diff --git a/Mesh/BackgroundMesh.cpp b/Mesh/BackgroundMesh.cpp index ce0cd09f6fa69fa95b601b0c8a01fd6cb8c74ecb..a846a8f1a03bf63edba7794e29f4eef6341b8637 100644 --- a/Mesh/BackgroundMesh.cpp +++ b/Mesh/BackgroundMesh.cpp @@ -196,6 +196,41 @@ static SMetric3 metric_based_on_surface_curvature(const GEdge *ge, double u) return intersection(mesh_size,curvMetric); } +static SMetric3 metric_based_on_surface_curvature_ES(const GEdge *ge, double u) +{ + // If the curve is a compound curve, find the corresponding discrete curve. Then loop over all + // neighboring (discrete) surfaces and compute the metric as the intersection of the surface metrics + + SMetric3 mesh_size(1.e-12); + int iDiscEdge; + double tLoc; + if (ge->geomType() == GEntity::CompoundCurve) + { + const GEdgeCompound* ptrEdgeCompound = dynamic_cast<const GEdgeCompound*>(ge); + ptrEdgeCompound->getLocalParameter(u, iDiscEdge, tLoc); + std::vector <GEdge*> DiscreteEdge = ptrEdgeCompound->getCompounds(); //vector of pointers to GEdge + GEdge* ptrDiscEdge = DiscreteEdge[iDiscEdge]; //Single pointer to GEdge + + std::list<GFace *> faces = ptrDiscEdge->faces(); + std::list<GFace *>::iterator it = faces.begin(); + int count = 0; + while(it != faces.end()) + { + +// SMetric3 m = metric_based_on_surface_curvature(*it, u, v); //This doesn't work!!!! + SPoint2 par = ge->reparamOnFace((*it), u, 1); + SMetric3 m = metric_based_on_surface_curvature (*it, par.x(), par.y()); + if (!count) mesh_size = m; + else mesh_size = intersection(mesh_size, m); + count++; + + ++it; + } + } + + return mesh_size; +} + static SMetric3 metric_based_on_surface_curvature(const GVertex *gv) { SMetric3 mesh_size(1.e-5); @@ -216,6 +251,65 @@ static SMetric3 metric_based_on_surface_curvature(const GVertex *gv) return mesh_size; } +static SMetric3 metric_based_on_surface_curvature_ES(const GVertex *gv) +{ + SMetric3 mesh_size(1.e-5); + std::list <GFace*>::const_iterator itf; + + int iDiscEdge; + double tLoc; + + std::list<GEdge*> l_edges = gv->edges(); + std::list<GFace*> l_faces; + for (std::list<GEdge*>::const_iterator ite = l_edges.begin(); ite != l_edges.end(); ++ite) + { + if ((*ite)->geomType() == GEntity::CompoundCurve) + { + const GEdgeCompound* ptrEdgeCompound = dynamic_cast<const GEdgeCompound*>(*ite); + Range<double> bounds = (*ite)->parBounds(0); + + if (gv == (*ite)->getBeginVertex()) + { + ptrEdgeCompound->getLocalParameter(bounds.low(), iDiscEdge, tLoc); + } + else + { + ptrEdgeCompound->getLocalParameter(bounds.high(), iDiscEdge, tLoc); + } + + std::vector <GEdge*> DiscreteEdge = ptrEdgeCompound->getCompounds(); //vector of pointers to GEdge + GEdge* ptrDiscEdge = DiscreteEdge[iDiscEdge]; //Single pointer to GEdge + + + std::list<GFace *> neighFaces = ptrDiscEdge->faces(); + for (itf = neighFaces.begin(); itf != neighFaces.end(); ++itf) + { + l_faces.push_back(*itf); + } + } + } + + l_faces.sort(); + l_faces.unique(); + + itf = l_faces.begin(); + int count = 0; + while(itf != l_faces.end()) + { + SPoint2 par = gv->reparamOnFace((*itf), 1); + SMetric3 m = metric_based_on_surface_curvature (*itf, par.x(), par.y()); + if (!count) mesh_size = m; + else mesh_size = intersection(mesh_size, m); + count++; + + ++itf; + } + + return mesh_size; +} + + + // the mesh vertex is classified on a model vertex. we compute the // maximum of the curvature of model faces surrounding this point if // it is classified on a model edge, we do the same for all model