X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;ds=sidebyside;f=src%2FBuildPlugin%2FBuildPlugin_Face.cpp;h=022865abdd3682773a3b4a0a1cee2e70858ea434;hb=09365c927ebe8d881de2eda7f96bc33a2d9511c8;hp=391ea4bd908365dd7bfc51564660f58fe3686c1a;hpb=dc7d4d86b58b81684abc9b5a2be8ec30f210c2da;p=modules%2Fshaper.git diff --git a/src/BuildPlugin/BuildPlugin_Face.cpp b/src/BuildPlugin/BuildPlugin_Face.cpp index 391ea4bd9..022865abd 100644 --- a/src/BuildPlugin/BuildPlugin_Face.cpp +++ b/src/BuildPlugin/BuildPlugin_Face.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2014-2017 CEA/DEN, EDF R&D +// Copyright (C) 2014-2019 CEA/DEN, EDF R&D // // This library is free software; you can redistribute it and/or // modify it under the terms of the GNU Lesser General Public @@ -12,10 +12,9 @@ // // You should have received a copy of the GNU Lesser General Public // License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // -// See http://www.salome-platform.org/ or -// email : webmaster.salome@opencascade.com +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // #include "BuildPlugin_Face.h" @@ -28,6 +27,7 @@ #include #include +#include #include #include #include @@ -60,6 +60,9 @@ void BuildPlugin_Face::execute() // Collect base shapes. ListOfShape anEdges; ListOfShape anOriginalFaces; + ListOfShape aContexts; + getOriginalShapesAndContexts(BASE_OBJECTS_ID(), anOriginalFaces, aContexts); + anOriginalFaces.clear(); std::list< std::shared_ptr > aListOfNormals; for(int anIndex = 0; anIndex < aSelectionList->size(); ++anIndex) { AttributeSelectionPtr aSelection = aSelectionList->value(anIndex); @@ -88,8 +91,10 @@ void BuildPlugin_Face::execute() // Build faces by edges. ListOfShape aFaces; + GeomMakeShapePtr aFaceBuilder; if (!anEdges.empty()) - buildFacesByEdges(anEdges, aListOfNormals, aFaces); + buildFacesByEdges(anEdges, aListOfNormals, aFaces, aFaceBuilder); + int aNbFacesFromEdges = (int)aFaces.size(); // Add faces selected by user. aFaces.insert(aFaces.end(), anOriginalFaces.begin(), anOriginalFaces.end()); @@ -97,22 +102,20 @@ void BuildPlugin_Face::execute() // Store result. int anIndex = 0; for(ListOfShape::const_iterator anIt = aFaces.cbegin(); anIt != aFaces.cend(); ++anIt) { - ResultBodyPtr aResultBody = document()->createBody(data(), anIndex); - GeomShapePtr aShape = *anIt; - GeomAlgoAPI_Copy aCopy(aShape); - aShape = aCopy.shape(); - aResultBody->store(aShape); - - // Store edges. - int anEdgeIndex = 1; - for(GeomAPI_ShapeExplorer anExp(aShape, GeomAPI_Shape::EDGE); anExp.more(); anExp.next()) { - GeomShapePtr anEdge = anExp.current(); - aResultBody->generated(anEdge, "Edge_" + std::to_string((long long)anEdgeIndex), anEdgeIndex); - ++anEdgeIndex; - } + std::shared_ptr aMakeShapeList(new GeomAlgoAPI_MakeShapeList); + if (anIndex < aNbFacesFromEdges) + aMakeShapeList->appendAlgo(aFaceBuilder); - setResult(aResultBody, anIndex); - ++anIndex; + GeomShapePtr aShape = *anIt; + GeomMakeShapePtr aCopy(new GeomAlgoAPI_Copy(aShape)); + aMakeShapeList->appendAlgo(aCopy); + + ListOfShape aBaseShapes; + if (anIndex < aNbFacesFromEdges) + aBaseShapes = anEdges; + else + aBaseShapes.push_back(aShape); + storeResult(aMakeShapeList, aBaseShapes, aContexts, aCopy->shape(), anIndex++); } removeResults(anIndex); @@ -121,7 +124,8 @@ void BuildPlugin_Face::execute() void BuildPlugin_Face::buildFacesByEdges( const ListOfShape& theEdges, const std::list< std::shared_ptr >& theNormals, - ListOfShape& theFaces) const + ListOfShape& theFaces, + std::shared_ptr& theBuilderAlgo) const { // Get plane. std::shared_ptr aPln = GeomAlgoAPI_ShapeTools::findPlane(theEdges); @@ -137,8 +141,10 @@ void BuildPlugin_Face::buildFacesByEdges( } // Get faces. - GeomAlgoAPI_SketchBuilder::createFaces(aPln->location(), aPln->xDirection(), - aPln->direction(), theEdges, theFaces); + std::shared_ptr aSketchBuilder( + new GeomAlgoAPI_SketchBuilder(aPln, theEdges)); + theFaces = aSketchBuilder->faces(); + theBuilderAlgo = aSketchBuilder; // Get wires from faces. ListOfShape aWires;