Salome HOME
merge with V5
authoreap <eap@opencascade.com>
Tue, 3 Nov 2009 09:53:16 +0000 (09:53 +0000)
committereap <eap@opencascade.com>
Tue, 3 Nov 2009 09:53:16 +0000 (09:53 +0000)
src/SMESH/SMESH_Algo.hxx
src/SMESH/SMESH_Gen.cxx
src/SMESH/SMESH_Gen.hxx
src/SMESH/SMESH_Hypothesis.hxx
src/SMESH/SMESH_subMesh.cxx
src/SMESH/SMESH_subMesh.hxx

index 5a4648207164d6d3ae6a9ed69f7e53734423ae96..35107fb220fbaaea0389b5c4a8087468aee3fe39 100644 (file)
@@ -125,6 +125,16 @@ public:
    */
   virtual bool Compute(SMESH_Mesh & aMesh, SMESH_MesherHelper* aHelper);
 
+  /*!
+   * \brief evaluates size of prospective mesh on a shape
+    * \param aMesh - the mesh
+    * \param aShape - the shape
+    * \param aNbElems - prospective number of elements by types
+    * \retval bool - is a success
+   */
+  virtual bool Evaluate(SMESH_Mesh & aMesh, const TopoDS_Shape & aShape,
+                        MapShapeNbElems& aResMap) {return false;}/*= 0*/
+
   /*!
    * \brief Returns a list of compatible hypotheses used to mesh a shape
     * \param aMesh - the mesh 
index a68aac8c7d6515a1cdcc9f7f340b830db14fddc2..10ec57e1fa5556160a6fa1f08c0eacb5b1d66169 100644 (file)
@@ -23,7 +23,6 @@
 //  File   : SMESH_Gen.cxx
 //  Author : Paul RASCLE, EDF
 //  Module : SMESH
-//  $Header$
 
 #include "SMESH_Gen.hxx"
 #include "SMESH_subMesh.hxx"
@@ -54,6 +53,7 @@ SMESH_Gen::SMESH_Gen()
         MESSAGE("SMESH_Gen::SMESH_Gen");
         _localId = 0;
         _hypId = 0;
+        _segmentation = 10;
 }
 
 //=============================================================================
@@ -128,9 +128,11 @@ SMESH_Mesh* SMESH_Gen::CreateMesh(int theStudyId, bool theIsEmbeddedMode)
  */
 //=============================================================================
 
-bool SMESH_Gen::Compute(SMESH_Mesh &         aMesh,
-                        const TopoDS_Shape & aShape,
-                        const bool           anUpward)
+bool SMESH_Gen::Compute(SMESH_Mesh &          aMesh,
+                        const TopoDS_Shape &  aShape,
+                        const bool            anUpward,
+                        const ::MeshDimension aDim,
+                        TSetOfInt*            aShapesId)
 {
   MESSAGE("SMESH_Gen::Compute");
 
@@ -154,16 +156,27 @@ bool SMESH_Gen::Compute(SMESH_Mesh &         aMesh,
       SMESH_subMesh* smToCompute = smIt->next();
 
       // do not mesh vertices of a pseudo shape
-      if ( !aMesh.HasShapeToMesh() &&
-           smToCompute->GetSubShape().ShapeType() == TopAbs_VERTEX )
+      const TopAbs_ShapeEnum aShType = smToCompute->GetSubShape().ShapeType();
+      if ( !aMesh.HasShapeToMesh() && aShType == TopAbs_VERTEX )
         continue;
 
+      // check for preview dimension limitations
+      if ( aShapesId && GetShapeDim( aShType ) > (int)aDim )
+      {
+        // clear compute state to not show previous compute errors
+        //  if preview invoked less dimension less than previous
+        smToCompute->ComputeStateEngine( SMESH_subMesh::CHECK_COMPUTE_STATE );
+        continue;
+      }
+
       if (smToCompute->GetComputeState() == SMESH_subMesh::READY_TO_COMPUTE)
         smToCompute->ComputeStateEngine( SMESH_subMesh::COMPUTE );
 
       // we check all the submeshes here and detect if any of them failed to compute
       if (smToCompute->GetComputeState() == SMESH_subMesh::FAILED_TO_COMPUTE)
         ret = false;
+      else if ( aShapesId )
+        aShapesId->insert( smToCompute->GetId() );
     }
     return ret;
   }
