From 66352ff97e5213cdf3ea8f90ed31a6d3d1803983 Mon Sep 17 00:00:00 2001 From: dbv Date: Thu, 17 Nov 2016 11:22:50 +0300 Subject: [PATCH] Issue #1866: Naming incorrect on edges after translation Fixed naming for edges after translation, rotation and placement. --- src/FeaturesPlugin/CMakeLists.txt | 2 + .../FeaturesPlugin_Placement.cpp | 25 ++-------- .../FeaturesPlugin_Rotation.cpp | 24 ++------- src/FeaturesPlugin/FeaturesPlugin_Tools.cpp | 50 +++++++++++++++++++ src/FeaturesPlugin/FeaturesPlugin_Tools.h | 24 +++++++++ .../FeaturesPlugin_Translation.cpp | 24 ++------- 6 files changed, 88 insertions(+), 61 deletions(-) create mode 100644 src/FeaturesPlugin/FeaturesPlugin_Tools.cpp create mode 100644 src/FeaturesPlugin/FeaturesPlugin_Tools.h diff --git a/src/FeaturesPlugin/CMakeLists.txt b/src/FeaturesPlugin/CMakeLists.txt index 34a303c08..8afae28a6 100644 --- a/src/FeaturesPlugin/CMakeLists.txt +++ b/src/FeaturesPlugin/CMakeLists.txt @@ -28,6 +28,7 @@ SET(PROJECT_HEADERS FeaturesPlugin_ValidatorTransform.h FeaturesPlugin_Validators.h FeaturesPlugin_RemoveSubShapes.h + FeaturesPlugin_Tools.h ) SET(PROJECT_SOURCES @@ -54,6 +55,7 @@ SET(PROJECT_SOURCES FeaturesPlugin_ValidatorTransform.cpp FeaturesPlugin_Validators.cpp FeaturesPlugin_RemoveSubShapes.cpp + FeaturesPlugin_Tools.cpp ) SET(XML_RESOURCES diff --git a/src/FeaturesPlugin/FeaturesPlugin_Placement.cpp b/src/FeaturesPlugin/FeaturesPlugin_Placement.cpp index 5702921e2..c33514085 100644 --- a/src/FeaturesPlugin/FeaturesPlugin_Placement.cpp +++ b/src/FeaturesPlugin/FeaturesPlugin_Placement.cpp @@ -20,6 +20,8 @@ #include #include +#include + FeaturesPlugin_Placement::FeaturesPlugin_Placement() { } @@ -191,28 +193,9 @@ void FeaturesPlugin_Placement::loadNamingDS(GeomAlgoAPI_Transform& theTransformA //load result theResultBody->storeModified(theBaseShape, theTransformAlgo.shape()); - std::shared_ptr aSubShapes = theTransformAlgo.mapOfSubShapes(); - - // put modifed faces in DF int aPlacedTag = 1; std::string aPlacedName = "Placed"; + std::shared_ptr aSubShapes = theTransformAlgo.mapOfSubShapes(); - switch(theBaseShape->shapeType()) { - case GeomAPI_Shape::COMPOUND: - case GeomAPI_Shape::COMPSOLID: - case GeomAPI_Shape::SOLID: - case GeomAPI_Shape::SHELL: - theResultBody->loadAndOrientModifiedShapes(&theTransformAlgo, - theBaseShape, GeomAPI_Shape::FACE, - aPlacedTag, aPlacedName + "_Face", *aSubShapes.get()); - case GeomAPI_Shape::FACE: - case GeomAPI_Shape::WIRE: - theResultBody->loadAndOrientModifiedShapes(&theTransformAlgo, - theBaseShape, GeomAPI_Shape::EDGE, - ++aPlacedTag, aPlacedName + "_Edge", *aSubShapes.get()); - case GeomAPI_Shape::EDGE: - theResultBody->loadAndOrientModifiedShapes(&theTransformAlgo, - theBaseShape, GeomAPI_Shape::VERTEX, - ++aPlacedTag, aPlacedName + "_Vertex", *aSubShapes.get()); - } + FeaturesPlugin_Tools::storeModifiedShapes(theTransformAlgo, theResultBody, theBaseShape, aPlacedTag, aPlacedName, *aSubShapes.get()); } diff --git a/src/FeaturesPlugin/FeaturesPlugin_Rotation.cpp b/src/FeaturesPlugin/FeaturesPlugin_Rotation.cpp index 1e0dd3c29..ac2c10ca0 100755 --- a/src/FeaturesPlugin/FeaturesPlugin_Rotation.cpp +++ b/src/FeaturesPlugin/FeaturesPlugin_Rotation.cpp @@ -14,6 +14,8 @@ #include #include +#include + //================================================================================================= FeaturesPlugin_Rotation::FeaturesPlugin_Rotation() { @@ -126,27 +128,9 @@ void FeaturesPlugin_Rotation::loadNamingDS(GeomAlgoAPI_Rotation& theRotaionAlgo, // Store result. theResultBody->storeModified(theBaseShape, theRotaionAlgo.shape()); - std::shared_ptr aSubShapes = theRotaionAlgo.mapOfSubShapes(); - int aRotatedTag = 1; std::string aRotatedName = "Rotated"; + std::shared_ptr aSubShapes = theRotaionAlgo.mapOfSubShapes(); - switch(theBaseShape->shapeType()) { - case GeomAPI_Shape::COMPOUND: - case GeomAPI_Shape::COMPSOLID: - case GeomAPI_Shape::SOLID: - case GeomAPI_Shape::SHELL: - theResultBody->loadAndOrientModifiedShapes(&theRotaionAlgo, - theBaseShape, GeomAPI_Shape::FACE, - aRotatedTag, aRotatedName + "_Face", *aSubShapes.get()); - case GeomAPI_Shape::FACE: - case GeomAPI_Shape::WIRE: - theResultBody->loadAndOrientModifiedShapes(&theRotaionAlgo, - theBaseShape, GeomAPI_Shape::EDGE, - ++aRotatedTag, aRotatedName + "_Edge", *aSubShapes.get()); - case GeomAPI_Shape::EDGE: - theResultBody->loadAndOrientModifiedShapes(&theRotaionAlgo, - theBaseShape, GeomAPI_Shape::VERTEX, - ++aRotatedTag, aRotatedName + "_Vertex", *aSubShapes.get()); - } + FeaturesPlugin_Tools::storeModifiedShapes(theRotaionAlgo, theResultBody, theBaseShape, aRotatedTag, aRotatedName, *aSubShapes.get()); } diff --git a/src/FeaturesPlugin/FeaturesPlugin_Tools.cpp b/src/FeaturesPlugin/FeaturesPlugin_Tools.cpp new file mode 100644 index 000000000..22431b98b --- /dev/null +++ b/src/FeaturesPlugin/FeaturesPlugin_Tools.cpp @@ -0,0 +1,50 @@ +// Copyright (C) 2014-20xx CEA/DEN, EDF R&D + +// File: FeaturesPlugin_Tools.cpp +// Created: 17 November 2016 +// Author: Dmitry Bobylev + +#include "FeaturesPlugin_Tools.h" + +#include + +#include + +void FeaturesPlugin_Tools::storeModifiedShapes(GeomAlgoAPI_MakeShape& theAlgo, + std::shared_ptr theResultBody, + std::shared_ptr theBaseShape, + int& theTag, + const std::string theName, + GeomAPI_DataMapOfShapeShape& theSubShapes) +{ + switch(theBaseShape->shapeType()) { + case GeomAPI_Shape::COMPOUND: { + for(GeomAPI_ShapeIterator anIt(theBaseShape); anIt.more(); anIt.next()) + { + storeModifiedShapes(theAlgo, theResultBody, theBaseShape, theTag, theName, theSubShapes); + theTag++; + } + break; + } + case GeomAPI_Shape::COMPSOLID: + case GeomAPI_Shape::SOLID: + case GeomAPI_Shape::SHELL: { + theResultBody->loadAndOrientModifiedShapes(&theAlgo, + theBaseShape, GeomAPI_Shape::FACE, + theTag, theName + "_Face", theSubShapes); + if (theBaseShape->shapeType() == GeomAPI_Shape::COMPSOLID + || theBaseShape->shapeType() == GeomAPI_Shape::SOLID) { + break; + } + } + case GeomAPI_Shape::FACE: + case GeomAPI_Shape::WIRE: + theResultBody->loadAndOrientModifiedShapes(&theAlgo, + theBaseShape, GeomAPI_Shape::EDGE, + ++theTag, theName + "_Edge", theSubShapes); + case GeomAPI_Shape::EDGE: + theResultBody->loadAndOrientModifiedShapes(&theAlgo, + theBaseShape, GeomAPI_Shape::VERTEX, + ++theTag, theName + "_Vertex", theSubShapes); + } +} diff --git a/src/FeaturesPlugin/FeaturesPlugin_Tools.h b/src/FeaturesPlugin/FeaturesPlugin_Tools.h new file mode 100644 index 000000000..c6cd120db --- /dev/null +++ b/src/FeaturesPlugin/FeaturesPlugin_Tools.h @@ -0,0 +1,24 @@ +// Copyright (C) 2014-20xx CEA/DEN, EDF R&D + +// File: FeaturesPlugin_Tools.h +// Created: 17 November 2016 +// Author: Dmitry Bobylev + +#ifndef FeaturesPlugin_Tools_H_ +#define FeaturesPlugin_Tools_H_ + +#include + +class ModelAPI_ResultBody; + +class FeaturesPlugin_Tools { +public: + static void storeModifiedShapes(GeomAlgoAPI_MakeShape& theAlgo, + std::shared_ptr theResultBody, + std::shared_ptr theBaseShape, + int& theTag, + const std::string theName, + GeomAPI_DataMapOfShapeShape& theSubShapes); +}; + +#endif /* FeaturesPlugin_Tools_H_ */ diff --git a/src/FeaturesPlugin/FeaturesPlugin_Translation.cpp b/src/FeaturesPlugin/FeaturesPlugin_Translation.cpp index 30b64de12..dea6df9f4 100644 --- a/src/FeaturesPlugin/FeaturesPlugin_Translation.cpp +++ b/src/FeaturesPlugin/FeaturesPlugin_Translation.cpp @@ -16,6 +16,8 @@ #include #include +#include + //================================================================================================= FeaturesPlugin_Translation::FeaturesPlugin_Translation() { @@ -130,27 +132,9 @@ void FeaturesPlugin_Translation::loadNamingDS(GeomAlgoAPI_Translation& theTransl // Store result. theResultBody->storeModified(theBaseShape, theTranslationAlgo.shape()); - std::shared_ptr aSubShapes = theTranslationAlgo.mapOfSubShapes(); - int aTranslatedTag = 1; std::string aTranslatedName = "Translated"; + std::shared_ptr aSubShapes = theTranslationAlgo.mapOfSubShapes(); - switch(theBaseShape->shapeType()) { - case GeomAPI_Shape::COMPOUND: - case GeomAPI_Shape::COMPSOLID: - case GeomAPI_Shape::SOLID: - case GeomAPI_Shape::SHELL: - theResultBody->loadAndOrientModifiedShapes(&theTranslationAlgo, - theBaseShape, GeomAPI_Shape::FACE, - aTranslatedTag, aTranslatedName + "_Face", *aSubShapes.get()); - case GeomAPI_Shape::FACE: - case GeomAPI_Shape::WIRE: - theResultBody->loadAndOrientModifiedShapes(&theTranslationAlgo, - theBaseShape, GeomAPI_Shape::EDGE, - ++aTranslatedTag, aTranslatedName + "_Edge", *aSubShapes.get()); - case GeomAPI_Shape::EDGE: - theResultBody->loadAndOrientModifiedShapes(&theTranslationAlgo, - theBaseShape, GeomAPI_Shape::VERTEX, - ++aTranslatedTag, aTranslatedName + "_Vertex", *aSubShapes.get()); - } + FeaturesPlugin_Tools::storeModifiedShapes(theTranslationAlgo, theResultBody, theBaseShape, aTranslatedTag, aTranslatedName, *aSubShapes.get()); } -- 2.30.2