Toponaming/Part: Rework and clean python interface and add tests

This commit is contained in:
bgbsww
2024-03-20 17:06:30 -04:00
parent 644491fcd7
commit 58bfabf925
6 changed files with 433 additions and 175 deletions

View File

@@ -103,11 +103,11 @@
#include "TopoShapeShellPy.h"
#include "TopoShapeSolidPy.h"
#include "TopoShapeWirePy.h"
#include "TopoShapeOpCode.h"
#include "TopoShapeMapper.h"
#ifdef FCUseFreeType
# include "FT2FC.h"
#include "TopoShapeOpCode.h"
#include "TopoShapeMapper.h"
#endif
extern const char* BRepBuilderAPI_FaceErrorText(BRepBuilderAPI_FaceError fe);
@@ -423,7 +423,8 @@ public:
add_varargs_method("getFacets",&Module::getFacets,
"getFacets(shape): simplified mesh generation"
);
add_varargs_method("makeCompound",&Module::makeCompound,
#ifdef FC_USE_TNP_FIX
add_keyword_method("makeCompound",&Module::makeCompound,
"makeCompound(list) -- Create a compound out of a list of shapes."
);
add_keyword_method("makeShell",&Module::makeShell,
@@ -442,6 +443,27 @@ public:
add_keyword_method("makeSolid",&Module::makeSolid,
"makeSolid(shape): Create a solid out of shells of shape. If shape is a compsolid, the overall volume solid is created."
);
#else
add_varargs_method("makeCompound",&Module::makeCompound,
"makeCompound(list) -- Create a compound out of a list of shapes."
);
add_varargs_method("makeShell",&Module::makeShell,
"makeShell(list) -- Create a shell out of a list of faces."
);
add_varargs_method("makeFace",&Module::makeFace,
"makeFace(list_of_shapes_or_compound, maker_class_name) -- Create a face (faces) using facemaker class.\n"
"maker_class_name is a string like 'Part::FaceMakerSimple'."
);
add_varargs_method("makeFilledSurface",&Module::makeFilledSurface,
"makeFilledSurface(list of curves, tolerance) -- Create a surface out of a list of curves."
);
add_varargs_method("makeFilledFace",&Module::makeFilledFace,
"makeFilledFace(list) -- Create a face out of a list of edges."
);
add_varargs_method("makeSolid",&Module::makeSolid,
"makeSolid(shape): Create a solid out of shells of shape. If shape is a compsolid, the overall volume solid is created."
);
#endif
add_varargs_method("makePlane",&Module::makePlane,
"makePlane(length,width,[pnt,dirZ,dirX]) -- Make a plane\n"
"By default pnt=Vector(0,0,0) and dirZ=Vector(0,0,1), dirX is ignored in this case"
@@ -522,6 +544,7 @@ public:
"By default vmin/vmax=bounds of the curve, angle=360, pnt=Vector(0,0,0),\n"
"dir=Vector(0,0,1) and shapetype=Part.Solid"
);
#ifdef FC_USE_TNP_FIX
add_keyword_method("makeRuledSurface",&Module::makeRuledSurface,
"makeRuledSurface(Edge|Wire,Edge|Wire) -- Make a ruled surface\n"
"Create a ruled surface out of two edges or wires. If wires are used then"
@@ -531,6 +554,23 @@ public:
"makeShellFromWires(Wires) -- Make a shell from wires.\n"
"The wires must have the same number of edges."
);
add_keyword_method("makeLoft",&Module::makeLoft,
"makeLoft(list of wires,[solid=False,ruled=False,closed=False,maxDegree=5]) -- Create a loft shape."
);
#else
add_varargs_method("makeRuledSurface",&Module::makeRuledSurface,
"makeRuledSurface(Edge|Wire,Edge|Wire) -- Make a ruled surface\n"
"Create a ruled surface out of two edges or wires. If wires are used then"
"these must have the same number of edges."
);
add_varargs_method("makeShellFromWires",&Module::makeShellFromWires,
"makeShellFromWires(Wires) -- Make a shell from wires.\n"
"The wires must have the same number of edges."
);
add_varargs_method("makeLoft",&Module::makeLoft,
"makeLoft(list of wires,[solid=False,ruled=False,closed=False,maxDegree=5]) -- Create a loft shape."
);
#endif
add_varargs_method("makeTube",&Module::makeTube,
"makeTube(edge,radius,[continuity,max degree,max segments]) -- Create a tube.\n"
"continuity is a string which must be 'C0','C1','C2','C3','CN','G1' or 'G1',"
@@ -538,9 +578,6 @@ public:
add_varargs_method("makeSweepSurface",&Module::makeSweepSurface,
"makeSweepSurface(edge(path),edge(profile),[float]) -- Create a profile along a path."
);
add_keyword_method("makeLoft",&Module::makeLoft,
"makeLoft(list of wires,[solid=False,ruled=False,closed=False,maxDegree=5]) -- Create a loft shape."
);
add_varargs_method("makeWireString",&Module::makeWireString,
"makeWireString(string,fontdir,fontfile,height,[track]) -- Make list of wires in the form of a string's characters."
);
@@ -887,18 +924,36 @@ private:
}
return list;
}
Py::Object makeCompound(const Py::Tuple& args)
#ifdef FC_USE_TNP_FIX
Py::Object makeCompound(const Py::Tuple& args, const Py::Dict &kwds)
{
#ifndef FC_USE_TNP_FIX
PyObject *pcObj;
PyObject *force = Py_True;
const char *op = nullptr;
static char* kwd_list[] = {"shapes", "force", "op", nullptr};
if(!PyArg_ParseTupleAndKeywords(args.ptr(), kwds.ptr(), "O|O!s", kwd_list, &pcObj, &PyBool_Type, &force, &op))
PyObject* pcObj;
PyObject* force = Py_True;
TopoShape::SingleShapeCompoundCreationPolicy
policy; // = TopoShape::SingleShapeCompoundCreationPolicy::forceCompound;
PyObject* module = PyImport_ImportModule("PartEnums");
PyObject* policyEnum =
PyObject_GetAttrString(module, (char*)"SingleShapeCompoundCreationPolicy");
const char* op = nullptr;
const std::array<const char*, 4> kwd_list = {"shapes", "force", "op", nullptr};
if (!Base::Wrapped_ParseTupleAndKeywords(args.ptr(),
kwds.ptr(),
"O|O!s",
kwd_list,
&pcObj,
policyEnum,
&force,
&op)) {
throw Py::Exception();
}
return shape2pyshape(Part::TopoShape().makECompound(getPyShapes(pcObj), op, PyObject_IsTrue(force)));
policy = static_cast<TopoShape::SingleShapeCompoundCreationPolicy>(PyLong_AsLong(force));
Py_DECREF(policyEnum);
return shape2pyshape(Part::TopoShape().makeElementCompound(getPyShapes(pcObj), op, policy));
#else
Py::Object makeCompound(const Py::Tuple& args)
{
PyObject *pcObj;
if (!PyArg_ParseTuple(args.ptr(), "O", &pcObj))
throw Py::Exception();
@@ -917,16 +972,25 @@ private:
return Py::asObject(new TopoShapeCompoundPy(new TopoShape(Comp)));
#endif
}
#ifdef FC_USE_TNP_FIX
Py::Object makeShell(const Py::Tuple& args, const Py::Dict &kwds)
{
#ifdef FC_USE_TNP_FIX
PyObject *obj;
const char *op = nullptr;
const std::array<const char *, 3> kwd_list = {"shapes", "op", nullptr};
if(!Base::Wrapped_ParseTupleAndKeywords(args.ptr(), kwds.ptr(), "O|s", kwd_list, &obj, &op))
PyObject* obj;
const char* op = nullptr;
const std::array<const char*, 3> kwd_list = {"shapes", "op", nullptr};
if (!Base::Wrapped_ParseTupleAndKeywords(args.ptr(),
kwds.ptr(),
"O|s",
kwd_list,
&obj,
&op)) {
throw Py::Exception();
return shape2pyshape(Part::TopoShape().makeElementBoolean(Part::OpCodes::Shell,getPyShapes(obj),op));
}
return shape2pyshape(
Part::TopoShape().makeElementBoolean(Part::OpCodes::Shell, getPyShapes(obj), op));
#else
Py::Object makeShell(const Py::Tuple& args)
{
PyObject *obj;
if (!PyArg_ParseTuple(args.ptr(), "O", &obj))
throw Py::Exception();
@@ -962,18 +1026,26 @@ private:
return Py::asObject(new TopoShapeShellPy(new TopoShape(shape)));
#endif
}
#ifdef FC_USE_TNP_FIX
Py::Object makeFace(const Py::Tuple& args, const Py::Dict &kwds)
{
#ifdef FC_USE_TNP_FIX
PyObject *obj;
const char *className = nullptr;
const char *op = nullptr;
const std::array<const char *, 4> kwd_list = {"shapes", "class_name", "op", nullptr};
if(!Base::Wrapped_ParseTupleAndKeywords(args.ptr(), kwds.ptr(), "O|ss", kwd_list,
&obj, &className, &op))
PyObject* obj;
const char* className = nullptr;
const char* op = nullptr;
const std::array<const char*, 4> kwd_list = {"shapes", "class_name", "op", nullptr};
if (!Base::Wrapped_ParseTupleAndKeywords(args.ptr(),
kwds.ptr(),
"O|ss",
kwd_list,
&obj,
&className,
&op)) {
throw Py::Exception();
return shape2pyshape(TopoShape().makeElementFace(getPyShapes(obj),op,className));
}
return shape2pyshape(TopoShape().makeElementFace(getPyShapes(obj), op, className));
#else
Py::Object makeFace(const Py::Tuple& args)
{
try {
char* className = nullptr;
PyObject* pcPyShapeOrList = nullptr;
@@ -1045,47 +1117,85 @@ private:
}
#ifdef FC_USE_TNP_FIX
Py::Object makeFilledSurface(const Py::Tuple &args, const Py::Dict &kwds)
{
#ifdef FC_USE_TNP_FIX
TopoShape::BRepFillingParams params;
PyObject *obj = nullptr;
PyObject *pySurface = Py_None;
PyObject *supports = Py_None;
PyObject *orders = Py_None;
PyObject *anisotropy = params.anisotropy ? Py_True : Py_False;
const char *op = nullptr;
const std::array<const char *, 16> kwd_list = {"shapes", "surface", "supports",
"orders","degree","ptsOnCurve","numIter","anisotropy",
"tol2d", "tol3d", "tolG1", "tolG2", "maxDegree", "maxSegments", "op", nullptr};
if(!Base::Wrapped_ParseTupleAndKeywords(args.ptr(), kwds.ptr(), "O|O!OOIIIOddddIIs", kwd_list,
&obj, &pySurface, &orders, &params.degree, &params.ptsoncurve,
&params.numiter, &anisotropy, &params.tol2d, &params.tol3d,
&params.tolG1, &params.tolG2, &params.maxdeg, &params.maxseg, &op))
PyObject* obj = nullptr;
PyObject* pySurface = Py_None;
PyObject* supports = Py_None;
PyObject* orders = Py_None;
PyObject* anisotropy = params.anisotropy ? Py_True : Py_False;
const char* op = nullptr;
const std::array<const char*, 16> kwd_list = {"shapes",
"surface",
"supports",
"orders",
"degree",
"ptsOnCurve",
"numIter",
"anisotropy",
"tol2d",
"tol3d",
"tolG1",
"tolG2",
"maxDegree",
"maxSegments",
"op",
nullptr};
if (!Base::Wrapped_ParseTupleAndKeywords(args.ptr(),
kwds.ptr(),
"O|O!OOIIIOddddIIs",
kwd_list,
&obj,
&pySurface,
&orders,
&params.degree,
&params.ptsoncurve,
&params.numiter,
&anisotropy,
&params.tol2d,
&params.tol3d,
&params.tolG1,
&params.tolG2,
&params.maxdeg,
&params.maxseg,
&op)) {
throw Py::Exception();
}
params.anisotropy = PyObject_IsTrue(anisotropy);
TopoShape surface;
if(pySurface != Py_None)
if (pySurface != Py_None) {
surface = *static_cast<TopoShapePy*>(pySurface)->getTopoShapePtr();
parseSequence(supports, "Expects 'supports' to be a sequence of tuple(shape, shape)",
[&](const TopoDS_Shape &s, PyObject *value, const char *err) {
if (!PyObject_TypeCheck(value, &(Part::TopoShapePy::Type)))
throw Py::TypeError(err);
params.supports[s] = static_cast<TopoShapePy*>(value)->getTopoShapePtr()->getShape();
}
parseSequence(supports,
"Expects 'supports' to be a sequence of tuple(shape, shape)",
[&](const TopoDS_Shape& s, PyObject* value, const char* err) {
if (!PyObject_TypeCheck(value, &(Part::TopoShapePy::Type))) {
throw Py::TypeError(err);
}
params.supports[s] =
static_cast<TopoShapePy*>(value)->getTopoShapePtr()->getShape();
});
parseSequence(orders, "Expects 'orders' to be a sequence of tuple(shape, PartEnums.Shape)",
[&](const TopoDS_Shape &s, PyObject *value, const char *err) {
if (!PyLong_Check(value))
throw Py::ValueError(err);
int order = Py::Int(value);
parseSequence(orders,
"Expects 'orders' to be a sequence of tuple(shape, PartEnums.Shape)",
[&](const TopoDS_Shape& s, PyObject* value, const char* err) {
if (!PyLong_Check(value)) {
throw Py::ValueError(err);
}
int order = Py::Int(value);
params.orders[s] = static_cast<TopoShape::Continuity>(order);
return;
});
auto shapes = getPyShapes(obj);
if (shapes.empty())
if (shapes.empty()) {
throw Py::ValueError("No input shape");
return shape2pyshape(TopoShape(0, shapes.front().Hasher).makeElementFilledFace(shapes,params,op));
}
return shape2pyshape(
TopoShape(0, shapes.front().Hasher).makeElementFilledFace(shapes, params, op));
#else
Py::Object makeFilledSurface(const Py::Tuple &args)
{
PyObject *obj;
double tolerance;
if (!PyArg_ParseTuple(args.ptr(), "Od", &obj, &tolerance))
@@ -1117,47 +1227,85 @@ private:
}
#endif
}
#ifdef FC_USE_TNP_FIX
Py::Object makeFilledFace(const Py::Tuple& args, const Py::Dict &kwds)
{
#ifdef FC_USE_TNP_FIX
TopoShape::BRepFillingParams params;
PyObject *obj = nullptr;
PyObject *pySurface = Py_None;
PyObject *supports = Py_None;
PyObject *orders = Py_None;
PyObject *anisotropy = params.anisotropy ? Py_True : Py_False;
const char *op = nullptr;
const std::array<const char *, 16> kwd_list = {"shapes", "surface", "supports",
"orders","degree","ptsOnCurve","numIter","anisotropy",
"tol2d", "tol3d", "tolG1", "tolG2", "maxDegree", "maxSegments", "op", nullptr};
if(!Base::Wrapped_ParseTupleAndKeywords(args.ptr(), kwds.ptr(), "O|O!OOIIIOddddIIs", kwd_list,
&obj, &pySurface, &orders, &params.degree, &params.ptsoncurve,
&params.numiter, &anisotropy, &params.tol2d, &params.tol3d,
&params.tolG1, &params.tolG2, &params.maxdeg, &params.maxseg, &op))
PyObject* obj = nullptr;
PyObject* pySurface = Py_None;
PyObject* supports = Py_None;
PyObject* orders = Py_None;
PyObject* anisotropy = params.anisotropy ? Py_True : Py_False;
const char* op = nullptr;
const std::array<const char*, 16> kwd_list = {"shapes",
"surface",
"supports",
"orders",
"degree",
"ptsOnCurve",
"numIter",
"anisotropy",
"tol2d",
"tol3d",
"tolG1",
"tolG2",
"maxDegree",
"maxSegments",
"op",
nullptr};
if (!Base::Wrapped_ParseTupleAndKeywords(args.ptr(),
kwds.ptr(),
"O|O!OOIIIOddddIIs",
kwd_list,
&obj,
&pySurface,
&orders,
&params.degree,
&params.ptsoncurve,
&params.numiter,
&anisotropy,
&params.tol2d,
&params.tol3d,
&params.tolG1,
&params.tolG2,
&params.maxdeg,
&params.maxseg,
&op)) {
throw Py::Exception();
}
params.anisotropy = PyObject_IsTrue(anisotropy);
TopoShape surface;
if(pySurface != Py_None)
if (pySurface != Py_None) {
surface = *static_cast<TopoShapePy*>(pySurface)->getTopoShapePtr();
parseSequence(supports, "Expects 'supports' to be a sequence of tuple(shape, shape)",
[&](const TopoDS_Shape &s, PyObject *value, const char *err) {
if (!PyObject_TypeCheck(value, &(Part::TopoShapePy::Type)))
throw Py::TypeError(err);
params.supports[s] = static_cast<TopoShapePy*>(value)->getTopoShapePtr()->getShape();
}
parseSequence(supports,
"Expects 'supports' to be a sequence of tuple(shape, shape)",
[&](const TopoDS_Shape& s, PyObject* value, const char* err) {
if (!PyObject_TypeCheck(value, &(Part::TopoShapePy::Type))) {
throw Py::TypeError(err);
}
params.supports[s] =
static_cast<TopoShapePy*>(value)->getTopoShapePtr()->getShape();
});
parseSequence(orders, "Expects 'orders' to be a sequence of tuple(shape, PartEnums.Shape)",
[&](const TopoDS_Shape &s, PyObject *value, const char *err) {
if (!PyLong_Check(value))
throw Py::ValueError(err);
int order = Py::Int(value);
parseSequence(orders,
"Expects 'orders' to be a sequence of tuple(shape, PartEnums.Shape)",
[&](const TopoDS_Shape& s, PyObject* value, const char* err) {
if (!PyLong_Check(value)) {
throw Py::ValueError(err);
}
int order = Py::Int(value);
params.orders[s] = static_cast<TopoShape::Continuity>(order);
return;
});
auto shapes = getPyShapes(obj);
if (shapes.empty())
if (shapes.empty()) {
throw Py::ValueError("No input shape");
return shape2pyshape(TopoShape(0, shapes.front().Hasher).makeElementFilledFace(shapes,params,op));
}
return shape2pyshape(
TopoShape(0, shapes.front().Hasher).makeElementFilledFace(shapes, params, op));
#else
Py::Object makeFilledFace(const Py::Tuple& args)
{
// TODO: BRepFeat_SplitShape
PyObject *obj;
PyObject *surf=nullptr;
@@ -1216,17 +1364,26 @@ private:
}
#endif
}
#ifdef FC_USE_TNP_FIX
Py::Object makeSolid(const Py::Tuple& args, const Py::Dict &kwds)
{
#ifndef FC_NO_ELEMENT_MAP
PyObject *obj;
const char *op = nullptr;
const std::array<const char *, 3> kwd_list = {"shape", "op", nullptr};
if(!Base::Wrapped_ParseTupleAndKeywords(args.ptr(), kwds.ptr(), "O!|s",
kwd_list, &(TopoShapePy::Type), &obj, &op))
PyObject* obj;
const char* op = nullptr;
const std::array<const char*, 3> kwd_list = {"shape", "op", nullptr};
if (!Base::Wrapped_ParseTupleAndKeywords(args.ptr(),
kwds.ptr(),
"O!|s",
kwd_list,
&(TopoShapePy::Type),
&obj,
&op)) {
throw Py::Exception();
return shape2pyshape(TopoShape().makeElementSolid(*static_cast<TopoShapePy*>(obj)->getTopoShapePtr(),op));
}
return shape2pyshape(
TopoShape().makeElementSolid(*static_cast<TopoShapePy*>(obj)->getTopoShapePtr(), op));
#else
Py::Object makeSolid(const Py::Tuple& args)
{
PyObject *obj;
if (!PyArg_ParseTuple(args.ptr(), "O!", &(TopoShapePy::Type), &obj))
throw Py::Exception();
@@ -1831,25 +1988,37 @@ private:
throw Py::Exception(PartExceptionOCCDomainError, "creation of revolved shape failed");
}
}
#ifdef FC_USE_TNP_FIX
Py::Object makeRuledSurface(const Py::Tuple& args, const Py::Dict &kwds)
{
#ifdef FC_USE_TNP_FIX
const char *op=nullptr;
const char* op = nullptr;
int orientation = 0;
PyObject *sh1, *sh2;
const std::array<const char *, 5> kwd_list = {"path", "profile", "orientation", "op", nullptr};
if(!Base::Wrapped_ParseTupleAndKeywords(args.ptr(), kwds.ptr(), "O!O!|is", kwd_list,
&(TopoShapePy::Type), &sh1,
&(TopoShapePy::Type), &sh2,
&orientation,
&op))
const std::array<const char*, 5> kwd_list = {"path",
"profile",
"orientation",
"op",
nullptr};
if (!Base::Wrapped_ParseTupleAndKeywords(args.ptr(),
kwds.ptr(),
"O!O!|is",
kwd_list,
&(TopoShapePy::Type),
&sh1,
&(TopoShapePy::Type),
&sh2,
&orientation,
&op)) {
throw Py::Exception();
}
std::vector<TopoShape> shapes;
shapes.push_back(*static_cast<TopoShapePy*>(sh1)->getTopoShapePtr());
shapes.push_back(*static_cast<TopoShapePy*>(sh2)->getTopoShapePtr());
return shape2pyshape(TopoShape().makeElementRuledSurface(shapes,orientation,op));
return shape2pyshape(TopoShape().makeElementRuledSurface(shapes, orientation, op));
#else
Py::Object makeRuledSurface(const Py::Tuple& args)
{
// http://opencascade.blogspot.com/2009/10/surface-modeling-part1.html
PyObject *sh1, *sh2;
if (!PyArg_ParseTuple(args.ptr(), "O!O!", &(TopoShapePy::Type), &sh1,
@@ -1877,20 +2046,31 @@ private:
}
#endif
}
#ifdef FC_USE_TNP_FIX
Py::Object makeShellFromWires(const Py::Tuple& args, const Py::Dict &kwds)
{
PyObject *pylist;
#ifdef FC_USE_TNP_FIX
const char *op = nullptr;
const std::array<const char *, 3> kwd_list = {"shape", "op", nullptr};
if(!Base::Wrapped_ParseTupleAndKeywords(args.ptr(), kwds.ptr(), "O|s", kwd_list, &pylist, &op))
const char* op = nullptr;
const std::array<const char*, 3> kwd_list = {"shape", "op", nullptr};
if (!Base::Wrapped_ParseTupleAndKeywords(args.ptr(),
kwds.ptr(),
"O|s",
kwd_list,
&pylist,
&op)) {
throw Py::Exception();
}
try {
return shape2pyshape(TopoShape().makeElementShellFromWires(getPyShapes(pylist), /*silent*/false, op));
} catch (Standard_Failure&) {
return shape2pyshape(
TopoShape().makeElementShellFromWires(getPyShapes(pylist), /*silent*/ false, op));
}
catch (Standard_Failure&) {
throw Py::Exception(PartExceptionOCCError, "creation of shell failed");
}
#else
Py::Object makeShellFromWires(const Py::Tuple& args)
{
PyObject *pylist;
if (!PyArg_ParseTuple(args.ptr(), "O", &pylist))
throw Py::Exception();
@@ -1968,14 +2148,19 @@ private:
throw Py::Exception();
try {
#ifndef FC_NO_ELEMENT_MAP
#ifdef FC_USE_TNP_FIX
TopoShape mShape = *static_cast<TopoShapePy*>(path)->getTopoShapePtr();
// makeSweep uses GeomFill_Pipe which does not support shape
// history. So use makEPipeShell() as a replacement
return shape2pyshape(TopoShape(0, mShape.Hasher).makeElementPipeShell(
{mShape, *static_cast<TopoShapePy*>(profile)->getTopoShapePtr()},
Part::MakeSolid::noSolid, Standard_False, TransitionMode::Transformed,
nullptr, tolerance));
return shape2pyshape(
TopoShape(0, mShape.Hasher)
.makeElementPipeShell(
{mShape, *static_cast<TopoShapePy*>(profile)->getTopoShapePtr()},
Part::MakeSolid::noSolid,
Standard_False,
TransitionMode::Transformed,
nullptr,
tolerance));
#else
const TopoDS_Shape& path_shape = static_cast<TopoShapePy*>(path)->getTopoShapePtr()->getShape();
const TopoDS_Shape& prof_shape = static_cast<TopoShapePy*>(profile)->getTopoShapePtr()->getShape();
@@ -1989,6 +2174,7 @@ private:
throw Py::Exception(PartExceptionOCCError, e.GetMessageString());
}
}
# ifdef FC_USE_TNP_FIX
Py::Object makeLoft(const Py::Tuple& args, const Py::Dict &kwds)
{
PyObject *pcObj;
@@ -1996,27 +2182,43 @@ private:
PyObject *pruled=Py_False;
PyObject *pclosed=Py_False;
int degMax = 5;
# ifdef FC_USE_TNP_FIX
const char *op = nullptr;
const std::array<const char *, 7> kwd_list = {"shapes", "solid", "ruled", "closed", "max_degree", "op", nullptr};
if (!Base::Wrapped_ParseTupleAndKeywords(args.ptr(), kwds.ptr(), "O!|O!O!O!is", kwd_list,
&pcObj,
&(PyBool_Type), &psolid,
&(PyBool_Type), &pruled,
&(PyBool_Type), &pclosed,
&degMax, &op))
{
const char* op = nullptr;
const std::array<const char*, 7> kwd_list =
{"shapes", "solid", "ruled", "closed", "max_degree", "op", nullptr};
if (!Base::Wrapped_ParseTupleAndKeywords(args.ptr(),
kwds.ptr(),
"O!|O!O!O!is",
kwd_list,
&(PyList_Type),
&pcObj,
&(PyBool_Type),
&psolid,
&(PyBool_Type),
&pruled,
&(PyBool_Type),
&pclosed,
&degMax,
&op)) {
throw Py::Exception();
}
Standard_Boolean anIsSolid = PyObject_IsTrue(psolid) ? Standard_True : Standard_False;
Standard_Boolean anIsRuled = PyObject_IsTrue(pruled) ? Standard_True : Standard_False;
Standard_Boolean anIsClosed = PyObject_IsTrue(pclosed) ? Standard_True : Standard_False;
return shape2pyshape(TopoShape().makeElementLoft(getPyShapes(pcObj),
anIsSolid ? Part::IsSolid::solid : Part::IsSolid::notSolid,
anIsRuled ? Part::IsRuled::ruled : Part::IsRuled::notRuled,
anIsClosed ? Part::IsClosed::closed : Part::IsClosed::notClosed,
degMax,op));
# else
return shape2pyshape(TopoShape().makeElementLoft(
getPyShapes(pcObj),
anIsSolid ? Part::IsSolid::solid : Part::IsSolid::notSolid,
anIsRuled ? Part::IsRuled::ruled : Part::IsRuled::notRuled,
anIsClosed ? Part::IsClosed::closed : Part::IsClosed::notClosed,
degMax,
op));
#else
Py::Object makeLoft(const Py::Tuple& args)
{
PyObject *pcObj;
PyObject *psolid=Py_False;
PyObject *pruled=Py_False;
PyObject *pclosed=Py_False;
int degMax = 5;
if (!PyArg_ParseTuple(args.ptr(), "O|O!O!O!i", &pcObj,
&(PyBool_Type), &psolid,
&(PyBool_Type), &pruled,
@@ -2108,11 +2310,13 @@ private:
MapperMaker mapper(splitShape);
for (TopTools_ListIteratorOfListOfShape it(d); it.More(); it.Next()) {
TopoShape s(0, sources.front().Hasher);
list1.append(shape2pyshape(s.makeShapeWithElementMap(it.Value(), mapper, sources, Part::OpCodes::Split)));
list1.append(shape2pyshape(
s.makeShapeWithElementMap(it.Value(), mapper, sources, Part::OpCodes::Split)));
}
for (TopTools_ListIteratorOfListOfShape it(l); it.More(); it.Next()) {
TopoShape s(0, sources.front().Hasher);
list2.append(shape2pyshape(s.makeShapeWithElementMap(it.Value(), mapper, sources, Part::OpCodes::Split)));
list2.append(shape2pyshape(
s.makeShapeWithElementMap(it.Value(), mapper, sources, Part::OpCodes::Split)));
}
#else
for (TopTools_ListIteratorOfListOfShape it(d); it.More(); it.Next()) {
@@ -2456,10 +2660,12 @@ private:
"needSubElement", "transform", "retType", "noElementMap",
"refine", nullptr};
if (!Base::Wrapped_ParseTupleAndKeywords(args.ptr(), kwds.ptr(), "O!|sO!O!O!hO!O!", kwd_list,
&App::DocumentObjectPy::Type, &pObj, &subname, &Base::MatrixPy::Type,
&pyMat,
&PyBool_Type, &needSubElement, &PyBool_Type, &transform, &retType,
&PyBool_Type, &noElementMap, &PyBool_Type, &refine)) {
&App::DocumentObjectPy::Type, &pObj, &subname,
&Base::MatrixPy::Type, &pyMat,
&PyBool_Type, &needSubElement,
&PyBool_Type, &transform, &retType,
&PyBool_Type, &noElementMap,
&PyBool_Type, &refine)) {
throw Py::Exception();
}
@@ -2473,8 +2679,8 @@ private:
&mat,&subObj,retType==2,Base::asBoolean(transform),
Base::asBoolean(noElementMap));
if (Base::asBoolean(refine)) {
#ifndef FC_NO_ELEMENT_MAP
shape = TopoShape(0,shape.Hasher).makeElementRefine(shape);
#ifdef FC_USE_TNP_FIX
shape = TopoShape(0, shape.Hasher).makeElementRefine(shape);
#else
BRepBuilderAPI_RefineModel mkRefine(shape.getShape());
shape.setShape(mkRefine.Shape());