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 <IntRes2d_Domain.hxx> |
7fd59977 |
22 | #include <Precision.hxx> |
23 | |
24 | const Standard_Real infVal = Precision::Infinite(); |
25 | |
26 | //======================================================================= |
27 | //function : LimitInfinite |
28 | //purpose : |
29 | //======================================================================= |
30 | |
31 | static inline Standard_Real LimitInfinite(const Standard_Real Val) |
32 | { |
33 | return ( Abs(Val) > infVal ? (Val>0 ? infVal : -infVal) : Val ); |
34 | } |
35 | |
36 | //======================================================================= |
37 | //function : IntRes2d_Domain |
38 | //purpose : |
39 | //======================================================================= |
40 | |
41 | IntRes2d_Domain::IntRes2d_Domain(): |
42 | status(0), |
43 | first_param(0.0), last_param(0.0), |
44 | first_tol(0.0), last_tol(0.0), |
45 | first_point(0.0, 0.0), last_point(0.0, 0.0), |
46 | periodfirst(0.0), |
47 | periodlast(0.0) { } |
48 | |
49 | |
50 | void IntRes2d_Domain::SetValues() { |
51 | status=0; |
52 | periodfirst=periodlast=0.0; |
53 | } |
54 | |
55 | //======================================================================= |
56 | //function : IntRes2d_Domain |
57 | //purpose : Creates a bounded Domain. |
58 | //======================================================================= |
59 | |
60 | IntRes2d_Domain::IntRes2d_Domain(const gp_Pnt2d& Pnt1, |
61 | const Standard_Real Par1, |
62 | const Standard_Real Tol1, |
63 | const gp_Pnt2d& Pnt2, |
64 | const Standard_Real Par2, |
65 | const Standard_Real Tol2) { |
66 | |
67 | SetValues(Pnt1,Par1,Tol1,Pnt2,Par2,Tol2); |
68 | } |
69 | |
70 | //======================================================================= |
71 | //function : SetValues |
72 | //purpose : Sets the values for a bounded domain. |
73 | //======================================================================= |
74 | |
75 | void IntRes2d_Domain::SetValues(const gp_Pnt2d& Pnt1, |
76 | const Standard_Real Par1, |
77 | const Standard_Real Tol1, |
78 | const gp_Pnt2d& Pnt2, |
79 | const Standard_Real Par2, |
80 | const Standard_Real Tol2) { |
81 | |
82 | status = 3; |
83 | periodfirst = periodlast = 0.0; |
84 | |
85 | first_param=LimitInfinite(Par1); |
86 | first_point.SetCoord( LimitInfinite(Pnt1.X()), LimitInfinite(Pnt1.Y()) ); |
87 | first_tol=Tol1; |
88 | |
89 | last_param=LimitInfinite(Par2); |
90 | last_point.SetCoord( LimitInfinite(Pnt2.X()), LimitInfinite(Pnt2.Y()) ); |
91 | last_tol=Tol2; |
92 | |
93 | } |
94 | |
95 | |
96 | |
97 | IntRes2d_Domain::IntRes2d_Domain(const gp_Pnt2d& Pnt, |
98 | const Standard_Real Par, |
99 | const Standard_Real Tol, |
100 | const Standard_Boolean First) : |
101 | first_param(0.0), last_param(0.0), |
102 | first_tol(0.0), last_tol(0.0), |
103 | first_point(0.0, 0.0), last_point(0.0, 0.0) |
104 | { |
105 | SetValues(Pnt,Par,Tol,First); |
106 | } |
107 | |
108 | void IntRes2d_Domain::SetValues(const gp_Pnt2d& Pnt, |
109 | const Standard_Real Par, |
110 | const Standard_Real Tol, |
111 | const Standard_Boolean First) { |
112 | |
113 | periodfirst=periodlast=0.0; |
114 | if(First) { |
115 | status=1; |
116 | first_param=LimitInfinite(Par); |
117 | first_point.SetCoord( LimitInfinite(Pnt.X()), LimitInfinite(Pnt.Y()) ); |
118 | first_tol=Tol; |
119 | } |
120 | else { |
121 | status=2; |
122 | last_param=LimitInfinite(Par); |
123 | last_point.SetCoord( LimitInfinite(Pnt.X()), LimitInfinite(Pnt.Y()) ); |
124 | last_tol=Tol; |
125 | } |
126 | } |
127 | |
128 | |
129 | |