]> SALOME platform Git repositories - modules/smesh.git/blobdiff - src/SMESH/SMESH_ProxyMesh.cxx
Salome HOME
a bit more comments
[modules/smesh.git] / src / SMESH / SMESH_ProxyMesh.cxx
index aba3c8e9c7b5932589c53a8b706cf279b8b79040..29c01abd9fbac0e8d1674435b0cf25cf2ea40f8d 100644 (file)
@@ -1,20 +1,20 @@
-//  Copyright (C) 2007-2010  CEA/DEN, EDF R&D, OPEN CASCADE
+// Copyright (C) 2007-2012  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
-//  License as published by the Free Software Foundation; either
-//  version 2.1 of the License.
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
 //
-//  This library is distributed in the hope that it will be useful,
-//  but WITHOUT ANY WARRANTY; without even the implied warranty of
-//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-//  Lesser General Public License for more details.
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+// Lesser General Public License for more details.
 //
-//  You should have received a copy of the GNU Lesser General Public
-//  License along with this library; if not, write to the Free Software
-//  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
 //
-//  See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
 //
 // File      : SMESH_ProxyMesh.cxx
 // Created   : Thu Dec  2 12:32:53 2010
@@ -178,6 +178,21 @@ const SMDS_MeshNode* SMESH_ProxyMesh::GetProxyNode( const SMDS_MeshNode* node )
   return proxy;
 }
 
+//================================================================================
+/*!
+ * \brief Returns number of proxy sub-meshes
+ */
+//================================================================================
+
+int SMESH_ProxyMesh::NbProxySubMeshes() const
+{
+  int nb = 0;
+  for ( size_t i = 0; i < _subMeshes.size(); ++i )
+    nb += bool( _subMeshes[i] );
+
+  return nb;
+}
+
 namespace
 {
   //================================================================================
@@ -329,7 +344,7 @@ SMESH_ProxyMesh::SubMesh* SMESH_ProxyMesh::getProxySubMesh(int index)
   if ( int(_subMeshes.size()) <= index )
     _subMeshes.resize( index+1, 0 );
   if ( !_subMeshes[index] )
-    _subMeshes[index] = new SubMesh( index );
+    _subMeshes[index] = newSubmesh( index );
   return _subMeshes[index];
 }
 
@@ -408,24 +423,24 @@ void SMESH_ProxyMesh::takeTmpElemsInMesh( SMESH_ProxyMesh* proxyMesh )
 
 //================================================================================
 /*!
- * \brief Removes tmp faces from the _mesh
+ * \brief Removes tmp elements from the _mesh
  */
 //================================================================================
 
-void SMESH_ProxyMesh::removeTmpElement( const SMDS_MeshElement* face )
+void SMESH_ProxyMesh::removeTmpElement( const SMDS_MeshElement* elem )
 {
-  if ( face && face->GetID() > 0 )
+  if ( elem && elem->GetID() > 0 )
   {
-    set< const SMDS_MeshElement* >::iterator i =  _elemsInMesh.find( face );
+    set< const SMDS_MeshElement* >::iterator i =  _elemsInMesh.find( elem );
     if ( i != _elemsInMesh.end() )
     {
-      GetMeshDS()->RemoveFreeElement( face, 0 );
+      GetMeshDS()->RemoveFreeElement( elem, 0 );
       _elemsInMesh.erase( i );
     }
   }
   else
   {
-    delete face;
+    delete elem;
   }
 }
 
@@ -435,9 +450,9 @@ void SMESH_ProxyMesh::removeTmpElement( const SMDS_MeshElement* face )
  */
 //================================================================================
 
-void SMESH_ProxyMesh::storeTmpElement( const SMDS_MeshElement* face )
+void SMESH_ProxyMesh::storeTmpElement( const SMDS_MeshElement* elem )
 {
-  _elemsInMesh.insert( face );
+  _elemsInMesh.insert( elem );
 }
 
 //================================================================================
@@ -447,8 +462,8 @@ void SMESH_ProxyMesh::storeTmpElement( const SMDS_MeshElement* face )
 //================================================================================
 
 void SMESH_ProxyMesh::setNode2Node(const SMDS_MeshNode* srcNode,
-                                        const SMDS_MeshNode* proxyNode,
-                                        const SubMesh*       subMesh)
+                                   const SMDS_MeshNode* proxyNode,
+                                   const SubMesh*       subMesh)
 {
   SubMesh* sm = const_cast<SubMesh*>( subMesh );
   if ( !subMesh->_n2n )
@@ -499,18 +514,20 @@ void SMESH_ProxyMesh::SubMesh::Clear()
 
 //================================================================================
 /*!
- * \brief Return number of elements in a proxy submesh
+ * \brief Return number of elements in a proxy sub-mesh. The method is meaningful
+ *        for a sub-mesh containing tmp faces.
  */
 //================================================================================
 
 int SMESH_ProxyMesh::SubMesh::NbElements() const
 {
-  return _elements.size();
+  return _uvPtStructVec.empty() ? _elements.size() : _uvPtStructVec.size() - 1;
 }
 
 //================================================================================
 /*!
- * \brief Return elements of a proxy submesh
+ * \brief Return elements of a proxy sub-mesh. The method is meaningful
+ *        for a sub-mesh containing tmp faces.
  */
 //================================================================================
 
@@ -520,6 +537,39 @@ SMDS_ElemIteratorPtr SMESH_ProxyMesh::SubMesh::GetElements() const
     ( new SMDS_ElementVectorIterator( _elements.begin(), _elements.end() ));
 }
 
+//================================================================================
+/*!
+ * \brief Return number of nodes in a proxy sub-mesh. The method is meaningful
+ *        for a sub-mesh containing nodes of 2D viscous layer.
+ */
+//================================================================================
+
+int SMESH_ProxyMesh::SubMesh::NbNodes() const
+{
+  return _uvPtStructVec.size();
+}
+
+//================================================================================
+/*!
+ * \brief Return nodes of a proxy sub-mesh. The method is meaningful
+ *        for a sub-mesh containing nodes of 2D viscous layer.
+ */
+//================================================================================
+
+SMDS_NodeIteratorPtr SMESH_ProxyMesh::SubMesh::GetNodes() const
+{
+  if ( !_uvPtStructVec.empty() )
+    return SMDS_NodeIteratorPtr ( new SMDS_SetIterator
+                                  < SMDS_pNode,
+                                  UVPtStructVec::const_iterator,
+                                  UVPtStruct::NodeAccessor >
+                                  ( _uvPtStructVec.begin(), _uvPtStructVec.end() ));
+
+  return SMDS_NodeIteratorPtr
+    ( new SMDS_SetIterator< SMDS_pNode, std::vector< SMDS_pElement >::const_iterator>
+      ( _elements.begin(), _elements.end() ));
+}
+
 //================================================================================
 /*!
  * \brief Store an element