PartDesign: 3rdParty to PCH

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

View File

@@ -41,21 +41,21 @@
# include <BRepAdaptor_Surface.hxx>
# include <gp_Pln.hxx>
# include <GeomAPI_ProjectPointOnSurf.hxx>
#include <BRepOffsetAPI_MakePipeShell.hxx>
#include <BRepBuilderAPI_MakeWire.hxx>
#include <ShapeAnalysis_FreeBounds.hxx>
#include <TopTools_HSequenceOfShape.hxx>
#include <TopTools_ListIteratorOfListOfShape.hxx>
#include <TopTools_IndexedMapOfShape.hxx>
#include <TopTools_IndexedDataMapOfShapeListOfShape.hxx>
#include <TopExp.hxx>
#include <BRepAlgoAPI_Cut.hxx>
#include <BRepBuilderAPI_Sewing.hxx>
#include <BRepBuilderAPI_MakeSolid.hxx>
#include <BRepClass3d_SolidClassifier.hxx>
#include <Law_Function.hxx>
#include <Law_Linear.hxx>
#include <Law_S.hxx>
# include <BRepOffsetAPI_MakePipeShell.hxx>
# include <BRepBuilderAPI_MakeWire.hxx>
# include <ShapeAnalysis_FreeBounds.hxx>
# include <TopTools_HSequenceOfShape.hxx>
# include <TopTools_ListIteratorOfListOfShape.hxx>
# include <TopTools_IndexedMapOfShape.hxx>
# include <TopTools_IndexedDataMapOfShapeListOfShape.hxx>
# include <TopExp.hxx>
# include <BRepAlgoAPI_Cut.hxx>
# include <BRepBuilderAPI_Sewing.hxx>
# include <BRepBuilderAPI_MakeSolid.hxx>
# include <BRepClass3d_SolidClassifier.hxx>
# include <Law_Function.hxx>
# include <Law_Linear.hxx>
# include <Law_S.hxx>
#endif
#include <Base/Exception.h>
@@ -80,7 +80,7 @@ const char* Pipe::TransformEnums[] = {"Constant", "Multisection", "Linear", "S-s
PROPERTY_SOURCE(PartDesign::Pipe, PartDesign::ProfileBased)
Pipe::Pipe()
{
{
ADD_PROPERTY_TYPE(Sections,(0),"Sweep",App::Prop_None,"List of sections");
Sections.setSize(0);
ADD_PROPERTY_TYPE(Spine,(0),"Sweep",App::Prop_None,"Path to sweep along");
@@ -118,13 +118,13 @@ App::DocumentObjectExecReturn *Pipe::execute(void)
} catch (const Base::Exception& e) {
return new App::DocumentObjectExecReturn(e.what());
}
TopoDS_Shape sketchshape = getVerifiedFace();
if (sketchshape.IsNull())
return new App::DocumentObjectExecReturn("Pipe: No valid sketch or face as first section");
else {
//TODO: currently we only allow planar faces. the reason for this is that with other faces in front, we could
//not use the current simulate approach and build the start and end face from the wires. As the shell
//TODO: currently we only allow planar faces. the reason for this is that with other faces in front, we could
//not use the current simulate approach and build the start and end face from the wires. As the shell
//begins always at the spine and not the profile, the sketchshape cannot be used directly as front face.
//We would need a method to translate the front shape to match the shell starting position somehow...
TopoDS_Face face = TopoDS::Face(sketchshape);
@@ -140,14 +140,14 @@ App::DocumentObjectExecReturn *Pipe::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 the paths
App::DocumentObject* spine = Spine.getValue();
if (!(spine && spine->getTypeId().isDerivedFrom(Part::Feature::getClassTypeId())))
@@ -180,17 +180,17 @@ App::DocumentObjectExecReturn *Pipe::execute(void)
wiresections.push_back(std::vector<TopoDS_Wire>(1, wire));
//maybe we need a sacling law
Handle(Law_Function) scalinglaw;
//see if we shall use multiple sections
if(Transformation.getValue() == 1) {
//TODO: we need to order the sections to prevent occ from crahsing, as makepieshell connects
//the sections in the order of adding
//the sections in the order of adding
for(App::DocumentObject* obj : multisections) {
if(!obj->isDerivedFrom(Part::Feature::getClassTypeId()))
return new App::DocumentObjectExecReturn("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()) {
@@ -209,30 +209,30 @@ App::DocumentObjectExecReturn *Pipe::execute(void)
else if(Transformation.getValue() == 2) {
if(ScalingData.getValues().size()<1)
return new App::DocumentObjectExecReturn("No valid data given for linear scaling mode");
Handle(Law_Linear) lin = new Law_Linear();
lin->Set(0,1,1,ScalingData[0].x);
scalinglaw = lin;
}
else if(Transformation.getValue() == 3) {
if(ScalingData.getValues().size()<1)
return new App::DocumentObjectExecReturn("No valid data given for S-shape scaling mode");
Handle(Law_S) s = new Law_S();
s->Set(0,1,ScalingData[0].y, 1, ScalingData[0].x, ScalingData[0].z);
scalinglaw = s;
}*/
//build all shells
std::vector<TopoDS_Shape> shells;
std::vector<TopoDS_Wire> frontwires, backwires;
for(std::vector<TopoDS_Wire>& wires : wiresections) {
BRepOffsetAPI_MakePipeShell mkPS(TopoDS::Wire(path));
setupAlgorithm(mkPS, auxpath);
if(!scalinglaw) {
for(TopoDS_Wire& wire : wires) {
wire.Move(invObjLoc);
@@ -250,7 +250,7 @@ App::DocumentObjectExecReturn *Pipe::execute(void)
return new App::DocumentObjectExecReturn("Pipe could not be built");
shells.push_back(mkPS.Shape());
if (!mkPS.Shape().Closed()) {
// shell is not closed - use simulate to get the end wires
TopTools_ListOfShape sim;
@@ -313,7 +313,7 @@ App::DocumentObjectExecReturn *Pipe::execute(void)
// lets check if the result is a solid
if (boolOp.IsNull())
return new App::DocumentObjectExecReturn("Resulting shape is not a solid");
int solidCount = countSolids(boolOp);
if (solidCount > 1) {
return new App::DocumentObjectExecReturn("Pipe: Result has multiple solids. This is not supported at this time.");
@@ -332,7 +332,7 @@ App::DocumentObjectExecReturn *Pipe::execute(void)
// lets check if the result is a solid
if (boolOp.IsNull())
return new App::DocumentObjectExecReturn("Resulting shape is not a solid");
int solidCount = countSolids(boolOp);
if (solidCount > 1) {
return new App::DocumentObjectExecReturn("Pipe: Result has multiple solids. This is not supported at this time.");
@@ -385,7 +385,7 @@ void Pipe::setupAlgorithm(BRepOffsetAPI_MakePipeShell& mkPipeShell, TopoDS_Shape
mkPipeShell.SetMode(gp_Dir(bVec.x,bVec.y,bVec.z));
break;
}
if(auxiliary) {
mkPipeShell.SetMode(TopoDS::Wire(auxshape), AuxilleryCurvelinear.getValue());
//mkPipeShell.SetMode(TopoDS::Wire(auxshape), AuxilleryCurvelinear.getValue(), BRepFill_ContactOnBorder);
@@ -404,7 +404,7 @@ void Pipe::getContiniusEdges(Part::TopoShape /*TopShape*/, std::vector< std::str
Base::Console().Message("Initial edges:\n");
for(int i=0; i<SubNames.size(); ++i)
Base::Console().Message("Subname: %s\n", SubNames[i].c_str());
unsigned int i = 0;
while(i < SubNames.size())
{
@@ -436,8 +436,8 @@ void Pipe::getContiniusEdges(Part::TopoShape /*TopShape*/, std::vector< std::str
else {
SubNames.erase(SubNames.begin()+i);
}
}
}
Base::Console().Message("Final edges:\n");
for(int i=0; i<SubNames.size(); ++i)
Base::Console().Message("Subname: %s\n", SubNames[i].c_str());