From ebf8304dd67a97f8c9705dd5ac49553915d5ddee Mon Sep 17 00:00:00 2001 From: dish Date: Wed, 14 Aug 2024 13:22:36 +0000 Subject: [PATCH] [bos #35154][EDF](2023-T1) Edge thickness. --- .../ExchangePlugin_ExportFeature.cpp | 22 +++++++++---------- src/Model/Model_Objects.cpp | 10 +++++---- src/PrimitivesPlugin/PrimitivesPlugin_Box.h | 18 +++++++++++++-- 3 files changed, 33 insertions(+), 17 deletions(-) diff --git a/src/ExchangePlugin/ExchangePlugin_ExportFeature.cpp b/src/ExchangePlugin/ExchangePlugin_ExportFeature.cpp index 9fb5a8a22..cdcddd2ac 100644 --- a/src/ExchangePlugin/ExchangePlugin_ExportFeature.cpp +++ b/src/ExchangePlugin/ExchangePlugin_ExportFeature.cpp @@ -223,7 +223,7 @@ void ExchangePlugin_ExportFeature::exportFile(const std::string& theFileName, } else if (aFormatName == "STL") { exportSTL(theFileName); return; - }else if (aFormatName == "STEP") { + } else if (aFormatName == "STEP") { exportSTEP(theFileName); return; } @@ -655,26 +655,27 @@ void ExchangePlugin_ExportFeature::exportSTEP(const std::string & theFileName) std::list aShapeList; std::string anError; std::map> aColoredShapes; - for (int anIndex = 0; anIndex < aSelectionList->size(); ++anIndex) - { + for (int anIndex = 0; anIndex < aSelectionList->size(); ++anIndex) { AttributeSelectionPtr anAttrSelection = aSelectionList->value(anIndex); std::shared_ptr aCurShape = anAttrSelection->value(); if (!aCurShape.get()) aCurShape = anAttrSelection->context()->shape(); + if (!aCurShape.get()) continue; - //#ifndef HAVE_SALOME + + //#ifndef HAVE_SALOME ResultPtr aRes = anAttrSelection->context(); std::vector aColor; ModelAPI_Tools::getColor(aRes, aColor); ModelAPI_Tools::getColoredShapes(aRes, aColoredShapes); if (aColor.size() == 3) - { aColoredShapes[aCurShape] = aColor; - } - //#endif + + //#endif aShapeList.push_back(aCurShape); - } + } + std::shared_ptr aShape = aShapeList.size() == 1 ? aShapeList.front() : GeomAlgoAPI_CompoundBuilder::compound(aShapeList); #ifndef HAVE_SALOME @@ -683,12 +684,11 @@ void ExchangePlugin_ExportFeature::exportSTEP(const std::string & theFileName) bool aRes = STEPExport(theFileName, aShape, aColoredShapes, anError); #endif - if (!anError.empty() || !aRes) - { + if (!anError.empty() || !aRes) { setError("An error occurred while exporting " + theFileName + ": " + anError); return; - } } +} bool ExchangePlugin_ExportFeature::isMacro() const { diff --git a/src/Model/Model_Objects.cpp b/src/Model/Model_Objects.cpp index 570423b9d..56af66544 100644 --- a/src/Model/Model_Objects.cpp +++ b/src/Model/Model_Objects.cpp @@ -592,8 +592,9 @@ ObjectPtr Model_Objects::object(TDF_Label theLabel) FeaturePtr aFeature = feature(theLabel); if (aFeature.get()) return feature(theLabel); + TDF_Label aFeatureLabel = theLabel; // let's suppose it is result of this feature - TDF_LabelList aSubLabs; // sub - labels from higher level to lower level of result + TDF_LabelList aSubLabs; // sub - labels from higher level to lower level of result // Maybe these are superlabels? while(!aFeature.get() && aFeatureLabel.Depth() > 1) { aSubLabs.Prepend(aFeatureLabel); aFeatureLabel = aFeatureLabel.Father().Father(); @@ -607,6 +608,7 @@ ObjectPtr Model_Objects::object(TDF_Label theLabel) ResultBodyPtr anOwner = std::dynamic_pointer_cast(aCurrentResult); if (!anOwner) return ObjectPtr(); // only Body can have sub-results + int a, aNumSubs = anOwner->numberOfSubs(); for(a = 0; a < aNumSubs; a++) { ResultPtr aSub = anOwner->subResult(a); @@ -622,7 +624,8 @@ ObjectPtr Model_Objects::object(TDF_Label theLabel) } if (a == aNumSubs) // not found an appropriate sub-result of result return ObjectPtr(); - } else { // iterate results of feature + } + else { // iterate results of feature const std::list& aResults = aFeature->results(); std::list >::const_iterator aRIter = aResults.cbegin(); for(; aRIter != aResults.cend(); aRIter++) { @@ -1432,8 +1435,7 @@ void Model_Objects::synchronizeBackRefs() TDF_Label Model_Objects::resultLabel( const std::shared_ptr& theFeatureData, const int theResultIndex) { - const std::shared_ptr& aData = - std::dynamic_pointer_cast(theFeatureData); + const std::shared_ptr& aData = std::dynamic_pointer_cast(theFeatureData); return aData->label().Father().FindChild(TAG_FEATURE_RESULTS).FindChild(theResultIndex + 1); } diff --git a/src/PrimitivesPlugin/PrimitivesPlugin_Box.h b/src/PrimitivesPlugin/PrimitivesPlugin_Box.h index ce4a2ddef..00f6787f6 100644 --- a/src/PrimitivesPlugin/PrimitivesPlugin_Box.h +++ b/src/PrimitivesPlugin/PrimitivesPlugin_Box.h @@ -33,7 +33,7 @@ class ModelAPI_ResultBody; * * Box creates a cuboid - Parallelepiped with 6 rectangular faces. It can be built via three * methods : using two points that define a diagonal, a point that define a center and 3 lengths - * that define the half-lengths on X, Y and Z-axes, or using 3 lengths that define the + * that define the half-lengths on X, Y and Z-axes, or using 3 lengths that define the * rectangular dimensions. */ class PrimitivesPlugin_Box : public ModelAPI_Feature @@ -60,7 +60,21 @@ class PrimitivesPlugin_Box : public ModelAPI_Feature return MY_CREATION_METHOD_ID; } - /// Attribute name for creation method + /// Attribute name for creation method// Load the result + theResultBox->store(theBoxAlgo->shape()); + + // Prepare the naming + theBoxAlgo->prepareNamingFaces(); + + // Insert to faces + std::map< std::string, std::shared_ptr > listOfFaces = + theBoxAlgo->getCreatedFaces(); + for (std::map< std::string, std::shared_ptr >::iterator it = listOfFaces.begin(); + it != listOfFaces.end(); + ++it) + { + theResultBox->generated((*it).second, (*it).first); + }s inline static const std::string& CREATION_METHOD_BY_TWO_POINTS() { static const std::string MY_CREATION_METHOD_ID("BoxByTwoPoints"); -- 2.39.2