0027780: Face-face intersection produces 2D curve that has reversed derivative at...
[occt.git] / src / IntPatch / IntPatch_WLine.lxx
1 // Created on: 1991-05-27
2 // Created by: Isabelle GRIGNON
3 // Copyright (c) 1991-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 #include <Standard_DomainError.hxx>
18 #include <IntSurf_LineOn2S.hxx>
19 #include <IntPatch_Point.hxx>
20
21
22 inline void IntPatch_WLine::AddVertex (const IntPatch_Point& thePnt,
23                                        const Standard_Boolean theIsPrepend)
24 {
25   if(theIsPrepend)
26     svtx.Prepend(thePnt);
27   else
28     svtx.Append(thePnt);
29 }
30
31 inline void IntPatch_WLine::Replace (const Standard_Integer Index,
32                                      const IntPatch_Point& Pnt)
33 {
34   svtx(Index) = Pnt;
35 }
36
37 inline void IntPatch_WLine::SetFirstPoint (const Standard_Integer IndFirst)
38 {
39   fipt = Standard_True;
40   indf = IndFirst;
41 }
42
43 inline void IntPatch_WLine::SetLastPoint (const Standard_Integer IndLast)
44 {
45   lapt = Standard_True;
46   indl = IndLast;
47 }
48
49 inline Standard_Integer IntPatch_WLine::NbPnts () const
50 {
51   return curv->NbPoints();
52 }
53
54 inline const IntSurf_PntOn2S& IntPatch_WLine::Point (const Standard_Integer Index) const
55 {
56   return curv->Value(Index);
57 }
58
59 inline Standard_Boolean IntPatch_WLine::HasFirstPoint () const
60 {
61   return fipt;
62 }
63
64 inline Standard_Boolean IntPatch_WLine::HasLastPoint () const
65 {
66   return lapt;
67 }
68
69 inline const IntPatch_Point& IntPatch_WLine::FirstPoint () const
70 {
71   if (!fipt) {Standard_DomainError::Raise();}
72   return svtx(indf);
73 }
74
75 inline const IntPatch_Point& IntPatch_WLine::LastPoint () const
76 {
77   if (!lapt) {Standard_DomainError::Raise();}
78   return svtx(indl);
79 }
80
81 inline const IntPatch_Point& IntPatch_WLine::FirstPoint (Standard_Integer& Indfirst) const
82 {
83   if (!fipt) {Standard_DomainError::Raise();}
84   Indfirst = indf;
85   return svtx(indf);
86 }
87
88 inline const IntPatch_Point& IntPatch_WLine::LastPoint (Standard_Integer& Indlast) const
89 {
90   if (!lapt) {Standard_DomainError::Raise();}
91   Indlast = indl;
92   return svtx(indl);
93 }
94
95 inline Standard_Integer IntPatch_WLine::NbVertex () const
96 {
97   return svtx.Length();
98 }
99
100 inline const IntPatch_Point& IntPatch_WLine::Vertex (const Standard_Integer Index) const
101 {
102   return svtx(Index);
103 }
104
105 inline IntPatch_Point& IntPatch_WLine::ChangeVertex (const Standard_Integer Index)
106 {
107   return svtx(Index);
108 }
109
110 inline void IntPatch_WLine::ClearVertexes()
111 {
112   svtx.Clear();
113 }
114
115 inline void IntPatch_WLine::RemoveVertex(const Standard_Integer theIndex)
116 {
117   if((theIndex < 1) || (theIndex > NbVertex()))
118     Standard_OutOfRange::Raise("Cannot delete not existing vertex");
119   svtx.Remove(theIndex);
120 }
121
122 inline void IntPatch_WLine::InsertVertexBefore( const Standard_Integer theIndex,
123                                                 const IntPatch_Point& thePnt)
124 {
125   const Standard_Integer aNbVertexes = NbVertex();
126   Standard_Integer anIndex = Max(theIndex, 1);
127
128   if(anIndex > aNbVertexes)
129     svtx.Append(thePnt);
130   else
131     svtx.InsertBefore(theIndex, thePnt);
132 }