All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Mesh.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_GRAPHICS_MESH_H
17 #define SURGSIM_GRAPHICS_MESH_H
18 
19 #include <vector>
20 
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 class Mesh : public SurgSim::DataStructures::TriangleMeshBase<VertexData, SurgSim::DataStructures::EmptyData,
56  SurgSim::DataStructures::EmptyData>
57 {
58 public:
60  Mesh();
61 
68  template <class VertexDataSource, class EdgeDataSource, class TriangleDataSource>
69  explicit Mesh(const TriangleMeshBase<VertexDataSource, EdgeDataSource, TriangleDataSource>& mesh);
70 
79  void initialize(const std::vector<SurgSim::Math::Vector3d>& vertices,
80  const std::vector<SurgSim::Math::Vector4d>& colors,
81  const std::vector<SurgSim::Math::Vector2d>& textures,
82  const std::vector<size_t>& triangles);
83 };
84 
85 
86 }; // Graphics
87 }; // SurgSim
88 
90 
91 #endif // SURGSIM_GRAPHICS_MESH_H
bool operator==(const SurgSim::Graphics::VertexData &rhs) const
Equality operator.
Definition: Mesh.h:40
Definition: Mesh.h:55
Mesh()
Default constructor.
Definition: Mesh.cpp:30
void initialize(const std::vector< SurgSim::Math::Vector3d > &vertices, const std::vector< SurgSim::Math::Vector4d > &colors, const std::vector< SurgSim::Math::Vector2d > &textures, const std::vector< size_t > &triangles)
Utility function to initialize a mesh with plain data,.
Definition: Mesh.cpp:34
SurgSim::DataStructures::OptionalValue< SurgSim::Math::Vector4d > color
Definition: Mesh.h:35
Definition: Mesh.h:32
Definitions of small fixed-size vector types.
Basic class for storing Triangle Meshes, handling basic vertex, edge, and triangle functionality...
Definition: TriangleMeshBase.h:58
bool operator!=(const SurgSim::Graphics::VertexData &rhs) const
Inequality operator.
Definition: Mesh.h:49
SurgSim::DataStructures::OptionalValue< SurgSim::Math::Vector2d > texture
Definition: Mesh.h:34