X-Git-Url: http://git.salome-platform.org/gitweb/?p=modules%2Fsmesh.git;a=blobdiff_plain;f=src%2FSMESH%2FSMESH_ProxyMesh.cxx;h=c8dcec11c7f3cd0bddb77175f8bf3b4fdc6fddd2;hp=a28033fda4fe6c43d0bf337a5b1ec1ea1f66f75c;hb=2f529dcd2629679dadcca3047583bfcf28ca7b1a;hpb=7a713be33b27d6a8c77f983460f0e97e52c6ff7c diff --git a/src/SMESH/SMESH_ProxyMesh.cxx b/src/SMESH/SMESH_ProxyMesh.cxx index a28033fda..c8dcec11c 100644 --- a/src/SMESH/SMESH_ProxyMesh.cxx +++ b/src/SMESH/SMESH_ProxyMesh.cxx @@ -38,9 +38,21 @@ */ //================================================================================ -SMESH_ProxyMesh::SMESH_ProxyMesh():_mesh(0) +SMESH_ProxyMesh::SMESH_ProxyMesh():_mesh(0), _subContainer(0) { } +//================================================================================ +/*! + * \brief Constructor + */ +//================================================================================ + +SMESH_ProxyMesh::SMESH_ProxyMesh(const SMESH_Mesh& mesh) + : _mesh( &mesh ), + _subContainer( new SubMesh( GetMeshDS() ) ) +{ +} + //================================================================================ /*! * \brief Make a proxy mesh from components. Components become empty @@ -59,7 +71,7 @@ SMESH_ProxyMesh::SMESH_ProxyMesh(std::vector& components): takeTmpElemsInMesh( m ); - if ( !_mesh ) _mesh = m->_mesh; + if ( !_mesh && m->_mesh ) setMesh( *( m->_mesh )); if ( _allowedTypes.empty() ) _allowedTypes = m->_allowedTypes; if ( _subMeshes.size() < m->_subMeshes.size() ) @@ -101,6 +113,8 @@ SMESH_ProxyMesh::SMESH_ProxyMesh(std::vector& components): SMESH_ProxyMesh::~SMESH_ProxyMesh() { + delete _subContainer; + for ( size_t i = 0; i < _subMeshes.size(); ++i ) delete _subMeshes[i]; _subMeshes.clear(); @@ -111,6 +125,19 @@ SMESH_ProxyMesh::~SMESH_ProxyMesh() _elemsInMesh.clear(); } +//================================================================================ +/*! + * \brief Set mesh + */ +//================================================================================ + +void SMESH_ProxyMesh::setMesh(const SMESH_Mesh& mesh) +{ + _mesh = &mesh; + if ( _mesh ) + _subContainer = new SubMesh( GetMeshDS() ); +} + //================================================================================ /*! * \brief Returns index of a shape @@ -122,6 +149,19 @@ int SMESH_ProxyMesh::shapeIndex(const TopoDS_Shape& shape) const return ( shape.IsNull() || !_mesh->HasShapeToMesh() ? 0 : GetMeshDS()->ShapeToIndex(shape)); } +//================================================================================ +/*! + * \brief Create a SubMesh + * \param [ino] index - shape index + * \return SubMesh* - new SubMesh + */ +//================================================================================ + +SMESH_ProxyMesh::SubMesh* SMESH_ProxyMesh::newSubmesh(int index) const +{ + return new SubMesh( GetMeshDS(),index ); +} + //================================================================================ /*! * \brief Returns the submesh of a shape; it can be a proxy sub-mesh @@ -245,15 +285,15 @@ SMDS_ElemIteratorPtr SMESH_ProxyMesh::GetFaces(const TopoDS_Shape& shape) const if ( !_mesh->HasShapeToMesh() ) return SMDS_ElemIteratorPtr(); - _subContainer.RemoveAllSubmeshes(); + _subContainer->RemoveAllSubmeshes(); TopTools_IndexedMapOfShape FF; TopExp::MapShapes( shape, TopAbs_FACE, FF ); for ( int i = 1; i <= FF.Extent(); ++i ) if ( const SMESHDS_SubMesh* sm = GetSubMesh( FF(i))) - _subContainer.AddSubMesh( sm ); + _subContainer->AddSubMesh( sm ); - return _subContainer.SMESHDS_SubMesh::GetElements(); + return _subContainer->SMESHDS_SubMesh::GetElements(); } //================================================================================ @@ -268,16 +308,16 @@ SMDS_ElemIteratorPtr SMESH_ProxyMesh::GetFaces() const if ( _mesh->HasShapeToMesh() ) return SMDS_ElemIteratorPtr(); - _subContainer.RemoveAllSubmeshes(); + _subContainer->RemoveAllSubmeshes(); for ( unsigned i = 0; i < _subMeshes.size(); ++i ) if ( _subMeshes[i] ) - _subContainer.AddSubMesh( _subMeshes[i] ); + _subContainer->AddSubMesh( _subMeshes[i] ); - if ( _subContainer.NbSubMeshes() == 0 ) // no elements substituted + if ( _subContainer->NbSubMeshes() == 0 ) // no elements substituted return GetMeshDS()->elementsIterator(SMDSAbs_Face); // if _allowedTypes is empty, only elements from _subMeshes are returned,... - SMDS_ElemIteratorPtr proxyIter = _subContainer.SMESHDS_SubMesh::GetElements(); + SMDS_ElemIteratorPtr proxyIter = _subContainer->SMESHDS_SubMesh::GetElements(); if ( _allowedTypes.empty() || NbFaces() == _mesh->NbFaces() ) return proxyIter; @@ -484,6 +524,18 @@ bool SMESH_ProxyMesh::IsTemporary(const SMDS_MeshElement* elem ) const return ( elem->GetID() < 1 ) || _elemsInMesh.count( elem ); } +//================================================================================ +/*! + * \brief SubMesh Constructor + */ +//================================================================================ + +SMESH_ProxyMesh::SubMesh::SubMesh( const SMDS_Mesh* mesh, int index ) + : SMESHDS_SubMesh( static_cast( mesh ), index ), + _n2n(0) +{ +} + //================================================================================ /*! * \brief Return a proxy node or an input node @@ -533,7 +585,7 @@ int SMESH_ProxyMesh::SubMesh::NbElements() const */ //================================================================================ -SMDS_ElemIteratorPtr SMESH_ProxyMesh::SubMesh::GetElements(bool reverse) const +SMDS_ElemIteratorPtr SMESH_ProxyMesh::SubMesh::GetElements() const { return SMDS_ElemIteratorPtr ( new SMDS_ElementVectorIterator( _elements.begin(), _elements.end() )); @@ -558,7 +610,7 @@ int SMESH_ProxyMesh::SubMesh::NbNodes() const */ //================================================================================ -SMDS_NodeIteratorPtr SMESH_ProxyMesh::SubMesh::GetNodes(bool reverse) const +SMDS_NodeIteratorPtr SMESH_ProxyMesh::SubMesh::GetNodes() const { if ( !_uvPtStructVec.empty() ) return SMDS_NodeIteratorPtr ( new SMDS_SetIterator