From: mbs Date: Fri, 2 Dec 2022 09:35:32 +0000 (+0000) Subject: * store result only after checking if sewn X-Git-Tag: V9_11_0a1~36 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=b928c27cd38f150c23d182df53c23ab266aa6b49;p=modules%2Fshaper.git * store result only after checking if sewn * fixed isSewn method * code cleanup --- diff --git a/src/FeaturesPlugin/FeaturesPlugin_Sewing.cpp b/src/FeaturesPlugin/FeaturesPlugin_Sewing.cpp index 8282f66c1..c8319e6fc 100644 --- a/src/FeaturesPlugin/FeaturesPlugin_Sewing.cpp +++ b/src/FeaturesPlugin/FeaturesPlugin_Sewing.cpp @@ -19,43 +19,26 @@ #include -//#include #include #include -//#include #include -//#include -//#include #include #include #include #include -//#include - -//--------------------------------------------------------- -// #define USE_DEBUG -// #define DEBUG -// static const char *dbg_class = "FeaturesPlugin_Sewing"; -// #include "MBDebug.h" -// #include "MBModel.h" -// #include "MBGeom.h" -//--------------------------------------------------------- //================================================================================================= FeaturesPlugin_Sewing::FeaturesPlugin_Sewing() { -// DBG_FUN(); } //================================================================================================= void FeaturesPlugin_Sewing::initAttributes() { -// DBG_FUN(); - data()->addAttribute(OBJECTS_LIST_ID(), ModelAPI_AttributeSelectionList::typeId()); data()->addAttribute(ALLOW_NON_MANIFOLD_ID(), ModelAPI_AttributeBoolean::typeId()); data()->addAttribute(TOLERANCE_ID(), ModelAPI_AttributeDouble::typeId()); @@ -65,40 +48,26 @@ void FeaturesPlugin_Sewing::initAttributes() //================================================================================================= void FeaturesPlugin_Sewing::execute() { -// DBG_FUN(); - // Collect all base shapes ListOfShape aShapes; getOriginalShapes(OBJECTS_LIST_ID(), aShapes); -// SHOW(aShapes); // Get all other feature arguments bool isAllowNonManifold = boolean(FeaturesPlugin_Sewing::ALLOW_NON_MANIFOLD_ID())->value(); bool isAlwaysCreateResult = boolean(FeaturesPlugin_Sewing::ALWAYS_CREATE_RESULT_ID())->value(); double aTolerance = real(FeaturesPlugin_Sewing::TOLERANCE_ID())->value(); - // SHOW(isAllowNonManifold); - // SHOW(isAlwaysCreateResult); - // SHOW(aTolerance); std::shared_ptr aSewingAlgo(new GeomAlgoAPI_Sewing(aShapes, isAllowNonManifold, aTolerance)); std::string anError; if (GeomAlgoAPI_Tools::AlgoError::isAlgorithmFailed(aSewingAlgo, getKind(), anError)) { - // SHOW(anError); setError(anError); return; } // Store result. GeomShapePtr aResult = aSewingAlgo->shape(); - // SHOW(aResult); - - int anIndex = 0; - ResultBodyPtr aResultBody = document()->createBody(data(), anIndex); - // SHOW(aResultBody); - aResultBody->storeModified(aShapes, aResult, aSewingAlgo); - // SHOW(aResultBody); if (!isSewn(aShapes, aResult) && !isAlwaysCreateResult) { @@ -107,6 +76,10 @@ void FeaturesPlugin_Sewing::execute() return; } + int anIndex = 0; + ResultBodyPtr aResultBody = document()->createBody(data(), anIndex); + aResultBody->storeModified(aShapes, aResult, aSewingAlgo); + setResult(aResultBody, anIndex); } @@ -114,9 +87,6 @@ void FeaturesPlugin_Sewing::execute() void FeaturesPlugin_Sewing::getOriginalShapes(const std::string& theAttributeName, ListOfShape& theShapes) { - // DBG_FUN(); - // ARG(theAttributeName); - // Collect all selections into a single list of shapes AttributeSelectionListPtr aSelectionList = selectionList(theAttributeName); for (int anIndex = 0; anIndex < aSelectionList->size(); ++anIndex) @@ -136,10 +106,6 @@ void FeaturesPlugin_Sewing::getOriginalShapes(const std::string& theAttributeNam bool FeaturesPlugin_Sewing::isSewn(const ListOfShape& theInputs, const GeomShapePtr theResult) { - // DBG_FUN(); - // ARG(theInputs); - // ARG(theResult); - // Consider the list of input shapes the same as the result, if // * both arguments have the same number of shells // * the total number of faces in these shells did NOT change. @@ -155,13 +121,10 @@ bool FeaturesPlugin_Sewing::isSewn(const ListOfShape& theInputs, nbInputFaces += aShape->subShapes(GeomAPI_Shape::FACE, true).size(); } } - // SHOW(nbInputShells); - // SHOW(nbInputFaces); int nbResultShells = 0, nbResultFaces = 0; if (theResult->isCompound()) { - // MSGEL("...result is COMPOUND"); ListOfShape shells = theResult->subShapes(GeomAPI_Shape::SHELL, true); nbResultShells = shells.size(); for (ListOfShape::const_iterator anIt = shells.cbegin(); @@ -177,12 +140,9 @@ bool FeaturesPlugin_Sewing::isSewn(const ListOfShape& theInputs, } else if (theResult->isShell()) { - // MSGEL("...result is single SHELL"); nbResultShells = 1; nbResultFaces = theResult->subShapes(GeomAPI_Shape::FACE, true).size(); } - // SHOW(nbResultShells); - // SHOW(nbResultFaces); - return (nbResultShells >= nbInputShells && nbResultFaces > nbInputFaces); + return (nbResultShells > nbInputShells || (nbResultShells == nbInputShells && nbResultFaces > nbInputFaces)); } diff --git a/src/FeaturesPlugin/FeaturesPlugin_Sewing.h b/src/FeaturesPlugin/FeaturesPlugin_Sewing.h index 815ad1aac..2a368f6f3 100644 --- a/src/FeaturesPlugin/FeaturesPlugin_Sewing.h +++ b/src/FeaturesPlugin/FeaturesPlugin_Sewing.h @@ -23,7 +23,6 @@ #include #include -//#include #include