17 #include "vtkPoints.h"
18 #include "vtkCellArray.h"
19 #include "vtkPolyDataMapper.h"
20 #include "vtkProperty.h"
21 #include "vtkMatrix4x4.h"
27 vtkPoints * points = vtkPoints::New();
28 vtkCellArray * triangles = vtkCellArray::New();
40 vtkPoints * points = vtkPoints::New();
41 vtkCellArray * triangles = vtkCellArray::New();
59 o <<
"***************" << std::endl;
60 o <<
"a_trianglecloud" << std::endl;
61 o <<
"***************" << std::endl;
62 o <<
"The class derives from a_element." << std::endl;
63 o <<
"An object of this class is meant to store, manipulate and display a triangle cloud in a_canvas object" << std::endl;
64 o <<
"Commands:" << std::endl;
65 o <<
"--------" << std::endl;
66 o <<
"nt: get number of triangles" << std::endl;
67 o <<
"clear: empty the object" << std::endl;
69 o <<
"triangle 'x1' 'y1' 'z1' 'x2' 'y2' 'z2' 'x3' 'y3' 'z3': add a triangle" << std::endl;
70 o <<
"triangle 'a_point' 'a_point' 'a_point': add a triangle" << std::endl;
71 o <<
"append 'a_pointcloud': add triangles from another a_trianglecloud" << std::endl;
90 for (
int i=0; i<c.
nt(); i++)
101 return polydata_->GetPolys()->GetNumberOfCells();
113 vtkPoints * points =
polydata_->GetPoints();
114 for (
int i=0; i<n_pts; i++)
116 in >> x[0] >> x[1] >> x[2];
117 points->InsertNextPoint(x);
121 vtkCellArray * triangles =
polydata_->GetPolys();
122 for (
int k = 0; k < n_tris; k++)
125 for (
int l = 0; l < 3; l++)
127 triangles->InsertNextCell(3,p);
133 vtkMatrix4x4 * mat =
actor_->GetMatrix();
134 vtkPoints * pts_n =
polydata_->GetPoints();
135 int n_pts = pts_n->GetNumberOfPoints();
136 o << n_pts << std::endl;
137 for (
int k = 0; k < n_pts; k++)
141 pts_n->GetPoint(k,x);
142 mat->MultiplyPoint(x,x);
143 o << x[0] <<
'\t' << x[1] <<
'\t' << x[2] << std::endl;
145 vtkCellArray * triangles_n =
polydata_->GetPolys();
147 o <<
n_tri << std::endl;
148 triangles_n->InitTraversal();
149 for (
int k = 0; k <
n_tri; k++)
152 const vtkIdType * ref_pt =
nullptr;
153 triangles_n->GetNextCell(npt,ref_pt);
154 o << ref_pt[0] <<
'\t' << ref_pt[1] <<
'\t' << ref_pt[2] << std::endl;
182 if ((ref<0)||(ref>this->
nt()))
184 vtkMatrix4x4 * mat =
actor_->GetMatrix();
185 vtkCellArray * triangles =
polydata_->GetPolys();
187 const vtkIdType * ref_pt =
nullptr;
188 triangles->GetCell(ref, npt, ref_pt);
189 vtkPoints * points =
polydata_->GetPoints();
192 points->GetPoint(ref_pt[0],x);
193 mat->MultiplyPoint(x,x);
194 p1.set(x[0],x[1],x[2]);
195 points->GetPoint(ref_pt[1],x);
196 mat->MultiplyPoint(x,x);
197 p2.set(x[0],x[1],x[2]);
198 points->GetPoint(ref_pt[2],x);
199 mat->MultiplyPoint(x,x);
200 p3.set(x[0],x[1],x[2]);
205 vtkCellArray * triangles =
polydata_->GetPolys();
210 return triangles->InsertNextCell(3,p);
layer used by screen to draw vector graphics
int addpoint(const a_point &p)
static const std::string help()
void reset_mapper_clipping()
layer used by screen to draw vector graphics
void dxfout(std::ostream &o) const
void append(const a_trianglecloud &)
static const std::string help()
void read(std::istream &in)
void gettriangle(const int ref, a_point &p1, a_point &p2, a_point &p3) const
void reset_mapper_clipping()
a_trianglecloud & operator+=(const a_trianglecloud &c)
int addtriangle(const a_point &p1, const a_point &p2, const a_point &p3)
void write(std::ostream &o) const