Localization.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_PHYSICS_LOCALIZATION_H
17 #define SURGSIM_PHYSICS_LOCALIZATION_H
18 
19 #include <memory>
20 
21 #include "SurgSim/Math/Vector.h"
23 
24 namespace SurgSim
25 {
26 
27 namespace Physics
28 {
29 
30 class Representation;
31 
34 {
35 public:
37  Localization();
38 
41  explicit Localization(std::shared_ptr<Representation> representation);
42 
44  virtual ~Localization();
45 
48  void setRepresentation(std::shared_ptr<Representation> representation)
49  {
50  if (isValidRepresentation(representation))
51  {
52  m_representation = representation;
53  }
54  else
55  {
56  SURGSIM_ASSERT(false) << "Unexpected representation type" << std::endl;
57  }
58  }
59 
62  std::shared_ptr<Representation> getRepresentation() const
63  {
64  return m_representation;
65  }
66 
72  {
73  return doCalculatePosition(time);
74  }
75 
76  virtual bool isValidRepresentation(std::shared_ptr<Representation> representation);
77 
78 private:
83  virtual SurgSim::Math::Vector3d doCalculatePosition(double time) = 0;
85  std::shared_ptr<Representation> m_representation;
86 };
87 
88 }; // namespace Physics
89 
90 }; // namespace SurgSim
91 
92 #endif // SURGSIM_PHYSICS_LOCALIZATION_H
std::shared_ptr< Representation > m_representation
The representation on which the localization is defined.
Definition: Localization.h:85
Definition: DriveElementFromInputBehavior.cpp:27
SurgSim::Math::Vector3d calculatePosition(double time=1.0)
Calculates the global position of this localization.
Definition: Localization.h:71
#define SURGSIM_ASSERT(condition)
Assert that condition is true.
Definition: Assert.h:77
std::shared_ptr< Representation > getRepresentation() const
Gets the representation.
Definition: Localization.h:62
void setRepresentation(std::shared_ptr< Representation > representation)
Sets the representation.
Definition: Localization.h:48
virtual ~Localization()
Destructor.
Definition: Localization.cpp:30
Localization()
Default constructor.
Definition: Localization.cpp:22
The header that provides the assertion API.
Definitions of small fixed-size vector types.
virtual SurgSim::Math::Vector3d doCalculatePosition(double time)=0
Calculates the global position of this localization.
virtual bool isValidRepresentation(std::shared_ptr< Representation > representation)
Definition: Localization.cpp:34
This class localize a point on a representation (representation specific)
Definition: Localization.h:33
Eigen::Matrix< double, 3, 1 > Vector3d
A 3D vector of doubles.
Definition: Vector.h:56