-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFSTD_TIN2FSTD.tcl
More file actions
106 lines (89 loc) · 2.75 KB
/
Copy pathFSTD_TIN2FSTD.tcl
File metadata and controls
106 lines (89 loc) · 2.75 KB
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
#!/bin/sh
# the next line restarts using tclsh \
exec $SPI_PATH/tclsh "$0" "$@"
#============================================================================
# Environnement Canada
# Centre Meteorologique Canadien
# 2100 Trans-Canadienne
# Dorval, Quebec
#
# Projet : Exemple de scripts.
# Fichier : FSTD_Sort.tcl
# Creation : Mars 2005 - J.P. Gauthier - CMC/CMOE
# Description: Convertir une triangulation irreguliere en champs RPN (Grille M).
# Pour visualisation dans SPI
# Aussi applicable au grille icosahedrale.
#
# Parametres :
#
# Retour:
#
# Remarques :
#
#============================================================================
package require TclData
#package require TclGeoEER
package require Logger
Log::Start [info script] 0.1
file delete -force $env(CI_DATA_OUT)/FSTD_TIN2FSTD.fstd
fstdfile open 1 write $env(CI_DATA_OUT)/FSTD_TIN2FSTD.fstd
set fnod [open [lindex $argv 0].nod r]
set fele [open [lindex $argv 0].ele r]
set fbat [open [lindex $argv 0].bat r]
#----- Triangles
Log::Print INFO "Processing Triangle meshe"
set n 0
set i -1
while { ![eof $fele] } {
gets $fele line
incr n
}
seek $fele 0
Log::Print INFO "Found $n triangles"
fstdfield create TR [expr $n*3] 1 1 UInt32
fstdfield define TR -NOMVAR ## -TYPVAR X -IP1 0 -IP2 0 -IP3 0 -GRTYP X -IG1 0 -IG2 0 -IG3 0 -IG4 0
while { ![eof $fele] } {
gets $fele line
if { $line!="" } {
fstdfield stats TR -gridvalue [incr i] 0 [expr [lindex $line 1]-1]
fstdfield stats TR -gridvalue [incr i] 0 [expr [lindex $line 2]-1]
fstdfield stats TR -gridvalue [incr i] 0 [expr [lindex $line 3]-1]
}
}
fstdfield write TR 1 -32 False
#----- Vertices
Log::Print INFO "Processing Vertices"
set n 0
while { ![eof $fnod] } {
gets $fnod line
incr n
}
seek $fnod 0
Log::Print INFO "Found $n vertices"
fstdfield create LA $n 1 1 Float32
fstdfield define LA -NOMVAR ^^ -TYPVAR X -IP1 0 -IP2 0 -IP3 0 -GRTYP L 0 0 1.0 1.0
fstdfield create LO $n 1 1 Float32
fstdfield define LO -NOMVAR >> -TYPVAR X -IP1 0 -IP2 0 -IP3 0 -GRTYP L 0 0 1.0 1.0
while { ![eof $fnod] } {
gets $fnod line
if { $line!="" } {
fstdfield stats LA -gridvalue [expr [lindex $line 0]-1] 0 [lindex $line 2]
fstdfield stats LO -gridvalue [expr [lindex $line 0]-1] 0 [lindex $line 1]
}
}
fstdfield write LA 1 -32 False
fstdfield write LO 1 -32 False
#----- Values per vertices
Log::Print INFO "Processing Values per Vertices"
fstdfield create BA $n 1 1 Float32
fstdfield define BA -NOMVAR BA -TYPVAR S -IP1 0 -IP2 0 -IP3 0 -GRTYP M
fstdfield define BA -IG1 0 -IG2 0 -IG3 0 -IG4 0
while { ![eof $fbat] } {
gets $fbat line
if { $line!="" } {
fstdfield stats BA -gridvalue [expr [lindex $line 0]-1] 0 [lindex $line 1]
}
}
fstdfield write BA 1 -32 False
fstdfile close 1
Log::End