PartDesign: 3rdParty to PCH

This commit is contained in:
Abdullah Tahiri
2019-05-01 17:20:46 +02:00
committed by abdullahtahiriyo
parent a56658489b
commit a415ad72e1
12 changed files with 238 additions and 200 deletions

View File

@@ -28,13 +28,13 @@
# include <TopExp_Explorer.hxx>
# include <BRepAlgoAPI_Fuse.hxx>
# include <BRepAlgoAPI_Common.hxx>
#include <BRepOffsetAPI_ThruSections.hxx>
#include <BRepBuilderAPI_Sewing.hxx>
#include <BRepBuilderAPI_MakeSolid.hxx>
#include <BRepClass3d_SolidClassifier.hxx>
#include <BRepAlgoAPI_Cut.hxx>
#include <TopoDS.hxx>
#include <Precision.hxx>
# include <BRepOffsetAPI_ThruSections.hxx>
# include <BRepBuilderAPI_Sewing.hxx>
# include <BRepBuilderAPI_MakeSolid.hxx>
# include <BRepClass3d_SolidClassifier.hxx>
# include <BRepAlgoAPI_Cut.hxx>
# include <TopoDS.hxx>
# include <Precision.hxx>
#endif
#include <Base/Exception.h>
@@ -68,20 +68,20 @@ short Loft::mustExecute() const
return 1;
if (Closed.isTouched())
return 1;
return ProfileBased::mustExecute();
}
App::DocumentObjectExecReturn *Loft::execute(void)
{
std::vector<TopoDS_Wire> wires;
try {
wires = getProfileWires();
} catch (const Base::Exception& e) {
return new App::DocumentObjectExecReturn(e.what());
}
TopoDS_Shape sketchshape = getVerifiedFace();
if (sketchshape.IsNull())
return new App::DocumentObjectExecReturn("Loft: Creating a face from sketch failed");
@@ -93,27 +93,27 @@ App::DocumentObjectExecReturn *Loft::execute(void)
} catch (const Base::Exception&) {
base = TopoDS_Shape();
}
try {
//setup the location
this->positionByPrevious();
TopLoc_Location invObjLoc = this->getLocation().Inverted();
if(!base.IsNull())
base.Move(invObjLoc);
//build up multisections
auto multisections = Sections.getValues();
if(multisections.empty())
return new App::DocumentObjectExecReturn("Loft: At least one section is needed");
std::vector<std::vector<TopoDS_Wire>> wiresections;
for(TopoDS_Wire& wire : wires)
wiresections.push_back(std::vector<TopoDS_Wire>(1, wire));
for(App::DocumentObject* obj : multisections) {
if(!obj->isDerivedFrom(Part::Feature::getClassTypeId()))
return new App::DocumentObjectExecReturn("Loft: All sections need to be part features");
TopExp_Explorer ex;
size_t i=0;
for (ex.Init(static_cast<Part::Feature*>(obj)->Shape.getValue(), TopAbs_WIRE); ex.More(); ex.Next(), ++i) {
@@ -123,13 +123,13 @@ App::DocumentObjectExecReturn *Loft::execute(void)
}
if(i<wiresections.size())
return new App::DocumentObjectExecReturn("Loft: Sections need to have the same amount of inner wires as the base section");
}
//build all shells
std::vector<TopoDS_Shape> shells;
for(std::vector<TopoDS_Wire>& wires : wiresections) {
BRepOffsetAPI_ThruSections mkTS(false, Ruled.getValue(), Precision::Confusion());
for(TopoDS_Wire& wire : wires) {
@@ -140,35 +140,35 @@ App::DocumentObjectExecReturn *Loft::execute(void)
mkTS.Build();
if (!mkTS.IsDone())
return new App::DocumentObjectExecReturn("Loft could not be built");
//build the shell use simulate to get the top and bottom wires in an easy way
shells.push_back(mkTS.Shape());
}
//build the top and bottom face, sew the shell and build the final solid
TopoDS_Shape front = getVerifiedFace();
front.Move(invObjLoc);
std::vector<TopoDS_Wire> backwires;
for(std::vector<TopoDS_Wire>& wires : wiresections)
backwires.push_back(wires.back());
TopoDS_Shape back = Part::FaceMakerCheese::makeFace(backwires);
BRepBuilderAPI_Sewing sewer;
sewer.SetTolerance(Precision::Confusion());
sewer.Add(front);
sewer.Add(back);
for(TopoDS_Shape& s : shells)
sewer.Add(s);
sewer.Add(s);
sewer.Perform();
//build the solid
BRepBuilderAPI_MakeSolid mkSolid;
mkSolid.Add(TopoDS::Shell(sewer.SewedShape()));
if(!mkSolid.IsDone())
return new App::DocumentObjectExecReturn("Loft: Result is not a solid");
TopoDS_Shape result = mkSolid.Shape();
BRepClass3d_SolidClassifier SC(result);
SC.PerformInfinitePoint(Precision::Confusion());
@@ -177,14 +177,14 @@ App::DocumentObjectExecReturn *Loft::execute(void)
}
AddSubShape.setValue(result);
if(base.IsNull()) {
Shape.setValue(getSolid(result));
return App::DocumentObject::StdReturn;
}
if(getAddSubType() == FeatureAddSub::Additive) {
BRepAlgoAPI_Fuse mkFuse(base, result);
if (!mkFuse.IsDone())
return new App::DocumentObjectExecReturn("Loft: Adding the loft failed");
@@ -197,12 +197,12 @@ App::DocumentObjectExecReturn *Loft::execute(void)
if (solidCount > 1) {
return new App::DocumentObjectExecReturn("Loft: Result has multiple solids. This is not supported at this time.");
}
boolOp = refineShapeIfActive(boolOp);
Shape.setValue(getSolid(boolOp));
}
else if(getAddSubType() == FeatureAddSub::Subtractive) {
BRepAlgoAPI_Cut mkCut(base, result);
if (!mkCut.IsDone())
return new App::DocumentObjectExecReturn("Loft: Subtracting the loft failed");
@@ -215,11 +215,11 @@ App::DocumentObjectExecReturn *Loft::execute(void)
if (solidCount > 1) {
return new App::DocumentObjectExecReturn("Loft: Result has multiple solids. This is not supported at this time.");
}
boolOp = refineShapeIfActive(boolOp);
Shape.setValue(getSolid(boolOp));
}
return App::DocumentObject::StdReturn;
}
catch (Standard_Failure& e) {