TransferPhysicsToGraphicsMeshBehavior.h
Go to the documentation of this file.
// This file is a part of the OpenSurgSim project.
// Copyright 2013, SimQuest Solutions Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#ifndef SURGSIM_BLOCKS_TRANSFERPHYSICSTOGRAPHICSMESHBEHAVIOR_H
#define SURGSIM_BLOCKS_TRANSFERPHYSICSTOGRAPHICSMESHBEHAVIOR_H
#include "SurgSim/DataStructures/TriangleMesh.h"
#include "SurgSim/Framework/Behavior.h"
#include "SurgSim/Framework/Macros.h"
namespace SurgSim
{
namespace Framework
{
class Component;
class Asset;
}
namespace Graphics
{
class MeshRepresentation;
}
namespace Physics
{
class DeformableRepresentation;
}
namespace Blocks
{
SURGSIM_STATIC_REGISTRATION(TransferPhysicsToGraphicsMeshBehavior);
class TransferPhysicsToGraphicsMeshBehavior : public Framework::Behavior
{
public:
explicit TransferPhysicsToGraphicsMeshBehavior(const std::string& name);
SURGSIM_CLASSNAME(SurgSim::Blocks::TransferPhysicsToGraphicsMeshBehavior);
void setSource(const std::shared_ptr<Framework::Component>& source);
void setTarget(const std::shared_ptr<Framework::Component>& target);
std::shared_ptr<Physics::DeformableRepresentation> getSource() const;
std::shared_ptr<Graphics::MeshRepresentation> getTarget() const;
void setIndexMap(
const std::shared_ptr<DataStructures::TriangleMeshPlain>& source,
const std::shared_ptr<DataStructures::TriangleMeshPlain>& target);
void setIndexMap(const std::string& sourceFile, const std::string& targetFile);
void setIndexMap(const std::vector<std::pair<size_t, size_t>>& indexMap);
const std::vector<std::pair<size_t, size_t>> getIndexMap() const;
void update(double dt) override;
private:
bool doInitialize() override;
bool doWakeUp() override;
void setIndexMap(const std::pair<std::string, std::string>& fileName);
void setIndexMap(const std::pair<std::shared_ptr<Framework::Asset>, std::shared_ptr<Framework::Asset>>& meshes);
std::shared_ptr<Physics::DeformableRepresentation> m_source;
std::shared_ptr<Graphics::MeshRepresentation> m_target;
std::vector<std::pair<size_t, size_t>> m_indexMap;
};
std::vector<std::pair<size_t, size_t>> generateIndexMap(
const std::shared_ptr<DataStructures::TriangleMeshPlain>& source,
const std::shared_ptr<DataStructures::TriangleMeshPlain>& target);
}; // namespace Blocks
}; // namespace SurgSim
#endif // SURGSIM_BLOCKS_TRANSFERPHYSICSTOGRAPHICSMESHBEHAVIOR_H
SurgSim
Definition: CompoundShapeToGraphics.cpp:29
SurgSim::Blocks::TransferPhysicsToGraphicsMeshBehavior::m_target
std::shared_ptr< Graphics::MeshRepresentation > m_target
The Graphics Mesh Representation to which the vertices&#39; positions are set.
Definition: TransferPhysicsToGraphicsMeshBehavior.h:113
SurgSim::Blocks::TransferPhysicsToGraphicsMeshBehavior::m_indexMap
std::vector< std::pair< size_t, size_t > > m_indexMap
The mapping to be used if not empty.
Definition: TransferPhysicsToGraphicsMeshBehavior.h:116
Behavior.h
SURGSIM_CLASSNAME
#define SURGSIM_CLASSNAME(ClassName)
Declare the class name of a class with the appropriate function header, do not use quotes...
Definition: Macros.h:21
SurgSim::Blocks::TransferPhysicsToGraphicsMeshBehavior::m_source
std::shared_ptr< Physics::DeformableRepresentation > m_source
The DeformableRepresentation from which the Ode state comes.
Definition: TransferPhysicsToGraphicsMeshBehavior.h:110
Macros.h
SurgSim::Framework::Behavior
Behaviors perform actions.
Definition: Behavior.h:40
SurgSim::Blocks::generateIndexMap
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
TriangleMesh.h
SurgSim::Blocks::TransferPhysicsToGraphicsMeshBehavior
Behavior to copy positions of a PhysicsRepresentation to a GraphicsMesh.
Definition: TransferPhysicsToGraphicsMeshBehavior.h:51