1 puts "Test includes comparing for $CompareDocumentsMode"
2 ############## INIZIALIZING OF VARIABLES #################################
3 # ========== variables for comparison ======================
5 set Checkshape_Second **
7 set nbDocVertex_Second **
8 set nbDocEdge_Second **
9 set nbDocWire_Second **
10 set nbDocFace_Second **
11 set nbDocShell_Second **
12 set nbDocSolid_Second **
13 set nbDocCompsolid_Second **
14 set nbDocCompound_Second **
15 set nbDocShape_Second **
17 set faces_list_Second **
19 set DocLabels_Second **
20 set DocVolume_Second **
22 set nbClosedShells_Second **
23 set DocVolume_Second **
25 set DocAllColors_Second **
26 set DocShapeLabels_Second **
28 set DocLayers_Second **
29 set DocLayerLabels_Second **
30 set DocShapeLabels_Second **
31 ###################################
33 set Checkshape_First 0
35 set nbDocVertex_First 0
39 set nbDocShell_First 0
40 set nbDocSolid_First 0
41 set nbDocCompsolid_First 0
42 set nbDocCompound_First 0
43 set nbDocShape_First 0
45 set faces_list_First 0
50 set nbClosedShells_First 0
53 set DocAllColors_First 0
54 set DocShapeLabels_First 0
57 set DocLayerLabels_First 0
58 set DocShapeLabels_First 0
60 # If it needs, adding to document D_First "Assembly colors and layers" OR "colors and layers"
61 if { [regexp "ASSEMBLY_C_L" $AddToDocument] } {
62 if { [info exists D_First] == 0} {
63 puts "Creating new doc"
67 set color1 "1 0 0" ;# RED
68 set color2 "0 1 0" ;# GREEN
69 set color3 "0 0 1" ;# BLUE1
70 set color4 "1 1 0" ;# YELLOW
71 set color1c "0 1 1" ;# CYAN1
72 set color2c "1 0 1" ;# MAGENTA1
73 set color3c "1 1 1" ;# WHITE
74 set color4c "0 0 0" ;# BLACK
82 set color2cname MAGENTA1
86 ### Add compound in document as ASSEMBLY (default behaviour of XAddShape function)
88 box b2 10 10 10 20 20 20
92 ### Add free shape in document
93 box b3 30 30 30 30 30 30
95 ######################### COLORS VERIFYING ##############################
96 ### Add some colors in document
97 eval XAddColor D_First $color1
98 eval XAddColor D_First $color2
100 ### Verify whether the collors are in document
101 if {[eval XFindColor D_First $color1] == "" || [eval XFindColor D_First $color1] == ""} {
102 puts "Error : Color was not added in the document or was not found after adding"
106 ### Verify number of colors in document
107 if { [llength [XGetAllColors D_First]] != "2" } {
108 puts "Error : XGetAllColors function returns an invalid value"
112 ### Assign color to shapes (two existing colors and six new colors)
114 eval XSetColor D_First b1 $color1 s
115 eval XSetColor D_First b2 $color2 s
116 eval XSetColor D_First b3 $color3 s
117 eval XSetColor D_First c $color4 s
119 eval XSetColor D_First b1 $color1c c
120 eval XSetColor D_First b2 $color2c c
121 eval XSetColor D_First b3 $color3c c
122 eval XSetColor D_First c $color4c c
123 ### Verify number of colors in document
124 if { [llength [XGetAllColors D_First]] != "8" } {
125 puts "Error : XGetAllColors function returns an invalid value after assigning colors to shapes in the document"
128 ### Verify colors of all shapes
129 if {[XGetShapeColor D_First [XFindShape D_First b1] s] != $color1name} {
130 puts "Error : Shape b1 has an invalid surface color "
133 if {[XGetShapeColor D_First [XFindShape D_First b2] s] != $color2name} {
134 puts "Error : Shape b2 has an invalid surface color "
137 if {[XGetShapeColor D_First [XFindShape D_First b3] s] != $color3name} {
138 puts "Error : Shape b3 has an invalid surface color "
141 if {[XGetShapeColor D_First [XFindShape D_First c ] s] != $color4name} {
142 puts "Error : Shape c has an invalid surface color "
145 if {[XGetShapeColor D_First [XFindShape D_First b1] c] != $color1cname} {
146 puts "Error : Shape b1 has an invalid surface color "
149 if {[XGetShapeColor D_First [XFindShape D_First b2] c] != $color2cname} {
150 puts "Error : Shape b2 has an invalid surface color "
153 if {[XGetShapeColor D_First [XFindShape D_First b3] c] != $color3cname} {
154 puts "Error : Shape b3 has an invalid surface color "
157 if {[XGetShapeColor D_First [XFindShape D_First c ] c] != $color4cname} {
158 puts "Error : Shape c has an invalid surface color
161 ### Remove some colors from document
162 # Remove colors of b1 surfaces
163 XRemoveColor D_First [eval XFindColor D_First $color1]
164 # Remove colors of b2 curves
165 XRemoveColor D_First [eval XFindColor D_First $color2c]
166 ### Verify number of colors in document
167 if { [llength [XGetAllColors D_First]] != "6" } {
168 puts "Error : XGetAllColors function returns an invalid value after removing two colors from the document"
171 ### Verify whether b1 and b2 have the removed colors
172 if {[XGetShapeColor D_First [XFindShape D_First b1] s] != ""} {
173 puts "Error : Color of b1 surface was removed from the document however XGetShapeColor function returns value "
176 if {[XGetShapeColor D_First [XFindShape D_First b2] c] != ""} {
177 puts "Error : Color of b2 curves was removed from the document however XGetShapeColor function returns value "
180 ######################### LAYERS VERIFYING ##############################
181 ### Add three layers in document
185 ### Verify amount layers in document
186 if { [llength [XGetAllLayers D_First]] != "3" } {
187 puts "Error : Error occurs during adding layers in document "
190 if { [llength [XGetLayerLabels D_First]] != "3" } {
191 puts "Error : XGetLayerLabels function works incorrectly "
194 ### Verify whether the layers was added in document correctly
195 if { [XFindLayer D_First L1] == "" || [XFindLayer D_First L2] == "" || [XFindLayer D_First L3] == "" } {
196 puts "Error : Layers were not added in the document correctly "
199 ### Verify XGetOneLayer function
200 if { [XGetOneLayer D_First [XFindLayer D_First L1]] != "\"L1\"" } {
201 puts "Error : XGetOneLayer function works incorrectly for L1 layer"
204 if { [XGetOneLayer D_First [XFindLayer D_First L2]] != "\"L2\"" } {
205 puts "Error : XGetOneLayer function works incorrectly for L2 layer"
208 if { [XGetOneLayer D_First [XFindLayer D_First L3]] != "\"L3\"" } {
209 puts "Error : XGetOneLayer function works incorrectly for L3 layer"
212 ### Verify removing layer from document
213 XAddLayer D_First LtoRemove
214 if { [llength [XGetAllLayers D_First]] != "4" } {
215 puts "Error : Error occurs when adding a layer in the document "
218 XRemoveLayer D_First LtoRemove
219 if { [llength [XGetAllLayers D_First]] != "3" } {
220 puts "Error : Error occurs when removing a layer from the document "
223 ### Verify interconnection layers and shapes
224 XSetLayer D_First b1 L1
225 XSetLayer D_First b2 L2
226 XSetLayer D_First b3 L3
227 XSetLayer D_First c L3
228 if {[XGetLayers D_First b1] != "\"L1\" "} {
229 puts "Error : Shape b1 is not on layer L1"
232 if {[XGetLayers D_First b2] != "\"L2\" "} {
233 puts "Error : Shape b2 is not on layer L2"
236 if {[XGetLayers D_First b3] != "\"L3\" "} {
237 puts "Error : Shape b3 is not on layer L3"
240 if {[XGetLayers D_First c ] != "\"L3\" "} {
241 puts "Error : Compound c is not on layer L3"
244 XRemoveColor D_First [eval XFindColor D_First $color4]
245 XRemoveColor D_First [eval XFindColor D_First $color4c]
246 XUnSetLayer D_First c L3
249 #================== COLORS_LAYER ===============
250 } elseif { [regexp "COLORS_LAYERS" $AddToDocument] } {
251 if {[info exists D_First] == 0} {
255 set color1 "1 0 0" ;# RED
256 set color2 "0 1 0" ;# GREEN
257 set color3 "0 0 1" ;# BLUE1
258 set color4 "1 1 0" ;# YELLOW
259 set color1c "0 1 1" ;# CYAN1
260 set color2c "1 0 1" ;# MAGENTA1
261 set color3c "1 1 1" ;# WHITE
262 set color4c "0 0 0" ;# BLACK
268 set color4name YELLOW
269 set color1cname CYAN1
270 set color2cname MAGENTA1
271 set color3cname WHITE
272 set color4cname BLACK
273 ######################### COLORS VERIFYING ##############################
274 ### Add some colors in document
275 eval XAddColor D_First $color1
276 eval XAddColor D_First $color2
277 ### Verify whether the collors are in document
278 if {[eval XFindColor D_First $color1] == "" || [eval XFindColor D_First $color1] == ""} {
279 puts "Error : Color was not added in the document or was not found after adding"
283 ### Verify number of colors in document
284 if { [llength [XGetAllColors D_First]] != "2" } {
285 puts "Error : XGetAllColors function returns an invalid value"
288 set list [XGetTopLevelShapes D_First]
290 eval XSetColor D_First $i $color1 s
291 eval XSetColor D_First $i $color1c c
294 if {[XGetShapeColor D_First $i s] != $color1name} {
295 puts [format "Error : Shape located on label %s has an invalid surface color " $i]
298 if {[XGetShapeColor D_First $i c] != $color1cname} {
299 puts [format "Error : Shape located on label %s has an invalid curves color " $i]
303 ### Remove some colors from document
304 XRemoveColor D_First [eval XFindColor D_First $color1c]
305 ### Verify number of colors in document
306 if { [llength [XGetAllColors D_First]] != "2" } {
307 puts "Error : XGetAllColors function returns an invalid value after removing colors from the document"
311 ### Verify shapes have the removed colors of curves
313 if {[XGetShapeColor D_First $i c] != ""} {
314 puts "Error : Curves color was removed from the document however XGetShapeColor function returns value "
318 ######################### LAYERS VERIFYING ##############################
319 ### Add three layers in document
323 ### Verify amount layers in document
324 if { [llength [XGetAllLayers D_First]] != "3" } {
325 puts "Error : Error occurs when adding layers in the document "
328 if { [llength [XGetLayerLabels D_First]] != "3" } {
329 puts "Error : XGetLayerLabels function works incorrectly "
333 ### Verify whether the layers were added in the document correctly
334 if { [XFindLayer D_First L1] == "" || [XFindLayer D_First L2] == "" || [XFindLayer D_First L3] == "" } {
335 puts "Error : Layers were not added in the document correctly "
339 ### Verify XGetOneLayer function
340 if { [XGetOneLayer D_First [XFindLayer D_First L1]] != "\"L1\"" } {
341 puts "Error : XGetOneLayer function works incorrectly for L1 layer"
344 if { [XGetOneLayer D_First [XFindLayer D_First L2]] != "\"L2\"" } {
345 puts "Error : XGetOneLayer function works incorrectly for L2 layer"
348 if { [XGetOneLayer D_First [XFindLayer D_First L3]] != "\"L3\"" } {
349 puts "Error : XGetOneLayer function works incorrectly for L3 layer"
353 ### Verify removing layer from document
354 XAddLayer D_First LtoRemove
355 if { [llength [XGetAllLayers D_First]] != "4" } {
356 puts "Error : Error occurs when adding a layer in the document "
359 XRemoveLayer D_First LtoRemove
360 if { [llength [XGetAllLayers D_First]] != "3" } {
361 puts "Error : Error occurs when removing a layer from the document "
364 ### Verify interconnection layers and shapes
365 set aLen [llength $list]
366 for {set i 0} { $i < $aLen} {incr i} {
367 if { [expr $i / 2 == int ($i/2)] } {
368 eval XSetLayer D_First [lindex $list $i] L1
370 eval XSetLayer D_First [lindex $list $i] L2
373 for {set i 0} { $i < $aLen} {incr i} {
374 if { [expr $i / 2 == int ($i/2)] } {
379 if {[XGetLayers D_First [lindex $list $i]] != $LLL} {
380 puts [format "Error : Shape located on label %s is not on layer %s" [lindex $list $i] $LLL]
384 XRemoveLayer D_First L2
385 XRemoveLayer D_First L3
386 XRemoveColor D_First [eval XFindColor D_First $color2]
387 set list [XGetTopLevelShapes D_First]
389 set str [XLabelInfo D_First $i]
390 if {[regexp "Assembly" $str] || [regexp "This Shape is not used" $str]} {
391 XUnSetLayer D_First $i L1
392 XUnsetColor D_First $i c
393 XUnsetColor D_First $i s
396 #erase all unused colors and layers
397 set list [XGetTopLevelShapes D_First]
401 set l [XGetShapeColor D_First $i c]
402 if {[expr [llength $l] != 0]} {
405 set l [XGetShapeColor D_First $i s]
406 if {[expr [llength $l] != 0]} {
409 set l [XGetLayers D_First $i]
410 if {[expr [llength $l] != 0]} {
414 if {$ColorIsUsed == 0} {
415 set label [XFindColor D_First 1 0 0 ]
416 XRemoveColor D_First $label
418 if {$LayerIsUsed == 0} {
419 XRemoveLayer D_First L1
423 # Get information for the first document
424 # Get shape for standard analysis
425 XGetOneShape res_First D_First
427 if {[regexp "CHECKSHAPE" $CompareDocumentsMode]} {
428 set Checkshape_First [checkshape res_First]
431 if {[regexp "SHAPES" $CompareDocumentsMode] || [regexp "ALL" $CompareDocumentsMode]} {
432 set Stat_First [nbshapes res_First]
433 regexp {VERTEX +: +([-0-9.+eE]+)} $Stat_First full nbDocVertex_First
434 regexp {EDGE +: +([-0-9.+eE]+)} $Stat_First full nbDocEdge_First
435 regexp {WIRE +: +([-0-9.+eE]+)} $Stat_First full nbDocWire_First
436 regexp {FACE +: +([-0-9.+eE]+)} $Stat_First full nbDocFace_First
437 regexp {SHELL +: +([-0-9.+eE]+)} $Stat_First full nbDocShell_First
438 regexp {SOLID +: +([-0-9.+eE]+)} $Stat_First full nbDocSolid_First
439 regexp {COMPSOLID +: +([-0-9.+eE]+)} $Stat_First full nbDocCompsolid_First
440 regexp {COMPOUND +: +([-0-9.+eE]+)} $Stat_First full nbDocCompound_First
441 regexp {SHAPE +: +([-0-9.+eE]+)} $Stat_First full nbDocShape_First
444 if {[regexp "FACES" $CompareDocumentsMode]} {
445 set type_of [dtyp res_First]
446 if {[regexp "FACE" $type_of] } {
447 set faces_list_First "FACE"
449 set faces_list_First [explode res_First F]
453 if {[regexp "VOLUME_EXACTLY" $CompareDocumentsMode] || [regexp "ALL" $CompareDocumentsMode]} {
454 set DocLabels_First [XGetFreeShapes D_First]
455 set DocVolume_First "0"
456 foreach {i} $DocLabels_First {
457 XSetProps D_First $i 1
458 set DocVolume_First [expr $DocVolume_First + abs([XGetVolume D_First $i])]
460 } elseif {[regexp "VOLUME" $CompareDocumentsMode]} {
462 XGetOneShape Shape_First D_First
463 set type [dtyp Shape_First]
465 if {[regexp "SOLID" $type]} {
467 } elseif {[regexp "SHELL" $type] && [regexp "Orientable" $type] && [regexp "Closed" $type]} {
469 } elseif {[regexp "COMPOUND" $type]} {
470 set list [explode Shape_First So]
471 if {[llength $list] != 0} {
474 set list [explode Shape_First Sh]
475 if {[llength $list] != 0} {
478 if {[regexp "Orientable" $type] && [regexp "Closed" $type]} {
484 if {[expr $IsComp == 1]} {
485 XGetOneShape Shape_First D_First
486 catch { sewing r 0.00001 Shape_First}
487 set nbClosedShells_First 0
488 # Calculate amount of closed shells in initial shape
489 if {[regexp SHELL [whatis r]]} {
490 catch { fbclose r 0.001 0.00001 }
491 catch { if {[llength [explode r_o V]] == 0 && [llength [explode r_c V]] == 0} {
492 puts "nbClosedShells_First = 1"
493 set nbClosedShells_First 1 }
496 set shells [explode r Sh]
497 foreach {i} $shells {
498 catch { fbclose $i 0.001 0.00001}
500 if { [llength [explode $i_o V]] == 0 && [llength [explode $i_c V]] == 0} {
501 set nbClosedShells_First [expr $nbClosedShells_First + 1]
508 XSetProps T_First 0:1:1:1 1
509 set DocVolume_First [expr abs([XGetVolume T_First 0:1:1:1])]
511 puts "Volume of shape is equal 0"
512 set DocVolume_First 0
513 set nbClosedShells_First 0
517 if {[regexp "COLORS" $CompareDocumentsMode] || [regexp "ALL" $CompareDocumentsMode]} {
518 set DocAllColors_First [lsort [XGetAllColors D_First]]
519 set DocShapeLabels_First [XGetTopLevelShapes D_First]
522 if { [regexp "LAYERS" $CompareDocumentsMode] || [regexp "ALL" $CompareDocumentsMode] || [regexp "LAYERS_EXACTLY" $CompareDocumentsMode] } {
523 set DocLayers_First [XGetAllLayers D_First]
524 set DocLayerLabels_First [XGetLayerLabels D_First]
525 set DocShapeLabels_First [XGetTopLevelShapes D_First]
527 ################## WRITING FILE ##################"
528 ###Open temporary file
529 if { [string compare ${TypeOfFile} ""] == 0 } {
530 set saving [SaveAs D_First $WorkDirectory/${casename}_D_First.dxc]
531 set closing [Close D_First]
532 set opening [Open $WorkDirectory/${casename}_D_First.dxc D_Second]
533 } elseif {[string compare ${TypeOfFile} "igs"] == 0 } {
534 set writing [WriteIges D_First $WorkDirectory/${casename}_D_First.igs]
535 set reading [ReadIges D_Second $WorkDirectory/${casename}_D_First.igs]
536 } elseif {[string compare ${TypeOfFile} "stp"] == 0 } {
537 set writing [WriteStep D_First $WorkDirectory/${casename}_D_First.stp]
538 set reading [ReadStep D_Second $WorkDirectory/${casename}_D_First.stp]
539 } elseif {[string compare ${TypeOfFile} "brep"] == 0 } {
540 XGetOneShape Shape1 D_First
541 set saving [save Shape1 $WorkDirectory/${casename}_D_First.brep]
542 restore $WorkDirectory/${casename}_D_First.brep NewShape1
544 XAddShape D_Second NewShape1
546 puts "Error : Wrong value of TypeOfFile"
550 if { [string compare ${TypeOfFile} ""] == 0 } {
551 catch {[file delete $WorkDirectory/${casename}_D_First.dxc]}
552 } elseif {[string compare ${TypeOfFile} "igs"] == 0 } {
553 catch {[file delete $WorkDirectory/${casename}_D_First.igs]}
554 } elseif {[string compare ${TypeOfFile} "stp"] == 0} {
555 catch {[file delete $WorkDirectory/${casename}_D_First.stp]}
556 } elseif {[string compare ${TypeOfFile} "brep"] == 0} {
557 catch {[file delete $WorkDirectory/${casename}_D_First.brep]}
560 # Get shape for standard analysis
561 XGetOneShape res_Second D_Second
563 if {[regexp "CHECKSHAPE" $CompareDocumentsMode]} {
564 set Checkshape_Second [checkshape res_Second]
567 if {[regexp "SHAPES" $CompareDocumentsMode] || [regexp "ALL" $CompareDocumentsMode]} {
568 set Stat_Second [nbshapes res_Second]
569 regexp {VERTEX +: +([-0-9.+eE]+)} $Stat_Second full nbDocVertex_Second
570 regexp {EDGE +: +([-0-9.+eE]+)} $Stat_Second full nbDocEdge_Second
571 regexp {WIRE +: +([-0-9.+eE]+)} $Stat_Second full nbDocWire_Second
572 regexp {FACE +: +([-0-9.+eE]+)} $Stat_Second full nbDocFace_Second
573 regexp {SHELL +: +([-0-9.+eE]+)} $Stat_Second full nbDocShell_Second
574 regexp {SOLID +: +([-0-9.+eE]+)} $Stat_Second full nbDocSolid_Second
575 regexp {COMPSOLID +: +([-0-9.+eE]+)} $Stat_Second full nbDocCompsolid_Second
576 regexp {COMPOUND +: +([-0-9.+eE]+)} $Stat_Second full nbDocCompound_Second
577 regexp {SHAPE +: +([-0-9.+eE]+)} $Stat_Second full nbDocShape_Second
580 if {[regexp "FACES" $CompareDocumentsMode]} {
581 set type_of [dtyp res_Second]
582 if {[regexp "FACE" $type_of] } {
583 set faces_list_Second "FACE"
585 set faces_list_Second [explode res_Second F]
589 if {[regexp "VOLUME_EXACTLY" $CompareDocumentsMode] || [regexp "ALL" $CompareDocumentsMode]} {
590 set DocLabels_Second [XGetFreeShapes D_Second]
591 set DocVolume_Second "0"
592 foreach {i} $DocLabels_Second {
593 XSetProps D_Second $i 1
594 set DocVolume_Second [expr $DocVolume_Second + abs([XGetVolume D_Second $i])]
596 } elseif {[regexp "VOLUME" $CompareDocumentsMode]} {
597 if {[expr $IsComp == 1]} {
598 # Perform sewing of resulting shape. If amount of closed shells of resulting shape is not equal to amount of
599 # closed shells of initial shape increace tolerance and perform sewing again
600 set nbClosedShells_Second 0
602 set IsSewingPerformedCorrectly 0
603 XGetOneShape Shape_Second D_Second
604 for {set k 0} {$k < 5} {incr k} {
606 puts [format "PERFORM SEWING. TOLERANCE = %f" $toler]
607 catch { sewing res $toler Shape_Second }
608 # 2. Calculate amount of closed shells
609 set nbClosedShells_Second 0
610 if {[regexp SHELL [whatis res]]} {
611 catch { fbclose res 0.001 $toler }
613 if {[llength [explode res_o V]] == 0 && [llength [explode res_c V]] == 0 } {
614 set nbClosedShells_Second 1
618 set shells [explode res Sh]
620 catch { fbclose $i 0.001 0.000001 }
622 if {[llength [explode $i_o V]] == 0 && [llength [explode $i_c V]] == 0} {
623 set nbClosedShells_Second [expr $nbClosedShells_Second +1]
628 # 3. Verify amount of closed shells
629 if { $nbClosedShells_Second >= $nbClosedShells_First} {
630 set IsSewingPerformedCorrectly 1
633 # 4. Set new tolerance
634 set toler [expr $toler * 10]
637 XAddShape T_Second res;
638 XSetProps T_Second 0:1:1:1 1;
639 set DocVolume_Second [expr abs([XGetVolume T_Second 0:1:1:1])]
640 if { $IsSewingPerformedCorrectly == 0 } {
641 puts "Error : SEWING IS NOT PERFORMED PROPERLY"
644 puts "Volume of shape is equal 0"
645 set DocVolume_Second 0
646 set nbClosedShells_Second 0
650 if {[regexp "COLORS" $CompareDocumentsMode] || [regexp "ALL" $CompareDocumentsMode]} {
651 set DocAllColors_Second [lsort [XGetAllColors D_Second]]
652 set DocShapeLabels_Second [XGetTopLevelShapes D_Second]
655 if { [regexp "LAYERS" $CompareDocumentsMode] || [regexp "ALL" $CompareDocumentsMode] || [regexp "LAYERS_EXACTLY" $CompareDocumentsMode] } {
656 set DocLayers_Second [XGetAllLayers D_Second]
657 set DocLayerLabels_Second [XGetLayerLabels D_Second]
658 set DocShapeLabels_Second [XGetTopLevelShapes D_Second]
660 puts "====================RESULTS OF COMPARISON===================="
661 if {[regexp "CHECKSHAPE" $CompareDocumentsMode]} {
662 puts "====================CHECKSHAPE==============="
663 puts "First : $Checkshape_First"
664 puts "Second : $Checkshape_Second"
665 if {[string compare $Checkshape_First $Checkshape_Second] != 0} {
666 puts "Error : checkshape is wrong"
670 if {[regexp "SHAPES" $CompareDocumentsMode] || [regexp "ALL" $CompareDocumentsMode]} {
671 puts "====================SHAPES==============="
672 puts "Vertex First: $nbDocVertex_First"
673 puts "Vertex Second: $nbDocVertex_Second"
674 if {[string compare $nbDocVertex_First $nbDocVertex_Second] != 0} {
675 puts "Error : nbshapes is wrong"
678 puts "Edge First: $nbDocEdge_First"
679 puts "Edge Second: $nbDocEdge_Second"
680 if {[string compare $nbDocEdge_First $nbDocEdge_Second] != 0} {
681 puts "Error : nbshapes is wrong"
684 puts "Wire First: $nbDocWire_First"
685 puts "Wire Second: $nbDocWire_Second"
686 if {[string compare $nbDocWire_First $nbDocWire_Second] != 0} {
687 puts "Error : nbshapes is wrong"
690 puts "Face First: $nbDocFace_First"
691 puts "Face Second: $nbDocFace_Second"
692 if {[string compare $nbDocFace_First $nbDocFace_Second] != 0} {
693 puts "Error : nbshapes is wrong"
696 puts "Shell First: $nbDocShell_First"
697 puts "Shell Second: $nbDocShell_Second"
698 if {[string compare $nbDocShell_First $nbDocShell_Second] != 0} {
699 puts "Error : nbshapes is wrong"
702 puts "Solid First: $nbDocSolid_First"
703 puts "Solid Second: $nbDocSolid_Second"
704 if {[string compare $nbDocSolid_First $nbDocSolid_Second] != 0} {
705 puts "Error : nbshapes is wrong"
708 puts "Compsolid First: $nbDocCompsolid_First"
709 puts "Compsolid Second: $nbDocCompsolid_Second"
710 if {[string compare $nbDocCompsolid_First $nbDocCompsolid_Second] != 0} {
711 puts "Error : nbshapes is wrong"
714 puts "Compound First: $nbDocCompound_First"
715 puts "Compound Second: $nbDocCompound_Second"
716 if {[string compare $nbDocCompound_First $nbDocCompound_Second] != 0} {
717 puts "Error : nbshapes is wrong"
720 puts "Shape First: $nbDocShape_First"
721 puts "Shape Second: $nbDocShape_Second"
722 if {[string compare $nbDocShape_First $nbDocShape_Second] != 0} {
723 puts "Error : nbshapes is wrong"
727 if {[regexp "FACES" $CompareDocumentsMode]} {
728 puts "================FACES==================="
729 puts "Faces First: [llength $faces_list_First]"
730 puts "Faces Second: [llength $faces_list_Second]"
731 if {[llength $faces_list_First] != [llength $faces_list_Second]} {
732 puts "Error : The number of faces is wrong"
736 if {[regexp "VOLUME_EXACTLY" $CompareDocumentsMode] || [regexp "ALL" $CompareDocumentsMode]} {
737 puts "===============VOLUME_EXACTLY===================="
738 puts "DocLabels First: $DocLabels_First"
739 puts "DocLabels Second: $DocLabels_Second"
740 if {[string compare $DocLabels_First $DocLabels_Second] != 0} {
741 puts "Error : DocLabels are wrong"
744 puts "DocVolume First: $DocVolume_First"
745 puts "DocVolume Second: $DocVolume_Second"
746 if {[string compare $DocVolume_First $DocVolume_Second] != 0} {
747 set MaxVolume [expr $DocVolume_First> $DocVolume_Second ? $DocVolume_First : $DocVolume_Second]
748 if {[expr $MaxVolume > 0]} {
749 set diff [ expr abs($DocVolume_First-$DocVolume_Second)/ $MaxVolume * 100 ]
753 if {[expr $diff > 5]} {
754 puts [format "Error : The difference between volumes is %f%s" $diff "%"]
757 puts [format "The difference between volumes is %f%s - OK" $diff "%"]
760 } elseif {[regexp "VOLUME" $CompareDocumentsMode]} {
761 puts "===============VOLUME===================="
762 puts "DocVolume First: $DocVolume_First"
763 puts "DocVolume Second: $DocVolume_Second"
764 if {[string compare $DocVolume_First $DocVolume_Second] != 0} {
765 set MaxVolume [expr $DocVolume_First> $DocVolume_Second ? $DocVolume_First : $DocVolume_Second]
766 if {[expr $MaxVolume > 0]} {
767 set diff [ expr abs($DocVolume_First-$DocVolume_Second)/ $MaxVolume * 100 ]
771 if {[expr $diff > 5]} {
772 puts [format "Error : The difference between volumes is %f%s" $diff "%"]
775 puts [format "The difference between volumes is %f%s - OK" $diff "%"]
778 puts "nbClosedShells First: $nbClosedShells_First"
779 puts "nbClosedShells Second: $nbClosedShells_Second"
780 if {[string compare $nbClosedShells_First $nbClosedShells_Second] != 0} {
781 puts "Error : nbClosedShells is wrong"
785 if {[regexp "COLORS" $CompareDocumentsMode] || [regexp "ALL" $CompareDocumentsMode]} {
786 puts "==============COLORS====================="
787 puts "DocAllColors First: $DocAllColors_First"
788 puts "DocAllColors Second: $DocAllColors_Second"
789 if {[llength $DocAllColors_Second] == 0 && [llength $DocAllColors_First] != 0} {
790 puts "Warning : There are no colors in D_Second although they are present in D_First"
791 if {[expr $ErrorCode == 0]} {
795 if {[regexp "COLORS_EXACTLY" $CompareDocumentsMode] || [regexp "ALL" $CompareDocumentsMode]} {
796 if {[string compare $DocAllColors_First $DocAllColors_Second] != 0} {
797 puts "Error : Compared documents have a different set of colors"
801 puts "DocShapeLabels First: $DocShapeLabels_First"
802 puts "DocShapeLabels Second: $DocShapeLabels_Second"
803 if {[string compare $DocShapeLabels_First $DocShapeLabels_Second] != 0} {
804 if {[regexp "ALL" $CompareDocumentsMode]} {
806 puts "Error : Compared documents have a different number of toplevel shapes "
808 puts "Warning : Compared documents have a different number of toplevel shapes "
809 if {[expr $ErrorCode == 0]} {
815 if { [regexp "LAYERS" $CompareDocumentsMode] || [regexp "ALL" $CompareDocumentsMode] || [regexp "LAYERS_EXACTLY" $CompareDocumentsMode] } {
816 puts "================LAYERS==================="
818 puts "DocLayers First: $DocLayers_First"
819 puts "DocLayers Second: $DocLayers_Second"
820 if {[string compare $DocLayers_First $DocLayers_Second] != 0} {
821 if {[regexp "LAYERS_EXACTLY" $CompareDocumentsMode]} {
823 puts "Error : Compared documents have a different set of LAYERS names"
825 puts "Warning : Compared documents have a different set of LAYERS names"
826 if {[expr $ErrorCode == 0]} {
831 puts "DocLayerLabels First: $DocLayerLabels_First"
832 puts "DocLayerLabels Second: $DocLayerLabels_Second"
833 if {[string compare $DocLayerLabels_First $DocLayerLabels_Second] != 0} {
834 if {[regexp "LAYERS_EXACTLY" $CompareDocumentsMode]} {
835 puts [format "Error : Compared documents have a different set of LAYERS labels"]
838 puts [format "Warning : Compared documents have a different set of LAYERS labels"]
839 if {[expr $ErrorCode == 0]} {
844 puts "DocShapeLabels First: $DocShapeLabels_First"
845 puts "DocShapeLabels Second: $DocShapeLabels_Second"
846 if {[string compare $DocShapeLabels_First $DocShapeLabels_Second] != 0} {
847 if {[regexp "ALL" $CompareDocumentsMode]} {
848 puts "Error : DocShapeLabels is wrong"
851 puts "Warning : DocShapeLabels is wrong"
855 if {[regexp "LAYERS_EXACTLY" $CompareDocumentsMode]} {
856 set DDD $DocLayers_First
857 if {$DocLayers_First > $DocLayers_Second} {
858 set DDD $DocLayers_Second
861 set DocLabel_First [XFindLayer D_First $i]
862 set DocLabel_Second [XFindLayer D_Second $i]
864 if {[string compare $DocLabel_First $DocLabel_Second] != 0} {
865 puts [format " DocLabel_First(%s) = %s " $i $DocLabel_First]
866 puts [format " DocLabel_Second(%s) = %s " $i $DocLabel_Second]
867 puts [format "Error : Compared documents have different labels for one layer (%s)" $i]
872 set DocShapeLabels_First [XGetTopLevelShapes D_First]
873 set DocShapeLabels_Second [XGetTopLevelShapes D_Second]
875 set DDD $DocShapeLabels_First
876 if {$DocShapeLabels_First > $DocShapeLabels_Second} {
877 set DDD $DocShapeLabels_Second
880 set DocLayer_First [XGetLayers D_First $i]
881 set DocLayer_Second [XGetLayers D_Second $i]
883 if {[string compare $DocLayer_First $DocLayer_Second] != 0} {
885 set DocLayer_Second [XGetLayers D_Second $NewLabel]
888 if {[string compare $DocLayer_Second $DocLayer_First] != 0} {
889 puts [format " DocLayer_First(%s) = %s " $i $DocLayer_First]
890 puts [format "DocLayer_Second(%s) = %s " $i $DocLayer_Second]
891 puts [format "DocLayer_Second(%s) = %s " $NewLabel $DocLayer_Second]
892 puts [format "Error : Compared documents have different LAYERS for the shape located on %s label" $i]
897 set DDD $DocLayerLabels_First
898 if {$DocLayerLabels_First > $DocLayerLabels_Second} {
899 set DDD $DocLayerLabels_Second
902 set LayerName_First [XGetOneLayer D_First $i]
903 set LayerName_Second [XGetOneLayer D_Second $i]
905 if {[string compare $LayerName_First $LayerName_Second]!=0} {
907 set LayerName_Second [XGetOneLayer D_Second $NewLabel]
909 if {[string compare $LayerName_Second $LayerName_First]!=0} {
910 puts [format " LayerName_First(%s) = %s " $i $LayerName_First]
911 puts [format "LayerName_Second(%s) = %s " $i $LayerName_Second]
912 puts [format "LayerName_Second(%s) = %s " $NewLabel $LayerName_Second]
913 puts [format "Error : Compared documents have different LAYERS names on %s label" $i]
920 XGetOneShape result D_Second
921 if {[isdraw result]} {
926 xwd $imagedir/${test_image}.png
929 if {[expr $ErrorCode == 2]} {
930 puts "Error : errors occur during test"
931 } elseif {[expr $ErrorCode == 1]} {
932 puts "WARNING OCCURS DURING TEST"
933 } elseif {[expr $ErrorCode != 0]} {
934 puts "Error : a wrong value of ErrorCode."
937 puts "TEST COMPLETED"