diff --git a/Mesh/BDS.cpp b/Mesh/BDS.cpp index 4e2bd936d05ee325061b748b040c6be38b3f8f5f..661fac8f09c3ddd8025b62397bbc2c831ba7b679 100644 --- a/Mesh/BDS.cpp +++ b/Mesh/BDS.cpp @@ -109,40 +109,48 @@ void BDS_GeomEntity::getClosestTriangles ( double x, double y, double z, double eps; kdTree->annkSearch( // search queryPt, // query point - 1, // number of near neighbors + nbK, // number of near neighbors nnIdx, // nearest neighbors (returned) dists, // distance (returned) eps); // error bound - if (nnIdx[0] < sP.size()) + + for (int K=0;K<nbK;K++) { - sP[nnIdx[0]]->getTriangles (l); + if (nnIdx[K] < sP.size()) + { + std::list<BDS_Triangle *> l1; + sP[nnIdx[K]]->getTriangles (l1); + l.insert(l.begin(),l1.begin(),l1.end()); + } + else if (nnIdx[K] < sP.size() + sE.size() ) + { + + BDS_Edge *e = sE[nnIdx[K]- sP.size()]; + std::list<BDS_Triangle *> l1,l2; + e->p1->getTriangles (l1); + e->p2->getTriangles (l2); + l.insert(l.begin(),l1.begin(),l1.end()); + l.insert(l.begin(),l2.begin(),l2.end()); + // for (int i=0;i<e->numfaces();i++) + // { + // app.push_back(e->faces(i)); + // } + } + else + { + std::list<BDS_Triangle *> l1,l2,l3; + BDS_Point *pts[3]; + sT[nnIdx[K] - sP.size() - sE.size()]->getNodes (pts); + pts[0]->getTriangles (l1); + pts[0]->getTriangles (l2); + pts[0]->getTriangles (l3); + l.insert(l.begin(),l1.begin(),l1.end()); + l.insert(l.begin(),l2.begin(),l2.end()); + l.insert(l.begin(),l3.begin(),l3.end()); + // l.push_back( sT[nnIdx[0] - sP.size() - sE.size()]); + } } - else if (nnIdx[0] < sP.size() + sE.size() ) - { - BDS_Edge *e = sE[nnIdx[0]- sP.size()]; - std::list<BDS_Triangle *> l1; - //e->p1->getTriangles (l); - //e->p2->getTriangles (l1); - //l.insert(l.begin(),l1.begin(),l1.end()); - for (int i=0;i<e->numfaces();i++) - { - l.push_back(e->faces(i)); - } - } - else - { - std::list<BDS_Triangle *> l1,l2; - BDS_Point *pts[3]; - sT[nnIdx[0] - sP.size() - sE.size()]->getNodes (pts); - pts[0]->getTriangles (l); - pts[0]->getTriangles (l1); - pts[0]->getTriangles (l2); - l.insert(l.begin(),l1.begin(),l1.end()); - l.insert(l.begin(),l2.begin(),l2.end()); - - // l.push_back( sT[nnIdx[0] - sP.size() - sE.size()]); - } #else { l = t; @@ -715,8 +723,8 @@ void BDS_Mesh :: createSearchStructures ( ) const int dim = 3; (*it)->queryPt = annAllocPt(dim); // allocate query point (*it)->dataPts = annAllocPts(maxPts, dim); // allocate data points - (*it)->nnIdx = new ANNidx[1]; // allocate near neigh indices - (*it)->dists = new ANNdist[1]; // allocate near neighbor dists + (*it)->nnIdx = new ANNidx[(*it)->nbK]; // allocate near neigh indices + (*it)->dists = new ANNdist[(*it)->nbK]; // allocate near neighbor dists int I = 0; @@ -2250,7 +2258,7 @@ int BDS_Mesh :: adapt_mesh ( double l, bool smooth, BDS_Mesh *geom_mesh) SNAP_SUCCESS = 0; SNAP_FAILURE = 0; - BDS_Metric metric ( l , LC/100 , LC ); + BDS_Metric metric ( l , LC/200 , LC ); // printf("METRIC %g %g %g\n",LC,metric._min,metric._max); // add initial set of edges in a list diff --git a/Mesh/BDS.h b/Mesh/BDS.h index 98036b0a134860a3b03eee8cf30d8ecd1627c5f9..4cc366059897da63c3cd57d4b05e43db11813750 100644 --- a/Mesh/BDS.h +++ b/Mesh/BDS.h @@ -62,8 +62,9 @@ public : class BDS_GeomEntity { public: - int classif_tag; - int classif_degree; + int nbK; + int classif_tag; + int classif_degree; #ifdef HAVE_ANN_ ANNpointArray dataPts; // data points @@ -91,6 +92,7 @@ public: BDS_GeomEntity (int a, int b) : classif_tag (a),classif_degree(b),p(0),surf(0) { + nbK=3; #ifdef HAVE_ANN_ kdTree = 0; #endif diff --git a/configure.in b/configure.in index e1569aed02bcbd2f7d39d37336047ed8de6a0360..0ac740b9a8d98653aeefb82bee93db3ebb70b225 100644 --- a/configure.in +++ b/configure.in @@ -1,4 +1,4 @@ -dnl $Id: configure.in,v 1.73 2005-07-03 08:02:23 geuzaine Exp $ +dnl $Id: configure.in,v 1.74 2005-08-22 07:17:34 remacle Exp $ dnl dnl Copyright (C) 1997-2005 C. Geuzaine, J.-F. Remacle dnl @@ -66,6 +66,9 @@ AC_ARG_ENABLE(triangle, AC_ARG_ENABLE(netgen, AC_HELP_STRING([--enable-netgen], [compile Netgen if available (default=yes)])) +AC_ARG_ENABLE(ann, + AC_HELP_STRING([--enable-ann], + [compile ANN if available (default=yes)])) AC_ARG_ENABLE(tetgen, AC_HELP_STRING([--enable-tetgen], [compile Tetgen if available (default=yes)])) @@ -249,6 +252,34 @@ else fi fi +dnl Check if ANN is installed +AC_CHECK_FILE(./ANN/include/ANN/ANN.h, ANN="yes", ANN="no") +if test "x${ANN}" = "xyes"; then + if test "x$enable_ann" != "xno"; then + GMSH_DIRS="${GMSH_DIRS} Netgen" + GMSH_LIBS="${GMSH_LIBS} -lGmshNetgen" + FLAGS="-DHAVE_NETGEN ${FLAGS}" + echo "********************************************************************" + echo "You are building a version of Gmsh that contains ANN, the Approximate" + echo "Nearest Neighbor library." + echo "Please note that by doing so, you agree with ANN's licensing" + echo "requirements stated in ./ANN/Copyright.txt." + echo "To disable ANN, run configure again with the --disable-ann" + echo "option." + echo "********************************************************************" + fi +else + if test "x$enable_ann" != "xno"; then + echo "********************************************************************" + echo "If you want to use ANN for doing fast geometrical searchs in the" + echo "STL mesher, please download ANN from the" + echo "author's web site at http://www.cs.umd.edu/~mount/ANN/," + echo "unpack the archive and copy both src and include directories in the ./ANN subdirectory." + echo "Then run ./configure again." + echo "********************************************************************" + fi +fi + dnl Check if Netgen is installed AC_CHECK_FILE(./Netgen/libsrc/meshing/meshclass.cpp, NETGEN="yes", NETGEN="no") if test "x${NETGEN}" = "xyes"; then