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();
41 o <<
"************" << std::endl;
42 o <<
"a_pointcloud" << std::endl;
43 o <<
"************" << std::endl;
44 o <<
"The class derives from a_element." << std::endl;
45 o <<
"An object of this class is meant to store, manipulate and display a point cloud in a_canvas object" << std::endl;
46 o <<
"Commands:" << std::endl;
47 o <<
"--------" << std::endl;
48 o <<
"np: get number of points" << std::endl;
49 o <<
"clear: empty the object" << std::endl;
50 o <<
"eraselastpoint: erase the last drawn point" << std::endl;
51 o <<
"point 'x''y' 'z': add a point" << std::endl;
52 o <<
"point 'a_point': add a point" << std::endl;
53 o <<
"append 'a_pointcloud': add points from another a_pointcloud" << std::endl;
54 o <<
"dxfout 'file': export a dxf file with the points" << std::endl;
61 return polydata_->GetVerts()->GetNumberOfCells();
66 vtkPoints * points =
polydata_->GetPoints();
67 vtkIdType
pt = points->InsertNextPoint(x,y,z);
76 this->
point(x[0],x[1],x[2]);
81 this->
point(p.x(),p.y(),p.z());
87 vtkCellArray * old_pts =
polydata_->GetVerts();
88 vtkCellArray * new_pts = vtkCellArray::New();
89 old_pts->InitTraversal();
90 for (
int i = 0; i < old_pts->GetNumberOfCells()-1; i++)
93 const vtkIdType * pts =
nullptr;
94 old_pts->GetNextCell(npts, pts);
95 new_pts->InsertNextCell(npts, pts);
105 vtkMatrix4x4 * mat =
actor_->GetMatrix();
106 vtkCellArray * cells;
108 int n_pts =
polydata_->GetNumberOfVerts();
109 cells->InitTraversal();
110 for (
int k = 0; k < n_pts; k++)
113 const vtkIdType * ref_pt =
nullptr;
116 cells->GetNextCell(npt,ref_pt);
118 mat->MultiplyPoint(
pt,
pt);
119 o <<
" 0" << std::endl <<
"POINT" << std::endl;
120 o <<
" 8" << std::endl <<
name_ << std::endl;
121 o <<
" 10" << std::endl <<
pt[0] << std::endl;
122 o <<
" 20" << std::endl <<
pt[1] << std::endl;
123 o <<
" 30" << std::endl <<
pt[2] << std::endl;
129 vtkMatrix4x4 * mat =
actor_->GetMatrix();
130 vtkCellArray * cells;
132 int n_pts =
polydata_->GetNumberOfVerts();
133 std::vector<a_point>
cloud;
134 cells->InitTraversal();
135 for (
int k = 0; k < n_pts; k++)
138 const vtkIdType * ref_pt =
nullptr;
141 cells->GetNextCell(npt,ref_pt);
143 mat->MultiplyPoint(
pt,
pt);
155 for (
int i=0; i<n_pts; i++)
157 in >> x[0] >> x[1] >> x[2];
164 vtkMatrix4x4 * mat =
actor_->GetMatrix();
165 vtkCellArray * cells =
polydata_->GetVerts();
166 int n_pts =
polydata_->GetNumberOfVerts();
167 o << n_pts << std::endl;
168 cells->InitTraversal();
169 for (
int k = 0; k < n_pts; k++)
172 const vtkIdType * ref_pt =
nullptr;
175 cells->GetNextCell(npt,ref_pt);
177 mat->MultiplyPoint(
pt,
pt);
178 o <<
pt[0] <<
" " <<
pt[1] <<
" " <<
pt[2] << std::endl;
187 vtkCellArray * cells = l.
polydata_->GetVerts();
188 int n_pts = l.
polydata_->GetNumberOfVerts();
189 cells->InitTraversal();
190 for (
int k = 0; k < n_pts; k++)
193 const vtkIdType * ref_pt =
nullptr;
196 cells->GetNextCell(npt,ref_pt);
layer used by screen to draw vector graphics
void name(std::string &aname)
static const std::string help()
void thickness(const int)
void reset_mapper_clipping()
void color(double r, double g, double b)
layer used by screen to draw vector graphics
virtual void read(std::istream &in)
void append(const a_pointcloud &)
std::vector< a_point > cloud() const
void point(double x, double y, double z)
void reset_mapper_clipping()
void dxfout(std::ostream &o) const
static const std::string help()
virtual void write(std::ostream &o) const