Speed-up improvments

- Use of the kdTree instead of the staticGrid
- Use of OpenMP in the computation of the slice values
This commit is contained in:
Gianpaolo Palma 2018-02-22 11:32:17 +01:00
parent 2a33dcf967
commit 926020d508
1 changed files with 9 additions and 4 deletions

View File

@ -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++)