18 #include <vtkCellArray.h> 19 #include <vtkClipPolyData.h> 20 #include <vtkLinearExtrusionFilter.h> 21 #include <vtkPlanes.h> 22 #include <vtkPoints.h> 23 #include <vtkPolyData.h> 25 #include <vtkDoubleArray.h> 26 #include <vtkFloatArray.h> 28 #include <vtkPolygon.h> 31 #include <vtkCubeSource.h> 32 #include <vtkImageData.h> 33 #include <vtkLinearSubdivisionFilter.h> 34 #include <vtkSampleFunction.h> 35 #include <vtkTriangleFilter.h> 38 : m_Contour(nullptr), m_ClippingGeometry(nullptr), m_AutomaticVectorGeneration(false), m_Decimate(nullptr)
41 timeGeometry->Initialize(1);
52 double vtkvector[3] = {0, 0, 1};
87 static double polygonNormal[3] = {0.0, 0.0, 1.0};
94 xt[1] = worldPoint[1] - m_Origin[1];
95 xt[2] = worldPoint[2] - m_Origin[2];
98 xt[0] -= dist * m_Normal[0];
99 xt[1] -= dist * m_Normal[1];
100 xt[2] -= dist * m_Normal[2];
114 ((vtkDoubleArray *)this->
m_Polygon->Points->GetData())->GetPointer(0),
131 this->
GetSource()->UpdateOutputInformation();
151 vtkPolyData *polyData = vtkPolyData::New();
152 vtkCellArray *polys = vtkCellArray::New();
154 polys->InsertNextCell(
m_Polygon->GetPointIds());
155 polyData->SetPoints(
m_Polygon->GetPoints());
169 polyData->SetPolys(polys);
206 nullvector.Fill(0.0);
209 unsigned int numPts = 20;
211 mitk::Contour::PathType::InputType cstart = path->StartOfInput();
212 mitk::Contour::PathType::InputType cend = path->EndOfInput();
213 mitk::Contour::PathType::InputType cstep = (cend - cstart) / numPts;
214 mitk::Contour::PathType::InputType ccur;
224 itkWarningMacro(
"Extrusion vector is 0 (" <<
m_Vector <<
"); trying to use normal of polygon");
226 vtkPoints *loopPoints = vtkPoints::New();
231 for (i = 0, ccur = cstart; i < numPts; ++i, ccur += cstep)
233 itk2vtk(path->Evaluate(ccur), vtkpoint);
234 loopPoints->InsertNextPoint(vtkpoint);
238 vtkPolygon::ComputeNormal(loopPoints,
m_Normal);
239 loopPoints->Delete();
244 itkExceptionMacro(
"Cannot calculate normal of polygon");
252 itkDebugMacro(
"Right vector is 0. Calculating.");
256 itkWarningMacro(
"Right vector (" <<
m_RightVector <<
") not perpendicular to extrusion vector " << m_Vector
276 VnlVector downDV = vnl_cross_3d(m_Vector.GetVnlVector(), rightDV);
290 m_Polygon->Points->SetNumberOfPoints(numPts);
292 m_Polygon->PointIds->SetNumberOfIds(numPts);
299 for (i = 0, ccur = cstart; i < numPts; ++i, ccur += cstep)
301 pt3d.CastFrom(path->Evaluate(ccur));
304 if (pt2d[0] < min[0])
306 if (pt2d[0] > max[0])
309 if (pt2d[1] < min[1])
311 if (pt2d[1] > max[1])
317 for (i = 0; i < numPts; ++i)
319 double *pt = this->
m_Polygon->Points->GetPoint(i);
323 itkDebugMacro(<< i <<
": (" << pt[0] <<
"," << pt[1] <<
"," << pt[2] <<
")");
334 ScalarType bounds[6] = {0, max[0] - min[0], 0, max[1] - min[1], 0, 1};
344 for (i = 0; i < 8; ++i)
353 origin = origin + m_Vector * min_dist;
355 bounds[5] = max_dist - min_dist;
363 assert(g3d.IsNotNull());
364 g3d->SetBounds(bounds);
368 timeGeometry->Initialize(g3d, 1);
374 unsigned long latestTime = Superclass::GetMTime();
377 unsigned long localTime;
379 if (localTime > latestTime)
380 latestTime = localTime;
~ExtrudedContour() override
itk::SmartPointer< mitk::BaseDataSource > GetSource() const
Get the process object that generated this data object.
vnl_vector< ScalarType > VnlVector
mitk::ScalarType GetVolume() override
vtkLinearSubdivisionFilter * m_SubdivisionFilter
vtkPlanes * m_ClippingBox
virtual void SetTimeGeometry(TimeGeometry *geometry)
Set the TimeGeometry of the data, which will be referenced (not copied!).
vtkLinearExtrusionFilter * m_ExtrusionFilter
mitk::PlaneGeometry::Pointer m_ProjectionPlane
void FillVector3D(Tout &out, mitk::ScalarType x, mitk::ScalarType y, mitk::ScalarType z)
bool m_AutomaticVectorGeneration
mitk::Vector3D m_RightVector
void vnl2vtk(const vnl_vector< Tin > &in, Tout *out)
mitk::BaseGeometry::Pointer m_ClippingGeometry
unsigned long GetMTime() const override
float m_ProjectedContourBounds[6]
void vtk2itk(const Tin &in, Tout &out)
virtual void SetVtkPolyData(vtkPolyData *polydata, unsigned int t=0)
void UpdateOutputInformation() override
PathType::Pointer PathPointer
void itk2vtk(const Tin &in, Tout &out)
vtkClipPolyData * m_ClipPolyDataFilter
MITKNEWMODULE_EXPORT bool Equal(mitk::ExampleDataStructure *leftHandSide, mitk::ExampleDataStructure *rightHandSide, mitk::ScalarType eps, bool verbose)
Returns true if the example data structures are considered equal.
mitk::Contour::Pointer m_Contour
itk::TimeStamp m_LastCalculateExtrusionTime
bool IsInside(const Point3D &p) const override
mitk::BaseGeometry * GetGeometry(int t=0) const
Return the geometry, which is a TimeGeometry, of the data as non-const pointer.
vtkTriangleFilter * m_TriangleFilter
float m_Right[3]
For fast projection on plane.