X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FGeomAlgoAPI%2FGeomAlgoAPI_Offset.cpp;h=dccf9bd131f4df22ed8ac3542869d74fea253cf8;hb=81baa77e52cb1ade2bfbe5b21e893cc34b03c323;hp=212bef8bdf65914a42f4fa8ab4c7e5a26a2b150e;hpb=50a8df0c6a66da8067b16155e5ae39f8f26a7ebc;p=modules%2Fshaper.git diff --git a/src/GeomAlgoAPI/GeomAlgoAPI_Offset.cpp b/src/GeomAlgoAPI/GeomAlgoAPI_Offset.cpp index 212bef8bd..dccf9bd13 100644 --- a/src/GeomAlgoAPI/GeomAlgoAPI_Offset.cpp +++ b/src/GeomAlgoAPI/GeomAlgoAPI_Offset.cpp @@ -19,8 +19,16 @@ #include "GeomAlgoAPI_Offset.h" +#include + #include +#include + +#include +#include +#include +#include GeomAlgoAPI_Offset::GeomAlgoAPI_Offset(const GeomShapePtr& theShape, const double theOffsetValue) @@ -53,3 +61,45 @@ void GeomAlgoAPI_Offset::generated(const GeomShapePtr theOldShape, // nothing is generated } } + +GeomAlgoAPI_Offset::GeomAlgoAPI_Offset(const GeomPlanePtr& thePlane, + const GeomShapePtr& theEdgeOrWire, + const double theOffsetValue) +{ + // 1. Make wire from edge, if need + TopoDS_Wire aWire; + TopoDS_Shape anEdgeOrWire = theEdgeOrWire->impl(); + if (anEdgeOrWire.ShapeType() == TopAbs_WIRE) { + aWire = TopoDS::Wire(anEdgeOrWire); + } else { + if (anEdgeOrWire.ShapeType() == TopAbs_EDGE) { + BRepBuilderAPI_MakeWire aWireBuilder; + aWireBuilder.Add(TopoDS::Edge(anEdgeOrWire)); + if (aWireBuilder.IsDone()) { + aWire = aWireBuilder.Wire(); + } + } + } + if (aWire.IsNull()) + return; + + // 2. Make invalid face to pass it in Offset algorithm + BRepBuilderAPI_MakeFace aFaceBuilder (thePlane->impl(), aWire); + const TopoDS_Face& aFace = aFaceBuilder.Face(); + + // 3. Make Offset + BRepOffsetAPI_MakeOffset* aParal = new BRepOffsetAPI_MakeOffset; + setImpl(aParal); + setBuilderType(OCCT_BRepBuilderAPI_MakeShape); + + Standard_Boolean isOpenResult = !aWire.Closed(); + aParal->Init(aFace, GeomAbs_Arc, isOpenResult); + aParal->Perform(theOffsetValue, 0.); + if (aParal->IsDone()) { + TopoDS_Shape anOffset = aParal->Shape(); + GeomShapePtr aResult(new GeomAPI_Shape()); + aResult->setImpl(new TopoDS_Shape(anOffset)); + setShape(aResult); + setDone(true); + } +}