]> SALOME platform Git repositories - modules/hydro.git/commitdiff
Salome HOME
NCollection sequences improved.
authoradv <adv@opencascade.com>
Thu, 16 Jan 2014 06:26:50 +0000 (06:26 +0000)
committeradv <adv@opencascade.com>
Thu, 16 Jan 2014 06:26:50 +0000 (06:26 +0000)
CMake/UsePyQt4EXT.cmake
src/HYDROPy/CAS/NCollection_Sequence.sip
src/HYDROPy/HYDROData_Bathymetry.sip
src/HYDROPy/HYDROData_IPolyline.sip
src/HYDROPy/HYDROData_PolylineXY.sip
src/HYDROPy/HYDROData_Profile.sip

index 5fb12fd452966293f42529411bb5e03d3b6e4908..b3898524b8657d92a6b46087f6083fa1c50be3b4 100644 (file)
@@ -127,15 +127,6 @@ MACRO(PYQT4_WRAP_SIP_EXT outfiles)
     LIST(APPEND _output ${CMAKE_CURRENT_BINARY_DIR}/sipHYDROPyHYDROData_Zone.cc)
     SET(${outfiles} ${${outfiles}} ${CMAKE_CURRENT_BINARY_DIR}/sipHYDROPyHYDROData_Zone.cc)
 
-    LIST(APPEND _output ${CMAKE_CURRENT_BINARY_DIR}/sipHYDROPyNCollection_Sequence0100Handle_HYDROData_Entity.cc)
-    SET(${outfiles} ${${outfiles}} ${CMAKE_CURRENT_BINARY_DIR}/sipHYDROPyNCollection_Sequence0100Handle_HYDROData_Entity.cc)
-       
-    LIST(APPEND _output ${CMAKE_CURRENT_BINARY_DIR}/sipHYDROPyNCollection_Sequence0100gp_XYZ.cc)
-    SET(${outfiles} ${${outfiles}} ${CMAKE_CURRENT_BINARY_DIR}/sipHYDROPyNCollection_Sequence0100gp_XYZ.cc)
-    
-#    LIST(APPEND _output ${CMAKE_CURRENT_BINARY_DIR}/sipHYDROPyNCollection_Sequence0100gp_XY.cc)
-#    SET(${outfiles} ${${outfiles}} ${CMAKE_CURRENT_BINARY_DIR}/sipHYDROPyNCollection_Sequence0100gp_XY.cc)
-    
     LIST(APPEND _output ${CMAKE_CURRENT_BINARY_DIR}/sipHYDROPygp_XYZ.cc)
     SET(${outfiles} ${${outfiles}} ${CMAKE_CURRENT_BINARY_DIR}/sipHYDROPygp_XYZ.cc)
 
@@ -151,21 +142,24 @@ MACRO(PYQT4_WRAP_SIP_EXT outfiles)
     LIST(APPEND _output ${CMAKE_CURRENT_BINARY_DIR}/sipHYDROPyTCollection_AsciiString.cc)
     SET(${outfiles} ${${outfiles}} ${CMAKE_CURRENT_BINARY_DIR}/sipHYDROPyTCollection_AsciiString.cc)
 
-    LIST(APPEND _output ${CMAKE_CURRENT_BINARY_DIR}/sipHYDROPyNCollection_Sequence0100HYDROData_BathymetryAltitudePoint.cc)
-    SET(${outfiles} ${${outfiles}} ${CMAKE_CURRENT_BINARY_DIR}/sipHYDROPyNCollection_Sequence0100HYDROData_BathymetryAltitudePoint.cc)
+    LIST(APPEND _output ${CMAKE_CURRENT_BINARY_DIR}/sipHYDROPyNCollection_Sequence1800.cc)
+    SET(${outfiles} ${${outfiles}} ${CMAKE_CURRENT_BINARY_DIR}/sipHYDROPyNCollection_Sequence1800.cc)
 
-    LIST(APPEND _output ${CMAKE_CURRENT_BINARY_DIR}/sipHYDROPyNCollection_Sequence0100HYDROData_IPolylinePoint.cc)
-    SET(${outfiles} ${${outfiles}} ${CMAKE_CURRENT_BINARY_DIR}/sipHYDROPyNCollection_Sequence0100HYDROData_IPolylinePoint.cc)
+    LIST(APPEND _output ${CMAKE_CURRENT_BINARY_DIR}/sipHYDROPyNCollection_Sequence2600.cc)
+    SET(${outfiles} ${${outfiles}} ${CMAKE_CURRENT_BINARY_DIR}/sipHYDROPyNCollection_Sequence2600.cc)
 
