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 // Given the constraint vector-field V(p), there are two ways to solve for the coefficients, x, of the indicator function
71 #define FORCE_NEUMANN_FIELD 1 // This flag forces the normal component across the boundary of the integration domain to be zero.
75 #include <unordered_map>
77 #include "bspline_data.h"
102 static long long EdgeIndex(
const TreeOctNode* node ,
int eIndex ,
int maxDepth ,
int index[DIMENSION] );
103 static long long EdgeIndex(
const TreeOctNode* node ,
int eIndex ,
int maxDepth );
104 static long long FaceIndex(
const TreeOctNode* node ,
int fIndex ,
int maxDepth,
int index[DIMENSION] );
105 static long long FaceIndex(
const TreeOctNode* node ,
int fIndex ,
int maxDepth );
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] );
108 static long long CornerIndex(
const TreeOctNode* node ,
int cIndex ,
int maxDepth );
109 static long long CenterIndex(
int depth ,
const int offSet[DIMENSION] ,
int maxDepth ,
int index[DIMENSION] );
110 static long long CenterIndex(
const TreeOctNode* node ,
int maxDepth ,
int index[DIMENSION] );
111 static long long CenterIndex(
const TreeOctNode* node ,
int maxDepth );
122 void set( TreeOctNode& root );
146 int getMaxCornerCount(
const TreeOctNode* rootNode ,
int depth ,
int maxDepth ,
int threads )
const ;
170 int getMaxEdgeCount(
const TreeOctNode* rootNode ,
int depth ,
int threads )
const ;
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;
216 Real GetLaplacian(
const TreeOctNode* node1 ,
const TreeOctNode* node2 )
const;
218 Real GetDivergenceMinusLaplacian(
const TreeOctNode* node1 ,
const TreeOctNode* node2 , Real value1 ,
const pcl::poisson::Point3D<Real>& normal1 )
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
230 void Function(
const TreeOctNode* node1,
const TreeOctNode* node2);
232 class AdjacencySetFunction{
234 int *adjacencies,adjacencyCount;
235 void Function(
const TreeOctNode* node1,
const TreeOctNode* node2);
238 class RefineFunction{
241 void Function(TreeOctNode* node1,
const TreeOctNode* node2);
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;
249 void Function(
const TreeOctNode* node1 ,
const TreeOctNode* node2 );
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;
298 int SetBoundaryMCRootPositions(
int sDepth , Real isoValue , RootData& rootData ,
pcl::poisson::CoredMeshData* mesh ,
int nonLinearFit );
299 int SetMCRootPositions( TreeOctNode* node ,
int sDepth , Real isoValue , TreeOctNode::ConstNeighborKey5& neighborKey5 , RootData& rootData ,
305 #else // !MISHA_DEBUG
308 static int AddTriangles(
pcl::poisson::CoredMeshData* mesh , std::vector<CoredPointIndex>& edges , std::vector<
Point3D<float> >* interiorPositions ,
int offSet ,
bool addBarycenter ,
bool polygonMesh );
309 #endif // MISHA_DEBUG
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 );
325 void NonLinearGetSampleDepthAndWeight(TreeOctNode* node,
const pcl::poisson::Point3D<Real>& position,Real samplesPerNode,Real& depth,Real& weight);
329 int HasNormals(TreeOctNode* node,Real epsilon);
330 Real getCornerValue(
const TreeOctNode::ConstNeighborKey3& neighborKey3 ,
const TreeOctNode* node ,
int corner ,
const Real* metSolution );
331 pcl::poisson::Point3D< Real > getCornerNormal(
const TreeOctNode::ConstNeighborKey5& neighborKey5 ,
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
352 int kernelDepth , Real samplesPerNode , Real scaleFactor ,
Point3D<Real>& center , Real& scale ,
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"
371 #endif // MULTI_GRID_OCTREE_DATA_INCLUDED
CornerIndices & cornerIndices(const TreeOctNode *node)
CornerIndices & operator[](const TreeOctNode *node)
EdgeIndices & operator[](const TreeOctNode *node)
void set(TreeOctNode &root)
std::vector< int > offsets
static long long FaceIndex(const TreeOctNode *node, int fIndex, int maxDepth, int index[DIMENSION])
void RefineBoundary(int subdivisionDepth)
Real * GetWeightGrid(int &res, int depth=-1)
int getMaxCornerCount(const TreeOctNode *rootNode, int depth, int maxDepth, int threads) const
EdgeIndices & edgeIndices(const TreeOctNode *node)
void setEdgeTable(EdgeTableData &eData, int threads)
int LaplacianMatrixIteration(int subdivideDepth, bool showResidual, int minIters, double accuracy)
void setEdgeTable(EdgeTableData &eData, const TreeOctNode *rootNode, int threads)
void setCornerTable(CornerTableData &cData, const TreeOctNode *rootNode, int threads) const
std::vector< int > offsets
int getMaxEdgeCount(const TreeOctNode *rootNode, int depth, int threads) const
static long long CornerIndexKey(const int index[DIMENSION])
static double maxMemoryUsage
Real centerWeightContribution
std::vector< CornerIndices > cTable
pcl::poisson::BSplineData< Degree, BSplineDataReal > fData
static long long CenterIndex(int depth, const int offSet[DIMENSION], int maxDepth, int index[DIMENSION])
pcl::poisson::OctNode< class TreeNodeData, Real > TreeOctNode
static long long CornerIndex(int depth, const int offSet[DIMENSION], int cIndex, int maxDepth, int index[DIMENSION])
static double MemoryUsage(void)
shared_ptr< const PointCloud< PointT > > ConstPtr
void setCornerTable(CornerTableData &cData, int threads) const
std::vector< EdgeIndices > eTable
int idx[pcl::poisson::Cube::EDGES]
void setCornerTable(CornerTableData &cData, const TreeOctNode *rootNode, int depth, int threads) const
int idx[pcl::poisson::Cube::CORNERS]
void setEdgeTable(EdgeTableData &eData, const TreeOctNode *rootNode, int depth, int threads)
std::vector< pcl::poisson::Point3D< Real > > * normals
static long long EdgeIndex(const TreeOctNode *node, int eIndex, int maxDepth, int index[DIMENSION])
Real * GetSolutionGrid(int &res, float isoValue=0.f, int depth=-1)
void SetLaplacianConstraints(void)
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 setBSplineData(int maxDepth, Real normalSmooth=-1, bool reflectBoundary=false)