Skip to content

Commit

Permalink
Merge branch 'master' of github.com:FreeCAD/FreeCAD
Browse files Browse the repository at this point in the history
  • Loading branch information
yorikvanhavre committed Jun 16, 2019
2 parents e529871 + 972ec50 commit 6259e1e
Show file tree
Hide file tree
Showing 4 changed files with 57 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/Mod/PartDesign/App/FeaturePad.cpp
Expand Up @@ -218,13 +218,18 @@ App::DocumentObjectExecReturn *Pad::execute(void)
TopExp_Explorer Ex(supportface,TopAbs_WIRE);
if (!Ex.More())
supportface = TopoDS_Face();

#if 0
BRepFeat_MakePrism PrismMaker;
PrismMaker.Init(base, sketchshape, supportface, dir, 2, 1);
PrismMaker.Perform(upToFace);

if (!PrismMaker.IsDone())
return new App::DocumentObjectExecReturn("Pad: Up to face: Could not extrude the sketch!");
prism = PrismMaker.Shape();
#else
generatePrism(prism, method, base, sketchshape, supportface, upToFace, dir, 2, 1);
#endif
base.Nullify();
} else {
// A support object is always required and we need to use BRepFeat_MakePrism
Expand All @@ -239,13 +244,17 @@ App::DocumentObjectExecReturn *Pad::execute(void)
TopExp_Explorer Ex(supportface,TopAbs_WIRE);
if (!Ex.More())
supportface = TopoDS_Face();
#if 0
BRepFeat_MakePrism PrismMaker;
PrismMaker.Init(base, sketchshape, supportface, dir, 2, 1);
PrismMaker.Perform(upToFace);

if (!PrismMaker.IsDone())
return new App::DocumentObjectExecReturn("Pad: Up to face: Could not extrude the sketch!");
prism = PrismMaker.Shape();
#else
generatePrism(prism, method, base, sketchshape, supportface, upToFace, dir, 2, 1);
#endif
}
} else {
generatePrism(prism, sketchshape, method, dir, L, L2,
Expand Down
5 changes: 5 additions & 0 deletions src/Mod/PartDesign/App/FeaturePocket.cpp
Expand Up @@ -174,13 +174,18 @@ App::DocumentObjectExecReturn *Pocket::execute(void)
TopExp_Explorer Ex(supportface,TopAbs_WIRE);
if (!Ex.More())
supportface = TopoDS_Face();
#if 0
BRepFeat_MakePrism PrismMaker;
PrismMaker.Init(base, profileshape, supportface, dir, 0, 1);
PrismMaker.Perform(upToFace);

if (!PrismMaker.IsDone())
return new App::DocumentObjectExecReturn("Pocket: Up to face: Could not extrude the sketch!");
TopoDS_Shape prism = PrismMaker.Shape();
#else
TopoDS_Shape prism;
generatePrism(prism, method, base, profileshape, supportface, upToFace, dir, 0, 1);
#endif

// And the really expensive way to get the SubShape...
BRepAlgoAPI_Cut mkCut(base, prism);
Expand Down
30 changes: 30 additions & 0 deletions src/Mod/PartDesign/App/FeatureSketchBased.cpp
Expand Up @@ -34,6 +34,7 @@
# include <BRep_Tool.hxx>
# include <BRepExtrema_DistShapeShape.hxx>
# include <BRepPrimAPI_MakePrism.hxx>
# include <BRepFeat_MakePrism.hxx>
# include <BRepProj_Projection.hxx>
# include <Geom_Plane.hxx>
# include <TopoDS.hxx>
Expand Down Expand Up @@ -544,6 +545,35 @@ void ProfileBased::generatePrism(TopoDS_Shape& prism,

}

void ProfileBased::generatePrism(TopoDS_Shape& prism,
const std::string& method,
const TopoDS_Shape& baseshape,
const TopoDS_Shape& profileshape,
const TopoDS_Face& sketchface,
const TopoDS_Face& uptoface,
const gp_Dir& direction,
Standard_Integer Mode,
Standard_Boolean Modify)
{
if (method == "UpToFirst" || method == "UpToFace") {
BRepFeat_MakePrism PrismMaker;
TopoDS_Shape base = baseshape;
TopoDS_Face supportface = sketchface;
for (TopExp_Explorer xp(profileshape, TopAbs_FACE); xp.More(); xp.Next()) {
PrismMaker.Init(base, xp.Current(), supportface, direction, Mode, Modify);
PrismMaker.Perform(uptoface);
if (!PrismMaker.IsDone())
throw Base::RuntimeError("ProfileBased: Up to face: Could not extrude the sketch!");

base = PrismMaker.Shape();
if (Mode == 2)
Mode = 1;
}

prism = base;
}
}

bool ProfileBased::checkWireInsideFace(const TopoDS_Wire& wire, const TopoDS_Face& face,
const gp_Dir& dir) {
// Project wire onto the face (face, not surface! So limits of face apply)
Expand Down
13 changes: 13 additions & 0 deletions src/Mod/PartDesign/App/FeatureSketchBased.h
Expand Up @@ -134,6 +134,19 @@ class PartDesignExport ProfileBased : public PartDesign::FeatureAddSub
const double L2,
const bool midplane,
const bool reversed);
/**
* Generate a linear prism
* It will be a stand-alone solid created with BRepFeat_MakePrism
*/
static void generatePrism(TopoDS_Shape& prism,
const std::string& method,
const TopoDS_Shape& baseshape,
const TopoDS_Shape& profileshape,
const TopoDS_Face& sketchface,
const TopoDS_Face& uptoface,
const gp_Dir& direction,
Standard_Integer Mode,
Standard_Boolean Modify);

/// Check whether the wire after projection on the face is inside the face
static bool checkWireInsideFace(const TopoDS_Wire& wire,
Expand Down

0 comments on commit 6259e1e

Please sign in to comment.