cleanup work: overload methods instead of using new method names

This commit is contained in:
wmayer
2017-01-04 15:39:27 +01:00
parent 43ad429734
commit dfbd6aa237
5 changed files with 357 additions and 314 deletions

View File

@@ -1286,6 +1286,42 @@ TopoDS_Shape TopoShape::cut(TopoDS_Shape shape) const
return mkCut.Shape();
}
TopoDS_Shape TopoShape::cut(const std::vector<TopoDS_Shape>& shapes, Standard_Real tolerance) const
{
if (this->_Shape.IsNull())
Standard_Failure::Raise("Base shape is null");
#if OCC_VERSION_HEX < 0x060900
(void)shapes;
(void)tolerance;
throw Base::RuntimeError("Multi cut is available only in OCC 6.9.0 and up.");
#else
BRepAlgoAPI_Cut mkCut;
mkCut.SetRunParallel(true);
TopTools_ListOfShape shapeArguments,shapeTools;
shapeArguments.Append(this->_Shape);
for (std::vector<TopoDS_Shape>::const_iterator it = shapes.begin(); it != shapes.end(); ++it) {
if (it->IsNull())
throw Base::ValueError("Tool shape is null");
if (tolerance > 0.0)
// workaround for http://dev.opencascade.org/index.php?q=node/1056#comment-520
shapeTools.Append(BRepBuilderAPI_Copy(*it).Shape());
else
shapeTools.Append(*it);
}
mkCut.SetArguments(shapeArguments);
mkCut.SetTools(shapeTools);
if (tolerance > 0.0)
mkCut.SetFuzzyValue(tolerance);
mkCut.Build();
if (!mkCut.IsDone())
throw Base::RuntimeError("Multi cut failed");
TopoDS_Shape resShape = mkCut.Shape();
return resShape;
#endif
}
TopoDS_Shape TopoShape::common(TopoDS_Shape shape) const
{
if (this->_Shape.IsNull())
@@ -1296,6 +1332,42 @@ TopoDS_Shape TopoShape::common(TopoDS_Shape shape) const
return mkCommon.Shape();
}
TopoDS_Shape TopoShape::common(const std::vector<TopoDS_Shape>& shapes, Standard_Real tolerance) const
{
if (this->_Shape.IsNull())
Standard_Failure::Raise("Base shape is null");
#if OCC_VERSION_HEX < 0x060900
(void)shapes;
(void)tolerance;
throw Base::RuntimeError("Multi common is available only in OCC 6.9.0 and up.");
#else
BRepAlgoAPI_Common mkCommon;
mkCommon.SetRunParallel(true);
TopTools_ListOfShape shapeArguments,shapeTools;
shapeArguments.Append(this->_Shape);
for (std::vector<TopoDS_Shape>::const_iterator it = shapes.begin(); it != shapes.end(); ++it) {
if (it->IsNull())
throw Base::ValueError("Tool shape is null");
if (tolerance > 0.0)
// workaround for http://dev.opencascade.org/index.php?q=node/1056#comment-520
shapeTools.Append(BRepBuilderAPI_Copy(*it).Shape());
else
shapeTools.Append(*it);
}
mkCommon.SetArguments(shapeArguments);
mkCommon.SetTools(shapeTools);
if (tolerance > 0.0)
mkCommon.SetFuzzyValue(tolerance);
mkCommon.Build();
if (!mkCommon.IsDone())
throw Base::RuntimeError("Multi common failed");
TopoDS_Shape resShape = mkCommon.Shape();
return resShape;
#endif
}
TopoDS_Shape TopoShape::fuse(TopoDS_Shape shape) const
{
if (this->_Shape.IsNull())
@@ -1306,75 +1378,7 @@ TopoDS_Shape TopoShape::fuse(TopoDS_Shape shape) const
return mkFuse.Shape();
}
TopoDS_Shape TopoShape::multiCut(const std::vector<TopoDS_Shape>& shapes, Standard_Real tolerance) const
{
if (this->_Shape.IsNull())
Standard_Failure::Raise("Base shape is null");
#if OCC_VERSION_HEX < 0x060900
(void)shapes;
(void)tolerance;
throw Base::AttributeError("multiCut is available only in OCC 6.9.0 and up.");
#else
BRepAlgoAPI_Cut mkCut;
mkCut.SetRunParallel(true);
TopTools_ListOfShape shapeArguments,shapeTools;
shapeArguments.Append(this->_Shape);
for (std::vector<TopoDS_Shape>::const_iterator it = shapes.begin(); it != shapes.end(); ++it) {
if (it->IsNull())
throw Base::Exception("Tool shape is null");
if (tolerance > 0.0)
// workaround for http://dev.opencascade.org/index.php?q=node/1056#comment-520
shapeTools.Append(BRepBuilderAPI_Copy(*it).Shape());
else
shapeTools.Append(*it);
}
mkCut.SetArguments(shapeArguments);
mkCut.SetTools(shapeTools);
if (tolerance > 0.0)
mkCut.SetFuzzyValue(tolerance);
mkCut.Build();
if (!mkCut.IsDone())
throw Base::Exception("MultiCut failed");
TopoDS_Shape resShape = mkCut.Shape();
return resShape;
#endif
}
TopoDS_Shape TopoShape::multiCommon(const std::vector<TopoDS_Shape>& shapes, Standard_Real tolerance) const
{
if (this->_Shape.IsNull())
Standard_Failure::Raise("Base shape is null");
#if OCC_VERSION_HEX < 0x060900
(void)shapes;
(void)tolerance;
throw Base::AttributeError("multiCommon is available only in OCC 6.9.0 and up.");
#else
BRepAlgoAPI_Common mkCommon;
mkCommon.SetRunParallel(true);
TopTools_ListOfShape shapeArguments,shapeTools;
shapeArguments.Append(this->_Shape);
for (std::vector<TopoDS_Shape>::const_iterator it = shapes.begin(); it != shapes.end(); ++it) {
if (it->IsNull())
throw Base::Exception("Tool shape is null");
if (tolerance > 0.0)
// workaround for http://dev.opencascade.org/index.php?q=node/1056#comment-520
shapeTools.Append(BRepBuilderAPI_Copy(*it).Shape());
else
shapeTools.Append(*it);
}
mkCommon.SetArguments(shapeArguments);
mkCommon.SetTools(shapeTools);
if (tolerance > 0.0)
mkCommon.SetFuzzyValue(tolerance);
mkCommon.Build();
if (!mkCommon.IsDone())
throw Base::Exception("MultiCommon failed");
TopoDS_Shape resShape = mkCommon.Shape();
return resShape;
#endif
}
TopoDS_Shape TopoShape::multiFuse(const std::vector<TopoDS_Shape>& shapes, Standard_Real tolerance) const
TopoDS_Shape TopoShape::fuse(const std::vector<TopoDS_Shape>& shapes, Standard_Real tolerance) const
{
if (this->_Shape.IsNull())
Standard_Failure::Raise("Base shape is null");
@@ -1383,7 +1387,7 @@ TopoDS_Shape TopoShape::multiFuse(const std::vector<TopoDS_Shape>& shapes, Stand
Standard_Failure::Raise("Fuzzy Booleans are not supported in this version of OCCT");
TopoDS_Shape resShape = this->_Shape;
if (resShape.IsNull())
throw Base::Exception("Object shape is null");
throw Base::ValueError("Object shape is null");
for (std::vector<TopoDS_Shape>::const_iterator it = shapes.begin(); it != shapes.end(); ++it) {
if (it->IsNull())
throw Base::Exception("Input shape is null");
@@ -1391,7 +1395,7 @@ TopoDS_Shape TopoShape::multiFuse(const std::vector<TopoDS_Shape>& shapes, Stand
BRepAlgoAPI_Fuse mkFuse(resShape, *it);
// Let's check if the fusion has been successful
if (!mkFuse.IsDone())
throw Base::Exception("Fusion failed");
throw Base::RuntimeError("Fusion failed");
resShape = mkFuse.Shape();
}
#else
@@ -1416,46 +1420,13 @@ TopoDS_Shape TopoShape::multiFuse(const std::vector<TopoDS_Shape>& shapes, Stand
mkFuse.SetFuzzyValue(tolerance);
mkFuse.Build();
if (!mkFuse.IsDone())
throw Base::Exception("MultiFusion failed");
throw Base::RuntimeError("Multi fuse failed");
TopoDS_Shape resShape = mkFuse.Shape();
#endif
return resShape;
}
TopoDS_Shape TopoShape::multiSection(const std::vector<TopoDS_Shape>& shapes, Standard_Real tolerance) const
{
if (this->_Shape.IsNull())
Standard_Failure::Raise("Base shape is null");
#if OCC_VERSION_HEX < 0x060900
(void)shapes;
(void)tolerance;
throw Base::AttributeError("multiSection is available only in OCC 6.9.0 and up.");
#else
BRepAlgoAPI_Section mkSection;
mkSection.SetRunParallel(true);
TopTools_ListOfShape shapeArguments,shapeTools;
shapeArguments.Append(this->_Shape);
for (std::vector<TopoDS_Shape>::const_iterator it = shapes.begin(); it != shapes.end(); ++it) {
if (it->IsNull())
throw Base::Exception("Tool shape is null");
if (tolerance > 0.0)
// workaround for http://dev.opencascade.org/index.php?q=node/1056#comment-520
shapeTools.Append(BRepBuilderAPI_Copy(*it).Shape());
else
shapeTools.Append(*it);
}
mkSection.SetArguments(shapeArguments);
mkSection.SetTools(shapeTools);
if (tolerance > 0.0)
mkSection.SetFuzzyValue(tolerance);
mkSection.Build();
if (!mkSection.IsDone())
throw Base::Exception("MultiSection failed");
TopoDS_Shape resShape = mkSection.Shape();
return resShape;
#endif
}
TopoDS_Shape TopoShape::oldFuse(TopoDS_Shape shape) const
{
if (this->_Shape.IsNull())
@@ -1476,6 +1447,42 @@ TopoDS_Shape TopoShape::section(TopoDS_Shape shape) const
return mkSection.Shape();
}
TopoDS_Shape TopoShape::section(const std::vector<TopoDS_Shape>& shapes, Standard_Real tolerance) const
{
if (this->_Shape.IsNull())
Standard_Failure::Raise("Base shape is null");
#if OCC_VERSION_HEX < 0x060900
(void)shapes;
(void)tolerance;
throw Base::RuntimeError("Multi section is available only in OCC 6.9.0 and up.");
#else
BRepAlgoAPI_Section mkSection;
mkSection.SetRunParallel(true);
TopTools_ListOfShape shapeArguments,shapeTools;
shapeArguments.Append(this->_Shape);
for (std::vector<TopoDS_Shape>::const_iterator it = shapes.begin(); it != shapes.end(); ++it) {
if (it->IsNull())
throw Base::ValueError("Tool shape is null");
if (tolerance > 0.0)
// workaround for http://dev.opencascade.org/index.php?q=node/1056#comment-520
shapeTools.Append(BRepBuilderAPI_Copy(*it).Shape());
else
shapeTools.Append(*it);
}
mkSection.SetArguments(shapeArguments);
mkSection.SetTools(shapeTools);
if (tolerance > 0.0)
mkSection.SetFuzzyValue(tolerance);
mkSection.Build();
if (!mkSection.IsDone())
throw Base::RuntimeError("Multi section failed");
TopoDS_Shape resShape = mkSection.Shape();
return resShape;
#endif
}
std::list<TopoDS_Wire> TopoShape::slice(const Base::Vector3d& dir, double d) const
{
CrossSection cs(dir.x, dir.y, dir.z, this->_Shape);