anatomist  5.0.5
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 
95  void setMethod( Method method );
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 
115  const_iterator firstVolume() const;
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( unsigned tex = 0 ) const;
126  virtual GLComponent* glTexture( unsigned tex = 0 );
127  virtual unsigned glNumTextures() const;
128  virtual unsigned glNumTextures( const ViewState & ) const;
129  virtual unsigned glDimTex( const ViewState & s, unsigned tex = 0 ) const;
130  virtual const AObjectPalette* glPalette( unsigned tex = 0 ) const;
131  virtual glTextureMode glTexMode( unsigned tex = 0 ) const;
132  virtual void glSetTexMode( glTextureMode mode, unsigned tex = 0 );
133  virtual float glTexRate( unsigned tex = 0 ) const;
134  virtual void glSetTexRate( float rate, unsigned tex = 0 );
135  virtual glTextureFiltering glTexFiltering( unsigned tex = 0 ) const;
136  virtual void glSetTexFiltering( glTextureFiltering x, unsigned tex = 0 );
137  virtual glAutoTexturingMode glAutoTexMode( unsigned tex = 0 ) const;
138  virtual void glSetAutoTexMode( glAutoTexturingMode mode,
139  unsigned tex = 0 );
140  virtual const float *glAutoTexParams( unsigned coord = 0,
141  unsigned tex = 0 ) const;
142  virtual void glSetAutoTexParams( const float* params, unsigned coord = 0,
143  unsigned tex = 0 );
144 
145  //virtual bool glTexImageChanged( unsigned tex = 0 ) const;
146  virtual void glSetTexImageChanged( bool x = true, unsigned tex = 0 ) const;
147  //virtual bool glTexEnvChanged( unsigned tex = 0 ) const;
148  virtual void glSetTexEnvChanged( bool x = true, unsigned tex = 0 ) const;
149  virtual GLPrimitives glTexNameGLL( const ViewState &,
150  unsigned tex = 0 ) const;
151  virtual GLPrimitives glTexEnvGLL( const ViewState &,
152  unsigned tex = 0 ) const;
153  const TexExtrema & glTexExtrema( unsigned tex = 0 ) const;
154  TexExtrema & glTexExtrema( unsigned tex = 0 );
155 
156  virtual void glGarbageCollector( int nkept = -1 );
157 
158  protected:
160  void refreshVTexture( const ViewState & ) const;
161  const AObject* volume( unsigned n ) const;
162  virtual std::string viewStateID( glPart part, const ViewState & ) const;
163 
165  unsigned _nsurf;
168  float _depth;
169  float _step;
170 
171  private:
172  struct Private;
173 
175  virtual void insert( AObject* o ) { GLObjectVector::insert( o ); }
176  virtual void insert( AObject* o, int pos )
177  { GLObjectVector::insert( o, pos ); }
178  virtual void insert( const carto::shared_ptr<AObject> & o,
179  int pos = -1 )
180  { GLObjectVector::insert( o, pos ); }
182  virtual void erase( iterator & i ) { GLObjectVector::erase( i ); }
183 
184  void refreshVTextureWithPointToPoint( const ViewState &,
185  unsigned tex ) const;
186  void refreshVTextureWithLineToPoint( const ViewState &,
187  unsigned tex ) const;
188  void refreshVTextureWithInsideLineToPoint( const ViewState &,
189  unsigned tex ) const;
190  void refreshVTextureWithOutsideLineToPoint( const ViewState &,
191  unsigned tex ) const;
192  void refreshVTextureWithSphereToPoint( const ViewState &,
193  unsigned tex ) const;
197  void refreshLineTexture( float start_depth, float stop_depth,
198  const ViewState &, unsigned tex ) const;
199 
200  float enhancedMean( float value, int nbElemCorrected, int nbElem ) const;
201 
202  Private *d;
203  };
204 
205 
206  //
207 
208 
209  inline bool Fusion3D::CanRemove( AObject * )
210  {
211  return(false);
212  }
213 
214 
215 
216  inline float Fusion3D::enhancedMean( float value,
217  int nbElemCorrected,
218  int nbElem ) const
219  {
220  if( nbElemCorrected == 0 )
221  return(0.0);
222  return( value / ((float) nbElemCorrected)
223  * ( 1. - 0.7 * ((float) nbElemCorrected) / ((float) nbElem) ) );
224  }
225 
226 }
227 
228 
229 #endif
Fusion3D(const std::vector< AObject *> &obj)
virtual unsigned glNumTextures() const
void setSubMethod(SubMethod submethod)
ViewState holds information about how a view wants to see an object.
Definition: viewstate.h:66
void setStep(float step)
Base Anatomist object (abstract)
Definition: Object.h:95
Multi-object generic iterator.
Definition: MObject.h:114
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...
SubMethod
3D mapping sub-methods
Definition: Fusion3D.h:70
SubMethod subMethod()
Definition: Fusion3D.h:99
virtual const float * glAutoTexParams(unsigned coord=0, unsigned tex=0) const
std::list< carto::rc_ptr< GLItem > > PrimList
Definition: Object.h:72
virtual bool Is3DObject()
Can be display in 3D windows.
Definition: Fusion3D.h:90
virtual int MType() const
Precise type of multi-object.
Definition: Fusion3D.h:84
virtual void glClearHasChangedFlags() const
unsigned _nsurf
number of 3D objects
Definition: Fusion3D.h:165
This class can be subclassed to represent an object that the programmer wants to have observed...
Definition: Observable.h:67
virtual void erase(iterator &)
virtual glTextureFiltering glTexFiltering(unsigned tex=0) const
virtual void insert(AObject *)
virtual glTextureMode glTexMode(unsigned tex=0) const
virtual GLPrimitives glTexNameGLL(const ViewState &, unsigned tex=0) const
virtual void glSetTexFiltering(glTextureFiltering x, unsigned tex=0)
Anatomist object which contains a volume of functional data (fMRI, PET...) and a surface of the MRI a...
Definition: Fusion3D.h:54
virtual void glSetAutoTexMode(glAutoTexturingMode mode, unsigned tex=0)
virtual void glSetTexMode(glTextureMode mode, unsigned tex=0)
virtual void glSetTexImageChanged(bool x=true, unsigned tex=0) const
virtual Tree * optionTree() const
Menu tree for new options, see object/optionMatcher.h.
Method method()
Definition: Fusion3D.h:96
Method
3D mapping methods
Definition: Fusion3D.h:58
virtual bool CanRemove(AObject *obj)
Definition: Fusion3D.h:209
virtual void glGarbageCollector(int nkept=-1)
Frees unused display lists.
virtual void update(const Observable *observable, void *arg)
This class is an Observer of each of the AObject it groups.
virtual const AObjectPalette * glPalette(unsigned tex=0) const
virtual unsigned glDimTex(const ViewState &s, unsigned tex=0) const
texture dimension (1, 2 [or 3])
virtual float glTexRate(unsigned tex=0) const
iterator firstVolume()
void setMethod(Method method)
virtual GLPrimitives glTexEnvGLL(const ViewState &, unsigned tex=0) const
virtual bool hasTexture() const
Textured objects have values associated with a geometric coordinate.
Definition: Fusion3D.h:124
SubMethod _submethod
Definition: Fusion3D.h:167
std::list< RefGLItem > GLPrimitives
Definition: primitive.h:156
Base class for all OpenGL objects in Anatomist (with OpenGL display lists)
Definition: glcomponent.h:66
static Tree * _optionTree
Definition: Fusion3D.h:112
void refreshVTexture(const ViewState &) const
Refresh texture values.
glPart
GL object parts, each driving a GL list.
Definition: glcomponent.h:113
virtual bool render(PrimList &, const ViewState &)
rendering (generally 2D or 3D using OpenGL).
const TexExtrema & glTexExtrema(unsigned tex=0) const
virtual unsigned glTexCoordSize(const ViewState &, unsigned) const
texture array size (must be >= numVertex to work), defalut=0
virtual const GLComponent * glTexture(unsigned tex=0) const
virtual const GLfloat * glTexCoordArray(const ViewState &, unsigned) const
virtual std::string viewStateID(glPart part, const ViewState &) const
Makes a unique ID from a viewstate.
void setDepth(float depth)
virtual void glSetTexEnvChanged(bool x=true, unsigned tex=0) const
virtual glAutoTexturingMode glAutoTexMode(unsigned tex=0) const
virtual bool Is2DObject()
Can be display in 2D windows.
virtual void glSetAutoTexParams(const float *params, unsigned coord=0, unsigned tex=0)
const AObject * volume(unsigned n) const
virtual void glSetTexRate(float rate, unsigned tex=0)