34 #ifndef ANA_SURFACE_SURFACE_D_H 
   35 #define ANA_SURFACE_SURFACE_D_H 
   49 #include <qtranslator.h> 
   54   template <
int D> 
inline 
   68         carto::Object cnorm = mat->getProperty( 
"shader_color_normals" );
 
   69         if( cnorm->getScalar() )
 
   72           if( nisd->getScalar() )
 
   74             std::cout << 
"normal_is_direction ON\n";
 
   75             std::vector<AimsVector<float, 3> > *dirs
 
   77             std::cout << 
"generate dirs: " << dirs->size() << std::endl;
 
   98     : 
AGLObject(), _surface( 0 ), _planar( false )
 
  153     unsigned    t = (unsigned) ( time / voxelSize()[3] );
 
  156     if( is == _surface->end() )
 
  158       if( is != _surface->begin() )
 
  161     return( &(*is).second );
 
  171     unsigned    t = (unsigned) ( time / voxelSize()[3] );
 
  173     if( _surface->empty() )
 
  174       return( &(*_surface)[t] );
 
  178     if( is == _surface->end() )
 
  180       if( is != _surface->begin() )
 
  183     return( &(*is).second );
 
  194     const std::vector<Point3df> & 
norm = _surface->normal();
 
  195     std::vector<Point3df>::size_type i, n = 
norm.size();
 
  196     if( n < _surface->vertex().size() )
 
  197       _surface->updateNormals();
 
  201     const float eps = 1e-5;
 
  204       if( fabs( 
norm[i][0] - nref[0] ) > eps 
 
  205           || fabs( 
norm[i][1] - nref[1] ) > eps 
 
  206           || fabs( 
norm[i][2] - nref[2] ) > eps )
 
  218     if( !_surface || _surface->size() == 0 )
 
  220     return( voxelSize()[3] * (*_surface->rbegin()).first );
 
  227     if( !_surface || _surface->size() == 0 )
 
  229     return( voxelSize()[3] * (*_surface->begin()).first );
 
  236     bool hasold = _surface.get() != 0;
 
  240     _completeMeshDirections( *surf );
 
  241     if( D == 2 && !_surface->normal().empty() )
 
  249       carto::Object omat = _surface->header().getProperty( 
"material" );
 
  257     glSetChanged( glGEOMETRY );
 
  267     bool hasold = _surface.get() != 0;
 
  269     _surface.reset( surf );
 
  271     _completeMeshDirections( *surf );
 
  272     if( D == 2 && !_surface->normal().empty() )
 
  280       carto::Object omat = _surface->header().getProperty( 
"material" );
 
  288     glSetChanged( glGEOMETRY );
 
  302     return surf->
vertex().size();
 
  313     return &surf->
vertex()[0][0];
 
  324     return surf->
normal().size();
 
  335     const std::vector<Point3df> & n = surf->
normal();
 
  336     if( n.size() < surf->
vertex().size() )
 
  349     return( (GLuint *) &surf->
polygon()[0][0] );
 
  360     return( surf->
polygon().size() );
 
  367     static Tree*        _optionTree = 0;
 
  372         _optionTree = 
new Tree( 
true, 
"option tree" );
 
  373         t = 
new Tree( 
true, QT_TRANSLATE_NOOP( 
"QSelectMenu", 
"File" ) );
 
  375         t2 = 
new Tree( 
true, QT_TRANSLATE_NOOP( 
"QSelectMenu", 
"Reload" ) );
 
  378         t2 = 
new Tree( 
true, QT_TRANSLATE_NOOP( 
"QSelectMenu", 
"Save" ) );
 
  381         t2 = 
new Tree( 
true, QT_TRANSLATE_NOOP( 
"QSelectMenu",
 
  386                        QT_TRANSLATE_NOOP( 
"QSelectMenu",
 
  387                                           "Create generated 1D texture" ) );
 
  391                        QT_TRANSLATE_NOOP( 
"QSelectMenu",
 
  392                                           "Create generated 2D texture" ) );
 
  396         t = 
new Tree( 
true, QT_TRANSLATE_NOOP( 
"QSelectMenu", 
"Color" ) );
 
  398         t2 = 
new Tree( 
true, QT_TRANSLATE_NOOP( 
"QSelectMenu", 
"Material" ) );
 
  401         t2 = 
new Tree( 
true, QT_TRANSLATE_NOOP( 
"QSelectMenu", 
"Rendering" ) );
 
  404         t = 
