Salome HOME
PAL13639 (EDF PAL 317 : SMESH : Create "0D Hypothesis")
authoreap <eap@opencascade.com>
Mon, 19 Feb 2007 15:51:21 +0000 (15:51 +0000)
committereap <eap@opencascade.com>
Mon, 19 Feb 2007 15:51:21 +0000 (15:51 +0000)
   add Compute(SMESH_subMesh) and a map of 0D algos

src/SMESH/SMESH_Gen.cxx
src/SMESH/SMESH_Gen.hxx

index 9fa10ca3e8e66722e78f319d4593beb0e3404d59..9c8c864dc648ef74202df58bd630ab0d9fd82716 100644 (file)
@@ -122,6 +122,30 @@ SMESH_Mesh* SMESH_Gen::CreateMesh(int theStudyId, bool theIsEmbeddedMode)
   return aMesh;
 }
 
   return aMesh;
 }
 
+//================================================================================
+/*!
+ * \brief Compute submesh
+  * \param sm - submesh
+  * \retval bool - is a success
+  */
+//================================================================================
+
+bool SMESH_Gen::Compute(::SMESH_subMesh& sm)
+{
+  if ( sm.GetSubShape().ShapeType() == TopAbs_VERTEX )
+  {
+    SMESHDS_SubMesh* smDS = sm.GetSubMeshDS();
+    if ( !smDS || !smDS->NbNodes() ) {
+      TopoDS_Vertex V = TopoDS::Vertex(sm.GetSubShape());
+      gp_Pnt P = BRep_Tool::Pnt(V);
+      SMESHDS_Mesh * meshDS = sm.GetFather()->GetMeshDS();
+      if ( SMDS_MeshNode * node = meshDS->AddNode(P.X(), P.Y(), P.Z()) )
+        meshDS->SetNodeOnVertex(node, V);
+    }
+  }
+  return sm.ComputeStateEngine(SMESH_subMesh::COMPUTE);
+}
+
 //=============================================================================
 /*!
  *
 //=============================================================================
 /*!
  *
@@ -158,8 +182,8 @@ bool SMESH_Gen::Compute(SMESH_Mesh & aMesh, const TopoDS_Shape & aShape)
 
   SMESH_subMesh *sm = aMesh.GetSubMesh(aShape);
 
 
   SMESH_subMesh *sm = aMesh.GetSubMesh(aShape);
 
-  if ( sm->GetComputeState() == SMESH_subMesh::COMPUTE_OK )
-    return true; // already computed
+//   if ( sm->GetComputeState() == SMESH_subMesh::COMPUTE_OK )
+//     return true; // already computed
 
   // -----------------------------------------------------------------
   // apply algos that do not require descretized boundaries, starting
 
   // -----------------------------------------------------------------
   // apply algos that do not require descretized boundaries, starting
@@ -211,27 +235,13 @@ bool SMESH_Gen::Compute(SMESH_Mesh & aMesh, const TopoDS_Shape & aShape)
       smToCompute = sm;
     else
       smToCompute = (itSub++)->second;
       smToCompute = sm;
     else
       smToCompute = (itSub++)->second;
+
     if (smToCompute->GetComputeState() != SMESH_subMesh::READY_TO_COMPUTE) {
       if (smToCompute->GetComputeState() == SMESH_subMesh::FAILED_TO_COMPUTE)
         ret = false;
     if (smToCompute->GetComputeState() != SMESH_subMesh::READY_TO_COMPUTE) {
       if (smToCompute->GetComputeState() == SMESH_subMesh::FAILED_TO_COMPUTE)
         ret = false;
-      continue;
-    }
-    TopoDS_Shape subShape = smToCompute->GetSubShape();
-    if ( subShape.ShapeType() != TopAbs_VERTEX )
-    {
-      if ( !smToCompute->ComputeStateEngine(SMESH_subMesh::COMPUTE) )
-        ret = false;
     }
     }
-    else
-    {
-      TopoDS_Vertex V1 = TopoDS::Vertex(subShape);
-      gp_Pnt P1 = BRep_Tool::Pnt(V1);
-      SMESHDS_Mesh * meshDS = aMesh.GetMeshDS();
-      SMDS_MeshNode * node = meshDS->AddNode(P1.X(), P1.Y(), P1.Z());
-      if ( node ) {  // san - increase robustness
-        meshDS->SetNodeOnVertex(node, V1);
-        smToCompute->ComputeStateEngine(SMESH_subMesh::COMPUTE);
-      }
+    else if ( !Compute( *smToCompute )) {
+      ret = false;
     }
   }
 
     }
   }
 
@@ -496,7 +506,7 @@ bool SMESH_Gen::GetAlgoState(SMESH_Mesh&               theMesh,
   // --------------------------------------------------------
 
 
   // --------------------------------------------------------
 
 
-  // find a global algo possibly hidding sub-algos
+  // find a global algo possibly hiding sub-algos
   int dim;
   const SMESH_Algo* aGlobIgnoAlgo = 0;
   for (dim = 3; dim > 0; dim--)
   int dim;
   const SMESH_Algo* aGlobIgnoAlgo = 0;
   for (dim = 3; dim > 0; dim--)
@@ -564,7 +574,7 @@ bool SMESH_Gen::GetAlgoState(SMESH_Mesh&               theMesh,
   aCheckedMap.clear();
   smToCheck = sm;
   revItSub = smMap.rbegin();
   aCheckedMap.clear();
   smToCheck = sm;
   revItSub = smMap.rbegin();
-  bool checkNoAlgo = (bool) aTopAlgoDim;
+  bool checkNoAlgo = theMesh.HasShapeToMesh() ? bool( aTopAlgoDim ) : false;
   bool globalChecked[] = { false, false, false, false };
 
   // loop on theShape and its sub-shapes
   bool globalChecked[] = { false, false, false, false };
 
   // loop on theShape and its sub-shapes
index 58d03e6f5d0a7d5f603a895fbddb3e2751ef7b8f..e3a59ef7dfa38253e9a7c168eff3500c87bb4afa 100644 (file)
@@ -33,6 +33,7 @@
 
 #include "SMESH_Hypothesis.hxx"
 #include "SMESH_Algo.hxx"
 
 #include "SMESH_Hypothesis.hxx"
 #include "SMESH_Algo.hxx"
+#include "SMESH_0D_Algo.hxx"
 #include "SMESH_1D_Algo.hxx"
 #include "SMESH_2D_Algo.hxx"
 #include "SMESH_3D_Algo.hxx"
 #include "SMESH_1D_Algo.hxx"
 #include "SMESH_2D_Algo.hxx"
 #include "SMESH_3D_Algo.hxx"
@@ -47,9 +48,9 @@
 
 typedef struct studyContextStruct
 {
 
 typedef struct studyContextStruct
 {
-       std::map < int, SMESH_Hypothesis * >mapHypothesis;
-         std::map < int, SMESH_Mesh * >mapMesh;
-         SMESHDS_Document * myDocument;
+  std::map < int, SMESH_Hypothesis * >mapHypothesis;
+  std::map < int, SMESH_Mesh * >mapMesh;
+  SMESHDS_Document * myDocument;
 } StudyContextStruct;
 
 class SMESH_Gen
 } StudyContextStruct;
 
 class SMESH_Gen
@@ -63,6 +64,7 @@ class SMESH_Gen
   SMESH_Mesh* CreateMesh(int theStudyId, bool theIsEmbeddedMode)
     throw(SALOME_Exception);
   bool Compute(::SMESH_Mesh & aMesh, const TopoDS_Shape & aShape);
   SMESH_Mesh* CreateMesh(int theStudyId, bool theIsEmbeddedMode)
     throw(SALOME_Exception);
   bool Compute(::SMESH_Mesh & aMesh, const TopoDS_Shape & aShape);
+  bool Compute(::SMESH_subMesh& aSubMesh);
 
   bool CheckAlgoState(SMESH_Mesh& aMesh, const TopoDS_Shape& aShape);
   // notify on bad state of attached algos, return false
 
   bool CheckAlgoState(SMESH_Mesh& aMesh, const TopoDS_Shape& aShape);
   // notify on bad state of attached algos, return false
@@ -116,6 +118,7 @@ class SMESH_Gen
   int GetANewId();
 
   std::map < int, SMESH_Algo * >_mapAlgo;
   int GetANewId();
 
   std::map < int, SMESH_Algo * >_mapAlgo;
+  std::map < int, SMESH_0D_Algo * >_map0D_Algo;
   std::map < int, SMESH_1D_Algo * >_map1D_Algo;
   std::map < int, SMESH_2D_Algo * >_map2D_Algo;
   std::map < int, SMESH_3D_Algo * >_map3D_Algo;
   std::map < int, SMESH_1D_Algo * >_map1D_Algo;
   std::map < int, SMESH_2D_Algo * >_map2D_Algo;
   std::map < int, SMESH_3D_Algo * >_map3D_Algo;