1 // SMESH SMESHDS : idl implementation based on 'SMESH' unit's classes
3 // Copyright (C) 2004 CEA
5 // This library is free software; you can redistribute it and/or
6 // modify it under the terms of the GNU Lesser General Public
7 // License as published by the Free Software Foundation; either
8 // version 2.1 of the License.
10 // This library is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 // Lesser General Public License for more details.
15 // You should have received a copy of the GNU Lesser General Public
16 // License along with this library; if not, write to the Free Software
17 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
23 // File : SMESHDS_GroupOnGeom.cxx
27 #include "SMESHDS_GroupOnGeom.hxx"
28 #include "SMESHDS_Mesh.hxx"
29 #include "utilities.h"
33 //=============================================================================
37 //=============================================================================
39 SMESHDS_GroupOnGeom::SMESHDS_GroupOnGeom (const int theID,
40 const SMESHDS_Mesh* theMesh,
41 const SMDSAbs_ElementType theType,
42 const TopoDS_Shape& theShape)
43 : SMESHDS_GroupBase(theID,theMesh,theType), myShape(theShape)
45 SMESHDS_Mesh* aMesh = const_cast<SMESHDS_Mesh*>(theMesh);
46 mySubMesh = aMesh->MeshElements( aMesh->AddCompoundSubmesh( theShape ));
49 // =====================
50 // class MyGroupIterator
51 // =====================
53 class MyIterator: public SMDS_ElemIterator
55 SMDSAbs_ElementType myType;
56 SMDS_ElemIteratorPtr myElemIt;
57 SMDS_NodeIteratorPtr myNodeIt;
58 const SMDS_MeshElement* myElem;
60 MyIterator(SMDSAbs_ElementType type, const SMESHDS_SubMesh* subMesh)
61 : myType(type), myElem(0)
64 if ( myType == SMDSAbs_Node )
65 myNodeIt = subMesh->GetNodes();
67 myElemIt = subMesh->GetElements();
73 if ( myType == SMDSAbs_Node && myNodeIt )
74 return myNodeIt->more();
75 return ( myElem != 0 );
77 const SMDS_MeshElement* next()
79 if ( myType == SMDSAbs_Node && myNodeIt )
80 return myNodeIt->next();
81 const SMDS_MeshElement* res = myElem;
83 while ( myElemIt && myElemIt->more() ) {
84 myElem = myElemIt->next();
85 if ( myElem && myElem->GetType() == myType )
94 //=======================================================================
95 //function : GetElements
97 //=======================================================================
99 SMDS_ElemIteratorPtr SMESHDS_GroupOnGeom::GetElements()
101 return SMDS_ElemIteratorPtr( new MyIterator ( GetType(), mySubMesh ));
104 //=======================================================================
105 //function : Contains
107 //=======================================================================
109 bool SMESHDS_GroupOnGeom::Contains (const int theID)
111 return mySubMesh->Contains( findInMesh( theID ));