#include "GeomAlgoAPI_Offset.h"
#include <BRepOffsetAPI_MakeOffsetShape.hxx>
+#include <BRepOffsetAPI_MakeOffset.hxx>
+#include <BRepBuilderAPI_MakeWire.hxx>
+#include <BRepBuilderAPI_MakeFace.hxx>
+
+#include <TopoDS.hxx>
+#include <TopoDS_Wire.hxx>
GeomAlgoAPI_Offset::GeomAlgoAPI_Offset(const GeomShapePtr& theShape,
const double theOffsetValue)
// nothing is generated
}
}
+
+//GeomShapePtr GeomAlgoAPI_Offset::OffsetInPlane (const std::shared_ptr<GeomAPI_Pln>& thePlane,
+// const ListOfShape& theEdgesAndWires,
+// const double theOffsetValue)
+//{
+//}
+
+GeomShapePtr GeomAlgoAPI_Offset::OffsetInPlane (const std::shared_ptr<GeomAPI_Pln>& thePlane,
+ const GeomShapePtr& theEdgeOrWire,
+ const double theOffsetValue)
+{
+ GeomShapePtr aResult;
+
+ // 1. Make wire from edge, if need
+ TopoDS_Wire aWire;
+ TopoDS_Shape anEdgeOrWire = theEdgeOrWire->impl<TopoDS_Shape>();
+ 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 aResult;
+
+ // 2. Make invalid face to pass it in Offset algorithm
+ BRepBuilderAPI_MakeFace aFaceBuilder (thePlane->impl<gp_Pln>(), aWire);
+ const TopoDS_Face& aFace = aFaceBuilder.Face();
+
+ // 3. Make Offset
+ BRepOffsetAPI_MakeOffset aParal;
+ aParal.Init(aFace, GeomAbs_Arc, Standard_True);
+ aParal.Perform(theOffsetValue, 0.);
+ if (aParal.IsDone()) {
+ TopoDS_Shape anOffset = aParal.Shape();
+ aResult.reset(new GeomAPI_Shape());
+ aResult->setImpl(new TopoDS_Shape(anOffset));
+ }
+
+ return aResult;
+}
#include <GeomAlgoAPI.h>
#include <GeomAlgoAPI_MakeShape.h>
+#include <GeomAPI_Pln.h>
+
/// \class GeomAlgoAPI_Offset
/// \ingroup DataAlgo
/// \brief Perform 3D offset for the shape
GEOMALGOAPI_EXPORT virtual void generated(const GeomShapePtr theOldShape,
ListOfShape& theNewShapes);
+ /// \return a compound of offset wires
+ /// \param[in] thePlane base plane for all offsets
+ /// \param[in] theEdgesAndWires base shapes
+ /// \param[in] theOffsetValue offset distance, it can be negative
+ //GEOMALGOAPI_EXPORT static GeomShapePtr OffsetInPlane (const std::shared_ptr<GeomAPI_Pln>& thePlane,
+ // const ListOfShape& theEdgesAndWires,
+ // const double theOffsetValue);
+ GEOMALGOAPI_EXPORT static GeomShapePtr OffsetInPlane (const std::shared_ptr<GeomAPI_Pln>& thePlane,
+ const GeomShapePtr& theEdgeOrWire,
+ const double theOffsetValue);
+
private:
/// \brief Perform offset operation
void build(const GeomShapePtr& theShape, const double theOffsetValue);