Salome HOME
22364: EDF SMESH: Create Mesh dialog box improvement: hide inapplicable algorithms...
authoreap <eap@opencascade.com>
Tue, 25 Feb 2014 14:54:34 +0000 (18:54 +0400)
committereap <eap@opencascade.com>
Tue, 25 Feb 2014 14:54:34 +0000 (18:54 +0400)
1) Some optimization
2) Implement StdMeshers_Prism_3D::IsApplicable()

15 files changed:
src/SMESH_I/SMESH_Gen_i.cxx
src/StdMeshers/StdMeshers_Hexa_3D.cxx
src/StdMeshers/StdMeshers_Prism_3D.cxx
src/StdMeshers/StdMeshers_Prism_3D.hxx
src/StdMeshers/StdMeshers_Quadrangle_2D.cxx
src/StdMeshers/StdMeshers_RadialPrism_3D.cxx
src/StdMeshers/StdMeshers_RadialQuadrangle_1D2D.cxx
src/StdMeshers_I/StdMeshers_Hexa_3D_i.cxx
src/StdMeshers_I/StdMeshers_Hexa_3D_i.hxx
src/StdMeshers_I/StdMeshers_Prism_3D_i.cxx
src/StdMeshers_I/StdMeshers_Prism_3D_i.hxx
src/StdMeshers_I/StdMeshers_Quadrangle_2D_i.cxx
src/StdMeshers_I/StdMeshers_Quadrangle_2D_i.hxx
src/StdMeshers_I/StdMeshers_RadialQuadrangle_1D2D_i.hxx
src/StdMeshers_I/StdMeshers_i.cxx

index 200fa90341524dbdff8d25a7ee37a5cd81aa52c6..5ec51b54a8bfa88622a6d0247ae1f61303ec5f8c 100644 (file)
@@ -93,7 +93,7 @@
 #include "SMESH_Mesh_i.hxx"
 #include "SMESH_PreMeshInfo.hxx"
 #include "SMESH_PythonDump.hxx"
-//#include "memoire.h"
+#include "SMESH_TryCatch.hxx" // to include after OCC headers!
 
 #include CORBA_SERVER_HEADER(SMESH_Group)
 #include CORBA_SERVER_HEADER(SMESH_Filter)
@@ -5070,27 +5070,33 @@ CORBA::Boolean SMESH_Gen_i::IsApplicable ( const char*           theAlgoType,
                                            GEOM::GEOM_Object_ptr theGeomObject,
                                            CORBA::Boolean        toCheckAll)
 {
+  SMESH_TRY;
+
   std::string aPlatformLibName;
   typedef GenericHypothesisCreator_i* (*GetHypothesisCreator)(const char*);
   GenericHypothesisCreator_i* aCreator = getHypothesisCreator(theAlgoType, theLibName, aPlatformLibName);
   if (aCreator)
   {
     TopoDS_Shape shape = GeomObjectToShape( theGeomObject );
-    return aCreator->IsApplicable( shape, toCheckAll );
+    if ( !shape.IsNull() )
+      return aCreator->IsApplicable( shape, toCheckAll );
   }
   else
   {
-    if(MYDEBUG) { MESSAGE( "Shape not defined"); }
     return false;
   }
+
+  SMESH_CATCH( SMESH::doNothing );
+  return true;
 }
 
 //=================================================================================
 // function : importData
 // purpose  : imports mesh data file (the med one) into the SMESH internal data structure
 //=================================================================================
