Toponaming/Part: Fix all getBaseTopoShape calls. Tests and missing code.
This commit is contained in:
@@ -893,12 +893,34 @@ private:
|
||||
App::Document *pcDoc = App::GetApplication().getActiveDocument();
|
||||
if (!pcDoc)
|
||||
pcDoc = App::GetApplication().newDocument();
|
||||
#ifndef FC_USE_TNP_FIX
|
||||
TopoShapePy* pShape = static_cast<TopoShapePy*>(pcObj);
|
||||
Part::Feature *pcFeature = static_cast<Part::Feature*>(pcDoc->addObject("Part::Feature", name));
|
||||
// copy the data
|
||||
pcFeature->Shape.setValue(pShape->getTopoShapePtr()->getShape());
|
||||
pcDoc->recompute();
|
||||
return Py::asObject(pcFeature->getPyObject());
|
||||
#else
|
||||
App::Document *pcSrcDoc = nullptr;
|
||||
TopoShape shape;
|
||||
if (PyObject_TypeCheck(pcObj, &TopoShapePy::Type))
|
||||
shape = *static_cast<TopoShapePy*>(pcObj)->getTopoShapePtr();
|
||||
else if (PyObject_TypeCheck(pcObj, &GeometryPy::Type))
|
||||
shape = static_cast<GeometryPy*>(pcObj)->getGeometryPtr()->toShape();
|
||||
else if (PyObject_TypeCheck(pcObj, &App::DocumentObjectPy::Type)) {
|
||||
auto obj = static_cast<App::DocumentObjectPy*>(pcObj)->getDocumentObjectPtr();
|
||||
pcSrcDoc = obj->getDocument();
|
||||
shape = Feature::getTopoShape(obj);
|
||||
}
|
||||
else
|
||||
throw Py::TypeError("Expects argument of type DocumentObject, Shape, or Geometry");
|
||||
Part::Feature *pcFeature = static_cast<Part::Feature*>(pcDoc->addObject("Part::Feature", name));
|
||||
// copy the data
|
||||
pcFeature->Shape.setValue(shape);
|
||||
pcFeature->purgeTouched();
|
||||
return Py::asObject(pcFeature->getPyObject());
|
||||
#endif
|
||||
|
||||
}
|
||||
Py::Object getFacets(const Py::Tuple& args)
|
||||
{
|
||||
|
||||
@@ -1015,6 +1015,22 @@ TopoShape Feature::getTopoShape(const App::DocumentObject* obj,
|
||||
hiddens,
|
||||
lastLink);
|
||||
|
||||
if (needSubElement && shape.shapeType(true) == TopAbs_COMPOUND) {
|
||||
if (shape.countSubShapes(TopAbs_SOLID) == 1)
|
||||
shape = shape.getSubTopoShape(TopAbs_SOLID, 1);
|
||||
else if (shape.countSubShapes(TopAbs_COMPSOLID) == 1)
|
||||
shape = shape.getSubTopoShape(TopAbs_COMPSOLID, 1);
|
||||
else if (shape.countSubShapes(TopAbs_FACE) == 1)
|
||||
shape = shape.getSubTopoShape(TopAbs_FACE, 1);
|
||||
else if (shape.countSubShapes(TopAbs_SHELL) == 1)
|
||||
shape = shape.getSubTopoShape(TopAbs_SHELL, 1);
|
||||
else if (shape.countSubShapes(TopAbs_EDGE) == 1)
|
||||
shape = shape.getSubTopoShape(TopAbs_EDGE, 1);
|
||||
else if (shape.countSubShapes(TopAbs_WIRE) == 1)
|
||||
shape = shape.getSubTopoShape(TopAbs_WIRE, 1);
|
||||
else if (shape.countSubShapes(TopAbs_VERTEX) == 1)
|
||||
shape = shape.getSubTopoShape(TopAbs_VERTEX, 1);
|
||||
}
|
||||
Base::Matrix4D topMat;
|
||||
if (pmat || transform) {
|
||||
// Obtain top level transformation
|
||||
|
||||
@@ -5574,6 +5574,9 @@ TopoShape& TopoShape::makeElementBoolean(const char* maker,
|
||||
for (auto it = shapes.begin(); it != shapes.end(); ++it) {
|
||||
auto& s = *it;
|
||||
if (s.isNull()) {
|
||||
if ( it == shapes.begin() ) {
|
||||
return *this; // Compatible with pre-TNP allowing <null shape>.fuse() behavior
|
||||
}
|
||||
FC_THROWM(NullShapeException, "Null input shape");
|
||||
}
|
||||
if (s.shapeType() == TopAbs_COMPOUND) {
|
||||
|
||||
Reference in New Issue
Block a user