@@ -183,7 +196,12 @@ bool SMESH_Gen::Compute(SMESH_Mesh &         aMesh,
         continue;
 
       const TopoDS_Shape& aSubShape = smToCompute->GetSubShape();
-      if ( GetShapeDim( aSubShape ) < 1 ) break;
+      const int aShapeDim = GetShapeDim( aSubShape );
+      if ( aShapeDim < 1 ) break;
+      
+      // check for preview dimension limitations
+      if ( aShapesId && aShapeDim > (int)aDim )
+        continue;
 
       SMESH_Algo* algo = GetAlgo( aMesh, aSubShape );
       if ( algo && !algo->NeedDescretBoundary() )
@@ -191,7 +209,11 @@ bool SMESH_Gen::Compute(SMESH_Mesh &         aMesh,
         if ( algo->SupportSubmeshes() )
           smWithAlgoSupportingSubmeshes.push_back( smToCompute );
         else
+        {
           smToCompute->ComputeStateEngine( SMESH_subMesh::COMPUTE );
+          if ( aShapesId )
+            aShapesId->insert( smToCompute->GetId() );
+        }
       }
     }
     // ------------------------------------------------------------
@@ -218,8 +240,14 @@ bool SMESH_Gen::Compute(SMESH_Mesh &         aMesh,
         SMESH_subMesh* smToCompute = smIt->next();
 
         const TopoDS_Shape& aSubShape = smToCompute->GetSubShape();
-        if ( aSubShape.ShapeType() == TopAbs_VERTEX ) continue;
-
+        const int aShapeDim = GetShapeDim( aSubShape );
+        //if ( aSubShape.ShapeType() == TopAbs_VERTEX ) continue;
+        if ( aShapeDim < 1 ) continue;
+
+        // check for preview dimension limitations
+        if ( aShapesId && GetShapeDim( aSubShape.ShapeType() ) > (int)aDim )
+          continue;
+        
         SMESH_HypoFilter filter( SMESH_HypoFilter::IsAlgo() );
         filter
           .And( SMESH_HypoFilter::IsApplicableTo( aSubShape ))
@@ -228,8 +256,8 @@ bool SMESH_Gen::Compute(SMESH_Mesh &         aMesh,
         if ( SMESH_Algo* subAlgo = (SMESH_Algo*) aMesh.GetHypothesis( aSubShape, filter, true )) {
           SMESH_Hypothesis::Hypothesis_Status status;
           if ( subAlgo->CheckHypothesis( aMesh, aSubShape, status ))
-            // mesh a lower smToCompute
-            Compute( aMesh, aSubShape );
+            // mesh a lower smToCompute starting from vertices
+            Compute( aMesh, aSubShape, /*anUpward=*/true, aDim, aShapesId );
         }
       }
     }
@@ -240,18 +268,162 @@ bool SMESH_Gen::Compute(SMESH_Mesh &         aMesh,
     {
       sm = *subIt;
       if ( sm->GetComputeState() == SMESH_subMesh::READY_TO_COMPUTE)
+      {
+        const TopAbs_ShapeEnum aShType = sm->GetSubShape().ShapeType();
+        // check for preview dimension limitations
+        if ( aShapesId && GetShapeDim( aShType ) > (int)aDim )
+          continue;
+
         sm->ComputeStateEngine( SMESH_subMesh::COMPUTE );
+        if ( aShapesId )
+          aShapesId->insert( sm->GetId() );
+      }
     }
     // -----------------------------------------------
     // mesh the rest subshapes starting from vertices
     // -----------------------------------------------
-    ret = Compute( aMesh, aShape, /*anUpward=*/true );
+    ret = Compute( aMesh, aShape, /*anUpward=*/true, aDim, aShapesId );
   }
 
   MESSAGE( "VSR - SMESH_Gen::Compute() finished, OK = " << ret);
   return ret;
 }
 
