0030416: Incorrect implementation of the method Bnd_OBB::SquareExtent
[occt.git] / src / IntRes2d / IntRes2d_Domain.cxx
CommitLineData
b311480e 1// Created on: 1992-06-10
2// Created by: Laurent BUCHARD
3// Copyright (c) 1992-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
17// modified by Edward AGAPOV (eap) Jun 7 2002 (occ 438)
18// --- limit infinite points and parameters in order to make
19// --- arithmetic operation on them safe
20
42cf5bc1 21#include <gp_Pnt2d.hxx>
22#include <IntRes2d_Domain.hxx>
7fd59977 23#include <Precision.hxx>
42cf5bc1 24#include <Standard_DomainError.hxx>
7fd59977 25
26const Standard_Real infVal = Precision::Infinite();
27
28//=======================================================================
29//function : LimitInfinite
30//purpose :
31//=======================================================================
32
33static inline Standard_Real LimitInfinite(const Standard_Real Val)
34{
35 return ( Abs(Val) > infVal ? (Val>0 ? infVal : -infVal) : Val );
36}
37
38//=======================================================================
39//function : IntRes2d_Domain
40//purpose :
41//=======================================================================
42
43IntRes2d_Domain::IntRes2d_Domain():
44 status(0),
45 first_param(0.0), last_param(0.0),
46 first_tol(0.0), last_tol(0.0),
47 first_point(0.0, 0.0), last_point(0.0, 0.0),
48 periodfirst(0.0),
49 periodlast(0.0) { }
50
51
52void IntRes2d_Domain::SetValues() {
53 status=0;
54 periodfirst=periodlast=0.0;
55}
56
57//=======================================================================
58//function : IntRes2d_Domain
59//purpose : Creates a bounded Domain.
60//=======================================================================
61
62IntRes2d_Domain::IntRes2d_Domain(const gp_Pnt2d& Pnt1,
63 const Standard_Real Par1,
64 const Standard_Real Tol1,
65 const gp_Pnt2d& Pnt2,
66 const Standard_Real Par2,
67 const Standard_Real Tol2) {
68
69 SetValues(Pnt1,Par1,Tol1,Pnt2,Par2,Tol2);
70}
71
72//=======================================================================
73//function : SetValues
74//purpose : Sets the values for a bounded domain.
75//=======================================================================
76
77void IntRes2d_Domain::SetValues(const gp_Pnt2d& Pnt1,
78 const Standard_Real Par1,
79 const Standard_Real Tol1,
80 const gp_Pnt2d& Pnt2,
81 const Standard_Real Par2,
82 const Standard_Real Tol2) {
83
84 status = 3;
85 periodfirst = periodlast = 0.0;
86
87 first_param=LimitInfinite(Par1);
88 first_point.SetCoord( LimitInfinite(Pnt1.X()), LimitInfinite(Pnt1.Y()) );
89 first_tol=Tol1;
90
91 last_param=LimitInfinite(Par2);
92 last_point.SetCoord( LimitInfinite(Pnt2.X()), LimitInfinite(Pnt2.Y()) );
93 last_tol=Tol2;
94
95}
96
97
98
99IntRes2d_Domain::IntRes2d_Domain(const gp_Pnt2d& Pnt,
100 const Standard_Real Par,
101 const Standard_Real Tol,
102 const Standard_Boolean First) :
103 first_param(0.0), last_param(0.0),
104 first_tol(0.0), last_tol(0.0),
105 first_point(0.0, 0.0), last_point(0.0, 0.0)
106{
107 SetValues(Pnt,Par,Tol,First);
108}
109
110void IntRes2d_Domain::SetValues(const gp_Pnt2d& Pnt,
111 const Standard_Real Par,
112 const Standard_Real Tol,
113 const Standard_Boolean First) {
114
115 periodfirst=periodlast=0.0;
116 if(First) {
117 status=1;
118 first_param=LimitInfinite(Par);
119 first_point.SetCoord( LimitInfinite(Pnt.X()), LimitInfinite(Pnt.Y()) );
120 first_tol=Tol;
121 }
122 else {
123 status=2;
124 last_param=LimitInfinite(Par);
125 last_point.SetCoord( LimitInfinite(Pnt.X()), LimitInfinite(Pnt.Y()) );
126 last_tol=Tol;
127 }
128}
129
130
131