15 #include "vtkImageData.h"
16 #include <vtkPointData.h>
17 #include <vtkUnsignedCharArray.h>
18 #include <vtkPolyData.h>
19 #include <vtkCellArray.h>
20 #include <vtkFloatArray.h>
21 #include <vtkPolyLine.h>
22 #include <vtkClipPolyData.h>
25 #include <vtkPlanes.h>
26 #include <vtkCutter.h>
27 #include <vtkAppendPolyData.h>
44 mPolyData = vtkPolyDataPtr::New();
61 mData(data), m_vMu(uMv.inv())
72 return this->insideClipRect(p_v) && this->insideSector(p_v);
81 bool insideClipRect(
const Vector3D& p_v)
const
91 bool insideSector(
const Vector3D& p_v)
const
97 double angle = atan2(d[1], d[0]);
102 if (fabs(angle) > mData.
getWidth() / 2.0)
112 if (fabs(d[0]) > mData.
getWidth() / 2.0)
122 ProbeDefinition mData;
125 DoubleBoundingBox3D mClipRect_v;
140 int* dim(retval->GetDimensions());
141 unsigned char* dataPtr =
static_cast<unsigned char*
> (retval->GetScalarPointer());
142 for (
int x = 0; x < dim[0]; x++)
143 for (
int y = 0; y < dim[1]; y++)
145 dataPtr[x + y * dim[0]] = checkInside(x, y) ? 1 : 0;
159 std::cout <<
"zero = tMu * mOrigin_u, zero: " << tMu.coord(
mData.
getOrigin_u()) <<
", mOrigin_u: "
163 std::cout <<
"e_z = tMu * -e_y " << tMu.vector(-e_y) << std::endl;
166 std::cout <<
"e_y = tMu * -e_x " << tMu.vector(-e_x) << std::endl;
169 std::cout <<
"tMu * e_x = <0,-1,0>" << tMu.vector(e_x) << std::endl;
171 std::cout <<
"tMu * e_y = <0,0,-1> " << tMu.vector(e_y) << std::endl;
203 bool ProbeSector::clipRectIntersectsSector()
const
209 bool outside = ( (c[0] < s[0]) ||
similar(c[0],s[0], tol) )
210 && ( (s[1] < c[1]) ||
similar(s[1],c[1], tol) )
211 && ( (c[2] < s[2]) ||
similar(c[2],s[2], tol) )
212 && ( (s[3] < c[3]) ||
similar(s[3],c[3], tol) );
223 output->SetPoints(mPolyData->GetPoints());
224 output->SetLines(mPolyData->GetLines());
228 retval->AddInputData(output);
230 if (this->clipRectIntersectsSector())
231 retval->AddInputData(this->getClipRectPolyData());
234 return retval->GetOutput();
244 output->SetPoints(mPolyData->GetPoints());
245 output->SetLines(mPolyData->GetLines());
253 return this->getClipRectPolyData();
263 sides->InsertNextCell(5, cells);
266 points->InsertNextPoint(bb.corner(0, 0, 0).begin());
267 points->InsertNextPoint(bb.corner(1, 0, 0).begin());
268 points->InsertNextPoint(bb.corner(1, 1, 0).begin());
269 points->InsertNextPoint(bb.corner(0, 1, 0).begin());
272 polydata->SetPoints(points);
273 polydata->SetLines(sides);
288 sides->InsertNextCell(4, cells);
297 points->InsertNextPoint(o_u.begin());
298 points->InsertNextPoint(tip.begin());
299 points->InsertNextPoint(left.begin());
300 points->InsertNextPoint(right.begin());
303 polydata->SetPoints(points);
304 polydata->SetLines(sides);
313 mPolyData = vtkPolyDataPtr::New();
321 newTCoords->SetNumberOfComponents(2);
328 Transform3D texMu =
createTransformNormalize(
DoubleBoundingBox3D(0, bounds[0], 0, bounds[1], 0, 1),
DoubleBoundingBox3D(0, 1, 0, 1, 0, 1));
353 points->InsertNextPoint(uMl.coord(cl).begin());
354 points->InsertNextPoint(uMl.coord(cr).begin());
355 points->InsertNextPoint(uMl.coord(pr).begin());
356 points->InsertNextPoint(uMl.coord(pl).begin());
358 newTCoords->Allocate(4);
359 newTCoords->InsertNextTuple(texMl.coord(cl).begin());
360 newTCoords->InsertNextTuple(texMl.coord(cr).begin());
361 newTCoords->InsertNextTuple(texMl.coord(pr).begin());
362 newTCoords->InsertNextTuple(texMl.coord(pl).begin());
364 vtkIdType cells[5] = { 0, 1, 2, 3, 0 };
365 sides->InsertNextCell(5, cells);
366 polys->InsertNextCell(5, cells);
367 vtkIdType s_cells[5] = { 0, 3, 1, 2 };
368 strips->InsertNextCell(4, s_cells);
379 int N = 2 * (arcRes + 1);
382 newTCoords->Allocate(2 * N);
384 for (
int i = 0; i <= arcRes; i++)
386 double theta = startAngle + i * angleIncrement;
396 newTCoords->InsertNextTuple(texMl.coord(startTheta).begin());
397 points->InsertNextPoint(uMl.coord(startTheta).begin());
400 for (
int i = 0; i <= arcRes; i++)
402 double theta = stopAngle - i * angleIncrement;
411 newTCoords->InsertNextTuple(texMl.coord(endTheta).begin());
412 points->InsertNextPoint(uMl.coord(endTheta).begin());
415 sides->InsertNextCell(N + 1);
416 for (
int i = 0; i < N; i++)
417 sides->InsertCellPoint(i);
418 sides->InsertCellPoint(0);
420 polys->InsertNextCell(N + 1);
421 for (
int i = 0; i < arcRes * 2 + 2; i++)
422 polys->InsertCellPoint(i);
423 polys->InsertCellPoint(0);
425 strips->InsertNextCell(N);
426 for (
int i = 0; i <= arcRes; ++i)
428 strips->InsertCellPoint(i);
429 strips->InsertCellPoint(N - 1 - i);
434 polydata->SetPoints(points);
435 polydata->SetStrips(strips);
436 polydata->GetPointData()->SetTCoords(newTCoords);
437 polydata->SetLines(sides);
438 mPolyData = polydata;