anatomist  5.1.2
3D neuroimaging data viewer
Volume.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 #ifndef ANA_VOLUME_VOLUME_H
35 #define ANA_VOLUME_VOLUME_H
36 
40 #include <aims/rgb/rgb.h>
41 
42 
43 namespace anatomist
44 {
45 
46  class Referential;
47  class Transformation;
48  class Geometry;
49 
53  : public SliceableObject, public PythonAObject
54  {
55  public:
57  virtual ~AVolumeBase();
58 
59  virtual void setShaderParameters(const Shader &shader, const ViewState & state) const;
60  };
61 
63  template <typename T>
64  class AVolume : public AVolumeBase
65  {
66  public:
67  AVolume( const std::string & filename = "" );
69  virtual ~AVolume();
70 
71  virtual AObject* clone( bool shallow = true );
72 
73  float MinT() const { return 0.0; }
74  float MaxT() const { return float(_volume->getSizeT()-1); }
75 
76  virtual bool boundingBox2D( std::vector<float> & bmin,
77  std::vector<float> & bmax ) const;
78  virtual bool boundingBox( std::vector<float> & bmin,
79  std::vector<float> & bmax ) const;
80 
81  void SetExtrema();
82  void adjustPalette();
83 
84  carto::rc_ptr<carto::Volume<T> > volume() { return _volume; }
85  const carto::rc_ptr<carto::Volume<T> > volume() const { return _volume; }
86  virtual void setVolume( carto::rc_ptr<carto::Volume<T> > vol );
87  T & operator () ( size_t x=0, size_t y=0, size_t z=0, size_t t=0 )
88  { return (*_volume)( x, y , z ,t ); }
89  const T & operator () ( size_t x=0, size_t y=0, size_t z=0,
90  size_t t=0 ) const
91  { return (*_volume)( x, y , z ,t ); }
92 
94  virtual bool update2DTexture( AImage &, const Point3df & posbase,
95  const SliceViewState &,
96  unsigned tex = 0 ) const;
97  virtual std::vector<float> voxelSize() const;
98  virtual void setVoxelSize( const std::vector<float> & vs );
100  float GetValue(Point3df pos,float time, Referential *winref,
101  Geometry *wingeom);
103  bool Is2DObject() { return(true); }
104  bool textured2D() const { return( true ); }
106  bool Is3DObject() { return(false); }
107  virtual bool isTransparent() const;
109  virtual AObject* objectAt( const std::vector<float> & pos, float tol = 0 );
110 
111  virtual bool hasTexture() const { return( true ); }
112  virtual unsigned dimTexture() const { return( 1 ); }
113  virtual float mixedTexValue( const std::vector<float> & pos ) const;
114  virtual std::vector<float>
115  texValues( const std::vector<float> & pos ) const;
116 
118  virtual const carto::GenericObject* attributed() const;
119 
120  virtual bool loadable() const { return( true ); }
121  virtual bool savable() const { return( true ); }
122  virtual bool reload( const std::string & filename );
123  virtual bool save( const std::string & filename );
124  virtual std::string objectFullTypeName(void) const;
125 
127  virtual bool printTalairachCoord( const Point3df & pos,
128  const Referential* ) const;
129  virtual void setInternalsChanged();
130 
131  protected:
133  void updateSlice( AImage & image, const Point3df & p0,
134  const std::vector<float> & time,
135  const Transformation* tra, const Point3df & inc,
136  const Point3df & offset, const Geometry* wingeom ) const;
138  void updateAxial( AImage *ximage, const Point3df & p0,
139  const std::vector<float> & time ) const;
141  void updateCoronal( AImage *ximage, const Point3df & p0,
142  const std::vector<float> & time ) const;
144  void updateSagittal( AImage *ximage, const Point3df & p0,
145  const std::vector<float> & time ) const;
146 
147  private:
148  struct PrivateData;
149  PrivateData *d;
151  };
152 
153 
154  template<class T>
155  inline AObject*
156  anatomist::AVolume<T>::objectAt( const std::vector<float> &, float )
157  { return 0; }
158 
159 }
160 
161 
162 #endif
Base Anatomist object (abstract)
Definition: Object.h:96
VolumeBase object : use for generic dynamic_cast of all AVolume<T>, thus the visitor design pattern c...
Definition: Volume.h:54
virtual void setShaderParameters(const Shader &shader, const ViewState &state) const
Volume object.
Definition: Volume.h:65
virtual float mixedTexValue(const std::vector< float > &pos) const
Same as above except that coordinates are not transformed but taken in object coordinates system.
bool textured2D() const
true if 2D rendering uses a textured plane (not a full openGL object)
Definition: Volume.h:104
bool Is3DObject()
Can be display in 3D windows.
Definition: Volume.h:106
const carto::rc_ptr< carto::Volume< T > > volume() const
Definition: Volume.h:85
virtual unsigned dimTexture() const
Number of texture values for a point.
Definition: Volume.h:112
bool Is2DObject()
Can be display in 2D windows.
Definition: Volume.h:103
void updateSagittal(AImage *ximage, const Point3df &p0, const std::vector< float > &time) const
Optimized texture filling routine (no transformation)
virtual bool isTransparent() const
float GetValue(Point3df pos, float time, Referential *winref, Geometry *wingeom)
Retourne la valeur d'un voxel du volume.
AVolume(carto::rc_ptr< carto::Volume< T > >)
void adjustPalette()
Creates or updates object palette according to object values (if needed)
float MaxT() const
Obsolete, deprecated.
Definition: Volume.h:74
virtual void setInternalsChanged()
Notifies some underlying lower-level objects have changed.
virtual void setVolume(carto::rc_ptr< carto::Volume< T > > vol)
virtual std::vector< float > texValues(const std::vector< float > &pos) const
virtual bool hasTexture() const
Textured objects have values associated with a geometric coordinate.
Definition: Volume.h:111
void updateSlice(AImage &image, const Point3df &p0, const std::vector< float > &time, const Transformation *tra, const Point3df &inc, const Point3df &offset, const Geometry *wingeom) const
Generic texture filling routine for any transformation.
virtual std::string objectFullTypeName(void) const
Get Object Full Type Name.
carto::rc_ptr< carto::Volume< T > > volume()
Definition: Volume.h:84
virtual bool reload(const std::string &filename)
Re-reads objects from disk.
void updateAxial(AImage *ximage, const Point3df &p0, const std::vector< float > &time) const
Optimized texture filling routine (no transformation)
virtual bool printTalairachCoord(const Point3df &pos, const Referential *) const
should be replaced by a real referential
virtual bool boundingBox2D(std::vector< float > &bmin, std::vector< float > &bmax) const
Bounding box in 2D views mode.
float MinT() const
Obsolete, deprecated.
Definition: Volume.h:73
AVolume(const std::string &filename="")
T & operator()(size_t x=0, size_t y=0, size_t z=0, size_t t=0)
Definition: Volume.h:87
virtual carto::GenericObject * attributed()
void SetExtrema()
Scans the object internals and determines its (texture) extrema values.
virtual AObject * objectAt(const std::vector< float > &pos, float tol=0)
Not selectable: always returns Null.
Definition: Volume.h:156
virtual bool savable() const
Definition: Volume.h:121
virtual std::vector< float > voxelSize() const
Returns at least 4 sizes. For 3D objects, returns (1, 1, 1, 1)
void updateCoronal(AImage *ximage, const Point3df &p0, const std::vector< float > &time) const
Optimized texture filling routine (no transformation)
virtual bool update2DTexture(AImage &, const Point3df &posbase, const SliceViewState &, unsigned tex=0) const
new API
virtual AObject * clone(bool shallow=true)
Makes a copy of the object, with a duplicated object structure, palette and material,...
virtual bool loadable() const
Definition: Volume.h:120
virtual void setVoxelSize(const std::vector< float > &vs)
virtual bool save(const std::string &filename)
virtual const carto::GenericObject * attributed() const
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.
Attributed objects wrapper.
Definition: pythonAObject.h:46
Referential: marker for transformations, with an associated color.
Definition: Referential.h:55
AObject-inherited version of Sliceable.
Definition: sliceable.h:112
Transformation between two referentials.
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