Skip to content
Snippets Groups Projects
Commit 482a7d3e authored by Christophe Geuzaine's avatar Christophe Geuzaine
Browse files

tentative patch for min # of points on curve

parent b5a383e9
No related branches found
No related tags found
No related merge requests found
...@@ -126,8 +126,8 @@ int gmshEdge::minimumMeshSegments () const ...@@ -126,8 +126,8 @@ int gmshEdge::minimumMeshSegments () const
} }
} }
else if(geomType() == Circle || geomType() == Ellipse) else if(geomType() == Circle || geomType() == Ellipse)
np = (int)(fabs(c->Circle.t1 - c->Circle.t2) * np = (int)(0.99 + fabs(c->Circle.t1 - c->Circle.t2) *
(double)CTX::instance()->mesh.minCircPoints / (2 * M_PI)) - 1; ((double)CTX::instance()->mesh.minCircPoints - 1.0) / (2 * M_PI));
else else
np = CTX::instance()->mesh.minCurvPoints - 1; np = CTX::instance()->mesh.minCurvPoints - 1;
return std::max(np, meshAttributes.minimumMeshSegments); return std::max(np, meshAttributes.minimumMeshSegments);
......
...@@ -379,7 +379,7 @@ static int increaseN (int N) ...@@ -379,7 +379,7 @@ static int increaseN (int N)
// ensure not to have points that are too close to each other. // ensure not to have points that are too close to each other.
// can be caused by a coarse 1D mesh or by a noisy curve // can be caused by a coarse 1D mesh or by a noisy curve
static void filterPoints (GEdge*ge) { static void filterPoints (GEdge*ge, int nMinimumPoints) {
if (ge->mesh_vertices.empty())return; if (ge->mesh_vertices.empty())return;
if(ge->meshAttributes.method == MESH_TRANSFINITE)return; if(ge->meshAttributes.method == MESH_TRANSFINITE)return;
//if (ge->mesh_vertices.size() <=3)return; //if (ge->mesh_vertices.size() <=3)return;
...@@ -429,12 +429,15 @@ static void filterPoints (GEdge*ge) { ...@@ -429,12 +429,15 @@ static void filterPoints (GEdge*ge) {
} }
*/ */
bool filteringObservesMinimumN = ((ge->mesh_vertices.size() - last) >= nMinimumPoints);
if (filteringObservesMinimumN){
for (int i=0;i<last;i++){ for (int i=0;i<last;i++){
std::vector<MVertex*>::iterator it = std::find(ge->mesh_vertices.begin(),ge->mesh_vertices.end(),lengths[i].second); std::vector<MVertex*>::iterator it = std::find(ge->mesh_vertices.begin(),ge->mesh_vertices.end(),lengths[i].second);
ge->mesh_vertices.erase(it); ge->mesh_vertices.erase(it);
delete lengths[i].second; delete lengths[i].second;
} }
} }
}
void meshGEdge::operator() (GEdge *ge) void meshGEdge::operator() (GEdge *ge)
{ {
...@@ -499,6 +502,7 @@ void meshGEdge::operator() (GEdge *ge) ...@@ -499,6 +502,7 @@ void meshGEdge::operator() (GEdge *ge)
// Integrate detJ/lc du // Integrate detJ/lc du
double a; double a;
int N; int N;
int filterMinimumN = 1;
if(length == 0. && CTX::instance()->mesh.toleranceEdgeLength == 0.){ if(length == 0. && CTX::instance()->mesh.toleranceEdgeLength == 0.){
Msg::Warning("Curve %d has a zero length", ge->tag()); Msg::Warning("Curve %d has a zero length", ge->tag());
a = 0.; a = 0.;
...@@ -532,7 +536,8 @@ void meshGEdge::operator() (GEdge *ge) ...@@ -532,7 +536,8 @@ void meshGEdge::operator() (GEdge *ge)
pt.xp = der.norm(); pt.xp = der.norm();
} }
// a = smoothPrimitive(ge, sqrt(CTX::instance()->mesh.smoothRatio), Points); // a = smoothPrimitive(ge, sqrt(CTX::instance()->mesh.smoothRatio), Points);
N = std::max(ge->minimumMeshSegments() + 1, (int)(a + 1.99)); filterMinimumN = ge->minimumMeshSegments() + 1;
N = std::max(filterMinimumN, (int)(a + 1.99));
} }
// force odd number of points if blossom is used for recombination // force odd number of points if blossom is used for recombination
...@@ -610,7 +615,7 @@ void meshGEdge::operator() (GEdge *ge) ...@@ -610,7 +615,7 @@ void meshGEdge::operator() (GEdge *ge)
} }
// printf("%ld ----> ", ge->mesh_vertices.size()); // printf("%ld ----> ", ge->mesh_vertices.size());
filterPoints (ge); filterPoints (ge, filterMinimumN - 2);
// printf("%ld \n", ge->mesh_vertices.size()); // printf("%ld \n", ge->mesh_vertices.size());
for(unsigned int i = 0; i < mesh_vertices.size() + 1; i++){ for(unsigned int i = 0; i < mesh_vertices.size() + 1; i++){
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment