Developer documentation | Axl-2.5.1

axlPointSetConverter.cpp
Go to the documentation of this file.
1 /* axlPointSetConverter.cpp ---
2  *
3  * Author: Julien Wintz
4  * Copyright (C) 2008-2011 - Julien Wintz, Inria.
5  * Created: Tue Jan 24 11:03:18 2012 (+0100)
6  * Version: $Id$
7  * Last-Updated: Tue Jan 24 11:27:25 2012 (+0100)
8  * By: Julien Wintz
9  * Update #: 50
10  */
11 
12 /* Commentary:
13  *
14  */
15 
16 /* Change log:
17  *
18  */
19 
20 #include "axlMesh.h"
21 #include "axlPointSetConverter.h"
22 #include "axlPointSet.h"
23 #include <dtkCoreSupport/dtkAbstractDataFactory.h>
24 
25 class axlPointSetConverterPrivate
26 {
27 public:
28  axlPointSet *data;
29 };
30 
31 axlPointSetConverter::axlPointSetConverter(void) : axlAbstractDataConverter(), d(new axlPointSetConverterPrivate)
32 {
33  d->data = NULL;
34 }
35 
37 {
38  delete d;
39 
40  d = NULL;
41 }
42 
44 {
45  return "Converter from axlPointSetConverter to axlMesh";
46 }
47 
48 QStringList axlPointSetConverter::fromTypes(void) const
49 {
50  return QStringList() << "axlPointSetConverter" << "axlPointSet";
51 }
52 
53 QString axlPointSetConverter::toType (void) const
54 {
55  return "axlMesh";
56 }
57 
59 {
60  return dtkAbstractDataFactory::instance()->registerDataConverterType("axlPointSetConverter", QStringList(), "axlMesh", createaxlPointSetConverter);
61 }
62 
64 {
65  if(!d->data)
66  return NULL;
67 
68  axlMesh *mesh = new axlMesh;
69 
70  for(int i = 0 ; i < d->data->numberOfPoints() ; i++)
71  mesh->push_back_vertex(d->data->value(i));
72 
73 
74  return mesh;
75 }
76 
77 void axlPointSetConverter::setData(dtkAbstractData *data)
78 {
79  if(axlPointSet *point = dynamic_cast<axlPointSet *>(data))
80  d->data = point;
81 }
82 
83 dtkAbstractDataConverter *createaxlPointSetConverter(void)
84 {
85  return new axlPointSetConverter;
86 }
QString description(void) const
static bool registered(void)
QString toType(void) const
dtkAbstractDataConverter * createaxlPointSetConverter(void)
QStringList fromTypes(void) const
void setData(dtkAbstractData *data)
Class axlMesh defines a piecewise-linear 3D object.
Definition: axlMesh.h:41
void push_back_vertex(const double &x, const double &y, const double &z)
Add a new vertex to the mesh.
Definition: axlMesh.cpp:333