Graphite  Version 3
An experimental 3D geometry processing program
voxel_grob.h
Go to the documentation of this file.
1 /*
2  * OGF/Graphite: Geometry and Graphics Programming Library + Utilities
3  * Copyright (C) 2000-2009 INRIA - Project ALICE
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation; either version 2 of the License, or
8  * (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program; if not, write to the Free Software
17  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
18  *
19  * If you modify this software, you should include a notice giving the
20  * name of the person performing the modification, the date of modification,
21  * and the reason for such modification.
22  *
23  * Contact: Bruno Levy - levy@loria.fr
24  *
25  * Project ALICE
26  * LORIA, INRIA Lorraine,
27  * Campus Scientifique, BP 239
28  * 54506 VANDOEUVRE LES NANCY CEDEX
29  * FRANCE
30  *
31  * Note that the GNU General Public License does not permit incorporating
32  * the Software into proprietary programs.
33  *
34  * As an exception to the GPL, Graphite can be linked
35  * with the following (non-GPL) libraries:
36  * Qt, SuperLU, WildMagic and CGAL
37  */
38 
39 
40 #ifndef H_OGF_GRAPHITE_VOXEL_VOXEL_GROB_H
41 #define H_OGF_GRAPHITE_VOXEL_VOXEL_GROB_H
42 
46 
51 namespace OGF {
52 
56  gom_class VOXEL_API VoxelGrob : public Grob {
57  public:
64 
69  const vec3& origin() const {
70  return origin_;
71  }
72 
77  const vec3& U() const {
78  return U_;
79  }
80 
85  const vec3& V() const {
86  return V_;
87  }
88 
93  const vec3& W() const {
94  return W_;
95  }
96 
101  index_t nu() const {
102  return nu_;
103  }
104 
109  index_t nv() const {
110  return nv_;
111  }
112 
117  index_t nw() const {
118  return nw_;
119  }
120 
127  void resize(index_t nu, index_t nv, index_t nw);
128 
136  void set_box(
137  const vec3& origin, const vec3& U, const vec3& V, const vec3& W
138  );
139 
147  geo_debug_assert(u < nu());
148  geo_debug_assert(v < nv());
149  geo_debug_assert(w < nw());
150  return u + nu_ * (v + nv_ * w);
151  }
152 
156  void clear() override;
157 
161  Grob* duplicate(SceneGraph* sg) override;
162 
166  bool is_serializable() const override;
167 
171  bool serialize_read(InputGraphiteFile& geofile) override;
172 
176  bool serialize_write(OutputGraphiteFile& geofile) override;
177 
178 
179  gom_properties:
180 
185  std::string get_displayable_attributes() const;
186 
187 
188 
189  public:
193  void update() override;
194 
195 
199  Box3d bbox() const override;
200 
210  SceneGraph* sg, const std::string& name
211  );
212 
220  static VoxelGrob* find(SceneGraph* sg, const std::string& name);
221 
230  return const_cast<AttributesManager&>(attributes_);
231  }
232 
233  private:
234  AttributesManager attributes_;
235  index_t nu_;
236  index_t nv_;
237  index_t nw_;
238  vec3 origin_;
239  vec3 U_;
240  vec3 V_;
241  vec3 W_;
242  };
243 
252 
263 }
264 #endif
#define geo_debug_assert(x)
Verifies that a condition is met.
Definition: assert.h:196
Generic mechanism for attributes.
Managers a set of attributes attached to an object.
Definition: attributes.h:834
A 3d axis aligned box.
Definition: geometry.h:235
A Composite Graphite Object.
Base class for all 3D Graphite objects.
Definition: grob.h:68
An extension of InputGeoFile for storing a complete Graphite scenegraph in a structured binary file.
Definition: geofile.h:67
A template class for strings that need to have a specific type in the GOM system.
Definition: properties.h:218
An extension of InputGeoFile for storing a complete Graphite scenegraph in a structured binary file.
Definition: geofile.h:129
Represents the list of objects loaded in Graphite.
Definition: scene_graph.h:62
A Grob class for voxel grids.
Definition: voxel_grob.h:56
bool is_serializable() const override
Tests whether this Grob can be serialized in GeoFile.
void update() override
const vec3 & U() const
Gets the first axis.
Definition: voxel_grob.h:77
index_t nv() const
Gets the size of the second axis.
Definition: voxel_grob.h:109
Grob * duplicate(SceneGraph *sg) override
Duplicates this Grob.
static VoxelGrob * find_or_create(SceneGraph *sg, const std::string &name)
Finds or creates a VoxelGrob with the specified name.
void clear() override
Clears this Grob.
index_t linear_index(index_t u, index_t v, index_t w) const
Converts (u,v,w) indices into a linear index.
Definition: voxel_grob.h:146
VoxelGrob(CompositeGrob *parent)
VoxelGrob constructor.
const vec3 & V() const
Gets the second axis.
Definition: voxel_grob.h:85
static VoxelGrob * find(SceneGraph *sg, const std::string &name)
Finds a VoxelGrob by name.
index_t nw() const
Gets the size of the third axis.
Definition: voxel_grob.h:117
Box3d bbox() const override
Gets the bounding box.
AttributesManager & attributes() const
Gets the attributes manager.
Definition: voxel_grob.h:229
void resize(index_t nu, index_t nv, index_t nw)
Defines the sizes in cells of the three axes.
const vec3 & origin() const
Gets the origin.
Definition: voxel_grob.h:69
bool serialize_read(InputGraphiteFile &geofile) override
Reads this Grob from a GeoFile.
void set_box(const vec3 &origin, const vec3 &U, const vec3 &V, const vec3 &W)
Sets the geometry of the box.
index_t nu() const
Gets the size of the first axis.
Definition: voxel_grob.h:101
const vec3 & W() const
Gets the third axis.
Definition: voxel_grob.h:93
bool serialize_write(OutputGraphiteFile &geofile) override
Writes this Grob into a stream.
The base class for all 3D objects in the system.
geo_index_t index_t
The type for storing and manipulating indices.
Definition: numeric.h:329
Global Graphite namespace.
Definition: common.h:76
Name< VoxelGrob * > VoxelGrobName
The name of an existing VoxelGrob in the SceneGraph.
Definition: voxel_grob.h:251
Name< VoxelGrob *, true > NewVoxelGrobName
The name of an (existing or not) VoxelGrob in the SceneGraph.
Definition: voxel_grob.h:262
Definitions common to all include files in the voxel library.