Medical Imaging Interaction Toolkit  2018.4.99-93926fb8
Medical Imaging Interaction Toolkit
mitkContourModelSetGLMapper2D.cpp
Go to the documentation of this file.
1 /*============================================================================
2 
3 The Medical Imaging Interaction Toolkit (MITK)
4 
5 Copyright (c) German Cancer Research Center (DKFZ)
6 All rights reserved.
7 
8 Use of this source code is governed by a 3-clause BSD license that can be
9 found in the LICENSE file.
10 
11 ============================================================================*/
12 
14 
15 #include "mitkColorProperty.h"
16 #include "mitkContourModelSet.h"
17 #include "mitkPlaneGeometry.h"
18 #include "mitkProperties.h"
19 #include <vtkLinearTransform.h>
20 
21 #include "mitkGL.h"
22 
24 {
25 }
26 
28 {
29 }
30 
32 {
34 
35  mitk::DataNode::Pointer dataNode = this->GetDataNode();
36  bool visible = true;
37  dataNode->GetVisibility(visible, nullptr);
38 
39  if (!visible)
40  return;
41 
42  mitk::ContourModelSet::Pointer input = this->GetInput();
43 
44  auto centerOfViewPointZ = renderer->GetCurrentWorldPlaneGeometry()->GetCenter()[2];
45  auto it = input->Begin();
46 
47  auto end = input->End();
48 
49  while (it != end)
50  {
51  //we have the assumption that each contour model vertex has the same z coordinate
52  auto currentZValue = (*it)->GetVertexAt(0)->Coordinates[2];
53  double acceptedDeviationInMM = 5.0;
54  //only draw contour if it is visible
55  if (currentZValue - acceptedDeviationInMM < centerOfViewPointZ && currentZValue + acceptedDeviationInMM > centerOfViewPointZ){
56  this->DrawContour(it->GetPointer(), renderer);
57  }
58  ++it;
59  }
60 
61  if (input->GetSize() < 1)
62  return;
63 
65 }
66 
67 mitk::ContourModelSet *mitk::ContourModelSetGLMapper2D::GetInput(void)
68 {
69  return static_cast<mitk::ContourModelSet *>(GetDataNode()->GetData());
70 }
71 
73  mitk::BaseRenderer *renderer,
74  bool overwrite)
75 {
76  node->AddProperty("contour.color", ColorProperty::New(0.9, 1.0, 0.1), renderer, overwrite);
77  node->AddProperty("contour.points.color", ColorProperty::New(1.0, 0.0, 0.1), renderer, overwrite);
78  node->AddProperty("contour.points.show", mitk::BoolProperty::New(false), renderer, overwrite);
79  node->AddProperty("contour.segments.show", mitk::BoolProperty::New(true), renderer, overwrite);
80  node->AddProperty("contour.controlpoints.show", mitk::BoolProperty::New(false), renderer, overwrite);
81  node->AddProperty("contour.width", mitk::FloatProperty::New(1.0), renderer, overwrite);
82  node->AddProperty("contour.hovering.width", mitk::FloatProperty::New(3.0), renderer, overwrite);
83  node->AddProperty("contour.hovering", mitk::BoolProperty::New(false), renderer, overwrite);
84  node->AddProperty("contour.points.text", mitk::BoolProperty::New(false), renderer, overwrite);
85  node->AddProperty("contour.controlpoints.text", mitk::BoolProperty::New(false), renderer, overwrite);
86 
87  node->AddProperty("contour.project-onto-plane", mitk::BoolProperty::New(false), renderer, overwrite);
88 
89  node->AddProperty("opacity", mitk::FloatProperty::New(1.0f), renderer, overwrite);
90 
91  Superclass::SetDefaultProperties(node, renderer, overwrite);
92 }
#define ls
Definition: MitkMCxyz.cpp:57
LocalStorageHandler< BaseLocalStorage > m_LSH
void MitkRender(mitk::BaseRenderer *renderer, mitk::VtkPropRenderer::RenderType type) override
L * GetLocalStorage(mitk::BaseRenderer *forRenderer)
Retrieves a LocalStorage for a specific BaseRenderer.
Base class for mapper specific rendering ressources.
Definition: mitkMapper.h:193
virtual DataNode * GetDataNode() const
Get the DataNode containing the data to map. Method only returns valid DataNode Pointer if the mapper...
Definition: mitkMapper.cpp:31
static Pointer New()
Organizes the rendering process.
virtual const PlaneGeometry * GetCurrentWorldPlaneGeometry()
Get the current 2D-worldgeometry (m_CurrentWorldPlaneGeometry) used for 2D-rendering.
Point3D GetCenter() const
Get the center of the bounding-box in mm.
static Pointer New()
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 ...
void DrawContour(mitk::ContourModel *contour, mitk::BaseRenderer *renderer)
static Pointer New()
static void SetDefaultProperties(mitk::DataNode *node, mitk::BaseRenderer *renderer=nullptr, bool overwrite=false)
Class for nodes of the DataTree.
Definition: mitkDataNode.h:57