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
>
>
|