MCPcopy Create free account
hub / github.com/MITK/MITK / UpdateVtkObjects

Method UpdateVtkObjects

Modules/MapperExt/src/mitkEnhancedPointSetVtkMapper3D.cpp:80–178  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

78}
79
80void mitk::EnhancedPointSetVtkMapper3D::UpdateVtkObjects()
81{
82 // get and update the PointSet
83 const mitk::PointSet *pointset = this->GetInput();
84 // pointset->Update();
85 int timestep = this->GetTimestep();
86
87 mitk::PointSet::DataType *itkPointSet = pointset->GetPointSet(timestep);
88 mitk::PointSet::PointsContainer *points = itkPointSet->GetPoints();
89 mitk::PointSet::PointDataContainer *pointData = itkPointSet->GetPointData();
90
91 assert(points->Size() == pointData->Size());
92
93 mitk::PointSet::PointsIterator pIt;
94 mitk::PointSet::PointDataIterator pdIt;
95
96 /* search removed points and delete the corresponding source/actor/mapper objects */
97 for (auto it = m_PointActors.begin(); it != m_PointActors.end();)
98 {
99 PointIdentifier id = it->first;
100 if (!points->IndexExists(id))
101 {
102 this->RemoveEntryFromSourceMaps(id);
103 m_PropAssembly->GetParts()->RemoveItem(it->second.first); // remove from prop assembly
104 if (it->second.first != nullptr)
105 it->second.first->Delete(); // Delete actor, which deletes mapper too (reference count)
106 auto er = it; // save iterator for deleting
107 ++it; // advance iterator to next object
108 m_PointActors.erase(
109 er); // erase element from map. This invalidates er, therefore we had to advance it before deletion.
110 }
111 else
112 ++it;
113 }
114
115 /* iterate over each point in the pointset and create corresponding vtk objects */
116 for (pIt = points->Begin(), pdIt = pointData->Begin(); pIt != itkPointSet->GetPoints()->End(); ++pIt, ++pdIt)
117 {
118 PointIdentifier pointID = pIt->Index();
119 assert(pointID == pdIt->Index());
120
121 mitk::PointSet::PointDataType data = pdIt->Value();
122
123 auto aIt = m_PointActors.find(pointID); // Does an actor exist for the point?
124
125 /* Create/Update sources for the point */
126 vtkActor *a = nullptr;
127 bool newPoint = (aIt == m_PointActors.end()); // current point is new
128 bool specChanged = (!newPoint && data.pointSpec != aIt->second.second); // point spec of current point has changed
129
130 if (newPoint) // point did not exist before, we have to create vtk objects for it
131 { // create actor and mapper for the new point
132 a = vtkActor::New();
133 vtkPolyDataMapper *m = vtkPolyDataMapper::New();
134 a->SetMapper(m);
135 m->UnRegister(nullptr);
136 aIt = m_PointActors.insert(std::make_pair(pointID, std::make_pair(a, data.pointSpec)))
137 .first; // insert element and update actormap iterator to point to new element

Callers 2

Calls 15

GetInputMethod · 0.95
IndexExistsMethod · 0.80
RemoveItemMethod · 0.80
ValueMethod · 0.80
SetMapperMethod · 0.80
GetMapperMethod · 0.80
SetInputConnectionMethod · 0.80
NewFunction · 0.50
GetPointSetMethod · 0.45
SizeMethod · 0.45
beginMethod · 0.45

Tested by

no test coverage detected