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.filters
|
||||
*.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/component_ep.h>
|
||||
#include <vcg/complex/algorithms/create/marching_cubes.h>
|
||||
#include <vcg/space/index/grid_static_ptr.h>
|
||||
#include <vcg/complex/algorithms/closest.h>
|
||||
//#include <vcg/space/index/grid_static_ptr.h>
|
||||
//#include <vcg/complex/algorithms/closest.h>
|
||||
#include <vcg/space/index/kdtree/kdtree_face.h>
|
||||
|
||||
namespace vcg {
|
||||
namespace tri {
|
||||
|
|
@ -63,13 +64,15 @@ class Resampler : public BasicGrid<typename NewMeshType::ScalarType>
|
|||
{
|
||||
private:
|
||||
typedef int VertexIndex;
|
||||
typedef typename vcg::GridStaticPtr<OldFaceType, OldScalarType> GridType;
|
||||
//typedef typename vcg::GridStaticPtr<OldFaceType, OldScalarType> GridType;
|
||||
typedef vcg::KdTreeFace<OldMeshType> GridType;
|
||||
|
||||
protected:
|
||||
|
||||
int SliceSize;
|
||||
int CurrentSlice;
|
||||
typedef tri::FaceTmark<OldMeshType> MarkerFace;
|
||||
//typedef tri::FaceTmark<OldMeshType> MarkerFace;
|
||||
typedef vcg::tri::EmptyTMark<OldMeshType> MarkerFace;
|
||||
MarkerFace markerFunctor;
|
||||
|
||||
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;
|
||||
DISTFUNCTOR PDistFunct;
|
||||
OldFaceType *f = _g.GetClosest(PDistFunct,markerFunctor,testPt,max_dist,dist,closestPt);
|
||||
|
||||
if (f==NULL) return field_value(false,0);
|
||||
if(AbsDistFlag) return field_value(true,dist);
|
||||
assert(!f->IsD());
|
||||
|
|
@ -230,6 +234,7 @@ class Resampler : public BasicGrid<typename NewMeshType::ScalarType>
|
|||
/// the distance of the bb
|
||||
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 k=0; k<=this->siz.Z(); k++)
|
||||
|
|
|
|||
|
|
@ -57,18 +57,23 @@ namespace vcg {
|
|||
|
||||
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;
|
||||
targetMaxDepth = maxDepth;
|
||||
mNodes.resize(1);
|
||||
Node& node = mNodes.back();
|
||||
node.leaf = 0;
|
||||
node.aabb = mesh.bbox;
|
||||
node.aabb.Offset(VectorType(epsilon, epsilon, epsilon));
|
||||
for (int i = 0; i < mesh.face.size(); i++)
|
||||
node.list.push_back(&mesh.face[i]);
|
||||
numLevel = createTree(0, 1);
|
||||
};
|
||||
|
||||
KdTreeFace(MeshType& mesh, unsigned int maxObjPerCell = 64, unsigned int maxDepth = 64, bool onlySelection = false) : epsilon(std::numeric_limits<Scalar>::epsilon())
|
||||
{
|
||||
targetCellSize = maxObjPerCell;
|
||||
targetMaxDepth = maxDepth;
|
||||
Set(mesh, maxObjPerCell, maxDepth);
|
||||
};
|
||||
|
||||
~KdTreeFace()
|
||||
|
|
@ -76,10 +81,53 @@ namespace vcg {
|
|||
|
||||
};
|
||||
|
||||
|
||||
template <class ObjectMarker> FacePointer doQueryClosest(const VectorType& queryPoint, VectorType& narestPoint, Scalar& dist, ObjectMarker& marker, Scalar maxDist = std::numeric_limits<Scalar>::max())
|
||||
template <class ObjIter>
|
||||
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;
|
||||
return NULL;
|
||||
|
|
@ -109,7 +157,7 @@ namespace vcg {
|
|||
marker.Mark(node.list[i]);
|
||||
Scalar tempDist = minDist;
|
||||
VectorType tempP;
|
||||
if (vcg::face::PointDistanceBase(*node.list[i], queryPoint, tempDist, tempP))
|
||||
if (pDistFunc(*node.list[i], queryPoint, tempDist, tempP))
|
||||
{
|
||||
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];
|
||||
VectorType diag = node.aabb.max - node.aabb.min;
|
||||
|
|
@ -264,7 +312,7 @@ namespace vcg {
|
|||
else
|
||||
{
|
||||
leftChild.leaf = 0;
|
||||
leftLevel = createTree(firstChildId, level + 1);
|
||||
leftLevel = CreateTree(firstChildId, level + 1);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -278,7 +326,7 @@ namespace vcg {
|
|||
else
|
||||
{
|
||||
rightChild.leaf = 0;
|
||||
rightLevel = createTree(firstChildId + 1, level + 1);
|
||||
rightLevel = CreateTree(firstChildId + 1, level + 1);
|
||||
}
|
||||
}
|
||||
if (leftLevel > rightLevel)
|
||||
|
|
|
|||
Loading…
Reference in New Issue