Skip to content

Commit

Permalink
Update method names and clean
Browse files Browse the repository at this point in the history
  • Loading branch information
bgbsww committed Sep 21, 2024
1 parent b2d6787 commit a42cb02
Showing 1 changed file with 16 additions and 17 deletions.
33 changes: 16 additions & 17 deletions src/Mod/PartDesign/App/FeatureHole.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,14 @@
#include <Base/Stream.h>
#include <Base/Tools.h>
#include <Mod/Part/App/FaceMakerCheese.h>
#include <Mod/Part/App/TopoShapeMapper.h>
#include <Mod/Part/App/TopoShapeOpCode.h>

#include "FeatureHole.h"
#include "json.hpp"

Check warning on line 58 in src/Mod/PartDesign/App/FeatureHole.cpp

View workflow job for this annotation

GitHub Actions / Lint / Lint

Include the directory when naming header files [build/include_subdir] [4]

FC_LOG_LEVEL_INIT("PartDesign", true, true);

namespace PartDesign {

/* TRANSLATOR PartDesign::Hole */
Expand Down Expand Up @@ -1885,37 +1889,32 @@ App::DocumentObjectExecReturn* Hole::execute()
std::vector<TopoShape> holes;
auto compound = findHoles(holes, profileshape, protoHole);

TopoShape result(0,getDocument()->getStringHasher());
TopoShape result(0);

// set the subtractive shape property for later usage in e.g. pattern
this->AddSubShape.setValue(compound);
if (isRecomputePaused())
return App::DocumentObject::StdReturn;

if (base.isNull()) {
Shape.setValue(compound);
return App::DocumentObject::StdReturn;
}

// First try cuting with compound which will be faster as it is done in
// First try cutting with compound which will be faster as it is done in
// parallel
bool retry = true;
const char *maker;
switch (getAddSubType()) {
case Additive:
maker = Part::OpCodes::Fuse;
break;
case Intersecting:
maker = Part::OpCodes::Common;
break;
default:
maker = Part::OpCodes::Cut;
}
try {
if (base.isNull())
result = compound;
else
result.makEBoolean(maker, {base,compound});
result.makeElementBoolean(maker, {base,compound});
result = getSolid(result);
retry = false;
} catch (Standard_Failure & e) {
Expand All @@ -1931,20 +1930,20 @@ App::DocumentObjectExecReturn* Hole::execute()
for (auto & hole : holes) {
++i;
try {
result.makEBoolean(maker, {base,hole});
result.makeElementBoolean(maker, {base,hole});
} catch (Standard_Failure &) {
std::string msg(QT_TRANSLATE_NOOP("Exception", "Boolean operation failed on profile Edge"));
msg += std::to_string(i);
return new App::DocumentObjectExecReturn(msg.c_str());
} catch (Base::Exception &e) {
e.ReportException();
std::string msg(QT_TRANSLATE_NOOP("Exception", "Boolean operataion failed on profile Edge"));
std::string msg(QT_TRANSLATE_NOOP("Exception", "Boolean operation failed on profile Edge"));
msg += std::to_string(i);
return new App::DocumentObjectExecReturn(msg.c_str());
}
base = getSolid(result);
if (base.isNull()) {
std::string msg(QT_TRANSLATE_NOOP("Exception", "Boolean operataion produced non-solid on profile Edge"));
std::string msg(QT_TRANSLATE_NOOP("Exception", "Boolean operation produced non-solid on profile Edge"));
msg += std::to_string(i);
return new App::DocumentObjectExecReturn(msg.c_str());
}
Expand Down Expand Up @@ -2030,7 +2029,7 @@ TopoShape Hole::findHoles(std::vector<TopoShape> &holes,
const TopoShape& profileshape,
const TopoDS_Shape& protoHole) const
{
TopoShape result(0,getDocument()->getStringHasher());
TopoShape result(0);

int i = 0;
for(const auto &profileEdge : profileshape.getSubTopoShapes(TopAbs_EDGE)) {
Expand All @@ -2053,16 +2052,16 @@ TopoShape Hole::findHoles(std::vector<TopoShape> &holes,
gp_Pnt(loc.X(), loc.Y(), loc.Z()) );

Part::ShapeMapper mapper;
mapper.populate(true, profileEdge, TopoShape(protoHole).getSubTopoShapes(TopAbs_FACE));
mapper.populate(Part::MappingStatus::Modified, profileEdge, TopoShape(protoHole).getSubTopoShapes(TopAbs_FACE));

TopoShape hole(-getID(), getDocument()->getStringHasher());
hole.makESHAPE(protoHole, mapper, {profileEdge});
TopoShape hole(-getID());
hole.makeShapeWithElementMap(protoHole, mapper, {profileEdge});

// transform and generate element map.
hole = hole.makETransform(localSketchTransformation);
hole = hole.makeElementTransform(localSketchTransformation);
holes.push_back(hole);
}
return TopoShape().makECompound(holes);
return TopoShape().makeElementCompound(holes);
}

TopoDS_Shape Hole::makeThread(const gp_Vec& xDir, const gp_Vec& zDir, double length)
Expand Down

0 comments on commit a42cb02

Please sign in to comment.