Go to the documentation of this file.
16 #ifndef SURGSIM_BLOCKS_TRANSFERPHYSICSTOGRAPHICSMESHBEHAVIOR_H
17 #define SURGSIM_BLOCKS_TRANSFERPHYSICSTOGRAPHICSMESHBEHAVIOR_H
34 class MeshRepresentation;
39 class DeformableRepresentation;
44 SURGSIM_STATIC_REGISTRATION(TransferPhysicsToGraphicsMeshBehavior);
62 void setSource(
const std::shared_ptr<Framework::Component>& source);
66 void setTarget(
const std::shared_ptr<Framework::Component>& target);
70 std::shared_ptr<Physics::DeformableRepresentation>
getSource()
const;
74 std::shared_ptr<Graphics::MeshRepresentation>
getTarget()
const;
81 const std::shared_ptr<DataStructures::TriangleMeshPlain>& source,
82 const std::shared_ptr<DataStructures::TriangleMeshPlain>& target);
88 void setIndexMap(
const std::string& sourceFile,
const std::string& targetFile);
93 void setIndexMap(
const std::vector<std::pair<size_t, size_t>>& indexMap);
96 const std::vector<std::pair<size_t, size_t>>
getIndexMap()
const;
98 void update(
double dt)
override;
105 void setIndexMap(
const std::pair<std::string, std::string>& fileName);
107 void setIndexMap(
const std::pair<std::shared_ptr<Framework::Asset>, std::shared_ptr<Framework::Asset>>& meshes);
110 std::shared_ptr<Physics::DeformableRepresentation>
m_source;
113 std::shared_ptr<Graphics::MeshRepresentation>
m_target;
125 const std::shared_ptr<DataStructures::TriangleMeshPlain>& source,
126 const std::shared_ptr<DataStructures::TriangleMeshPlain>& target);
131 #endif // SURGSIM_BLOCKS_TRANSFERPHYSICSTOGRAPHICSMESHBEHAVIOR_H
Behavior to copy positions of a PhysicsRepresentation to a GraphicsMesh.
Definition: TransferPhysicsToGraphicsMeshBehavior.h:51
std::shared_ptr< Physics::DeformableRepresentation > m_source
The DeformableRepresentation from which the Ode state comes.
Definition: TransferPhysicsToGraphicsMeshBehavior.h:110
std::shared_ptr< Physics::DeformableRepresentation > getSource() const
Get the Physics representation which sends the positions.
Definition: TransferPhysicsToGraphicsMeshBehavior.cpp:109
void update(double dt) override
Update the behavior.
Definition: TransferPhysicsToGraphicsMeshBehavior.cpp:119
bool doWakeUp() override
Interface to be implemented by derived classes.
Definition: TransferPhysicsToGraphicsMeshBehavior.cpp:148
void setTarget(const std::shared_ptr< Framework::Component > &target)
Set the representation which will receive the positions.
Definition: TransferPhysicsToGraphicsMeshBehavior.cpp:102
Behaviors perform actions.
Definition: Behavior.h:40
Definition: CompoundShapeToGraphics.cpp:29
void setSource(const std::shared_ptr< Framework::Component > &source)
Set the representation from which the positions are from.
Definition: TransferPhysicsToGraphicsMeshBehavior.cpp:95
TransferPhysicsToGraphicsMeshBehavior(const std::string &name)
Constructor.
Definition: TransferPhysicsToGraphicsMeshBehavior.cpp:41
bool doInitialize() override
Interface to be implemented by derived classes.
Definition: TransferPhysicsToGraphicsMeshBehavior.cpp:143
std::shared_ptr< Graphics::MeshRepresentation > getTarget() const
Get the Graphics representation which receives the positions.
Definition: TransferPhysicsToGraphicsMeshBehavior.cpp:114
SURGSIM_CLASSNAME(SurgSim::Blocks::TransferPhysicsToGraphicsMeshBehavior)
const std::vector< std::pair< size_t, size_t > > getIndexMap() const
Definition: TransferPhysicsToGraphicsMeshBehavior.cpp:206
std::shared_ptr< Graphics::MeshRepresentation > m_target
The Graphics Mesh Representation to which the vertices' positions are set.
Definition: TransferPhysicsToGraphicsMeshBehavior.h:113
void setIndexMap(const std::shared_ptr< DataStructures::TriangleMeshPlain > &source, const std::shared_ptr< DataStructures::TriangleMeshPlain > &target)
Generate a mapping, for each point in source find the points target that coincide.
Definition: TransferPhysicsToGraphicsMeshBehavior.cpp:165
std::vector< std::pair< size_t, size_t > > generateIndexMap(const std::shared_ptr< DataStructures::TriangleMeshPlain > &source, const std::shared_ptr< DataStructures::TriangleMeshPlain > &target)
Generate a mapping, for each point in source find the points target that coincide.
Definition: TransferPhysicsToGraphicsMeshBehavior.cpp:211
std::vector< std::pair< size_t, size_t > > m_indexMap
The mapping to be used if not empty.
Definition: TransferPhysicsToGraphicsMeshBehavior.h:116