X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FBuildPlugin%2FBuildPlugin_Wire.cpp;h=ff29af48add642e820dce8272b15d9ae3b516c50;hb=4656ef7be2170488c06dbc0586f71348be93b5fb;hp=c7caa85812a46170e654e5298e309f35a53b494e;hpb=77d6e03555d0d46232e09ace4178f66f8c9b40ee;p=modules%2Fshaper.git diff --git a/src/BuildPlugin/BuildPlugin_Wire.cpp b/src/BuildPlugin/BuildPlugin_Wire.cpp index c7caa8581..ff29af48a 100644 --- a/src/BuildPlugin/BuildPlugin_Wire.cpp +++ b/src/BuildPlugin/BuildPlugin_Wire.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2014-2019 CEA/DEN, EDF R&D +// Copyright (C) 2014-2022 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 @@ -122,7 +122,10 @@ void BuildPlugin_Wire::execute() 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); + if (anEdgeInList->isSame(anEdgeInResult)) + aResultBody->generated(anEdgeInResult, "Edge"); + else + aResultBody->modified(anEdgeInList, anEdgeInResult); break; } } @@ -144,9 +147,9 @@ void BuildPlugin_Wire::execute() for (ListOfShape::iterator aWIt = aWires.begin(); aWIt != aWires.end(); ++aWIt) { ResultBodyPtr aResultBody = document()->createBody(data(), aResultIndex); - ListOfShape aSketches; - aSketches.push_back(anIt->second); - aResultBody->storeModified(aSketches, *aWIt, aMakeShapeList); + ListOfShape aSketch; + aSketch.push_back(anIt->second); + aResultBody->storeModified(aSketch, *aWIt, aMakeShapeList); aResultBody->loadModifiedShapes(aMakeShapeList, anIt->second, GeomAPI_Shape::EDGE); setResult(aResultBody, aResultIndex); ++aResultIndex; @@ -317,11 +320,16 @@ bool buildSketchWires(FeaturePtr theSketchFeature, GeomShapePtr theSketchShape, const ListOfShape& aFaces = aSketchBuilder->faces(); for (ListOfShape::const_iterator anIt = aFaces.begin(); anIt != aFaces.end(); ++anIt) { for (GeomAPI_ShapeExplorer aWExp(*anIt, GeomAPI_Shape::WIRE); aWExp.more(); aWExp.next()) { + // skip the wire if at least one its edge was already processed GeomAPI_ShapeExplorer aEExp(aWExp.current(), GeomAPI_Shape::EDGE); - if (aProcessedEdges.find(aEExp.current()) != aProcessedEdges.end()) - continue; // wire is already processed + for (; aEExp.more(); aEExp.next()) { + if (aProcessedEdges.find(aEExp.current()) != aProcessedEdges.end()) + break; // wire is already processed + } + if (aEExp.more()) + continue; // mark edges as processed - for (; aEExp.more(); aEExp.next()) + for (aEExp.init(aWExp.current(), GeomAPI_Shape::EDGE); aEExp.more(); aEExp.next()) aProcessedEdges.insert(aEExp.current()); // store the wire theWires.push_back(aWExp.current()); @@ -386,15 +394,24 @@ bool buildSketchWires(FeaturePtr theSketchFeature, GeomShapePtr theSketchShape, aStartV = aEndV; } else { - // both vertices are found => close the loop + // both vertices are found aFoundStart->second->push_back(anEdge); - if (aFoundStart->second != aFoundEnd->second) { + if (aFoundStart->second == aFoundEnd->second) + aMapVW.erase(aFoundStart); + else { + // different wires => merge segments aFoundStart->second->insert(aFoundStart->second->end(), aFoundEnd->second->begin(), aFoundEnd->second->end()); + for (MapVertexWire::iterator it = aMapVW.begin(); it != aMapVW.end(); ++it) + if (it != aFoundEnd && it->second == aFoundEnd->second) { + // another boundary of the wire, change link to the whole result + it->second = aFoundStart->second; + break; + } aNewWires.erase(aFoundEnd->second); + aMapVW.erase(aFoundStart); + aMapVW.erase(aFoundEnd); } - aMapVW.erase(aFoundStart); - aMapVW.erase(aFoundEnd); continue; } }