26 #include <vtkLinearTransform.h>
42 return static_cast<const mitk::Mesh *
>(GetDataNode()->GetData());
48 if (elem1[0] != elem2[0])
49 return elem1[0] < elem2[0];
50 if (elem1[1] != elem2[1])
51 return elem1[1] < elem2[1];
52 return elem1[2] < elem2[2];
59 GetDataNode()->GetVisibility(visible, renderer,
"visible");
65 bool updateNeccesary =
true;
73 const TimeGeometry *inputTimeGeometry = input->GetTimeGeometry();
74 if ((inputTimeGeometry == NULL) || (inputTimeGeometry->CountTimeSteps() == 0))
88 if (time > itk::NumericTraits<mitk::ScalarType>::NonpositiveMin())
97 if (itkMesh.GetPointer() == NULL)
105 ApplyColorAndOpacityProperties(renderer);
107 vtkLinearTransform *transform = GetDataNode()->GetVtkTransform();
110 Mesh::DataType::PointsContainerConstIterator it, end;
111 it = itkMesh->GetPoints()->Begin();
112 end = itkMesh->GetPoints()->End();
116 dataIt = itkMesh->GetPointData()->Begin();
119 float unselectedColor[4];
120 glGetFloatv(GL_CURRENT_COLOR, unselectedColor);
128 transform->TransformPoint(vtkp, vtkp);
133 if (diff.GetSquaredNorm() < 4.0)
145 if (dataIt->Value().selected)
151 switch (dataIt->Value().pointSpec)
156 glBegin(GL_LINE_LOOP);
157 tmp = pt2d - horz + vert;
158 glVertex2dv(&tmp[0]);
159 tmp = pt2d + horz + vert;
160 glVertex2dv(&tmp[0]);
161 tmp = pt2d + horz - vert;
162 glVertex2dv(&tmp[0]);
163 tmp = pt2d - horz - vert;
164 glVertex2dv(&tmp[0]);
171 glBegin(GL_LINE_LOOP);
173 glVertex2dv(&tmp[0]);
175 glVertex2dv(&tmp[0]);
177 glVertex2dv(&tmp[0]);
179 glVertex2dv(&tmp[0]);
190 glVertex2dv(&tmp[0]);
195 glColor3f(unselectedColor[0], unselectedColor[1], unselectedColor[2]);
196 switch (dataIt->Value().pointSpec)
201 glBegin(GL_LINE_LOOP);
202 tmp = pt2d - horz + vert;
203 glVertex2dv(&tmp[0]);
204 tmp = pt2d + horz + vert;
205 glVertex2dv(&tmp[0]);
206 tmp = pt2d + horz - vert;
207 glVertex2dv(&tmp[0]);
208 tmp = pt2d - horz - vert;
209 glVertex2dv(&tmp[0]);
217 glVertex2dv(&tmp[0]);
219 glVertex2dv(&tmp[0]);
221 glVertex2dv(&tmp[0]);
223 glVertex2dv(&tmp[0]);
242 unsigned int lastPointId = 0;
243 bool lineSelected =
false;
249 std::vector<mitk::Point3D> intersectionPoints;
257 cellIt = itkMesh->GetCells()->Begin();
258 cellEnd = itkMesh->GetCells()->End();
259 cellDataIt = itkMesh->GetCellData()->Begin();
261 while (cellIt != cellEnd)
263 unsigned int numOfPointsInCell = cellIt->Value()->GetNumberOfPoints();
264 if (numOfPointsInCell > 1)
267 cellIdIt = cellIt->Value()->PointIdsBegin();
268 cellIdEnd = cellIt->Value()->PointIdsEnd();
270 firstOfCell3D = input->GetPoint(*cellIdIt, timeStep);
272 intersectionPoints.clear();
273 intersectionPoints.reserve(numOfPointsInCell);
277 while (cellIdIt != cellIdEnd)
279 lastPoint3D = thisPoint;
281 thisPoint = input->GetPoint(*cellIdIt, timeStep);
284 lineSelected =
false;
290 if (position != selectedLines.end())
298 transform->TransformPoint(vtkp, vtkp);
302 if (diff.GetSquaredNorm() < 4.0)
307 if (lastPoint == NULL)
314 lastPointId = *cellIdIt;
323 glVertex2dv(&(*lastPoint)[0]);
324 glVertex2dv(&pt2d[0]);
329 glColor3f(unselectedColor[0], unselectedColor[1], unselectedColor[2]);
332 glVertex2dv(&(*lastPoint)[0]);
333 glVertex2dv(&pt2d[0]);
339 lastPointId = *cellIdIt;
344 if ((!first) && (worldplanegeometry != NULL))
349 intersectionPoints.push_back(line.
GetPoint(t));
357 if (cellDataIt->Value().closed)
360 if (firstOfCell != NULL)
362 lineSelected =
false;
365 if (position != selectedLines.end())
370 glVertex2dv(&(*lastPoint)[0]);
371 glVertex2dv(&(*firstOfCell)[0]);
376 glColor3f(unselectedColor[0], unselectedColor[1], unselectedColor[2]);
378 glVertex2dv(&(*lastPoint)[0]);
379 glVertex2dv(&(*firstOfCell)[0]);
386 bool showBoundingBox;
387 if (dynamic_cast<mitk::BoolProperty *>(this->GetDataNode()->GetProperty(
"showBoundingBox")) == NULL)
388 showBoundingBox =
false;
391 dynamic_cast<mitk::BoolProperty *
>(this->GetDataNode()->GetProperty(
"showBoundingBox"))->GetValue();
395 if (cellDataIt->Value().selected)
398 if (aABB.IsNotNull())
401 min = aABB->GetMinimum();
402 max = aABB->GetMaximum();
409 transform->TransformPoint(vtkp, vtkp);
414 transform->TransformPoint(vtkp, vtkp);
418 if (diff.GetSquaredNorm() < 4.0)
425 glBegin(GL_LINE_LOOP);
426 glVertex2f(min2D[0], min2D[1]);
427 glVertex2f(min2D[0], max2D[1]);
428 glVertex2f(max2D[0], max2D[1]);
429 glVertex2f(max2D[0], min2D[1]);
437 if (worldplanegeometry != NULL)
440 line.
SetPoints(thisPoint, firstOfCell3D);
443 intersectionPoints.push_back(line.
GetPoint(t));
445 std::sort(intersectionPoints.begin(), intersectionPoints.end(),
point3DSmaller);
446 std::vector<mitk::Point3D>::iterator it, end;
447 end = intersectionPoints.end();
448 if ((intersectionPoints.size() % 2) != 0)
453 for (it = intersectionPoints.begin(); it != end; ++it)
457 glVertex2dv(pt2d.GetDataPointer());
460 glVertex2dv(pt2d.GetDataPointer());
463 if (it != intersectionPoints.end())
467 glVertex2dv(pt2d.GetDataPointer());
468 glVertex2dv(pt2d.GetDataPointer());
static bool point3DSmaller(const mitk::Point3D &elem1, const mitk::Point3D &elem2)
bool IntersectionPointParam(const Line3D &line, double &t) const
Calculate line parameter of intersection point between the plane and a line.
Point< ScalarType, 2 > Point2D
itk::SmartPointer< Self > Pointer
DataType::CellDataContainerIterator CellDataIterator
Organizes the rendering process.
ScalarType GetTime() const
Get the time in ms of the currently displayed content.
SelectedLinesType::iterator SelectedLinesIter
virtual const PlaneGeometry * GetCurrentWorldPlaneGeometry()
Get the current 2D-worldgeometry (m_CurrentWorldPlaneGeometry) used for 2D-rendering.
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...
virtual void Paint(mitk::BaseRenderer *renderer) override
Do the painting into the renderer.
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...
DataStructure which stores a set of points (incl. pointdata) where each point can be associated to an...
const itk::Point< TCoordRep, NPointDimension > & GetPoint() const
Get start point of the line.
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.
const mitk::Mesh * GetInput(void)
Get the Mesh to map.
void vtk2itk(const Tin &in, Tout &out)
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 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.