-// Copyright (C) 2007-2015 CEA/DEN, EDF R&D, OPEN CASCADE
+// Copyright (C) 2007-2016 CEA/DEN, EDF R&D, OPEN CASCADE
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
#include "SMDS_IteratorOnIterators.hxx"
#include "SMDS_SetIterator.hxx"
+#include "SMESHDS_Mesh.hxx"
+#include "SMESH_Mesh.hxx"
#include "SMESH_MesherHelper.hxx"
#include <TopTools_ListIteratorOfListOfShape.hxx>
*/
//================================================================================
-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
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() )
//================================================================================
/*!
- * \brief Destructor deletes proxy submeshes and tmp elemens
+ * \brief Destructor deletes proxy submeshes and tmp elements
*/
//================================================================================
SMESH_ProxyMesh::~SMESH_ProxyMesh()
{
- for ( unsigned i = 0; i < _subMeshes.size(); ++i )
+ delete _subContainer;
+
+ for ( size_t i = 0; i < _subMeshes.size(); ++i )
delete _subMeshes[i];
_subMeshes.clear();
_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
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
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();
}
//================================================================================
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;