 |
ACloudViewer
3.9.4
A Modern Library for 3D Data Processing
|
Go to the documentation of this file.
21 #define OCTREE_CODES_64_BITS
30 class GenericIndexedCloudPersist;
31 class GenericProgressCallback;
32 class NormalizedProgress;
47 static unsigned char GET_BIT_SHIFT(
unsigned char level);
54 static int OCTREE_LENGTH(
int level);
64 #ifdef OCTREE_CODES_64_BITS
65 static const int MAX_OCTREE_LEVEL = 21;
67 static const int MAX_OCTREE_LEVEL = 10;
74 #ifdef OCTREE_CODES_64_BITS
84 static const int MAX_OCTREE_LENGTH = (1 << MAX_OCTREE_LEVEL);
89 static const CellCode INVALID_CELL_CODE = (~static_cast<CellCode>(0));
114 : point(P), pointIndex(index), squareDistd(-1.0) {}
118 : point(P), pointIndex(index), squareDistd(d2) {}
237 : queryPoint(0, 0, 0),
239 minNumberOfNeighbors(1),
242 maxSearchSquareDistd(0),
243 alreadyVisitedNeighbourhoodSize(0),
244 theNearestPointIndex(0) {}
249 #ifdef TEST_CELLS_FOR_SPHERICAL_NN
272 #ifdef TEST_CELLS_FOR_SPHERICAL_NN
275 minOutD2 = radius + cellDiag;
276 minOutD2 *= minOutD2;
277 maxInD2 = radius - cellDiag;
288 #ifdef TEST_CELLS_FOR_SPHERICAL_NN
312 : theIndex(index), theCode(code) {}
316 : theIndex(ic.theIndex), theCode(ic.theCode) {}
335 return a.theCode < b.theCode;
346 return a.theIndex < b.theIndex;
410 virtual void clear();
437 const CCVector3* pointsMinFilter =
nullptr,
438 const CCVector3* pointsMaxFilter =
nullptr,
447 return m_numberOfProjectedPoints;
475 return m_fillIndexes + 6 * level;
486 return m_fillIndexes + 6 * level + 3;
495 return m_cellSize[level];
505 void getCellDistanceFromBorders(
const Tuple3i& cellPos,
507 int* cellDists)
const;
518 void getCellDistanceFromBorders(
const Tuple3i& cellPos,
520 int neighbourhoodLength,
521 int* cellDists)
const;
539 bool clearOutputCloud =
true)
const;
549 bool getPointsInCell(CellCode cellCode,
552 bool isCodeTruncated =
false,
553 bool clearOutputCloud =
true)
const;
565 cellCodesContainer& cellCodes,
568 bool areCodesTruncated =
false)
const;
588 unsigned findPointNeighbourhood(
591 unsigned maxNumberOfNeighbors,
593 double& maxSquareDist,
594 double maxSearchDist = 0,
595 int* finalNeighbourhoodSize =
nullptr)
const;
605 double findTheNearestNeighborStartingFromCell(
606 NearestNeighboursSearchStruct& nNSS)
const;
617 unsigned findNearestNeighborsStartingFromCell(
618 NearestNeighboursSearchStruct& nNSS,
619 bool getOnlyPointsWithValidScalar =
false)
const;
633 int findNeighborsInASphereStartingFromCell(
634 NearestNeighboursSearchStruct& nNSS,
636 bool sortValues =
true)
const;
651 int getPointsInSphericalNeighbourhood(
const CCVector3& sphereCenter,
653 NeighboursSet& neighbours,
654 unsigned char level)
const;
682 onlyPositiveDir(false) {}
694 std::size_t getPointsInCylindricalNeighbourhood(
695 CylindricalNeighbourhood& params)
const;
714 currentHalfLength(0),
715 prevMinCornerPos(-1, -1, -1),
716 prevMaxCornerPos(0, 0, 0) {}
723 std::size_t getPointsInCylindricalNeighbourhoodProgressive(
724 ProgressiveCylindricalNeighbourhood& params)
const;
741 : center(0, 0, 0), axes(nullptr), dimensions(0, 0, 0), level(0) {}
749 std::size_t getPointsInBoxNeighbourhood(BoxNeighbourhood& params)
const;
763 static CellCode GenerateTruncatedCellCode(
const Tuple3i& cellPos,
764 unsigned char level);
766 #ifndef OCTREE_CODES_64_BITS
767 static CellCode GenerateTruncatedCellCode(
const Tuple3s& pos,
769 unsigned char level);
784 cellPos.
x =
static_cast<int>( (thePoint->
x - m_dimMin.x) / cs);
785 cellPos.
y =
static_cast<int>( (thePoint->
y - m_dimMin.y) / cs);
786 cellPos.
z =
static_cast<int>( (thePoint->
z - m_dimMin.z) / cs);
800 unsigned char level)
const {
801 assert(level <= MAX_OCTREE_LEVEL);
803 getTheCellPosWhichIncludesThePoint(thePoint, cellPos);
805 const unsigned char dec = MAX_OCTREE_LEVEL - level;
826 bool& inBounds)
const {
827 assert(level <= MAX_OCTREE_LEVEL);
829 getTheCellPosWhichIncludesThePoint(thePoint, cellPos);
831 inBounds = (cellPos.
x >= 0 && cellPos.
x < MAX_OCTREE_LENGTH &&
832 cellPos.
y >= 0 && cellPos.
y < MAX_OCTREE_LENGTH &&
833 cellPos.
z >= 0 && cellPos.
z < MAX_OCTREE_LENGTH);
835 const unsigned char dec = MAX_OCTREE_LEVEL - level;
849 void getCellPos(CellCode code,
852 bool isCodeTruncated)
const;
865 bool isCodeTruncated =
false)
const {
867 getCellPos(code, level, cellPos, isCodeTruncated);
869 return computeCellCenter(cellPos, level, center);
893 #ifndef OCTREE_CODES_64_BITS
894 inline void computeCellCenter(
const Tuple3s& cellPos,
919 void computeCellLimits(CellCode code,
923 bool isCodeTruncated =
false)
const;
933 unsigned char findBestLevelForAGivenNeighbourhoodSizeExtraction(
943 unsigned char findBestLevelForComparisonWithOctree(
944 const DgmOctree* theOtherOctree)
const;
951 unsigned char findBestLevelForAGivenPopulationPerCell(
952 unsigned indicativeNumberOfPointsPerCell)
const;
959 unsigned char findBestLevelForAGivenCellNumber(
960 unsigned indicativeNumberOfCells)
const;
964 return m_thePointsAndTheirCellCodes[index].theCode;
975 bool getCellCodes(
unsigned char level,
976 cellCodesContainer& vec,
977 bool truncatedCodes =
false)
const;
987 bool getCellIndexes(
unsigned char level, cellIndexesContainer& vec)
const;
998 bool getCellCodesAndIndexes(
unsigned char level,
1000 bool truncatedCodes =
false)
const;
1011 void diff(
const cellCodesContainer& codesA,
1012 const cellCodesContainer& codesB,
1013 cellCodesContainer& diffA,
1014 cellCodesContainer& diffB)
const;
1030 const cellsContainer& codesA,
1031 const cellsContainer& codesB,
1039 assert(level <= MAX_OCTREE_LEVEL);
1040 return m_cellCount[level];
1048 double computeMeanOctreeDensity(
unsigned char level)
const;
1063 if (d2 > d1) d1 = d2;
1065 d2 = std::abs(cellCenter.
z - queryPoint.
z);
1066 return cs / 2 - (d2 > d1 ? d2 : d1);
1088 int extractCCs(
const cellCodesContainer& cellCodes,
1089 unsigned char level,
1108 int extractCCs(
unsigned char level,
1139 unsigned executeFunctionForAllCellsStartingAtLevel(
1140 unsigned char startingLevel,
1141 octreeCellFunc func,
1142 void** additionalParameters,
1143 unsigned minNumberOfPointsPerCell,
1144 unsigned maxNumberOfPointsPerCell,
1145 bool multiThread =
true,
1147 const char* functionTitle =
nullptr,
1148 int maxThreadCount = 0);
1169 unsigned executeFunctionForAllCellsAtLevel(
1170 unsigned char level,
1171 octreeCellFunc func,
1172 void** additionalParameters,
1173 bool multiThread =
false,
1175 const char* functionTitle =
nullptr,
1176 int maxThreadCount = 0);
1184 double maxRadiusOrFov,
1187 RayCastProcess process,
1188 std::vector<PointDescriptor>& output)
const;
1192 return m_theAssociatedCloud;
1197 return m_thePointsAndTheirCellCodes;
1202 static bool MultiThreadSupport();
1258 int m_fillIndexes[(MAX_OCTREE_LEVEL + 1) * 6];
1260 unsigned m_cellCount[MAX_OCTREE_LEVEL + 1];
1262 unsigned m_maxCellPopulation[MAX_OCTREE_LEVEL + 1];
1264 double m_averageCellPopulation[MAX_OCTREE_LEVEL + 1];
1266 double m_stdDevCellPopulation[MAX_OCTREE_LEVEL + 1];
1281 void updateMinAndMaxTables();
1285 void updateCellSizeTable();
1289 void updateCellCountTable();
1296 void computeCellsStatistics(
unsigned char level);
1306 void getNeighborCellsAround(
const Tuple3i& cellPos,
1308 int neighbourhoodLength,
1309 unsigned char level)
const;
1318 void getPointsInNeighbourCellsAround(
1320 int neighbourhoodLength,
1321 bool getOnlyPointsWithValidScalar =
false)
const;
1323 #ifdef TEST_CELLS_FOR_SPHERICAL_NN
1324 void getPointsInNeighbourCellsAround(
1326 int minNeighbourhoodLength,
1327 int maxNeighbourhoodLength)
const;
1340 unsigned getCellIndex(
CellCode truncatedCellCode,
1341 unsigned char bitDec)
const;
1353 unsigned getCellIndex(
CellCode truncatedCellCode,
1354 unsigned char bitDec,
1356 unsigned end)
const;
Generic file read and write utility for python interface.
Definition: CloudViewerConfig.cpp:12
static PointCoordinateType ComputeMinDistanceToCellBorder(const CCVector3 &queryPoint, PointCoordinateType cs, const CCVector3 &cellCenter)
Definition: DgmOctree.h:1057
Tuple3i prevMaxCornerPos
Previous search box (max corner)
Definition: DgmOctree.h:710
const CellCode & getCellCode(unsigned index) const
Returns the ith cell code.
Definition: DgmOctree.h:963
void computeCellCenter(CellCode code, unsigned char level, CCVector3 ¢er, bool isCodeTruncated=false) const
Definition: DgmOctree.h:862
IndexAndCode(unsigned index, CellCode code)
Constructor from an index and a code.
Definition: DgmOctree.h:311
CCVector3 center
Cylinder center.
Definition: DgmOctree.h:660
Type x
Definition: CVGeom.h:137
PointCoordinateType radius
Cylinder radius.
Definition: DgmOctree.h:664
Definition: GenericOctree.h:17
const cellsContainer & pointsAndTheirCellCodes() const
Returns the octree 'structure'.
Definition: DgmOctree.h:1196
NeighboursSet potentialCandidates
Vector to store potential candidates for the next pass.
Definition: DgmOctree.h:706
static bool codeComp(const IndexAndCode &a, const IndexAndCode &b)
Compares two IndexAndCode instances based on their code.
Definition: DgmOctree.h:333
unsigned char level
subdivision level at which to apply the extraction process
Definition: DgmOctree.h:670
Structure used during nearest neighbour search.
Definition: DgmOctree.h:136
bool operator<(const IndexAndCode &iac) const
Code-based 'less than' comparison operator.
Definition: DgmOctree.h:319
void computeCellCenter(const Tuple3i &cellPos, unsigned char level, CCVector3 ¢er) const
Definition: DgmOctree.h:878
std::vector< unsigned int > cellIndexesContainer
Octree cell indexes container.
Definition: DgmOctree.h:95
std::vector< IndexAndCode > cellsContainer
Container of 'IndexAndCode' structures.
Definition: DgmOctree.h:351
PointDescriptor(const CCVector3 *P, unsigned index)
Constructor with point and its index.
Definition: DgmOctree.h:113
Definition: GenericProgressCallback.h:20
const CCVector3 & getOctreeMaxs() const
Returns the higher boundaries of the octree.
Definition: DgmOctree.h:458
IndexAndCode()
Default constructor.
Definition: DgmOctree.h:308
Internal structure used to perform a top-down scan of the octree.
Definition: DgmOctree.h:1210
Association between an index and the code of an octree cell.
Definition: DgmOctree.h:301
Definition: DgmOctree.h:658
bool(*)(const octreeCell &, void **, NormalizedProgress *) octreeCellFunc
Definition: DgmOctree.h:395
double squareDistd
Point associated distance value.
Definition: DgmOctree.h:107
Octree cell descriptor.
Definition: DgmOctree.h:354
CylindricalNeighbourhood()
Default constructor.
Definition: DgmOctree.h:676
unsigned pos
Cell position inside subdivision level.
Definition: DgmOctree.h:1215
const unsigned & getCellNumber(unsigned char level) const
Returns the number of cells for a given level of subdivision.
Definition: DgmOctree.h:1038
unsigned index
First point index in associated NeighboursSet.
Definition: DgmOctree.h:140
unsigned pointIndex
Point index.
Definition: DgmOctree.h:105
IndexAndCode(const IndexAndCode &ic)
Copy constructor.
Definition: DgmOctree.h:315
unsigned theIndex
index
Definition: DgmOctree.h:303
const DgmOctree * parentOctree
Octree to which the cell belongs.
Definition: DgmOctree.h:359
bool operator>(const IndexAndCode &iac) const
Code-based 'greater than' comparison operator.
Definition: DgmOctree.h:324
BoxNeighbourhood()
Default constructor.
Definition: DgmOctree.h:740
CCVector3 m_dimMax
Max coordinates of the octree bounding-box.
Definition: DgmOctree.h:1245
PointDescriptor()
Default constructor.
Definition: DgmOctree.h:110
const int * getMinFillIndexes(unsigned char level) const
Definition: DgmOctree.h:474
CellCode truncatedCode
Truncated cell code.
Definition: DgmOctree.h:361
The octree structure used throughout the library.
Definition: DgmOctree.h:39
unsigned m_numberOfProjectedPoints
Number of points projected in the octree.
Definition: DgmOctree.h:1236
bool onlyPositiveDir
Definition: DgmOctree.h:673
unsigned getNumberOfProjectedPoints() const
Returns the number of points projected into the octree.
Definition: DgmOctree.h:446
a[190]
Definition: essential_matrix_poly.h:19
unsigned char level
Subdivision level.
Definition: DgmOctree.h:1219
CCVector3 dir
Cylinder axis (direction)
Definition: DgmOctree.h:662
Type z
Definition: CVGeom.h:137
ReferenceCloud * points
Set of points lying inside this cell.
Definition: DgmOctree.h:365
unsigned index
Cell index in octree structure (see m_thePointsAndTheirCellCodes)
Definition: DgmOctree.h:363
A generic 3D point cloud with index-based and presistent access to points.
Definition: GenericIndexedCloudPersist.h:18
Definition: DgmOctree.h:699
CCVector3 center
Box center.
Definition: DgmOctree.h:729
CCVector3 center
Cell center.
Definition: DgmOctree.h:138
@ RC_NEAREST_POINT
Definition: DgmOctree.h:1179
unsigned char level
Cell level of subdivision.
Definition: DgmOctree.h:367
CCVector3 m_dimMin
Min coordinates of the octree bounding-box.
Definition: DgmOctree.h:1243
NeighboursSet neighbours
Neighbour points falling inside the box.
Definition: DgmOctree.h:735
std::vector< PointDescriptor > NeighboursSet
A set of neighbours.
Definition: DgmOctree.h:133
CCVector3 m_pointsMax
Definition: DgmOctree.h:1252
const int * getMaxFillIndexes(unsigned char level) const
Definition: DgmOctree.h:485
A very simple point cloud (no point duplication)
Definition: ReferenceCloud.h:29
ProgressiveCylindricalNeighbourhood()
Definition: DgmOctree.h:712
CCVector3 * axes
Box axes (optional)
Definition: DgmOctree.h:731
std::vector< CellDescriptor > NeighbourCellsSet
A set of neighbour cells descriptors.
Definition: DgmOctree.h:150
static bool distComp(const PointDescriptor &a, const PointDescriptor &b)
Comparison operator.
Definition: DgmOctree.h:126
PointCoordinateType currentHalfLength
Current search depth.
Definition: DgmOctree.h:701
unsigned CellCode
Type of the code of an octree cell.
Definition: DgmOctree.h:78
CCVector3 dimensions
Box dimensions.
Definition: DgmOctree.h:733
GenericIndexedCloudPersist * associatedCloud() const
Returns the associated cloud.
Definition: DgmOctree.h:1191
Tuple3i prevMinCornerPos
Previous search box (min corner)
Definition: DgmOctree.h:708
Type y
Definition: CVGeom.h:137
RayCastProcess
Ray casting processes.
Definition: DgmOctree.h:1179
void getTheCellPosWhichIncludesThePoint(const CCVector3 *thePoint, Tuple3i &cellPos, unsigned char level, bool &inBounds) const
Definition: DgmOctree.h:823
unsigned char level
subdivision level at which to apply the extraction process
Definition: DgmOctree.h:737
NeighboursSet neighbours
Neighbour points falling inside the cylinder.
Definition: DgmOctree.h:668
unsigned m_nearestPow2
Definition: DgmOctree.h:1240
Input/output parameters structure for getPointsInBoxNeighbourhood.
Definition: DgmOctree.h:727
CellCode theCode
cell code
Definition: DgmOctree.h:305
static bool indexComp(const IndexAndCode &a, const IndexAndCode &b)
Compares two IndexAndCode instances based on their index.
Definition: DgmOctree.h:344
Definition: GenericProgressCallback.h:78
float PointCoordinateType
Type of the coordinates of a (N-D) point.
Definition: CVTypes.h:16
const CCVector3 & getOctreeMins() const
Returns the lower boundaries of the octree.
Definition: DgmOctree.h:453
unsigned elements
Number of points in cell.
Definition: DgmOctree.h:1217
cellsContainer m_thePointsAndTheirCellCodes
The coded octree structure.
Definition: DgmOctree.h:1230
PointCoordinateType maxHalfLength
Cylinder (half) length.
Definition: DgmOctree.h:666
std::vector< CellCode > cellCodesContainer
Octree cell codes container.
Definition: DgmOctree.h:92
CCVector3 m_pointsMin
Definition: DgmOctree.h:1249
CellDescriptor(const CCVector3 &C, unsigned i)
Constructor from a point and an index.
Definition: DgmOctree.h:146
const PointCoordinateType & getCellSize(unsigned char level) const
Returns the octree cells length for a given level of subdivision.
Definition: DgmOctree.h:494
const CCVector3 * point
Point.
Definition: DgmOctree.h:103
PointDescriptor(const CCVector3 *P, unsigned index, double d2)
Constructor with point, its index and square distance.
Definition: DgmOctree.h:117
Structure used during nearest neighbour search.
Definition: DgmOctree.h:101
void getTheCellPosWhichIncludesThePoint(const CCVector3 *thePoint, Tuple3i &cellPos, unsigned char level) const
Definition: DgmOctree.h:798
GenericIndexedCloudPersist * m_theAssociatedCloud
Associated cloud.
Definition: DgmOctree.h:1233
constexpr double SQRT_3
Square root of 3.
Definition: CVConst.h:29
#define CV_CORE_LIB_API
Definition: CVCoreLibWin.h:15
void getTheCellPosWhichIncludesThePoint(const CCVector3 *thePoint, Tuple3i &cellPos) const
Definition: DgmOctree.h:779