diff --git a/Geo/GModel.cpp b/Geo/GModel.cpp index 2653288b72d246670404a5a79c35a7cc902ed67f..c43f9b67353799b02b6e310c2754d6a4b4d14357 100644 --- a/Geo/GModel.cpp +++ b/Geo/GModel.cpp @@ -559,7 +559,7 @@ int GModel::adaptMesh(int technique, simpleFunction<double> *f, writeMSH(name); if (ITER++ >= niter) break; - if (ITER > 5 && fabs((double)(nbElems - nbElemsOld)) < 0.0 * nbElemsOld) break; + if (ITER > 3 && fabs((double)(nbElems - nbElemsOld)) < 0.01 * nbElemsOld) break; nbElemsOld = nbElems; } diff --git a/Mesh/CenterlineField.cpp b/Mesh/CenterlineField.cpp index 88b7791880bf63e72de8d2e56517715b13513ae0..c81328fbb64dfff52c3e1bb19c40cadae92819eb 100644 --- a/Mesh/CenterlineField.cpp +++ b/Mesh/CenterlineField.cpp @@ -12,12 +12,17 @@ #include <vector> #include <map> #include <string> +#include <fstream> +#include <sstream> #include "GModel.h" #include "MElement.h" #include "MVertex.h" #include "MLine.h" #include "GEntity.h" #include "Field.h" +#include "Os.h" + + #if defined(HAVE_ANN) #include <ANN/ANN.h> @@ -37,14 +42,9 @@ Centerline::Centerline(): kdtree(0), nodes(0){ index = new ANNidx[1]; dist = new ANNdist[1]; - update_needed = false; - options["FileName"] = new FieldOptionString (fileName, "File Name for the centerlines"); + options["FileName"] = new FieldOptionString (fileName, "File name for the centerlines", &update_needed); fileName = "centerlines.vtk";//default - //TODO get fileName from file - - importFile(fileName); - buildKdTree(); } @@ -131,6 +131,17 @@ void Centerline::buildKdTree(){ double Centerline::operator() (double x, double y, double z, GEntity *ge){ + if (update_needed){ + std::ifstream input; + input.open(fileName.c_str()); + + if(StatFile(fileName)) Msg::Fatal("Centerline file '%s' does not exist", fileName.c_str()); + + importFile(fileName); + buildKdTree(); + update_needed = false; + } + double xyz[3] = {x,y,z }; int num_neighbours = 1; kdtree->annkSearch(xyz, num_neighbours, index, dist); diff --git a/Mesh/CenterlineField.h b/Mesh/CenterlineField.h index b8c8ba408991ba96dfaf68fa01d701e87fc4d25a..ceb2c4ddfd4f8f8f484ec1894125e7ea51ea1f17 100644 --- a/Mesh/CenterlineField.h +++ b/Mesh/CenterlineField.h @@ -46,8 +46,8 @@ class Centerline : public Field{ virtual std::string getDescription() { return "The value of this field is the distance to the centerline.\n\n" -" You should specify a fileName that contains the centerline.\n" -" The centerline of a surface can be obtained using the open source software vmtk\n\n" +" You should specify a fileName that contains the centerline." +" The centerline of a surface can be obtained with the open source software vmtk (http://www.vmtk.org/)" " using the following script:\n\n" "vmtk vmtkcenterlines -seedselector openprofiles -ifile mysurface.stl -ofile centerlines.vtp --pipe vmtksurfacewriter -ifile centerlines.vtp -ofile centerlines.vtk\n"; } diff --git a/Mesh/meshGEdge.cpp b/Mesh/meshGEdge.cpp index 8a5ba76b0034adf985e01238390e1c9c07e02829..c491c5d6f3381515cef9b56853dee08408d77d00 100644 --- a/Mesh/meshGEdge.cpp +++ b/Mesh/meshGEdge.cpp @@ -396,7 +396,7 @@ void meshGEdge::operator() (GEdge *ge) // FIXME JF : MAYBE WE SHOULD NOT ALWAYS SMOOTH THE 1D MESH SIZE FIELD ?? //printFandPrimitive(ge->tag(), Points); - a = smoothPrimitive (ge,CTX::instance()->mesh.smoothRatio*CTX::instance()->mesh.smoothRatio,Points); + // a = smoothPrimitive (ge,CTX::instance()->mesh.smoothRatio*CTX::instance()->mesh.smoothRatio,Points); //printFandPrimitive(ge->tag()+10000, Points); N = std::max(ge->minimumMeshSegments() + 1, (int)(a + 1.)); diff --git a/Mesh/meshMetric.cpp b/Mesh/meshMetric.cpp index 79c0e52a4797eb42fe89d9c311c24cd4a286f93c..eb690c3f925e5bc644a0bf627d14752190bc2db7 100644 --- a/Mesh/meshMetric.cpp +++ b/Mesh/meshMetric.cpp @@ -80,7 +80,7 @@ meshMetric::meshMetric(GModel *gm, int technique, simpleFunction<double> *fct, s computeMetric(); - //printMetric("toto.pos"); + printMetric("toto.pos"); //exit(1); } @@ -332,7 +332,6 @@ void meshMetric::computeMetric(){ //smoothMetric (sol); //curvatureContributionToMetric(); - } double meshMetric::operator() (double x, double y, double z, GEntity *ge) {