summaryrefslogtreecommitdiff
path: root/src/IntRes2d/IntRes2d_Domain.cxx
blob: 9b064f372de36852e43ac1ef29ecf744a7b149d1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
// File:	IntRes2d_Domain.cxx
// Created:	Wed Jun 10 15:06:44 1992
// Author:	Laurent BUCHARD
//		<lbr@sdsun2>

//  modified by Edward AGAPOV (eap)  Jun 7 2002 (occ 438)
//  --- limit infinite points and parameters in order to make
//  --- arithmetic operation on them safe 

#include <IntRes2d_Domain.ixx>
#include <Precision.hxx>

const Standard_Real infVal = Precision::Infinite();

//=======================================================================
//function : LimitInfinite
//purpose  : 
//=======================================================================

static inline Standard_Real LimitInfinite(const Standard_Real Val)
{
  return ( Abs(Val) > infVal ? (Val>0 ? infVal : -infVal) : Val );
}

//=======================================================================
//function : IntRes2d_Domain
//purpose  : 
//=======================================================================

IntRes2d_Domain::IntRes2d_Domain(): 
       status(0),
       first_param(0.0), last_param(0.0),
       first_tol(0.0), last_tol(0.0),
       first_point(0.0, 0.0), last_point(0.0, 0.0),
       periodfirst(0.0),
       periodlast(0.0) { } 


void IntRes2d_Domain::SetValues() {
  status=0;
  periodfirst=periodlast=0.0;
}

//=======================================================================
//function : IntRes2d_Domain
//purpose  : Creates a bounded Domain.
//=======================================================================

IntRes2d_Domain::IntRes2d_Domain(const gp_Pnt2d& Pnt1,
				 const Standard_Real Par1,
				 const Standard_Real Tol1,
				 const gp_Pnt2d& Pnt2,
				 const Standard_Real Par2,
				 const Standard_Real Tol2) {

  SetValues(Pnt1,Par1,Tol1,Pnt2,Par2,Tol2);
}

//=======================================================================
//function : SetValues
//purpose  : Sets the values for a bounded domain.
//=======================================================================

void IntRes2d_Domain::SetValues(const gp_Pnt2d& Pnt1,
				const Standard_Real Par1,
				const Standard_Real Tol1,
				const gp_Pnt2d& Pnt2,
				const Standard_Real Par2,
				const Standard_Real Tol2) {

  status = 3;
  periodfirst = periodlast = 0.0;

  first_param=LimitInfinite(Par1);
  first_point.SetCoord( LimitInfinite(Pnt1.X()), LimitInfinite(Pnt1.Y()) );
  first_tol=Tol1;

  last_param=LimitInfinite(Par2);
  last_point.SetCoord( LimitInfinite(Pnt2.X()), LimitInfinite(Pnt2.Y()) );
  last_tol=Tol2;

}



IntRes2d_Domain::IntRes2d_Domain(const gp_Pnt2d& Pnt,
				 const Standard_Real Par,
				 const Standard_Real Tol,
				 const Standard_Boolean First) :
       first_param(0.0), last_param(0.0),
       first_tol(0.0), last_tol(0.0),
       first_point(0.0, 0.0), last_point(0.0, 0.0)
{
  SetValues(Pnt,Par,Tol,First);
}

void IntRes2d_Domain::SetValues(const gp_Pnt2d& Pnt,
				const Standard_Real Par,
				const Standard_Real Tol,
				const Standard_Boolean First) {
  
  periodfirst=periodlast=0.0;
  if(First) {
    status=1;
    first_param=LimitInfinite(Par);
    first_point.SetCoord( LimitInfinite(Pnt.X()), LimitInfinite(Pnt.Y()) );
    first_tol=Tol;
  }
  else {
    status=2;
    last_param=LimitInfinite(Par);
    last_point.SetCoord( LimitInfinite(Pnt.X()), LimitInfinite(Pnt.Y()) );
    last_tol=Tol;
  }
}