VR-Forces 4.10 Class Documentation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
gridPostList.h
Go to the documentation of this file.
1 /*********************************************************************
2 ** Copyright (c) 1999 MaK Technologies, Inc.
3 ** All rights reserved.
4 *********************************************************************/
5 /*********************************************************************
6 ** $RCSfile: gridPstLst.h,v $ $Revision: 1.9 $ $State: Exp $
7 *********************************************************************/
8 
9 #ifndef gridPostList_H_
10 #define gridPostList_H_
11 
12 // include files
13 #include "gdb/gdbDefines.h"
14 #include "gdb/baseVertexList.h"
15 #include "geometry/point.h"
16 #include "gdb/surfaceManager.h"
17 
21 typedef enum
22 {
23 
26 
28 
29 
30 // forward declarations
31 class DtSurface;
32 class DtSurfaceManager;
33 class DtGroup;
34 class DtVertexManager;
35 
36 
37 //
38 // class DtGridPostList:
39 //
40 // DtGridPostList is used to describe the terrain skin.
41 // Posts are uniformly spaced in the x and y directions.
42 // Diagonalization at posts runs southwest to northeast,
43 // or southeast to northwest. However, the convention is
44 // uniform for the entire database.
45 // At each post, the elevation of the terrain is
46 // specified. Also defined are the characterization of surfaces
47 // of the two triangles in the square that is to the NE of the
48 // post. The last row and the last column have no surface
49 // associations. They do have corresponding elevation data.
50 //
52 {
53 public:
54 
55  // default constructor
57 
58  // destructor
59  virtual ~DtGridPostList();
60 
61  // additional constructor that specifies the origin of the grid
62  // post list, associated surface manager, post interval, width and
63  // height of the grid post list measured in posts, and the
64  // diagonalization of the database.
65  DtGridPostList(DtSurfaceManager* surfaceManager,
66  const DtPoint o,
67  double interval,
68  unsigned int pwide,
69  unsigned int phigh,
70  bool swNeDiag);
71 
72  // copy constructor
73  DtGridPostList(const DtGridPostList& orig);
74 
75  // assignment operator
77 
78  // return the type of the node.
79  virtual DtGdbNode::DtGdbNodeType type() const;
80 
81  //accessor functions
82 
83  // returns origin of grid post list
84  virtual const DtPoint& origin() const;
85 
86  // returns number of posts along x-axis
87  virtual unsigned int width() const;
88 
89  // returns number of posts along y-axis
90  virtual unsigned int height() const;
91 
92  // returns distance between adjacent posts in x- or y- direction.
93  virtual double interval() const;
94 
95  // a grid post list may be diagonalized SW-NE or SE_NW. Returns the
96  // diagonalization associated with this grid post list.
97  virtual DtGridDiagonalType diagonal() const;
98 
99  // used to set the diagonal from the value read from
100  // a GDB1.0 Grid Node; generally, it should not be used!
101  virtual void setDiagonal(bool diag);
102 
103  // returns array of elevations associated with the grid post list
104  virtual double* elevations() const;
105 
106  // returns a pointer to the surface manager associated with the grid post list
107  virtual DtSurfaceManager* surfaces() const;
108 
109  // sets the surface list associated with the grid post list
110  virtual void setSurfaceManager(DtSurfaceManager* surfMgr);
111 
112  // returns index into surface list associated with triangle 0 (top-left
113  // for SW-NE, bottom-left for SE_NW) for post n.
114  virtual unsigned int tri0Surface(unsigned int n) const;
115 
116  // returns index into surface list associated with triangle 1 (bottom-right
117  // for SW-NE, top-right for SE_NW) for post n.
118  virtual unsigned int tri1Surface(unsigned int n) const;
119 
120  // get the i-th vertex of gridpost list
121  virtual DtPoint vertex(unsigned int i) const;
122 
123  // return the i-th vertex of gridpost list in retVal
124  virtual bool getVertex(DtPoint& retVal, unsigned int i) const;
125 
126  //access the surface description of Triangle0(SW)? at postnum.
127  virtual DtSurface& getTri0Surface(unsigned int postnum) const;
128 
129  //access the surface description of Triangle1(NE)? at postnum.
130  virtual DtSurface& getTri1Surface(unsigned int postnum) const;
131 
132  // This function is used when elevations are specified sequentially.
133  // when you add a grid post, should you specify elevation and
134  // and surface indices for the next post?? -- RVK
135  virtual unsigned int addGridPost(double elevation);
136 
137  // set the elevation at postnum as specified.
138  virtual void setElevation(unsigned int postnum, double elevation);
139 
140  // set the surface of Triangle0(top-left for SW-NE diagonal, bottom-left
141  // for SE-NW diagonal) at postnum.
142  virtual void setTri0Surface(unsigned int postnum, DtSurfaceID surfaceID, bool check = true);
143 
144  // set the surface of Triangle1(bottom-right if SW-NE diagonal, top-right
145  // for SE-NW diagonal) at postnum.
146  virtual void setTri1Surface(unsigned int postnum, DtSurfaceID surfaceID, bool check = true);
147 
148  // determines if postNum is the last grid post of a row
149  virtual bool isLastGridpostOfRow(unsigned int pnum) const;
150 
151  // determines if postNum is the last grid post of a column
152  virtual bool isLastGridpostOfColumn(unsigned int pnum) const;
153 
154  // Triangulates the gridpostlist returning 2 * (height - 1) * (width - 1)
155  // triangles as children of the specified group.
156  // Needs the terrain database for vertex manager and surface manager pointers
157  // Uses the specified vertex manager and sets the triangles to reference
158  // the same SurfaceManager that this class references.
159  // Returns false if triangulation failed for any reason.
160  virtual bool triangulate(DtGroup& parent, DtTerrainDatabase* terrainDatabase) const;
161 
162  //debugging aid function
163  virtual void dump(int indentLevel) const;
164 
165  virtual int sizeInBytes() const;
166 
167 protected:
168 
169  virtual unsigned int* tri0Surfaces() const;
170  virtual unsigned int* tri1Surfaces() const;
171 
172 protected:
173 
175  unsigned int myWidthInPosts;
176  unsigned int myHeightInPosts;
179 
180  // Dynamically allocated array of elevations.
181  double* myElevationList;
182 
183  // my list of surfaces
185 
186  // Dynamically allocated array of surface indices for
187  // left triangle
188  unsigned int* myTri0Surfaces;
189 
190  // Dynamically allocated array of surface indices for
191  // triangle to the right.
192  unsigned int* myTri1Surfaces;
193 };
194 
195 
199 
201 {
202  return(DtGdbNode::GRIDPOST_LIST);
203 }
204 
205 inline const DtPoint& DtGridPostList::origin() const
206 {
207  return myOrigin;
208 }
209 
210 inline unsigned int DtGridPostList::width() const
211 {
212  return myWidthInPosts;
213 }
214 
215 inline unsigned int DtGridPostList::height() const
216 {
217  return myHeightInPosts;
218 }
219 
220 inline double DtGridPostList::interval() const
221 {
222  return myPostInterval;
223 }
224 
226 {
227  if (mySwNeDiag)
228  return(SW_NE_DIAGONAL);
229  else
230  return(NW_SE_DIAGONAL);
231 }
232 
233 inline void DtGridPostList::setDiagonal(bool diag)
234 {
235  mySwNeDiag = diag;
236 }
237 
238 inline double* DtGridPostList::elevations() const
239 {
240  return myElevationList;
241 }
242 
244 {
245  return mySurfaceManager;
246 }
247 
249 {
250  mySurfaceManager = surfMgr;
251 }
252 
253 inline unsigned int* DtGridPostList::tri0Surfaces() const
254 {
255  return myTri0Surfaces;
256 }
257 
258 inline unsigned int* DtGridPostList::tri1Surfaces() const
259 {
260  return myTri1Surfaces;
261 }
262 
263 #endif
unsigned int * myTri0Surfaces
Definition: gridPostList.h:188
Definition: gdbNode.h:51
virtual int sizeInBytes() const
Definition: group.h:28
virtual const DtPoint & origin() const
Definition: gridPostList.h:205
DtGdbNodeType
Definition: gdbNode.h:48
voidpf uLong int origin
Definition: ioapi.h:42
virtual unsigned int height() const
Definition: gridPostList.h:215
virtual unsigned int * tri0Surfaces() const
Definition: gridPostList.h:253
virtual unsigned int * tri1Surfaces() const
Definition: gridPostList.h:258
DtBaseVertexList & operator=(const DtBaseVertexList &orig)
virtual void dump(int indentLevel) const
double * myElevationList
Definition: gridPostList.h:181
Definition: surface.h:179
#define DT_DLL_gdb
Definition: gdbDefines.h:25
Definition: gridPostList.h:51
bool mySwNeDiag
Definition: gridPostList.h:178
Definition: vertexManager.h:26
DtPoint myOrigin
Definition: gridPostList.h:174
virtual void setSurfaceManager(DtSurfaceManager *surfMgr)
Definition: gridPostList.h:248
virtual double * elevations() const
Definition: gridPostList.h:238
virtual bool getVertex(DtPoint &retVal, unsigned int i) const =0
Definition: gridPostList.h:24
virtual double interval() const
Definition: gridPostList.h:220
Definition: gridPostList.h:25
unsigned int * myTri1Surfaces
Definition: gridPostList.h:192
DtGridDiagonalType
*/
Definition: gridPostList.h:21
Definition: surfaceManager.h:30
double myPostInterval
Definition: gridPostList.h:177
unsigned int DtSurfaceID
Definition: surfaceManager.h:25
virtual DtGridDiagonalType diagonal() const
Definition: gridPostList.h:225
unsigned int myHeightInPosts
Definition: gridPostList.h:176
unsigned int myWidthInPosts
Definition: gridPostList.h:175
virtual DtPoint vertex(unsigned int i) const =0
Definition: baseVertexList.h:37
virtual void setDiagonal(bool diag)
Definition: gridPostList.h:233
Definition: terrainDatabase.h:148
virtual unsigned int width() const
Definition: gridPostList.h:210
virtual DtSurfaceManager * surfaces() const
Definition: gridPostList.h:243
virtual DtGdbNodeType type(void) const =0
Definition: point.h:34
DtSurfaceManager * mySurfaceManager
Definition: gridPostList.h:184
virtual DtGdbNode::DtGdbNodeType type() const
*/
Definition: gridPostList.h:200

Document ID: Generated on Tue Sep 21 17:42:52 EDT 2021 from SVN revision 234861
Copyright © 2005-2021 MAK Technologies. All Rights Reserved (www.mak.com)