|
Closest Point
Find the Closest Point on a mesh
|
00001 #pragma once 00002 #include "Mesh.h" 00003 #include "Vector.h" 00004 #include <math.h> 00005 #include <limits> 00006 00007 #define INFINITY_FLOAT std::numeric_limits<float>::infinity(); 00008 #define INFINITY_INT std::numeric_limits<int>::infinity(); 00009 00010 using namespace math; 00011 using namespace std; 00012 00013 class ClosestPoint{ 00014 private: 00015 Mesh mesh; 00016 00017 public: 00018 /*Filtered vertices and faces within Maxradius*/ 00019 set<int> vlist_in_sphere; 00020 set<int> edge_in_sphere; 00021 00022 ClosestPoint(const Mesh &m){ 00023 mesh = Mesh(m); 00024 /*Ply give vertex and face list, make edge list*/ 00025 makeEdgeList(); 00026 }; 00027 00028 ~ClosestPoint(){}; 00029 00030 /*Prepare Adjacency List for edges from Vertex and Face list*/ 00031 void makeEdgeList(); 00032 00033 /*Overload the call () operator */ 00034 Vec3f operator ()(const Vec3f &point, float maxRadius); 00035 00036 /*Minimum distance of Query Point from all vertices*/ 00037 pair<float,Vec3f> minVertexDistance(const Vec3f &point, float maxRadius); 00038 00039 /*Closest point on an edge, from all edges in the mesh*/ 00040 pair<float,Vec3f> minEdgeDistance(const Vec3f &point, float maxRadius); 00041 00042 /*Closest point on a face, from all faces in the mesh*/ 00043 pair<float,Vec3f> minFaceDistance(const Vec3f &point, float maxRadius); 00044 00045 inline Mesh getMesh(){ 00046 return mesh; 00047 } 00048 00049 /*Fetch only the faces which contain vertices/edges within MaxRadius*/ 00050 vector<Face> fetchFacesinSphere(); 00051 00052 };
1.7.6.1