Mesh.h
Go to the documentation of this file.
// This file is a part of the OpenSurgSim project.
// Copyright 2013, SimQuest Solutions Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#ifndef SURGSIM_GRAPHICS_MESH_H
#define SURGSIM_GRAPHICS_MESH_H
#include <vector>
#include "SurgSim/DataStructures/EmptyData.h"
#include "SurgSim/DataStructures/TriangleMesh.h"
#include "SurgSim/DataStructures/OptionalValue.h"
#include "SurgSim/Math/Vector.h"
namespace SurgSim
{
namespace Graphics
{
struct VertexData
{
SurgSim::DataStructures::OptionalValue<SurgSim::Math::Vector2d> texture;
SurgSim::DataStructures::OptionalValue<SurgSim::Math::Vector4d> color;
bool operator==(const SurgSim::Graphics::VertexData& rhs) const
{
return texture == rhs.texture &&
color == rhs.color;
}
bool operator!=(const SurgSim::Graphics::VertexData& rhs) const
{
return !((*this) == rhs);
}
};
SURGSIM_STATIC_REGISTRATION(Mesh);
class Mesh : public SurgSim::DataStructures::TriangleMesh<VertexData, SurgSim::DataStructures::EmptyData,
SurgSim::DataStructures::EmptyData>
{
public:
Mesh();
typedef TriangleMesh<VertexData, DataStructures::EmptyData, DataStructures::EmptyData> BaseType;
template <class V, class E, class T>
explicit Mesh(const TriangleMesh<V, E, T>& other);
Mesh(const Mesh& other);
Mesh(Mesh&& other);
Mesh& operator=(const Mesh& other);
Mesh& operator=(Mesh&& other);
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);
void dirty();
size_t getUpdateCount() const;
protected:
bool doLoad(const std::string& fileName) override;
size_t m_updateCount;
};
}; // Graphics
}; // SurgSim
#include "SurgSim/Graphics/Mesh-inl.h"
#endif // SURGSIM_GRAPHICS_MESH_H
SurgSim
Definition: CompoundShapeToGraphics.cpp:29
SurgSim::Graphics::Mesh
Definition: Mesh.h:57
Mesh-inl.h
SurgSim::DataStructures::OptionalValue< SurgSim::Math::Vector2d >
SurgSim::Graphics::Mesh::BaseType
TriangleMesh< VertexData, DataStructures::EmptyData, DataStructures::EmptyData > BaseType
Definition: Mesh.h:64
SurgSim::Graphics::VertexData::color
SurgSim::DataStructures::OptionalValue< SurgSim::Math::Vector4d > color
Definition: Mesh.h:35
SurgSim::Graphics::VertexData
Definition: Mesh.h:32
SurgSim::Graphics::Mesh::m_updateCount
size_t m_updateCount
For checking whether the mesh has changed.
Definition: Mesh.h:116
SurgSim::Graphics::VertexData::operator==
bool operator==(const SurgSim::Graphics::VertexData &rhs) const
Equality operator.
Definition: Mesh.h:40
Vector.h
Definitions of small fixed-size vector types.
SurgSim::Graphics::VertexData::operator!=
bool operator!=(const SurgSim::Graphics::VertexData &rhs) const
Inequality operator.
Definition: Mesh.h:49
SurgSim::DataStructures::TriangleMesh
Basic class for storing Triangle Meshes, handling basic vertex, edge, and triangle functionality...
Definition: TriangleMesh.h:62
OptionalValue.h
TriangleMesh.h
EmptyData.h
SurgSim::Graphics::VertexData::texture
SurgSim::DataStructures::OptionalValue< SurgSim::Math::Vector2d > texture
Definition: Mesh.h:34