From: abk Date: Fri, 13 Dec 2019 12:32:45 +0000 (+0300) Subject: 0031168: JT Import - cannot see properties attached to objects X-Git-Url: http://git.dev.opencascade.org/gitweb/?a=commitdiff_plain;h=refs%2Fheads%2FCR0-T-S-740;p=occt-copy.git 0031168: JT Import - cannot see properties attached to objects Draw command GetNDStrings was improved to sort the properties by the keys and skip conversions of the strings to type TCollection_AsciiString. Certain Draw commands were corrected to use the Draw interpreter instead of "std::cout". A Tcl procedure was created to compare two multi-line strings. # Conflicts: # src/DDataStd/DDataStd_BasicCommands.cxx # src/DrawResources/CheckCommands.tcl --- diff --git a/src/DDataStd/DDataStd_BasicCommands.cxx b/src/DDataStd/DDataStd_BasicCommands.cxx index 32265907fb..0a8c45debf 100644 --- a/src/DDataStd/DDataStd_BasicCommands.cxx +++ b/src/DDataStd/DDataStd_BasicCommands.cxx @@ -100,6 +100,10 @@ #include #include #include + +#include +#include + #define MAXLENGTH 10 //#define DEB_DDataStd @@ -3407,7 +3411,7 @@ static Standard_Integer DDataStd_GetNDIntegers (Draw_Interpretor& di, TCollection_ExtendedString aKey(itr.Key()); TCollection_AsciiString aStr(aKey,'?'); Standard_Integer aValue = itr.Value(); - std::cout << "Key = " << aStr.ToCString() << " Value = " < + DDataStd_GetNDStrings_Property; + + bool isLess( + const DDataStd_GetNDStrings_Property& theProperty1, + const DDataStd_GetNDStrings_Property& theProperty2) + { + return theProperty1.first.IsLess(theProperty2.first); + } +} + static Standard_Integer DDataStd_GetNDStrings (Draw_Interpretor& di, Standard_Integer nb, const char** arg) @@ -3625,15 +3642,20 @@ static Standard_Integer DDataStd_GetNDStrings (Draw_Interpretor& di, std::cout <<"NamedData attribute at Label = " << arg[2] <LoadDeferredData(); const TDataStd_DataMapOfStringString& aMap = anAtt->GetStringsContainer(); - TDataStd_DataMapIteratorOfDataMapOfStringString itr(aMap); - for (; itr.More(); itr.Next()){ - TCollection_ExtendedString aKey(itr.Key()); - TCollection_AsciiString aStr(aKey,'?'); - TCollection_ExtendedString aVal(itr.Value()); - TCollection_AsciiString aStrValue(aVal,'?'); - std::cout << "Key = " << aStr.ToCString() << " Value = " < aProperties; + for (TDataStd_DataMapIteratorOfDataMapOfStringString aIt (aMap); aIt.More(); aIt.Next()) + { + aProperties.push_back(DDataStd_GetNDStrings_Property (aIt.Key(), aIt.Value())); + } + std::sort (aProperties.begin(), aProperties.end(), isLess); + + for (std::vector::size_type aI = 0; aI < aProperties.size(); ++aI) + { + di << "Key = " << aProperties[aI].first << " Value = " << aProperties[aI].second << "\n"; + } + + return 0; } di << "DDataStd_GetNDStrings : Error\n"; return 1; diff --git a/src/DrawResources/CheckCommands.tcl b/src/DrawResources/CheckCommands.tcl index 7c3c3041cc..0faa900342 100644 --- a/src/DrawResources/CheckCommands.tcl +++ b/src/DrawResources/CheckCommands.tcl @@ -1104,3 +1104,61 @@ proc checkplatform {args} { # current platform is not equal to given as argument platform, return false return 0 } + +help checkgravitycenter { + Compare Center Of Gravity with given reference data + + Use: checkgravitycenter shape prop_type x y z tol +} +proc checkgravitycenter {shape prop_type x y z tol} { + puts "checkgravitycenter ${shape} $prop_type $x $y $z $tol" + upvar ${shape} ${shape} + + if { $prop_type == "-l" } { + set outstr [lprops $shape] + } elseif { $prop_type == "-s" } { + set outstr [sprops $shape] + } elseif { $prop_type == "-v" } { + set outstr [vprops $shape] + } else { + error "Error : invalid prop_type" + } + + if { ![regexp {\nX = +([-0-9.+eE]+).*\nY = +([-0-9.+eE]+).*\nZ = +([-0-9.+eE]+)} ${outstr} full comp_x comp_y comp_z] } { + error "Error : cannot evaluate properties" + } + + if { [expr abs($comp_x-$x)] < $tol && [expr abs($comp_y-$y)] < $tol && [expr abs($comp_z-$z)] < $tol } { + puts "Check of center of gravity is OK: value = ($comp_x, $comp_y, $comp_z), expected = ($x, $y, $z)" + } else { + puts "Error: center of gravity ($comp_x, $comp_y, $comp_z) is not equal to expected ($x, $y, $z)" + } +} + +help checkMultilineStrings { + Compares two strings. + Logically splits the strings to lines by the new line characters. + Outputs the first different lines. + + Use: checkMultilineStrings +} +proc checkMultilineStrings {tS1 tS2} { + set aL1 [split $tS1 \n] + set aL2 [split $tS2 \n] + + set aC1 [llength $aL1] + set aC2 [llength $aL2] + set aC [expr {min($aC1, $aC2)}] + + for {set aI 0} {$aI < $aC} {incr aI} { + if {[lindex $aL1 $aI] != [lindex $aL2 $aI]} { + puts "Error. $aI-th lines are different:" + puts "[lindex $aL1 $aI]" + puts "[lindex $aL2 $aI]" + } + } + + if {$aC1 != $aC2} { + puts "Error. Line counts are different: $aC1 != $aC2." + } +}