21 #include <sofa/component/visualmodel/VisualStyle.h>
22 #include <sofa/core/visual/VisualParams.h>
24 mitk::SimulationVtkMapper3D::LocalStorage::LocalStorage()
25 : m_Actor(vtkSmartPointer<vtkActor>::
New())
29 mitk::SimulationVtkMapper3D::LocalStorage::~LocalStorage()
39 if (simulation != NULL)
41 sofa::simulation::Node::SPtr rootNode = simulation->
GetRootNode();
42 sofa::component::visualmodel::VisualStyle::SPtr visualStyle;
44 rootNode->get(visualStyle);
48 visualStyle = sofa::core::objectmodel::New<sofa::component::visualmodel::VisualStyle>();
50 sofa::core::visual::DisplayFlags* displayFlags = visualStyle->displayFlags.beginEdit();
51 displayFlags->setShowVisualModels();
52 visualStyle->displayFlags.endEdit();
54 rootNode->addObject(visualStyle);
57 const sofa::core::visual::DisplayFlags& displayFlags = visualStyle->displayFlags.getValue();
61 node->
AddProperty(
"Simulation.Behavior.Interactions",
BoolProperty::New(displayFlags.getShowInteractionForceFields()), renderer, overwrite);
62 node->
AddProperty(
"Simulation.Collision.Bounding Trees",
BoolProperty::New(displayFlags.getShowBoundingCollisionModels()), renderer, overwrite);
63 node->
AddProperty(
"Simulation.Collision.Collision Models",
BoolProperty::New(displayFlags.getShowCollisionModels()), renderer, overwrite);
64 node->
AddProperty(
"Simulation.Mapping.Mechanical Mappings",
BoolProperty::New(displayFlags.getShowMechanicalMappings()), renderer, overwrite);
68 node->
AddProperty(
"Simulation.Visual.Visual Models",
BoolProperty::New(displayFlags.getShowVisualModels() != sofa::core::visual::tristate::false_value), renderer, overwrite);
71 Superclass::SetDefaultProperties(node, renderer, overwrite);
75 mitk::SimulationVtkMapper3D::SimulationVtkMapper3D()
79 mitk::SimulationVtkMapper3D::~SimulationVtkMapper3D()
89 DataNode* node = this->GetDataNode();
91 bool showBehaviorModels;
93 bool showInteractionForceFields;
94 bool showBoundingCollisionModels;
95 bool showCollisionModels;
96 bool showMechanicalMappings;
100 bool showVisualModels;
102 node->
GetBoolProperty(
"Simulation.Behavior.Behavior Models", showBehaviorModels, renderer);
103 node->
GetBoolProperty(
"Simulation.Behavior.Force Fields", showForceFields, renderer);
104 node->
GetBoolProperty(
"Simulation.Behavior.Interactions", showInteractionForceFields, renderer);
105 node->
GetBoolProperty(
"Simulation.Collision.Bounding Trees", showBoundingCollisionModels, renderer);
106 node->
GetBoolProperty(
"Simulation.Collision.Collision Models", showCollisionModels, renderer);
107 node->
GetBoolProperty(
"Simulation.Mapping.Mechanical Mappings", showMechanicalMappings, renderer);
108 node->
GetBoolProperty(
"Simulation.Mapping.Visual Mappings", showMappings, renderer);
109 node->
GetBoolProperty(
"Simulation.Options.Normals", showNormals, renderer);
110 node->
GetBoolProperty(
"Simulation.Options.Wire Frame", showWireFrame, renderer);
111 node->
GetBoolProperty(
"Simulation.Visual.Visual Models", showVisualModels, renderer);
114 sofa::component::visualmodel::VisualStyle::SPtr visualStyle;
117 sofa::core::visual::DisplayFlags* displayFlags = visualStyle->displayFlags.beginEdit();
119 displayFlags->setShowBehaviorModels(showBehaviorModels);
120 displayFlags->setShowForceFields(showForceFields);
121 displayFlags->setShowInteractionForceFields(showInteractionForceFields);
122 displayFlags->setShowBoundingCollisionModels(showBoundingCollisionModels);
123 displayFlags->setShowCollisionModels(showCollisionModels);
124 displayFlags->setShowMechanicalMappings(showMechanicalMappings);
125 displayFlags->setShowMappings(showMappings);
126 displayFlags->setShowNormals(showNormals);
127 displayFlags->setShowWireFrame(showWireFrame);
128 displayFlags->setShowVisualModels(showVisualModels);
130 visualStyle->displayFlags.endEdit();
135 DataNode* dataNode = this->GetDataNode();
137 if (dataNode == NULL)
142 if (simulation == NULL)
145 LocalStorage* localStorage = m_LocalStorageHandler.GetLocalStorage(renderer);
147 if (localStorage->m_Mapper == NULL)
150 localStorage->m_Mapper->SetSimulation(simulation);
152 localStorage->m_Actor->SetMapper(localStorage->m_Mapper);
155 simulation->
GetRootNode()->executeVisitor(&setVtkRendererVisitor);
158 this->ApplySimulationProperties(renderer);
163 return m_LocalStorageHandler.GetLocalStorage(renderer)->m_Actor;
vtkProp * GetVtkProp(BaseRenderer *renderer) override
static void SetDefaultProperties(DataNode *node, BaseRenderer *renderer=NULL, bool overwrite=false)
Organizes the rendering process.
bool GetBoolProperty(const char *propertyKey, bool &boolValue, const mitk::BaseRenderer *renderer=nullptr) const
Convenience access method for bool properties (instances of BoolProperty)
void ApplySimulationProperties(BaseRenderer *renderer)
BaseData * GetData() const
Get the data object (instance of BaseData, e.g., an Image) managed by this DataNode.
void ApplyColorAndOpacityProperties(BaseRenderer *, vtkActor *) override
Apply color and opacity properties read from the PropertyList. Called by mapper subclasses.
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 GenerateDataForRenderer(BaseRenderer *renderer) override
Generate the data needed for rendering into renderer.
sofa::simulation::Node::SPtr GetRootNode() const
vtkRenderer * GetVtkRenderer() const
Class for nodes of the DataTree.
static itkEventMacro(BoundingShapeInteractionEvent, itk::AnyEvent) class MITKBOUNDINGSHAPE_EXPORT BoundingShapeInteractor Pointer New()
Basic interaction methods for mitk::GeometryData.