17 #include "vtkPoints.h"
18 #include "vtkCellArray.h"
19 #include "vtkPolyDataMapper.h"
20 #include "vtkProperty.h"
21 #include "vtkDelaunay2D.h"
32 vtkPoints * points = vtkPoints::New();
36 vtkPolyDataMapper * map = vtkPolyDataMapper::New();
38 vtkMapper::SetResolveCoincidentTopologyToPolygonOffset();
41 actor_->GetProperty()->SetColor(0,0,0);
46 vtkPolyDataMapper * map2 = vtkPolyDataMapper::New();
48 vtkMapper::SetResolveCoincidentTopologyToPolygonOffset();
51 actor2_->GetProperty()->SetColor(0,0,0);
71 actor_->GetProperty()->SetColor(1,1,1);
75 actor2_->GetProperty()->SetColor(1,1,1);
85 if ((r>=0)&&(g>=0)&&(b>=0)&&(r<=1)&&(g<=1)&&(b<=1))
87 actor_->GetProperty()->SetColor(r,g,b);
88 actor2_->GetProperty()->SetColor(r,g,b);
135 actor_->GetProperty()->SetPointSize(
v);
136 actor_->GetProperty()->SetLineWidth(
v);
137 actor2_->GetProperty()->SetLineWidth(
v);
147 vtkCellArray * vertices = vtkCellArray::New();
152 vtkPoints * points =
polydata_->GetPoints();
153 pt[0] = points->InsertNextPoint(x[0],x[1],x[2]);
155 points->GetData()->Modified();
164 vtkCellArray * vertices = vtkCellArray::New();
168 vtkPoints * points =
polydata_->GetPoints();
169 vtkIdType
pt = points->InsertNextPoint(x,y,z);
171 points->GetData()->Modified();
180 vtkCellArray * lines = vtkCellArray::New();
185 vtkPoints * points =
polydata_->GetPoints();
186 pt[0] = points->InsertNextPoint(x[0],x[1],x[2]);
187 pt[1] = points->InsertNextPoint(x[3],x[4],x[5]);
189 points->GetData()->Modified();
198 vtkCellArray * lines = vtkCellArray::New();
203 vtkPoints * points =
polydata_->GetPoints();
204 pt[0] = points->InsertNextPoint(x1,y1,z1);
205 pt[1] = points->InsertNextPoint(
x2,y2,z2);
207 points->GetData()->Modified();
232 vtkCellArray * polylines = vtkCellArray::New();
237 vtkCellArray * lines =
polydata2_->GetLines();
243 int p = points->InsertNextPoint(xp);
245 lines->InsertCellPoint(p);
249 points->GetData()->Modified();
261 vtkCellArray * polylines = vtkCellArray::New();
266 vtkCellArray * lines =
polydata2_->GetLines();
273 int p = points->InsertNextPoint(xp);
274 lines->InsertCellPoint(p);
277 lines->InsertCellPoint(p0);
280 points->GetData()->Modified();
293 vtkPolyData * data = vtkPolyData::New();
296 vtkDelaunay2D * del = vtkDelaunay2D::New();
297 del->SetInputData(data);
299 del->SetTolerance(0.001);
300 vtkPolyDataMapper * map = vtkPolyDataMapper::New();
301 map->SetInputConnection(del->GetOutputPort());
302 vtkMapper::SetResolveCoincidentTopologyToPolygonOffset();
313 vtkCellArray * old_pts =
polydata_->GetVerts();
314 vtkCellArray * new_pts = vtkCellArray::New();
315 old_pts->InitTraversal();
316 for (
int i = 0; i < old_pts->GetNumberOfCells()-1; i++)
319 const vtkIdType * pts =
nullptr;
320 old_pts->GetNextCell(npts, pts);
321 new_pts->InsertNextCell(npts, pts);
332 vtkCellArray * old_lis =
polydata_->GetLines();
333 vtkCellArray * new_lis = vtkCellArray::New();
334 old_lis->InitTraversal();
335 for (
int i = 0; i < old_lis->GetNumberOfCells()-1; i++)
338 const vtkIdType * pts =
nullptr;
339 old_lis->GetNextCell(npts, pts);
340 new_lis->InsertNextCell(npts, pts);
350 vtkCellArray * old_lis =
polydata2_->GetLines();
351 vtkCellArray * new_lis = vtkCellArray::New();
352 old_lis->InitTraversal();
353 for (
int i = 0; i < old_lis->GetNumberOfCells()-1; i++)
356 const vtkIdType * pts =
nullptr;
357 old_lis->GetNextCell(npts, pts);
358 new_lis->InsertNextCell(npts, pts);
368 const vtkIdType * ref_pt =
nullptr;
373 vtkCellArray * cells;
375 cells->InitTraversal();
378 stop = cells->GetNextCell(npt,ref_pt);
382 o <<
" 0" << std::endl <<
"POINT" << std::endl;
383 o <<
" 8" << std::endl <<
name_ << std::endl;
384 o <<
" 10" << std::endl <<
pt[0] << std::endl;
385 o <<
" 20" << std::endl <<
pt[1] << std::endl;
386 o <<
" 30" << std::endl <<
pt[2] << std::endl;
393 cells->InitTraversal();
397 stop = cells->GetNextCell(npt,ref_pt);
401 o <<
" 0" << std::endl <<
"LINE" << std::endl;
402 o <<
" 8" << std::endl <<
name_ << std::endl;
403 o <<
" 10" << std::endl <<
pt[0] << std::endl;
404 o <<
" 20" << std::endl <<
pt[1] << std::endl;
405 o <<
" 30" << std::endl <<
pt[2] << std::endl;
407 o <<
" 11" << std::endl <<
pt[0] << std::endl;
408 o <<
" 21" << std::endl <<
pt[1] << std::endl;
409 o <<
" 31" << std::endl <<
pt[2] << std::endl;
416 cells->InitTraversal();
419 stop = cells->GetNextCell(npt,ref_pt);
422 o <<
" 0" << std::endl <<
"POLYLINE" << std::endl;
423 o <<
" 8" << std::endl <<
name_ << std::endl;
424 o <<
" 66" << std::endl << 1 << std::endl;
425 o <<
" 70" << std::endl << 8 << std::endl;
426 for (
int j=0; j<npt; j++)
429 o <<
" 0" << std::endl <<
"VERTEX" << std::endl;
430 o <<
" 8" << std::endl <<
name_ << std::endl;
431 o <<
" 10" << std::endl <<
pt[0] << std::endl;
432 o <<
" 20" << std::endl <<
pt[1] << std::endl;
433 o <<
" 30" << std::endl <<
pt[2] << std::endl;
434 o <<
" 70" << std::endl << 32 << std::endl;
436 o <<
" 0" << std::endl <<
"SEQEND" << std::endl;
437 o <<
" 8" << std::endl <<
name_ << std::endl;
445 vtkPolyData * data = (vtkPolyData *)(
surface_actor_->GetMapper()->GetInput());
446 vtkCellArray * triangles = data->GetPolys();
449 triangles->InitTraversal();
453 const vtkIdType * ref_pt =
nullptr;
454 stop = triangles->GetNextCell(npt,ref_pt);
459 data->GetPoint(ref_pt[0],
pt);
460 o <<
" 0" << std::endl <<
"3DFACE" << std::endl;
461 o <<
" 8" << std::endl <<
name_ << std::endl;
462 o <<
" 10" << std::endl <<
pt[0] << std::endl;
463 o <<
" 20" << std::endl <<
pt[1] << std::endl;
464 o <<
" 30" << std::endl <<
pt[2] << std::endl;
465 data->GetPoint(ref_pt[1],
pt);
466 o <<
" 11" << std::endl <<
pt[0] << std::endl;
467 o <<
" 21" << std::endl <<
pt[1] << std::endl;
468 o <<
" 31" << std::endl <<
pt[2] << std::endl;
469 data->GetPoint(ref_pt[2],
pt);
470 o <<
" 12" << std::endl <<
pt[0] << std::endl;
471 o <<
" 22" << std::endl <<
pt[1] << std::endl;
472 o <<
" 32" << std::endl <<
pt[2] << std::endl;
473 o <<
" 13" << std::endl <<
pt[0] << std::endl;
474 o <<
" 23" << std::endl <<
pt[1] << std::endl;
475 o <<
" 33" << std::endl <<
pt[2] << std::endl;
487 for (
int i=0; i<n_pts; i++)
489 in >> x[0] >> x[1] >> x[2];
497 const vtkIdType * ref_pt =
nullptr;
502 vtkCellArray * cells;
503 int n_pts =
polydata_->GetNumberOfVerts();
505 o << n_pts << std::endl;
506 cells->InitTraversal();
509 stop = cells->GetNextCell(npt,ref_pt);
513 o <<
pt[0] <<
"\t" <<
pt[1] <<
"\t" <<
pt[2] << std::endl;
529 int n_point,n_line,n_polyline;
530 i >> n_point >> n_line >> n_polyline;
532 for (
int k = 0; k < n_point; k++)
534 i >> x[0] >> x[1] >> x[2];
537 for (
int k = 0; k < n_line; k++)
539 i >> x[0] >> x[1] >> x[2];
540 i >> x[3] >> x[4] >> x[5];
543 for (
int k = 0; k < n_polyline; k++)
547 for (
int j=0; j<
n; j++)
549 i >> x[0] >> x[1] >> x[2];
554 if ((n_point != 0)||(n_line != 0)||(n_polyline != 0))
562 o << l.
name() << std::endl;
563 o << l.
R() <<
" " << l.
G() <<
" " << l.
B() << std::endl;
565 o << l.
polydata_->GetVerts()->GetNumberOfCells() <<
" ";
566 o << l.
polydata_->GetLines()->GetNumberOfCells() <<
" ";
567 o << l.
polydata2_->GetLines()->GetNumberOfCells() << std::endl;
570 const vtkIdType * ref_pt =
nullptr;
575 vtkCellArray * cells;
577 cells->InitTraversal();
580 stop = cells->GetNextCell(npt,ref_pt);
584 o <<
pt[0] <<
" " <<
pt[1] <<
" " <<
pt[2] << std::endl;
591 cells->InitTraversal();
595 stop = cells->GetNextCell(npt,ref_pt);
599 o <<
pt[0] <<
" " <<
pt[1] <<
" " <<
pt[2] <<
" ";
601 o <<
pt[0] <<
" " <<
pt[1] <<
" " <<
pt[2] << std::endl;
608 cells->InitTraversal();
611 stop = cells->GetNextCell(npt,ref_pt);
614 o << npt << std::endl;
615 for (
int i=0; i<npt; i++)
618 o <<
pt[0] <<
" " <<
pt[1] <<
" " <<
pt[2] << std::endl;
629 std::ifstream ff(file.c_str());
635 std::ofstream ff(file.c_str());
648 const vtkIdType * ref_pt =
nullptr;
654 vtkCellArray * cells;
656 cells->InitTraversal();
659 stop = cells->GetNextCell(npt,ref_pt);
663 this->
point(pt1[0],pt1[1],pt1[2]);
670 cells->InitTraversal();
674 stop = cells->GetNextCell(npt,ref_pt);
679 this->
line(pt1[0],pt1[1],pt1[2],pt2[0],pt2[1],pt2[2]);
686 cells->InitTraversal();
689 stop = cells->GetNextCell(npt,ref_pt);
692 for (
int i=0; i<npt; i++)
695 this->
vertex(pt1[0],pt1[1],pt1[2]);
708 actor_->GetMapper()->Update();
709 actor_->GetMapper()->GetBounds(b);
713 std::cout <<
name_ <<
": ";
714 for (
int k=0; k<6; k++) std::cout << b[k] <<
" ";
715 std::cout << std::endl;
722 for (
int i = 0; i <
v.size(); i++)
void d_v(a_screenlayer *la)
void delete_vector(std::vector< a_screenlayer * > &v)
std::istream & operator>>(std::istream &i, a_screenlayer &l)
std::ostream & operator<<(std::ostream &o, const a_screenlayer &l)
layer used by screen to draw vector graphics
void append(const a_screenlayer &)
void surfacepoint(double x, double y, double z)
void name(std::string aname)
void color(float r, float g, float b)
vtkPoints * points_polyline_
void vertex(double x, double y, double z)
void reset_mapper_clipping()
void line(double x1, double y1, double z1, double x2, double y2, double z2)
vtkActor * surface_actor_
void thickness(const int)
void ptout(std::ostream &o) const
void point(double x, double y, double z)
vtkPoints * surface_points_
void dxfout(std::ostream &o) const
void save(const std::string file)
void ptin(std::istream &in)
void open(const std::string file)
int number_of_surface_point_
double v(const uint32_t step, const uint32_t n)