-Engines::ListOfIdentifiers* SMESH_Gen_i::importData(
-  CORBA::Long studyId, Engines::DataContainer_ptr data, const Engines::ListOfOptions& options)
+Engines::ListOfIdentifiers* SMESH_Gen_i::importData(CORBA::Long                   studyId,
+                                                    Engines::DataContainer_ptr    data,
+                                                    const Engines::ListOfOptions& options)
 {
   Engines::ListOfIdentifiers_var aResultIds = new Engines::ListOfIdentifiers;
   list<string> aResultList;
index 22b658de4e450c8ebb89adbe7cc693b719c1aa70..fd67131876cd7fd9ea1c58ff1375233379370f31 100644 (file)
@@ -743,7 +743,10 @@ bool StdMeshers_Hexa_3D::Compute(SMESH_Mesh & aMesh, SMESH_MesherHelper* aHelper
 
 //================================================================================
 /*!
- * \brief Return true if applied compute mesh on this shape
+ * \brief Return true if the algorithm can mesh this shape
+ *  \param [in] aShape - shape to check
+ *  \param [in] toCheckAll - if true, this check returns OK if all shapes are OK,
+ *              else, returns OK if all at least one shape is OK
  */
 //================================================================================
 
@@ -753,19 +756,24 @@ bool StdMeshers_Hexa_3D::IsApplicable( const TopoDS_Shape & aShape, bool toCheck
   TopTools_IndexedMapOfOrientedShape theShapeIDMap;
   bool isCurShellApp;
   int nbFoundShells = 0;
-  bool isEmpty = true;
-  for ( TopExp_Explorer exp0( aShape, TopAbs_SOLID ); exp0.More(); exp0.Next() ){
-    nbFoundShells = 0;
+  TopExp_Explorer exp0( aShape, TopAbs_SOLID );
+  if ( !exp0.More() ) return false;
+  for ( ; exp0.More(); exp0.Next() )
+  {
+    nbFoundShells = 1;
+    isCurShellApp = false;
     for (TopExp_Explorer exp1( exp0.Current(), TopAbs_SHELL ); exp1.More(); exp1.Next(), ++nbFoundShells){
-      TopoDS_Shell shell = TopoDS::Shell(exp1.Current());
+      if ( nbFoundShells == 2 ) {
+        if ( toCheckAll ) return false;
+        break;
+      }
+      const TopoDS_Shell& shell = TopoDS::Shell(exp1.Current());
       isCurShellApp = SMESH_Block::FindBlockShapes(shell, theVertex0, theVertex1, theShapeIDMap );
-      if( ( toCheckAll && !isCurShellApp ) || nbFoundShells == 1 ) return false;
-      isEmpty = false;
+      if ( toCheckAll && !isCurShellApp ) return false;
     }
     if( !toCheckAll && isCurShellApp ) return true;
   }
-  if( toCheckAll && !isEmpty) return true;
-  return false;
+  return toCheckAll;
 };
 
 //=======================================================================
index 6019723a70d581e3811def71d7c2751cec3a0ea4..5a1be1b5f1171a097b7f78528df9413e5db91c76 100644 (file)
@@ -2037,6 +2037,341 @@ int StdMeshers_Prism_3D::shapeID( const TopoDS_Shape& S )
   return myHelper->GetMeshDS()->ShapeToIndex( S );
 }
 
+namespace // utils used by StdMeshers_Prism_3D::IsApplicable()
+{
+  struct EdgeWithNeighbors
+  {
+    TopoDS_Edge _edge;
+    int         _iL, _iR;
+    EdgeWithNeighbors(const TopoDS_Edge& E, int iE, int nbE, int shift = 0 ):
+      _edge( E ),
+      _iL( SMESH_MesherHelper::WrapIndex( iE-1, nbE ) + shift ),
+      _iR( SMESH_MesherHelper::WrapIndex( iE+1, nbE ) + shift )
+    {
+    }
+    EdgeWithNeighbors() {}
+  };
+  struct PrismSide
+  {
+    TopoDS_Face                 _face;
+    TopTools_IndexedMapOfShape *_faces; // pointer because its copy constructor is private
+    TopoDS_Edge                 _topEdge;
+    vector< EdgeWithNeighbors >*_edges;
+    int                         _iBotEdge;
+    vector< bool >              _isCheckedEdge;
+    int                         _nbCheckedEdges; // nb of EDGEs whose location is defined
+    PrismSide                  *_leftSide;
+    PrismSide                  *_rightSide;
+    const TopoDS_Edge& Edge( int i ) const
+    {
+      return (*_edges)[ i ]._edge;
+    }
+    int FindEdge( const TopoDS_Edge& E ) const
+    {
+      for ( size_t i = 0; i < _edges->size(); ++i )
+        if ( E.IsSame( Edge( i ))) return i;
+      return -1;
+    }
+  };
+  //--------------------------------------------------------------------------------
+  /*!
+   * \brief Return ordered edges of a face
+   */
+  bool getEdges( const TopoDS_Face&            face,
+                 vector< EdgeWithNeighbors > & edges,
+                 const bool                    noHolesAllowed)
+  {
+    list< TopoDS_Edge > ee;
+    list< int >         nbEdgesInWires;
+    int nbW = SMESH_Block::GetOrderedEdges( face, ee, nbEdgesInWires );
+    if ( nbW > 1 && noHolesAllowed )
+      return false;
+
+    int iE, nbTot = 0;
+    list< TopoDS_Edge >::iterator e = ee.begin();
+    list< int >::iterator       nbE = nbEdgesInWires.begin();
+    for ( ; nbE != nbEdgesInWires.end(); ++nbE )
+      for ( iE = 0; iE < *nbE; ++e, ++iE )
+        if ( SMESH_Algo::isDegenerated( *e ))
+        {
+          ee.erase( e );
+          --(*nbE);
+          --iE;
+        }
+        else
+        {
+          e->Orientation( TopAbs_FORWARD ); // for operator==() to work
+        }
+
+    edges.clear();
+    e = ee.begin();
+    for ( nbE = nbEdgesInWires.begin(); nbE != nbEdgesInWires.end(); ++nbE )
+    {
+      for ( iE = 0; iE < *nbE; ++e, ++iE )
+        edges.push_back( EdgeWithNeighbors( *e, iE, *nbE, nbTot ));
+      nbTot += *nbE;
+    }
+    return edges.size();
+  }
+  //--------------------------------------------------------------------------------
+  /*!
+   * \brief Return another faces sharing an edge
+   */
+  const TopoDS_Shape & getAnotherFace( const TopoDS_Face& face,
+                                       const TopoDS_Edge& edge,
+                                       TopTools_IndexedDataMapOfShapeListOfShape& facesOfEdge)
+  {
+    TopTools_ListIteratorOfListOfShape faceIt( facesOfEdge.FindFromKey( edge ));
+    for ( ; faceIt.More(); faceIt.Next() )
+      if ( !face.IsSame( faceIt.Value() ))
+        return faceIt.Value();
+    return face;
+  }
+}
+
+//================================================================================
+/*!
+ * \brief Return true if the algorithm can mesh this shape
+ *  \param [in] aShape - shape to check
+ *  \param [in] toCheckAll - if true, this check returns OK if all shapes are OK,
+ *              else, returns OK if all at least one shape is OK
+ */
+//================================================================================
+
+bool StdMeshers_Prism_3D::IsApplicable(const TopoDS_Shape & shape, bool toCheckAll)
+{
+  TopExp_Explorer sExp( shape, TopAbs_SOLID );
+  if ( !sExp.More() )
+    return false;
+
+  for ( ; sExp.More(); sExp.Next() )
+  {
+    // check nb shells
+    TopoDS_Shape shell;
+    TopExp_Explorer shExp( sExp.Current(), TopAbs_SHELL );
+    if ( shExp.More() ) {
+      shell = shExp.Current();
+      shExp.Next();
+      if ( shExp.More() )
+        shell.Nullify();
+    }
+    if ( shell.IsNull() ) {
+      if ( toCheckAll ) return false;
+      continue;
+    }
+    // get all faces
+    TopTools_IndexedMapOfShape allFaces;
+    TopExp::MapShapes( shell, TopAbs_FACE, allFaces );
+    if ( allFaces.Extent() < 3 ) {
+      if ( toCheckAll ) return false;
+      continue;
+    }
+    // is a box?
+    if ( allFaces.Extent() == 6 )
+    {
+      TopTools_IndexedMapOfOrientedShape map;
+      bool isBox = SMESH_Block::FindBlockShapes( TopoDS::Shell( shell ),
+                                                 TopoDS_Vertex(), TopoDS_Vertex(), map );
+      if ( isBox ) {
+        if ( !toCheckAll ) return true;
+        continue;
+      }
+    }
+#ifdef _DEBUG_
+    TopTools_IndexedMapOfShape allShapes;
+    TopExp::MapShapes( shape, allShapes );
+#endif
+
+    TopTools_IndexedDataMapOfShapeListOfShape facesOfEdge;
+    TopTools_ListIteratorOfListOfShape faceIt;
+    TopExp::MapShapesAndAncestors( sExp.Current(), TopAbs_EDGE, TopAbs_FACE , facesOfEdge );
+    if ( facesOfEdge.IsEmpty() ) {
+      if ( toCheckAll ) return false;
+      continue;
+    }
+
+    typedef vector< EdgeWithNeighbors > TEdgeWithNeighborsVec;
+    vector< TEdgeWithNeighborsVec > faceEdgesVec( allFaces.Extent() + 1 );
+    TopTools_IndexedMapOfShape* facesOfSide = new TopTools_IndexedMapOfShape[ faceEdgesVec.size() ];
+    SMESHUtils::ArrayDeleter<TopTools_IndexedMapOfShape> delFacesOfSide( facesOfSide );
+
+    // try to use each face as a bottom one
+    bool prismDetected = false;
+    for ( int iF = 1; iF < allFaces.Extent() && !prismDetected; ++iF )
+    {
+      const TopoDS_Face& botF = TopoDS::Face( allFaces( iF ));
+
+      TEdgeWithNeighborsVec& botEdges = faceEdgesVec[ iF ];
+      if ( botEdges.empty() )
+      {
+        if ( !getEdges( botF, botEdges, /*noHoles=*/false ))
+          break;
+        if ( allFaces.Extent()-1 <= (int) botEdges.size() )
+          continue; // all faces are adjacent to botF - no top FACE
+      }
+      // init data of side FACEs
+      vector< PrismSide > sides( botEdges.size() );
+      for ( int iS = 0; iS < botEdges.size(); ++iS )
+      {
+        sides[ iS ]._topEdge = botEdges[ iS ]._edge;
+        sides[ iS ]._face    = botF;
+        sides[ iS ]._leftSide  = & sides[ botEdges[ iS ]._iR ];
+        sides[ iS ]._rightSide = & sides[ botEdges[ iS ]._iL ];
+        sides[ iS ]._faces = & facesOfSide[ iS ];
+        sides[ iS ]._faces->Clear();
+      }
+
+      bool isOK = true; // ok for a current botF
+      bool isAdvanced = true;
+      int nbFoundSideFaces = 0;
+      for ( int iLoop = 0; isOK && isAdvanced; ++iLoop )
+      {
+        isAdvanced = false;
+        for ( size_t iS = 0; iS < sides.size() && isOK; ++iS )
+        {
+          PrismSide& side = sides[ iS ];
+          if ( side._face.IsNull() )
+            continue;
+          if ( side._topEdge.IsNull() )
+          {
+            // find vertical EDGEs --- EGDEs shared with neighbor side FACEs
+            for ( int is2nd = 0; is2nd < 2 && isOK; ++is2nd ) // 2 adjacent neighbors
+            {
+              int di = is2nd ? 1 : -1;
+              const PrismSide* adjSide = is2nd ? side._rightSide : side._leftSide;
+              for ( size_t i = 1; i < side._edges->size(); ++i )
+              {
+                int iE = SMESH_MesherHelper::WrapIndex( i*di + side._iBotEdge, side._edges->size());
+                if ( side._isCheckedEdge[ iE ] ) continue;
+                const TopoDS_Edge&      vertE = side.Edge( iE );
+                const TopoDS_Shape& neighborF = getAnotherFace( side._face, vertE, facesOfEdge );
+                bool isEdgeShared = adjSide->_faces->Contains( neighborF );
+                if ( isEdgeShared )
+                {
+                  isAdvanced = true;
+                  side._isCheckedEdge[ iE ] = true;
+                  side._nbCheckedEdges++;
+                  int nbNotCheckedE = side._edges->size() - side._nbCheckedEdges;
+                  if ( nbNotCheckedE == 1 )
+                    break;
+                }
+                else
+                {
+                  if ( i == 1 && iLoop == 0 ) isOK = false;
+                  break;
+                }
+              }
+            }
+            // find a top EDGE
+            int nbNotCheckedE = side._edges->size() - side._nbCheckedEdges;
+            if ( nbNotCheckedE == 1 )
+            {
+              vector<bool>::iterator ii = std::find( side._isCheckedEdge.begin(),
+                                                     side._isCheckedEdge.end(), false );
+              if ( ii != side._isCheckedEdge.end() )
+              {
+                size_t iE = std::distance( side._isCheckedEdge.begin(), ii );
+                side._topEdge = side.Edge( iE );
+              }
+            }
+            isOK = ( nbNotCheckedE >= 1 );
+          }
+          else //if ( !side._topEdge.IsNull() )
+          {
+            // get a next face of a side
+            const TopoDS_Shape& f = getAnotherFace( side._face, side._topEdge, facesOfEdge );
+            side._faces->Add( f );
+            bool stop = false;
+            if ( f.IsSame( side._face ) || // _topEdge is a seam
+                 SMESH_MesherHelper::Count( f, TopAbs_WIRE, false ) != 1 )
+            {
+              stop = true;
+            }
+            else if ( side._leftSide != & side ) // not closed side face
+            {
+              if ( side._leftSide->_faces->Contains( f ))
+              {
+                stop = true;
+                side._leftSide->_face.Nullify();
+                side._leftSide->_topEdge.Nullify();
+              }
+              if ( side._rightSide->_faces->Contains( f ))
+              {
+                stop = true;
+                side._rightSide->_face.Nullify();
+                side._rightSide->_topEdge.Nullify();
+              }
+            }
+            if ( stop )
+            {
+              side._face.Nullify();
+              side._topEdge.Nullify();
+              continue;
+            }
+            side._face = TopoDS::Face( f );
+            int faceID = allFaces.FindIndex( side._face );
+            side._edges = & faceEdgesVec[ faceID ];
+            if ( side._edges->empty() )
+              if ( !getEdges( side._face, * side._edges, /*noHoles=*/true ))
+                break;
+            const int nbE = side._edges->size();
+            if ( nbE >= 4 )
+            {
+              isAdvanced = true;
+              ++nbFoundSideFaces;
+              side._iBotEdge = side.FindEdge( side._topEdge );
+              side._isCheckedEdge.clear();
+              side._isCheckedEdge.resize( nbE, false );
+              side._isCheckedEdge[ side._iBotEdge ] = true;
+              side._nbCheckedEdges = 1; // bottom EDGE is known
+            }
+            side._topEdge.Nullify();
+            isOK = ( !side._edges->empty() || side._faces->Extent() > 1 );
+
+          } //if ( !side._topEdge.IsNull() )
+
+        } // loop on prism sides
+
+        if ( nbFoundSideFaces > allFaces.Extent() )
+        {
+          isOK = false;
+        }
+        if ( iLoop > allFaces.Extent() * 10 )
+        {
+          isOK = false;
+#ifdef _DEBUG_
+          cerr << "BUG: infinite loop in StdMeshers_Prism_3D::IsApplicable()" << endl;
+#endif
+        }
+      } // while isAdvanced
+
+      if ( isOK && sides[0]._faces->Extent() > 1 )
+      {
+        const int nbFaces = sides[0]._faces->Extent();
+        if ( botEdges.size() == 1 ) // cylinder
+        {
+          prismDetected = ( nbFaces == allFaces.Extent()-1 );
+        }
+        else
+        {
+          const TopoDS_Shape& topFace = sides[0]._faces->FindKey( nbFaces );
+          size_t iS;
+          for ( iS = 1; iS < sides.size(); ++iS )
+            if ( !sides[ iS ]._faces->Contains( topFace ))
+              break;
+          prismDetected = ( iS == sides.size() );
+        }
+      }
+    } // loop on allFaces
+
+    if ( !prismDetected && toCheckAll ) return false;
+    if ( prismDetected && !toCheckAll ) return true;
+
+  } // loop on solids
+
+  return toCheckAll;
+}
+
 namespace Prism_3D
 {
   //================================================================================
index d76f747bcb2f8dad6a986f25ac951d179cc0bb32..3a4f61f4dcd49d4bd2e4294be4db7d8f43a841ba 100644 (file)
@@ -432,9 +432,11 @@ public:
     * \param helper - helper initialized by mesh and shape to add prisms to
    */
   static void AddPrisms( std::vector<const TNodeColumn*> & nodeColumns,
-                         SMESH_MesherHelper*          helper);
+                         SMESH_MesherHelper*               helper);
 
-private:
+  static bool IsApplicable(const TopoDS_Shape & aShape, bool toCheckAll);
+
+ private:
 
   /*!
    * \brief Analyse shape geometry and mesh.
index 89e8042b494892e6ae83b253aee0a57775c2e3db..7b37553fd33b0cde09f49bf5bae57a454b8e4127 100644 (file)
@@ -906,32 +906,39 @@ bool StdMeshers_Quadrangle_2D::Evaluate(SMESH_Mesh&         aMesh,
 
 //================================================================================
 /*!
- * \brief Return true if applied compute mesh on this shape
+ * \brief Return true if the algorithm can mesh this shape
+ *  \param [in] aShape - shape to check
+ *  \param [in] toCheckAll - if true, this check returns OK if all shapes are OK,
+ *              else, returns OK if all at least one shape is OK
  */
 //================================================================================
 
 bool StdMeshers_Quadrangle_2D::IsApplicable( const TopoDS_Shape & aShape, bool toCheckAll )
 {
   int nbFoundFaces = 0;
-  for (TopExp_Explorer exp( aShape, TopAbs_FACE ); exp.More(); exp.Next(), ++nbFoundFaces ){
+  for (TopExp_Explorer exp( aShape, TopAbs_FACE ); exp.More(); exp.Next(), ++nbFoundFaces )
+  {
     TopoDS_Face aFace = TopoDS::Face(exp.Current());
     if ( aFace.Orientation() >= TopAbs_INTERNAL ) aFace.Orientation( TopAbs_FORWARD );
 
     list< TopoDS_Edge > aWire;
     list< int > nbEdgesInWire;
     int nbWire = SMESH_Block::GetOrderedEdges (aFace, aWire, nbEdgesInWire);
+    if ( nbWire != 1 ) {
+      if ( toCheckAll ) return false;
+      continue;
+    }
 
     int nbNoDegenEdges = 0;
     list<TopoDS_Edge>::iterator edge = aWire.begin();
-      for ( ; edge != aWire.end(); ++edge ){
-        if ( !SMESH_Algo::isDegenerated( *edge ))
-          ++nbNoDegenEdges;
-      }
-      if( toCheckAll && (nbWire != 1 || nbNoDegenEdges <= 3 ) ) return false;
-      if( !toCheckAll && nbWire == 1 && nbNoDegenEdges > 3 ) return true;
+    for ( ; edge != aWire.end(); ++edge ) {
+      if ( !SMESH_Algo::isDegenerated( *edge ))
+        ++nbNoDegenEdges;
+    }
+    if ( toCheckAll  && nbNoDegenEdges <  3 ) return false;
+    if ( !toCheckAll && nbNoDegenEdges >= 3 ) return true;
   }
-  if( toCheckAll && nbFoundFaces != 0) return true;
-  return false;
+  return ( toCheckAll && nbFoundFaces != 0 );
 };
 
 //================================================================================
index 5dbf7fb29f59b80961849eb83845837de5831e49..f6d39bd3e218246ecd513218c2f42b59724cc65f 100644 (file)
@@ -601,7 +601,10 @@ bool StdMeshers_RadialPrism_3D::Evaluate(SMESH_Mesh& aMesh,
 
 //================================================================================
 /*!
- * \brief Return true if applied compute mesh on this shape
+ * \brief Return true if the algorithm can mesh this shape
+ *  \param [in] aShape - shape to check
+ *  \param [in] toCheckAll - if true, this check returns OK if all shapes are OK,
+ *              else, returns OK if all at least one shape is OK
  */
 //================================================================================
 
@@ -609,39 +612,40 @@ bool StdMeshers_RadialPrism_3D::IsApplicable( const TopoDS_Shape & aShape, bool
 {
   bool isCurShellApp;
   int nbFoundSolids = 0;
-  for (TopExp_Explorer exp( aShape, TopAbs_SOLID ); exp.More(); exp.Next(), ++nbFoundSolids ){
-#if OCC_VERSION_LARGE > 0x06050400
-    TopoDS_Shell outerShell = BRepClass3d::OuterShell( TopoDS::Solid( exp.Current() ));
-#else
-    TopoDS_Shell outerShell = BRepTools::OuterShell( TopoDS::Solid( exp.Current() ));
-#endif
-    TopoDS_Shape innerShell;
+  for (TopExp_Explorer exp( aShape, TopAbs_SOLID ); exp.More(); exp.Next(), ++nbFoundSolids )
+  {
+    TopoDS_Shape shell[2];
     int nbShells = 0;
-    for ( TopoDS_Iterator It (exp.Current()); It.More(); It.Next(), ++nbShells )
-      if ( !outerShell.IsSame( It.Value() ))
-        innerShell = It.Value();
-    if ( nbShells != 2 ) { nbFoundSolids--; continue; }
+    for ( TopoDS_Iterator It (exp.Current()); It.More(); It.Next() )
+    {
+      nbShells++;
+      if ( nbShells > 2 ) {
+        if ( toCheckAll ) return false;
+        break;
+      }
+      shell[ nbShells-1 ] = It.Value();
+    }
+    if ( nbShells != 2 ) continue;
 
-    int nbFaces1 = SMESH_MesherHelper:: Count( innerShell, TopAbs_FACE, 0 );
-    int nbFaces2 = SMESH_MesherHelper:: Count( outerShell, TopAbs_FACE, 0 );
+    int nbFaces1 = SMESH_MesherHelper:: Count( shell[0], TopAbs_FACE, 0 );
+    int nbFaces2 = SMESH_MesherHelper:: Count( shell[1], TopAbs_FACE, 0 );
     if ( nbFaces1 != nbFaces2 ){
       if( toCheckAll ) return false;
       continue;
     }
-    int nbEdges1 = SMESH_MesherHelper:: Count( innerShell, TopAbs_EDGE, 0 );
-    int nbEdges2 = SMESH_MesherHelper:: Count( outerShell, TopAbs_EDGE, 0 );
+    int nbEdges1 = SMESH_MesherHelper:: Count( shell[0], TopAbs_EDGE, 0 );
+    int nbEdges2 = SMESH_MesherHelper:: Count( shell[1], TopAbs_EDGE, 0 );
     if ( nbEdges1 != nbEdges2 ){
       if( toCheckAll ) return false;
       continue;
     }
-    int nbVertices1 = SMESH_MesherHelper:: Count( innerShell, TopAbs_VERTEX, 0 );
-    int nbVertices2 = SMESH_MesherHelper:: Count( outerShell, TopAbs_VERTEX, 0 );
+    int nbVertices1 = SMESH_MesherHelper:: Count( shell[0], TopAbs_VERTEX, 0 );
+    int nbVertices2 = SMESH_MesherHelper:: Count( shell[1], TopAbs_VERTEX, 0 );
     if ( nbVertices1 != nbVertices2 ){
       if( toCheckAll ) return false;
       continue;
     }
     if ( !toCheckAll ) return true;
   }
-  if( toCheckAll && nbFoundSolids != 0) return true;
-  return false;
+  return ( toCheckAll && nbFoundSolids != 0);
 };
index 83e667968052f799a550cecbd61eebd633688a86..92b2949002e18f62f822772b8113341583e509cb 100644 (file)
@@ -1293,10 +1293,11 @@ bool StdMeshers_RadialQuadrangle_1D2D::IsApplicable( const TopoDS_Shape & aShape
   int nbFoundFaces = 0;
   for (TopExp_Explorer exp( aShape, TopAbs_FACE ); exp.More(); exp.Next(), ++nbFoundFaces ){
     TopoDS_Edge CircEdge, LinEdge1, LinEdge2;
-    int nbe = analyseFace( TopoDS_Shape( exp.Current() ), CircEdge, LinEdge1, LinEdge2 );
+    int nbe = analyseFace( exp.Current(), CircEdge, LinEdge1, LinEdge2 );
     Handle(Geom_Circle) aCirc = Handle(Geom_Circle)::DownCast( getCurve( CircEdge ));
-    if( toCheckAll && ( nbe > 3 || nbe < 1 || aCirc.IsNull() )) return false;
-    if( !toCheckAll && ( nbe <= 3 && nbe >= 1 && !aCirc.IsNull() )) return true;
+    bool ok = ( nbe <= 3 && nbe >= 1 && !aCirc.IsNull() );
+    if( toCheckAll  && !ok ) return false;
+    if( !toCheckAll && ok  ) return true;
   }
   if( toCheckAll && nbFoundFaces != 0 ) return true;
   return false;
index 2aceaede23f49f439554cb3929e4b4fadd1ad994..9b1f7e22b22ae85b7952a9fcd24baf6d11fd97cc 100644 (file)
@@ -25,7 +25,6 @@
 //           Moved here from SMESH_Hexa_3D_i.cxx
 //  Author : Paul RASCLE, EDF
 //  Module : SMESH
-//  $Header$
 //
 #include "StdMeshers_Hexa_3D_i.hxx"
 #include "SMESH_Gen.hxx"
@@ -44,17 +43,17 @@ using namespace std;
 //=============================================================================
 
 StdMeshers_Hexa_3D_i::StdMeshers_Hexa_3D_i( PortableServer::POA_ptr thePOA,
-                                  int                     theStudyId,
-                                  ::SMESH_Gen*            theGenImpl )
-     : SALOME::GenericObj_i( thePOA ), 
-       SMESH_Hypothesis_i( thePOA ), 
-       SMESH_Algo_i( thePOA ),
-       SMESH_3D_Algo_i( thePOA )
+                                            int                     theStudyId,
+                                            ::SMESH_Gen*            theGenImpl )
+  : SALOME::GenericObj_i( thePOA ),
+    SMESH_Hypothesis_i( thePOA ),
+    SMESH_Algo_i( thePOA ),
+    SMESH_3D_Algo_i( thePOA )
 {
   MESSAGE( "StdMeshers_Hexa_3D_i::StdMeshers_Hexa_3D_i" );
   myBaseImpl = new ::StdMeshers_Hexa_3D( theGenImpl->GetANewId(),
-                                    theStudyId,
-                                    theGenImpl );
+                                         theStudyId,
+                                         theGenImpl );
 }
 
 //=============================================================================
@@ -88,11 +87,12 @@ StdMeshers_Hexa_3D_i::~StdMeshers_Hexa_3D_i()
 /*!
  *  StdMeshers_Hexa_3D_i::IsApplicable
  *
- *  Method return true if algorithm is applicable
+ *  Return true if the algorithm is applicable to a shape
  */
 //=============================================================================
 
-CORBA::Boolean StdMeshers_Hexa_3D_i::IsApplicable( const TopoDS_Shape &S, CORBA::Boolean toCheckAll )
+CORBA::Boolean StdMeshers_Hexa_3D_i::IsApplicable( const TopoDS_Shape &S,
+                                                   CORBA::Boolean toCheckAll )
 {
   return ::StdMeshers_Hexa_3D::IsApplicable( S, toCheckAll );
 }
index 633793ba793ab0007af8ec6127e5898a39c9ba53..999eb94d2d4cf188db372d4762d5fcf0253fc642 100644 (file)
@@ -25,7 +25,6 @@
 //           Moved here from SMESH_Hexa_3D_i.hxx
 //  Author : Paul RASCLE, EDF
 //  Module : SMESH
-//  $Header$
 //
 #ifndef _SMESH_HEXA_3D_I_HXX_
 #define _SMESH_HEXA_3D_I_HXX_
@@ -59,7 +58,7 @@ public:
   // Get implementation
   ::StdMeshers_Hexa_3D* GetImpl();
 
-  // Method return true if algorithm is applicable
+  // Return true if the algorithm is applicable to a shape
   static CORBA::Boolean IsApplicable(const TopoDS_Shape &S, CORBA::Boolean toCheckAll);
 };
 
index 6425523381aaaa528d3af3084d1e69e435bcecaf..450e32586e16d78fec4e5c8ab6098ba4ebe33670 100644 (file)
@@ -25,7 +25,6 @@
 //           Moved here from SMESH_Prism_3D_i.cxx
 //  Author : Paul RASCLE, EDF
 //  Module : SMESH
-//  $Header$
 //
 #include "StdMeshers_Prism_3D_i.hxx"
 #include "SMESH_Gen.hxx"
@@ -42,12 +41,12 @@ using namespace std;
 //=============================================================================
 
 StdMeshers_Prism_3D_i::StdMeshers_Prism_3D_i( PortableServer::POA_ptr thePOA,
-                                  int                     theStudyId,
-                                  ::SMESH_Gen*            theGenImpl )
-     : SALOME::GenericObj_i( thePOA ), 
-       SMESH_Hypothesis_i( thePOA ), 
-       SMESH_Algo_i( thePOA ),
-       SMESH_3D_Algo_i( thePOA )
+                                              int                     theStudyId,
+                                              ::SMESH_Gen*            theGenImpl )
+  : SALOME::GenericObj_i( thePOA ),
+    SMESH_Hypothesis_i( thePOA ),
+    SMESH_Algo_i( thePOA ),
+    SMESH_3D_Algo_i( thePOA )
 {
   MESSAGE( "StdMeshers_Prism_3D_i::StdMeshers_Prism_3D_i" );
   myBaseImpl = new ::StdMeshers_Prism_3D( theGenImpl->GetANewId(),
@@ -67,6 +66,13 @@ StdMeshers_Prism_3D_i::~StdMeshers_Prism_3D_i()
   MESSAGE( "StdMeshers_Prism_3D_i::GetImpl" );
   return ( ::StdMeshers_Prism_3D* )myBaseImpl;
 }
+//-----------------------------------------------------------------------------
+
+CORBA::Boolean StdMeshers_Prism_3D_i::IsApplicable( const TopoDS_Shape &S,
+                                                    CORBA::Boolean toCheckAll )
+{
+  return ::StdMeshers_Prism_3D::IsApplicable( S, toCheckAll );
+}
 
 
 //=============================================================================
@@ -76,17 +82,17 @@ StdMeshers_Prism_3D_i::~StdMeshers_Prism_3D_i()
 //=============================================================================
 
 StdMeshers_RadialPrism_3D_i::StdMeshers_RadialPrism_3D_i( PortableServer::POA_ptr thePOA,
-                                  int                     theStudyId,
-                                  ::SMESH_Gen*            theGenImpl )
-     : SALOME::GenericObj_i( thePOA ), 
-       SMESH_Hypothesis_i( thePOA ), 
-       SMESH_Algo_i( thePOA ),
-       SMESH_3D_Algo_i( thePOA )
+                                                          int                     theStudyId,
+                                                          ::SMESH_Gen*            theGenImpl )
+  : SALOME::GenericObj_i( thePOA ),
+    SMESH_Hypothesis_i( thePOA ),
+    SMESH_Algo_i( thePOA ),
+    SMESH_3D_Algo_i( thePOA )
 {
   MESSAGE( "StdMeshers_RadialPrism_3D_i::StdMeshers_RadialPrism_3D_i" );
   myBaseImpl = new ::StdMeshers_RadialPrism_3D( theGenImpl->GetANewId(),
-                                    theStudyId,
-                                    theGenImpl );
+                                                theStudyId,
+                                                theGenImpl );
 }
 //-----------------------------------------------------------------------------
 
@@ -103,7 +109,8 @@ StdMeshers_RadialPrism_3D_i::~StdMeshers_RadialPrism_3D_i()
 }
 //-----------------------------------------------------------------------------
 
-CORBA::Boolean StdMeshers_RadialPrism_3D_i::IsApplicable( const TopoDS_Shape &S, CORBA::Boolean toCheckAll )
+CORBA::Boolean StdMeshers_RadialPrism_3D_i::IsApplicable( const TopoDS_Shape &S,
+                                                          CORBA::Boolean toCheckAll )
 {
   return ::StdMeshers_RadialPrism_3D::IsApplicable( S, toCheckAll );
 }
index 8850f4d95a2c62f774cbef765f9cabe8dbd9925c..dc01ef2e7c4542adb2c1beb3505e54054ed0fda9 100644 (file)
@@ -25,7 +25,6 @@
 //           Moved here from SMESH_Prism_3D_i.hxx
 //  Author : Paul RASCLE, EDF
 //  Module : SMESH
-//  $Header$
 //
 #ifndef _SMESH_Prism_3D_I_HXX_
 #define _SMESH_Prism_3D_I_HXX_
@@ -57,6 +56,9 @@ public:
 
   // Get implementation
   ::StdMeshers_Prism_3D* GetImpl();
+
+  // Return true if the algorithm is applicable to a shape
+  static CORBA::Boolean IsApplicable(const TopoDS_Shape &S, CORBA::Boolean toCheckAll);
 };
 
 // ======================================================
