X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FRENUMBER_Swig%2FMEDRenumberCommon.i;h=717b15d775ecd634921b7984b4c3c71546c1052e;hb=b832b15337be013a56e0976170e5e235b89fcb03;hp=81814916c23076368aeb9d2711f33c6bed08dc4b;hpb=db558a57570648c5f07b0e3cfc7b1f61629c70d7;p=tools%2Fmedcoupling.git diff --git a/src/RENUMBER_Swig/MEDRenumberCommon.i b/src/RENUMBER_Swig/MEDRenumberCommon.i index 81814916c..717b15d77 100644 --- a/src/RENUMBER_Swig/MEDRenumberCommon.i +++ b/src/RENUMBER_Swig/MEDRenumberCommon.i @@ -1,9 +1,9 @@ -// Copyright (C) 2007-2013 CEA/DEN, EDF R&D +// Copyright (C) 2007-2024 CEA, EDF // // This library is free software; you can redistribute it and/or // modify it under the terms of the GNU Lesser General Public // License as published by the Free Software Foundation; either -// version 2.1 of the License. +// version 2.1 of the License, or (at your option) any later version. // // This library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -18,22 +18,18 @@ // // Author : Anthony Geay (CEA/DEN) -%module MEDRenumber - %include std_vector.i %include std_string.i +%include "MEDCouplingCommon.i" + %{ -#include "MEDCouplingMemArray.hxx" -#include "MEDCouplingAutoRefCountObjectPtr.hxx" +#include "MEDCouplingMemArray.txx" +#include "MCAuto.hxx" #include "MEDCouplingDataArrayTypemaps.i" -#include "RenumberingFactory.hxx" -#include "RENUMBER_Renumbering.hxx" - -using namespace ParaMEDMEM; +using namespace MEDCoupling; using namespace INTERP_KERNEL; - using namespace MED_RENUMBER; %} %template(ivec) std::vector; @@ -44,11 +40,11 @@ using namespace INTERP_KERNEL; %init %{ import_array(); %} #endif +%init %{ initializeMe_renumber(); %} + %feature("autodoc", "1"); %feature("docstring"); -%newobject MED_RENUMBER::RenumberingFactory; - %nodefaultctor; %rename (InterpKernelException) INTERP_KERNEL::Exception; @@ -56,52 +52,20 @@ using namespace INTERP_KERNEL; %include "MEDCouplingRefCountObject.i" %include "MEDCouplingMemArray.i" -class Renumbering -{ -public: - %extend - { - virtual PyObject *renumber(const ParaMEDMEM::DataArrayInt *graph, const ParaMEDMEM::DataArrayInt *index_graph) throw(INTERP_KERNEL::Exception) - { - if(!graph || !index_graph) - throw INTERP_KERNEL::Exception("wrap of Renumbering::renumber : One of the input arrays is NULL !"); - if(!graph->isAllocated() || !index_graph->isAllocated()) - throw INTERP_KERNEL::Exception("wrap of Renumbering::renumber : One of the input arrays is not allocated !"); - ParaMEDMEM::DataArrayInt *out0(0),*out1(0); - self->renumber(graph->begin(),index_graph->begin(),index_graph->getNumberOfTuples()-1,out0,out1); - PyObject *ret=PyTuple_New(2); - PyTuple_SetItem(ret,0,SWIG_NewPointerObj(SWIG_as_voidptr(out0),SWIGTYPE_p_ParaMEDMEM__DataArrayInt, SWIG_POINTER_OWN | 0 )); - PyTuple_SetItem(ret,1,SWIG_NewPointerObj(SWIG_as_voidptr(out1),SWIGTYPE_p_ParaMEDMEM__DataArrayInt, SWIG_POINTER_OWN | 0 )); - return ret; - } +%{ + void initializeMe_renumber() + {// AGY : here initialization of C++ traits in MEDCouplingDataArrayTypemaps.i for code factorization. Awful, I know, but no other solutions. + SWIGTITraits::TI=SWIGTYPE_p_MEDCoupling__DataArrayDouble; + SWIGTITraits::TI=SWIGTYPE_p_MEDCoupling__DataArrayFloat; } - virtual ~Renumbering(); -}; - -namespace MED_RENUMBER -{ - Renumbering *RenumberingFactory(const std::string& s) throw(INTERP_KERNEL::Exception); -} +%} -%inline -{ - std::vector RenumberAvailableMethods()throw(INTERP_KERNEL::Exception) - { - std::vector ret; -#ifdef HAS_BOOST - ret.push_back(std::string("BOOST")); -#endif -#ifdef HAS_METIS - ret.push_back(std::string("METIS")); -#endif - return ret; - } -} +%include "MEDRenumberImpl.i" %pythoncode %{ import os __filename=os.environ.get('PYTHONSTARTUP') if __filename and os.path.isfile(__filename): - execfile(__filename) - pass + with open(__filename) as __fp: + exec(__fp.read()) %}