Merge branch 'devel' of https://github.com/cnr-isti-vclab/vcglib into devel
This commit is contained in:
commit
060cfc3ecb
|
|
@ -19,3 +19,9 @@ release/
|
||||||
*.vcxproj
|
*.vcxproj
|
||||||
*.vcxproj.filters
|
*.vcxproj.filters
|
||||||
*.suo
|
*.suo
|
||||||
|
*.ply
|
||||||
|
wrap/nanoply/nanoply_vcg/nanoply_vcg.sln
|
||||||
|
*.db
|
||||||
|
wrap/nanoply/nanoply_vcg/nanoply_vcg.VC.VC.opendb
|
||||||
|
wrap/nanoply/nanoply_vcg/.vs/nanoply_vcg/v15/ipch/AutoPCH/NANOPLY_VCG-1b6b1a83/MAIN-5f62d91f/MAIN.ipch
|
||||||
|
*.sln
|
||||||
|
|
|
||||||
|
|
@ -27,8 +27,9 @@
|
||||||
#include <vcg/complex/algorithms/update/bounding.h>
|
#include <vcg/complex/algorithms/update/bounding.h>
|
||||||
#include <vcg/complex/algorithms/update/component_ep.h>
|
#include <vcg/complex/algorithms/update/component_ep.h>
|
||||||
#include <vcg/complex/algorithms/create/marching_cubes.h>
|
#include <vcg/complex/algorithms/create/marching_cubes.h>
|
||||||
#include <vcg/space/index/grid_static_ptr.h>
|
//#include <vcg/space/index/grid_static_ptr.h>
|
||||||
#include <vcg/complex/algorithms/closest.h>
|
//#include <vcg/complex/algorithms/closest.h>
|
||||||
|
#include <vcg/space/index/kdtree/kdtree_face.h>
|
||||||
|
|
||||||
namespace vcg {
|
namespace vcg {
|
||||||
namespace tri {
|
namespace tri {
|
||||||
|
|
@ -63,13 +64,15 @@ class Resampler : public BasicGrid<typename NewMeshType::ScalarType>
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
typedef int VertexIndex;
|
typedef int VertexIndex;
|
||||||
typedef typename vcg::GridStaticPtr<OldFaceType, OldScalarType> GridType;
|
//typedef typename vcg::GridStaticPtr<OldFaceType, OldScalarType> GridType;
|
||||||
|
typedef vcg::KdTreeFace<OldMeshType> GridType;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
int SliceSize;
|
int SliceSize;
|
||||||
int CurrentSlice;
|
int CurrentSlice;
|
||||||
typedef tri::FaceTmark<OldMeshType> MarkerFace;
|
//typedef tri::FaceTmark<OldMeshType> MarkerFace;
|
||||||
|
typedef vcg::tri::EmptyTMark<OldMeshType> MarkerFace;
|
||||||
MarkerFace markerFunctor;
|
MarkerFace markerFunctor;
|
||||||
|
|
||||||
VertexIndex *_x_cs; // indici dell'intersezioni della superficie lungo gli Xedge della fetta corrente
|
VertexIndex *_x_cs; // indici dell'intersezioni della superficie lungo gli Xedge della fetta corrente
|
||||||
|
|
@ -159,6 +162,7 @@ class Resampler : public BasicGrid<typename NewMeshType::ScalarType>
|
||||||
OldCoordType closestPt;
|
OldCoordType closestPt;
|
||||||
DISTFUNCTOR PDistFunct;
|
DISTFUNCTOR PDistFunct;
|
||||||
OldFaceType *f = _g.GetClosest(PDistFunct,markerFunctor,testPt,max_dist,dist,closestPt);
|
OldFaceType *f = _g.GetClosest(PDistFunct,markerFunctor,testPt,max_dist,dist,closestPt);
|
||||||
|
|
||||||
if (f==NULL) return field_value(false,0);
|
if (f==NULL) return field_value(false,0);
|
||||||
if(AbsDistFlag) return field_value(true,dist);
|
if(AbsDistFlag) return field_value(true,dist);
|
||||||
assert(!f->IsD());
|
assert(!f->IsD());
|
||||||
|
|
@ -230,6 +234,7 @@ class Resampler : public BasicGrid<typename NewMeshType::ScalarType>
|
||||||
/// the distance of the bb
|
/// the distance of the bb
|
||||||
void ComputeSliceValues(int slice,field_value *slice_values)
|
void ComputeSliceValues(int slice,field_value *slice_values)
|
||||||
{
|
{
|
||||||
|
#pragma omp parallel for schedule(dynamic, 10)
|
||||||
for (int i=0; i<=this->siz.X(); i++)
|
for (int i=0; i<=this->siz.X(); i++)
|
||||||
{
|
{
|
||||||
for (int k=0; k<=this->siz.Z(); k++)
|
for (int k=0; k<=this->siz.Z(); k++)
|
||||||
|
|
|
||||||
|
|
@ -57,18 +57,23 @@ namespace vcg {
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
KdTreeFace(MeshType& mesh, unsigned int maxObjPerCell = 64, unsigned int maxDepth = 64) : epsilon(std::numeric_limits<Scalar>::epsilon())
|
KdTreeFace():epsilon(std::numeric_limits<Scalar>::epsilon())
|
||||||
|
{
|
||||||
|
targetCellSize = 64;
|
||||||
|
targetMaxDepth = 64;
|
||||||
|
};
|
||||||
|
|
||||||
|
KdTreeFace(unsigned int maxObjPerCell, unsigned int maxDepth) : epsilon(std::numeric_limits<Scalar>::epsilon())
|
||||||
{
|
{
|
||||||
targetCellSize = maxObjPerCell;
|
targetCellSize = maxObjPerCell;
|
||||||
targetMaxDepth = maxDepth;
|
targetMaxDepth = maxDepth;
|
||||||
mNodes.resize(1);
|
};
|
||||||
Node& node = mNodes.back();
|
|
||||||
node.leaf = 0;
|
KdTreeFace(MeshType& mesh, unsigned int maxObjPerCell = 64, unsigned int maxDepth = 64, bool onlySelection = false) : epsilon(std::numeric_limits<Scalar>::epsilon())
|
||||||
node.aabb = mesh.bbox;
|
{
|
||||||
node.aabb.Offset(VectorType(epsilon, epsilon, epsilon));
|
targetCellSize = maxObjPerCell;
|
||||||
for (int i = 0; i < mesh.face.size(); i++)
|
targetMaxDepth = maxDepth;
|
||||||
node.list.push_back(&mesh.face[i]);
|
Set(mesh, maxObjPerCell, maxDepth);
|
||||||
numLevel = createTree(0, 1);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
~KdTreeFace()
|
~KdTreeFace()
|
||||||
|
|
@ -76,10 +81,53 @@ namespace vcg {
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
template <class ObjIter>
|
||||||
template <class ObjectMarker> FacePointer doQueryClosest(const VectorType& queryPoint, VectorType& narestPoint, Scalar& dist, ObjectMarker& marker, Scalar maxDist = std::numeric_limits<Scalar>::max())
|
void Set(const ObjIter & _oBegin, const ObjIter & _oEnd, int size = 0, bool onlySelection = false)
|
||||||
{
|
{
|
||||||
if (maxDist < std::numeric_limits<Scalar>::max() && !mNodes[0].aabb.IsIn(queryPoint) && vcg::PointFilledBoxDistance(queryPoint, mNodes[0].aabb) >= maxDist)
|
mNodes.resize(1);
|
||||||
|
Node& node = mNodes.back();
|
||||||
|
node.leaf = 0;
|
||||||
|
node.aabb.Offset(VectorType(epsilon, epsilon, epsilon));
|
||||||
|
Box3<Scalar> box;
|
||||||
|
if (onlySelection)
|
||||||
|
{
|
||||||
|
for (ObjIter i = _oBegin; i != _oEnd; ++i)
|
||||||
|
{
|
||||||
|
if ((*i).IsS())
|
||||||
|
{
|
||||||
|
node.list.push_back(&(*i));
|
||||||
|
box.Add((*i).P(0));
|
||||||
|
box.Add((*i).P(1));
|
||||||
|
box.Add((*i).P(2));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
for (ObjIter i = _oBegin; i != _oEnd; ++i)
|
||||||
|
{
|
||||||
|
node.list.push_back(&(*i));
|
||||||
|
box.Add((*i).P(0));
|
||||||
|
box.Add((*i).P(1));
|
||||||
|
box.Add((*i).P(2));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
node.aabb = box;
|
||||||
|
numLevel = CreateTree(0, 1);
|
||||||
|
};
|
||||||
|
|
||||||
|
void Clear()
|
||||||
|
{
|
||||||
|
for (int i = 0; i < mNodes.size(); i++)
|
||||||
|
mNodes[i].list.clear();
|
||||||
|
mNodes.clear();
|
||||||
|
};
|
||||||
|
|
||||||
|
//template <class ObjectMarker> FacePointer GetClosest(const VectorType& queryPoint, VectorType& narestPoint, Scalar& dist, ObjectMarker& marker, Scalar maxDist = std::numeric_limits<Scalar>::max())
|
||||||
|
template <class ObjPointDistFunction, class ObjectMarker>
|
||||||
|
FacePointer GetClosest(ObjPointDistFunction& pDistFunc, ObjectMarker& marker, const VectorType& queryPoint, Scalar maxDist, Scalar& dist, VectorType& narestPoint)
|
||||||
|
{
|
||||||
|
if (mNodes.size() == 0|| (maxDist < std::numeric_limits<Scalar>::max() && !mNodes[0].aabb.IsIn(queryPoint) && vcg::PointFilledBoxDistance(queryPoint, mNodes[0].aabb) >= maxDist))
|
||||||
{
|
{
|
||||||
dist = maxDist;
|
dist = maxDist;
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
@ -109,7 +157,7 @@ namespace vcg {
|
||||||
marker.Mark(node.list[i]);
|
marker.Mark(node.list[i]);
|
||||||
Scalar tempDist = minDist;
|
Scalar tempDist = minDist;
|
||||||
VectorType tempP;
|
VectorType tempP;
|
||||||
if (vcg::face::PointDistanceBase(*node.list[i], queryPoint, tempDist, tempP))
|
if (pDistFunc(*node.list[i], queryPoint, tempDist, tempP))
|
||||||
{
|
{
|
||||||
if (tempDist < minDist)
|
if (tempDist < minDist)
|
||||||
{
|
{
|
||||||
|
|
@ -176,7 +224,7 @@ namespace vcg {
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
int createTree(unsigned int nodeId, unsigned int level)
|
int CreateTree(unsigned int nodeId, unsigned int level)
|
||||||
{
|
{
|
||||||
Node& node = mNodes[nodeId];
|
Node& node = mNodes[nodeId];
|
||||||
VectorType diag = node.aabb.max - node.aabb.min;
|
VectorType diag = node.aabb.max - node.aabb.min;
|
||||||
|
|
@ -264,7 +312,7 @@ namespace vcg {
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
leftChild.leaf = 0;
|
leftChild.leaf = 0;
|
||||||
leftLevel = createTree(firstChildId, level + 1);
|
leftLevel = CreateTree(firstChildId, level + 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -278,7 +326,7 @@ namespace vcg {
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
rightChild.leaf = 0;
|
rightChild.leaf = 0;
|
||||||
rightLevel = createTree(firstChildId + 1, level + 1);
|
rightLevel = CreateTree(firstChildId + 1, level + 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (leftLevel > rightLevel)
|
if (leftLevel > rightLevel)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue