VR-Forces 5.0.3 Developer's Guide
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
triangleIndirect.h
Go to the documentation of this file.
1 /*********************************************************************
2 ** Copyright (c) 2000 MaK Technologies, Inc.
3 ** All rights reserved.
4 *********************************************************************/
5 /*********************************************************************
6 ** $RCSfile: triInd.h,v $ $Revision: 1.25 $ $State: Exp $
7 *********************************************************************/
8 
9 #ifndef triangleIndirect_H_
10 #define triangleIndirect_H_
11 
12 #include "gdb/gdbDefines.h"
13 #include "gdb/baseTriangle.h"
14 #include "gdb/vertexManager.h"
15 #include "gdb/surfaceManager.h"
16 #include "geometry/point.h"
17 
18 #include <vlutil/vlPrint.h>
19 #include <assert.h>
20 
21 // forward declarations
22 class DtSurfaceManager;
23 class DtPolygonIndirect;
24 
25 
26 // class DtTriangleIndirect:
27 //
28 // DtTriangleIndirect allows for the specification of the
29 // vertices of a polygon as indices into a vertex Manager.
30 
32 {
33 public:
34 
35  // constructor using a polygon indirect.
36  DtTriangleIndirect(const DtPolygonIndirect* const poly);
37 
38  // constructor with vertex IDs, vertex manager, surface manager,
39  // and surface ID
40  DtTriangleIndirect(DtVertexManager* const vertManager,
41  const DtVertexID vertID0,
42  const DtVertexID vertID1,
43  const DtVertexID vertID2,
44  DtSurfaceManager* const surfMgr,
45  const DtSurfaceID surfID);
46 
47  // destructor
48  virtual ~DtTriangleIndirect();
49 
50  // copy constructor
52 
53  // assignment operator
55 
56  // computes the intersection of chord with polygon; returns
57  // intersection point.
58  virtual bool intersect(const DtChord& chord,
59  DtPoint& intersectionPoint,
60  double& t) const;
61 
62  // Since this class only overrides one of the intersection functions,
63  // specify that its using the base classes to prevent hiding.
67 
68  // returns extent of the triangle
69  inline DtExtent extent() const;
70 
71  // vertex accessors
72  inline DtPoint& vertex0();
73  inline const DtPoint& vertex0() const;
74 
75  inline DtPoint& vertex1();
76  inline const DtPoint& vertex1() const;
77 
78  inline DtPoint& vertex2();
79  inline const DtPoint& vertex2() const;
80 
81  virtual bool getVertex(DtPoint& retVal, unsigned int localIndex) const;
82  const DtPoint& getVertex(unsigned int localIndex) const;
83 
84  // Requires index be a valid localIndex into the list of vertex IDs.
85  virtual DtVertexID getVertexID(unsigned int localIndex) const;
86 
87  virtual void setVertex(unsigned int localIndex, DtVertexID vertexID);
88 
89  // get the surface associated with the triangle
90  virtual bool getSurface(DtSurface& s) const;
91  const DtSurface& getSurface() const;
92 
93  // get the surface ID associated with the triangle
94  virtual DtSurfaceID getSurfaceID() const;
95 
96  // set the surface associated with the triangle
97  // If the ID is a valid surface ID, then it sets the
98  // surface and returns true. If the ID is invalid,
99  // the it returns false and does NOT set the surface.
100  virtual bool setSurface(DtSurfaceID surfaceID);
101 
102  // Sets the surface of the associated triangle.
103  // \return A boolean indicating whether or not the surface could be set.
104  // \note \b Implementation \b detail! - Does not add the surface if it already
105  // exists in the surface manager.
106  virtual bool setSurface(const DtSurface& newSurface);
107 
108  // get the vertex Manager associated with the polygon
109  inline virtual DtVertexManager* const vertexManager() const;
110 
111  // get a pointer to the the surface Manager associated with the triangle
112  inline virtual DtSurfaceManager* const surfaceManager() const;
113 
114  // debugging aid function
115  virtual void dump(int indentLevel) const;
116 
117  // Applies the specified transform to its vertices. If the flag
118  // is true, will create new vertices instead of modifying existing
119  // ones. Returns false if the transformation fails for any reason.
120  virtual bool applyTransform(const DtHomogeneousTransformMatrix& matrix,
121  bool createNewVertices);
122 
123 // Unsafe public functions: These functions expose the internals of
124 // the object.They are unsafe in that, should the implementation change,
125 // these functions are not guaranteed to stay the same. Any use of these
126 // functions assumes the risk they will be broken by future changes to the
127 // internals of this class
128 
129  // default constructor
131 
132  // constructor with vertex indices and vertex manager to
133  // index into
135  const DtVertexID ind0,
136  const DtVertexID ind1,
137  const DtVertexID ind2);
138 
139  // returns type of gdb node
140  virtual DtGdbNode::DtGdbNodeType type() const;
141 
142  // set the vertex Manager associated with the polygon
143  // Requires that the specified vertex manager is not 0.
144  virtual void setVertexManager(DtVertexManager* const vertManager);
145 
146  // set the pointer to the surface Manager associated with the triangle
147  // Requires that the specified surface manager is not 0.
148  virtual void setSurfaceManager(DtSurfaceManager* const surfManager);
149 
150  virtual int sizeInBytes() const;
151 
152 protected:
153 
154  virtual bool testInvariant() const;
155 
159  DtVertexID myVertexIDs[3]; // an array of size 3 to hold the indices.
160 };
161 
163 // Functions below do NOT test for invariancy
164 // and may corrupt the triangle if not used properly
167 {
168  return myVertexManager->vertex(myVertexIDs[0]);
169 }
170 
172 {
173  return myVertexManager->vertex(myVertexIDs[0]);
174 }
175 
176 
178 {
179  return myVertexManager->vertex(myVertexIDs[1]);
180 }
181 
183 {
184  return myVertexManager->vertex(myVertexIDs[1]);
185 }
186 
187 
189 {
190  return myVertexManager->vertex(myVertexIDs[2]);
191 }
192 
194 {
195  return myVertexManager->vertex(myVertexIDs[2]);
196 }
197 
199 {
200  DtExtent expandedExtent(vertex0(), vertex1());
201  expandedExtent.expandToInclude(vertex2());
202  return expandedExtent;
203 }
204 
206 {
207  return myVertexManager;
208 }
209 
210 
212 {
213  return mySurfaceManager;
214 }
215 
216 
218 {
220 }
221 
222 inline DtVertexID DtTriangleIndirect::getVertexID(unsigned int index) const
223 {
224  assert(index <= 2);
225  return myVertexIDs[index];
226 }
227 
228 inline const DtPoint& DtTriangleIndirect::getVertex(unsigned int localIndex) const
229 {
230  return myVertexManager->vertex(myVertexIDs[localIndex]);
231 }
232 
234 {
235  return mySurfaceID;
236 }
237 
239 {
240  assert(surfMgr != 0);
241  mySurfaceManager = surfMgr;
242  // every polygon is created with a surface type of 0
243  // as soon as there is a surface manager, add 1 to the polygon count of this
244  // surface
246 }
247 
249 {
250  assert(vertManager != 0);
251  myVertexManager = vertManager;
252 }
253 
254 inline void DtTriangleIndirect::setVertex(unsigned int localIndex, DtVertexID vertexIndex)
255 {
256  assert(localIndex <= 2);
257  assert(myVertexManager->isValidID(vertexIndex));
258  if (localIndex <= 2)
259  {
260  myVertexIDs[localIndex] = vertexIndex;
261  }
262  else
263  {
264  DtWarn("Warning: DtTriangleIndirect::setVertex -- "
265  "bad localIndex %d\n", localIndex);
266  }
267 }
268 
270 {
272 }
273 
274 #endif
DtVertexManager * myVertexManager
Definition: triangleIndirect.h:158
NOTE: This entire class is deprecated, in favor of Dt3dChord.
Definition: chord.h:40
Definition: gdbNode.h:64
const DtSurface & getSurface() const
Definition: triangleIndirect.h:269
DtSurfaceID mySurfaceID
Definition: triangleIndirect.h:156
Definition: triangleIndirect.h:31
DtPoint & vertex2()
Definition: triangleIndirect.h:188
DtGdbNodeType
Definition: gdbNode.h:48
virtual void setVertexManager(DtVertexManager *const vertManager)
Definition: triangleIndirect.h:248
DtBaseTriangle & operator=(const DtBaseTriangle &orig)
DtPoint & vertex0()
Definition: triangleIndirect.h:166
virtual DtVertexID getVertexID(unsigned int localIndex) const
Definition: triangleIndirect.h:222
DtExtent extent() const
Definition: triangleIndirect.h:198
virtual DtGdbNode::DtGdbNodeType type() const
Definition: triangleIndirect.h:217
DtSurfaceManager * mySurfaceManager
Definition: triangleIndirect.h:157
The DtExtent represents an axis-aligned 3d bounding box.
Definition: extent.h:43
Definition: surface.h:179
#define DT_DLL_gdb
Definition: gdbDefines.h:25
virtual void expandToInclude(const DtExtent &otherExtent)
Expand extent, if necessary, to include input extent.
virtual int allIntersectsAlongChordBundle(const DtChordBundle &chordBundle, DtList &intListList, DtIntersectRecordType irtFlag) const
virtual bool setSurface(const DtSurface &newSurface)=0
DtVertexID myVertexIDs[3]
Definition: triangleIndirect.h:159
Definition: vertexManager.h:26
DtPoint & vertex1()
Definition: triangleIndirect.h:177
virtual void updateSurfaceTerrainElementMap(DtSurfaceID key, unsigned int numElements)
virtual bool getVertex(DtPoint &retVal, unsigned int i) const =0
Definition: baseTriangle.h:28
virtual const DtSurface & getSurface() const =0
virtual bool vertex(DtVertexID vertID, DtVertex &vertex) const
virtual bool getVertex(DtPoint &retVal, unsigned int localIndex) const
Definition: surfaceManager.h:30
virtual DtVertexManager *const vertexManager() const
Definition: triangleIndirect.h:205
virtual void setVertex(unsigned int localIndex, DtVertexID vertexID)
Definition: triangleIndirect.h:254
unsigned int DtSurfaceID
Definition: surfaceManager.h:25
virtual DtSurfaceID getSurfaceID() const
Definition: triangleIndirect.h:233
virtual DtSurfaceManager *const surfaceManager() const
Definition: triangleIndirect.h:211
virtual bool applyTransform(const DtHomogeneousTransformMatrix &matrix, bool createNewVertices)
Definition: polygonIndirect.h:29
virtual void setSurfaceManager(DtSurfaceManager *const surfManager)
Definition: triangleIndirect.h:238
virtual bool isValidID(DtVertexID vertID) const
virtual int sizeInBytes() const =0
virtual void dump(int indentLevel) const =0
virtual int intersectBundle(const DtChordBundle &chordBundle, DtList &recordList, DtIntersectRecordType irtFlag) const
Definition: homogeneousTransformMatrix.h:25
virtual DtGdbNodeType type(void) const =0
Definition: point.h:34
virtual DtExtent extent() const =0
virtual bool surface(DtSurfaceID surfID, DtSurface &surf) const
virtual bool intersect(const DtChord &chordToTest, DtPoint &intersectionPoint, double &intersectionTime) const

Document ID: Generated on Thu Jun 1 17:58:13 EDT 2023 from SVN revision 255404
Copyright © 2005-2021 MAK Technologies. All Rights Reserved (www.mak.com)