+
+//=============================================================================
+/*!
+ * Evaluate a mesh
+ */
+//=============================================================================
+
+bool SMESH_Gen::Evaluate(SMESH_Mesh &          aMesh,
+                         const TopoDS_Shape &  aShape,
+                         MapShapeNbElems&      aResMap,
+                         const bool            anUpward,
+                         TSetOfInt*            aShapesId)
+{
+  MESSAGE("SMESH_Gen::Evaluate");
+
+  bool ret = true;
+
+  SMESH_subMesh *sm = aMesh.GetSubMesh(aShape);
+
+  const bool includeSelf = true;
+  const bool complexShapeFirst = true;
+  SMESH_subMeshIteratorPtr smIt;
+
+  if ( anUpward ) { // is called from below code here
+    // -----------------------------------------------
+    // mesh all the subshapes starting from vertices
+    // -----------------------------------------------
+    smIt = sm->getDependsOnIterator(includeSelf, !complexShapeFirst);
+    while ( smIt->more() ) {
+      SMESH_subMesh* smToCompute = smIt->next();
+
+      // do not mesh vertices of a pseudo shape
+      const TopAbs_ShapeEnum aShType = smToCompute->GetSubShape().ShapeType();
+      //if ( !aMesh.HasShapeToMesh() && aShType == TopAbs_VERTEX )
+      //  continue;
+      if ( !aMesh.HasShapeToMesh() ) {
+        if( aShType == TopAbs_VERTEX || aShType == TopAbs_WIRE ||
+            aShType == TopAbs_SHELL )
+          continue;
+      }
+
+      smToCompute->Evaluate(aResMap);
+      if( aShapesId )
+        aShapesId->insert( smToCompute->GetId() );
+    }
+    return ret;
+  }
+  else {
+    // -----------------------------------------------------------------
+    // apply algos that DO NOT require descretized boundaries and DO NOT
+    // support submeshes, starting from the most complex shapes
+    // and collect submeshes with algos that DO support submeshes
+    // -----------------------------------------------------------------
+    list< SMESH_subMesh* > smWithAlgoSupportingSubmeshes;
+    smIt = sm->getDependsOnIterator(includeSelf, complexShapeFirst);
+    while ( smIt->more() ) {
+      SMESH_subMesh* smToCompute = smIt->next();
+      const TopoDS_Shape& aSubShape = smToCompute->GetSubShape();
+      const int aShapeDim = GetShapeDim( aSubShape );
+      if ( aShapeDim < 1 ) break;
+      
+      SMESH_Algo* algo = GetAlgo( aMesh, aSubShape );
+      if ( algo && !algo->NeedDescretBoundary() ) {
+        if ( algo->SupportSubmeshes() ) {
+          smWithAlgoSupportingSubmeshes.push_back( smToCompute );
+        }
+        else {
+          smToCompute->Evaluate(aResMap);
+          if ( aShapesId )
+            aShapesId->insert( smToCompute->GetId() );
+        }
+      }
+    }
+    // ------------------------------------------------------------
+    // compute submeshes under shapes with algos that DO NOT require
+    // descretized boundaries and DO support submeshes
+    // ------------------------------------------------------------
+    list< SMESH_subMesh* >::reverse_iterator subIt, subEnd;
+    subIt  = smWithAlgoSupportingSubmeshes.rbegin();
+    subEnd = smWithAlgoSupportingSubmeshes.rend();
+    // start from lower shapes
+    for ( ; subIt != subEnd; ++subIt ) {
+      sm = *subIt;
+
+      // get a shape the algo is assigned to
+      TopoDS_Shape algoShape;
+      if ( !GetAlgo( aMesh, sm->GetSubShape(), & algoShape ))
+        continue; // strange...
+
+      // look for more local algos
+      smIt = sm->getDependsOnIterator(!includeSelf, !complexShapeFirst);
+      while ( smIt->more() ) {
+        SMESH_subMesh* smToCompute = smIt->next();
+
+        const TopoDS_Shape& aSubShape = smToCompute->GetSubShape();
+        const int aShapeDim = GetShapeDim( aSubShape );
+        if ( aShapeDim < 1 ) continue;
+
+        //const TopAbs_ShapeEnum aShType = smToCompute->GetSubShape().ShapeType();
+
+        SMESH_HypoFilter filter( SMESH_HypoFilter::IsAlgo() );
+        filter
+          .And( SMESH_HypoFilter::IsApplicableTo( aSubShape ))
+          .And( SMESH_HypoFilter::IsMoreLocalThan( algoShape ));
+
+        if ( SMESH_Algo* subAlgo = (SMESH_Algo*) aMesh.GetHypothesis( aSubShape, filter, true )) {
+          SMESH_Hypothesis::Hypothesis_Status status;
+          if ( subAlgo->CheckHypothesis( aMesh, aSubShape, status ))
+            // mesh a lower smToCompute starting from vertices
+            Evaluate( aMesh, aSubShape, aResMap, /*anUpward=*/true, aShapesId );
+        }
+      }
+    }
+    // ----------------------------------------------------------
+    // apply the algos that do not require descretized boundaries
+    // ----------------------------------------------------------
+    for ( subIt = smWithAlgoSupportingSubmeshes.rbegin(); subIt != subEnd; ++subIt )
+    {
+      sm = *subIt;
+      sm->Evaluate(aResMap);
+      if ( aShapesId )
+        aShapesId->insert( sm->GetId() );
+    }
+
+    // -----------------------------------------------
+    // mesh the rest subshapes starting from vertices
+    // -----------------------------------------------
+    ret = Evaluate( aMesh, aShape, aResMap, /*anUpward=*/true, aShapesId );
+  }
+
+  MESSAGE( "VSR - SMESH_Gen::Evaluate() finished, OK = " << ret);
+  return ret;
+}
+
+
 //=======================================================================
 //function : checkConformIgnoredAlgos
 //purpose  :
