16 #ifndef SURGSIM_DATASTRUCTURES_LOCATION_H 17 #define SURGSIM_DATASTRUCTURES_LOCATION_H 21 #include "SurgSim/DataStructures/OptionalValue.h" 22 #include "SurgSim/DataStructures/IndexedLocalCoordinate.h" 23 #include "SurgSim/DataStructures/OctreeNode.h" 28 namespace DataStructures
42 enum Type {TRIANGLE, ELEMENT};
52 : rigidLocalPosition(other.rigidLocalPosition),
53 octreeNodePath(other.octreeNodePath),
55 triangleMeshLocalCoordinate(other.triangleMeshLocalCoordinate),
56 elementMeshLocalCoordinate(other.elementMeshLocalCoordinate)
63 rigidLocalPosition.
setValue(localPosition);
68 explicit Location(
const SurgSim::DataStructures::OctreePath& nodePath)
88 triangleMeshLocalCoordinate.setValue(localCoordinate);
91 elementMeshLocalCoordinate.setValue(localCoordinate);
109 return triangleMeshLocalCoordinate;
112 return elementMeshLocalCoordinate;
121 bool isApprox(
const Location& other,
double precision = std::numeric_limits<double>::epsilon())
const 127 auto const& vector1 = rigidLocalPosition.
getValue();
128 auto const& vector2 = other.rigidLocalPosition.
getValue();
130 result = (vector1.isZero(precision) && vector2.isZero(precision)) || vector1.isApprox(vector2, precision);
140 else if (triangleMeshLocalCoordinate.hasValue() && other.triangleMeshLocalCoordinate.hasValue())
142 result = triangleMeshLocalCoordinate.getValue().isApprox(other.triangleMeshLocalCoordinate.getValue());
144 else if (elementMeshLocalCoordinate.hasValue() && other.elementMeshLocalCoordinate.hasValue())
146 result = elementMeshLocalCoordinate.getValue().isApprox(other.elementMeshLocalCoordinate.getValue());
164 template <
typename charT,
typename traits,
typename T>
165 std::basic_ostream<charT, traits>& operator << (std::basic_ostream<charT, traits>& out,
179 template <
typename charT,
typename traits>
180 std::basic_ostream<charT, traits>& operator << (std::basic_ostream<charT, traits>& out,
195 template <
typename charT,
typename traits>
196 std::basic_ostream<charT, traits>& operator << (std::basic_ostream<charT, traits>& out,
199 out <<
"[ " << val.
index <<
" : " << val.coordinate.transpose() <<
" ]";
204 template <
typename charT,
typename traits>
205 std::basic_ostream<charT, traits>& operator << (std::basic_ostream<charT, traits>& out,
208 out <<
"ElementMesh: " << loc.elementMeshLocalCoordinate << std::endl;
209 out <<
"Index: " << loc.index << std::endl;
210 out <<
"RigidLocal: " << loc.rigidLocalPosition << std::endl;
211 out <<
"TriangleMeshLocal: " << loc.triangleMeshLocalCoordinate << std::endl;
218 #endif // SURGSIM_DATASTRUCTURES_LOCATION_H Wraps glewInit() to separate the glew opengl definitions from the osg opengl definitions only imgui n...
Definition: AddRandomSphereBehavior.cpp:36
A generic (size_t index, Vector coordinate) pair.
Definition: IndexedLocalCoordinate.h:29
Location(const size_t val)
Constructor for an index.
Definition: Location.h:75
Location(const SurgSim::DataStructures::IndexedLocalCoordinate &localCoordinate, Type meshType)
Constructor for mesh-based location.
Definition: Location.h:83
Location(const SurgSim::Math::Vector3d &localPosition)
Constructor for rigid local position.
Definition: Location.h:61
A Location defines a local position w.r.t.
Definition: Location.h:39
Container class that can indicate whether the object has been assigned a value.
Definition: OptionalValue.h:29
#define SURGSIM_FAILURE()
Report that something very bad has happened and abort program execution.
Definition: Assert.h:95
Eigen::Matrix< double, 3, 1 > Vector3d
A 3D vector of doubles.
Definition: Vector.h:57
size_t index
Numeric index to indicate the entity w.r.t which the barycentricCoordinate is defined.
Definition: IndexedLocalCoordinate.h:41
Location()
Default constructor.
Definition: Location.h:45
Definitions of small fixed-size vector types.
Location(const SurgSim::DataStructures::OctreePath &nodePath)
Constructor for octree node path.
Definition: Location.h:68
bool hasValue() const
Query if this object has been assigned a value.
Definition: OptionalValue.h:56
void setValue(const T &val)
Set the value of this object, and mark it as valid.
Definition: OptionalValue.h:69
const T & getValue() const
Gets the value.
Definition: OptionalValue.h:78
Location(const Location &other)
Copy constructor.
Definition: Location.h:51