0025465: Excess vertex in the result of CUT operation
[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& Pnt)
23 {
24   svtx.Append(Pnt);
25 }
26
27 inline void IntPatch_WLine::Replace (const Standard_Integer Index,
28                                      const IntPatch_Point& Pnt)
29 {
30   svtx(Index) = Pnt;
31 }
32
33 inline void IntPatch_WLine::SetFirstPoint (const Standard_Integer IndFirst)
34 {
35   fipt = Standard_True;
36   indf = IndFirst;
37 }
38
39 inline void IntPatch_WLine::SetLastPoint (const Standard_Integer IndLast)
40 {
41   lapt = Standard_True;
42   indl = IndLast;
43 }
44
45 inline Standard_Integer IntPatch_WLine::NbPnts () const
46 {
47   return curv->NbPoints();
48 }
49
50 inline const IntSurf_PntOn2S& IntPatch_WLine::Point (const Standard_Integer Index) const
51 {
52   return curv->Value(Index);
53 }
54
55 inline Standard_Boolean IntPatch_WLine::HasFirstPoint () const
56 {
57   return fipt;
58 }
59
60 inline Standard_Boolean IntPatch_WLine::HasLastPoint () const
61 {
62   return lapt;
63 }
64
65 inline const IntPatch_Point& IntPatch_WLine::FirstPoint () const
66 {
67   if (!fipt) {Standard_DomainError::Raise();}
68   return svtx(indf);
69 }
70
71 inline const IntPatch_Point& IntPatch_WLine::LastPoint () const
72 {
73   if (!lapt) {Standard_DomainError::Raise();}
74   return svtx(indl);
75 }
76
77 inline const IntPatch_Point& IntPatch_WLine::FirstPoint (Standard_Integer& Indfirst) const
78 {
79   if (!fipt) {Standard_DomainError::Raise();}
80   Indfirst = indf;
81   return svtx(indf);
82 }
83
84 inline const IntPatch_Point& IntPatch_WLine::LastPoint (Standard_Integer& Indlast) const
85 {
86   if (!lapt) {Standard_DomainError::Raise();}
87   Indlast = indl;
88   return svtx(indl);
89 }
90
91 inline Standard_Integer IntPatch_WLine::NbVertex () const
92 {
93   return svtx.Length();
94 }
95
96 inline const IntPatch_Point& IntPatch_WLine::Vertex (const Standard_Integer Index) const
97 {
98   return svtx(Index);
99 }
100
101 inline void IntPatch_WLine::ClearVertexes()
102 {
103   svtx.Clear();
104 }
105
106 inline void IntPatch_WLine::RemoveVertex(const Standard_Integer theIndex)
107 {
108   if((theIndex < 1) || (theIndex > NbVertex()))
109     Standard_OutOfRange::Raise("Cannot delete not existing vertex");
110   svtx.Remove(theIndex);
111 }
112
113 inline void IntPatch_WLine::InsertVertexBefore( const Standard_Integer theIndex,
114                                                 const IntPatch_Point& thePnt)
115 {
116   const Standard_Integer aNbVertexes = NbVertex();
117   Standard_Integer anIndex = Max(theIndex, 1);
118
119   if(anIndex > aNbVertexes)
120     svtx.Append(thePnt);
121   else
122     svtx.InsertBefore(theIndex, thePnt);
123 }