@@ -78,7 +80,7 @@ public:
   // Get implementation
   ::StdMeshers_RadialPrism_3D* GetImpl();
 
-  // Method return true if algorithm is applicable
+  // Return true if the algorithm is applicable to a shape
   static CORBA::Boolean IsApplicable(const TopoDS_Shape &S, CORBA::Boolean toCheckAll);
 };
 
index d169457fa4af4770522a31a458a0cf192b448370..3ca07c9e8f677b2f77d196b12bf52a813aa79bdd 100644 (file)
@@ -25,7 +25,6 @@
 //           Moved here from SMESH_Quadrangle_2D_i.cxx
 //  Author : Paul RASCLE, EDF
 //  Module : SMESH
-//  $Header$
 //
 #include "StdMeshers_Quadrangle_2D_i.hxx"
 #include "SMESH_Gen.hxx"
@@ -44,17 +43,17 @@ using namespace std;
 //=============================================================================
 
 StdMeshers_Quadrangle_2D_i::StdMeshers_Quadrangle_2D_i( PortableServer::POA_ptr thePOA,
-                                              int                     theStudyId,
-                                              ::SMESH_Gen*            theGenImpl )
-     : SALOME::GenericObj_i( thePOA ), 
-       SMESH_Hypothesis_i( thePOA ), 
-       SMESH_Algo_i( thePOA ),
-       SMESH_2D_Algo_i( thePOA )
+                                                        int                     theStudyId,
+                                                        ::SMESH_Gen*            theGenImpl )
+  : SALOME::GenericObj_i( thePOA ),
+    SMESH_Hypothesis_i( thePOA ),
+    SMESH_Algo_i( thePOA ),
+    SMESH_2D_Algo_i( thePOA )
 {
   MESSAGE( "StdMeshers_Quadrangle_2D_i::StdMeshers_Quadrangle_2D_i" );
   myBaseImpl = new ::StdMeshers_Quadrangle_2D( theGenImpl->GetANewId(),
-                                          theStudyId,
-                                          theGenImpl );
+                                               theStudyId,
+                                               theGenImpl );
 }
 
 //=============================================================================
