void mitk::ColorBarAnnotation::UpdateVtkAnnotation(mitk::BaseRenderer *renderer)
{
  LocalStorage *ls = this->m_LSH.GetLocalStorage(renderer);

  if (ls->IsGenerateDataRequired(renderer, this))
  {
    ls->m_ScalarBarActor->SetDrawAnnotations(this->GetDrawAnnotations());
    ls->m_ScalarBarActor->SetLookupTable(this->GetLookupTable());
    ls->m_ScalarBarActor->SetOrientation(this->GetOrientation());
    ls->m_ScalarBarActor->SetDrawTickLabels(this->GetDrawTickLabels());
    ls->m_ScalarBarActor->SetMaximumNumberOfColors(this->GetMaxNumberOfColors());
    ls->m_ScalarBarActor->SetNumberOfLabels(this->GetNumberOfLabels());
    ls->m_ScalarBarActor->SetAnnotationTextScaling(this->GetAnnotationTextScaling());
    // manually set position so there is no overlap with mitk logo in 3d renderwindow
    if (this->GetOrientation() == 1)
    {
      ls->m_ScalarBarActor->SetPosition(0.80, 0.15);
      ls->m_ScalarBarActor->SetWidth(0.15);
      ls->m_ScalarBarActor->SetHeight(0.85);
    }
    else
    {
      ls->m_ScalarBarActor->SetPosition(0.03, 0.03);
      ls->m_ScalarBarActor->SetWidth(0.8);
      ls->m_ScalarBarActor->SetHeight(0.15);
    }
  }
}
Ejemplo n.º 2
0
    int w_LocalStorage_prototype_clear(duk_context *ctx)
    {
        duk_push_this(ctx); /* this */
        duk_push_object(ctx); /* this, emptyObj */
        duk_put_prop_string(ctx, -2, "__MURAL_DATA__"); /* this */
        duk_pop(ctx);

        LocalStorage *inst = getNativePointer<LocalStorage>(ctx);
        inst->clear();

        return 0;
    }
Ejemplo n.º 3
0
void mitk::AxisOverlay::UpdateVtkAnnotation(mitk::BaseRenderer *renderer)
{
  LocalStorage *ls = this->m_LSH.GetLocalStorage(renderer);
  if (ls->IsGenerateDataRequired(renderer, this))
  {
    ls->m_widget->SetOrientationMarker(ls->m_axesActor);
    ls->m_widget->SetInteractor(renderer->GetRenderWindow()->GetInteractor());
    ls->m_widget->SetEnabled(true);
    ls->m_widget->SetOutlineColor(0.3, 0, 0);
    ls->m_widget->SetInteractive(true);
    ls->m_initialized = true;
  }
}
Ejemplo n.º 4
0
    int w_LocalStorage_prototype_removeItem(duk_context *ctx)
    {
        const char *key = duk_require_string(ctx, 0);

        duk_push_this(ctx); /* this */
        duk_get_prop_string(ctx, -1, "__MURAL_DATA__"); /* this, __MURAL_DATA__ */
        duk_del_prop_string(ctx, -1, key); /* this, __MURAL_DATA__ */

        LocalStorage *inst = getNativePointer<LocalStorage>(ctx);
        duk_json_encode(ctx, -1); /* this, JSON(__MURAL_DATA__) */
        inst->setData(duk_to_string(ctx, -1)); /* this, string(JSON(__MURAL_DATA__)) */

        duk_pop_2(ctx);

        return 0;
    }
