1 // Created on: 1992-06-10
2 // Created by: Laurent BUCHARD
3 // Copyright (c) 1992-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.
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
21 #include <gp_Pnt2d.hxx>
22 #include <IntRes2d_Domain.hxx>
23 #include <Precision.hxx>
24 #include <Standard_DomainError.hxx>
26 const Standard_Real infVal = Precision::Infinite();
28 //=======================================================================
29 //function : LimitInfinite
31 //=======================================================================
33 static inline Standard_Real LimitInfinite(const Standard_Real Val)
35 return ( Abs(Val) > infVal ? (Val>0 ? infVal : -infVal) : Val );
38 //=======================================================================
39 //function : IntRes2d_Domain
41 //=======================================================================
43 IntRes2d_Domain::IntRes2d_Domain():
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),
52 void IntRes2d_Domain::SetValues() {
54 periodfirst=periodlast=0.0;
57 //=======================================================================
58 //function : IntRes2d_Domain
59 //purpose : Creates a bounded Domain.
60 //=======================================================================
62 IntRes2d_Domain::IntRes2d_Domain(const gp_Pnt2d& Pnt1,
63 const Standard_Real Par1,
64 const Standard_Real Tol1,
66 const Standard_Real Par2,
67 const Standard_Real Tol2) {
69 SetValues(Pnt1,Par1,Tol1,Pnt2,Par2,Tol2);
72 //=======================================================================
73 //function : SetValues
74 //purpose : Sets the values for a bounded domain.
75 //=======================================================================
77 void IntRes2d_Domain::SetValues(const gp_Pnt2d& Pnt1,
78 const Standard_Real Par1,
79 const Standard_Real Tol1,
81 const Standard_Real Par2,
82 const Standard_Real Tol2) {
85 periodfirst = periodlast = 0.0;
87 first_param=LimitInfinite(Par1);
88 first_point.SetCoord( LimitInfinite(Pnt1.X()), LimitInfinite(Pnt1.Y()) );
91 last_param=LimitInfinite(Par2);
92 last_point.SetCoord( LimitInfinite(Pnt2.X()), LimitInfinite(Pnt2.Y()) );
99 IntRes2d_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)
107 SetValues(Pnt,Par,Tol,First);
110 void IntRes2d_Domain::SetValues(const gp_Pnt2d& Pnt,
111 const Standard_Real Par,
112 const Standard_Real Tol,
113 const Standard_Boolean First) {
115 periodfirst=periodlast=0.0;
118 first_param=LimitInfinite(Par);
119 first_point.SetCoord( LimitInfinite(Pnt.X()), LimitInfinite(Pnt.Y()) );
124 last_param=LimitInfinite(Par);
125 last_point.SetCoord( LimitInfinite(Pnt.X()), LimitInfinite(Pnt.Y()) );