Developer documentation | Axl-2.5.1

axlCurveOnParamSurfaceConverter.cpp
Go to the documentation of this file.
3 #include "axlSamplingCurve.h"
4 
5 #include <axlCore/axlMesh.h>
6 #include <dtkCore/dtkAbstractDataFactory.h>
7 
8 
9 class axlCurveOnParamSurfaceConverterPrivate
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 axlCurveOnParamSurface to axlMesh";
29 }
30 
32 {
33  return "axlCurveOnParamSurfaceConverter";
34 }
35 
37 {
38  return QStringList() << "axlCurveOnParamSurfaceConverter" << "axlCurveOnParamSurface";
39 }
40 
42 {
43  return "axlMesh";
44 }
45 
47 {
48  return dtkAbstractDataFactory::instance()->registerDataConverterType("axlCurveOnParamSurfaceConverter", QStringList(), "axlMesh", createaxlCurveOnParamSurfaceConverter);
49 }
50 
52 {
53  if(!d->data)
54  return NULL;
55  axlMesh *mesh = new axlMesh();
56  axlAbstractSurfaceParametric main = d->data->get_main_surface();
57  if(d->data->get_way_create_curve()==1)
58  {
59 
60  }
61  else if(d->data->get_way_create_curve()==2)
62  {
63 
64  }
65  else if(d->data->get_way_create_curve()==3)
66  {
67  if(axlLine *line = dynamic_cast<axlLine *>(d->data->get_support_curve_param_domain()))
68  {
69  axlPoint *endPoint1 = line->firstPoint();
70  axlPoint direct = *(line->secondPoint()) - *(line->firstPoint());
71 
72  for(int i = 0; i<41; i++)
73  {
74  axlPoint temp = *endPoint1 + direct*((double)i/40.0);
75  mesh->push_back_vertex(main.eval(temp.x(),temp.y()));
76  }
77 
78  for(int i = 0; i<40; i++)
79  {
80  mesh->push_back_edge(i,i+1);
81  }
82  }
83  else
84  {
85  QList<axlPoint *> list_point = Sampling(d->data->get_support_curve_param_domain());
86 
87  for(int i = 0; i<list_point.size(); i++)
88  {
89  mesh->push_back_vertex(main.eval(list_point.value(i)->x(),list_point.value(i)->y()));
90  }
91 
92  for(int i = 0; i<list_point.size() - 1; i++)
93  {
94  mesh->push_back_edge(i,i+1);
95  }
96  }
97  }
98 
99  //QList<axlPoint *> $list;
100  //$list.append(Sampling(d->data->get_pt_directrix()));
101  //axlPoint *$pt = d->data->get_pt_generatrix();
102  //for(int i = 0; i<$list.size(); ++i)
103  //{
104  // mesh->push_back_vertex($list.value(i));
105  // mesh->push_back_vertex(*$list.value(i)+ *$pt);
106  // if(i>0)
107  // {
108  // /*axlMesh::Face face(4);*/
109  // /*face<<2*i<<2*i+1<<2*i+3<<2*i+2;*/
110  // mesh->push_back_face(2*i-2, 2*i-1, 2*i);
111  // mesh->push_back_face(2*i-1, 2*i,2*i+1);
112  // /*mesh->push_back_face(face);*/
113  // mesh->push_back_edge(2*i-2, 2*i);
114  // mesh->push_back_edge(2*i-1, 2*i+1);
115  // }
116  //}
117 
118  //mesh->push_back_edge(0,1);
119  // mesh->push_back_edge(2*($list.size()-1),2*($list.size()-1)+1);
120 
121  mesh->vertex_show() = false;
122  mesh->normal_used() = false;
123  mesh->color_used() = false;
124  mesh->edge_show() = true;
125  mesh->face_show() = false;
126 
127  return mesh;
128 }
129 
130 void axlCurveOnParamSurfaceConverter::setData(dtkAbstractData *data)
131 {
132  if(axlCurveOnParamSurface *Data = dynamic_cast<axlCurveOnParamSurface *>(data))
133  d->data = Data;
134 }
135 
136 dtkAbstractDataConverter *createaxlCurveOnParamSurfaceConverter(void)
137 {
139 }
Class axlPoint defines 3D points.
Definition: axlPoint.h:34
Class axlLine defines 3D lines.
Definition: axlLine.h:35
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
virtual axlPoint eval(double u, double v)
bool edge_show(void) const
Definition: axlMesh.cpp:190
dtkAbstractDataConverter * createaxlCurveOnParamSurfaceConverter(void)
QList< axlPoint * > Sampling(axlAbstractCurve *curve)
bool face_show(void) const
Definition: axlMesh.cpp:200
double y
Definition: axlPoint.h:37
bool color_used(void) const
Definition: axlMesh.cpp:180
double x
Definition: axlPoint.h:37
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