%include "ModelHighAPI_Tools.h"
%template(SelectionList) std::list<ModelHighAPI_Selection>;
+%template(RefAttrList) std::list<ModelHighAPI_RefAttr>;
#include "ModelHighAPI_RefAttr.h"
#include <ModelAPI_AttributeRefAttr.h>
+#include <ModelAPI_AttributeRefAttrList.h>
#include <ModelAPI_Feature.h>
#include <ModelAPI_Result.h>
#include "ModelHighAPI_Interface.h"
{
boost::apply_visitor(fill_visitor(theAttribute), myValue);
}
+
+//--------------------------------------------------------------------------------------
+struct append_visitor : boost::static_visitor<void>
+{
+ mutable std::shared_ptr<ModelAPI_AttributeRefAttrList> myAttribute;
+
+ append_visitor(const std::shared_ptr<ModelAPI_AttributeRefAttrList> & theAttribute)
+ : myAttribute(theAttribute) {}
+
+ void operator()(const std::shared_ptr<ModelAPI_Attribute>& theValue) const { myAttribute->append(theValue); }
+ void operator()(const std::shared_ptr<ModelAPI_Object>& theValue) const { myAttribute->append(theValue); }
+};
+
+void ModelHighAPI_RefAttr::appendToList(
+ const std::shared_ptr<ModelAPI_AttributeRefAttrList> & theAttribute) const
+{
+ boost::apply_visitor(append_visitor(theAttribute), myValue);
+}
//--------------------------------------------------------------------------------------
class ModelAPI_Attribute;
class ModelAPI_AttributeRefAttr;
+class ModelAPI_AttributeRefAttrList;
class ModelAPI_Object;
class ModelHighAPI_Interface;
//--------------------------------------------------------------------------------------
MODELHIGHAPI_EXPORT
virtual void fillAttribute(const std::shared_ptr<ModelAPI_AttributeRefAttr> & theAttribute) const;
+ /// Append to list attribute
+ MODELHIGHAPI_EXPORT
+ virtual void appendToList(const std::shared_ptr<ModelAPI_AttributeRefAttrList> & theAttribute) const;
+
private:
boost::variant<
std::shared_ptr<ModelAPI_Attribute>,
theValue.fillAttribute(theAttribute);
}
+//--------------------------------------------------------------------------------------
+void fillAttribute(const std::list<ModelHighAPI_RefAttr> & theValue,
+ const std::shared_ptr<ModelAPI_AttributeRefAttrList> & theAttribute)
+{
+ theAttribute->clear();
+ for (auto it = theValue.begin(); it != theValue.end(); ++it)
+ it->appendToList(theAttribute);
+}
+
//--------------------------------------------------------------------------------------
void fillAttribute(const ModelHighAPI_Selection & theValue,
const std::shared_ptr<ModelAPI_AttributeSelection> & theAttribute)
void fillAttribute(const ModelHighAPI_RefAttr & theValue,
const std::shared_ptr<ModelAPI_AttributeRefAttr> & theAttribute);
+MODELHIGHAPI_EXPORT
+void fillAttribute(const std::list<ModelHighAPI_RefAttr> & theValue,
+ const std::shared_ptr<ModelAPI_AttributeRefAttrList> & theAttribute);
+
MODELHIGHAPI_EXPORT
void fillAttribute(const ModelHighAPI_Selection & theValue,
const std::shared_ptr<ModelAPI_AttributeSelection> & theAttribute);
%shared_ptr(SketchAPI_Sketch)
%shared_ptr(SketchAPI_SketchEntity)
+// fix compilarion error: ‘res2’ was not declared in this scope
+%typemap(freearg) const std::list<ModelHighAPI_RefAttr> & {}
+
+%typemap(in) const std::list<ModelHighAPI_RefAttr> & (std::list<ModelHighAPI_RefAttr> temp) {
+ std::shared_ptr<ModelAPI_Attribute> * temp_attribute;
+ int newmem = 0;
+ if (PySequence_Check($input)) {
+ for (Py_ssize_t i = 0; i < PySequence_Size($input); ++i) {
+ PyObject * item = PySequence_GetItem($input, i);
+ if ((SWIG_ConvertPtrAndOwn(item, (void **)&temp_attribute, $descriptor(std::shared_ptr<ModelAPI_Attribute> *), SWIG_POINTER_EXCEPTION, &newmem)) == 0) {
+ if (!temp_attribute) {
+ PyErr_SetString(PyExc_TypeError, "argument must be list of ModelHighAPI_RefAttr, ModelHighAPI_Interface, ModelAPI_Attribute or ModelAPI_Object.");
+ return NULL;
+ }
+ temp.push_back(ModelHighAPI_RefAttr(*temp_attribute));
+ if (newmem & SWIG_CAST_NEW_MEMORY) {
+ delete temp_attribute;
+ }
+ }
+ Py_DECREF(item);
+ }
+ $1 = &temp;
+ } else {
+ PyErr_SetString(PyExc_ValueError, "argument must be list of ModelHighAPI_RefAttr, ModelHighAPI_Interface, ModelAPI_Attribute or ModelAPI_Object.");
+ return NULL;
+ }
+}
+
// all supported interfaces (the order is very important: base class first)
%include "SketchAPI_SketchEntity.h"
%include "SketchAPI_Circle.h"