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())
68 bool operator ()(
int x,
int y)
const 72 return this->insideClipRect(p_v) && this->insideSector(p_v);
81 bool insideClipRect(
const Vector3D& p_v)
const 83 return mClipRect_v.contains(p_v);
91 bool insideSector(
const Vector3D& p_v)
const 97 double angle = atan2(d[1], d[0]);
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);
294 Vector3D left = o_u +
Vector3D(-length/3, 0, 0);
295 Vector3D right = o_u +
Vector3D(length/3, 0, 0);
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;
DoubleBoundingBox3D transform(const Transform3D &m, const DoubleBoundingBox3D &bb)
Transform3D createTransformRotateY(const double angle)
vtkSmartPointer< class vtkPlanes > vtkPlanesPtr
Vector3D corner(int x, int y, int z) const
Transform3D Transform3D
Transform3D is a representation of an affine 3D transform.
vtkPolyDataPtr getSector()
get a polydata representation of the us sector
vtkSmartPointer< class vtkCellArray > vtkCellArrayPtr
double getCenterOffset() const
US beam is emitted straight forward.
Vector3D unitVector(double thetaXY, double thetaZ)
compute a unit vector given angles xy in the xy plane and z meaning the elevation from the xy plane...
vtkSmartPointer< class vtkAppendPolyData > vtkAppendPolyDataPtr
vtkSmartPointer< class vtkFloatArray > vtkFloatArrayPtr
vtkSmartPointer< vtkPoints > vtkPointsPtr
vtkPolyDataPtr getSectorLinesOnly()
get a polydata representation of the us sector
vtkSmartPointer< class vtkBox > vtkBoxPtr
double getDepthStart() const
Transform3D createTransformNormalize(const DoubleBoundingBox3D &in, const DoubleBoundingBox3D &out)
double getDepthEnd() const
Transform3D createTransformIJC(const Vector3D &ivec, const Vector3D &jvec, const Vector3D ¢er)
Transform3D get_uMv() const
get transform from inverted image space v (origin in ul corner) to image space u. ...
InsideMaskFunctor(ProbeDefinition data, Transform3D uMv)
US beam is emitted radially in a flat cone.
vtkPolyDataPtr getSectorSectorOnlyLinesOnly()
get a polydata representation of the us sector
double constrainValue(double val, double min, double max)
DoubleBoundingBox3D getClipRect_u() const
sector clipping rect in image space u. (lower-left corner origin)
Transform3D createTransformTranslate(const Vector3D &translation)
vtkPolyDataPtr getClipRectLinesOnly()
get a polydata representation of the us clip rect
Transform3D get_tMu() const
get transform from image space u to probe tool space t.
Representation of a floating-point bounding box in 3D. The data are stored as {xmin,xmax,ymin,ymax,zmin,zmax}, in order to simplify communication with vtk.
vtkImageDataPtr generateVtkImageData(Eigen::Array3i dim, Vector3D spacing, const unsigned char initValue, int components)
vtkSmartPointer< class vtkCutter > vtkCutterPtr
Vector3D getOrigin_u() const
probe origin in image space u. (lower-left corner origin)
vtkSmartPointer< vtkPolyData > vtkPolyDataPtr
Eigen::Vector3d Vector3D
Vector3D is a representation of a point or vector in 3D.
Definition of characteristics for an Ultrasound Probe Sector.
Vector3D multiply_elems(const Vector3D &a, const Vector3D &b)
perform element-wise multiplication of a and b.
Vector3D getSpacing() const
bool similar(const CameraInfo &lhs, const CameraInfo &rhs, double tol)
vtkImageDataPtr getMask()
RealScalar length() const
Transform3D createTransformRotateX(const double angle)
vtkPolyDataPtr getOriginPolyData()
get a polydata representation of the origin
vtkSmartPointer< class vtkPlane > vtkPlanePtr
void setData(ProbeDefinition data)
Namespace for all CustusX production code.