20 #include <vtkAppendPolyData.h>
21 #include <vtkCellArray.h>
22 #include <vtkCutter.h>
24 #include <vtkPoints.h>
25 #include <vtkProperty.h>
26 #include <vtkSphereSource.h>
27 #include <vtkStripper.h>
28 #include <vtkTubeFilter.h>
49 return m_LSH.GetLocalStorage(renderer)->m_Actor;
56 LocalStorage *localStorage = m_LSH.GetLocalStorage(renderer);
65 localStorage->
m_OutlinePolyData = this->CreateVtkPolyDataFromContour(inputContour, renderer);
68 this->ApplyContourProperties(renderer);
76 GetDataNode()->GetVisibility(visible, renderer,
"visible");
89 this->CalculateTimeStep(renderer);
91 LocalStorage *localStorage = m_LSH.GetLocalStorage(renderer);
95 if ((dataTimeGeometry == NULL) || (dataTimeGeometry->CountTimeSteps() == 0) ||
99 localStorage->
m_Mapper->RemoveAllInputs();
103 const DataNode *node = this->GetDataNode();
119 this->GenerateDataForRenderer(renderer);
130 unsigned int timestep = this->GetTimestep();
137 if (currentWorldGeometry)
144 plane->SetOrigin(origin[0], origin[1], origin[2]);
145 plane->SetNormal(normal[0], normal[1], normal[2]);
160 renderingContour = inputContour;
162 bool subdivision =
false;
163 this->GetDataNode()->GetBoolProperty(
"subdivision curve", subdivision, renderer);
170 subdivFilter->SetInput(inputContour);
171 subdivFilter->Update();
173 subdivContour = subdivFilter->GetOutput();
175 if (subdivContour->GetNumberOfVertices() == 0)
177 subdivContour = inputContour;
180 renderingContour = subdivContour;
186 if (next != renderingContour->IteratorEnd(timestep))
197 vtkIdType p1 = points->InsertNextPoint(currentControlPoint->
Coordinates[0],
200 vtkIdType p2 = points->InsertNextPoint(
203 lines->InsertNextCell(2);
204 lines->InsertCellPoint(p1);
205 lines->InsertCellPoint(p2);
209 double coordinates[3];
210 coordinates[0] = currentControlPoint->
Coordinates[0];
211 coordinates[1] = currentControlPoint->
Coordinates[1];
212 coordinates[2] = currentControlPoint->
Coordinates[2];
214 double distance = plane->DistanceToPlane(coordinates);
219 sphere->SetRadius(1.2);
220 sphere->SetCenter(coordinates[0], coordinates[1], coordinates[2]);
222 appendPoly->AddInputConnection(sphere->GetOutputPort());
231 if ((*current)->IsControlPoint)
233 double coordinates[3];
234 coordinates[0] = (*current)->Coordinates[0];
235 coordinates[1] = (*current)->Coordinates[1];
236 coordinates[2] = (*current)->Coordinates[2];
238 double distance = plane->DistanceToPlane(coordinates);
243 sphere->SetRadius(1.2);
244 sphere->SetCenter(coordinates[0], coordinates[1], coordinates[2]);
246 appendPoly->AddInputConnection(sphere->GetOutputPort());
253 if (renderingContour->IsClosed(timestep))
258 vtkIdType p2 = points->InsertNextPoint(
260 vtkIdType p1 = points->InsertNextPoint(
264 lines->InsertNextCell(2);
265 lines->InsertCellPoint(p1);
266 lines->InsertCellPoint(p2);
270 polyDataIn3D->SetPoints(points);
272 polyDataIn3D->SetLines(lines);
275 bool useCuttingPlane =
false;
276 this->GetDataNode()->GetBoolProperty(
"use cutting plane", useCuttingPlane, renderer);
283 tubeFilter->SetInputData(polyDataIn3D);
284 tubeFilter->SetRadius(0.05);
289 cutter->SetCutFunction(plane);
291 cutter->SetInputConnection(tubeFilter->GetOutputPort());
294 cutter->GenerateCutScalarsOff();
298 resultingPolyData = cutter->GetOutput();
304 resultingPolyData = polyDataIn3D;
309 appendPoly->AddInputData(resultingPolyData);
310 appendPoly->Update();
313 return appendPoly->GetOutput();
318 return resultingPolyData;
324 LocalStorage *localStorage = m_LSH.GetLocalStorage(renderer);
326 float lineWidth(1.0);
327 if (this->GetDataNode()->GetFloatProperty(
"width", lineWidth, renderer))
329 localStorage->
m_Actor->GetProperty()->SetLineWidth(lineWidth);
337 double red = colorprop->GetColor().GetRed();
338 double green = colorprop->GetColor().GetGreen();
339 double blue = colorprop->GetColor().GetBlue();
340 localStorage->
m_Actor->GetProperty()->SetColor(red, green, blue);
344 localStorage->
m_Actor->GetProperty()->SetAmbient(1.0);
345 localStorage->
m_Actor->GetProperty()->SetDiffuse(0.0);
346 localStorage->
m_Actor->GetProperty()->SetSpecular(0.0);
353 return m_LSH.GetLocalStorage(renderer);
363 m_Actor->SetMapper(m_Mapper);
375 Superclass::SetDefaultProperties(node, renderer, overwrite);
const Point3D GetOrigin() const
Get the origin, e.g. the upper-left corner of the plane.
mitk::PropertyList * GetPropertyList(const mitk::BaseRenderer *renderer=nullptr) const
Get the PropertyList of the renderer. If renderer is NULL, the BaseRenderer-independent PropertyList ...
ContourModel is a structure of linked vertices defining a contour in 3D space. The vertices are store...
virtual void UpdateOutputInformation() override
Update the OutputInformation of a ContourModel object.
mitk::Point3D Coordinates
Coordinates in 3D space.
virtual 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 ...
Organizes the rendering process.
mitk::ContourElement::VertexIterator VertexIterator
virtual const PlaneGeometry * GetCurrentWorldPlaneGeometry()
Get the current 2D-worldgeometry (m_CurrentWorldPlaneGeometry) used for 2D-rendering.
const mitk::TimeGeometry * GetTimeGeometry() const
Return the TimeGeometry of the data as const pointer.
bool IsControlPoint
Treat point special.
LocalStorage * GetLocalStorage(mitk::BaseRenderer *renderer)
Get the LocalStorage corresponding to the current renderer.
virtual unsigned long GetMTime() const override
Get the timestamp of the last change of the contents of this node or the referenced BaseData...
virtual 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.
Vector3D GetNormal() const
Normal of the plane.
The ColorProperty class RGB color property.
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 ...
virtual vtkProp * GetVtkProp(mitk::BaseRenderer *renderer) override
virtual ~ContourModelMapper2D()
const mitk::ContourModel * GetInput(void)
virtual void ApplyContourProperties(mitk::BaseRenderer *renderer)
vtkSmartPointer< vtkPolyDataMapper > m_Mapper
Mapper of a 2D render window.
vtkSmartPointer< vtkActor > m_Actor
Actor of a 2D render window.
LocalStorage()
Default constructor of the local storage.
virtual unsigned int GetTimeStep() const
itk::TimeStamp m_LastUpdateTime
Timestamp of last update of stored data.
unsigned long GetCurrentWorldPlaneGeometryUpdateTime()
Get timestamp of last call of SetCurrentWorldPlaneGeometry.
Describes a two-dimensional, rectangular plane.
static void SetDefaultProperties(mitk::DataNode *node, mitk::BaseRenderer *renderer=NULL, bool overwrite=false)
Set the default properties for general image rendering.
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.
int GetNumberOfVertices(int timestep=0) const
Returns the number of vertices at a given timestep.
static itkEventMacro(BoundingShapeInteractionEvent, itk::AnyEvent) class MITKBOUNDINGSHAPE_EXPORT BoundingShapeInteractor Pointer New()
Basic interaction methods for mitk::GeometryData.