Part: Link support -- replace TopoShape.getSubShape() with Part::Feature::getTopoShape(obj, elementname, true).getShape() in order to support use of App::Link sublinks.

This commit is contained in:
mwganson
2022-04-17 14:06:53 -05:00
committed by Uwe
parent 41afe9d8ae
commit 4f300abf32
7 changed files with 20 additions and 9 deletions

View File

@@ -100,7 +100,7 @@ bool Extrusion::fetchAxisLink(const App::PropertyLinkSub& axisLink, Base::Vector
TopoDS_Shape axEdge;
if (axisLink.getSubValues().size() > 0 && axisLink.getSubValues()[0].length() > 0) {
axEdge = Feature::getTopoShape(linked).getSubShape(axisLink.getSubValues()[0].c_str());
axEdge = Feature::getTopoShape(linked, axisLink.getSubValues()[0].c_str(), true /*need element*/).getShape();
}
else {
axEdge = Feature::getShape(linked);

View File

@@ -94,7 +94,7 @@ bool Revolution::fetchAxisLink(const App::PropertyLinkSub &axisLink,
TopoDS_Shape axEdge;
if (axisLink.getSubValues().size() > 0 && axisLink.getSubValues()[0].length() > 0){
axEdge = Feature::getTopoShape(linked).getSubShape(axisLink.getSubValues()[0].c_str());
axEdge = Feature::getTopoShape(linked, axisLink.getSubValues()[0].c_str(), true /*need element*/).getShape();
} else {
axEdge = Feature::getShape(linked);
}

View File

@@ -61,6 +61,8 @@ RuledSurface::RuledSurface()
ADD_PROPERTY_TYPE(Curve2,(nullptr),"Ruled Surface",App::Prop_None,"Curve of ruled surface");
ADD_PROPERTY_TYPE(Orientation,((long)0),"Ruled Surface",App::Prop_None,"Orientation of ruled surface");
Orientation.setEnums(OrientationEnums);
ADD_PROPERTY_TYPE(ResetPlacement,(false),"Ruled Surface",App::Prop_None,
"Whether to reset placement");
}
short RuledSurface::mustExecute() const
@@ -71,6 +73,8 @@ short RuledSurface::mustExecute() const
return 1;
if (Orientation.isTouched())
return 1;
if (ResetPlacement.isTouched())
return 1;
return 0;
}
@@ -100,6 +104,7 @@ App::DocumentObjectExecReturn* RuledSurface::getShape(const App::PropertyLinkSub
if (!part.getShape().IsNull()) {
if (!element[0].empty()) {
//shape = Part::Feature::getTopoShape(obj, element[0].c_str(), true /*need element*/).getShape();
shape = part.getSubShape(element[0].c_str());
}
else {
@@ -239,15 +244,20 @@ App::DocumentObjectExecReturn *RuledSurface::execute(void)
// re-apply the placement in case we reset it
if (!Loc.IsIdentity())
ruledShape.Move(Loc);
Loc = ruledShape.Location();
if (!Loc.IsIdentity()) {
if (!Loc.IsIdentity() && ResetPlacement.getValue()) {
// reset the placement of the shape because the Placement
// property will be changed
ruledShape.Location(TopLoc_Location());
Base::Matrix4D transform;
TopoShape::convertToMatrix(Loc.Transformation(), transform);
this->Placement.setValue(Base::Placement(transform));
} else {
if (!Loc.IsIdentity()){ //Reset Placement property = False
this->Placement.setValue(Base::Placement());
}
}
this->Shape.setValue(ruledShape);
@@ -431,7 +441,7 @@ App::DocumentObjectExecReturn *Sweep::execute(void)
if (!subedge.empty()) {
BRepBuilderAPI_MakeWire mkWire;
for (std::vector<std::string>::const_iterator it = subedge.begin(); it != subedge.end(); ++it) {
TopoDS_Shape subshape = shape.getSubShape(it->c_str());
TopoDS_Shape subshape = Feature::getTopoShape(spine, it->c_str(), true /*need element*/).getShape();
mkWire.Add(TopoDS::Edge(subshape));
}
path = mkWire.Wire();

View File

@@ -41,6 +41,7 @@ public:
App::PropertyEnumeration Orientation;
App::PropertyLinkSub Curve1;
App::PropertyLinkSub Curve2;
App::PropertyBool ResetPlacement;
/** @name methods override feature */
//@{

View File

@@ -2108,11 +2108,11 @@ void CmdPartRuledSurface::activated(int iMsg)
}
if (ok && subnames1.size() <= 2) {
if (subnames1.size() >= 1) {
curve1 = shape1.getSubShape(subnames1[0].c_str());
curve1 = Part::Feature::getTopoShape(docobj1, subnames1[0].c_str(), true /*need element*/).getShape();
link1 = subnames1[0];
}
if (subnames1.size() == 2) {
curve2 = shape1.getSubShape(subnames1[1].c_str());
curve2 = Part::Feature::getTopoShape(docobj1, subnames1[1].c_str(), true /*need element*/).getShape();
link2 = subnames1[1];
}
if (subnames1.size() == 0) {
@@ -2132,7 +2132,7 @@ void CmdPartRuledSurface::activated(int iMsg)
ok = false;
}
if (ok && subnames2.size() == 1) {
curve2 = shape2.getSubShape(subnames2[0].c_str());
curve2 = Part::Feature::getTopoShape(docobj2, subnames2[0].c_str(), true /*need element*/).getShape();
link2 = subnames2[0];
} else {
if (subnames2.size() == 0) {

View File

@@ -81,7 +81,7 @@ public:
return false;
}
try {
TopoDS_Shape sub = part.getSubShape(sSubName);
TopoDS_Shape sub = Part::Feature::getTopoShape(pObj, sSubName, true /*need element*/).getShape();
if (!sub.IsNull() && sub.ShapeType() == TopAbs_EDGE) {
const TopoDS_Edge& edge = TopoDS::Edge(sub);
BRepAdaptor_Curve adapt(edge);

View File

@@ -300,7 +300,7 @@ bool SweepWidget::accept()
topoShape = Part::Feature::getTopoShape(docobj);
if (!topoShape.isNull()) {
for (std::vector<std::string>::const_iterator it = subnames.begin(); it != subnames.end(); ++it) {
subShapes.push_back(topoShape.getSubShape(subnames[0].c_str()));
subShapes.push_back(Part::Feature::getTopoShape(docobj, subnames[0].c_str(), true /*need element*/));
}
for (std::vector<Part::TopoShape>::iterator it = subShapes.begin(); it != subShapes.end(); ++it) {
TopoDS_Shape dsShape = (*it).getShape();