Salome HOME
23092: EDF 10836 SMESH: UseExisting2DElements fails when geometry contains more than...
authoreap <eap@opencascade.com>
Fri, 8 May 2015 15:49:31 +0000 (18:49 +0300)
committereap <eap@opencascade.com>
Fri, 8 May 2015 15:49:31 +0000 (18:49 +0300)
   Decrease 2D tolerance user for UV classification

src/SMESH/SMESH_Mesh.cxx
src/SMESH/SMESH_Mesh.hxx
src/SMESH/SMESH_subMesh.cxx
src/StdMeshers/StdMeshers_Import_1D2D.cxx

index 49446080fa25794004ca7f9c81952eedf4b3d7e6..94b1b7a72c22313edf9cb2d51fd369b3afac1de5 100644 (file)
@@ -237,6 +237,26 @@ bool SMESH_Mesh::MeshExists( int meshId ) const
   return _myDocument ? bool( _myDocument->GetMesh( meshId )) : false;
 }
 
+//================================================================================
+/*!
+ * \brief Return a mesh by id
+ */
+//================================================================================
+
+SMESH_Mesh* SMESH_Mesh::FindMesh( int meshId ) const
+{
+  if ( _id == meshId )
+    return (SMESH_Mesh*) this;
+
+  if ( StudyContextStruct *aStudyContext = _gen->GetStudyContext( _studyId ))
+  {
+    std::map < int, SMESH_Mesh * >::iterator i_m = aStudyContext->mapMesh.find( meshId );
+    if ( i_m != aStudyContext->mapMesh.end() )
+      return i_m->second;
+  }
+  return NULL;
+}
+
 //=============================================================================
 /*!
  * \brief Set geometry to be meshed
index b6f001f277449eae344d7e6dbab7da862f03d920..4878dc4f96cd815f4d9c00bd403c8ef41a5f6529 100644 (file)
@@ -169,8 +169,10 @@ class SMESH_EXPORT SMESH_Mesh
   
   bool MeshExists( int meshId ) const;
   
+  SMESH_Mesh* FindMesh( int meshId ) const;
+
   SMESHDS_Mesh * GetMeshDS() { return _myMeshDS; }
-  
+
   const SMESHDS_Mesh * GetMeshDS() const { return _myMeshDS; }
   
   SMESH_Gen *GetGen()        { return _gen; }
index 1d481713389949ea9a25e52312fb123c7e805267..3745a2b77afe3dcce5911f5de6506c17cef6f2fc 100644 (file)
@@ -2470,11 +2470,8 @@ void SMESH_subMesh::deleteOwnListeners()
   list< OwnListenerData >::iterator d;
   for ( d = _ownListeners.begin(); d != _ownListeners.end(); ++d )
   {
-    if ( !_father->MeshExists( d->myMeshID ))
-      continue;
-    if ( _father->GetId() == d->myMeshID &&
-         this->GetId()    != d->mySubMeshID &&
-         !_father->GetSubMeshContaining( d->mySubMeshID ))
+    SMESH_Mesh* mesh = _father->FindMesh( d->myMeshID );
+    if ( !mesh || !mesh->GetSubMeshContaining( d->mySubMeshID ))
       continue;
     d->mySubMesh->DeleteEventListener( d->myListener );
   }
index 505b85f729c0d8fd13105c8978087f8f79217870..7d3097997dd2a04d230a566dbf3af73fe41f677e 100644 (file)
 #include "Utils_SALOME_Exception.hxx"
 #include "utilities.h"
 
+#include <BRepBndLib.hxx>
 #include <BRepClass_FaceClassifier.hxx>
 #include <BRepTools.hxx>
 #include <BRep_Builder.hxx>
 #include <BRep_Tool.hxx>
 #include <Bnd_B2d.hxx>
+#include <Bnd_Box.hxx>
 #include <GeomAPI_ProjectPointOnSurf.hxx>
 #include <GeomAdaptor_Surface.hxx>
 #include <Precision.hxx>
@@ -191,12 +193,13 @@ bool StdMeshers_Import_1D2D::Compute(SMESH_Mesh & theMesh, const TopoDS_Shape &
   const bool toCheckOri = (helper.NbAncestors( geomFace, theMesh, TopAbs_SOLID ) == 1 );
 
   Handle(Geom_Surface) surface = BRep_Tool::Surface( geomFace );
-  const bool reverse = 
+  const bool reverse =
     ( helper.GetSubShapeOri( tgtMesh->ShapeToMesh(), geomFace ) == TopAbs_REVERSED );
   gp_Pnt p; gp_Vec du, dv;
 
   BRepClass_FaceClassifier classifier;
   Bnd_B2d bndBox2d;
+  Bnd_Box bndBox3d;
   {
     Standard_Real umin,umax,vmin,vmax;
     BRepTools::UVBounds(geomFace,umin,umax,vmin,vmax);
@@ -212,6 +215,9 @@ bool StdMeshers_Import_1D2D::Compute(SMESH_Mesh & theMesh, const TopoDS_Shape &
       bndBox2d.Add( pmax );
     }
     bndBox2d.Enlarge( 1e-2 * Sqrt( bndBox2d.SquareExtent() ));
+
+    BRepBndLib::Add( geomFace, bndBox3d );
+    bndBox3d.Enlarge( 1e-4 * sqrt( bndBox3d.SquareExtent() ));
   }
 
   set<int> subShapeIDs;
@@ -284,9 +290,10 @@ bool StdMeshers_Import_1D2D::Compute(SMESH_Mesh & theMesh, const TopoDS_Shape &
     const double groupTol = 0.5 * sqrt( getMinElemSize2( srcGroup ));
     minGroupTol = std::min( groupTol, minGroupTol );
 
-    GeomAdaptor_Surface S( surface );
-    const double clsfTol = Min( S.UResolution( 0.1 * groupTol ),
-                                S.VResolution( 0.1 * groupTol ));
+    //GeomAdaptor_Surface S( surface );
+    // const double clsfTol = Min( S.UResolution( 0.1 * groupTol ), -- issue 0023092
+    //                             S.VResolution( 0.1 * groupTol ));
+    const double clsfTol = BRep_Tool::Tolerance( geomFace );
 
     StdMeshers_Import_1D::TNodeNodeMap::iterator n2nIt;
     pair< StdMeshers_Import_1D::TNodeNodeMap::iterator, bool > it_isnew;
@@ -296,13 +303,16 @@ bool StdMeshers_Import_1D2D::Compute(SMESH_Mesh & theMesh, const TopoDS_Shape &
     {
       const SMDS_MeshElement* face = srcElems->next();
 
+      SMDS_MeshElement::iterator node = face->begin_nodes();
+      if ( bndBox3d.IsOut( SMESH_TNodeXYZ( *node )))
+        continue;
+
       // find or create nodes of a new face
       nodeState.resize( face->NbNodes() );
       newNodes.resize( nodeState.size() );
       newNodes.back() = 0;
       int nbCreatedNodes = 0;
       bool isOut = false, isIn = false; // if at least one node isIn - do not classify other nodes
-      SMDS_MeshElement::iterator node = face->begin_nodes();
       for ( size_t i = 0; i < newNodes.size(); ++i, ++node )
       {
         SMESH_TNodeXYZ nXYZ = *node;