0033040: Coding - get rid of unused headers [Storage to TopOpeBRepTool]
[occt.git] / src / Sweep / Sweep_NumShapeTool.cxx
1 // Created on: 1993-06-02
2 // Created by: Laurent BOURESCHE
3 // Copyright (c) 1993-1999 Matra Datavision
4 // Copyright (c) 1999-2014 OPEN CASCADE SAS
5 //
6 // This file is part of Open CASCADE Technology software library.
7 //
8 // This library is free software; you can redistribute it and/or modify it under
9 // the terms of the GNU Lesser General Public License version 2.1 as published
10 // by the Free Software Foundation, with special exception defined in the file
11 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
12 // distribution for complete text of the license and disclaimer of any warranty.
13 //
14 // Alternatively, this file may be used under the terms of Open CASCADE
15 // commercial license or contractual agreement.
16
17
18 #include <Standard_ConstructionError.hxx>
19 #include <Standard_OutOfRange.hxx>
20 #include <Sweep_NumShapeTool.hxx>
21
22 //=======================================================================
23 //function : Sweep_NumShapeTool
24 //purpose  : 
25 //=======================================================================
26 Sweep_NumShapeTool::Sweep_NumShapeTool(const Sweep_NumShape& aShape) :
27        myNumShape(aShape)
28 {
29 }
30
31
32 //=======================================================================
33 //function : NbShapes
34 //purpose  : 
35 //=======================================================================
36
37 Standard_Integer  Sweep_NumShapeTool::NbShapes()const 
38 {
39   if (myNumShape.Type()==TopAbs_EDGE){
40     if (myNumShape.Closed()) { return myNumShape.Index(); }
41     else { return myNumShape.Index() + 1 ;}
42   }
43   else{
44     return 1;
45   }
46 }
47
48
49 //=======================================================================
50 //function : Index
51 //purpose  : 
52 //=======================================================================
53
54 Standard_Integer  Sweep_NumShapeTool::Index
55   (const Sweep_NumShape& aShape)const 
56 {
57   if (aShape.Type()==TopAbs_EDGE){
58     return 1;
59   }
60   else{
61     if (aShape.Closed()) { return 2; }
62     else { return (aShape.Index() + 1); }
63   }
64 }
65
66
67 //=======================================================================
68 //function : Shape
69 //purpose  : 
70 //=======================================================================
71
72 Sweep_NumShape  Sweep_NumShapeTool::Shape
73   (const Standard_Integer anIndex)const 
74 {
75   if (anIndex == 1){
76     return myNumShape;
77   }
78   else{
79     return Sweep_NumShape((anIndex-1),TopAbs_VERTEX,
80                           myNumShape.Closed(),Standard_False,
81                           Standard_False);
82   }
83 }
84
85
86 //=======================================================================
87 //function : Type
88 //purpose  : 
89 //=======================================================================
90
91 TopAbs_ShapeEnum  Sweep_NumShapeTool::Type(const Sweep_NumShape& aShape)const 
92 {
93   return aShape.Type();
94 }
95
96
97
98 //=======================================================================
99 //function : Orientation
100 //purpose  : 
101 //=======================================================================
102
103 TopAbs_Orientation  Sweep_NumShapeTool::Orientation
104   (const Sweep_NumShape& aShape)const 
105 {
106   return aShape.Orientation();
107 }
108
109
110 //=======================================================================
111 //function : HasFirstVertex
112 //purpose  : 
113 //=======================================================================
114
115 Standard_Boolean Sweep_NumShapeTool::HasFirstVertex()const
116 {
117   if (myNumShape.Type()==TopAbs_EDGE)
118     return !myNumShape.BegInfinite();
119   return Standard_True;
120 }
121
122
123 //=======================================================================
124 //function : HasLastVertex
125 //purpose  : 
126 //=======================================================================
127
128 Standard_Boolean Sweep_NumShapeTool::HasLastVertex()const
129 {
130   if (myNumShape.Type()==TopAbs_EDGE)
131     return !myNumShape.EndInfinite();
132   return Standard_True;
133 }
134
135
136 //=======================================================================
137 //function : FirstVertex
138 //purpose  : 
139 //=======================================================================
140
141 Sweep_NumShape Sweep_NumShapeTool::FirstVertex()const
142 {
143   if (myNumShape.Type()==TopAbs_EDGE){
144     if(HasFirstVertex()){
145       return Sweep_NumShape(1,TopAbs_VERTEX,
146                             myNumShape.Closed(),Standard_False,
147                             Standard_False);
148     }
149     else throw Standard_ConstructionError("inifinite Shape");
150   }
151   return myNumShape;
152 }
153
154
155 //=======================================================================
156 //function : LastVertex
157 //purpose  : 
158 //=======================================================================
159
160 Sweep_NumShape Sweep_NumShapeTool::LastVertex()const
161 {
162   if (myNumShape.Type()==TopAbs_EDGE){
163     if(HasLastVertex()){
164       return Sweep_NumShape(NbShapes()-1,TopAbs_VERTEX,
165                             myNumShape.Closed(),Standard_False,
166                             Standard_False);
167     }
168     else throw Standard_ConstructionError("inifinite Shape");
169   }
170   return myNumShape;
171 }
172