anatomist  5.1.2
3D neuroimaging data viewer
Bucket.h
Go to the documentation of this file.
1 /* This software and supporting documentation are distributed by
2  * Institut Federatif de Recherche 49
3  * CEA/NeuroSpin, Batiment 145,
4  * 91191 Gif-sur-Yvette cedex
5  * France
6  *
7  * This software is governed by the CeCILL-B license under
8  * French law and abiding by the rules of distribution of free software.
9  * You can use, modify and/or redistribute the software under the
10  * terms of the CeCILL-B license as circulated by CEA, CNRS
11  * and INRIA at the following URL "http://www.cecill.info".
12  *
13  * As a counterpart to the access to the source code and rights to copy,
14  * modify and redistribute granted by the license, users are provided only
15  * with a limited warranty and the software's author, the holder of the
16  * economic rights, and the successive licensors have only limited
17  * liability.
18  *
19  * In this respect, the user's attention is drawn to the risks associated
20  * with loading, using, modifying and/or developing or reproducing the
21  * software by the user in light of its specific status of free software,
22  * that may mean that it is complicated to manipulate, and that also
23  * therefore means that it is reserved for developers and experienced
24  * professionals having in-depth computer knowledge. Users are therefore
25  * encouraged to load and test the software's suitability as regards their
26  * requirements in conditions enabling the security of their systems and/or
27  * data to be ensured and, more generally, to use and operate it in the
28  * same conditions as regards security.
29  *
30  * The fact that you are presently reading this means that you have had
31  * knowledge of the CeCILL-B license and that you accept its terms.
32  */
33 
34 
35 #ifndef ANA_BUCKET_BUCKET_H
36 #define ANA_BUCKET_BUCKET_H
37 
38 
41 #include <aims/mesh/surface.h>
42 #include <aims/bucket/bucket.h>
43 
44 
45 namespace anatomist
46 {
47 
48  class Referential;
49  class Geometry;
50  class Transformation;
51  struct SliceViewState;
52 
55  class Bucket : public AGLObject, public PythonAObject
56  {
57  public:
58  Bucket(const char *filename=NULL);
60 
61  float MinT() const { return( _minT ); }
62  float MaxT() const { return( _maxT ); }
63  virtual bool boundingBox( std::vector<float> & bmin,
64  std::vector<float> & bmax ) const;
65  virtual bool boundingBox2D( std::vector<float> & bmin,
66  std::vector<float> & bmax ) const
67  { return boundingBox( bmin, bmax ); }
68 
69  virtual void
70  setSubBucketGeomExtrema( const Point3df& pmin = Point3df(0., 0., 0.),
71  const Point3df& pmax = Point3df(0., 0., 0.) ) ;
72  virtual void setGeomExtrema();
73  virtual std::vector<float> voxelSize() const;
74  virtual void setVoxelSize( const std::vector<float> & vs );
75  virtual void setBucketChanged();
76  virtual bool hasBucketChanged() const;
77  void setBucket( const aims::BucketMap<Void>& theBuck );
79  aims::BucketMap<Void> & bucket() { return( *_bucket ); }
80  const aims::BucketMap<Void> & bucket() const { return( *_bucket ); }
82 
83  size_t createFacet( size_t t = 0 ) const;
84  virtual bool Is2DObject();
85  virtual bool Is3DObject() { return true; }
86  const AimsSurface<4, Void>* surface( const ViewState & ) const;
88  void freeSurface();
89  virtual unsigned glNumVertex( const ViewState & ) const;
90  virtual const GLfloat* glVertexArray( const ViewState & ) const;
91  virtual const GLfloat* glNormalArray( const ViewState & ) const;
92  virtual unsigned glNumPolygon( const ViewState & ) const;
93  virtual const GLuint* glPolygonArray( const ViewState & ) const;
94  virtual unsigned glPolygonSize( const ViewState & ) const { return 4; }
95  bool allow2DRendering() const;
97  void setAllow2DRendering( bool x );
98 
99  virtual bool empty() const;
100  void insert( const aims::BucketMap<Void> & region );
101  void erase( const aims::BucketMap<Void> & region );
104  AimsSurface<4,Void> *surf, bool glonfly=false ) const;
105  void meshSubBucket( const std::vector<std::pair<
108  AimsSurface<4,Void> *surf, bool glonfly=false ) const;
109 
110  virtual AObject* objectAt( const std::vector<float> & pos, float tol = 0 );
111 
112  virtual bool loadable() const { return( true ); }
113  virtual bool savable() const { return( true ); }
114  virtual bool save( const std::string & filename );
115  virtual bool reload( const std::string & filename );
116 
117  virtual void setInternalsChanged();
119  virtual const carto::GenericObject* attributed() const;
120 
121  virtual Tree* optionTree() const;
122  static Tree* _optionTree;
123 
124  protected:
126  mutable int _minX,_minY,_minZ,_minT;
127  mutable int _maxX,_maxY,_maxZ,_maxT;
128 
129  void freeSurface() const;
130  virtual void setBucketChanged() const;
131  virtual std::string viewStateID( glPart part, const ViewState & ) const;
132 
133  private:
134  struct Private;
135  Private *d;
136 
137  const AimsSurface<4,Void>* meshPlane( const SliceViewState & ) const;
138  };
139 
140  inline void
143  AimsSurface<4,Void> *surf, bool glonfly ) const
144  {
146  typedef std::pair<biter, biter> piter;
147  std::vector<piter> ivec;
148  ivec.push_back( piter( ibegin, iend ) );
149  meshSubBucket( ivec, surf, glonfly );
150  }
151 
152 }
153 
154 
155 #endif
Base Anatomist object (abstract)
Definition: Object.h:96
Bucket class.
Definition: Bucket.h:56
virtual unsigned glPolygonSize(const ViewState &) const
number of vertices per polygon (default = 3: triangles)
Definition: Bucket.h:94
virtual const GLfloat * glNormalArray(const ViewState &) const
normals array (optional), default=0 (no normals, flat shaded faces)
float MaxT() const
Obsolete, deprecated.
Definition: Bucket.h:62
bool allow2DRendering() const
void setSurface(AimsSurfaceFacet *surf)
virtual carto::GenericObject * attributed()
virtual bool loadable() const
Definition: Bucket.h:112
Bucket(const char *filename=NULL)
virtual unsigned glNumVertex(const ViewState &) const
virtual void setGeomExtrema()
Scans the object internals and determines its geometry extrema.
virtual bool Is3DObject()
Definition: Bucket.h:85
void freeSurface() const
virtual void setSubBucketGeomExtrema(const Point3df &pmin=Point3df(0., 0., 0.), const Point3df &pmax=Point3df(0., 0., 0.))
const AimsSurface< 4, Void > * surface(const ViewState &) const
void insert(const aims::BucketMap< Void > &region)
virtual bool savable() const
Definition: Bucket.h:113
void setBucket(const aims::BucketMap< Void > &theBuck)
virtual unsigned glNumPolygon(const ViewState &) const
virtual std::string viewStateID(glPart part, const ViewState &) const
Makes a unique ID from a viewstate.
virtual bool boundingBox2D(std::vector< float > &bmin, std::vector< float > &bmax) const
Bounding box in 2D views mode.
Definition: Bucket.h:65
virtual Tree * optionTree() const
Menu tree for new options, see object/optionMatcher.h.
virtual bool boundingBox(std::vector< float > &bmin, std::vector< float > &bmax) const
Fills bmin and bmax with the N-D bounding box extrema in the object's referential coordinates.
float MinT() const
Obsolete, deprecated.
Definition: Bucket.h:61
virtual void setInternalsChanged()
Notifies some underlying lower-level objects have changed.
carto::rc_ptr< aims::BucketMap< Void > > _bucket
Definition: Bucket.h:125
virtual void setBucketChanged() const
void meshSubBucket(const std::vector< std::pair< aims::BucketMap< Void >::Bucket::const_iterator, aims::BucketMap< Void >::Bucket::const_iterator > > &iv, AimsSurface< 4, Void > *surf, bool glonfly=false) const
virtual std::vector< float > voxelSize() const
Returns at least 4 sizes. For 3D objects, returns (1, 1, 1, 1)
virtual const GLfloat * glVertexArray(const ViewState &) const
void setAllow2DRendering(bool x)
when false, a bucket will always appear 3D
virtual bool empty() const
aims::BucketMap< Void > & bucket()
Definition: Bucket.h:79
void setBucket(carto::rc_ptr< aims::BucketMap< Void > > theBuck)
virtual void setBucketChanged()
size_t createFacet(size_t t=0) const
virtual const carto::GenericObject * attributed() const
virtual bool Is2DObject()
virtual const GLuint * glPolygonArray(const ViewState &) const
virtual AObject * objectAt(const std::vector< float > &pos, float tol=0)
Find the object (sub-object) at given postion with a tolerence.
static Tree * _optionTree
Definition: Bucket.h:122
virtual void setVoxelSize(const std::vector< float > &vs)
carto::rc_ptr< aims::BucketMap< Void > > rcBucket()
Definition: Bucket.h:81
virtual bool reload(const std::string &filename)
Re-reads objects from disk.
void erase(const aims::BucketMap< Void > &region)
virtual bool hasBucketChanged() const
virtual bool save(const std::string &filename)
void meshSubBucket(aims::BucketMap< Void >::Bucket::const_iterator ibegin, aims::BucketMap< Void >::Bucket::const_iterator iend, AimsSurface< 4, Void > *surf, bool glonfly=false) const
Definition: Bucket.h:141
const aims::BucketMap< Void > & bucket() const
Definition: Bucket.h:80
glPart
GL object parts, each driving a GL list.
Definition: glcomponent.h:114
Attributed objects wrapper.
Definition: pythonAObject.h:46
Specialization for a sliceable object.
Definition: viewstate.h:99
ViewState holds information about how a view wants to see an object.
Definition: viewstate.h:67
AIMSDATA_API AimsTimeSurface< 4, Void > AimsSurfaceFacet