VR-Forces 4.10 Class Documentation
Home
Modules
Namespaces
Classes
Files
Examples
Behavior Models
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Properties
Friends
Macros
Groups
Pages
include
gdb
vertexManager.h
Go to the documentation of this file.
1
/*********************************************************************
2
** Copyright (c) 1998 MaK Technologies, Inc.
3
** All rights reserved.
4
*********************************************************************/
5
/*********************************************************************
6
** $RCSfile: vtxMgr.h,v $ $Revision: 1.11 $ $State: Exp $
7
*********************************************************************/
8
9
#ifndef vertexManager_H_
10
#define vertexManager_H_
11
12
#include "
gdb/gdbDefines.h
"
13
#include "
geometry/point.h
"
14
#include <vector>
15
16
typedef
int
DtVertexID
;
17
18
#define DEFAULT_VERT_MGR_EXPANSION_AMOUNT 50000
19
20
//
21
// class DtVertexManager:
22
//
23
// DtVertexManager represents a general vertex list. It is used in
24
// DtPolygonIndirect and in various types of Features.
25
//
26
class
DT_DLL_gdb
DtVertexManager
27
{
28
public
:
29
30
// default constructor
31
DtVertexManager
();
32
33
// additional constructor
34
DtVertexManager
(
unsigned
int
size
);
35
36
// destructor
37
virtual
~
DtVertexManager
();
38
39
// copy constructor
40
DtVertexManager
(
const
DtVertexManager
& orig);
41
42
// assignment operator
43
DtVertexManager
& operator=(
const
DtVertexManager
& orig);
44
45
// If the vertex associated with the specified vertex ID is managed by
46
// the vertex manager, returns true and sets retVal to be a reference to
47
// the associated vertex. Otherwise, returns false.
48
virtual
bool
vertex(
DtVertexID
vertID,
DtVertex
& vertex)
const
;
49
50
// Provided for performance reasons.
51
// ASSUMES that the ID provided is valid.
52
virtual
DtVertex
& vertex(
DtVertexID
vertID);
53
virtual
const
DtVertex
& vertex(
DtVertexID
vertID)
const
;
54
55
// add vertex v to the DtVertexManager object.
56
// If allowDuplicate is true, then the vertex manager will add the
57
// vertex even if it is could be considered a duplicate of an existing
58
// managed vertex. vertID will be set to a new vertex ID associated with
59
// the newly added vertex.
60
// If the manager does not allow duplicates (see allowDuplicates below),
61
// vertID will be set to the ID of the first vertex it finds that is within
62
// tolerance of being equal to it.
63
// If it doesn't find an approximately equal vertex, it adds it as a
64
// new vertex and sets vertID to the associated ID.
65
// If it fails to add the vertex due to lack of memory, it throws a
66
// std::bad_alloc exception. If for some other reason, it cannot add the
67
// vertex at all, it returns false and leaves vertID untouched.
68
// \throws std:bad_alloc
69
virtual
bool
addVertex(
const
DtVertex
& vertex,
70
DtVertexID
& vertID,
71
const
double
tolerance = 0.0000);
72
73
// Analyzes the managed vertices and removes multiple instances of
74
// the same vertex where the same is defined by the fitness function.
75
// All duplicate vertices will be collapsed and mapped to one vert ID.
76
// If the manager cannot remove the duplicates for any reason, it returns
77
// false.
78
// Otherwise, it removes the duplicates and sets oldIDToNewIDMapping[OldID]
79
// to be a the new vertex ID that is associated with the original ID's vertex.
80
// This function guarantees that all original IDs will be valid indices into
81
// the oldIDToNewIDMapping. The user is responsible for deleting the memory
82
// allocated by this function for oldIDToNewIDMapping. (use delete[]).
83
virtual
bool
removeDuplicates(
double
tolerance,
84
int
& numDuplicates,
85
int
& numEntries,
86
DtVertexID
*& oldIDToNewIDMapping);
87
88
// Returns the number of vertices currently managed by the manager.
89
virtual
unsigned
int
numberOfVertices()
const
;
90
91
// Determines if a given vertex ID is valid. Returns true if the
92
// ID maps to a managed vertex and false if it doesn't.
93
virtual
bool
isValidID(
DtVertexID
vertID)
const
;
94
95
virtual
bool
assignFrom(
const
DtVertex
* vertices,
int
numVertices);
96
97
// debugging aid
98
virtual
void
dump(
int
indexLevel)
const
;
99
100
// If numVertices is greater than the current number of vertices managed,
101
// the the vertex manager increases its storage to be able to handle the
102
// specified number of vertices. This is useful when a large number of
103
// vertices will be given to the manager as it will reduce the number
104
// of memory operations the manager needs to use to grow to accommodate
105
// the new vertices as well as reduces the likelihood that the system will
106
// run out of memory.
107
// Returns true if the operation was a success or if the number specified
108
// is smaller than the amount already capable of being managed. Returns false
109
// otherwise. However, if the manager cannot be expanded due to lack of memory,
110
// it throws a std::bad_alloc exception.
111
// \throws std::bad_alloc
112
virtual
bool
expandToManage(
unsigned
int
numVertices =
DEFAULT_VERT_MGR_EXPANSION_AMOUNT
);
113
114
// Returns the size (in bytes) of this object
115
virtual
int
sizeInBytes();
116
117
// This const accessor allows direct access to the vertex array. In practice,
118
// only the vertex() accessor should be used to get vertices from the array.
119
// This access is currently only used by DtOpcodeGdbInterfaceImpl to provide
120
// the Opcode mesh interface with direct, read access to the array.
121
virtual
const
DtVertex
* getVertexArray();
122
123
// Returns the lowest and highest points (in the Z coordinate) stored in the manager
124
virtual
bool
extremePoints(
DtVertex
& highest,
DtVertex
& lowest)
const
;
125
126
// Sets/gets whether the manager should allow duplicate vertices when being
127
// added.
128
virtual
void
setAllowDuplicates(
bool
flag);
129
virtual
bool
allowDuplicates()
const
;
130
131
protected
:
132
// tests the invariants of the class.
133
// Should be called first in every const public member
134
// function and both first and last in every other function
135
virtual
bool
testInvariant
()
const
;
136
137
// Adds the vertex to the vertex manager and sets vertID to be the
138
// associated vertex ID. If it fails to add the vertex due to lack of memory,
139
// it throws std::bad_alloc exception. If it fails to add the vertex due to any
140
// other issue - it returns false.
141
// \throws std:bad_alloc
142
bool
addNewVertex(
const
DtVertex
& vertexToAdd,
DtVertexID
& vertID);
143
144
// Looks for a duplicate vertex in the group of managed vertices.
145
// If it finds one, it returns true and sets managedVertID to the
146
// associated vertex ID. If not, it returns false and leaves managedVertID
147
// alone.
148
// Does NOT sort - performance for large numbers of surfaces may be
149
// very slow. (O(n^2))
150
bool
isDuplicate(
const
DtVertex
& vertex,
151
DtVertexID
& managedVertID,
152
const
double
tol)
const
;
153
154
// Checks to see if the vertex associated with the specified
155
// ID is a duplicate of a vertex stored BEFORE the specified ID in
156
// the manager. If one is found, the function returns true and
157
// sets managedVertID to the associated vertex ID. If the comparisonID
158
// is not a valid ID, or if no duplicate is found BEFORE the specified ID,
159
// it returns false and leaves managedVertID alone.
160
// Does NOT sort - performance for large numbers of surfaces may be
161
// very slow. (O(n^2))
162
bool
isDuplicate(
const
DtVertexID
& comparisonVertID,
163
DtVertexID
& managedVertID,
164
const
double
tol)
const
;
165
166
// If the vertex manager is not managing any vertices, then
167
// expand to a default amount. If it is managing vertices,
168
// then expand by the specified amount. Maintains the order of the
169
// vertices managed.
170
// \throws std::bad_alloc if there is not enough memory to expand the array
171
virtual
bool
expandVertexArray(
unsigned
int
numToExpandBy);
172
173
unsigned
int
myNumberOfVertices
;
174
unsigned
int
myMaxNumberOfVertices
;
175
176
// Vector of vertices.
177
std::vector<DtVertex>
myVertexArray
;
178
179
// Memory-management flag for vertex array
180
bool
myArrayIsMemoryManaged
;
181
182
bool
myManagerAllowsDuplicates
;
183
};
184
188
inline
unsigned
int
DtVertexManager::numberOfVertices
()
const
189
{
190
return
myNumberOfVertices
;
191
}
192
193
#endif
point.h
size
voidpf void uLong size
Definition:
ioapi.h:39
testInvariant
*bool testInvariant() const
gdbDefines.h
DtVertexManager::myNumberOfVertices
unsigned int myNumberOfVertices
Definition:
vertexManager.h:173
DT_DLL_gdb
#define DT_DLL_gdb
Definition:
gdbDefines.h:25
DtVertexManager::myArrayIsMemoryManaged
bool myArrayIsMemoryManaged
Definition:
vertexManager.h:180
DtVertexManager
Definition:
vertexManager.h:26
DtVertexManager::myMaxNumberOfVertices
unsigned int myMaxNumberOfVertices
Definition:
vertexManager.h:174
DtVertexID
int DtVertexID
Definition:
vertexManager.h:16
DtVertexManager::numberOfVertices
virtual unsigned int numberOfVertices() const
*/
Definition:
vertexManager.h:188
DtVertexManager::myManagerAllowsDuplicates
bool myManagerAllowsDuplicates
Definition:
vertexManager.h:182
DtVertexManager::myVertexArray
std::vector< DtVertex > myVertexArray
Definition:
vertexManager.h:177
DEFAULT_VERT_MGR_EXPANSION_AMOUNT
#define DEFAULT_VERT_MGR_EXPANSION_AMOUNT
Definition:
vertexManager.h:18
int
DtPoint
Definition:
point.h:34
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
)