Warnings on vc14 were eliminated
[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_NumShape.hxx>
21 #include <Sweep_NumShapeTool.hxx>
22
23 //=======================================================================
24 //function : Sweep_NumShapeTool
25 //purpose  : 
26 //=======================================================================
27 Sweep_NumShapeTool::Sweep_NumShapeTool(const Sweep_NumShape& aShape) :
28        myNumShape(aShape)
29 {
30 }
31
32
33 //=======================================================================
34 //function : NbShapes
35 //purpose  : 
36 //=======================================================================
37
38 Standard_Integer  Sweep_NumShapeTool::NbShapes()const 
39 {
40   if (myNumShape.Type()==TopAbs_EDGE){
41     if (myNumShape.Closed()) { return myNumShape.Index(); }
42     else { return myNumShape.Index() + 1 ;}
43   }
44   else{
45     return 1;
46   }
47 }
48
49
50 //=======================================================================
51 //function : Index
52 //purpose  : 
53 //=======================================================================
54
55 Standard_Integer  Sweep_NumShapeTool::Index
56   (const Sweep_NumShape& aShape)const 
57 {
58   if (aShape.Type()==TopAbs_EDGE){
59     return 1;
60   }
61   else{
62     if (aShape.Closed()) { return 2; }
63     else { return (aShape.Index() + 1); }
64   }
65 }
66
67
68 //=======================================================================
69 //function : Shape
70 //purpose  : 
71 //=======================================================================
72
73 Sweep_NumShape  Sweep_NumShapeTool::Shape
74   (const Standard_Integer anIndex)const 
75 {
76   if (anIndex == 1){
77     return myNumShape;
78   }
79   else{
80     return Sweep_NumShape((anIndex-1),TopAbs_VERTEX,
81                           myNumShape.Closed(),Standard_False,
82                           Standard_False);
83   }
84 }
85
86
87 //=======================================================================
88 //function : Type
89 //purpose  : 
90 //=======================================================================
91
92 TopAbs_ShapeEnum  Sweep_NumShapeTool::Type(const Sweep_NumShape& aShape)const 
93 {
94   return aShape.Type();
95 }
96
97
98
99 //=======================================================================
100 //function : Orientation
101 //purpose  : 
102 //=======================================================================
103
104 TopAbs_Orientation  Sweep_NumShapeTool::Orientation
105   (const Sweep_NumShape& aShape)const 
106 {
107   return aShape.Orientation();
108 }
109
110
111 //=======================================================================
112 //function : HasFirstVertex
113 //purpose  : 
114 //=======================================================================
115
116 Standard_Boolean Sweep_NumShapeTool::HasFirstVertex()const
117 {
118   if (myNumShape.Type()==TopAbs_EDGE)
119     return !myNumShape.BegInfinite();
120   return Standard_True;
121 }
122
123
124 //=======================================================================
125 //function : HasLastVertex
126 //purpose  : 
127 //=======================================================================
128
129 Standard_Boolean Sweep_NumShapeTool::HasLastVertex()const
130 {
131   if (myNumShape.Type()==TopAbs_EDGE)
132     return !myNumShape.EndInfinite();
133   return Standard_True;
134 }
135
136
137 //=======================================================================
138 //function : FirstVertex
139 //purpose  : 
140 //=======================================================================
141
142 Sweep_NumShape Sweep_NumShapeTool::FirstVertex()const
143 {
144   if (myNumShape.Type()==TopAbs_EDGE){
145     if(HasFirstVertex()){
146       return Sweep_NumShape(1,TopAbs_VERTEX,
147                             myNumShape.Closed(),Standard_False,
148                             Standard_False);
149     }
150     else throw Standard_ConstructionError("inifinite Shape");
151   }
152   return myNumShape;
153 }
154
155
156 //=======================================================================
157 //function : LastVertex
158 //purpose  : 
159 //=======================================================================
160
161 Sweep_NumShape Sweep_NumShapeTool::LastVertex()const
162 {
163   if (myNumShape.Type()==TopAbs_EDGE){
164     if(HasLastVertex()){
165       return Sweep_NumShape(NbShapes()-1,TopAbs_VERTEX,
166                             myNumShape.Closed(),Standard_False,
167                             Standard_False);
168     }
169     else throw Standard_ConstructionError("inifinite Shape");
170   }
171   return myNumShape;
172 }
173