-    LIST(APPEND _output ${CMAKE_CURRENT_BINARY_DIR}/sipHYDROPyNCollection_Sequence0100HYDROData_ProfileProfilePoint.cc)
-    SET(${outfiles} ${${outfiles}} ${CMAKE_CURRENT_BINARY_DIR}/sipHYDROPyNCollection_Sequence0100HYDROData_ProfileProfilePoint.cc)
+    LIST(APPEND _output ${CMAKE_CURRENT_BINARY_DIR}/sipHYDROPyNCollection_Sequence0100Handle_HYDROData_Entity.cc)
+    SET(${outfiles} ${${outfiles}} ${CMAKE_CURRENT_BINARY_DIR}/sipHYDROPyNCollection_Sequence0100Handle_HYDROData_Entity.cc)
+       
+    LIST(APPEND _output ${CMAKE_CURRENT_BINARY_DIR}/sipHYDROPyNCollection_Sequence0100gp_XY.cc)
+    SET(${outfiles} ${${outfiles}} ${CMAKE_CURRENT_BINARY_DIR}/sipHYDROPyNCollection_Sequence0100gp_XY.cc)
 
+    LIST(APPEND _output ${CMAKE_CURRENT_BINARY_DIR}/sipHYDROPyNCollection_Sequence0100gp_XYZ.cc)
+    SET(${outfiles} ${${outfiles}} ${CMAKE_CURRENT_BINARY_DIR}/sipHYDROPyNCollection_Sequence0100gp_XYZ.cc)
+    
     LIST(APPEND _output ${CMAKE_CURRENT_BINARY_DIR}/sipHYDROPyNCollection_Sequence0100HYDROData_IPolylineSectionType.cc)
     SET(${outfiles} ${${outfiles}} ${CMAKE_CURRENT_BINARY_DIR}/sipHYDROPyNCollection_Sequence0100HYDROData_IPolylineSectionType.cc)
 
-    LIST(APPEND _output ${CMAKE_CURRENT_BINARY_DIR}/sipHYDROPyNCollection_Sequence0100BOOLTYPE.cc)
-    SET(${outfiles} ${${outfiles}} ${CMAKE_CURRENT_BINARY_DIR}/sipHYDROPyNCollection_Sequence0100BOOLTYPE.cc)
-    
     LIST(APPEND _output ${CMAKE_CURRENT_BINARY_DIR}/sipHYDROPyNCollection_Sequence0100TCollection_AsciiString.cc)
     SET(${outfiles} ${${outfiles}} ${CMAKE_CURRENT_BINARY_DIR}/sipHYDROPyNCollection_Sequence0100TCollection_AsciiString.cc)
     
index 8c002cd38d0111b0b8c929aa6e6b0ddd76bae503..dc4f30d9d9c9e313d7968dd8ab3f0125d4ba2239 100644 (file)
@@ -36,24 +36,24 @@ template<TYPE>
     // Create the list.
     PyObject *l;
 
-    if ((l = PyList_New(sipCpp->Length())) == NULL)
-        return NULL;
+    if ( ( l = PyList_New( sipCpp->Length() ) ) == NULL )
+      return NULL;
 
     // Set the list elements.
-    for (int i = 1; i <= sipCpp->Length(); ++i)
+    for ( int i = 1, n = sipCpp->Length(); i <= n; ++i )
     {
-        TYPE *t = new TYPE(sipCpp->Value(i));
-        PyObject *tobj;
+      TYPE* t = new TYPE( sipCpp->Value( i ) );
 
-        if ((tobj = sipConvertFromNewType(t, sipFindType("TYPE"), sipTransferObj)) == NULL)
-        {
-            Py_DECREF(l);
-            delete t;
+      PyObject* pobj;
+      if ( ( pobj = sipConvertFromNewType( t, sipType_TYPE, sipTransferObj ) ) == NULL )
+      {
+        Py_DECREF( l );
+        delete t;
 
-            return NULL;
-        }
+        return NULL;
+      }
 
-        PyList_SET_ITEM(l, i - 1, tobj);
+      PyList_SET_ITEM( l, i - 1, pobj );
     }
 
     return l;