@@ -262,7 +434,7 @@ static bool checkConformIgnoredAlgos(SMESH_Mesh&               aMesh,
                                      const SMESH_Algo*         aGlobIgnoAlgo,
                                      const SMESH_Algo*         aLocIgnoAlgo,
                                      bool &                    checkConform,
-                                     map<int, SMESH_subMesh*>& aCheckedMap,
+                                     set<SMESH_subMesh*>&      aCheckedMap,
                                      list< SMESH_Gen::TAlgoStateError > & theErrors)
 {
   ASSERT( aSubMesh );
@@ -317,19 +489,15 @@ static bool checkConformIgnoredAlgos(SMESH_Mesh&               aMesh,
         }
 
         // sub-algos will be hidden by a local <algo>
-        const map<int, SMESH_subMesh*>& smMap = aSubMesh->DependsOn();
-        map<int, SMESH_subMesh*>::const_reverse_iterator revItSub;
+        SMESH_subMeshIteratorPtr revItSub =
+          aSubMesh->getDependsOnIterator( /*includeSelf=*/false, /*complexShapeFirst=*/true);
         bool checkConform2 = false;
-        for ( revItSub = smMap.rbegin(); revItSub != smMap.rend(); revItSub++)
+        while ( revItSub->more() )
         {
-          checkConformIgnoredAlgos (aMesh, (*revItSub).second, aGlobIgnoAlgo,
+          SMESH_subMesh* sm = revItSub->next();
+          checkConformIgnoredAlgos (aMesh, sm, aGlobIgnoAlgo,
                                     algo, checkConform2, aCheckedMap, theErrors);
-          int key = (*revItSub).first;
-          SMESH_subMesh* sm = (*revItSub).second;
-          if ( aCheckedMap.find( key ) == aCheckedMap.end() )
-          {
-            aCheckedMap[ key ] = sm;
-          }
+          aCheckedMap.insert( sm );
         }
       }
     }
