VisualizeContactsBehavior.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_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> getCollisionRepresentation();
57 
60  void setCollisionRepresentation(std::shared_ptr<SurgSim::Framework::Component> collisionRepresentation);
61 
64  virtual void update(double dt) override;
65 
68  virtual int getTargetManagerType() const override;
69 
71  double getVectorFieldScale();
72 
74  // \param scale The scale of the vector field.
75  void setVectorFieldScale(double scale);
76 
77 protected:
81  virtual bool doInitialize() override;
82 
86  virtual bool doWakeUp() override;
87 
88 private:
90  std::shared_ptr<SurgSim::Collision::Representation> m_collisionRepresentation;
91 
93  std::shared_ptr<SurgSim::Graphics::VectorFieldRepresentation> m_vectorField;
94 };
95 
96 } // namespace Blocks
97 } // namespace SurgSim
98 
99 #endif // SURGSIM_BLOCKS_VISUALIZECONTACTSBEHAVIOR_H
Definition: DriveElementFromInputBehavior.cpp:27
virtual int getTargetManagerType() const override
Return the type of manager that should be responsible for this behavior.
Definition: VisualizeContactsBehavior.cpp:112
virtual bool doInitialize() override
Initialize this behavior.
Definition: VisualizeContactsBehavior.cpp:117
This behavior is used to visualize the contacts on collision representation through vector field...
Definition: VisualizeContactsBehavior.h:45
std::shared_ptr< SurgSim::Framework::Component > getCollisionRepresentation()
Used for serialization.
Definition: VisualizeContactsBehavior.cpp:54
void setVectorFieldScale(double scale)
Set the scale of vector field, default 1.0.
Definition: VisualizeContactsBehavior.cpp:134
VisualizeContactsBehavior(const std::string &name)
Constructor.
Definition: VisualizeContactsBehavior.cpp:44
SURGSIM_CLASSNAME(SurgSim::Blocks::VisualizeContactsBehavior)
virtual bool doWakeUp() override
Wakeup this behavior.
Definition: VisualizeContactsBehavior.cpp:123
void setCollisionRepresentation(std::shared_ptr< SurgSim::Framework::Component > collisionRepresentation)
Used for serialization.
Definition: VisualizeContactsBehavior.cpp:59
std::shared_ptr< SurgSim::Graphics::VectorFieldRepresentation > m_vectorField
The osg vector field for visualizing contacts on collision representation.
Definition: VisualizeContactsBehavior.h:93
double getVectorFieldScale()
Definition: VisualizeContactsBehavior.cpp:129
virtual void update(double dt) override
Update the behavior, show vector field for contacts if there is any.
Definition: VisualizeContactsBehavior.cpp:65
Behaviors perform actions.
Definition: Behavior.h:40
Wrapper class to use for the collision operation, handles its enclosed shaped and a possible local to...
Definition: Representation.h:52
SURGSIM_STATIC_REGISTRATION(DriveElementFromInputBehavior)
std::shared_ptr< SurgSim::Collision::Representation > m_collisionRepresentation
The collision representation to get contacts for visualizing.
Definition: VisualizeContactsBehavior.h:90