Introduction

Short description of the problem

We consider a vacuum vessel embodied as a toroidal volume defined by a 2D arbitrary polygon representing in cross-section in (R,Z) coordinates. We want to efficiently mesh both the volume and the 3D surface of the vessel.

As input, we provide the cross-section polygon and a list dV defining the three resolutions dV = [dR,dZ,dRphi], where each resolution is a distance in meters in the corresponding direction (note the use of dRphi instead of dphi for that purpose). Indeed, we do not want a simple cylindrical mesh, as we want to capture details in the toroidal (Rphi) direction with a similar accuracy for every value of R.

In most uses, we will only need a fraction of the total mesh. Hence, the routine should not compute the total mesh but only the fraction we need. For a given resolution dV (i.e. a given tuple of dR,dZ,dRphi), there should be only one possible mesh. This way, the fraction of interest can be defined either by its physical limits (DR,DZ,DPhi) or by the indices of the mesh elements which are required.

Hence, we need a methods to

  • Compute the mesh fraction from its limits and return it with its indices
  • Compute the mesh fraction from its indices and return it with its limits

Not returning the whole mesh makes sense since it may well be a huge array (memory-expensive). The computation should be as fast as possible.

Numerical strategy

Volume

For a given input cross-section polygon VPoly, provided with the required resolutions dR, dZ and dRphi, the total mesh is a torus of rectangular cross-section (R goes from a minimum to a maximum, as Z, and phi goes from -pi to pi). This simplifies the computation of the indices without making the result heavier since only the relevant mesh elements are returned. The limits of the desired submesh can be provided as DR, DZ and DPhi (note that the toroidal limit is angular as opposed to the toroidal resolution).

The minimum and maximim boundaries of R and Z are also provided. They could be deduced from VPOly but they are explicitly provided for two reasons:

  • In ToFu these limits are stored in the Ves object, so it is already available and there is no need to compute it again
  • It may happen that a VPoly is slightly modified with no desire to modify the mesh, so it should remain possible to force the boundaries.

The indices are return in numeric form (not boolean), and computed as follows:

  • The numbering occurs anti-clockwise from -pi to pi for phi
  • Then, it occurs along Z, from its minimum to its maximum value
  • Finally it is incremented along R, from its minimum to its maximum value

Hence, we first describe the innermost column (starting from the lowest horizontal ring), and we gradually moved towards the outermost column.

This is necessary since due the desired quasi-constant toroidal accuracy, the number of mesh elements in the toroidal direction is a function of R.

Surface

The strategy for meshing the surface is similar, expect that here there are only two resolutions, dL and dRPhi, where dL is the resolution in the poloidal direction along the segments of VPoly.

Volume meshing

Naive python


In [4]:
A = np.random.random((100,))
%timeit len(A)
%timeit A.size


The slowest run took 44.64 times longer than the fastest. This could mean that an intermediate result is being cached.
10000000 loops, best of 3: 90.8 ns per loop
The slowest run took 36.53 times longer than the fastest. This could mean that an intermediate result is being cached.
10000000 loops, best of 3: 111 ns per loop

Numpy


In [55]:
10%2


Out[55]:
0

In [14]:
import numpy as np

# Preliminary function to get optimal resolution from input resolution
def _Ves_mesh_dlfromL_numpy(LMinMax, dL, DL=None, margin=1.e-9):
    """ Get the actual reolution from the desired resolution and MinMax and limits """
    # Get the number of mesh elements in LMinMax
    N = np.ceil(np.diff(LMinMax)/dL)[0]
    # Derive the real (effective) resolution
    dLr = (np.diff(LMinMax)/N)[0]
    # Get desired limits if any
    DL = LMinMax if DL is None else DL
    # Get the extreme indices of the mesh elements that really need to be created within those limits
    abs0 = np.abs(DL[0]-LMinMax[0])
    if abs0-dLr*np.floor(abs0/dLr)<margin*dLr:
        nL0 = np.round((DL[0]-LMinMax[0])/dLr)
    else:
        nL0 = np.floor((DL[0]-LMinMax[0])/dLr)
    abs1 = np.abs(DL[1]-LMinMax[0])
    if abs1-dLr*np.floor(abs1/dLr)<margin*dLr:
        nL1 = np.round((DL[1]-LMinMax[0])/dLr)-1
    else:
        nL1 = np.floor((DL[1]-LMinMax[0])/dLr)
    # Get the corresponding indices
    indL = np.arange(nL0,nL1+1,1).astype(int)
    # Get the centers of the mesh elements
    L = LMinMax[0] + (0.5 + indL)*dLr
    return L, dLr, indL, N


def _Ves_Vmesh_Phi_numpy(DPhi, dPhir, NRPhi, margin=1.e-9):
    """ Get the min and max indices of the relevant Phi for each R (to be finished) """
    nPhi0 = np.nan*np.ones((dPhir.size,))
    nPhi1 = np.nan*np.ones((dPhir.size,))
    abs0 = np.abs(DPhi[0]+np.pi)
    ind0 = abs0-dPhir*np.floor(abs0/dPhir)<margin*dPhir
    nPhi0[ind0] = np.round((DPhi[0]+np.pi)/dPhir[ind0])
    nPhi0[~ind0] = np.floor((DPhi[0]+np.pi)/dPhir[~ind0])
    abs1 = np.abs(DPhi[1]+np.pi)
    ind1 = abs1-dPhir*np.floor(abs1/dPhir)<margin*dPhir
    nPhi1[ind1] = np.round((DPhi[1]+np.pi)/dPhir[ind1])-1
    nPhi1[~ind1] = np.floor((DPhi[1]+np.pi)/dPhir[~ind1])
    assert np.all(nPhi0>=0) and np.all(nPhi0<=NRPhi)
    assert np.all(nPhi1>=0) and np.all(nPhi1<=NRPhi)
    return nPhi0, nPhi1


def _Ves_Vmesh_Tor_SubFromD_numpy(dR, dZ, dRPhi, RMinMax, ZMinMax, DR=None, DZ=None, DPhi=None, VPoly=None, Out='(X,Y,Z)', margin=1.e-9):
    """ Return the desired submesh indicated by the limits (DR,DZ,DPhi), for the desired resolution (dR,dZ,dRphi) """
    # Get the actual R and Z resolutions and mesh elements
    R0, dRr0, indR0, NR0 = _Ves_mesh_dlfromL_numpy(RMinMax, dR, None, margin=margin)
    R, dRr, indR, NR = _Ves_mesh_dlfromL_numpy(RMinMax, dR, DR, margin=margin)
    Z, dZr, indZ, NZ = _Ves_mesh_dlfromL_numpy(ZMinMax, dZ, DZ, margin=margin)
    Rn, Zn = len(R), len(Z)

    # Get the actual RPhi resolution and Phi mesh elements (! depends on R !)
    NRPhi0 = np.ceil(2.*np.pi*R0/dRPhi)
    NRPhi = np.ceil(2.*np.pi*R/dRPhi)
    dPhir = 2.*np.pi/NRPhi
    # Get the limits if any (and make sure to replace them in the proper quadrants)
    DPhi = [-np.pi,np.pi] if DPhi is None else np.arctan2(np.sin(DPhi),np.cos(DPhi))
    # Later we'll have to remember that the lower limit may be greater than the upper limit due to 2pi modulo
    # Get the two extreme indices of the Phi elements inside the limits for each R
    nPhi0, nPhi1 = _Ves_Vmesh_Phi_numpy(DPhi, dPhir, NRPhi, margin=margin)

    # Compute the centers and indices, using a for loop (no choice) on R
    NRZPhi_cum0 = np.concatenate(([0],NZ*np.cumsum(NRPhi0[:-1])))
    PtsRZP, dV, ind = [], [], []
    for ii in range(0,Rn):
        # Get the phi values
        if DPhi[0]<DPhi[1]:
            indPhi = np.arange(nPhi0[ii],nPhi1[ii]+1)
        else:
            indPhi = np.concatenate((np.arange(nPhi0[ii],NRPhi[ii]),np.arange(0,nPhi1[ii]+1)))
        Phin = len(indPhi)
        phi = -np.pi + (0.5 + indPhi)*dPhir[ii]
        # Get the (R,Z,phi) points
        PtsRZP.append( np.array([R[ii]*np.ones((Phin*Zn,)), np.repeat(Z,Phin), np.tile(phi,Zn)]) )
        # Get the volume
        dV.append( dRr*dZr*dPhir[ii]*R[ii]*np.ones((Phin*Zn,))  )
        # Get the indices
        indii = R0==R[ii]
        ind.append( NRZPhi_cum0[indii] + (indZ[:,np.newaxis]*NRPhi[ii] + indPhi[np.newaxis,:]).flatten() )
        
    PtsRZP = np.concatenate(tuple(PtsRZP),axis=1)
    dV = np.concatenate(tuple(dV))
    ind = np.concatenate(tuple(ind))
    
    # To be commented out once debugged
    assert ind.size==PtsRZP.shape[1]
    assert ind.size==dV.size
    assert np.unique(ind).size==ind.size 

    dRPhir = (dPhir*R)
    """
    if not VPoly is None:
        indin = _Ves_isInside(VPoly, 'Tor', None, PtsRZP[:-1,:], In='(R,Z)')
        PtsRZP, dV, ind = PtsRZP[:,indin], dV[indin], ind[indin]
        Ru = np.unique(PtsRZP[0,:])
        if not Ru==R:
            indii = np.array([R[ii] in Ru for ii in range(0,len(R))], dtype=bool)
            dRPhir = dRPhir[indii]
    """

    if Out.lower()=='(x,y,z)':
        Pts = np.array([PtsRZP[0,:]*np.cos(PtsRZP[2,:]), PtsRZP[0,:]*np.sin(PtsRZP[2,:]), PtsRZP[1,:]])
    else:
        Pts = PtsRZP
        
    return Pts, dV, ind, dRr, dZr, dRPhir

def _Ves_Vmesh_Tor_SubFromInd_numpy(dR, dZ, dRPhi, RMinMax, ZMinMax, ind, Out='(X,Y,Z)', margin=1.e-9):
    """ Return the desired submesh indicated by the (numerical) indices, for the desired resolution (dR,dZ,dRphi) """
    # Get the actual R and Z resolutions and mesh elements
    R, dRr, indR, NR = _Ves_mesh_dlfromL_numpy(RMinMax, dR, None, margin=margin)
    Z, dZr, indZ, NZ = _Ves_mesh_dlfromL_numpy(ZMinMax, dZ, None, margin=margin)
    Rn, Zn = len(R), len(Z)

    # Get the actual RPhi resolution and Phi mesh elements (! depends on R !)
    NRPhi = np.ceil(2.*np.pi*R/dRPhi)
    dPhir = 2.*np.pi/NRPhi
    NRZPhi_cum = np.concatenate(([0],NZ*np.cumsum(NRPhi[:-1])))
    
    # Get R, Z, and Phi indices
    Nind = ind.size
    indR = ind[:,np.newaxis]-NRZPhi_cum[np.newaxis,:]<0
    indRtemp = np.tile(np.arange(0,NR),(Nind,1))
    indRtemp[indR] = np.nan
    indR = np.nanmax(indRtemp, axis=1).astype(int)
    indZ = ((ind - NRZPhi_cum[indR]) // NRPhi[indR]).astype(int)
    indPhi = ind - NRZPhi_cum[indR] - indZ*NRPhi[indR]
    
    # Derive R, Z and phi values
    PtsRZP = np.array([R[indR], Z[indZ], np.nan*np.ones((Nind,))])
    dV = np.nan*np.ones((Nind,))
    Ru = np.unique(PtsRZP[0,:])
    dRPhir = np.nan*np.ones((len(Ru),))
    for ii in range(0,len(Ru)):
        indRii = (R==Ru[ii]).nonzero()[0]
        indRu = (PtsRZP[0,:]==Ru[ii]).nonzero()[0]
        PtsRZP[2,indRu] = -np.pi + (0.5+indPhi[indRu])*dPhir[indRii]
        dRPhir[ii] = dPhir[indRii]*Ru[ii]
        dV[indRu] = dRr*dZr*dRPhir[ii]
        
    if Out.lower()=='(x,y,z)':
        Pts = np.array([PtsRZP[0,:]*np.cos(PtsRZP[2,:]), PtsRZP[0,:]*np.sin(PtsRZP[2,:]), PtsRZP[1,:]])
    else:
        Pts = PtsRZP

    return Pts, dV, dRr, dZr, dRPhir



Check and debug


In [2]:
# Check and debug
[dR, dZ, dRPhi], RMinMax, ZMinMax = [0.03]*3, [2.,3.], [-1.,1.]
DR, DZ, DPhi = [2.15,2.6], [-0.21,0.51], [7.*np.pi/4.,5.*np.pi/4.]

Pts0, dV0, ind0, dRr0, dZr0, dRPhir0 = _Ves_Vmesh_Tor_SubFromD_numpy(dR,dZ,dRPhi, RMinMax,ZMinMax, Out='(X,Y,Z)')
PtsRZP0 = np.array([np.hypot(Pts0[0,:],Pts0[1,:]), Pts0[2,:],np.arctan2(Pts0[1,:],Pts0[0,:])])
Pts0b, dV0b, dRr0b, dZr0b, dRPhir0b = _Ves_Vmesh_Tor_SubFromInd_numpy(dR, dZ, dRPhi, RMinMax, ZMinMax, ind0, Out='(X,Y,Z)')
print "Check 0", [np.allclose(Pts0,Pts0b,atol=1.e-14,rtol=0.,equal_nan=True) for (A,B) in [(Pts0,Pts0b),(dV0,dV0b),(dRr0,dRr0b),(dZr0,dZr0b),(dRPhir0,dRPhir0b)]]

Pts, dV, ind, dRr, dZr, dRPhir = _Ves_Vmesh_Tor_SubFromD_numpy(dR,dZ,dRPhi, RMinMax,ZMinMax, DR=DR,DZ=DZ,DPhi=DPhi, Out='(X,Y,Z)')
PtsRZP = np.array([np.hypot(Pts[0,:],Pts[1,:]), Pts[2,:],np.arctan2(Pts[1,:],Pts[0,:])])
Ptsb, dVb, dRrb, dZrb, dRPhirb = _Ves_Vmesh_Tor_SubFromInd_numpy(dR,dZ,dRPhi, RMinMax,ZMinMax, ind, Out='(X,Y,Z)')
print "Check 1", [np.allclose(A,B,atol=1.e-14,rtol=0.,equal_nan=True) for (A,B) in [(Pts,Ptsb),(dV,dVb),(dRr,dRrb),(dZr,dZrb),(dRPhir,dRPhirb)]]


Check 0 [True, True, True, True, True]
Check 1 [True, True, True, True, True]

In [3]:
# Plot for check and debug
import matplotlib.pyplot as plt

plt.figure(figsize=(16,10))
plt.subplot(1,2,1, aspect="equal", adjustable="datalim")
plt.plot(PtsRZP0[0,:],PtsRZP0[1,:],'.b', PtsRZP[0,:],PtsRZP[1,:],'.r', markersize=2)
plt.plot([DR[0],DR[1],DR[1],DR[0],DR[0]], [DZ[0],DZ[0],DZ[1],DZ[1],DZ[0]],'--k')

plt.subplot(1,2,2, aspect="equal", adjustable="datalim")
plt.plot(Pts0[0,:],Pts0[1,:],'.b', Pts[0,:],Pts[1,:],'.r', markersize=2)
thet = np.linspace(DPhi[0],DPhi[1],100) if DPhi[0]<DPhi[1] else np.linspace(DPhi[0],DPhi[1]+2.*np.pi,100)
X = np.concatenate((DR[0]*np.cos(thet),DR[1]*np.cos(thet[::-1]),[DR[0]*np.cos(thet[0])]))
Y = np.concatenate((DR[0]*np.sin(thet),DR[1]*np.sin(thet[::-1]),[DR[0]*np.sin(thet[0])]))
plt.plot(X,Y,'--k')

plt.show()



In [6]:
# Check and debug
[dR, dZ, dRPhi], RMinMax, ZMinMax = [0.02]*3, [2.,3.], [-1.,1.]
DR, DZ, DPhi = [2.15,2.6], [-0.21,0.51], [7.*np.pi/4.,5.*np.pi/4.]
Pts0, dV0, ind0, dRr0, dZr0, dRPhir0 = _Ves_Vmesh_Tor_SubFromD_numpy(dR,dZ,dRPhi, RMinMax,ZMinMax, Out='(X,Y,Z)')

%timeit out = _Ves_Vmesh_Tor_SubFromD_numpy(dR,dZ,dRPhi, RMinMax,ZMinMax, Out='(X,Y,Z)')
%timeit out = _Ves_Vmesh_Tor_SubFromInd_numpy(dR, dZ, dRPhi, RMinMax, ZMinMax, ind0, Out='(X,Y,Z)')


1 loop, best of 3: 773 ms per loop
1 loop, best of 3: 6.31 s per loop

Cython


In [1]:
%load_ext cython

In [52]:
%%cython -a
cimport cython
import numpy as np
cimport numpy as cnp
from cpython cimport bool
from libc.math cimport ceil as Cceil, abs as Cabs, floor as Cfloor, round as Cround
from libc.math cimport cos as Ccos, sin as Csin, atan2 as Catan2, pi as Cpi
from matplotlib.path import Path

import datetime as dtm

# Preliminary function to get optimal resolution from input resolution
@cython.cdivision(True)
@cython.wraparound(False)
@cython.boundscheck(False)
def _Ves_mesh_dlfromL_cython(double[::1] LMinMax, double dL, DL=None, double margin=1.e-9):
    """ Get the actual reolution from the desired resolution and MinMax and limits """
    # Get the number of mesh elements in LMinMax
    cdef double N = Cceil((LMinMax[1]-LMinMax[0])/dL)
    # Derive the real (effective) resolution
    cdef double dLr = (LMinMax[1]-LMinMax[0])/N
    # Get desired limits if any
    cdef double[::1] DLc, L
    cdef long [::1] indL
    #cdef cnp.ndarray[double,ndim=1] indL, L
    cdef double abs0, abs1, A
    cdef int nL0, nL1, Nind, ii, jj
    if DL is None:
        DLc = LMinMax
    else:
        if DL[0] is None:
            DL[0] = LMinMax[0]
        if DL[1] is None:
            DL[1] = LMinMax[1]
        DLc = np.array(DL)
        
    # Get the extreme indices of the mesh elements that really need to be created within those limits
    abs0 = Cabs(DLc[0]-LMinMax[0])
    if abs0-dLr*Cfloor(abs0/dLr)<margin*dLr:
        nL0 = int(Cround((DLc[0]-LMinMax[0])/dLr))
    else:
        nL0 = int(Cfloor((DLc[0]-LMinMax[0])/dLr))
    abs1 = Cabs(DLc[1]-LMinMax[0])
    if abs1-dLr*Cfloor(abs1/dLr)<margin*dLr:
        nL1 = int(Cround((DLc[1]-LMinMax[0])/dLr)-1)
    else:
        nL1 = int(Cfloor((DLc[1]-LMinMax[0])/dLr))
    # Get the corresponding indices
    Nind = nL1+1-nL0
    indL = np.empty((Nind,),dtype=int)#np.linspace(nL0,nL1,Nind,endpoint=True)
    L = np.empty((Nind,))
    for ii in range(0,Nind):
        jj = nL0+ii
        indL[ii] = jj
        L[ii] = LMinMax[0] + (0.5 + (<double>jj))*dLr
    return np.asarray(L), dLr, np.asarray(indL), N

@cython.cdivision(True)
@cython.wraparound(False)
@cython.boundscheck(False)
def _Ves_Vmesh_Tor_SubFromD_cython(double dR, double dZ, double dRPhi, 
                                   double[::1] RMinMax, double[::1] ZMinMax,
                                   DR=None, DZ=None, DPhi=None, VPoly=None,
                                   str Out='(X,Y,Z)', double margin=1.e-9):
    " Return the desired submesh indicated by the limits (DR,DZ,DPhi), for the desired resolution (dR,dZ,dRphi) "
    
    cdef double[::1] R0, R, Z, dRPhir, dPhir, NRPhi#, dPhi, NRZPhi_cum0, indPhi, phi
    cdef double dRr0, dRr, dZr, DPhi0, DPhi1
    cdef double abs0, abs1, phi, indiijj
    cdef long[::1] indR0, indR, indZ, Phin, NRPhi0
    cdef int NR0, NR, NZ, Rn, Zn, nRPhi0, indR0ii, ii, jj, nPhi0, nPhi1, zz, NP, NRPhi_int, Rratio
    cdef cnp.ndarray[double,ndim=2] Pts, indI
    cdef cnp.ndarray[double,ndim=1] dV, ind
    
    # Get the actual R and Z resolutions and mesh elements
    R0, dRr0, indR0, NR0 = _Ves_mesh_dlfromL_cython(RMinMax, dR, None, margin=margin)
    R, dRr, indR, NR = _Ves_mesh_dlfromL_cython(RMinMax, dR, DR, margin=margin)
    Z, dZr, indZ, NZ = _Ves_mesh_dlfromL_cython(ZMinMax, dZ, DZ, margin=margin)
    Rn = len(R)
    Zn = len(Z)
    
    # Get the limits if any (and make sure to replace them in the proper quadrants)
    if DPhi is None:
        DPhi0, DPhi1 = -Cpi, Cpi
    else:
        DPhi0, DPhi1 = Catan2(Csin(DPhi[0]),Ccos(DPhi[0])), Catan2(Csin(DPhi[1]),Ccos(DPhi[1]))
    
    dRPhir, dPhir = np.empty((Rn,)), np.empty((Rn,))
    Phin = np.empty((Rn,),dtype=int)
    NRPhi = np.empty((Rn,))
    NRPhi0 = np.zeros((Rn,),dtype=int)
    nRPhi0, indR0ii = 0, 0
    NP, NPhimax = 0, 0
    Rratio = int(Cceil(R[Rn-1]/R[0]))
    for ii in range(0,Rn):
        # Get the actual RPhi resolution and Phi mesh elements (! depends on R !)
        NRPhi[ii] = Cceil(2.*Cpi*R[ii]/dRPhi)
        NRPhi_int = int(NRPhi[ii])
        dPhir[ii] = 2.*Cpi/NRPhi[ii]
        dRPhir[ii] = dPhir[ii]*R[ii]
        # Get index and cumulated indices from background
        for jj in range(indR0ii,NR0):
            if R0[jj]==R[ii]:
                indR0ii = jj
                break
            else:
                nRPhi0 += <long>Cceil(2.*Cpi*R0[jj]/dRPhi)
                NRPhi0[ii] = nRPhi0*NZ
        # Get indices of phi
        # Get the extreme indices of the mesh elements that really need to be created within those limits
        abs0 = Cabs(DPhi0+Cpi)
        if abs0-dPhir[ii]*Cfloor(abs0/dPhir[ii])<margin*dPhir[ii]:
            nPhi0 = int(Cround((DPhi0+Cpi)/dPhir[ii]))
        else:
            nPhi0 = int(Cfloor((DPhi0+Cpi)/dPhir[ii]))
        abs1 = Cabs(DPhi1+Cpi)
        if abs1-dPhir[ii]*Cfloor(abs1/dPhir[ii])<margin*dPhir[ii]:
            nPhi1 = int(Cround((DPhi1+Cpi)/dPhir[ii])-1)
        else:
            nPhi1 = int(Cfloor((DPhi1+Cpi)/dPhir[ii]))
            
        if DPhi0<DPhi1:
            #indI.append(list(range(nPhi0,nPhi1+1)))
            Phin[ii] = nPhi1+1-nPhi0
            if ii==0:
                indI = np.ones((Rn,Phin[ii]*Rratio+1))
            for jj in range(0,Phin[ii]):
                indI[ii,jj] = <double>( nPhi0+jj )
        else:
            #indI.append(list(range(nPhi0,NRPhi_int)+list(range(0,nPhi1+1))))
            Phin[ii] = nPhi1+1+NRPhi_int-nPhi0
            if ii==0:
                indI = np.ones((Rn,Phin[ii]*Rratio+1))
            for jj in range(0,NRPhi_int-nPhi0):
                indI[ii,jj] = <double>( nPhi0+jj )
            for jj in range(NRPhi_int-nPhi0,Phin[ii]):
                indI[ii,jj] = <double>( jj- (NRPhi_int-nPhi0) )
        NP += Zn*Phin[ii]   
    
    Pts = np.empty((3,NP))
    ind = np.empty((NP,))
    dV = np.empty((NP,))
    # Compute Pts, dV and ind
    # This triple loop is the longest part, it takes ~90% of the CPU time
    NP = 0
    if Out.lower()=='(x,y,z)':
        for ii in range(0,Rn):
            for zz in range(0,Zn):
                for jj in range(0,Phin[ii]):
                    indiijj = indI[ii,jj]
                    phi = -Cpi + (0.5+indiijj)*dPhir[ii]
                    Pts[0,NP] = R[ii]*Ccos(phi)
                    Pts[1,NP] = R[ii]*Csin(phi)
                    Pts[2,NP] = Z[zz]
                    ind[NP] = NRPhi0[ii] + indZ[zz]*NRPhi[ii] + indiijj
                    dV[NP] = dRr*dZr*dRPhir[ii]
                    NP += 1
    else:
        for ii in range(0,Rn):
            for zz in range(0,Zn):
                for jj in range(0,Phin[ii]):
                    indiijj = indI[ii,jj]
                    Pts[0,NP] = R[ii]
                    Pts[1,NP] = Z[zz]
                    Pts[2,NP] = -Cpi + (0.5+indiijj)*dPhir[ii]
                    ind[NP] = NRPhi0[ii] + indZ[zz]*NRPhi[ii] + indiijj
                    dV[NP] = dRr*dZr*dRPhir[ii]
                    NP += 1

    if not VPoly is None:
        indin = Path(VPoly.T).contains_points(PtsRZP[:-1,:].T, transform=None, radius=0.0)
        PtsRZP, dV, ind = PtsRZP[:,indin], dV[indin], ind[indin]
        Ru = np.unique(PtsRZP[0,:])
        if not Ru==R:
            indii = np.array([R[ii] in Ru for ii in range(0,len(R))], dtype=bool)
            dRPhir = dRPhir[indii]
    return Pts, dV, ind.astype(int), dRr, dZr, np.asarray(dRPhir)
    
@cython.cdivision(True)
@cython.wraparound(False)
@cython.boundscheck(False)
def _Ves_Vmesh_Tor_SubFromInd_cython(double dR, double dZ, double dRPhi, 
                                     double[::1] RMinMax, double[::1] ZMinMax, long[::1] ind, 
                                     str Out='(X,Y,Z)', double margin=1.e-9):
    """ Return the desired submesh indicated by the (numerical) indices, for the desired resolution (dR,dZ,dRphi) """
    cdef double[::1] R, Z, dRPhirRef, dPhir, Ru, dRPhir
    cdef double dRr, dZr, phi
    cdef long[::1] indR, indZ, NRPhi0, NRPhi
    cdef long NR, NZ, Rn, Zn, NP=len(ind), Rratio
    cdef int ii, jj, iiR, iiZ, iiphi
    cdef double[:,::1] Phi
    cdef cnp.ndarray[double,ndim=2] Pts=np.empty((3,NP))
    cdef cnp.ndarray[double,ndim=1] dV=np.empty((NP,))
    
    # Get the actual R and Z resolutions and mesh elements
    R, dRr, indR, NR = _Ves_mesh_dlfromL_cython(RMinMax, dR, None, margin=margin)
    Z, dZr, indZ, NZ = _Ves_mesh_dlfromL_cython(ZMinMax, dZ, None, margin=margin)
    Rn, Zn = len(R), len(Z)
    
    # Number of Phi per R
    dRPhirRef, dPhir = np.empty((NR,)), np.empty((NR,))
    Ru, dRPhir = np.zeros((NR,)), np.nan*np.ones((NR,))
    NRPhi, NRPhi0 = np.empty((NR,),dtype=int), np.empty((NR+1,),dtype=int)
    Rratio = int(Cceil(R[NR-1]/R[0]))
    for ii in range(0,NR):
        NRPhi[ii] = <long>(Cceil(2.*Cpi*R[ii]/dRPhi))
        dRPhirRef[ii] = 2.*Cpi*R[ii]/<double>(NRPhi[ii])
        dPhir[ii] = 2.*Cpi/<double>(NRPhi[ii])
        if ii==0:
            NRPhi0[ii] = 0
            Phi = np.empty((NR,NRPhi[ii]*Rratio+1))
        else:
            NRPhi0[ii] = NRPhi0[ii-1] + NRPhi[ii-1]*NZ
        for jj in range(0,NRPhi[ii]):
            Phi[ii,jj] = -Cpi + (0.5+<double>jj)*dPhir[ii]
            
    if Out.lower()=='(x,y,z)':
        for ii in range(0,NP):
            for jj in range(0,NR+1):
                if ind[ii]-NRPhi0[jj]<0.:
                    break
            iiR = jj-1
            iiZ = (ind[ii] - NRPhi0[iiR])//NRPhi[iiR]
            iiphi = ind[ii] - NRPhi0[iiR] - iiZ*NRPhi[iiR]
            phi = Phi[iiR,iiphi]
            Pts[0,ii] = R[iiR]*Ccos(phi)
            Pts[1,ii] = R[iiR]*Csin(phi)
            Pts[2,ii] = Z[iiZ]
            dV[ii] = dRr*dZr*dRPhirRef[iiR]
            if Ru[iiR]==0.:
                dRPhir[iiR] = dRPhirRef[iiR]
                Ru[iiR] = 1.
    else: 
        for ii in range(0,NP):
            for jj in range(0,NR+1):
                if ind[ii]-NRPhi0[jj]<0.:
                    break
            iiR = jj-1
            iiZ = (ind[ii] - NRPhi0[iiR])//NRPhi[iiR]
            iiphi = ind[ii] - NRPhi0[iiR] - iiZ*NRPhi[iiR]
            Pts[0,ii] = R[iiR]
            Pts[1,ii] = Z[iiZ]
            Pts[2,ii] = Phi[iiR,iiphi]
            dV[ii] = dRr*dZr*dRPhirRef[iiR]
            if Ru[iiR]==0.:
                dRPhir[iiR] = dRPhirRef[iiR]
                Ru[iiR] = 1.
    
    return Pts, dV, dRr, dZr, np.asarray(dRPhir)[~np.isnan(dRPhir)]
   
    
    
    
def _Ves_Vmesh_Lin_SubFromD_cython(double dX, double dY, double dZ, 
                                   double[::1] XMinMax, double[::1] YMinMax, double[::1] ZMinMax,
                                   DX=None, DY=None, DZ=None, VPoly=None,
                                   double margin=1.e-9):
    " Return the desired submesh indicated by the limits (DX,DY,DZ), for the desired resolution (dX,dY,dZ) "
    
    cdef double[::1] X, Y, Z
    cdef double dXr, dYr, dZr, dV
    cdef cnp.ndarray[long,ndim=1] indX, indY, indZ
    cdef int NX, NY, NZ, Xn, Yn, Zn
    cdef cnp.ndarray[double,ndim=2] Pts
    cdef cnp.ndarray[long,ndim=1] ind
    
    # Get the actual X, Y and Z resolutions and mesh elements
    X, dXr, indX, NX = _Ves_mesh_dlfromL_cython(XMinMax, dX, DX, margin=margin)
    Y, dYr, indY, NY = _Ves_mesh_dlfromL_cython(YMinMax, dY, DY, margin=margin)
    Z, dZr, indZ, NZ = _Ves_mesh_dlfromL_cython(ZMinMax, dZ, DZ, margin=margin)
    Xn, Yn, Zn = len(X), len(Y), len(Z)
        
    Pts = np.array([np.tile(X,(Yn*Zn,1)).flatten(), np.tile(np.repeat(Y,Xn),(Zn,1)).flatten(), np.repeat(Z,Xn*Yn)])
    ind = np.repeat(NX*NY*indZ,Xn*Yn) + np.tile(np.repeat(NX*indY,Xn),(Zn,1)).flatten() + np.tile(indX,(Yn*Zn,1)).flatten()
    dV = dXr*dYr*dZr
    
    #if VPoly is not None:
    #    indin = _Ves_isInside(Pts[:-1,:], VPoly=VPoly, VType='Lin', In='(X,Y)')
    #    Pts, dV, ind = Pts[:,indin], dV[indin], ind[indin]
    
    return Pts, dV, ind.astype(int), dXr, dYr, dZr
    

def _Ves_Vmesh_Lin_SubFromInd_cython(double dX, double dY, double dZ, 
                                     double[::1] XMinMax, double[::1] YMinMax, double[::1] ZMinMax,
                                     cnp.ndarray[long,ndim=1] ind, double margin=1.e-9):
    " Return the desired submesh indicated by the limits (DX,DY,DZ), for the desired resolution (dX,dY,dZ) "
    
    cdef cnp.ndarray[double,ndim=1] X, Y, Z
    cdef double dXr, dYr, dZr, dV
    cdef long[::1] bla
    cdef cnp.ndarray[long,ndim=1] indX, indY, indZ
    cdef int NX, NY, NZ, Xn, Yn, Zn
    cdef cnp.ndarray[double,ndim=2] Pts
    
    # Get the actual X, Y and Z resolutions and mesh elements
    X, dXr, bla, NX = _Ves_mesh_dlfromL_cython(XMinMax, dX, None, margin=margin)
    Y, dYr, bla, NY = _Ves_mesh_dlfromL_cython(YMinMax, dY, None, margin=margin)
    Z, dZr, bla, NZ = _Ves_mesh_dlfromL_cython(ZMinMax, dZ, None, margin=margin)
    
    #print NX, NY, NZ
    indZ = ind // (NX*NY)
    indY = (ind - NX*NY*indZ) // NX
    indX = ind - NX*NY*indZ - NX*indY
    #print ind
    #print indZ
    #print indY
    #print indX
    Pts = np.array([X[indX.astype(int)], Y[indY.astype(int)], Z[indZ.astype(int)]])
    dV = dXr*dYr*dZr
    
    return Pts, dV, dXr, dYr, dZr


Out[52]:
Cython: _cython_magic_ffb7650808bb7830760fff8d6d047f13.pyx

Generated by Cython 0.25.2

Yellow lines hint at Python interaction.
Click on a line that starts with a "+" to see the C code that Cython generated for it.

+001: cimport cython
  __pyx_t_1 = PyDict_New(); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_test, __pyx_t_1) < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+002: import numpy as np
  __pyx_t_1 = __Pyx_Import(__pyx_n_s_numpy, 0, -1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_np, __pyx_t_1) < 0) __PYX_ERR(0, 2, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
 003: cimport numpy as cnp
 004: from cpython cimport bool
 005: from libc.math cimport ceil as Cceil, abs as Cabs, floor as Cfloor, round as Cround
 006: from libc.math cimport cos as Ccos, sin as Csin, atan2 as Catan2, pi as Cpi
 007: 
+008: import datetime as dtm
  __pyx_t_1 = __Pyx_Import(__pyx_n_s_datetime, 0, -1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 8, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_dtm, __pyx_t_1) < 0) __PYX_ERR(0, 8, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
 009: 
 010: # Preliminary function to get optimal resolution from input resolution
 011: @cython.cdivision(True)
 012: @cython.wraparound(False)
 013: @cython.boundscheck(False)
+014: def _Ves_mesh_dlfromL_cython(double[::1] LMinMax, double dL, DL=None, double margin=1.e-9):
/* Python wrapper */
static PyObject *__pyx_pw_46_cython_magic_ffb7650808bb7830760fff8d6d047f13_1_Ves_mesh_dlfromL_cython(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_46_cython_magic_ffb7650808bb7830760fff8d6d047f13__Ves_mesh_dlfromL_cython[] = " Get the actual reolution from the desired resolution and MinMax and limits ";
static PyMethodDef __pyx_mdef_46_cython_magic_ffb7650808bb7830760fff8d6d047f13_1_Ves_mesh_dlfromL_cython = {"_Ves_mesh_dlfromL_cython", (PyCFunction)__pyx_pw_46_cython_magic_ffb7650808bb7830760fff8d6d047f13_1_Ves_mesh_dlfromL_cython, METH_VARARGS|METH_KEYWORDS, __pyx_doc_46_cython_magic_ffb7650808bb7830760fff8d6d047f13__Ves_mesh_dlfromL_cython};
static PyObject *__pyx_pw_46_cython_magic_ffb7650808bb7830760fff8d6d047f13_1_Ves_mesh_dlfromL_cython(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  __Pyx_memviewslice __pyx_v_LMinMax = { 0, 0, { 0 }, { 0 }, { 0 } };
  double __pyx_v_dL;
  PyObject *__pyx_v_DL = 0;
  double __pyx_v_margin;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("_Ves_mesh_dlfromL_cython (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_LMinMax,&__pyx_n_s_dL,&__pyx_n_s_DL,&__pyx_n_s_margin,0};
    PyObject* values[4] = {0,0,0,0};
    values[2] = ((PyObject *)Py_None);
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_LMinMax)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        case  1:
        if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_dL)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_Ves_mesh_dlfromL_cython", 0, 2, 4, 1); __PYX_ERR(0, 14, __pyx_L3_error)
        }
        case  2:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_DL);
          if (value) { values[2] = value; kw_args--; }
        }
        case  3:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_margin);
          if (value) { values[3] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "_Ves_mesh_dlfromL_cython") < 0)) __PYX_ERR(0, 14, __pyx_L3_error)
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    __pyx_v_LMinMax = __Pyx_PyObject_to_MemoryviewSlice_dc_double(values[0]); if (unlikely(!__pyx_v_LMinMax.memview)) __PYX_ERR(0, 14, __pyx_L3_error)
    __pyx_v_dL = __pyx_PyFloat_AsDouble(values[1]); if (unlikely((__pyx_v_dL == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 14, __pyx_L3_error)
    __pyx_v_DL = values[2];
    if (values[3]) {
      __pyx_v_margin = __pyx_PyFloat_AsDouble(values[3]); if (unlikely((__pyx_v_margin == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 14, __pyx_L3_error)
    } else {
      __pyx_v_margin = ((double)1.e-9);
    }
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("_Ves_mesh_dlfromL_cython", 0, 2, 4, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 14, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("_cython_magic_ffb7650808bb7830760fff8d6d047f13._Ves_mesh_dlfromL_cython", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_46_cython_magic_ffb7650808bb7830760fff8d6d047f13__Ves_mesh_dlfromL_cython(__pyx_self, __pyx_v_LMinMax, __pyx_v_dL, __pyx_v_DL, __pyx_v_margin);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_46_cython_magic_ffb7650808bb7830760fff8d6d047f13__Ves_mesh_dlfromL_cython(CYTHON_UNUSED PyObject *__pyx_self, __Pyx_memviewslice __pyx_v_LMinMax, double __pyx_v_dL, PyObject *__pyx_v_DL, double __pyx_v_margin) {
  double __pyx_v_N;
  double __pyx_v_dLr;
  __Pyx_memviewslice __pyx_v_DLc = { 0, 0, { 0 }, { 0 }, { 0 } };
  __Pyx_memviewslice __pyx_v_L = { 0, 0, { 0 }, { 0 }, { 0 } };
  __Pyx_memviewslice __pyx_v_indL = { 0, 0, { 0 }, { 0 }, { 0 } };
  double __pyx_v_abs0;
  double __pyx_v_abs1;
  int __pyx_v_nL0;
  int __pyx_v_nL1;
  int __pyx_v_Nind;
  int __pyx_v_ii;
  int __pyx_v_jj;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("_Ves_mesh_dlfromL_cython", 0);
/* … */
  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_XDECREF(__pyx_t_10);
  __Pyx_XDECREF(__pyx_t_11);
  __Pyx_XDECREF(__pyx_t_12);
  __PYX_XDEC_MEMVIEW(&__pyx_t_13, 1);
  __PYX_XDEC_MEMVIEW(&__pyx_t_26, 1);
  __Pyx_XDECREF(__pyx_t_27);
  __Pyx_XDECREF(__pyx_t_33);
  __Pyx_XDECREF(__pyx_t_34);
  __Pyx_AddTraceback("_cython_magic_ffb7650808bb7830760fff8d6d047f13._Ves_mesh_dlfromL_cython", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __PYX_XDEC_MEMVIEW(&__pyx_v_DLc, 1);
  __PYX_XDEC_MEMVIEW(&__pyx_v_L, 1);
  __PYX_XDEC_MEMVIEW(&__pyx_v_indL, 1);
  __PYX_XDEC_MEMVIEW(&__pyx_v_LMinMax, 1);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}
/* … */
  __pyx_tuple__23 = PyTuple_Pack(17, __pyx_n_s_LMinMax, __pyx_n_s_dL, __pyx_n_s_DL, __pyx_n_s_margin, __pyx_n_s_N, __pyx_n_s_dLr, __pyx_n_s_DLc, __pyx_n_s_L, __pyx_n_s_indL, __pyx_n_s_abs0, __pyx_n_s_abs1, __pyx_n_s_A, __pyx_n_s_nL0, __pyx_n_s_nL1, __pyx_n_s_Nind, __pyx_n_s_ii, __pyx_n_s_jj); if (unlikely(!__pyx_tuple__23)) __PYX_ERR(0, 14, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__23);
  __Pyx_GIVEREF(__pyx_tuple__23);
/* … */
  __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_46_cython_magic_ffb7650808bb7830760fff8d6d047f13_1_Ves_mesh_dlfromL_cython, NULL, __pyx_n_s_cython_magic_ffb7650808bb783076); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 14, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_Ves_mesh_dlfromL_cython, __pyx_t_1) < 0) __PYX_ERR(0, 14, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_codeobj__24 = (PyObject*)__Pyx_PyCode_New(4, 0, 17, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__23, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_Home_DV226270_cache_ipython_cyt, __pyx_n_s_Ves_mesh_dlfromL_cython, 14, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__24)) __PYX_ERR(0, 14, __pyx_L1_error)
 015:     """ Get the actual reolution from the desired resolution and MinMax and limits """
 016:     # Get the number of mesh elements in LMinMax
+017:     cdef double N = Cceil((LMinMax[1]-LMinMax[0])/dL)
  __pyx_t_1 = 1;
  __pyx_t_2 = 0;
  __pyx_v_N = ceil((((*((double *) ( /* dim=0 */ ((char *) (((double *) __pyx_v_LMinMax.data) + __pyx_t_1)) ))) - (*((double *) ( /* dim=0 */ ((char *) (((double *) __pyx_v_LMinMax.data) + __pyx_t_2)) )))) / __pyx_v_dL));
 018:     # Derive the real (effective) resolution
+019:     cdef double dLr = (LMinMax[1]-LMinMax[0])/N
  __pyx_t_3 = 1;
  __pyx_t_4 = 0;
  __pyx_v_dLr = (((*((double *) ( /* dim=0 */ ((char *) (((double *) __pyx_v_LMinMax.data) + __pyx_t_3)) ))) - (*((double *) ( /* dim=0 */ ((char *) (((double *) __pyx_v_LMinMax.data) + __pyx_t_4)) )))) / __pyx_v_N);
 020:     # Get desired limits if any
 021:     cdef double[::1] DLc, L
 022:     cdef long [::1] indL
 023:     #cdef cnp.ndarray[double,ndim=1] indL, L
 024:     cdef double abs0, abs1, A
 025:     cdef int nL0, nL1, Nind, ii, jj
+026:     if DL is None:
  __pyx_t_5 = (__pyx_v_DL == Py_None);
  __pyx_t_6 = (__pyx_t_5 != 0);
  if (__pyx_t_6) {
/* … */
    goto __pyx_L3;
  }
+027:         DLc = LMinMax
    __PYX_INC_MEMVIEW(&__pyx_v_LMinMax, 0);
    __pyx_v_DLc = __pyx_v_LMinMax;
 028:     else:
+029:         if DL[0] is None:
  /*else*/ {
    __pyx_t_7 = __Pyx_GetItemInt(__pyx_v_DL, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 0); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 29, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    __pyx_t_6 = (__pyx_t_7 == Py_None);
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    __pyx_t_5 = (__pyx_t_6 != 0);
    if (__pyx_t_5) {
/* … */
    }
+030:             DL[0] = LMinMax[0]
      __pyx_t_8 = 0;
      __pyx_t_7 = PyFloat_FromDouble((*((double *) ( /* dim=0 */ ((char *) (((double *) __pyx_v_LMinMax.data) + __pyx_t_8)) )))); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 30, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_7);
      if (unlikely(__Pyx_SetItemInt(__pyx_v_DL, 0, __pyx_t_7, long, 1, __Pyx_PyInt_From_long, 0, 0, 0) < 0)) __PYX_ERR(0, 30, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
+031:         if DL[1] is None:
    __pyx_t_7 = __Pyx_GetItemInt(__pyx_v_DL, 1, long, 1, __Pyx_PyInt_From_long, 0, 0, 0); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 31, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    __pyx_t_5 = (__pyx_t_7 == Py_None);
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    __pyx_t_6 = (__pyx_t_5 != 0);
    if (__pyx_t_6) {
/* … */
    }
+032:             DL[1] = LMinMax[1]
      __pyx_t_9 = 1;
      __pyx_t_7 = PyFloat_FromDouble((*((double *) ( /* dim=0 */ ((char *) (((double *) __pyx_v_LMinMax.data) + __pyx_t_9)) )))); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 32, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_7);
      if (unlikely(__Pyx_SetItemInt(__pyx_v_DL, 1, __pyx_t_7, long, 1, __Pyx_PyInt_From_long, 0, 0, 0) < 0)) __PYX_ERR(0, 32, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
+033:         DLc = np.array(DL)
    __pyx_t_10 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 33, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_10);
    __pyx_t_11 = __Pyx_PyObject_GetAttrStr(__pyx_t_10, __pyx_n_s_array); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 33, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_11);
    __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
    __pyx_t_10 = NULL;
    if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_11))) {
      __pyx_t_10 = PyMethod_GET_SELF(__pyx_t_11);
      if (likely(__pyx_t_10)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_11);
        __Pyx_INCREF(__pyx_t_10);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_11, function);
      }
    }
    if (!__pyx_t_10) {
      __pyx_t_7 = __Pyx_PyObject_CallOneArg(__pyx_t_11, __pyx_v_DL); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 33, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_7);
    } else {
      #if CYTHON_FAST_PYCALL
      if (PyFunction_Check(__pyx_t_11)) {
        PyObject *__pyx_temp[2] = {__pyx_t_10, __pyx_v_DL};
        __pyx_t_7 = __Pyx_PyFunction_FastCall(__pyx_t_11, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 33, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
        __Pyx_GOTREF(__pyx_t_7);
      } else
      #endif
      #if CYTHON_FAST_PYCCALL
      if (__Pyx_PyFastCFunction_Check(__pyx_t_11)) {
        PyObject *__pyx_temp[2] = {__pyx_t_10, __pyx_v_DL};
        __pyx_t_7 = __Pyx_PyCFunction_FastCall(__pyx_t_11, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 33, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
        __Pyx_GOTREF(__pyx_t_7);
      } else
      #endif
      {
        __pyx_t_12 = PyTuple_New(1+1); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 33, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_12);
        __Pyx_GIVEREF(__pyx_t_10); PyTuple_SET_ITEM(__pyx_t_12, 0, __pyx_t_10); __pyx_t_10 = NULL;
        __Pyx_INCREF(__pyx_v_DL);
        __Pyx_GIVEREF(__pyx_v_DL);
        PyTuple_SET_ITEM(__pyx_t_12, 0+1, __pyx_v_DL);
        __pyx_t_7 = __Pyx_PyObject_Call(__pyx_t_11, __pyx_t_12, NULL); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 33, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_7);
        __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
      }
    }
    __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
    __pyx_t_13 = __Pyx_PyObject_to_MemoryviewSlice_dc_double(__pyx_t_7);
    if (unlikely(!__pyx_t_13.memview)) __PYX_ERR(0, 33, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    __pyx_v_DLc = __pyx_t_13;
    __pyx_t_13.memview = NULL;
    __pyx_t_13.data = NULL;
  }
  __pyx_L3:;
 034: 
 035:     # Get the extreme indices of the mesh elements that really need to be created within those limits
+036:     abs0 = Cabs(DLc[0]-LMinMax[0])
  __pyx_t_14 = 0;
  __pyx_t_15 = 0;
  __pyx_v_abs0 = fabs(((*((double *) ( /* dim=0 */ ((char *) (((double *) __pyx_v_DLc.data) + __pyx_t_14)) ))) - (*((double *) ( /* dim=0 */ ((char *) (((double *) __pyx_v_LMinMax.data) + __pyx_t_15)) )))));
+037:     if abs0-dLr*Cfloor(abs0/dLr)<margin*dLr:
  __pyx_t_6 = (((__pyx_v_abs0 - (__pyx_v_dLr * floor((__pyx_v_abs0 / __pyx_v_dLr)))) < (__pyx_v_margin * __pyx_v_dLr)) != 0);
  if (__pyx_t_6) {
/* … */
    goto __pyx_L6;
  }
+038:         nL0 = int(Cround((DLc[0]-LMinMax[0])/dLr))
    __pyx_t_16 = 0;
    __pyx_t_17 = 0;
    __pyx_v_nL0 = ((int)round((((*((double *) ( /* dim=0 */ ((char *) (((double *) __pyx_v_DLc.data) + __pyx_t_16)) ))) - (*((double *) ( /* dim=0 */ ((char *) (((double *) __pyx_v_LMinMax.data) + __pyx_t_17)) )))) / __pyx_v_dLr)));
 039:     else:
+040:         nL0 = int(Cfloor((DLc[0]-LMinMax[0])/dLr))
  /*else*/ {
    __pyx_t_18 = 0;
    __pyx_t_19 = 0;
    __pyx_v_nL0 = ((int)floor((((*((double *) ( /* dim=0 */ ((char *) (((double *) __pyx_v_DLc.data) + __pyx_t_18)) ))) - (*((double *) ( /* dim=0 */ ((char *) (((double *) __pyx_v_LMinMax.data) + __pyx_t_19)) )))) / __pyx_v_dLr)));
  }
  __pyx_L6:;
+041:     abs1 = Cabs(DLc[1]-LMinMax[0])
  __pyx_t_20 = 1;
  __pyx_t_21 = 0;
  __pyx_v_abs1 = fabs(((*((double *) ( /* dim=0 */ ((char *) (((double *) __pyx_v_DLc.data) + __pyx_t_20)) ))) - (*((double *) ( /* dim=0 */ ((char *) (((double *) __pyx_v_LMinMax.data) + __pyx_t_21)) )))));
+042:     if abs1-dLr*Cfloor(abs1/dLr)<margin*dLr:
  __pyx_t_6 = (((__pyx_v_abs1 - (__pyx_v_dLr * floor((__pyx_v_abs1 / __pyx_v_dLr)))) < (__pyx_v_margin * __pyx_v_dLr)) != 0);
  if (__pyx_t_6) {
/* … */
    goto __pyx_L7;
  }
+043:         nL1 = int(Cround((DLc[1]-LMinMax[0])/dLr)-1)
    __pyx_t_22 = 1;
    __pyx_t_23 = 0;
    __pyx_v_nL1 = ((int)(round((((*((double *) ( /* dim=0 */ ((char *) (((double *) __pyx_v_DLc.data) + __pyx_t_22)) ))) - (*((double *) ( /* dim=0 */ ((char *) (((double *) __pyx_v_LMinMax.data) + __pyx_t_23)) )))) / __pyx_v_dLr)) - 1.0));
 044:     else:
+045:         nL1 = int(Cfloor((DLc[1]-LMinMax[0])/dLr))
  /*else*/ {
    __pyx_t_24 = 1;
    __pyx_t_25 = 0;
    __pyx_v_nL1 = ((int)floor((((*((double *) ( /* dim=0 */ ((char *) (((double *) __pyx_v_DLc.data) + __pyx_t_24)) ))) - (*((double *) ( /* dim=0 */ ((char *) (((double *) __pyx_v_LMinMax.data) + __pyx_t_25)) )))) / __pyx_v_dLr)));
  }
  __pyx_L7:;
 046:     # Get the corresponding indices
+047:     Nind = nL1+1-nL0
  __pyx_v_Nind = ((__pyx_v_nL1 + 1) - __pyx_v_nL0);
+048:     indL = np.empty((Nind,),dtype=int)#np.linspace(nL0,nL1,Nind,endpoint=True)
  __pyx_t_7 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 48, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  __pyx_t_11 = __Pyx_PyObject_GetAttrStr(__pyx_t_7, __pyx_n_s_empty); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 48, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_11);
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  __pyx_t_7 = __Pyx_PyInt_From_int(__pyx_v_Nind); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 48, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  __pyx_t_12 = PyTuple_New(1); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 48, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_12);
  __Pyx_GIVEREF(__pyx_t_7);
  PyTuple_SET_ITEM(__pyx_t_12, 0, __pyx_t_7);
  __pyx_t_7 = 0;
  __pyx_t_7 = PyTuple_New(1); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 48, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  __Pyx_GIVEREF(__pyx_t_12);
  PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_12);
  __pyx_t_12 = 0;
  __pyx_t_12 = PyDict_New(); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 48, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_12);
  if (PyDict_SetItem(__pyx_t_12, __pyx_n_s_dtype, ((PyObject *)(&PyInt_Type))) < 0) __PYX_ERR(0, 48, __pyx_L1_error)
  __pyx_t_10 = __Pyx_PyObject_Call(__pyx_t_11, __pyx_t_7, __pyx_t_12); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 48, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_10);
  __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
  __pyx_t_26 = __Pyx_PyObject_to_MemoryviewSlice_dc_long(__pyx_t_10);
  if (unlikely(!__pyx_t_26.memview)) __PYX_ERR(0, 48, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
  __pyx_v_indL = __pyx_t_26;
  __pyx_t_26.memview = NULL;
  __pyx_t_26.data = NULL;
+049:     L = np.empty((Nind,))
  __pyx_t_12 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 49, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_12);
  __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_t_12, __pyx_n_s_empty); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 49, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
  __pyx_t_12 = __Pyx_PyInt_From_int(__pyx_v_Nind); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 49, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_12);
  __pyx_t_11 = PyTuple_New(1); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 49, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_11);
  __Pyx_GIVEREF(__pyx_t_12);
  PyTuple_SET_ITEM(__pyx_t_11, 0, __pyx_t_12);
  __pyx_t_12 = 0;
  __pyx_t_12 = NULL;
  if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_7))) {
    __pyx_t_12 = PyMethod_GET_SELF(__pyx_t_7);
    if (likely(__pyx_t_12)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_7);
      __Pyx_INCREF(__pyx_t_12);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_7, function);
    }
  }
  if (!__pyx_t_12) {
    __pyx_t_10 = __Pyx_PyObject_CallOneArg(__pyx_t_7, __pyx_t_11); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 49, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
    __Pyx_GOTREF(__pyx_t_10);
  } else {
    #if CYTHON_FAST_PYCALL
    if (PyFunction_Check(__pyx_t_7)) {
      PyObject *__pyx_temp[2] = {__pyx_t_12, __pyx_t_11};
      __pyx_t_10 = __Pyx_PyFunction_FastCall(__pyx_t_7, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 49, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0;
      __Pyx_GOTREF(__pyx_t_10);
      __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
    } else
    #endif
    #if CYTHON_FAST_PYCCALL
    if (__Pyx_PyFastCFunction_Check(__pyx_t_7)) {
      PyObject *__pyx_temp[2] = {__pyx_t_12, __pyx_t_11};
      __pyx_t_10 = __Pyx_PyCFunction_FastCall(__pyx_t_7, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 49, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0;
      __Pyx_GOTREF(__pyx_t_10);
      __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
    } else
    #endif
    {
      __pyx_t_27 = PyTuple_New(1+1); if (unlikely(!__pyx_t_27)) __PYX_ERR(0, 49, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_27);
      __Pyx_GIVEREF(__pyx_t_12); PyTuple_SET_ITEM(__pyx_t_27, 0, __pyx_t_12); __pyx_t_12 = NULL;
      __Pyx_GIVEREF(__pyx_t_11);
      PyTuple_SET_ITEM(__pyx_t_27, 0+1, __pyx_t_11);
      __pyx_t_11 = 0;
      __pyx_t_10 = __Pyx_PyObject_Call(__pyx_t_7, __pyx_t_27, NULL); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 49, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_10);
      __Pyx_DECREF(__pyx_t_27); __pyx_t_27 = 0;
    }
  }
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  __pyx_t_13 = __Pyx_PyObject_to_MemoryviewSlice_dc_double(__pyx_t_10);
  if (unlikely(!__pyx_t_13.memview)) __PYX_ERR(0, 49, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
  __pyx_v_L = __pyx_t_13;
  __pyx_t_13.memview = NULL;
  __pyx_t_13.data = NULL;
+050:     for ii in range(0,Nind):
  __pyx_t_28 = __pyx_v_Nind;
  for (__pyx_t_29 = 0; __pyx_t_29 < __pyx_t_28; __pyx_t_29+=1) {
    __pyx_v_ii = __pyx_t_29;
+051:         jj = nL0+ii
    __pyx_v_jj = (__pyx_v_nL0 + __pyx_v_ii);
+052:         indL[ii] = jj
    __pyx_t_30 = __pyx_v_ii;
    *((long *) ( /* dim=0 */ ((char *) (((long *) __pyx_v_indL.data) + __pyx_t_30)) )) = __pyx_v_jj;
+053:         L[ii] = LMinMax[0] + (0.5 + (<double>jj))*dLr
    __pyx_t_31 = 0;
    __pyx_t_32 = __pyx_v_ii;
    *((double *) ( /* dim=0 */ ((char *) (((double *) __pyx_v_L.data) + __pyx_t_32)) )) = ((*((double *) ( /* dim=0 */ ((char *) (((double *) __pyx_v_LMinMax.data) + __pyx_t_31)) ))) + ((0.5 + ((double)__pyx_v_jj)) * __pyx_v_dLr));
  }
+054:     return np.asarray(L), dLr, np.asarray(indL), N
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_7 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 54, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  __pyx_t_27 = __Pyx_PyObject_GetAttrStr(__pyx_t_7, __pyx_n_s_asarray); if (unlikely(!__pyx_t_27)) __PYX_ERR(0, 54, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_27);
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  __pyx_t_7 = __pyx_memoryview_fromslice(__pyx_v_L, 1, (PyObject *(*)(char *)) __pyx_memview_get_double, (int (*)(char *, PyObject *)) __pyx_memview_set_double, 0);; if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 54, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  __pyx_t_11 = NULL;
  if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_27))) {
    __pyx_t_11 = PyMethod_GET_SELF(__pyx_t_27);
    if (likely(__pyx_t_11)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_27);
      __Pyx_INCREF(__pyx_t_11);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_27, function);
    }
  }
  if (!__pyx_t_11) {
    __pyx_t_10 = __Pyx_PyObject_CallOneArg(__pyx_t_27, __pyx_t_7); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 54, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    __Pyx_GOTREF(__pyx_t_10);
  } else {
    #if CYTHON_FAST_PYCALL
    if (PyFunction_Check(__pyx_t_27)) {
      PyObject *__pyx_temp[2] = {__pyx_t_11, __pyx_t_7};
      __pyx_t_10 = __Pyx_PyFunction_FastCall(__pyx_t_27, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 54, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0;
      __Pyx_GOTREF(__pyx_t_10);
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    } else
    #endif
    #if CYTHON_FAST_PYCCALL
    if (__Pyx_PyFastCFunction_Check(__pyx_t_27)) {
      PyObject *__pyx_temp[2] = {__pyx_t_11, __pyx_t_7};
      __pyx_t_10 = __Pyx_PyCFunction_FastCall(__pyx_t_27, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 54, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0;
      __Pyx_GOTREF(__pyx_t_10);
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    } else
    #endif
    {
      __pyx_t_12 = PyTuple_New(1+1); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 54, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_12);
      __Pyx_GIVEREF(__pyx_t_11); PyTuple_SET_ITEM(__pyx_t_12, 0, __pyx_t_11); __pyx_t_11 = NULL;
      __Pyx_GIVEREF(__pyx_t_7);
      PyTuple_SET_ITEM(__pyx_t_12, 0+1, __pyx_t_7);
      __pyx_t_7 = 0;
      __pyx_t_10 = __Pyx_PyObject_Call(__pyx_t_27, __pyx_t_12, NULL); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 54, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_10);
      __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
    }
  }
  __Pyx_DECREF(__pyx_t_27); __pyx_t_27 = 0;
  __pyx_t_27 = PyFloat_FromDouble(__pyx_v_dLr); if (unlikely(!__pyx_t_27)) __PYX_ERR(0, 54, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_27);
  __pyx_t_7 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 54, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  __pyx_t_11 = __Pyx_PyObject_GetAttrStr(__pyx_t_7, __pyx_n_s_asarray); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 54, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_11);
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  __pyx_t_7 = __pyx_memoryview_fromslice(__pyx_v_indL, 1, (PyObject *(*)(char *)) __pyx_memview_get_long, (int (*)(char *, PyObject *)) __pyx_memview_set_long, 0);; if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 54, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  __pyx_t_33 = NULL;
  if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_11))) {
    __pyx_t_33 = PyMethod_GET_SELF(__pyx_t_11);
    if (likely(__pyx_t_33)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_11);
      __Pyx_INCREF(__pyx_t_33);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_11, function);
    }
  }
  if (!__pyx_t_33) {
    __pyx_t_12 = __Pyx_PyObject_CallOneArg(__pyx_t_11, __pyx_t_7); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 54, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    __Pyx_GOTREF(__pyx_t_12);
  } else {
    #if CYTHON_FAST_PYCALL
    if (PyFunction_Check(__pyx_t_11)) {
      PyObject *__pyx_temp[2] = {__pyx_t_33, __pyx_t_7};
      __pyx_t_12 = __Pyx_PyFunction_FastCall(__pyx_t_11, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 54, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_33); __pyx_t_33 = 0;
      __Pyx_GOTREF(__pyx_t_12);
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    } else
    #endif
    #if CYTHON_FAST_PYCCALL
    if (__Pyx_PyFastCFunction_Check(__pyx_t_11)) {
      PyObject *__pyx_temp[2] = {__pyx_t_33, __pyx_t_7};
      __pyx_t_12 = __Pyx_PyCFunction_FastCall(__pyx_t_11, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 54, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_33); __pyx_t_33 = 0;
      __Pyx_GOTREF(__pyx_t_12);
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    } else
    #endif
    {
      __pyx_t_34 = PyTuple_New(1+1); if (unlikely(!__pyx_t_34)) __PYX_ERR(0, 54, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_34);
      __Pyx_GIVEREF(__pyx_t_33); PyTuple_SET_ITEM(__pyx_t_34, 0, __pyx_t_33); __pyx_t_33 = NULL;
      __Pyx_GIVEREF(__pyx_t_7);
      PyTuple_SET_ITEM(__pyx_t_34, 0+1, __pyx_t_7);
      __pyx_t_7 = 0;
      __pyx_t_12 = __Pyx_PyObject_Call(__pyx_t_11, __pyx_t_34, NULL); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 54, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_12);
      __Pyx_DECREF(__pyx_t_34); __pyx_t_34 = 0;
    }
  }
  __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
  __pyx_t_11 = PyFloat_FromDouble(__pyx_v_N); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 54, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_11);
  __pyx_t_34 = PyTuple_New(4); if (unlikely(!__pyx_t_34)) __PYX_ERR(0, 54, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_34);
  __Pyx_GIVEREF(__pyx_t_10);
  PyTuple_SET_ITEM(__pyx_t_34, 0, __pyx_t_10);
  __Pyx_GIVEREF(__pyx_t_27);
  PyTuple_SET_ITEM(__pyx_t_34, 1, __pyx_t_27);
  __Pyx_GIVEREF(__pyx_t_12);
  PyTuple_SET_ITEM(__pyx_t_34, 2, __pyx_t_12);
  __Pyx_GIVEREF(__pyx_t_11);
  PyTuple_SET_ITEM(__pyx_t_34, 3, __pyx_t_11);
  __pyx_t_10 = 0;
  __pyx_t_27 = 0;
  __pyx_t_12 = 0;
  __pyx_t_11 = 0;
  __pyx_r = __pyx_t_34;
  __pyx_t_34 = 0;
  goto __pyx_L0;
 055: 
 056: @cython.cdivision(True)
 057: @cython.wraparound(False)
 058: @cython.boundscheck(False)
+059: def _Ves_Vmesh_Tor_SubFromD_cython(double dR, double dZ, double dRPhi,
/* Python wrapper */
static PyObject *__pyx_pw_46_cython_magic_ffb7650808bb7830760fff8d6d047f13_3_Ves_Vmesh_Tor_SubFromD_cython(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_46_cython_magic_ffb7650808bb7830760fff8d6d047f13_2_Ves_Vmesh_Tor_SubFromD_cython[] = " Return the desired submesh indicated by the limits (DR,DZ,DPhi), for the desired resolution (dR,dZ,dRphi) ";
static PyMethodDef __pyx_mdef_46_cython_magic_ffb7650808bb7830760fff8d6d047f13_3_Ves_Vmesh_Tor_SubFromD_cython = {"_Ves_Vmesh_Tor_SubFromD_cython", (PyCFunction)__pyx_pw_46_cython_magic_ffb7650808bb7830760fff8d6d047f13_3_Ves_Vmesh_Tor_SubFromD_cython, METH_VARARGS|METH_KEYWORDS, __pyx_doc_46_cython_magic_ffb7650808bb7830760fff8d6d047f13_2_Ves_Vmesh_Tor_SubFromD_cython};
static PyObject *__pyx_pw_46_cython_magic_ffb7650808bb7830760fff8d6d047f13_3_Ves_Vmesh_Tor_SubFromD_cython(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  double __pyx_v_dR;
  double __pyx_v_dZ;
  double __pyx_v_dRPhi;
  __Pyx_memviewslice __pyx_v_RMinMax = { 0, 0, { 0 }, { 0 }, { 0 } };
  __Pyx_memviewslice __pyx_v_ZMinMax = { 0, 0, { 0 }, { 0 }, { 0 } };
  PyObject *__pyx_v_DR = 0;
  PyObject *__pyx_v_DZ = 0;
  PyObject *__pyx_v_DPhi = 0;
  CYTHON_UNUSED PyObject *__pyx_v_VPoly = 0;
  PyObject *__pyx_v_Out = 0;
  double __pyx_v_margin;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("_Ves_Vmesh_Tor_SubFromD_cython (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_dR,&__pyx_n_s_dZ,&__pyx_n_s_dRPhi,&__pyx_n_s_RMinMax,&__pyx_n_s_ZMinMax,&__pyx_n_s_DR,&__pyx_n_s_DZ,&__pyx_n_s_DPhi,&__pyx_n_s_VPoly,&__pyx_n_s_Out,&__pyx_n_s_margin,0};
    PyObject* values[11] = {0,0,0,0,0,0,0,0,0,0,0};
/* … */
  /* function exit code */
  goto __pyx_L0;
  __pyx_L1_error:;
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_46_cython_magic_ffb7650808bb7830760fff8d6d047f13_2_Ves_Vmesh_Tor_SubFromD_cython(CYTHON_UNUSED PyObject *__pyx_self, double __pyx_v_dR, double __pyx_v_dZ, double __pyx_v_dRPhi, __Pyx_memviewslice __pyx_v_RMinMax, __Pyx_memviewslice __pyx_v_ZMinMax, PyObject *__pyx_v_DR, PyObject *__pyx_v_DZ, PyObject *__pyx_v_DPhi, CYTHON_UNUSED PyObject *__pyx_v_VPoly, PyObject *__pyx_v_Out, double __pyx_v_margin) {
  __Pyx_memviewslice __pyx_v_R0 = { 0, 0, { 0 }, { 0 }, { 0 } };
  __Pyx_memviewslice __pyx_v_R = { 0, 0, { 0 }, { 0 }, { 0 } };
  __Pyx_memviewslice __pyx_v_Z = { 0, 0, { 0 }, { 0 }, { 0 } };
  __Pyx_memviewslice __pyx_v_dRPhir = { 0, 0, { 0 }, { 0 }, { 0 } };
  __Pyx_memviewslice __pyx_v_dPhir = { 0, 0, { 0 }, { 0 }, { 0 } };
  __Pyx_memviewslice __pyx_v_NRPhi = { 0, 0, { 0 }, { 0 }, { 0 } };
  CYTHON_UNUSED double __pyx_v_dRr0;
  double __pyx_v_dRr;
  double __pyx_v_dZr;
  double __pyx_v_DPhi0;
  double __pyx_v_DPhi1;
  double __pyx_v_abs0;
  double __pyx_v_abs1;
  double __pyx_v_phi;
  double __pyx_v_indiijj;
  CYTHON_UNUSED __Pyx_memviewslice __pyx_v_indR0 = { 0, 0, { 0 }, { 0 }, { 0 } };
  CYTHON_UNUSED __Pyx_memviewslice __pyx_v_indR = { 0, 0, { 0 }, { 0 }, { 0 } };
  __Pyx_memviewslice __pyx_v_indZ = { 0, 0, { 0 }, { 0 }, { 0 } };
  __Pyx_memviewslice __pyx_v_Phin = { 0, 0, { 0 }, { 0 }, { 0 } };
  __Pyx_memviewslice __pyx_v_NRPhi0 = { 0, 0, { 0 }, { 0 }, { 0 } };
  int __pyx_v_NR0;
  CYTHON_UNUSED int __pyx_v_NR;
  int __pyx_v_NZ;
  int __pyx_v_Rn;
  int __pyx_v_Zn;
  int __pyx_v_nRPhi0;
  int __pyx_v_indR0ii;
  int __pyx_v_ii;
  int __pyx_v_jj;
  int __pyx_v_nPhi0;
  int __pyx_v_nPhi1;
  int __pyx_v_zz;
  int __pyx_v_NP;
  int __pyx_v_NRPhi_int;
  int __pyx_v_Rratio;
  PyArrayObject *__pyx_v_Pts = 0;
  PyArrayObject *__pyx_v_indI = 0;
  PyArrayObject *__pyx_v_dV = 0;
  PyArrayObject *__pyx_v_ind = 0;
  CYTHON_UNUSED long __pyx_v_NPhimax;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_Pts;
  __Pyx_Buffer __pyx_pybuffer_Pts;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_dV;
  __Pyx_Buffer __pyx_pybuffer_dV;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_ind;
  __Pyx_Buffer __pyx_pybuffer_ind;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_indI;
  __Pyx_Buffer __pyx_pybuffer_indI;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("_Ves_Vmesh_Tor_SubFromD_cython", 0);
  __pyx_pybuffer_Pts.pybuffer.buf = NULL;
  __pyx_pybuffer_Pts.refcount = 0;
  __pyx_pybuffernd_Pts.data = NULL;
  __pyx_pybuffernd_Pts.rcbuffer = &__pyx_pybuffer_Pts;
  __pyx_pybuffer_indI.pybuffer.buf = NULL;
  __pyx_pybuffer_indI.refcount = 0;
  __pyx_pybuffernd_indI.data = NULL;
  __pyx_pybuffernd_indI.rcbuffer = &__pyx_pybuffer_indI;
  __pyx_pybuffer_dV.pybuffer.buf = NULL;
  __pyx_pybuffer_dV.refcount = 0;
  __pyx_pybuffernd_dV.data = NULL;
  __pyx_pybuffernd_dV.rcbuffer = &__pyx_pybuffer_dV;
  __pyx_pybuffer_ind.pybuffer.buf = NULL;
  __pyx_pybuffer_ind.refcount = 0;
  __pyx_pybuffernd_ind.data = NULL;
  __pyx_pybuffernd_ind.rcbuffer = &__pyx_pybuffer_ind;
/* … */
  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __PYX_XDEC_MEMVIEW(&__pyx_t_8, 1);
  __PYX_XDEC_MEMVIEW(&__pyx_t_10, 1);
  __PYX_XDEC_MEMVIEW(&__pyx_t_18, 1);
  __Pyx_XDECREF(__pyx_t_103);
  __Pyx_XDECREF(__pyx_t_104);
  { PyObject *__pyx_type, *__pyx_value, *__pyx_tb;
    __Pyx_PyThreadState_declare
    __Pyx_PyThreadState_assign
    __Pyx_ErrFetch(&__pyx_type, &__pyx_value, &__pyx_tb);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_Pts.rcbuffer->pybuffer);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_dV.rcbuffer->pybuffer);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_ind.rcbuffer->pybuffer);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_indI.rcbuffer->pybuffer);
  __Pyx_ErrRestore(__pyx_type, __pyx_value, __pyx_tb);}
  __Pyx_AddTraceback("_cython_magic_ffb7650808bb7830760fff8d6d047f13._Ves_Vmesh_Tor_SubFromD_cython", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  goto __pyx_L2;
  __pyx_L0:;
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_Pts.rcbuffer->pybuffer);
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_dV.rcbuffer->pybuffer);
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_ind.rcbuffer->pybuffer);
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_indI.rcbuffer->pybuffer);
  __pyx_L2:;
  __PYX_XDEC_MEMVIEW(&__pyx_v_R0, 1);
  __PYX_XDEC_MEMVIEW(&__pyx_v_R, 1);
  __PYX_XDEC_MEMVIEW(&__pyx_v_Z, 1);
  __PYX_XDEC_MEMVIEW(&__pyx_v_dRPhir, 1);
  __PYX_XDEC_MEMVIEW(&__pyx_v_dPhir, 1);
  __PYX_XDEC_MEMVIEW(&__pyx_v_NRPhi, 1);
  __PYX_XDEC_MEMVIEW(&__pyx_v_indR0, 1);
  __PYX_XDEC_MEMVIEW(&__pyx_v_indR, 1);
  __PYX_XDEC_MEMVIEW(&__pyx_v_indZ, 1);
  __PYX_XDEC_MEMVIEW(&__pyx_v_Phin, 1);
  __PYX_XDEC_MEMVIEW(&__pyx_v_NRPhi0, 1);
  __Pyx_XDECREF((PyObject *)__pyx_v_Pts);
  __Pyx_XDECREF((PyObject *)__pyx_v_indI);
  __Pyx_XDECREF((PyObject *)__pyx_v_dV);
  __Pyx_XDECREF((PyObject *)__pyx_v_ind);
  __PYX_XDEC_MEMVIEW(&__pyx_v_RMinMax, 1);
  __PYX_XDEC_MEMVIEW(&__pyx_v_ZMinMax, 1);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}
/* … */
  __pyx_tuple__25 = PyTuple_Pack(51, __pyx_n_s_dR, __pyx_n_s_dZ, __pyx_n_s_dRPhi, __pyx_n_s_RMinMax, __pyx_n_s_ZMinMax, __pyx_n_s_DR, __pyx_n_s_DZ, __pyx_n_s_DPhi, __pyx_n_s_VPoly, __pyx_n_s_Out, __pyx_n_s_margin, __pyx_n_s_R0, __pyx_n_s_R, __pyx_n_s_Z, __pyx_n_s_dRPhir, __pyx_n_s_dPhir, __pyx_n_s_NRPhi, __pyx_n_s_dRr0, __pyx_n_s_dRr, __pyx_n_s_dZr, __pyx_n_s_DPhi0, __pyx_n_s_DPhi1, __pyx_n_s_abs0, __pyx_n_s_abs1, __pyx_n_s_phi, __pyx_n_s_indiijj, __pyx_n_s_indR0, __pyx_n_s_indR, __pyx_n_s_indZ, __pyx_n_s_Phin, __pyx_n_s_NRPhi0, __pyx_n_s_NR0, __pyx_n_s_NR, __pyx_n_s_NZ, __pyx_n_s_Rn, __pyx_n_s_Zn, __pyx_n_s_nRPhi0, __pyx_n_s_indR0ii, __pyx_n_s_ii, __pyx_n_s_jj, __pyx_n_s_nPhi0, __pyx_n_s_nPhi1, __pyx_n_s_zz, __pyx_n_s_NP, __pyx_n_s_NRPhi_int, __pyx_n_s_Rratio, __pyx_n_s_Pts, __pyx_n_s_indI, __pyx_n_s_dV, __pyx_n_s_ind, __pyx_n_s_NPhimax); if (unlikely(!__pyx_tuple__25)) __PYX_ERR(0, 59, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__25);
  __Pyx_GIVEREF(__pyx_tuple__25);
/* … */
  __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_46_cython_magic_ffb7650808bb7830760fff8d6d047f13_3_Ves_Vmesh_Tor_SubFromD_cython, NULL, __pyx_n_s_cython_magic_ffb7650808bb783076); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 59, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_Ves_Vmesh_Tor_SubFromD_cython, __pyx_t_1) < 0) __PYX_ERR(0, 59, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_codeobj__26 = (PyObject*)__Pyx_PyCode_New(11, 0, 51, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__25, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_Home_DV226270_cache_ipython_cyt, __pyx_n_s_Ves_Vmesh_Tor_SubFromD_cython, 59, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__26)) __PYX_ERR(0, 59, __pyx_L1_error)
 060:                                    double[::1] RMinMax, double[::1] ZMinMax,
+061:                                    DR=None, DZ=None, DPhi=None, VPoly=None,
    values[5] = ((PyObject *)Py_None);
    values[6] = ((PyObject *)Py_None);
    values[7] = ((PyObject *)Py_None);
    values[8] = ((PyObject *)Py_None);
    values[9] = ((PyObject*)__pyx_kp_s_X_Y_Z);
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case 11: values[10] = PyTuple_GET_ITEM(__pyx_args, 10);
        case 10: values[9] = PyTuple_GET_ITEM(__pyx_args, 9);
        case  9: values[8] = PyTuple_GET_ITEM(__pyx_args, 8);
        case  8: values[7] = PyTuple_GET_ITEM(__pyx_args, 7);
        case  7: values[6] = PyTuple_GET_ITEM(__pyx_args, 6);
        case  6: values[5] = PyTuple_GET_ITEM(__pyx_args, 5);
        case  5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_dR)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        case  1:
        if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_dZ)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_Ves_Vmesh_Tor_SubFromD_cython", 0, 5, 11, 1); __PYX_ERR(0, 59, __pyx_L3_error)
        }
        case  2:
        if (likely((values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_dRPhi)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_Ves_Vmesh_Tor_SubFromD_cython", 0, 5, 11, 2); __PYX_ERR(0, 59, __pyx_L3_error)
        }
        case  3:
        if (likely((values[3] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_RMinMax)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_Ves_Vmesh_Tor_SubFromD_cython", 0, 5, 11, 3); __PYX_ERR(0, 59, __pyx_L3_error)
        }
        case  4:
        if (likely((values[4] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_ZMinMax)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_Ves_Vmesh_Tor_SubFromD_cython", 0, 5, 11, 4); __PYX_ERR(0, 59, __pyx_L3_error)
        }
        case  5:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_DR);
          if (value) { values[5] = value; kw_args--; }
        }
        case  6:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_DZ);
          if (value) { values[6] = value; kw_args--; }
        }
        case  7:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_DPhi);
          if (value) { values[7] = value; kw_args--; }
        }
        case  8:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_VPoly);
          if (value) { values[8] = value; kw_args--; }
        }
        case  9:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_Out);
          if (value) { values[9] = value; kw_args--; }
        }
        case 10:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_margin);
          if (value) { values[10] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "_Ves_Vmesh_Tor_SubFromD_cython") < 0)) __PYX_ERR(0, 59, __pyx_L3_error)
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case 11: values[10] = PyTuple_GET_ITEM(__pyx_args, 10);
        case 10: values[9] = PyTuple_GET_ITEM(__pyx_args, 9);
        case  9: values[8] = PyTuple_GET_ITEM(__pyx_args, 8);
        case  8: values[7] = PyTuple_GET_ITEM(__pyx_args, 7);
        case  7: values[6] = PyTuple_GET_ITEM(__pyx_args, 6);
        case  6: values[5] = PyTuple_GET_ITEM(__pyx_args, 5);
        case  5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
        values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    __pyx_v_dR = __pyx_PyFloat_AsDouble(values[0]); if (unlikely((__pyx_v_dR == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 59, __pyx_L3_error)
    __pyx_v_dZ = __pyx_PyFloat_AsDouble(values[1]); if (unlikely((__pyx_v_dZ == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 59, __pyx_L3_error)
    __pyx_v_dRPhi = __pyx_PyFloat_AsDouble(values[2]); if (unlikely((__pyx_v_dRPhi == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 59, __pyx_L3_error)
    __pyx_v_RMinMax = __Pyx_PyObject_to_MemoryviewSlice_dc_double(values[3]); if (unlikely(!__pyx_v_RMinMax.memview)) __PYX_ERR(0, 60, __pyx_L3_error)
    __pyx_v_ZMinMax = __Pyx_PyObject_to_MemoryviewSlice_dc_double(values[4]); if (unlikely(!__pyx_v_ZMinMax.memview)) __PYX_ERR(0, 60, __pyx_L3_error)
    __pyx_v_DR = values[5];
    __pyx_v_DZ = values[6];
    __pyx_v_DPhi = values[7];
    __pyx_v_VPoly = values[8];
    __pyx_v_Out = ((PyObject*)values[9]);
    if (values[10]) {
      __pyx_v_margin = __pyx_PyFloat_AsDouble(values[10]); if (unlikely((__pyx_v_margin == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 62, __pyx_L3_error)
    } else {
      __pyx_v_margin = ((double)1.e-9);
    }
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("_Ves_Vmesh_Tor_SubFromD_cython", 0, 5, 11, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 59, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("_cython_magic_ffb7650808bb7830760fff8d6d047f13._Ves_Vmesh_Tor_SubFromD_cython", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_Out), (&PyString_Type), 1, "Out", 1))) __PYX_ERR(0, 62, __pyx_L1_error)
  __pyx_r = __pyx_pf_46_cython_magic_ffb7650808bb7830760fff8d6d047f13_2_Ves_Vmesh_Tor_SubFromD_cython(__pyx_self, __pyx_v_dR, __pyx_v_dZ, __pyx_v_dRPhi, __pyx_v_RMinMax, __pyx_v_ZMinMax, __pyx_v_DR, __pyx_v_DZ, __pyx_v_DPhi, __pyx_v_VPoly, __pyx_v_Out, __pyx_v_margin);
 062:                                    str Out='(X,Y,Z)', double margin=1.e-9):
 063:     " Return the desired submesh indicated by the limits (DR,DZ,DPhi), for the desired resolution (dR,dZ,dRphi) "
 064: 
 065:     cdef double[::1] R0, R, Z, dRPhir, dPhir, NRPhi#, dPhi, NRZPhi_cum0, indPhi, phi
 066:     cdef double dRr0, dRr, dZr, DPhi0, DPhi1
 067:     cdef double abs0, abs1, phi, indiijj
 068:     cdef long[::1] indR0, indR, indZ, Phin, NRPhi0
 069:     cdef int NR0, NR, NZ, Rn, Zn, nRPhi0, indR0ii, ii, jj, nPhi0, nPhi1, zz, NP, NRPhi_int, Rratio
 070:     cdef cnp.ndarray[double,ndim=2] Pts, indI
 071:     cdef cnp.ndarray[double,ndim=1] dV, ind
 072: 
 073:     # Get the actual R and Z resolutions and mesh elements
+074:     R0, dRr0, indR0, NR0 = _Ves_mesh_dlfromL_cython(RMinMax, dR, None, margin=margin)
  __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_Ves_mesh_dlfromL_cython); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 74, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __pyx_memoryview_fromslice(__pyx_v_RMinMax, 1, (PyObject *(*)(char *)) __pyx_memview_get_double, (int (*)(char *, PyObject *)) __pyx_memview_set_double, 0);; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 74, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = PyFloat_FromDouble(__pyx_v_dR); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 74, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = PyTuple_New(3); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 74, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_GIVEREF(__pyx_t_2);
  PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_2);
  __Pyx_GIVEREF(__pyx_t_3);
  PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_t_3);
  __Pyx_INCREF(Py_None);
  __Pyx_GIVEREF(Py_None);
  PyTuple_SET_ITEM(__pyx_t_4, 2, Py_None);
  __pyx_t_2 = 0;
  __pyx_t_3 = 0;
  __pyx_t_3 = PyDict_New(); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 74, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_2 = PyFloat_FromDouble(__pyx_v_margin); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 74, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_margin, __pyx_t_2) < 0) __PYX_ERR(0, 74, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_4, __pyx_t_3); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 74, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  if ((likely(PyTuple_CheckExact(__pyx_t_2))) || (PyList_CheckExact(__pyx_t_2))) {
    PyObject* sequence = __pyx_t_2;
    #if !CYTHON_COMPILING_IN_PYPY
    Py_ssize_t size = Py_SIZE(sequence);
    #else
    Py_ssize_t size = PySequence_Size(sequence);
    #endif
    if (unlikely(size != 4)) {
      if (size > 4) __Pyx_RaiseTooManyValuesError(4);
      else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
      __PYX_ERR(0, 74, __pyx_L1_error)
    }
    #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
    if (likely(PyTuple_CheckExact(sequence))) {
      __pyx_t_3 = PyTuple_GET_ITEM(sequence, 0); 
      __pyx_t_4 = PyTuple_GET_ITEM(sequence, 1); 
      __pyx_t_1 = PyTuple_GET_ITEM(sequence, 2); 
      __pyx_t_5 = PyTuple_GET_ITEM(sequence, 3); 
    } else {
      __pyx_t_3 = PyList_GET_ITEM(sequence, 0); 
      __pyx_t_4 = PyList_GET_ITEM(sequence, 1); 
      __pyx_t_1 = PyList_GET_ITEM(sequence, 2); 
      __pyx_t_5 = PyList_GET_ITEM(sequence, 3); 
    }
    __Pyx_INCREF(__pyx_t_3);
    __Pyx_INCREF(__pyx_t_4);
    __Pyx_INCREF(__pyx_t_1);
    __Pyx_INCREF(__pyx_t_5);
    #else
    {
      Py_ssize_t i;
      PyObject** temps[4] = {&__pyx_t_3,&__pyx_t_4,&__pyx_t_1,&__pyx_t_5};
      for (i=0; i < 4; i++) {
        PyObject* item = PySequence_ITEM(sequence, i); if (unlikely(!item)) __PYX_ERR(0, 74, __pyx_L1_error)
        __Pyx_GOTREF(item);
        *(temps[i]) = item;
      }
    }
    #endif
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  } else {
    Py_ssize_t index = -1;
    PyObject** temps[4] = {&__pyx_t_3,&__pyx_t_4,&__pyx_t_1,&__pyx_t_5};
    __pyx_t_6 = PyObject_GetIter(__pyx_t_2); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 74, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_t_7 = Py_TYPE(__pyx_t_6)->tp_iternext;
    for (index=0; index < 4; index++) {
      PyObject* item = __pyx_t_7(__pyx_t_6); if (unlikely(!item)) goto __pyx_L3_unpacking_failed;
      __Pyx_GOTREF(item);
      *(temps[index]) = item;
    }
    if (__Pyx_IternextUnpackEndCheck(__pyx_t_7(__pyx_t_6), 4) < 0) __PYX_ERR(0, 74, __pyx_L1_error)
    __pyx_t_7 = NULL;
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    goto __pyx_L4_unpacking_done;
    __pyx_L3_unpacking_failed:;
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __pyx_t_7 = NULL;
    if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
    __PYX_ERR(0, 74, __pyx_L1_error)
    __pyx_L4_unpacking_done:;
  }
  __pyx_t_8 = __Pyx_PyObject_to_MemoryviewSlice_dc_double(__pyx_t_3);
  if (unlikely(!__pyx_t_8.memview)) __PYX_ERR(0, 74, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_9 = __pyx_PyFloat_AsDouble(__pyx_t_4); if (unlikely((__pyx_t_9 == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 74, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_10 = __Pyx_PyObject_to_MemoryviewSlice_dc_long(__pyx_t_1);
  if (unlikely(!__pyx_t_10.memview)) __PYX_ERR(0, 74, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_11 = __Pyx_PyInt_As_int(__pyx_t_5); if (unlikely((__pyx_t_11 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 74, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __pyx_v_R0 = __pyx_t_8;
  __pyx_t_8.memview = NULL;
  __pyx_t_8.data = NULL;
  __pyx_v_dRr0 = __pyx_t_9;
  __pyx_v_indR0 = __pyx_t_10;
  __pyx_t_10.memview = NULL;
  __pyx_t_10.data = NULL;
  __pyx_v_NR0 = __pyx_t_11;
+075:     R, dRr, indR, NR = _Ves_mesh_dlfromL_cython(RMinMax, dR, DR, margin=margin)
  __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_Ves_mesh_dlfromL_cython); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 75, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_5 = __pyx_memoryview_fromslice(__pyx_v_RMinMax, 1, (PyObject *(*)(char *)) __pyx_memview_get_double, (int (*)(char *, PyObject *)) __pyx_memview_set_double, 0);; if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 75, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_t_1 = PyFloat_FromDouble(__pyx_v_dR); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 75, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_4 = PyTuple_New(3); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 75, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_GIVEREF(__pyx_t_5);
  PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_5);
  __Pyx_GIVEREF(__pyx_t_1);
  PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_t_1);
  __Pyx_INCREF(__pyx_v_DR);
  __Pyx_GIVEREF(__pyx_v_DR);
  PyTuple_SET_ITEM(__pyx_t_4, 2, __pyx_v_DR);
  __pyx_t_5 = 0;
  __pyx_t_1 = 0;
  __pyx_t_1 = PyDict_New(); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 75, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_5 = PyFloat_FromDouble(__pyx_v_margin); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 75, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_margin, __pyx_t_5) < 0) __PYX_ERR(0, 75, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __pyx_t_5 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_4, __pyx_t_1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 75, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if ((likely(PyTuple_CheckExact(__pyx_t_5))) || (PyList_CheckExact(__pyx_t_5))) {
    PyObject* sequence = __pyx_t_5;
    #if !CYTHON_COMPILING_IN_PYPY
    Py_ssize_t size = Py_SIZE(sequence);
    #else
    Py_ssize_t size = PySequence_Size(sequence);
    #endif
    if (unlikely(size != 4)) {
      if (size > 4) __Pyx_RaiseTooManyValuesError(4);
      else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
      __PYX_ERR(0, 75, __pyx_L1_error)
    }
    #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
    if (likely(PyTuple_CheckExact(sequence))) {
      __pyx_t_1 = PyTuple_GET_ITEM(sequence, 0); 
      __pyx_t_4 = PyTuple_GET_ITEM(sequence, 1); 
      __pyx_t_2 = PyTuple_GET_ITEM(sequence, 2); 
      __pyx_t_3 = PyTuple_GET_ITEM(sequence, 3); 
    } else {
      __pyx_t_1 = PyList_GET_ITEM(sequence, 0); 
      __pyx_t_4 = PyList_GET_ITEM(sequence, 1); 
      __pyx_t_2 = PyList_GET_ITEM(sequence, 2); 
      __pyx_t_3 = PyList_GET_ITEM(sequence, 3); 
    }
    __Pyx_INCREF(__pyx_t_1);
    __Pyx_INCREF(__pyx_t_4);
    __Pyx_INCREF(__pyx_t_2);
    __Pyx_INCREF(__pyx_t_3);
    #else
    {
      Py_ssize_t i;
      PyObject** temps[4] = {&__pyx_t_1,&__pyx_t_4,&__pyx_t_2,&__pyx_t_3};
      for (i=0; i < 4; i++) {
        PyObject* item = PySequence_ITEM(sequence, i); if (unlikely(!item)) __PYX_ERR(0, 75, __pyx_L1_error)
        __Pyx_GOTREF(item);
        *(temps[i]) = item;
      }
    }
    #endif
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  } else {
    Py_ssize_t index = -1;
    PyObject** temps[4] = {&__pyx_t_1,&__pyx_t_4,&__pyx_t_2,&__pyx_t_3};
    __pyx_t_6 = PyObject_GetIter(__pyx_t_5); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 75, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __pyx_t_7 = Py_TYPE(__pyx_t_6)->tp_iternext;
    for (index=0; index < 4; index++) {
      PyObject* item = __pyx_t_7(__pyx_t_6); if (unlikely(!item)) goto __pyx_L5_unpacking_failed;
      __Pyx_GOTREF(item);
      *(temps[index]) = item;
    }
    if (__Pyx_IternextUnpackEndCheck(__pyx_t_7(__pyx_t_6), 4) < 0) __PYX_ERR(0, 75, __pyx_L1_error)
    __pyx_t_7 = NULL;
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    goto __pyx_L6_unpacking_done;
    __pyx_L5_unpacking_failed:;
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __pyx_t_7 = NULL;
    if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
    __PYX_ERR(0, 75, __pyx_L1_error)
    __pyx_L6_unpacking_done:;
  }
  __pyx_t_8 = __Pyx_PyObject_to_MemoryviewSlice_dc_double(__pyx_t_1);
  if (unlikely(!__pyx_t_8.memview)) __PYX_ERR(0, 75, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_9 = __pyx_PyFloat_AsDouble(__pyx_t_4); if (unlikely((__pyx_t_9 == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 75, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_10 = __Pyx_PyObject_to_MemoryviewSlice_dc_long(__pyx_t_2);
  if (unlikely(!__pyx_t_10.memview)) __PYX_ERR(0, 75, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_11 = __Pyx_PyInt_As_int(__pyx_t_3); if (unlikely((__pyx_t_11 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 75, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_v_R = __pyx_t_8;
  __pyx_t_8.memview = NULL;
  __pyx_t_8.data = NULL;
  __pyx_v_dRr = __pyx_t_9;
  __pyx_v_indR = __pyx_t_10;
  __pyx_t_10.memview = NULL;
  __pyx_t_10.data = NULL;
  __pyx_v_NR = __pyx_t_11;
+076:     Z, dZr, indZ, NZ = _Ves_mesh_dlfromL_cython(ZMinMax, dZ, DZ, margin=margin)
  __pyx_t_5 = __Pyx_GetModuleGlobalName(__pyx_n_s_Ves_mesh_dlfromL_cython); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 76, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_t_3 = __pyx_memoryview_fromslice(__pyx_v_ZMinMax, 1, (PyObject *(*)(char *)) __pyx_memview_get_double, (int (*)(char *, PyObject *)) __pyx_memview_set_double, 0);; if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 76, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_2 = PyFloat_FromDouble(__pyx_v_dZ); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 76, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_4 = PyTuple_New(3); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 76, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_GIVEREF(__pyx_t_3);
  PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_3);
  __Pyx_GIVEREF(__pyx_t_2);
  PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_t_2);
  __Pyx_INCREF(__pyx_v_DZ);
  __Pyx_GIVEREF(__pyx_v_DZ);
  PyTuple_SET_ITEM(__pyx_t_4, 2, __pyx_v_DZ);
  __pyx_t_3 = 0;
  __pyx_t_2 = 0;
  __pyx_t_2 = PyDict_New(); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 76, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = PyFloat_FromDouble(__pyx_v_margin); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 76, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_margin, __pyx_t_3) < 0) __PYX_ERR(0, 76, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_t_4, __pyx_t_2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 76, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  if ((likely(PyTuple_CheckExact(__pyx_t_3))) || (PyList_CheckExact(__pyx_t_3))) {
    PyObject* sequence = __pyx_t_3;
    #if !CYTHON_COMPILING_IN_PYPY
    Py_ssize_t size = Py_SIZE(sequence);
    #else
    Py_ssize_t size = PySequence_Size(sequence);
    #endif
    if (unlikely(size != 4)) {
      if (size > 4) __Pyx_RaiseTooManyValuesError(4);
      else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
      __PYX_ERR(0, 76, __pyx_L1_error)
    }
    #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
    if (likely(PyTuple_CheckExact(sequence))) {
      __pyx_t_2 = PyTuple_GET_ITEM(sequence, 0); 
      __pyx_t_4 = PyTuple_GET_ITEM(sequence, 1); 
      __pyx_t_5 = PyTuple_GET_ITEM(sequence, 2); 
      __pyx_t_1 = PyTuple_GET_ITEM(sequence, 3); 
    } else {
      __pyx_t_2 = PyList_GET_ITEM(sequence, 0); 
      __pyx_t_4 = PyList_GET_ITEM(sequence, 1); 
      __pyx_t_5 = PyList_GET_ITEM(sequence, 2); 
      __pyx_t_1 = PyList_GET_ITEM(sequence, 3); 
    }
    __Pyx_INCREF(__pyx_t_2);
    __Pyx_INCREF(__pyx_t_4);
    __Pyx_INCREF(__pyx_t_5);
    __Pyx_INCREF(__pyx_t_1);
    #else
    {
      Py_ssize_t i;
      PyObject** temps[4] = {&__pyx_t_2,&__pyx_t_4,&__pyx_t_5,&__pyx_t_1};
      for (i=0; i < 4; i++) {
        PyObject* item = PySequence_ITEM(sequence, i); if (unlikely(!item)) __PYX_ERR(0, 76, __pyx_L1_error)
        __Pyx_GOTREF(item);
        *(temps[i]) = item;
      }
    }
    #endif
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  } else {
    Py_ssize_t index = -1;
    PyObject** temps[4] = {&__pyx_t_2,&__pyx_t_4,&__pyx_t_5,&__pyx_t_1};
    __pyx_t_6 = PyObject_GetIter(__pyx_t_3); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 76, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_t_7 = Py_TYPE(__pyx_t_6)->tp_iternext;
    for (index=0; index < 4; index++) {
      PyObject* item = __pyx_t_7(__pyx_t_6); if (unlikely(!item)) goto __pyx_L7_unpacking_failed;
      __Pyx_GOTREF(item);
      *(temps[index]) = item;
    }
    if (__Pyx_IternextUnpackEndCheck(__pyx_t_7(__pyx_t_6), 4) < 0) __PYX_ERR(0, 76, __pyx_L1_error)
    __pyx_t_7 = NULL;
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    goto __pyx_L8_unpacking_done;
    __pyx_L7_unpacking_failed:;
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __pyx_t_7 = NULL;
    if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
    __PYX_ERR(0, 76, __pyx_L1_error)
    __pyx_L8_unpacking_done:;
  }
  __pyx_t_8 = __Pyx_PyObject_to_MemoryviewSlice_dc_double(__pyx_t_2);
  if (unlikely(!__pyx_t_8.memview)) __PYX_ERR(0, 76, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_9 = __pyx_PyFloat_AsDouble(__pyx_t_4); if (unlikely((__pyx_t_9 == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 76, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_10 = __Pyx_PyObject_to_MemoryviewSlice_dc_long(__pyx_t_5);
  if (unlikely(!__pyx_t_10.memview)) __PYX_ERR(0, 76, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __pyx_t_11 = __Pyx_PyInt_As_int(__pyx_t_1); if (unlikely((__pyx_t_11 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 76, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v_Z = __pyx_t_8;
  __pyx_t_8.memview = NULL;
  __pyx_t_8.data = NULL;
  __pyx_v_dZr = __pyx_t_9;
  __pyx_v_indZ = __pyx_t_10;
  __pyx_t_10.memview = NULL;
  __pyx_t_10.data = NULL;
  __pyx_v_NZ = __pyx_t_11;
+077:     Rn = len(R)
  __pyx_t_3 = __pyx_memoryview_fromslice(__pyx_v_R, 1, (PyObject *(*)(char *)) __pyx_memview_get_double, (int (*)(char *, PyObject *)) __pyx_memview_set_double, 0);; if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 77, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_12 = PyObject_Length(__pyx_t_3); if (unlikely(__pyx_t_12 == -1)) __PYX_ERR(0, 77, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_v_Rn = __pyx_t_12;
+078:     Zn = len(Z)
  __pyx_t_3 = __pyx_memoryview_fromslice(__pyx_v_Z, 1, (PyObject *(*)(char *)) __pyx_memview_get_double, (int (*)(char *, PyObject *)) __pyx_memview_set_double, 0);; if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 78, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_12 = PyObject_Length(__pyx_t_3); if (unlikely(__pyx_t_12 == -1)) __PYX_ERR(0, 78, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_v_Zn = __pyx_t_12;
 079: 
 080:     # Get the limits if any (and make sure to replace them in the proper quadrants)
+081:     if DPhi is None:
  __pyx_t_13 = (__pyx_v_DPhi == Py_None);
  __pyx_t_14 = (__pyx_t_13 != 0);
  if (__pyx_t_14) {
/* … */
    goto __pyx_L9;
  }
+082:         DPhi0, DPhi1 = -Cpi, Cpi
    __pyx_t_9 = (-M_PI);
    __pyx_t_15 = M_PI;
    __pyx_v_DPhi0 = __pyx_t_9;
    __pyx_v_DPhi1 = __pyx_t_15;
 083:     else:
+084:         DPhi0, DPhi1 = Catan2(Csin(DPhi[0]),Ccos(DPhi[0])), Catan2(Csin(DPhi[1]),Ccos(DPhi[1]))
  /*else*/ {
    __pyx_t_3 = __Pyx_GetItemInt(__pyx_v_DPhi, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 84, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_15 = __pyx_PyFloat_AsDouble(__pyx_t_3); if (unlikely((__pyx_t_15 == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 84, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_t_3 = __Pyx_GetItemInt(__pyx_v_DPhi, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 84, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_9 = __pyx_PyFloat_AsDouble(__pyx_t_3); if (unlikely((__pyx_t_9 == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 84, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_t_16 = atan2(sin(__pyx_t_15), cos(__pyx_t_9));
    __pyx_t_3 = __Pyx_GetItemInt(__pyx_v_DPhi, 1, long, 1, __Pyx_PyInt_From_long, 0, 0, 0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 84, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_9 = __pyx_PyFloat_AsDouble(__pyx_t_3); if (unlikely((__pyx_t_9 == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 84, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_t_3 = __Pyx_GetItemInt(__pyx_v_DPhi, 1, long, 1, __Pyx_PyInt_From_long, 0, 0, 0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 84, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_15 = __pyx_PyFloat_AsDouble(__pyx_t_3); if (unlikely((__pyx_t_15 == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 84, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_t_17 = atan2(sin(__pyx_t_9), cos(__pyx_t_15));
    __pyx_v_DPhi0 = __pyx_t_16;
    __pyx_v_DPhi1 = __pyx_t_17;
  }
  __pyx_L9:;
 085: 
+086:     dRPhir, dPhir = np.empty((Rn,)), np.empty((Rn,))
  __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 86, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_empty); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 86, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_Rn); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 86, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 86, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_GIVEREF(__pyx_t_1);
  PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_1);
  __pyx_t_1 = 0;
  __pyx_t_1 = NULL;
  if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_5))) {
    __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_5);
    if (likely(__pyx_t_1)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5);
      __Pyx_INCREF(__pyx_t_1);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_5, function);
    }
  }
  if (!__pyx_t_1) {
    __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_t_5, __pyx_t_4); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 86, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_GOTREF(__pyx_t_3);
  } else {
    #if CYTHON_FAST_PYCALL
    if (PyFunction_Check(__pyx_t_5)) {
      PyObject *__pyx_temp[2] = {__pyx_t_1, __pyx_t_4};
      __pyx_t_3 = __Pyx_PyFunction_FastCall(__pyx_t_5, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 86, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    } else
    #endif
    #if CYTHON_FAST_PYCCALL
    if (__Pyx_PyFastCFunction_Check(__pyx_t_5)) {
      PyObject *__pyx_temp[2] = {__pyx_t_1, __pyx_t_4};
      __pyx_t_3 = __Pyx_PyCFunction_FastCall(__pyx_t_5, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 86, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    } else
    #endif
    {
      __pyx_t_2 = PyTuple_New(1+1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 86, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_GIVEREF(__pyx_t_1); PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_1); __pyx_t_1 = NULL;
      __Pyx_GIVEREF(__pyx_t_4);
      PyTuple_SET_ITEM(__pyx_t_2, 0+1, __pyx_t_4);
      __pyx_t_4 = 0;
      __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_t_2, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 86, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    }
  }
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __pyx_t_8 = __Pyx_PyObject_to_MemoryviewSlice_dc_double(__pyx_t_3);
  if (unlikely(!__pyx_t_8.memview)) __PYX_ERR(0, 86, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_5 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 86, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_n_s_empty); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 86, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __pyx_t_5 = __Pyx_PyInt_From_int(__pyx_v_Rn); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 86, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 86, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_GIVEREF(__pyx_t_5);
  PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_5);
  __pyx_t_5 = 0;
  __pyx_t_5 = NULL;
  if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_2))) {
    __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_2);
    if (likely(__pyx_t_5)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
      __Pyx_INCREF(__pyx_t_5);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_2, function);
    }
  }
  if (!__pyx_t_5) {
    __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_4); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 86, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_GOTREF(__pyx_t_3);
  } else {
    #if CYTHON_FAST_PYCALL
    if (PyFunction_Check(__pyx_t_2)) {
      PyObject *__pyx_temp[2] = {__pyx_t_5, __pyx_t_4};
      __pyx_t_3 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 86, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    } else
    #endif
    #if CYTHON_FAST_PYCCALL
    if (__Pyx_PyFastCFunction_Check(__pyx_t_2)) {
      PyObject *__pyx_temp[2] = {__pyx_t_5, __pyx_t_4};
      __pyx_t_3 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 86, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    } else
    #endif
    {
      __pyx_t_1 = PyTuple_New(1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 86, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_5); __pyx_t_5 = NULL;
      __Pyx_GIVEREF(__pyx_t_4);
      PyTuple_SET_ITEM(__pyx_t_1, 0+1, __pyx_t_4);
      __pyx_t_4 = 0;
      __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_1, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 86, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    }
  }
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_18 = __Pyx_PyObject_to_MemoryviewSlice_dc_double(__pyx_t_3);
  if (unlikely(!__pyx_t_18.memview)) __PYX_ERR(0, 86, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_v_dRPhir = __pyx_t_8;
  __pyx_t_8.memview = NULL;
  __pyx_t_8.data = NULL;
  __pyx_v_dPhir = __pyx_t_18;
  __pyx_t_18.memview = NULL;
  __pyx_t_18.data = NULL;
+087:     Phin = np.empty((Rn,),dtype=int)
  __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 87, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_empty); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 87, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_3 = __Pyx_PyInt_From_int(__pyx_v_Rn); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 87, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 87, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_3);
  PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_3);
  __pyx_t_3 = 0;
  __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 87, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_GIVEREF(__pyx_t_1);
  PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_1);
  __pyx_t_1 = 0;
  __pyx_t_1 = PyDict_New(); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 87, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_dtype, ((PyObject *)(&PyInt_Type))) < 0) __PYX_ERR(0, 87, __pyx_L1_error)
  __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_3, __pyx_t_1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 87, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_10 = __Pyx_PyObject_to_MemoryviewSlice_dc_long(__pyx_t_4);
  if (unlikely(!__pyx_t_10.memview)) __PYX_ERR(0, 87, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_v_Phin = __pyx_t_10;
  __pyx_t_10.memview = NULL;
  __pyx_t_10.data = NULL;
+088:     NRPhi = np.empty((Rn,))
  __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 88, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_empty); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 88, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_Rn); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 88, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 88, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_GIVEREF(__pyx_t_1);
  PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_1);
  __pyx_t_1 = 0;
  __pyx_t_1 = NULL;
  if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) {
    __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_3);
    if (likely(__pyx_t_1)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
      __Pyx_INCREF(__pyx_t_1);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_3, function);
    }
  }
  if (!__pyx_t_1) {
    __pyx_t_4 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_2); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 88, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_GOTREF(__pyx_t_4);
  } else {
    #if CYTHON_FAST_PYCALL
    if (PyFunction_Check(__pyx_t_3)) {
      PyObject *__pyx_temp[2] = {__pyx_t_1, __pyx_t_2};
      __pyx_t_4 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 88, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    } else
    #endif
    #if CYTHON_FAST_PYCCALL
    if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) {
      PyObject *__pyx_temp[2] = {__pyx_t_1, __pyx_t_2};
      __pyx_t_4 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 88, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    } else
    #endif
    {
      __pyx_t_5 = PyTuple_New(1+1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 88, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_GIVEREF(__pyx_t_1); PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_1); __pyx_t_1 = NULL;
      __Pyx_GIVEREF(__pyx_t_2);
      PyTuple_SET_ITEM(__pyx_t_5, 0+1, __pyx_t_2);
      __pyx_t_2 = 0;
      __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_5, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 88, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    }
  }
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_18 = __Pyx_PyObject_to_MemoryviewSlice_dc_double(__pyx_t_4);
  if (unlikely(!__pyx_t_18.memview)) __PYX_ERR(0, 88, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_v_NRPhi = __pyx_t_18;
  __pyx_t_18.memview = NULL;
  __pyx_t_18.data = NULL;
+089:     NRPhi0 = np.zeros((Rn,),dtype=int)
  __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 89, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_zeros); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 89, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_4 = __Pyx_PyInt_From_int(__pyx_v_Rn); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 89, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_5 = PyTuple_New(1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 89, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_GIVEREF(__pyx_t_4);
  PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_4);
  __pyx_t_4 = 0;
  __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 89, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_GIVEREF(__pyx_t_5);
  PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_5);
  __pyx_t_5 = 0;
  __pyx_t_5 = PyDict_New(); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 89, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  if (PyDict_SetItem(__pyx_t_5, __pyx_n_s_dtype, ((PyObject *)(&PyInt_Type))) < 0) __PYX_ERR(0, 89, __pyx_L1_error)
  __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_4, __pyx_t_5); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 89, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __pyx_t_10 = __Pyx_PyObject_to_MemoryviewSlice_dc_long(__pyx_t_2);
  if (unlikely(!__pyx_t_10.memview)) __PYX_ERR(0, 89, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_v_NRPhi0 = __pyx_t_10;
  __pyx_t_10.memview = NULL;
  __pyx_t_10.data = NULL;
+090:     nRPhi0, indR0ii = 0, 0
  __pyx_t_11 = 0;
  __pyx_t_19 = 0;
  __pyx_v_nRPhi0 = __pyx_t_11;
  __pyx_v_indR0ii = __pyx_t_19;
+091:     NP, NPhimax = 0, 0
  __pyx_t_19 = 0;
  __pyx_t_20 = 0;
  __pyx_v_NP = __pyx_t_19;
  __pyx_v_NPhimax = __pyx_t_20;
+092:     Rratio = int(Cceil(R[Rn-1]/R[0]))
  __pyx_t_21 = (__pyx_v_Rn - 1);
  __pyx_t_22 = 0;
  __pyx_v_Rratio = ((int)ceil(((*((double *) ( /* dim=0 */ ((char *) (((double *) __pyx_v_R.data) + __pyx_t_21)) ))) / (*((double *) ( /* dim=0 */ ((char *) (((double *) __pyx_v_R.data) + __pyx_t_22)) ))))));
+093:     for ii in range(0,Rn):
  __pyx_t_19 = __pyx_v_Rn;
  for (__pyx_t_11 = 0; __pyx_t_11 < __pyx_t_19; __pyx_t_11+=1) {
    __pyx_v_ii = __pyx_t_11;
 094:         # Get the actual RPhi resolution and Phi mesh elements (! depends on R !)
+095:         NRPhi[ii] = Cceil(2.*Cpi*R[ii]/dRPhi)
    __pyx_t_23 = __pyx_v_ii;
    __pyx_t_24 = __pyx_v_ii;
    *((double *) ( /* dim=0 */ ((char *) (((double *) __pyx_v_NRPhi.data) + __pyx_t_24)) )) = ceil((((2. * M_PI) * (*((double *) ( /* dim=0 */ ((char *) (((double *) __pyx_v_R.data) + __pyx_t_23)) )))) / __pyx_v_dRPhi));
+096:         NRPhi_int = int(NRPhi[ii])
    __pyx_t_25 = __pyx_v_ii;
    __pyx_v_NRPhi_int = ((int)(*((double *) ( /* dim=0 */ ((char *) (((double *) __pyx_v_NRPhi.data) + __pyx_t_25)) ))));
+097:         dPhir[ii] = 2.*Cpi/NRPhi[ii]
    __pyx_t_26 = __pyx_v_ii;
    __pyx_t_27 = __pyx_v_ii;
    *((double *) ( /* dim=0 */ ((char *) (((double *) __pyx_v_dPhir.data) + __pyx_t_27)) )) = ((2. * M_PI) / (*((double *) ( /* dim=0 */ ((char *) (((double *) __pyx_v_NRPhi.data) + __pyx_t_26)) ))));
+098:         dRPhir[ii] = dPhir[ii]*R[ii]
    __pyx_t_28 = __pyx_v_ii;
    __pyx_t_29 = __pyx_v_ii;
    __pyx_t_30 = __pyx_v_ii;
    *((double *) ( /* dim=0 */ ((char *) (((double *) __pyx_v_dRPhir.data) + __pyx_t_30)) )) = ((*((double *) ( /* dim=0 */ ((char *) (((double *) __pyx_v_dPhir.data) + __pyx_t_28)) ))) * (*((double *) ( /* dim=0 */ ((char *) (((double *) __pyx_v_R.data) + __pyx_t_29)) ))));
 099:         # Get index and cumulated indices from background
+100:         for jj in range(indR0ii,NR0):
    __pyx_t_31 = __pyx_v_NR0;
    for (__pyx_t_32 = __pyx_v_indR0ii; __pyx_t_32 < __pyx_t_31; __pyx_t_32+=1) {
      __pyx_v_jj = __pyx_t_32;
+101:             if R0[jj]==R[ii]:
      __pyx_t_33 = __pyx_v_jj;
      __pyx_t_34 = __pyx_v_ii;
      __pyx_t_14 = (((*((double *) ( /* dim=0 */ ((char *) (((double *) __pyx_v_R0.data) + __pyx_t_33)) ))) == (*((double *) ( /* dim=0 */ ((char *) (((double *) __pyx_v_R.data) + __pyx_t_34)) )))) != 0);
      if (__pyx_t_14) {
/* … */
      }
+102:                 indR0ii = jj
        __pyx_v_indR0ii = __pyx_v_jj;
+103:                 break
        goto __pyx_L13_break;
 104:             else:
+105:                 nRPhi0 += <long>Cceil(2.*Cpi*R0[jj]/dRPhi)
      /*else*/ {
        __pyx_t_35 = __pyx_v_jj;
        __pyx_v_nRPhi0 = (__pyx_v_nRPhi0 + ((long)ceil((((2. * M_PI) * (*((double *) ( /* dim=0 */ ((char *) (((double *) __pyx_v_R0.data) + __pyx_t_35)) )))) / __pyx_v_dRPhi))));
+106:                 NRPhi0[ii] = nRPhi0*NZ
        __pyx_t_36 = __pyx_v_ii;
        *((long *) ( /* dim=0 */ ((char *) (((long *) __pyx_v_NRPhi0.data) + __pyx_t_36)) )) = (__pyx_v_nRPhi0 * __pyx_v_NZ);
      }
    }
    __pyx_L13_break:;
 107:         # Get indices of phi
 108:         # Get the extreme indices of the mesh elements that really need to be created within those limits
+109:         abs0 = Cabs(DPhi0+Cpi)
    __pyx_v_abs0 = fabs((__pyx_v_DPhi0 + M_PI));
+110:         if abs0-dPhir[ii]*Cfloor(abs0/dPhir[ii])<margin*dPhir[ii]:
    __pyx_t_37 = __pyx_v_ii;
    __pyx_t_38 = __pyx_v_ii;
    __pyx_t_39 = __pyx_v_ii;
    __pyx_t_14 = (((__pyx_v_abs0 - ((*((double *) ( /* dim=0 */ ((char *) (((double *) __pyx_v_dPhir.data) + __pyx_t_37)) ))) * floor((__pyx_v_abs0 / (*((double *) ( /* dim=0 */ ((char *) (((double *) __pyx_v_dPhir.data) + __pyx_t_38)) ))))))) < (__pyx_v_margin * (*((double *) ( /* dim=0 */ ((char *) (((double *) __pyx_v_dPhir.data) + __pyx_t_39)) ))))) != 0);
    if (__pyx_t_14) {
/* … */
      goto __pyx_L15;
    }
+111:             nPhi0 = int(Cround((DPhi0+Cpi)/dPhir[ii]))
      __pyx_t_40 = __pyx_v_ii;
      __pyx_v_nPhi0 = ((int)round(((__pyx_v_DPhi0 + M_PI) / (*((double *) ( /* dim=0 */ ((char *) (((double *) __pyx_v_dPhir.data) + __pyx_t_40)) ))))));
 112:         else:
+113:             nPhi0 = int(Cfloor((DPhi0+Cpi)/dPhir[ii]))
    /*else*/ {
      __pyx_t_41 = __pyx_v_ii;
      __pyx_v_nPhi0 = ((int)floor(((__pyx_v_DPhi0 + M_PI) / (*((double *) ( /* dim=0 */ ((char *) (((double *) __pyx_v_dPhir.data) + __pyx_t_41)) ))))));
    }
    __pyx_L15:;
+114:         abs1 = Cabs(DPhi1+Cpi)
    __pyx_v_abs1 = fabs((__pyx_v_DPhi1 + M_PI));
+115:         if abs1-dPhir[ii]*Cfloor(abs1/dPhir[ii])<margin*dPhir[ii]:
    __pyx_t_42 = __pyx_v_ii;
    __pyx_t_43 = __pyx_v_ii;
    __pyx_t_44 = __pyx_v_ii;
    __pyx_t_14 = (((__pyx_v_abs1 - ((*((double *) ( /* dim=0 */ ((char *) (((double *) __pyx_v_dPhir.data) + __pyx_t_42)) ))) * floor((__pyx_v_abs1 / (*((double *) ( /* dim=0 */ ((char *) (((double *) __pyx_v_dPhir.data) + __pyx_t_43)) ))))))) < (__pyx_v_margin * (*((double *) ( /* dim=0 */ ((char *) (((double *) __pyx_v_dPhir.data) + __pyx_t_44)) ))))) != 0);
    if (__pyx_t_14) {
/* … */
      goto __pyx_L16;
    }
+116:             nPhi1 = int(Cround((DPhi1+Cpi)/dPhir[ii])-1)
      __pyx_t_45 = __pyx_v_ii;
      __pyx_v_nPhi1 = ((int)(round(((__pyx_v_DPhi1 + M_PI) / (*((double *) ( /* dim=0 */ ((char *) (((double *) __pyx_v_dPhir.data) + __pyx_t_45)) ))))) - 1.0));
 117:         else:
+118:             nPhi1 = int(Cfloor((DPhi1+Cpi)/dPhir[ii]))
    /*else*/ {
      __pyx_t_46 = __pyx_v_ii;
      __pyx_v_nPhi1 = ((int)floor(((__pyx_v_DPhi1 + M_PI) / (*((double *) ( /* dim=0 */ ((char *) (((double *) __pyx_v_dPhir.data) + __pyx_t_46)) ))))));
    }
    __pyx_L16:;
 119: 
+120:         if DPhi0<DPhi1:
    __pyx_t_14 = ((__pyx_v_DPhi0 < __pyx_v_DPhi1) != 0);
    if (__pyx_t_14) {
/* … */
      goto __pyx_L17;
    }
 121:             #indI.append(list(range(nPhi0,nPhi1+1)))
+122:             Phin[ii] = nPhi1+1-nPhi0
      __pyx_t_47 = __pyx_v_ii;
      *((long *) ( /* dim=0 */ ((char *) (((long *) __pyx_v_Phin.data) + __pyx_t_47)) )) = ((__pyx_v_nPhi1 + 1) - __pyx_v_nPhi0);
+123:             if ii==0:
      __pyx_t_14 = ((__pyx_v_ii == 0) != 0);
      if (__pyx_t_14) {
/* … */
      }
+124:                 indI = np.ones((Rn,Phin[ii]*Rratio+1))
        __pyx_t_5 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 124, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_5);
        __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_n_s_ones); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 124, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_4);
        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
        __pyx_t_5 = __Pyx_PyInt_From_int(__pyx_v_Rn); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 124, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_5);
        __pyx_t_48 = __pyx_v_ii;
        __pyx_t_3 = __Pyx_PyInt_From_long((((*((long *) ( /* dim=0 */ ((char *) (((long *) __pyx_v_Phin.data) + __pyx_t_48)) ))) * __pyx_v_Rratio) + 1)); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 124, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_3);
        __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 124, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_1);
        __Pyx_GIVEREF(__pyx_t_5);
        PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_5);
        __Pyx_GIVEREF(__pyx_t_3);
        PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_t_3);
        __pyx_t_5 = 0;
        __pyx_t_3 = 0;
        __pyx_t_3 = NULL;
        if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_4))) {
          __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_4);
          if (likely(__pyx_t_3)) {
            PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
            __Pyx_INCREF(__pyx_t_3);
            __Pyx_INCREF(function);
            __Pyx_DECREF_SET(__pyx_t_4, function);
          }
        }
        if (!__pyx_t_3) {
          __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 124, __pyx_L1_error)
          __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
          __Pyx_GOTREF(__pyx_t_2);
        } else {
          #if CYTHON_FAST_PYCALL
          if (PyFunction_Check(__pyx_t_4)) {
            PyObject *__pyx_temp[2] = {__pyx_t_3, __pyx_t_1};
            __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_4, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 124, __pyx_L1_error)
            __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
            __Pyx_GOTREF(__pyx_t_2);
            __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
          } else
          #endif
          #if CYTHON_FAST_PYCCALL
          if (__Pyx_PyFastCFunction_Check(__pyx_t_4)) {
            PyObject *__pyx_temp[2] = {__pyx_t_3, __pyx_t_1};
            __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_4, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 124, __pyx_L1_error)
            __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
            __Pyx_GOTREF(__pyx_t_2);
            __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
          } else
          #endif
          {
            __pyx_t_5 = PyTuple_New(1+1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 124, __pyx_L1_error)
            __Pyx_GOTREF(__pyx_t_5);
            __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_3); __pyx_t_3 = NULL;
            __Pyx_GIVEREF(__pyx_t_1);
            PyTuple_SET_ITEM(__pyx_t_5, 0+1, __pyx_t_1);
            __pyx_t_1 = 0;
            __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_5, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 124, __pyx_L1_error)
            __Pyx_GOTREF(__pyx_t_2);
            __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
          }
        }
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
        if (!(likely(((__pyx_t_2) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_2, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 124, __pyx_L1_error)
        __pyx_t_49 = ((PyArrayObject *)__pyx_t_2);
        {
          __Pyx_BufFmt_StackElem __pyx_stack[1];
          __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_indI.rcbuffer->pybuffer);
          __pyx_t_31 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_indI.rcbuffer->pybuffer, (PyObject*)__pyx_t_49, &__Pyx_TypeInfo_double, PyBUF_FORMAT| PyBUF_STRIDES| PyBUF_WRITABLE, 2, 0, __pyx_stack);
          if (unlikely(__pyx_t_31 < 0)) {
            PyErr_Fetch(&__pyx_t_50, &__pyx_t_51, &__pyx_t_52);
            if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_indI.rcbuffer->pybuffer, (PyObject*)__pyx_v_indI, &__Pyx_TypeInfo_double, PyBUF_FORMAT| PyBUF_STRIDES| PyBUF_WRITABLE, 2, 0, __pyx_stack) == -1)) {
              Py_XDECREF(__pyx_t_50); Py_XDECREF(__pyx_t_51); Py_XDECREF(__pyx_t_52);
              __Pyx_RaiseBufferFallbackError();
            } else {
              PyErr_Restore(__pyx_t_50, __pyx_t_51, __pyx_t_52);
            }
          }
          __pyx_pybuffernd_indI.diminfo[0].strides = __pyx_pybuffernd_indI.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_indI.diminfo[0].shape = __pyx_pybuffernd_indI.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_indI.diminfo[1].strides = __pyx_pybuffernd_indI.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_indI.diminfo[1].shape = __pyx_pybuffernd_indI.rcbuffer->pybuffer.shape[1];
          if (unlikely(__pyx_t_31 < 0)) __PYX_ERR(0, 124, __pyx_L1_error)
        }
        __pyx_t_49 = 0;
        __Pyx_XDECREF_SET(__pyx_v_indI, ((PyArrayObject *)__pyx_t_2));
        __pyx_t_2 = 0;
+125:             for jj in range(0,Phin[ii]):
      __pyx_t_53 = __pyx_v_ii;
      __pyx_t_20 = (*((long *) ( /* dim=0 */ ((char *) (((long *) __pyx_v_Phin.data) + __pyx_t_53)) )));
      for (__pyx_t_31 = 0; __pyx_t_31 < __pyx_t_20; __pyx_t_31+=1) {
        __pyx_v_jj = __pyx_t_31;
+126:                 indI[ii,jj] = <double>( nPhi0+jj )
        __pyx_t_54 = __pyx_v_ii;
        __pyx_t_55 = __pyx_v_jj;
        *__Pyx_BufPtrStrided2d(double *, __pyx_pybuffernd_indI.rcbuffer->pybuffer.buf, __pyx_t_54, __pyx_pybuffernd_indI.diminfo[0].strides, __pyx_t_55, __pyx_pybuffernd_indI.diminfo[1].strides) = ((double)(__pyx_v_nPhi0 + __pyx_v_jj));
      }
 127:         else:
 128:             #indI.append(list(range(nPhi0,NRPhi_int)+list(range(0,nPhi1+1))))
+129:             Phin[ii] = nPhi1+1+NRPhi_int-nPhi0
    /*else*/ {
      __pyx_t_56 = __pyx_v_ii;
      *((long *) ( /* dim=0 */ ((char *) (((long *) __pyx_v_Phin.data) + __pyx_t_56)) )) = (((__pyx_v_nPhi1 + 1) + __pyx_v_NRPhi_int) - __pyx_v_nPhi0);
+130:             if ii==0:
      __pyx_t_14 = ((__pyx_v_ii == 0) != 0);
      if (__pyx_t_14) {
/* … */
      }
+131:                 indI = np.ones((Rn,Phin[ii]*Rratio+1))
        __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 131, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_4);
        __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_ones); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 131, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_5);
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
        __pyx_t_4 = __Pyx_PyInt_From_int(__pyx_v_Rn); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 131, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_4);
        __pyx_t_57 = __pyx_v_ii;
        __pyx_t_1 = __Pyx_PyInt_From_long((((*((long *) ( /* dim=0 */ ((char *) (((long *) __pyx_v_Phin.data) + __pyx_t_57)) ))) * __pyx_v_Rratio) + 1)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 131, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_1);
        __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 131, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_3);
        __Pyx_GIVEREF(__pyx_t_4);
        PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_4);
        __Pyx_GIVEREF(__pyx_t_1);
        PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_t_1);
        __pyx_t_4 = 0;
        __pyx_t_1 = 0;
        __pyx_t_1 = NULL;
        if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_5))) {
          __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_5);
          if (likely(__pyx_t_1)) {
            PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5);
            __Pyx_INCREF(__pyx_t_1);
            __Pyx_INCREF(function);
            __Pyx_DECREF_SET(__pyx_t_5, function);
          }
        }
        if (!__pyx_t_1) {
          __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_5, __pyx_t_3); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 131, __pyx_L1_error)
          __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
          __Pyx_GOTREF(__pyx_t_2);
        } else {
          #if CYTHON_FAST_PYCALL
          if (PyFunction_Check(__pyx_t_5)) {
            PyObject *__pyx_temp[2] = {__pyx_t_1, __pyx_t_3};
            __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_5, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 131, __pyx_L1_error)
            __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
            __Pyx_GOTREF(__pyx_t_2);
            __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
          } else
          #endif
          #if CYTHON_FAST_PYCCALL
          if (__Pyx_PyFastCFunction_Check(__pyx_t_5)) {
            PyObject *__pyx_temp[2] = {__pyx_t_1, __pyx_t_3};
            __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_5, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 131, __pyx_L1_error)
            __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
            __Pyx_GOTREF(__pyx_t_2);
            __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
          } else
          #endif
          {
            __pyx_t_4 = PyTuple_New(1+1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 131, __pyx_L1_error)
            __Pyx_GOTREF(__pyx_t_4);
            __Pyx_GIVEREF(__pyx_t_1); PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_1); __pyx_t_1 = NULL;
            __Pyx_GIVEREF(__pyx_t_3);
            PyTuple_SET_ITEM(__pyx_t_4, 0+1, __pyx_t_3);
            __pyx_t_3 = 0;
            __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_t_4, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 131, __pyx_L1_error)
            __Pyx_GOTREF(__pyx_t_2);
            __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
          }
        }
        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
        if (!(likely(((__pyx_t_2) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_2, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 131, __pyx_L1_error)
        __pyx_t_49 = ((PyArrayObject *)__pyx_t_2);
        {
          __Pyx_BufFmt_StackElem __pyx_stack[1];
          __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_indI.rcbuffer->pybuffer);
          __pyx_t_31 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_indI.rcbuffer->pybuffer, (PyObject*)__pyx_t_49, &__Pyx_TypeInfo_double, PyBUF_FORMAT| PyBUF_STRIDES| PyBUF_WRITABLE, 2, 0, __pyx_stack);
          if (unlikely(__pyx_t_31 < 0)) {
            PyErr_Fetch(&__pyx_t_52, &__pyx_t_51, &__pyx_t_50);
            if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_indI.rcbuffer->pybuffer, (PyObject*)__pyx_v_indI, &__Pyx_TypeInfo_double, PyBUF_FORMAT| PyBUF_STRIDES| PyBUF_WRITABLE, 2, 0, __pyx_stack) == -1)) {
              Py_XDECREF(__pyx_t_52); Py_XDECREF(__pyx_t_51); Py_XDECREF(__pyx_t_50);
              __Pyx_RaiseBufferFallbackError();
            } else {
              PyErr_Restore(__pyx_t_52, __pyx_t_51, __pyx_t_50);
            }
          }
          __pyx_pybuffernd_indI.diminfo[0].strides = __pyx_pybuffernd_indI.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_indI.diminfo[0].shape = __pyx_pybuffernd_indI.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_indI.diminfo[1].strides = __pyx_pybuffernd_indI.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_indI.diminfo[1].shape = __pyx_pybuffernd_indI.rcbuffer->pybuffer.shape[1];
          if (unlikely(__pyx_t_31 < 0)) __PYX_ERR(0, 131, __pyx_L1_error)
        }
        __pyx_t_49 = 0;
        __Pyx_XDECREF_SET(__pyx_v_indI, ((PyArrayObject *)__pyx_t_2));
        __pyx_t_2 = 0;
+132:             for jj in range(0,NRPhi_int-nPhi0):
      __pyx_t_31 = (__pyx_v_NRPhi_int - __pyx_v_nPhi0);
      for (__pyx_t_32 = 0; __pyx_t_32 < __pyx_t_31; __pyx_t_32+=1) {
        __pyx_v_jj = __pyx_t_32;
+133:                 indI[ii,jj] = <double>( nPhi0+jj )
        __pyx_t_58 = __pyx_v_ii;
        __pyx_t_59 = __pyx_v_jj;
        *__Pyx_BufPtrStrided2d(double *, __pyx_pybuffernd_indI.rcbuffer->pybuffer.buf, __pyx_t_58, __pyx_pybuffernd_indI.diminfo[0].strides, __pyx_t_59, __pyx_pybuffernd_indI.diminfo[1].strides) = ((double)(__pyx_v_nPhi0 + __pyx_v_jj));
      }
+134:             for jj in range(NRPhi_int-nPhi0,Phin[ii]):
      __pyx_t_60 = __pyx_v_ii;
      __pyx_t_20 = (*((long *) ( /* dim=0 */ ((char *) (((long *) __pyx_v_Phin.data) + __pyx_t_60)) )));
      for (__pyx_t_31 = (__pyx_v_NRPhi_int - __pyx_v_nPhi0); __pyx_t_31 < __pyx_t_20; __pyx_t_31+=1) {
        __pyx_v_jj = __pyx_t_31;
+135:                 indI[ii,jj] = <double>( jj- (NRPhi_int-nPhi0) )
        __pyx_t_61 = __pyx_v_ii;
        __pyx_t_62 = __pyx_v_jj;
        *__Pyx_BufPtrStrided2d(double *, __pyx_pybuffernd_indI.rcbuffer->pybuffer.buf, __pyx_t_61, __pyx_pybuffernd_indI.diminfo[0].strides, __pyx_t_62, __pyx_pybuffernd_indI.diminfo[1].strides) = ((double)(__pyx_v_jj - (__pyx_v_NRPhi_int - __pyx_v_nPhi0)));
      }
    }
    __pyx_L17:;
+136:         NP += Zn*Phin[ii]
    __pyx_t_63 = __pyx_v_ii;
    __pyx_v_NP = (__pyx_v_NP + (__pyx_v_Zn * (*((long *) ( /* dim=0 */ ((char *) (((long *) __pyx_v_Phin.data) + __pyx_t_63)) )))));
  }
 137: 
+138:     Pts = np.empty((3,NP))
  __pyx_t_5 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 138, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_n_s_empty); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 138, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __pyx_t_5 = __Pyx_PyInt_From_int(__pyx_v_NP); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 138, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 138, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_INCREF(__pyx_int_3);
  __Pyx_GIVEREF(__pyx_int_3);
  PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_int_3);
  __Pyx_GIVEREF(__pyx_t_5);
  PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_t_5);
  __pyx_t_5 = 0;
  __pyx_t_5 = NULL;
  if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_4))) {
    __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_4);
    if (likely(__pyx_t_5)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
      __Pyx_INCREF(__pyx_t_5);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_4, function);
    }
  }
  if (!__pyx_t_5) {
    __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_3); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 138, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_GOTREF(__pyx_t_2);
  } else {
    #if CYTHON_FAST_PYCALL
    if (PyFunction_Check(__pyx_t_4)) {
      PyObject *__pyx_temp[2] = {__pyx_t_5, __pyx_t_3};
      __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_4, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 138, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    } else
    #endif
    #if CYTHON_FAST_PYCCALL
    if (__Pyx_PyFastCFunction_Check(__pyx_t_4)) {
      PyObject *__pyx_temp[2] = {__pyx_t_5, __pyx_t_3};
      __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_4, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 138, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    } else
    #endif
    {
      __pyx_t_1 = PyTuple_New(1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 138, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_5); __pyx_t_5 = NULL;
      __Pyx_GIVEREF(__pyx_t_3);
      PyTuple_SET_ITEM(__pyx_t_1, 0+1, __pyx_t_3);
      __pyx_t_3 = 0;
      __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_1, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 138, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    }
  }
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  if (!(likely(((__pyx_t_2) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_2, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 138, __pyx_L1_error)
  __pyx_t_49 = ((PyArrayObject *)__pyx_t_2);
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_Pts.rcbuffer->pybuffer);
    __pyx_t_19 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_Pts.rcbuffer->pybuffer, (PyObject*)__pyx_t_49, &__Pyx_TypeInfo_double, PyBUF_FORMAT| PyBUF_STRIDES| PyBUF_WRITABLE, 2, 0, __pyx_stack);
    if (unlikely(__pyx_t_19 < 0)) {
      PyErr_Fetch(&__pyx_t_50, &__pyx_t_51, &__pyx_t_52);
      if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_Pts.rcbuffer->pybuffer, (PyObject*)__pyx_v_Pts, &__Pyx_TypeInfo_double, PyBUF_FORMAT| PyBUF_STRIDES| PyBUF_WRITABLE, 2, 0, __pyx_stack) == -1)) {
        Py_XDECREF(__pyx_t_50); Py_XDECREF(__pyx_t_51); Py_XDECREF(__pyx_t_52);
        __Pyx_RaiseBufferFallbackError();
      } else {
        PyErr_Restore(__pyx_t_50, __pyx_t_51, __pyx_t_52);
      }
    }
    __pyx_pybuffernd_Pts.diminfo[0].strides = __pyx_pybuffernd_Pts.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_Pts.diminfo[0].shape = __pyx_pybuffernd_Pts.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_Pts.diminfo[1].strides = __pyx_pybuffernd_Pts.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_Pts.diminfo[1].shape = __pyx_pybuffernd_Pts.rcbuffer->pybuffer.shape[1];
    if (unlikely(__pyx_t_19 < 0)) __PYX_ERR(0, 138, __pyx_L1_error)
  }
  __pyx_t_49 = 0;
  __pyx_v_Pts = ((PyArrayObject *)__pyx_t_2);
  __pyx_t_2 = 0;
+139:     ind = np.empty((NP,))
  __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 139, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_empty); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 139, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_4 = __Pyx_PyInt_From_int(__pyx_v_NP); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 139, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 139, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_GIVEREF(__pyx_t_4);
  PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_4);
  __pyx_t_4 = 0;
  __pyx_t_4 = NULL;
  if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_1))) {
    __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_1);
    if (likely(__pyx_t_4)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1);
      __Pyx_INCREF(__pyx_t_4);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_1, function);
    }
  }
  if (!__pyx_t_4) {
    __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_1, __pyx_t_3); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 139, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_GOTREF(__pyx_t_2);
  } else {
    #if CYTHON_FAST_PYCALL
    if (PyFunction_Check(__pyx_t_1)) {
      PyObject *__pyx_temp[2] = {__pyx_t_4, __pyx_t_3};
      __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_1, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 139, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    } else
    #endif
    #if CYTHON_FAST_PYCCALL
    if (__Pyx_PyFastCFunction_Check(__pyx_t_1)) {
      PyObject *__pyx_temp[2] = {__pyx_t_4, __pyx_t_3};
      __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_1, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 139, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    } else
    #endif
    {
      __pyx_t_5 = PyTuple_New(1+1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 139, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_4); __pyx_t_4 = NULL;
      __Pyx_GIVEREF(__pyx_t_3);
      PyTuple_SET_ITEM(__pyx_t_5, 0+1, __pyx_t_3);
      __pyx_t_3 = 0;
      __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_5, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 139, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    }
  }
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (!(likely(((__pyx_t_2) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_2, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 139, __pyx_L1_error)
  __pyx_t_64 = ((PyArrayObject *)__pyx_t_2);
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_ind.rcbuffer->pybuffer);
    __pyx_t_19 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_ind.rcbuffer->pybuffer, (PyObject*)__pyx_t_64, &__Pyx_TypeInfo_double, PyBUF_FORMAT| PyBUF_STRIDES| PyBUF_WRITABLE, 1, 0, __pyx_stack);
    if (unlikely(__pyx_t_19 < 0)) {
      PyErr_Fetch(&__pyx_t_52, &__pyx_t_51, &__pyx_t_50);
      if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_ind.rcbuffer->pybuffer, (PyObject*)__pyx_v_ind, &__Pyx_TypeInfo_double, PyBUF_FORMAT| PyBUF_STRIDES| PyBUF_WRITABLE, 1, 0, __pyx_stack) == -1)) {
        Py_XDECREF(__pyx_t_52); Py_XDECREF(__pyx_t_51); Py_XDECREF(__pyx_t_50);
        __Pyx_RaiseBufferFallbackError();
      } else {
        PyErr_Restore(__pyx_t_52, __pyx_t_51, __pyx_t_50);
      }
    }
    __pyx_pybuffernd_ind.diminfo[0].strides = __pyx_pybuffernd_ind.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_ind.diminfo[0].shape = __pyx_pybuffernd_ind.rcbuffer->pybuffer.shape[0];
    if (unlikely(__pyx_t_19 < 0)) __PYX_ERR(0, 139, __pyx_L1_error)
  }
  __pyx_t_64 = 0;
  __pyx_v_ind = ((PyArrayObject *)__pyx_t_2);
  __pyx_t_2 = 0;
+140:     dV = np.empty((NP,))
  __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 140, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_empty); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 140, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_NP); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 140, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 140, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_GIVEREF(__pyx_t_1);
  PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_1);
  __pyx_t_1 = 0;
  __pyx_t_1 = NULL;
  if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_5))) {
    __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_5);
    if (likely(__pyx_t_1)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5);
      __Pyx_INCREF(__pyx_t_1);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_5, function);
    }
  }
  if (!__pyx_t_1) {
    __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_5, __pyx_t_3); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 140, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_GOTREF(__pyx_t_2);
  } else {
    #if CYTHON_FAST_PYCALL
    if (PyFunction_Check(__pyx_t_5)) {
      PyObject *__pyx_temp[2] = {__pyx_t_1, __pyx_t_3};
      __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_5, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 140, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    } else
    #endif
    #if CYTHON_FAST_PYCCALL
    if (__Pyx_PyFastCFunction_Check(__pyx_t_5)) {
      PyObject *__pyx_temp[2] = {__pyx_t_1, __pyx_t_3};
      __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_5, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 140, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    } else
    #endif
    {
      __pyx_t_4 = PyTuple_New(1+1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 140, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_GIVEREF(__pyx_t_1); PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_1); __pyx_t_1 = NULL;
      __Pyx_GIVEREF(__pyx_t_3);
      PyTuple_SET_ITEM(__pyx_t_4, 0+1, __pyx_t_3);
      __pyx_t_3 = 0;
      __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_t_4, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 140, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    }
  }
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  if (!(likely(((__pyx_t_2) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_2, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 140, __pyx_L1_error)
  __pyx_t_64 = ((PyArrayObject *)__pyx_t_2);
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_dV.rcbuffer->pybuffer);
    __pyx_t_19 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_dV.rcbuffer->pybuffer, (PyObject*)__pyx_t_64, &__Pyx_TypeInfo_double, PyBUF_FORMAT| PyBUF_STRIDES| PyBUF_WRITABLE, 1, 0, __pyx_stack);
    if (unlikely(__pyx_t_19 < 0)) {
      PyErr_Fetch(&__pyx_t_50, &__pyx_t_51, &__pyx_t_52);
      if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_dV.rcbuffer->pybuffer, (PyObject*)__pyx_v_dV, &__Pyx_TypeInfo_double, PyBUF_FORMAT| PyBUF_STRIDES| PyBUF_WRITABLE, 1, 0, __pyx_stack) == -1)) {
        Py_XDECREF(__pyx_t_50); Py_XDECREF(__pyx_t_51); Py_XDECREF(__pyx_t_52);
        __Pyx_RaiseBufferFallbackError();
      } else {
        PyErr_Restore(__pyx_t_50, __pyx_t_51, __pyx_t_52);
      }
    }
    __pyx_pybuffernd_dV.diminfo[0].strides = __pyx_pybuffernd_dV.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_dV.diminfo[0].shape = __pyx_pybuffernd_dV.rcbuffer->pybuffer.shape[0];
    if (unlikely(__pyx_t_19 < 0)) __PYX_ERR(0, 140, __pyx_L1_error)
  }
  __pyx_t_64 = 0;
  __pyx_v_dV = ((PyArrayObject *)__pyx_t_2);
  __pyx_t_2 = 0;
 141:     # Compute Pts, dV and ind
 142:     # This triple loop is the longest part, it takes ~90% of the CPU time
+143:     NP = 0
  __pyx_v_NP = 0;
+144:     if Out.lower()=='(x,y,z)':
  __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_v_Out, __pyx_n_s_lower); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 144, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_t_4 = NULL;
  if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_5))) {
    __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_5);
    if (likely(__pyx_t_4)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5);
      __Pyx_INCREF(__pyx_t_4);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_5, function);
    }
  }
  if (__pyx_t_4) {
    __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_5, __pyx_t_4); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 144, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  } else {
    __pyx_t_2 = __Pyx_PyObject_CallNoArg(__pyx_t_5); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 144, __pyx_L1_error)
  }
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __pyx_t_14 = (__Pyx_PyString_Equals(__pyx_t_2, __pyx_kp_s_x_y_z, Py_EQ)); if (unlikely(__pyx_t_14 < 0)) __PYX_ERR(0, 144, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  if (__pyx_t_14) {
/* … */
    goto __pyx_L26;
  }
+145:         for ii in range(0,Rn):
    __pyx_t_19 = __pyx_v_Rn;
    for (__pyx_t_11 = 0; __pyx_t_11 < __pyx_t_19; __pyx_t_11+=1) {
      __pyx_v_ii = __pyx_t_11;
+146:             for zz in range(0,Zn):
      __pyx_t_31 = __pyx_v_Zn;
      for (__pyx_t_32 = 0; __pyx_t_32 < __pyx_t_31; __pyx_t_32+=1) {
        __pyx_v_zz = __pyx_t_32;
+147:                 for jj in range(0,Phin[ii]):
        __pyx_t_65 = __pyx_v_ii;
        __pyx_t_20 = (*((long *) ( /* dim=0 */ ((char *) (((long *) __pyx_v_Phin.data) + __pyx_t_65)) )));
        for (__pyx_t_66 = 0; __pyx_t_66 < __pyx_t_20; __pyx_t_66+=1) {
          __pyx_v_jj = __pyx_t_66;
+148:                     indiijj = indI[ii,jj]
          __pyx_t_67 = __pyx_v_ii;
          __pyx_t_68 = __pyx_v_jj;
          __pyx_v_indiijj = (*__Pyx_BufPtrStrided2d(double *, __pyx_pybuffernd_indI.rcbuffer->pybuffer.buf, __pyx_t_67, __pyx_pybuffernd_indI.diminfo[0].strides, __pyx_t_68, __pyx_pybuffernd_indI.diminfo[1].strides));
+149:                     phi = -Cpi + (0.5+indiijj)*dPhir[ii]
          __pyx_t_69 = __pyx_v_ii;
          __pyx_v_phi = ((-M_PI) + ((0.5 + __pyx_v_indiijj) * (*((double *) ( /* dim=0 */ ((char *) (((double *) __pyx_v_dPhir.data) + __pyx_t_69)) )))));
+150:                     Pts[0,NP] = R[ii]*Ccos(phi)
          __pyx_t_70 = __pyx_v_ii;
          __pyx_t_71 = 0;
          __pyx_t_72 = __pyx_v_NP;
          *__Pyx_BufPtrStrided2d(double *, __pyx_pybuffernd_Pts.rcbuffer->pybuffer.buf, __pyx_t_71, __pyx_pybuffernd_Pts.diminfo[0].strides, __pyx_t_72, __pyx_pybuffernd_Pts.diminfo[1].strides) = ((*((double *) ( /* dim=0 */ ((char *) (((double *) __pyx_v_R.data) + __pyx_t_70)) ))) * cos(__pyx_v_phi));
+151:                     Pts[1,NP] = R[ii]*Csin(phi)
          __pyx_t_73 = __pyx_v_ii;
          __pyx_t_74 = 1;
          __pyx_t_75 = __pyx_v_NP;
          *__Pyx_BufPtrStrided2d(double *, __pyx_pybuffernd_Pts.rcbuffer->pybuffer.buf, __pyx_t_74, __pyx_pybuffernd_Pts.diminfo[0].strides, __pyx_t_75, __pyx_pybuffernd_Pts.diminfo[1].strides) = ((*((double *) ( /* dim=0 */ ((char *) (((double *) __pyx_v_R.data) + __pyx_t_73)) ))) * sin(__pyx_v_phi));
+152:                     Pts[2,NP] = Z[zz]
          __pyx_t_76 = __pyx_v_zz;
          __pyx_t_77 = 2;
          __pyx_t_78 = __pyx_v_NP;
          *__Pyx_BufPtrStrided2d(double *, __pyx_pybuffernd_Pts.rcbuffer->pybuffer.buf, __pyx_t_77, __pyx_pybuffernd_Pts.diminfo[0].strides, __pyx_t_78, __pyx_pybuffernd_Pts.diminfo[1].strides) = (*((double *) ( /* dim=0 */ ((char *) (((double *) __pyx_v_Z.data) + __pyx_t_76)) )));
+153:                     ind[NP] = NRPhi0[ii] + indZ[zz]*NRPhi[ii] + indiijj
          __pyx_t_79 = __pyx_v_ii;
          __pyx_t_80 = __pyx_v_zz;
          __pyx_t_81 = __pyx_v_ii;
          __pyx_t_82 = __pyx_v_NP;
          *__Pyx_BufPtrStrided1d(double *, __pyx_pybuffernd_ind.rcbuffer->pybuffer.buf, __pyx_t_82, __pyx_pybuffernd_ind.diminfo[0].strides) = (((*((long *) ( /* dim=0 */ ((char *) (((long *) __pyx_v_NRPhi0.data) + __pyx_t_79)) ))) + ((*((long *) ( /* dim=0 */ ((char *) (((long *) __pyx_v_indZ.data) + __pyx_t_80)) ))) * (*((double *) ( /* dim=0 */ ((char *) (((double *) __pyx_v_NRPhi.data) + __pyx_t_81)) ))))) + __pyx_v_indiijj);
+154:                     dV[NP] = dRr*dZr*dRPhir[ii]
          __pyx_t_83 = __pyx_v_ii;
          __pyx_t_84 = __pyx_v_NP;
          *__Pyx_BufPtrStrided1d(double *, __pyx_pybuffernd_dV.rcbuffer->pybuffer.buf, __pyx_t_84, __pyx_pybuffernd_dV.diminfo[0].strides) = ((__pyx_v_dRr * __pyx_v_dZr) * (*((double *) ( /* dim=0 */ ((char *) (((double *) __pyx_v_dRPhir.data) + __pyx_t_83)) ))));
+155:                     NP += 1
          __pyx_v_NP = (__pyx_v_NP + 1);
        }
      }
    }
 156:     else:
+157:         for ii in range(0,Rn):
  /*else*/ {
    __pyx_t_19 = __pyx_v_Rn;
    for (__pyx_t_11 = 0; __pyx_t_11 < __pyx_t_19; __pyx_t_11+=1) {
      __pyx_v_ii = __pyx_t_11;
+158:             for zz in range(0,Zn):
      __pyx_t_31 = __pyx_v_Zn;
      for (__pyx_t_32 = 0; __pyx_t_32 < __pyx_t_31; __pyx_t_32+=1) {
        __pyx_v_zz = __pyx_t_32;
+159:                 for jj in range(0,Phin[ii]):
        __pyx_t_85 = __pyx_v_ii;
        __pyx_t_20 = (*((long *) ( /* dim=0 */ ((char *) (((long *) __pyx_v_Phin.data) + __pyx_t_85)) )));
        for (__pyx_t_66 = 0; __pyx_t_66 < __pyx_t_20; __pyx_t_66+=1) {
          __pyx_v_jj = __pyx_t_66;
+160:                     indiijj = indI[ii,jj]
          __pyx_t_86 = __pyx_v_ii;
          __pyx_t_87 = __pyx_v_jj;
          __pyx_v_indiijj = (*__Pyx_BufPtrStrided2d(double *, __pyx_pybuffernd_indI.rcbuffer->pybuffer.buf, __pyx_t_86, __pyx_pybuffernd_indI.diminfo[0].strides, __pyx_t_87, __pyx_pybuffernd_indI.diminfo[1].strides));
+161:                     Pts[0,NP] = R[ii]
          __pyx_t_88 = __pyx_v_ii;
          __pyx_t_89 = 0;
          __pyx_t_90 = __pyx_v_NP;
          *__Pyx_BufPtrStrided2d(double *, __pyx_pybuffernd_Pts.rcbuffer->pybuffer.buf, __pyx_t_89, __pyx_pybuffernd_Pts.diminfo[0].strides, __pyx_t_90, __pyx_pybuffernd_Pts.diminfo[1].strides) = (*((double *) ( /* dim=0 */ ((char *) (((double *) __pyx_v_R.data) + __pyx_t_88)) )));
+162:                     Pts[1,NP] = Z[zz]
          __pyx_t_91 = __pyx_v_zz;
          __pyx_t_92 = 1;
          __pyx_t_93 = __pyx_v_NP;
          *__Pyx_BufPtrStrided2d(double *, __pyx_pybuffernd_Pts.rcbuffer->pybuffer.buf, __pyx_t_92, __pyx_pybuffernd_Pts.diminfo[0].strides, __pyx_t_93, __pyx_pybuffernd_Pts.diminfo[1].strides) = (*((double *) ( /* dim=0 */ ((char *) (((double *) __pyx_v_Z.data) + __pyx_t_91)) )));
+163:                     Pts[2,NP] = -Cpi + (0.5+indiijj)*dPhir[ii]
          __pyx_t_94 = __pyx_v_ii;
          __pyx_t_95 = 2;
          __pyx_t_96 = __pyx_v_NP;
          *__Pyx_BufPtrStrided2d(double *, __pyx_pybuffernd_Pts.rcbuffer->pybuffer.buf, __pyx_t_95, __pyx_pybuffernd_Pts.diminfo[0].strides, __pyx_t_96, __pyx_pybuffernd_Pts.diminfo[1].strides) = ((-M_PI) + ((0.5 + __pyx_v_indiijj) * (*((double *) ( /* dim=0 */ ((char *) (((double *) __pyx_v_dPhir.data) + __pyx_t_94)) )))));
+164:                     ind[NP] = NRPhi0[ii] + indZ[zz]*NRPhi[ii] + indiijj
          __pyx_t_97 = __pyx_v_ii;
          __pyx_t_98 = __pyx_v_zz;
          __pyx_t_99 = __pyx_v_ii;
          __pyx_t_100 = __pyx_v_NP;
          *__Pyx_BufPtrStrided1d(double *, __pyx_pybuffernd_ind.rcbuffer->pybuffer.buf, __pyx_t_100, __pyx_pybuffernd_ind.diminfo[0].strides) = (((*((long *) ( /* dim=0 */ ((char *) (((long *) __pyx_v_NRPhi0.data) + __pyx_t_97)) ))) + ((*((long *) ( /* dim=0 */ ((char *) (((long *) __pyx_v_indZ.data) + __pyx_t_98)) ))) * (*((double *) ( /* dim=0 */ ((char *) (((double *) __pyx_v_NRPhi.data) + __pyx_t_99)) ))))) + __pyx_v_indiijj);
+165:                     dV[NP] = dRr*dZr*dRPhir[ii]
          __pyx_t_101 = __pyx_v_ii;
          __pyx_t_102 = __pyx_v_NP;
          *__Pyx_BufPtrStrided1d(double *, __pyx_pybuffernd_dV.rcbuffer->pybuffer.buf, __pyx_t_102, __pyx_pybuffernd_dV.diminfo[0].strides) = ((__pyx_v_dRr * __pyx_v_dZr) * (*((double *) ( /* dim=0 */ ((char *) (((double *) __pyx_v_dRPhir.data) + __pyx_t_101)) ))));
+166:                     NP += 1
          __pyx_v_NP = (__pyx_v_NP + 1);
        }
      }
    }
  }
  __pyx_L26:;
 167: 
 168:     """
 169:     #if not VPoly is None:
 170:     #    indin = _Ves_isInside(VPoly, 'Tor', None, PtsRZP[:-1,:], In='(R,Z)')
 171:     #    PtsRZP, dV, ind = PtsRZP[:,indin], dV[indin], ind[indin]
 172:     #    Ru = np.unique(PtsRZP[0,:])
 173:     #    if not Ru==R:
 174:     #        indii = np.array([R[ii] in Ru for ii in range(0,len(R))], dtype=bool)
 175:     #        dRPhir = dRPhir[indii]
 176:     """
 177: 
+178:     return Pts, dV, ind.astype(int), dRr, dZr, np.asarray(dRPhir)
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_5 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_ind), __pyx_n_s_astype); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 178, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_t_4 = NULL;
  if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_5))) {
    __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_5);
    if (likely(__pyx_t_4)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5);
      __Pyx_INCREF(__pyx_t_4);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_5, function);
    }
  }
  if (!__pyx_t_4) {
    __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_5, ((PyObject *)(&PyInt_Type))); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 178, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
  } else {
    #if CYTHON_FAST_PYCALL
    if (PyFunction_Check(__pyx_t_5)) {
      PyObject *__pyx_temp[2] = {__pyx_t_4, ((PyObject *)(&PyInt_Type))};
      __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_5, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 178, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
      __Pyx_GOTREF(__pyx_t_2);
    } else
    #endif
    #if CYTHON_FAST_PYCCALL
    if (__Pyx_PyFastCFunction_Check(__pyx_t_5)) {
      PyObject *__pyx_temp[2] = {__pyx_t_4, ((PyObject *)(&PyInt_Type))};
      __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_5, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 178, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
      __Pyx_GOTREF(__pyx_t_2);
    } else
    #endif
    {
      __pyx_t_3 = PyTuple_New(1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 178, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_4); __pyx_t_4 = NULL;
      __Pyx_INCREF(((PyObject *)(&PyInt_Type)));
      __Pyx_GIVEREF(((PyObject *)(&PyInt_Type)));
      PyTuple_SET_ITEM(__pyx_t_3, 0+1, ((PyObject *)(&PyInt_Type)));
      __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_t_3, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 178, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    }
  }
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __pyx_t_5 = PyFloat_FromDouble(__pyx_v_dRr); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 178, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_t_3 = PyFloat_FromDouble(__pyx_v_dZr); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 178, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 178, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_asarray); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 178, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = __pyx_memoryview_fromslice(__pyx_v_dRPhir, 1, (PyObject *(*)(char *)) __pyx_memview_get_double, (int (*)(char *, PyObject *)) __pyx_memview_set_double, 0);; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 178, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_103 = NULL;
  if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_6))) {
    __pyx_t_103 = PyMethod_GET_SELF(__pyx_t_6);
    if (likely(__pyx_t_103)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6);
      __Pyx_INCREF(__pyx_t_103);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_6, function);
    }
  }
  if (!__pyx_t_103) {
    __pyx_t_4 = __Pyx_PyObject_CallOneArg(__pyx_t_6, __pyx_t_1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 178, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_GOTREF(__pyx_t_4);
  } else {
    #if CYTHON_FAST_PYCALL
    if (PyFunction_Check(__pyx_t_6)) {
      PyObject *__pyx_temp[2] = {__pyx_t_103, __pyx_t_1};
      __pyx_t_4 = __Pyx_PyFunction_FastCall(__pyx_t_6, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 178, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_103); __pyx_t_103 = 0;
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    } else
    #endif
    #if CYTHON_FAST_PYCCALL
    if (__Pyx_PyFastCFunction_Check(__pyx_t_6)) {
      PyObject *__pyx_temp[2] = {__pyx_t_103, __pyx_t_1};
      __pyx_t_4 = __Pyx_PyCFunction_FastCall(__pyx_t_6, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 178, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_103); __pyx_t_103 = 0;
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    } else
    #endif
    {
      __pyx_t_104 = PyTuple_New(1+1); if (unlikely(!__pyx_t_104)) __PYX_ERR(0, 178, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_104);
      __Pyx_GIVEREF(__pyx_t_103); PyTuple_SET_ITEM(__pyx_t_104, 0, __pyx_t_103); __pyx_t_103 = NULL;
      __Pyx_GIVEREF(__pyx_t_1);
      PyTuple_SET_ITEM(__pyx_t_104, 0+1, __pyx_t_1);
      __pyx_t_1 = 0;
      __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_6, __pyx_t_104, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 178, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF(__pyx_t_104); __pyx_t_104 = 0;
    }
  }
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  __pyx_t_6 = PyTuple_New(6); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 178, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_INCREF(((PyObject *)__pyx_v_Pts));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_Pts));
  PyTuple_SET_ITEM(__pyx_t_6, 0, ((PyObject *)__pyx_v_Pts));
  __Pyx_INCREF(((PyObject *)__pyx_v_dV));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_dV));
  PyTuple_SET_ITEM(__pyx_t_6, 1, ((PyObject *)__pyx_v_dV));
  __Pyx_GIVEREF(__pyx_t_2);
  PyTuple_SET_ITEM(__pyx_t_6, 2, __pyx_t_2);
  __Pyx_GIVEREF(__pyx_t_5);
  PyTuple_SET_ITEM(__pyx_t_6, 3, __pyx_t_5);
  __Pyx_GIVEREF(__pyx_t_3);
  PyTuple_SET_ITEM(__pyx_t_6, 4, __pyx_t_3);
  __Pyx_GIVEREF(__pyx_t_4);
  PyTuple_SET_ITEM(__pyx_t_6, 5, __pyx_t_4);
  __pyx_t_2 = 0;
  __pyx_t_5 = 0;
  __pyx_t_3 = 0;
  __pyx_t_4 = 0;
  __pyx_r = __pyx_t_6;
  __pyx_t_6 = 0;
  goto __pyx_L0;
 179: 
 180: @cython.cdivision(True)
 181: @cython.wraparound(False)
 182: @cython.boundscheck(False)
+183: def _Ves_Vmesh_Tor_SubFromInd_cython(double dR, double dZ, double dRPhi,
/* Python wrapper */
static PyObject *__pyx_pw_46_cython_magic_ffb7650808bb7830760fff8d6d047f13_5_Ves_Vmesh_Tor_SubFromInd_cython(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_46_cython_magic_ffb7650808bb7830760fff8d6d047f13_4_Ves_Vmesh_Tor_SubFromInd_cython[] = " Return the desired submesh indicated by the (numerical) indices, for the desired resolution (dR,dZ,dRphi) ";
static PyMethodDef __pyx_mdef_46_cython_magic_ffb7650808bb7830760fff8d6d047f13_5_Ves_Vmesh_Tor_SubFromInd_cython = {"_Ves_Vmesh_Tor_SubFromInd_cython", (PyCFunction)__pyx_pw_46_cython_magic_ffb7650808bb7830760fff8d6d047f13_5_Ves_Vmesh_Tor_SubFromInd_cython, METH_VARARGS|METH_KEYWORDS, __pyx_doc_46_cython_magic_ffb7650808bb7830760fff8d6d047f13_4_Ves_Vmesh_Tor_SubFromInd_cython};
static PyObject *__pyx_pw_46_cython_magic_ffb7650808bb7830760fff8d6d047f13_5_Ves_Vmesh_Tor_SubFromInd_cython(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  double __pyx_v_dR;
  double __pyx_v_dZ;
  double __pyx_v_dRPhi;
  __Pyx_memviewslice __pyx_v_RMinMax = { 0, 0, { 0 }, { 0 }, { 0 } };
  __Pyx_memviewslice __pyx_v_ZMinMax = { 0, 0, { 0 }, { 0 }, { 0 } };
  __Pyx_memviewslice __pyx_v_ind = { 0, 0, { 0 }, { 0 }, { 0 } };
  PyObject *__pyx_v_Out = 0;
  double __pyx_v_margin;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("_Ves_Vmesh_Tor_SubFromInd_cython (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_dR,&__pyx_n_s_dZ,&__pyx_n_s_dRPhi,&__pyx_n_s_RMinMax,&__pyx_n_s_ZMinMax,&__pyx_n_s_ind,&__pyx_n_s_Out,&__pyx_n_s_margin,0};
    PyObject* values[8] = {0,0,0,0,0,0,0,0};
    values[6] = ((PyObject*)__pyx_kp_s_X_Y_Z);
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  8: values[7] = PyTuple_GET_ITEM(__pyx_args, 7);
        case  7: values[6] = PyTuple_GET_ITEM(__pyx_args, 6);
        case  6: values[5] = PyTuple_GET_ITEM(__pyx_args, 5);
        case  5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_dR)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        case  1:
        if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_dZ)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_Ves_Vmesh_Tor_SubFromInd_cython", 0, 6, 8, 1); __PYX_ERR(0, 183, __pyx_L3_error)
        }
        case  2:
        if (likely((values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_dRPhi)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_Ves_Vmesh_Tor_SubFromInd_cython", 0, 6, 8, 2); __PYX_ERR(0, 183, __pyx_L3_error)
        }
        case  3:
        if (likely((values[3] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_RMinMax)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_Ves_Vmesh_Tor_SubFromInd_cython", 0, 6, 8, 3); __PYX_ERR(0, 183, __pyx_L3_error)
        }
        case  4:
        if (likely((values[4] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_ZMinMax)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_Ves_Vmesh_Tor_SubFromInd_cython", 0, 6, 8, 4); __PYX_ERR(0, 183, __pyx_L3_error)
        }
        case  5:
        if (likely((values[5] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_ind)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_Ves_Vmesh_Tor_SubFromInd_cython", 0, 6, 8, 5); __PYX_ERR(0, 183, __pyx_L3_error)
        }
        case  6:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_Out);
          if (value) { values[6] = value; kw_args--; }
        }
        case  7:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_margin);
          if (value) { values[7] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "_Ves_Vmesh_Tor_SubFromInd_cython") < 0)) __PYX_ERR(0, 183, __pyx_L3_error)
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  8: values[7] = PyTuple_GET_ITEM(__pyx_args, 7);
        case  7: values[6] = PyTuple_GET_ITEM(__pyx_args, 6);
        case  6: values[5] = PyTuple_GET_ITEM(__pyx_args, 5);
        values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
        values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    __pyx_v_dR = __pyx_PyFloat_AsDouble(values[0]); if (unlikely((__pyx_v_dR == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 183, __pyx_L3_error)
    __pyx_v_dZ = __pyx_PyFloat_AsDouble(values[1]); if (unlikely((__pyx_v_dZ == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 183, __pyx_L3_error)
    __pyx_v_dRPhi = __pyx_PyFloat_AsDouble(values[2]); if (unlikely((__pyx_v_dRPhi == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 183, __pyx_L3_error)
    __pyx_v_RMinMax = __Pyx_PyObject_to_MemoryviewSlice_dc_double(values[3]); if (unlikely(!__pyx_v_RMinMax.memview)) __PYX_ERR(0, 184, __pyx_L3_error)
    __pyx_v_ZMinMax = __Pyx_PyObject_to_MemoryviewSlice_dc_double(values[4]); if (unlikely(!__pyx_v_ZMinMax.memview)) __PYX_ERR(0, 184, __pyx_L3_error)
    __pyx_v_ind = __Pyx_PyObject_to_MemoryviewSlice_dc_long(values[5]); if (unlikely(!__pyx_v_ind.memview)) __PYX_ERR(0, 184, __pyx_L3_error)
    __pyx_v_Out = ((PyObject*)values[6]);
    if (values[7]) {
      __pyx_v_margin = __pyx_PyFloat_AsDouble(values[7]); if (unlikely((__pyx_v_margin == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 185, __pyx_L3_error)
    } else {
      __pyx_v_margin = ((double)1.e-9);
    }
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("_Ves_Vmesh_Tor_SubFromInd_cython", 0, 6, 8, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 183, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("_cython_magic_ffb7650808bb7830760fff8d6d047f13._Ves_Vmesh_Tor_SubFromInd_cython", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_Out), (&PyString_Type), 1, "Out", 1))) __PYX_ERR(0, 185, __pyx_L1_error)
  __pyx_r = __pyx_pf_46_cython_magic_ffb7650808bb7830760fff8d6d047f13_4_Ves_Vmesh_Tor_SubFromInd_cython(__pyx_self, __pyx_v_dR, __pyx_v_dZ, __pyx_v_dRPhi, __pyx_v_RMinMax, __pyx_v_ZMinMax, __pyx_v_ind, __pyx_v_Out, __pyx_v_margin);

  /* function exit code */
  goto __pyx_L0;
  __pyx_L1_error:;
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_46_cython_magic_ffb7650808bb7830760fff8d6d047f13_4_Ves_Vmesh_Tor_SubFromInd_cython(CYTHON_UNUSED PyObject *__pyx_self, double __pyx_v_dR, double __pyx_v_dZ, double __pyx_v_dRPhi, __Pyx_memviewslice __pyx_v_RMinMax, __Pyx_memviewslice __pyx_v_ZMinMax, __Pyx_memviewslice __pyx_v_ind, PyObject *__pyx_v_Out, double __pyx_v_margin) {
  __Pyx_memviewslice __pyx_v_R = { 0, 0, { 0 }, { 0 }, { 0 } };
  __Pyx_memviewslice __pyx_v_Z = { 0, 0, { 0 }, { 0 }, { 0 } };
  __Pyx_memviewslice __pyx_v_dRPhirRef = { 0, 0, { 0 }, { 0 }, { 0 } };
  __Pyx_memviewslice __pyx_v_dPhir = { 0, 0, { 0 }, { 0 }, { 0 } };
  __Pyx_memviewslice __pyx_v_Ru = { 0, 0, { 0 }, { 0 }, { 0 } };
  __Pyx_memviewslice __pyx_v_dRPhir = { 0, 0, { 0 }, { 0 }, { 0 } };
  double __pyx_v_dRr;
  double __pyx_v_dZr;
  double __pyx_v_phi;
  CYTHON_UNUSED __Pyx_memviewslice __pyx_v_indR = { 0, 0, { 0 }, { 0 }, { 0 } };
  CYTHON_UNUSED __Pyx_memviewslice __pyx_v_indZ = { 0, 0, { 0 }, { 0 }, { 0 } };
  __Pyx_memviewslice __pyx_v_NRPhi0 = { 0, 0, { 0 }, { 0 }, { 0 } };
  __Pyx_memviewslice __pyx_v_NRPhi = { 0, 0, { 0 }, { 0 }, { 0 } };
  long __pyx_v_NR;
  long __pyx_v_NZ;
  CYTHON_UNUSED long __pyx_v_Rn;
  CYTHON_UNUSED long __pyx_v_Zn;
  long __pyx_v_NP;
  long __pyx_v_Rratio;
  int __pyx_v_ii;
  int __pyx_v_jj;
  int __pyx_v_iiR;
  int __pyx_v_iiZ;
  int __pyx_v_iiphi;
  __Pyx_memviewslice __pyx_v_Phi = { 0, 0, { 0 }, { 0 }, { 0 } };
  PyArrayObject *__pyx_v_Pts = 0;
  PyArrayObject *__pyx_v_dV = 0;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_Pts;
  __Pyx_Buffer __pyx_pybuffer_Pts;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_dV;
  __Pyx_Buffer __pyx_pybuffer_dV;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("_Ves_Vmesh_Tor_SubFromInd_cython", 0);
  __pyx_pybuffer_Pts.pybuffer.buf = NULL;
  __pyx_pybuffer_Pts.refcount = 0;
  __pyx_pybuffernd_Pts.data = NULL;
  __pyx_pybuffernd_Pts.rcbuffer = &__pyx_pybuffer_Pts;
  __pyx_pybuffer_dV.pybuffer.buf = NULL;
  __pyx_pybuffer_dV.refcount = 0;
  __pyx_pybuffernd_dV.data = NULL;
  __pyx_pybuffernd_dV.rcbuffer = &__pyx_pybuffer_dV;
/* … */
  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_9);
  __PYX_XDEC_MEMVIEW(&__pyx_t_11, 1);
  __PYX_XDEC_MEMVIEW(&__pyx_t_13, 1);
  __PYX_XDEC_MEMVIEW(&__pyx_t_16, 1);
  __PYX_XDEC_MEMVIEW(&__pyx_t_17, 1);
  __PYX_XDEC_MEMVIEW(&__pyx_t_31, 1);
  __Pyx_XDECREF(__pyx_t_90);
  __Pyx_XDECREF(__pyx_t_91);
  { PyObject *__pyx_type, *__pyx_value, *__pyx_tb;
    __Pyx_PyThreadState_declare
    __Pyx_PyThreadState_assign
    __Pyx_ErrFetch(&__pyx_type, &__pyx_value, &__pyx_tb);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_Pts.rcbuffer->pybuffer);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_dV.rcbuffer->pybuffer);
  __Pyx_ErrRestore(__pyx_type, __pyx_value, __pyx_tb);}
  __Pyx_AddTraceback("_cython_magic_ffb7650808bb7830760fff8d6d047f13._Ves_Vmesh_Tor_SubFromInd_cython", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  goto __pyx_L2;
  __pyx_L0:;
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_Pts.rcbuffer->pybuffer);
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_dV.rcbuffer->pybuffer);
  __pyx_L2:;
  __PYX_XDEC_MEMVIEW(&__pyx_v_R, 1);
  __PYX_XDEC_MEMVIEW(&__pyx_v_Z, 1);
  __PYX_XDEC_MEMVIEW(&__pyx_v_dRPhirRef, 1);
  __PYX_XDEC_MEMVIEW(&__pyx_v_dPhir, 1);
  __PYX_XDEC_MEMVIEW(&__pyx_v_Ru, 1);
  __PYX_XDEC_MEMVIEW(&__pyx_v_dRPhir, 1);
  __PYX_XDEC_MEMVIEW(&__pyx_v_indR, 1);
  __PYX_XDEC_MEMVIEW(&__pyx_v_indZ, 1);
  __PYX_XDEC_MEMVIEW(&__pyx_v_NRPhi0, 1);
  __PYX_XDEC_MEMVIEW(&__pyx_v_NRPhi, 1);
  __PYX_XDEC_MEMVIEW(&__pyx_v_Phi, 1);
  __Pyx_XDECREF((PyObject *)__pyx_v_Pts);
  __Pyx_XDECREF((PyObject *)__pyx_v_dV);
  __PYX_XDEC_MEMVIEW(&__pyx_v_RMinMax, 1);
  __PYX_XDEC_MEMVIEW(&__pyx_v_ZMinMax, 1);
  __PYX_XDEC_MEMVIEW(&__pyx_v_ind, 1);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}
/* … */
  __pyx_tuple__27 = PyTuple_Pack(35, __pyx_n_s_dR, __pyx_n_s_dZ, __pyx_n_s_dRPhi, __pyx_n_s_RMinMax, __pyx_n_s_ZMinMax, __pyx_n_s_ind, __pyx_n_s_Out, __pyx_n_s_margin, __pyx_n_s_R, __pyx_n_s_Z, __pyx_n_s_dRPhirRef, __pyx_n_s_dPhir, __pyx_n_s_Ru, __pyx_n_s_dRPhir, __pyx_n_s_dRr, __pyx_n_s_dZr, __pyx_n_s_phi, __pyx_n_s_indR, __pyx_n_s_indZ, __pyx_n_s_NRPhi0, __pyx_n_s_NRPhi, __pyx_n_s_NR, __pyx_n_s_NZ, __pyx_n_s_Rn, __pyx_n_s_Zn, __pyx_n_s_NP, __pyx_n_s_Rratio, __pyx_n_s_ii, __pyx_n_s_jj, __pyx_n_s_iiR, __pyx_n_s_iiZ, __pyx_n_s_iiphi, __pyx_n_s_Phi, __pyx_n_s_Pts, __pyx_n_s_dV); if (unlikely(!__pyx_tuple__27)) __PYX_ERR(0, 183, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__27);
  __Pyx_GIVEREF(__pyx_tuple__27);
/* … */
  __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_46_cython_magic_ffb7650808bb7830760fff8d6d047f13_5_Ves_Vmesh_Tor_SubFromInd_cython, NULL, __pyx_n_s_cython_magic_ffb7650808bb783076); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 183, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_Ves_Vmesh_Tor_SubFromInd_cython, __pyx_t_1) < 0) __PYX_ERR(0, 183, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_codeobj__28 = (PyObject*)__Pyx_PyCode_New(8, 0, 35, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__27, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_Home_DV226270_cache_ipython_cyt, __pyx_n_s_Ves_Vmesh_Tor_SubFromInd_cython, 183, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__28)) __PYX_ERR(0, 183, __pyx_L1_error)
 184:                                      double[::1] RMinMax, double[::1] ZMinMax, long[::1] ind,
 185:                                      str Out='(X,Y,Z)', double margin=1.e-9):
 186:     """ Return the desired submesh indicated by the (numerical) indices, for the desired resolution (dR,dZ,dRphi) """
 187:     cdef double[::1] R, Z, dRPhirRef, dPhir, Ru, dRPhir
 188:     cdef double dRr, dZr, phi
 189:     cdef long[::1] indR, indZ, NRPhi0, NRPhi
+190:     cdef long NR, NZ, Rn, Zn, NP=len(ind), Rratio
  __pyx_t_1 = __pyx_memoryview_fromslice(__pyx_v_ind, 1, (PyObject *(*)(char *)) __pyx_memview_get_long, (int (*)(char *, PyObject *)) __pyx_memview_set_long, 0);; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 190, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PyObject_Length(__pyx_t_1); if (unlikely(__pyx_t_2 == -1)) __PYX_ERR(0, 190, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v_NP = __pyx_t_2;
 191:     cdef int ii, jj, iiR, iiZ, iiphi
 192:     cdef double[:,::1] Phi
+193:     cdef cnp.ndarray[double,ndim=2] Pts=np.empty((3,NP))
  __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 193, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_empty); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 193, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_3 = __Pyx_PyInt_From_long(__pyx_v_NP); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 193, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_5 = PyTuple_New(2); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 193, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_INCREF(__pyx_int_3);
  __Pyx_GIVEREF(__pyx_int_3);
  PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_int_3);
  __Pyx_GIVEREF(__pyx_t_3);
  PyTuple_SET_ITEM(__pyx_t_5, 1, __pyx_t_3);
  __pyx_t_3 = 0;
  __pyx_t_3 = NULL;
  if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_4))) {
    __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_4);
    if (likely(__pyx_t_3)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
      __Pyx_INCREF(__pyx_t_3);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_4, function);
    }
  }
  if (!__pyx_t_3) {
    __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_5); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 193, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_GOTREF(__pyx_t_1);
  } else {
    #if CYTHON_FAST_PYCALL
    if (PyFunction_Check(__pyx_t_4)) {
      PyObject *__pyx_temp[2] = {__pyx_t_3, __pyx_t_5};
      __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_4, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 193, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    } else
    #endif
    #if CYTHON_FAST_PYCCALL
    if (__Pyx_PyFastCFunction_Check(__pyx_t_4)) {
      PyObject *__pyx_temp[2] = {__pyx_t_3, __pyx_t_5};
      __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_4, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 193, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    } else
    #endif
    {
      __pyx_t_6 = PyTuple_New(1+1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 193, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_6);
      __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_3); __pyx_t_3 = NULL;
      __Pyx_GIVEREF(__pyx_t_5);
      PyTuple_SET_ITEM(__pyx_t_6, 0+1, __pyx_t_5);
      __pyx_t_5 = 0;
      __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_6, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 193, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    }
  }
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 193, __pyx_L1_error)
  __pyx_t_7 = ((PyArrayObject *)__pyx_t_1);
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_Pts.rcbuffer->pybuffer, (PyObject*)__pyx_t_7, &__Pyx_TypeInfo_double, PyBUF_FORMAT| PyBUF_STRIDES| PyBUF_WRITABLE, 2, 0, __pyx_stack) == -1)) {
      __pyx_v_Pts = ((PyArrayObject *)Py_None); __Pyx_INCREF(Py_None); __pyx_pybuffernd_Pts.rcbuffer->pybuffer.buf = NULL;
      __PYX_ERR(0, 193, __pyx_L1_error)
    } else {__pyx_pybuffernd_Pts.diminfo[0].strides = __pyx_pybuffernd_Pts.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_Pts.diminfo[0].shape = __pyx_pybuffernd_Pts.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_Pts.diminfo[1].strides = __pyx_pybuffernd_Pts.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_Pts.diminfo[1].shape = __pyx_pybuffernd_Pts.rcbuffer->pybuffer.shape[1];
    }
  }
  __pyx_t_7 = 0;
  __pyx_v_Pts = ((PyArrayObject *)__pyx_t_1);
  __pyx_t_1 = 0;
+194:     cdef cnp.ndarray[double,ndim=1] dV=np.empty((NP,))
  __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 194, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_empty); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 194, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_4 = __Pyx_PyInt_From_long(__pyx_v_NP); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 194, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_5 = PyTuple_New(1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 194, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_GIVEREF(__pyx_t_4);
  PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_4);
  __pyx_t_4 = 0;
  __pyx_t_4 = NULL;
  if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_6))) {
    __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_6);
    if (likely(__pyx_t_4)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6);
      __Pyx_INCREF(__pyx_t_4);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_6, function);
    }
  }
  if (!__pyx_t_4) {
    __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_6, __pyx_t_5); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 194, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_GOTREF(__pyx_t_1);
  } else {
    #if CYTHON_FAST_PYCALL
    if (PyFunction_Check(__pyx_t_6)) {
      PyObject *__pyx_temp[2] = {__pyx_t_4, __pyx_t_5};
      __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_6, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 194, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    } else
    #endif
    #if CYTHON_FAST_PYCCALL
    if (__Pyx_PyFastCFunction_Check(__pyx_t_6)) {
      PyObject *__pyx_temp[2] = {__pyx_t_4, __pyx_t_5};
      __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_6, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 194, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    } else
    #endif
    {
      __pyx_t_3 = PyTuple_New(1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 194, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_4); __pyx_t_4 = NULL;
      __Pyx_GIVEREF(__pyx_t_5);
      PyTuple_SET_ITEM(__pyx_t_3, 0+1, __pyx_t_5);
      __pyx_t_5 = 0;
      __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_6, __pyx_t_3, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 194, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    }
  }
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 194, __pyx_L1_error)
  __pyx_t_8 = ((PyArrayObject *)__pyx_t_1);
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_dV.rcbuffer->pybuffer, (PyObject*)__pyx_t_8, &__Pyx_TypeInfo_double, PyBUF_FORMAT| PyBUF_STRIDES| PyBUF_WRITABLE, 1, 0, __pyx_stack) == -1)) {
      __pyx_v_dV = ((PyArrayObject *)Py_None); __Pyx_INCREF(Py_None); __pyx_pybuffernd_dV.rcbuffer->pybuffer.buf = NULL;
      __PYX_ERR(0, 194, __pyx_L1_error)
    } else {__pyx_pybuffernd_dV.diminfo[0].strides = __pyx_pybuffernd_dV.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_dV.diminfo[0].shape = __pyx_pybuffernd_dV.rcbuffer->pybuffer.shape[0];
    }
  }
  __pyx_t_8 = 0;
  __pyx_v_dV = ((PyArrayObject *)__pyx_t_1);
  __pyx_t_1 = 0;
 195: 
 196:     # Get the actual R and Z resolutions and mesh elements
+197:     R, dRr, indR, NR = _Ves_mesh_dlfromL_cython(RMinMax, dR, None, margin=margin)
  __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_Ves_mesh_dlfromL_cython); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 197, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_6 = __pyx_memoryview_fromslice(__pyx_v_RMinMax, 1, (PyObject *(*)(char *)) __pyx_memview_get_double, (int (*)(char *, PyObject *)) __pyx_memview_set_double, 0);; if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 197, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __pyx_t_3 = PyFloat_FromDouble(__pyx_v_dR); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 197, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_5 = PyTuple_New(3); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 197, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_GIVEREF(__pyx_t_6);
  PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_6);
  __Pyx_GIVEREF(__pyx_t_3);
  PyTuple_SET_ITEM(__pyx_t_5, 1, __pyx_t_3);
  __Pyx_INCREF(Py_None);
  __Pyx_GIVEREF(Py_None);
  PyTuple_SET_ITEM(__pyx_t_5, 2, Py_None);
  __pyx_t_6 = 0;
  __pyx_t_3 = 0;
  __pyx_t_3 = PyDict_New(); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 197, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_6 = PyFloat_FromDouble(__pyx_v_margin); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 197, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_margin, __pyx_t_6) < 0) __PYX_ERR(0, 197, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  __pyx_t_6 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_5, __pyx_t_3); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 197, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  if ((likely(PyTuple_CheckExact(__pyx_t_6))) || (PyList_CheckExact(__pyx_t_6))) {
    PyObject* sequence = __pyx_t_6;
    #if !CYTHON_COMPILING_IN_PYPY
    Py_ssize_t size = Py_SIZE(sequence);
    #else
    Py_ssize_t size = PySequence_Size(sequence);
    #endif
    if (unlikely(size != 4)) {
      if (size > 4) __Pyx_RaiseTooManyValuesError(4);
      else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
      __PYX_ERR(0, 197, __pyx_L1_error)
    }
    #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
    if (likely(PyTuple_CheckExact(sequence))) {
      __pyx_t_3 = PyTuple_GET_ITEM(sequence, 0); 
      __pyx_t_5 = PyTuple_GET_ITEM(sequence, 1); 
      __pyx_t_1 = PyTuple_GET_ITEM(sequence, 2); 
      __pyx_t_4 = PyTuple_GET_ITEM(sequence, 3); 
    } else {
      __pyx_t_3 = PyList_GET_ITEM(sequence, 0); 
      __pyx_t_5 = PyList_GET_ITEM(sequence, 1); 
      __pyx_t_1 = PyList_GET_ITEM(sequence, 2); 
      __pyx_t_4 = PyList_GET_ITEM(sequence, 3); 
    }
    __Pyx_INCREF(__pyx_t_3);
    __Pyx_INCREF(__pyx_t_5);
    __Pyx_INCREF(__pyx_t_1);
    __Pyx_INCREF(__pyx_t_4);
    #else
    {
      Py_ssize_t i;
      PyObject** temps[4] = {&__pyx_t_3,&__pyx_t_5,&__pyx_t_1,&__pyx_t_4};
      for (i=0; i < 4; i++) {
        PyObject* item = PySequence_ITEM(sequence, i); if (unlikely(!item)) __PYX_ERR(0, 197, __pyx_L1_error)
        __Pyx_GOTREF(item);
        *(temps[i]) = item;
      }
    }
    #endif
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  } else {
    Py_ssize_t index = -1;
    PyObject** temps[4] = {&__pyx_t_3,&__pyx_t_5,&__pyx_t_1,&__pyx_t_4};
    __pyx_t_9 = PyObject_GetIter(__pyx_t_6); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 197, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_9);
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __pyx_t_10 = Py_TYPE(__pyx_t_9)->tp_iternext;
    for (index=0; index < 4; index++) {
      PyObject* item = __pyx_t_10(__pyx_t_9); if (unlikely(!item)) goto __pyx_L3_unpacking_failed;
      __Pyx_GOTREF(item);
      *(temps[index]) = item;
    }
    if (__Pyx_IternextUnpackEndCheck(__pyx_t_10(__pyx_t_9), 4) < 0) __PYX_ERR(0, 197, __pyx_L1_error)
    __pyx_t_10 = NULL;
    __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
    goto __pyx_L4_unpacking_done;
    __pyx_L3_unpacking_failed:;
    __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
    __pyx_t_10 = NULL;
    if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
    __PYX_ERR(0, 197, __pyx_L1_error)
    __pyx_L4_unpacking_done:;
  }
  __pyx_t_11 = __Pyx_PyObject_to_MemoryviewSlice_dc_double(__pyx_t_3);
  if (unlikely(!__pyx_t_11.memview)) __PYX_ERR(0, 197, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_12 = __pyx_PyFloat_AsDouble(__pyx_t_5); if (unlikely((__pyx_t_12 == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 197, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __pyx_t_13 = __Pyx_PyObject_to_MemoryviewSlice_dc_long(__pyx_t_1);
  if (unlikely(!__pyx_t_13.memview)) __PYX_ERR(0, 197, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_14 = __Pyx_PyInt_As_long(__pyx_t_4); if (unlikely((__pyx_t_14 == (long)-1) && PyErr_Occurred())) __PYX_ERR(0, 197, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_v_R = __pyx_t_11;
  __pyx_t_11.memview = NULL;
  __pyx_t_11.data = NULL;
  __pyx_v_dRr = __pyx_t_12;
  __pyx_v_indR = __pyx_t_13;
  __pyx_t_13.memview = NULL;
  __pyx_t_13.data = NULL;
  __pyx_v_NR = __pyx_t_14;
+198:     Z, dZr, indZ, NZ = _Ves_mesh_dlfromL_cython(ZMinMax, dZ, None, margin=margin)
  __pyx_t_6 = __Pyx_GetModuleGlobalName(__pyx_n_s_Ves_mesh_dlfromL_cython); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 198, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __pyx_t_4 = __pyx_memoryview_fromslice(__pyx_v_ZMinMax, 1, (PyObject *(*)(char *)) __pyx_memview_get_double, (int (*)(char *, PyObject *)) __pyx_memview_set_double, 0);; if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 198, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_1 = PyFloat_FromDouble(__pyx_v_dZ); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 198, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_5 = PyTuple_New(3); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 198, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_GIVEREF(__pyx_t_4);
  PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_4);
  __Pyx_GIVEREF(__pyx_t_1);
  PyTuple_SET_ITEM(__pyx_t_5, 1, __pyx_t_1);
  __Pyx_INCREF(Py_None);
  __Pyx_GIVEREF(Py_None);
  PyTuple_SET_ITEM(__pyx_t_5, 2, Py_None);
  __pyx_t_4 = 0;
  __pyx_t_1 = 0;
  __pyx_t_1 = PyDict_New(); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 198, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_4 = PyFloat_FromDouble(__pyx_v_margin); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 198, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_margin, __pyx_t_4) < 0) __PYX_ERR(0, 198, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_6, __pyx_t_5, __pyx_t_1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 198, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if ((likely(PyTuple_CheckExact(__pyx_t_4))) || (PyList_CheckExact(__pyx_t_4))) {
    PyObject* sequence = __pyx_t_4;
    #if !CYTHON_COMPILING_IN_PYPY
    Py_ssize_t size = Py_SIZE(sequence);
    #else
    Py_ssize_t size = PySequence_Size(sequence);
    #endif
    if (unlikely(size != 4)) {
      if (size > 4) __Pyx_RaiseTooManyValuesError(4);
      else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
      __PYX_ERR(0, 198, __pyx_L1_error)
    }
    #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
    if (likely(PyTuple_CheckExact(sequence))) {
      __pyx_t_1 = PyTuple_GET_ITEM(sequence, 0); 
      __pyx_t_5 = PyTuple_GET_ITEM(sequence, 1); 
      __pyx_t_6 = PyTuple_GET_ITEM(sequence, 2); 
      __pyx_t_3 = PyTuple_GET_ITEM(sequence, 3); 
    } else {
      __pyx_t_1 = PyList_GET_ITEM(sequence, 0); 
      __pyx_t_5 = PyList_GET_ITEM(sequence, 1); 
      __pyx_t_6 = PyList_GET_ITEM(sequence, 2); 
      __pyx_t_3 = PyList_GET_ITEM(sequence, 3); 
    }
    __Pyx_INCREF(__pyx_t_1);
    __Pyx_INCREF(__pyx_t_5);
    __Pyx_INCREF(__pyx_t_6);
    __Pyx_INCREF(__pyx_t_3);
    #else
    {
      Py_ssize_t i;
      PyObject** temps[4] = {&__pyx_t_1,&__pyx_t_5,&__pyx_t_6,&__pyx_t_3};
      for (i=0; i < 4; i++) {
        PyObject* item = PySequence_ITEM(sequence, i); if (unlikely(!item)) __PYX_ERR(0, 198, __pyx_L1_error)
        __Pyx_GOTREF(item);
        *(temps[i]) = item;
      }
    }
    #endif
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  } else {
    Py_ssize_t index = -1;
    PyObject** temps[4] = {&__pyx_t_1,&__pyx_t_5,&__pyx_t_6,&__pyx_t_3};
    __pyx_t_9 = PyObject_GetIter(__pyx_t_4); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 198, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_9);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_t_10 = Py_TYPE(__pyx_t_9)->tp_iternext;
    for (index=0; index < 4; index++) {
      PyObject* item = __pyx_t_10(__pyx_t_9); if (unlikely(!item)) goto __pyx_L5_unpacking_failed;
      __Pyx_GOTREF(item);
      *(temps[index]) = item;
    }
    if (__Pyx_IternextUnpackEndCheck(__pyx_t_10(__pyx_t_9), 4) < 0) __PYX_ERR(0, 198, __pyx_L1_error)
    __pyx_t_10 = NULL;
    __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
    goto __pyx_L6_unpacking_done;
    __pyx_L5_unpacking_failed:;
    __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
    __pyx_t_10 = NULL;
    if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
    __PYX_ERR(0, 198, __pyx_L1_error)
    __pyx_L6_unpacking_done:;
  }
  __pyx_t_11 = __Pyx_PyObject_to_MemoryviewSlice_dc_double(__pyx_t_1);
  if (unlikely(!__pyx_t_11.memview)) __PYX_ERR(0, 198, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_12 = __pyx_PyFloat_AsDouble(__pyx_t_5); if (unlikely((__pyx_t_12 == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 198, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __pyx_t_13 = __Pyx_PyObject_to_MemoryviewSlice_dc_long(__pyx_t_6);
  if (unlikely(!__pyx_t_13.memview)) __PYX_ERR(0, 198, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  __pyx_t_14 = __Pyx_PyInt_As_long(__pyx_t_3); if (unlikely((__pyx_t_14 == (long)-1) && PyErr_Occurred())) __PYX_ERR(0, 198, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_v_Z = __pyx_t_11;
  __pyx_t_11.memview = NULL;
  __pyx_t_11.data = NULL;
  __pyx_v_dZr = __pyx_t_12;
  __pyx_v_indZ = __pyx_t_13;
  __pyx_t_13.memview = NULL;
  __pyx_t_13.data = NULL;
  __pyx_v_NZ = __pyx_t_14;
+199:     Rn, Zn = len(R), len(Z)
  __pyx_t_4 = __pyx_memoryview_fromslice(__pyx_v_R, 1, (PyObject *(*)(char *)) __pyx_memview_get_double, (int (*)(char *, PyObject *)) __pyx_memview_set_double, 0);; if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 199, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_2 = PyObject_Length(__pyx_t_4); if (unlikely(__pyx_t_2 == -1)) __PYX_ERR(0, 199, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_4 = __pyx_memoryview_fromslice(__pyx_v_Z, 1, (PyObject *(*)(char *)) __pyx_memview_get_double, (int (*)(char *, PyObject *)) __pyx_memview_set_double, 0);; if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 199, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_15 = PyObject_Length(__pyx_t_4); if (unlikely(__pyx_t_15 == -1)) __PYX_ERR(0, 199, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_v_Rn = __pyx_t_2;
  __pyx_v_Zn = __pyx_t_15;
 200: 
 201:     # Number of Phi per R
+202:     dRPhirRef, dPhir = np.empty((NR,)), np.empty((NR,))
  __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 202, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_empty); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 202, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_3 = __Pyx_PyInt_From_long(__pyx_v_NR); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 202, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_5 = PyTuple_New(1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 202, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_GIVEREF(__pyx_t_3);
  PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_3);
  __pyx_t_3 = 0;
  __pyx_t_3 = NULL;
  if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_6))) {
    __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_6);
    if (likely(__pyx_t_3)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6);
      __Pyx_INCREF(__pyx_t_3);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_6, function);
    }
  }
  if (!__pyx_t_3) {
    __pyx_t_4 = __Pyx_PyObject_CallOneArg(__pyx_t_6, __pyx_t_5); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 202, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_GOTREF(__pyx_t_4);
  } else {
    #if CYTHON_FAST_PYCALL
    if (PyFunction_Check(__pyx_t_6)) {
      PyObject *__pyx_temp[2] = {__pyx_t_3, __pyx_t_5};
      __pyx_t_4 = __Pyx_PyFunction_FastCall(__pyx_t_6, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 202, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    } else
    #endif
    #if CYTHON_FAST_PYCCALL
    if (__Pyx_PyFastCFunction_Check(__pyx_t_6)) {
      PyObject *__pyx_temp[2] = {__pyx_t_3, __pyx_t_5};
      __pyx_t_4 = __Pyx_PyCFunction_FastCall(__pyx_t_6, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 202, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    } else
    #endif
    {
      __pyx_t_1 = PyTuple_New(1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 202, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_3); __pyx_t_3 = NULL;
      __Pyx_GIVEREF(__pyx_t_5);
      PyTuple_SET_ITEM(__pyx_t_1, 0+1, __pyx_t_5);
      __pyx_t_5 = 0;
      __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_6, __pyx_t_1, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 202, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    }
  }
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  __pyx_t_11 = __Pyx_PyObject_to_MemoryviewSlice_dc_double(__pyx_t_4);
  if (unlikely(!__pyx_t_11.memview)) __PYX_ERR(0, 202, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_6 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 202, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_n_s_empty); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 202, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  __pyx_t_6 = __Pyx_PyInt_From_long(__pyx_v_NR); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 202, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __pyx_t_5 = PyTuple_New(1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 202, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_GIVEREF(__pyx_t_6);
  PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_6);
  __pyx_t_6 = 0;
  __pyx_t_6 = NULL;
  if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_1))) {
    __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_1);
    if (likely(__pyx_t_6)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1);
      __Pyx_INCREF(__pyx_t_6);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_1, function);
    }
  }
  if (!__pyx_t_6) {
    __pyx_t_4 = __Pyx_PyObject_CallOneArg(__pyx_t_1, __pyx_t_5); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 202, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_GOTREF(__pyx_t_4);
  } else {
    #if CYTHON_FAST_PYCALL
    if (PyFunction_Check(__pyx_t_1)) {
      PyObject *__pyx_temp[2] = {__pyx_t_6, __pyx_t_5};
      __pyx_t_4 = __Pyx_PyFunction_FastCall(__pyx_t_1, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 202, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    } else
    #endif
    #if CYTHON_FAST_PYCCALL
    if (__Pyx_PyFastCFunction_Check(__pyx_t_1)) {
      PyObject *__pyx_temp[2] = {__pyx_t_6, __pyx_t_5};
      __pyx_t_4 = __Pyx_PyCFunction_FastCall(__pyx_t_1, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 202, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    } else
    #endif
    {
      __pyx_t_3 = PyTuple_New(1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 202, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_6); __pyx_t_6 = NULL;
      __Pyx_GIVEREF(__pyx_t_5);
      PyTuple_SET_ITEM(__pyx_t_3, 0+1, __pyx_t_5);
      __pyx_t_5 = 0;
      __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_3, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 202, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    }
  }
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_16 = __Pyx_PyObject_to_MemoryviewSlice_dc_double(__pyx_t_4);
  if (unlikely(!__pyx_t_16.memview)) __PYX_ERR(0, 202, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_v_dRPhirRef = __pyx_t_11;
  __pyx_t_11.memview = NULL;
  __pyx_t_11.data = NULL;
  __pyx_v_dPhir = __pyx_t_16;
  __pyx_t_16.memview = NULL;
  __pyx_t_16.data = NULL;
+203:     Ru, dRPhir = np.zeros((NR,)), np.nan*np.ones((NR,))
  __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 203, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_zeros); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 203, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = __Pyx_PyInt_From_long(__pyx_v_NR); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 203, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_5 = PyTuple_New(1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 203, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_GIVEREF(__pyx_t_1);
  PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_1);
  __pyx_t_1 = 0;
  __pyx_t_1 = NULL;
  if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) {
    __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_3);
    if (likely(__pyx_t_1)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
      __Pyx_INCREF(__pyx_t_1);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_3, function);
    }
  }
  if (!__pyx_t_1) {
    __pyx_t_4 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_5); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 203, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_GOTREF(__pyx_t_4);
  } else {
    #if CYTHON_FAST_PYCALL
    if (PyFunction_Check(__pyx_t_3)) {
      PyObject *__pyx_temp[2] = {__pyx_t_1, __pyx_t_5};
      __pyx_t_4 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 203, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    } else
    #endif
    #if CYTHON_FAST_PYCCALL
    if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) {
      PyObject *__pyx_temp[2] = {__pyx_t_1, __pyx_t_5};
      __pyx_t_4 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 203, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    } else
    #endif
    {
      __pyx_t_6 = PyTuple_New(1+1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 203, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_6);
      __Pyx_GIVEREF(__pyx_t_1); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_1); __pyx_t_1 = NULL;
      __Pyx_GIVEREF(__pyx_t_5);
      PyTuple_SET_ITEM(__pyx_t_6, 0+1, __pyx_t_5);
      __pyx_t_5 = 0;
      __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_6, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 203, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    }
  }
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_16 = __Pyx_PyObject_to_MemoryviewSlice_dc_double(__pyx_t_4);
  if (unlikely(!__pyx_t_16.memview)) __PYX_ERR(0, 203, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 203, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_nan); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 203, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_6 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 203, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_n_s_ones); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 203, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  __pyx_t_6 = __Pyx_PyInt_From_long(__pyx_v_NR); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 203, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 203, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_6);
  PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_6);
  __pyx_t_6 = 0;
  __pyx_t_6 = NULL;
  if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_5))) {
    __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_5);
    if (likely(__pyx_t_6)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5);
      __Pyx_INCREF(__pyx_t_6);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_5, function);
    }
  }
  if (!__pyx_t_6) {
    __pyx_t_4 = __Pyx_PyObject_CallOneArg(__pyx_t_5, __pyx_t_1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 203, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_GOTREF(__pyx_t_4);
  } else {
    #if CYTHON_FAST_PYCALL
    if (PyFunction_Check(__pyx_t_5)) {
      PyObject *__pyx_temp[2] = {__pyx_t_6, __pyx_t_1};
      __pyx_t_4 = __Pyx_PyFunction_FastCall(__pyx_t_5, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 203, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    } else
    #endif
    #if CYTHON_FAST_PYCCALL
    if (__Pyx_PyFastCFunction_Check(__pyx_t_5)) {
      PyObject *__pyx_temp[2] = {__pyx_t_6, __pyx_t_1};
      __pyx_t_4 = __Pyx_PyCFunction_FastCall(__pyx_t_5, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 203, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    } else
    #endif
    {
      __pyx_t_9 = PyTuple_New(1+1); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 203, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_9);
      __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_t_6); __pyx_t_6 = NULL;
      __Pyx_GIVEREF(__pyx_t_1);
      PyTuple_SET_ITEM(__pyx_t_9, 0+1, __pyx_t_1);
      __pyx_t_1 = 0;
      __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_t_9, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 203, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
    }
  }
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __pyx_t_5 = PyNumber_Multiply(__pyx_t_3, __pyx_t_4); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 203, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_11 = __Pyx_PyObject_to_MemoryviewSlice_dc_double(__pyx_t_5);
  if (unlikely(!__pyx_t_11.memview)) __PYX_ERR(0, 203, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __pyx_v_Ru = __pyx_t_16;
  __pyx_t_16.memview = NULL;
  __pyx_t_16.data = NULL;
  __pyx_v_dRPhir = __pyx_t_11;
  __pyx_t_11.memview = NULL;
  __pyx_t_11.data = NULL;
+204:     NRPhi, NRPhi0 = np.empty((NR,),dtype=int), np.empty((NR+1,),dtype=int)
  __pyx_t_5 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 204, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_n_s_empty); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 204, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __pyx_t_5 = __Pyx_PyInt_From_long(__pyx_v_NR); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 204, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 204, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_GIVEREF(__pyx_t_5);
  PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_5);
  __pyx_t_5 = 0;
  __pyx_t_5 = PyTuple_New(1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 204, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_GIVEREF(__pyx_t_3);
  PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_3);
  __pyx_t_3 = 0;
  __pyx_t_3 = PyDict_New(); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 204, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_dtype, ((PyObject *)(&PyInt_Type))) < 0) __PYX_ERR(0, 204, __pyx_L1_error)
  __pyx_t_9 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_5, __pyx_t_3); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 204, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_9);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_13 = __Pyx_PyObject_to_MemoryviewSlice_dc_long(__pyx_t_9);
  if (unlikely(!__pyx_t_13.memview)) __PYX_ERR(0, 204, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
  __pyx_t_9 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 204, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_9);
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_9, __pyx_n_s_empty); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 204, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
  __pyx_t_9 = __Pyx_PyInt_From_long((__pyx_v_NR + 1)); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 204, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_9);
  __pyx_t_5 = PyTuple_New(1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 204, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_GIVEREF(__pyx_t_9);
  PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_9);
  __pyx_t_9 = 0;
  __pyx_t_9 = PyTuple_New(1); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 204, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_9);
  __Pyx_GIVEREF(__pyx_t_5);
  PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_t_5);
  __pyx_t_5 = 0;
  __pyx_t_5 = PyDict_New(); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 204, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  if (PyDict_SetItem(__pyx_t_5, __pyx_n_s_dtype, ((PyObject *)(&PyInt_Type))) < 0) __PYX_ERR(0, 204, __pyx_L1_error)
  __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_9, __pyx_t_5); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 204, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __pyx_t_17 = __Pyx_PyObject_to_MemoryviewSlice_dc_long(__pyx_t_4);
  if (unlikely(!__pyx_t_17.memview)) __PYX_ERR(0, 204, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_v_NRPhi = __pyx_t_13;
  __pyx_t_13.memview = NULL;
  __pyx_t_13.data = NULL;
  __pyx_v_NRPhi0 = __pyx_t_17;
  __pyx_t_17.memview = NULL;
  __pyx_t_17.data = NULL;
+205:     Rratio = int(Cceil(R[NR-1]/R[0]))
  __pyx_t_18 = (__pyx_v_NR - 1);
  __pyx_t_19 = 0;
  __pyx_v_Rratio = ((long)ceil(((*((double *) ( /* dim=0 */ ((char *) (((double *) __pyx_v_R.data) + __pyx_t_18)) ))) / (*((double *) ( /* dim=0 */ ((char *) (((double *) __pyx_v_R.data) + __pyx_t_19)) ))))));
+206:     for ii in range(0,NR):
  __pyx_t_14 = __pyx_v_NR;
  for (__pyx_t_20 = 0; __pyx_t_20 < __pyx_t_14; __pyx_t_20+=1) {
    __pyx_v_ii = __pyx_t_20;
+207:         NRPhi[ii] = <long>(Cceil(2.*Cpi*R[ii]/dRPhi))
    __pyx_t_21 = __pyx_v_ii;
    __pyx_t_22 = __pyx_v_ii;
    *((long *) ( /* dim=0 */ ((char *) (((long *) __pyx_v_NRPhi.data) + __pyx_t_22)) )) = ((long)ceil((((2. * M_PI) * (*((double *) ( /* dim=0 */ ((char *) (((double *) __pyx_v_R.data) + __pyx_t_21)) )))) / __pyx_v_dRPhi)));
+208:         dRPhirRef[ii] = 2.*Cpi*R[ii]/<double>(NRPhi[ii])
    __pyx_t_23 = __pyx_v_ii;
    __pyx_t_24 = __pyx_v_ii;
    __pyx_t_25 = __pyx_v_ii;
    *((double *) ( /* dim=0 */ ((char *) (((double *) __pyx_v_dRPhirRef.data) + __pyx_t_25)) )) = (((2. * M_PI) * (*((double *) ( /* dim=0 */ ((char *) (((double *) __pyx_v_R.data) + __pyx_t_23)) )))) / ((double)(*((long *) ( /* dim=0 */ ((char *) (((long *) __pyx_v_NRPhi.data) + __pyx_t_24)) )))));
+209:         dPhir[ii] = 2.*Cpi/<double>(NRPhi[ii])
    __pyx_t_26 = __pyx_v_ii;
    __pyx_t_27 = __pyx_v_ii;
    *((double *) ( /* dim=0 */ ((char *) (((double *) __pyx_v_dPhir.data) + __pyx_t_27)) )) = ((2. * M_PI) / ((double)(*((long *) ( /* dim=0 */ ((char *) (((long *) __pyx_v_NRPhi.data) + __pyx_t_26)) )))));
+210:         if ii==0:
    __pyx_t_28 = ((__pyx_v_ii == 0) != 0);
    if (__pyx_t_28) {
/* … */
      goto __pyx_L9;
    }
+211:             NRPhi0[ii] = 0
      __pyx_t_29 = __pyx_v_ii;
      *((long *) ( /* dim=0 */ ((char *) (((long *) __pyx_v_NRPhi0.data) + __pyx_t_29)) )) = 0;
+212:             Phi = np.empty((NR,NRPhi[ii]*Rratio+1))
      __pyx_t_5 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 212, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
      __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_n_s_empty); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 212, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_9);
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __pyx_t_5 = __Pyx_PyInt_From_long(__pyx_v_NR); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 212, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
      __pyx_t_30 = __pyx_v_ii;
      __pyx_t_3 = __Pyx_PyInt_From_long((((*((long *) ( /* dim=0 */ ((char *) (((long *) __pyx_v_NRPhi.data) + __pyx_t_30)) ))) * __pyx_v_Rratio) + 1)); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 212, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 212, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_GIVEREF(__pyx_t_5);
      PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_5);
      __Pyx_GIVEREF(__pyx_t_3);
      PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_t_3);
      __pyx_t_5 = 0;
      __pyx_t_3 = 0;
      __pyx_t_3 = NULL;
      if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_9))) {
        __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_9);
        if (likely(__pyx_t_3)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_9);
          __Pyx_INCREF(__pyx_t_3);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_9, function);
        }
      }
      if (!__pyx_t_3) {
        __pyx_t_4 = __Pyx_PyObject_CallOneArg(__pyx_t_9, __pyx_t_1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 212, __pyx_L1_error)
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        __Pyx_GOTREF(__pyx_t_4);
      } else {
        #if CYTHON_FAST_PYCALL
        if (PyFunction_Check(__pyx_t_9)) {
          PyObject *__pyx_temp[2] = {__pyx_t_3, __pyx_t_1};
          __pyx_t_4 = __Pyx_PyFunction_FastCall(__pyx_t_9, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 212, __pyx_L1_error)
          __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
          __Pyx_GOTREF(__pyx_t_4);
          __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        } else
        #endif
        #if CYTHON_FAST_PYCCALL
        if (__Pyx_PyFastCFunction_Check(__pyx_t_9)) {
          PyObject *__pyx_temp[2] = {__pyx_t_3, __pyx_t_1};
          __pyx_t_4 = __Pyx_PyCFunction_FastCall(__pyx_t_9, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 212, __pyx_L1_error)
          __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
          __Pyx_GOTREF(__pyx_t_4);
          __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        } else
        #endif
        {
          __pyx_t_5 = PyTuple_New(1+1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 212, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_5);
          __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_3); __pyx_t_3 = NULL;
          __Pyx_GIVEREF(__pyx_t_1);
          PyTuple_SET_ITEM(__pyx_t_5, 0+1, __pyx_t_1);
          __pyx_t_1 = 0;
          __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_9, __pyx_t_5, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 212, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_4);
          __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
        }
      }
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
      __pyx_t_31 = __Pyx_PyObject_to_MemoryviewSlice_d_dc_double(__pyx_t_4);
      if (unlikely(!__pyx_t_31.memview)) __PYX_ERR(0, 212, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __PYX_XDEC_MEMVIEW(&__pyx_v_Phi, 1);
      __pyx_v_Phi = __pyx_t_31;
      __pyx_t_31.memview = NULL;
      __pyx_t_31.data = NULL;
 213:         else:
+214:             NRPhi0[ii] = NRPhi0[ii-1] + NRPhi[ii-1]*NZ
    /*else*/ {
      __pyx_t_32 = (__pyx_v_ii - 1);
      __pyx_t_33 = (__pyx_v_ii - 1);
      __pyx_t_34 = __pyx_v_ii;
      *((long *) ( /* dim=0 */ ((char *) (((long *) __pyx_v_NRPhi0.data) + __pyx_t_34)) )) = ((*((long *) ( /* dim=0 */ ((char *) (((long *) __pyx_v_NRPhi0.data) + __pyx_t_32)) ))) + ((*((long *) ( /* dim=0 */ ((char *) (((long *) __pyx_v_NRPhi.data) + __pyx_t_33)) ))) * __pyx_v_NZ));
    }
    __pyx_L9:;
+215:         for jj in range(0,NRPhi[ii]):
    __pyx_t_35 = __pyx_v_ii;
    __pyx_t_36 = (*((long *) ( /* dim=0 */ ((char *) (((long *) __pyx_v_NRPhi.data) + __pyx_t_35)) )));
    for (__pyx_t_37 = 0; __pyx_t_37 < __pyx_t_36; __pyx_t_37+=1) {
      __pyx_v_jj = __pyx_t_37;
+216:             Phi[ii,jj] = -Cpi + (0.5+<double>jj)*dPhir[ii]
      __pyx_t_38 = __pyx_v_ii;
      if (unlikely(!__pyx_v_Phi.memview)) { __Pyx_RaiseUnboundLocalError("Phi"); __PYX_ERR(0, 216, __pyx_L1_error) }
      __pyx_t_39 = __pyx_v_ii;
      __pyx_t_40 = __pyx_v_jj;
      *((double *) ( /* dim=1 */ ((char *) (((double *) ( /* dim=0 */ (__pyx_v_Phi.data + __pyx_t_39 * __pyx_v_Phi.strides[0]) )) + __pyx_t_40)) )) = ((-M_PI) + ((0.5 + ((double)__pyx_v_jj)) * (*((double *) ( /* dim=0 */ ((char *) (((double *) __pyx_v_dPhir.data) + __pyx_t_38)) )))));
    }
  }
 217: 
+218:     if Out.lower()=='(x,y,z)':
  __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_v_Out, __pyx_n_s_lower); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 218, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_9);
  __pyx_t_5 = NULL;
  if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_9))) {
    __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_9);
    if (likely(__pyx_t_5)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_9);
      __Pyx_INCREF(__pyx_t_5);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_9, function);
    }
  }
  if (__pyx_t_5) {
    __pyx_t_4 = __Pyx_PyObject_CallOneArg(__pyx_t_9, __pyx_t_5); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 218, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  } else {
    __pyx_t_4 = __Pyx_PyObject_CallNoArg(__pyx_t_9); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 218, __pyx_L1_error)
  }
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
  __pyx_t_28 = (__Pyx_PyString_Equals(__pyx_t_4, __pyx_kp_s_x_y_z, Py_EQ)); if (unlikely(__pyx_t_28 < 0)) __PYX_ERR(0, 218, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  if (__pyx_t_28) {
/* … */
    goto __pyx_L12;
  }
+219:         for ii in range(0,NP):
    __pyx_t_14 = __pyx_v_NP;
    for (__pyx_t_20 = 0; __pyx_t_20 < __pyx_t_14; __pyx_t_20+=1) {
      __pyx_v_ii = __pyx_t_20;
+220:             for jj in range(0,NR+1):
      __pyx_t_36 = (__pyx_v_NR + 1);
      for (__pyx_t_37 = 0; __pyx_t_37 < __pyx_t_36; __pyx_t_37+=1) {
        __pyx_v_jj = __pyx_t_37;
+221:                 if ind[ii]-NRPhi0[jj]<0.:
        __pyx_t_41 = __pyx_v_ii;
        __pyx_t_42 = __pyx_v_jj;
        __pyx_t_28 = ((((*((long *) ( /* dim=0 */ ((char *) (((long *) __pyx_v_ind.data) + __pyx_t_41)) ))) - (*((long *) ( /* dim=0 */ ((char *) (((long *) __pyx_v_NRPhi0.data) + __pyx_t_42)) )))) < 0.) != 0);
        if (__pyx_t_28) {
/* … */
        }
      }
      __pyx_L16_break:;
+222:                     break
          goto __pyx_L16_break;
+223:             iiR = jj-1
      __pyx_v_iiR = (__pyx_v_jj - 1);
+224:             iiZ = (ind[ii] - NRPhi0[iiR])//NRPhi[iiR]
      __pyx_t_43 = __pyx_v_ii;
      __pyx_t_44 = __pyx_v_iiR;
      __pyx_t_45 = __pyx_v_iiR;
      __pyx_v_iiZ = (((*((long *) ( /* dim=0 */ ((char *) (((long *) __pyx_v_ind.data) + __pyx_t_43)) ))) - (*((long *) ( /* dim=0 */ ((char *) (((long *) __pyx_v_NRPhi0.data) + __pyx_t_44)) )))) / (*((long *) ( /* dim=0 */ ((char *) (((long *) __pyx_v_NRPhi.data) + __pyx_t_45)) ))));
+225:             iiphi = ind[ii] - NRPhi0[iiR] - iiZ*NRPhi[iiR]
      __pyx_t_46 = __pyx_v_ii;
      __pyx_t_47 = __pyx_v_iiR;
      __pyx_t_48 = __pyx_v_iiR;
      __pyx_v_iiphi = (((*((long *) ( /* dim=0 */ ((char *) (((long *) __pyx_v_ind.data) + __pyx_t_46)) ))) - (*((long *) ( /* dim=0 */ ((char *) (((long *) __pyx_v_NRPhi0.data) + __pyx_t_47)) )))) - (__pyx_v_iiZ * (*((long *) ( /* dim=0 */ ((char *) (((long *) __pyx_v_NRPhi.data) + __pyx_t_48)) )))));
+226:             phi = Phi[iiR,iiphi]
      if (unlikely(!__pyx_v_Phi.memview)) { __Pyx_RaiseUnboundLocalError("Phi"); __PYX_ERR(0, 226, __pyx_L1_error) }
      __pyx_t_49 = __pyx_v_iiR;
      __pyx_t_50 = __pyx_v_iiphi;
      __pyx_v_phi = (*((double *) ( /* dim=1 */ ((char *) (((double *) ( /* dim=0 */ (__pyx_v_Phi.data + __pyx_t_49 * __pyx_v_Phi.strides[0]) )) + __pyx_t_50)) )));
+227:             Pts[0,ii] = R[iiR]*Ccos(phi)
      __pyx_t_51 = __pyx_v_iiR;
      __pyx_t_52 = 0;
      __pyx_t_53 = __pyx_v_ii;
      *__Pyx_BufPtrStrided2d(double *, __pyx_pybuffernd_Pts.rcbuffer->pybuffer.buf, __pyx_t_52, __pyx_pybuffernd_Pts.diminfo[0].strides, __pyx_t_53, __pyx_pybuffernd_Pts.diminfo[1].strides) = ((*((double *) ( /* dim=0 */ ((char *) (((double *) __pyx_v_R.data) + __pyx_t_51)) ))) * cos(__pyx_v_phi));
+228:             Pts[1,ii] = R[iiR]*Csin(phi)
      __pyx_t_54 = __pyx_v_iiR;
      __pyx_t_55 = 1;
      __pyx_t_56 = __pyx_v_ii;
      *__Pyx_BufPtrStrided2d(double *, __pyx_pybuffernd_Pts.rcbuffer->pybuffer.buf, __pyx_t_55, __pyx_pybuffernd_Pts.diminfo[0].strides, __pyx_t_56, __pyx_pybuffernd_Pts.diminfo[1].strides) = ((*((double *) ( /* dim=0 */ ((char *) (((double *) __pyx_v_R.data) + __pyx_t_54)) ))) * sin(__pyx_v_phi));
+229:             Pts[2,ii] = Z[iiZ]
      __pyx_t_57 = __pyx_v_iiZ;
      __pyx_t_58 = 2;
      __pyx_t_59 = __pyx_v_ii;
      *__Pyx_BufPtrStrided2d(double *, __pyx_pybuffernd_Pts.rcbuffer->pybuffer.buf, __pyx_t_58, __pyx_pybuffernd_Pts.diminfo[0].strides, __pyx_t_59, __pyx_pybuffernd_Pts.diminfo[1].strides) = (*((double *) ( /* dim=0 */ ((char *) (((double *) __pyx_v_Z.data) + __pyx_t_57)) )));
+230:             dV[ii] = dRr*dZr*dRPhirRef[iiR]
      __pyx_t_60 = __pyx_v_iiR;
      __pyx_t_61 = __pyx_v_ii;
      *__Pyx_BufPtrStrided1d(double *, __pyx_pybuffernd_dV.rcbuffer->pybuffer.buf, __pyx_t_61, __pyx_pybuffernd_dV.diminfo[0].strides) = ((__pyx_v_dRr * __pyx_v_dZr) * (*((double *) ( /* dim=0 */ ((char *) (((double *) __pyx_v_dRPhirRef.data) + __pyx_t_60)) ))));
+231:             if Ru[iiR]==0.:
      __pyx_t_62 = __pyx_v_iiR;
      __pyx_t_28 = (((*((double *) ( /* dim=0 */ ((char *) (((double *) __pyx_v_Ru.data) + __pyx_t_62)) ))) == 0.) != 0);
      if (__pyx_t_28) {
/* … */
      }
    }
+232:                 dRPhir[iiR] = dRPhirRef[iiR]
        __pyx_t_63 = __pyx_v_iiR;
        __pyx_t_64 = __pyx_v_iiR;
        *((double *) ( /* dim=0 */ ((char *) (((double *) __pyx_v_dRPhir.data) + __pyx_t_64)) )) = (*((double *) ( /* dim=0 */ ((char *) (((double *) __pyx_v_dRPhirRef.data) + __pyx_t_63)) )));
+233:                 Ru[iiR] = 1.
        __pyx_t_65 = __pyx_v_iiR;
        *((double *) ( /* dim=0 */ ((char *) (((double *) __pyx_v_Ru.data) + __pyx_t_65)) )) = 1.;
 234:     else:
+235:         for ii in range(0,NP):
  /*else*/ {
    __pyx_t_14 = __pyx_v_NP;
    for (__pyx_t_20 = 0; __pyx_t_20 < __pyx_t_14; __pyx_t_20+=1) {
      __pyx_v_ii = __pyx_t_20;
+236:             for jj in range(0,NR+1):
      __pyx_t_36 = (__pyx_v_NR + 1);
      for (__pyx_t_37 = 0; __pyx_t_37 < __pyx_t_36; __pyx_t_37+=1) {
        __pyx_v_jj = __pyx_t_37;
+237:                 if ind[ii]-NRPhi0[jj]<0.:
        __pyx_t_66 = __pyx_v_ii;
        __pyx_t_67 = __pyx_v_jj;
        __pyx_t_28 = ((((*((long *) ( /* dim=0 */ ((char *) (((long *) __pyx_v_ind.data) + __pyx_t_66)) ))) - (*((long *) ( /* dim=0 */ ((char *) (((long *) __pyx_v_NRPhi0.data) + __pyx_t_67)) )))) < 0.) != 0);
        if (__pyx_t_28) {
/* … */
        }
      }
      __pyx_L22_break:;
+238:                     break
          goto __pyx_L22_break;
+239:             iiR = jj-1
      __pyx_v_iiR = (__pyx_v_jj - 1);
+240:             iiZ = (ind[ii] - NRPhi0[iiR])//NRPhi[iiR]
      __pyx_t_68 = __pyx_v_ii;
      __pyx_t_69 = __pyx_v_iiR;
      __pyx_t_70 = __pyx_v_iiR;
      __pyx_v_iiZ = (((*((long *) ( /* dim=0 */ ((char *) (((long *) __pyx_v_ind.data) + __pyx_t_68)) ))) - (*((long *) ( /* dim=0 */ ((char *) (((long *) __pyx_v_NRPhi0.data) + __pyx_t_69)) )))) / (*((long *) ( /* dim=0 */ ((char *) (((long *) __pyx_v_NRPhi.data) + __pyx_t_70)) ))));
+241:             iiphi = ind[ii] - NRPhi0[iiR] - iiZ*NRPhi[iiR]
      __pyx_t_71 = __pyx_v_ii;
      __pyx_t_72 = __pyx_v_iiR;
      __pyx_t_73 = __pyx_v_iiR;
      __pyx_v_iiphi = (((*((long *) ( /* dim=0 */ ((char *) (((long *) __pyx_v_ind.data) + __pyx_t_71)) ))) - (*((long *) ( /* dim=0 */ ((char *) (((long *) __pyx_v_NRPhi0.data) + __pyx_t_72)) )))) - (__pyx_v_iiZ * (*((long *) ( /* dim=0 */ ((char *) (((long *) __pyx_v_NRPhi.data) + __pyx_t_73)) )))));
+242:             Pts[0,ii] = R[iiR]
      __pyx_t_74 = __pyx_v_iiR;
      __pyx_t_75 = 0;
      __pyx_t_76 = __pyx_v_ii;
      *__Pyx_BufPtrStrided2d(double *, __pyx_pybuffernd_Pts.rcbuffer->pybuffer.buf, __pyx_t_75, __pyx_pybuffernd_Pts.diminfo[0].strides, __pyx_t_76, __pyx_pybuffernd_Pts.diminfo[1].strides) = (*((double *) ( /* dim=0 */ ((char *) (((double *) __pyx_v_R.data) + __pyx_t_74)) )));
+243:             Pts[1,ii] = Z[iiZ]
      __pyx_t_77 = __pyx_v_iiZ;
      __pyx_t_78 = 1;
      __pyx_t_79 = __pyx_v_ii;
      *__Pyx_BufPtrStrided2d(double *, __pyx_pybuffernd_Pts.rcbuffer->pybuffer.buf, __pyx_t_78, __pyx_pybuffernd_Pts.diminfo[0].strides, __pyx_t_79, __pyx_pybuffernd_Pts.diminfo[1].strides) = (*((double *) ( /* dim=0 */ ((char *) (((double *) __pyx_v_Z.data) + __pyx_t_77)) )));
+244:             Pts[2,ii] = Phi[iiR,iiphi]
      if (unlikely(!__pyx_v_Phi.memview)) { __Pyx_RaiseUnboundLocalError("Phi"); __PYX_ERR(0, 244, __pyx_L1_error) }
      __pyx_t_80 = __pyx_v_iiR;
      __pyx_t_81 = __pyx_v_iiphi;
      __pyx_t_82 = 2;
      __pyx_t_83 = __pyx_v_ii;
      *__Pyx_BufPtrStrided2d(double *, __pyx_pybuffernd_Pts.rcbuffer->pybuffer.buf, __pyx_t_82, __pyx_pybuffernd_Pts.diminfo[0].strides, __pyx_t_83, __pyx_pybuffernd_Pts.diminfo[1].strides) = (*((double *) ( /* dim=1 */ ((char *) (((double *) ( /* dim=0 */ (__pyx_v_Phi.data + __pyx_t_80 * __pyx_v_Phi.strides[0]) )) + __pyx_t_81)) )));
+245:             dV[ii] = dRr*dZr*dRPhirRef[iiR]
      __pyx_t_84 = __pyx_v_iiR;
      __pyx_t_85 = __pyx_v_ii;
      *__Pyx_BufPtrStrided1d(double *, __pyx_pybuffernd_dV.rcbuffer->pybuffer.buf, __pyx_t_85, __pyx_pybuffernd_dV.diminfo[0].strides) = ((__pyx_v_dRr * __pyx_v_dZr) * (*((double *) ( /* dim=0 */ ((char *) (((double *) __pyx_v_dRPhirRef.data) + __pyx_t_84)) ))));
+246:             if Ru[iiR]==0.:
      __pyx_t_86 = __pyx_v_iiR;
      __pyx_t_28 = (((*((double *) ( /* dim=0 */ ((char *) (((double *) __pyx_v_Ru.data) + __pyx_t_86)) ))) == 0.) != 0);
      if (__pyx_t_28) {
/* … */
      }
    }
  }
  __pyx_L12:;
+247:                 dRPhir[iiR] = dRPhirRef[iiR]
        __pyx_t_87 = __pyx_v_iiR;
        __pyx_t_88 = __pyx_v_iiR;
        *((double *) ( /* dim=0 */ ((char *) (((double *) __pyx_v_dRPhir.data) + __pyx_t_88)) )) = (*((double *) ( /* dim=0 */ ((char *) (((double *) __pyx_v_dRPhirRef.data) + __pyx_t_87)) )));
+248:                 Ru[iiR] = 1.
        __pyx_t_89 = __pyx_v_iiR;
        *((double *) ( /* dim=0 */ ((char *) (((double *) __pyx_v_Ru.data) + __pyx_t_89)) )) = 1.;
 249: 
+250:     return Pts, dV, dRr, dZr, np.asarray(dRPhir)[~np.isnan(dRPhir)]
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_4 = PyFloat_FromDouble(__pyx_v_dRr); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 250, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_9 = PyFloat_FromDouble(__pyx_v_dZr); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 250, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_9);
  __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 250, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_asarray); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 250, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = __pyx_memoryview_fromslice(__pyx_v_dRPhir, 1, (PyObject *(*)(char *)) __pyx_memview_get_double, (int (*)(char *, PyObject *)) __pyx_memview_set_double, 0);; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 250, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_6 = NULL;
  if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) {
    __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_3);
    if (likely(__pyx_t_6)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
      __Pyx_INCREF(__pyx_t_6);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_3, function);
    }
  }
  if (!__pyx_t_6) {
    __pyx_t_5 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 250, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_GOTREF(__pyx_t_5);
  } else {
    #if CYTHON_FAST_PYCALL
    if (PyFunction_Check(__pyx_t_3)) {
      PyObject *__pyx_temp[2] = {__pyx_t_6, __pyx_t_1};
      __pyx_t_5 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 250, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    } else
    #endif
    #if CYTHON_FAST_PYCCALL
    if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) {
      PyObject *__pyx_temp[2] = {__pyx_t_6, __pyx_t_1};
      __pyx_t_5 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 250, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    } else
    #endif
    {
      __pyx_t_90 = PyTuple_New(1+1); if (unlikely(!__pyx_t_90)) __PYX_ERR(0, 250, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_90);
      __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_90, 0, __pyx_t_6); __pyx_t_6 = NULL;
      __Pyx_GIVEREF(__pyx_t_1);
      PyTuple_SET_ITEM(__pyx_t_90, 0+1, __pyx_t_1);
      __pyx_t_1 = 0;
      __pyx_t_5 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_90, NULL); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 250, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_DECREF(__pyx_t_90); __pyx_t_90 = 0;
    }
  }
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_90 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_90)) __PYX_ERR(0, 250, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_90);
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_90, __pyx_n_s_isnan); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 250, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_90); __pyx_t_90 = 0;
  __pyx_t_90 = __pyx_memoryview_fromslice(__pyx_v_dRPhir, 1, (PyObject *(*)(char *)) __pyx_memview_get_double, (int (*)(char *, PyObject *)) __pyx_memview_set_double, 0);; if (unlikely(!__pyx_t_90)) __PYX_ERR(0, 250, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_90);
  __pyx_t_6 = NULL;
  if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_1))) {
    __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_1);
    if (likely(__pyx_t_6)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1);
      __Pyx_INCREF(__pyx_t_6);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_1, function);
    }
  }
  if (!__pyx_t_6) {
    __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_t_1, __pyx_t_90); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 250, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_90); __pyx_t_90 = 0;
    __Pyx_GOTREF(__pyx_t_3);
  } else {
    #if CYTHON_FAST_PYCALL
    if (PyFunction_Check(__pyx_t_1)) {
      PyObject *__pyx_temp[2] = {__pyx_t_6, __pyx_t_90};
      __pyx_t_3 = __Pyx_PyFunction_FastCall(__pyx_t_1, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 250, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_90); __pyx_t_90 = 0;
    } else
    #endif
    #if CYTHON_FAST_PYCCALL
    if (__Pyx_PyFastCFunction_Check(__pyx_t_1)) {
      PyObject *__pyx_temp[2] = {__pyx_t_6, __pyx_t_90};
      __pyx_t_3 = __Pyx_PyCFunction_FastCall(__pyx_t_1, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 250, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_90); __pyx_t_90 = 0;
    } else
    #endif
    {
      __pyx_t_91 = PyTuple_New(1+1); if (unlikely(!__pyx_t_91)) __PYX_ERR(0, 250, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_91);
      __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_91, 0, __pyx_t_6); __pyx_t_6 = NULL;
      __Pyx_GIVEREF(__pyx_t_90);
      PyTuple_SET_ITEM(__pyx_t_91, 0+1, __pyx_t_90);
      __pyx_t_90 = 0;
      __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_91, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 250, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_91); __pyx_t_91 = 0;
    }
  }
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = PyNumber_Invert(__pyx_t_3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 250, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_3 = PyObject_GetItem(__pyx_t_5, __pyx_t_1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 250, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = PyTuple_New(5); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 250, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_INCREF(((PyObject *)__pyx_v_Pts));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_Pts));
  PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)__pyx_v_Pts));
  __Pyx_INCREF(((PyObject *)__pyx_v_dV));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_dV));
  PyTuple_SET_ITEM(__pyx_t_1, 1, ((PyObject *)__pyx_v_dV));
  __Pyx_GIVEREF(__pyx_t_4);
  PyTuple_SET_ITEM(__pyx_t_1, 2, __pyx_t_4);
  __Pyx_GIVEREF(__pyx_t_9);
  PyTuple_SET_ITEM(__pyx_t_1, 3, __pyx_t_9);
  __Pyx_GIVEREF(__pyx_t_3);
  PyTuple_SET_ITEM(__pyx_t_1, 4, __pyx_t_3);
  __pyx_t_4 = 0;
  __pyx_t_9 = 0;
  __pyx_t_3 = 0;
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;
 251: 
 252: 
 253: 
 254: 
+255: def _Ves_Vmesh_Lin_SubFromD_cython(double dX, double dY, double dZ,
/* Python wrapper */
static PyObject *__pyx_pw_46_cython_magic_ffb7650808bb7830760fff8d6d047f13_7_Ves_Vmesh_Lin_SubFromD_cython(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_46_cython_magic_ffb7650808bb7830760fff8d6d047f13_6_Ves_Vmesh_Lin_SubFromD_cython[] = " Return the desired submesh indicated by the limits (DX,DY,DZ), for the desired resolution (dX,dY,dZ) ";
static PyMethodDef __pyx_mdef_46_cython_magic_ffb7650808bb7830760fff8d6d047f13_7_Ves_Vmesh_Lin_SubFromD_cython = {"_Ves_Vmesh_Lin_SubFromD_cython", (PyCFunction)__pyx_pw_46_cython_magic_ffb7650808bb7830760fff8d6d047f13_7_Ves_Vmesh_Lin_SubFromD_cython, METH_VARARGS|METH_KEYWORDS, __pyx_doc_46_cython_magic_ffb7650808bb7830760fff8d6d047f13_6_Ves_Vmesh_Lin_SubFromD_cython};
static PyObject *__pyx_pw_46_cython_magic_ffb7650808bb7830760fff8d6d047f13_7_Ves_Vmesh_Lin_SubFromD_cython(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  double __pyx_v_dX;
  double __pyx_v_dY;
  double __pyx_v_dZ;
  __Pyx_memviewslice __pyx_v_XMinMax = { 0, 0, { 0 }, { 0 }, { 0 } };
  __Pyx_memviewslice __pyx_v_YMinMax = { 0, 0, { 0 }, { 0 }, { 0 } };
  __Pyx_memviewslice __pyx_v_ZMinMax = { 0, 0, { 0 }, { 0 }, { 0 } };
  PyObject *__pyx_v_DX = 0;
  PyObject *__pyx_v_DY = 0;
  PyObject *__pyx_v_DZ = 0;
  CYTHON_UNUSED PyObject *__pyx_v_VPoly = 0;
  double __pyx_v_margin;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("_Ves_Vmesh_Lin_SubFromD_cython (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_dX,&__pyx_n_s_dY,&__pyx_n_s_dZ,&__pyx_n_s_XMinMax,&__pyx_n_s_YMinMax,&__pyx_n_s_ZMinMax,&__pyx_n_s_DX,&__pyx_n_s_DY,&__pyx_n_s_DZ,&__pyx_n_s_VPoly,&__pyx_n_s_margin,0};
    PyObject* values[11] = {0,0,0,0,0,0,0,0,0,0,0};
/* … */
  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_46_cython_magic_ffb7650808bb7830760fff8d6d047f13_6_Ves_Vmesh_Lin_SubFromD_cython(CYTHON_UNUSED PyObject *__pyx_self, double __pyx_v_dX, double __pyx_v_dY, double __pyx_v_dZ, __Pyx_memviewslice __pyx_v_XMinMax, __Pyx_memviewslice __pyx_v_YMinMax, __Pyx_memviewslice __pyx_v_ZMinMax, PyObject *__pyx_v_DX, PyObject *__pyx_v_DY, PyObject *__pyx_v_DZ, CYTHON_UNUSED PyObject *__pyx_v_VPoly, double __pyx_v_margin) {
  __Pyx_memviewslice __pyx_v_X = { 0, 0, { 0 }, { 0 }, { 0 } };
  __Pyx_memviewslice __pyx_v_Y = { 0, 0, { 0 }, { 0 }, { 0 } };
  __Pyx_memviewslice __pyx_v_Z = { 0, 0, { 0 }, { 0 }, { 0 } };
  double __pyx_v_dXr;
  double __pyx_v_dYr;
  double __pyx_v_dZr;
  double __pyx_v_dV;
  PyArrayObject *__pyx_v_indX = 0;
  PyArrayObject *__pyx_v_indY = 0;
  PyArrayObject *__pyx_v_indZ = 0;
  int __pyx_v_NX;
  int __pyx_v_NY;
  CYTHON_UNUSED int __pyx_v_NZ;
  int __pyx_v_Xn;
  int __pyx_v_Yn;
  int __pyx_v_Zn;
  PyArrayObject *__pyx_v_Pts = 0;
  PyArrayObject *__pyx_v_ind = 0;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_Pts;
  __Pyx_Buffer __pyx_pybuffer_Pts;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_ind;
  __Pyx_Buffer __pyx_pybuffer_ind;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_indX;
  __Pyx_Buffer __pyx_pybuffer_indX;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_indY;
  __Pyx_Buffer __pyx_pybuffer_indY;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_indZ;
  __Pyx_Buffer __pyx_pybuffer_indZ;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("_Ves_Vmesh_Lin_SubFromD_cython", 0);
  __pyx_pybuffer_indX.pybuffer.buf = NULL;
  __pyx_pybuffer_indX.refcount = 0;
  __pyx_pybuffernd_indX.data = NULL;
  __pyx_pybuffernd_indX.rcbuffer = &__pyx_pybuffer_indX;
  __pyx_pybuffer_indY.pybuffer.buf = NULL;
  __pyx_pybuffer_indY.refcount = 0;
  __pyx_pybuffernd_indY.data = NULL;
  __pyx_pybuffernd_indY.rcbuffer = &__pyx_pybuffer_indY;
  __pyx_pybuffer_indZ.pybuffer.buf = NULL;
  __pyx_pybuffer_indZ.refcount = 0;
  __pyx_pybuffernd_indZ.data = NULL;
  __pyx_pybuffernd_indZ.rcbuffer = &__pyx_pybuffer_indZ;
  __pyx_pybuffer_Pts.pybuffer.buf = NULL;
  __pyx_pybuffer_Pts.refcount = 0;
  __pyx_pybuffernd_Pts.data = NULL;
  __pyx_pybuffernd_Pts.rcbuffer = &__pyx_pybuffer_Pts;
  __pyx_pybuffer_ind.pybuffer.buf = NULL;
  __pyx_pybuffer_ind.refcount = 0;
  __pyx_pybuffernd_ind.data = NULL;
  __pyx_pybuffernd_ind.rcbuffer = &__pyx_pybuffer_ind;
/* … */
  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __PYX_XDEC_MEMVIEW(&__pyx_t_8, 1);
  __Pyx_XDECREF(__pyx_t_19);
  __Pyx_XDECREF(__pyx_t_20);
  __Pyx_XDECREF(__pyx_t_21);
  __Pyx_XDECREF(__pyx_t_22);
  __Pyx_XDECREF(__pyx_t_23);
  __Pyx_XDECREF(__pyx_t_24);
  { PyObject *__pyx_type, *__pyx_value, *__pyx_tb;
    __Pyx_PyThreadState_declare
    __Pyx_PyThreadState_assign
    __Pyx_ErrFetch(&__pyx_type, &__pyx_value, &__pyx_tb);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_Pts.rcbuffer->pybuffer);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_ind.rcbuffer->pybuffer);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_indX.rcbuffer->pybuffer);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_indY.rcbuffer->pybuffer);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_indZ.rcbuffer->pybuffer);
  __Pyx_ErrRestore(__pyx_type, __pyx_value, __pyx_tb);}
  __Pyx_AddTraceback("_cython_magic_ffb7650808bb7830760fff8d6d047f13._Ves_Vmesh_Lin_SubFromD_cython", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  goto __pyx_L2;
  __pyx_L0:;
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_Pts.rcbuffer->pybuffer);
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_ind.rcbuffer->pybuffer);
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_indX.rcbuffer->pybuffer);
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_indY.rcbuffer->pybuffer);
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_indZ.rcbuffer->pybuffer);
  __pyx_L2:;
  __PYX_XDEC_MEMVIEW(&__pyx_v_X, 1);
  __PYX_XDEC_MEMVIEW(&__pyx_v_Y, 1);
  __PYX_XDEC_MEMVIEW(&__pyx_v_Z, 1);
  __Pyx_XDECREF((PyObject *)__pyx_v_indX);
  __Pyx_XDECREF((PyObject *)__pyx_v_indY);
  __Pyx_XDECREF((PyObject *)__pyx_v_indZ);
  __Pyx_XDECREF((PyObject *)__pyx_v_Pts);
  __Pyx_XDECREF((PyObject *)__pyx_v_ind);
  __PYX_XDEC_MEMVIEW(&__pyx_v_XMinMax, 1);
  __PYX_XDEC_MEMVIEW(&__pyx_v_YMinMax, 1);
  __PYX_XDEC_MEMVIEW(&__pyx_v_ZMinMax, 1);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}
/* … */
  __pyx_tuple__29 = PyTuple_Pack(29, __pyx_n_s_dX, __pyx_n_s_dY, __pyx_n_s_dZ, __pyx_n_s_XMinMax, __pyx_n_s_YMinMax, __pyx_n_s_ZMinMax, __pyx_n_s_DX, __pyx_n_s_DY, __pyx_n_s_DZ, __pyx_n_s_VPoly, __pyx_n_s_margin, __pyx_n_s_X, __pyx_n_s_Y, __pyx_n_s_Z, __pyx_n_s_dXr, __pyx_n_s_dYr, __pyx_n_s_dZr, __pyx_n_s_dV, __pyx_n_s_indX, __pyx_n_s_indY, __pyx_n_s_indZ, __pyx_n_s_NX, __pyx_n_s_NY, __pyx_n_s_NZ, __pyx_n_s_Xn, __pyx_n_s_Yn, __pyx_n_s_Zn, __pyx_n_s_Pts, __pyx_n_s_ind); if (unlikely(!__pyx_tuple__29)) __PYX_ERR(0, 255, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__29);
  __Pyx_GIVEREF(__pyx_tuple__29);
/* … */
  __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_46_cython_magic_ffb7650808bb7830760fff8d6d047f13_7_Ves_Vmesh_Lin_SubFromD_cython, NULL, __pyx_n_s_cython_magic_ffb7650808bb783076); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 255, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_Ves_Vmesh_Lin_SubFromD_cython, __pyx_t_1) < 0) __PYX_ERR(0, 255, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_codeobj__30 = (PyObject*)__Pyx_PyCode_New(11, 0, 29, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__29, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_Home_DV226270_cache_ipython_cyt, __pyx_n_s_Ves_Vmesh_Lin_SubFromD_cython, 255, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__30)) __PYX_ERR(0, 255, __pyx_L1_error)
 256:                                    double[::1] XMinMax, double[::1] YMinMax, double[::1] ZMinMax,
+257:                                    DX=None, DY=None, DZ=None, VPoly=None,
    values[6] = ((PyObject *)Py_None);
    values[7] = ((PyObject *)Py_None);
    values[8] = ((PyObject *)Py_None);
    values[9] = ((PyObject *)Py_None);
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case 11: values[10] = PyTuple_GET_ITEM(__pyx_args, 10);
        case 10: values[9] = PyTuple_GET_ITEM(__pyx_args, 9);
        case  9: values[8] = PyTuple_GET_ITEM(__pyx_args, 8);
        case  8: values[7] = PyTuple_GET_ITEM(__pyx_args, 7);
        case  7: values[6] = PyTuple_GET_ITEM(__pyx_args, 6);
        case  6: values[5] = PyTuple_GET_ITEM(__pyx_args, 5);
        case  5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_dX)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        case  1:
        if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_dY)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_Ves_Vmesh_Lin_SubFromD_cython", 0, 6, 11, 1); __PYX_ERR(0, 255, __pyx_L3_error)
        }
        case  2:
        if (likely((values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_dZ)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_Ves_Vmesh_Lin_SubFromD_cython", 0, 6, 11, 2); __PYX_ERR(0, 255, __pyx_L3_error)
        }
        case  3:
        if (likely((values[3] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_XMinMax)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_Ves_Vmesh_Lin_SubFromD_cython", 0, 6, 11, 3); __PYX_ERR(0, 255, __pyx_L3_error)
        }
        case  4:
        if (likely((values[4] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_YMinMax)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_Ves_Vmesh_Lin_SubFromD_cython", 0, 6, 11, 4); __PYX_ERR(0, 255, __pyx_L3_error)
        }
        case  5:
        if (likely((values[5] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_ZMinMax)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_Ves_Vmesh_Lin_SubFromD_cython", 0, 6, 11, 5); __PYX_ERR(0, 255, __pyx_L3_error)
        }
        case  6:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_DX);
          if (value) { values[6] = value; kw_args--; }
        }
        case  7:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_DY);
          if (value) { values[7] = value; kw_args--; }
        }
        case  8:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_DZ);
          if (value) { values[8] = value; kw_args--; }
        }
        case  9:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_VPoly);
          if (value) { values[9] = value; kw_args--; }
        }
        case 10:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_margin);
          if (value) { values[10] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "_Ves_Vmesh_Lin_SubFromD_cython") < 0)) __PYX_ERR(0, 255, __pyx_L3_error)
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case 11: values[10] = PyTuple_GET_ITEM(__pyx_args, 10);
        case 10: values[9] = PyTuple_GET_ITEM(__pyx_args, 9);
        case  9: values[8] = PyTuple_GET_ITEM(__pyx_args, 8);
        case  8: values[7] = PyTuple_GET_ITEM(__pyx_args, 7);
        case  7: values[6] = PyTuple_GET_ITEM(__pyx_args, 6);
        case  6: values[5] = PyTuple_GET_ITEM(__pyx_args, 5);
        values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
        values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    __pyx_v_dX = __pyx_PyFloat_AsDouble(values[0]); if (unlikely((__pyx_v_dX == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 255, __pyx_L3_error)
    __pyx_v_dY = __pyx_PyFloat_AsDouble(values[1]); if (unlikely((__pyx_v_dY == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 255, __pyx_L3_error)
    __pyx_v_dZ = __pyx_PyFloat_AsDouble(values[2]); if (unlikely((__pyx_v_dZ == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 255, __pyx_L3_error)
    __pyx_v_XMinMax = __Pyx_PyObject_to_MemoryviewSlice_dc_double(values[3]); if (unlikely(!__pyx_v_XMinMax.memview)) __PYX_ERR(0, 256, __pyx_L3_error)
    __pyx_v_YMinMax = __Pyx_PyObject_to_MemoryviewSlice_dc_double(values[4]); if (unlikely(!__pyx_v_YMinMax.memview)) __PYX_ERR(0, 256, __pyx_L3_error)
    __pyx_v_ZMinMax = __Pyx_PyObject_to_MemoryviewSlice_dc_double(values[5]); if (unlikely(!__pyx_v_ZMinMax.memview)) __PYX_ERR(0, 256, __pyx_L3_error)
    __pyx_v_DX = values[6];
    __pyx_v_DY = values[7];
    __pyx_v_DZ = values[8];
    __pyx_v_VPoly = values[9];
    if (values[10]) {
      __pyx_v_margin = __pyx_PyFloat_AsDouble(values[10]); if (unlikely((__pyx_v_margin == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 258, __pyx_L3_error)
    } else {
      __pyx_v_margin = ((double)1.e-9);
    }
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("_Ves_Vmesh_Lin_SubFromD_cython", 0, 6, 11, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 255, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("_cython_magic_ffb7650808bb7830760fff8d6d047f13._Ves_Vmesh_Lin_SubFromD_cython", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_46_cython_magic_ffb7650808bb7830760fff8d6d047f13_6_Ves_Vmesh_Lin_SubFromD_cython(__pyx_self, __pyx_v_dX, __pyx_v_dY, __pyx_v_dZ, __pyx_v_XMinMax, __pyx_v_YMinMax, __pyx_v_ZMinMax, __pyx_v_DX, __pyx_v_DY, __pyx_v_DZ, __pyx_v_VPoly, __pyx_v_margin);
 258:                                    double margin=1.e-9):
 259:     " Return the desired submesh indicated by the limits (DX,DY,DZ), for the desired resolution (dX,dY,dZ) "
 260: 
 261:     cdef double[::1] X, Y, Z
 262:     cdef double dXr, dYr, dZr, dV
 263:     cdef cnp.ndarray[long,ndim=1] indX, indY, indZ
 264:     cdef int NX, NY, NZ, Xn, Yn, Zn
 265:     cdef cnp.ndarray[double,ndim=2] Pts
 266:     cdef cnp.ndarray[long,ndim=1] ind
 267: 
 268:     # Get the actual X, Y and Z resolutions and mesh elements
+269:     X, dXr, indX, NX = _Ves_mesh_dlfromL_cython(XMinMax, dX, DX, margin=margin)
  __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_Ves_mesh_dlfromL_cython); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 269, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __pyx_memoryview_fromslice(__pyx_v_XMinMax, 1, (PyObject *(*)(char *)) __pyx_memview_get_double, (int (*)(char *, PyObject *)) __pyx_memview_set_double, 0);; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 269, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = PyFloat_FromDouble(__pyx_v_dX); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 269, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = PyTuple_New(3); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 269, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_GIVEREF(__pyx_t_2);
  PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_2);
  __Pyx_GIVEREF(__pyx_t_3);
  PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_t_3);
  __Pyx_INCREF(__pyx_v_DX);
  __Pyx_GIVEREF(__pyx_v_DX);
  PyTuple_SET_ITEM(__pyx_t_4, 2, __pyx_v_DX);
  __pyx_t_2 = 0;
  __pyx_t_3 = 0;
  __pyx_t_3 = PyDict_New(); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 269, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_2 = PyFloat_FromDouble(__pyx_v_margin); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 269, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_margin, __pyx_t_2) < 0) __PYX_ERR(0, 269, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_4, __pyx_t_3); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 269, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  if ((likely(PyTuple_CheckExact(__pyx_t_2))) || (PyList_CheckExact(__pyx_t_2))) {
    PyObject* sequence = __pyx_t_2;
    #if !CYTHON_COMPILING_IN_PYPY
    Py_ssize_t size = Py_SIZE(sequence);
    #else
    Py_ssize_t size = PySequence_Size(sequence);
    #endif
    if (unlikely(size != 4)) {
      if (size > 4) __Pyx_RaiseTooManyValuesError(4);
      else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
      __PYX_ERR(0, 269, __pyx_L1_error)
    }
    #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
    if (likely(PyTuple_CheckExact(sequence))) {
      __pyx_t_3 = PyTuple_GET_ITEM(sequence, 0); 
      __pyx_t_4 = PyTuple_GET_ITEM(sequence, 1); 
      __pyx_t_1 = PyTuple_GET_ITEM(sequence, 2); 
      __pyx_t_5 = PyTuple_GET_ITEM(sequence, 3); 
    } else {
      __pyx_t_3 = PyList_GET_ITEM(sequence, 0); 
      __pyx_t_4 = PyList_GET_ITEM(sequence, 1); 
      __pyx_t_1 = PyList_GET_ITEM(sequence, 2); 
      __pyx_t_5 = PyList_GET_ITEM(sequence, 3); 
    }
    __Pyx_INCREF(__pyx_t_3);
    __Pyx_INCREF(__pyx_t_4);
    __Pyx_INCREF(__pyx_t_1);
    __Pyx_INCREF(__pyx_t_5);
    #else
    {
      Py_ssize_t i;
      PyObject** temps[4] = {&__pyx_t_3,&__pyx_t_4,&__pyx_t_1,&__pyx_t_5};
      for (i=0; i < 4; i++) {
        PyObject* item = PySequence_ITEM(sequence, i); if (unlikely(!item)) __PYX_ERR(0, 269, __pyx_L1_error)
        __Pyx_GOTREF(item);
        *(temps[i]) = item;
      }
    }
    #endif
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  } else {
    Py_ssize_t index = -1;
    PyObject** temps[4] = {&__pyx_t_3,&__pyx_t_4,&__pyx_t_1,&__pyx_t_5};
    __pyx_t_6 = PyObject_GetIter(__pyx_t_2); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 269, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_t_7 = Py_TYPE(__pyx_t_6)->tp_iternext;
    for (index=0; index < 4; index++) {
      PyObject* item = __pyx_t_7(__pyx_t_6); if (unlikely(!item)) goto __pyx_L3_unpacking_failed;
      __Pyx_GOTREF(item);
      *(temps[index]) = item;
    }
    if (__Pyx_IternextUnpackEndCheck(__pyx_t_7(__pyx_t_6), 4) < 0) __PYX_ERR(0, 269, __pyx_L1_error)
    __pyx_t_7 = NULL;
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    goto __pyx_L4_unpacking_done;
    __pyx_L3_unpacking_failed:;
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __pyx_t_7 = NULL;
    if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
    __PYX_ERR(0, 269, __pyx_L1_error)
    __pyx_L4_unpacking_done:;
  }
  __pyx_t_8 = __Pyx_PyObject_to_MemoryviewSlice_dc_double(__pyx_t_3);
  if (unlikely(!__pyx_t_8.memview)) __PYX_ERR(0, 269, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_9 = __pyx_PyFloat_AsDouble(__pyx_t_4); if (unlikely((__pyx_t_9 == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 269, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 269, __pyx_L1_error)
  __pyx_t_10 = __Pyx_PyInt_As_int(__pyx_t_5); if (unlikely((__pyx_t_10 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 269, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __pyx_v_X = __pyx_t_8;
  __pyx_t_8.memview = NULL;
  __pyx_t_8.data = NULL;
  __pyx_v_dXr = __pyx_t_9;
  __pyx_t_11 = ((PyArrayObject *)__pyx_t_1);
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_indX.rcbuffer->pybuffer);
    __pyx_t_12 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_indX.rcbuffer->pybuffer, (PyObject*)__pyx_t_11, &__Pyx_TypeInfo_long, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack);
    if (unlikely(__pyx_t_12 < 0)) {
      PyErr_Fetch(&__pyx_t_13, &__pyx_t_14, &__pyx_t_15);
      if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_indX.rcbuffer->pybuffer, (PyObject*)__pyx_v_indX, &__Pyx_TypeInfo_long, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {
        Py_XDECREF(__pyx_t_13); Py_XDECREF(__pyx_t_14); Py_XDECREF(__pyx_t_15);
        __Pyx_RaiseBufferFallbackError();
      } else {
        PyErr_Restore(__pyx_t_13, __pyx_t_14, __pyx_t_15);
      }
    }
    __pyx_pybuffernd_indX.diminfo[0].strides = __pyx_pybuffernd_indX.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_indX.diminfo[0].shape = __pyx_pybuffernd_indX.rcbuffer->pybuffer.shape[0];
    if (unlikely(__pyx_t_12 < 0)) __PYX_ERR(0, 269, __pyx_L1_error)
  }
  __pyx_t_11 = 0;
  __pyx_v_indX = ((PyArrayObject *)__pyx_t_1);
  __pyx_t_1 = 0;
  __pyx_v_NX = __pyx_t_10;
+270:     Y, dYr, indY, NY = _Ves_mesh_dlfromL_cython(YMinMax, dY, DY, margin=margin)
  __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_Ves_mesh_dlfromL_cython); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 270, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_5 = __pyx_memoryview_fromslice(__pyx_v_YMinMax, 1, (PyObject *(*)(char *)) __pyx_memview_get_double, (int (*)(char *, PyObject *)) __pyx_memview_set_double, 0);; if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 270, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_t_1 = PyFloat_FromDouble(__pyx_v_dY); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 270, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_4 = PyTuple_New(3); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 270, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_GIVEREF(__pyx_t_5);
  PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_5);
  __Pyx_GIVEREF(__pyx_t_1);
  PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_t_1);
  __Pyx_INCREF(__pyx_v_DY);
  __Pyx_GIVEREF(__pyx_v_DY);
  PyTuple_SET_ITEM(__pyx_t_4, 2, __pyx_v_DY);
  __pyx_t_5 = 0;
  __pyx_t_1 = 0;
  __pyx_t_1 = PyDict_New(); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 270, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_5 = PyFloat_FromDouble(__pyx_v_margin); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 270, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_margin, __pyx_t_5) < 0) __PYX_ERR(0, 270, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __pyx_t_5 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_4, __pyx_t_1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 270, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if ((likely(PyTuple_CheckExact(__pyx_t_5))) || (PyList_CheckExact(__pyx_t_5))) {
    PyObject* sequence = __pyx_t_5;
    #if !CYTHON_COMPILING_IN_PYPY
    Py_ssize_t size = Py_SIZE(sequence);
    #else
    Py_ssize_t size = PySequence_Size(sequence);
    #endif
    if (unlikely(size != 4)) {
      if (size > 4) __Pyx_RaiseTooManyValuesError(4);
      else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
      __PYX_ERR(0, 270, __pyx_L1_error)
    }
    #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
    if (likely(PyTuple_CheckExact(sequence))) {
      __pyx_t_1 = PyTuple_GET_ITEM(sequence, 0); 
      __pyx_t_4 = PyTuple_GET_ITEM(sequence, 1); 
      __pyx_t_2 = PyTuple_GET_ITEM(sequence, 2); 
      __pyx_t_3 = PyTuple_GET_ITEM(sequence, 3); 
    } else {
      __pyx_t_1 = PyList_GET_ITEM(sequence, 0); 
      __pyx_t_4 = PyList_GET_ITEM(sequence, 1); 
      __pyx_t_2 = PyList_GET_ITEM(sequence, 2); 
      __pyx_t_3 = PyList_GET_ITEM(sequence, 3); 
    }
    __Pyx_INCREF(__pyx_t_1);
    __Pyx_INCREF(__pyx_t_4);
    __Pyx_INCREF(__pyx_t_2);
    __Pyx_INCREF(__pyx_t_3);
    #else
    {
      Py_ssize_t i;
      PyObject** temps[4] = {&__pyx_t_1,&__pyx_t_4,&__pyx_t_2,&__pyx_t_3};
      for (i=0; i < 4; i++) {
        PyObject* item = PySequence_ITEM(sequence, i); if (unlikely(!item)) __PYX_ERR(0, 270, __pyx_L1_error)
        __Pyx_GOTREF(item);
        *(temps[i]) = item;
      }
    }
    #endif
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  } else {
    Py_ssize_t index = -1;
    PyObject** temps[4] = {&__pyx_t_1,&__pyx_t_4,&__pyx_t_2,&__pyx_t_3};
    __pyx_t_6 = PyObject_GetIter(__pyx_t_5); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 270, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __pyx_t_7 = Py_TYPE(__pyx_t_6)->tp_iternext;
    for (index=0; index < 4; index++) {
      PyObject* item = __pyx_t_7(__pyx_t_6); if (unlikely(!item)) goto __pyx_L5_unpacking_failed;
      __Pyx_GOTREF(item);
      *(temps[index]) = item;
    }
    if (__Pyx_IternextUnpackEndCheck(__pyx_t_7(__pyx_t_6), 4) < 0) __PYX_ERR(0, 270, __pyx_L1_error)
    __pyx_t_7 = NULL;
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    goto __pyx_L6_unpacking_done;
    __pyx_L5_unpacking_failed:;
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __pyx_t_7 = NULL;
    if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
    __PYX_ERR(0, 270, __pyx_L1_error)
    __pyx_L6_unpacking_done:;
  }
  __pyx_t_8 = __Pyx_PyObject_to_MemoryviewSlice_dc_double(__pyx_t_1);
  if (unlikely(!__pyx_t_8.memview)) __PYX_ERR(0, 270, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_9 = __pyx_PyFloat_AsDouble(__pyx_t_4); if (unlikely((__pyx_t_9 == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 270, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  if (!(likely(((__pyx_t_2) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_2, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 270, __pyx_L1_error)
  __pyx_t_10 = __Pyx_PyInt_As_int(__pyx_t_3); if (unlikely((__pyx_t_10 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 270, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_v_Y = __pyx_t_8;
  __pyx_t_8.memview = NULL;
  __pyx_t_8.data = NULL;
  __pyx_v_dYr = __pyx_t_9;
  __pyx_t_11 = ((PyArrayObject *)__pyx_t_2);
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_indY.rcbuffer->pybuffer);
    __pyx_t_12 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_indY.rcbuffer->pybuffer, (PyObject*)__pyx_t_11, &__Pyx_TypeInfo_long, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack);
    if (unlikely(__pyx_t_12 < 0)) {
      PyErr_Fetch(&__pyx_t_15, &__pyx_t_14, &__pyx_t_13);
      if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_indY.rcbuffer->pybuffer, (PyObject*)__pyx_v_indY, &__Pyx_TypeInfo_long, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {
        Py_XDECREF(__pyx_t_15); Py_XDECREF(__pyx_t_14); Py_XDECREF(__pyx_t_13);
        __Pyx_RaiseBufferFallbackError();
      } else {
        PyErr_Restore(__pyx_t_15, __pyx_t_14, __pyx_t_13);
      }
    }
    __pyx_pybuffernd_indY.diminfo[0].strides = __pyx_pybuffernd_indY.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_indY.diminfo[0].shape = __pyx_pybuffernd_indY.rcbuffer->pybuffer.shape[0];
    if (unlikely(__pyx_t_12 < 0)) __PYX_ERR(0, 270, __pyx_L1_error)
  }
  __pyx_t_11 = 0;
  __pyx_v_indY = ((PyArrayObject *)__pyx_t_2);
  __pyx_t_2 = 0;
  __pyx_v_NY = __pyx_t_10;
+271:     Z, dZr, indZ, NZ = _Ves_mesh_dlfromL_cython(ZMinMax, dZ, DZ, margin=margin)
  __pyx_t_5 = __Pyx_GetModuleGlobalName(__pyx_n_s_Ves_mesh_dlfromL_cython); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 271, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_t_3 = __pyx_memoryview_fromslice(__pyx_v_ZMinMax, 1, (PyObject *(*)(char *)) __pyx_memview_get_double, (int (*)(char *, PyObject *)) __pyx_memview_set_double, 0);; if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 271, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_2 = PyFloat_FromDouble(__pyx_v_dZ); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 271, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_4 = PyTuple_New(3); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 271, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_GIVEREF(__pyx_t_3);
  PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_3);
  __Pyx_GIVEREF(__pyx_t_2);
  PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_t_2);
  __Pyx_INCREF(__pyx_v_DZ);
  __Pyx_GIVEREF(__pyx_v_DZ);
  PyTuple_SET_ITEM(__pyx_t_4, 2, __pyx_v_DZ);
  __pyx_t_3 = 0;
  __pyx_t_2 = 0;
  __pyx_t_2 = PyDict_New(); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 271, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = PyFloat_FromDouble(__pyx_v_margin); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 271, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_margin, __pyx_t_3) < 0) __PYX_ERR(0, 271, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_t_4, __pyx_t_2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 271, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  if ((likely(PyTuple_CheckExact(__pyx_t_3))) || (PyList_CheckExact(__pyx_t_3))) {
    PyObject* sequence = __pyx_t_3;
    #if !CYTHON_COMPILING_IN_PYPY
    Py_ssize_t size = Py_SIZE(sequence);
    #else
    Py_ssize_t size = PySequence_Size(sequence);
    #endif
    if (unlikely(size != 4)) {
      if (size > 4) __Pyx_RaiseTooManyValuesError(4);
      else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
      __PYX_ERR(0, 271, __pyx_L1_error)
    }
    #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
    if (likely(PyTuple_CheckExact(sequence))) {
      __pyx_t_2 = PyTuple_GET_ITEM(sequence, 0); 
      __pyx_t_4 = PyTuple_GET_ITEM(sequence, 1); 
      __pyx_t_5 = PyTuple_GET_ITEM(sequence, 2); 
      __pyx_t_1 = PyTuple_GET_ITEM(sequence, 3); 
    } else {
      __pyx_t_2 = PyList_GET_ITEM(sequence, 0); 
      __pyx_t_4 = PyList_GET_ITEM(sequence, 1); 
      __pyx_t_5 = PyList_GET_ITEM(sequence, 2); 
      __pyx_t_1 = PyList_GET_ITEM(sequence, 3); 
    }
    __Pyx_INCREF(__pyx_t_2);
    __Pyx_INCREF(__pyx_t_4);
    __Pyx_INCREF(__pyx_t_5);
    __Pyx_INCREF(__pyx_t_1);
    #else
    {
      Py_ssize_t i;
      PyObject** temps[4] = {&__pyx_t_2,&__pyx_t_4,&__pyx_t_5,&__pyx_t_1};
      for (i=0; i < 4; i++) {
        PyObject* item = PySequence_ITEM(sequence, i); if (unlikely(!item)) __PYX_ERR(0, 271, __pyx_L1_error)
        __Pyx_GOTREF(item);
        *(temps[i]) = item;
      }
    }
    #endif
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  } else {
    Py_ssize_t index = -1;
    PyObject** temps[4] = {&__pyx_t_2,&__pyx_t_4,&__pyx_t_5,&__pyx_t_1};
    __pyx_t_6 = PyObject_GetIter(__pyx_t_3); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 271, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_t_7 = Py_TYPE(__pyx_t_6)->tp_iternext;
    for (index=0; index < 4; index++) {
      PyObject* item = __pyx_t_7(__pyx_t_6); if (unlikely(!item)) goto __pyx_L7_unpacking_failed;
      __Pyx_GOTREF(item);
      *(temps[index]) = item;
    }
    if (__Pyx_IternextUnpackEndCheck(__pyx_t_7(__pyx_t_6), 4) < 0) __PYX_ERR(0, 271, __pyx_L1_error)
    __pyx_t_7 = NULL;
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    goto __pyx_L8_unpacking_done;
    __pyx_L7_unpacking_failed:;
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __pyx_t_7 = NULL;
    if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
    __PYX_ERR(0, 271, __pyx_L1_error)
    __pyx_L8_unpacking_done:;
  }
  __pyx_t_8 = __Pyx_PyObject_to_MemoryviewSlice_dc_double(__pyx_t_2);
  if (unlikely(!__pyx_t_8.memview)) __PYX_ERR(0, 271, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_9 = __pyx_PyFloat_AsDouble(__pyx_t_4); if (unlikely((__pyx_t_9 == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 271, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  if (!(likely(((__pyx_t_5) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_5, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 271, __pyx_L1_error)
  __pyx_t_10 = __Pyx_PyInt_As_int(__pyx_t_1); if (unlikely((__pyx_t_10 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 271, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v_Z = __pyx_t_8;
  __pyx_t_8.memview = NULL;
  __pyx_t_8.data = NULL;
  __pyx_v_dZr = __pyx_t_9;
  __pyx_t_11 = ((PyArrayObject *)__pyx_t_5);
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_indZ.rcbuffer->pybuffer);
    __pyx_t_12 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_indZ.rcbuffer->pybuffer, (PyObject*)__pyx_t_11, &__Pyx_TypeInfo_long, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack);
    if (unlikely(__pyx_t_12 < 0)) {
      PyErr_Fetch(&__pyx_t_13, &__pyx_t_14, &__pyx_t_15);
      if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_indZ.rcbuffer->pybuffer, (PyObject*)__pyx_v_indZ, &__Pyx_TypeInfo_long, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {
        Py_XDECREF(__pyx_t_13); Py_XDECREF(__pyx_t_14); Py_XDECREF(__pyx_t_15);
        __Pyx_RaiseBufferFallbackError();
      } else {
        PyErr_Restore(__pyx_t_13, __pyx_t_14, __pyx_t_15);
      }
    }
    __pyx_pybuffernd_indZ.diminfo[0].strides = __pyx_pybuffernd_indZ.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_indZ.diminfo[0].shape = __pyx_pybuffernd_indZ.rcbuffer->pybuffer.shape[0];
    if (unlikely(__pyx_t_12 < 0)) __PYX_ERR(0, 271, __pyx_L1_error)
  }
  __pyx_t_11 = 0;
  __pyx_v_indZ = ((PyArrayObject *)__pyx_t_5);
  __pyx_t_5 = 0;
  __pyx_v_NZ = __pyx_t_10;
+272:     Xn, Yn, Zn = len(X), len(Y), len(Z)
  __pyx_t_3 = __pyx_memoryview_fromslice(__pyx_v_X, 1, (PyObject *(*)(char *)) __pyx_memview_get_double, (int (*)(char *, PyObject *)) __pyx_memview_set_double, 0);; if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 272, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_16 = PyObject_Length(__pyx_t_3); if (unlikely(__pyx_t_16 == -1)) __PYX_ERR(0, 272, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_3 = __pyx_memoryview_fromslice(__pyx_v_Y, 1, (PyObject *(*)(char *)) __pyx_memview_get_double, (int (*)(char *, PyObject *)) __pyx_memview_set_double, 0);; if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 272, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_17 = PyObject_Length(__pyx_t_3); if (unlikely(__pyx_t_17 == -1)) __PYX_ERR(0, 272, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_3 = __pyx_memoryview_fromslice(__pyx_v_Z, 1, (PyObject *(*)(char *)) __pyx_memview_get_double, (int (*)(char *, PyObject *)) __pyx_memview_set_double, 0);; if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 272, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_18 = PyObject_Length(__pyx_t_3); if (unlikely(__pyx_t_18 == -1)) __PYX_ERR(0, 272, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_v_Xn = __pyx_t_16;
  __pyx_v_Yn = __pyx_t_17;
  __pyx_v_Zn = __pyx_t_18;
 273: 
+274:     Pts = np.array([np.tile(X,(Yn*Zn,1)).flatten(), np.tile(np.repeat(Y,Xn),(Zn,1)).flatten(), np.repeat(Z,Xn*Yn)])
  __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 274, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_array); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 274, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 274, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_tile); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 274, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = __pyx_memoryview_fromslice(__pyx_v_X, 1, (PyObject *(*)(char *)) __pyx_memview_get_double, (int (*)(char *, PyObject *)) __pyx_memview_set_double, 0);; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 274, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_19 = __Pyx_PyInt_From_int((__pyx_v_Yn * __pyx_v_Zn)); if (unlikely(!__pyx_t_19)) __PYX_ERR(0, 274, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_19);
  __pyx_t_20 = PyTuple_New(2); if (unlikely(!__pyx_t_20)) __PYX_ERR(0, 274, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_20);
  __Pyx_GIVEREF(__pyx_t_19);
  PyTuple_SET_ITEM(__pyx_t_20, 0, __pyx_t_19);
  __Pyx_INCREF(__pyx_int_1);
  __Pyx_GIVEREF(__pyx_int_1);
  PyTuple_SET_ITEM(__pyx_t_20, 1, __pyx_int_1);
  __pyx_t_19 = 0;
  __pyx_t_19 = NULL;
  __pyx_t_10 = 0;
  if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_6))) {
    __pyx_t_19 = PyMethod_GET_SELF(__pyx_t_6);
    if (likely(__pyx_t_19)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6);
      __Pyx_INCREF(__pyx_t_19);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_6, function);
      __pyx_t_10 = 1;
    }
  }
  #if CYTHON_FAST_PYCALL
  if (PyFunction_Check(__pyx_t_6)) {
    PyObject *__pyx_temp[3] = {__pyx_t_19, __pyx_t_2, __pyx_t_20};
    __pyx_t_4 = __Pyx_PyFunction_FastCall(__pyx_t_6, __pyx_temp+1-__pyx_t_10, 2+__pyx_t_10); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 274, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_19); __pyx_t_19 = 0;
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_DECREF(__pyx_t_20); __pyx_t_20 = 0;
  } else
  #endif
  #if CYTHON_FAST_PYCCALL
  if (__Pyx_PyFastCFunction_Check(__pyx_t_6)) {
    PyObject *__pyx_temp[3] = {__pyx_t_19, __pyx_t_2, __pyx_t_20};
    __pyx_t_4 = __Pyx_PyCFunction_FastCall(__pyx_t_6, __pyx_temp+1-__pyx_t_10, 2+__pyx_t_10); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 274, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_19); __pyx_t_19 = 0;
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_DECREF(__pyx_t_20); __pyx_t_20 = 0;
  } else
  #endif
  {
    __pyx_t_21 = PyTuple_New(2+__pyx_t_10); if (unlikely(!__pyx_t_21)) __PYX_ERR(0, 274, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_21);
    if (__pyx_t_19) {
      __Pyx_GIVEREF(__pyx_t_19); PyTuple_SET_ITEM(__pyx_t_21, 0, __pyx_t_19); __pyx_t_19 = NULL;
    }
    __Pyx_GIVEREF(__pyx_t_2);
    PyTuple_SET_ITEM(__pyx_t_21, 0+__pyx_t_10, __pyx_t_2);
    __Pyx_GIVEREF(__pyx_t_20);
    PyTuple_SET_ITEM(__pyx_t_21, 1+__pyx_t_10, __pyx_t_20);
    __pyx_t_2 = 0;
    __pyx_t_20 = 0;
    __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_6, __pyx_t_21, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 274, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_21); __pyx_t_21 = 0;
  }
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_flatten); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 274, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_4 = NULL;
  if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_6))) {
    __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_6);
    if (likely(__pyx_t_4)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6);
      __Pyx_INCREF(__pyx_t_4);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_6, function);
    }
  }
  if (__pyx_t_4) {
    __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_6, __pyx_t_4); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 274, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  } else {
    __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_t_6); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 274, __pyx_L1_error)
  }
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  __pyx_t_21 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_21)) __PYX_ERR(0, 274, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_21);
  __pyx_t_20 = __Pyx_PyObject_GetAttrStr(__pyx_t_21, __pyx_n_s_tile); if (unlikely(!__pyx_t_20)) __PYX_ERR(0, 274, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_20);
  __Pyx_DECREF(__pyx_t_21); __pyx_t_21 = 0;
  __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 274, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_19 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_repeat); if (unlikely(!__pyx_t_19)) __PYX_ERR(0, 274, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_19);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = __pyx_memoryview_fromslice(__pyx_v_Y, 1, (PyObject *(*)(char *)) __pyx_memview_get_double, (int (*)(char *, PyObject *)) __pyx_memview_set_double, 0);; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 274, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_22 = __Pyx_PyInt_From_int(__pyx_v_Xn); if (unlikely(!__pyx_t_22)) __PYX_ERR(0, 274, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_22);
  __pyx_t_23 = NULL;
  __pyx_t_10 = 0;
  if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_19))) {
    __pyx_t_23 = PyMethod_GET_SELF(__pyx_t_19);
    if (likely(__pyx_t_23)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_19);
      __Pyx_INCREF(__pyx_t_23);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_19, function);
      __pyx_t_10 = 1;
    }
  }
  #if CYTHON_FAST_PYCALL
  if (PyFunction_Check(__pyx_t_19)) {
    PyObject *__pyx_temp[3] = {__pyx_t_23, __pyx_t_2, __pyx_t_22};
    __pyx_t_21 = __Pyx_PyFunction_FastCall(__pyx_t_19, __pyx_temp+1-__pyx_t_10, 2+__pyx_t_10); if (unlikely(!__pyx_t_21)) __PYX_ERR(0, 274, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_23); __pyx_t_23 = 0;
    __Pyx_GOTREF(__pyx_t_21);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_DECREF(__pyx_t_22); __pyx_t_22 = 0;
  } else
  #endif
  #if CYTHON_FAST_PYCCALL
  if (__Pyx_PyFastCFunction_Check(__pyx_t_19)) {
    PyObject *__pyx_temp[3] = {__pyx_t_23, __pyx_t_2, __pyx_t_22};
    __pyx_t_21 = __Pyx_PyCFunction_FastCall(__pyx_t_19, __pyx_temp+1-__pyx_t_10, 2+__pyx_t_10); if (unlikely(!__pyx_t_21)) __PYX_ERR(0, 274, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_23); __pyx_t_23 = 0;
    __Pyx_GOTREF(__pyx_t_21);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_DECREF(__pyx_t_22); __pyx_t_22 = 0;
  } else
  #endif
  {
    __pyx_t_24 = PyTuple_New(2+__pyx_t_10); if (unlikely(!__pyx_t_24)) __PYX_ERR(0, 274, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_24);
    if (__pyx_t_23) {
      __Pyx_GIVEREF(__pyx_t_23); PyTuple_SET_ITEM(__pyx_t_24, 0, __pyx_t_23); __pyx_t_23 = NULL;
    }
    __Pyx_GIVEREF(__pyx_t_2);
    PyTuple_SET_ITEM(__pyx_t_24, 0+__pyx_t_10, __pyx_t_2);
    __Pyx_GIVEREF(__pyx_t_22);
    PyTuple_SET_ITEM(__pyx_t_24, 1+__pyx_t_10, __pyx_t_22);
    __pyx_t_2 = 0;
    __pyx_t_22 = 0;
    __pyx_t_21 = __Pyx_PyObject_Call(__pyx_t_19, __pyx_t_24, NULL); if (unlikely(!__pyx_t_21)) __PYX_ERR(0, 274, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_21);
    __Pyx_DECREF(__pyx_t_24); __pyx_t_24 = 0;
  }
  __Pyx_DECREF(__pyx_t_19); __pyx_t_19 = 0;
  __pyx_t_19 = __Pyx_PyInt_From_int(__pyx_v_Zn); if (unlikely(!__pyx_t_19)) __PYX_ERR(0, 274, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_19);
  __pyx_t_24 = PyTuple_New(2); if (unlikely(!__pyx_t_24)) __PYX_ERR(0, 274, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_24);
  __Pyx_GIVEREF(__pyx_t_19);
  PyTuple_SET_ITEM(__pyx_t_24, 0, __pyx_t_19);
  __Pyx_INCREF(__pyx_int_1);
  __Pyx_GIVEREF(__pyx_int_1);
  PyTuple_SET_ITEM(__pyx_t_24, 1, __pyx_int_1);
  __pyx_t_19 = 0;
  __pyx_t_19 = NULL;
  __pyx_t_10 = 0;
  if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_20))) {
    __pyx_t_19 = PyMethod_GET_SELF(__pyx_t_20);
    if (likely(__pyx_t_19)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_20);
      __Pyx_INCREF(__pyx_t_19);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_20, function);
      __pyx_t_10 = 1;
    }
  }
  #if CYTHON_FAST_PYCALL
  if (PyFunction_Check(__pyx_t_20)) {
    PyObject *__pyx_temp[3] = {__pyx_t_19, __pyx_t_21, __pyx_t_24};
    __pyx_t_4 = __Pyx_PyFunction_FastCall(__pyx_t_20, __pyx_temp+1-__pyx_t_10, 2+__pyx_t_10); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 274, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_19); __pyx_t_19 = 0;
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_21); __pyx_t_21 = 0;
    __Pyx_DECREF(__pyx_t_24); __pyx_t_24 = 0;
  } else
  #endif
  #if CYTHON_FAST_PYCCALL
  if (__Pyx_PyFastCFunction_Check(__pyx_t_20)) {
    PyObject *__pyx_temp[3] = {__pyx_t_19, __pyx_t_21, __pyx_t_24};
    __pyx_t_4 = __Pyx_PyCFunction_FastCall(__pyx_t_20, __pyx_temp+1-__pyx_t_10, 2+__pyx_t_10); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 274, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_19); __pyx_t_19 = 0;
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_21); __pyx_t_21 = 0;
    __Pyx_DECREF(__pyx_t_24); __pyx_t_24 = 0;
  } else
  #endif
  {
    __pyx_t_22 = PyTuple_New(2+__pyx_t_10); if (unlikely(!__pyx_t_22)) __PYX_ERR(0, 274, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_22);
    if (__pyx_t_19) {
      __Pyx_GIVEREF(__pyx_t_19); PyTuple_SET_ITEM(__pyx_t_22, 0, __pyx_t_19); __pyx_t_19 = NULL;
    }
    __Pyx_GIVEREF(__pyx_t_21);
    PyTuple_SET_ITEM(__pyx_t_22, 0+__pyx_t_10, __pyx_t_21);
    __Pyx_GIVEREF(__pyx_t_24);
    PyTuple_SET_ITEM(__pyx_t_22, 1+__pyx_t_10, __pyx_t_24);
    __pyx_t_21 = 0;
    __pyx_t_24 = 0;
    __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_20, __pyx_t_22, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 274, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_22); __pyx_t_22 = 0;
  }
  __Pyx_DECREF(__pyx_t_20); __pyx_t_20 = 0;
  __pyx_t_20 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_flatten); if (unlikely(!__pyx_t_20)) __PYX_ERR(0, 274, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_20);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_4 = NULL;
  if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_20))) {
    __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_20);
    if (likely(__pyx_t_4)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_20);
      __Pyx_INCREF(__pyx_t_4);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_20, function);
    }
  }
  if (__pyx_t_4) {
    __pyx_t_6 = __Pyx_PyObject_CallOneArg(__pyx_t_20, __pyx_t_4); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 274, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  } else {
    __pyx_t_6 = __Pyx_PyObject_CallNoArg(__pyx_t_20); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 274, __pyx_L1_error)
  }
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_DECREF(__pyx_t_20); __pyx_t_20 = 0;
  __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 274, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_22 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_repeat); if (unlikely(!__pyx_t_22)) __PYX_ERR(0, 274, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_22);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_4 = __pyx_memoryview_fromslice(__pyx_v_Z, 1, (PyObject *(*)(char *)) __pyx_memview_get_double, (int (*)(char *, PyObject *)) __pyx_memview_set_double, 0);; if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 274, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_24 = __Pyx_PyInt_From_int((__pyx_v_Xn * __pyx_v_Yn)); if (unlikely(!__pyx_t_24)) __PYX_ERR(0, 274, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_24);
  __pyx_t_21 = NULL;
  __pyx_t_10 = 0;
  if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_22))) {
    __pyx_t_21 = PyMethod_GET_SELF(__pyx_t_22);
    if (likely(__pyx_t_21)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_22);
      __Pyx_INCREF(__pyx_t_21);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_22, function);
      __pyx_t_10 = 1;
    }
  }
  #if CYTHON_FAST_PYCALL
  if (PyFunction_Check(__pyx_t_22)) {
    PyObject *__pyx_temp[3] = {__pyx_t_21, __pyx_t_4, __pyx_t_24};
    __pyx_t_20 = __Pyx_PyFunction_FastCall(__pyx_t_22, __pyx_temp+1-__pyx_t_10, 2+__pyx_t_10); if (unlikely(!__pyx_t_20)) __PYX_ERR(0, 274, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_21); __pyx_t_21 = 0;
    __Pyx_GOTREF(__pyx_t_20);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_DECREF(__pyx_t_24); __pyx_t_24 = 0;
  } else
  #endif
  #if CYTHON_FAST_PYCCALL
  if (__Pyx_PyFastCFunction_Check(__pyx_t_22)) {
    PyObject *__pyx_temp[3] = {__pyx_t_21, __pyx_t_4, __pyx_t_24};
    __pyx_t_20 = __Pyx_PyCFunction_FastCall(__pyx_t_22, __pyx_temp+1-__pyx_t_10, 2+__pyx_t_10); if (unlikely(!__pyx_t_20)) __PYX_ERR(0, 274, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_21); __pyx_t_21 = 0;
    __Pyx_GOTREF(__pyx_t_20);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_DECREF(__pyx_t_24); __pyx_t_24 = 0;
  } else
  #endif
  {
    __pyx_t_19 = PyTuple_New(2+__pyx_t_10); if (unlikely(!__pyx_t_19)) __PYX_ERR(0, 274, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_19);
    if (__pyx_t_21) {
      __Pyx_GIVEREF(__pyx_t_21); PyTuple_SET_ITEM(__pyx_t_19, 0, __pyx_t_21); __pyx_t_21 = NULL;
    }
    __Pyx_GIVEREF(__pyx_t_4);
    PyTuple_SET_ITEM(__pyx_t_19, 0+__pyx_t_10, __pyx_t_4);
    __Pyx_GIVEREF(__pyx_t_24);
    PyTuple_SET_ITEM(__pyx_t_19, 1+__pyx_t_10, __pyx_t_24);
    __pyx_t_4 = 0;
    __pyx_t_24 = 0;
    __pyx_t_20 = __Pyx_PyObject_Call(__pyx_t_22, __pyx_t_19, NULL); if (unlikely(!__pyx_t_20)) __PYX_ERR(0, 274, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_20);
    __Pyx_DECREF(__pyx_t_19); __pyx_t_19 = 0;
  }
  __Pyx_DECREF(__pyx_t_22); __pyx_t_22 = 0;
  __pyx_t_22 = PyList_New(3); if (unlikely(!__pyx_t_22)) __PYX_ERR(0, 274, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_22);
  __Pyx_GIVEREF(__pyx_t_1);
  PyList_SET_ITEM(__pyx_t_22, 0, __pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_6);
  PyList_SET_ITEM(__pyx_t_22, 1, __pyx_t_6);
  __Pyx_GIVEREF(__pyx_t_20);
  PyList_SET_ITEM(__pyx_t_22, 2, __pyx_t_20);
  __pyx_t_1 = 0;
  __pyx_t_6 = 0;
  __pyx_t_20 = 0;
  __pyx_t_20 = NULL;
  if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_5))) {
    __pyx_t_20 = PyMethod_GET_SELF(__pyx_t_5);
    if (likely(__pyx_t_20)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5);
      __Pyx_INCREF(__pyx_t_20);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_5, function);
    }
  }
  if (!__pyx_t_20) {
    __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_t_5, __pyx_t_22); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 274, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_22); __pyx_t_22 = 0;
    __Pyx_GOTREF(__pyx_t_3);
  } else {
    #if CYTHON_FAST_PYCALL
    if (PyFunction_Check(__pyx_t_5)) {
      PyObject *__pyx_temp[2] = {__pyx_t_20, __pyx_t_22};
      __pyx_t_3 = __Pyx_PyFunction_FastCall(__pyx_t_5, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 274, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_20); __pyx_t_20 = 0;
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_22); __pyx_t_22 = 0;
    } else
    #endif
    #if CYTHON_FAST_PYCCALL
    if (__Pyx_PyFastCFunction_Check(__pyx_t_5)) {
      PyObject *__pyx_temp[2] = {__pyx_t_20, __pyx_t_22};
      __pyx_t_3 = __Pyx_PyCFunction_FastCall(__pyx_t_5, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 274, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_20); __pyx_t_20 = 0;
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_22); __pyx_t_22 = 0;
    } else
    #endif
    {
      __pyx_t_6 = PyTuple_New(1+1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 274, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_6);
      __Pyx_GIVEREF(__pyx_t_20); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_20); __pyx_t_20 = NULL;
      __Pyx_GIVEREF(__pyx_t_22);
      PyTuple_SET_ITEM(__pyx_t_6, 0+1, __pyx_t_22);
      __pyx_t_22 = 0;
      __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_t_6, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 274, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    }
  }
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  if (!(likely(((__pyx_t_3) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_3, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 274, __pyx_L1_error)
  __pyx_t_25 = ((PyArrayObject *)__pyx_t_3);
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_Pts.rcbuffer->pybuffer);
    __pyx_t_10 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_Pts.rcbuffer->pybuffer, (PyObject*)__pyx_t_25, &__Pyx_TypeInfo_double, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack);
    if (unlikely(__pyx_t_10 < 0)) {
      PyErr_Fetch(&__pyx_t_15, &__pyx_t_14, &__pyx_t_13);
      if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_Pts.rcbuffer->pybuffer, (PyObject*)__pyx_v_Pts, &__Pyx_TypeInfo_double, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) {
        Py_XDECREF(__pyx_t_15); Py_XDECREF(__pyx_t_14); Py_XDECREF(__pyx_t_13);
        __Pyx_RaiseBufferFallbackError();
      } else {
        PyErr_Restore(__pyx_t_15, __pyx_t_14, __pyx_t_13);
      }
    }
    __pyx_pybuffernd_Pts.diminfo[0].strides = __pyx_pybuffernd_Pts.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_Pts.diminfo[0].shape = __pyx_pybuffernd_Pts.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_Pts.diminfo[1].strides = __pyx_pybuffernd_Pts.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_Pts.diminfo[1].shape = __pyx_pybuffernd_Pts.rcbuffer->pybuffer.shape[1];
    if (unlikely(__pyx_t_10 < 0)) __PYX_ERR(0, 274, __pyx_L1_error)
  }
  __pyx_t_25 = 0;
  __pyx_v_Pts = ((PyArrayObject *)__pyx_t_3);
  __pyx_t_3 = 0;
+275:     ind = np.repeat(NX*NY*indZ,Xn*Yn) + np.tile(np.repeat(NX*indY,Xn),(Zn,1)).flatten() + np.tile(indX,(Yn*Zn,1)).flatten()
  __pyx_t_5 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 275, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_n_s_repeat); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 275, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __pyx_t_5 = __Pyx_PyInt_From_int((__pyx_v_NX * __pyx_v_NY)); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 275, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_t_22 = PyNumber_Multiply(__pyx_t_5, ((PyObject *)__pyx_v_indZ)); if (unlikely(!__pyx_t_22)) __PYX_ERR(0, 275, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_22);
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __pyx_t_5 = __Pyx_PyInt_From_int((__pyx_v_Xn * __pyx_v_Yn)); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 275, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_t_20 = NULL;
  __pyx_t_10 = 0;
  if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_6))) {
    __pyx_t_20 = PyMethod_GET_SELF(__pyx_t_6);
    if (likely(__pyx_t_20)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6);
      __Pyx_INCREF(__pyx_t_20);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_6, function);
      __pyx_t_10 = 1;
    }
  }
  #if CYTHON_FAST_PYCALL
  if (PyFunction_Check(__pyx_t_6)) {
    PyObject *__pyx_temp[3] = {__pyx_t_20, __pyx_t_22, __pyx_t_5};
    __pyx_t_3 = __Pyx_PyFunction_FastCall(__pyx_t_6, __pyx_temp+1-__pyx_t_10, 2+__pyx_t_10); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 275, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_20); __pyx_t_20 = 0;
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_22); __pyx_t_22 = 0;
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  } else
  #endif
  #if CYTHON_FAST_PYCCALL
  if (__Pyx_PyFastCFunction_Check(__pyx_t_6)) {
    PyObject *__pyx_temp[3] = {__pyx_t_20, __pyx_t_22, __pyx_t_5};
    __pyx_t_3 = __Pyx_PyCFunction_FastCall(__pyx_t_6, __pyx_temp+1-__pyx_t_10, 2+__pyx_t_10); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 275, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_20); __pyx_t_20 = 0;
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_22); __pyx_t_22 = 0;
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  } else
  #endif
  {
    __pyx_t_1 = PyTuple_New(2+__pyx_t_10); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 275, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    if (__pyx_t_20) {
      __Pyx_GIVEREF(__pyx_t_20); PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_20); __pyx_t_20 = NULL;
    }
    __Pyx_GIVEREF(__pyx_t_22);
    PyTuple_SET_ITEM(__pyx_t_1, 0+__pyx_t_10, __pyx_t_22);
    __Pyx_GIVEREF(__pyx_t_5);
    PyTuple_SET_ITEM(__pyx_t_1, 1+__pyx_t_10, __pyx_t_5);
    __pyx_t_22 = 0;
    __pyx_t_5 = 0;
    __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_6, __pyx_t_1, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 275, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  }
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  __pyx_t_5 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 275, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_t_22 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_n_s_tile); if (unlikely(!__pyx_t_22)) __PYX_ERR(0, 275, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_22);
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __pyx_t_20 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_20)) __PYX_ERR(0, 275, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_20);
  __pyx_t_19 = __Pyx_PyObject_GetAttrStr(__pyx_t_20, __pyx_n_s_repeat); if (unlikely(!__pyx_t_19)) __PYX_ERR(0, 275, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_19);
  __Pyx_DECREF(__pyx_t_20); __pyx_t_20 = 0;
  __pyx_t_20 = __Pyx_PyInt_From_int(__pyx_v_NX); if (unlikely(!__pyx_t_20)) __PYX_ERR(0, 275, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_20);
  __pyx_t_24 = PyNumber_Multiply(__pyx_t_20, ((PyObject *)__pyx_v_indY)); if (unlikely(!__pyx_t_24)) __PYX_ERR(0, 275, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_24);
  __Pyx_DECREF(__pyx_t_20); __pyx_t_20 = 0;
  __pyx_t_20 = __Pyx_PyInt_From_int(__pyx_v_Xn); if (unlikely(!__pyx_t_20)) __PYX_ERR(0, 275, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_20);
  __pyx_t_4 = NULL;
  __pyx_t_10 = 0;
  if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_19))) {
    __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_19);
    if (likely(__pyx_t_4)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_19);
      __Pyx_INCREF(__pyx_t_4);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_19, function);
      __pyx_t_10 = 1;
    }
  }
  #if CYTHON_FAST_PYCALL
  if (PyFunction_Check(__pyx_t_19)) {
    PyObject *__pyx_temp[3] = {__pyx_t_4, __pyx_t_24, __pyx_t_20};
    __pyx_t_5 = __Pyx_PyFunction_FastCall(__pyx_t_19, __pyx_temp+1-__pyx_t_10, 2+__pyx_t_10); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 275, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_24); __pyx_t_24 = 0;
    __Pyx_DECREF(__pyx_t_20); __pyx_t_20 = 0;
  } else
  #endif
  #if CYTHON_FAST_PYCCALL
  if (__Pyx_PyFastCFunction_Check(__pyx_t_19)) {
    PyObject *__pyx_temp[3] = {__pyx_t_4, __pyx_t_24, __pyx_t_20};
    __pyx_t_5 = __Pyx_PyCFunction_FastCall(__pyx_t_19, __pyx_temp+1-__pyx_t_10, 2+__pyx_t_10); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 275, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_24); __pyx_t_24 = 0;
    __Pyx_DECREF(__pyx_t_20); __pyx_t_20 = 0;
  } else
  #endif
  {
    __pyx_t_21 = PyTuple_New(2+__pyx_t_10); if (unlikely(!__pyx_t_21)) __PYX_ERR(0, 275, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_21);
    if (__pyx_t_4) {
      __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_21, 0, __pyx_t_4); __pyx_t_4 = NULL;
    }
    __Pyx_GIVEREF(__pyx_t_24);
    PyTuple_SET_ITEM(__pyx_t_21, 0+__pyx_t_10, __pyx_t_24);
    __Pyx_GIVEREF(__pyx_t_20);
    PyTuple_SET_ITEM(__pyx_t_21, 1+__pyx_t_10, __pyx_t_20);
    __pyx_t_24 = 0;
    __pyx_t_20 = 0;
    __pyx_t_5 = __Pyx_PyObject_Call(__pyx_t_19, __pyx_t_21, NULL); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 275, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_21); __pyx_t_21 = 0;
  }
  __Pyx_DECREF(__pyx_t_19); __pyx_t_19 = 0;
  __pyx_t_19 = __Pyx_PyInt_From_int(__pyx_v_Zn); if (unlikely(!__pyx_t_19)) __PYX_ERR(0, 275, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_19);
  __pyx_t_21 = PyTuple_New(2); if (unlikely(!__pyx_t_21)) __PYX_ERR(0, 275, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_21);
  __Pyx_GIVEREF(__pyx_t_19);
  PyTuple_SET_ITEM(__pyx_t_21, 0, __pyx_t_19);
  __Pyx_INCREF(__pyx_int_1);
  __Pyx_GIVEREF(__pyx_int_1);
  PyTuple_SET_ITEM(__pyx_t_21, 1, __pyx_int_1);
  __pyx_t_19 = 0;
  __pyx_t_19 = NULL;
  __pyx_t_10 = 0;
  if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_22))) {
    __pyx_t_19 = PyMethod_GET_SELF(__pyx_t_22);
    if (likely(__pyx_t_19)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_22);
      __Pyx_INCREF(__pyx_t_19);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_22, function);
      __pyx_t_10 = 1;
    }
  }
  #if CYTHON_FAST_PYCALL
  if (PyFunction_Check(__pyx_t_22)) {
    PyObject *__pyx_temp[3] = {__pyx_t_19, __pyx_t_5, __pyx_t_21};
    __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_22, __pyx_temp+1-__pyx_t_10, 2+__pyx_t_10); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 275, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_19); __pyx_t_19 = 0;
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_DECREF(__pyx_t_21); __pyx_t_21 = 0;
  } else
  #endif
  #if CYTHON_FAST_PYCCALL
  if (__Pyx_PyFastCFunction_Check(__pyx_t_22)) {
    PyObject *__pyx_temp[3] = {__pyx_t_19, __pyx_t_5, __pyx_t_21};
    __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_22, __pyx_temp+1-__pyx_t_10, 2+__pyx_t_10); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 275, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_19); __pyx_t_19 = 0;
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_DECREF(__pyx_t_21); __pyx_t_21 = 0;
  } else
  #endif
  {
    __pyx_t_20 = PyTuple_New(2+__pyx_t_10); if (unlikely(!__pyx_t_20)) __PYX_ERR(0, 275, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_20);
    if (__pyx_t_19) {
      __Pyx_GIVEREF(__pyx_t_19); PyTuple_SET_ITEM(__pyx_t_20, 0, __pyx_t_19); __pyx_t_19 = NULL;
    }
    __Pyx_GIVEREF(__pyx_t_5);
    PyTuple_SET_ITEM(__pyx_t_20, 0+__pyx_t_10, __pyx_t_5);
    __Pyx_GIVEREF(__pyx_t_21);
    PyTuple_SET_ITEM(__pyx_t_20, 1+__pyx_t_10, __pyx_t_21);
    __pyx_t_5 = 0;
    __pyx_t_21 = 0;
    __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_22, __pyx_t_20, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 275, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_20); __pyx_t_20 = 0;
  }
  __Pyx_DECREF(__pyx_t_22); __pyx_t_22 = 0;
  __pyx_t_22 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_flatten); if (unlikely(!__pyx_t_22)) __PYX_ERR(0, 275, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_22);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = NULL;
  if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_22))) {
    __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_22);
    if (likely(__pyx_t_1)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_22);
      __Pyx_INCREF(__pyx_t_1);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_22, function);
    }
  }
  if (__pyx_t_1) {
    __pyx_t_6 = __Pyx_PyObject_CallOneArg(__pyx_t_22, __pyx_t_1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 275, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  } else {
    __pyx_t_6 = __Pyx_PyObject_CallNoArg(__pyx_t_22); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 275, __pyx_L1_error)
  }
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_DECREF(__pyx_t_22); __pyx_t_22 = 0;
  __pyx_t_22 = PyNumber_Add(__pyx_t_3, __pyx_t_6); if (unlikely(!__pyx_t_22)) __PYX_ERR(0, 275, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_22);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 275, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_20 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_tile); if (unlikely(!__pyx_t_20)) __PYX_ERR(0, 275, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_20);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = __Pyx_PyInt_From_int((__pyx_v_Yn * __pyx_v_Zn)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 275, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_21 = PyTuple_New(2); if (unlikely(!__pyx_t_21)) __PYX_ERR(0, 275, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_21);
  __Pyx_GIVEREF(__pyx_t_1);
  PyTuple_SET_ITEM(__pyx_t_21, 0, __pyx_t_1);
  __Pyx_INCREF(__pyx_int_1);
  __Pyx_GIVEREF(__pyx_int_1);
  PyTuple_SET_ITEM(__pyx_t_21, 1, __pyx_int_1);
  __pyx_t_1 = 0;
  __pyx_t_1 = NULL;
  __pyx_t_10 = 0;
  if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_20))) {
    __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_20);
    if (likely(__pyx_t_1)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_20);
      __Pyx_INCREF(__pyx_t_1);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_20, function);
      __pyx_t_10 = 1;
    }
  }
  #if CYTHON_FAST_PYCALL
  if (PyFunction_Check(__pyx_t_20)) {
    PyObject *__pyx_temp[3] = {__pyx_t_1, ((PyObject *)__pyx_v_indX), __pyx_t_21};
    __pyx_t_3 = __Pyx_PyFunction_FastCall(__pyx_t_20, __pyx_temp+1-__pyx_t_10, 2+__pyx_t_10); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 275, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_21); __pyx_t_21 = 0;
  } else
  #endif
  #if CYTHON_FAST_PYCCALL
  if (__Pyx_PyFastCFunction_Check(__pyx_t_20)) {
    PyObject *__pyx_temp[3] = {__pyx_t_1, ((PyObject *)__pyx_v_indX), __pyx_t_21};
    __pyx_t_3 = __Pyx_PyCFunction_FastCall(__pyx_t_20, __pyx_temp+1-__pyx_t_10, 2+__pyx_t_10); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 275, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_21); __pyx_t_21 = 0;
  } else
  #endif
  {
    __pyx_t_5 = PyTuple_New(2+__pyx_t_10); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 275, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    if (__pyx_t_1) {
      __Pyx_GIVEREF(__pyx_t_1); PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_1); __pyx_t_1 = NULL;
    }
    __Pyx_INCREF(((PyObject *)__pyx_v_indX));
    __Pyx_GIVEREF(((PyObject *)__pyx_v_indX));
    PyTuple_SET_ITEM(__pyx_t_5, 0+__pyx_t_10, ((PyObject *)__pyx_v_indX));
    __Pyx_GIVEREF(__pyx_t_21);
    PyTuple_SET_ITEM(__pyx_t_5, 1+__pyx_t_10, __pyx_t_21);
    __pyx_t_21 = 0;
    __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_20, __pyx_t_5, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 275, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  }
  __Pyx_DECREF(__pyx_t_20); __pyx_t_20 = 0;
  __pyx_t_20 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_flatten); if (unlikely(!__pyx_t_20)) __PYX_ERR(0, 275, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_20);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_3 = NULL;
  if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_20))) {
    __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_20);
    if (likely(__pyx_t_3)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_20);
      __Pyx_INCREF(__pyx_t_3);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_20, function);
    }
  }
  if (__pyx_t_3) {
    __pyx_t_6 = __Pyx_PyObject_CallOneArg(__pyx_t_20, __pyx_t_3); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 275, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  } else {
    __pyx_t_6 = __Pyx_PyObject_CallNoArg(__pyx_t_20); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 275, __pyx_L1_error)
  }
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_DECREF(__pyx_t_20); __pyx_t_20 = 0;
  __pyx_t_20 = PyNumber_Add(__pyx_t_22, __pyx_t_6); if (unlikely(!__pyx_t_20)) __PYX_ERR(0, 275, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_20);
  __Pyx_DECREF(__pyx_t_22); __pyx_t_22 = 0;
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  if (!(likely(((__pyx_t_20) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_20, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 275, __pyx_L1_error)
  __pyx_t_26 = ((PyArrayObject *)__pyx_t_20);
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_ind.rcbuffer->pybuffer);
    __pyx_t_10 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_ind.rcbuffer->pybuffer, (PyObject*)__pyx_t_26, &__Pyx_TypeInfo_long, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack);
    if (unlikely(__pyx_t_10 < 0)) {
      PyErr_Fetch(&__pyx_t_13, &__pyx_t_14, &__pyx_t_15);
      if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_ind.rcbuffer->pybuffer, (PyObject*)__pyx_v_ind, &__Pyx_TypeInfo_long, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {
        Py_XDECREF(__pyx_t_13); Py_XDECREF(__pyx_t_14); Py_XDECREF(__pyx_t_15);
        __Pyx_RaiseBufferFallbackError();
      } else {
        PyErr_Restore(__pyx_t_13, __pyx_t_14, __pyx_t_15);
      }
    }
    __pyx_pybuffernd_ind.diminfo[0].strides = __pyx_pybuffernd_ind.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_ind.diminfo[0].shape = __pyx_pybuffernd_ind.rcbuffer->pybuffer.shape[0];
    if (unlikely(__pyx_t_10 < 0)) __PYX_ERR(0, 275, __pyx_L1_error)
  }
  __pyx_t_26 = 0;
  __pyx_v_ind = ((PyArrayObject *)__pyx_t_20);
  __pyx_t_20 = 0;
+276:     dV = dXr*dYr*dZr
  __pyx_v_dV = ((__pyx_v_dXr * __pyx_v_dYr) * __pyx_v_dZr);
 277: 
 278:     #if VPoly is not None:
 279:     #    indin = _Ves_isInside(Pts[:-1,:], VPoly=VPoly, VType='Lin', In='(X,Y)')
 280:     #    Pts, dV, ind = Pts[:,indin], dV[indin], ind[indin]
 281: 
+282:     return Pts, dV, ind.astype(int), dXr, dYr, dZr
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_20 = PyFloat_FromDouble(__pyx_v_dV); if (unlikely(!__pyx_t_20)) __PYX_ERR(0, 282, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_20);
  __pyx_t_22 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_ind), __pyx_n_s_astype); if (unlikely(!__pyx_t_22)) __PYX_ERR(0, 282, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_22);
  __pyx_t_3 = NULL;
  if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_22))) {
    __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_22);
    if (likely(__pyx_t_3)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_22);
      __Pyx_INCREF(__pyx_t_3);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_22, function);
    }
  }
  if (!__pyx_t_3) {
    __pyx_t_6 = __Pyx_PyObject_CallOneArg(__pyx_t_22, ((PyObject *)(&PyInt_Type))); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 282, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
  } else {
    #if CYTHON_FAST_PYCALL
    if (PyFunction_Check(__pyx_t_22)) {
      PyObject *__pyx_temp[2] = {__pyx_t_3, ((PyObject *)(&PyInt_Type))};
      __pyx_t_6 = __Pyx_PyFunction_FastCall(__pyx_t_22, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 282, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
      __Pyx_GOTREF(__pyx_t_6);
    } else
    #endif
    #if CYTHON_FAST_PYCCALL
    if (__Pyx_PyFastCFunction_Check(__pyx_t_22)) {
      PyObject *__pyx_temp[2] = {__pyx_t_3, ((PyObject *)(&PyInt_Type))};
      __pyx_t_6 = __Pyx_PyCFunction_FastCall(__pyx_t_22, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 282, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
      __Pyx_GOTREF(__pyx_t_6);
    } else
    #endif
    {
      __pyx_t_5 = PyTuple_New(1+1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 282, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_3); __pyx_t_3 = NULL;
      __Pyx_INCREF(((PyObject *)(&PyInt_Type)));
      __Pyx_GIVEREF(((PyObject *)(&PyInt_Type)));
      PyTuple_SET_ITEM(__pyx_t_5, 0+1, ((PyObject *)(&PyInt_Type)));
      __pyx_t_6 = __Pyx_PyObject_Call(__pyx_t_22, __pyx_t_5, NULL); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 282, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_6);
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    }
  }
  __Pyx_DECREF(__pyx_t_22); __pyx_t_22 = 0;
  __pyx_t_22 = PyFloat_FromDouble(__pyx_v_dXr); if (unlikely(!__pyx_t_22)) __PYX_ERR(0, 282, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_22);
  __pyx_t_5 = PyFloat_FromDouble(__pyx_v_dYr); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 282, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_t_3 = PyFloat_FromDouble(__pyx_v_dZr); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 282, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_21 = PyTuple_New(6); if (unlikely(!__pyx_t_21)) __PYX_ERR(0, 282, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_21);
  __Pyx_INCREF(((PyObject *)__pyx_v_Pts));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_Pts));
  PyTuple_SET_ITEM(__pyx_t_21, 0, ((PyObject *)__pyx_v_Pts));
  __Pyx_GIVEREF(__pyx_t_20);
  PyTuple_SET_ITEM(__pyx_t_21, 1, __pyx_t_20);
  __Pyx_GIVEREF(__pyx_t_6);
  PyTuple_SET_ITEM(__pyx_t_21, 2, __pyx_t_6);
  __Pyx_GIVEREF(__pyx_t_22);
  PyTuple_SET_ITEM(__pyx_t_21, 3, __pyx_t_22);
  __Pyx_GIVEREF(__pyx_t_5);
  PyTuple_SET_ITEM(__pyx_t_21, 4, __pyx_t_5);
  __Pyx_GIVEREF(__pyx_t_3);
  PyTuple_SET_ITEM(__pyx_t_21, 5, __pyx_t_3);
  __pyx_t_20 = 0;
  __pyx_t_6 = 0;
  __pyx_t_22 = 0;
  __pyx_t_5 = 0;
  __pyx_t_3 = 0;
  __pyx_r = __pyx_t_21;
  __pyx_t_21 = 0;
  goto __pyx_L0;
 283: 
 284: 
+285: def _Ves_Vmesh_Lin_SubFromInd_cython(double dX, double dY, double dZ,
/* Python wrapper */
static PyObject *__pyx_pw_46_cython_magic_ffb7650808bb7830760fff8d6d047f13_9_Ves_Vmesh_Lin_SubFromInd_cython(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_46_cython_magic_ffb7650808bb7830760fff8d6d047f13_8_Ves_Vmesh_Lin_SubFromInd_cython[] = " Return the desired submesh indicated by the limits (DX,DY,DZ), for the desired resolution (dX,dY,dZ) ";
static PyMethodDef __pyx_mdef_46_cython_magic_ffb7650808bb7830760fff8d6d047f13_9_Ves_Vmesh_Lin_SubFromInd_cython = {"_Ves_Vmesh_Lin_SubFromInd_cython", (PyCFunction)__pyx_pw_46_cython_magic_ffb7650808bb7830760fff8d6d047f13_9_Ves_Vmesh_Lin_SubFromInd_cython, METH_VARARGS|METH_KEYWORDS, __pyx_doc_46_cython_magic_ffb7650808bb7830760fff8d6d047f13_8_Ves_Vmesh_Lin_SubFromInd_cython};
static PyObject *__pyx_pw_46_cython_magic_ffb7650808bb7830760fff8d6d047f13_9_Ves_Vmesh_Lin_SubFromInd_cython(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  double __pyx_v_dX;
  double __pyx_v_dY;
  double __pyx_v_dZ;
  __Pyx_memviewslice __pyx_v_XMinMax = { 0, 0, { 0 }, { 0 }, { 0 } };
  __Pyx_memviewslice __pyx_v_YMinMax = { 0, 0, { 0 }, { 0 }, { 0 } };
  __Pyx_memviewslice __pyx_v_ZMinMax = { 0, 0, { 0 }, { 0 }, { 0 } };
  PyArrayObject *__pyx_v_ind = 0;
  double __pyx_v_margin;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("_Ves_Vmesh_Lin_SubFromInd_cython (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_dX,&__pyx_n_s_dY,&__pyx_n_s_dZ,&__pyx_n_s_XMinMax,&__pyx_n_s_YMinMax,&__pyx_n_s_ZMinMax,&__pyx_n_s_ind,&__pyx_n_s_margin,0};
    PyObject* values[8] = {0,0,0,0,0,0,0,0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  8: values[7] = PyTuple_GET_ITEM(__pyx_args, 7);
        case  7: values[6] = PyTuple_GET_ITEM(__pyx_args, 6);
        case  6: values[5] = PyTuple_GET_ITEM(__pyx_args, 5);
        case  5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_dX)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        case  1:
        if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_dY)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_Ves_Vmesh_Lin_SubFromInd_cython", 0, 7, 8, 1); __PYX_ERR(0, 285, __pyx_L3_error)
        }
        case  2:
        if (likely((values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_dZ)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_Ves_Vmesh_Lin_SubFromInd_cython", 0, 7, 8, 2); __PYX_ERR(0, 285, __pyx_L3_error)
        }
        case  3:
        if (likely((values[3] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_XMinMax)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_Ves_Vmesh_Lin_SubFromInd_cython", 0, 7, 8, 3); __PYX_ERR(0, 285, __pyx_L3_error)
        }
        case  4:
        if (likely((values[4] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_YMinMax)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_Ves_Vmesh_Lin_SubFromInd_cython", 0, 7, 8, 4); __PYX_ERR(0, 285, __pyx_L3_error)
        }
        case  5:
        if (likely((values[5] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_ZMinMax)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_Ves_Vmesh_Lin_SubFromInd_cython", 0, 7, 8, 5); __PYX_ERR(0, 285, __pyx_L3_error)
        }
        case  6:
        if (likely((values[6] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_ind)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_Ves_Vmesh_Lin_SubFromInd_cython", 0, 7, 8, 6); __PYX_ERR(0, 285, __pyx_L3_error)
        }
        case  7:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_margin);
          if (value) { values[7] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "_Ves_Vmesh_Lin_SubFromInd_cython") < 0)) __PYX_ERR(0, 285, __pyx_L3_error)
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  8: values[7] = PyTuple_GET_ITEM(__pyx_args, 7);
        case  7: values[6] = PyTuple_GET_ITEM(__pyx_args, 6);
        values[5] = PyTuple_GET_ITEM(__pyx_args, 5);
        values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
        values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    __pyx_v_dX = __pyx_PyFloat_AsDouble(values[0]); if (unlikely((__pyx_v_dX == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 285, __pyx_L3_error)
    __pyx_v_dY = __pyx_PyFloat_AsDouble(values[1]); if (unlikely((__pyx_v_dY == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 285, __pyx_L3_error)
    __pyx_v_dZ = __pyx_PyFloat_AsDouble(values[2]); if (unlikely((__pyx_v_dZ == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 285, __pyx_L3_error)
    __pyx_v_XMinMax = __Pyx_PyObject_to_MemoryviewSlice_dc_double(values[3]); if (unlikely(!__pyx_v_XMinMax.memview)) __PYX_ERR(0, 286, __pyx_L3_error)
    __pyx_v_YMinMax = __Pyx_PyObject_to_MemoryviewSlice_dc_double(values[4]); if (unlikely(!__pyx_v_YMinMax.memview)) __PYX_ERR(0, 286, __pyx_L3_error)
    __pyx_v_ZMinMax = __Pyx_PyObject_to_MemoryviewSlice_dc_double(values[5]); if (unlikely(!__pyx_v_ZMinMax.memview)) __PYX_ERR(0, 286, __pyx_L3_error)
    __pyx_v_ind = ((PyArrayObject *)values[6]);
    if (values[7]) {
      __pyx_v_margin = __pyx_PyFloat_AsDouble(values[7]); if (unlikely((__pyx_v_margin == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 287, __pyx_L3_error)
    } else {
      __pyx_v_margin = ((double)1.e-9);
    }
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("_Ves_Vmesh_Lin_SubFromInd_cython", 0, 7, 8, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 285, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("_cython_magic_ffb7650808bb7830760fff8d6d047f13._Ves_Vmesh_Lin_SubFromInd_cython", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_ind), __pyx_ptype_5numpy_ndarray, 1, "ind", 0))) __PYX_ERR(0, 287, __pyx_L1_error)
  __pyx_r = __pyx_pf_46_cython_magic_ffb7650808bb7830760fff8d6d047f13_8_Ves_Vmesh_Lin_SubFromInd_cython(__pyx_self, __pyx_v_dX, __pyx_v_dY, __pyx_v_dZ, __pyx_v_XMinMax, __pyx_v_YMinMax, __pyx_v_ZMinMax, __pyx_v_ind, __pyx_v_margin);

  /* function exit code */
  goto __pyx_L0;
  __pyx_L1_error:;
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_46_cython_magic_ffb7650808bb7830760fff8d6d047f13_8_Ves_Vmesh_Lin_SubFromInd_cython(CYTHON_UNUSED PyObject *__pyx_self, double __pyx_v_dX, double __pyx_v_dY, double __pyx_v_dZ, __Pyx_memviewslice __pyx_v_XMinMax, __Pyx_memviewslice __pyx_v_YMinMax, __Pyx_memviewslice __pyx_v_ZMinMax, PyArrayObject *__pyx_v_ind, double __pyx_v_margin) {
  PyArrayObject *__pyx_v_X = 0;
  PyArrayObject *__pyx_v_Y = 0;
  PyArrayObject *__pyx_v_Z = 0;
  double __pyx_v_dXr;
  double __pyx_v_dYr;
  double __pyx_v_dZr;
  double __pyx_v_dV;
  CYTHON_UNUSED __Pyx_memviewslice __pyx_v_bla = { 0, 0, { 0 }, { 0 }, { 0 } };
  PyArrayObject *__pyx_v_indX = 0;
  PyArrayObject *__pyx_v_indY = 0;
  PyArrayObject *__pyx_v_indZ = 0;
  int __pyx_v_NX;
  int __pyx_v_NY;
  CYTHON_UNUSED int __pyx_v_NZ;
  PyArrayObject *__pyx_v_Pts = 0;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_Pts;
  __Pyx_Buffer __pyx_pybuffer_Pts;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_X;
  __Pyx_Buffer __pyx_pybuffer_X;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_Y;
  __Pyx_Buffer __pyx_pybuffer_Y;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_Z;
  __Pyx_Buffer __pyx_pybuffer_Z;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_ind;
  __Pyx_Buffer __pyx_pybuffer_ind;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_indX;
  __Pyx_Buffer __pyx_pybuffer_indX;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_indY;
  __Pyx_Buffer __pyx_pybuffer_indY;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_indZ;
  __Pyx_Buffer __pyx_pybuffer_indZ;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("_Ves_Vmesh_Lin_SubFromInd_cython", 0);
  __pyx_pybuffer_X.pybuffer.buf = NULL;
  __pyx_pybuffer_X.refcount = 0;
  __pyx_pybuffernd_X.data = NULL;
  __pyx_pybuffernd_X.rcbuffer = &__pyx_pybuffer_X;
  __pyx_pybuffer_Y.pybuffer.buf = NULL;
  __pyx_pybuffer_Y.refcount = 0;
  __pyx_pybuffernd_Y.data = NULL;
  __pyx_pybuffernd_Y.rcbuffer = &__pyx_pybuffer_Y;
  __pyx_pybuffer_Z.pybuffer.buf = NULL;
  __pyx_pybuffer_Z.refcount = 0;
  __pyx_pybuffernd_Z.data = NULL;
  __pyx_pybuffernd_Z.rcbuffer = &__pyx_pybuffer_Z;
  __pyx_pybuffer_indX.pybuffer.buf = NULL;
  __pyx_pybuffer_indX.refcount = 0;
  __pyx_pybuffernd_indX.data = NULL;
  __pyx_pybuffernd_indX.rcbuffer = &__pyx_pybuffer_indX;
  __pyx_pybuffer_indY.pybuffer.buf = NULL;
  __pyx_pybuffer_indY.refcount = 0;
  __pyx_pybuffernd_indY.data = NULL;
  __pyx_pybuffernd_indY.rcbuffer = &__pyx_pybuffer_indY;
  __pyx_pybuffer_indZ.pybuffer.buf = NULL;
  __pyx_pybuffer_indZ.refcount = 0;
  __pyx_pybuffernd_indZ.data = NULL;
  __pyx_pybuffernd_indZ.rcbuffer = &__pyx_pybuffer_indZ;
  __pyx_pybuffer_Pts.pybuffer.buf = NULL;
  __pyx_pybuffer_Pts.refcount = 0;
  __pyx_pybuffernd_Pts.data = NULL;
  __pyx_pybuffernd_Pts.rcbuffer = &__pyx_pybuffer_Pts;
  __pyx_pybuffer_ind.pybuffer.buf = NULL;
  __pyx_pybuffer_ind.refcount = 0;
  __pyx_pybuffernd_ind.data = NULL;
  __pyx_pybuffernd_ind.rcbuffer = &__pyx_pybuffer_ind;
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_ind.rcbuffer->pybuffer, (PyObject*)__pyx_v_ind, &__Pyx_TypeInfo_long, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) __PYX_ERR(0, 285, __pyx_L1_error)
  }
  __pyx_pybuffernd_ind.diminfo[0].strides = __pyx_pybuffernd_ind.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_ind.diminfo[0].shape = __pyx_pybuffernd_ind.rcbuffer->pybuffer.shape[0];
/* … */
  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __PYX_XDEC_MEMVIEW(&__pyx_t_9, 1);
  __Pyx_XDECREF(__pyx_t_17);
  __Pyx_XDECREF(__pyx_t_18);
  { PyObject *__pyx_type, *__pyx_value, *__pyx_tb;
    __Pyx_PyThreadState_declare
    __Pyx_PyThreadState_assign
    __Pyx_ErrFetch(&__pyx_type, &__pyx_value, &__pyx_tb);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_Pts.rcbuffer->pybuffer);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_X.rcbuffer->pybuffer);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_Y.rcbuffer->pybuffer);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_Z.rcbuffer->pybuffer);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_ind.rcbuffer->pybuffer);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_indX.rcbuffer->pybuffer);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_indY.rcbuffer->pybuffer);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_indZ.rcbuffer->pybuffer);
  __Pyx_ErrRestore(__pyx_type, __pyx_value, __pyx_tb);}
  __Pyx_AddTraceback("_cython_magic_ffb7650808bb7830760fff8d6d047f13._Ves_Vmesh_Lin_SubFromInd_cython", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  goto __pyx_L2;
  __pyx_L0:;
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_Pts.rcbuffer->pybuffer);
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_X.rcbuffer->pybuffer);
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_Y.rcbuffer->pybuffer);
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_Z.rcbuffer->pybuffer);
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_ind.rcbuffer->pybuffer);
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_indX.rcbuffer->pybuffer);
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_indY.rcbuffer->pybuffer);
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_indZ.rcbuffer->pybuffer);
  __pyx_L2:;
  __Pyx_XDECREF((PyObject *)__pyx_v_X);
  __Pyx_XDECREF((PyObject *)__pyx_v_Y);
  __Pyx_XDECREF((PyObject *)__pyx_v_Z);
  __PYX_XDEC_MEMVIEW(&__pyx_v_bla, 1);
  __Pyx_XDECREF((PyObject *)__pyx_v_indX);
  __Pyx_XDECREF((PyObject *)__pyx_v_indY);
  __Pyx_XDECREF((PyObject *)__pyx_v_indZ);
  __Pyx_XDECREF((PyObject *)__pyx_v_Pts);
  __PYX_XDEC_MEMVIEW(&__pyx_v_XMinMax, 1);
  __PYX_XDEC_MEMVIEW(&__pyx_v_YMinMax, 1);
  __PYX_XDEC_MEMVIEW(&__pyx_v_ZMinMax, 1);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}
/* … */
  __pyx_tuple__31 = PyTuple_Pack(26, __pyx_n_s_dX, __pyx_n_s_dY, __pyx_n_s_dZ, __pyx_n_s_XMinMax, __pyx_n_s_YMinMax, __pyx_n_s_ZMinMax, __pyx_n_s_ind, __pyx_n_s_margin, __pyx_n_s_X, __pyx_n_s_Y, __pyx_n_s_Z, __pyx_n_s_dXr, __pyx_n_s_dYr, __pyx_n_s_dZr, __pyx_n_s_dV, __pyx_n_s_bla, __pyx_n_s_indX, __pyx_n_s_indY, __pyx_n_s_indZ, __pyx_n_s_NX, __pyx_n_s_NY, __pyx_n_s_NZ, __pyx_n_s_Xn, __pyx_n_s_Yn, __pyx_n_s_Zn, __pyx_n_s_Pts); if (unlikely(!__pyx_tuple__31)) __PYX_ERR(0, 285, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__31);
  __Pyx_GIVEREF(__pyx_tuple__31);
/* … */
  __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_46_cython_magic_ffb7650808bb7830760fff8d6d047f13_9_Ves_Vmesh_Lin_SubFromInd_cython, NULL, __pyx_n_s_cython_magic_ffb7650808bb783076); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 285, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_Ves_Vmesh_Lin_SubFromInd_cython, __pyx_t_1) < 0) __PYX_ERR(0, 285, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_codeobj__32 = (PyObject*)__Pyx_PyCode_New(8, 0, 26, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__31, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_Home_DV226270_cache_ipython_cyt, __pyx_n_s_Ves_Vmesh_Lin_SubFromInd_cython, 285, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__32)) __PYX_ERR(0, 285, __pyx_L1_error)
 286:                                      double[::1] XMinMax, double[::1] YMinMax, double[::1] ZMinMax,
 287:                                      cnp.ndarray[long,ndim=1] ind, double margin=1.e-9):
 288:     " Return the desired submesh indicated by the limits (DX,DY,DZ), for the desired resolution (dX,dY,dZ) "
 289: 
 290:     cdef cnp.ndarray[double,ndim=1] X, Y, Z
 291:     cdef double dXr, dYr, dZr, dV
 292:     cdef long[::1] bla
 293:     cdef cnp.ndarray[long,ndim=1] indX, indY, indZ
 294:     cdef int NX, NY, NZ, Xn, Yn, Zn
 295:     cdef cnp.ndarray[double,ndim=2] Pts
 296: 
 297:     # Get the actual X, Y and Z resolutions and mesh elements
+298:     X, dXr, bla, NX = _Ves_mesh_dlfromL_cython(XMinMax, dX, None, margin=margin)
  __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_Ves_mesh_dlfromL_cython); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 298, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __pyx_memoryview_fromslice(__pyx_v_XMinMax, 1, (PyObject *(*)(char *)) __pyx_memview_get_double, (int (*)(char *, PyObject *)) __pyx_memview_set_double, 0);; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 298, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = PyFloat_FromDouble(__pyx_v_dX); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 298, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = PyTuple_New(3); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 298, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_GIVEREF(__pyx_t_2);
  PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_2);
  __Pyx_GIVEREF(__pyx_t_3);
  PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_t_3);
  __Pyx_INCREF(Py_None);
  __Pyx_GIVEREF(Py_None);
  PyTuple_SET_ITEM(__pyx_t_4, 2, Py_None);
  __pyx_t_2 = 0;
  __pyx_t_3 = 0;
  __pyx_t_3 = PyDict_New(); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 298, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_2 = PyFloat_FromDouble(__pyx_v_margin); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 298, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_margin, __pyx_t_2) < 0) __PYX_ERR(0, 298, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_4, __pyx_t_3); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 298, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  if ((likely(PyTuple_CheckExact(__pyx_t_2))) || (PyList_CheckExact(__pyx_t_2))) {
    PyObject* sequence = __pyx_t_2;
    #if !CYTHON_COMPILING_IN_PYPY
    Py_ssize_t size = Py_SIZE(sequence);
    #else
    Py_ssize_t size = PySequence_Size(sequence);
    #endif
    if (unlikely(size != 4)) {
      if (size > 4) __Pyx_RaiseTooManyValuesError(4);
      else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
      __PYX_ERR(0, 298, __pyx_L1_error)
    }
    #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
    if (likely(PyTuple_CheckExact(sequence))) {
      __pyx_t_3 = PyTuple_GET_ITEM(sequence, 0); 
      __pyx_t_4 = PyTuple_GET_ITEM(sequence, 1); 
      __pyx_t_1 = PyTuple_GET_ITEM(sequence, 2); 
      __pyx_t_5 = PyTuple_GET_ITEM(sequence, 3); 
    } else {
      __pyx_t_3 = PyList_GET_ITEM(sequence, 0); 
      __pyx_t_4 = PyList_GET_ITEM(sequence, 1); 
      __pyx_t_1 = PyList_GET_ITEM(sequence, 2); 
      __pyx_t_5 = PyList_GET_ITEM(sequence, 3); 
    }
    __Pyx_INCREF(__pyx_t_3);
    __Pyx_INCREF(__pyx_t_4);
    __Pyx_INCREF(__pyx_t_1);
    __Pyx_INCREF(__pyx_t_5);
    #else
    {
      Py_ssize_t i;
      PyObject** temps[4] = {&__pyx_t_3,&__pyx_t_4,&__pyx_t_1,&__pyx_t_5};
      for (i=0; i < 4; i++) {
        PyObject* item = PySequence_ITEM(sequence, i); if (unlikely(!item)) __PYX_ERR(0, 298, __pyx_L1_error)
        __Pyx_GOTREF(item);
        *(temps[i]) = item;
      }
    }
    #endif
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  } else {
    Py_ssize_t index = -1;
    PyObject** temps[4] = {&__pyx_t_3,&__pyx_t_4,&__pyx_t_1,&__pyx_t_5};
    __pyx_t_6 = PyObject_GetIter(__pyx_t_2); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 298, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_t_7 = Py_TYPE(__pyx_t_6)->tp_iternext;
    for (index=0; index < 4; index++) {
      PyObject* item = __pyx_t_7(__pyx_t_6); if (unlikely(!item)) goto __pyx_L3_unpacking_failed;
      __Pyx_GOTREF(item);
      *(temps[index]) = item;
    }
    if (__Pyx_IternextUnpackEndCheck(__pyx_t_7(__pyx_t_6), 4) < 0) __PYX_ERR(0, 298, __pyx_L1_error)
    __pyx_t_7 = NULL;
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    goto __pyx_L4_unpacking_done;
    __pyx_L3_unpacking_failed:;
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __pyx_t_7 = NULL;
    if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
    __PYX_ERR(0, 298, __pyx_L1_error)
    __pyx_L4_unpacking_done:;
  }
  if (!(likely(((__pyx_t_3) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_3, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 298, __pyx_L1_error)
  __pyx_t_8 = __pyx_PyFloat_AsDouble(__pyx_t_4); if (unlikely((__pyx_t_8 == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 298, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_9 = __Pyx_PyObject_to_MemoryviewSlice_dc_long(__pyx_t_1);
  if (unlikely(!__pyx_t_9.memview)) __PYX_ERR(0, 298, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_10 = __Pyx_PyInt_As_int(__pyx_t_5); if (unlikely((__pyx_t_10 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 298, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __pyx_t_11 = ((PyArrayObject *)__pyx_t_3);
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_X.rcbuffer->pybuffer);
    __pyx_t_12 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_X.rcbuffer->pybuffer, (PyObject*)__pyx_t_11, &__Pyx_TypeInfo_double, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack);
    if (unlikely(__pyx_t_12 < 0)) {
      PyErr_Fetch(&__pyx_t_13, &__pyx_t_14, &__pyx_t_15);
      if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_X.rcbuffer->pybuffer, (PyObject*)__pyx_v_X, &__Pyx_TypeInfo_double, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {
        Py_XDECREF(__pyx_t_13); Py_XDECREF(__pyx_t_14); Py_XDECREF(__pyx_t_15);
        __Pyx_RaiseBufferFallbackError();
      } else {
        PyErr_Restore(__pyx_t_13, __pyx_t_14, __pyx_t_15);
      }
    }
    __pyx_pybuffernd_X.diminfo[0].strides = __pyx_pybuffernd_X.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_X.diminfo[0].shape = __pyx_pybuffernd_X.rcbuffer->pybuffer.shape[0];
    if (unlikely(__pyx_t_12 < 0)) __PYX_ERR(0, 298, __pyx_L1_error)
  }
  __pyx_t_11 = 0;
  __pyx_v_X = ((PyArrayObject *)__pyx_t_3);
  __pyx_t_3 = 0;
  __pyx_v_dXr = __pyx_t_8;
  __pyx_v_bla = __pyx_t_9;
  __pyx_t_9.memview = NULL;
  __pyx_t_9.data = NULL;
  __pyx_v_NX = __pyx_t_10;
+299:     Y, dYr, bla, NY = _Ves_mesh_dlfromL_cython(YMinMax, dY, None, margin=margin)
  __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_Ves_mesh_dlfromL_cython); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 299, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_5 = __pyx_memoryview_fromslice(__pyx_v_YMinMax, 1, (PyObject *(*)(char *)) __pyx_memview_get_double, (int (*)(char *, PyObject *)) __pyx_memview_set_double, 0);; if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 299, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_t_1 = PyFloat_FromDouble(__pyx_v_dY); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 299, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_4 = PyTuple_New(3); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 299, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_GIVEREF(__pyx_t_5);
  PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_5);
  __Pyx_GIVEREF(__pyx_t_1);
  PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_t_1);
  __Pyx_INCREF(Py_None);
  __Pyx_GIVEREF(Py_None);
  PyTuple_SET_ITEM(__pyx_t_4, 2, Py_None);
  __pyx_t_5 = 0;
  __pyx_t_1 = 0;
  __pyx_t_1 = PyDict_New(); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 299, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_5 = PyFloat_FromDouble(__pyx_v_margin); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 299, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_margin, __pyx_t_5) < 0) __PYX_ERR(0, 299, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __pyx_t_5 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_4, __pyx_t_1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 299, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if ((likely(PyTuple_CheckExact(__pyx_t_5))) || (PyList_CheckExact(__pyx_t_5))) {
    PyObject* sequence = __pyx_t_5;
    #if !CYTHON_COMPILING_IN_PYPY
    Py_ssize_t size = Py_SIZE(sequence);
    #else
    Py_ssize_t size = PySequence_Size(sequence);
    #endif
    if (unlikely(size != 4)) {
      if (size > 4) __Pyx_RaiseTooManyValuesError(4);
      else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
      __PYX_ERR(0, 299, __pyx_L1_error)
    }
    #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
    if (likely(PyTuple_CheckExact(sequence))) {
      __pyx_t_1 = PyTuple_GET_ITEM(sequence, 0); 
      __pyx_t_4 = PyTuple_GET_ITEM(sequence, 1); 
      __pyx_t_2 = PyTuple_GET_ITEM(sequence, 2); 
      __pyx_t_3 = PyTuple_GET_ITEM(sequence, 3); 
    } else {
      __pyx_t_1 = PyList_GET_ITEM(sequence, 0); 
      __pyx_t_4 = PyList_GET_ITEM(sequence, 1); 
      __pyx_t_2 = PyList_GET_ITEM(sequence, 2); 
      __pyx_t_3 = PyList_GET_ITEM(sequence, 3); 
    }
    __Pyx_INCREF(__pyx_t_1);
    __Pyx_INCREF(__pyx_t_4);
    __Pyx_INCREF(__pyx_t_2);
    __Pyx_INCREF(__pyx_t_3);
    #else
    {
      Py_ssize_t i;
      PyObject** temps[4] = {&__pyx_t_1,&__pyx_t_4,&__pyx_t_2,&__pyx_t_3};
      for (i=0; i < 4; i++) {
        PyObject* item = PySequence_ITEM(sequence, i); if (unlikely(!item)) __PYX_ERR(0, 299, __pyx_L1_error)
        __Pyx_GOTREF(item);
        *(temps[i]) = item;
      }
    }
    #endif
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  } else {
    Py_ssize_t index = -1;
    PyObject** temps[4] = {&__pyx_t_1,&__pyx_t_4,&__pyx_t_2,&__pyx_t_3};
    __pyx_t_6 = PyObject_GetIter(__pyx_t_5); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 299, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __pyx_t_7 = Py_TYPE(__pyx_t_6)->tp_iternext;
    for (index=0; index < 4; index++) {
      PyObject* item = __pyx_t_7(__pyx_t_6); if (unlikely(!item)) goto __pyx_L5_unpacking_failed;
      __Pyx_GOTREF(item);
      *(temps[index]) = item;
    }
    if (__Pyx_IternextUnpackEndCheck(__pyx_t_7(__pyx_t_6), 4) < 0) __PYX_ERR(0, 299, __pyx_L1_error)
    __pyx_t_7 = NULL;
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    goto __pyx_L6_unpacking_done;
    __pyx_L5_unpacking_failed:;
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __pyx_t_7 = NULL;
    if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
    __PYX_ERR(0, 299, __pyx_L1_error)
    __pyx_L6_unpacking_done:;
  }
  if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 299, __pyx_L1_error)
  __pyx_t_8 = __pyx_PyFloat_AsDouble(__pyx_t_4); if (unlikely((__pyx_t_8 == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 299, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_9 = __Pyx_PyObject_to_MemoryviewSlice_dc_long(__pyx_t_2);
  if (unlikely(!__pyx_t_9.memview)) __PYX_ERR(0, 299, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_10 = __Pyx_PyInt_As_int(__pyx_t_3); if (unlikely((__pyx_t_10 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 299, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_11 = ((PyArrayObject *)__pyx_t_1);
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_Y.rcbuffer->pybuffer);
    __pyx_t_12 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_Y.rcbuffer->pybuffer, (PyObject*)__pyx_t_11, &__Pyx_TypeInfo_double, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack);
    if (unlikely(__pyx_t_12 < 0)) {
      PyErr_Fetch(&__pyx_t_15, &__pyx_t_14, &__pyx_t_13);
      if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_Y.rcbuffer->pybuffer, (PyObject*)__pyx_v_Y, &__Pyx_TypeInfo_double, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {
        Py_XDECREF(__pyx_t_15); Py_XDECREF(__pyx_t_14); Py_XDECREF(__pyx_t_13);
        __Pyx_RaiseBufferFallbackError();
      } else {
        PyErr_Restore(__pyx_t_15, __pyx_t_14, __pyx_t_13);
      }
    }
    __pyx_pybuffernd_Y.diminfo[0].strides = __pyx_pybuffernd_Y.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_Y.diminfo[0].shape = __pyx_pybuffernd_Y.rcbuffer->pybuffer.shape[0];
    if (unlikely(__pyx_t_12 < 0)) __PYX_ERR(0, 299, __pyx_L1_error)
  }
  __pyx_t_11 = 0;
  __pyx_v_Y = ((PyArrayObject *)__pyx_t_1);
  __pyx_t_1 = 0;
  __pyx_v_dYr = __pyx_t_8;
  __PYX_XDEC_MEMVIEW(&__pyx_v_bla, 1);
  __pyx_v_bla = __pyx_t_9;
  __pyx_t_9.memview = NULL;
  __pyx_t_9.data = NULL;
  __pyx_v_NY = __pyx_t_10;
+300:     Z, dZr, bla, NZ = _Ves_mesh_dlfromL_cython(ZMinMax, dZ, None, margin=margin)
  __pyx_t_5 = __Pyx_GetModuleGlobalName(__pyx_n_s_Ves_mesh_dlfromL_cython); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 300, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_t_3 = __pyx_memoryview_fromslice(__pyx_v_ZMinMax, 1, (PyObject *(*)(char *)) __pyx_memview_get_double, (int (*)(char *, PyObject *)) __pyx_memview_set_double, 0);; if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 300, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_2 = PyFloat_FromDouble(__pyx_v_dZ); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 300, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_4 = PyTuple_New(3); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 300, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_GIVEREF(__pyx_t_3);
  PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_3);
  __Pyx_GIVEREF(__pyx_t_2);
  PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_t_2);
  __Pyx_INCREF(Py_None);
  __Pyx_GIVEREF(Py_None);
  PyTuple_SET_ITEM(__pyx_t_4, 2, Py_None);
  __pyx_t_3 = 0;
  __pyx_t_2 = 0;
  __pyx_t_2 = PyDict_New(); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 300, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = PyFloat_FromDouble(__pyx_v_margin); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 300, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_margin, __pyx_t_3) < 0) __PYX_ERR(0, 300, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_t_4, __pyx_t_2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 300, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  if ((likely(PyTuple_CheckExact(__pyx_t_3))) || (PyList_CheckExact(__pyx_t_3))) {
    PyObject* sequence = __pyx_t_3;
    #if !CYTHON_COMPILING_IN_PYPY
    Py_ssize_t size = Py_SIZE(sequence);
    #else
    Py_ssize_t size = PySequence_Size(sequence);
    #endif
    if (unlikely(size != 4)) {
      if (size > 4) __Pyx_RaiseTooManyValuesError(4);
      else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
      __PYX_ERR(0, 300, __pyx_L1_error)
    }
    #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
    if (likely(PyTuple_CheckExact(sequence))) {
      __pyx_t_2 = PyTuple_GET_ITEM(sequence, 0); 
      __pyx_t_4 = PyTuple_GET_ITEM(sequence, 1); 
      __pyx_t_5 = PyTuple_GET_ITEM(sequence, 2); 
      __pyx_t_1 = PyTuple_GET_ITEM(sequence, 3); 
    } else {
      __pyx_t_2 = PyList_GET_ITEM(sequence, 0); 
      __pyx_t_4 = PyList_GET_ITEM(sequence, 1); 
      __pyx_t_5 = PyList_GET_ITEM(sequence, 2); 
      __pyx_t_1 = PyList_GET_ITEM(sequence, 3); 
    }
    __Pyx_INCREF(__pyx_t_2);
    __Pyx_INCREF(__pyx_t_4);
    __Pyx_INCREF(__pyx_t_5);
    __Pyx_INCREF(__pyx_t_1);
    #else
    {
      Py_ssize_t i;
      PyObject** temps[4] = {&__pyx_t_2,&__pyx_t_4,&__pyx_t_5,&__pyx_t_1};
      for (i=0; i < 4; i++) {
        PyObject* item = PySequence_ITEM(sequence, i); if (unlikely(!item)) __PYX_ERR(0, 300, __pyx_L1_error)
        __Pyx_GOTREF(item);
        *(temps[i]) = item;
      }
    }
    #endif
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  } else {
    Py_ssize_t index = -1;
    PyObject** temps[4] = {&__pyx_t_2,&__pyx_t_4,&__pyx_t_5,&__pyx_t_1};
    __pyx_t_6 = PyObject_GetIter(__pyx_t_3); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 300, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_t_7 = Py_TYPE(__pyx_t_6)->tp_iternext;
    for (index=0; index < 4; index++) {
      PyObject* item = __pyx_t_7(__pyx_t_6); if (unlikely(!item)) goto __pyx_L7_unpacking_failed;
      __Pyx_GOTREF(item);
      *(temps[index]) = item;
    }
    if (__Pyx_IternextUnpackEndCheck(__pyx_t_7(__pyx_t_6), 4) < 0) __PYX_ERR(0, 300, __pyx_L1_error)
    __pyx_t_7 = NULL;
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    goto __pyx_L8_unpacking_done;
    __pyx_L7_unpacking_failed:;
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __pyx_t_7 = NULL;
    if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
    __PYX_ERR(0, 300, __pyx_L1_error)
    __pyx_L8_unpacking_done:;
  }
  if (!(likely(((__pyx_t_2) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_2, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 300, __pyx_L1_error)
  __pyx_t_8 = __pyx_PyFloat_AsDouble(__pyx_t_4); if (unlikely((__pyx_t_8 == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 300, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_9 = __Pyx_PyObject_to_MemoryviewSlice_dc_long(__pyx_t_5);
  if (unlikely(!__pyx_t_9.memview)) __PYX_ERR(0, 300, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __pyx_t_10 = __Pyx_PyInt_As_int(__pyx_t_1); if (unlikely((__pyx_t_10 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 300, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_11 = ((PyArrayObject *)__pyx_t_2);
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_Z.rcbuffer->pybuffer);
    __pyx_t_12 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_Z.rcbuffer->pybuffer, (PyObject*)__pyx_t_11, &__Pyx_TypeInfo_double, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack);
    if (unlikely(__pyx_t_12 < 0)) {
      PyErr_Fetch(&__pyx_t_13, &__pyx_t_14, &__pyx_t_15);
      if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_Z.rcbuffer->pybuffer, (PyObject*)__pyx_v_Z, &__Pyx_TypeInfo_double, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {
        Py_XDECREF(__pyx_t_13); Py_XDECREF(__pyx_t_14); Py_XDECREF(__pyx_t_15);
        __Pyx_RaiseBufferFallbackError();
      } else {
        PyErr_Restore(__pyx_t_13, __pyx_t_14, __pyx_t_15);
      }
    }
    __pyx_pybuffernd_Z.diminfo[0].strides = __pyx_pybuffernd_Z.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_Z.diminfo[0].shape = __pyx_pybuffernd_Z.rcbuffer->pybuffer.shape[0];
    if (unlikely(__pyx_t_12 < 0)) __PYX_ERR(0, 300, __pyx_L1_error)
  }
  __pyx_t_11 = 0;
  __pyx_v_Z = ((PyArrayObject *)__pyx_t_2);
  __pyx_t_2 = 0;
  __pyx_v_dZr = __pyx_t_8;
  __PYX_XDEC_MEMVIEW(&__pyx_v_bla, 1);
  __pyx_v_bla = __pyx_t_9;
  __pyx_t_9.memview = NULL;
  __pyx_t_9.data = NULL;
  __pyx_v_NZ = __pyx_t_10;
 301: 
 302:     #print NX, NY, NZ
+303:     indZ = ind // (NX*NY)
  __pyx_t_3 = __Pyx_PyInt_From_int((__pyx_v_NX * __pyx_v_NY)); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 303, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_1 = PyNumber_FloorDivide(((PyObject *)__pyx_v_ind), __pyx_t_3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 303, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 303, __pyx_L1_error)
  __pyx_t_16 = ((PyArrayObject *)__pyx_t_1);
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_indZ.rcbuffer->pybuffer);
    __pyx_t_10 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_indZ.rcbuffer->pybuffer, (PyObject*)__pyx_t_16, &__Pyx_TypeInfo_long, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack);
    if (unlikely(__pyx_t_10 < 0)) {
      PyErr_Fetch(&__pyx_t_15, &__pyx_t_14, &__pyx_t_13);
      if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_indZ.rcbuffer->pybuffer, (PyObject*)__pyx_v_indZ, &__Pyx_TypeInfo_long, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {
        Py_XDECREF(__pyx_t_15); Py_XDECREF(__pyx_t_14); Py_XDECREF(__pyx_t_13);
        __Pyx_RaiseBufferFallbackError();
      } else {
        PyErr_Restore(__pyx_t_15, __pyx_t_14, __pyx_t_13);
      }
    }
    __pyx_pybuffernd_indZ.diminfo[0].strides = __pyx_pybuffernd_indZ.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_indZ.diminfo[0].shape = __pyx_pybuffernd_indZ.rcbuffer->pybuffer.shape[0];
    if (unlikely(__pyx_t_10 < 0)) __PYX_ERR(0, 303, __pyx_L1_error)
  }
  __pyx_t_16 = 0;
  __pyx_v_indZ = ((PyArrayObject *)__pyx_t_1);
  __pyx_t_1 = 0;
+304:     indY = (ind - NX*NY*indZ) // NX
  __pyx_t_1 = __Pyx_PyInt_From_int((__pyx_v_NX * __pyx_v_NY)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 304, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_3 = PyNumber_Multiply(__pyx_t_1, ((PyObject *)__pyx_v_indZ)); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 304, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = PyNumber_Subtract(((PyObject *)__pyx_v_ind), __pyx_t_3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 304, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_3 = __Pyx_PyInt_From_int(__pyx_v_NX); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 304, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_5 = PyNumber_FloorDivide(__pyx_t_1, __pyx_t_3); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 304, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  if (!(likely(((__pyx_t_5) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_5, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 304, __pyx_L1_error)
  __pyx_t_16 = ((PyArrayObject *)__pyx_t_5);
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_indY.rcbuffer->pybuffer);
    __pyx_t_10 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_indY.rcbuffer->pybuffer, (PyObject*)__pyx_t_16, &__Pyx_TypeInfo_long, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack);
    if (unlikely(__pyx_t_10 < 0)) {
      PyErr_Fetch(&__pyx_t_13, &__pyx_t_14, &__pyx_t_15);
      if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_indY.rcbuffer->pybuffer, (PyObject*)__pyx_v_indY, &__Pyx_TypeInfo_long, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {
        Py_XDECREF(__pyx_t_13); Py_XDECREF(__pyx_t_14); Py_XDECREF(__pyx_t_15);
        __Pyx_RaiseBufferFallbackError();
      } else {
        PyErr_Restore(__pyx_t_13, __pyx_t_14, __pyx_t_15);
      }
    }
    __pyx_pybuffernd_indY.diminfo[0].strides = __pyx_pybuffernd_indY.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_indY.diminfo[0].shape = __pyx_pybuffernd_indY.rcbuffer->pybuffer.shape[0];
    if (unlikely(__pyx_t_10 < 0)) __PYX_ERR(0, 304, __pyx_L1_error)
  }
  __pyx_t_16 = 0;
  __pyx_v_indY = ((PyArrayObject *)__pyx_t_5);
  __pyx_t_5 = 0;
+305:     indX = ind - NX*NY*indZ - NX*indY
  __pyx_t_5 = __Pyx_PyInt_From_int((__pyx_v_NX * __pyx_v_NY)); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 305, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_t_3 = PyNumber_Multiply(__pyx_t_5, ((PyObject *)__pyx_v_indZ)); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 305, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __pyx_t_5 = PyNumber_Subtract(((PyObject *)__pyx_v_ind), __pyx_t_3); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 305, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_3 = __Pyx_PyInt_From_int(__pyx_v_NX); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 305, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_1 = PyNumber_Multiply(__pyx_t_3, ((PyObject *)__pyx_v_indY)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 305, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_3 = PyNumber_Subtract(__pyx_t_5, __pyx_t_1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 305, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (!(likely(((__pyx_t_3) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_3, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 305, __pyx_L1_error)
  __pyx_t_16 = ((PyArrayObject *)__pyx_t_3);
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_indX.rcbuffer->pybuffer);
    __pyx_t_10 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_indX.rcbuffer->pybuffer, (PyObject*)__pyx_t_16, &__Pyx_TypeInfo_long, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack);
    if (unlikely(__pyx_t_10 < 0)) {
      PyErr_Fetch(&__pyx_t_15, &__pyx_t_14, &__pyx_t_13);
      if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_indX.rcbuffer->pybuffer, (PyObject*)__pyx_v_indX, &__Pyx_TypeInfo_long, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {
        Py_XDECREF(__pyx_t_15); Py_XDECREF(__pyx_t_14); Py_XDECREF(__pyx_t_13);
        __Pyx_RaiseBufferFallbackError();
      } else {
        PyErr_Restore(__pyx_t_15, __pyx_t_14, __pyx_t_13);
      }
    }
    __pyx_pybuffernd_indX.diminfo[0].strides = __pyx_pybuffernd_indX.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_indX.diminfo[0].shape = __pyx_pybuffernd_indX.rcbuffer->pybuffer.shape[0];
    if (unlikely(__pyx_t_10 < 0)) __PYX_ERR(0, 305, __pyx_L1_error)
  }
  __pyx_t_16 = 0;
  __pyx_v_indX = ((PyArrayObject *)__pyx_t_3);
  __pyx_t_3 = 0;
 306:     #print ind
 307:     #print indZ
 308:     #print indY
 309:     #print indX
+310:     Pts = np.array([X[indX.astype(int)], Y[indY.astype(int)], Z[indZ.astype(int)]])
  __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 310, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_array); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 310, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_4 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_indX), __pyx_n_s_astype); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 310, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_2 = NULL;
  if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_4))) {
    __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_4);
    if (likely(__pyx_t_2)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
      __Pyx_INCREF(__pyx_t_2);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_4, function);
    }
  }
  if (!__pyx_t_2) {
    __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_4, ((PyObject *)(&PyInt_Type))); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 310, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
  } else {
    #if CYTHON_FAST_PYCALL
    if (PyFunction_Check(__pyx_t_4)) {
      PyObject *__pyx_temp[2] = {__pyx_t_2, ((PyObject *)(&PyInt_Type))};
      __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_4, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 310, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_GOTREF(__pyx_t_1);
    } else
    #endif
    #if CYTHON_FAST_PYCCALL
    if (__Pyx_PyFastCFunction_Check(__pyx_t_4)) {
      PyObject *__pyx_temp[2] = {__pyx_t_2, ((PyObject *)(&PyInt_Type))};
      __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_4, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 310, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_GOTREF(__pyx_t_1);
    } else
    #endif
    {
      __pyx_t_6 = PyTuple_New(1+1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 310, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_6);
      __Pyx_GIVEREF(__pyx_t_2); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_2); __pyx_t_2 = NULL;
      __Pyx_INCREF(((PyObject *)(&PyInt_Type)));
      __Pyx_GIVEREF(((PyObject *)(&PyInt_Type)));
      PyTuple_SET_ITEM(__pyx_t_6, 0+1, ((PyObject *)(&PyInt_Type)));
      __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_6, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 310, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    }
  }
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_4 = PyObject_GetItem(((PyObject *)__pyx_v_X), __pyx_t_1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 310, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_6 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_indY), __pyx_n_s_astype); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 310, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __pyx_t_2 = NULL;
  if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_6))) {
    __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_6);
    if (likely(__pyx_t_2)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6);
      __Pyx_INCREF(__pyx_t_2);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_6, function);
    }
  }
  if (!__pyx_t_2) {
    __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_6, ((PyObject *)(&PyInt_Type))); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 310, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
  } else {
    #if CYTHON_FAST_PYCALL
    if (PyFunction_Check(__pyx_t_6)) {
      PyObject *__pyx_temp[2] = {__pyx_t_2, ((PyObject *)(&PyInt_Type))};
      __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_6, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 310, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_GOTREF(__pyx_t_1);
    } else
    #endif
    #if CYTHON_FAST_PYCCALL
    if (__Pyx_PyFastCFunction_Check(__pyx_t_6)) {
      PyObject *__pyx_temp[2] = {__pyx_t_2, ((PyObject *)(&PyInt_Type))};
      __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_6, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 310, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_GOTREF(__pyx_t_1);
    } else
    #endif
    {
      __pyx_t_17 = PyTuple_New(1+1); if (unlikely(!__pyx_t_17)) __PYX_ERR(0, 310, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_17);
      __Pyx_GIVEREF(__pyx_t_2); PyTuple_SET_ITEM(__pyx_t_17, 0, __pyx_t_2); __pyx_t_2 = NULL;
      __Pyx_INCREF(((PyObject *)(&PyInt_Type)));
      __Pyx_GIVEREF(((PyObject *)(&PyInt_Type)));
      PyTuple_SET_ITEM(__pyx_t_17, 0+1, ((PyObject *)(&PyInt_Type)));
      __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_6, __pyx_t_17, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 310, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;
    }
  }
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  __pyx_t_6 = PyObject_GetItem(((PyObject *)__pyx_v_Y), __pyx_t_1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 310, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_17 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_indZ), __pyx_n_s_astype); if (unlikely(!__pyx_t_17)) __PYX_ERR(0, 310, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_17);
  __pyx_t_2 = NULL;
  if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_17))) {
    __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_17);
    if (likely(__pyx_t_2)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_17);
      __Pyx_INCREF(__pyx_t_2);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_17, function);
    }
  }
  if (!__pyx_t_2) {
    __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_17, ((PyObject *)(&PyInt_Type))); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 310, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
  } else {
    #if CYTHON_FAST_PYCALL
    if (PyFunction_Check(__pyx_t_17)) {
      PyObject *__pyx_temp[2] = {__pyx_t_2, ((PyObject *)(&PyInt_Type))};
      __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_17, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 310, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_GOTREF(__pyx_t_1);
    } else
    #endif
    #if CYTHON_FAST_PYCCALL
    if (__Pyx_PyFastCFunction_Check(__pyx_t_17)) {
      PyObject *__pyx_temp[2] = {__pyx_t_2, ((PyObject *)(&PyInt_Type))};
      __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_17, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 310, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_GOTREF(__pyx_t_1);
    } else
    #endif
    {
      __pyx_t_18 = PyTuple_New(1+1); if (unlikely(!__pyx_t_18)) __PYX_ERR(0, 310, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_18);
      __Pyx_GIVEREF(__pyx_t_2); PyTuple_SET_ITEM(__pyx_t_18, 0, __pyx_t_2); __pyx_t_2 = NULL;
      __Pyx_INCREF(((PyObject *)(&PyInt_Type)));
      __Pyx_GIVEREF(((PyObject *)(&PyInt_Type)));
      PyTuple_SET_ITEM(__pyx_t_18, 0+1, ((PyObject *)(&PyInt_Type)));
      __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_17, __pyx_t_18, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 310, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_18); __pyx_t_18 = 0;
    }
  }
  __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;
  __pyx_t_17 = PyObject_GetItem(((PyObject *)__pyx_v_Z), __pyx_t_1); if (unlikely(!__pyx_t_17)) __PYX_ERR(0, 310, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_17);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = PyList_New(3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 310, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_4);
  PyList_SET_ITEM(__pyx_t_1, 0, __pyx_t_4);
  __Pyx_GIVEREF(__pyx_t_6);
  PyList_SET_ITEM(__pyx_t_1, 1, __pyx_t_6);
  __Pyx_GIVEREF(__pyx_t_17);
  PyList_SET_ITEM(__pyx_t_1, 2, __pyx_t_17);
  __pyx_t_4 = 0;
  __pyx_t_6 = 0;
  __pyx_t_17 = 0;
  __pyx_t_17 = NULL;
  if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_5))) {
    __pyx_t_17 = PyMethod_GET_SELF(__pyx_t_5);
    if (likely(__pyx_t_17)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5);
      __Pyx_INCREF(__pyx_t_17);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_5, function);
    }
  }
  if (!__pyx_t_17) {
    __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_t_5, __pyx_t_1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 310, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_GOTREF(__pyx_t_3);
  } else {
    #if CYTHON_FAST_PYCALL
    if (PyFunction_Check(__pyx_t_5)) {
      PyObject *__pyx_temp[2] = {__pyx_t_17, __pyx_t_1};
      __pyx_t_3 = __Pyx_PyFunction_FastCall(__pyx_t_5, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 310, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_17); __pyx_t_17 = 0;
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    } else
    #endif
    #if CYTHON_FAST_PYCCALL
    if (__Pyx_PyFastCFunction_Check(__pyx_t_5)) {
      PyObject *__pyx_temp[2] = {__pyx_t_17, __pyx_t_1};
      __pyx_t_3 = __Pyx_PyCFunction_FastCall(__pyx_t_5, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 310, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_17); __pyx_t_17 = 0;
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    } else
    #endif
    {
      __pyx_t_6 = PyTuple_New(1+1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 310, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_6);
      __Pyx_GIVEREF(__pyx_t_17); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_17); __pyx_t_17 = NULL;
      __Pyx_GIVEREF(__pyx_t_1);
      PyTuple_SET_ITEM(__pyx_t_6, 0+1, __pyx_t_1);
      __pyx_t_1 = 0;
      __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_t_6, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 310, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    }
  }
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  if (!(likely(((__pyx_t_3) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_3, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 310, __pyx_L1_error)
  __pyx_t_19 = ((PyArrayObject *)__pyx_t_3);
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_Pts.rcbuffer->pybuffer);
    __pyx_t_10 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_Pts.rcbuffer->pybuffer, (PyObject*)__pyx_t_19, &__Pyx_TypeInfo_double, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack);
    if (unlikely(__pyx_t_10 < 0)) {
      PyErr_Fetch(&__pyx_t_13, &__pyx_t_14, &__pyx_t_15);
      if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_Pts.rcbuffer->pybuffer, (PyObject*)__pyx_v_Pts, &__Pyx_TypeInfo_double, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) {
        Py_XDECREF(__pyx_t_13); Py_XDECREF(__pyx_t_14); Py_XDECREF(__pyx_t_15);
        __Pyx_RaiseBufferFallbackError();
      } else {
        PyErr_Restore(__pyx_t_13, __pyx_t_14, __pyx_t_15);
      }
    }
    __pyx_pybuffernd_Pts.diminfo[0].strides = __pyx_pybuffernd_Pts.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_Pts.diminfo[0].shape = __pyx_pybuffernd_Pts.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_Pts.diminfo[1].strides = __pyx_pybuffernd_Pts.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_Pts.diminfo[1].shape = __pyx_pybuffernd_Pts.rcbuffer->pybuffer.shape[1];
    if (unlikely(__pyx_t_10 < 0)) __PYX_ERR(0, 310, __pyx_L1_error)
  }
  __pyx_t_19 = 0;
  __pyx_v_Pts = ((PyArrayObject *)__pyx_t_3);
  __pyx_t_3 = 0;
+311:     dV = dXr*dYr*dZr
  __pyx_v_dV = ((__pyx_v_dXr * __pyx_v_dYr) * __pyx_v_dZr);
 312: 
+313:     return Pts, dV, dXr, dYr, dZr
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_3 = PyFloat_FromDouble(__pyx_v_dV); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 313, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_5 = PyFloat_FromDouble(__pyx_v_dXr); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 313, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_t_6 = PyFloat_FromDouble(__pyx_v_dYr); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 313, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __pyx_t_1 = PyFloat_FromDouble(__pyx_v_dZr); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 313, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_17 = PyTuple_New(5); if (unlikely(!__pyx_t_17)) __PYX_ERR(0, 313, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_17);
  __Pyx_INCREF(((PyObject *)__pyx_v_Pts));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_Pts));
  PyTuple_SET_ITEM(__pyx_t_17, 0, ((PyObject *)__pyx_v_Pts));
  __Pyx_GIVEREF(__pyx_t_3);
  PyTuple_SET_ITEM(__pyx_t_17, 1, __pyx_t_3);
  __Pyx_GIVEREF(__pyx_t_5);
  PyTuple_SET_ITEM(__pyx_t_17, 2, __pyx_t_5);
  __Pyx_GIVEREF(__pyx_t_6);
  PyTuple_SET_ITEM(__pyx_t_17, 3, __pyx_t_6);
  __Pyx_GIVEREF(__pyx_t_1);
  PyTuple_SET_ITEM(__pyx_t_17, 4, __pyx_t_1);
  __pyx_t_3 = 0;
  __pyx_t_5 = 0;
  __pyx_t_6 = 0;
  __pyx_t_1 = 0;
  __pyx_r = __pyx_t_17;
  __pyx_t_17 = 0;
  goto __pyx_L0;
 314: 
 315: 
 316: 

In [17]:
[dR, dZ, dRPhi], RMinMax, ZMinMax = np.asarray([0.01]*3), np.array([2.,3.]), np.array([-1.,1.])
DR, DZ, DPhi = [2.15,2.6], [-0.21,0.51], [7.*np.pi/4.,5.*np.pi/4.]

Ptsc, dVc, indc, dRrc, dZrc, dRPhirc = _Ves_Vmesh_Tor_SubFromD_cython(dR, dZ, dRPhi, RMinMax, ZMinMax,
                                                                      DR=DR, DZ=DZ, DPhi=DPhi, VPoly=None,
                                                                      Out='(R,Z,phi)', margin=1.e-9)
PtsnI, dVnI, dRrnI, dZrnI, dRPhirnI = _Ves_Vmesh_Tor_SubFromInd_numpy(dR, dZ, dRPhi, RMinMax, ZMinMax,
                                                                      ind=indc, Out='(R,Z,Phi)', margin=1.e-9)
PtscI, dVcI, dRrcI, dZrcI, dRPhircI = _Ves_Vmesh_Tor_SubFromInd_cython(dR, dZ, dRPhi, RMinMax, ZMinMax,
                                                                       ind=indc, Out='(R,Z,phi)', margin=1.e-9)

print dRPhirc.shape, dRPhirnI.shape, dRPhircI.shape
print dRPhirnI
print dRPhircI


(46,) (46,) (46,)
[ 0.0099981   0.00999282  0.00999493  0.00999702  0.0099991   0.00999391
  0.00999598  0.00999803  0.00999291  0.00999496  0.00999699  0.009999
  0.00999397  0.00999598  0.00999797  0.00999994  0.00999499  0.00999696
  0.00999891  0.00999403  0.00999598  0.00999791  0.00999982  0.00999502
  0.00999693  0.00999882  0.00999409  0.00999598  0.00999785  0.00999971
  0.00999505  0.0099969   0.00999874  0.00999414  0.00999598  0.0099978
  0.00999961  0.00999507  0.00999688  0.00999867  0.00999419  0.00999598
  0.00999775  0.00999951  0.0099951   0.00999685]
[ 0.0099981   0.00999282  0.00999493  0.00999702  0.0099991   0.00999391
  0.00999598  0.00999803  0.00999291  0.00999496  0.00999699  0.009999
  0.00999397  0.00999598  0.00999797  0.00999994  0.00999499  0.00999696
  0.00999891  0.00999403  0.00999598  0.00999791  0.00999982  0.00999502
  0.00999693  0.00999882  0.00999409  0.00999598  0.00999785  0.00999971
  0.00999505  0.0099969   0.00999874  0.00999414  0.00999598  0.0099978
  0.00999961  0.00999507  0.00999688  0.00999867  0.00999419  0.00999598
  0.00999775  0.00999951  0.0099951   0.00999685]

In [34]:
LMinMax, dL, DL, margin = np.array([0.,10.]), 0.0001, [1.,9.], 1.e-9
Ln, dLrn, indLn, NLn = _Ves_mesh_dlfromL_numpy(LMinMax, dL, DL=DL, margin=margin)
Lc, dLrc, indLc, NLc = _Ves_mesh_dlfromL_cython(LMinMax, dL, DL=DL, margin=margin)

# Check and debug Tor
[dR, dZ, dRPhi], RMinMax, ZMinMax = np.asarray([0.02]*3), np.array([4.,8.]), np.array([-4.,4.])
DR, DZ, DPhi = np.array([5.,6.5]), np.array([-1.5,2.]), np.array([-np.pi/4.,np.pi/4.])
Ptsn, dVn, indn, dRrn, dZrn, dRPhirn = _Ves_Vmesh_Tor_SubFromD_numpy(dR, dZ, dRPhi, RMinMax, ZMinMax,
                                                                     DR=DR, DZ=DZ, DPhi=DPhi, VPoly=None,
                                                                     Out='(R,Z,Phi)', margin=1.e-9)
Ptsc, dVc, indc, dRrc, dZrc, dRPhirc = _Ves_Vmesh_Tor_SubFromD_cython(dR, dZ, dRPhi, RMinMax, ZMinMax,
                                                                      DR=DR, DZ=DZ, DPhi=DPhi, VPoly=None,
                                                                      Out='(R,Z,phi)', margin=1.e-9)

PtsnI, dVnI, dRrnI, dZrnI, dRPhirnI = _Ves_Vmesh_Tor_SubFromInd_numpy(dR, dZ, dRPhi, RMinMax, ZMinMax,
                                                                      ind=indn, Out='(R,Z,Phi)', margin=1.e-9)
PtscI, dVcI, dRrcI, dZrcI, dRPhircI = _Ves_Vmesh_Tor_SubFromInd_cython(dR, dZ, dRPhi, RMinMax, ZMinMax,
                                                                       ind=indc, Out='(R,Z,Phi)', margin=1.e-9)

print Ptsn.shape[1], 'points'
%timeit Ln, dLrn, indLn, NLn = _Ves_mesh_dlfromL_numpy(LMinMax, dL, DL=DL, margin=margin)
%timeit Lc, dLrc, indLc, NLc = _Ves_mesh_dlfromL_cython(LMinMax, dL, DL=DL, margin=margin)
print [np.allclose(A,B,atol=1.e-9,rtol=0.,equal_nan=True) for (A,B) in [(Ln,Lc),(dLrn,dLrc),(indLn,indLc),(NLn,NLc)]]

%timeit out = _Ves_Vmesh_Tor_SubFromD_numpy(dR, dZ, dRPhi, RMinMax, ZMinMax, DR=DR, DZ=DZ, DPhi=DPhi, VPoly=None)
%timeit out = _Ves_Vmesh_Tor_SubFromD_cython(dR, dZ, dRPhi, RMinMax, ZMinMax, DR=DR, DZ=DZ, DPhi=DPhi, VPoly=None, Out='(X,Y,Z)')
print [np.allclose(A,B,atol=1.e-9,rtol=0.,equal_nan=True) for (A,B) in [(Ptsn,Ptsc),(dVn,dVc),(indn,indc),(dRPhirn,dRPhirc)]]

%timeit out = _Ves_Vmesh_Tor_SubFromInd_numpy(dR, dZ, dRPhi, RMinMax, ZMinMax, ind=indn, Out='(R,Z,Phi)', margin=1.e-9)
%timeit out = _Ves_Vmesh_Tor_SubFromInd_cython(dR, dZ, dRPhi, RMinMax, ZMinMax, ind=indc, Out='(R,Z,Phi)', margin=1.e-9)
print [np.allclose(A,B,atol=1.e-9,rtol=0.,equal_nan=True) for (A,B) in [(PtsnI,PtscI),(dVnI,dVcI),(dRPhirnI,dRPhircI)]]
print [np.allclose(A,B,atol=1.e-9,rtol=0.,equal_nan=True) for (A,B) in [(Ptsc,PtscI),(dVc,dVcI),(dRPhirc,dRPhircI)]]


5940900 points
1000 loops, best of 3: 909 µs per loop
1000 loops, best of 3: 550 µs per loop
[True, True, True, True]
1 loop, best of 3: 1.01 s per loop
1 loop, best of 3: 541 ms per loop
[True, True, True, True]
1 loop, best of 3: 25.2 s per loop
1 loop, best of 3: 1.31 s per loop
[True, True, True]
[True, True, True]

In [18]:
# Check and debug Lin
[dX, dY, dZ], XMinMax, YMinMax, ZMinMax = np.asarray([0.01]*3), np.array([-1,1.]), np.array([-1.,1]), np.array([0.,4.])
DX, DY, DZ = [-0.5,0.5], [-0.5,0.5], [1.,3.]
Ptsn, dVn, indn, dXrn, dYrn, dZrn = _Ves_Vmesh_Lin_SubFromD_cython(dX, dY, dZ, XMinMax, YMinMax, ZMinMax,
                                                                   DX=DX, DY=DY, DZ=DZ, VPoly=None, margin=1.e-9)
Ptsc, dVc, dXrc, dYrc, dZrc = _Ves_Vmesh_Lin_SubFromInd_cython(dX, dY, dZ, XMinMax, YMinMax, ZMinMax,
                                                                     indn, margin=1.e-9)

print Ptsn.shape[1], 'points'
%timeit out = _Ves_Vmesh_Lin_SubFromD_cython(dX, dY, dZ, XMinMax, YMinMax, ZMinMax, DX=DX, DY=DY, DZ=DZ, VPoly=None, margin=1.e-9)
%timeit out = _Ves_Vmesh_Lin_SubFromInd_cython(dX, dY, dZ, XMinMax, YMinMax, ZMinMax, indn, margin=1.e-9)
print [np.allclose(A,B,atol=1.e-9,rtol=0.,equal_nan=True) for (A,B) in [(Ptsn,Ptsc),(dVn,dVc)]]


2000000 points
10 loops, best of 3: 86.7 ms per loop
10 loops, best of 3: 235 ms per loop
[True, True]

Surface meshing


In [1]:
%load_ext cython

In [9]:
%%cython -a

cimport cython
cimport numpy as cnp
from cpython cimport bool
from libc.math cimport sqrt as Csqrt, ceil as Cceil, round as Cround, floor as Cfloor, abs as Cabs
from libc.math cimport cos as Ccos, sin as Csin, atan2 as Catan2, pi as Cpi
from matplotlib.path import Path

import numpy as np

@cython.cdivision(True)
@cython.wraparound(False)
@cython.boundscheck(False)
def _Ves_mesh_dlfromL_cython(double[::1] LMinMax, double dL, DL=None, double margin=1.e-9):
    """ Get the actual reolution from the desired resolution and MinMax and limits """
    # Get the number of mesh elements in LMinMax
    cdef double N = Cceil((LMinMax[1]-LMinMax[0])/dL)
    # Derive the real (effective) resolution
    cdef double dLr = (LMinMax[1]-LMinMax[0])/N
    # Get desired limits if any
    cdef double[::1] DLc, L
    cdef long [::1] indL
    #cdef cnp.ndarray[double,ndim=1] indL, L
    cdef double abs0, abs1, A
    cdef int nL0, nL1, Nind, ii, jj
    cdef list dl
    if DL is None:
        DLc = LMinMax
    else:
        dl = list(DL)
        if dl[0] is None:
            dl[0] = LMinMax[0]
        if dl[1] is None:
            dl[1] = LMinMax[1]
        DLc = np.array(dl)
    # Get the extreme indices of the mesh elements that really need to be created within those limits
    abs0 = Cabs(DLc[0]-LMinMax[0])
    if abs0-dLr*Cfloor(abs0/dLr)<margin*dLr:
        nL0 = int(Cround((DLc[0]-LMinMax[0])/dLr))
    else:
        nL0 = int(Cfloor((DLc[0]-LMinMax[0])/dLr))
    abs1 = Cabs(DLc[1]-LMinMax[0])
    if abs1-dLr*Cfloor(abs1/dLr)<margin*dLr:
        nL1 = int(Cround((DLc[1]-LMinMax[0])/dLr)-1)
    else:
        nL1 = int(Cfloor((DLc[1]-LMinMax[0])/dLr))
    # Get the corresponding indices
    Nind = nL1+1-nL0
    indL = np.empty((Nind,),dtype=int)#np.linspace(nL0,nL1,Nind,endpoint=True)
    L = np.empty((Nind,))
    for ii in range(0,Nind):
        jj = nL0+ii
        indL[ii] = jj
        L[ii] = LMinMax[0] + (0.5 + (<double>jj))*dLr
    return np.asarray(L), dLr, np.asarray(indL), N


@cython.cdivision(True)
@cython.wraparound(False)
@cython.boundscheck(False)
def _Ves_mesh_CrossPoly(double[:,::1] VPoly, double dL, D1=None, D2=None, double margin=1.e-9, double DIn=0., VIn=None):
    cdef int ii, jj, nn=0, NP=VPoly.shape[1]
    cdef double[::1] LMinMax, L
    cdef double v0, v1, dlr
    cdef long[::1] indL
    cdef cnp.ndarray[long,ndim=1] N, ind
    cdef cnp.ndarray[double,ndim=1] dLr, Rref
    cdef cnp.ndarray[double,ndim=2] PtsCross
    cdef list LPtsCross=[], LdLr=[], Lind=[], LRref=[], VPolybis=[]
    
    LMinMax = np.array([0.,1.],dtype=float)
    N = np.empty((NP-1,),dtype=int)
    if DIn==0.:
        for ii in range(0,NP-1):
            v0, v1 = VPoly[0,ii+1]-VPoly[0,ii], VPoly[1,ii+1]-VPoly[1,ii]
            LMinMax[1] = Csqrt(v0**2 + v1**2)
            L, dlr, indL, N[ii] = _Ves_mesh_dlfromL_cython(LMinMax, dL, DL=None, margin=margin)
            VPolybis.append((VPoly[0,ii],VPoly[1,ii]))
            v0, v1 = v0/LMinMax[1], v1/LMinMax[1]
            for jj in range(0,N[ii]):
                LdLr.append(dlr)
                LRref.append(VPoly[0,ii] + L[jj]*v0)
                LPtsCross.append((VPoly[0,ii] + L[jj]*v0, VPoly[1,ii] + L[jj]*v1))
                Lind.append(nn)
                nn += 1
                VPolybis.append((VPoly[0,ii] + jj*dlr*v0, VPoly[1,ii] + jj*dlr*v1))
        VPolybis.append((VPoly[0,0],VPoly[1,0]))
    else:
        for ii in range(0,NP-1):
            v0, v1 = VPoly[0,ii+1]-VPoly[0,ii], VPoly[1,ii+1]-VPoly[1,ii]
            LMinMax[1] = Csqrt(v0**2 + v1**2)
            L, dlr, indL, N[ii] = _Ves_mesh_dlfromL_cython(LMinMax, dL, DL=None, margin=margin)
            VPolybis.append((VPoly[0,ii],VPoly[1,ii]))
            v0, v1 = v0/LMinMax[1], v1/LMinMax[1]
            for jj in range(0,N[ii]):
                LdLr.append(dlr)
                LRref.append(VPoly[0,ii] + L[jj]*v0)
                LPtsCross.append((VPoly[0,ii] + L[jj]*v0 + DIn*VIn[0,ii], VPoly[1,ii] + L[jj]*v1 + DIn*VIn[1,ii]))
                Lind.append(nn)
                nn += 1
                VPolybis.append((VPoly[0,ii] + jj*dlr*v0, VPoly[1,ii] + jj*dlr*v1))
        VPolybis.append((VPoly[0,0],VPoly[1,0]))
    
    PtsCross, dLr, ind, Rref = np.array(LPtsCross).T, np.array(LdLr), np.array(Lind,dtype=int), np.array(LRref)
    if D1 is not None:
        indin = (PtsCross[0,:]>=D1[0]) & (PtsCross[0,:]<=D1[1])
        PtsCross = PtsCross[:,indin]
        dLr, ind = dLr[indin], ind[indin]
    if D2 is not None:
        indin = (PtsCross[1,:]>=D2[0]) & (PtsCross[1,:]<=D2[1])
        PtsCross = PtsCross[:,indin]
        dLr, ind = dLr[indin], ind[indin]   
    
    return PtsCross, dLr, ind, N, Rref, np.array(VPolybis).T
    
    

@cython.cdivision(True)
@cython.wraparound(False)
@cython.boundscheck(False)
def _Ves_Smesh_Tor_SubFromD_cython(double dL, double dRPhi, 
                                   double[:,::1] VPoly,
                                   DR=None, DZ=None, DPhi=None,
                                   double DIn=0., VIn=None, PhiMinMax=None,
                                   str Out='(X,Y,Z)', double margin=1.e-9):
    " Return the desired surfacic submesh indicated by the limits (DR,DZ,DPhi), for the desired resolution (dR,dZ,dRphi) "
    cdef double[::1] R, Z, dPhir, NRPhi#, dPhi, NRZPhi_cum0, indPhi, phi
    cdef double dRr0, dRr, dZr, DPhi0, DPhi1, DPhiMinMax
    cdef double abs0, abs1, phi, indiijj
    cdef long[::1] indR0, indR, indZ, Phin, NRPhi0, Indin
    cdef int NR0, NR, NZ, Rn, Zn, nRPhi0, indR0ii, ii, jj0, jj, nPhi0, nPhi1, zz, NP, NRPhi_int, Rratio, Ln
    cdef cnp.ndarray[double,ndim=2] Pts, indI, PtsCross, VPbis
    cdef cnp.ndarray[double,ndim=1] R0, dS, ind, dLr, Rref, dRPhir
    cdef cnp.ndarray[long,ndim=1] indL, NL
    
    # Pre-format input
    if PhiMinMax is None:
        PhiMinMax = [-Cpi,Cpi]
        DPhiMinMax = 2.*Cpi
    else:
        PhiMinMax = [Catan2(Csin(PhiMinMax[0]),Ccos(PhiMinMax[0])), Catan2(Csin(PhiMinMax[1]),Ccos(PhiMinMax[1]))]
        if PhiMinMax[1]>=PhiMinMax[0]:
            DPhiMinMax = PhiMinMax[1]-PhiMinMax[0]
        else:
            DPhiMinMax = 2.*Cpi + PhiMinMax[1] - PhiMinMax[0]
        
    
    # Get the actual R and Z resolutions and mesh elements
    PtsCross, dLr, indL, NL, Rref, VPbis = _Ves_mesh_CrossPoly(VPoly, dL, D1=None, D2=None, margin=margin, DIn=DIn, VIn=VIn)
    R0 = np.copy(Rref)
    NR0 = R0.size
    indin = np.ones((PtsCross.shape[1],),dtype=bool)
    if DR is not None:
        indin = indin & (R0>=DR[0]) & (R0<=DR[1])
    if DZ is not None:
        indin = indin & (PtsCross[1,:]>=DZ[0]) & (PtsCross[1,:]<=DZ[1])
    PtsCross, dLr, indL, Rref = PtsCross[:,indin], dLr[indin], indL[indin], Rref[indin]
    Ln = indin.sum()
    Indin = indin.nonzero()[0]
    
    # Get the limits if any (and make sure to replace them in the proper quadrants)
    if DPhi is None:
        DPhi0, DPhi1 = PhiMinMax[0], PhiMinMax[1]
    else:
        DPhi0 = PhiMinMax[0] if DPhi[0] is None else Catan2(Csin(DPhi[0]),Ccos(DPhi[0]))
        DPhi1 = PhiMinMax[1] if DPhi[1] is None else Catan2(Csin(DPhi[1]),Ccos(DPhi[1]))
    dRPhir, dPhir = np.empty((Ln,)), np.empty((Ln,))
    Phin = np.empty((Ln,),dtype=int)
    NRPhi = np.empty((Ln,))
    NRPhi0 = np.zeros((Ln,),dtype=int)
    nRPhi0, indR0ii = 0, 0
    NP, NPhimax = 0, 0
    Rratio = int(Cceil(np.max(Rref)/np.min(Rref)))
    for ii in range(0,Ln):
        # Get the actual RPhi resolution and Phi mesh elements (! depends on R !)
        NRPhi[ii] = Cceil(DPhiMinMax*Rref[ii]/dRPhi)
        NRPhi_int = int(NRPhi[ii])
        dPhir[ii] = DPhiMinMax/NRPhi[ii]
        dRPhir[ii] = dPhir[ii]*Rref[ii]
        # Get index and cumulated indices from background
        for jj0 in range(indR0ii,NR0):
            if jj0==Indin[ii]:
                indR0ii = jj0
                break
            else:
                nRPhi0 += <long>Cceil(DPhiMinMax*R0[jj0]/dRPhi)
                NRPhi0[ii] = nRPhi0
        # Get indices of phi
        # Get the extreme indices of the mesh elements that really need to be created within those limits
        abs0 = Cabs(DPhi0-PhiMinMax[0])
        if abs0-dPhir[ii]*Cfloor(abs0/dPhir[ii])<margin*dPhir[ii]:
            nPhi0 = int(Cround((DPhi0-PhiMinMax[0])/dPhir[ii]))
        else:
            nPhi0 = int(Cfloor((DPhi0-PhiMinMax[0])/dPhir[ii]))
        abs1 = Cabs(DPhi1-PhiMinMax[0])
        if abs1-dPhir[ii]*Cfloor(abs1/dPhir[ii])<margin*dPhir[ii]:
            nPhi1 = int(Cround((DPhi1-PhiMinMax[0])/dPhir[ii])-1)
        else:
            nPhi1 = int(Cfloor((DPhi1-PhiMinMax[0])/dPhir[ii]))
        if DPhi0<DPhi1:
            Phin[ii] = nPhi1+1-nPhi0
            if ii==0:
                indI = np.ones((Ln,Phin[ii]*Rratio+1))
            for jj in range(0,Phin[ii]):
                indI[ii,jj] = <double>( nPhi0+jj )
        else:
            Phin[ii] = nPhi1+1+NRPhi_int-nPhi0
            if ii==0:
                indI = np.ones((Ln,Phin[ii]*Rratio+1))
            for jj in range(0,NRPhi_int-nPhi0):
                indI[ii,jj] = <double>( nPhi0+jj )
            for jj in range(NRPhi_int-nPhi0,Phin[ii]):
                indI[ii,jj] = <double>( jj- (NRPhi_int-nPhi0) )
        NP += Phin[ii]
    
    # Finish counting to get total number of points
    if jj0<=NR0-1:
        for jj0 in range(indR0ii,NR0):
            nRPhi0 += <long>Cceil(DPhiMinMax*R0[jj0]/dRPhi)
        
    # Compute Pts, dV and ind
    Pts = np.empty((3,NP))
    ind = np.empty((NP,))
    dS = np.empty((NP,))
    # This triple loop is the longest part, it takes ~90% of the CPU time
    NP = 0
    if Out.lower()=='(x,y,z)':
        for ii in range(0,Ln):
            for jj in range(0,Phin[ii]):
                indiijj = indI[ii,jj]
                phi = PhiMinMax[0] + (0.5+indiijj)*dPhir[ii]
                Pts[0,NP] = PtsCross[0,ii]*Ccos(phi)
                Pts[1,NP] = PtsCross[0,ii]*Csin(phi)
                Pts[2,NP] = PtsCross[1,ii]
                ind[NP] = NRPhi0[ii] + indiijj
                dS[NP] = dLr[ii]*dRPhir[ii]
                NP += 1
    else:
        for ii in range(0,Ln):
            for jj in range(0,Phin[ii]):
                indiijj = indI[ii,jj]
                Pts[0,NP] = PtsCross[0,ii]
                Pts[1,NP] = PtsCross[1,ii]
                Pts[2,NP] = PhiMinMax[0] + (0.5+indiijj)*dPhir[ii]
                ind[NP] = NRPhi0[ii] + indiijj
                dS[NP] = dLr[ii]*dRPhir[ii]
                NP += 1
    return Pts, dS, ind.astype(int), NL, dLr, Rref, dRPhir, nRPhi0, VPbis




@cython.cdivision(True)
@cython.wraparound(False)
@cython.boundscheck(False)
def _Ves_Smesh_Tor_SubFromInd_cython(double dL, double dRPhi, 
                                     double[:,::1] VPoly, long[::1] ind, 
                                     double DIn=0., VIn=None, PhiMinMax=None,
                                     str Out='(X,Y,Z)', double margin=1.e-9):
    """ Return the desired submesh indicated by the (numerical) indices, for the desired resolution (dR,dZ,dRphi) """
    cdef double[::1] dRPhirRef, dPhir
    cdef long[::1] indL, NRPhi0, NRPhi
    cdef long NR, NZ, Rn, Zn, NP=len(ind), Rratio
    cdef int ii, jj0, jj, iiL, iiphi, Ln, nn=0, kk=0, nRPhi0
    cdef double[:,::1] Phi
    cdef cnp.ndarray[double,ndim=2] Pts=np.empty((3,NP)), indI, PtsCross, VPbis
    cdef cnp.ndarray[double,ndim=1] R0, dS=np.empty((NP,)), dLr, dRPhir, Rref
    cdef cnp.ndarray[long,ndim=1] NL

    # Pre-format input
    if PhiMinMax is None:
        PhiMinMax = [-Cpi,Cpi]
        DPhiMinMax = 2.*Cpi
    else:
        PhiMinMax = [Catan2(Csin(PhiMinMax[0]),Ccos(PhiMinMax[0])), Catan2(Csin(PhiMinMax[1]),Ccos(PhiMinMax[1]))]
        if PhiMinMax[1]>=PhiMinMax[0]:
            DPhiMinMax = PhiMinMax[1]-PhiMinMax[0]
        else:
            DPhiMinMax = 2.*Cpi + PhiMinMax[1] - PhiMinMax[0]
    
    
    # Get the actual R and Z resolutions and mesh elements
    PtsCross, dLr, indL, NL, Rref, VPbis = _Ves_mesh_CrossPoly(VPoly, dL, D1=None, D2=None, margin=margin, DIn=DIn, VIn=VIn)
    Ln = dLr.size
    # Number of Phi per R
    dRPhirRef, dPhir, dRPhir = np.empty((Ln,)), np.empty((Ln,)), -np.ones((Ln,))
    NRPhi, NRPhi0 = np.empty((Ln,),dtype=int), np.empty((Ln,),dtype=int)
    Rratio = int(Cceil(np.max(Rref)/np.min(Rref)))
    for ii in range(0,Ln):
        NRPhi[ii] = <long>(Cceil(DPhiMinMax*Rref[ii]/dRPhi))
        dRPhirRef[ii] = DPhiMinMax*Rref[ii]/<double>(NRPhi[ii])
        dPhir[ii] = DPhiMinMax/<double>(NRPhi[ii])
        if ii==0:
            NRPhi0[ii] = 0
            Phi = np.empty((Ln,NRPhi[ii]*Rratio+1))
        else:
            NRPhi0[ii] = NRPhi0[ii-1] + NRPhi[ii-1]
        for jj in range(0,NRPhi[ii]):
            Phi[ii,jj] = PhiMinMax[0] + (0.5+<double>jj)*dPhir[ii]
    nRPhi0 = NRPhi0[Ln-1]+NRPhi[Ln-1]
            
    if Out.lower()=='(x,y,z)':
        for ii in range(0,NP):
            for jj in range(0,Ln+1):
                if ind[ii]-NRPhi0[jj]<0.:
                    break
            iiL = jj-1
            iiphi = ind[ii] - NRPhi0[iiL]
            Pts[0,ii] = PtsCross[0,iiL]*Ccos(Phi[iiL,iiphi])
            Pts[1,ii] = PtsCross[0,iiL]*Csin(Phi[iiL,iiphi])
            Pts[2,ii] = PtsCross[1,iiL]
            dS[ii] = dLr[iiL]*dRPhirRef[iiL]
            if dRPhir[iiL]==-1.:
                dRPhir[iiL] = dRPhirRef[iiL]
            
    else: 
        for ii in range(0,NP):
            for jj in range(0,Ln+1):
                if ind[ii]-NRPhi0[jj]<0.:
                    break
            iiL = jj-1
            iiphi = ind[ii] - NRPhi0[iiL]
            Pts[0,ii] = PtsCross[0,iiL]
            Pts[1,ii] = PtsCross[1,iiL]
            Pts[2,ii] = Phi[iiL,iiphi]
            dS[ii] = dLr[iiL]*dRPhirRef[iiL]
            if dRPhir[iiL]==-1.:
                dRPhir[iiL] = dRPhirRef[iiL]
    return Pts, dS, NL, dLr, Rref, dRPhir[dRPhir>-1.], <long>nRPhi0, VPbis


@cython.cdivision(True)
@cython.wraparound(False)
@cython.boundscheck(False)
def _Ves_Smesh_TorStruct_SubFromD_cython(double[::1] PhiMinMax, double dL, double dRPhi, 
                                         double[:,::1] VPoly,
                                         DR=None, DZ=None, DPhi=None,
                                         double DIn=0., VIn=None,
                                         str Out='(X,Y,Z)', double margin=1.e-9):
    " Return the desired surfacic submesh indicated by the limits (DR,DZ,DPhi), for the desired resolution (dR,dZ,dRphi) "
    cdef double Dphi, dR0r, dZ0r
    cdef int NR0, NZ0, R0n, Z0n, NRPhi0
    cdef cnp.ndarray[double, ndim=1] R0, Z0, dsF, dSM, dLr, Rref, dRPhir, dS
    cdef cnp.ndarray[long,ndim=1] indR0, indZ0, iind, iindF, indM, NL, ind
    cdef cnp.ndarray[double,ndim=2] ptsrz, pts, PtsM, VPbis, Pts
    cdef list LPts=[], LdS=[], Lind=[] 

    # Pre-format input
    if DPhi is not None:
        if DPhi[0]<=PhiMinMax[0]:
            DPhi[0] = None
        if DPhi[1]>=PhiMinMax[1]:
            DPhi[1] = None
            
    Dphi = DIn/np.max(VPoly[0,:]) if DIn!=0. else 0. # Required distance effective at max R

    # Get the mesh for the faces
    Faces = False
    if DPhi is None or DPhi[0] is None or DPhi[1] is None:
        R0, dR0r, indR0, NR0 = _Ves_mesh_dlfromL_cython(np.array([np.min(VPoly[0,:]),np.max(VPoly[0,:])]), dL, DL=DR, margin=margin)
        Z0, dZ0r, indZ0, NZ0 = _Ves_mesh_dlfromL_cython(np.array([np.min(VPoly[1,:]),np.max(VPoly[1,:])]), dL, DL=DZ, margin=margin)
        R0n, Z0n = len(R0), len(Z0)
        ptsrz = np.array([np.tile(R0,Z0n),np.repeat(Z0,R0n)])
        iind = NR0*np.repeat(indZ0,R0n) + np.tile(indR0,Z0n)
        indin = Path(VPoly.T).contains_points(ptsrz.T, transform=None, radius=0.0)
        if np.any(indin):
            ptsrz = ptsrz[:,indin] if indin.sum()>1 else ptsrz[:,indin].reshape((2,1))
            iindF = iind[indin]
            dsF = dR0r*dZ0r*np.ones((indin.sum(),))
            Faces = True

    # First face
    if (DPhi is None or DPhi[0] is None) and Faces:
        if Out.lower()=='(x,y,z)':
            pts = np.array([ptsrz[0,:]*Ccos(PhiMinMax[0]+Dphi), ptsrz[0,:]*Csin(PhiMinMax[0]+Dphi), ptsrz[1,:]])
        else:
            pts = np.array([ptsrz[0,:],ptsrz[1,:],(PhiMinMax[0]+Dphi)*np.ones((indin.sum(),))])
        LPts.append( pts )
        Lind.append( iindF )
        LdS.append( dsF )
  
    # Main body
    PtsM, dSM, indM, NL, dLr, Rref, dRPhir, nRPhi0, VPbis = _Ves_Smesh_Tor_SubFromD_cython(dL, dRPhi, VPoly, 
                                                                                           DR=DR, DZ=DZ, DPhi=DPhi,
                                                                                           DIn=DIn, VIn=VIn, PhiMinMax=PhiMinMax,
                                                                                           Out=Out, margin=margin)      

    if PtsM.shape[1]>=1:
        if PtsM.shape[1]==1:
            LPts.append(PtsM.reshape((3,1)))
        else:
            LPts.append(PtsM)
        Lind.append( indM + NR0*NZ0 )
        LdS.append( dSM )

    # Second face
    if (DPhi is None or DPhi[1] is None) and Faces:
        if Out.lower()=='(x,y,z)':
            pts = np.array([ptsrz[0,:]*Ccos(PhiMinMax[1]-Dphi), ptsrz[0,:]*Csin(PhiMinMax[1]-Dphi), ptsrz[1,:]])
        else:
            pts = np.array([ptsrz[0,:],ptsrz[1,:],(PhiMinMax[1]-Dphi)*np.ones((indin.sum(),))])
        LPts.append( pts )
        Lind.append( iindF + NR0*NZ0 + nRPhi0 )
        LdS.append( dsF )

    # Aggregate
    if len(LPts)==1:
        Pts = LPts[0]
        ind = Lind[0]
        dS = LdS[0]
    else:
        Pts = np.concatenate(tuple(LPts),axis=1)
        ind = np.concatenate(tuple(Lind)).astype(int)
        dS = np.concatenate(tuple(LdS))
        
    return Pts, dS, ind, NL, dLr, Rref, dR0r, dZ0r, dRPhir, VPbis 
      
    
@cython.cdivision(True)
@cython.wraparound(False)
@cython.boundscheck(False)
def _Ves_Smesh_TorStruct_SubFromInd_cython(double[::1] PhiMinMax, double dL, double dRPhi, 
                                           double[:,::1] VPoly, cnp.ndarray[long,ndim=1] ind,
                                           double DIn=0., VIn=None,
                                           str Out='(X,Y,Z)', double margin=1.e-9):
    " Return the desired surfacic submesh indicated by the limits (DR,DZ,DPhi), for the desired resolution (dR,dZ,dRphi) "
    cdef double Dphi, dR0r, dZ0r
    cdef int NR0, NZ0, R0n, Z0n, NRPhi0
    cdef cnp.ndarray[double, ndim=1] R0, Z0, dsF, dSM, dLr, Rref, dRPhir, dS
    cdef cnp.ndarray[long,ndim=1] bla, indR0, indZ0, iind, iindF, indM, NL
    cdef cnp.ndarray[double,ndim=2] ptsrz, pts, PtsM, VPbis, Pts
    cdef list LPts=[], LdS=[], Lind=[] 

    # Pre-format input
    Dphi = DIn/np.max(VPoly[0,:]) if DIn!=0. else 0. # Required distance effective at max R

    # Get the basic meshes for the faces
    R0, dR0r, bla, NR0 = _Ves_mesh_dlfromL_cython(np.array([np.min(VPoly[0,:]),np.max(VPoly[0,:])]), dL, DL=None, margin=margin)
    Z0, dZ0r, bla, NZ0 = _Ves_mesh_dlfromL_cython(np.array([np.min(VPoly[1,:]),np.max(VPoly[1,:])]), dL, DL=None, margin=margin)
    
    PtsM, dSM, indM, NL, dLr, Rref, dRPhir, nRPhi0, VPbis = _Ves_Smesh_Tor_SubFromD_cython(dL, dRPhi, VPoly, 
                                                                                           DR=None, DZ=None, DPhi=None,
                                                                                           DIn=DIn, VIn=VIn, PhiMinMax=PhiMinMax,
                                                                                           Out=Out, margin=margin)
    # First face
    ii = (ind<NR0*NZ0).nonzero()[0]
    nii = len(ii)
    if nii>0:
        indZ0 = ind[ii] // NR0
        indR0 = (ind[ii]-indZ0*NR0)
        if Out.lower()=='(x,y,z)':
            pts = np.array([R0[indR0]*Ccos(PhiMinMax[0]+Dphi), R0[indR0]*Csin(PhiMinMax[0]+Dphi), Z0[indZ0]])
        else:
            pts = np.array([R0[indR0], Z0[indZ0], (PhiMinMax[0]+Dphi)*np.ones((nii,))])
        pts = pts if nii>1 else pts.reshape((3,1))
        LPts.append( pts )
        LdS.append( dR0r*dZ0r*np.ones((nii,)) )
 
    # Main body
    ii = (ind>=NR0*NZ0) & (ind<NR0*NZ0+PtsM.shape[1])
    nii = len(ii)
    if nii>0:
        pts = PtsM[:,ind[ii]-NR0*NZ0] if nii>1 else PtsM[:,ind[ii]-NR0*NZ0].reshape((3,1))
        LPts.append( PtsM[:,ind[ii]-NR0*NZ0] )
        LdS.append( dSM[ind[ii]-NR0*NZ0] )
        
    # Second face
    ii = (ind >= NR0*NZ0+PtsM.shape[1] ).nonzero()[0]
    nii = len(ii)
    if nii>0:
        indZ0 = (ind[ii]-(NR0*NZ0+PtsM.shape[1])) // NR0
        indR0 = ind[ii]-(NR0*NZ0+PtsM.shape[1]) - indZ0*NR0
        if Out.lower()=='(x,y,z)':
            pts = np.array([R0[indR0]*Ccos(PhiMinMax[1]-Dphi), R0[indR0]*Csin(PhiMinMax[1]-Dphi), Z0[indZ0]])
        else:
            pts = np.array([R0[indR0], Z0[indZ0], (PhiMinMax[1]-Dphi)*np.ones((nii,))])
        pts = pts if nii>1 else pts.reshape((3,1))
        LPts.append( pts )
        LdS.append( dR0r*dZ0r*np.ones((nii,)) )
        
    # Aggregate
    if len(LPts)==1:
        Pts = LPts[0]
        dS = LdS[0]
    elif len(LPts)>1:
        Pts = np.concatenate(tuple(LPts),axis=1)
        dS = np.concatenate(tuple(LdS))
        
    return Pts, dS, NL, dLr, Rref, dR0r, dZ0r, dRPhir, VPbis
    

    

@cython.cdivision(True)
@cython.wraparound(False)
@cython.boundscheck(False)
def _Ves_Smesh_Lin_SubFromD_cython(double[::1] XMinMax, double dL, double dX, 
                                   double[:,::1] VPoly,
                                   DX=None, DY=None, DZ=None,
                                   double DIn=0., VIn=None, double margin=1.e-9):
    " Return the desired surfacic submesh indicated by the limits (DX,DY,DZ), for the desired resolution (dX,dL) "
    cdef cnp.ndarray[double,ndim=1] X, Y0, Z0
    cdef double dXr, dY0r, dZ0r
    cdef int NY0, NZ0, Y0n, Z0n, NX, Xn, Ln, NR0
    cdef cnp.ndarray[double,ndim=2] Pts, PtsCross, VPbis
    cdef cnp.ndarray[double,ndim=1] dS, dLr, Rref
    cdef cnp.ndarray[long,ndim=1] indX, indY0, indZ0, indL, NL, ind
    
    # Preformat
    if DX is not None:
        if DX[0]<=XMinMax[0]:
            DX[0] = None
        if DX[1]>=XMinMax[1]:
            DX[1] = None
    if DY is not None:
        if DY[0]<=np.min(VPoly[0,:]):
            DY[0] = None
        if DY[1]>=np.max(VPoly[0,:]):
            DY[1] = None
    if DZ is not None:
        if DZ[0]<=np.min(VPoly[1,:]):
            DZ[0] = None
        if DZ[1]>=np.max(VPoly[1,:]):
            DZ[1] = None
    
    # Get the mesh for the faces
    Y0, dY0r, indY0, NY0 = _Ves_mesh_dlfromL_cython(np.array([np.min(VPoly[0,:]),np.max(VPoly[0,:])]), dL, DL=DY, margin=margin)
    Z0, dZ0r, indZ0, NZ0 = _Ves_mesh_dlfromL_cython(np.array([np.min(VPoly[1,:]),np.max(VPoly[1,:])]), dL, DL=DZ, margin=margin)
    Y0n, Z0n = len(Y0), len(Z0)
    
    # Get the actual R and Z resolutions and mesh elements
    X, dXr, indX, NX = _Ves_mesh_dlfromL_cython(XMinMax, dX, DL=DX, margin=margin)
    Xn = len(X)
    PtsCross, dLr, indL, NL, Rref, VPbis = _Ves_mesh_CrossPoly(VPoly, dL, D1=None, D2=None, margin=margin, DIn=DIn, VIn=VIn)
    NR0 = Rref.size
    indin = np.ones((PtsCross.shape[1],),dtype=bool)
    if DY is not None:
        if DY[0] is not None:
            indin = indin & (PtsCross[0,:]>=DY[0])
        if DY[1] is not None:
            indin = indin & (PtsCross[0,:]<=DY[1])
    if DZ is not None:
        if DZ[0] is not None:
            indin = indin & (PtsCross[1,:]>=DZ[0])
        if DZ[1] is not None:
            indin = indin & (PtsCross[1,:]<=DZ[1])
    PtsCross, dLr, indL, Rref = PtsCross[:,indin], dLr[indin], indL[indin], Rref[indin]
    Ln = indin.sum() 
    # Agregating
    Pts = np.array([np.repeat(X,Ln), np.tile(PtsCross[0,:],Xn), np.tile(PtsCross[1,:],Xn)])
    ind = NY0*NZ0 + np.repeat(indX*NR0,Ln) + np.tile(indL,Xn)
    dS = np.tile(dLr*dXr,Xn)
    if DX is None or DX[0] is None:
        pts = np.array([(XMinMax[0]+DIn)*np.ones((Y0n*Z0n,)), np.tile(Y0,Z0n), np.repeat(Z0,Y0n)])
        iind = NY0*np.repeat(indZ0,Y0n) + np.tile(indY0,Z0n)
        indin = Path(VPoly.T).contains_points(pts[1:,:].T, transform=None, radius=0.0)
        if np.any(indin):
            pts = pts[:,indin].reshape((3,1)) if indin.sum()==1 else pts[:,indin]
            Pts = np.concatenate((pts,Pts),axis=1)
            ind = np.concatenate((iind[indin], ind))
            dS = np.concatenate((dY0r*dZ0r*np.ones((indin.sum(),)),dS))
    if DX is None or DX[1] is None:
        pts = np.array([(XMinMax[1]-DIn)*np.ones((Y0n*Z0n,)), np.tile(Y0,Z0n), np.repeat(Z0,Y0n)])
        iind = NY0*NZ0 + NX*NR0 + NY0*np.repeat(indZ0,Y0n) + np.tile(indY0,Z0n)
        indin = Path(VPoly.T).contains_points(pts[1:,:].T, transform=None, radius=0.0)
        if np.any(indin):
            pts = pts[:,indin].reshape((3,1)) if indin.sum()==1 else pts[:,indin]
            Pts = np.concatenate((Pts,pts),axis=1)
            ind = np.concatenate((ind,iind[indin]))
            dS = np.concatenate((dS,dY0r*dZ0r*np.ones((indin.sum(),))))
    return Pts, dS, ind, NL, dLr, Rref, dXr, dY0r, dZ0r, VPbis
    
  
    
    
    
    
@cython.cdivision(True)
@cython.wraparound(False)
@cython.boundscheck(False)
def _Ves_Smesh_Lin_SubFromInd_cython(double[::1] XMinMax, double dL, double dX, 
                                     double[:,::1] VPoly, cnp.ndarray[long,ndim=1] ind,
                                     double DIn=0., VIn=None, double margin=1.e-9):
    " Return the desired surfacic submesh indicated by ind, for the desired resolution (dX,dL) "
    cdef double dXr, dY0r, dZ0r
    cdef int NX, NY0, NZ0, Ln, NR0, nii
    cdef list LPts, LdS
    cdef cnp.ndarray[double,ndim=2] Pts, PtsCross, VPbis
    cdef cnp.ndarray[double,ndim=1] X, Y0, Z0, dS, dLr, Rref
    cdef cnp.ndarray[long,ndim=1] indX, indY0, indZ0, indL, NL, ii
    
    # Get the mesh for the faces
    Y0, dY0r, bla, NY0 = _Ves_mesh_dlfromL_cython(np.array([np.min(VPoly[0,:]),np.max(VPoly[0,:])]), dL, DL=None, margin=margin)
    Z0, dZ0r, bla, NZ0 = _Ves_mesh_dlfromL_cython(np.array([np.min(VPoly[1,:]),np.max(VPoly[1,:])]), dL, DL=None, margin=margin)
    
    # Get the actual R and Z resolutions and mesh elements
    X, dXr, bla, NX = _Ves_mesh_dlfromL_cython(XMinMax, dX, DL=None, margin=margin)
    PtsCross, dLr, bla, NL, Rref, VPbis = _Ves_mesh_CrossPoly(VPoly, dL, D1=None, D2=None, margin=margin, DIn=DIn, VIn=VIn)
    Ln = PtsCross.shape[1] 

    LPts, LdS = [], []
    # First face
    ii = (ind<NY0*NZ0).nonzero()[0]
    nii = len(ii)
    if nii>0:
        indZ0 = ind[ii] // NY0
        indY0 = (ind[ii]-indZ0*NY0)
        if nii==1:
            LPts.append( np.array([[XMinMax[0]+DIn], [Y0[indY0]], [Z0[indZ0]]]) )
        else:
            LPts.append( np.array([(XMinMax[0]+DIn)*np.ones((nii,)), Y0[indY0], Z0[indZ0]]) )
        LdS.append( dY0r*dZ0r*np.ones((nii,)) )

    # Cylinder
    ii = ((ind>=NY0*NZ0) & (ind<NY0*NZ0+NX*Ln)).nonzero()[0]
    nii = len(ii)
    if nii>0:
        indX = (ind[ii]-NY0*NZ0) // Ln
        indL = (ind[ii]-NY0*NZ0 - Ln*indX)
        if nii==1:
            LPts.append( np.array([[X[indX]], [PtsCross[0,indL]], [PtsCross[1,indL]]]) )
            LdS.append( np.array([dXr*dLr[indL]]) )
        else:
            LPts.append( np.array([X[indX], PtsCross[0,indL], PtsCross[1,indL]]) )
            LdS.append( dXr*dLr[indL] )

    # End face
    ii = (ind >= NY0*NZ0+NX*Ln).nonzero()[0]
    nii = len(ii)
    if nii>0:
        indZ0 = (ind[ii]-NY0*NZ0-NX*Ln) // NY0
        indY0 = ind[ii]-NY0*NZ0-NX*Ln - NY0*indZ0
        if nii==1:
            LPts.append( np.array([[XMinMax[1]-DIn], [Y0[indY0]], [Z0[indZ0]]]) )
        else:
            LPts.append( np.array([(XMinMax[1]-DIn)*np.ones((nii,)), Y0[indY0], Z0[indZ0]]) )
        LdS.append( dY0r*dZ0r*np.ones((nii,)) )

    # Format output
    if len(LPts)==1:
        Pts, dS = LPts[0], LdS[0]
    else:
        Pts = np.concatenate(tuple(LPts),axis=1)
        dS = np.concatenate(tuple(LdS))
        
    return Pts, dS, NL, dLr, Rref, dXr, dY0r, dZ0r, VPbis




##################### New version

def _getBoundsInter2AngSeg(bool Full, double Phi0, double Phi1, double DPhi0, double DPhi1):
    """ Return Inter=True if an intersection exist (all angles in radians in [-pi;pi])

    If Inter, return Bounds, a list of tuples indicating the segments defining the intersection, with
    The intervals are ordered from lowest index to highst index (with respect to [Phi0,Phi1])
    """
    if Full:
        Bounds = [[DPhi0,DPhi1]] if DPhi0<=DPhi1 else [[-Cpi,DPhi1],[DPhi0,Cpi]]
        Inter = True

    else:
        Inter, Bounds = False, None
        if Phi0<=Phi1:
            if DPhi0<=DPhi1:
                if DPhi0<=Phi1 and DPhi1>=Phi0:
                    Inter = True
                    Bounds = [[None,None]]
                    Bounds[0][0] = Phi0 if DPhi0<=Phi0 else DPhi0
                    Bounds[0][1] = Phi1 if DPhi1>=Phi1 else DPhi1
            else:
                if DPhi0<=Phi1 or DPhi1>=Phi0:
                    Inter = True
                    if DPhi0<=Phi1 and DPhi1>=Phi0:
                        Bounds = [[Phi0,DPhi1],[DPhi0,Phi1]]
                    else:
                        Bounds = [[None,None]]
                        if DPhi0<=Phi1:
                            Bounds[0][0] = Phi0 if DPhi0<=Phi0 else DPhi0
                            Bounds[0][1] = Phi1
                        else:
                            Bounds[0][0] = Phi0
                            Bounds[0][1] = Phi1 if DPhi1>=Phi1 else DPhi1
        else:
            if DPhi0<=DPhi1:
                if DPhi0<=Phi1 or DPhi1>=Phi0:
                    Inter = True
                    if DPhi0<=Phi1 and DPhi1>=Phi0:
                        Bounds = [[Phi0,DPhi1],[DPhi0,Phi1]]
                    else:
                        Bounds = [[None,None]]
                        if DPhi0<=Phi1:
                            Bounds[0][0] = DPhi0
                            Bounds[0][1] = Phi1 if DPhi1>=Phi1 else DPhi1
                        else:
                            Bounds[0][0] = Phi0 if DPhi0<=Phi0 else DPhi0
                            Bounds[0][1] = DPhi1
            else:
                Inter = True
                if DPhi0>=Phi0 and DPhi1>=Phi0:
                    Bounds = [[Phi0,DPhi1],[DPhi0,Cpi],[-Cpi,Phi1]]
                elif DPhi0<=Phi1 and DPhi1<=Phi1:
                    Bounds = [[Phi0,Cpi],[-Cpi,DPhi1],[DPhi0,Phi1]]
                else:
                    Bounds = [[None,Cpi],[-Cpi,None]]
                    Bounds[0][0] = Phi0 if DPhi0<=Phi0 else DPhi0
                    Bounds[1][1] = Phi1 if DPhi1>=Phi1 else DPhi1
    return Inter, Bounds

    



@cython.cdivision(True)
@cython.wraparound(False)
@cython.boundscheck(False)
def _Ves_Smesh_Tor_SubFromD_bis(double dL, double dRPhi,
                                   double[:,::1] VPoly,
                                   DR=None, DZ=None, DPhi=None,
                                   double DIn=0., VIn=None, PhiMinMax=None,
                                   str Out='(X,Y,Z)', double margin=1.e-9):
    " Return the desired surfacic submesh indicated by the limits (DR,DZ,DPhi), for the desired resolution (dR,dZ,dRphi) "
    cdef double[::1] R, Z, dPhir, NRPhi#, dPhi, NRZPhi_cum0, indPhi, phi
    cdef double dRr0, dRr, dZr, DPhi0, DPhi1, DDPhi, DPhiMinMax
    cdef double abs0, abs1, phi, indiijj
    cdef long[::1] indR0, indR, indZ, Phin, NRPhi0, Indin
    cdef int NR0, NR, NZ, Rn, Zn, nRPhi0, indR0ii, ii, jj0=0, jj, nPhi0, nPhi1, zz, NP, NRPhi_int, Rratio, Ln
    cdef cnp.ndarray[double,ndim=2] Pts, indI, PtsCross, VPbis
    cdef cnp.ndarray[double,ndim=1] R0, dS, ind, dLr, Rref, dRPhir
    cdef cnp.ndarray[long,ndim=1] indL, NL

    # Pre-format input
    if PhiMinMax is None:
        PhiMinMax = [-Cpi,Cpi]
        DPhiMinMax = 2.*Cpi
        Full = True
    else:
        PhiMinMax = [Catan2(Csin(PhiMinMax[0]),Ccos(PhiMinMax[0])), Catan2(Csin(PhiMinMax[1]),Ccos(PhiMinMax[1]))]
        DPhiMinMax = PhiMinMax[1]-PhiMinMax[0] if PhiMinMax[1]>=PhiMinMax[0] else 2.*Cpi + PhiMinMax[1] - PhiMinMax[0]
        Full = False

    # Get the limits if any (and make sure to replace them in the proper quadrants)
    if DPhi is None:
        DPhi0, DPhi1 = PhiMinMax[0], PhiMinMax[1]
    else:
        DPhi0 = PhiMinMax[0] if DPhi[0] is None else Catan2(Csin(DPhi[0]),Ccos(DPhi[0]))
        DPhi1 = PhiMinMax[1] if DPhi[1] is None else Catan2(Csin(DPhi[1]),Ccos(DPhi[1]))
    DDPhi = DPhi1-DPhi0 if DPhi1>DPhi0 else 2.*Cpi+DPhi1-DPhi0

    Inter, Bounds = _getBoundsInter2AngSeg(Full, PhiMinMax[0], PhiMinMax[1], DPhi0, DPhi1)
    BC = list(Bounds)
    nBounds = len(Bounds)
    for ii in range(0,nBounds):
        if BC[ii][0]<PhiMinMax[0]:
            BC[ii][0] += 2.*Cpi
        if BC[ii][1]<=PhiMinMax[0]:
            BC[ii][1] += 2.*Cpi
            
    
    if Inter:

        # Get the actual R and Z resolutions and mesh elements
        PtsCross, dLr, indL, NL, Rref, VPbis = _Ves_mesh_CrossPoly(VPoly, dL, D1=None, D2=None, margin=margin, DIn=DIn, VIn=VIn)
        R0 = np.copy(Rref)
        NR0 = R0.size
        indin = np.ones((PtsCross.shape[1],),dtype=bool)
        if DR is not None:
            indin = indin & (R0>=DR[0]) & (R0<=DR[1])
        if DZ is not None:
            indin = indin & (PtsCross[1,:]>=DZ[0]) & (PtsCross[1,:]<=DZ[1])
        PtsCross, dLr, indL, Rref = PtsCross[:,indin], dLr[indin], indL[indin], Rref[indin]
        Ln = indin.sum()
        Indin = indin.nonzero()[0]

        dRPhir, dPhir = np.empty((Ln,)), np.empty((Ln,))
        Phin = np.zeros((Ln,),dtype=int)
        NRPhi = np.empty((Ln,))
        NRPhi0 = np.zeros((Ln,),dtype=int)
        nRPhi0, indR0ii = 0, 0
        NP, NPhimax = 0, 0
        Rratio = int(Cceil(np.max(Rref)/np.min(Rref)))
        indBounds = np.empty((2,nBounds),dtype=int)
        for ii in range(0,Ln):
            # Get the actual RPhi resolution and Phi mesh elements (! depends on R !)
            NRPhi[ii] = Cceil(DPhiMinMax*Rref[ii]/dRPhi)
            NRPhi_int = int(NRPhi[ii])
            dPhir[ii] = DPhiMinMax/NRPhi[ii]
            dRPhir[ii] = dPhir[ii]*Rref[ii]
            # Get index and cumulated indices from background
            for jj0 in range(indR0ii,NR0):
                if jj0==Indin[ii]:
                    indR0ii = jj0
                    break
                else:
                    nRPhi0 += <long>Cceil(DPhiMinMax*R0[jj0]/dRPhi)
                    NRPhi0[ii] = nRPhi0
            # Get indices of phi
            # Get the extreme indices of the mesh elements that really need to be created within those limits
            for kk in range(0,nBounds):
                abs0 = Cabs(BC[kk][0]-PhiMinMax[0])
                if abs0-dPhir[ii]*Cfloor(abs0/dPhir[ii])<margin*dPhir[ii]:
                    nPhi0 = int(Cround(abs0/dPhir[ii]))
                else:
                    nPhi0 = int(Cfloor(abs0/dPhir[ii]))
                abs1 = Cabs(BC[kk][1]-PhiMinMax[0])
                if abs1-dPhir[ii]*Cfloor(abs1/dPhir[ii])<margin*dPhir[ii]:
                    nPhi1 = int(Cround(abs1/dPhir[ii]))
                else:
                    nPhi1 = int(Cfloor(abs1/dPhir[ii]))
                indBounds[0,kk] = nPhi0
                indBounds[1,kk] = nPhi1
                Phin[ii] += nPhi1+1-nPhi0
                
            if ii==0:
                indI = np.ones((Ln,Phin[ii]*Rratio+1))
            jj = 0
            for kk in range(0,nBounds):
                for kkb in range(indBounds[0,kk],indBounds[1,kk]+1):
                    indI[ii,jj] = <double>( kkb )
                    jj += 1
            NP += Phin[ii]

        # Finish counting to get total number of points
        if jj0<=NR0-1:
            for jj0 in range(indR0ii,NR0):
                nRPhi0 += <long>Cceil(DPhiMinMax*R0[jj0]/dRPhi)

        # Compute Pts, dV and ind
        Pts = np.empty((3,NP))
        ind = np.empty((NP,))
        dS = np.empty((NP,))
        # This triple loop is the longest part, it takes ~90% of the CPU time
        NP = 0
        if Out.lower()=='(x,y,z)':
            for ii in range(0,Ln):
                for jj in range(0,Phin[ii]):
                    indiijj = indI[ii,jj]
                    phi = PhiMinMax[0] + (0.5+indiijj)*dPhir[ii]
                    Pts[0,NP] = PtsCross[0,ii]*Ccos(phi)
                    Pts[1,NP] = PtsCross[0,ii]*Csin(phi)
                    Pts[2,NP] = PtsCross[1,ii]
                    ind[NP] = NRPhi0[ii] + indiijj
                    dS[NP] = dLr[ii]*dRPhir[ii]
                    NP += 1
        else:
            for ii in range(0,Ln):
                for jj in range(0,Phin[ii]):
                    indiijj = indI[ii,jj]
                    Pts[0,NP] = PtsCross[0,ii]
                    Pts[1,NP] = PtsCross[1,ii]
                    Pts[2,NP] = PhiMinMax[0] + (0.5+indiijj)*dPhir[ii]
                    ind[NP] = NRPhi0[ii] + indiijj
                    dS[NP] = dLr[ii]*dRPhir[ii]
                    NP += 1
    else:
        Pts, dS, ind, NL, dRPhir, nRPhi0 = None, None, None, None, None, None
    return Pts, dS, ind.astype(int), NL, dLr, Rref, dRPhir, nRPhi0, VPbis


Out[9]:
Cython: _cython_magic_8152fc40fb05daa7217c00b66474f995.pyx

Generated by Cython 0.25.2

Yellow lines hint at Python interaction.
Click on a line that starts with a "+" to see the C code that Cython generated for it.

 001: 
+002: cimport cython
  __pyx_t_2 = PyDict_New(); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_test, __pyx_t_2) < 0) __PYX_ERR(0, 2, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
 003: cimport numpy as cnp
 004: from cpython cimport bool
 005: from libc.math cimport sqrt as Csqrt, ceil as Cceil, round as Cround, floor as Cfloor, abs as Cabs
 006: from libc.math cimport cos as Ccos, sin as Csin, atan2 as Catan2, pi as Cpi
+007: from matplotlib.path import Path
  __pyx_t_1 = PyList_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 7, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_INCREF(__pyx_n_s_Path);
  __Pyx_GIVEREF(__pyx_n_s_Path);
  PyList_SET_ITEM(__pyx_t_1, 0, __pyx_n_s_Path);
  __pyx_t_2 = __Pyx_Import(__pyx_n_s_matplotlib_path, __pyx_t_1, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 7, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = __Pyx_ImportFrom(__pyx_t_2, __pyx_n_s_Path); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 7, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_Path, __pyx_t_1) < 0) __PYX_ERR(0, 7, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
 008: 
+009: import numpy as np
  __pyx_t_2 = __Pyx_Import(__pyx_n_s_numpy, 0, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 9, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_np, __pyx_t_2) < 0) __PYX_ERR(0, 9, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
 010: 
 011: @cython.cdivision(True)
 012: @cython.wraparound(False)
 013: @cython.boundscheck(False)
+014: def _Ves_mesh_dlfromL_cython(double[::1] LMinMax, double dL, DL=None, double margin=1.e-9):
/* Python wrapper */
static PyObject *__pyx_pw_46_cython_magic_8152fc40fb05daa7217c00b66474f995_1_Ves_mesh_dlfromL_cython(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_46_cython_magic_8152fc40fb05daa7217c00b66474f995__Ves_mesh_dlfromL_cython[] = " Get the actual reolution from the desired resolution and MinMax and limits ";
static PyMethodDef __pyx_mdef_46_cython_magic_8152fc40fb05daa7217c00b66474f995_1_Ves_mesh_dlfromL_cython = {"_Ves_mesh_dlfromL_cython", (PyCFunction)__pyx_pw_46_cython_magic_8152fc40fb05daa7217c00b66474f995_1_Ves_mesh_dlfromL_cython, METH_VARARGS|METH_KEYWORDS, __pyx_doc_46_cython_magic_8152fc40fb05daa7217c00b66474f995__Ves_mesh_dlfromL_cython};
static PyObject *__pyx_pw_46_cython_magic_8152fc40fb05daa7217c00b66474f995_1_Ves_mesh_dlfromL_cython(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  __Pyx_memviewslice __pyx_v_LMinMax = { 0, 0, { 0 }, { 0 }, { 0 } };
  double __pyx_v_dL;
  PyObject *__pyx_v_DL = 0;
  double __pyx_v_margin;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("_Ves_mesh_dlfromL_cython (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_LMinMax,&__pyx_n_s_dL,&__pyx_n_s_DL,&__pyx_n_s_margin,0};
    PyObject* values[4] = {0,0,0,0};
    values[2] = ((PyObject *)Py_None);
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_LMinMax)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        case  1:
        if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_dL)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_Ves_mesh_dlfromL_cython", 0, 2, 4, 1); __PYX_ERR(0, 14, __pyx_L3_error)
        }
        case  2:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_DL);
          if (value) { values[2] = value; kw_args--; }
        }
        case  3:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_margin);
          if (value) { values[3] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "_Ves_mesh_dlfromL_cython") < 0)) __PYX_ERR(0, 14, __pyx_L3_error)
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    __pyx_v_LMinMax = __Pyx_PyObject_to_MemoryviewSlice_dc_double(values[0]); if (unlikely(!__pyx_v_LMinMax.memview)) __PYX_ERR(0, 14, __pyx_L3_error)
    __pyx_v_dL = __pyx_PyFloat_AsDouble(values[1]); if (unlikely((__pyx_v_dL == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 14, __pyx_L3_error)
    __pyx_v_DL = values[2];
    if (values[3]) {
      __pyx_v_margin = __pyx_PyFloat_AsDouble(values[3]); if (unlikely((__pyx_v_margin == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 14, __pyx_L3_error)
    } else {
      __pyx_v_margin = ((double)1.e-9);
    }
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("_Ves_mesh_dlfromL_cython", 0, 2, 4, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 14, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("_cython_magic_8152fc40fb05daa7217c00b66474f995._Ves_mesh_dlfromL_cython", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_46_cython_magic_8152fc40fb05daa7217c00b66474f995__Ves_mesh_dlfromL_cython(__pyx_self, __pyx_v_LMinMax, __pyx_v_dL, __pyx_v_DL, __pyx_v_margin);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_46_cython_magic_8152fc40fb05daa7217c00b66474f995__Ves_mesh_dlfromL_cython(CYTHON_UNUSED PyObject *__pyx_self, __Pyx_memviewslice __pyx_v_LMinMax, double __pyx_v_dL, PyObject *__pyx_v_DL, double __pyx_v_margin) {
  double __pyx_v_N;
  double __pyx_v_dLr;
  __Pyx_memviewslice __pyx_v_DLc = { 0, 0, { 0 }, { 0 }, { 0 } };
  __Pyx_memviewslice __pyx_v_L = { 0, 0, { 0 }, { 0 }, { 0 } };
  __Pyx_memviewslice __pyx_v_indL = { 0, 0, { 0 }, { 0 }, { 0 } };
  double __pyx_v_abs0;
  double __pyx_v_abs1;
  int __pyx_v_nL0;
  int __pyx_v_nL1;
  int __pyx_v_Nind;
  int __pyx_v_ii;
  int __pyx_v_jj;
  PyObject *__pyx_v_dl = 0;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("_Ves_mesh_dlfromL_cython", 0);
/* … */
  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_XDECREF(__pyx_t_10);
  __Pyx_XDECREF(__pyx_t_11);
  __Pyx_XDECREF(__pyx_t_12);
  __PYX_XDEC_MEMVIEW(&__pyx_t_13, 1);
  __PYX_XDEC_MEMVIEW(&__pyx_t_26, 1);
  __Pyx_XDECREF(__pyx_t_27);
  __Pyx_XDECREF(__pyx_t_33);
  __Pyx_XDECREF(__pyx_t_34);
  __Pyx_AddTraceback("_cython_magic_8152fc40fb05daa7217c00b66474f995._Ves_mesh_dlfromL_cython", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __PYX_XDEC_MEMVIEW(&__pyx_v_DLc, 1);
  __PYX_XDEC_MEMVIEW(&__pyx_v_L, 1);
  __PYX_XDEC_MEMVIEW(&__pyx_v_indL, 1);
  __Pyx_XDECREF(__pyx_v_dl);
  __PYX_XDEC_MEMVIEW(&__pyx_v_LMinMax, 1);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}
/* … */
  __pyx_tuple__105 = PyTuple_Pack(18, __pyx_n_s_LMinMax, __pyx_n_s_dL, __pyx_n_s_DL, __pyx_n_s_margin, __pyx_n_s_N, __pyx_n_s_dLr, __pyx_n_s_DLc, __pyx_n_s_L, __pyx_n_s_indL, __pyx_n_s_abs0, __pyx_n_s_abs1, __pyx_n_s_A, __pyx_n_s_nL0, __pyx_n_s_nL1, __pyx_n_s_Nind, __pyx_n_s_ii, __pyx_n_s_jj, __pyx_n_s_dl); if (unlikely(!__pyx_tuple__105)) __PYX_ERR(0, 14, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__105);
  __Pyx_GIVEREF(__pyx_tuple__105);
/* … */
  __pyx_t_2 = PyCFunction_NewEx(&__pyx_mdef_46_cython_magic_8152fc40fb05daa7217c00b66474f995_1_Ves_mesh_dlfromL_cython, NULL, __pyx_n_s_cython_magic_8152fc40fb05daa721); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 14, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_Ves_mesh_dlfromL_cython, __pyx_t_2) < 0) __PYX_ERR(0, 14, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_codeobj__106 = (PyObject*)__Pyx_PyCode_New(4, 0, 18, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__105, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_Home_DV226270_cache_ipython_cyt, __pyx_n_s_Ves_mesh_dlfromL_cython, 14, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__106)) __PYX_ERR(0, 14, __pyx_L1_error)
 015:     """ Get the actual reolution from the desired resolution and MinMax and limits """
 016:     # Get the number of mesh elements in LMinMax
+017:     cdef double N = Cceil((LMinMax[1]-LMinMax[0])/dL)
  __pyx_t_1 = 1;
  __pyx_t_2 = 0;
  __pyx_v_N = ceil((((*((double *) ( /* dim=0 */ ((char *) (((double *) __pyx_v_LMinMax.data) + __pyx_t_1)) ))) - (*((double *) ( /* dim=0 */ ((char *) (((double *) __pyx_v_LMinMax.data) + __pyx_t_2)) )))) / __pyx_v_dL));
 018:     # Derive the real (effective) resolution
+019:     cdef double dLr = (LMinMax[1]-LMinMax[0])/N
  __pyx_t_3 = 1;
  __pyx_t_4 = 0;
  __pyx_v_dLr = (((*((double *) ( /* dim=0 */ ((char *) (((double *) __pyx_v_LMinMax.data) + __pyx_t_3)) ))) - (*((double *) ( /* dim=0 */ ((char *) (((double *) __pyx_v_LMinMax.data) + __pyx_t_4)) )))) / __pyx_v_N);
 020:     # Get desired limits if any
 021:     cdef double[::1] DLc, L
 022:     cdef long [::1] indL
 023:     #cdef cnp.ndarray[double,ndim=1] indL, L
 024:     cdef double abs0, abs1, A
 025:     cdef int nL0, nL1, Nind, ii, jj
 026:     cdef list dl
+027:     if DL is None:
  __pyx_t_5 = (__pyx_v_DL == Py_None);
  __pyx_t_6 = (__pyx_t_5 != 0);
  if (__pyx_t_6) {
/* … */
    goto __pyx_L3;
  }
+028:         DLc = LMinMax
    __PYX_INC_MEMVIEW(&__pyx_v_LMinMax, 0);
    __pyx_v_DLc = __pyx_v_LMinMax;
 029:     else:
+030:         dl = list(DL)
  /*else*/ {
    __pyx_t_7 = PySequence_List(__pyx_v_DL); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 30, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    __pyx_v_dl = ((PyObject*)__pyx_t_7);
    __pyx_t_7 = 0;
+031:         if dl[0] is None:
    __pyx_t_6 = (PyList_GET_ITEM(__pyx_v_dl, 0) == Py_None);
    __pyx_t_5 = (__pyx_t_6 != 0);
    if (__pyx_t_5) {
/* … */
    }
+032:             dl[0] = LMinMax[0]
      __pyx_t_8 = 0;
      __pyx_t_7 = PyFloat_FromDouble((*((double *) ( /* dim=0 */ ((char *) (((double *) __pyx_v_LMinMax.data) + __pyx_t_8)) )))); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 32, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_7);
      if (unlikely(__Pyx_SetItemInt(__pyx_v_dl, 0, __pyx_t_7, long, 1, __Pyx_PyInt_From_long, 1, 0, 0) < 0)) __PYX_ERR(0, 32, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
+033:         if dl[1] is None:
    __pyx_t_5 = (PyList_GET_ITEM(__pyx_v_dl, 1) == Py_None);
    __pyx_t_6 = (__pyx_t_5 != 0);
    if (__pyx_t_6) {
/* … */
    }
+034:             dl[1] = LMinMax[1]
      __pyx_t_9 = 1;
      __pyx_t_7 = PyFloat_FromDouble((*((double *) ( /* dim=0 */ ((char *) (((double *) __pyx_v_LMinMax.data) + __pyx_t_9)) )))); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 34, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_7);
      if (unlikely(__Pyx_SetItemInt(__pyx_v_dl, 1, __pyx_t_7, long, 1, __Pyx_PyInt_From_long, 1, 0, 0) < 0)) __PYX_ERR(0, 34, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
+035:         DLc = np.array(dl)
    __pyx_t_10 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 35, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_10);
    __pyx_t_11 = __Pyx_PyObject_GetAttrStr(__pyx_t_10, __pyx_n_s_array); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 35, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_11);
    __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
    __pyx_t_10 = NULL;
    if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_11))) {
      __pyx_t_10 = PyMethod_GET_SELF(__pyx_t_11);
      if (likely(__pyx_t_10)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_11);
        __Pyx_INCREF(__pyx_t_10);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_11, function);
      }
    }
    if (!__pyx_t_10) {
      __pyx_t_7 = __Pyx_PyObject_CallOneArg(__pyx_t_11, __pyx_v_dl); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 35, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_7);
    } else {
      #if CYTHON_FAST_PYCALL
      if (PyFunction_Check(__pyx_t_11)) {
        PyObject *__pyx_temp[2] = {__pyx_t_10, __pyx_v_dl};
        __pyx_t_7 = __Pyx_PyFunction_FastCall(__pyx_t_11, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 35, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
        __Pyx_GOTREF(__pyx_t_7);
      } else
      #endif
      #if CYTHON_FAST_PYCCALL
      if (__Pyx_PyFastCFunction_Check(__pyx_t_11)) {
        PyObject *__pyx_temp[2] = {__pyx_t_10, __pyx_v_dl};
        __pyx_t_7 = __Pyx_PyCFunction_FastCall(__pyx_t_11, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 35, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
        __Pyx_GOTREF(__pyx_t_7);
      } else
      #endif
      {
        __pyx_t_12 = PyTuple_New(1+1); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 35, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_12);
        __Pyx_GIVEREF(__pyx_t_10); PyTuple_SET_ITEM(__pyx_t_12, 0, __pyx_t_10); __pyx_t_10 = NULL;
        __Pyx_INCREF(__pyx_v_dl);
        __Pyx_GIVEREF(__pyx_v_dl);
        PyTuple_SET_ITEM(__pyx_t_12, 0+1, __pyx_v_dl);
        __pyx_t_7 = __Pyx_PyObject_Call(__pyx_t_11, __pyx_t_12, NULL); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 35, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_7);
        __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
      }
    }
    __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
    __pyx_t_13 = __Pyx_PyObject_to_MemoryviewSlice_dc_double(__pyx_t_7);
    if (unlikely(!__pyx_t_13.memview)) __PYX_ERR(0, 35, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    __pyx_v_DLc = __pyx_t_13;
    __pyx_t_13.memview = NULL;
    __pyx_t_13.data = NULL;
  }
  __pyx_L3:;
 036:     # Get the extreme indices of the mesh elements that really need to be created within those limits
+037:     abs0 = Cabs(DLc[0]-LMinMax[0])
  __pyx_t_14 = 0;
  __pyx_t_15 = 0;
  __pyx_v_abs0 = fabs(((*((double *) ( /* dim=0 */ ((char *) (((double *) __pyx_v_DLc.data) + __pyx_t_14)) ))) - (*((double *) ( /* dim=0 */ ((char *) (((double *) __pyx_v_LMinMax.data) + __pyx_t_15)) )))));
+038:     if abs0-dLr*Cfloor(abs0/dLr)<margin*dLr:
  __pyx_t_6 = (((__pyx_v_abs0 - (__pyx_v_dLr * floor((__pyx_v_abs0 / __pyx_v_dLr)))) < (__pyx_v_margin * __pyx_v_dLr)) != 0);
  if (__pyx_t_6) {
/* … */
    goto __pyx_L6;
  }
+039:         nL0 = int(Cround((DLc[0]-LMinMax[0])/dLr))
    __pyx_t_16 = 0;
    __pyx_t_17 = 0;
    __pyx_v_nL0 = ((int)round((((*((double *) ( /* dim=0 */ ((char *) (((double *) __pyx_v_DLc.data) + __pyx_t_16)) ))) - (*((double *) ( /* dim=0 */ ((char *) (((double *) __pyx_v_LMinMax.data) + __pyx_t_17)) )))) / __pyx_v_dLr)));
 040:     else:
+041:         nL0 = int(Cfloor((DLc[0]-LMinMax[0])/dLr))
  /*else*/ {
    __pyx_t_18 = 0;
    __pyx_t_19 = 0;
    __pyx_v_nL0 = ((int)floor((((*((double *) ( /* dim=0 */ ((char *) (((double *) __pyx_v_DLc.data) + __pyx_t_18)) ))) - (*((double *) ( /* dim=0 */ ((char *) (((double *) __pyx_v_LMinMax.data) + __pyx_t_19)) )))) / __pyx_v_dLr)));
  }
  __pyx_L6:;
+042:     abs1 = Cabs(DLc[1]-LMinMax[0])
  __pyx_t_20 = 1;
  __pyx_t_21 = 0;
  __pyx_v_abs1 = fabs(((*((double *) ( /* dim=0 */ ((char *) (((double *) __pyx_v_DLc.data) + __pyx_t_20)) ))) - (*((double *) ( /* dim=0 */ ((char *) (((double *) __pyx_v_LMinMax.data) + __pyx_t_21)) )))));
+043:     if abs1-dLr*Cfloor(abs1/dLr)<margin*dLr:
  __pyx_t_6 = (((__pyx_v_abs1 - (__pyx_v_dLr * floor((__pyx_v_abs1 / __pyx_v_dLr)))) < (__pyx_v_margin * __pyx_v_dLr)) != 0);
  if (__pyx_t_6) {
/* … */
    goto __pyx_L7;
  }
+044:         nL1 = int(Cround((DLc[1]-LMinMax[0])/dLr)-1)
    __pyx_t_22 = 1;
    __pyx_t_23 = 0;
    __pyx_v_nL1 = ((int)(round((((*((double *) ( /* dim=0 */ ((char *) (((double *) __pyx_v_DLc.data) + __pyx_t_22)) ))) - (*((double *) ( /* dim=0 */ ((char *) (((double *) __pyx_v_LMinMax.data) + __pyx_t_23)) )))) / __pyx_v_dLr)) - 1.0));
 045:     else:
+046:         nL1 = int(Cfloor((DLc[1]-LMinMax[0])/dLr))
  /*else*/ {
    __pyx_t_24 = 1;
    __pyx_t_25 = 0;
    __pyx_v_nL1 = ((int)floor((((*((double *) ( /* dim=0 */ ((char *) (((double *) __pyx_v_DLc.data) + __pyx_t_24)) ))) - (*((double *) ( /* dim=0 */ ((char *) (((double *) __pyx_v_LMinMax.data) + __pyx_t_25)) )))) / __pyx_v_dLr)));
  }
  __pyx_L7:;
 047:     # Get the corresponding indices
+048:     Nind = nL1+1-nL0
  __pyx_v_Nind = ((__pyx_v_nL1 + 1) - __pyx_v_nL0);
+049:     indL = np.empty((Nind,),dtype=int)#np.linspace(nL0,nL1,Nind,endpoint=True)
  __pyx_t_7 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 49, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  __pyx_t_11 = __Pyx_PyObject_GetAttrStr(__pyx_t_7, __pyx_n_s_empty); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 49, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_11);
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  __pyx_t_7 = __Pyx_PyInt_From_int(__pyx_v_Nind); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 49, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  __pyx_t_12 = PyTuple_New(1); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 49, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_12);
  __Pyx_GIVEREF(__pyx_t_7);
  PyTuple_SET_ITEM(__pyx_t_12, 0, __pyx_t_7);
  __pyx_t_7 = 0;
  __pyx_t_7 = PyTuple_New(1); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 49, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  __Pyx_GIVEREF(__pyx_t_12);
  PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_12);
  __pyx_t_12 = 0;
  __pyx_t_12 = PyDict_New(); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 49, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_12);
  if (PyDict_SetItem(__pyx_t_12, __pyx_n_s_dtype, ((PyObject *)(&PyInt_Type))) < 0) __PYX_ERR(0, 49, __pyx_L1_error)
  __pyx_t_10 = __Pyx_PyObject_Call(__pyx_t_11, __pyx_t_7, __pyx_t_12); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 49, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_10);
  __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
  __pyx_t_26 = __Pyx_PyObject_to_MemoryviewSlice_dc_long(__pyx_t_10);
  if (unlikely(!__pyx_t_26.memview)) __PYX_ERR(0, 49, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
  __pyx_v_indL = __pyx_t_26;
  __pyx_t_26.memview = NULL;
  __pyx_t_26.data = NULL;
+050:     L = np.empty((Nind,))
  __pyx_t_12 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 50, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_12);
  __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_t_12, __pyx_n_s_empty); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 50, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
  __pyx_t_12 = __Pyx_PyInt_From_int(__pyx_v_Nind); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 50, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_12);
  __pyx_t_11 = PyTuple_New(1); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 50, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_11);
  __Pyx_GIVEREF(__pyx_t_12);
  PyTuple_SET_ITEM(__pyx_t_11, 0, __pyx_t_12);
  __pyx_t_12 = 0;
  __pyx_t_12 = NULL;
  if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_7))) {
    __pyx_t_12 = PyMethod_GET_SELF(__pyx_t_7);
    if (likely(__pyx_t_12)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_7);
      __Pyx_INCREF(__pyx_t_12);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_7, function);
    }
  }
  if (!__pyx_t_12) {
    __pyx_t_10 = __Pyx_PyObject_CallOneArg(__pyx_t_7, __pyx_t_11); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 50, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
    __Pyx_GOTREF(__pyx_t_10);
  } else {
    #if CYTHON_FAST_PYCALL
    if (PyFunction_Check(__pyx_t_7)) {
      PyObject *__pyx_temp[2] = {__pyx_t_12, __pyx_t_11};
      __pyx_t_10 = __Pyx_PyFunction_FastCall(__pyx_t_7, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 50, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0;
      __Pyx_GOTREF(__pyx_t_10);
      __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
    } else
    #endif
    #if CYTHON_FAST_PYCCALL
    if (__Pyx_PyFastCFunction_Check(__pyx_t_7)) {
      PyObject *__pyx_temp[2] = {__pyx_t_12, __pyx_t_11};
      __pyx_t_10 = __Pyx_PyCFunction_FastCall(__pyx_t_7, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 50, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0;
      __Pyx_GOTREF(__pyx_t_10);
      __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
    } else
    #endif
    {
      __pyx_t_27 = PyTuple_New(1+1); if (unlikely(!__pyx_t_27)) __PYX_ERR(0, 50, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_27);
      __Pyx_GIVEREF(__pyx_t_12); PyTuple_SET_ITEM(__pyx_t_27, 0, __pyx_t_12); __pyx_t_12 = NULL;
      __Pyx_GIVEREF(__pyx_t_11);
      PyTuple_SET_ITEM(__pyx_t_27, 0+1, __pyx_t_11);
      __pyx_t_11 = 0;
      __pyx_t_10 = __Pyx_PyObject_Call(__pyx_t_7, __pyx_t_27, NULL); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 50, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_10);
      __Pyx_DECREF(__pyx_t_27); __pyx_t_27 = 0;
    }
  }
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  __pyx_t_13 = __Pyx_PyObject_to_MemoryviewSlice_dc_double(__pyx_t_10);
  if (unlikely(!__pyx_t_13.memview)) __PYX_ERR(0, 50, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
  __pyx_v_L = __pyx_t_13;
  __pyx_t_13.memview = NULL;
  __pyx_t_13.data = NULL;
+051:     for ii in range(0,Nind):
  __pyx_t_28 = __pyx_v_Nind;
  for (__pyx_t_29 = 0; __pyx_t_29 < __pyx_t_28; __pyx_t_29+=1) {
    __pyx_v_ii = __pyx_t_29;
+052:         jj = nL0+ii
    __pyx_v_jj = (__pyx_v_nL0 + __pyx_v_ii);
+053:         indL[ii] = jj
    __pyx_t_30 = __pyx_v_ii;
    *((long *) ( /* dim=0 */ ((char *) (((long *) __pyx_v_indL.data) + __pyx_t_30)) )) = __pyx_v_jj;
+054:         L[ii] = LMinMax[0] + (0.5 + (<double>jj))*dLr
    __pyx_t_31 = 0;
    __pyx_t_32 = __pyx_v_ii;
    *((double *) ( /* dim=0 */ ((char *) (((double *) __pyx_v_L.data) + __pyx_t_32)) )) = ((*((double *) ( /* dim=0 */ ((char *) (((double *) __pyx_v_LMinMax.data) + __pyx_t_31)) ))) + ((0.5 + ((double)__pyx_v_jj)) * __pyx_v_dLr));
  }
+055:     return np.asarray(L), dLr, np.asarray(indL), N
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_7 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 55, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  __pyx_t_27 = __Pyx_PyObject_GetAttrStr(__pyx_t_7, __pyx_n_s_asarray); if (unlikely(!__pyx_t_27)) __PYX_ERR(0, 55, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_27);
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  __pyx_t_7 = __pyx_memoryview_fromslice(__pyx_v_L, 1, (PyObject *(*)(char *)) __pyx_memview_get_double, (int (*)(char *, PyObject *)) __pyx_memview_set_double, 0);; if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 55, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  __pyx_t_11 = NULL;
  if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_27))) {
    __pyx_t_11 = PyMethod_GET_SELF(__pyx_t_27);
    if (likely(__pyx_t_11)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_27);
      __Pyx_INCREF(__pyx_t_11);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_27, function);
    }
  }
  if (!__pyx_t_11) {
    __pyx_t_10 = __Pyx_PyObject_CallOneArg(__pyx_t_27, __pyx_t_7); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 55, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    __Pyx_GOTREF(__pyx_t_10);
  } else {
    #if CYTHON_FAST_PYCALL
    if (PyFunction_Check(__pyx_t_27)) {
      PyObject *__pyx_temp[2] = {__pyx_t_11, __pyx_t_7};
      __pyx_t_10 = __Pyx_PyFunction_FastCall(__pyx_t_27, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 55, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0;
      __Pyx_GOTREF(__pyx_t_10);
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    } else
    #endif
    #if CYTHON_FAST_PYCCALL
    if (__Pyx_PyFastCFunction_Check(__pyx_t_27)) {
      PyObject *__pyx_temp[2] = {__pyx_t_11, __pyx_t_7};
      __pyx_t_10 = __Pyx_PyCFunction_FastCall(__pyx_t_27, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 55, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0;
      __Pyx_GOTREF(__pyx_t_10);
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    } else
    #endif
    {
      __pyx_t_12 = PyTuple_New(1+1); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 55, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_12);
      __Pyx_GIVEREF(__pyx_t_11); PyTuple_SET_ITEM(__pyx_t_12, 0, __pyx_t_11); __pyx_t_11 = NULL;
      __Pyx_GIVEREF(__pyx_t_7);
      PyTuple_SET_ITEM(__pyx_t_12, 0+1, __pyx_t_7);
      __pyx_t_7 = 0;
      __pyx_t_10 = __Pyx_PyObject_Call(__pyx_t_27, __pyx_t_12, NULL); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 55, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_10);
      __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
    }
  }
  __Pyx_DECREF(__pyx_t_27); __pyx_t_27 = 0;
  __pyx_t_27 = PyFloat_FromDouble(__pyx_v_dLr); if (unlikely(!__pyx_t_27)) __PYX_ERR(0, 55, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_27);
  __pyx_t_7 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 55, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  __pyx_t_11 = __Pyx_PyObject_GetAttrStr(__pyx_t_7, __pyx_n_s_asarray); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 55, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_11);
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  __pyx_t_7 = __pyx_memoryview_fromslice(__pyx_v_indL, 1, (PyObject *(*)(char *)) __pyx_memview_get_long, (int (*)(char *, PyObject *)) __pyx_memview_set_long, 0);; if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 55, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  __pyx_t_33 = NULL;
  if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_11))) {
    __pyx_t_33 = PyMethod_GET_SELF(__pyx_t_11);
    if (likely(__pyx_t_33)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_11);
      __Pyx_INCREF(__pyx_t_33);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_11, function);
    }
  }
  if (!__pyx_t_33) {
    __pyx_t_12 = __Pyx_PyObject_CallOneArg(__pyx_t_11, __pyx_t_7); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 55, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    __Pyx_GOTREF(__pyx_t_12);
  } else {
    #if CYTHON_FAST_PYCALL
    if (PyFunction_Check(__pyx_t_11)) {
      PyObject *__pyx_temp[2] = {__pyx_t_33, __pyx_t_7};
      __pyx_t_12 = __Pyx_PyFunction_FastCall(__pyx_t_11, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 55, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_33); __pyx_t_33 = 0;
      __Pyx_GOTREF(__pyx_t_12);
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    } else
    #endif
    #if CYTHON_FAST_PYCCALL
    if (__Pyx_PyFastCFunction_Check(__pyx_t_11)) {
      PyObject *__pyx_temp[2] = {__pyx_t_33, __pyx_t_7};
      __pyx_t_12 = __Pyx_PyCFunction_FastCall(__pyx_t_11, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 55, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_33); __pyx_t_33 = 0;
      __Pyx_GOTREF(__pyx_t_12);
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    } else
    #endif
    {
      __pyx_t_34 = PyTuple_New(1+1); if (unlikely(!__pyx_t_34)) __PYX_ERR(0, 55, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_34);
      __Pyx_GIVEREF(__pyx_t_33); PyTuple_SET_ITEM(__pyx_t_34, 0, __pyx_t_33); __pyx_t_33 = NULL;
      __Pyx_GIVEREF(__pyx_t_7);
      PyTuple_SET_ITEM(__pyx_t_34, 0+1, __pyx_t_7);
      __pyx_t_7 = 0;
      __pyx_t_12 = __Pyx_PyObject_Call(__pyx_t_11, __pyx_t_34, NULL); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 55, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_12);
      __Pyx_DECREF(__pyx_t_34); __pyx_t_34 = 0;
    }
  }
  __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
  __pyx_t_11 = PyFloat_FromDouble(__pyx_v_N); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 55, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_11);
  __pyx_t_34 = PyTuple_New(4); if (unlikely(!__pyx_t_34)) __PYX_ERR(0, 55, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_34);
  __Pyx_GIVEREF(__pyx_t_10);
  PyTuple_SET_ITEM(__pyx_t_34, 0, __pyx_t_10);
  __Pyx_GIVEREF(__pyx_t_27);
  PyTuple_SET_ITEM(__pyx_t_34, 1, __pyx_t_27);
  __Pyx_GIVEREF(__pyx_t_12);
  PyTuple_SET_ITEM(__pyx_t_34, 2, __pyx_t_12);
  __Pyx_GIVEREF(__pyx_t_11);
  PyTuple_SET_ITEM(__pyx_t_34, 3, __pyx_t_11);
  __pyx_t_10 = 0;
  __pyx_t_27 = 0;
  __pyx_t_12 = 0;
  __pyx_t_11 = 0;
  __pyx_r = __pyx_t_34;
  __pyx_t_34 = 0;
  goto __pyx_L0;
 056: 
 057: 
 058: @cython.cdivision(True)
 059: @cython.wraparound(False)
 060: @cython.boundscheck(False)
+061: def _Ves_mesh_CrossPoly(double[:,::1] VPoly, double dL, D1=None, D2=None, double margin=1.e-9, double DIn=0., VIn=None):
/* Python wrapper */
static PyObject *__pyx_pw_46_cython_magic_8152fc40fb05daa7217c00b66474f995_3_Ves_mesh_CrossPoly(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyMethodDef __pyx_mdef_46_cython_magic_8152fc40fb05daa7217c00b66474f995_3_Ves_mesh_CrossPoly = {"_Ves_mesh_CrossPoly", (PyCFunction)__pyx_pw_46_cython_magic_8152fc40fb05daa7217c00b66474f995_3_Ves_mesh_CrossPoly, METH_VARARGS|METH_KEYWORDS, 0};
static PyObject *__pyx_pw_46_cython_magic_8152fc40fb05daa7217c00b66474f995_3_Ves_mesh_CrossPoly(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  __Pyx_memviewslice __pyx_v_VPoly = { 0, 0, { 0 }, { 0 }, { 0 } };
  double __pyx_v_dL;
  PyObject *__pyx_v_D1 = 0;
  PyObject *__pyx_v_D2 = 0;
  double __pyx_v_margin;
  double __pyx_v_DIn;
  PyObject *__pyx_v_VIn = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("_Ves_mesh_CrossPoly (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_VPoly,&__pyx_n_s_dL,&__pyx_n_s_D1,&__pyx_n_s_D2,&__pyx_n_s_margin,&__pyx_n_s_DIn,&__pyx_n_s_VIn,0};
    PyObject* values[7] = {0,0,0,0,0,0,0};
    values[2] = ((PyObject *)Py_None);
    values[3] = ((PyObject *)Py_None);
    values[6] = ((PyObject *)Py_None);
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  7: values[6] = PyTuple_GET_ITEM(__pyx_args, 6);
        case  6: values[5] = PyTuple_GET_ITEM(__pyx_args, 5);
        case  5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_VPoly)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        case  1:
        if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_dL)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_Ves_mesh_CrossPoly", 0, 2, 7, 1); __PYX_ERR(0, 61, __pyx_L3_error)
        }
        case  2:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_D1);
          if (value) { values[2] = value; kw_args--; }
        }
        case  3:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_D2);
          if (value) { values[3] = value; kw_args--; }
        }
        case  4:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_margin);
          if (value) { values[4] = value; kw_args--; }
        }
        case  5:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_DIn);
          if (value) { values[5] = value; kw_args--; }
        }
        case  6:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_VIn);
          if (value) { values[6] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "_Ves_mesh_CrossPoly") < 0)) __PYX_ERR(0, 61, __pyx_L3_error)
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  7: values[6] = PyTuple_GET_ITEM(__pyx_args, 6);
        case  6: values[5] = PyTuple_GET_ITEM(__pyx_args, 5);
        case  5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    __pyx_v_VPoly = __Pyx_PyObject_to_MemoryviewSlice_d_dc_double(values[0]); if (unlikely(!__pyx_v_VPoly.memview)) __PYX_ERR(0, 61, __pyx_L3_error)
    __pyx_v_dL = __pyx_PyFloat_AsDouble(values[1]); if (unlikely((__pyx_v_dL == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 61, __pyx_L3_error)
    __pyx_v_D1 = values[2];
    __pyx_v_D2 = values[3];
    if (values[4]) {
      __pyx_v_margin = __pyx_PyFloat_AsDouble(values[4]); if (unlikely((__pyx_v_margin == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 61, __pyx_L3_error)
    } else {
      __pyx_v_margin = ((double)1.e-9);
    }
    if (values[5]) {
      __pyx_v_DIn = __pyx_PyFloat_AsDouble(values[5]); if (unlikely((__pyx_v_DIn == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 61, __pyx_L3_error)
    } else {
      __pyx_v_DIn = ((double)0.);
    }
    __pyx_v_VIn = values[6];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("_Ves_mesh_CrossPoly", 0, 2, 7, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 61, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("_cython_magic_8152fc40fb05daa7217c00b66474f995._Ves_mesh_CrossPoly", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_46_cython_magic_8152fc40fb05daa7217c00b66474f995_2_Ves_mesh_CrossPoly(__pyx_self, __pyx_v_VPoly, __pyx_v_dL, __pyx_v_D1, __pyx_v_D2, __pyx_v_margin, __pyx_v_DIn, __pyx_v_VIn);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_46_cython_magic_8152fc40fb05daa7217c00b66474f995_2_Ves_mesh_CrossPoly(CYTHON_UNUSED PyObject *__pyx_self, __Pyx_memviewslice __pyx_v_VPoly, double __pyx_v_dL, PyObject *__pyx_v_D1, PyObject *__pyx_v_D2, double __pyx_v_margin, double __pyx_v_DIn, PyObject *__pyx_v_VIn) {
  int __pyx_v_ii;
  int __pyx_v_jj;
  int __pyx_v_nn;
  int __pyx_v_NP;
  __Pyx_memviewslice __pyx_v_LMinMax = { 0, 0, { 0 }, { 0 }, { 0 } };
  __Pyx_memviewslice __pyx_v_L = { 0, 0, { 0 }, { 0 }, { 0 } };
  double __pyx_v_v0;
  double __pyx_v_v1;
  double __pyx_v_dlr;
  CYTHON_UNUSED __Pyx_memviewslice __pyx_v_indL = { 0, 0, { 0 }, { 0 }, { 0 } };
  PyArrayObject *__pyx_v_N = 0;
  PyArrayObject *__pyx_v_ind = 0;
  PyArrayObject *__pyx_v_dLr = 0;
  PyArrayObject *__pyx_v_Rref = 0;
  PyArrayObject *__pyx_v_PtsCross = 0;
  PyObject *__pyx_v_LPtsCross = 0;
  PyObject *__pyx_v_LdLr = 0;
  PyObject *__pyx_v_Lind = 0;
  PyObject *__pyx_v_LRref = 0;
  PyObject *__pyx_v_VPolybis = 0;
  PyObject *__pyx_v_indin = NULL;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_N;
  __Pyx_Buffer __pyx_pybuffer_N;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_PtsCross;
  __Pyx_Buffer __pyx_pybuffer_PtsCross;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_Rref;
  __Pyx_Buffer __pyx_pybuffer_Rref;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_dLr;
  __Pyx_Buffer __pyx_pybuffer_dLr;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_ind;
  __Pyx_Buffer __pyx_pybuffer_ind;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("_Ves_mesh_CrossPoly", 0);
  __pyx_pybuffer_N.pybuffer.buf = NULL;
  __pyx_pybuffer_N.refcount = 0;
  __pyx_pybuffernd_N.data = NULL;
  __pyx_pybuffernd_N.rcbuffer = &__pyx_pybuffer_N;
  __pyx_pybuffer_ind.pybuffer.buf = NULL;
  __pyx_pybuffer_ind.refcount = 0;
  __pyx_pybuffernd_ind.data = NULL;
  __pyx_pybuffernd_ind.rcbuffer = &__pyx_pybuffer_ind;
  __pyx_pybuffer_dLr.pybuffer.buf = NULL;
  __pyx_pybuffer_dLr.refcount = 0;
  __pyx_pybuffernd_dLr.data = NULL;
  __pyx_pybuffernd_dLr.rcbuffer = &__pyx_pybuffer_dLr;
  __pyx_pybuffer_Rref.pybuffer.buf = NULL;
  __pyx_pybuffer_Rref.refcount = 0;
  __pyx_pybuffernd_Rref.data = NULL;
  __pyx_pybuffernd_Rref.rcbuffer = &__pyx_pybuffer_Rref;
  __pyx_pybuffer_PtsCross.pybuffer.buf = NULL;
  __pyx_pybuffer_PtsCross.refcount = 0;
  __pyx_pybuffernd_PtsCross.data = NULL;
  __pyx_pybuffernd_PtsCross.rcbuffer = &__pyx_pybuffer_PtsCross;
/* … */
  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __PYX_XDEC_MEMVIEW(&__pyx_t_5, 1);
  __Pyx_XDECREF(__pyx_t_24);
  __Pyx_XDECREF(__pyx_t_25);
  __PYX_XDEC_MEMVIEW(&__pyx_t_27, 1);
  __Pyx_XDECREF(__pyx_t_90);
  { PyObject *__pyx_type, *__pyx_value, *__pyx_tb;
    __Pyx_PyThreadState_declare
    __Pyx_PyThreadState_assign
    __Pyx_ErrFetch(&__pyx_type, &__pyx_value, &__pyx_tb);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_N.rcbuffer->pybuffer);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_PtsCross.rcbuffer->pybuffer);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_Rref.rcbuffer->pybuffer);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_dLr.rcbuffer->pybuffer);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_ind.rcbuffer->pybuffer);
  __Pyx_ErrRestore(__pyx_type, __pyx_value, __pyx_tb);}
  __Pyx_AddTraceback("_cython_magic_8152fc40fb05daa7217c00b66474f995._Ves_mesh_CrossPoly", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  goto __pyx_L2;
  __pyx_L0:;
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_N.rcbuffer->pybuffer);
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_PtsCross.rcbuffer->pybuffer);
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_Rref.rcbuffer->pybuffer);
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_dLr.rcbuffer->pybuffer);
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_ind.rcbuffer->pybuffer);
  __pyx_L2:;
  __PYX_XDEC_MEMVIEW(&__pyx_v_LMinMax, 1);
  __PYX_XDEC_MEMVIEW(&__pyx_v_L, 1);
  __PYX_XDEC_MEMVIEW(&__pyx_v_indL, 1);
  __Pyx_XDECREF((PyObject *)__pyx_v_N);
  __Pyx_XDECREF((PyObject *)__pyx_v_ind);
  __Pyx_XDECREF((PyObject *)__pyx_v_dLr);
  __Pyx_XDECREF((PyObject *)__pyx_v_Rref);
  __Pyx_XDECREF((PyObject *)__pyx_v_PtsCross);
  __Pyx_XDECREF(__pyx_v_LPtsCross);
  __Pyx_XDECREF(__pyx_v_LdLr);
  __Pyx_XDECREF(__pyx_v_Lind);
  __Pyx_XDECREF(__pyx_v_LRref);
  __Pyx_XDECREF(__pyx_v_VPolybis);
  __Pyx_XDECREF(__pyx_v_indin);
  __PYX_XDEC_MEMVIEW(&__pyx_v_VPoly, 1);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}
/* … */
  __pyx_tuple__107 = PyTuple_Pack(28, __pyx_n_s_VPoly, __pyx_n_s_dL, __pyx_n_s_D1, __pyx_n_s_D2, __pyx_n_s_margin, __pyx_n_s_DIn, __pyx_n_s_VIn, __pyx_n_s_ii, __pyx_n_s_jj, __pyx_n_s_nn, __pyx_n_s_NP, __pyx_n_s_LMinMax, __pyx_n_s_L, __pyx_n_s_v0, __pyx_n_s_v1, __pyx_n_s_dlr, __pyx_n_s_indL, __pyx_n_s_N, __pyx_n_s_ind, __pyx_n_s_dLr, __pyx_n_s_Rref, __pyx_n_s_PtsCross, __pyx_n_s_LPtsCross, __pyx_n_s_LdLr, __pyx_n_s_Lind, __pyx_n_s_LRref, __pyx_n_s_VPolybis, __pyx_n_s_indin); if (unlikely(!__pyx_tuple__107)) __PYX_ERR(0, 61, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__107);
  __Pyx_GIVEREF(__pyx_tuple__107);
/* … */
  __pyx_t_2 = PyCFunction_NewEx(&__pyx_mdef_46_cython_magic_8152fc40fb05daa7217c00b66474f995_3_Ves_mesh_CrossPoly, NULL, __pyx_n_s_cython_magic_8152fc40fb05daa721); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 61, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_Ves_mesh_CrossPoly, __pyx_t_2) < 0) __PYX_ERR(0, 61, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_codeobj__108 = (PyObject*)__Pyx_PyCode_New(7, 0, 28, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__107, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_Home_DV226270_cache_ipython_cyt, __pyx_n_s_Ves_mesh_CrossPoly, 61, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__108)) __PYX_ERR(0, 61, __pyx_L1_error)
+062:     cdef int ii, jj, nn=0, NP=VPoly.shape[1]
  __pyx_v_nn = 0;
  __pyx_v_NP = (__pyx_v_VPoly.shape[1]);
 063:     cdef double[::1] LMinMax, L
 064:     cdef double v0, v1, dlr
 065:     cdef long[::1] indL
 066:     cdef cnp.ndarray[long,ndim=1] N, ind
 067:     cdef cnp.ndarray[double,ndim=1] dLr, Rref
 068:     cdef cnp.ndarray[double,ndim=2] PtsCross
+069:     cdef list LPtsCross=[], LdLr=[], Lind=[], LRref=[], VPolybis=[]
  __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 69, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_LPtsCross = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;
  __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 69, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_LdLr = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;
  __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 69, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_Lind = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;
  __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 69, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_LRref = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;
  __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 69, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_VPolybis = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;
 070: 
+071:     LMinMax = np.array([0.,1.],dtype=float)
  __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 71, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_array); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 71, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = PyList_New(2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 71, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_INCREF(__pyx_float_0_);
  __Pyx_GIVEREF(__pyx_float_0_);
  PyList_SET_ITEM(__pyx_t_1, 0, __pyx_float_0_);
  __Pyx_INCREF(__pyx_float_1_);
  __Pyx_GIVEREF(__pyx_float_1_);
  PyList_SET_ITEM(__pyx_t_1, 1, __pyx_float_1_);
  __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 71, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_GIVEREF(__pyx_t_1);
  PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_1);
  __pyx_t_1 = 0;
  __pyx_t_1 = PyDict_New(); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 71, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_dtype, ((PyObject *)(&PyFloat_Type))) < 0) __PYX_ERR(0, 71, __pyx_L1_error)
  __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_3, __pyx_t_1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 71, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_5 = __Pyx_PyObject_to_MemoryviewSlice_dc_double(__pyx_t_4);
  if (unlikely(!__pyx_t_5.memview)) __PYX_ERR(0, 71, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_v_LMinMax = __pyx_t_5;
  __pyx_t_5.memview = NULL;
  __pyx_t_5.data = NULL;
+072:     N = np.empty((NP-1,),dtype=int)
  __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 72, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_empty); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 72, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_4 = __Pyx_PyInt_From_long((__pyx_v_NP - 1)); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 72, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 72, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_GIVEREF(__pyx_t_4);
  PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_4);
  __pyx_t_4 = 0;
  __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 72, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_GIVEREF(__pyx_t_3);
  PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_3);
  __pyx_t_3 = 0;
  __pyx_t_3 = PyDict_New(); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 72, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_dtype, ((PyObject *)(&PyInt_Type))) < 0) __PYX_ERR(0, 72, __pyx_L1_error)
  __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_4, __pyx_t_3); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 72, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  if (!(likely(((__pyx_t_2) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_2, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 72, __pyx_L1_error)
  __pyx_t_6 = ((PyArrayObject *)__pyx_t_2);
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_N.rcbuffer->pybuffer);
    __pyx_t_7 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_N.rcbuffer->pybuffer, (PyObject*)__pyx_t_6, &__Pyx_TypeInfo_long, PyBUF_FORMAT| PyBUF_STRIDES| PyBUF_WRITABLE, 1, 0, __pyx_stack);
    if (unlikely(__pyx_t_7 < 0)) {
      PyErr_Fetch(&__pyx_t_8, &__pyx_t_9, &__pyx_t_10);
      if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_N.rcbuffer->pybuffer, (PyObject*)__pyx_v_N, &__Pyx_TypeInfo_long, PyBUF_FORMAT| PyBUF_STRIDES| PyBUF_WRITABLE, 1, 0, __pyx_stack) == -1)) {
        Py_XDECREF(__pyx_t_8); Py_XDECREF(__pyx_t_9); Py_XDECREF(__pyx_t_10);
        __Pyx_RaiseBufferFallbackError();
      } else {
        PyErr_Restore(__pyx_t_8, __pyx_t_9, __pyx_t_10);
      }
    }
    __pyx_pybuffernd_N.diminfo[0].strides = __pyx_pybuffernd_N.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_N.diminfo[0].shape = __pyx_pybuffernd_N.rcbuffer->pybuffer.shape[0];
    if (unlikely(__pyx_t_7 < 0)) __PYX_ERR(0, 72, __pyx_L1_error)
  }
  __pyx_t_6 = 0;
  __pyx_v_N = ((PyArrayObject *)__pyx_t_2);
  __pyx_t_2 = 0;
+073:     if DIn==0.:
  __pyx_t_11 = ((__pyx_v_DIn == 0.) != 0);
  if (__pyx_t_11) {
/* … */
    goto __pyx_L3;
  }
+074:         for ii in range(0,NP-1):
    __pyx_t_12 = (__pyx_v_NP - 1);
    for (__pyx_t_7 = 0; __pyx_t_7 < __pyx_t_12; __pyx_t_7+=1) {
      __pyx_v_ii = __pyx_t_7;
+075:             v0, v1 = VPoly[0,ii+1]-VPoly[0,ii], VPoly[1,ii+1]-VPoly[1,ii]
      __pyx_t_13 = 0;
      __pyx_t_14 = (__pyx_v_ii + 1);
      __pyx_t_15 = 0;
      __pyx_t_16 = __pyx_v_ii;
      __pyx_t_17 = ((*((double *) ( /* dim=1 */ ((char *) (((double *) ( /* dim=0 */ (__pyx_v_VPoly.data + __pyx_t_13 * __pyx_v_VPoly.strides[0]) )) + __pyx_t_14)) ))) - (*((double *) ( /* dim=1 */ ((char *) (((double *) ( /* dim=0 */ (__pyx_v_VPoly.data + __pyx_t_15 * __pyx_v_VPoly.strides[0]) )) + __pyx_t_16)) ))));
      __pyx_t_18 = 1;
      __pyx_t_19 = (__pyx_v_ii + 1);
      __pyx_t_20 = 1;
      __pyx_t_21 = __pyx_v_ii;
      __pyx_t_22 = ((*((double *) ( /* dim=1 */ ((char *) (((double *) ( /* dim=0 */ (__pyx_v_VPoly.data + __pyx_t_18 * __pyx_v_VPoly.strides[0]) )) + __pyx_t_19)) ))) - (*((double *) ( /* dim=1 */ ((char *) (((double *) ( /* dim=0 */ (__pyx_v_VPoly.data + __pyx_t_20 * __pyx_v_VPoly.strides[0]) )) + __pyx_t_21)) ))));
      __pyx_v_v0 = __pyx_t_17;
      __pyx_v_v1 = __pyx_t_22;
+076:             LMinMax[1] = Csqrt(v0**2 + v1**2)
      __pyx_t_23 = 1;
      *((double *) ( /* dim=0 */ ((char *) (((double *) __pyx_v_LMinMax.data) + __pyx_t_23)) )) = sqrt((pow(__pyx_v_v0, 2.0) + pow(__pyx_v_v1, 2.0)));
+077:             L, dlr, indL, N[ii] = _Ves_mesh_dlfromL_cython(LMinMax, dL, DL=None, margin=margin)
      __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_Ves_mesh_dlfromL_cython); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 77, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_t_3 = __pyx_memoryview_fromslice(__pyx_v_LMinMax, 1, (PyObject *(*)(char *)) __pyx_memview_get_double, (int (*)(char *, PyObject *)) __pyx_memview_set_double, 0);; if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 77, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_4 = PyFloat_FromDouble(__pyx_v_dL); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 77, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 77, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_GIVEREF(__pyx_t_3);
      PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_3);
      __Pyx_GIVEREF(__pyx_t_4);
      PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_t_4);
      __pyx_t_3 = 0;
      __pyx_t_4 = 0;
      __pyx_t_4 = PyDict_New(); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 77, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      if (PyDict_SetItem(__pyx_t_4, __pyx_n_s_DL, Py_None) < 0) __PYX_ERR(0, 77, __pyx_L1_error)
      __pyx_t_3 = PyFloat_FromDouble(__pyx_v_margin); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 77, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      if (PyDict_SetItem(__pyx_t_4, __pyx_n_s_margin, __pyx_t_3) < 0) __PYX_ERR(0, 77, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_1, __pyx_t_4); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 77, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      if ((likely(PyTuple_CheckExact(__pyx_t_3))) || (PyList_CheckExact(__pyx_t_3))) {
        PyObject* sequence = __pyx_t_3;
        #if !CYTHON_COMPILING_IN_PYPY
        Py_ssize_t size = Py_SIZE(sequence);
        #else
        Py_ssize_t size = PySequence_Size(sequence);
        #endif
        if (unlikely(size != 4)) {
          if (size > 4) __Pyx_RaiseTooManyValuesError(4);
          else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
          __PYX_ERR(0, 77, __pyx_L1_error)
        }
        #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
        if (likely(PyTuple_CheckExact(sequence))) {
          __pyx_t_4 = PyTuple_GET_ITEM(sequence, 0); 
          __pyx_t_1 = PyTuple_GET_ITEM(sequence, 1); 
          __pyx_t_2 = PyTuple_GET_ITEM(sequence, 2); 
          __pyx_t_24 = PyTuple_GET_ITEM(sequence, 3); 
        } else {
          __pyx_t_4 = PyList_GET_ITEM(sequence, 0); 
          __pyx_t_1 = PyList_GET_ITEM(sequence, 1); 
          __pyx_t_2 = PyList_GET_ITEM(sequence, 2); 
          __pyx_t_24 = PyList_GET_ITEM(sequence, 3); 
        }
        __Pyx_INCREF(__pyx_t_4);
        __Pyx_INCREF(__pyx_t_1);
        __Pyx_INCREF(__pyx_t_2);
        __Pyx_INCREF(__pyx_t_24);
        #else
        {
          Py_ssize_t i;
          PyObject** temps[4] = {&__pyx_t_4,&__pyx_t_1,&__pyx_t_2,&__pyx_t_24};
          for (i=0; i < 4; i++) {
            PyObject* item = PySequence_ITEM(sequence, i); if (unlikely(!item)) __PYX_ERR(0, 77, __pyx_L1_error)
            __Pyx_GOTREF(item);
            *(temps[i]) = item;
          }
        }
        #endif
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      } else {
        Py_ssize_t index = -1;
        PyObject** temps[4] = {&__pyx_t_4,&__pyx_t_1,&__pyx_t_2,&__pyx_t_24};
        __pyx_t_25 = PyObject_GetIter(__pyx_t_3); if (unlikely(!__pyx_t_25)) __PYX_ERR(0, 77, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_25);
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        __pyx_t_26 = Py_TYPE(__pyx_t_25)->tp_iternext;
        for (index=0; index < 4; index++) {
          PyObject* item = __pyx_t_26(__pyx_t_25); if (unlikely(!item)) goto __pyx_L6_unpacking_failed;
          __Pyx_GOTREF(item);
          *(temps[index]) = item;
        }
        if (__Pyx_IternextUnpackEndCheck(__pyx_t_26(__pyx_t_25), 4) < 0) __PYX_ERR(0, 77, __pyx_L1_error)
        __pyx_t_26 = NULL;
        __Pyx_DECREF(__pyx_t_25); __pyx_t_25 = 0;
        goto __pyx_L7_unpacking_done;
        __pyx_L6_unpacking_failed:;
        __Pyx_DECREF(__pyx_t_25); __pyx_t_25 = 0;
        __pyx_t_26 = NULL;
        if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
        __PYX_ERR(0, 77, __pyx_L1_error)
        __pyx_L7_unpacking_done:;
      }
      __pyx_t_5 = __Pyx_PyObject_to_MemoryviewSlice_dc_double(__pyx_t_4);
      if (unlikely(!__pyx_t_5.memview)) __PYX_ERR(0, 77, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __pyx_t_22 = __pyx_PyFloat_AsDouble(__pyx_t_1); if (unlikely((__pyx_t_22 == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 77, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __pyx_t_27 = __Pyx_PyObject_to_MemoryviewSlice_dc_long(__pyx_t_2);
      if (unlikely(!__pyx_t_27.memview)) __PYX_ERR(0, 77, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __pyx_t_28 = __Pyx_PyInt_As_long(__pyx_t_24); if (unlikely((__pyx_t_28 == (long)-1) && PyErr_Occurred())) __PYX_ERR(0, 77, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_24); __pyx_t_24 = 0;
      __PYX_XDEC_MEMVIEW(&__pyx_v_L, 1);
      __pyx_v_L = __pyx_t_5;
      __pyx_t_5.memview = NULL;
      __pyx_t_5.data = NULL;
      __pyx_v_dlr = __pyx_t_22;
      __PYX_XDEC_MEMVIEW(&__pyx_v_indL, 1);
      __pyx_v_indL = __pyx_t_27;
      __pyx_t_27.memview = NULL;
      __pyx_t_27.data = NULL;
      __pyx_t_29 = __pyx_v_ii;
      *__Pyx_BufPtrStrided1d(long *, __pyx_pybuffernd_N.rcbuffer->pybuffer.buf, __pyx_t_29, __pyx_pybuffernd_N.diminfo[0].strides) = __pyx_t_28;
+078:             VPolybis.append((VPoly[0,ii],VPoly[1,ii]))
      __pyx_t_30 = 0;
      __pyx_t_31 = __pyx_v_ii;
      __pyx_t_3 = PyFloat_FromDouble((*((double *) ( /* dim=1 */ ((char *) (((double *) ( /* dim=0 */ (__pyx_v_VPoly.data + __pyx_t_30 * __pyx_v_VPoly.strides[0]) )) + __pyx_t_31)) )))); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 78, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_32 = 1;
      __pyx_t_33 = __pyx_v_ii;
      __pyx_t_24 = PyFloat_FromDouble((*((double *) ( /* dim=1 */ ((char *) (((double *) ( /* dim=0 */ (__pyx_v_VPoly.data + __pyx_t_32 * __pyx_v_VPoly.strides[0]) )) + __pyx_t_33)) )))); if (unlikely(!__pyx_t_24)) __PYX_ERR(0, 78, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_24);
      __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 78, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_GIVEREF(__pyx_t_3);
      PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_3);
      __Pyx_GIVEREF(__pyx_t_24);
      PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_t_24);
      __pyx_t_3 = 0;
      __pyx_t_24 = 0;
      __pyx_t_34 = __Pyx_PyList_Append(__pyx_v_VPolybis, __pyx_t_2); if (unlikely(__pyx_t_34 == -1)) __PYX_ERR(0, 78, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+079:             v0, v1 = v0/LMinMax[1], v1/LMinMax[1]
      __pyx_t_35 = 1;
      __pyx_t_22 = (__pyx_v_v0 / (*((double *) ( /* dim=0 */ ((char *) (((double *) __pyx_v_LMinMax.data) + __pyx_t_35)) ))));
      __pyx_t_36 = 1;
      __pyx_t_17 = (__pyx_v_v1 / (*((double *) ( /* dim=0 */ ((char *) (((double *) __pyx_v_LMinMax.data) + __pyx_t_36)) ))));
      __pyx_v_v0 = __pyx_t_22;
      __pyx_v_v1 = __pyx_t_17;
+080:             for jj in range(0,N[ii]):
      __pyx_t_37 = __pyx_v_ii;
      __pyx_t_28 = (*__Pyx_BufPtrStrided1d(long *, __pyx_pybuffernd_N.rcbuffer->pybuffer.buf, __pyx_t_37, __pyx_pybuffernd_N.diminfo[0].strides));
      for (__pyx_t_38 = 0; __pyx_t_38 < __pyx_t_28; __pyx_t_38+=1) {
        __pyx_v_jj = __pyx_t_38;
+081:                 LdLr.append(dlr)
        __pyx_t_2 = PyFloat_FromDouble(__pyx_v_dlr); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 81, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_2);
        __pyx_t_34 = __Pyx_PyList_Append(__pyx_v_LdLr, __pyx_t_2); if (unlikely(__pyx_t_34 == -1)) __PYX_ERR(0, 81, __pyx_L1_error)
        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+082:                 LRref.append(VPoly[0,ii] + L[jj]*v0)
        __pyx_t_39 = 0;
        __pyx_t_40 = __pyx_v_ii;
        __pyx_t_41 = __pyx_v_jj;
        __pyx_t_2 = PyFloat_FromDouble(((*((double *) ( /* dim=1 */ ((char *) (((double *) ( /* dim=0 */ (__pyx_v_VPoly.data + __pyx_t_39 * __pyx_v_VPoly.strides[0]) )) + __pyx_t_40)) ))) + ((*((double *) ( /* dim=0 */ ((char *) (((double *) __pyx_v_L.data) + __pyx_t_41)) ))) * __pyx_v_v0))); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 82, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_2);
        __pyx_t_34 = __Pyx_PyList_Append(__pyx_v_LRref, __pyx_t_2); if (unlikely(__pyx_t_34 == -1)) __PYX_ERR(0, 82, __pyx_L1_error)
        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+083:                 LPtsCross.append((VPoly[0,ii] + L[jj]*v0, VPoly[1,ii] + L[jj]*v1))
        __pyx_t_42 = 0;
        __pyx_t_43 = __pyx_v_ii;
        __pyx_t_44 = __pyx_v_jj;
        __pyx_t_2 = PyFloat_FromDouble(((*((double *) ( /* dim=1 */ ((char *) (((double *) ( /* dim=0 */ (__pyx_v_VPoly.data + __pyx_t_42 * __pyx_v_VPoly.strides[0]) )) + __pyx_t_43)) ))) + ((*((double *) ( /* dim=0 */ ((char *) (((double *) __pyx_v_L.data) + __pyx_t_44)) ))) * __pyx_v_v0))); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 83, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_2);
        __pyx_t_45 = 1;
        __pyx_t_46 = __pyx_v_ii;
        __pyx_t_47 = __pyx_v_jj;
        __pyx_t_24 = PyFloat_FromDouble(((*((double *) ( /* dim=1 */ ((char *) (((double *) ( /* dim=0 */ (__pyx_v_VPoly.data + __pyx_t_45 * __pyx_v_VPoly.strides[0]) )) + __pyx_t_46)) ))) + ((*((double *) ( /* dim=0 */ ((char *) (((double *) __pyx_v_L.data) + __pyx_t_47)) ))) * __pyx_v_v1))); if (unlikely(!__pyx_t_24)) __PYX_ERR(0, 83, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_24);
        __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 83, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_3);
        __Pyx_GIVEREF(__pyx_t_2);
        PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_2);
        __Pyx_GIVEREF(__pyx_t_24);
        PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_t_24);
        __pyx_t_2 = 0;
        __pyx_t_24 = 0;
        __pyx_t_34 = __Pyx_PyList_Append(__pyx_v_LPtsCross, __pyx_t_3); if (unlikely(__pyx_t_34 == -1)) __PYX_ERR(0, 83, __pyx_L1_error)
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+084:                 Lind.append(nn)
        __pyx_t_3 = __Pyx_PyInt_From_int(__pyx_v_nn); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 84, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_3);
        __pyx_t_34 = __Pyx_PyList_Append(__pyx_v_Lind, __pyx_t_3); if (unlikely(__pyx_t_34 == -1)) __PYX_ERR(0, 84, __pyx_L1_error)
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+085:                 nn += 1
        __pyx_v_nn = (__pyx_v_nn + 1);
+086:                 VPolybis.append((VPoly[0,ii] + jj*dlr*v0, VPoly[1,ii] + jj*dlr*v1))
        __pyx_t_48 = 0;
        __pyx_t_49 = __pyx_v_ii;
        __pyx_t_3 = PyFloat_FromDouble(((*((double *) ( /* dim=1 */ ((char *) (((double *) ( /* dim=0 */ (__pyx_v_VPoly.data + __pyx_t_48 * __pyx_v_VPoly.strides[0]) )) + __pyx_t_49)) ))) + ((__pyx_v_jj * __pyx_v_dlr) * __pyx_v_v0))); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 86, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_3);
        __pyx_t_50 = 1;
        __pyx_t_51 = __pyx_v_ii;
        __pyx_t_24 = PyFloat_FromDouble(((*((double *) ( /* dim=1 */ ((char *) (((double *) ( /* dim=0 */ (__pyx_v_VPoly.data + __pyx_t_50 * __pyx_v_VPoly.strides[0]) )) + __pyx_t_51)) ))) + ((__pyx_v_jj * __pyx_v_dlr) * __pyx_v_v1))); if (unlikely(!__pyx_t_24)) __PYX_ERR(0, 86, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_24);
        __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 86, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_2);
        __Pyx_GIVEREF(__pyx_t_3);
        PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_3);
        __Pyx_GIVEREF(__pyx_t_24);
        PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_t_24);
        __pyx_t_3 = 0;
        __pyx_t_24 = 0;
        __pyx_t_34 = __Pyx_PyList_Append(__pyx_v_VPolybis, __pyx_t_2); if (unlikely(__pyx_t_34 == -1)) __PYX_ERR(0, 86, __pyx_L1_error)
        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      }
    }
+087:         VPolybis.append((VPoly[0,0],VPoly[1,0]))
    __pyx_t_52 = 0;
    __pyx_t_53 = 0;
    __pyx_t_2 = PyFloat_FromDouble((*((double *) ( /* dim=1 */ ((char *) (((double *) ( /* dim=0 */ (__pyx_v_VPoly.data + __pyx_t_52 * __pyx_v_VPoly.strides[0]) )) + __pyx_t_53)) )))); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 87, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_54 = 1;
    __pyx_t_55 = 0;
    __pyx_t_24 = PyFloat_FromDouble((*((double *) ( /* dim=1 */ ((char *) (((double *) ( /* dim=0 */ (__pyx_v_VPoly.data + __pyx_t_54 * __pyx_v_VPoly.strides[0]) )) + __pyx_t_55)) )))); if (unlikely(!__pyx_t_24)) __PYX_ERR(0, 87, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_24);
    __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 87, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_GIVEREF(__pyx_t_2);
    PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_2);
    __Pyx_GIVEREF(__pyx_t_24);
    PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_t_24);
    __pyx_t_2 = 0;
    __pyx_t_24 = 0;
    __pyx_t_34 = __Pyx_PyList_Append(__pyx_v_VPolybis, __pyx_t_3); if (unlikely(__pyx_t_34 == -1)) __PYX_ERR(0, 87, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
 088:     else:
+089:         for ii in range(0,NP-1):
  /*else*/ {
    __pyx_t_12 = (__pyx_v_NP - 1);
    for (__pyx_t_7 = 0; __pyx_t_7 < __pyx_t_12; __pyx_t_7+=1) {
      __pyx_v_ii = __pyx_t_7;
+090:             v0, v1 = VPoly[0,ii+1]-VPoly[0,ii], VPoly[1,ii+1]-VPoly[1,ii]
      __pyx_t_56 = 0;
      __pyx_t_57 = (__pyx_v_ii + 1);
      __pyx_t_58 = 0;
      __pyx_t_59 = __pyx_v_ii;
      __pyx_t_17 = ((*((double *) ( /* dim=1 */ ((char *) (((double *) ( /* dim=0 */ (__pyx_v_VPoly.data + __pyx_t_56 * __pyx_v_VPoly.strides[0]) )) + __pyx_t_57)) ))) - (*((double *) ( /* dim=1 */ ((char *) (((double *) ( /* dim=0 */ (__pyx_v_VPoly.data + __pyx_t_58 * __pyx_v_VPoly.strides[0]) )) + __pyx_t_59)) ))));
      __pyx_t_60 = 1;
      __pyx_t_61 = (__pyx_v_ii + 1);
      __pyx_t_62 = 1;
      __pyx_t_63 = __pyx_v_ii;
      __pyx_t_22 = ((*((double *) ( /* dim=1 */ ((char *) (((double *) ( /* dim=0 */ (__pyx_v_VPoly.data + __pyx_t_60 * __pyx_v_VPoly.strides[0]) )) + __pyx_t_61)) ))) - (*((double *) ( /* dim=1 */ ((char *) (((double *) ( /* dim=0 */ (__pyx_v_VPoly.data + __pyx_t_62 * __pyx_v_VPoly.strides[0]) )) + __pyx_t_63)) ))));
      __pyx_v_v0 = __pyx_t_17;
      __pyx_v_v1 = __pyx_t_22;
+091:             LMinMax[1] = Csqrt(v0**2 + v1**2)
      __pyx_t_64 = 1;
      *((double *) ( /* dim=0 */ ((char *) (((double *) __pyx_v_LMinMax.data) + __pyx_t_64)) )) = sqrt((pow(__pyx_v_v0, 2.0) + pow(__pyx_v_v1, 2.0)));
+092:             L, dlr, indL, N[ii] = _Ves_mesh_dlfromL_cython(LMinMax, dL, DL=None, margin=margin)
      __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_Ves_mesh_dlfromL_cython); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 92, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_24 = __pyx_memoryview_fromslice(__pyx_v_LMinMax, 1, (PyObject *(*)(char *)) __pyx_memview_get_double, (int (*)(char *, PyObject *)) __pyx_memview_set_double, 0);; if (unlikely(!__pyx_t_24)) __PYX_ERR(0, 92, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_24);
      __pyx_t_2 = PyFloat_FromDouble(__pyx_v_dL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 92, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 92, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_GIVEREF(__pyx_t_24);
      PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_24);
      __Pyx_GIVEREF(__pyx_t_2);
      PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_t_2);
      __pyx_t_24 = 0;
      __pyx_t_2 = 0;
      __pyx_t_2 = PyDict_New(); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 92, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_DL, Py_None) < 0) __PYX_ERR(0, 92, __pyx_L1_error)
      __pyx_t_24 = PyFloat_FromDouble(__pyx_v_margin); if (unlikely(!__pyx_t_24)) __PYX_ERR(0, 92, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_24);
      if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_margin, __pyx_t_24) < 0) __PYX_ERR(0, 92, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_24); __pyx_t_24 = 0;
      __pyx_t_24 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_1, __pyx_t_2); if (unlikely(!__pyx_t_24)) __PYX_ERR(0, 92, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_24);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      if ((likely(PyTuple_CheckExact(__pyx_t_24))) || (PyList_CheckExact(__pyx_t_24))) {
        PyObject* sequence = __pyx_t_24;
        #if !CYTHON_COMPILING_IN_PYPY
        Py_ssize_t size = Py_SIZE(sequence);
        #else
        Py_ssize_t size = PySequence_Size(sequence);
        #endif
        if (unlikely(size != 4)) {
          if (size > 4) __Pyx_RaiseTooManyValuesError(4);
          else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
          __PYX_ERR(0, 92, __pyx_L1_error)
        }
        #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
        if (likely(PyTuple_CheckExact(sequence))) {
          __pyx_t_2 = PyTuple_GET_ITEM(sequence, 0); 
          __pyx_t_1 = PyTuple_GET_ITEM(sequence, 1); 
          __pyx_t_3 = PyTuple_GET_ITEM(sequence, 2); 
          __pyx_t_4 = PyTuple_GET_ITEM(sequence, 3); 
        } else {
          __pyx_t_2 = PyList_GET_ITEM(sequence, 0); 
          __pyx_t_1 = PyList_GET_ITEM(sequence, 1); 
          __pyx_t_3 = PyList_GET_ITEM(sequence, 2); 
          __pyx_t_4 = PyList_GET_ITEM(sequence, 3); 
        }
        __Pyx_INCREF(__pyx_t_2);
        __Pyx_INCREF(__pyx_t_1);
        __Pyx_INCREF(__pyx_t_3);
        __Pyx_INCREF(__pyx_t_4);
        #else
        {
          Py_ssize_t i;
          PyObject** temps[4] = {&__pyx_t_2,&__pyx_t_1,&__pyx_t_3,&__pyx_t_4};
          for (i=0; i < 4; i++) {
            PyObject* item = PySequence_ITEM(sequence, i); if (unlikely(!item)) __PYX_ERR(0, 92, __pyx_L1_error)
            __Pyx_GOTREF(item);
            *(temps[i]) = item;
          }
        }
        #endif
        __Pyx_DECREF(__pyx_t_24); __pyx_t_24 = 0;
      } else {
        Py_ssize_t index = -1;
        PyObject** temps[4] = {&__pyx_t_2,&__pyx_t_1,&__pyx_t_3,&__pyx_t_4};
        __pyx_t_25 = PyObject_GetIter(__pyx_t_24); if (unlikely(!__pyx_t_25)) __PYX_ERR(0, 92, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_25);
        __Pyx_DECREF(__pyx_t_24); __pyx_t_24 = 0;
        __pyx_t_26 = Py_TYPE(__pyx_t_25)->tp_iternext;
        for (index=0; index < 4; index++) {
          PyObject* item = __pyx_t_26(__pyx_t_25); if (unlikely(!item)) goto __pyx_L12_unpacking_failed;
          __Pyx_GOTREF(item);
          *(temps[index]) = item;
        }
        if (__Pyx_IternextUnpackEndCheck(__pyx_t_26(__pyx_t_25), 4) < 0) __PYX_ERR(0, 92, __pyx_L1_error)
        __pyx_t_26 = NULL;
        __Pyx_DECREF(__pyx_t_25); __pyx_t_25 = 0;
        goto __pyx_L13_unpacking_done;
        __pyx_L12_unpacking_failed:;
        __Pyx_DECREF(__pyx_t_25); __pyx_t_25 = 0;
        __pyx_t_26 = NULL;
        if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
        __PYX_ERR(0, 92, __pyx_L1_error)
        __pyx_L13_unpacking_done:;
      }
      __pyx_t_5 = __Pyx_PyObject_to_MemoryviewSlice_dc_double(__pyx_t_2);
      if (unlikely(!__pyx_t_5.memview)) __PYX_ERR(0, 92, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __pyx_t_22 = __pyx_PyFloat_AsDouble(__pyx_t_1); if (unlikely((__pyx_t_22 == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 92, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __pyx_t_27 = __Pyx_PyObject_to_MemoryviewSlice_dc_long(__pyx_t_3);
      if (unlikely(!__pyx_t_27.memview)) __PYX_ERR(0, 92, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __pyx_t_28 = __Pyx_PyInt_As_long(__pyx_t_4); if (unlikely((__pyx_t_28 == (long)-1) && PyErr_Occurred())) __PYX_ERR(0, 92, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __PYX_XDEC_MEMVIEW(&__pyx_v_L, 1);
      __pyx_v_L = __pyx_t_5;
      __pyx_t_5.memview = NULL;
      __pyx_t_5.data = NULL;
      __pyx_v_dlr = __pyx_t_22;
      __PYX_XDEC_MEMVIEW(&__pyx_v_indL, 1);
      __pyx_v_indL = __pyx_t_27;
      __pyx_t_27.memview = NULL;
      __pyx_t_27.data = NULL;
      __pyx_t_65 = __pyx_v_ii;
      *__Pyx_BufPtrStrided1d(long *, __pyx_pybuffernd_N.rcbuffer->pybuffer.buf, __pyx_t_65, __pyx_pybuffernd_N.diminfo[0].strides) = __pyx_t_28;
+093:             VPolybis.append((VPoly[0,ii],VPoly[1,ii]))
      __pyx_t_66 = 0;
      __pyx_t_67 = __pyx_v_ii;
      __pyx_t_24 = PyFloat_FromDouble((*((double *) ( /* dim=1 */ ((char *) (((double *) ( /* dim=0 */ (__pyx_v_VPoly.data + __pyx_t_66 * __pyx_v_VPoly.strides[0]) )) + __pyx_t_67)) )))); if (unlikely(!__pyx_t_24)) __PYX_ERR(0, 93, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_24);
      __pyx_t_68 = 1;
      __pyx_t_69 = __pyx_v_ii;
      __pyx_t_4 = PyFloat_FromDouble((*((double *) ( /* dim=1 */ ((char *) (((double *) ( /* dim=0 */ (__pyx_v_VPoly.data + __pyx_t_68 * __pyx_v_VPoly.strides[0]) )) + __pyx_t_69)) )))); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 93, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 93, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_GIVEREF(__pyx_t_24);
      PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_24);
      __Pyx_GIVEREF(__pyx_t_4);
      PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_t_4);
      __pyx_t_24 = 0;
      __pyx_t_4 = 0;
      __pyx_t_34 = __Pyx_PyList_Append(__pyx_v_VPolybis, __pyx_t_3); if (unlikely(__pyx_t_34 == -1)) __PYX_ERR(0, 93, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+094:             v0, v1 = v0/LMinMax[1], v1/LMinMax[1]
      __pyx_t_70 = 1;
      __pyx_t_22 = (__pyx_v_v0 / (*((double *) ( /* dim=0 */ ((char *) (((double *) __pyx_v_LMinMax.data) + __pyx_t_70)) ))));
      __pyx_t_71 = 1;
      __pyx_t_17 = (__pyx_v_v1 / (*((double *) ( /* dim=0 */ ((char *) (((double *) __pyx_v_LMinMax.data) + __pyx_t_71)) ))));
      __pyx_v_v0 = __pyx_t_22;
      __pyx_v_v1 = __pyx_t_17;
+095:             for jj in range(0,N[ii]):
      __pyx_t_72 = __pyx_v_ii;
      __pyx_t_28 = (*__Pyx_BufPtrStrided1d(long *, __pyx_pybuffernd_N.rcbuffer->pybuffer.buf, __pyx_t_72, __pyx_pybuffernd_N.diminfo[0].strides));
      for (__pyx_t_38 = 0; __pyx_t_38 < __pyx_t_28; __pyx_t_38+=1) {
        __pyx_v_jj = __pyx_t_38;
+096:                 LdLr.append(dlr)
        __pyx_t_3 = PyFloat_FromDouble(__pyx_v_dlr); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 96, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_3);
        __pyx_t_34 = __Pyx_PyList_Append(__pyx_v_LdLr, __pyx_t_3); if (unlikely(__pyx_t_34 == -1)) __PYX_ERR(0, 96, __pyx_L1_error)
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+097:                 LRref.append(VPoly[0,ii] + L[jj]*v0)
        __pyx_t_73 = 0;
        __pyx_t_74 = __pyx_v_ii;
        __pyx_t_75 = __pyx_v_jj;
        __pyx_t_3 = PyFloat_FromDouble(((*((double *) ( /* dim=1 */ ((char *) (((double *) ( /* dim=0 */ (__pyx_v_VPoly.data + __pyx_t_73 * __pyx_v_VPoly.strides[0]) )) + __pyx_t_74)) ))) + ((*((double *) ( /* dim=0 */ ((char *) (((double *) __pyx_v_L.data) + __pyx_t_75)) ))) * __pyx_v_v0))); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 97, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_3);
        __pyx_t_34 = __Pyx_PyList_Append(__pyx_v_LRref, __pyx_t_3); if (unlikely(__pyx_t_34 == -1)) __PYX_ERR(0, 97, __pyx_L1_error)
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+098:                 LPtsCross.append((VPoly[0,ii] + L[jj]*v0 + DIn*VIn[0,ii], VPoly[1,ii] + L[jj]*v1 + DIn*VIn[1,ii]))
        __pyx_t_76 = 0;
        __pyx_t_77 = __pyx_v_ii;
        __pyx_t_78 = __pyx_v_jj;
        __pyx_t_3 = PyFloat_FromDouble(((*((double *) ( /* dim=1 */ ((char *) (((double *) ( /* dim=0 */ (__pyx_v_VPoly.data + __pyx_t_76 * __pyx_v_VPoly.strides[0]) )) + __pyx_t_77)) ))) + ((*((double *) ( /* dim=0 */ ((char *) (((double *) __pyx_v_L.data) + __pyx_t_78)) ))) * __pyx_v_v0))); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 98, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_3);
        __pyx_t_4 = PyFloat_FromDouble(__pyx_v_DIn); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 98, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_4);
        __pyx_t_24 = __Pyx_PyInt_From_int(__pyx_v_ii); if (unlikely(!__pyx_t_24)) __PYX_ERR(0, 98, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_24);
        __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 98, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_1);
        __Pyx_INCREF(__pyx_int_0);
        __Pyx_GIVEREF(__pyx_int_0);
        PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_int_0);
        __Pyx_GIVEREF(__pyx_t_24);
        PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_t_24);
        __pyx_t_24 = 0;
        __pyx_t_24 = PyObject_GetItem(__pyx_v_VIn, __pyx_t_1); if (unlikely(!__pyx_t_24)) __PYX_ERR(0, 98, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_24);
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        __pyx_t_1 = PyNumber_Multiply(__pyx_t_4, __pyx_t_24); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 98, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_1);
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
        __Pyx_DECREF(__pyx_t_24); __pyx_t_24 = 0;
        __pyx_t_24 = PyNumber_Add(__pyx_t_3, __pyx_t_1); if (unlikely(!__pyx_t_24)) __PYX_ERR(0, 98, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_24);
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        __pyx_t_79 = 1;
        __pyx_t_80 = __pyx_v_ii;
        __pyx_t_81 = __pyx_v_jj;
        __pyx_t_1 = PyFloat_FromDouble(((*((double *) ( /* dim=1 */ ((char *) (((double *) ( /* dim=0 */ (__pyx_v_VPoly.data + __pyx_t_79 * __pyx_v_VPoly.strides[0]) )) + __pyx_t_80)) ))) + ((*((double *) ( /* dim=0 */ ((char *) (((double *) __pyx_v_L.data) + __pyx_t_81)) ))) * __pyx_v_v1))); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 98, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_1);
        __pyx_t_3 = PyFloat_FromDouble(__pyx_v_DIn); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 98, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_3);
        __pyx_t_4 = __Pyx_PyInt_From_int(__pyx_v_ii); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 98, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_4);
        __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 98, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_2);
        __Pyx_INCREF(__pyx_int_1);
        __Pyx_GIVEREF(__pyx_int_1);
        PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_int_1);
        __Pyx_GIVEREF(__pyx_t_4);
        PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_t_4);
        __pyx_t_4 = 0;
        __pyx_t_4 = PyObject_GetItem(__pyx_v_VIn, __pyx_t_2); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 98, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_4);
        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
        __pyx_t_2 = PyNumber_Multiply(__pyx_t_3, __pyx_t_4); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 98, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_2);
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
        __pyx_t_4 = PyNumber_Add(__pyx_t_1, __pyx_t_2); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 98, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_4);
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
        __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 98, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_2);
        __Pyx_GIVEREF(__pyx_t_24);
        PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_24);
        __Pyx_GIVEREF(__pyx_t_4);
        PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_t_4);
        __pyx_t_24 = 0;
        __pyx_t_4 = 0;
        __pyx_t_34 = __Pyx_PyList_Append(__pyx_v_LPtsCross, __pyx_t_2); if (unlikely(__pyx_t_34 == -1)) __PYX_ERR(0, 98, __pyx_L1_error)
        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+099:                 Lind.append(nn)
        __pyx_t_2 = __Pyx_PyInt_From_int(__pyx_v_nn); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 99, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_2);
        __pyx_t_34 = __Pyx_PyList_Append(__pyx_v_Lind, __pyx_t_2); if (unlikely(__pyx_t_34 == -1)) __PYX_ERR(0, 99, __pyx_L1_error)
        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+100:                 nn += 1
        __pyx_v_nn = (__pyx_v_nn + 1);
+101:                 VPolybis.append((VPoly[0,ii] + jj*dlr*v0, VPoly[1,ii] + jj*dlr*v1))
        __pyx_t_82 = 0;
        __pyx_t_83 = __pyx_v_ii;
        __pyx_t_2 = PyFloat_FromDouble(((*((double *) ( /* dim=1 */ ((char *) (((double *) ( /* dim=0 */ (__pyx_v_VPoly.data + __pyx_t_82 * __pyx_v_VPoly.strides[0]) )) + __pyx_t_83)) ))) + ((__pyx_v_jj * __pyx_v_dlr) * __pyx_v_v0))); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 101, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_2);
        __pyx_t_84 = 1;
        __pyx_t_85 = __pyx_v_ii;
        __pyx_t_4 = PyFloat_FromDouble(((*((double *) ( /* dim=1 */ ((char *) (((double *) ( /* dim=0 */ (__pyx_v_VPoly.data + __pyx_t_84 * __pyx_v_VPoly.strides[0]) )) + __pyx_t_85)) ))) + ((__pyx_v_jj * __pyx_v_dlr) * __pyx_v_v1))); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 101, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_4);
        __pyx_t_24 = PyTuple_New(2); if (unlikely(!__pyx_t_24)) __PYX_ERR(0, 101, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_24);
        __Pyx_GIVEREF(__pyx_t_2);
        PyTuple_SET_ITEM(__pyx_t_24, 0, __pyx_t_2);
        __Pyx_GIVEREF(__pyx_t_4);
        PyTuple_SET_ITEM(__pyx_t_24, 1, __pyx_t_4);
        __pyx_t_2 = 0;
        __pyx_t_4 = 0;
        __pyx_t_34 = __Pyx_PyList_Append(__pyx_v_VPolybis, __pyx_t_24); if (unlikely(__pyx_t_34 == -1)) __PYX_ERR(0, 101, __pyx_L1_error)
        __Pyx_DECREF(__pyx_t_24); __pyx_t_24 = 0;
      }
    }
+102:         VPolybis.append((VPoly[0,0],VPoly[1,0]))
    __pyx_t_86 = 0;
    __pyx_t_87 = 0;
    __pyx_t_24 = PyFloat_FromDouble((*((double *) ( /* dim=1 */ ((char *) (((double *) ( /* dim=0 */ (__pyx_v_VPoly.data + __pyx_t_86 * __pyx_v_VPoly.strides[0]) )) + __pyx_t_87)) )))); if (unlikely(!__pyx_t_24)) __PYX_ERR(0, 102, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_24);
    __pyx_t_88 = 1;
    __pyx_t_89 = 0;
    __pyx_t_4 = PyFloat_FromDouble((*((double *) ( /* dim=1 */ ((char *) (((double *) ( /* dim=0 */ (__pyx_v_VPoly.data + __pyx_t_88 * __pyx_v_VPoly.strides[0]) )) + __pyx_t_89)) )))); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 102, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 102, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_GIVEREF(__pyx_t_24);
    PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_24);
    __Pyx_GIVEREF(__pyx_t_4);
    PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_t_4);
    __pyx_t_24 = 0;
    __pyx_t_4 = 0;
    __pyx_t_34 = __Pyx_PyList_Append(__pyx_v_VPolybis, __pyx_t_2); if (unlikely(__pyx_t_34 == -1)) __PYX_ERR(0, 102, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  }
  __pyx_L3:;
 103: 
+104:     PtsCross, dLr, ind, Rref = np.array(LPtsCross).T, np.array(LdLr), np.array(Lind,dtype=int), np.array(LRref)
  __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 104, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_24 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_array); if (unlikely(!__pyx_t_24)) __PYX_ERR(0, 104, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_24);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_4 = NULL;
  if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_24))) {
    __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_24);
    if (likely(__pyx_t_4)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_24);
      __Pyx_INCREF(__pyx_t_4);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_24, function);
    }
  }
  if (!__pyx_t_4) {
    __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_24, __pyx_v_LPtsCross); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 104, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
  } else {
    #if CYTHON_FAST_PYCALL
    if (PyFunction_Check(__pyx_t_24)) {
      PyObject *__pyx_temp[2] = {__pyx_t_4, __pyx_v_LPtsCross};
      __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_24, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 104, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
      __Pyx_GOTREF(__pyx_t_2);
    } else
    #endif
    #if CYTHON_FAST_PYCCALL
    if (__Pyx_PyFastCFunction_Check(__pyx_t_24)) {
      PyObject *__pyx_temp[2] = {__pyx_t_4, __pyx_v_LPtsCross};
      __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_24, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 104, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
      __Pyx_GOTREF(__pyx_t_2);
    } else
    #endif
    {
      __pyx_t_1 = PyTuple_New(1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 104, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_4); __pyx_t_4 = NULL;
      __Pyx_INCREF(__pyx_v_LPtsCross);
      __Pyx_GIVEREF(__pyx_v_LPtsCross);
      PyTuple_SET_ITEM(__pyx_t_1, 0+1, __pyx_v_LPtsCross);
      __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_24, __pyx_t_1, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 104, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    }
  }
  __Pyx_DECREF(__pyx_t_24); __pyx_t_24 = 0;
  __pyx_t_24 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_T); if (unlikely(!__pyx_t_24)) __PYX_ERR(0, 104, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_24);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  if (!(likely(((__pyx_t_24) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_24, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 104, __pyx_L1_error)
  __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 104, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_array); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 104, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = NULL;
  if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_4))) {
    __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_4);
    if (likely(__pyx_t_1)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
      __Pyx_INCREF(__pyx_t_1);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_4, function);
    }
  }
  if (!__pyx_t_1) {
    __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_v_LdLr); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 104, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
  } else {
    #if CYTHON_FAST_PYCALL
    if (PyFunction_Check(__pyx_t_4)) {
      PyObject *__pyx_temp[2] = {__pyx_t_1, __pyx_v_LdLr};
      __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_4, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 104, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
      __Pyx_GOTREF(__pyx_t_2);
    } else
    #endif
    #if CYTHON_FAST_PYCCALL
    if (__Pyx_PyFastCFunction_Check(__pyx_t_4)) {
      PyObject *__pyx_temp[2] = {__pyx_t_1, __pyx_v_LdLr};
      __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_4, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 104, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
      __Pyx_GOTREF(__pyx_t_2);
    } else
    #endif
    {
      __pyx_t_3 = PyTuple_New(1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 104, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_GIVEREF(__pyx_t_1); PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_1); __pyx_t_1 = NULL;
      __Pyx_INCREF(__pyx_v_LdLr);
      __Pyx_GIVEREF(__pyx_v_LdLr);
      PyTuple_SET_ITEM(__pyx_t_3, 0+1, __pyx_v_LdLr);
      __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_3, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 104, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    }
  }
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  if (!(likely(((__pyx_t_2) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_2, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 104, __pyx_L1_error)
  __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 104, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_array); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 104, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 104, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_INCREF(__pyx_v_Lind);
  __Pyx_GIVEREF(__pyx_v_Lind);
  PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_v_Lind);
  __pyx_t_1 = PyDict_New(); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 104, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_dtype, ((PyObject *)(&PyInt_Type))) < 0) __PYX_ERR(0, 104, __pyx_L1_error)
  __pyx_t_25 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_4, __pyx_t_1); if (unlikely(!__pyx_t_25)) __PYX_ERR(0, 104, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_25);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (!(likely(((__pyx_t_25) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_25, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 104, __pyx_L1_error)
  __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 104, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_array); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 104, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_4 = NULL;
  if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) {
    __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
    if (likely(__pyx_t_4)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
      __Pyx_INCREF(__pyx_t_4);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_3, function);
    }
  }
  if (!__pyx_t_4) {
    __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_v_LRref); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 104, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
  } else {
    #if CYTHON_FAST_PYCALL
    if (PyFunction_Check(__pyx_t_3)) {
      PyObject *__pyx_temp[2] = {__pyx_t_4, __pyx_v_LRref};
      __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 104, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
      __Pyx_GOTREF(__pyx_t_1);
    } else
    #endif
    #if CYTHON_FAST_PYCCALL
    if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) {
      PyObject *__pyx_temp[2] = {__pyx_t_4, __pyx_v_LRref};
      __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 104, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
      __Pyx_GOTREF(__pyx_t_1);
    } else
    #endif
    {
      __pyx_t_90 = PyTuple_New(1+1); if (unlikely(!__pyx_t_90)) __PYX_ERR(0, 104, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_90);
      __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_90, 0, __pyx_t_4); __pyx_t_4 = NULL;
      __Pyx_INCREF(__pyx_v_LRref);
      __Pyx_GIVEREF(__pyx_v_LRref);
      PyTuple_SET_ITEM(__pyx_t_90, 0+1, __pyx_v_LRref);
      __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_90, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 104, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_90); __pyx_t_90 = 0;
    }
  }
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 104, __pyx_L1_error)
  __pyx_t_91 = ((PyArrayObject *)__pyx_t_24);
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_PtsCross.rcbuffer->pybuffer);
    __pyx_t_7 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_PtsCross.rcbuffer->pybuffer, (PyObject*)__pyx_t_91, &__Pyx_TypeInfo_double, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack);
    if (unlikely(__pyx_t_7 < 0)) {
      PyErr_Fetch(&__pyx_t_10, &__pyx_t_9, &__pyx_t_8);
      if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_PtsCross.rcbuffer->pybuffer, (PyObject*)__pyx_v_PtsCross, &__Pyx_TypeInfo_double, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) {
        Py_XDECREF(__pyx_t_10); Py_XDECREF(__pyx_t_9); Py_XDECREF(__pyx_t_8);
        __Pyx_RaiseBufferFallbackError();
      } else {
        PyErr_Restore(__pyx_t_10, __pyx_t_9, __pyx_t_8);
      }
    }
    __pyx_pybuffernd_PtsCross.diminfo[0].strides = __pyx_pybuffernd_PtsCross.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_PtsCross.diminfo[0].shape = __pyx_pybuffernd_PtsCross.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_PtsCross.diminfo[1].strides = __pyx_pybuffernd_PtsCross.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_PtsCross.diminfo[1].shape = __pyx_pybuffernd_PtsCross.rcbuffer->pybuffer.shape[1];
    if (unlikely(__pyx_t_7 < 0)) __PYX_ERR(0, 104, __pyx_L1_error)
  }
  __pyx_t_91 = 0;
  __pyx_v_PtsCross = ((PyArrayObject *)__pyx_t_24);
  __pyx_t_24 = 0;
  __pyx_t_92 = ((PyArrayObject *)__pyx_t_2);
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_dLr.rcbuffer->pybuffer);
    __pyx_t_7 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_dLr.rcbuffer->pybuffer, (PyObject*)__pyx_t_92, &__Pyx_TypeInfo_double, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack);
    if (unlikely(__pyx_t_7 < 0)) {
      PyErr_Fetch(&__pyx_t_8, &__pyx_t_9, &__pyx_t_10);
      if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_dLr.rcbuffer->pybuffer, (PyObject*)__pyx_v_dLr, &__Pyx_TypeInfo_double, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {
        Py_XDECREF(__pyx_t_8); Py_XDECREF(__pyx_t_9); Py_XDECREF(__pyx_t_10);
        __Pyx_RaiseBufferFallbackError();
      } else {
        PyErr_Restore(__pyx_t_8, __pyx_t_9, __pyx_t_10);
      }
    }
    __pyx_pybuffernd_dLr.diminfo[0].strides = __pyx_pybuffernd_dLr.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_dLr.diminfo[0].shape = __pyx_pybuffernd_dLr.rcbuffer->pybuffer.shape[0];
    if (unlikely(__pyx_t_7 < 0)) __PYX_ERR(0, 104, __pyx_L1_error)
  }
  __pyx_t_92 = 0;
  __pyx_v_dLr = ((PyArrayObject *)__pyx_t_2);
  __pyx_t_2 = 0;
  __pyx_t_6 = ((PyArrayObject *)__pyx_t_25);
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_ind.rcbuffer->pybuffer);
    __pyx_t_7 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_ind.rcbuffer->pybuffer, (PyObject*)__pyx_t_6, &__Pyx_TypeInfo_long, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack);
    if (unlikely(__pyx_t_7 < 0)) {
      PyErr_Fetch(&__pyx_t_10, &__pyx_t_9, &__pyx_t_8);
      if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_ind.rcbuffer->pybuffer, (PyObject*)__pyx_v_ind, &__Pyx_TypeInfo_long, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {
        Py_XDECREF(__pyx_t_10); Py_XDECREF(__pyx_t_9); Py_XDECREF(__pyx_t_8);
        __Pyx_RaiseBufferFallbackError();
      } else {
        PyErr_Restore(__pyx_t_10, __pyx_t_9, __pyx_t_8);
      }
    }
    __pyx_pybuffernd_ind.diminfo[0].strides = __pyx_pybuffernd_ind.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_ind.diminfo[0].shape = __pyx_pybuffernd_ind.rcbuffer->pybuffer.shape[0];
    if (unlikely(__pyx_t_7 < 0)) __PYX_ERR(0, 104, __pyx_L1_error)
  }
  __pyx_t_6 = 0;
  __pyx_v_ind = ((PyArrayObject *)__pyx_t_25);
  __pyx_t_25 = 0;
  __pyx_t_92 = ((PyArrayObject *)__pyx_t_1);
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_Rref.rcbuffer->pybuffer);
    __pyx_t_7 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_Rref.rcbuffer->pybuffer, (PyObject*)__pyx_t_92, &__Pyx_TypeInfo_double, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack);
    if (unlikely(__pyx_t_7 < 0)) {
      PyErr_Fetch(&__pyx_t_8, &__pyx_t_9, &__pyx_t_10);
      if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_Rref.rcbuffer->pybuffer, (PyObject*)__pyx_v_Rref, &__Pyx_TypeInfo_double, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {
        Py_XDECREF(__pyx_t_8); Py_XDECREF(__pyx_t_9); Py_XDECREF(__pyx_t_10);
        __Pyx_RaiseBufferFallbackError();
      } else {
        PyErr_Restore(__pyx_t_8, __pyx_t_9, __pyx_t_10);
      }
    }
    __pyx_pybuffernd_Rref.diminfo[0].strides = __pyx_pybuffernd_Rref.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_Rref.diminfo[0].shape = __pyx_pybuffernd_Rref.rcbuffer->pybuffer.shape[0];
    if (unlikely(__pyx_t_7 < 0)) __PYX_ERR(0, 104, __pyx_L1_error)
  }
  __pyx_t_92 = 0;
  __pyx_v_Rref = ((PyArrayObject *)__pyx_t_1);
  __pyx_t_1 = 0;
+105:     if D1 is not None:
  __pyx_t_11 = (__pyx_v_D1 != Py_None);
  __pyx_t_93 = (__pyx_t_11 != 0);
  if (__pyx_t_93) {
/* … */
  }
+106:         indin = (PtsCross[0,:]>=D1[0]) & (PtsCross[0,:]<=D1[1])
  __pyx_slice_ = PySlice_New(Py_None, Py_None, Py_None); if (unlikely(!__pyx_slice_)) __PYX_ERR(0, 106, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_slice_);
  __Pyx_GIVEREF(__pyx_slice_);
/* … */
    __pyx_t_1 = PyObject_GetItem(((PyObject *)__pyx_v_PtsCross), __pyx_tuple__2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 106, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_25 = __Pyx_GetItemInt(__pyx_v_D1, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 0); if (unlikely(!__pyx_t_25)) __PYX_ERR(0, 106, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_25);
    __pyx_t_2 = PyObject_RichCompare(__pyx_t_1, __pyx_t_25, Py_GE); __Pyx_XGOTREF(__pyx_t_2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 106, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_DECREF(__pyx_t_25); __pyx_t_25 = 0;
  __pyx_tuple__2 = PyTuple_Pack(2, __pyx_int_0, __pyx_slice_); if (unlikely(!__pyx_tuple__2)) __PYX_ERR(0, 106, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__2);
  __Pyx_GIVEREF(__pyx_tuple__2);
  __pyx_slice__3 = PySlice_New(Py_None, Py_None, Py_None); if (unlikely(!__pyx_slice__3)) __PYX_ERR(0, 106, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_slice__3);
  __Pyx_GIVEREF(__pyx_slice__3);
    __pyx_t_25 = PyObject_GetItem(((PyObject *)__pyx_v_PtsCross), __pyx_tuple__4); if (unlikely(!__pyx_t_25)) __PYX_ERR(0, 106, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_25);
    __pyx_t_1 = __Pyx_GetItemInt(__pyx_v_D1, 1, long, 1, __Pyx_PyInt_From_long, 0, 0, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 106, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_24 = PyObject_RichCompare(__pyx_t_25, __pyx_t_1, Py_LE); __Pyx_XGOTREF(__pyx_t_24); if (unlikely(!__pyx_t_24)) __PYX_ERR(0, 106, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_25); __pyx_t_25 = 0;
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_1 = PyNumber_And(__pyx_t_2, __pyx_t_24); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 106, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_DECREF(__pyx_t_24); __pyx_t_24 = 0;
    __pyx_v_indin = __pyx_t_1;
    __pyx_t_1 = 0;
  __pyx_tuple__4 = PyTuple_Pack(2, __pyx_int_0, __pyx_slice__3); if (unlikely(!__pyx_tuple__4)) __PYX_ERR(0, 106, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__4);
  __Pyx_GIVEREF(__pyx_tuple__4);
+107:         PtsCross = PtsCross[:,indin]
    __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 107, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_INCREF(__pyx_slice__5);
    __Pyx_GIVEREF(__pyx_slice__5);
    PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_slice__5);
    __Pyx_INCREF(__pyx_v_indin);
    __Pyx_GIVEREF(__pyx_v_indin);
    PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_v_indin);
    __pyx_t_24 = PyObject_GetItem(((PyObject *)__pyx_v_PtsCross), __pyx_t_1); if (unlikely(!__pyx_t_24)) __PYX_ERR(0, 107, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_24);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    if (!(likely(((__pyx_t_24) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_24, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 107, __pyx_L1_error)
    __pyx_t_91 = ((PyArrayObject *)__pyx_t_24);
    {
      __Pyx_BufFmt_StackElem __pyx_stack[1];
      __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_PtsCross.rcbuffer->pybuffer);
      __pyx_t_7 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_PtsCross.rcbuffer->pybuffer, (PyObject*)__pyx_t_91, &__Pyx_TypeInfo_double, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack);
      if (unlikely(__pyx_t_7 < 0)) {
        PyErr_Fetch(&__pyx_t_10, &__pyx_t_9, &__pyx_t_8);
        if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_PtsCross.rcbuffer->pybuffer, (PyObject*)__pyx_v_PtsCross, &__Pyx_TypeInfo_double, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) {
          Py_XDECREF(__pyx_t_10); Py_XDECREF(__pyx_t_9); Py_XDECREF(__pyx_t_8);
          __Pyx_RaiseBufferFallbackError();
        } else {
          PyErr_Restore(__pyx_t_10, __pyx_t_9, __pyx_t_8);
        }
      }
      __pyx_pybuffernd_PtsCross.diminfo[0].strides = __pyx_pybuffernd_PtsCross.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_PtsCross.diminfo[0].shape = __pyx_pybuffernd_PtsCross.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_PtsCross.diminfo[1].strides = __pyx_pybuffernd_PtsCross.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_PtsCross.diminfo[1].shape = __pyx_pybuffernd_PtsCross.rcbuffer->pybuffer.shape[1];
      if (unlikely(__pyx_t_7 < 0)) __PYX_ERR(0, 107, __pyx_L1_error)
    }
    __pyx_t_91 = 0;
    __Pyx_DECREF_SET(__pyx_v_PtsCross, ((PyArrayObject *)__pyx_t_24));
    __pyx_t_24 = 0;
/* … */
  __pyx_slice__5 = PySlice_New(Py_None, Py_None, Py_None); if (unlikely(!__pyx_slice__5)) __PYX_ERR(0, 107, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_slice__5);
  __Pyx_GIVEREF(__pyx_slice__5);
+108:         dLr, ind = dLr[indin], ind[indin]
    __pyx_t_24 = PyObject_GetItem(((PyObject *)__pyx_v_dLr), __pyx_v_indin); if (unlikely(!__pyx_t_24)) __PYX_ERR(0, 108, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_24);
    if (!(likely(((__pyx_t_24) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_24, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 108, __pyx_L1_error)
    __pyx_t_1 = PyObject_GetItem(((PyObject *)__pyx_v_ind), __pyx_v_indin); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 108, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 108, __pyx_L1_error)
    __pyx_t_92 = ((PyArrayObject *)__pyx_t_24);
    {
      __Pyx_BufFmt_StackElem __pyx_stack[1];
      __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_dLr.rcbuffer->pybuffer);
      __pyx_t_7 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_dLr.rcbuffer->pybuffer, (PyObject*)__pyx_t_92, &__Pyx_TypeInfo_double, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack);
      if (unlikely(__pyx_t_7 < 0)) {
        PyErr_Fetch(&__pyx_t_8, &__pyx_t_9, &__pyx_t_10);
        if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_dLr.rcbuffer->pybuffer, (PyObject*)__pyx_v_dLr, &__Pyx_TypeInfo_double, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {
          Py_XDECREF(__pyx_t_8); Py_XDECREF(__pyx_t_9); Py_XDECREF(__pyx_t_10);
          __Pyx_RaiseBufferFallbackError();
        } else {
          PyErr_Restore(__pyx_t_8, __pyx_t_9, __pyx_t_10);
        }
      }
      __pyx_pybuffernd_dLr.diminfo[0].strides = __pyx_pybuffernd_dLr.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_dLr.diminfo[0].shape = __pyx_pybuffernd_dLr.rcbuffer->pybuffer.shape[0];
      if (unlikely(__pyx_t_7 < 0)) __PYX_ERR(0, 108, __pyx_L1_error)
    }
    __pyx_t_92 = 0;
    __Pyx_DECREF_SET(__pyx_v_dLr, ((PyArrayObject *)__pyx_t_24));
    __pyx_t_24 = 0;
    __pyx_t_6 = ((PyArrayObject *)__pyx_t_1);
    {
      __Pyx_BufFmt_StackElem __pyx_stack[1];
      __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_ind.rcbuffer->pybuffer);
      __pyx_t_7 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_ind.rcbuffer->pybuffer, (PyObject*)__pyx_t_6, &__Pyx_TypeInfo_long, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack);
      if (unlikely(__pyx_t_7 < 0)) {
        PyErr_Fetch(&__pyx_t_10, &__pyx_t_9, &__pyx_t_8);
        if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_ind.rcbuffer->pybuffer, (PyObject*)__pyx_v_ind, &__Pyx_TypeInfo_long, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {
          Py_XDECREF(__pyx_t_10); Py_XDECREF(__pyx_t_9); Py_XDECREF(__pyx_t_8);
          __Pyx_RaiseBufferFallbackError();
        } else {
          PyErr_Restore(__pyx_t_10, __pyx_t_9, __pyx_t_8);
        }
      }
      __pyx_pybuffernd_ind.diminfo[0].strides = __pyx_pybuffernd_ind.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_ind.diminfo[0].shape = __pyx_pybuffernd_ind.rcbuffer->pybuffer.shape[0];
      if (unlikely(__pyx_t_7 < 0)) __PYX_ERR(0, 108, __pyx_L1_error)
    }
    __pyx_t_6 = 0;
    __Pyx_DECREF_SET(__pyx_v_ind, ((PyArrayObject *)__pyx_t_1));
    __pyx_t_1 = 0;
+109:     if D2 is not None:
  __pyx_t_93 = (__pyx_v_D2 != Py_None);
  __pyx_t_11 = (__pyx_t_93 != 0);
  if (__pyx_t_11) {
/* … */
  }
+110:         indin = (PtsCross[1,:]>=D2[0]) & (PtsCross[1,:]<=D2[1])
  __pyx_slice__6 = PySlice_New(Py_None, Py_None, Py_None); if (unlikely(!__pyx_slice__6)) __PYX_ERR(0, 110, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_slice__6);
  __Pyx_GIVEREF(__pyx_slice__6);
/* … */
    __pyx_t_1 = PyObject_GetItem(((PyObject *)__pyx_v_PtsCross), __pyx_tuple__7); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 110, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_24 = __Pyx_GetItemInt(__pyx_v_D2, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 0); if (unlikely(!__pyx_t_24)) __PYX_ERR(0, 110, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_24);
    __pyx_t_2 = PyObject_RichCompare(__pyx_t_1, __pyx_t_24, Py_GE); __Pyx_XGOTREF(__pyx_t_2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 110, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_DECREF(__pyx_t_24); __pyx_t_24 = 0;
  __pyx_tuple__7 = PyTuple_Pack(2, __pyx_int_1, __pyx_slice__6); if (unlikely(!__pyx_tuple__7)) __PYX_ERR(0, 110, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__7);
  __Pyx_GIVEREF(__pyx_tuple__7);
  __pyx_slice__8 = PySlice_New(Py_None, Py_None, Py_None); if (unlikely(!__pyx_slice__8)) __PYX_ERR(0, 110, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_slice__8);
  __Pyx_GIVEREF(__pyx_slice__8);
    __pyx_t_24 = PyObject_GetItem(((PyObject *)__pyx_v_PtsCross), __pyx_tuple__9); if (unlikely(!__pyx_t_24)) __PYX_ERR(0, 110, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_24);
    __pyx_t_1 = __Pyx_GetItemInt(__pyx_v_D2, 1, long, 1, __Pyx_PyInt_From_long, 0, 0, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 110, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_25 = PyObject_RichCompare(__pyx_t_24, __pyx_t_1, Py_LE); __Pyx_XGOTREF(__pyx_t_25); if (unlikely(!__pyx_t_25)) __PYX_ERR(0, 110, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_24); __pyx_t_24 = 0;
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_1 = PyNumber_And(__pyx_t_2, __pyx_t_25); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 110, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_DECREF(__pyx_t_25); __pyx_t_25 = 0;
    __Pyx_XDECREF_SET(__pyx_v_indin, __pyx_t_1);
    __pyx_t_1 = 0;
  __pyx_tuple__9 = PyTuple_Pack(2, __pyx_int_1, __pyx_slice__8); if (unlikely(!__pyx_tuple__9)) __PYX_ERR(0, 110, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__9);
  __Pyx_GIVEREF(__pyx_tuple__9);
+111:         PtsCross = PtsCross[:,indin]
    __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 111, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_INCREF(__pyx_slice__10);
    __Pyx_GIVEREF(__pyx_slice__10);
    PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_slice__10);
    __Pyx_INCREF(__pyx_v_indin);
    __Pyx_GIVEREF(__pyx_v_indin);
    PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_v_indin);
    __pyx_t_25 = PyObject_GetItem(((PyObject *)__pyx_v_PtsCross), __pyx_t_1); if (unlikely(!__pyx_t_25)) __PYX_ERR(0, 111, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_25);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    if (!(likely(((__pyx_t_25) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_25, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 111, __pyx_L1_error)
    __pyx_t_91 = ((PyArrayObject *)__pyx_t_25);
    {
      __Pyx_BufFmt_StackElem __pyx_stack[1];
      __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_PtsCross.rcbuffer->pybuffer);
      __pyx_t_7 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_PtsCross.rcbuffer->pybuffer, (PyObject*)__pyx_t_91, &__Pyx_TypeInfo_double, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack);
      if (unlikely(__pyx_t_7 < 0)) {
        PyErr_Fetch(&__pyx_t_8, &__pyx_t_9, &__pyx_t_10);
        if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_PtsCross.rcbuffer->pybuffer, (PyObject*)__pyx_v_PtsCross, &__Pyx_TypeInfo_double, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) {
          Py_XDECREF(__pyx_t_8); Py_XDECREF(__pyx_t_9); Py_XDECREF(__pyx_t_10);
          __Pyx_RaiseBufferFallbackError();
        } else {
          PyErr_Restore(__pyx_t_8, __pyx_t_9, __pyx_t_10);
        }
      }
      __pyx_pybuffernd_PtsCross.diminfo[0].strides = __pyx_pybuffernd_PtsCross.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_PtsCross.diminfo[0].shape = __pyx_pybuffernd_PtsCross.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_PtsCross.diminfo[1].strides = __pyx_pybuffernd_PtsCross.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_PtsCross.diminfo[1].shape = __pyx_pybuffernd_PtsCross.rcbuffer->pybuffer.shape[1];
      if (unlikely(__pyx_t_7 < 0)) __PYX_ERR(0, 111, __pyx_L1_error)
    }
    __pyx_t_91 = 0;
    __Pyx_DECREF_SET(__pyx_v_PtsCross, ((PyArrayObject *)__pyx_t_25));
    __pyx_t_25 = 0;
/* … */
  __pyx_slice__10 = PySlice_New(Py_None, Py_None, Py_None); if (unlikely(!__pyx_slice__10)) __PYX_ERR(0, 111, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_slice__10);
  __Pyx_GIVEREF(__pyx_slice__10);
+112:         dLr, ind = dLr[indin], ind[indin]
    __pyx_t_25 = PyObject_GetItem(((PyObject *)__pyx_v_dLr), __pyx_v_indin); if (unlikely(!__pyx_t_25)) __PYX_ERR(0, 112, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_25);
    if (!(likely(((__pyx_t_25) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_25, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 112, __pyx_L1_error)
    __pyx_t_1 = PyObject_GetItem(((PyObject *)__pyx_v_ind), __pyx_v_indin); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 112, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 112, __pyx_L1_error)
    __pyx_t_92 = ((PyArrayObject *)__pyx_t_25);
    {
      __Pyx_BufFmt_StackElem __pyx_stack[1];
      __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_dLr.rcbuffer->pybuffer);
      __pyx_t_7 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_dLr.rcbuffer->pybuffer, (PyObject*)__pyx_t_92, &__Pyx_TypeInfo_double, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack);
      if (unlikely(__pyx_t_7 < 0)) {
        PyErr_Fetch(&__pyx_t_10, &__pyx_t_9, &__pyx_t_8);
        if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_dLr.rcbuffer->pybuffer, (PyObject*)__pyx_v_dLr, &__Pyx_TypeInfo_double, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {
          Py_XDECREF(__pyx_t_10); Py_XDECREF(__pyx_t_9); Py_XDECREF(__pyx_t_8);
          __Pyx_RaiseBufferFallbackError();
        } else {
          PyErr_Restore(__pyx_t_10, __pyx_t_9, __pyx_t_8);
        }
      }
      __pyx_pybuffernd_dLr.diminfo[0].strides = __pyx_pybuffernd_dLr.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_dLr.diminfo[0].shape = __pyx_pybuffernd_dLr.rcbuffer->pybuffer.shape[0];
      if (unlikely(__pyx_t_7 < 0)) __PYX_ERR(0, 112, __pyx_L1_error)
    }
    __pyx_t_92 = 0;
    __Pyx_DECREF_SET(__pyx_v_dLr, ((PyArrayObject *)__pyx_t_25));
    __pyx_t_25 = 0;
    __pyx_t_6 = ((PyArrayObject *)__pyx_t_1);
    {
      __Pyx_BufFmt_StackElem __pyx_stack[1];
      __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_ind.rcbuffer->pybuffer);
      __pyx_t_7 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_ind.rcbuffer->pybuffer, (PyObject*)__pyx_t_6, &__Pyx_TypeInfo_long, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack);
      if (unlikely(__pyx_t_7 < 0)) {
        PyErr_Fetch(&__pyx_t_8, &__pyx_t_9, &__pyx_t_10);
        if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_ind.rcbuffer->pybuffer, (PyObject*)__pyx_v_ind, &__Pyx_TypeInfo_long, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {
          Py_XDECREF(__pyx_t_8); Py_XDECREF(__pyx_t_9); Py_XDECREF(__pyx_t_10);
          __Pyx_RaiseBufferFallbackError();
        } else {
          PyErr_Restore(__pyx_t_8, __pyx_t_9, __pyx_t_10);
        }
      }
      __pyx_pybuffernd_ind.diminfo[0].strides = __pyx_pybuffernd_ind.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_ind.diminfo[0].shape = __pyx_pybuffernd_ind.rcbuffer->pybuffer.shape[0];
      if (unlikely(__pyx_t_7 < 0)) __PYX_ERR(0, 112, __pyx_L1_error)
    }
    __pyx_t_6 = 0;
    __Pyx_DECREF_SET(__pyx_v_ind, ((PyArrayObject *)__pyx_t_1));
    __pyx_t_1 = 0;
 113: 
+114:     return PtsCross, dLr, ind, N, Rref, np.array(VPolybis).T
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_25 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_25)) __PYX_ERR(0, 114, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_25);
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_25, __pyx_n_s_array); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 114, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_25); __pyx_t_25 = 0;
  __pyx_t_25 = NULL;
  if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_2))) {
    __pyx_t_25 = PyMethod_GET_SELF(__pyx_t_2);
    if (likely(__pyx_t_25)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
      __Pyx_INCREF(__pyx_t_25);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_2, function);
    }
  }
  if (!__pyx_t_25) {
    __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_v_VPolybis); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 114, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
  } else {
    #if CYTHON_FAST_PYCALL
    if (PyFunction_Check(__pyx_t_2)) {
      PyObject *__pyx_temp[2] = {__pyx_t_25, __pyx_v_VPolybis};
      __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 114, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_25); __pyx_t_25 = 0;
      __Pyx_GOTREF(__pyx_t_1);
    } else
    #endif
    #if CYTHON_FAST_PYCCALL
    if (__Pyx_PyFastCFunction_Check(__pyx_t_2)) {
      PyObject *__pyx_temp[2] = {__pyx_t_25, __pyx_v_VPolybis};
      __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 114, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_25); __pyx_t_25 = 0;
      __Pyx_GOTREF(__pyx_t_1);
    } else
    #endif
    {
      __pyx_t_24 = PyTuple_New(1+1); if (unlikely(!__pyx_t_24)) __PYX_ERR(0, 114, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_24);
      __Pyx_GIVEREF(__pyx_t_25); PyTuple_SET_ITEM(__pyx_t_24, 0, __pyx_t_25); __pyx_t_25 = NULL;
      __Pyx_INCREF(__pyx_v_VPolybis);
      __Pyx_GIVEREF(__pyx_v_VPolybis);
      PyTuple_SET_ITEM(__pyx_t_24, 0+1, __pyx_v_VPolybis);
      __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_24, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 114, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_24); __pyx_t_24 = 0;
    }
  }
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_T); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 114, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = PyTuple_New(6); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 114, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_INCREF(((PyObject *)__pyx_v_PtsCross));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_PtsCross));
  PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)__pyx_v_PtsCross));
  __Pyx_INCREF(((PyObject *)__pyx_v_dLr));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_dLr));
  PyTuple_SET_ITEM(__pyx_t_1, 1, ((PyObject *)__pyx_v_dLr));
  __Pyx_INCREF(((PyObject *)__pyx_v_ind));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_ind));
  PyTuple_SET_ITEM(__pyx_t_1, 2, ((PyObject *)__pyx_v_ind));
  __Pyx_INCREF(((PyObject *)__pyx_v_N));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_N));
  PyTuple_SET_ITEM(__pyx_t_1, 3, ((PyObject *)__pyx_v_N));
  __Pyx_INCREF(((PyObject *)__pyx_v_Rref));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_Rref));
  PyTuple_SET_ITEM(__pyx_t_1, 4, ((PyObject *)__pyx_v_Rref));
  __Pyx_GIVEREF(__pyx_t_2);
  PyTuple_SET_ITEM(__pyx_t_1, 5, __pyx_t_2);
  __pyx_t_2 = 0;
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;
 115: 
 116: 
 117: 
 118: @cython.cdivision(True)
 119: @cython.wraparound(False)
 120: @cython.boundscheck(False)
+121: def _Ves_Smesh_Tor_SubFromD_cython(double dL, double dRPhi,
/* Python wrapper */
static PyObject *__pyx_pw_46_cython_magic_8152fc40fb05daa7217c00b66474f995_5_Ves_Smesh_Tor_SubFromD_cython(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_46_cython_magic_8152fc40fb05daa7217c00b66474f995_4_Ves_Smesh_Tor_SubFromD_cython[] = " Return the desired surfacic submesh indicated by the limits (DR,DZ,DPhi), for the desired resolution (dR,dZ,dRphi) ";
static PyMethodDef __pyx_mdef_46_cython_magic_8152fc40fb05daa7217c00b66474f995_5_Ves_Smesh_Tor_SubFromD_cython = {"_Ves_Smesh_Tor_SubFromD_cython", (PyCFunction)__pyx_pw_46_cython_magic_8152fc40fb05daa7217c00b66474f995_5_Ves_Smesh_Tor_SubFromD_cython, METH_VARARGS|METH_KEYWORDS, __pyx_doc_46_cython_magic_8152fc40fb05daa7217c00b66474f995_4_Ves_Smesh_Tor_SubFromD_cython};
static PyObject *__pyx_pw_46_cython_magic_8152fc40fb05daa7217c00b66474f995_5_Ves_Smesh_Tor_SubFromD_cython(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  double __pyx_v_dL;
  double __pyx_v_dRPhi;
  __Pyx_memviewslice __pyx_v_VPoly = { 0, 0, { 0 }, { 0 }, { 0 } };
  PyObject *__pyx_v_DR = 0;
  PyObject *__pyx_v_DZ = 0;
  PyObject *__pyx_v_DPhi = 0;
  double __pyx_v_DIn;
  PyObject *__pyx_v_VIn = 0;
  PyObject *__pyx_v_PhiMinMax = 0;
  PyObject *__pyx_v_Out = 0;
  double __pyx_v_margin;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("_Ves_Smesh_Tor_SubFromD_cython (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_dL,&__pyx_n_s_dRPhi,&__pyx_n_s_VPoly,&__pyx_n_s_DR,&__pyx_n_s_DZ,&__pyx_n_s_DPhi,&__pyx_n_s_DIn,&__pyx_n_s_VIn,&__pyx_n_s_PhiMinMax,&__pyx_n_s_Out,&__pyx_n_s_margin,0};
    PyObject* values[11] = {0,0,0,0,0,0,0,0,0,0,0};
/* … */
  /* function exit code */
  goto __pyx_L0;
  __pyx_L1_error:;
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_46_cython_magic_8152fc40fb05daa7217c00b66474f995_4_Ves_Smesh_Tor_SubFromD_cython(CYTHON_UNUSED PyObject *__pyx_self, double __pyx_v_dL, double __pyx_v_dRPhi, __Pyx_memviewslice __pyx_v_VPoly, PyObject *__pyx_v_DR, PyObject *__pyx_v_DZ, PyObject *__pyx_v_DPhi, double __pyx_v_DIn, PyObject *__pyx_v_VIn, PyObject *__pyx_v_PhiMinMax, PyObject *__pyx_v_Out, double __pyx_v_margin) {
  __Pyx_memviewslice __pyx_v_dPhir = { 0, 0, { 0 }, { 0 }, { 0 } };
  __Pyx_memviewslice __pyx_v_NRPhi = { 0, 0, { 0 }, { 0 }, { 0 } };
  double __pyx_v_DPhi0;
  double __pyx_v_DPhi1;
  double __pyx_v_DPhiMinMax;
  double __pyx_v_abs0;
  double __pyx_v_abs1;
  double __pyx_v_phi;
  double __pyx_v_indiijj;
  __Pyx_memviewslice __pyx_v_Phin = { 0, 0, { 0 }, { 0 }, { 0 } };
  __Pyx_memviewslice __pyx_v_NRPhi0 = { 0, 0, { 0 }, { 0 }, { 0 } };
  __Pyx_memviewslice __pyx_v_Indin = { 0, 0, { 0 }, { 0 }, { 0 } };
  int __pyx_v_NR0;
  int __pyx_v_nRPhi0;
  int __pyx_v_indR0ii;
  int __pyx_v_ii;
  int __pyx_v_jj0;
  int __pyx_v_jj;
  int __pyx_v_nPhi0;
  int __pyx_v_nPhi1;
  int __pyx_v_NP;
  int __pyx_v_NRPhi_int;
  int __pyx_v_Rratio;
  int __pyx_v_Ln;
  PyArrayObject *__pyx_v_Pts = 0;
  PyArrayObject *__pyx_v_indI = 0;
  PyArrayObject *__pyx_v_PtsCross = 0;
  PyArrayObject *__pyx_v_VPbis = 0;
  PyArrayObject *__pyx_v_R0 = 0;
  PyArrayObject *__pyx_v_dS = 0;
  PyArrayObject *__pyx_v_ind = 0;
  PyArrayObject *__pyx_v_dLr = 0;
  PyArrayObject *__pyx_v_Rref = 0;
  PyArrayObject *__pyx_v_dRPhir = 0;
  PyArrayObject *__pyx_v_indL = 0;
  PyArrayObject *__pyx_v_NL = 0;
  PyObject *__pyx_v_indin = NULL;
  CYTHON_UNUSED long __pyx_v_NPhimax;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_NL;
  __Pyx_Buffer __pyx_pybuffer_NL;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_Pts;
  __Pyx_Buffer __pyx_pybuffer_Pts;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_PtsCross;
  __Pyx_Buffer __pyx_pybuffer_PtsCross;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_R0;
  __Pyx_Buffer __pyx_pybuffer_R0;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_Rref;
  __Pyx_Buffer __pyx_pybuffer_Rref;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_VPbis;
  __Pyx_Buffer __pyx_pybuffer_VPbis;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_dLr;
  __Pyx_Buffer __pyx_pybuffer_dLr;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_dRPhir;
  __Pyx_Buffer __pyx_pybuffer_dRPhir;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_dS;
  __Pyx_Buffer __pyx_pybuffer_dS;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_ind;
  __Pyx_Buffer __pyx_pybuffer_ind;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_indI;
  __Pyx_Buffer __pyx_pybuffer_indI;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_indL;
  __Pyx_Buffer __pyx_pybuffer_indL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("_Ves_Smesh_Tor_SubFromD_cython", 0);
  __Pyx_INCREF(__pyx_v_PhiMinMax);
  __pyx_pybuffer_Pts.pybuffer.buf = NULL;
  __pyx_pybuffer_Pts.refcount = 0;
  __pyx_pybuffernd_Pts.data = NULL;
  __pyx_pybuffernd_Pts.rcbuffer = &__pyx_pybuffer_Pts;
  __pyx_pybuffer_indI.pybuffer.buf = NULL;
  __pyx_pybuffer_indI.refcount = 0;
  __pyx_pybuffernd_indI.data = NULL;
  __pyx_pybuffernd_indI.rcbuffer = &__pyx_pybuffer_indI;
  __pyx_pybuffer_PtsCross.pybuffer.buf = NULL;
  __pyx_pybuffer_PtsCross.refcount = 0;
  __pyx_pybuffernd_PtsCross.data = NULL;
  __pyx_pybuffernd_PtsCross.rcbuffer = &__pyx_pybuffer_PtsCross;
  __pyx_pybuffer_VPbis.pybuffer.buf = NULL;
  __pyx_pybuffer_VPbis.refcount = 0;
  __pyx_pybuffernd_VPbis.data = NULL;
  __pyx_pybuffernd_VPbis.rcbuffer = &__pyx_pybuffer_VPbis;
  __pyx_pybuffer_R0.pybuffer.buf = NULL;
  __pyx_pybuffer_R0.refcount = 0;
  __pyx_pybuffernd_R0.data = NULL;
  __pyx_pybuffernd_R0.rcbuffer = &__pyx_pybuffer_R0;
  __pyx_pybuffer_dS.pybuffer.buf = NULL;
  __pyx_pybuffer_dS.refcount = 0;
  __pyx_pybuffernd_dS.data = NULL;
  __pyx_pybuffernd_dS.rcbuffer = &__pyx_pybuffer_dS;
  __pyx_pybuffer_ind.pybuffer.buf = NULL;
  __pyx_pybuffer_ind.refcount = 0;
  __pyx_pybuffernd_ind.data = NULL;
  __pyx_pybuffernd_ind.rcbuffer = &__pyx_pybuffer_ind;
  __pyx_pybuffer_dLr.pybuffer.buf = NULL;
  __pyx_pybuffer_dLr.refcount = 0;
  __pyx_pybuffernd_dLr.data = NULL;
  __pyx_pybuffernd_dLr.rcbuffer = &__pyx_pybuffer_dLr;
  __pyx_pybuffer_Rref.pybuffer.buf = NULL;
  __pyx_pybuffer_Rref.refcount = 0;
  __pyx_pybuffernd_Rref.data = NULL;
  __pyx_pybuffernd_Rref.rcbuffer = &__pyx_pybuffer_Rref;
  __pyx_pybuffer_dRPhir.pybuffer.buf = NULL;
  __pyx_pybuffer_dRPhir.refcount = 0;
  __pyx_pybuffernd_dRPhir.data = NULL;
  __pyx_pybuffernd_dRPhir.rcbuffer = &__pyx_pybuffer_dRPhir;
  __pyx_pybuffer_indL.pybuffer.buf = NULL;
  __pyx_pybuffer_indL.refcount = 0;
  __pyx_pybuffernd_indL.data = NULL;
  __pyx_pybuffernd_indL.rcbuffer = &__pyx_pybuffer_indL;
  __pyx_pybuffer_NL.pybuffer.buf = NULL;
  __pyx_pybuffer_NL.refcount = 0;
  __pyx_pybuffernd_NL.data = NULL;
  __pyx_pybuffernd_NL.rcbuffer = &__pyx_pybuffer_NL;
/* … */
  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_XDECREF(__pyx_t_9);
  __Pyx_XDECREF(__pyx_t_10);
  __Pyx_XDECREF(__pyx_t_11);
  __Pyx_XDECREF(__pyx_t_12);
  __PYX_XDEC_MEMVIEW(&__pyx_t_21, 1);
  __PYX_XDEC_MEMVIEW(&__pyx_t_23, 1);
  { PyObject *__pyx_type, *__pyx_value, *__pyx_tb;
    __Pyx_PyThreadState_declare
    __Pyx_PyThreadState_assign
    __Pyx_ErrFetch(&__pyx_type, &__pyx_value, &__pyx_tb);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_NL.rcbuffer->pybuffer);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_Pts.rcbuffer->pybuffer);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_PtsCross.rcbuffer->pybuffer);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_R0.rcbuffer->pybuffer);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_Rref.rcbuffer->pybuffer);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_VPbis.rcbuffer->pybuffer);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_dLr.rcbuffer->pybuffer);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_dRPhir.rcbuffer->pybuffer);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_dS.rcbuffer->pybuffer);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_ind.rcbuffer->pybuffer);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_indI.rcbuffer->pybuffer);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_indL.rcbuffer->pybuffer);
  __Pyx_ErrRestore(__pyx_type, __pyx_value, __pyx_tb);}
  __Pyx_AddTraceback("_cython_magic_8152fc40fb05daa7217c00b66474f995._Ves_Smesh_Tor_SubFromD_cython", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  goto __pyx_L2;
  __pyx_L0:;
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_NL.rcbuffer->pybuffer);
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_Pts.rcbuffer->pybuffer);
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_PtsCross.rcbuffer->pybuffer);
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_R0.rcbuffer->pybuffer);
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_Rref.rcbuffer->pybuffer);
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_VPbis.rcbuffer->pybuffer);
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_dLr.rcbuffer->pybuffer);
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_dRPhir.rcbuffer->pybuffer);
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_dS.rcbuffer->pybuffer);
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_ind.rcbuffer->pybuffer);
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_indI.rcbuffer->pybuffer);
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_indL.rcbuffer->pybuffer);
  __pyx_L2:;
  __PYX_XDEC_MEMVIEW(&__pyx_v_dPhir, 1);
  __PYX_XDEC_MEMVIEW(&__pyx_v_NRPhi, 1);
  __PYX_XDEC_MEMVIEW(&__pyx_v_Phin, 1);
  __PYX_XDEC_MEMVIEW(&__pyx_v_NRPhi0, 1);
  __PYX_XDEC_MEMVIEW(&__pyx_v_Indin, 1);
  __Pyx_XDECREF((PyObject *)__pyx_v_Pts);
  __Pyx_XDECREF((PyObject *)__pyx_v_indI);
  __Pyx_XDECREF((PyObject *)__pyx_v_PtsCross);
  __Pyx_XDECREF((PyObject *)__pyx_v_VPbis);
  __Pyx_XDECREF((PyObject *)__pyx_v_R0);
  __Pyx_XDECREF((PyObject *)__pyx_v_dS);
  __Pyx_XDECREF((PyObject *)__pyx_v_ind);
  __Pyx_XDECREF((PyObject *)__pyx_v_dLr);
  __Pyx_XDECREF((PyObject *)__pyx_v_Rref);
  __Pyx_XDECREF((PyObject *)__pyx_v_dRPhir);
  __Pyx_XDECREF((PyObject *)__pyx_v_indL);
  __Pyx_XDECREF((PyObject *)__pyx_v_NL);
  __Pyx_XDECREF(__pyx_v_indin);
  __PYX_XDEC_MEMVIEW(&__pyx_v_VPoly, 1);
  __Pyx_XDECREF(__pyx_v_PhiMinMax);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}
/* … */
  __pyx_tuple__109 = PyTuple_Pack(62, __pyx_n_s_dL, __pyx_n_s_dRPhi, __pyx_n_s_VPoly, __pyx_n_s_DR, __pyx_n_s_DZ, __pyx_n_s_DPhi, __pyx_n_s_DIn, __pyx_n_s_VIn, __pyx_n_s_PhiMinMax, __pyx_n_s_Out, __pyx_n_s_margin, __pyx_n_s_R, __pyx_n_s_Z, __pyx_n_s_dPhir, __pyx_n_s_NRPhi, __pyx_n_s_dRr0, __pyx_n_s_dRr, __pyx_n_s_dZr, __pyx_n_s_DPhi0, __pyx_n_s_DPhi1, __pyx_n_s_DPhiMinMax, __pyx_n_s_abs0, __pyx_n_s_abs1, __pyx_n_s_phi, __pyx_n_s_indiijj, __pyx_n_s_indR0, __pyx_n_s_indR, __pyx_n_s_indZ, __pyx_n_s_Phin, __pyx_n_s_NRPhi0, __pyx_n_s_Indin, __pyx_n_s_NR0, __pyx_n_s_NR, __pyx_n_s_NZ, __pyx_n_s_Rn, __pyx_n_s_Zn, __pyx_n_s_nRPhi0, __pyx_n_s_indR0ii, __pyx_n_s_ii, __pyx_n_s_jj0, __pyx_n_s_jj, __pyx_n_s_nPhi0, __pyx_n_s_nPhi1, __pyx_n_s_zz, __pyx_n_s_NP, __pyx_n_s_NRPhi_int, __pyx_n_s_Rratio, __pyx_n_s_Ln, __pyx_n_s_Pts, __pyx_n_s_indI, __pyx_n_s_PtsCross, __pyx_n_s_VPbis, __pyx_n_s_R0, __pyx_n_s_dS, __pyx_n_s_ind, __pyx_n_s_dLr, __pyx_n_s_Rref, __pyx_n_s_dRPhir, __pyx_n_s_indL, __pyx_n_s_NL, __pyx_n_s_indin, __pyx_n_s_NPhimax); if (unlikely(!__pyx_tuple__109)) __PYX_ERR(0, 121, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__109);
  __Pyx_GIVEREF(__pyx_tuple__109);
/* … */
  __pyx_t_2 = PyCFunction_NewEx(&__pyx_mdef_46_cython_magic_8152fc40fb05daa7217c00b66474f995_5_Ves_Smesh_Tor_SubFromD_cython, NULL, __pyx_n_s_cython_magic_8152fc40fb05daa721); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 121, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_Ves_Smesh_Tor_SubFromD_cython, __pyx_t_2) < 0) __PYX_ERR(0, 121, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_codeobj__110 = (PyObject*)__Pyx_PyCode_New(11, 0, 62, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__109, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_Home_DV226270_cache_ipython_cyt, __pyx_n_s_Ves_Smesh_Tor_SubFromD_cython, 121, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__110)) __PYX_ERR(0, 121, __pyx_L1_error)
 122:                                    double[:,::1] VPoly,
+123:                                    DR=None, DZ=None, DPhi=None,
    values[3] = ((PyObject *)Py_None);
    values[4] = ((PyObject *)Py_None);
    values[5] = ((PyObject *)Py_None);
+124:                                    double DIn=0., VIn=None, PhiMinMax=None,
    values[7] = ((PyObject *)Py_None);
    values[8] = ((PyObject *)Py_None);
    values[9] = ((PyObject*)__pyx_kp_u_X_Y_Z);
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case 11: values[10] = PyTuple_GET_ITEM(__pyx_args, 10);
        case 10: values[9] = PyTuple_GET_ITEM(__pyx_args, 9);
        case  9: values[8] = PyTuple_GET_ITEM(__pyx_args, 8);
        case  8: values[7] = PyTuple_GET_ITEM(__pyx_args, 7);
        case  7: values[6] = PyTuple_GET_ITEM(__pyx_args, 6);
        case  6: values[5] = PyTuple_GET_ITEM(__pyx_args, 5);
        case  5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_dL)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        case  1:
        if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_dRPhi)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_Ves_Smesh_Tor_SubFromD_cython", 0, 3, 11, 1); __PYX_ERR(0, 121, __pyx_L3_error)
        }
        case  2:
        if (likely((values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_VPoly)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_Ves_Smesh_Tor_SubFromD_cython", 0, 3, 11, 2); __PYX_ERR(0, 121, __pyx_L3_error)
        }
        case  3:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_DR);
          if (value) { values[3] = value; kw_args--; }
        }
        case  4:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_DZ);
          if (value) { values[4] = value; kw_args--; }
        }
        case  5:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_DPhi);
          if (value) { values[5] = value; kw_args--; }
        }
        case  6:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_DIn);
          if (value) { values[6] = value; kw_args--; }
        }
        case  7:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_VIn);
          if (value) { values[7] = value; kw_args--; }
        }
        case  8:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_PhiMinMax);
          if (value) { values[8] = value; kw_args--; }
        }
        case  9:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_Out);
          if (value) { values[9] = value; kw_args--; }
        }
        case 10:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_margin);
          if (value) { values[10] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "_Ves_Smesh_Tor_SubFromD_cython") < 0)) __PYX_ERR(0, 121, __pyx_L3_error)
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case 11: values[10] = PyTuple_GET_ITEM(__pyx_args, 10);
        case 10: values[9] = PyTuple_GET_ITEM(__pyx_args, 9);
        case  9: values[8] = PyTuple_GET_ITEM(__pyx_args, 8);
        case  8: values[7] = PyTuple_GET_ITEM(__pyx_args, 7);
        case  7: values[6] = PyTuple_GET_ITEM(__pyx_args, 6);
        case  6: values[5] = PyTuple_GET_ITEM(__pyx_args, 5);
        case  5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    __pyx_v_dL = __pyx_PyFloat_AsDouble(values[0]); if (unlikely((__pyx_v_dL == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 121, __pyx_L3_error)
    __pyx_v_dRPhi = __pyx_PyFloat_AsDouble(values[1]); if (unlikely((__pyx_v_dRPhi == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 121, __pyx_L3_error)
    __pyx_v_VPoly = __Pyx_PyObject_to_MemoryviewSlice_d_dc_double(values[2]); if (unlikely(!__pyx_v_VPoly.memview)) __PYX_ERR(0, 122, __pyx_L3_error)
    __pyx_v_DR = values[3];
    __pyx_v_DZ = values[4];
    __pyx_v_DPhi = values[5];
    if (values[6]) {
      __pyx_v_DIn = __pyx_PyFloat_AsDouble(values[6]); if (unlikely((__pyx_v_DIn == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 124, __pyx_L3_error)
    } else {
      __pyx_v_DIn = ((double)0.);
    }
    __pyx_v_VIn = values[7];
    __pyx_v_PhiMinMax = values[8];
    __pyx_v_Out = ((PyObject*)values[9]);
    if (values[10]) {
      __pyx_v_margin = __pyx_PyFloat_AsDouble(values[10]); if (unlikely((__pyx_v_margin == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 125, __pyx_L3_error)
    } else {
      __pyx_v_margin = ((double)1.e-9);
    }
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("_Ves_Smesh_Tor_SubFromD_cython", 0, 3, 11, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 121, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("_cython_magic_8152fc40fb05daa7217c00b66474f995._Ves_Smesh_Tor_SubFromD_cython", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_Out), (&PyUnicode_Type), 1, "Out", 1))) __PYX_ERR(0, 125, __pyx_L1_error)
  __pyx_r = __pyx_pf_46_cython_magic_8152fc40fb05daa7217c00b66474f995_4_Ves_Smesh_Tor_SubFromD_cython(__pyx_self, __pyx_v_dL, __pyx_v_dRPhi, __pyx_v_VPoly, __pyx_v_DR, __pyx_v_DZ, __pyx_v_DPhi, __pyx_v_DIn, __pyx_v_VIn, __pyx_v_PhiMinMax, __pyx_v_Out, __pyx_v_margin);
 125:                                    str Out='(X,Y,Z)', double margin=1.e-9):
 126:     " Return the desired surfacic submesh indicated by the limits (DR,DZ,DPhi), for the desired resolution (dR,dZ,dRphi) "
 127:     cdef double[::1] R, Z, dPhir, NRPhi#, dPhi, NRZPhi_cum0, indPhi, phi
 128:     cdef double dRr0, dRr, dZr, DPhi0, DPhi1, DPhiMinMax
 129:     cdef double abs0, abs1, phi, indiijj
 130:     cdef long[::1] indR0, indR, indZ, Phin, NRPhi0, Indin
 131:     cdef int NR0, NR, NZ, Rn, Zn, nRPhi0, indR0ii, ii, jj0, jj, nPhi0, nPhi1, zz, NP, NRPhi_int, Rratio, Ln
 132:     cdef cnp.ndarray[double,ndim=2] Pts, indI, PtsCross, VPbis
 133:     cdef cnp.ndarray[double,ndim=1] R0, dS, ind, dLr, Rref, dRPhir
 134:     cdef cnp.ndarray[long,ndim=1] indL, NL
 135: 
 136:     # Pre-format input
+137:     if PhiMinMax is None:
  __pyx_t_1 = (__pyx_v_PhiMinMax == Py_None);
  __pyx_t_2 = (__pyx_t_1 != 0);
  if (__pyx_t_2) {
/* … */
    goto __pyx_L3;
  }
+138:         PhiMinMax = [-Cpi,Cpi]
    __pyx_t_3 = PyFloat_FromDouble((-M_PI)); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 138, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_4 = PyFloat_FromDouble(M_PI); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 138, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_5 = PyList_New(2); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 138, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_GIVEREF(__pyx_t_3);
    PyList_SET_ITEM(__pyx_t_5, 0, __pyx_t_3);
    __Pyx_GIVEREF(__pyx_t_4);
    PyList_SET_ITEM(__pyx_t_5, 1, __pyx_t_4);
    __pyx_t_3 = 0;
    __pyx_t_4 = 0;
    __Pyx_DECREF_SET(__pyx_v_PhiMinMax, __pyx_t_5);
    __pyx_t_5 = 0;
+139:         DPhiMinMax = 2.*Cpi
    __pyx_v_DPhiMinMax = (2. * M_PI);
 140:     else:
+141:         PhiMinMax = [Catan2(Csin(PhiMinMax[0]),Ccos(PhiMinMax[0])), Catan2(Csin(PhiMinMax[1]),Ccos(PhiMinMax[1]))]
  /*else*/ {
    __pyx_t_5 = __Pyx_GetItemInt(__pyx_v_PhiMinMax, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 0); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 141, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_6 = __pyx_PyFloat_AsDouble(__pyx_t_5); if (unlikely((__pyx_t_6 == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 141, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __pyx_t_5 = __Pyx_GetItemInt(__pyx_v_PhiMinMax, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 0); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 141, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_7 = __pyx_PyFloat_AsDouble(__pyx_t_5); if (unlikely((__pyx_t_7 == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 141, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __pyx_t_5 = PyFloat_FromDouble(atan2(sin(__pyx_t_6), cos(__pyx_t_7))); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 141, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_4 = __Pyx_GetItemInt(__pyx_v_PhiMinMax, 1, long, 1, __Pyx_PyInt_From_long, 0, 0, 0); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 141, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_7 = __pyx_PyFloat_AsDouble(__pyx_t_4); if (unlikely((__pyx_t_7 == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 141, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_t_4 = __Pyx_GetItemInt(__pyx_v_PhiMinMax, 1, long, 1, __Pyx_PyInt_From_long, 0, 0, 0); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 141, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_6 = __pyx_PyFloat_AsDouble(__pyx_t_4); if (unlikely((__pyx_t_6 == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 141, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_t_4 = PyFloat_FromDouble(atan2(sin(__pyx_t_7), cos(__pyx_t_6))); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 141, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_3 = PyList_New(2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 141, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_GIVEREF(__pyx_t_5);
    PyList_SET_ITEM(__pyx_t_3, 0, __pyx_t_5);
    __Pyx_GIVEREF(__pyx_t_4);
    PyList_SET_ITEM(__pyx_t_3, 1, __pyx_t_4);
    __pyx_t_5 = 0;
    __pyx_t_4 = 0;
    __Pyx_DECREF_SET(__pyx_v_PhiMinMax, __pyx_t_3);
    __pyx_t_3 = 0;
+142:         if PhiMinMax[1]>=PhiMinMax[0]:
    __pyx_t_3 = __Pyx_GetItemInt(__pyx_v_PhiMinMax, 1, long, 1, __Pyx_PyInt_From_long, 0, 0, 0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 142, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_4 = __Pyx_GetItemInt(__pyx_v_PhiMinMax, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 0); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 142, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_5 = PyObject_RichCompare(__pyx_t_3, __pyx_t_4, Py_GE); __Pyx_XGOTREF(__pyx_t_5); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 142, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_5); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(0, 142, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    if (__pyx_t_2) {
/* … */
      goto __pyx_L4;
    }
+143:             DPhiMinMax = PhiMinMax[1]-PhiMinMax[0]
      __pyx_t_5 = __Pyx_GetItemInt(__pyx_v_PhiMinMax, 1, long, 1, __Pyx_PyInt_From_long, 0, 0, 0); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 143, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
      __pyx_t_4 = __Pyx_GetItemInt(__pyx_v_PhiMinMax, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 0); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 143, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_t_3 = PyNumber_Subtract(__pyx_t_5, __pyx_t_4); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 143, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __pyx_t_6 = __pyx_PyFloat_AsDouble(__pyx_t_3); if (unlikely((__pyx_t_6 == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 143, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __pyx_v_DPhiMinMax = __pyx_t_6;
 144:         else:
+145:             DPhiMinMax = 2.*Cpi + PhiMinMax[1] - PhiMinMax[0]
    /*else*/ {
      __pyx_t_3 = PyFloat_FromDouble((2. * M_PI)); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 145, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_4 = __Pyx_GetItemInt(__pyx_v_PhiMinMax, 1, long, 1, __Pyx_PyInt_From_long, 0, 0, 0); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 145, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_t_5 = PyNumber_Add(__pyx_t_3, __pyx_t_4); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 145, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __pyx_t_4 = __Pyx_GetItemInt(__pyx_v_PhiMinMax, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 0); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 145, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_t_3 = PyNumber_Subtract(__pyx_t_5, __pyx_t_4); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 145, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __pyx_t_6 = __pyx_PyFloat_AsDouble(__pyx_t_3); if (unlikely((__pyx_t_6 == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 145, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __pyx_v_DPhiMinMax = __pyx_t_6;
    }
    __pyx_L4:;
  }
  __pyx_L3:;
 146: 
 147: 
 148:     # Get the actual R and Z resolutions and mesh elements
+149:     PtsCross, dLr, indL, NL, Rref, VPbis = _Ves_mesh_CrossPoly(VPoly, dL, D1=None, D2=None, margin=margin, DIn=DIn, VIn=VIn)
  __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_Ves_mesh_CrossPoly); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 149, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = __pyx_memoryview_fromslice(__pyx_v_VPoly, 2, (PyObject *(*)(char *)) __pyx_memview_get_double, (int (*)(char *, PyObject *)) __pyx_memview_set_double, 0);; if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 149, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_5 = PyFloat_FromDouble(__pyx_v_dL); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 149, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_t_8 = PyTuple_New(2); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 149, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);
  __Pyx_GIVEREF(__pyx_t_4);
  PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_4);
  __Pyx_GIVEREF(__pyx_t_5);
  PyTuple_SET_ITEM(__pyx_t_8, 1, __pyx_t_5);
  __pyx_t_4 = 0;
  __pyx_t_5 = 0;
  __pyx_t_5 = PyDict_New(); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 149, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  if (PyDict_SetItem(__pyx_t_5, __pyx_n_s_D1, Py_None) < 0) __PYX_ERR(0, 149, __pyx_L1_error)
  if (PyDict_SetItem(__pyx_t_5, __pyx_n_s_D2, Py_None) < 0) __PYX_ERR(0, 149, __pyx_L1_error)
  __pyx_t_4 = PyFloat_FromDouble(__pyx_v_margin); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 149, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  if (PyDict_SetItem(__pyx_t_5, __pyx_n_s_margin, __pyx_t_4) < 0) __PYX_ERR(0, 149, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_4 = PyFloat_FromDouble(__pyx_v_DIn); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 149, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  if (PyDict_SetItem(__pyx_t_5, __pyx_n_s_DIn, __pyx_t_4) < 0) __PYX_ERR(0, 149, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  if (PyDict_SetItem(__pyx_t_5, __pyx_n_s_VIn, __pyx_v_VIn) < 0) __PYX_ERR(0, 149, __pyx_L1_error)
  __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_8, __pyx_t_5); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 149, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  if ((likely(PyTuple_CheckExact(__pyx_t_4))) || (PyList_CheckExact(__pyx_t_4))) {
    PyObject* sequence = __pyx_t_4;
    #if !CYTHON_COMPILING_IN_PYPY
    Py_ssize_t size = Py_SIZE(sequence);
    #else
    Py_ssize_t size = PySequence_Size(sequence);
    #endif
    if (unlikely(size != 6)) {
      if (size > 6) __Pyx_RaiseTooManyValuesError(6);
      else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
      __PYX_ERR(0, 149, __pyx_L1_error)
    }
    #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
    if (likely(PyTuple_CheckExact(sequence))) {
      __pyx_t_5 = PyTuple_GET_ITEM(sequence, 0); 
      __pyx_t_8 = PyTuple_GET_ITEM(sequence, 1); 
      __pyx_t_3 = PyTuple_GET_ITEM(sequence, 2); 
      __pyx_t_9 = PyTuple_GET_ITEM(sequence, 3); 
      __pyx_t_10 = PyTuple_GET_ITEM(sequence, 4); 
      __pyx_t_11 = PyTuple_GET_ITEM(sequence, 5); 
    } else {
      __pyx_t_5 = PyList_GET_ITEM(sequence, 0); 
      __pyx_t_8 = PyList_GET_ITEM(sequence, 1); 
      __pyx_t_3 = PyList_GET_ITEM(sequence, 2); 
      __pyx_t_9 = PyList_GET_ITEM(sequence, 3); 
      __pyx_t_10 = PyList_GET_ITEM(sequence, 4); 
      __pyx_t_11 = PyList_GET_ITEM(sequence, 5); 
    }
    __Pyx_INCREF(__pyx_t_5);
    __Pyx_INCREF(__pyx_t_8);
    __Pyx_INCREF(__pyx_t_3);
    __Pyx_INCREF(__pyx_t_9);
    __Pyx_INCREF(__pyx_t_10);
    __Pyx_INCREF(__pyx_t_11);
    #else
    {
      Py_ssize_t i;
      PyObject** temps[6] = {&__pyx_t_5,&__pyx_t_8,&__pyx_t_3,&__pyx_t_9,&__pyx_t_10,&__pyx_t_11};
      for (i=0; i < 6; i++) {
        PyObject* item = PySequence_ITEM(sequence, i); if (unlikely(!item)) __PYX_ERR(0, 149, __pyx_L1_error)
        __Pyx_GOTREF(item);
        *(temps[i]) = item;
      }
    }
    #endif
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  } else {
    Py_ssize_t index = -1;
    PyObject** temps[6] = {&__pyx_t_5,&__pyx_t_8,&__pyx_t_3,&__pyx_t_9,&__pyx_t_10,&__pyx_t_11};
    __pyx_t_12 = PyObject_GetIter(__pyx_t_4); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 149, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_12);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_t_13 = Py_TYPE(__pyx_t_12)->tp_iternext;
    for (index=0; index < 6; index++) {
      PyObject* item = __pyx_t_13(__pyx_t_12); if (unlikely(!item)) goto __pyx_L5_unpacking_failed;
      __Pyx_GOTREF(item);
      *(temps[index]) = item;
    }
    if (__Pyx_IternextUnpackEndCheck(__pyx_t_13(__pyx_t_12), 6) < 0) __PYX_ERR(0, 149, __pyx_L1_error)
    __pyx_t_13 = NULL;
    __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
    goto __pyx_L6_unpacking_done;
    __pyx_L5_unpacking_failed:;
    __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
    __pyx_t_13 = NULL;
    if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
    __PYX_ERR(0, 149, __pyx_L1_error)
    __pyx_L6_unpacking_done:;
  }
  if (!(likely(((__pyx_t_5) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_5, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 149, __pyx_L1_error)
  if (!(likely(((__pyx_t_8) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_8, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 149, __pyx_L1_error)
  if (!(likely(((__pyx_t_3) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_3, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 149, __pyx_L1_error)
  if (!(likely(((__pyx_t_9) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_9, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 149, __pyx_L1_error)
  if (!(likely(((__pyx_t_10) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_10, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 149, __pyx_L1_error)
  if (!(likely(((__pyx_t_11) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_11, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 149, __pyx_L1_error)
  __pyx_t_14 = ((PyArrayObject *)__pyx_t_5);
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_PtsCross.rcbuffer->pybuffer);
    __pyx_t_15 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_PtsCross.rcbuffer->pybuffer, (PyObject*)__pyx_t_14, &__Pyx_TypeInfo_double, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack);
    if (unlikely(__pyx_t_15 < 0)) {
      PyErr_Fetch(&__pyx_t_16, &__pyx_t_17, &__pyx_t_18);
      if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_PtsCross.rcbuffer->pybuffer, (PyObject*)__pyx_v_PtsCross, &__Pyx_TypeInfo_double, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) {
        Py_XDECREF(__pyx_t_16); Py_XDECREF(__pyx_t_17); Py_XDECREF(__pyx_t_18);
        __Pyx_RaiseBufferFallbackError();
      } else {
        PyErr_Restore(__pyx_t_16, __pyx_t_17, __pyx_t_18);
      }
    }
    __pyx_pybuffernd_PtsCross.diminfo[0].strides = __pyx_pybuffernd_PtsCross.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_PtsCross.diminfo[0].shape = __pyx_pybuffernd_PtsCross.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_PtsCross.diminfo[1].strides = __pyx_pybuffernd_PtsCross.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_PtsCross.diminfo[1].shape = __pyx_pybuffernd_PtsCross.rcbuffer->pybuffer.shape[1];
    if (unlikely(__pyx_t_15 < 0)) __PYX_ERR(0, 149, __pyx_L1_error)
  }
  __pyx_t_14 = 0;
  __pyx_v_PtsCross = ((PyArrayObject *)__pyx_t_5);
  __pyx_t_5 = 0;
  __pyx_t_19 = ((PyArrayObject *)__pyx_t_8);
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_dLr.rcbuffer->pybuffer);
    __pyx_t_15 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_dLr.rcbuffer->pybuffer, (PyObject*)__pyx_t_19, &__Pyx_TypeInfo_double, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack);
    if (unlikely(__pyx_t_15 < 0)) {
      PyErr_Fetch(&__pyx_t_18, &__pyx_t_17, &__pyx_t_16);
      if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_dLr.rcbuffer->pybuffer, (PyObject*)__pyx_v_dLr, &__Pyx_TypeInfo_double, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {
        Py_XDECREF(__pyx_t_18); Py_XDECREF(__pyx_t_17); Py_XDECREF(__pyx_t_16);
        __Pyx_RaiseBufferFallbackError();
      } else {
        PyErr_Restore(__pyx_t_18, __pyx_t_17, __pyx_t_16);
      }
    }
    __pyx_pybuffernd_dLr.diminfo[0].strides = __pyx_pybuffernd_dLr.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_dLr.diminfo[0].shape = __pyx_pybuffernd_dLr.rcbuffer->pybuffer.shape[0];
    if (unlikely(__pyx_t_15 < 0)) __PYX_ERR(0, 149, __pyx_L1_error)
  }
  __pyx_t_19 = 0;
  __pyx_v_dLr = ((PyArrayObject *)__pyx_t_8);
  __pyx_t_8 = 0;
  __pyx_t_20 = ((PyArrayObject *)__pyx_t_3);
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_indL.rcbuffer->pybuffer);
    __pyx_t_15 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_indL.rcbuffer->pybuffer, (PyObject*)__pyx_t_20, &__Pyx_TypeInfo_long, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack);
    if (unlikely(__pyx_t_15 < 0)) {
      PyErr_Fetch(&__pyx_t_16, &__pyx_t_17, &__pyx_t_18);
      if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_indL.rcbuffer->pybuffer, (PyObject*)__pyx_v_indL, &__Pyx_TypeInfo_long, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {
        Py_XDECREF(__pyx_t_16); Py_XDECREF(__pyx_t_17); Py_XDECREF(__pyx_t_18);
        __Pyx_RaiseBufferFallbackError();
      } else {
        PyErr_Restore(__pyx_t_16, __pyx_t_17, __pyx_t_18);
      }
    }
    __pyx_pybuffernd_indL.diminfo[0].strides = __pyx_pybuffernd_indL.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_indL.diminfo[0].shape = __pyx_pybuffernd_indL.rcbuffer->pybuffer.shape[0];
    if (unlikely(__pyx_t_15 < 0)) __PYX_ERR(0, 149, __pyx_L1_error)
  }
  __pyx_t_20 = 0;
  __pyx_v_indL = ((PyArrayObject *)__pyx_t_3);
  __pyx_t_3 = 0;
  __pyx_t_20 = ((PyArrayObject *)__pyx_t_9);
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_NL.rcbuffer->pybuffer);
    __pyx_t_15 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_NL.rcbuffer->pybuffer, (PyObject*)__pyx_t_20, &__Pyx_TypeInfo_long, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack);
    if (unlikely(__pyx_t_15 < 0)) {
      PyErr_Fetch(&__pyx_t_18, &__pyx_t_17, &__pyx_t_16);
      if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_NL.rcbuffer->pybuffer, (PyObject*)__pyx_v_NL, &__Pyx_TypeInfo_long, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {
        Py_XDECREF(__pyx_t_18); Py_XDECREF(__pyx_t_17); Py_XDECREF(__pyx_t_16);
        __Pyx_RaiseBufferFallbackError();
      } else {
        PyErr_Restore(__pyx_t_18, __pyx_t_17, __pyx_t_16);
      }
    }
    __pyx_pybuffernd_NL.diminfo[0].strides = __pyx_pybuffernd_NL.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_NL.diminfo[0].shape = __pyx_pybuffernd_NL.rcbuffer->pybuffer.shape[0];
    if (unlikely(__pyx_t_15 < 0)) __PYX_ERR(0, 149, __pyx_L1_error)
  }
  __pyx_t_20 = 0;
  __pyx_v_NL = ((PyArrayObject *)__pyx_t_9);
  __pyx_t_9 = 0;
  __pyx_t_19 = ((PyArrayObject *)__pyx_t_10);
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_Rref.rcbuffer->pybuffer);
    __pyx_t_15 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_Rref.rcbuffer->pybuffer, (PyObject*)__pyx_t_19, &__Pyx_TypeInfo_double, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack);
    if (unlikely(__pyx_t_15 < 0)) {
      PyErr_Fetch(&__pyx_t_16, &__pyx_t_17, &__pyx_t_18);
      if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_Rref.rcbuffer->pybuffer, (PyObject*)__pyx_v_Rref, &__Pyx_TypeInfo_double, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {
        Py_XDECREF(__pyx_t_16); Py_XDECREF(__pyx_t_17); Py_XDECREF(__pyx_t_18);
        __Pyx_RaiseBufferFallbackError();
      } else {
        PyErr_Restore(__pyx_t_16, __pyx_t_17, __pyx_t_18);
      }
    }
    __pyx_pybuffernd_Rref.diminfo[0].strides = __pyx_pybuffernd_Rref.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_Rref.diminfo[0].shape = __pyx_pybuffernd_Rref.rcbuffer->pybuffer.shape[0];
    if (unlikely(__pyx_t_15 < 0)) __PYX_ERR(0, 149, __pyx_L1_error)
  }
  __pyx_t_19 = 0;
  __pyx_v_Rref = ((PyArrayObject *)__pyx_t_10);
  __pyx_t_10 = 0;
  __pyx_t_14 = ((PyArrayObject *)__pyx_t_11);
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_VPbis.rcbuffer->pybuffer);
    __pyx_t_15 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_VPbis.rcbuffer->pybuffer, (PyObject*)__pyx_t_14, &__Pyx_TypeInfo_double, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack);
    if (unlikely(__pyx_t_15 < 0)) {
      PyErr_Fetch(&__pyx_t_18, &__pyx_t_17, &__pyx_t_16);
      if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_VPbis.rcbuffer->pybuffer, (PyObject*)__pyx_v_VPbis, &__Pyx_TypeInfo_double, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) {
        Py_XDECREF(__pyx_t_18); Py_XDECREF(__pyx_t_17); Py_XDECREF(__pyx_t_16);
        __Pyx_RaiseBufferFallbackError();
      } else {
        PyErr_Restore(__pyx_t_18, __pyx_t_17, __pyx_t_16);
      }
    }
    __pyx_pybuffernd_VPbis.diminfo[0].strides = __pyx_pybuffernd_VPbis.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_VPbis.diminfo[0].shape = __pyx_pybuffernd_VPbis.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_VPbis.diminfo[1].strides = __pyx_pybuffernd_VPbis.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_VPbis.diminfo[1].shape = __pyx_pybuffernd_VPbis.rcbuffer->pybuffer.shape[1];
    if (unlikely(__pyx_t_15 < 0)) __PYX_ERR(0, 149, __pyx_L1_error)
  }
  __pyx_t_14 = 0;
  __pyx_v_VPbis = ((PyArrayObject *)__pyx_t_11);
  __pyx_t_11 = 0;
+150:     R0 = np.copy(Rref)
  __pyx_t_11 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 150, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_11);
  __pyx_t_10 = __Pyx_PyObject_GetAttrStr(__pyx_t_11, __pyx_n_s_copy); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 150, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_10);
  __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
  __pyx_t_11 = NULL;
  if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_10))) {
    __pyx_t_11 = PyMethod_GET_SELF(__pyx_t_10);
    if (likely(__pyx_t_11)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_10);
      __Pyx_INCREF(__pyx_t_11);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_10, function);
    }
  }
  if (!__pyx_t_11) {
    __pyx_t_4 = __Pyx_PyObject_CallOneArg(__pyx_t_10, ((PyObject *)__pyx_v_Rref)); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 150, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
  } else {
    #if CYTHON_FAST_PYCALL
    if (PyFunction_Check(__pyx_t_10)) {
      PyObject *__pyx_temp[2] = {__pyx_t_11, ((PyObject *)__pyx_v_Rref)};
      __pyx_t_4 = __Pyx_PyFunction_FastCall(__pyx_t_10, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 150, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0;
      __Pyx_GOTREF(__pyx_t_4);
    } else
    #endif
    #if CYTHON_FAST_PYCCALL
    if (__Pyx_PyFastCFunction_Check(__pyx_t_10)) {
      PyObject *__pyx_temp[2] = {__pyx_t_11, ((PyObject *)__pyx_v_Rref)};
      __pyx_t_4 = __Pyx_PyCFunction_FastCall(__pyx_t_10, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 150, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0;
      __Pyx_GOTREF(__pyx_t_4);
    } else
    #endif
    {
      __pyx_t_9 = PyTuple_New(1+1); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 150, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_9);
      __Pyx_GIVEREF(__pyx_t_11); PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_t_11); __pyx_t_11 = NULL;
      __Pyx_INCREF(((PyObject *)__pyx_v_Rref));
      __Pyx_GIVEREF(((PyObject *)__pyx_v_Rref));
      PyTuple_SET_ITEM(__pyx_t_9, 0+1, ((PyObject *)__pyx_v_Rref));
      __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_10, __pyx_t_9, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 150, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
    }
  }
  __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
  if (!(likely(((__pyx_t_4) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_4, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 150, __pyx_L1_error)
  __pyx_t_19 = ((PyArrayObject *)__pyx_t_4);
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_R0.rcbuffer->pybuffer);
    __pyx_t_15 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_R0.rcbuffer->pybuffer, (PyObject*)__pyx_t_19, &__Pyx_TypeInfo_double, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack);
    if (unlikely(__pyx_t_15 < 0)) {
      PyErr_Fetch(&__pyx_t_16, &__pyx_t_17, &__pyx_t_18);
      if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_R0.rcbuffer->pybuffer, (PyObject*)__pyx_v_R0, &__Pyx_TypeInfo_double, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {
        Py_XDECREF(__pyx_t_16); Py_XDECREF(__pyx_t_17); Py_XDECREF(__pyx_t_18);
        __Pyx_RaiseBufferFallbackError();
      } else {
        PyErr_Restore(__pyx_t_16, __pyx_t_17, __pyx_t_18);
      }
    }
    __pyx_pybuffernd_R0.diminfo[0].strides = __pyx_pybuffernd_R0.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_R0.diminfo[0].shape = __pyx_pybuffernd_R0.rcbuffer->pybuffer.shape[0];
    if (unlikely(__pyx_t_15 < 0)) __PYX_ERR(0, 150, __pyx_L1_error)
  }
  __pyx_t_19 = 0;
  __pyx_v_R0 = ((PyArrayObject *)__pyx_t_4);
  __pyx_t_4 = 0;
+151:     NR0 = R0.size
  __pyx_t_4 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_R0), __pyx_n_s_size); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 151, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_15 = __Pyx_PyInt_As_int(__pyx_t_4); if (unlikely((__pyx_t_15 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 151, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_v_NR0 = __pyx_t_15;
+152:     indin = np.ones((PtsCross.shape[1],),dtype=bool)
  __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 152, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_10 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_ones); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 152, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_10);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_4 = __Pyx_PyInt_From_Py_intptr_t((__pyx_v_PtsCross->dimensions[1])); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 152, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_9 = PyTuple_New(1); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 152, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_9);
  __Pyx_GIVEREF(__pyx_t_4);
  PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_t_4);
  __pyx_t_4 = 0;
  __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 152, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_GIVEREF(__pyx_t_9);
  PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_9);
  __pyx_t_9 = 0;
  __pyx_t_9 = PyDict_New(); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 152, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_9);
  if (PyDict_SetItem(__pyx_t_9, __pyx_n_s_dtype, ((PyObject *)__pyx_ptype_7cpython_4bool_bool)) < 0) __PYX_ERR(0, 152, __pyx_L1_error)
  __pyx_t_11 = __Pyx_PyObject_Call(__pyx_t_10, __pyx_t_4, __pyx_t_9); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 152, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_11);
  __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
  __pyx_v_indin = __pyx_t_11;
  __pyx_t_11 = 0;
+153:     if DR is not None:
  __pyx_t_2 = (__pyx_v_DR != Py_None);
  __pyx_t_1 = (__pyx_t_2 != 0);
  if (__pyx_t_1) {
/* … */
  }
+154:         indin = indin & (R0>=DR[0]) & (R0<=DR[1])
    __pyx_t_11 = __Pyx_GetItemInt(__pyx_v_DR, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 0); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 154, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_11);
    __pyx_t_9 = PyObject_RichCompare(((PyObject *)__pyx_v_R0), __pyx_t_11, Py_GE); __Pyx_XGOTREF(__pyx_t_9); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 154, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
    __pyx_t_11 = PyNumber_And(__pyx_v_indin, __pyx_t_9); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 154, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_11);
    __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
    __pyx_t_9 = __Pyx_GetItemInt(__pyx_v_DR, 1, long, 1, __Pyx_PyInt_From_long, 0, 0, 0); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 154, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_9);
    __pyx_t_4 = PyObject_RichCompare(((PyObject *)__pyx_v_R0), __pyx_t_9, Py_LE); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 154, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
    __pyx_t_9 = PyNumber_And(__pyx_t_11, __pyx_t_4); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 154, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_9);
    __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_DECREF_SET(__pyx_v_indin, __pyx_t_9);
    __pyx_t_9 = 0;
+155:     if DZ is not None:
  __pyx_t_1 = (__pyx_v_DZ != Py_None);
  __pyx_t_2 = (__pyx_t_1 != 0);
  if (__pyx_t_2) {
/* … */
  }
+156:         indin = indin & (PtsCross[1,:]>=DZ[0]) & (PtsCross[1,:]<=DZ[1])
  __pyx_slice__11 = PySlice_New(Py_None, Py_None, Py_None); if (unlikely(!__pyx_slice__11)) __PYX_ERR(0, 156, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_slice__11);
  __Pyx_GIVEREF(__pyx_slice__11);
/* … */
    __pyx_t_9 = PyObject_GetItem(((PyObject *)__pyx_v_PtsCross), __pyx_tuple__12); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 156, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_9);
    __pyx_t_4 = __Pyx_GetItemInt(__pyx_v_DZ, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 0); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 156, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_11 = PyObject_RichCompare(__pyx_t_9, __pyx_t_4, Py_GE); __Pyx_XGOTREF(__pyx_t_11); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 156, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_t_4 = PyNumber_And(__pyx_v_indin, __pyx_t_11); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 156, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
  __pyx_tuple__12 = PyTuple_Pack(2, __pyx_int_1, __pyx_slice__11); if (unlikely(!__pyx_tuple__12)) __PYX_ERR(0, 156, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__12);
  __Pyx_GIVEREF(__pyx_tuple__12);
  __pyx_slice__13 = PySlice_New(Py_None, Py_None, Py_None); if (unlikely(!__pyx_slice__13)) __PYX_ERR(0, 156, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_slice__13);
  __Pyx_GIVEREF(__pyx_slice__13);
    __pyx_t_11 = PyObject_GetItem(((PyObject *)__pyx_v_PtsCross), __pyx_tuple__14); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 156, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_11);
    __pyx_t_9 = __Pyx_GetItemInt(__pyx_v_DZ, 1, long, 1, __Pyx_PyInt_From_long, 0, 0, 0); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 156, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_9);
    __pyx_t_10 = PyObject_RichCompare(__pyx_t_11, __pyx_t_9, Py_LE); __Pyx_XGOTREF(__pyx_t_10); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 156, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
    __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
    __pyx_t_9 = PyNumber_And(__pyx_t_4, __pyx_t_10); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 156, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_9);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
    __Pyx_DECREF_SET(__pyx_v_indin, __pyx_t_9);
    __pyx_t_9 = 0;
  __pyx_tuple__14 = PyTuple_Pack(2, __pyx_int_1, __pyx_slice__13); if (unlikely(!__pyx_tuple__14)) __PYX_ERR(0, 156, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__14);
  __Pyx_GIVEREF(__pyx_tuple__14);
+157:     PtsCross, dLr, indL, Rref = PtsCross[:,indin], dLr[indin], indL[indin], Rref[indin]
  __pyx_t_9 = PyTuple_New(2); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 157, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_9);
  __Pyx_INCREF(__pyx_slice__15);
  __Pyx_GIVEREF(__pyx_slice__15);
  PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_slice__15);
  __Pyx_INCREF(__pyx_v_indin);
  __Pyx_GIVEREF(__pyx_v_indin);
  PyTuple_SET_ITEM(__pyx_t_9, 1, __pyx_v_indin);
  __pyx_t_10 = PyObject_GetItem(((PyObject *)__pyx_v_PtsCross), __pyx_t_9); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 157, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_10);
  __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
  if (!(likely(((__pyx_t_10) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_10, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 157, __pyx_L1_error)
  __pyx_t_9 = PyObject_GetItem(((PyObject *)__pyx_v_dLr), __pyx_v_indin); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 157, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_9);
  if (!(likely(((__pyx_t_9) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_9, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 157, __pyx_L1_error)
  __pyx_t_4 = PyObject_GetItem(((PyObject *)__pyx_v_indL), __pyx_v_indin); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 157, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  if (!(likely(((__pyx_t_4) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_4, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 157, __pyx_L1_error)
  __pyx_t_11 = PyObject_GetItem(((PyObject *)__pyx_v_Rref), __pyx_v_indin); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 157, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_11);
  if (!(likely(((__pyx_t_11) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_11, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 157, __pyx_L1_error)
  __pyx_t_14 = ((PyArrayObject *)__pyx_t_10);
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_PtsCross.rcbuffer->pybuffer);
    __pyx_t_15 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_PtsCross.rcbuffer->pybuffer, (PyObject*)__pyx_t_14, &__Pyx_TypeInfo_double, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack);
    if (unlikely(__pyx_t_15 < 0)) {
      PyErr_Fetch(&__pyx_t_18, &__pyx_t_17, &__pyx_t_16);
      if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_PtsCross.rcbuffer->pybuffer, (PyObject*)__pyx_v_PtsCross, &__Pyx_TypeInfo_double, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) {
        Py_XDECREF(__pyx_t_18); Py_XDECREF(__pyx_t_17); Py_XDECREF(__pyx_t_16);
        __Pyx_RaiseBufferFallbackError();
      } else {
        PyErr_Restore(__pyx_t_18, __pyx_t_17, __pyx_t_16);
      }
    }
    __pyx_pybuffernd_PtsCross.diminfo[0].strides = __pyx_pybuffernd_PtsCross.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_PtsCross.diminfo[0].shape = __pyx_pybuffernd_PtsCross.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_PtsCross.diminfo[1].strides = __pyx_pybuffernd_PtsCross.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_PtsCross.diminfo[1].shape = __pyx_pybuffernd_PtsCross.rcbuffer->pybuffer.shape[1];
    if (unlikely(__pyx_t_15 < 0)) __PYX_ERR(0, 157, __pyx_L1_error)
  }
  __pyx_t_14 = 0;
  __Pyx_DECREF_SET(__pyx_v_PtsCross, ((PyArrayObject *)__pyx_t_10));
  __pyx_t_10 = 0;
  __pyx_t_19 = ((PyArrayObject *)__pyx_t_9);
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_dLr.rcbuffer->pybuffer);
    __pyx_t_15 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_dLr.rcbuffer->pybuffer, (PyObject*)__pyx_t_19, &__Pyx_TypeInfo_double, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack);
    if (unlikely(__pyx_t_15 < 0)) {
      PyErr_Fetch(&__pyx_t_16, &__pyx_t_17, &__pyx_t_18);
      if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_dLr.rcbuffer->pybuffer, (PyObject*)__pyx_v_dLr, &__Pyx_TypeInfo_double, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {
        Py_XDECREF(__pyx_t_16); Py_XDECREF(__pyx_t_17); Py_XDECREF(__pyx_t_18);
        __Pyx_RaiseBufferFallbackError();
      } else {
        PyErr_Restore(__pyx_t_16, __pyx_t_17, __pyx_t_18);
      }
    }
    __pyx_pybuffernd_dLr.diminfo[0].strides = __pyx_pybuffernd_dLr.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_dLr.diminfo[0].shape = __pyx_pybuffernd_dLr.rcbuffer->pybuffer.shape[0];
    if (unlikely(__pyx_t_15 < 0)) __PYX_ERR(0, 157, __pyx_L1_error)
  }
  __pyx_t_19 = 0;
  __Pyx_DECREF_SET(__pyx_v_dLr, ((PyArrayObject *)__pyx_t_9));
  __pyx_t_9 = 0;
  __pyx_t_20 = ((PyArrayObject *)__pyx_t_4);
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_indL.rcbuffer->pybuffer);
    __pyx_t_15 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_indL.rcbuffer->pybuffer, (PyObject*)__pyx_t_20, &__Pyx_TypeInfo_long, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack);
    if (unlikely(__pyx_t_15 < 0)) {
      PyErr_Fetch(&__pyx_t_18, &__pyx_t_17, &__pyx_t_16);
      if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_indL.rcbuffer->pybuffer, (PyObject*)__pyx_v_indL, &__Pyx_TypeInfo_long, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {
        Py_XDECREF(__pyx_t_18); Py_XDECREF(__pyx_t_17); Py_XDECREF(__pyx_t_16);
        __Pyx_RaiseBufferFallbackError();
      } else {
        PyErr_Restore(__pyx_t_18, __pyx_t_17, __pyx_t_16);
      }
    }
    __pyx_pybuffernd_indL.diminfo[0].strides = __pyx_pybuffernd_indL.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_indL.diminfo[0].shape = __pyx_pybuffernd_indL.rcbuffer->pybuffer.shape[0];
    if (unlikely(__pyx_t_15 < 0)) __PYX_ERR(0, 157, __pyx_L1_error)
  }
  __pyx_t_20 = 0;
  __Pyx_DECREF_SET(__pyx_v_indL, ((PyArrayObject *)__pyx_t_4));
  __pyx_t_4 = 0;
  __pyx_t_19 = ((PyArrayObject *)__pyx_t_11);
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_Rref.rcbuffer->pybuffer);
    __pyx_t_15 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_Rref.rcbuffer->pybuffer, (PyObject*)__pyx_t_19, &__Pyx_TypeInfo_double, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack);
    if (unlikely(__pyx_t_15 < 0)) {
      PyErr_Fetch(&__pyx_t_16, &__pyx_t_17, &__pyx_t_18);
      if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_Rref.rcbuffer->pybuffer, (PyObject*)__pyx_v_Rref, &__Pyx_TypeInfo_double, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {
        Py_XDECREF(__pyx_t_16); Py_XDECREF(__pyx_t_17); Py_XDECREF(__pyx_t_18);
        __Pyx_RaiseBufferFallbackError();
      } else {
        PyErr_Restore(__pyx_t_16, __pyx_t_17, __pyx_t_18);
      }
    }
    __pyx_pybuffernd_Rref.diminfo[0].strides = __pyx_pybuffernd_Rref.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_Rref.diminfo[0].shape = __pyx_pybuffernd_Rref.rcbuffer->pybuffer.shape[0];
    if (unlikely(__pyx_t_15 < 0)) __PYX_ERR(0, 157, __pyx_L1_error)
  }
  __pyx_t_19 = 0;
  __Pyx_DECREF_SET(__pyx_v_Rref, ((PyArrayObject *)__pyx_t_11));
  __pyx_t_11 = 0;
/* … */
  __pyx_slice__15 = PySlice_New(Py_None, Py_None, Py_None); if (unlikely(!__pyx_slice__15)) __PYX_ERR(0, 157, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_slice__15);
  __Pyx_GIVEREF(__pyx_slice__15);
+158:     Ln = indin.sum()
  __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_indin, __pyx_n_s_sum); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 158, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_9 = NULL;
  if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_4))) {
    __pyx_t_9 = PyMethod_GET_SELF(__pyx_t_4);
    if (likely(__pyx_t_9)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
      __Pyx_INCREF(__pyx_t_9);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_4, function);
    }
  }
  if (__pyx_t_9) {
    __pyx_t_11 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_9); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 158, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
  } else {
    __pyx_t_11 = __Pyx_PyObject_CallNoArg(__pyx_t_4); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 158, __pyx_L1_error)
  }
  __Pyx_GOTREF(__pyx_t_11);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_15 = __Pyx_PyInt_As_int(__pyx_t_11); if (unlikely((__pyx_t_15 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 158, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
  __pyx_v_Ln = __pyx_t_15;
+159:     Indin = indin.nonzero()[0]
  __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_indin, __pyx_n_s_nonzero); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 159, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_9 = NULL;
  if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_4))) {
    __pyx_t_9 = PyMethod_GET_SELF(__pyx_t_4);
    if (likely(__pyx_t_9)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
      __Pyx_INCREF(__pyx_t_9);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_4, function);
    }
  }
  if (__pyx_t_9) {
    __pyx_t_11 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_9); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 159, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
  } else {
    __pyx_t_11 = __Pyx_PyObject_CallNoArg(__pyx_t_4); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 159, __pyx_L1_error)
  }
  __Pyx_GOTREF(__pyx_t_11);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_4 = __Pyx_GetItemInt(__pyx_t_11, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 0); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 159, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
  __pyx_t_21 = __Pyx_PyObject_to_MemoryviewSlice_dc_long(__pyx_t_4);
  if (unlikely(!__pyx_t_21.memview)) __PYX_ERR(0, 159, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_v_Indin = __pyx_t_21;
  __pyx_t_21.memview = NULL;
  __pyx_t_21.data = NULL;
 160: 
 161:     # Get the limits if any (and make sure to replace them in the proper quadrants)
+162:     if DPhi is None:
  __pyx_t_2 = (__pyx_v_DPhi == Py_None);
  __pyx_t_1 = (__pyx_t_2 != 0);
  if (__pyx_t_1) {
/* … */
    goto __pyx_L9;
  }
+163:         DPhi0, DPhi1 = PhiMinMax[0], PhiMinMax[1]
    __pyx_t_4 = __Pyx_GetItemInt(__pyx_v_PhiMinMax, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 0); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 163, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_6 = __pyx_PyFloat_AsDouble(__pyx_t_4); if (unlikely((__pyx_t_6 == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 163, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_t_4 = __Pyx_GetItemInt(__pyx_v_PhiMinMax, 1, long, 1, __Pyx_PyInt_From_long, 0, 0, 0); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 163, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_7 = __pyx_PyFloat_AsDouble(__pyx_t_4); if (unlikely((__pyx_t_7 == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 163, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_v_DPhi0 = __pyx_t_6;
    __pyx_v_DPhi1 = __pyx_t_7;
 164:     else:
+165:         DPhi0 = PhiMinMax[0] if DPhi[0] is None else Catan2(Csin(DPhi[0]),Ccos(DPhi[0]))
  /*else*/ {
    __pyx_t_4 = __Pyx_GetItemInt(__pyx_v_DPhi, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 0); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 165, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_1 = (__pyx_t_4 == Py_None);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    if ((__pyx_t_1 != 0)) {
      __pyx_t_4 = __Pyx_GetItemInt(__pyx_v_PhiMinMax, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 0); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 165, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_t_6 = __pyx_PyFloat_AsDouble(__pyx_t_4); if (unlikely((__pyx_t_6 == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 165, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __pyx_t_7 = __pyx_t_6;
    } else {
      __pyx_t_4 = __Pyx_GetItemInt(__pyx_v_DPhi, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 0); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 165, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_t_6 = __pyx_PyFloat_AsDouble(__pyx_t_4); if (unlikely((__pyx_t_6 == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 165, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __pyx_t_4 = __Pyx_GetItemInt(__pyx_v_DPhi, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 0); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 165, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_t_22 = __pyx_PyFloat_AsDouble(__pyx_t_4); if (unlikely((__pyx_t_22 == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 165, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __pyx_t_7 = atan2(sin(__pyx_t_6), cos(__pyx_t_22));
    }
    __pyx_v_DPhi0 = __pyx_t_7;
+166:         DPhi1 = PhiMinMax[1] if DPhi[1] is None else Catan2(Csin(DPhi[1]),Ccos(DPhi[1]))
    __pyx_t_4 = __Pyx_GetItemInt(__pyx_v_DPhi, 1, long, 1, __Pyx_PyInt_From_long, 0, 0, 0); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 166, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_1 = (__pyx_t_4 == Py_None);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    if ((__pyx_t_1 != 0)) {
      __pyx_t_4 = __Pyx_GetItemInt(__pyx_v_PhiMinMax, 1, long, 1, __Pyx_PyInt_From_long, 0, 0, 0); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 166, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_t_22 = __pyx_PyFloat_AsDouble(__pyx_t_4); if (unlikely((__pyx_t_22 == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 166, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __pyx_t_7 = __pyx_t_22;
    } else {
      __pyx_t_4 = __Pyx_GetItemInt(__pyx_v_DPhi, 1, long, 1, __Pyx_PyInt_From_long, 0, 0, 0); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 166, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_t_22 = __pyx_PyFloat_AsDouble(__pyx_t_4); if (unlikely((__pyx_t_22 == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 166, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __pyx_t_4 = __Pyx_GetItemInt(__pyx_v_DPhi, 1, long, 1, __Pyx_PyInt_From_long, 0, 0, 0); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 166, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_t_6 = __pyx_PyFloat_AsDouble(__pyx_t_4); if (unlikely((__pyx_t_6 == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 166, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __pyx_t_7 = atan2(sin(__pyx_t_22), cos(__pyx_t_6));
    }
    __pyx_v_DPhi1 = __pyx_t_7;
  }
  __pyx_L9:;
+167:     dRPhir, dPhir = np.empty((Ln,)), np.empty((Ln,))
  __pyx_t_11 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 167, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_11);
  __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_t_11, __pyx_n_s_empty); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 167, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_9);
  __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
  __pyx_t_11 = __Pyx_PyInt_From_int(__pyx_v_Ln); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 167, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_11);
  __pyx_t_10 = PyTuple_New(1); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 167, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_10);
  __Pyx_GIVEREF(__pyx_t_11);
  PyTuple_SET_ITEM(__pyx_t_10, 0, __pyx_t_11);
  __pyx_t_11 = 0;
  __pyx_t_11 = NULL;
  if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_9))) {
    __pyx_t_11 = PyMethod_GET_SELF(__pyx_t_9);
    if (likely(__pyx_t_11)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_9);
      __Pyx_INCREF(__pyx_t_11);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_9, function);
    }
  }
  if (!__pyx_t_11) {
    __pyx_t_4 = __Pyx_PyObject_CallOneArg(__pyx_t_9, __pyx_t_10); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 167, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
    __Pyx_GOTREF(__pyx_t_4);
  } else {
    #if CYTHON_FAST_PYCALL
    if (PyFunction_Check(__pyx_t_9)) {
      PyObject *__pyx_temp[2] = {__pyx_t_11, __pyx_t_10};
      __pyx_t_4 = __Pyx_PyFunction_FastCall(__pyx_t_9, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 167, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0;
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
    } else
    #endif
    #if CYTHON_FAST_PYCCALL
    if (__Pyx_PyFastCFunction_Check(__pyx_t_9)) {
      PyObject *__pyx_temp[2] = {__pyx_t_11, __pyx_t_10};
      __pyx_t_4 = __Pyx_PyCFunction_FastCall(__pyx_t_9, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 167, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0;
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
    } else
    #endif
    {
      __pyx_t_3 = PyTuple_New(1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 167, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_GIVEREF(__pyx_t_11); PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_11); __pyx_t_11 = NULL;
      __Pyx_GIVEREF(__pyx_t_10);
      PyTuple_SET_ITEM(__pyx_t_3, 0+1, __pyx_t_10);
      __pyx_t_10 = 0;
      __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_9, __pyx_t_3, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 167, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    }
  }
  __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
  if (!(likely(((__pyx_t_4) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_4, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 167, __pyx_L1_error)
  __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 167, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_10 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_empty); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 167, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_10);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_3 = __Pyx_PyInt_From_int(__pyx_v_Ln); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 167, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_11 = PyTuple_New(1); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 167, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_11);
  __Pyx_GIVEREF(__pyx_t_3);
  PyTuple_SET_ITEM(__pyx_t_11, 0, __pyx_t_3);
  __pyx_t_3 = 0;
  __pyx_t_3 = NULL;
  if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_10))) {
    __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_10);
    if (likely(__pyx_t_3)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_10);
      __Pyx_INCREF(__pyx_t_3);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_10, function);
    }
  }
  if (!__pyx_t_3) {
    __pyx_t_9 = __Pyx_PyObject_CallOneArg(__pyx_t_10, __pyx_t_11); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 167, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
    __Pyx_GOTREF(__pyx_t_9);
  } else {
    #if CYTHON_FAST_PYCALL
    if (PyFunction_Check(__pyx_t_10)) {
      PyObject *__pyx_temp[2] = {__pyx_t_3, __pyx_t_11};
      __pyx_t_9 = __Pyx_PyFunction_FastCall(__pyx_t_10, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 167, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
      __Pyx_GOTREF(__pyx_t_9);
      __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
    } else
    #endif
    #if CYTHON_FAST_PYCCALL
    if (__Pyx_PyFastCFunction_Check(__pyx_t_10)) {
      PyObject *__pyx_temp[2] = {__pyx_t_3, __pyx_t_11};
      __pyx_t_9 = __Pyx_PyCFunction_FastCall(__pyx_t_10, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 167, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
      __Pyx_GOTREF(__pyx_t_9);
      __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
    } else
    #endif
    {
      __pyx_t_8 = PyTuple_New(1+1); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 167, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_8);
      __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_3); __pyx_t_3 = NULL;
      __Pyx_GIVEREF(__pyx_t_11);
      PyTuple_SET_ITEM(__pyx_t_8, 0+1, __pyx_t_11);
      __pyx_t_11 = 0;
      __pyx_t_9 = __Pyx_PyObject_Call(__pyx_t_10, __pyx_t_8, NULL); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 167, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_9);
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    }
  }
  __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
  __pyx_t_23 = __Pyx_PyObject_to_MemoryviewSlice_dc_double(__pyx_t_9);
  if (unlikely(!__pyx_t_23.memview)) __PYX_ERR(0, 167, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
  __pyx_t_19 = ((PyArrayObject *)__pyx_t_4);
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_dRPhir.rcbuffer->pybuffer);
    __pyx_t_15 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_dRPhir.rcbuffer->pybuffer, (PyObject*)__pyx_t_19, &__Pyx_TypeInfo_double, PyBUF_FORMAT| PyBUF_STRIDES| PyBUF_WRITABLE, 1, 0, __pyx_stack);
    if (unlikely(__pyx_t_15 < 0)) {
      PyErr_Fetch(&__pyx_t_18, &__pyx_t_17, &__pyx_t_16);
      if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_dRPhir.rcbuffer->pybuffer, (PyObject*)__pyx_v_dRPhir, &__Pyx_TypeInfo_double, PyBUF_FORMAT| PyBUF_STRIDES| PyBUF_WRITABLE, 1, 0, __pyx_stack) == -1)) {
        Py_XDECREF(__pyx_t_18); Py_XDECREF(__pyx_t_17); Py_XDECREF(__pyx_t_16);
        __Pyx_RaiseBufferFallbackError();
      } else {
        PyErr_Restore(__pyx_t_18, __pyx_t_17, __pyx_t_16);
      }
    }
    __pyx_pybuffernd_dRPhir.diminfo[0].strides = __pyx_pybuffernd_dRPhir.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_dRPhir.diminfo[0].shape = __pyx_pybuffernd_dRPhir.rcbuffer->pybuffer.shape[0];
    if (unlikely(__pyx_t_15 < 0)) __PYX_ERR(0, 167, __pyx_L1_error)
  }
  __pyx_t_19 = 0;
  __pyx_v_dRPhir = ((PyArrayObject *)__pyx_t_4);
  __pyx_t_4 = 0;
  __pyx_v_dPhir = __pyx_t_23;
  __pyx_t_23.memview = NULL;
  __pyx_t_23.data = NULL;
+168:     Phin = np.empty((Ln,),dtype=int)
  __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 168, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_empty); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 168, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_9);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_4 = __Pyx_PyInt_From_int(__pyx_v_Ln); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 168, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_10 = PyTuple_New(1); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 168, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_10);
  __Pyx_GIVEREF(__pyx_t_4);
  PyTuple_SET_ITEM(__pyx_t_10, 0, __pyx_t_4);
  __pyx_t_4 = 0;
  __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 168, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_GIVEREF(__pyx_t_10);
  PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_10);
  __pyx_t_10 = 0;
  __pyx_t_10 = PyDict_New(); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 168, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_10);
  if (PyDict_SetItem(__pyx_t_10, __pyx_n_s_dtype, ((PyObject *)(&PyInt_Type))) < 0) __PYX_ERR(0, 168, __pyx_L1_error)
  __pyx_t_8 = __Pyx_PyObject_Call(__pyx_t_9, __pyx_t_4, __pyx_t_10); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 168, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);
  __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
  __pyx_t_21 = __Pyx_PyObject_to_MemoryviewSlice_dc_long(__pyx_t_8);
  if (unlikely(!__pyx_t_21.memview)) __PYX_ERR(0, 168, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  __pyx_v_Phin = __pyx_t_21;
  __pyx_t_21.memview = NULL;
  __pyx_t_21.data = NULL;
+169:     NRPhi = np.empty((Ln,))
  __pyx_t_10 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 169, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_10);
  __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_10, __pyx_n_s_empty); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 169, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
  __pyx_t_10 = __Pyx_PyInt_From_int(__pyx_v_Ln); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 169, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_10);
  __pyx_t_9 = PyTuple_New(1); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 169, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_9);
  __Pyx_GIVEREF(__pyx_t_10);
  PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_t_10);
  __pyx_t_10 = 0;
  __pyx_t_10 = NULL;
  if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_4))) {
    __pyx_t_10 = PyMethod_GET_SELF(__pyx_t_4);
    if (likely(__pyx_t_10)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
      __Pyx_INCREF(__pyx_t_10);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_4, function);
    }
  }
  if (!__pyx_t_10) {
    __pyx_t_8 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_9); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 169, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
    __Pyx_GOTREF(__pyx_t_8);
  } else {
    #if CYTHON_FAST_PYCALL
    if (PyFunction_Check(__pyx_t_4)) {
      PyObject *__pyx_temp[2] = {__pyx_t_10, __pyx_t_9};
      __pyx_t_8 = __Pyx_PyFunction_FastCall(__pyx_t_4, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 169, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
      __Pyx_GOTREF(__pyx_t_8);
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
    } else
    #endif
    #if CYTHON_FAST_PYCCALL
    if (__Pyx_PyFastCFunction_Check(__pyx_t_4)) {
      PyObject *__pyx_temp[2] = {__pyx_t_10, __pyx_t_9};
      __pyx_t_8 = __Pyx_PyCFunction_FastCall(__pyx_t_4, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 169, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
      __Pyx_GOTREF(__pyx_t_8);
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
    } else
    #endif
    {
      __pyx_t_11 = PyTuple_New(1+1); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 169, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_11);
      __Pyx_GIVEREF(__pyx_t_10); PyTuple_SET_ITEM(__pyx_t_11, 0, __pyx_t_10); __pyx_t_10 = NULL;
      __Pyx_GIVEREF(__pyx_t_9);
      PyTuple_SET_ITEM(__pyx_t_11, 0+1, __pyx_t_9);
      __pyx_t_9 = 0;
      __pyx_t_8 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_11, NULL); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 169, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_8);
      __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
    }
  }
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_23 = __Pyx_PyObject_to_MemoryviewSlice_dc_double(__pyx_t_8);
  if (unlikely(!__pyx_t_23.memview)) __PYX_ERR(0, 169, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  __pyx_v_NRPhi = __pyx_t_23;
  __pyx_t_23.memview = NULL;
  __pyx_t_23.data = NULL;
+170:     NRPhi0 = np.zeros((Ln,),dtype=int)
  __pyx_t_8 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 170, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);
  __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_8, __pyx_n_s_zeros); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 170, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  __pyx_t_8 = __Pyx_PyInt_From_int(__pyx_v_Ln); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 170, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);
  __pyx_t_11 = PyTuple_New(1); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 170, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_11);
  __Pyx_GIVEREF(__pyx_t_8);
  PyTuple_SET_ITEM(__pyx_t_11, 0, __pyx_t_8);
  __pyx_t_8 = 0;
  __pyx_t_8 = PyTuple_New(1); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 170, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);
  __Pyx_GIVEREF(__pyx_t_11);
  PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_11);
  __pyx_t_11 = 0;
  __pyx_t_11 = PyDict_New(); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 170, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_11);
  if (PyDict_SetItem(__pyx_t_11, __pyx_n_s_dtype, ((PyObject *)(&PyInt_Type))) < 0) __PYX_ERR(0, 170, __pyx_L1_error)
  __pyx_t_9 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_8, __pyx_t_11); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 170, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_9);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
  __pyx_t_21 = __Pyx_PyObject_to_MemoryviewSlice_dc_long(__pyx_t_9);
  if (unlikely(!__pyx_t_21.memview)) __PYX_ERR(0, 170, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
  __pyx_v_NRPhi0 = __pyx_t_21;
  __pyx_t_21.memview = NULL;
  __pyx_t_21.data = NULL;
+171:     nRPhi0, indR0ii = 0, 0
  __pyx_t_15 = 0;
  __pyx_t_24 = 0;
  __pyx_v_nRPhi0 = __pyx_t_15;
  __pyx_v_indR0ii = __pyx_t_24;
+172:     NP, NPhimax = 0, 0
  __pyx_t_24 = 0;
  __pyx_t_25 = 0;
  __pyx_v_NP = __pyx_t_24;
  __pyx_v_NPhimax = __pyx_t_25;
+173:     Rratio = int(Cceil(np.max(Rref)/np.min(Rref)))
  __pyx_t_11 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 173, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_11);
  __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_t_11, __pyx_n_s_max); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 173, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);
  __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
  __pyx_t_11 = NULL;
  if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_8))) {
    __pyx_t_11 = PyMethod_GET_SELF(__pyx_t_8);
    if (likely(__pyx_t_11)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_8);
      __Pyx_INCREF(__pyx_t_11);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_8, function);
    }
  }
  if (!__pyx_t_11) {
    __pyx_t_9 = __Pyx_PyObject_CallOneArg(__pyx_t_8, ((PyObject *)__pyx_v_Rref)); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 173, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_9);
  } else {
    #if CYTHON_FAST_PYCALL
    if (PyFunction_Check(__pyx_t_8)) {
      PyObject *__pyx_temp[2] = {__pyx_t_11, ((PyObject *)__pyx_v_Rref)};
      __pyx_t_9 = __Pyx_PyFunction_FastCall(__pyx_t_8, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 173, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0;
      __Pyx_GOTREF(__pyx_t_9);
    } else
    #endif
    #if CYTHON_FAST_PYCCALL
    if (__Pyx_PyFastCFunction_Check(__pyx_t_8)) {
      PyObject *__pyx_temp[2] = {__pyx_t_11, ((PyObject *)__pyx_v_Rref)};
      __pyx_t_9 = __Pyx_PyCFunction_FastCall(__pyx_t_8, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 173, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0;
      __Pyx_GOTREF(__pyx_t_9);
    } else
    #endif
    {
      __pyx_t_4 = PyTuple_New(1+1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 173, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_GIVEREF(__pyx_t_11); PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_11); __pyx_t_11 = NULL;
      __Pyx_INCREF(((PyObject *)__pyx_v_Rref));
      __Pyx_GIVEREF(((PyObject *)__pyx_v_Rref));
      PyTuple_SET_ITEM(__pyx_t_4, 0+1, ((PyObject *)__pyx_v_Rref));
      __pyx_t_9 = __Pyx_PyObject_Call(__pyx_t_8, __pyx_t_4, NULL); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 173, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_9);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    }
  }
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 173, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_11 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_min); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 173, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_11);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_4 = NULL;
  if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_11))) {
    __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_11);
    if (likely(__pyx_t_4)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_11);
      __Pyx_INCREF(__pyx_t_4);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_11, function);
    }
  }
  if (!__pyx_t_4) {
    __pyx_t_8 = __Pyx_PyObject_CallOneArg(__pyx_t_11, ((PyObject *)__pyx_v_Rref)); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 173, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_8);
  } else {
    #if CYTHON_FAST_PYCALL
    if (PyFunction_Check(__pyx_t_11)) {
      PyObject *__pyx_temp[2] = {__pyx_t_4, ((PyObject *)__pyx_v_Rref)};
      __pyx_t_8 = __Pyx_PyFunction_FastCall(__pyx_t_11, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 173, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
      __Pyx_GOTREF(__pyx_t_8);
    } else
    #endif
    #if CYTHON_FAST_PYCCALL
    if (__Pyx_PyFastCFunction_Check(__pyx_t_11)) {
      PyObject *__pyx_temp[2] = {__pyx_t_4, ((PyObject *)__pyx_v_Rref)};
      __pyx_t_8 = __Pyx_PyCFunction_FastCall(__pyx_t_11, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 173, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
      __Pyx_GOTREF(__pyx_t_8);
    } else
    #endif
    {
      __pyx_t_10 = PyTuple_New(1+1); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 173, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_10);
      __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_10, 0, __pyx_t_4); __pyx_t_4 = NULL;
      __Pyx_INCREF(((PyObject *)__pyx_v_Rref));
      __Pyx_GIVEREF(((PyObject *)__pyx_v_Rref));
      PyTuple_SET_ITEM(__pyx_t_10, 0+1, ((PyObject *)__pyx_v_Rref));
      __pyx_t_8 = __Pyx_PyObject_Call(__pyx_t_11, __pyx_t_10, NULL); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 173, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_8);
      __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
    }
  }
  __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
  __pyx_t_11 = __Pyx_PyNumber_Divide(__pyx_t_9, __pyx_t_8); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 173, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_11);
  __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  __pyx_t_7 = __pyx_PyFloat_AsDouble(__pyx_t_11); if (unlikely((__pyx_t_7 == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 173, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
  __pyx_v_Rratio = ((int)ceil(__pyx_t_7));
+174:     for ii in range(0,Ln):
  __pyx_t_24 = __pyx_v_Ln;
  for (__pyx_t_15 = 0; __pyx_t_15 < __pyx_t_24; __pyx_t_15+=1) {
    __pyx_v_ii = __pyx_t_15;
 175:         # Get the actual RPhi resolution and Phi mesh elements (! depends on R !)
+176:         NRPhi[ii] = Cceil(DPhiMinMax*Rref[ii]/dRPhi)
    __pyx_t_26 = __pyx_v_ii;
    __pyx_t_27 = __pyx_v_ii;
    *((double *) ( /* dim=0 */ ((char *) (((double *) __pyx_v_NRPhi.data) + __pyx_t_27)) )) = ceil(((__pyx_v_DPhiMinMax * (*__Pyx_BufPtrStrided1d(double *, __pyx_pybuffernd_Rref.rcbuffer->pybuffer.buf, __pyx_t_26, __pyx_pybuffernd_Rref.diminfo[0].strides))) / __pyx_v_dRPhi));
+177:         NRPhi_int = int(NRPhi[ii])
    __pyx_t_28 = __pyx_v_ii;
    __pyx_v_NRPhi_int = ((int)(*((double *) ( /* dim=0 */ ((char *) (((double *) __pyx_v_NRPhi.data) + __pyx_t_28)) ))));
+178:         dPhir[ii] = DPhiMinMax/NRPhi[ii]
    __pyx_t_29 = __pyx_v_ii;
    __pyx_t_30 = __pyx_v_ii;
    *((double *) ( /* dim=0 */ ((char *) (((double *) __pyx_v_dPhir.data) + __pyx_t_30)) )) = (__pyx_v_DPhiMinMax / (*((double *) ( /* dim=0 */ ((char *) (((double *) __pyx_v_NRPhi.data) + __pyx_t_29)) ))));
+179:         dRPhir[ii] = dPhir[ii]*Rref[ii]
    __pyx_t_31 = __pyx_v_ii;
    __pyx_t_32 = __pyx_v_ii;
    __pyx_t_33 = __pyx_v_ii;
    *__Pyx_BufPtrStrided1d(double *, __pyx_pybuffernd_dRPhir.rcbuffer->pybuffer.buf, __pyx_t_33, __pyx_pybuffernd_dRPhir.diminfo[0].strides) = ((*((double *) ( /* dim=0 */ ((char *) (((double *) __pyx_v_dPhir.data) + __pyx_t_31)) ))) * (*__Pyx_BufPtrStrided1d(double *, __pyx_pybuffernd_Rref.rcbuffer->pybuffer.buf, __pyx_t_32, __pyx_pybuffernd_Rref.diminfo[0].strides)));
 180:         # Get index and cumulated indices from background
+181:         for jj0 in range(indR0ii,NR0):
    __pyx_t_34 = __pyx_v_NR0;
    for (__pyx_t_35 = __pyx_v_indR0ii; __pyx_t_35 < __pyx_t_34; __pyx_t_35+=1) {
      __pyx_v_jj0 = __pyx_t_35;
+182:             if jj0==Indin[ii]:
      __pyx_t_36 = __pyx_v_ii;
      __pyx_t_1 = ((__pyx_v_jj0 == (*((long *) ( /* dim=0 */ ((char *) (((long *) __pyx_v_Indin.data) + __pyx_t_36)) )))) != 0);
      if (__pyx_t_1) {
/* … */
      }
+183:                 indR0ii = jj0
        __pyx_v_indR0ii = __pyx_v_jj0;
+184:                 break
        goto __pyx_L13_break;
 185:             else:
+186:                 nRPhi0 += <long>Cceil(DPhiMinMax*R0[jj0]/dRPhi)
      /*else*/ {
        __pyx_t_37 = __pyx_v_jj0;
        __pyx_v_nRPhi0 = (__pyx_v_nRPhi0 + ((long)ceil(((__pyx_v_DPhiMinMax * (*__Pyx_BufPtrStrided1d(double *, __pyx_pybuffernd_R0.rcbuffer->pybuffer.buf, __pyx_t_37, __pyx_pybuffernd_R0.diminfo[0].strides))) / __pyx_v_dRPhi))));
+187:                 NRPhi0[ii] = nRPhi0
        __pyx_t_38 = __pyx_v_ii;
        *((long *) ( /* dim=0 */ ((char *) (((long *) __pyx_v_NRPhi0.data) + __pyx_t_38)) )) = __pyx_v_nRPhi0;
      }
    }
    __pyx_L13_break:;
 188:         # Get indices of phi
 189:         # Get the extreme indices of the mesh elements that really need to be created within those limits
+190:         abs0 = Cabs(DPhi0-PhiMinMax[0])
    __pyx_t_11 = PyFloat_FromDouble(__pyx_v_DPhi0); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 190, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_11);
    __pyx_t_8 = __Pyx_GetItemInt(__pyx_v_PhiMinMax, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 0); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 190, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_8);
    __pyx_t_9 = PyNumber_Subtract(__pyx_t_11, __pyx_t_8); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 190, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_9);
    __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    __pyx_t_8 = PyNumber_Absolute(__pyx_t_9); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 190, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_8);
    __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
    __pyx_t_7 = __pyx_PyFloat_AsDouble(__pyx_t_8); if (unlikely((__pyx_t_7 == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 190, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    __pyx_v_abs0 = __pyx_t_7;
+191:         if abs0-dPhir[ii]*Cfloor(abs0/dPhir[ii])<margin*dPhir[ii]:
    __pyx_t_39 = __pyx_v_ii;
    __pyx_t_40 = __pyx_v_ii;
    __pyx_t_41 = __pyx_v_ii;
    __pyx_t_1 = (((__pyx_v_abs0 - ((*((double *) ( /* dim=0 */ ((char *) (((double *) __pyx_v_dPhir.data) + __pyx_t_39)) ))) * floor((__pyx_v_abs0 / (*((double *) ( /* dim=0 */ ((char *) (((double *) __pyx_v_dPhir.data) + __pyx_t_40)) ))))))) < (__pyx_v_margin * (*((double *) ( /* dim=0 */ ((char *) (((double *) __pyx_v_dPhir.data) + __pyx_t_41)) ))))) != 0);
    if (__pyx_t_1) {
/* … */
      goto __pyx_L15;
    }
+192:             nPhi0 = int(Cround((DPhi0-PhiMinMax[0])/dPhir[ii]))
      __pyx_t_8 = PyFloat_FromDouble(__pyx_v_DPhi0); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 192, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_8);
      __pyx_t_9 = __Pyx_GetItemInt(__pyx_v_PhiMinMax, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 0); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 192, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_9);
      __pyx_t_11 = PyNumber_Subtract(__pyx_t_8, __pyx_t_9); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 192, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_11);
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
      __pyx_t_42 = __pyx_v_ii;
      __pyx_t_9 = PyFloat_FromDouble((*((double *) ( /* dim=0 */ ((char *) (((double *) __pyx_v_dPhir.data) + __pyx_t_42)) )))); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 192, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_9);
      __pyx_t_8 = __Pyx_PyNumber_Divide(__pyx_t_11, __pyx_t_9); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 192, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_8);
      __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
      __pyx_t_7 = __pyx_PyFloat_AsDouble(__pyx_t_8); if (unlikely((__pyx_t_7 == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 192, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
      __pyx_v_nPhi0 = ((int)round(__pyx_t_7));
 193:         else:
+194:             nPhi0 = int(Cfloor((DPhi0-PhiMinMax[0])/dPhir[ii]))
    /*else*/ {
      __pyx_t_8 = PyFloat_FromDouble(__pyx_v_DPhi0); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 194, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_8);
      __pyx_t_9 = __Pyx_GetItemInt(__pyx_v_PhiMinMax, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 0); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 194, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_9);
      __pyx_t_11 = PyNumber_Subtract(__pyx_t_8, __pyx_t_9); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 194, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_11);
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
      __pyx_t_43 = __pyx_v_ii;
      __pyx_t_9 = PyFloat_FromDouble((*((double *) ( /* dim=0 */ ((char *) (((double *) __pyx_v_dPhir.data) + __pyx_t_43)) )))); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 194, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_9);
      __pyx_t_8 = __Pyx_PyNumber_Divide(__pyx_t_11, __pyx_t_9); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 194, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_8);
      __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
      __pyx_t_7 = __pyx_PyFloat_AsDouble(__pyx_t_8); if (unlikely((__pyx_t_7 == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 194, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
      __pyx_v_nPhi0 = ((int)floor(__pyx_t_7));
    }
    __pyx_L15:;
+195:         abs1 = Cabs(DPhi1-PhiMinMax[0])
    __pyx_t_8 = PyFloat_FromDouble(__pyx_v_DPhi1); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 195, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_8);
    __pyx_t_9 = __Pyx_GetItemInt(__pyx_v_PhiMinMax, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 0); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 195, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_9);
    __pyx_t_11 = PyNumber_Subtract(__pyx_t_8, __pyx_t_9); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 195, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_11);
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
    __pyx_t_9 = PyNumber_Absolute(__pyx_t_11); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 195, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_9);
    __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
    __pyx_t_7 = __pyx_PyFloat_AsDouble(__pyx_t_9); if (unlikely((__pyx_t_7 == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 195, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
    __pyx_v_abs1 = __pyx_t_7;
+196:         if abs1-dPhir[ii]*Cfloor(abs1/dPhir[ii])<margin*dPhir[ii]:
    __pyx_t_44 = __pyx_v_ii;
    __pyx_t_45 = __pyx_v_ii;
    __pyx_t_46 = __pyx_v_ii;
    __pyx_t_1 = (((__pyx_v_abs1 - ((*((double *) ( /* dim=0 */ ((char *) (((double *) __pyx_v_dPhir.data) + __pyx_t_44)) ))) * floor((__pyx_v_abs1 / (*((double *) ( /* dim=0 */ ((char *) (((double *) __pyx_v_dPhir.data) + __pyx_t_45)) ))))))) < (__pyx_v_margin * (*((double *) ( /* dim=0 */ ((char *) (((double *) __pyx_v_dPhir.data) + __pyx_t_46)) ))))) != 0);
    if (__pyx_t_1) {
/* … */
      goto __pyx_L16;
    }
+197:             nPhi1 = int(Cround((DPhi1-PhiMinMax[0])/dPhir[ii])-1)
      __pyx_t_9 = PyFloat_FromDouble(__pyx_v_DPhi1); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 197, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_9);
      __pyx_t_11 = __Pyx_GetItemInt(__pyx_v_PhiMinMax, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 0); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 197, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_11);
      __pyx_t_8 = PyNumber_Subtract(__pyx_t_9, __pyx_t_11); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 197, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_8);
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
      __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
      __pyx_t_47 = __pyx_v_ii;
      __pyx_t_11 = PyFloat_FromDouble((*((double *) ( /* dim=0 */ ((char *) (((double *) __pyx_v_dPhir.data) + __pyx_t_47)) )))); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 197, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_11);
      __pyx_t_9 = __Pyx_PyNumber_Divide(__pyx_t_8, __pyx_t_11); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 197, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_9);
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
      __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
      __pyx_t_7 = __pyx_PyFloat_AsDouble(__pyx_t_9); if (unlikely((__pyx_t_7 == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 197, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
      __pyx_v_nPhi1 = ((int)(round(__pyx_t_7) - 1.0));
 198:         else:
+199:             nPhi1 = int(Cfloor((DPhi1-PhiMinMax[0])/dPhir[ii]))
    /*else*/ {
      __pyx_t_9 = PyFloat_FromDouble(__pyx_v_DPhi1); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 199, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_9);
      __pyx_t_11 = __Pyx_GetItemInt(__pyx_v_PhiMinMax, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 0); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 199, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_11);
      __pyx_t_8 = PyNumber_Subtract(__pyx_t_9, __pyx_t_11); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 199, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_8);
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
      __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
      __pyx_t_48 = __pyx_v_ii;
      __pyx_t_11 = PyFloat_FromDouble((*((double *) ( /* dim=0 */ ((char *) (((double *) __pyx_v_dPhir.data) + __pyx_t_48)) )))); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 199, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_11);
      __pyx_t_9 = __Pyx_PyNumber_Divide(__pyx_t_8, __pyx_t_11); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 199, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_9);
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
      __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
      __pyx_t_7 = __pyx_PyFloat_AsDouble(__pyx_t_9); if (unlikely((__pyx_t_7 == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 199, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
      __pyx_v_nPhi1 = ((int)floor(__pyx_t_7));
    }
    __pyx_L16:;
+200:         if DPhi0<DPhi1:
    __pyx_t_1 = ((__pyx_v_DPhi0 < __pyx_v_DPhi1) != 0);
    if (__pyx_t_1) {
/* … */
      goto __pyx_L17;
    }
+201:             Phin[ii] = nPhi1+1-nPhi0
      __pyx_t_49 = __pyx_v_ii;
      *((long *) ( /* dim=0 */ ((char *) (((long *) __pyx_v_Phin.data) + __pyx_t_49)) )) = ((__pyx_v_nPhi1 + 1) - __pyx_v_nPhi0);
+202:             if ii==0:
      __pyx_t_1 = ((__pyx_v_ii == 0) != 0);
      if (__pyx_t_1) {
/* … */
      }
+203:                 indI = np.ones((Ln,Phin[ii]*Rratio+1))
        __pyx_t_11 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 203, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_11);
        __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_t_11, __pyx_n_s_ones); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 203, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_8);
        __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
        __pyx_t_11 = __Pyx_PyInt_From_int(__pyx_v_Ln); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 203, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_11);
        __pyx_t_50 = __pyx_v_ii;
        __pyx_t_10 = __Pyx_PyInt_From_long((((*((long *) ( /* dim=0 */ ((char *) (((long *) __pyx_v_Phin.data) + __pyx_t_50)) ))) * __pyx_v_Rratio) + 1)); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 203, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_10);
        __pyx_t_4 = PyTuple_New(2); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 203, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_4);
        __Pyx_GIVEREF(__pyx_t_11);
        PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_11);
        __Pyx_GIVEREF(__pyx_t_10);
        PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_t_10);
        __pyx_t_11 = 0;
        __pyx_t_10 = 0;
        __pyx_t_10 = NULL;
        if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_8))) {
          __pyx_t_10 = PyMethod_GET_SELF(__pyx_t_8);
          if (likely(__pyx_t_10)) {
            PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_8);
            __Pyx_INCREF(__pyx_t_10);
            __Pyx_INCREF(function);
            __Pyx_DECREF_SET(__pyx_t_8, function);
          }
        }
        if (!__pyx_t_10) {
          __pyx_t_9 = __Pyx_PyObject_CallOneArg(__pyx_t_8, __pyx_t_4); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 203, __pyx_L1_error)
          __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
          __Pyx_GOTREF(__pyx_t_9);
        } else {
          #if CYTHON_FAST_PYCALL
          if (PyFunction_Check(__pyx_t_8)) {
            PyObject *__pyx_temp[2] = {__pyx_t_10, __pyx_t_4};
            __pyx_t_9 = __Pyx_PyFunction_FastCall(__pyx_t_8, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 203, __pyx_L1_error)
            __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
            __Pyx_GOTREF(__pyx_t_9);
            __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
          } else
          #endif
          #if CYTHON_FAST_PYCCALL
          if (__Pyx_PyFastCFunction_Check(__pyx_t_8)) {
            PyObject *__pyx_temp[2] = {__pyx_t_10, __pyx_t_4};
            __pyx_t_9 = __Pyx_PyCFunction_FastCall(__pyx_t_8, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 203, __pyx_L1_error)
            __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
            __Pyx_GOTREF(__pyx_t_9);
            __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
          } else
          #endif
          {
            __pyx_t_11 = PyTuple_New(1+1); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 203, __pyx_L1_error)
            __Pyx_GOTREF(__pyx_t_11);
            __Pyx_GIVEREF(__pyx_t_10); PyTuple_SET_ITEM(__pyx_t_11, 0, __pyx_t_10); __pyx_t_10 = NULL;
            __Pyx_GIVEREF(__pyx_t_4);
            PyTuple_SET_ITEM(__pyx_t_11, 0+1, __pyx_t_4);
            __pyx_t_4 = 0;
            __pyx_t_9 = __Pyx_PyObject_Call(__pyx_t_8, __pyx_t_11, NULL); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 203, __pyx_L1_error)
            __Pyx_GOTREF(__pyx_t_9);
            __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
          }
        }
        __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
        if (!(likely(((__pyx_t_9) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_9, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 203, __pyx_L1_error)
        __pyx_t_14 = ((PyArrayObject *)__pyx_t_9);
        {
          __Pyx_BufFmt_StackElem __pyx_stack[1];
          __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_indI.rcbuffer->pybuffer);
          __pyx_t_34 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_indI.rcbuffer->pybuffer, (PyObject*)__pyx_t_14, &__Pyx_TypeInfo_double, PyBUF_FORMAT| PyBUF_STRIDES| PyBUF_WRITABLE, 2, 0, __pyx_stack);
          if (unlikely(__pyx_t_34 < 0)) {
            PyErr_Fetch(&__pyx_t_16, &__pyx_t_17, &__pyx_t_18);
            if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_indI.rcbuffer->pybuffer, (PyObject*)__pyx_v_indI, &__Pyx_TypeInfo_double, PyBUF_FORMAT| PyBUF_STRIDES| PyBUF_WRITABLE, 2, 0, __pyx_stack) == -1)) {
              Py_XDECREF(__pyx_t_16); Py_XDECREF(__pyx_t_17); Py_XDECREF(__pyx_t_18);
              __Pyx_RaiseBufferFallbackError();
            } else {
              PyErr_Restore(__pyx_t_16, __pyx_t_17, __pyx_t_18);
            }
          }
          __pyx_pybuffernd_indI.diminfo[0].strides = __pyx_pybuffernd_indI.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_indI.diminfo[0].shape = __pyx_pybuffernd_indI.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_indI.diminfo[1].strides = __pyx_pybuffernd_indI.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_indI.diminfo[1].shape = __pyx_pybuffernd_indI.rcbuffer->pybuffer.shape[1];
          if (unlikely(__pyx_t_34 < 0)) __PYX_ERR(0, 203, __pyx_L1_error)
        }
        __pyx_t_14 = 0;
        __Pyx_XDECREF_SET(__pyx_v_indI, ((PyArrayObject *)__pyx_t_9));
        __pyx_t_9 = 0;
+204:             for jj in range(0,Phin[ii]):
      __pyx_t_51 = __pyx_v_ii;
      __pyx_t_25 = (*((long *) ( /* dim=0 */ ((char *) (((long *) __pyx_v_Phin.data) + __pyx_t_51)) )));
      for (__pyx_t_34 = 0; __pyx_t_34 < __pyx_t_25; __pyx_t_34+=1) {
        __pyx_v_jj = __pyx_t_34;
+205:                 indI[ii,jj] = <double>( nPhi0+jj )
        __pyx_t_52 = __pyx_v_ii;
        __pyx_t_53 = __pyx_v_jj;
        *__Pyx_BufPtrStrided2d(double *, __pyx_pybuffernd_indI.rcbuffer->pybuffer.buf, __pyx_t_52, __pyx_pybuffernd_indI.diminfo[0].strides, __pyx_t_53, __pyx_pybuffernd_indI.diminfo[1].strides) = ((double)(__pyx_v_nPhi0 + __pyx_v_jj));
      }
 206:         else:
+207:             Phin[ii] = nPhi1+1+NRPhi_int-nPhi0
    /*else*/ {
      __pyx_t_54 = __pyx_v_ii;
      *((long *) ( /* dim=0 */ ((char *) (((long *) __pyx_v_Phin.data) + __pyx_t_54)) )) = (((__pyx_v_nPhi1 + 1) + __pyx_v_NRPhi_int) - __pyx_v_nPhi0);
+208:             if ii==0:
      __pyx_t_1 = ((__pyx_v_ii == 0) != 0);
      if (__pyx_t_1) {
/* … */
      }
+209:                 indI = np.ones((Ln,Phin[ii]*Rratio+1))
        __pyx_t_8 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 209, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_8);
        __pyx_t_11 = __Pyx_PyObject_GetAttrStr(__pyx_t_8, __pyx_n_s_ones); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 209, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_11);
        __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
        __pyx_t_8 = __Pyx_PyInt_From_int(__pyx_v_Ln); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 209, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_8);
        __pyx_t_55 = __pyx_v_ii;
        __pyx_t_4 = __Pyx_PyInt_From_long((((*((long *) ( /* dim=0 */ ((char *) (((long *) __pyx_v_Phin.data) + __pyx_t_55)) ))) * __pyx_v_Rratio) + 1)); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 209, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_4);
        __pyx_t_10 = PyTuple_New(2); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 209, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_10);
        __Pyx_GIVEREF(__pyx_t_8);
        PyTuple_SET_ITEM(__pyx_t_10, 0, __pyx_t_8);
        __Pyx_GIVEREF(__pyx_t_4);
        PyTuple_SET_ITEM(__pyx_t_10, 1, __pyx_t_4);
        __pyx_t_8 = 0;
        __pyx_t_4 = 0;
        __pyx_t_4 = NULL;
        if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_11))) {
          __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_11);
          if (likely(__pyx_t_4)) {
            PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_11);
            __Pyx_INCREF(__pyx_t_4);
            __Pyx_INCREF(function);
            __Pyx_DECREF_SET(__pyx_t_11, function);
          }
        }
        if (!__pyx_t_4) {
          __pyx_t_9 = __Pyx_PyObject_CallOneArg(__pyx_t_11, __pyx_t_10); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 209, __pyx_L1_error)
          __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
          __Pyx_GOTREF(__pyx_t_9);
        } else {
          #if CYTHON_FAST_PYCALL
          if (PyFunction_Check(__pyx_t_11)) {
            PyObject *__pyx_temp[2] = {__pyx_t_4, __pyx_t_10};
            __pyx_t_9 = __Pyx_PyFunction_FastCall(__pyx_t_11, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 209, __pyx_L1_error)
            __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
            __Pyx_GOTREF(__pyx_t_9);
            __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
          } else
          #endif
          #if CYTHON_FAST_PYCCALL
          if (__Pyx_PyFastCFunction_Check(__pyx_t_11)) {
            PyObject *__pyx_temp[2] = {__pyx_t_4, __pyx_t_10};
            __pyx_t_9 = __Pyx_PyCFunction_FastCall(__pyx_t_11, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 209, __pyx_L1_error)
            __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
            __Pyx_GOTREF(__pyx_t_9);
            __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
          } else
          #endif
          {
            __pyx_t_8 = PyTuple_New(1+1); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 209, __pyx_L1_error)
            __Pyx_GOTREF(__pyx_t_8);
            __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_4); __pyx_t_4 = NULL;
            __Pyx_GIVEREF(__pyx_t_10);
            PyTuple_SET_ITEM(__pyx_t_8, 0+1, __pyx_t_10);
            __pyx_t_10 = 0;
            __pyx_t_9 = __Pyx_PyObject_Call(__pyx_t_11, __pyx_t_8, NULL); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 209, __pyx_L1_error)
            __Pyx_GOTREF(__pyx_t_9);
            __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
          }
        }
        __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
        if (!(likely(((__pyx_t_9) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_9, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 209, __pyx_L1_error)
        __pyx_t_14 = ((PyArrayObject *)__pyx_t_9);
        {
          __Pyx_BufFmt_StackElem __pyx_stack[1];
          __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_indI.rcbuffer->pybuffer);
          __pyx_t_34 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_indI.rcbuffer->pybuffer, (PyObject*)__pyx_t_14, &__Pyx_TypeInfo_double, PyBUF_FORMAT| PyBUF_STRIDES| PyBUF_WRITABLE, 2, 0, __pyx_stack);
          if (unlikely(__pyx_t_34 < 0)) {
            PyErr_Fetch(&__pyx_t_18, &__pyx_t_17, &__pyx_t_16);
            if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_indI.rcbuffer->pybuffer, (PyObject*)__pyx_v_indI, &__Pyx_TypeInfo_double, PyBUF_FORMAT| PyBUF_STRIDES| PyBUF_WRITABLE, 2, 0, __pyx_stack) == -1)) {
              Py_XDECREF(__pyx_t_18); Py_XDECREF(__pyx_t_17); Py_XDECREF(__pyx_t_16);
              __Pyx_RaiseBufferFallbackError();
            } else {
              PyErr_Restore(__pyx_t_18, __pyx_t_17, __pyx_t_16);
            }
          }
          __pyx_pybuffernd_indI.diminfo[0].strides = __pyx_pybuffernd_indI.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_indI.diminfo[0].shape = __pyx_pybuffernd_indI.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_indI.diminfo[1].strides = __pyx_pybuffernd_indI.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_indI.diminfo[1].shape = __pyx_pybuffernd_indI.rcbuffer->pybuffer.shape[1];
          if (unlikely(__pyx_t_34 < 0)) __PYX_ERR(0, 209, __pyx_L1_error)
        }
        __pyx_t_14 = 0;
        __Pyx_XDECREF_SET(__pyx_v_indI, ((PyArrayObject *)__pyx_t_9));
        __pyx_t_9 = 0;
+210:             for jj in range(0,NRPhi_int-nPhi0):
      __pyx_t_34 = (__pyx_v_NRPhi_int - __pyx_v_nPhi0);
      for (__pyx_t_35 = 0; __pyx_t_35 < __pyx_t_34; __pyx_t_35+=1) {
        __pyx_v_jj = __pyx_t_35;
+211:                 indI[ii,jj] = <double>( nPhi0+jj )
        __pyx_t_56 = __pyx_v_ii;
        __pyx_t_57 = __pyx_v_jj;
        *__Pyx_BufPtrStrided2d(double *, __pyx_pybuffernd_indI.rcbuffer->pybuffer.buf, __pyx_t_56, __pyx_pybuffernd_indI.diminfo[0].strides, __pyx_t_57, __pyx_pybuffernd_indI.diminfo[1].strides) = ((double)(__pyx_v_nPhi0 + __pyx_v_jj));
      }
+212:             for jj in range(NRPhi_int-nPhi0,Phin[ii]):
      __pyx_t_58 = __pyx_v_ii;
      __pyx_t_25 = (*((long *) ( /* dim=0 */ ((char *) (((long *) __pyx_v_Phin.data) + __pyx_t_58)) )));
      for (__pyx_t_34 = (__pyx_v_NRPhi_int - __pyx_v_nPhi0); __pyx_t_34 < __pyx_t_25; __pyx_t_34+=1) {
        __pyx_v_jj = __pyx_t_34;
+213:                 indI[ii,jj] = <double>( jj- (NRPhi_int-nPhi0) )
        __pyx_t_59 = __pyx_v_ii;
        __pyx_t_60 = __pyx_v_jj;
        *__Pyx_BufPtrStrided2d(double *, __pyx_pybuffernd_indI.rcbuffer->pybuffer.buf, __pyx_t_59, __pyx_pybuffernd_indI.diminfo[0].strides, __pyx_t_60, __pyx_pybuffernd_indI.diminfo[1].strides) = ((double)(__pyx_v_jj - (__pyx_v_NRPhi_int - __pyx_v_nPhi0)));
      }
    }
    __pyx_L17:;
+214:         NP += Phin[ii]
    __pyx_t_61 = __pyx_v_ii;
    __pyx_v_NP = (__pyx_v_NP + (*((long *) ( /* dim=0 */ ((char *) (((long *) __pyx_v_Phin.data) + __pyx_t_61)) ))));
  }
 215: 
 216:     # Finish counting to get total number of points
+217:     if jj0<=NR0-1:
  __pyx_t_1 = ((__pyx_v_jj0 <= (__pyx_v_NR0 - 1)) != 0);
  if (__pyx_t_1) {
/* … */
  }
+218:         for jj0 in range(indR0ii,NR0):
    __pyx_t_24 = __pyx_v_NR0;
    for (__pyx_t_15 = __pyx_v_indR0ii; __pyx_t_15 < __pyx_t_24; __pyx_t_15+=1) {
      __pyx_v_jj0 = __pyx_t_15;
+219:             nRPhi0 += <long>Cceil(DPhiMinMax*R0[jj0]/dRPhi)
      __pyx_t_62 = __pyx_v_jj0;
      __pyx_v_nRPhi0 = (__pyx_v_nRPhi0 + ((long)ceil(((__pyx_v_DPhiMinMax * (*__Pyx_BufPtrStrided1d(double *, __pyx_pybuffernd_R0.rcbuffer->pybuffer.buf, __pyx_t_62, __pyx_pybuffernd_R0.diminfo[0].strides))) / __pyx_v_dRPhi))));
    }
 220: 
 221:     # Compute Pts, dV and ind
+222:     Pts = np.empty((3,NP))
  __pyx_t_11 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 222, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_11);
  __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_t_11, __pyx_n_s_empty); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 222, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);
  __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
  __pyx_t_11 = __Pyx_PyInt_From_int(__pyx_v_NP); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 222, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_11);
  __pyx_t_10 = PyTuple_New(2); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 222, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_10);
  __Pyx_INCREF(__pyx_int_3);
  __Pyx_GIVEREF(__pyx_int_3);
  PyTuple_SET_ITEM(__pyx_t_10, 0, __pyx_int_3);
  __Pyx_GIVEREF(__pyx_t_11);
  PyTuple_SET_ITEM(__pyx_t_10, 1, __pyx_t_11);
  __pyx_t_11 = 0;
  __pyx_t_11 = NULL;
  if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_8))) {
    __pyx_t_11 = PyMethod_GET_SELF(__pyx_t_8);
    if (likely(__pyx_t_11)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_8);
      __Pyx_INCREF(__pyx_t_11);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_8, function);
    }
  }
  if (!__pyx_t_11) {
    __pyx_t_9 = __Pyx_PyObject_CallOneArg(__pyx_t_8, __pyx_t_10); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 222, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
    __Pyx_GOTREF(__pyx_t_9);
  } else {
    #if CYTHON_FAST_PYCALL
    if (PyFunction_Check(__pyx_t_8)) {
      PyObject *__pyx_temp[2] = {__pyx_t_11, __pyx_t_10};
      __pyx_t_9 = __Pyx_PyFunction_FastCall(__pyx_t_8, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 222, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0;
      __Pyx_GOTREF(__pyx_t_9);
      __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
    } else
    #endif
    #if CYTHON_FAST_PYCCALL
    if (__Pyx_PyFastCFunction_Check(__pyx_t_8)) {
      PyObject *__pyx_temp[2] = {__pyx_t_11, __pyx_t_10};
      __pyx_t_9 = __Pyx_PyCFunction_FastCall(__pyx_t_8, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 222, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0;
      __Pyx_GOTREF(__pyx_t_9);
      __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
    } else
    #endif
    {
      __pyx_t_4 = PyTuple_New(1+1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 222, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_GIVEREF(__pyx_t_11); PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_11); __pyx_t_11 = NULL;
      __Pyx_GIVEREF(__pyx_t_10);
      PyTuple_SET_ITEM(__pyx_t_4, 0+1, __pyx_t_10);
      __pyx_t_10 = 0;
      __pyx_t_9 = __Pyx_PyObject_Call(__pyx_t_8, __pyx_t_4, NULL); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 222, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_9);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    }
  }
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  if (!(likely(((__pyx_t_9) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_9, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 222, __pyx_L1_error)
  __pyx_t_14 = ((PyArrayObject *)__pyx_t_9);
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_Pts.rcbuffer->pybuffer);
    __pyx_t_24 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_Pts.rcbuffer->pybuffer, (PyObject*)__pyx_t_14, &__Pyx_TypeInfo_double, PyBUF_FORMAT| PyBUF_STRIDES| PyBUF_WRITABLE, 2, 0, __pyx_stack);
    if (unlikely(__pyx_t_24 < 0)) {
      PyErr_Fetch(&__pyx_t_16, &__pyx_t_17, &__pyx_t_18);
      if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_Pts.rcbuffer->pybuffer, (PyObject*)__pyx_v_Pts, &__Pyx_TypeInfo_double, PyBUF_FORMAT| PyBUF_STRIDES| PyBUF_WRITABLE, 2, 0, __pyx_stack) == -1)) {
        Py_XDECREF(__pyx_t_16); Py_XDECREF(__pyx_t_17); Py_XDECREF(__pyx_t_18);
        __Pyx_RaiseBufferFallbackError();
      } else {
        PyErr_Restore(__pyx_t_16, __pyx_t_17, __pyx_t_18);
      }
    }
    __pyx_pybuffernd_Pts.diminfo[0].strides = __pyx_pybuffernd_Pts.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_Pts.diminfo[0].shape = __pyx_pybuffernd_Pts.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_Pts.diminfo[1].strides = __pyx_pybuffernd_Pts.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_Pts.diminfo[1].shape = __pyx_pybuffernd_Pts.rcbuffer->pybuffer.shape[1];
    if (unlikely(__pyx_t_24 < 0)) __PYX_ERR(0, 222, __pyx_L1_error)
  }
  __pyx_t_14 = 0;
  __pyx_v_Pts = ((PyArrayObject *)__pyx_t_9);
  __pyx_t_9 = 0;
+223:     ind = np.empty((NP,))
  __pyx_t_8 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 223, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);
  __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_8, __pyx_n_s_empty); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 223, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  __pyx_t_8 = __Pyx_PyInt_From_int(__pyx_v_NP); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 223, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);
  __pyx_t_10 = PyTuple_New(1); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 223, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_10);
  __Pyx_GIVEREF(__pyx_t_8);
  PyTuple_SET_ITEM(__pyx_t_10, 0, __pyx_t_8);
  __pyx_t_8 = 0;
  __pyx_t_8 = NULL;
  if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_4))) {
    __pyx_t_8 = PyMethod_GET_SELF(__pyx_t_4);
    if (likely(__pyx_t_8)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
      __Pyx_INCREF(__pyx_t_8);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_4, function);
    }
  }
  if (!__pyx_t_8) {
    __pyx_t_9 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_10); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 223, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
    __Pyx_GOTREF(__pyx_t_9);
  } else {
    #if CYTHON_FAST_PYCALL
    if (PyFunction_Check(__pyx_t_4)) {
      PyObject *__pyx_temp[2] = {__pyx_t_8, __pyx_t_10};
      __pyx_t_9 = __Pyx_PyFunction_FastCall(__pyx_t_4, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 223, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
      __Pyx_GOTREF(__pyx_t_9);
      __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
    } else
    #endif
    #if CYTHON_FAST_PYCCALL
    if (__Pyx_PyFastCFunction_Check(__pyx_t_4)) {
      PyObject *__pyx_temp[2] = {__pyx_t_8, __pyx_t_10};
      __pyx_t_9 = __Pyx_PyCFunction_FastCall(__pyx_t_4, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 223, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
      __Pyx_GOTREF(__pyx_t_9);
      __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
    } else
    #endif
    {
      __pyx_t_11 = PyTuple_New(1+1); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 223, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_11);
      __Pyx_GIVEREF(__pyx_t_8); PyTuple_SET_ITEM(__pyx_t_11, 0, __pyx_t_8); __pyx_t_8 = NULL;
      __Pyx_GIVEREF(__pyx_t_10);
      PyTuple_SET_ITEM(__pyx_t_11, 0+1, __pyx_t_10);
      __pyx_t_10 = 0;
      __pyx_t_9 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_11, NULL); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 223, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_9);
      __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
    }
  }
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  if (!(likely(((__pyx_t_9) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_9, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 223, __pyx_L1_error)
  __pyx_t_19 = ((PyArrayObject *)__pyx_t_9);
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_ind.rcbuffer->pybuffer);
    __pyx_t_24 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_ind.rcbuffer->pybuffer, (PyObject*)__pyx_t_19, &__Pyx_TypeInfo_double, PyBUF_FORMAT| PyBUF_STRIDES| PyBUF_WRITABLE, 1, 0, __pyx_stack);
    if (unlikely(__pyx_t_24 < 0)) {
      PyErr_Fetch(&__pyx_t_18, &__pyx_t_17, &__pyx_t_16);
      if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_ind.rcbuffer->pybuffer, (PyObject*)__pyx_v_ind, &__Pyx_TypeInfo_double, PyBUF_FORMAT| PyBUF_STRIDES| PyBUF_WRITABLE, 1, 0, __pyx_stack) == -1)) {
        Py_XDECREF(__pyx_t_18); Py_XDECREF(__pyx_t_17); Py_XDECREF(__pyx_t_16);
        __Pyx_RaiseBufferFallbackError();
      } else {
        PyErr_Restore(__pyx_t_18, __pyx_t_17, __pyx_t_16);
      }
    }
    __pyx_pybuffernd_ind.diminfo[0].strides = __pyx_pybuffernd_ind.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_ind.diminfo[0].shape = __pyx_pybuffernd_ind.rcbuffer->pybuffer.shape[0];
    if (unlikely(__pyx_t_24 < 0)) __PYX_ERR(0, 223, __pyx_L1_error)
  }
  __pyx_t_19 = 0;
  __pyx_v_ind = ((PyArrayObject *)__pyx_t_9);
  __pyx_t_9 = 0;
+224:     dS = np.empty((NP,))
  __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 224, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_11 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_empty); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 224, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_11);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_4 = __Pyx_PyInt_From_int(__pyx_v_NP); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 224, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_10 = PyTuple_New(1); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 224, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_10);
  __Pyx_GIVEREF(__pyx_t_4);
  PyTuple_SET_ITEM(__pyx_t_10, 0, __pyx_t_4);
  __pyx_t_4 = 0;
  __pyx_t_4 = NULL;
  if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_11))) {
    __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_11);
    if (likely(__pyx_t_4)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_11);
      __Pyx_INCREF(__pyx_t_4);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_11, function);
    }
  }
  if (!__pyx_t_4) {
    __pyx_t_9 = __Pyx_PyObject_CallOneArg(__pyx_t_11, __pyx_t_10); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 224, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
    __Pyx_GOTREF(__pyx_t_9);
  } else {
    #if CYTHON_FAST_PYCALL
    if (PyFunction_Check(__pyx_t_11)) {
      PyObject *__pyx_temp[2] = {__pyx_t_4, __pyx_t_10};
      __pyx_t_9 = __Pyx_PyFunction_FastCall(__pyx_t_11, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 224, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
      __Pyx_GOTREF(__pyx_t_9);
      __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
    } else
    #endif
    #if CYTHON_FAST_PYCCALL
    if (__Pyx_PyFastCFunction_Check(__pyx_t_11)) {
      PyObject *__pyx_temp[2] = {__pyx_t_4, __pyx_t_10};
      __pyx_t_9 = __Pyx_PyCFunction_FastCall(__pyx_t_11, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 224, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
      __Pyx_GOTREF(__pyx_t_9);
      __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
    } else
    #endif
    {
      __pyx_t_8 = PyTuple_New(1+1); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 224, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_8);
      __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_4); __pyx_t_4 = NULL;
      __Pyx_GIVEREF(__pyx_t_10);
      PyTuple_SET_ITEM(__pyx_t_8, 0+1, __pyx_t_10);
      __pyx_t_10 = 0;
      __pyx_t_9 = __Pyx_PyObject_Call(__pyx_t_11, __pyx_t_8, NULL); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 224, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_9);
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    }
  }
  __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
  if (!(likely(((__pyx_t_9) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_9, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 224, __pyx_L1_error)
  __pyx_t_19 = ((PyArrayObject *)__pyx_t_9);
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_dS.rcbuffer->pybuffer);
    __pyx_t_24 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_dS.rcbuffer->pybuffer, (PyObject*)__pyx_t_19, &__Pyx_TypeInfo_double, PyBUF_FORMAT| PyBUF_STRIDES| PyBUF_WRITABLE, 1, 0, __pyx_stack);
    if (unlikely(__pyx_t_24 < 0)) {
      PyErr_Fetch(&__pyx_t_16, &__pyx_t_17, &__pyx_t_18);
      if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_dS.rcbuffer->pybuffer, (PyObject*)__pyx_v_dS, &__Pyx_TypeInfo_double, PyBUF_FORMAT| PyBUF_STRIDES| PyBUF_WRITABLE, 1, 0, __pyx_stack) == -1)) {
        Py_XDECREF(__pyx_t_16); Py_XDECREF(__pyx_t_17); Py_XDECREF(__pyx_t_18);
        __Pyx_RaiseBufferFallbackError();
      } else {
        PyErr_Restore(__pyx_t_16, __pyx_t_17, __pyx_t_18);
      }
    }
    __pyx_pybuffernd_dS.diminfo[0].strides = __pyx_pybuffernd_dS.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_dS.diminfo[0].shape = __pyx_pybuffernd_dS.rcbuffer->pybuffer.shape[0];
    if (unlikely(__pyx_t_24 < 0)) __PYX_ERR(0, 224, __pyx_L1_error)
  }
  __pyx_t_19 = 0;
  __pyx_v_dS = ((PyArrayObject *)__pyx_t_9);
  __pyx_t_9 = 0;
 225:     # This triple loop is the longest part, it takes ~90% of the CPU time
+226:     NP = 0
  __pyx_v_NP = 0;
+227:     if Out.lower()=='(x,y,z)':
  __pyx_t_11 = __Pyx_PyObject_GetAttrStr(__pyx_v_Out, __pyx_n_s_lower); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 227, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_11);
  __pyx_t_8 = NULL;
  if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_11))) {
    __pyx_t_8 = PyMethod_GET_SELF(__pyx_t_11);
    if (likely(__pyx_t_8)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_11);
      __Pyx_INCREF(__pyx_t_8);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_11, function);
    }
  }
  if (__pyx_t_8) {
    __pyx_t_9 = __Pyx_PyObject_CallOneArg(__pyx_t_11, __pyx_t_8); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 227, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  } else {
    __pyx_t_9 = __Pyx_PyObject_CallNoArg(__pyx_t_11); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 227, __pyx_L1_error)
  }
  __Pyx_GOTREF(__pyx_t_9);
  __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
  __pyx_t_1 = (__Pyx_PyUnicode_Equals(__pyx_t_9, __pyx_kp_u_x_y_z, Py_EQ)); if (unlikely(__pyx_t_1 < 0)) __PYX_ERR(0, 227, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
  if (__pyx_t_1) {
/* … */
    goto __pyx_L29;
  }
+228:         for ii in range(0,Ln):
    __pyx_t_24 = __pyx_v_Ln;
    for (__pyx_t_15 = 0; __pyx_t_15 < __pyx_t_24; __pyx_t_15+=1) {
      __pyx_v_ii = __pyx_t_15;
+229:             for jj in range(0,Phin[ii]):
      __pyx_t_63 = __pyx_v_ii;
      __pyx_t_25 = (*((long *) ( /* dim=0 */ ((char *) (((long *) __pyx_v_Phin.data) + __pyx_t_63)) )));
      for (__pyx_t_34 = 0; __pyx_t_34 < __pyx_t_25; __pyx_t_34+=1) {
        __pyx_v_jj = __pyx_t_34;
+230:                 indiijj = indI[ii,jj]
        __pyx_t_64 = __pyx_v_ii;
        __pyx_t_65 = __pyx_v_jj;
        __pyx_v_indiijj = (*__Pyx_BufPtrStrided2d(double *, __pyx_pybuffernd_indI.rcbuffer->pybuffer.buf, __pyx_t_64, __pyx_pybuffernd_indI.diminfo[0].strides, __pyx_t_65, __pyx_pybuffernd_indI.diminfo[1].strides));
+231:                 phi = PhiMinMax[0] + (0.5+indiijj)*dPhir[ii]
        __pyx_t_9 = __Pyx_GetItemInt(__pyx_v_PhiMinMax, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 0); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 231, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_9);
        __pyx_t_66 = __pyx_v_ii;
        __pyx_t_11 = PyFloat_FromDouble(((0.5 + __pyx_v_indiijj) * (*((double *) ( /* dim=0 */ ((char *) (((double *) __pyx_v_dPhir.data) + __pyx_t_66)) ))))); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 231, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_11);
        __pyx_t_8 = PyNumber_Add(__pyx_t_9, __pyx_t_11); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 231, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_8);
        __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
        __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
        __pyx_t_7 = __pyx_PyFloat_AsDouble(__pyx_t_8); if (unlikely((__pyx_t_7 == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 231, __pyx_L1_error)
        __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
        __pyx_v_phi = __pyx_t_7;
+232:                 Pts[0,NP] = PtsCross[0,ii]*Ccos(phi)
        __pyx_t_67 = 0;
        __pyx_t_68 = __pyx_v_ii;
        __pyx_t_69 = 0;
        __pyx_t_70 = __pyx_v_NP;
        *__Pyx_BufPtrStrided2d(double *, __pyx_pybuffernd_Pts.rcbuffer->pybuffer.buf, __pyx_t_69, __pyx_pybuffernd_Pts.diminfo[0].strides, __pyx_t_70, __pyx_pybuffernd_Pts.diminfo[1].strides) = ((*__Pyx_BufPtrStrided2d(double *, __pyx_pybuffernd_PtsCross.rcbuffer->pybuffer.buf, __pyx_t_67, __pyx_pybuffernd_PtsCross.diminfo[0].strides, __pyx_t_68, __pyx_pybuffernd_PtsCross.diminfo[1].strides)) * cos(__pyx_v_phi));
+233:                 Pts[1,NP] = PtsCross[0,ii]*Csin(phi)
        __pyx_t_71 = 0;
        __pyx_t_72 = __pyx_v_ii;
        __pyx_t_73 = 1;
        __pyx_t_74 = __pyx_v_NP;
        *__Pyx_BufPtrStrided2d(double *, __pyx_pybuffernd_Pts.rcbuffer->pybuffer.buf, __pyx_t_73, __pyx_pybuffernd_Pts.diminfo[0].strides, __pyx_t_74, __pyx_pybuffernd_Pts.diminfo[1].strides) = ((*__Pyx_BufPtrStrided2d(double *, __pyx_pybuffernd_PtsCross.rcbuffer->pybuffer.buf, __pyx_t_71, __pyx_pybuffernd_PtsCross.diminfo[0].strides, __pyx_t_72, __pyx_pybuffernd_PtsCross.diminfo[1].strides)) * sin(__pyx_v_phi));
+234:                 Pts[2,NP] = PtsCross[1,ii]
        __pyx_t_75 = 1;
        __pyx_t_76 = __pyx_v_ii;
        __pyx_t_77 = 2;
        __pyx_t_78 = __pyx_v_NP;
        *__Pyx_BufPtrStrided2d(double *, __pyx_pybuffernd_Pts.rcbuffer->pybuffer.buf, __pyx_t_77, __pyx_pybuffernd_Pts.diminfo[0].strides, __pyx_t_78, __pyx_pybuffernd_Pts.diminfo[1].strides) = (*__Pyx_BufPtrStrided2d(double *, __pyx_pybuffernd_PtsCross.rcbuffer->pybuffer.buf, __pyx_t_75, __pyx_pybuffernd_PtsCross.diminfo[0].strides, __pyx_t_76, __pyx_pybuffernd_PtsCross.diminfo[1].strides));
+235:                 ind[NP] = NRPhi0[ii] + indiijj
        __pyx_t_79 = __pyx_v_ii;
        __pyx_t_80 = __pyx_v_NP;
        *__Pyx_BufPtrStrided1d(double *, __pyx_pybuffernd_ind.rcbuffer->pybuffer.buf, __pyx_t_80, __pyx_pybuffernd_ind.diminfo[0].strides) = ((*((long *) ( /* dim=0 */ ((char *) (((long *) __pyx_v_NRPhi0.data) + __pyx_t_79)) ))) + __pyx_v_indiijj);
+236:                 dS[NP] = dLr[ii]*dRPhir[ii]
        __pyx_t_81 = __pyx_v_ii;
        __pyx_t_82 = __pyx_v_ii;
        __pyx_t_83 = __pyx_v_NP;
        *__Pyx_BufPtrStrided1d(double *, __pyx_pybuffernd_dS.rcbuffer->pybuffer.buf, __pyx_t_83, __pyx_pybuffernd_dS.diminfo[0].strides) = ((*__Pyx_BufPtrStrided1d(double *, __pyx_pybuffernd_dLr.rcbuffer->pybuffer.buf, __pyx_t_81, __pyx_pybuffernd_dLr.diminfo[0].strides)) * (*__Pyx_BufPtrStrided1d(double *, __pyx_pybuffernd_dRPhir.rcbuffer->pybuffer.buf, __pyx_t_82, __pyx_pybuffernd_dRPhir.diminfo[0].strides)));
+237:                 NP += 1
        __pyx_v_NP = (__pyx_v_NP + 1);
      }
    }
 238:     else:
+239:         for ii in range(0,Ln):
  /*else*/ {
    __pyx_t_24 = __pyx_v_Ln;
    for (__pyx_t_15 = 0; __pyx_t_15 < __pyx_t_24; __pyx_t_15+=1) {
      __pyx_v_ii = __pyx_t_15;
+240:             for jj in range(0,Phin[ii]):
      __pyx_t_84 = __pyx_v_ii;
      __pyx_t_25 = (*((long *) ( /* dim=0 */ ((char *) (((long *) __pyx_v_Phin.data) + __pyx_t_84)) )));
      for (__pyx_t_34 = 0; __pyx_t_34 < __pyx_t_25; __pyx_t_34+=1) {
        __pyx_v_jj = __pyx_t_34;
+241:                 indiijj = indI[ii,jj]
        __pyx_t_85 = __pyx_v_ii;
        __pyx_t_86 = __pyx_v_jj;
        __pyx_v_indiijj = (*__Pyx_BufPtrStrided2d(double *, __pyx_pybuffernd_indI.rcbuffer->pybuffer.buf, __pyx_t_85, __pyx_pybuffernd_indI.diminfo[0].strides, __pyx_t_86, __pyx_pybuffernd_indI.diminfo[1].strides));
+242:                 Pts[0,NP] = PtsCross[0,ii]
        __pyx_t_87 = 0;
        __pyx_t_88 = __pyx_v_ii;
        __pyx_t_89 = 0;
        __pyx_t_90 = __pyx_v_NP;
        *__Pyx_BufPtrStrided2d(double *, __pyx_pybuffernd_Pts.rcbuffer->pybuffer.buf, __pyx_t_89, __pyx_pybuffernd_Pts.diminfo[0].strides, __pyx_t_90, __pyx_pybuffernd_Pts.diminfo[1].strides) = (*__Pyx_BufPtrStrided2d(double *, __pyx_pybuffernd_PtsCross.rcbuffer->pybuffer.buf, __pyx_t_87, __pyx_pybuffernd_PtsCross.diminfo[0].strides, __pyx_t_88, __pyx_pybuffernd_PtsCross.diminfo[1].strides));
+243:                 Pts[1,NP] = PtsCross[1,ii]
        __pyx_t_91 = 1;
        __pyx_t_92 = __pyx_v_ii;
        __pyx_t_93 = 1;
        __pyx_t_94 = __pyx_v_NP;
        *__Pyx_BufPtrStrided2d(double *, __pyx_pybuffernd_Pts.rcbuffer->pybuffer.buf, __pyx_t_93, __pyx_pybuffernd_Pts.diminfo[0].strides, __pyx_t_94, __pyx_pybuffernd_Pts.diminfo[1].strides) = (*__Pyx_BufPtrStrided2d(double *, __pyx_pybuffernd_PtsCross.rcbuffer->pybuffer.buf, __pyx_t_91, __pyx_pybuffernd_PtsCross.diminfo[0].strides, __pyx_t_92, __pyx_pybuffernd_PtsCross.diminfo[1].strides));
+244:                 Pts[2,NP] = PhiMinMax[0] + (0.5+indiijj)*dPhir[ii]
        __pyx_t_8 = __Pyx_GetItemInt(__pyx_v_PhiMinMax, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 0); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 244, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_8);
        __pyx_t_95 = __pyx_v_ii;
        __pyx_t_11 = PyFloat_FromDouble(((0.5 + __pyx_v_indiijj) * (*((double *) ( /* dim=0 */ ((char *) (((double *) __pyx_v_dPhir.data) + __pyx_t_95)) ))))); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 244, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_11);
        __pyx_t_9 = PyNumber_Add(__pyx_t_8, __pyx_t_11); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 244, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_9);
        __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
        __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
        __pyx_t_7 = __pyx_PyFloat_AsDouble(__pyx_t_9); if (unlikely((__pyx_t_7 == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 244, __pyx_L1_error)
        __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
        __pyx_t_96 = 2;
        __pyx_t_97 = __pyx_v_NP;
        *__Pyx_BufPtrStrided2d(double *, __pyx_pybuffernd_Pts.rcbuffer->pybuffer.buf, __pyx_t_96, __pyx_pybuffernd_Pts.diminfo[0].strides, __pyx_t_97, __pyx_pybuffernd_Pts.diminfo[1].strides) = __pyx_t_7;
+245:                 ind[NP] = NRPhi0[ii] + indiijj
        __pyx_t_98 = __pyx_v_ii;
        __pyx_t_99 = __pyx_v_NP;
        *__Pyx_BufPtrStrided1d(double *, __pyx_pybuffernd_ind.rcbuffer->pybuffer.buf, __pyx_t_99, __pyx_pybuffernd_ind.diminfo[0].strides) = ((*((long *) ( /* dim=0 */ ((char *) (((long *) __pyx_v_NRPhi0.data) + __pyx_t_98)) ))) + __pyx_v_indiijj);
+246:                 dS[NP] = dLr[ii]*dRPhir[ii]
        __pyx_t_100 = __pyx_v_ii;
        __pyx_t_101 = __pyx_v_ii;
        __pyx_t_102 = __pyx_v_NP;
        *__Pyx_BufPtrStrided1d(double *, __pyx_pybuffernd_dS.rcbuffer->pybuffer.buf, __pyx_t_102, __pyx_pybuffernd_dS.diminfo[0].strides) = ((*__Pyx_BufPtrStrided1d(double *, __pyx_pybuffernd_dLr.rcbuffer->pybuffer.buf, __pyx_t_100, __pyx_pybuffernd_dLr.diminfo[0].strides)) * (*__Pyx_BufPtrStrided1d(double *, __pyx_pybuffernd_dRPhir.rcbuffer->pybuffer.buf, __pyx_t_101, __pyx_pybuffernd_dRPhir.diminfo[0].strides)));
+247:                 NP += 1
        __pyx_v_NP = (__pyx_v_NP + 1);
      }
    }
  }
  __pyx_L29:;
+248:     return Pts, dS, ind.astype(int), NL, dLr, Rref, dRPhir, nRPhi0, VPbis
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_11 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_ind), __pyx_n_s_astype); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 248, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_11);
  __pyx_t_8 = NULL;
  if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_11))) {
    __pyx_t_8 = PyMethod_GET_SELF(__pyx_t_11);
    if (likely(__pyx_t_8)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_11);
      __Pyx_INCREF(__pyx_t_8);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_11, function);
    }
  }
  if (!__pyx_t_8) {
    __pyx_t_9 = __Pyx_PyObject_CallOneArg(__pyx_t_11, ((PyObject *)(&PyInt_Type))); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 248, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_9);
  } else {
    #if CYTHON_FAST_PYCALL
    if (PyFunction_Check(__pyx_t_11)) {
      PyObject *__pyx_temp[2] = {__pyx_t_8, ((PyObject *)(&PyInt_Type))};
      __pyx_t_9 = __Pyx_PyFunction_FastCall(__pyx_t_11, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 248, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
      __Pyx_GOTREF(__pyx_t_9);
    } else
    #endif
    #if CYTHON_FAST_PYCCALL
    if (__Pyx_PyFastCFunction_Check(__pyx_t_11)) {
      PyObject *__pyx_temp[2] = {__pyx_t_8, ((PyObject *)(&PyInt_Type))};
      __pyx_t_9 = __Pyx_PyCFunction_FastCall(__pyx_t_11, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 248, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
      __Pyx_GOTREF(__pyx_t_9);
    } else
    #endif
    {
      __pyx_t_10 = PyTuple_New(1+1); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 248, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_10);
      __Pyx_GIVEREF(__pyx_t_8); PyTuple_SET_ITEM(__pyx_t_10, 0, __pyx_t_8); __pyx_t_8 = NULL;
      __Pyx_INCREF(((PyObject *)(&PyInt_Type)));
      __Pyx_GIVEREF(((PyObject *)(&PyInt_Type)));
      PyTuple_SET_ITEM(__pyx_t_10, 0+1, ((PyObject *)(&PyInt_Type)));
      __pyx_t_9 = __Pyx_PyObject_Call(__pyx_t_11, __pyx_t_10, NULL); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 248, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_9);
      __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
    }
  }
  __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
  __pyx_t_11 = __Pyx_PyInt_From_int(__pyx_v_nRPhi0); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 248, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_11);
  __pyx_t_10 = PyTuple_New(9); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 248, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_10);
  __Pyx_INCREF(((PyObject *)__pyx_v_Pts));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_Pts));
  PyTuple_SET_ITEM(__pyx_t_10, 0, ((PyObject *)__pyx_v_Pts));
  __Pyx_INCREF(((PyObject *)__pyx_v_dS));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_dS));
  PyTuple_SET_ITEM(__pyx_t_10, 1, ((PyObject *)__pyx_v_dS));
  __Pyx_GIVEREF(__pyx_t_9);
  PyTuple_SET_ITEM(__pyx_t_10, 2, __pyx_t_9);
  __Pyx_INCREF(((PyObject *)__pyx_v_NL));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_NL));
  PyTuple_SET_ITEM(__pyx_t_10, 3, ((PyObject *)__pyx_v_NL));
  __Pyx_INCREF(((PyObject *)__pyx_v_dLr));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_dLr));
  PyTuple_SET_ITEM(__pyx_t_10, 4, ((PyObject *)__pyx_v_dLr));
  __Pyx_INCREF(((PyObject *)__pyx_v_Rref));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_Rref));
  PyTuple_SET_ITEM(__pyx_t_10, 5, ((PyObject *)__pyx_v_Rref));
  __Pyx_INCREF(((PyObject *)__pyx_v_dRPhir));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_dRPhir));
  PyTuple_SET_ITEM(__pyx_t_10, 6, ((PyObject *)__pyx_v_dRPhir));
  __Pyx_GIVEREF(__pyx_t_11);
  PyTuple_SET_ITEM(__pyx_t_10, 7, __pyx_t_11);
  __Pyx_INCREF(((PyObject *)__pyx_v_VPbis));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_VPbis));
  PyTuple_SET_ITEM(__pyx_t_10, 8, ((PyObject *)__pyx_v_VPbis));
  __pyx_t_9 = 0;
  __pyx_t_11 = 0;
  __pyx_r = __pyx_t_10;
  __pyx_t_10 = 0;
  goto __pyx_L0;
 249: 
 250: 
 251: 
 252: 
 253: @cython.cdivision(True)
 254: @cython.wraparound(False)
 255: @cython.boundscheck(False)
+256: def _Ves_Smesh_Tor_SubFromInd_cython(double dL, double dRPhi,
/* Python wrapper */
static PyObject *__pyx_pw_46_cython_magic_8152fc40fb05daa7217c00b66474f995_7_Ves_Smesh_Tor_SubFromInd_cython(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_46_cython_magic_8152fc40fb05daa7217c00b66474f995_6_Ves_Smesh_Tor_SubFromInd_cython[] = " Return the desired submesh indicated by the (numerical) indices, for the desired resolution (dR,dZ,dRphi) ";
static PyMethodDef __pyx_mdef_46_cython_magic_8152fc40fb05daa7217c00b66474f995_7_Ves_Smesh_Tor_SubFromInd_cython = {"_Ves_Smesh_Tor_SubFromInd_cython", (PyCFunction)__pyx_pw_46_cython_magic_8152fc40fb05daa7217c00b66474f995_7_Ves_Smesh_Tor_SubFromInd_cython, METH_VARARGS|METH_KEYWORDS, __pyx_doc_46_cython_magic_8152fc40fb05daa7217c00b66474f995_6_Ves_Smesh_Tor_SubFromInd_cython};
static PyObject *__pyx_pw_46_cython_magic_8152fc40fb05daa7217c00b66474f995_7_Ves_Smesh_Tor_SubFromInd_cython(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  double __pyx_v_dL;
  double __pyx_v_dRPhi;
  __Pyx_memviewslice __pyx_v_VPoly = { 0, 0, { 0 }, { 0 }, { 0 } };
  __Pyx_memviewslice __pyx_v_ind = { 0, 0, { 0 }, { 0 }, { 0 } };
  double __pyx_v_DIn;
  PyObject *__pyx_v_VIn = 0;
  PyObject *__pyx_v_PhiMinMax = 0;
  PyObject *__pyx_v_Out = 0;
  double __pyx_v_margin;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("_Ves_Smesh_Tor_SubFromInd_cython (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_dL,&__pyx_n_s_dRPhi,&__pyx_n_s_VPoly,&__pyx_n_s_ind,&__pyx_n_s_DIn,&__pyx_n_s_VIn,&__pyx_n_s_PhiMinMax,&__pyx_n_s_Out,&__pyx_n_s_margin,0};
    PyObject* values[9] = {0,0,0,0,0,0,0,0,0};
/* … */
  /* function exit code */
  goto __pyx_L0;
  __pyx_L1_error:;
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_46_cython_magic_8152fc40fb05daa7217c00b66474f995_6_Ves_Smesh_Tor_SubFromInd_cython(CYTHON_UNUSED PyObject *__pyx_self, double __pyx_v_dL, double __pyx_v_dRPhi, __Pyx_memviewslice __pyx_v_VPoly, __Pyx_memviewslice __pyx_v_ind, double __pyx_v_DIn, PyObject *__pyx_v_VIn, PyObject *__pyx_v_PhiMinMax, PyObject *__pyx_v_Out, double __pyx_v_margin) {
  __Pyx_memviewslice __pyx_v_dRPhirRef = { 0, 0, { 0 }, { 0 }, { 0 } };
  __Pyx_memviewslice __pyx_v_dPhir = { 0, 0, { 0 }, { 0 }, { 0 } };
  CYTHON_UNUSED __Pyx_memviewslice __pyx_v_indL = { 0, 0, { 0 }, { 0 }, { 0 } };
  __Pyx_memviewslice __pyx_v_NRPhi0 = { 0, 0, { 0 }, { 0 }, { 0 } };
  __Pyx_memviewslice __pyx_v_NRPhi = { 0, 0, { 0 }, { 0 }, { 0 } };
  long __pyx_v_NP;
  long __pyx_v_Rratio;
  int __pyx_v_ii;
  int __pyx_v_jj;
  int __pyx_v_iiL;
  int __pyx_v_iiphi;
  int __pyx_v_Ln;
  CYTHON_UNUSED int __pyx_v_nn;
  CYTHON_UNUSED int __pyx_v_kk;
  int __pyx_v_nRPhi0;
  __Pyx_memviewslice __pyx_v_Phi = { 0, 0, { 0 }, { 0 }, { 0 } };
  PyArrayObject *__pyx_v_Pts = 0;
  PyArrayObject *__pyx_v_PtsCross = 0;
  PyArrayObject *__pyx_v_VPbis = 0;
  PyArrayObject *__pyx_v_dS = 0;
  PyArrayObject *__pyx_v_dLr = 0;
  PyArrayObject *__pyx_v_dRPhir = 0;
  PyArrayObject *__pyx_v_Rref = 0;
  PyArrayObject *__pyx_v_NL = 0;
  PyObject *__pyx_v_DPhiMinMax = NULL;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_NL;
  __Pyx_Buffer __pyx_pybuffer_NL;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_Pts;
  __Pyx_Buffer __pyx_pybuffer_Pts;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_PtsCross;
  __Pyx_Buffer __pyx_pybuffer_PtsCross;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_Rref;
  __Pyx_Buffer __pyx_pybuffer_Rref;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_VPbis;
  __Pyx_Buffer __pyx_pybuffer_VPbis;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_dLr;
  __Pyx_Buffer __pyx_pybuffer_dLr;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_dRPhir;
  __Pyx_Buffer __pyx_pybuffer_dRPhir;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_dS;
  __Pyx_Buffer __pyx_pybuffer_dS;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("_Ves_Smesh_Tor_SubFromInd_cython", 0);
  __Pyx_INCREF(__pyx_v_PhiMinMax);
  __pyx_pybuffer_Pts.pybuffer.buf = NULL;
  __pyx_pybuffer_Pts.refcount = 0;
  __pyx_pybuffernd_Pts.data = NULL;
  __pyx_pybuffernd_Pts.rcbuffer = &__pyx_pybuffer_Pts;
  __pyx_pybuffer_PtsCross.pybuffer.buf = NULL;
  __pyx_pybuffer_PtsCross.refcount = 0;
  __pyx_pybuffernd_PtsCross.data = NULL;
  __pyx_pybuffernd_PtsCross.rcbuffer = &__pyx_pybuffer_PtsCross;
  __pyx_pybuffer_VPbis.pybuffer.buf = NULL;
  __pyx_pybuffer_VPbis.refcount = 0;
  __pyx_pybuffernd_VPbis.data = NULL;
  __pyx_pybuffernd_VPbis.rcbuffer = &__pyx_pybuffer_VPbis;
  __pyx_pybuffer_dS.pybuffer.buf = NULL;
  __pyx_pybuffer_dS.refcount = 0;
  __pyx_pybuffernd_dS.data = NULL;
  __pyx_pybuffernd_dS.rcbuffer = &__pyx_pybuffer_dS;
  __pyx_pybuffer_dLr.pybuffer.buf = NULL;
  __pyx_pybuffer_dLr.refcount = 0;
  __pyx_pybuffernd_dLr.data = NULL;
  __pyx_pybuffernd_dLr.rcbuffer = &__pyx_pybuffer_dLr;
  __pyx_pybuffer_dRPhir.pybuffer.buf = NULL;
  __pyx_pybuffer_dRPhir.refcount = 0;
  __pyx_pybuffernd_dRPhir.data = NULL;
  __pyx_pybuffernd_dRPhir.rcbuffer = &__pyx_pybuffer_dRPhir;
  __pyx_pybuffer_Rref.pybuffer.buf = NULL;
  __pyx_pybuffer_Rref.refcount = 0;
  __pyx_pybuffernd_Rref.data = NULL;
  __pyx_pybuffernd_Rref.rcbuffer = &__pyx_pybuffer_Rref;
  __pyx_pybuffer_NL.pybuffer.buf = NULL;
  __pyx_pybuffer_NL.refcount = 0;
  __pyx_pybuffernd_NL.data = NULL;
  __pyx_pybuffernd_NL.rcbuffer = &__pyx_pybuffer_NL;
/* … */
  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_13);
  __Pyx_XDECREF(__pyx_t_14);
  __Pyx_XDECREF(__pyx_t_15);
  __PYX_XDEC_MEMVIEW(&__pyx_t_17, 1);
  __PYX_XDEC_MEMVIEW(&__pyx_t_23, 1);
  __PYX_XDEC_MEMVIEW(&__pyx_t_24, 1);
  __PYX_XDEC_MEMVIEW(&__pyx_t_25, 1);
  __PYX_XDEC_MEMVIEW(&__pyx_t_36, 1);
  { PyObject *__pyx_type, *__pyx_value, *__pyx_tb;
    __Pyx_PyThreadState_declare
    __Pyx_PyThreadState_assign
    __Pyx_ErrFetch(&__pyx_type, &__pyx_value, &__pyx_tb);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_NL.rcbuffer->pybuffer);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_Pts.rcbuffer->pybuffer);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_PtsCross.rcbuffer->pybuffer);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_Rref.rcbuffer->pybuffer);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_VPbis.rcbuffer->pybuffer);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_dLr.rcbuffer->pybuffer);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_dRPhir.rcbuffer->pybuffer);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_dS.rcbuffer->pybuffer);
  __Pyx_ErrRestore(__pyx_type, __pyx_value, __pyx_tb);}
  __Pyx_AddTraceback("_cython_magic_8152fc40fb05daa7217c00b66474f995._Ves_Smesh_Tor_SubFromInd_cython", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  goto __pyx_L2;
  __pyx_L0:;
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_NL.rcbuffer->pybuffer);
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_Pts.rcbuffer->pybuffer);
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_PtsCross.rcbuffer->pybuffer);
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_Rref.rcbuffer->pybuffer);
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_VPbis.rcbuffer->pybuffer);
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_dLr.rcbuffer->pybuffer);
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_dRPhir.rcbuffer->pybuffer);
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_dS.rcbuffer->pybuffer);
  __pyx_L2:;
  __PYX_XDEC_MEMVIEW(&__pyx_v_dRPhirRef, 1);
  __PYX_XDEC_MEMVIEW(&__pyx_v_dPhir, 1);
  __PYX_XDEC_MEMVIEW(&__pyx_v_indL, 1);
  __PYX_XDEC_MEMVIEW(&__pyx_v_NRPhi0, 1);
  __PYX_XDEC_MEMVIEW(&__pyx_v_NRPhi, 1);
  __PYX_XDEC_MEMVIEW(&__pyx_v_Phi, 1);
  __Pyx_XDECREF((PyObject *)__pyx_v_Pts);
  __Pyx_XDECREF((PyObject *)__pyx_v_PtsCross);
  __Pyx_XDECREF((PyObject *)__pyx_v_VPbis);
  __Pyx_XDECREF((PyObject *)__pyx_v_dS);
  __Pyx_XDECREF((PyObject *)__pyx_v_dLr);
  __Pyx_XDECREF((PyObject *)__pyx_v_dRPhir);
  __Pyx_XDECREF((PyObject *)__pyx_v_Rref);
  __Pyx_XDECREF((PyObject *)__pyx_v_NL);
  __Pyx_XDECREF(__pyx_v_DPhiMinMax);
  __PYX_XDEC_MEMVIEW(&__pyx_v_VPoly, 1);
  __PYX_XDEC_MEMVIEW(&__pyx_v_ind, 1);
  __Pyx_XDECREF(__pyx_v_PhiMinMax);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}
/* … */
  __pyx_tuple__111 = PyTuple_Pack(41, __pyx_n_s_dL, __pyx_n_s_dRPhi, __pyx_n_s_VPoly, __pyx_n_s_ind, __pyx_n_s_DIn, __pyx_n_s_VIn, __pyx_n_s_PhiMinMax, __pyx_n_s_Out, __pyx_n_s_margin, __pyx_n_s_dRPhirRef, __pyx_n_s_dPhir, __pyx_n_s_indL, __pyx_n_s_NRPhi0, __pyx_n_s_NRPhi, __pyx_n_s_NR, __pyx_n_s_NZ, __pyx_n_s_Rn, __pyx_n_s_Zn, __pyx_n_s_NP, __pyx_n_s_Rratio, __pyx_n_s_ii, __pyx_n_s_jj0, __pyx_n_s_jj, __pyx_n_s_iiL, __pyx_n_s_iiphi, __pyx_n_s_Ln, __pyx_n_s_nn, __pyx_n_s_kk, __pyx_n_s_nRPhi0, __pyx_n_s_Phi, __pyx_n_s_Pts, __pyx_n_s_indI, __pyx_n_s_PtsCross, __pyx_n_s_VPbis, __pyx_n_s_R0, __pyx_n_s_dS, __pyx_n_s_dLr, __pyx_n_s_dRPhir, __pyx_n_s_Rref, __pyx_n_s_NL, __pyx_n_s_DPhiMinMax); if (unlikely(!__pyx_tuple__111)) __PYX_ERR(0, 256, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__111);
  __Pyx_GIVEREF(__pyx_tuple__111);
/* … */
  __pyx_t_2 = PyCFunction_NewEx(&__pyx_mdef_46_cython_magic_8152fc40fb05daa7217c00b66474f995_7_Ves_Smesh_Tor_SubFromInd_cython, NULL, __pyx_n_s_cython_magic_8152fc40fb05daa721); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 256, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_Ves_Smesh_Tor_SubFromInd_cython, __pyx_t_2) < 0) __PYX_ERR(0, 256, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_codeobj__112 = (PyObject*)__Pyx_PyCode_New(9, 0, 41, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__111, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_Home_DV226270_cache_ipython_cyt, __pyx_n_s_Ves_Smesh_Tor_SubFromInd_cython, 256, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__112)) __PYX_ERR(0, 256, __pyx_L1_error)
 257:                                      double[:,::1] VPoly, long[::1] ind,
+258:                                      double DIn=0., VIn=None, PhiMinMax=None,
    values[5] = ((PyObject *)Py_None);
    values[6] = ((PyObject *)Py_None);
    values[7] = ((PyObject*)__pyx_kp_u_X_Y_Z);
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  9: values[8] = PyTuple_GET_ITEM(__pyx_args, 8);
        case  8: values[7] = PyTuple_GET_ITEM(__pyx_args, 7);
        case  7: values[6] = PyTuple_GET_ITEM(__pyx_args, 6);
        case  6: values[5] = PyTuple_GET_ITEM(__pyx_args, 5);
        case  5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_dL)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        case  1:
        if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_dRPhi)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_Ves_Smesh_Tor_SubFromInd_cython", 0, 4, 9, 1); __PYX_ERR(0, 256, __pyx_L3_error)
        }
        case  2:
        if (likely((values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_VPoly)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_Ves_Smesh_Tor_SubFromInd_cython", 0, 4, 9, 2); __PYX_ERR(0, 256, __pyx_L3_error)
        }
        case  3:
        if (likely((values[3] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_ind)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_Ves_Smesh_Tor_SubFromInd_cython", 0, 4, 9, 3); __PYX_ERR(0, 256, __pyx_L3_error)
        }
        case  4:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_DIn);
          if (value) { values[4] = value; kw_args--; }
        }
        case  5:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_VIn);
          if (value) { values[5] = value; kw_args--; }
        }
        case  6:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_PhiMinMax);
          if (value) { values[6] = value; kw_args--; }
        }
        case  7:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_Out);
          if (value) { values[7] = value; kw_args--; }
        }
        case  8:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_margin);
          if (value) { values[8] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "_Ves_Smesh_Tor_SubFromInd_cython") < 0)) __PYX_ERR(0, 256, __pyx_L3_error)
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  9: values[8] = PyTuple_GET_ITEM(__pyx_args, 8);
        case  8: values[7] = PyTuple_GET_ITEM(__pyx_args, 7);
        case  7: values[6] = PyTuple_GET_ITEM(__pyx_args, 6);
        case  6: values[5] = PyTuple_GET_ITEM(__pyx_args, 5);
        case  5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    __pyx_v_dL = __pyx_PyFloat_AsDouble(values[0]); if (unlikely((__pyx_v_dL == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 256, __pyx_L3_error)
    __pyx_v_dRPhi = __pyx_PyFloat_AsDouble(values[1]); if (unlikely((__pyx_v_dRPhi == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 256, __pyx_L3_error)
    __pyx_v_VPoly = __Pyx_PyObject_to_MemoryviewSlice_d_dc_double(values[2]); if (unlikely(!__pyx_v_VPoly.memview)) __PYX_ERR(0, 257, __pyx_L3_error)
    __pyx_v_ind = __Pyx_PyObject_to_MemoryviewSlice_dc_long(values[3]); if (unlikely(!__pyx_v_ind.memview)) __PYX_ERR(0, 257, __pyx_L3_error)
    if (values[4]) {
      __pyx_v_DIn = __pyx_PyFloat_AsDouble(values[4]); if (unlikely((__pyx_v_DIn == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 258, __pyx_L3_error)
    } else {
      __pyx_v_DIn = ((double)0.);
    }
    __pyx_v_VIn = values[5];
    __pyx_v_PhiMinMax = values[6];
    __pyx_v_Out = ((PyObject*)values[7]);
    if (values[8]) {
      __pyx_v_margin = __pyx_PyFloat_AsDouble(values[8]); if (unlikely((__pyx_v_margin == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 259, __pyx_L3_error)
    } else {
      __pyx_v_margin = ((double)1.e-9);
    }
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("_Ves_Smesh_Tor_SubFromInd_cython", 0, 4, 9, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 256, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("_cython_magic_8152fc40fb05daa7217c00b66474f995._Ves_Smesh_Tor_SubFromInd_cython", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_Out), (&PyUnicode_Type), 1, "Out", 1))) __PYX_ERR(0, 259, __pyx_L1_error)
  __pyx_r = __pyx_pf_46_cython_magic_8152fc40fb05daa7217c00b66474f995_6_Ves_Smesh_Tor_SubFromInd_cython(__pyx_self, __pyx_v_dL, __pyx_v_dRPhi, __pyx_v_VPoly, __pyx_v_ind, __pyx_v_DIn, __pyx_v_VIn, __pyx_v_PhiMinMax, __pyx_v_Out, __pyx_v_margin);
 259:                                      str Out='(X,Y,Z)', double margin=1.e-9):
 260:     """ Return the desired submesh indicated by the (numerical) indices, for the desired resolution (dR,dZ,dRphi) """
 261:     cdef double[::1] dRPhirRef, dPhir
 262:     cdef long[::1] indL, NRPhi0, NRPhi
+263:     cdef long NR, NZ, Rn, Zn, NP=len(ind), Rratio
  __pyx_t_1 = __pyx_memoryview_fromslice(__pyx_v_ind, 1, (PyObject *(*)(char *)) __pyx_memview_get_long, (int (*)(char *, PyObject *)) __pyx_memview_set_long, 0);; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 263, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PyObject_Length(__pyx_t_1); if (unlikely(__pyx_t_2 == -1)) __PYX_ERR(0, 263, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v_NP = __pyx_t_2;
+264:     cdef int ii, jj0, jj, iiL, iiphi, Ln, nn=0, kk=0, nRPhi0
  __pyx_v_nn = 0;
  __pyx_v_kk = 0;
 265:     cdef double[:,::1] Phi
+266:     cdef cnp.ndarray[double,ndim=2] Pts=np.empty((3,NP)), indI, PtsCross, VPbis
  __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 266, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_empty); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 266, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_3 = __Pyx_PyInt_From_long(__pyx_v_NP); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 266, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_5 = PyTuple_New(2); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 266, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_INCREF(__pyx_int_3);
  __Pyx_GIVEREF(__pyx_int_3);
  PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_int_3);
  __Pyx_GIVEREF(__pyx_t_3);
  PyTuple_SET_ITEM(__pyx_t_5, 1, __pyx_t_3);
  __pyx_t_3 = 0;
  __pyx_t_3 = NULL;
  if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_4))) {
    __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_4);
    if (likely(__pyx_t_3)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
      __Pyx_INCREF(__pyx_t_3);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_4, function);
    }
  }
  if (!__pyx_t_3) {
    __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_5); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 266, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_GOTREF(__pyx_t_1);
  } else {
    #if CYTHON_FAST_PYCALL
    if (PyFunction_Check(__pyx_t_4)) {
      PyObject *__pyx_temp[2] = {__pyx_t_3, __pyx_t_5};
      __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_4, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 266, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    } else
    #endif
    #if CYTHON_FAST_PYCCALL
    if (__Pyx_PyFastCFunction_Check(__pyx_t_4)) {
      PyObject *__pyx_temp[2] = {__pyx_t_3, __pyx_t_5};
      __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_4, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 266, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    } else
    #endif
    {
      __pyx_t_6 = PyTuple_New(1+1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 266, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_6);
      __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_3); __pyx_t_3 = NULL;
      __Pyx_GIVEREF(__pyx_t_5);
      PyTuple_SET_ITEM(__pyx_t_6, 0+1, __pyx_t_5);
      __pyx_t_5 = 0;
      __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_6, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 266, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    }
  }
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 266, __pyx_L1_error)
  __pyx_t_7 = ((PyArrayObject *)__pyx_t_1);
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_Pts.rcbuffer->pybuffer, (PyObject*)__pyx_t_7, &__Pyx_TypeInfo_double, PyBUF_FORMAT| PyBUF_STRIDES| PyBUF_WRITABLE, 2, 0, __pyx_stack) == -1)) {
      __pyx_v_Pts = ((PyArrayObject *)Py_None); __Pyx_INCREF(Py_None); __pyx_pybuffernd_Pts.rcbuffer->pybuffer.buf = NULL;
      __PYX_ERR(0, 266, __pyx_L1_error)
    } else {__pyx_pybuffernd_Pts.diminfo[0].strides = __pyx_pybuffernd_Pts.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_Pts.diminfo[0].shape = __pyx_pybuffernd_Pts.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_Pts.diminfo[1].strides = __pyx_pybuffernd_Pts.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_Pts.diminfo[1].shape = __pyx_pybuffernd_Pts.rcbuffer->pybuffer.shape[1];
    }
  }
  __pyx_t_7 = 0;
  __pyx_v_Pts = ((PyArrayObject *)__pyx_t_1);
  __pyx_t_1 = 0;
+267:     cdef cnp.ndarray[double,ndim=1] R0, dS=np.empty((NP,)), dLr, dRPhir, Rref
  __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 267, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_empty); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 267, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_4 = __Pyx_PyInt_From_long(__pyx_v_NP); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 267, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_5 = PyTuple_New(1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 267, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_GIVEREF(__pyx_t_4);
  PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_4);
  __pyx_t_4 = 0;
  __pyx_t_4 = NULL;
  if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_6))) {
    __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_6);
    if (likely(__pyx_t_4)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6);
      __Pyx_INCREF(__pyx_t_4);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_6, function);
    }
  }
  if (!__pyx_t_4) {
    __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_6, __pyx_t_5); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 267, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_GOTREF(__pyx_t_1);
  } else {
    #if CYTHON_FAST_PYCALL
    if (PyFunction_Check(__pyx_t_6)) {
      PyObject *__pyx_temp[2] = {__pyx_t_4, __pyx_t_5};
      __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_6, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 267, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    } else
    #endif
    #if CYTHON_FAST_PYCCALL
    if (__Pyx_PyFastCFunction_Check(__pyx_t_6)) {
      PyObject *__pyx_temp[2] = {__pyx_t_4, __pyx_t_5};
      __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_6, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 267, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    } else
    #endif
    {
      __pyx_t_3 = PyTuple_New(1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 267, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_4); __pyx_t_4 = NULL;
      __Pyx_GIVEREF(__pyx_t_5);
      PyTuple_SET_ITEM(__pyx_t_3, 0+1, __pyx_t_5);
      __pyx_t_5 = 0;
      __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_6, __pyx_t_3, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 267, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    }
  }
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 267, __pyx_L1_error)
  __pyx_t_8 = ((PyArrayObject *)__pyx_t_1);
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_dS.rcbuffer->pybuffer, (PyObject*)__pyx_t_8, &__Pyx_TypeInfo_double, PyBUF_FORMAT| PyBUF_STRIDES| PyBUF_WRITABLE, 1, 0, __pyx_stack) == -1)) {
      __pyx_v_dS = ((PyArrayObject *)Py_None); __Pyx_INCREF(Py_None); __pyx_pybuffernd_dS.rcbuffer->pybuffer.buf = NULL;
      __PYX_ERR(0, 267, __pyx_L1_error)
    } else {__pyx_pybuffernd_dS.diminfo[0].strides = __pyx_pybuffernd_dS.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_dS.diminfo[0].shape = __pyx_pybuffernd_dS.rcbuffer->pybuffer.shape[0];
    }
  }
  __pyx_t_8 = 0;
  __pyx_v_dS = ((PyArrayObject *)__pyx_t_1);
  __pyx_t_1 = 0;
 268:     cdef cnp.ndarray[long,ndim=1] NL
 269: 
 270:     # Pre-format input
+271:     if PhiMinMax is None:
  __pyx_t_9 = (__pyx_v_PhiMinMax == Py_None);
  __pyx_t_10 = (__pyx_t_9 != 0);
  if (__pyx_t_10) {
/* … */
    goto __pyx_L3;
  }
+272:         PhiMinMax = [-Cpi,Cpi]
    __pyx_t_1 = PyFloat_FromDouble((-M_PI)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 272, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_6 = PyFloat_FromDouble(M_PI); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 272, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_t_3 = PyList_New(2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 272, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_GIVEREF(__pyx_t_1);
    PyList_SET_ITEM(__pyx_t_3, 0, __pyx_t_1);
    __Pyx_GIVEREF(__pyx_t_6);
    PyList_SET_ITEM(__pyx_t_3, 1, __pyx_t_6);
    __pyx_t_1 = 0;
    __pyx_t_6 = 0;
    __Pyx_DECREF_SET(__pyx_v_PhiMinMax, __pyx_t_3);
    __pyx_t_3 = 0;
+273:         DPhiMinMax = 2.*Cpi
    __pyx_t_3 = PyFloat_FromDouble((2. * M_PI)); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 273, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_v_DPhiMinMax = __pyx_t_3;
    __pyx_t_3 = 0;
 274:     else:
+275:         PhiMinMax = [Catan2(Csin(PhiMinMax[0]),Ccos(PhiMinMax[0])), Catan2(Csin(PhiMinMax[1]),Ccos(PhiMinMax[1]))]
  /*else*/ {
    __pyx_t_3 = __Pyx_GetItemInt(__pyx_v_PhiMinMax, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 275, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_11 = __pyx_PyFloat_AsDouble(__pyx_t_3); if (unlikely((__pyx_t_11 == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 275, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_t_3 = __Pyx_GetItemInt(__pyx_v_PhiMinMax, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 275, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_12 = __pyx_PyFloat_AsDouble(__pyx_t_3); if (unlikely((__pyx_t_12 == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 275, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_t_3 = PyFloat_FromDouble(atan2(sin(__pyx_t_11), cos(__pyx_t_12))); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 275, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_6 = __Pyx_GetItemInt(__pyx_v_PhiMinMax, 1, long, 1, __Pyx_PyInt_From_long, 0, 0, 0); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 275, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_t_12 = __pyx_PyFloat_AsDouble(__pyx_t_6); if (unlikely((__pyx_t_12 == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 275, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __pyx_t_6 = __Pyx_GetItemInt(__pyx_v_PhiMinMax, 1, long, 1, __Pyx_PyInt_From_long, 0, 0, 0); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 275, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_t_11 = __pyx_PyFloat_AsDouble(__pyx_t_6); if (unlikely((__pyx_t_11 == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 275, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __pyx_t_6 = PyFloat_FromDouble(atan2(sin(__pyx_t_12), cos(__pyx_t_11))); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 275, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_t_1 = PyList_New(2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 275, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_GIVEREF(__pyx_t_3);
    PyList_SET_ITEM(__pyx_t_1, 0, __pyx_t_3);
    __Pyx_GIVEREF(__pyx_t_6);
    PyList_SET_ITEM(__pyx_t_1, 1, __pyx_t_6);
    __pyx_t_3 = 0;
    __pyx_t_6 = 0;
    __Pyx_DECREF_SET(__pyx_v_PhiMinMax, __pyx_t_1);
    __pyx_t_1 = 0;
+276:         if PhiMinMax[1]>=PhiMinMax[0]:
    __pyx_t_1 = __Pyx_GetItemInt(__pyx_v_PhiMinMax, 1, long, 1, __Pyx_PyInt_From_long, 0, 0, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 276, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_6 = __Pyx_GetItemInt(__pyx_v_PhiMinMax, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 0); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 276, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_t_3 = PyObject_RichCompare(__pyx_t_1, __pyx_t_6, Py_GE); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 276, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __pyx_t_10 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_10 < 0)) __PYX_ERR(0, 276, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    if (__pyx_t_10) {
/* … */
      goto __pyx_L4;
    }
+277:             DPhiMinMax = PhiMinMax[1]-PhiMinMax[0]
      __pyx_t_3 = __Pyx_GetItemInt(__pyx_v_PhiMinMax, 1, long, 1, __Pyx_PyInt_From_long, 0, 0, 0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 277, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_6 = __Pyx_GetItemInt(__pyx_v_PhiMinMax, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 0); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 277, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_6);
      __pyx_t_1 = PyNumber_Subtract(__pyx_t_3, __pyx_t_6); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 277, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      __pyx_v_DPhiMinMax = __pyx_t_1;
      __pyx_t_1 = 0;
 278:         else:
+279:             DPhiMinMax = 2.*Cpi + PhiMinMax[1] - PhiMinMax[0]
    /*else*/ {
      __pyx_t_1 = PyFloat_FromDouble((2. * M_PI)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 279, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_6 = __Pyx_GetItemInt(__pyx_v_PhiMinMax, 1, long, 1, __Pyx_PyInt_From_long, 0, 0, 0); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 279, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_6);
      __pyx_t_3 = PyNumber_Add(__pyx_t_1, __pyx_t_6); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 279, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      __pyx_t_6 = __Pyx_GetItemInt(__pyx_v_PhiMinMax, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 0); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 279, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_6);
      __pyx_t_1 = PyNumber_Subtract(__pyx_t_3, __pyx_t_6); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 279, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      __pyx_v_DPhiMinMax = __pyx_t_1;
      __pyx_t_1 = 0;
    }
    __pyx_L4:;
  }
  __pyx_L3:;
 280: 
 281: 
 282:     # Get the actual R and Z resolutions and mesh elements
+283:     PtsCross, dLr, indL, NL, Rref, VPbis = _Ves_mesh_CrossPoly(VPoly, dL, D1=None, D2=None, margin=margin, DIn=DIn, VIn=VIn)
  __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_Ves_mesh_CrossPoly); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 283, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_6 = __pyx_memoryview_fromslice(__pyx_v_VPoly, 2, (PyObject *(*)(char *)) __pyx_memview_get_double, (int (*)(char *, PyObject *)) __pyx_memview_set_double, 0);; if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 283, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __pyx_t_3 = PyFloat_FromDouble(__pyx_v_dL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 283, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_5 = PyTuple_New(2); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 283, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_GIVEREF(__pyx_t_6);
  PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_6);
  __Pyx_GIVEREF(__pyx_t_3);
  PyTuple_SET_ITEM(__pyx_t_5, 1, __pyx_t_3);
  __pyx_t_6 = 0;
  __pyx_t_3 = 0;
  __pyx_t_3 = PyDict_New(); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 283, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_D1, Py_None) < 0) __PYX_ERR(0, 283, __pyx_L1_error)
  if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_D2, Py_None) < 0) __PYX_ERR(0, 283, __pyx_L1_error)
  __pyx_t_6 = PyFloat_FromDouble(__pyx_v_margin); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 283, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_margin, __pyx_t_6) < 0) __PYX_ERR(0, 283, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  __pyx_t_6 = PyFloat_FromDouble(__pyx_v_DIn); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 283, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_DIn, __pyx_t_6) < 0) __PYX_ERR(0, 283, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_VIn, __pyx_v_VIn) < 0) __PYX_ERR(0, 283, __pyx_L1_error)
  __pyx_t_6 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_5, __pyx_t_3); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 283, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  if ((likely(PyTuple_CheckExact(__pyx_t_6))) || (PyList_CheckExact(__pyx_t_6))) {
    PyObject* sequence = __pyx_t_6;
    #if !CYTHON_COMPILING_IN_PYPY
    Py_ssize_t size = Py_SIZE(sequence);
    #else
    Py_ssize_t size = PySequence_Size(sequence);
    #endif
    if (unlikely(size != 6)) {
      if (size > 6) __Pyx_RaiseTooManyValuesError(6);
      else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
      __PYX_ERR(0, 283, __pyx_L1_error)
    }
    #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
    if (likely(PyTuple_CheckExact(sequence))) {
      __pyx_t_3 = PyTuple_GET_ITEM(sequence, 0); 
      __pyx_t_5 = PyTuple_GET_ITEM(sequence, 1); 
      __pyx_t_1 = PyTuple_GET_ITEM(sequence, 2); 
      __pyx_t_4 = PyTuple_GET_ITEM(sequence, 3); 
      __pyx_t_13 = PyTuple_GET_ITEM(sequence, 4); 
      __pyx_t_14 = PyTuple_GET_ITEM(sequence, 5); 
    } else {
      __pyx_t_3 = PyList_GET_ITEM(sequence, 0); 
      __pyx_t_5 = PyList_GET_ITEM(sequence, 1); 
      __pyx_t_1 = PyList_GET_ITEM(sequence, 2); 
      __pyx_t_4 = PyList_GET_ITEM(sequence, 3); 
      __pyx_t_13 = PyList_GET_ITEM(sequence, 4); 
      __pyx_t_14 = PyList_GET_ITEM(sequence, 5); 
    }
    __Pyx_INCREF(__pyx_t_3);
    __Pyx_INCREF(__pyx_t_5);
    __Pyx_INCREF(__pyx_t_1);
    __Pyx_INCREF(__pyx_t_4);
    __Pyx_INCREF(__pyx_t_13);
    __Pyx_INCREF(__pyx_t_14);
    #else
    {
      Py_ssize_t i;
      PyObject** temps[6] = {&__pyx_t_3,&__pyx_t_5,&__pyx_t_1,&__pyx_t_4,&__pyx_t_13,&__pyx_t_14};
      for (i=0; i < 6; i++) {
        PyObject* item = PySequence_ITEM(sequence, i); if (unlikely(!item)) __PYX_ERR(0, 283, __pyx_L1_error)
        __Pyx_GOTREF(item);
        *(temps[i]) = item;
      }
    }
    #endif
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  } else {
    Py_ssize_t index = -1;
    PyObject** temps[6] = {&__pyx_t_3,&__pyx_t_5,&__pyx_t_1,&__pyx_t_4,&__pyx_t_13,&__pyx_t_14};
    __pyx_t_15 = PyObject_GetIter(__pyx_t_6); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 283, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_15);
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __pyx_t_16 = Py_TYPE(__pyx_t_15)->tp_iternext;
    for (index=0; index < 6; index++) {
      PyObject* item = __pyx_t_16(__pyx_t_15); if (unlikely(!item)) goto __pyx_L5_unpacking_failed;
      __Pyx_GOTREF(item);
      *(temps[index]) = item;
    }
    if (__Pyx_IternextUnpackEndCheck(__pyx_t_16(__pyx_t_15), 6) < 0) __PYX_ERR(0, 283, __pyx_L1_error)
    __pyx_t_16 = NULL;
    __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
    goto __pyx_L6_unpacking_done;
    __pyx_L5_unpacking_failed:;
    __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
    __pyx_t_16 = NULL;
    if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
    __PYX_ERR(0, 283, __pyx_L1_error)
    __pyx_L6_unpacking_done:;
  }
  if (!(likely(((__pyx_t_3) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_3, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 283, __pyx_L1_error)
  if (!(likely(((__pyx_t_5) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_5, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 283, __pyx_L1_error)
  __pyx_t_17 = __Pyx_PyObject_to_MemoryviewSlice_dc_long(__pyx_t_1);
  if (unlikely(!__pyx_t_17.memview)) __PYX_ERR(0, 283, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (!(likely(((__pyx_t_4) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_4, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 283, __pyx_L1_error)
  if (!(likely(((__pyx_t_13) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_13, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 283, __pyx_L1_error)
  if (!(likely(((__pyx_t_14) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_14, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 283, __pyx_L1_error)
  __pyx_t_7 = ((PyArrayObject *)__pyx_t_3);
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_PtsCross.rcbuffer->pybuffer);
    __pyx_t_18 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_PtsCross.rcbuffer->pybuffer, (PyObject*)__pyx_t_7, &__Pyx_TypeInfo_double, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack);
    if (unlikely(__pyx_t_18 < 0)) {
      PyErr_Fetch(&__pyx_t_19, &__pyx_t_20, &__pyx_t_21);
      if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_PtsCross.rcbuffer->pybuffer, (PyObject*)__pyx_v_PtsCross, &__Pyx_TypeInfo_double, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) {
        Py_XDECREF(__pyx_t_19); Py_XDECREF(__pyx_t_20); Py_XDECREF(__pyx_t_21);
        __Pyx_RaiseBufferFallbackError();
      } else {
        PyErr_Restore(__pyx_t_19, __pyx_t_20, __pyx_t_21);
      }
    }
    __pyx_pybuffernd_PtsCross.diminfo[0].strides = __pyx_pybuffernd_PtsCross.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_PtsCross.diminfo[0].shape = __pyx_pybuffernd_PtsCross.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_PtsCross.diminfo[1].strides = __pyx_pybuffernd_PtsCross.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_PtsCross.diminfo[1].shape = __pyx_pybuffernd_PtsCross.rcbuffer->pybuffer.shape[1];
    if (unlikely(__pyx_t_18 < 0)) __PYX_ERR(0, 283, __pyx_L1_error)
  }
  __pyx_t_7 = 0;
  __pyx_v_PtsCross = ((PyArrayObject *)__pyx_t_3);
  __pyx_t_3 = 0;
  __pyx_t_8 = ((PyArrayObject *)__pyx_t_5);
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_dLr.rcbuffer->pybuffer);
    __pyx_t_18 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_dLr.rcbuffer->pybuffer, (PyObject*)__pyx_t_8, &__Pyx_TypeInfo_double, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack);
    if (unlikely(__pyx_t_18 < 0)) {
      PyErr_Fetch(&__pyx_t_21, &__pyx_t_20, &__pyx_t_19);
      if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_dLr.rcbuffer->pybuffer, (PyObject*)__pyx_v_dLr, &__Pyx_TypeInfo_double, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {
        Py_XDECREF(__pyx_t_21); Py_XDECREF(__pyx_t_20); Py_XDECREF(__pyx_t_19);
        __Pyx_RaiseBufferFallbackError();
      } else {
        PyErr_Restore(__pyx_t_21, __pyx_t_20, __pyx_t_19);
      }
    }
    __pyx_pybuffernd_dLr.diminfo[0].strides = __pyx_pybuffernd_dLr.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_dLr.diminfo[0].shape = __pyx_pybuffernd_dLr.rcbuffer->pybuffer.shape[0];
    if (unlikely(__pyx_t_18 < 0)) __PYX_ERR(0, 283, __pyx_L1_error)
  }
  __pyx_t_8 = 0;
  __pyx_v_dLr = ((PyArrayObject *)__pyx_t_5);
  __pyx_t_5 = 0;
  __pyx_v_indL = __pyx_t_17;
  __pyx_t_17.memview = NULL;
  __pyx_t_17.data = NULL;
  __pyx_t_22 = ((PyArrayObject *)__pyx_t_4);
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_NL.rcbuffer->pybuffer);
    __pyx_t_18 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_NL.rcbuffer->pybuffer, (PyObject*)__pyx_t_22, &__Pyx_TypeInfo_long, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack);
    if (unlikely(__pyx_t_18 < 0)) {
      PyErr_Fetch(&__pyx_t_19, &__pyx_t_20, &__pyx_t_21);
      if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_NL.rcbuffer->pybuffer, (PyObject*)__pyx_v_NL, &__Pyx_TypeInfo_long, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {
        Py_XDECREF(__pyx_t_19); Py_XDECREF(__pyx_t_20); Py_XDECREF(__pyx_t_21);
        __Pyx_RaiseBufferFallbackError();
      } else {
        PyErr_Restore(__pyx_t_19, __pyx_t_20, __pyx_t_21);
      }
    }
    __pyx_pybuffernd_NL.diminfo[0].strides = __pyx_pybuffernd_NL.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_NL.diminfo[0].shape = __pyx_pybuffernd_NL.rcbuffer->pybuffer.shape[0];
    if (unlikely(__pyx_t_18 < 0)) __PYX_ERR(0, 283, __pyx_L1_error)
  }
  __pyx_t_22 = 0;
  __pyx_v_NL = ((PyArrayObject *)__pyx_t_4);
  __pyx_t_4 = 0;
  __pyx_t_8 = ((PyArrayObject *)__pyx_t_13);
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_Rref.rcbuffer->pybuffer);
    __pyx_t_18 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_Rref.rcbuffer->pybuffer, (PyObject*)__pyx_t_8, &__Pyx_TypeInfo_double, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack);
    if (unlikely(__pyx_t_18 < 0)) {
      PyErr_Fetch(&__pyx_t_21, &__pyx_t_20, &__pyx_t_19);
      if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_Rref.rcbuffer->pybuffer, (PyObject*)__pyx_v_Rref, &__Pyx_TypeInfo_double, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {
        Py_XDECREF(__pyx_t_21); Py_XDECREF(__pyx_t_20); Py_XDECREF(__pyx_t_19);
        __Pyx_RaiseBufferFallbackError();
      } else {
        PyErr_Restore(__pyx_t_21, __pyx_t_20, __pyx_t_19);
      }
    }
    __pyx_pybuffernd_Rref.diminfo[0].strides = __pyx_pybuffernd_Rref.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_Rref.diminfo[0].shape = __pyx_pybuffernd_Rref.rcbuffer->pybuffer.shape[0];
    if (unlikely(__pyx_t_18 < 0)) __PYX_ERR(0, 283, __pyx_L1_error)
  }
  __pyx_t_8 = 0;
  __pyx_v_Rref = ((PyArrayObject *)__pyx_t_13);
  __pyx_t_13 = 0;
  __pyx_t_7 = ((PyArrayObject *)__pyx_t_14);
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_VPbis.rcbuffer->pybuffer);
    __pyx_t_18 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_VPbis.rcbuffer->pybuffer, (PyObject*)__pyx_t_7, &__Pyx_TypeInfo_double, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack);
    if (unlikely(__pyx_t_18 < 0)) {
      PyErr_Fetch(&__pyx_t_19, &__pyx_t_20, &__pyx_t_21);
      if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_VPbis.rcbuffer->pybuffer, (PyObject*)__pyx_v_VPbis, &__Pyx_TypeInfo_double, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) {
        Py_XDECREF(__pyx_t_19); Py_XDECREF(__pyx_t_20); Py_XDECREF(__pyx_t_21);
        __Pyx_RaiseBufferFallbackError();
      } else {
        PyErr_Restore(__pyx_t_19, __pyx_t_20, __pyx_t_21);
      }
    }
    __pyx_pybuffernd_VPbis.diminfo[0].strides = __pyx_pybuffernd_VPbis.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_VPbis.diminfo[0].shape = __pyx_pybuffernd_VPbis.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_VPbis.diminfo[1].strides = __pyx_pybuffernd_VPbis.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_VPbis.diminfo[1].shape = __pyx_pybuffernd_VPbis.rcbuffer->pybuffer.shape[1];
    if (unlikely(__pyx_t_18 < 0)) __PYX_ERR(0, 283, __pyx_L1_error)
  }
  __pyx_t_7 = 0;
  __pyx_v_VPbis = ((PyArrayObject *)__pyx_t_14);
  __pyx_t_14 = 0;
+284:     Ln = dLr.size
  __pyx_t_6 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_dLr), __pyx_n_s_size); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 284, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __pyx_t_18 = __Pyx_PyInt_As_int(__pyx_t_6); if (unlikely((__pyx_t_18 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 284, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  __pyx_v_Ln = __pyx_t_18;
 285:     # Number of Phi per R
+286:     dRPhirRef, dPhir, dRPhir = np.empty((Ln,)), np.empty((Ln,)), -np.ones((Ln,))
  __pyx_t_14 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 286, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_14);
  __pyx_t_13 = __Pyx_PyObject_GetAttrStr(__pyx_t_14, __pyx_n_s_empty); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 286, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_13);
  __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
  __pyx_t_14 = __Pyx_PyInt_From_int(__pyx_v_Ln); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 286, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_14);
  __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 286, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_GIVEREF(__pyx_t_14);
  PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_14);
  __pyx_t_14 = 0;
  __pyx_t_14 = NULL;
  if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_13))) {
    __pyx_t_14 = PyMethod_GET_SELF(__pyx_t_13);
    if (likely(__pyx_t_14)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_13);
      __Pyx_INCREF(__pyx_t_14);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_13, function);
    }
  }
  if (!__pyx_t_14) {
    __pyx_t_6 = __Pyx_PyObject_CallOneArg(__pyx_t_13, __pyx_t_4); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 286, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_GOTREF(__pyx_t_6);
  } else {
    #if CYTHON_FAST_PYCALL
    if (PyFunction_Check(__pyx_t_13)) {
      PyObject *__pyx_temp[2] = {__pyx_t_14, __pyx_t_4};
      __pyx_t_6 = __Pyx_PyFunction_FastCall(__pyx_t_13, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 286, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_14); __pyx_t_14 = 0;
      __Pyx_GOTREF(__pyx_t_6);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    } else
    #endif
    #if CYTHON_FAST_PYCCALL
    if (__Pyx_PyFastCFunction_Check(__pyx_t_13)) {
      PyObject *__pyx_temp[2] = {__pyx_t_14, __pyx_t_4};
      __pyx_t_6 = __Pyx_PyCFunction_FastCall(__pyx_t_13, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 286, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_14); __pyx_t_14 = 0;
      __Pyx_GOTREF(__pyx_t_6);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    } else
    #endif
    {
      __pyx_t_1 = PyTuple_New(1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 286, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_GIVEREF(__pyx_t_14); PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_14); __pyx_t_14 = NULL;
      __Pyx_GIVEREF(__pyx_t_4);
      PyTuple_SET_ITEM(__pyx_t_1, 0+1, __pyx_t_4);
      __pyx_t_4 = 0;
      __pyx_t_6 = __Pyx_PyObject_Call(__pyx_t_13, __pyx_t_1, NULL); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 286, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_6);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    }
  }
  __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
  __pyx_t_23 = __Pyx_PyObject_to_MemoryviewSlice_dc_double(__pyx_t_6);
  if (unlikely(!__pyx_t_23.memview)) __PYX_ERR(0, 286, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  __pyx_t_13 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 286, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_13);
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_13, __pyx_n_s_empty); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 286, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
  __pyx_t_13 = __Pyx_PyInt_From_int(__pyx_v_Ln); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 286, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_13);
  __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 286, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_GIVEREF(__pyx_t_13);
  PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_13);
  __pyx_t_13 = 0;
  __pyx_t_13 = NULL;
  if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_1))) {
    __pyx_t_13 = PyMethod_GET_SELF(__pyx_t_1);
    if (likely(__pyx_t_13)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1);
      __Pyx_INCREF(__pyx_t_13);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_1, function);
    }
  }
  if (!__pyx_t_13) {
    __pyx_t_6 = __Pyx_PyObject_CallOneArg(__pyx_t_1, __pyx_t_4); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 286, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_GOTREF(__pyx_t_6);
  } else {
    #if CYTHON_FAST_PYCALL
    if (PyFunction_Check(__pyx_t_1)) {
      PyObject *__pyx_temp[2] = {__pyx_t_13, __pyx_t_4};
      __pyx_t_6 = __Pyx_PyFunction_FastCall(__pyx_t_1, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 286, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0;
      __Pyx_GOTREF(__pyx_t_6);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    } else
    #endif
    #if CYTHON_FAST_PYCCALL
    if (__Pyx_PyFastCFunction_Check(__pyx_t_1)) {
      PyObject *__pyx_temp[2] = {__pyx_t_13, __pyx_t_4};
      __pyx_t_6 = __Pyx_PyCFunction_FastCall(__pyx_t_1, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 286, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0;
      __Pyx_GOTREF(__pyx_t_6);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    } else
    #endif
    {
      __pyx_t_14 = PyTuple_New(1+1); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 286, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_14);
      __Pyx_GIVEREF(__pyx_t_13); PyTuple_SET_ITEM(__pyx_t_14, 0, __pyx_t_13); __pyx_t_13 = NULL;
      __Pyx_GIVEREF(__pyx_t_4);
      PyTuple_SET_ITEM(__pyx_t_14, 0+1, __pyx_t_4);
      __pyx_t_4 = 0;
      __pyx_t_6 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_14, NULL); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 286, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_6);
      __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
    }
  }
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_24 = __Pyx_PyObject_to_MemoryviewSlice_dc_double(__pyx_t_6);
  if (unlikely(!__pyx_t_24.memview)) __PYX_ERR(0, 286, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 286, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_14 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_ones); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 286, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_14);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_Ln); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 286, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 286, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_GIVEREF(__pyx_t_1);
  PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_1);
  __pyx_t_1 = 0;
  __pyx_t_1 = NULL;
  if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_14))) {
    __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_14);
    if (likely(__pyx_t_1)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_14);
      __Pyx_INCREF(__pyx_t_1);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_14, function);
    }
  }
  if (!__pyx_t_1) {
    __pyx_t_6 = __Pyx_PyObject_CallOneArg(__pyx_t_14, __pyx_t_4); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 286, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_GOTREF(__pyx_t_6);
  } else {
    #if CYTHON_FAST_PYCALL
    if (PyFunction_Check(__pyx_t_14)) {
      PyObject *__pyx_temp[2] = {__pyx_t_1, __pyx_t_4};
      __pyx_t_6 = __Pyx_PyFunction_FastCall(__pyx_t_14, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 286, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
      __Pyx_GOTREF(__pyx_t_6);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    } else
    #endif
    #if CYTHON_FAST_PYCCALL
    if (__Pyx_PyFastCFunction_Check(__pyx_t_14)) {
      PyObject *__pyx_temp[2] = {__pyx_t_1, __pyx_t_4};
      __pyx_t_6 = __Pyx_PyCFunction_FastCall(__pyx_t_14, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 286, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
      __Pyx_GOTREF(__pyx_t_6);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    } else
    #endif
    {
      __pyx_t_13 = PyTuple_New(1+1); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 286, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_13);
      __Pyx_GIVEREF(__pyx_t_1); PyTuple_SET_ITEM(__pyx_t_13, 0, __pyx_t_1); __pyx_t_1 = NULL;
      __Pyx_GIVEREF(__pyx_t_4);
      PyTuple_SET_ITEM(__pyx_t_13, 0+1, __pyx_t_4);
      __pyx_t_4 = 0;
      __pyx_t_6 = __Pyx_PyObject_Call(__pyx_t_14, __pyx_t_13, NULL); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 286, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_6);
      __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
    }
  }
  __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
  __pyx_t_14 = PyNumber_Negative(__pyx_t_6); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 286, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_14);
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  if (!(likely(((__pyx_t_14) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_14, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 286, __pyx_L1_error)
  __pyx_v_dRPhirRef = __pyx_t_23;
  __pyx_t_23.memview = NULL;
  __pyx_t_23.data = NULL;
  __pyx_v_dPhir = __pyx_t_24;
  __pyx_t_24.memview = NULL;
  __pyx_t_24.data = NULL;
  __pyx_t_8 = ((PyArrayObject *)__pyx_t_14);
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_dRPhir.rcbuffer->pybuffer);
    __pyx_t_18 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_dRPhir.rcbuffer->pybuffer, (PyObject*)__pyx_t_8, &__Pyx_TypeInfo_double, PyBUF_FORMAT| PyBUF_STRIDES| PyBUF_WRITABLE, 1, 0, __pyx_stack);
    if (unlikely(__pyx_t_18 < 0)) {
      PyErr_Fetch(&__pyx_t_21, &__pyx_t_20, &__pyx_t_19);
      if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_dRPhir.rcbuffer->pybuffer, (PyObject*)__pyx_v_dRPhir, &__Pyx_TypeInfo_double, PyBUF_FORMAT| PyBUF_STRIDES| PyBUF_WRITABLE, 1, 0, __pyx_stack) == -1)) {
        Py_XDECREF(__pyx_t_21); Py_XDECREF(__pyx_t_20); Py_XDECREF(__pyx_t_19);
        __Pyx_RaiseBufferFallbackError();
      } else {
        PyErr_Restore(__pyx_t_21, __pyx_t_20, __pyx_t_19);
      }
    }
    __pyx_pybuffernd_dRPhir.diminfo[0].strides = __pyx_pybuffernd_dRPhir.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_dRPhir.diminfo[0].shape = __pyx_pybuffernd_dRPhir.rcbuffer->pybuffer.shape[0];
    if (unlikely(__pyx_t_18 < 0)) __PYX_ERR(0, 286, __pyx_L1_error)
  }
  __pyx_t_8 = 0;
  __pyx_v_dRPhir = ((PyArrayObject *)__pyx_t_14);
  __pyx_t_14 = 0;
+287:     NRPhi, NRPhi0 = np.empty((Ln,),dtype=int), np.empty((Ln,),dtype=int)
  __pyx_t_14 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 287, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_14);
  __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_14, __pyx_n_s_empty); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 287, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
  __pyx_t_14 = __Pyx_PyInt_From_int(__pyx_v_Ln); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 287, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_14);
  __pyx_t_13 = PyTuple_New(1); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 287, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_13);
  __Pyx_GIVEREF(__pyx_t_14);
  PyTuple_SET_ITEM(__pyx_t_13, 0, __pyx_t_14);
  __pyx_t_14 = 0;
  __pyx_t_14 = PyTuple_New(1); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 287, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_14);
  __Pyx_GIVEREF(__pyx_t_13);
  PyTuple_SET_ITEM(__pyx_t_14, 0, __pyx_t_13);
  __pyx_t_13 = 0;
  __pyx_t_13 = PyDict_New(); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 287, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_13);
  if (PyDict_SetItem(__pyx_t_13, __pyx_n_s_dtype, ((PyObject *)(&PyInt_Type))) < 0) __PYX_ERR(0, 287, __pyx_L1_error)
  __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_6, __pyx_t_14, __pyx_t_13); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 287, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
  __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
  __pyx_t_17 = __Pyx_PyObject_to_MemoryviewSlice_dc_long(__pyx_t_4);
  if (unlikely(!__pyx_t_17.memview)) __PYX_ERR(0, 287, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 287, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_13 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_empty); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 287, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_13);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_4 = __Pyx_PyInt_From_int(__pyx_v_Ln); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 287, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_14 = PyTuple_New(1); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 287, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_14);
  __Pyx_GIVEREF(__pyx_t_4);
  PyTuple_SET_ITEM(__pyx_t_14, 0, __pyx_t_4);
  __pyx_t_4 = 0;
  __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 287, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_GIVEREF(__pyx_t_14);
  PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_14);
  __pyx_t_14 = 0;
  __pyx_t_14 = PyDict_New(); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 287, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_14);
  if (PyDict_SetItem(__pyx_t_14, __pyx_n_s_dtype, ((PyObject *)(&PyInt_Type))) < 0) __PYX_ERR(0, 287, __pyx_L1_error)
  __pyx_t_6 = __Pyx_PyObject_Call(__pyx_t_13, __pyx_t_4, __pyx_t_14); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 287, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
  __pyx_t_25 = __Pyx_PyObject_to_MemoryviewSlice_dc_long(__pyx_t_6);
  if (unlikely(!__pyx_t_25.memview)) __PYX_ERR(0, 287, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  __pyx_v_NRPhi = __pyx_t_17;
  __pyx_t_17.memview = NULL;
  __pyx_t_17.data = NULL;
  __pyx_v_NRPhi0 = __pyx_t_25;
  __pyx_t_25.memview = NULL;
  __pyx_t_25.data = NULL;
+288:     Rratio = int(Cceil(np.max(Rref)/np.min(Rref)))
  __pyx_t_14 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 288, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_14);
  __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_14, __pyx_n_s_max); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 288, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
  __pyx_t_14 = NULL;
  if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_4))) {
    __pyx_t_14 = PyMethod_GET_SELF(__pyx_t_4);
    if (likely(__pyx_t_14)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
      __Pyx_INCREF(__pyx_t_14);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_4, function);
    }
  }
  if (!__pyx_t_14) {
    __pyx_t_6 = __Pyx_PyObject_CallOneArg(__pyx_t_4, ((PyObject *)__pyx_v_Rref)); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 288, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
  } else {
    #if CYTHON_FAST_PYCALL
    if (PyFunction_Check(__pyx_t_4)) {
      PyObject *__pyx_temp[2] = {__pyx_t_14, ((PyObject *)__pyx_v_Rref)};
      __pyx_t_6 = __Pyx_PyFunction_FastCall(__pyx_t_4, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 288, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_14); __pyx_t_14 = 0;
      __Pyx_GOTREF(__pyx_t_6);
    } else
    #endif
    #if CYTHON_FAST_PYCCALL
    if (__Pyx_PyFastCFunction_Check(__pyx_t_4)) {
      PyObject *__pyx_temp[2] = {__pyx_t_14, ((PyObject *)__pyx_v_Rref)};
      __pyx_t_6 = __Pyx_PyCFunction_FastCall(__pyx_t_4, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 288, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_14); __pyx_t_14 = 0;
      __Pyx_GOTREF(__pyx_t_6);
    } else
    #endif
    {
      __pyx_t_13 = PyTuple_New(1+1); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 288, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_13);
      __Pyx_GIVEREF(__pyx_t_14); PyTuple_SET_ITEM(__pyx_t_13, 0, __pyx_t_14); __pyx_t_14 = NULL;
      __Pyx_INCREF(((PyObject *)__pyx_v_Rref));
      __Pyx_GIVEREF(((PyObject *)__pyx_v_Rref));
      PyTuple_SET_ITEM(__pyx_t_13, 0+1, ((PyObject *)__pyx_v_Rref));
      __pyx_t_6 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_13, NULL); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 288, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_6);
      __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
    }
  }
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_13 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 288, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_13);
  __pyx_t_14 = __Pyx_PyObject_GetAttrStr(__pyx_t_13, __pyx_n_s_min); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 288, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_14);
  __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
  __pyx_t_13 = NULL;
  if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_14))) {
    __pyx_t_13 = PyMethod_GET_SELF(__pyx_t_14);
    if (likely(__pyx_t_13)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_14);
      __Pyx_INCREF(__pyx_t_13);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_14, function);
    }
  }
  if (!__pyx_t_13) {
    __pyx_t_4 = __Pyx_PyObject_CallOneArg(__pyx_t_14, ((PyObject *)__pyx_v_Rref)); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 288, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
  } else {
    #if CYTHON_FAST_PYCALL
    if (PyFunction_Check(__pyx_t_14)) {
      PyObject *__pyx_temp[2] = {__pyx_t_13, ((PyObject *)__pyx_v_Rref)};
      __pyx_t_4 = __Pyx_PyFunction_FastCall(__pyx_t_14, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 288, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0;
      __Pyx_GOTREF(__pyx_t_4);
    } else
    #endif
    #if CYTHON_FAST_PYCCALL
    if (__Pyx_PyFastCFunction_Check(__pyx_t_14)) {
      PyObject *__pyx_temp[2] = {__pyx_t_13, ((PyObject *)__pyx_v_Rref)};
      __pyx_t_4 = __Pyx_PyCFunction_FastCall(__pyx_t_14, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 288, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0;
      __Pyx_GOTREF(__pyx_t_4);
    } else
    #endif
    {
      __pyx_t_1 = PyTuple_New(1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 288, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_GIVEREF(__pyx_t_13); PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_13); __pyx_t_13 = NULL;
      __Pyx_INCREF(((PyObject *)__pyx_v_Rref));
      __Pyx_GIVEREF(((PyObject *)__pyx_v_Rref));
      PyTuple_SET_ITEM(__pyx_t_1, 0+1, ((PyObject *)__pyx_v_Rref));
      __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_14, __pyx_t_1, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 288, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    }
  }
  __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
  __pyx_t_14 = __Pyx_PyNumber_Divide(__pyx_t_6, __pyx_t_4); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 288, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_14);
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_11 = __pyx_PyFloat_AsDouble(__pyx_t_14); if (unlikely((__pyx_t_11 == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 288, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
  __pyx_v_Rratio = ((long)ceil(__pyx_t_11));
+289:     for ii in range(0,Ln):
  __pyx_t_18 = __pyx_v_Ln;
  for (__pyx_t_26 = 0; __pyx_t_26 < __pyx_t_18; __pyx_t_26+=1) {
    __pyx_v_ii = __pyx_t_26;
+290:         NRPhi[ii] = <long>(Cceil(DPhiMinMax*Rref[ii]/dRPhi))
    __pyx_t_27 = __pyx_v_ii;
    __pyx_t_14 = PyFloat_FromDouble((*__Pyx_BufPtrStrided1d(double *, __pyx_pybuffernd_Rref.rcbuffer->pybuffer.buf, __pyx_t_27, __pyx_pybuffernd_Rref.diminfo[0].strides))); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 290, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_14);
    __pyx_t_4 = PyNumber_Multiply(__pyx_v_DPhiMinMax, __pyx_t_14); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 290, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
    __pyx_t_14 = PyFloat_FromDouble(__pyx_v_dRPhi); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 290, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_14);
    __pyx_t_6 = __Pyx_PyNumber_Divide(__pyx_t_4, __pyx_t_14); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 290, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
    __pyx_t_11 = __pyx_PyFloat_AsDouble(__pyx_t_6); if (unlikely((__pyx_t_11 == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 290, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __pyx_t_28 = __pyx_v_ii;
    *((long *) ( /* dim=0 */ ((char *) (((long *) __pyx_v_NRPhi.data) + __pyx_t_28)) )) = ((long)ceil(__pyx_t_11));
+291:         dRPhirRef[ii] = DPhiMinMax*Rref[ii]/<double>(NRPhi[ii])
    __pyx_t_29 = __pyx_v_ii;
    __pyx_t_6 = PyFloat_FromDouble((*__Pyx_BufPtrStrided1d(double *, __pyx_pybuffernd_Rref.rcbuffer->pybuffer.buf, __pyx_t_29, __pyx_pybuffernd_Rref.diminfo[0].strides))); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 291, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_t_14 = PyNumber_Multiply(__pyx_v_DPhiMinMax, __pyx_t_6); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 291, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_14);
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __pyx_t_30 = __pyx_v_ii;
    __pyx_t_6 = PyFloat_FromDouble(((double)(*((long *) ( /* dim=0 */ ((char *) (((long *) __pyx_v_NRPhi.data) + __pyx_t_30)) ))))); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 291, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_t_4 = __Pyx_PyNumber_Divide(__pyx_t_14, __pyx_t_6); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 291, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __pyx_t_11 = __pyx_PyFloat_AsDouble(__pyx_t_4); if (unlikely((__pyx_t_11 == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 291, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_t_31 = __pyx_v_ii;
    *((double *) ( /* dim=0 */ ((char *) (((double *) __pyx_v_dRPhirRef.data) + __pyx_t_31)) )) = __pyx_t_11;
+292:         dPhir[ii] = DPhiMinMax/<double>(NRPhi[ii])
    __pyx_t_32 = __pyx_v_ii;
    __pyx_t_4 = PyFloat_FromDouble(((double)(*((long *) ( /* dim=0 */ ((char *) (((long *) __pyx_v_NRPhi.data) + __pyx_t_32)) ))))); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 292, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_6 = __Pyx_PyNumber_Divide(__pyx_v_DPhiMinMax, __pyx_t_4); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 292, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_t_11 = __pyx_PyFloat_AsDouble(__pyx_t_6); if (unlikely((__pyx_t_11 == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 292, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __pyx_t_33 = __pyx_v_ii;
    *((double *) ( /* dim=0 */ ((char *) (((double *) __pyx_v_dPhir.data) + __pyx_t_33)) )) = __pyx_t_11;
+293:         if ii==0:
    __pyx_t_10 = ((__pyx_v_ii == 0) != 0);
    if (__pyx_t_10) {
/* … */
      goto __pyx_L9;
    }
+294:             NRPhi0[ii] = 0
      __pyx_t_34 = __pyx_v_ii;
      *((long *) ( /* dim=0 */ ((char *) (((long *) __pyx_v_NRPhi0.data) + __pyx_t_34)) )) = 0;
+295:             Phi = np.empty((Ln,NRPhi[ii]*Rratio+1))
      __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 295, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_t_14 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_empty); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 295, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_14);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __pyx_t_4 = __Pyx_PyInt_From_int(__pyx_v_Ln); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 295, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_t_35 = __pyx_v_ii;
      __pyx_t_1 = __Pyx_PyInt_From_long((((*((long *) ( /* dim=0 */ ((char *) (((long *) __pyx_v_NRPhi.data) + __pyx_t_35)) ))) * __pyx_v_Rratio) + 1)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 295, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_13 = PyTuple_New(2); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 295, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_13);
      __Pyx_GIVEREF(__pyx_t_4);
      PyTuple_SET_ITEM(__pyx_t_13, 0, __pyx_t_4);
      __Pyx_GIVEREF(__pyx_t_1);
      PyTuple_SET_ITEM(__pyx_t_13, 1, __pyx_t_1);
      __pyx_t_4 = 0;
      __pyx_t_1 = 0;
      __pyx_t_1 = NULL;
      if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_14))) {
        __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_14);
        if (likely(__pyx_t_1)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_14);
          __Pyx_INCREF(__pyx_t_1);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_14, function);
        }
      }
      if (!__pyx_t_1) {
        __pyx_t_6 = __Pyx_PyObject_CallOneArg(__pyx_t_14, __pyx_t_13); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 295, __pyx_L1_error)
        __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
        __Pyx_GOTREF(__pyx_t_6);
      } else {
        #if CYTHON_FAST_PYCALL
        if (PyFunction_Check(__pyx_t_14)) {
          PyObject *__pyx_temp[2] = {__pyx_t_1, __pyx_t_13};
          __pyx_t_6 = __Pyx_PyFunction_FastCall(__pyx_t_14, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 295, __pyx_L1_error)
          __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
          __Pyx_GOTREF(__pyx_t_6);
          __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
        } else
        #endif
        #if CYTHON_FAST_PYCCALL
        if (__Pyx_PyFastCFunction_Check(__pyx_t_14)) {
          PyObject *__pyx_temp[2] = {__pyx_t_1, __pyx_t_13};
          __pyx_t_6 = __Pyx_PyCFunction_FastCall(__pyx_t_14, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 295, __pyx_L1_error)
          __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
          __Pyx_GOTREF(__pyx_t_6);
          __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
        } else
        #endif
        {
          __pyx_t_4 = PyTuple_New(1+1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 295, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_4);
          __Pyx_GIVEREF(__pyx_t_1); PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_1); __pyx_t_1 = NULL;
          __Pyx_GIVEREF(__pyx_t_13);
          PyTuple_SET_ITEM(__pyx_t_4, 0+1, __pyx_t_13);
          __pyx_t_13 = 0;
          __pyx_t_6 = __Pyx_PyObject_Call(__pyx_t_14, __pyx_t_4, NULL); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 295, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_6);
          __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
        }
      }
      __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
      __pyx_t_36 = __Pyx_PyObject_to_MemoryviewSlice_d_dc_double(__pyx_t_6);
      if (unlikely(!__pyx_t_36.memview)) __PYX_ERR(0, 295, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      __PYX_XDEC_MEMVIEW(&__pyx_v_Phi, 1);
      __pyx_v_Phi = __pyx_t_36;
      __pyx_t_36.memview = NULL;
      __pyx_t_36.data = NULL;
 296:         else:
+297:             NRPhi0[ii] = NRPhi0[ii-1] + NRPhi[ii-1]
    /*else*/ {
      __pyx_t_37 = (__pyx_v_ii - 1);
      __pyx_t_38 = (__pyx_v_ii - 1);
      __pyx_t_39 = __pyx_v_ii;
      *((long *) ( /* dim=0 */ ((char *) (((long *) __pyx_v_NRPhi0.data) + __pyx_t_39)) )) = ((*((long *) ( /* dim=0 */ ((char *) (((long *) __pyx_v_NRPhi0.data) + __pyx_t_37)) ))) + (*((long *) ( /* dim=0 */ ((char *) (((long *) __pyx_v_NRPhi.data) + __pyx_t_38)) ))));
    }
    __pyx_L9:;
+298:         for jj in range(0,NRPhi[ii]):
    __pyx_t_40 = __pyx_v_ii;
    __pyx_t_41 = (*((long *) ( /* dim=0 */ ((char *) (((long *) __pyx_v_NRPhi.data) + __pyx_t_40)) )));
    for (__pyx_t_42 = 0; __pyx_t_42 < __pyx_t_41; __pyx_t_42+=1) {
      __pyx_v_jj = __pyx_t_42;
+299:             Phi[ii,jj] = PhiMinMax[0] + (0.5+<double>jj)*dPhir[ii]
      __pyx_t_6 = __Pyx_GetItemInt(__pyx_v_PhiMinMax, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 0); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 299, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_6);
      __pyx_t_43 = __pyx_v_ii;
      __pyx_t_14 = PyFloat_FromDouble(((0.5 + ((double)__pyx_v_jj)) * (*((double *) ( /* dim=0 */ ((char *) (((double *) __pyx_v_dPhir.data) + __pyx_t_43)) ))))); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 299, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_14);
      __pyx_t_4 = PyNumber_Add(__pyx_t_6, __pyx_t_14); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 299, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
      __pyx_t_11 = __pyx_PyFloat_AsDouble(__pyx_t_4); if (unlikely((__pyx_t_11 == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 299, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      if (unlikely(!__pyx_v_Phi.memview)) { __Pyx_RaiseUnboundLocalError("Phi"); __PYX_ERR(0, 299, __pyx_L1_error) }
      __pyx_t_44 = __pyx_v_ii;
      __pyx_t_45 = __pyx_v_jj;
      *((double *) ( /* dim=1 */ ((char *) (((double *) ( /* dim=0 */ (__pyx_v_Phi.data + __pyx_t_44 * __pyx_v_Phi.strides[0]) )) + __pyx_t_45)) )) = __pyx_t_11;
    }
  }
+300:     nRPhi0 = NRPhi0[Ln-1]+NRPhi[Ln-1]
  __pyx_t_46 = (__pyx_v_Ln - 1);
  __pyx_t_47 = (__pyx_v_Ln - 1);
  __pyx_v_nRPhi0 = ((*((long *) ( /* dim=0 */ ((char *) (((long *) __pyx_v_NRPhi0.data) + __pyx_t_46)) ))) + (*((long *) ( /* dim=0 */ ((char *) (((long *) __pyx_v_NRPhi.data) + __pyx_t_47)) ))));
 301: 
+302:     if Out.lower()=='(x,y,z)':
  __pyx_t_14 = __Pyx_PyObject_GetAttrStr(__pyx_v_Out, __pyx_n_s_lower); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 302, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_14);
  __pyx_t_6 = NULL;
  if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_14))) {
    __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_14);
    if (likely(__pyx_t_6)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_14);
      __Pyx_INCREF(__pyx_t_6);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_14, function);
    }
  }
  if (__pyx_t_6) {
    __pyx_t_4 = __Pyx_PyObject_CallOneArg(__pyx_t_14, __pyx_t_6); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 302, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  } else {
    __pyx_t_4 = __Pyx_PyObject_CallNoArg(__pyx_t_14); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 302, __pyx_L1_error)
  }
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
  __pyx_t_10 = (__Pyx_PyUnicode_Equals(__pyx_t_4, __pyx_kp_u_x_y_z, Py_EQ)); if (unlikely(__pyx_t_10 < 0)) __PYX_ERR(0, 302, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  if (__pyx_t_10) {
/* … */
    goto __pyx_L12;
  }
+303:         for ii in range(0,NP):
    __pyx_t_41 = __pyx_v_NP;
    for (__pyx_t_18 = 0; __pyx_t_18 < __pyx_t_41; __pyx_t_18+=1) {
      __pyx_v_ii = __pyx_t_18;
+304:             for jj in range(0,Ln+1):
      __pyx_t_48 = (__pyx_v_Ln + 1);
      for (__pyx_t_26 = 0; __pyx_t_26 < __pyx_t_48; __pyx_t_26+=1) {
        __pyx_v_jj = __pyx_t_26;
+305:                 if ind[ii]-NRPhi0[jj]<0.:
        __pyx_t_49 = __pyx_v_ii;
        __pyx_t_50 = __pyx_v_jj;
        __pyx_t_10 = ((((*((long *) ( /* dim=0 */ ((char *) (((long *) __pyx_v_ind.data) + __pyx_t_49)) ))) - (*((long *) ( /* dim=0 */ ((char *) (((long *) __pyx_v_NRPhi0.data) + __pyx_t_50)) )))) < 0.) != 0);
        if (__pyx_t_10) {
/* … */
        }
      }
      __pyx_L16_break:;
+306:                     break
          goto __pyx_L16_break;
+307:             iiL = jj-1
      __pyx_v_iiL = (__pyx_v_jj - 1);
+308:             iiphi = ind[ii] - NRPhi0[iiL]
      __pyx_t_51 = __pyx_v_ii;
      __pyx_t_52 = __pyx_v_iiL;
      __pyx_v_iiphi = ((*((long *) ( /* dim=0 */ ((char *) (((long *) __pyx_v_ind.data) + __pyx_t_51)) ))) - (*((long *) ( /* dim=0 */ ((char *) (((long *) __pyx_v_NRPhi0.data) + __pyx_t_52)) ))));
+309:             Pts[0,ii] = PtsCross[0,iiL]*Ccos(Phi[iiL,iiphi])
      __pyx_t_53 = 0;
      __pyx_t_54 = __pyx_v_iiL;
      if (unlikely(!__pyx_v_Phi.memview)) { __Pyx_RaiseUnboundLocalError("Phi"); __PYX_ERR(0, 309, __pyx_L1_error) }
      __pyx_t_55 = __pyx_v_iiL;
      __pyx_t_56 = __pyx_v_iiphi;
      __pyx_t_57 = 0;
      __pyx_t_58 = __pyx_v_ii;
      *__Pyx_BufPtrStrided2d(double *, __pyx_pybuffernd_Pts.rcbuffer->pybuffer.buf, __pyx_t_57, __pyx_pybuffernd_Pts.diminfo[0].strides, __pyx_t_58, __pyx_pybuffernd_Pts.diminfo[1].strides) = ((*__Pyx_BufPtrStrided2d(double *, __pyx_pybuffernd_PtsCross.rcbuffer->pybuffer.buf, __pyx_t_53, __pyx_pybuffernd_PtsCross.diminfo[0].strides, __pyx_t_54, __pyx_pybuffernd_PtsCross.diminfo[1].strides)) * cos((*((double *) ( /* dim=1 */ ((char *) (((double *) ( /* dim=0 */ (__pyx_v_Phi.data + __pyx_t_55 * __pyx_v_Phi.strides[0]) )) + __pyx_t_56)) )))));
+310:             Pts[1,ii] = PtsCross[0,iiL]*Csin(Phi[iiL,iiphi])
      __pyx_t_59 = 0;
      __pyx_t_60 = __pyx_v_iiL;
      if (unlikely(!__pyx_v_Phi.memview)) { __Pyx_RaiseUnboundLocalError("Phi"); __PYX_ERR(0, 310, __pyx_L1_error) }
      __pyx_t_61 = __pyx_v_iiL;
      __pyx_t_62 = __pyx_v_iiphi;
      __pyx_t_63 = 1;
      __pyx_t_64 = __pyx_v_ii;
      *__Pyx_BufPtrStrided2d(double *, __pyx_pybuffernd_Pts.rcbuffer->pybuffer.buf, __pyx_t_63, __pyx_pybuffernd_Pts.diminfo[0].strides, __pyx_t_64, __pyx_pybuffernd_Pts.diminfo[1].strides) = ((*__Pyx_BufPtrStrided2d(double *, __pyx_pybuffernd_PtsCross.rcbuffer->pybuffer.buf, __pyx_t_59, __pyx_pybuffernd_PtsCross.diminfo[0].strides, __pyx_t_60, __pyx_pybuffernd_PtsCross.diminfo[1].strides)) * sin((*((double *) ( /* dim=1 */ ((char *) (((double *) ( /* dim=0 */ (__pyx_v_Phi.data + __pyx_t_61 * __pyx_v_Phi.strides[0]) )) + __pyx_t_62)) )))));
+311:             Pts[2,ii] = PtsCross[1,iiL]
      __pyx_t_65 = 1;
      __pyx_t_66 = __pyx_v_iiL;
      __pyx_t_67 = 2;
      __pyx_t_68 = __pyx_v_ii;
      *__Pyx_BufPtrStrided2d(double *, __pyx_pybuffernd_Pts.rcbuffer->pybuffer.buf, __pyx_t_67, __pyx_pybuffernd_Pts.diminfo[0].strides, __pyx_t_68, __pyx_pybuffernd_Pts.diminfo[1].strides) = (*__Pyx_BufPtrStrided2d(double *, __pyx_pybuffernd_PtsCross.rcbuffer->pybuffer.buf, __pyx_t_65, __pyx_pybuffernd_PtsCross.diminfo[0].strides, __pyx_t_66, __pyx_pybuffernd_PtsCross.diminfo[1].strides));
+312:             dS[ii] = dLr[iiL]*dRPhirRef[iiL]
      __pyx_t_69 = __pyx_v_iiL;
      __pyx_t_70 = __pyx_v_iiL;
      __pyx_t_71 = __pyx_v_ii;
      *__Pyx_BufPtrStrided1d(double *, __pyx_pybuffernd_dS.rcbuffer->pybuffer.buf, __pyx_t_71, __pyx_pybuffernd_dS.diminfo[0].strides) = ((*__Pyx_BufPtrStrided1d(double *, __pyx_pybuffernd_dLr.rcbuffer->pybuffer.buf, __pyx_t_69, __pyx_pybuffernd_dLr.diminfo[0].strides)) * (*((double *) ( /* dim=0 */ ((char *) (((double *) __pyx_v_dRPhirRef.data) + __pyx_t_70)) ))));
+313:             if dRPhir[iiL]==-1.:
      __pyx_t_72 = __pyx_v_iiL;
      __pyx_t_10 = (((*__Pyx_BufPtrStrided1d(double *, __pyx_pybuffernd_dRPhir.rcbuffer->pybuffer.buf, __pyx_t_72, __pyx_pybuffernd_dRPhir.diminfo[0].strides)) == -1.) != 0);
      if (__pyx_t_10) {
/* … */
      }
    }
+314:                 dRPhir[iiL] = dRPhirRef[iiL]
        __pyx_t_73 = __pyx_v_iiL;
        __pyx_t_74 = __pyx_v_iiL;
        *__Pyx_BufPtrStrided1d(double *, __pyx_pybuffernd_dRPhir.rcbuffer->pybuffer.buf, __pyx_t_74, __pyx_pybuffernd_dRPhir.diminfo[0].strides) = (*((double *) ( /* dim=0 */ ((char *) (((double *) __pyx_v_dRPhirRef.data) + __pyx_t_73)) )));
 315: 
 316:     else:
+317:         for ii in range(0,NP):
  /*else*/ {
    __pyx_t_41 = __pyx_v_NP;
    for (__pyx_t_18 = 0; __pyx_t_18 < __pyx_t_41; __pyx_t_18+=1) {
      __pyx_v_ii = __pyx_t_18;
+318:             for jj in range(0,Ln+1):
      __pyx_t_48 = (__pyx_v_Ln + 1);
      for (__pyx_t_26 = 0; __pyx_t_26 < __pyx_t_48; __pyx_t_26+=1) {
        __pyx_v_jj = __pyx_t_26;
+319:                 if ind[ii]-NRPhi0[jj]<0.:
        __pyx_t_75 = __pyx_v_ii;
        __pyx_t_76 = __pyx_v_jj;
        __pyx_t_10 = ((((*((long *) ( /* dim=0 */ ((char *) (((long *) __pyx_v_ind.data) + __pyx_t_75)) ))) - (*((long *) ( /* dim=0 */ ((char *) (((long *) __pyx_v_NRPhi0.data) + __pyx_t_76)) )))) < 0.) != 0);
        if (__pyx_t_10) {
/* … */
        }
      }
      __pyx_L22_break:;
+320:                     break
          goto __pyx_L22_break;
+321:             iiL = jj-1
      __pyx_v_iiL = (__pyx_v_jj - 1);
+322:             iiphi = ind[ii] - NRPhi0[iiL]
      __pyx_t_77 = __pyx_v_ii;
      __pyx_t_78 = __pyx_v_iiL;
      __pyx_v_iiphi = ((*((long *) ( /* dim=0 */ ((char *) (((long *) __pyx_v_ind.data) + __pyx_t_77)) ))) - (*((long *) ( /* dim=0 */ ((char *) (((long *) __pyx_v_NRPhi0.data) + __pyx_t_78)) ))));
+323:             Pts[0,ii] = PtsCross[0,iiL]
      __pyx_t_79 = 0;
      __pyx_t_80 = __pyx_v_iiL;
      __pyx_t_81 = 0;
      __pyx_t_82 = __pyx_v_ii;
      *__Pyx_BufPtrStrided2d(double *, __pyx_pybuffernd_Pts.rcbuffer->pybuffer.buf, __pyx_t_81, __pyx_pybuffernd_Pts.diminfo[0].strides, __pyx_t_82, __pyx_pybuffernd_Pts.diminfo[1].strides) = (*__Pyx_BufPtrStrided2d(double *, __pyx_pybuffernd_PtsCross.rcbuffer->pybuffer.buf, __pyx_t_79, __pyx_pybuffernd_PtsCross.diminfo[0].strides, __pyx_t_80, __pyx_pybuffernd_PtsCross.diminfo[1].strides));
+324:             Pts[1,ii] = PtsCross[1,iiL]
      __pyx_t_83 = 1;
      __pyx_t_84 = __pyx_v_iiL;
      __pyx_t_85 = 1;
      __pyx_t_86 = __pyx_v_ii;
      *__Pyx_BufPtrStrided2d(double *, __pyx_pybuffernd_Pts.rcbuffer->pybuffer.buf, __pyx_t_85, __pyx_pybuffernd_Pts.diminfo[0].strides, __pyx_t_86, __pyx_pybuffernd_Pts.diminfo[1].strides) = (*__Pyx_BufPtrStrided2d(double *, __pyx_pybuffernd_PtsCross.rcbuffer->pybuffer.buf, __pyx_t_83, __pyx_pybuffernd_PtsCross.diminfo[0].strides, __pyx_t_84, __pyx_pybuffernd_PtsCross.diminfo[1].strides));
+325:             Pts[2,ii] = Phi[iiL,iiphi]
      if (unlikely(!__pyx_v_Phi.memview)) { __Pyx_RaiseUnboundLocalError("Phi"); __PYX_ERR(0, 325, __pyx_L1_error) }
      __pyx_t_87 = __pyx_v_iiL;
      __pyx_t_88 = __pyx_v_iiphi;
      __pyx_t_89 = 2;
      __pyx_t_90 = __pyx_v_ii;
      *__Pyx_BufPtrStrided2d(double *, __pyx_pybuffernd_Pts.rcbuffer->pybuffer.buf, __pyx_t_89, __pyx_pybuffernd_Pts.diminfo[0].strides, __pyx_t_90, __pyx_pybuffernd_Pts.diminfo[1].strides) = (*((double *) ( /* dim=1 */ ((char *) (((double *) ( /* dim=0 */ (__pyx_v_Phi.data + __pyx_t_87 * __pyx_v_Phi.strides[0]) )) + __pyx_t_88)) )));
+326:             dS[ii] = dLr[iiL]*dRPhirRef[iiL]
      __pyx_t_91 = __pyx_v_iiL;
      __pyx_t_92 = __pyx_v_iiL;
      __pyx_t_93 = __pyx_v_ii;
      *__Pyx_BufPtrStrided1d(double *, __pyx_pybuffernd_dS.rcbuffer->pybuffer.buf, __pyx_t_93, __pyx_pybuffernd_dS.diminfo[0].strides) = ((*__Pyx_BufPtrStrided1d(double *, __pyx_pybuffernd_dLr.rcbuffer->pybuffer.buf, __pyx_t_91, __pyx_pybuffernd_dLr.diminfo[0].strides)) * (*((double *) ( /* dim=0 */ ((char *) (((double *) __pyx_v_dRPhirRef.data) + __pyx_t_92)) ))));
+327:             if dRPhir[iiL]==-1.:
      __pyx_t_94 = __pyx_v_iiL;
      __pyx_t_10 = (((*__Pyx_BufPtrStrided1d(double *, __pyx_pybuffernd_dRPhir.rcbuffer->pybuffer.buf, __pyx_t_94, __pyx_pybuffernd_dRPhir.diminfo[0].strides)) == -1.) != 0);
      if (__pyx_t_10) {
/* … */
      }
    }
  }
  __pyx_L12:;
+328:                 dRPhir[iiL] = dRPhirRef[iiL]
        __pyx_t_95 = __pyx_v_iiL;
        __pyx_t_96 = __pyx_v_iiL;
        *__Pyx_BufPtrStrided1d(double *, __pyx_pybuffernd_dRPhir.rcbuffer->pybuffer.buf, __pyx_t_96, __pyx_pybuffernd_dRPhir.diminfo[0].strides) = (*((double *) ( /* dim=0 */ ((char *) (((double *) __pyx_v_dRPhirRef.data) + __pyx_t_95)) )));
+329:     return Pts, dS, NL, dLr, Rref, dRPhir[dRPhir>-1.], <long>nRPhi0, VPbis
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_4 = PyObject_RichCompare(((PyObject *)__pyx_v_dRPhir), __pyx_float_neg_1_, Py_GT); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 329, __pyx_L1_error)
  __pyx_t_14 = PyObject_GetItem(((PyObject *)__pyx_v_dRPhir), __pyx_t_4); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 329, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_14);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_4 = __Pyx_PyInt_From_long(((long)__pyx_v_nRPhi0)); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 329, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_6 = PyTuple_New(8); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 329, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_INCREF(((PyObject *)__pyx_v_Pts));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_Pts));
  PyTuple_SET_ITEM(__pyx_t_6, 0, ((PyObject *)__pyx_v_Pts));
  __Pyx_INCREF(((PyObject *)__pyx_v_dS));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_dS));
  PyTuple_SET_ITEM(__pyx_t_6, 1, ((PyObject *)__pyx_v_dS));
  __Pyx_INCREF(((PyObject *)__pyx_v_NL));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_NL));
  PyTuple_SET_ITEM(__pyx_t_6, 2, ((PyObject *)__pyx_v_NL));
  __Pyx_INCREF(((PyObject *)__pyx_v_dLr));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_dLr));
  PyTuple_SET_ITEM(__pyx_t_6, 3, ((PyObject *)__pyx_v_dLr));
  __Pyx_INCREF(((PyObject *)__pyx_v_Rref));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_Rref));
  PyTuple_SET_ITEM(__pyx_t_6, 4, ((PyObject *)__pyx_v_Rref));
  __Pyx_GIVEREF(__pyx_t_14);
  PyTuple_SET_ITEM(__pyx_t_6, 5, __pyx_t_14);
  __Pyx_GIVEREF(__pyx_t_4);
  PyTuple_SET_ITEM(__pyx_t_6, 6, __pyx_t_4);
  __Pyx_INCREF(((PyObject *)__pyx_v_VPbis));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_VPbis));
  PyTuple_SET_ITEM(__pyx_t_6, 7, ((PyObject *)__pyx_v_VPbis));
  __pyx_t_14 = 0;
  __pyx_t_4 = 0;
  __pyx_r = __pyx_t_6;
  __pyx_t_6 = 0;
  goto __pyx_L0;
 330: 
 331: 
 332: @cython.cdivision(True)
 333: @cython.wraparound(False)
 334: @cython.boundscheck(False)
+335: def _Ves_Smesh_TorStruct_SubFromD_cython(double[::1] PhiMinMax, double dL, double dRPhi,
/* Python wrapper */
static PyObject *__pyx_pw_46_cython_magic_8152fc40fb05daa7217c00b66474f995_9_Ves_Smesh_TorStruct_SubFromD_cython(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_46_cython_magic_8152fc40fb05daa7217c00b66474f995_8_Ves_Smesh_TorStruct_SubFromD_cython[] = " Return the desired surfacic submesh indicated by the limits (DR,DZ,DPhi), for the desired resolution (dR,dZ,dRphi) ";
static PyMethodDef __pyx_mdef_46_cython_magic_8152fc40fb05daa7217c00b66474f995_9_Ves_Smesh_TorStruct_SubFromD_cython = {"_Ves_Smesh_TorStruct_SubFromD_cython", (PyCFunction)__pyx_pw_46_cython_magic_8152fc40fb05daa7217c00b66474f995_9_Ves_Smesh_TorStruct_SubFromD_cython, METH_VARARGS|METH_KEYWORDS, __pyx_doc_46_cython_magic_8152fc40fb05daa7217c00b66474f995_8_Ves_Smesh_TorStruct_SubFromD_cython};
static PyObject *__pyx_pw_46_cython_magic_8152fc40fb05daa7217c00b66474f995_9_Ves_Smesh_TorStruct_SubFromD_cython(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  __Pyx_memviewslice __pyx_v_PhiMinMax = { 0, 0, { 0 }, { 0 }, { 0 } };
  double __pyx_v_dL;
  double __pyx_v_dRPhi;
  __Pyx_memviewslice __pyx_v_VPoly = { 0, 0, { 0 }, { 0 }, { 0 } };
  PyObject *__pyx_v_DR = 0;
  PyObject *__pyx_v_DZ = 0;
  PyObject *__pyx_v_DPhi = 0;
  double __pyx_v_DIn;
  PyObject *__pyx_v_VIn = 0;
  PyObject *__pyx_v_Out = 0;
  double __pyx_v_margin;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("_Ves_Smesh_TorStruct_SubFromD_cython (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_PhiMinMax,&__pyx_n_s_dL,&__pyx_n_s_dRPhi,&__pyx_n_s_VPoly,&__pyx_n_s_DR,&__pyx_n_s_DZ,&__pyx_n_s_DPhi,&__pyx_n_s_DIn,&__pyx_n_s_VIn,&__pyx_n_s_Out,&__pyx_n_s_margin,0};
    PyObject* values[11] = {0,0,0,0,0,0,0,0,0,0,0};
/* … */
  /* function exit code */
  goto __pyx_L0;
  __pyx_L1_error:;
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_46_cython_magic_8152fc40fb05daa7217c00b66474f995_8_Ves_Smesh_TorStruct_SubFromD_cython(CYTHON_UNUSED PyObject *__pyx_self, __Pyx_memviewslice __pyx_v_PhiMinMax, double __pyx_v_dL, double __pyx_v_dRPhi, __Pyx_memviewslice __pyx_v_VPoly, PyObject *__pyx_v_DR, PyObject *__pyx_v_DZ, PyObject *__pyx_v_DPhi, double __pyx_v_DIn, PyObject *__pyx_v_VIn, PyObject *__pyx_v_Out, double __pyx_v_margin) {
  double __pyx_v_Dphi;
  double __pyx_v_dR0r;
  double __pyx_v_dZ0r;
  int __pyx_v_NR0;
  int __pyx_v_NZ0;
  int __pyx_v_R0n;
  int __pyx_v_Z0n;
  PyArrayObject *__pyx_v_R0 = 0;
  PyArrayObject *__pyx_v_Z0 = 0;
  PyArrayObject *__pyx_v_dsF = 0;
  PyArrayObject *__pyx_v_dSM = 0;
  PyArrayObject *__pyx_v_dLr = 0;
  PyArrayObject *__pyx_v_Rref = 0;
  PyArrayObject *__pyx_v_dRPhir = 0;
  PyArrayObject *__pyx_v_dS = 0;
  PyArrayObject *__pyx_v_indR0 = 0;
  PyArrayObject *__pyx_v_indZ0 = 0;
  PyArrayObject *__pyx_v_iind = 0;
  PyArrayObject *__pyx_v_iindF = 0;
  PyArrayObject *__pyx_v_indM = 0;
  PyArrayObject *__pyx_v_NL = 0;
  PyArrayObject *__pyx_v_ind = 0;
  PyArrayObject *__pyx_v_ptsrz = 0;
  PyArrayObject *__pyx_v_pts = 0;
  PyArrayObject *__pyx_v_PtsM = 0;
  PyArrayObject *__pyx_v_VPbis = 0;
  PyArrayObject *__pyx_v_Pts = 0;
  PyObject *__pyx_v_LPts = 0;
  PyObject *__pyx_v_LdS = 0;
  PyObject *__pyx_v_Lind = 0;
  int __pyx_v_Faces;
  PyObject *__pyx_v_indin = NULL;
  PyObject *__pyx_v_nRPhi0 = NULL;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_NL;
  __Pyx_Buffer __pyx_pybuffer_NL;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_Pts;
  __Pyx_Buffer __pyx_pybuffer_Pts;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_PtsM;
  __Pyx_Buffer __pyx_pybuffer_PtsM;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_R0;
  __Pyx_Buffer __pyx_pybuffer_R0;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_Rref;
  __Pyx_Buffer __pyx_pybuffer_Rref;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_VPbis;
  __Pyx_Buffer __pyx_pybuffer_VPbis;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_Z0;
  __Pyx_Buffer __pyx_pybuffer_Z0;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_dLr;
  __Pyx_Buffer __pyx_pybuffer_dLr;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_dRPhir;
  __Pyx_Buffer __pyx_pybuffer_dRPhir;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_dS;
  __Pyx_Buffer __pyx_pybuffer_dS;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_dSM;
  __Pyx_Buffer __pyx_pybuffer_dSM;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_dsF;
  __Pyx_Buffer __pyx_pybuffer_dsF;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_iind;
  __Pyx_Buffer __pyx_pybuffer_iind;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_iindF;
  __Pyx_Buffer __pyx_pybuffer_iindF;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_ind;
  __Pyx_Buffer __pyx_pybuffer_ind;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_indM;
  __Pyx_Buffer __pyx_pybuffer_indM;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_indR0;
  __Pyx_Buffer __pyx_pybuffer_indR0;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_indZ0;
  __Pyx_Buffer __pyx_pybuffer_indZ0;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_pts;
  __Pyx_Buffer __pyx_pybuffer_pts;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_ptsrz;
  __Pyx_Buffer __pyx_pybuffer_ptsrz;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("_Ves_Smesh_TorStruct_SubFromD_cython", 0);
  __pyx_pybuffer_R0.pybuffer.buf = NULL;
  __pyx_pybuffer_R0.refcount = 0;
  __pyx_pybuffernd_R0.data = NULL;
  __pyx_pybuffernd_R0.rcbuffer = &__pyx_pybuffer_R0;
  __pyx_pybuffer_Z0.pybuffer.buf = NULL;
  __pyx_pybuffer_Z0.refcount = 0;
  __pyx_pybuffernd_Z0.data = NULL;
  __pyx_pybuffernd_Z0.rcbuffer = &__pyx_pybuffer_Z0;
  __pyx_pybuffer_dsF.pybuffer.buf = NULL;
  __pyx_pybuffer_dsF.refcount = 0;
  __pyx_pybuffernd_dsF.data = NULL;
  __pyx_pybuffernd_dsF.rcbuffer = &__pyx_pybuffer_dsF;
  __pyx_pybuffer_dSM.pybuffer.buf = NULL;
  __pyx_pybuffer_dSM.refcount = 0;
  __pyx_pybuffernd_dSM.data = NULL;
  __pyx_pybuffernd_dSM.rcbuffer = &__pyx_pybuffer_dSM;
  __pyx_pybuffer_dLr.pybuffer.buf = NULL;
  __pyx_pybuffer_dLr.refcount = 0;
  __pyx_pybuffernd_dLr.data = NULL;
  __pyx_pybuffernd_dLr.rcbuffer = &__pyx_pybuffer_dLr;
  __pyx_pybuffer_Rref.pybuffer.buf = NULL;
  __pyx_pybuffer_Rref.refcount = 0;
  __pyx_pybuffernd_Rref.data = NULL;
  __pyx_pybuffernd_Rref.rcbuffer = &__pyx_pybuffer_Rref;
  __pyx_pybuffer_dRPhir.pybuffer.buf = NULL;
  __pyx_pybuffer_dRPhir.refcount = 0;
  __pyx_pybuffernd_dRPhir.data = NULL;
  __pyx_pybuffernd_dRPhir.rcbuffer = &__pyx_pybuffer_dRPhir;
  __pyx_pybuffer_dS.pybuffer.buf = NULL;
  __pyx_pybuffer_dS.refcount = 0;
  __pyx_pybuffernd_dS.data = NULL;
  __pyx_pybuffernd_dS.rcbuffer = &__pyx_pybuffer_dS;
  __pyx_pybuffer_indR0.pybuffer.buf = NULL;
  __pyx_pybuffer_indR0.refcount = 0;
  __pyx_pybuffernd_indR0.data = NULL;
  __pyx_pybuffernd_indR0.rcbuffer = &__pyx_pybuffer_indR0;
  __pyx_pybuffer_indZ0.pybuffer.buf = NULL;
  __pyx_pybuffer_indZ0.refcount = 0;
  __pyx_pybuffernd_indZ0.data = NULL;
  __pyx_pybuffernd_indZ0.rcbuffer = &__pyx_pybuffer_indZ0;
  __pyx_pybuffer_iind.pybuffer.buf = NULL;
  __pyx_pybuffer_iind.refcount = 0;
  __pyx_pybuffernd_iind.data = NULL;
  __pyx_pybuffernd_iind.rcbuffer = &__pyx_pybuffer_iind;
  __pyx_pybuffer_iindF.pybuffer.buf = NULL;
  __pyx_pybuffer_iindF.refcount = 0;
  __pyx_pybuffernd_iindF.data = NULL;
  __pyx_pybuffernd_iindF.rcbuffer = &__pyx_pybuffer_iindF;
  __pyx_pybuffer_indM.pybuffer.buf = NULL;
  __pyx_pybuffer_indM.refcount = 0;
  __pyx_pybuffernd_indM.data = NULL;
  __pyx_pybuffernd_indM.rcbuffer = &__pyx_pybuffer_indM;
  __pyx_pybuffer_NL.pybuffer.buf = NULL;
  __pyx_pybuffer_NL.refcount = 0;
  __pyx_pybuffernd_NL.data = NULL;
  __pyx_pybuffernd_NL.rcbuffer = &__pyx_pybuffer_NL;
  __pyx_pybuffer_ind.pybuffer.buf = NULL;
  __pyx_pybuffer_ind.refcount = 0;
  __pyx_pybuffernd_ind.data = NULL;
  __pyx_pybuffernd_ind.rcbuffer = &__pyx_pybuffer_ind;
  __pyx_pybuffer_ptsrz.pybuffer.buf = NULL;
  __pyx_pybuffer_ptsrz.refcount = 0;
  __pyx_pybuffernd_ptsrz.data = NULL;
  __pyx_pybuffernd_ptsrz.rcbuffer = &__pyx_pybuffer_ptsrz;
  __pyx_pybuffer_pts.pybuffer.buf = NULL;
  __pyx_pybuffer_pts.refcount = 0;
  __pyx_pybuffernd_pts.data = NULL;
  __pyx_pybuffernd_pts.rcbuffer = &__pyx_pybuffer_pts;
  __pyx_pybuffer_PtsM.pybuffer.buf = NULL;
  __pyx_pybuffer_PtsM.refcount = 0;
  __pyx_pybuffernd_PtsM.data = NULL;
  __pyx_pybuffernd_PtsM.rcbuffer = &__pyx_pybuffer_PtsM;
  __pyx_pybuffer_VPbis.pybuffer.buf = NULL;
  __pyx_pybuffer_VPbis.refcount = 0;
  __pyx_pybuffernd_VPbis.data = NULL;
  __pyx_pybuffernd_VPbis.rcbuffer = &__pyx_pybuffer_VPbis;
  __pyx_pybuffer_Pts.pybuffer.buf = NULL;
  __pyx_pybuffer_Pts.refcount = 0;
  __pyx_pybuffernd_Pts.data = NULL;
  __pyx_pybuffernd_Pts.rcbuffer = &__pyx_pybuffer_Pts;
/* … */
  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_9);
  __PYX_XDEC_MEMVIEW(&__pyx_t_10, 1);
  __Pyx_XDECREF(__pyx_t_11);
  __Pyx_XDECREF(__pyx_t_12);
  __Pyx_XDECREF(__pyx_t_15);
  __Pyx_XDECREF(__pyx_t_16);
  __Pyx_XDECREF(__pyx_t_17);
  __PYX_XDEC_MEMVIEW(&__pyx_t_29, 1);
  __Pyx_XDECREF(__pyx_t_33);
  __Pyx_XDECREF(__pyx_t_35);
  { PyObject *__pyx_type, *__pyx_value, *__pyx_tb;
    __Pyx_PyThreadState_declare
    __Pyx_PyThreadState_assign
    __Pyx_ErrFetch(&__pyx_type, &__pyx_value, &__pyx_tb);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_NL.rcbuffer->pybuffer);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_Pts.rcbuffer->pybuffer);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_PtsM.rcbuffer->pybuffer);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_R0.rcbuffer->pybuffer);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_Rref.rcbuffer->pybuffer);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_VPbis.rcbuffer->pybuffer);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_Z0.rcbuffer->pybuffer);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_dLr.rcbuffer->pybuffer);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_dRPhir.rcbuffer->pybuffer);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_dS.rcbuffer->pybuffer);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_dSM.rcbuffer->pybuffer);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_dsF.rcbuffer->pybuffer);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_iind.rcbuffer->pybuffer);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_iindF.rcbuffer->pybuffer);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_ind.rcbuffer->pybuffer);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_indM.rcbuffer->pybuffer);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_indR0.rcbuffer->pybuffer);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_indZ0.rcbuffer->pybuffer);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_pts.rcbuffer->pybuffer);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_ptsrz.rcbuffer->pybuffer);
  __Pyx_ErrRestore(__pyx_type, __pyx_value, __pyx_tb);}
  __Pyx_AddTraceback("_cython_magic_8152fc40fb05daa7217c00b66474f995._Ves_Smesh_TorStruct_SubFromD_cython", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  goto __pyx_L2;
  __pyx_L0:;
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_NL.rcbuffer->pybuffer);
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_Pts.rcbuffer->pybuffer);
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_PtsM.rcbuffer->pybuffer);
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_R0.rcbuffer->pybuffer);
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_Rref.rcbuffer->pybuffer);
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_VPbis.rcbuffer->pybuffer);
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_Z0.rcbuffer->pybuffer);
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_dLr.rcbuffer->pybuffer);
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_dRPhir.rcbuffer->pybuffer);
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_dS.rcbuffer->pybuffer);
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_dSM.rcbuffer->pybuffer);
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_dsF.rcbuffer->pybuffer);
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_iind.rcbuffer->pybuffer);
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_iindF.rcbuffer->pybuffer);
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_ind.rcbuffer->pybuffer);
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_indM.rcbuffer->pybuffer);
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_indR0.rcbuffer->pybuffer);
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_indZ0.rcbuffer->pybuffer);
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_pts.rcbuffer->pybuffer);
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_ptsrz.rcbuffer->pybuffer);
  __pyx_L2:;
  __Pyx_XDECREF((PyObject *)__pyx_v_R0);
  __Pyx_XDECREF((PyObject *)__pyx_v_Z0);
  __Pyx_XDECREF((PyObject *)__pyx_v_dsF);
  __Pyx_XDECREF((PyObject *)__pyx_v_dSM);
  __Pyx_XDECREF((PyObject *)__pyx_v_dLr);
  __Pyx_XDECREF((PyObject *)__pyx_v_Rref);
  __Pyx_XDECREF((PyObject *)__pyx_v_dRPhir);
  __Pyx_XDECREF((PyObject *)__pyx_v_dS);
  __Pyx_XDECREF((PyObject *)__pyx_v_indR0);
  __Pyx_XDECREF((PyObject *)__pyx_v_indZ0);
  __Pyx_XDECREF((PyObject *)__pyx_v_iind);
  __Pyx_XDECREF((PyObject *)__pyx_v_iindF);
  __Pyx_XDECREF((PyObject *)__pyx_v_indM);
  __Pyx_XDECREF((PyObject *)__pyx_v_NL);
  __Pyx_XDECREF((PyObject *)__pyx_v_ind);
  __Pyx_XDECREF((PyObject *)__pyx_v_ptsrz);
  __Pyx_XDECREF((PyObject *)__pyx_v_pts);
  __Pyx_XDECREF((PyObject *)__pyx_v_PtsM);
  __Pyx_XDECREF((PyObject *)__pyx_v_VPbis);
  __Pyx_XDECREF((PyObject *)__pyx_v_Pts);
  __Pyx_XDECREF(__pyx_v_LPts);
  __Pyx_XDECREF(__pyx_v_LdS);
  __Pyx_XDECREF(__pyx_v_Lind);
  __Pyx_XDECREF(__pyx_v_indin);
  __Pyx_XDECREF(__pyx_v_nRPhi0);
  __PYX_XDEC_MEMVIEW(&__pyx_v_PhiMinMax, 1);
  __PYX_XDEC_MEMVIEW(&__pyx_v_VPoly, 1);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}
/* … */
  __pyx_tuple__113 = PyTuple_Pack(45, __pyx_n_s_PhiMinMax, __pyx_n_s_dL, __pyx_n_s_dRPhi, __pyx_n_s_VPoly, __pyx_n_s_DR, __pyx_n_s_DZ, __pyx_n_s_DPhi, __pyx_n_s_DIn, __pyx_n_s_VIn, __pyx_n_s_Out, __pyx_n_s_margin, __pyx_n_s_Dphi, __pyx_n_s_dR0r, __pyx_n_s_dZ0r, __pyx_n_s_NR0, __pyx_n_s_NZ0, __pyx_n_s_R0n, __pyx_n_s_Z0n, __pyx_n_s_NRPhi0, __pyx_n_s_R0, __pyx_n_s_Z0, __pyx_n_s_dsF, __pyx_n_s_dSM, __pyx_n_s_dLr, __pyx_n_s_Rref, __pyx_n_s_dRPhir, __pyx_n_s_dS, __pyx_n_s_indR0, __pyx_n_s_indZ0, __pyx_n_s_iind, __pyx_n_s_iindF, __pyx_n_s_indM, __pyx_n_s_NL, __pyx_n_s_ind, __pyx_n_s_ptsrz, __pyx_n_s_pts, __pyx_n_s_PtsM, __pyx_n_s_VPbis, __pyx_n_s_Pts, __pyx_n_s_LPts, __pyx_n_s_LdS, __pyx_n_s_Lind, __pyx_n_s_Faces, __pyx_n_s_indin, __pyx_n_s_nRPhi0); if (unlikely(!__pyx_tuple__113)) __PYX_ERR(0, 335, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__113);
  __Pyx_GIVEREF(__pyx_tuple__113);
/* … */
  __pyx_t_2 = PyCFunction_NewEx(&__pyx_mdef_46_cython_magic_8152fc40fb05daa7217c00b66474f995_9_Ves_Smesh_TorStruct_SubFromD_cython, NULL, __pyx_n_s_cython_magic_8152fc40fb05daa721); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 335, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_Ves_Smesh_TorStruct_SubFromD_cy, __pyx_t_2) < 0) __PYX_ERR(0, 335, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_codeobj__114 = (PyObject*)__Pyx_PyCode_New(11, 0, 45, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__113, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_Home_DV226270_cache_ipython_cyt, __pyx_n_s_Ves_Smesh_TorStruct_SubFromD_cy, 335, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__114)) __PYX_ERR(0, 335, __pyx_L1_error)
 336:                                          double[:,::1] VPoly,
+337:                                          DR=None, DZ=None, DPhi=None,
    values[4] = ((PyObject *)Py_None);
    values[5] = ((PyObject *)Py_None);
    values[6] = ((PyObject *)Py_None);
+338:                                          double DIn=0., VIn=None,
    values[8] = ((PyObject *)Py_None);
    values[9] = ((PyObject*)__pyx_kp_u_X_Y_Z);
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case 11: values[10] = PyTuple_GET_ITEM(__pyx_args, 10);
        case 10: values[9] = PyTuple_GET_ITEM(__pyx_args, 9);
        case  9: values[8] = PyTuple_GET_ITEM(__pyx_args, 8);
        case  8: values[7] = PyTuple_GET_ITEM(__pyx_args, 7);
        case  7: values[6] = PyTuple_GET_ITEM(__pyx_args, 6);
        case  6: values[5] = PyTuple_GET_ITEM(__pyx_args, 5);
        case  5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_PhiMinMax)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        case  1:
        if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_dL)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_Ves_Smesh_TorStruct_SubFromD_cython", 0, 4, 11, 1); __PYX_ERR(0, 335, __pyx_L3_error)
        }
        case  2:
        if (likely((values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_dRPhi)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_Ves_Smesh_TorStruct_SubFromD_cython", 0, 4, 11, 2); __PYX_ERR(0, 335, __pyx_L3_error)
        }
        case  3:
        if (likely((values[3] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_VPoly)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_Ves_Smesh_TorStruct_SubFromD_cython", 0, 4, 11, 3); __PYX_ERR(0, 335, __pyx_L3_error)
        }
        case  4:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_DR);
          if (value) { values[4] = value; kw_args--; }
        }
        case  5:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_DZ);
          if (value) { values[5] = value; kw_args--; }
        }
        case  6:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_DPhi);
          if (value) { values[6] = value; kw_args--; }
        }
        case  7:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_DIn);
          if (value) { values[7] = value; kw_args--; }
        }
        case  8:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_VIn);
          if (value) { values[8] = value; kw_args--; }
        }
        case  9:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_Out);
          if (value) { values[9] = value; kw_args--; }
        }
        case 10:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_margin);
          if (value) { values[10] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "_Ves_Smesh_TorStruct_SubFromD_cython") < 0)) __PYX_ERR(0, 335, __pyx_L3_error)
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case 11: values[10] = PyTuple_GET_ITEM(__pyx_args, 10);
        case 10: values[9] = PyTuple_GET_ITEM(__pyx_args, 9);
        case  9: values[8] = PyTuple_GET_ITEM(__pyx_args, 8);
        case  8: values[7] = PyTuple_GET_ITEM(__pyx_args, 7);
        case  7: values[6] = PyTuple_GET_ITEM(__pyx_args, 6);
        case  6: values[5] = PyTuple_GET_ITEM(__pyx_args, 5);
        case  5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    __pyx_v_PhiMinMax = __Pyx_PyObject_to_MemoryviewSlice_dc_double(values[0]); if (unlikely(!__pyx_v_PhiMinMax.memview)) __PYX_ERR(0, 335, __pyx_L3_error)
    __pyx_v_dL = __pyx_PyFloat_AsDouble(values[1]); if (unlikely((__pyx_v_dL == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 335, __pyx_L3_error)
    __pyx_v_dRPhi = __pyx_PyFloat_AsDouble(values[2]); if (unlikely((__pyx_v_dRPhi == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 335, __pyx_L3_error)
    __pyx_v_VPoly = __Pyx_PyObject_to_MemoryviewSlice_d_dc_double(values[3]); if (unlikely(!__pyx_v_VPoly.memview)) __PYX_ERR(0, 336, __pyx_L3_error)
    __pyx_v_DR = values[4];
    __pyx_v_DZ = values[5];
    __pyx_v_DPhi = values[6];
    if (values[7]) {
      __pyx_v_DIn = __pyx_PyFloat_AsDouble(values[7]); if (unlikely((__pyx_v_DIn == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 338, __pyx_L3_error)
    } else {
      __pyx_v_DIn = ((double)0.);
    }
    __pyx_v_VIn = values[8];
    __pyx_v_Out = ((PyObject*)values[9]);
    if (values[10]) {
      __pyx_v_margin = __pyx_PyFloat_AsDouble(values[10]); if (unlikely((__pyx_v_margin == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 339, __pyx_L3_error)
    } else {
      __pyx_v_margin = ((double)1.e-9);
    }
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("_Ves_Smesh_TorStruct_SubFromD_cython", 0, 4, 11, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 335, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("_cython_magic_8152fc40fb05daa7217c00b66474f995._Ves_Smesh_TorStruct_SubFromD_cython", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_Out), (&PyUnicode_Type), 1, "Out", 1))) __PYX_ERR(0, 339, __pyx_L1_error)
  __pyx_r = __pyx_pf_46_cython_magic_8152fc40fb05daa7217c00b66474f995_8_Ves_Smesh_TorStruct_SubFromD_cython(__pyx_self, __pyx_v_PhiMinMax, __pyx_v_dL, __pyx_v_dRPhi, __pyx_v_VPoly, __pyx_v_DR, __pyx_v_DZ, __pyx_v_DPhi, __pyx_v_DIn, __pyx_v_VIn, __pyx_v_Out, __pyx_v_margin);
 339:                                          str Out='(X,Y,Z)', double margin=1.e-9):
 340:     " Return the desired surfacic submesh indicated by the limits (DR,DZ,DPhi), for the desired resolution (dR,dZ,dRphi) "
 341:     cdef double Dphi, dR0r, dZ0r
 342:     cdef int NR0, NZ0, R0n, Z0n, NRPhi0
 343:     cdef cnp.ndarray[double, ndim=1] R0, Z0, dsF, dSM, dLr, Rref, dRPhir, dS
 344:     cdef cnp.ndarray[long,ndim=1] indR0, indZ0, iind, iindF, indM, NL, ind
 345:     cdef cnp.ndarray[double,ndim=2] ptsrz, pts, PtsM, VPbis, Pts
+346:     cdef list LPts=[], LdS=[], Lind=[]
  __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 346, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_LPts = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;
  __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 346, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_LdS = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;
  __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 346, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_Lind = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;
 347: 
 348:     # Pre-format input
+349:     if DPhi is not None:
  __pyx_t_2 = (__pyx_v_DPhi != Py_None);
  __pyx_t_3 = (__pyx_t_2 != 0);
  if (__pyx_t_3) {
/* … */
  }
+350:         if DPhi[0]<=PhiMinMax[0]:
    __pyx_t_1 = __Pyx_GetItemInt(__pyx_v_DPhi, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 350, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_4 = 0;
    __pyx_t_5 = PyFloat_FromDouble((*((double *) ( /* dim=0 */ ((char *) (((double *) __pyx_v_PhiMinMax.data) + __pyx_t_4)) )))); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 350, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_6 = PyObject_RichCompare(__pyx_t_1, __pyx_t_5, Py_LE); __Pyx_XGOTREF(__pyx_t_6); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 350, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_6); if (unlikely(__pyx_t_3 < 0)) __PYX_ERR(0, 350, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    if (__pyx_t_3) {
/* … */
    }
+351:             DPhi[0] = None
      if (unlikely(__Pyx_SetItemInt(__pyx_v_DPhi, 0, Py_None, long, 1, __Pyx_PyInt_From_long, 0, 0, 0) < 0)) __PYX_ERR(0, 351, __pyx_L1_error)
+352:         if DPhi[1]>=PhiMinMax[1]:
    __pyx_t_6 = __Pyx_GetItemInt(__pyx_v_DPhi, 1, long, 1, __Pyx_PyInt_From_long, 0, 0, 0); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 352, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_t_7 = 1;
    __pyx_t_5 = PyFloat_FromDouble((*((double *) ( /* dim=0 */ ((char *) (((double *) __pyx_v_PhiMinMax.data) + __pyx_t_7)) )))); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 352, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_1 = PyObject_RichCompare(__pyx_t_6, __pyx_t_5, Py_GE); __Pyx_XGOTREF(__pyx_t_1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 352, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_3 < 0)) __PYX_ERR(0, 352, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    if (__pyx_t_3) {
/* … */
    }
+353:             DPhi[1] = None
      if (unlikely(__Pyx_SetItemInt(__pyx_v_DPhi, 1, Py_None, long, 1, __Pyx_PyInt_From_long, 0, 0, 0) < 0)) __PYX_ERR(0, 353, __pyx_L1_error)
 354: 
+355:     Dphi = DIn/np.max(VPoly[0,:]) if DIn!=0. else 0. # Required distance effective at max R
  if (((__pyx_v_DIn != 0.) != 0)) {
    __pyx_t_1 = PyFloat_FromDouble(__pyx_v_DIn); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 355, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_6 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 355, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_n_s_max); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 355, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_9);
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __pyx_t_10.data = __pyx_v_VPoly.data;
    __pyx_t_10.memview = __pyx_v_VPoly.memview;
    __PYX_INC_MEMVIEW(&__pyx_t_10, 0);
    {
    Py_ssize_t __pyx_tmp_idx = 0;
    Py_ssize_t __pyx_tmp_shape = __pyx_v_VPoly.shape[0];
    Py_ssize_t __pyx_tmp_stride = __pyx_v_VPoly.strides[0];
    if (0 && (__pyx_tmp_idx < 0))
        __pyx_tmp_idx += __pyx_tmp_shape;
    if (0 && (__pyx_tmp_idx < 0 || __pyx_tmp_idx >= __pyx_tmp_shape)) {
        PyErr_SetString(PyExc_IndexError, "Index out of bounds (axis 0)");
        __PYX_ERR(0, 355, __pyx_L1_error)
    }
        __pyx_t_10.data += __pyx_tmp_idx * __pyx_tmp_stride;
}

__pyx_t_10.shape[0] = __pyx_v_VPoly.shape[1];
__pyx_t_10.strides[0] = __pyx_v_VPoly.strides[1];
    __pyx_t_10.suboffsets[0] = -1;

__pyx_t_6 = __pyx_memoryview_fromslice(__pyx_t_10, 1, (PyObject *(*)(char *)) __pyx_memview_get_double, (int (*)(char *, PyObject *)) __pyx_memview_set_double, 0);; if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 355, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __PYX_XDEC_MEMVIEW(&__pyx_t_10, 1);
    __pyx_t_10.memview = NULL;
    __pyx_t_10.data = NULL;
    __pyx_t_11 = NULL;
    if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_9))) {
      __pyx_t_11 = PyMethod_GET_SELF(__pyx_t_9);
      if (likely(__pyx_t_11)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_9);
        __Pyx_INCREF(__pyx_t_11);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_9, function);
      }
    }
    if (!__pyx_t_11) {
      __pyx_t_5 = __Pyx_PyObject_CallOneArg(__pyx_t_9, __pyx_t_6); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 355, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      __Pyx_GOTREF(__pyx_t_5);
    } else {
      #if CYTHON_FAST_PYCALL
      if (PyFunction_Check(__pyx_t_9)) {
        PyObject *__pyx_temp[2] = {__pyx_t_11, __pyx_t_6};
        __pyx_t_5 = __Pyx_PyFunction_FastCall(__pyx_t_9, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 355, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0;
        __Pyx_GOTREF(__pyx_t_5);
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      } else
      #endif
      #if CYTHON_FAST_PYCCALL
      if (__Pyx_PyFastCFunction_Check(__pyx_t_9)) {
        PyObject *__pyx_temp[2] = {__pyx_t_11, __pyx_t_6};
        __pyx_t_5 = __Pyx_PyCFunction_FastCall(__pyx_t_9, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 355, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0;
        __Pyx_GOTREF(__pyx_t_5);
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      } else
      #endif
      {
        __pyx_t_12 = PyTuple_New(1+1); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 355, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_12);
        __Pyx_GIVEREF(__pyx_t_11); PyTuple_SET_ITEM(__pyx_t_12, 0, __pyx_t_11); __pyx_t_11 = NULL;
        __Pyx_GIVEREF(__pyx_t_6);
        PyTuple_SET_ITEM(__pyx_t_12, 0+1, __pyx_t_6);
        __pyx_t_6 = 0;
        __pyx_t_5 = __Pyx_PyObject_Call(__pyx_t_9, __pyx_t_12, NULL); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 355, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_5);
        __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
      }
    }
    __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
    __pyx_t_9 = __Pyx_PyNumber_Divide(__pyx_t_1, __pyx_t_5); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 355, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_9);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __pyx_t_13 = __pyx_PyFloat_AsDouble(__pyx_t_9); if (unlikely((__pyx_t_13 == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 355, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
    __pyx_t_8 = __pyx_t_13;
  } else {
    __pyx_t_8 = 0.;
  }
  __pyx_v_Dphi = __pyx_t_8;
 356: 
 357:     # Get the mesh for the faces
+358:     Faces = False
  __pyx_v_Faces = 0;
+359:     if DPhi is None or DPhi[0] is None or DPhi[1] is None:
  __pyx_t_2 = (__pyx_v_DPhi == Py_None);
  __pyx_t_14 = (__pyx_t_2 != 0);
  if (!__pyx_t_14) {
  } else {
    __pyx_t_3 = __pyx_t_14;
    goto __pyx_L7_bool_binop_done;
  }
  __pyx_t_9 = __Pyx_GetItemInt(__pyx_v_DPhi, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 0); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 359, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_9);
  __pyx_t_14 = (__pyx_t_9 == Py_None);
  __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
  __pyx_t_2 = (__pyx_t_14 != 0);
  if (!__pyx_t_2) {
  } else {
    __pyx_t_3 = __pyx_t_2;
    goto __pyx_L7_bool_binop_done;
  }
  __pyx_t_9 = __Pyx_GetItemInt(__pyx_v_DPhi, 1, long, 1, __Pyx_PyInt_From_long, 0, 0, 0); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 359, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_9);
  __pyx_t_2 = (__pyx_t_9 == Py_None);
  __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
  __pyx_t_14 = (__pyx_t_2 != 0);
  __pyx_t_3 = __pyx_t_14;
  __pyx_L7_bool_binop_done:;
  if (__pyx_t_3) {
/* … */
  }
+360:         R0, dR0r, indR0, NR0 = _Ves_mesh_dlfromL_cython(np.array([np.min(VPoly[0,:]),np.max(VPoly[0,:])]), dL, DL=DR, margin=margin)
    __pyx_t_9 = __Pyx_GetModuleGlobalName(__pyx_n_s_Ves_mesh_dlfromL_cython); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 360, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_9);
    __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 360, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_12 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_array); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 360, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_12);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_6 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 360, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_t_11 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_n_s_min); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 360, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_11);
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __pyx_t_10.data = __pyx_v_VPoly.data;
    __pyx_t_10.memview = __pyx_v_VPoly.memview;
    __PYX_INC_MEMVIEW(&__pyx_t_10, 0);
    {
    Py_ssize_t __pyx_tmp_idx = 0;
    Py_ssize_t __pyx_tmp_shape = __pyx_v_VPoly.shape[0];
    Py_ssize_t __pyx_tmp_stride = __pyx_v_VPoly.strides[0];
    if (0 && (__pyx_tmp_idx < 0))
        __pyx_tmp_idx += __pyx_tmp_shape;
    if (0 && (__pyx_tmp_idx < 0 || __pyx_tmp_idx >= __pyx_tmp_shape)) {
        PyErr_SetString(PyExc_IndexError, "Index out of bounds (axis 0)");
        __PYX_ERR(0, 360, __pyx_L1_error)
    }
        __pyx_t_10.data += __pyx_tmp_idx * __pyx_tmp_stride;
}

__pyx_t_10.shape[0] = __pyx_v_VPoly.shape[1];
__pyx_t_10.strides[0] = __pyx_v_VPoly.strides[1];
    __pyx_t_10.suboffsets[0] = -1;

__pyx_t_6 = __pyx_memoryview_fromslice(__pyx_t_10, 1, (PyObject *(*)(char *)) __pyx_memview_get_double, (int (*)(char *, PyObject *)) __pyx_memview_set_double, 0);; if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 360, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __PYX_XDEC_MEMVIEW(&__pyx_t_10, 1);
    __pyx_t_10.memview = NULL;
    __pyx_t_10.data = NULL;
    __pyx_t_15 = NULL;
    if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_11))) {
      __pyx_t_15 = PyMethod_GET_SELF(__pyx_t_11);
      if (likely(__pyx_t_15)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_11);
        __Pyx_INCREF(__pyx_t_15);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_11, function);
      }
    }
    if (!__pyx_t_15) {
      __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_11, __pyx_t_6); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 360, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      __Pyx_GOTREF(__pyx_t_1);
    } else {
      #if CYTHON_FAST_PYCALL
      if (PyFunction_Check(__pyx_t_11)) {
        PyObject *__pyx_temp[2] = {__pyx_t_15, __pyx_t_6};
        __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_11, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 360, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0;
        __Pyx_GOTREF(__pyx_t_1);
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      } else
      #endif
      #if CYTHON_FAST_PYCCALL
      if (__Pyx_PyFastCFunction_Check(__pyx_t_11)) {
        PyObject *__pyx_temp[2] = {__pyx_t_15, __pyx_t_6};
        __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_11, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 360, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0;
        __Pyx_GOTREF(__pyx_t_1);
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      } else
      #endif
      {
        __pyx_t_16 = PyTuple_New(1+1); if (unlikely(!__pyx_t_16)) __PYX_ERR(0, 360, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_16);
        __Pyx_GIVEREF(__pyx_t_15); PyTuple_SET_ITEM(__pyx_t_16, 0, __pyx_t_15); __pyx_t_15 = NULL;
        __Pyx_GIVEREF(__pyx_t_6);
        PyTuple_SET_ITEM(__pyx_t_16, 0+1, __pyx_t_6);
        __pyx_t_6 = 0;
        __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_11, __pyx_t_16, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 360, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_1);
        __Pyx_DECREF(__pyx_t_16); __pyx_t_16 = 0;
      }
    }
    __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
    __pyx_t_16 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_16)) __PYX_ERR(0, 360, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_16);
    __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_16, __pyx_n_s_max); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 360, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_DECREF(__pyx_t_16); __pyx_t_16 = 0;
    __pyx_t_10.data = __pyx_v_VPoly.data;
    __pyx_t_10.memview = __pyx_v_VPoly.memview;
    __PYX_INC_MEMVIEW(&__pyx_t_10, 0);
    {
    Py_ssize_t __pyx_tmp_idx = 0;
    Py_ssize_t __pyx_tmp_shape = __pyx_v_VPoly.shape[0];
    Py_ssize_t __pyx_tmp_stride = __pyx_v_VPoly.strides[0];
    if (0 && (__pyx_tmp_idx < 0))
        __pyx_tmp_idx += __pyx_tmp_shape;
    if (0 && (__pyx_tmp_idx < 0 || __pyx_tmp_idx >= __pyx_tmp_shape)) {
        PyErr_SetString(PyExc_IndexError, "Index out of bounds (axis 0)");
        __PYX_ERR(0, 360, __pyx_L1_error)
    }
        __pyx_t_10.data += __pyx_tmp_idx * __pyx_tmp_stride;
}

__pyx_t_10.shape[0] = __pyx_v_VPoly.shape[1];
__pyx_t_10.strides[0] = __pyx_v_VPoly.strides[1];
    __pyx_t_10.suboffsets[0] = -1;

__pyx_t_16 = __pyx_memoryview_fromslice(__pyx_t_10, 1, (PyObject *(*)(char *)) __pyx_memview_get_double, (int (*)(char *, PyObject *)) __pyx_memview_set_double, 0);; if (unlikely(!__pyx_t_16)) __PYX_ERR(0, 360, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_16);
    __PYX_XDEC_MEMVIEW(&__pyx_t_10, 1);
    __pyx_t_10.memview = NULL;
    __pyx_t_10.data = NULL;
    __pyx_t_15 = NULL;
    if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_6))) {
      __pyx_t_15 = PyMethod_GET_SELF(__pyx_t_6);
      if (likely(__pyx_t_15)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6);
        __Pyx_INCREF(__pyx_t_15);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_6, function);
      }
    }
    if (!__pyx_t_15) {
      __pyx_t_11 = __Pyx_PyObject_CallOneArg(__pyx_t_6, __pyx_t_16); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 360, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_16); __pyx_t_16 = 0;
      __Pyx_GOTREF(__pyx_t_11);
    } else {
      #if CYTHON_FAST_PYCALL
      if (PyFunction_Check(__pyx_t_6)) {
        PyObject *__pyx_temp[2] = {__pyx_t_15, __pyx_t_16};
        __pyx_t_11 = __Pyx_PyFunction_FastCall(__pyx_t_6, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 360, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0;
        __Pyx_GOTREF(__pyx_t_11);
        __Pyx_DECREF(__pyx_t_16); __pyx_t_16 = 0;
      } else
      #endif
      #if CYTHON_FAST_PYCCALL
      if (__Pyx_PyFastCFunction_Check(__pyx_t_6)) {
        PyObject *__pyx_temp[2] = {__pyx_t_15, __pyx_t_16};
        __pyx_t_11 = __Pyx_PyCFunction_FastCall(__pyx_t_6, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 360, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0;
        __Pyx_GOTREF(__pyx_t_11);
        __Pyx_DECREF(__pyx_t_16); __pyx_t_16 = 0;
      } else
      #endif
      {
        __pyx_t_17 = PyTuple_New(1+1); if (unlikely(!__pyx_t_17)) __PYX_ERR(0, 360, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_17);
        __Pyx_GIVEREF(__pyx_t_15); PyTuple_SET_ITEM(__pyx_t_17, 0, __pyx_t_15); __pyx_t_15 = NULL;
        __Pyx_GIVEREF(__pyx_t_16);
        PyTuple_SET_ITEM(__pyx_t_17, 0+1, __pyx_t_16);
        __pyx_t_16 = 0;
        __pyx_t_11 = __Pyx_PyObject_Call(__pyx_t_6, __pyx_t_17, NULL); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 360, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_11);
        __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;
      }
    }
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __pyx_t_6 = PyList_New(2); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 360, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_GIVEREF(__pyx_t_1);
    PyList_SET_ITEM(__pyx_t_6, 0, __pyx_t_1);
    __Pyx_GIVEREF(__pyx_t_11);
    PyList_SET_ITEM(__pyx_t_6, 1, __pyx_t_11);
    __pyx_t_1 = 0;
    __pyx_t_11 = 0;
    __pyx_t_11 = NULL;
    if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_12))) {
      __pyx_t_11 = PyMethod_GET_SELF(__pyx_t_12);
      if (likely(__pyx_t_11)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_12);
        __Pyx_INCREF(__pyx_t_11);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_12, function);
      }
    }
    if (!__pyx_t_11) {
      __pyx_t_5 = __Pyx_PyObject_CallOneArg(__pyx_t_12, __pyx_t_6); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 360, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      __Pyx_GOTREF(__pyx_t_5);
    } else {
      #if CYTHON_FAST_PYCALL
      if (PyFunction_Check(__pyx_t_12)) {
        PyObject *__pyx_temp[2] = {__pyx_t_11, __pyx_t_6};
        __pyx_t_5 = __Pyx_PyFunction_FastCall(__pyx_t_12, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 360, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0;
        __Pyx_GOTREF(__pyx_t_5);
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      } else
      #endif
      #if CYTHON_FAST_PYCCALL
      if (__Pyx_PyFastCFunction_Check(__pyx_t_12)) {
        PyObject *__pyx_temp[2] = {__pyx_t_11, __pyx_t_6};
        __pyx_t_5 = __Pyx_PyCFunction_FastCall(__pyx_t_12, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 360, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0;
        __Pyx_GOTREF(__pyx_t_5);
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      } else
      #endif
      {
        __pyx_t_1 = PyTuple_New(1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 360, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_1);
        __Pyx_GIVEREF(__pyx_t_11); PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_11); __pyx_t_11 = NULL;
        __Pyx_GIVEREF(__pyx_t_6);
        PyTuple_SET_ITEM(__pyx_t_1, 0+1, __pyx_t_6);
        __pyx_t_6 = 0;
        __pyx_t_5 = __Pyx_PyObject_Call(__pyx_t_12, __pyx_t_1, NULL); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 360, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_5);
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      }
    }
    __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
    __pyx_t_12 = PyFloat_FromDouble(__pyx_v_dL); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 360, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_12);
    __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 360, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_GIVEREF(__pyx_t_5);
    PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_5);
    __Pyx_GIVEREF(__pyx_t_12);
    PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_t_12);
    __pyx_t_5 = 0;
    __pyx_t_12 = 0;
    __pyx_t_12 = PyDict_New(); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 360, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_12);
    if (PyDict_SetItem(__pyx_t_12, __pyx_n_s_DL, __pyx_v_DR) < 0) __PYX_ERR(0, 360, __pyx_L1_error)
    __pyx_t_5 = PyFloat_FromDouble(__pyx_v_margin); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 360, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    if (PyDict_SetItem(__pyx_t_12, __pyx_n_s_margin, __pyx_t_5) < 0) __PYX_ERR(0, 360, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __pyx_t_5 = __Pyx_PyObject_Call(__pyx_t_9, __pyx_t_1, __pyx_t_12); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 360, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
    if ((likely(PyTuple_CheckExact(__pyx_t_5))) || (PyList_CheckExact(__pyx_t_5))) {
      PyObject* sequence = __pyx_t_5;
      #if !CYTHON_COMPILING_IN_PYPY
      Py_ssize_t size = Py_SIZE(sequence);
      #else
      Py_ssize_t size = PySequence_Size(sequence);
      #endif
      if (unlikely(size != 4)) {
        if (size > 4) __Pyx_RaiseTooManyValuesError(4);
        else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
        __PYX_ERR(0, 360, __pyx_L1_error)
      }
      #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
      if (likely(PyTuple_CheckExact(sequence))) {
        __pyx_t_12 = PyTuple_GET_ITEM(sequence, 0); 
        __pyx_t_1 = PyTuple_GET_ITEM(sequence, 1); 
        __pyx_t_9 = PyTuple_GET_ITEM(sequence, 2); 
        __pyx_t_6 = PyTuple_GET_ITEM(sequence, 3); 
      } else {
        __pyx_t_12 = PyList_GET_ITEM(sequence, 0); 
        __pyx_t_1 = PyList_GET_ITEM(sequence, 1); 
        __pyx_t_9 = PyList_GET_ITEM(sequence, 2); 
        __pyx_t_6 = PyList_GET_ITEM(sequence, 3); 
      }
      __Pyx_INCREF(__pyx_t_12);
      __Pyx_INCREF(__pyx_t_1);
      __Pyx_INCREF(__pyx_t_9);
      __Pyx_INCREF(__pyx_t_6);
      #else
      {
        Py_ssize_t i;
        PyObject** temps[4] = {&__pyx_t_12,&__pyx_t_1,&__pyx_t_9,&__pyx_t_6};
        for (i=0; i < 4; i++) {
          PyObject* item = PySequence_ITEM(sequence, i); if (unlikely(!item)) __PYX_ERR(0, 360, __pyx_L1_error)
          __Pyx_GOTREF(item);
          *(temps[i]) = item;
        }
      }
      #endif
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    } else {
      Py_ssize_t index = -1;
      PyObject** temps[4] = {&__pyx_t_12,&__pyx_t_1,&__pyx_t_9,&__pyx_t_6};
      __pyx_t_11 = PyObject_GetIter(__pyx_t_5); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 360, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_11);
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __pyx_t_18 = Py_TYPE(__pyx_t_11)->tp_iternext;
      for (index=0; index < 4; index++) {
        PyObject* item = __pyx_t_18(__pyx_t_11); if (unlikely(!item)) goto __pyx_L10_unpacking_failed;
        __Pyx_GOTREF(item);
        *(temps[index]) = item;
      }
      if (__Pyx_IternextUnpackEndCheck(__pyx_t_18(__pyx_t_11), 4) < 0) __PYX_ERR(0, 360, __pyx_L1_error)
      __pyx_t_18 = NULL;
      __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
      goto __pyx_L11_unpacking_done;
      __pyx_L10_unpacking_failed:;
      __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
      __pyx_t_18 = NULL;
      if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
      __PYX_ERR(0, 360, __pyx_L1_error)
      __pyx_L11_unpacking_done:;
    }
    if (!(likely(((__pyx_t_12) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_12, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 360, __pyx_L1_error)
    __pyx_t_8 = __pyx_PyFloat_AsDouble(__pyx_t_1); if (unlikely((__pyx_t_8 == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 360, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    if (!(likely(((__pyx_t_9) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_9, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 360, __pyx_L1_error)
    __pyx_t_19 = __Pyx_PyInt_As_int(__pyx_t_6); if (unlikely((__pyx_t_19 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 360, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __pyx_t_20 = ((PyArrayObject *)__pyx_t_12);
    {
      __Pyx_BufFmt_StackElem __pyx_stack[1];
      __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_R0.rcbuffer->pybuffer);
      __pyx_t_21 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_R0.rcbuffer->pybuffer, (PyObject*)__pyx_t_20, &__Pyx_TypeInfo_double, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack);
      if (unlikely(__pyx_t_21 < 0)) {
        PyErr_Fetch(&__pyx_t_22, &__pyx_t_23, &__pyx_t_24);
        if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_R0.rcbuffer->pybuffer, (PyObject*)__pyx_v_R0, &__Pyx_TypeInfo_double, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {
          Py_XDECREF(__pyx_t_22); Py_XDECREF(__pyx_t_23); Py_XDECREF(__pyx_t_24);
          __Pyx_RaiseBufferFallbackError();
        } else {
          PyErr_Restore(__pyx_t_22, __pyx_t_23, __pyx_t_24);
        }
      }
      __pyx_pybuffernd_R0.diminfo[0].strides = __pyx_pybuffernd_R0.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_R0.diminfo[0].shape = __pyx_pybuffernd_R0.rcbuffer->pybuffer.shape[0];
      if (unlikely(__pyx_t_21 < 0)) __PYX_ERR(0, 360, __pyx_L1_error)
    }
    __pyx_t_20 = 0;
    __pyx_v_R0 = ((PyArrayObject *)__pyx_t_12);
    __pyx_t_12 = 0;
    __pyx_v_dR0r = __pyx_t_8;
    __pyx_t_25 = ((PyArrayObject *)__pyx_t_9);
    {
      __Pyx_BufFmt_StackElem __pyx_stack[1];
      __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_indR0.rcbuffer->pybuffer);
      __pyx_t_21 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_indR0.rcbuffer->pybuffer, (PyObject*)__pyx_t_25, &__Pyx_TypeInfo_long, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack);
      if (unlikely(__pyx_t_21 < 0)) {
        PyErr_Fetch(&__pyx_t_24, &__pyx_t_23, &__pyx_t_22);
        if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_indR0.rcbuffer->pybuffer, (PyObject*)__pyx_v_indR0, &__Pyx_TypeInfo_long, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {
          Py_XDECREF(__pyx_t_24); Py_XDECREF(__pyx_t_23); Py_XDECREF(__pyx_t_22);
          __Pyx_RaiseBufferFallbackError();
        } else {
          PyErr_Restore(__pyx_t_24, __pyx_t_23, __pyx_t_22);
        }
      }
      __pyx_pybuffernd_indR0.diminfo[0].strides = __pyx_pybuffernd_indR0.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_indR0.diminfo[0].shape = __pyx_pybuffernd_indR0.rcbuffer->pybuffer.shape[0];
      if (unlikely(__pyx_t_21 < 0)) __PYX_ERR(0, 360, __pyx_L1_error)
    }
    __pyx_t_25 = 0;
    __pyx_v_indR0 = ((PyArrayObject *)__pyx_t_9);
    __pyx_t_9 = 0;
    __pyx_v_NR0 = __pyx_t_19;
+361:         Z0, dZ0r, indZ0, NZ0 = _Ves_mesh_dlfromL_cython(np.array([np.min(VPoly[1,:]),np.max(VPoly[1,:])]), dL, DL=DZ, margin=margin)
    __pyx_t_5 = __Pyx_GetModuleGlobalName(__pyx_n_s_Ves_mesh_dlfromL_cython); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 361, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_9 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 361, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_9);
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_9, __pyx_n_s_array); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 361, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
    __pyx_t_12 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 361, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_12);
    __pyx_t_11 = __Pyx_PyObject_GetAttrStr(__pyx_t_12, __pyx_n_s_min); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 361, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_11);
    __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
    __pyx_t_10.data = __pyx_v_VPoly.data;
    __pyx_t_10.memview = __pyx_v_VPoly.memview;
    __PYX_INC_MEMVIEW(&__pyx_t_10, 0);
    {
    Py_ssize_t __pyx_tmp_idx = 1;
    Py_ssize_t __pyx_tmp_shape = __pyx_v_VPoly.shape[0];
    Py_ssize_t __pyx_tmp_stride = __pyx_v_VPoly.strides[0];
    if (0 && (__pyx_tmp_idx < 0))
        __pyx_tmp_idx += __pyx_tmp_shape;
    if (0 && (__pyx_tmp_idx < 0 || __pyx_tmp_idx >= __pyx_tmp_shape)) {
        PyErr_SetString(PyExc_IndexError, "Index out of bounds (axis 0)");
        __PYX_ERR(0, 361, __pyx_L1_error)
    }
        __pyx_t_10.data += __pyx_tmp_idx * __pyx_tmp_stride;
}

__pyx_t_10.shape[0] = __pyx_v_VPoly.shape[1];
__pyx_t_10.strides[0] = __pyx_v_VPoly.strides[1];
    __pyx_t_10.suboffsets[0] = -1;

__pyx_t_12 = __pyx_memoryview_fromslice(__pyx_t_10, 1, (PyObject *(*)(char *)) __pyx_memview_get_double, (int (*)(char *, PyObject *)) __pyx_memview_set_double, 0);; if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 361, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_12);
    __PYX_XDEC_MEMVIEW(&__pyx_t_10, 1);
    __pyx_t_10.memview = NULL;
    __pyx_t_10.data = NULL;
    __pyx_t_17 = NULL;
    if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_11))) {
      __pyx_t_17 = PyMethod_GET_SELF(__pyx_t_11);
      if (likely(__pyx_t_17)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_11);
        __Pyx_INCREF(__pyx_t_17);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_11, function);
      }
    }
    if (!__pyx_t_17) {
      __pyx_t_9 = __Pyx_PyObject_CallOneArg(__pyx_t_11, __pyx_t_12); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 361, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
      __Pyx_GOTREF(__pyx_t_9);
    } else {
      #if CYTHON_FAST_PYCALL
      if (PyFunction_Check(__pyx_t_11)) {
        PyObject *__pyx_temp[2] = {__pyx_t_17, __pyx_t_12};
        __pyx_t_9 = __Pyx_PyFunction_FastCall(__pyx_t_11, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 361, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_17); __pyx_t_17 = 0;
        __Pyx_GOTREF(__pyx_t_9);
        __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
      } else
      #endif
      #if CYTHON_FAST_PYCCALL
      if (__Pyx_PyFastCFunction_Check(__pyx_t_11)) {
        PyObject *__pyx_temp[2] = {__pyx_t_17, __pyx_t_12};
        __pyx_t_9 = __Pyx_PyCFunction_FastCall(__pyx_t_11, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 361, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_17); __pyx_t_17 = 0;
        __Pyx_GOTREF(__pyx_t_9);
        __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
      } else
      #endif
      {
        __pyx_t_16 = PyTuple_New(1+1); if (unlikely(!__pyx_t_16)) __PYX_ERR(0, 361, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_16);
        __Pyx_GIVEREF(__pyx_t_17); PyTuple_SET_ITEM(__pyx_t_16, 0, __pyx_t_17); __pyx_t_17 = NULL;
        __Pyx_GIVEREF(__pyx_t_12);
        PyTuple_SET_ITEM(__pyx_t_16, 0+1, __pyx_t_12);
        __pyx_t_12 = 0;
        __pyx_t_9 = __Pyx_PyObject_Call(__pyx_t_11, __pyx_t_16, NULL); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 361, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_9);
        __Pyx_DECREF(__pyx_t_16); __pyx_t_16 = 0;
      }
    }
    __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
    __pyx_t_16 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_16)) __PYX_ERR(0, 361, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_16);
    __pyx_t_12 = __Pyx_PyObject_GetAttrStr(__pyx_t_16, __pyx_n_s_max); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 361, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_12);
    __Pyx_DECREF(__pyx_t_16); __pyx_t_16 = 0;
    __pyx_t_10.data = __pyx_v_VPoly.data;
    __pyx_t_10.memview = __pyx_v_VPoly.memview;
    __PYX_INC_MEMVIEW(&__pyx_t_10, 0);
    {
    Py_ssize_t __pyx_tmp_idx = 1;
    Py_ssize_t __pyx_tmp_shape = __pyx_v_VPoly.shape[0];
    Py_ssize_t __pyx_tmp_stride = __pyx_v_VPoly.strides[0];
    if (0 && (__pyx_tmp_idx < 0))
        __pyx_tmp_idx += __pyx_tmp_shape;
    if (0 && (__pyx_tmp_idx < 0 || __pyx_tmp_idx >= __pyx_tmp_shape)) {
        PyErr_SetString(PyExc_IndexError, "Index out of bounds (axis 0)");
        __PYX_ERR(0, 361, __pyx_L1_error)
    }
        __pyx_t_10.data += __pyx_tmp_idx * __pyx_tmp_stride;
}

__pyx_t_10.shape[0] = __pyx_v_VPoly.shape[1];
__pyx_t_10.strides[0] = __pyx_v_VPoly.strides[1];
    __pyx_t_10.suboffsets[0] = -1;

__pyx_t_16 = __pyx_memoryview_fromslice(__pyx_t_10, 1, (PyObject *(*)(char *)) __pyx_memview_get_double, (int (*)(char *, PyObject *)) __pyx_memview_set_double, 0);; if (unlikely(!__pyx_t_16)) __PYX_ERR(0, 361, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_16);
    __PYX_XDEC_MEMVIEW(&__pyx_t_10, 1);
    __pyx_t_10.memview = NULL;
    __pyx_t_10.data = NULL;
    __pyx_t_17 = NULL;
    if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_12))) {
      __pyx_t_17 = PyMethod_GET_SELF(__pyx_t_12);
      if (likely(__pyx_t_17)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_12);
        __Pyx_INCREF(__pyx_t_17);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_12, function);
      }
    }
    if (!__pyx_t_17) {
      __pyx_t_11 = __Pyx_PyObject_CallOneArg(__pyx_t_12, __pyx_t_16); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 361, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_16); __pyx_t_16 = 0;
      __Pyx_GOTREF(__pyx_t_11);
    } else {
      #if CYTHON_FAST_PYCALL
      if (PyFunction_Check(__pyx_t_12)) {
        PyObject *__pyx_temp[2] = {__pyx_t_17, __pyx_t_16};
        __pyx_t_11 = __Pyx_PyFunction_FastCall(__pyx_t_12, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 361, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_17); __pyx_t_17 = 0;
        __Pyx_GOTREF(__pyx_t_11);
        __Pyx_DECREF(__pyx_t_16); __pyx_t_16 = 0;
      } else
      #endif
      #if CYTHON_FAST_PYCCALL
      if (__Pyx_PyFastCFunction_Check(__pyx_t_12)) {
        PyObject *__pyx_temp[2] = {__pyx_t_17, __pyx_t_16};
        __pyx_t_11 = __Pyx_PyCFunction_FastCall(__pyx_t_12, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 361, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_17); __pyx_t_17 = 0;
        __Pyx_GOTREF(__pyx_t_11);
        __Pyx_DECREF(__pyx_t_16); __pyx_t_16 = 0;
      } else
      #endif
      {
        __pyx_t_15 = PyTuple_New(1+1); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 361, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_15);
        __Pyx_GIVEREF(__pyx_t_17); PyTuple_SET_ITEM(__pyx_t_15, 0, __pyx_t_17); __pyx_t_17 = NULL;
        __Pyx_GIVEREF(__pyx_t_16);
        PyTuple_SET_ITEM(__pyx_t_15, 0+1, __pyx_t_16);
        __pyx_t_16 = 0;
        __pyx_t_11 = __Pyx_PyObject_Call(__pyx_t_12, __pyx_t_15, NULL); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 361, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_11);
        __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
      }
    }
    __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
    __pyx_t_12 = PyList_New(2); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 361, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_12);
    __Pyx_GIVEREF(__pyx_t_9);
    PyList_SET_ITEM(__pyx_t_12, 0, __pyx_t_9);
    __Pyx_GIVEREF(__pyx_t_11);
    PyList_SET_ITEM(__pyx_t_12, 1, __pyx_t_11);
    __pyx_t_9 = 0;
    __pyx_t_11 = 0;
    __pyx_t_11 = NULL;
    if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_1))) {
      __pyx_t_11 = PyMethod_GET_SELF(__pyx_t_1);
      if (likely(__pyx_t_11)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1);
        __Pyx_INCREF(__pyx_t_11);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_1, function);
      }
    }
    if (!__pyx_t_11) {
      __pyx_t_6 = __Pyx_PyObject_CallOneArg(__pyx_t_1, __pyx_t_12); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 361, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
      __Pyx_GOTREF(__pyx_t_6);
    } else {
      #if CYTHON_FAST_PYCALL
      if (PyFunction_Check(__pyx_t_1)) {
        PyObject *__pyx_temp[2] = {__pyx_t_11, __pyx_t_12};
        __pyx_t_6 = __Pyx_PyFunction_FastCall(__pyx_t_1, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 361, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0;
        __Pyx_GOTREF(__pyx_t_6);
        __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
      } else
      #endif
      #if CYTHON_FAST_PYCCALL
      if (__Pyx_PyFastCFunction_Check(__pyx_t_1)) {
        PyObject *__pyx_temp[2] = {__pyx_t_11, __pyx_t_12};
        __pyx_t_6 = __Pyx_PyCFunction_FastCall(__pyx_t_1, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 361, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0;
        __Pyx_GOTREF(__pyx_t_6);
        __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
      } else
      #endif
      {
        __pyx_t_9 = PyTuple_New(1+1); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 361, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_9);
        __Pyx_GIVEREF(__pyx_t_11); PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_t_11); __pyx_t_11 = NULL;
        __Pyx_GIVEREF(__pyx_t_12);
        PyTuple_SET_ITEM(__pyx_t_9, 0+1, __pyx_t_12);
        __pyx_t_12 = 0;
        __pyx_t_6 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_9, NULL); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 361, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_6);
        __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
      }
    }
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_1 = PyFloat_FromDouble(__pyx_v_dL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 361, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_9 = PyTuple_New(2); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 361, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_9);
    __Pyx_GIVEREF(__pyx_t_6);
    PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_t_6);
    __Pyx_GIVEREF(__pyx_t_1);
    PyTuple_SET_ITEM(__pyx_t_9, 1, __pyx_t_1);
    __pyx_t_6 = 0;
    __pyx_t_1 = 0;
    __pyx_t_1 = PyDict_New(); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 361, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_DL, __pyx_v_DZ) < 0) __PYX_ERR(0, 361, __pyx_L1_error)
    __pyx_t_6 = PyFloat_FromDouble(__pyx_v_margin); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 361, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_margin, __pyx_t_6) < 0) __PYX_ERR(0, 361, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __pyx_t_6 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_t_9, __pyx_t_1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 361, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    if ((likely(PyTuple_CheckExact(__pyx_t_6))) || (PyList_CheckExact(__pyx_t_6))) {
      PyObject* sequence = __pyx_t_6;
      #if !CYTHON_COMPILING_IN_PYPY
      Py_ssize_t size = Py_SIZE(sequence);
      #else
      Py_ssize_t size = PySequence_Size(sequence);
      #endif
      if (unlikely(size != 4)) {
        if (size > 4) __Pyx_RaiseTooManyValuesError(4);
        else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
        __PYX_ERR(0, 361, __pyx_L1_error)
      }
      #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
      if (likely(PyTuple_CheckExact(sequence))) {
        __pyx_t_1 = PyTuple_GET_ITEM(sequence, 0); 
        __pyx_t_9 = PyTuple_GET_ITEM(sequence, 1); 
        __pyx_t_5 = PyTuple_GET_ITEM(sequence, 2); 
        __pyx_t_12 = PyTuple_GET_ITEM(sequence, 3); 
      } else {
        __pyx_t_1 = PyList_GET_ITEM(sequence, 0); 
        __pyx_t_9 = PyList_GET_ITEM(sequence, 1); 
        __pyx_t_5 = PyList_GET_ITEM(sequence, 2); 
        __pyx_t_12 = PyList_GET_ITEM(sequence, 3); 
      }
      __Pyx_INCREF(__pyx_t_1);
      __Pyx_INCREF(__pyx_t_9);
      __Pyx_INCREF(__pyx_t_5);
      __Pyx_INCREF(__pyx_t_12);
      #else
      {
        Py_ssize_t i;
        PyObject** temps[4] = {&__pyx_t_1,&__pyx_t_9,&__pyx_t_5,&__pyx_t_12};
        for (i=0; i < 4; i++) {
          PyObject* item = PySequence_ITEM(sequence, i); if (unlikely(!item)) __PYX_ERR(0, 361, __pyx_L1_error)
          __Pyx_GOTREF(item);
          *(temps[i]) = item;
        }
      }
      #endif
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    } else {
      Py_ssize_t index = -1;
      PyObject** temps[4] = {&__pyx_t_1,&__pyx_t_9,&__pyx_t_5,&__pyx_t_12};
      __pyx_t_11 = PyObject_GetIter(__pyx_t_6); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 361, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_11);
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      __pyx_t_18 = Py_TYPE(__pyx_t_11)->tp_iternext;
      for (index=0; index < 4; index++) {
        PyObject* item = __pyx_t_18(__pyx_t_11); if (unlikely(!item)) goto __pyx_L12_unpacking_failed;
        __Pyx_GOTREF(item);
        *(temps[index]) = item;
      }
      if (__Pyx_IternextUnpackEndCheck(__pyx_t_18(__pyx_t_11), 4) < 0) __PYX_ERR(0, 361, __pyx_L1_error)
      __pyx_t_18 = NULL;
      __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
      goto __pyx_L13_unpacking_done;
      __pyx_L12_unpacking_failed:;
      __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
      __pyx_t_18 = NULL;
      if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
      __PYX_ERR(0, 361, __pyx_L1_error)
      __pyx_L13_unpacking_done:;
    }
    if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 361, __pyx_L1_error)
    __pyx_t_8 = __pyx_PyFloat_AsDouble(__pyx_t_9); if (unlikely((__pyx_t_8 == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 361, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
    if (!(likely(((__pyx_t_5) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_5, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 361, __pyx_L1_error)
    __pyx_t_19 = __Pyx_PyInt_As_int(__pyx_t_12); if (unlikely((__pyx_t_19 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 361, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
    __pyx_t_20 = ((PyArrayObject *)__pyx_t_1);
    {
      __Pyx_BufFmt_StackElem __pyx_stack[1];
      __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_Z0.rcbuffer->pybuffer);
      __pyx_t_21 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_Z0.rcbuffer->pybuffer, (PyObject*)__pyx_t_20, &__Pyx_TypeInfo_double, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack);
      if (unlikely(__pyx_t_21 < 0)) {
        PyErr_Fetch(&__pyx_t_22, &__pyx_t_23, &__pyx_t_24);
        if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_Z0.rcbuffer->pybuffer, (PyObject*)__pyx_v_Z0, &__Pyx_TypeInfo_double, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {
          Py_XDECREF(__pyx_t_22); Py_XDECREF(__pyx_t_23); Py_XDECREF(__pyx_t_24);
          __Pyx_RaiseBufferFallbackError();
        } else {
          PyErr_Restore(__pyx_t_22, __pyx_t_23, __pyx_t_24);
        }
      }
      __pyx_pybuffernd_Z0.diminfo[0].strides = __pyx_pybuffernd_Z0.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_Z0.diminfo[0].shape = __pyx_pybuffernd_Z0.rcbuffer->pybuffer.shape[0];
      if (unlikely(__pyx_t_21 < 0)) __PYX_ERR(0, 361, __pyx_L1_error)
    }
    __pyx_t_20 = 0;
    __pyx_v_Z0 = ((PyArrayObject *)__pyx_t_1);
    __pyx_t_1 = 0;
    __pyx_v_dZ0r = __pyx_t_8;
    __pyx_t_25 = ((PyArrayObject *)__pyx_t_5);
    {
      __Pyx_BufFmt_StackElem __pyx_stack[1];
      __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_indZ0.rcbuffer->pybuffer);
      __pyx_t_21 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_indZ0.rcbuffer->pybuffer, (PyObject*)__pyx_t_25, &__Pyx_TypeInfo_long, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack);
      if (unlikely(__pyx_t_21 < 0)) {
        PyErr_Fetch(&__pyx_t_24, &__pyx_t_23, &__pyx_t_22);
        if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_indZ0.rcbuffer->pybuffer, (PyObject*)__pyx_v_indZ0, &__Pyx_TypeInfo_long, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {
          Py_XDECREF(__pyx_t_24); Py_XDECREF(__pyx_t_23); Py_XDECREF(__pyx_t_22);
          __Pyx_RaiseBufferFallbackError();
        } else {
          PyErr_Restore(__pyx_t_24, __pyx_t_23, __pyx_t_22);
        }
      }
      __pyx_pybuffernd_indZ0.diminfo[0].strides = __pyx_pybuffernd_indZ0.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_indZ0.diminfo[0].shape = __pyx_pybuffernd_indZ0.rcbuffer->pybuffer.shape[0];
      if (unlikely(__pyx_t_21 < 0)) __PYX_ERR(0, 361, __pyx_L1_error)
    }
    __pyx_t_25 = 0;
    __pyx_v_indZ0 = ((PyArrayObject *)__pyx_t_5);
    __pyx_t_5 = 0;
    __pyx_v_NZ0 = __pyx_t_19;
+362:         R0n, Z0n = len(R0), len(Z0)
    __pyx_t_26 = PyObject_Length(((PyObject *)__pyx_v_R0)); if (unlikely(__pyx_t_26 == -1)) __PYX_ERR(0, 362, __pyx_L1_error)
    __pyx_t_27 = PyObject_Length(((PyObject *)__pyx_v_Z0)); if (unlikely(__pyx_t_27 == -1)) __PYX_ERR(0, 362, __pyx_L1_error)
    __pyx_v_R0n = __pyx_t_26;
    __pyx_v_Z0n = __pyx_t_27;
+363:         ptsrz = np.array([np.tile(R0,Z0n),np.repeat(Z0,R0n)])
    __pyx_t_12 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 363, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_12);
    __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_12, __pyx_n_s_array); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 363, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
    __pyx_t_9 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 363, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_9);
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_9, __pyx_n_s_tile); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 363, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
    __pyx_t_9 = __Pyx_PyInt_From_int(__pyx_v_Z0n); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 363, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_9);
    __pyx_t_11 = NULL;
    __pyx_t_19 = 0;
    if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_1))) {
      __pyx_t_11 = PyMethod_GET_SELF(__pyx_t_1);
      if (likely(__pyx_t_11)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1);
        __Pyx_INCREF(__pyx_t_11);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_1, function);
        __pyx_t_19 = 1;
      }
    }
    #if CYTHON_FAST_PYCALL
    if (PyFunction_Check(__pyx_t_1)) {
      PyObject *__pyx_temp[3] = {__pyx_t_11, ((PyObject *)__pyx_v_R0), __pyx_t_9};
      __pyx_t_12 = __Pyx_PyFunction_FastCall(__pyx_t_1, __pyx_temp+1-__pyx_t_19, 2+__pyx_t_19); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 363, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0;
      __Pyx_GOTREF(__pyx_t_12);
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
    } else
    #endif
    #if CYTHON_FAST_PYCCALL
    if (__Pyx_PyFastCFunction_Check(__pyx_t_1)) {
      PyObject *__pyx_temp[3] = {__pyx_t_11, ((PyObject *)__pyx_v_R0), __pyx_t_9};
      __pyx_t_12 = __Pyx_PyCFunction_FastCall(__pyx_t_1, __pyx_temp+1-__pyx_t_19, 2+__pyx_t_19); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 363, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0;
      __Pyx_GOTREF(__pyx_t_12);
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
    } else
    #endif
    {
      __pyx_t_15 = PyTuple_New(2+__pyx_t_19); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 363, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_15);
      if (__pyx_t_11) {
        __Pyx_GIVEREF(__pyx_t_11); PyTuple_SET_ITEM(__pyx_t_15, 0, __pyx_t_11); __pyx_t_11 = NULL;
      }
      __Pyx_INCREF(((PyObject *)__pyx_v_R0));
      __Pyx_GIVEREF(((PyObject *)__pyx_v_R0));
      PyTuple_SET_ITEM(__pyx_t_15, 0+__pyx_t_19, ((PyObject *)__pyx_v_R0));
      __Pyx_GIVEREF(__pyx_t_9);
      PyTuple_SET_ITEM(__pyx_t_15, 1+__pyx_t_19, __pyx_t_9);
      __pyx_t_9 = 0;
      __pyx_t_12 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_15, NULL); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 363, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_12);
      __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
    }
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_15 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 363, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_15);
    __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_t_15, __pyx_n_s_repeat); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 363, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_9);
    __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
    __pyx_t_15 = __Pyx_PyInt_From_int(__pyx_v_R0n); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 363, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_15);
    __pyx_t_11 = NULL;
    __pyx_t_19 = 0;
    if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_9))) {
      __pyx_t_11 = PyMethod_GET_SELF(__pyx_t_9);
      if (likely(__pyx_t_11)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_9);
        __Pyx_INCREF(__pyx_t_11);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_9, function);
        __pyx_t_19 = 1;
      }
    }
    #if CYTHON_FAST_PYCALL
    if (PyFunction_Check(__pyx_t_9)) {
      PyObject *__pyx_temp[3] = {__pyx_t_11, ((PyObject *)__pyx_v_Z0), __pyx_t_15};
      __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_9, __pyx_temp+1-__pyx_t_19, 2+__pyx_t_19); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 363, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0;
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
    } else
    #endif
    #if CYTHON_FAST_PYCCALL
    if (__Pyx_PyFastCFunction_Check(__pyx_t_9)) {
      PyObject *__pyx_temp[3] = {__pyx_t_11, ((PyObject *)__pyx_v_Z0), __pyx_t_15};
      __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_9, __pyx_temp+1-__pyx_t_19, 2+__pyx_t_19); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 363, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0;
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
    } else
    #endif
    {
      __pyx_t_16 = PyTuple_New(2+__pyx_t_19); if (unlikely(!__pyx_t_16)) __PYX_ERR(0, 363, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_16);
      if (__pyx_t_11) {
        __Pyx_GIVEREF(__pyx_t_11); PyTuple_SET_ITEM(__pyx_t_16, 0, __pyx_t_11); __pyx_t_11 = NULL;
      }
      __Pyx_INCREF(((PyObject *)__pyx_v_Z0));
      __Pyx_GIVEREF(((PyObject *)__pyx_v_Z0));
      PyTuple_SET_ITEM(__pyx_t_16, 0+__pyx_t_19, ((PyObject *)__pyx_v_Z0));
      __Pyx_GIVEREF(__pyx_t_15);
      PyTuple_SET_ITEM(__pyx_t_16, 1+__pyx_t_19, __pyx_t_15);
      __pyx_t_15 = 0;
      __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_9, __pyx_t_16, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 363, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_16); __pyx_t_16 = 0;
    }
    __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
    __pyx_t_9 = PyList_New(2); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 363, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_9);
    __Pyx_GIVEREF(__pyx_t_12);
    PyList_SET_ITEM(__pyx_t_9, 0, __pyx_t_12);
    __Pyx_GIVEREF(__pyx_t_1);
    PyList_SET_ITEM(__pyx_t_9, 1, __pyx_t_1);
    __pyx_t_12 = 0;
    __pyx_t_1 = 0;
    __pyx_t_1 = NULL;
    if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_5))) {
      __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_5);
      if (likely(__pyx_t_1)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5);
        __Pyx_INCREF(__pyx_t_1);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_5, function);
      }
    }
    if (!__pyx_t_1) {
      __pyx_t_6 = __Pyx_PyObject_CallOneArg(__pyx_t_5, __pyx_t_9); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 363, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
      __Pyx_GOTREF(__pyx_t_6);
    } else {
      #if CYTHON_FAST_PYCALL
      if (PyFunction_Check(__pyx_t_5)) {
        PyObject *__pyx_temp[2] = {__pyx_t_1, __pyx_t_9};
        __pyx_t_6 = __Pyx_PyFunction_FastCall(__pyx_t_5, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 363, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
        __Pyx_GOTREF(__pyx_t_6);
        __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
      } else
      #endif
      #if CYTHON_FAST_PYCCALL
      if (__Pyx_PyFastCFunction_Check(__pyx_t_5)) {
        PyObject *__pyx_temp[2] = {__pyx_t_1, __pyx_t_9};
        __pyx_t_6 = __Pyx_PyCFunction_FastCall(__pyx_t_5, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 363, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
        __Pyx_GOTREF(__pyx_t_6);
        __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
      } else
      #endif
      {
        __pyx_t_12 = PyTuple_New(1+1); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 363, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_12);
        __Pyx_GIVEREF(__pyx_t_1); PyTuple_SET_ITEM(__pyx_t_12, 0, __pyx_t_1); __pyx_t_1 = NULL;
        __Pyx_GIVEREF(__pyx_t_9);
        PyTuple_SET_ITEM(__pyx_t_12, 0+1, __pyx_t_9);
        __pyx_t_9 = 0;
        __pyx_t_6 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_t_12, NULL); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 363, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_6);
        __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
      }
    }
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    if (!(likely(((__pyx_t_6) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_6, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 363, __pyx_L1_error)
    __pyx_t_28 = ((PyArrayObject *)__pyx_t_6);
    {
      __Pyx_BufFmt_StackElem __pyx_stack[1];
      __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_ptsrz.rcbuffer->pybuffer);
      __pyx_t_19 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_ptsrz.rcbuffer->pybuffer, (PyObject*)__pyx_t_28, &__Pyx_TypeInfo_double, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack);
      if (unlikely(__pyx_t_19 < 0)) {
        PyErr_Fetch(&__pyx_t_22, &__pyx_t_23, &__pyx_t_24);
        if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_ptsrz.rcbuffer->pybuffer, (PyObject*)__pyx_v_ptsrz, &__Pyx_TypeInfo_double, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) {
          Py_XDECREF(__pyx_t_22); Py_XDECREF(__pyx_t_23); Py_XDECREF(__pyx_t_24);
          __Pyx_RaiseBufferFallbackError();
        } else {
          PyErr_Restore(__pyx_t_22, __pyx_t_23, __pyx_t_24);
        }
      }
      __pyx_pybuffernd_ptsrz.diminfo[0].strides = __pyx_pybuffernd_ptsrz.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_ptsrz.diminfo[0].shape = __pyx_pybuffernd_ptsrz.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_ptsrz.diminfo[1].strides = __pyx_pybuffernd_ptsrz.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_ptsrz.diminfo[1].shape = __pyx_pybuffernd_ptsrz.rcbuffer->pybuffer.shape[1];
      if (unlikely(__pyx_t_19 < 0)) __PYX_ERR(0, 363, __pyx_L1_error)
    }
    __pyx_t_28 = 0;
    __pyx_v_ptsrz = ((PyArrayObject *)__pyx_t_6);
    __pyx_t_6 = 0;
+364:         iind = NR0*np.repeat(indZ0,R0n) + np.tile(indR0,Z0n)
    __pyx_t_6 = __Pyx_PyInt_From_int(__pyx_v_NR0); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 364, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_t_12 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 364, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_12);
    __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_t_12, __pyx_n_s_repeat); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 364, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_9);
    __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
    __pyx_t_12 = __Pyx_PyInt_From_int(__pyx_v_R0n); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 364, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_12);
    __pyx_t_1 = NULL;
    __pyx_t_19 = 0;
    if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_9))) {
      __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_9);
      if (likely(__pyx_t_1)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_9);
        __Pyx_INCREF(__pyx_t_1);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_9, function);
        __pyx_t_19 = 1;
      }
    }
    #if CYTHON_FAST_PYCALL
    if (PyFunction_Check(__pyx_t_9)) {
      PyObject *__pyx_temp[3] = {__pyx_t_1, ((PyObject *)__pyx_v_indZ0), __pyx_t_12};
      __pyx_t_5 = __Pyx_PyFunction_FastCall(__pyx_t_9, __pyx_temp+1-__pyx_t_19, 2+__pyx_t_19); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 364, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
    } else
    #endif
    #if CYTHON_FAST_PYCCALL
    if (__Pyx_PyFastCFunction_Check(__pyx_t_9)) {
      PyObject *__pyx_temp[3] = {__pyx_t_1, ((PyObject *)__pyx_v_indZ0), __pyx_t_12};
      __pyx_t_5 = __Pyx_PyCFunction_FastCall(__pyx_t_9, __pyx_temp+1-__pyx_t_19, 2+__pyx_t_19); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 364, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
    } else
    #endif
    {
      __pyx_t_16 = PyTuple_New(2+__pyx_t_19); if (unlikely(!__pyx_t_16)) __PYX_ERR(0, 364, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_16);
      if (__pyx_t_1) {
        __Pyx_GIVEREF(__pyx_t_1); PyTuple_SET_ITEM(__pyx_t_16, 0, __pyx_t_1); __pyx_t_1 = NULL;
      }
      __Pyx_INCREF(((PyObject *)__pyx_v_indZ0));
      __Pyx_GIVEREF(((PyObject *)__pyx_v_indZ0));
      PyTuple_SET_ITEM(__pyx_t_16, 0+__pyx_t_19, ((PyObject *)__pyx_v_indZ0));
      __Pyx_GIVEREF(__pyx_t_12);
      PyTuple_SET_ITEM(__pyx_t_16, 1+__pyx_t_19, __pyx_t_12);
      __pyx_t_12 = 0;
      __pyx_t_5 = __Pyx_PyObject_Call(__pyx_t_9, __pyx_t_16, NULL); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 364, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_DECREF(__pyx_t_16); __pyx_t_16 = 0;
    }
    __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
    __pyx_t_9 = PyNumber_Multiply(__pyx_t_6, __pyx_t_5); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 364, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_9);
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __pyx_t_6 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 364, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_t_16 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_n_s_tile); if (unlikely(!__pyx_t_16)) __PYX_ERR(0, 364, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_16);
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __pyx_t_6 = __Pyx_PyInt_From_int(__pyx_v_Z0n); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 364, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_t_12 = NULL;
    __pyx_t_19 = 0;
    if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_16))) {
      __pyx_t_12 = PyMethod_GET_SELF(__pyx_t_16);
      if (likely(__pyx_t_12)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_16);
        __Pyx_INCREF(__pyx_t_12);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_16, function);
        __pyx_t_19 = 1;
      }
    }
    #if CYTHON_FAST_PYCALL
    if (PyFunction_Check(__pyx_t_16)) {
      PyObject *__pyx_temp[3] = {__pyx_t_12, ((PyObject *)__pyx_v_indR0), __pyx_t_6};
      __pyx_t_5 = __Pyx_PyFunction_FastCall(__pyx_t_16, __pyx_temp+1-__pyx_t_19, 2+__pyx_t_19); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 364, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0;
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    } else
    #endif
    #if CYTHON_FAST_PYCCALL
    if (__Pyx_PyFastCFunction_Check(__pyx_t_16)) {
      PyObject *__pyx_temp[3] = {__pyx_t_12, ((PyObject *)__pyx_v_indR0), __pyx_t_6};
      __pyx_t_5 = __Pyx_PyCFunction_FastCall(__pyx_t_16, __pyx_temp+1-__pyx_t_19, 2+__pyx_t_19); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 364, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0;
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    } else
    #endif
    {
      __pyx_t_1 = PyTuple_New(2+__pyx_t_19); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 364, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      if (__pyx_t_12) {
        __Pyx_GIVEREF(__pyx_t_12); PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_12); __pyx_t_12 = NULL;
      }
      __Pyx_INCREF(((PyObject *)__pyx_v_indR0));
      __Pyx_GIVEREF(((PyObject *)__pyx_v_indR0));
      PyTuple_SET_ITEM(__pyx_t_1, 0+__pyx_t_19, ((PyObject *)__pyx_v_indR0));
      __Pyx_GIVEREF(__pyx_t_6);
      PyTuple_SET_ITEM(__pyx_t_1, 1+__pyx_t_19, __pyx_t_6);
      __pyx_t_6 = 0;
      __pyx_t_5 = __Pyx_PyObject_Call(__pyx_t_16, __pyx_t_1, NULL); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 364, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    }
    __Pyx_DECREF(__pyx_t_16); __pyx_t_16 = 0;
    __pyx_t_16 = PyNumber_Add(__pyx_t_9, __pyx_t_5); if (unlikely(!__pyx_t_16)) __PYX_ERR(0, 364, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_16);
    __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    if (!(likely(((__pyx_t_16) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_16, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 364, __pyx_L1_error)
    __pyx_t_25 = ((PyArrayObject *)__pyx_t_16);
    {
      __Pyx_BufFmt_StackElem __pyx_stack[1];
      __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_iind.rcbuffer->pybuffer);
      __pyx_t_19 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_iind.rcbuffer->pybuffer, (PyObject*)__pyx_t_25, &__Pyx_TypeInfo_long, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack);
      if (unlikely(__pyx_t_19 < 0)) {
        PyErr_Fetch(&__pyx_t_24, &__pyx_t_23, &__pyx_t_22);
        if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_iind.rcbuffer->pybuffer, (PyObject*)__pyx_v_iind, &__Pyx_TypeInfo_long, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {
          Py_XDECREF(__pyx_t_24); Py_XDECREF(__pyx_t_23); Py_XDECREF(__pyx_t_22);
          __Pyx_RaiseBufferFallbackError();
        } else {
          PyErr_Restore(__pyx_t_24, __pyx_t_23, __pyx_t_22);
        }
      }
      __pyx_pybuffernd_iind.diminfo[0].strides = __pyx_pybuffernd_iind.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_iind.diminfo[0].shape = __pyx_pybuffernd_iind.rcbuffer->pybuffer.shape[0];
      if (unlikely(__pyx_t_19 < 0)) __PYX_ERR(0, 364, __pyx_L1_error)
    }
    __pyx_t_25 = 0;
    __pyx_v_iind = ((PyArrayObject *)__pyx_t_16);
    __pyx_t_16 = 0;
+365:         indin = Path(VPoly.T).contains_points(ptsrz.T, transform=None, radius=0.0)
    __pyx_t_5 = __Pyx_GetModuleGlobalName(__pyx_n_s_Path); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 365, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_29 = __pyx_v_VPoly;
    __PYX_INC_MEMVIEW(&__pyx_t_29, 1);
    if (unlikely(__pyx_memslice_transpose(&__pyx_t_29) == 0)) __PYX_ERR(0, 365, __pyx_L1_error)
    __pyx_t_9 = __pyx_memoryview_fromslice(__pyx_t_29, 2, (PyObject *(*)(char *)) __pyx_memview_get_double, (int (*)(char *, PyObject *)) __pyx_memview_set_double, 0);; if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 365, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_9);
    __PYX_XDEC_MEMVIEW(&__pyx_t_29, 1);
    __pyx_t_29.memview = NULL;
    __pyx_t_29.data = NULL;
    __pyx_t_1 = NULL;
    if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_5))) {
      __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_5);
      if (likely(__pyx_t_1)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5);
        __Pyx_INCREF(__pyx_t_1);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_5, function);
      }
    }
    if (!__pyx_t_1) {
      __pyx_t_16 = __Pyx_PyObject_CallOneArg(__pyx_t_5, __pyx_t_9); if (unlikely(!__pyx_t_16)) __PYX_ERR(0, 365, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
      __Pyx_GOTREF(__pyx_t_16);
    } else {
      #if CYTHON_FAST_PYCALL
      if (PyFunction_Check(__pyx_t_5)) {
        PyObject *__pyx_temp[2] = {__pyx_t_1, __pyx_t_9};
        __pyx_t_16 = __Pyx_PyFunction_FastCall(__pyx_t_5, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_16)) __PYX_ERR(0, 365, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
        __Pyx_GOTREF(__pyx_t_16);
        __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
      } else
      #endif
      #if CYTHON_FAST_PYCCALL
      if (__Pyx_PyFastCFunction_Check(__pyx_t_5)) {
        PyObject *__pyx_temp[2] = {__pyx_t_1, __pyx_t_9};
        __pyx_t_16 = __Pyx_PyCFunction_FastCall(__pyx_t_5, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_16)) __PYX_ERR(0, 365, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
        __Pyx_GOTREF(__pyx_t_16);
        __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
      } else
      #endif
      {
        __pyx_t_6 = PyTuple_New(1+1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 365, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_6);
        __Pyx_GIVEREF(__pyx_t_1); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_1); __pyx_t_1 = NULL;
        __Pyx_GIVEREF(__pyx_t_9);
        PyTuple_SET_ITEM(__pyx_t_6, 0+1, __pyx_t_9);
        __pyx_t_9 = 0;
        __pyx_t_16 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_t_6, NULL); if (unlikely(!__pyx_t_16)) __PYX_ERR(0, 365, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_16);
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      }
    }
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_16, __pyx_n_s_contains_points); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 365, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_16); __pyx_t_16 = 0;
    __pyx_t_16 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_ptsrz), __pyx_n_s_T); if (unlikely(!__pyx_t_16)) __PYX_ERR(0, 365, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_16);
    __pyx_t_6 = PyTuple_New(1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 365, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_GIVEREF(__pyx_t_16);
    PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_16);
    __pyx_t_16 = 0;
    __pyx_t_16 = PyDict_New(); if (unlikely(!__pyx_t_16)) __PYX_ERR(0, 365, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_16);
    if (PyDict_SetItem(__pyx_t_16, __pyx_n_s_transform, Py_None) < 0) __PYX_ERR(0, 365, __pyx_L1_error)
    if (PyDict_SetItem(__pyx_t_16, __pyx_n_s_radius, __pyx_float_0_0) < 0) __PYX_ERR(0, 365, __pyx_L1_error)
    __pyx_t_9 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_t_6, __pyx_t_16); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 365, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_9);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __Pyx_DECREF(__pyx_t_16); __pyx_t_16 = 0;
    __pyx_v_indin = __pyx_t_9;
    __pyx_t_9 = 0;
+366:         if np.any(indin):
    __pyx_t_16 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_16)) __PYX_ERR(0, 366, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_16);
    __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_16, __pyx_n_s_any); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 366, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_DECREF(__pyx_t_16); __pyx_t_16 = 0;
    __pyx_t_16 = NULL;
    if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_6))) {
      __pyx_t_16 = PyMethod_GET_SELF(__pyx_t_6);
      if (likely(__pyx_t_16)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6);
        __Pyx_INCREF(__pyx_t_16);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_6, function);
      }
    }
    if (!__pyx_t_16) {
      __pyx_t_9 = __Pyx_PyObject_CallOneArg(__pyx_t_6, __pyx_v_indin); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 366, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_9);
    } else {
      #if CYTHON_FAST_PYCALL
      if (PyFunction_Check(__pyx_t_6)) {
        PyObject *__pyx_temp[2] = {__pyx_t_16, __pyx_v_indin};
        __pyx_t_9 = __Pyx_PyFunction_FastCall(__pyx_t_6, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 366, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_16); __pyx_t_16 = 0;
        __Pyx_GOTREF(__pyx_t_9);
      } else
      #endif
      #if CYTHON_FAST_PYCCALL
      if (__Pyx_PyFastCFunction_Check(__pyx_t_6)) {
        PyObject *__pyx_temp[2] = {__pyx_t_16, __pyx_v_indin};
        __pyx_t_9 = __Pyx_PyCFunction_FastCall(__pyx_t_6, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 366, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_16); __pyx_t_16 = 0;
        __Pyx_GOTREF(__pyx_t_9);
      } else
      #endif
      {
        __pyx_t_5 = PyTuple_New(1+1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 366, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_5);
        __Pyx_GIVEREF(__pyx_t_16); PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_16); __pyx_t_16 = NULL;
        __Pyx_INCREF(__pyx_v_indin);
        __Pyx_GIVEREF(__pyx_v_indin);
        PyTuple_SET_ITEM(__pyx_t_5, 0+1, __pyx_v_indin);
        __pyx_t_9 = __Pyx_PyObject_Call(__pyx_t_6, __pyx_t_5, NULL); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 366, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_9);
        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      }
    }
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_9); if (unlikely(__pyx_t_3 < 0)) __PYX_ERR(0, 366, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
    if (__pyx_t_3) {
/* … */
    }
+367:             ptsrz = ptsrz[:,indin] if indin.sum()>1 else ptsrz[:,indin].reshape((2,1))
      __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_v_indin, __pyx_n_s_sum); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 367, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
      __pyx_t_16 = NULL;
      if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_5))) {
        __pyx_t_16 = PyMethod_GET_SELF(__pyx_t_5);
        if (likely(__pyx_t_16)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5);
          __Pyx_INCREF(__pyx_t_16);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_5, function);
        }
      }
      if (__pyx_t_16) {
        __pyx_t_6 = __Pyx_PyObject_CallOneArg(__pyx_t_5, __pyx_t_16); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 367, __pyx_L1_error)
        __Pyx_DECREF(__pyx_t_16); __pyx_t_16 = 0;
      } else {
        __pyx_t_6 = __Pyx_PyObject_CallNoArg(__pyx_t_5); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 367, __pyx_L1_error)
      }
      __Pyx_GOTREF(__pyx_t_6);
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __pyx_t_5 = PyObject_RichCompare(__pyx_t_6, __pyx_int_1, Py_GT); __Pyx_XGOTREF(__pyx_t_5); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 367, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_5); if (unlikely(__pyx_t_3 < 0)) __PYX_ERR(0, 367, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      if (__pyx_t_3) {
        __pyx_t_5 = PyTuple_New(2); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 367, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_5);
        __Pyx_INCREF(__pyx_slice__16);
        __Pyx_GIVEREF(__pyx_slice__16);
        PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_slice__16);
        __Pyx_INCREF(__pyx_v_indin);
        __Pyx_GIVEREF(__pyx_v_indin);
        PyTuple_SET_ITEM(__pyx_t_5, 1, __pyx_v_indin);
        __pyx_t_6 = PyObject_GetItem(((PyObject *)__pyx_v_ptsrz), __pyx_t_5); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 367, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_6);
        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
        if (!(likely(((__pyx_t_6) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_6, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 367, __pyx_L1_error)
        __pyx_t_9 = __pyx_t_6;
        __pyx_t_6 = 0;
      } else {
/* … */
  __pyx_slice__16 = PySlice_New(Py_None, Py_None, Py_None); if (unlikely(!__pyx_slice__16)) __PYX_ERR(0, 367, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_slice__16);
  __Pyx_GIVEREF(__pyx_slice__16);
        __pyx_t_6 = PyTuple_New(2); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 367, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_6);
        __Pyx_INCREF(__pyx_slice__17);
        __Pyx_GIVEREF(__pyx_slice__17);
        PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_slice__17);
        __Pyx_INCREF(__pyx_v_indin);
        __Pyx_GIVEREF(__pyx_v_indin);
        PyTuple_SET_ITEM(__pyx_t_6, 1, __pyx_v_indin);
        __pyx_t_5 = PyObject_GetItem(((PyObject *)__pyx_v_ptsrz), __pyx_t_6); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 367, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_5);
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
        __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_n_s_reshape); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 367, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_6);
        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __pyx_slice__17 = PySlice_New(Py_None, Py_None, Py_None); if (unlikely(!__pyx_slice__17)) __PYX_ERR(0, 367, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_slice__17);
  __Pyx_GIVEREF(__pyx_slice__17);
  __pyx_tuple__18 = PyTuple_Pack(2, __pyx_int_2, __pyx_int_1); if (unlikely(!__pyx_tuple__18)) __PYX_ERR(0, 367, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__18);
  __Pyx_GIVEREF(__pyx_tuple__18);
        __pyx_t_5 = __Pyx_PyObject_Call(__pyx_t_6, __pyx_tuple__19, NULL); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 367, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_5);
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
        if (!(likely(((__pyx_t_5) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_5, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 367, __pyx_L1_error)
        __pyx_t_9 = __pyx_t_5;
        __pyx_t_5 = 0;
      }
      {
        __Pyx_BufFmt_StackElem __pyx_stack[1];
        __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_ptsrz.rcbuffer->pybuffer);
        __pyx_t_19 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_ptsrz.rcbuffer->pybuffer, (PyObject*)((PyArrayObject *)__pyx_t_9), &__Pyx_TypeInfo_double, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack);
        if (unlikely(__pyx_t_19 < 0)) {
          PyErr_Fetch(&__pyx_t_22, &__pyx_t_23, &__pyx_t_24);
          if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_ptsrz.rcbuffer->pybuffer, (PyObject*)__pyx_v_ptsrz, &__Pyx_TypeInfo_double, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) {
            Py_XDECREF(__pyx_t_22); Py_XDECREF(__pyx_t_23); Py_XDECREF(__pyx_t_24);
            __Pyx_RaiseBufferFallbackError();
          } else {
            PyErr_Restore(__pyx_t_22, __pyx_t_23, __pyx_t_24);
          }
        }
        __pyx_pybuffernd_ptsrz.diminfo[0].strides = __pyx_pybuffernd_ptsrz.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_ptsrz.diminfo[0].shape = __pyx_pybuffernd_ptsrz.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_ptsrz.diminfo[1].strides = __pyx_pybuffernd_ptsrz.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_ptsrz.diminfo[1].shape = __pyx_pybuffernd_ptsrz.rcbuffer->pybuffer.shape[1];
        if (unlikely(__pyx_t_19 < 0)) __PYX_ERR(0, 367, __pyx_L1_error)
      }
      __Pyx_DECREF_SET(__pyx_v_ptsrz, ((PyArrayObject *)__pyx_t_9));
      __pyx_t_9 = 0;
  __pyx_tuple__19 = PyTuple_Pack(1, __pyx_tuple__18); if (unlikely(!__pyx_tuple__19)) __PYX_ERR(0, 367, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__19);
  __Pyx_GIVEREF(__pyx_tuple__19);
+368:             iindF = iind[indin]
      __pyx_t_9 = PyObject_GetItem(((PyObject *)__pyx_v_iind), __pyx_v_indin); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 368, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_9);
      if (!(likely(((__pyx_t_9) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_9, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 368, __pyx_L1_error)
      __pyx_t_25 = ((PyArrayObject *)__pyx_t_9);
      {
        __Pyx_BufFmt_StackElem __pyx_stack[1];
        __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_iindF.rcbuffer->pybuffer);
        __pyx_t_19 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_iindF.rcbuffer->pybuffer, (PyObject*)__pyx_t_25, &__Pyx_TypeInfo_long, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack);
        if (unlikely(__pyx_t_19 < 0)) {
          PyErr_Fetch(&__pyx_t_24, &__pyx_t_23, &__pyx_t_22);
          if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_iindF.rcbuffer->pybuffer, (PyObject*)__pyx_v_iindF, &__Pyx_TypeInfo_long, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {
            Py_XDECREF(__pyx_t_24); Py_XDECREF(__pyx_t_23); Py_XDECREF(__pyx_t_22);
            __Pyx_RaiseBufferFallbackError();
          } else {
            PyErr_Restore(__pyx_t_24, __pyx_t_23, __pyx_t_22);
          }
        }
        __pyx_pybuffernd_iindF.diminfo[0].strides = __pyx_pybuffernd_iindF.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_iindF.diminfo[0].shape = __pyx_pybuffernd_iindF.rcbuffer->pybuffer.shape[0];
        if (unlikely(__pyx_t_19 < 0)) __PYX_ERR(0, 368, __pyx_L1_error)
      }
      __pyx_t_25 = 0;
      __pyx_v_iindF = ((PyArrayObject *)__pyx_t_9);
      __pyx_t_9 = 0;
+369:             dsF = dR0r*dZ0r*np.ones((indin.sum(),))
      __pyx_t_9 = PyFloat_FromDouble((__pyx_v_dR0r * __pyx_v_dZ0r)); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 369, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_9);
      __pyx_t_6 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 369, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_6);
      __pyx_t_16 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_n_s_ones); if (unlikely(!__pyx_t_16)) __PYX_ERR(0, 369, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_16);
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_indin, __pyx_n_s_sum); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 369, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_12 = NULL;
      if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_1))) {
        __pyx_t_12 = PyMethod_GET_SELF(__pyx_t_1);
        if (likely(__pyx_t_12)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1);
          __Pyx_INCREF(__pyx_t_12);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_1, function);
        }
      }
      if (__pyx_t_12) {
        __pyx_t_6 = __Pyx_PyObject_CallOneArg(__pyx_t_1, __pyx_t_12); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 369, __pyx_L1_error)
        __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
      } else {
        __pyx_t_6 = __Pyx_PyObject_CallNoArg(__pyx_t_1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 369, __pyx_L1_error)
      }
      __Pyx_GOTREF(__pyx_t_6);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 369, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_GIVEREF(__pyx_t_6);
      PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_6);
      __pyx_t_6 = 0;
      __pyx_t_6 = NULL;
      if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_16))) {
        __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_16);
        if (likely(__pyx_t_6)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_16);
          __Pyx_INCREF(__pyx_t_6);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_16, function);
        }
      }
      if (!__pyx_t_6) {
        __pyx_t_5 = __Pyx_PyObject_CallOneArg(__pyx_t_16, __pyx_t_1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 369, __pyx_L1_error)
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        __Pyx_GOTREF(__pyx_t_5);
      } else {
        #if CYTHON_FAST_PYCALL
        if (PyFunction_Check(__pyx_t_16)) {
          PyObject *__pyx_temp[2] = {__pyx_t_6, __pyx_t_1};
          __pyx_t_5 = __Pyx_PyFunction_FastCall(__pyx_t_16, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 369, __pyx_L1_error)
          __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
          __Pyx_GOTREF(__pyx_t_5);
          __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        } else
        #endif
        #if CYTHON_FAST_PYCCALL
        if (__Pyx_PyFastCFunction_Check(__pyx_t_16)) {
          PyObject *__pyx_temp[2] = {__pyx_t_6, __pyx_t_1};
          __pyx_t_5 = __Pyx_PyCFunction_FastCall(__pyx_t_16, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 369, __pyx_L1_error)
          __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
          __Pyx_GOTREF(__pyx_t_5);
          __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        } else
        #endif
        {
          __pyx_t_12 = PyTuple_New(1+1); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 369, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_12);
          __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_12, 0, __pyx_t_6); __pyx_t_6 = NULL;
          __Pyx_GIVEREF(__pyx_t_1);
          PyTuple_SET_ITEM(__pyx_t_12, 0+1, __pyx_t_1);
          __pyx_t_1 = 0;
          __pyx_t_5 = __Pyx_PyObject_Call(__pyx_t_16, __pyx_t_12, NULL); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 369, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_5);
          __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
        }
      }
      __Pyx_DECREF(__pyx_t_16); __pyx_t_16 = 0;
      __pyx_t_16 = PyNumber_Multiply(__pyx_t_9, __pyx_t_5); if (unlikely(!__pyx_t_16)) __PYX_ERR(0, 369, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_16);
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      if (!(likely(((__pyx_t_16) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_16, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 369, __pyx_L1_error)
      __pyx_t_20 = ((PyArrayObject *)__pyx_t_16);
      {
        __Pyx_BufFmt_StackElem __pyx_stack[1];
        __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_dsF.rcbuffer->pybuffer);
        __pyx_t_19 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_dsF.rcbuffer->pybuffer, (PyObject*)__pyx_t_20, &__Pyx_TypeInfo_double, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack);
        if (unlikely(__pyx_t_19 < 0)) {
          PyErr_Fetch(&__pyx_t_22, &__pyx_t_23, &__pyx_t_24);
          if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_dsF.rcbuffer->pybuffer, (PyObject*)__pyx_v_dsF, &__Pyx_TypeInfo_double, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {
            Py_XDECREF(__pyx_t_22); Py_XDECREF(__pyx_t_23); Py_XDECREF(__pyx_t_24);
            __Pyx_RaiseBufferFallbackError();
          } else {
            PyErr_Restore(__pyx_t_22, __pyx_t_23, __pyx_t_24);
          }
        }
        __pyx_pybuffernd_dsF.diminfo[0].strides = __pyx_pybuffernd_dsF.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_dsF.diminfo[0].shape = __pyx_pybuffernd_dsF.rcbuffer->pybuffer.shape[0];
        if (unlikely(__pyx_t_19 < 0)) __PYX_ERR(0, 369, __pyx_L1_error)
      }
      __pyx_t_20 = 0;
      __pyx_v_dsF = ((PyArrayObject *)__pyx_t_16);
      __pyx_t_16 = 0;
+370:             Faces = True
      __pyx_v_Faces = 1;
 371: 
 372:     # First face
+373:     if (DPhi is None or DPhi[0] is None) and Faces:
  __pyx_t_14 = (__pyx_v_DPhi == Py_None);
  __pyx_t_2 = (__pyx_t_14 != 0);
  if (!__pyx_t_2) {
  } else {
    goto __pyx_L17_next_and;
  }
  __pyx_t_16 = __Pyx_GetItemInt(__pyx_v_DPhi, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 0); if (unlikely(!__pyx_t_16)) __PYX_ERR(0, 373, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_16);
  __pyx_t_2 = (__pyx_t_16 == Py_None);
  __Pyx_DECREF(__pyx_t_16); __pyx_t_16 = 0;
  __pyx_t_14 = (__pyx_t_2 != 0);
  if (__pyx_t_14) {
  } else {
    __pyx_t_3 = __pyx_t_14;
    goto __pyx_L16_bool_binop_done;
  }
  __pyx_L17_next_and:;
  __pyx_t_14 = (__pyx_v_Faces != 0);
  __pyx_t_3 = __pyx_t_14;
  __pyx_L16_bool_binop_done:;
  if (__pyx_t_3) {
/* … */
  }
+374:         if Out.lower()=='(x,y,z)':
    __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_v_Out, __pyx_n_s_lower); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 374, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_9 = NULL;
    if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_5))) {
      __pyx_t_9 = PyMethod_GET_SELF(__pyx_t_5);
      if (likely(__pyx_t_9)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5);
        __Pyx_INCREF(__pyx_t_9);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_5, function);
      }
    }
    if (__pyx_t_9) {
      __pyx_t_16 = __Pyx_PyObject_CallOneArg(__pyx_t_5, __pyx_t_9); if (unlikely(!__pyx_t_16)) __PYX_ERR(0, 374, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
    } else {
      __pyx_t_16 = __Pyx_PyObject_CallNoArg(__pyx_t_5); if (unlikely(!__pyx_t_16)) __PYX_ERR(0, 374, __pyx_L1_error)
    }
    __Pyx_GOTREF(__pyx_t_16);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __pyx_t_3 = (__Pyx_PyUnicode_Equals(__pyx_t_16, __pyx_kp_u_x_y_z, Py_EQ)); if (unlikely(__pyx_t_3 < 0)) __PYX_ERR(0, 374, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_16); __pyx_t_16 = 0;
    if (__pyx_t_3) {
/* … */
      goto __pyx_L19;
    }
+375:             pts = np.array([ptsrz[0,:]*Ccos(PhiMinMax[0]+Dphi), ptsrz[0,:]*Csin(PhiMinMax[0]+Dphi), ptsrz[1,:]])
      __pyx_t_5 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 375, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
      __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_n_s_array); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 375, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_9);
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
/* … */
  __pyx_slice__20 = PySlice_New(Py_None, Py_None, Py_None); if (unlikely(!__pyx_slice__20)) __PYX_ERR(0, 375, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_slice__20);
  __Pyx_GIVEREF(__pyx_slice__20);
      __pyx_t_5 = PyObject_GetItem(((PyObject *)__pyx_v_ptsrz), __pyx_tuple__21); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 375, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
      __pyx_t_30 = 0;
      __pyx_t_12 = PyFloat_FromDouble(cos(((*((double *) ( /* dim=0 */ ((char *) (((double *) __pyx_v_PhiMinMax.data) + __pyx_t_30)) ))) + __pyx_v_Dphi))); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 375, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_12);
      __pyx_t_1 = PyNumber_Multiply(__pyx_t_5, __pyx_t_12); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 375, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
  __pyx_tuple__21 = PyTuple_Pack(2, __pyx_int_0, __pyx_slice__20); if (unlikely(!__pyx_tuple__21)) __PYX_ERR(0, 375, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__21);
  __Pyx_GIVEREF(__pyx_tuple__21);
  __pyx_slice__22 = PySlice_New(Py_None, Py_None, Py_None); if (unlikely(!__pyx_slice__22)) __PYX_ERR(0, 375, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_slice__22);
  __Pyx_GIVEREF(__pyx_slice__22);
      __pyx_t_12 = PyObject_GetItem(((PyObject *)__pyx_v_ptsrz), __pyx_tuple__23); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 375, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_12);
      __pyx_t_31 = 0;
      __pyx_t_5 = PyFloat_FromDouble(sin(((*((double *) ( /* dim=0 */ ((char *) (((double *) __pyx_v_PhiMinMax.data) + __pyx_t_31)) ))) + __pyx_v_Dphi))); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 375, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
      __pyx_t_6 = PyNumber_Multiply(__pyx_t_12, __pyx_t_5); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 375, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_6);
      __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __pyx_tuple__23 = PyTuple_Pack(2, __pyx_int_0, __pyx_slice__22); if (unlikely(!__pyx_tuple__23)) __PYX_ERR(0, 375, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__23);
  __Pyx_GIVEREF(__pyx_tuple__23);
  __pyx_slice__24 = PySlice_New(Py_None, Py_None, Py_None); if (unlikely(!__pyx_slice__24)) __PYX_ERR(0, 375, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_slice__24);
  __Pyx_GIVEREF(__pyx_slice__24);
      __pyx_t_5 = PyObject_GetItem(((PyObject *)__pyx_v_ptsrz), __pyx_tuple__25); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 375, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
      __pyx_t_12 = PyList_New(3); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 375, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_12);
      __Pyx_GIVEREF(__pyx_t_1);
      PyList_SET_ITEM(__pyx_t_12, 0, __pyx_t_1);
      __Pyx_GIVEREF(__pyx_t_6);
      PyList_SET_ITEM(__pyx_t_12, 1, __pyx_t_6);
      __Pyx_GIVEREF(__pyx_t_5);
      PyList_SET_ITEM(__pyx_t_12, 2, __pyx_t_5);
      __pyx_t_1 = 0;
      __pyx_t_6 = 0;
      __pyx_t_5 = 0;
      __pyx_t_5 = NULL;
      if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_9))) {
        __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_9);
        if (likely(__pyx_t_5)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_9);
          __Pyx_INCREF(__pyx_t_5);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_9, function);
        }
      }
      if (!__pyx_t_5) {
        __pyx_t_16 = __Pyx_PyObject_CallOneArg(__pyx_t_9, __pyx_t_12); if (unlikely(!__pyx_t_16)) __PYX_ERR(0, 375, __pyx_L1_error)
        __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
        __Pyx_GOTREF(__pyx_t_16);
      } else {
        #if CYTHON_FAST_PYCALL
        if (PyFunction_Check(__pyx_t_9)) {
          PyObject *__pyx_temp[2] = {__pyx_t_5, __pyx_t_12};
          __pyx_t_16 = __Pyx_PyFunction_FastCall(__pyx_t_9, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_16)) __PYX_ERR(0, 375, __pyx_L1_error)
          __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
          __Pyx_GOTREF(__pyx_t_16);
          __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
        } else
        #endif
        #if CYTHON_FAST_PYCCALL
        if (__Pyx_PyFastCFunction_Check(__pyx_t_9)) {
          PyObject *__pyx_temp[2] = {__pyx_t_5, __pyx_t_12};
          __pyx_t_16 = __Pyx_PyCFunction_FastCall(__pyx_t_9, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_16)) __PYX_ERR(0, 375, __pyx_L1_error)
          __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
          __Pyx_GOTREF(__pyx_t_16);
          __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
        } else
        #endif
        {
          __pyx_t_6 = PyTuple_New(1+1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 375, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_6);
          __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_5); __pyx_t_5 = NULL;
          __Pyx_GIVEREF(__pyx_t_12);
          PyTuple_SET_ITEM(__pyx_t_6, 0+1, __pyx_t_12);
          __pyx_t_12 = 0;
          __pyx_t_16 = __Pyx_PyObject_Call(__pyx_t_9, __pyx_t_6, NULL); if (unlikely(!__pyx_t_16)) __PYX_ERR(0, 375, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_16);
          __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
        }
      }
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
      if (!(likely(((__pyx_t_16) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_16, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 375, __pyx_L1_error)
      __pyx_t_28 = ((PyArrayObject *)__pyx_t_16);
      {
        __Pyx_BufFmt_StackElem __pyx_stack[1];
        __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_pts.rcbuffer->pybuffer);
        __pyx_t_19 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_pts.rcbuffer->pybuffer, (PyObject*)__pyx_t_28, &__Pyx_TypeInfo_double, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack);
        if (unlikely(__pyx_t_19 < 0)) {
          PyErr_Fetch(&__pyx_t_24, &__pyx_t_23, &__pyx_t_22);
          if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_pts.rcbuffer->pybuffer, (PyObject*)__pyx_v_pts, &__Pyx_TypeInfo_double, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) {
            Py_XDECREF(__pyx_t_24); Py_XDECREF(__pyx_t_23); Py_XDECREF(__pyx_t_22);
            __Pyx_RaiseBufferFallbackError();
          } else {
            PyErr_Restore(__pyx_t_24, __pyx_t_23, __pyx_t_22);
          }
        }
        __pyx_pybuffernd_pts.diminfo[0].strides = __pyx_pybuffernd_pts.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_pts.diminfo[0].shape = __pyx_pybuffernd_pts.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_pts.diminfo[1].strides = __pyx_pybuffernd_pts.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_pts.diminfo[1].shape = __pyx_pybuffernd_pts.rcbuffer->pybuffer.shape[1];
        if (unlikely(__pyx_t_19 < 0)) __PYX_ERR(0, 375, __pyx_L1_error)
      }
      __pyx_t_28 = 0;
      __pyx_v_pts = ((PyArrayObject *)__pyx_t_16);
      __pyx_t_16 = 0;
  __pyx_tuple__25 = PyTuple_Pack(2, __pyx_int_1, __pyx_slice__24); if (unlikely(!__pyx_tuple__25)) __PYX_ERR(0, 375, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__25);
  __Pyx_GIVEREF(__pyx_tuple__25);
 376:         else:
+377:             pts = np.array([ptsrz[0,:],ptsrz[1,:],(PhiMinMax[0]+Dphi)*np.ones((indin.sum(),))])
    /*else*/ {
      __pyx_t_9 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 377, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_9);
      __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_9, __pyx_n_s_array); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 377, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_6);
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
/* … */
  __pyx_slice__26 = PySlice_New(Py_None, Py_None, Py_None); if (unlikely(!__pyx_slice__26)) __PYX_ERR(0, 377, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_slice__26);
  __Pyx_GIVEREF(__pyx_slice__26);
      __pyx_t_9 = PyObject_GetItem(((PyObject *)__pyx_v_ptsrz), __pyx_tuple__27); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 377, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_9);
  __pyx_tuple__27 = PyTuple_Pack(2, __pyx_int_0, __pyx_slice__26); if (unlikely(!__pyx_tuple__27)) __PYX_ERR(0, 377, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__27);
  __Pyx_GIVEREF(__pyx_tuple__27);
  __pyx_slice__28 = PySlice_New(Py_None, Py_None, Py_None); if (unlikely(!__pyx_slice__28)) __PYX_ERR(0, 377, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_slice__28);
  __Pyx_GIVEREF(__pyx_slice__28);
      __pyx_t_12 = PyObject_GetItem(((PyObject *)__pyx_v_ptsrz), __pyx_tuple__29); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 377, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_12);
      __pyx_t_32 = 0;
      __pyx_t_5 = PyFloat_FromDouble(((*((double *) ( /* dim=0 */ ((char *) (((double *) __pyx_v_PhiMinMax.data) + __pyx_t_32)) ))) + __pyx_v_Dphi)); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 377, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
      __pyx_t_15 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 377, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_15);
      __pyx_t_11 = __Pyx_PyObject_GetAttrStr(__pyx_t_15, __pyx_n_s_ones); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 377, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_11);
      __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
      if (unlikely(!__pyx_v_indin)) { __Pyx_RaiseUnboundLocalError("indin"); __PYX_ERR(0, 377, __pyx_L1_error) }
      __pyx_t_17 = __Pyx_PyObject_GetAttrStr(__pyx_v_indin, __pyx_n_s_sum); if (unlikely(!__pyx_t_17)) __PYX_ERR(0, 377, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_17);
      __pyx_t_33 = NULL;
      if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_17))) {
        __pyx_t_33 = PyMethod_GET_SELF(__pyx_t_17);
        if (likely(__pyx_t_33)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_17);
          __Pyx_INCREF(__pyx_t_33);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_17, function);
        }
      }
      if (__pyx_t_33) {
        __pyx_t_15 = __Pyx_PyObject_CallOneArg(__pyx_t_17, __pyx_t_33); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 377, __pyx_L1_error)
        __Pyx_DECREF(__pyx_t_33); __pyx_t_33 = 0;
      } else {
        __pyx_t_15 = __Pyx_PyObject_CallNoArg(__pyx_t_17); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 377, __pyx_L1_error)
      }
      __Pyx_GOTREF(__pyx_t_15);
      __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;
      __pyx_t_17 = PyTuple_New(1); if (unlikely(!__pyx_t_17)) __PYX_ERR(0, 377, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_17);
      __Pyx_GIVEREF(__pyx_t_15);
      PyTuple_SET_ITEM(__pyx_t_17, 0, __pyx_t_15);
      __pyx_t_15 = 0;
      __pyx_t_15 = NULL;
      if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_11))) {
        __pyx_t_15 = PyMethod_GET_SELF(__pyx_t_11);
        if (likely(__pyx_t_15)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_11);
          __Pyx_INCREF(__pyx_t_15);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_11, function);
        }
      }
      if (!__pyx_t_15) {
        __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_11, __pyx_t_17); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 377, __pyx_L1_error)
        __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;
        __Pyx_GOTREF(__pyx_t_1);
      } else {
        #if CYTHON_FAST_PYCALL
        if (PyFunction_Check(__pyx_t_11)) {
          PyObject *__pyx_temp[2] = {__pyx_t_15, __pyx_t_17};
          __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_11, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 377, __pyx_L1_error)
          __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0;
          __Pyx_GOTREF(__pyx_t_1);
          __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;
        } else
        #endif
        #if CYTHON_FAST_PYCCALL
        if (__Pyx_PyFastCFunction_Check(__pyx_t_11)) {
          PyObject *__pyx_temp[2] = {__pyx_t_15, __pyx_t_17};
          __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_11, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 377, __pyx_L1_error)
          __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0;
          __Pyx_GOTREF(__pyx_t_1);
          __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;
        } else
        #endif
        {
          __pyx_t_33 = PyTuple_New(1+1); if (unlikely(!__pyx_t_33)) __PYX_ERR(0, 377, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_33);
          __Pyx_GIVEREF(__pyx_t_15); PyTuple_SET_ITEM(__pyx_t_33, 0, __pyx_t_15); __pyx_t_15 = NULL;
          __Pyx_GIVEREF(__pyx_t_17);
          PyTuple_SET_ITEM(__pyx_t_33, 0+1, __pyx_t_17);
          __pyx_t_17 = 0;
          __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_11, __pyx_t_33, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 377, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_1);
          __Pyx_DECREF(__pyx_t_33); __pyx_t_33 = 0;
        }
      }
      __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
      __pyx_t_11 = PyNumber_Multiply(__pyx_t_5, __pyx_t_1); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 377, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_11);
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __pyx_t_1 = PyList_New(3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 377, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_GIVEREF(__pyx_t_9);
      PyList_SET_ITEM(__pyx_t_1, 0, __pyx_t_9);
      __Pyx_GIVEREF(__pyx_t_12);
      PyList_SET_ITEM(__pyx_t_1, 1, __pyx_t_12);
      __Pyx_GIVEREF(__pyx_t_11);
      PyList_SET_ITEM(__pyx_t_1, 2, __pyx_t_11);
      __pyx_t_9 = 0;
      __pyx_t_12 = 0;
      __pyx_t_11 = 0;
      __pyx_t_11 = NULL;
      if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_6))) {
        __pyx_t_11 = PyMethod_GET_SELF(__pyx_t_6);
        if (likely(__pyx_t_11)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6);
          __Pyx_INCREF(__pyx_t_11);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_6, function);
        }
      }
      if (!__pyx_t_11) {
        __pyx_t_16 = __Pyx_PyObject_CallOneArg(__pyx_t_6, __pyx_t_1); if (unlikely(!__pyx_t_16)) __PYX_ERR(0, 377, __pyx_L1_error)
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        __Pyx_GOTREF(__pyx_t_16);
      } else {
        #if CYTHON_FAST_PYCALL
        if (PyFunction_Check(__pyx_t_6)) {
          PyObject *__pyx_temp[2] = {__pyx_t_11, __pyx_t_1};
          __pyx_t_16 = __Pyx_PyFunction_FastCall(__pyx_t_6, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_16)) __PYX_ERR(0, 377, __pyx_L1_error)
          __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0;
          __Pyx_GOTREF(__pyx_t_16);
          __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        } else
        #endif
        #if CYTHON_FAST_PYCCALL
        if (__Pyx_PyFastCFunction_Check(__pyx_t_6)) {
          PyObject *__pyx_temp[2] = {__pyx_t_11, __pyx_t_1};
          __pyx_t_16 = __Pyx_PyCFunction_FastCall(__pyx_t_6, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_16)) __PYX_ERR(0, 377, __pyx_L1_error)
          __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0;
          __Pyx_GOTREF(__pyx_t_16);
          __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        } else
        #endif
        {
          __pyx_t_12 = PyTuple_New(1+1); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 377, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_12);
          __Pyx_GIVEREF(__pyx_t_11); PyTuple_SET_ITEM(__pyx_t_12, 0, __pyx_t_11); __pyx_t_11 = NULL;
          __Pyx_GIVEREF(__pyx_t_1);
          PyTuple_SET_ITEM(__pyx_t_12, 0+1, __pyx_t_1);
          __pyx_t_1 = 0;
          __pyx_t_16 = __Pyx_PyObject_Call(__pyx_t_6, __pyx_t_12, NULL); if (unlikely(!__pyx_t_16)) __PYX_ERR(0, 377, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_16);
          __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
        }
      }
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      if (!(likely(((__pyx_t_16) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_16, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 377, __pyx_L1_error)
      __pyx_t_28 = ((PyArrayObject *)__pyx_t_16);
      {
        __Pyx_BufFmt_StackElem __pyx_stack[1];
        __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_pts.rcbuffer->pybuffer);
        __pyx_t_19 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_pts.rcbuffer->pybuffer, (PyObject*)__pyx_t_28, &__Pyx_TypeInfo_double, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack);
        if (unlikely(__pyx_t_19 < 0)) {
          PyErr_Fetch(&__pyx_t_22, &__pyx_t_23, &__pyx_t_24);
          if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_pts.rcbuffer->pybuffer, (PyObject*)__pyx_v_pts, &__Pyx_TypeInfo_double, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) {
            Py_XDECREF(__pyx_t_22); Py_XDECREF(__pyx_t_23); Py_XDECREF(__pyx_t_24);
            __Pyx_RaiseBufferFallbackError();
          } else {
            PyErr_Restore(__pyx_t_22, __pyx_t_23, __pyx_t_24);
          }
        }
        __pyx_pybuffernd_pts.diminfo[0].strides = __pyx_pybuffernd_pts.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_pts.diminfo[0].shape = __pyx_pybuffernd_pts.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_pts.diminfo[1].strides = __pyx_pybuffernd_pts.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_pts.diminfo[1].shape = __pyx_pybuffernd_pts.rcbuffer->pybuffer.shape[1];
        if (unlikely(__pyx_t_19 < 0)) __PYX_ERR(0, 377, __pyx_L1_error)
      }
      __pyx_t_28 = 0;
      __pyx_v_pts = ((PyArrayObject *)__pyx_t_16);
      __pyx_t_16 = 0;
    }
    __pyx_L19:;
  __pyx_tuple__29 = PyTuple_Pack(2, __pyx_int_1, __pyx_slice__28); if (unlikely(!__pyx_tuple__29)) __PYX_ERR(0, 377, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__29);
  __Pyx_GIVEREF(__pyx_tuple__29);
+378:         LPts.append( pts )
    __pyx_t_34 = __Pyx_PyList_Append(__pyx_v_LPts, ((PyObject *)__pyx_v_pts)); if (unlikely(__pyx_t_34 == -1)) __PYX_ERR(0, 378, __pyx_L1_error)
+379:         Lind.append( iindF )
    __pyx_t_34 = __Pyx_PyList_Append(__pyx_v_Lind, ((PyObject *)__pyx_v_iindF)); if (unlikely(__pyx_t_34 == -1)) __PYX_ERR(0, 379, __pyx_L1_error)
+380:         LdS.append( dsF )
    __pyx_t_34 = __Pyx_PyList_Append(__pyx_v_LdS, ((PyObject *)__pyx_v_dsF)); if (unlikely(__pyx_t_34 == -1)) __PYX_ERR(0, 380, __pyx_L1_error)
 381: 
 382:     # Main body
+383:     PtsM, dSM, indM, NL, dLr, Rref, dRPhir, nRPhi0, VPbis = _Ves_Smesh_Tor_SubFromD_cython(dL, dRPhi, VPoly,
  __pyx_t_16 = __Pyx_GetModuleGlobalName(__pyx_n_s_Ves_Smesh_Tor_SubFromD_cython); if (unlikely(!__pyx_t_16)) __PYX_ERR(0, 383, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_16);
  __pyx_t_6 = PyFloat_FromDouble(__pyx_v_dL); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 383, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __pyx_t_12 = PyFloat_FromDouble(__pyx_v_dRPhi); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 383, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_12);
  __pyx_t_1 = __pyx_memoryview_fromslice(__pyx_v_VPoly, 2, (PyObject *(*)(char *)) __pyx_memview_get_double, (int (*)(char *, PyObject *)) __pyx_memview_set_double, 0);; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 383, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_11 = PyTuple_New(3); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 383, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_11);
  __Pyx_GIVEREF(__pyx_t_6);
  PyTuple_SET_ITEM(__pyx_t_11, 0, __pyx_t_6);
  __Pyx_GIVEREF(__pyx_t_12);
  PyTuple_SET_ITEM(__pyx_t_11, 1, __pyx_t_12);
  __Pyx_GIVEREF(__pyx_t_1);
  PyTuple_SET_ITEM(__pyx_t_11, 2, __pyx_t_1);
  __pyx_t_6 = 0;
  __pyx_t_12 = 0;
  __pyx_t_1 = 0;
/* … */
  __pyx_t_12 = __Pyx_PyObject_Call(__pyx_t_16, __pyx_t_11, __pyx_t_1); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 383, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_12);
  __Pyx_DECREF(__pyx_t_16); __pyx_t_16 = 0;
  __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if ((likely(PyTuple_CheckExact(__pyx_t_12))) || (PyList_CheckExact(__pyx_t_12))) {
    PyObject* sequence = __pyx_t_12;
    #if !CYTHON_COMPILING_IN_PYPY
    Py_ssize_t size = Py_SIZE(sequence);
    #else
    Py_ssize_t size = PySequence_Size(sequence);
    #endif
    if (unlikely(size != 9)) {
      if (size > 9) __Pyx_RaiseTooManyValuesError(9);
      else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
      __PYX_ERR(0, 383, __pyx_L1_error)
    }
    #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
    if (likely(PyTuple_CheckExact(sequence))) {
      __pyx_t_1 = PyTuple_GET_ITEM(sequence, 0); 
      __pyx_t_11 = PyTuple_GET_ITEM(sequence, 1); 
      __pyx_t_16 = PyTuple_GET_ITEM(sequence, 2); 
      __pyx_t_6 = PyTuple_GET_ITEM(sequence, 3); 
      __pyx_t_9 = PyTuple_GET_ITEM(sequence, 4); 
      __pyx_t_5 = PyTuple_GET_ITEM(sequence, 5); 
      __pyx_t_33 = PyTuple_GET_ITEM(sequence, 6); 
      __pyx_t_17 = PyTuple_GET_ITEM(sequence, 7); 
      __pyx_t_15 = PyTuple_GET_ITEM(sequence, 8); 
    } else {
      __pyx_t_1 = PyList_GET_ITEM(sequence, 0); 
      __pyx_t_11 = PyList_GET_ITEM(sequence, 1); 
      __pyx_t_16 = PyList_GET_ITEM(sequence, 2); 
      __pyx_t_6 = PyList_GET_ITEM(sequence, 3); 
      __pyx_t_9 = PyList_GET_ITEM(sequence, 4); 
      __pyx_t_5 = PyList_GET_ITEM(sequence, 5); 
      __pyx_t_33 = PyList_GET_ITEM(sequence, 6); 
      __pyx_t_17 = PyList_GET_ITEM(sequence, 7); 
      __pyx_t_15 = PyList_GET_ITEM(sequence, 8); 
    }
    __Pyx_INCREF(__pyx_t_1);
    __Pyx_INCREF(__pyx_t_11);
    __Pyx_INCREF(__pyx_t_16);
    __Pyx_INCREF(__pyx_t_6);
    __Pyx_INCREF(__pyx_t_9);
    __Pyx_INCREF(__pyx_t_5);
    __Pyx_INCREF(__pyx_t_33);
    __Pyx_INCREF(__pyx_t_17);
    __Pyx_INCREF(__pyx_t_15);
    #else
    {
      Py_ssize_t i;
      PyObject** temps[9] = {&__pyx_t_1,&__pyx_t_11,&__pyx_t_16,&__pyx_t_6,&__pyx_t_9,&__pyx_t_5,&__pyx_t_33,&__pyx_t_17,&__pyx_t_15};
      for (i=0; i < 9; i++) {
        PyObject* item = PySequence_ITEM(sequence, i); if (unlikely(!item)) __PYX_ERR(0, 383, __pyx_L1_error)
        __Pyx_GOTREF(item);
        *(temps[i]) = item;
      }
    }
    #endif
    __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
  } else {
    Py_ssize_t index = -1;
    PyObject** temps[9] = {&__pyx_t_1,&__pyx_t_11,&__pyx_t_16,&__pyx_t_6,&__pyx_t_9,&__pyx_t_5,&__pyx_t_33,&__pyx_t_17,&__pyx_t_15};
    __pyx_t_35 = PyObject_GetIter(__pyx_t_12); if (unlikely(!__pyx_t_35)) __PYX_ERR(0, 383, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_35);
    __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
    __pyx_t_18 = Py_TYPE(__pyx_t_35)->tp_iternext;
    for (index=0; index < 9; index++) {
      PyObject* item = __pyx_t_18(__pyx_t_35); if (unlikely(!item)) goto __pyx_L20_unpacking_failed;
      __Pyx_GOTREF(item);
      *(temps[index]) = item;
    }
    if (__Pyx_IternextUnpackEndCheck(__pyx_t_18(__pyx_t_35), 9) < 0) __PYX_ERR(0, 383, __pyx_L1_error)
    __pyx_t_18 = NULL;
    __Pyx_DECREF(__pyx_t_35); __pyx_t_35 = 0;
    goto __pyx_L21_unpacking_done;
    __pyx_L20_unpacking_failed:;
    __Pyx_DECREF(__pyx_t_35); __pyx_t_35 = 0;
    __pyx_t_18 = NULL;
    if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
    __PYX_ERR(0, 383, __pyx_L1_error)
    __pyx_L21_unpacking_done:;
  }
  if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 383, __pyx_L1_error)
  if (!(likely(((__pyx_t_11) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_11, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 383, __pyx_L1_error)
  if (!(likely(((__pyx_t_16) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_16, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 383, __pyx_L1_error)
  if (!(likely(((__pyx_t_6) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_6, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 383, __pyx_L1_error)
  if (!(likely(((__pyx_t_9) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_9, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 383, __pyx_L1_error)
  if (!(likely(((__pyx_t_5) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_5, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 383, __pyx_L1_error)
  if (!(likely(((__pyx_t_33) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_33, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 383, __pyx_L1_error)
  if (!(likely(((__pyx_t_15) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_15, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 383, __pyx_L1_error)
  __pyx_t_28 = ((PyArrayObject *)__pyx_t_1);
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_PtsM.rcbuffer->pybuffer);
    __pyx_t_19 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_PtsM.rcbuffer->pybuffer, (PyObject*)__pyx_t_28, &__Pyx_TypeInfo_double, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack);
    if (unlikely(__pyx_t_19 < 0)) {
      PyErr_Fetch(&__pyx_t_24, &__pyx_t_23, &__pyx_t_22);
      if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_PtsM.rcbuffer->pybuffer, (PyObject*)__pyx_v_PtsM, &__Pyx_TypeInfo_double, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) {
        Py_XDECREF(__pyx_t_24); Py_XDECREF(__pyx_t_23); Py_XDECREF(__pyx_t_22);
        __Pyx_RaiseBufferFallbackError();
      } else {
        PyErr_Restore(__pyx_t_24, __pyx_t_23, __pyx_t_22);
      }
    }
    __pyx_pybuffernd_PtsM.diminfo[0].strides = __pyx_pybuffernd_PtsM.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_PtsM.diminfo[0].shape = __pyx_pybuffernd_PtsM.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_PtsM.diminfo[1].strides = __pyx_pybuffernd_PtsM.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_PtsM.diminfo[1].shape = __pyx_pybuffernd_PtsM.rcbuffer->pybuffer.shape[1];
    if (unlikely(__pyx_t_19 < 0)) __PYX_ERR(0, 383, __pyx_L1_error)
  }
  __pyx_t_28 = 0;
  __pyx_v_PtsM = ((PyArrayObject *)__pyx_t_1);
  __pyx_t_1 = 0;
  __pyx_t_20 = ((PyArrayObject *)__pyx_t_11);
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_dSM.rcbuffer->pybuffer);
    __pyx_t_19 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_dSM.rcbuffer->pybuffer, (PyObject*)__pyx_t_20, &__Pyx_TypeInfo_double, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack);
    if (unlikely(__pyx_t_19 < 0)) {
      PyErr_Fetch(&__pyx_t_22, &__pyx_t_23, &__pyx_t_24);
      if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_dSM.rcbuffer->pybuffer, (PyObject*)__pyx_v_dSM, &__Pyx_TypeInfo_double, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {
        Py_XDECREF(__pyx_t_22); Py_XDECREF(__pyx_t_23); Py_XDECREF(__pyx_t_24);
        __Pyx_RaiseBufferFallbackError();
      } else {
        PyErr_Restore(__pyx_t_22, __pyx_t_23, __pyx_t_24);
      }
    }
    __pyx_pybuffernd_dSM.diminfo[0].strides = __pyx_pybuffernd_dSM.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_dSM.diminfo[0].shape = __pyx_pybuffernd_dSM.rcbuffer->pybuffer.shape[0];
    if (unlikely(__pyx_t_19 < 0)) __PYX_ERR(0, 383, __pyx_L1_error)
  }
  __pyx_t_20 = 0;
  __pyx_v_dSM = ((PyArrayObject *)__pyx_t_11);
  __pyx_t_11 = 0;
  __pyx_t_25 = ((PyArrayObject *)__pyx_t_16);
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_indM.rcbuffer->pybuffer);
    __pyx_t_19 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_indM.rcbuffer->pybuffer, (PyObject*)__pyx_t_25, &__Pyx_TypeInfo_long, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack);
    if (unlikely(__pyx_t_19 < 0)) {
      PyErr_Fetch(&__pyx_t_24, &__pyx_t_23, &__pyx_t_22);
      if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_indM.rcbuffer->pybuffer, (PyObject*)__pyx_v_indM, &__Pyx_TypeInfo_long, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {
        Py_XDECREF(__pyx_t_24); Py_XDECREF(__pyx_t_23); Py_XDECREF(__pyx_t_22);
        __Pyx_RaiseBufferFallbackError();
      } else {
        PyErr_Restore(__pyx_t_24, __pyx_t_23, __pyx_t_22);
      }
    }
    __pyx_pybuffernd_indM.diminfo[0].strides = __pyx_pybuffernd_indM.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_indM.diminfo[0].shape = __pyx_pybuffernd_indM.rcbuffer->pybuffer.shape[0];
    if (unlikely(__pyx_t_19 < 0)) __PYX_ERR(0, 383, __pyx_L1_error)
  }
  __pyx_t_25 = 0;
  __pyx_v_indM = ((PyArrayObject *)__pyx_t_16);
  __pyx_t_16 = 0;
  __pyx_t_25 = ((PyArrayObject *)__pyx_t_6);
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_NL.rcbuffer->pybuffer);
    __pyx_t_19 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_NL.rcbuffer->pybuffer, (PyObject*)__pyx_t_25, &__Pyx_TypeInfo_long, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack);
    if (unlikely(__pyx_t_19 < 0)) {
      PyErr_Fetch(&__pyx_t_22, &__pyx_t_23, &__pyx_t_24);
      if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_NL.rcbuffer->pybuffer, (PyObject*)__pyx_v_NL, &__Pyx_TypeInfo_long, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {
        Py_XDECREF(__pyx_t_22); Py_XDECREF(__pyx_t_23); Py_XDECREF(__pyx_t_24);
        __Pyx_RaiseBufferFallbackError();
      } else {
        PyErr_Restore(__pyx_t_22, __pyx_t_23, __pyx_t_24);
      }
    }
    __pyx_pybuffernd_NL.diminfo[0].strides = __pyx_pybuffernd_NL.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_NL.diminfo[0].shape = __pyx_pybuffernd_NL.rcbuffer->pybuffer.shape[0];
    if (unlikely(__pyx_t_19 < 0)) __PYX_ERR(0, 383, __pyx_L1_error)
  }
  __pyx_t_25 = 0;
  __pyx_v_NL = ((PyArrayObject *)__pyx_t_6);
  __pyx_t_6 = 0;
  __pyx_t_20 = ((PyArrayObject *)__pyx_t_9);
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_dLr.rcbuffer->pybuffer);
    __pyx_t_19 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_dLr.rcbuffer->pybuffer, (PyObject*)__pyx_t_20, &__Pyx_TypeInfo_double, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack);
    if (unlikely(__pyx_t_19 < 0)) {
      PyErr_Fetch(&__pyx_t_24, &__pyx_t_23, &__pyx_t_22);
      if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_dLr.rcbuffer->pybuffer, (PyObject*)__pyx_v_dLr, &__Pyx_TypeInfo_double, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {
        Py_XDECREF(__pyx_t_24); Py_XDECREF(__pyx_t_23); Py_XDECREF(__pyx_t_22);
        __Pyx_RaiseBufferFallbackError();
      } else {
        PyErr_Restore(__pyx_t_24, __pyx_t_23, __pyx_t_22);
      }
    }
    __pyx_pybuffernd_dLr.diminfo[0].strides = __pyx_pybuffernd_dLr.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_dLr.diminfo[0].shape = __pyx_pybuffernd_dLr.rcbuffer->pybuffer.shape[0];
    if (unlikely(__pyx_t_19 < 0)) __PYX_ERR(0, 383, __pyx_L1_error)
  }
  __pyx_t_20 = 0;
  __pyx_v_dLr = ((PyArrayObject *)__pyx_t_9);
  __pyx_t_9 = 0;
  __pyx_t_20 = ((PyArrayObject *)__pyx_t_5);
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_Rref.rcbuffer->pybuffer);
    __pyx_t_19 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_Rref.rcbuffer->pybuffer, (PyObject*)__pyx_t_20, &__Pyx_TypeInfo_double, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack);
    if (unlikely(__pyx_t_19 < 0)) {
      PyErr_Fetch(&__pyx_t_22, &__pyx_t_23, &__pyx_t_24);
      if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_Rref.rcbuffer->pybuffer, (PyObject*)__pyx_v_Rref, &__Pyx_TypeInfo_double, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {
        Py_XDECREF(__pyx_t_22); Py_XDECREF(__pyx_t_23); Py_XDECREF(__pyx_t_24);
        __Pyx_RaiseBufferFallbackError();
      } else {
        PyErr_Restore(__pyx_t_22, __pyx_t_23, __pyx_t_24);
      }
    }
    __pyx_pybuffernd_Rref.diminfo[0].strides = __pyx_pybuffernd_Rref.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_Rref.diminfo[0].shape = __pyx_pybuffernd_Rref.rcbuffer->pybuffer.shape[0];
    if (unlikely(__pyx_t_19 < 0)) __PYX_ERR(0, 383, __pyx_L1_error)
  }
  __pyx_t_20 = 0;
  __pyx_v_Rref = ((PyArrayObject *)__pyx_t_5);
  __pyx_t_5 = 0;
  __pyx_t_20 = ((PyArrayObject *)__pyx_t_33);
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_dRPhir.rcbuffer->pybuffer);
    __pyx_t_19 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_dRPhir.rcbuffer->pybuffer, (PyObject*)__pyx_t_20, &__Pyx_TypeInfo_double, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack);
    if (unlikely(__pyx_t_19 < 0)) {
      PyErr_Fetch(&__pyx_t_24, &__pyx_t_23, &__pyx_t_22);
      if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_dRPhir.rcbuffer->pybuffer, (PyObject*)__pyx_v_dRPhir, &__Pyx_TypeInfo_double, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {
        Py_XDECREF(__pyx_t_24); Py_XDECREF(__pyx_t_23); Py_XDECREF(__pyx_t_22);
        __Pyx_RaiseBufferFallbackError();
      } else {
        PyErr_Restore(__pyx_t_24, __pyx_t_23, __pyx_t_22);
      }
    }
    __pyx_pybuffernd_dRPhir.diminfo[0].strides = __pyx_pybuffernd_dRPhir.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_dRPhir.diminfo[0].shape = __pyx_pybuffernd_dRPhir.rcbuffer->pybuffer.shape[0];
    if (unlikely(__pyx_t_19 < 0)) __PYX_ERR(0, 383, __pyx_L1_error)
  }
  __pyx_t_20 = 0;
  __pyx_v_dRPhir = ((PyArrayObject *)__pyx_t_33);
  __pyx_t_33 = 0;
  __pyx_v_nRPhi0 = __pyx_t_17;
  __pyx_t_17 = 0;
  __pyx_t_28 = ((PyArrayObject *)__pyx_t_15);
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_VPbis.rcbuffer->pybuffer);
    __pyx_t_19 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_VPbis.rcbuffer->pybuffer, (PyObject*)__pyx_t_28, &__Pyx_TypeInfo_double, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack);
    if (unlikely(__pyx_t_19 < 0)) {
      PyErr_Fetch(&__pyx_t_22, &__pyx_t_23, &__pyx_t_24);
      if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_VPbis.rcbuffer->pybuffer, (PyObject*)__pyx_v_VPbis, &__Pyx_TypeInfo_double, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) {
        Py_XDECREF(__pyx_t_22); Py_XDECREF(__pyx_t_23); Py_XDECREF(__pyx_t_24);
        __Pyx_RaiseBufferFallbackError();
      } else {
        PyErr_Restore(__pyx_t_22, __pyx_t_23, __pyx_t_24);
      }
    }
    __pyx_pybuffernd_VPbis.diminfo[0].strides = __pyx_pybuffernd_VPbis.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_VPbis.diminfo[0].shape = __pyx_pybuffernd_VPbis.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_VPbis.diminfo[1].strides = __pyx_pybuffernd_VPbis.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_VPbis.diminfo[1].shape = __pyx_pybuffernd_VPbis.rcbuffer->pybuffer.shape[1];
    if (unlikely(__pyx_t_19 < 0)) __PYX_ERR(0, 383, __pyx_L1_error)
  }
  __pyx_t_28 = 0;
  __pyx_v_VPbis = ((PyArrayObject *)__pyx_t_15);
  __pyx_t_15 = 0;
+384:                                                                                            DR=DR, DZ=DZ, DPhi=DPhi,
  __pyx_t_1 = PyDict_New(); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 384, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_DR, __pyx_v_DR) < 0) __PYX_ERR(0, 384, __pyx_L1_error)
  if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_DZ, __pyx_v_DZ) < 0) __PYX_ERR(0, 384, __pyx_L1_error)
  if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_DPhi, __pyx_v_DPhi) < 0) __PYX_ERR(0, 384, __pyx_L1_error)
+385:                                                                                            DIn=DIn, VIn=VIn, PhiMinMax=PhiMinMax,
  __pyx_t_12 = PyFloat_FromDouble(__pyx_v_DIn); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 385, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_12);
  if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_DIn, __pyx_t_12) < 0) __PYX_ERR(0, 384, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
  if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_VIn, __pyx_v_VIn) < 0) __PYX_ERR(0, 384, __pyx_L1_error)
  __pyx_t_12 = __pyx_memoryview_fromslice(__pyx_v_PhiMinMax, 1, (PyObject *(*)(char *)) __pyx_memview_get_double, (int (*)(char *, PyObject *)) __pyx_memview_set_double, 0);; if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 385, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_12);
  if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_PhiMinMax, __pyx_t_12) < 0) __PYX_ERR(0, 384, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
+386:                                                                                            Out=Out, margin=margin)
  if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_Out, __pyx_v_Out) < 0) __PYX_ERR(0, 384, __pyx_L1_error)
  __pyx_t_12 = PyFloat_FromDouble(__pyx_v_margin); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 386, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_12);
  if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_margin, __pyx_t_12) < 0) __PYX_ERR(0, 384, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
 387: 
+388:     if PtsM.shape[1]>=1:
  __pyx_t_3 = (((__pyx_v_PtsM->dimensions[1]) >= 1) != 0);
  if (__pyx_t_3) {
/* … */
  }
+389:         if PtsM.shape[1]==1:
    __pyx_t_3 = (((__pyx_v_PtsM->dimensions[1]) == 1) != 0);
    if (__pyx_t_3) {
/* … */
      goto __pyx_L23;
    }
+390:             LPts.append(PtsM.reshape((3,1)))
      __pyx_t_12 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_PtsM), __pyx_n_s_reshape); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 390, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_12);
/* … */
  __pyx_tuple__30 = PyTuple_Pack(2, __pyx_int_3, __pyx_int_1); if (unlikely(!__pyx_tuple__30)) __PYX_ERR(0, 390, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__30);
  __Pyx_GIVEREF(__pyx_tuple__30);
      __pyx_t_15 = __Pyx_PyObject_Call(__pyx_t_12, __pyx_tuple__31, NULL); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 390, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_15);
      __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
      __pyx_t_34 = __Pyx_PyList_Append(__pyx_v_LPts, __pyx_t_15); if (unlikely(__pyx_t_34 == -1)) __PYX_ERR(0, 390, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
  __pyx_tuple__31 = PyTuple_Pack(1, __pyx_tuple__30); if (unlikely(!__pyx_tuple__31)) __PYX_ERR(0, 390, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__31);
  __Pyx_GIVEREF(__pyx_tuple__31);
 391:         else:
+392:             LPts.append(PtsM)
    /*else*/ {
      __pyx_t_34 = __Pyx_PyList_Append(__pyx_v_LPts, ((PyObject *)__pyx_v_PtsM)); if (unlikely(__pyx_t_34 == -1)) __PYX_ERR(0, 392, __pyx_L1_error)
    }
    __pyx_L23:;
+393:         Lind.append( indM + NR0*NZ0 )
    __pyx_t_15 = __Pyx_PyInt_From_int((__pyx_v_NR0 * __pyx_v_NZ0)); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 393, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_15);
    __pyx_t_12 = PyNumber_Add(((PyObject *)__pyx_v_indM), __pyx_t_15); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 393, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_12);
    __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
    __pyx_t_34 = __Pyx_PyList_Append(__pyx_v_Lind, __pyx_t_12); if (unlikely(__pyx_t_34 == -1)) __PYX_ERR(0, 393, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
+394:         LdS.append( dSM )
    __pyx_t_34 = __Pyx_PyList_Append(__pyx_v_LdS, ((PyObject *)__pyx_v_dSM)); if (unlikely(__pyx_t_34 == -1)) __PYX_ERR(0, 394, __pyx_L1_error)
 395: 
 396:     # Second face
+397:     if (DPhi is None or DPhi[1] is None) and Faces:
  __pyx_t_14 = (__pyx_v_DPhi == Py_None);
  __pyx_t_2 = (__pyx_t_14 != 0);
  if (!__pyx_t_2) {
  } else {
    goto __pyx_L26_next_and;
  }
  __pyx_t_12 = __Pyx_GetItemInt(__pyx_v_DPhi, 1, long, 1, __Pyx_PyInt_From_long, 0, 0, 0); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 397, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_12);
  __pyx_t_2 = (__pyx_t_12 == Py_None);
  __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
  __pyx_t_14 = (__pyx_t_2 != 0);
  if (__pyx_t_14) {
  } else {
    __pyx_t_3 = __pyx_t_14;
    goto __pyx_L25_bool_binop_done;
  }
  __pyx_L26_next_and:;
  __pyx_t_14 = (__pyx_v_Faces != 0);
  __pyx_t_3 = __pyx_t_14;
  __pyx_L25_bool_binop_done:;
  if (__pyx_t_3) {
/* … */
  }
+398:         if Out.lower()=='(x,y,z)':
    __pyx_t_15 = __Pyx_PyObject_GetAttrStr(__pyx_v_Out, __pyx_n_s_lower); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 398, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_15);
    __pyx_t_17 = NULL;
    if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_15))) {
      __pyx_t_17 = PyMethod_GET_SELF(__pyx_t_15);
      if (likely(__pyx_t_17)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_15);
        __Pyx_INCREF(__pyx_t_17);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_15, function);
      }
    }
    if (__pyx_t_17) {
      __pyx_t_12 = __Pyx_PyObject_CallOneArg(__pyx_t_15, __pyx_t_17); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 398, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;
    } else {
      __pyx_t_12 = __Pyx_PyObject_CallNoArg(__pyx_t_15); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 398, __pyx_L1_error)
    }
    __Pyx_GOTREF(__pyx_t_12);
    __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
    __pyx_t_3 = (__Pyx_PyUnicode_Equals(__pyx_t_12, __pyx_kp_u_x_y_z, Py_EQ)); if (unlikely(__pyx_t_3 < 0)) __PYX_ERR(0, 398, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
    if (__pyx_t_3) {
/* … */
      goto __pyx_L28;
    }
+399:             pts = np.array([ptsrz[0,:]*Ccos(PhiMinMax[1]-Dphi), ptsrz[0,:]*Csin(PhiMinMax[1]-Dphi), ptsrz[1,:]])
      __pyx_t_15 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 399, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_15);
      __pyx_t_17 = __Pyx_PyObject_GetAttrStr(__pyx_t_15, __pyx_n_s_array); if (unlikely(!__pyx_t_17)) __PYX_ERR(0, 399, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_17);
      __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
/* … */
  __pyx_slice__32 = PySlice_New(Py_None, Py_None, Py_None); if (unlikely(!__pyx_slice__32)) __PYX_ERR(0, 399, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_slice__32);
  __Pyx_GIVEREF(__pyx_slice__32);
      __pyx_t_15 = PyObject_GetItem(((PyObject *)__pyx_v_ptsrz), __pyx_tuple__33); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 399, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_15);
      __pyx_t_36 = 1;
      __pyx_t_33 = PyFloat_FromDouble(cos(((*((double *) ( /* dim=0 */ ((char *) (((double *) __pyx_v_PhiMinMax.data) + __pyx_t_36)) ))) - __pyx_v_Dphi))); if (unlikely(!__pyx_t_33)) __PYX_ERR(0, 399, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_33);
      __pyx_t_5 = PyNumber_Multiply(__pyx_t_15, __pyx_t_33); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 399, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
      __Pyx_DECREF(__pyx_t_33); __pyx_t_33 = 0;
  __pyx_tuple__33 = PyTuple_Pack(2, __pyx_int_0, __pyx_slice__32); if (unlikely(!__pyx_tuple__33)) __PYX_ERR(0, 399, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__33);
  __Pyx_GIVEREF(__pyx_tuple__33);
  __pyx_slice__34 = PySlice_New(Py_None, Py_None, Py_None); if (unlikely(!__pyx_slice__34)) __PYX_ERR(0, 399, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_slice__34);
  __Pyx_GIVEREF(__pyx_slice__34);
      __pyx_t_33 = PyObject_GetItem(((PyObject *)__pyx_v_ptsrz), __pyx_tuple__35); if (unlikely(!__pyx_t_33)) __PYX_ERR(0, 399, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_33);
      __pyx_t_37 = 1;
      __pyx_t_15 = PyFloat_FromDouble(sin(((*((double *) ( /* dim=0 */ ((char *) (((double *) __pyx_v_PhiMinMax.data) + __pyx_t_37)) ))) - __pyx_v_Dphi))); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 399, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_15);
      __pyx_t_9 = PyNumber_Multiply(__pyx_t_33, __pyx_t_15); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 399, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_9);
      __Pyx_DECREF(__pyx_t_33); __pyx_t_33 = 0;
      __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
  __pyx_tuple__35 = PyTuple_Pack(2, __pyx_int_0, __pyx_slice__34); if (unlikely(!__pyx_tuple__35)) __PYX_ERR(0, 399, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__35);
  __Pyx_GIVEREF(__pyx_tuple__35);
  __pyx_slice__36 = PySlice_New(Py_None, Py_None, Py_None); if (unlikely(!__pyx_slice__36)) __PYX_ERR(0, 399, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_slice__36);
  __Pyx_GIVEREF(__pyx_slice__36);
      __pyx_t_15 = PyObject_GetItem(((PyObject *)__pyx_v_ptsrz), __pyx_tuple__37); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 399, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_15);
      __pyx_t_33 = PyList_New(3); if (unlikely(!__pyx_t_33)) __PYX_ERR(0, 399, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_33);
      __Pyx_GIVEREF(__pyx_t_5);
      PyList_SET_ITEM(__pyx_t_33, 0, __pyx_t_5);
      __Pyx_GIVEREF(__pyx_t_9);
      PyList_SET_ITEM(__pyx_t_33, 1, __pyx_t_9);
      __Pyx_GIVEREF(__pyx_t_15);
      PyList_SET_ITEM(__pyx_t_33, 2, __pyx_t_15);
      __pyx_t_5 = 0;
      __pyx_t_9 = 0;
      __pyx_t_15 = 0;
      __pyx_t_15 = NULL;
      if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_17))) {
        __pyx_t_15 = PyMethod_GET_SELF(__pyx_t_17);
        if (likely(__pyx_t_15)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_17);
          __Pyx_INCREF(__pyx_t_15);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_17, function);
        }
      }
      if (!__pyx_t_15) {
        __pyx_t_12 = __Pyx_PyObject_CallOneArg(__pyx_t_17, __pyx_t_33); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 399, __pyx_L1_error)
        __Pyx_DECREF(__pyx_t_33); __pyx_t_33 = 0;
        __Pyx_GOTREF(__pyx_t_12);
      } else {
        #if CYTHON_FAST_PYCALL
        if (PyFunction_Check(__pyx_t_17)) {
          PyObject *__pyx_temp[2] = {__pyx_t_15, __pyx_t_33};
          __pyx_t_12 = __Pyx_PyFunction_FastCall(__pyx_t_17, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 399, __pyx_L1_error)
          __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0;
          __Pyx_GOTREF(__pyx_t_12);
          __Pyx_DECREF(__pyx_t_33); __pyx_t_33 = 0;
        } else
        #endif
        #if CYTHON_FAST_PYCCALL
        if (__Pyx_PyFastCFunction_Check(__pyx_t_17)) {
          PyObject *__pyx_temp[2] = {__pyx_t_15, __pyx_t_33};
          __pyx_t_12 = __Pyx_PyCFunction_FastCall(__pyx_t_17, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 399, __pyx_L1_error)
          __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0;
          __Pyx_GOTREF(__pyx_t_12);
          __Pyx_DECREF(__pyx_t_33); __pyx_t_33 = 0;
        } else
        #endif
        {
          __pyx_t_9 = PyTuple_New(1+1); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 399, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_9);
          __Pyx_GIVEREF(__pyx_t_15); PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_t_15); __pyx_t_15 = NULL;
          __Pyx_GIVEREF(__pyx_t_33);
          PyTuple_SET_ITEM(__pyx_t_9, 0+1, __pyx_t_33);
          __pyx_t_33 = 0;
          __pyx_t_12 = __Pyx_PyObject_Call(__pyx_t_17, __pyx_t_9, NULL); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 399, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_12);
          __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
        }
      }
      __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;
      if (!(likely(((__pyx_t_12) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_12, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 399, __pyx_L1_error)
      __pyx_t_28 = ((PyArrayObject *)__pyx_t_12);
      {
        __Pyx_BufFmt_StackElem __pyx_stack[1];
        __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_pts.rcbuffer->pybuffer);
        __pyx_t_19 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_pts.rcbuffer->pybuffer, (PyObject*)__pyx_t_28, &__Pyx_TypeInfo_double, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack);
        if (unlikely(__pyx_t_19 < 0)) {
          PyErr_Fetch(&__pyx_t_24, &__pyx_t_23, &__pyx_t_22);
          if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_pts.rcbuffer->pybuffer, (PyObject*)__pyx_v_pts, &__Pyx_TypeInfo_double, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) {
            Py_XDECREF(__pyx_t_24); Py_XDECREF(__pyx_t_23); Py_XDECREF(__pyx_t_22);
            __Pyx_RaiseBufferFallbackError();
          } else {
            PyErr_Restore(__pyx_t_24, __pyx_t_23, __pyx_t_22);
          }
        }
        __pyx_pybuffernd_pts.diminfo[0].strides = __pyx_pybuffernd_pts.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_pts.diminfo[0].shape = __pyx_pybuffernd_pts.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_pts.diminfo[1].strides = __pyx_pybuffernd_pts.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_pts.diminfo[1].shape = __pyx_pybuffernd_pts.rcbuffer->pybuffer.shape[1];
        if (unlikely(__pyx_t_19 < 0)) __PYX_ERR(0, 399, __pyx_L1_error)
      }
      __pyx_t_28 = 0;
      __Pyx_XDECREF_SET(__pyx_v_pts, ((PyArrayObject *)__pyx_t_12));
      __pyx_t_12 = 0;
  __pyx_tuple__37 = PyTuple_Pack(2, __pyx_int_1, __pyx_slice__36); if (unlikely(!__pyx_tuple__37)) __PYX_ERR(0, 399, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__37);
  __Pyx_GIVEREF(__pyx_tuple__37);
 400:         else:
+401:             pts = np.array([ptsrz[0,:],ptsrz[1,:],(PhiMinMax[1]-Dphi)*np.ones((indin.sum(),))])
    /*else*/ {
      __pyx_t_17 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_17)) __PYX_ERR(0, 401, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_17);
      __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_t_17, __pyx_n_s_array); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 401, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_9);
      __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;
/* … */
  __pyx_slice__38 = PySlice_New(Py_None, Py_None, Py_None); if (unlikely(!__pyx_slice__38)) __PYX_ERR(0, 401, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_slice__38);
  __Pyx_GIVEREF(__pyx_slice__38);
      __pyx_t_17 = PyObject_GetItem(((PyObject *)__pyx_v_ptsrz), __pyx_tuple__39); if (unlikely(!__pyx_t_17)) __PYX_ERR(0, 401, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_17);
  __pyx_tuple__39 = PyTuple_Pack(2, __pyx_int_0, __pyx_slice__38); if (unlikely(!__pyx_tuple__39)) __PYX_ERR(0, 401, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__39);
  __Pyx_GIVEREF(__pyx_tuple__39);
  __pyx_slice__40 = PySlice_New(Py_None, Py_None, Py_None); if (unlikely(!__pyx_slice__40)) __PYX_ERR(0, 401, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_slice__40);
  __Pyx_GIVEREF(__pyx_slice__40);
      __pyx_t_33 = PyObject_GetItem(((PyObject *)__pyx_v_ptsrz), __pyx_tuple__41); if (unlikely(!__pyx_t_33)) __PYX_ERR(0, 401, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_33);
      __pyx_t_38 = 1;
      __pyx_t_15 = PyFloat_FromDouble(((*((double *) ( /* dim=0 */ ((char *) (((double *) __pyx_v_PhiMinMax.data) + __pyx_t_38)) ))) - __pyx_v_Dphi)); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 401, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_15);
      __pyx_t_6 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 401, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_6);
      __pyx_t_16 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_n_s_ones); if (unlikely(!__pyx_t_16)) __PYX_ERR(0, 401, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_16);
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      if (unlikely(!__pyx_v_indin)) { __Pyx_RaiseUnboundLocalError("indin"); __PYX_ERR(0, 401, __pyx_L1_error) }
      __pyx_t_11 = __Pyx_PyObject_GetAttrStr(__pyx_v_indin, __pyx_n_s_sum); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 401, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_11);
      __pyx_t_1 = NULL;
      if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_11))) {
        __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_11);
        if (likely(__pyx_t_1)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_11);
          __Pyx_INCREF(__pyx_t_1);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_11, function);
        }
      }
      if (__pyx_t_1) {
        __pyx_t_6 = __Pyx_PyObject_CallOneArg(__pyx_t_11, __pyx_t_1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 401, __pyx_L1_error)
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      } else {
        __pyx_t_6 = __Pyx_PyObject_CallNoArg(__pyx_t_11); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 401, __pyx_L1_error)
      }
      __Pyx_GOTREF(__pyx_t_6);
      __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
      __pyx_t_11 = PyTuple_New(1); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 401, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_11);
      __Pyx_GIVEREF(__pyx_t_6);
      PyTuple_SET_ITEM(__pyx_t_11, 0, __pyx_t_6);
      __pyx_t_6 = 0;
      __pyx_t_6 = NULL;
      if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_16))) {
        __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_16);
        if (likely(__pyx_t_6)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_16);
          __Pyx_INCREF(__pyx_t_6);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_16, function);
        }
      }
      if (!__pyx_t_6) {
        __pyx_t_5 = __Pyx_PyObject_CallOneArg(__pyx_t_16, __pyx_t_11); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 401, __pyx_L1_error)
        __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
        __Pyx_GOTREF(__pyx_t_5);
      } else {
        #if CYTHON_FAST_PYCALL
        if (PyFunction_Check(__pyx_t_16)) {
          PyObject *__pyx_temp[2] = {__pyx_t_6, __pyx_t_11};
          __pyx_t_5 = __Pyx_PyFunction_FastCall(__pyx_t_16, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 401, __pyx_L1_error)
          __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
          __Pyx_GOTREF(__pyx_t_5);
          __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
        } else
        #endif
        #if CYTHON_FAST_PYCCALL
        if (__Pyx_PyFastCFunction_Check(__pyx_t_16)) {
          PyObject *__pyx_temp[2] = {__pyx_t_6, __pyx_t_11};
          __pyx_t_5 = __Pyx_PyCFunction_FastCall(__pyx_t_16, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 401, __pyx_L1_error)
          __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
          __Pyx_GOTREF(__pyx_t_5);
          __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
        } else
        #endif
        {
          __pyx_t_1 = PyTuple_New(1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 401, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_1);
          __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_6); __pyx_t_6 = NULL;
          __Pyx_GIVEREF(__pyx_t_11);
          PyTuple_SET_ITEM(__pyx_t_1, 0+1, __pyx_t_11);
          __pyx_t_11 = 0;
          __pyx_t_5 = __Pyx_PyObject_Call(__pyx_t_16, __pyx_t_1, NULL); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 401, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_5);
          __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        }
      }
      __Pyx_DECREF(__pyx_t_16); __pyx_t_16 = 0;
      __pyx_t_16 = PyNumber_Multiply(__pyx_t_15, __pyx_t_5); if (unlikely(!__pyx_t_16)) __PYX_ERR(0, 401, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_16);
      __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __pyx_t_5 = PyList_New(3); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 401, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_GIVEREF(__pyx_t_17);
      PyList_SET_ITEM(__pyx_t_5, 0, __pyx_t_17);
      __Pyx_GIVEREF(__pyx_t_33);
      PyList_SET_ITEM(__pyx_t_5, 1, __pyx_t_33);
      __Pyx_GIVEREF(__pyx_t_16);
      PyList_SET_ITEM(__pyx_t_5, 2, __pyx_t_16);
      __pyx_t_17 = 0;
      __pyx_t_33 = 0;
      __pyx_t_16 = 0;
      __pyx_t_16 = NULL;
      if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_9))) {
        __pyx_t_16 = PyMethod_GET_SELF(__pyx_t_9);
        if (likely(__pyx_t_16)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_9);
          __Pyx_INCREF(__pyx_t_16);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_9, function);
        }
      }
      if (!__pyx_t_16) {
        __pyx_t_12 = __Pyx_PyObject_CallOneArg(__pyx_t_9, __pyx_t_5); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 401, __pyx_L1_error)
        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
        __Pyx_GOTREF(__pyx_t_12);
      } else {
        #if CYTHON_FAST_PYCALL
        if (PyFunction_Check(__pyx_t_9)) {
          PyObject *__pyx_temp[2] = {__pyx_t_16, __pyx_t_5};
          __pyx_t_12 = __Pyx_PyFunction_FastCall(__pyx_t_9, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 401, __pyx_L1_error)
          __Pyx_XDECREF(__pyx_t_16); __pyx_t_16 = 0;
          __Pyx_GOTREF(__pyx_t_12);
          __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
        } else
        #endif
        #if CYTHON_FAST_PYCCALL
        if (__Pyx_PyFastCFunction_Check(__pyx_t_9)) {
          PyObject *__pyx_temp[2] = {__pyx_t_16, __pyx_t_5};
          __pyx_t_12 = __Pyx_PyCFunction_FastCall(__pyx_t_9, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 401, __pyx_L1_error)
          __Pyx_XDECREF(__pyx_t_16); __pyx_t_16 = 0;
          __Pyx_GOTREF(__pyx_t_12);
          __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
        } else
        #endif
        {
          __pyx_t_33 = PyTuple_New(1+1); if (unlikely(!__pyx_t_33)) __PYX_ERR(0, 401, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_33);
          __Pyx_GIVEREF(__pyx_t_16); PyTuple_SET_ITEM(__pyx_t_33, 0, __pyx_t_16); __pyx_t_16 = NULL;
          __Pyx_GIVEREF(__pyx_t_5);
          PyTuple_SET_ITEM(__pyx_t_33, 0+1, __pyx_t_5);
          __pyx_t_5 = 0;
          __pyx_t_12 = __Pyx_PyObject_Call(__pyx_t_9, __pyx_t_33, NULL); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 401, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_12);
          __Pyx_DECREF(__pyx_t_33); __pyx_t_33 = 0;
        }
      }
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
      if (!(likely(((__pyx_t_12) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_12, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 401, __pyx_L1_error)
      __pyx_t_28 = ((PyArrayObject *)__pyx_t_12);
      {
        __Pyx_BufFmt_StackElem __pyx_stack[1];
        __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_pts.rcbuffer->pybuffer);
        __pyx_t_19 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_pts.rcbuffer->pybuffer, (PyObject*)__pyx_t_28, &__Pyx_TypeInfo_double, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack);
        if (unlikely(__pyx_t_19 < 0)) {
          PyErr_Fetch(&__pyx_t_22, &__pyx_t_23, &__pyx_t_24);
          if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_pts.rcbuffer->pybuffer, (PyObject*)__pyx_v_pts, &__Pyx_TypeInfo_double, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) {
            Py_XDECREF(__pyx_t_22); Py_XDECREF(__pyx_t_23); Py_XDECREF(__pyx_t_24);
            __Pyx_RaiseBufferFallbackError();
          } else {
            PyErr_Restore(__pyx_t_22, __pyx_t_23, __pyx_t_24);
          }
        }
        __pyx_pybuffernd_pts.diminfo[0].strides = __pyx_pybuffernd_pts.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_pts.diminfo[0].shape = __pyx_pybuffernd_pts.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_pts.diminfo[1].strides = __pyx_pybuffernd_pts.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_pts.diminfo[1].shape = __pyx_pybuffernd_pts.rcbuffer->pybuffer.shape[1];
        if (unlikely(__pyx_t_19 < 0)) __PYX_ERR(0, 401, __pyx_L1_error)
      }
      __pyx_t_28 = 0;
      __Pyx_XDECREF_SET(__pyx_v_pts, ((PyArrayObject *)__pyx_t_12));
      __pyx_t_12 = 0;
    }
    __pyx_L28:;
  __pyx_tuple__41 = PyTuple_Pack(2, __pyx_int_1, __pyx_slice__40); if (unlikely(!__pyx_tuple__41)) __PYX_ERR(0, 401, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__41);
  __Pyx_GIVEREF(__pyx_tuple__41);
+402:         LPts.append( pts )
    __pyx_t_34 = __Pyx_PyList_Append(__pyx_v_LPts, ((PyObject *)__pyx_v_pts)); if (unlikely(__pyx_t_34 == -1)) __PYX_ERR(0, 402, __pyx_L1_error)
+403:         Lind.append( iindF + NR0*NZ0 + nRPhi0 )
    __pyx_t_12 = __Pyx_PyInt_From_int((__pyx_v_NR0 * __pyx_v_NZ0)); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 403, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_12);
    __pyx_t_9 = PyNumber_Add(((PyObject *)__pyx_v_iindF), __pyx_t_12); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 403, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_9);
    __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
    __pyx_t_12 = PyNumber_Add(__pyx_t_9, __pyx_v_nRPhi0); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 403, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_12);
    __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
    __pyx_t_34 = __Pyx_PyList_Append(__pyx_v_Lind, __pyx_t_12); if (unlikely(__pyx_t_34 == -1)) __PYX_ERR(0, 403, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
+404:         LdS.append( dsF )
    __pyx_t_34 = __Pyx_PyList_Append(__pyx_v_LdS, ((PyObject *)__pyx_v_dsF)); if (unlikely(__pyx_t_34 == -1)) __PYX_ERR(0, 404, __pyx_L1_error)
 405: 
 406:     # Aggregate
+407:     if len(LPts)==1:
  __pyx_t_27 = PyList_GET_SIZE(__pyx_v_LPts); if (unlikely(__pyx_t_27 == -1)) __PYX_ERR(0, 407, __pyx_L1_error)
  __pyx_t_3 = ((__pyx_t_27 == 1) != 0);
  if (__pyx_t_3) {
/* … */
    goto __pyx_L29;
  }
+408:         Pts = LPts[0]
    if (!(likely(((PyList_GET_ITEM(__pyx_v_LPts, 0)) == Py_None) || likely(__Pyx_TypeTest(PyList_GET_ITEM(__pyx_v_LPts, 0), __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 408, __pyx_L1_error)
    __pyx_t_12 = PyList_GET_ITEM(__pyx_v_LPts, 0);
    __Pyx_INCREF(__pyx_t_12);
    {
      __Pyx_BufFmt_StackElem __pyx_stack[1];
      __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_Pts.rcbuffer->pybuffer);
      __pyx_t_19 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_Pts.rcbuffer->pybuffer, (PyObject*)((PyArrayObject *)__pyx_t_12), &__Pyx_TypeInfo_double, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack);
      if (unlikely(__pyx_t_19 < 0)) {
        PyErr_Fetch(&__pyx_t_24, &__pyx_t_23, &__pyx_t_22);
        if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_Pts.rcbuffer->pybuffer, (PyObject*)__pyx_v_Pts, &__Pyx_TypeInfo_double, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) {
          Py_XDECREF(__pyx_t_24); Py_XDECREF(__pyx_t_23); Py_XDECREF(__pyx_t_22);
          __Pyx_RaiseBufferFallbackError();
        } else {
          PyErr_Restore(__pyx_t_24, __pyx_t_23, __pyx_t_22);
        }
      }
      __pyx_pybuffernd_Pts.diminfo[0].strides = __pyx_pybuffernd_Pts.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_Pts.diminfo[0].shape = __pyx_pybuffernd_Pts.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_Pts.diminfo[1].strides = __pyx_pybuffernd_Pts.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_Pts.diminfo[1].shape = __pyx_pybuffernd_Pts.rcbuffer->pybuffer.shape[1];
      if (unlikely(__pyx_t_19 < 0)) __PYX_ERR(0, 408, __pyx_L1_error)
    }
    __pyx_v_Pts = ((PyArrayObject *)__pyx_t_12);
    __pyx_t_12 = 0;
+409:         ind = Lind[0]
    if (!(likely(((PyList_GET_ITEM(__pyx_v_Lind, 0)) == Py_None) || likely(__Pyx_TypeTest(PyList_GET_ITEM(__pyx_v_Lind, 0), __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 409, __pyx_L1_error)
    __pyx_t_12 = PyList_GET_ITEM(__pyx_v_Lind, 0);
    __Pyx_INCREF(__pyx_t_12);
    {
      __Pyx_BufFmt_StackElem __pyx_stack[1];
      __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_ind.rcbuffer->pybuffer);
      __pyx_t_19 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_ind.rcbuffer->pybuffer, (PyObject*)((PyArrayObject *)__pyx_t_12), &__Pyx_TypeInfo_long, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack);
      if (unlikely(__pyx_t_19 < 0)) {
        PyErr_Fetch(&__pyx_t_22, &__pyx_t_23, &__pyx_t_24);
        if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_ind.rcbuffer->pybuffer, (PyObject*)__pyx_v_ind, &__Pyx_TypeInfo_long, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {
          Py_XDECREF(__pyx_t_22); Py_XDECREF(__pyx_t_23); Py_XDECREF(__pyx_t_24);
          __Pyx_RaiseBufferFallbackError();
        } else {
          PyErr_Restore(__pyx_t_22, __pyx_t_23, __pyx_t_24);
        }
      }
      __pyx_pybuffernd_ind.diminfo[0].strides = __pyx_pybuffernd_ind.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_ind.diminfo[0].shape = __pyx_pybuffernd_ind.rcbuffer->pybuffer.shape[0];
      if (unlikely(__pyx_t_19 < 0)) __PYX_ERR(0, 409, __pyx_L1_error)
    }
    __pyx_v_ind = ((PyArrayObject *)__pyx_t_12);
    __pyx_t_12 = 0;
+410:         dS = LdS[0]
    if (!(likely(((PyList_GET_ITEM(__pyx_v_LdS, 0)) == Py_None) || likely(__Pyx_TypeTest(PyList_GET_ITEM(__pyx_v_LdS, 0), __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 410, __pyx_L1_error)
    __pyx_t_12 = PyList_GET_ITEM(__pyx_v_LdS, 0);
    __Pyx_INCREF(__pyx_t_12);
    {
      __Pyx_BufFmt_StackElem __pyx_stack[1];
      __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_dS.rcbuffer->pybuffer);
      __pyx_t_19 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_dS.rcbuffer->pybuffer, (PyObject*)((PyArrayObject *)__pyx_t_12), &__Pyx_TypeInfo_double, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack);
      if (unlikely(__pyx_t_19 < 0)) {
        PyErr_Fetch(&__pyx_t_24, &__pyx_t_23, &__pyx_t_22);
        if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_dS.rcbuffer->pybuffer, (PyObject*)__pyx_v_dS, &__Pyx_TypeInfo_double, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {
          Py_XDECREF(__pyx_t_24); Py_XDECREF(__pyx_t_23); Py_XDECREF(__pyx_t_22);
          __Pyx_RaiseBufferFallbackError();
        } else {
          PyErr_Restore(__pyx_t_24, __pyx_t_23, __pyx_t_22);
        }
      }
      __pyx_pybuffernd_dS.diminfo[0].strides = __pyx_pybuffernd_dS.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_dS.diminfo[0].shape = __pyx_pybuffernd_dS.rcbuffer->pybuffer.shape[0];
      if (unlikely(__pyx_t_19 < 0)) __PYX_ERR(0, 410, __pyx_L1_error)
    }
    __pyx_v_dS = ((PyArrayObject *)__pyx_t_12);
    __pyx_t_12 = 0;
 411:     else:
+412:         Pts = np.concatenate(tuple(LPts),axis=1)
  /*else*/ {
    __pyx_t_12 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 412, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_12);
    __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_t_12, __pyx_n_s_concatenate); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 412, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_9);
    __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
    __pyx_t_12 = PyList_AsTuple(__pyx_v_LPts); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 412, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_12);
    __pyx_t_33 = PyTuple_New(1); if (unlikely(!__pyx_t_33)) __PYX_ERR(0, 412, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_33);
    __Pyx_GIVEREF(__pyx_t_12);
    PyTuple_SET_ITEM(__pyx_t_33, 0, __pyx_t_12);
    __pyx_t_12 = 0;
    __pyx_t_12 = PyDict_New(); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 412, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_12);
    if (PyDict_SetItem(__pyx_t_12, __pyx_n_s_axis, __pyx_int_1) < 0) __PYX_ERR(0, 412, __pyx_L1_error)
    __pyx_t_5 = __Pyx_PyObject_Call(__pyx_t_9, __pyx_t_33, __pyx_t_12); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 412, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
    __Pyx_DECREF(__pyx_t_33); __pyx_t_33 = 0;
    __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
    if (!(likely(((__pyx_t_5) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_5, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 412, __pyx_L1_error)
    __pyx_t_28 = ((PyArrayObject *)__pyx_t_5);
    {
      __Pyx_BufFmt_StackElem __pyx_stack[1];
      __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_Pts.rcbuffer->pybuffer);
      __pyx_t_19 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_Pts.rcbuffer->pybuffer, (PyObject*)__pyx_t_28, &__Pyx_TypeInfo_double, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack);
      if (unlikely(__pyx_t_19 < 0)) {
        PyErr_Fetch(&__pyx_t_22, &__pyx_t_23, &__pyx_t_24);
        if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_Pts.rcbuffer->pybuffer, (PyObject*)__pyx_v_Pts, &__Pyx_TypeInfo_double, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) {
          Py_XDECREF(__pyx_t_22); Py_XDECREF(__pyx_t_23); Py_XDECREF(__pyx_t_24);
          __Pyx_RaiseBufferFallbackError();
        } else {
          PyErr_Restore(__pyx_t_22, __pyx_t_23, __pyx_t_24);
        }
      }
      __pyx_pybuffernd_Pts.diminfo[0].strides = __pyx_pybuffernd_Pts.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_Pts.diminfo[0].shape = __pyx_pybuffernd_Pts.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_Pts.diminfo[1].strides = __pyx_pybuffernd_Pts.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_Pts.diminfo[1].shape = __pyx_pybuffernd_Pts.rcbuffer->pybuffer.shape[1];
      if (unlikely(__pyx_t_19 < 0)) __PYX_ERR(0, 412, __pyx_L1_error)
    }
    __pyx_t_28 = 0;
    __pyx_v_Pts = ((PyArrayObject *)__pyx_t_5);
    __pyx_t_5 = 0;
+413:         ind = np.concatenate(tuple(Lind)).astype(int)
    __pyx_t_33 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_33)) __PYX_ERR(0, 413, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_33);
    __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_t_33, __pyx_n_s_concatenate); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 413, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_9);
    __Pyx_DECREF(__pyx_t_33); __pyx_t_33 = 0;
    __pyx_t_33 = PyList_AsTuple(__pyx_v_Lind); if (unlikely(!__pyx_t_33)) __PYX_ERR(0, 413, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_33);
    __pyx_t_16 = NULL;
    if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_9))) {
      __pyx_t_16 = PyMethod_GET_SELF(__pyx_t_9);
      if (likely(__pyx_t_16)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_9);
        __Pyx_INCREF(__pyx_t_16);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_9, function);
      }
    }
    if (!__pyx_t_16) {
      __pyx_t_12 = __Pyx_PyObject_CallOneArg(__pyx_t_9, __pyx_t_33); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 413, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_33); __pyx_t_33 = 0;
      __Pyx_GOTREF(__pyx_t_12);
    } else {
      #if CYTHON_FAST_PYCALL
      if (PyFunction_Check(__pyx_t_9)) {
        PyObject *__pyx_temp[2] = {__pyx_t_16, __pyx_t_33};
        __pyx_t_12 = __Pyx_PyFunction_FastCall(__pyx_t_9, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 413, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_16); __pyx_t_16 = 0;
        __Pyx_GOTREF(__pyx_t_12);
        __Pyx_DECREF(__pyx_t_33); __pyx_t_33 = 0;
      } else
      #endif
      #if CYTHON_FAST_PYCCALL
      if (__Pyx_PyFastCFunction_Check(__pyx_t_9)) {
        PyObject *__pyx_temp[2] = {__pyx_t_16, __pyx_t_33};
        __pyx_t_12 = __Pyx_PyCFunction_FastCall(__pyx_t_9, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 413, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_16); __pyx_t_16 = 0;
        __Pyx_GOTREF(__pyx_t_12);
        __Pyx_DECREF(__pyx_t_33); __pyx_t_33 = 0;
      } else
      #endif
      {
        __pyx_t_17 = PyTuple_New(1+1); if (unlikely(!__pyx_t_17)) __PYX_ERR(0, 413, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_17);
        __Pyx_GIVEREF(__pyx_t_16); PyTuple_SET_ITEM(__pyx_t_17, 0, __pyx_t_16); __pyx_t_16 = NULL;
        __Pyx_GIVEREF(__pyx_t_33);
        PyTuple_SET_ITEM(__pyx_t_17, 0+1, __pyx_t_33);
        __pyx_t_33 = 0;
        __pyx_t_12 = __Pyx_PyObject_Call(__pyx_t_9, __pyx_t_17, NULL); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 413, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_12);
        __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;
      }
    }
    __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
    __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_t_12, __pyx_n_s_astype); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 413, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_9);
    __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
    __pyx_t_12 = NULL;
    if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_9))) {
      __pyx_t_12 = PyMethod_GET_SELF(__pyx_t_9);
      if (likely(__pyx_t_12)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_9);
        __Pyx_INCREF(__pyx_t_12);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_9, function);
      }
    }
    if (!__pyx_t_12) {
      __pyx_t_5 = __Pyx_PyObject_CallOneArg(__pyx_t_9, ((PyObject *)(&PyInt_Type))); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 413, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
    } else {
      #if CYTHON_FAST_PYCALL
      if (PyFunction_Check(__pyx_t_9)) {
        PyObject *__pyx_temp[2] = {__pyx_t_12, ((PyObject *)(&PyInt_Type))};
        __pyx_t_5 = __Pyx_PyFunction_FastCall(__pyx_t_9, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 413, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0;
        __Pyx_GOTREF(__pyx_t_5);
      } else
      #endif
      #if CYTHON_FAST_PYCCALL
      if (__Pyx_PyFastCFunction_Check(__pyx_t_9)) {
        PyObject *__pyx_temp[2] = {__pyx_t_12, ((PyObject *)(&PyInt_Type))};
        __pyx_t_5 = __Pyx_PyCFunction_FastCall(__pyx_t_9, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 413, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0;
        __Pyx_GOTREF(__pyx_t_5);
      } else
      #endif
      {
        __pyx_t_17 = PyTuple_New(1+1); if (unlikely(!__pyx_t_17)) __PYX_ERR(0, 413, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_17);
        __Pyx_GIVEREF(__pyx_t_12); PyTuple_SET_ITEM(__pyx_t_17, 0, __pyx_t_12); __pyx_t_12 = NULL;
        __Pyx_INCREF(((PyObject *)(&PyInt_Type)));
        __Pyx_GIVEREF(((PyObject *)(&PyInt_Type)));
        PyTuple_SET_ITEM(__pyx_t_17, 0+1, ((PyObject *)(&PyInt_Type)));
        __pyx_t_5 = __Pyx_PyObject_Call(__pyx_t_9, __pyx_t_17, NULL); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 413, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_5);
        __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;
      }
    }
    __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
    if (!(likely(((__pyx_t_5) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_5, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 413, __pyx_L1_error)
    __pyx_t_25 = ((PyArrayObject *)__pyx_t_5);
    {
      __Pyx_BufFmt_StackElem __pyx_stack[1];
      __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_ind.rcbuffer->pybuffer);
      __pyx_t_19 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_ind.rcbuffer->pybuffer, (PyObject*)__pyx_t_25, &__Pyx_TypeInfo_long, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack);
      if (unlikely(__pyx_t_19 < 0)) {
        PyErr_Fetch(&__pyx_t_24, &__pyx_t_23, &__pyx_t_22);
        if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_ind.rcbuffer->pybuffer, (PyObject*)__pyx_v_ind, &__Pyx_TypeInfo_long, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {
          Py_XDECREF(__pyx_t_24); Py_XDECREF(__pyx_t_23); Py_XDECREF(__pyx_t_22);
          __Pyx_RaiseBufferFallbackError();
        } else {
          PyErr_Restore(__pyx_t_24, __pyx_t_23, __pyx_t_22);
        }
      }
      __pyx_pybuffernd_ind.diminfo[0].strides = __pyx_pybuffernd_ind.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_ind.diminfo[0].shape = __pyx_pybuffernd_ind.rcbuffer->pybuffer.shape[0];
      if (unlikely(__pyx_t_19 < 0)) __PYX_ERR(0, 413, __pyx_L1_error)
    }
    __pyx_t_25 = 0;
    __pyx_v_ind = ((PyArrayObject *)__pyx_t_5);
    __pyx_t_5 = 0;
+414:         dS = np.concatenate(tuple(LdS))
    __pyx_t_9 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 414, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_9);
    __pyx_t_17 = __Pyx_PyObject_GetAttrStr(__pyx_t_9, __pyx_n_s_concatenate); if (unlikely(!__pyx_t_17)) __PYX_ERR(0, 414, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_17);
    __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
    __pyx_t_9 = PyList_AsTuple(__pyx_v_LdS); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 414, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_9);
    __pyx_t_12 = NULL;
    if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_17))) {
      __pyx_t_12 = PyMethod_GET_SELF(__pyx_t_17);
      if (likely(__pyx_t_12)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_17);
        __Pyx_INCREF(__pyx_t_12);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_17, function);
      }
    }
    if (!__pyx_t_12) {
      __pyx_t_5 = __Pyx_PyObject_CallOneArg(__pyx_t_17, __pyx_t_9); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 414, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
      __Pyx_GOTREF(__pyx_t_5);
    } else {
      #if CYTHON_FAST_PYCALL
      if (PyFunction_Check(__pyx_t_17)) {
        PyObject *__pyx_temp[2] = {__pyx_t_12, __pyx_t_9};
        __pyx_t_5 = __Pyx_PyFunction_FastCall(__pyx_t_17, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 414, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0;
        __Pyx_GOTREF(__pyx_t_5);
        __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
      } else
      #endif
      #if CYTHON_FAST_PYCCALL
      if (__Pyx_PyFastCFunction_Check(__pyx_t_17)) {
        PyObject *__pyx_temp[2] = {__pyx_t_12, __pyx_t_9};
        __pyx_t_5 = __Pyx_PyCFunction_FastCall(__pyx_t_17, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 414, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0;
        __Pyx_GOTREF(__pyx_t_5);
        __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
      } else
      #endif
      {
        __pyx_t_33 = PyTuple_New(1+1); if (unlikely(!__pyx_t_33)) __PYX_ERR(0, 414, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_33);
        __Pyx_GIVEREF(__pyx_t_12); PyTuple_SET_ITEM(__pyx_t_33, 0, __pyx_t_12); __pyx_t_12 = NULL;
        __Pyx_GIVEREF(__pyx_t_9);
        PyTuple_SET_ITEM(__pyx_t_33, 0+1, __pyx_t_9);
        __pyx_t_9 = 0;
        __pyx_t_5 = __Pyx_PyObject_Call(__pyx_t_17, __pyx_t_33, NULL); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 414, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_5);
        __Pyx_DECREF(__pyx_t_33); __pyx_t_33 = 0;
      }
    }
    __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;
    if (!(likely(((__pyx_t_5) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_5, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 414, __pyx_L1_error)
    __pyx_t_20 = ((PyArrayObject *)__pyx_t_5);
    {
      __Pyx_BufFmt_StackElem __pyx_stack[1];
      __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_dS.rcbuffer->pybuffer);
      __pyx_t_19 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_dS.rcbuffer->pybuffer, (PyObject*)__pyx_t_20, &__Pyx_TypeInfo_double, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack);
      if (unlikely(__pyx_t_19 < 0)) {
        PyErr_Fetch(&__pyx_t_22, &__pyx_t_23, &__pyx_t_24);
        if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_dS.rcbuffer->pybuffer, (PyObject*)__pyx_v_dS, &__Pyx_TypeInfo_double, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {
          Py_XDECREF(__pyx_t_22); Py_XDECREF(__pyx_t_23); Py_XDECREF(__pyx_t_24);
          __Pyx_RaiseBufferFallbackError();
        } else {
          PyErr_Restore(__pyx_t_22, __pyx_t_23, __pyx_t_24);
        }
      }
      __pyx_pybuffernd_dS.diminfo[0].strides = __pyx_pybuffernd_dS.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_dS.diminfo[0].shape = __pyx_pybuffernd_dS.rcbuffer->pybuffer.shape[0];
      if (unlikely(__pyx_t_19 < 0)) __PYX_ERR(0, 414, __pyx_L1_error)
    }
    __pyx_t_20 = 0;
    __pyx_v_dS = ((PyArrayObject *)__pyx_t_5);
    __pyx_t_5 = 0;
  }
  __pyx_L29:;
 415: 
+416:     return Pts, dS, ind, NL, dLr, Rref, dR0r, dZ0r, dRPhir, VPbis
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_5 = PyFloat_FromDouble(__pyx_v_dR0r); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 416, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_t_17 = PyFloat_FromDouble(__pyx_v_dZ0r); if (unlikely(!__pyx_t_17)) __PYX_ERR(0, 416, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_17);
  __pyx_t_33 = PyTuple_New(10); if (unlikely(!__pyx_t_33)) __PYX_ERR(0, 416, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_33);
  __Pyx_INCREF(((PyObject *)__pyx_v_Pts));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_Pts));
  PyTuple_SET_ITEM(__pyx_t_33, 0, ((PyObject *)__pyx_v_Pts));
  __Pyx_INCREF(((PyObject *)__pyx_v_dS));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_dS));
  PyTuple_SET_ITEM(__pyx_t_33, 1, ((PyObject *)__pyx_v_dS));
  __Pyx_INCREF(((PyObject *)__pyx_v_ind));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_ind));
  PyTuple_SET_ITEM(__pyx_t_33, 2, ((PyObject *)__pyx_v_ind));
  __Pyx_INCREF(((PyObject *)__pyx_v_NL));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_NL));
  PyTuple_SET_ITEM(__pyx_t_33, 3, ((PyObject *)__pyx_v_NL));
  __Pyx_INCREF(((PyObject *)__pyx_v_dLr));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_dLr));
  PyTuple_SET_ITEM(__pyx_t_33, 4, ((PyObject *)__pyx_v_dLr));
  __Pyx_INCREF(((PyObject *)__pyx_v_Rref));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_Rref));
  PyTuple_SET_ITEM(__pyx_t_33, 5, ((PyObject *)__pyx_v_Rref));
  __Pyx_GIVEREF(__pyx_t_5);
  PyTuple_SET_ITEM(__pyx_t_33, 6, __pyx_t_5);
  __Pyx_GIVEREF(__pyx_t_17);
  PyTuple_SET_ITEM(__pyx_t_33, 7, __pyx_t_17);
  __Pyx_INCREF(((PyObject *)__pyx_v_dRPhir));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_dRPhir));
  PyTuple_SET_ITEM(__pyx_t_33, 8, ((PyObject *)__pyx_v_dRPhir));
  __Pyx_INCREF(((PyObject *)__pyx_v_VPbis));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_VPbis));
  PyTuple_SET_ITEM(__pyx_t_33, 9, ((PyObject *)__pyx_v_VPbis));
  __pyx_t_5 = 0;
  __pyx_t_17 = 0;
  __pyx_r = __pyx_t_33;
  __pyx_t_33 = 0;
  goto __pyx_L0;
 417: 
 418: 
 419: @cython.cdivision(True)
 420: @cython.wraparound(False)
 421: @cython.boundscheck(False)
+422: def _Ves_Smesh_TorStruct_SubFromInd_cython(double[::1] PhiMinMax, double dL, double dRPhi,
/* Python wrapper */
static PyObject *__pyx_pw_46_cython_magic_8152fc40fb05daa7217c00b66474f995_11_Ves_Smesh_TorStruct_SubFromInd_cython(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_46_cython_magic_8152fc40fb05daa7217c00b66474f995_10_Ves_Smesh_TorStruct_SubFromInd_cython[] = " Return the desired surfacic submesh indicated by the limits (DR,DZ,DPhi), for the desired resolution (dR,dZ,dRphi) ";
static PyMethodDef __pyx_mdef_46_cython_magic_8152fc40fb05daa7217c00b66474f995_11_Ves_Smesh_TorStruct_SubFromInd_cython = {"_Ves_Smesh_TorStruct_SubFromInd_cython", (PyCFunction)__pyx_pw_46_cython_magic_8152fc40fb05daa7217c00b66474f995_11_Ves_Smesh_TorStruct_SubFromInd_cython, METH_VARARGS|METH_KEYWORDS, __pyx_doc_46_cython_magic_8152fc40fb05daa7217c00b66474f995_10_Ves_Smesh_TorStruct_SubFromInd_cython};
static PyObject *__pyx_pw_46_cython_magic_8152fc40fb05daa7217c00b66474f995_11_Ves_Smesh_TorStruct_SubFromInd_cython(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  __Pyx_memviewslice __pyx_v_PhiMinMax = { 0, 0, { 0 }, { 0 }, { 0 } };
  double __pyx_v_dL;
  double __pyx_v_dRPhi;
  __Pyx_memviewslice __pyx_v_VPoly = { 0, 0, { 0 }, { 0 }, { 0 } };
  PyArrayObject *__pyx_v_ind = 0;
  double __pyx_v_DIn;
  PyObject *__pyx_v_VIn = 0;
  PyObject *__pyx_v_Out = 0;
  double __pyx_v_margin;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("_Ves_Smesh_TorStruct_SubFromInd_cython (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_PhiMinMax,&__pyx_n_s_dL,&__pyx_n_s_dRPhi,&__pyx_n_s_VPoly,&__pyx_n_s_ind,&__pyx_n_s_DIn,&__pyx_n_s_VIn,&__pyx_n_s_Out,&__pyx_n_s_margin,0};
    PyObject* values[9] = {0,0,0,0,0,0,0,0,0};
/* … */
  /* function exit code */
  goto __pyx_L0;
  __pyx_L1_error:;
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_46_cython_magic_8152fc40fb05daa7217c00b66474f995_10_Ves_Smesh_TorStruct_SubFromInd_cython(CYTHON_UNUSED PyObject *__pyx_self, __Pyx_memviewslice __pyx_v_PhiMinMax, double __pyx_v_dL, double __pyx_v_dRPhi, __Pyx_memviewslice __pyx_v_VPoly, PyArrayObject *__pyx_v_ind, double __pyx_v_DIn, PyObject *__pyx_v_VIn, PyObject *__pyx_v_Out, double __pyx_v_margin) {
  double __pyx_v_Dphi;
  double __pyx_v_dR0r;
  double __pyx_v_dZ0r;
  int __pyx_v_NR0;
  int __pyx_v_NZ0;
  PyArrayObject *__pyx_v_R0 = 0;
  PyArrayObject *__pyx_v_Z0 = 0;
  PyArrayObject *__pyx_v_dSM = 0;
  PyArrayObject *__pyx_v_dLr = 0;
  PyArrayObject *__pyx_v_Rref = 0;
  PyArrayObject *__pyx_v_dRPhir = 0;
  PyArrayObject *__pyx_v_dS = 0;
  CYTHON_UNUSED PyArrayObject *__pyx_v_bla = 0;
  PyArrayObject *__pyx_v_indR0 = 0;
  PyArrayObject *__pyx_v_indZ0 = 0;
  CYTHON_UNUSED PyArrayObject *__pyx_v_indM = 0;
  PyArrayObject *__pyx_v_NL = 0;
  PyArrayObject *__pyx_v_pts = 0;
  PyArrayObject *__pyx_v_PtsM = 0;
  PyArrayObject *__pyx_v_VPbis = 0;
  PyArrayObject *__pyx_v_Pts = 0;
  PyObject *__pyx_v_LPts = 0;
  PyObject *__pyx_v_LdS = 0;
  CYTHON_UNUSED PyObject *__pyx_v_Lind = 0;
  CYTHON_UNUSED PyObject *__pyx_v_nRPhi0 = NULL;
  PyObject *__pyx_v_ii = NULL;
  Py_ssize_t __pyx_v_nii;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_NL;
  __Pyx_Buffer __pyx_pybuffer_NL;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_Pts;
  __Pyx_Buffer __pyx_pybuffer_Pts;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_PtsM;
  __Pyx_Buffer __pyx_pybuffer_PtsM;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_R0;
  __Pyx_Buffer __pyx_pybuffer_R0;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_Rref;
  __Pyx_Buffer __pyx_pybuffer_Rref;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_VPbis;
  __Pyx_Buffer __pyx_pybuffer_VPbis;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_Z0;
  __Pyx_Buffer __pyx_pybuffer_Z0;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_bla;
  __Pyx_Buffer __pyx_pybuffer_bla;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_dLr;
  __Pyx_Buffer __pyx_pybuffer_dLr;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_dRPhir;
  __Pyx_Buffer __pyx_pybuffer_dRPhir;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_dS;
  __Pyx_Buffer __pyx_pybuffer_dS;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_dSM;
  __Pyx_Buffer __pyx_pybuffer_dSM;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_ind;
  __Pyx_Buffer __pyx_pybuffer_ind;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_indM;
  __Pyx_Buffer __pyx_pybuffer_indM;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_indR0;
  __Pyx_Buffer __pyx_pybuffer_indR0;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_indZ0;
  __Pyx_Buffer __pyx_pybuffer_indZ0;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_pts;
  __Pyx_Buffer __pyx_pybuffer_pts;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("_Ves_Smesh_TorStruct_SubFromInd_cython", 0);
  __pyx_pybuffer_R0.pybuffer.buf = NULL;
  __pyx_pybuffer_R0.refcount = 0;
  __pyx_pybuffernd_R0.data = NULL;
  __pyx_pybuffernd_R0.rcbuffer = &__pyx_pybuffer_R0;
  __pyx_pybuffer_Z0.pybuffer.buf = NULL;
  __pyx_pybuffer_Z0.refcount = 0;
  __pyx_pybuffernd_Z0.data = NULL;
  __pyx_pybuffernd_Z0.rcbuffer = &__pyx_pybuffer_Z0;
  __pyx_pybuffer_dSM.pybuffer.buf = NULL;
  __pyx_pybuffer_dSM.refcount = 0;
  __pyx_pybuffernd_dSM.data = NULL;
  __pyx_pybuffernd_dSM.rcbuffer = &__pyx_pybuffer_dSM;
  __pyx_pybuffer_dLr.pybuffer.buf = NULL;
  __pyx_pybuffer_dLr.refcount = 0;
  __pyx_pybuffernd_dLr.data = NULL;
  __pyx_pybuffernd_dLr.rcbuffer = &__pyx_pybuffer_dLr;
  __pyx_pybuffer_Rref.pybuffer.buf = NULL;
  __pyx_pybuffer_Rref.refcount = 0;
  __pyx_pybuffernd_Rref.data = NULL;
  __pyx_pybuffernd_Rref.rcbuffer = &__pyx_pybuffer_Rref;
  __pyx_pybuffer_dRPhir.pybuffer.buf = NULL;
  __pyx_pybuffer_dRPhir.refcount = 0;
  __pyx_pybuffernd_dRPhir.data = NULL;
  __pyx_pybuffernd_dRPhir.rcbuffer = &__pyx_pybuffer_dRPhir;
  __pyx_pybuffer_dS.pybuffer.buf = NULL;
  __pyx_pybuffer_dS.refcount = 0;
  __pyx_pybuffernd_dS.data = NULL;
  __pyx_pybuffernd_dS.rcbuffer = &__pyx_pybuffer_dS;
  __pyx_pybuffer_bla.pybuffer.buf = NULL;
  __pyx_pybuffer_bla.refcount = 0;
  __pyx_pybuffernd_bla.data = NULL;
  __pyx_pybuffernd_bla.rcbuffer = &__pyx_pybuffer_bla;
  __pyx_pybuffer_indR0.pybuffer.buf = NULL;
  __pyx_pybuffer_indR0.refcount = 0;
  __pyx_pybuffernd_indR0.data = NULL;
  __pyx_pybuffernd_indR0.rcbuffer = &__pyx_pybuffer_indR0;
  __pyx_pybuffer_indZ0.pybuffer.buf = NULL;
  __pyx_pybuffer_indZ0.refcount = 0;
  __pyx_pybuffernd_indZ0.data = NULL;
  __pyx_pybuffernd_indZ0.rcbuffer = &__pyx_pybuffer_indZ0;
  __pyx_pybuffer_indM.pybuffer.buf = NULL;
  __pyx_pybuffer_indM.refcount = 0;
  __pyx_pybuffernd_indM.data = NULL;
  __pyx_pybuffernd_indM.rcbuffer = &__pyx_pybuffer_indM;
  __pyx_pybuffer_NL.pybuffer.buf = NULL;
  __pyx_pybuffer_NL.refcount = 0;
  __pyx_pybuffernd_NL.data = NULL;
  __pyx_pybuffernd_NL.rcbuffer = &__pyx_pybuffer_NL;
  __pyx_pybuffer_pts.pybuffer.buf = NULL;
  __pyx_pybuffer_pts.refcount = 0;
  __pyx_pybuffernd_pts.data = NULL;
  __pyx_pybuffernd_pts.rcbuffer = &__pyx_pybuffer_pts;
  __pyx_pybuffer_PtsM.pybuffer.buf = NULL;
  __pyx_pybuffer_PtsM.refcount = 0;
  __pyx_pybuffernd_PtsM.data = NULL;
  __pyx_pybuffernd_PtsM.rcbuffer = &__pyx_pybuffer_PtsM;
  __pyx_pybuffer_VPbis.pybuffer.buf = NULL;
  __pyx_pybuffer_VPbis.refcount = 0;
  __pyx_pybuffernd_VPbis.data = NULL;
  __pyx_pybuffernd_VPbis.rcbuffer = &__pyx_pybuffer_VPbis;
  __pyx_pybuffer_Pts.pybuffer.buf = NULL;
  __pyx_pybuffer_Pts.refcount = 0;
  __pyx_pybuffernd_Pts.data = NULL;
  __pyx_pybuffernd_Pts.rcbuffer = &__pyx_pybuffer_Pts;
  __pyx_pybuffer_ind.pybuffer.buf = NULL;
  __pyx_pybuffer_ind.refcount = 0;
  __pyx_pybuffernd_ind.data = NULL;
  __pyx_pybuffernd_ind.rcbuffer = &__pyx_pybuffer_ind;
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_ind.rcbuffer->pybuffer, (PyObject*)__pyx_v_ind, &__Pyx_TypeInfo_long, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) __PYX_ERR(0, 422, __pyx_L1_error)
  }
  __pyx_pybuffernd_ind.diminfo[0].strides = __pyx_pybuffernd_ind.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_ind.diminfo[0].shape = __pyx_pybuffernd_ind.rcbuffer->pybuffer.shape[0];
/* … */
  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __PYX_XDEC_MEMVIEW(&__pyx_t_6, 1);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_XDECREF(__pyx_t_10);
  __Pyx_XDECREF(__pyx_t_11);
  __Pyx_XDECREF(__pyx_t_12);
  __Pyx_XDECREF(__pyx_t_21);
  __Pyx_XDECREF(__pyx_t_22);
  { PyObject *__pyx_type, *__pyx_value, *__pyx_tb;
    __Pyx_PyThreadState_declare
    __Pyx_PyThreadState_assign
    __Pyx_ErrFetch(&__pyx_type, &__pyx_value, &__pyx_tb);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_NL.rcbuffer->pybuffer);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_Pts.rcbuffer->pybuffer);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_PtsM.rcbuffer->pybuffer);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_R0.rcbuffer->pybuffer);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_Rref.rcbuffer->pybuffer);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_VPbis.rcbuffer->pybuffer);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_Z0.rcbuffer->pybuffer);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_bla.rcbuffer->pybuffer);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_dLr.rcbuffer->pybuffer);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_dRPhir.rcbuffer->pybuffer);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_dS.rcbuffer->pybuffer);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_dSM.rcbuffer->pybuffer);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_ind.rcbuffer->pybuffer);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_indM.rcbuffer->pybuffer);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_indR0.rcbuffer->pybuffer);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_indZ0.rcbuffer->pybuffer);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_pts.rcbuffer->pybuffer);
  __Pyx_ErrRestore(__pyx_type, __pyx_value, __pyx_tb);}
  __Pyx_AddTraceback("_cython_magic_8152fc40fb05daa7217c00b66474f995._Ves_Smesh_TorStruct_SubFromInd_cython", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  goto __pyx_L2;
  __pyx_L0:;
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_NL.rcbuffer->pybuffer);
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_Pts.rcbuffer->pybuffer);
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_PtsM.rcbuffer->pybuffer);
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_R0.rcbuffer->pybuffer);
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_Rref.rcbuffer->pybuffer);
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_VPbis.rcbuffer->pybuffer);
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_Z0.rcbuffer->pybuffer);
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_bla.rcbuffer->pybuffer);
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_dLr.rcbuffer->pybuffer);
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_dRPhir.rcbuffer->pybuffer);
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_dS.rcbuffer->pybuffer);
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_dSM.rcbuffer->pybuffer);
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_ind.rcbuffer->pybuffer);
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_indM.rcbuffer->pybuffer);
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_indR0.rcbuffer->pybuffer);
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_indZ0.rcbuffer->pybuffer);
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_pts.rcbuffer->pybuffer);
  __pyx_L2:;
  __Pyx_XDECREF((PyObject *)__pyx_v_R0);
  __Pyx_XDECREF((PyObject *)__pyx_v_Z0);
  __Pyx_XDECREF((PyObject *)__pyx_v_dSM);
  __Pyx_XDECREF((PyObject *)__pyx_v_dLr);
  __Pyx_XDECREF((PyObject *)__pyx_v_Rref);
  __Pyx_XDECREF((PyObject *)__pyx_v_dRPhir);
  __Pyx_XDECREF((PyObject *)__pyx_v_dS);
  __Pyx_XDECREF((PyObject *)__pyx_v_bla);
  __Pyx_XDECREF((PyObject *)__pyx_v_indR0);
  __Pyx_XDECREF((PyObject *)__pyx_v_indZ0);
  __Pyx_XDECREF((PyObject *)__pyx_v_indM);
  __Pyx_XDECREF((PyObject *)__pyx_v_NL);
  __Pyx_XDECREF((PyObject *)__pyx_v_pts);
  __Pyx_XDECREF((PyObject *)__pyx_v_PtsM);
  __Pyx_XDECREF((PyObject *)__pyx_v_VPbis);
  __Pyx_XDECREF((PyObject *)__pyx_v_Pts);
  __Pyx_XDECREF(__pyx_v_LPts);
  __Pyx_XDECREF(__pyx_v_LdS);
  __Pyx_XDECREF(__pyx_v_Lind);
  __Pyx_XDECREF(__pyx_v_nRPhi0);
  __Pyx_XDECREF(__pyx_v_ii);
  __PYX_XDEC_MEMVIEW(&__pyx_v_PhiMinMax, 1);
  __PYX_XDEC_MEMVIEW(&__pyx_v_VPoly, 1);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}
/* … */
  __pyx_tuple__115 = PyTuple_Pack(43, __pyx_n_s_PhiMinMax, __pyx_n_s_dL, __pyx_n_s_dRPhi, __pyx_n_s_VPoly, __pyx_n_s_ind, __pyx_n_s_DIn, __pyx_n_s_VIn, __pyx_n_s_Out, __pyx_n_s_margin, __pyx_n_s_Dphi, __pyx_n_s_dR0r, __pyx_n_s_dZ0r, __pyx_n_s_NR0, __pyx_n_s_NZ0, __pyx_n_s_R0n, __pyx_n_s_Z0n, __pyx_n_s_NRPhi0, __pyx_n_s_R0, __pyx_n_s_Z0, __pyx_n_s_dsF, __pyx_n_s_dSM, __pyx_n_s_dLr, __pyx_n_s_Rref, __pyx_n_s_dRPhir, __pyx_n_s_dS, __pyx_n_s_bla, __pyx_n_s_indR0, __pyx_n_s_indZ0, __pyx_n_s_iind, __pyx_n_s_iindF, __pyx_n_s_indM, __pyx_n_s_NL, __pyx_n_s_ptsrz, __pyx_n_s_pts, __pyx_n_s_PtsM, __pyx_n_s_VPbis, __pyx_n_s_Pts, __pyx_n_s_LPts, __pyx_n_s_LdS, __pyx_n_s_Lind, __pyx_n_s_nRPhi0, __pyx_n_s_ii, __pyx_n_s_nii); if (unlikely(!__pyx_tuple__115)) __PYX_ERR(0, 422, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__115);
  __Pyx_GIVEREF(__pyx_tuple__115);
/* … */
  __pyx_t_2 = PyCFunction_NewEx(&__pyx_mdef_46_cython_magic_8152fc40fb05daa7217c00b66474f995_11_Ves_Smesh_TorStruct_SubFromInd_cython, NULL, __pyx_n_s_cython_magic_8152fc40fb05daa721); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 422, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_Ves_Smesh_TorStruct_SubFromInd, __pyx_t_2) < 0) __PYX_ERR(0, 422, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_codeobj__116 = (PyObject*)__Pyx_PyCode_New(9, 0, 43, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__115, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_Home_DV226270_cache_ipython_cyt, __pyx_n_s_Ves_Smesh_TorStruct_SubFromInd, 422, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__116)) __PYX_ERR(0, 422, __pyx_L1_error)
 423:                                            double[:,::1] VPoly, cnp.ndarray[long,ndim=1] ind,
+424:                                            double DIn=0., VIn=None,
    values[6] = ((PyObject *)Py_None);
    values[7] = ((PyObject*)__pyx_kp_u_X_Y_Z);
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  9: values[8] = PyTuple_GET_ITEM(__pyx_args, 8);
        case  8: values[7] = PyTuple_GET_ITEM(__pyx_args, 7);
        case  7: values[6] = PyTuple_GET_ITEM(__pyx_args, 6);
        case  6: values[5] = PyTuple_GET_ITEM(__pyx_args, 5);
        case  5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_PhiMinMax)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        case  1:
        if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_dL)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_Ves_Smesh_TorStruct_SubFromInd_cython", 0, 5, 9, 1); __PYX_ERR(0, 422, __pyx_L3_error)
        }
        case  2:
        if (likely((values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_dRPhi)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_Ves_Smesh_TorStruct_SubFromInd_cython", 0, 5, 9, 2); __PYX_ERR(0, 422, __pyx_L3_error)
        }
        case  3:
        if (likely((values[3] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_VPoly)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_Ves_Smesh_TorStruct_SubFromInd_cython", 0, 5, 9, 3); __PYX_ERR(0, 422, __pyx_L3_error)
        }
        case  4:
        if (likely((values[4] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_ind)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_Ves_Smesh_TorStruct_SubFromInd_cython", 0, 5, 9, 4); __PYX_ERR(0, 422, __pyx_L3_error)
        }
        case  5:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_DIn);
          if (value) { values[5] = value; kw_args--; }
        }
        case  6:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_VIn);
          if (value) { values[6] = value; kw_args--; }
        }
        case  7:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_Out);
          if (value) { values[7] = value; kw_args--; }
        }
        case  8:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_margin);
          if (value) { values[8] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "_Ves_Smesh_TorStruct_SubFromInd_cython") < 0)) __PYX_ERR(0, 422, __pyx_L3_error)
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  9: values[8] = PyTuple_GET_ITEM(__pyx_args, 8);
        case  8: values[7] = PyTuple_GET_ITEM(__pyx_args, 7);
        case  7: values[6] = PyTuple_GET_ITEM(__pyx_args, 6);
        case  6: values[5] = PyTuple_GET_ITEM(__pyx_args, 5);
        case  5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
        values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    __pyx_v_PhiMinMax = __Pyx_PyObject_to_MemoryviewSlice_dc_double(values[0]); if (unlikely(!__pyx_v_PhiMinMax.memview)) __PYX_ERR(0, 422, __pyx_L3_error)
    __pyx_v_dL = __pyx_PyFloat_AsDouble(values[1]); if (unlikely((__pyx_v_dL == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 422, __pyx_L3_error)
    __pyx_v_dRPhi = __pyx_PyFloat_AsDouble(values[2]); if (unlikely((__pyx_v_dRPhi == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 422, __pyx_L3_error)
    __pyx_v_VPoly = __Pyx_PyObject_to_MemoryviewSlice_d_dc_double(values[3]); if (unlikely(!__pyx_v_VPoly.memview)) __PYX_ERR(0, 423, __pyx_L3_error)
    __pyx_v_ind = ((PyArrayObject *)values[4]);
    if (values[5]) {
      __pyx_v_DIn = __pyx_PyFloat_AsDouble(values[5]); if (unlikely((__pyx_v_DIn == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 424, __pyx_L3_error)
    } else {
      __pyx_v_DIn = ((double)0.);
    }
    __pyx_v_VIn = values[6];
    __pyx_v_Out = ((PyObject*)values[7]);
    if (values[8]) {
      __pyx_v_margin = __pyx_PyFloat_AsDouble(values[8]); if (unlikely((__pyx_v_margin == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 425, __pyx_L3_error)
    } else {
      __pyx_v_margin = ((double)1.e-9);
    }
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("_Ves_Smesh_TorStruct_SubFromInd_cython", 0, 5, 9, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 422, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("_cython_magic_8152fc40fb05daa7217c00b66474f995._Ves_Smesh_TorStruct_SubFromInd_cython", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_ind), __pyx_ptype_5numpy_ndarray, 1, "ind", 0))) __PYX_ERR(0, 423, __pyx_L1_error)
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_Out), (&PyUnicode_Type), 1, "Out", 1))) __PYX_ERR(0, 425, __pyx_L1_error)
  __pyx_r = __pyx_pf_46_cython_magic_8152fc40fb05daa7217c00b66474f995_10_Ves_Smesh_TorStruct_SubFromInd_cython(__pyx_self, __pyx_v_PhiMinMax, __pyx_v_dL, __pyx_v_dRPhi, __pyx_v_VPoly, __pyx_v_ind, __pyx_v_DIn, __pyx_v_VIn, __pyx_v_Out, __pyx_v_margin);
 425:                                            str Out='(X,Y,Z)', double margin=1.e-9):
 426:     " Return the desired surfacic submesh indicated by the limits (DR,DZ,DPhi), for the desired resolution (dR,dZ,dRphi) "
 427:     cdef double Dphi, dR0r, dZ0r
 428:     cdef int NR0, NZ0, R0n, Z0n, NRPhi0
 429:     cdef cnp.ndarray[double, ndim=1] R0, Z0, dsF, dSM, dLr, Rref, dRPhir, dS
 430:     cdef cnp.ndarray[long,ndim=1] bla, indR0, indZ0, iind, iindF, indM, NL
 431:     cdef cnp.ndarray[double,ndim=2] ptsrz, pts, PtsM, VPbis, Pts
+432:     cdef list LPts=[], LdS=[], Lind=[]
  __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 432, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_LPts = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;
  __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 432, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_LdS = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;
  __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 432, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_Lind = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;
 433: 
 434:     # Pre-format input
+435:     Dphi = DIn/np.max(VPoly[0,:]) if DIn!=0. else 0. # Required distance effective at max R
  if (((__pyx_v_DIn != 0.) != 0)) {
    __pyx_t_1 = PyFloat_FromDouble(__pyx_v_DIn); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 435, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 435, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_max); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 435, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_t_6.data = __pyx_v_VPoly.data;
    __pyx_t_6.memview = __pyx_v_VPoly.memview;
    __PYX_INC_MEMVIEW(&__pyx_t_6, 0);
    {
    Py_ssize_t __pyx_tmp_idx = 0;
    Py_ssize_t __pyx_tmp_shape = __pyx_v_VPoly.shape[0];
    Py_ssize_t __pyx_tmp_stride = __pyx_v_VPoly.strides[0];
    if (0 && (__pyx_tmp_idx < 0))
        __pyx_tmp_idx += __pyx_tmp_shape;
    if (0 && (__pyx_tmp_idx < 0 || __pyx_tmp_idx >= __pyx_tmp_shape)) {
        PyErr_SetString(PyExc_IndexError, "Index out of bounds (axis 0)");
        __PYX_ERR(0, 435, __pyx_L1_error)
    }
        __pyx_t_6.data += __pyx_tmp_idx * __pyx_tmp_stride;
}

__pyx_t_6.shape[0] = __pyx_v_VPoly.shape[1];
__pyx_t_6.strides[0] = __pyx_v_VPoly.strides[1];
    __pyx_t_6.suboffsets[0] = -1;

__pyx_t_4 = __pyx_memoryview_fromslice(__pyx_t_6, 1, (PyObject *(*)(char *)) __pyx_memview_get_double, (int (*)(char *, PyObject *)) __pyx_memview_set_double, 0);; if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 435, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __PYX_XDEC_MEMVIEW(&__pyx_t_6, 1);
    __pyx_t_6.memview = NULL;
    __pyx_t_6.data = NULL;
    __pyx_t_7 = NULL;
    if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_5))) {
      __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_5);
      if (likely(__pyx_t_7)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5);
        __Pyx_INCREF(__pyx_t_7);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_5, function);
      }
    }
    if (!__pyx_t_7) {
      __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_t_5, __pyx_t_4); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 435, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __Pyx_GOTREF(__pyx_t_3);
    } else {
      #if CYTHON_FAST_PYCALL
      if (PyFunction_Check(__pyx_t_5)) {
        PyObject *__pyx_temp[2] = {__pyx_t_7, __pyx_t_4};
        __pyx_t_3 = __Pyx_PyFunction_FastCall(__pyx_t_5, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 435, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
        __Pyx_GOTREF(__pyx_t_3);
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      } else
      #endif
      #if CYTHON_FAST_PYCCALL
      if (__Pyx_PyFastCFunction_Check(__pyx_t_5)) {
        PyObject *__pyx_temp[2] = {__pyx_t_7, __pyx_t_4};
        __pyx_t_3 = __Pyx_PyCFunction_FastCall(__pyx_t_5, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 435, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
        __Pyx_GOTREF(__pyx_t_3);
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      } else
      #endif
      {
        __pyx_t_8 = PyTuple_New(1+1); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 435, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_8);
        __Pyx_GIVEREF(__pyx_t_7); PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_7); __pyx_t_7 = NULL;
        __Pyx_GIVEREF(__pyx_t_4);
        PyTuple_SET_ITEM(__pyx_t_8, 0+1, __pyx_t_4);
        __pyx_t_4 = 0;
        __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_t_8, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 435, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_3);
        __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
      }
    }
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __pyx_t_5 = __Pyx_PyNumber_Divide(__pyx_t_1, __pyx_t_3); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 435, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_t_9 = __pyx_PyFloat_AsDouble(__pyx_t_5); if (unlikely((__pyx_t_9 == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 435, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __pyx_t_2 = __pyx_t_9;
  } else {
    __pyx_t_2 = 0.;
  }
  __pyx_v_Dphi = __pyx_t_2;
 436: 
 437:     # Get the basic meshes for the faces
+438:     R0, dR0r, bla, NR0 = _Ves_mesh_dlfromL_cython(np.array([np.min(VPoly[0,:]),np.max(VPoly[0,:])]), dL, DL=None, margin=margin)
  __pyx_t_5 = __Pyx_GetModuleGlobalName(__pyx_n_s_Ves_mesh_dlfromL_cython); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 438, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 438, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_array); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 438, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 438, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_min); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 438, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_6.data = __pyx_v_VPoly.data;
  __pyx_t_6.memview = __pyx_v_VPoly.memview;
  __PYX_INC_MEMVIEW(&__pyx_t_6, 0);
  {
    Py_ssize_t __pyx_tmp_idx = 0;
    Py_ssize_t __pyx_tmp_shape = __pyx_v_VPoly.shape[0];
    Py_ssize_t __pyx_tmp_stride = __pyx_v_VPoly.strides[0];
    if (0 && (__pyx_tmp_idx < 0))
        __pyx_tmp_idx += __pyx_tmp_shape;
    if (0 && (__pyx_tmp_idx < 0 || __pyx_tmp_idx >= __pyx_tmp_shape)) {
        PyErr_SetString(PyExc_IndexError, "Index out of bounds (axis 0)");
        __PYX_ERR(0, 438, __pyx_L1_error)
    }
        __pyx_t_6.data += __pyx_tmp_idx * __pyx_tmp_stride;
}

__pyx_t_6.shape[0] = __pyx_v_VPoly.shape[1];
__pyx_t_6.strides[0] = __pyx_v_VPoly.strides[1];
    __pyx_t_6.suboffsets[0] = -1;

__pyx_t_4 = __pyx_memoryview_fromslice(__pyx_t_6, 1, (PyObject *(*)(char *)) __pyx_memview_get_double, (int (*)(char *, PyObject *)) __pyx_memview_set_double, 0);; if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 438, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __PYX_XDEC_MEMVIEW(&__pyx_t_6, 1);
  __pyx_t_6.memview = NULL;
  __pyx_t_6.data = NULL;
  __pyx_t_10 = NULL;
  if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_7))) {
    __pyx_t_10 = PyMethod_GET_SELF(__pyx_t_7);
    if (likely(__pyx_t_10)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_7);
      __Pyx_INCREF(__pyx_t_10);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_7, function);
    }
  }
  if (!__pyx_t_10) {
    __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_7, __pyx_t_4); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 438, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_GOTREF(__pyx_t_1);
  } else {
    #if CYTHON_FAST_PYCALL
    if (PyFunction_Check(__pyx_t_7)) {
      PyObject *__pyx_temp[2] = {__pyx_t_10, __pyx_t_4};
      __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_7, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 438, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    } else
    #endif
    #if CYTHON_FAST_PYCCALL
    if (__Pyx_PyFastCFunction_Check(__pyx_t_7)) {
      PyObject *__pyx_temp[2] = {__pyx_t_10, __pyx_t_4};
      __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_7, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 438, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    } else
    #endif
    {
      __pyx_t_11 = PyTuple_New(1+1); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 438, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_11);
      __Pyx_GIVEREF(__pyx_t_10); PyTuple_SET_ITEM(__pyx_t_11, 0, __pyx_t_10); __pyx_t_10 = NULL;
      __Pyx_GIVEREF(__pyx_t_4);
      PyTuple_SET_ITEM(__pyx_t_11, 0+1, __pyx_t_4);
      __pyx_t_4 = 0;
      __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_7, __pyx_t_11, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 438, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
    }
  }
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  __pyx_t_11 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 438, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_11);
  __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_11, __pyx_n_s_max); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 438, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
  __pyx_t_6.data = __pyx_v_VPoly.data;
  __pyx_t_6.memview = __pyx_v_VPoly.memview;
  __PYX_INC_MEMVIEW(&__pyx_t_6, 0);
  {
    Py_ssize_t __pyx_tmp_idx = 0;
    Py_ssize_t __pyx_tmp_shape = __pyx_v_VPoly.shape[0];
    Py_ssize_t __pyx_tmp_stride = __pyx_v_VPoly.strides[0];
    if (0 && (__pyx_tmp_idx < 0))
        __pyx_tmp_idx += __pyx_tmp_shape;
    if (0 && (__pyx_tmp_idx < 0 || __pyx_tmp_idx >= __pyx_tmp_shape)) {
        PyErr_SetString(PyExc_IndexError, "Index out of bounds (axis 0)");
        __PYX_ERR(0, 438, __pyx_L1_error)
    }
        __pyx_t_6.data += __pyx_tmp_idx * __pyx_tmp_stride;
}

__pyx_t_6.shape[0] = __pyx_v_VPoly.shape[1];
__pyx_t_6.strides[0] = __pyx_v_VPoly.strides[1];
    __pyx_t_6.suboffsets[0] = -1;

__pyx_t_11 = __pyx_memoryview_fromslice(__pyx_t_6, 1, (PyObject *(*)(char *)) __pyx_memview_get_double, (int (*)(char *, PyObject *)) __pyx_memview_set_double, 0);; if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 438, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_11);
  __PYX_XDEC_MEMVIEW(&__pyx_t_6, 1);
  __pyx_t_6.memview = NULL;
  __pyx_t_6.data = NULL;
  __pyx_t_10 = NULL;
  if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_4))) {
    __pyx_t_10 = PyMethod_GET_SELF(__pyx_t_4);
    if (likely(__pyx_t_10)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
      __Pyx_INCREF(__pyx_t_10);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_4, function);
    }
  }
  if (!__pyx_t_10) {
    __pyx_t_7 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_11); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 438, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
    __Pyx_GOTREF(__pyx_t_7);
  } else {
    #if CYTHON_FAST_PYCALL
    if (PyFunction_Check(__pyx_t_4)) {
      PyObject *__pyx_temp[2] = {__pyx_t_10, __pyx_t_11};
      __pyx_t_7 = __Pyx_PyFunction_FastCall(__pyx_t_4, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 438, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
      __Pyx_GOTREF(__pyx_t_7);
      __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
    } else
    #endif
    #if CYTHON_FAST_PYCCALL
    if (__Pyx_PyFastCFunction_Check(__pyx_t_4)) {
      PyObject *__pyx_temp[2] = {__pyx_t_10, __pyx_t_11};
      __pyx_t_7 = __Pyx_PyCFunction_FastCall(__pyx_t_4, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 438, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
      __Pyx_GOTREF(__pyx_t_7);
      __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
    } else
    #endif
    {
      __pyx_t_12 = PyTuple_New(1+1); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 438, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_12);
      __Pyx_GIVEREF(__pyx_t_10); PyTuple_SET_ITEM(__pyx_t_12, 0, __pyx_t_10); __pyx_t_10 = NULL;
      __Pyx_GIVEREF(__pyx_t_11);
      PyTuple_SET_ITEM(__pyx_t_12, 0+1, __pyx_t_11);
      __pyx_t_11 = 0;
      __pyx_t_7 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_12, NULL); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 438, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_7);
      __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
    }
  }
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_4 = PyList_New(2); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 438, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_GIVEREF(__pyx_t_1);
  PyList_SET_ITEM(__pyx_t_4, 0, __pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_7);
  PyList_SET_ITEM(__pyx_t_4, 1, __pyx_t_7);
  __pyx_t_1 = 0;
  __pyx_t_7 = 0;
  __pyx_t_7 = NULL;
  if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_8))) {
    __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_8);
    if (likely(__pyx_t_7)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_8);
      __Pyx_INCREF(__pyx_t_7);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_8, function);
    }
  }
  if (!__pyx_t_7) {
    __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_t_8, __pyx_t_4); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 438, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_GOTREF(__pyx_t_3);
  } else {
    #if CYTHON_FAST_PYCALL
    if (PyFunction_Check(__pyx_t_8)) {
      PyObject *__pyx_temp[2] = {__pyx_t_7, __pyx_t_4};
      __pyx_t_3 = __Pyx_PyFunction_FastCall(__pyx_t_8, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 438, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    } else
    #endif
    #if CYTHON_FAST_PYCCALL
    if (__Pyx_PyFastCFunction_Check(__pyx_t_8)) {
      PyObject *__pyx_temp[2] = {__pyx_t_7, __pyx_t_4};
      __pyx_t_3 = __Pyx_PyCFunction_FastCall(__pyx_t_8, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 438, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    } else
    #endif
    {
      __pyx_t_1 = PyTuple_New(1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 438, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_GIVEREF(__pyx_t_7); PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_7); __pyx_t_7 = NULL;
      __Pyx_GIVEREF(__pyx_t_4);
      PyTuple_SET_ITEM(__pyx_t_1, 0+1, __pyx_t_4);
      __pyx_t_4 = 0;
      __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_8, __pyx_t_1, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 438, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    }
  }
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  __pyx_t_8 = PyFloat_FromDouble(__pyx_v_dL); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 438, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);
  __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 438, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_3);
  PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_3);
  __Pyx_GIVEREF(__pyx_t_8);
  PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_t_8);
  __pyx_t_3 = 0;
  __pyx_t_8 = 0;
  __pyx_t_8 = PyDict_New(); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 438, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);
  if (PyDict_SetItem(__pyx_t_8, __pyx_n_s_DL, Py_None) < 0) __PYX_ERR(0, 438, __pyx_L1_error)
  __pyx_t_3 = PyFloat_FromDouble(__pyx_v_margin); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 438, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  if (PyDict_SetItem(__pyx_t_8, __pyx_n_s_margin, __pyx_t_3) < 0) __PYX_ERR(0, 438, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_t_1, __pyx_t_8); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 438, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  if ((likely(PyTuple_CheckExact(__pyx_t_3))) || (PyList_CheckExact(__pyx_t_3))) {
    PyObject* sequence = __pyx_t_3;
    #if !CYTHON_COMPILING_IN_PYPY
    Py_ssize_t size = Py_SIZE(sequence);
    #else
    Py_ssize_t size = PySequence_Size(sequence);
    #endif
    if (unlikely(size != 4)) {
      if (size > 4) __Pyx_RaiseTooManyValuesError(4);
      else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
      __PYX_ERR(0, 438, __pyx_L1_error)
    }
    #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
    if (likely(PyTuple_CheckExact(sequence))) {
      __pyx_t_8 = PyTuple_GET_ITEM(sequence, 0); 
      __pyx_t_1 = PyTuple_GET_ITEM(sequence, 1); 
      __pyx_t_5 = PyTuple_GET_ITEM(sequence, 2); 
      __pyx_t_4 = PyTuple_GET_ITEM(sequence, 3); 
    } else {
      __pyx_t_8 = PyList_GET_ITEM(sequence, 0); 
      __pyx_t_1 = PyList_GET_ITEM(sequence, 1); 
      __pyx_t_5 = PyList_GET_ITEM(sequence, 2); 
      __pyx_t_4 = PyList_GET_ITEM(sequence, 3); 
    }
    __Pyx_INCREF(__pyx_t_8);
    __Pyx_INCREF(__pyx_t_1);
    __Pyx_INCREF(__pyx_t_5);
    __Pyx_INCREF(__pyx_t_4);
    #else
    {
      Py_ssize_t i;
      PyObject** temps[4] = {&__pyx_t_8,&__pyx_t_1,&__pyx_t_5,&__pyx_t_4};
      for (i=0; i < 4; i++) {
        PyObject* item = PySequence_ITEM(sequence, i); if (unlikely(!item)) __PYX_ERR(0, 438, __pyx_L1_error)
        __Pyx_GOTREF(item);
        *(temps[i]) = item;
      }
    }
    #endif
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  } else {
    Py_ssize_t index = -1;
    PyObject** temps[4] = {&__pyx_t_8,&__pyx_t_1,&__pyx_t_5,&__pyx_t_4};
    __pyx_t_7 = PyObject_GetIter(__pyx_t_3); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 438, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_t_13 = Py_TYPE(__pyx_t_7)->tp_iternext;
    for (index=0; index < 4; index++) {
      PyObject* item = __pyx_t_13(__pyx_t_7); if (unlikely(!item)) goto __pyx_L3_unpacking_failed;
      __Pyx_GOTREF(item);
      *(temps[index]) = item;
    }
    if (__Pyx_IternextUnpackEndCheck(__pyx_t_13(__pyx_t_7), 4) < 0) __PYX_ERR(0, 438, __pyx_L1_error)
    __pyx_t_13 = NULL;
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    goto __pyx_L4_unpacking_done;
    __pyx_L3_unpacking_failed:;
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    __pyx_t_13 = NULL;
    if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
    __PYX_ERR(0, 438, __pyx_L1_error)
    __pyx_L4_unpacking_done:;
  }
  if (!(likely(((__pyx_t_8) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_8, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 438, __pyx_L1_error)
  __pyx_t_2 = __pyx_PyFloat_AsDouble(__pyx_t_1); if (unlikely((__pyx_t_2 == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 438, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (!(likely(((__pyx_t_5) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_5, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 438, __pyx_L1_error)
  __pyx_t_14 = __Pyx_PyInt_As_int(__pyx_t_4); if (unlikely((__pyx_t_14 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 438, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_15 = ((PyArrayObject *)__pyx_t_8);
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_R0.rcbuffer->pybuffer);
    __pyx_t_16 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_R0.rcbuffer->pybuffer, (PyObject*)__pyx_t_15, &__Pyx_TypeInfo_double, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack);
    if (unlikely(__pyx_t_16 < 0)) {
      PyErr_Fetch(&__pyx_t_17, &__pyx_t_18, &__pyx_t_19);
      if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_R0.rcbuffer->pybuffer, (PyObject*)__pyx_v_R0, &__Pyx_TypeInfo_double, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {
        Py_XDECREF(__pyx_t_17); Py_XDECREF(__pyx_t_18); Py_XDECREF(__pyx_t_19);
        __Pyx_RaiseBufferFallbackError();
      } else {
        PyErr_Restore(__pyx_t_17, __pyx_t_18, __pyx_t_19);
      }
    }
    __pyx_pybuffernd_R0.diminfo[0].strides = __pyx_pybuffernd_R0.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_R0.diminfo[0].shape = __pyx_pybuffernd_R0.rcbuffer->pybuffer.shape[0];
    if (unlikely(__pyx_t_16 < 0)) __PYX_ERR(0, 438, __pyx_L1_error)
  }
  __pyx_t_15 = 0;
  __pyx_v_R0 = ((PyArrayObject *)__pyx_t_8);
  __pyx_t_8 = 0;
  __pyx_v_dR0r = __pyx_t_2;
  __pyx_t_20 = ((PyArrayObject *)__pyx_t_5);
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_bla.rcbuffer->pybuffer);
    __pyx_t_16 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_bla.rcbuffer->pybuffer, (PyObject*)__pyx_t_20, &__Pyx_TypeInfo_long, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack);
    if (unlikely(__pyx_t_16 < 0)) {
      PyErr_Fetch(&__pyx_t_19, &__pyx_t_18, &__pyx_t_17);
      if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_bla.rcbuffer->pybuffer, (PyObject*)__pyx_v_bla, &__Pyx_TypeInfo_long, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {
        Py_XDECREF(__pyx_t_19); Py_XDECREF(__pyx_t_18); Py_XDECREF(__pyx_t_17);
        __Pyx_RaiseBufferFallbackError();
      } else {
        PyErr_Restore(__pyx_t_19, __pyx_t_18, __pyx_t_17);
      }
    }
    __pyx_pybuffernd_bla.diminfo[0].strides = __pyx_pybuffernd_bla.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_bla.diminfo[0].shape = __pyx_pybuffernd_bla.rcbuffer->pybuffer.shape[0];
    if (unlikely(__pyx_t_16 < 0)) __PYX_ERR(0, 438, __pyx_L1_error)
  }
  __pyx_t_20 = 0;
  __pyx_v_bla = ((PyArrayObject *)__pyx_t_5);
  __pyx_t_5 = 0;
  __pyx_v_NR0 = __pyx_t_14;
+439:     Z0, dZ0r, bla, NZ0 = _Ves_mesh_dlfromL_cython(np.array([np.min(VPoly[1,:]),np.max(VPoly[1,:])]), dL, DL=None, margin=margin)
  __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_Ves_mesh_dlfromL_cython); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 439, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_5 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 439, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_n_s_array); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 439, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __pyx_t_8 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 439, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);
  __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_t_8, __pyx_n_s_min); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 439, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  __pyx_t_6.data = __pyx_v_VPoly.data;
  __pyx_t_6.memview = __pyx_v_VPoly.memview;
  __PYX_INC_MEMVIEW(&__pyx_t_6, 0);
  {
    Py_ssize_t __pyx_tmp_idx = 1;
    Py_ssize_t __pyx_tmp_shape = __pyx_v_VPoly.shape[0];
    Py_ssize_t __pyx_tmp_stride = __pyx_v_VPoly.strides[0];
    if (0 && (__pyx_tmp_idx < 0))
        __pyx_tmp_idx += __pyx_tmp_shape;
    if (0 && (__pyx_tmp_idx < 0 || __pyx_tmp_idx >= __pyx_tmp_shape)) {
        PyErr_SetString(PyExc_IndexError, "Index out of bounds (axis 0)");
        __PYX_ERR(0, 439, __pyx_L1_error)
    }
        __pyx_t_6.data += __pyx_tmp_idx * __pyx_tmp_stride;
}

__pyx_t_6.shape[0] = __pyx_v_VPoly.shape[1];
__pyx_t_6.strides[0] = __pyx_v_VPoly.strides[1];
    __pyx_t_6.suboffsets[0] = -1;

__pyx_t_8 = __pyx_memoryview_fromslice(__pyx_t_6, 1, (PyObject *(*)(char *)) __pyx_memview_get_double, (int (*)(char *, PyObject *)) __pyx_memview_set_double, 0);; if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 439, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);
  __PYX_XDEC_MEMVIEW(&__pyx_t_6, 1);
  __pyx_t_6.memview = NULL;
  __pyx_t_6.data = NULL;
  __pyx_t_12 = NULL;
  if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_7))) {
    __pyx_t_12 = PyMethod_GET_SELF(__pyx_t_7);
    if (likely(__pyx_t_12)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_7);
      __Pyx_INCREF(__pyx_t_12);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_7, function);
    }
  }
  if (!__pyx_t_12) {
    __pyx_t_5 = __Pyx_PyObject_CallOneArg(__pyx_t_7, __pyx_t_8); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 439, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    __Pyx_GOTREF(__pyx_t_5);
  } else {
    #if CYTHON_FAST_PYCALL
    if (PyFunction_Check(__pyx_t_7)) {
      PyObject *__pyx_temp[2] = {__pyx_t_12, __pyx_t_8};
      __pyx_t_5 = __Pyx_PyFunction_FastCall(__pyx_t_7, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 439, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0;
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    } else
    #endif
    #if CYTHON_FAST_PYCCALL
    if (__Pyx_PyFastCFunction_Check(__pyx_t_7)) {
      PyObject *__pyx_temp[2] = {__pyx_t_12, __pyx_t_8};
      __pyx_t_5 = __Pyx_PyCFunction_FastCall(__pyx_t_7, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 439, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0;
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    } else
    #endif
    {
      __pyx_t_11 = PyTuple_New(1+1); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 439, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_11);
      __Pyx_GIVEREF(__pyx_t_12); PyTuple_SET_ITEM(__pyx_t_11, 0, __pyx_t_12); __pyx_t_12 = NULL;
      __Pyx_GIVEREF(__pyx_t_8);
      PyTuple_SET_ITEM(__pyx_t_11, 0+1, __pyx_t_8);
      __pyx_t_8 = 0;
      __pyx_t_5 = __Pyx_PyObject_Call(__pyx_t_7, __pyx_t_11, NULL); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 439, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
    }
  }
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  __pyx_t_11 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 439, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_11);
  __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_t_11, __pyx_n_s_max); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 439, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);
  __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
  __pyx_t_6.data = __pyx_v_VPoly.data;
  __pyx_t_6.memview = __pyx_v_VPoly.memview;
  __PYX_INC_MEMVIEW(&__pyx_t_6, 0);
  {
    Py_ssize_t __pyx_tmp_idx = 1;
    Py_ssize_t __pyx_tmp_shape = __pyx_v_VPoly.shape[0];
    Py_ssize_t __pyx_tmp_stride = __pyx_v_VPoly.strides[0];
    if (0 && (__pyx_tmp_idx < 0))
        __pyx_tmp_idx += __pyx_tmp_shape;
    if (0 && (__pyx_tmp_idx < 0 || __pyx_tmp_idx >= __pyx_tmp_shape)) {
        PyErr_SetString(PyExc_IndexError, "Index out of bounds (axis 0)");
        __PYX_ERR(0, 439, __pyx_L1_error)
    }
        __pyx_t_6.data += __pyx_tmp_idx * __pyx_tmp_stride;
}

__pyx_t_6.shape[0] = __pyx_v_VPoly.shape[1];
__pyx_t_6.strides[0] = __pyx_v_VPoly.strides[1];
    __pyx_t_6.suboffsets[0] = -1;

__pyx_t_11 = __pyx_memoryview_fromslice(__pyx_t_6, 1, (PyObject *(*)(char *)) __pyx_memview_get_double, (int (*)(char *, PyObject *)) __pyx_memview_set_double, 0);; if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 439, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_11);
  __PYX_XDEC_MEMVIEW(&__pyx_t_6, 1);
  __pyx_t_6.memview = NULL;
  __pyx_t_6.data = NULL;
  __pyx_t_12 = NULL;
  if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_8))) {
    __pyx_t_12 = PyMethod_GET_SELF(__pyx_t_8);
    if (likely(__pyx_t_12)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_8);
      __Pyx_INCREF(__pyx_t_12);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_8, function);
    }
  }
  if (!__pyx_t_12) {
    __pyx_t_7 = __Pyx_PyObject_CallOneArg(__pyx_t_8, __pyx_t_11); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 439, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
    __Pyx_GOTREF(__pyx_t_7);
  } else {
    #if CYTHON_FAST_PYCALL
    if (PyFunction_Check(__pyx_t_8)) {
      PyObject *__pyx_temp[2] = {__pyx_t_12, __pyx_t_11};
      __pyx_t_7 = __Pyx_PyFunction_FastCall(__pyx_t_8, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 439, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0;
      __Pyx_GOTREF(__pyx_t_7);
      __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
    } else
    #endif
    #if CYTHON_FAST_PYCCALL
    if (__Pyx_PyFastCFunction_Check(__pyx_t_8)) {
      PyObject *__pyx_temp[2] = {__pyx_t_12, __pyx_t_11};
      __pyx_t_7 = __Pyx_PyCFunction_FastCall(__pyx_t_8, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 439, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0;
      __Pyx_GOTREF(__pyx_t_7);
      __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
    } else
    #endif
    {
      __pyx_t_10 = PyTuple_New(1+1); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 439, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_10);
      __Pyx_GIVEREF(__pyx_t_12); PyTuple_SET_ITEM(__pyx_t_10, 0, __pyx_t_12); __pyx_t_12 = NULL;
      __Pyx_GIVEREF(__pyx_t_11);
      PyTuple_SET_ITEM(__pyx_t_10, 0+1, __pyx_t_11);
      __pyx_t_11 = 0;
      __pyx_t_7 = __Pyx_PyObject_Call(__pyx_t_8, __pyx_t_10, NULL); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 439, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_7);
      __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
    }
  }
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  __pyx_t_8 = PyList_New(2); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 439, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);
  __Pyx_GIVEREF(__pyx_t_5);
  PyList_SET_ITEM(__pyx_t_8, 0, __pyx_t_5);
  __Pyx_GIVEREF(__pyx_t_7);
  PyList_SET_ITEM(__pyx_t_8, 1, __pyx_t_7);
  __pyx_t_5 = 0;
  __pyx_t_7 = 0;
  __pyx_t_7 = NULL;
  if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_1))) {
    __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_1);
    if (likely(__pyx_t_7)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1);
      __Pyx_INCREF(__pyx_t_7);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_1, function);
    }
  }
  if (!__pyx_t_7) {
    __pyx_t_4 = __Pyx_PyObject_CallOneArg(__pyx_t_1, __pyx_t_8); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 439, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    __Pyx_GOTREF(__pyx_t_4);
  } else {
    #if CYTHON_FAST_PYCALL
    if (PyFunction_Check(__pyx_t_1)) {
      PyObject *__pyx_temp[2] = {__pyx_t_7, __pyx_t_8};
      __pyx_t_4 = __Pyx_PyFunction_FastCall(__pyx_t_1, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 439, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    } else
    #endif
    #if CYTHON_FAST_PYCCALL
    if (__Pyx_PyFastCFunction_Check(__pyx_t_1)) {
      PyObject *__pyx_temp[2] = {__pyx_t_7, __pyx_t_8};
      __pyx_t_4 = __Pyx_PyCFunction_FastCall(__pyx_t_1, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 439, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    } else
    #endif
    {
      __pyx_t_5 = PyTuple_New(1+1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 439, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_GIVEREF(__pyx_t_7); PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_7); __pyx_t_7 = NULL;
      __Pyx_GIVEREF(__pyx_t_8);
      PyTuple_SET_ITEM(__pyx_t_5, 0+1, __pyx_t_8);
      __pyx_t_8 = 0;
      __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_5, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 439, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    }
  }
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = PyFloat_FromDouble(__pyx_v_dL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 439, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_5 = PyTuple_New(2); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 439, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_GIVEREF(__pyx_t_4);
  PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_4);
  __Pyx_GIVEREF(__pyx_t_1);
  PyTuple_SET_ITEM(__pyx_t_5, 1, __pyx_t_1);
  __pyx_t_4 = 0;
  __pyx_t_1 = 0;
  __pyx_t_1 = PyDict_New(); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 439, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_DL, Py_None) < 0) __PYX_ERR(0, 439, __pyx_L1_error)
  __pyx_t_4 = PyFloat_FromDouble(__pyx_v_margin); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 439, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_margin, __pyx_t_4) < 0) __PYX_ERR(0, 439, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_5, __pyx_t_1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 439, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if ((likely(PyTuple_CheckExact(__pyx_t_4))) || (PyList_CheckExact(__pyx_t_4))) {
    PyObject* sequence = __pyx_t_4;
    #if !CYTHON_COMPILING_IN_PYPY
    Py_ssize_t size = Py_SIZE(sequence);
    #else
    Py_ssize_t size = PySequence_Size(sequence);
    #endif
    if (unlikely(size != 4)) {
      if (size > 4) __Pyx_RaiseTooManyValuesError(4);
      else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
      __PYX_ERR(0, 439, __pyx_L1_error)
    }
    #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
    if (likely(PyTuple_CheckExact(sequence))) {
      __pyx_t_1 = PyTuple_GET_ITEM(sequence, 0); 
      __pyx_t_5 = PyTuple_GET_ITEM(sequence, 1); 
      __pyx_t_3 = PyTuple_GET_ITEM(sequence, 2); 
      __pyx_t_8 = PyTuple_GET_ITEM(sequence, 3); 
    } else {
      __pyx_t_1 = PyList_GET_ITEM(sequence, 0); 
      __pyx_t_5 = PyList_GET_ITEM(sequence, 1); 
      __pyx_t_3 = PyList_GET_ITEM(sequence, 2); 
      __pyx_t_8 = PyList_GET_ITEM(sequence, 3); 
    }
    __Pyx_INCREF(__pyx_t_1);
    __Pyx_INCREF(__pyx_t_5);
    __Pyx_INCREF(__pyx_t_3);
    __Pyx_INCREF(__pyx_t_8);
    #else
    {
      Py_ssize_t i;
      PyObject** temps[4] = {&__pyx_t_1,&__pyx_t_5,&__pyx_t_3,&__pyx_t_8};
      for (i=0; i < 4; i++) {
        PyObject* item = PySequence_ITEM(sequence, i); if (unlikely(!item)) __PYX_ERR(0, 439, __pyx_L1_error)
        __Pyx_GOTREF(item);
        *(temps[i]) = item;
      }
    }
    #endif
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  } else {
    Py_ssize_t index = -1;
    PyObject** temps[4] = {&__pyx_t_1,&__pyx_t_5,&__pyx_t_3,&__pyx_t_8};
    __pyx_t_7 = PyObject_GetIter(__pyx_t_4); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 439, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_t_13 = Py_TYPE(__pyx_t_7)->tp_iternext;
    for (index=0; index < 4; index++) {
      PyObject* item = __pyx_t_13(__pyx_t_7); if (unlikely(!item)) goto __pyx_L5_unpacking_failed;
      __Pyx_GOTREF(item);
      *(temps[index]) = item;
    }
    if (__Pyx_IternextUnpackEndCheck(__pyx_t_13(__pyx_t_7), 4) < 0) __PYX_ERR(0, 439, __pyx_L1_error)
    __pyx_t_13 = NULL;
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    goto __pyx_L6_unpacking_done;
    __pyx_L5_unpacking_failed:;
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    __pyx_t_13 = NULL;
    if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
    __PYX_ERR(0, 439, __pyx_L1_error)
    __pyx_L6_unpacking_done:;
  }
  if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 439, __pyx_L1_error)
  __pyx_t_2 = __pyx_PyFloat_AsDouble(__pyx_t_5); if (unlikely((__pyx_t_2 == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 439, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  if (!(likely(((__pyx_t_3) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_3, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 439, __pyx_L1_error)
  __pyx_t_14 = __Pyx_PyInt_As_int(__pyx_t_8); if (unlikely((__pyx_t_14 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 439, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  __pyx_t_15 = ((PyArrayObject *)__pyx_t_1);
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_Z0.rcbuffer->pybuffer);
    __pyx_t_16 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_Z0.rcbuffer->pybuffer, (PyObject*)__pyx_t_15, &__Pyx_TypeInfo_double, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack);
    if (unlikely(__pyx_t_16 < 0)) {
      PyErr_Fetch(&__pyx_t_17, &__pyx_t_18, &__pyx_t_19);
      if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_Z0.rcbuffer->pybuffer, (PyObject*)__pyx_v_Z0, &__Pyx_TypeInfo_double, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {
        Py_XDECREF(__pyx_t_17); Py_XDECREF(__pyx_t_18); Py_XDECREF(__pyx_t_19);
        __Pyx_RaiseBufferFallbackError();
      } else {
        PyErr_Restore(__pyx_t_17, __pyx_t_18, __pyx_t_19);
      }
    }
    __pyx_pybuffernd_Z0.diminfo[0].strides = __pyx_pybuffernd_Z0.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_Z0.diminfo[0].shape = __pyx_pybuffernd_Z0.rcbuffer->pybuffer.shape[0];
    if (unlikely(__pyx_t_16 < 0)) __PYX_ERR(0, 439, __pyx_L1_error)
  }
  __pyx_t_15 = 0;
  __pyx_v_Z0 = ((PyArrayObject *)__pyx_t_1);
  __pyx_t_1 = 0;
  __pyx_v_dZ0r = __pyx_t_2;
  __pyx_t_20 = ((PyArrayObject *)__pyx_t_3);
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_bla.rcbuffer->pybuffer);
    __pyx_t_16 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_bla.rcbuffer->pybuffer, (PyObject*)__pyx_t_20, &__Pyx_TypeInfo_long, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack);
    if (unlikely(__pyx_t_16 < 0)) {
      PyErr_Fetch(&__pyx_t_19, &__pyx_t_18, &__pyx_t_17);
      if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_bla.rcbuffer->pybuffer, (PyObject*)__pyx_v_bla, &__Pyx_TypeInfo_long, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {
        Py_XDECREF(__pyx_t_19); Py_XDECREF(__pyx_t_18); Py_XDECREF(__pyx_t_17);
        __Pyx_RaiseBufferFallbackError();
      } else {
        PyErr_Restore(__pyx_t_19, __pyx_t_18, __pyx_t_17);
      }
    }
    __pyx_pybuffernd_bla.diminfo[0].strides = __pyx_pybuffernd_bla.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_bla.diminfo[0].shape = __pyx_pybuffernd_bla.rcbuffer->pybuffer.shape[0];
    if (unlikely(__pyx_t_16 < 0)) __PYX_ERR(0, 439, __pyx_L1_error)
  }
  __pyx_t_20 = 0;
  __Pyx_DECREF_SET(__pyx_v_bla, ((PyArrayObject *)__pyx_t_3));
  __pyx_t_3 = 0;
  __pyx_v_NZ0 = __pyx_t_14;
 440: 
+441:     PtsM, dSM, indM, NL, dLr, Rref, dRPhir, nRPhi0, VPbis = _Ves_Smesh_Tor_SubFromD_cython(dL, dRPhi, VPoly,
  __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_Ves_Smesh_Tor_SubFromD_cython); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 441, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_8 = PyFloat_FromDouble(__pyx_v_dL); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 441, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);
  __pyx_t_3 = PyFloat_FromDouble(__pyx_v_dRPhi); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 441, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_5 = __pyx_memoryview_fromslice(__pyx_v_VPoly, 2, (PyObject *(*)(char *)) __pyx_memview_get_double, (int (*)(char *, PyObject *)) __pyx_memview_set_double, 0);; if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 441, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_t_1 = PyTuple_New(3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 441, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_8);
  PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_8);
  __Pyx_GIVEREF(__pyx_t_3);
  PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_t_3);
  __Pyx_GIVEREF(__pyx_t_5);
  PyTuple_SET_ITEM(__pyx_t_1, 2, __pyx_t_5);
  __pyx_t_8 = 0;
  __pyx_t_3 = 0;
  __pyx_t_5 = 0;
/* … */
  __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_1, __pyx_t_5); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 441, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  if ((likely(PyTuple_CheckExact(__pyx_t_3))) || (PyList_CheckExact(__pyx_t_3))) {
    PyObject* sequence = __pyx_t_3;
    #if !CYTHON_COMPILING_IN_PYPY
    Py_ssize_t size = Py_SIZE(sequence);
    #else
    Py_ssize_t size = PySequence_Size(sequence);
    #endif
    if (unlikely(size != 9)) {
      if (size > 9) __Pyx_RaiseTooManyValuesError(9);
      else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
      __PYX_ERR(0, 441, __pyx_L1_error)
    }
    #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
    if (likely(PyTuple_CheckExact(sequence))) {
      __pyx_t_5 = PyTuple_GET_ITEM(sequence, 0); 
      __pyx_t_1 = PyTuple_GET_ITEM(sequence, 1); 
      __pyx_t_4 = PyTuple_GET_ITEM(sequence, 2); 
      __pyx_t_8 = PyTuple_GET_ITEM(sequence, 3); 
      __pyx_t_7 = PyTuple_GET_ITEM(sequence, 4); 
      __pyx_t_10 = PyTuple_GET_ITEM(sequence, 5); 
      __pyx_t_11 = PyTuple_GET_ITEM(sequence, 6); 
      __pyx_t_12 = PyTuple_GET_ITEM(sequence, 7); 
      __pyx_t_21 = PyTuple_GET_ITEM(sequence, 8); 
    } else {
      __pyx_t_5 = PyList_GET_ITEM(sequence, 0); 
      __pyx_t_1 = PyList_GET_ITEM(sequence, 1); 
      __pyx_t_4 = PyList_GET_ITEM(sequence, 2); 
      __pyx_t_8 = PyList_GET_ITEM(sequence, 3); 
      __pyx_t_7 = PyList_GET_ITEM(sequence, 4); 
      __pyx_t_10 = PyList_GET_ITEM(sequence, 5); 
      __pyx_t_11 = PyList_GET_ITEM(sequence, 6); 
      __pyx_t_12 = PyList_GET_ITEM(sequence, 7); 
      __pyx_t_21 = PyList_GET_ITEM(sequence, 8); 
    }
    __Pyx_INCREF(__pyx_t_5);
    __Pyx_INCREF(__pyx_t_1);
    __Pyx_INCREF(__pyx_t_4);
    __Pyx_INCREF(__pyx_t_8);
    __Pyx_INCREF(__pyx_t_7);
    __Pyx_INCREF(__pyx_t_10);
    __Pyx_INCREF(__pyx_t_11);
    __Pyx_INCREF(__pyx_t_12);
    __Pyx_INCREF(__pyx_t_21);
    #else
    {
      Py_ssize_t i;
      PyObject** temps[9] = {&__pyx_t_5,&__pyx_t_1,&__pyx_t_4,&__pyx_t_8,&__pyx_t_7,&__pyx_t_10,&__pyx_t_11,&__pyx_t_12,&__pyx_t_21};
      for (i=0; i < 9; i++) {
        PyObject* item = PySequence_ITEM(sequence, i); if (unlikely(!item)) __PYX_ERR(0, 441, __pyx_L1_error)
        __Pyx_GOTREF(item);
        *(temps[i]) = item;
      }
    }
    #endif
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  } else {
    Py_ssize_t index = -1;
    PyObject** temps[9] = {&__pyx_t_5,&__pyx_t_1,&__pyx_t_4,&__pyx_t_8,&__pyx_t_7,&__pyx_t_10,&__pyx_t_11,&__pyx_t_12,&__pyx_t_21};
    __pyx_t_22 = PyObject_GetIter(__pyx_t_3); if (unlikely(!__pyx_t_22)) __PYX_ERR(0, 441, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_22);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_t_13 = Py_TYPE(__pyx_t_22)->tp_iternext;
    for (index=0; index < 9; index++) {
      PyObject* item = __pyx_t_13(__pyx_t_22); if (unlikely(!item)) goto __pyx_L7_unpacking_failed;
      __Pyx_GOTREF(item);
      *(temps[index]) = item;
    }
    if (__Pyx_IternextUnpackEndCheck(__pyx_t_13(__pyx_t_22), 9) < 0) __PYX_ERR(0, 441, __pyx_L1_error)
    __pyx_t_13 = NULL;
    __Pyx_DECREF(__pyx_t_22); __pyx_t_22 = 0;
    goto __pyx_L8_unpacking_done;
    __pyx_L7_unpacking_failed:;
    __Pyx_DECREF(__pyx_t_22); __pyx_t_22 = 0;
    __pyx_t_13 = NULL;
    if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
    __PYX_ERR(0, 441, __pyx_L1_error)
    __pyx_L8_unpacking_done:;
  }
  if (!(likely(((__pyx_t_5) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_5, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 441, __pyx_L1_error)
  if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 441, __pyx_L1_error)
  if (!(likely(((__pyx_t_4) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_4, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 441, __pyx_L1_error)
  if (!(likely(((__pyx_t_8) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_8, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 441, __pyx_L1_error)
  if (!(likely(((__pyx_t_7) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_7, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 441, __pyx_L1_error)
  if (!(likely(((__pyx_t_10) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_10, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 441, __pyx_L1_error)
  if (!(likely(((__pyx_t_11) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_11, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 441, __pyx_L1_error)
  if (!(likely(((__pyx_t_21) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_21, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 441, __pyx_L1_error)
  __pyx_t_23 = ((PyArrayObject *)__pyx_t_5);
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_PtsM.rcbuffer->pybuffer);
    __pyx_t_14 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_PtsM.rcbuffer->pybuffer, (PyObject*)__pyx_t_23, &__Pyx_TypeInfo_double, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack);
    if (unlikely(__pyx_t_14 < 0)) {
      PyErr_Fetch(&__pyx_t_17, &__pyx_t_18, &__pyx_t_19);
      if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_PtsM.rcbuffer->pybuffer, (PyObject*)__pyx_v_PtsM, &__Pyx_TypeInfo_double, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) {
        Py_XDECREF(__pyx_t_17); Py_XDECREF(__pyx_t_18); Py_XDECREF(__pyx_t_19);
        __Pyx_RaiseBufferFallbackError();
      } else {
        PyErr_Restore(__pyx_t_17, __pyx_t_18, __pyx_t_19);
      }
    }
    __pyx_pybuffernd_PtsM.diminfo[0].strides = __pyx_pybuffernd_PtsM.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_PtsM.diminfo[0].shape = __pyx_pybuffernd_PtsM.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_PtsM.diminfo[1].strides = __pyx_pybuffernd_PtsM.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_PtsM.diminfo[1].shape = __pyx_pybuffernd_PtsM.rcbuffer->pybuffer.shape[1];
    if (unlikely(__pyx_t_14 < 0)) __PYX_ERR(0, 441, __pyx_L1_error)
  }
  __pyx_t_23 = 0;
  __pyx_v_PtsM = ((PyArrayObject *)__pyx_t_5);
  __pyx_t_5 = 0;
  __pyx_t_15 = ((PyArrayObject *)__pyx_t_1);
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_dSM.rcbuffer->pybuffer);
    __pyx_t_14 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_dSM.rcbuffer->pybuffer, (PyObject*)__pyx_t_15, &__Pyx_TypeInfo_double, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack);
    if (unlikely(__pyx_t_14 < 0)) {
      PyErr_Fetch(&__pyx_t_19, &__pyx_t_18, &__pyx_t_17);
      if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_dSM.rcbuffer->pybuffer, (PyObject*)__pyx_v_dSM, &__Pyx_TypeInfo_double, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {
        Py_XDECREF(__pyx_t_19); Py_XDECREF(__pyx_t_18); Py_XDECREF(__pyx_t_17);
        __Pyx_RaiseBufferFallbackError();
      } else {
        PyErr_Restore(__pyx_t_19, __pyx_t_18, __pyx_t_17);
      }
    }
    __pyx_pybuffernd_dSM.diminfo[0].strides = __pyx_pybuffernd_dSM.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_dSM.diminfo[0].shape = __pyx_pybuffernd_dSM.rcbuffer->pybuffer.shape[0];
    if (unlikely(__pyx_t_14 < 0)) __PYX_ERR(0, 441, __pyx_L1_error)
  }
  __pyx_t_15 = 0;
  __pyx_v_dSM = ((PyArrayObject *)__pyx_t_1);
  __pyx_t_1 = 0;
  __pyx_t_20 = ((PyArrayObject *)__pyx_t_4);
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_indM.rcbuffer->pybuffer);
    __pyx_t_14 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_indM.rcbuffer->pybuffer, (PyObject*)__pyx_t_20, &__Pyx_TypeInfo_long, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack);
    if (unlikely(__pyx_t_14 < 0)) {
      PyErr_Fetch(&__pyx_t_17, &__pyx_t_18, &__pyx_t_19);
      if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_indM.rcbuffer->pybuffer, (PyObject*)__pyx_v_indM, &__Pyx_TypeInfo_long, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {
        Py_XDECREF(__pyx_t_17); Py_XDECREF(__pyx_t_18); Py_XDECREF(__pyx_t_19);
        __Pyx_RaiseBufferFallbackError();
      } else {
        PyErr_Restore(__pyx_t_17, __pyx_t_18, __pyx_t_19);
      }
    }
    __pyx_pybuffernd_indM.diminfo[0].strides = __pyx_pybuffernd_indM.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_indM.diminfo[0].shape = __pyx_pybuffernd_indM.rcbuffer->pybuffer.shape[0];
    if (unlikely(__pyx_t_14 < 0)) __PYX_ERR(0, 441, __pyx_L1_error)
  }
  __pyx_t_20 = 0;
  __pyx_v_indM = ((PyArrayObject *)__pyx_t_4);
  __pyx_t_4 = 0;
  __pyx_t_20 = ((PyArrayObject *)__pyx_t_8);
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_NL.rcbuffer->pybuffer);
    __pyx_t_14 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_NL.rcbuffer->pybuffer, (PyObject*)__pyx_t_20, &__Pyx_TypeInfo_long, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack);
    if (unlikely(__pyx_t_14 < 0)) {
      PyErr_Fetch(&__pyx_t_19, &__pyx_t_18, &__pyx_t_17);
      if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_NL.rcbuffer->pybuffer, (PyObject*)__pyx_v_NL, &__Pyx_TypeInfo_long, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {
        Py_XDECREF(__pyx_t_19); Py_XDECREF(__pyx_t_18); Py_XDECREF(__pyx_t_17);
        __Pyx_RaiseBufferFallbackError();
      } else {
        PyErr_Restore(__pyx_t_19, __pyx_t_18, __pyx_t_17);
      }
    }
    __pyx_pybuffernd_NL.diminfo[0].strides = __pyx_pybuffernd_NL.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_NL.diminfo[0].shape = __pyx_pybuffernd_NL.rcbuffer->pybuffer.shape[0];
    if (unlikely(__pyx_t_14 < 0)) __PYX_ERR(0, 441, __pyx_L1_error)
  }
  __pyx_t_20 = 0;
  __pyx_v_NL = ((PyArrayObject *)__pyx_t_8);
  __pyx_t_8 = 0;
  __pyx_t_15 = ((PyArrayObject *)__pyx_t_7);
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_dLr.rcbuffer->pybuffer);
    __pyx_t_14 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_dLr.rcbuffer->pybuffer, (PyObject*)__pyx_t_15, &__Pyx_TypeInfo_double, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack);
    if (unlikely(__pyx_t_14 < 0)) {
      PyErr_Fetch(&__pyx_t_17, &__pyx_t_18, &__pyx_t_19);
      if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_dLr.rcbuffer->pybuffer, (PyObject*)__pyx_v_dLr, &__Pyx_TypeInfo_double, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {
        Py_XDECREF(__pyx_t_17); Py_XDECREF(__pyx_t_18); Py_XDECREF(__pyx_t_19);
        __Pyx_RaiseBufferFallbackError();
      } else {
        PyErr_Restore(__pyx_t_17, __pyx_t_18, __pyx_t_19);
      }
    }
    __pyx_pybuffernd_dLr.diminfo[0].strides = __pyx_pybuffernd_dLr.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_dLr.diminfo[0].shape = __pyx_pybuffernd_dLr.rcbuffer->pybuffer.shape[0];
    if (unlikely(__pyx_t_14 < 0)) __PYX_ERR(0, 441, __pyx_L1_error)
  }
  __pyx_t_15 = 0;
  __pyx_v_dLr = ((PyArrayObject *)__pyx_t_7);
  __pyx_t_7 = 0;
  __pyx_t_15 = ((PyArrayObject *)__pyx_t_10);
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_Rref.rcbuffer->pybuffer);
    __pyx_t_14 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_Rref.rcbuffer->pybuffer, (PyObject*)__pyx_t_15, &__Pyx_TypeInfo_double, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack);
    if (unlikely(__pyx_t_14 < 0)) {
      PyErr_Fetch(&__pyx_t_19, &__pyx_t_18, &__pyx_t_17);
      if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_Rref.rcbuffer->pybuffer, (PyObject*)__pyx_v_Rref, &__Pyx_TypeInfo_double, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {
        Py_XDECREF(__pyx_t_19); Py_XDECREF(__pyx_t_18); Py_XDECREF(__pyx_t_17);
        __Pyx_RaiseBufferFallbackError();
      } else {
        PyErr_Restore(__pyx_t_19, __pyx_t_18, __pyx_t_17);
      }
    }
    __pyx_pybuffernd_Rref.diminfo[0].strides = __pyx_pybuffernd_Rref.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_Rref.diminfo[0].shape = __pyx_pybuffernd_Rref.rcbuffer->pybuffer.shape[0];
    if (unlikely(__pyx_t_14 < 0)) __PYX_ERR(0, 441, __pyx_L1_error)
  }
  __pyx_t_15 = 0;
  __pyx_v_Rref = ((PyArrayObject *)__pyx_t_10);
  __pyx_t_10 = 0;
  __pyx_t_15 = ((PyArrayObject *)__pyx_t_11);
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_dRPhir.rcbuffer->pybuffer);
    __pyx_t_14 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_dRPhir.rcbuffer->pybuffer, (PyObject*)__pyx_t_15, &__Pyx_TypeInfo_double, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack);
    if (unlikely(__pyx_t_14 < 0)) {
      PyErr_Fetch(&__pyx_t_17, &__pyx_t_18, &__pyx_t_19);
      if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_dRPhir.rcbuffer->pybuffer, (PyObject*)__pyx_v_dRPhir, &__Pyx_TypeInfo_double, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {
        Py_XDECREF(__pyx_t_17); Py_XDECREF(__pyx_t_18); Py_XDECREF(__pyx_t_19);
        __Pyx_RaiseBufferFallbackError();
      } else {
        PyErr_Restore(__pyx_t_17, __pyx_t_18, __pyx_t_19);
      }
    }
    __pyx_pybuffernd_dRPhir.diminfo[0].strides = __pyx_pybuffernd_dRPhir.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_dRPhir.diminfo[0].shape = __pyx_pybuffernd_dRPhir.rcbuffer->pybuffer.shape[0];
    if (unlikely(__pyx_t_14 < 0)) __PYX_ERR(0, 441, __pyx_L1_error)
  }
  __pyx_t_15 = 0;
  __pyx_v_dRPhir = ((PyArrayObject *)__pyx_t_11);
  __pyx_t_11 = 0;
  __pyx_v_nRPhi0 = __pyx_t_12;
  __pyx_t_12 = 0;
  __pyx_t_23 = ((PyArrayObject *)__pyx_t_21);
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_VPbis.rcbuffer->pybuffer);
    __pyx_t_14 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_VPbis.rcbuffer->pybuffer, (PyObject*)__pyx_t_23, &__Pyx_TypeInfo_double, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack);
    if (unlikely(__pyx_t_14 < 0)) {
      PyErr_Fetch(&__pyx_t_19, &__pyx_t_18, &__pyx_t_17);
      if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_VPbis.rcbuffer->pybuffer, (PyObject*)__pyx_v_VPbis, &__Pyx_TypeInfo_double, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) {
        Py_XDECREF(__pyx_t_19); Py_XDECREF(__pyx_t_18); Py_XDECREF(__pyx_t_17);
        __Pyx_RaiseBufferFallbackError();
      } else {
        PyErr_Restore(__pyx_t_19, __pyx_t_18, __pyx_t_17);
      }
    }
    __pyx_pybuffernd_VPbis.diminfo[0].strides = __pyx_pybuffernd_VPbis.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_VPbis.diminfo[0].shape = __pyx_pybuffernd_VPbis.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_VPbis.diminfo[1].strides = __pyx_pybuffernd_VPbis.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_VPbis.diminfo[1].shape = __pyx_pybuffernd_VPbis.rcbuffer->pybuffer.shape[1];
    if (unlikely(__pyx_t_14 < 0)) __PYX_ERR(0, 441, __pyx_L1_error)
  }
  __pyx_t_23 = 0;
  __pyx_v_VPbis = ((PyArrayObject *)__pyx_t_21);
  __pyx_t_21 = 0;
+442:                                                                                            DR=None, DZ=None, DPhi=None,
  __pyx_t_5 = PyDict_New(); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 442, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  if (PyDict_SetItem(__pyx_t_5, __pyx_n_s_DR, Py_None) < 0) __PYX_ERR(0, 442, __pyx_L1_error)
  if (PyDict_SetItem(__pyx_t_5, __pyx_n_s_DZ, Py_None) < 0) __PYX_ERR(0, 442, __pyx_L1_error)
  if (PyDict_SetItem(__pyx_t_5, __pyx_n_s_DPhi, Py_None) < 0) __PYX_ERR(0, 442, __pyx_L1_error)
+443:                                                                                            DIn=DIn, VIn=VIn, PhiMinMax=PhiMinMax,
  __pyx_t_3 = PyFloat_FromDouble(__pyx_v_DIn); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 443, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  if (PyDict_SetItem(__pyx_t_5, __pyx_n_s_DIn, __pyx_t_3) < 0) __PYX_ERR(0, 442, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  if (PyDict_SetItem(__pyx_t_5, __pyx_n_s_VIn, __pyx_v_VIn) < 0) __PYX_ERR(0, 442, __pyx_L1_error)
  __pyx_t_3 = __pyx_memoryview_fromslice(__pyx_v_PhiMinMax, 1, (PyObject *(*)(char *)) __pyx_memview_get_double, (int (*)(char *, PyObject *)) __pyx_memview_set_double, 0);; if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 443, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  if (PyDict_SetItem(__pyx_t_5, __pyx_n_s_PhiMinMax, __pyx_t_3) < 0) __PYX_ERR(0, 442, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+444:                                                                                            Out=Out, margin=margin)
  if (PyDict_SetItem(__pyx_t_5, __pyx_n_s_Out, __pyx_v_Out) < 0) __PYX_ERR(0, 442, __pyx_L1_error)
  __pyx_t_3 = PyFloat_FromDouble(__pyx_v_margin); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 444, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  if (PyDict_SetItem(__pyx_t_5, __pyx_n_s_margin, __pyx_t_3) < 0) __PYX_ERR(0, 442, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
 445:     # First face
+446:     ii = (ind<NR0*NZ0).nonzero()[0]
  __pyx_t_21 = __Pyx_PyInt_From_int((__pyx_v_NR0 * __pyx_v_NZ0)); if (unlikely(!__pyx_t_21)) __PYX_ERR(0, 446, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_21);
  __pyx_t_12 = PyObject_RichCompare(((PyObject *)__pyx_v_ind), __pyx_t_21, Py_LT); __Pyx_XGOTREF(__pyx_t_12); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 446, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_21); __pyx_t_21 = 0;
  __pyx_t_21 = __Pyx_PyObject_GetAttrStr(__pyx_t_12, __pyx_n_s_nonzero); if (unlikely(!__pyx_t_21)) __PYX_ERR(0, 446, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_21);
  __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
  __pyx_t_12 = NULL;
  if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_21))) {
    __pyx_t_12 = PyMethod_GET_SELF(__pyx_t_21);
    if (likely(__pyx_t_12)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_21);
      __Pyx_INCREF(__pyx_t_12);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_21, function);
    }
  }
  if (__pyx_t_12) {
    __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_t_21, __pyx_t_12); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 446, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
  } else {
    __pyx_t_3 = __Pyx_PyObject_CallNoArg(__pyx_t_21); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 446, __pyx_L1_error)
  }
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_21); __pyx_t_21 = 0;
  __pyx_t_21 = __Pyx_GetItemInt(__pyx_t_3, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 0); if (unlikely(!__pyx_t_21)) __PYX_ERR(0, 446, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_21);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_v_ii = __pyx_t_21;
  __pyx_t_21 = 0;
+447:     nii = len(ii)
  __pyx_t_24 = PyObject_Length(__pyx_v_ii); if (unlikely(__pyx_t_24 == -1)) __PYX_ERR(0, 447, __pyx_L1_error)
  __pyx_v_nii = __pyx_t_24;
+448:     if nii>0:
  __pyx_t_25 = ((__pyx_v_nii > 0) != 0);
  if (__pyx_t_25) {
/* … */
  }
+449:         indZ0 = ind[ii] // NR0
    __pyx_t_21 = PyObject_GetItem(((PyObject *)__pyx_v_ind), __pyx_v_ii); if (unlikely(!__pyx_t_21)) __PYX_ERR(0, 449, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_21);
    __pyx_t_3 = __Pyx_PyInt_From_int(__pyx_v_NR0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 449, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_12 = PyNumber_FloorDivide(__pyx_t_21, __pyx_t_3); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 449, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_12);
    __Pyx_DECREF(__pyx_t_21); __pyx_t_21 = 0;
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    if (!(likely(((__pyx_t_12) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_12, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 449, __pyx_L1_error)
    __pyx_t_20 = ((PyArrayObject *)__pyx_t_12);
    {
      __Pyx_BufFmt_StackElem __pyx_stack[1];
      __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_indZ0.rcbuffer->pybuffer);
      __pyx_t_14 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_indZ0.rcbuffer->pybuffer, (PyObject*)__pyx_t_20, &__Pyx_TypeInfo_long, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack);
      if (unlikely(__pyx_t_14 < 0)) {
        PyErr_Fetch(&__pyx_t_17, &__pyx_t_18, &__pyx_t_19);
        if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_indZ0.rcbuffer->pybuffer, (PyObject*)__pyx_v_indZ0, &__Pyx_TypeInfo_long, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {
          Py_XDECREF(__pyx_t_17); Py_XDECREF(__pyx_t_18); Py_XDECREF(__pyx_t_19);
          __Pyx_RaiseBufferFallbackError();
        } else {
          PyErr_Restore(__pyx_t_17, __pyx_t_18, __pyx_t_19);
        }
      }
      __pyx_pybuffernd_indZ0.diminfo[0].strides = __pyx_pybuffernd_indZ0.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_indZ0.diminfo[0].shape = __pyx_pybuffernd_indZ0.rcbuffer->pybuffer.shape[0];
      if (unlikely(__pyx_t_14 < 0)) __PYX_ERR(0, 449, __pyx_L1_error)
    }
    __pyx_t_20 = 0;
    __pyx_v_indZ0 = ((PyArrayObject *)__pyx_t_12);
    __pyx_t_12 = 0;
+450:         indR0 = (ind[ii]-indZ0*NR0)
    __pyx_t_12 = PyObject_GetItem(((PyObject *)__pyx_v_ind), __pyx_v_ii); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 450, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_12);
    __pyx_t_3 = __Pyx_PyInt_From_int(__pyx_v_NR0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 450, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_21 = PyNumber_Multiply(((PyObject *)__pyx_v_indZ0), __pyx_t_3); if (unlikely(!__pyx_t_21)) __PYX_ERR(0, 450, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_21);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_t_3 = PyNumber_Subtract(__pyx_t_12, __pyx_t_21); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 450, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
    __Pyx_DECREF(__pyx_t_21); __pyx_t_21 = 0;
    if (!(likely(((__pyx_t_3) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_3, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 450, __pyx_L1_error)
    __pyx_t_20 = ((PyArrayObject *)__pyx_t_3);
    {
      __Pyx_BufFmt_StackElem __pyx_stack[1];
      __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_indR0.rcbuffer->pybuffer);
      __pyx_t_14 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_indR0.rcbuffer->pybuffer, (PyObject*)__pyx_t_20, &__Pyx_TypeInfo_long, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack);
      if (unlikely(__pyx_t_14 < 0)) {
        PyErr_Fetch(&__pyx_t_19, &__pyx_t_18, &__pyx_t_17);
        if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_indR0.rcbuffer->pybuffer, (PyObject*)__pyx_v_indR0, &__Pyx_TypeInfo_long, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {
          Py_XDECREF(__pyx_t_19); Py_XDECREF(__pyx_t_18); Py_XDECREF(__pyx_t_17);
          __Pyx_RaiseBufferFallbackError();
        } else {
          PyErr_Restore(__pyx_t_19, __pyx_t_18, __pyx_t_17);
        }
      }
      __pyx_pybuffernd_indR0.diminfo[0].strides = __pyx_pybuffernd_indR0.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_indR0.diminfo[0].shape = __pyx_pybuffernd_indR0.rcbuffer->pybuffer.shape[0];
      if (unlikely(__pyx_t_14 < 0)) __PYX_ERR(0, 450, __pyx_L1_error)
    }
    __pyx_t_20 = 0;
    __pyx_v_indR0 = ((PyArrayObject *)__pyx_t_3);
    __pyx_t_3 = 0;
+451:         if Out.lower()=='(x,y,z)':
    __pyx_t_21 = __Pyx_PyObject_GetAttrStr(__pyx_v_Out, __pyx_n_s_lower); if (unlikely(!__pyx_t_21)) __PYX_ERR(0, 451, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_21);
    __pyx_t_12 = NULL;
    if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_21))) {
      __pyx_t_12 = PyMethod_GET_SELF(__pyx_t_21);
      if (likely(__pyx_t_12)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_21);
        __Pyx_INCREF(__pyx_t_12);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_21, function);
      }
    }
    if (__pyx_t_12) {
      __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_t_21, __pyx_t_12); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 451, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
    } else {
      __pyx_t_3 = __Pyx_PyObject_CallNoArg(__pyx_t_21); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 451, __pyx_L1_error)
    }
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_21); __pyx_t_21 = 0;
    __pyx_t_25 = (__Pyx_PyUnicode_Equals(__pyx_t_3, __pyx_kp_u_x_y_z, Py_EQ)); if (unlikely(__pyx_t_25 < 0)) __PYX_ERR(0, 451, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    if (__pyx_t_25) {
/* … */
      goto __pyx_L10;
    }
+452:             pts = np.array([R0[indR0]*Ccos(PhiMinMax[0]+Dphi), R0[indR0]*Csin(PhiMinMax[0]+Dphi), Z0[indZ0]])
      __pyx_t_21 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_21)) __PYX_ERR(0, 452, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_21);
      __pyx_t_12 = __Pyx_PyObject_GetAttrStr(__pyx_t_21, __pyx_n_s_array); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 452, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_12);
      __Pyx_DECREF(__pyx_t_21); __pyx_t_21 = 0;
      __pyx_t_21 = PyObject_GetItem(((PyObject *)__pyx_v_R0), ((PyObject *)__pyx_v_indR0)); if (unlikely(!__pyx_t_21)) __PYX_ERR(0, 452, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_21);
      __pyx_t_26 = 0;
      __pyx_t_11 = PyFloat_FromDouble(cos(((*((double *) ( /* dim=0 */ ((char *) (((double *) __pyx_v_PhiMinMax.data) + __pyx_t_26)) ))) + __pyx_v_Dphi))); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 452, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_11);
      __pyx_t_10 = PyNumber_Multiply(__pyx_t_21, __pyx_t_11); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 452, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_10);
      __Pyx_DECREF(__pyx_t_21); __pyx_t_21 = 0;
      __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
      __pyx_t_11 = PyObject_GetItem(((PyObject *)__pyx_v_R0), ((PyObject *)__pyx_v_indR0)); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 452, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_11);
      __pyx_t_27 = 0;
      __pyx_t_21 = PyFloat_FromDouble(sin(((*((double *) ( /* dim=0 */ ((char *) (((double *) __pyx_v_PhiMinMax.data) + __pyx_t_27)) ))) + __pyx_v_Dphi))); if (unlikely(!__pyx_t_21)) __PYX_ERR(0, 452, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_21);
      __pyx_t_7 = PyNumber_Multiply(__pyx_t_11, __pyx_t_21); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 452, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_7);
      __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
      __Pyx_DECREF(__pyx_t_21); __pyx_t_21 = 0;
      __pyx_t_21 = PyObject_GetItem(((PyObject *)__pyx_v_Z0), ((PyObject *)__pyx_v_indZ0)); if (unlikely(!__pyx_t_21)) __PYX_ERR(0, 452, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_21);
      __pyx_t_11 = PyList_New(3); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 452, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_11);
      __Pyx_GIVEREF(__pyx_t_10);
      PyList_SET_ITEM(__pyx_t_11, 0, __pyx_t_10);
      __Pyx_GIVEREF(__pyx_t_7);
      PyList_SET_ITEM(__pyx_t_11, 1, __pyx_t_7);
      __Pyx_GIVEREF(__pyx_t_21);
      PyList_SET_ITEM(__pyx_t_11, 2, __pyx_t_21);
      __pyx_t_10 = 0;
      __pyx_t_7 = 0;
      __pyx_t_21 = 0;
      __pyx_t_21 = NULL;
      if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_12))) {
        __pyx_t_21 = PyMethod_GET_SELF(__pyx_t_12);
        if (likely(__pyx_t_21)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_12);
          __Pyx_INCREF(__pyx_t_21);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_12, function);
        }
      }
      if (!__pyx_t_21) {
        __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_t_12, __pyx_t_11); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 452, __pyx_L1_error)
        __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
        __Pyx_GOTREF(__pyx_t_3);
      } else {
        #if CYTHON_FAST_PYCALL
        if (PyFunction_Check(__pyx_t_12)) {
          PyObject *__pyx_temp[2] = {__pyx_t_21, __pyx_t_11};
          __pyx_t_3 = __Pyx_PyFunction_FastCall(__pyx_t_12, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 452, __pyx_L1_error)
          __Pyx_XDECREF(__pyx_t_21); __pyx_t_21 = 0;
          __Pyx_GOTREF(__pyx_t_3);
          __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
        } else
        #endif
        #if CYTHON_FAST_PYCCALL
        if (__Pyx_PyFastCFunction_Check(__pyx_t_12)) {
          PyObject *__pyx_temp[2] = {__pyx_t_21, __pyx_t_11};
          __pyx_t_3 = __Pyx_PyCFunction_FastCall(__pyx_t_12, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 452, __pyx_L1_error)
          __Pyx_XDECREF(__pyx_t_21); __pyx_t_21 = 0;
          __Pyx_GOTREF(__pyx_t_3);
          __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
        } else
        #endif
        {
          __pyx_t_7 = PyTuple_New(1+1); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 452, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_7);
          __Pyx_GIVEREF(__pyx_t_21); PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_21); __pyx_t_21 = NULL;
          __Pyx_GIVEREF(__pyx_t_11);
          PyTuple_SET_ITEM(__pyx_t_7, 0+1, __pyx_t_11);
          __pyx_t_11 = 0;
          __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_12, __pyx_t_7, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 452, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_3);
          __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
        }
      }
      __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
      if (!(likely(((__pyx_t_3) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_3, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 452, __pyx_L1_error)
      __pyx_t_23 = ((PyArrayObject *)__pyx_t_3);
      {
        __Pyx_BufFmt_StackElem __pyx_stack[1];
        __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_pts.rcbuffer->pybuffer);
        __pyx_t_14 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_pts.rcbuffer->pybuffer, (PyObject*)__pyx_t_23, &__Pyx_TypeInfo_double, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack);
        if (unlikely(__pyx_t_14 < 0)) {
          PyErr_Fetch(&__pyx_t_17, &__pyx_t_18, &__pyx_t_19);
          if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_pts.rcbuffer->pybuffer, (PyObject*)__pyx_v_pts, &__Pyx_TypeInfo_double, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) {
            Py_XDECREF(__pyx_t_17); Py_XDECREF(__pyx_t_18); Py_XDECREF(__pyx_t_19);
            __Pyx_RaiseBufferFallbackError();
          } else {
            PyErr_Restore(__pyx_t_17, __pyx_t_18, __pyx_t_19);
          }
        }
        __pyx_pybuffernd_pts.diminfo[0].strides = __pyx_pybuffernd_pts.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_pts.diminfo[0].shape = __pyx_pybuffernd_pts.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_pts.diminfo[1].strides = __pyx_pybuffernd_pts.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_pts.diminfo[1].shape = __pyx_pybuffernd_pts.rcbuffer->pybuffer.shape[1];
        if (unlikely(__pyx_t_14 < 0)) __PYX_ERR(0, 452, __pyx_L1_error)
      }
      __pyx_t_23 = 0;
      __pyx_v_pts = ((PyArrayObject *)__pyx_t_3);
      __pyx_t_3 = 0;
 453:         else:
+454:             pts = np.array([R0[indR0], Z0[indZ0], (PhiMinMax[0]+Dphi)*np.ones((nii,))])
    /*else*/ {
      __pyx_t_12 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 454, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_12);
      __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_t_12, __pyx_n_s_array); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 454, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_7);
      __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
      __pyx_t_12 = PyObject_GetItem(((PyObject *)__pyx_v_R0), ((PyObject *)__pyx_v_indR0)); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 454, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_12);
      __pyx_t_11 = PyObject_GetItem(((PyObject *)__pyx_v_Z0), ((PyObject *)__pyx_v_indZ0)); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 454, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_11);
      __pyx_t_28 = 0;
      __pyx_t_21 = PyFloat_FromDouble(((*((double *) ( /* dim=0 */ ((char *) (((double *) __pyx_v_PhiMinMax.data) + __pyx_t_28)) ))) + __pyx_v_Dphi)); if (unlikely(!__pyx_t_21)) __PYX_ERR(0, 454, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_21);
      __pyx_t_8 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 454, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_8);
      __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_8, __pyx_n_s_ones); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 454, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
      __pyx_t_8 = PyInt_FromSsize_t(__pyx_v_nii); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 454, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_8);
      __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 454, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_GIVEREF(__pyx_t_8);
      PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_8);
      __pyx_t_8 = 0;
      __pyx_t_8 = NULL;
      if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_4))) {
        __pyx_t_8 = PyMethod_GET_SELF(__pyx_t_4);
        if (likely(__pyx_t_8)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
          __Pyx_INCREF(__pyx_t_8);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_4, function);
        }
      }
      if (!__pyx_t_8) {
        __pyx_t_10 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_1); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 454, __pyx_L1_error)
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        __Pyx_GOTREF(__pyx_t_10);
      } else {
        #if CYTHON_FAST_PYCALL
        if (PyFunction_Check(__pyx_t_4)) {
          PyObject *__pyx_temp[2] = {__pyx_t_8, __pyx_t_1};
          __pyx_t_10 = __Pyx_PyFunction_FastCall(__pyx_t_4, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 454, __pyx_L1_error)
          __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
          __Pyx_GOTREF(__pyx_t_10);
          __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        } else
        #endif
        #if CYTHON_FAST_PYCCALL
        if (__Pyx_PyFastCFunction_Check(__pyx_t_4)) {
          PyObject *__pyx_temp[2] = {__pyx_t_8, __pyx_t_1};
          __pyx_t_10 = __Pyx_PyCFunction_FastCall(__pyx_t_4, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 454, __pyx_L1_error)
          __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
          __Pyx_GOTREF(__pyx_t_10);
          __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        } else
        #endif
        {
          __pyx_t_5 = PyTuple_New(1+1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 454, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_5);
          __Pyx_GIVEREF(__pyx_t_8); PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_8); __pyx_t_8 = NULL;
          __Pyx_GIVEREF(__pyx_t_1);
          PyTuple_SET_ITEM(__pyx_t_5, 0+1, __pyx_t_1);
          __pyx_t_1 = 0;
          __pyx_t_10 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_5, NULL); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 454, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_10);
          __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
        }
      }
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __pyx_t_4 = PyNumber_Multiply(__pyx_t_21, __pyx_t_10); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 454, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF(__pyx_t_21); __pyx_t_21 = 0;
      __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
      __pyx_t_10 = PyList_New(3); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 454, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_10);
      __Pyx_GIVEREF(__pyx_t_12);
      PyList_SET_ITEM(__pyx_t_10, 0, __pyx_t_12);
      __Pyx_GIVEREF(__pyx_t_11);
      PyList_SET_ITEM(__pyx_t_10, 1, __pyx_t_11);
      __Pyx_GIVEREF(__pyx_t_4);
      PyList_SET_ITEM(__pyx_t_10, 2, __pyx_t_4);
      __pyx_t_12 = 0;
      __pyx_t_11 = 0;
      __pyx_t_4 = 0;
      __pyx_t_4 = NULL;
      if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_7))) {
        __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_7);
        if (likely(__pyx_t_4)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_7);
          __Pyx_INCREF(__pyx_t_4);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_7, function);
        }
      }
      if (!__pyx_t_4) {
        __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_t_7, __pyx_t_10); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 454, __pyx_L1_error)
        __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
        __Pyx_GOTREF(__pyx_t_3);
      } else {
        #if CYTHON_FAST_PYCALL
        if (PyFunction_Check(__pyx_t_7)) {
          PyObject *__pyx_temp[2] = {__pyx_t_4, __pyx_t_10};
          __pyx_t_3 = __Pyx_PyFunction_FastCall(__pyx_t_7, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 454, __pyx_L1_error)
          __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
          __Pyx_GOTREF(__pyx_t_3);
          __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
        } else
        #endif
        #if CYTHON_FAST_PYCCALL
        if (__Pyx_PyFastCFunction_Check(__pyx_t_7)) {
          PyObject *__pyx_temp[2] = {__pyx_t_4, __pyx_t_10};
          __pyx_t_3 = __Pyx_PyCFunction_FastCall(__pyx_t_7, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 454, __pyx_L1_error)
          __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
          __Pyx_GOTREF(__pyx_t_3);
          __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
        } else
        #endif
        {
          __pyx_t_11 = PyTuple_New(1+1); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 454, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_11);
          __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_11, 0, __pyx_t_4); __pyx_t_4 = NULL;
          __Pyx_GIVEREF(__pyx_t_10);
          PyTuple_SET_ITEM(__pyx_t_11, 0+1, __pyx_t_10);
          __pyx_t_10 = 0;
          __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_7, __pyx_t_11, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 454, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_3);
          __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
        }
      }
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      if (!(likely(((__pyx_t_3) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_3, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 454, __pyx_L1_error)
      __pyx_t_23 = ((PyArrayObject *)__pyx_t_3);
      {
        __Pyx_BufFmt_StackElem __pyx_stack[1];
        __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_pts.rcbuffer->pybuffer);
        __pyx_t_14 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_pts.rcbuffer->pybuffer, (PyObject*)__pyx_t_23, &__Pyx_TypeInfo_double, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack);
        if (unlikely(__pyx_t_14 < 0)) {
          PyErr_Fetch(&__pyx_t_19, &__pyx_t_18, &__pyx_t_17);
          if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_pts.rcbuffer->pybuffer, (PyObject*)__pyx_v_pts, &__Pyx_TypeInfo_double, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) {
            Py_XDECREF(__pyx_t_19); Py_XDECREF(__pyx_t_18); Py_XDECREF(__pyx_t_17);
            __Pyx_RaiseBufferFallbackError();
          } else {
            PyErr_Restore(__pyx_t_19, __pyx_t_18, __pyx_t_17);
          }
        }
        __pyx_pybuffernd_pts.diminfo[0].strides = __pyx_pybuffernd_pts.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_pts.diminfo[0].shape = __pyx_pybuffernd_pts.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_pts.diminfo[1].strides = __pyx_pybuffernd_pts.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_pts.diminfo[1].shape = __pyx_pybuffernd_pts.rcbuffer->pybuffer.shape[1];
        if (unlikely(__pyx_t_14 < 0)) __PYX_ERR(0, 454, __pyx_L1_error)
      }
      __pyx_t_23 = 0;
      __pyx_v_pts = ((PyArrayObject *)__pyx_t_3);
      __pyx_t_3 = 0;
    }
    __pyx_L10:;
+455:         pts = pts if nii>1 else pts.reshape((3,1))
    if (((__pyx_v_nii > 1) != 0)) {
      __Pyx_INCREF(((PyObject *)__pyx_v_pts));
      __pyx_t_3 = ((PyObject *)__pyx_v_pts);
    } else {
      __pyx_t_7 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_pts), __pyx_n_s_reshape); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 455, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_7);
/* … */
  __pyx_tuple__42 = PyTuple_Pack(2, __pyx_int_3, __pyx_int_1); if (unlikely(!__pyx_tuple__42)) __PYX_ERR(0, 455, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__42);
  __Pyx_GIVEREF(__pyx_tuple__42);
      __pyx_t_11 = __Pyx_PyObject_Call(__pyx_t_7, __pyx_tuple__43, NULL); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 455, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_11);
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      if (!(likely(((__pyx_t_11) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_11, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 455, __pyx_L1_error)
      __pyx_t_3 = __pyx_t_11;
      __pyx_t_11 = 0;
    }
    {
      __Pyx_BufFmt_StackElem __pyx_stack[1];
      __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_pts.rcbuffer->pybuffer);
      __pyx_t_14 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_pts.rcbuffer->pybuffer, (PyObject*)((PyArrayObject *)__pyx_t_3), &__Pyx_TypeInfo_double, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack);
      if (unlikely(__pyx_t_14 < 0)) {
        PyErr_Fetch(&__pyx_t_17, &__pyx_t_18, &__pyx_t_19);
        if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_pts.rcbuffer->pybuffer, (PyObject*)__pyx_v_pts, &__Pyx_TypeInfo_double, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) {
          Py_XDECREF(__pyx_t_17); Py_XDECREF(__pyx_t_18); Py_XDECREF(__pyx_t_19);
          __Pyx_RaiseBufferFallbackError();
        } else {
          PyErr_Restore(__pyx_t_17, __pyx_t_18, __pyx_t_19);
        }
      }
      __pyx_pybuffernd_pts.diminfo[0].strides = __pyx_pybuffernd_pts.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_pts.diminfo[0].shape = __pyx_pybuffernd_pts.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_pts.diminfo[1].strides = __pyx_pybuffernd_pts.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_pts.diminfo[1].shape = __pyx_pybuffernd_pts.rcbuffer->pybuffer.shape[1];
      if (unlikely(__pyx_t_14 < 0)) __PYX_ERR(0, 455, __pyx_L1_error)
    }
    __Pyx_DECREF_SET(__pyx_v_pts, ((PyArrayObject *)__pyx_t_3));
    __pyx_t_3 = 0;
  __pyx_tuple__43 = PyTuple_Pack(1, __pyx_tuple__42); if (unlikely(!__pyx_tuple__43)) __PYX_ERR(0, 455, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__43);
  __Pyx_GIVEREF(__pyx_tuple__43);
+456:         LPts.append( pts )
    __pyx_t_29 = __Pyx_PyList_Append(__pyx_v_LPts, ((PyObject *)__pyx_v_pts)); if (unlikely(__pyx_t_29 == -1)) __PYX_ERR(0, 456, __pyx_L1_error)
+457:         LdS.append( dR0r*dZ0r*np.ones((nii,)) )
    __pyx_t_3 = PyFloat_FromDouble((__pyx_v_dR0r * __pyx_v_dZ0r)); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 457, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_7 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 457, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    __pyx_t_10 = __Pyx_PyObject_GetAttrStr(__pyx_t_7, __pyx_n_s_ones); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 457, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_10);
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    __pyx_t_7 = PyInt_FromSsize_t(__pyx_v_nii); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 457, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 457, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_GIVEREF(__pyx_t_7);
    PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_7);
    __pyx_t_7 = 0;
    __pyx_t_7 = NULL;
    if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_10))) {
      __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_10);
      if (likely(__pyx_t_7)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_10);
        __Pyx_INCREF(__pyx_t_7);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_10, function);
      }
    }
    if (!__pyx_t_7) {
      __pyx_t_11 = __Pyx_PyObject_CallOneArg(__pyx_t_10, __pyx_t_4); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 457, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __Pyx_GOTREF(__pyx_t_11);
    } else {
      #if CYTHON_FAST_PYCALL
      if (PyFunction_Check(__pyx_t_10)) {
        PyObject *__pyx_temp[2] = {__pyx_t_7, __pyx_t_4};
        __pyx_t_11 = __Pyx_PyFunction_FastCall(__pyx_t_10, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 457, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
        __Pyx_GOTREF(__pyx_t_11);
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      } else
      #endif
      #if CYTHON_FAST_PYCCALL
      if (__Pyx_PyFastCFunction_Check(__pyx_t_10)) {
        PyObject *__pyx_temp[2] = {__pyx_t_7, __pyx_t_4};
        __pyx_t_11 = __Pyx_PyCFunction_FastCall(__pyx_t_10, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 457, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
        __Pyx_GOTREF(__pyx_t_11);
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      } else
      #endif
      {
        __pyx_t_12 = PyTuple_New(1+1); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 457, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_12);
        __Pyx_GIVEREF(__pyx_t_7); PyTuple_SET_ITEM(__pyx_t_12, 0, __pyx_t_7); __pyx_t_7 = NULL;
        __Pyx_GIVEREF(__pyx_t_4);
        PyTuple_SET_ITEM(__pyx_t_12, 0+1, __pyx_t_4);
        __pyx_t_4 = 0;
        __pyx_t_11 = __Pyx_PyObject_Call(__pyx_t_10, __pyx_t_12, NULL); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 457, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_11);
        __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
      }
    }
    __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
    __pyx_t_10 = PyNumber_Multiply(__pyx_t_3, __pyx_t_11); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 457, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_10);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
    __pyx_t_29 = __Pyx_PyList_Append(__pyx_v_LdS, __pyx_t_10); if (unlikely(__pyx_t_29 == -1)) __PYX_ERR(0, 457, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
 458: 
 459:     # Main body
+460:     ii = (ind>=NR0*NZ0) & (ind<NR0*NZ0+PtsM.shape[1])
  __pyx_t_10 = __Pyx_PyInt_From_int((__pyx_v_NR0 * __pyx_v_NZ0)); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 460, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_10);
  __pyx_t_11 = PyObject_RichCompare(((PyObject *)__pyx_v_ind), __pyx_t_10, Py_GE); __Pyx_XGOTREF(__pyx_t_11); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 460, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
  __pyx_t_10 = __Pyx_PyInt_From_Py_intptr_t(((__pyx_v_NR0 * __pyx_v_NZ0) + (__pyx_v_PtsM->dimensions[1]))); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 460, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_10);
  __pyx_t_3 = PyObject_RichCompare(((PyObject *)__pyx_v_ind), __pyx_t_10, Py_LT); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 460, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
  __pyx_t_10 = PyNumber_And(__pyx_t_11, __pyx_t_3); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 460, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_10);
  __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __Pyx_DECREF_SET(__pyx_v_ii, __pyx_t_10);
  __pyx_t_10 = 0;
+461:     nii = len(ii)
  __pyx_t_24 = PyObject_Length(__pyx_v_ii); if (unlikely(__pyx_t_24 == -1)) __PYX_ERR(0, 461, __pyx_L1_error)
  __pyx_v_nii = __pyx_t_24;
+462:     if nii>0:
  __pyx_t_25 = ((__pyx_v_nii > 0) != 0);
  if (__pyx_t_25) {
/* … */
  }
+463:         pts = PtsM[:,ind[ii]-NR0*NZ0] if nii>1 else PtsM[:,ind[ii]-NR0*NZ0].reshape((3,1))
    if (((__pyx_v_nii > 1) != 0)) {
      __pyx_t_3 = PyObject_GetItem(((PyObject *)__pyx_v_ind), __pyx_v_ii); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 463, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_11 = __Pyx_PyInt_From_int((__pyx_v_NR0 * __pyx_v_NZ0)); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 463, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_11);
      __pyx_t_12 = PyNumber_Subtract(__pyx_t_3, __pyx_t_11); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 463, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_12);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
      __pyx_t_11 = PyTuple_New(2); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 463, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_11);
      __Pyx_INCREF(__pyx_slice__44);
      __Pyx_GIVEREF(__pyx_slice__44);
      PyTuple_SET_ITEM(__pyx_t_11, 0, __pyx_slice__44);
      __Pyx_GIVEREF(__pyx_t_12);
      PyTuple_SET_ITEM(__pyx_t_11, 1, __pyx_t_12);
      __pyx_t_12 = 0;
      __pyx_t_12 = PyObject_GetItem(((PyObject *)__pyx_v_PtsM), __pyx_t_11); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 463, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_12);
      __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
      if (!(likely(((__pyx_t_12) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_12, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 463, __pyx_L1_error)
      __pyx_t_10 = __pyx_t_12;
      __pyx_t_12 = 0;
    } else {
/* … */
  __pyx_slice__44 = PySlice_New(Py_None, Py_None, Py_None); if (unlikely(!__pyx_slice__44)) __PYX_ERR(0, 463, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_slice__44);
  __Pyx_GIVEREF(__pyx_slice__44);
      __pyx_t_12 = PyObject_GetItem(((PyObject *)__pyx_v_ind), __pyx_v_ii); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 463, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_12);
      __pyx_t_11 = __Pyx_PyInt_From_int((__pyx_v_NR0 * __pyx_v_NZ0)); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 463, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_11);
      __pyx_t_3 = PyNumber_Subtract(__pyx_t_12, __pyx_t_11); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 463, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
      __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
      __pyx_t_11 = PyTuple_New(2); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 463, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_11);
      __Pyx_INCREF(__pyx_slice__45);
      __Pyx_GIVEREF(__pyx_slice__45);
      PyTuple_SET_ITEM(__pyx_t_11, 0, __pyx_slice__45);
      __Pyx_GIVEREF(__pyx_t_3);
      PyTuple_SET_ITEM(__pyx_t_11, 1, __pyx_t_3);
      __pyx_t_3 = 0;
      __pyx_t_3 = PyObject_GetItem(((PyObject *)__pyx_v_PtsM), __pyx_t_11); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 463, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
      __pyx_t_11 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_reshape); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 463, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_11);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_slice__45 = PySlice_New(Py_None, Py_None, Py_None); if (unlikely(!__pyx_slice__45)) __PYX_ERR(0, 463, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_slice__45);
  __Pyx_GIVEREF(__pyx_slice__45);
  __pyx_tuple__46 = PyTuple_Pack(2, __pyx_int_3, __pyx_int_1); if (unlikely(!__pyx_tuple__46)) __PYX_ERR(0, 463, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__46);
  __Pyx_GIVEREF(__pyx_tuple__46);
      __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_11, __pyx_tuple__47, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 463, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
      if (!(likely(((__pyx_t_3) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_3, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 463, __pyx_L1_error)
      __pyx_t_10 = __pyx_t_3;
      __pyx_t_3 = 0;
    }
    {
      __Pyx_BufFmt_StackElem __pyx_stack[1];
      __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_pts.rcbuffer->pybuffer);
      __pyx_t_14 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_pts.rcbuffer->pybuffer, (PyObject*)((PyArrayObject *)__pyx_t_10), &__Pyx_TypeInfo_double, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack);
      if (unlikely(__pyx_t_14 < 0)) {
        PyErr_Fetch(&__pyx_t_19, &__pyx_t_18, &__pyx_t_17);
        if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_pts.rcbuffer->pybuffer, (PyObject*)__pyx_v_pts, &__Pyx_TypeInfo_double, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) {
          Py_XDECREF(__pyx_t_19); Py_XDECREF(__pyx_t_18); Py_XDECREF(__pyx_t_17);
          __Pyx_RaiseBufferFallbackError();
        } else {
          PyErr_Restore(__pyx_t_19, __pyx_t_18, __pyx_t_17);
        }
      }
      __pyx_pybuffernd_pts.diminfo[0].strides = __pyx_pybuffernd_pts.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_pts.diminfo[0].shape = __pyx_pybuffernd_pts.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_pts.diminfo[1].strides = __pyx_pybuffernd_pts.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_pts.diminfo[1].shape = __pyx_pybuffernd_pts.rcbuffer->pybuffer.shape[1];
      if (unlikely(__pyx_t_14 < 0)) __PYX_ERR(0, 463, __pyx_L1_error)
    }
    __Pyx_XDECREF_SET(__pyx_v_pts, ((PyArrayObject *)__pyx_t_10));
    __pyx_t_10 = 0;
  __pyx_tuple__47 = PyTuple_Pack(1, __pyx_tuple__46); if (unlikely(!__pyx_tuple__47)) __PYX_ERR(0, 463, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__47);
  __Pyx_GIVEREF(__pyx_tuple__47);
+464:         LPts.append( PtsM[:,ind[ii]-NR0*NZ0] )
    __pyx_t_10 = PyObject_GetItem(((PyObject *)__pyx_v_ind), __pyx_v_ii); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 464, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_10);
    __pyx_t_3 = __Pyx_PyInt_From_int((__pyx_v_NR0 * __pyx_v_NZ0)); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 464, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_11 = PyNumber_Subtract(__pyx_t_10, __pyx_t_3); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 464, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_11);
    __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 464, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_INCREF(__pyx_slice__48);
    __Pyx_GIVEREF(__pyx_slice__48);
    PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_slice__48);
    __Pyx_GIVEREF(__pyx_t_11);
    PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_t_11);
    __pyx_t_11 = 0;
    __pyx_t_11 = PyObject_GetItem(((PyObject *)__pyx_v_PtsM), __pyx_t_3); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 464, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_11);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_t_29 = __Pyx_PyList_Append(__pyx_v_LPts, __pyx_t_11); if (unlikely(__pyx_t_29 == -1)) __PYX_ERR(0, 464, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
/* … */
  __pyx_slice__48 = PySlice_New(Py_None, Py_None, Py_None); if (unlikely(!__pyx_slice__48)) __PYX_ERR(0, 464, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_slice__48);
  __Pyx_GIVEREF(__pyx_slice__48);
+465:         LdS.append( dSM[ind[ii]-NR0*NZ0] )
    __pyx_t_11 = PyObject_GetItem(((PyObject *)__pyx_v_ind), __pyx_v_ii); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 465, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_11);
    __pyx_t_3 = __Pyx_PyInt_From_int((__pyx_v_NR0 * __pyx_v_NZ0)); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 465, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_10 = PyNumber_Subtract(__pyx_t_11, __pyx_t_3); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 465, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_10);
    __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_t_3 = PyObject_GetItem(((PyObject *)__pyx_v_dSM), __pyx_t_10); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 465, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
    __pyx_t_29 = __Pyx_PyList_Append(__pyx_v_LdS, __pyx_t_3); if (unlikely(__pyx_t_29 == -1)) __PYX_ERR(0, 465, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
 466: 
 467:     # Second face
+468:     ii = (ind >= NR0*NZ0+PtsM.shape[1] ).nonzero()[0]
  __pyx_t_10 = __Pyx_PyInt_From_Py_intptr_t(((__pyx_v_NR0 * __pyx_v_NZ0) + (__pyx_v_PtsM->dimensions[1]))); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 468, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_10);
  __pyx_t_11 = PyObject_RichCompare(((PyObject *)__pyx_v_ind), __pyx_t_10, Py_GE); __Pyx_XGOTREF(__pyx_t_11); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 468, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
  __pyx_t_10 = __Pyx_PyObject_GetAttrStr(__pyx_t_11, __pyx_n_s_nonzero); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 468, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_10);
  __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
  __pyx_t_11 = NULL;
  if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_10))) {
    __pyx_t_11 = PyMethod_GET_SELF(__pyx_t_10);
    if (likely(__pyx_t_11)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_10);
      __Pyx_INCREF(__pyx_t_11);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_10, function);
    }
  }
  if (__pyx_t_11) {
    __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_t_10, __pyx_t_11); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 468, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
  } else {
    __pyx_t_3 = __Pyx_PyObject_CallNoArg(__pyx_t_10); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 468, __pyx_L1_error)
  }
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
  __pyx_t_10 = __Pyx_GetItemInt(__pyx_t_3, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 0); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 468, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_10);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __Pyx_DECREF_SET(__pyx_v_ii, __pyx_t_10);
  __pyx_t_10 = 0;
+469:     nii = len(ii)
  __pyx_t_24 = PyObject_Length(__pyx_v_ii); if (unlikely(__pyx_t_24 == -1)) __PYX_ERR(0, 469, __pyx_L1_error)
  __pyx_v_nii = __pyx_t_24;
+470:     if nii>0:
  __pyx_t_25 = ((__pyx_v_nii > 0) != 0);
  if (__pyx_t_25) {
/* … */
  }
+471:         indZ0 = (ind[ii]-(NR0*NZ0+PtsM.shape[1])) // NR0
    __pyx_t_10 = PyObject_GetItem(((PyObject *)__pyx_v_ind), __pyx_v_ii); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 471, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_10);
    __pyx_t_3 = __Pyx_PyInt_From_Py_intptr_t(((__pyx_v_NR0 * __pyx_v_NZ0) + (__pyx_v_PtsM->dimensions[1]))); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 471, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_11 = PyNumber_Subtract(__pyx_t_10, __pyx_t_3); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 471, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_11);
    __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_t_3 = __Pyx_PyInt_From_int(__pyx_v_NR0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 471, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_10 = PyNumber_FloorDivide(__pyx_t_11, __pyx_t_3); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 471, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_10);
    __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    if (!(likely(((__pyx_t_10) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_10, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 471, __pyx_L1_error)
    __pyx_t_20 = ((PyArrayObject *)__pyx_t_10);
    {
      __Pyx_BufFmt_StackElem __pyx_stack[1];
      __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_indZ0.rcbuffer->pybuffer);
      __pyx_t_14 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_indZ0.rcbuffer->pybuffer, (PyObject*)__pyx_t_20, &__Pyx_TypeInfo_long, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack);
      if (unlikely(__pyx_t_14 < 0)) {
        PyErr_Fetch(&__pyx_t_17, &__pyx_t_18, &__pyx_t_19);
        if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_indZ0.rcbuffer->pybuffer, (PyObject*)__pyx_v_indZ0, &__Pyx_TypeInfo_long, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {
          Py_XDECREF(__pyx_t_17); Py_XDECREF(__pyx_t_18); Py_XDECREF(__pyx_t_19);
          __Pyx_RaiseBufferFallbackError();
        } else {
          PyErr_Restore(__pyx_t_17, __pyx_t_18, __pyx_t_19);
        }
      }
      __pyx_pybuffernd_indZ0.diminfo[0].strides = __pyx_pybuffernd_indZ0.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_indZ0.diminfo[0].shape = __pyx_pybuffernd_indZ0.rcbuffer->pybuffer.shape[0];
      if (unlikely(__pyx_t_14 < 0)) __PYX_ERR(0, 471, __pyx_L1_error)
    }
    __pyx_t_20 = 0;
    __Pyx_XDECREF_SET(__pyx_v_indZ0, ((PyArrayObject *)__pyx_t_10));
    __pyx_t_10 = 0;
+472:         indR0 = ind[ii]-(NR0*NZ0+PtsM.shape[1]) - indZ0*NR0
    __pyx_t_10 = PyObject_GetItem(((PyObject *)__pyx_v_ind), __pyx_v_ii); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 472, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_10);
    __pyx_t_3 = __Pyx_PyInt_From_Py_intptr_t(((__pyx_v_NR0 * __pyx_v_NZ0) + (__pyx_v_PtsM->dimensions[1]))); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 472, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_11 = PyNumber_Subtract(__pyx_t_10, __pyx_t_3); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 472, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_11);
    __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_t_3 = __Pyx_PyInt_From_int(__pyx_v_NR0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 472, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_10 = PyNumber_Multiply(((PyObject *)__pyx_v_indZ0), __pyx_t_3); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 472, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_10);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_t_3 = PyNumber_Subtract(__pyx_t_11, __pyx_t_10); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 472, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
    __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
    if (!(likely(((__pyx_t_3) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_3, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 472, __pyx_L1_error)
    __pyx_t_20 = ((PyArrayObject *)__pyx_t_3);
    {
      __Pyx_BufFmt_StackElem __pyx_stack[1];
      __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_indR0.rcbuffer->pybuffer);
      __pyx_t_14 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_indR0.rcbuffer->pybuffer, (PyObject*)__pyx_t_20, &__Pyx_TypeInfo_long, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack);
      if (unlikely(__pyx_t_14 < 0)) {
        PyErr_Fetch(&__pyx_t_19, &__pyx_t_18, &__pyx_t_17);
        if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_indR0.rcbuffer->pybuffer, (PyObject*)__pyx_v_indR0, &__Pyx_TypeInfo_long, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {
          Py_XDECREF(__pyx_t_19); Py_XDECREF(__pyx_t_18); Py_XDECREF(__pyx_t_17);
          __Pyx_RaiseBufferFallbackError();
        } else {
          PyErr_Restore(__pyx_t_19, __pyx_t_18, __pyx_t_17);
        }
      }
      __pyx_pybuffernd_indR0.diminfo[0].strides = __pyx_pybuffernd_indR0.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_indR0.diminfo[0].shape = __pyx_pybuffernd_indR0.rcbuffer->pybuffer.shape[0];
      if (unlikely(__pyx_t_14 < 0)) __PYX_ERR(0, 472, __pyx_L1_error)
    }
    __pyx_t_20 = 0;
    __Pyx_XDECREF_SET(__pyx_v_indR0, ((PyArrayObject *)__pyx_t_3));
    __pyx_t_3 = 0;
+473:         if Out.lower()=='(x,y,z)':
    __pyx_t_10 = __Pyx_PyObject_GetAttrStr(__pyx_v_Out, __pyx_n_s_lower); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 473, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_10);
    __pyx_t_11 = NULL;
    if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_10))) {
      __pyx_t_11 = PyMethod_GET_SELF(__pyx_t_10);
      if (likely(__pyx_t_11)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_10);
        __Pyx_INCREF(__pyx_t_11);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_10, function);
      }
    }
    if (__pyx_t_11) {
      __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_t_10, __pyx_t_11); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 473, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
    } else {
      __pyx_t_3 = __Pyx_PyObject_CallNoArg(__pyx_t_10); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 473, __pyx_L1_error)
    }
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
    __pyx_t_25 = (__Pyx_PyUnicode_Equals(__pyx_t_3, __pyx_kp_u_x_y_z, Py_EQ)); if (unlikely(__pyx_t_25 < 0)) __PYX_ERR(0, 473, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    if (__pyx_t_25) {
/* … */
      goto __pyx_L13;
    }
+474:             pts = np.array([R0[indR0]*Ccos(PhiMinMax[1]-Dphi), R0[indR0]*Csin(PhiMinMax[1]-Dphi), Z0[indZ0]])
      __pyx_t_10 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 474, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_10);
      __pyx_t_11 = __Pyx_PyObject_GetAttrStr(__pyx_t_10, __pyx_n_s_array); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 474, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_11);
      __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
      __pyx_t_10 = PyObject_GetItem(((PyObject *)__pyx_v_R0), ((PyObject *)__pyx_v_indR0)); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 474, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_10);
      __pyx_t_30 = 1;
      __pyx_t_12 = PyFloat_FromDouble(cos(((*((double *) ( /* dim=0 */ ((char *) (((double *) __pyx_v_PhiMinMax.data) + __pyx_t_30)) ))) - __pyx_v_Dphi))); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 474, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_12);
      __pyx_t_4 = PyNumber_Multiply(__pyx_t_10, __pyx_t_12); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 474, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
      __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
      __pyx_t_12 = PyObject_GetItem(((PyObject *)__pyx_v_R0), ((PyObject *)__pyx_v_indR0)); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 474, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_12);
      __pyx_t_31 = 1;
      __pyx_t_10 = PyFloat_FromDouble(sin(((*((double *) ( /* dim=0 */ ((char *) (((double *) __pyx_v_PhiMinMax.data) + __pyx_t_31)) ))) - __pyx_v_Dphi))); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 474, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_10);
      __pyx_t_7 = PyNumber_Multiply(__pyx_t_12, __pyx_t_10); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 474, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_7);
      __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
      __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
      __pyx_t_10 = PyObject_GetItem(((PyObject *)__pyx_v_Z0), ((PyObject *)__pyx_v_indZ0)); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 474, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_10);
      __pyx_t_12 = PyList_New(3); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 474, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_12);
      __Pyx_GIVEREF(__pyx_t_4);
      PyList_SET_ITEM(__pyx_t_12, 0, __pyx_t_4);
      __Pyx_GIVEREF(__pyx_t_7);
      PyList_SET_ITEM(__pyx_t_12, 1, __pyx_t_7);
      __Pyx_GIVEREF(__pyx_t_10);
      PyList_SET_ITEM(__pyx_t_12, 2, __pyx_t_10);
      __pyx_t_4 = 0;
      __pyx_t_7 = 0;
      __pyx_t_10 = 0;
      __pyx_t_10 = NULL;
      if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_11))) {
        __pyx_t_10 = PyMethod_GET_SELF(__pyx_t_11);
        if (likely(__pyx_t_10)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_11);
          __Pyx_INCREF(__pyx_t_10);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_11, function);
        }
      }
      if (!__pyx_t_10) {
        __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_t_11, __pyx_t_12); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 474, __pyx_L1_error)
        __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
        __Pyx_GOTREF(__pyx_t_3);
      } else {
        #if CYTHON_FAST_PYCALL
        if (PyFunction_Check(__pyx_t_11)) {
          PyObject *__pyx_temp[2] = {__pyx_t_10, __pyx_t_12};
          __pyx_t_3 = __Pyx_PyFunction_FastCall(__pyx_t_11, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 474, __pyx_L1_error)
          __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
          __Pyx_GOTREF(__pyx_t_3);
          __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
        } else
        #endif
        #if CYTHON_FAST_PYCCALL
        if (__Pyx_PyFastCFunction_Check(__pyx_t_11)) {
          PyObject *__pyx_temp[2] = {__pyx_t_10, __pyx_t_12};
          __pyx_t_3 = __Pyx_PyCFunction_FastCall(__pyx_t_11, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 474, __pyx_L1_error)
          __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
          __Pyx_GOTREF(__pyx_t_3);
          __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
        } else
        #endif
        {
          __pyx_t_7 = PyTuple_New(1+1); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 474, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_7);
          __Pyx_GIVEREF(__pyx_t_10); PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_10); __pyx_t_10 = NULL;
          __Pyx_GIVEREF(__pyx_t_12);
          PyTuple_SET_ITEM(__pyx_t_7, 0+1, __pyx_t_12);
          __pyx_t_12 = 0;
          __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_11, __pyx_t_7, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 474, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_3);
          __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
        }
      }
      __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
      if (!(likely(((__pyx_t_3) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_3, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 474, __pyx_L1_error)
      __pyx_t_23 = ((PyArrayObject *)__pyx_t_3);
      {
        __Pyx_BufFmt_StackElem __pyx_stack[1];
        __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_pts.rcbuffer->pybuffer);
        __pyx_t_14 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_pts.rcbuffer->pybuffer, (PyObject*)__pyx_t_23, &__Pyx_TypeInfo_double, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack);
        if (unlikely(__pyx_t_14 < 0)) {
          PyErr_Fetch(&__pyx_t_17, &__pyx_t_18, &__pyx_t_19);
          if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_pts.rcbuffer->pybuffer, (PyObject*)__pyx_v_pts, &__Pyx_TypeInfo_double, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) {
            Py_XDECREF(__pyx_t_17); Py_XDECREF(__pyx_t_18); Py_XDECREF(__pyx_t_19);
            __Pyx_RaiseBufferFallbackError();
          } else {
            PyErr_Restore(__pyx_t_17, __pyx_t_18, __pyx_t_19);
          }
        }
        __pyx_pybuffernd_pts.diminfo[0].strides = __pyx_pybuffernd_pts.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_pts.diminfo[0].shape = __pyx_pybuffernd_pts.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_pts.diminfo[1].strides = __pyx_pybuffernd_pts.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_pts.diminfo[1].shape = __pyx_pybuffernd_pts.rcbuffer->pybuffer.shape[1];
        if (unlikely(__pyx_t_14 < 0)) __PYX_ERR(0, 474, __pyx_L1_error)
      }
      __pyx_t_23 = 0;
      __Pyx_XDECREF_SET(__pyx_v_pts, ((PyArrayObject *)__pyx_t_3));
      __pyx_t_3 = 0;
 475:         else:
+476:             pts = np.array([R0[indR0], Z0[indZ0], (PhiMinMax[1]-Dphi)*np.ones((nii,))])
    /*else*/ {
      __pyx_t_11 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 476, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_11);
      __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_t_11, __pyx_n_s_array); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 476, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_7);
      __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
      __pyx_t_11 = PyObject_GetItem(((PyObject *)__pyx_v_R0), ((PyObject *)__pyx_v_indR0)); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 476, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_11);
      __pyx_t_12 = PyObject_GetItem(((PyObject *)__pyx_v_Z0), ((PyObject *)__pyx_v_indZ0)); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 476, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_12);
      __pyx_t_32 = 1;
      __pyx_t_10 = PyFloat_FromDouble(((*((double *) ( /* dim=0 */ ((char *) (((double *) __pyx_v_PhiMinMax.data) + __pyx_t_32)) ))) - __pyx_v_Dphi)); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 476, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_10);
      __pyx_t_21 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_21)) __PYX_ERR(0, 476, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_21);
      __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_21, __pyx_n_s_ones); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 476, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_DECREF(__pyx_t_21); __pyx_t_21 = 0;
      __pyx_t_21 = PyInt_FromSsize_t(__pyx_v_nii); if (unlikely(!__pyx_t_21)) __PYX_ERR(0, 476, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_21);
      __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 476, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_GIVEREF(__pyx_t_21);
      PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_21);
      __pyx_t_21 = 0;
      __pyx_t_21 = NULL;
      if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_5))) {
        __pyx_t_21 = PyMethod_GET_SELF(__pyx_t_5);
        if (likely(__pyx_t_21)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5);
          __Pyx_INCREF(__pyx_t_21);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_5, function);
        }
      }
      if (!__pyx_t_21) {
        __pyx_t_4 = __Pyx_PyObject_CallOneArg(__pyx_t_5, __pyx_t_1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 476, __pyx_L1_error)
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        __Pyx_GOTREF(__pyx_t_4);
      } else {
        #if CYTHON_FAST_PYCALL
        if (PyFunction_Check(__pyx_t_5)) {
          PyObject *__pyx_temp[2] = {__pyx_t_21, __pyx_t_1};
          __pyx_t_4 = __Pyx_PyFunction_FastCall(__pyx_t_5, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 476, __pyx_L1_error)
          __Pyx_XDECREF(__pyx_t_21); __pyx_t_21 = 0;
          __Pyx_GOTREF(__pyx_t_4);
          __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        } else
        #endif
        #if CYTHON_FAST_PYCCALL
        if (__Pyx_PyFastCFunction_Check(__pyx_t_5)) {
          PyObject *__pyx_temp[2] = {__pyx_t_21, __pyx_t_1};
          __pyx_t_4 = __Pyx_PyCFunction_FastCall(__pyx_t_5, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 476, __pyx_L1_error)
          __Pyx_XDECREF(__pyx_t_21); __pyx_t_21 = 0;
          __Pyx_GOTREF(__pyx_t_4);
          __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        } else
        #endif
        {
          __pyx_t_8 = PyTuple_New(1+1); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 476, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_8);
          __Pyx_GIVEREF(__pyx_t_21); PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_21); __pyx_t_21 = NULL;
          __Pyx_GIVEREF(__pyx_t_1);
          PyTuple_SET_ITEM(__pyx_t_8, 0+1, __pyx_t_1);
          __pyx_t_1 = 0;
          __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_t_8, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 476, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_4);
          __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
        }
      }
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __pyx_t_5 = PyNumber_Multiply(__pyx_t_10, __pyx_t_4); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 476, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __pyx_t_4 = PyList_New(3); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 476, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_GIVEREF(__pyx_t_11);
      PyList_SET_ITEM(__pyx_t_4, 0, __pyx_t_11);
      __Pyx_GIVEREF(__pyx_t_12);
      PyList_SET_ITEM(__pyx_t_4, 1, __pyx_t_12);
      __Pyx_GIVEREF(__pyx_t_5);
      PyList_SET_ITEM(__pyx_t_4, 2, __pyx_t_5);
      __pyx_t_11 = 0;
      __pyx_t_12 = 0;
      __pyx_t_5 = 0;
      __pyx_t_5 = NULL;
      if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_7))) {
        __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_7);
        if (likely(__pyx_t_5)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_7);
          __Pyx_INCREF(__pyx_t_5);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_7, function);
        }
      }
      if (!__pyx_t_5) {
        __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_t_7, __pyx_t_4); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 476, __pyx_L1_error)
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
        __Pyx_GOTREF(__pyx_t_3);
      } else {
        #if CYTHON_FAST_PYCALL
        if (PyFunction_Check(__pyx_t_7)) {
          PyObject *__pyx_temp[2] = {__pyx_t_5, __pyx_t_4};
          __pyx_t_3 = __Pyx_PyFunction_FastCall(__pyx_t_7, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 476, __pyx_L1_error)
          __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
          __Pyx_GOTREF(__pyx_t_3);
          __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
        } else
        #endif
        #if CYTHON_FAST_PYCCALL
        if (__Pyx_PyFastCFunction_Check(__pyx_t_7)) {
          PyObject *__pyx_temp[2] = {__pyx_t_5, __pyx_t_4};
          __pyx_t_3 = __Pyx_PyCFunction_FastCall(__pyx_t_7, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 476, __pyx_L1_error)
          __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
          __Pyx_GOTREF(__pyx_t_3);
          __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
        } else
        #endif
        {
          __pyx_t_12 = PyTuple_New(1+1); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 476, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_12);
          __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_12, 0, __pyx_t_5); __pyx_t_5 = NULL;
          __Pyx_GIVEREF(__pyx_t_4);
          PyTuple_SET_ITEM(__pyx_t_12, 0+1, __pyx_t_4);
          __pyx_t_4 = 0;
          __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_7, __pyx_t_12, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 476, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_3);
          __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
        }
      }
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      if (!(likely(((__pyx_t_3) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_3, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 476, __pyx_L1_error)
      __pyx_t_23 = ((PyArrayObject *)__pyx_t_3);
      {
        __Pyx_BufFmt_StackElem __pyx_stack[1];
        __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_pts.rcbuffer->pybuffer);
        __pyx_t_14 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_pts.rcbuffer->pybuffer, (PyObject*)__pyx_t_23, &__Pyx_TypeInfo_double, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack);
        if (unlikely(__pyx_t_14 < 0)) {
          PyErr_Fetch(&__pyx_t_19, &__pyx_t_18, &__pyx_t_17);
          if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_pts.rcbuffer->pybuffer, (PyObject*)__pyx_v_pts, &__Pyx_TypeInfo_double, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) {
            Py_XDECREF(__pyx_t_19); Py_XDECREF(__pyx_t_18); Py_XDECREF(__pyx_t_17);
            __Pyx_RaiseBufferFallbackError();
          } else {
            PyErr_Restore(__pyx_t_19, __pyx_t_18, __pyx_t_17);
          }
        }
        __pyx_pybuffernd_pts.diminfo[0].strides = __pyx_pybuffernd_pts.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_pts.diminfo[0].shape = __pyx_pybuffernd_pts.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_pts.diminfo[1].strides = __pyx_pybuffernd_pts.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_pts.diminfo[1].shape = __pyx_pybuffernd_pts.rcbuffer->pybuffer.shape[1];
        if (unlikely(__pyx_t_14 < 0)) __PYX_ERR(0, 476, __pyx_L1_error)
      }
      __pyx_t_23 = 0;
      __Pyx_XDECREF_SET(__pyx_v_pts, ((PyArrayObject *)__pyx_t_3));
      __pyx_t_3 = 0;
    }
    __pyx_L13:;
+477:         pts = pts if nii>1 else pts.reshape((3,1))
    if (((__pyx_v_nii > 1) != 0)) {
      __Pyx_INCREF(((PyObject *)__pyx_v_pts));
      __pyx_t_3 = ((PyObject *)__pyx_v_pts);
    } else {
      __pyx_t_7 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_pts), __pyx_n_s_reshape); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 477, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_7);
/* … */
  __pyx_tuple__49 = PyTuple_Pack(2, __pyx_int_3, __pyx_int_1); if (unlikely(!__pyx_tuple__49)) __PYX_ERR(0, 477, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__49);
  __Pyx_GIVEREF(__pyx_tuple__49);
      __pyx_t_12 = __Pyx_PyObject_Call(__pyx_t_7, __pyx_tuple__50, NULL); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 477, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_12);
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      if (!(likely(((__pyx_t_12) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_12, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 477, __pyx_L1_error)
      __pyx_t_3 = __pyx_t_12;
      __pyx_t_12 = 0;
    }
    {
      __Pyx_BufFmt_StackElem __pyx_stack[1];
      __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_pts.rcbuffer->pybuffer);
      __pyx_t_14 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_pts.rcbuffer->pybuffer, (PyObject*)((PyArrayObject *)__pyx_t_3), &__Pyx_TypeInfo_double, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack);
      if (unlikely(__pyx_t_14 < 0)) {
        PyErr_Fetch(&__pyx_t_17, &__pyx_t_18, &__pyx_t_19);
        if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_pts.rcbuffer->pybuffer, (PyObject*)__pyx_v_pts, &__Pyx_TypeInfo_double, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) {
          Py_XDECREF(__pyx_t_17); Py_XDECREF(__pyx_t_18); Py_XDECREF(__pyx_t_19);
          __Pyx_RaiseBufferFallbackError();
        } else {
          PyErr_Restore(__pyx_t_17, __pyx_t_18, __pyx_t_19);
        }
      }
      __pyx_pybuffernd_pts.diminfo[0].strides = __pyx_pybuffernd_pts.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_pts.diminfo[0].shape = __pyx_pybuffernd_pts.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_pts.diminfo[1].strides = __pyx_pybuffernd_pts.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_pts.diminfo[1].shape = __pyx_pybuffernd_pts.rcbuffer->pybuffer.shape[1];
      if (unlikely(__pyx_t_14 < 0)) __PYX_ERR(0, 477, __pyx_L1_error)
    }
    __Pyx_DECREF_SET(__pyx_v_pts, ((PyArrayObject *)__pyx_t_3));
    __pyx_t_3 = 0;
  __pyx_tuple__50 = PyTuple_Pack(1, __pyx_tuple__49); if (unlikely(!__pyx_tuple__50)) __PYX_ERR(0, 477, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__50);
  __Pyx_GIVEREF(__pyx_tuple__50);
+478:         LPts.append( pts )
    __pyx_t_29 = __Pyx_PyList_Append(__pyx_v_LPts, ((PyObject *)__pyx_v_pts)); if (unlikely(__pyx_t_29 == -1)) __PYX_ERR(0, 478, __pyx_L1_error)
+479:         LdS.append( dR0r*dZ0r*np.ones((nii,)) )
    __pyx_t_3 = PyFloat_FromDouble((__pyx_v_dR0r * __pyx_v_dZ0r)); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 479, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_7 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 479, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_7, __pyx_n_s_ones); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 479, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    __pyx_t_7 = PyInt_FromSsize_t(__pyx_v_nii); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 479, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    __pyx_t_5 = PyTuple_New(1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 479, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_GIVEREF(__pyx_t_7);
    PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_7);
    __pyx_t_7 = 0;
    __pyx_t_7 = NULL;
    if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_4))) {
      __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_4);
      if (likely(__pyx_t_7)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
        __Pyx_INCREF(__pyx_t_7);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_4, function);
      }
    }
    if (!__pyx_t_7) {
      __pyx_t_12 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_5); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 479, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __Pyx_GOTREF(__pyx_t_12);
    } else {
      #if CYTHON_FAST_PYCALL
      if (PyFunction_Check(__pyx_t_4)) {
        PyObject *__pyx_temp[2] = {__pyx_t_7, __pyx_t_5};
        __pyx_t_12 = __Pyx_PyFunction_FastCall(__pyx_t_4, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 479, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
        __Pyx_GOTREF(__pyx_t_12);
        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      } else
      #endif
      #if CYTHON_FAST_PYCCALL
      if (__Pyx_PyFastCFunction_Check(__pyx_t_4)) {
        PyObject *__pyx_temp[2] = {__pyx_t_7, __pyx_t_5};
        __pyx_t_12 = __Pyx_PyCFunction_FastCall(__pyx_t_4, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 479, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
        __Pyx_GOTREF(__pyx_t_12);
        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      } else
      #endif
      {
        __pyx_t_11 = PyTuple_New(1+1); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 479, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_11);
        __Pyx_GIVEREF(__pyx_t_7); PyTuple_SET_ITEM(__pyx_t_11, 0, __pyx_t_7); __pyx_t_7 = NULL;
        __Pyx_GIVEREF(__pyx_t_5);
        PyTuple_SET_ITEM(__pyx_t_11, 0+1, __pyx_t_5);
        __pyx_t_5 = 0;
        __pyx_t_12 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_11, NULL); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 479, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_12);
        __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
      }
    }
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_t_4 = PyNumber_Multiply(__pyx_t_3, __pyx_t_12); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 479, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
    __pyx_t_29 = __Pyx_PyList_Append(__pyx_v_LdS, __pyx_t_4); if (unlikely(__pyx_t_29 == -1)) __PYX_ERR(0, 479, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
 480: 
 481:     # Aggregate
+482:     if len(LPts)==1:
  __pyx_t_24 = PyList_GET_SIZE(__pyx_v_LPts); if (unlikely(__pyx_t_24 == -1)) __PYX_ERR(0, 482, __pyx_L1_error)
  __pyx_t_25 = ((__pyx_t_24 == 1) != 0);
  if (__pyx_t_25) {
/* … */
    goto __pyx_L14;
  }
+483:         Pts = LPts[0]
    if (!(likely(((PyList_GET_ITEM(__pyx_v_LPts, 0)) == Py_None) || likely(__Pyx_TypeTest(PyList_GET_ITEM(__pyx_v_LPts, 0), __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 483, __pyx_L1_error)
    __pyx_t_4 = PyList_GET_ITEM(__pyx_v_LPts, 0);
    __Pyx_INCREF(__pyx_t_4);
    {
      __Pyx_BufFmt_StackElem __pyx_stack[1];
      __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_Pts.rcbuffer->pybuffer);
      __pyx_t_14 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_Pts.rcbuffer->pybuffer, (PyObject*)((PyArrayObject *)__pyx_t_4), &__Pyx_TypeInfo_double, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack);
      if (unlikely(__pyx_t_14 < 0)) {
        PyErr_Fetch(&__pyx_t_19, &__pyx_t_18, &__pyx_t_17);
        if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_Pts.rcbuffer->pybuffer, (PyObject*)__pyx_v_Pts, &__Pyx_TypeInfo_double, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) {
          Py_XDECREF(__pyx_t_19); Py_XDECREF(__pyx_t_18); Py_XDECREF(__pyx_t_17);
          __Pyx_RaiseBufferFallbackError();
        } else {
          PyErr_Restore(__pyx_t_19, __pyx_t_18, __pyx_t_17);
        }
      }
      __pyx_pybuffernd_Pts.diminfo[0].strides = __pyx_pybuffernd_Pts.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_Pts.diminfo[0].shape = __pyx_pybuffernd_Pts.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_Pts.diminfo[1].strides = __pyx_pybuffernd_Pts.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_Pts.diminfo[1].shape = __pyx_pybuffernd_Pts.rcbuffer->pybuffer.shape[1];
      if (unlikely(__pyx_t_14 < 0)) __PYX_ERR(0, 483, __pyx_L1_error)
    }
    __pyx_v_Pts = ((PyArrayObject *)__pyx_t_4);
    __pyx_t_4 = 0;
+484:         dS = LdS[0]
    if (!(likely(((PyList_GET_ITEM(__pyx_v_LdS, 0)) == Py_None) || likely(__Pyx_TypeTest(PyList_GET_ITEM(__pyx_v_LdS, 0), __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 484, __pyx_L1_error)
    __pyx_t_4 = PyList_GET_ITEM(__pyx_v_LdS, 0);
    __Pyx_INCREF(__pyx_t_4);
    {
      __Pyx_BufFmt_StackElem __pyx_stack[1];
      __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_dS.rcbuffer->pybuffer);
      __pyx_t_14 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_dS.rcbuffer->pybuffer, (PyObject*)((PyArrayObject *)__pyx_t_4), &__Pyx_TypeInfo_double, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack);
      if (unlikely(__pyx_t_14 < 0)) {
        PyErr_Fetch(&__pyx_t_17, &__pyx_t_18, &__pyx_t_19);
        if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_dS.rcbuffer->pybuffer, (PyObject*)__pyx_v_dS, &__Pyx_TypeInfo_double, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {
          Py_XDECREF(__pyx_t_17); Py_XDECREF(__pyx_t_18); Py_XDECREF(__pyx_t_19);
          __Pyx_RaiseBufferFallbackError();
        } else {
          PyErr_Restore(__pyx_t_17, __pyx_t_18, __pyx_t_19);
        }
      }
      __pyx_pybuffernd_dS.diminfo[0].strides = __pyx_pybuffernd_dS.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_dS.diminfo[0].shape = __pyx_pybuffernd_dS.rcbuffer->pybuffer.shape[0];
      if (unlikely(__pyx_t_14 < 0)) __PYX_ERR(0, 484, __pyx_L1_error)
    }
    __pyx_v_dS = ((PyArrayObject *)__pyx_t_4);
    __pyx_t_4 = 0;
+485:     elif len(LPts)>1:
  __pyx_t_24 = PyList_GET_SIZE(__pyx_v_LPts); if (unlikely(__pyx_t_24 == -1)) __PYX_ERR(0, 485, __pyx_L1_error)
  __pyx_t_25 = ((__pyx_t_24 > 1) != 0);
  if (__pyx_t_25) {
/* … */
  }
  __pyx_L14:;
+486:         Pts = np.concatenate(tuple(LPts),axis=1)
    __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 486, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_12 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_concatenate); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 486, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_12);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_t_4 = PyList_AsTuple(__pyx_v_LPts); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 486, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 486, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_GIVEREF(__pyx_t_4);
    PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_4);
    __pyx_t_4 = 0;
    __pyx_t_4 = PyDict_New(); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 486, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    if (PyDict_SetItem(__pyx_t_4, __pyx_n_s_axis, __pyx_int_1) < 0) __PYX_ERR(0, 486, __pyx_L1_error)
    __pyx_t_11 = __Pyx_PyObject_Call(__pyx_t_12, __pyx_t_3, __pyx_t_4); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 486, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_11);
    __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    if (!(likely(((__pyx_t_11) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_11, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 486, __pyx_L1_error)
    __pyx_t_23 = ((PyArrayObject *)__pyx_t_11);
    {
      __Pyx_BufFmt_StackElem __pyx_stack[1];
      __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_Pts.rcbuffer->pybuffer);
      __pyx_t_14 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_Pts.rcbuffer->pybuffer, (PyObject*)__pyx_t_23, &__Pyx_TypeInfo_double, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack);
      if (unlikely(__pyx_t_14 < 0)) {
        PyErr_Fetch(&__pyx_t_19, &__pyx_t_18, &__pyx_t_17);
        if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_Pts.rcbuffer->pybuffer, (PyObject*)__pyx_v_Pts, &__Pyx_TypeInfo_double, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) {
          Py_XDECREF(__pyx_t_19); Py_XDECREF(__pyx_t_18); Py_XDECREF(__pyx_t_17);
          __Pyx_RaiseBufferFallbackError();
        } else {
          PyErr_Restore(__pyx_t_19, __pyx_t_18, __pyx_t_17);
        }
      }
      __pyx_pybuffernd_Pts.diminfo[0].strides = __pyx_pybuffernd_Pts.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_Pts.diminfo[0].shape = __pyx_pybuffernd_Pts.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_Pts.diminfo[1].strides = __pyx_pybuffernd_Pts.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_Pts.diminfo[1].shape = __pyx_pybuffernd_Pts.rcbuffer->pybuffer.shape[1];
      if (unlikely(__pyx_t_14 < 0)) __PYX_ERR(0, 486, __pyx_L1_error)
    }
    __pyx_t_23 = 0;
    __pyx_v_Pts = ((PyArrayObject *)__pyx_t_11);
    __pyx_t_11 = 0;
+487:         dS = np.concatenate(tuple(LdS))
    __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 487, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_concatenate); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 487, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_t_4 = PyList_AsTuple(__pyx_v_LdS); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 487, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_12 = NULL;
    if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) {
      __pyx_t_12 = PyMethod_GET_SELF(__pyx_t_3);
      if (likely(__pyx_t_12)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
        __Pyx_INCREF(__pyx_t_12);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_3, function);
      }
    }
    if (!__pyx_t_12) {
      __pyx_t_11 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_4); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 487, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __Pyx_GOTREF(__pyx_t_11);
    } else {
      #if CYTHON_FAST_PYCALL
      if (PyFunction_Check(__pyx_t_3)) {
        PyObject *__pyx_temp[2] = {__pyx_t_12, __pyx_t_4};
        __pyx_t_11 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 487, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0;
        __Pyx_GOTREF(__pyx_t_11);
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      } else
      #endif
      #if CYTHON_FAST_PYCCALL
      if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) {
        PyObject *__pyx_temp[2] = {__pyx_t_12, __pyx_t_4};
        __pyx_t_11 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 487, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0;
        __Pyx_GOTREF(__pyx_t_11);
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      } else
      #endif
      {
        __pyx_t_5 = PyTuple_New(1+1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 487, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_5);
        __Pyx_GIVEREF(__pyx_t_12); PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_12); __pyx_t_12 = NULL;
        __Pyx_GIVEREF(__pyx_t_4);
        PyTuple_SET_ITEM(__pyx_t_5, 0+1, __pyx_t_4);
        __pyx_t_4 = 0;
        __pyx_t_11 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_5, NULL); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 487, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_11);
        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      }
    }
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    if (!(likely(((__pyx_t_11) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_11, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 487, __pyx_L1_error)
    __pyx_t_15 = ((PyArrayObject *)__pyx_t_11);
    {
      __Pyx_BufFmt_StackElem __pyx_stack[1];
      __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_dS.rcbuffer->pybuffer);
      __pyx_t_14 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_dS.rcbuffer->pybuffer, (PyObject*)__pyx_t_15, &__Pyx_TypeInfo_double, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack);
      if (unlikely(__pyx_t_14 < 0)) {
        PyErr_Fetch(&__pyx_t_17, &__pyx_t_18, &__pyx_t_19);
        if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_dS.rcbuffer->pybuffer, (PyObject*)__pyx_v_dS, &__Pyx_TypeInfo_double, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {
          Py_XDECREF(__pyx_t_17); Py_XDECREF(__pyx_t_18); Py_XDECREF(__pyx_t_19);
          __Pyx_RaiseBufferFallbackError();
        } else {
          PyErr_Restore(__pyx_t_17, __pyx_t_18, __pyx_t_19);
        }
      }
      __pyx_pybuffernd_dS.diminfo[0].strides = __pyx_pybuffernd_dS.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_dS.diminfo[0].shape = __pyx_pybuffernd_dS.rcbuffer->pybuffer.shape[0];
      if (unlikely(__pyx_t_14 < 0)) __PYX_ERR(0, 487, __pyx_L1_error)
    }
    __pyx_t_15 = 0;
    __pyx_v_dS = ((PyArrayObject *)__pyx_t_11);
    __pyx_t_11 = 0;
 488: 
+489:     return Pts, dS, NL, dLr, Rref, dR0r, dZ0r, dRPhir, VPbis
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_11 = PyFloat_FromDouble(__pyx_v_dR0r); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 489, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_11);
  __pyx_t_3 = PyFloat_FromDouble(__pyx_v_dZ0r); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 489, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_5 = PyTuple_New(9); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 489, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_INCREF(((PyObject *)__pyx_v_Pts));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_Pts));
  PyTuple_SET_ITEM(__pyx_t_5, 0, ((PyObject *)__pyx_v_Pts));
  __Pyx_INCREF(((PyObject *)__pyx_v_dS));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_dS));
  PyTuple_SET_ITEM(__pyx_t_5, 1, ((PyObject *)__pyx_v_dS));
  __Pyx_INCREF(((PyObject *)__pyx_v_NL));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_NL));
  PyTuple_SET_ITEM(__pyx_t_5, 2, ((PyObject *)__pyx_v_NL));
  __Pyx_INCREF(((PyObject *)__pyx_v_dLr));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_dLr));
  PyTuple_SET_ITEM(__pyx_t_5, 3, ((PyObject *)__pyx_v_dLr));
  __Pyx_INCREF(((PyObject *)__pyx_v_Rref));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_Rref));
  PyTuple_SET_ITEM(__pyx_t_5, 4, ((PyObject *)__pyx_v_Rref));
  __Pyx_GIVEREF(__pyx_t_11);
  PyTuple_SET_ITEM(__pyx_t_5, 5, __pyx_t_11);
  __Pyx_GIVEREF(__pyx_t_3);
  PyTuple_SET_ITEM(__pyx_t_5, 6, __pyx_t_3);
  __Pyx_INCREF(((PyObject *)__pyx_v_dRPhir));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_dRPhir));
  PyTuple_SET_ITEM(__pyx_t_5, 7, ((PyObject *)__pyx_v_dRPhir));
  __Pyx_INCREF(((PyObject *)__pyx_v_VPbis));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_VPbis));
  PyTuple_SET_ITEM(__pyx_t_5, 8, ((PyObject *)__pyx_v_VPbis));
  __pyx_t_11 = 0;
  __pyx_t_3 = 0;
  __pyx_r = __pyx_t_5;
  __pyx_t_5 = 0;
  goto __pyx_L0;
 490: 
 491: 
 492: 
 493: 
 494: @cython.cdivision(True)
 495: @cython.wraparound(False)
 496: @cython.boundscheck(False)
+497: def _Ves_Smesh_Lin_SubFromD_cython(double[::1] XMinMax, double dL, double dX,
/* Python wrapper */
static PyObject *__pyx_pw_46_cython_magic_8152fc40fb05daa7217c00b66474f995_13_Ves_Smesh_Lin_SubFromD_cython(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_46_cython_magic_8152fc40fb05daa7217c00b66474f995_12_Ves_Smesh_Lin_SubFromD_cython[] = " Return the desired surfacic submesh indicated by the limits (DX,DY,DZ), for the desired resolution (dX,dL) ";
static PyMethodDef __pyx_mdef_46_cython_magic_8152fc40fb05daa7217c00b66474f995_13_Ves_Smesh_Lin_SubFromD_cython = {"_Ves_Smesh_Lin_SubFromD_cython", (PyCFunction)__pyx_pw_46_cython_magic_8152fc40fb05daa7217c00b66474f995_13_Ves_Smesh_Lin_SubFromD_cython, METH_VARARGS|METH_KEYWORDS, __pyx_doc_46_cython_magic_8152fc40fb05daa7217c00b66474f995_12_Ves_Smesh_Lin_SubFromD_cython};
static PyObject *__pyx_pw_46_cython_magic_8152fc40fb05daa7217c00b66474f995_13_Ves_Smesh_Lin_SubFromD_cython(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  __Pyx_memviewslice __pyx_v_XMinMax = { 0, 0, { 0 }, { 0 }, { 0 } };
  double __pyx_v_dL;
  double __pyx_v_dX;
  __Pyx_memviewslice __pyx_v_VPoly = { 0, 0, { 0 }, { 0 }, { 0 } };
  PyObject *__pyx_v_DX = 0;
  PyObject *__pyx_v_DY = 0;
  PyObject *__pyx_v_DZ = 0;
  double __pyx_v_DIn;
  PyObject *__pyx_v_VIn = 0;
  double __pyx_v_margin;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("_Ves_Smesh_Lin_SubFromD_cython (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_XMinMax,&__pyx_n_s_dL,&__pyx_n_s_dX,&__pyx_n_s_VPoly,&__pyx_n_s_DX,&__pyx_n_s_DY,&__pyx_n_s_DZ,&__pyx_n_s_DIn,&__pyx_n_s_VIn,&__pyx_n_s_margin,0};
    PyObject* values[10] = {0,0,0,0,0,0,0,0,0,0};
/* … */
  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_46_cython_magic_8152fc40fb05daa7217c00b66474f995_12_Ves_Smesh_Lin_SubFromD_cython(CYTHON_UNUSED PyObject *__pyx_self, __Pyx_memviewslice __pyx_v_XMinMax, double __pyx_v_dL, double __pyx_v_dX, __Pyx_memviewslice __pyx_v_VPoly, PyObject *__pyx_v_DX, PyObject *__pyx_v_DY, PyObject *__pyx_v_DZ, double __pyx_v_DIn, PyObject *__pyx_v_VIn, double __pyx_v_margin) {
  PyArrayObject *__pyx_v_X = 0;
  PyArrayObject *__pyx_v_Y0 = 0;
  PyArrayObject *__pyx_v_Z0 = 0;
  double __pyx_v_dXr;
  double __pyx_v_dY0r;
  double __pyx_v_dZ0r;
  int __pyx_v_NY0;
  int __pyx_v_NZ0;
  int __pyx_v_Y0n;
  int __pyx_v_Z0n;
  int __pyx_v_NX;
  int __pyx_v_Xn;
  int __pyx_v_Ln;
  int __pyx_v_NR0;
  PyArrayObject *__pyx_v_Pts = 0;
  PyArrayObject *__pyx_v_PtsCross = 0;
  PyArrayObject *__pyx_v_VPbis = 0;
  PyArrayObject *__pyx_v_dS = 0;
  PyArrayObject *__pyx_v_dLr = 0;
  PyArrayObject *__pyx_v_Rref = 0;
  PyArrayObject *__pyx_v_indX = 0;
  PyArrayObject *__pyx_v_indY0 = 0;
  PyArrayObject *__pyx_v_indZ0 = 0;
  PyArrayObject *__pyx_v_indL = 0;
  PyArrayObject *__pyx_v_NL = 0;
  PyArrayObject *__pyx_v_ind = 0;
  PyObject *__pyx_v_indin = NULL;
  PyObject *__pyx_v_pts = NULL;
  PyObject *__pyx_v_iind = NULL;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_NL;
  __Pyx_Buffer __pyx_pybuffer_NL;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_Pts;
  __Pyx_Buffer __pyx_pybuffer_Pts;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_PtsCross;
  __Pyx_Buffer __pyx_pybuffer_PtsCross;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_Rref;
  __Pyx_Buffer __pyx_pybuffer_Rref;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_VPbis;
  __Pyx_Buffer __pyx_pybuffer_VPbis;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_X;
  __Pyx_Buffer __pyx_pybuffer_X;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_Y0;
  __Pyx_Buffer __pyx_pybuffer_Y0;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_Z0;
  __Pyx_Buffer __pyx_pybuffer_Z0;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_dLr;
  __Pyx_Buffer __pyx_pybuffer_dLr;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_dS;
  __Pyx_Buffer __pyx_pybuffer_dS;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_ind;
  __Pyx_Buffer __pyx_pybuffer_ind;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_indL;
  __Pyx_Buffer __pyx_pybuffer_indL;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_indX;
  __Pyx_Buffer __pyx_pybuffer_indX;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_indY0;
  __Pyx_Buffer __pyx_pybuffer_indY0;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_indZ0;
  __Pyx_Buffer __pyx_pybuffer_indZ0;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("_Ves_Smesh_Lin_SubFromD_cython", 0);
  __pyx_pybuffer_X.pybuffer.buf = NULL;
  __pyx_pybuffer_X.refcount = 0;
  __pyx_pybuffernd_X.data = NULL;
  __pyx_pybuffernd_X.rcbuffer = &__pyx_pybuffer_X;
  __pyx_pybuffer_Y0.pybuffer.buf = NULL;
  __pyx_pybuffer_Y0.refcount = 0;
  __pyx_pybuffernd_Y0.data = NULL;
  __pyx_pybuffernd_Y0.rcbuffer = &__pyx_pybuffer_Y0;
  __pyx_pybuffer_Z0.pybuffer.buf = NULL;
  __pyx_pybuffer_Z0.refcount = 0;
  __pyx_pybuffernd_Z0.data = NULL;
  __pyx_pybuffernd_Z0.rcbuffer = &__pyx_pybuffer_Z0;
  __pyx_pybuffer_Pts.pybuffer.buf = NULL;
  __pyx_pybuffer_Pts.refcount = 0;
  __pyx_pybuffernd_Pts.data = NULL;
  __pyx_pybuffernd_Pts.rcbuffer = &__pyx_pybuffer_Pts;
  __pyx_pybuffer_PtsCross.pybuffer.buf = NULL;
  __pyx_pybuffer_PtsCross.refcount = 0;
  __pyx_pybuffernd_PtsCross.data = NULL;
  __pyx_pybuffernd_PtsCross.rcbuffer = &__pyx_pybuffer_PtsCross;
  __pyx_pybuffer_VPbis.pybuffer.buf = NULL;
  __pyx_pybuffer_VPbis.refcount = 0;
  __pyx_pybuffernd_VPbis.data = NULL;
  __pyx_pybuffernd_VPbis.rcbuffer = &__pyx_pybuffer_VPbis;
  __pyx_pybuffer_dS.pybuffer.buf = NULL;
  __pyx_pybuffer_dS.refcount = 0;
  __pyx_pybuffernd_dS.data = NULL;
  __pyx_pybuffernd_dS.rcbuffer = &__pyx_pybuffer_dS;
  __pyx_pybuffer_dLr.pybuffer.buf = NULL;
  __pyx_pybuffer_dLr.refcount = 0;
  __pyx_pybuffernd_dLr.data = NULL;
  __pyx_pybuffernd_dLr.rcbuffer = &__pyx_pybuffer_dLr;
  __pyx_pybuffer_Rref.pybuffer.buf = NULL;
  __pyx_pybuffer_Rref.refcount = 0;
  __pyx_pybuffernd_Rref.data = NULL;
  __pyx_pybuffernd_Rref.rcbuffer = &__pyx_pybuffer_Rref;
  __pyx_pybuffer_indX.pybuffer.buf = NULL;
  __pyx_pybuffer_indX.refcount = 0;
  __pyx_pybuffernd_indX.data = NULL;
  __pyx_pybuffernd_indX.rcbuffer = &__pyx_pybuffer_indX;
  __pyx_pybuffer_indY0.pybuffer.buf = NULL;
  __pyx_pybuffer_indY0.refcount = 0;
  __pyx_pybuffernd_indY0.data = NULL;
  __pyx_pybuffernd_indY0.rcbuffer = &__pyx_pybuffer_indY0;
  __pyx_pybuffer_indZ0.pybuffer.buf = NULL;
  __pyx_pybuffer_indZ0.refcount = 0;
  __pyx_pybuffernd_indZ0.data = NULL;
  __pyx_pybuffernd_indZ0.rcbuffer = &__pyx_pybuffer_indZ0;
  __pyx_pybuffer_indL.pybuffer.buf = NULL;
  __pyx_pybuffer_indL.refcount = 0;
  __pyx_pybuffernd_indL.data = NULL;
  __pyx_pybuffernd_indL.rcbuffer = &__pyx_pybuffer_indL;
  __pyx_pybuffer_NL.pybuffer.buf = NULL;
  __pyx_pybuffer_NL.refcount = 0;
  __pyx_pybuffernd_NL.data = NULL;
  __pyx_pybuffernd_NL.rcbuffer = &__pyx_pybuffer_NL;
  __pyx_pybuffer_ind.pybuffer.buf = NULL;
  __pyx_pybuffer_ind.refcount = 0;
  __pyx_pybuffernd_ind.data = NULL;
  __pyx_pybuffernd_ind.rcbuffer = &__pyx_pybuffer_ind;
/* … */
  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_8);
  __PYX_XDEC_MEMVIEW(&__pyx_t_9, 1);
  __Pyx_XDECREF(__pyx_t_10);
  __Pyx_XDECREF(__pyx_t_11);
  __Pyx_XDECREF(__pyx_t_12);
  __Pyx_XDECREF(__pyx_t_13);
  __Pyx_XDECREF(__pyx_t_14);
  __Pyx_XDECREF(__pyx_t_28);
  __PYX_XDEC_MEMVIEW(&__pyx_t_31, 1);
  { PyObject *__pyx_type, *__pyx_value, *__pyx_tb;
    __Pyx_PyThreadState_declare
    __Pyx_PyThreadState_assign
    __Pyx_ErrFetch(&__pyx_type, &__pyx_value, &__pyx_tb);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_NL.rcbuffer->pybuffer);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_Pts.rcbuffer->pybuffer);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_PtsCross.rcbuffer->pybuffer);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_Rref.rcbuffer->pybuffer);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_VPbis.rcbuffer->pybuffer);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_X.rcbuffer->pybuffer);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_Y0.rcbuffer->pybuffer);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_Z0.rcbuffer->pybuffer);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_dLr.rcbuffer->pybuffer);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_dS.rcbuffer->pybuffer);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_ind.rcbuffer->pybuffer);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_indL.rcbuffer->pybuffer);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_indX.rcbuffer->pybuffer);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_indY0.rcbuffer->pybuffer);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_indZ0.rcbuffer->pybuffer);
  __Pyx_ErrRestore(__pyx_type, __pyx_value, __pyx_tb);}
  __Pyx_AddTraceback("_cython_magic_8152fc40fb05daa7217c00b66474f995._Ves_Smesh_Lin_SubFromD_cython", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  goto __pyx_L2;
  __pyx_L0:;
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_NL.rcbuffer->pybuffer);
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_Pts.rcbuffer->pybuffer);
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_PtsCross.rcbuffer->pybuffer);
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_Rref.rcbuffer->pybuffer);
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_VPbis.rcbuffer->pybuffer);
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_X.rcbuffer->pybuffer);
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_Y0.rcbuffer->pybuffer);
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_Z0.rcbuffer->pybuffer);
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_dLr.rcbuffer->pybuffer);
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_dS.rcbuffer->pybuffer);
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_ind.rcbuffer->pybuffer);
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_indL.rcbuffer->pybuffer);
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_indX.rcbuffer->pybuffer);
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_indY0.rcbuffer->pybuffer);
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_indZ0.rcbuffer->pybuffer);
  __pyx_L2:;
  __Pyx_XDECREF((PyObject *)__pyx_v_X);
  __Pyx_XDECREF((PyObject *)__pyx_v_Y0);
  __Pyx_XDECREF((PyObject *)__pyx_v_Z0);
  __Pyx_XDECREF((PyObject *)__pyx_v_Pts);
  __Pyx_XDECREF((PyObject *)__pyx_v_PtsCross);
  __Pyx_XDECREF((PyObject *)__pyx_v_VPbis);
  __Pyx_XDECREF((PyObject *)__pyx_v_dS);
  __Pyx_XDECREF((PyObject *)__pyx_v_dLr);
  __Pyx_XDECREF((PyObject *)__pyx_v_Rref);
  __Pyx_XDECREF((PyObject *)__pyx_v_indX);
  __Pyx_XDECREF((PyObject *)__pyx_v_indY0);
  __Pyx_XDECREF((PyObject *)__pyx_v_indZ0);
  __Pyx_XDECREF((PyObject *)__pyx_v_indL);
  __Pyx_XDECREF((PyObject *)__pyx_v_NL);
  __Pyx_XDECREF((PyObject *)__pyx_v_ind);
  __Pyx_XDECREF(__pyx_v_indin);
  __Pyx_XDECREF(__pyx_v_pts);
  __Pyx_XDECREF(__pyx_v_iind);
  __PYX_XDEC_MEMVIEW(&__pyx_v_XMinMax, 1);
  __PYX_XDEC_MEMVIEW(&__pyx_v_VPoly, 1);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}
/* … */
  __pyx_tuple__117 = PyTuple_Pack(39, __pyx_n_s_XMinMax, __pyx_n_s_dL, __pyx_n_s_dX, __pyx_n_s_VPoly, __pyx_n_s_DX, __pyx_n_s_DY, __pyx_n_s_DZ, __pyx_n_s_DIn, __pyx_n_s_VIn, __pyx_n_s_margin, __pyx_n_s_X, __pyx_n_s_Y0, __pyx_n_s_Z0, __pyx_n_s_dXr, __pyx_n_s_dY0r, __pyx_n_s_dZ0r, __pyx_n_s_NY0, __pyx_n_s_NZ0, __pyx_n_s_Y0n, __pyx_n_s_Z0n, __pyx_n_s_NX, __pyx_n_s_Xn, __pyx_n_s_Ln, __pyx_n_s_NR0, __pyx_n_s_Pts, __pyx_n_s_PtsCross, __pyx_n_s_VPbis, __pyx_n_s_dS, __pyx_n_s_dLr, __pyx_n_s_Rref, __pyx_n_s_indX, __pyx_n_s_indY0, __pyx_n_s_indZ0, __pyx_n_s_indL, __pyx_n_s_NL, __pyx_n_s_ind, __pyx_n_s_indin, __pyx_n_s_pts, __pyx_n_s_iind); if (unlikely(!__pyx_tuple__117)) __PYX_ERR(0, 497, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__117);
  __Pyx_GIVEREF(__pyx_tuple__117);
/* … */
  __pyx_t_2 = PyCFunction_NewEx(&__pyx_mdef_46_cython_magic_8152fc40fb05daa7217c00b66474f995_13_Ves_Smesh_Lin_SubFromD_cython, NULL, __pyx_n_s_cython_magic_8152fc40fb05daa721); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 497, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_Ves_Smesh_Lin_SubFromD_cython, __pyx_t_2) < 0) __PYX_ERR(0, 497, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_codeobj__118 = (PyObject*)__Pyx_PyCode_New(10, 0, 39, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__117, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_Home_DV226270_cache_ipython_cyt, __pyx_n_s_Ves_Smesh_Lin_SubFromD_cython, 497, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__118)) __PYX_ERR(0, 497, __pyx_L1_error)
 498:                                    double[:,::1] VPoly,
+499:                                    DX=None, DY=None, DZ=None,
    values[4] = ((PyObject *)Py_None);
    values[5] = ((PyObject *)Py_None);
    values[6] = ((PyObject *)Py_None);
+500:                                    double DIn=0., VIn=None, double margin=1.e-9):
    values[8] = ((PyObject *)Py_None);
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case 10: values[9] = PyTuple_GET_ITEM(__pyx_args, 9);
        case  9: values[8] = PyTuple_GET_ITEM(__pyx_args, 8);
        case  8: values[7] = PyTuple_GET_ITEM(__pyx_args, 7);
        case  7: values[6] = PyTuple_GET_ITEM(__pyx_args, 6);
        case  6: values[5] = PyTuple_GET_ITEM(__pyx_args, 5);
        case  5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_XMinMax)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        case  1:
        if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_dL)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_Ves_Smesh_Lin_SubFromD_cython", 0, 4, 10, 1); __PYX_ERR(0, 497, __pyx_L3_error)
        }
        case  2:
        if (likely((values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_dX)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_Ves_Smesh_Lin_SubFromD_cython", 0, 4, 10, 2); __PYX_ERR(0, 497, __pyx_L3_error)
        }
        case  3:
        if (likely((values[3] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_VPoly)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_Ves_Smesh_Lin_SubFromD_cython", 0, 4, 10, 3); __PYX_ERR(0, 497, __pyx_L3_error)
        }
        case  4:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_DX);
          if (value) { values[4] = value; kw_args--; }
        }
        case  5:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_DY);
          if (value) { values[5] = value; kw_args--; }
        }
        case  6:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_DZ);
          if (value) { values[6] = value; kw_args--; }
        }
        case  7:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_DIn);
          if (value) { values[7] = value; kw_args--; }
        }
        case  8:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_VIn);
          if (value) { values[8] = value; kw_args--; }
        }
        case  9:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_margin);
          if (value) { values[9] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "_Ves_Smesh_Lin_SubFromD_cython") < 0)) __PYX_ERR(0, 497, __pyx_L3_error)
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case 10: values[9] = PyTuple_GET_ITEM(__pyx_args, 9);
        case  9: values[8] = PyTuple_GET_ITEM(__pyx_args, 8);
        case  8: values[7] = PyTuple_GET_ITEM(__pyx_args, 7);
        case  7: values[6] = PyTuple_GET_ITEM(__pyx_args, 6);
        case  6: values[5] = PyTuple_GET_ITEM(__pyx_args, 5);
        case  5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    __pyx_v_XMinMax = __Pyx_PyObject_to_MemoryviewSlice_dc_double(values[0]); if (unlikely(!__pyx_v_XMinMax.memview)) __PYX_ERR(0, 497, __pyx_L3_error)
    __pyx_v_dL = __pyx_PyFloat_AsDouble(values[1]); if (unlikely((__pyx_v_dL == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 497, __pyx_L3_error)
    __pyx_v_dX = __pyx_PyFloat_AsDouble(values[2]); if (unlikely((__pyx_v_dX == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 497, __pyx_L3_error)
    __pyx_v_VPoly = __Pyx_PyObject_to_MemoryviewSlice_d_dc_double(values[3]); if (unlikely(!__pyx_v_VPoly.memview)) __PYX_ERR(0, 498, __pyx_L3_error)
    __pyx_v_DX = values[4];
    __pyx_v_DY = values[5];
    __pyx_v_DZ = values[6];
    if (values[7]) {
      __pyx_v_DIn = __pyx_PyFloat_AsDouble(values[7]); if (unlikely((__pyx_v_DIn == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 500, __pyx_L3_error)
    } else {
      __pyx_v_DIn = ((double)0.);
    }
    __pyx_v_VIn = values[8];
    if (values[9]) {
      __pyx_v_margin = __pyx_PyFloat_AsDouble(values[9]); if (unlikely((__pyx_v_margin == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 500, __pyx_L3_error)
    } else {
      __pyx_v_margin = ((double)1.e-9);
    }
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("_Ves_Smesh_Lin_SubFromD_cython", 0, 4, 10, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 497, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("_cython_magic_8152fc40fb05daa7217c00b66474f995._Ves_Smesh_Lin_SubFromD_cython", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_46_cython_magic_8152fc40fb05daa7217c00b66474f995_12_Ves_Smesh_Lin_SubFromD_cython(__pyx_self, __pyx_v_XMinMax, __pyx_v_dL, __pyx_v_dX, __pyx_v_VPoly, __pyx_v_DX, __pyx_v_DY, __pyx_v_DZ, __pyx_v_DIn, __pyx_v_VIn, __pyx_v_margin);
 501:     " Return the desired surfacic submesh indicated by the limits (DX,DY,DZ), for the desired resolution (dX,dL) "
 502:     cdef cnp.ndarray[double,ndim=1] X, Y0, Z0
 503:     cdef double dXr, dY0r, dZ0r
 504:     cdef int NY0, NZ0, Y0n, Z0n, NX, Xn, Ln, NR0
 505:     cdef cnp.ndarray[double,ndim=2] Pts, PtsCross, VPbis
 506:     cdef cnp.ndarray[double,ndim=1] dS, dLr, Rref
 507:     cdef cnp.ndarray[long,ndim=1] indX, indY0, indZ0, indL, NL, ind
 508: 
 509:     # Preformat
+510:     if DX is not None:
  __pyx_t_1 = (__pyx_v_DX != Py_None);
  __pyx_t_2 = (__pyx_t_1 != 0);
  if (__pyx_t_2) {
/* … */
  }
+511:         if DX[0]<=XMinMax[0]:
    __pyx_t_3 = __Pyx_GetItemInt(__pyx_v_DX, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 511, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_4 = 0;
    __pyx_t_5 = PyFloat_FromDouble((*((double *) ( /* dim=0 */ ((char *) (((double *) __pyx_v_XMinMax.data) + __pyx_t_4)) )))); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 511, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_6 = PyObject_RichCompare(__pyx_t_3, __pyx_t_5, Py_LE); __Pyx_XGOTREF(__pyx_t_6); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 511, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_6); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(0, 511, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    if (__pyx_t_2) {
/* … */
    }
+512:             DX[0] = None
      if (unlikely(__Pyx_SetItemInt(__pyx_v_DX, 0, Py_None, long, 1, __Pyx_PyInt_From_long, 0, 0, 0) < 0)) __PYX_ERR(0, 512, __pyx_L1_error)
+513:         if DX[1]>=XMinMax[1]:
    __pyx_t_6 = __Pyx_GetItemInt(__pyx_v_DX, 1, long, 1, __Pyx_PyInt_From_long, 0, 0, 0); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 513, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_t_7 = 1;
    __pyx_t_5 = PyFloat_FromDouble((*((double *) ( /* dim=0 */ ((char *) (((double *) __pyx_v_XMinMax.data) + __pyx_t_7)) )))); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 513, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_3 = PyObject_RichCompare(__pyx_t_6, __pyx_t_5, Py_GE); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 513, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(0, 513, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    if (__pyx_t_2) {
/* … */
    }
+514:             DX[1] = None
      if (unlikely(__Pyx_SetItemInt(__pyx_v_DX, 1, Py_None, long, 1, __Pyx_PyInt_From_long, 0, 0, 0) < 0)) __PYX_ERR(0, 514, __pyx_L1_error)
+515:     if DY is not None:
  __pyx_t_2 = (__pyx_v_DY != Py_None);
  __pyx_t_1 = (__pyx_t_2 != 0);
  if (__pyx_t_1) {
/* … */
  }
+516:         if DY[0]<=np.min(VPoly[0,:]):
    __pyx_t_3 = __Pyx_GetItemInt(__pyx_v_DY, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 516, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_6 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 516, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_n_s_min); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 516, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_8);
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __pyx_t_9.data = __pyx_v_VPoly.data;
    __pyx_t_9.memview = __pyx_v_VPoly.memview;
    __PYX_INC_MEMVIEW(&__pyx_t_9, 0);
    {
    Py_ssize_t __pyx_tmp_idx = 0;
    Py_ssize_t __pyx_tmp_shape = __pyx_v_VPoly.shape[0];
    Py_ssize_t __pyx_tmp_stride = __pyx_v_VPoly.strides[0];
    if (0 && (__pyx_tmp_idx < 0))
        __pyx_tmp_idx += __pyx_tmp_shape;
    if (0 && (__pyx_tmp_idx < 0 || __pyx_tmp_idx >= __pyx_tmp_shape)) {
        PyErr_SetString(PyExc_IndexError, "Index out of bounds (axis 0)");
        __PYX_ERR(0, 516, __pyx_L1_error)
    }
        __pyx_t_9.data += __pyx_tmp_idx * __pyx_tmp_stride;
}

__pyx_t_9.shape[0] = __pyx_v_VPoly.shape[1];
__pyx_t_9.strides[0] = __pyx_v_VPoly.strides[1];
    __pyx_t_9.suboffsets[0] = -1;

__pyx_t_6 = __pyx_memoryview_fromslice(__pyx_t_9, 1, (PyObject *(*)(char *)) __pyx_memview_get_double, (int (*)(char *, PyObject *)) __pyx_memview_set_double, 0);; if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 516, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __PYX_XDEC_MEMVIEW(&__pyx_t_9, 1);
    __pyx_t_9.memview = NULL;
    __pyx_t_9.data = NULL;
    __pyx_t_10 = NULL;
    if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_8))) {
      __pyx_t_10 = PyMethod_GET_SELF(__pyx_t_8);
      if (likely(__pyx_t_10)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_8);
        __Pyx_INCREF(__pyx_t_10);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_8, function);
      }
    }
    if (!__pyx_t_10) {
      __pyx_t_5 = __Pyx_PyObject_CallOneArg(__pyx_t_8, __pyx_t_6); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 516, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      __Pyx_GOTREF(__pyx_t_5);
    } else {
      #if CYTHON_FAST_PYCALL
      if (PyFunction_Check(__pyx_t_8)) {
        PyObject *__pyx_temp[2] = {__pyx_t_10, __pyx_t_6};
        __pyx_t_5 = __Pyx_PyFunction_FastCall(__pyx_t_8, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 516, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
        __Pyx_GOTREF(__pyx_t_5);
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      } else
      #endif
      #if CYTHON_FAST_PYCCALL
      if (__Pyx_PyFastCFunction_Check(__pyx_t_8)) {
        PyObject *__pyx_temp[2] = {__pyx_t_10, __pyx_t_6};
        __pyx_t_5 = __Pyx_PyCFunction_FastCall(__pyx_t_8, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 516, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
        __Pyx_GOTREF(__pyx_t_5);
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      } else
      #endif
      {
        __pyx_t_11 = PyTuple_New(1+1); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 516, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_11);
        __Pyx_GIVEREF(__pyx_t_10); PyTuple_SET_ITEM(__pyx_t_11, 0, __pyx_t_10); __pyx_t_10 = NULL;
        __Pyx_GIVEREF(__pyx_t_6);
        PyTuple_SET_ITEM(__pyx_t_11, 0+1, __pyx_t_6);
        __pyx_t_6 = 0;
        __pyx_t_5 = __Pyx_PyObject_Call(__pyx_t_8, __pyx_t_11, NULL); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 516, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_5);
        __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
      }
    }
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    __pyx_t_8 = PyObject_RichCompare(__pyx_t_3, __pyx_t_5, Py_LE); __Pyx_XGOTREF(__pyx_t_8); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 516, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_t_8); if (unlikely(__pyx_t_1 < 0)) __PYX_ERR(0, 516, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    if (__pyx_t_1) {
/* … */
    }
+517:             DY[0] = None
      if (unlikely(__Pyx_SetItemInt(__pyx_v_DY, 0, Py_None, long, 1, __Pyx_PyInt_From_long, 0, 0, 0) < 0)) __PYX_ERR(0, 517, __pyx_L1_error)
+518:         if DY[1]>=np.max(VPoly[0,:]):
    __pyx_t_8 = __Pyx_GetItemInt(__pyx_v_DY, 1, long, 1, __Pyx_PyInt_From_long, 0, 0, 0); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 518, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_8);
    __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 518, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_11 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_max); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 518, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_11);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_t_9.data = __pyx_v_VPoly.data;
    __pyx_t_9.memview = __pyx_v_VPoly.memview;
    __PYX_INC_MEMVIEW(&__pyx_t_9, 0);
    {
    Py_ssize_t __pyx_tmp_idx = 0;
    Py_ssize_t __pyx_tmp_shape = __pyx_v_VPoly.shape[0];
    Py_ssize_t __pyx_tmp_stride = __pyx_v_VPoly.strides[0];
    if (0 && (__pyx_tmp_idx < 0))
        __pyx_tmp_idx += __pyx_tmp_shape;
    if (0 && (__pyx_tmp_idx < 0 || __pyx_tmp_idx >= __pyx_tmp_shape)) {
        PyErr_SetString(PyExc_IndexError, "Index out of bounds (axis 0)");
        __PYX_ERR(0, 518, __pyx_L1_error)
    }
        __pyx_t_9.data += __pyx_tmp_idx * __pyx_tmp_stride;
}

__pyx_t_9.shape[0] = __pyx_v_VPoly.shape[1];
__pyx_t_9.strides[0] = __pyx_v_VPoly.strides[1];
    __pyx_t_9.suboffsets[0] = -1;

__pyx_t_3 = __pyx_memoryview_fromslice(__pyx_t_9, 1, (PyObject *(*)(char *)) __pyx_memview_get_double, (int (*)(char *, PyObject *)) __pyx_memview_set_double, 0);; if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 518, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __PYX_XDEC_MEMVIEW(&__pyx_t_9, 1);
    __pyx_t_9.memview = NULL;
    __pyx_t_9.data = NULL;
    __pyx_t_6 = NULL;
    if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_11))) {
      __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_11);
      if (likely(__pyx_t_6)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_11);
        __Pyx_INCREF(__pyx_t_6);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_11, function);
      }
    }
    if (!__pyx_t_6) {
      __pyx_t_5 = __Pyx_PyObject_CallOneArg(__pyx_t_11, __pyx_t_3); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 518, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __Pyx_GOTREF(__pyx_t_5);
    } else {
      #if CYTHON_FAST_PYCALL
      if (PyFunction_Check(__pyx_t_11)) {
        PyObject *__pyx_temp[2] = {__pyx_t_6, __pyx_t_3};
        __pyx_t_5 = __Pyx_PyFunction_FastCall(__pyx_t_11, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 518, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
        __Pyx_GOTREF(__pyx_t_5);
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      } else
      #endif
      #if CYTHON_FAST_PYCCALL
      if (__Pyx_PyFastCFunction_Check(__pyx_t_11)) {
        PyObject *__pyx_temp[2] = {__pyx_t_6, __pyx_t_3};
        __pyx_t_5 = __Pyx_PyCFunction_FastCall(__pyx_t_11, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 518, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
        __Pyx_GOTREF(__pyx_t_5);
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      } else
      #endif
      {
        __pyx_t_10 = PyTuple_New(1+1); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 518, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_10);
        __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_10, 0, __pyx_t_6); __pyx_t_6 = NULL;
        __Pyx_GIVEREF(__pyx_t_3);
        PyTuple_SET_ITEM(__pyx_t_10, 0+1, __pyx_t_3);
        __pyx_t_3 = 0;
        __pyx_t_5 = __Pyx_PyObject_Call(__pyx_t_11, __pyx_t_10, NULL); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 518, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_5);
        __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
      }
    }
    __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
    __pyx_t_11 = PyObject_RichCompare(__pyx_t_8, __pyx_t_5, Py_GE); __Pyx_XGOTREF(__pyx_t_11); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 518, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_t_11); if (unlikely(__pyx_t_1 < 0)) __PYX_ERR(0, 518, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
    if (__pyx_t_1) {
/* … */
    }
+519:             DY[1] = None
      if (unlikely(__Pyx_SetItemInt(__pyx_v_DY, 1, Py_None, long, 1, __Pyx_PyInt_From_long, 0, 0, 0) < 0)) __PYX_ERR(0, 519, __pyx_L1_error)
+520:     if DZ is not None:
  __pyx_t_1 = (__pyx_v_DZ != Py_None);
  __pyx_t_2 = (__pyx_t_1 != 0);
  if (__pyx_t_2) {
/* … */
  }
+521:         if DZ[0]<=np.min(VPoly[1,:]):
    __pyx_t_11 = __Pyx_GetItemInt(__pyx_v_DZ, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 0); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 521, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_11);
    __pyx_t_8 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 521, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_8);
    __pyx_t_10 = __Pyx_PyObject_GetAttrStr(__pyx_t_8, __pyx_n_s_min); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 521, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_10);
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    __pyx_t_9.data = __pyx_v_VPoly.data;
    __pyx_t_9.memview = __pyx_v_VPoly.memview;
    __PYX_INC_MEMVIEW(&__pyx_t_9, 0);
    {
    Py_ssize_t __pyx_tmp_idx = 1;
    Py_ssize_t __pyx_tmp_shape = __pyx_v_VPoly.shape[0];
    Py_ssize_t __pyx_tmp_stride = __pyx_v_VPoly.strides[0];
    if (0 && (__pyx_tmp_idx < 0))
        __pyx_tmp_idx += __pyx_tmp_shape;
    if (0 && (__pyx_tmp_idx < 0 || __pyx_tmp_idx >= __pyx_tmp_shape)) {
        PyErr_SetString(PyExc_IndexError, "Index out of bounds (axis 0)");
        __PYX_ERR(0, 521, __pyx_L1_error)
    }
        __pyx_t_9.data += __pyx_tmp_idx * __pyx_tmp_stride;
}

__pyx_t_9.shape[0] = __pyx_v_VPoly.shape[1];
__pyx_t_9.strides[0] = __pyx_v_VPoly.strides[1];
    __pyx_t_9.suboffsets[0] = -1;

__pyx_t_8 = __pyx_memoryview_fromslice(__pyx_t_9, 1, (PyObject *(*)(char *)) __pyx_memview_get_double, (int (*)(char *, PyObject *)) __pyx_memview_set_double, 0);; if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 521, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_8);
    __PYX_XDEC_MEMVIEW(&__pyx_t_9, 1);
    __pyx_t_9.memview = NULL;
    __pyx_t_9.data = NULL;
    __pyx_t_3 = NULL;
    if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_10))) {
      __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_10);
      if (likely(__pyx_t_3)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_10);
        __Pyx_INCREF(__pyx_t_3);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_10, function);
      }
    }
    if (!__pyx_t_3) {
      __pyx_t_5 = __Pyx_PyObject_CallOneArg(__pyx_t_10, __pyx_t_8); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 521, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
      __Pyx_GOTREF(__pyx_t_5);
    } else {
      #if CYTHON_FAST_PYCALL
      if (PyFunction_Check(__pyx_t_10)) {
        PyObject *__pyx_temp[2] = {__pyx_t_3, __pyx_t_8};
        __pyx_t_5 = __Pyx_PyFunction_FastCall(__pyx_t_10, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 521, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
        __Pyx_GOTREF(__pyx_t_5);
        __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
      } else
      #endif
      #if CYTHON_FAST_PYCCALL
      if (__Pyx_PyFastCFunction_Check(__pyx_t_10)) {
        PyObject *__pyx_temp[2] = {__pyx_t_3, __pyx_t_8};
        __pyx_t_5 = __Pyx_PyCFunction_FastCall(__pyx_t_10, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 521, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
        __Pyx_GOTREF(__pyx_t_5);
        __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
      } else
      #endif
      {
        __pyx_t_6 = PyTuple_New(1+1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 521, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_6);
        __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_3); __pyx_t_3 = NULL;
        __Pyx_GIVEREF(__pyx_t_8);
        PyTuple_SET_ITEM(__pyx_t_6, 0+1, __pyx_t_8);
        __pyx_t_8 = 0;
        __pyx_t_5 = __Pyx_PyObject_Call(__pyx_t_10, __pyx_t_6, NULL); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 521, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_5);
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      }
    }
    __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
    __pyx_t_10 = PyObject_RichCompare(__pyx_t_11, __pyx_t_5, Py_LE); __Pyx_XGOTREF(__pyx_t_10); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 521, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_10); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(0, 521, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
    if (__pyx_t_2) {
/* … */
    }
+522:             DZ[0] = None
      if (unlikely(__Pyx_SetItemInt(__pyx_v_DZ, 0, Py_None, long, 1, __Pyx_PyInt_From_long, 0, 0, 0) < 0)) __PYX_ERR(0, 522, __pyx_L1_error)
+523:         if DZ[1]>=np.max(VPoly[1,:]):
    __pyx_t_10 = __Pyx_GetItemInt(__pyx_v_DZ, 1, long, 1, __Pyx_PyInt_From_long, 0, 0, 0); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 523, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_10);
    __pyx_t_11 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 523, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_11);
    __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_11, __pyx_n_s_max); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 523, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
    __pyx_t_9.data = __pyx_v_VPoly.data;
    __pyx_t_9.memview = __pyx_v_VPoly.memview;
    __PYX_INC_MEMVIEW(&__pyx_t_9, 0);
    {
    Py_ssize_t __pyx_tmp_idx = 1;
    Py_ssize_t __pyx_tmp_shape = __pyx_v_VPoly.shape[0];
    Py_ssize_t __pyx_tmp_stride = __pyx_v_VPoly.strides[0];
    if (0 && (__pyx_tmp_idx < 0))
        __pyx_tmp_idx += __pyx_tmp_shape;
    if (0 && (__pyx_tmp_idx < 0 || __pyx_tmp_idx >= __pyx_tmp_shape)) {
        PyErr_SetString(PyExc_IndexError, "Index out of bounds (axis 0)");
        __PYX_ERR(0, 523, __pyx_L1_error)
    }
        __pyx_t_9.data += __pyx_tmp_idx * __pyx_tmp_stride;
}

__pyx_t_9.shape[0] = __pyx_v_VPoly.shape[1];
__pyx_t_9.strides[0] = __pyx_v_VPoly.strides[1];
    __pyx_t_9.suboffsets[0] = -1;

__pyx_t_11 = __pyx_memoryview_fromslice(__pyx_t_9, 1, (PyObject *(*)(char *)) __pyx_memview_get_double, (int (*)(char *, PyObject *)) __pyx_memview_set_double, 0);; if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 523, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_11);
    __PYX_XDEC_MEMVIEW(&__pyx_t_9, 1);
    __pyx_t_9.memview = NULL;
    __pyx_t_9.data = NULL;
    __pyx_t_8 = NULL;
    if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_6))) {
      __pyx_t_8 = PyMethod_GET_SELF(__pyx_t_6);
      if (likely(__pyx_t_8)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6);
        __Pyx_INCREF(__pyx_t_8);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_6, function);
      }
    }
    if (!__pyx_t_8) {
      __pyx_t_5 = __Pyx_PyObject_CallOneArg(__pyx_t_6, __pyx_t_11); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 523, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
      __Pyx_GOTREF(__pyx_t_5);
    } else {
      #if CYTHON_FAST_PYCALL
      if (PyFunction_Check(__pyx_t_6)) {
        PyObject *__pyx_temp[2] = {__pyx_t_8, __pyx_t_11};
        __pyx_t_5 = __Pyx_PyFunction_FastCall(__pyx_t_6, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 523, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
        __Pyx_GOTREF(__pyx_t_5);
        __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
      } else
      #endif
      #if CYTHON_FAST_PYCCALL
      if (__Pyx_PyFastCFunction_Check(__pyx_t_6)) {
        PyObject *__pyx_temp[2] = {__pyx_t_8, __pyx_t_11};
        __pyx_t_5 = __Pyx_PyCFunction_FastCall(__pyx_t_6, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 523, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
        __Pyx_GOTREF(__pyx_t_5);
        __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
      } else
      #endif
      {
        __pyx_t_3 = PyTuple_New(1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 523, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_3);
        __Pyx_GIVEREF(__pyx_t_8); PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_8); __pyx_t_8 = NULL;
        __Pyx_GIVEREF(__pyx_t_11);
        PyTuple_SET_ITEM(__pyx_t_3, 0+1, __pyx_t_11);
        __pyx_t_11 = 0;
        __pyx_t_5 = __Pyx_PyObject_Call(__pyx_t_6, __pyx_t_3, NULL); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 523, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_5);
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      }
    }
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __pyx_t_6 = PyObject_RichCompare(__pyx_t_10, __pyx_t_5, Py_GE); __Pyx_XGOTREF(__pyx_t_6); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 523, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_6); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(0, 523, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    if (__pyx_t_2) {
/* … */
    }
+524:             DZ[1] = None
      if (unlikely(__Pyx_SetItemInt(__pyx_v_DZ, 1, Py_None, long, 1, __Pyx_PyInt_From_long, 0, 0, 0) < 0)) __PYX_ERR(0, 524, __pyx_L1_error)
 525: 
 526:     # Get the mesh for the faces
+527:     Y0, dY0r, indY0, NY0 = _Ves_mesh_dlfromL_cython(np.array([np.min(VPoly[0,:]),np.max(VPoly[0,:])]), dL, DL=DY, margin=margin)
  __pyx_t_6 = __Pyx_GetModuleGlobalName(__pyx_n_s_Ves_mesh_dlfromL_cython); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 527, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __pyx_t_10 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 527, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_10);
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_10, __pyx_n_s_array); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 527, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
  __pyx_t_11 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 527, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_11);
  __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_t_11, __pyx_n_s_min); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 527, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);
  __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
  __pyx_t_9.data = __pyx_v_VPoly.data;
  __pyx_t_9.memview = __pyx_v_VPoly.memview;
  __PYX_INC_MEMVIEW(&__pyx_t_9, 0);
  {
    Py_ssize_t __pyx_tmp_idx = 0;
    Py_ssize_t __pyx_tmp_shape = __pyx_v_VPoly.shape[0];
    Py_ssize_t __pyx_tmp_stride = __pyx_v_VPoly.strides[0];
    if (0 && (__pyx_tmp_idx < 0))
        __pyx_tmp_idx += __pyx_tmp_shape;
    if (0 && (__pyx_tmp_idx < 0 || __pyx_tmp_idx >= __pyx_tmp_shape)) {
        PyErr_SetString(PyExc_IndexError, "Index out of bounds (axis 0)");
        __PYX_ERR(0, 527, __pyx_L1_error)
    }
        __pyx_t_9.data += __pyx_tmp_idx * __pyx_tmp_stride;
}

__pyx_t_9.shape[0] = __pyx_v_VPoly.shape[1];
__pyx_t_9.strides[0] = __pyx_v_VPoly.strides[1];
    __pyx_t_9.suboffsets[0] = -1;

__pyx_t_11 = __pyx_memoryview_fromslice(__pyx_t_9, 1, (PyObject *(*)(char *)) __pyx_memview_get_double, (int (*)(char *, PyObject *)) __pyx_memview_set_double, 0);; if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 527, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_11);
  __PYX_XDEC_MEMVIEW(&__pyx_t_9, 1);
  __pyx_t_9.memview = NULL;
  __pyx_t_9.data = NULL;
  __pyx_t_12 = NULL;
  if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_8))) {
    __pyx_t_12 = PyMethod_GET_SELF(__pyx_t_8);
    if (likely(__pyx_t_12)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_8);
      __Pyx_INCREF(__pyx_t_12);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_8, function);
    }
  }
  if (!__pyx_t_12) {
    __pyx_t_10 = __Pyx_PyObject_CallOneArg(__pyx_t_8, __pyx_t_11); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 527, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
    __Pyx_GOTREF(__pyx_t_10);
  } else {
    #if CYTHON_FAST_PYCALL
    if (PyFunction_Check(__pyx_t_8)) {
      PyObject *__pyx_temp[2] = {__pyx_t_12, __pyx_t_11};
      __pyx_t_10 = __Pyx_PyFunction_FastCall(__pyx_t_8, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 527, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0;
      __Pyx_GOTREF(__pyx_t_10);
      __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
    } else
    #endif
    #if CYTHON_FAST_PYCCALL
    if (__Pyx_PyFastCFunction_Check(__pyx_t_8)) {
      PyObject *__pyx_temp[2] = {__pyx_t_12, __pyx_t_11};
      __pyx_t_10 = __Pyx_PyCFunction_FastCall(__pyx_t_8, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 527, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0;
      __Pyx_GOTREF(__pyx_t_10);
      __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
    } else
    #endif
    {
      __pyx_t_13 = PyTuple_New(1+1); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 527, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_13);
      __Pyx_GIVEREF(__pyx_t_12); PyTuple_SET_ITEM(__pyx_t_13, 0, __pyx_t_12); __pyx_t_12 = NULL;
      __Pyx_GIVEREF(__pyx_t_11);
      PyTuple_SET_ITEM(__pyx_t_13, 0+1, __pyx_t_11);
      __pyx_t_11 = 0;
      __pyx_t_10 = __Pyx_PyObject_Call(__pyx_t_8, __pyx_t_13, NULL); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 527, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_10);
      __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
    }
  }
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  __pyx_t_13 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 527, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_13);
  __pyx_t_11 = __Pyx_PyObject_GetAttrStr(__pyx_t_13, __pyx_n_s_max); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 527, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_11);
  __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
  __pyx_t_9.data = __pyx_v_VPoly.data;
  __pyx_t_9.memview = __pyx_v_VPoly.memview;
  __PYX_INC_MEMVIEW(&__pyx_t_9, 0);
  {
    Py_ssize_t __pyx_tmp_idx = 0;
    Py_ssize_t __pyx_tmp_shape = __pyx_v_VPoly.shape[0];
    Py_ssize_t __pyx_tmp_stride = __pyx_v_VPoly.strides[0];
    if (0 && (__pyx_tmp_idx < 0))
        __pyx_tmp_idx += __pyx_tmp_shape;
    if (0 && (__pyx_tmp_idx < 0 || __pyx_tmp_idx >= __pyx_tmp_shape)) {
        PyErr_SetString(PyExc_IndexError, "Index out of bounds (axis 0)");
        __PYX_ERR(0, 527, __pyx_L1_error)
    }
        __pyx_t_9.data += __pyx_tmp_idx * __pyx_tmp_stride;
}

__pyx_t_9.shape[0] = __pyx_v_VPoly.shape[1];
__pyx_t_9.strides[0] = __pyx_v_VPoly.strides[1];
    __pyx_t_9.suboffsets[0] = -1;

__pyx_t_13 = __pyx_memoryview_fromslice(__pyx_t_9, 1, (PyObject *(*)(char *)) __pyx_memview_get_double, (int (*)(char *, PyObject *)) __pyx_memview_set_double, 0);; if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 527, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_13);
  __PYX_XDEC_MEMVIEW(&__pyx_t_9, 1);
  __pyx_t_9.memview = NULL;
  __pyx_t_9.data = NULL;
  __pyx_t_12 = NULL;
  if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_11))) {
    __pyx_t_12 = PyMethod_GET_SELF(__pyx_t_11);
    if (likely(__pyx_t_12)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_11);
      __Pyx_INCREF(__pyx_t_12);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_11, function);
    }
  }
  if (!__pyx_t_12) {
    __pyx_t_8 = __Pyx_PyObject_CallOneArg(__pyx_t_11, __pyx_t_13); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 527, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
    __Pyx_GOTREF(__pyx_t_8);
  } else {
    #if CYTHON_FAST_PYCALL
    if (PyFunction_Check(__pyx_t_11)) {
      PyObject *__pyx_temp[2] = {__pyx_t_12, __pyx_t_13};
      __pyx_t_8 = __Pyx_PyFunction_FastCall(__pyx_t_11, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 527, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0;
      __Pyx_GOTREF(__pyx_t_8);
      __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
    } else
    #endif
    #if CYTHON_FAST_PYCCALL
    if (__Pyx_PyFastCFunction_Check(__pyx_t_11)) {
      PyObject *__pyx_temp[2] = {__pyx_t_12, __pyx_t_13};
      __pyx_t_8 = __Pyx_PyCFunction_FastCall(__pyx_t_11, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 527, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0;
      __Pyx_GOTREF(__pyx_t_8);
      __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
    } else
    #endif
    {
      __pyx_t_14 = PyTuple_New(1+1); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 527, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_14);
      __Pyx_GIVEREF(__pyx_t_12); PyTuple_SET_ITEM(__pyx_t_14, 0, __pyx_t_12); __pyx_t_12 = NULL;
      __Pyx_GIVEREF(__pyx_t_13);
      PyTuple_SET_ITEM(__pyx_t_14, 0+1, __pyx_t_13);
      __pyx_t_13 = 0;
      __pyx_t_8 = __Pyx_PyObject_Call(__pyx_t_11, __pyx_t_14, NULL); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 527, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_8);
      __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
    }
  }
  __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
  __pyx_t_11 = PyList_New(2); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 527, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_11);
  __Pyx_GIVEREF(__pyx_t_10);
  PyList_SET_ITEM(__pyx_t_11, 0, __pyx_t_10);
  __Pyx_GIVEREF(__pyx_t_8);
  PyList_SET_ITEM(__pyx_t_11, 1, __pyx_t_8);
  __pyx_t_10 = 0;
  __pyx_t_8 = 0;
  __pyx_t_8 = NULL;
  if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) {
    __pyx_t_8 = PyMethod_GET_SELF(__pyx_t_3);
    if (likely(__pyx_t_8)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
      __Pyx_INCREF(__pyx_t_8);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_3, function);
    }
  }
  if (!__pyx_t_8) {
    __pyx_t_5 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_11); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 527, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
    __Pyx_GOTREF(__pyx_t_5);
  } else {
    #if CYTHON_FAST_PYCALL
    if (PyFunction_Check(__pyx_t_3)) {
      PyObject *__pyx_temp[2] = {__pyx_t_8, __pyx_t_11};
      __pyx_t_5 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 527, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
    } else
    #endif
    #if CYTHON_FAST_PYCCALL
    if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) {
      PyObject *__pyx_temp[2] = {__pyx_t_8, __pyx_t_11};
      __pyx_t_5 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 527, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
    } else
    #endif
    {
      __pyx_t_10 = PyTuple_New(1+1); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 527, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_10);
      __Pyx_GIVEREF(__pyx_t_8); PyTuple_SET_ITEM(__pyx_t_10, 0, __pyx_t_8); __pyx_t_8 = NULL;
      __Pyx_GIVEREF(__pyx_t_11);
      PyTuple_SET_ITEM(__pyx_t_10, 0+1, __pyx_t_11);
      __pyx_t_11 = 0;
      __pyx_t_5 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_10, NULL); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 527, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
    }
  }
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_3 = PyFloat_FromDouble(__pyx_v_dL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 527, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_10 = PyTuple_New(2); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 527, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_10);
  __Pyx_GIVEREF(__pyx_t_5);
  PyTuple_SET_ITEM(__pyx_t_10, 0, __pyx_t_5);
  __Pyx_GIVEREF(__pyx_t_3);
  PyTuple_SET_ITEM(__pyx_t_10, 1, __pyx_t_3);
  __pyx_t_5 = 0;
  __pyx_t_3 = 0;
  __pyx_t_3 = PyDict_New(); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 527, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_DL, __pyx_v_DY) < 0) __PYX_ERR(0, 527, __pyx_L1_error)
  __pyx_t_5 = PyFloat_FromDouble(__pyx_v_margin); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 527, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_margin, __pyx_t_5) < 0) __PYX_ERR(0, 527, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __pyx_t_5 = __Pyx_PyObject_Call(__pyx_t_6, __pyx_t_10, __pyx_t_3); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 527, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  if ((likely(PyTuple_CheckExact(__pyx_t_5))) || (PyList_CheckExact(__pyx_t_5))) {
    PyObject* sequence = __pyx_t_5;
    #if !CYTHON_COMPILING_IN_PYPY
    Py_ssize_t size = Py_SIZE(sequence);
    #else
    Py_ssize_t size = PySequence_Size(sequence);
    #endif
    if (unlikely(size != 4)) {
      if (size > 4) __Pyx_RaiseTooManyValuesError(4);
      else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
      __PYX_ERR(0, 527, __pyx_L1_error)
    }
    #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
    if (likely(PyTuple_CheckExact(sequence))) {
      __pyx_t_3 = PyTuple_GET_ITEM(sequence, 0); 
      __pyx_t_10 = PyTuple_GET_ITEM(sequence, 1); 
      __pyx_t_6 = PyTuple_GET_ITEM(sequence, 2); 
      __pyx_t_11 = PyTuple_GET_ITEM(sequence, 3); 
    } else {
      __pyx_t_3 = PyList_GET_ITEM(sequence, 0); 
      __pyx_t_10 = PyList_GET_ITEM(sequence, 1); 
      __pyx_t_6 = PyList_GET_ITEM(sequence, 2); 
      __pyx_t_11 = PyList_GET_ITEM(sequence, 3); 
    }
    __Pyx_INCREF(__pyx_t_3);
    __Pyx_INCREF(__pyx_t_10);
    __Pyx_INCREF(__pyx_t_6);
    __Pyx_INCREF(__pyx_t_11);
    #else
    {
      Py_ssize_t i;
      PyObject** temps[4] = {&__pyx_t_3,&__pyx_t_10,&__pyx_t_6,&__pyx_t_11};
      for (i=0; i < 4; i++) {
        PyObject* item = PySequence_ITEM(sequence, i); if (unlikely(!item)) __PYX_ERR(0, 527, __pyx_L1_error)
        __Pyx_GOTREF(item);
        *(temps[i]) = item;
      }
    }
    #endif
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  } else {
    Py_ssize_t index = -1;
    PyObject** temps[4] = {&__pyx_t_3,&__pyx_t_10,&__pyx_t_6,&__pyx_t_11};
    __pyx_t_8 = PyObject_GetIter(__pyx_t_5); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 527, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_8);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __pyx_t_15 = Py_TYPE(__pyx_t_8)->tp_iternext;
    for (index=0; index < 4; index++) {
      PyObject* item = __pyx_t_15(__pyx_t_8); if (unlikely(!item)) goto __pyx_L12_unpacking_failed;
      __Pyx_GOTREF(item);
      *(temps[index]) = item;
    }
    if (__Pyx_IternextUnpackEndCheck(__pyx_t_15(__pyx_t_8), 4) < 0) __PYX_ERR(0, 527, __pyx_L1_error)
    __pyx_t_15 = NULL;
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    goto __pyx_L13_unpacking_done;
    __pyx_L12_unpacking_failed:;
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    __pyx_t_15 = NULL;
    if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
    __PYX_ERR(0, 527, __pyx_L1_error)
    __pyx_L13_unpacking_done:;
  }
  if (!(likely(((__pyx_t_3) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_3, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 527, __pyx_L1_error)
  __pyx_t_16 = __pyx_PyFloat_AsDouble(__pyx_t_10); if (unlikely((__pyx_t_16 == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 527, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
  if (!(likely(((__pyx_t_6) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_6, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 527, __pyx_L1_error)
  __pyx_t_17 = __Pyx_PyInt_As_int(__pyx_t_11); if (unlikely((__pyx_t_17 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 527, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
  __pyx_t_18 = ((PyArrayObject *)__pyx_t_3);
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_Y0.rcbuffer->pybuffer);
    __pyx_t_19 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_Y0.rcbuffer->pybuffer, (PyObject*)__pyx_t_18, &__Pyx_TypeInfo_double, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack);
    if (unlikely(__pyx_t_19 < 0)) {
      PyErr_Fetch(&__pyx_t_20, &__pyx_t_21, &__pyx_t_22);
      if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_Y0.rcbuffer->pybuffer, (PyObject*)__pyx_v_Y0, &__Pyx_TypeInfo_double, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {
        Py_XDECREF(__pyx_t_20); Py_XDECREF(__pyx_t_21); Py_XDECREF(__pyx_t_22);
        __Pyx_RaiseBufferFallbackError();
      } else {
        PyErr_Restore(__pyx_t_20, __pyx_t_21, __pyx_t_22);
      }
    }
    __pyx_pybuffernd_Y0.diminfo[0].strides = __pyx_pybuffernd_Y0.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_Y0.diminfo[0].shape = __pyx_pybuffernd_Y0.rcbuffer->pybuffer.shape[0];
    if (unlikely(__pyx_t_19 < 0)) __PYX_ERR(0, 527, __pyx_L1_error)
  }
  __pyx_t_18 = 0;
  __pyx_v_Y0 = ((PyArrayObject *)__pyx_t_3);
  __pyx_t_3 = 0;
  __pyx_v_dY0r = __pyx_t_16;
  __pyx_t_23 = ((PyArrayObject *)__pyx_t_6);
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_indY0.rcbuffer->pybuffer);
    __pyx_t_19 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_indY0.rcbuffer->pybuffer, (PyObject*)__pyx_t_23, &__Pyx_TypeInfo_long, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack);
    if (unlikely(__pyx_t_19 < 0)) {
      PyErr_Fetch(&__pyx_t_22, &__pyx_t_21, &__pyx_t_20);
      if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_indY0.rcbuffer->pybuffer, (PyObject*)__pyx_v_indY0, &__Pyx_TypeInfo_long, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {
        Py_XDECREF(__pyx_t_22); Py_XDECREF(__pyx_t_21); Py_XDECREF(__pyx_t_20);
        __Pyx_RaiseBufferFallbackError();
      } else {
        PyErr_Restore(__pyx_t_22, __pyx_t_21, __pyx_t_20);
      }
    }
    __pyx_pybuffernd_indY0.diminfo[0].strides = __pyx_pybuffernd_indY0.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_indY0.diminfo[0].shape = __pyx_pybuffernd_indY0.rcbuffer->pybuffer.shape[0];
    if (unlikely(__pyx_t_19 < 0)) __PYX_ERR(0, 527, __pyx_L1_error)
  }
  __pyx_t_23 = 0;
  __pyx_v_indY0 = ((PyArrayObject *)__pyx_t_6);
  __pyx_t_6 = 0;
  __pyx_v_NY0 = __pyx_t_17;
+528:     Z0, dZ0r, indZ0, NZ0 = _Ves_mesh_dlfromL_cython(np.array([np.min(VPoly[1,:]),np.max(VPoly[1,:])]), dL, DL=DZ, margin=margin)
  __pyx_t_5 = __Pyx_GetModuleGlobalName(__pyx_n_s_Ves_mesh_dlfromL_cython); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 528, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_t_6 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 528, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __pyx_t_10 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_n_s_array); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 528, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_10);
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 528, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_min); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 528, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_9.data = __pyx_v_VPoly.data;
  __pyx_t_9.memview = __pyx_v_VPoly.memview;
  __PYX_INC_MEMVIEW(&__pyx_t_9, 0);
  {
    Py_ssize_t __pyx_tmp_idx = 1;
    Py_ssize_t __pyx_tmp_shape = __pyx_v_VPoly.shape[0];
    Py_ssize_t __pyx_tmp_stride = __pyx_v_VPoly.strides[0];
    if (0 && (__pyx_tmp_idx < 0))
        __pyx_tmp_idx += __pyx_tmp_shape;
    if (0 && (__pyx_tmp_idx < 0 || __pyx_tmp_idx >= __pyx_tmp_shape)) {
        PyErr_SetString(PyExc_IndexError, "Index out of bounds (axis 0)");
        __PYX_ERR(0, 528, __pyx_L1_error)
    }
        __pyx_t_9.data += __pyx_tmp_idx * __pyx_tmp_stride;
}

__pyx_t_9.shape[0] = __pyx_v_VPoly.shape[1];
__pyx_t_9.strides[0] = __pyx_v_VPoly.strides[1];
    __pyx_t_9.suboffsets[0] = -1;

__pyx_t_3 = __pyx_memoryview_fromslice(__pyx_t_9, 1, (PyObject *(*)(char *)) __pyx_memview_get_double, (int (*)(char *, PyObject *)) __pyx_memview_set_double, 0);; if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 528, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __PYX_XDEC_MEMVIEW(&__pyx_t_9, 1);
  __pyx_t_9.memview = NULL;
  __pyx_t_9.data = NULL;
  __pyx_t_14 = NULL;
  if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_8))) {
    __pyx_t_14 = PyMethod_GET_SELF(__pyx_t_8);
    if (likely(__pyx_t_14)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_8);
      __Pyx_INCREF(__pyx_t_14);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_8, function);
    }
  }
  if (!__pyx_t_14) {
    __pyx_t_6 = __Pyx_PyObject_CallOneArg(__pyx_t_8, __pyx_t_3); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 528, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_GOTREF(__pyx_t_6);
  } else {
    #if CYTHON_FAST_PYCALL
    if (PyFunction_Check(__pyx_t_8)) {
      PyObject *__pyx_temp[2] = {__pyx_t_14, __pyx_t_3};
      __pyx_t_6 = __Pyx_PyFunction_FastCall(__pyx_t_8, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 528, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_14); __pyx_t_14 = 0;
      __Pyx_GOTREF(__pyx_t_6);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    } else
    #endif
    #if CYTHON_FAST_PYCCALL
    if (__Pyx_PyFastCFunction_Check(__pyx_t_8)) {
      PyObject *__pyx_temp[2] = {__pyx_t_14, __pyx_t_3};
      __pyx_t_6 = __Pyx_PyCFunction_FastCall(__pyx_t_8, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 528, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_14); __pyx_t_14 = 0;
      __Pyx_GOTREF(__pyx_t_6);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    } else
    #endif
    {
      __pyx_t_13 = PyTuple_New(1+1); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 528, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_13);
      __Pyx_GIVEREF(__pyx_t_14); PyTuple_SET_ITEM(__pyx_t_13, 0, __pyx_t_14); __pyx_t_14 = NULL;
      __Pyx_GIVEREF(__pyx_t_3);
      PyTuple_SET_ITEM(__pyx_t_13, 0+1, __pyx_t_3);
      __pyx_t_3 = 0;
      __pyx_t_6 = __Pyx_PyObject_Call(__pyx_t_8, __pyx_t_13, NULL); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 528, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_6);
      __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
    }
  }
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  __pyx_t_13 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 528, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_13);
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_13, __pyx_n_s_max); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 528, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
  __pyx_t_9.data = __pyx_v_VPoly.data;
  __pyx_t_9.memview = __pyx_v_VPoly.memview;
  __PYX_INC_MEMVIEW(&__pyx_t_9, 0);
  {
    Py_ssize_t __pyx_tmp_idx = 1;
    Py_ssize_t __pyx_tmp_shape = __pyx_v_VPoly.shape[0];
    Py_ssize_t __pyx_tmp_stride = __pyx_v_VPoly.strides[0];
    if (0 && (__pyx_tmp_idx < 0))
        __pyx_tmp_idx += __pyx_tmp_shape;
    if (0 && (__pyx_tmp_idx < 0 || __pyx_tmp_idx >= __pyx_tmp_shape)) {
        PyErr_SetString(PyExc_IndexError, "Index out of bounds (axis 0)");
        __PYX_ERR(0, 528, __pyx_L1_error)
    }
        __pyx_t_9.data += __pyx_tmp_idx * __pyx_tmp_stride;
}

__pyx_t_9.shape[0] = __pyx_v_VPoly.shape[1];
__pyx_t_9.strides[0] = __pyx_v_VPoly.strides[1];
    __pyx_t_9.suboffsets[0] = -1;

__pyx_t_13 = __pyx_memoryview_fromslice(__pyx_t_9, 1, (PyObject *(*)(char *)) __pyx_memview_get_double, (int (*)(char *, PyObject *)) __pyx_memview_set_double, 0);; if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 528, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_13);
  __PYX_XDEC_MEMVIEW(&__pyx_t_9, 1);
  __pyx_t_9.memview = NULL;
  __pyx_t_9.data = NULL;
  __pyx_t_14 = NULL;
  if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) {
    __pyx_t_14 = PyMethod_GET_SELF(__pyx_t_3);
    if (likely(__pyx_t_14)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
      __Pyx_INCREF(__pyx_t_14);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_3, function);
    }
  }
  if (!__pyx_t_14) {
    __pyx_t_8 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_13); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 528, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
    __Pyx_GOTREF(__pyx_t_8);
  } else {
    #if CYTHON_FAST_PYCALL
    if (PyFunction_Check(__pyx_t_3)) {
      PyObject *__pyx_temp[2] = {__pyx_t_14, __pyx_t_13};
      __pyx_t_8 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 528, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_14); __pyx_t_14 = 0;
      __Pyx_GOTREF(__pyx_t_8);
      __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
    } else
    #endif
    #if CYTHON_FAST_PYCCALL
    if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) {
      PyObject *__pyx_temp[2] = {__pyx_t_14, __pyx_t_13};
      __pyx_t_8 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 528, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_14); __pyx_t_14 = 0;
      __Pyx_GOTREF(__pyx_t_8);
      __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
    } else
    #endif
    {
      __pyx_t_12 = PyTuple_New(1+1); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 528, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_12);
      __Pyx_GIVEREF(__pyx_t_14); PyTuple_SET_ITEM(__pyx_t_12, 0, __pyx_t_14); __pyx_t_14 = NULL;
      __Pyx_GIVEREF(__pyx_t_13);
      PyTuple_SET_ITEM(__pyx_t_12, 0+1, __pyx_t_13);
      __pyx_t_13 = 0;
      __pyx_t_8 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_12, NULL); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 528, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_8);
      __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
    }
  }
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_3 = PyList_New(2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 528, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_GIVEREF(__pyx_t_6);
  PyList_SET_ITEM(__pyx_t_3, 0, __pyx_t_6);
  __Pyx_GIVEREF(__pyx_t_8);
  PyList_SET_ITEM(__pyx_t_3, 1, __pyx_t_8);
  __pyx_t_6 = 0;
  __pyx_t_8 = 0;
  __pyx_t_8 = NULL;
  if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_10))) {
    __pyx_t_8 = PyMethod_GET_SELF(__pyx_t_10);
    if (likely(__pyx_t_8)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_10);
      __Pyx_INCREF(__pyx_t_8);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_10, function);
    }
  }
  if (!__pyx_t_8) {
    __pyx_t_11 = __Pyx_PyObject_CallOneArg(__pyx_t_10, __pyx_t_3); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 528, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_GOTREF(__pyx_t_11);
  } else {
    #if CYTHON_FAST_PYCALL
    if (PyFunction_Check(__pyx_t_10)) {
      PyObject *__pyx_temp[2] = {__pyx_t_8, __pyx_t_3};
      __pyx_t_11 = __Pyx_PyFunction_FastCall(__pyx_t_10, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 528, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
      __Pyx_GOTREF(__pyx_t_11);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    } else
    #endif
    #if CYTHON_FAST_PYCCALL
    if (__Pyx_PyFastCFunction_Check(__pyx_t_10)) {
      PyObject *__pyx_temp[2] = {__pyx_t_8, __pyx_t_3};
      __pyx_t_11 = __Pyx_PyCFunction_FastCall(__pyx_t_10, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 528, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
      __Pyx_GOTREF(__pyx_t_11);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    } else
    #endif
    {
      __pyx_t_6 = PyTuple_New(1+1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 528, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_6);
      __Pyx_GIVEREF(__pyx_t_8); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_8); __pyx_t_8 = NULL;
      __Pyx_GIVEREF(__pyx_t_3);
      PyTuple_SET_ITEM(__pyx_t_6, 0+1, __pyx_t_3);
      __pyx_t_3 = 0;
      __pyx_t_11 = __Pyx_PyObject_Call(__pyx_t_10, __pyx_t_6, NULL); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 528, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_11);
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    }
  }
  __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
  __pyx_t_10 = PyFloat_FromDouble(__pyx_v_dL); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 528, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_10);
  __pyx_t_6 = PyTuple_New(2); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 528, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_GIVEREF(__pyx_t_11);
  PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_11);
  __Pyx_GIVEREF(__pyx_t_10);
  PyTuple_SET_ITEM(__pyx_t_6, 1, __pyx_t_10);
  __pyx_t_11 = 0;
  __pyx_t_10 = 0;
  __pyx_t_10 = PyDict_New(); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 528, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_10);
  if (PyDict_SetItem(__pyx_t_10, __pyx_n_s_DL, __pyx_v_DZ) < 0) __PYX_ERR(0, 528, __pyx_L1_error)
  __pyx_t_11 = PyFloat_FromDouble(__pyx_v_margin); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 528, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_11);
  if (PyDict_SetItem(__pyx_t_10, __pyx_n_s_margin, __pyx_t_11) < 0) __PYX_ERR(0, 528, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
  __pyx_t_11 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_t_6, __pyx_t_10); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 528, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_11);
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
  if ((likely(PyTuple_CheckExact(__pyx_t_11))) || (PyList_CheckExact(__pyx_t_11))) {
    PyObject* sequence = __pyx_t_11;
    #if !CYTHON_COMPILING_IN_PYPY
    Py_ssize_t size = Py_SIZE(sequence);
    #else
    Py_ssize_t size = PySequence_Size(sequence);
    #endif
    if (unlikely(size != 4)) {
      if (size > 4) __Pyx_RaiseTooManyValuesError(4);
      else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
      __PYX_ERR(0, 528, __pyx_L1_error)
    }
    #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
    if (likely(PyTuple_CheckExact(sequence))) {
      __pyx_t_10 = PyTuple_GET_ITEM(sequence, 0); 
      __pyx_t_6 = PyTuple_GET_ITEM(sequence, 1); 
      __pyx_t_5 = PyTuple_GET_ITEM(sequence, 2); 
      __pyx_t_3 = PyTuple_GET_ITEM(sequence, 3); 
    } else {
      __pyx_t_10 = PyList_GET_ITEM(sequence, 0); 
      __pyx_t_6 = PyList_GET_ITEM(sequence, 1); 
      __pyx_t_5 = PyList_GET_ITEM(sequence, 2); 
      __pyx_t_3 = PyList_GET_ITEM(sequence, 3); 
    }
    __Pyx_INCREF(__pyx_t_10);
    __Pyx_INCREF(__pyx_t_6);
    __Pyx_INCREF(__pyx_t_5);
    __Pyx_INCREF(__pyx_t_3);
    #else
    {
      Py_ssize_t i;
      PyObject** temps[4] = {&__pyx_t_10,&__pyx_t_6,&__pyx_t_5,&__pyx_t_3};
      for (i=0; i < 4; i++) {
        PyObject* item = PySequence_ITEM(sequence, i); if (unlikely(!item)) __PYX_ERR(0, 528, __pyx_L1_error)
        __Pyx_GOTREF(item);
        *(temps[i]) = item;
      }
    }
    #endif
    __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
  } else {
    Py_ssize_t index = -1;
    PyObject** temps[4] = {&__pyx_t_10,&__pyx_t_6,&__pyx_t_5,&__pyx_t_3};
    __pyx_t_8 = PyObject_GetIter(__pyx_t_11); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 528, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_8);
    __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
    __pyx_t_15 = Py_TYPE(__pyx_t_8)->tp_iternext;
    for (index=0; index < 4; index++) {
      PyObject* item = __pyx_t_15(__pyx_t_8); if (unlikely(!item)) goto __pyx_L14_unpacking_failed;
      __Pyx_GOTREF(item);
      *(temps[index]) = item;
    }
    if (__Pyx_IternextUnpackEndCheck(__pyx_t_15(__pyx_t_8), 4) < 0) __PYX_ERR(0, 528, __pyx_L1_error)
    __pyx_t_15 = NULL;
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    goto __pyx_L15_unpacking_done;
    __pyx_L14_unpacking_failed:;
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    __pyx_t_15 = NULL;
    if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
    __PYX_ERR(0, 528, __pyx_L1_error)
    __pyx_L15_unpacking_done:;
  }
  if (!(likely(((__pyx_t_10) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_10, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 528, __pyx_L1_error)
  __pyx_t_16 = __pyx_PyFloat_AsDouble(__pyx_t_6); if (unlikely((__pyx_t_16 == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 528, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  if (!(likely(((__pyx_t_5) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_5, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 528, __pyx_L1_error)
  __pyx_t_17 = __Pyx_PyInt_As_int(__pyx_t_3); if (unlikely((__pyx_t_17 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 528, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_18 = ((PyArrayObject *)__pyx_t_10);
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_Z0.rcbuffer->pybuffer);
    __pyx_t_19 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_Z0.rcbuffer->pybuffer, (PyObject*)__pyx_t_18, &__Pyx_TypeInfo_double, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack);
    if (unlikely(__pyx_t_19 < 0)) {
      PyErr_Fetch(&__pyx_t_20, &__pyx_t_21, &__pyx_t_22);
      if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_Z0.rcbuffer->pybuffer, (PyObject*)__pyx_v_Z0, &__Pyx_TypeInfo_double, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {
        Py_XDECREF(__pyx_t_20); Py_XDECREF(__pyx_t_21); Py_XDECREF(__pyx_t_22);
        __Pyx_RaiseBufferFallbackError();
      } else {
        PyErr_Restore(__pyx_t_20, __pyx_t_21, __pyx_t_22);
      }
    }
    __pyx_pybuffernd_Z0.diminfo[0].strides = __pyx_pybuffernd_Z0.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_Z0.diminfo[0].shape = __pyx_pybuffernd_Z0.rcbuffer->pybuffer.shape[0];
    if (unlikely(__pyx_t_19 < 0)) __PYX_ERR(0, 528, __pyx_L1_error)
  }
  __pyx_t_18 = 0;
  __pyx_v_Z0 = ((PyArrayObject *)__pyx_t_10);
  __pyx_t_10 = 0;
  __pyx_v_dZ0r = __pyx_t_16;
  __pyx_t_23 = ((PyArrayObject *)__pyx_t_5);
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_indZ0.rcbuffer->pybuffer);
    __pyx_t_19 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_indZ0.rcbuffer->pybuffer, (PyObject*)__pyx_t_23, &__Pyx_TypeInfo_long, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack);
    if (unlikely(__pyx_t_19 < 0)) {
      PyErr_Fetch(&__pyx_t_22, &__pyx_t_21, &__pyx_t_20);
      if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_indZ0.rcbuffer->pybuffer, (PyObject*)__pyx_v_indZ0, &__Pyx_TypeInfo_long, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {
        Py_XDECREF(__pyx_t_22); Py_XDECREF(__pyx_t_21); Py_XDECREF(__pyx_t_20);
        __Pyx_RaiseBufferFallbackError();
      } else {
        PyErr_Restore(__pyx_t_22, __pyx_t_21, __pyx_t_20);
      }
    }
    __pyx_pybuffernd_indZ0.diminfo[0].strides = __pyx_pybuffernd_indZ0.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_indZ0.diminfo[0].shape = __pyx_pybuffernd_indZ0.rcbuffer->pybuffer.shape[0];
    if (unlikely(__pyx_t_19 < 0)) __PYX_ERR(0, 528, __pyx_L1_error)
  }
  __pyx_t_23 = 0;
  __pyx_v_indZ0 = ((PyArrayObject *)__pyx_t_5);
  __pyx_t_5 = 0;
  __pyx_v_NZ0 = __pyx_t_17;
+529:     Y0n, Z0n = len(Y0), len(Z0)
  __pyx_t_24 = PyObject_Length(((PyObject *)__pyx_v_Y0)); if (unlikely(__pyx_t_24 == -1)) __PYX_ERR(0, 529, __pyx_L1_error)
  __pyx_t_25 = PyObject_Length(((PyObject *)__pyx_v_Z0)); if (unlikely(__pyx_t_25 == -1)) __PYX_ERR(0, 529, __pyx_L1_error)
  __pyx_v_Y0n = __pyx_t_24;
  __pyx_v_Z0n = __pyx_t_25;
 530: 
 531:     # Get the actual R and Z resolutions and mesh elements
+532:     X, dXr, indX, NX = _Ves_mesh_dlfromL_cython(XMinMax, dX, DL=DX, margin=margin)
  __pyx_t_11 = __Pyx_GetModuleGlobalName(__pyx_n_s_Ves_mesh_dlfromL_cython); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 532, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_11);
  __pyx_t_3 = __pyx_memoryview_fromslice(__pyx_v_XMinMax, 1, (PyObject *(*)(char *)) __pyx_memview_get_double, (int (*)(char *, PyObject *)) __pyx_memview_set_double, 0);; if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 532, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_5 = PyFloat_FromDouble(__pyx_v_dX); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 532, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_t_6 = PyTuple_New(2); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 532, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_GIVEREF(__pyx_t_3);
  PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_3);
  __Pyx_GIVEREF(__pyx_t_5);
  PyTuple_SET_ITEM(__pyx_t_6, 1, __pyx_t_5);
  __pyx_t_3 = 0;
  __pyx_t_5 = 0;
  __pyx_t_5 = PyDict_New(); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 532, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  if (PyDict_SetItem(__pyx_t_5, __pyx_n_s_DL, __pyx_v_DX) < 0) __PYX_ERR(0, 532, __pyx_L1_error)
  __pyx_t_3 = PyFloat_FromDouble(__pyx_v_margin); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 532, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  if (PyDict_SetItem(__pyx_t_5, __pyx_n_s_margin, __pyx_t_3) < 0) __PYX_ERR(0, 532, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_11, __pyx_t_6, __pyx_t_5); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 532, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  if ((likely(PyTuple_CheckExact(__pyx_t_3))) || (PyList_CheckExact(__pyx_t_3))) {
    PyObject* sequence = __pyx_t_3;
    #if !CYTHON_COMPILING_IN_PYPY
    Py_ssize_t size = Py_SIZE(sequence);
    #else
    Py_ssize_t size = PySequence_Size(sequence);
    #endif
    if (unlikely(size != 4)) {
      if (size > 4) __Pyx_RaiseTooManyValuesError(4);
      else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
      __PYX_ERR(0, 532, __pyx_L1_error)
    }
    #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
    if (likely(PyTuple_CheckExact(sequence))) {
      __pyx_t_5 = PyTuple_GET_ITEM(sequence, 0); 
      __pyx_t_6 = PyTuple_GET_ITEM(sequence, 1); 
      __pyx_t_11 = PyTuple_GET_ITEM(sequence, 2); 
      __pyx_t_10 = PyTuple_GET_ITEM(sequence, 3); 
    } else {
      __pyx_t_5 = PyList_GET_ITEM(sequence, 0); 
      __pyx_t_6 = PyList_GET_ITEM(sequence, 1); 
      __pyx_t_11 = PyList_GET_ITEM(sequence, 2); 
      __pyx_t_10 = PyList_GET_ITEM(sequence, 3); 
    }
    __Pyx_INCREF(__pyx_t_5);
    __Pyx_INCREF(__pyx_t_6);
    __Pyx_INCREF(__pyx_t_11);
    __Pyx_INCREF(__pyx_t_10);
    #else
    {
      Py_ssize_t i;
      PyObject** temps[4] = {&__pyx_t_5,&__pyx_t_6,&__pyx_t_11,&__pyx_t_10};
      for (i=0; i < 4; i++) {
        PyObject* item = PySequence_ITEM(sequence, i); if (unlikely(!item)) __PYX_ERR(0, 532, __pyx_L1_error)
        __Pyx_GOTREF(item);
        *(temps[i]) = item;
      }
    }
    #endif
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  } else {
    Py_ssize_t index = -1;
    PyObject** temps[4] = {&__pyx_t_5,&__pyx_t_6,&__pyx_t_11,&__pyx_t_10};
    __pyx_t_8 = PyObject_GetIter(__pyx_t_3); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 532, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_8);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_t_15 = Py_TYPE(__pyx_t_8)->tp_iternext;
    for (index=0; index < 4; index++) {
      PyObject* item = __pyx_t_15(__pyx_t_8); if (unlikely(!item)) goto __pyx_L16_unpacking_failed;
      __Pyx_GOTREF(item);
      *(temps[index]) = item;
    }
    if (__Pyx_IternextUnpackEndCheck(__pyx_t_15(__pyx_t_8), 4) < 0) __PYX_ERR(0, 532, __pyx_L1_error)
    __pyx_t_15 = NULL;
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    goto __pyx_L17_unpacking_done;
    __pyx_L16_unpacking_failed:;
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    __pyx_t_15 = NULL;
    if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
    __PYX_ERR(0, 532, __pyx_L1_error)
    __pyx_L17_unpacking_done:;
  }
  if (!(likely(((__pyx_t_5) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_5, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 532, __pyx_L1_error)
  __pyx_t_16 = __pyx_PyFloat_AsDouble(__pyx_t_6); if (unlikely((__pyx_t_16 == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 532, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  if (!(likely(((__pyx_t_11) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_11, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 532, __pyx_L1_error)
  __pyx_t_17 = __Pyx_PyInt_As_int(__pyx_t_10); if (unlikely((__pyx_t_17 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 532, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
  __pyx_t_18 = ((PyArrayObject *)__pyx_t_5);
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_X.rcbuffer->pybuffer);
    __pyx_t_19 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_X.rcbuffer->pybuffer, (PyObject*)__pyx_t_18, &__Pyx_TypeInfo_double, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack);
    if (unlikely(__pyx_t_19 < 0)) {
      PyErr_Fetch(&__pyx_t_20, &__pyx_t_21, &__pyx_t_22);
      if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_X.rcbuffer->pybuffer, (PyObject*)__pyx_v_X, &__Pyx_TypeInfo_double, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {
        Py_XDECREF(__pyx_t_20); Py_XDECREF(__pyx_t_21); Py_XDECREF(__pyx_t_22);
        __Pyx_RaiseBufferFallbackError();
      } else {
        PyErr_Restore(__pyx_t_20, __pyx_t_21, __pyx_t_22);
      }
    }
    __pyx_pybuffernd_X.diminfo[0].strides = __pyx_pybuffernd_X.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_X.diminfo[0].shape = __pyx_pybuffernd_X.rcbuffer->pybuffer.shape[0];
    if (unlikely(__pyx_t_19 < 0)) __PYX_ERR(0, 532, __pyx_L1_error)
  }
  __pyx_t_18 = 0;
  __pyx_v_X = ((PyArrayObject *)__pyx_t_5);
  __pyx_t_5 = 0;
  __pyx_v_dXr = __pyx_t_16;
  __pyx_t_23 = ((PyArrayObject *)__pyx_t_11);
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_indX.rcbuffer->pybuffer);
    __pyx_t_19 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_indX.rcbuffer->pybuffer, (PyObject*)__pyx_t_23, &__Pyx_TypeInfo_long, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack);
    if (unlikely(__pyx_t_19 < 0)) {
      PyErr_Fetch(&__pyx_t_22, &__pyx_t_21, &__pyx_t_20);
      if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_indX.rcbuffer->pybuffer, (PyObject*)__pyx_v_indX, &__Pyx_TypeInfo_long, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {
        Py_XDECREF(__pyx_t_22); Py_XDECREF(__pyx_t_21); Py_XDECREF(__pyx_t_20);
        __Pyx_RaiseBufferFallbackError();
      } else {
        PyErr_Restore(__pyx_t_22, __pyx_t_21, __pyx_t_20);
      }
    }
    __pyx_pybuffernd_indX.diminfo[0].strides = __pyx_pybuffernd_indX.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_indX.diminfo[0].shape = __pyx_pybuffernd_indX.rcbuffer->pybuffer.shape[0];
    if (unlikely(__pyx_t_19 < 0)) __PYX_ERR(0, 532, __pyx_L1_error)
  }
  __pyx_t_23 = 0;
  __pyx_v_indX = ((PyArrayObject *)__pyx_t_11);
  __pyx_t_11 = 0;
  __pyx_v_NX = __pyx_t_17;
+533:     Xn = len(X)
  __pyx_t_25 = PyObject_Length(((PyObject *)__pyx_v_X)); if (unlikely(__pyx_t_25 == -1)) __PYX_ERR(0, 533, __pyx_L1_error)
  __pyx_v_Xn = __pyx_t_25;
+534:     PtsCross, dLr, indL, NL, Rref, VPbis = _Ves_mesh_CrossPoly(VPoly, dL, D1=None, D2=None, margin=margin, DIn=DIn, VIn=VIn)
  __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_Ves_mesh_CrossPoly); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 534, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_10 = __pyx_memoryview_fromslice(__pyx_v_VPoly, 2, (PyObject *(*)(char *)) __pyx_memview_get_double, (int (*)(char *, PyObject *)) __pyx_memview_set_double, 0);; if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 534, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_10);
  __pyx_t_11 = PyFloat_FromDouble(__pyx_v_dL); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 534, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_11);
  __pyx_t_6 = PyTuple_New(2); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 534, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_GIVEREF(__pyx_t_10);
  PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_10);
  __Pyx_GIVEREF(__pyx_t_11);
  PyTuple_SET_ITEM(__pyx_t_6, 1, __pyx_t_11);
  __pyx_t_10 = 0;
  __pyx_t_11 = 0;
  __pyx_t_11 = PyDict_New(); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 534, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_11);
  if (PyDict_SetItem(__pyx_t_11, __pyx_n_s_D1, Py_None) < 0) __PYX_ERR(0, 534, __pyx_L1_error)
  if (PyDict_SetItem(__pyx_t_11, __pyx_n_s_D2, Py_None) < 0) __PYX_ERR(0, 534, __pyx_L1_error)
  __pyx_t_10 = PyFloat_FromDouble(__pyx_v_margin); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 534, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_10);
  if (PyDict_SetItem(__pyx_t_11, __pyx_n_s_margin, __pyx_t_10) < 0) __PYX_ERR(0, 534, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
  __pyx_t_10 = PyFloat_FromDouble(__pyx_v_DIn); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 534, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_10);
  if (PyDict_SetItem(__pyx_t_11, __pyx_n_s_DIn, __pyx_t_10) < 0) __PYX_ERR(0, 534, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
  if (PyDict_SetItem(__pyx_t_11, __pyx_n_s_VIn, __pyx_v_VIn) < 0) __PYX_ERR(0, 534, __pyx_L1_error)
  __pyx_t_10 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_6, __pyx_t_11); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 534, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_10);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
  if ((likely(PyTuple_CheckExact(__pyx_t_10))) || (PyList_CheckExact(__pyx_t_10))) {
    PyObject* sequence = __pyx_t_10;
    #if !CYTHON_COMPILING_IN_PYPY
    Py_ssize_t size = Py_SIZE(sequence);
    #else
    Py_ssize_t size = PySequence_Size(sequence);
    #endif
    if (unlikely(size != 6)) {
      if (size > 6) __Pyx_RaiseTooManyValuesError(6);
      else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
      __PYX_ERR(0, 534, __pyx_L1_error)
    }
    #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
    if (likely(PyTuple_CheckExact(sequence))) {
      __pyx_t_11 = PyTuple_GET_ITEM(sequence, 0); 
      __pyx_t_6 = PyTuple_GET_ITEM(sequence, 1); 
      __pyx_t_3 = PyTuple_GET_ITEM(sequence, 2); 
      __pyx_t_5 = PyTuple_GET_ITEM(sequence, 3); 
      __pyx_t_8 = PyTuple_GET_ITEM(sequence, 4); 
      __pyx_t_12 = PyTuple_GET_ITEM(sequence, 5); 
    } else {
      __pyx_t_11 = PyList_GET_ITEM(sequence, 0); 
      __pyx_t_6 = PyList_GET_ITEM(sequence, 1); 
      __pyx_t_3 = PyList_GET_ITEM(sequence, 2); 
      __pyx_t_5 = PyList_GET_ITEM(sequence, 3); 
      __pyx_t_8 = PyList_GET_ITEM(sequence, 4); 
      __pyx_t_12 = PyList_GET_ITEM(sequence, 5); 
    }
    __Pyx_INCREF(__pyx_t_11);
    __Pyx_INCREF(__pyx_t_6);
    __Pyx_INCREF(__pyx_t_3);
    __Pyx_INCREF(__pyx_t_5);
    __Pyx_INCREF(__pyx_t_8);
    __Pyx_INCREF(__pyx_t_12);
    #else
    {
      Py_ssize_t i;
      PyObject** temps[6] = {&__pyx_t_11,&__pyx_t_6,&__pyx_t_3,&__pyx_t_5,&__pyx_t_8,&__pyx_t_12};
      for (i=0; i < 6; i++) {
        PyObject* item = PySequence_ITEM(sequence, i); if (unlikely(!item)) __PYX_ERR(0, 534, __pyx_L1_error)
        __Pyx_GOTREF(item);
        *(temps[i]) = item;
      }
    }
    #endif
    __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
  } else {
    Py_ssize_t index = -1;
    PyObject** temps[6] = {&__pyx_t_11,&__pyx_t_6,&__pyx_t_3,&__pyx_t_5,&__pyx_t_8,&__pyx_t_12};
    __pyx_t_13 = PyObject_GetIter(__pyx_t_10); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 534, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_13);
    __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
    __pyx_t_15 = Py_TYPE(__pyx_t_13)->tp_iternext;
    for (index=0; index < 6; index++) {
      PyObject* item = __pyx_t_15(__pyx_t_13); if (unlikely(!item)) goto __pyx_L18_unpacking_failed;
      __Pyx_GOTREF(item);
      *(temps[index]) = item;
    }
    if (__Pyx_IternextUnpackEndCheck(__pyx_t_15(__pyx_t_13), 6) < 0) __PYX_ERR(0, 534, __pyx_L1_error)
    __pyx_t_15 = NULL;
    __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
    goto __pyx_L19_unpacking_done;
    __pyx_L18_unpacking_failed:;
    __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
    __pyx_t_15 = NULL;
    if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
    __PYX_ERR(0, 534, __pyx_L1_error)
    __pyx_L19_unpacking_done:;
  }
  if (!(likely(((__pyx_t_11) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_11, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 534, __pyx_L1_error)
  if (!(likely(((__pyx_t_6) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_6, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 534, __pyx_L1_error)
  if (!(likely(((__pyx_t_3) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_3, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 534, __pyx_L1_error)
  if (!(likely(((__pyx_t_5) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_5, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 534, __pyx_L1_error)
  if (!(likely(((__pyx_t_8) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_8, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 534, __pyx_L1_error)
  if (!(likely(((__pyx_t_12) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_12, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 534, __pyx_L1_error)
  __pyx_t_26 = ((PyArrayObject *)__pyx_t_11);
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_PtsCross.rcbuffer->pybuffer);
    __pyx_t_17 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_PtsCross.rcbuffer->pybuffer, (PyObject*)__pyx_t_26, &__Pyx_TypeInfo_double, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack);
    if (unlikely(__pyx_t_17 < 0)) {
      PyErr_Fetch(&__pyx_t_20, &__pyx_t_21, &__pyx_t_22);
      if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_PtsCross.rcbuffer->pybuffer, (PyObject*)__pyx_v_PtsCross, &__Pyx_TypeInfo_double, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) {
        Py_XDECREF(__pyx_t_20); Py_XDECREF(__pyx_t_21); Py_XDECREF(__pyx_t_22);
        __Pyx_RaiseBufferFallbackError();
      } else {
        PyErr_Restore(__pyx_t_20, __pyx_t_21, __pyx_t_22);
      }
    }
    __pyx_pybuffernd_PtsCross.diminfo[0].strides = __pyx_pybuffernd_PtsCross.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_PtsCross.diminfo[0].shape = __pyx_pybuffernd_PtsCross.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_PtsCross.diminfo[1].strides = __pyx_pybuffernd_PtsCross.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_PtsCross.diminfo[1].shape = __pyx_pybuffernd_PtsCross.rcbuffer->pybuffer.shape[1];
    if (unlikely(__pyx_t_17 < 0)) __PYX_ERR(0, 534, __pyx_L1_error)
  }
  __pyx_t_26 = 0;
  __pyx_v_PtsCross = ((PyArrayObject *)__pyx_t_11);
  __pyx_t_11 = 0;
  __pyx_t_27 = ((PyArrayObject *)__pyx_t_6);
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_dLr.rcbuffer->pybuffer);
    __pyx_t_17 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_dLr.rcbuffer->pybuffer, (PyObject*)__pyx_t_27, &__Pyx_TypeInfo_double, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack);
    if (unlikely(__pyx_t_17 < 0)) {
      PyErr_Fetch(&__pyx_t_22, &__pyx_t_21, &__pyx_t_20);
      if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_dLr.rcbuffer->pybuffer, (PyObject*)__pyx_v_dLr, &__Pyx_TypeInfo_double, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {
        Py_XDECREF(__pyx_t_22); Py_XDECREF(__pyx_t_21); Py_XDECREF(__pyx_t_20);
        __Pyx_RaiseBufferFallbackError();
      } else {
        PyErr_Restore(__pyx_t_22, __pyx_t_21, __pyx_t_20);
      }
    }
    __pyx_pybuffernd_dLr.diminfo[0].strides = __pyx_pybuffernd_dLr.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_dLr.diminfo[0].shape = __pyx_pybuffernd_dLr.rcbuffer->pybuffer.shape[0];
    if (unlikely(__pyx_t_17 < 0)) __PYX_ERR(0, 534, __pyx_L1_error)
  }
  __pyx_t_27 = 0;
  __pyx_v_dLr = ((PyArrayObject *)__pyx_t_6);
  __pyx_t_6 = 0;
  __pyx_t_23 = ((PyArrayObject *)__pyx_t_3);
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_indL.rcbuffer->pybuffer);
    __pyx_t_17 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_indL.rcbuffer->pybuffer, (PyObject*)__pyx_t_23, &__Pyx_TypeInfo_long, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack);
    if (unlikely(__pyx_t_17 < 0)) {
      PyErr_Fetch(&__pyx_t_20, &__pyx_t_21, &__pyx_t_22);
      if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_indL.rcbuffer->pybuffer, (PyObject*)__pyx_v_indL, &__Pyx_TypeInfo_long, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {
        Py_XDECREF(__pyx_t_20); Py_XDECREF(__pyx_t_21); Py_XDECREF(__pyx_t_22);
        __Pyx_RaiseBufferFallbackError();
      } else {
        PyErr_Restore(__pyx_t_20, __pyx_t_21, __pyx_t_22);
      }
    }
    __pyx_pybuffernd_indL.diminfo[0].strides = __pyx_pybuffernd_indL.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_indL.diminfo[0].shape = __pyx_pybuffernd_indL.rcbuffer->pybuffer.shape[0];
    if (unlikely(__pyx_t_17 < 0)) __PYX_ERR(0, 534, __pyx_L1_error)
  }
  __pyx_t_23 = 0;
  __pyx_v_indL = ((PyArrayObject *)__pyx_t_3);
  __pyx_t_3 = 0;
  __pyx_t_23 = ((PyArrayObject *)__pyx_t_5);
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_NL.rcbuffer->pybuffer);
    __pyx_t_17 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_NL.rcbuffer->pybuffer, (PyObject*)__pyx_t_23, &__Pyx_TypeInfo_long, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack);
    if (unlikely(__pyx_t_17 < 0)) {
      PyErr_Fetch(&__pyx_t_22, &__pyx_t_21, &__pyx_t_20);
      if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_NL.rcbuffer->pybuffer, (PyObject*)__pyx_v_NL, &__Pyx_TypeInfo_long, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {
        Py_XDECREF(__pyx_t_22); Py_XDECREF(__pyx_t_21); Py_XDECREF(__pyx_t_20);
        __Pyx_RaiseBufferFallbackError();
      } else {
        PyErr_Restore(__pyx_t_22, __pyx_t_21, __pyx_t_20);
      }
    }
    __pyx_pybuffernd_NL.diminfo[0].strides = __pyx_pybuffernd_NL.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_NL.diminfo[0].shape = __pyx_pybuffernd_NL.rcbuffer->pybuffer.shape[0];
    if (unlikely(__pyx_t_17 < 0)) __PYX_ERR(0, 534, __pyx_L1_error)
  }
  __pyx_t_23 = 0;
  __pyx_v_NL = ((PyArrayObject *)__pyx_t_5);
  __pyx_t_5 = 0;
  __pyx_t_27 = ((PyArrayObject *)__pyx_t_8);
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_Rref.rcbuffer->pybuffer);
    __pyx_t_17 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_Rref.rcbuffer->pybuffer, (PyObject*)__pyx_t_27, &__Pyx_TypeInfo_double, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack);
    if (unlikely(__pyx_t_17 < 0)) {
      PyErr_Fetch(&__pyx_t_20, &__pyx_t_21, &__pyx_t_22);
      if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_Rref.rcbuffer->pybuffer, (PyObject*)__pyx_v_Rref, &__Pyx_TypeInfo_double, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {
        Py_XDECREF(__pyx_t_20); Py_XDECREF(__pyx_t_21); Py_XDECREF(__pyx_t_22);
        __Pyx_RaiseBufferFallbackError();
      } else {
        PyErr_Restore(__pyx_t_20, __pyx_t_21, __pyx_t_22);
      }
    }
    __pyx_pybuffernd_Rref.diminfo[0].strides = __pyx_pybuffernd_Rref.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_Rref.diminfo[0].shape = __pyx_pybuffernd_Rref.rcbuffer->pybuffer.shape[0];
    if (unlikely(__pyx_t_17 < 0)) __PYX_ERR(0, 534, __pyx_L1_error)
  }
  __pyx_t_27 = 0;
  __pyx_v_Rref = ((PyArrayObject *)__pyx_t_8);
  __pyx_t_8 = 0;
  __pyx_t_26 = ((PyArrayObject *)__pyx_t_12);
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_VPbis.rcbuffer->pybuffer);
    __pyx_t_17 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_VPbis.rcbuffer->pybuffer, (PyObject*)__pyx_t_26, &__Pyx_TypeInfo_double, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack);
    if (unlikely(__pyx_t_17 < 0)) {
      PyErr_Fetch(&__pyx_t_22, &__pyx_t_21, &__pyx_t_20);
      if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_VPbis.rcbuffer->pybuffer, (PyObject*)__pyx_v_VPbis, &__Pyx_TypeInfo_double, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) {
        Py_XDECREF(__pyx_t_22); Py_XDECREF(__pyx_t_21); Py_XDECREF(__pyx_t_20);
        __Pyx_RaiseBufferFallbackError();
      } else {
        PyErr_Restore(__pyx_t_22, __pyx_t_21, __pyx_t_20);
      }
    }
    __pyx_pybuffernd_VPbis.diminfo[0].strides = __pyx_pybuffernd_VPbis.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_VPbis.diminfo[0].shape = __pyx_pybuffernd_VPbis.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_VPbis.diminfo[1].strides = __pyx_pybuffernd_VPbis.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_VPbis.diminfo[1].shape = __pyx_pybuffernd_VPbis.rcbuffer->pybuffer.shape[1];
    if (unlikely(__pyx_t_17 < 0)) __PYX_ERR(0, 534, __pyx_L1_error)
  }
  __pyx_t_26 = 0;
  __pyx_v_VPbis = ((PyArrayObject *)__pyx_t_12);
  __pyx_t_12 = 0;
+535:     NR0 = Rref.size
  __pyx_t_10 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_Rref), __pyx_n_s_size); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 535, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_10);
  __pyx_t_17 = __Pyx_PyInt_As_int(__pyx_t_10); if (unlikely((__pyx_t_17 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 535, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
  __pyx_v_NR0 = __pyx_t_17;
+536:     indin = np.ones((PtsCross.shape[1],),dtype=bool)
  __pyx_t_10 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 536, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_10);
  __pyx_t_12 = __Pyx_PyObject_GetAttrStr(__pyx_t_10, __pyx_n_s_ones); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 536, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_12);
  __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
  __pyx_t_10 = __Pyx_PyInt_From_Py_intptr_t((__pyx_v_PtsCross->dimensions[1])); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 536, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_10);
  __pyx_t_8 = PyTuple_New(1); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 536, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);
  __Pyx_GIVEREF(__pyx_t_10);
  PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_10);
  __pyx_t_10 = 0;
  __pyx_t_10 = PyTuple_New(1); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 536, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_10);
  __Pyx_GIVEREF(__pyx_t_8);
  PyTuple_SET_ITEM(__pyx_t_10, 0, __pyx_t_8);
  __pyx_t_8 = 0;
  __pyx_t_8 = PyDict_New(); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 536, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);
  if (PyDict_SetItem(__pyx_t_8, __pyx_n_s_dtype, ((PyObject *)__pyx_ptype_7cpython_4bool_bool)) < 0) __PYX_ERR(0, 536, __pyx_L1_error)
  __pyx_t_5 = __Pyx_PyObject_Call(__pyx_t_12, __pyx_t_10, __pyx_t_8); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 536, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
  __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  __pyx_v_indin = __pyx_t_5;
  __pyx_t_5 = 0;
+537:     if DY is not None:
  __pyx_t_2 = (__pyx_v_DY != Py_None);
  __pyx_t_1 = (__pyx_t_2 != 0);
  if (__pyx_t_1) {
/* … */
  }
+538:         if DY[0] is not None:
    __pyx_t_5 = __Pyx_GetItemInt(__pyx_v_DY, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 0); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 538, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_1 = (__pyx_t_5 != Py_None);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __pyx_t_2 = (__pyx_t_1 != 0);
    if (__pyx_t_2) {
/* … */
    }
+539:             indin = indin & (PtsCross[0,:]>=DY[0])
  __pyx_slice__51 = PySlice_New(Py_None, Py_None, Py_None); if (unlikely(!__pyx_slice__51)) __PYX_ERR(0, 539, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_slice__51);
  __Pyx_GIVEREF(__pyx_slice__51);
/* … */
      __pyx_t_5 = PyObject_GetItem(((PyObject *)__pyx_v_PtsCross), __pyx_tuple__52); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 539, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
      __pyx_t_8 = __Pyx_GetItemInt(__pyx_v_DY, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 0); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 539, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_8);
      __pyx_t_10 = PyObject_RichCompare(__pyx_t_5, __pyx_t_8, Py_GE); __Pyx_XGOTREF(__pyx_t_10); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 539, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
      __pyx_t_8 = PyNumber_And(__pyx_v_indin, __pyx_t_10); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 539, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_8);
      __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
      __Pyx_DECREF_SET(__pyx_v_indin, __pyx_t_8);
      __pyx_t_8 = 0;
  __pyx_tuple__52 = PyTuple_Pack(2, __pyx_int_0, __pyx_slice__51); if (unlikely(!__pyx_tuple__52)) __PYX_ERR(0, 539, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__52);
  __Pyx_GIVEREF(__pyx_tuple__52);
+540:         if DY[1] is not None:
    __pyx_t_8 = __Pyx_GetItemInt(__pyx_v_DY, 1, long, 1, __Pyx_PyInt_From_long, 0, 0, 0); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 540, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_8);
    __pyx_t_2 = (__pyx_t_8 != Py_None);
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    __pyx_t_1 = (__pyx_t_2 != 0);
    if (__pyx_t_1) {
/* … */
    }
+541:             indin = indin & (PtsCross[0,:]<=DY[1])
  __pyx_slice__53 = PySlice_New(Py_None, Py_None, Py_None); if (unlikely(!__pyx_slice__53)) __PYX_ERR(0, 541, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_slice__53);
  __Pyx_GIVEREF(__pyx_slice__53);
/* … */
      __pyx_t_8 = PyObject_GetItem(((PyObject *)__pyx_v_PtsCross), __pyx_tuple__54); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 541, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_8);
      __pyx_t_10 = __Pyx_GetItemInt(__pyx_v_DY, 1, long, 1, __Pyx_PyInt_From_long, 0, 0, 0); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 541, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_10);
      __pyx_t_5 = PyObject_RichCompare(__pyx_t_8, __pyx_t_10, Py_LE); __Pyx_XGOTREF(__pyx_t_5); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 541, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
      __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
      __pyx_t_10 = PyNumber_And(__pyx_v_indin, __pyx_t_5); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 541, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_10);
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __Pyx_DECREF_SET(__pyx_v_indin, __pyx_t_10);
      __pyx_t_10 = 0;
  __pyx_tuple__54 = PyTuple_Pack(2, __pyx_int_0, __pyx_slice__53); if (unlikely(!__pyx_tuple__54)) __PYX_ERR(0, 541, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__54);
  __Pyx_GIVEREF(__pyx_tuple__54);
+542:     if DZ is not None:
  __pyx_t_1 = (__pyx_v_DZ != Py_None);
  __pyx_t_2 = (__pyx_t_1 != 0);
  if (__pyx_t_2) {
/* … */
  }
+543:         if DZ[0] is not None:
    __pyx_t_10 = __Pyx_GetItemInt(__pyx_v_DZ, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 0); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 543, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_10);
    __pyx_t_2 = (__pyx_t_10 != Py_None);
    __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
    __pyx_t_1 = (__pyx_t_2 != 0);
    if (__pyx_t_1) {
/* … */
    }
+544:             indin = indin & (PtsCross[1,:]>=DZ[0])
  __pyx_slice__55 = PySlice_New(Py_None, Py_None, Py_None); if (unlikely(!__pyx_slice__55)) __PYX_ERR(0, 544, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_slice__55);
  __Pyx_GIVEREF(__pyx_slice__55);
/* … */
      __pyx_t_10 = PyObject_GetItem(((PyObject *)__pyx_v_PtsCross), __pyx_tuple__56); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 544, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_10);
      __pyx_t_5 = __Pyx_GetItemInt(__pyx_v_DZ, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 0); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 544, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
      __pyx_t_8 = PyObject_RichCompare(__pyx_t_10, __pyx_t_5, Py_GE); __Pyx_XGOTREF(__pyx_t_8); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 544, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __pyx_t_5 = PyNumber_And(__pyx_v_indin, __pyx_t_8); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 544, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
      __Pyx_DECREF_SET(__pyx_v_indin, __pyx_t_5);
      __pyx_t_5 = 0;
  __pyx_tuple__56 = PyTuple_Pack(2, __pyx_int_1, __pyx_slice__55); if (unlikely(!__pyx_tuple__56)) __PYX_ERR(0, 544, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__56);
  __Pyx_GIVEREF(__pyx_tuple__56);
+545:         if DZ[1] is not None:
    __pyx_t_5 = __Pyx_GetItemInt(__pyx_v_DZ, 1, long, 1, __Pyx_PyInt_From_long, 0, 0, 0); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 545, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_1 = (__pyx_t_5 != Py_None);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __pyx_t_2 = (__pyx_t_1 != 0);
    if (__pyx_t_2) {
/* … */
    }
+546:             indin = indin & (PtsCross[1,:]<=DZ[1])
  __pyx_slice__57 = PySlice_New(Py_None, Py_None, Py_None); if (unlikely(!__pyx_slice__57)) __PYX_ERR(0, 546, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_slice__57);
  __Pyx_GIVEREF(__pyx_slice__57);
/* … */
      __pyx_t_5 = PyObject_GetItem(((PyObject *)__pyx_v_PtsCross), __pyx_tuple__58); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 546, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
      __pyx_t_8 = __Pyx_GetItemInt(__pyx_v_DZ, 1, long, 1, __Pyx_PyInt_From_long, 0, 0, 0); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 546, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_8);
      __pyx_t_10 = PyObject_RichCompare(__pyx_t_5, __pyx_t_8, Py_LE); __Pyx_XGOTREF(__pyx_t_10); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 546, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
      __pyx_t_8 = PyNumber_And(__pyx_v_indin, __pyx_t_10); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 546, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_8);
      __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
      __Pyx_DECREF_SET(__pyx_v_indin, __pyx_t_8);
      __pyx_t_8 = 0;
  __pyx_tuple__58 = PyTuple_Pack(2, __pyx_int_1, __pyx_slice__57); if (unlikely(!__pyx_tuple__58)) __PYX_ERR(0, 546, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__58);
  __Pyx_GIVEREF(__pyx_tuple__58);
+547:     PtsCross, dLr, indL, Rref = PtsCross[:,indin], dLr[indin], indL[indin], Rref[indin]
  __pyx_t_8 = PyTuple_New(2); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 547, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);
  __Pyx_INCREF(__pyx_slice__59);
  __Pyx_GIVEREF(__pyx_slice__59);
  PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_slice__59);
  __Pyx_INCREF(__pyx_v_indin);
  __Pyx_GIVEREF(__pyx_v_indin);
  PyTuple_SET_ITEM(__pyx_t_8, 1, __pyx_v_indin);
  __pyx_t_10 = PyObject_GetItem(((PyObject *)__pyx_v_PtsCross), __pyx_t_8); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 547, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_10);
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  if (!(likely(((__pyx_t_10) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_10, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 547, __pyx_L1_error)
  __pyx_t_8 = PyObject_GetItem(((PyObject *)__pyx_v_dLr), __pyx_v_indin); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 547, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);
  if (!(likely(((__pyx_t_8) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_8, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 547, __pyx_L1_error)
  __pyx_t_5 = PyObject_GetItem(((PyObject *)__pyx_v_indL), __pyx_v_indin); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 547, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  if (!(likely(((__pyx_t_5) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_5, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 547, __pyx_L1_error)
  __pyx_t_12 = PyObject_GetItem(((PyObject *)__pyx_v_Rref), __pyx_v_indin); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 547, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_12);
  if (!(likely(((__pyx_t_12) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_12, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 547, __pyx_L1_error)
  __pyx_t_26 = ((PyArrayObject *)__pyx_t_10);
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_PtsCross.rcbuffer->pybuffer);
    __pyx_t_17 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_PtsCross.rcbuffer->pybuffer, (PyObject*)__pyx_t_26, &__Pyx_TypeInfo_double, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack);
    if (unlikely(__pyx_t_17 < 0)) {
      PyErr_Fetch(&__pyx_t_20, &__pyx_t_21, &__pyx_t_22);
      if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_PtsCross.rcbuffer->pybuffer, (PyObject*)__pyx_v_PtsCross, &__Pyx_TypeInfo_double, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) {
        Py_XDECREF(__pyx_t_20); Py_XDECREF(__pyx_t_21); Py_XDECREF(__pyx_t_22);
        __Pyx_RaiseBufferFallbackError();
      } else {
        PyErr_Restore(__pyx_t_20, __pyx_t_21, __pyx_t_22);
      }
    }
    __pyx_pybuffernd_PtsCross.diminfo[0].strides = __pyx_pybuffernd_PtsCross.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_PtsCross.diminfo[0].shape = __pyx_pybuffernd_PtsCross.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_PtsCross.diminfo[1].strides = __pyx_pybuffernd_PtsCross.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_PtsCross.diminfo[1].shape = __pyx_pybuffernd_PtsCross.rcbuffer->pybuffer.shape[1];
    if (unlikely(__pyx_t_17 < 0)) __PYX_ERR(0, 547, __pyx_L1_error)
  }
  __pyx_t_26 = 0;
  __Pyx_DECREF_SET(__pyx_v_PtsCross, ((PyArrayObject *)__pyx_t_10));
  __pyx_t_10 = 0;
  __pyx_t_27 = ((PyArrayObject *)__pyx_t_8);
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_dLr.rcbuffer->pybuffer);
    __pyx_t_17 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_dLr.rcbuffer->pybuffer, (PyObject*)__pyx_t_27, &__Pyx_TypeInfo_double, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack);
    if (unlikely(__pyx_t_17 < 0)) {
      PyErr_Fetch(&__pyx_t_22, &__pyx_t_21, &__pyx_t_20);
      if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_dLr.rcbuffer->pybuffer, (PyObject*)__pyx_v_dLr, &__Pyx_TypeInfo_double, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {
        Py_XDECREF(__pyx_t_22); Py_XDECREF(__pyx_t_21); Py_XDECREF(__pyx_t_20);
        __Pyx_RaiseBufferFallbackError();
      } else {
        PyErr_Restore(__pyx_t_22, __pyx_t_21, __pyx_t_20);
      }
    }
    __pyx_pybuffernd_dLr.diminfo[0].strides = __pyx_pybuffernd_dLr.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_dLr.diminfo[0].shape = __pyx_pybuffernd_dLr.rcbuffer->pybuffer.shape[0];
    if (unlikely(__pyx_t_17 < 0)) __PYX_ERR(0, 547, __pyx_L1_error)
  }
  __pyx_t_27 = 0;
  __Pyx_DECREF_SET(__pyx_v_dLr, ((PyArrayObject *)__pyx_t_8));
  __pyx_t_8 = 0;
  __pyx_t_23 = ((PyArrayObject *)__pyx_t_5);
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_indL.rcbuffer->pybuffer);
    __pyx_t_17 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_indL.rcbuffer->pybuffer, (PyObject*)__pyx_t_23, &__Pyx_TypeInfo_long, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack);
    if (unlikely(__pyx_t_17 < 0)) {
      PyErr_Fetch(&__pyx_t_20, &__pyx_t_21, &__pyx_t_22);
      if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_indL.rcbuffer->pybuffer, (PyObject*)__pyx_v_indL, &__Pyx_TypeInfo_long, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {
        Py_XDECREF(__pyx_t_20); Py_XDECREF(__pyx_t_21); Py_XDECREF(__pyx_t_22);
        __Pyx_RaiseBufferFallbackError();
      } else {
        PyErr_Restore(__pyx_t_20, __pyx_t_21, __pyx_t_22);
      }
    }
    __pyx_pybuffernd_indL.diminfo[0].strides = __pyx_pybuffernd_indL.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_indL.diminfo[0].shape = __pyx_pybuffernd_indL.rcbuffer->pybuffer.shape[0];
    if (unlikely(__pyx_t_17 < 0)) __PYX_ERR(0, 547, __pyx_L1_error)
  }
  __pyx_t_23 = 0;
  __Pyx_DECREF_SET(__pyx_v_indL, ((PyArrayObject *)__pyx_t_5));
  __pyx_t_5 = 0;
  __pyx_t_27 = ((PyArrayObject *)__pyx_t_12);
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_Rref.rcbuffer->pybuffer);
    __pyx_t_17 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_Rref.rcbuffer->pybuffer, (PyObject*)__pyx_t_27, &__Pyx_TypeInfo_double, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack);
    if (unlikely(__pyx_t_17 < 0)) {
      PyErr_Fetch(&__pyx_t_22, &__pyx_t_21, &__pyx_t_20);
      if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_Rref.rcbuffer->pybuffer, (PyObject*)__pyx_v_Rref, &__Pyx_TypeInfo_double, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {
        Py_XDECREF(__pyx_t_22); Py_XDECREF(__pyx_t_21); Py_XDECREF(__pyx_t_20);
        __Pyx_RaiseBufferFallbackError();
      } else {
        PyErr_Restore(__pyx_t_22, __pyx_t_21, __pyx_t_20);
      }
    }
    __pyx_pybuffernd_Rref.diminfo[0].strides = __pyx_pybuffernd_Rref.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_Rref.diminfo[0].shape = __pyx_pybuffernd_Rref.rcbuffer->pybuffer.shape[0];
    if (unlikely(__pyx_t_17 < 0)) __PYX_ERR(0, 547, __pyx_L1_error)
  }
  __pyx_t_27 = 0;
  __Pyx_DECREF_SET(__pyx_v_Rref, ((PyArrayObject *)__pyx_t_12));
  __pyx_t_12 = 0;
/* … */
  __pyx_slice__59 = PySlice_New(Py_None, Py_None, Py_None); if (unlikely(!__pyx_slice__59)) __PYX_ERR(0, 547, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_slice__59);
  __Pyx_GIVEREF(__pyx_slice__59);
+548:     Ln = indin.sum()
  __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_v_indin, __pyx_n_s_sum); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 548, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_t_8 = NULL;
  if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_5))) {
    __pyx_t_8 = PyMethod_GET_SELF(__pyx_t_5);
    if (likely(__pyx_t_8)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5);
      __Pyx_INCREF(__pyx_t_8);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_5, function);
    }
  }
  if (__pyx_t_8) {
    __pyx_t_12 = __Pyx_PyObject_CallOneArg(__pyx_t_5, __pyx_t_8); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 548, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  } else {
    __pyx_t_12 = __Pyx_PyObject_CallNoArg(__pyx_t_5); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 548, __pyx_L1_error)
  }
  __Pyx_GOTREF(__pyx_t_12);
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __pyx_t_17 = __Pyx_PyInt_As_int(__pyx_t_12); if (unlikely((__pyx_t_17 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 548, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
  __pyx_v_Ln = __pyx_t_17;
 549:     # Agregating
+550:     Pts = np.array([np.repeat(X,Ln), np.tile(PtsCross[0,:],Xn), np.tile(PtsCross[1,:],Xn)])
  __pyx_t_5 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 550, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_n_s_array); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 550, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __pyx_t_10 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 550, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_10);
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_10, __pyx_n_s_repeat); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 550, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
  __pyx_t_10 = __Pyx_PyInt_From_int(__pyx_v_Ln); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 550, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_10);
  __pyx_t_6 = NULL;
  __pyx_t_17 = 0;
  if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) {
    __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_3);
    if (likely(__pyx_t_6)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
      __Pyx_INCREF(__pyx_t_6);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_3, function);
      __pyx_t_17 = 1;
    }
  }
  #if CYTHON_FAST_PYCALL
  if (PyFunction_Check(__pyx_t_3)) {
    PyObject *__pyx_temp[3] = {__pyx_t_6, ((PyObject *)__pyx_v_X), __pyx_t_10};
    __pyx_t_5 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_17, 2+__pyx_t_17); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 550, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
  } else
  #endif
  #if CYTHON_FAST_PYCCALL
  if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) {
    PyObject *__pyx_temp[3] = {__pyx_t_6, ((PyObject *)__pyx_v_X), __pyx_t_10};
    __pyx_t_5 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_17, 2+__pyx_t_17); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 550, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
  } else
  #endif
  {
    __pyx_t_11 = PyTuple_New(2+__pyx_t_17); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 550, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_11);
    if (__pyx_t_6) {
      __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_11, 0, __pyx_t_6); __pyx_t_6 = NULL;
    }
    __Pyx_INCREF(((PyObject *)__pyx_v_X));
    __Pyx_GIVEREF(((PyObject *)__pyx_v_X));
    PyTuple_SET_ITEM(__pyx_t_11, 0+__pyx_t_17, ((PyObject *)__pyx_v_X));
    __Pyx_GIVEREF(__pyx_t_10);
    PyTuple_SET_ITEM(__pyx_t_11, 1+__pyx_t_17, __pyx_t_10);
    __pyx_t_10 = 0;
    __pyx_t_5 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_11, NULL); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 550, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
  }
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_11 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 550, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_11);
  __pyx_t_10 = __Pyx_PyObject_GetAttrStr(__pyx_t_11, __pyx_n_s_tile); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 550, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_10);
  __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
/* … */
  __pyx_slice__60 = PySlice_New(Py_None, Py_None, Py_None); if (unlikely(!__pyx_slice__60)) __PYX_ERR(0, 550, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_slice__60);
  __Pyx_GIVEREF(__pyx_slice__60);
  __pyx_t_11 = PyObject_GetItem(((PyObject *)__pyx_v_PtsCross), __pyx_tuple__61); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 550, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_11);
  __pyx_t_6 = __Pyx_PyInt_From_int(__pyx_v_Xn); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 550, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __pyx_t_13 = NULL;
  __pyx_t_17 = 0;
  if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_10))) {
    __pyx_t_13 = PyMethod_GET_SELF(__pyx_t_10);
    if (likely(__pyx_t_13)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_10);
      __Pyx_INCREF(__pyx_t_13);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_10, function);
      __pyx_t_17 = 1;
    }
  }
  #if CYTHON_FAST_PYCALL
  if (PyFunction_Check(__pyx_t_10)) {
    PyObject *__pyx_temp[3] = {__pyx_t_13, __pyx_t_11, __pyx_t_6};
    __pyx_t_3 = __Pyx_PyFunction_FastCall(__pyx_t_10, __pyx_temp+1-__pyx_t_17, 2+__pyx_t_17); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 550, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0;
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  } else
  #endif
  #if CYTHON_FAST_PYCCALL
  if (__Pyx_PyFastCFunction_Check(__pyx_t_10)) {
    PyObject *__pyx_temp[3] = {__pyx_t_13, __pyx_t_11, __pyx_t_6};
    __pyx_t_3 = __Pyx_PyCFunction_FastCall(__pyx_t_10, __pyx_temp+1-__pyx_t_17, 2+__pyx_t_17); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 550, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0;
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  } else
  #endif
  {
    __pyx_t_14 = PyTuple_New(2+__pyx_t_17); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 550, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_14);
    if (__pyx_t_13) {
      __Pyx_GIVEREF(__pyx_t_13); PyTuple_SET_ITEM(__pyx_t_14, 0, __pyx_t_13); __pyx_t_13 = NULL;
    }
    __Pyx_GIVEREF(__pyx_t_11);
    PyTuple_SET_ITEM(__pyx_t_14, 0+__pyx_t_17, __pyx_t_11);
    __Pyx_GIVEREF(__pyx_t_6);
    PyTuple_SET_ITEM(__pyx_t_14, 1+__pyx_t_17, __pyx_t_6);
    __pyx_t_11 = 0;
    __pyx_t_6 = 0;
    __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_10, __pyx_t_14, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 550, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
  }
  __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
  __pyx_t_14 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 550, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_14);
  __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_14, __pyx_n_s_tile); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 550, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
  __pyx_tuple__61 = PyTuple_Pack(2, __pyx_int_0, __pyx_slice__60); if (unlikely(!__pyx_tuple__61)) __PYX_ERR(0, 550, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__61);
  __Pyx_GIVEREF(__pyx_tuple__61);
  __pyx_slice__62 = PySlice_New(Py_None, Py_None, Py_None); if (unlikely(!__pyx_slice__62)) __PYX_ERR(0, 550, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_slice__62);
  __Pyx_GIVEREF(__pyx_slice__62);
  __pyx_t_14 = PyObject_GetItem(((PyObject *)__pyx_v_PtsCross), __pyx_tuple__63); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 550, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_14);
  __pyx_t_11 = __Pyx_PyInt_From_int(__pyx_v_Xn); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 550, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_11);
  __pyx_t_13 = NULL;
  __pyx_t_17 = 0;
  if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_6))) {
    __pyx_t_13 = PyMethod_GET_SELF(__pyx_t_6);
    if (likely(__pyx_t_13)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6);
      __Pyx_INCREF(__pyx_t_13);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_6, function);
      __pyx_t_17 = 1;
    }
  }
  #if CYTHON_FAST_PYCALL
  if (PyFunction_Check(__pyx_t_6)) {
    PyObject *__pyx_temp[3] = {__pyx_t_13, __pyx_t_14, __pyx_t_11};
    __pyx_t_10 = __Pyx_PyFunction_FastCall(__pyx_t_6, __pyx_temp+1-__pyx_t_17, 2+__pyx_t_17); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 550, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0;
    __Pyx_GOTREF(__pyx_t_10);
    __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
    __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
  } else
  #endif
  #if CYTHON_FAST_PYCCALL
  if (__Pyx_PyFastCFunction_Check(__pyx_t_6)) {
    PyObject *__pyx_temp[3] = {__pyx_t_13, __pyx_t_14, __pyx_t_11};
    __pyx_t_10 = __Pyx_PyCFunction_FastCall(__pyx_t_6, __pyx_temp+1-__pyx_t_17, 2+__pyx_t_17); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 550, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0;
    __Pyx_GOTREF(__pyx_t_10);
    __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
    __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
  } else
  #endif
  {
    __pyx_t_28 = PyTuple_New(2+__pyx_t_17); if (unlikely(!__pyx_t_28)) __PYX_ERR(0, 550, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_28);
    if (__pyx_t_13) {
      __Pyx_GIVEREF(__pyx_t_13); PyTuple_SET_ITEM(__pyx_t_28, 0, __pyx_t_13); __pyx_t_13 = NULL;
    }
    __Pyx_GIVEREF(__pyx_t_14);
    PyTuple_SET_ITEM(__pyx_t_28, 0+__pyx_t_17, __pyx_t_14);
    __Pyx_GIVEREF(__pyx_t_11);
    PyTuple_SET_ITEM(__pyx_t_28, 1+__pyx_t_17, __pyx_t_11);
    __pyx_t_14 = 0;
    __pyx_t_11 = 0;
    __pyx_t_10 = __Pyx_PyObject_Call(__pyx_t_6, __pyx_t_28, NULL); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 550, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_10);
    __Pyx_DECREF(__pyx_t_28); __pyx_t_28 = 0;
  }
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  __pyx_t_6 = PyList_New(3); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 550, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_GIVEREF(__pyx_t_5);
  PyList_SET_ITEM(__pyx_t_6, 0, __pyx_t_5);
  __Pyx_GIVEREF(__pyx_t_3);
  PyList_SET_ITEM(__pyx_t_6, 1, __pyx_t_3);
  __Pyx_GIVEREF(__pyx_t_10);
  PyList_SET_ITEM(__pyx_t_6, 2, __pyx_t_10);
  __pyx_t_5 = 0;
  __pyx_t_3 = 0;
  __pyx_t_10 = 0;
  __pyx_t_10 = NULL;
  if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_8))) {
    __pyx_t_10 = PyMethod_GET_SELF(__pyx_t_8);
    if (likely(__pyx_t_10)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_8);
      __Pyx_INCREF(__pyx_t_10);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_8, function);
    }
  }
  if (!__pyx_t_10) {
    __pyx_t_12 = __Pyx_PyObject_CallOneArg(__pyx_t_8, __pyx_t_6); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 550, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __Pyx_GOTREF(__pyx_t_12);
  } else {
    #if CYTHON_FAST_PYCALL
    if (PyFunction_Check(__pyx_t_8)) {
      PyObject *__pyx_temp[2] = {__pyx_t_10, __pyx_t_6};
      __pyx_t_12 = __Pyx_PyFunction_FastCall(__pyx_t_8, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 550, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
      __Pyx_GOTREF(__pyx_t_12);
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    } else
    #endif
    #if CYTHON_FAST_PYCCALL
    if (__Pyx_PyFastCFunction_Check(__pyx_t_8)) {
      PyObject *__pyx_temp[2] = {__pyx_t_10, __pyx_t_6};
      __pyx_t_12 = __Pyx_PyCFunction_FastCall(__pyx_t_8, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 550, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
      __Pyx_GOTREF(__pyx_t_12);
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    } else
    #endif
    {
      __pyx_t_3 = PyTuple_New(1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 550, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_GIVEREF(__pyx_t_10); PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_10); __pyx_t_10 = NULL;
      __Pyx_GIVEREF(__pyx_t_6);
      PyTuple_SET_ITEM(__pyx_t_3, 0+1, __pyx_t_6);
      __pyx_t_6 = 0;
      __pyx_t_12 = __Pyx_PyObject_Call(__pyx_t_8, __pyx_t_3, NULL); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 550, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_12);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    }
  }
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  if (!(likely(((__pyx_t_12) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_12, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 550, __pyx_L1_error)
  __pyx_t_26 = ((PyArrayObject *)__pyx_t_12);
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_Pts.rcbuffer->pybuffer);
    __pyx_t_17 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_Pts.rcbuffer->pybuffer, (PyObject*)__pyx_t_26, &__Pyx_TypeInfo_double, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack);
    if (unlikely(__pyx_t_17 < 0)) {
      PyErr_Fetch(&__pyx_t_20, &__pyx_t_21, &__pyx_t_22);
      if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_Pts.rcbuffer->pybuffer, (PyObject*)__pyx_v_Pts, &__Pyx_TypeInfo_double, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) {
        Py_XDECREF(__pyx_t_20); Py_XDECREF(__pyx_t_21); Py_XDECREF(__pyx_t_22);
        __Pyx_RaiseBufferFallbackError();
      } else {
        PyErr_Restore(__pyx_t_20, __pyx_t_21, __pyx_t_22);
      }
    }
    __pyx_pybuffernd_Pts.diminfo[0].strides = __pyx_pybuffernd_Pts.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_Pts.diminfo[0].shape = __pyx_pybuffernd_Pts.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_Pts.diminfo[1].strides = __pyx_pybuffernd_Pts.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_Pts.diminfo[1].shape = __pyx_pybuffernd_Pts.rcbuffer->pybuffer.shape[1];
    if (unlikely(__pyx_t_17 < 0)) __PYX_ERR(0, 550, __pyx_L1_error)
  }
  __pyx_t_26 = 0;
  __pyx_v_Pts = ((PyArrayObject *)__pyx_t_12);
  __pyx_t_12 = 0;
  __pyx_tuple__63 = PyTuple_Pack(2, __pyx_int_1, __pyx_slice__62); if (unlikely(!__pyx_tuple__63)) __PYX_ERR(0, 550, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__63);
  __Pyx_GIVEREF(__pyx_tuple__63);
+551:     ind = NY0*NZ0 + np.repeat(indX*NR0,Ln) + np.tile(indL,Xn)
  __pyx_t_12 = __Pyx_PyInt_From_int((__pyx_v_NY0 * __pyx_v_NZ0)); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 551, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_12);
  __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 551, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_repeat); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 551, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_3 = __Pyx_PyInt_From_int(__pyx_v_NR0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 551, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_10 = PyNumber_Multiply(((PyObject *)__pyx_v_indX), __pyx_t_3); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 551, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_10);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_3 = __Pyx_PyInt_From_int(__pyx_v_Ln); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 551, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_5 = NULL;
  __pyx_t_17 = 0;
  if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_6))) {
    __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_6);
    if (likely(__pyx_t_5)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6);
      __Pyx_INCREF(__pyx_t_5);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_6, function);
      __pyx_t_17 = 1;
    }
  }
  #if CYTHON_FAST_PYCALL
  if (PyFunction_Check(__pyx_t_6)) {
    PyObject *__pyx_temp[3] = {__pyx_t_5, __pyx_t_10, __pyx_t_3};
    __pyx_t_8 = __Pyx_PyFunction_FastCall(__pyx_t_6, __pyx_temp+1-__pyx_t_17, 2+__pyx_t_17); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 551, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_GOTREF(__pyx_t_8);
    __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  } else
  #endif
  #if CYTHON_FAST_PYCCALL
  if (__Pyx_PyFastCFunction_Check(__pyx_t_6)) {
    PyObject *__pyx_temp[3] = {__pyx_t_5, __pyx_t_10, __pyx_t_3};
    __pyx_t_8 = __Pyx_PyCFunction_FastCall(__pyx_t_6, __pyx_temp+1-__pyx_t_17, 2+__pyx_t_17); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 551, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_GOTREF(__pyx_t_8);
    __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  } else
  #endif
  {
    __pyx_t_28 = PyTuple_New(2+__pyx_t_17); if (unlikely(!__pyx_t_28)) __PYX_ERR(0, 551, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_28);
    if (__pyx_t_5) {
      __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_28, 0, __pyx_t_5); __pyx_t_5 = NULL;
    }
    __Pyx_GIVEREF(__pyx_t_10);
    PyTuple_SET_ITEM(__pyx_t_28, 0+__pyx_t_17, __pyx_t_10);
    __Pyx_GIVEREF(__pyx_t_3);
    PyTuple_SET_ITEM(__pyx_t_28, 1+__pyx_t_17, __pyx_t_3);
    __pyx_t_10 = 0;
    __pyx_t_3 = 0;
    __pyx_t_8 = __Pyx_PyObject_Call(__pyx_t_6, __pyx_t_28, NULL); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 551, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_8);
    __Pyx_DECREF(__pyx_t_28); __pyx_t_28 = 0;
  }
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  __pyx_t_6 = PyNumber_Add(__pyx_t_12, __pyx_t_8); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 551, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  __pyx_t_12 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 551, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_12);
  __pyx_t_28 = __Pyx_PyObject_GetAttrStr(__pyx_t_12, __pyx_n_s_tile); if (unlikely(!__pyx_t_28)) __PYX_ERR(0, 551, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_28);
  __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
  __pyx_t_12 = __Pyx_PyInt_From_int(__pyx_v_Xn); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 551, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_12);
  __pyx_t_3 = NULL;
  __pyx_t_17 = 0;
  if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_28))) {
    __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_28);
    if (likely(__pyx_t_3)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_28);
      __Pyx_INCREF(__pyx_t_3);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_28, function);
      __pyx_t_17 = 1;
    }
  }
  #if CYTHON_FAST_PYCALL
  if (PyFunction_Check(__pyx_t_28)) {
    PyObject *__pyx_temp[3] = {__pyx_t_3, ((PyObject *)__pyx_v_indL), __pyx_t_12};
    __pyx_t_8 = __Pyx_PyFunction_FastCall(__pyx_t_28, __pyx_temp+1-__pyx_t_17, 2+__pyx_t_17); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 551, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_GOTREF(__pyx_t_8);
    __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
  } else
  #endif
  #if CYTHON_FAST_PYCCALL
  if (__Pyx_PyFastCFunction_Check(__pyx_t_28)) {
    PyObject *__pyx_temp[3] = {__pyx_t_3, ((PyObject *)__pyx_v_indL), __pyx_t_12};
    __pyx_t_8 = __Pyx_PyCFunction_FastCall(__pyx_t_28, __pyx_temp+1-__pyx_t_17, 2+__pyx_t_17); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 551, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_GOTREF(__pyx_t_8);
    __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
  } else
  #endif
  {
    __pyx_t_10 = PyTuple_New(2+__pyx_t_17); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 551, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_10);
    if (__pyx_t_3) {
      __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_10, 0, __pyx_t_3); __pyx_t_3 = NULL;
    }
    __Pyx_INCREF(((PyObject *)__pyx_v_indL));
    __Pyx_GIVEREF(((PyObject *)__pyx_v_indL));
    PyTuple_SET_ITEM(__pyx_t_10, 0+__pyx_t_17, ((PyObject *)__pyx_v_indL));
    __Pyx_GIVEREF(__pyx_t_12);
    PyTuple_SET_ITEM(__pyx_t_10, 1+__pyx_t_17, __pyx_t_12);
    __pyx_t_12 = 0;
    __pyx_t_8 = __Pyx_PyObject_Call(__pyx_t_28, __pyx_t_10, NULL); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 551, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_8);
    __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
  }
  __Pyx_DECREF(__pyx_t_28); __pyx_t_28 = 0;
  __pyx_t_28 = PyNumber_Add(__pyx_t_6, __pyx_t_8); if (unlikely(!__pyx_t_28)) __PYX_ERR(0, 551, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_28);
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  if (!(likely(((__pyx_t_28) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_28, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 551, __pyx_L1_error)
  __pyx_t_23 = ((PyArrayObject *)__pyx_t_28);
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_ind.rcbuffer->pybuffer);
    __pyx_t_17 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_ind.rcbuffer->pybuffer, (PyObject*)__pyx_t_23, &__Pyx_TypeInfo_long, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack);
    if (unlikely(__pyx_t_17 < 0)) {
      PyErr_Fetch(&__pyx_t_22, &__pyx_t_21, &__pyx_t_20);
      if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_ind.rcbuffer->pybuffer, (PyObject*)__pyx_v_ind, &__Pyx_TypeInfo_long, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {
        Py_XDECREF(__pyx_t_22); Py_XDECREF(__pyx_t_21); Py_XDECREF(__pyx_t_20);
        __Pyx_RaiseBufferFallbackError();
      } else {
        PyErr_Restore(__pyx_t_22, __pyx_t_21, __pyx_t_20);
      }
    }
    __pyx_pybuffernd_ind.diminfo[0].strides = __pyx_pybuffernd_ind.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_ind.diminfo[0].shape = __pyx_pybuffernd_ind.rcbuffer->pybuffer.shape[0];
    if (unlikely(__pyx_t_17 < 0)) __PYX_ERR(0, 551, __pyx_L1_error)
  }
  __pyx_t_23 = 0;
  __pyx_v_ind = ((PyArrayObject *)__pyx_t_28);
  __pyx_t_28 = 0;
+552:     dS = np.tile(dLr*dXr,Xn)
  __pyx_t_8 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 552, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);
  __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_8, __pyx_n_s_tile); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 552, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  __pyx_t_8 = PyFloat_FromDouble(__pyx_v_dXr); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 552, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);
  __pyx_t_10 = PyNumber_Multiply(((PyObject *)__pyx_v_dLr), __pyx_t_8); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 552, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_10);
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  __pyx_t_8 = __Pyx_PyInt_From_int(__pyx_v_Xn); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 552, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);
  __pyx_t_12 = NULL;
  __pyx_t_17 = 0;
  if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_6))) {
    __pyx_t_12 = PyMethod_GET_SELF(__pyx_t_6);
    if (likely(__pyx_t_12)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6);
      __Pyx_INCREF(__pyx_t_12);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_6, function);
      __pyx_t_17 = 1;
    }
  }
  #if CYTHON_FAST_PYCALL
  if (PyFunction_Check(__pyx_t_6)) {
    PyObject *__pyx_temp[3] = {__pyx_t_12, __pyx_t_10, __pyx_t_8};
    __pyx_t_28 = __Pyx_PyFunction_FastCall(__pyx_t_6, __pyx_temp+1-__pyx_t_17, 2+__pyx_t_17); if (unlikely(!__pyx_t_28)) __PYX_ERR(0, 552, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0;
    __Pyx_GOTREF(__pyx_t_28);
    __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  } else
  #endif
  #if CYTHON_FAST_PYCCALL
  if (__Pyx_PyFastCFunction_Check(__pyx_t_6)) {
    PyObject *__pyx_temp[3] = {__pyx_t_12, __pyx_t_10, __pyx_t_8};
    __pyx_t_28 = __Pyx_PyCFunction_FastCall(__pyx_t_6, __pyx_temp+1-__pyx_t_17, 2+__pyx_t_17); if (unlikely(!__pyx_t_28)) __PYX_ERR(0, 552, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0;
    __Pyx_GOTREF(__pyx_t_28);
    __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  } else
  #endif
  {
    __pyx_t_3 = PyTuple_New(2+__pyx_t_17); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 552, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    if (__pyx_t_12) {
      __Pyx_GIVEREF(__pyx_t_12); PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_12); __pyx_t_12 = NULL;
    }
    __Pyx_GIVEREF(__pyx_t_10);
    PyTuple_SET_ITEM(__pyx_t_3, 0+__pyx_t_17, __pyx_t_10);
    __Pyx_GIVEREF(__pyx_t_8);
    PyTuple_SET_ITEM(__pyx_t_3, 1+__pyx_t_17, __pyx_t_8);
    __pyx_t_10 = 0;
    __pyx_t_8 = 0;
    __pyx_t_28 = __Pyx_PyObject_Call(__pyx_t_6, __pyx_t_3, NULL); if (unlikely(!__pyx_t_28)) __PYX_ERR(0, 552, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_28);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  }
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  if (!(likely(((__pyx_t_28) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_28, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 552, __pyx_L1_error)
  __pyx_t_27 = ((PyArrayObject *)__pyx_t_28);
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_dS.rcbuffer->pybuffer);
    __pyx_t_17 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_dS.rcbuffer->pybuffer, (PyObject*)__pyx_t_27, &__Pyx_TypeInfo_double, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack);
    if (unlikely(__pyx_t_17 < 0)) {
      PyErr_Fetch(&__pyx_t_20, &__pyx_t_21, &__pyx_t_22);
      if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_dS.rcbuffer->pybuffer, (PyObject*)__pyx_v_dS, &__Pyx_TypeInfo_double, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {
        Py_XDECREF(__pyx_t_20); Py_XDECREF(__pyx_t_21); Py_XDECREF(__pyx_t_22);
        __Pyx_RaiseBufferFallbackError();
      } else {
        PyErr_Restore(__pyx_t_20, __pyx_t_21, __pyx_t_22);
      }
    }
    __pyx_pybuffernd_dS.diminfo[0].strides = __pyx_pybuffernd_dS.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_dS.diminfo[0].shape = __pyx_pybuffernd_dS.rcbuffer->pybuffer.shape[0];
    if (unlikely(__pyx_t_17 < 0)) __PYX_ERR(0, 552, __pyx_L1_error)
  }
  __pyx_t_27 = 0;
  __pyx_v_dS = ((PyArrayObject *)__pyx_t_28);
  __pyx_t_28 = 0;
+553:     if DX is None or DX[0] is None:
  __pyx_t_1 = (__pyx_v_DX == Py_None);
  __pyx_t_29 = (__pyx_t_1 != 0);
  if (!__pyx_t_29) {
  } else {
    __pyx_t_2 = __pyx_t_29;
    goto __pyx_L27_bool_binop_done;
  }
  __pyx_t_28 = __Pyx_GetItemInt(__pyx_v_DX, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 0); if (unlikely(!__pyx_t_28)) __PYX_ERR(0, 553, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_28);
  __pyx_t_29 = (__pyx_t_28 == Py_None);
  __Pyx_DECREF(__pyx_t_28); __pyx_t_28 = 0;
  __pyx_t_1 = (__pyx_t_29 != 0);
  __pyx_t_2 = __pyx_t_1;
  __pyx_L27_bool_binop_done:;
  if (__pyx_t_2) {
/* … */
  }
+554:         pts = np.array([(XMinMax[0]+DIn)*np.ones((Y0n*Z0n,)), np.tile(Y0,Z0n), np.repeat(Z0,Y0n)])
    __pyx_t_6 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 554, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_n_s_array); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 554, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __pyx_t_30 = 0;
    __pyx_t_6 = PyFloat_FromDouble(((*((double *) ( /* dim=0 */ ((char *) (((double *) __pyx_v_XMinMax.data) + __pyx_t_30)) ))) + __pyx_v_DIn)); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 554, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_t_10 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 554, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_10);
    __pyx_t_12 = __Pyx_PyObject_GetAttrStr(__pyx_t_10, __pyx_n_s_ones); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 554, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_12);
    __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
    __pyx_t_10 = __Pyx_PyInt_From_int((__pyx_v_Y0n * __pyx_v_Z0n)); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 554, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_10);
    __pyx_t_5 = PyTuple_New(1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 554, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_GIVEREF(__pyx_t_10);
    PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_10);
    __pyx_t_10 = 0;
    __pyx_t_10 = NULL;
    if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_12))) {
      __pyx_t_10 = PyMethod_GET_SELF(__pyx_t_12);
      if (likely(__pyx_t_10)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_12);
        __Pyx_INCREF(__pyx_t_10);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_12, function);
      }
    }
    if (!__pyx_t_10) {
      __pyx_t_8 = __Pyx_PyObject_CallOneArg(__pyx_t_12, __pyx_t_5); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 554, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __Pyx_GOTREF(__pyx_t_8);
    } else {
      #if CYTHON_FAST_PYCALL
      if (PyFunction_Check(__pyx_t_12)) {
        PyObject *__pyx_temp[2] = {__pyx_t_10, __pyx_t_5};
        __pyx_t_8 = __Pyx_PyFunction_FastCall(__pyx_t_12, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 554, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
        __Pyx_GOTREF(__pyx_t_8);
        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      } else
      #endif
      #if CYTHON_FAST_PYCCALL
      if (__Pyx_PyFastCFunction_Check(__pyx_t_12)) {
        PyObject *__pyx_temp[2] = {__pyx_t_10, __pyx_t_5};
        __pyx_t_8 = __Pyx_PyCFunction_FastCall(__pyx_t_12, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 554, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
        __Pyx_GOTREF(__pyx_t_8);
        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      } else
      #endif
      {
        __pyx_t_11 = PyTuple_New(1+1); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 554, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_11);
        __Pyx_GIVEREF(__pyx_t_10); PyTuple_SET_ITEM(__pyx_t_11, 0, __pyx_t_10); __pyx_t_10 = NULL;
        __Pyx_GIVEREF(__pyx_t_5);
        PyTuple_SET_ITEM(__pyx_t_11, 0+1, __pyx_t_5);
        __pyx_t_5 = 0;
        __pyx_t_8 = __Pyx_PyObject_Call(__pyx_t_12, __pyx_t_11, NULL); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 554, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_8);
        __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
      }
    }
    __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
    __pyx_t_12 = PyNumber_Multiply(__pyx_t_6, __pyx_t_8); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 554, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_12);
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    __pyx_t_6 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 554, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_t_11 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_n_s_tile); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 554, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_11);
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __pyx_t_6 = __Pyx_PyInt_From_int(__pyx_v_Z0n); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 554, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_t_5 = NULL;
    __pyx_t_17 = 0;
    if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_11))) {
      __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_11);
      if (likely(__pyx_t_5)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_11);
        __Pyx_INCREF(__pyx_t_5);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_11, function);
        __pyx_t_17 = 1;
      }
    }
    #if CYTHON_FAST_PYCALL
    if (PyFunction_Check(__pyx_t_11)) {
      PyObject *__pyx_temp[3] = {__pyx_t_5, ((PyObject *)__pyx_v_Y0), __pyx_t_6};
      __pyx_t_8 = __Pyx_PyFunction_FastCall(__pyx_t_11, __pyx_temp+1-__pyx_t_17, 2+__pyx_t_17); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 554, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
      __Pyx_GOTREF(__pyx_t_8);
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    } else
    #endif
    #if CYTHON_FAST_PYCCALL
    if (__Pyx_PyFastCFunction_Check(__pyx_t_11)) {
      PyObject *__pyx_temp[3] = {__pyx_t_5, ((PyObject *)__pyx_v_Y0), __pyx_t_6};
      __pyx_t_8 = __Pyx_PyCFunction_FastCall(__pyx_t_11, __pyx_temp+1-__pyx_t_17, 2+__pyx_t_17); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 554, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
      __Pyx_GOTREF(__pyx_t_8);
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    } else
    #endif
    {
      __pyx_t_10 = PyTuple_New(2+__pyx_t_17); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 554, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_10);
      if (__pyx_t_5) {
        __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_10, 0, __pyx_t_5); __pyx_t_5 = NULL;
      }
      __Pyx_INCREF(((PyObject *)__pyx_v_Y0));
      __Pyx_GIVEREF(((PyObject *)__pyx_v_Y0));
      PyTuple_SET_ITEM(__pyx_t_10, 0+__pyx_t_17, ((PyObject *)__pyx_v_Y0));
      __Pyx_GIVEREF(__pyx_t_6);
      PyTuple_SET_ITEM(__pyx_t_10, 1+__pyx_t_17, __pyx_t_6);
      __pyx_t_6 = 0;
      __pyx_t_8 = __Pyx_PyObject_Call(__pyx_t_11, __pyx_t_10, NULL); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 554, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_8);
      __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
    }
    __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
    __pyx_t_10 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 554, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_10);
    __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_10, __pyx_n_s_repeat); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 554, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
    __pyx_t_10 = __Pyx_PyInt_From_int(__pyx_v_Y0n); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 554, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_10);
    __pyx_t_5 = NULL;
    __pyx_t_17 = 0;
    if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_6))) {
      __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_6);
      if (likely(__pyx_t_5)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6);
        __Pyx_INCREF(__pyx_t_5);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_6, function);
        __pyx_t_17 = 1;
      }
    }
    #if CYTHON_FAST_PYCALL
    if (PyFunction_Check(__pyx_t_6)) {
      PyObject *__pyx_temp[3] = {__pyx_t_5, ((PyObject *)__pyx_v_Z0), __pyx_t_10};
      __pyx_t_11 = __Pyx_PyFunction_FastCall(__pyx_t_6, __pyx_temp+1-__pyx_t_17, 2+__pyx_t_17); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 554, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
      __Pyx_GOTREF(__pyx_t_11);
      __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
    } else
    #endif
    #if CYTHON_FAST_PYCCALL
    if (__Pyx_PyFastCFunction_Check(__pyx_t_6)) {
      PyObject *__pyx_temp[3] = {__pyx_t_5, ((PyObject *)__pyx_v_Z0), __pyx_t_10};
      __pyx_t_11 = __Pyx_PyCFunction_FastCall(__pyx_t_6, __pyx_temp+1-__pyx_t_17, 2+__pyx_t_17); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 554, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
      __Pyx_GOTREF(__pyx_t_11);
      __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
    } else
    #endif
    {
      __pyx_t_14 = PyTuple_New(2+__pyx_t_17); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 554, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_14);
      if (__pyx_t_5) {
        __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_14, 0, __pyx_t_5); __pyx_t_5 = NULL;
      }
      __Pyx_INCREF(((PyObject *)__pyx_v_Z0));
      __Pyx_GIVEREF(((PyObject *)__pyx_v_Z0));
      PyTuple_SET_ITEM(__pyx_t_14, 0+__pyx_t_17, ((PyObject *)__pyx_v_Z0));
      __Pyx_GIVEREF(__pyx_t_10);
      PyTuple_SET_ITEM(__pyx_t_14, 1+__pyx_t_17, __pyx_t_10);
      __pyx_t_10 = 0;
      __pyx_t_11 = __Pyx_PyObject_Call(__pyx_t_6, __pyx_t_14, NULL); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 554, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_11);
      __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
    }
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __pyx_t_6 = PyList_New(3); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 554, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_GIVEREF(__pyx_t_12);
    PyList_SET_ITEM(__pyx_t_6, 0, __pyx_t_12);
    __Pyx_GIVEREF(__pyx_t_8);
    PyList_SET_ITEM(__pyx_t_6, 1, __pyx_t_8);
    __Pyx_GIVEREF(__pyx_t_11);
    PyList_SET_ITEM(__pyx_t_6, 2, __pyx_t_11);
    __pyx_t_12 = 0;
    __pyx_t_8 = 0;
    __pyx_t_11 = 0;
    __pyx_t_11 = NULL;
    if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) {
      __pyx_t_11 = PyMethod_GET_SELF(__pyx_t_3);
      if (likely(__pyx_t_11)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
        __Pyx_INCREF(__pyx_t_11);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_3, function);
      }
    }
    if (!__pyx_t_11) {
      __pyx_t_28 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_6); if (unlikely(!__pyx_t_28)) __PYX_ERR(0, 554, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      __Pyx_GOTREF(__pyx_t_28);
    } else {
      #if CYTHON_FAST_PYCALL
      if (PyFunction_Check(__pyx_t_3)) {
        PyObject *__pyx_temp[2] = {__pyx_t_11, __pyx_t_6};
        __pyx_t_28 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_28)) __PYX_ERR(0, 554, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0;
        __Pyx_GOTREF(__pyx_t_28);
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      } else
      #endif
      #if CYTHON_FAST_PYCCALL
      if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) {
        PyObject *__pyx_temp[2] = {__pyx_t_11, __pyx_t_6};
        __pyx_t_28 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_28)) __PYX_ERR(0, 554, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0;
        __Pyx_GOTREF(__pyx_t_28);
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      } else
      #endif
      {
        __pyx_t_8 = PyTuple_New(1+1); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 554, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_8);
        __Pyx_GIVEREF(__pyx_t_11); PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_11); __pyx_t_11 = NULL;
        __Pyx_GIVEREF(__pyx_t_6);
        PyTuple_SET_ITEM(__pyx_t_8, 0+1, __pyx_t_6);
        __pyx_t_6 = 0;
        __pyx_t_28 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_8, NULL); if (unlikely(!__pyx_t_28)) __PYX_ERR(0, 554, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_28);
        __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
      }
    }
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_v_pts = __pyx_t_28;
    __pyx_t_28 = 0;
+555:         iind = NY0*np.repeat(indZ0,Y0n) + np.tile(indY0,Z0n)
    __pyx_t_28 = __Pyx_PyInt_From_int(__pyx_v_NY0); if (unlikely(!__pyx_t_28)) __PYX_ERR(0, 555, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_28);
    __pyx_t_8 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 555, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_8);
    __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_8, __pyx_n_s_repeat); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 555, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    __pyx_t_8 = __Pyx_PyInt_From_int(__pyx_v_Y0n); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 555, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_8);
    __pyx_t_11 = NULL;
    __pyx_t_17 = 0;
    if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_6))) {
      __pyx_t_11 = PyMethod_GET_SELF(__pyx_t_6);
      if (likely(__pyx_t_11)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6);
        __Pyx_INCREF(__pyx_t_11);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_6, function);
        __pyx_t_17 = 1;
      }
    }
    #if CYTHON_FAST_PYCALL
    if (PyFunction_Check(__pyx_t_6)) {
      PyObject *__pyx_temp[3] = {__pyx_t_11, ((PyObject *)__pyx_v_indZ0), __pyx_t_8};
      __pyx_t_3 = __Pyx_PyFunction_FastCall(__pyx_t_6, __pyx_temp+1-__pyx_t_17, 2+__pyx_t_17); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 555, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0;
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    } else
    #endif
    #if CYTHON_FAST_PYCCALL
    if (__Pyx_PyFastCFunction_Check(__pyx_t_6)) {
      PyObject *__pyx_temp[3] = {__pyx_t_11, ((PyObject *)__pyx_v_indZ0), __pyx_t_8};
      __pyx_t_3 = __Pyx_PyCFunction_FastCall(__pyx_t_6, __pyx_temp+1-__pyx_t_17, 2+__pyx_t_17); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 555, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0;
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    } else
    #endif
    {
      __pyx_t_12 = PyTuple_New(2+__pyx_t_17); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 555, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_12);
      if (__pyx_t_11) {
        __Pyx_GIVEREF(__pyx_t_11); PyTuple_SET_ITEM(__pyx_t_12, 0, __pyx_t_11); __pyx_t_11 = NULL;
      }
      __Pyx_INCREF(((PyObject *)__pyx_v_indZ0));
      __Pyx_GIVEREF(((PyObject *)__pyx_v_indZ0));
      PyTuple_SET_ITEM(__pyx_t_12, 0+__pyx_t_17, ((PyObject *)__pyx_v_indZ0));
      __Pyx_GIVEREF(__pyx_t_8);
      PyTuple_SET_ITEM(__pyx_t_12, 1+__pyx_t_17, __pyx_t_8);
      __pyx_t_8 = 0;
      __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_6, __pyx_t_12, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 555, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
    }
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __pyx_t_6 = PyNumber_Multiply(__pyx_t_28, __pyx_t_3); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 555, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_DECREF(__pyx_t_28); __pyx_t_28 = 0;
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_t_28 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_28)) __PYX_ERR(0, 555, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_28);
    __pyx_t_12 = __Pyx_PyObject_GetAttrStr(__pyx_t_28, __pyx_n_s_tile); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 555, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_12);
    __Pyx_DECREF(__pyx_t_28); __pyx_t_28 = 0;
    __pyx_t_28 = __Pyx_PyInt_From_int(__pyx_v_Z0n); if (unlikely(!__pyx_t_28)) __PYX_ERR(0, 555, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_28);
    __pyx_t_8 = NULL;
    __pyx_t_17 = 0;
    if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_12))) {
      __pyx_t_8 = PyMethod_GET_SELF(__pyx_t_12);
      if (likely(__pyx_t_8)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_12);
        __Pyx_INCREF(__pyx_t_8);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_12, function);
        __pyx_t_17 = 1;
      }
    }
    #if CYTHON_FAST_PYCALL
    if (PyFunction_Check(__pyx_t_12)) {
      PyObject *__pyx_temp[3] = {__pyx_t_8, ((PyObject *)__pyx_v_indY0), __pyx_t_28};
      __pyx_t_3 = __Pyx_PyFunction_FastCall(__pyx_t_12, __pyx_temp+1-__pyx_t_17, 2+__pyx_t_17); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 555, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_28); __pyx_t_28 = 0;
    } else
    #endif
    #if CYTHON_FAST_PYCCALL
    if (__Pyx_PyFastCFunction_Check(__pyx_t_12)) {
      PyObject *__pyx_temp[3] = {__pyx_t_8, ((PyObject *)__pyx_v_indY0), __pyx_t_28};
      __pyx_t_3 = __Pyx_PyCFunction_FastCall(__pyx_t_12, __pyx_temp+1-__pyx_t_17, 2+__pyx_t_17); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 555, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_28); __pyx_t_28 = 0;
    } else
    #endif
    {
      __pyx_t_11 = PyTuple_New(2+__pyx_t_17); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 555, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_11);
      if (__pyx_t_8) {
        __Pyx_GIVEREF(__pyx_t_8); PyTuple_SET_ITEM(__pyx_t_11, 0, __pyx_t_8); __pyx_t_8 = NULL;
      }
      __Pyx_INCREF(((PyObject *)__pyx_v_indY0));
      __Pyx_GIVEREF(((PyObject *)__pyx_v_indY0));
      PyTuple_SET_ITEM(__pyx_t_11, 0+__pyx_t_17, ((PyObject *)__pyx_v_indY0));
      __Pyx_GIVEREF(__pyx_t_28);
      PyTuple_SET_ITEM(__pyx_t_11, 1+__pyx_t_17, __pyx_t_28);
      __pyx_t_28 = 0;
      __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_12, __pyx_t_11, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 555, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
    }
    __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
    __pyx_t_12 = PyNumber_Add(__pyx_t_6, __pyx_t_3); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 555, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_12);
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_v_iind = __pyx_t_12;
    __pyx_t_12 = 0;
+556:         indin = Path(VPoly.T).contains_points(pts[1:,:].T, transform=None, radius=0.0)
    __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_Path); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 556, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_31 = __pyx_v_VPoly;
    __PYX_INC_MEMVIEW(&__pyx_t_31, 1);
    if (unlikely(__pyx_memslice_transpose(&__pyx_t_31) == 0)) __PYX_ERR(0, 556, __pyx_L1_error)
    __pyx_t_6 = __pyx_memoryview_fromslice(__pyx_t_31, 2, (PyObject *(*)(char *)) __pyx_memview_get_double, (int (*)(char *, PyObject *)) __pyx_memview_set_double, 0);; if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 556, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __PYX_XDEC_MEMVIEW(&__pyx_t_31, 1);
    __pyx_t_31.memview = NULL;
    __pyx_t_31.data = NULL;
    __pyx_t_11 = NULL;
    if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) {
      __pyx_t_11 = PyMethod_GET_SELF(__pyx_t_3);
      if (likely(__pyx_t_11)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
        __Pyx_INCREF(__pyx_t_11);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_3, function);
      }
    }
    if (!__pyx_t_11) {
      __pyx_t_12 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_6); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 556, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      __Pyx_GOTREF(__pyx_t_12);
    } else {
      #if CYTHON_FAST_PYCALL
      if (PyFunction_Check(__pyx_t_3)) {
        PyObject *__pyx_temp[2] = {__pyx_t_11, __pyx_t_6};
        __pyx_t_12 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 556, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0;
        __Pyx_GOTREF(__pyx_t_12);
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      } else
      #endif
      #if CYTHON_FAST_PYCCALL
      if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) {
        PyObject *__pyx_temp[2] = {__pyx_t_11, __pyx_t_6};
        __pyx_t_12 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 556, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0;
        __Pyx_GOTREF(__pyx_t_12);
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      } else
      #endif
      {
        __pyx_t_28 = PyTuple_New(1+1); if (unlikely(!__pyx_t_28)) __PYX_ERR(0, 556, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_28);
        __Pyx_GIVEREF(__pyx_t_11); PyTuple_SET_ITEM(__pyx_t_28, 0, __pyx_t_11); __pyx_t_11 = NULL;
        __Pyx_GIVEREF(__pyx_t_6);
        PyTuple_SET_ITEM(__pyx_t_28, 0+1, __pyx_t_6);
        __pyx_t_6 = 0;
        __pyx_t_12 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_28, NULL); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 556, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_12);
        __Pyx_DECREF(__pyx_t_28); __pyx_t_28 = 0;
      }
    }
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_12, __pyx_n_s_contains_points); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 556, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
/* … */
  __pyx_slice__64 = PySlice_New(__pyx_int_1, Py_None, Py_None); if (unlikely(!__pyx_slice__64)) __PYX_ERR(0, 556, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_slice__64);
  __Pyx_GIVEREF(__pyx_slice__64);
  __pyx_slice__65 = PySlice_New(Py_None, Py_None, Py_None); if (unlikely(!__pyx_slice__65)) __PYX_ERR(0, 556, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_slice__65);
  __Pyx_GIVEREF(__pyx_slice__65);
    __pyx_t_12 = PyObject_GetItem(__pyx_v_pts, __pyx_tuple__66); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 556, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_12);
    __pyx_t_28 = __Pyx_PyObject_GetAttrStr(__pyx_t_12, __pyx_n_s_T); if (unlikely(!__pyx_t_28)) __PYX_ERR(0, 556, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_28);
    __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
    __pyx_t_12 = PyTuple_New(1); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 556, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_12);
    __Pyx_GIVEREF(__pyx_t_28);
    PyTuple_SET_ITEM(__pyx_t_12, 0, __pyx_t_28);
    __pyx_t_28 = 0;
    __pyx_t_28 = PyDict_New(); if (unlikely(!__pyx_t_28)) __PYX_ERR(0, 556, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_28);
    if (PyDict_SetItem(__pyx_t_28, __pyx_n_s_transform, Py_None) < 0) __PYX_ERR(0, 556, __pyx_L1_error)
    if (PyDict_SetItem(__pyx_t_28, __pyx_n_s_radius, __pyx_float_0_0) < 0) __PYX_ERR(0, 556, __pyx_L1_error)
    __pyx_t_6 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_12, __pyx_t_28); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 556, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
    __Pyx_DECREF(__pyx_t_28); __pyx_t_28 = 0;
    __Pyx_DECREF_SET(__pyx_v_indin, __pyx_t_6);
    __pyx_t_6 = 0;
  __pyx_tuple__66 = PyTuple_Pack(2, __pyx_slice__64, __pyx_slice__65); if (unlikely(!__pyx_tuple__66)) __PYX_ERR(0, 556, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__66);
  __Pyx_GIVEREF(__pyx_tuple__66);
+557:         if np.any(indin):
    __pyx_t_28 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_28)) __PYX_ERR(0, 557, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_28);
    __pyx_t_12 = __Pyx_PyObject_GetAttrStr(__pyx_t_28, __pyx_n_s_any); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 557, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_12);
    __Pyx_DECREF(__pyx_t_28); __pyx_t_28 = 0;
    __pyx_t_28 = NULL;
    if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_12))) {
      __pyx_t_28 = PyMethod_GET_SELF(__pyx_t_12);
      if (likely(__pyx_t_28)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_12);
        __Pyx_INCREF(__pyx_t_28);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_12, function);
      }
    }
    if (!__pyx_t_28) {
      __pyx_t_6 = __Pyx_PyObject_CallOneArg(__pyx_t_12, __pyx_v_indin); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 557, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_6);
    } else {
      #if CYTHON_FAST_PYCALL
      if (PyFunction_Check(__pyx_t_12)) {
        PyObject *__pyx_temp[2] = {__pyx_t_28, __pyx_v_indin};
        __pyx_t_6 = __Pyx_PyFunction_FastCall(__pyx_t_12, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 557, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_28); __pyx_t_28 = 0;
        __Pyx_GOTREF(__pyx_t_6);
      } else
      #endif
      #if CYTHON_FAST_PYCCALL
      if (__Pyx_PyFastCFunction_Check(__pyx_t_12)) {
        PyObject *__pyx_temp[2] = {__pyx_t_28, __pyx_v_indin};
        __pyx_t_6 = __Pyx_PyCFunction_FastCall(__pyx_t_12, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 557, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_28); __pyx_t_28 = 0;
        __Pyx_GOTREF(__pyx_t_6);
      } else
      #endif
      {
        __pyx_t_3 = PyTuple_New(1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 557, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_3);
        __Pyx_GIVEREF(__pyx_t_28); PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_28); __pyx_t_28 = NULL;
        __Pyx_INCREF(__pyx_v_indin);
        __Pyx_GIVEREF(__pyx_v_indin);
        PyTuple_SET_ITEM(__pyx_t_3, 0+1, __pyx_v_indin);
        __pyx_t_6 = __Pyx_PyObject_Call(__pyx_t_12, __pyx_t_3, NULL); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 557, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_6);
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      }
    }
    __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
    __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_6); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(0, 557, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    if (__pyx_t_2) {
/* … */
    }
+558:             pts = pts[:,indin].reshape((3,1)) if indin.sum()==1 else pts[:,indin]
      __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_indin, __pyx_n_s_sum); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 558, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_28 = NULL;
      if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_3))) {
        __pyx_t_28 = PyMethod_GET_SELF(__pyx_t_3);
        if (likely(__pyx_t_28)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
          __Pyx_INCREF(__pyx_t_28);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_3, function);
        }
      }
      if (__pyx_t_28) {
        __pyx_t_12 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_28); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 558, __pyx_L1_error)
        __Pyx_DECREF(__pyx_t_28); __pyx_t_28 = 0;
      } else {
        __pyx_t_12 = __Pyx_PyObject_CallNoArg(__pyx_t_3); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 558, __pyx_L1_error)
      }
      __Pyx_GOTREF(__pyx_t_12);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __pyx_t_3 = __Pyx_PyInt_EqObjC(__pyx_t_12, __pyx_int_1, 1, 0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 558, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
      __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(0, 558, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      if (__pyx_t_2) {
        __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 558, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_3);
        __Pyx_INCREF(__pyx_slice__67);
        __Pyx_GIVEREF(__pyx_slice__67);
        PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_slice__67);
        __Pyx_INCREF(__pyx_v_indin);
        __Pyx_GIVEREF(__pyx_v_indin);
        PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_v_indin);
        __pyx_t_12 = PyObject_GetItem(__pyx_v_pts, __pyx_t_3); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 558, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_12);
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_12, __pyx_n_s_reshape); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 558, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_3);
        __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
/* … */
  __pyx_slice__67 = PySlice_New(Py_None, Py_None, Py_None); if (unlikely(!__pyx_slice__67)) __PYX_ERR(0, 558, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_slice__67);
  __Pyx_GIVEREF(__pyx_slice__67);
  __pyx_tuple__68 = PyTuple_Pack(2, __pyx_int_3, __pyx_int_1); if (unlikely(!__pyx_tuple__68)) __PYX_ERR(0, 558, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__68);
  __Pyx_GIVEREF(__pyx_tuple__68);
        __pyx_t_12 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_tuple__69, NULL); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 558, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_12);
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        __pyx_t_6 = __pyx_t_12;
        __pyx_t_12 = 0;
      } else {
  __pyx_tuple__69 = PyTuple_Pack(1, __pyx_tuple__68); if (unlikely(!__pyx_tuple__69)) __PYX_ERR(0, 558, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__69);
  __Pyx_GIVEREF(__pyx_tuple__69);
        __pyx_t_12 = PyTuple_New(2); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 558, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_12);
        __Pyx_INCREF(__pyx_slice__70);
        __Pyx_GIVEREF(__pyx_slice__70);
        PyTuple_SET_ITEM(__pyx_t_12, 0, __pyx_slice__70);
        __Pyx_INCREF(__pyx_v_indin);
        __Pyx_GIVEREF(__pyx_v_indin);
        PyTuple_SET_ITEM(__pyx_t_12, 1, __pyx_v_indin);
        __pyx_t_3 = PyObject_GetItem(__pyx_v_pts, __pyx_t_12); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 558, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_3);
        __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
        __pyx_t_6 = __pyx_t_3;
        __pyx_t_3 = 0;
      }
      __Pyx_DECREF_SET(__pyx_v_pts, __pyx_t_6);
      __pyx_t_6 = 0;
  __pyx_slice__70 = PySlice_New(Py_None, Py_None, Py_None); if (unlikely(!__pyx_slice__70)) __PYX_ERR(0, 558, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_slice__70);
  __Pyx_GIVEREF(__pyx_slice__70);
+559:             Pts = np.concatenate((pts,Pts),axis=1)
      __pyx_t_6 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 559, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_6);
      __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_n_s_concatenate); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 559, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      __pyx_t_6 = PyTuple_New(2); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 559, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_6);
      __Pyx_INCREF(__pyx_v_pts);
      __Pyx_GIVEREF(__pyx_v_pts);
      PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_v_pts);
      __Pyx_INCREF(((PyObject *)__pyx_v_Pts));
      __Pyx_GIVEREF(((PyObject *)__pyx_v_Pts));
      PyTuple_SET_ITEM(__pyx_t_6, 1, ((PyObject *)__pyx_v_Pts));
      __pyx_t_12 = PyTuple_New(1); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 559, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_12);
      __Pyx_GIVEREF(__pyx_t_6);
      PyTuple_SET_ITEM(__pyx_t_12, 0, __pyx_t_6);
      __pyx_t_6 = 0;
      __pyx_t_6 = PyDict_New(); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 559, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_6);
      if (PyDict_SetItem(__pyx_t_6, __pyx_n_s_axis, __pyx_int_1) < 0) __PYX_ERR(0, 559, __pyx_L1_error)
      __pyx_t_28 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_12, __pyx_t_6); if (unlikely(!__pyx_t_28)) __PYX_ERR(0, 559, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_28);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      if (!(likely(((__pyx_t_28) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_28, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 559, __pyx_L1_error)
      __pyx_t_26 = ((PyArrayObject *)__pyx_t_28);
      {
        __Pyx_BufFmt_StackElem __pyx_stack[1];
        __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_Pts.rcbuffer->pybuffer);
        __pyx_t_17 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_Pts.rcbuffer->pybuffer, (PyObject*)__pyx_t_26, &__Pyx_TypeInfo_double, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack);
        if (unlikely(__pyx_t_17 < 0)) {
          PyErr_Fetch(&__pyx_t_22, &__pyx_t_21, &__pyx_t_20);
          if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_Pts.rcbuffer->pybuffer, (PyObject*)__pyx_v_Pts, &__Pyx_TypeInfo_double, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) {
            Py_XDECREF(__pyx_t_22); Py_XDECREF(__pyx_t_21); Py_XDECREF(__pyx_t_20);
            __Pyx_RaiseBufferFallbackError();
          } else {
            PyErr_Restore(__pyx_t_22, __pyx_t_21, __pyx_t_20);
          }
        }
        __pyx_pybuffernd_Pts.diminfo[0].strides = __pyx_pybuffernd_Pts.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_Pts.diminfo[0].shape = __pyx_pybuffernd_Pts.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_Pts.diminfo[1].strides = __pyx_pybuffernd_Pts.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_Pts.diminfo[1].shape = __pyx_pybuffernd_Pts.rcbuffer->pybuffer.shape[1];
        if (unlikely(__pyx_t_17 < 0)) __PYX_ERR(0, 559, __pyx_L1_error)
      }
      __pyx_t_26 = 0;
      __Pyx_DECREF_SET(__pyx_v_Pts, ((PyArrayObject *)__pyx_t_28));
      __pyx_t_28 = 0;
+560:             ind = np.concatenate((iind[indin], ind))
      __pyx_t_6 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 560, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_6);
      __pyx_t_12 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_n_s_concatenate); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 560, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_12);
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      __pyx_t_6 = PyObject_GetItem(__pyx_v_iind, __pyx_v_indin); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 560, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_6);
      __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 560, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_GIVEREF(__pyx_t_6);
      PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_6);
      __Pyx_INCREF(((PyObject *)__pyx_v_ind));
      __Pyx_GIVEREF(((PyObject *)__pyx_v_ind));
      PyTuple_SET_ITEM(__pyx_t_3, 1, ((PyObject *)__pyx_v_ind));
      __pyx_t_6 = 0;
      __pyx_t_6 = NULL;
      if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_12))) {
        __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_12);
        if (likely(__pyx_t_6)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_12);
          __Pyx_INCREF(__pyx_t_6);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_12, function);
        }
      }
      if (!__pyx_t_6) {
        __pyx_t_28 = __Pyx_PyObject_CallOneArg(__pyx_t_12, __pyx_t_3); if (unlikely(!__pyx_t_28)) __PYX_ERR(0, 560, __pyx_L1_error)
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        __Pyx_GOTREF(__pyx_t_28);
      } else {
        #if CYTHON_FAST_PYCALL
        if (PyFunction_Check(__pyx_t_12)) {
          PyObject *__pyx_temp[2] = {__pyx_t_6, __pyx_t_3};
          __pyx_t_28 = __Pyx_PyFunction_FastCall(__pyx_t_12, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_28)) __PYX_ERR(0, 560, __pyx_L1_error)
          __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
          __Pyx_GOTREF(__pyx_t_28);
          __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        } else
        #endif
        #if CYTHON_FAST_PYCCALL
        if (__Pyx_PyFastCFunction_Check(__pyx_t_12)) {
          PyObject *__pyx_temp[2] = {__pyx_t_6, __pyx_t_3};
          __pyx_t_28 = __Pyx_PyCFunction_FastCall(__pyx_t_12, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_28)) __PYX_ERR(0, 560, __pyx_L1_error)
          __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
          __Pyx_GOTREF(__pyx_t_28);
          __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        } else
        #endif
        {
          __pyx_t_11 = PyTuple_New(1+1); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 560, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_11);
          __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_11, 0, __pyx_t_6); __pyx_t_6 = NULL;
          __Pyx_GIVEREF(__pyx_t_3);
          PyTuple_SET_ITEM(__pyx_t_11, 0+1, __pyx_t_3);
          __pyx_t_3 = 0;
          __pyx_t_28 = __Pyx_PyObject_Call(__pyx_t_12, __pyx_t_11, NULL); if (unlikely(!__pyx_t_28)) __PYX_ERR(0, 560, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_28);
          __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
        }
      }
      __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
      if (!(likely(((__pyx_t_28) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_28, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 560, __pyx_L1_error)
      __pyx_t_23 = ((PyArrayObject *)__pyx_t_28);
      {
        __Pyx_BufFmt_StackElem __pyx_stack[1];
        __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_ind.rcbuffer->pybuffer);
        __pyx_t_17 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_ind.rcbuffer->pybuffer, (PyObject*)__pyx_t_23, &__Pyx_TypeInfo_long, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack);
        if (unlikely(__pyx_t_17 < 0)) {
          PyErr_Fetch(&__pyx_t_20, &__pyx_t_21, &__pyx_t_22);
          if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_ind.rcbuffer->pybuffer, (PyObject*)__pyx_v_ind, &__Pyx_TypeInfo_long, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {
            Py_XDECREF(__pyx_t_20); Py_XDECREF(__pyx_t_21); Py_XDECREF(__pyx_t_22);
            __Pyx_RaiseBufferFallbackError();
          } else {
            PyErr_Restore(__pyx_t_20, __pyx_t_21, __pyx_t_22);
          }
        }
        __pyx_pybuffernd_ind.diminfo[0].strides = __pyx_pybuffernd_ind.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_ind.diminfo[0].shape = __pyx_pybuffernd_ind.rcbuffer->pybuffer.shape[0];
        if (unlikely(__pyx_t_17 < 0)) __PYX_ERR(0, 560, __pyx_L1_error)
      }
      __pyx_t_23 = 0;
      __Pyx_DECREF_SET(__pyx_v_ind, ((PyArrayObject *)__pyx_t_28));
      __pyx_t_28 = 0;
+561:             dS = np.concatenate((dY0r*dZ0r*np.ones((indin.sum(),)),dS))
      __pyx_t_12 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 561, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_12);
      __pyx_t_11 = __Pyx_PyObject_GetAttrStr(__pyx_t_12, __pyx_n_s_concatenate); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 561, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_11);
      __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
      __pyx_t_12 = PyFloat_FromDouble((__pyx_v_dY0r * __pyx_v_dZ0r)); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 561, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_12);
      __pyx_t_6 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 561, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_6);
      __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_n_s_ones); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 561, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_8);
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      __pyx_t_14 = __Pyx_PyObject_GetAttrStr(__pyx_v_indin, __pyx_n_s_sum); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 561, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_14);
      __pyx_t_10 = NULL;
      if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_14))) {
        __pyx_t_10 = PyMethod_GET_SELF(__pyx_t_14);
        if (likely(__pyx_t_10)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_14);
          __Pyx_INCREF(__pyx_t_10);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_14, function);
        }
      }
      if (__pyx_t_10) {
        __pyx_t_6 = __Pyx_PyObject_CallOneArg(__pyx_t_14, __pyx_t_10); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 561, __pyx_L1_error)
        __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
      } else {
        __pyx_t_6 = __Pyx_PyObject_CallNoArg(__pyx_t_14); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 561, __pyx_L1_error)
      }
      __Pyx_GOTREF(__pyx_t_6);
      __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
      __pyx_t_14 = PyTuple_New(1); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 561, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_14);
      __Pyx_GIVEREF(__pyx_t_6);
      PyTuple_SET_ITEM(__pyx_t_14, 0, __pyx_t_6);
      __pyx_t_6 = 0;
      __pyx_t_6 = NULL;
      if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_8))) {
        __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_8);
        if (likely(__pyx_t_6)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_8);
          __Pyx_INCREF(__pyx_t_6);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_8, function);
        }
      }
      if (!__pyx_t_6) {
        __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_t_8, __pyx_t_14); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 561, __pyx_L1_error)
        __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
        __Pyx_GOTREF(__pyx_t_3);
      } else {
        #if CYTHON_FAST_PYCALL
        if (PyFunction_Check(__pyx_t_8)) {
          PyObject *__pyx_temp[2] = {__pyx_t_6, __pyx_t_14};
          __pyx_t_3 = __Pyx_PyFunction_FastCall(__pyx_t_8, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 561, __pyx_L1_error)
          __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
          __Pyx_GOTREF(__pyx_t_3);
          __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
        } else
        #endif
        #if CYTHON_FAST_PYCCALL
        if (__Pyx_PyFastCFunction_Check(__pyx_t_8)) {
          PyObject *__pyx_temp[2] = {__pyx_t_6, __pyx_t_14};
          __pyx_t_3 = __Pyx_PyCFunction_FastCall(__pyx_t_8, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 561, __pyx_L1_error)
          __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
          __Pyx_GOTREF(__pyx_t_3);
          __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
        } else
        #endif
        {
          __pyx_t_10 = PyTuple_New(1+1); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 561, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_10);
          __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_10, 0, __pyx_t_6); __pyx_t_6 = NULL;
          __Pyx_GIVEREF(__pyx_t_14);
          PyTuple_SET_ITEM(__pyx_t_10, 0+1, __pyx_t_14);
          __pyx_t_14 = 0;
          __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_8, __pyx_t_10, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 561, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_3);
          __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
        }
      }
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
      __pyx_t_8 = PyNumber_Multiply(__pyx_t_12, __pyx_t_3); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 561, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_8);
      __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 561, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_GIVEREF(__pyx_t_8);
      PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_8);
      __Pyx_INCREF(((PyObject *)__pyx_v_dS));
      __Pyx_GIVEREF(((PyObject *)__pyx_v_dS));
      PyTuple_SET_ITEM(__pyx_t_3, 1, ((PyObject *)__pyx_v_dS));
      __pyx_t_8 = 0;
      __pyx_t_8 = NULL;
      if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_11))) {
        __pyx_t_8 = PyMethod_GET_SELF(__pyx_t_11);
        if (likely(__pyx_t_8)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_11);
          __Pyx_INCREF(__pyx_t_8);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_11, function);
        }
      }
      if (!__pyx_t_8) {
        __pyx_t_28 = __Pyx_PyObject_CallOneArg(__pyx_t_11, __pyx_t_3); if (unlikely(!__pyx_t_28)) __PYX_ERR(0, 561, __pyx_L1_error)
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        __Pyx_GOTREF(__pyx_t_28);
      } else {
        #if CYTHON_FAST_PYCALL
        if (PyFunction_Check(__pyx_t_11)) {
          PyObject *__pyx_temp[2] = {__pyx_t_8, __pyx_t_3};
          __pyx_t_28 = __Pyx_PyFunction_FastCall(__pyx_t_11, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_28)) __PYX_ERR(0, 561, __pyx_L1_error)
          __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
          __Pyx_GOTREF(__pyx_t_28);
          __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        } else
        #endif
        #if CYTHON_FAST_PYCCALL
        if (__Pyx_PyFastCFunction_Check(__pyx_t_11)) {
          PyObject *__pyx_temp[2] = {__pyx_t_8, __pyx_t_3};
          __pyx_t_28 = __Pyx_PyCFunction_FastCall(__pyx_t_11, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_28)) __PYX_ERR(0, 561, __pyx_L1_error)
          __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
          __Pyx_GOTREF(__pyx_t_28);
          __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        } else
        #endif
        {
          __pyx_t_12 = PyTuple_New(1+1); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 561, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_12);
          __Pyx_GIVEREF(__pyx_t_8); PyTuple_SET_ITEM(__pyx_t_12, 0, __pyx_t_8); __pyx_t_8 = NULL;
          __Pyx_GIVEREF(__pyx_t_3);
          PyTuple_SET_ITEM(__pyx_t_12, 0+1, __pyx_t_3);
          __pyx_t_3 = 0;
          __pyx_t_28 = __Pyx_PyObject_Call(__pyx_t_11, __pyx_t_12, NULL); if (unlikely(!__pyx_t_28)) __PYX_ERR(0, 561, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_28);
          __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
        }
      }
      __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
      if (!(likely(((__pyx_t_28) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_28, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 561, __pyx_L1_error)
      __pyx_t_27 = ((PyArrayObject *)__pyx_t_28);
      {
        __Pyx_BufFmt_StackElem __pyx_stack[1];
        __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_dS.rcbuffer->pybuffer);
        __pyx_t_17 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_dS.rcbuffer->pybuffer, (PyObject*)__pyx_t_27, &__Pyx_TypeInfo_double, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack);
        if (unlikely(__pyx_t_17 < 0)) {
          PyErr_Fetch(&__pyx_t_22, &__pyx_t_21, &__pyx_t_20);
          if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_dS.rcbuffer->pybuffer, (PyObject*)__pyx_v_dS, &__Pyx_TypeInfo_double, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {
            Py_XDECREF(__pyx_t_22); Py_XDECREF(__pyx_t_21); Py_XDECREF(__pyx_t_20);
            __Pyx_RaiseBufferFallbackError();
          } else {
            PyErr_Restore(__pyx_t_22, __pyx_t_21, __pyx_t_20);
          }
        }
        __pyx_pybuffernd_dS.diminfo[0].strides = __pyx_pybuffernd_dS.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_dS.diminfo[0].shape = __pyx_pybuffernd_dS.rcbuffer->pybuffer.shape[0];
        if (unlikely(__pyx_t_17 < 0)) __PYX_ERR(0, 561, __pyx_L1_error)
      }
      __pyx_t_27 = 0;
      __Pyx_DECREF_SET(__pyx_v_dS, ((PyArrayObject *)__pyx_t_28));
      __pyx_t_28 = 0;
+562:     if DX is None or DX[1] is None:
  __pyx_t_1 = (__pyx_v_DX == Py_None);
  __pyx_t_29 = (__pyx_t_1 != 0);
  if (!__pyx_t_29) {
  } else {
    __pyx_t_2 = __pyx_t_29;
    goto __pyx_L31_bool_binop_done;
  }
  __pyx_t_28 = __Pyx_GetItemInt(__pyx_v_DX, 1, long, 1, __Pyx_PyInt_From_long, 0, 0, 0); if (unlikely(!__pyx_t_28)) __PYX_ERR(0, 562, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_28);
  __pyx_t_29 = (__pyx_t_28 == Py_None);
  __Pyx_DECREF(__pyx_t_28); __pyx_t_28 = 0;
  __pyx_t_1 = (__pyx_t_29 != 0);
  __pyx_t_2 = __pyx_t_1;
  __pyx_L31_bool_binop_done:;
  if (__pyx_t_2) {
/* … */
  }
+563:         pts = np.array([(XMinMax[1]-DIn)*np.ones((Y0n*Z0n,)), np.tile(Y0,Z0n), np.repeat(Z0,Y0n)])
    __pyx_t_11 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 563, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_11);
    __pyx_t_12 = __Pyx_PyObject_GetAttrStr(__pyx_t_11, __pyx_n_s_array); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 563, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_12);
    __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
    __pyx_t_32 = 1;
    __pyx_t_11 = PyFloat_FromDouble(((*((double *) ( /* dim=0 */ ((char *) (((double *) __pyx_v_XMinMax.data) + __pyx_t_32)) ))) - __pyx_v_DIn)); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 563, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_11);
    __pyx_t_8 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 563, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_8);
    __pyx_t_10 = __Pyx_PyObject_GetAttrStr(__pyx_t_8, __pyx_n_s_ones); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 563, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_10);
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    __pyx_t_8 = __Pyx_PyInt_From_int((__pyx_v_Y0n * __pyx_v_Z0n)); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 563, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_8);
    __pyx_t_14 = PyTuple_New(1); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 563, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_14);
    __Pyx_GIVEREF(__pyx_t_8);
    PyTuple_SET_ITEM(__pyx_t_14, 0, __pyx_t_8);
    __pyx_t_8 = 0;
    __pyx_t_8 = NULL;
    if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_10))) {
      __pyx_t_8 = PyMethod_GET_SELF(__pyx_t_10);
      if (likely(__pyx_t_8)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_10);
        __Pyx_INCREF(__pyx_t_8);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_10, function);
      }
    }
    if (!__pyx_t_8) {
      __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_t_10, __pyx_t_14); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 563, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
      __Pyx_GOTREF(__pyx_t_3);
    } else {
      #if CYTHON_FAST_PYCALL
      if (PyFunction_Check(__pyx_t_10)) {
        PyObject *__pyx_temp[2] = {__pyx_t_8, __pyx_t_14};
        __pyx_t_3 = __Pyx_PyFunction_FastCall(__pyx_t_10, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 563, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
        __Pyx_GOTREF(__pyx_t_3);
        __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
      } else
      #endif
      #if CYTHON_FAST_PYCCALL
      if (__Pyx_PyFastCFunction_Check(__pyx_t_10)) {
        PyObject *__pyx_temp[2] = {__pyx_t_8, __pyx_t_14};
        __pyx_t_3 = __Pyx_PyCFunction_FastCall(__pyx_t_10, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 563, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
        __Pyx_GOTREF(__pyx_t_3);
        __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
      } else
      #endif
      {
        __pyx_t_6 = PyTuple_New(1+1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 563, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_6);
        __Pyx_GIVEREF(__pyx_t_8); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_8); __pyx_t_8 = NULL;
        __Pyx_GIVEREF(__pyx_t_14);
        PyTuple_SET_ITEM(__pyx_t_6, 0+1, __pyx_t_14);
        __pyx_t_14 = 0;
        __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_10, __pyx_t_6, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 563, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_3);
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      }
    }
    __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
    __pyx_t_10 = PyNumber_Multiply(__pyx_t_11, __pyx_t_3); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 563, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_10);
    __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_t_11 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 563, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_11);
    __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_11, __pyx_n_s_tile); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 563, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
    __pyx_t_11 = __Pyx_PyInt_From_int(__pyx_v_Z0n); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 563, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_11);
    __pyx_t_14 = NULL;
    __pyx_t_17 = 0;
    if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_6))) {
      __pyx_t_14 = PyMethod_GET_SELF(__pyx_t_6);
      if (likely(__pyx_t_14)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6);
        __Pyx_INCREF(__pyx_t_14);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_6, function);
        __pyx_t_17 = 1;
      }
    }
    #if CYTHON_FAST_PYCALL
    if (PyFunction_Check(__pyx_t_6)) {
      PyObject *__pyx_temp[3] = {__pyx_t_14, ((PyObject *)__pyx_v_Y0), __pyx_t_11};
      __pyx_t_3 = __Pyx_PyFunction_FastCall(__pyx_t_6, __pyx_temp+1-__pyx_t_17, 2+__pyx_t_17); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 563, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_14); __pyx_t_14 = 0;
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
    } else
    #endif
    #if CYTHON_FAST_PYCCALL
    if (__Pyx_PyFastCFunction_Check(__pyx_t_6)) {
      PyObject *__pyx_temp[3] = {__pyx_t_14, ((PyObject *)__pyx_v_Y0), __pyx_t_11};
      __pyx_t_3 = __Pyx_PyCFunction_FastCall(__pyx_t_6, __pyx_temp+1-__pyx_t_17, 2+__pyx_t_17); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 563, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_14); __pyx_t_14 = 0;
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
    } else
    #endif
    {
      __pyx_t_8 = PyTuple_New(2+__pyx_t_17); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 563, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_8);
      if (__pyx_t_14) {
        __Pyx_GIVEREF(__pyx_t_14); PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_14); __pyx_t_14 = NULL;
      }
      __Pyx_INCREF(((PyObject *)__pyx_v_Y0));
      __Pyx_GIVEREF(((PyObject *)__pyx_v_Y0));
      PyTuple_SET_ITEM(__pyx_t_8, 0+__pyx_t_17, ((PyObject *)__pyx_v_Y0));
      __Pyx_GIVEREF(__pyx_t_11);
      PyTuple_SET_ITEM(__pyx_t_8, 1+__pyx_t_17, __pyx_t_11);
      __pyx_t_11 = 0;
      __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_6, __pyx_t_8, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 563, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    }
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __pyx_t_8 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 563, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_8);
    __pyx_t_11 = __Pyx_PyObject_GetAttrStr(__pyx_t_8, __pyx_n_s_repeat); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 563, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_11);
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    __pyx_t_8 = __Pyx_PyInt_From_int(__pyx_v_Y0n); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 563, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_8);
    __pyx_t_14 = NULL;
    __pyx_t_17 = 0;
    if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_11))) {
      __pyx_t_14 = PyMethod_GET_SELF(__pyx_t_11);
      if (likely(__pyx_t_14)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_11);
        __Pyx_INCREF(__pyx_t_14);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_11, function);
        __pyx_t_17 = 1;
      }
    }
    #if CYTHON_FAST_PYCALL
    if (PyFunction_Check(__pyx_t_11)) {
      PyObject *__pyx_temp[3] = {__pyx_t_14, ((PyObject *)__pyx_v_Z0), __pyx_t_8};
      __pyx_t_6 = __Pyx_PyFunction_FastCall(__pyx_t_11, __pyx_temp+1-__pyx_t_17, 2+__pyx_t_17); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 563, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_14); __pyx_t_14 = 0;
      __Pyx_GOTREF(__pyx_t_6);
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    } else
    #endif
    #if CYTHON_FAST_PYCCALL
    if (__Pyx_PyFastCFunction_Check(__pyx_t_11)) {
      PyObject *__pyx_temp[3] = {__pyx_t_14, ((PyObject *)__pyx_v_Z0), __pyx_t_8};
      __pyx_t_6 = __Pyx_PyCFunction_FastCall(__pyx_t_11, __pyx_temp+1-__pyx_t_17, 2+__pyx_t_17); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 563, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_14); __pyx_t_14 = 0;
      __Pyx_GOTREF(__pyx_t_6);
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    } else
    #endif
    {
      __pyx_t_5 = PyTuple_New(2+__pyx_t_17); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 563, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
      if (__pyx_t_14) {
        __Pyx_GIVEREF(__pyx_t_14); PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_14); __pyx_t_14 = NULL;
      }
      __Pyx_INCREF(((PyObject *)__pyx_v_Z0));
      __Pyx_GIVEREF(((PyObject *)__pyx_v_Z0));
      PyTuple_SET_ITEM(__pyx_t_5, 0+__pyx_t_17, ((PyObject *)__pyx_v_Z0));
      __Pyx_GIVEREF(__pyx_t_8);
      PyTuple_SET_ITEM(__pyx_t_5, 1+__pyx_t_17, __pyx_t_8);
      __pyx_t_8 = 0;
      __pyx_t_6 = __Pyx_PyObject_Call(__pyx_t_11, __pyx_t_5, NULL); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 563, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_6);
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    }
    __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
    __pyx_t_11 = PyList_New(3); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 563, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_11);
    __Pyx_GIVEREF(__pyx_t_10);
    PyList_SET_ITEM(__pyx_t_11, 0, __pyx_t_10);
    __Pyx_GIVEREF(__pyx_t_3);
    PyList_SET_ITEM(__pyx_t_11, 1, __pyx_t_3);
    __Pyx_GIVEREF(__pyx_t_6);
    PyList_SET_ITEM(__pyx_t_11, 2, __pyx_t_6);
    __pyx_t_10 = 0;
    __pyx_t_3 = 0;
    __pyx_t_6 = 0;
    __pyx_t_6 = NULL;
    if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_12))) {
      __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_12);
      if (likely(__pyx_t_6)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_12);
        __Pyx_INCREF(__pyx_t_6);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_12, function);
      }
    }
    if (!__pyx_t_6) {
      __pyx_t_28 = __Pyx_PyObject_CallOneArg(__pyx_t_12, __pyx_t_11); if (unlikely(!__pyx_t_28)) __PYX_ERR(0, 563, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
      __Pyx_GOTREF(__pyx_t_28);
    } else {
      #if CYTHON_FAST_PYCALL
      if (PyFunction_Check(__pyx_t_12)) {
        PyObject *__pyx_temp[2] = {__pyx_t_6, __pyx_t_11};
        __pyx_t_28 = __Pyx_PyFunction_FastCall(__pyx_t_12, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_28)) __PYX_ERR(0, 563, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
        __Pyx_GOTREF(__pyx_t_28);
        __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
      } else
      #endif
      #if CYTHON_FAST_PYCCALL
      if (__Pyx_PyFastCFunction_Check(__pyx_t_12)) {
        PyObject *__pyx_temp[2] = {__pyx_t_6, __pyx_t_11};
        __pyx_t_28 = __Pyx_PyCFunction_FastCall(__pyx_t_12, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_28)) __PYX_ERR(0, 563, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
        __Pyx_GOTREF(__pyx_t_28);
        __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
      } else
      #endif
      {
        __pyx_t_3 = PyTuple_New(1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 563, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_3);
        __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_6); __pyx_t_6 = NULL;
        __Pyx_GIVEREF(__pyx_t_11);
        PyTuple_SET_ITEM(__pyx_t_3, 0+1, __pyx_t_11);
        __pyx_t_11 = 0;
        __pyx_t_28 = __Pyx_PyObject_Call(__pyx_t_12, __pyx_t_3, NULL); if (unlikely(!__pyx_t_28)) __PYX_ERR(0, 563, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_28);
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      }
    }
    __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
    __Pyx_XDECREF_SET(__pyx_v_pts, __pyx_t_28);
    __pyx_t_28 = 0;
+564:         iind = NY0*NZ0 + NX*NR0 + NY0*np.repeat(indZ0,Y0n) + np.tile(indY0,Z0n)
    __pyx_t_28 = __Pyx_PyInt_From_int(((__pyx_v_NY0 * __pyx_v_NZ0) + (__pyx_v_NX * __pyx_v_NR0))); if (unlikely(!__pyx_t_28)) __PYX_ERR(0, 564, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_28);
    __pyx_t_12 = __Pyx_PyInt_From_int(__pyx_v_NY0); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 564, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_12);
    __pyx_t_11 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 564, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_11);
    __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_11, __pyx_n_s_repeat); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 564, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
    __pyx_t_11 = __Pyx_PyInt_From_int(__pyx_v_Y0n); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 564, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_11);
    __pyx_t_10 = NULL;
    __pyx_t_17 = 0;
    if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_6))) {
      __pyx_t_10 = PyMethod_GET_SELF(__pyx_t_6);
      if (likely(__pyx_t_10)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6);
        __Pyx_INCREF(__pyx_t_10);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_6, function);
        __pyx_t_17 = 1;
      }
    }
    #if CYTHON_FAST_PYCALL
    if (PyFunction_Check(__pyx_t_6)) {
      PyObject *__pyx_temp[3] = {__pyx_t_10, ((PyObject *)__pyx_v_indZ0), __pyx_t_11};
      __pyx_t_3 = __Pyx_PyFunction_FastCall(__pyx_t_6, __pyx_temp+1-__pyx_t_17, 2+__pyx_t_17); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 564, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
    } else
    #endif
    #if CYTHON_FAST_PYCCALL
    if (__Pyx_PyFastCFunction_Check(__pyx_t_6)) {
      PyObject *__pyx_temp[3] = {__pyx_t_10, ((PyObject *)__pyx_v_indZ0), __pyx_t_11};
      __pyx_t_3 = __Pyx_PyCFunction_FastCall(__pyx_t_6, __pyx_temp+1-__pyx_t_17, 2+__pyx_t_17); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 564, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
    } else
    #endif
    {
      __pyx_t_5 = PyTuple_New(2+__pyx_t_17); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 564, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
      if (__pyx_t_10) {
        __Pyx_GIVEREF(__pyx_t_10); PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_10); __pyx_t_10 = NULL;
      }
      __Pyx_INCREF(((PyObject *)__pyx_v_indZ0));
      __Pyx_GIVEREF(((PyObject *)__pyx_v_indZ0));
      PyTuple_SET_ITEM(__pyx_t_5, 0+__pyx_t_17, ((PyObject *)__pyx_v_indZ0));
      __Pyx_GIVEREF(__pyx_t_11);
      PyTuple_SET_ITEM(__pyx_t_5, 1+__pyx_t_17, __pyx_t_11);
      __pyx_t_11 = 0;
      __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_6, __pyx_t_5, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 564, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    }
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __pyx_t_6 = PyNumber_Multiply(__pyx_t_12, __pyx_t_3); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 564, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_t_3 = PyNumber_Add(__pyx_t_28, __pyx_t_6); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 564, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_28); __pyx_t_28 = 0;
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __pyx_t_28 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_28)) __PYX_ERR(0, 564, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_28);
    __pyx_t_12 = __Pyx_PyObject_GetAttrStr(__pyx_t_28, __pyx_n_s_tile); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 564, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_12);
    __Pyx_DECREF(__pyx_t_28); __pyx_t_28 = 0;
    __pyx_t_28 = __Pyx_PyInt_From_int(__pyx_v_Z0n); if (unlikely(!__pyx_t_28)) __PYX_ERR(0, 564, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_28);
    __pyx_t_5 = NULL;
    __pyx_t_17 = 0;
    if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_12))) {
      __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_12);
      if (likely(__pyx_t_5)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_12);
        __Pyx_INCREF(__pyx_t_5);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_12, function);
        __pyx_t_17 = 1;
      }
    }
    #if CYTHON_FAST_PYCALL
    if (PyFunction_Check(__pyx_t_12)) {
      PyObject *__pyx_temp[3] = {__pyx_t_5, ((PyObject *)__pyx_v_indY0), __pyx_t_28};
      __pyx_t_6 = __Pyx_PyFunction_FastCall(__pyx_t_12, __pyx_temp+1-__pyx_t_17, 2+__pyx_t_17); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 564, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
      __Pyx_GOTREF(__pyx_t_6);
      __Pyx_DECREF(__pyx_t_28); __pyx_t_28 = 0;
    } else
    #endif
    #if CYTHON_FAST_PYCCALL
    if (__Pyx_PyFastCFunction_Check(__pyx_t_12)) {
      PyObject *__pyx_temp[3] = {__pyx_t_5, ((PyObject *)__pyx_v_indY0), __pyx_t_28};
      __pyx_t_6 = __Pyx_PyCFunction_FastCall(__pyx_t_12, __pyx_temp+1-__pyx_t_17, 2+__pyx_t_17); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 564, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
      __Pyx_GOTREF(__pyx_t_6);
      __Pyx_DECREF(__pyx_t_28); __pyx_t_28 = 0;
    } else
    #endif
    {
      __pyx_t_11 = PyTuple_New(2+__pyx_t_17); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 564, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_11);
      if (__pyx_t_5) {
        __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_11, 0, __pyx_t_5); __pyx_t_5 = NULL;
      }
      __Pyx_INCREF(((PyObject *)__pyx_v_indY0));
      __Pyx_GIVEREF(((PyObject *)__pyx_v_indY0));
      PyTuple_SET_ITEM(__pyx_t_11, 0+__pyx_t_17, ((PyObject *)__pyx_v_indY0));
      __Pyx_GIVEREF(__pyx_t_28);
      PyTuple_SET_ITEM(__pyx_t_11, 1+__pyx_t_17, __pyx_t_28);
      __pyx_t_28 = 0;
      __pyx_t_6 = __Pyx_PyObject_Call(__pyx_t_12, __pyx_t_11, NULL); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 564, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_6);
      __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
    }
    __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
    __pyx_t_12 = PyNumber_Add(__pyx_t_3, __pyx_t_6); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 564, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_12);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __Pyx_XDECREF_SET(__pyx_v_iind, __pyx_t_12);
    __pyx_t_12 = 0;
+565:         indin = Path(VPoly.T).contains_points(pts[1:,:].T, transform=None, radius=0.0)
    __pyx_t_6 = __Pyx_GetModuleGlobalName(__pyx_n_s_Path); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 565, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_t_31 = __pyx_v_VPoly;
    __PYX_INC_MEMVIEW(&__pyx_t_31, 1);
    if (unlikely(__pyx_memslice_transpose(&__pyx_t_31) == 0)) __PYX_ERR(0, 565, __pyx_L1_error)
    __pyx_t_3 = __pyx_memoryview_fromslice(__pyx_t_31, 2, (PyObject *(*)(char *)) __pyx_memview_get_double, (int (*)(char *, PyObject *)) __pyx_memview_set_double, 0);; if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 565, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __PYX_XDEC_MEMVIEW(&__pyx_t_31, 1);
    __pyx_t_31.memview = NULL;
    __pyx_t_31.data = NULL;
    __pyx_t_11 = NULL;
    if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_6))) {
      __pyx_t_11 = PyMethod_GET_SELF(__pyx_t_6);
      if (likely(__pyx_t_11)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6);
        __Pyx_INCREF(__pyx_t_11);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_6, function);
      }
    }
    if (!__pyx_t_11) {
      __pyx_t_12 = __Pyx_PyObject_CallOneArg(__pyx_t_6, __pyx_t_3); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 565, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __Pyx_GOTREF(__pyx_t_12);
    } else {
      #if CYTHON_FAST_PYCALL
      if (PyFunction_Check(__pyx_t_6)) {
        PyObject *__pyx_temp[2] = {__pyx_t_11, __pyx_t_3};
        __pyx_t_12 = __Pyx_PyFunction_FastCall(__pyx_t_6, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 565, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0;
        __Pyx_GOTREF(__pyx_t_12);
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      } else
      #endif
      #if CYTHON_FAST_PYCCALL
      if (__Pyx_PyFastCFunction_Check(__pyx_t_6)) {
        PyObject *__pyx_temp[2] = {__pyx_t_11, __pyx_t_3};
        __pyx_t_12 = __Pyx_PyCFunction_FastCall(__pyx_t_6, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 565, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0;
        __Pyx_GOTREF(__pyx_t_12);
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      } else
      #endif
      {
        __pyx_t_28 = PyTuple_New(1+1); if (unlikely(!__pyx_t_28)) __PYX_ERR(0, 565, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_28);
        __Pyx_GIVEREF(__pyx_t_11); PyTuple_SET_ITEM(__pyx_t_28, 0, __pyx_t_11); __pyx_t_11 = NULL;
        __Pyx_GIVEREF(__pyx_t_3);
        PyTuple_SET_ITEM(__pyx_t_28, 0+1, __pyx_t_3);
        __pyx_t_3 = 0;
        __pyx_t_12 = __Pyx_PyObject_Call(__pyx_t_6, __pyx_t_28, NULL); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 565, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_12);
        __Pyx_DECREF(__pyx_t_28); __pyx_t_28 = 0;
      }
    }
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_12, __pyx_n_s_contains_points); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 565, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
/* … */
  __pyx_slice__71 = PySlice_New(__pyx_int_1, Py_None, Py_None); if (unlikely(!__pyx_slice__71)) __PYX_ERR(0, 565, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_slice__71);
  __Pyx_GIVEREF(__pyx_slice__71);
  __pyx_slice__72 = PySlice_New(Py_None, Py_None, Py_None); if (unlikely(!__pyx_slice__72)) __PYX_ERR(0, 565, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_slice__72);
  __Pyx_GIVEREF(__pyx_slice__72);
    __pyx_t_12 = PyObject_GetItem(__pyx_v_pts, __pyx_tuple__73); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 565, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_12);
    __pyx_t_28 = __Pyx_PyObject_GetAttrStr(__pyx_t_12, __pyx_n_s_T); if (unlikely(!__pyx_t_28)) __PYX_ERR(0, 565, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_28);
    __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
    __pyx_t_12 = PyTuple_New(1); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 565, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_12);
    __Pyx_GIVEREF(__pyx_t_28);
    PyTuple_SET_ITEM(__pyx_t_12, 0, __pyx_t_28);
    __pyx_t_28 = 0;
    __pyx_t_28 = PyDict_New(); if (unlikely(!__pyx_t_28)) __PYX_ERR(0, 565, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_28);
    if (PyDict_SetItem(__pyx_t_28, __pyx_n_s_transform, Py_None) < 0) __PYX_ERR(0, 565, __pyx_L1_error)
    if (PyDict_SetItem(__pyx_t_28, __pyx_n_s_radius, __pyx_float_0_0) < 0) __PYX_ERR(0, 565, __pyx_L1_error)
    __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_6, __pyx_t_12, __pyx_t_28); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 565, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
    __Pyx_DECREF(__pyx_t_28); __pyx_t_28 = 0;
    __Pyx_DECREF_SET(__pyx_v_indin, __pyx_t_3);
    __pyx_t_3 = 0;
  __pyx_tuple__73 = PyTuple_Pack(2, __pyx_slice__71, __pyx_slice__72); if (unlikely(!__pyx_tuple__73)) __PYX_ERR(0, 565, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__73);
  __Pyx_GIVEREF(__pyx_tuple__73);
+566:         if np.any(indin):
    __pyx_t_28 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_28)) __PYX_ERR(0, 566, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_28);
    __pyx_t_12 = __Pyx_PyObject_GetAttrStr(__pyx_t_28, __pyx_n_s_any); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 566, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_12);
    __Pyx_DECREF(__pyx_t_28); __pyx_t_28 = 0;
    __pyx_t_28 = NULL;
    if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_12))) {
      __pyx_t_28 = PyMethod_GET_SELF(__pyx_t_12);
      if (likely(__pyx_t_28)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_12);
        __Pyx_INCREF(__pyx_t_28);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_12, function);
      }
    }
    if (!__pyx_t_28) {
      __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_t_12, __pyx_v_indin); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 566, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
    } else {
      #if CYTHON_FAST_PYCALL
      if (PyFunction_Check(__pyx_t_12)) {
        PyObject *__pyx_temp[2] = {__pyx_t_28, __pyx_v_indin};
        __pyx_t_3 = __Pyx_PyFunction_FastCall(__pyx_t_12, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 566, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_28); __pyx_t_28 = 0;
        __Pyx_GOTREF(__pyx_t_3);
      } else
      #endif
      #if CYTHON_FAST_PYCCALL
      if (__Pyx_PyFastCFunction_Check(__pyx_t_12)) {
        PyObject *__pyx_temp[2] = {__pyx_t_28, __pyx_v_indin};
        __pyx_t_3 = __Pyx_PyCFunction_FastCall(__pyx_t_12, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 566, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_28); __pyx_t_28 = 0;
        __Pyx_GOTREF(__pyx_t_3);
      } else
      #endif
      {
        __pyx_t_6 = PyTuple_New(1+1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 566, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_6);
        __Pyx_GIVEREF(__pyx_t_28); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_28); __pyx_t_28 = NULL;
        __Pyx_INCREF(__pyx_v_indin);
        __Pyx_GIVEREF(__pyx_v_indin);
        PyTuple_SET_ITEM(__pyx_t_6, 0+1, __pyx_v_indin);
        __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_12, __pyx_t_6, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 566, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_3);
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      }
    }
    __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
    __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(0, 566, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    if (__pyx_t_2) {
/* … */
    }
+567:             pts = pts[:,indin].reshape((3,1)) if indin.sum()==1 else pts[:,indin]
      __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_v_indin, __pyx_n_s_sum); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 567, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_6);
      __pyx_t_28 = NULL;
      if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_6))) {
        __pyx_t_28 = PyMethod_GET_SELF(__pyx_t_6);
        if (likely(__pyx_t_28)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6);
          __Pyx_INCREF(__pyx_t_28);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_6, function);
        }
      }
      if (__pyx_t_28) {
        __pyx_t_12 = __Pyx_PyObject_CallOneArg(__pyx_t_6, __pyx_t_28); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 567, __pyx_L1_error)
        __Pyx_DECREF(__pyx_t_28); __pyx_t_28 = 0;
      } else {
        __pyx_t_12 = __Pyx_PyObject_CallNoArg(__pyx_t_6); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 567, __pyx_L1_error)
      }
      __Pyx_GOTREF(__pyx_t_12);
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      __pyx_t_6 = __Pyx_PyInt_EqObjC(__pyx_t_12, __pyx_int_1, 1, 0); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 567, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_6);
      __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
      __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_6); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(0, 567, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      if (__pyx_t_2) {
        __pyx_t_6 = PyTuple_New(2); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 567, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_6);
        __Pyx_INCREF(__pyx_slice__74);
        __Pyx_GIVEREF(__pyx_slice__74);
        PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_slice__74);
        __Pyx_INCREF(__pyx_v_indin);
        __Pyx_GIVEREF(__pyx_v_indin);
        PyTuple_SET_ITEM(__pyx_t_6, 1, __pyx_v_indin);
        __pyx_t_12 = PyObject_GetItem(__pyx_v_pts, __pyx_t_6); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 567, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_12);
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
        __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_12, __pyx_n_s_reshape); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 567, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_6);
        __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
/* … */
  __pyx_slice__74 = PySlice_New(Py_None, Py_None, Py_None); if (unlikely(!__pyx_slice__74)) __PYX_ERR(0, 567, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_slice__74);
  __Pyx_GIVEREF(__pyx_slice__74);
  __pyx_tuple__75 = PyTuple_Pack(2, __pyx_int_3, __pyx_int_1); if (unlikely(!__pyx_tuple__75)) __PYX_ERR(0, 567, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__75);
  __Pyx_GIVEREF(__pyx_tuple__75);
        __pyx_t_12 = __Pyx_PyObject_Call(__pyx_t_6, __pyx_tuple__76, NULL); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 567, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_12);
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
        __pyx_t_3 = __pyx_t_12;
        __pyx_t_12 = 0;
      } else {
  __pyx_tuple__76 = PyTuple_Pack(1, __pyx_tuple__75); if (unlikely(!__pyx_tuple__76)) __PYX_ERR(0, 567, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__76);
  __Pyx_GIVEREF(__pyx_tuple__76);
        __pyx_t_12 = PyTuple_New(2); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 567, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_12);
        __Pyx_INCREF(__pyx_slice__77);
        __Pyx_GIVEREF(__pyx_slice__77);
        PyTuple_SET_ITEM(__pyx_t_12, 0, __pyx_slice__77);
        __Pyx_INCREF(__pyx_v_indin);
        __Pyx_GIVEREF(__pyx_v_indin);
        PyTuple_SET_ITEM(__pyx_t_12, 1, __pyx_v_indin);
        __pyx_t_6 = PyObject_GetItem(__pyx_v_pts, __pyx_t_12); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 567, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_6);
        __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
        __pyx_t_3 = __pyx_t_6;
        __pyx_t_6 = 0;
      }
      __Pyx_DECREF_SET(__pyx_v_pts, __pyx_t_3);
      __pyx_t_3 = 0;
  __pyx_slice__77 = PySlice_New(Py_None, Py_None, Py_None); if (unlikely(!__pyx_slice__77)) __PYX_ERR(0, 567, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_slice__77);
  __Pyx_GIVEREF(__pyx_slice__77);
+568:             Pts = np.concatenate((Pts,pts),axis=1)
      __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 568, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_concatenate); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 568, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_6);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 568, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_INCREF(((PyObject *)__pyx_v_Pts));
      __Pyx_GIVEREF(((PyObject *)__pyx_v_Pts));
      PyTuple_SET_ITEM(__pyx_t_3, 0, ((PyObject *)__pyx_v_Pts));
      __Pyx_INCREF(__pyx_v_pts);
      __Pyx_GIVEREF(__pyx_v_pts);
      PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_v_pts);
      __pyx_t_12 = PyTuple_New(1); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 568, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_12);
      __Pyx_GIVEREF(__pyx_t_3);
      PyTuple_SET_ITEM(__pyx_t_12, 0, __pyx_t_3);
      __pyx_t_3 = 0;
      __pyx_t_3 = PyDict_New(); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 568, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_axis, __pyx_int_1) < 0) __PYX_ERR(0, 568, __pyx_L1_error)
      __pyx_t_28 = __Pyx_PyObject_Call(__pyx_t_6, __pyx_t_12, __pyx_t_3); if (unlikely(!__pyx_t_28)) __PYX_ERR(0, 568, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_28);
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      if (!(likely(((__pyx_t_28) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_28, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 568, __pyx_L1_error)
      __pyx_t_26 = ((PyArrayObject *)__pyx_t_28);
      {
        __Pyx_BufFmt_StackElem __pyx_stack[1];
        __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_Pts.rcbuffer->pybuffer);
        __pyx_t_17 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_Pts.rcbuffer->pybuffer, (PyObject*)__pyx_t_26, &__Pyx_TypeInfo_double, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack);
        if (unlikely(__pyx_t_17 < 0)) {
          PyErr_Fetch(&__pyx_t_20, &__pyx_t_21, &__pyx_t_22);
          if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_Pts.rcbuffer->pybuffer, (PyObject*)__pyx_v_Pts, &__Pyx_TypeInfo_double, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) {
            Py_XDECREF(__pyx_t_20); Py_XDECREF(__pyx_t_21); Py_XDECREF(__pyx_t_22);
            __Pyx_RaiseBufferFallbackError();
          } else {
            PyErr_Restore(__pyx_t_20, __pyx_t_21, __pyx_t_22);
          }
        }
        __pyx_pybuffernd_Pts.diminfo[0].strides = __pyx_pybuffernd_Pts.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_Pts.diminfo[0].shape = __pyx_pybuffernd_Pts.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_Pts.diminfo[1].strides = __pyx_pybuffernd_Pts.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_Pts.diminfo[1].shape = __pyx_pybuffernd_Pts.rcbuffer->pybuffer.shape[1];
        if (unlikely(__pyx_t_17 < 0)) __PYX_ERR(0, 568, __pyx_L1_error)
      }
      __pyx_t_26 = 0;
      __Pyx_DECREF_SET(__pyx_v_Pts, ((PyArrayObject *)__pyx_t_28));
      __pyx_t_28 = 0;
+569:             ind = np.concatenate((ind,iind[indin]))
      __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 569, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_12 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_concatenate); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 569, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_12);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __pyx_t_3 = PyObject_GetItem(__pyx_v_iind, __pyx_v_indin); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 569, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_6 = PyTuple_New(2); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 569, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_6);
      __Pyx_INCREF(((PyObject *)__pyx_v_ind));
      __Pyx_GIVEREF(((PyObject *)__pyx_v_ind));
      PyTuple_SET_ITEM(__pyx_t_6, 0, ((PyObject *)__pyx_v_ind));
      __Pyx_GIVEREF(__pyx_t_3);
      PyTuple_SET_ITEM(__pyx_t_6, 1, __pyx_t_3);
      __pyx_t_3 = 0;
      __pyx_t_3 = NULL;
      if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_12))) {
        __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_12);
        if (likely(__pyx_t_3)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_12);
          __Pyx_INCREF(__pyx_t_3);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_12, function);
        }
      }
      if (!__pyx_t_3) {
        __pyx_t_28 = __Pyx_PyObject_CallOneArg(__pyx_t_12, __pyx_t_6); if (unlikely(!__pyx_t_28)) __PYX_ERR(0, 569, __pyx_L1_error)
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
        __Pyx_GOTREF(__pyx_t_28);
      } else {
        #if CYTHON_FAST_PYCALL
        if (PyFunction_Check(__pyx_t_12)) {
          PyObject *__pyx_temp[2] = {__pyx_t_3, __pyx_t_6};
          __pyx_t_28 = __Pyx_PyFunction_FastCall(__pyx_t_12, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_28)) __PYX_ERR(0, 569, __pyx_L1_error)
          __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
          __Pyx_GOTREF(__pyx_t_28);
          __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
        } else
        #endif
        #if CYTHON_FAST_PYCCALL
        if (__Pyx_PyFastCFunction_Check(__pyx_t_12)) {
          PyObject *__pyx_temp[2] = {__pyx_t_3, __pyx_t_6};
          __pyx_t_28 = __Pyx_PyCFunction_FastCall(__pyx_t_12, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_28)) __PYX_ERR(0, 569, __pyx_L1_error)
          __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
          __Pyx_GOTREF(__pyx_t_28);
          __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
        } else
        #endif
        {
          __pyx_t_11 = PyTuple_New(1+1); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 569, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_11);
          __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_11, 0, __pyx_t_3); __pyx_t_3 = NULL;
          __Pyx_GIVEREF(__pyx_t_6);
          PyTuple_SET_ITEM(__pyx_t_11, 0+1, __pyx_t_6);
          __pyx_t_6 = 0;
          __pyx_t_28 = __Pyx_PyObject_Call(__pyx_t_12, __pyx_t_11, NULL); if (unlikely(!__pyx_t_28)) __PYX_ERR(0, 569, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_28);
          __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
        }
      }
      __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
      if (!(likely(((__pyx_t_28) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_28, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 569, __pyx_L1_error)
      __pyx_t_23 = ((PyArrayObject *)__pyx_t_28);
      {
        __Pyx_BufFmt_StackElem __pyx_stack[1];
        __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_ind.rcbuffer->pybuffer);
        __pyx_t_17 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_ind.rcbuffer->pybuffer, (PyObject*)__pyx_t_23, &__Pyx_TypeInfo_long, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack);
        if (unlikely(__pyx_t_17 < 0)) {
          PyErr_Fetch(&__pyx_t_22, &__pyx_t_21, &__pyx_t_20);
          if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_ind.rcbuffer->pybuffer, (PyObject*)__pyx_v_ind, &__Pyx_TypeInfo_long, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {
            Py_XDECREF(__pyx_t_22); Py_XDECREF(__pyx_t_21); Py_XDECREF(__pyx_t_20);
            __Pyx_RaiseBufferFallbackError();
          } else {
            PyErr_Restore(__pyx_t_22, __pyx_t_21, __pyx_t_20);
          }
        }
        __pyx_pybuffernd_ind.diminfo[0].strides = __pyx_pybuffernd_ind.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_ind.diminfo[0].shape = __pyx_pybuffernd_ind.rcbuffer->pybuffer.shape[0];
        if (unlikely(__pyx_t_17 < 0)) __PYX_ERR(0, 569, __pyx_L1_error)
      }
      __pyx_t_23 = 0;
      __Pyx_DECREF_SET(__pyx_v_ind, ((PyArrayObject *)__pyx_t_28));
      __pyx_t_28 = 0;
+570:             dS = np.concatenate((dS,dY0r*dZ0r*np.ones((indin.sum(),))))
      __pyx_t_12 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 570, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_12);
      __pyx_t_11 = __Pyx_PyObject_GetAttrStr(__pyx_t_12, __pyx_n_s_concatenate); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 570, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_11);
      __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
      __pyx_t_12 = PyFloat_FromDouble((__pyx_v_dY0r * __pyx_v_dZ0r)); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 570, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_12);
      __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 570, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_ones); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 570, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __pyx_t_10 = __Pyx_PyObject_GetAttrStr(__pyx_v_indin, __pyx_n_s_sum); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 570, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_10);
      __pyx_t_8 = NULL;
      if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_10))) {
        __pyx_t_8 = PyMethod_GET_SELF(__pyx_t_10);
        if (likely(__pyx_t_8)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_10);
          __Pyx_INCREF(__pyx_t_8);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_10, function);
        }
      }
      if (__pyx_t_8) {
        __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_t_10, __pyx_t_8); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 570, __pyx_L1_error)
        __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
      } else {
        __pyx_t_3 = __Pyx_PyObject_CallNoArg(__pyx_t_10); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 570, __pyx_L1_error)
      }
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
      __pyx_t_10 = PyTuple_New(1); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 570, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_10);
      __Pyx_GIVEREF(__pyx_t_3);
      PyTuple_SET_ITEM(__pyx_t_10, 0, __pyx_t_3);
      __pyx_t_3 = 0;
      __pyx_t_3 = NULL;
      if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_5))) {
        __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_5);
        if (likely(__pyx_t_3)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5);
          __Pyx_INCREF(__pyx_t_3);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_5, function);
        }
      }
      if (!__pyx_t_3) {
        __pyx_t_6 = __Pyx_PyObject_CallOneArg(__pyx_t_5, __pyx_t_10); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 570, __pyx_L1_error)
        __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
        __Pyx_GOTREF(__pyx_t_6);
      } else {
        #if CYTHON_FAST_PYCALL
        if (PyFunction_Check(__pyx_t_5)) {
          PyObject *__pyx_temp[2] = {__pyx_t_3, __pyx_t_10};
          __pyx_t_6 = __Pyx_PyFunction_FastCall(__pyx_t_5, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 570, __pyx_L1_error)
          __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
          __Pyx_GOTREF(__pyx_t_6);
          __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
        } else
        #endif
        #if CYTHON_FAST_PYCCALL
        if (__Pyx_PyFastCFunction_Check(__pyx_t_5)) {
          PyObject *__pyx_temp[2] = {__pyx_t_3, __pyx_t_10};
          __pyx_t_6 = __Pyx_PyCFunction_FastCall(__pyx_t_5, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 570, __pyx_L1_error)
          __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
          __Pyx_GOTREF(__pyx_t_6);
          __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
        } else
        #endif
        {
          __pyx_t_8 = PyTuple_New(1+1); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 570, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_8);
          __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_3); __pyx_t_3 = NULL;
          __Pyx_GIVEREF(__pyx_t_10);
          PyTuple_SET_ITEM(__pyx_t_8, 0+1, __pyx_t_10);
          __pyx_t_10 = 0;
          __pyx_t_6 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_t_8, NULL); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 570, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_6);
          __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
        }
      }
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __pyx_t_5 = PyNumber_Multiply(__pyx_t_12, __pyx_t_6); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 570, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      __pyx_t_6 = PyTuple_New(2); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 570, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_6);
      __Pyx_INCREF(((PyObject *)__pyx_v_dS));
      __Pyx_GIVEREF(((PyObject *)__pyx_v_dS));
      PyTuple_SET_ITEM(__pyx_t_6, 0, ((PyObject *)__pyx_v_dS));
      __Pyx_GIVEREF(__pyx_t_5);
      PyTuple_SET_ITEM(__pyx_t_6, 1, __pyx_t_5);
      __pyx_t_5 = 0;
      __pyx_t_5 = NULL;
      if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_11))) {
        __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_11);
        if (likely(__pyx_t_5)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_11);
          __Pyx_INCREF(__pyx_t_5);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_11, function);
        }
      }
      if (!__pyx_t_5) {
        __pyx_t_28 = __Pyx_PyObject_CallOneArg(__pyx_t_11, __pyx_t_6); if (unlikely(!__pyx_t_28)) __PYX_ERR(0, 570, __pyx_L1_error)
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
        __Pyx_GOTREF(__pyx_t_28);
      } else {
        #if CYTHON_FAST_PYCALL
        if (PyFunction_Check(__pyx_t_11)) {
          PyObject *__pyx_temp[2] = {__pyx_t_5, __pyx_t_6};
          __pyx_t_28 = __Pyx_PyFunction_FastCall(__pyx_t_11, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_28)) __PYX_ERR(0, 570, __pyx_L1_error)
          __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
          __Pyx_GOTREF(__pyx_t_28);
          __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
        } else
        #endif
        #if CYTHON_FAST_PYCCALL
        if (__Pyx_PyFastCFunction_Check(__pyx_t_11)) {
          PyObject *__pyx_temp[2] = {__pyx_t_5, __pyx_t_6};
          __pyx_t_28 = __Pyx_PyCFunction_FastCall(__pyx_t_11, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_28)) __PYX_ERR(0, 570, __pyx_L1_error)
          __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
          __Pyx_GOTREF(__pyx_t_28);
          __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
        } else
        #endif
        {
          __pyx_t_12 = PyTuple_New(1+1); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 570, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_12);
          __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_12, 0, __pyx_t_5); __pyx_t_5 = NULL;
          __Pyx_GIVEREF(__pyx_t_6);
          PyTuple_SET_ITEM(__pyx_t_12, 0+1, __pyx_t_6);
          __pyx_t_6 = 0;
          __pyx_t_28 = __Pyx_PyObject_Call(__pyx_t_11, __pyx_t_12, NULL); if (unlikely(!__pyx_t_28)) __PYX_ERR(0, 570, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_28);
          __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
        }
      }
      __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
      if (!(likely(((__pyx_t_28) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_28, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 570, __pyx_L1_error)
      __pyx_t_27 = ((PyArrayObject *)__pyx_t_28);
      {
        __Pyx_BufFmt_StackElem __pyx_stack[1];
        __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_dS.rcbuffer->pybuffer);
        __pyx_t_17 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_dS.rcbuffer->pybuffer, (PyObject*)__pyx_t_27, &__Pyx_TypeInfo_double, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack);
        if (unlikely(__pyx_t_17 < 0)) {
          PyErr_Fetch(&__pyx_t_20, &__pyx_t_21, &__pyx_t_22);
          if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_dS.rcbuffer->pybuffer, (PyObject*)__pyx_v_dS, &__Pyx_TypeInfo_double, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {
            Py_XDECREF(__pyx_t_20); Py_XDECREF(__pyx_t_21); Py_XDECREF(__pyx_t_22);
            __Pyx_RaiseBufferFallbackError();
          } else {
            PyErr_Restore(__pyx_t_20, __pyx_t_21, __pyx_t_22);
          }
        }
        __pyx_pybuffernd_dS.diminfo[0].strides = __pyx_pybuffernd_dS.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_dS.diminfo[0].shape = __pyx_pybuffernd_dS.rcbuffer->pybuffer.shape[0];
        if (unlikely(__pyx_t_17 < 0)) __PYX_ERR(0, 570, __pyx_L1_error)
      }
      __pyx_t_27 = 0;
      __Pyx_DECREF_SET(__pyx_v_dS, ((PyArrayObject *)__pyx_t_28));
      __pyx_t_28 = 0;
+571:     return Pts, dS, ind, NL, dLr, Rref, dXr, dY0r, dZ0r, VPbis
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_28 = PyFloat_FromDouble(__pyx_v_dXr); if (unlikely(!__pyx_t_28)) __PYX_ERR(0, 571, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_28);
  __pyx_t_11 = PyFloat_FromDouble(__pyx_v_dY0r); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 571, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_11);
  __pyx_t_12 = PyFloat_FromDouble(__pyx_v_dZ0r); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 571, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_12);
  __pyx_t_6 = PyTuple_New(10); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 571, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_INCREF(((PyObject *)__pyx_v_Pts));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_Pts));
  PyTuple_SET_ITEM(__pyx_t_6, 0, ((PyObject *)__pyx_v_Pts));
  __Pyx_INCREF(((PyObject *)__pyx_v_dS));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_dS));
  PyTuple_SET_ITEM(__pyx_t_6, 1, ((PyObject *)__pyx_v_dS));
  __Pyx_INCREF(((PyObject *)__pyx_v_ind));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_ind));
  PyTuple_SET_ITEM(__pyx_t_6, 2, ((PyObject *)__pyx_v_ind));
  __Pyx_INCREF(((PyObject *)__pyx_v_NL));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_NL));
  PyTuple_SET_ITEM(__pyx_t_6, 3, ((PyObject *)__pyx_v_NL));
  __Pyx_INCREF(((PyObject *)__pyx_v_dLr));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_dLr));
  PyTuple_SET_ITEM(__pyx_t_6, 4, ((PyObject *)__pyx_v_dLr));
  __Pyx_INCREF(((PyObject *)__pyx_v_Rref));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_Rref));
  PyTuple_SET_ITEM(__pyx_t_6, 5, ((PyObject *)__pyx_v_Rref));
  __Pyx_GIVEREF(__pyx_t_28);
  PyTuple_SET_ITEM(__pyx_t_6, 6, __pyx_t_28);
  __Pyx_GIVEREF(__pyx_t_11);
  PyTuple_SET_ITEM(__pyx_t_6, 7, __pyx_t_11);
  __Pyx_GIVEREF(__pyx_t_12);
  PyTuple_SET_ITEM(__pyx_t_6, 8, __pyx_t_12);
  __Pyx_INCREF(((PyObject *)__pyx_v_VPbis));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_VPbis));
  PyTuple_SET_ITEM(__pyx_t_6, 9, ((PyObject *)__pyx_v_VPbis));
  __pyx_t_28 = 0;
  __pyx_t_11 = 0;
  __pyx_t_12 = 0;
  __pyx_r = __pyx_t_6;
  __pyx_t_6 = 0;
  goto __pyx_L0;
 572: 
 573: 
 574: 
 575: 
 576: 
 577: 
 578: @cython.cdivision(True)
 579: @cython.wraparound(False)
 580: @cython.boundscheck(False)
+581: def _Ves_Smesh_Lin_SubFromInd_cython(double[::1] XMinMax, double dL, double dX,
/* Python wrapper */
static PyObject *__pyx_pw_46_cython_magic_8152fc40fb05daa7217c00b66474f995_15_Ves_Smesh_Lin_SubFromInd_cython(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_46_cython_magic_8152fc40fb05daa7217c00b66474f995_14_Ves_Smesh_Lin_SubFromInd_cython[] = " Return the desired surfacic submesh indicated by ind, for the desired resolution (dX,dL) ";
static PyMethodDef __pyx_mdef_46_cython_magic_8152fc40fb05daa7217c00b66474f995_15_Ves_Smesh_Lin_SubFromInd_cython = {"_Ves_Smesh_Lin_SubFromInd_cython", (PyCFunction)__pyx_pw_46_cython_magic_8152fc40fb05daa7217c00b66474f995_15_Ves_Smesh_Lin_SubFromInd_cython, METH_VARARGS|METH_KEYWORDS, __pyx_doc_46_cython_magic_8152fc40fb05daa7217c00b66474f995_14_Ves_Smesh_Lin_SubFromInd_cython};
static PyObject *__pyx_pw_46_cython_magic_8152fc40fb05daa7217c00b66474f995_15_Ves_Smesh_Lin_SubFromInd_cython(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  __Pyx_memviewslice __pyx_v_XMinMax = { 0, 0, { 0 }, { 0 }, { 0 } };
  double __pyx_v_dL;
  double __pyx_v_dX;
  __Pyx_memviewslice __pyx_v_VPoly = { 0, 0, { 0 }, { 0 }, { 0 } };
  PyArrayObject *__pyx_v_ind = 0;
  double __pyx_v_DIn;
  PyObject *__pyx_v_VIn = 0;
  double __pyx_v_margin;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("_Ves_Smesh_Lin_SubFromInd_cython (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_XMinMax,&__pyx_n_s_dL,&__pyx_n_s_dX,&__pyx_n_s_VPoly,&__pyx_n_s_ind,&__pyx_n_s_DIn,&__pyx_n_s_VIn,&__pyx_n_s_margin,0};
    PyObject* values[8] = {0,0,0,0,0,0,0,0};
/* … */
  /* function exit code */
  goto __pyx_L0;
  __pyx_L1_error:;
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_46_cython_magic_8152fc40fb05daa7217c00b66474f995_14_Ves_Smesh_Lin_SubFromInd_cython(CYTHON_UNUSED PyObject *__pyx_self, __Pyx_memviewslice __pyx_v_XMinMax, double __pyx_v_dL, double __pyx_v_dX, __Pyx_memviewslice __pyx_v_VPoly, PyArrayObject *__pyx_v_ind, double __pyx_v_DIn, PyObject *__pyx_v_VIn, double __pyx_v_margin) {
  double __pyx_v_dXr;
  double __pyx_v_dY0r;
  double __pyx_v_dZ0r;
  int __pyx_v_NX;
  int __pyx_v_NY0;
  int __pyx_v_NZ0;
  int __pyx_v_Ln;
  int __pyx_v_nii;
  PyObject *__pyx_v_LPts = 0;
  PyObject *__pyx_v_LdS = 0;
  PyArrayObject *__pyx_v_Pts = 0;
  PyArrayObject *__pyx_v_PtsCross = 0;
  PyArrayObject *__pyx_v_VPbis = 0;
  PyArrayObject *__pyx_v_X = 0;
  PyArrayObject *__pyx_v_Y0 = 0;
  PyArrayObject *__pyx_v_Z0 = 0;
  PyArrayObject *__pyx_v_dS = 0;
  PyArrayObject *__pyx_v_dLr = 0;
  PyArrayObject *__pyx_v_Rref = 0;
  PyArrayObject *__pyx_v_indX = 0;
  PyArrayObject *__pyx_v_indY0 = 0;
  PyArrayObject *__pyx_v_indZ0 = 0;
  PyArrayObject *__pyx_v_indL = 0;
  PyArrayObject *__pyx_v_NL = 0;
  PyArrayObject *__pyx_v_ii = 0;
  CYTHON_UNUSED PyObject *__pyx_v_bla = NULL;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_NL;
  __Pyx_Buffer __pyx_pybuffer_NL;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_Pts;
  __Pyx_Buffer __pyx_pybuffer_Pts;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_PtsCross;
  __Pyx_Buffer __pyx_pybuffer_PtsCross;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_Rref;
  __Pyx_Buffer __pyx_pybuffer_Rref;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_VPbis;
  __Pyx_Buffer __pyx_pybuffer_VPbis;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_X;
  __Pyx_Buffer __pyx_pybuffer_X;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_Y0;
  __Pyx_Buffer __pyx_pybuffer_Y0;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_Z0;
  __Pyx_Buffer __pyx_pybuffer_Z0;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_dLr;
  __Pyx_Buffer __pyx_pybuffer_dLr;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_dS;
  __Pyx_Buffer __pyx_pybuffer_dS;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_ii;
  __Pyx_Buffer __pyx_pybuffer_ii;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_ind;
  __Pyx_Buffer __pyx_pybuffer_ind;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_indL;
  __Pyx_Buffer __pyx_pybuffer_indL;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_indX;
  __Pyx_Buffer __pyx_pybuffer_indX;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_indY0;
  __Pyx_Buffer __pyx_pybuffer_indY0;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_indZ0;
  __Pyx_Buffer __pyx_pybuffer_indZ0;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("_Ves_Smesh_Lin_SubFromInd_cython", 0);
  __pyx_pybuffer_Pts.pybuffer.buf = NULL;
  __pyx_pybuffer_Pts.refcount = 0;
  __pyx_pybuffernd_Pts.data = NULL;
  __pyx_pybuffernd_Pts.rcbuffer = &__pyx_pybuffer_Pts;
  __pyx_pybuffer_PtsCross.pybuffer.buf = NULL;
  __pyx_pybuffer_PtsCross.refcount = 0;
  __pyx_pybuffernd_PtsCross.data = NULL;
  __pyx_pybuffernd_PtsCross.rcbuffer = &__pyx_pybuffer_PtsCross;
  __pyx_pybuffer_VPbis.pybuffer.buf = NULL;
  __pyx_pybuffer_VPbis.refcount = 0;
  __pyx_pybuffernd_VPbis.data = NULL;
  __pyx_pybuffernd_VPbis.rcbuffer = &__pyx_pybuffer_VPbis;
  __pyx_pybuffer_X.pybuffer.buf = NULL;
  __pyx_pybuffer_X.refcount = 0;
  __pyx_pybuffernd_X.data = NULL;
  __pyx_pybuffernd_X.rcbuffer = &__pyx_pybuffer_X;
  __pyx_pybuffer_Y0.pybuffer.buf = NULL;
  __pyx_pybuffer_Y0.refcount = 0;
  __pyx_pybuffernd_Y0.data = NULL;
  __pyx_pybuffernd_Y0.rcbuffer = &__pyx_pybuffer_Y0;
  __pyx_pybuffer_Z0.pybuffer.buf = NULL;
  __pyx_pybuffer_Z0.refcount = 0;
  __pyx_pybuffernd_Z0.data = NULL;
  __pyx_pybuffernd_Z0.rcbuffer = &__pyx_pybuffer_Z0;
  __pyx_pybuffer_dS.pybuffer.buf = NULL;
  __pyx_pybuffer_dS.refcount = 0;
  __pyx_pybuffernd_dS.data = NULL;
  __pyx_pybuffernd_dS.rcbuffer = &__pyx_pybuffer_dS;
  __pyx_pybuffer_dLr.pybuffer.buf = NULL;
  __pyx_pybuffer_dLr.refcount = 0;
  __pyx_pybuffernd_dLr.data = NULL;
  __pyx_pybuffernd_dLr.rcbuffer = &__pyx_pybuffer_dLr;
  __pyx_pybuffer_Rref.pybuffer.buf = NULL;
  __pyx_pybuffer_Rref.refcount = 0;
  __pyx_pybuffernd_Rref.data = NULL;
  __pyx_pybuffernd_Rref.rcbuffer = &__pyx_pybuffer_Rref;
  __pyx_pybuffer_indX.pybuffer.buf = NULL;
  __pyx_pybuffer_indX.refcount = 0;
  __pyx_pybuffernd_indX.data = NULL;
  __pyx_pybuffernd_indX.rcbuffer = &__pyx_pybuffer_indX;
  __pyx_pybuffer_indY0.pybuffer.buf = NULL;
  __pyx_pybuffer_indY0.refcount = 0;
  __pyx_pybuffernd_indY0.data = NULL;
  __pyx_pybuffernd_indY0.rcbuffer = &__pyx_pybuffer_indY0;
  __pyx_pybuffer_indZ0.pybuffer.buf = NULL;
  __pyx_pybuffer_indZ0.refcount = 0;
  __pyx_pybuffernd_indZ0.data = NULL;
  __pyx_pybuffernd_indZ0.rcbuffer = &__pyx_pybuffer_indZ0;
  __pyx_pybuffer_indL.pybuffer.buf = NULL;
  __pyx_pybuffer_indL.refcount = 0;
  __pyx_pybuffernd_indL.data = NULL;
  __pyx_pybuffernd_indL.rcbuffer = &__pyx_pybuffer_indL;
  __pyx_pybuffer_NL.pybuffer.buf = NULL;
  __pyx_pybuffer_NL.refcount = 0;
  __pyx_pybuffernd_NL.data = NULL;
  __pyx_pybuffernd_NL.rcbuffer = &__pyx_pybuffer_NL;
  __pyx_pybuffer_ii.pybuffer.buf = NULL;
  __pyx_pybuffer_ii.refcount = 0;
  __pyx_pybuffernd_ii.data = NULL;
  __pyx_pybuffernd_ii.rcbuffer = &__pyx_pybuffer_ii;
  __pyx_pybuffer_ind.pybuffer.buf = NULL;
  __pyx_pybuffer_ind.refcount = 0;
  __pyx_pybuffernd_ind.data = NULL;
  __pyx_pybuffernd_ind.rcbuffer = &__pyx_pybuffer_ind;
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_ind.rcbuffer->pybuffer, (PyObject*)__pyx_v_ind, &__Pyx_TypeInfo_long, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) __PYX_ERR(0, 581, __pyx_L1_error)
  }
  __pyx_pybuffernd_ind.diminfo[0].strides = __pyx_pybuffernd_ind.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_ind.diminfo[0].shape = __pyx_pybuffernd_ind.rcbuffer->pybuffer.shape[0];
/* … */
  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __PYX_XDEC_MEMVIEW(&__pyx_t_7, 1);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_XDECREF(__pyx_t_9);
  __Pyx_XDECREF(__pyx_t_10);
  { PyObject *__pyx_type, *__pyx_value, *__pyx_tb;
    __Pyx_PyThreadState_declare
    __Pyx_PyThreadState_assign
    __Pyx_ErrFetch(&__pyx_type, &__pyx_value, &__pyx_tb);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_NL.rcbuffer->pybuffer);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_Pts.rcbuffer->pybuffer);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_PtsCross.rcbuffer->pybuffer);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_Rref.rcbuffer->pybuffer);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_VPbis.rcbuffer->pybuffer);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_X.rcbuffer->pybuffer);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_Y0.rcbuffer->pybuffer);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_Z0.rcbuffer->pybuffer);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_dLr.rcbuffer->pybuffer);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_dS.rcbuffer->pybuffer);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_ii.rcbuffer->pybuffer);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_ind.rcbuffer->pybuffer);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_indL.rcbuffer->pybuffer);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_indX.rcbuffer->pybuffer);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_indY0.rcbuffer->pybuffer);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_indZ0.rcbuffer->pybuffer);
  __Pyx_ErrRestore(__pyx_type, __pyx_value, __pyx_tb);}
  __Pyx_AddTraceback("_cython_magic_8152fc40fb05daa7217c00b66474f995._Ves_Smesh_Lin_SubFromInd_cython", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  goto __pyx_L2;
  __pyx_L0:;
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_NL.rcbuffer->pybuffer);
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_Pts.rcbuffer->pybuffer);
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_PtsCross.rcbuffer->pybuffer);
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_Rref.rcbuffer->pybuffer);
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_VPbis.rcbuffer->pybuffer);
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_X.rcbuffer->pybuffer);
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_Y0.rcbuffer->pybuffer);
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_Z0.rcbuffer->pybuffer);
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_dLr.rcbuffer->pybuffer);
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_dS.rcbuffer->pybuffer);
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_ii.rcbuffer->pybuffer);
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_ind.rcbuffer->pybuffer);
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_indL.rcbuffer->pybuffer);
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_indX.rcbuffer->pybuffer);
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_indY0.rcbuffer->pybuffer);
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_indZ0.rcbuffer->pybuffer);
  __pyx_L2:;
  __Pyx_XDECREF(__pyx_v_LPts);
  __Pyx_XDECREF(__pyx_v_LdS);
  __Pyx_XDECREF((PyObject *)__pyx_v_Pts);
  __Pyx_XDECREF((PyObject *)__pyx_v_PtsCross);
  __Pyx_XDECREF((PyObject *)__pyx_v_VPbis);
  __Pyx_XDECREF((PyObject *)__pyx_v_X);
  __Pyx_XDECREF((PyObject *)__pyx_v_Y0);
  __Pyx_XDECREF((PyObject *)__pyx_v_Z0);
  __Pyx_XDECREF((PyObject *)__pyx_v_dS);
  __Pyx_XDECREF((PyObject *)__pyx_v_dLr);
  __Pyx_XDECREF((PyObject *)__pyx_v_Rref);
  __Pyx_XDECREF((PyObject *)__pyx_v_indX);
  __Pyx_XDECREF((PyObject *)__pyx_v_indY0);
  __Pyx_XDECREF((PyObject *)__pyx_v_indZ0);
  __Pyx_XDECREF((PyObject *)__pyx_v_indL);
  __Pyx_XDECREF((PyObject *)__pyx_v_NL);
  __Pyx_XDECREF((PyObject *)__pyx_v_ii);
  __Pyx_XDECREF(__pyx_v_bla);
  __PYX_XDEC_MEMVIEW(&__pyx_v_XMinMax, 1);
  __PYX_XDEC_MEMVIEW(&__pyx_v_VPoly, 1);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}
/* … */
  __pyx_tuple__119 = PyTuple_Pack(35, __pyx_n_s_XMinMax, __pyx_n_s_dL, __pyx_n_s_dX, __pyx_n_s_VPoly, __pyx_n_s_ind, __pyx_n_s_DIn, __pyx_n_s_VIn, __pyx_n_s_margin, __pyx_n_s_dXr, __pyx_n_s_dY0r, __pyx_n_s_dZ0r, __pyx_n_s_NX, __pyx_n_s_NY0, __pyx_n_s_NZ0, __pyx_n_s_Ln, __pyx_n_s_NR0, __pyx_n_s_nii, __pyx_n_s_LPts, __pyx_n_s_LdS, __pyx_n_s_Pts, __pyx_n_s_PtsCross, __pyx_n_s_VPbis, __pyx_n_s_X, __pyx_n_s_Y0, __pyx_n_s_Z0, __pyx_n_s_dS, __pyx_n_s_dLr, __pyx_n_s_Rref, __pyx_n_s_indX, __pyx_n_s_indY0, __pyx_n_s_indZ0, __pyx_n_s_indL, __pyx_n_s_NL, __pyx_n_s_ii, __pyx_n_s_bla); if (unlikely(!__pyx_tuple__119)) __PYX_ERR(0, 581, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__119);
  __Pyx_GIVEREF(__pyx_tuple__119);
/* … */
  __pyx_t_2 = PyCFunction_NewEx(&__pyx_mdef_46_cython_magic_8152fc40fb05daa7217c00b66474f995_15_Ves_Smesh_Lin_SubFromInd_cython, NULL, __pyx_n_s_cython_magic_8152fc40fb05daa721); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 581, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_Ves_Smesh_Lin_SubFromInd_cython, __pyx_t_2) < 0) __PYX_ERR(0, 581, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_codeobj__120 = (PyObject*)__Pyx_PyCode_New(8, 0, 35, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__119, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_Home_DV226270_cache_ipython_cyt, __pyx_n_s_Ves_Smesh_Lin_SubFromInd_cython, 581, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__120)) __PYX_ERR(0, 581, __pyx_L1_error)
 582:                                      double[:,::1] VPoly, cnp.ndarray[long,ndim=1] ind,
+583:                                      double DIn=0., VIn=None, double margin=1.e-9):
    values[6] = ((PyObject *)Py_None);
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  8: values[7] = PyTuple_GET_ITEM(__pyx_args, 7);
        case  7: values[6] = PyTuple_GET_ITEM(__pyx_args, 6);
        case  6: values[5] = PyTuple_GET_ITEM(__pyx_args, 5);
        case  5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_XMinMax)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        case  1:
        if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_dL)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_Ves_Smesh_Lin_SubFromInd_cython", 0, 5, 8, 1); __PYX_ERR(0, 581, __pyx_L3_error)
        }
        case  2:
        if (likely((values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_dX)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_Ves_Smesh_Lin_SubFromInd_cython", 0, 5, 8, 2); __PYX_ERR(0, 581, __pyx_L3_error)
        }
        case  3:
        if (likely((values[3] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_VPoly)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_Ves_Smesh_Lin_SubFromInd_cython", 0, 5, 8, 3); __PYX_ERR(0, 581, __pyx_L3_error)
        }
        case  4:
        if (likely((values[4] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_ind)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_Ves_Smesh_Lin_SubFromInd_cython", 0, 5, 8, 4); __PYX_ERR(0, 581, __pyx_L3_error)
        }
        case  5:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_DIn);
          if (value) { values[5] = value; kw_args--; }
        }
        case  6:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_VIn);
          if (value) { values[6] = value; kw_args--; }
        }
        case  7:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_margin);
          if (value) { values[7] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "_Ves_Smesh_Lin_SubFromInd_cython") < 0)) __PYX_ERR(0, 581, __pyx_L3_error)
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  8: values[7] = PyTuple_GET_ITEM(__pyx_args, 7);
        case  7: values[6] = PyTuple_GET_ITEM(__pyx_args, 6);
        case  6: values[5] = PyTuple_GET_ITEM(__pyx_args, 5);
        case  5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
        values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    __pyx_v_XMinMax = __Pyx_PyObject_to_MemoryviewSlice_dc_double(values[0]); if (unlikely(!__pyx_v_XMinMax.memview)) __PYX_ERR(0, 581, __pyx_L3_error)
    __pyx_v_dL = __pyx_PyFloat_AsDouble(values[1]); if (unlikely((__pyx_v_dL == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 581, __pyx_L3_error)
    __pyx_v_dX = __pyx_PyFloat_AsDouble(values[2]); if (unlikely((__pyx_v_dX == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 581, __pyx_L3_error)
    __pyx_v_VPoly = __Pyx_PyObject_to_MemoryviewSlice_d_dc_double(values[3]); if (unlikely(!__pyx_v_VPoly.memview)) __PYX_ERR(0, 582, __pyx_L3_error)
    __pyx_v_ind = ((PyArrayObject *)values[4]);
    if (values[5]) {
      __pyx_v_DIn = __pyx_PyFloat_AsDouble(values[5]); if (unlikely((__pyx_v_DIn == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 583, __pyx_L3_error)
    } else {
      __pyx_v_DIn = ((double)0.);
    }
    __pyx_v_VIn = values[6];
    if (values[7]) {
      __pyx_v_margin = __pyx_PyFloat_AsDouble(values[7]); if (unlikely((__pyx_v_margin == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 583, __pyx_L3_error)
    } else {
      __pyx_v_margin = ((double)1.e-9);
    }
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("_Ves_Smesh_Lin_SubFromInd_cython", 0, 5, 8, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 581, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("_cython_magic_8152fc40fb05daa7217c00b66474f995._Ves_Smesh_Lin_SubFromInd_cython", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_ind), __pyx_ptype_5numpy_ndarray, 1, "ind", 0))) __PYX_ERR(0, 582, __pyx_L1_error)
  __pyx_r = __pyx_pf_46_cython_magic_8152fc40fb05daa7217c00b66474f995_14_Ves_Smesh_Lin_SubFromInd_cython(__pyx_self, __pyx_v_XMinMax, __pyx_v_dL, __pyx_v_dX, __pyx_v_VPoly, __pyx_v_ind, __pyx_v_DIn, __pyx_v_VIn, __pyx_v_margin);
 584:     " Return the desired surfacic submesh indicated by ind, for the desired resolution (dX,dL) "
 585:     cdef double dXr, dY0r, dZ0r
 586:     cdef int NX, NY0, NZ0, Ln, NR0, nii
 587:     cdef list LPts, LdS
 588:     cdef cnp.ndarray[double,ndim=2] Pts, PtsCross, VPbis
 589:     cdef cnp.ndarray[double,ndim=1] X, Y0, Z0, dS, dLr, Rref
 590:     cdef cnp.ndarray[long,ndim=1] indX, indY0, indZ0, indL, NL, ii
 591: 
 592:     # Get the mesh for the faces
+593:     Y0, dY0r, bla, NY0 = _Ves_mesh_dlfromL_cython(np.array([np.min(VPoly[0,:]),np.max(VPoly[0,:])]), dL, DL=None, margin=margin)
  __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_Ves_mesh_dlfromL_cython); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 593, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 593, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_array); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 593, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_5 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 593, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_n_s_min); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 593, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __pyx_t_7.data = __pyx_v_VPoly.data;
  __pyx_t_7.memview = __pyx_v_VPoly.memview;
  __PYX_INC_MEMVIEW(&__pyx_t_7, 0);
  {
    Py_ssize_t __pyx_tmp_idx = 0;
    Py_ssize_t __pyx_tmp_shape = __pyx_v_VPoly.shape[0];
    Py_ssize_t __pyx_tmp_stride = __pyx_v_VPoly.strides[0];
    if (0 && (__pyx_tmp_idx < 0))
        __pyx_tmp_idx += __pyx_tmp_shape;
    if (0 && (__pyx_tmp_idx < 0 || __pyx_tmp_idx >= __pyx_tmp_shape)) {
        PyErr_SetString(PyExc_IndexError, "Index out of bounds (axis 0)");
        __PYX_ERR(0, 593, __pyx_L1_error)
    }
        __pyx_t_7.data += __pyx_tmp_idx * __pyx_tmp_stride;
}

__pyx_t_7.shape[0] = __pyx_v_VPoly.shape[1];
__pyx_t_7.strides[0] = __pyx_v_VPoly.strides[1];
    __pyx_t_7.suboffsets[0] = -1;

__pyx_t_5 = __pyx_memoryview_fromslice(__pyx_t_7, 1, (PyObject *(*)(char *)) __pyx_memview_get_double, (int (*)(char *, PyObject *)) __pyx_memview_set_double, 0);; if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 593, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __PYX_XDEC_MEMVIEW(&__pyx_t_7, 1);
  __pyx_t_7.memview = NULL;
  __pyx_t_7.data = NULL;
  __pyx_t_8 = NULL;
  if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_6))) {
    __pyx_t_8 = PyMethod_GET_SELF(__pyx_t_6);
    if (likely(__pyx_t_8)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6);
      __Pyx_INCREF(__pyx_t_8);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_6, function);
    }
  }
  if (!__pyx_t_8) {
    __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_t_6, __pyx_t_5); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 593, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_GOTREF(__pyx_t_3);
  } else {
    #if CYTHON_FAST_PYCALL
    if (PyFunction_Check(__pyx_t_6)) {
      PyObject *__pyx_temp[2] = {__pyx_t_8, __pyx_t_5};
      __pyx_t_3 = __Pyx_PyFunction_FastCall(__pyx_t_6, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 593, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    } else
    #endif
    #if CYTHON_FAST_PYCCALL
    if (__Pyx_PyFastCFunction_Check(__pyx_t_6)) {
      PyObject *__pyx_temp[2] = {__pyx_t_8, __pyx_t_5};
      __pyx_t_3 = __Pyx_PyCFunction_FastCall(__pyx_t_6, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 593, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    } else
    #endif
    {
      __pyx_t_9 = PyTuple_New(1+1); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 593, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_9);
      __Pyx_GIVEREF(__pyx_t_8); PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_t_8); __pyx_t_8 = NULL;
      __Pyx_GIVEREF(__pyx_t_5);
      PyTuple_SET_ITEM(__pyx_t_9, 0+1, __pyx_t_5);
      __pyx_t_5 = 0;
      __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_6, __pyx_t_9, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 593, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
    }
  }
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  __pyx_t_9 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 593, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_9);
  __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_9, __pyx_n_s_max); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 593, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
  __pyx_t_7.data = __pyx_v_VPoly.data;
  __pyx_t_7.memview = __pyx_v_VPoly.memview;
  __PYX_INC_MEMVIEW(&__pyx_t_7, 0);
  {
    Py_ssize_t __pyx_tmp_idx = 0;
    Py_ssize_t __pyx_tmp_shape = __pyx_v_VPoly.shape[0];
    Py_ssize_t __pyx_tmp_stride = __pyx_v_VPoly.strides[0];
    if (0 && (__pyx_tmp_idx < 0))
        __pyx_tmp_idx += __pyx_tmp_shape;
    if (0 && (__pyx_tmp_idx < 0 || __pyx_tmp_idx >= __pyx_tmp_shape)) {
        PyErr_SetString(PyExc_IndexError, "Index out of bounds (axis 0)");
        __PYX_ERR(0, 593, __pyx_L1_error)
    }
        __pyx_t_7.data += __pyx_tmp_idx * __pyx_tmp_stride;
}

__pyx_t_7.shape[0] = __pyx_v_VPoly.shape[1];
__pyx_t_7.strides[0] = __pyx_v_VPoly.strides[1];
    __pyx_t_7.suboffsets[0] = -1;

__pyx_t_9 = __pyx_memoryview_fromslice(__pyx_t_7, 1, (PyObject *(*)(char *)) __pyx_memview_get_double, (int (*)(char *, PyObject *)) __pyx_memview_set_double, 0);; if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 593, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_9);
  __PYX_XDEC_MEMVIEW(&__pyx_t_7, 1);
  __pyx_t_7.memview = NULL;
  __pyx_t_7.data = NULL;
  __pyx_t_8 = NULL;
  if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_5))) {
    __pyx_t_8 = PyMethod_GET_SELF(__pyx_t_5);
    if (likely(__pyx_t_8)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5);
      __Pyx_INCREF(__pyx_t_8);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_5, function);
    }
  }
  if (!__pyx_t_8) {
    __pyx_t_6 = __Pyx_PyObject_CallOneArg(__pyx_t_5, __pyx_t_9); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 593, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
    __Pyx_GOTREF(__pyx_t_6);
  } else {
    #if CYTHON_FAST_PYCALL
    if (PyFunction_Check(__pyx_t_5)) {
      PyObject *__pyx_temp[2] = {__pyx_t_8, __pyx_t_9};
      __pyx_t_6 = __Pyx_PyFunction_FastCall(__pyx_t_5, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 593, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
      __Pyx_GOTREF(__pyx_t_6);
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
    } else
    #endif
    #if CYTHON_FAST_PYCCALL
    if (__Pyx_PyFastCFunction_Check(__pyx_t_5)) {
      PyObject *__pyx_temp[2] = {__pyx_t_8, __pyx_t_9};
      __pyx_t_6 = __Pyx_PyCFunction_FastCall(__pyx_t_5, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 593, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
      __Pyx_GOTREF(__pyx_t_6);
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
    } else
    #endif
    {
      __pyx_t_10 = PyTuple_New(1+1); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 593, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_10);
      __Pyx_GIVEREF(__pyx_t_8); PyTuple_SET_ITEM(__pyx_t_10, 0, __pyx_t_8); __pyx_t_8 = NULL;
      __Pyx_GIVEREF(__pyx_t_9);
      PyTuple_SET_ITEM(__pyx_t_10, 0+1, __pyx_t_9);
      __pyx_t_9 = 0;
      __pyx_t_6 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_t_10, NULL); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 593, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_6);
      __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
    }
  }
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __pyx_t_5 = PyList_New(2); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 593, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_GIVEREF(__pyx_t_3);
  PyList_SET_ITEM(__pyx_t_5, 0, __pyx_t_3);
  __Pyx_GIVEREF(__pyx_t_6);
  PyList_SET_ITEM(__pyx_t_5, 1, __pyx_t_6);
  __pyx_t_3 = 0;
  __pyx_t_6 = 0;
  __pyx_t_6 = NULL;
  if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_4))) {
    __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_4);
    if (likely(__pyx_t_6)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
      __Pyx_INCREF(__pyx_t_6);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_4, function);
    }
  }
  if (!__pyx_t_6) {
    __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_5); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 593, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_GOTREF(__pyx_t_2);
  } else {
    #if CYTHON_FAST_PYCALL
    if (PyFunction_Check(__pyx_t_4)) {
      PyObject *__pyx_temp[2] = {__pyx_t_6, __pyx_t_5};
      __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_4, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 593, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    } else
    #endif
    #if CYTHON_FAST_PYCCALL
    if (__Pyx_PyFastCFunction_Check(__pyx_t_4)) {
      PyObject *__pyx_temp[2] = {__pyx_t_6, __pyx_t_5};
      __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_4, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 593, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    } else
    #endif
    {
      __pyx_t_3 = PyTuple_New(1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 593, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_6); __pyx_t_6 = NULL;
      __Pyx_GIVEREF(__pyx_t_5);
      PyTuple_SET_ITEM(__pyx_t_3, 0+1, __pyx_t_5);
      __pyx_t_5 = 0;
      __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_3, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 593, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    }
  }
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_4 = PyFloat_FromDouble(__pyx_v_dL); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 593, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 593, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_GIVEREF(__pyx_t_2);
  PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_2);
  __Pyx_GIVEREF(__pyx_t_4);
  PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_t_4);
  __pyx_t_2 = 0;
  __pyx_t_4 = 0;
  __pyx_t_4 = PyDict_New(); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 593, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  if (PyDict_SetItem(__pyx_t_4, __pyx_n_s_DL, Py_None) < 0) __PYX_ERR(0, 593, __pyx_L1_error)
  __pyx_t_2 = PyFloat_FromDouble(__pyx_v_margin); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 593, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_t_4, __pyx_n_s_margin, __pyx_t_2) < 0) __PYX_ERR(0, 593, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_3, __pyx_t_4); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 593, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  if ((likely(PyTuple_CheckExact(__pyx_t_2))) || (PyList_CheckExact(__pyx_t_2))) {
    PyObject* sequence = __pyx_t_2;
    #if !CYTHON_COMPILING_IN_PYPY
    Py_ssize_t size = Py_SIZE(sequence);
    #else
    Py_ssize_t size = PySequence_Size(sequence);
    #endif
    if (unlikely(size != 4)) {
      if (size > 4) __Pyx_RaiseTooManyValuesError(4);
      else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
      __PYX_ERR(0, 593, __pyx_L1_error)
    }
    #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
    if (likely(PyTuple_CheckExact(sequence))) {
      __pyx_t_4 = PyTuple_GET_ITEM(sequence, 0); 
      __pyx_t_3 = PyTuple_GET_ITEM(sequence, 1); 
      __pyx_t_1 = PyTuple_GET_ITEM(sequence, 2); 
      __pyx_t_5 = PyTuple_GET_ITEM(sequence, 3); 
    } else {
      __pyx_t_4 = PyList_GET_ITEM(sequence, 0); 
      __pyx_t_3 = PyList_GET_ITEM(sequence, 1); 
      __pyx_t_1 = PyList_GET_ITEM(sequence, 2); 
      __pyx_t_5 = PyList_GET_ITEM(sequence, 3); 
    }
    __Pyx_INCREF(__pyx_t_4);
    __Pyx_INCREF(__pyx_t_3);
    __Pyx_INCREF(__pyx_t_1);
    __Pyx_INCREF(__pyx_t_5);
    #else
    {
      Py_ssize_t i;
      PyObject** temps[4] = {&__pyx_t_4,&__pyx_t_3,&__pyx_t_1,&__pyx_t_5};
      for (i=0; i < 4; i++) {
        PyObject* item = PySequence_ITEM(sequence, i); if (unlikely(!item)) __PYX_ERR(0, 593, __pyx_L1_error)
        __Pyx_GOTREF(item);
        *(temps[i]) = item;
      }
    }
    #endif
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  } else {
    Py_ssize_t index = -1;
    PyObject** temps[4] = {&__pyx_t_4,&__pyx_t_3,&__pyx_t_1,&__pyx_t_5};
    __pyx_t_6 = PyObject_GetIter(__pyx_t_2); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 593, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_t_11 = Py_TYPE(__pyx_t_6)->tp_iternext;
    for (index=0; index < 4; index++) {
      PyObject* item = __pyx_t_11(__pyx_t_6); if (unlikely(!item)) goto __pyx_L3_unpacking_failed;
      __Pyx_GOTREF(item);
      *(temps[index]) = item;
    }
    if (__Pyx_IternextUnpackEndCheck(__pyx_t_11(__pyx_t_6), 4) < 0) __PYX_ERR(0, 593, __pyx_L1_error)
    __pyx_t_11 = NULL;
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    goto __pyx_L4_unpacking_done;
    __pyx_L3_unpacking_failed:;
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __pyx_t_11 = NULL;
    if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
    __PYX_ERR(0, 593, __pyx_L1_error)
    __pyx_L4_unpacking_done:;
  }
  if (!(likely(((__pyx_t_4) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_4, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 593, __pyx_L1_error)
  __pyx_t_12 = __pyx_PyFloat_AsDouble(__pyx_t_3); if (unlikely((__pyx_t_12 == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 593, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_13 = __Pyx_PyInt_As_int(__pyx_t_5); if (unlikely((__pyx_t_13 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 593, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __pyx_t_14 = ((PyArrayObject *)__pyx_t_4);
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_Y0.rcbuffer->pybuffer);
    __pyx_t_15 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_Y0.rcbuffer->pybuffer, (PyObject*)__pyx_t_14, &__Pyx_TypeInfo_double, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack);
    if (unlikely(__pyx_t_15 < 0)) {
      PyErr_Fetch(&__pyx_t_16, &__pyx_t_17, &__pyx_t_18);
      if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_Y0.rcbuffer->pybuffer, (PyObject*)__pyx_v_Y0, &__Pyx_TypeInfo_double, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {
        Py_XDECREF(__pyx_t_16); Py_XDECREF(__pyx_t_17); Py_XDECREF(__pyx_t_18);
        __Pyx_RaiseBufferFallbackError();
      } else {
        PyErr_Restore(__pyx_t_16, __pyx_t_17, __pyx_t_18);
      }
    }
    __pyx_pybuffernd_Y0.diminfo[0].strides = __pyx_pybuffernd_Y0.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_Y0.diminfo[0].shape = __pyx_pybuffernd_Y0.rcbuffer->pybuffer.shape[0];
    if (unlikely(__pyx_t_15 < 0)) __PYX_ERR(0, 593, __pyx_L1_error)
  }
  __pyx_t_14 = 0;
  __pyx_v_Y0 = ((PyArrayObject *)__pyx_t_4);
  __pyx_t_4 = 0;
  __pyx_v_dY0r = __pyx_t_12;
  __pyx_v_bla = __pyx_t_1;
  __pyx_t_1 = 0;
  __pyx_v_NY0 = __pyx_t_13;
+594:     Z0, dZ0r, bla, NZ0 = _Ves_mesh_dlfromL_cython(np.array([np.min(VPoly[1,:]),np.max(VPoly[1,:])]), dL, DL=None, margin=margin)
  __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_Ves_mesh_dlfromL_cython); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 594, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 594, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_array); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 594, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 594, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_min); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 594, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_7.data = __pyx_v_VPoly.data;
  __pyx_t_7.memview = __pyx_v_VPoly.memview;
  __PYX_INC_MEMVIEW(&__pyx_t_7, 0);
  {
    Py_ssize_t __pyx_tmp_idx = 1;
    Py_ssize_t __pyx_tmp_shape = __pyx_v_VPoly.shape[0];
    Py_ssize_t __pyx_tmp_stride = __pyx_v_VPoly.strides[0];
    if (0 && (__pyx_tmp_idx < 0))
        __pyx_tmp_idx += __pyx_tmp_shape;
    if (0 && (__pyx_tmp_idx < 0 || __pyx_tmp_idx >= __pyx_tmp_shape)) {
        PyErr_SetString(PyExc_IndexError, "Index out of bounds (axis 0)");
        __PYX_ERR(0, 594, __pyx_L1_error)
    }
        __pyx_t_7.data += __pyx_tmp_idx * __pyx_tmp_stride;
}

__pyx_t_7.shape[0] = __pyx_v_VPoly.shape[1];
__pyx_t_7.strides[0] = __pyx_v_VPoly.strides[1];
    __pyx_t_7.suboffsets[0] = -1;

__pyx_t_4 = __pyx_memoryview_fromslice(__pyx_t_7, 1, (PyObject *(*)(char *)) __pyx_memview_get_double, (int (*)(char *, PyObject *)) __pyx_memview_set_double, 0);; if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 594, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __PYX_XDEC_MEMVIEW(&__pyx_t_7, 1);
  __pyx_t_7.memview = NULL;
  __pyx_t_7.data = NULL;
  __pyx_t_10 = NULL;
  if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_6))) {
    __pyx_t_10 = PyMethod_GET_SELF(__pyx_t_6);
    if (likely(__pyx_t_10)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6);
      __Pyx_INCREF(__pyx_t_10);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_6, function);
    }
  }
  if (!__pyx_t_10) {
    __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_6, __pyx_t_4); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 594, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_GOTREF(__pyx_t_1);
  } else {
    #if CYTHON_FAST_PYCALL
    if (PyFunction_Check(__pyx_t_6)) {
      PyObject *__pyx_temp[2] = {__pyx_t_10, __pyx_t_4};
      __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_6, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 594, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    } else
    #endif
    #if CYTHON_FAST_PYCCALL
    if (__Pyx_PyFastCFunction_Check(__pyx_t_6)) {
      PyObject *__pyx_temp[2] = {__pyx_t_10, __pyx_t_4};
      __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_6, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 594, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    } else
    #endif
    {
      __pyx_t_9 = PyTuple_New(1+1); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 594, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_9);
      __Pyx_GIVEREF(__pyx_t_10); PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_t_10); __pyx_t_10 = NULL;
      __Pyx_GIVEREF(__pyx_t_4);
      PyTuple_SET_ITEM(__pyx_t_9, 0+1, __pyx_t_4);
      __pyx_t_4 = 0;
      __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_6, __pyx_t_9, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 594, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
    }
  }
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  __pyx_t_9 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 594, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_9);
  __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_9, __pyx_n_s_max); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 594, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
  __pyx_t_7.data = __pyx_v_VPoly.data;
  __pyx_t_7.memview = __pyx_v_VPoly.memview;
  __PYX_INC_MEMVIEW(&__pyx_t_7, 0);
  {
    Py_ssize_t __pyx_tmp_idx = 1;
    Py_ssize_t __pyx_tmp_shape = __pyx_v_VPoly.shape[0];
    Py_ssize_t __pyx_tmp_stride = __pyx_v_VPoly.strides[0];
    if (0 && (__pyx_tmp_idx < 0))
        __pyx_tmp_idx += __pyx_tmp_shape;
    if (0 && (__pyx_tmp_idx < 0 || __pyx_tmp_idx >= __pyx_tmp_shape)) {
        PyErr_SetString(PyExc_IndexError, "Index out of bounds (axis 0)");
        __PYX_ERR(0, 594, __pyx_L1_error)
    }
        __pyx_t_7.data += __pyx_tmp_idx * __pyx_tmp_stride;
}

__pyx_t_7.shape[0] = __pyx_v_VPoly.shape[1];
__pyx_t_7.strides[0] = __pyx_v_VPoly.strides[1];
    __pyx_t_7.suboffsets[0] = -1;

__pyx_t_9 = __pyx_memoryview_fromslice(__pyx_t_7, 1, (PyObject *(*)(char *)) __pyx_memview_get_double, (int (*)(char *, PyObject *)) __pyx_memview_set_double, 0);; if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 594, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_9);
  __PYX_XDEC_MEMVIEW(&__pyx_t_7, 1);
  __pyx_t_7.memview = NULL;
  __pyx_t_7.data = NULL;
  __pyx_t_10 = NULL;
  if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_4))) {
    __pyx_t_10 = PyMethod_GET_SELF(__pyx_t_4);
    if (likely(__pyx_t_10)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
      __Pyx_INCREF(__pyx_t_10);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_4, function);
    }
  }
  if (!__pyx_t_10) {
    __pyx_t_6 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_9); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 594, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
    __Pyx_GOTREF(__pyx_t_6);
  } else {
    #if CYTHON_FAST_PYCALL
    if (PyFunction_Check(__pyx_t_4)) {
      PyObject *__pyx_temp[2] = {__pyx_t_10, __pyx_t_9};
      __pyx_t_6 = __Pyx_PyFunction_FastCall(__pyx_t_4, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 594, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
      __Pyx_GOTREF(__pyx_t_6);
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
    } else
    #endif
    #if CYTHON_FAST_PYCCALL
    if (__Pyx_PyFastCFunction_Check(__pyx_t_4)) {
      PyObject *__pyx_temp[2] = {__pyx_t_10, __pyx_t_9};
      __pyx_t_6 = __Pyx_PyCFunction_FastCall(__pyx_t_4, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 594, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
      __Pyx_GOTREF(__pyx_t_6);
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
    } else
    #endif
    {
      __pyx_t_8 = PyTuple_New(1+1); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 594, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_8);
      __Pyx_GIVEREF(__pyx_t_10); PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_10); __pyx_t_10 = NULL;
      __Pyx_GIVEREF(__pyx_t_9);
      PyTuple_SET_ITEM(__pyx_t_8, 0+1, __pyx_t_9);
      __pyx_t_9 = 0;
      __pyx_t_6 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_8, NULL); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 594, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_6);
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    }
  }
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_4 = PyList_New(2); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 594, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_GIVEREF(__pyx_t_1);
  PyList_SET_ITEM(__pyx_t_4, 0, __pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_6);
  PyList_SET_ITEM(__pyx_t_4, 1, __pyx_t_6);
  __pyx_t_1 = 0;
  __pyx_t_6 = 0;
  __pyx_t_6 = NULL;
  if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) {
    __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_3);
    if (likely(__pyx_t_6)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
      __Pyx_INCREF(__pyx_t_6);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_3, function);
    }
  }
  if (!__pyx_t_6) {
    __pyx_t_5 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_4); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 594, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_GOTREF(__pyx_t_5);
  } else {
    #if CYTHON_FAST_PYCALL
    if (PyFunction_Check(__pyx_t_3)) {
      PyObject *__pyx_temp[2] = {__pyx_t_6, __pyx_t_4};
      __pyx_t_5 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 594, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    } else
    #endif
    #if CYTHON_FAST_PYCCALL
    if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) {
      PyObject *__pyx_temp[2] = {__pyx_t_6, __pyx_t_4};
      __pyx_t_5 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 594, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    } else
    #endif
    {
      __pyx_t_1 = PyTuple_New(1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 594, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_6); __pyx_t_6 = NULL;
      __Pyx_GIVEREF(__pyx_t_4);
      PyTuple_SET_ITEM(__pyx_t_1, 0+1, __pyx_t_4);
      __pyx_t_4 = 0;
      __pyx_t_5 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_1, NULL); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 594, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    }
  }
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_3 = PyFloat_FromDouble(__pyx_v_dL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 594, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 594, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_5);
  PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_5);
  __Pyx_GIVEREF(__pyx_t_3);
  PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_t_3);
  __pyx_t_5 = 0;
  __pyx_t_3 = 0;
  __pyx_t_3 = PyDict_New(); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 594, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_DL, Py_None) < 0) __PYX_ERR(0, 594, __pyx_L1_error)
  __pyx_t_5 = PyFloat_FromDouble(__pyx_v_margin); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 594, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_margin, __pyx_t_5) < 0) __PYX_ERR(0, 594, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __pyx_t_5 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_1, __pyx_t_3); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 594, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  if ((likely(PyTuple_CheckExact(__pyx_t_5))) || (PyList_CheckExact(__pyx_t_5))) {
    PyObject* sequence = __pyx_t_5;
    #if !CYTHON_COMPILING_IN_PYPY
    Py_ssize_t size = Py_SIZE(sequence);
    #else
    Py_ssize_t size = PySequence_Size(sequence);
    #endif
    if (unlikely(size != 4)) {
      if (size > 4) __Pyx_RaiseTooManyValuesError(4);
      else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
      __PYX_ERR(0, 594, __pyx_L1_error)
    }
    #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
    if (likely(PyTuple_CheckExact(sequence))) {
      __pyx_t_3 = PyTuple_GET_ITEM(sequence, 0); 
      __pyx_t_1 = PyTuple_GET_ITEM(sequence, 1); 
      __pyx_t_2 = PyTuple_GET_ITEM(sequence, 2); 
      __pyx_t_4 = PyTuple_GET_ITEM(sequence, 3); 
    } else {
      __pyx_t_3 = PyList_GET_ITEM(sequence, 0); 
      __pyx_t_1 = PyList_GET_ITEM(sequence, 1); 
      __pyx_t_2 = PyList_GET_ITEM(sequence, 2); 
      __pyx_t_4 = PyList_GET_ITEM(sequence, 3); 
    }
    __Pyx_INCREF(__pyx_t_3);
    __Pyx_INCREF(__pyx_t_1);
    __Pyx_INCREF(__pyx_t_2);
    __Pyx_INCREF(__pyx_t_4);
    #else
    {
      Py_ssize_t i;
      PyObject** temps[4] = {&__pyx_t_3,&__pyx_t_1,&__pyx_t_2,&__pyx_t_4};
      for (i=0; i < 4; i++) {
        PyObject* item = PySequence_ITEM(sequence, i); if (unlikely(!item)) __PYX_ERR(0, 594, __pyx_L1_error)
        __Pyx_GOTREF(item);
        *(temps[i]) = item;
      }
    }
    #endif
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  } else {
    Py_ssize_t index = -1;
    PyObject** temps[4] = {&__pyx_t_3,&__pyx_t_1,&__pyx_t_2,&__pyx_t_4};
    __pyx_t_6 = PyObject_GetIter(__pyx_t_5); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 594, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __pyx_t_11 = Py_TYPE(__pyx_t_6)->tp_iternext;
    for (index=0; index < 4; index++) {
      PyObject* item = __pyx_t_11(__pyx_t_6); if (unlikely(!item)) goto __pyx_L5_unpacking_failed;
      __Pyx_GOTREF(item);
      *(temps[index]) = item;
    }
    if (__Pyx_IternextUnpackEndCheck(__pyx_t_11(__pyx_t_6), 4) < 0) __PYX_ERR(0, 594, __pyx_L1_error)
    __pyx_t_11 = NULL;
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    goto __pyx_L6_unpacking_done;
    __pyx_L5_unpacking_failed:;
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __pyx_t_11 = NULL;
    if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
    __PYX_ERR(0, 594, __pyx_L1_error)
    __pyx_L6_unpacking_done:;
  }
  if (!(likely(((__pyx_t_3) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_3, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 594, __pyx_L1_error)
  __pyx_t_12 = __pyx_PyFloat_AsDouble(__pyx_t_1); if (unlikely((__pyx_t_12 == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 594, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_13 = __Pyx_PyInt_As_int(__pyx_t_4); if (unlikely((__pyx_t_13 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 594, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_14 = ((PyArrayObject *)__pyx_t_3);
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_Z0.rcbuffer->pybuffer);
    __pyx_t_15 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_Z0.rcbuffer->pybuffer, (PyObject*)__pyx_t_14, &__Pyx_TypeInfo_double, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack);
    if (unlikely(__pyx_t_15 < 0)) {
      PyErr_Fetch(&__pyx_t_18, &__pyx_t_17, &__pyx_t_16);
      if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_Z0.rcbuffer->pybuffer, (PyObject*)__pyx_v_Z0, &__Pyx_TypeInfo_double, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {
        Py_XDECREF(__pyx_t_18); Py_XDECREF(__pyx_t_17); Py_XDECREF(__pyx_t_16);
        __Pyx_RaiseBufferFallbackError();
      } else {
        PyErr_Restore(__pyx_t_18, __pyx_t_17, __pyx_t_16);
      }
    }
    __pyx_pybuffernd_Z0.diminfo[0].strides = __pyx_pybuffernd_Z0.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_Z0.diminfo[0].shape = __pyx_pybuffernd_Z0.rcbuffer->pybuffer.shape[0];
    if (unlikely(__pyx_t_15 < 0)) __PYX_ERR(0, 594, __pyx_L1_error)
  }
  __pyx_t_14 = 0;
  __pyx_v_Z0 = ((PyArrayObject *)__pyx_t_3);
  __pyx_t_3 = 0;
  __pyx_v_dZ0r = __pyx_t_12;
  __Pyx_DECREF_SET(__pyx_v_bla, __pyx_t_2);
  __pyx_t_2 = 0;
  __pyx_v_NZ0 = __pyx_t_13;
 595: 
 596:     # Get the actual R and Z resolutions and mesh elements
+597:     X, dXr, bla, NX = _Ves_mesh_dlfromL_cython(XMinMax, dX, DL=None, margin=margin)
  __pyx_t_5 = __Pyx_GetModuleGlobalName(__pyx_n_s_Ves_mesh_dlfromL_cython); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 597, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_t_4 = __pyx_memoryview_fromslice(__pyx_v_XMinMax, 1, (PyObject *(*)(char *)) __pyx_memview_get_double, (int (*)(char *, PyObject *)) __pyx_memview_set_double, 0);; if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 597, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_2 = PyFloat_FromDouble(__pyx_v_dX); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 597, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 597, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_4);
  PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_4);
  __Pyx_GIVEREF(__pyx_t_2);
  PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_t_2);
  __pyx_t_4 = 0;
  __pyx_t_2 = 0;
  __pyx_t_2 = PyDict_New(); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 597, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_DL, Py_None) < 0) __PYX_ERR(0, 597, __pyx_L1_error)
  __pyx_t_4 = PyFloat_FromDouble(__pyx_v_margin); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 597, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_margin, __pyx_t_4) < 0) __PYX_ERR(0, 597, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_t_1, __pyx_t_2); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 597, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  if ((likely(PyTuple_CheckExact(__pyx_t_4))) || (PyList_CheckExact(__pyx_t_4))) {
    PyObject* sequence = __pyx_t_4;
    #if !CYTHON_COMPILING_IN_PYPY
    Py_ssize_t size = Py_SIZE(sequence);
    #else
    Py_ssize_t size = PySequence_Size(sequence);
    #endif
    if (unlikely(size != 4)) {
      if (size > 4) __Pyx_RaiseTooManyValuesError(4);
      else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
      __PYX_ERR(0, 597, __pyx_L1_error)
    }
    #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
    if (likely(PyTuple_CheckExact(sequence))) {
      __pyx_t_2 = PyTuple_GET_ITEM(sequence, 0); 
      __pyx_t_1 = PyTuple_GET_ITEM(sequence, 1); 
      __pyx_t_5 = PyTuple_GET_ITEM(sequence, 2); 
      __pyx_t_3 = PyTuple_GET_ITEM(sequence, 3); 
    } else {
      __pyx_t_2 = PyList_GET_ITEM(sequence, 0); 
      __pyx_t_1 = PyList_GET_ITEM(sequence, 1); 
      __pyx_t_5 = PyList_GET_ITEM(sequence, 2); 
      __pyx_t_3 = PyList_GET_ITEM(sequence, 3); 
    }
    __Pyx_INCREF(__pyx_t_2);
    __Pyx_INCREF(__pyx_t_1);
    __Pyx_INCREF(__pyx_t_5);
    __Pyx_INCREF(__pyx_t_3);
    #else
    {
      Py_ssize_t i;
      PyObject** temps[4] = {&__pyx_t_2,&__pyx_t_1,&__pyx_t_5,&__pyx_t_3};
      for (i=0; i < 4; i++) {
        PyObject* item = PySequence_ITEM(sequence, i); if (unlikely(!item)) __PYX_ERR(0, 597, __pyx_L1_error)
        __Pyx_GOTREF(item);
        *(temps[i]) = item;
      }
    }
    #endif
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  } else {
    Py_ssize_t index = -1;
    PyObject** temps[4] = {&__pyx_t_2,&__pyx_t_1,&__pyx_t_5,&__pyx_t_3};
    __pyx_t_6 = PyObject_GetIter(__pyx_t_4); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 597, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_t_11 = Py_TYPE(__pyx_t_6)->tp_iternext;
    for (index=0; index < 4; index++) {
      PyObject* item = __pyx_t_11(__pyx_t_6); if (unlikely(!item)) goto __pyx_L7_unpacking_failed;
      __Pyx_GOTREF(item);
      *(temps[index]) = item;
    }
    if (__Pyx_IternextUnpackEndCheck(__pyx_t_11(__pyx_t_6), 4) < 0) __PYX_ERR(0, 597, __pyx_L1_error)
    __pyx_t_11 = NULL;
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    goto __pyx_L8_unpacking_done;
    __pyx_L7_unpacking_failed:;
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __pyx_t_11 = NULL;
    if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
    __PYX_ERR(0, 597, __pyx_L1_error)
    __pyx_L8_unpacking_done:;
  }
  if (!(likely(((__pyx_t_2) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_2, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 597, __pyx_L1_error)
  __pyx_t_12 = __pyx_PyFloat_AsDouble(__pyx_t_1); if (unlikely((__pyx_t_12 == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 597, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_13 = __Pyx_PyInt_As_int(__pyx_t_3); if (unlikely((__pyx_t_13 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 597, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_14 = ((PyArrayObject *)__pyx_t_2);
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_X.rcbuffer->pybuffer);
    __pyx_t_15 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_X.rcbuffer->pybuffer, (PyObject*)__pyx_t_14, &__Pyx_TypeInfo_double, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack);
    if (unlikely(__pyx_t_15 < 0)) {
      PyErr_Fetch(&__pyx_t_16, &__pyx_t_17, &__pyx_t_18);
      if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_X.rcbuffer->pybuffer, (PyObject*)__pyx_v_X, &__Pyx_TypeInfo_double, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {
        Py_XDECREF(__pyx_t_16); Py_XDECREF(__pyx_t_17); Py_XDECREF(__pyx_t_18);
        __Pyx_RaiseBufferFallbackError();
      } else {
        PyErr_Restore(__pyx_t_16, __pyx_t_17, __pyx_t_18);
      }
    }
    __pyx_pybuffernd_X.diminfo[0].strides = __pyx_pybuffernd_X.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_X.diminfo[0].shape = __pyx_pybuffernd_X.rcbuffer->pybuffer.shape[0];
    if (unlikely(__pyx_t_15 < 0)) __PYX_ERR(0, 597, __pyx_L1_error)
  }
  __pyx_t_14 = 0;
  __pyx_v_X = ((PyArrayObject *)__pyx_t_2);
  __pyx_t_2 = 0;
  __pyx_v_dXr = __pyx_t_12;
  __Pyx_DECREF_SET(__pyx_v_bla, __pyx_t_5);
  __pyx_t_5 = 0;
  __pyx_v_NX = __pyx_t_13;
+598:     PtsCross, dLr, bla, NL, Rref, VPbis = _Ves_mesh_CrossPoly(VPoly, dL, D1=None, D2=None, margin=margin, DIn=DIn, VIn=VIn)
  __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_Ves_mesh_CrossPoly); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 598, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_3 = __pyx_memoryview_fromslice(__pyx_v_VPoly, 2, (PyObject *(*)(char *)) __pyx_memview_get_double, (int (*)(char *, PyObject *)) __pyx_memview_set_double, 0);; if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 598, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_5 = PyFloat_FromDouble(__pyx_v_dL); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 598, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 598, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_3);
  PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_3);
  __Pyx_GIVEREF(__pyx_t_5);
  PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_t_5);
  __pyx_t_3 = 0;
  __pyx_t_5 = 0;
  __pyx_t_5 = PyDict_New(); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 598, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  if (PyDict_SetItem(__pyx_t_5, __pyx_n_s_D1, Py_None) < 0) __PYX_ERR(0, 598, __pyx_L1_error)
  if (PyDict_SetItem(__pyx_t_5, __pyx_n_s_D2, Py_None) < 0) __PYX_ERR(0, 598, __pyx_L1_error)
  __pyx_t_3 = PyFloat_FromDouble(__pyx_v_margin); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 598, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  if (PyDict_SetItem(__pyx_t_5, __pyx_n_s_margin, __pyx_t_3) < 0) __PYX_ERR(0, 598, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_3 = PyFloat_FromDouble(__pyx_v_DIn); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 598, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  if (PyDict_SetItem(__pyx_t_5, __pyx_n_s_DIn, __pyx_t_3) < 0) __PYX_ERR(0, 598, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  if (PyDict_SetItem(__pyx_t_5, __pyx_n_s_VIn, __pyx_v_VIn) < 0) __PYX_ERR(0, 598, __pyx_L1_error)
  __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_1, __pyx_t_5); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 598, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  if ((likely(PyTuple_CheckExact(__pyx_t_3))) || (PyList_CheckExact(__pyx_t_3))) {
    PyObject* sequence = __pyx_t_3;
    #if !CYTHON_COMPILING_IN_PYPY
    Py_ssize_t size = Py_SIZE(sequence);
    #else
    Py_ssize_t size = PySequence_Size(sequence);
    #endif
    if (unlikely(size != 6)) {
      if (size > 6) __Pyx_RaiseTooManyValuesError(6);
      else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
      __PYX_ERR(0, 598, __pyx_L1_error)
    }
    #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
    if (likely(PyTuple_CheckExact(sequence))) {
      __pyx_t_5 = PyTuple_GET_ITEM(sequence, 0); 
      __pyx_t_1 = PyTuple_GET_ITEM(sequence, 1); 
      __pyx_t_4 = PyTuple_GET_ITEM(sequence, 2); 
      __pyx_t_2 = PyTuple_GET_ITEM(sequence, 3); 
      __pyx_t_6 = PyTuple_GET_ITEM(sequence, 4); 
      __pyx_t_8 = PyTuple_GET_ITEM(sequence, 5); 
    } else {
      __pyx_t_5 = PyList_GET_ITEM(sequence, 0); 
      __pyx_t_1 = PyList_GET_ITEM(sequence, 1); 
      __pyx_t_4 = PyList_GET_ITEM(sequence, 2); 
      __pyx_t_2 = PyList_GET_ITEM(sequence, 3); 
      __pyx_t_6 = PyList_GET_ITEM(sequence, 4); 
      __pyx_t_8 = PyList_GET_ITEM(sequence, 5); 
    }
    __Pyx_INCREF(__pyx_t_5);
    __Pyx_INCREF(__pyx_t_1);
    __Pyx_INCREF(__pyx_t_4);
    __Pyx_INCREF(__pyx_t_2);
    __Pyx_INCREF(__pyx_t_6);
    __Pyx_INCREF(__pyx_t_8);
    #else
    {
      Py_ssize_t i;
      PyObject** temps[6] = {&__pyx_t_5,&__pyx_t_1,&__pyx_t_4,&__pyx_t_2,&__pyx_t_6,&__pyx_t_8};
      for (i=0; i < 6; i++) {
        PyObject* item = PySequence_ITEM(sequence, i); if (unlikely(!item)) __PYX_ERR(0, 598, __pyx_L1_error)
        __Pyx_GOTREF(item);
        *(temps[i]) = item;
      }
    }
    #endif
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  } else {
    Py_ssize_t index = -1;
    PyObject** temps[6] = {&__pyx_t_5,&__pyx_t_1,&__pyx_t_4,&__pyx_t_2,&__pyx_t_6,&__pyx_t_8};
    __pyx_t_9 = PyObject_GetIter(__pyx_t_3); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 598, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_9);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_t_11 = Py_TYPE(__pyx_t_9)->tp_iternext;
    for (index=0; index < 6; index++) {
      PyObject* item = __pyx_t_11(__pyx_t_9); if (unlikely(!item)) goto __pyx_L9_unpacking_failed;
      __Pyx_GOTREF(item);
      *(temps[index]) = item;
    }
    if (__Pyx_IternextUnpackEndCheck(__pyx_t_11(__pyx_t_9), 6) < 0) __PYX_ERR(0, 598, __pyx_L1_error)
    __pyx_t_11 = NULL;
    __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
    goto __pyx_L10_unpacking_done;
    __pyx_L9_unpacking_failed:;
    __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
    __pyx_t_11 = NULL;
    if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
    __PYX_ERR(0, 598, __pyx_L1_error)
    __pyx_L10_unpacking_done:;
  }
  if (!(likely(((__pyx_t_5) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_5, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 598, __pyx_L1_error)
  if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 598, __pyx_L1_error)
  if (!(likely(((__pyx_t_2) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_2, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 598, __pyx_L1_error)
  if (!(likely(((__pyx_t_6) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_6, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 598, __pyx_L1_error)
  if (!(likely(((__pyx_t_8) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_8, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 598, __pyx_L1_error)
  __pyx_t_19 = ((PyArrayObject *)__pyx_t_5);
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_PtsCross.rcbuffer->pybuffer);
    __pyx_t_13 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_PtsCross.rcbuffer->pybuffer, (PyObject*)__pyx_t_19, &__Pyx_TypeInfo_double, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack);
    if (unlikely(__pyx_t_13 < 0)) {
      PyErr_Fetch(&__pyx_t_18, &__pyx_t_17, &__pyx_t_16);
      if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_PtsCross.rcbuffer->pybuffer, (PyObject*)__pyx_v_PtsCross, &__Pyx_TypeInfo_double, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) {
        Py_XDECREF(__pyx_t_18); Py_XDECREF(__pyx_t_17); Py_XDECREF(__pyx_t_16);
        __Pyx_RaiseBufferFallbackError();
      } else {
        PyErr_Restore(__pyx_t_18, __pyx_t_17, __pyx_t_16);
      }
    }
    __pyx_pybuffernd_PtsCross.diminfo[0].strides = __pyx_pybuffernd_PtsCross.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_PtsCross.diminfo[0].shape = __pyx_pybuffernd_PtsCross.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_PtsCross.diminfo[1].strides = __pyx_pybuffernd_PtsCross.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_PtsCross.diminfo[1].shape = __pyx_pybuffernd_PtsCross.rcbuffer->pybuffer.shape[1];
    if (unlikely(__pyx_t_13 < 0)) __PYX_ERR(0, 598, __pyx_L1_error)
  }
  __pyx_t_19 = 0;
  __pyx_v_PtsCross = ((PyArrayObject *)__pyx_t_5);
  __pyx_t_5 = 0;
  __pyx_t_14 = ((PyArrayObject *)__pyx_t_1);
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_dLr.rcbuffer->pybuffer);
    __pyx_t_13 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_dLr.rcbuffer->pybuffer, (PyObject*)__pyx_t_14, &__Pyx_TypeInfo_double, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack);
    if (unlikely(__pyx_t_13 < 0)) {
      PyErr_Fetch(&__pyx_t_16, &__pyx_t_17, &__pyx_t_18);
      if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_dLr.rcbuffer->pybuffer, (PyObject*)__pyx_v_dLr, &__Pyx_TypeInfo_double, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {
        Py_XDECREF(__pyx_t_16); Py_XDECREF(__pyx_t_17); Py_XDECREF(__pyx_t_18);
        __Pyx_RaiseBufferFallbackError();
      } else {
        PyErr_Restore(__pyx_t_16, __pyx_t_17, __pyx_t_18);
      }
    }
    __pyx_pybuffernd_dLr.diminfo[0].strides = __pyx_pybuffernd_dLr.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_dLr.diminfo[0].shape = __pyx_pybuffernd_dLr.rcbuffer->pybuffer.shape[0];
    if (unlikely(__pyx_t_13 < 0)) __PYX_ERR(0, 598, __pyx_L1_error)
  }
  __pyx_t_14 = 0;
  __pyx_v_dLr = ((PyArrayObject *)__pyx_t_1);
  __pyx_t_1 = 0;
  __Pyx_DECREF_SET(__pyx_v_bla, __pyx_t_4);
  __pyx_t_4 = 0;
  __pyx_t_20 = ((PyArrayObject *)__pyx_t_2);
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_NL.rcbuffer->pybuffer);
    __pyx_t_13 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_NL.rcbuffer->pybuffer, (PyObject*)__pyx_t_20, &__Pyx_TypeInfo_long, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack);
    if (unlikely(__pyx_t_13 < 0)) {
      PyErr_Fetch(&__pyx_t_18, &__pyx_t_17, &__pyx_t_16);
      if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_NL.rcbuffer->pybuffer, (PyObject*)__pyx_v_NL, &__Pyx_TypeInfo_long, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {
        Py_XDECREF(__pyx_t_18); Py_XDECREF(__pyx_t_17); Py_XDECREF(__pyx_t_16);
        __Pyx_RaiseBufferFallbackError();
      } else {
        PyErr_Restore(__pyx_t_18, __pyx_t_17, __pyx_t_16);
      }
    }
    __pyx_pybuffernd_NL.diminfo[0].strides = __pyx_pybuffernd_NL.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_NL.diminfo[0].shape = __pyx_pybuffernd_NL.rcbuffer->pybuffer.shape[0];
    if (unlikely(__pyx_t_13 < 0)) __PYX_ERR(0, 598, __pyx_L1_error)
  }
  __pyx_t_20 = 0;
  __pyx_v_NL = ((PyArrayObject *)__pyx_t_2);
  __pyx_t_2 = 0;
  __pyx_t_14 = ((PyArrayObject *)__pyx_t_6);
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_Rref.rcbuffer->pybuffer);
    __pyx_t_13 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_Rref.rcbuffer->pybuffer, (PyObject*)__pyx_t_14, &__Pyx_TypeInfo_double, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack);
    if (unlikely(__pyx_t_13 < 0)) {
      PyErr_Fetch(&__pyx_t_16, &__pyx_t_17, &__pyx_t_18);
      if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_Rref.rcbuffer->pybuffer, (PyObject*)__pyx_v_Rref, &__Pyx_TypeInfo_double, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {
        Py_XDECREF(__pyx_t_16); Py_XDECREF(__pyx_t_17); Py_XDECREF(__pyx_t_18);
        __Pyx_RaiseBufferFallbackError();
      } else {
        PyErr_Restore(__pyx_t_16, __pyx_t_17, __pyx_t_18);
      }
    }
    __pyx_pybuffernd_Rref.diminfo[0].strides = __pyx_pybuffernd_Rref.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_Rref.diminfo[0].shape = __pyx_pybuffernd_Rref.rcbuffer->pybuffer.shape[0];
    if (unlikely(__pyx_t_13 < 0)) __PYX_ERR(0, 598, __pyx_L1_error)
  }
  __pyx_t_14 = 0;
  __pyx_v_Rref = ((PyArrayObject *)__pyx_t_6);
  __pyx_t_6 = 0;
  __pyx_t_19 = ((PyArrayObject *)__pyx_t_8);
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_VPbis.rcbuffer->pybuffer);
    __pyx_t_13 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_VPbis.rcbuffer->pybuffer, (PyObject*)__pyx_t_19, &__Pyx_TypeInfo_double, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack);
    if (unlikely(__pyx_t_13 < 0)) {
      PyErr_Fetch(&__pyx_t_18, &__pyx_t_17, &__pyx_t_16);
      if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_VPbis.rcbuffer->pybuffer, (PyObject*)__pyx_v_VPbis, &__Pyx_TypeInfo_double, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) {
        Py_XDECREF(__pyx_t_18); Py_XDECREF(__pyx_t_17); Py_XDECREF(__pyx_t_16);
        __Pyx_RaiseBufferFallbackError();
      } else {
        PyErr_Restore(__pyx_t_18, __pyx_t_17, __pyx_t_16);
      }
    }
    __pyx_pybuffernd_VPbis.diminfo[0].strides = __pyx_pybuffernd_VPbis.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_VPbis.diminfo[0].shape = __pyx_pybuffernd_VPbis.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_VPbis.diminfo[1].strides = __pyx_pybuffernd_VPbis.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_VPbis.diminfo[1].shape = __pyx_pybuffernd_VPbis.rcbuffer->pybuffer.shape[1];
    if (unlikely(__pyx_t_13 < 0)) __PYX_ERR(0, 598, __pyx_L1_error)
  }
  __pyx_t_19 = 0;
  __pyx_v_VPbis = ((PyArrayObject *)__pyx_t_8);
  __pyx_t_8 = 0;
+599:     Ln = PtsCross.shape[1]
  __pyx_v_Ln = (__pyx_v_PtsCross->dimensions[1]);
 600: 
+601:     LPts, LdS = [], []
  __pyx_t_3 = PyList_New(0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 601, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_8 = PyList_New(0); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 601, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);
  __pyx_v_LPts = ((PyObject*)__pyx_t_3);
  __pyx_t_3 = 0;
  __pyx_v_LdS = ((PyObject*)__pyx_t_8);
  __pyx_t_8 = 0;
 602:     # First face
+603:     ii = (ind<NY0*NZ0).nonzero()[0]
  __pyx_t_3 = __Pyx_PyInt_From_int((__pyx_v_NY0 * __pyx_v_NZ0)); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 603, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_6 = PyObject_RichCompare(((PyObject *)__pyx_v_ind), __pyx_t_3, Py_LT); __Pyx_XGOTREF(__pyx_t_6); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 603, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_n_s_nonzero); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 603, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  __pyx_t_6 = NULL;
  if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_3))) {
    __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_3);
    if (likely(__pyx_t_6)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
      __Pyx_INCREF(__pyx_t_6);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_3, function);
    }
  }
  if (__pyx_t_6) {
    __pyx_t_8 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_6); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 603, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  } else {
    __pyx_t_8 = __Pyx_PyObject_CallNoArg(__pyx_t_3); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 603, __pyx_L1_error)
  }
  __Pyx_GOTREF(__pyx_t_8);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_3 = __Pyx_GetItemInt(__pyx_t_8, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 603, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  if (!(likely(((__pyx_t_3) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_3, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 603, __pyx_L1_error)
  __pyx_t_20 = ((PyArrayObject *)__pyx_t_3);
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_ii.rcbuffer->pybuffer);
    __pyx_t_13 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_ii.rcbuffer->pybuffer, (PyObject*)__pyx_t_20, &__Pyx_TypeInfo_long, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack);
    if (unlikely(__pyx_t_13 < 0)) {
      PyErr_Fetch(&__pyx_t_16, &__pyx_t_17, &__pyx_t_18);
      if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_ii.rcbuffer->pybuffer, (PyObject*)__pyx_v_ii, &__Pyx_TypeInfo_long, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {
        Py_XDECREF(__pyx_t_16); Py_XDECREF(__pyx_t_17); Py_XDECREF(__pyx_t_18);
        __Pyx_RaiseBufferFallbackError();
      } else {
        PyErr_Restore(__pyx_t_16, __pyx_t_17, __pyx_t_18);
      }
    }
    __pyx_pybuffernd_ii.diminfo[0].strides = __pyx_pybuffernd_ii.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_ii.diminfo[0].shape = __pyx_pybuffernd_ii.rcbuffer->pybuffer.shape[0];
    if (unlikely(__pyx_t_13 < 0)) __PYX_ERR(0, 603, __pyx_L1_error)
  }
  __pyx_t_20 = 0;
  __pyx_v_ii = ((PyArrayObject *)__pyx_t_3);
  __pyx_t_3 = 0;
+604:     nii = len(ii)
  __pyx_t_21 = PyObject_Length(((PyObject *)__pyx_v_ii)); if (unlikely(__pyx_t_21 == -1)) __PYX_ERR(0, 604, __pyx_L1_error)
  __pyx_v_nii = __pyx_t_21;
+605:     if nii>0:
  __pyx_t_22 = ((__pyx_v_nii > 0) != 0);
  if (__pyx_t_22) {
/* … */
  }
+606:         indZ0 = ind[ii] // NY0
    __pyx_t_3 = PyObject_GetItem(((PyObject *)__pyx_v_ind), ((PyObject *)__pyx_v_ii)); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 606, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_8 = __Pyx_PyInt_From_int(__pyx_v_NY0); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 606, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_8);
    __pyx_t_6 = PyNumber_FloorDivide(__pyx_t_3, __pyx_t_8); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 606, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    if (!(likely(((__pyx_t_6) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_6, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 606, __pyx_L1_error)
    __pyx_t_20 = ((PyArrayObject *)__pyx_t_6);
    {
      __Pyx_BufFmt_StackElem __pyx_stack[1];
      __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_indZ0.rcbuffer->pybuffer);
      __pyx_t_13 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_indZ0.rcbuffer->pybuffer, (PyObject*)__pyx_t_20, &__Pyx_TypeInfo_long, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack);
      if (unlikely(__pyx_t_13 < 0)) {
        PyErr_Fetch(&__pyx_t_18, &__pyx_t_17, &__pyx_t_16);
        if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_indZ0.rcbuffer->pybuffer, (PyObject*)__pyx_v_indZ0, &__Pyx_TypeInfo_long, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {
          Py_XDECREF(__pyx_t_18); Py_XDECREF(__pyx_t_17); Py_XDECREF(__pyx_t_16);
          __Pyx_RaiseBufferFallbackError();
        } else {
          PyErr_Restore(__pyx_t_18, __pyx_t_17, __pyx_t_16);
        }
      }
      __pyx_pybuffernd_indZ0.diminfo[0].strides = __pyx_pybuffernd_indZ0.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_indZ0.diminfo[0].shape = __pyx_pybuffernd_indZ0.rcbuffer->pybuffer.shape[0];
      if (unlikely(__pyx_t_13 < 0)) __PYX_ERR(0, 606, __pyx_L1_error)
    }
    __pyx_t_20 = 0;
    __pyx_v_indZ0 = ((PyArrayObject *)__pyx_t_6);
    __pyx_t_6 = 0;
+607:         indY0 = (ind[ii]-indZ0*NY0)
    __pyx_t_6 = PyObject_GetItem(((PyObject *)__pyx_v_ind), ((PyObject *)__pyx_v_ii)); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 607, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_t_8 = __Pyx_PyInt_From_int(__pyx_v_NY0); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 607, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_8);
    __pyx_t_3 = PyNumber_Multiply(((PyObject *)__pyx_v_indZ0), __pyx_t_8); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 607, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    __pyx_t_8 = PyNumber_Subtract(__pyx_t_6, __pyx_t_3); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 607, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_8);
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    if (!(likely(((__pyx_t_8) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_8, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 607, __pyx_L1_error)
    __pyx_t_20 = ((PyArrayObject *)__pyx_t_8);
    {
      __Pyx_BufFmt_StackElem __pyx_stack[1];
      __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_indY0.rcbuffer->pybuffer);
      __pyx_t_13 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_indY0.rcbuffer->pybuffer, (PyObject*)__pyx_t_20, &__Pyx_TypeInfo_long, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack);
      if (unlikely(__pyx_t_13 < 0)) {
        PyErr_Fetch(&__pyx_t_16, &__pyx_t_17, &__pyx_t_18);
        if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_indY0.rcbuffer->pybuffer, (PyObject*)__pyx_v_indY0, &__Pyx_TypeInfo_long, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {
          Py_XDECREF(__pyx_t_16); Py_XDECREF(__pyx_t_17); Py_XDECREF(__pyx_t_18);
          __Pyx_RaiseBufferFallbackError();
        } else {
          PyErr_Restore(__pyx_t_16, __pyx_t_17, __pyx_t_18);
        }
      }
      __pyx_pybuffernd_indY0.diminfo[0].strides = __pyx_pybuffernd_indY0.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_indY0.diminfo[0].shape = __pyx_pybuffernd_indY0.rcbuffer->pybuffer.shape[0];
      if (unlikely(__pyx_t_13 < 0)) __PYX_ERR(0, 607, __pyx_L1_error)
    }
    __pyx_t_20 = 0;
    __pyx_v_indY0 = ((PyArrayObject *)__pyx_t_8);
    __pyx_t_8 = 0;
+608:         if nii==1:
    __pyx_t_22 = ((__pyx_v_nii == 1) != 0);
    if (__pyx_t_22) {
/* … */
      goto __pyx_L12;
    }
+609:             LPts.append( np.array([[XMinMax[0]+DIn], [Y0[indY0]], [Z0[indZ0]]]) )
      __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 609, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_array); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 609, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_6);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __pyx_t_23 = 0;
      __pyx_t_3 = PyFloat_FromDouble(((*((double *) ( /* dim=0 */ ((char *) (((double *) __pyx_v_XMinMax.data) + __pyx_t_23)) ))) + __pyx_v_DIn)); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 609, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_2 = PyList_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 609, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_GIVEREF(__pyx_t_3);
      PyList_SET_ITEM(__pyx_t_2, 0, __pyx_t_3);
      __pyx_t_3 = 0;
      __pyx_t_3 = PyObject_GetItem(((PyObject *)__pyx_v_Y0), ((PyObject *)__pyx_v_indY0)); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 609, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_4 = PyList_New(1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 609, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_GIVEREF(__pyx_t_3);
      PyList_SET_ITEM(__pyx_t_4, 0, __pyx_t_3);
      __pyx_t_3 = 0;
      __pyx_t_3 = PyObject_GetItem(((PyObject *)__pyx_v_Z0), ((PyObject *)__pyx_v_indZ0)); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 609, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_1 = PyList_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 609, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_GIVEREF(__pyx_t_3);
      PyList_SET_ITEM(__pyx_t_1, 0, __pyx_t_3);
      __pyx_t_3 = 0;
      __pyx_t_3 = PyList_New(3); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 609, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_GIVEREF(__pyx_t_2);
      PyList_SET_ITEM(__pyx_t_3, 0, __pyx_t_2);
      __Pyx_GIVEREF(__pyx_t_4);
      PyList_SET_ITEM(__pyx_t_3, 1, __pyx_t_4);
      __Pyx_GIVEREF(__pyx_t_1);
      PyList_SET_ITEM(__pyx_t_3, 2, __pyx_t_1);
      __pyx_t_2 = 0;
      __pyx_t_4 = 0;
      __pyx_t_1 = 0;
      __pyx_t_1 = NULL;
      if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_6))) {
        __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_6);
        if (likely(__pyx_t_1)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6);
          __Pyx_INCREF(__pyx_t_1);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_6, function);
        }
      }
      if (!__pyx_t_1) {
        __pyx_t_8 = __Pyx_PyObject_CallOneArg(__pyx_t_6, __pyx_t_3); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 609, __pyx_L1_error)
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        __Pyx_GOTREF(__pyx_t_8);
      } else {
        #if CYTHON_FAST_PYCALL
        if (PyFunction_Check(__pyx_t_6)) {
          PyObject *__pyx_temp[2] = {__pyx_t_1, __pyx_t_3};
          __pyx_t_8 = __Pyx_PyFunction_FastCall(__pyx_t_6, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 609, __pyx_L1_error)
          __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
          __Pyx_GOTREF(__pyx_t_8);
          __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        } else
        #endif
        #if CYTHON_FAST_PYCCALL
        if (__Pyx_PyFastCFunction_Check(__pyx_t_6)) {
          PyObject *__pyx_temp[2] = {__pyx_t_1, __pyx_t_3};
          __pyx_t_8 = __Pyx_PyCFunction_FastCall(__pyx_t_6, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 609, __pyx_L1_error)
          __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
          __Pyx_GOTREF(__pyx_t_8);
          __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        } else
        #endif
        {
          __pyx_t_4 = PyTuple_New(1+1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 609, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_4);
          __Pyx_GIVEREF(__pyx_t_1); PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_1); __pyx_t_1 = NULL;
          __Pyx_GIVEREF(__pyx_t_3);
          PyTuple_SET_ITEM(__pyx_t_4, 0+1, __pyx_t_3);
          __pyx_t_3 = 0;
          __pyx_t_8 = __Pyx_PyObject_Call(__pyx_t_6, __pyx_t_4, NULL); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 609, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_8);
          __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
        }
      }
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      __pyx_t_24 = __Pyx_PyList_Append(__pyx_v_LPts, __pyx_t_8); if (unlikely(__pyx_t_24 == -1)) __PYX_ERR(0, 609, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
 610:         else:
+611:             LPts.append( np.array([(XMinMax[0]+DIn)*np.ones((nii,)), Y0[indY0], Z0[indZ0]]) )
    /*else*/ {
      __pyx_t_6 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 611, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_6);
      __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_n_s_array); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 611, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      __pyx_t_25 = 0;
      __pyx_t_6 = PyFloat_FromDouble(((*((double *) ( /* dim=0 */ ((char *) (((double *) __pyx_v_XMinMax.data) + __pyx_t_25)) ))) + __pyx_v_DIn)); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 611, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_6);
      __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 611, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_ones); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 611, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_nii); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 611, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_5 = PyTuple_New(1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 611, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_GIVEREF(__pyx_t_1);
      PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_1);
      __pyx_t_1 = 0;
      __pyx_t_1 = NULL;
      if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_2))) {
        __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_2);
        if (likely(__pyx_t_1)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
          __Pyx_INCREF(__pyx_t_1);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_2, function);
        }
      }
      if (!__pyx_t_1) {
        __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_5); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 611, __pyx_L1_error)
        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
        __Pyx_GOTREF(__pyx_t_3);
      } else {
        #if CYTHON_FAST_PYCALL
        if (PyFunction_Check(__pyx_t_2)) {
          PyObject *__pyx_temp[2] = {__pyx_t_1, __pyx_t_5};
          __pyx_t_3 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 611, __pyx_L1_error)
          __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
          __Pyx_GOTREF(__pyx_t_3);
          __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
        } else
        #endif
        #if CYTHON_FAST_PYCCALL
        if (__Pyx_PyFastCFunction_Check(__pyx_t_2)) {
          PyObject *__pyx_temp[2] = {__pyx_t_1, __pyx_t_5};
          __pyx_t_3 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 611, __pyx_L1_error)
          __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
          __Pyx_GOTREF(__pyx_t_3);
          __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
        } else
        #endif
        {
          __pyx_t_9 = PyTuple_New(1+1); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 611, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_9);
          __Pyx_GIVEREF(__pyx_t_1); PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_t_1); __pyx_t_1 = NULL;
          __Pyx_GIVEREF(__pyx_t_5);
          PyTuple_SET_ITEM(__pyx_t_9, 0+1, __pyx_t_5);
          __pyx_t_5 = 0;
          __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_9, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 611, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_3);
          __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
        }
      }
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __pyx_t_2 = PyNumber_Multiply(__pyx_t_6, __pyx_t_3); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 611, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __pyx_t_3 = PyObject_GetItem(((PyObject *)__pyx_v_Y0), ((PyObject *)__pyx_v_indY0)); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 611, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_6 = PyObject_GetItem(((PyObject *)__pyx_v_Z0), ((PyObject *)__pyx_v_indZ0)); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 611, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_6);
      __pyx_t_9 = PyList_New(3); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 611, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_9);
      __Pyx_GIVEREF(__pyx_t_2);
      PyList_SET_ITEM(__pyx_t_9, 0, __pyx_t_2);
      __Pyx_GIVEREF(__pyx_t_3);
      PyList_SET_ITEM(__pyx_t_9, 1, __pyx_t_3);
      __Pyx_GIVEREF(__pyx_t_6);
      PyList_SET_ITEM(__pyx_t_9, 2, __pyx_t_6);
      __pyx_t_2 = 0;
      __pyx_t_3 = 0;
      __pyx_t_6 = 0;
      __pyx_t_6 = NULL;
      if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_4))) {
        __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_4);
        if (likely(__pyx_t_6)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
          __Pyx_INCREF(__pyx_t_6);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_4, function);
        }
      }
      if (!__pyx_t_6) {
        __pyx_t_8 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_9); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 611, __pyx_L1_error)
        __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
        __Pyx_GOTREF(__pyx_t_8);
      } else {
        #if CYTHON_FAST_PYCALL
        if (PyFunction_Check(__pyx_t_4)) {
          PyObject *__pyx_temp[2] = {__pyx_t_6, __pyx_t_9};
          __pyx_t_8 = __Pyx_PyFunction_FastCall(__pyx_t_4, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 611, __pyx_L1_error)
          __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
          __Pyx_GOTREF(__pyx_t_8);
          __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
        } else
        #endif
        #if CYTHON_FAST_PYCCALL
        if (__Pyx_PyFastCFunction_Check(__pyx_t_4)) {
          PyObject *__pyx_temp[2] = {__pyx_t_6, __pyx_t_9};
          __pyx_t_8 = __Pyx_PyCFunction_FastCall(__pyx_t_4, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 611, __pyx_L1_error)
          __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
          __Pyx_GOTREF(__pyx_t_8);
          __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
        } else
        #endif
        {
          __pyx_t_3 = PyTuple_New(1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 611, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_3);
          __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_6); __pyx_t_6 = NULL;
          __Pyx_GIVEREF(__pyx_t_9);
          PyTuple_SET_ITEM(__pyx_t_3, 0+1, __pyx_t_9);
          __pyx_t_9 = 0;
          __pyx_t_8 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_3, NULL); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 611, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_8);
          __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        }
      }
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __pyx_t_24 = __Pyx_PyList_Append(__pyx_v_LPts, __pyx_t_8); if (unlikely(__pyx_t_24 == -1)) __PYX_ERR(0, 611, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    }
    __pyx_L12:;
+612:         LdS.append( dY0r*dZ0r*np.ones((nii,)) )
    __pyx_t_8 = PyFloat_FromDouble((__pyx_v_dY0r * __pyx_v_dZ0r)); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 612, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_8);
    __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 612, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_ones); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 612, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_9);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_t_3 = __Pyx_PyInt_From_int(__pyx_v_nii); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 612, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_6 = PyTuple_New(1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 612, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_GIVEREF(__pyx_t_3);
    PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_3);
    __pyx_t_3 = 0;
    __pyx_t_3 = NULL;
    if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_9))) {
      __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_9);
      if (likely(__pyx_t_3)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_9);
        __Pyx_INCREF(__pyx_t_3);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_9, function);
      }
    }
    if (!__pyx_t_3) {
      __pyx_t_4 = __Pyx_PyObject_CallOneArg(__pyx_t_9, __pyx_t_6); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 612, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      __Pyx_GOTREF(__pyx_t_4);
    } else {
      #if CYTHON_FAST_PYCALL
      if (PyFunction_Check(__pyx_t_9)) {
        PyObject *__pyx_temp[2] = {__pyx_t_3, __pyx_t_6};
        __pyx_t_4 = __Pyx_PyFunction_FastCall(__pyx_t_9, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 612, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
        __Pyx_GOTREF(__pyx_t_4);
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      } else
      #endif
      #if CYTHON_FAST_PYCCALL
      if (__Pyx_PyFastCFunction_Check(__pyx_t_9)) {
        PyObject *__pyx_temp[2] = {__pyx_t_3, __pyx_t_6};
        __pyx_t_4 = __Pyx_PyCFunction_FastCall(__pyx_t_9, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 612, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
        __Pyx_GOTREF(__pyx_t_4);
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      } else
      #endif
      {
        __pyx_t_2 = PyTuple_New(1+1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 612, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_2);
        __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_3); __pyx_t_3 = NULL;
        __Pyx_GIVEREF(__pyx_t_6);
        PyTuple_SET_ITEM(__pyx_t_2, 0+1, __pyx_t_6);
        __pyx_t_6 = 0;
        __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_9, __pyx_t_2, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 612, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_4);
        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      }
    }
    __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
    __pyx_t_9 = PyNumber_Multiply(__pyx_t_8, __pyx_t_4); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 612, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_9);
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_t_24 = __Pyx_PyList_Append(__pyx_v_LdS, __pyx_t_9); if (unlikely(__pyx_t_24 == -1)) __PYX_ERR(0, 612, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
 613: 
 614:     # Cylinder
+615:     ii = ((ind>=NY0*NZ0) & (ind<NY0*NZ0+NX*Ln)).nonzero()[0]
  __pyx_t_4 = __Pyx_PyInt_From_int((__pyx_v_NY0 * __pyx_v_NZ0)); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 615, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_8 = PyObject_RichCompare(((PyObject *)__pyx_v_ind), __pyx_t_4, Py_GE); __Pyx_XGOTREF(__pyx_t_8); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 615, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_4 = __Pyx_PyInt_From_int(((__pyx_v_NY0 * __pyx_v_NZ0) + (__pyx_v_NX * __pyx_v_Ln))); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 615, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_2 = PyObject_RichCompare(((PyObject *)__pyx_v_ind), __pyx_t_4, Py_LT); __Pyx_XGOTREF(__pyx_t_2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 615, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_4 = PyNumber_And(__pyx_t_8, __pyx_t_2); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 615, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_nonzero); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 615, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_4 = NULL;
  if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) {
    __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_2);
    if (likely(__pyx_t_4)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
      __Pyx_INCREF(__pyx_t_4);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_2, function);
    }
  }
  if (__pyx_t_4) {
    __pyx_t_9 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_4); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 615, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  } else {
    __pyx_t_9 = __Pyx_PyObject_CallNoArg(__pyx_t_2); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 615, __pyx_L1_error)
  }
  __Pyx_GOTREF(__pyx_t_9);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = __Pyx_GetItemInt(__pyx_t_9, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 615, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
  if (!(likely(((__pyx_t_2) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_2, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 615, __pyx_L1_error)
  __pyx_t_20 = ((PyArrayObject *)__pyx_t_2);
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_ii.rcbuffer->pybuffer);
    __pyx_t_13 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_ii.rcbuffer->pybuffer, (PyObject*)__pyx_t_20, &__Pyx_TypeInfo_long, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack);
    if (unlikely(__pyx_t_13 < 0)) {
      PyErr_Fetch(&__pyx_t_18, &__pyx_t_17, &__pyx_t_16);
      if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_ii.rcbuffer->pybuffer, (PyObject*)__pyx_v_ii, &__Pyx_TypeInfo_long, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {
        Py_XDECREF(__pyx_t_18); Py_XDECREF(__pyx_t_17); Py_XDECREF(__pyx_t_16);
        __Pyx_RaiseBufferFallbackError();
      } else {
        PyErr_Restore(__pyx_t_18, __pyx_t_17, __pyx_t_16);
      }
    }
    __pyx_pybuffernd_ii.diminfo[0].strides = __pyx_pybuffernd_ii.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_ii.diminfo[0].shape = __pyx_pybuffernd_ii.rcbuffer->pybuffer.shape[0];
    if (unlikely(__pyx_t_13 < 0)) __PYX_ERR(0, 615, __pyx_L1_error)
  }
  __pyx_t_20 = 0;
  __Pyx_DECREF_SET(__pyx_v_ii, ((PyArrayObject *)__pyx_t_2));
  __pyx_t_2 = 0;
+616:     nii = len(ii)
  __pyx_t_21 = PyObject_Length(((PyObject *)__pyx_v_ii)); if (unlikely(__pyx_t_21 == -1)) __PYX_ERR(0, 616, __pyx_L1_error)
  __pyx_v_nii = __pyx_t_21;
+617:     if nii>0:
  __pyx_t_22 = ((__pyx_v_nii > 0) != 0);
  if (__pyx_t_22) {
/* … */
  }
+618:         indX = (ind[ii]-NY0*NZ0) // Ln
    __pyx_t_2 = PyObject_GetItem(((PyObject *)__pyx_v_ind), ((PyObject *)__pyx_v_ii)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 618, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_9 = __Pyx_PyInt_From_int((__pyx_v_NY0 * __pyx_v_NZ0)); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 618, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_9);
    __pyx_t_4 = PyNumber_Subtract(__pyx_t_2, __pyx_t_9); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 618, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
    __pyx_t_9 = __Pyx_PyInt_From_int(__pyx_v_Ln); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 618, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_9);
    __pyx_t_2 = PyNumber_FloorDivide(__pyx_t_4, __pyx_t_9); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 618, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
    if (!(likely(((__pyx_t_2) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_2, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 618, __pyx_L1_error)
    __pyx_t_20 = ((PyArrayObject *)__pyx_t_2);
    {
      __Pyx_BufFmt_StackElem __pyx_stack[1];
      __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_indX.rcbuffer->pybuffer);
      __pyx_t_13 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_indX.rcbuffer->pybuffer, (PyObject*)__pyx_t_20, &__Pyx_TypeInfo_long, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack);
      if (unlikely(__pyx_t_13 < 0)) {
        PyErr_Fetch(&__pyx_t_16, &__pyx_t_17, &__pyx_t_18);
        if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_indX.rcbuffer->pybuffer, (PyObject*)__pyx_v_indX, &__Pyx_TypeInfo_long, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {
          Py_XDECREF(__pyx_t_16); Py_XDECREF(__pyx_t_17); Py_XDECREF(__pyx_t_18);
          __Pyx_RaiseBufferFallbackError();
        } else {
          PyErr_Restore(__pyx_t_16, __pyx_t_17, __pyx_t_18);
        }
      }
      __pyx_pybuffernd_indX.diminfo[0].strides = __pyx_pybuffernd_indX.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_indX.diminfo[0].shape = __pyx_pybuffernd_indX.rcbuffer->pybuffer.shape[0];
      if (unlikely(__pyx_t_13 < 0)) __PYX_ERR(0, 618, __pyx_L1_error)
    }
    __pyx_t_20 = 0;
    __pyx_v_indX = ((PyArrayObject *)__pyx_t_2);
    __pyx_t_2 = 0;
+619:         indL = (ind[ii]-NY0*NZ0 - Ln*indX)
    __pyx_t_2 = PyObject_GetItem(((PyObject *)__pyx_v_ind), ((PyObject *)__pyx_v_ii)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 619, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_9 = __Pyx_PyInt_From_int((__pyx_v_NY0 * __pyx_v_NZ0)); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 619, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_9);
    __pyx_t_4 = PyNumber_Subtract(__pyx_t_2, __pyx_t_9); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 619, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
    __pyx_t_9 = __Pyx_PyInt_From_int(__pyx_v_Ln); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 619, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_9);
    __pyx_t_2 = PyNumber_Multiply(__pyx_t_9, ((PyObject *)__pyx_v_indX)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 619, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
    __pyx_t_9 = PyNumber_Subtract(__pyx_t_4, __pyx_t_2); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 619, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_9);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    if (!(likely(((__pyx_t_9) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_9, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 619, __pyx_L1_error)
    __pyx_t_20 = ((PyArrayObject *)__pyx_t_9);
    {
      __Pyx_BufFmt_StackElem __pyx_stack[1];
      __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_indL.rcbuffer->pybuffer);
      __pyx_t_13 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_indL.rcbuffer->pybuffer, (PyObject*)__pyx_t_20, &__Pyx_TypeInfo_long, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack);
      if (unlikely(__pyx_t_13 < 0)) {
        PyErr_Fetch(&__pyx_t_18, &__pyx_t_17, &__pyx_t_16);
        if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_indL.rcbuffer->pybuffer, (PyObject*)__pyx_v_indL, &__Pyx_TypeInfo_long, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {
          Py_XDECREF(__pyx_t_18); Py_XDECREF(__pyx_t_17); Py_XDECREF(__pyx_t_16);
          __Pyx_RaiseBufferFallbackError();
        } else {
          PyErr_Restore(__pyx_t_18, __pyx_t_17, __pyx_t_16);
        }
      }
      __pyx_pybuffernd_indL.diminfo[0].strides = __pyx_pybuffernd_indL.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_indL.diminfo[0].shape = __pyx_pybuffernd_indL.rcbuffer->pybuffer.shape[0];
      if (unlikely(__pyx_t_13 < 0)) __PYX_ERR(0, 619, __pyx_L1_error)
    }
    __pyx_t_20 = 0;
    __pyx_v_indL = ((PyArrayObject *)__pyx_t_9);
    __pyx_t_9 = 0;
+620:         if nii==1:
    __pyx_t_22 = ((__pyx_v_nii == 1) != 0);
    if (__pyx_t_22) {
/* … */
      goto __pyx_L14;
    }
+621:             LPts.append( np.array([[X[indX]], [PtsCross[0,indL]], [PtsCross[1,indL]]]) )
      __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 621, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_array); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 621, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __pyx_t_2 = PyObject_GetItem(((PyObject *)__pyx_v_X), ((PyObject *)__pyx_v_indX)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 621, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_t_8 = PyList_New(1); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 621, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_8);
      __Pyx_GIVEREF(__pyx_t_2);
      PyList_SET_ITEM(__pyx_t_8, 0, __pyx_t_2);
      __pyx_t_2 = 0;
      __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 621, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_INCREF(__pyx_int_0);
      __Pyx_GIVEREF(__pyx_int_0);
      PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_int_0);
      __Pyx_INCREF(((PyObject *)__pyx_v_indL));
      __Pyx_GIVEREF(((PyObject *)__pyx_v_indL));
      PyTuple_SET_ITEM(__pyx_t_2, 1, ((PyObject *)__pyx_v_indL));
      __pyx_t_6 = PyObject_GetItem(((PyObject *)__pyx_v_PtsCross), __pyx_t_2); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 621, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_6);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __pyx_t_2 = PyList_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 621, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_GIVEREF(__pyx_t_6);
      PyList_SET_ITEM(__pyx_t_2, 0, __pyx_t_6);
      __pyx_t_6 = 0;
      __pyx_t_6 = PyTuple_New(2); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 621, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_6);
      __Pyx_INCREF(__pyx_int_1);
      __Pyx_GIVEREF(__pyx_int_1);
      PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_int_1);
      __Pyx_INCREF(((PyObject *)__pyx_v_indL));
      __Pyx_GIVEREF(((PyObject *)__pyx_v_indL));
      PyTuple_SET_ITEM(__pyx_t_6, 1, ((PyObject *)__pyx_v_indL));
      __pyx_t_3 = PyObject_GetItem(((PyObject *)__pyx_v_PtsCross), __pyx_t_6); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 621, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      __pyx_t_6 = PyList_New(1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 621, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_6);
      __Pyx_GIVEREF(__pyx_t_3);
      PyList_SET_ITEM(__pyx_t_6, 0, __pyx_t_3);
      __pyx_t_3 = 0;
      __pyx_t_3 = PyList_New(3); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 621, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_GIVEREF(__pyx_t_8);
      PyList_SET_ITEM(__pyx_t_3, 0, __pyx_t_8);
      __Pyx_GIVEREF(__pyx_t_2);
      PyList_SET_ITEM(__pyx_t_3, 1, __pyx_t_2);
      __Pyx_GIVEREF(__pyx_t_6);
      PyList_SET_ITEM(__pyx_t_3, 2, __pyx_t_6);
      __pyx_t_8 = 0;
      __pyx_t_2 = 0;
      __pyx_t_6 = 0;
      __pyx_t_6 = NULL;
      if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_4))) {
        __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_4);
        if (likely(__pyx_t_6)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
          __Pyx_INCREF(__pyx_t_6);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_4, function);
        }
      }
      if (!__pyx_t_6) {
        __pyx_t_9 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_3); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 621, __pyx_L1_error)
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        __Pyx_GOTREF(__pyx_t_9);
      } else {
        #if CYTHON_FAST_PYCALL
        if (PyFunction_Check(__pyx_t_4)) {
          PyObject *__pyx_temp[2] = {__pyx_t_6, __pyx_t_3};
          __pyx_t_9 = __Pyx_PyFunction_FastCall(__pyx_t_4, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 621, __pyx_L1_error)
          __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
          __Pyx_GOTREF(__pyx_t_9);
          __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        } else
        #endif
        #if CYTHON_FAST_PYCCALL
        if (__Pyx_PyFastCFunction_Check(__pyx_t_4)) {
          PyObject *__pyx_temp[2] = {__pyx_t_6, __pyx_t_3};
          __pyx_t_9 = __Pyx_PyCFunction_FastCall(__pyx_t_4, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 621, __pyx_L1_error)
          __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
          __Pyx_GOTREF(__pyx_t_9);
          __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        } else
        #endif
        {
          __pyx_t_2 = PyTuple_New(1+1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 621, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_2);
          __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_6); __pyx_t_6 = NULL;
          __Pyx_GIVEREF(__pyx_t_3);
          PyTuple_SET_ITEM(__pyx_t_2, 0+1, __pyx_t_3);
          __pyx_t_3 = 0;
          __pyx_t_9 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_2, NULL); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 621, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_9);
          __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
        }
      }
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __pyx_t_24 = __Pyx_PyList_Append(__pyx_v_LPts, __pyx_t_9); if (unlikely(__pyx_t_24 == -1)) __PYX_ERR(0, 621, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
+622:             LdS.append( np.array([dXr*dLr[indL]]) )
      __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 622, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_array); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 622, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __pyx_t_4 = PyFloat_FromDouble(__pyx_v_dXr); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 622, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_t_3 = PyObject_GetItem(((PyObject *)__pyx_v_dLr), ((PyObject *)__pyx_v_indL)); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 622, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_6 = PyNumber_Multiply(__pyx_t_4, __pyx_t_3); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 622, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_6);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __pyx_t_3 = PyList_New(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 622, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_GIVEREF(__pyx_t_6);
      PyList_SET_ITEM(__pyx_t_3, 0, __pyx_t_6);
      __pyx_t_6 = 0;
      __pyx_t_6 = NULL;
      if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_2))) {
        __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_2);
        if (likely(__pyx_t_6)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
          __Pyx_INCREF(__pyx_t_6);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_2, function);
        }
      }
      if (!__pyx_t_6) {
        __pyx_t_9 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_3); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 622, __pyx_L1_error)
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        __Pyx_GOTREF(__pyx_t_9);
      } else {
        #if CYTHON_FAST_PYCALL
        if (PyFunction_Check(__pyx_t_2)) {
          PyObject *__pyx_temp[2] = {__pyx_t_6, __pyx_t_3};
          __pyx_t_9 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 622, __pyx_L1_error)
          __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
          __Pyx_GOTREF(__pyx_t_9);
          __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        } else
        #endif
        #if CYTHON_FAST_PYCCALL
        if (__Pyx_PyFastCFunction_Check(__pyx_t_2)) {
          PyObject *__pyx_temp[2] = {__pyx_t_6, __pyx_t_3};
          __pyx_t_9 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 622, __pyx_L1_error)
          __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
          __Pyx_GOTREF(__pyx_t_9);
          __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        } else
        #endif
        {
          __pyx_t_4 = PyTuple_New(1+1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 622, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_4);
          __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_6); __pyx_t_6 = NULL;
          __Pyx_GIVEREF(__pyx_t_3);
          PyTuple_SET_ITEM(__pyx_t_4, 0+1, __pyx_t_3);
          __pyx_t_3 = 0;
          __pyx_t_9 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_4, NULL); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 622, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_9);
          __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
        }
      }
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __pyx_t_24 = __Pyx_PyList_Append(__pyx_v_LdS, __pyx_t_9); if (unlikely(__pyx_t_24 == -1)) __PYX_ERR(0, 622, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
 623:         else:
+624:             LPts.append( np.array([X[indX], PtsCross[0,indL], PtsCross[1,indL]]) )
    /*else*/ {
      __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 624, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_array); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 624, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __pyx_t_2 = PyObject_GetItem(((PyObject *)__pyx_v_X), ((PyObject *)__pyx_v_indX)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 624, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 624, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_INCREF(__pyx_int_0);
      __Pyx_GIVEREF(__pyx_int_0);
      PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_int_0);
      __Pyx_INCREF(((PyObject *)__pyx_v_indL));
      __Pyx_GIVEREF(((PyObject *)__pyx_v_indL));
      PyTuple_SET_ITEM(__pyx_t_3, 1, ((PyObject *)__pyx_v_indL));
      __pyx_t_6 = PyObject_GetItem(((PyObject *)__pyx_v_PtsCross), __pyx_t_3); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 624, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_6);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 624, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_INCREF(__pyx_int_1);
      __Pyx_GIVEREF(__pyx_int_1);
      PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_int_1);
      __Pyx_INCREF(((PyObject *)__pyx_v_indL));
      __Pyx_GIVEREF(((PyObject *)__pyx_v_indL));
      PyTuple_SET_ITEM(__pyx_t_3, 1, ((PyObject *)__pyx_v_indL));
      __pyx_t_8 = PyObject_GetItem(((PyObject *)__pyx_v_PtsCross), __pyx_t_3); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 624, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_8);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __pyx_t_3 = PyList_New(3); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 624, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_GIVEREF(__pyx_t_2);
      PyList_SET_ITEM(__pyx_t_3, 0, __pyx_t_2);
      __Pyx_GIVEREF(__pyx_t_6);
      PyList_SET_ITEM(__pyx_t_3, 1, __pyx_t_6);
      __Pyx_GIVEREF(__pyx_t_8);
      PyList_SET_ITEM(__pyx_t_3, 2, __pyx_t_8);
      __pyx_t_2 = 0;
      __pyx_t_6 = 0;
      __pyx_t_8 = 0;
      __pyx_t_8 = NULL;
      if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_4))) {
        __pyx_t_8 = PyMethod_GET_SELF(__pyx_t_4);
        if (likely(__pyx_t_8)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
          __Pyx_INCREF(__pyx_t_8);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_4, function);
        }
      }
      if (!__pyx_t_8) {
        __pyx_t_9 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_3); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 624, __pyx_L1_error)
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        __Pyx_GOTREF(__pyx_t_9);
      } else {
        #if CYTHON_FAST_PYCALL
        if (PyFunction_Check(__pyx_t_4)) {
          PyObject *__pyx_temp[2] = {__pyx_t_8, __pyx_t_3};
          __pyx_t_9 = __Pyx_PyFunction_FastCall(__pyx_t_4, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 624, __pyx_L1_error)
          __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
          __Pyx_GOTREF(__pyx_t_9);
          __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        } else
        #endif
        #if CYTHON_FAST_PYCCALL
        if (__Pyx_PyFastCFunction_Check(__pyx_t_4)) {
          PyObject *__pyx_temp[2] = {__pyx_t_8, __pyx_t_3};
          __pyx_t_9 = __Pyx_PyCFunction_FastCall(__pyx_t_4, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 624, __pyx_L1_error)
          __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
          __Pyx_GOTREF(__pyx_t_9);
          __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        } else
        #endif
        {
          __pyx_t_6 = PyTuple_New(1+1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 624, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_6);
          __Pyx_GIVEREF(__pyx_t_8); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_8); __pyx_t_8 = NULL;
          __Pyx_GIVEREF(__pyx_t_3);
          PyTuple_SET_ITEM(__pyx_t_6, 0+1, __pyx_t_3);
          __pyx_t_3 = 0;
          __pyx_t_9 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_6, NULL); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 624, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_9);
          __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
        }
      }
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __pyx_t_24 = __Pyx_PyList_Append(__pyx_v_LPts, __pyx_t_9); if (unlikely(__pyx_t_24 == -1)) __PYX_ERR(0, 624, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
+625:             LdS.append( dXr*dLr[indL] )
      __pyx_t_9 = PyFloat_FromDouble(__pyx_v_dXr); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 625, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_9);
      __pyx_t_4 = PyObject_GetItem(((PyObject *)__pyx_v_dLr), ((PyObject *)__pyx_v_indL)); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 625, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_t_6 = PyNumber_Multiply(__pyx_t_9, __pyx_t_4); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 625, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_6);
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __pyx_t_24 = __Pyx_PyList_Append(__pyx_v_LdS, __pyx_t_6); if (unlikely(__pyx_t_24 == -1)) __PYX_ERR(0, 625, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    }
    __pyx_L14:;
 626: 
 627:     # End face
+628:     ii = (ind >= NY0*NZ0+NX*Ln).nonzero()[0]
  __pyx_t_4 = __Pyx_PyInt_From_int(((__pyx_v_NY0 * __pyx_v_NZ0) + (__pyx_v_NX * __pyx_v_Ln))); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 628, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_9 = PyObject_RichCompare(((PyObject *)__pyx_v_ind), __pyx_t_4, Py_GE); __Pyx_XGOTREF(__pyx_t_9); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 628, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_9, __pyx_n_s_nonzero); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 628, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
  __pyx_t_9 = NULL;
  if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_4))) {
    __pyx_t_9 = PyMethod_GET_SELF(__pyx_t_4);
    if (likely(__pyx_t_9)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
      __Pyx_INCREF(__pyx_t_9);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_4, function);
    }
  }
  if (__pyx_t_9) {
    __pyx_t_6 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_9); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 628, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
  } else {
    __pyx_t_6 = __Pyx_PyObject_CallNoArg(__pyx_t_4); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 628, __pyx_L1_error)
  }
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_4 = __Pyx_GetItemInt(__pyx_t_6, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 0); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 628, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  if (!(likely(((__pyx_t_4) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_4, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 628, __pyx_L1_error)
  __pyx_t_20 = ((PyArrayObject *)__pyx_t_4);
  {
    __Pyx_BufFmt_StackElem __pyx_stack[1];
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_ii.rcbuffer->pybuffer);
    __pyx_t_13 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_ii.rcbuffer->pybuffer, (PyObject*)__pyx_t_20, &__Pyx_TypeInfo_long, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack);
    if (unlikely(__pyx_t_13 < 0)) {
      PyErr_Fetch(&__pyx_t_16, &__pyx_t_17, &__pyx_t_18);
      if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_ii.rcbuffer->pybuffer, (PyObject*)__pyx_v_ii, &__Pyx_TypeInfo_long, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {
        Py_XDECREF(__pyx_t_16); Py_XDECREF(__pyx_t_17); Py_XDECREF(__pyx_t_18);
        __Pyx_RaiseBufferFallbackError();
      } else {
        PyErr_Restore(__pyx_t_16, __pyx_t_17, __pyx_t_18);
      }
    }
    __pyx_pybuffernd_ii.diminfo[0].strides = __pyx_pybuffernd_ii.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_ii.diminfo[0].shape = __pyx_pybuffernd_ii.rcbuffer->pybuffer.shape[0];
    if (unlikely(__pyx_t_13 < 0)) __PYX_ERR(0, 628, __pyx_L1_error)
  }
  __pyx_t_20 = 0;
  __Pyx_DECREF_SET(__pyx_v_ii, ((PyArrayObject *)__pyx_t_4));
  __pyx_t_4 = 0;
+629:     nii = len(ii)
  __pyx_t_21 = PyObject_Length(((PyObject *)__pyx_v_ii)); if (unlikely(__pyx_t_21 == -1)) __PYX_ERR(0, 629, __pyx_L1_error)
  __pyx_v_nii = __pyx_t_21;
+630:     if nii>0:
  __pyx_t_22 = ((__pyx_v_nii > 0) != 0);
  if (__pyx_t_22) {
/* … */
  }
+631:         indZ0 = (ind[ii]-NY0*NZ0-NX*Ln) // NY0
    __pyx_t_4 = PyObject_GetItem(((PyObject *)__pyx_v_ind), ((PyObject *)__pyx_v_ii)); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 631, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_6 = __Pyx_PyInt_From_int((__pyx_v_NY0 * __pyx_v_NZ0)); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 631, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_t_9 = PyNumber_Subtract(__pyx_t_4, __pyx_t_6); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 631, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_9);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __pyx_t_6 = __Pyx_PyInt_From_int((__pyx_v_NX * __pyx_v_Ln)); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 631, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_t_4 = PyNumber_Subtract(__pyx_t_9, __pyx_t_6); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 631, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __pyx_t_6 = __Pyx_PyInt_From_int(__pyx_v_NY0); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 631, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_t_9 = PyNumber_FloorDivide(__pyx_t_4, __pyx_t_6); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 631, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_9);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    if (!(likely(((__pyx_t_9) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_9, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 631, __pyx_L1_error)
    __pyx_t_20 = ((PyArrayObject *)__pyx_t_9);
    {
      __Pyx_BufFmt_StackElem __pyx_stack[1];
      __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_indZ0.rcbuffer->pybuffer);
      __pyx_t_13 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_indZ0.rcbuffer->pybuffer, (PyObject*)__pyx_t_20, &__Pyx_TypeInfo_long, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack);
      if (unlikely(__pyx_t_13 < 0)) {
        PyErr_Fetch(&__pyx_t_18, &__pyx_t_17, &__pyx_t_16);
        if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_indZ0.rcbuffer->pybuffer, (PyObject*)__pyx_v_indZ0, &__Pyx_TypeInfo_long, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {
          Py_XDECREF(__pyx_t_18); Py_XDECREF(__pyx_t_17); Py_XDECREF(__pyx_t_16);
          __Pyx_RaiseBufferFallbackError();
        } else {
          PyErr_Restore(__pyx_t_18, __pyx_t_17, __pyx_t_16);
        }
      }
      __pyx_pybuffernd_indZ0.diminfo[0].strides = __pyx_pybuffernd_indZ0.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_indZ0.diminfo[0].shape = __pyx_pybuffernd_indZ0.rcbuffer->pybuffer.shape[0];
      if (unlikely(__pyx_t_13 < 0)) __PYX_ERR(0, 631, __pyx_L1_error)
    }
    __pyx_t_20 = 0;
    __Pyx_XDECREF_SET(__pyx_v_indZ0, ((PyArrayObject *)__pyx_t_9));
    __pyx_t_9 = 0;
+632:         indY0 = ind[ii]-NY0*NZ0-NX*Ln - NY0*indZ0
    __pyx_t_9 = PyObject_GetItem(((PyObject *)__pyx_v_ind), ((PyObject *)__pyx_v_ii)); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 632, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_9);
    __pyx_t_6 = __Pyx_PyInt_From_int((__pyx_v_NY0 * __pyx_v_NZ0)); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 632, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_t_4 = PyNumber_Subtract(__pyx_t_9, __pyx_t_6); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 632, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __pyx_t_6 = __Pyx_PyInt_From_int((__pyx_v_NX * __pyx_v_Ln)); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 632, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_t_9 = PyNumber_Subtract(__pyx_t_4, __pyx_t_6); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 632, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_9);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __pyx_t_6 = __Pyx_PyInt_From_int(__pyx_v_NY0); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 632, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_t_4 = PyNumber_Multiply(__pyx_t_6, ((PyObject *)__pyx_v_indZ0)); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 632, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __pyx_t_6 = PyNumber_Subtract(__pyx_t_9, __pyx_t_4); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 632, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    if (!(likely(((__pyx_t_6) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_6, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 632, __pyx_L1_error)
    __pyx_t_20 = ((PyArrayObject *)__pyx_t_6);
    {
      __Pyx_BufFmt_StackElem __pyx_stack[1];
      __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_indY0.rcbuffer->pybuffer);
      __pyx_t_13 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_indY0.rcbuffer->pybuffer, (PyObject*)__pyx_t_20, &__Pyx_TypeInfo_long, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack);
      if (unlikely(__pyx_t_13 < 0)) {
        PyErr_Fetch(&__pyx_t_16, &__pyx_t_17, &__pyx_t_18);
        if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_indY0.rcbuffer->pybuffer, (PyObject*)__pyx_v_indY0, &__Pyx_TypeInfo_long, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {
          Py_XDECREF(__pyx_t_16); Py_XDECREF(__pyx_t_17); Py_XDECREF(__pyx_t_18);
          __Pyx_RaiseBufferFallbackError();
        } else {
          PyErr_Restore(__pyx_t_16, __pyx_t_17, __pyx_t_18);
        }
      }
      __pyx_pybuffernd_indY0.diminfo[0].strides = __pyx_pybuffernd_indY0.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_indY0.diminfo[0].shape = __pyx_pybuffernd_indY0.rcbuffer->pybuffer.shape[0];
      if (unlikely(__pyx_t_13 < 0)) __PYX_ERR(0, 632, __pyx_L1_error)
    }
    __pyx_t_20 = 0;
    __Pyx_XDECREF_SET(__pyx_v_indY0, ((PyArrayObject *)__pyx_t_6));
    __pyx_t_6 = 0;
+633:         if nii==1:
    __pyx_t_22 = ((__pyx_v_nii == 1) != 0);
    if (__pyx_t_22) {
/* … */
      goto __pyx_L16;
    }
+634:             LPts.append( np.array([[XMinMax[1]-DIn], [Y0[indY0]], [Z0[indZ0]]]) )
      __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 634, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_array); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 634, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_9);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __pyx_t_26 = 1;
      __pyx_t_4 = PyFloat_FromDouble(((*((double *) ( /* dim=0 */ ((char *) (((double *) __pyx_v_XMinMax.data) + __pyx_t_26)) ))) - __pyx_v_DIn)); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 634, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_t_3 = PyList_New(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 634, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_GIVEREF(__pyx_t_4);
      PyList_SET_ITEM(__pyx_t_3, 0, __pyx_t_4);
      __pyx_t_4 = 0;
      __pyx_t_4 = PyObject_GetItem(((PyObject *)__pyx_v_Y0), ((PyObject *)__pyx_v_indY0)); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 634, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_t_8 = PyList_New(1); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 634, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_8);
      __Pyx_GIVEREF(__pyx_t_4);
      PyList_SET_ITEM(__pyx_t_8, 0, __pyx_t_4);
      __pyx_t_4 = 0;
      __pyx_t_4 = PyObject_GetItem(((PyObject *)__pyx_v_Z0), ((PyObject *)__pyx_v_indZ0)); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 634, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_t_2 = PyList_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 634, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_GIVEREF(__pyx_t_4);
      PyList_SET_ITEM(__pyx_t_2, 0, __pyx_t_4);
      __pyx_t_4 = 0;
      __pyx_t_4 = PyList_New(3); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 634, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_GIVEREF(__pyx_t_3);
      PyList_SET_ITEM(__pyx_t_4, 0, __pyx_t_3);
      __Pyx_GIVEREF(__pyx_t_8);
      PyList_SET_ITEM(__pyx_t_4, 1, __pyx_t_8);
      __Pyx_GIVEREF(__pyx_t_2);
      PyList_SET_ITEM(__pyx_t_4, 2, __pyx_t_2);
      __pyx_t_3 = 0;
      __pyx_t_8 = 0;
      __pyx_t_2 = 0;
      __pyx_t_2 = NULL;
      if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_9))) {
        __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_9);
        if (likely(__pyx_t_2)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_9);
          __Pyx_INCREF(__pyx_t_2);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_9, function);
        }
      }
      if (!__pyx_t_2) {
        __pyx_t_6 = __Pyx_PyObject_CallOneArg(__pyx_t_9, __pyx_t_4); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 634, __pyx_L1_error)
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
        __Pyx_GOTREF(__pyx_t_6);
      } else {
        #if CYTHON_FAST_PYCALL
        if (PyFunction_Check(__pyx_t_9)) {
          PyObject *__pyx_temp[2] = {__pyx_t_2, __pyx_t_4};
          __pyx_t_6 = __Pyx_PyFunction_FastCall(__pyx_t_9, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 634, __pyx_L1_error)
          __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
          __Pyx_GOTREF(__pyx_t_6);
          __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
        } else
        #endif
        #if CYTHON_FAST_PYCCALL
        if (__Pyx_PyFastCFunction_Check(__pyx_t_9)) {
          PyObject *__pyx_temp[2] = {__pyx_t_2, __pyx_t_4};
          __pyx_t_6 = __Pyx_PyCFunction_FastCall(__pyx_t_9, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 634, __pyx_L1_error)
          __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
          __Pyx_GOTREF(__pyx_t_6);
          __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
        } else
        #endif
        {
          __pyx_t_8 = PyTuple_New(1+1); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 634, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_8);
          __Pyx_GIVEREF(__pyx_t_2); PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_2); __pyx_t_2 = NULL;
          __Pyx_GIVEREF(__pyx_t_4);
          PyTuple_SET_ITEM(__pyx_t_8, 0+1, __pyx_t_4);
          __pyx_t_4 = 0;
          __pyx_t_6 = __Pyx_PyObject_Call(__pyx_t_9, __pyx_t_8, NULL); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 634, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_6);
          __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
        }
      }
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
      __pyx_t_24 = __Pyx_PyList_Append(__pyx_v_LPts, __pyx_t_6); if (unlikely(__pyx_t_24 == -1)) __PYX_ERR(0, 634, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
 635:         else:
+636:             LPts.append( np.array([(XMinMax[1]-DIn)*np.ones((nii,)), Y0[indY0], Z0[indZ0]]) )
    /*else*/ {
      __pyx_t_9 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 636, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_9);
      __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_t_9, __pyx_n_s_array); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 636, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_8);
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
      __pyx_t_27 = 1;
      __pyx_t_9 = PyFloat_FromDouble(((*((double *) ( /* dim=0 */ ((char *) (((double *) __pyx_v_XMinMax.data) + __pyx_t_27)) ))) - __pyx_v_DIn)); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 636, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_9);
      __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 636, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_ones); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 636, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __pyx_t_2 = __Pyx_PyInt_From_int(__pyx_v_nii); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 636, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_t_5 = PyTuple_New(1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 636, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_GIVEREF(__pyx_t_2);
      PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_2);
      __pyx_t_2 = 0;
      __pyx_t_2 = NULL;
      if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) {
        __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_3);
        if (likely(__pyx_t_2)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
          __Pyx_INCREF(__pyx_t_2);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_3, function);
        }
      }
      if (!__pyx_t_2) {
        __pyx_t_4 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_5); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 636, __pyx_L1_error)
        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
        __Pyx_GOTREF(__pyx_t_4);
      } else {
        #if CYTHON_FAST_PYCALL
        if (PyFunction_Check(__pyx_t_3)) {
          PyObject *__pyx_temp[2] = {__pyx_t_2, __pyx_t_5};
          __pyx_t_4 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 636, __pyx_L1_error)
          __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
          __Pyx_GOTREF(__pyx_t_4);
          __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
        } else
        #endif
        #if CYTHON_FAST_PYCCALL
        if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) {
          PyObject *__pyx_temp[2] = {__pyx_t_2, __pyx_t_5};
          __pyx_t_4 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 636, __pyx_L1_error)
          __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
          __Pyx_GOTREF(__pyx_t_4);
          __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
        } else
        #endif
        {
          __pyx_t_1 = PyTuple_New(1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 636, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_1);
          __Pyx_GIVEREF(__pyx_t_2); PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_2); __pyx_t_2 = NULL;
          __Pyx_GIVEREF(__pyx_t_5);
          PyTuple_SET_ITEM(__pyx_t_1, 0+1, __pyx_t_5);
          __pyx_t_5 = 0;
          __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_1, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 636, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_4);
          __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        }
      }
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __pyx_t_3 = PyNumber_Multiply(__pyx_t_9, __pyx_t_4); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 636, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __pyx_t_4 = PyObject_GetItem(((PyObject *)__pyx_v_Y0), ((PyObject *)__pyx_v_indY0)); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 636, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_t_9 = PyObject_GetItem(((PyObject *)__pyx_v_Z0), ((PyObject *)__pyx_v_indZ0)); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 636, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_9);
      __pyx_t_1 = PyList_New(3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 636, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_GIVEREF(__pyx_t_3);
      PyList_SET_ITEM(__pyx_t_1, 0, __pyx_t_3);
      __Pyx_GIVEREF(__pyx_t_4);
      PyList_SET_ITEM(__pyx_t_1, 1, __pyx_t_4);
      __Pyx_GIVEREF(__pyx_t_9);
      PyList_SET_ITEM(__pyx_t_1, 2, __pyx_t_9);
      __pyx_t_3 = 0;
      __pyx_t_4 = 0;
      __pyx_t_9 = 0;
      __pyx_t_9 = NULL;
      if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_8))) {
        __pyx_t_9 = PyMethod_GET_SELF(__pyx_t_8);
        if (likely(__pyx_t_9)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_8);
          __Pyx_INCREF(__pyx_t_9);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_8, function);
        }
      }
      if (!__pyx_t_9) {
        __pyx_t_6 = __Pyx_PyObject_CallOneArg(__pyx_t_8, __pyx_t_1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 636, __pyx_L1_error)
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        __Pyx_GOTREF(__pyx_t_6);
      } else {
        #if CYTHON_FAST_PYCALL
        if (PyFunction_Check(__pyx_t_8)) {
          PyObject *__pyx_temp[2] = {__pyx_t_9, __pyx_t_1};
          __pyx_t_6 = __Pyx_PyFunction_FastCall(__pyx_t_8, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 636, __pyx_L1_error)
          __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
          __Pyx_GOTREF(__pyx_t_6);
          __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        } else
        #endif
        #if CYTHON_FAST_PYCCALL
        if (__Pyx_PyFastCFunction_Check(__pyx_t_8)) {
          PyObject *__pyx_temp[2] = {__pyx_t_9, __pyx_t_1};
          __pyx_t_6 = __Pyx_PyCFunction_FastCall(__pyx_t_8, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 636, __pyx_L1_error)
          __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
          __Pyx_GOTREF(__pyx_t_6);
          __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        } else
        #endif
        {
          __pyx_t_4 = PyTuple_New(1+1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 636, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_4);
          __Pyx_GIVEREF(__pyx_t_9); PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_9); __pyx_t_9 = NULL;
          __Pyx_GIVEREF(__pyx_t_1);
          PyTuple_SET_ITEM(__pyx_t_4, 0+1, __pyx_t_1);
          __pyx_t_1 = 0;
          __pyx_t_6 = __Pyx_PyObject_Call(__pyx_t_8, __pyx_t_4, NULL); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 636, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_6);
          __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
        }
      }
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
      __pyx_t_24 = __Pyx_PyList_Append(__pyx_v_LPts, __pyx_t_6); if (unlikely(__pyx_t_24 == -1)) __PYX_ERR(0, 636, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    }
    __pyx_L16:;
+637:         LdS.append( dY0r*dZ0r*np.ones((nii,)) )
    __pyx_t_6 = PyFloat_FromDouble((__pyx_v_dY0r * __pyx_v_dZ0r)); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 637, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 637, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_ones); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 637, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_t_4 = __Pyx_PyInt_From_int(__pyx_v_nii); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 637, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_9 = PyTuple_New(1); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 637, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_9);
    __Pyx_GIVEREF(__pyx_t_4);
    PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_t_4);
    __pyx_t_4 = 0;
    __pyx_t_4 = NULL;
    if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_1))) {
      __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_1);
      if (likely(__pyx_t_4)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1);
        __Pyx_INCREF(__pyx_t_4);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_1, function);
      }
    }
    if (!__pyx_t_4) {
      __pyx_t_8 = __Pyx_PyObject_CallOneArg(__pyx_t_1, __pyx_t_9); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 637, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
      __Pyx_GOTREF(__pyx_t_8);
    } else {
      #if CYTHON_FAST_PYCALL
      if (PyFunction_Check(__pyx_t_1)) {
        PyObject *__pyx_temp[2] = {__pyx_t_4, __pyx_t_9};
        __pyx_t_8 = __Pyx_PyFunction_FastCall(__pyx_t_1, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 637, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
        __Pyx_GOTREF(__pyx_t_8);
        __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
      } else
      #endif
      #if CYTHON_FAST_PYCCALL
      if (__Pyx_PyFastCFunction_Check(__pyx_t_1)) {
        PyObject *__pyx_temp[2] = {__pyx_t_4, __pyx_t_9};
        __pyx_t_8 = __Pyx_PyCFunction_FastCall(__pyx_t_1, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 637, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
        __Pyx_GOTREF(__pyx_t_8);
        __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
      } else
      #endif
      {
        __pyx_t_3 = PyTuple_New(1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 637, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_3);
        __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_4); __pyx_t_4 = NULL;
        __Pyx_GIVEREF(__pyx_t_9);
        PyTuple_SET_ITEM(__pyx_t_3, 0+1, __pyx_t_9);
        __pyx_t_9 = 0;
        __pyx_t_8 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_3, NULL); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 637, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_8);
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      }
    }
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_1 = PyNumber_Multiply(__pyx_t_6, __pyx_t_8); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 637, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    __pyx_t_24 = __Pyx_PyList_Append(__pyx_v_LdS, __pyx_t_1); if (unlikely(__pyx_t_24 == -1)) __PYX_ERR(0, 637, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
 638: 
 639:     # Format output
+640:     if len(LPts)==1:
  __pyx_t_21 = PyList_GET_SIZE(__pyx_v_LPts); if (unlikely(__pyx_t_21 == -1)) __PYX_ERR(0, 640, __pyx_L1_error)
  __pyx_t_22 = ((__pyx_t_21 == 1) != 0);
  if (__pyx_t_22) {
/* … */
    goto __pyx_L17;
  }
+641:         Pts, dS = LPts[0], LdS[0]
    if (!(likely(((PyList_GET_ITEM(__pyx_v_LPts, 0)) == Py_None) || likely(__Pyx_TypeTest(PyList_GET_ITEM(__pyx_v_LPts, 0), __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 641, __pyx_L1_error)
    __pyx_t_1 = PyList_GET_ITEM(__pyx_v_LPts, 0);
    __Pyx_INCREF(__pyx_t_1);
    if (!(likely(((PyList_GET_ITEM(__pyx_v_LdS, 0)) == Py_None) || likely(__Pyx_TypeTest(PyList_GET_ITEM(__pyx_v_LdS, 0), __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 641, __pyx_L1_error)
    __pyx_t_8 = PyList_GET_ITEM(__pyx_v_LdS, 0);
    __Pyx_INCREF(__pyx_t_8);
    {
      __Pyx_BufFmt_StackElem __pyx_stack[1];
      __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_Pts.rcbuffer->pybuffer);
      __pyx_t_13 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_Pts.rcbuffer->pybuffer, (PyObject*)((PyArrayObject *)__pyx_t_1), &__Pyx_TypeInfo_double, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack);
      if (unlikely(__pyx_t_13 < 0)) {
        PyErr_Fetch(&__pyx_t_18, &__pyx_t_17, &__pyx_t_16);
        if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_Pts.rcbuffer->pybuffer, (PyObject*)__pyx_v_Pts, &__Pyx_TypeInfo_double, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) {
          Py_XDECREF(__pyx_t_18); Py_XDECREF(__pyx_t_17); Py_XDECREF(__pyx_t_16);
          __Pyx_RaiseBufferFallbackError();
        } else {
          PyErr_Restore(__pyx_t_18, __pyx_t_17, __pyx_t_16);
        }
      }
      __pyx_pybuffernd_Pts.diminfo[0].strides = __pyx_pybuffernd_Pts.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_Pts.diminfo[0].shape = __pyx_pybuffernd_Pts.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_Pts.diminfo[1].strides = __pyx_pybuffernd_Pts.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_Pts.diminfo[1].shape = __pyx_pybuffernd_Pts.rcbuffer->pybuffer.shape[1];
      if (unlikely(__pyx_t_13 < 0)) __PYX_ERR(0, 641, __pyx_L1_error)
    }
    __pyx_v_Pts = ((PyArrayObject *)__pyx_t_1);
    __pyx_t_1 = 0;
    {
      __Pyx_BufFmt_StackElem __pyx_stack[1];
      __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_dS.rcbuffer->pybuffer);
      __pyx_t_13 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_dS.rcbuffer->pybuffer, (PyObject*)((PyArrayObject *)__pyx_t_8), &__Pyx_TypeInfo_double, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack);
      if (unlikely(__pyx_t_13 < 0)) {
        PyErr_Fetch(&__pyx_t_16, &__pyx_t_17, &__pyx_t_18);
        if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_dS.rcbuffer->pybuffer, (PyObject*)__pyx_v_dS, &__Pyx_TypeInfo_double, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {
          Py_XDECREF(__pyx_t_16); Py_XDECREF(__pyx_t_17); Py_XDECREF(__pyx_t_18);
          __Pyx_RaiseBufferFallbackError();
        } else {
          PyErr_Restore(__pyx_t_16, __pyx_t_17, __pyx_t_18);
        }
      }
      __pyx_pybuffernd_dS.diminfo[0].strides = __pyx_pybuffernd_dS.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_dS.diminfo[0].shape = __pyx_pybuffernd_dS.rcbuffer->pybuffer.shape[0];
      if (unlikely(__pyx_t_13 < 0)) __PYX_ERR(0, 641, __pyx_L1_error)
    }
    __pyx_v_dS = ((PyArrayObject *)__pyx_t_8);
    __pyx_t_8 = 0;
 642:     else:
+643:         Pts = np.concatenate(tuple(LPts),axis=1)
  /*else*/ {
    __pyx_t_8 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 643, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_8);
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_8, __pyx_n_s_concatenate); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 643, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    __pyx_t_8 = PyList_AsTuple(__pyx_v_LPts); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 643, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_8);
    __pyx_t_6 = PyTuple_New(1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 643, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_GIVEREF(__pyx_t_8);
    PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_8);
    __pyx_t_8 = 0;
    __pyx_t_8 = PyDict_New(); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 643, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_8);
    if (PyDict_SetItem(__pyx_t_8, __pyx_n_s_axis, __pyx_int_1) < 0) __PYX_ERR(0, 643, __pyx_L1_error)
    __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_6, __pyx_t_8); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 643, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    if (!(likely(((__pyx_t_3) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_3, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 643, __pyx_L1_error)
    __pyx_t_19 = ((PyArrayObject *)__pyx_t_3);
    {
      __Pyx_BufFmt_StackElem __pyx_stack[1];
      __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_Pts.rcbuffer->pybuffer);
      __pyx_t_13 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_Pts.rcbuffer->pybuffer, (PyObject*)__pyx_t_19, &__Pyx_TypeInfo_double, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack);
      if (unlikely(__pyx_t_13 < 0)) {
        PyErr_Fetch(&__pyx_t_18, &__pyx_t_17, &__pyx_t_16);
        if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_Pts.rcbuffer->pybuffer, (PyObject*)__pyx_v_Pts, &__Pyx_TypeInfo_double, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) {
          Py_XDECREF(__pyx_t_18); Py_XDECREF(__pyx_t_17); Py_XDECREF(__pyx_t_16);
          __Pyx_RaiseBufferFallbackError();
        } else {
          PyErr_Restore(__pyx_t_18, __pyx_t_17, __pyx_t_16);
        }
      }
      __pyx_pybuffernd_Pts.diminfo[0].strides = __pyx_pybuffernd_Pts.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_Pts.diminfo[0].shape = __pyx_pybuffernd_Pts.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_Pts.diminfo[1].strides = __pyx_pybuffernd_Pts.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_Pts.diminfo[1].shape = __pyx_pybuffernd_Pts.rcbuffer->pybuffer.shape[1];
      if (unlikely(__pyx_t_13 < 0)) __PYX_ERR(0, 643, __pyx_L1_error)
    }
    __pyx_t_19 = 0;
    __pyx_v_Pts = ((PyArrayObject *)__pyx_t_3);
    __pyx_t_3 = 0;
+644:         dS = np.concatenate(tuple(LdS))
    __pyx_t_8 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 644, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_8);
    __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_8, __pyx_n_s_concatenate); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 644, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    __pyx_t_8 = PyList_AsTuple(__pyx_v_LdS); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 644, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_8);
    __pyx_t_1 = NULL;
    if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_6))) {
      __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_6);
      if (likely(__pyx_t_1)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6);
        __Pyx_INCREF(__pyx_t_1);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_6, function);
      }
    }
    if (!__pyx_t_1) {
      __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_t_6, __pyx_t_8); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 644, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
      __Pyx_GOTREF(__pyx_t_3);
    } else {
      #if CYTHON_FAST_PYCALL
      if (PyFunction_Check(__pyx_t_6)) {
        PyObject *__pyx_temp[2] = {__pyx_t_1, __pyx_t_8};
        __pyx_t_3 = __Pyx_PyFunction_FastCall(__pyx_t_6, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 644, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
        __Pyx_GOTREF(__pyx_t_3);
        __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
      } else
      #endif
      #if CYTHON_FAST_PYCCALL
      if (__Pyx_PyFastCFunction_Check(__pyx_t_6)) {
        PyObject *__pyx_temp[2] = {__pyx_t_1, __pyx_t_8};
        __pyx_t_3 = __Pyx_PyCFunction_FastCall(__pyx_t_6, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 644, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
        __Pyx_GOTREF(__pyx_t_3);
        __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
      } else
      #endif
      {
        __pyx_t_9 = PyTuple_New(1+1); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 644, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_9);
        __Pyx_GIVEREF(__pyx_t_1); PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_t_1); __pyx_t_1 = NULL;
        __Pyx_GIVEREF(__pyx_t_8);
        PyTuple_SET_ITEM(__pyx_t_9, 0+1, __pyx_t_8);
        __pyx_t_8 = 0;
        __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_6, __pyx_t_9, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 644, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_3);
        __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
      }
    }
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    if (!(likely(((__pyx_t_3) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_3, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 644, __pyx_L1_error)
    __pyx_t_14 = ((PyArrayObject *)__pyx_t_3);
    {
      __Pyx_BufFmt_StackElem __pyx_stack[1];
      __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_dS.rcbuffer->pybuffer);
      __pyx_t_13 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_dS.rcbuffer->pybuffer, (PyObject*)__pyx_t_14, &__Pyx_TypeInfo_double, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack);
      if (unlikely(__pyx_t_13 < 0)) {
        PyErr_Fetch(&__pyx_t_16, &__pyx_t_17, &__pyx_t_18);
        if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_dS.rcbuffer->pybuffer, (PyObject*)__pyx_v_dS, &__Pyx_TypeInfo_double, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {
          Py_XDECREF(__pyx_t_16); Py_XDECREF(__pyx_t_17); Py_XDECREF(__pyx_t_18);
          __Pyx_RaiseBufferFallbackError();
        } else {
          PyErr_Restore(__pyx_t_16, __pyx_t_17, __pyx_t_18);
        }
      }
      __pyx_pybuffernd_dS.diminfo[0].strides = __pyx_pybuffernd_dS.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_dS.diminfo[0].shape = __pyx_pybuffernd_dS.rcbuffer->pybuffer.shape[0];
      if (unlikely(__pyx_t_13 < 0)) __PYX_ERR(0, 644, __pyx_L1_error)
    }
    __pyx_t_14 = 0;
    __pyx_v_dS = ((PyArrayObject *)__pyx_t_3);
    __pyx_t_3 = 0;
  }
  __pyx_L17:;
 645: 
+646:     return Pts, dS, NL, dLr, Rref, dXr, dY0r, dZ0r, VPbis
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_3 = PyFloat_FromDouble(__pyx_v_dXr); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 646, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_6 = PyFloat_FromDouble(__pyx_v_dY0r); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 646, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __pyx_t_9 = PyFloat_FromDouble(__pyx_v_dZ0r); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 646, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_9);
  __pyx_t_8 = PyTuple_New(9); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 646, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);
  __Pyx_INCREF(((PyObject *)__pyx_v_Pts));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_Pts));
  PyTuple_SET_ITEM(__pyx_t_8, 0, ((PyObject *)__pyx_v_Pts));
  __Pyx_INCREF(((PyObject *)__pyx_v_dS));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_dS));
  PyTuple_SET_ITEM(__pyx_t_8, 1, ((PyObject *)__pyx_v_dS));
  __Pyx_INCREF(((PyObject *)__pyx_v_NL));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_NL));
  PyTuple_SET_ITEM(__pyx_t_8, 2, ((PyObject *)__pyx_v_NL));
  __Pyx_INCREF(((PyObject *)__pyx_v_dLr));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_dLr));
  PyTuple_SET_ITEM(__pyx_t_8, 3, ((PyObject *)__pyx_v_dLr));
  __Pyx_INCREF(((PyObject *)__pyx_v_Rref));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_Rref));
  PyTuple_SET_ITEM(__pyx_t_8, 4, ((PyObject *)__pyx_v_Rref));
  __Pyx_GIVEREF(__pyx_t_3);
  PyTuple_SET_ITEM(__pyx_t_8, 5, __pyx_t_3);
  __Pyx_GIVEREF(__pyx_t_6);
  PyTuple_SET_ITEM(__pyx_t_8, 6, __pyx_t_6);
  __Pyx_GIVEREF(__pyx_t_9);
  PyTuple_SET_ITEM(__pyx_t_8, 7, __pyx_t_9);
  __Pyx_INCREF(((PyObject *)__pyx_v_VPbis));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_VPbis));
  PyTuple_SET_ITEM(__pyx_t_8, 8, ((PyObject *)__pyx_v_VPbis));
  __pyx_t_3 = 0;
  __pyx_t_6 = 0;
  __pyx_t_9 = 0;
  __pyx_r = __pyx_t_8;
  __pyx_t_8 = 0;
  goto __pyx_L0;
 647: 
 648: 
 649: 
 650: 
 651: ##################### New version
 652: 
+653: def _getBoundsInter2AngSeg(bool Full, double Phi0, double Phi1, double DPhi0, double DPhi1):
/* Python wrapper */
static PyObject *__pyx_pw_46_cython_magic_8152fc40fb05daa7217c00b66474f995_17_getBoundsInter2AngSeg(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_46_cython_magic_8152fc40fb05daa7217c00b66474f995_16_getBoundsInter2AngSeg[] = " Return Inter=True if an intersection exist (all angles in radians in [-pi;pi])\n\n    If Inter, return Bounds, a list of tuples indicating the segments defining the intersection, with\n    The intervals are ordered from lowest index to highst index (with respect to [Phi0,Phi1])\n    ";
static PyMethodDef __pyx_mdef_46_cython_magic_8152fc40fb05daa7217c00b66474f995_17_getBoundsInter2AngSeg = {"_getBoundsInter2AngSeg", (PyCFunction)__pyx_pw_46_cython_magic_8152fc40fb05daa7217c00b66474f995_17_getBoundsInter2AngSeg, METH_VARARGS|METH_KEYWORDS, __pyx_doc_46_cython_magic_8152fc40fb05daa7217c00b66474f995_16_getBoundsInter2AngSeg};
static PyObject *__pyx_pw_46_cython_magic_8152fc40fb05daa7217c00b66474f995_17_getBoundsInter2AngSeg(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyBoolObject *__pyx_v_Full = 0;
  double __pyx_v_Phi0;
  double __pyx_v_Phi1;
  double __pyx_v_DPhi0;
  double __pyx_v_DPhi1;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("_getBoundsInter2AngSeg (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_Full,&__pyx_n_s_Phi0,&__pyx_n_s_Phi1,&__pyx_n_s_DPhi0,&__pyx_n_s_DPhi1,0};
    PyObject* values[5] = {0,0,0,0,0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_Full)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        case  1:
        if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_Phi0)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_getBoundsInter2AngSeg", 1, 5, 5, 1); __PYX_ERR(0, 653, __pyx_L3_error)
        }
        case  2:
        if (likely((values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_Phi1)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_getBoundsInter2AngSeg", 1, 5, 5, 2); __PYX_ERR(0, 653, __pyx_L3_error)
        }
        case  3:
        if (likely((values[3] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_DPhi0)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_getBoundsInter2AngSeg", 1, 5, 5, 3); __PYX_ERR(0, 653, __pyx_L3_error)
        }
        case  4:
        if (likely((values[4] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_DPhi1)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_getBoundsInter2AngSeg", 1, 5, 5, 4); __PYX_ERR(0, 653, __pyx_L3_error)
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "_getBoundsInter2AngSeg") < 0)) __PYX_ERR(0, 653, __pyx_L3_error)
      }
    } else if (PyTuple_GET_SIZE(__pyx_args) != 5) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
      values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
      values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
      values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
    }
    __pyx_v_Full = ((PyBoolObject *)values[0]);
    __pyx_v_Phi0 = __pyx_PyFloat_AsDouble(values[1]); if (unlikely((__pyx_v_Phi0 == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 653, __pyx_L3_error)
    __pyx_v_Phi1 = __pyx_PyFloat_AsDouble(values[2]); if (unlikely((__pyx_v_Phi1 == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 653, __pyx_L3_error)
    __pyx_v_DPhi0 = __pyx_PyFloat_AsDouble(values[3]); if (unlikely((__pyx_v_DPhi0 == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 653, __pyx_L3_error)
    __pyx_v_DPhi1 = __pyx_PyFloat_AsDouble(values[4]); if (unlikely((__pyx_v_DPhi1 == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 653, __pyx_L3_error)
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("_getBoundsInter2AngSeg", 1, 5, 5, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 653, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("_cython_magic_8152fc40fb05daa7217c00b66474f995._getBoundsInter2AngSeg", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_Full), __pyx_ptype_7cpython_4bool_bool, 1, "Full", 0))) __PYX_ERR(0, 653, __pyx_L1_error)
  __pyx_r = __pyx_pf_46_cython_magic_8152fc40fb05daa7217c00b66474f995_16_getBoundsInter2AngSeg(__pyx_self, __pyx_v_Full, __pyx_v_Phi0, __pyx_v_Phi1, __pyx_v_DPhi0, __pyx_v_DPhi1);

  /* function exit code */
  goto __pyx_L0;
  __pyx_L1_error:;
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_46_cython_magic_8152fc40fb05daa7217c00b66474f995_16_getBoundsInter2AngSeg(CYTHON_UNUSED PyObject *__pyx_self, PyBoolObject *__pyx_v_Full, double __pyx_v_Phi0, double __pyx_v_Phi1, double __pyx_v_DPhi0, double __pyx_v_DPhi1) {
  PyObject *__pyx_v_Bounds = NULL;
  int __pyx_v_Inter;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("_getBoundsInter2AngSeg", 0);
/* … */
  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_AddTraceback("_cython_magic_8152fc40fb05daa7217c00b66474f995._getBoundsInter2AngSeg", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_Bounds);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}
/* … */
  __pyx_tuple__121 = PyTuple_Pack(7, __pyx_n_s_Full, __pyx_n_s_Phi0, __pyx_n_s_Phi1, __pyx_n_s_DPhi0, __pyx_n_s_DPhi1, __pyx_n_s_Bounds, __pyx_n_s_Inter); if (unlikely(!__pyx_tuple__121)) __PYX_ERR(0, 653, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__121);
  __Pyx_GIVEREF(__pyx_tuple__121);
/* … */
  __pyx_t_2 = PyCFunction_NewEx(&__pyx_mdef_46_cython_magic_8152fc40fb05daa7217c00b66474f995_17_getBoundsInter2AngSeg, NULL, __pyx_n_s_cython_magic_8152fc40fb05daa721); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 653, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_getBoundsInter2AngSeg, __pyx_t_2) < 0) __PYX_ERR(0, 653, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_codeobj__122 = (PyObject*)__Pyx_PyCode_New(5, 0, 7, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__121, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_Home_DV226270_cache_ipython_cyt, __pyx_n_s_getBoundsInter2AngSeg, 653, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__122)) __PYX_ERR(0, 653, __pyx_L1_error)
 654:     """ Return Inter=True if an intersection exist (all angles in radians in [-pi;pi])
 655: 
 656:     If Inter, return Bounds, a list of tuples indicating the segments defining the intersection, with
 657:     The intervals are ordered from lowest index to highst index (with respect to [Phi0,Phi1])
 658:     """
+659:     if Full:
  __pyx_t_1 = __Pyx_PyObject_IsTrue(((PyObject *)__pyx_v_Full)); if (unlikely(__pyx_t_1 < 0)) __PYX_ERR(0, 659, __pyx_L1_error)
  if (__pyx_t_1) {
/* … */
    goto __pyx_L3;
  }
+660:         Bounds = [[DPhi0,DPhi1]] if DPhi0<=DPhi1 else [[-Cpi,DPhi1],[DPhi0,Cpi]]
    if (((__pyx_v_DPhi0 <= __pyx_v_DPhi1) != 0)) {
      __pyx_t_3 = PyFloat_FromDouble(__pyx_v_DPhi0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 660, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_4 = PyFloat_FromDouble(__pyx_v_DPhi1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 660, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_t_5 = PyList_New(2); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 660, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_GIVEREF(__pyx_t_3);
      PyList_SET_ITEM(__pyx_t_5, 0, __pyx_t_3);
      __Pyx_GIVEREF(__pyx_t_4);
      PyList_SET_ITEM(__pyx_t_5, 1, __pyx_t_4);
      __pyx_t_3 = 0;
      __pyx_t_4 = 0;
      __pyx_t_4 = PyList_New(1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 660, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_GIVEREF(__pyx_t_5);
      PyList_SET_ITEM(__pyx_t_4, 0, __pyx_t_5);
      __pyx_t_5 = 0;
      __pyx_t_2 = __pyx_t_4;
      __pyx_t_4 = 0;
    } else {
      __pyx_t_4 = PyFloat_FromDouble((-M_PI)); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 660, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_t_5 = PyFloat_FromDouble(__pyx_v_DPhi1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 660, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
      __pyx_t_3 = PyList_New(2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 660, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_GIVEREF(__pyx_t_4);
      PyList_SET_ITEM(__pyx_t_3, 0, __pyx_t_4);
      __Pyx_GIVEREF(__pyx_t_5);
      PyList_SET_ITEM(__pyx_t_3, 1, __pyx_t_5);
      __pyx_t_4 = 0;
      __pyx_t_5 = 0;
      __pyx_t_5 = PyFloat_FromDouble(__pyx_v_DPhi0); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 660, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
      __pyx_t_4 = PyFloat_FromDouble(M_PI); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 660, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_t_6 = PyList_New(2); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 660, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_6);
      __Pyx_GIVEREF(__pyx_t_5);
      PyList_SET_ITEM(__pyx_t_6, 0, __pyx_t_5);
      __Pyx_GIVEREF(__pyx_t_4);
      PyList_SET_ITEM(__pyx_t_6, 1, __pyx_t_4);
      __pyx_t_5 = 0;
      __pyx_t_4 = 0;
      __pyx_t_4 = PyList_New(2); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 660, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_GIVEREF(__pyx_t_3);
      PyList_SET_ITEM(__pyx_t_4, 0, __pyx_t_3);
      __Pyx_GIVEREF(__pyx_t_6);
      PyList_SET_ITEM(__pyx_t_4, 1, __pyx_t_6);
      __pyx_t_3 = 0;
      __pyx_t_6 = 0;
      __pyx_t_2 = __pyx_t_4;
      __pyx_t_4 = 0;
    }
    __pyx_v_Bounds = __pyx_t_2;
    __pyx_t_2 = 0;
+661:         Inter = True
    __pyx_v_Inter = 1;
 662: 
 663:     else:
+664:         Inter, Bounds = False, None
  /*else*/ {
    __pyx_t_1 = 0;
    __pyx_t_2 = Py_None;
    __Pyx_INCREF(__pyx_t_2);
    __pyx_v_Inter = __pyx_t_1;
    __pyx_v_Bounds = __pyx_t_2;
    __pyx_t_2 = 0;
+665:         if Phi0<=Phi1:
    __pyx_t_1 = ((__pyx_v_Phi0 <= __pyx_v_Phi1) != 0);
    if (__pyx_t_1) {
/* … */
      goto __pyx_L4;
    }
+666:             if DPhi0<=DPhi1:
      __pyx_t_1 = ((__pyx_v_DPhi0 <= __pyx_v_DPhi1) != 0);
      if (__pyx_t_1) {
/* … */
        goto __pyx_L5;
      }
+667:                 if DPhi0<=Phi1 and DPhi1>=Phi0:
        __pyx_t_7 = ((__pyx_v_DPhi0 <= __pyx_v_Phi1) != 0);
        if (__pyx_t_7) {
        } else {
          __pyx_t_1 = __pyx_t_7;
          goto __pyx_L7_bool_binop_done;
        }
        __pyx_t_7 = ((__pyx_v_DPhi1 >= __pyx_v_Phi0) != 0);
        __pyx_t_1 = __pyx_t_7;
        __pyx_L7_bool_binop_done:;
        if (__pyx_t_1) {
/* … */
        }
+668:                     Inter = True
          __pyx_v_Inter = 1;
+669:                     Bounds = [[None,None]]
          __pyx_t_2 = PyList_New(2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 669, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_2);
          __Pyx_INCREF(Py_None);
          __Pyx_GIVEREF(Py_None);
          PyList_SET_ITEM(__pyx_t_2, 0, Py_None);
          __Pyx_INCREF(Py_None);
          __Pyx_GIVEREF(Py_None);
          PyList_SET_ITEM(__pyx_t_2, 1, Py_None);
          __pyx_t_4 = PyList_New(1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 669, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_4);
          __Pyx_GIVEREF(__pyx_t_2);
          PyList_SET_ITEM(__pyx_t_4, 0, __pyx_t_2);
          __pyx_t_2 = 0;
          __Pyx_DECREF_SET(__pyx_v_Bounds, __pyx_t_4);
          __pyx_t_4 = 0;
+670:                     Bounds[0][0] = Phi0 if DPhi0<=Phi0 else DPhi0
          if (((__pyx_v_DPhi0 <= __pyx_v_Phi0) != 0)) {
            __pyx_t_2 = PyFloat_FromDouble(__pyx_v_Phi0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 670, __pyx_L1_error)
            __Pyx_GOTREF(__pyx_t_2);
            __pyx_t_4 = __pyx_t_2;
            __pyx_t_2 = 0;
          } else {
            __pyx_t_2 = PyFloat_FromDouble(__pyx_v_DPhi0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 670, __pyx_L1_error)
            __Pyx_GOTREF(__pyx_t_2);
            __pyx_t_4 = __pyx_t_2;
            __pyx_t_2 = 0;
          }
          __pyx_t_2 = __Pyx_GetItemInt(__pyx_v_Bounds, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 670, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_2);
          if (unlikely(__Pyx_SetItemInt(__pyx_t_2, 0, __pyx_t_4, long, 1, __Pyx_PyInt_From_long, 0, 0, 1) < 0)) __PYX_ERR(0, 670, __pyx_L1_error)
          __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
          __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+671:                     Bounds[0][1] = Phi1 if DPhi1>=Phi1 else DPhi1
          if (((__pyx_v_DPhi1 >= __pyx_v_Phi1) != 0)) {
            __pyx_t_2 = PyFloat_FromDouble(__pyx_v_Phi1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 671, __pyx_L1_error)
            __Pyx_GOTREF(__pyx_t_2);
            __pyx_t_4 = __pyx_t_2;
            __pyx_t_2 = 0;
          } else {
            __pyx_t_2 = PyFloat_FromDouble(__pyx_v_DPhi1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 671, __pyx_L1_error)
            __Pyx_GOTREF(__pyx_t_2);
            __pyx_t_4 = __pyx_t_2;
            __pyx_t_2 = 0;
          }
          __pyx_t_2 = __Pyx_GetItemInt(__pyx_v_Bounds, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 671, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_2);
          if (unlikely(__Pyx_SetItemInt(__pyx_t_2, 1, __pyx_t_4, long, 1, __Pyx_PyInt_From_long, 0, 0, 1) < 0)) __PYX_ERR(0, 671, __pyx_L1_error)
          __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
          __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
 672:             else:
+673:                 if DPhi0<=Phi1 or DPhi1>=Phi0:
      /*else*/ {
        __pyx_t_7 = ((__pyx_v_DPhi0 <= __pyx_v_Phi1) != 0);
        if (!__pyx_t_7) {
        } else {
          __pyx_t_1 = __pyx_t_7;
          goto __pyx_L10_bool_binop_done;
        }
        __pyx_t_7 = ((__pyx_v_DPhi1 >= __pyx_v_Phi0) != 0);
        __pyx_t_1 = __pyx_t_7;
        __pyx_L10_bool_binop_done:;
        if (__pyx_t_1) {
/* … */
        }
      }
      __pyx_L5:;
+674:                     Inter = True
          __pyx_v_Inter = 1;
+675:                     if DPhi0<=Phi1 and DPhi1>=Phi0:
          __pyx_t_7 = ((__pyx_v_DPhi0 <= __pyx_v_Phi1) != 0);
          if (__pyx_t_7) {
          } else {
            __pyx_t_1 = __pyx_t_7;
            goto __pyx_L13_bool_binop_done;
          }
          __pyx_t_7 = ((__pyx_v_DPhi1 >= __pyx_v_Phi0) != 0);
          __pyx_t_1 = __pyx_t_7;
          __pyx_L13_bool_binop_done:;
          if (__pyx_t_1) {
/* … */
            goto __pyx_L12;
          }
+676:                         Bounds = [[Phi0,DPhi1],[DPhi0,Phi1]]
            __pyx_t_4 = PyFloat_FromDouble(__pyx_v_Phi0); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 676, __pyx_L1_error)
            __Pyx_GOTREF(__pyx_t_4);
            __pyx_t_2 = PyFloat_FromDouble(__pyx_v_DPhi1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 676, __pyx_L1_error)
            __Pyx_GOTREF(__pyx_t_2);
            __pyx_t_6 = PyList_New(2); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 676, __pyx_L1_error)
            __Pyx_GOTREF(__pyx_t_6);
            __Pyx_GIVEREF(__pyx_t_4);
            PyList_SET_ITEM(__pyx_t_6, 0, __pyx_t_4);
            __Pyx_GIVEREF(__pyx_t_2);
            PyList_SET_ITEM(__pyx_t_6, 1, __pyx_t_2);
            __pyx_t_4 = 0;
            __pyx_t_2 = 0;
            __pyx_t_2 = PyFloat_FromDouble(__pyx_v_DPhi0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 676, __pyx_L1_error)
            __Pyx_GOTREF(__pyx_t_2);
            __pyx_t_4 = PyFloat_FromDouble(__pyx_v_Phi1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 676, __pyx_L1_error)
            __Pyx_GOTREF(__pyx_t_4);
            __pyx_t_3 = PyList_New(2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 676, __pyx_L1_error)
            __Pyx_GOTREF(__pyx_t_3);
            __Pyx_GIVEREF(__pyx_t_2);
            PyList_SET_ITEM(__pyx_t_3, 0, __pyx_t_2);
            __Pyx_GIVEREF(__pyx_t_4);
            PyList_SET_ITEM(__pyx_t_3, 1, __pyx_t_4);
            __pyx_t_2 = 0;
            __pyx_t_4 = 0;
            __pyx_t_4 = PyList_New(2); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 676, __pyx_L1_error)
            __Pyx_GOTREF(__pyx_t_4);
            __Pyx_GIVEREF(__pyx_t_6);
            PyList_SET_ITEM(__pyx_t_4, 0, __pyx_t_6);
            __Pyx_GIVEREF(__pyx_t_3);
            PyList_SET_ITEM(__pyx_t_4, 1, __pyx_t_3);
            __pyx_t_6 = 0;
            __pyx_t_3 = 0;
            __Pyx_DECREF_SET(__pyx_v_Bounds, __pyx_t_4);
            __pyx_t_4 = 0;
 677:                     else:
+678:                         Bounds = [[None,None]]
          /*else*/ {
            __pyx_t_4 = PyList_New(2); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 678, __pyx_L1_error)
            __Pyx_GOTREF(__pyx_t_4);
            __Pyx_INCREF(Py_None);
            __Pyx_GIVEREF(Py_None);
            PyList_SET_ITEM(__pyx_t_4, 0, Py_None);
            __Pyx_INCREF(Py_None);
            __Pyx_GIVEREF(Py_None);
            PyList_SET_ITEM(__pyx_t_4, 1, Py_None);
            __pyx_t_3 = PyList_New(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 678, __pyx_L1_error)
            __Pyx_GOTREF(__pyx_t_3);
            __Pyx_GIVEREF(__pyx_t_4);
            PyList_SET_ITEM(__pyx_t_3, 0, __pyx_t_4);
            __pyx_t_4 = 0;
            __Pyx_DECREF_SET(__pyx_v_Bounds, __pyx_t_3);
            __pyx_t_3 = 0;
+679:                         if DPhi0<=Phi1:
            __pyx_t_1 = ((__pyx_v_DPhi0 <= __pyx_v_Phi1) != 0);
            if (__pyx_t_1) {
/* … */
              goto __pyx_L15;
            }
+680:                             Bounds[0][0] = Phi0 if DPhi0<=Phi0 else DPhi0
              if (((__pyx_v_DPhi0 <= __pyx_v_Phi0) != 0)) {
                __pyx_t_4 = PyFloat_FromDouble(__pyx_v_Phi0); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 680, __pyx_L1_error)
                __Pyx_GOTREF(__pyx_t_4);
                __pyx_t_3 = __pyx_t_4;
                __pyx_t_4 = 0;
              } else {
                __pyx_t_4 = PyFloat_FromDouble(__pyx_v_DPhi0); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 680, __pyx_L1_error)
                __Pyx_GOTREF(__pyx_t_4);
                __pyx_t_3 = __pyx_t_4;
                __pyx_t_4 = 0;
              }
              __pyx_t_4 = __Pyx_GetItemInt(__pyx_v_Bounds, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 680, __pyx_L1_error)
              __Pyx_GOTREF(__pyx_t_4);
              if (unlikely(__Pyx_SetItemInt(__pyx_t_4, 0, __pyx_t_3, long, 1, __Pyx_PyInt_From_long, 0, 0, 1) < 0)) __PYX_ERR(0, 680, __pyx_L1_error)
              __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
              __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+681:                             Bounds[0][1] = Phi1
              __pyx_t_3 = PyFloat_FromDouble(__pyx_v_Phi1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 681, __pyx_L1_error)
              __Pyx_GOTREF(__pyx_t_3);
              __pyx_t_4 = __Pyx_GetItemInt(__pyx_v_Bounds, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 681, __pyx_L1_error)
              __Pyx_GOTREF(__pyx_t_4);
              if (unlikely(__Pyx_SetItemInt(__pyx_t_4, 1, __pyx_t_3, long, 1, __Pyx_PyInt_From_long, 0, 0, 1) < 0)) __PYX_ERR(0, 681, __pyx_L1_error)
              __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
              __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
 682:                         else:
+683:                             Bounds[0][0] = Phi0
            /*else*/ {
              __pyx_t_3 = PyFloat_FromDouble(__pyx_v_Phi0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 683, __pyx_L1_error)
              __Pyx_GOTREF(__pyx_t_3);
              __pyx_t_4 = __Pyx_GetItemInt(__pyx_v_Bounds, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 683, __pyx_L1_error)
              __Pyx_GOTREF(__pyx_t_4);
              if (unlikely(__Pyx_SetItemInt(__pyx_t_4, 0, __pyx_t_3, long, 1, __Pyx_PyInt_From_long, 0, 0, 1) < 0)) __PYX_ERR(0, 683, __pyx_L1_error)
              __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
              __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+684:                             Bounds[0][1] = Phi1 if DPhi1>=Phi1 else DPhi1
              if (((__pyx_v_DPhi1 >= __pyx_v_Phi1) != 0)) {
                __pyx_t_4 = PyFloat_FromDouble(__pyx_v_Phi1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 684, __pyx_L1_error)
                __Pyx_GOTREF(__pyx_t_4);
                __pyx_t_3 = __pyx_t_4;
                __pyx_t_4 = 0;
              } else {
                __pyx_t_4 = PyFloat_FromDouble(__pyx_v_DPhi1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 684, __pyx_L1_error)
                __Pyx_GOTREF(__pyx_t_4);
                __pyx_t_3 = __pyx_t_4;
                __pyx_t_4 = 0;
              }
              __pyx_t_4 = __Pyx_GetItemInt(__pyx_v_Bounds, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 684, __pyx_L1_error)
              __Pyx_GOTREF(__pyx_t_4);
              if (unlikely(__Pyx_SetItemInt(__pyx_t_4, 1, __pyx_t_3, long, 1, __Pyx_PyInt_From_long, 0, 0, 1) < 0)) __PYX_ERR(0, 684, __pyx_L1_error)
              __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
              __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
            }
            __pyx_L15:;
          }
          __pyx_L12:;
 685:         else:
+686:             if DPhi0<=DPhi1:
    /*else*/ {
      __pyx_t_1 = ((__pyx_v_DPhi0 <= __pyx_v_DPhi1) != 0);
      if (__pyx_t_1) {
/* … */
        goto __pyx_L16;
      }
+687:                 if DPhi0<=Phi1 or DPhi1>=Phi0:
        __pyx_t_7 = ((__pyx_v_DPhi0 <= __pyx_v_Phi1) != 0);
        if (!__pyx_t_7) {
        } else {
          __pyx_t_1 = __pyx_t_7;
          goto __pyx_L18_bool_binop_done;
        }
        __pyx_t_7 = ((__pyx_v_DPhi1 >= __pyx_v_Phi0) != 0);
        __pyx_t_1 = __pyx_t_7;
        __pyx_L18_bool_binop_done:;
        if (__pyx_t_1) {
/* … */
        }
+688:                     Inter = True
          __pyx_v_Inter = 1;
+689:                     if DPhi0<=Phi1 and DPhi1>=Phi0:
          __pyx_t_7 = ((__pyx_v_DPhi0 <= __pyx_v_Phi1) != 0);
          if (__pyx_t_7) {
          } else {
            __pyx_t_1 = __pyx_t_7;
            goto __pyx_L21_bool_binop_done;
          }
          __pyx_t_7 = ((__pyx_v_DPhi1 >= __pyx_v_Phi0) != 0);
          __pyx_t_1 = __pyx_t_7;
          __pyx_L21_bool_binop_done:;
          if (__pyx_t_1) {
/* … */
            goto __pyx_L20;
          }
+690:                         Bounds = [[Phi0,DPhi1],[DPhi0,Phi1]]
            __pyx_t_3 = PyFloat_FromDouble(__pyx_v_Phi0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 690, __pyx_L1_error)
            __Pyx_GOTREF(__pyx_t_3);
            __pyx_t_4 = PyFloat_FromDouble(__pyx_v_DPhi1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 690, __pyx_L1_error)
            __Pyx_GOTREF(__pyx_t_4);
            __pyx_t_6 = PyList_New(2); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 690, __pyx_L1_error)
            __Pyx_GOTREF(__pyx_t_6);
            __Pyx_GIVEREF(__pyx_t_3);
            PyList_SET_ITEM(__pyx_t_6, 0, __pyx_t_3);
            __Pyx_GIVEREF(__pyx_t_4);
            PyList_SET_ITEM(__pyx_t_6, 1, __pyx_t_4);
            __pyx_t_3 = 0;
            __pyx_t_4 = 0;
            __pyx_t_4 = PyFloat_FromDouble(__pyx_v_DPhi0); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 690, __pyx_L1_error)
            __Pyx_GOTREF(__pyx_t_4);
            __pyx_t_3 = PyFloat_FromDouble(__pyx_v_Phi1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 690, __pyx_L1_error)
            __Pyx_GOTREF(__pyx_t_3);
            __pyx_t_2 = PyList_New(2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 690, __pyx_L1_error)
            __Pyx_GOTREF(__pyx_t_2);
            __Pyx_GIVEREF(__pyx_t_4);
            PyList_SET_ITEM(__pyx_t_2, 0, __pyx_t_4);
            __Pyx_GIVEREF(__pyx_t_3);
            PyList_SET_ITEM(__pyx_t_2, 1, __pyx_t_3);
            __pyx_t_4 = 0;
            __pyx_t_3 = 0;
            __pyx_t_3 = PyList_New(2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 690, __pyx_L1_error)
            __Pyx_GOTREF(__pyx_t_3);
            __Pyx_GIVEREF(__pyx_t_6);
            PyList_SET_ITEM(__pyx_t_3, 0, __pyx_t_6);
            __Pyx_GIVEREF(__pyx_t_2);
            PyList_SET_ITEM(__pyx_t_3, 1, __pyx_t_2);
            __pyx_t_6 = 0;
            __pyx_t_2 = 0;
            __Pyx_DECREF_SET(__pyx_v_Bounds, __pyx_t_3);
            __pyx_t_3 = 0;
 691:                     else:
+692:                         Bounds = [[None,None]]
          /*else*/ {
            __pyx_t_3 = PyList_New(2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 692, __pyx_L1_error)
            __Pyx_GOTREF(__pyx_t_3);
            __Pyx_INCREF(Py_None);
            __Pyx_GIVEREF(Py_None);
            PyList_SET_ITEM(__pyx_t_3, 0, Py_None);
            __Pyx_INCREF(Py_None);
            __Pyx_GIVEREF(Py_None);
            PyList_SET_ITEM(__pyx_t_3, 1, Py_None);
            __pyx_t_2 = PyList_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 692, __pyx_L1_error)
            __Pyx_GOTREF(__pyx_t_2);
            __Pyx_GIVEREF(__pyx_t_3);
            PyList_SET_ITEM(__pyx_t_2, 0, __pyx_t_3);
            __pyx_t_3 = 0;
            __Pyx_DECREF_SET(__pyx_v_Bounds, __pyx_t_2);
            __pyx_t_2 = 0;
+693:                         if DPhi0<=Phi1:
            __pyx_t_1 = ((__pyx_v_DPhi0 <= __pyx_v_Phi1) != 0);
            if (__pyx_t_1) {
/* … */
              goto __pyx_L23;
            }
+694:                             Bounds[0][0] = DPhi0
              __pyx_t_2 = PyFloat_FromDouble(__pyx_v_DPhi0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 694, __pyx_L1_error)
              __Pyx_GOTREF(__pyx_t_2);
              __pyx_t_3 = __Pyx_GetItemInt(__pyx_v_Bounds, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 694, __pyx_L1_error)
              __Pyx_GOTREF(__pyx_t_3);
              if (unlikely(__Pyx_SetItemInt(__pyx_t_3, 0, __pyx_t_2, long, 1, __Pyx_PyInt_From_long, 0, 0, 1) < 0)) __PYX_ERR(0, 694, __pyx_L1_error)
              __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
              __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+695:                             Bounds[0][1] = Phi1 if DPhi1>=Phi1 else DPhi1
              if (((__pyx_v_DPhi1 >= __pyx_v_Phi1) != 0)) {
                __pyx_t_3 = PyFloat_FromDouble(__pyx_v_Phi1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 695, __pyx_L1_error)
                __Pyx_GOTREF(__pyx_t_3);
                __pyx_t_2 = __pyx_t_3;
                __pyx_t_3 = 0;
              } else {
                __pyx_t_3 = PyFloat_FromDouble(__pyx_v_DPhi1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 695, __pyx_L1_error)
                __Pyx_GOTREF(__pyx_t_3);
                __pyx_t_2 = __pyx_t_3;
                __pyx_t_3 = 0;
              }
              __pyx_t_3 = __Pyx_GetItemInt(__pyx_v_Bounds, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 695, __pyx_L1_error)
              __Pyx_GOTREF(__pyx_t_3);
              if (unlikely(__Pyx_SetItemInt(__pyx_t_3, 1, __pyx_t_2, long, 1, __Pyx_PyInt_From_long, 0, 0, 1) < 0)) __PYX_ERR(0, 695, __pyx_L1_error)
              __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
              __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
 696:                         else:
+697:                             Bounds[0][0] = Phi0 if DPhi0<=Phi0 else DPhi0
            /*else*/ {
              if (((__pyx_v_DPhi0 <= __pyx_v_Phi0) != 0)) {
                __pyx_t_3 = PyFloat_FromDouble(__pyx_v_Phi0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 697, __pyx_L1_error)
                __Pyx_GOTREF(__pyx_t_3);
                __pyx_t_2 = __pyx_t_3;
                __pyx_t_3 = 0;
              } else {
                __pyx_t_3 = PyFloat_FromDouble(__pyx_v_DPhi0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 697, __pyx_L1_error)
                __Pyx_GOTREF(__pyx_t_3);
                __pyx_t_2 = __pyx_t_3;
                __pyx_t_3 = 0;
              }
              __pyx_t_3 = __Pyx_GetItemInt(__pyx_v_Bounds, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 697, __pyx_L1_error)
              __Pyx_GOTREF(__pyx_t_3);
              if (unlikely(__Pyx_SetItemInt(__pyx_t_3, 0, __pyx_t_2, long, 1, __Pyx_PyInt_From_long, 0, 0, 1) < 0)) __PYX_ERR(0, 697, __pyx_L1_error)
              __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
              __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+698:                             Bounds[0][1] = DPhi1
              __pyx_t_2 = PyFloat_FromDouble(__pyx_v_DPhi1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 698, __pyx_L1_error)
              __Pyx_GOTREF(__pyx_t_2);
              __pyx_t_3 = __Pyx_GetItemInt(__pyx_v_Bounds, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 698, __pyx_L1_error)
              __Pyx_GOTREF(__pyx_t_3);
              if (unlikely(__Pyx_SetItemInt(__pyx_t_3, 1, __pyx_t_2, long, 1, __Pyx_PyInt_From_long, 0, 0, 1) < 0)) __PYX_ERR(0, 698, __pyx_L1_error)
              __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
              __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
            }
            __pyx_L23:;
          }
          __pyx_L20:;
 699:             else:
+700:                 Inter = True
      /*else*/ {
        __pyx_v_Inter = 1;
+701:                 if DPhi0>=Phi0 and DPhi1>=Phi0:
        __pyx_t_7 = ((__pyx_v_DPhi0 >= __pyx_v_Phi0) != 0);
        if (__pyx_t_7) {
        } else {
          __pyx_t_1 = __pyx_t_7;
          goto __pyx_L25_bool_binop_done;
        }
        __pyx_t_7 = ((__pyx_v_DPhi1 >= __pyx_v_Phi0) != 0);
        __pyx_t_1 = __pyx_t_7;
        __pyx_L25_bool_binop_done:;
        if (__pyx_t_1) {
/* … */
          goto __pyx_L24;
        }
+702:                     Bounds = [[Phi0,DPhi1],[DPhi0,Cpi],[-Cpi,Phi1]]
          __pyx_t_2 = PyFloat_FromDouble(__pyx_v_Phi0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 702, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_2);
          __pyx_t_3 = PyFloat_FromDouble(__pyx_v_DPhi1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 702, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_3);
          __pyx_t_6 = PyList_New(2); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 702, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_6);
          __Pyx_GIVEREF(__pyx_t_2);
          PyList_SET_ITEM(__pyx_t_6, 0, __pyx_t_2);
          __Pyx_GIVEREF(__pyx_t_3);
          PyList_SET_ITEM(__pyx_t_6, 1, __pyx_t_3);
          __pyx_t_2 = 0;
          __pyx_t_3 = 0;
          __pyx_t_3 = PyFloat_FromDouble(__pyx_v_DPhi0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 702, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_3);
          __pyx_t_2 = PyFloat_FromDouble(M_PI); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 702, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_2);
          __pyx_t_4 = PyList_New(2); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 702, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_4);
          __Pyx_GIVEREF(__pyx_t_3);
          PyList_SET_ITEM(__pyx_t_4, 0, __pyx_t_3);
          __Pyx_GIVEREF(__pyx_t_2);
          PyList_SET_ITEM(__pyx_t_4, 1, __pyx_t_2);
          __pyx_t_3 = 0;
          __pyx_t_2 = 0;
          __pyx_t_2 = PyFloat_FromDouble((-M_PI)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 702, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_2);
          __pyx_t_3 = PyFloat_FromDouble(__pyx_v_Phi1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 702, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_3);
          __pyx_t_5 = PyList_New(2); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 702, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_5);
          __Pyx_GIVEREF(__pyx_t_2);
          PyList_SET_ITEM(__pyx_t_5, 0, __pyx_t_2);
          __Pyx_GIVEREF(__pyx_t_3);
          PyList_SET_ITEM(__pyx_t_5, 1, __pyx_t_3);
          __pyx_t_2 = 0;
          __pyx_t_3 = 0;
          __pyx_t_3 = PyList_New(3); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 702, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_3);
          __Pyx_GIVEREF(__pyx_t_6);
          PyList_SET_ITEM(__pyx_t_3, 0, __pyx_t_6);
          __Pyx_GIVEREF(__pyx_t_4);
          PyList_SET_ITEM(__pyx_t_3, 1, __pyx_t_4);
          __Pyx_GIVEREF(__pyx_t_5);
          PyList_SET_ITEM(__pyx_t_3, 2, __pyx_t_5);
          __pyx_t_6 = 0;
          __pyx_t_4 = 0;
          __pyx_t_5 = 0;
          __Pyx_DECREF_SET(__pyx_v_Bounds, __pyx_t_3);
          __pyx_t_3 = 0;
+703:                 elif DPhi0<=Phi1 and DPhi1<=Phi1:
        __pyx_t_7 = ((__pyx_v_DPhi0 <= __pyx_v_Phi1) != 0);
        if (__pyx_t_7) {
        } else {
          __pyx_t_1 = __pyx_t_7;
          goto __pyx_L27_bool_binop_done;
        }
        __pyx_t_7 = ((__pyx_v_DPhi1 <= __pyx_v_Phi1) != 0);
        __pyx_t_1 = __pyx_t_7;
        __pyx_L27_bool_binop_done:;
        if (__pyx_t_1) {
/* … */
          goto __pyx_L24;
        }
+704:                     Bounds = [[Phi0,Cpi],[-Cpi,DPhi1],[DPhi0,Phi1]]
          __pyx_t_3 = PyFloat_FromDouble(__pyx_v_Phi0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 704, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_3);
          __pyx_t_5 = PyFloat_FromDouble(M_PI); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 704, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_5);
          __pyx_t_4 = PyList_New(2); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 704, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_4);
          __Pyx_GIVEREF(__pyx_t_3);
          PyList_SET_ITEM(__pyx_t_4, 0, __pyx_t_3);
          __Pyx_GIVEREF(__pyx_t_5);
          PyList_SET_ITEM(__pyx_t_4, 1, __pyx_t_5);
          __pyx_t_3 = 0;
          __pyx_t_5 = 0;
          __pyx_t_5 = PyFloat_FromDouble((-M_PI)); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 704, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_5);
          __pyx_t_3 = PyFloat_FromDouble(__pyx_v_DPhi1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 704, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_3);
          __pyx_t_6 = PyList_New(2); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 704, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_6);
          __Pyx_GIVEREF(__pyx_t_5);
          PyList_SET_ITEM(__pyx_t_6, 0, __pyx_t_5);
          __Pyx_GIVEREF(__pyx_t_3);
          PyList_SET_ITEM(__pyx_t_6, 1, __pyx_t_3);
          __pyx_t_5 = 0;
          __pyx_t_3 = 0;
          __pyx_t_3 = PyFloat_FromDouble(__pyx_v_DPhi0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 704, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_3);
          __pyx_t_5 = PyFloat_FromDouble(__pyx_v_Phi1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 704, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_5);
          __pyx_t_2 = PyList_New(2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 704, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_2);
          __Pyx_GIVEREF(__pyx_t_3);
          PyList_SET_ITEM(__pyx_t_2, 0, __pyx_t_3);
          __Pyx_GIVEREF(__pyx_t_5);
          PyList_SET_ITEM(__pyx_t_2, 1, __pyx_t_5);
          __pyx_t_3 = 0;
          __pyx_t_5 = 0;
          __pyx_t_5 = PyList_New(3); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 704, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_5);
          __Pyx_GIVEREF(__pyx_t_4);
          PyList_SET_ITEM(__pyx_t_5, 0, __pyx_t_4);
          __Pyx_GIVEREF(__pyx_t_6);
          PyList_SET_ITEM(__pyx_t_5, 1, __pyx_t_6);
          __Pyx_GIVEREF(__pyx_t_2);
          PyList_SET_ITEM(__pyx_t_5, 2, __pyx_t_2);
          __pyx_t_4 = 0;
          __pyx_t_6 = 0;
          __pyx_t_2 = 0;
          __Pyx_DECREF_SET(__pyx_v_Bounds, __pyx_t_5);
          __pyx_t_5 = 0;
 705:                 else:
+706:                     Bounds = [[None,Cpi],[-Cpi,None]]
        /*else*/ {
          __pyx_t_5 = PyFloat_FromDouble(M_PI); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 706, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_5);
          __pyx_t_2 = PyList_New(2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 706, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_2);
          __Pyx_INCREF(Py_None);
          __Pyx_GIVEREF(Py_None);
          PyList_SET_ITEM(__pyx_t_2, 0, Py_None);
          __Pyx_GIVEREF(__pyx_t_5);
          PyList_SET_ITEM(__pyx_t_2, 1, __pyx_t_5);
          __pyx_t_5 = 0;
          __pyx_t_5 = PyFloat_FromDouble((-M_PI)); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 706, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_5);
          __pyx_t_6 = PyList_New(2); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 706, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_6);
          __Pyx_GIVEREF(__pyx_t_5);
          PyList_SET_ITEM(__pyx_t_6, 0, __pyx_t_5);
          __Pyx_INCREF(Py_None);
          __Pyx_GIVEREF(Py_None);
          PyList_SET_ITEM(__pyx_t_6, 1, Py_None);
          __pyx_t_5 = 0;
          __pyx_t_5 = PyList_New(2); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 706, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_5);
          __Pyx_GIVEREF(__pyx_t_2);
          PyList_SET_ITEM(__pyx_t_5, 0, __pyx_t_2);
          __Pyx_GIVEREF(__pyx_t_6);
          PyList_SET_ITEM(__pyx_t_5, 1, __pyx_t_6);
          __pyx_t_2 = 0;
          __pyx_t_6 = 0;
          __Pyx_DECREF_SET(__pyx_v_Bounds, __pyx_t_5);
          __pyx_t_5 = 0;
+707:                     Bounds[0][0] = Phi0 if DPhi0<=Phi0 else DPhi0
          if (((__pyx_v_DPhi0 <= __pyx_v_Phi0) != 0)) {
            __pyx_t_6 = PyFloat_FromDouble(__pyx_v_Phi0); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 707, __pyx_L1_error)
            __Pyx_GOTREF(__pyx_t_6);
            __pyx_t_5 = __pyx_t_6;
            __pyx_t_6 = 0;
          } else {
            __pyx_t_6 = PyFloat_FromDouble(__pyx_v_DPhi0); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 707, __pyx_L1_error)
            __Pyx_GOTREF(__pyx_t_6);
            __pyx_t_5 = __pyx_t_6;
            __pyx_t_6 = 0;
          }
          __pyx_t_6 = __Pyx_GetItemInt(__pyx_v_Bounds, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 707, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_6);
          if (unlikely(__Pyx_SetItemInt(__pyx_t_6, 0, __pyx_t_5, long, 1, __Pyx_PyInt_From_long, 0, 0, 1) < 0)) __PYX_ERR(0, 707, __pyx_L1_error)
          __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
          __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
+708:                     Bounds[1][1] = Phi1 if DPhi1>=Phi1 else DPhi1
          if (((__pyx_v_DPhi1 >= __pyx_v_Phi1) != 0)) {
            __pyx_t_6 = PyFloat_FromDouble(__pyx_v_Phi1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 708, __pyx_L1_error)
            __Pyx_GOTREF(__pyx_t_6);
            __pyx_t_5 = __pyx_t_6;
            __pyx_t_6 = 0;
          } else {
            __pyx_t_6 = PyFloat_FromDouble(__pyx_v_DPhi1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 708, __pyx_L1_error)
            __Pyx_GOTREF(__pyx_t_6);
            __pyx_t_5 = __pyx_t_6;
            __pyx_t_6 = 0;
          }
          __pyx_t_6 = __Pyx_GetItemInt(__pyx_v_Bounds, 1, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 708, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_6);
          if (unlikely(__Pyx_SetItemInt(__pyx_t_6, 1, __pyx_t_5, long, 1, __Pyx_PyInt_From_long, 0, 0, 1) < 0)) __PYX_ERR(0, 708, __pyx_L1_error)
          __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
          __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
        }
        __pyx_L24:;
      }
      __pyx_L16:;
    }
    __pyx_L4:;
  }
  __pyx_L3:;
+709:     return Inter, Bounds
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_5 = __Pyx_PyBool_FromLong(__pyx_v_Inter); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 709, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_t_6 = PyTuple_New(2); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 709, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_GIVEREF(__pyx_t_5);
  PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_5);
  __Pyx_INCREF(__pyx_v_Bounds);
  __Pyx_GIVEREF(__pyx_v_Bounds);
  PyTuple_SET_ITEM(__pyx_t_6, 1, __pyx_v_Bounds);
  __pyx_t_5 = 0;
  __pyx_r = __pyx_t_6;
  __pyx_t_6 = 0;
  goto __pyx_L0;
 710: 
 711: 
 712: 
 713: 
 714: 
 715: @cython.cdivision(True)
 716: @cython.wraparound(False)
 717: @cython.boundscheck(False)
+718: def _Ves_Smesh_Tor_SubFromD_bis(double dL, double dRPhi,
/* Python wrapper */
static PyObject *__pyx_pw_46_cython_magic_8152fc40fb05daa7217c00b66474f995_19_Ves_Smesh_Tor_SubFromD_bis(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_46_cython_magic_8152fc40fb05daa7217c00b66474f995_18_Ves_Smesh_Tor_SubFromD_bis[] = " Return the desired surfacic submesh indicated by the limits (DR,DZ,DPhi), for the desired resolution (dR,dZ,dRphi) ";
static PyMethodDef __pyx_mdef_46_cython_magic_8152fc40fb05daa7217c00b66474f995_19_Ves_Smesh_Tor_SubFromD_bis = {"_Ves_Smesh_Tor_SubFromD_bis", (PyCFunction)__pyx_pw_46_cython_magic_8152fc40fb05daa7217c00b66474f995_19_Ves_Smesh_Tor_SubFromD_bis, METH_VARARGS|METH_KEYWORDS, __pyx_doc_46_cython_magic_8152fc40fb05daa7217c00b66474f995_18_Ves_Smesh_Tor_SubFromD_bis};
static PyObject *__pyx_pw_46_cython_magic_8152fc40fb05daa7217c00b66474f995_19_Ves_Smesh_Tor_SubFromD_bis(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  double __pyx_v_dL;
  double __pyx_v_dRPhi;
  __Pyx_memviewslice __pyx_v_VPoly = { 0, 0, { 0 }, { 0 }, { 0 } };
  PyObject *__pyx_v_DR = 0;
  PyObject *__pyx_v_DZ = 0;
  PyObject *__pyx_v_DPhi = 0;
  double __pyx_v_DIn;
  PyObject *__pyx_v_VIn = 0;
  PyObject *__pyx_v_PhiMinMax = 0;
  PyObject *__pyx_v_Out = 0;
  double __pyx_v_margin;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("_Ves_Smesh_Tor_SubFromD_bis (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_dL,&__pyx_n_s_dRPhi,&__pyx_n_s_VPoly,&__pyx_n_s_DR,&__pyx_n_s_DZ,&__pyx_n_s_DPhi,&__pyx_n_s_DIn,&__pyx_n_s_VIn,&__pyx_n_s_PhiMinMax,&__pyx_n_s_Out,&__pyx_n_s_margin,0};
    PyObject* values[11] = {0,0,0,0,0,0,0,0,0,0,0};
/* … */
  /* function exit code */
  goto __pyx_L0;
  __pyx_L1_error:;
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_46_cython_magic_8152fc40fb05daa7217c00b66474f995_18_Ves_Smesh_Tor_SubFromD_bis(CYTHON_UNUSED PyObject *__pyx_self, double __pyx_v_dL, double __pyx_v_dRPhi, __Pyx_memviewslice __pyx_v_VPoly, PyObject *__pyx_v_DR, PyObject *__pyx_v_DZ, PyObject *__pyx_v_DPhi, double __pyx_v_DIn, PyObject *__pyx_v_VIn, PyObject *__pyx_v_PhiMinMax, PyObject *__pyx_v_Out, double __pyx_v_margin) {
  __Pyx_memviewslice __pyx_v_dPhir = { 0, 0, { 0 }, { 0 }, { 0 } };
  __Pyx_memviewslice __pyx_v_NRPhi = { 0, 0, { 0 }, { 0 }, { 0 } };
  double __pyx_v_DPhi0;
  double __pyx_v_DPhi1;
  CYTHON_UNUSED double __pyx_v_DDPhi;
  double __pyx_v_DPhiMinMax;
  double __pyx_v_abs0;
  double __pyx_v_abs1;
  double __pyx_v_phi;
  double __pyx_v_indiijj;
  __Pyx_memviewslice __pyx_v_Phin = { 0, 0, { 0 }, { 0 }, { 0 } };
  __Pyx_memviewslice __pyx_v_NRPhi0 = { 0, 0, { 0 }, { 0 }, { 0 } };
  __Pyx_memviewslice __pyx_v_Indin = { 0, 0, { 0 }, { 0 }, { 0 } };
  int __pyx_v_NR0;
  int __pyx_v_nRPhi0;
  int __pyx_v_indR0ii;
  int __pyx_v_ii;
  int __pyx_v_jj0;
  int __pyx_v_jj;
  int __pyx_v_nPhi0;
  int __pyx_v_nPhi1;
  int __pyx_v_NP;
  CYTHON_UNUSED int __pyx_v_NRPhi_int;
  int __pyx_v_Rratio;
  int __pyx_v_Ln;
  PyArrayObject *__pyx_v_Pts = 0;
  PyArrayObject *__pyx_v_indI = 0;
  PyArrayObject *__pyx_v_PtsCross = 0;
  PyArrayObject *__pyx_v_VPbis = 0;
  PyArrayObject *__pyx_v_R0 = 0;
  PyArrayObject *__pyx_v_dS = 0;
  PyArrayObject *__pyx_v_ind = 0;
  PyArrayObject *__pyx_v_dLr = 0;
  PyArrayObject *__pyx_v_Rref = 0;
  PyArrayObject *__pyx_v_dRPhir = 0;
  PyArrayObject *__pyx_v_indL = 0;
  PyArrayObject *__pyx_v_NL = 0;
  int __pyx_v_Full;
  PyObject *__pyx_v_Inter = NULL;
  PyObject *__pyx_v_Bounds = NULL;
  PyObject *__pyx_v_BC = NULL;
  Py_ssize_t __pyx_v_nBounds;
  PyObject *__pyx_v_indin = NULL;
  CYTHON_UNUSED long __pyx_v_NPhimax;
  PyObject *__pyx_v_indBounds = NULL;
  Py_ssize_t __pyx_v_kk;
  PyObject *__pyx_v_kkb = NULL;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_NL;
  __Pyx_Buffer __pyx_pybuffer_NL;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_Pts;
  __Pyx_Buffer __pyx_pybuffer_Pts;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_PtsCross;
  __Pyx_Buffer __pyx_pybuffer_PtsCross;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_R0;
  __Pyx_Buffer __pyx_pybuffer_R0;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_Rref;
  __Pyx_Buffer __pyx_pybuffer_Rref;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_VPbis;
  __Pyx_Buffer __pyx_pybuffer_VPbis;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_dLr;
  __Pyx_Buffer __pyx_pybuffer_dLr;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_dRPhir;
  __Pyx_Buffer __pyx_pybuffer_dRPhir;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_dS;
  __Pyx_Buffer __pyx_pybuffer_dS;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_ind;
  __Pyx_Buffer __pyx_pybuffer_ind;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_indI;
  __Pyx_Buffer __pyx_pybuffer_indI;
  __Pyx_LocalBuf_ND __pyx_pybuffernd_indL;
  __Pyx_Buffer __pyx_pybuffer_indL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("_Ves_Smesh_Tor_SubFromD_bis", 0);
  __Pyx_INCREF(__pyx_v_PhiMinMax);
  __pyx_pybuffer_Pts.pybuffer.buf = NULL;
  __pyx_pybuffer_Pts.refcount = 0;
  __pyx_pybuffernd_Pts.data = NULL;
  __pyx_pybuffernd_Pts.rcbuffer = &__pyx_pybuffer_Pts;
  __pyx_pybuffer_indI.pybuffer.buf = NULL;
  __pyx_pybuffer_indI.refcount = 0;
  __pyx_pybuffernd_indI.data = NULL;
  __pyx_pybuffernd_indI.rcbuffer = &__pyx_pybuffer_indI;
  __pyx_pybuffer_PtsCross.pybuffer.buf = NULL;
  __pyx_pybuffer_PtsCross.refcount = 0;
  __pyx_pybuffernd_PtsCross.data = NULL;
  __pyx_pybuffernd_PtsCross.rcbuffer = &__pyx_pybuffer_PtsCross;
  __pyx_pybuffer_VPbis.pybuffer.buf = NULL;
  __pyx_pybuffer_VPbis.refcount = 0;
  __pyx_pybuffernd_VPbis.data = NULL;
  __pyx_pybuffernd_VPbis.rcbuffer = &__pyx_pybuffer_VPbis;
  __pyx_pybuffer_R0.pybuffer.buf = NULL;
  __pyx_pybuffer_R0.refcount = 0;
  __pyx_pybuffernd_R0.data = NULL;
  __pyx_pybuffernd_R0.rcbuffer = &__pyx_pybuffer_R0;
  __pyx_pybuffer_dS.pybuffer.buf = NULL;
  __pyx_pybuffer_dS.refcount = 0;
  __pyx_pybuffernd_dS.data = NULL;
  __pyx_pybuffernd_dS.rcbuffer = &__pyx_pybuffer_dS;
  __pyx_pybuffer_ind.pybuffer.buf = NULL;
  __pyx_pybuffer_ind.refcount = 0;
  __pyx_pybuffernd_ind.data = NULL;
  __pyx_pybuffernd_ind.rcbuffer = &__pyx_pybuffer_ind;
  __pyx_pybuffer_dLr.pybuffer.buf = NULL;
  __pyx_pybuffer_dLr.refcount = 0;
  __pyx_pybuffernd_dLr.data = NULL;
  __pyx_pybuffernd_dLr.rcbuffer = &__pyx_pybuffer_dLr;
  __pyx_pybuffer_Rref.pybuffer.buf = NULL;
  __pyx_pybuffer_Rref.refcount = 0;
  __pyx_pybuffernd_Rref.data = NULL;
  __pyx_pybuffernd_Rref.rcbuffer = &__pyx_pybuffer_Rref;
  __pyx_pybuffer_dRPhir.pybuffer.buf = NULL;
  __pyx_pybuffer_dRPhir.refcount = 0;
  __pyx_pybuffernd_dRPhir.data = NULL;
  __pyx_pybuffernd_dRPhir.rcbuffer = &__pyx_pybuffer_dRPhir;
  __pyx_pybuffer_indL.pybuffer.buf = NULL;
  __pyx_pybuffer_indL.refcount = 0;
  __pyx_pybuffernd_indL.data = NULL;
  __pyx_pybuffernd_indL.rcbuffer = &__pyx_pybuffer_indL;
  __pyx_pybuffer_NL.pybuffer.buf = NULL;
  __pyx_pybuffer_NL.refcount = 0;
  __pyx_pybuffernd_NL.data = NULL;
  __pyx_pybuffernd_NL.rcbuffer = &__pyx_pybuffer_NL;
/* … */
  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_9);
  __Pyx_XDECREF(__pyx_t_10);
  __Pyx_XDECREF(__pyx_t_11);
  __Pyx_XDECREF(__pyx_t_12);
  __Pyx_XDECREF(__pyx_t_13);
  __Pyx_XDECREF(__pyx_t_15);
  __PYX_XDEC_MEMVIEW(&__pyx_t_25, 1);
  __PYX_XDEC_MEMVIEW(&__pyx_t_26, 1);
  { PyObject *__pyx_type, *__pyx_value, *__pyx_tb;
    __Pyx_PyThreadState_declare
    __Pyx_PyThreadState_assign
    __Pyx_ErrFetch(&__pyx_type, &__pyx_value, &__pyx_tb);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_NL.rcbuffer->pybuffer);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_Pts.rcbuffer->pybuffer);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_PtsCross.rcbuffer->pybuffer);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_R0.rcbuffer->pybuffer);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_Rref.rcbuffer->pybuffer);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_VPbis.rcbuffer->pybuffer);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_dLr.rcbuffer->pybuffer);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_dRPhir.rcbuffer->pybuffer);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_dS.rcbuffer->pybuffer);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_ind.rcbuffer->pybuffer);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_indI.rcbuffer->pybuffer);
    __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_indL.rcbuffer->pybuffer);
  __Pyx_ErrRestore(__pyx_type, __pyx_value, __pyx_tb);}
  __Pyx_AddTraceback("_cython_magic_8152fc40fb05daa7217c00b66474f995._Ves_Smesh_Tor_SubFromD_bis", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  goto __pyx_L2;
  __pyx_L0:;
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_NL.rcbuffer->pybuffer);
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_Pts.rcbuffer->pybuffer);
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_PtsCross.rcbuffer->pybuffer);
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_R0.rcbuffer->pybuffer);
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_Rref.rcbuffer->pybuffer);
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_VPbis.rcbuffer->pybuffer);
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_dLr.rcbuffer->pybuffer);
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_dRPhir.rcbuffer->pybuffer);
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_dS.rcbuffer->pybuffer);
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_ind.rcbuffer->pybuffer);
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_indI.rcbuffer->pybuffer);
  __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_indL.rcbuffer->pybuffer);
  __pyx_L2:;
  __PYX_XDEC_MEMVIEW(&__pyx_v_dPhir, 1);
  __PYX_XDEC_MEMVIEW(&__pyx_v_NRPhi, 1);
  __PYX_XDEC_MEMVIEW(&__pyx_v_Phin, 1);
  __PYX_XDEC_MEMVIEW(&__pyx_v_NRPhi0, 1);
  __PYX_XDEC_MEMVIEW(&__pyx_v_Indin, 1);
  __Pyx_XDECREF((PyObject *)__pyx_v_Pts);
  __Pyx_XDECREF((PyObject *)__pyx_v_indI);
  __Pyx_XDECREF((PyObject *)__pyx_v_PtsCross);
  __Pyx_XDECREF((PyObject *)__pyx_v_VPbis);
  __Pyx_XDECREF((PyObject *)__pyx_v_R0);
  __Pyx_XDECREF((PyObject *)__pyx_v_dS);
  __Pyx_XDECREF((PyObject *)__pyx_v_ind);
  __Pyx_XDECREF((PyObject *)__pyx_v_dLr);
  __Pyx_XDECREF((PyObject *)__pyx_v_Rref);
  __Pyx_XDECREF((PyObject *)__pyx_v_dRPhir);
  __Pyx_XDECREF((PyObject *)__pyx_v_indL);
  __Pyx_XDECREF((PyObject *)__pyx_v_NL);
  __Pyx_XDECREF(__pyx_v_Inter);
  __Pyx_XDECREF(__pyx_v_Bounds);
  __Pyx_XDECREF(__pyx_v_BC);
  __Pyx_XDECREF(__pyx_v_indin);
  __Pyx_XDECREF(__pyx_v_indBounds);
  __Pyx_XDECREF(__pyx_v_kkb);
  __PYX_XDEC_MEMVIEW(&__pyx_v_VPoly, 1);
  __Pyx_XDECREF(__pyx_v_PhiMinMax);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}
/* … */
  __pyx_tuple__123 = PyTuple_Pack(71, __pyx_n_s_dL, __pyx_n_s_dRPhi, __pyx_n_s_VPoly, __pyx_n_s_DR, __pyx_n_s_DZ, __pyx_n_s_DPhi, __pyx_n_s_DIn, __pyx_n_s_VIn, __pyx_n_s_PhiMinMax, __pyx_n_s_Out, __pyx_n_s_margin, __pyx_n_s_R, __pyx_n_s_Z, __pyx_n_s_dPhir, __pyx_n_s_NRPhi, __pyx_n_s_dRr0, __pyx_n_s_dRr, __pyx_n_s_dZr, __pyx_n_s_DPhi0, __pyx_n_s_DPhi1, __pyx_n_s_DDPhi, __pyx_n_s_DPhiMinMax, __pyx_n_s_abs0, __pyx_n_s_abs1, __pyx_n_s_phi, __pyx_n_s_indiijj, __pyx_n_s_indR0, __pyx_n_s_indR, __pyx_n_s_indZ, __pyx_n_s_Phin, __pyx_n_s_NRPhi0, __pyx_n_s_Indin, __pyx_n_s_NR0, __pyx_n_s_NR, __pyx_n_s_NZ, __pyx_n_s_Rn, __pyx_n_s_Zn, __pyx_n_s_nRPhi0, __pyx_n_s_indR0ii, __pyx_n_s_ii, __pyx_n_s_jj0, __pyx_n_s_jj, __pyx_n_s_nPhi0, __pyx_n_s_nPhi1, __pyx_n_s_zz, __pyx_n_s_NP, __pyx_n_s_NRPhi_int, __pyx_n_s_Rratio, __pyx_n_s_Ln, __pyx_n_s_Pts, __pyx_n_s_indI, __pyx_n_s_PtsCross, __pyx_n_s_VPbis, __pyx_n_s_R0, __pyx_n_s_dS, __pyx_n_s_ind, __pyx_n_s_dLr, __pyx_n_s_Rref, __pyx_n_s_dRPhir, __pyx_n_s_indL, __pyx_n_s_NL, __pyx_n_s_Full, __pyx_n_s_Inter, __pyx_n_s_Bounds, __pyx_n_s_BC, __pyx_n_s_nBounds, __pyx_n_s_indin, __pyx_n_s_NPhimax, __pyx_n_s_indBounds, __pyx_n_s_kk, __pyx_n_s_kkb); if (unlikely(!__pyx_tuple__123)) __PYX_ERR(0, 718, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__123);
  __Pyx_GIVEREF(__pyx_tuple__123);
/* … */
  __pyx_t_2 = PyCFunction_NewEx(&__pyx_mdef_46_cython_magic_8152fc40fb05daa7217c00b66474f995_19_Ves_Smesh_Tor_SubFromD_bis, NULL, __pyx_n_s_cython_magic_8152fc40fb05daa721); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 718, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_Ves_Smesh_Tor_SubFromD_bis, __pyx_t_2) < 0) __PYX_ERR(0, 718, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_codeobj__124 = (PyObject*)__Pyx_PyCode_New(11, 0, 71, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__123, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_Home_DV226270_cache_ipython_cyt, __pyx_n_s_Ves_Smesh_Tor_SubFromD_bis, 718, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__124)) __PYX_ERR(0, 718, __pyx_L1_error)
 719:                                    double[:,::1] VPoly,
+720:                                    DR=None, DZ=None, DPhi=None,
    values[3] = ((PyObject *)Py_None);
    values[4] = ((PyObject *)Py_None);
    values[5] = ((PyObject *)Py_None);
+721:                                    double DIn=0., VIn=None, PhiMinMax=None,
    values[7] = ((PyObject *)Py_None);
    values[8] = ((PyObject *)Py_None);
    values[9] = ((PyObject*)__pyx_kp_u_X_Y_Z);
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case 11: values[10] = PyTuple_GET_ITEM(__pyx_args, 10);
        case 10: values[9] = PyTuple_GET_ITEM(__pyx_args, 9);
        case  9: values[8] = PyTuple_GET_ITEM(__pyx_args, 8);
        case  8: values[7] = PyTuple_GET_ITEM(__pyx_args, 7);
        case  7: values[6] = PyTuple_GET_ITEM(__pyx_args, 6);
        case  6: values[5] = PyTuple_GET_ITEM(__pyx_args, 5);
        case  5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_dL)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        case  1:
        if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_dRPhi)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_Ves_Smesh_Tor_SubFromD_bis", 0, 3, 11, 1); __PYX_ERR(0, 718, __pyx_L3_error)
        }
        case  2:
        if (likely((values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_VPoly)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("_Ves_Smesh_Tor_SubFromD_bis", 0, 3, 11, 2); __PYX_ERR(0, 718, __pyx_L3_error)
        }
        case  3:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_DR);
          if (value) { values[3] = value; kw_args--; }
        }
        case  4:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_DZ);
          if (value) { values[4] = value; kw_args--; }
        }
        case  5:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_DPhi);
          if (value) { values[5] = value; kw_args--; }
        }
        case  6:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_DIn);
          if (value) { values[6] = value; kw_args--; }
        }
        case  7:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_VIn);
          if (value) { values[7] = value; kw_args--; }
        }
        case  8:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_PhiMinMax);
          if (value) { values[8] = value; kw_args--; }
        }
        case  9:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_Out);
          if (value) { values[9] = value; kw_args--; }
        }
        case 10:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_margin);
          if (value) { values[10] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "_Ves_Smesh_Tor_SubFromD_bis") < 0)) __PYX_ERR(0, 718, __pyx_L3_error)
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case 11: values[10] = PyTuple_GET_ITEM(__pyx_args, 10);
        case 10: values[9] = PyTuple_GET_ITEM(__pyx_args, 9);
        case  9: values[8] = PyTuple_GET_ITEM(__pyx_args, 8);
        case  8: values[7] = PyTuple_GET_ITEM(__pyx_args, 7);
        case  7: values[6] = PyTuple_GET_ITEM(__pyx_args, 6);
        case  6: values[5] = PyTuple_GET_ITEM(__pyx_args, 5);
        case  5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    __pyx_v_dL = __pyx_PyFloat_AsDouble(values[0]); if (unlikely((__pyx_v_dL == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 718, __pyx_L3_error)
    __pyx_v_dRPhi = __pyx_PyFloat_AsDouble(values[1]); if (unlikely((__pyx_v_dRPhi == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 718, __pyx_L3_error)
    __pyx_v_VPoly = __Pyx_PyObject_to_MemoryviewSlice_d_dc_double(values[2]); if (unlikely(!__pyx_v_VPoly.memview)) __PYX_ERR(0, 719, __pyx_L3_error)
    __pyx_v_DR = values[3];
    __pyx_v_DZ = values[4];
    __pyx_v_DPhi = values[5];
    if (values[6]) {
      __pyx_v_DIn = __pyx_PyFloat_AsDouble(values[6]); if (unlikely((__pyx_v_DIn == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 721, __pyx_L3_error)
    } else {
      __pyx_v_DIn = ((double)0.);
    }
    __pyx_v_VIn = values[7];
    __pyx_v_PhiMinMax = values[8];
    __pyx_v_Out = ((PyObject*)values[9]);
    if (values[10]) {
      __pyx_v_margin = __pyx_PyFloat_AsDouble(values[10]); if (unlikely((__pyx_v_margin == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 722, __pyx_L3_error)
    } else {
      __pyx_v_margin = ((double)1.e-9);
    }
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("_Ves_Smesh_Tor_SubFromD_bis", 0, 3, 11, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 718, __pyx_L3_error)
  __pyx_L3_error:;
  __Pyx_AddTraceback("_cython_magic_8152fc40fb05daa7217c00b66474f995._Ves_Smesh_Tor_SubFromD_bis", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_Out), (&PyUnicode_Type), 1, "Out", 1))) __PYX_ERR(0, 722, __pyx_L1_error)
  __pyx_r = __pyx_pf_46_cython_magic_8152fc40fb05daa7217c00b66474f995_18_Ves_Smesh_Tor_SubFromD_bis(__pyx_self, __pyx_v_dL, __pyx_v_dRPhi, __pyx_v_VPoly, __pyx_v_DR, __pyx_v_DZ, __pyx_v_DPhi, __pyx_v_DIn, __pyx_v_VIn, __pyx_v_PhiMinMax, __pyx_v_Out, __pyx_v_margin);
 722:                                    str Out='(X,Y,Z)', double margin=1.e-9):
 723:     " Return the desired surfacic submesh indicated by the limits (DR,DZ,DPhi), for the desired resolution (dR,dZ,dRphi) "
 724:     cdef double[::1] R, Z, dPhir, NRPhi#, dPhi, NRZPhi_cum0, indPhi, phi
 725:     cdef double dRr0, dRr, dZr, DPhi0, DPhi1, DDPhi, DPhiMinMax
 726:     cdef double abs0, abs1, phi, indiijj
 727:     cdef long[::1] indR0, indR, indZ, Phin, NRPhi0, Indin
+728:     cdef int NR0, NR, NZ, Rn, Zn, nRPhi0, indR0ii, ii, jj0=0, jj, nPhi0, nPhi1, zz, NP, NRPhi_int, Rratio, Ln
  __pyx_v_jj0 = 0;
 729:     cdef cnp.ndarray[double,ndim=2] Pts, indI, PtsCross, VPbis
 730:     cdef cnp.ndarray[double,ndim=1] R0, dS, ind, dLr, Rref, dRPhir
 731:     cdef cnp.ndarray[long,ndim=1] indL, NL
 732: 
 733:     # Pre-format input
+734:     if PhiMinMax is None:
  __pyx_t_1 = (__pyx_v_PhiMinMax == Py_None);
  __pyx_t_2 = (__pyx_t_1 != 0);
  if (__pyx_t_2) {
/* … */
    goto __pyx_L3;
  }
+735:         PhiMinMax = [-Cpi,Cpi]
    __pyx_t_3 = PyFloat_FromDouble((-M_PI)); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 735, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_4 = PyFloat_FromDouble(M_PI); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 735, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_5 = PyList_New(2); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 735, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_GIVEREF(__pyx_t_3);
    PyList_SET_ITEM(__pyx_t_5, 0, __pyx_t_3);
    __Pyx_GIVEREF(__pyx_t_4);
    PyList_SET_ITEM(__pyx_t_5, 1, __pyx_t_4);
    __pyx_t_3 = 0;
    __pyx_t_4 = 0;
    __Pyx_DECREF_SET(__pyx_v_PhiMinMax, __pyx_t_5);
    __pyx_t_5 = 0;
+736:         DPhiMinMax = 2.*Cpi
    __pyx_v_DPhiMinMax = (2. * M_PI);
+737:         Full = True
    __pyx_v_Full = 1;
 738:     else:
+739:         PhiMinMax = [Catan2(Csin(PhiMinMax[0]),Ccos(PhiMinMax[0])), Catan2(Csin(PhiMinMax[1]),Ccos(PhiMinMax[1]))]
  /*else*/ {
    __pyx_t_5 = __Pyx_GetItemInt(__pyx_v_PhiMinMax, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 0); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 739, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_6 = __pyx_PyFloat_AsDouble(__pyx_t_5); if (unlikely((__pyx_t_6 == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 739, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __pyx_t_5 = __Pyx_GetItemInt(__pyx_v_PhiMinMax, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 0); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 739, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_7 = __pyx_PyFloat_AsDouble(__pyx_t_5); if (unlikely((__pyx_t_7 == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 739, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __pyx_t_5 = PyFloat_FromDouble(atan2(sin(__pyx_t_6), cos(__pyx_t_7))); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 739, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_4 = __Pyx_GetItemInt(__pyx_v_PhiMinMax, 1, long, 1, __Pyx_PyInt_From_long, 0, 0, 0); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 739, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_7 = __pyx_PyFloat_AsDouble(__pyx_t_4); if (unlikely((__pyx_t_7 == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 739, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_t_4 = __Pyx_GetItemInt(__pyx_v_PhiMinMax, 1, long, 1, __Pyx_PyInt_From_long, 0, 0, 0); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 739, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_6 = __pyx_PyFloat_AsDouble(__pyx_t_4); if (unlikely((__pyx_t_6 == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 739, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_t_4 = PyFloat_FromDouble(atan2(sin(__pyx_t_7), cos(__pyx_t_6))); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 739, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_3 = PyList_New(2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 739, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_GIVEREF(__pyx_t_5);
    PyList_SET_ITEM(__pyx_t_3, 0, __pyx_t_5);
    __Pyx_GIVEREF(__pyx_t_4);
    PyList_SET_ITEM(__pyx_t_3, 1, __pyx_t_4);
    __pyx_t_5 = 0;
    __pyx_t_4 = 0;
    __Pyx_DECREF_SET(__pyx_v_PhiMinMax, __pyx_t_3);
    __pyx_t_3 = 0;
+740:         DPhiMinMax = PhiMinMax[1]-PhiMinMax[0] if PhiMinMax[1]>=PhiMinMax[0] else 2.*Cpi + PhiMinMax[1] - PhiMinMax[0]
    __pyx_t_3 = __Pyx_GetItemInt(__pyx_v_PhiMinMax, 1, long, 1, __Pyx_PyInt_From_long, 0, 0, 0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 740, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_4 = __Pyx_GetItemInt(__pyx_v_PhiMinMax, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 0); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 740, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_5 = PyObject_RichCompare(__pyx_t_3, __pyx_t_4, Py_GE); __Pyx_XGOTREF(__pyx_t_5); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 740, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_5); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(0, 740, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    if (__pyx_t_2) {
      __pyx_t_5 = __Pyx_GetItemInt(__pyx_v_PhiMinMax, 1, long, 1, __Pyx_PyInt_From_long, 0, 0, 0); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 740, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
      __pyx_t_4 = __Pyx_GetItemInt(__pyx_v_PhiMinMax, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 0); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 740, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_t_3 = PyNumber_Subtract(__pyx_t_5, __pyx_t_4); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 740, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __pyx_t_7 = __pyx_PyFloat_AsDouble(__pyx_t_3); if (unlikely((__pyx_t_7 == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 740, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __pyx_t_6 = __pyx_t_7;
    } else {
      __pyx_t_3 = PyFloat_FromDouble((2. * M_PI)); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 740, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_4 = __Pyx_GetItemInt(__pyx_v_PhiMinMax, 1, long, 1, __Pyx_PyInt_From_long, 0, 0, 0); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 740, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_t_5 = PyNumber_Add(__pyx_t_3, __pyx_t_4); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 740, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __pyx_t_4 = __Pyx_GetItemInt(__pyx_v_PhiMinMax, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 0); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 740, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_t_3 = PyNumber_Subtract(__pyx_t_5, __pyx_t_4); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 740, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __pyx_t_7 = __pyx_PyFloat_AsDouble(__pyx_t_3); if (unlikely((__pyx_t_7 == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 740, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __pyx_t_6 = __pyx_t_7;
    }
    __pyx_v_DPhiMinMax = __pyx_t_6;
+741:         Full = False
    __pyx_v_Full = 0;
  }
  __pyx_L3:;
 742: 
 743:     # Get the limits if any (and make sure to replace them in the proper quadrants)
+744:     if DPhi is None:
  __pyx_t_2 = (__pyx_v_DPhi == Py_None);
  __pyx_t_1 = (__pyx_t_2 != 0);
  if (__pyx_t_1) {
/* … */
    goto __pyx_L4;
  }
+745:         DPhi0, DPhi1 = PhiMinMax[0], PhiMinMax[1]
    __pyx_t_3 = __Pyx_GetItemInt(__pyx_v_PhiMinMax, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 745, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_6 = __pyx_PyFloat_AsDouble(__pyx_t_3); if (unlikely((__pyx_t_6 == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 745, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_t_3 = __Pyx_GetItemInt(__pyx_v_PhiMinMax, 1, long, 1, __Pyx_PyInt_From_long, 0, 0, 0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 745, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_7 = __pyx_PyFloat_AsDouble(__pyx_t_3); if (unlikely((__pyx_t_7 == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 745, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_v_DPhi0 = __pyx_t_6;
    __pyx_v_DPhi1 = __pyx_t_7;
 746:     else:
+747:         DPhi0 = PhiMinMax[0] if DPhi[0] is None else Catan2(Csin(DPhi[0]),Ccos(DPhi[0]))
  /*else*/ {
    __pyx_t_3 = __Pyx_GetItemInt(__pyx_v_DPhi, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 747, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_1 = (__pyx_t_3 == Py_None);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    if ((__pyx_t_1 != 0)) {
      __pyx_t_3 = __Pyx_GetItemInt(__pyx_v_PhiMinMax, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 747, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_6 = __pyx_PyFloat_AsDouble(__pyx_t_3); if (unlikely((__pyx_t_6 == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 747, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __pyx_t_7 = __pyx_t_6;
    } else {
      __pyx_t_3 = __Pyx_GetItemInt(__pyx_v_DPhi, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 747, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_6 = __pyx_PyFloat_AsDouble(__pyx_t_3); if (unlikely((__pyx_t_6 == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 747, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __pyx_t_3 = __Pyx_GetItemInt(__pyx_v_DPhi, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 747, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_8 = __pyx_PyFloat_AsDouble(__pyx_t_3); if (unlikely((__pyx_t_8 == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 747, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __pyx_t_7 = atan2(sin(__pyx_t_6), cos(__pyx_t_8));
    }
    __pyx_v_DPhi0 = __pyx_t_7;
+748:         DPhi1 = PhiMinMax[1] if DPhi[1] is None else Catan2(Csin(DPhi[1]),Ccos(DPhi[1]))
    __pyx_t_3 = __Pyx_GetItemInt(__pyx_v_DPhi, 1, long, 1, __Pyx_PyInt_From_long, 0, 0, 0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 748, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_1 = (__pyx_t_3 == Py_None);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    if ((__pyx_t_1 != 0)) {
      __pyx_t_3 = __Pyx_GetItemInt(__pyx_v_PhiMinMax, 1, long, 1, __Pyx_PyInt_From_long, 0, 0, 0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 748, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_8 = __pyx_PyFloat_AsDouble(__pyx_t_3); if (unlikely((__pyx_t_8 == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 748, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __pyx_t_7 = __pyx_t_8;
    } else {
      __pyx_t_3 = __Pyx_GetItemInt(__pyx_v_DPhi, 1, long, 1, __Pyx_PyInt_From_long, 0, 0, 0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 748, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_8 = __pyx_PyFloat_AsDouble(__pyx_t_3); if (unlikely((__pyx_t_8 == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 748, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __pyx_t_3 = __Pyx_GetItemInt(__pyx_v_DPhi, 1, long, 1, __Pyx_PyInt_From_long, 0, 0, 0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 748, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_6 = __pyx_PyFloat_AsDouble(__pyx_t_3); if (unlikely((__pyx_t_6 == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 748, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __pyx_t_7 = atan2(sin(__pyx_t_8), cos(__pyx_t_6));
    }
    __pyx_v_DPhi1 = __pyx_t_7;
  }
  __pyx_L4:;
+749:     DDPhi = DPhi1-DPhi0 if DPhi1>DPhi0 else 2.*Cpi+DPhi1-DPhi0
  if (((__pyx_v_DPhi1 > __pyx_v_DPhi0) != 0)) {
    __pyx_t_7 = (__pyx_v_DPhi1 - __pyx_v_DPhi0);
  } else {
    __pyx_t_7 = (((2. * M_PI) + __pyx_v_DPhi1) - __pyx_v_DPhi0);
  }
  __pyx_v_DDPhi = __pyx_t_7;
 750: 
+751:     Inter, Bounds = _getBoundsInter2AngSeg(Full, PhiMinMax[0], PhiMinMax[1], DPhi0, DPhi1)
  __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_getBoundsInter2AngSeg); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 751, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_5 = __Pyx_PyBool_FromLong(__pyx_v_Full); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 751, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_t_9 = __Pyx_GetItemInt(__pyx_v_PhiMinMax, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 0); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 751, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_9);
  __pyx_t_10 = __Pyx_GetItemInt(__pyx_v_PhiMinMax, 1, long, 1, __Pyx_PyInt_From_long, 0, 0, 0); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 751, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_10);
  __pyx_t_11 = PyFloat_FromDouble(__pyx_v_DPhi0); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 751, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_11);
  __pyx_t_12 = PyFloat_FromDouble(__pyx_v_DPhi1); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 751, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_12);
  __pyx_t_13 = NULL;
  __pyx_t_14 = 0;
  if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_4))) {
    __pyx_t_13 = PyMethod_GET_SELF(__pyx_t_4);
    if (likely(__pyx_t_13)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
      __Pyx_INCREF(__pyx_t_13);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_4, function);
      __pyx_t_14 = 1;
    }
  }
  #if CYTHON_FAST_PYCALL
  if (PyFunction_Check(__pyx_t_4)) {
    PyObject *__pyx_temp[6] = {__pyx_t_13, __pyx_t_5, __pyx_t_9, __pyx_t_10, __pyx_t_11, __pyx_t_12};
    __pyx_t_3 = __Pyx_PyFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_14, 5+__pyx_t_14); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 751, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0;
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
    __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
    __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
    __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
  } else
  #endif
  #if CYTHON_FAST_PYCCALL
  if (__Pyx_PyFastCFunction_Check(__pyx_t_4)) {
    PyObject *__pyx_temp[6] = {__pyx_t_13, __pyx_t_5, __pyx_t_9, __pyx_t_10, __pyx_t_11, __pyx_t_12};
    __pyx_t_3 = __Pyx_PyCFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_14, 5+__pyx_t_14); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 751, __pyx_L1_error)
    __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0;
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
    __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
    __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
    __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
  } else
  #endif
  {
    __pyx_t_15 = PyTuple_New(5+__pyx_t_14); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 751, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_15);
    if (__pyx_t_13) {
      __Pyx_GIVEREF(__pyx_t_13); PyTuple_SET_ITEM(__pyx_t_15, 0, __pyx_t_13); __pyx_t_13 = NULL;
    }
    __Pyx_GIVEREF(__pyx_t_5);
    PyTuple_SET_ITEM(__pyx_t_15, 0+__pyx_t_14, __pyx_t_5);
    __Pyx_GIVEREF(__pyx_t_9);
    PyTuple_SET_ITEM(__pyx_t_15, 1+__pyx_t_14, __pyx_t_9);
    __Pyx_GIVEREF(__pyx_t_10);
    PyTuple_SET_ITEM(__pyx_t_15, 2+__pyx_t_14, __pyx_t_10);
    __Pyx_GIVEREF(__pyx_t_11);
    PyTuple_SET_ITEM(__pyx_t_15, 3+__pyx_t_14, __pyx_t_11);
    __Pyx_GIVEREF(__pyx_t_12);
    PyTuple_SET_ITEM(__pyx_t_15, 4+__pyx_t_14, __pyx_t_12);
    __pyx_t_5 = 0;
    __pyx_t_9 = 0;
    __pyx_t_10 = 0;
    __pyx_t_11 = 0;
    __pyx_t_12 = 0;
    __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_15, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 751, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
  }
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  if ((likely(PyTuple_CheckExact(__pyx_t_3))) || (PyList_CheckExact(__pyx_t_3))) {
    PyObject* sequence = __pyx_t_3;
    #if !CYTHON_COMPILING_IN_PYPY
    Py_ssize_t size = Py_SIZE(sequence);
    #else
    Py_ssize_t size = PySequence_Size(sequence);
    #endif
    if (unlikely(size != 2)) {
      if (size > 2) __Pyx_RaiseTooManyValuesError(2);
      else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
      __PYX_ERR(0, 751, __pyx_L1_error)
    }
    #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
    if (likely(PyTuple_CheckExact(sequence))) {
      __pyx_t_4 = PyTuple_GET_ITEM(sequence, 0); 
      __pyx_t_15 = PyTuple_GET_ITEM(sequence, 1); 
    } else {
      __pyx_t_4 = PyList_GET_ITEM(sequence, 0); 
      __pyx_t_15 = PyList_GET_ITEM(sequence, 1); 
    }
    __Pyx_INCREF(__pyx_t_4);
    __Pyx_INCREF(__pyx_t_15);
    #else
    __pyx_t_4 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 751, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_15 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 751, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_15);
    #endif
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  } else {
    Py_ssize_t index = -1;
    __pyx_t_12 = PyObject_GetIter(__pyx_t_3); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 751, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_12);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_t_16 = Py_TYPE(__pyx_t_12)->tp_iternext;
    index = 0; __pyx_t_4 = __pyx_t_16(__pyx_t_12); if (unlikely(!__pyx_t_4)) goto __pyx_L5_unpacking_failed;
    __Pyx_GOTREF(__pyx_t_4);
    index = 1; __pyx_t_15 = __pyx_t_16(__pyx_t_12); if (unlikely(!__pyx_t_15)) goto __pyx_L5_unpacking_failed;
    __Pyx_GOTREF(__pyx_t_15);
    if (__Pyx_IternextUnpackEndCheck(__pyx_t_16(__pyx_t_12), 2) < 0) __PYX_ERR(0, 751, __pyx_L1_error)
    __pyx_t_16 = NULL;
    __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
    goto __pyx_L6_unpacking_done;
    __pyx_L5_unpacking_failed:;
    __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
    __pyx_t_16 = NULL;
    if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
    __PYX_ERR(0, 751, __pyx_L1_error)
    __pyx_L6_unpacking_done:;
  }
  __pyx_v_Inter = __pyx_t_4;
  __pyx_t_4 = 0;
  __pyx_v_Bounds = __pyx_t_15;
  __pyx_t_15 = 0;
+752:     BC = list(Bounds)
  __pyx_t_3 = PySequence_List(__pyx_v_Bounds); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 752, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_v_BC = ((PyObject*)__pyx_t_3);
  __pyx_t_3 = 0;
+753:     nBounds = len(Bounds)
  __pyx_t_17 = PyObject_Length(__pyx_v_Bounds); if (unlikely(__pyx_t_17 == -1)) __PYX_ERR(0, 753, __pyx_L1_error)
  __pyx_v_nBounds = __pyx_t_17;
+754:     for ii in range(0,nBounds):
  __pyx_t_17 = __pyx_v_nBounds;
  for (__pyx_t_14 = 0; __pyx_t_14 < __pyx_t_17; __pyx_t_14+=1) {
    __pyx_v_ii = __pyx_t_14;
+755:         if BC[ii][0]<PhiMinMax[0]:
    __pyx_t_3 = __Pyx_GetItemInt(PyList_GET_ITEM(__pyx_v_BC, __pyx_v_ii), 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 755, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_15 = __Pyx_GetItemInt(__pyx_v_PhiMinMax, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 0); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 755, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_15);
    __pyx_t_4 = PyObject_RichCompare(__pyx_t_3, __pyx_t_15, Py_LT); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 755, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
    __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_1 < 0)) __PYX_ERR(0, 755, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    if (__pyx_t_1) {
/* … */
    }
+756:             BC[ii][0] += 2.*Cpi
      __Pyx_INCREF(PyList_GET_ITEM(__pyx_v_BC, __pyx_v_ii));
      __pyx_t_4 = PyList_GET_ITEM(__pyx_v_BC, __pyx_v_ii);
      __pyx_t_18 = 0;
      __pyx_t_15 = __Pyx_GetItemInt(__pyx_t_4, __pyx_t_18, Py_ssize_t, 1, PyInt_FromSsize_t, 0, 0, 0); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 756, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_15);
      __pyx_t_3 = PyFloat_FromDouble((2. * M_PI)); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 756, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_12 = PyNumber_InPlaceAdd(__pyx_t_15, __pyx_t_3); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 756, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_12);
      __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      if (unlikely(__Pyx_SetItemInt(__pyx_t_4, __pyx_t_18, __pyx_t_12, Py_ssize_t, 1, PyInt_FromSsize_t, 0, 0, 0) < 0)) __PYX_ERR(0, 756, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+757:         if BC[ii][1]<=PhiMinMax[0]:
    __pyx_t_4 = __Pyx_GetItemInt(PyList_GET_ITEM(__pyx_v_BC, __pyx_v_ii), 1, long, 1, __Pyx_PyInt_From_long, 0, 0, 0); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 757, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_12 = __Pyx_GetItemInt(__pyx_v_PhiMinMax, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 0); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 757, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_12);
    __pyx_t_3 = PyObject_RichCompare(__pyx_t_4, __pyx_t_12, Py_LE); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 757, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
    __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_1 < 0)) __PYX_ERR(0, 757, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    if (__pyx_t_1) {
/* … */
    }
  }
+758:             BC[ii][1] += 2.*Cpi
      __Pyx_INCREF(PyList_GET_ITEM(__pyx_v_BC, __pyx_v_ii));
      __pyx_t_3 = PyList_GET_ITEM(__pyx_v_BC, __pyx_v_ii);
      __pyx_t_18 = 1;
      __pyx_t_12 = __Pyx_GetItemInt(__pyx_t_3, __pyx_t_18, Py_ssize_t, 1, PyInt_FromSsize_t, 0, 0, 0); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 758, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_12);
      __pyx_t_4 = PyFloat_FromDouble((2. * M_PI)); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 758, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_t_15 = PyNumber_InPlaceAdd(__pyx_t_12, __pyx_t_4); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 758, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_15);
      __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      if (unlikely(__Pyx_SetItemInt(__pyx_t_3, __pyx_t_18, __pyx_t_15, Py_ssize_t, 1, PyInt_FromSsize_t, 0, 0, 0) < 0)) __PYX_ERR(0, 758, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
 759: 
 760: 
+761:     if Inter:
  __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_v_Inter); if (unlikely(__pyx_t_1 < 0)) __PYX_ERR(0, 761, __pyx_L1_error)
  if (__pyx_t_1) {
/* … */
    goto __pyx_L11;
  }
 762: 
 763:         # Get the actual R and Z resolutions and mesh elements
+764:         PtsCross, dLr, indL, NL, Rref, VPbis = _Ves_mesh_CrossPoly(VPoly, dL, D1=None, D2=None, margin=margin, DIn=DIn, VIn=VIn)
    __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_Ves_mesh_CrossPoly); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 764, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_15 = __pyx_memoryview_fromslice(__pyx_v_VPoly, 2, (PyObject *(*)(char *)) __pyx_memview_get_double, (int (*)(char *, PyObject *)) __pyx_memview_set_double, 0);; if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 764, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_15);
    __pyx_t_4 = PyFloat_FromDouble(__pyx_v_dL); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 764, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_12 = PyTuple_New(2); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 764, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_12);
    __Pyx_GIVEREF(__pyx_t_15);
    PyTuple_SET_ITEM(__pyx_t_12, 0, __pyx_t_15);
    __Pyx_GIVEREF(__pyx_t_4);
    PyTuple_SET_ITEM(__pyx_t_12, 1, __pyx_t_4);
    __pyx_t_15 = 0;
    __pyx_t_4 = 0;
    __pyx_t_4 = PyDict_New(); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 764, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    if (PyDict_SetItem(__pyx_t_4, __pyx_n_s_D1, Py_None) < 0) __PYX_ERR(0, 764, __pyx_L1_error)
    if (PyDict_SetItem(__pyx_t_4, __pyx_n_s_D2, Py_None) < 0) __PYX_ERR(0, 764, __pyx_L1_error)
    __pyx_t_15 = PyFloat_FromDouble(__pyx_v_margin); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 764, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_15);
    if (PyDict_SetItem(__pyx_t_4, __pyx_n_s_margin, __pyx_t_15) < 0) __PYX_ERR(0, 764, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
    __pyx_t_15 = PyFloat_FromDouble(__pyx_v_DIn); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 764, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_15);
    if (PyDict_SetItem(__pyx_t_4, __pyx_n_s_DIn, __pyx_t_15) < 0) __PYX_ERR(0, 764, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
    if (PyDict_SetItem(__pyx_t_4, __pyx_n_s_VIn, __pyx_v_VIn) < 0) __PYX_ERR(0, 764, __pyx_L1_error)
    __pyx_t_15 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_12, __pyx_t_4); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 764, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_15);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    if ((likely(PyTuple_CheckExact(__pyx_t_15))) || (PyList_CheckExact(__pyx_t_15))) {
      PyObject* sequence = __pyx_t_15;
      #if !CYTHON_COMPILING_IN_PYPY
      Py_ssize_t size = Py_SIZE(sequence);
      #else
      Py_ssize_t size = PySequence_Size(sequence);
      #endif
      if (unlikely(size != 6)) {
        if (size > 6) __Pyx_RaiseTooManyValuesError(6);
        else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
        __PYX_ERR(0, 764, __pyx_L1_error)
      }
      #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
      if (likely(PyTuple_CheckExact(sequence))) {
        __pyx_t_4 = PyTuple_GET_ITEM(sequence, 0); 
        __pyx_t_12 = PyTuple_GET_ITEM(sequence, 1); 
        __pyx_t_3 = PyTuple_GET_ITEM(sequence, 2); 
        __pyx_t_11 = PyTuple_GET_ITEM(sequence, 3); 
        __pyx_t_10 = PyTuple_GET_ITEM(sequence, 4); 
        __pyx_t_9 = PyTuple_GET_ITEM(sequence, 5); 
      } else {
        __pyx_t_4 = PyList_GET_ITEM(sequence, 0); 
        __pyx_t_12 = PyList_GET_ITEM(sequence, 1); 
        __pyx_t_3 = PyList_GET_ITEM(sequence, 2); 
        __pyx_t_11 = PyList_GET_ITEM(sequence, 3); 
        __pyx_t_10 = PyList_GET_ITEM(sequence, 4); 
        __pyx_t_9 = PyList_GET_ITEM(sequence, 5); 
      }
      __Pyx_INCREF(__pyx_t_4);
      __Pyx_INCREF(__pyx_t_12);
      __Pyx_INCREF(__pyx_t_3);
      __Pyx_INCREF(__pyx_t_11);
      __Pyx_INCREF(__pyx_t_10);
      __Pyx_INCREF(__pyx_t_9);
      #else
      {
        Py_ssize_t i;
        PyObject** temps[6] = {&__pyx_t_4,&__pyx_t_12,&__pyx_t_3,&__pyx_t_11,&__pyx_t_10,&__pyx_t_9};
        for (i=0; i < 6; i++) {
          PyObject* item = PySequence_ITEM(sequence, i); if (unlikely(!item)) __PYX_ERR(0, 764, __pyx_L1_error)
          __Pyx_GOTREF(item);
          *(temps[i]) = item;
        }
      }
      #endif
      __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
    } else {
      Py_ssize_t index = -1;
      PyObject** temps[6] = {&__pyx_t_4,&__pyx_t_12,&__pyx_t_3,&__pyx_t_11,&__pyx_t_10,&__pyx_t_9};
      __pyx_t_5 = PyObject_GetIter(__pyx_t_15); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 764, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
      __pyx_t_16 = Py_TYPE(__pyx_t_5)->tp_iternext;
      for (index=0; index < 6; index++) {
        PyObject* item = __pyx_t_16(__pyx_t_5); if (unlikely(!item)) goto __pyx_L12_unpacking_failed;
        __Pyx_GOTREF(item);
        *(temps[index]) = item;
      }
      if (__Pyx_IternextUnpackEndCheck(__pyx_t_16(__pyx_t_5), 6) < 0) __PYX_ERR(0, 764, __pyx_L1_error)
      __pyx_t_16 = NULL;
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      goto __pyx_L13_unpacking_done;
      __pyx_L12_unpacking_failed:;
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __pyx_t_16 = NULL;
      if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
      __PYX_ERR(0, 764, __pyx_L1_error)
      __pyx_L13_unpacking_done:;
    }
    if (!(likely(((__pyx_t_4) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_4, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 764, __pyx_L1_error)
    if (!(likely(((__pyx_t_12) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_12, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 764, __pyx_L1_error)
    if (!(likely(((__pyx_t_3) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_3, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 764, __pyx_L1_error)
    if (!(likely(((__pyx_t_11) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_11, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 764, __pyx_L1_error)
    if (!(likely(((__pyx_t_10) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_10, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 764, __pyx_L1_error)
    if (!(likely(((__pyx_t_9) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_9, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 764, __pyx_L1_error)
    __pyx_t_19 = ((PyArrayObject *)__pyx_t_4);
    {
      __Pyx_BufFmt_StackElem __pyx_stack[1];
      __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_PtsCross.rcbuffer->pybuffer);
      __pyx_t_14 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_PtsCross.rcbuffer->pybuffer, (PyObject*)__pyx_t_19, &__Pyx_TypeInfo_double, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack);
      if (unlikely(__pyx_t_14 < 0)) {
        PyErr_Fetch(&__pyx_t_20, &__pyx_t_21, &__pyx_t_22);
        if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_PtsCross.rcbuffer->pybuffer, (PyObject*)__pyx_v_PtsCross, &__Pyx_TypeInfo_double, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) {
          Py_XDECREF(__pyx_t_20); Py_XDECREF(__pyx_t_21); Py_XDECREF(__pyx_t_22);
          __Pyx_RaiseBufferFallbackError();
        } else {
          PyErr_Restore(__pyx_t_20, __pyx_t_21, __pyx_t_22);
        }
      }
      __pyx_pybuffernd_PtsCross.diminfo[0].strides = __pyx_pybuffernd_PtsCross.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_PtsCross.diminfo[0].shape = __pyx_pybuffernd_PtsCross.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_PtsCross.diminfo[1].strides = __pyx_pybuffernd_PtsCross.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_PtsCross.diminfo[1].shape = __pyx_pybuffernd_PtsCross.rcbuffer->pybuffer.shape[1];
      if (unlikely(__pyx_t_14 < 0)) __PYX_ERR(0, 764, __pyx_L1_error)
    }
    __pyx_t_19 = 0;
    __pyx_v_PtsCross = ((PyArrayObject *)__pyx_t_4);
    __pyx_t_4 = 0;
    __pyx_t_23 = ((PyArrayObject *)__pyx_t_12);
    {
      __Pyx_BufFmt_StackElem __pyx_stack[1];
      __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_dLr.rcbuffer->pybuffer);
      __pyx_t_14 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_dLr.rcbuffer->pybuffer, (PyObject*)__pyx_t_23, &__Pyx_TypeInfo_double, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack);
      if (unlikely(__pyx_t_14 < 0)) {
        PyErr_Fetch(&__pyx_t_22, &__pyx_t_21, &__pyx_t_20);
        if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_dLr.rcbuffer->pybuffer, (PyObject*)__pyx_v_dLr, &__Pyx_TypeInfo_double, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {
          Py_XDECREF(__pyx_t_22); Py_XDECREF(__pyx_t_21); Py_XDECREF(__pyx_t_20);
          __Pyx_RaiseBufferFallbackError();
        } else {
          PyErr_Restore(__pyx_t_22, __pyx_t_21, __pyx_t_20);
        }
      }
      __pyx_pybuffernd_dLr.diminfo[0].strides = __pyx_pybuffernd_dLr.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_dLr.diminfo[0].shape = __pyx_pybuffernd_dLr.rcbuffer->pybuffer.shape[0];
      if (unlikely(__pyx_t_14 < 0)) __PYX_ERR(0, 764, __pyx_L1_error)
    }
    __pyx_t_23 = 0;
    __pyx_v_dLr = ((PyArrayObject *)__pyx_t_12);
    __pyx_t_12 = 0;
    __pyx_t_24 = ((PyArrayObject *)__pyx_t_3);
    {
      __Pyx_BufFmt_StackElem __pyx_stack[1];
      __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_indL.rcbuffer->pybuffer);
      __pyx_t_14 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_indL.rcbuffer->pybuffer, (PyObject*)__pyx_t_24, &__Pyx_TypeInfo_long, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack);
      if (unlikely(__pyx_t_14 < 0)) {
        PyErr_Fetch(&__pyx_t_20, &__pyx_t_21, &__pyx_t_22);
        if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_indL.rcbuffer->pybuffer, (PyObject*)__pyx_v_indL, &__Pyx_TypeInfo_long, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {
          Py_XDECREF(__pyx_t_20); Py_XDECREF(__pyx_t_21); Py_XDECREF(__pyx_t_22);
          __Pyx_RaiseBufferFallbackError();
        } else {
          PyErr_Restore(__pyx_t_20, __pyx_t_21, __pyx_t_22);
        }
      }
      __pyx_pybuffernd_indL.diminfo[0].strides = __pyx_pybuffernd_indL.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_indL.diminfo[0].shape = __pyx_pybuffernd_indL.rcbuffer->pybuffer.shape[0];
      if (unlikely(__pyx_t_14 < 0)) __PYX_ERR(0, 764, __pyx_L1_error)
    }
    __pyx_t_24 = 0;
    __pyx_v_indL = ((PyArrayObject *)__pyx_t_3);
    __pyx_t_3 = 0;
    __pyx_t_24 = ((PyArrayObject *)__pyx_t_11);
    {
      __Pyx_BufFmt_StackElem __pyx_stack[1];
      __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_NL.rcbuffer->pybuffer);
      __pyx_t_14 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_NL.rcbuffer->pybuffer, (PyObject*)__pyx_t_24, &__Pyx_TypeInfo_long, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack);
      if (unlikely(__pyx_t_14 < 0)) {
        PyErr_Fetch(&__pyx_t_22, &__pyx_t_21, &__pyx_t_20);
        if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_NL.rcbuffer->pybuffer, (PyObject*)__pyx_v_NL, &__Pyx_TypeInfo_long, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {
          Py_XDECREF(__pyx_t_22); Py_XDECREF(__pyx_t_21); Py_XDECREF(__pyx_t_20);
          __Pyx_RaiseBufferFallbackError();
        } else {
          PyErr_Restore(__pyx_t_22, __pyx_t_21, __pyx_t_20);
        }
      }
      __pyx_pybuffernd_NL.diminfo[0].strides = __pyx_pybuffernd_NL.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_NL.diminfo[0].shape = __pyx_pybuffernd_NL.rcbuffer->pybuffer.shape[0];
      if (unlikely(__pyx_t_14 < 0)) __PYX_ERR(0, 764, __pyx_L1_error)
    }
    __pyx_t_24 = 0;
    __pyx_v_NL = ((PyArrayObject *)__pyx_t_11);
    __pyx_t_11 = 0;
    __pyx_t_23 = ((PyArrayObject *)__pyx_t_10);
    {
      __Pyx_BufFmt_StackElem __pyx_stack[1];
      __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_Rref.rcbuffer->pybuffer);
      __pyx_t_14 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_Rref.rcbuffer->pybuffer, (PyObject*)__pyx_t_23, &__Pyx_TypeInfo_double, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack);
      if (unlikely(__pyx_t_14 < 0)) {
        PyErr_Fetch(&__pyx_t_20, &__pyx_t_21, &__pyx_t_22);
        if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_Rref.rcbuffer->pybuffer, (PyObject*)__pyx_v_Rref, &__Pyx_TypeInfo_double, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {
          Py_XDECREF(__pyx_t_20); Py_XDECREF(__pyx_t_21); Py_XDECREF(__pyx_t_22);
          __Pyx_RaiseBufferFallbackError();
        } else {
          PyErr_Restore(__pyx_t_20, __pyx_t_21, __pyx_t_22);
        }
      }
      __pyx_pybuffernd_Rref.diminfo[0].strides = __pyx_pybuffernd_Rref.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_Rref.diminfo[0].shape = __pyx_pybuffernd_Rref.rcbuffer->pybuffer.shape[0];
      if (unlikely(__pyx_t_14 < 0)) __PYX_ERR(0, 764, __pyx_L1_error)
    }
    __pyx_t_23 = 0;
    __pyx_v_Rref = ((PyArrayObject *)__pyx_t_10);
    __pyx_t_10 = 0;
    __pyx_t_19 = ((PyArrayObject *)__pyx_t_9);
    {
      __Pyx_BufFmt_StackElem __pyx_stack[1];
      __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_VPbis.rcbuffer->pybuffer);
      __pyx_t_14 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_VPbis.rcbuffer->pybuffer, (PyObject*)__pyx_t_19, &__Pyx_TypeInfo_double, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack);
      if (unlikely(__pyx_t_14 < 0)) {
        PyErr_Fetch(&__pyx_t_22, &__pyx_t_21, &__pyx_t_20);
        if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_VPbis.rcbuffer->pybuffer, (PyObject*)__pyx_v_VPbis, &__Pyx_TypeInfo_double, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) {
          Py_XDECREF(__pyx_t_22); Py_XDECREF(__pyx_t_21); Py_XDECREF(__pyx_t_20);
          __Pyx_RaiseBufferFallbackError();
        } else {
          PyErr_Restore(__pyx_t_22, __pyx_t_21, __pyx_t_20);
        }
      }
      __pyx_pybuffernd_VPbis.diminfo[0].strides = __pyx_pybuffernd_VPbis.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_VPbis.diminfo[0].shape = __pyx_pybuffernd_VPbis.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_VPbis.diminfo[1].strides = __pyx_pybuffernd_VPbis.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_VPbis.diminfo[1].shape = __pyx_pybuffernd_VPbis.rcbuffer->pybuffer.shape[1];
      if (unlikely(__pyx_t_14 < 0)) __PYX_ERR(0, 764, __pyx_L1_error)
    }
    __pyx_t_19 = 0;
    __pyx_v_VPbis = ((PyArrayObject *)__pyx_t_9);
    __pyx_t_9 = 0;
+765:         R0 = np.copy(Rref)
    __pyx_t_9 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 765, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_9);
    __pyx_t_10 = __Pyx_PyObject_GetAttrStr(__pyx_t_9, __pyx_n_s_copy); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 765, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_10);
    __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
    __pyx_t_9 = NULL;
    if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_10))) {
      __pyx_t_9 = PyMethod_GET_SELF(__pyx_t_10);
      if (likely(__pyx_t_9)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_10);
        __Pyx_INCREF(__pyx_t_9);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_10, function);
      }
    }
    if (!__pyx_t_9) {
      __pyx_t_15 = __Pyx_PyObject_CallOneArg(__pyx_t_10, ((PyObject *)__pyx_v_Rref)); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 765, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_15);
    } else {
      #if CYTHON_FAST_PYCALL
      if (PyFunction_Check(__pyx_t_10)) {
        PyObject *__pyx_temp[2] = {__pyx_t_9, ((PyObject *)__pyx_v_Rref)};
        __pyx_t_15 = __Pyx_PyFunction_FastCall(__pyx_t_10, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 765, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
        __Pyx_GOTREF(__pyx_t_15);
      } else
      #endif
      #if CYTHON_FAST_PYCCALL
      if (__Pyx_PyFastCFunction_Check(__pyx_t_10)) {
        PyObject *__pyx_temp[2] = {__pyx_t_9, ((PyObject *)__pyx_v_Rref)};
        __pyx_t_15 = __Pyx_PyCFunction_FastCall(__pyx_t_10, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 765, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
        __Pyx_GOTREF(__pyx_t_15);
      } else
      #endif
      {
        __pyx_t_11 = PyTuple_New(1+1); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 765, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_11);
        __Pyx_GIVEREF(__pyx_t_9); PyTuple_SET_ITEM(__pyx_t_11, 0, __pyx_t_9); __pyx_t_9 = NULL;
        __Pyx_INCREF(((PyObject *)__pyx_v_Rref));
        __Pyx_GIVEREF(((PyObject *)__pyx_v_Rref));
        PyTuple_SET_ITEM(__pyx_t_11, 0+1, ((PyObject *)__pyx_v_Rref));
        __pyx_t_15 = __Pyx_PyObject_Call(__pyx_t_10, __pyx_t_11, NULL); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 765, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_15);
        __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
      }
    }
    __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
    if (!(likely(((__pyx_t_15) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_15, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 765, __pyx_L1_error)
    __pyx_t_23 = ((PyArrayObject *)__pyx_t_15);
    {
      __Pyx_BufFmt_StackElem __pyx_stack[1];
      __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_R0.rcbuffer->pybuffer);
      __pyx_t_14 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_R0.rcbuffer->pybuffer, (PyObject*)__pyx_t_23, &__Pyx_TypeInfo_double, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack);
      if (unlikely(__pyx_t_14 < 0)) {
        PyErr_Fetch(&__pyx_t_20, &__pyx_t_21, &__pyx_t_22);
        if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_R0.rcbuffer->pybuffer, (PyObject*)__pyx_v_R0, &__Pyx_TypeInfo_double, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {
          Py_XDECREF(__pyx_t_20); Py_XDECREF(__pyx_t_21); Py_XDECREF(__pyx_t_22);
          __Pyx_RaiseBufferFallbackError();
        } else {
          PyErr_Restore(__pyx_t_20, __pyx_t_21, __pyx_t_22);
        }
      }
      __pyx_pybuffernd_R0.diminfo[0].strides = __pyx_pybuffernd_R0.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_R0.diminfo[0].shape = __pyx_pybuffernd_R0.rcbuffer->pybuffer.shape[0];
      if (unlikely(__pyx_t_14 < 0)) __PYX_ERR(0, 765, __pyx_L1_error)
    }
    __pyx_t_23 = 0;
    __pyx_v_R0 = ((PyArrayObject *)__pyx_t_15);
    __pyx_t_15 = 0;
+766:         NR0 = R0.size
    __pyx_t_15 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_R0), __pyx_n_s_size); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 766, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_15);
    __pyx_t_14 = __Pyx_PyInt_As_int(__pyx_t_15); if (unlikely((__pyx_t_14 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 766, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
    __pyx_v_NR0 = __pyx_t_14;
+767:         indin = np.ones((PtsCross.shape[1],),dtype=bool)
    __pyx_t_15 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 767, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_15);
    __pyx_t_10 = __Pyx_PyObject_GetAttrStr(__pyx_t_15, __pyx_n_s_ones); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 767, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_10);
    __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
    __pyx_t_15 = __Pyx_PyInt_From_Py_intptr_t((__pyx_v_PtsCross->dimensions[1])); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 767, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_15);
    __pyx_t_11 = PyTuple_New(1); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 767, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_11);
    __Pyx_GIVEREF(__pyx_t_15);
    PyTuple_SET_ITEM(__pyx_t_11, 0, __pyx_t_15);
    __pyx_t_15 = 0;
    __pyx_t_15 = PyTuple_New(1); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 767, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_15);
    __Pyx_GIVEREF(__pyx_t_11);
    PyTuple_SET_ITEM(__pyx_t_15, 0, __pyx_t_11);
    __pyx_t_11 = 0;
    __pyx_t_11 = PyDict_New(); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 767, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_11);
    if (PyDict_SetItem(__pyx_t_11, __pyx_n_s_dtype, ((PyObject *)__pyx_ptype_7cpython_4bool_bool)) < 0) __PYX_ERR(0, 767, __pyx_L1_error)
    __pyx_t_9 = __Pyx_PyObject_Call(__pyx_t_10, __pyx_t_15, __pyx_t_11); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 767, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_9);
    __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
    __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
    __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
    __pyx_v_indin = __pyx_t_9;
    __pyx_t_9 = 0;
+768:         if DR is not None:
    __pyx_t_1 = (__pyx_v_DR != Py_None);
    __pyx_t_2 = (__pyx_t_1 != 0);
    if (__pyx_t_2) {
/* … */
    }
+769:             indin = indin & (R0>=DR[0]) & (R0<=DR[1])
      __pyx_t_9 = __Pyx_GetItemInt(__pyx_v_DR, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 0); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 769, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_9);
      __pyx_t_11 = PyObject_RichCompare(((PyObject *)__pyx_v_R0), __pyx_t_9, Py_GE); __Pyx_XGOTREF(__pyx_t_11); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 769, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
      __pyx_t_9 = PyNumber_And(__pyx_v_indin, __pyx_t_11); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 769, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_9);
      __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
      __pyx_t_11 = __Pyx_GetItemInt(__pyx_v_DR, 1, long, 1, __Pyx_PyInt_From_long, 0, 0, 0); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 769, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_11);
      __pyx_t_15 = PyObject_RichCompare(((PyObject *)__pyx_v_R0), __pyx_t_11, Py_LE); __Pyx_XGOTREF(__pyx_t_15); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 769, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
      __pyx_t_11 = PyNumber_And(__pyx_t_9, __pyx_t_15); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 769, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_11);
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
      __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
      __Pyx_DECREF_SET(__pyx_v_indin, __pyx_t_11);
      __pyx_t_11 = 0;
+770:         if DZ is not None:
    __pyx_t_2 = (__pyx_v_DZ != Py_None);
    __pyx_t_1 = (__pyx_t_2 != 0);
    if (__pyx_t_1) {
/* … */
    }
+771:             indin = indin & (PtsCross[1,:]>=DZ[0]) & (PtsCross[1,:]<=DZ[1])
  __pyx_slice__78 = PySlice_New(Py_None, Py_None, Py_None); if (unlikely(!__pyx_slice__78)) __PYX_ERR(0, 771, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_slice__78);
  __Pyx_GIVEREF(__pyx_slice__78);
/* … */
      __pyx_t_11 = PyObject_GetItem(((PyObject *)__pyx_v_PtsCross), __pyx_tuple__79); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 771, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_11);
      __pyx_t_15 = __Pyx_GetItemInt(__pyx_v_DZ, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 0); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 771, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_15);
      __pyx_t_9 = PyObject_RichCompare(__pyx_t_11, __pyx_t_15, Py_GE); __Pyx_XGOTREF(__pyx_t_9); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 771, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
      __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
      __pyx_t_15 = PyNumber_And(__pyx_v_indin, __pyx_t_9); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 771, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_15);
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
  __pyx_tuple__79 = PyTuple_Pack(2, __pyx_int_1, __pyx_slice__78); if (unlikely(!__pyx_tuple__79)) __PYX_ERR(0, 771, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__79);
  __Pyx_GIVEREF(__pyx_tuple__79);
  __pyx_slice__80 = PySlice_New(Py_None, Py_None, Py_None); if (unlikely(!__pyx_slice__80)) __PYX_ERR(0, 771, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_slice__80);
  __Pyx_GIVEREF(__pyx_slice__80);
      __pyx_t_9 = PyObject_GetItem(((PyObject *)__pyx_v_PtsCross), __pyx_tuple__81); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 771, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_9);
      __pyx_t_11 = __Pyx_GetItemInt(__pyx_v_DZ, 1, long, 1, __Pyx_PyInt_From_long, 0, 0, 0); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 771, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_11);
      __pyx_t_10 = PyObject_RichCompare(__pyx_t_9, __pyx_t_11, Py_LE); __Pyx_XGOTREF(__pyx_t_10); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 771, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
      __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
      __pyx_t_11 = PyNumber_And(__pyx_t_15, __pyx_t_10); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 771, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_11);
      __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
      __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
      __Pyx_DECREF_SET(__pyx_v_indin, __pyx_t_11);
      __pyx_t_11 = 0;
  __pyx_tuple__81 = PyTuple_Pack(2, __pyx_int_1, __pyx_slice__80); if (unlikely(!__pyx_tuple__81)) __PYX_ERR(0, 771, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_tuple__81);
  __Pyx_GIVEREF(__pyx_tuple__81);
+772:         PtsCross, dLr, indL, Rref = PtsCross[:,indin], dLr[indin], indL[indin], Rref[indin]
    __pyx_t_11 = PyTuple_New(2); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 772, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_11);
    __Pyx_INCREF(__pyx_slice__82);
    __Pyx_GIVEREF(__pyx_slice__82);
    PyTuple_SET_ITEM(__pyx_t_11, 0, __pyx_slice__82);
    __Pyx_INCREF(__pyx_v_indin);
    __Pyx_GIVEREF(__pyx_v_indin);
    PyTuple_SET_ITEM(__pyx_t_11, 1, __pyx_v_indin);
    __pyx_t_10 = PyObject_GetItem(((PyObject *)__pyx_v_PtsCross), __pyx_t_11); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 772, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_10);
    __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
    if (!(likely(((__pyx_t_10) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_10, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 772, __pyx_L1_error)
    __pyx_t_11 = PyObject_GetItem(((PyObject *)__pyx_v_dLr), __pyx_v_indin); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 772, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_11);
    if (!(likely(((__pyx_t_11) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_11, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 772, __pyx_L1_error)
    __pyx_t_15 = PyObject_GetItem(((PyObject *)__pyx_v_indL), __pyx_v_indin); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 772, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_15);
    if (!(likely(((__pyx_t_15) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_15, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 772, __pyx_L1_error)
    __pyx_t_9 = PyObject_GetItem(((PyObject *)__pyx_v_Rref), __pyx_v_indin); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 772, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_9);
    if (!(likely(((__pyx_t_9) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_9, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 772, __pyx_L1_error)
    __pyx_t_19 = ((PyArrayObject *)__pyx_t_10);
    {
      __Pyx_BufFmt_StackElem __pyx_stack[1];
      __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_PtsCross.rcbuffer->pybuffer);
      __pyx_t_14 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_PtsCross.rcbuffer->pybuffer, (PyObject*)__pyx_t_19, &__Pyx_TypeInfo_double, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack);
      if (unlikely(__pyx_t_14 < 0)) {
        PyErr_Fetch(&__pyx_t_22, &__pyx_t_21, &__pyx_t_20);
        if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_PtsCross.rcbuffer->pybuffer, (PyObject*)__pyx_v_PtsCross, &__Pyx_TypeInfo_double, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) {
          Py_XDECREF(__pyx_t_22); Py_XDECREF(__pyx_t_21); Py_XDECREF(__pyx_t_20);
          __Pyx_RaiseBufferFallbackError();
        } else {
          PyErr_Restore(__pyx_t_22, __pyx_t_21, __pyx_t_20);
        }
      }
      __pyx_pybuffernd_PtsCross.diminfo[0].strides = __pyx_pybuffernd_PtsCross.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_PtsCross.diminfo[0].shape = __pyx_pybuffernd_PtsCross.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_PtsCross.diminfo[1].strides = __pyx_pybuffernd_PtsCross.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_PtsCross.diminfo[1].shape = __pyx_pybuffernd_PtsCross.rcbuffer->pybuffer.shape[1];
      if (unlikely(__pyx_t_14 < 0)) __PYX_ERR(0, 772, __pyx_L1_error)
    }
    __pyx_t_19 = 0;
    __Pyx_DECREF_SET(__pyx_v_PtsCross, ((PyArrayObject *)__pyx_t_10));
    __pyx_t_10 = 0;
    __pyx_t_23 = ((PyArrayObject *)__pyx_t_11);
    {
      __Pyx_BufFmt_StackElem __pyx_stack[1];
      __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_dLr.rcbuffer->pybuffer);
      __pyx_t_14 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_dLr.rcbuffer->pybuffer, (PyObject*)__pyx_t_23, &__Pyx_TypeInfo_double, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack);
      if (unlikely(__pyx_t_14 < 0)) {
        PyErr_Fetch(&__pyx_t_20, &__pyx_t_21, &__pyx_t_22);
        if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_dLr.rcbuffer->pybuffer, (PyObject*)__pyx_v_dLr, &__Pyx_TypeInfo_double, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {
          Py_XDECREF(__pyx_t_20); Py_XDECREF(__pyx_t_21); Py_XDECREF(__pyx_t_22);
          __Pyx_RaiseBufferFallbackError();
        } else {
          PyErr_Restore(__pyx_t_20, __pyx_t_21, __pyx_t_22);
        }
      }
      __pyx_pybuffernd_dLr.diminfo[0].strides = __pyx_pybuffernd_dLr.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_dLr.diminfo[0].shape = __pyx_pybuffernd_dLr.rcbuffer->pybuffer.shape[0];
      if (unlikely(__pyx_t_14 < 0)) __PYX_ERR(0, 772, __pyx_L1_error)
    }
    __pyx_t_23 = 0;
    __Pyx_DECREF_SET(__pyx_v_dLr, ((PyArrayObject *)__pyx_t_11));
    __pyx_t_11 = 0;
    __pyx_t_24 = ((PyArrayObject *)__pyx_t_15);
    {
      __Pyx_BufFmt_StackElem __pyx_stack[1];
      __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_indL.rcbuffer->pybuffer);
      __pyx_t_14 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_indL.rcbuffer->pybuffer, (PyObject*)__pyx_t_24, &__Pyx_TypeInfo_long, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack);
      if (unlikely(__pyx_t_14 < 0)) {
        PyErr_Fetch(&__pyx_t_22, &__pyx_t_21, &__pyx_t_20);
        if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_indL.rcbuffer->pybuffer, (PyObject*)__pyx_v_indL, &__Pyx_TypeInfo_long, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {
          Py_XDECREF(__pyx_t_22); Py_XDECREF(__pyx_t_21); Py_XDECREF(__pyx_t_20);
          __Pyx_RaiseBufferFallbackError();
        } else {
          PyErr_Restore(__pyx_t_22, __pyx_t_21, __pyx_t_20);
        }
      }
      __pyx_pybuffernd_indL.diminfo[0].strides = __pyx_pybuffernd_indL.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_indL.diminfo[0].shape = __pyx_pybuffernd_indL.rcbuffer->pybuffer.shape[0];
      if (unlikely(__pyx_t_14 < 0)) __PYX_ERR(0, 772, __pyx_L1_error)
    }
    __pyx_t_24 = 0;
    __Pyx_DECREF_SET(__pyx_v_indL, ((PyArrayObject *)__pyx_t_15));
    __pyx_t_15 = 0;
    __pyx_t_23 = ((PyArrayObject *)__pyx_t_9);
    {
      __Pyx_BufFmt_StackElem __pyx_stack[1];
      __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_Rref.rcbuffer->pybuffer);
      __pyx_t_14 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_Rref.rcbuffer->pybuffer, (PyObject*)__pyx_t_23, &__Pyx_TypeInfo_double, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack);
      if (unlikely(__pyx_t_14 < 0)) {
        PyErr_Fetch(&__pyx_t_20, &__pyx_t_21, &__pyx_t_22);
        if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_Rref.rcbuffer->pybuffer, (PyObject*)__pyx_v_Rref, &__Pyx_TypeInfo_double, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {
          Py_XDECREF(__pyx_t_20); Py_XDECREF(__pyx_t_21); Py_XDECREF(__pyx_t_22);
          __Pyx_RaiseBufferFallbackError();
        } else {
          PyErr_Restore(__pyx_t_20, __pyx_t_21, __pyx_t_22);
        }
      }
      __pyx_pybuffernd_Rref.diminfo[0].strides = __pyx_pybuffernd_Rref.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_Rref.diminfo[0].shape = __pyx_pybuffernd_Rref.rcbuffer->pybuffer.shape[0];
      if (unlikely(__pyx_t_14 < 0)) __PYX_ERR(0, 772, __pyx_L1_error)
    }
    __pyx_t_23 = 0;
    __Pyx_DECREF_SET(__pyx_v_Rref, ((PyArrayObject *)__pyx_t_9));
    __pyx_t_9 = 0;
/* … */
  __pyx_slice__82 = PySlice_New(Py_None, Py_None, Py_None); if (unlikely(!__pyx_slice__82)) __PYX_ERR(0, 772, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_slice__82);
  __Pyx_GIVEREF(__pyx_slice__82);
+773:         Ln = indin.sum()
    __pyx_t_15 = __Pyx_PyObject_GetAttrStr(__pyx_v_indin, __pyx_n_s_sum); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 773, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_15);
    __pyx_t_11 = NULL;
    if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_15))) {
      __pyx_t_11 = PyMethod_GET_SELF(__pyx_t_15);
      if (likely(__pyx_t_11)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_15);
        __Pyx_INCREF(__pyx_t_11);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_15, function);
      }
    }
    if (__pyx_t_11) {
      __pyx_t_9 = __Pyx_PyObject_CallOneArg(__pyx_t_15, __pyx_t_11); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 773, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
    } else {
      __pyx_t_9 = __Pyx_PyObject_CallNoArg(__pyx_t_15); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 773, __pyx_L1_error)
    }
    __Pyx_GOTREF(__pyx_t_9);
    __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
    __pyx_t_14 = __Pyx_PyInt_As_int(__pyx_t_9); if (unlikely((__pyx_t_14 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 773, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
    __pyx_v_Ln = __pyx_t_14;
+774:         Indin = indin.nonzero()[0]
    __pyx_t_15 = __Pyx_PyObject_GetAttrStr(__pyx_v_indin, __pyx_n_s_nonzero); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 774, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_15);
    __pyx_t_11 = NULL;
    if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_15))) {
      __pyx_t_11 = PyMethod_GET_SELF(__pyx_t_15);
      if (likely(__pyx_t_11)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_15);
        __Pyx_INCREF(__pyx_t_11);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_15, function);
      }
    }
    if (__pyx_t_11) {
      __pyx_t_9 = __Pyx_PyObject_CallOneArg(__pyx_t_15, __pyx_t_11); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 774, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
    } else {
      __pyx_t_9 = __Pyx_PyObject_CallNoArg(__pyx_t_15); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 774, __pyx_L1_error)
    }
    __Pyx_GOTREF(__pyx_t_9);
    __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
    __pyx_t_15 = __Pyx_GetItemInt(__pyx_t_9, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 0); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 774, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_15);
    __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
    __pyx_t_25 = __Pyx_PyObject_to_MemoryviewSlice_dc_long(__pyx_t_15);
    if (unlikely(!__pyx_t_25.memview)) __PYX_ERR(0, 774, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
    __pyx_v_Indin = __pyx_t_25;
    __pyx_t_25.memview = NULL;
    __pyx_t_25.data = NULL;
 775: 
+776:         dRPhir, dPhir = np.empty((Ln,)), np.empty((Ln,))
    __pyx_t_9 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 776, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_9);
    __pyx_t_11 = __Pyx_PyObject_GetAttrStr(__pyx_t_9, __pyx_n_s_empty); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 776, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_11);
    __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
    __pyx_t_9 = __Pyx_PyInt_From_int(__pyx_v_Ln); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 776, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_9);
    __pyx_t_10 = PyTuple_New(1); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 776, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_10);
    __Pyx_GIVEREF(__pyx_t_9);
    PyTuple_SET_ITEM(__pyx_t_10, 0, __pyx_t_9);
    __pyx_t_9 = 0;
    __pyx_t_9 = NULL;
    if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_11))) {
      __pyx_t_9 = PyMethod_GET_SELF(__pyx_t_11);
      if (likely(__pyx_t_9)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_11);
        __Pyx_INCREF(__pyx_t_9);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_11, function);
      }
    }
    if (!__pyx_t_9) {
      __pyx_t_15 = __Pyx_PyObject_CallOneArg(__pyx_t_11, __pyx_t_10); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 776, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
      __Pyx_GOTREF(__pyx_t_15);
    } else {
      #if CYTHON_FAST_PYCALL
      if (PyFunction_Check(__pyx_t_11)) {
        PyObject *__pyx_temp[2] = {__pyx_t_9, __pyx_t_10};
        __pyx_t_15 = __Pyx_PyFunction_FastCall(__pyx_t_11, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 776, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
        __Pyx_GOTREF(__pyx_t_15);
        __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
      } else
      #endif
      #if CYTHON_FAST_PYCCALL
      if (__Pyx_PyFastCFunction_Check(__pyx_t_11)) {
        PyObject *__pyx_temp[2] = {__pyx_t_9, __pyx_t_10};
        __pyx_t_15 = __Pyx_PyCFunction_FastCall(__pyx_t_11, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 776, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
        __Pyx_GOTREF(__pyx_t_15);
        __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
      } else
      #endif
      {
        __pyx_t_3 = PyTuple_New(1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 776, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_3);
        __Pyx_GIVEREF(__pyx_t_9); PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_9); __pyx_t_9 = NULL;
        __Pyx_GIVEREF(__pyx_t_10);
        PyTuple_SET_ITEM(__pyx_t_3, 0+1, __pyx_t_10);
        __pyx_t_10 = 0;
        __pyx_t_15 = __Pyx_PyObject_Call(__pyx_t_11, __pyx_t_3, NULL); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 776, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_15);
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      }
    }
    __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
    if (!(likely(((__pyx_t_15) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_15, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 776, __pyx_L1_error)
    __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 776, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_10 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_empty); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 776, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_10);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_t_3 = __Pyx_PyInt_From_int(__pyx_v_Ln); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 776, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_9 = PyTuple_New(1); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 776, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_9);
    __Pyx_GIVEREF(__pyx_t_3);
    PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_t_3);
    __pyx_t_3 = 0;
    __pyx_t_3 = NULL;
    if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_10))) {
      __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_10);
      if (likely(__pyx_t_3)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_10);
        __Pyx_INCREF(__pyx_t_3);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_10, function);
      }
    }
    if (!__pyx_t_3) {
      __pyx_t_11 = __Pyx_PyObject_CallOneArg(__pyx_t_10, __pyx_t_9); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 776, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
      __Pyx_GOTREF(__pyx_t_11);
    } else {
      #if CYTHON_FAST_PYCALL
      if (PyFunction_Check(__pyx_t_10)) {
        PyObject *__pyx_temp[2] = {__pyx_t_3, __pyx_t_9};
        __pyx_t_11 = __Pyx_PyFunction_FastCall(__pyx_t_10, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 776, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
        __Pyx_GOTREF(__pyx_t_11);
        __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
      } else
      #endif
      #if CYTHON_FAST_PYCCALL
      if (__Pyx_PyFastCFunction_Check(__pyx_t_10)) {
        PyObject *__pyx_temp[2] = {__pyx_t_3, __pyx_t_9};
        __pyx_t_11 = __Pyx_PyCFunction_FastCall(__pyx_t_10, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 776, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
        __Pyx_GOTREF(__pyx_t_11);
        __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
      } else
      #endif
      {
        __pyx_t_12 = PyTuple_New(1+1); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 776, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_12);
        __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_12, 0, __pyx_t_3); __pyx_t_3 = NULL;
        __Pyx_GIVEREF(__pyx_t_9);
        PyTuple_SET_ITEM(__pyx_t_12, 0+1, __pyx_t_9);
        __pyx_t_9 = 0;
        __pyx_t_11 = __Pyx_PyObject_Call(__pyx_t_10, __pyx_t_12, NULL); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 776, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_11);
        __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
      }
    }
    __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
    __pyx_t_26 = __Pyx_PyObject_to_MemoryviewSlice_dc_double(__pyx_t_11);
    if (unlikely(!__pyx_t_26.memview)) __PYX_ERR(0, 776, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
    __pyx_t_23 = ((PyArrayObject *)__pyx_t_15);
    {
      __Pyx_BufFmt_StackElem __pyx_stack[1];
      __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_dRPhir.rcbuffer->pybuffer);
      __pyx_t_14 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_dRPhir.rcbuffer->pybuffer, (PyObject*)__pyx_t_23, &__Pyx_TypeInfo_double, PyBUF_FORMAT| PyBUF_STRIDES| PyBUF_WRITABLE, 1, 0, __pyx_stack);
      if (unlikely(__pyx_t_14 < 0)) {
        PyErr_Fetch(&__pyx_t_22, &__pyx_t_21, &__pyx_t_20);
        if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_dRPhir.rcbuffer->pybuffer, (PyObject*)__pyx_v_dRPhir, &__Pyx_TypeInfo_double, PyBUF_FORMAT| PyBUF_STRIDES| PyBUF_WRITABLE, 1, 0, __pyx_stack) == -1)) {
          Py_XDECREF(__pyx_t_22); Py_XDECREF(__pyx_t_21); Py_XDECREF(__pyx_t_20);
          __Pyx_RaiseBufferFallbackError();
        } else {
          PyErr_Restore(__pyx_t_22, __pyx_t_21, __pyx_t_20);
        }
      }
      __pyx_pybuffernd_dRPhir.diminfo[0].strides = __pyx_pybuffernd_dRPhir.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_dRPhir.diminfo[0].shape = __pyx_pybuffernd_dRPhir.rcbuffer->pybuffer.shape[0];
      if (unlikely(__pyx_t_14 < 0)) __PYX_ERR(0, 776, __pyx_L1_error)
    }
    __pyx_t_23 = 0;
    __pyx_v_dRPhir = ((PyArrayObject *)__pyx_t_15);
    __pyx_t_15 = 0;
    __pyx_v_dPhir = __pyx_t_26;
    __pyx_t_26.memview = NULL;
    __pyx_t_26.data = NULL;
+777:         Phin = np.zeros((Ln,),dtype=int)
    __pyx_t_15 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 777, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_15);
    __pyx_t_11 = __Pyx_PyObject_GetAttrStr(__pyx_t_15, __pyx_n_s_zeros); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 777, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_11);
    __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
    __pyx_t_15 = __Pyx_PyInt_From_int(__pyx_v_Ln); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 777, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_15);
    __pyx_t_10 = PyTuple_New(1); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 777, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_10);
    __Pyx_GIVEREF(__pyx_t_15);
    PyTuple_SET_ITEM(__pyx_t_10, 0, __pyx_t_15);
    __pyx_t_15 = 0;
    __pyx_t_15 = PyTuple_New(1); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 777, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_15);
    __Pyx_GIVEREF(__pyx_t_10);
    PyTuple_SET_ITEM(__pyx_t_15, 0, __pyx_t_10);
    __pyx_t_10 = 0;
    __pyx_t_10 = PyDict_New(); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 777, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_10);
    if (PyDict_SetItem(__pyx_t_10, __pyx_n_s_dtype, ((PyObject *)(&PyInt_Type))) < 0) __PYX_ERR(0, 777, __pyx_L1_error)
    __pyx_t_12 = __Pyx_PyObject_Call(__pyx_t_11, __pyx_t_15, __pyx_t_10); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 777, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_12);
    __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
    __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
    __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
    __pyx_t_25 = __Pyx_PyObject_to_MemoryviewSlice_dc_long(__pyx_t_12);
    if (unlikely(!__pyx_t_25.memview)) __PYX_ERR(0, 777, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
    __pyx_v_Phin = __pyx_t_25;
    __pyx_t_25.memview = NULL;
    __pyx_t_25.data = NULL;
+778:         NRPhi = np.empty((Ln,))
    __pyx_t_10 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 778, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_10);
    __pyx_t_15 = __Pyx_PyObject_GetAttrStr(__pyx_t_10, __pyx_n_s_empty); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 778, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_15);
    __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
    __pyx_t_10 = __Pyx_PyInt_From_int(__pyx_v_Ln); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 778, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_10);
    __pyx_t_11 = PyTuple_New(1); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 778, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_11);
    __Pyx_GIVEREF(__pyx_t_10);
    PyTuple_SET_ITEM(__pyx_t_11, 0, __pyx_t_10);
    __pyx_t_10 = 0;
    __pyx_t_10 = NULL;
    if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_15))) {
      __pyx_t_10 = PyMethod_GET_SELF(__pyx_t_15);
      if (likely(__pyx_t_10)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_15);
        __Pyx_INCREF(__pyx_t_10);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_15, function);
      }
    }
    if (!__pyx_t_10) {
      __pyx_t_12 = __Pyx_PyObject_CallOneArg(__pyx_t_15, __pyx_t_11); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 778, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
      __Pyx_GOTREF(__pyx_t_12);
    } else {
      #if CYTHON_FAST_PYCALL
      if (PyFunction_Check(__pyx_t_15)) {
        PyObject *__pyx_temp[2] = {__pyx_t_10, __pyx_t_11};
        __pyx_t_12 = __Pyx_PyFunction_FastCall(__pyx_t_15, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 778, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
        __Pyx_GOTREF(__pyx_t_12);
        __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
      } else
      #endif
      #if CYTHON_FAST_PYCCALL
      if (__Pyx_PyFastCFunction_Check(__pyx_t_15)) {
        PyObject *__pyx_temp[2] = {__pyx_t_10, __pyx_t_11};
        __pyx_t_12 = __Pyx_PyCFunction_FastCall(__pyx_t_15, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 778, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
        __Pyx_GOTREF(__pyx_t_12);
        __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
      } else
      #endif
      {
        __pyx_t_9 = PyTuple_New(1+1); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 778, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_9);
        __Pyx_GIVEREF(__pyx_t_10); PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_t_10); __pyx_t_10 = NULL;
        __Pyx_GIVEREF(__pyx_t_11);
        PyTuple_SET_ITEM(__pyx_t_9, 0+1, __pyx_t_11);
        __pyx_t_11 = 0;
        __pyx_t_12 = __Pyx_PyObject_Call(__pyx_t_15, __pyx_t_9, NULL); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 778, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_12);
        __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
      }
    }
    __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
    __pyx_t_26 = __Pyx_PyObject_to_MemoryviewSlice_dc_double(__pyx_t_12);
    if (unlikely(!__pyx_t_26.memview)) __PYX_ERR(0, 778, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
    __pyx_v_NRPhi = __pyx_t_26;
    __pyx_t_26.memview = NULL;
    __pyx_t_26.data = NULL;
+779:         NRPhi0 = np.zeros((Ln,),dtype=int)
    __pyx_t_12 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 779, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_12);
    __pyx_t_15 = __Pyx_PyObject_GetAttrStr(__pyx_t_12, __pyx_n_s_zeros); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 779, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_15);
    __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
    __pyx_t_12 = __Pyx_PyInt_From_int(__pyx_v_Ln); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 779, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_12);
    __pyx_t_9 = PyTuple_New(1); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 779, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_9);
    __Pyx_GIVEREF(__pyx_t_12);
    PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_t_12);
    __pyx_t_12 = 0;
    __pyx_t_12 = PyTuple_New(1); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 779, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_12);
    __Pyx_GIVEREF(__pyx_t_9);
    PyTuple_SET_ITEM(__pyx_t_12, 0, __pyx_t_9);
    __pyx_t_9 = 0;
    __pyx_t_9 = PyDict_New(); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 779, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_9);
    if (PyDict_SetItem(__pyx_t_9, __pyx_n_s_dtype, ((PyObject *)(&PyInt_Type))) < 0) __PYX_ERR(0, 779, __pyx_L1_error)
    __pyx_t_11 = __Pyx_PyObject_Call(__pyx_t_15, __pyx_t_12, __pyx_t_9); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 779, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_11);
    __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
    __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
    __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
    __pyx_t_25 = __Pyx_PyObject_to_MemoryviewSlice_dc_long(__pyx_t_11);
    if (unlikely(!__pyx_t_25.memview)) __PYX_ERR(0, 779, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
    __pyx_v_NRPhi0 = __pyx_t_25;
    __pyx_t_25.memview = NULL;
    __pyx_t_25.data = NULL;
+780:         nRPhi0, indR0ii = 0, 0
    __pyx_t_14 = 0;
    __pyx_t_27 = 0;
    __pyx_v_nRPhi0 = __pyx_t_14;
    __pyx_v_indR0ii = __pyx_t_27;
+781:         NP, NPhimax = 0, 0
    __pyx_t_27 = 0;
    __pyx_t_28 = 0;
    __pyx_v_NP = __pyx_t_27;
    __pyx_v_NPhimax = __pyx_t_28;
+782:         Rratio = int(Cceil(np.max(Rref)/np.min(Rref)))
    __pyx_t_9 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 782, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_9);
    __pyx_t_12 = __Pyx_PyObject_GetAttrStr(__pyx_t_9, __pyx_n_s_max); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 782, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_12);
    __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
    __pyx_t_9 = NULL;
    if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_12))) {
      __pyx_t_9 = PyMethod_GET_SELF(__pyx_t_12);
      if (likely(__pyx_t_9)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_12);
        __Pyx_INCREF(__pyx_t_9);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_12, function);
      }
    }
    if (!__pyx_t_9) {
      __pyx_t_11 = __Pyx_PyObject_CallOneArg(__pyx_t_12, ((PyObject *)__pyx_v_Rref)); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 782, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_11);
    } else {
      #if CYTHON_FAST_PYCALL
      if (PyFunction_Check(__pyx_t_12)) {
        PyObject *__pyx_temp[2] = {__pyx_t_9, ((PyObject *)__pyx_v_Rref)};
        __pyx_t_11 = __Pyx_PyFunction_FastCall(__pyx_t_12, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 782, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
        __Pyx_GOTREF(__pyx_t_11);
      } else
      #endif
      #if CYTHON_FAST_PYCCALL
      if (__Pyx_PyFastCFunction_Check(__pyx_t_12)) {
        PyObject *__pyx_temp[2] = {__pyx_t_9, ((PyObject *)__pyx_v_Rref)};
        __pyx_t_11 = __Pyx_PyCFunction_FastCall(__pyx_t_12, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 782, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
        __Pyx_GOTREF(__pyx_t_11);
      } else
      #endif
      {
        __pyx_t_15 = PyTuple_New(1+1); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 782, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_15);
        __Pyx_GIVEREF(__pyx_t_9); PyTuple_SET_ITEM(__pyx_t_15, 0, __pyx_t_9); __pyx_t_9 = NULL;
        __Pyx_INCREF(((PyObject *)__pyx_v_Rref));
        __Pyx_GIVEREF(((PyObject *)__pyx_v_Rref));
        PyTuple_SET_ITEM(__pyx_t_15, 0+1, ((PyObject *)__pyx_v_Rref));
        __pyx_t_11 = __Pyx_PyObject_Call(__pyx_t_12, __pyx_t_15, NULL); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 782, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_11);
        __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
      }
    }
    __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
    __pyx_t_15 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 782, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_15);
    __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_t_15, __pyx_n_s_min); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 782, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_9);
    __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
    __pyx_t_15 = NULL;
    if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_9))) {
      __pyx_t_15 = PyMethod_GET_SELF(__pyx_t_9);
      if (likely(__pyx_t_15)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_9);
        __Pyx_INCREF(__pyx_t_15);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_9, function);
      }
    }
    if (!__pyx_t_15) {
      __pyx_t_12 = __Pyx_PyObject_CallOneArg(__pyx_t_9, ((PyObject *)__pyx_v_Rref)); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 782, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_12);
    } else {
      #if CYTHON_FAST_PYCALL
      if (PyFunction_Check(__pyx_t_9)) {
        PyObject *__pyx_temp[2] = {__pyx_t_15, ((PyObject *)__pyx_v_Rref)};
        __pyx_t_12 = __Pyx_PyFunction_FastCall(__pyx_t_9, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 782, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0;
        __Pyx_GOTREF(__pyx_t_12);
      } else
      #endif
      #if CYTHON_FAST_PYCCALL
      if (__Pyx_PyFastCFunction_Check(__pyx_t_9)) {
        PyObject *__pyx_temp[2] = {__pyx_t_15, ((PyObject *)__pyx_v_Rref)};
        __pyx_t_12 = __Pyx_PyCFunction_FastCall(__pyx_t_9, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 782, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0;
        __Pyx_GOTREF(__pyx_t_12);
      } else
      #endif
      {
        __pyx_t_10 = PyTuple_New(1+1); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 782, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_10);
        __Pyx_GIVEREF(__pyx_t_15); PyTuple_SET_ITEM(__pyx_t_10, 0, __pyx_t_15); __pyx_t_15 = NULL;
        __Pyx_INCREF(((PyObject *)__pyx_v_Rref));
        __Pyx_GIVEREF(((PyObject *)__pyx_v_Rref));
        PyTuple_SET_ITEM(__pyx_t_10, 0+1, ((PyObject *)__pyx_v_Rref));
        __pyx_t_12 = __Pyx_PyObject_Call(__pyx_t_9, __pyx_t_10, NULL); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 782, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_12);
        __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
      }
    }
    __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
    __pyx_t_9 = __Pyx_PyNumber_Divide(__pyx_t_11, __pyx_t_12); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 782, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_9);
    __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
    __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
    __pyx_t_7 = __pyx_PyFloat_AsDouble(__pyx_t_9); if (unlikely((__pyx_t_7 == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 782, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
    __pyx_v_Rratio = ((int)ceil(__pyx_t_7));
+783:         indBounds = np.empty((2,nBounds),dtype=int)
    __pyx_t_9 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 783, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_9);
    __pyx_t_12 = __Pyx_PyObject_GetAttrStr(__pyx_t_9, __pyx_n_s_empty); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 783, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_12);
    __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
    __pyx_t_9 = PyInt_FromSsize_t(__pyx_v_nBounds); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 783, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_9);
    __pyx_t_11 = PyTuple_New(2); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 783, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_11);
    __Pyx_INCREF(__pyx_int_2);
    __Pyx_GIVEREF(__pyx_int_2);
    PyTuple_SET_ITEM(__pyx_t_11, 0, __pyx_int_2);
    __Pyx_GIVEREF(__pyx_t_9);
    PyTuple_SET_ITEM(__pyx_t_11, 1, __pyx_t_9);
    __pyx_t_9 = 0;
    __pyx_t_9 = PyTuple_New(1); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 783, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_9);
    __Pyx_GIVEREF(__pyx_t_11);
    PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_t_11);
    __pyx_t_11 = 0;
    __pyx_t_11 = PyDict_New(); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 783, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_11);
    if (PyDict_SetItem(__pyx_t_11, __pyx_n_s_dtype, ((PyObject *)(&PyInt_Type))) < 0) __PYX_ERR(0, 783, __pyx_L1_error)
    __pyx_t_10 = __Pyx_PyObject_Call(__pyx_t_12, __pyx_t_9, __pyx_t_11); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 783, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_10);
    __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
    __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
    __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
    __pyx_v_indBounds = __pyx_t_10;
    __pyx_t_10 = 0;
+784:         for ii in range(0,Ln):
    __pyx_t_27 = __pyx_v_Ln;
    for (__pyx_t_14 = 0; __pyx_t_14 < __pyx_t_27; __pyx_t_14+=1) {
      __pyx_v_ii = __pyx_t_14;
 785:             # Get the actual RPhi resolution and Phi mesh elements (! depends on R !)
+786:             NRPhi[ii] = Cceil(DPhiMinMax*Rref[ii]/dRPhi)
      __pyx_t_29 = __pyx_v_ii;
      __pyx_t_30 = __pyx_v_ii;
      *((double *) ( /* dim=0 */ ((char *) (((double *) __pyx_v_NRPhi.data) + __pyx_t_30)) )) = ceil(((__pyx_v_DPhiMinMax * (*__Pyx_BufPtrStrided1d(double *, __pyx_pybuffernd_Rref.rcbuffer->pybuffer.buf, __pyx_t_29, __pyx_pybuffernd_Rref.diminfo[0].strides))) / __pyx_v_dRPhi));
+787:             NRPhi_int = int(NRPhi[ii])
      __pyx_t_31 = __pyx_v_ii;
      __pyx_v_NRPhi_int = ((int)(*((double *) ( /* dim=0 */ ((char *) (((double *) __pyx_v_NRPhi.data) + __pyx_t_31)) ))));
+788:             dPhir[ii] = DPhiMinMax/NRPhi[ii]
      __pyx_t_32 = __pyx_v_ii;
      __pyx_t_33 = __pyx_v_ii;
      *((double *) ( /* dim=0 */ ((char *) (((double *) __pyx_v_dPhir.data) + __pyx_t_33)) )) = (__pyx_v_DPhiMinMax / (*((double *) ( /* dim=0 */ ((char *) (((double *) __pyx_v_NRPhi.data) + __pyx_t_32)) ))));
+789:             dRPhir[ii] = dPhir[ii]*Rref[ii]
      __pyx_t_34 = __pyx_v_ii;
      __pyx_t_35 = __pyx_v_ii;
      __pyx_t_36 = __pyx_v_ii;
      *__Pyx_BufPtrStrided1d(double *, __pyx_pybuffernd_dRPhir.rcbuffer->pybuffer.buf, __pyx_t_36, __pyx_pybuffernd_dRPhir.diminfo[0].strides) = ((*((double *) ( /* dim=0 */ ((char *) (((double *) __pyx_v_dPhir.data) + __pyx_t_34)) ))) * (*__Pyx_BufPtrStrided1d(double *, __pyx_pybuffernd_Rref.rcbuffer->pybuffer.buf, __pyx_t_35, __pyx_pybuffernd_Rref.diminfo[0].strides)));
 790:             # Get index and cumulated indices from background
+791:             for jj0 in range(indR0ii,NR0):
      __pyx_t_37 = __pyx_v_NR0;
      for (__pyx_t_38 = __pyx_v_indR0ii; __pyx_t_38 < __pyx_t_37; __pyx_t_38+=1) {
        __pyx_v_jj0 = __pyx_t_38;
+792:                 if jj0==Indin[ii]:
        __pyx_t_39 = __pyx_v_ii;
        __pyx_t_1 = ((__pyx_v_jj0 == (*((long *) ( /* dim=0 */ ((char *) (((long *) __pyx_v_Indin.data) + __pyx_t_39)) )))) != 0);
        if (__pyx_t_1) {
/* … */
        }
+793:                     indR0ii = jj0
          __pyx_v_indR0ii = __pyx_v_jj0;
+794:                     break
          goto __pyx_L19_break;
 795:                 else:
+796:                     nRPhi0 += <long>Cceil(DPhiMinMax*R0[jj0]/dRPhi)
        /*else*/ {
          __pyx_t_40 = __pyx_v_jj0;
          __pyx_v_nRPhi0 = (__pyx_v_nRPhi0 + ((long)ceil(((__pyx_v_DPhiMinMax * (*__Pyx_BufPtrStrided1d(double *, __pyx_pybuffernd_R0.rcbuffer->pybuffer.buf, __pyx_t_40, __pyx_pybuffernd_R0.diminfo[0].strides))) / __pyx_v_dRPhi))));
+797:                     NRPhi0[ii] = nRPhi0
          __pyx_t_41 = __pyx_v_ii;
          *((long *) ( /* dim=0 */ ((char *) (((long *) __pyx_v_NRPhi0.data) + __pyx_t_41)) )) = __pyx_v_nRPhi0;
        }
      }
      __pyx_L19_break:;
 798:             # Get indices of phi
 799:             # Get the extreme indices of the mesh elements that really need to be created within those limits
+800:             for kk in range(0,nBounds):
      __pyx_t_17 = __pyx_v_nBounds;
      for (__pyx_t_18 = 0; __pyx_t_18 < __pyx_t_17; __pyx_t_18+=1) {
        __pyx_v_kk = __pyx_t_18;
+801:                 abs0 = Cabs(BC[kk][0]-PhiMinMax[0])
        __pyx_t_10 = __Pyx_GetItemInt(PyList_GET_ITEM(__pyx_v_BC, __pyx_v_kk), 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 0); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 801, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_10);
        __pyx_t_11 = __Pyx_GetItemInt(__pyx_v_PhiMinMax, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 0); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 801, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_11);
        __pyx_t_9 = PyNumber_Subtract(__pyx_t_10, __pyx_t_11); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 801, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_9);
        __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
        __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
        __pyx_t_11 = PyNumber_Absolute(__pyx_t_9); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 801, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_11);
        __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
        __pyx_t_7 = __pyx_PyFloat_AsDouble(__pyx_t_11); if (unlikely((__pyx_t_7 == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 801, __pyx_L1_error)
        __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
        __pyx_v_abs0 = __pyx_t_7;
+802:                 if abs0-dPhir[ii]*Cfloor(abs0/dPhir[ii])<margin*dPhir[ii]:
        __pyx_t_42 = __pyx_v_ii;
        __pyx_t_43 = __pyx_v_ii;
        __pyx_t_44 = __pyx_v_ii;
        __pyx_t_1 = (((__pyx_v_abs0 - ((*((double *) ( /* dim=0 */ ((char *) (((double *) __pyx_v_dPhir.data) + __pyx_t_42)) ))) * floor((__pyx_v_abs0 / (*((double *) ( /* dim=0 */ ((char *) (((double *) __pyx_v_dPhir.data) + __pyx_t_43)) ))))))) < (__pyx_v_margin * (*((double *) ( /* dim=0 */ ((char *) (((double *) __pyx_v_dPhir.data) + __pyx_t_44)) ))))) != 0);
        if (__pyx_t_1) {
/* … */
          goto __pyx_L23;
        }
+803:                     nPhi0 = int(Cround(abs0/dPhir[ii]))
          __pyx_t_45 = __pyx_v_ii;
          __pyx_v_nPhi0 = ((int)round((__pyx_v_abs0 / (*((double *) ( /* dim=0 */ ((char *) (((double *) __pyx_v_dPhir.data) + __pyx_t_45)) ))))));
 804:                 else:
+805:                     nPhi0 = int(Cfloor(abs0/dPhir[ii]))
        /*else*/ {
          __pyx_t_46 = __pyx_v_ii;
          __pyx_v_nPhi0 = ((int)floor((__pyx_v_abs0 / (*((double *) ( /* dim=0 */ ((char *) (((double *) __pyx_v_dPhir.data) + __pyx_t_46)) ))))));
        }
        __pyx_L23:;
+806:                 abs1 = Cabs(BC[kk][1]-PhiMinMax[0])
        __pyx_t_11 = __Pyx_GetItemInt(PyList_GET_ITEM(__pyx_v_BC, __pyx_v_kk), 1, long, 1, __Pyx_PyInt_From_long, 0, 0, 0); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 806, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_11);
        __pyx_t_9 = __Pyx_GetItemInt(__pyx_v_PhiMinMax, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 0); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 806, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_9);
        __pyx_t_10 = PyNumber_Subtract(__pyx_t_11, __pyx_t_9); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 806, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_10);
        __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
        __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
        __pyx_t_9 = PyNumber_Absolute(__pyx_t_10); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 806, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_9);
        __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
        __pyx_t_7 = __pyx_PyFloat_AsDouble(__pyx_t_9); if (unlikely((__pyx_t_7 == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 806, __pyx_L1_error)
        __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
        __pyx_v_abs1 = __pyx_t_7;
+807:                 if abs1-dPhir[ii]*Cfloor(abs1/dPhir[ii])<margin*dPhir[ii]:
        __pyx_t_47 = __pyx_v_ii;
        __pyx_t_48 = __pyx_v_ii;
        __pyx_t_49 = __pyx_v_ii;
        __pyx_t_1 = (((__pyx_v_abs1 - ((*((double *) ( /* dim=0 */ ((char *) (((double *) __pyx_v_dPhir.data) + __pyx_t_47)) ))) * floor((__pyx_v_abs1 / (*((double *) ( /* dim=0 */ ((char *) (((double *) __pyx_v_dPhir.data) + __pyx_t_48)) ))))))) < (__pyx_v_margin * (*((double *) ( /* dim=0 */ ((char *) (((double *) __pyx_v_dPhir.data) + __pyx_t_49)) ))))) != 0);
        if (__pyx_t_1) {
/* … */
          goto __pyx_L24;
        }
+808:                     nPhi1 = int(Cround(abs1/dPhir[ii]))
          __pyx_t_50 = __pyx_v_ii;
          __pyx_v_nPhi1 = ((int)round((__pyx_v_abs1 / (*((double *) ( /* dim=0 */ ((char *) (((double *) __pyx_v_dPhir.data) + __pyx_t_50)) ))))));
 809:                 else:
+810:                     nPhi1 = int(Cfloor(abs1/dPhir[ii]))
        /*else*/ {
          __pyx_t_51 = __pyx_v_ii;
          __pyx_v_nPhi1 = ((int)floor((__pyx_v_abs1 / (*((double *) ( /* dim=0 */ ((char *) (((double *) __pyx_v_dPhir.data) + __pyx_t_51)) ))))));
        }
        __pyx_L24:;
+811:                 indBounds[0,kk] = nPhi0
        __pyx_t_9 = __Pyx_PyInt_From_int(__pyx_v_nPhi0); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 811, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_9);
        __pyx_t_10 = PyInt_FromSsize_t(__pyx_v_kk); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 811, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_10);
        __pyx_t_11 = PyTuple_New(2); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 811, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_11);
        __Pyx_INCREF(__pyx_int_0);
        __Pyx_GIVEREF(__pyx_int_0);
        PyTuple_SET_ITEM(__pyx_t_11, 0, __pyx_int_0);
        __Pyx_GIVEREF(__pyx_t_10);
        PyTuple_SET_ITEM(__pyx_t_11, 1, __pyx_t_10);
        __pyx_t_10 = 0;
        if (unlikely(PyObject_SetItem(__pyx_v_indBounds, __pyx_t_11, __pyx_t_9) < 0)) __PYX_ERR(0, 811, __pyx_L1_error)
        __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
        __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
+812:                 indBounds[1,kk] = nPhi1
        __pyx_t_9 = __Pyx_PyInt_From_int(__pyx_v_nPhi1); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 812, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_9);
        __pyx_t_11 = PyInt_FromSsize_t(__pyx_v_kk); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 812, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_11);
        __pyx_t_10 = PyTuple_New(2); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 812, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_10);
        __Pyx_INCREF(__pyx_int_1);
        __Pyx_GIVEREF(__pyx_int_1);
        PyTuple_SET_ITEM(__pyx_t_10, 0, __pyx_int_1);
        __Pyx_GIVEREF(__pyx_t_11);
        PyTuple_SET_ITEM(__pyx_t_10, 1, __pyx_t_11);
        __pyx_t_11 = 0;
        if (unlikely(PyObject_SetItem(__pyx_v_indBounds, __pyx_t_10, __pyx_t_9) < 0)) __PYX_ERR(0, 812, __pyx_L1_error)
        __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
        __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
+813:                 Phin[ii] += nPhi1+1-nPhi0
        __pyx_t_52 = __pyx_v_ii;
        *((long *) ( /* dim=0 */ ((char *) (((long *) __pyx_v_Phin.data) + __pyx_t_52)) )) += ((__pyx_v_nPhi1 + 1) - __pyx_v_nPhi0);
      }
 814: 
+815:             if ii==0:
      __pyx_t_1 = ((__pyx_v_ii == 0) != 0);
      if (__pyx_t_1) {
/* … */
      }
+816:                 indI = np.ones((Ln,Phin[ii]*Rratio+1))
        __pyx_t_10 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 816, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_10);
        __pyx_t_11 = __Pyx_PyObject_GetAttrStr(__pyx_t_10, __pyx_n_s_ones); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 816, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_11);
        __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
        __pyx_t_10 = __Pyx_PyInt_From_int(__pyx_v_Ln); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 816, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_10);
        __pyx_t_53 = __pyx_v_ii;
        __pyx_t_12 = __Pyx_PyInt_From_long((((*((long *) ( /* dim=0 */ ((char *) (((long *) __pyx_v_Phin.data) + __pyx_t_53)) ))) * __pyx_v_Rratio) + 1)); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 816, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_12);
        __pyx_t_15 = PyTuple_New(2); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 816, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_15);
        __Pyx_GIVEREF(__pyx_t_10);
        PyTuple_SET_ITEM(__pyx_t_15, 0, __pyx_t_10);
        __Pyx_GIVEREF(__pyx_t_12);
        PyTuple_SET_ITEM(__pyx_t_15, 1, __pyx_t_12);
        __pyx_t_10 = 0;
        __pyx_t_12 = 0;
        __pyx_t_12 = NULL;
        if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_11))) {
          __pyx_t_12 = PyMethod_GET_SELF(__pyx_t_11);
          if (likely(__pyx_t_12)) {
            PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_11);
            __Pyx_INCREF(__pyx_t_12);
            __Pyx_INCREF(function);
            __Pyx_DECREF_SET(__pyx_t_11, function);
          }
        }
        if (!__pyx_t_12) {
          __pyx_t_9 = __Pyx_PyObject_CallOneArg(__pyx_t_11, __pyx_t_15); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 816, __pyx_L1_error)
          __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
          __Pyx_GOTREF(__pyx_t_9);
        } else {
          #if CYTHON_FAST_PYCALL
          if (PyFunction_Check(__pyx_t_11)) {
            PyObject *__pyx_temp[2] = {__pyx_t_12, __pyx_t_15};
            __pyx_t_9 = __Pyx_PyFunction_FastCall(__pyx_t_11, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 816, __pyx_L1_error)
            __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0;
            __Pyx_GOTREF(__pyx_t_9);
            __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
          } else
          #endif
          #if CYTHON_FAST_PYCCALL
          if (__Pyx_PyFastCFunction_Check(__pyx_t_11)) {
            PyObject *__pyx_temp[2] = {__pyx_t_12, __pyx_t_15};
            __pyx_t_9 = __Pyx_PyCFunction_FastCall(__pyx_t_11, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 816, __pyx_L1_error)
            __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0;
            __Pyx_GOTREF(__pyx_t_9);
            __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
          } else
          #endif
          {
            __pyx_t_10 = PyTuple_New(1+1); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 816, __pyx_L1_error)
            __Pyx_GOTREF(__pyx_t_10);
            __Pyx_GIVEREF(__pyx_t_12); PyTuple_SET_ITEM(__pyx_t_10, 0, __pyx_t_12); __pyx_t_12 = NULL;
            __Pyx_GIVEREF(__pyx_t_15);
            PyTuple_SET_ITEM(__pyx_t_10, 0+1, __pyx_t_15);
            __pyx_t_15 = 0;
            __pyx_t_9 = __Pyx_PyObject_Call(__pyx_t_11, __pyx_t_10, NULL); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 816, __pyx_L1_error)
            __Pyx_GOTREF(__pyx_t_9);
            __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
          }
        }
        __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
        if (!(likely(((__pyx_t_9) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_9, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 816, __pyx_L1_error)
        __pyx_t_19 = ((PyArrayObject *)__pyx_t_9);
        {
          __Pyx_BufFmt_StackElem __pyx_stack[1];
          __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_indI.rcbuffer->pybuffer);
          __pyx_t_37 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_indI.rcbuffer->pybuffer, (PyObject*)__pyx_t_19, &__Pyx_TypeInfo_double, PyBUF_FORMAT| PyBUF_STRIDES| PyBUF_WRITABLE, 2, 0, __pyx_stack);
          if (unlikely(__pyx_t_37 < 0)) {
            PyErr_Fetch(&__pyx_t_20, &__pyx_t_21, &__pyx_t_22);
            if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_indI.rcbuffer->pybuffer, (PyObject*)__pyx_v_indI, &__Pyx_TypeInfo_double, PyBUF_FORMAT| PyBUF_STRIDES| PyBUF_WRITABLE, 2, 0, __pyx_stack) == -1)) {
              Py_XDECREF(__pyx_t_20); Py_XDECREF(__pyx_t_21); Py_XDECREF(__pyx_t_22);
              __Pyx_RaiseBufferFallbackError();
            } else {
              PyErr_Restore(__pyx_t_20, __pyx_t_21, __pyx_t_22);
            }
          }
          __pyx_pybuffernd_indI.diminfo[0].strides = __pyx_pybuffernd_indI.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_indI.diminfo[0].shape = __pyx_pybuffernd_indI.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_indI.diminfo[1].strides = __pyx_pybuffernd_indI.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_indI.diminfo[1].shape = __pyx_pybuffernd_indI.rcbuffer->pybuffer.shape[1];
          if (unlikely(__pyx_t_37 < 0)) __PYX_ERR(0, 816, __pyx_L1_error)
        }
        __pyx_t_19 = 0;
        __Pyx_XDECREF_SET(__pyx_v_indI, ((PyArrayObject *)__pyx_t_9));
        __pyx_t_9 = 0;
+817:             jj = 0
      __pyx_v_jj = 0;
+818:             for kk in range(0,nBounds):
      __pyx_t_17 = __pyx_v_nBounds;
      for (__pyx_t_18 = 0; __pyx_t_18 < __pyx_t_17; __pyx_t_18+=1) {
        __pyx_v_kk = __pyx_t_18;
+819:                 for kkb in range(indBounds[0,kk],indBounds[1,kk]+1):
        __pyx_t_9 = PyInt_FromSsize_t(__pyx_v_kk); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 819, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_9);
        __pyx_t_11 = PyTuple_New(2); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 819, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_11);
        __Pyx_INCREF(__pyx_int_0);
        __Pyx_GIVEREF(__pyx_int_0);
        PyTuple_SET_ITEM(__pyx_t_11, 0, __pyx_int_0);
        __Pyx_GIVEREF(__pyx_t_9);
        PyTuple_SET_ITEM(__pyx_t_11, 1, __pyx_t_9);
        __pyx_t_9 = 0;
        __pyx_t_9 = PyObject_GetItem(__pyx_v_indBounds, __pyx_t_11); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 819, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_9);
        __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
        __pyx_t_11 = PyInt_FromSsize_t(__pyx_v_kk); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 819, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_11);
        __pyx_t_10 = PyTuple_New(2); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 819, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_10);
        __Pyx_INCREF(__pyx_int_1);
        __Pyx_GIVEREF(__pyx_int_1);
        PyTuple_SET_ITEM(__pyx_t_10, 0, __pyx_int_1);
        __Pyx_GIVEREF(__pyx_t_11);
        PyTuple_SET_ITEM(__pyx_t_10, 1, __pyx_t_11);
        __pyx_t_11 = 0;
        __pyx_t_11 = PyObject_GetItem(__pyx_v_indBounds, __pyx_t_10); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 819, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_11);
        __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
        __pyx_t_10 = __Pyx_PyInt_AddObjC(__pyx_t_11, __pyx_int_1, 1, 0); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 819, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_10);
        __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
        __pyx_t_11 = PyTuple_New(2); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 819, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_11);
        __Pyx_GIVEREF(__pyx_t_9);
        PyTuple_SET_ITEM(__pyx_t_11, 0, __pyx_t_9);
        __Pyx_GIVEREF(__pyx_t_10);
        PyTuple_SET_ITEM(__pyx_t_11, 1, __pyx_t_10);
        __pyx_t_9 = 0;
        __pyx_t_10 = 0;
        __pyx_t_10 = __Pyx_PyObject_Call(__pyx_builtin_range, __pyx_t_11, NULL); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 819, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_10);
        __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
        if (likely(PyList_CheckExact(__pyx_t_10)) || PyTuple_CheckExact(__pyx_t_10)) {
          __pyx_t_11 = __pyx_t_10; __Pyx_INCREF(__pyx_t_11); __pyx_t_54 = 0;
          __pyx_t_55 = NULL;
        } else {
          __pyx_t_54 = -1; __pyx_t_11 = PyObject_GetIter(__pyx_t_10); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 819, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_11);
          __pyx_t_55 = Py_TYPE(__pyx_t_11)->tp_iternext; if (unlikely(!__pyx_t_55)) __PYX_ERR(0, 819, __pyx_L1_error)
        }
        __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
        for (;;) {
          if (likely(!__pyx_t_55)) {
            if (likely(PyList_CheckExact(__pyx_t_11))) {
              if (__pyx_t_54 >= PyList_GET_SIZE(__pyx_t_11)) break;
              #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
              __pyx_t_10 = PyList_GET_ITEM(__pyx_t_11, __pyx_t_54); __Pyx_INCREF(__pyx_t_10); __pyx_t_54++; if (unlikely(0 < 0)) __PYX_ERR(0, 819, __pyx_L1_error)
              #else
              __pyx_t_10 = PySequence_ITEM(__pyx_t_11, __pyx_t_54); __pyx_t_54++; if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 819, __pyx_L1_error)
              __Pyx_GOTREF(__pyx_t_10);
              #endif
            } else {
              if (__pyx_t_54 >= PyTuple_GET_SIZE(__pyx_t_11)) break;
              #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
              __pyx_t_10 = PyTuple_GET_ITEM(__pyx_t_11, __pyx_t_54); __Pyx_INCREF(__pyx_t_10); __pyx_t_54++; if (unlikely(0 < 0)) __PYX_ERR(0, 819, __pyx_L1_error)
              #else
              __pyx_t_10 = PySequence_ITEM(__pyx_t_11, __pyx_t_54); __pyx_t_54++; if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 819, __pyx_L1_error)
              __Pyx_GOTREF(__pyx_t_10);
              #endif
            }
          } else {
            __pyx_t_10 = __pyx_t_55(__pyx_t_11);
            if (unlikely(!__pyx_t_10)) {
              PyObject* exc_type = PyErr_Occurred();
              if (exc_type) {
                if (likely(exc_type == PyExc_StopIteration || PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
                else __PYX_ERR(0, 819, __pyx_L1_error)
              }
              break;
            }
            __Pyx_GOTREF(__pyx_t_10);
          }
          __Pyx_XDECREF_SET(__pyx_v_kkb, __pyx_t_10);
          __pyx_t_10 = 0;
/* … */
        }
        __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
      }
+820:                     indI[ii,jj] = <double>( kkb )
          __pyx_t_7 = __pyx_PyFloat_AsDouble(__pyx_v_kkb); if (unlikely((__pyx_t_7 == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 820, __pyx_L1_error)
          __pyx_t_56 = __pyx_v_ii;
          __pyx_t_57 = __pyx_v_jj;
          *__Pyx_BufPtrStrided2d(double *, __pyx_pybuffernd_indI.rcbuffer->pybuffer.buf, __pyx_t_56, __pyx_pybuffernd_indI.diminfo[0].strides, __pyx_t_57, __pyx_pybuffernd_indI.diminfo[1].strides) = ((double)__pyx_t_7);
+821:                     jj += 1
          __pyx_v_jj = (__pyx_v_jj + 1);
+822:             NP += Phin[ii]
      __pyx_t_58 = __pyx_v_ii;
      __pyx_v_NP = (__pyx_v_NP + (*((long *) ( /* dim=0 */ ((char *) (((long *) __pyx_v_Phin.data) + __pyx_t_58)) ))));
    }
 823: 
 824:         # Finish counting to get total number of points
+825:         if jj0<=NR0-1:
    __pyx_t_1 = ((__pyx_v_jj0 <= (__pyx_v_NR0 - 1)) != 0);
    if (__pyx_t_1) {
/* … */
    }
+826:             for jj0 in range(indR0ii,NR0):
      __pyx_t_27 = __pyx_v_NR0;
      for (__pyx_t_14 = __pyx_v_indR0ii; __pyx_t_14 < __pyx_t_27; __pyx_t_14+=1) {
        __pyx_v_jj0 = __pyx_t_14;
+827:                 nRPhi0 += <long>Cceil(DPhiMinMax*R0[jj0]/dRPhi)
        __pyx_t_59 = __pyx_v_jj0;
        __pyx_v_nRPhi0 = (__pyx_v_nRPhi0 + ((long)ceil(((__pyx_v_DPhiMinMax * (*__Pyx_BufPtrStrided1d(double *, __pyx_pybuffernd_R0.rcbuffer->pybuffer.buf, __pyx_t_59, __pyx_pybuffernd_R0.diminfo[0].strides))) / __pyx_v_dRPhi))));
      }
 828: 
 829:         # Compute Pts, dV and ind
+830:         Pts = np.empty((3,NP))
    __pyx_t_10 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 830, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_10);
    __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_t_10, __pyx_n_s_empty); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 830, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_9);
    __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
    __pyx_t_10 = __Pyx_PyInt_From_int(__pyx_v_NP); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 830, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_10);
    __pyx_t_15 = PyTuple_New(2); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 830, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_15);
    __Pyx_INCREF(__pyx_int_3);
    __Pyx_GIVEREF(__pyx_int_3);
    PyTuple_SET_ITEM(__pyx_t_15, 0, __pyx_int_3);
    __Pyx_GIVEREF(__pyx_t_10);
    PyTuple_SET_ITEM(__pyx_t_15, 1, __pyx_t_10);
    __pyx_t_10 = 0;
    __pyx_t_10 = NULL;
    if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_9))) {
      __pyx_t_10 = PyMethod_GET_SELF(__pyx_t_9);
      if (likely(__pyx_t_10)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_9);
        __Pyx_INCREF(__pyx_t_10);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_9, function);
      }
    }
    if (!__pyx_t_10) {
      __pyx_t_11 = __Pyx_PyObject_CallOneArg(__pyx_t_9, __pyx_t_15); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 830, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
      __Pyx_GOTREF(__pyx_t_11);
    } else {
      #if CYTHON_FAST_PYCALL
      if (PyFunction_Check(__pyx_t_9)) {
        PyObject *__pyx_temp[2] = {__pyx_t_10, __pyx_t_15};
        __pyx_t_11 = __Pyx_PyFunction_FastCall(__pyx_t_9, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 830, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
        __Pyx_GOTREF(__pyx_t_11);
        __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
      } else
      #endif
      #if CYTHON_FAST_PYCCALL
      if (__Pyx_PyFastCFunction_Check(__pyx_t_9)) {
        PyObject *__pyx_temp[2] = {__pyx_t_10, __pyx_t_15};
        __pyx_t_11 = __Pyx_PyCFunction_FastCall(__pyx_t_9, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 830, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
        __Pyx_GOTREF(__pyx_t_11);
        __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
      } else
      #endif
      {
        __pyx_t_12 = PyTuple_New(1+1); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 830, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_12);
        __Pyx_GIVEREF(__pyx_t_10); PyTuple_SET_ITEM(__pyx_t_12, 0, __pyx_t_10); __pyx_t_10 = NULL;
        __Pyx_GIVEREF(__pyx_t_15);
        PyTuple_SET_ITEM(__pyx_t_12, 0+1, __pyx_t_15);
        __pyx_t_15 = 0;
        __pyx_t_11 = __Pyx_PyObject_Call(__pyx_t_9, __pyx_t_12, NULL); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 830, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_11);
        __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
      }
    }
    __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
    if (!(likely(((__pyx_t_11) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_11, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 830, __pyx_L1_error)
    __pyx_t_19 = ((PyArrayObject *)__pyx_t_11);
    {
      __Pyx_BufFmt_StackElem __pyx_stack[1];
      __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_Pts.rcbuffer->pybuffer);
      __pyx_t_27 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_Pts.rcbuffer->pybuffer, (PyObject*)__pyx_t_19, &__Pyx_TypeInfo_double, PyBUF_FORMAT| PyBUF_STRIDES| PyBUF_WRITABLE, 2, 0, __pyx_stack);
      if (unlikely(__pyx_t_27 < 0)) {
        PyErr_Fetch(&__pyx_t_22, &__pyx_t_21, &__pyx_t_20);
        if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_Pts.rcbuffer->pybuffer, (PyObject*)__pyx_v_Pts, &__Pyx_TypeInfo_double, PyBUF_FORMAT| PyBUF_STRIDES| PyBUF_WRITABLE, 2, 0, __pyx_stack) == -1)) {
          Py_XDECREF(__pyx_t_22); Py_XDECREF(__pyx_t_21); Py_XDECREF(__pyx_t_20);
          __Pyx_RaiseBufferFallbackError();
        } else {
          PyErr_Restore(__pyx_t_22, __pyx_t_21, __pyx_t_20);
        }
      }
      __pyx_pybuffernd_Pts.diminfo[0].strides = __pyx_pybuffernd_Pts.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_Pts.diminfo[0].shape = __pyx_pybuffernd_Pts.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_Pts.diminfo[1].strides = __pyx_pybuffernd_Pts.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_Pts.diminfo[1].shape = __pyx_pybuffernd_Pts.rcbuffer->pybuffer.shape[1];
      if (unlikely(__pyx_t_27 < 0)) __PYX_ERR(0, 830, __pyx_L1_error)
    }
    __pyx_t_19 = 0;
    __pyx_v_Pts = ((PyArrayObject *)__pyx_t_11);
    __pyx_t_11 = 0;
+831:         ind = np.empty((NP,))
    __pyx_t_9 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 831, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_9);
    __pyx_t_12 = __Pyx_PyObject_GetAttrStr(__pyx_t_9, __pyx_n_s_empty); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 831, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_12);
    __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
    __pyx_t_9 = __Pyx_PyInt_From_int(__pyx_v_NP); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 831, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_9);
    __pyx_t_15 = PyTuple_New(1); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 831, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_15);
    __Pyx_GIVEREF(__pyx_t_9);
    PyTuple_SET_ITEM(__pyx_t_15, 0, __pyx_t_9);
    __pyx_t_9 = 0;
    __pyx_t_9 = NULL;
    if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_12))) {
      __pyx_t_9 = PyMethod_GET_SELF(__pyx_t_12);
      if (likely(__pyx_t_9)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_12);
        __Pyx_INCREF(__pyx_t_9);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_12, function);
      }
    }
    if (!__pyx_t_9) {
      __pyx_t_11 = __Pyx_PyObject_CallOneArg(__pyx_t_12, __pyx_t_15); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 831, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
      __Pyx_GOTREF(__pyx_t_11);
    } else {
      #if CYTHON_FAST_PYCALL
      if (PyFunction_Check(__pyx_t_12)) {
        PyObject *__pyx_temp[2] = {__pyx_t_9, __pyx_t_15};
        __pyx_t_11 = __Pyx_PyFunction_FastCall(__pyx_t_12, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 831, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
        __Pyx_GOTREF(__pyx_t_11);
        __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
      } else
      #endif
      #if CYTHON_FAST_PYCCALL
      if (__Pyx_PyFastCFunction_Check(__pyx_t_12)) {
        PyObject *__pyx_temp[2] = {__pyx_t_9, __pyx_t_15};
        __pyx_t_11 = __Pyx_PyCFunction_FastCall(__pyx_t_12, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 831, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
        __Pyx_GOTREF(__pyx_t_11);
        __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
      } else
      #endif
      {
        __pyx_t_10 = PyTuple_New(1+1); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 831, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_10);
        __Pyx_GIVEREF(__pyx_t_9); PyTuple_SET_ITEM(__pyx_t_10, 0, __pyx_t_9); __pyx_t_9 = NULL;
        __Pyx_GIVEREF(__pyx_t_15);
        PyTuple_SET_ITEM(__pyx_t_10, 0+1, __pyx_t_15);
        __pyx_t_15 = 0;
        __pyx_t_11 = __Pyx_PyObject_Call(__pyx_t_12, __pyx_t_10, NULL); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 831, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_11);
        __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
      }
    }
    __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
    if (!(likely(((__pyx_t_11) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_11, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 831, __pyx_L1_error)
    __pyx_t_23 = ((PyArrayObject *)__pyx_t_11);
    {
      __Pyx_BufFmt_StackElem __pyx_stack[1];
      __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_ind.rcbuffer->pybuffer);
      __pyx_t_27 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_ind.rcbuffer->pybuffer, (PyObject*)__pyx_t_23, &__Pyx_TypeInfo_double, PyBUF_FORMAT| PyBUF_STRIDES| PyBUF_WRITABLE, 1, 0, __pyx_stack);
      if (unlikely(__pyx_t_27 < 0)) {
        PyErr_Fetch(&__pyx_t_20, &__pyx_t_21, &__pyx_t_22);
        if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_ind.rcbuffer->pybuffer, (PyObject*)__pyx_v_ind, &__Pyx_TypeInfo_double, PyBUF_FORMAT| PyBUF_STRIDES| PyBUF_WRITABLE, 1, 0, __pyx_stack) == -1)) {
          Py_XDECREF(__pyx_t_20); Py_XDECREF(__pyx_t_21); Py_XDECREF(__pyx_t_22);
          __Pyx_RaiseBufferFallbackError();
        } else {
          PyErr_Restore(__pyx_t_20, __pyx_t_21, __pyx_t_22);
        }
      }
      __pyx_pybuffernd_ind.diminfo[0].strides = __pyx_pybuffernd_ind.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_ind.diminfo[0].shape = __pyx_pybuffernd_ind.rcbuffer->pybuffer.shape[0];
      if (unlikely(__pyx_t_27 < 0)) __PYX_ERR(0, 831, __pyx_L1_error)
    }
    __pyx_t_23 = 0;
    __pyx_v_ind = ((PyArrayObject *)__pyx_t_11);
    __pyx_t_11 = 0;
+832:         dS = np.empty((NP,))
    __pyx_t_12 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 832, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_12);
    __pyx_t_10 = __Pyx_PyObject_GetAttrStr(__pyx_t_12, __pyx_n_s_empty); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 832, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_10);
    __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
    __pyx_t_12 = __Pyx_PyInt_From_int(__pyx_v_NP); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 832, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_12);
    __pyx_t_15 = PyTuple_New(1); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 832, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_15);
    __Pyx_GIVEREF(__pyx_t_12);
    PyTuple_SET_ITEM(__pyx_t_15, 0, __pyx_t_12);
    __pyx_t_12 = 0;
    __pyx_t_12 = NULL;
    if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_10))) {
      __pyx_t_12 = PyMethod_GET_SELF(__pyx_t_10);
      if (likely(__pyx_t_12)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_10);
        __Pyx_INCREF(__pyx_t_12);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_10, function);
      }
    }
    if (!__pyx_t_12) {
      __pyx_t_11 = __Pyx_PyObject_CallOneArg(__pyx_t_10, __pyx_t_15); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 832, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
      __Pyx_GOTREF(__pyx_t_11);
    } else {
      #if CYTHON_FAST_PYCALL
      if (PyFunction_Check(__pyx_t_10)) {
        PyObject *__pyx_temp[2] = {__pyx_t_12, __pyx_t_15};
        __pyx_t_11 = __Pyx_PyFunction_FastCall(__pyx_t_10, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 832, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0;
        __Pyx_GOTREF(__pyx_t_11);
        __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
      } else
      #endif
      #if CYTHON_FAST_PYCCALL
      if (__Pyx_PyFastCFunction_Check(__pyx_t_10)) {
        PyObject *__pyx_temp[2] = {__pyx_t_12, __pyx_t_15};
        __pyx_t_11 = __Pyx_PyCFunction_FastCall(__pyx_t_10, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 832, __pyx_L1_error)
        __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0;
        __Pyx_GOTREF(__pyx_t_11);
        __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
      } else
      #endif
      {
        __pyx_t_9 = PyTuple_New(1+1); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 832, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_9);
        __Pyx_GIVEREF(__pyx_t_12); PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_t_12); __pyx_t_12 = NULL;
        __Pyx_GIVEREF(__pyx_t_15);
        PyTuple_SET_ITEM(__pyx_t_9, 0+1, __pyx_t_15);
        __pyx_t_15 = 0;
        __pyx_t_11 = __Pyx_PyObject_Call(__pyx_t_10, __pyx_t_9, NULL); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 832, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_11);
        __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
      }
    }
    __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
    if (!(likely(((__pyx_t_11) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_11, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 832, __pyx_L1_error)
    __pyx_t_23 = ((PyArrayObject *)__pyx_t_11);
    {
      __Pyx_BufFmt_StackElem __pyx_stack[1];
      __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_dS.rcbuffer->pybuffer);
      __pyx_t_27 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_dS.rcbuffer->pybuffer, (PyObject*)__pyx_t_23, &__Pyx_TypeInfo_double, PyBUF_FORMAT| PyBUF_STRIDES| PyBUF_WRITABLE, 1, 0, __pyx_stack);
      if (unlikely(__pyx_t_27 < 0)) {
        PyErr_Fetch(&__pyx_t_22, &__pyx_t_21, &__pyx_t_20);
        if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_dS.rcbuffer->pybuffer, (PyObject*)__pyx_v_dS, &__Pyx_TypeInfo_double, PyBUF_FORMAT| PyBUF_STRIDES| PyBUF_WRITABLE, 1, 0, __pyx_stack) == -1)) {
          Py_XDECREF(__pyx_t_22); Py_XDECREF(__pyx_t_21); Py_XDECREF(__pyx_t_20);
          __Pyx_RaiseBufferFallbackError();
        } else {
          PyErr_Restore(__pyx_t_22, __pyx_t_21, __pyx_t_20);
        }
      }
      __pyx_pybuffernd_dS.diminfo[0].strides = __pyx_pybuffernd_dS.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_dS.diminfo[0].shape = __pyx_pybuffernd_dS.rcbuffer->pybuffer.shape[0];
      if (unlikely(__pyx_t_27 < 0)) __PYX_ERR(0, 832, __pyx_L1_error)
    }
    __pyx_t_23 = 0;
    __pyx_v_dS = ((PyArrayObject *)__pyx_t_11);
    __pyx_t_11 = 0;
 833:         # This triple loop is the longest part, it takes ~90% of the CPU time
+834:         NP = 0
    __pyx_v_NP = 0;
+835:         if Out.lower()=='(x,y,z)':
    __pyx_t_10 = __Pyx_PyObject_GetAttrStr(__pyx_v_Out, __pyx_n_s_lower); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 835, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_10);
    __pyx_t_9 = NULL;
    if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_10))) {
      __pyx_t_9 = PyMethod_GET_SELF(__pyx_t_10);
      if (likely(__pyx_t_9)) {
        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_10);
        __Pyx_INCREF(__pyx_t_9);
        __Pyx_INCREF(function);
        __Pyx_DECREF_SET(__pyx_t_10, function);
      }
    }
    if (__pyx_t_9) {
      __pyx_t_11 = __Pyx_PyObject_CallOneArg(__pyx_t_10, __pyx_t_9); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 835, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
    } else {
      __pyx_t_11 = __Pyx_PyObject_CallNoArg(__pyx_t_10); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 835, __pyx_L1_error)
    }
    __Pyx_GOTREF(__pyx_t_11);
    __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
    __pyx_t_1 = (__Pyx_PyUnicode_Equals(__pyx_t_11, __pyx_kp_u_x_y_z, Py_EQ)); if (unlikely(__pyx_t_1 < 0)) __PYX_ERR(0, 835, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
    if (__pyx_t_1) {
/* … */
      goto __pyx_L33;
    }
+836:             for ii in range(0,Ln):
      __pyx_t_27 = __pyx_v_Ln;
      for (__pyx_t_14 = 0; __pyx_t_14 < __pyx_t_27; __pyx_t_14+=1) {
        __pyx_v_ii = __pyx_t_14;
+837:                 for jj in range(0,Phin[ii]):
        __pyx_t_60 = __pyx_v_ii;
        __pyx_t_28 = (*((long *) ( /* dim=0 */ ((char *) (((long *) __pyx_v_Phin.data) + __pyx_t_60)) )));
        for (__pyx_t_37 = 0; __pyx_t_37 < __pyx_t_28; __pyx_t_37+=1) {
          __pyx_v_jj = __pyx_t_37;
+838:                     indiijj = indI[ii,jj]
          __pyx_t_61 = __pyx_v_ii;
          __pyx_t_62 = __pyx_v_jj;
          __pyx_v_indiijj = (*__Pyx_BufPtrStrided2d(double *, __pyx_pybuffernd_indI.rcbuffer->pybuffer.buf, __pyx_t_61, __pyx_pybuffernd_indI.diminfo[0].strides, __pyx_t_62, __pyx_pybuffernd_indI.diminfo[1].strides));
+839:                     phi = PhiMinMax[0] + (0.5+indiijj)*dPhir[ii]
          __pyx_t_11 = __Pyx_GetItemInt(__pyx_v_PhiMinMax, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 0); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 839, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_11);
          __pyx_t_63 = __pyx_v_ii;
          __pyx_t_10 = PyFloat_FromDouble(((0.5 + __pyx_v_indiijj) * (*((double *) ( /* dim=0 */ ((char *) (((double *) __pyx_v_dPhir.data) + __pyx_t_63)) ))))); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 839, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_10);
          __pyx_t_9 = PyNumber_Add(__pyx_t_11, __pyx_t_10); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 839, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_9);
          __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
          __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
          __pyx_t_7 = __pyx_PyFloat_AsDouble(__pyx_t_9); if (unlikely((__pyx_t_7 == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 839, __pyx_L1_error)
          __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
          __pyx_v_phi = __pyx_t_7;
+840:                     Pts[0,NP] = PtsCross[0,ii]*Ccos(phi)
          __pyx_t_64 = 0;
          __pyx_t_65 = __pyx_v_ii;
          __pyx_t_66 = 0;
          __pyx_t_67 = __pyx_v_NP;
          *__Pyx_BufPtrStrided2d(double *, __pyx_pybuffernd_Pts.rcbuffer->pybuffer.buf, __pyx_t_66, __pyx_pybuffernd_Pts.diminfo[0].strides, __pyx_t_67, __pyx_pybuffernd_Pts.diminfo[1].strides) = ((*__Pyx_BufPtrStrided2d(double *, __pyx_pybuffernd_PtsCross.rcbuffer->pybuffer.buf, __pyx_t_64, __pyx_pybuffernd_PtsCross.diminfo[0].strides, __pyx_t_65, __pyx_pybuffernd_PtsCross.diminfo[1].strides)) * cos(__pyx_v_phi));
+841:                     Pts[1,NP] = PtsCross[0,ii]*Csin(phi)
          __pyx_t_68 = 0;
          __pyx_t_69 = __pyx_v_ii;
          __pyx_t_70 = 1;
          __pyx_t_71 = __pyx_v_NP;
          *__Pyx_BufPtrStrided2d(double *, __pyx_pybuffernd_Pts.rcbuffer->pybuffer.buf, __pyx_t_70, __pyx_pybuffernd_Pts.diminfo[0].strides, __pyx_t_71, __pyx_pybuffernd_Pts.diminfo[1].strides) = ((*__Pyx_BufPtrStrided2d(double *, __pyx_pybuffernd_PtsCross.rcbuffer->pybuffer.buf, __pyx_t_68, __pyx_pybuffernd_PtsCross.diminfo[0].strides, __pyx_t_69, __pyx_pybuffernd_PtsCross.diminfo[1].strides)) * sin(__pyx_v_phi));
+842:                     Pts[2,NP] = PtsCross[1,ii]
          __pyx_t_72 = 1;
          __pyx_t_73 = __pyx_v_ii;
          __pyx_t_74 = 2;
          __pyx_t_75 = __pyx_v_NP;
          *__Pyx_BufPtrStrided2d(double *, __pyx_pybuffernd_Pts.rcbuffer->pybuffer.buf, __pyx_t_74, __pyx_pybuffernd_Pts.diminfo[0].strides, __pyx_t_75, __pyx_pybuffernd_Pts.diminfo[1].strides) = (*__Pyx_BufPtrStrided2d(double *, __pyx_pybuffernd_PtsCross.rcbuffer->pybuffer.buf, __pyx_t_72, __pyx_pybuffernd_PtsCross.diminfo[0].strides, __pyx_t_73, __pyx_pybuffernd_PtsCross.diminfo[1].strides));
+843:                     ind[NP] = NRPhi0[ii] + indiijj
          __pyx_t_76 = __pyx_v_ii;
          __pyx_t_77 = __pyx_v_NP;
          *__Pyx_BufPtrStrided1d(double *, __pyx_pybuffernd_ind.rcbuffer->pybuffer.buf, __pyx_t_77, __pyx_pybuffernd_ind.diminfo[0].strides) = ((*((long *) ( /* dim=0 */ ((char *) (((long *) __pyx_v_NRPhi0.data) + __pyx_t_76)) ))) + __pyx_v_indiijj);
+844:                     dS[NP] = dLr[ii]*dRPhir[ii]
          __pyx_t_78 = __pyx_v_ii;
          __pyx_t_79 = __pyx_v_ii;
          __pyx_t_80 = __pyx_v_NP;
          *__Pyx_BufPtrStrided1d(double *, __pyx_pybuffernd_dS.rcbuffer->pybuffer.buf, __pyx_t_80, __pyx_pybuffernd_dS.diminfo[0].strides) = ((*__Pyx_BufPtrStrided1d(double *, __pyx_pybuffernd_dLr.rcbuffer->pybuffer.buf, __pyx_t_78, __pyx_pybuffernd_dLr.diminfo[0].strides)) * (*__Pyx_BufPtrStrided1d(double *, __pyx_pybuffernd_dRPhir.rcbuffer->pybuffer.buf, __pyx_t_79, __pyx_pybuffernd_dRPhir.diminfo[0].strides)));
+845:                     NP += 1
          __pyx_v_NP = (__pyx_v_NP + 1);
        }
      }
 846:         else:
+847:             for ii in range(0,Ln):
    /*else*/ {
      __pyx_t_27 = __pyx_v_Ln;
      for (__pyx_t_14 = 0; __pyx_t_14 < __pyx_t_27; __pyx_t_14+=1) {
        __pyx_v_ii = __pyx_t_14;
+848:                 for jj in range(0,Phin[ii]):
        __pyx_t_81 = __pyx_v_ii;
        __pyx_t_28 = (*((long *) ( /* dim=0 */ ((char *) (((long *) __pyx_v_Phin.data) + __pyx_t_81)) )));
        for (__pyx_t_37 = 0; __pyx_t_37 < __pyx_t_28; __pyx_t_37+=1) {
          __pyx_v_jj = __pyx_t_37;
+849:                     indiijj = indI[ii,jj]
          __pyx_t_82 = __pyx_v_ii;
          __pyx_t_83 = __pyx_v_jj;
          __pyx_v_indiijj = (*__Pyx_BufPtrStrided2d(double *, __pyx_pybuffernd_indI.rcbuffer->pybuffer.buf, __pyx_t_82, __pyx_pybuffernd_indI.diminfo[0].strides, __pyx_t_83, __pyx_pybuffernd_indI.diminfo[1].strides));
+850:                     Pts[0,NP] = PtsCross[0,ii]
          __pyx_t_84 = 0;
          __pyx_t_85 = __pyx_v_ii;
          __pyx_t_86 = 0;
          __pyx_t_87 = __pyx_v_NP;
          *__Pyx_BufPtrStrided2d(double *, __pyx_pybuffernd_Pts.rcbuffer->pybuffer.buf, __pyx_t_86, __pyx_pybuffernd_Pts.diminfo[0].strides, __pyx_t_87, __pyx_pybuffernd_Pts.diminfo[1].strides) = (*__Pyx_BufPtrStrided2d(double *, __pyx_pybuffernd_PtsCross.rcbuffer->pybuffer.buf, __pyx_t_84, __pyx_pybuffernd_PtsCross.diminfo[0].strides, __pyx_t_85, __pyx_pybuffernd_PtsCross.diminfo[1].strides));
+851:                     Pts[1,NP] = PtsCross[1,ii]
          __pyx_t_88 = 1;
          __pyx_t_89 = __pyx_v_ii;
          __pyx_t_90 = 1;
          __pyx_t_91 = __pyx_v_NP;
          *__Pyx_BufPtrStrided2d(double *, __pyx_pybuffernd_Pts.rcbuffer->pybuffer.buf, __pyx_t_90, __pyx_pybuffernd_Pts.diminfo[0].strides, __pyx_t_91, __pyx_pybuffernd_Pts.diminfo[1].strides) = (*__Pyx_BufPtrStrided2d(double *, __pyx_pybuffernd_PtsCross.rcbuffer->pybuffer.buf, __pyx_t_88, __pyx_pybuffernd_PtsCross.diminfo[0].strides, __pyx_t_89, __pyx_pybuffernd_PtsCross.diminfo[1].strides));
+852:                     Pts[2,NP] = PhiMinMax[0] + (0.5+indiijj)*dPhir[ii]
          __pyx_t_9 = __Pyx_GetItemInt(__pyx_v_PhiMinMax, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 0); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 852, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_9);
          __pyx_t_92 = __pyx_v_ii;
          __pyx_t_10 = PyFloat_FromDouble(((0.5 + __pyx_v_indiijj) * (*((double *) ( /* dim=0 */ ((char *) (((double *) __pyx_v_dPhir.data) + __pyx_t_92)) ))))); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 852, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_10);
          __pyx_t_11 = PyNumber_Add(__pyx_t_9, __pyx_t_10); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 852, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_11);
          __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
          __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
          __pyx_t_7 = __pyx_PyFloat_AsDouble(__pyx_t_11); if (unlikely((__pyx_t_7 == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 852, __pyx_L1_error)
          __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
          __pyx_t_93 = 2;
          __pyx_t_94 = __pyx_v_NP;
          *__Pyx_BufPtrStrided2d(double *, __pyx_pybuffernd_Pts.rcbuffer->pybuffer.buf, __pyx_t_93, __pyx_pybuffernd_Pts.diminfo[0].strides, __pyx_t_94, __pyx_pybuffernd_Pts.diminfo[1].strides) = __pyx_t_7;
+853:                     ind[NP] = NRPhi0[ii] + indiijj
          __pyx_t_95 = __pyx_v_ii;
          __pyx_t_96 = __pyx_v_NP;
          *__Pyx_BufPtrStrided1d(double *, __pyx_pybuffernd_ind.rcbuffer->pybuffer.buf, __pyx_t_96, __pyx_pybuffernd_ind.diminfo[0].strides) = ((*((long *) ( /* dim=0 */ ((char *) (((long *) __pyx_v_NRPhi0.data) + __pyx_t_95)) ))) + __pyx_v_indiijj);
+854:                     dS[NP] = dLr[ii]*dRPhir[ii]
          __pyx_t_97 = __pyx_v_ii;
          __pyx_t_98 = __pyx_v_ii;
          __pyx_t_99 = __pyx_v_NP;
          *__Pyx_BufPtrStrided1d(double *, __pyx_pybuffernd_dS.rcbuffer->pybuffer.buf, __pyx_t_99, __pyx_pybuffernd_dS.diminfo[0].strides) = ((*__Pyx_BufPtrStrided1d(double *, __pyx_pybuffernd_dLr.rcbuffer->pybuffer.buf, __pyx_t_97, __pyx_pybuffernd_dLr.diminfo[0].strides)) * (*__Pyx_BufPtrStrided1d(double *, __pyx_pybuffernd_dRPhir.rcbuffer->pybuffer.buf, __pyx_t_98, __pyx_pybuffernd_dRPhir.diminfo[0].strides)));
+855:                     NP += 1
          __pyx_v_NP = (__pyx_v_NP + 1);
        }
      }
    }
    __pyx_L33:;
 856:     else:
+857:         Pts, dS, ind, NL, dRPhir, nRPhi0 = None, None, None, None, None, None
  /*else*/ {
    __pyx_t_11 = Py_None;
    __Pyx_INCREF(__pyx_t_11);
    __pyx_t_10 = Py_None;
    __Pyx_INCREF(__pyx_t_10);
    __pyx_t_9 = Py_None;
    __Pyx_INCREF(__pyx_t_9);
    __pyx_t_15 = Py_None;
    __Pyx_INCREF(__pyx_t_15);
    __pyx_t_12 = Py_None;
    __Pyx_INCREF(__pyx_t_12);
    __pyx_t_27 = __Pyx_PyInt_As_int(Py_None); if (unlikely((__pyx_t_27 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 857, __pyx_L1_error)
    {
      __Pyx_BufFmt_StackElem __pyx_stack[1];
      __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_Pts.rcbuffer->pybuffer);
      __pyx_t_14 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_Pts.rcbuffer->pybuffer, (PyObject*)((PyArrayObject *)__pyx_t_11), &__Pyx_TypeInfo_double, PyBUF_FORMAT| PyBUF_STRIDES| PyBUF_WRITABLE, 2, 0, __pyx_stack);
      if (unlikely(__pyx_t_14 < 0)) {
        PyErr_Fetch(&__pyx_t_20, &__pyx_t_21, &__pyx_t_22);
        if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_Pts.rcbuffer->pybuffer, (PyObject*)__pyx_v_Pts, &__Pyx_TypeInfo_double, PyBUF_FORMAT| PyBUF_STRIDES| PyBUF_WRITABLE, 2, 0, __pyx_stack) == -1)) {
          Py_XDECREF(__pyx_t_20); Py_XDECREF(__pyx_t_21); Py_XDECREF(__pyx_t_22);
          __Pyx_RaiseBufferFallbackError();
        } else {
          PyErr_Restore(__pyx_t_20, __pyx_t_21, __pyx_t_22);
        }
      }
      __pyx_pybuffernd_Pts.diminfo[0].strides = __pyx_pybuffernd_Pts.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_Pts.diminfo[0].shape = __pyx_pybuffernd_Pts.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_Pts.diminfo[1].strides = __pyx_pybuffernd_Pts.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_Pts.diminfo[1].shape = __pyx_pybuffernd_Pts.rcbuffer->pybuffer.shape[1];
      if (unlikely(__pyx_t_14 < 0)) __PYX_ERR(0, 857, __pyx_L1_error)
    }
    __pyx_v_Pts = ((PyArrayObject *)__pyx_t_11);
    __pyx_t_11 = 0;
    {
      __Pyx_BufFmt_StackElem __pyx_stack[1];
      __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_dS.rcbuffer->pybuffer);
      __pyx_t_14 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_dS.rcbuffer->pybuffer, (PyObject*)((PyArrayObject *)__pyx_t_10), &__Pyx_TypeInfo_double, PyBUF_FORMAT| PyBUF_STRIDES| PyBUF_WRITABLE, 1, 0, __pyx_stack);
      if (unlikely(__pyx_t_14 < 0)) {
        PyErr_Fetch(&__pyx_t_22, &__pyx_t_21, &__pyx_t_20);
        if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_dS.rcbuffer->pybuffer, (PyObject*)__pyx_v_dS, &__Pyx_TypeInfo_double, PyBUF_FORMAT| PyBUF_STRIDES| PyBUF_WRITABLE, 1, 0, __pyx_stack) == -1)) {
          Py_XDECREF(__pyx_t_22); Py_XDECREF(__pyx_t_21); Py_XDECREF(__pyx_t_20);
          __Pyx_RaiseBufferFallbackError();
        } else {
          PyErr_Restore(__pyx_t_22, __pyx_t_21, __pyx_t_20);
        }
      }
      __pyx_pybuffernd_dS.diminfo[0].strides = __pyx_pybuffernd_dS.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_dS.diminfo[0].shape = __pyx_pybuffernd_dS.rcbuffer->pybuffer.shape[0];
      if (unlikely(__pyx_t_14 < 0)) __PYX_ERR(0, 857, __pyx_L1_error)
    }
    __pyx_v_dS = ((PyArrayObject *)__pyx_t_10);
    __pyx_t_10 = 0;
    {
      __Pyx_BufFmt_StackElem __pyx_stack[1];
      __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_ind.rcbuffer->pybuffer);
      __pyx_t_14 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_ind.rcbuffer->pybuffer, (PyObject*)((PyArrayObject *)__pyx_t_9), &__Pyx_TypeInfo_double, PyBUF_FORMAT| PyBUF_STRIDES| PyBUF_WRITABLE, 1, 0, __pyx_stack);
      if (unlikely(__pyx_t_14 < 0)) {
        PyErr_Fetch(&__pyx_t_20, &__pyx_t_21, &__pyx_t_22);
        if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_ind.rcbuffer->pybuffer, (PyObject*)__pyx_v_ind, &__Pyx_TypeInfo_double, PyBUF_FORMAT| PyBUF_STRIDES| PyBUF_WRITABLE, 1, 0, __pyx_stack) == -1)) {
          Py_XDECREF(__pyx_t_20); Py_XDECREF(__pyx_t_21); Py_XDECREF(__pyx_t_22);
          __Pyx_RaiseBufferFallbackError();
        } else {
          PyErr_Restore(__pyx_t_20, __pyx_t_21, __pyx_t_22);
        }
      }
      __pyx_pybuffernd_ind.diminfo[0].strides = __pyx_pybuffernd_ind.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_ind.diminfo[0].shape = __pyx_pybuffernd_ind.rcbuffer->pybuffer.shape[0];
      if (unlikely(__pyx_t_14 < 0)) __PYX_ERR(0, 857, __pyx_L1_error)
    }
    __pyx_v_ind = ((PyArrayObject *)__pyx_t_9);
    __pyx_t_9 = 0;
    {
      __Pyx_BufFmt_StackElem __pyx_stack[1];
      __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_NL.rcbuffer->pybuffer);
      __pyx_t_14 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_NL.rcbuffer->pybuffer, (PyObject*)((PyArrayObject *)__pyx_t_15), &__Pyx_TypeInfo_long, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack);
      if (unlikely(__pyx_t_14 < 0)) {
        PyErr_Fetch(&__pyx_t_22, &__pyx_t_21, &__pyx_t_20);
        if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_NL.rcbuffer->pybuffer, (PyObject*)__pyx_v_NL, &__Pyx_TypeInfo_long, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {
          Py_XDECREF(__pyx_t_22); Py_XDECREF(__pyx_t_21); Py_XDECREF(__pyx_t_20);
          __Pyx_RaiseBufferFallbackError();
        } else {
          PyErr_Restore(__pyx_t_22, __pyx_t_21, __pyx_t_20);
        }
      }
      __pyx_pybuffernd_NL.diminfo[0].strides = __pyx_pybuffernd_NL.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_NL.diminfo[0].shape = __pyx_pybuffernd_NL.rcbuffer->pybuffer.shape[0];
      if (unlikely(__pyx_t_14 < 0)) __PYX_ERR(0, 857, __pyx_L1_error)
    }
    __pyx_v_NL = ((PyArrayObject *)__pyx_t_15);
    __pyx_t_15 = 0;
    {
      __Pyx_BufFmt_StackElem __pyx_stack[1];
      __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_dRPhir.rcbuffer->pybuffer);
      __pyx_t_14 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_dRPhir.rcbuffer->pybuffer, (PyObject*)((PyArrayObject *)__pyx_t_12), &__Pyx_TypeInfo_double, PyBUF_FORMAT| PyBUF_STRIDES| PyBUF_WRITABLE, 1, 0, __pyx_stack);
      if (unlikely(__pyx_t_14 < 0)) {
        PyErr_Fetch(&__pyx_t_20, &__pyx_t_21, &__pyx_t_22);
        if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_dRPhir.rcbuffer->pybuffer, (PyObject*)__pyx_v_dRPhir, &__Pyx_TypeInfo_double, PyBUF_FORMAT| PyBUF_STRIDES| PyBUF_WRITABLE, 1, 0, __pyx_stack) == -1)) {
          Py_XDECREF(__pyx_t_20); Py_XDECREF(__pyx_t_21); Py_XDECREF(__pyx_t_22);
          __Pyx_RaiseBufferFallbackError();
        } else {
          PyErr_Restore(__pyx_t_20, __pyx_t_21, __pyx_t_22);
        }
      }
      __pyx_pybuffernd_dRPhir.diminfo[0].strides = __pyx_pybuffernd_dRPhir.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_dRPhir.diminfo[0].shape = __pyx_pybuffernd_dRPhir.rcbuffer->pybuffer.shape[0];
      if (unlikely(__pyx_t_14 < 0)) __PYX_ERR(0, 857, __pyx_L1_error)
    }
    __pyx_v_dRPhir = ((PyArrayObject *)__pyx_t_12);
    __pyx_t_12 = 0;
    __pyx_v_nRPhi0 = __pyx_t_27;
  }
  __pyx_L11:;
+858:     return Pts, dS, ind.astype(int), NL, dLr, Rref, dRPhir, nRPhi0, VPbis
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_15 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_ind), __pyx_n_s_astype); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 858, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_15);
  __pyx_t_9 = NULL;
  if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_15))) {
    __pyx_t_9 = PyMethod_GET_SELF(__pyx_t_15);
    if (likely(__pyx_t_9)) {
      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_15);
      __Pyx_INCREF(__pyx_t_9);
      __Pyx_INCREF(function);
      __Pyx_DECREF_SET(__pyx_t_15, function);
    }
  }
  if (!__pyx_t_9) {
    __pyx_t_12 = __Pyx_PyObject_CallOneArg(__pyx_t_15, ((PyObject *)(&PyInt_Type))); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 858, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_12);
  } else {
    #if CYTHON_FAST_PYCALL
    if (PyFunction_Check(__pyx_t_15)) {
      PyObject *__pyx_temp[2] = {__pyx_t_9, ((PyObject *)(&PyInt_Type))};
      __pyx_t_12 = __Pyx_PyFunction_FastCall(__pyx_t_15, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 858, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
      __Pyx_GOTREF(__pyx_t_12);
    } else
    #endif
    #if CYTHON_FAST_PYCCALL
    if (__Pyx_PyFastCFunction_Check(__pyx_t_15)) {
      PyObject *__pyx_temp[2] = {__pyx_t_9, ((PyObject *)(&PyInt_Type))};
      __pyx_t_12 = __Pyx_PyCFunction_FastCall(__pyx_t_15, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 858, __pyx_L1_error)
      __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
      __Pyx_GOTREF(__pyx_t_12);
    } else
    #endif
    {
      __pyx_t_10 = PyTuple_New(1+1); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 858, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_10);
      __Pyx_GIVEREF(__pyx_t_9); PyTuple_SET_ITEM(__pyx_t_10, 0, __pyx_t_9); __pyx_t_9 = NULL;
      __Pyx_INCREF(((PyObject *)(&PyInt_Type)));
      __Pyx_GIVEREF(((PyObject *)(&PyInt_Type)));
      PyTuple_SET_ITEM(__pyx_t_10, 0+1, ((PyObject *)(&PyInt_Type)));
      __pyx_t_12 = __Pyx_PyObject_Call(__pyx_t_15, __pyx_t_10, NULL); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 858, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_12);
      __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
    }
  }
  __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
  __pyx_t_15 = __Pyx_PyInt_From_int(__pyx_v_nRPhi0); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 858, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_15);
  __pyx_t_10 = PyTuple_New(9); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 858, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_10);
  __Pyx_INCREF(((PyObject *)__pyx_v_Pts));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_Pts));
  PyTuple_SET_ITEM(__pyx_t_10, 0, ((PyObject *)__pyx_v_Pts));
  __Pyx_INCREF(((PyObject *)__pyx_v_dS));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_dS));
  PyTuple_SET_ITEM(__pyx_t_10, 1, ((PyObject *)__pyx_v_dS));
  __Pyx_GIVEREF(__pyx_t_12);
  PyTuple_SET_ITEM(__pyx_t_10, 2, __pyx_t_12);
  __Pyx_INCREF(((PyObject *)__pyx_v_NL));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_NL));
  PyTuple_SET_ITEM(__pyx_t_10, 3, ((PyObject *)__pyx_v_NL));
  __Pyx_INCREF(((PyObject *)__pyx_v_dLr));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_dLr));
  PyTuple_SET_ITEM(__pyx_t_10, 4, ((PyObject *)__pyx_v_dLr));
  __Pyx_INCREF(((PyObject *)__pyx_v_Rref));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_Rref));
  PyTuple_SET_ITEM(__pyx_t_10, 5, ((PyObject *)__pyx_v_Rref));
  __Pyx_INCREF(((PyObject *)__pyx_v_dRPhir));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_dRPhir));
  PyTuple_SET_ITEM(__pyx_t_10, 6, ((PyObject *)__pyx_v_dRPhir));
  __Pyx_GIVEREF(__pyx_t_15);
  PyTuple_SET_ITEM(__pyx_t_10, 7, __pyx_t_15);
  __Pyx_INCREF(((PyObject *)__pyx_v_VPbis));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_VPbis));
  PyTuple_SET_ITEM(__pyx_t_10, 8, ((PyObject *)__pyx_v_VPbis));
  __pyx_t_12 = 0;
  __pyx_t_15 = 0;
  __pyx_r = __pyx_t_10;
  __pyx_t_10 = 0;
  goto __pyx_L0;
 859: 
 860: 
 861: 

In [10]:
VPoly = np.ascontiguousarray([[1,10.,20,20,10,1,1],[0,-10.,0,10,20,10,0.]])
VIn = VPoly[:,1:]-VPoly[:,:-1]
VIn = np.array([-VIn[1,:],VIn[0,:]])
VIn = VIn/np.sqrt(np.sum(VIn**2,axis=0))[np.newaxis,:]
DIn = -0.1
Ptsm, dLm, indm, Nm, Rrefm, VPbism = _Ves_mesh_CrossPoly(VPoly, 1., D1=[0,25], D2=[-25,25], DIn=DIn, VIn=VIn)

#%timeit out = _Ves_mesh_CrossPoly(VPoly, 0.1)
#print np.all(indm==np.unique(indm))

Pts, dS, ind, NL, dLr, Rref, dRPhir, nRPhi0, VPbis = _Ves_Smesh_Tor_SubFromD_cython(0.5, 0.5, VPoly, DR=[0,25], DZ=[-25,25], DPhi=[0,np.pi/2.], Out='(X,Y,Z)', DIn=DIn, VIn=VIn)
Ptsi, dSi, NLi, dLri, Rrefi, dRPhiri, nRPhi0i, VPbisi = _Ves_Smesh_Tor_SubFromInd_cython(0.5, 0.5, VPoly, ind, Out='(X,Y,Z)', DIn=DIn, VIn=VIn)
#%timeit out = _Ves_Smesh_Tor_SubFromD_cython(0.1, 0.1, VPoly, DR=None, DZ=None, DPhi=None, Out='(X,Y,Z)', DIn=DIn, VIn=VIn)
#%timeit out = _Ves_Smesh_Tor_SubFromInd_cython(0.5, 0.5, VPoly, ind, Out='(X,Y,Z)', DIn=DIn, VIn=VIn)
print([np.allclose(A,B,atol=1.e-9,rtol=0.,equal_nan=True) for (A,B) in [(Pts,Ptsi),(dS,dSi),(NL,NLi),(dLr,dLri),(Rref,Rrefi),(dRPhir,dRPhiri),(nRPhi0,nRPhi0i),(VPbis,VPbisi)]])


Ptsb, dSb, indb, NLb, dLrb, Rrefb, dRPhirb, nRPhi0b, VPbisb = _Ves_Smesh_Tor_SubFromD_bis(0.5, 0.5, VPoly, DR=[0,25], DZ=[-25,25], DPhi=[0,np.pi/2.], Out='(X,Y,Z)', DIn=DIn, VIn=VIn)
print([np.allclose(A,B,atol=1.e-9,rtol=0.,equal_nan=True) for (A,B) in [(Pts,Ptsb),(dS,dSb),(ind,indb),(NL,NLb),(dLr,dLrb),(Rref,Rrefb),(dRPhir,dRPhirb),(nRPhi0,nRPhi0b),(VPbis,VPbisb)]])
PhiMinMax = np.array([-np.pi/2.,0.])
#Ptsb, dSb, indb, NLb, dLrb, Rrefb, dRPhirb, nRPhi0b, VPbisb = _Ves_Smesh_Tor_SubFromD_bis(0.5, 0.5, VPoly, PhiMinMax=PhiMinMax, DR=[0,25], DZ=[-25,25], DPhi=[0,np.pi/2.], Out='(X,Y,Z)', DIn=DIn, VIn=VIn)



#PhiMinMax = np.array([-np.pi/2.,0.])
#PtsS, dSS, indS, NL, dLr, Rref, dR0r, dZ0r, dRPhir, VPbis = _Ves_Smesh_TorStruct_SubFromD_cython(PhiMinMax, 0.5, 0.5, VPoly, DR=[0.,25.], DZ=[-25.,25.], DPhi=[-np.pi/8.,0.], Out='(x,y,z)', DIn=DIn, VIn=VIn)
#PtsSi, dSSi, NLi, dLri, Rrefi, dR0ri, dZ0ri, dRPhiri, VPbisi = _Ves_Smesh_TorStruct_SubFromInd_cython(PhiMinMax, 0.5, 0.5, VPoly, indS, Out='(x,y,z)', DIn=DIn, VIn=VIn)
#%timeit out = _Ves_Smesh_TorStruct_SubFromD_cython(PhiMinMax, 0.1, 0.1, VPoly, DR=None, DZ=None, DPhi=None, Out='(X,Y,Z)', DIn=DIn, VIn=VIn)
#%timeit out = _Ves_Smesh_TorStruct_SubFromInd_cython(PhiMinMax, 0.5, 0.5, VPoly, indS, Out='(X,Y,Z)', DIn=DIn, VIn=VIn)
#print [np.allclose(A,B,atol=1.e-9,rtol=0.,equal_nan=True) for (A,B) in [(PtsS,PtsSi),(dSS,dSSi),(NL,NLi),(dLr,dLri),(Rref,Rrefi),(dR0r,dR0ri),(dZ0r,dZ0ri),(dRPhir,dRPhiri),(nRPhi0,nRPhi0i),(VPbis,VPbisi)]]


#PtsL, dS, ind, NL, dLr, Rref, dXr, dY0r, dZ0r, VPbis = _Ves_Smesh_Lin_SubFromD_cython(np.array([0.,10.]), 0.5, 0.01, VPoly, DY=[0.,25.], DZ=[-25.,25.], DX=None, DIn=DIn, VIn=VIn)
#Ptsi, dSi, NLi, dLri, Rrefi, dXri, dY0ri, dZ0ri, VPbisi = _Ves_Smesh_Lin_SubFromInd_cython(np.array([0.,10.]), 0.5, 0.01, VPoly, ind, DIn=DIn, VIn=VIn)
#%timeit out = _Ves_Smesh_Lin_SubFromD_cython(np.array([0.,10.]), 0.5, 0.01, VPoly, DX=None, DY=None, DZ=None, DIn=DIn, VIn=VIn)
#%timeit out = _Ves_Smesh_Lin_SubFromInd_cython(np.array([0.,10.]), 0.5, 0.01, VPoly, ind, DIn=DIn, VIn=VIn)
#print [np.allclose(A,B,atol=1.e-9,rtol=0.,equal_nan=True) for (A,B) in [(PtsL,Ptsi),(dS,dSi),(NL,NLi),(dLr,dLri),(Rref,Rrefi)]]


[True, True, True, True, True, True, True, True]

In [11]:
import matplotlib.pyplot as plt
from mpl_toolkits.mplot3d import Axes3D
"""
f = plt.figure(figsize=(14,10))
ax = f.add_axes([0.1,0.1,0.8,0.8])
ax.plot(VPoly[0,:],VPoly[1,:],'-k')
ax.plot(Ptsm[0,:],Ptsm[1,:], 'xb')
ax.plot(VPbism[0,:], VPbism[1,:],'sr')
"""
f = plt.figure(figsize=(14,10))
ax = f.add_axes([0.1,0.1,0.8,0.8],projection='3d')
ax.plot(Pts[0,:],Pts[1,:], Pts[2,:],'.b')

f = plt.figure(figsize=(14,10))
ax = f.add_axes([0.1,0.1,0.8,0.8],projection='3d')
ax.plot(Ptsb[0,:],Ptsb[1,:], Ptsb[2,:],'.b')
"""
f = plt.figure(figsize=(14,10))
ax = f.add_axes([0.1,0.1,0.8,0.8],projection='3d')
ax.plot(PtsS[0,:],PtsS[1,:], PtsS[2,:],'.b')

f = plt.figure(figsize=(14,10))
ax = f.add_axes([0.1,0.1,0.8,0.8],projection='3d')
ax.plot(PtsL[0,:],PtsL[1,:], PtsL[2,:],'.b')
"""
plt.show()



In [ ]:


In [ ]: