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 0791001787
commit 26e4a3345b
7 changed files with 20 additions and 9 deletions

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();