18 #include "vtkCamera.h"
19 #include "vtkRenderWindow.h"
20 #include "vtkRenderWindowInteractor.h"
21 #include "vtkPolyData.h"
22 #include "vtkPoints.h"
23 #include "vtkProperty.h"
24 #include "vtkCellArray.h"
25 #include "vtkPolyDataMapper.h"
27 #include "a_profile_edit_interactor.h"
39 int npts = prof->
size();
40 vtkPoints * pts = vtkPoints::New();
41 for (
int i = 0; i < npts; i++)
42 pts->InsertNextPoint((*prof)[i]->x(),(*prof)[i]->y(),(*prof)[i]->z());
43 vtkCellArray * vertices = vtkCellArray::New();
44 vtkCellArray * lines = vtkCellArray::New();
45 for (
int i = 0; i < npts-1; i++)
47 vertices->InsertNextCell(1,&i);
49 lines->InsertNextCell(2,p);
51 vtkPolyData * data = vtkPolyData::New();
54 data->SetVerts(vertices);
56 data->SetLines(lines);
58 vtkPolyDataMapper * map = vtkPolyDataMapper::New();
61 vtkActor * actor = vtkActor::New();
62 actor->SetMapper(map);
64 actor->GetProperty()->SetPointSize(3);
74 double bx = (
bd_[1]-
bd_[0])/2.;
75 double by = (
bd_[3]-
bd_[2])/2.;
76 vtkPoints * pts = vtkPoints::New();
77 pts->InsertNextPoint(
bd_[0]-bx,
bd_[2]-by,0.);
78 pts->InsertNextPoint(
bd_[1]+bx,
bd_[2]-by,0.);
79 pts->InsertNextPoint(
bd_[0]-bx,
bd_[3]+by,0.);
80 pts->InsertNextPoint(
bd_[1]+bx,
bd_[3]+by,0.);
81 vtkCellArray *
tri = vtkCellArray::New();
83 tri->InsertNextCell(3,pp);
84 pp[0] = 1; pp[1] = 3; pp[2] = 2;
85 tri->InsertNextCell(3,pp);
86 vtkPolyData * data = vtkPolyData::New();
91 vtkPolyDataMapper * map = vtkPolyDataMapper::New();
94 map->SetResolveCoincidentTopologyToPolygonOffset();
96 vtkActor * actor = vtkActor::New();
97 actor->SetMapper(map);
98 actor->GetProperty()->SetColor(.1,.1,.1);
100 actor->DragableOff();
102 ren->AddActor(actor);
111 RGB[0] = 1; RGB[1] = 0; RGB[2] = 0;
114 RGB[0] = 0; RGB[1] = 1; RGB[2] = 0;
117 RGB[0] = 0; RGB[1] = 0; RGB[2] = 1;
120 RGB[0] = 1; RGB[1] = 1; RGB[2] = 0;
123 RGB[0] = 0; RGB[1] = 1; RGB[2] = 1;
126 RGB[0] = 1; RGB[1] = 0; RGB[2] = 1;
134 int npts = prof->
size();
135 vtkPoints * pts = vtkPoints::New();
136 for (
int i = 0; i < npts; i++)
137 pts->InsertNextPoint((*prof)[i]->x(),(*prof)[i]->y(),(*prof)[i]->z());
138 double bx = (
bd_[1]-
bd_[0])/50.;
139 double by = (
bd_[3]-
bd_[2])/50.;
140 pts->InsertNextPoint(0.,0.,0.);
141 pts->InsertNextPoint(bx,0.,0.);
142 pts->InsertNextPoint(0.,by,0.);
143 pts->InsertNextPoint(bx,by,0.);
144 vtkCellArray * vertices = vtkCellArray::New();
145 for (
int i = 0; i < npts; i++)
146 vertices->InsertNextCell(1,&i);
147 vtkCellArray * handle = vtkCellArray::New();
148 int p[] = {npts,npts+1,npts+2};
149 handle->InsertNextCell(3,p);
150 p[0] = npts+1; p[1] = npts+3; p[2] = npts+2;
151 handle->InsertNextCell(3,p);
152 vtkPolyData * data = vtkPolyData::New();
153 data->SetPoints(pts);
155 data->SetVerts(vertices);
157 data->SetPolys(handle);
159 vtkPolyDataMapper * map = vtkPolyDataMapper::New();
162 vtkActor * actor = vtkActor::New();
163 actor->SetMapper(map);
165 actor->GetProperty()->SetPointSize(2);
168 actor->GetProperty()->SetColor(RGB);
169 ren->AddActor(actor);
178 std::vector<a_point> newpoints;
181 vtkRenderer *
ren = vtkRenderer::New();
182 vtkRenderWindow * renWin = vtkRenderWindow::New();
183 renWin->AddRenderer(
ren);
185 a_profile_edit_interactor * style = a_profile_edit_interactor::New();
186 style->setpoints(&newpoints);
187 style->SetPickColor(.5,1.,1.);
188 vtkRenderWindowInteractor * iren = vtkRenderWindowInteractor::New();
189 iren->SetRenderWindow(renWin);
191 iren->SetInteractorStyle(style);
199 ren->GetActiveCamera()->ParallelProjectionOn();
200 renWin->SetSize(640,480);
203 renWin->SetWindowName(
"profile_edit");
206 if (newpoints.size()>0)
209 for (
auto pt:newpoints)
211 auto x =
new a_point(
pt);
214 newprofile.
place3D(origin,x_axis,y_axis);
215 std::cout << std::fixed << std::setprecision(precision);
216 std::cout << newprofile;
std::ostream & operator<<(std::ostream &o, const a_profile_edit &p)
std::istream & operator>>(std::istream &in, a_profile_edit &p)
void getcolor(int ref, double *RGB)
a curve with linear interpolation
void addpoint(a_point *pt)
a_curve & place3D(a_point &origin, a_point &x_axis, a_point &y_axis)
std::vector< a_curve_lin * > profiles_ref_
void draw_refprof(a_curve_lin *prof, vtkRenderer *ren)
void draw_plan(vtkRenderer *ren)
void draw_prof(a_curve_lin *prof, vtkRenderer *ren)
void tri(const uint32_t i, const uint32_t j)