0032961: Coding - get rid of unused headers [IGESAppli to IGESToBRep]
[occt.git] / src / IGESSolid / IGESSolid_Loop.cxx
1 // Created by: CKY / Contract Toubro-Larsen
2 // Copyright (c) 1993-1999 Matra Datavision
3 // Copyright (c) 1999-2014 OPEN CASCADE SAS
4 //
5 // This file is part of Open CASCADE Technology software library.
6 //
7 // This library is free software; you can redistribute it and/or modify it under
8 // the terms of the GNU Lesser General Public License version 2.1 as published
9 // by the Free Software Foundation, with special exception defined in the file
10 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
11 // distribution for complete text of the license and disclaimer of any warranty.
12 //
13 // Alternatively, this file may be used under the terms of Open CASCADE
14 // commercial license or contractual agreement.
15
16 //--------------------------------------------------------------------
17 //--------------------------------------------------------------------
18 //pdn 20.04.99 CTS22655 avoid of exceptions on empty loops
19
20 #include <IGESBasic_HArray1OfHArray1OfIGESEntity.hxx>
21 #include <IGESBasic_HArray1OfHArray1OfInteger.hxx>
22 #include <IGESData_IGESEntity.hxx>
23 #include <IGESSolid_EdgeList.hxx>
24 #include <IGESSolid_Loop.hxx>
25 #include <IGESSolid_VertexList.hxx>
26 #include <Standard_DimensionMismatch.hxx>
27 #include <Standard_Type.hxx>
28
29 IMPLEMENT_STANDARD_RTTIEXT(IGESSolid_Loop,IGESData_IGESEntity)
30
31 IGESSolid_Loop::IGESSolid_Loop ()    {  }
32
33
34     void  IGESSolid_Loop::Init
35   (const Handle(TColStd_HArray1OfInteger)& Types,
36    const Handle(IGESData_HArray1OfIGESEntity)& Edges,
37    const Handle(TColStd_HArray1OfInteger)& Index,
38    const Handle(TColStd_HArray1OfInteger)& Orient,
39    const Handle(TColStd_HArray1OfInteger)& nbParameterCurves,
40    const Handle(IGESBasic_HArray1OfHArray1OfInteger)& IsoparametricFlags,
41    const Handle(IGESBasic_HArray1OfHArray1OfIGESEntity)& Curves)
42 {
43   Standard_Integer nb = Types->Length();
44
45   if (Types->Lower()  != 1 ||
46       Edges->Lower()  != 1 || nb != Edges->Length()  ||
47       Index->Lower()  != 1 || nb != Index->Length()  ||
48       Orient->Lower() != 1 || nb != Orient->Length() ||
49       nbParameterCurves->Lower() != 1 || nb != nbParameterCurves->Length() ||
50       IsoparametricFlags->Lower() != 1 || nb != IsoparametricFlags->Length() ||
51       Curves->Lower() != 1 || nb != Curves->Length() )
52     throw Standard_DimensionError("IGESSolid_Loop : Init");
53
54   theTypes  = Types;
55   theEdges  = Edges;
56   theIndex  = Index;
57   theOrientationFlags   = Orient;
58   theNbParameterCurves  = nbParameterCurves;
59   theIsoparametricFlags = IsoparametricFlags;
60   theCurves = Curves;
61
62   InitTypeAndForm(508,1);
63 }
64
65     Standard_Boolean  IGESSolid_Loop::IsBound () const
66       {  return (FormNumber() == 1);  }
67
68     void  IGESSolid_Loop::SetBound (const Standard_Boolean bound)
69       {  InitTypeAndForm(508, (bound ? 1 : 0));  }
70
71
72     Standard_Integer  IGESSolid_Loop::NbEdges () const
73 {
74   //pdn 20.04.99 CTS22655 to avoid exceptions on empty loops
75   if(theEdges.IsNull()) return 0;
76   return theEdges->Length();
77 }
78
79     Standard_Integer  IGESSolid_Loop::EdgeType (const Standard_Integer Index) const
80 {
81   return theTypes->Value(Index);
82 }
83
84     Handle(IGESData_IGESEntity)  IGESSolid_Loop::Edge
85   (const Standard_Integer Index) const
86 {
87   return theEdges->Value(Index);
88 }
89
90     Standard_Boolean IGESSolid_Loop::Orientation (const Standard_Integer Index) const
91 {
92   return (theOrientationFlags->Value(Index) != 0);
93 }
94
95     Standard_Integer  IGESSolid_Loop::NbParameterCurves
96   (const Standard_Integer Index) const
97 {
98   return theNbParameterCurves->Value(Index);
99 }
100
101     Standard_Boolean  IGESSolid_Loop::IsIsoparametric
102   (const Standard_Integer EdgeIndex, const Standard_Integer CurveIndex) const
103 {
104   if (!theIsoparametricFlags->Value(EdgeIndex).IsNull()) return
105     (theIsoparametricFlags->Value(EdgeIndex)->Value(CurveIndex) != 0);
106   else return Standard_False;  // faut bien dire qq chose
107 }
108
109     Handle(IGESData_IGESEntity)  IGESSolid_Loop::ParametricCurve
110   (const Standard_Integer EdgeIndex, const Standard_Integer CurveIndex) const
111 {
112   Handle(IGESData_IGESEntity) acurve;    // par defaut sera nulle
113   if (!theCurves->Value(EdgeIndex).IsNull()) acurve =
114     theCurves->Value(EdgeIndex)->Value(CurveIndex);
115   return acurve;
116 }
117
118     Standard_Integer  IGESSolid_Loop::ListIndex (const Standard_Integer num) const
119 {
120   return theIndex->Value(num);
121 }