0023473: Top face of imported STEP part is missing
authorepa <epa@opencascade.com>
Thu, 15 Nov 2012 12:37:23 +0000 (16:37 +0400)
committerepa <epa@opencascade.com>
Thu, 15 Nov 2012 12:37:23 +0000 (16:37 +0400)
Fix for constraints for case of complex internal wires
Test case for this bug

src/BRepMesh/BRepMesh_Delaun.cxx
tests/bugs/grids.list
tests/bugs/mesh/begin [new file with mode: 0755]
tests/bugs/mesh/bug23473 [new file with mode: 0755]
tests/bugs/mesh/end [new file with mode: 0644]

index 7f8f31a..3e448c6 100755 (executable)
@@ -828,9 +828,9 @@ void BRepMesh_Delaun::RemovePivotTriangles( const Standard_Integer theEdgeInfo,
         {
           if ( e1[i] == anOldEdge )
           {
-            for ( Standard_Integer i = 0; i < 2; ++i )
-            {
-              Standard_Integer aTmpEdgeId = e1[(i + 1) % 3];
+            for ( Standard_Integer j = 0; j < 2; ++j )
+            {              
+              Standard_Integer aTmpEdgeId = e1[(j + i + 1) % 3];
               const BRepMesh_Edge& anEdge = GetEdge( aTmpEdgeId );
               if ( anEdge.FirstNode() == thePivotNode || 
                    anEdge.LastNode()  == thePivotNode )
index 830d365..2482b74 100755 (executable)
@@ -7,5 +7,4 @@
 007 moddata
 008 step
 009 caf
-
-
+010 mesh
diff --git a/tests/bugs/mesh/begin b/tests/bugs/mesh/begin
new file mode 100755 (executable)
index 0000000..5d6a7d4
--- /dev/null
@@ -0,0 +1,29 @@
+set Deflection 0.1
+set percent_max 5.
+
+# relative tolerance (%)
+set rel_tol 1
+
+set area_eps 0
+
+cpulimit 1000
+
+set nbwithouttri(All) 0
+set nbfree(All) 0
+set nbcross(All) 0
+set nbasync(All) 0
+set nbfreenodes(All) 0
+
+set bug_area ""
+set bug_withouttri ""
+set bug_freelinks ""
+set bug_cross ""
+set bug_async ""
+set bug_freenodes ""
+
+if { [array get Draw_Groups "TOPOLOGY Check commands"] == "" } {
+       pload TOPTEST
+}
+if { [array get Draw_Groups "ZeViewer"] == "" } {
+       pload AISV
+}
diff --git a/tests/bugs/mesh/bug23473 b/tests/bugs/mesh/bug23473
new file mode 100755 (executable)
index 0000000..e136872
--- /dev/null
@@ -0,0 +1,3 @@
+set TheFileName bug23473_Scheibe_1_f867.brep
+
+set command shading
diff --git a/tests/bugs/mesh/end b/tests/bugs/mesh/end
new file mode 100644 (file)
index 0000000..94892e1
--- /dev/null
@@ -0,0 +1,205 @@
+# Get name of shape
+
+if { [string compare ${TheFileName} ""] != 0 } {
+    set is_brep [regexp "\.brep" $TheFileName]
+    if {$is_brep == 0} {
+        set is_brep [regexp "\.rle" $TheFileName]
+    }
+    if {$is_brep == 1} {
+        puts [brestore [locate_data_file $TheFileName] res]
+    } else {
+        if { [array get Draw_Groups "DE: STEP"] == "" } {
+           pload XDE
+        }
+        
+        stepread [locate_data_file ${TheFileName}] a *
+        tpcompound res
+    }
+}
+
+puts [checkshape res]
+
+tclean res
+
+if { [string compare $command "shading"] == 0 } {
+    vinit
+    vdisplay res
+    vsetdispmode res 1
+    vfit
+}
+
+if { [string compare $command "incmesh"] == 0 } {
+    set os "ALL"
+    if {[array get env os_type] != ""} {
+       set os $env(os_type)
+    }
+    if { $parallel != 1 || [info exists count_parallel] == 0 } {
+       set count_parallel 1
+    }
+    for {set i 1} {$i <= $count_parallel} {incr i} {
+       tclean res
+       puts "i = $i"
+       incmesh res ${Deflection} ${parallel}
+    }
+}
+
+if { [string compare $command "mesh"] == 0 } {
+    set ResultList [mesh res_mesh res ${Deflection}]
+}
+
+# Collect TODO for area
+if { [string compare $bug_area ""] != 0 } {
+# The difference between square of geometry surface and square of mesh triangles should be less rel_tol value.
+# If rel_tol is 100 we suppose the mesh con not be created.
+    if { $rel_tol == 100 } {
+       puts "TODO $bug_area All:^\\s*Error  : Meshing algo cannot create mesh.\\s*$"
+    } else {
+       puts "TODO $bug_area All:^\\s*Error   : area by triangles differs from true area by \[-.0-9\]+ %\\s*$"
+    }
+}
+
+# Collect TODO for number of triangles without mesh
+if { [string compare $bug_withouttri ""] != 0 } {
+# It may be different for different OS
+    foreach os_withouttri [array names nbwithouttri] {
+       if { $nbwithouttri($os_withouttri) != 0 } { 
+           puts "TODO $bug_withouttri $os_withouttri:^\\s*Error: Faces without triangulation: $nbwithouttri($os_withouttri)\\b\\s*"
+       }
+    }
+}
+
+# Collect TODO for number of free links
+if { [string compare $bug_freelinks ""] != 0 } {
+# It may be different for different OS
+    foreach os_freelinks [array names nbfree] {
+       if { $nbfree($os_freelinks) != 0 } { 
+           puts "TODO $bug_freelinks $os_freelinks:^\\s*Error: Free links: $nbfree($os_freelinks)\\b\\s*"
+       }
+    }
+}
+
+# Collect TODO for number of cross faces
+if { [string compare $bug_cross ""] != 0 } {
+# It may be different for different OS
+    foreach os_cross [array names nbcross] {
+       if { $nbcross($os_cross) != 0 } { 
+           puts "TODO $bug_cross $os_cross:^\\s*Error: Cross face errors: $nbcross($os_cross)\\b\\s*"
+       }
+    }
+}
+
+# Collect TODO for number of async edges
+if { [string compare $bug_async ""] != 0 } {
+# It may be different for different OS
+    foreach os_async [array names nbasync] {
+       if { $nbasync($os_async) != 0 } { 
+           puts "TODO $bug_async $os_async:^\\s*Error: Async edges: $nbasync($os_async)\\b\\s*"
+       }
+    }
+}
+
+# Collect TODO for number of free nodes
+if { [string compare $bug_freenodes ""] != 0 } {
+# It may be different for different OS
+    foreach os_freenodes [array names nbfreenodes] {
+       if { $nbfreenodes($os_freenodes) != 0 } { 
+           puts "TODO $bug_freenodes $os_freenodes:^\\s*Error: Free nodes: $nbfreenodes($os_freenodes)\\b\\s*"
+       }
+    }
+}
+
+# Number of triangles
+set tri 0
+# Number of nodes
+set nod 0
+# Deflection
+set def 0
+
+# Collect number of triangles, number ofof nodes and deflection.
+if { [string compare $command "mesh"] != 0 } {
+    set full [trinfo res]
+    regexp "(\[0-9\]+) +triangles.*\[^0-9]\(\[0-9\]+) +nodes.*deflection +(\[0-9\]|\.+)" $full reg_out tri nod def
+} else {
+    set full [split $ResultList "()"]
+    set tri [lindex [lindex $full 2] 0]
+    set lin [lindex [lindex $full 4] 0]
+    set nod [lindex [lindex $full 6] 0]
+}
+
+if { $tri == 0 || $nod == 0 } {                                                                     
+    puts " "
+    puts "Error  : Meshing algo cannot create mesh."    
+}             
+
+puts " "
+puts "XML property: triangles $tri"
+puts "XML property: nodes $nod"
+puts " "
+
+# Check if area of triangles is valid
+proc CheckTriArea {shape {eps 0}} {
+  upvar #0 $shape a
+  set area [triarea a $eps]
+  set t_area [lindex $area 0]
+  set g_area [expr abs([lindex $area 1])]
+  puts "area by triangles: $t_area"
+  puts "area by geometry:  $g_area"
+  expr ($t_area - $g_area) / $g_area * 100
+}
+
+puts "\nChecking triangulation area (triarea command)..."
+set rel_err [expr abs([CheckTriArea res $area_eps])]
+if { $rel_err > $rel_tol } {
+    puts "Error   : area by triangles differs from true area by $rel_err %"
+} else {
+    if { $rel_tol > 1 && $rel_tol < 100 } {
+       puts "Error: Improvement: The current area difference is $rel_err instead of $rel_tol"
+    }
+}
+
+# Check if topology of mesh is valid
+puts "\nChecking mesh topology (tricheck command)..."
+set l [tricheck res]
+if {$l != ""} {
+    puts $l
+    set withouttri [regsub -all "face \[0-9\]+ has no triangulation" $l "FOUND" ll]
+    if { $withouttri != 0 } {
+       puts "Error: Faces without triangulation: $withouttri"
+    }
+    if { [regexp "Free_links +(\[0-9\]+) +Cross_face_errors +(\[0-9\]+) +Async_edges +(\[0-9\]+) +Free_nodes +(\[0-9\]+)" $l full freelinks crossfaces asyncedges freenodes] } {
+       if { $freelinks != 0 } {
+           puts "Error: Free links: $freelinks"
+       }
+       if { $crossfaces != 0 } {
+           puts "Error: Cross face errors: $crossfaces"
+       }
+       if { $asyncedges != 0 } {
+           puts "Error: Async edges: $asyncedges"
+       }
+       if { $freenodes != 0 } {
+           puts "Error: Free nodes: $freenodes"
+       }
+    }
+}
+
+if { [info exists imagedir] == 0 } {
+   set imagedir .
+}
+if { [info exists test_image ] == 0 } {
+   set test_image photo
+}
+
+if { [string compare $command "shading"] == 0 } {
+    vdump $imagedir/${test_image}.png
+} else {
+    isos 0
+    smallview
+    donly res
+    fit
+    triangles res
+    xwd $imagedir/${test_image}.png
+}
+
+puts ""
+puts "TEST COMPLETED" 
+puts ""