1 // Created on: 1991-06-21
2 // Created by: Didier PIFFAULT
3 // Copyright (c) 1991-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 <Intf_SectionLine.hxx>
19 #include <Intf_SectionPoint.hxx>
20 #include <Standard_OutOfRange.hxx>
22 //=======================================================================
23 //function : Intf_SectionLine
25 //=======================================================================
26 Intf_SectionLine::Intf_SectionLine ()
27 : closed(Standard_False)
30 //=======================================================================
31 //function : Intf_SectionLine
33 //=======================================================================
35 Intf_SectionLine::Intf_SectionLine (const Intf_SectionLine& Other)
36 : closed(Standard_False)
38 myPoints=Other.myPoints;
42 //=======================================================================
45 //=======================================================================
47 void Intf_SectionLine::Append (const Intf_SectionPoint& Pi)
52 //=======================================================================
55 //=======================================================================
57 void Intf_SectionLine::Append (Intf_SectionLine& LS)
59 myPoints.Append(LS.myPoints);
62 //=======================================================================
65 //=======================================================================
67 void Intf_SectionLine::Prepend (const Intf_SectionPoint& Pi)
72 //=======================================================================
75 //=======================================================================
77 void Intf_SectionLine::Prepend (Intf_SectionLine& LS)
79 myPoints.Prepend(LS.myPoints);
82 //=======================================================================
85 //=======================================================================
87 void Intf_SectionLine::Reverse ()
92 //=======================================================================
95 //=======================================================================
97 void Intf_SectionLine::Close ()
103 //=======================================================================
104 //function : GetPoint
106 //=======================================================================
108 const Intf_SectionPoint& Intf_SectionLine::GetPoint
109 (const Standard_Integer index) const
111 return myPoints.Value(index);
115 //=======================================================================
116 //function : IsClosed
118 //=======================================================================
120 Standard_Boolean Intf_SectionLine::IsClosed () const
123 // On ne peut fermer une ligne de section inseree dans une liste car
124 // la fonction Value() copie l'element avant d'appeler la fonction.
125 // C'est donc la copie qui est modifiee.
126 // Pour la sequence myPoints on a un pointeur donc le pb ne se pose pas.
128 return (myPoints.First()==myPoints.Last());
131 //=======================================================================
132 //function : Contains
134 //=======================================================================
136 Standard_Boolean Intf_SectionLine::Contains
137 (const Intf_SectionPoint& ThePI) const
139 for (Standard_Integer i = 1; i <= myPoints.Length();i++)
140 if (ThePI.IsEqual(myPoints(i))) return Standard_True;
141 return Standard_False;
145 //=======================================================================
148 //=======================================================================
150 Standard_Integer Intf_SectionLine::IsEnd
151 (const Intf_SectionPoint& ThePI) const
153 if (myPoints.First().IsEqual(ThePI)) return 1;
154 if (myPoints.Last().IsEqual(ThePI)) return myPoints.Length();
159 //=======================================================================
162 //=======================================================================
164 Standard_Boolean Intf_SectionLine::IsEqual
165 (const Intf_SectionLine& Other) const
167 if (myPoints.Length() != Other.myPoints.Length())
168 return Standard_False;
169 for (Standard_Integer i = 1; i <= myPoints.Length(); i++)
170 if (!myPoints(i).IsEqual(Other.myPoints(i))) return Standard_False;
171 return Standard_True;
174 //=======================================================================
177 //=======================================================================
179 void Intf_SectionLine::Dump
180 (const Standard_Integer Indent) const
182 for (Standard_Integer id=0; id<Indent; id++) std::cout << " ";
184 if (IsClosed()) std::cout << "Closed :" << std::endl;
185 else std::cout << "Open :" << std::endl;
186 for (Standard_Integer p=1; p<=myPoints.Length(); p++) {
187 myPoints.Value(p).Dump(Indent+2);