18 #include "vtkCleanPolyData.h"
19 #include "vtkPoints.h"
20 #include "vtkCellArray.h"
21 #include "vtkPolyData.h"
22 #include "vtkPolyDataMapper.h"
23 #include "vtkProperty.h"
24 #include "vtkMatrix4x4.h"
30 vtkPoints * points = vtkPoints::New();
31 vtkCellArray * lines = vtkCellArray::New();
43 vtkPoints * points = vtkPoints::New();
44 vtkCellArray * lines = vtkCellArray::New();
62 o <<
"***********" << std::endl;
63 o <<
"a_linecloud" << std::endl;
64 o <<
"***********" << std::endl;
65 o <<
"The class derives from a_element." << std::endl;
66 o <<
"An object of this class is meant to store, manipulate and display a line cloud in a_canvas object" << std::endl;
67 o <<
"Commands:" << std::endl;
68 o <<
"--------" << std::endl;
69 o <<
"nl: get number of lines" << std::endl;
70 o <<
"clear: empty the object" << std::endl;
72 o <<
"line 'x1' 'y1' 'z2' 'x1' 'y2' 'z': add a line" << std::endl;
73 o <<
"line 'a_point' 'a_point'" << std::endl;
74 o <<
"append 'a_linecloud': add lines from another a_linecloud" << std::endl;
75 o <<
"dxfout 'file': export a dxf file with the points" << std::endl;
91 for (
int i=0; i<c.
nl(); i++)
106 return polydata_->GetLines()->GetNumberOfCells();
114 vtkPoints * points =
polydata_->GetPoints();
115 vtkCellArray * lines =
polydata_->GetLines();
116 for (
int i=0; i<n_pts; i++)
118 vtkIdType r[] = {0,0};
119 for (
int j=0; j<2; j++)
121 in >> x[0] >> x[1] >> x[2];
122 r[j] = points->InsertNextPoint(x);
124 int ref = lines->InsertNextCell(2,r);
126 vtkCleanPolyData * clean = vtkCleanPolyData::New();
128 clean->SetTolerance(0.);
129 clean->PointMergingOn();
136 vtkMatrix4x4 * mat =
actor_->GetMatrix();
137 vtkCellArray * lines_n =
polydata_->GetLines();
138 int n_lis =
polydata_->GetNumberOfLines();
139 o << n_lis << std::endl;
140 lines_n->InitTraversal();
141 for (
int k = 0; k < n_lis; k++)
144 const vtkIdType * ref_pt =
nullptr;
147 pt2[3] = pt1[3] = 1.;
148 lines_n->GetNextCell(npt,ref_pt);
151 mat->MultiplyPoint(pt1,pt1);
152 mat->MultiplyPoint(pt2,pt2);
153 o << pt1[0] <<
' ' << pt1[1] <<
' ' << pt1[2] <<
' ';
154 o << pt2[0] <<
' ' << pt2[1] <<
' ' << pt2[2] << std::endl;
160 if ((ref<0)||(ref>this->
nl()))
162 vtkMatrix4x4 * mat =
actor_->GetMatrix();
164 const vtkIdType * ref_pt =
nullptr;
165 vtkCell * cell =
polydata_->GetCell(ref);
166 vtkPoints * points =
polydata_->GetPoints();
169 points->GetPoint(cell->GetPointId(0),x);
170 mat->MultiplyPoint(x,x);
171 p1.set(x[0],x[1],x[2]);
172 points->GetPoint(cell->GetPointId(1),x);
173 mat->MultiplyPoint(x,x);
174 p2.set(x[0],x[1],x[2]);
179 vtkCellArray * lines =
polydata_->GetLines();
183 int ref = lines->InsertNextCell(2,p);
layer used by screen to draw vector graphics
int addpoint(const a_point &p)
static const std::string help()
layer used by screen to draw vector graphics
a_linecloud & operator+=(const a_linecloud &c)
int addline(const a_point &p1, const a_point &p2)
static const std::string help()
void append(const a_linecloud &)
void write(std::ostream &o) const
void dxfout(std::ostream &o) const
void read(std::istream &in)
void getline(const int ref, a_point &p1, a_point &p2) const