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
6 // This file is part of Open CASCADE Technology software library.
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.
14 // Alternatively, this file may be used under the terms of Open CASCADE
15 // commercial license or contractual agreement.
18 #include <Standard_ConstructionError.hxx>
19 #include <Standard_OutOfRange.hxx>
20 #include <Sweep_NumShape.hxx>
21 #include <Sweep_NumShapeTool.hxx>
23 //=======================================================================
24 //function : Sweep_NumShapeTool
26 //=======================================================================
27 Sweep_NumShapeTool::Sweep_NumShapeTool(const Sweep_NumShape& aShape) :
33 //=======================================================================
36 //=======================================================================
38 Standard_Integer Sweep_NumShapeTool::NbShapes()const
40 if (myNumShape.Type()==TopAbs_EDGE){
41 if (myNumShape.Closed()) { return myNumShape.Index(); }
42 else { return myNumShape.Index() + 1 ;}
50 //=======================================================================
53 //=======================================================================
55 Standard_Integer Sweep_NumShapeTool::Index
56 (const Sweep_NumShape& aShape)const
58 if (aShape.Type()==TopAbs_EDGE){
62 if (aShape.Closed()) { return 2; }
63 else { return (aShape.Index() + 1); }
68 //=======================================================================
71 //=======================================================================
73 Sweep_NumShape Sweep_NumShapeTool::Shape
74 (const Standard_Integer anIndex)const
80 return Sweep_NumShape((anIndex-1),TopAbs_VERTEX,
81 myNumShape.Closed(),Standard_False,
87 //=======================================================================
90 //=======================================================================
92 TopAbs_ShapeEnum Sweep_NumShapeTool::Type(const Sweep_NumShape& aShape)const
99 //=======================================================================
100 //function : Orientation
102 //=======================================================================
104 TopAbs_Orientation Sweep_NumShapeTool::Orientation
105 (const Sweep_NumShape& aShape)const
107 return aShape.Orientation();
111 //=======================================================================
112 //function : HasFirstVertex
114 //=======================================================================
116 Standard_Boolean Sweep_NumShapeTool::HasFirstVertex()const
118 if (myNumShape.Type()==TopAbs_EDGE)
119 return !myNumShape.BegInfinite();
120 return Standard_True;
124 //=======================================================================
125 //function : HasLastVertex
127 //=======================================================================
129 Standard_Boolean Sweep_NumShapeTool::HasLastVertex()const
131 if (myNumShape.Type()==TopAbs_EDGE)
132 return !myNumShape.EndInfinite();
133 return Standard_True;
137 //=======================================================================
138 //function : FirstVertex
140 //=======================================================================
142 Sweep_NumShape Sweep_NumShapeTool::FirstVertex()const
144 if (myNumShape.Type()==TopAbs_EDGE){
145 if(HasFirstVertex()){
146 return Sweep_NumShape(1,TopAbs_VERTEX,
147 myNumShape.Closed(),Standard_False,
150 else throw Standard_ConstructionError("inifinite Shape");
156 //=======================================================================
157 //function : LastVertex
159 //=======================================================================
161 Sweep_NumShape Sweep_NumShapeTool::LastVertex()const
163 if (myNumShape.Type()==TopAbs_EDGE){
165 return Sweep_NumShape(NbShapes()-1,TopAbs_VERTEX,
166 myNumShape.Closed(),Standard_False,
169 else throw Standard_ConstructionError("inifinite Shape");