From: azv Date: Wed, 27 Dec 2017 10:17:49 +0000 (+0300) Subject: Issue #2390: Revolution become invalid after changing parameter X-Git-Tag: V_2.10.1~14 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=d80030ff535f08f4f69ba97361f7c76372629f54;p=modules%2Fshaper.git Issue #2390: Revolution become invalid after changing parameter Do not use FuzzyValue but set correct tolerances for vertices on circular edges when execute Arc feature. --- diff --git a/src/GeomAPI/GeomAPI_Edge.cpp b/src/GeomAPI/GeomAPI_Edge.cpp index 5e72160c5..cf6197337 100644 --- a/src/GeomAPI/GeomAPI_Edge.cpp +++ b/src/GeomAPI/GeomAPI_Edge.cpp @@ -42,6 +42,7 @@ #include #include #include +#include #include @@ -308,3 +309,19 @@ bool GeomAPI_Edge::isDegenerated() const return false; return BRep_Tool::Degenerated(TopoDS::Edge(aShape)); } + +void GeomAPI_Edge::setFirstPointTolerance(const double theTolerance) +{ + TopoDS_Edge anEdge = impl(); + TopoDS_Vertex aVFirst, aVLast; + TopExp::Vertices(anEdge, aVFirst, aVLast); + BRep_Builder().UpdateVertex(aVFirst, theTolerance); +} + +void GeomAPI_Edge::setLastPointTolerance(const double theTolerance) +{ + TopoDS_Edge anEdge = impl(); + TopoDS_Vertex aVFirst, aVLast; + TopExp::Vertices(anEdge, aVFirst, aVLast); + BRep_Builder().UpdateVertex(aVLast, theTolerance); +} diff --git a/src/GeomAPI/GeomAPI_Edge.h b/src/GeomAPI/GeomAPI_Edge.h index ce0f7b559..e7d4910f1 100644 --- a/src/GeomAPI/GeomAPI_Edge.h +++ b/src/GeomAPI/GeomAPI_Edge.h @@ -104,6 +104,12 @@ public: /// Returns true if the edge is degenerated (has no 3D curve) GEOMAPI_EXPORT bool isDegenerated() const; + + GEOMAPI_EXPORT + void setFirstPointTolerance(const double theTolerance); + + GEOMAPI_EXPORT + void setLastPointTolerance(const double theTolerance); }; //! Pointer on attribute object diff --git a/src/GeomAlgoAPI/GeomAlgoAPI_SketchBuilder.cpp b/src/GeomAlgoAPI/GeomAlgoAPI_SketchBuilder.cpp index 5916597b6..a6da1e785 100644 --- a/src/GeomAlgoAPI/GeomAlgoAPI_SketchBuilder.cpp +++ b/src/GeomAlgoAPI/GeomAlgoAPI_SketchBuilder.cpp @@ -199,8 +199,6 @@ void GeomAlgoAPI_SketchBuilder::createFaces( if (theFeatures.empty()) return; - static const double kFUZZY_VALUE = 1.e-5; // tolerance to avoid gaps in contours - BRep_Builder aBuilder; // Planar face, where the sketch was built Handle(Geom_Surface) aPlane(new Geom_Plane(theOrigin->impl(), theNorm->impl())); @@ -220,7 +218,6 @@ void GeomAlgoAPI_SketchBuilder::createFaces( if (anEdge.ShapeType() == TopAbs_EDGE) aBB.AddArgument(anEdge); } - aBB.SetFuzzyValue(kFUZZY_VALUE); aBB.Perform(); #ifdef USE_OCCT_720 if (aBB.HasErrors()) diff --git a/src/SketchPlugin/SketchPlugin_Arc.cpp b/src/SketchPlugin/SketchPlugin_Arc.cpp index d8b03f5a8..87469bdf9 100644 --- a/src/SketchPlugin/SketchPlugin_Arc.cpp +++ b/src/SketchPlugin/SketchPlugin_Arc.cpp @@ -119,16 +119,37 @@ void SketchPlugin_Arc::execute() aCircleForArc->parameter(anEndAttr->pnt(), paramTolerance, myParamBefore); } - GeomShapePtr anArcShape; + bool isReversed = boolean(REVERSED_ID())->value(); + + GeomEdgePtr anArcShape; if (fabs(myParamBefore - 2.0 * PI) < paramTolerance) { anArcShape = GeomAlgoAPI_EdgeBuilder::lineCircle(aCenter, aNormal, aStart->distance(aCenter)); myParamBefore = 0; } else { - anArcShape = boolean(REVERSED_ID())->value() ? + anArcShape = isReversed ? GeomAlgoAPI_EdgeBuilder::lineCircleArc(aCenter, anEnd, aStart, aNormal) : GeomAlgoAPI_EdgeBuilder::lineCircleArc(aCenter, aStart, anEnd, aNormal); } + // calculate tolerances for start and end points of the arc and set them to the result shape + // (this is done to fix gaps which appear because of inaccurate computation of arcs in PlaneGCS, + // which leads to difference in SketchPlugin_Arc attributes and boundary points of result shape) + if (anArcShape) { + for (int ind = 0; ind < 2; ++ind) { + bool isFirst = ind == 0; + GeomPointPtr anArcBndPoint = isFirst == isReversed ? anEnd : aStart; + GeomPointPtr aShapePoint = isFirst ? anArcShape->firstPoint() : anArcShape->lastPoint(); + double aDistance = anArcBndPoint->distance(aShapePoint); + // avoid setting too high tolerance because it may be caused by incomplete update of an arc + if (aDistance > tolerance && aDistance < 100. * tolerance) { + if (isFirst) + anArcShape->setFirstPointTolerance(aDistance); + else + anArcShape->setLastPointTolerance(aDistance); + } + } + } + std::shared_ptr aResult = document()->createConstruction(data(), 1); aResult->setShape(anArcShape); aResult->setIsInHistory(false);