@@ -350,7 +518,7 @@ static bool checkMissing(SMESH_Gen*                aGen,
                          const int                 aTopAlgoDim,
                          bool*                     globalChecked,
                          const bool                checkNoAlgo,
-                         map<int, SMESH_subMesh*>& aCheckedMap,
+                         set<SMESH_subMesh*>&      aCheckedMap,
                          list< SMESH_Gen::TAlgoStateError > & theErrors)
 {
   if ( aSubMesh->GetSubShape().ShapeType() == TopAbs_VERTEX)
@@ -423,15 +591,13 @@ static bool checkMissing(SMESH_Gen*                aGen,
   if (!algo->NeedDescretBoundary() || isTopLocalAlgo)
   {
     bool checkNoAlgo2 = ( algo->NeedDescretBoundary() );
-    const map<int, SMESH_subMesh*>& subMeshes = aSubMesh->DependsOn();
-    map<int, SMESH_subMesh*>::const_iterator itsub;
-    for (itsub = subMeshes.begin(); itsub != subMeshes.end(); itsub++)
+    SMESH_subMeshIteratorPtr itsub = aSubMesh->getDependsOnIterator( /*includeSelf=*/false,
+                                                                     /*complexShapeFirst=*/false);
+    while ( itsub->more() )
     {
       // sub-meshes should not be checked further more
-      int key = (*itsub).first;
-      SMESH_subMesh* sm = (*itsub).second;
-      if ( aCheckedMap.find( key ) == aCheckedMap.end() )
-        aCheckedMap[ key ] = sm;
+      SMESH_subMesh* sm = itsub->next();
+      aCheckedMap.insert( sm );
 
       if (isTopLocalAlgo)
       {
@@ -525,39 +691,25 @@ bool SMESH_Gen::GetAlgoState(SMESH_Mesh&               theMesh,
     }
   }
 
-  const map<int, SMESH_subMesh*>& smMap = sm->DependsOn();
-  map<int, SMESH_subMesh*>::const_reverse_iterator revItSub = smMap.rbegin();
-  map<int, SMESH_subMesh*> aCheckedMap;
+  set<SMESH_subMesh*> aCheckedSubs;
   bool checkConform = ( !theMesh.IsNotConformAllowed() );
-  int aKey = 1;
-  SMESH_subMesh* smToCheck = sm;
 
   // loop on theShape and its sub-shapes
-  while ( smToCheck )
+  SMESH_subMeshIteratorPtr revItSub = sm->getDependsOnIterator( /*includeSelf=*/true,
+                                                                /*complexShapeFirst=*/true);
+  while ( revItSub->more() )
   {
+    SMESH_subMesh* smToCheck = revItSub->next();
     if ( smToCheck->GetSubShape().ShapeType() == TopAbs_VERTEX)
       break;
 
-    if ( aCheckedMap.find( aKey ) == aCheckedMap.end() )
+    if ( aCheckedSubs.insert( smToCheck ).second ) // not yet checked
       if (!checkConformIgnoredAlgos (theMesh, smToCheck, aGlobIgnoAlgo,
-                                     0, checkConform, aCheckedMap, theErrors))
+                                     0, checkConform, aCheckedSubs, theErrors))
         ret = false;
 
     if ( smToCheck->GetAlgoState() != SMESH_subMesh::NO_ALGO )
       hasAlgo = true;
-
-    // next subMesh
-    if (revItSub != smMap.rend())
-    {
-      aKey = (*revItSub).first;
-      smToCheck = (*revItSub).second;
-      revItSub++;
-    }
-    else
-    {
-      smToCheck = 0;
-    }
-
   }
 
   // ----------------------------------------------------------------
@@ -577,36 +729,26 @@ bool SMESH_Gen::GetAlgoState(SMESH_Mesh&               theMesh,
       break;
     }
   }
-  aCheckedMap.clear();
-  smToCheck = sm;
-  revItSub = smMap.rbegin();
   bool checkNoAlgo = theMesh.HasShapeToMesh() ? bool( aTopAlgoDim ) : false;
   bool globalChecked[] = { false, false, false, false };
 
   // loop on theShape and its sub-shapes
-  while ( smToCheck )
+  aCheckedSubs.clear();
+  revItSub = sm->getDependsOnIterator( /*includeSelf=*/true, /*complexShapeFirst=*/true);
+  while ( revItSub->more() )
   {
+    SMESH_subMesh* smToCheck = revItSub->next();
     if ( smToCheck->GetSubShape().ShapeType() == TopAbs_VERTEX)
       break;
 
-    if ( aCheckedMap.find( aKey ) == aCheckedMap.end() )
+    if ( aCheckedSubs.insert( smToCheck ).second ) // not yet checked
       if (!checkMissing (this, theMesh, smToCheck, aTopAlgoDim,
-                         globalChecked, checkNoAlgo, aCheckedMap, theErrors))
+                         globalChecked, checkNoAlgo, aCheckedSubs, theErrors))
       {
         ret = false;
         if (smToCheck->GetAlgoState() == SMESH_subMesh::NO_ALGO )
           checkNoAlgo = false;
       }
