VisualizeContactsBehavior.h
Go to the documentation of this file.
1 // This file is a part of the OpenSurgSim project.
2 // Copyright 2013-2015, 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_VISUALIZECONTACTSBEHAVIOR_H
17 #define SURGSIM_BLOCKS_VISUALIZECONTACTSBEHAVIOR_H
18 
19 #include <memory>
20 #include <string>
21 
24 
25 namespace SurgSim
26 {
27 
28 namespace Graphics
29 {
30 class VectorFieldRepresentation;
31 }
32 
33 namespace Collision
34 {
35 class Representation;
36 }
37 
38 namespace Blocks
39 {
40 
41 SURGSIM_STATIC_REGISTRATION(VisualizeContactsBehavior);
42 
46 {
47 public:
50  explicit VisualizeContactsBehavior(const std::string& name);
51 
53 
56  std::shared_ptr<SurgSim::Framework::Component> getSource();
57 
60  void setSource(std::shared_ptr<SurgSim::Framework::Component> source);
61 
62  void update(double dt) override;
63 
64  int getTargetManagerType() const override;
65 
67  double getVectorFieldScale();
68 
70  // \param scale The scale of the vector field.
71  void setVectorFieldScale(double scale);
72 
73 protected:
74  bool doInitialize() override;
75 
76  bool doWakeUp() override;
77 
78 private:
80  std::shared_ptr<SurgSim::Collision::Representation> m_source;
81 
83  std::shared_ptr<SurgSim::Graphics::VectorFieldRepresentation> m_vectorField;
84 };
85 
86 } // namespace Blocks
87 } // namespace SurgSim
88 
89 #endif // SURGSIM_BLOCKS_VISUALIZECONTACTSBEHAVIOR_H
SurgSim::Blocks::VisualizeContactsBehavior
This behavior is used to visualize the contacts on collision representation through vector field.
Definition: VisualizeContactsBehavior.h:45
SurgSim::Blocks::VisualizeContactsBehavior::getTargetManagerType
int getTargetManagerType() const override
Specifies which manger will handle this behavior.
Definition: VisualizeContactsBehavior.cpp:127
SurgSim::Blocks::VisualizeContactsBehavior::doInitialize
bool doInitialize() override
Interface to be implemented by derived classes.
Definition: VisualizeContactsBehavior.cpp:132
SurgSim::Framework::Behavior
Behaviors perform actions.
Definition: Behavior.h:40
SurgSim::Blocks::VisualizeContactsBehavior::SURGSIM_CLASSNAME
SURGSIM_CLASSNAME(SurgSim::Blocks::VisualizeContactsBehavior)
SurgSim::Blocks::VisualizeContactsBehavior::m_vectorField
std::shared_ptr< SurgSim::Graphics::VectorFieldRepresentation > m_vectorField
The osg vector field for visualizing contacts on collision representation.
Definition: VisualizeContactsBehavior.h:83
ObjectFactory.h
SurgSim
Definition: CompoundShapeToGraphics.cpp:29
SurgSim::Blocks::VisualizeContactsBehavior::VisualizeContactsBehavior
VisualizeContactsBehavior(const std::string &name)
Constructor.
Definition: VisualizeContactsBehavior.cpp:48
SurgSim::Blocks::VisualizeContactsBehavior::m_source
std::shared_ptr< SurgSim::Collision::Representation > m_source
The collision representation to get contacts for visualizing.
Definition: VisualizeContactsBehavior.h:80
SurgSim::Collision::Representation
The type of collision detection.
Definition: Representation.h:60
SurgSim::Blocks::VisualizeContactsBehavior::doWakeUp
bool doWakeUp() override
Interface to be implemented by derived classes.
Definition: VisualizeContactsBehavior.cpp:137
SurgSim::Blocks::VisualizeContactsBehavior::setVectorFieldScale
void setVectorFieldScale(double scale)
Set the scale of vector field, default 1.0.
Definition: VisualizeContactsBehavior.cpp:162
SurgSim::Blocks::VisualizeContactsBehavior::getSource
std::shared_ptr< SurgSim::Framework::Component > getSource()
Get the source of the contacts.
Definition: VisualizeContactsBehavior.cpp:58
SurgSim::Blocks::VisualizeContactsBehavior::setSource
void setSource(std::shared_ptr< SurgSim::Framework::Component > source)
Set the source of the contacts.
Definition: VisualizeContactsBehavior.cpp:63
SurgSim::Blocks::VisualizeContactsBehavior::update
void update(double dt) override
Update the behavior.
Definition: VisualizeContactsBehavior.cpp:68
SurgSim::Blocks::VisualizeContactsBehavior::getVectorFieldScale
double getVectorFieldScale()
Definition: VisualizeContactsBehavior.cpp:157
Behavior.h