@@ -62,7 +61,7 @@ StdMeshers_Quadrangle_2D_i::StdMeshers_Quadrangle_2D_i( PortableServer::POA_ptr
  *  StdMeshers_Quadrangle_2D_i::~StdMeshers_Quadrangle_2D_i
  *
  *  Destructor
- *  
+ *
  */
 //=============================================================================
 
@@ -89,11 +88,12 @@ StdMeshers_Quadrangle_2D_i::~StdMeshers_Quadrangle_2D_i()
 /*!
  *  StdMeshers_Quadrangle_2D_i::IsApplicable
  *
- *  Method return true if algorithm is applicable
+ *  Return true if the algorithm is applicable to a shape
  */
 //=============================================================================
 
-CORBA::Boolean StdMeshers_Quadrangle_2D_i::IsApplicable( const TopoDS_Shape &S, CORBA::Boolean toCheckAll )
+CORBA::Boolean StdMeshers_Quadrangle_2D_i::IsApplicable( const TopoDS_Shape &S,
+                                                         CORBA::Boolean toCheckAll )
 {
   return ::StdMeshers_Quadrangle_2D::IsApplicable( S, toCheckAll );
 }
index 690e9dc47e554834c38f2934891652e147987587..194817527ce8a6eaf946de31da138ec57c30b662 100644 (file)
@@ -25,7 +25,6 @@
 //           Moved here from SMESH_Quadrangle_2D_i.hxx
 //  Author : Paul RASCLE, EDF
 //  Module : SMESH
-//  $Header$
 //
 #ifndef _SMESH_QUADRANGLE_2D_I_HXX_
 #define _SMESH_QUADRANGLE_2D_I_HXX_
@@ -47,11 +46,11 @@ class STDMESHERS_I_EXPORT StdMeshers_Quadrangle_2D_i:
   public virtual POA_StdMeshers::StdMeshers_Quadrangle_2D,
   public virtual SMESH_2D_Algo_i
 {
-public:
+ public:
   // Constructor
   StdMeshers_Quadrangle_2D_i( PortableServer::POA_ptr thePOA,
-                         int                     theStudyId,
-                         ::SMESH_Gen*            theGenImpl );
+                              int                     theStudyId,
+                              ::SMESH_Gen*            theGenImpl );
 
   // Destructor
   virtual ~StdMeshers_Quadrangle_2D_i();
@@ -59,7 +58,7 @@ public:
   // Get implementation
   ::StdMeshers_Quadrangle_2D* GetImpl();
 
-  // Method return true if algorithm is applicable
+  // Return true if the algorithm is applicable to a shape
   static CORBA::Boolean IsApplicable(const TopoDS_Shape &S, CORBA::Boolean toCheckAll);
 };
 
