TriangleMesh.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_DATASTRUCTURES_TRIANGLEMESH_H
17 #define SURGSIM_DATASTRUCTURES_TRIANGLEMESH_H
18 
23 #include "SurgSim/Math/Vector.h"
24 
25 namespace SurgSim
26 {
27 
28 namespace Math
29 {
30 class MeshShape;
31 }
32 
33 namespace DataStructures
34 {
35 
37 struct NormalData
38 {
39 
41 
46  {
47  return normal == rhs.normal;
48  }
49 
54  {
55  return !((*this) == rhs);
56  }
57 };
58 
60 
62 class TriangleMesh: public std::enable_shared_from_this<TriangleMesh>,
64  public SurgSim::DataStructures::TriangleMeshBase<EmptyData, EmptyData, NormalData>
65 {
67 public:
68 
70  TriangleMesh();
71 
78  template <class VertexDataSource, class EdgeDataSource, class TriangleDataSource>
80 
84  const SurgSim::Math::Vector3d& getNormal(size_t triangleId);
85 
88  void calculateNormals();
89 
94  void copyWithTransform(const SurgSim::Math::RigidTransform3d& pose, const TriangleMesh& source);
95 
96 protected:
97  virtual void doUpdate() override;
98 
99  virtual bool doLoad(const std::string& fileName) override;
100 };
101 
102 }; // namespace DataStructures
103 }; // namespace SurgSim
104 
106 
107 #endif // SURGSIM_DATASTRUCTURES_TRIANGLEMESH_H
Definition: DriveElementFromInputBehavior.cpp:27
This class is used to facilitate file loading.
Definition: Asset.h:33
Mesh shape: shape made of a triangle mesh The triangle mesh needs to be watertight to produce valid v...
Definition: MeshShape.h:53
SurgSim::Math::Vector3d normal
Definition: TriangleMesh.h:40
bool operator!=(const SurgSim::DataStructures::NormalData &rhs) const
Inequality operator.
Definition: TriangleMesh.h:53
Store normal for each triangle in a triangle mesh.
Definition: TriangleMesh.h:37
string(TOUPPER ${DEVICE}DEVICE_UPPER_CASE) option(BUILD_DEVICE_ $
Definition: CMakeLists.txt:35
Definitions of 2x2 and 3x3 rigid (isometric) transforms.
Eigen::Transform< double, 3, Eigen::Isometry > RigidTransform3d
A 3D rigid (isometric) transform, represented as doubles.
Definition: RigidTransform.h:46
Definitions of small fixed-size vector types.
Basic class for storing Triangle Meshes, handling basic vertex, edge, and triangle functionality...
Definition: TriangleMeshBase.h:58
TriangleMeshBase< EmptyData, EmptyData, EmptyData > TriangleMeshPlain
Definition: TriangleMesh.h:59
A TriangleMesh stores normal information for the triangles.
Definition: TriangleMesh.h:62
virtual bool doLoad(const std::string &filePath) override
Derived classes will overwrite this method to do actual loading.
Definition: MeshShape.cpp:42
Eigen::Matrix< double, 3, 1 > Vector3d
A 3D vector of doubles.
Definition: Vector.h:56
bool operator==(const SurgSim::DataStructures::NormalData &rhs) const
Equality operator.
Definition: TriangleMesh.h:45