anatomist  5.1.2
3D neuroimaging data viewer
Fusion3D.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_MOBJECT_FUSION3D_H
36 #define ANA_MOBJECT_FUSION3D_H
37 
38 
40 #include <map>
41 #include <vector>
42 
43 
44 namespace anatomist
45 {
46 
47  class Referential;
48  class Geometry;
49 
50 
54  class Fusion3D : public GLObjectVector
55  {
56  public:
58  enum Method
59  {
67  };
68 
70  enum SubMethod
71  {
72  MAX,
73  MIN,
79  };
80 
81  Fusion3D( const std::vector<AObject *> & obj );
82  virtual ~Fusion3D();
83 
84  virtual int MType() const { return( AObject::FUSION3D ); }
85 
86  virtual bool CanRemove( AObject* obj );
87 
88  virtual bool render( PrimList &, const ViewState & );
89  virtual bool Is2DObject();
90  virtual bool Is3DObject() { return true; }
91 
92  virtual bool boundingBox( std::vector<float> & bmin,
93  std::vector<float> & bmax ) const;
94 
96  Method method() { return _method; }
97 
98  void setSubMethod( SubMethod submethod );
100 
101  void setDepth( float depth );
102  float depth() { return _depth; }
103  void setStep( float step );
104  float step() { return _step; }
105 
106  virtual void update( const Observable* observable, void* arg );
107 
108  virtual void glClearHasChangedFlags() const;
109 
110  virtual Tree* optionTree() const;
111 
112  static Tree* _optionTree;
113 
116 
117  /*
118  virtual bool glHasChanged( glPart ) const;
119  virtual void glSetChanged( glPart, bool = true );
120  */
121  virtual unsigned glTexCoordSize( const ViewState &, unsigned ) const;
122  virtual const GLfloat* glTexCoordArray( const ViewState &,
123  unsigned ) const;
124  virtual bool hasTexture() const { return true; }
125  virtual const GLComponent* glTexture( const ViewState & vs,
126  unsigned tex = 0 ) const;
127  virtual GLComponent* glTexture( const ViewState & vs, unsigned tex = 0 );
128  virtual unsigned glNumTextures() const;
129  virtual unsigned glNumTextures( const ViewState & ) const;
130  virtual unsigned glDimTex( const ViewState & s, unsigned tex = 0 ) const;
131  virtual const AObjectPalette* glPalette( unsigned tex = 0 ) const;
132  virtual glTextureMode glTexMode( unsigned tex = 0 ) const;
133  virtual void glSetTexMode( glTextureMode mode, unsigned tex = 0 );
134  virtual float glTexRate( unsigned tex = 0 ) const;
135  virtual void glSetTexRate( float rate, unsigned tex = 0 );
136  virtual glTextureFiltering glTexFiltering( unsigned tex = 0 ) const;
137  virtual void glSetTexFiltering( glTextureFiltering x, unsigned tex = 0 );
138  virtual glAutoTexturingMode glAutoTexMode( unsigned tex = 0 ) const;
140  unsigned tex = 0 );
141  virtual const float *glAutoTexParams( unsigned coord = 0,
142  unsigned tex = 0 ) const;
143  virtual void glSetAutoTexParams( const float* params, unsigned coord = 0,
144  unsigned tex = 0 );
145 
146  //virtual bool glTexImageChanged( unsigned tex = 0 ) const;
147  virtual void glSetTexImageChanged( bool x = true, unsigned tex = 0 ) const;
148  //virtual bool glTexEnvChanged( unsigned tex = 0 ) const;
149  virtual void glSetTexEnvChanged( bool x = true, unsigned tex = 0 ) const;
151  unsigned tex = 0 ) const;
152  virtual GLPrimitives glTexEnvGLL( const ViewState &,
153  unsigned tex = 0 ) const;
154  const TexExtrema & glTexExtrema( unsigned tex = 0 ) const;
155  TexExtrema & glTexExtrema( unsigned tex = 0 );
156 
157  virtual void glGarbageCollector( int nkept = -1 );
158 
159  protected:
161  void refreshVTexture( const ViewState & ) const;
162  const AObject* volume( unsigned n ) const;
163  virtual std::string viewStateID( glPart part, const ViewState & ) const;
164 
166  unsigned _nsurf;
169  float _depth;
170  float _step;
171 
172  private:
173  struct Private;
174 
176  virtual void insert( AObject* o ) { GLObjectVector::insert( o ); }
177  virtual void insert( AObject* o, int pos )
178  { GLObjectVector::insert( o, pos ); }
179  virtual void insert( const carto::shared_ptr<AObject> & o,
180  int pos = -1 )
181  { GLObjectVector::insert( o, pos ); }
183  virtual void erase( iterator & i ) { GLObjectVector::erase( i ); }
184 
185  void refreshVTextureWithPointToPoint( const ViewState &,
186  unsigned tex ) const;
187  void refreshVTextureWithLineToPoint( const ViewState &,
188  unsigned tex ) const;
189  void refreshVTextureWithInsideLineToPoint( const ViewState &,
190  unsigned tex ) const;
191  void refreshVTextureWithOutsideLineToPoint( const ViewState &,
192  unsigned tex ) const;
193  void refreshVTextureWithSphereToPoint( const ViewState &,
194  unsigned tex ) const;
198  void refreshLineTexture( float start_depth, float stop_depth,
199  const ViewState &, unsigned tex ) const;
200 
201  float enhancedMean( float value, int nbElemCorrected, int nbElem ) const;
202 
203  Private *d;
204  };
205 
206 
207  //
208 
209 
210  inline bool Fusion3D::CanRemove( AObject * )
211  {
212  return(false);
213  }
214 
215 
216 
217  inline float Fusion3D::enhancedMean( float value,
218  int nbElemCorrected,
219  int nbElem ) const
220  {
221  if( nbElemCorrected == 0 )
222  return(0.0);
223  return( value / ((float) nbElemCorrected)
224  * ( 1. - 0.7 * ((float) nbElemCorrected) / ((float) nbElem) ) );
225  }
226 
227 }
228 
229 
230 #endif
T * iterator
Multi-object generic iterator.
Definition: MObject.h:115
Base Anatomist object (abstract)
Definition: Object.h:96
Anatomist object which contains a volume of functional data (fMRI, PET...) and a surface of the MRI a...
Definition: Fusion3D.h:55
virtual void glSetAutoTexParams(const float *params, unsigned coord=0, unsigned tex=0)
void setMethod(Method method)
virtual glAutoTexturingMode glAutoTexMode(unsigned tex=0) const
SubMethod _submethod
Definition: Fusion3D.h:168
const AObject * volume(unsigned n) const
virtual GLPrimitives glTexNameGLL(const ViewState &, unsigned tex=0) const
virtual std::string viewStateID(glPart part, const ViewState &) const
Makes a unique ID from a viewstate.
virtual int MType() const
Precise type of multi-object.
Definition: Fusion3D.h:84
SubMethod subMethod()
Definition: Fusion3D.h:99
const_iterator firstVolume() const
virtual const GLComponent * glTexture(const ViewState &vs, unsigned tex=0) const
Method method()
Definition: Fusion3D.h:96
virtual bool Is3DObject()
Can be display in 3D windows.
Definition: Fusion3D.h:90
TexExtrema & glTexExtrema(unsigned tex=0)
virtual GLComponent * glTexture(const ViewState &vs, unsigned tex=0)
SubMethod
3D mapping sub-methods
Definition: Fusion3D.h:71
Fusion3D(const std::vector< AObject * > &obj)
static Tree * _optionTree
Definition: Fusion3D.h:112
virtual void glSetTexRate(float rate, unsigned tex=0)
virtual unsigned glDimTex(const ViewState &s, unsigned tex=0) const
texture dimension (1, 2 [or 3])
iterator firstVolume()
unsigned _nsurf
number of 3D objects
Definition: Fusion3D.h:166
void setDepth(float depth)
Method
3D mapping methods
Definition: Fusion3D.h:59
virtual void glSetTexFiltering(glTextureFiltering x, unsigned tex=0)
virtual bool CanRemove(AObject *obj)
Definition: Fusion3D.h:210
virtual Tree * optionTree() const
Menu tree for new options, see object/optionMatcher.h.
virtual void glSetAutoTexMode(glAutoTexturingMode mode, unsigned tex=0)
virtual float glTexRate(unsigned tex=0) const
virtual bool Is2DObject()
Can be display in 2D windows.
virtual unsigned glNumTextures() 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.
virtual const GLfloat * glTexCoordArray(const ViewState &, unsigned) const
virtual GLPrimitives glTexEnvGLL(const ViewState &, unsigned tex=0) const
virtual const float * glAutoTexParams(unsigned coord=0, unsigned tex=0) const
virtual unsigned glNumTextures(const ViewState &) const
virtual void glSetTexMode(glTextureMode mode, unsigned tex=0)
virtual void glSetTexEnvChanged(bool x=true, unsigned tex=0) const
virtual bool render(PrimList &, const ViewState &)
rendering (generally 2D or 3D using OpenGL).
virtual void update(const Observable *observable, void *arg)
This class is an Observer of each of the AObject it groups.
virtual void glSetTexImageChanged(bool x=true, unsigned tex=0) const
void setSubMethod(SubMethod submethod)
const TexExtrema & glTexExtrema(unsigned tex=0) const
void refreshVTexture(const ViewState &) const
Refresh texture values.
virtual glTextureMode glTexMode(unsigned tex=0) const
virtual void glGarbageCollector(int nkept=-1)
Frees unused display lists.
virtual unsigned glTexCoordSize(const ViewState &, unsigned) const
texture array size (must be >= numVertex to work), defalut=0
virtual glTextureFiltering glTexFiltering(unsigned tex=0) const
virtual void glClearHasChangedFlags() const
void setStep(float step)
virtual bool hasTexture() const
Textured objects have values associated with a geometric coordinate.
Definition: Fusion3D.h:124
virtual const AObjectPalette * glPalette(unsigned tex=0) const
Base class for all OpenGL objects in Anatomist (with OpenGL display lists)
Definition: glcomponent.h:67
glPart
GL object parts, each driving a GL list.
Definition: glcomponent.h:114
virtual void erase(iterator &)
virtual void insert(AObject *)
This class can be subclassed to represent an object that the programmer wants to have observed.
Definition: Observable.h:68
std::list< carto::rc_ptr< GLItem > > PrimList
Definition: Object.h:72
std::list< RefGLItem > GLPrimitives
Definition: primitive.h:156
ViewState holds information about how a view wants to see an object.
Definition: viewstate.h:67