void mitk::LabelAnnotation3D::UpdateVtkAnnotation(mitk::BaseRenderer *renderer)
{
  if (m_LabelCoordinates.IsNull())
  {
    MITK_WARN << "No pointset defined to print labels!";
    return;
  }
  LocalStorage *ls = this->m_LSH.GetLocalStorage(renderer);

  if (ls->IsGenerateDataRequired(renderer, this))
  {
    vtkSmartPointer<vtkPoints> points = vtkSmartPointer<vtkPoints>::New();

    size_t pointsetsize = (size_t)m_LabelCoordinates->GetSize();
    ls->m_Labels->SetNumberOfValues(pointsetsize);
    ls->m_Sizes->SetNumberOfValues(pointsetsize);

    for (size_t i = 0; i < pointsetsize; i++)
    {
      mitk::Point3D coordinate = m_LabelCoordinates->GetPoint(i);
      points->InsertNextPoint(coordinate[0] + GetOffsetVector()[0],
                              coordinate[1] + GetOffsetVector()[1],
                              coordinate[2] + GetOffsetVector()[2]);
      if (m_LabelVector.size() > i)
        ls->m_Labels->SetValue(i, m_LabelVector[i]);
      else
        ls->m_Labels->SetValue(i, "");

      if (m_PriorityVector.size() > i)
        ls->m_Sizes->SetValue(i, m_PriorityVector[i]);
      else
        ls->m_Sizes->SetValue(i, 1);
    }

    ls->m_Points->SetPoints(points);
    ls->m_PointSetToLabelHierarchyFilter->Update();
    ls->m_LabelMapper->Update();

    float color[3] = {1, 1, 1};
    float opacity = 1.0;
    GetColor(color);
    GetOpacity(opacity);
    ls->m_LabelsActor->GetProperty()->SetColor(color[0], color[1], color[2]);
    ls->m_LabelsActor->GetProperty()->SetOpacity(opacity);
    ls->UpdateGenerateDataTime();
  }
}
Ejemplo n.º 6
0
    int w_LocalStorage_prototype_setItem(duk_context *ctx)
    {
        const char *key = duk_require_string(ctx, 0);
        // Make sure value is string
        duk_to_string(ctx, 1);
        const char *value = duk_require_string(ctx, 1);

        duk_push_this(ctx); /* this */
        duk_get_prop_string(ctx, -1, "__MURAL_DATA__"); /* this, __MURAL_DATA__ */
        duk_push_string(ctx, value); /* this, __MURAL_DATA__, value */
        duk_put_prop_string(ctx, -2, key); /* this, __MURAL_DATA__ */

        LocalStorage *inst = getNativePointer<LocalStorage>(ctx);
        duk_json_encode(ctx, -1); /* this, JSON(__MURAL_DATA__) */
        inst->setData(duk_to_string(ctx, -1)); /* this, string(JSON(__MURAL_DATA__)) */

        duk_pop_2(ctx);

        return 0;
    }
