OpenRadioss 2025.1.11
OpenRadioss project
Loading...
Searching...
No Matches
vw_smooth.F File Reference
#include "implicit_f.inc"

Go to the source code of this file.

Functions/Subroutines

subroutine vw_smooth (npt, ntarget, x, y)

Function/Subroutine Documentation

◆ vw_smooth()

subroutine vw_smooth ( integer, intent(inout) npt,
integer, intent(in) ntarget,
intent(inout) x,
intent(inout) y )

Definition at line 29 of file vw_smooth.F.

30C-----------------------------------------------
31C I m p l i c i t T y p e s
32C-----------------------------------------------
33#include "implicit_f.inc"
34C-----------------------------------------------
35 INTEGER ,INTENT(INOUT) :: NPT ! number of input function points
36 INTEGER ,INTENT(IN) :: NTARGET ! target length of abscissa vector
37 my_real ,DIMENSION(NPT) ,INTENT(INOUT) :: x,y
38C-----------------------------------------------
39C L o c a l V a r i a b l e s
40C-----------------------------------------------
41 INTEGER :: I,I0,I1,I2,IDX,IMIN,IPREV,INEXT,ITER,NITER,IZERO
42 my_real :: amin,aa,s,t
43 INTEGER ,DIMENSION(NPT) :: PREV,NEXT
44 my_real ,DIMENSION(NPT) :: area
45c-----------------------------------------------
46c smooth input curve using Visvalingam-Whyatt algorithm
47c reduce number of points from NPT to NTARGET
48c first and last points are never eliminated, as well as (0,0)
49c=======================================================================
50 niter = npt - ntarget
51 IF (niter < 1) RETURN
52
53 prev(1) = 0
54 next(1) = 2
55 area(1) = infinity / ten
56 prev(npt) = npt - 1
57 next(npt) = 10000000
58 area(npt) = infinity / ten
59c
60 DO i = 2,npt-1
61 i1 = i-1
62 i2 = i+1
63 prev(i) = i1
64 next(i) = i2
65 IF (x(i) == zero .and. y(i) == zero) THEN
66 area(i) = infinity / ten
67 ELSE
68 area(i) = x(i1)*y(i) + x(i)*y(i2) + x(i2)*y(i1)
69 . - x(i1)*y(i2) - x(i)*y(i1) - x(i2)*y(i)
70 area(i) = abs(area(i))
71 END IF
72 END DO
73c----------------------------------------------------
74c eliminate points with min area until NPT = target number of points
75c----------------------------------------------------
76 imin = 1
77 DO iter = 1,niter
78 amin = infinity
79 idx = 1
80 DO i=1,npt
81 IF (area(i) < amin) THEN
82 amin = area(i)
83 imin = i
84 ENDIF
85 END DO
86c
87 iprev = prev(imin)
88 inext = next(imin)
89 next(iprev) = inext
90 prev(inext) = iprev
91 area(imin) = infinity
92c
93 ! recalculate PREV POINT AREA
94 i0 = iprev
95 i1 = prev(iprev)
96 i2 = inext
97 IF (i1 > 0) THEN
98 aa = x(i0)*y(i0) + x(i0)*y(i2) + x(i2)*y(i1)
99 . - x(i0)*y(i2) - x(i0)*y(i1) - x(i2)*y(i0)
100 area(i0) = abs(aa)
101 END IF
102c
103 ! recalculate NEXT POINT AREA
104 i0 = inext
105 i1 = iprev
106 i2 = next(inext)
107 IF (i2 < npt) THEN
108 aa = x(i0)*y(i0) + x(i0)*y(i2) + x(i2)*y(i1)
109 . - x(i0)*y(i2) - x(i0)*y(i1) - x(i2)*y(i0)
110 area(i0) = abs(aa)
111 END IF
112 END DO ! ITER
113c------------
114 idx = 0
115 DO i=1,npt
116 IF (area(i) < infinity) THEN
117 idx = idx + 1
118 x(idx) = x(i)
119 y(idx) = y(i)
120 END IF
121 END DO
122 npt = 0
123 izero = 0
124 DO i = 1,idx
125 s = x(i)
126 t = y(i)
127 IF (s < zero .and. t > zero .or.
128 . s > zero .and. t < zero .or.
129 . s == zero .and. t /= zero) THEN
130 IF (izero == 1) CONTINUE
131 s = zero
132 t = zero
133 izero = 1
134 ELSE IF (s < zero .and. t < zero .and.
135 . x(i+1) > zero .and. y(i+1) > zero) THEN ! .or.
136! . S > ZERO .and. T > ZERO .and.
137! . X(I-1) < ZERO .and. Y(I-1) < ZERO .and. I > 1) THEN
138 IF (izero == 1) CONTINUE
139 s = zero
140 t = zero
141 izero = 1
142 END IF
143 npt = npt + 1
144 x(npt) = s
145 y(npt) = t
146 END DO
147c-----------
148 RETURN
#define my_real
Definition cppsort.cpp:32
subroutine area(d1, x, x2, y, y2, eint, stif0)