Developer documentation | Axl-2.5.1

axlTabulatedCylinderConverter.cpp
Go to the documentation of this file.
2 #include "axlTabulatedCylinder.h"
3 #include "axlSamplingCurve.h"
4 
5 #include <axlCore/axlMesh.h>
6 #include <dtkCoreSupport/dtkAbstractDataFactory.h>
7 
8 
9 class axlTabulatedCylinderConverterPrivate
10 {
11 public:
13 };
14 
16 {
17  d->data = NULL;
18 };
19 
21 {
22  delete d;
23  d = NULL;
24 }
25 
27 {
28  return "Converter from axlTabulatedCylinder to axlMesh";
29 }
30 
32 {
33  return "axlTabulatedCylinderConverter";
34 }
35 
37 {
38  return QStringList() << "axlTabulatedCylinderConverter" << "axlTabulatedCylinder";
39 }
41 {
42  return "axlMesh";
43 }
44 
46 {
47  return dtkAbstractDataFactory::instance()->registerDataConverterType("axlTabulatedCylinderConverter", QStringList(), "axlMesh", createaxlTabulatedCylinderConverter);
48 }
49 
51 {
52  if(!d->data)
53  return NULL;
54 
55 
56  axlMesh *mesh = new axlMesh();
57  QList<axlPoint *> $list;
58  $list.append(Sampling(d->data->get_pt_directrix()));
59  axlPoint *$pt = d->data->get_pt_generatrix();
60  for(int i = 0; i<$list.size(); ++i)
61  {
62  mesh->push_back_vertex($list.value(i));
63  mesh->push_back_vertex(*$list.value(i)+ *$pt);
64  if(i>0)
65  {
66  /*axlMesh::Face face(4);*/
67  /*face<<2*i<<2*i+1<<2*i+3<<2*i+2;*/
68  mesh->push_back_face(2*i-2, 2*i-1, 2*i);
69  mesh->push_back_face(2*i-1, 2*i,2*i+1);
70  /*mesh->push_back_face(face);*/
71  mesh->push_back_edge(2*i-2, 2*i);
72  mesh->push_back_edge(2*i-1, 2*i+1);
73  }
74  }
75 
76  mesh->push_back_edge(0,1);
77  mesh->push_back_edge(2*($list.size()-1),2*($list.size()-1)+1);
78 
79  mesh->vertex_show() = false;
80  mesh->normal_used() = false;
81  mesh->color_used() = false;
82  mesh->edge_show() = true;
83  mesh->face_show() = true;
84 
85  return mesh;
86 }
87 
88 void axlTabulatedCylinderConverter::setData(dtkAbstractData *data)
89 {
90  if(axlTabulatedCylinder *Data = dynamic_cast<axlTabulatedCylinder *>(data))
91  d->data = Data;
92 }
93 
94 dtkAbstractDataConverter *createaxlTabulatedCylinderConverter(void)
95 {
97 }
Class axlPoint defines 3D points.
Definition: axlPoint.h:34
bool vertex_show(void) const
Definition: axlMesh.cpp:159
void push_back_edge(int, int)
Definition: axlMesh.cpp:669
bool normal_used(void) const
Definition: axlMesh.cpp:170
dtkAbstractDataConverter * createaxlTabulatedCylinderConverter(void)
bool edge_show(void) const
Definition: axlMesh.cpp:190
QList< axlPoint * > Sampling(axlAbstractCurve *curve)
bool face_show(void) const
Definition: axlMesh.cpp:200
void push_back_face(const Face &face)
Definition: axlMesh.cpp:735
bool color_used(void) const
Definition: axlMesh.cpp:180
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