diff --git a/Modules/Simulation/mitkExportMitkVisitor.cpp b/Modules/Simulation/mitkExportMitkVisitor.cpp index 4d9ef80592..6c7cd634dd 100644 --- a/Modules/Simulation/mitkExportMitkVisitor.cpp +++ b/Modules/Simulation/mitkExportMitkVisitor.cpp @@ -1,230 +1,230 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #include "mitkExportMitkVisitor.h" #include #include #include #include #include #include #include #include #include static void ApplyMaterial(mitk::DataNode::Pointer dataNode, const sofa::core::loader::Material& material) { using sofa::defaulttype::Vec4f; if (dataNode.IsNull() || dynamic_cast(dataNode->GetData()) == NULL) return; if (material.useDiffuse) dataNode->SetFloatProperty("opacity", material.diffuse[3]); Vec4f ambient = material.useAmbient ? material.ambient : Vec4f(); Vec4f diffuse = material.useDiffuse ? material.diffuse : Vec4f(); Vec4f specular = material.useSpecular ? material.specular : Vec4f(); float shininess = material.useShininess ? std::min(material.shininess, 128.0f) : 45.0f; if (shininess == 0.0f) { specular.clear(); shininess = 1.0f; } dataNode->SetFloatProperty("material.ambientCoefficient", 1.0f); - dataNode->SetProperty("material.ambientColor", mitk::ColorProperty::New(material.ambient.elems)); + dataNode->SetProperty("material.ambientColor", mitk::ColorProperty::New(ambient.elems)); dataNode->SetFloatProperty("material.diffuseCoefficient", 1.0f); - dataNode->SetProperty("color", mitk::ColorProperty::New(material.diffuse.elems)); + dataNode->SetProperty("color", mitk::ColorProperty::New(diffuse.elems)); dataNode->SetFloatProperty("material.specularCoefficient", 1.0f); dataNode->SetProperty("material.specularColor", mitk::ColorProperty::New(specular.elems)); dataNode->SetFloatProperty("material.specularPower", shininess); } static mitk::DataNode::Pointer GetSimulationDataNode(mitk::DataStorage::Pointer dataStorage, sofa::core::objectmodel::BaseNode::SPtr rootNode) { if (dataStorage.IsNull()) return NULL; if (!rootNode) return NULL; mitk::TNodePredicateDataType::Pointer predicate = mitk::TNodePredicateDataType::New(); mitk::DataStorage::SetOfObjects::ConstPointer subset = dataStorage->GetSubset(predicate); for (mitk::DataStorage::SetOfObjects::ConstIterator it = subset->Begin(); it != subset->End(); ++it) { mitk::DataNode::Pointer dataNode = it.Value(); mitk::Simulation::Pointer simulation = static_cast(dataNode->GetData()); if (simulation->GetRootNode() == rootNode) return dataNode; } return NULL; } mitk::ExportMitkVisitor::ExportMitkVisitor(DataStorage::Pointer dataStorage, const sofa::core::ExecParams* params) : Visitor(params), m_DataStorage(dataStorage) { } mitk::ExportMitkVisitor::ExportMitkVisitor(DataStorage::Pointer dataStorage, const std::string& visualModelName, const sofa::core::ExecParams* params) : Visitor(params), m_DataStorage(dataStorage), m_VisualModelName(visualModelName) { } mitk::ExportMitkVisitor::~ExportMitkVisitor() { } sofa::simulation::Visitor::Result mitk::ExportMitkVisitor::processNodeTopDown(sofa::simulation::Node* node) { if (m_DataStorage.IsNotNull()) { for_each(this, node, node->visualModel, &ExportMitkVisitor::processVisualModel); return RESULT_CONTINUE; } return RESULT_PRUNE; } void mitk::ExportMitkVisitor::processVisualModel(sofa::simulation::Node* node, sofa::core::visual::VisualModel* visualModel) { using sofa::defaulttype::ResizableExtVector; typedef sofa::component::visualmodel::VisualModelImpl::VecCoord VecCoord; typedef sofa::component::visualmodel::VisualModelImpl::Triangle Triangle; typedef sofa::component::visualmodel::VisualModelImpl::Quad Quad; typedef sofa::component::visualmodel::VisualModelImpl::Deriv Deriv; typedef sofa::component::visualmodel::VisualModelImpl::VecTexCoord VecTexCoord; sofa::component::visualmodel::VisualModelImpl* visualModelImpl = dynamic_cast(visualModel); if (visualModelImpl == NULL) return; if (!m_VisualModelName.empty() && m_VisualModelName != visualModelImpl->name.getValue()) return; vtkSmartPointer polyData = vtkSmartPointer::New(); vtkSmartPointer points = vtkSmartPointer::New(); const VecCoord& vertices = visualModelImpl->m_vertices2.getValue().empty() ? visualModelImpl->m_positions.getValue() : visualModelImpl->m_vertices2.getValue(); size_t numPoints = vertices.size(); points->SetNumberOfPoints(numPoints); for (size_t i = 0; i < numPoints; ++i) points->SetPoint(i, vertices[i].elems); polyData->SetPoints(points); vtkSmartPointer polys = vtkSmartPointer::New(); const ResizableExtVector& triangles = visualModelImpl->m_triangles.getValue(); if (!triangles.empty()) { ResizableExtVector::const_iterator trianglesEnd = triangles.end(); for (ResizableExtVector::const_iterator it = triangles.begin(); it != trianglesEnd; ++it) { const Triangle& triangle = *it; polys->InsertNextCell(3); polys->InsertCellPoint(triangle[0]); polys->InsertCellPoint(triangle[1]); polys->InsertCellPoint(triangle[2]); } } const ResizableExtVector& quads = visualModelImpl->m_quads.getValue(); if (!quads.empty()) { ResizableExtVector::const_iterator quadsEnd = quads.end(); for (ResizableExtVector::const_iterator it = quads.begin(); it != quadsEnd; ++it) { const Quad& quad = *it; polys->InsertNextCell(4); polys->InsertCellPoint(quad[0]); polys->InsertCellPoint(quad[1]); polys->InsertCellPoint(quad[2]); polys->InsertCellPoint(quad[3]); } } polyData->SetPolys(polys); const ResizableExtVector& normals = visualModelImpl->m_vnormals.getValue(); if (!normals.empty()) { size_t numNormals = normals.size(); vtkSmartPointer vtkNormals = vtkSmartPointer::New(); vtkNormals->SetNumberOfComponents(3); vtkNormals->SetNumberOfTuples(numNormals); for (size_t i = 0; i < numNormals; ++i) vtkNormals->SetTuple(i, normals[i].elems); polyData->GetPointData()->SetNormals(vtkNormals); } const VecTexCoord& texCoords = visualModelImpl->m_vtexcoords.getValue(); if (!texCoords.empty()) { size_t numTexCoords = texCoords.size(); vtkSmartPointer vtkTexCoords = vtkSmartPointer::New(); vtkTexCoords->SetNumberOfComponents(2); vtkTexCoords->SetNumberOfTuples(numTexCoords); for (size_t i = 0; i < numTexCoords; ++i) vtkTexCoords->SetTuple(i, texCoords[i].elems); polyData->GetPointData()->SetTCoords(vtkTexCoords); } Surface::Pointer surface = Surface::New(); surface->SetVtkPolyData(polyData); DataNode::Pointer dataNode = DataNode::New(); dataNode->SetName(visualModelImpl->name.getValue()); dataNode->SetData(surface); ApplyMaterial(dataNode, visualModelImpl->material.getValue()); DataNode::Pointer parentDataNode = GetSimulationDataNode(m_DataStorage, node->getRoot()); if (parentDataNode.IsNotNull()) surface->SetGeometry(parentDataNode->GetData()->GetGeometry()); m_DataStorage->Add(dataNode, parentDataNode); } diff --git a/Modules/Simulation/mitkExportMitkVisitor.h b/Modules/Simulation/mitkExportMitkVisitor.h index fb89e0ee35..75f4d73eb1 100644 --- a/Modules/Simulation/mitkExportMitkVisitor.h +++ b/Modules/Simulation/mitkExportMitkVisitor.h @@ -1,46 +1,47 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #ifndef mitkExportMitkVisitor_h #define mitkExportMitkVisitor_h #include #include #include namespace mitk { class MitkSimulation_EXPORT ExportMitkVisitor : public sofa::simulation::Visitor { public: explicit ExportMitkVisitor(DataStorage::Pointer dataStorage, const sofa::core::ExecParams* params = sofa::core::ExecParams::defaultInstance()); ExportMitkVisitor(DataStorage::Pointer dataStorage, const std::string& visualModelName, const sofa::core::ExecParams* params = sofa::core::ExecParams::defaultInstance()); ~ExportMitkVisitor(); + using sofa::simulation::Visitor::processNodeTopDown; Result processNodeTopDown(sofa::simulation::Node* node); private: ExportMitkVisitor(const ExportMitkVisitor&); ExportMitkVisitor& operator=(const ExportMitkVisitor&); void processVisualModel(sofa::simulation::Node* node, sofa::core::visual::VisualModel* visualModel); DataStorage::Pointer m_DataStorage; std::string m_VisualModelName; }; } #endif diff --git a/Modules/Simulation/mitkPlaneIntersectionVisitor.h b/Modules/Simulation/mitkPlaneIntersectionVisitor.h index ddbc24cfdf..337fbdd80a 100644 --- a/Modules/Simulation/mitkPlaneIntersectionVisitor.h +++ b/Modules/Simulation/mitkPlaneIntersectionVisitor.h @@ -1,62 +1,63 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #ifndef mitkPlaneIntersectionVisitor_h #define mitkPlaneIntersectionVisitor_h #include #include #include #include namespace mitk { class MitkSimulation_EXPORT PlaneIntersectionVisitor : public sofa::simulation::Visitor { public: struct Edge { Point3D v0; Point3D v1; }; struct Intersection { float color[4]; std::vector edges; }; PlaneIntersectionVisitor(const Point3D& point, const Vector3D& normal, const sofa::core::ExecParams* params = sofa::core::ExecParams::defaultInstance()); ~PlaneIntersectionVisitor(); const std::vector& GetIntersections() const; + using sofa::simulation::Visitor::processNodeTopDown; Result processNodeTopDown(sofa::simulation::Node* node); private: PlaneIntersectionVisitor(const PlaneIntersectionVisitor&); PlaneIntersectionVisitor& operator=(const PlaneIntersectionVisitor&); void processVisualModel(sofa::simulation::Node*, sofa::core::visual::VisualModel* visualModel); Point3D m_Point; Vector3D m_Normal; std::vector m_Intersections; }; } #endif diff --git a/Modules/Simulation/mitkSetVtkRendererVisitor.h b/Modules/Simulation/mitkSetVtkRendererVisitor.h index 93ebc0d385..cc9bd00d55 100644 --- a/Modules/Simulation/mitkSetVtkRendererVisitor.h +++ b/Modules/Simulation/mitkSetVtkRendererVisitor.h @@ -1,45 +1,46 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #ifndef mitkSetVtkRendererVisitor_h #define mitkSetVtkRendererVisitor_h #include #include class vtkRenderer; namespace mitk { class MitkSimulation_EXPORT SetVtkRendererVisitor : public sofa::simulation::Visitor { public: explicit SetVtkRendererVisitor(vtkRenderer* renderer, const sofa::core::ExecParams* params = sofa::core::ExecParams::defaultInstance()); ~SetVtkRendererVisitor(); + using sofa::simulation::Visitor::processNodeTopDown; Result processNodeTopDown(sofa::simulation::Node* node); private: SetVtkRendererVisitor(const SetVtkRendererVisitor&); SetVtkRendererVisitor& operator=(const SetVtkRendererVisitor&); void processVisualModel(sofa::simulation::Node*, sofa::core::visual::VisualModel* visualModel); vtkRenderer* m_VtkRenderer; }; } #endif diff --git a/Modules/Simulation/mitkSimulationVtkMapper3D.cpp b/Modules/Simulation/mitkSimulationVtkMapper3D.cpp index bb0013078c..51c7e3914b 100644 --- a/Modules/Simulation/mitkSimulationVtkMapper3D.cpp +++ b/Modules/Simulation/mitkSimulationVtkMapper3D.cpp @@ -1,164 +1,164 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #include "mitkSetVtkRendererVisitor.h" #include "mitkSimulation.h" #include "mitkSimulationVtkMapper3D.h" #include "mitkVtkSimulationPolyDataMapper3D.h" #include #include mitk::SimulationVtkMapper3D::LocalStorage::LocalStorage() : m_Actor(vtkSmartPointer::New()) { } mitk::SimulationVtkMapper3D::LocalStorage::~LocalStorage() { } void mitk::SimulationVtkMapper3D::SetDefaultProperties(DataNode* node, BaseRenderer* renderer, bool overwrite) { if (node != NULL) { Simulation* simulation = dynamic_cast(node->GetData()); if (simulation != NULL) { sofa::simulation::Node::SPtr rootNode = simulation->GetRootNode(); sofa::component::visualmodel::VisualStyle::SPtr visualStyle; rootNode->get(visualStyle); if (!visualStyle) { visualStyle = sofa::core::objectmodel::New(); sofa::core::visual::DisplayFlags* displayFlags = visualStyle->displayFlags.beginEdit(); displayFlags->setShowVisualModels(); visualStyle->displayFlags.endEdit(); rootNode->addObject(visualStyle); } const sofa::core::visual::DisplayFlags& displayFlags = visualStyle->displayFlags.getValue(); node->AddProperty("Simulation.Behavior.Behavior Models", BoolProperty::New(displayFlags.getShowBehaviorModels()), renderer, overwrite); node->AddProperty("Simulation.Behavior.Force Fields", BoolProperty::New(displayFlags.getShowForceFields()), renderer, overwrite); node->AddProperty("Simulation.Behavior.Interactions", BoolProperty::New(displayFlags.getShowInteractionForceFields()), renderer, overwrite); node->AddProperty("Simulation.Collision.Bounding Trees", BoolProperty::New(displayFlags.getShowBoundingCollisionModels()), renderer, overwrite); node->AddProperty("Simulation.Collision.Collision Models", BoolProperty::New(displayFlags.getShowCollisionModels()), renderer, overwrite); node->AddProperty("Simulation.Mapping.Mechanical Mappings", BoolProperty::New(displayFlags.getShowMechanicalMappings()), renderer, overwrite); node->AddProperty("Simulation.Mapping.Visual Mappings", BoolProperty::New(displayFlags.getShowMappings()), renderer, overwrite); node->AddProperty("Simulation.Options.Normals", BoolProperty::New(displayFlags.getShowNormals()), renderer, overwrite); node->AddProperty("Simulation.Options.Wire Frame", BoolProperty::New(displayFlags.getShowWireFrame()), renderer, overwrite); node->AddProperty("Simulation.Visual.Visual Models", BoolProperty::New(displayFlags.getShowVisualModels() != sofa::core::visual::tristate::false_value), renderer, overwrite); } Superclass::SetDefaultProperties(node, renderer, overwrite); } } mitk::SimulationVtkMapper3D::SimulationVtkMapper3D() { } mitk::SimulationVtkMapper3D::~SimulationVtkMapper3D() { } void mitk::SimulationVtkMapper3D::ApplyColorAndOpacityProperties(BaseRenderer*, vtkActor*) { } void mitk::SimulationVtkMapper3D::ApplySimulationProperties(BaseRenderer* renderer) { DataNode* node = this->GetDataNode(); bool showBehaviorModels; bool showForceFields; bool showInteractionForceFields; bool showBoundingCollisionModels; bool showCollisionModels; bool showMechanicalMappings; bool showMappings; bool showNormals; bool showWireFrame; bool showVisualModels; node->GetBoolProperty("Simulation.Behavior.Behavior Models", showBehaviorModels, renderer); node->GetBoolProperty("Simulation.Behavior.Force Fields", showForceFields, renderer); node->GetBoolProperty("Simulation.Behavior.Interactions", showInteractionForceFields, renderer); node->GetBoolProperty("Simulation.Collision.Bounding Trees", showBoundingCollisionModels, renderer); node->GetBoolProperty("Simulation.Collision.Collision Models", showCollisionModels, renderer); node->GetBoolProperty("Simulation.Mapping.Mechanical Mappings", showMechanicalMappings, renderer); node->GetBoolProperty("Simulation.Mapping.Visual Mappings", showMappings, renderer); node->GetBoolProperty("Simulation.Options.Normals", showNormals, renderer); node->GetBoolProperty("Simulation.Options.Wire Frame", showWireFrame, renderer); node->GetBoolProperty("Simulation.Visual.Visual Models", showVisualModels, renderer); - Simulation* simulation = static_cast(this->GetData()); + Simulation* simulation = static_cast(node->GetData()); sofa::component::visualmodel::VisualStyle::SPtr visualStyle; simulation->GetRootNode()->get(visualStyle); sofa::core::visual::DisplayFlags* displayFlags = visualStyle->displayFlags.beginEdit(); displayFlags->setShowBehaviorModels(showBehaviorModels); displayFlags->setShowForceFields(showForceFields); displayFlags->setShowInteractionForceFields(showInteractionForceFields); displayFlags->setShowBoundingCollisionModels(showBoundingCollisionModels); displayFlags->setShowCollisionModels(showCollisionModels); displayFlags->setShowMechanicalMappings(showMechanicalMappings); displayFlags->setShowMappings(showMappings); displayFlags->setShowNormals(showNormals); displayFlags->setShowWireFrame(showWireFrame); displayFlags->setShowVisualModels(showVisualModels); visualStyle->displayFlags.endEdit(); } void mitk::SimulationVtkMapper3D::GenerateDataForRenderer(BaseRenderer* renderer) { DataNode* dataNode = this->GetDataNode(); if (dataNode == NULL) return; Simulation* simulation = dynamic_cast(dataNode->GetData()); if (simulation == NULL) return; LocalStorage* localStorage = m_LocalStorageHandler.GetLocalStorage(renderer); if (localStorage->m_Mapper == NULL) { localStorage->m_Mapper = vtkSmartPointer::New(); localStorage->m_Mapper->SetSimulation(simulation); localStorage->m_Actor->SetMapper(localStorage->m_Mapper); SetVtkRendererVisitor setVtkRendererVisitor(renderer->GetVtkRenderer()); simulation->GetRootNode()->executeVisitor(&setVtkRendererVisitor); } this->ApplySimulationProperties(renderer); } vtkProp* mitk::SimulationVtkMapper3D::GetVtkProp(BaseRenderer* renderer) { return m_LocalStorageHandler.GetLocalStorage(renderer)->m_Actor; } diff --git a/Modules/Simulation/mitkVtkSimulationPolyDataMapper2D.cpp b/Modules/Simulation/mitkVtkSimulationPolyDataMapper2D.cpp index fe2fa687a5..773fdb9177 100644 --- a/Modules/Simulation/mitkVtkSimulationPolyDataMapper2D.cpp +++ b/Modules/Simulation/mitkVtkSimulationPolyDataMapper2D.cpp @@ -1,139 +1,139 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #include "mitkGetSimulationService.h" #include "mitkISimulationService.h" #include "mitkPlaneIntersectionVisitor.h" #include "mitkVtkSimulationPolyDataMapper2D.h" #include #include #include #include #include #include namespace mitk { vtkStandardNewMacro(vtkSimulationPolyDataMapper2D); } mitk::vtkSimulationPolyDataMapper2D::vtkSimulationPolyDataMapper2D() : m_SimulationService(GetSimulationService()) { } mitk::vtkSimulationPolyDataMapper2D::~vtkSimulationPolyDataMapper2D() { } -void mitk::vtkSimulationPolyDataMapper2D::Render(vtkRenderer* renderer, vtkActor* actor) +void mitk::vtkSimulationPolyDataMapper2D::Render(vtkRenderer* renderer, vtkActor*) { typedef PlaneIntersectionVisitor::Edge Edge; typedef PlaneIntersectionVisitor::Intersection Intersection; vtkRenderWindow* renderWindow = renderer->GetRenderWindow(); if (renderWindow->CheckAbortStatus() == 1) return; if (renderWindow->SupportsOpenGL() == 0) return; if (m_Simulation.IsNull()) return; if (!renderWindow->IsCurrent()) renderWindow->MakeCurrent(); BaseRenderer* mitkRenderer = BaseRenderer::GetInstance(renderer->GetRenderWindow()); if (mitkRenderer == NULL) return; SliceNavigationController* sliceNavigationController = mitkRenderer->GetSliceNavigationController(); if (sliceNavigationController == NULL) return; const PlaneGeometry* planeGeometry = sliceNavigationController->GetCurrentPlaneGeometry(); if (planeGeometry == NULL) return; renderer->GetRenderWindow()->MakeCurrent(); m_SimulationService->SetActiveSimulation(m_Simulation); PlaneIntersectionVisitor planeIntersectionVisitor(planeGeometry->GetOrigin(), planeGeometry->GetNormal()); m_Simulation->GetRootNode()->executeVisitor(&planeIntersectionVisitor); mitk::DisplayGeometry::Pointer displayGeometry = mitkRenderer->GetDisplayGeometry(); Point2D point2D; glColorMaterial(GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE); glEnable(GL_COLOR_MATERIAL); const std::vector& intersections = planeIntersectionVisitor.GetIntersections(); std::vector::const_iterator intersectionsEnd = intersections.end(); for (std::vector::const_iterator intersectionIt = intersections.begin(); intersectionIt != intersectionsEnd; ++intersectionIt) { const std::vector& edges = intersectionIt->edges; std::vector::const_iterator edgesEnd = edges.end(); glColor4fv(intersectionIt->color); glBegin(GL_LINES); for (std::vector::const_iterator edgeIt = edges.begin(); edgeIt != edgesEnd; ++edgeIt) { glVertex3dv(edgeIt->v0.GetDataPointer()); glVertex3dv(edgeIt->v1.GetDataPointer()); } glEnd(); } glDisable(GL_COLOR_MATERIAL); } void mitk::vtkSimulationPolyDataMapper2D::RenderPiece(vtkRenderer*, vtkActor*) { } void mitk::vtkSimulationPolyDataMapper2D::SetSimulation(Simulation::Pointer simulation) { m_Simulation = simulation; } double* mitk::vtkSimulationPolyDataMapper2D::GetBounds() { if (m_Simulation.IsNull()) return Superclass::GetBounds(); sofa::simulation::Node::SPtr rootNode = m_Simulation->GetRootNode(); const sofa::defaulttype::BoundingBox& bbox = rootNode->f_bbox.getValue(); const sofa::defaulttype::Vector3& min = bbox.minBBox(); const sofa::defaulttype::Vector3& max = bbox.maxBBox(); Bounds[0] = min.x(); Bounds[1] = max.x(); Bounds[2] = min.y(); Bounds[3] = max.y(); Bounds[4] = min.z(); Bounds[5] = max.z(); return this->Bounds; } diff --git a/Modules/Simulation/mitkVtkSimulationPolyDataMapper3D.cpp b/Modules/Simulation/mitkVtkSimulationPolyDataMapper3D.cpp index 2d242e5e14..6d6e7c528b 100644 --- a/Modules/Simulation/mitkVtkSimulationPolyDataMapper3D.cpp +++ b/Modules/Simulation/mitkVtkSimulationPolyDataMapper3D.cpp @@ -1,95 +1,95 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #include "mitkGetSimulationService.h" #include "mitkISimulationService.h" #include "mitkVtkSimulationPolyDataMapper3D.h" #include #include #include #include namespace mitk { vtkStandardNewMacro(vtkSimulationPolyDataMapper3D); } mitk::vtkSimulationPolyDataMapper3D::vtkSimulationPolyDataMapper3D() : m_SimulationService(GetSimulationService()) { } mitk::vtkSimulationPolyDataMapper3D::~vtkSimulationPolyDataMapper3D() { } -void mitk::vtkSimulationPolyDataMapper3D::Render(vtkRenderer* renderer, vtkActor* actor) +void mitk::vtkSimulationPolyDataMapper3D::Render(vtkRenderer* renderer, vtkActor*) { vtkRenderWindow* renderWindow = renderer->GetRenderWindow(); if (renderWindow->CheckAbortStatus() == 1) return; if (renderWindow->SupportsOpenGL() == 0) return; if (m_Simulation.IsNull()) return; if (!renderWindow->IsCurrent()) renderWindow->MakeCurrent(); m_SimulationService->SetActiveSimulation(m_Simulation); sofa::core::visual::VisualParams* vParams = sofa::core::visual::VisualParams::defaultInstance(); sofa::simulation::Simulation::SPtr sofaSimulation = m_Simulation->GetSOFASimulation(); sofa::simulation::Node::SPtr rootNode = m_Simulation->GetRootNode(); sofaSimulation->updateVisual(rootNode.get()); sofaSimulation->draw(vParams, rootNode.get()); // SOFA potentially disables GL_BLEND but VTK relies on it. glEnable(GL_BLEND); } void mitk::vtkSimulationPolyDataMapper3D::RenderPiece(vtkRenderer*, vtkActor*) { } void mitk::vtkSimulationPolyDataMapper3D::SetSimulation(Simulation::Pointer simulation) { m_Simulation = simulation; } double* mitk::vtkSimulationPolyDataMapper3D::GetBounds() { if (m_Simulation.IsNull()) return Superclass::GetBounds(); sofa::simulation::Node::SPtr rootNode = m_Simulation->GetRootNode(); const sofa::defaulttype::BoundingBox& bbox = rootNode->f_bbox.getValue(); const sofa::defaulttype::Vector3& min = bbox.minBBox(); const sofa::defaulttype::Vector3& max = bbox.maxBBox(); Bounds[0] = min.x(); Bounds[1] = max.x(); Bounds[2] = min.y(); Bounds[3] = max.y(); Bounds[4] = min.z(); Bounds[5] = max.z(); return this->Bounds; }