Ejemplo n.º 7
0
void mitk::TextOverlay3D::UpdateVtkOverlay(mitk::BaseRenderer *renderer)
{
  LocalStorage* ls = this->m_LSH.GetLocalStorage(renderer);
  if(ls->IsGenerateDataRequired(renderer,this))
  {
    ls->m_follower->SetPosition(
      GetPosition3D(renderer)[0]+GetOffsetVector(renderer)[0],
      GetPosition3D(renderer)[1]+GetOffsetVector(renderer)[1],
      GetPosition3D(renderer)[2]+GetOffsetVector(renderer)[2]);
    ls->m_textSource->SetText(GetText().c_str());
    float color[3] = {1,1,1};
    float opacity = 1.0;
    GetColor(color,renderer);
    GetOpacity(opacity,renderer);
    ls->m_follower->GetProperty()->SetColor(color[0], color[1], color[2]);
    ls->m_follower->GetProperty()->SetOpacity(opacity);
    ls->m_follower->SetScale(this->GetFontSize());
    vtkRenderer* vtkRender = renderer->GetVtkRenderer();
    if(vtkRender)
      ls->m_follower->SetCamera(vtkRender->GetActiveCamera());
    ls->UpdateGenerateDataTime();
  }
}
Ejemplo n.º 8
0
void mitk::TextOverlay2D::UpdateVtkOverlay2D(mitk::BaseRenderer *renderer)
{
  LocalStorage* ls = this->m_LSH.GetLocalStorage(renderer);

  if (ls->IsGenerateDataRequired(renderer, this))
  {
    float color[3] = { 0.0, 1.0, 0.0 };
    float opacity = 1.0;
    GetColor(color, renderer);
    GetOpacity(opacity, renderer);
    ls->m_TextProp->SetColor(color[0], color[1], color[2]);
    ls->m_STextProp->SetColor(0, 0, 0);
    ls->m_TextProp->SetFontSize(GetFontSize());
    ls->m_TextProp->SetOpacity(opacity);
    ls->m_STextProp->SetFontSize(GetFontSize());
    ls->m_STextProp->SetOpacity(opacity);

    bool drawShadow;
    GetBoolProperty("drawShadow", drawShadow);
    ls->m_TextProp->SetShadow(false);
    ls->m_STextProp->SetShadow(false);
    ls->m_STextActor->SetVisibility(drawShadow);

    ls->m_TextActor->SetInput(GetText().c_str());
    ls->m_STextActor->SetInput(GetText().c_str());

    mitk::Point2D posT, posS;
    posT[0] = GetPosition2D(renderer)[0] + GetOffsetVector(renderer)[0];
    posT[1] = GetPosition2D(renderer)[1] + GetOffsetVector(renderer)[1];
    posS[0] = posT[0] + 1;
    posS[1] = posT[1] - 1;

    ls->m_TextActor->SetDisplayPosition(posT[0], posT[1]);
    ls->m_STextActor->SetDisplayPosition(posS[0], posS[1]);
    ls->UpdateGenerateDataTime();
  }
}
Ejemplo n.º 9
0
void RemoteStorage::sync(LocalStorage ls) {
	cout << "Sync" << endl;
	
	date last_sync;
	convert_time(last_sync, ls.get_last_sync_time());

	vector<pair<string, int> > files = get_list();
	time_t start_sync_time;
	time(&start_sync_time);

	set<string> remote_storage_files;
	
	for (int i = 0; i < files.size(); i++) {
		pair<string, int> file = files[i];
		
		if (file.first.find("/") == string::npos) {
			date mail_date;
			string path;			

			parse_header(file.first, mail_date, path);
	
			remote_storage_files.insert(path);

			date file_date;
			
			if (!get_file_date(file_date, ls.get_path()+"/"+path)) {
				// file not exist
				if (last_sync < mail_date) {
					string tmp;
					cout << "File " << path << " doesn't exist in local storage; Downloading..." << endl;
					if (!download(file.second, ls.get_path(), tmp)) {
						cout << tmp;
					}
				} else {
					cout << "File " << path << " removed in local storage; Removing file from remote storage" << endl;
					remove(file.second);
				}
			} else {
				// file exist
				if (mail_date < file_date) {
					cout << "File " << path << " sending to remote storage" << endl;
					send(path, ls.get_path()+"/"+path);
				} 

				if (file_date < mail_date) {
					cout << "File " << path << " downloading from remote storage" << endl;
					string tmp;
					if (!download(file.second, ls.get_path(), tmp)) {
						cout << tmp;
					}
				}		
			}
		}
	}
 
	vector<string> local_files = read_dir(ls.get_path().c_str());

	for (int i = 0; i < local_files.size(); i++) {
		string file = get_file_name(local_files[i]);		

		if (remote_storage_files.count(file) == 0) {
			cout << "sending new file " << file << " to remote storage" << endl;
			send(file, ls.get_path()+"/"+file);
		}
	} 	
	
	ls.set_last_sync_time(start_sync_time);	

	cout << "Sync is finished" << endl;
}
void mitk::PointSetVtkMapper2D::GenerateDataForRenderer( mitk::BaseRenderer *renderer )
{
  const mitk::DataNode* node = GetDataNode();
  if( node == NULL )
    return;

  LocalStorage *ls = m_LSH.GetLocalStorage(renderer);

  // check whether the input data has been changed
  bool needGenerateData = ls->IsGenerateDataRequired( renderer, this, GetDataNode() );

  // toggle visibility
  bool visible = true;
  node->GetVisibility(visible, renderer, "visible");
  if(!visible)
  {
    ls->m_UnselectedActor->VisibilityOff();
    ls->m_SelectedActor->VisibilityOff();
    ls->m_ContourActor->VisibilityOff();
    ls->m_PropAssembly->VisibilityOff();
    return;
  }else{
    ls->m_PropAssembly->VisibilityOn();
  }

  node->GetBoolProperty("show contour",       m_ShowContour, renderer);
  node->GetBoolProperty("close contour",      m_CloseContour, renderer);
  node->GetBoolProperty("show points",        m_ShowPoints, renderer);
  node->GetBoolProperty("show distances",     m_ShowDistances, renderer);
  node->GetIntProperty("distance decimal digits",     m_DistancesDecimalDigits, renderer);
  node->GetBoolProperty("show angles",        m_ShowAngles, renderer);
  node->GetBoolProperty("show distant lines", m_ShowDistantLines, renderer);
  node->GetIntProperty("line width",          m_LineWidth, renderer);
  node->GetIntProperty("point line width",    m_PointLineWidth, renderer);
  node->GetIntProperty("point 2D size",       m_Point2DSize, renderer);
  node->GetBoolProperty("Pointset.2D.fill shape", m_FillShape, renderer);
  node->GetFloatProperty("Pointset.2D.distance to plane", m_DistanceToPlane, renderer );

  mitk::PointSetShapeProperty::Pointer shape = dynamic_cast<mitk::PointSetShapeProperty*>(this->GetDataNode()->GetProperty( "Pointset.2D.shape", renderer ));
  if(shape.IsNotNull())
  {
    m_IDShapeProperty = shape->GetPointSetShape();
  }

  //check for color props and use it for rendering of selected/unselected points and contour
  //due to different params in VTK (double/float) we have to convert

  float unselectedColor[4];
  double selectedColor[4]={1.0f,0.0f,0.0f,1.0f};    //red
  double contourColor[4]={1.0f,0.0f,0.0f,1.0f};     //red

  float opacity = 1.0;

  GetDataNode()->GetOpacity(opacity, renderer);

  // apply color and opacity
  if(m_ShowPoints)
  {
    ls->m_UnselectedActor->VisibilityOn();
    ls->m_SelectedActor->VisibilityOn();

    //check if there is a color property
    GetDataNode()->GetColor(unselectedColor);

    //get selected color property
    if (dynamic_cast<mitk::ColorProperty*>(this->GetDataNode()->GetPropertyList(renderer)->GetProperty("selectedcolor")) != NULL)
    {
      mitk::Color tmpColor = dynamic_cast<mitk::ColorProperty *>(this->GetDataNode()->GetPropertyList(renderer)->GetProperty("selectedcolor"))->GetValue();
      selectedColor[0] = tmpColor[0];
      selectedColor[1] = tmpColor[1];
      selectedColor[2] = tmpColor[2];
      selectedColor[3] = 1.0f; // alpha value
    }
    else if (dynamic_cast<mitk::ColorProperty*>(this->GetDataNode()->GetPropertyList(NULL)->GetProperty("selectedcolor")) != NULL)
    {
      mitk::Color tmpColor = dynamic_cast<mitk::ColorProperty *>(this->GetDataNode()->GetPropertyList(NULL)->GetProperty("selectedcolor"))->GetValue();
      selectedColor[0] = tmpColor[0];
      selectedColor[1] = tmpColor[1];
      selectedColor[2] = tmpColor[2];
      selectedColor[3] = 1.0f; // alpha value
    }

    ls->m_SelectedActor->GetProperty()->SetColor(selectedColor);
    ls->m_SelectedActor->GetProperty()->SetOpacity(opacity);

    ls->m_UnselectedActor->GetProperty()->SetColor(unselectedColor[0],unselectedColor[1],unselectedColor[2]);
    ls->m_UnselectedActor->GetProperty()->SetOpacity(opacity);
  }
  else
  {
    ls->m_UnselectedActor->VisibilityOff();
    ls-> m_SelectedActor->VisibilityOff();
  }

  if (m_ShowContour)
  {
    ls->m_ContourActor->VisibilityOn();

    //get contour color property
    if (dynamic_cast<mitk::ColorProperty*>(this->GetDataNode()->GetPropertyList(renderer)->GetProperty("contourcolor")) != NULL)
    {
      mitk::Color tmpColor = dynamic_cast<mitk::ColorProperty *>(this->GetDataNode()->GetPropertyList(renderer)->GetProperty("contourcolor"))->GetValue();
      contourColor[0] = tmpColor[0];
      contourColor[1] = tmpColor[1];
      contourColor[2] = tmpColor[2];
      contourColor[3] = 1.0f;
    }
    else if (dynamic_cast<mitk::ColorProperty*>(this->GetDataNode()->GetPropertyList(NULL)->GetProperty("contourcolor")) != NULL)
    {
      mitk::Color tmpColor = dynamic_cast<mitk::ColorProperty *>(this->GetDataNode()->GetPropertyList(NULL)->GetProperty("contourcolor"))->GetValue();
      contourColor[0] = tmpColor[0];
      contourColor[1] = tmpColor[1];
      contourColor[2] = tmpColor[2];
      contourColor[3] = 1.0f;
    }

    ls->m_ContourActor->GetProperty()->SetColor(contourColor);
    ls->m_ContourActor->GetProperty()->SetOpacity(opacity);
  }
  else
  {
    ls->m_ContourActor->VisibilityOff();
  }

  if(needGenerateData)
  {
    // create new vtk render objects (e.g. a circle for a point)
    this->CreateVTKRenderObjects(renderer);
  }
}
void mitk::BoundingShapeVtkMapper2D::GenerateDataForRenderer(BaseRenderer *renderer)
{
  const DataNode::Pointer node = GetDataNode();
  if (node == nullptr)
    return;

  LocalStorage *localStorage = m_Impl->LocalStorageHandler.GetLocalStorage(renderer);

  // either update if GeometryData was modified or if the zooming was performed
  bool needGenerateData = localStorage->IsUpdateRequired(
    renderer, this, GetDataNode()); // true; // localStorage->GetLastGenerateDataTime() < node->GetMTime() ||
  // localStorage->GetLastGenerateDataTime() < node->GetData()->GetMTime();
  // //localStorage->IsGenerateDataRequired(renderer, this, GetDataNode());

  double scale = renderer->GetScaleFactorMMPerDisplayUnit();

  if (std::abs(scale - localStorage->m_ZoomFactor) > 0.001)
  {
    localStorage->m_ZoomFactor = scale;
    needGenerateData = true;
  }

  if (needGenerateData)
  {
    bool visible = true;
    GetDataNode()->GetVisibility(visible, renderer, "visible");

    if (!visible)
    {
      localStorage->m_Actor->VisibilityOff();
      return;
    }
    GeometryData::Pointer shape = static_cast<GeometryData *>(node->GetData());
    if (shape == nullptr)
      return;

    mitk::BaseGeometry::Pointer geometry = shape->GetGeometry();
    mitk::Vector3D spacing = geometry->GetSpacing();

    // calculate cornerpoints and extent from geometry with visualization offset
    std::vector<Point3D> cornerPoints = GetCornerPoints(geometry, true);
    Point3D p0 = cornerPoints[0];
    Point3D p1 = cornerPoints[1];
    Point3D p2 = cornerPoints[2];
    Point3D p4 = cornerPoints[4];
    Point3D extent;
    extent[0] =
      sqrt((p0[0] - p4[0]) * (p0[0] - p4[0]) + (p0[1] - p4[1]) * (p0[1] - p4[1]) + (p0[2] - p4[2]) * (p0[2] - p4[2]));
    extent[1] =
      sqrt((p0[0] - p2[0]) * (p0[0] - p2[0]) + (p0[1] - p2[1]) * (p0[1] - p2[1]) + (p0[2] - p2[2]) * (p0[2] - p2[2]));
    extent[2] =
      sqrt((p0[0] - p1[0]) * (p0[0] - p1[0]) + (p0[1] - p1[1]) * (p0[1] - p1[1]) + (p0[2] - p1[2]) * (p0[2] - p1[2]));

    // calculate center based on half way of the distance between two opposing cornerpoints
    mitk::Point3D center = CalcAvgPoint(cornerPoints[7], cornerPoints[0]);

    if (m_Impl->HandlePropertyList.size() == 6)
    {
      // set handle positions
      Point3D pointLeft = CalcAvgPoint(cornerPoints[5], cornerPoints[6]);
      Point3D pointRight = CalcAvgPoint(cornerPoints[1], cornerPoints[2]);
      Point3D pointTop = CalcAvgPoint(cornerPoints[0], cornerPoints[6]);
      Point3D pointBottom = CalcAvgPoint(cornerPoints[7], cornerPoints[1]);
      Point3D pointFront = CalcAvgPoint(cornerPoints[2], cornerPoints[7]);
      Point3D pointBack = CalcAvgPoint(cornerPoints[4], cornerPoints[1]);

      m_Impl->HandlePropertyList[0].SetPosition(pointLeft);
      m_Impl->HandlePropertyList[1].SetPosition(pointRight);
      m_Impl->HandlePropertyList[2].SetPosition(pointTop);
      m_Impl->HandlePropertyList[3].SetPosition(pointBottom);
      m_Impl->HandlePropertyList[4].SetPosition(pointFront);
      m_Impl->HandlePropertyList[5].SetPosition(pointBack);
    }

    // caculate face normals
    double result0[3], result1[3], result2[3];
    double a[3], b[3];
    a[0] = (cornerPoints[5][0] - cornerPoints[6][0]);
    a[1] = (cornerPoints[5][1] - cornerPoints[6][1]);
    a[2] = (cornerPoints[5][2] - cornerPoints[6][2]);

    b[0] = (cornerPoints[5][0] - cornerPoints[4][0]);
    b[1] = (cornerPoints[5][1] - cornerPoints[4][1]);
    b[2] = (cornerPoints[5][2] - cornerPoints[4][2]);

    vtkMath::Cross(a, b, result0);

    a[0] = (cornerPoints[0][0] - cornerPoints[6][0]);
    a[1] = (cornerPoints[0][1] - cornerPoints[6][1]);
    a[2] = (cornerPoints[0][2] - cornerPoints[6][2]);

    b[0] = (cornerPoints[0][0] - cornerPoints[2][0]);
    b[1] = (cornerPoints[0][1] - cornerPoints[2][1]);
    b[2] = (cornerPoints[0][2] - cornerPoints[2][2]);

    vtkMath::Cross(a, b, result1);

    a[0] = (cornerPoints[2][0] - cornerPoints[7][0]);
    a[1] = (cornerPoints[2][1] - cornerPoints[7][1]);
    a[2] = (cornerPoints[2][2] - cornerPoints[7][2]);

    b[0] = (cornerPoints[2][0] - cornerPoints[6][0]);
    b[1] = (cornerPoints[2][1] - cornerPoints[6][1]);
    b[2] = (cornerPoints[2][2] - cornerPoints[6][2]);

    vtkMath::Cross(a, b, result2);

    vtkMath::Normalize(result0);
    vtkMath::Normalize(result1);
    vtkMath::Normalize(result2);

    // create cube for rendering bounding box
    auto cube = vtkCubeSource::New();
    cube->SetXLength(extent[0] / spacing[0]);
    cube->SetYLength(extent[1] / spacing[1]);
    cube->SetZLength(extent[2] / spacing[2]);

    // calculates translation based on offset+extent not on the transformation matrix
    vtkSmartPointer<vtkMatrix4x4> imageTransform = geometry->GetVtkTransform()->GetMatrix();
    auto translation = vtkSmartPointer<vtkTransform>::New();
    translation->Translate(center[0] - imageTransform->GetElement(0, 3),
      center[1] - imageTransform->GetElement(1, 3),
      center[2] - imageTransform->GetElement(2, 3));

    auto transform = vtkSmartPointer<vtkTransform>::New();
    transform->SetMatrix(imageTransform);
    transform->PostMultiply();
    transform->Concatenate(translation);
    transform->Update();
    cube->Update();

    auto transformFilter = vtkSmartPointer<vtkTransformFilter>::New();
    transformFilter->SetInputData(cube->GetOutput());
    transformFilter->SetTransform(transform);
    transformFilter->Update();
    cube->Delete();

    vtkSmartPointer<vtkPolyData> polydata = transformFilter->GetPolyDataOutput();
    if (polydata == nullptr || (polydata->GetNumberOfPoints() < 1))
    {
      localStorage->m_Actor->VisibilityOff();
      localStorage->m_HandleActor->VisibilityOff();
      localStorage->m_SelectedHandleActor->VisibilityOff();
      return;
    }

    // estimate current image plane to decide whether the cube is visible or not
    const PlaneGeometry *planeGeometry = renderer->GetCurrentWorldPlaneGeometry();
    if ((planeGeometry == nullptr) || (!planeGeometry->IsValid()) || (!planeGeometry->HasReferenceGeometry()))
      return;

    double origin[3];
    origin[0] = planeGeometry->GetOrigin()[0];
    origin[1] = planeGeometry->GetOrigin()[1];
    origin[2] = planeGeometry->GetOrigin()[2];

    double normal[3];
    normal[0] = planeGeometry->GetNormal()[0];
    normal[1] = planeGeometry->GetNormal()[1];
    normal[2] = planeGeometry->GetNormal()[2];

    //    MITK_INFO << "normal1 " << normal[0] << " " << normal[1] << " " << normal[2];
    localStorage->m_CuttingPlane->SetOrigin(origin);
    localStorage->m_CuttingPlane->SetNormal(normal);

    // add cube polydata to local storage
    localStorage->m_Cutter->SetInputData(polydata);
    localStorage->m_Cutter->SetGenerateCutScalars(1);
    localStorage->m_Cutter->Update();

    if (localStorage->m_PropAssembly->GetParts()->IsItemPresent(localStorage->m_HandleActor))
      localStorage->m_PropAssembly->RemovePart(localStorage->m_HandleActor);
    if (localStorage->m_PropAssembly->GetParts()->IsItemPresent(localStorage->m_Actor))
      localStorage->m_PropAssembly->RemovePart(localStorage->m_Actor);

    vtkCoordinate *tcoord = vtkCoordinate::New();
    tcoord->SetCoordinateSystemToWorld();
    localStorage->m_HandleMapper->SetTransformCoordinate(tcoord);
    tcoord->Delete();

    if (localStorage->m_Cutter->GetOutput()->GetNumberOfPoints() > 0) // if plane is visible in the renderwindow
    {
      mitk::DoubleProperty::Pointer handleSizeProperty =
        dynamic_cast<mitk::DoubleProperty *>(this->GetDataNode()->GetProperty("Bounding Shape.Handle Size Factor"));

      ScalarType initialHandleSize;
      if (handleSizeProperty != nullptr)
        initialHandleSize = handleSizeProperty->GetValue();
      else
        initialHandleSize = 1.0 / 40.0;

      mitk::Point2D displaySize = renderer->GetDisplaySizeInMM();
      double handleSize = ((displaySize[0] + displaySize[1]) / 2.0) * initialHandleSize;

      auto appendPoly = vtkSmartPointer<vtkAppendPolyData>::New();
      unsigned int i = 0;

      // add handles and their assigned properties to the local storage
      mitk::IntProperty::Pointer activeHandleId =
        dynamic_cast<mitk::IntProperty *>(node->GetProperty("Bounding Shape.Active Handle ID"));

      bool visible = false;
      bool selected = false;
      for (auto handle : localStorage->m_Handles)
      {
        Point3D handleCenter = m_Impl->HandlePropertyList[i].GetPosition();

        handle->SetRadius(handleSize);
        handle->SetCenter(handleCenter[0], handleCenter[1], handleCenter[2]);

        vtkMath::Normalize(normal);
        double angle = vtkMath::DegreesFromRadians(acos(vtkMath::Dot(normal, result0)));
        double angle1 = vtkMath::DegreesFromRadians(acos(vtkMath::Dot(normal, result1)));
        double angle2 = vtkMath::DegreesFromRadians(acos(vtkMath::Dot(normal, result2)));

        // show handles only if the corresponding face is aligned to the render window
        if ((((std::abs(angle - 0) < 0.001) || (std::abs(angle - 180) < 0.001)) && i != 0 && i != 1) ||
          (((std::abs(angle1 - 0) < 0.001) || (std::abs(angle1 - 180) < 0.001)) && i != 2 && i != 3) ||
          (((std::abs(angle2 - 0) < 0.001) || (std::abs(angle2 - 180) < 0.001)) && i != 4 && i != 5))
        {
          if (activeHandleId == nullptr)
          {
            appendPoly->AddInputConnection(handle->GetOutputPort());
          }
          else
          {
            if ((activeHandleId->GetValue() != m_Impl->HandlePropertyList[i].GetIndex()))
            {
              appendPoly->AddInputConnection(handle->GetOutputPort());
            }
            else
            {
              handle->Update();
              localStorage->m_SelectedHandleMapper->SetInputData(handle->GetOutput());
              localStorage->m_SelectedHandleActor->VisibilityOn();
              selected = true;
            }
          }
          visible = true;
        }

        i++;
      }

      if (visible)
      {
        appendPoly->Update();
      }
      else
      {
        localStorage->m_HandleActor->VisibilityOff();
        localStorage->m_SelectedHandleActor->VisibilityOff();
      }

      auto stripper = vtkSmartPointer<vtkStripper>::New();
      stripper->SetInputData(localStorage->m_Cutter->GetOutput());
      stripper->Update();

      auto cutPolyData = vtkSmartPointer<vtkPolyData>::New();
      cutPolyData->SetPoints(stripper->GetOutput()->GetPoints());
      cutPolyData->SetPolys(stripper->GetOutput()->GetLines());

      localStorage->m_Actor->GetMapper()->SetInputDataObject(cutPolyData);
      mitk::ColorProperty::Pointer selectedColor = dynamic_cast<mitk::ColorProperty *>(node->GetProperty("color"));
      if (selectedColor != nullptr)
      {
        mitk::Color color = selectedColor->GetColor();
        localStorage->m_Actor->GetProperty()->SetColor(color[0], color[1], color[2]);
      }

      if (activeHandleId != nullptr)
      {
        localStorage->m_HandleActor->GetProperty()->SetColor(1, 0, 0);
      }
      else
      {
        localStorage->m_HandleActor->GetProperty()->SetColor(1, 1, 1);
      }
      localStorage->m_HandleActor->GetMapper()->SetInputDataObject(appendPoly->GetOutput());

      // add parts to the overall storage
      localStorage->m_PropAssembly->AddPart(localStorage->m_Actor);
      localStorage->m_PropAssembly->AddPart(localStorage->m_HandleActor);
      if (selected)
      {
        localStorage->m_PropAssembly->AddPart(localStorage->m_SelectedHandleActor);
      }

      localStorage->m_PropAssembly->VisibilityOn();
      localStorage->m_Actor->VisibilityOn();
      localStorage->m_HandleActor->VisibilityOn();
    }
    else
    {
      localStorage->m_PropAssembly->VisibilityOff();
      localStorage->m_Actor->VisibilityOff();
      localStorage->m_HandleActor->VisibilityOff();
      localStorage->m_SelectedHandleActor->VisibilityOff();
      localStorage->UpdateGenerateDataTime();
    }
    localStorage->UpdateGenerateDataTime();
  }
}