VR-Forces 4.1 Class Documentation
Home
Modules
Namespaces
Classes
Files
Examples
Behavior Models
File List
File Members
include
geometry
ssUniformAnalyzer.h
Go to the documentation of this file.
1
/*******************************************************************************
2
** Copyright (c) 2005 MAK Technologies, Inc.
3
** All rights reserved.
4
*******************************************************************************/
5
/*******************************************************************************
6
** $RCSfile: ssUniformAnalyzer.h,v $ $Revision: 1.7 $ $State: Exp $
7
*******************************************************************************/
8
#ifndef ssUniformAnalyzer_H_
9
#define ssUniformAnalyzer_H_
10
11
#include "
geometry/spatialSubdivision.h
"
12
#include "
geometry/simpleStats.h
"
13
#include <vlutil/vlConfig.h>
14
#include <map>
15
#include <vector>
16
17
23
24
template
<
typename
T>
25
class
DtSsUniformAnalyzer
26
{
27
public
:
28
29
typedef
unsigned
int
DtNumElementsInCell
;
30
typedef
unsigned
int
DtNumCells
;
31
typedef
std::map<DtNumElementsInCell, DtNumCells>
DtNumCellsWithNumElementsContainer
;
32
33
typedef
unsigned
int
DtElementFillRate
;
34
typedef
unsigned
int
DtNumElementsWithFillRate
;
35
typedef
std::map<DtElementFillRate, DtNumElementsWithFillRate>
DtElementFillRatesContainer
;
36
37
typedef
std::vector<unsigned int>
DtFillDistributionContainer
;
38
39
typedef
std::list<unsigned int>
DtFillModeContainer
;
40
41
42
DtSsUniformAnalyzer
(
const
DtSpatialSubdivision<T>
& spatialSubdivision);
43
44
// This object requires none of the big three to be defined. It *is* copyable,
45
// assignable, and destroyable. - The compiler will generate these.
46
// virtual ~DtSsUniformAnalyzer();
47
// DtSsUniformAnalyzer(const DtSsUniformAnalyzer& original);
48
// DtSsUniformAnalyzer& operator=(const DtSsUniformAnalyzer& original);
49
50
public
:
51
52
// @returns The number of empty cells in the SS.
53
unsigned
int
numEmptyCells
()
const
;
54
55
// @returns The number of non-empty cells in the SS.
56
unsigned
int
numNonEmptyCells
();
57
58
// @returns The largest number of elements contained in a single SS cell.
59
unsigned
int
maxFill
()
const
;
60
61
// @returns The smallest number of elements contained in a single SS cell.
62
// @note This is almost always zero, but for highly and/or evenly filled
63
// subdivisions, it may not be.
64
unsigned
int
minFill
()
const
;
65
66
// @returns The median fill rate for the spatial subdivision.
67
unsigned
int
medianFill
()
const
;
68
69
// @returns The average fill rate for the spatial subdivision.
70
float
averageFill
()
const
;
71
72
// Determines the fill rate mode for the spatial subdivision.
73
// @returns A container of cell sizes that are most common.
74
// For example, a spatial subdivision with 9 cells, with the fill values of:
75
// 3, 6, 4, 2, 0, 2, 6, 0, 0
76
// would have a single mode of 0. If, instead the values were:
77
// 6, 6, 4, 2, 0, 2, 6, 0, 0
78
// the SS would have two modes, 0 and 6.
79
//
80
DtFillModeContainer
fillMode
()
const
;
81
82
// @returns The fill rate statistical range for the SS.
83
unsigned
int
fillRange
()
const
;
84
85
// Determines the fill distribution for the spatial subdivision. This can be
86
// used to get the relative efficiency of the spatial subdivision, as
87
// it can point to areas of higher and lower utilization.
88
//
89
// @returns A container of the fill rates for each cell, where the index into the
90
// returned container is the same as the associated cell in the spatial subdivision,
91
// and the value is that cell's fill amount.
92
// For example, if the spatial subdivision contained 1000 cells, then the
93
// returned container's 500th element would contain the 500th cell's fill amount.
94
const
DtFillDistributionContainer
&
fillDistribution
()
const
;
95
96
// Determines the number of cells with the same number of elements. For example,
97
// the first entry in the returned container may be 17, 12. This would mean that
98
// there are 12 cells in the SS that have 17 elements referenced in them.
99
//
100
// @returns A container values, where the index into the container is the number
101
// of referenced elements, and the value at that index in the container is the number
102
// of cells that reference <index> numbers of elements.
103
const
DtNumCellsWithNumElementsContainer
&
numCellsWithNumElements
()
const
;
104
105
// Determines the number of cells that the elements are individually referenced in.
106
// For example, in the returned container, the index is equal to the number of
107
// cells and the value at that index is the number of elements that are stored
108
// in that many cells.
109
//
110
// @returns A container of pairs of data: the number of cells used to store
111
// the elements, and the number of elements stored individually in that many
112
// cells.
113
//
114
// For instance, if 100 items total are sorted spatially in the spatial
115
// subdivision, and 20 of those items happen to be referenced in 10 cells
116
// each, then the container would contain an entry with key 10 and value 20.
117
const
DtElementFillRatesContainer
&
elementFillRates
()
const
;
118
119
120
// Notify the SS analyzer that its spatial subdivision has changed.
121
void
spatialSubdivisionChanged
()
const
;
122
123
protected
:
124
125
// @returns A boolean indicating whether or not the statistics need to be
126
// generated or not.
127
bool
isStatsClean
()
const
;
128
129
// Sets the state of the statistics to be clean or unclean. When unclean,
130
// they need to be recalculated before they are valid.
131
void
setStatsClean
(
bool
yesOrNo)
const
;
132
133
// Analyzes the spatial subdivision, and calculates all statistics.
134
// @note When this is finished, the statistics are considered clean.
135
void
analyzeSs
()
const
;
136
137
private
:
138
139
// The spatial subdivision to reference.
140
const
DtSpatialSubdivision<T>
&
mySpatialSubdivision
;
141
143
// Holds the min, max, sum, and average of all cell size counts
145
mutable
DtSimpleStats<unsigned int>
mySimpleStats
;
146
147
// The number of empty cells in the spatial subdivision
148
mutable
unsigned
int
myNumEmptyCells
;
149
// The number of cells referencing at least one element.
150
mutable
unsigned
int
myNumNonEmptyCells
;
151
153
// Fill stats.
154
// For these statistics, fill is defined as the number of elements in a
155
// spatial subdivision cell.
157
158
// Essentially a container with numCells elements that contains the fill
159
// amount of each cell in the spatial subdivision.
160
// @note If this data was plotted, it might give an idea of the efficiency
161
// graphically. (You could see areas of higher and lower cell fill rates.)
162
mutable
DtFillDistributionContainer
myFillDistribution
;
163
164
// The median fill amount.
165
mutable
unsigned
int
myFillMedian
;
166
167
// A container of the fill modes (most commonly occurring cell sizes).
168
mutable
DtFillModeContainer
myFillMode
;
169
170
// A container that maps the number of cells referencing N elements to the
171
// number of elements. For example, if 10 cells reference 5 elements, and
172
// 15 reference 1, and 20 reference 0, the this container would have 3
173
// entries, of those three pairs.
174
mutable
DtNumCellsWithNumElementsContainer
myNumCellsWithNumElements
;
175
176
// This container maps between the number of elements referenced in N cells,
177
// and the number of elements. It's essentially the opposite of the previous
178
// container, as it is concerned with how many elements are stored over
179
// how many cells. The higher the number of elements that are stored in more
180
// cells, the more likely that the subdivision is an overly high resolution.
181
mutable
DtElementFillRatesContainer
myNumElementsReferencedInNumCells
;
182
183
// This group of statistics is not trivial to calculate, especially for very
184
// large datasets. As a result, don't calculate the values until requested,
185
// and then not again until the spatial subdivision has changed.
186
mutable
bool
myStatsClean
;
187
};
188
189
//------------------------------------------------------
190
// INLINE METHODS
191
//------------------------------------------------------
192
// include the inline code
193
#define SSUNIFORMANALYZER_HEADER
194
#include "geometry/ssUniformAnalyzer.inl"
195
#undef SSUNIFORMANALYZER_HEADER
196
197
#endif
Document ID: Generated on Tue Jan 29 18:21:16 EST 2013 from SVN revision 123193
Copyright © 2005-2013 VT MÄK Inc. All Rights Reserved (
www.mak.com
)