Toponaming: Bring in composite shapes for findSubshapesWithSharedVertex ( searchSubShape )

This commit is contained in:
Zheng, Lei
2024-07-18 17:09:48 -04:00
committed by bgbsww
parent 3fa339e9eb
commit f6494bdf05
8 changed files with 181 additions and 49 deletions

View File

@@ -3112,10 +3112,11 @@ PyObject* TopoShapePy::findSubShape(PyObject* args)
PyObject* TopoShapePy::findSubShapesWithSharedVertex(PyObject* args, PyObject* keywds)
{
static const std::array<const char*, 6> kwlist {"shape", "needName", "checkGeometry", "tol", "atol", nullptr};
static const std::array<const char*, 7> kwlist {"shape", "needName", "checkGeometry", "tol", "atol", "singleResult", nullptr};
PyObject* pyobj;
PyObject* needName = Py_False;
PyObject* checkGeometry = Py_True;
PyObject* singleResult = Py_False;
double tol = 1e-7;
double atol = 1e-12;
if (!Base::Wrapped_ParseTupleAndKeywords(args,
@@ -3127,7 +3128,8 @@ PyObject* TopoShapePy::findSubShapesWithSharedVertex(PyObject* args, PyObject* k
&needName,
&checkGeometry,
&tol,
&atol)) {
&atol,
&singleResult)) {
return nullptr;
}
@@ -3135,13 +3137,17 @@ PyObject* TopoShapePy::findSubShapesWithSharedVertex(PyObject* args, PyObject* k
{
Py::List res;
const TopoShape& shape = *static_cast<TopoShapePy*>(pyobj)->getTopoShapePtr();
Data::SearchOptions options;
if (PyObject_IsTrue(checkGeometry))
options.setFlag(Data::SearchOption::CheckGeometry);
if (PyObject_IsTrue(singleResult))
options.setFlag(Data::SearchOption::SingleResult);
if (PyObject_IsTrue(needName)) {
std::vector<std::string> names;
auto shapes = getTopoShapePtr()->findSubShapesWithSharedVertex(
shape,
&names,
PyObject_IsTrue(checkGeometry) ? CheckGeometry::checkGeometry
: CheckGeometry::ignoreGeometry,
options,
tol,
atol);
for (std::size_t i = 0; i < shapes.size(); ++i) {
@@ -3152,8 +3158,7 @@ PyObject* TopoShapePy::findSubShapesWithSharedVertex(PyObject* args, PyObject* k
for (auto& s : getTopoShapePtr()->findSubShapesWithSharedVertex(
shape,
nullptr,
PyObject_IsTrue(checkGeometry) ? CheckGeometry::checkGeometry
: CheckGeometry::ignoreGeometry,
options,
tol,
atol)) {
res.append(shape2pyshape(s));