SCIRun  5.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Geometry.h
Go to the documentation of this file.
1 /*
2  For more information, please see: http://software.sci.utah.edu
3 
4  The MIT License
5 
6  Copyright (c) 2012 Scientific Computing and Imaging Institute,
7  University of Utah.
8 
9 
10  Permission is hereby granted, free of charge, to any person obtaining a
11  copy of this software and associated documentation files (the "Software"),
12  to deal in the Software without restriction, including without limitation
13  the rights to use, copy, modify, merge, publish, distribute, sublicense,
14  and/or sell copies of the Software, and to permit persons to whom the
15  Software is furnished to do so, subject to the following conditions:
16 
17  The above copyright notice and this permission notice shall be included
18  in all copies or substantial portions of the Software.
19 
20  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
21  OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
22  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
23  THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
24  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
25  FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
26  DEALINGS IN THE SOFTWARE.
27 */
28 /// @todo Documentation Core/Datatypes/Geometry.h
29 
30 #ifndef CORE_DATATYPES_GEOMETRY_H
31 #define CORE_DATATYPES_GEOMETRY_H
32 
33 #include <cstdint>
34 #include <list>
35 #include <vector>
38 #include <spire/Interface.h>
39 
40 
41 /// The following include contains AbstractUniformStateItem which allows
42 /// us to store uniforms to be passed, at a later time, to spire.
43 #include <spire/src/ShaderUniformStateManTemplates.h>
44 
45 #include <Core/Datatypes/share.h>
46 
47 namespace SCIRun {
48 namespace Core {
49 namespace Datatypes {
50 
51  namespace spire = CPM_SPIRE_NS;
52 
54  {
55  public:
57  GeometryObject(const GeometryObject& other);
58  GeometryObject& operator=(const GeometryObject& other);
59  DatatypeConstHandle get_underlying() const;
60  virtual GeometryObject* clone() const { return new GeometryObject(*this); }
61 
62  std::string objectName; ///< Name of this object. Should be unique
63  ///< across all modules in the network.
64 
65  // Could require rvalue references...
66  struct SpireVBO
67  {
68  SpireVBO(const std::string& vboName, const std::vector<std::string> attribs,
69  std::shared_ptr<std::vector<uint8_t>> vboData,
70  const Core::Geometry::BBox& bbox) :
71  name(vboName),
72  attributeNames(attribs),
73  data(vboData),
74  boundingBox(bbox)
75  {}
76 
77  std::string name;
78  std::vector<std::string> attributeNames;
79  std::shared_ptr<std::vector<uint8_t>> data;
81  };
82 
83  // Could require rvalue references...
84  struct SpireIBO
85  {
86  SpireIBO(const std::string& iboName, size_t iboIndexSize,
87  std::shared_ptr<std::vector<uint8_t>> iboData) :
88  name(iboName),
89  indexSize(iboIndexSize),
90  data(iboData)
91  {}
92 
93  std::string name;
94  size_t indexSize;
95  std::shared_ptr<std::vector<uint8_t>> data;
96  };
97 
98  std::list<SpireVBO> mVBOs; ///< Array of vertex buffer objects.
99  std::list<SpireIBO> mIBOs; ///< Array of index buffer objects.
100 
101  /// Defines a Spire object 'pass'.
103  {
104  SpireSubPass(const std::string& name, const std::string& vbo,
105  const std::string& ibo, const std::string& program,
106  spire::Interface::PRIMITIVE_TYPES primType) :
107  passName(name),
108  vboName(vbo),
109  iboName(ibo),
110  programName(program),
111  type(primType)
112  {}
113 
114  std::string passName;
115  std::string vboName;
116  std::string iboName;
117  std::string programName;
118  spire::Interface::PRIMITIVE_TYPES type;
119 
120  template <typename T>
121  void addUniform(const std::string& uniformName, T uniformData)
122  {
123  uniforms.push_back(
124  std::make_pair(uniformName, std::shared_ptr<spire::AbstractUniformStateItem>(
125  new spire::UniformStateItem<T>(uniformData))));
126  }
127 
128  // Tuple containing the name of the uniform and its contents.
129  std::list<std::tuple<
130  std::string, std::shared_ptr<spire::AbstractUniformStateItem>>> uniforms;
131  };
132 
133  /// List of passes to setup.
134  std::list<SpireSubPass> mPasses;
135 
136  /// Optional colormap name.
137  boost::optional<std::string> mColorMap;
138 
139  double mLowestValue; ///< Lowest value a field takes on.
140  double mHighestValue; ///< Highest value a field takes on.
141 
142  /// \xxx Possibly implement a list of global uniforms. Only do this if
143  /// there is a clear need for global uniforms.
144 
145  private:
146  DatatypeConstHandle data_;
147  };
148 
149 }}}
150 
151 
152 #endif
std::list< std::tuple< std::string, std::shared_ptr< spire::AbstractUniformStateItem > > > uniforms
Definition: Geometry.h:130
std::string iboName
Definition: Geometry.h:116
SpireVBO(const std::string &vboName, const std::vector< std::string > attribs, std::shared_ptr< std::vector< uint8_t >> vboData, const Core::Geometry::BBox &bbox)
Definition: Geometry.h:68
SpireSubPass(const std::string &name, const std::string &vbo, const std::string &ibo, const std::string &program, spire::Interface::PRIMITIVE_TYPES primType)
Definition: Geometry.h:104
#define SCISHARE
Definition: share.h:39
Definition: BBox.h:46
Defines a Spire object &#39;pass&#39;.
Definition: Geometry.h:102
spire::Interface::PRIMITIVE_TYPES type
Definition: Geometry.h:118
std::vector< std::string > attributeNames
Definition: Geometry.h:78
void addUniform(const std::string &uniformName, T uniformData)
Definition: Geometry.h:121
Definition: Datatype.h:41
virtual GeometryObject * clone() const
Definition: Geometry.h:60
const char * name[]
Definition: BoostGraphExampleTests.cc:87
std::string name
Definition: Geometry.h:93
dictionary data
Definition: eabLatVolData.py:11
std::string programName
Definition: Geometry.h:117
std::string name
Definition: Geometry.h:77
double mHighestValue
Highest value a field takes on.
Definition: Geometry.h:140
std::shared_ptr< std::vector< uint8_t > > data
Definition: Geometry.h:79
std::shared_ptr< std::vector< uint8_t > > data
Definition: Geometry.h:95
std::list< SpireSubPass > mPasses
List of passes to setup.
Definition: Geometry.h:134
std::string objectName
Definition: Geometry.h:62
std::list< SpireIBO > mIBOs
Array of index buffer objects.
Definition: Geometry.h:99
double mLowestValue
Lowest value a field takes on.
Definition: Geometry.h:139
boost::optional< std::string > mColorMap
Optional colormap name.
Definition: Geometry.h:137
boost::shared_ptr< const Datatype > DatatypeConstHandle
Definition: DatatypeFwd.h:46
std::string passName
Definition: Geometry.h:114
Core::Geometry::BBox boundingBox
Definition: Geometry.h:80
size_t indexSize
Definition: Geometry.h:94
std::string vboName
Definition: Geometry.h:115
std::list< SpireVBO > mVBOs
Array of vertex buffer objects.
Definition: Geometry.h:98
SpireIBO(const std::string &iboName, size_t iboIndexSize, std::shared_ptr< std::vector< uint8_t >> iboData)
Definition: Geometry.h:86