VR-Forces 4.0.4 Class Documentation
include/gdb/gdbNode.h
Go to the documentation of this file.
00001 /*********************************************************************
00002 ** Copyright (c) 1998 MAK Technologies, Inc.
00003 ** All rights reserved.
00004 *********************************************************************/
00005 /*********************************************************************
00006 ** $RCSfile: gdbNode.h,v $ $Revision: 1.27 $ $State: Exp $
00007 *********************************************************************/
00008 #ifndef gdbNode_H_
00009 #define gdbNode_H_
00010 
00011 // include files
00012 #include "gdb/gdbDefines.h"
00013 #include "gdb/memManageable.h"
00014 #include "gdb/terrainReader.h"
00015 #include "gdb/gdbNodeEvaluationFunctor.h"
00016 #include <geometry/matrix4x4.h>
00017 #include <vlutil/vlConfig.h>
00018 #include <vlutil/vlList.h>
00019 #include <set>
00020 #include <stdio.h>
00021 
00022 // forward declarations
00023 class DtList;
00024 class DtPoint;
00025 class DtChord;
00026 class DtChordBundle;
00027 class DtChordIntersectionRecord;
00028 class DtChordIntersectRecordList;
00029 class DtIntersectionRecord;
00030 class DtExtent;
00031 class DtColorCountRecord;
00032 class DtTerrainDatabase;
00033 class DtMemoryManager;
00034 class DtSimpleList;
00035 class DtSphere;
00036 class DtSphereIntersectionRecord;
00037 
00038 //
00039 // DtGdbNode is the basic component  of a GDB terrain 
00040 // database and represents a section of the terrain such as
00041 // a polygon, grid, feature, or a collection of such items. 
00042 // It is an abstract base class. All node types 
00043 // of the GDB are subclassed from this class. 
00044 class DT_DLL_gdb DtGdbNode : public DtMemoryManageable
00045 {
00046 public:
00047 
00048    enum DtGdbNodeType
00049    {
00050       NULL_NODE = -1,              
00051       GRIDPOST_LIST = 0,          // = 0
00052       VERTEX_LIST,                // = 1
00053       GROUP,                      // = 2
00054       POLYGON_IMMEDIATE,          // = 3
00055       POLYGON_INDIRECT,           // = 4
00056       LEVEL_OF_DETAIL,            // = 5
00057       GRID,                       // = 6
00058       DYNAMIC_COORDINATE_SYSTEM,  // = 7
00059       STATIC_COORDINATE_SYSTEM,   // = 8
00060       TERRAIN_FEATURE,            // = 9
00061       CULTURAL_FEATURE,           // = 10
00062       BUILDING,                   // = 11
00063       TREE,                       // = 12
00064       TRIANGLE_INDIRECT,          // = 13
00065       FILE_NODE,                  // = 14
00066       REF_GROUP,                  // = 15
00067       EXTENT_TRIANGLE_INDIRECT,   // = 16
00068       LAST_NODE_TYPE
00069    };
00070   
00071 
00072    // The Intersect Record Type flag indicates the kind of data requested from
00073    // a call to one of the intersect functions.  
00074    enum DtIntersectRecordType
00075    {
00076       // NO_DATA returns only a bool indication that an intersection was
00077       // found.
00078       IRT_NO_DATA = 0,
00079 
00080       // IPOINT is like IRT_NO_DATA, but also returns the closest intersection
00081       // point as a DtPoint, the associated "time" value, and the
00082       // surface type.
00083       IRT_IPOINT = 0x01,
00084 
00085       // INORMAL is like IRT_NO_DATA, but also returns the normal as a
00086       // DtWorldCoordVector.
00087       IRT_INORMAL = 0x02,
00088 
00089       // IPOLYGON is like IRT_NO_DATA, but also returns a copy of the polygon that
00090       // was hit.
00091       IRT_IPOLYGON = 0x04,
00092 
00093       // ALL_DATA_TERRAIN requests that all possible data be returned from the terrain node
00094       IRT_ALL_DATA_TERRAIN = 0x07,
00095 
00096       // VECTOR_DATA is like IRT_NO_DATA, but also returns information about the best
00097       // intersection in the vector network using only XY coords of the first point the chord
00098       IRT_VECTOR_DATA_INPOINT = 0x10,
00099 
00100       // VECTOR_DATA is like IRT_NO_DATA, but also returns information about all intersections
00101       // against the vector network XY coords of the first point the chord
00102       IRT_VECTOR_DATA_ALONG_CHORD = 0x20,
00103 
00104       // ALL_DATA requests that all possible data be returned from the terrain node and the info 
00105       // in the point from vector network
00106       IRT_ALL_DATA_INPOINT = 0x17,
00107 
00108       // ALL_DATA requests that all possible data be returned from the terrain node and from the
00109       // vector network along the chord.
00110       IRT_ALL_DATA_ALONG_CHORD = 0x27
00111 
00112    };
00113 
00114    // destructor
00115    virtual ~DtGdbNode();
00116 
00117    // assignment operator
00118    DtGdbNode& operator=(const DtGdbNode& orig);
00119 
00120    // Provides information on the type of the subclassed node.
00121    virtual DtGdbNodeType type(void) const = 0;
00122 
00123    // Prints out information contained in the node.
00124    // There is apparently a problem with consistency of argument
00125    // to this function.
00126    virtual void dump(int indentLevel) const = 0;
00127 
00128    // Return the minimum terrain file version number that this Node can be
00129    // saved in.
00130    virtual DtTerrainFileVersionNumber minSaveVersion() const;
00131 
00132    // Redefines input argument extent such that it encompasses
00133    // the contents of the DtGdbNode object. Nodes that represent
00134    // geometric objects should redefine this. By default, it returns
00135    // the input argument, unchanged.
00136    virtual void expandExtent(DtExtent& extent) const;
00137 
00138    // Recomputes the extent of node if it has one
00139    virtual void recomputeExtent();
00140 
00141    // Node applies the transformation matrix to itself and any possible
00142    // children as appropriate.  The flag specifies whether or not to 
00143    // create new vertices for the transformed vertices instead of 
00144    // just modifying existing vertices.
00145    virtual bool applyTransform(const DtHomogeneousTransfMatrix& matrix,
00146                                bool createNewVertices);
00147 
00148    // process the polygons included in the node that fall within the input
00149    // extent, and update the color count in the colorCountRecord which is
00150    // an in-out parameter.
00151    virtual void countPolyColors(DtColorCountRecord& cr,const DtExtent& e) const;
00152 
00153    // reduce the node to a more compact representation.
00154    virtual DtGdbNode* reduce(int& numReductions);
00155 
00156    // repeatedly invoke the reduce function until no further reduction is
00157    // possible.
00158    virtual DtGdbNode* persistentReduce();
00159 
00160    // check the validity of the node
00161    virtual bool sanityCheck() const;
00162 
00163    // Computes the intersection of terrain section represented by
00164    // DtGdbNode object and a chord. Returns the intersection point
00165    // and a parametric value.
00166    virtual bool intersect(const DtChord& chord, DtPoint& intersectionPoint, 
00167       double& intersectionTime) const;
00168 
00169    // Computes the intersection of terrain section represented by DtGdbNode
00170    // object and a chord. In addition to the intersection point and a
00171    // parametric value, optionally computes and returns surface description
00172    // for the intersecting surface, and normal. Identifies the lowest level
00173    // intersecting polygon.  This function will only replace the contents of
00174    // the intersection record if it finds an intersection with a smaller
00175    // intersectionTime value.
00176    virtual bool intersect(const DtChord& chord, DtChordIntersectionRecord& record,
00177       DtIntersectRecordType irtFlag) const;
00178 
00179    // Tests for intersection between the terrain represented by this node
00180    // and the specified sphere.
00181    // \return True if an intersection occurs.
00182    // If irtFlag is IRT_IPOLYGON or higher, a list of all the intersected 
00183    // polygons is returned inside the record.
00184    virtual bool intersect(const DtSphere& sphere, DtSphereIntersectionRecord& record,
00185       DtIntersectRecordType irtFlag) const;
00186 
00187    // Computes the list of all intersections of a chord with terrain section
00188    // represented by DtGdbNode. Adds to a list of DtChordIntersectionRecords
00189    // sorted by distance along the chord. Returns false if no intersections
00190    // exist.  Note that passing an irtFlag value of IRT_NO_DATA will probably
00191    // never return more than one intersection.
00192    virtual bool allIntersectsAlongChord(const DtChord& chord,
00193       DtChordIntersectRecordList& intList, DtIntersectRecordType irtFlag) const;
00194 
00195    // Computes the intersection of terrain section represented by DtGdbNode
00196    // object and a bundle of chords. The returned record list is a a DtList of
00197    // DtChordIntersectionRecords (one for each chord) each of which must be
00198    // created and deleted by the caller.  The irtFlag value specifies which
00199    // data should be calculated and returned for each intersection point.  The
00200    // return value of this function is the number of the chords that had any
00201    // intersections with the terrain.  This function will only replace the
00202    // contents of the intersection records if it finds an intersection with a
00203    // smaller intersectionTime value.
00204    virtual int intersectBundle(const DtChordBundle& chordBundle, 
00205       DtList& recordList, DtIntersectRecordType irtFlag) const;
00206 
00207    // Computes the list of all intersections of each of a bundle of chords
00208    // with terrain section represented by DtGdbNode.  For each chord in the
00209    // bundle, adds to a matching DtChordIntersectRecordList sorted by distance
00210    // along the chord.  The caller is responsible for creating and deleting
00211    // the DtChordIntersectRecordLists in the intListList DtList.  The return
00212    // value of this function is the number of the chords that had any
00213    // intersections with the terrain.  Note that passing an irtFlag value of
00214    // IRT_NO_DATA will probably never return more than one intersection per
00215    // chord.
00216    virtual int allIntersectsAlongChordBundle(const DtChordBundle& chordBundle,
00217       DtList& intListList, DtIntersectRecordType irtFlag) const;
00218 
00219    // The DtFoundInstancesContainer is the container of pointers to DtGdbNode 
00220    // instances filled in by the allInstancesOf function.  
00221    typedef std::set<DtGdbNode*> DtFoundInstancesContainer;
00222    typedef DtFoundInstancesContainer::iterator DtFoundInstancesIter;
00223    typedef DtFoundInstancesContainer::const_iterator DtFoundInstancesConstIter;
00224 
00225    typedef std::set<const DtGdbNode*> DtFoundInstancesConstContainer;
00226    typedef DtFoundInstancesConstContainer::iterator DtConstFoundInstancesIter;
00227    typedef DtFoundInstancesConstContainer::const_iterator DtConstFoundInstancesConstIter;
00228 
00229    // Finds all instances of node type searchType in the tree including and
00230    // below this node.  This default method only includes the current node,
00231    // and is overwritten in derived classes as appropriate.
00232    virtual void allInstancesOf(const DtGdbNodeType searchType, 
00233       DtFoundInstancesContainer& foundInstances,
00234       bool recurseIntoCoordSysNodes = false);
00235 
00236    virtual void allInstancesOf(const DtGdbNodeType searchType, 
00237       DtFoundInstancesConstContainer& foundInstances,
00238       bool recurseIntoCoordSysNodes = false) const;
00239 
00240    virtual void allInstancesOf(const DtGdbNodeType searchType, 
00241       DtFoundInstancesContainer& foundInstances,
00242       bool recurseIntoCoordSysNodes,
00243       DtGdbNodeEvaluationFunctor& functor);
00244 
00245    virtual void allInstancesOf(const DtGdbNodeType searchType, 
00246       DtFoundInstancesConstContainer& foundInstances,
00247       bool recurseIntoCoordSysNodes,
00248       DtGdbNodeEvaluationFunctor& functor) const;
00249 
00250    
00251    // Finds and removes all instances of node type searchType in the tree 
00252    // below this node.
00253    virtual void purgeAllInstancesOf(const DtGdbNodeType searchType);
00254 
00255    // Finds and removes all instances of every node type in the tree below
00256    // this node; deletes the nodes if they are not memory managed.  It returns
00257    // this.
00258    virtual DtGdbNode* purgeAll();
00259 
00260    // Find the parent (if it exists of child in the tree under the node)
00261    virtual DtGdbNode* parent(DtGdbNode *child);
00262 
00263    // remove the child (if it is) from this node
00264    virtual DtGdbNode* removeChild(DtGdbNode *child);
00265 
00266    // Finds and replaces all three-sided polygons with triangles
00267    // in the tree below this node.  
00268    virtual void polygonToTriangle(DtMemoryManager* memMgr,
00269                                   unsigned int& numIndConverted, 
00270                                   unsigned int& numIndTotal); 
00271 
00272    // Load in all external DtFileNode files.  Returns the number of databases
00273    // that were just loaded.
00274    virtual unsigned int loadAllExternalFiles() const;
00275 
00276    // Unload all external DtFileNode files.  Returns the number of databases
00277    // that were unloaded.
00278    virtual unsigned int unloadAllExternalFiles() const;
00279 
00280    virtual int sizeInBytes() const = 0;
00281 
00282 protected:
00283 
00284    // constructors are protected as this is an 
00285    // abstract base class.
00286    DtGdbNode();
00287 
00288    // copy constructor
00289    DtGdbNode(const DtGdbNode& orig);
00290 
00291    DtGdbNode*           myOwner;   // pointer to the node's owner
00292                                    
00293 };
00294 #endif
00295 

Document ID: Generated on Fri Jun 29 16:33:32 EDT 2012 from SVN revision 116588
Copyright © 2005-2012 VT MÄK Inc. All Rights Reserved (www.mak.com)