1 // SWIG file PolygonArray.i
2 
3 %{
4 #include "openturns/PolygonArray.hxx"
5 
6 namespace OT {
7   template <>
8   struct traitsPythonType<OT::Polygon>
9   {
10     typedef _PyObject_ Type;
11   };
12 
13   template <>
14   inline
15   bool
16   canConvert< _PyObject_, OT::Polygon >(PyObject * pyObj)
17   {
18     void * ptr = 0;
19     if (SWIG_IsOK(SWIG_ConvertPtr( pyObj, &ptr, SWIG_TypeQuery("OT::Polygon *"), SWIG_POINTER_NO_NULL))) {
20       OT::Polygon * p_it = reinterpret_cast< OT::Polygon * >(ptr);
21       return p_it != NULL;
22     }
23     return false;
24   }
25 
26   template <>
27   inline
28   OT::Polygon
29   convert< _PyObject_, OT::Polygon >(PyObject * pyObj)
30   {
31     void * ptr = 0;
32     if (SWIG_IsOK(SWIG_ConvertPtr( pyObj, &ptr, SWIG_TypeQuery("OT::Polygon *"), SWIG_POINTER_NO_NULL))) {
33       OT::Polygon * p_it = reinterpret_cast< OT::Polygon * >(ptr);
34       return *p_it;
35     }
36     else {
37       throw OT::InvalidArgumentException(HERE) << "Object passed as argument is not convertible to a Polygon";
38     }
39     return OT::Polygon();
40   }
41 } // namespace OT
42 %}
43 
44 %template(PolygonCollection) OT::Collection<OT::Polygon>;
45 
46 %typemap(in) const PolygonCollection & (OT::Pointer<OT::Collection<OT::Polygon> > temp) {
47   if (SWIG_IsOK(SWIG_ConvertPtr($input, (void **) &$1, $1_descriptor, SWIG_POINTER_NO_NULL))) {
48     // From interface class, ok
49   } else {
50     try {
51       temp = OT::buildCollectionFromPySequence< OT::Polygon >($input);
52       $1 = temp.get();
53     } catch (OT::InvalidArgumentException &) {
54       SWIG_exception(SWIG_TypeError, "Object passed as argument is not convertible to a collection of Polygon");
55     }
56   }
57 }
58 
59 %typemap(typecheck,precedence=SWIG_TYPECHECK_POINTER) const PolygonCollection & {
60   $1 = SWIG_IsOK(SWIG_ConvertPtr($input, NULL, $1_descriptor, SWIG_POINTER_NO_NULL))
61     || OT::canConvertCollectionObjectFromPySequence< OT::Polygon >($input);
62 }
63 
64 %apply const PolygonCollection & { const OT::PolygonArray::PolygonCollection & };
65 
66 %include PolygonArray_doc.i
67 
68 %include openturns/PolygonArray.hxx
69 namespace OT { %extend PolygonArray { PolygonArray(const PolygonArray & other) { return new OT::PolygonArray(other); } } }
70