-
-    // next subMesh
-    if (revItSub != smMap.rend())
-    {
-      aKey = (*revItSub).first;
-      smToCheck = (*revItSub).second;
-      revItSub++;
-    }
-    else
-      smToCheck = 0;
   }
 
   if ( !hasAlgo ) {
@@ -667,35 +809,35 @@ StudyContextStruct *SMESH_Gen::GetStudyContext(int studyId)
         return myStudyContext;
 }
 
-//=============================================================================
-/*!
- *
- */
-//=============================================================================
+// //=============================================================================
+// /*!
+//  *
+//  */
+// //=============================================================================
 
-void SMESH_Gen::Save(int studyId, const char *aUrlOfFile)
-{
-}
+// void SMESH_Gen::Save(int studyId, const char *aUrlOfFile)
+// {
+// }
 
-//=============================================================================
-/*!
- *
- */
-//=============================================================================
+// //=============================================================================
+// /*!
+//  *
+//  */
+// //=============================================================================
 
-void SMESH_Gen::Load(int studyId, const char *aUrlOfFile)
-{
-}
+// void SMESH_Gen::Load(int studyId, const char *aUrlOfFile)
+// {
+// }
 
-//=============================================================================
-/*!
- *
- */
-//=============================================================================
+// //=============================================================================
+// /*!
+//  *
+//  */
+// //=============================================================================
 
-void SMESH_Gen::Close(int studyId)
-{
-}
+// void SMESH_Gen::Close(int studyId)
+// {
+// }
 
 //=============================================================================
 /*!
@@ -709,14 +851,14 @@ int SMESH_Gen::GetShapeDim(const TopAbs_ShapeEnum & aShapeType)
   if ( dim.empty() )
   {
     dim.resize( TopAbs_SHAPE, -1 );
-    dim[ TopAbs_COMPOUND ]  = 3;
-    dim[ TopAbs_COMPSOLID ] = 3;
-    dim[ TopAbs_SOLID ]     = 3;
-    dim[ TopAbs_SHELL ]     = 3;
-    dim[ TopAbs_FACE  ]     = 2;
-    dim[ TopAbs_WIRE ]      = 1;
-    dim[ TopAbs_EDGE ]      = 1;
-    dim[ TopAbs_VERTEX ]    = 0;
+    dim[ TopAbs_COMPOUND ]  = MeshDim_3D;
+    dim[ TopAbs_COMPSOLID ] = MeshDim_3D;
+    dim[ TopAbs_SOLID ]     = MeshDim_3D;
+    dim[ TopAbs_SHELL ]     = MeshDim_3D;
+    dim[ TopAbs_FACE  ]     = MeshDim_2D;
+    dim[ TopAbs_WIRE ]      = MeshDim_1D;
+    dim[ TopAbs_EDGE ]      = MeshDim_1D;
+    dim[ TopAbs_VERTEX ]    = MeshDim_0D;
   }
   return dim[ aShapeType ];
 }
index 9d1b40561d669d10dd0d60b47f69f929b39afe61..ab610a00a7b8e7f3c4305cc5055011d8bcd3b63d 100644 (file)
@@ -23,8 +23,8 @@
 //  File   : SMESH_Gen.hxx
 //  Author : Paul RASCLE, EDF
 //  Module : SMESH
-//  $Header$
 //
+
 #ifndef _SMESH_GEN_HXX_
 #define _SMESH_GEN_HXX_
 
@@ -44,6 +44,7 @@
 #include <TopoDS_Shape.hxx>
 
 #include <map>
+#include <list>
 
 class SMESHDS_Document;
 
@@ -56,9 +57,11 @@ typedef struct studyContextStruct
   SMESHDS_Document * myDocument;
 } StudyContextStruct;
 
+typedef std::set<int> TSetOfInt;
+
 class SMESH_EXPORT  SMESH_Gen
 {
- public:
+public:
   SMESH_Gen();
   ~SMESH_Gen();
 
@@ -68,17 +71,45 @@ class SMESH_EXPORT  SMESH_Gen
   /*!
    * \brief Computes aMesh on aShape 
    *  \param anUpward - compute from vertices up to more complex shape (internal usage)
+   *  \param aDim - upper level dimension of the mesh computation
+   *  \param aShapesId - list of shapes with computed mesh entities (elements or nodes)
    *  \retval bool - true if none submesh failed to compute
    */