new Tree( 
true, QT_TRANSLATE_NOOP( 
"QSelectMenu",
 
  407         t2 = 
new Tree( 
true, QT_TRANSLATE_NOOP( 
"QSelectMenu", 
"Load" ) );
 
  410         t2 = 
new Tree( 
true, QT_TRANSLATE_NOOP( 
"QSelectMenu",
 
  411                        "Load information from file header") );
 
  414         t = 
new Tree( 
true, QT_TRANSLATE_NOOP( 
"QSelectMenu", 
"Geometry" ) );
 
  417                        QT_TRANSLATE_NOOP( 
"QSelectMenu",
 
  418                                           "Invert polygon orientation" ) );
 
  419         t2->setProperty( 
"callback", &invertPolygonsStatic );
 
  421         setObjectMenu( objectFullTypeName(),
 
  444         storeHeaderOptions();
 
  448     catch( std::exception & e )
 
  450         std::cerr << e.what() << 
"\nsave aborted\n";
 
  462     if( !reader.
read( *obj ) )
 
  473     std::set<AObject *>::const_iterator io, fo=obj.end();
 
  475     for( io=obj.begin(); io!=fo; ++io )
 
  484     glSetChanged( glGEOMETRY );
 
  486     notifyObservers( 
this );
 
  492                                  std::vector<float> & bmax )
 const 
  499     Point3df bminp = _surface->minimum();
 
  500     Point3df bmaxp = _surface->maximum();
 
  501     if( bminp == 
Point3df( 1e38, 1e38, 1e38 )
 
  502         && bmaxp == 
Point3df( -1e38, -1e38, -1e38) )
 
  515     if( _surface->empty() )
 
  522       float timestep = voxelSize()[3];
 
  523       bmin[3] = _surface->
begin()->first * timestep;
 
  524       bmax[3] = _surface->rbegin()->first * timestep;
 
  536     float ts = voxelSize()[3];
 
  537     unsigned    t = (unsigned) ( time / ts );
 
  540     if( is == _surface->end() )
 
  541       is = _surface->begin();
 
  542     return( is->first * ts );
 
  550     glSetChanged( glGEOMETRY, 
false );
 
  593     glSetChanged( glGEOMETRY );
 
const std::vector< Point3df > & normal() const
const std::vector< Point3df > & vertex() const
const std::vector< AimsVector< uint, D > > & polygon() const
std::map< int, AimsSurface< D, T > >::iterator iterator
const aims::PythonHeader & header() const
std::map< int, AimsSurface< D, T > >::const_iterator const_iterator
const std::vector< Point3df > & normal() const
void insert(BaseTree *child, int index=-1)
virtual bool read(T &obj, int border=0, const std::string *format=0, int frame=-1)
static void invertSurfacePolygons(AimsTimeSurface< D, T > &surface)
static std::vector< Point3df > * lineDirections(const AimsTimeSurface< 2, Void > &)
Base Anatomist object (abstract)
void setFileName(const std::string &filename)
virtual Tree * optionTree() const
Menu tree for new options, see object/optionMatcher.h.
virtual bool render(PrimList &, const ViewState &)
rendering (generally 2D or 3D using OpenGL).
int _type
Should be static in each object class.
virtual void notifyObservers(void *=0)
If this object has changed, as indicated by the hasChanged method, then notify all of its observers.
virtual bool render(anatomist::PrimList &primitiveList, const anatomist::ViewState &viewState)
rendering (generally 2D or 3D using OpenGL).
virtual unsigned glNumPolygon(const ViewState &) const
virtual bool glMakeBodyGLL(const anatomist::ViewState &viewState, const anatomist::GLList &glList) const
If you want to make a non-standard GL display list for the body geometry, overload this function to f...
virtual bool save(const std::string &filename)
virtual Tree * optionTree() const
Menu tree for new options, see object/optionMatcher.h.
void setSurface(carto::rc_ptr< TimeSurfaceType > surf)
virtual unsigned glPolygonSize(const ViewState &) const
number of vertices per polygon (default = 3: triangles)
const SurfaceType * surfaceOfTime(float time) const
virtual const GLfloat * glVertexArray(const ViewState &) const
virtual const GLuint * glPolygonArray(const ViewState &) const
ASurface(const char *filename="")
virtual carto::GenericObject * attributed()
virtual float MinT() const
Obsolete, deprecated.
virtual bool reload(const std::string &filename)
Re-reads objects from disk.
virtual unsigned glNumNormal(const ViewState &) const
virtual AObject * clone(bool shallow=true)
Makes a copy of the object, with a duplicated object structure, palette and material,...
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 float MaxT() const
Obsolete, deprecated.
virtual AObject * objectAt(const std::vector< float > &pos, float tol=0)
selection is disabled for surfaces
static void invertPolygonsStatic(const std::set< AObject * > &obj)
float actualTime(float time) const
virtual unsigned glNumVertex(const ViewState &) const
virtual void UpdateMinAndMax()
virtual const GLfloat * glNormalArray(const ViewState &) const
normals array (optional), default=0 (no normals, flat shaded faces)
virtual void setInternalsChanged()
Notifies some underlying lower-level objects have changed.
virtual bool glMakeBodyGLL(const ViewState &state, const GLList &gllist) const
If you want to make a non-standard GL display list for the body geometry, overload this function to f...
This class has to be rewritten, it's really really a shame.......
void set(const carto::GenericObject &)
@ NormalIsDirection
if set, the normal in a mesh is actually its wireframe direction, and interpreted as if the wireframe...
static void referentialLoad(const std::set< AObject * > &obj)
static void setAutomaticReferential(const std::set< AObject * > &obj)
static void renameObject(const std::set< AObject * > &obj)
static void fileReload(const std::set< AObject * > &obj)
static void generateTexture1D(const std::set< AObject * > &obj)
static void generateTexture2D(const std::set< AObject * > &obj)
static void colorMaterial(const std::set< AObject * > &obj)
static void saveStatic(const std::set< AObject * > &obj)
static void colorRendering(const std::set< AObject * > &obj)
virtual void notifyObservers(void *arg=0)
If this object has changed, as indicated by the hasChanged method, then notify all of its observers.
virtual bool getProperty(const std::string &, Object &) const
std::list< carto::rc_ptr< GLItem > > PrimList
ViewState holds information about how a view wants to see an object.
std::vector< float > timedims
AIMSDATA_API float norm(const Tensor &thing)