![]() |
VR-Forces 4.0.4 Class Documentation
|
00001 /********************************************************************* 00002 ** Copyright (c) 1999 MaK Technologies, Inc. 00003 ** All rights reserved. 00004 *********************************************************************/ 00005 /********************************************************************* 00006 ** $RCSfile: gridPstLst.h,v $ $Revision: 1.9 $ $State: Exp $ 00007 *********************************************************************/ 00008 00009 #ifndef gridPstLst_H_ 00010 #define gridPstLst_H_ 00011 00012 // include files 00013 #include "gdb/gdbDefines.h" 00014 #include "gdb/baseVtxLst.h" 00015 #include "geometry/point.h" 00016 #include "gdb/surfMgr.h" 00017 00021 typedef enum 00022 { 00023 00024 SW_NE_DIAGONAL, 00025 NW_SE_DIAGONAL 00026 00027 } DtGridDiagonalType; 00028 00029 00030 // forward declarations 00031 class DtSurface; 00032 class DtSurfaceManager; 00033 class DtGroup; 00034 class DtVertexManager; 00035 00036 00037 // 00038 // class DtGridPostList: 00039 // 00040 // DtGridPostList is used to describe the terrain skin. 00041 // Posts are uniformly spaced in the x and y directions. 00042 // Diagonalization at posts runs southwest to northeast, 00043 // or southeast to northwest. However, the convention is 00044 // uniform for the entire database. 00045 // At each post, the elevation of the terrain is 00046 // specified. Also defined are the characterization of surfaces 00047 // of the two triangles in the square that is to the NE of the 00048 // post. The last row and the last column have no surface 00049 // associations. They do have corresponding elevation data. 00050 // 00051 class DT_DLL_gdb DtGridPostList : public DtBaseVertexList 00052 { 00053 public: 00054 00055 // default constructor 00056 DtGridPostList(); 00057 00058 // destructor 00059 virtual ~DtGridPostList(); 00060 00061 // additional constructor that specifies the origin of the grid 00062 // post list, associated surface manager, post interval, width and 00063 // height of the grid post list measured in posts, and the 00064 // diagonalization of the database. 00065 DtGridPostList(DtSurfaceManager* surfaceManager, 00066 const DtPoint o, 00067 double interval, 00068 unsigned int pwide, 00069 unsigned int phigh, 00070 bool swNeDiag); 00071 00072 // copy constructor 00073 DtGridPostList(const DtGridPostList& orig); 00074 00075 // assignment operator 00076 DtGridPostList& operator=(const DtGridPostList& orig); 00077 00078 // return the type of the node. 00079 virtual DtGdbNode::DtGdbNodeType type() const; 00080 00081 //accessor functions 00082 00083 // returns origin of grid post list 00084 virtual const DtPoint& origin() const; 00085 00086 // returns number of posts along x-axis 00087 virtual unsigned int width() const; 00088 00089 // returns number of posts along y-axis 00090 virtual unsigned int height() const; 00091 00092 // returns distance between adjacent posts in x- or y- direction. 00093 virtual double interval() const; 00094 00095 // a grid post list may be diagonalized SW-NE or SE_NW. Returns the 00096 // diagonalization associated with this grid post list. 00097 virtual DtGridDiagonalType diagonal() const; 00098 00099 // used to set the diagonal from the value read from 00100 // a GDB1.0 Grid Node; generally, it should not be used! 00101 virtual void setDiagonal(bool diag); 00102 00103 // returns array of elevations associated with the grid post list 00104 virtual double* elevations() const; 00105 00106 // returns a pointer to the surface manager associated with the grid post list 00107 virtual DtSurfaceManager* surfaces() const; 00108 00109 // sets the surface list associated with the grid post list 00110 virtual void setSurfaceManager(DtSurfaceManager* surfMgr); 00111 00112 // returns index into surface list associated with triangle 0 (top-left 00113 // for SW-NE, bottom-left for SE_NW) for post n. 00114 virtual unsigned int tri0Surface(unsigned int n) const; 00115 00116 // returns index into surface list associated with triangle 1 (bottom-right 00117 // for SW-NE, top-right for SE_NW) for post n. 00118 virtual unsigned int tri1Surface(unsigned int n) const; 00119 00120 // get the i-th vertex of gridpost list 00121 virtual DtPoint vertex(unsigned int i) const; 00122 00123 // return the i-th vertex of gridpost list in retVal 00124 virtual bool getVertex(DtPoint& retVal, unsigned int i) const; 00125 00126 //access the surface description of Triangle0(SW)? at postnum. 00127 virtual DtSurface& getTri0Surface(unsigned int postnum) const; 00128 00129 //access the surface description of Triangle1(NE)? at postnum. 00130 virtual DtSurface& getTri1Surface(unsigned int postnum) const; 00131 00132 // This function is used when elevations are specified sequentially. 00133 // when you add a grid post, should you specify elevation and 00134 // and surface indices for the next post?? -- RVK 00135 virtual unsigned int addGridPost(double elevation); 00136 00137 // set the elevation at postnum as specified. 00138 virtual void setElevation(unsigned int postnum, double elevation); 00139 00140 // set the surface of Triangle0(top-left for SW-NE diagonal, bottom-left 00141 // for SE-NW diagonal) at postnum. 00142 virtual void setTri0Surface(unsigned int postnum, DtSurfaceID surfaceID, bool check = true); 00143 00144 // set the surface of Triangle1(bottom-right if SW-NE diagonal, top-right 00145 // for SE-NW diagonal) at postnum. 00146 virtual void setTri1Surface(unsigned int postnum, DtSurfaceID surfaceID, bool check = true); 00147 00148 // determines if postNum is the last grid post of a row 00149 virtual bool isLastGridpostOfRow(unsigned int pnum) const; 00150 00151 // determines if postNum is the last grid post of a column 00152 virtual bool isLastGridpostOfColumn(unsigned int pnum) const; 00153 00154 // Triangulates the gridpostlist returning 2 * (height - 1) * (width - 1) 00155 // triangles as children of the specified group. 00156 // Needs the terrain database for vertex manager and surface manager pointers 00157 // Uses the specified vertex manager and sets the triangles to reference 00158 // the same SurfaceManager that this class references. 00159 // Returns false if triangulation failed for any reason. 00160 virtual bool triangulate(DtGroup& parent, DtTerrainDatabase* terrainDatabase) const; 00161 00162 //debugging aid function 00163 virtual void dump(int indentLevel) const; 00164 00165 virtual int sizeInBytes() const; 00166 00167 protected: 00168 00169 virtual unsigned int* tri0Surfaces() const; 00170 virtual unsigned int* tri1Surfaces() const; 00171 00172 protected: 00173 00174 DtPoint myOrigin; 00175 unsigned int myWidthInPosts; 00176 unsigned int myHeightInPosts; 00177 double myPostInterval; 00178 bool mySwNeDiag; 00179 00180 // Dynamically allocated array of elevations. 00181 double* myElevationList; 00182 00183 // my list of surfaces 00184 mutable DtSurfaceManager* mySurfaceManager; 00185 00186 // Dynamically allocated array of surface indices for 00187 // left triangle 00188 unsigned int* myTri0Surfaces; 00189 00190 // Dynamically allocated array of surface indices for 00191 // triangle to the right. 00192 unsigned int* myTri1Surfaces; 00193 }; 00194 00195 00199 00200 inline DtGdbNode::DtGdbNodeType DtGridPostList::type() const 00201 { 00202 return(DtGdbNode::GRIDPOST_LIST); 00203 } 00204 00205 inline const DtPoint& DtGridPostList::origin() const 00206 { 00207 return myOrigin; 00208 } 00209 00210 inline unsigned int DtGridPostList::width() const 00211 { 00212 return myWidthInPosts; 00213 } 00214 00215 inline unsigned int DtGridPostList::height() const 00216 { 00217 return myHeightInPosts; 00218 } 00219 00220 inline double DtGridPostList::interval() const 00221 { 00222 return myPostInterval; 00223 } 00224 00225 inline DtGridDiagonalType DtGridPostList::diagonal() const 00226 { 00227 if (mySwNeDiag) 00228 return(SW_NE_DIAGONAL); 00229 else 00230 return(NW_SE_DIAGONAL); 00231 } 00232 00233 inline void DtGridPostList::setDiagonal(bool diag) 00234 { 00235 mySwNeDiag = diag; 00236 } 00237 00238 inline double* DtGridPostList::elevations() const 00239 { 00240 return myElevationList; 00241 } 00242 00243 inline DtSurfaceManager* DtGridPostList::surfaces() const 00244 { 00245 return mySurfaceManager; 00246 } 00247 00248 inline void DtGridPostList::setSurfaceManager(DtSurfaceManager* surfMgr) 00249 { 00250 mySurfaceManager = surfMgr; 00251 } 00252 00253 inline unsigned int* DtGridPostList::tri0Surfaces() const 00254 { 00255 return myTri0Surfaces; 00256 } 00257 00258 inline unsigned int* DtGridPostList::tri1Surfaces() const 00259 { 00260 return myTri1Surfaces; 00261 } 00262 00263 #endif