File: normals.fbl

package info (click to toggle)
calculix-cgx 2.17%2Bdfsg-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bullseye
  • size: 65,048 kB
  • sloc: ansic: 99,922; cpp: 3,016; sh: 70; makefile: 35
file content (73 lines) | stat: -rw-r--r-- 1,567 bytes parent folder | download
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
# Example: Calculate normals of all free surfaces
# and write them to a new dataset
#
# read geo and mesh
read ../geometry.fbd
elty all he8i
mesh all
#
# get the number of surface nodes
seta n f all
comp n do
stack on
prnt se n
stack off
valu sum_nods pop
# calculate the normals
# and write all face-nodes to the stack (it writes them in inverse order)
stack on
norm n
stack off
#
# store the node numbers and values in array's (nod1 to nod<sum_nods>)
val n sum_nods
while n > 0
  valu cur_nod & nod n
  valu cur_val1 & val1_nod n
  valu cur_val2 & val2_nod n
  valu cur_val3 & val3_nod n
  val cur_nod pop
  val cur_val1 pop
  val cur_val2 pop
  val cur_val3 pop
  valu n - n 1
  valu n int n
endwhile
#
# create a new dataset
ds g NORMAL 3 
#
# use the 'node' command to write data to the new dataset
# REMARK: 'n' has to be masked ('\') since is is already defined as a value
val \n sum_nods
while n > 0
  valu cur_nod & nod n
  valu cur_val1 & val1_nod n
  valu cur_val2 & val2_nod n
  valu cur_val3 & val3_nod n
  # code for cgx_2.16
  val \cur_nod cur_nod
  val \cur_val1 cur_val1
  val \cur_val2 cur_val2
  val \cur_val3 cur_val3
  # code for cgx_2.15:
  #val \cur_nod + cur_nod 0
  #val \cur_val1 + cur_val1 0
  #val \cur_val2 + cur_val2 0
  #val \cur_val3 + cur_val3 0
  valu cur_nod int cur_nod
  # node cur_nod v cur_val1 cur_val2 cur_val3
  node cur_nod v cur_val1 cur_val2 cur_val3
  valu n - n 1
  valu n int n
endwhile
# set entity parameters
ds e nx 1 2 1
ds e ny 2 2 2
ds e nz 3 2 3
# finish the dataset
ds f
# show it
ds 1 e 4
plot fv all
view vec