29 #ifndef MULTI_GRID_OCTREE_DATA_INCLUDED
30 #define MULTI_GRID_OCTREE_DATA_INCLUDED
33 # pragma GCC system_header
38 #define GRADIENT_DOMAIN_SOLUTION 1
71 #define FORCE_NEUMANN_FIELD 1
75 #include <unordered_map>
77 #include "bspline_data.h"
102 static long long EdgeIndex(
const TreeOctNode* node ,
int eIndex ,
int maxDepth ,
int index[DIMENSION] );
104 static long long FaceIndex(
const TreeOctNode* node ,
int fIndex ,
int maxDepth,
int index[DIMENSION] );
106 static long long CornerIndex(
int depth ,
const int offSet[DIMENSION] ,
int cIndex ,
int maxDepth ,
int index[DIMENSION] );
107 static long long CornerIndex(
const TreeOctNode* node ,
int cIndex ,
int maxDepth ,
int index[DIMENSION] );
109 static long long CenterIndex(
int depth ,
const int offSet[DIMENSION] ,
int maxDepth ,
int index[DIMENSION] );
149 int idx[
pcl::poisson::Cube::EDGES] = {-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1};
194 template<
int Degree >
199 bool _constrainValues;
200 std::vector< int > _pointCount;
208 std::vector< PointData > _points;
209 TreeOctNode::NeighborKey3 neighborKey;
210 TreeOctNode::ConstNeighborKey3 neighborKey2;
214 Real GetLaplacian(
const int index[DIMENSION] )
const;
221 float splineValues[3][3];
224 Real GetValue(
const PointInfo points[3][3][3] ,
const bool hasPoints[3][3] ,
const int d[3] )
const;
226 class AdjacencyCountFunction
232 class AdjacencySetFunction{
234 int *adjacencies,adjacencyCount;
238 class RefineFunction{
243 class FaceEdgesFunction
246 int fIndex , maxDepth;
247 std::vector< std::pair< RootInfo , RootInfo > >* edges;
248 std::unordered_map< long long , std::pair< RootInfo , int > >* vertexCount;
252 int SolveFixedDepthMatrix(
int depth ,
const SortedTreeNodes& sNodes ,
Real* subConstraints ,
bool showResidual ,
int minIters ,
double accuracy );
253 int SolveFixedDepthMatrix(
int depth ,
const SortedTreeNodes& sNodes ,
Real* subConstraints ,
int startingDepth ,
bool showResidual ,
int minIters ,
double accuracy );
255 void SetMatrixRowBounds(
const TreeOctNode* node ,
int rDepth ,
const int rOff[3] ,
int& xStart ,
int& xEnd ,
int& yStart ,
int& yEnd ,
int& zStart ,
int& zEnd )
const;
256 int GetMatrixRowSize(
const TreeOctNode::Neighbors5& neighbors5 )
const;
257 int GetMatrixRowSize(
const TreeOctNode::Neighbors5& neighbors5 ,
int xStart ,
int xEnd ,
int yStart ,
int yEnd ,
int zStart ,
int zEnd )
const;
259 int SetMatrixRow(
const TreeOctNode::Neighbors5& neighbors5 ,
pcl::poisson::MatrixEntry< float >* row ,
int offset ,
const double stencil[5][5][5] ,
int xStart ,
int xEnd ,
int yStart ,
int yEnd ,
int zStart ,
int zEnd )
const;
261 void SetLaplacianStencil(
int depth ,
double stencil[5][5][5] )
const;
262 template<
class C ,
int N >
struct Stencil{ C values[N][N][N]; };
263 void SetLaplacianStencils(
int depth , Stencil< double , 5 > stencil[2][2][2] )
const;
265 void SetEvaluationStencils(
int depth , Stencil< double , 3 > stencil1[8] , Stencil< double , 3 > stencil2[8][8] )
const;
267 static void UpdateCoarserSupportBounds(
const TreeOctNode* node ,
int& startX ,
int& endX ,
int& startY ,
int& endY ,
int& startZ ,
int& endZ );
268 void UpdateConstraintsFromCoarser(
const TreeOctNode::NeighborKey5& neighborKey5 ,
TreeOctNode* node ,
Real* metSolution ,
const Stencil< double , 5 >& stencil )
const;
269 void SetCoarserPointValues(
int depth ,
const SortedTreeNodes& sNodes ,
Real* metSolution );
270 Real WeightedCoarserFunctionValue(
const TreeOctNode::NeighborKey3& neighborKey3 ,
const TreeOctNode* node ,
Real* metSolution )
const;
272 void DownSampleFinerConstraints(
int depth ,
SortedTreeNodes& sNodes )
const;
273 template<
class C >
void DownSample(
int depth ,
const SortedTreeNodes& sNodes , C* constraints )
const;
274 template<
class C >
void UpSample(
int depth ,
const SortedTreeNodes& sNodes , C* coefficients )
const;
278 void SetIsoCorners(
Real isoValue ,
TreeOctNode* leaf ,
SortedTreeNodes::CornerTableData& cData ,
char* valuesSet ,
Real* values , TreeOctNode::ConstNeighborKey3& nKey ,
const Real* metSolution ,
const Stencil< double , 3 > stencil1[8] ,
const Stencil< double , 3 > stencil2[8][8] );
279 static int IsBoundaryFace(
const TreeOctNode* node ,
int faceIndex ,
int subdivideDepth );
280 static int IsBoundaryEdge(
const TreeOctNode* node ,
int edgeIndex ,
int subdivideDepth );
281 static int IsBoundaryEdge(
const TreeOctNode* node ,
int dir ,
int x ,
int y ,
int subidivideDepth );
289 std::unordered_map< long long , int > boundaryRoots;
291 std::unordered_map< long long , std::pair< Real , pcl::poisson::Point3D< Real > > > *boundaryValues;
295 char *cornerValuesSet , *cornerNormalsSet , *edgesSet;
299 int SetMCRootPositions(
TreeOctNode* node ,
int sDepth ,
Real isoValue , TreeOctNode::ConstNeighborKey5& neighborKey5 , RootData& rootData ,
308 static int AddTriangles(
pcl::poisson::CoredMeshData* mesh , std::vector<CoredPointIndex>& edges , std::vector<
Point3D<float> >* interiorPositions ,
int offSet ,
bool addBarycenter ,
bool polygonMesh );
312 void GetMCIsoEdges(
TreeOctNode* node ,
int sDepth , std::vector< std::pair< RootInfo , RootInfo > >& edges );
313 static int GetEdgeLoops( std::vector< std::pair< RootInfo , RootInfo > >& edges , std::vector< std::vector< std::pair< RootInfo , RootInfo > > >& loops);
314 static int InteriorFaceRootCount(
const TreeOctNode* node ,
const int &faceIndex ,
int maxDepth );
315 static int EdgeRootCount(
const TreeOctNode* node ,
int edgeIndex ,
int maxDepth );
317 int GetRoot(
const RootInfo& ri ,
Real isoValue , TreeOctNode::ConstNeighborKey5& neighborKey5 ,
pcl::poisson::Point3D<Real> & position , RootData& rootData ,
int sDepth ,
const Real* metSolution ,
int nonLinearFit );
318 static int GetRootIndex(
const TreeOctNode* node ,
int edgeIndex ,
int maxDepth ,
RootInfo& ri );
319 static int GetRootIndex(
const TreeOctNode* node ,
int edgeIndex ,
int maxDepth ,
int sDepth ,
RootInfo& ri );
321 static int GetRootPair(
const RootInfo& root ,
int maxDepth ,
RootInfo& pair );
330 Real getCornerValue(
const TreeOctNode::ConstNeighborKey3& neighborKey3 ,
const TreeOctNode* node ,
int corner ,
const Real* metSolution );
332 Real getCornerValue(
const TreeOctNode::ConstNeighborKey3& neighborKey3 ,
const TreeOctNode* node ,
int corner ,
const Real* metSolution ,
const double stencil1[3][3][3] ,
const double stencil2[3][3][3] );
333 Real getCenterValue(
const TreeOctNode::ConstNeighborKey3& neighborKey3 ,
const TreeOctNode* node );
338 std::vector< pcl::poisson::Point3D<Real> >*
normals;
344 void setBSplineData(
int maxDepth ,
Real normalSmooth=-1 ,
bool reflectBoundary=
false );
350 template<
typename Po
intNT>
int
353 int useConfidence ,
Real constraintWeight ,
bool adaptiveWeights );
360 void GetMCIsoTriangles(
Real isoValue ,
int subdivideDepth ,
pcl::poisson::CoredMeshData* mesh ,
int fullDepthIso=0 ,
int nonLinearFit=1 ,
bool addBarycenter=
false ,
bool polygonMesh=
false );
370 #include "multi_grid_octree_data.hpp"
shared_ptr< const PointCloud< PointT > > ConstPtr
void RefineBoundary(int subdivisionDepth)
void setBSplineData(int maxDepth, Real normalSmooth=-1, bool reflectBoundary=false)
static double MemoryUsage(void)
int LaplacianMatrixIteration(int subdivideDepth, bool showResidual, int minIters, double accuracy)
Real * GetSolutionGrid(int &res, float isoValue=0.f, int depth=-1)
std::vector< pcl::poisson::Point3D< Real > > * normals
void SetLaplacianConstraints(void)
Real * GetWeightGrid(int &res, int depth=-1)
static double maxMemoryUsage
pcl::poisson::BSplineData< Degree, BSplineDataReal > fData
int setTree(typename pcl::PointCloud< PointNT >::ConstPtr input_, int maxDepth, int minDepth, int kernelDepth, Real samplesPerNode, Real scaleFactor, Point3D< Real > ¢er, Real &scale, int useConfidence, Real constraintWeight, bool adaptiveWeights)
void setEdgeTable(EdgeTableData &eData, const TreeOctNode *rootNode, int depth, int threads)
void setCornerTable(CornerTableData &cData, const TreeOctNode *rootNode, int threads) const
void setEdgeTable(EdgeTableData &eData, const TreeOctNode *rootNode, int threads)
int getMaxEdgeCount(const TreeOctNode *rootNode, int depth, int threads) const
void setCornerTable(CornerTableData &cData, int threads) const
int getMaxCornerCount(const TreeOctNode *rootNode, int depth, int maxDepth, int threads) const
void set(TreeOctNode &root)
void setEdgeTable(EdgeTableData &eData, int threads)
void setCornerTable(CornerTableData &cData, const TreeOctNode *rootNode, int depth, int threads) const
Real centerWeightContribution
static long long CenterIndex(int depth, const int offSet[DIMENSION], int maxDepth, int index[DIMENSION])
static long long CornerIndex(int depth, const int offSet[DIMENSION], int cIndex, int maxDepth, int index[DIMENSION])
static long long FaceIndex(const TreeOctNode *node, int fIndex, int maxDepth, int index[DIMENSION])
static long long CornerIndexKey(const int index[DIMENSION])
static long long EdgeIndex(const TreeOctNode *node, int eIndex, int maxDepth, int index[DIMENSION])
pcl::poisson::OctNode< class TreeNodeData, Real > TreeOctNode
int idx[pcl::poisson::Cube::CORNERS]
CornerIndices(void)=default
std::vector< int > offsets
CornerIndices & operator[](const TreeOctNode *node)
std::vector< CornerIndices > cTable
CornerIndices & cornerIndices(const TreeOctNode *node)
int idx[pcl::poisson::Cube::EDGES]
EdgeIndices(void)=default
std::vector< EdgeIndices > eTable
std::vector< int > offsets
EdgeIndices & operator[](const TreeOctNode *node)
EdgeIndices & edgeIndices(const TreeOctNode *node)