63 typename std::vector<T>::const_iterator begin = vec.begin(), end = vec.end();
64 int res = std::upper_bound(begin, end, value) - begin - 1;
70 void Voxelize(std::vector<VUSolid*>& solids, std::vector<UTransform3D*>& transforms);
73 void Voxelize(std::vector<VUFacet*>& facets);
92 inline const std::vector<UVoxelBox>&
GetBoxes()
const
98 return fBoundaries[
index];
105 for (
int i = 0; i <= 2; ++i)
107 const std::vector<double>& boundary =
GetBoundary(i);
110 else if (n == (
int) boundary.size() - 1) n--;
117 return fNPerSlice * 8 *
sizeof(
unsigned int);
130 if (x < 0 || y < 0 || z < 0)
return -1;
131 int maxX = fBoundaries[0].size();
132 int maxY = fBoundaries[1].size();
133 int index = x + y * maxX + z * maxX * maxY;
144 for (
int i = 0; i <= 2; ++i)
145 if (p[i] < *fBoundaries[i].begin() || p[i] > *fBoundaries[i].end())
return false;
147 for (
int i = 0; i <= 2; ++i)
155 int maxX = fBoundaries[0].size();
156 int maxY = fBoundaries[1].size();
160 int index = x + y * maxX + z * maxX * maxY;
171 return fEmpty[
index];
180 ratioOfReduction = fReductionRatio;
188 return fCountOfVoxels;
191 inline long long CountVoxels(std::vector<double> boundaries[])
const
193 long long sx = boundaries[0].size() - 1;
194 long long sy = boundaries[1].size() - 1;
195 long long sz = boundaries[2].size() - 1;
221 inline const std::vector<int>&
GetCandidates(std::vector<int>& curVoxel)
const
224 if (voxelsIndex >= 0 && !fEmpty[voxelsIndex])
226 return fCandidates[voxelsIndex];
228 return fNoCandidates;
233 return fVoxelBoxes.size();
238 return fVoxelBoxes[i];
243 return fVoxelBoxesCandidates[i];
248 return fTotalCandidates;
263 static int fDefaultVoxelsCount;
265 std::vector<UVoxelBox> fVoxelBoxes;
267 std::vector<std::vector<int> > fVoxelBoxesCandidates;
269 mutable std::map<int, std::vector<int> > fCandidates;
271 const std::vector<int> fNoCandidates;
273 long long fCountOfVoxels;
277 std::string GetCandidatesAsString(
const UBits& bits);
279 void CreateSortedBoundary(std::vector<double>& boundaryRaw,
int axis);
281 void BuildBoundaries();
283 void BuildReduceVoxels(std::vector<double> fBoundaries[],
UVector3 reductionRatio);
285 void BuildReduceVoxels2(std::vector<double> fBoundaries[],
UVector3 reductionRatio);
288 void BuildVoxelLimits(std::vector<VUSolid*>& solids, std::vector<UTransform3D*>& transforms);
289 #endif // USOLIDSONLY
291 void BuildVoxelLimits(std::vector<VUFacet*>& facets);
295 void BuildBitmasks(std::vector<double> fBoundaries[],
UBits bitmasks[]);
297 void SetReductionRatio(
int maxVoxels,
UVector3& reductionRatio);
299 void CreateMiniVoxels(std::vector<double> fBoundaries[],
UBits bitmasks[]);
303 std::vector<UVoxelBox> fBoxes;
305 std::vector<double> fBoundaries[3];
307 std::vector<int> fCandidatesCounts[3];
309 int fTotalCandidates;
346 #endif // USOLIDSONLY
int GetVoxelsIndex(const std::vector< int > &voxels) const
const std::vector< double > & GetBoundary(int index) const
int GetVoxelsIndex(int x, int y, int z) const
double DistanceToNext(const UVector3 &point, const UVector3 &direction, std::vector< int > &curVoxel) const
typedef int(XMLCALL *XML_NotStandaloneHandler)(void *userData)
int GetTotalCandidates() const
void SetMaxVoxels(int max)
bool UpdateCurrentVoxel(const UVector3 &point, const UVector3 &direction, std::vector< int > &curVoxel) const
void GetVoxel(std::vector< int > &curVoxel, const UVector3 &point) const
bool Contains(const UVector3 &point) const
long long GetCountOfVoxels() const
int GetMaxVoxels(UVector3 &ratioOfReduction)
double DistanceToFirst(const UVector3 &point, const UVector3 &direction) const
static int BinarySearch(const std::vector< T > &vec, T value)
int GetVoxelBoxesSize() const
static double MinDistanceToBox(const UVector3 &aPoint, const UVector3 &f)
int GetCandidatesVoxelArray(const UVector3 &point, std::vector< int > &list, UBits *crossed=NULL) const
long long CountVoxels(std::vector< double > boundaries[]) const
const UVoxelBox & GetVoxelBox(int i) const
bool GetPointVoxel(const UVector3 &p, std::vector< int > &voxels) const
const std::vector< int > & GetCandidates(std::vector< int > &curVoxel) const
T max(const T t1, const T t2)
brief Return the largest of the two arguments
const std::vector< int > & GetVoxelBoxCandidates(int i) const
void GetCandidatesVoxel(std::vector< int > &voxels)
static int GetDefaultVoxelsCount()
int GetPointIndex(const UVector3 &p) const
int GetBitsPerSlice() const
const XML_Char int const XML_Char * value
void DisplayVoxelLimits()
const std::vector< UVoxelBox > & GetBoxes() const
double SafetyToBoundingBox(const UVector3 &point) const
const UBits & Empty() const
static void SetDefaultVoxelsCount(int count)
void Voxelize(std::vector< VUSolid * > &solids, std::vector< UTransform3D * > &transforms)
bool IsEmpty(int index) const