For the use of the UniformGrid inside meshlab you should look at the
filter_sampling plugin
the RedetailSampler class uses a UG to find the closest point for a
given query point.
UG initialization is done in the RedetailSampler::init and the query
procedure that uses GetClosestFace is inside RedetailSampler::AddVert
The basic meshlab mesh type has not the EdgePlane component
so you should resort to the (slightly) slower mechanism.
p.
fabio ganovelli wrote:
> Hi,
> you can use the GetClosestFace function in vcg/trimesh/closest.h.
>
> Include vcg::face::EdgePlane as component of your face type and call
> vcg::UpdateEdge<MeshModel>::Set(..) which sets the values of EdgePlane
> for each face.
> If you don't do this, there quantities will be computed on demand
> (multiple times) and your code will
> be considerably slower.
>
> Look at the project apps/metro/ (file sampling.h) to see a complete example.
>
> cheers,
> Fabio
>
>
>
>> Hi all,
>>
>> i've started working on the "re-topology" plugin (just committed a
>> *very* initial version),
>> and i've got a question on how to use (correctly) the Uniform Grid object.
>>
>> My goal is to get the closest point of a mesh from a given spatial
>> coord (not a vertex of
>> the mesh structure, just a free point over its surface),
>> and then use that point to build the retopologized mesh.
>>
>> In order to do this, i've looked for some spatial indexing structures,
>> and found the
>> one that is called "GridStaticPtr", whitch seems to be exaclty what i needed.
>>
>>
>> So, once initialized the Grid object ("unifGrid"):
>>
>>
>> meshModel->updateDataMask(MeshModel::MM_FACEMARK);
>> unifGrid.Set(mesh->face.begin(), mesh->face.end());
>> markerFunctor.SetMesh(mesh);
>>
>>
>> i use this code to get the closest point:
>>
>>
>> float dist_upper_bound =mesh->bbox.Diag()/50;
>> float dist = dist_upper_bound;
>> const CMeshO::CoordType &startPt= toCheck;
>>
>> CMeshO::FaceType *nearestF=0;
>> vcg::face::PointDistanceBaseFunctor PDistFunct;
>>
>> nearestF = unifGrid.GetClosest(PDistFunct, markerFunctor, startPt,
>> dist_upper_bound, dist, closestPt);
>>
>>
>> Here i expect to get in "closestPt" the mesh surface point nearest to
>> "startPt", but this does
>> not happen for every starting point passed (expecially on hi-res meshes, the
>> returned point is not just the nonclosest, but it's also not a point
>> of the mesh).
>>
>>
>> Well, my question is: am i using "unifGrid" correctly?
>> And, if not, any suggestion on how to get the closest mesh point from
>> a given coord (using uniform grid or something else)?
>>
>> Tanks in advance,
>> D.
>>
>> -------------------------------------------------------------------------
>> This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
>> Build the coolest Linux based applications with Moblin SDK & win great prizes
>> Grand prize is a trip for two to an Open Source event anywhere in the world
>> http://moblin-contest.org/redirect.php?banner_id=100&url=/
>> _______________________________________________
>> Meshlab-devel mailing list
>> Mes...@li...
>> https://lists.sourceforge.net/lists/listinfo/meshlab-devel
>>
>>
>>
>
>
> -------------------------------------------------------------------------
> This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
> Build the coolest Linux based applications with Moblin SDK & win great prizes
> Grand prize is a trip for two to an Open Source event anywhere in the world
> http://moblin-contest.org/redirect.php?banner_id=100&url=/
> _______________________________________________
> Meshlab-devel mailing list
> Mes...@li...
> https://lists.sourceforge.net/lists/listinfo/meshlab-devel
>
>
--
Paolo Cignoni -- Senior Researcher
Visual Computing Laboratory - ISTI - CNR
http://vcg.isti.cnr.it/~cignoni
ISTI - CNR
Via Moruzzi 1,
56124 Pisa
ITALY
|