X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FBuildPlugin%2FBuildPlugin_Face.cpp;h=774cfdf39787a3745719e15fd8cca67d90e8f009;hb=b38bb339a84175749f2742d906db858e3377c86b;hp=fddd223f053a505c2d48cb5b063e7b2a70dbb38f;hpb=a8cfbfb436c27ff96edd5c808e9a452c35cef207;p=modules%2Fshaper.git diff --git a/src/BuildPlugin/BuildPlugin_Face.cpp b/src/BuildPlugin/BuildPlugin_Face.cpp index fddd223f0..774cfdf39 100644 --- a/src/BuildPlugin/BuildPlugin_Face.cpp +++ b/src/BuildPlugin/BuildPlugin_Face.cpp @@ -10,6 +10,7 @@ #include #include +#include #include #include @@ -43,24 +44,43 @@ void BuildPlugin_Face::execute() // Collect base shapes. ListOfShape anEdges; + std::list< std::shared_ptr > aListOfNormals; for(int anIndex = 0; anIndex < aSelectionList->size(); ++anIndex) { AttributeSelectionPtr aSelection = aSelectionList->value(anIndex); GeomShapePtr aShape = aSelection->value(); + GeomShapePtr aContext = aSelection->context()->shape(); if(!aShape.get()) { - aShape = aSelection->context()->shape(); + aShape = aContext; } for(GeomAPI_ShapeExplorer anExp(aShape, GeomAPI_Shape::EDGE); anExp.more(); anExp.next()) { GeomShapePtr anEdge = anExp.current(); anEdges.push_back(anEdge); } + + // check whether the context is a sketch, in this case store its normal for further needs + std::shared_ptr aSketch = + std::dynamic_pointer_cast(aContext); + if (aSketch) + aListOfNormals.push_back(aSketch->norm()); } // Get plane. std::shared_ptr aPln = GeomAlgoAPI_ShapeTools::findPlane(anEdges); + std::shared_ptr aNormal = aPln->direction(); + bool isReverse = !aListOfNormals.empty(); + std::list< std::shared_ptr >::const_iterator aNormIt = aListOfNormals.begin(); + for (; aNormIt != aListOfNormals.end() && isReverse; ++aNormIt) + if ((*aNormIt)->dot(aNormal) > 1.e-7) + isReverse = false; + if (isReverse) { + aNormal->reverse(); + aPln = std::shared_ptr(new GeomAPI_Pln(aPln->location(), aNormal)); + } // Get faces. ListOfShape aFaces; - GeomAlgoAPI_SketchBuilder::createFaces(aPln->location(), aPln->xDirection(), aPln->direction(), anEdges, aFaces); + GeomAlgoAPI_SketchBuilder::createFaces(aPln->location(), aPln->xDirection(), + aPln->direction(), anEdges, aFaces); // Get wires from faces. ListOfShape aWires; @@ -85,12 +105,16 @@ void BuildPlugin_Face::execute() GeomShapePtr aShape = *anIt; aResultBody->store(aShape); + int anEdgeIndex = 1; + for(GeomAPI_ShapeExplorer anExp(aShape, GeomAPI_Shape::EDGE); anExp.more(); anExp.next()) { GeomShapePtr anEdgeInResult = anExp.current(); for(ListOfShape::const_iterator anIt = anEdges.cbegin(); anIt != anEdges.cend(); ++anIt) { std::shared_ptr anEdgeInList(new GeomAPI_Edge(*anIt)); if(anEdgeInList->isEqual(anEdgeInResult)) { - aResultBody->modified(anEdgeInList, anEdgeInResult, "Edge"); + aResultBody->modified(anEdgeInList, anEdgeInResult, + "Edge_" + std::to_string((long long)anEdgeIndex), anEdgeIndex); + ++anEdgeIndex; break; } }