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
119
120
121
122
123
124
125
126
127
128
129
130
131
132
|
*DECK NXTIRR
FUNCTION NXTIRR(XYCAR ,XYPIN ,VOLINT)
*
*----------
*
*Purpose:
* Compute the volume of intersection between
* a rectangular region and a Cartesian pin.
* centered at the origin.
*
*Copyright:
* Copyright (C) 2005 Ecole Polytechnique de Montreal
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
*Author(s): G. Marleau.
*
*Parameters: input
* XYCAR spatial description of the Cartesian region with:
* XYCAR(1) for left face; XYCAR(2) for right face;
* XYCAR(3) for bottom face, XYCAR(4) for top face
* positions.
* XYPIN spatial description of the Cartesian pin region with
* XYPIN(1) for left face; XYPIN(2) for right face;
* XYPIN(3) for bottom face; XYPIN(4) for top face
* positions.
*
*Parameters: output
* NXTIRR type of intersection between Cartesian region and
* annular pin or annular region and Cartesian pin, where:
* =0 means that there is no intersection
* between the two regions;
* = 1 means that the Cartesian region
* is all located inside the Cartesian pin;
* = 2 means that the Cartesian pin
* is all located inside the Cartesian region;
* =-1 means that the intersection between
* the Cartesian region and the Cartesian pin is partial.
* VOLINT 2-D volume of intersection (area) between Cartesian region and
* Cartesian pin.
*
*Reference:
* G. Marleau,
* New Geometries Processing in DRAGON: The NXT: Module,
* Report IGE-260, Polytechnique Montreal,
* Montreal, 2005.
*
*----
*
IMPLICIT NONE
*----
* Subroutine arguments
*----
INTEGER NXTIRR
DOUBLE PRECISION XYCAR(4),XYPIN(4)
DOUBLE PRECISION VOLINT
*----
* Local parameters
*----
INTEGER IOUT
CHARACTER NAMSBR*6
PARAMETER (IOUT=6,NAMSBR='NXTIRR')
INTEGER IPRINT
PARAMETER (IPRINT=100)
DOUBLE PRECISION DCUTOF
PARAMETER (DCUTOF=1.0D-8)
DOUBLE PRECISION DZERO
PARAMETER (DZERO=0.0D0)
*----
* Functions
*----
INTEGER NXTPRR,ITYPRR
*----
* Local variables
*----
INTEGER IFACE
DOUBLE PRECISION VOLCAR,VOLPIN,XYINT(4)
DOUBLE PRECISION DT1,DT2,DT3
*----
* Initialize NXTIRR and VOLINT
*----
IF(IPRINT .GE. 200) THEN
WRITE(IOUT,6000) NAMSBR
WRITE(IOUT,6010) (XYCAR(IFACE),IFACE=1,4)
WRITE(IOUT,6011) (XYPIN(IFACE),IFACE=1,4)
ENDIF
NXTIRR=0
VOLINT=DZERO
VOLCAR=(XYCAR(2)-XYCAR(1))*(XYCAR(4)-XYCAR(3))
VOLPIN=(XYPIN(2)-XYPIN(1))*(XYPIN(4)-XYPIN(3))
*----
* Find rectangle of intersection between the two rectangles.
*----
ITYPRR=NXTPRR(XYCAR ,XYPIN ,XYINT )
*----
* For cases with intersection, compute volume of intersection
* and type of intersection
*----
IF(ITYPRR .NE. 0) THEN
VOLINT=(XYINT(2)-XYINT(1))*(XYINT(4)-XYINT(3))
DT1=ABS(VOLINT-VOLPIN)
DT2=ABS(VOLINT-VOLCAR)
DT3=ABS(VOLINT)
IF(DT1 .LT. DCUTOF) THEN
VOLINT=VOLPIN
NXTIRR=2
ELSE IF(DT2 .LT. DCUTOF) THEN
VOLINT=VOLCAR
NXTIRR=1
ELSE IF(DT3 .LT. DCUTOF) THEN
VOLINT=DZERO
NXTIRR=0
ELSE
NXTIRR=-1
ENDIF
ENDIF
IF(IPRINT .GE. 200) THEN
WRITE(IOUT,6012) NAMSBR,NXTIRR,VOLINT
WRITE(IOUT,6001) NAMSBR
ENDIF
RETURN
*----
* Output formats
*----
6000 FORMAT('(* Output from --',A6,'-- follows ')
6001 FORMAT(' Output from --',A6,'-- completed *)')
6010 FORMAT('XYCAR ={',3(F20.10,','),F20.10,'};')
6011 FORMAT('XYPIN ={',3(F20.10,','),F20.10,'};')
6012 FORMAT(A6,'={',I5,',',F20.10,'};')
END
|