Part: changes to Part Module
* Added Part::Feature::getTopoShape/getShape() function that can obtain
shape from any object with proper implementation of getSubObject(). It
can even construct compound from group object with proper implementation
of getSubObjects().
* Modified ViewProviderExt to work on any object, because it now obtain
the shape using Part::Feature::getShape()
* Modified various Part features to obtain base/tool shapes using
Part::getShape(), which allows them to be any type of object,
including Link and groups.
* Modified various Part command to relax type requirement on selected
objects.
* Add support of link and group to dimension, and add dimension refresh
command
* Support link and group in simple command command, and add a few more
copy command variations.
* Add special handling of 'Shape' attribute in PropertyContainerPy and
use Part::Feature::getShape() to return shape for any object without
Shape property. This allows many python feature work with any object
without modification.
* GeometrySurface/CurvePy, add convenience attribute 'Rotation'
* TopoShapePy:
* Extended support of sub shape attribute, e.g. Compound1, Solid2,
SubShape3 ('SubShape' is used to access child shape of a compound)
* makeWires(), new API to sort and return wires given a list of edges.
* transformed/translated/rotated/scaled(), return a new shape with
some transformation.
* findPlane(), find the plane of a planar shape
* isCoplanar(), check if two shape are coplanar
This commit is contained in:
@@ -102,16 +102,13 @@ bool Extrusion::fetchAxisLink(const App::PropertyLinkSub& axisLink, Base::Vector
|
||||
if (!axisLink.getValue())
|
||||
return false;
|
||||
|
||||
if (!axisLink.getValue()->isDerivedFrom(Part::Feature::getClassTypeId()))
|
||||
throw Base::TypeError("AxisLink has no OCC shape");
|
||||
|
||||
Part::Feature* linked = static_cast<Part::Feature*>(axisLink.getValue());
|
||||
auto linked = axisLink.getValue();
|
||||
|
||||
TopoDS_Shape axEdge;
|
||||
if (axisLink.getSubValues().size() > 0 && axisLink.getSubValues()[0].length() > 0){
|
||||
axEdge = linked->Shape.getShape().getSubShape(axisLink.getSubValues()[0].c_str());
|
||||
axEdge = Feature::getTopoShape(linked).getSubShape(axisLink.getSubValues()[0].c_str());
|
||||
} else {
|
||||
axEdge = linked->Shape.getValue();
|
||||
axEdge = Feature::getShape(linked);
|
||||
}
|
||||
|
||||
if (axEdge.IsNull())
|
||||
@@ -196,25 +193,21 @@ Extrusion::ExtrusionParameters Extrusion::computeFinalParameters()
|
||||
|
||||
Base::Vector3d Extrusion::calculateShapeNormal(const App::PropertyLink& shapeLink)
|
||||
{
|
||||
if (!shapeLink.getValue())
|
||||
App::DocumentObject* docobj = 0;
|
||||
Base::Matrix4D mat;
|
||||
TopoDS_Shape sh = Feature::getShape(shapeLink.getValue(),0,false, &mat,&docobj);
|
||||
|
||||
if (!docobj)
|
||||
throw Base::ValueError("calculateShapeNormal: link is empty");
|
||||
const App::DocumentObject* docobj = shapeLink.getValue();
|
||||
|
||||
//special case for sketches and the like: no matter what shape they have, use their local Z axis.
|
||||
if (docobj->isDerivedFrom(Part::Part2DObject::getClassTypeId())){
|
||||
const Part::Part2DObject* p2do = static_cast<const Part::Part2DObject*>(docobj);
|
||||
Base::Vector3d OZ (0.0, 0.0, 1.0);
|
||||
Base::Vector3d result;
|
||||
p2do->Placement.getValue().getRotation().multVec(OZ, result);
|
||||
Base::Rotation(mat).multVec(OZ, result);
|
||||
return result;
|
||||
}
|
||||
|
||||
//extract the shape
|
||||
if (! docobj->isDerivedFrom(Part::Feature::getClassTypeId()))
|
||||
throw Base::TypeError("Linked object doesn't have shape.");
|
||||
|
||||
const TopoShape &tsh = static_cast<const Part::Feature*>(docobj)->Shape.getShape();
|
||||
TopoDS_Shape sh = tsh.getShape();
|
||||
if (sh.IsNull())
|
||||
throw NullShapeException("calculateShapeNormal: link points to a valid object, but its shape is null.");
|
||||
|
||||
@@ -327,13 +320,10 @@ App::DocumentObjectExecReturn *Extrusion::execute(void)
|
||||
App::DocumentObject* link = Base.getValue();
|
||||
if (!link)
|
||||
return new App::DocumentObjectExecReturn("No object linked");
|
||||
if (!link->getTypeId().isDerivedFrom(Part::Feature::getClassTypeId()))
|
||||
return new App::DocumentObjectExecReturn("Linked object is not a Part object");
|
||||
Part::Feature *base = static_cast<Part::Feature*>(Base.getValue());
|
||||
|
||||
try {
|
||||
Extrusion::ExtrusionParameters params = computeFinalParameters();
|
||||
TopoShape result = extrudeShape(base->Shape.getShape(),params);
|
||||
TopoShape result = extrudeShape(Feature::getShape(link),params);
|
||||
this->Shape.setValue(result);
|
||||
return App::DocumentObject::StdReturn;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user