def _Struct_set_Poly(Poly, pos=None, extent=None, arrayorder='C',
                     Type='Tor', Clock=False):
    """ Compute geometrical attributes of a Struct object """

    # Make Poly closed, counter-clockwise, with '(cc,N)' layout and arrayorder
    Poly = _GG.Poly_Order(Poly, order='C', Clock=False,
                          close=True, layout='(cc,N)', Test=True)
    assert Poly.shape[0]==2, "Arg Poly must be a 2D polygon !"
    fPfmt = np.ascontiguousarray if arrayorder=='C' else np.asfortranarray

    # Get all remarkable points and moments
    NP = Poly.shape[1]-1
    P1Max = Poly[:,np.argmax(Poly[0,:])]
    P1Min = Poly[:,np.argmin(Poly[0,:])]
    P2Max = Poly[:,np.argmax(Poly[1,:])]
    P2Min = Poly[:,np.argmin(Poly[1,:])]
    BaryP = np.sum(Poly[:,:-1],axis=1,keepdims=False)/(Poly.shape[1]-1)
    BaryL = np.array([(P1Max[0]+P1Min[0])/2., (P2Max[1]+P2Min[1])/2.])
    TorP = plg.Polygon(Poly.T)
    Surf = TorP.area()
    BaryS = np.array(TorP.center()).flatten()

    # Get lim-related indicators
    noccur = int(pos.size)
    Multi = noccur>1

    # Get Tor-related quantities
    if Type.lower()=='lin':
        Vol, BaryV = None, None
    else:
        Vol, BaryV = _GG.Poly_VolAngTor(Poly)
        msg = "Pb. with volume computation for Ves object of type 'Tor' !"
        assert Vol>0., msg

    # Compute the non-normalized vector of each side of the Poly
    Vect = np.diff(Poly,n=1,axis=1)
    Vect = fPfmt(Vect)

    # Compute the normalised vectors directed inwards
    Vin = np.array([Vect[1,:],-Vect[0,:]])
    if not _GG.Poly_isClockwise(Poly):
        Vin = -Vin
    Vin = Vin/np.hypot(Vin[0,:],Vin[1,:])[np.newaxis,:]
    Vin = fPfmt(Vin)

    poly = _GG.Poly_Order(Poly, order=arrayorder, Clock=Clock,
                          close=False, layout='(cc,N)', Test=True)

    # Get bounding circle
    circC = BaryS
    r = np.sqrt(np.sum((poly-circC[:,np.newaxis])**2,axis=0))
    circr = np.max(r)

    dout = {'Poly':poly, 'pos':pos, 'extent':extent,
            'noccur':noccur, 'Multi':Multi, 'nP':NP,
            'P1Max':P1Max, 'P1Min':P1Min, 'P2Max':P2Max, 'P2Min':P2Min,
            'BaryP':BaryP, 'BaryL':BaryL, 'BaryS':BaryS, 'BaryV':BaryV,
            'Surf':Surf, 'VolAng':Vol, 'Vect':Vect, 'VIn':Vin,
            'circ-C':circC, 'circ-r':circr, 'Clock':Clock}
    return dout
def _Struct_set_Poly ( Poly , pos = None , extent = None , arrayorder = 'C' , Type = 'Tor' , Clock = False ) : Poly = _GG . Poly_Order ( Poly , order = 'C' , Clock = False , close = True , layout = '(cc,N)' , Test = True ) assert Poly . shape [ 0 ] == 2 , "Arg Poly must be a 2D polygon !" fPfmt = np . ascontiguousarray if arrayorder == 'C' else np . asfortranarray NP = Poly . shape [ 1 ] - 1 P1Max = Poly [ : , np . argmax ( Poly [ 0 , : ] ) ] P1Min = Poly [ : , np . argmin ( Poly [ 0 , : ] ) ] P2Max = Poly [ : , np . argmax ( Poly [ 1 , : ] ) ] P2Min = Poly [ : , np . argmin ( Poly [ 1 , : ] ) ] BaryP = np . sum ( Poly [ : , : - 1 ] , axis = 1 , keepdims = False ) / ( Poly . shape [ 1 ] - 1 ) BaryL = np . array ( [ ( P1Max [ 0 ] + P1Min [ 0 ] ) / 2. , ( P2Max [ 1 ] + P2Min [ 1 ] ) / 2. ] ) TorP = plg . Polygon ( Poly . T ) Surf = TorP . area ( ) BaryS = np . array ( TorP . center ( ) ) . flatten ( ) noccur = int ( pos . size ) Multi = noccur > 1 if Type . lower ( ) == 'lin' : Vol , BaryV = None , None else : Vol , BaryV = _GG . Poly_VolAngTor ( Poly ) msg = "Pb. with volume computation for Ves object of type 'Tor' !" assert Vol > 0. , msg Vect = np . diff ( Poly , n = 1 , axis = 1 ) Vect = fPfmt ( Vect ) Vin = np . array ( [ Vect [ 1 , : ] , - Vect [ 0 , : ] ] ) if not _GG . Poly_isClockwise ( Poly ) : Vin = - Vin Vin = Vin / np . hypot ( Vin [ 0 , : ] , Vin [ 1 , : ] ) [ np . newaxis , : ] Vin = fPfmt ( Vin ) poly = _GG . Poly_Order ( Poly , order = arrayorder , Clock = Clock , close = False , layout = '(cc,N)' , Test = True ) circC = BaryS r = np . sqrt ( np . sum ( ( poly - circC [ : , np . newaxis ] ) ** 2 , axis = 0 ) ) circr = np . max ( r ) dout = { 'Poly' : poly , 'pos' : pos , 'extent' : extent , 'noccur' : noccur , 'Multi' : Multi , 'nP' : NP , 'P1Max' : P1Max , 'P1Min' : P1Min , 'P2Max' : P2Max , 'P2Min' : P2Min , 'BaryP' : BaryP , 'BaryL' : BaryL , 'BaryS' : BaryS , 'BaryV' : BaryV , 'Surf' : Surf , 'VolAng' : Vol , 'Vect' : Vect , 'VIn' : Vin , 'circ-C' : circC , 'circ-r' : circr , 'Clock' : Clock } return dout
Compute geometrical attributes of a Struct object