22 #include <vtkLinearTransform.h> 44 if (elem1[0] != elem2[0])
45 return elem1[0] < elem2[0];
46 if (elem1[1] != elem2[1])
47 return elem1[1] < elem2[1];
48 return elem1[2] < elem2[2];
61 bool updateNeccesary =
true;
69 const TimeGeometry *inputTimeGeometry = input->GetTimeGeometry();
70 if ((inputTimeGeometry ==
nullptr) || (inputTimeGeometry->
CountTimeSteps() == 0))
84 if (time > itk::NumericTraits<mitk::ScalarType>::NonpositiveMin())
91 mitk::Mesh::MeshType::Pointer itkMesh = input->GetMesh(timeStep);
93 if (itkMesh.GetPointer() ==
nullptr)
106 Mesh::DataType::PointsContainerConstIterator it, end;
107 it = itkMesh->GetPoints()->Begin();
108 end = itkMesh->GetPoints()->End();
112 dataIt = itkMesh->GetPointData()->Begin();
115 float unselectedColor[4];
116 glGetFloatv(GL_CURRENT_COLOR, unselectedColor);
124 transform->TransformPoint(vtkp, vtkp);
129 if (diff.GetSquaredNorm() < 4.0)
141 if (dataIt->Value().selected)
147 switch (dataIt->Value().pointSpec)
151 glBegin(GL_LINE_LOOP);
152 tmp = pt2d - horz + vert;
153 glVertex2dv(&tmp[0]);
154 tmp = pt2d + horz + vert;
155 glVertex2dv(&tmp[0]);
156 tmp = pt2d + horz - vert;
157 glVertex2dv(&tmp[0]);
158 tmp = pt2d - horz - vert;
159 glVertex2dv(&tmp[0]);
164 glBegin(GL_LINE_LOOP);
166 glVertex2dv(&tmp[0]);
168 glVertex2dv(&tmp[0]);
170 glVertex2dv(&tmp[0]);
172 glVertex2dv(&tmp[0]);
182 glVertex2dv(&tmp[0]);
187 glColor3f(unselectedColor[0], unselectedColor[1], unselectedColor[2]);
188 switch (dataIt->Value().pointSpec)
192 glBegin(GL_LINE_LOOP);
193 tmp = pt2d - horz + vert;
194 glVertex2dv(&tmp[0]);
195 tmp = pt2d + horz + vert;
196 glVertex2dv(&tmp[0]);
197 tmp = pt2d + horz - vert;
198 glVertex2dv(&tmp[0]);
199 tmp = pt2d - horz - vert;
200 glVertex2dv(&tmp[0]);
207 glVertex2dv(&tmp[0]);
209 glVertex2dv(&tmp[0]);
211 glVertex2dv(&tmp[0]);
213 glVertex2dv(&tmp[0]);
230 Point2D *firstOfCell =
nullptr;
232 unsigned int lastPointId = 0;
233 bool lineSelected =
false;
239 std::vector<mitk::Point3D> intersectionPoints;
247 cellIt = itkMesh->GetCells()->Begin();
248 cellEnd = itkMesh->GetCells()->End();
249 cellDataIt = itkMesh->GetCellData()->Begin();
251 while (cellIt != cellEnd)
253 unsigned int numOfPointsInCell = cellIt->Value()->GetNumberOfPoints();
254 if (numOfPointsInCell > 1)
257 cellIdIt = cellIt->Value()->PointIdsBegin();
258 cellIdEnd = cellIt->Value()->PointIdsEnd();
260 firstOfCell3D = input->GetPoint(*cellIdIt, timeStep);
262 intersectionPoints.clear();
263 intersectionPoints.reserve(numOfPointsInCell);
267 while (cellIdIt != cellIdEnd)
269 lastPoint3D = thisPoint;
271 thisPoint = input->GetPoint(*cellIdIt, timeStep);
274 lineSelected =
false;
279 auto position = std::find(selectedLines.begin(), selectedLines.end(), lastPointId);
280 if (position != selectedLines.end())
288 transform->TransformPoint(vtkp, vtkp);
292 if (diff.GetSquaredNorm() < 4.0)
297 if (lastPoint ==
nullptr)
304 lastPointId = *cellIdIt;
313 glVertex2dv(&(*lastPoint)[0]);
314 glVertex2dv(&pt2d[0]);
319 glColor3f(unselectedColor[0], unselectedColor[1], unselectedColor[2]);
322 glVertex2dv(&(*lastPoint)[0]);
323 glVertex2dv(&pt2d[0]);
329 lastPointId = *cellIdIt;
334 if ((!first) && (worldplanegeometry !=
nullptr))
339 intersectionPoints.push_back(line.
GetPoint(t));
347 if (cellDataIt->Value().closed)
350 if (firstOfCell !=
nullptr)
352 lineSelected =
false;
354 auto position = std::find(selectedLines.begin(), selectedLines.end(), lastPointId);
355 if (position != selectedLines.end())
360 glVertex2dv(&(*lastPoint)[0]);
361 glVertex2dv(&(*firstOfCell)[0]);
366 glColor3f(unselectedColor[0], unselectedColor[1], unselectedColor[2]);
368 glVertex2dv(&(*lastPoint)[0]);
369 glVertex2dv(&(*firstOfCell)[0]);
376 bool showBoundingBox;
377 if (dynamic_cast<mitk::BoolProperty *>(this->
GetDataNode()->GetProperty(
"showBoundingBox")) ==
nullptr)
378 showBoundingBox =
false;
385 if (cellDataIt->Value().selected)
388 if (aABB.IsNotNull())
391 min = aABB->GetMinimum();
392 max = aABB->GetMaximum();
399 transform->TransformPoint(vtkp, vtkp);
404 transform->TransformPoint(vtkp, vtkp);
408 if (diff.GetSquaredNorm() < 4.0)
415 glBegin(GL_LINE_LOOP);
416 glVertex2f(min2D[0], min2D[1]);
417 glVertex2f(min2D[0], max2D[1]);
418 glVertex2f(max2D[0], max2D[1]);
419 glVertex2f(max2D[0], min2D[1]);
427 if (worldplanegeometry !=
nullptr)
430 line.
SetPoints(thisPoint, firstOfCell3D);
433 intersectionPoints.push_back(line.
GetPoint(t));
435 std::sort(intersectionPoints.begin(), intersectionPoints.end(),
point3DSmaller);
436 std::vector<mitk::Point3D>::iterator it, end;
437 end = intersectionPoints.end();
438 if ((intersectionPoints.size() % 2) != 0)
443 for (it = intersectionPoints.begin(); it != end; ++it)
447 glVertex2dv(pt2d.GetDataPointer());
450 glVertex2dv(pt2d.GetDataPointer());
453 if (it != intersectionPoints.end())
457 glVertex2dv(pt2d.GetDataPointer());
458 glVertex2dv(pt2d.GetDataPointer());
466 firstOfCell =
nullptr;
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...
static bool point3DSmaller(const mitk::Point3D &elem1, const mitk::Point3D &elem2)
ScalarType GetTime() const
Get the time in ms of the currently displayed content.
Point< ScalarType, 2 > Point2D
virtual TimeStepType CountTimeSteps() const =0
Returns the number of time steps.
DataType::CellDataContainerIterator CellDataIterator
virtual DataNode * GetDataNode() const
Get the DataNode containing the data to map. Method only returns valid DataNode Pointer if the mapper...
bool IntersectionPointParam(const Line3D &line, double &t) const
Calculate line parameter of intersection point between the plane and a line.
Organizes the rendering process.
virtual const PlaneGeometry * GetCurrentWorldPlaneGeometry()
Get the current 2D-worldgeometry (m_CurrentWorldPlaneGeometry) used for 2D-rendering.
virtual bool Project(const mitk::Point3D &pt3d_mm, mitk::Point3D &projectedPt3d_mm) const
Project a 3D point given in mm (pt3d_mm) onto the 2D geometry. The result is a 3D point in mm (projec...
void WorldToDisplay(const Point3D &worldIndex, Point2D &displayPoint) const
This method converts a 3D world index to the display point using the geometry of the renderWindow...
const itk::Point< TCoordRep, NPointDimension > & GetPoint() const
Get start point of the line.
Superclass::DataType::CellsContainer::Iterator CellIterator
std::vector< unsigned int > SelectedLinesType
cellDataType, that stores all indexes of the lines, that are selected e.g.: points A...
void Paint(mitk::BaseRenderer *renderer) override
Do the painting into the renderer.
BaseData * GetData() const
Get the data object (instance of BaseData, e.g., an Image) managed by this DataNode.
DataStructure which stores a set of points (incl. pointdata) where each point can be associated to an...
virtual TimeStepType TimePointToTimeStep(TimePointType timePoint) const =0
Converts a time point to the corresponding time step.
void SetPoints(const itk::Point< TCoordRep, NPointDimension > &point1, const itk::Point< TCoordRep, NPointDimension > &point2)
Define line by two points.
void ApplyColorAndOpacityProperties(mitk::BaseRenderer *renderer, vtkActor *actor=nullptr) override
Apply color and opacity properties read from the PropertyList. The actor is not used in the GLMappers...
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::Mesh * GetInput(void)
Get the Mesh to map.
void vtk2itk(const Tin &in, Tout &out)
vtkLinearTransform * GetVtkTransform(int t=0) const
Get the transformation applied prior to displaying the data as a vtkTransform.
void itk2vtk(const Tin &in, Tout &out)
const float selectedColor[]
Describes a two-dimensional, rectangular plane.
DataType::PointDataContainerIterator PointDataIterator
CellTraits::PointIdIterator PointIdIterator
BoundingBoxType::Pointer BoundingBoxPointer
virtual bool IsValidTimeStep(TimeStepType timeStep) const =0
Test for the given time step if a geometry is availible.