]> SALOME platform Git repositories - modules/smesh.git/commitdiff
Salome HOME
0020918: EDF 1447 SMESH: Mesh common borders
authoreap <eap@opencascade.com>
Fri, 12 Nov 2010 14:40:33 +0000 (14:40 +0000)
committereap <eap@opencascade.com>
Fri, 12 Nov 2010 14:40:33 +0000 (14:40 +0000)
  store GeomAPI_ProjectPointOnCurve

src/SMESH/SMESH_MesherHelper.cxx
src/SMESH/SMESH_MesherHelper.hxx

index 0a3887f702fd5eec16baeb1b22b1573390d3d2ba..e9ec5e03d3f119a650b3ddea31b24031f9191e72 100644 (file)
@@ -89,9 +89,16 @@ SMESH_MesherHelper::SMESH_MesherHelper(SMESH_Mesh& theMesh)
 
 SMESH_MesherHelper::~SMESH_MesherHelper()
 {
-  TID2Projector::iterator i_proj = myFace2Projector.begin();
-  for ( ; i_proj != myFace2Projector.end(); ++i_proj )
-    delete i_proj->second;
+  {
+    TID2ProjectorOnSurf::iterator i_proj = myFace2Projector.begin();
+    for ( ; i_proj != myFace2Projector.end(); ++i_proj )
+      delete i_proj->second;
+  }
+  {
+    TID2ProjectorOnCurve::iterator i_proj = myEdge2Projector.begin();
+    for ( ; i_proj != myEdge2Projector.end(); ++i_proj )
+      delete i_proj->second;
+  }
 }
 
 //=======================================================================
@@ -517,8 +524,8 @@ GeomAPI_ProjectPointOnSurf& SMESH_MesherHelper::GetProjector(const TopoDS_Face&
 {
   Handle(Geom_Surface) surface = BRep_Tool::Surface( F,loc );
   int faceID = GetMeshDS()->ShapeToIndex( F );
-  TID2Projector& i2proj = const_cast< TID2Projector&>( myFace2Projector );
-  TID2Projector::iterator i_proj = i2proj.find( faceID );
+  TID2ProjectorOnSurf& i2proj = const_cast< TID2ProjectorOnSurf&>( myFace2Projector );
+  TID2ProjectorOnSurf::iterator i_proj = i2proj.find( faceID );
   if ( i_proj == i2proj.end() )
   {
     if ( tol == 0 ) tol = BRep_Tool::Tolerance( F );
@@ -672,13 +679,23 @@ bool SMESH_MesherHelper::CheckNodeU(const TopoDS_Edge&   E,
       if ( dist > tol )
       {
         // u incorrect, project the node to the curve
-        GeomAPI_ProjectPointOnCurve projector( nodePnt, curve, f, l );
-        if ( projector.NbPoints() < 1 )
+        int edgeID = GetMeshDS()->ShapeToIndex( E );
+        TID2ProjectorOnCurve& i2proj = const_cast< TID2ProjectorOnCurve&>( myEdge2Projector );
+        TID2ProjectorOnCurve::iterator i_proj =
+          i2proj.insert( make_pair( edgeID, (GeomAPI_ProjectPointOnCurve*) 0 )).first;
+        if ( !i_proj->second  )
+        {
+          i_proj->second = new GeomAPI_ProjectPointOnCurve();
+          i_proj->second->Init( curve, f, l );
+        }
+        GeomAPI_ProjectPointOnCurve* projector = i_proj->second;
+        projector->Perform( nodePnt );
+        if ( projector->NbPoints() < 1 )
         {
           MESSAGE( "SMESH_MesherHelper::CheckNodeU() failed to project" );
           return false;
         }
-        Quantity_Parameter U = projector.LowerDistanceParameter();
+        Quantity_Parameter U = projector->LowerDistanceParameter();
         u = double( U );
         dist = nodePnt.Distance( curve->Value( U ));
         if ( distance ) *distance = dist;
@@ -1521,6 +1538,26 @@ bool SMESH_MesherHelper::IsSubShape( const TopoDS_Shape& shape, SMESH_Mesh* aMes
     shape.ShapeType() == TopAbs_COMPOUND && aMesh->GetMeshDS()->IsGroupOfSubShapes( shape );
 }
 
+//================================================================================
+/*!
+ * \brief Return maximal tolerance of shape
+ */
+//================================================================================
+
+double SMESH_MesherHelper::MaxTolerance( const TopoDS_Shape& shape )
+{
+  double tol = Precision::Confusion();
+  TopExp_Explorer exp;
+  for ( exp.Init( shape, TopAbs_FACE ); exp.More(); exp.Next() )
+    tol = Max( tol, BRep_Tool::Tolerance( TopoDS::Face( exp.Current())));
+  for ( exp.Init( shape, TopAbs_EDGE ); exp.More(); exp.Next() )
+    tol = Max( tol, BRep_Tool::Tolerance( TopoDS::Edge( exp.Current())));
+  for ( exp.Init( shape, TopAbs_VERTEX ); exp.More(); exp.Next() )
+    tol = Max( tol, BRep_Tool::Tolerance( TopoDS::Vertex( exp.Current())));
+
+  return tol;
+}
+
 //=======================================================================
 //function : IsQuadraticMesh
 //purpose  : Check mesh without geometry for: if all elements on this shape are quadratic,
index 14d9225e6535bc38f732c78be76b0968edcb897f..2f89ce7899239f2abc9617f95c7e8c864f8032b5 100644 (file)
@@ -42,6 +42,7 @@
 #include <vector>
 
 class GeomAPI_ProjectPointOnSurf;
+class GeomAPI_ProjectPointOnCurve;
 
 typedef std::map<SMESH_TLink, const SMDS_MeshNode*>           TLinkNodeMap;
 typedef std::map<SMESH_TLink, const SMDS_MeshNode*>::iterator ItTLinkNode;
@@ -140,6 +141,8 @@ public:
 
   static bool IsSubShape( const TopoDS_Shape& shape, SMESH_Mesh* aMesh );
 
+  static double MaxTolerance( const TopoDS_Shape& shape );
+
 
 public:
   // ---------- PUBLIC INSTANCE METHODS ----------
@@ -230,7 +233,7 @@ public:
                                    const int id = 0,
                                    const bool force3d = false);
   /*!
-   * Creates quadratic or linear tetraahedron
+   * Creates quadratic or linear tetrahedron
    */
   SMDS_MeshVolume* AddVolume(const SMDS_MeshNode* n1,
                              const SMDS_MeshNode* n2,
@@ -486,8 +489,10 @@ protected:
   double          myPar1[2], myPar2[2]; // U and V bounds of a closed periodic surface
   int             myParIndex;     // bounds' index (1-U, 2-V, 3-both)
 
-  typedef std::map< int, GeomAPI_ProjectPointOnSurf* > TID2Projector;
-  TID2Projector   myFace2Projector;
+  typedef std::map< int, GeomAPI_ProjectPointOnSurf* > TID2ProjectorOnSurf;
+  TID2ProjectorOnSurf myFace2Projector;
+  typedef std::map< int, GeomAPI_ProjectPointOnCurve* > TID2ProjectorOnCurve;
+  TID2ProjectorOnCurve myEdge2Projector;
 
   TopoDS_Shape    myShape;
   SMESH_Mesh*     myMesh;