All: Reformat according to new standard

This commit is contained in:
pre-commit-ci[bot]
2025-11-11 13:49:01 +01:00
committed by Kacper Donat
parent eafd18dac0
commit 25c3ba7338
2390 changed files with 154630 additions and 115818 deletions

View File

@@ -21,23 +21,23 @@
***************************************************************************/
# include <Mod/Part/App/FCBRepAlgoAPI_Cut.h>
# include <Mod/Part/App/FCBRepAlgoAPI_Fuse.h>
# include <BRepBndLib.hxx>
# include <BRepBuilderAPI_Sewing.hxx>
# include <BRepBuilderAPI_MakeSolid.hxx>
# include <BRepBuilderAPI_MakeWire.hxx>
# include <BRepClass3d_SolidClassifier.hxx>
# include <BRepOffsetAPI_MakePipeShell.hxx>
# include <gp_Ax2.hxx>
# include <Law_Function.hxx>
# include <Precision.hxx>
# include <ShapeAnalysis_FreeBounds.hxx>
# include <TopExp.hxx>
# include <TopExp_Explorer.hxx>
# include <TopoDS.hxx>
# include <TopoDS_Wire.hxx>
# include <TopTools_HSequenceOfShape.hxx>
#include <Mod/Part/App/FCBRepAlgoAPI_Cut.h>
#include <Mod/Part/App/FCBRepAlgoAPI_Fuse.h>
#include <BRepBndLib.hxx>
#include <BRepBuilderAPI_Sewing.hxx>
#include <BRepBuilderAPI_MakeSolid.hxx>
#include <BRepBuilderAPI_MakeWire.hxx>
#include <BRepClass3d_SolidClassifier.hxx>
#include <BRepOffsetAPI_MakePipeShell.hxx>
#include <gp_Ax2.hxx>
#include <Law_Function.hxx>
#include <Precision.hxx>
#include <ShapeAnalysis_FreeBounds.hxx>
#include <TopExp.hxx>
#include <TopExp_Explorer.hxx>
#include <TopoDS.hxx>
#include <TopoDS_Wire.hxx>
#include <TopTools_HSequenceOfShape.hxx>
#include <App/Document.h>
@@ -51,15 +51,15 @@
#include "Mod/Part/App/TopoShapeMapper.h"
#include "FeatureLoft.h"
FC_LOG_LEVEL_INIT("PartDesign",true,true);
FC_LOG_LEVEL_INIT("PartDesign", true, true);
using namespace PartDesign;
const char* Pipe::TypeEnums[] = {"FullPath", "UpToFace", nullptr};
const char* Pipe::TransitionEnums[] = {"Transformed", "Right corner", "Round corner", nullptr};
const char* Pipe::ModeEnums[] = {"Standard", "Fixed", "Frenet", "Auxiliary", "Binormal", nullptr};
const char* Pipe::TransformEnums[] = {
"Constant", "Multisection", "Linear", "S-shape", "Interpolation", nullptr};
const char* Pipe::TransformEnums[]
= {"Constant", "Multisection", "Linear", "S-shape", "Interpolation", nullptr};
PROPERTY_SOURCE(PartDesign::Pipe, PartDesign::ProfileBased)
@@ -69,20 +69,32 @@ Pipe::Pipe()
ADD_PROPERTY_TYPE(Sections, (nullptr), "Sweep", App::Prop_None, "List of sections");
Sections.setValue(nullptr);
ADD_PROPERTY_TYPE(Spine, (nullptr), "Sweep", App::Prop_None, "Path to sweep along");
ADD_PROPERTY_TYPE(SpineTangent, (false), "Sweep", App::Prop_None,
"Include tangent edges into path");
ADD_PROPERTY_TYPE(AuxiliarySpine, (nullptr), "Sweep", App::Prop_None,
"Secondary path to orient sweep");
ADD_PROPERTY_TYPE(AuxiliarySpineTangent, (false), "Sweep", App::Prop_None,
"Include tangent edges into secondary path");
ADD_PROPERTY_TYPE(AuxiliaryCurvilinear, (true), "Sweep", App::Prop_None,
"Calculate normal between equidistant points on both spines");
ADD_PROPERTY_TYPE(SpineTangent, (false), "Sweep", App::Prop_None, "Include tangent edges into path");
ADD_PROPERTY_TYPE(AuxiliarySpine, (nullptr), "Sweep", App::Prop_None, "Secondary path to orient sweep");
ADD_PROPERTY_TYPE(
AuxiliarySpineTangent,
(false),
"Sweep",
App::Prop_None,
"Include tangent edges into secondary path"
);
ADD_PROPERTY_TYPE(
AuxiliaryCurvilinear,
(true),
"Sweep",
App::Prop_None,
"Calculate normal between equidistant points on both spines"
);
ADD_PROPERTY_TYPE(Mode, (long(0)), "Sweep", App::Prop_None, "Profile mode");
ADD_PROPERTY_TYPE(Binormal, (Base::Vector3d()), "Sweep", App::Prop_None,
"Binormal vector for corresponding orientation mode");
ADD_PROPERTY_TYPE(
Binormal,
(Base::Vector3d()),
"Sweep",
App::Prop_None,
"Binormal vector for corresponding orientation mode"
);
ADD_PROPERTY_TYPE(Transition, (long(0)), "Sweep", App::Prop_None, "Transition mode");
ADD_PROPERTY_TYPE(Transformation, (long(0)), "Sweep", App::Prop_None,
"Section transformation mode");
ADD_PROPERTY_TYPE(Transformation, (long(0)), "Sweep", App::Prop_None, "Section transformation mode");
Mode.setEnums(ModeEnums);
Transition.setEnums(TransitionEnums);
Transformation.setEnums(TransformEnums);
@@ -90,38 +102,45 @@ Pipe::Pipe()
short Pipe::mustExecute() const
{
if (Sections.isTouched())
if (Sections.isTouched()) {
return 1;
if (Spine.isTouched())
}
if (Spine.isTouched()) {
return 1;
if (Mode.isTouched())
}
if (Mode.isTouched()) {
return 1;
if (Transition.isTouched())
}
if (Transition.isTouched()) {
return 1;
}
return ProfileBased::mustExecute();
}
App::DocumentObjectExecReturn *Pipe::execute()
App::DocumentObjectExecReturn* Pipe::execute()
{
if (onlyHaveRefined()) { return App::DocumentObject::StdReturn; }
if (onlyHaveRefined()) {
return App::DocumentObject::StdReturn;
}
auto getSectionShape = [](App::DocumentObject* feature,
const std::vector<std::string>& subs) -> TopoDS_Shape {
if (!feature || !feature->isDerivedFrom<Part::Feature>())
if (!feature || !feature->isDerivedFrom<Part::Feature>()) {
throw Base::TypeError("Pipe: Invalid profile/section");
}
auto subName = subs.empty() ? "" : subs.front();
// only take the entire shape when we have a sketch selected, but
// not a point of the sketch
if (feature->isDerivedFrom<Part::Part2DObject>()
&& subName.compare(0, 6, "Vertex") != 0)
if (feature->isDerivedFrom<Part::Part2DObject>() && subName.compare(0, 6, "Vertex") != 0) {
return static_cast<Part::Part2DObject*>(feature)->Shape.getValue();
}
else {
if (subName.empty())
if (subName.empty()) {
throw Base::ValueError("Pipe: No valid subelement linked in Part::Feature");
return static_cast<Part::Feature*>(feature)->Shape.getShape().getSubShape(
subName.c_str());
}
return static_cast<Part::Feature*>(feature)->Shape.getShape().getSubShape(subName.c_str());
}
};
@@ -133,15 +152,19 @@ App::DocumentObjectExecReturn *Pipe::execute()
for (ex.Init(section, TopAbs_WIRE); ex.More(); ex.Next(), ++i) {
// if profile was just a point then this is where we can first set our list
if (i >= wiresections.size()) {
if (initialWireSectionsEmpty)
if (initialWireSectionsEmpty) {
wiresections.emplace_back(1, ex.Current());
else
}
else {
throw Base::ValueError(
"Pipe: Sections need to have the same amount of inner wires (except "
"profile and last section, which can be points)");
"profile and last section, which can be points)"
);
}
}
else
else {
wiresections[i].push_back(TopoDS::Wire(ex.Current()));
}
}
return i;
};
@@ -158,7 +181,8 @@ App::DocumentObjectExecReturn *Pipe::execute()
TopoShape base;
try {
base = getBaseTopoShape();
} catch (const Base::Exception&) {
}
catch (const Base::Exception&) {
base = TopoShape();
}
@@ -168,19 +192,23 @@ App::DocumentObjectExecReturn *Pipe::execute()
// setup the location
this->positionByPrevious();
TopLoc_Location invObjLoc = this->getLocation().Inverted();
if (!base.isNull())
if (!base.isNull()) {
base.move(invObjLoc);
}
// setup the profile section
TopoDS_Shape profileShape = getSectionShape(Profile.getValue(),
Profile.getSubValues());
if (profileShape.IsNull())
return new App::DocumentObjectExecReturn(QT_TRANSLATE_NOOP("Exception", "Pipe: Could not obtain profile shape"));
TopoDS_Shape profileShape = getSectionShape(Profile.getValue(), Profile.getSubValues());
if (profileShape.IsNull()) {
return new App::DocumentObjectExecReturn(
QT_TRANSLATE_NOOP("Exception", "Pipe: Could not obtain profile shape")
);
}
// build the paths
App::DocumentObject* spine = Spine.getValue();
if (!(spine && spine->isDerivedFrom<Part::Feature>()))
if (!(spine && spine->isDerivedFrom<Part::Feature>())) {
return new App::DocumentObjectExecReturn(QT_TRANSLATE_NOOP("Exception", "No spine linked"));
}
std::vector<std::string> subedge = Spine.getSubValues();
TopoDS_Shape path;
@@ -192,12 +220,14 @@ App::DocumentObjectExecReturn *Pipe::execute()
TopoDS_Shape auxpath;
if (Mode.getValue() == 3) {
App::DocumentObject* auxspine = AuxiliarySpine.getValue();
if (!(auxspine && auxspine->isDerivedFrom<Part::Feature>()))
return new App::DocumentObjectExecReturn(QT_TRANSLATE_NOOP("Exception", "No auxiliary spine linked."));
if (!(auxspine && auxspine->isDerivedFrom<Part::Feature>())) {
return new App::DocumentObjectExecReturn(
QT_TRANSLATE_NOOP("Exception", "No auxiliary spine linked.")
);
}
std::vector<std::string> auxsubedge = AuxiliarySpine.getSubValues();
const Part::TopoShape& auxshape =
static_cast<Part::Feature*>(auxspine)->Shape.getValue();
const Part::TopoShape& auxshape = static_cast<Part::Feature*>(auxspine)->Shape.getValue();
buildPipePath(auxshape, auxsubedge, auxpath);
auxpath.Move(invObjLoc);
}
@@ -211,17 +241,24 @@ App::DocumentObjectExecReturn *Pipe::execute()
// profileShape had no wires so only other valid option is single point section
TopExp_Explorer ex;
size_t i = 0;
for (ex.Init(profileShape, TopAbs_VERTEX); ex.More(); ex.Next(), ++i)
for (ex.Init(profileShape, TopAbs_VERTEX); ex.More(); ex.Next(), ++i) {
profilePoint = ex.Current();
if (i > 1)
return new App::DocumentObjectExecReturn(QT_TRANSLATE_NOOP("Exception",
"Pipe: Only one isolated point is needed if using a sketch with isolated "
"points for section"));
}
if (i > 1) {
return new App::DocumentObjectExecReturn(QT_TRANSLATE_NOOP(
"Exception",
"Pipe: Only one isolated point is needed if using a sketch with isolated "
"points for section"
));
}
}
if (!profilePoint.IsNull() && (Transformation.getValue() != 1 || multisections.empty()))
return new App::DocumentObjectExecReturn(QT_TRANSLATE_NOOP("Exception",
"Pipe: At least one section is needed when using a single point for profile"));
if (!profilePoint.IsNull() && (Transformation.getValue() != 1 || multisections.empty())) {
return new App::DocumentObjectExecReturn(QT_TRANSLATE_NOOP(
"Exception",
"Pipe: At least one section is needed when using a single point for profile"
));
}
// maybe we need a scaling law
Handle(Law_Function) scalinglaw;
@@ -233,40 +270,52 @@ App::DocumentObjectExecReturn *Pipe::execute()
// TODO: we need to order the sections to prevent occ from crashing,
// as makepipeshell connects the sections in the order of adding
for (auto& subSet : multisections) {
if (!subSet.first->isDerivedFrom<Part::Feature>())
return new App::DocumentObjectExecReturn(QT_TRANSLATE_NOOP("Exception",
"Pipe: All sections need to be Part features"));
if (!subSet.first->isDerivedFrom<Part::Feature>()) {
return new App::DocumentObjectExecReturn(
QT_TRANSLATE_NOOP("Exception", "Pipe: All sections need to be Part features")
);
}
// if the section is an object's face then take just the face
TopoDS_Shape shape = getSectionShape(subSet.first, subSet.second);
if (shape.IsNull())
return new App::DocumentObjectExecReturn(QT_TRANSLATE_NOOP("Exception",
"Pipe: Could not obtain section shape"));
if (shape.IsNull()) {
return new App::DocumentObjectExecReturn(
QT_TRANSLATE_NOOP("Exception", "Pipe: Could not obtain section shape")
);
}
size_t nWiresAdded = addWiresToWireSections(shape, wiresections);
if (nWiresAdded == 0) {
TopExp_Explorer ex;
size_t i = 0;
for (ex.Init(shape, TopAbs_VERTEX); ex.More(); ex.Next(), ++i) {
if (isLastSectionVertex)
return new App::DocumentObjectExecReturn(QT_TRANSLATE_NOOP("Exception",
"Pipe: Only the profile and last section can be vertices"));
if (isLastSectionVertex) {
return new App::DocumentObjectExecReturn(QT_TRANSLATE_NOOP(
"Exception",
"Pipe: Only the profile and last section can be vertices"
));
}
isLastSectionVertex = true;
for (auto& wires : wiresections)
for (auto& wires : wiresections) {
wires.push_back(ex.Current());
}
}
}
if (!isLastSectionVertex && nWiresAdded < wiresections.size())
return new App::DocumentObjectExecReturn(QT_TRANSLATE_NOOP("Exception",
"Multisections need to have the same amount of inner wires as the base "
"section"));
if (!isLastSectionVertex && nWiresAdded < wiresections.size()) {
return new App::DocumentObjectExecReturn(QT_TRANSLATE_NOOP(
"Exception",
"Multisections need to have the same amount of inner wires as the base "
"section"
));
}
}
}
/*//build the law functions instead
else if (Transformation.getValue() == 2) {
if (ScalingData.getValues().size()<1)
return new App::DocumentObjectExecReturn("No valid data given for linear scaling mode");
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);
@@ -275,7 +324,8 @@ App::DocumentObjectExecReturn *Pipe::execute()
}
else if (Transformation.getValue() == 3) {
if (ScalingData.getValues().size()<1)
return new App::DocumentObjectExecReturn("No valid data given for S-shape scaling mode");
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);
@@ -284,16 +334,19 @@ App::DocumentObjectExecReturn *Pipe::execute()
}*/
// Verify that path is not a null shape
if (path.IsNull())
return new App::DocumentObjectExecReturn(QT_TRANSLATE_NOOP(
"Exception", "Path must not be a null shape"));
if (path.IsNull()) {
return new App::DocumentObjectExecReturn(
QT_TRANSLATE_NOOP("Exception", "Path must not be a null shape")
);
}
// build all shells
std::vector<TopoShape> shells;
TopoDS_Shape copyProfilePoint(profilePoint);
if (!profilePoint.IsNull())
if (!profilePoint.IsNull()) {
copyProfilePoint.Move(invObjLoc);
}
std::vector<TopoDS_Wire> frontwires, backwires;
for (auto& wires : wiresections) {
@@ -301,8 +354,9 @@ App::DocumentObjectExecReturn *Pipe::execute()
setupAlgorithm(mkPS, auxpath);
if (!scalinglaw) {
if (!profilePoint.IsNull())
if (!profilePoint.IsNull()) {
mkPS.Add(copyProfilePoint);
}
for (auto& wire : wires) {
wire.Move(invObjLoc);
@@ -310,17 +364,21 @@ App::DocumentObjectExecReturn *Pipe::execute()
}
}
else {
if (!profilePoint.IsNull())
if (!profilePoint.IsNull()) {
mkPS.SetLaw(copyProfilePoint, scalinglaw);
}
for (auto& wire : wires) {
for (auto& wire : wires) {
wire.Move(invObjLoc);
mkPS.SetLaw(wire, scalinglaw);
}
}
if (!mkPS.IsReady())
return new App::DocumentObjectExecReturn(QT_TRANSLATE_NOOP("Exception", "Pipe could not be built"));
if (!mkPS.IsReady()) {
return new App::DocumentObjectExecReturn(
QT_TRANSLATE_NOOP("Exception", "Pipe could not be built")
);
}
shells.emplace_back(mkPS.Shape());
@@ -350,54 +408,79 @@ App::DocumentObjectExecReturn *Pipe::execute()
shells.emplace_back(front);
}
if (!backwires.empty()) {
TopoDS_Shape back = Part::FaceMakerCheese::makeFace(backwires);
TopoDS_Shape back = Part::FaceMakerCheese::makeFace(backwires);
sewer.Add(back);
shells.emplace_back(back);
}
for (TopoShape& s : shells)
for (TopoShape& s : shells) {
sewer.Add(s.getShape());
}
sewer.Perform();
result = result.makeShapeWithElementMap(sewer.SewedShape(), Part::MapperSewing(sewer), shells, Part::OpCodes::Sewing);
} else {
result = result.makeShapeWithElementMap(
sewer.SewedShape(),
Part::MapperSewing(sewer),
shells,
Part::OpCodes::Sewing
);
}
else {
// shells are already closed - add them directly
BRepBuilderAPI_MakeSolid mkSolid;
for (TopoShape& s : shells) {
mkSolid.Add(TopoDS::Shell(s.getShape()));
}
if (!mkSolid.IsDone())
return new App::DocumentObjectExecReturn(QT_TRANSLATE_NOOP("Exception", "Result is not a solid"));
if (!mkSolid.IsDone()) {
return new App::DocumentObjectExecReturn(
QT_TRANSLATE_NOOP("Exception", "Result is not a solid")
);
}
result.setShape(mkSolid.Shape());
}
if(!result.countSubShapes(TopAbs_SHELL))
return new App::DocumentObjectExecReturn(QT_TRANSLATE_NOOP("Exception", "Loft: Failed to create shell"));
if (!result.countSubShapes(TopAbs_SHELL)) {
return new App::DocumentObjectExecReturn(
QT_TRANSLATE_NOOP("Exception", "Loft: Failed to create shell")
);
}
auto shapes = result.getSubTopoShapes(TopAbs_SHELL);
for (auto &s : shapes) {
for (auto& s : shapes) {
// build the solid
s = s.makeElementSolid();
BRepClass3d_SolidClassifier SC(s.getShape());
SC.PerformInfinitePoint(Precision::Confusion());
if ( SC.State() == TopAbs_IN)
s.setShape(s.getShape().Reversed(),false);
if (SC.State() == TopAbs_IN) {
s.setShape(s.getShape().Reversed(), false);
}
}
AddSubShape.setValue(result.makeElementCompound(shapes, nullptr, Part::TopoShape::SingleShapeCompoundCreationPolicy::returnShape));
AddSubShape.setValue(result.makeElementCompound(
shapes,
nullptr,
Part::TopoShape::SingleShapeCompoundCreationPolicy::returnShape
));
if (shapes.size() > 1)
if (shapes.size() > 1) {
result.makeElementFuse(shapes);
else
}
else {
result = shapes.front();
}
if(base.isNull()) {
if (getAddSubType() == FeatureAddSub::Subtractive)
if (base.isNull()) {
if (getAddSubType() == FeatureAddSub::Subtractive) {
return new App::DocumentObjectExecReturn(
QT_TRANSLATE_NOOP("Exception", "Pipe: There is nothing to subtract from"));
QT_TRANSLATE_NOOP("Exception", "Pipe: There is nothing to subtract from")
);
}
if (!isSingleSolidRuleSatisfied(result.getShape())) {
return new App::DocumentObjectExecReturn(QT_TRANSLATE_NOOP("Exception", "Result has multiple solids: enable 'Allow Compound' in the active body."));
return new App::DocumentObjectExecReturn(QT_TRANSLATE_NOOP(
"Exception",
"Result has multiple solids: enable 'Allow Compound' in the active body."
));
}
// store shape before refinement
@@ -409,7 +492,7 @@ App::DocumentObjectExecReturn *Pipe::execute()
}
TopoShape boolOp(0, getDocument()->getStringHasher());
const char *maker;
const char* maker;
switch (getAddSubType()) {
case Additive:
maker = Part::OpCodes::Fuse;
@@ -418,26 +501,35 @@ App::DocumentObjectExecReturn *Pipe::execute()
maker = Part::OpCodes::Cut;
break;
default:
return new App::DocumentObjectExecReturn(QT_TRANSLATE_NOOP("Exception", "Unknown operation type"));
return new App::DocumentObjectExecReturn(
QT_TRANSLATE_NOOP("Exception", "Unknown operation type")
);
}
try {
boolOp.makeElementBoolean(maker, {base,result});
boolOp.makeElementBoolean(maker, {base, result});
}
catch(Standard_Failure&) {
return new App::DocumentObjectExecReturn(QT_TRANSLATE_NOOP("Exception", "Failed to perform boolean operation"));
catch (Standard_Failure&) {
return new App::DocumentObjectExecReturn(
QT_TRANSLATE_NOOP("Exception", "Failed to perform boolean operation")
);
}
TopoShape solid = getSolid(boolOp);
// lets check if the result is a solid
if (solid.isNull())
return new App::DocumentObjectExecReturn(QT_TRANSLATE_NOOP("Exception", "Resulting shape is not a solid"));
if (solid.isNull()) {
return new App::DocumentObjectExecReturn(
QT_TRANSLATE_NOOP("Exception", "Resulting shape is not a solid")
);
}
// store shape before refinement
this->rawShape = boolOp;
boolOp = refineShapeIfActive(boolOp);
if (!isSingleSolidRuleSatisfied(boolOp.getShape())) {
return new App::DocumentObjectExecReturn(QT_TRANSLATE_NOOP("Exception",
"Result has multiple solids: enable 'Allow Compound' in the active body."));
return new App::DocumentObjectExecReturn(QT_TRANSLATE_NOOP(
"Exception",
"Result has multiple solids: enable 'Allow Compound' in the active body."
));
}
boolOp = getSolid(boolOp);
Shape.setValue(boolOp);
@@ -447,15 +539,18 @@ App::DocumentObjectExecReturn *Pipe::execute()
return new App::DocumentObjectExecReturn(e.GetMessageString());
}
catch (...) {
return new App::DocumentObjectExecReturn(QT_TRANSLATE_NOOP("Exception", "A fatal error occurred when making the pipe"));
return new App::DocumentObjectExecReturn(
QT_TRANSLATE_NOOP("Exception", "A fatal error occurred when making the pipe")
);
}
}
void Pipe::setupAlgorithm(BRepOffsetAPI_MakePipeShell& mkPipeShell, const TopoDS_Shape& auxshape) {
void Pipe::setupAlgorithm(BRepOffsetAPI_MakePipeShell& mkPipeShell, const TopoDS_Shape& auxshape)
{
mkPipeShell.SetTolerance(Precision::Confusion());
switch(Transition.getValue()) {
switch (Transition.getValue()) {
case 0:
mkPipeShell.SetTransitionMode(BRepBuilderAPI_Transformed);
break;
@@ -469,7 +564,7 @@ void Pipe::setupAlgorithm(BRepOffsetAPI_MakePipeShell& mkPipeShell, const TopoDS
bool auxiliary = false;
const Base::Vector3d& bVec = Binormal.getValue();
switch(Mode.getValue()) {
switch (Mode.getValue()) {
case 1:
mkPipeShell.SetMode(gp_Ax2(gp_Pnt(0, 0, 0), gp_Dir(0, 0, 1), gp_Dir(1, 0, 0)));
break;
@@ -543,17 +638,20 @@ void Pipe::getContinuousEdges(Part::TopoShape /*TopShape*/, std::vector<std::str
*/
}
void Pipe::buildPipePath(const Part::TopoShape& shape, const std::vector<std::string>& subedge,
TopoDS_Shape& path)
void Pipe::buildPipePath(
const Part::TopoShape& shape,
const std::vector<std::string>& subedge,
TopoDS_Shape& path
)
{
if (!shape.getShape().IsNull()) {
try {
if (!subedge.empty()) {
//if (SpineTangent.getValue())
//getContinuousEdges(shape, subedge);
// if (SpineTangent.getValue())
// getContinuousEdges(shape, subedge);
BRepBuilderAPI_MakeWire mkWire;
for (const auto & it : subedge) {
for (const auto& it : subedge) {
TopoDS_Shape subshape = shape.getSubShape(it.c_str());
mkWire.Add(TopoDS::Edge(subshape));
}
@@ -569,28 +667,42 @@ void Pipe::buildPipePath(const Part::TopoShape& shape, const std::vector<std::st
else if (shape.getShape().ShapeType() == TopAbs_COMPOUND) {
TopoDS_Iterator it(shape.getShape());
for (; it.More(); it.Next()) {
if (it.Value().IsNull())
throw Base::ValueError(QT_TRANSLATE_NOOP("Exception", "Invalid element in spine."));
if ((it.Value().ShapeType() != TopAbs_EDGE) &&
(it.Value().ShapeType() != TopAbs_WIRE)) {
throw Base::TypeError(QT_TRANSLATE_NOOP("Exception", "Element in spine is neither an edge nor a wire."));
if (it.Value().IsNull()) {
throw Base::ValueError(
QT_TRANSLATE_NOOP("Exception", "Invalid element in spine.")
);
}
if ((it.Value().ShapeType() != TopAbs_EDGE)
&& (it.Value().ShapeType() != TopAbs_WIRE)) {
throw Base::TypeError(QT_TRANSLATE_NOOP(
"Exception",
"Element in spine is neither an edge nor a wire."
));
}
}
Handle(TopTools_HSequenceOfShape) hEdges = new TopTools_HSequenceOfShape();
Handle(TopTools_HSequenceOfShape) hWires = new TopTools_HSequenceOfShape();
for (TopExp_Explorer xp(shape.getShape(), TopAbs_EDGE); xp.More(); xp.Next())
for (TopExp_Explorer xp(shape.getShape(), TopAbs_EDGE); xp.More(); xp.Next()) {
hEdges->Append(xp.Current());
}
ShapeAnalysis_FreeBounds::ConnectEdgesToWires(
hEdges, Precision::Confusion(), Standard_True, hWires);
hEdges,
Precision::Confusion(),
Standard_True,
hWires
);
int len = hWires->Length();
if (len != 1)
if (len != 1) {
throw Base::ValueError(QT_TRANSLATE_NOOP("Exception", "Spine is not connected."));
}
path = hWires->Value(1);
}
else {
throw Base::TypeError(QT_TRANSLATE_NOOP("Exception", "Spine is neither an edge nor a wire."));
throw Base::TypeError(
QT_TRANSLATE_NOOP("Exception", "Spine is neither an edge nor a wire.")
);
}
}
catch (Standard_Failure&) {
@@ -599,17 +711,18 @@ void Pipe::buildPipePath(const Part::TopoShape& shape, const std::vector<std::st
}
}
PROPERTY_SOURCE(PartDesign::AdditivePipe, PartDesign::Pipe)
AdditivePipe::AdditivePipe() {
AdditivePipe::AdditivePipe()
{
addSubType = Additive;
}
PROPERTY_SOURCE(PartDesign::SubtractivePipe, PartDesign::Pipe)
SubtractivePipe::SubtractivePipe() {
SubtractivePipe::SubtractivePipe()
{
addSubType = Subtractive;
}
void Pipe::handleChangedPropertyType(Base::XMLReader& reader, const char* TypeName,
App::Property* prop)
void Pipe::handleChangedPropertyType(Base::XMLReader& reader, const char* TypeName, App::Property* prop)
{
// property Sections had the App::PropertyLinkList and was changed to App::PropertyXLinkSubList
if (prop == &Sections && strcmp(TypeName, "App::PropertyLinkList") == 0) {
@@ -620,9 +733,7 @@ void Pipe::handleChangedPropertyType(Base::XMLReader& reader, const char* TypeNa
}
}
void Pipe::handleChangedPropertyName(Base::XMLReader& reader,
const char* TypeName,
const char* PropName)
void Pipe::handleChangedPropertyName(Base::XMLReader& reader, const char* TypeName, const char* PropName)
{
// The AuxiliarySpine property was AuxillerySpine in the past
std::string strAuxillerySpine("AuxillerySpine");
@@ -634,8 +745,7 @@ void Pipe::handleChangedPropertyName(Base::XMLReader& reader,
if (AuxiliarySpine.getClassTypeId() == type && strAuxillerySpine == PropName) {
AuxiliarySpine.Restore(reader);
}
else if (AuxiliarySpineTangent.getClassTypeId() == type
&& strAuxillerySpineTangent == PropName) {
else if (AuxiliarySpineTangent.getClassTypeId() == type && strAuxillerySpineTangent == PropName) {
AuxiliarySpineTangent.Restore(reader);
}
else if (AuxiliaryCurvilinear.getClassTypeId() == type && strAuxilleryCurvelinear == PropName) {
@@ -645,4 +755,3 @@ void Pipe::handleChangedPropertyName(Base::XMLReader& reader,
ProfileBased::handleChangedPropertyName(reader, TypeName, PropName);
}
}