opensurgsim
MeshRepresentation.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_MESHREPRESENTATION_H
17 #define SURGSIM_GRAPHICS_MESHREPRESENTATION_H
18 
19 #include "SurgSim/Framework/Asset.h"
20 #include "SurgSim/Framework/FrameworkConvert.h"
21 #include "SurgSim/DataStructures/DataStructuresConvert.h"
23 #include "SurgSim/Graphics/Mesh.h"
24 #include "SurgSim/Graphics/Representation.h"
25 
26 
27 namespace SurgSim
28 {
29 
30 namespace Graphics
31 {
32 
34 class MeshRepresentation : public virtual Representation
35 {
36 public:
37 
38  enum UpdateOption
39  {
40  UPDATE_OPTION_NONE = 0,
41  UPDATE_OPTION_VERTICES = 0x01,
42  UPDATE_OPTION_COLORS = 0x02,
43  UPDATE_OPTION_TEXTURES = 0x04,
44  UPDATE_OPTION_TRIANGLES = 0x08,
45  UPDATE_OPTION_ALL = UPDATE_OPTION_VERTICES | UPDATE_OPTION_COLORS |
46  UPDATE_OPTION_TEXTURES | UPDATE_OPTION_TRIANGLES
47  };
48 
51  explicit MeshRepresentation(const std::string& name) : Representation(name)
52  {
53  SURGSIM_ADD_SERIALIZABLE_PROPERTY(MeshRepresentation, std::shared_ptr<SurgSim::Framework::Asset>, Mesh, getMesh,
54  setMesh);
55  SURGSIM_ADD_SERIALIZABLE_PROPERTY(MeshRepresentation, int, UpdateOptions, getUpdateOptions, setUpdateOptions);
56  SURGSIM_ADD_SETTER(MeshRepresentation, std::string, MeshFileName, loadMesh);
57  }
58 
60  virtual ~MeshRepresentation() {}
61 
64  virtual std::shared_ptr<Mesh> getMesh() = 0;
65 
68  virtual void setMesh(std::shared_ptr<SurgSim::Framework::Asset> mesh) = 0;
69 
72  virtual void loadMesh(const std::string& fileName) = 0;
73 
77  virtual void setShape(std::shared_ptr<SurgSim::Math::Shape> shape) = 0;
78 
83  virtual void setUpdateOptions(int val) = 0;
84 
87  virtual int getUpdateOptions() const = 0;
88 
89  virtual void updateMesh(const Mesh& mesh) = 0;
90 };
91 
92 }; // Graphics
93 }; // SurgSim
94 
95 #endif // SURGSIM_GRAPHICS_MESHREPRESENTATION_H
Wraps glewInit() to separate the glew opengl definitions from the osg opengl definitions only imgui n...
Definition: AddRandomSphereBehavior.cpp:36
Graphics representation of a mesh, can be initialized from a Mesh structure.
Definition: MeshRepresentation.h:34
Definition: Mesh.h:57
virtual void loadMesh(const std::string &fileName)=0
Convenience function to trigger the load of the mesh with the given filename.
virtual ~MeshRepresentation()
Destructor.
Definition: MeshRepresentation.h:60
This contains a series of functions to encode and decode Eigen data structures to and from YAML nodes...
virtual int getUpdateOptions() const =0
Gets update options for this mesh.
virtual void setUpdateOptions(int val)=0
Sets the structures that are expected to change during the lifetime of the mesh, these will be update...
virtual void setMesh(std::shared_ptr< SurgSim::Framework::Asset > mesh)=0
Sets the mesh.
Base graphics representation class, which defines the interface that all graphics representations mus...
Definition: Representation.h:40
virtual std::shared_ptr< Mesh > getMesh()=0
Gets the mesh.
MeshRepresentation(const std::string &name)
Constructor.
Definition: MeshRepresentation.h:51
virtual void setShape(std::shared_ptr< SurgSim::Math::Shape > shape)=0
Sets the shape of the representation param shape the shape of this representation.