TransferPhysicsToGraphicsMeshBehavior.h
Go to the documentation of this file.
1 // This file is a part of the OpenSurgSim project.
2 // Copyright 2013, SimQuest Solutions Inc.
3 //
4 // Licensed under the Apache License, Version 2.0 (the "License");
5 // you may not use this file except in compliance with the License.
6 // You may obtain a copy of the License at
7 //
8 // http://www.apache.org/licenses/LICENSE-2.0
9 //
10 // Unless required by applicable law or agreed to in writing, software
11 // distributed under the License is distributed on an "AS IS" BASIS,
12 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 // See the License for the specific language governing permissions and
14 // limitations under the License.
15 
16 #ifndef SURGSIM_BLOCKS_TRANSFERPHYSICSTOGRAPHICSMESHBEHAVIOR_H
17 #define SURGSIM_BLOCKS_TRANSFERPHYSICSTOGRAPHICSMESHBEHAVIOR_H
18 
21 
22 namespace SurgSim
23 {
24 
25 namespace Framework
26 {
27 class Component;
28 }
29 
30 namespace Graphics
31 {
32 class MeshRepresentation;
33 }
34 
35 namespace Physics
36 {
37 class DeformableRepresentation;
38 }
39 
40 namespace Blocks
41 {
42 SURGSIM_STATIC_REGISTRATION(TransferPhysicsToGraphicsMeshBehavior);
43 
46 {
47 public:
50  explicit TransferPhysicsToGraphicsMeshBehavior(const std::string& name);
51 
53 
56  void setSource(const std::shared_ptr<SurgSim::Framework::Component>& source);
57 
60  void setTarget(const std::shared_ptr<SurgSim::Framework::Component>& target);
61 
64  std::shared_ptr<SurgSim::Physics::DeformableRepresentation> getSource() const;
65 
68  std::shared_ptr<SurgSim::Graphics::MeshRepresentation> getTarget() const;
69 
70  virtual void update(double dt) override;
71 
72 private:
73  virtual bool doInitialize() override;
74  virtual bool doWakeUp() override;
75 
77  std::shared_ptr<SurgSim::Physics::DeformableRepresentation> m_source;
78 
80  std::shared_ptr<SurgSim::Graphics::MeshRepresentation> m_target;
81 };
82 
83 }; // namespace Blocks
84 }; // namespace SurgSim
85 
86 #endif // SURGSIM_BLOCKS_TRANSFERPHYSICSTOGRAPHICSMESHBEHAVIOR_H
std::shared_ptr< SurgSim::Physics::DeformableRepresentation > m_source
The DeformableRepresentation from which the Ode state comes.
Definition: TransferPhysicsToGraphicsMeshBehavior.h:77
void setSource(const std::shared_ptr< SurgSim::Framework::Component > &source)
Set the representation from which the positions are from.
Definition: TransferPhysicsToGraphicsMeshBehavior.cpp:44
Definition: DriveElementFromInputBehavior.cpp:27
Graphics representation of a mesh, can be initialized from a Mesh structure.
Definition: MeshRepresentation.h:28
std::shared_ptr< SurgSim::Graphics::MeshRepresentation > getTarget() const
Get the Graphics representation which receives the positions.
Definition: TransferPhysicsToGraphicsMeshBehavior.cpp:69
std::shared_ptr< SurgSim::Graphics::MeshRepresentation > m_target
The Graphics Mesh Representation to which the vertices' positions are set.
Definition: TransferPhysicsToGraphicsMeshBehavior.h:80
std::shared_ptr< SurgSim::Physics::DeformableRepresentation > getSource() const
Get the Physics representation which sends the positions.
Definition: TransferPhysicsToGraphicsMeshBehavior.cpp:64
void setTarget(const std::shared_ptr< SurgSim::Framework::Component > &target)
Set the representation which will receive the positions.
Definition: TransferPhysicsToGraphicsMeshBehavior.cpp:54
Behaviors perform actions.
Definition: Behavior.h:40
TransferPhysicsToGraphicsMeshBehavior(const std::string &name)
Constructor.
Definition: TransferPhysicsToGraphicsMeshBehavior.cpp:35
SURGSIM_CLASSNAME(SurgSim::Blocks::TransferPhysicsToGraphicsMeshBehavior)
virtual bool doInitialize() override
Interface to be implemented by derived classes.
Definition: TransferPhysicsToGraphicsMeshBehavior.cpp:84
virtual void update(double dt) override
Update the behavior.
Definition: TransferPhysicsToGraphicsMeshBehavior.cpp:74
virtual bool doWakeUp() override
Interface to be implemented by derived classes.
Definition: TransferPhysicsToGraphicsMeshBehavior.cpp:89
SURGSIM_STATIC_REGISTRATION(DriveElementFromInputBehavior)
Behavior to copy positions of a PhysicsRepresentation to a GraphicsMesh.
Definition: TransferPhysicsToGraphicsMeshBehavior.h:45