VR-Forces 4.0.4 Class Documentation
include/gdb/baseCoord.h
Go to the documentation of this file.
00001 /******************************************************************************
00002 ** Copyright (c) 1999 MAK Technologies, Inc.
00003 ** All rights reserved.
00004 ******************************************************************************/
00005 /******************************************************************************
00006 ** $RCSfile: baseCoord.h,v $ $Revision: 1.18 $ $State: Exp $
00007 ******************************************************************************/
00008 #ifndef baseCoord_H_
00009 #define baseCoord_H_
00010 
00011 #include "gdb/gdbDefines.h"
00012 #include "gdb/gdbNode.h"
00013 #include "geometry/matrix4x4.h"
00014 
00015 //forward declarations
00016 class DtTerrainDatabase;
00017 class DtExtent;
00018 class DtChord;
00019 class DtChordBundle;
00020 class DtChordIntersectionRecord;
00021 class DtChordIntersectRecordList;
00022 class DtAllTypesPolygon;
00023 
00024 //
00025 // Coordinate system.
00026 //
00027 class DT_DLL_gdb DtBaseCoordinateSystem: public DtGdbNode
00028 {
00029   public:
00030 
00031    DtBaseCoordinateSystem();
00032 
00033    virtual ~DtBaseCoordinateSystem();
00034 
00035 private:
00036    // Copy constructor and Assignment operator not implemented
00037    DtBaseCoordinateSystem(const DtBaseCoordinateSystem& original);
00038    DtBaseCoordinateSystem& operator=(const DtBaseCoordinateSystem& original);
00039 
00040 public:
00041 
00042    virtual DtGdbNode* child();
00043    virtual const DtGdbNode* child() const;
00044    virtual void setChild(DtGdbNode* node);
00045 
00046    virtual const DtHomogeneousTransfMatrix& fromChildXformForPoints() const;
00047    virtual void setFromChildXformForPoints(DtHomogeneousTransfMatrix& matrix);
00048 
00049    virtual const DtHomogeneousTransfMatrix& toChildXformForPoints() const;
00050    virtual void setToChildXformForPoints(DtHomogeneousTransfMatrix& matrix);
00051 
00052    virtual void   dump(int indentLevel) const;
00053 
00054    // Finds all instances of node type searchType in the tree including and
00055    // below this node.
00056    virtual void allInstancesOf(const DtGdbNodeType searchType, 
00057       DtFoundInstancesContainer& foundInstances,
00058       bool recurseIntoCoordSysNodes = false);
00059 
00060    virtual void allInstancesOf(const DtGdbNodeType searchType, 
00061       DtFoundInstancesConstContainer& foundInstances,
00062       bool recurseIntoCoordSysNodes = false) const;
00063 
00064    virtual void allInstancesOf(const DtGdbNodeType searchType, 
00065       DtFoundInstancesContainer& foundInstances,
00066       bool recurseIntoCoordSysNodes, DtGdbNodeEvaluationFunctor functor);
00067 
00068    virtual void allInstancesOf(const DtGdbNodeType searchType, 
00069       DtFoundInstancesConstContainer& foundInstances,
00070       bool recurseIntoCoordSysNodes, DtGdbNodeEvaluationFunctor functor) const;
00071    
00072    // process the polygons included in the node that fall within the input
00073    // extent, and update the color count in the colorCountRecord which is
00074    // an in-out parameter.
00075    virtual void countPolyColors(DtColorCountRecord& cr,const DtExtent& e) const;
00076 
00077    // reduce the DtBaseCoordinateSystem node by reducing its child node.
00078    virtual DtGdbNode* reduce(int& numReductions);
00079 
00080    // ensure the validity of the CoordinateSystem node 
00081    virtual bool sanityCheck() const;
00082 
00083    virtual void expandExtent(DtExtent& extent) const;
00084 
00085    // Forces the child to recalculate its extent
00086    virtual void recomputeExtent();
00087 
00088    // Computes the intersection of the terrain section below the coordinate
00089    // system node object and a chord. Returns the intersection point and a
00090    // parametric value.
00091    virtual bool   intersect(const DtChord& chord,
00092       DtPoint& intersectionPoint,
00093       double& intersectionTime) const;
00094 
00095    // Computes the intersection of the terrain section below the coordinate
00096    // system node and a chord. In addition to the intersection point and a
00097    // parametric value, optionally computes and returns surface description
00098    // for the intersecting surface, and normal. Identifies the lowest level
00099    // intersecting polygon.  This function will only replace the contents of
00100    // the intersection record if it finds an intersection with a smaller
00101    // intersectionTime value.
00102    virtual bool   intersect(const DtChord& chord, 
00103       DtChordIntersectionRecord& record, DtIntersectRecordType irtFlag) const;
00104 
00105    // Computes the list of all intersections of a chord with the terrain
00106    // section below the coordinate system node object.  Adds to a list of
00107    // DtChordIntersectionRecords sorted by distance along the chord. Returns
00108    // false if no intersections exist.  Note that passing an irtFlag value
00109    // of IRT_NO_DATA will probably never return more than one intersection.
00110    virtual bool   allIntersectsAlongChord(const DtChord& chord,
00111       DtChordIntersectRecordList& intList,
00112       DtIntersectRecordType irtFlag) const;
00113 
00114    // Computes the intersection of terrain section represented by the terrain
00115    // section below the coordinate system node and a bundle of chords. The
00116    // returned record list is a a DtList of DtChordIntersectionRecords (one
00117    // for each chord) each of which must be created and deleted by the caller.
00118    // The irtFlag value specifies which data should be calculated and returned
00119    // for each intersection point.  The return value of this function is the
00120    // number of the chords that had any intersections with the terrain.  This
00121    // function will only replace the contents of the intersection records if
00122    // it finds an intersection with a smaller intersectionTime value.
00123    virtual int intersectBundle(const DtChordBundle& chordBundle,
00124       DtList& recordList, DtIntersectRecordType irtFlag) const;
00125 
00126    // Computes the list of all intersections of each of a bundle of chords
00127    // with the terrain section below the coordinate system node object.  For
00128    // each chord in the bundle, adds to a matching DtChordIntersectRecordList
00129    // sorted by distance along the chord.  The caller is responsible for
00130    // creating and deleting the DtChordIntersectRecordLists in the intListList
00131    // DtList.  The return value of this function is the number of the chords
00132    // that had any intersections with the terrain.  Note that passing an
00133    // irtFlag value of IRT_NO_DATA will probably never return more than one
00134    // intersection per chord.
00135    virtual int allIntersectsAlongChordBundle(
00136       const DtChordBundle& chordBundle,
00137       DtList& intListList, DtIntersectRecordType irtFlag) const;
00138 
00139    void      initOtherMatricesFromMyToChildXformForPoints(void);
00140    void      initOtherMatricesFromMyFromChildXformForPoints(void);
00141 
00142    //Finds and replaces all three-sided polygons with triangles
00143    //in the tree below this node.  
00144    virtual void polygonToTriangle(DtMemoryManager* memMgr,
00145    unsigned int& numIndConverted, unsigned int& numIndTotal); 
00146 
00147    // Finds and removes all instances of every node type in the tree below
00148    // this node; deletes the nodes if they are not memory managed.  It returns
00149    // this.
00150    virtual DtGdbNode* purgeAll();
00151 
00152    // Find the parent (if it exists of child in the tree under the node)
00153    virtual DtGdbNode* parent(DtGdbNode *child);
00154 
00155    // remove the child (if it is) from this node
00156    virtual DtGdbNode* removeChild(DtGdbNode *child);
00157 
00158    // Applies the input matrix to itself and its children as appropriate.
00159    //
00160    // Concatenates member homogeneous transform with specified transform 
00161    // matrix to create a transformation from child coords all
00162    // the way to world coords.
00163    // Returns false if the transform failed for any reason.
00164    // (after using, in parent node, should replace coordinate system 
00165    // node with its child node.)
00166    // Note:  If the transform matrix is non-identity, will change the
00167    // flag to true if it is already not.
00168    virtual bool applyTransform(const DtHomogeneousTransfMatrix& matrix,
00169                                 bool createNewVertices);
00170 
00171    virtual int sizeInBytes() const;
00172 
00173 protected:
00174 
00175 
00176    // Copy a given polygon to my Coordinate system
00177    virtual DtAllTypesPolygon* copyPolygonToMyCs(
00178       const DtAllTypesPolygon& orig) const;
00179 
00180    // Translate a given intersection record to my Coordinate system
00181    virtual void chordIntersectionRecordChildsCsToMyCs(
00182       const DtChordIntersectionRecord& recordInChildsCs,
00183       DtChordIntersectionRecord& recordInMyCs,
00184       DtIntersectRecordType irtFlag) const;
00185 
00186    // Translate a given list of intersection records to my Coordinate system.
00187    // This modifies the records in its first argument!
00188    virtual void chordIntersectRecordListChildsCsToMyCs(
00189       DtChordIntersectRecordList& intListInChildsCs,
00190       DtIntersectRecordType irtFlag) const;
00191     
00192     DtGdbNode* myChild;
00193 
00194     DtHomogeneousTransfMatrix      myToChildXformForPoints;
00195     DtHomogeneousTransfMatrix      myFromChildXformForPoints;
00196 };
00197 
00198 inline DtGdbNode* DtBaseCoordinateSystem::child()
00199 {
00200    return myChild;
00201 }
00202 inline const DtGdbNode* DtBaseCoordinateSystem::child() const 
00203 {
00204    return myChild;
00205 }
00206 
00207 inline void DtBaseCoordinateSystem::setChild(DtGdbNode* node)
00208 {
00209   myChild = node;
00210 }
00211 
00212 inline const DtHomogeneousTransfMatrix& DtBaseCoordinateSystem::fromChildXformForPoints() const
00213 {
00214    return myFromChildXformForPoints; 
00215 }
00216 
00217 inline void DtBaseCoordinateSystem::setFromChildXformForPoints(
00218    DtHomogeneousTransfMatrix& matrix)
00219 {
00220    myFromChildXformForPoints = matrix;
00221 }
00222 
00223 inline const DtHomogeneousTransfMatrix& DtBaseCoordinateSystem::toChildXformForPoints() const
00224 {
00225    return myToChildXformForPoints; 
00226 }
00227 
00228 inline void DtBaseCoordinateSystem::setToChildXformForPoints(
00229    DtHomogeneousTransfMatrix& matrix)
00230 {
00231    myToChildXformForPoints = matrix;
00232 }
00233 
00234 /****************************************************************
00235  * Dynamic coordinate system.
00236  ****************************************************************/
00237 
00238 class DtDynamicCoordinateSystem: public DtBaseCoordinateSystem
00239 {
00240   public:
00241 
00242     DtDynamicCoordinateSystem();
00243 
00244     void         dump(int indentLevel) const;
00245     DtGdbNodeType      type(void) const;
00246 };
00247 
00248 
00249 /****************************************************************
00250  * Static coordinate system.
00251  ****************************************************************/
00252 
00253 
00254 class DtStaticCoordinateSystem: public DtBaseCoordinateSystem
00255 {
00256   public:
00257 
00258     DtStaticCoordinateSystem();
00259 
00260     void         dump(int indentLevel) const;
00261     DtGdbNodeType      type(void) const;
00262 };
00263 
00264 #endif

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)