From 6587ce676ef427b94c0a52d1e70a0e999d0efe2a Mon Sep 17 00:00:00 2001 From: mpv Date: Wed, 20 Jul 2022 15:21:47 +0300 Subject: [PATCH] Fix for error in dump of addSphere of older versions, where creation method was not invented. --- src/PrimitivesAPI/PrimitivesAPI_Sphere.cpp | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/PrimitivesAPI/PrimitivesAPI_Sphere.cpp b/src/PrimitivesAPI/PrimitivesAPI_Sphere.cpp index 43cfaa1ae..ac429fb80 100644 --- a/src/PrimitivesAPI/PrimitivesAPI_Sphere.cpp +++ b/src/PrimitivesAPI/PrimitivesAPI_Sphere.cpp @@ -125,12 +125,7 @@ void PrimitivesAPI_Sphere::dump(ModelHighAPI_Dumper& theDumper) const std::string aCreationMethod = aBase->string(PrimitivesPlugin_Sphere::CREATION_METHOD())->value(); - if(aCreationMethod == PrimitivesPlugin_Sphere::CREATION_METHOD_BY_PT_RADIUS()) { - AttributeSelectionPtr anAttrCenterPoint = - aBase->selection(PrimitivesPlugin_Sphere::CENTER_POINT_ID()); - AttributeDoublePtr anAttrRadius = aBase->real(PrimitivesPlugin_Sphere::RADIUS_ID()); - theDumper << ", " << anAttrCenterPoint << ", " << anAttrRadius; - } else if(aCreationMethod == PrimitivesPlugin_Sphere::CREATION_METHOD_BY_DIMENSIONS()) { + if (aCreationMethod == PrimitivesPlugin_Sphere::CREATION_METHOD_BY_DIMENSIONS()) { AttributeDoublePtr anAttrRMin = aBase->real(PrimitivesPlugin_Sphere::RMIN_ID()); AttributeDoublePtr anAttrRMax = aBase->real(PrimitivesPlugin_Sphere::RMAX_ID()); AttributeDoublePtr anAttrPhiMin = aBase->real(PrimitivesPlugin_Sphere::PHIMIN_ID()); @@ -140,6 +135,13 @@ void PrimitivesAPI_Sphere::dump(ModelHighAPI_Dumper& theDumper) const theDumper << ", " << anAttrRMin << ", " << anAttrRMax; theDumper << ", " << anAttrPhiMin << ", " << anAttrPhiMax; theDumper << ", " << anAttrThetaMin << ", " << anAttrThetaMax; + } else { // CREATION_METHOD_BY_PT_RADIUS by default to support versions with undefined method + AttributeSelectionPtr anAttrCenterPoint = + aBase->selection(PrimitivesPlugin_Sphere::CENTER_POINT_ID()); + AttributeDoublePtr anAttrRadius = aBase->real(PrimitivesPlugin_Sphere::RADIUS_ID()); + // for old versions radius value was located in another place, so, use the default 10 + double aRadValue = anAttrRadius->isInitialized() ? anAttrRadius->value() : 10; + theDumper << ", " << anAttrCenterPoint << ", " << aRadValue; } theDumper << ")" << std::endl; -- 2.39.2