Part:: Geometry container extend hasExtension to type and name

This commit is contained in:
Abdullah Tahiri
2019-02-11 16:21:40 +01:00
committed by wmayer
parent 854452e2e1
commit afbe1df322
4 changed files with 68 additions and 0 deletions

View File

@@ -276,6 +276,16 @@ bool Geometry::hasExtension(Base::Type type) const
return false;
}
bool Geometry::hasExtension(std::string name) const
{
for( auto ext : extensions) {
if(ext->getName() == name)
return true;
}
return false;
}
const std::weak_ptr<GeometryExtension> Geometry::getExtension(Base::Type type) const
{
for( auto ext : extensions) {

View File

@@ -100,6 +100,7 @@ public:
const std::vector<std::weak_ptr<GeometryExtension>> getExtensions() const;
bool hasExtension(Base::Type type) const;
bool hasExtension(std::string name) const;
const std::weak_ptr<GeometryExtension> getExtension(Base::Type type) const;
void setExtension(std::unique_ptr<GeometryExtension> &&geo);
void deleteExtension(Base::Type type);

View File

@@ -51,6 +51,16 @@ It describes the common behavior of these objects when:
<Methode Name="clone" Const="true">
<Documentation>
<UserDocu>Create a clone of this geometry with the same Tag</UserDocu>
</Documentation>
</Methode>
<Methode Name="hasExtensionType" Const="true">
<Documentation>
<UserDocu>Returns a boolean indicating whether a geometry extension of the type indicated as a string exists.</UserDocu>
</Documentation>
</Methode>
<Methode Name="hasExtensionName" Const="true">
<Documentation>
<UserDocu>Returns a boolean indicating whether a geometry extension with the name indicated as a string exists.</UserDocu>
</Documentation>
</Methode>
<Methode Name="getExtension" Const="true">

View File

@@ -291,6 +291,53 @@ PyObject* GeometryPy::getExtension(PyObject *args)
return 0;
}
PyObject* GeometryPy::hasExtensionType(PyObject *args)
{
char* o;
if (PyArg_ParseTuple(args, "s", &o)) {
Base::Type type = Base::Type::fromName(o);
if(type != Base::Type::badType()) {
try {
return Py::new_reference_to(Py::Boolean(this->getGeometryPtr()->hasExtension(type)));
}
catch(Base::ValueError e) {
PyErr_SetString(PartExceptionOCCError, e.what());
return 0;
}
}
else
{
PyErr_SetString(PartExceptionOCCError, "Exception type does not exist");
return 0;
}
}
PyErr_SetString(PartExceptionOCCError, "A string with the type of the geometry extension was expected");
return 0;
}
PyObject* GeometryPy::hasExtensionName(PyObject *args)
{
char* o;
if (PyArg_ParseTuple(args, "s", &o)) {
try {
return Py::new_reference_to(Py::Boolean(this->getGeometryPtr()->hasExtension(std::string(o))));
}
catch(Base::ValueError e) {
PyErr_SetString(PartExceptionOCCError, e.what());
return 0;
}
}
PyErr_SetString(PartExceptionOCCError, "A string with the type of the geometry extension was expected");
return 0;
}
PyObject* GeometryPy::deleteExtensionType(PyObject *args)
{
char* o;