From b4888f2b960f28696a1dad84f46222f9f6083e31 Mon Sep 17 00:00:00 2001 From: eap Date: Mon, 19 Feb 2007 15:55:57 +0000 Subject: [PATCH] PAL13504 (Mesh from an imported mesh) add PseudoShape(), HasShapeToMesh() --- src/SMESH/SMESH_Mesh.cxx | 112 ++++++++++++++++++++------------------- src/SMESH/SMESH_Mesh.hxx | 26 +++++++-- 2 files changed, 79 insertions(+), 59 deletions(-) diff --git a/src/SMESH/SMESH_Mesh.cxx b/src/SMESH/SMESH_Mesh.cxx index 4cc5f79f3..3f3177694 100644 --- a/src/SMESH/SMESH_Mesh.cxx +++ b/src/SMESH/SMESH_Mesh.cxx @@ -49,6 +49,7 @@ #include "DriverSTL_R_SMDS_Mesh.h" #include +#include #include #include @@ -94,6 +95,7 @@ SMESH_Mesh::SMESH_Mesh(int theLocalId, _myDocument = theDocument; _idDoc = theDocument->NewMesh(theIsEmbeddedMode); _myMeshDS = theDocument->GetMesh(_idDoc); + _myMeshDS->ShapeToMesh( PseudoShape() ); _isShapeToMesh = false; } @@ -117,7 +119,7 @@ SMESH_Mesh::~SMESH_Mesh() //============================================================================= /*! - * + * \brief Set geometry to be meshed */ //============================================================================= @@ -125,7 +127,11 @@ void SMESH_Mesh::ShapeToMesh(const TopoDS_Shape & aShape) { if(MYDEBUG) MESSAGE("SMESH_Mesh::ShapeToMesh"); - if ( !_myMeshDS->ShapeToMesh().IsNull() && aShape.IsNull() ) + if ( !aShape.IsNull() && _isShapeToMesh ) + throw SALOME_Exception(LOCALIZED ("a shape to mesh has already been defined")); + + // clear current data + if ( !_myMeshDS->ShapeToMesh().IsNull() ) { // removal of a shape to mesh, delete objects referring to sub-shapes: // - sub-meshes @@ -144,28 +150,57 @@ void SMESH_Mesh::ShapeToMesh(const TopoDS_Shape & aShape) else i_gr++; } + _mapAncestors.Clear(); _mapPropagationChains.Clear(); + + // clear SMESHDS + TopoDS_Shape aNullShape; + _myMeshDS->ShapeToMesh( aNullShape ); } - else + + // set a new geometry + if ( !aShape.IsNull() ) { - if (_isShapeToMesh) - throw SALOME_Exception(LOCALIZED ("a shape to mesh has already been defined")); + _myMeshDS->ShapeToMesh(aShape); + _isShapeToMesh = true; + + // fill _mapAncestors + int desType, ancType; + for ( desType = TopAbs_VERTEX; desType > TopAbs_COMPOUND; desType-- ) + for ( ancType = desType - 1; ancType >= TopAbs_COMPOUND; ancType-- ) + TopExp::MapShapesAndAncestors ( aShape, + (TopAbs_ShapeEnum) desType, + (TopAbs_ShapeEnum) ancType, + _mapAncestors ); } - _isShapeToMesh = true; - _myMeshDS->ShapeToMesh(aShape); - - // fill _mapAncestors - _mapAncestors.Clear(); - int desType, ancType; - for ( desType = TopAbs_VERTEX; desType > TopAbs_COMPOUND; desType-- ) - for ( ancType = desType - 1; ancType >= TopAbs_COMPOUND; ancType-- ) - TopExp::MapShapesAndAncestors ( aShape, - (TopAbs_ShapeEnum) desType, - (TopAbs_ShapeEnum) ancType, - _mapAncestors ); - - // NRI : 24/02/03 - //EAP: 1/9/04 TopExp::MapShapes(aShape, _subShapes); USE the same map of _myMeshDS +} + +//======================================================================= +/*! + * \brief Return geometry to be meshed. (It may be a PseudoShape()!) + */ +//======================================================================= + +TopoDS_Shape SMESH_Mesh::GetShapeToMesh() const +{ + return _myMeshDS->ShapeToMesh(); +} + +//======================================================================= +/*! + * \brief Return a solid which is returned by GetShapeToMesh() if + * a real geometry to be meshed was not set + */ +//======================================================================= + +const TopoDS_Solid& SMESH_Mesh::PseudoShape() +{ + static TopoDS_Solid aSolid; + if ( aSolid.IsNull() ) + { + aSolid = BRepPrimAPI_MakeBox(1,1,1); + } + return aSolid; } //======================================================================= @@ -494,17 +529,6 @@ SMESH_Hypothesis::Hypothesis_Status */ //============================================================================= -SMESHDS_Mesh * SMESH_Mesh::GetMeshDS() -{ - return _myMeshDS; -} - -//============================================================================= -/*! - * - */ -//============================================================================= - const list& SMESH_Mesh::GetHypothesisList(const TopoDS_Shape & aSubShape) const throw(SALOME_Exception) @@ -649,29 +673,6 @@ void SMESH_Mesh::ClearLog() throw(SALOME_Exception) _myMeshDS->GetScript()->Clear(); } -//============================================================================= -/*! - * - */ -//============================================================================= - -int SMESH_Mesh::GetId() -{ - if(MYDEBUG) MESSAGE("SMESH_Mesh::GetId"); - return _id; -} - -//============================================================================= -/*! - * - */ -//============================================================================= - -SMESH_Gen *SMESH_Mesh::GetGen() -{ - return _gen; -} - //============================================================================= /*! * Get or Create the SMESH_subMesh object implementation @@ -857,7 +858,8 @@ void SMESH_Mesh::NotifySubMeshesHypothesisModification(const SMESH_Hypothesis* t if ( GetHypotheses( aSubShape, compatibleHypoKind, usedHyps, true ) && find( usedHyps.begin(), usedHyps.end(), hyp ) != usedHyps.end() ) { - aSubMesh->ComputeStateEngine(SMESH_subMesh::MODIF_HYP); + aSubMesh->AlgoStateEngine(SMESH_subMesh::MODIF_HYP, + const_cast< SMESH_Hypothesis*>( hyp )); if ( algo->GetDim() == 1 && IsPropagationHypothesis( aSubShape )) CleanMeshOnPropagationChain( aSubShape ); diff --git a/src/SMESH/SMESH_Mesh.hxx b/src/SMESH/SMESH_Mesh.hxx index 0e6e1aabe..3b4eef596 100644 --- a/src/SMESH/SMESH_Mesh.hxx +++ b/src/SMESH/SMESH_Mesh.hxx @@ -70,6 +70,7 @@ class SMESH_Group; class TopTools_ListOfShape; class SMESH_subMesh; class SMESH_HypoFilter; +class TopoDS_Solid; //typedef NMTTools_IndexedDataMapOfShapeIndexedMapOfShape IndexedMapOfChain; typedef SMESH_IndexedDataMapOfShapeIndexedMapOfShape IndexedMapOfChain; @@ -87,8 +88,25 @@ public: virtual ~SMESH_Mesh(); + /*! + * \brief Set geometry to be meshed + */ void ShapeToMesh(const TopoDS_Shape & aShape); - + /*! + * \brief Return geometry to be meshed. (It may be a PseudoShape()!) + */ + TopoDS_Shape GetShapeToMesh() const; + /*! + * \brief Return true if there is a geometry to be meshed, not PseudoShape() + */ + bool HasShapeToMesh() const { return _isShapeToMesh; } + /*! + * \brief Return a solid which is returned by GetShapeToMesh() if + * a real geometry to be meshed was not set + */ + static const TopoDS_Solid& PseudoShape(); + + int UNVToMesh(const char* theFileName); /*! * consult DriverMED_R_SMESHDS_Mesh::ReadStatus for returned value @@ -122,11 +140,11 @@ public: void ClearLog() throw(SALOME_Exception); - int GetId(); + int GetId() { return _id; } - SMESHDS_Mesh * GetMeshDS(); + SMESHDS_Mesh * GetMeshDS() { return _myMeshDS; } - SMESH_Gen *GetGen(); + SMESH_Gen *GetGen() { return _gen; } SMESH_subMesh *GetSubMesh(const TopoDS_Shape & aSubShape) throw(SALOME_Exception); -- 2.39.2