IteratorSDS.h

Go to the documentation of this file.
00001 /* $Id: IteratorSDS.h,v 1.3 2002/11/05 14:31:15 anonymous Exp $ */
00002 
00003 #ifndef __ITERATOR_SDS_H
00004 #define __ITERATOR_SDS_H
00005 
00006 #include <esg/Definitions.h>
00007 #include <esg/Group.h>
00008 #include <esg/SceneGraphObject.h>
00009 #include <esg/iterator/Iterator.h>
00010 #include <esg/geometry/Geometry.h>
00011 #include <esg/spacesorting/SDS.h>
00012 #include <esg/List.h>
00013 
00014 /*
00015  * Iterator of space-sorting structure
00016  *
00017  * Protocol:
00018  *    IteratorSDS * it = space_sorting.createIterator();
00019  *    it->initRyaItersection();
00020  *       -or-
00021  *    it->initChildrenSearch();
00022  *       -...-
00023  *    it->firstChild();
00024  *    it->nextChild(); _UNTIL_NOT_NULL;
00025  *
00026  *    it->init...();
00027  *    it->firstChild();
00028  *    it->nextChild(); _UNTIL_NOT_NULL;
00029  *
00030  *    delete it;
00031  */
00032 
00033 namespace esg {
00034 
00035 class OGSCENE_EXPORT IteratorSDS : public Iterator {
00036 public:
00037     enum Traverse {
00038         NONE,                // no traverse strategy is set
00039         RAY_INTERSECTION,    // intersection with ray
00040         HALF_SPACE,          // objects infering half-space
00041         AREA,                // objects infering enclosed space
00042         CHILDREN             // child by child
00043     };
00044 
00045 protected:
00046     struct RIAttr { // attributes of "ray intersection" search
00047         Vector3      origin;
00048         Vector3      direction;
00049         PointEnv     iEnv;
00050         float        distLimit;
00051         const void*  parentElement;
00052         RIAttr(const Vector3& o, const Vector3& d, float l, const void* e)
00053             : origin(o), direction(d), distLimit(l), parentElement(e) {}
00054     };
00055     
00056     struct HSAttr { // attributes of "objects in half-space" search
00057         Vector3      origin;
00058         Vector3      direction;
00059         HSAttr(const Vector3& o, const Vector3& d)
00060             : origin(o), direction(d) {}
00061     };
00062     
00063     struct ARAttr { // attributes of "objects inside area" search 
00064         Geometry* area;
00065         ARAttr(Geometry* e) : area(e) {}
00066     };
00067 
00068 protected:
00069     RIAttr*  _riAttr;   // attributes used by "ray intersection"
00070     HSAttr*  _hsAttr;   // attributes used by "objs in half-space" search
00071     ARAttr*  _arAttr;   // attributes used by "objects inside area" search
00072     Traverse _traverse; // type of traversal
00073     SDS*     _pAggregate;
00074     bool     _iterateTangible;
00075 
00076 protected:
00077     virtual SceneGraphObject* _first_child (void) = 0;
00078     virtual SceneGraphObject* _next_child  (void) = 0;
00079 
00080 public:    
00081     IteratorSDS (SDS* /* aggregate */);
00082     virtual ~IteratorSDS();
00083 
00084     /*
00085      * Initialization for different traversals.
00086      *
00087      * parentElement is element of spacial data structure which is
00088      * intersected by the given ray. If we now than some concrete element
00089      * is intersected then we can exploit this information to get faster
00090      * tests.
00091      */
00092     virtual void initRayIntersection (const Vector3& o /* ray's origin     */,
00093                                       const Vector3& d /* ray's direction  */,
00094                                       bool           clearCache,
00095                                       float          distLimit = MAXFLOAT,
00096                                       const void*    parentElement  = NULL);
00097     
00098     virtual void initHalfSpaceSearch (const Vector3& /* ray's origin */,
00099                                       const Vector3& /* ray's direction */);
00100     
00101     virtual void initAreaSearch      (Geometry*      /* area */);
00102 
00103     virtual void initChildrenSearch  (void);
00104 
00105     //    virtual bool      iteratesBVH     (void) const { return false; }
00106     //    virtual Geometry* delimitBoundary (void) const { return NULL; }
00107     
00108     // Methods for children traversal:
00109     virtual SceneGraphObject* firstChild (void);
00110     virtual SceneGraphObject* nextChild  (void);
00111 
00112     /*
00113      * This method returns pointer to an element of the inner ordering
00114      * tructure. Returned element is that containing the child successfully
00115      * returned in previous call of the firstChild() or nextChild().
00116      * Therefore it should be invoked after the firstChild() or nextChild().
00117      */
00118     virtual const void* lastExploitedElement (void) const { return NULL; }
00119 };
00120 
00121 }; // namespace
00122 
00123 #endif // __ITERATOR_SDS_H

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