Warnings on vc14 were eliminated
[occt.git] / src / Bisector / Bisector_PolyBis.cxx
CommitLineData
b311480e 1// Created on: 1994-01-10
2// Created by: Yves FRICAUD
3// Copyright (c) 1994-1999 Matra Datavision
973c2be1 4// Copyright (c) 1999-2014 OPEN CASCADE SAS
b311480e 5//
973c2be1 6// This file is part of Open CASCADE Technology software library.
b311480e 7//
d5f74e42 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
973c2be1 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.
b311480e 13//
973c2be1 14// Alternatively, this file may be used under the terms of Open CASCADE
15// commercial license or contractual agreement.
7fd59977 16
42cf5bc1 17
7fd59977 18#include <Bisector_PointOnBis.hxx>
42cf5bc1 19#include <Bisector_PolyBis.hxx>
7fd59977 20#include <ElCLib.hxx>
42cf5bc1 21#include <Geom2d_Curve.hxx>
7fd59977 22#include <gp.hxx>
42cf5bc1 23#include <gp_Trsf2d.hxx>
7fd59977 24#include <Standard_ConstructionError.hxx>
25
26//=============================================================================
27//function : Bisector_PolyBis
28// purpose :
29//=============================================================================
30Bisector_PolyBis::Bisector_PolyBis()
31{
32 nbPoints = 0;
33}
34
35//=============================================================================
36//function : Append
37// purpose :
38//=============================================================================
39void Bisector_PolyBis::Append (const Bisector_PointOnBis& P)
40{
41 nbPoints++;
42 thePoints [nbPoints] = P;
43}
44
45//=============================================================================
46//function : Length
47// purpose :
48//=============================================================================
49Standard_Integer Bisector_PolyBis::Length() const
50{
51 return nbPoints;
52}
53
54//=============================================================================
55//function : IsEmpty
56// purpose :
57//=============================================================================
58Standard_Boolean Bisector_PolyBis::IsEmpty() const
59{
60 return (nbPoints == 0);
61}
62
63//=============================================================================
64//function : Value
65// purpose :
66//=============================================================================
67const Bisector_PointOnBis& Bisector_PolyBis::Value
68 (const Standard_Integer Index)
69const
70{
71 return thePoints [Index];
72}
73
74//=============================================================================
75//function : First
76// purpose :
77//=============================================================================
78const Bisector_PointOnBis& Bisector_PolyBis::First() const
79{
80 return thePoints[1];
81}
82
83//=============================================================================
84//function : Last
85// purpose :
86//=============================================================================
87const Bisector_PointOnBis& Bisector_PolyBis::Last() const
88{
89 return thePoints[nbPoints];
90}
91
92//=============================================================================
93//function : Points
94// purpose :
95//=============================================================================
96//const PointOnBis& Bisector_PolyBis::Points()
97//{
98// return thePoints;
99//}
100
101//=============================================================================
102//function : Interval
103// purpose :
104//=============================================================================
105Standard_Integer Bisector_PolyBis::Interval (const Standard_Real U) const
106{
107 if ( Last().ParamOnBis() - U < gp::Resolution()) {
108 return nbPoints - 1;
109 }
110 Standard_Real dU = (Last().ParamOnBis() - First().ParamOnBis())/(nbPoints - 1);
111 if (dU <= gp::Resolution()) return 1;
112
113 Standard_Integer IntU = Standard_Integer(Abs(U - First().ParamOnBis())/dU) ;
114 IntU++;
115
116 if (thePoints[IntU].ParamOnBis() >= U) {
117 for (Standard_Integer i = IntU; i >= 1; i--) {
118 if (thePoints[i].ParamOnBis() <= U) {
119 IntU = i;
120 break;
121 }
122 }
123 }
124 else {
125 for (Standard_Integer i = IntU; i <= nbPoints - 1; i++) {
126 if (thePoints[i].ParamOnBis() >= U) {
127 IntU = i - 1;
128 break;
129 }
130 }
131 }
132 return IntU;
133}
134
135
136//=======================================================================
137//function : Transform
138//purpose :
139//=======================================================================
140
141void Bisector_PolyBis::Transform(const gp_Trsf2d& T)
142{
143 for (Standard_Integer i = 1; i <= nbPoints; i ++) {
144 gp_Pnt2d P = thePoints[i].Point();
145 P.Transform(T) ;
146 thePoints[i].Point(P);
147 }
148}