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 22, 2024
1 parent b2d6787 commit 34a4da7
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 20 deletions.
36 changes: 19 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,27 +1930,30 @@ 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());
}
}
result = base;
}

if (!isSingleSolidRuleSatisfied(result.getShape())) {
return new App::DocumentObjectExecReturn(
QT_TRANSLATE_NOOP("Exception", "Result has multiple solids: that is not currently supported."));
this->Shape.setValue(result);

return App::DocumentObject::StdReturn;
Expand Down Expand Up @@ -2030,7 +2032,7 @@ TopoShape Hole::findHoles(std::vector<TopoShape> &holes,
const TopoShape& profileshape,
const TopoDS_Shape& protoHole) const
{

Check failure on line 2034 in src/Mod/PartDesign/App/FeatureHole.cpp

View workflow job for this annotation

GitHub Actions / Lint / Lint

function definition is not allowed here

Check failure on line 2034 in src/Mod/PartDesign/App/FeatureHole.cpp

View workflow job for this annotation

GitHub Actions / Lint / Lint

function definition is not allowed here [clang-diagnostic-error]
TopoShape result(0,getDocument()->getStringHasher());
TopoShape result(0);

int i = 0;
for(const auto &profileEdge : profileshape.getSubTopoShapes(TopAbs_EDGE)) {
Expand All @@ -2053,16 +2055,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
6 changes: 3 additions & 3 deletions src/Mod/Sketcher/SketcherTests/TestSketcherSolver.py
Original file line number Diff line number Diff line change
Expand Up @@ -520,7 +520,7 @@ def testRemovedExternalGeometryReference(self):
hole.DrillForDepth = 0
hole.Tapered = 0
self.Doc.recompute()
self.assertEqual(len(hole.Shape.Edges), 12)
self.assertEqual(len(hole.Shape.Edges), 13)
hole.Threaded = True
hole.ModelThread = True
body.addObject(hole)
Expand All @@ -530,11 +530,11 @@ def testRemovedExternalGeometryReference(self):
body.addObject(sketch2)
self.Doc.recompute()
sketch2.addExternal("Hole", "Edge29") # Edge29 will disappear when we stop modeling threads
self.assertEqual(len(hole.Shape.Edges), 32)
self.assertEqual(len(hole.Shape.Edges), 38)
hole.ModelThread = False
hole.Refine = True
self.Doc.recompute()
self.assertEqual(len(hole.Shape.Edges), 32)
self.assertEqual(len(hole.Shape.Edges), 38)
self.assertEqual(len(sketch2.ExternalGeometry), 1)

def testSaveLoadWithExternalGeometryReference(self):
Expand Down

0 comments on commit 34a4da7

Please sign in to comment.