Skip to content

Commit

Permalink
backport to occt < 6.9
Browse files Browse the repository at this point in the history
  • Loading branch information
wwmayer committed Jun 10, 2018
1 parent f3ac51d commit f90cd4a
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 6 deletions.
8 changes: 6 additions & 2 deletions src/Mod/Part/App/FeaturePartSection.cpp
Expand Up @@ -24,6 +24,7 @@
#include "PreCompiled.h"
#ifndef _PreComp_
# include <BRepAlgoAPI_Section.hxx>
# include <Standard_Version.hxx>
#endif

#include "FeaturePartSection.h"
Expand All @@ -47,10 +48,12 @@ short Section::mustExecute() const
return 0;
}

BRepAlgoAPI_BooleanOperation *Section::makeOperation(const TopoDS_Shape& base, const TopoDS_Shape& tool) const
BRepAlgoAPI_BooleanOperation* Section::makeOperation(const TopoDS_Shape& base, const TopoDS_Shape& tool) const
{
// Let's call algorithm computing a section operation:
// return new BRepAlgoAPI_Section(base, tool);
#if OCC_VERSION_HEX < 0x060900
return new BRepAlgoAPI_Section(base, tool);
#else
bool approx = Approximation.getValue();
BRepAlgoAPI_Section* mkSection = new BRepAlgoAPI_Section();
mkSection->Init1(base);
Expand All @@ -60,4 +63,5 @@ BRepAlgoAPI_BooleanOperation *Section::makeOperation(const TopoDS_Shape& base, c
if (!mkSection->IsDone())
throw Base::RuntimeError("Section failed");
return mkSection;
#endif
}
11 changes: 9 additions & 2 deletions src/Mod/Part/App/TopoShape.cpp
Expand Up @@ -1637,29 +1637,36 @@ TopoDS_Shape TopoShape::oldFuse(TopoDS_Shape shape) const
#endif
}

TopoDS_Shape TopoShape::section(TopoDS_Shape shape, const Standard_Boolean approximate) const
TopoDS_Shape TopoShape::section(TopoDS_Shape shape, Standard_Boolean approximate) const
{
if (this->_Shape.IsNull())
Standard_Failure::Raise("Base shape is null");
if (shape.IsNull())
Standard_Failure::Raise("Tool shape is null");
#if OCC_VERSION_HEX < 0x060900
BRepAlgoAPI_Section mkSection(this->_Shape, shape);
#else
BRepAlgoAPI_Section mkSection;
mkSection.Init1(this->_Shape);
mkSection.Init2(shape);
mkSection.Approximation(approximate);
mkSection.Build();
#endif
if (!mkSection.IsDone())
throw Base::RuntimeError("Section failed");
return mkSection.Shape();
}

TopoDS_Shape TopoShape::section(const std::vector<TopoDS_Shape>& shapes, Standard_Real tolerance, const Standard_Boolean approximate) const
TopoDS_Shape TopoShape::section(const std::vector<TopoDS_Shape>& shapes,
Standard_Real tolerance,
Standard_Boolean approximate) const
{
if (this->_Shape.IsNull())
Standard_Failure::Raise("Base shape is null");
#if OCC_VERSION_HEX < 0x060900
(void)shapes;
(void)tolerance;
(void)approximate;
throw Base::RuntimeError("Multi section is available only in OCC 6.9.0 and up.");
#else
BRepAlgoAPI_Section mkSection;
Expand Down
4 changes: 2 additions & 2 deletions src/Mod/Part/App/TopoShape.h
Expand Up @@ -165,8 +165,8 @@ class PartExport TopoShape : public Data::ComplexGeoData
TopoDS_Shape fuse(TopoDS_Shape) const;
TopoDS_Shape fuse(const std::vector<TopoDS_Shape>&, Standard_Real tolerance = 0.0) const;
TopoDS_Shape oldFuse(TopoDS_Shape) const;
TopoDS_Shape section(TopoDS_Shape, const Standard_Boolean approximate=Standard_False) const;
TopoDS_Shape section(const std::vector<TopoDS_Shape>&, Standard_Real tolerance = 0.0, const Standard_Boolean approximate=Standard_False) const;
TopoDS_Shape section(TopoDS_Shape, Standard_Boolean approximate=Standard_False) const;
TopoDS_Shape section(const std::vector<TopoDS_Shape>&, Standard_Real tolerance = 0.0, Standard_Boolean approximate=Standard_False) const;
std::list<TopoDS_Wire> slice(const Base::Vector3d&, double) const;
TopoDS_Compound slices(const Base::Vector3d&, const std::vector<double>&) const;
/**
Expand Down

0 comments on commit f90cd4a

Please sign in to comment.