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_NumShapeTool.hxx>
22 //=======================================================================
23 //function : Sweep_NumShapeTool
25 //=======================================================================
26 Sweep_NumShapeTool::Sweep_NumShapeTool(const Sweep_NumShape& aShape) :
32 //=======================================================================
35 //=======================================================================
37 Standard_Integer Sweep_NumShapeTool::NbShapes()const
39 if (myNumShape.Type()==TopAbs_EDGE){
40 if (myNumShape.Closed()) { return myNumShape.Index(); }
41 else { return myNumShape.Index() + 1 ;}
49 //=======================================================================
52 //=======================================================================
54 Standard_Integer Sweep_NumShapeTool::Index
55 (const Sweep_NumShape& aShape)const
57 if (aShape.Type()==TopAbs_EDGE){
61 if (aShape.Closed()) { return 2; }
62 else { return (aShape.Index() + 1); }
67 //=======================================================================
70 //=======================================================================
72 Sweep_NumShape Sweep_NumShapeTool::Shape
73 (const Standard_Integer anIndex)const
79 return Sweep_NumShape((anIndex-1),TopAbs_VERTEX,
80 myNumShape.Closed(),Standard_False,
86 //=======================================================================
89 //=======================================================================
91 TopAbs_ShapeEnum Sweep_NumShapeTool::Type(const Sweep_NumShape& aShape)const
98 //=======================================================================
99 //function : Orientation
101 //=======================================================================
103 TopAbs_Orientation Sweep_NumShapeTool::Orientation
104 (const Sweep_NumShape& aShape)const
106 return aShape.Orientation();
110 //=======================================================================
111 //function : HasFirstVertex
113 //=======================================================================
115 Standard_Boolean Sweep_NumShapeTool::HasFirstVertex()const
117 if (myNumShape.Type()==TopAbs_EDGE)
118 return !myNumShape.BegInfinite();
119 return Standard_True;
123 //=======================================================================
124 //function : HasLastVertex
126 //=======================================================================
128 Standard_Boolean Sweep_NumShapeTool::HasLastVertex()const
130 if (myNumShape.Type()==TopAbs_EDGE)
131 return !myNumShape.EndInfinite();
132 return Standard_True;
136 //=======================================================================
137 //function : FirstVertex
139 //=======================================================================
141 Sweep_NumShape Sweep_NumShapeTool::FirstVertex()const
143 if (myNumShape.Type()==TopAbs_EDGE){
144 if(HasFirstVertex()){
145 return Sweep_NumShape(1,TopAbs_VERTEX,
146 myNumShape.Closed(),Standard_False,
149 else throw Standard_ConstructionError("inifinite Shape");
155 //=======================================================================
156 //function : LastVertex
158 //=======================================================================
160 Sweep_NumShape Sweep_NumShapeTool::LastVertex()const
162 if (myNumShape.Type()==TopAbs_EDGE){
164 return Sweep_NumShape(NbShapes()-1,TopAbs_VERTEX,
165 myNumShape.Closed(),Standard_False,
168 else throw Standard_ConstructionError("inifinite Shape");