-  bool Compute(::SMESH_Mesh &       aMesh,
-               const TopoDS_Shape & aShape,
-               const bool           anUpward=false);
+  bool Compute(::SMESH_Mesh &        aMesh,
+               const TopoDS_Shape &  aShape,
+               const bool            anUpward=false,
+               const ::MeshDimension aDim=::MeshDim_3D,
+               TSetOfInt*            aShapesId=0);
+
+  /*!
+   * \brief evaluates size of prospective mesh on a shape 
+   * \param aMesh - the mesh
+   * \param aShape - the shape
+   * \param aResMap - map for prospective numbers of elements
+   * \retval bool - is a success
+   */
+  bool Evaluate(::SMESH_Mesh &        aMesh,
+                const TopoDS_Shape &  aShape,
+                MapShapeNbElems&      aResMap,
+                const bool            anUpward=false,
+                TSetOfInt*            aShapesId=0);
 
   bool CheckAlgoState(SMESH_Mesh& aMesh, const TopoDS_Shape& aShape);
   // notify on bad state of attached algos, return false
   // if Compute() would fail because of some algo bad state
 
-  
+  /*!
+   * \brief Sets number of segments per diagonal of boundary box of geometry by which
+   *        default segment length of appropriate 1D hypotheses is defined
+   */
+  void SetBoundaryBoxSegmentation( int theNbSegments ) { _segmentation = theNbSegments; }
+  int  GetBoundaryBoxSegmentation() const { return _segmentation; }
+  /*!
+   * \brief Sets default number of segments per edge
+   */
+  void SetDefaultNbSegments(int nb) { _nbSegments = nb; }
+  int GetDefaultNbSegments() const { return _nbSegments; }
+
   struct TAlgoStateError
   {
     TAlgoStateErrorName _name;
@@ -107,16 +138,6 @@ class SMESH_EXPORT  SMESH_Gen
   SMESH_Algo* GetAlgo(SMESH_Mesh & aMesh, const TopoDS_Shape & aShape, TopoDS_Shape* assignedTo=0);
   static bool IsGlobalHypothesis(const SMESH_Hypothesis* theHyp, SMESH_Mesh& aMesh);
 
-  // inherited methods from SALOMEDS::Driver
-
-  void Save(int studyId, const char *aUrlOfFile);
-  void Load(int studyId, const char *aUrlOfFile);
-  void Close(int studyId);
-  const char *ComponentDataType();
-
-  const char *IORToLocalPersistentID(const char *IORString, bool & IsAFile);
-  const char *LocalPersistentIDToIOR(const char *aLocalPersistentID);
-
   int GetANewId();
 
   std::map < int, SMESH_Algo * >_mapAlgo;
@@ -125,13 +146,19 @@ class SMESH_EXPORT  SMESH_Gen
   std::map < int, SMESH_2D_Algo * >_map2D_Algo;
   std::map < int, SMESH_3D_Algo * >_map3D_Algo;
 
- private:
+private:
 
-  int _localId;                                // unique Id of created objects, within SMESH_Gen entity
+  int _localId;                     // unique Id of created objects, within SMESH_Gen entity
   std::map < int, StudyContextStruct * >_mapStudyContext;
 
   // hypotheses managing
   int _hypId;
+
+  // number of segments per diagonal of boundary box of geometry by which
+  // default segment length of appropriate 1D hypotheses is defined
+  int _segmentation;
+  // default of segments
+  int _nbSegments;
 };
 
 #endif
index 355f166a457d8724fbbe8ae6c72ff3a0a1c32195..9494f0b7f15113c749e5ab8b6a04913abff6c929 100644 (file)
@@ -23,8 +23,8 @@
 //  File   : SMESH_Hypothesis.hxx
 //  Author : Paul RASCLE, EDF
 //  Module : SMESH
-//  $Header$
 //
+
 #ifndef _SMESH_HYPOTHESIS_HXX_
 #define _SMESH_HYPOTHESIS_HXX_
 
@@ -36,6 +36,14 @@ class SMESH_Gen;
 class TopoDS_Shape;
 class SMESH_Mesh;
 
