92bdc03ec9464d3b685ba6928c8f01c79866d0d1
[occt.git] / src / Expr / Expr_RelationIterator.cxx
1 //static const char* sccsid = "@(#)Expr_RelationIterator.cxx    3.2 95/01/10"; // Do not delete this line. Used by sccs.
2 // Copyright:   Matra-Datavision 1991
3 // File:        Expr_RelationIterator.cxx
4 // Created:     Thu Jun 13 16:57:35 1991
5 // Author:      Arnaud BOUZY
6 //              <adn>
7
8 #include <Expr_RelationIterator.ixx>
9 #include <Standard_NoMoreObject.hxx>
10 #include <Standard_NoSuchObject.hxx>
11 #include <Expr_SystemRelation.hxx>
12
13 Expr_RelationIterator::Expr_RelationIterator (const Handle(Expr_GeneralRelation)& rel):myRelation(1,rel->NbOfSingleRelations())
14 {
15   if (rel->IsKind(STANDARD_TYPE(Expr_SingleRelation))) {
16     myRelation(1) = Handle(Expr_SingleRelation)::DownCast(rel);
17   }
18   else {
19     Standard_Integer nbcur = 1;
20     Handle(Expr_GeneralRelation) currel;
21     for (Standard_Integer i =1; i<= rel->NbOfSubRelations(); i++) {
22       currel = rel->SubRelation(i);
23       if (currel->IsKind(STANDARD_TYPE(Expr_SingleRelation))) {
24         myRelation(nbcur) = Handle(Expr_SingleRelation)::DownCast(currel);
25         nbcur++;
26       }
27       else {
28         Expr_RelationIterator subit(currel);
29         while (subit.More()) {
30           myRelation(nbcur) = subit.Value();
31           subit.Next();
32           nbcur++;
33         }
34       }
35     }
36   }
37   current = 1;
38 }
39
40 Standard_Boolean Expr_RelationIterator::More () const
41 {
42   return (current <= myRelation.Length());
43 }
44
45 void Expr_RelationIterator::Next ()
46 {
47   if (!More()) {
48     Standard_NoMoreObject::Raise();
49   }
50   current++;
51 }
52
53 Handle(Expr_SingleRelation) Expr_RelationIterator::Value () const
54 {
55   if (!More()) {
56     Standard_NoSuchObject::Raise();
57   }
58   return myRelation(current);
59 }
60