From e05bacd4fa68519893f5589d386493b4d8c27d42 Mon Sep 17 00:00:00 2001 From: eap Date: Mon, 19 Feb 2007 15:51:21 +0000 Subject: [PATCH] PAL13639 (EDF PAL 317 : SMESH : Create "0D Hypothesis") add Compute(SMESH_subMesh) and a map of 0D algos --- src/SMESH/SMESH_Gen.cxx | 52 ++++++++++++++++++++++++----------------- src/SMESH/SMESH_Gen.hxx | 9 ++++--- 2 files changed, 37 insertions(+), 24 deletions(-) diff --git a/src/SMESH/SMESH_Gen.cxx b/src/SMESH/SMESH_Gen.cxx index 9fa10ca3e..9c8c864dc 100644 --- a/src/SMESH/SMESH_Gen.cxx +++ b/src/SMESH/SMESH_Gen.cxx @@ -122,6 +122,30 @@ SMESH_Mesh* SMESH_Gen::CreateMesh(int theStudyId, bool theIsEmbeddedMode) 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); - 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 @@ -211,27 +235,13 @@ bool SMESH_Gen::Compute(SMESH_Mesh & aMesh, const TopoDS_Shape & aShape) smToCompute = sm; else smToCompute = (itSub++)->second; + 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--) @@ -564,7 +574,7 @@ bool SMESH_Gen::GetAlgoState(SMESH_Mesh& theMesh, 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 diff --git a/src/SMESH/SMESH_Gen.hxx b/src/SMESH/SMESH_Gen.hxx index 58d03e6f5..e3a59ef7d 100644 --- a/src/SMESH/SMESH_Gen.hxx +++ b/src/SMESH/SMESH_Gen.hxx @@ -33,6 +33,7 @@ #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" @@ -47,9 +48,9 @@ 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 @@ -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); + bool Compute(::SMESH_subMesh& aSubMesh); 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; + 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; -- 2.39.2