0026106: BRepMesh - revision of data model
[occt.git] / tests / bugs / mesh / bug26532
1 puts "========"
2 puts "OCC26532"
3 puts "========"
4 puts ""
5 #######################################################################
6 # Meshing of edge with minSize parameter leads to incorrect result
7 #######################################################################
8
9 proc xyzList {List N A B} {
10    set ResultList {}
11    for {set i 1} {$i <= $N} {incr i} {
12       set tmpList {}
13       set x [lindex $List [expr ($A + 0 + $B*$i) ]]
14       set y [lindex $List [expr ($A + 1 + $B*$i) ]]
15       set z [lindex $List [expr ($A + 2 + $B*$i) ]]
16       #puts "i=$i x=$x y=$y z=$z"
17       lappend tmpList $x
18       lappend tmpList $y
19       lappend tmpList $z
20       lappend ResultList $tmpList
21    }
22    return $ResultList
23 }
24
25 restore [locate_data_file bug26533_aal2.brep] a
26
27 vinit
28 vdisplay a
29 vfit
30 vdump ${imagedir}/${casename}_1.png
31
32 # 1
33 # with min size
34 # => ugly curve
35 vclear
36 incmesh a 0.3 -min 0.06
37 vdisplay a
38 vdump ${imagedir}/${casename}_2.png
39
40 set log1 [dump a]
41
42 regexp {Polygon3D with +([-0-9.+eE]+)} $log1 full Nodes1
43
44 set Index1 [lsearch -exact $log1 "Polygon3D"]
45 set Index1 [expr ($Index1 + 8)]
46 set B 5
47
48 set RL1 [xyzList $log1 $Nodes1 $Index1 $B]
49 set Length1 [llength $RL1]
50
51 # 2
52 # without min size
53 # => nice curve
54 restore [locate_data_file bug26533_aal2.brep] a2
55 vdisplay a2
56 vclear
57 incmesh a2 0.3
58 vdisplay a2
59 vdump ${imagedir}/${casename}_3.png
60
61 set log2 [dump a2]
62
63 regexp {Polygon3D with +([-0-9.+eE]+)} $log2 full Nodes2
64
65 set Index2 [lsearch -exact $log2 "Polygon3D"]
66 set Index2 [expr ($Index2 + 8)]
67
68 set RL2 [xyzList $log2 $Nodes2 $Index2 $B]
69 set Length2 [llength $RL2]
70
71 # 3. Compare coordinates of Polygon3Dare
72
73 set Tolerance 1.0e-07
74
75 if {$Length1 != $Length2} {
76    puts "Error: Numbers of nodes are not equal"
77 } else {
78    puts "OK: Numbers of nodes are equal"
79    set xyzBad 0
80    for {set i 0} {$i < $Length1} {incr i} {
81       set tmpList1 [lindex $RL1 $i]
82       set x1 [lindex $tmpList1 0]
83       set y1 [lindex $tmpList1 1]
84       set z1 [lindex $tmpList1 2]
85       #puts "x1=$x1 y1=$y1 z1=$z1"
86
87       set tmpList2 [lindex $RL2 $i]
88       set x2 [lindex $tmpList2 0]
89       set y2 [lindex $tmpList2 1]
90       set z2 [lindex $tmpList2 2]
91       #puts "x2=$x2 y2=$y2 z2=$z2"
92
93       set xBad 0
94       set yBad 0
95       set zBad 0
96
97       if { [expr abs($x1 - $x2)] > $Tolerance } {
98          set xBad 1
99       }
100       if { [expr abs($y1 - $y2)] > $Tolerance } {
101          set yBad 1
102       }
103       if { [expr abs($z1 - $z2)] > $Tolerance } {
104          set zBad 1
105       }
106       if { $xBad !=0 && $yBad !=0 && $zBad !=0 } {
107          set xyzBad 1
108          set j [expr ($i + 1)] 
109          puts "Following coordinates are not equal:"
110          puts "i=$j x1=$x1 y1=$y1 z1=$z1"
111          puts "i=$j x2=$x2 y2=$y2 z2=$z2"
112          break
113       }
114
115    }
116    if { $xyzBad !=0 } {
117       puts "Error: Coordinates of Polygon3Dare are not equal"
118    } else {
119       puts "OK: Coordinates of Polygon3Dare are equal"
120    }
121 }