diff --git a/Modules/Simulation/mitkSimulation.h b/Modules/Simulation/mitkSimulation.h index 5857ffed71..58428cb911 100644 --- a/Modules/Simulation/mitkSimulation.h +++ b/Modules/Simulation/mitkSimulation.h @@ -1,168 +1,168 @@ /*=================================================================== 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 mitkSimulation_h #define mitkSimulation_h #include "mitkSimulationDrawTool.h" #include #include #include #include #include namespace mitk { /** \brief Encapsulates a SOFA simulation. * * Call GetSimulation() to access the initially default constructed SOFA simulation. * Directly after loading a scene into the SOFA simulation you must set its root node by calling SetRootNode(). * You should set the simulation scene's default time step as well by calling SetDefaultDT(). * Make sure to manually initilalize the SOFA simulation. * * SOFA can conceptionally handle only one simulation at a time, however, MITK %Simulation allows to load several simulation scenes in parallel. - * Therfore it is necessary and important to set a simulation as active simulation when using it. + * Therefore it is necessary to set a simulation as active simulation when using it. * You can do this either by calling SetAsActiveSimulation() or by calling the static SetActiveSimulation() method. * * You can take snapshots of simulations represented as 3D surfaces by calling TakeSnapshot() or easily record simulations as 3D+t surfaces by calling AppendSnapshot(). */ class Simulation_EXPORT Simulation : public BaseData { public: enum SimulationType { Tree, DAG, Bgl }; mitkClassMacro(Simulation, BaseData); itkNewMacro(Self); /** \brief %Set the active simulation. * * \param[in] simulation The new active simulation or NULL. * \sa SetAsActiveSimulation() */ static void SetActiveSimulation(Self* simulation); /** \brief Scale factor by which all objects in a simulation scene are scaled for visualization. */ static const float ScaleFactor; /** \brief Append snapshot of scene at current simulation time to given Surface. * * \param[in] surface Surface to which the current scene is appended as 3D surface. * \return Returns true if a snapshot was successfully appended to the surface. * \sa TakeSnapshot() */ bool AppendSnapshot(Surface::Pointer surface) const; /** \brief Get default time step of simulation scene. * * You need to manually set the default time step by calling SetDefaultDT(). * * \return The default time step of the simulation scene if available or 0.0 otherwise. */ double GetDefaultDT() const; /** \brief Get simulation draw tool. * * Usually called only by the corresponding mapper or to reset the draw tool manually. * * \return The simulation draw tool. */ SimulationDrawTool* GetDrawTool(); /** \brief Get root node of simulation scene. * * You must manually set the root node by calling SetRootNode() first. * This is usually done directly after setting/loading a simulation scene. * * \return The root node of the encapsulated SOFA simulation scene. */ sofa::simulation::Node::SPtr GetRootNode() const; /** \brief Get SOFA simulation. * * The encapsulated SOFA simulation is default constructed during construction. * Use this method to gain access to it or to initially load a scene into the simulation. * Make sure to also call SetRootNode() and SetDefaultDT() in the latter case. * * \return The encapsulated SOFA simulation. */ sofa::simulation::Simulation::SPtr GetSimulation() const; bool RequestedRegionIsOutsideOfTheBufferedRegion(); /** \brief %Set this simulation as active simulation. * * You must set a simulation as active simulation prior to use it. * * \sa SetActiveSimulation() */ void SetAsActiveSimulation(); /** \brief %Set default simulation scene time step. * * You should call this method after you loaded a scene into the encapsulated SOFA simulation and set the root node. * * \param[in] dt Default time step of encapsulated simulation scene. * \sa GetSimulation(), SetRootNode() */ void SetDefaultDT(double dt); void SetRequestedRegion(const itk::DataObject* data); void SetRequestedRegionToLargestPossibleRegion(); /** \brief %Set the simulation scene root node of the encapsulated simulation. * * This is usually the first method you call after you accessed the encapsulated simulation by calling GetSimulation() to set or load the simulation scene. * * \param[in] rootNode Root Node of the simulation scene corresponding to the encapsulated SOFA simulation. */ void SetRootNode(sofa::simulation::Node* rootNode); /** \brief Take a snapshot of the encapsulated simulation scene at current simulation time. * * Snapshots cannot be created if the simulation scene contains no visual models or only hidden visual models. * * \return Snapshot represented as 3D surface or NULL. */ Surface::Pointer TakeSnapshot() const; void UpdateOutputInformation(); bool VerifyRequestedRegion(); private: Simulation(); ~Simulation(); Simulation(Self&); Self& operator=(const Self&); vtkSmartPointer CreateSnapshot() const; sofa::simulation::Simulation::SPtr m_Simulation; sofa::simulation::Node::SPtr m_RootNode; SimulationDrawTool m_DrawTool; double m_DefaultDT; }; } #endif diff --git a/Modules/Simulation/mitkSimulationTemplate.h b/Modules/Simulation/mitkSimulationTemplate.h index 3b40c5f803..702117e0b0 100644 --- a/Modules/Simulation/mitkSimulationTemplate.h +++ b/Modules/Simulation/mitkSimulationTemplate.h @@ -1,57 +1,69 @@ /*=================================================================== 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 mitkSimulationTemplate_h #define mitkSimulationTemplate_h #include #include #include #include #include #include namespace mitk { + /** \brief %Simulation templates are extended simulation scenes which can contain variables. + * + * These variables are mapped to properties (mitk::BaseProperty) to be easily adjustable. + * A simulation template is an intermediate format and cannot be loaded by SOFA as simulation scene. + * However, a simulation scene based on a simulation template can be created easily. + * + * For information on the syntax of simulation templates, see \ref org_mitk_gui_qt_simulationSimulationTemplates. + * + * Call Parse() to initialize the class by parsing a simulation scene template. + * Parsed templates are represented by properties which you must set manually for the corresponding data node (mitk::DataNode) by calling SetProperties(). + * To create a simulation scene based on the simulation template call CreateSimulation(). + */ class Simulation_EXPORT SimulationTemplate : public BaseData { public: mitkClassMacro(SimulationTemplate, BaseData); itkNewMacro(Self); std::string CreateSimulation() const; bool Parse(const std::string& contents); bool RequestedRegionIsOutsideOfTheBufferedRegion(); bool SetProperties(DataNode::Pointer dataNode) const; void SetRequestedRegion(const itk::DataObject* data); void SetRequestedRegionToLargestPossibleRegion(); void UpdateOutputInformation(); bool VerifyRequestedRegion(); private: SimulationTemplate(); ~SimulationTemplate(); SimulationTemplate(Self&); Self& operator=(const Self&); bool m_IsInitialized; std::vector m_StaticContents; std::vector > m_VariableContents; }; } #endif