16 #include <vtkAppendPolyData.h> 17 #include <vtkCellArray.h> 18 #include <vtkCutter.h> 20 #include <vtkPoints.h> 21 #include <vtkProperty.h> 22 #include <vtkSphereSource.h> 23 #include <vtkStripper.h> 24 #include <vtkTubeFilter.h> 59 if (inputContour->GetNumberOfVertices(timestep) > 0)
90 const TimeGeometry *dataTimeGeometry = data->GetTimeGeometry();
91 if ((dataTimeGeometry ==
nullptr) || (dataTimeGeometry->
CountTimeSteps() == 0) ||
95 localStorage->
m_Mapper->RemoveAllInputs();
100 data->UpdateOutputInformation();
128 vtkSmartPointer<vtkPolyData> resultingPolyData = vtkSmartPointer<vtkPolyData>::New();
133 if (currentWorldGeometry)
139 vtkSmartPointer<vtkPlane> plane = vtkSmartPointer<vtkPlane>::New();
140 plane->SetOrigin(origin[0], origin[1], origin[2]);
141 plane->SetNormal(normal[0], normal[1], normal[2]);
147 vtkSmartPointer<vtkPoints> points = vtkSmartPointer<vtkPoints>::New();
149 vtkSmartPointer<vtkCellArray> lines = vtkSmartPointer<vtkCellArray>::New();
151 vtkSmartPointer<vtkPolyData> polyDataIn3D = vtkSmartPointer<vtkPolyData>::New();
153 vtkSmartPointer<vtkAppendPolyData> appendPoly = vtkSmartPointer<vtkAppendPolyData>::New();
156 renderingContour = inputContour;
158 bool subdivision =
false;
166 subdivFilter->SetInput(inputContour);
167 subdivFilter->Update();
169 subdivContour = subdivFilter->GetOutput();
171 if (subdivContour->GetNumberOfVertices() == 0)
173 subdivContour = inputContour;
176 renderingContour = subdivContour;
180 auto current = renderingContour->IteratorBegin(timestep);
181 auto next = renderingContour->IteratorBegin(timestep);
182 if (next != renderingContour->IteratorEnd(timestep))
186 auto end = renderingContour->IteratorEnd(timestep);
193 vtkIdType p1 = points->InsertNextPoint(currentControlPoint->
Coordinates[0],
196 vtkIdType p2 = points->InsertNextPoint(
199 lines->InsertNextCell(2);
200 lines->InsertCellPoint(p1);
201 lines->InsertCellPoint(p2);
205 double coordinates[3];
206 coordinates[0] = currentControlPoint->
Coordinates[0];
207 coordinates[1] = currentControlPoint->
Coordinates[1];
208 coordinates[2] = currentControlPoint->
Coordinates[2];
210 double distance = plane->DistanceToPlane(coordinates);
213 vtkSmartPointer<vtkSphereSource> sphere = vtkSmartPointer<vtkSphereSource>::New();
215 sphere->SetRadius(1.2);
216 sphere->SetCenter(coordinates[0], coordinates[1], coordinates[2]);
218 appendPoly->AddInputConnection(sphere->GetOutputPort());
227 if ((*current)->IsControlPoint)
229 double coordinates[3];
230 coordinates[0] = (*current)->Coordinates[0];
231 coordinates[1] = (*current)->Coordinates[1];
232 coordinates[2] = (*current)->Coordinates[2];
234 double distance = plane->DistanceToPlane(coordinates);
237 vtkSmartPointer<vtkSphereSource> sphere = vtkSmartPointer<vtkSphereSource>::New();
239 sphere->SetRadius(1.2);
240 sphere->SetCenter(coordinates[0], coordinates[1], coordinates[2]);
242 appendPoly->AddInputConnection(sphere->GetOutputPort());
249 if (renderingContour->IsClosed(timestep))
254 vtkIdType p2 = points->InsertNextPoint(
256 vtkIdType p1 = points->InsertNextPoint(
260 lines->InsertNextCell(2);
261 lines->InsertCellPoint(p1);
262 lines->InsertCellPoint(p2);
266 polyDataIn3D->SetPoints(points);
268 polyDataIn3D->SetLines(lines);
271 bool useCuttingPlane =
false;
278 vtkSmartPointer<vtkTubeFilter> tubeFilter = vtkSmartPointer<vtkTubeFilter>::New();
279 tubeFilter->SetInputData(polyDataIn3D);
280 tubeFilter->SetRadius(0.05);
283 vtkSmartPointer<vtkCutter> cutter = vtkSmartPointer<vtkCutter>::New();
285 cutter->SetCutFunction(plane);
287 cutter->SetInputConnection(tubeFilter->GetOutputPort());
290 cutter->GenerateCutScalarsOff();
294 resultingPolyData = cutter->GetOutput();
300 resultingPolyData = polyDataIn3D;
305 appendPoly->AddInputData(resultingPolyData);
306 appendPoly->Update();
309 return appendPoly->GetOutput();
314 return resultingPolyData;
322 float lineWidth(1.0);
323 if (this->
GetDataNode()->GetFloatProperty(
"width", lineWidth, renderer))
325 localStorage->
m_Actor->GetProperty()->SetLineWidth(lineWidth);
333 double red = colorprop->GetColor().GetRed();
334 double green = colorprop->GetColor().GetGreen();
335 double blue = colorprop->GetColor().GetBlue();
336 localStorage->
m_Actor->GetProperty()->SetColor(red, green, blue);
340 localStorage->
m_Actor->GetProperty()->SetAmbient(1.0);
341 localStorage->
m_Actor->GetProperty()->SetDiffuse(0.0);
342 localStorage->
m_Actor->GetProperty()->SetSpecular(0.0);
354 m_Mapper = vtkSmartPointer<vtkPolyDataMapper>::New();
355 m_Actor = vtkSmartPointer<vtkActor>::New();
356 m_OutlinePolyData = vtkSmartPointer<vtkPolyData>::New();
359 m_Actor->SetMapper(m_Mapper);
371 Superclass::SetDefaultProperties(node, renderer, overwrite);
mitk::BaseProperty * GetProperty(const char *propertyKey, const mitk::BaseRenderer *renderer=nullptr, bool fallBackOnDataProperties=true) const
Get the property (instance of BaseProperty) with key propertyKey from the PropertyList of the rendere...
L * GetLocalStorage(mitk::BaseRenderer *forRenderer)
Retrieves a LocalStorage for a specific BaseRenderer.
ContourModel is a structure of linked vertices defining a contour in 3D space. The vertices are store...
virtual TimeStepType CountTimeSteps() const =0
Returns the number of time steps.
mitk::Point3D Coordinates
Coordinates in 3D space.
unsigned long GetMTime() const override
Get the timestamp of the last change of the map or the last change of one of the properties store in ...
virtual DataNode * GetDataNode() const
Get the DataNode containing the data to map. Method only returns valid DataNode Pointer if the mapper...
Organizes the rendering process.
virtual const PlaneGeometry * GetCurrentWorldPlaneGeometry()
Get the current 2D-worldgeometry (m_CurrentWorldPlaneGeometry) used for 2D-rendering.
bool IsControlPoint
Treat point special.
LocalStorage * GetLocalStorage(mitk::BaseRenderer *renderer)
Get the LocalStorage corresponding to the current renderer.
unsigned long GetMTime() const override
Get the timestamp of the last change of the contents of this node or the referenced BaseData...
bool GetBoolProperty(const char *propertyKey, bool &boolValue, const mitk::BaseRenderer *renderer=nullptr) const
Convenience access method for bool properties (instances of BoolProperty)
void Update(mitk::BaseRenderer *renderer) override
Checks whether this mapper needs to update itself and generate data.
void GenerateDataForRenderer(mitk::BaseRenderer *renderer) override
Generate the data needed for rendering into renderer.
The ColorProperty class RGB color property.
BaseData * GetData() const
Get the data object (instance of BaseData, e.g., an Image) managed by this DataNode.
void AddProperty(const char *propertyKey, BaseProperty *property, const mitk::BaseRenderer *renderer=nullptr, bool overwrite=false)
Add the property (instance of BaseProperty) if it does not exist (or always ifoverwrite istrue) with ...
~ContourModelMapper2D() override
vtkProp * GetVtkProp(mitk::BaseRenderer *renderer) override
virtual unsigned int GetTimeStep() const
static void SetDefaultProperties(mitk::DataNode *node, mitk::BaseRenderer *renderer=nullptr, bool overwrite=false)
Set the default properties for general image rendering.
bool GetVisibility(bool &visible, const mitk::BaseRenderer *renderer, const char *propertyKey="visible") const
Convenience access method for visibility properties (instances of BoolProperty with property-key "vis...
const mitk::ContourModel * GetInput(void)
virtual void ApplyContourProperties(mitk::BaseRenderer *renderer)
virtual void CalculateTimeStep(BaseRenderer *renderer)
Updates the time step, which is sometimes needed in subclasses.
vtkSmartPointer< vtkPolyDataMapper > m_Mapper
Mapper of a 2D render window.
vtkSmartPointer< vtkActor > m_Actor
Actor of a 2D render window.
const Point3D GetOrigin() const
Get the origin, e.g. the upper-left corner of the plane.
LocalStorage()
Default constructor of the local storage.
mitk::PropertyList * GetPropertyList(const mitk::BaseRenderer *renderer=nullptr) const
Get the PropertyList of the renderer. If renderer is nullptr, the BaseRenderer-independent PropertyLi...
Vector3D GetNormal() const
Normal of the plane.
mitk::LocalStorageHandler< LocalStorage > m_LSH
The LocalStorageHandler holds all (three) LocalStorages for the three 2D render windows.
itk::TimeStamp m_LastUpdateTime
Timestamp of last update of stored data.
int GetTimestep() const
Returns the current time step as calculated from the renderer.
unsigned long GetCurrentWorldPlaneGeometryUpdateTime()
Get timestamp of last call of SetCurrentWorldPlaneGeometry.
Describes a two-dimensional, rectangular plane.
Represents a single vertex of contour.
virtual vtkSmartPointer< vtkPolyData > CreateVtkPolyDataFromContour(mitk::ContourModel *inputContour, mitk::BaseRenderer *renderer)
virtual bool IsValidTimeStep(TimeStepType timeStep) const =0
Test for the given time step if a geometry is availible.
vtkSmartPointer< vtkPolyData > m_OutlinePolyData
Class for nodes of the DataTree.