Salome HOME
8a40ff22664be44214e6bd3d3a90bc4f7df5e196
[modules/geom.git] / src / GEOMDS / GEOMDS_Explorer.cxx
1 //  GEOM GEOMDS : implementation of Geometry component data structure and Geometry documents management
2 //
3 //  Copyright (C) 2003  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 //  CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS 
5 // 
6 //  This library is free software; you can redistribute it and/or 
7 //  modify it under the terms of the GNU Lesser General Public 
8 //  License as published by the Free Software Foundation; either 
9 //  version 2.1 of the License. 
10 // 
11 //  This library is distributed in the hope that it will be useful, 
12 //  but WITHOUT ANY WARRANTY; without even the implied warranty of 
13 //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU 
14 //  Lesser General Public License for more details. 
15 // 
16 //  You should have received a copy of the GNU Lesser General Public 
17 //  License along with this library; if not, write to the Free Software 
18 //  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA 
19 // 
20 //  See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org 
21 //
22 //
23 //
24 //  File   : GEOMDS_Explorer.cxx
25 //  Author : Yves FRICAUD
26 //  Module : GEOM
27 //  $Header$
28
29 using namespace std;
30 #include "GEOMDS_Explorer.ixx"
31
32 #include <TNaming_NamedShape.hxx>
33 #include <TNaming_Tool.hxx>
34 #include <TDataStd_Name.hxx>
35
36
37 //=======================================================================
38 //function : GEOMDS_Explorer
39 //purpose  : 
40 //=======================================================================
41
42 GEOMDS_Explorer::GEOMDS_Explorer(const TDF_Label& Main) : myChildIterator(Main)
43 {
44 }
45
46
47 //=======================================================================
48 //function : const;
49 //purpose  : 
50 //=======================================================================
51
52 Standard_Boolean GEOMDS_Explorer::More() 
53 {
54   if (!myChildIterator.More())
55     return 0;
56   Handle(TDataStd_Name) Att;
57   Handle(TNaming_NamedShape) NS; 
58   TDF_Label L = myChildIterator.Value();
59   if (( L.FindAttribute(TDataStd_Name::GetID(),Att) ) || 
60       (L.FindAttribute(TNaming_NamedShape::GetID(),NS))
61       )
62     return 1;
63   //  myChildIterator.Next();
64   //  More();
65   return 0;
66   /*
67     if (!myChildIterator.More())
68     return 0;
69     TDF_Label L = myChildIterator.Value();
70     Handle(TNaming_NamedShape) NS; 
71     for (TDF_ChildIterator it2(L); it2.More(); it2.Next()) {
72     TDF_Label L2 = it2.Value();
73     if (L2.FindAttribute(TNaming_NamedShape::GetID(),NS)) {
74     return 1;
75     }
76     myChildIterator.Next();
77     }
78     return 0;
79   */
80 }
81
82
83 //=======================================================================
84 //function : Next
85 //purpose  : 
86 //=======================================================================
87
88 void GEOMDS_Explorer::Next() 
89 {
90   myChildIterator.Next();
91 }
92
93
94 //=======================================================================
95 //function : Shape
96 //purpose  : 
97 //=======================================================================
98
99 TopoDS_Shape GEOMDS_Explorer::Shape() const
100 {
101   Handle(TNaming_NamedShape) NS; 
102   TDF_Label L = myChildIterator.Value();
103   L.FindAttribute(TNaming_NamedShape::GetID(),NS);
104   TopoDS_Shape S = TNaming_Tool::GetShape(NS);
105   return S;
106 }
107
108 //=======================================================================
109 //function : Name
110 //purpose  : 
111 //=======================================================================
112
113 TCollection_ExtendedString GEOMDS_Explorer::Name() const
114 {
115  TDF_Label L = myChildIterator.Value();
116  Handle(TDataStd_Name) Att;
117  if ( L.FindAttribute(TDataStd_Name::GetID(),Att) )
118    //L.FindAttribute(TDataStd_Name::GetID(),Att);
119    return Att->Get();
120  else
121    return TCollection_ExtendedString();
122 }
123
124
125
126