SDS.h

Go to the documentation of this file.
00001 /* $Id: SDS.h,v 1.4 2002/11/20 15:22:15 cvs Exp $ */
00002 
00003 #ifndef __SDS_H
00004 #define __SDS_H
00005 
00006 #include <esg/Definitions.h>
00007 #include <esg/SceneGraphObject.h>
00008 #include <esg/List.h>
00009 
00010 /*
00011  * Generic class for spatial data structures.
00012  *
00013  * Spatial data structures can order only those objects that have
00014  * a geometry. Intangible objects are therefore stored unsorted in list.
00015  * They should be treated by only such iterator functions that
00016  * do not require geometry.
00017  *
00018  * Spatial data structures should never destroy objects it stores.
00019  */
00020 
00021 namespace esg {
00022 
00023 class OGSCENE_EXPORT Iterator;
00024 class OGSCENE_EXPORT InspectorSDS;
00025 
00026 class OGSCENE_EXPORT SDS {
00027     friend class IteratorSDS;
00028     friend class InspectorSDS;
00029     
00030 protected:
00031     bool                   _delayBuild;
00032     List<SceneGraphObject> _intangibleChildren;
00033     
00034 protected:
00035     virtual void _duplicate_attributes (const SDS&);
00036 
00037     SDS () {}
00038   
00039 public:
00040     // When delayBuild is set to true then creation of inner structure
00041     // is delaied until the build() method is called - see build() for
00042     // more details
00043     SDS (bool delayBuild) : _delayBuild(delayBuild) {}
00044 
00045     virtual ~SDS () { _intangibleChildren.deleteAll(); }
00046 
00047     // Convert two tranformation matrices into one mixed so that the
00048     // left matrix becames initial.
00049     static Matrix4* multiTrans (const Matrix4*, const Matrix4*, Vector3&);
00050 
00051     // The same as previous but ignore "stretching". Return the only maximal
00052     // scale value ration instead
00053     static Matrix4* multiTrans (const Matrix4*, const Matrix4*, double&);
00054         
00055     virtual SDS*          clone           () const   = 0;
00056     virtual Iterator*     createIterator  ()         = 0;
00057     virtual InspectorSDS* createInspector (unsigned) = 0;
00058     
00059     // Operations changing inner structure must be fixed in SDS
00060     // interface. Operations which traverse inner structure can be
00061     // moved to Iterator.
00062     //
00063     // All operation are applied locally (not recursivelly to sub-nodes)
00064     virtual int               append  (SceneGraphObject*)       = 0;
00065     virtual SceneGraphObject* detach  (SceneGraphObject::OID)   = 0;
00066 
00067     // Update inner structure. Typically when some stored object
00068     // has been moved.
00069     virtual bool update (void) = 0;
00070 
00071     // Build inner structure. Some space sub-division structures
00072     // may preffer its real creation not until they know most of storing
00073     // objects.
00074     // This method must be called after all objects are appended when
00075     // delayBuild is set to true in constructor
00076     virtual bool build (void) = 0;
00077 
00078     // Dump the tree structure into (opened) file
00079     virtual void dump (const char* /* intent */, const char* /* tab */) = 0;
00080     virtual void dump (const char* /* file name */)
00081     {
00082         dump("", " ");
00083         /* to do */
00084     } 
00085 
00086     // Metrices
00087 //    virtual void acceptMetric (Metric&) = 0;
00088 
00089     // debugging:
00090     virtual void __debug() {
00091         fprintf(stderr,"SDS: No debug info\n");
00092     }
00093 };
00094 
00095 }; // namespace
00096 
00097 #endif // __SDS_H

Generated on Wed Jun 28 12:24:28 2006 for esg by  doxygen 1.4.6