@@ -71,7 +71,7 @@ template<TYPE>
         for (SIP_SSIZE_T i = 0; i < len; ++i)
         {
             PyObject *itm = PySequence_ITEM(sipPy, i);
-            bool ok = (itm && sipCanConvertToType(itm, sipFindType("TYPE"), SIP_NOT_NONE));
+            bool ok = (itm && sipCanConvertToType(itm, sipType_TYPE, SIP_NOT_NONE));
 
             Py_XDECREF(itm);
 
@@ -89,13 +89,13 @@ template<TYPE>
     {
         PyObject *itm = PySequence_ITEM(sipPy, i);
         int state;
-        TYPE *t = reinterpret_cast<TYPE *>(sipConvertToType(itm, sipFindType("TYPE"), sipTransferObj, SIP_NOT_NONE, &state, sipIsErr));
+        TYPE *t = reinterpret_cast<TYPE *>(sipConvertToType(itm, sipType_TYPE, sipTransferObj, SIP_NOT_NONE, &state, sipIsErr));
 
         Py_DECREF(itm);
  
         if (*sipIsErr)
         {
-            sipReleaseType(t, sipFindType("TYPE"), state);
+            sipReleaseType(t, sipType_TYPE, state);
 
             delete aSeq;
             return 0;
@@ -103,7 +103,7 @@ template<TYPE>
 
         aSeq->Append(*t);
 
-        sipReleaseType(t, sipFindType("TYPE"), state);
+        sipReleaseType(t, sipType_TYPE, state);
     }
  
     *sipCppPtr = aSeq;
@@ -112,3 +112,124 @@ template<TYPE>
 %End
 };
 
+// NCollection_Sequence<int> is implemented as a Python list of integers.
+%MappedType NCollection_Sequence<int>
+{
+%TypeHeaderCode
+#include <NCollection_Sequence.hxx>
+%End
+
+%ConvertFromTypeCode
+    // Create the list.
+    PyObject *l;
+
+    if ( ( l = PyList_New( sipCpp->Length() ) ) == NULL )
+      return NULL;
+
+    // Set the list elements.
+    for ( int i = 1, n = sipCpp->Length(); i <= n; ++i )
+    {
+      PyObject *pobj;
+      if ( ( pobj = SIPLong_FromLong( sipCpp->Value( i ) ) ) == NULL )
+      {
+        Py_DECREF(l);
+
+        return NULL;
+      }
+
+      PyList_SET_ITEM( l, i, pobj );
+    }
+
+    return l;
+%End
+
+%ConvertToTypeCode
+    // Check the type if that is all that is required.
+    if ( sipIsErr == NULL )
+        return ( PySequence_Check( sipPy)  && PySequence_Size( sipPy ) >= 0 );
+
+    NCollection_Sequence<int> *aSeq = new NCollection_Sequence<int>;
+
+    SIP_SSIZE_T len = PySequence_Size(sipPy);
+    for ( SIP_SSIZE_T i = 0; i < len; ++i )
+    {
+      PyObject *itm = PySequence_ITEM( sipPy, i );
+      if ( !itm )
+      {
+        delete aSeq;
+        *sipIsErr = 1;
+
+        return 0;
+      }
+
+      aSeq->Append( SIPLong_AsLong( itm ) );
+
+      Py_DECREF( itm );
+    }
+    *sipCppPtr = aSeq;
+    return sipGetState( sipTransferObj );
+%End
+};
+
+// NCollection_Sequence<bool> is implemented as a Python list of integers.
+%MappedType NCollection_Sequence<bool>
+{
+%TypeHeaderCode
+#include <NCollection_Sequence.hxx>
+%End
+
+%ConvertFromTypeCode
+    // Create the list.
+    PyObject *l;
+
+    if ( ( l = PyList_New( sipCpp->Length() ) ) == NULL )
+      return NULL;
+
+    // Set the list elements.
+    for ( int i = 1, n = sipCpp->Length(); i <= n; ++i )
+    {
+      PyObject *pobj;
+      if ( ( pobj = SIPLong_FromLong( sipCpp->Value( i ) ) ) == NULL )
+      {
+        Py_DECREF(l);
+
+        return NULL;
+      }
+
+      PyList_SET_ITEM( l, i, pobj );
+    }
+
+    return l;
+%End
+
+%ConvertToTypeCode
+    // Check the type if that is all that is required.
+    if ( sipIsErr == NULL )
+        return ( PySequence_Check( sipPy)  && PySequence_Size( sipPy ) >= 0 );
+
+    NCollection_Sequence<bool> *aSeq = new NCollection_Sequence<bool>;
+
+    SIP_SSIZE_T len = PySequence_Size(sipPy);
+    for ( SIP_SSIZE_T i = 0; i < len; ++i )
+    {
+      PyObject *itm = PySequence_ITEM( sipPy, i );
+      if ( !itm )
+      {
+        delete aSeq;
+        *sipIsErr = 1;
+
+        return 0;
+      }
+
+      aSeq->Append( SIPLong_AsLong( itm ) != 0 );
+
+      Py_DECREF( itm );
+    }
+    *sipCppPtr = aSeq;
+    return sipGetState( sipTransferObj );
+%End
+};
\ No newline at end of file
index 057b276785186b90a14083a6924a02fd1c626c56..c13645ade96043e1f6919a8563f0fee9118a136f 100644 (file)
@@ -40,7 +40,7 @@ class HYDROData_Bathymetry : HYDROData_IAltitudeObject
 %End
 
   typedef gp_XYZ                       AltitudePoint;
-  typedef NCollection_Sequence<HYDROData_Bathymetry::AltitudePoint> AltitudePoints;
+  typedef NCollection_Sequence<gp_XYZ> AltitudePoints;
 
 
 %TypeHeaderCode
index 885a97b9cb25bf834e2bef325a3195cb429e67eb..da3010719977844174f67b225ccb1d8e3515cffc 100644 (file)
@@ -31,7 +31,7 @@ class HYDROData_IPolyline : HYDROData_Entity /Abstract/
 %End
 
   typedef gp_XY                       Point;
-  typedef NCollection_Sequence<HYDROData_IPolyline::Point> PointsList;
+  typedef NCollection_Sequence<gp_XY> PointsList;
 
 
 %ConvertToSubClassCode
index 82aa9ff5e83c4db8eda03cda10c3ce65de43d8b6..40781bdf3c0e03d52858d125c104cae2ef6a78c4 100644 (file)
@@ -22,7 +22,6 @@
 
 %ExportedHeaderCode
 #include <HYDROData_PolylineXY.h>
-   typedef bool BOOLTYPE;
 %End
 
 class HYDROData_PolylineXY : HYDROData_IPolyline
@@ -90,7 +89,7 @@ public:
    */
   void GetSections( NCollection_Sequence<TCollection_AsciiString>& theSectNames,
                     NCollection_Sequence<HYDROData_IPolyline::SectionType>& theSectTypes,
-                    /*NCollection_Sequence<bool>&*/ NCollection_Sequence<BOOLTYPE>& theSectClosures ) const;
+                    NCollection_Sequence<bool>& theSectClosures ) const;
 
   /**
    * Replaces point for section with index "theSectionIndex".
index ab34b1bc3e5ac0e8fbe628f231650cabd03624ca..11c9a2a8286ca0d417a246385a95797e1fcd38f9 100644 (file)
@@ -32,7 +32,7 @@ class HYDROData_Profile : public HYDROData_Object
 public:
 
   typedef gp_XYZ                       ProfilePoint;
-  typedef NCollection_Sequence<HYDROData_Profile::ProfilePoint> ProfilePoints;
+  typedef NCollection_Sequence<gp_XYZ> ProfilePoints;
 
 public:
   /**
@@ -174,15 +174,15 @@ public:
    * \param theFileName the path to file
    * \return \c number of successfully imported profiles
    */
-  static int ImportFromFile( const HYDROData_Document theDoc,
-                             const TCollection_AsciiString&    theFileName,
-                             NCollection_Sequence<int>&        theBadProfilesIds )
-  [int ( const Handle_HYDROData_Document& ,
-         const TCollection_AsciiString&    ,
-         NCollection_Sequence<int>&         )];
+  static int ImportFromFile( HYDROData_Document             theDoc,
+                             const TCollection_AsciiString& theFileName,
+                             NCollection_Sequence<int>&     theBadProfilesIds )
+  [int ( const Handle_HYDROData_Document&,
+         const TCollection_AsciiString&,
+         NCollection_Sequence<int>& )];
   %MethodCode
     Py_BEGIN_ALLOW_THREADS
-    sipRes = HYDROData_Profile::ImportFromFile( a0, *a1, a2 );
+    sipRes = HYDROData_Profile::ImportFromFile( a0, *a1, *a2 );
     Py_END_ALLOW_THREADS
   %End