+enum MeshDimension // dimension of mesh
+{
+  MeshDim_0D = 0,
+  MeshDim_1D,
+  MeshDim_2D,
+  MeshDim_3D
+};
+
 class SMESH_EXPORT SMESH_Hypothesis: public SMESHDS_Hypothesis
 {
 public:
@@ -71,9 +79,9 @@ public:
 
   /*!
    * \brief Initialize my parameter values by the mesh built on the geometry
-    * \param theMesh - the built mesh
-    * \param theShape - the geometry of interest
-    * \retval bool - true if parameter values have been successfully defined
+    \param theMesh - the built mesh
+    \param theShape - the geometry of interest
+    \retval bool - true if parameter values have been successfully defined
    */
   virtual bool SetParametersByMesh(const SMESH_Mesh* theMesh, const TopoDS_Shape& theShape)=0;
 
index d92c7ee4bebd840404f89488869ee01dce4d0fdb..21d1675184e5ce3f911484c3b2308fab9430fe54 100644 (file)
@@ -35,6 +35,7 @@
 #include "SMESH_subMeshEventListener.hxx"
 #include "SMESH_Comment.hxx"
 #include "SMDS_SetIterator.hxx"
+#include "SMDSAbs_ElementType.hxx"
 
 #include "utilities.h"
 #include "OpUtil.hxx"
@@ -1583,6 +1584,48 @@ bool SMESH_subMesh::ComputeStateEngine(int event)
   return ret;
 }
 
+
+//=============================================================================
+/*!
+ *
+ */
+//=============================================================================
+
+bool SMESH_subMesh::Evaluate(MapShapeNbElems& aResMap)
+{
+  _computeError.reset();
+
+  bool ret = true;
+
+  if (_subShape.ShapeType() == TopAbs_VERTEX) {
+    std::vector<int> aVec(SMDSEntity_Last);
+    for(int i= SMDSEntity_Node; i < SMDSEntity_Last; i++)
+      aVec[i] = 0;
+    aVec[SMDSEntity_Node] = 1;
+    aResMap.insert(std::make_pair(this,aVec));
+    return ret;
+  }
+
+  SMESH_Gen *gen = _father->GetGen();
+  SMESH_Algo *algo = 0;
+  SMESH_Hypothesis::Hypothesis_Status hyp_status;
+
+  algo = gen->GetAlgo((*_father), _subShape);
+  if(algo) {
+    ret = algo->CheckHypothesis((*_father), _subShape, hyp_status);
+    if (!ret) return false;
+
+    TopoDS_Shape shape = _subShape;
+
+    _computeError = SMESH_ComputeError::New(COMPERR_OK,"",algo);
+
+    ret = algo->Evaluate((*_father), shape, aResMap);
+  }
+
+  return ret;
+}
+
+
 //=======================================================================
 /*!
  * \brief Update compute_state by _computeError and send proper events to
index 83de353db90568255afab26cbc2d3ca21f55c265..b086771ab99405a271d492ec25953dd681a2b50e 100644 (file)
@@ -23,7 +23,6 @@
 //  File   : SMESH_subMesh.hxx
 //  Author : Paul RASCLE, EDF
 //  Module : SMESH
-//  $Header$
 //
 #ifndef _SMESH_SUBMESH_HXX_
 #define _SMESH_SUBMESH_HXX_
@@ -34,6 +33,7 @@
 #include "SMESHDS_SubMesh.hxx"
 #include "SMESH_Hypothesis.hxx"
 #include "SMESH_ComputeError.hxx"
+#include "SMESH_Algo.hxx"
 
 #include "Utils_SALOME_Exception.hxx"
 
@@ -60,7 +60,7 @@ class SMESH_EXPORT SMESH_subMesh
 {
  public:
   SMESH_subMesh(int Id, SMESH_Mesh * father, SMESHDS_Mesh * meshDS,
-               const TopoDS_Shape & aSubShape);
+                const TopoDS_Shape & aSubShape);
   virtual ~ SMESH_subMesh();
 
   int GetId() const;
@@ -192,6 +192,8 @@ public:
 
   bool ComputeStateEngine(int event);
 
+  bool Evaluate(MapShapeNbElems& aResMap);
+
   bool IsConform(const SMESH_Algo* theAlgo);
   // check if a conform mesh will be produced by the Algo