opensurgsim
Mesh.h
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_GRAPHICS_MESH_H
17 #define SURGSIM_GRAPHICS_MESH_H
18 
19 #include <vector>
20 
21 #include "SurgSim/DataStructures/EmptyData.h"
22 #include "SurgSim/DataStructures/TriangleMesh.h"
23 #include "SurgSim/DataStructures/OptionalValue.h"
24 #include "SurgSim/Math/Vector.h"
25 
26 namespace SurgSim
27 {
28 
29 namespace Graphics
30 {
31 
32 struct VertexData
33 {
36 
41  {
42  return texture == rhs.texture &&
43  color == rhs.color;
44  }
45 
50  {
51  return !((*this) == rhs);
52  }
53 };
54 
55 SURGSIM_STATIC_REGISTRATION(Mesh);
56 
57 class Mesh : public SurgSim::DataStructures::TriangleMesh<VertexData, SurgSim::DataStructures::EmptyData,
58  SurgSim::DataStructures::EmptyData>
59 {
60 public:
62  Mesh();
63 
64  typedef TriangleMesh<VertexData, DataStructures::EmptyData, DataStructures::EmptyData> BaseType;
65 
72  template <class V, class E, class T>
73  explicit Mesh(const TriangleMesh<V, E, T>& other);
74 
77  Mesh(const Mesh& other);
78 
81  Mesh(Mesh&& other);
82 
85  Mesh& operator=(const Mesh& other);
86 
89  Mesh& operator=(Mesh&& other);
90 
99  void initialize(const std::vector<SurgSim::Math::Vector3d>& vertices,
100  const std::vector<SurgSim::Math::Vector4d>& colors,
101  const std::vector<SurgSim::Math::Vector2d>& textures,
102  const std::vector<size_t>& triangles);
103 
106  void dirty();
107 
109  size_t getUpdateCount() const;
110 
111 
112 protected:
113  bool doLoad(const std::string& fileName) override;
114 
117 };
118 
119 
120 }; // Graphics
121 }; // SurgSim
122 
123 #include "SurgSim/Graphics/Mesh-inl.h"
124 
125 #endif // SURGSIM_GRAPHICS_MESH_H
Wraps glewInit() to separate the glew opengl definitions from the osg opengl definitions only imgui n...
Definition: AddRandomSphereBehavior.cpp:36
Definition: Mesh.h:57
Definition: Mesh.h:32
size_t m_updateCount
For checking whether the mesh has changed.
Definition: Mesh.h:116
bool operator==(const SurgSim::Graphics::VertexData &rhs) const
Equality operator.
Definition: Mesh.h:40
Definitions of small fixed-size vector types.
bool operator!=(const SurgSim::Graphics::VertexData &rhs) const
Inequality operator.
Definition: Mesh.h:49
Basic class for storing Triangle Meshes, handling basic vertex, edge, and triangle functionality...
Definition: TriangleMesh.h:62