VR-Forces Development_Version Class Documentation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
polygonIndirect.h
Go to the documentation of this file.
1 /*********************************************************************
2 ** Copyright (c) 1999 MaK Technologies, Inc.
3 ** All rights reserved.
4 *********************************************************************/
5 /*********************************************************************
6 ** $RCSfile: polyInd.h,v $ $Revision: 1.19 $ $State: Exp $
7 *********************************************************************/
8 
9 #ifndef polygonIndirect_H_
10 #define polygonIndirect_H_
11 
12 #include "gdb/gdbDefines.h"
13 #include "gdb/basePolygon.h"
14 #include "gdb/surfaceManager.h"
15 #include "gdb/vertexManager.h"
16 #include <assert.h>
18 
19 // forward declarations
20 class DtVertexManager;
21 class DtSurfaceManager;
22 class DtMemoryManager;
23 
24 // class DtPolygonIndirect:
25 //
26 // DtPolygonIndirect allows for the specification of the
27 // vertices of a polygon as indices into a vertex manager.
28 
30 {
31 public:
32 
33  // constructor with number of vertices, array of ints (vertex IDs)
34  // a vertex manager, a surface manager and a surface ID;
35  // uses DtMemoryManager to allocate vertex index array.
36  // NOTE: Does not take ownership of the array of vertex indices
37  // specified - copies them into its own memory managed list.
38  DtPolygonIndirect(unsigned int numVertices,
39  DtVertexManager* vertMgr,
40  DtVertexID* vertexIDs,
41  DtSurfaceManager* surfMgr,
42  DtSurfaceID surfID,
43  DtMemoryManager* memMgr);
44 
45  // destructor
46  virtual ~DtPolygonIndirect();
47 
48  // copy constructor
50 
51  // assignment operator
53 
54  // returns type of gdb node
55  virtual DtGdbNode::DtGdbNodeType type() const;
56 
57  // get the i-th vertex of the polygon
58  virtual bool getVertex(DtPoint& retVal, unsigned int i) const;
59  const DtPoint& getVertex(unsigned int i) const;
60 
61  // set the i-th vertex of the polygon
62  virtual bool setVertex(unsigned int localIndex, DtVertexID vertexID);
63 
64  // get the surface associated with the polygon
65  virtual bool getSurface(DtSurface& s) const;
66  const DtSurface& getSurface() const;
67 
68  // set the surface associated with the polygon
69  // If the ID is a valid surface ID, then it sets the
70  // surface and returns true. If the ID is invalid,
71  // the it returns false and does NOT set the surface.
72  virtual bool setSurface(DtSurfaceID surfaceID);
73 
74  // Set the surface of the polygon with the specified surface.
75  // \note Checks to see if the same surface has already been added, so there
76  // is no need to eliminate duplicate surfaces after calling this function.
77  virtual bool setSurface(const DtSurface& newSurface);
78 
79  // get the vertex/surface/memory manager associated with the polygon
80  virtual const DtVertexManager* vertexManager() const;
81  virtual const DtSurfaceManager* surfaceManager() const;
82  virtual const DtMemoryManager* memoryManager() const;
83 
84  // debugging aid function
85  virtual void dump(int indentLevel) const;
86 
87  // Applies the specified transform to its vertices. If the flag
88  // is true, will create new vertices instead of modifying existing
89  // ones. Returns false if the transformation fails for any reason.
90  virtual bool applyTransform(const DtHomogeneousTransformMatrix& matrix,
91  bool createNewVertices);
92 
93  // UNSAFE PUBLIC FUNCTIONS
94  // These functions either modify internal state, create
95  // instances of the class that are not fully formed, or
96  // expose implementation details of the class that may change
97  // in future releases.
98  // They do NOT enforce the invariants of the class.
99 
100  // default constructor
102 
103  // constructor with number of vertices
104  DtPolygonIndirect(unsigned int numVertices, DtMemoryManager* memMgr);
105 
106  // constructor with number of vertices, vertex manager and
107  // surface manager to index into; uses DtMemoryManager to allocate
108  // index array.
109  DtPolygonIndirect(unsigned int numVertices,
110  DtVertexManager* vertMgr,
111  DtSurfaceManager* surfMgr,
112  DtMemoryManager* memMgr);
113 
114  // set the vertex manager, surface manager, memory manager
115  // and vertex ID list associated with the polygon
116  virtual void setVertexManager(DtVertexManager* vertMgr);
117  virtual void setSurfaceManager(DtSurfaceManager* surfMgr);
118 
119  // Sets the memory manager. The polygon does *not* take ownership of the
120  // memory manager - it just references it.
121  // @note The memMgr parameter should not be a 0 pointer. The invariant
122  // specifies that the memory manager always be valid, and if it is not, the
123  // behavior is @b undefined.
124  virtual void setMemoryManager(DtMemoryManager* memMgr);
125 
126  // get i-th vertex ID of the polygon
127  // returns false if localIndex is not a valid index into the
128  // list of vertex IDs
129  virtual bool getVertexID(DtVertexID& id, unsigned int localIndex) const;
130  // get the i-th vertex ID of the polygon.
131  // Requires that i be a valid vertex index.
132  virtual int getVertexID(unsigned int localIndex) const;
133 
134  // get the surface ID associated with the polygon
135  virtual DtSurfaceID getSurfaceID() const;
136 
137  // get the index list associated with the polygon
138  virtual const DtVertexID* indexList() const;
139 
140  // determine if all the vertices have been specified
141  virtual bool isFull() const;
142 
143  // add a vertex to the polygon. Returns the index into the polygon's
144  // local list of vertexIDs associated with the newly added vertex ID.
145  virtual int addVertex(DtVertexID vertexID);
146 
147  // specify the maximum size of the polygon; initializes the index
148  // array to the specified size;
149  virtual void setNumberOfVertices(unsigned int n);
150 
151  virtual int sizeInBytes() const;
152 
153 protected:
154  bool testInvariant() const;
155 
156  virtual void init();
157 
158 protected:
161  DtVertexID* myIndexList; // an array of size mySize to hold the indices.
162  unsigned int myVertexCount; //number of vertices specified thus far.
165 };
166 
167 //returns the type of gdb node
169 {
171 }
172 
173 // get the vertex manager associated with the polygon
175 {
176  assert(testInvariant());
177  return myVertexManager;
178 }
179 
180 // set the vertex manager associated with the polygon
182 {
183  assert(vertMgr);
184  myVertexManager = vertMgr;
185 }
186 
187 // get the surface manager associated with the polygon
189 {
190  assert(testInvariant());
191  return mySurfaceManager;
192 }
193 
194 // set the surface manager associated with the polygon
196 {
197  assert(surfMgr);
198  mySurfaceManager = surfMgr;
199  // every polygon is created with a surface type of 0
200  // as soon as there is a surface manager, add 1 to the polygon count of this
201  // surface
203 }
204 
205 // get the memory manager associated with the polygon
207 {
208  assert(testInvariant());
209  return myMemoryManager;
210 }
211 
213 {
214  assert(memMgr);
215  myMemoryManager = memMgr;
216 }
217 
219 {
221 }
222 
223 inline const DtPoint& DtPolygonIndirect::getVertex(unsigned int localIndex) const
224 {
225  DtVertexID vertexID = myIndexList[localIndex];
226  return myVertexManager->vertex(vertexID);
227 }
228 
229 #endif

Document ID: Generated on Tue Mar 8 22:13:38 EST 2016 from SVN revision 162938
Copyright © 2005-2015 VT MÄK. All Rights Reserved (www.mak.com)