15 #include <vtkCellArray.h> 16 #include <vtkPoints.h> 17 #include <vtkPolyLine.h> 18 #include <vtkProperty.h> 50 if (contourModelSet !=
nullptr)
52 vtkSmartPointer<vtkPoints> points = vtkSmartPointer<vtkPoints>::New();
53 vtkSmartPointer<vtkCellArray> cells = vtkSmartPointer<vtkCellArray>::New();
54 vtkIdType baseIndex = 0;
56 auto it = contourModelSet->Begin();
57 auto end = contourModelSet->End();
63 auto vertIt = contourModel->
Begin();
64 auto vertEnd = contourModel->
End();
66 while (vertIt != vertEnd)
68 points->InsertNextPoint((*vertIt)->Coordinates[0], (*vertIt)->Coordinates[1], (*vertIt)->Coordinates[2]);
72 vtkSmartPointer<vtkPolyLine>
line = vtkSmartPointer<vtkPolyLine>::New();
73 vtkIdList *pointIds = line->GetPointIds();
76 pointIds->SetNumberOfIds(numPoints + 1);
78 for (vtkIdType i = 0; i < numPoints; ++i)
79 pointIds->SetId(i, baseIndex + i);
81 pointIds->SetId(numPoints, baseIndex);
83 cells->InsertNextCell(line);
85 baseIndex += numPoints;
90 vtkSmartPointer<vtkPolyData> polyData = vtkSmartPointer<vtkPolyData>::New();
91 polyData->SetPoints(points);
92 polyData->SetLines(cells);
94 vtkSmartPointer<vtkPolyDataMapper> mapper = vtkSmartPointer<vtkPolyDataMapper>::New();
95 vtkSmartPointer<vtkActor> actor = vtkSmartPointer<vtkActor>::New();
96 actor->SetMapper(mapper);
98 mapper->SetInputData(polyData);
128 data->UpdateOutputInformation();
161 vtkSmartPointer<vtkPolyData> polyData = vtkSmartPointer<vtkPolyData>::New();
172 if (dataNode !=
nullptr)
177 vtkSmartPointer<vtkPropCollection> collection = vtkSmartPointer<vtkPropCollection>::New();
178 localStorage->
m_Assembly->GetActors(collection);
179 collection->InitTraversal();
180 for (vtkIdType i = 0; i < collection->GetNumberOfItems(); i++)
182 vtkActor::SafeDownCast(collection->GetNextProp())->GetProperty()->SetLineWidth(lineWidth);
196 double red = colorprop->GetColor().GetRed();
197 double green = colorprop->GetColor().GetGreen();
198 double blue = colorprop->GetColor().GetBlue();
200 vtkSmartPointer<vtkPropCollection> collection = vtkSmartPointer<vtkPropCollection>::New();
201 localStorage->
m_Assembly->GetActors(collection);
202 collection->InitTraversal();
203 for (vtkIdType i = 0; i < collection->GetNumberOfItems(); i++)
205 vtkActor::SafeDownCast(collection->GetNextProp())->GetProperty()->SetColor(red, green, blue);
220 m_Assembly = vtkSmartPointer<vtkAssembly>::New();
231 Superclass::SetDefaultProperties(node, renderer, overwrite);
LocalStorage()
Default constructor of the local storage.
int GetNumberOfVertices(int timestep=0) const
Returns the number of vertices at a given timestep.
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 void ApplyContourProperties(mitk::BaseRenderer *renderer)
LocalStorage * GetLocalStorage(mitk::BaseRenderer *renderer)
Get the LocalStorage corresponding to the current renderer.
vtkProp * GetVtkProp(mitk::BaseRenderer *renderer) override
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...
bool GetFloatProperty(const char *propertyKey, float &floatValue, const mitk::BaseRenderer *renderer=nullptr) const
Convenience access method for float properties (instances of FloatProperty)
Organizes the rendering process.
virtual const PlaneGeometry * GetCurrentWorldPlaneGeometry()
Get the current 2D-worldgeometry (m_CurrentWorldPlaneGeometry) used for 2D-rendering.
virtual vtkSmartPointer< vtkPolyData > CreateVtkPolyDataFromContour(mitk::ContourModel *inputContour, mitk::BaseRenderer *renderer)
unsigned long GetMTime() const override
Get the timestamp of the last change of the contents of this node or the referenced BaseData...
mitk::LocalStorageHandler< LocalStorage > m_LSH
The LocalStorageHandler holds all (three) LocalStorages for the three 2D render windows.
VertexIterator Begin(int timestep=0) const
Returns a const VertexIterator at the start element of the contour.
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 ...
const mitk::ContourModelSet * GetInput(void)
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...
virtual void CalculateTimeStep(BaseRenderer *renderer)
Updates the time step, which is sometimes needed in subclasses.
ContourModelSetMapper3D()
void Update(mitk::BaseRenderer *renderer) override
Checks whether this mapper needs to update itself and generate data.
mitk::PropertyList * GetPropertyList(const mitk::BaseRenderer *renderer=nullptr) const
Get the PropertyList of the renderer. If renderer is nullptr, the BaseRenderer-independent PropertyLi...
~ContourModelSetMapper3D() override
VertexIterator End(int timestep=0) const
Returns a const VertexIterator at the end element of the contour.
static void SetDefaultProperties(mitk::DataNode *node, mitk::BaseRenderer *renderer=nullptr, bool overwrite=false)
Set the default properties for general image rendering.
int GetTimestep() const
Returns the current time step as calculated from the renderer.
mitk::ContourModelToSurfaceFilter::Pointer m_contourToPolyData
unsigned long GetCurrentWorldPlaneGeometryUpdateTime()
Get timestamp of last call of SetCurrentWorldPlaneGeometry.
virtual void ApplyContourModelSetProperties(BaseRenderer *renderer)
vtkSmartPointer< vtkAssembly > m_Assembly
Assembly of contours.
itk::TimeStamp m_LastUpdateTime
Timestamp of last update of stored data.
Class for nodes of the DataTree.