VR-Forces 4.8 Class Documentation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
baseTriangle.h
Go to the documentation of this file.
1 /*********************************************************************
2 ** Copyright (c) 2000 MAK Technologies, Inc.
3 ** All rights reserved.
4 *********************************************************************/
5 /*********************************************************************
6 ** $RCSfile: baseTri.h,v $ $Revision: 1.21 $ $State: Exp $
7 *********************************************************************/
8 
9 #ifndef baseTriangle_H_
10 #define baseTriangle_H_
11 
12 #include "gdb/gdbDefines.h"
13 #include "gdb/allTypesPolygon.h"
14 #include "geometry/extent.h"
15 #include "geometry/plane.h"
16 #include "geometry/surface.h"
17 
18 #include <matrix/vlVector.h>
19 
20 // forward declarations
21 class DtChordBundle;
22 class DtSurface;
23 class DtTerrainDatabase;
24 
25 // class DtBaseTriangle:
26 //
27 // DtBaseTriangle is an base class for triangles
29 {
30 protected:
31  //constructor is protected as this is an abstract
32  //base class.
34 
35  // destructor
36  virtual ~DtBaseTriangle();
37 
38  // copy constructor
39  DtBaseTriangle(const DtBaseTriangle& orig);
40 
41  // assignment operator
43 
44 public:
45 
46  // number of vertices
47  virtual unsigned int numberOfVertices() const;
48 
49  // returns plane through the triangle
50  virtual DtPlane plane() const;
51 
52  // returns extent of the triangle
53  virtual DtExtent extent() const = 0;
54 
55  // returns normal to the triangle
56  virtual DtVector normal() const;
57 
58  // for edge, plane, and normal.
59  virtual bool getEdge(DtChord& edge, int edgeNumber) const;
60  virtual void getPlane(DtPlane& plane) const;
61  virtual void getNormal(DtVector& normal) const;
62 
63  //geometric functions
64  //redefine other extent to include all the vertices of the
65  //polygon.
66  virtual void expandExtent(DtExtent& otherExtent) const;
67 
68  // Computes the intersection of the specified chord with the triangle.
69  //
70  // \param chordToTest The chord to test for intersection.
71  // \param intersectionPoint The intersection point, if one occurred.
72  // \param intersectionTime The time along the chord of the intersection. Only set if an intersection occured.
73  // \return A boolean indicating whether or not an intersection occurred.
74  virtual bool intersect(const DtChord& chordToTest, DtPoint& intersectionPoint,
75  double& intersectionTime) const;
76 
77  // Computes the intersection of the polygon and a chord. In addition to the
78  // intersection point and a parametric value, optionally computes and
79  // returns surface description for the intersecting surface, and
80  // normal. Identifies the lowest level intersecting polygon. This function
81  // will only replace the contents of the intersection record if it finds an
82  // intersection with a smaller intersectionTime value.
83  virtual bool intersect(const DtChord& chord,
85  DtIntersectRecordType irtFlag) const;
86 
87  // Computes the intersection of terrain section represented by the polygon
88  // and a bundle of chords. The returned record list is a a DtList of
89  // DtChordIntersectionRecords (one for each chord) each of which must be
90  // created and deleted by the caller. The irtFlag value specifies which
91  // data should be calculated and returned for each intersection point. The
92  // return value of this function is the number of the chords that had any
93  // intersections with the terrain. This function will only replace the
94  // contents of the intersection records if it finds an intersection with a
95  // smaller intersectionTime value.
96  virtual int intersectBundle(const DtChordBundle& chordBundle,
97  DtList& recordList,
98  DtIntersectRecordType irtFlag) const;
99 
100  // Computes the list of all intersections of each of a bundle of chords
101  // with the polygon. For each chord in the bundle, adds to a matching
102  // DtChordIntersectRecordList sorted by distance along the chord. The
103  // caller is responsible for creating and deleting the
104  // DtChordIntersectRecordLists in the intListList DtList. The return
105  // value of this function is the number of the chords that had any
106  // intersections with the terrain. Note that passing an irtFlag value of
107  // IRT_NO_DATA will probably never return more than one intersection per
108  // chord.
109  virtual int allIntersectsAlongChordBundle(const DtChordBundle& chordBundle,
110  DtList& intListList,
111  DtIntersectRecordType irtFlag) const;
112 
113  // \copydoc DtGdbNode::intersect(const DtSphere& sphere,
114  // DtSphereIntersectionRecord& record, DtIntersectRecordType irtFlag)
115  virtual bool intersect(const DtSphere& sphere, DtSphereIntersectionRecord& record,
116  DtIntersectRecordType irtFlag) const;
117 
118 
119 
120  // if the polygon falls within the input
121  // extent, update the color count in the colorCountRecord which is
122  // an in-out parameter.
123  virtual void countPolyColors(DtColorCountRecord& cr,const DtExtent& e) const;
124 
125  //accessor functions
126  virtual bool getVertex(DtPoint& retVal, unsigned int i) const = 0;
127  virtual const DtPoint& getVertex(unsigned int i) const = 0;
128 
129  // determine if a given point is inside the polygon.
130  virtual bool pointInPolygon(const DtPoint& point) const;
131 
132  // Finds the point on the specified chord that is closest to this
133  // polygon, and returns it in closestPoint.
134  // \return Distance squared to the found point.
135  // If cutoffDistance is specified (> 0), the first point found within
136  // this distance will be returned, even if it is not the closest point.
137  // This may cut down significantly on the calculation when the actual
138  // closest point is not required.
139  virtual double closestPointOnChordToPolygon(const DtChord& chord,
140  DtPoint& closestPoint, double cutoffDistance = 0.) const;
141 
142  // determine the minimum and maximum z-values among the
143  // vertices in the polygon.
144  virtual double minZ() const;
145  virtual double maxZ() const;
146 
147  // get the surface associated with the polygon
148  virtual bool getSurface(DtSurface& surf) const = 0;
149  virtual const DtSurface& getSurface() const = 0;
150  virtual bool setSurface(const DtSurface& newSurface) = 0;
151 
152  virtual int sizeInBytes() const = 0;
153 
154 protected:
155  // compute twice the area of the triangle formed by a, b, c,
156  // as the magnitude of the cross product (b-a)X(c-a).
157  // Won't be needed later.
158  virtual double computeTwiceArea(const DtPoint& a,
159  const DtPoint& b, const DtPoint& c) const;
160 };
161 
162 
163 inline unsigned int DtBaseTriangle::numberOfVertices() const
164 {
165  return 3;
166 }
167 
168 inline double DtBaseTriangle::minZ() const
169 {
170  return extent().minZ();
171 }
172 
173 inline double DtBaseTriangle::maxZ() const
174 {
175  return extent().maxZ();
176 }
177 
179 {
180  return DtPlane(getVertex(0), getVertex(1), getVertex(2));
181 }
182 
184 {
185  return plane().normal();
186 }
187 
188 
189 
190 #endif
NOTE: This entire class is deprecated, in favor of Dt3dChord.
Definition: chord.h:40
Definition: chordIntersectionRecord.h:23
Definition: sphere.h:22
virtual double maxZ() const =0
Definition: colorCountRecord.h:21
virtual bool pointInPolygon(const DtPoint &point) const =0
Definition: plane.h:25
virtual void expandExtent(DtExtent &extent) const
Definition: sphereIntersectionRecord.h:19
virtual DtVector normal() const
Definition: baseTriangle.h:183
virtual bool getVertex(DtPoint &retVal, unsigned int i) const =0
DtIntersectRecordType
Definition: gdbNode.h:74
virtual double minZ() const
Definition: baseTriangle.h:168
The DtExtent represents an axis-aligned 3d bounding box.
Definition: extent.h:43
Definition: allTypesPolygon.h:22
Definition: surface.h:179
#define DT_DLL_gdb
Definition: gdbDefines.h:25
virtual void getNormal(DtVector &normal) const =0
double maxZ() const
double minZ() const
virtual bool setSurface(const DtSurface &newSurface)=0
virtual DtPlane plane() const
Definition: baseTriangle.h:178
virtual bool getVertex(DtPoint &retVal, unsigned int i) const =0
Definition: baseTriangle.h:28
virtual unsigned int numberOfVertices() const =0
DtAllTypesPolygon & operator=(const DtAllTypesPolygon &orig)
virtual bool intersect(const DtChord &chord, DtPoint &intersectionPoint, double &t) const =0
Definition: chordBundle.h:29
virtual unsigned int numberOfVertices() const
Definition: baseTriangle.h:163
virtual double minZ() const =0
virtual double closestPointOnChordToPolygon(const DtChord &chord, DtPoint &closestPoint, double cutoffDistance=0.) const =0
virtual int intersectBundle(const DtChordBundle &chordBundle, DtList &recordList, DtIntersectRecordType irtFlag) const =0
virtual double maxZ() const
Definition: baseTriangle.h:173
virtual int allIntersectsAlongChordBundle(const DtChordBundle &chordBundle, DtList &intListList, DtIntersectRecordType irtFlag) const
Contains the declaration of the DtExtent class.
virtual int sizeInBytes() const =0
virtual const DtSurface & getSurface() const =0
Definition: terrainDatabase.h:148
virtual bool getEdge(DtChord &edge, int edgeNumber) const =0
virtual const DtVector normal() const
virtual DtVector normal() const =0
virtual void countPolyColors(DtColorCountRecord &cr, const DtExtent &e) const =0
Definition: point.h:34
virtual DtExtent extent() const =0

Document ID: Generated on Thu Aug 27 10:56:05 EDT 2020 from SVN revision 217100
Copyright © 2005-2020 MAK Technologies. All Rights Reserved (www.mak.com)