fw4spl
SSimpleMeshDeformation.hpp
1 /* ***** BEGIN LICENSE BLOCK *****
2  * FW4SPL - Copyright (C) IRCAD, 2009-2017.
3  * Distributed under the terms of the GNU Lesser General Public License (LGPL) as
4  * published by the Free Software Foundation.
5  * ****** END LICENSE BLOCK ****** */
6 
7 #ifndef __VTKSIMPLEMESH_SSIMPLEMESHDEFORMATION_HPP__
8 #define __VTKSIMPLEMESH_SSIMPLEMESHDEFORMATION_HPP__
9 
10 #include "vtkSimpleMesh/config.hpp"
11 
12 #include <fwData/Mesh.hpp>
13 
14 #include <fwServices/IController.hpp>
15 
16 #include <fwThread/Timer.hpp>
17 
18 namespace vtkSimpleMesh
19 {
20 
38 class VTKSIMPLEMESH_CLASS_API SSimpleMeshDeformation : public ::fwServices::IController
39 {
40 public:
41 
43 
44  // Key used to register the 'startDeformation' slot
45  VTKSIMPLEMESH_API static const ::fwCom::Slots::SlotKeyType s_START_DEFORMATION_SLOT;
46 
47  // Key used to register the 'stopDeformation' slot
48  VTKSIMPLEMESH_API static const ::fwCom::Slots::SlotKeyType s_STOP_DEFORMATION_SLOT;
49 
51  VTKSIMPLEMESH_API SSimpleMeshDeformation() noexcept;
52 
54  VTKSIMPLEMESH_API virtual ~SSimpleMeshDeformation() noexcept;
55 
56 protected:
57 
59  VTKSIMPLEMESH_API virtual void starting() override;
60 
62  VTKSIMPLEMESH_API virtual void configuring() override;
63 
65  VTKSIMPLEMESH_API virtual void stopping() override;
66 
68  VTKSIMPLEMESH_API virtual void updating() override;
69 
71  VTKSIMPLEMESH_API void startDeformation();
72 
74  VTKSIMPLEMESH_API void stopDeformation();
75 
76 private:
77 
79  void copyMesh( const ::fwData::Mesh::sptr& src, const ::fwData::Mesh::sptr& dest ) const;
80 
82  void initMeshBackup();
83 
85  void computeDeformation( const ::fwData::Mesh::sptr& refMesh, const ::fwData::Mesh::sptr& transformMesh );
86 
88  void computeDeformation(
89  const ::fwData::Mesh::sptr& refMesh,
90  const ::fwData::Mesh::sptr& transformMesh,
91  float deformationPercent );
92 
93  ::fwThread::Timer::sptr m_timer;
94 
96  ::fwCore::HiResTimer m_hiRestimer;
97 
99  ::fwData::Mesh::sptr m_transformMesh;
100 
102  ::fwData::Mesh::sptr m_mesh;
103 
105  float m_currentIncrement;
106 
108  float m_currentDeformation;
109 };
110 
111 }
112 
113 #endif /* __VTKSIMPLEMESH_SSIMPLEMESHDEFORMATION_HPP__ */
This namespace fwCore provides common foundations for FW4SPL.
Definition: BaseObject.hpp:16
Service used to demonstrate how to deform a mesh.
This interface defines control service API. Does nothing particularly, can be considered as a default...
Definition: IController.hpp:23
The namespace vtkSimpleMesh contains a service which renders one mesh (fwData::Mesh).
#define fwCoreServiceClassDefinitionsMacro(_classinfo_)
Generate common code for services classes.
Contains the representation of the data objects used in the framework.
This namespace fwThread provides few tools to execute asynchronous tasks on different threads...