iRoCS Toolbox  1.1.0
SurfaceGeometry.hh
Go to the documentation of this file.
1 /**************************************************************************
2  *
3  * Copyright (C) 2015 Thorsten Falk
4  *
5  * Image Analysis Lab, University of Freiburg, Germany
6  *
7  * This program is free software; you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation; either version 3 of the License, or
10  * (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program; if not, write to the Free Software Foundation,
19  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20  *
21  **************************************************************************/
22 
23 /*======================================================================*/
28 /*======================================================================*/
29 
30 #ifndef ATBSURFACEGEOMETRY_HH
31 #define ATBSURFACEGEOMETRY_HH
32 
33 #ifdef HAVE_CONFIG_H
34 #include <config.hh>
35 #endif
36 
37 #include <vector>
38 
39 #include <blitz/array.h>
40 
41 namespace atb
42 {
43 
44 /*======================================================================*/
51 /*======================================================================*/
53  {
54 
55  public:
56 
57 /*======================================================================*/
61 /*======================================================================*/
62  typedef blitz::TinyVector<float,3> VertexT;
63 
64 /*======================================================================*/
68 /*======================================================================*/
69  typedef blitz::TinyVector<float,3> NormalT;
70 
71 /*======================================================================*/
76 /*======================================================================*/
77  typedef unsigned int IndexT;
78 
79 /*======================================================================*/
85 /*======================================================================*/
87 
88 /*======================================================================*/
96 /*======================================================================*/
97  SurfaceGeometry(SurfaceGeometry const &geometry);
98 
99 /*======================================================================*/
103 /*======================================================================*/
105 
106 /*======================================================================*/
118 /*======================================================================*/
119  SurfaceGeometry &operator=(SurfaceGeometry const &geometry);
120 
121 /*======================================================================*/
128 /*======================================================================*/
129  std::vector<VertexT> const &vertices() const;
130 
131 /*======================================================================*/
144 /*======================================================================*/
145  std::vector<VertexT> &vertices();
146 
147 /*======================================================================*/
154 /*======================================================================*/
155  std::vector<NormalT> const &normals() const;
156 
157 /*======================================================================*/
164 /*======================================================================*/
165  std::vector<NormalT> &normals();
166 
167 /*======================================================================*/
174 /*======================================================================*/
175  std::vector<IndexT> const &indices() const;
176 
177 /*======================================================================*/
184 /*======================================================================*/
185  std::vector<IndexT> &indices();
186 
187 /*======================================================================*/
196 /*======================================================================*/
197  void computeDefaultNormals();
198 
199 /*======================================================================*/
220 /*======================================================================*/
221  void renderSTL(std::ostream &os, bool writeASCII = true) const;
222 
223 /*======================================================================*/
234 /*======================================================================*/
235  void planeIntersection(
236  blitz::TinyVector<float,3> const &planeNormal, float planeOffset,
237  std::vector< blitz::TinyVector<blitz::TinyVector<float,2>,2> > &lines)
238  const;
239 
240 /*======================================================================*/
253 /*======================================================================*/
254  void planeIntersection(
255  int direction, float planeOffset,
256  std::vector< blitz::TinyVector<blitz::TinyVector<float,2>,2> > &lines)
257  const;
258 
259 /*======================================================================*/
271 /*======================================================================*/
272  blitz::TinyVector<double,3> const &boundingBoxLowerBoundUm() const;
273 
274 /*======================================================================*/
286 /*======================================================================*/
287  blitz::TinyVector<double,3> const &boundingBoxUpperBoundUm() const;
288 
289  private:
290 
291  void _updateBoundingBox() const;
292 
293  std::vector<VertexT> _vertices;
294  std::vector<NormalT> _normals;
295  std::vector<IndexT> _indices;
296 
297  mutable blitz::TinyVector<double,3> _boundingBoxLowerBoundUm,
298  _boundingBoxUpperBoundUm;
299  mutable bool _boundingBoxUpToDate;
300 
301  };
302 
303 }
304 
305 #endif
std::vector< IndexT > const & indices() const
Get a read only reference onto the Index vector of this SurfaceGeometry object.
SurfaceGeometry()
Default Constructor.
blitz::TinyVector< double, 3 > const & boundingBoxLowerBoundUm() const
Get the tight, axis-aligned lower bound of the bounding box for this surface geometry.
blitz::TinyVector< float, 3 > VertexT
VertexT is the type used to store a 3D vertex position.
unsigned int IndexT
IndexT is the type used to store the triangle corner indices in the vertex Array. ...
SurfaceGeometry & operator=(SurfaceGeometry const &geometry)
Copy assignment operator.
blitz::TinyVector< double, 3 > const & boundingBoxUpperBoundUm() const
Get the tight, axis-aligned upper bound of the bounding box for this surface geometry.
std::vector< NormalT > const & normals() const
Get a read only reference onto the Normal vector of this SurfaceGeometry object.
~SurfaceGeometry()
Destructor.
void renderSTL(std::ostream &os, bool writeASCII=true) const
Appends the set of triangle primitives described by this SurfaceGeometry as STL facets to the given o...
void computeDefaultNormals()
Computes the surface normals from the provided vertices and indices.
blitz::TinyVector< float, 3 > NormalT
NormalT is the type used to store a 3D vertex normal.
The SurfaceGeometry struct provides data structures required for the storage of triangulated surface ...
std::vector< VertexT > const & vertices() const
Get a read only reference onto the Vertex vector of this SurfaceGeometry object.
void planeIntersection(blitz::TinyVector< float, 3 > const &planeNormal, float planeOffset, std::vector< blitz::TinyVector< blitz::TinyVector< float, 2 >, 2 > > &lines) const
Intersect the SurfaceGeometryObject with the plane defined by the given parameters and return the res...