anatomist  5.0.5
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 
39 #include <aims/data/data.h>
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:
56  AVolumeBase();
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 = "" );
68  AVolume( const AimsData<T> & );
71  virtual ~AVolume();
72 
73  virtual AObject* clone( bool shallow = true );
74 
75  float MinT() const { return 0.0; }
76  float MaxT() const { return float(_volume->getSizeT()-1); }
77 
78  virtual bool boundingBox2D( std::vector<float> & bmin,
79  std::vector<float> & bmax ) const;
80  virtual bool boundingBox( std::vector<float> & bmin,
81  std::vector<float> & bmax ) const;
82 
83  void SetExtrema();
84  void adjustPalette();
85 
86  carto::rc_ptr<carto::Volume<T> > volume() { return _volume; }
88  { return carto::rc_ptr<AimsData<T> >( new AimsData<T>(_volume) ); }
89  const carto::rc_ptr<carto::Volume<T> > volume() const { return _volume; }
91  { return carto::rc_ptr<AimsData<T> >( new AimsData<T>( _volume ) ); }
92  void setVolume( carto::rc_ptr<AimsData<T> > vol );
93  virtual void setVolume( carto::rc_ptr<carto::Volume<T> > vol );
94  T & operator () ( size_t x=0, size_t y=0, size_t z=0, size_t t=0 )
95  { return (*_volume)( x, y , z ,t ); }
96  const T & operator () ( size_t x=0, size_t y=0, size_t z=0,
97  size_t t=0 ) const
98  { return (*_volume)( x, y , z ,t ); }
99 
101  virtual bool update2DTexture( AImage &, const Point3df & posbase,
102  const SliceViewState &,
103  unsigned tex = 0 ) const;
104  virtual std::vector<float> voxelSize() const;
105  virtual void setVoxelSize( const std::vector<float> & vs );
107  float GetValue(Point3df pos,float time, Referential *winref,
108  Geometry *wingeom);
110  bool Is2DObject() { return(true); }
111  bool textured2D() const { return( true ); }
113  bool Is3DObject() { return(false); }
114  virtual bool isTransparent() const;
116  virtual AObject* objectAt( const std::vector<float> & pos, float tol = 0 );
117 
118  virtual bool hasTexture() const { return( true ); }
119  virtual unsigned dimTexture() const { return( 1 ); }
120  virtual float mixedTexValue( const std::vector<float> & pos ) const;
121  virtual std::vector<float>
122  texValues( const std::vector<float> & pos ) const;
123 
124  virtual carto::GenericObject* attributed();
125  virtual const carto::GenericObject* attributed() const;
126 
127  virtual bool loadable() const { return( true ); }
128  virtual bool savable() const { return( true ); }
129  virtual bool reload( const std::string & filename );
130  virtual bool save( const std::string & filename );
131  virtual std::string objectFullTypeName(void) const;
132 
134  virtual bool printTalairachCoord( const Point3df & pos,
135  const Referential* ) const;
136  virtual void setInternalsChanged();
137 
138  protected:
140  void updateSlice( AImage & image, const Point3df & p0,
141  const std::vector<float> & time,
142  const Transformation* tra, const Point3df & inc,
143  const Point3df & offset, const Geometry* wingeom ) const;
145  void updateAxial( AImage *ximage, const Point3df & p0,
146  const std::vector<float> & time ) const;
148  void updateCoronal( AImage *ximage, const Point3df & p0,
149  const std::vector<float> & time ) const;
151  void updateSagittal( AImage *ximage, const Point3df & p0,
152  const std::vector<float> & time ) const;
153 
154  private:
155  struct PrivateData;
156  PrivateData *d;
158  };
159 
160 
161  template<class T>
162  inline AObject*
163  anatomist::AVolume<T>::objectAt( const std::vector<float> &, float )
164  { return 0; }
165 
166 }
167 
168 
169 #endif
ViewState holds information about how a view wants to see an object.
Definition: viewstate.h:66
float MaxT() const
Obsolete, deprecated.
Definition: Volume.h:76
Base Anatomist object (abstract)
Definition: Object.h:95
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&#39;s referential coordinates...
virtual bool save(const std::string &filename)
carto::rc_ptr< carto::Volume< T > > volume()
Definition: Volume.h:86
virtual bool update2DTexture(AImage &, const Point3df &posbase, const SliceViewState &, unsigned tex=0) const
this function must be overloaded to actually fill the slice image
carto::rc_ptr< AimsData< T > > aimsvolume()
Definition: Volume.h:87
virtual void adjustPalette()
Creates or updates object palette according to object values (if needed)
Definition: Object.h:221
float MinT() const
Obsolete, deprecated.
Definition: Volume.h:75
virtual void setInternalsChanged()
Notifies some underlying lower-level objects have changed.
virtual AObject * objectAt(const std::vector< float > &pos, float tol=0)
Not selectable: always returns Null.
Definition: Volume.h:163
Attributed objects wrapper.
Definition: pythonAObject.h:45
virtual bool loadable() const
Definition: Volume.h:127
AObject-inherited version of Sliceable.
Definition: sliceable.h:111
virtual bool hasTexture() const
Textured objects have values associated with a geometric coordinate.
Definition: Volume.h:118
virtual carto::GenericObject * attributed()=0
virtual float mixedTexValue(const std::vector< float > &pos, const Referential *orgRef) const
Gets a "mixed" texture value at a given space / time location.
VolumeBase object : use for generic dynamic_cast of all AVolume<T>, thus the visitor design pattern c...
Definition: Volume.h:52
bool Is2DObject()
Can be display in 2D windows.
Definition: Volume.h:110
virtual void setShaderParameters(const Shader &shader, const ViewState &state) const
bool Is3DObject()
Can be display in 3D windows.
Definition: Volume.h:113
virtual std::vector< float > voxelSize() const
Returns at least 4 sizes. For 3D objects, returns (1, 1, 1, 1)
virtual bool printTalairachCoord(const Point3df &, const Referential *) const
should be replaced by a real referential
Definition: Object.h:371
virtual bool savable() const
Definition: Volume.h:128
Volume object.
Definition: Volume.h:64
virtual bool boundingBox2D(std::vector< float > &bmin, std::vector< float > &bmax) const
Bounding box in 2D views mode.
virtual std::vector< float > texValues(const std::vector< float > &pos, const Referential *orgRef) const
Gets the array of texture values at a given location.
virtual AObject * objectAt(const std::vector< float > &pos, float tol=0)
Find the object (sub-object) at given postion with a tolerence.
virtual unsigned dimTexture() const
Number of texture values for a point.
Definition: Volume.h:119
virtual void SetExtrema()
Scans the object internals and determines its (texture) extrema values.
Definition: Object.h:313
virtual bool isTransparent() const
Referential: marker for transformations, with an associated color.
Definition: Referential.h:54
Transformation between two referentials.
virtual bool reload(const std::string &filename)
Re-reads objects from disk.
bool textured2D() const
true if 2D rendering uses a textured plane (not a full openGL object)
Definition: Volume.h:111
const carto::rc_ptr< carto::Volume< T > > volume() const
Definition: Volume.h:89
virtual AObject * clone(bool shallow=true)
Makes a copy of the object, with a duplicated object structure, palette and material, but which may share the underlying low-level data object (Aims object).
const carto::rc_ptr< AimsData< T > > aimsvolume() const
Definition: Volume.h:90
Specialization for a sliceable object.
Definition: viewstate.h:98
virtual std::string objectFullTypeName(void) const
Get Object Full Type Name.
Definition: Object.h:366
virtual void setVoxelSize(const std::vector< float > &)
Definition: Object.h:213