From 71e8d4816ea8ce20dda49fde68b137fcc7f6f47d Mon Sep 17 00:00:00 2001 From: mbs Date: Wed, 5 Jun 2024 15:10:55 +0100 Subject: [PATCH] * Use new method to dump the volume and area value in shape dump * check only NAMING in BearingSeparator.py test during checkPythonDump as the Revolution_1 body cannot be selected from a point --- .../ModelHighAPI_FeatureStore.cpp | 35 +++++++++++++------ test.hdfs/BearingSeparator.py | 5 +-- 2 files changed, 28 insertions(+), 12 deletions(-) diff --git a/src/ModelHighAPI/ModelHighAPI_FeatureStore.cpp b/src/ModelHighAPI/ModelHighAPI_FeatureStore.cpp index e6b73dcdc..ff5ce5435 100644 --- a/src/ModelHighAPI/ModelHighAPI_FeatureStore.cpp +++ b/src/ModelHighAPI/ModelHighAPI_FeatureStore.cpp @@ -147,6 +147,26 @@ std::string ModelHighAPI_FeatureStore::compareData(std::shared_ptr= nDigits) + { + int idx = numdigits - nDigits; + theOutput << std::fixed << std::setprecision(0) << (0 < idx && idx < 20 ? std::round(x / pow10[idx]) * pow10[idx] : x); + } + else + { + int prec = (numdigits < 0 ? nDigits : nDigits - numdigits); + theOutput << std::fixed << std::setprecision(prec) << x; + } +} + + static void dumpArray(std::ostringstream& theOutput, const double theArray[], int theSize, int thePrecision = PRECISION) { @@ -155,6 +175,7 @@ static void dumpArray(std::ostringstream& theOutput, const double theArray[], theOutput << " "; theOutput << std::fixed << std::setprecision(thePrecision) << (fabs(theArray[i]) < TOLERANCE ? 0.0 : theArray[i]); + //dumpFloat(theOutput, (fabs(theArray[i]) < TOLERANCE ? 0.0 : theArray[i]), thePrecision); } } @@ -423,21 +444,15 @@ std::string ModelHighAPI_FeatureStore::dumpShape(std::shared_ptr& if (aVolume > 1.e-5) { aResult<<"Volume: "; // volumes of too huge shapes write in the scientific format - if (aVolume >= 1.e5) - aResult< 1.e-5) { aResult << "Area: "; // volumes of too huge shapes write in the scientific format - if (anArea >= 1.e5) - aResult << std::scientific << std::setprecision(7); - else - aResult << std::fixed << std::setprecision(3); - aResult << anArea << std::endl; + dumpFloat(aResult, anArea, 6); + aResult << std::endl; } std::shared_ptr aCenter = GeomAlgoAPI_ShapeTools::centreOfMass(theShape); aResult<<"Center of mass: "; diff --git a/test.hdfs/BearingSeparator.py b/test.hdfs/BearingSeparator.py index f41b0a15c..761590e06 100644 --- a/test.hdfs/BearingSeparator.py +++ b/test.hdfs/BearingSeparator.py @@ -25,7 +25,8 @@ if __name__ == "__main__": model.testNbSubShapes(aPartFeature, GeomAPI_Shape.FACE, [115]) model.testNbSubShapes(aPartFeature, GeomAPI_Shape.EDGE, [890]) model.testNbSubShapes(aPartFeature, GeomAPI_Shape.VERTEX, [1780]) - model.testResultsVolumes(aPartFeature, [1311.87963636394]) + model.testResultsVolumes(aPartFeature, [1311.87963636394], 6) model.testResultsAreas(aPartFeature, [3765.24411189]) - assert(model.checkPythonDump()) +from ModelHighAPI import CHECK_NAMING +assert(model.checkPythonDump(CHECK_NAMING)) -- 2.39.2