index c15ea3a71256211bf7b08ec1237f05431ca6dcee..6b5ad31158e599ab74a125055bbffbf17713fb98 100644 (file)
@@ -48,7 +48,7 @@ public:
   // Get implementation
   ::StdMeshers_RadialQuadrangle_1D2D* GetImpl();
 
-  // Method return true if algorithm is applicable
+  // Return true if the algorithm is applicable to a shape
   static CORBA::Boolean IsApplicable(const TopoDS_Shape &S, CORBA::Boolean toCheckAll);
 };
 
index 14669202940c31d34ec0181f118c933695375015..bdfcb2fc8d3256e92a57b05d1857dea02e2ef36c 100644 (file)
@@ -84,7 +84,9 @@ namespace SMESH {
   class ApplicableToAny
   {
   public:
-    static CORBA::Boolean IsApplicable( const TopoDS_Shape &S, CORBA::Boolean toCheckAll ){ return true; }
+    static CORBA::Boolean IsApplicable( const TopoDS_Shape &S, CORBA::Boolean toCheckAll ) {
+      return true;
+    }
   };
 };
 template <class T, class TIsApplicable = SMESH::ApplicableToAny> class StdHypothesisCreator_i:public HypothesisCreator_i<T>
@@ -223,9 +225,9 @@ STDMESHERS_I_EXPORT
     else if (strcmp(aHypName, "Projection_2D") == 0)
       aCreator = new StdHypothesisCreator_i<StdMeshers_Projection_2D_i>;
     else if (strcmp(aHypName, "Projection_3D") == 0)
-      aCreator = new StdHypothesisCreator_i<StdMeshers_Projection_3D_i>;
+      aCreator = new StdHypothesisCreator_i<StdMeshers_Projection_3D_i, StdMeshers_Hexa_3D_i>;
     else if (strcmp(aHypName, "Prism_3D") == 0)
-      aCreator = new StdHypothesisCreator_i<StdMeshers_Prism_3D_i>;
+      aCreator = new StdHypothesisCreator_i<StdMeshers_Prism_3D_i, StdMeshers_Prism_3D_i>;
     else if (strcmp(aHypName, "RadialPrism_3D") == 0)
       aCreator = new StdHypothesisCreator_i<StdMeshers_RadialPrism_3D_i, StdMeshers_RadialPrism_3D_i>;
     else if (strcmp(aHypName, "SegmentAroundVertex_0D") == 0)