From df02ce077569370eb8e71b1d764fb42258f57381 Mon Sep 17 00:00:00 2001 From: dbv Date: Tue, 19 Apr 2016 15:16:46 +0300 Subject: [PATCH] Fixed wire selection for extrusion and revolution --- .../FeaturesPlugin_CompositeSketch.cpp | 18 +++++------ src/FeaturesPlugin/FeaturesPlugin_Pipe.cpp | 32 +++++++++++++++++-- 2 files changed, 37 insertions(+), 13 deletions(-) diff --git a/src/FeaturesPlugin/FeaturesPlugin_CompositeSketch.cpp b/src/FeaturesPlugin/FeaturesPlugin_CompositeSketch.cpp index 665840127..1759b26b8 100644 --- a/src/FeaturesPlugin/FeaturesPlugin_CompositeSketch.cpp +++ b/src/FeaturesPlugin/FeaturesPlugin_CompositeSketch.cpp @@ -139,17 +139,15 @@ void FeaturesPlugin_CompositeSketch::getBaseShapes(ListOfShape& theBaseShapesLis setError("Error: Selected shapes has unsupported type."); return; } - if(aST == GeomAPI_Shape::WIRE) { - ResultConstructionPtr aConstruction = - std::dynamic_pointer_cast(aBaseObjectSelection->context()); - if(aConstruction.get() && !aBaseShape->isEqual(aConstruction->shape())) { - // It is a wire on the sketch, store it to make face later. - aSketchWiresMap[aConstruction].push_back(aBaseShape); - continue; - } + ResultConstructionPtr aConstruction = + std::dynamic_pointer_cast(aBaseObjectSelection->context()); + if(aConstruction.get() && !aBaseShape->isEqual(aConstruction->shape()) && aST == GeomAPI_Shape::WIRE) { + // It is a wire on the sketch, store it to make face later. + aSketchWiresMap[aConstruction].push_back(aBaseShape); + continue; } else { - aST == GeomAPI_Shape::FACE ? aBaseFacesList.push_back(aBaseShape) : - theBaseShapesList.push_back(aBaseShape); + aST == GeomAPI_Shape::FACE ? aBaseFacesList.push_back(aBaseShape) : + theBaseShapesList.push_back(aBaseShape); } } else { // This may be the whole sketch result selected, check and get faces. diff --git a/src/FeaturesPlugin/FeaturesPlugin_Pipe.cpp b/src/FeaturesPlugin/FeaturesPlugin_Pipe.cpp index 4f3e1675b..101034de0 100644 --- a/src/FeaturesPlugin/FeaturesPlugin_Pipe.cpp +++ b/src/FeaturesPlugin/FeaturesPlugin_Pipe.cpp @@ -15,9 +15,11 @@ #include #include -#include #include +#include +#include +#include #include //================================================================================================= @@ -47,6 +49,7 @@ void FeaturesPlugin_Pipe::execute() // Getting base objects. ListOfShape aBaseShapesList, aBaseFacesList; + std::map aSketchWiresMap; AttributeSelectionListPtr aBaseObjectsSelectionList = selectionList(BASE_OBJECTS_ID()); if(!aBaseObjectsSelectionList.get()) { setError("Error: Could not get base objects selection list."); @@ -64,8 +67,17 @@ void FeaturesPlugin_Pipe::execute() } std::shared_ptr aBaseShape = aBaseObjectSelection->value(); if(aBaseShape.get() && !aBaseShape->isNull()) { - aBaseShape->shapeType() == GeomAPI_Shape::FACE ? aBaseFacesList.push_back(aBaseShape) : - aBaseShapesList.push_back(aBaseShape); + GeomAPI_Shape::ShapeType aST = aBaseShape->shapeType(); + ResultConstructionPtr aConstruction = + std::dynamic_pointer_cast(aBaseObjectSelection->context()); + if(aConstruction.get() && !aBaseShape->isEqual(aConstruction->shape()) && aST == GeomAPI_Shape::WIRE) { + // It is a wire on the sketch, store it to make face later. + aSketchWiresMap[aConstruction].push_back(aBaseShape); + continue; + } else { + aST == GeomAPI_Shape::FACE ? aBaseFacesList.push_back(aBaseShape) : + aBaseShapesList.push_back(aBaseShape); + } } else { // This may be the whole sketch result selected, check and get faces. ResultConstructionPtr aConstruction = std::dynamic_pointer_cast(aBaseObjectSelection->context()); @@ -94,6 +106,20 @@ void FeaturesPlugin_Pipe::execute() } } + // Make faces from sketch wires. + for(std::map::const_iterator anIt = aSketchWiresMap.cbegin(); + anIt != aSketchWiresMap.cend(); ++anIt) { + const std::shared_ptr aSketchPlanarEdges = + std::dynamic_pointer_cast((*anIt).first->shape()); + const ListOfShape& aWiresList = (*anIt).second; + ListOfShape aFaces; + GeomAlgoAPI_ShapeTools::makeFacesWithHoles(aSketchPlanarEdges->origin(), + aSketchPlanarEdges->norm(), + aWiresList, + aFaces); + aBaseFacesList.insert(aBaseFacesList.end(), aFaces.begin(), aFaces.end()); + } + // Searching faces with common edges. if(aCreationMethod == "simple") { ListOfShape aShells; -- 2.39.2