Esempio n. 1
0
 def translate(self,idgrp):
     lbl_vecx=_(u"Direction x (m)")
     lbl_vecy=_(u"Direction y (m)")
     lbl_vecz=_(u"Direction z (m)")
     res=ui.application.getuserinput(_(u"Translation of a group of receivers"),
                                     _(u"Please enter the coordinates of the translation vector"),
                                 { lbl_vecx : "1.",
                                   lbl_vecy : "0.",
                                   lbl_vecz : "0.",
                                     })
     if res[0]:
         try:
             vectranslation=vec3(float(res[1][lbl_vecx]),float(res[1][lbl_vecy]),float(res[1][lbl_vecz]))
         except:
             print(_(u"Wrong parameters"),file=sys.stderr)
             return
         #on recupere le groupe des rp
         rpgroup=ui.element(idgrp)
         #on recupere tout les indices des rp déjà existante
         rplst=rpgroup.getallelementbytype(ui.element_type.ELEMENT_TYPE_SCENE_RECEPTEURSP_RECEPTEUR)
         for rp in rplst:
             rpEl=ui.element(rp)
             #On recupere la position du rp
             posrecp = rpEl.getpositionconfig("pos_recepteur")
             newpos=vec3(posrecp[0], posrecp[1], posrecp[2])+vectranslation
             rpEl.updatepositionconfig("pos_recepteur",[newpos[0],newpos[1],newpos[2]])
Esempio n. 2
0
 def translate_src(self,idgrp):
     lbl_vecx=_(u"Direction x (m)")
     lbl_vecy=_(u"Direction y (m)")
     lbl_vecz=_(u"Direction z (m)")
     res=ui.application.getuserinput(_(u"Translation of a group of sound sources"),
                                 "",
                                 { lbl_vecx : "1",
                                 lbl_vecy : "0",
                                 lbl_vecz : "0"
                                     })
     if res[0]:
         try:
             vectranslation=vec3(float(res[1][lbl_vecx]), float(res[1][lbl_vecy]), float(res[1][lbl_vecz]))
         except ValueError:
             print(_(u"Wrong parameters"),file=sys.stderr)
             return
         #on recupere le groupe des sources
         srcgroup=ui.element(idgrp)
         #on recupere tout les indices des sources déjà existante
         srclst=srcgroup.getallelementbytype(ui.element_type.ELEMENT_TYPE_SCENE_SOURCES_SOURCE)
         for src in srclst:
             sourceEl=ui.element(src)
             #On recupere la position de la source
             pos_source = sourceEl.getpositionconfig("pos_source")
             newpos=vec3(pos_source[0], pos_source[1], pos_source[2])+vectranslation
             sourceEl.updatepositionconfig("pos_source",[newpos[0],newpos[1],newpos[2]])
Esempio n. 3
0
    def rotate(self,idgrp):
        lbl_vec=_(u"Vector of rotation (m)")
        lbl_angle=_(u"Angle of rotation (degrees)")
        lbl_rotation_pos=_(u"Rotation center (m)")

        #on recupere le groupe des rp
        rpgroup=ui.element(idgrp)
        #on recupere tout les indices des rp déjà existante
        rplst=rpgroup.getallelementbytype(ui.element_type.ELEMENT_TYPE_SCENE_RECEPTEURSP_RECEPTEUR)
        centregroup=vec3()
        for rp in rplst:
            rpEl=ui.element(rp)
            #On recupere la position du récepteur ponctuel
            centregroup+=vec3(rpEl.getpositionconfig("pos_recepteur"))
        centregroup/=len(rplst)
        res=ui.application.getuserinput(_(u"Rotation of a group of receivers"),
                                    "",
                                    { lbl_vec : "[0.,0.,1.]",
                                      lbl_angle : "90",
                                      lbl_rotation_pos : str(centregroup)
                                        })
        if res[0]:
            try:
                vecrotation=vec3(eval(res[1][lbl_vec]))
                anglerotation=float(res[1][lbl_angle])
                centregroup=vec3(eval(res[1][lbl_rotation_pos]))
            except:
                print(_(u"Wrong parameters"),file=sys.stderr)
                return
            for rp in rplst:
                rpEl=ui.element(rp)
                rotatedpos=vec3(rpEl.getpositionconfig("pos_recepteur"))-centregroup
                rotatedpos=rotatedpos.rotate(vecrotation,math.radians(anglerotation))+centregroup
                rpEl.updatepositionconfig("pos_recepteur",[rotatedpos.x,rotatedpos.y,rotatedpos.z])
Esempio n. 4
0
 def translate_src(self,idgrp):
     lbl_vecx=_(u"Direction x (m)")
     lbl_vecy=_(u"Direction y (m)")
     lbl_vecz=_(u"Direction z (m)")
     res=ui.application.getuserinput(_(u"Translation of a group of sound sources"),
                                 "",
                                 { lbl_vecx : "1",
                                 lbl_vecy : "0",
                                 lbl_vecz : "0"
                                     })
     if res[0]:
         try:
             vectranslation=vec3(float(res[1][lbl_vecx]), float(res[1][lbl_vecy]), float(res[1][lbl_vecz]))
         except ValueError:
             print(_(u"Wrong parameters"),file=sys.stderr)
             return
         #on recupere le groupe des sources
         srcgroup=ui.element(idgrp)
         #on recupere tout les indices des sources déjà existante
         srclst=srcgroup.getallelementbytype(ui.element_type.ELEMENT_TYPE_SCENE_SOURCES_SOURCE)
         for src in srclst:
             sourceEl=ui.element(src)
             #On recupere la position de la source
             pos_source = sourceEl.getpositionconfig("pos_source")
             newpos=vec3(pos_source[0], pos_source[1], pos_source[2])+vectranslation
             sourceEl.updatepositionconfig("pos_source",[newpos[0],newpos[1],newpos[2]])
Esempio n. 5
0
def GetRecepteurSurfList(scene,mesh,coreconf,appl_lst,domains_lst, domains_dict):
    """
        Cette méthode est assez lente si il y a beaucoup de mailles
        Il serai possible de passer ceci dans libsimpa afin d'optimiser la recherche
    """
    rslst={}
    transsommets={}
    sommets=[]
    #Ajout des récepteur de surface positionné par les surfaces de la scène
    for tetra in mesh.tetrahedres:
        for face in tetra.tetrafaces:
            if face.marker !=-1:
                idrs=scene.faces[face.marker].idRs
                if idrs!=-1:
                    if not rslst.has_key(idrs):
                        rslst[idrs]=rsurf(coreconf.recepteurssurf[idrs])
                    sommetsCoords=[vec3(sommet.node[0],sommet.node[1],sommet.node[2]) for sommet in [mesh.nodes[idverts] for idverts in face.sommets]]
                    centretri=GetCentreTri(sommetsCoords)
                    appname=GetApplFromPosition( centretri, coreconf.tetmesh, coreconf.splitter, appl_lst, domains_lst, domains_dict )
                    rslst[idrs].pushtriface(centretri,appname)
                    rslst[idrs].pushfacesommets(AddSommetIfUsed(transsommets,sommets,face.sommets,sommetsCoords))
    #Ajout de récepteur de surface de coupe
    for recsurf in coreconf.rootnode["recepteurss"].lstnodesenum("recepteur_surfacique_coupe"):
        idrs=int(recsurf.getproperty("id"))
        newrs=rsurf(idrs)
        vertA=vec3(float(recsurf.getpropertyfloat("ax")),float(recsurf.getpropertyfloat("ay")),float(recsurf.getpropertyfloat("az")))
        vertB=vec3(float(recsurf.getpropertyfloat("bx")),float(recsurf.getpropertyfloat("by")),float(recsurf.getpropertyfloat("bz")))
        vertC=vec3(float(recsurf.getpropertyfloat("cx")),float(recsurf.getpropertyfloat("cy")),float(recsurf.getpropertyfloat("cz")))
        resolution=float(recsurf.getpropertyfloat("resolution"))
        BC=vertC-vertB
        BA=vertA-vertB
        NbCellU=int(ceil(BC.length()/resolution))
        NbCellV=int(ceil(BA.length()/resolution))
        UCellSize=BC.length()/NbCellU
        VCellSize=BA.length()/NbCellV
        stepU=BC/BC.length()*UCellSize
        stepV=BA/BA.length()*VCellSize
        nbvertrow=NbCellU+1;
        nbvertcol=NbCellV+1;
        nodecount=len(sommets)
        #Calcul des coordonnées des sommets
        sommets+=[vertB+(stepU*(idnoderow)+(stepV*(idnodecol))) for idnoderow in range(nbvertrow) for idnodecol in range(nbvertcol)]
        #Calcul des indices des sommets des faces triangulaire.
        facesindex=[[int(nodecount+(idcol+1+(idrow*nbvertcol))),int(nodecount+(idcol+(idrow*nbvertcol))),int(nodecount+(idcol+((idrow+1)*nbvertcol)))] for idcol in range(NbCellV) for idrow in range(NbCellU)]
        facesindex+=[[int(nodecount+(idcol+1+(idrow*nbvertcol))),int(nodecount+(idcol+((idrow+1)*nbvertcol))),int(nodecount+(idcol+1+((idrow+1)*nbvertcol)))] for idcol in range(NbCellV) for idrow in range(NbCellU)]
        map(newrs.pushfacesommets,facesindex)
        #Calcul des coordonnées des points au centre des triangles
        #Et l'application correspondante aux points
        centretri=[GetCentreTri(sommetstri) for sommetstri in [ [sommets[i[0]],sommets[i[1]],sommets[i[2]]] for i in facesindex]]
        appnamelst=[GetApplFromPosition( centreoftri, coreconf.tetmesh, coreconf.splitter, appl_lst, domains_lst, domains_dict ) for centreoftri in centretri]
        [newrs.pushtriface(centreoftri,appname) for centreoftri,appname in zip(centretri,appnamelst)]
        #Ajout du récepteur surfacique
        rslst[idrs]=newrs
    return (rslst,sommets)
Esempio n. 6
0
    def rotate(self,idgrp):
        lbl_vecx=_(u"Vector of rotation x (m)")
        lbl_vecy=_(u"Vector of rotation y (m)")
        lbl_vecz=_(u"Vector of rotation z (m)")
        lbl_angle=_(u"Angle of rotation (degrees)")
        lbl_rotation_posx=_(u"Rotation center x (m)")
        lbl_rotation_posy=_(u"Rotation center y (m)")
        lbl_rotation_posz=_(u"Rotation center z (m)")

        #on recupere le groupe des rp
        rpgroup=ui.element(idgrp)
        #on recupere tout les indices des rp déjà existante
        rplst=rpgroup.getallelementbytype(ui.element_type.ELEMENT_TYPE_SCENE_RECEPTEURSP_RECEPTEUR)
        centregroup=vec3()
        for rp in rplst:
            rpEl=ui.element(rp)
            #On recupere la position du récepteur ponctuel
            pos = rpEl.getpositionconfig("pos_recepteur")
            centregroup += vec3(pos[0], pos[1], pos[2])
        centregroup/=len(rplst)
        res=ui.application.getuserinput(_(u"Rotation of a group of receivers"),
                                    "",
                                    { lbl_vecx : "0.",
                                      lbl_vecy : "0.",
                                      lbl_vecz : "1.",
                                      lbl_angle : "90",
                                      lbl_rotation_posx : "%0.8g" % centregroup[0],
                                      lbl_rotation_posy : "%0.8g" % centregroup[1],
                                      lbl_rotation_posz : "%0.8g" % centregroup[2]
                                        })
        if res[0]:
            try:
                vecrotation=vec3(float(res[1][lbl_vecx]), float(res[1][lbl_vecy]), float(res[1][lbl_vecz]))
                anglerotation=float(res[1][lbl_angle])
                centregroup=vec3(float(res[1][lbl_rotation_posx]),float(res[1][lbl_rotation_posy]),float(res[1][lbl_rotation_posz]))
            except:
                print(_(u"Wrong parameters"),file=sys.stderr)
                return
            for rp in rplst:
                rpEl=ui.element(rp)
                rppos = rpEl.getpositionconfig("pos_recepteur")
                rotatedpos=vec3(rppos[0], rppos[1], rppos[2])-centregroup
                rotatedpos=rotatedpos.Rotation(vecrotation,math.radians(anglerotation))+centregroup
                rpEl.updatepositionconfig("pos_recepteur",[rotatedpos[0],rotatedpos[1],rotatedpos[2]])
Esempio n. 7
0
    def rotate_src(self, idgrp):
        lbl_vec = _(u"Vecteur de rotation")
        lbl_angle = _(u"Angle (degrés)")
        lbl_rotation_pos = _(u"Centre de rotation")
        ##Evaluation du centre de rotation
        #on recupere le groupe des sources
        srcgroup = ui.element(idgrp)
        #on recupere tout les indices des sources déjà existante
        srclst = srcgroup.getallelementbytype(
            ui.element_type.ELEMENT_TYPE_SCENE_SOURCES_SOURCE)
        centregroup = vec3()
        for src in srclst:
            sourceEl = ui.element(src)
            #On recupere la position de la source
            centregroup += vec3(sourceEl.getpositionconfig("pos_source"))
        centregroup /= len(srclst)

        res = ui.application.getuserinput(
            _(u"Rotation d'un groupe de sources sonores"), "", {
                lbl_vec: "[0.,0.,1.]",
                lbl_angle: "90",
                lbl_rotation_pos: str(centregroup)
            })
        if res[0]:
            try:
                vecrotation = vec3(eval(res[1][lbl_vec]))
                anglerotation = float(res[1][lbl_angle])
                centregroup = vec3(eval(res[1][lbl_rotation_pos]))
            except:
                print(_(u"Erreur de saisie des paramètres"), file=sys.stderr)
                return
            #on recupere le groupe des sources
            srcgroup = ui.element(idgrp)
            #on recupere tout les indices des sources déjà existante
            srclst = srcgroup.getallelementbytype(
                ui.element_type.ELEMENT_TYPE_SCENE_SOURCES_SOURCE)
            for src in srclst:
                sourceEl = ui.element(src)
                rotatedpos = vec3(
                    sourceEl.getpositionconfig("pos_source")) - centregroup
                rotatedpos = rotatedpos.rotate(
                    vecrotation, math.radians(anglerotation)) + centregroup
                sourceEl.updatepositionconfig(
                    "pos_source", [rotatedpos.x, rotatedpos.y, rotatedpos.z])
Esempio n. 8
0
 def translate(self,idgrp):
     lbl_vec=_(u"Direction (m)")
     res=ui.application.getuserinput(_(u"Translation of a group of receivers"),
                                 "",
                                 { lbl_vec : "[1.,0.,0.]"
                                     })
     if res[0]:
         try:
             vectranslation=vec3(eval(res[1][lbl_vec]))
         except:
             print(_(u"Wrong parameters"),file=sys.stderr)
             return
         #on recupere le groupe des rp
         rpgroup=ui.element(idgrp)
         #on recupere tout les indices des rp déjà existante
         rplst=rpgroup.getallelementbytype(ui.element_type.ELEMENT_TYPE_SCENE_RECEPTEURSP_RECEPTEUR)
         for rp in rplst:
             rpEl=ui.element(rp)
             #On recupere la position du rp
             newpos=vec3(rpEl.getpositionconfig("pos_recepteur"))+vectranslation
             rpEl.updatepositionconfig("pos_recepteur",[newpos.x,newpos.y,newpos.z])
Esempio n. 9
0
 def translate_src(self,idgrp):
     lbl_vec=_(u"Direction (m)")
     res=ui.application.getuserinput(_(u"Translation of a group of sound sources"),
                                 "",
                                 { lbl_vec : "[1.,0.,0.]"
                                     })
     if res[0]:
         try:
             vectranslation=vec3(eval(res[1][lbl_vec]))
         except:
             print(_(u"Wrong parameters"),file=sys.stderr)
             return
         #on recupere le groupe des sources
         srcgroup=ui.element(idgrp)
         #on recupere tout les indices des sources déjà existante
         srclst=srcgroup.getallelementbytype(ui.element_type.ELEMENT_TYPE_SCENE_SOURCES_SOURCE)
         for src in srclst:
             sourceEl=ui.element(src)
             #On recupere la position de la source
             newpos=vec3(sourceEl.getpositionconfig("pos_source"))+vectranslation
             sourceEl.updatepositionconfig("pos_source",[newpos.x,newpos.y,newpos.z])
Esempio n. 10
0
 def translate_src(self,idgrp):
     lbl_vec=_(u"Direction (m)")
     res=ui.application.getuserinput(_(u"Translation of a group of sound sources"),
                                 "",
                                 { lbl_vec : "[1.,0.,0.]"
                                     })
     if res[0]:
         try:
             vectranslation=vec3(eval(res[1][lbl_vec]))
         except:
             print(_(u"Wrong parameters"),file=sys.stderr)
             return
         #on recupere le groupe des sources
         srcgroup=ui.element(idgrp)
         #on recupere tout les indices des sources déjà existante
         srclst=srcgroup.getallelementbytype(ui.element_type.ELEMENT_TYPE_SCENE_SOURCES_SOURCE)
         for src in srclst:
             sourceEl=ui.element(src)
             #On recupere la position de la source
             newpos=vec3(sourceEl.getpositionconfig("pos_source"))+vectranslation
             sourceEl.updatepositionconfig("pos_source",[newpos.x,newpos.y,newpos.z])
Esempio n. 11
0
    def rotate_src(self, idgrp):
        lbl_vecx = _(u"Vector of rotation x (m)")
        lbl_vecy = _(u"Vector of rotation y (m)")
        lbl_vecz = _(u"Vector of rotation z (m)")
        lbl_angle = _(u"Angle (degrees)")
        lbl_rotation_posx = _(u"Rotation center x (m)")
        lbl_rotation_posy = _(u"Rotation center y (m)")
        lbl_rotation_posz = _(u"Rotation center z (m)")
        ##Evaluation du centre de rotation
        #on recupere le groupe des sources
        srcgroup = ui.element(idgrp)
        #on recupere tout les indices des sources déjà existante
        srclst = srcgroup.getallelementbytype(
            ui.element_type.ELEMENT_TYPE_SCENE_SOURCES_SOURCE)
        centregroup = vec3()
        for src in srclst:
            sourceEl = ui.element(src)
            #On recupere la position de la source
            pos = sourceEl.getpositionconfig("pos_source")
            centregroup += vec3(pos[0], pos[1], pos[2])
        centregroup /= len(srclst)

        res = ui.application.getuserinput(
            _(u"Rotation of a group of sound sources"), "", {
                lbl_vecx: "0",
                lbl_vecy: "0",
                lbl_vecz: "1",
                lbl_angle: "90",
                lbl_rotation_posx: str(centregroup[0]),
                lbl_rotation_posy: str(centregroup[1]),
                lbl_rotation_posz: str(centregroup[2])
            })
        if res[0]:
            vecrotation = vec3()
            try:
                vecrotation = vec3(float(res[1][lbl_vecx]),
                                   float(res[1][lbl_vecy]),
                                   float(res[1][lbl_vecz]))
                anglerotation = float(res[1][lbl_angle])
                centregroup = vec3(float(res[1][lbl_rotation_posx]),
                                   float(res[1][lbl_rotation_posy]),
                                   float(res[1][lbl_rotation_posz]))
            except:
                print(_(u"Wrong parameters"), file=sys.stderr)
                return
            #on recupere le groupe des sources
            srcgroup = ui.element(idgrp)
            #on recupere tout les indices des sources déjà existante
            srclst = srcgroup.getallelementbytype(
                ui.element_type.ELEMENT_TYPE_SCENE_SOURCES_SOURCE)
            for src in srclst:
                sourceEl = ui.element(src)
                pos_source = sourceEl.getpositionconfig("pos_source")
                rotatedpos = vec3(pos_source[0], pos_source[1],
                                  pos_source[2]) - centregroup
                rotatedpos = rotatedpos.Rotation(
                    vecrotation, math.radians(anglerotation)) + centregroup
                sourceEl.updatepositionconfig(
                    "pos_source",
                    [rotatedpos[0], rotatedpos[1], rotatedpos[2]])
Esempio n. 12
0
 def rotate_src(self,idgrp):
     lbl_vec=_(u"Vector of rotation")
     lbl_angle=_(u"Angle (degrees)")
     lbl_rotation_pos=_(u"Rotation centre")
     ##Evaluation du centre de rotation
     #on recupere le groupe des sources
     srcgroup=ui.element(idgrp)
     #on recupere tout les indices des sources déjà existante
     srclst=srcgroup.getallelementbytype(ui.element_type.ELEMENT_TYPE_SCENE_SOURCES_SOURCE)
     centregroup=vec3()
     for src in srclst:
         sourceEl=ui.element(src)
         #On recupere la position de la source
         centregroup+=vec3(sourceEl.getpositionconfig("pos_source"))
     centregroup/=len(srclst)
     
     res=ui.application.getuserinput(_(u"Rotation of a group of sound sources"),
                                 "",
                                 { lbl_vec : "[0.,0.,1.]",
                                   lbl_angle : "90",
                                   lbl_rotation_pos : str(centregroup)
                                     })
     if res[0]:
         try:
             vecrotation=vec3(eval(res[1][lbl_vec]))
             anglerotation=float(res[1][lbl_angle])
             centregroup=vec3(eval(res[1][lbl_rotation_pos]))
         except:
             print(_(u"Wrong parameters"),file=sys.stderr)
             return
         #on recupere le groupe des sources
         srcgroup=ui.element(idgrp)
         #on recupere tout les indices des sources déjà existante
         srclst=srcgroup.getallelementbytype(ui.element_type.ELEMENT_TYPE_SCENE_SOURCES_SOURCE)
         for src in srclst:
             sourceEl=ui.element(src)
             rotatedpos=vec3(sourceEl.getpositionconfig("pos_source"))-centregroup
             rotatedpos=rotatedpos.rotate(vecrotation,math.radians(anglerotation))+centregroup
             sourceEl.updatepositionconfig("pos_source",[rotatedpos.x,rotatedpos.y,rotatedpos.z])
Esempio n. 13
0
 def rotate_src(self,idgrp):
     lbl_vecx=_(u"Vector of rotation x (m)")
     lbl_vecy=_(u"Vector of rotation y (m)")
     lbl_vecz=_(u"Vector of rotation z (m)")
     lbl_angle=_(u"Angle (degrees)")
     lbl_rotation_posx=_(u"Rotation center x (m)")
     lbl_rotation_posy=_(u"Rotation center y (m)")
     lbl_rotation_posz=_(u"Rotation center z (m)")
     ##Evaluation du centre de rotation
     #on recupere le groupe des sources
     srcgroup=ui.element(idgrp)
     #on recupere tout les indices des sources déjà existante
     srclst=srcgroup.getallelementbytype(ui.element_type.ELEMENT_TYPE_SCENE_SOURCES_SOURCE)
     centregroup=vec3()
     for src in srclst:
         sourceEl=ui.element(src)
         #On recupere la position de la source
         pos = sourceEl.getpositionconfig("pos_source")
         centregroup+=vec3(pos[0], pos[1], pos[2])
     centregroup/=len(srclst)
     
     res=ui.application.getuserinput(_(u"Rotation of a group of sound sources"),
                                 "",
                                 { lbl_vecx : "0",
                                 lbl_vecy : "0",
                                 lbl_vecz : "1",
                                   lbl_angle : "90",
                                   lbl_rotation_posx : str(centregroup[0]),
                                   lbl_rotation_posy : str(centregroup[1]),
                                   lbl_rotation_posz : str(centregroup[2])
                                     })
     if res[0]:
         vecrotation = vec3()
         try:
             vecrotation=vec3(float(res[1][lbl_vecx]), float(res[1][lbl_vecy]), float(res[1][lbl_vecz]))
             anglerotation=float(res[1][lbl_angle])
             centregroup=vec3(float(res[1][lbl_rotation_posx]), float(res[1][lbl_rotation_posy]), float(res[1][lbl_rotation_posz]))
         except:
             print(_(u"Wrong parameters"),file=sys.stderr)
             return
         #on recupere le groupe des sources
         srcgroup=ui.element(idgrp)
         #on recupere tout les indices des sources déjà existante
         srclst=srcgroup.getallelementbytype(ui.element_type.ELEMENT_TYPE_SCENE_SOURCES_SOURCE)
         for src in srclst:
             sourceEl=ui.element(src)
             pos_source = sourceEl.getpositionconfig("pos_source")
             rotatedpos=vec3(pos_source[0], pos_source[1], pos_source[2])-centregroup
             rotatedpos=rotatedpos.Rotation(vecrotation,math.radians(anglerotation))+centregroup
             sourceEl.updatepositionconfig("pos_source",[rotatedpos[0],rotatedpos[1], rotatedpos[2]])
Esempio n. 14
0
def to_vec3(vec):
    return ls.vec3(vec[0], vec[1], vec[2])
Esempio n. 15
0
 def __init__(self,node, db):
     self.pos=libsimpa.vec3(node.getpropertyfloat("x"),node.getpropertyfloat("y"),node.getpropertyfloat("z"))
     self.id=int(node.getproperty("id"))
     self.db = db
Esempio n. 16
0
def to_vec3(vec):
    return vec3(vec[0], vec[1], vec[2])
Esempio n. 17
0
    def __init__(self,xmlfilepath):
        ## Xml root node. Use this member to give access to the raw input data of the core.
        self.rootnode=xmlreader.readXmlFile(xmlfilepath)
        ## A list of coreConfig.material instance. Key: XmlIdMaterial
        self.materials={}
        ## A list of sourceElement.sourceElement instance.
        self.sources_lst=[]
        ## None or 3D model data.
        self.scene=None
        ## Dictionnary with Xml Id in Key and Surface Receiver name in values.
        self.recepteursponct={}
        self.recepteurssurf={}
        self.tlm_receivers=0 #Mixing ponctual and surface receivers cells. Keep the same order in the mic.dat file.
        ## Dictionnary giving path information.
        self.paths={}
        ## Main simulation simple data
        self.const={}
        ## A list, contains the frequencies values in Hz.
        self.freqlst=[]
        ## A dictionnary that return the frequency index(value) from the frequency value in hertz(key)
        self.freqlstassoc = {}
        ## A list, only the frequency user selected, contains the coreConfig.freqlst list index.
        self.freqid_docalclst = []
        ## Fittings data. A dictionnary with fittings Xml id in key and fitting Xml node in values.
        self.fittings = {}
        ## A list that contain the m parameter values. Atmospheric absorption computed from temperature, air pressure etc..
        self.abs_atmo = []
        self.tr = libsimpa.vec3()  # translation of model between python and fortran code
        simunode = self.rootnode["simulation"]
        condition_atmospherique_node = self.rootnode["condition_atmospherique"]
        self.paths["workingdirectory"] = self.rootnode.getproperty("workingdirectory")
        self.paths["modelName"] = simunode.getproperty("modelName")
        self.paths["tetrameshFileName"] = simunode.getproperty("tetrameshFileName")
        self.paths["recepteurss_directory"] = simunode.getproperty("recepteurss_directory")
        self.paths["recepteurss_filename"] = simunode.getproperty("recepteurss_filename")
        self.paths["recepteursp_directory"] = simunode.getproperty("receiversp_directory")
        self.paths["recepteursp_filename"] = simunode.getproperty("receiversp_filename")
        self.const["cel"] = libsimpa.CCalculsGenerauxThermodynamique.c_son(
            condition_atmospherique_node.getpropertyfloat("temperature") + 273.15)
        self.const["temperature_celsius"] = condition_atmospherique_node.getpropertyfloat("temperature")
        self.const["temperature_kelvin"] = condition_atmospherique_node.getpropertyfloat("temperature") + 273.15
        self.const["humidite"] = condition_atmospherique_node.getpropertyfloat("humidite")
        self.const["frequencies"] = [int(freq.getproperty("freq")) for freq in self.rootnode["simulation"]["freq_enum"].lstnodesenum("bfreq") if freq.getproperty("docalc") == "1"]
        self.const["frequencies"].sort()
        self.const["allfrequencies"] = [int(freq.getproperty("freq")) for freq in self.rootnode["simulation"]["freq_enum"].lstnodesenum("bfreq")]
        self.const["allfrequencies"].sort()
        self.const["pression"] = condition_atmospherique_node.getpropertyfloat("pression")
        self.const["with_direct_sound"] = bool(int(simunode.getproperty("with_direct_sound", "1")))
        self.const['timestep'] = simunode.getpropertyfloat('pasdetemps', 0.01)
        self.const['tolerance'] = simunode.getpropertyfloat('tolerance', 1e-6)
        self.const['maxint'] = simunode.getpropertyint('maxint', 200)
        self.const['duration'] = simunode.getpropertyfloat('duree_simulation', 2)
        self.const['do_abs_atmo'] = bool(int(simunode.getproperty("do_abs_atmo", "1")))
        self.const['stationary'] = bool(int(simunode.getproperty("stationary", "0")))

        # Load surface receiver
        for recsurf in self.rootnode["recepteurss"].lstnodesenum("recepteur_surfacique"):
            self.recepteurssurf[int(recsurf.getproperty("id"))]={ "name": recsurf.getproperty("name"), "id": int(recsurf.getproperty("id"))}
        for recsurf in self.rootnode["recepteurss"].lstnodesenum("recepteur_surfacique_coupe"):
            self.recepteurssurf[int(recsurf.getproperty("id"))]={ "name": recsurf.getproperty("name"), "a" : vec3(float(recsurf.getpropertyfloat("ax")),float(recsurf.getpropertyfloat("ay")),float(recsurf.getpropertyfloat("az"))), "b" :vec3(float(recsurf.getpropertyfloat("bx")),float(recsurf.getpropertyfloat("by")),float(recsurf.getpropertyfloat("bz"))) , "c" : vec3(float(recsurf.getpropertyfloat("cx")),float(recsurf.getpropertyfloat("cy")),float(recsurf.getpropertyfloat("cz"))), "resolution" : recsurf.getpropertyfloat("resolution") }
        for recponct in self.rootnode["recepteursp"].lstnodesenum("recepteur_ponctuel"):
            self.recepteursponct[int(recponct.getproperty("id"))] = {"name": recponct.getproperty("name"),
                                                                     "power_statio": [],
                                                                     "power_insta": [],
                                                                     "pos": libsimpa.vec3(
                                                                         recponct.getpropertyfloat("x"),
                                                                         recponct.getpropertyfloat("y"),
                                                                         recponct.getpropertyfloat("z"))}
        self.load_materials()
        self.load_sources(self.rootnode["sources"])
        self.load_fittings()
Esempio n. 18
0
 def test_init(self):
     v = ls.vec3(1.2, 1.5, -2.8)
Esempio n. 19
0
 def __init__(self, node, db):
     self.pos = libsimpa.vec3(node.getpropertyfloat("x"),
                              node.getpropertyfloat("y"),
                              node.getpropertyfloat("z"))
     self.id = int(node.getproperty("id"))
     self.db = db
Esempio n. 20
0
 def __init__(self):
     self.pos = libsimpa.vec3()
     self.id = -1
Esempio n. 21
0
 def __init__(self):
     self.pos=libsimpa.vec3()
     self.id=-1
Esempio n. 22
0
    def __init__(self, xmlfilepath):
        ## Xml root node. Use this member to give access to the raw input data of the core.
        self.rootnode = xmlreader.readXmlFile(xmlfilepath)
        ## A list of coreConfig.material instance. Key: XmlIdMaterial
        self.materials = {}
        ## A list of sourceElement.sourceElement instance.
        self.sources_lst = []
        ## None or 3D model data.
        self.scene = None
        ## Dictionnary with Xml Id in Key and Surface Receiver name in values.
        self.recepteursponct = {}
        self.recepteurssurf = {}
        self.tlm_receivers = 0  #Mixing ponctual and surface receivers cells. Keep the same order in the mic.dat file.
        ## Dictionnary giving path information.
        self.paths = {}
        ## Main simulation simple data
        self.const = {}
        ## A list, contains the frequencies values in Hz.
        self.freqlst = []
        ## A dictionnary that return the frequency index(value) from the frequency value in hertz(key)
        self.freqlstassoc = {}
        ## A list, only the frequency user selected, contains the coreConfig.freqlst list index.
        self.freqid_docalclst = []
        ## Fittings data. A dictionnary with fittings Xml id in key and fitting Xml node in values.
        self.fittings = {}
        ## A list that contain the m parameter values. Atmospheric absorption computed from temperature, air pressure etc..
        self.abs_atmo = []
        self.tr = libsimpa.vec3(
        )  # translation of model between python and fortran code
        simunode = self.rootnode["simulation"]
        condition_atmospherique_node = self.rootnode["condition_atmospherique"]
        self.paths["workingdirectory"] = self.rootnode.getproperty(
            "workingdirectory")
        self.paths["modelName"] = simunode.getproperty("modelName")
        self.paths["tetrameshFileName"] = simunode.getproperty(
            "tetrameshFileName")
        self.paths["recepteurss_directory"] = simunode.getproperty(
            "recepteurss_directory")
        self.paths["recepteurss_filename"] = simunode.getproperty(
            "recepteurss_filename")
        self.paths["recepteursp_directory"] = simunode.getproperty(
            "receiversp_directory")
        self.paths["recepteursp_filename"] = simunode.getproperty(
            "receiversp_filename")
        self.const["cel"] = libsimpa.CCalculsGenerauxThermodynamique.c_son(
            condition_atmospherique_node.getpropertyfloat("temperature") +
            273.15)
        self.const[
            "temperature_celsius"] = condition_atmospherique_node.getpropertyfloat(
                "temperature")
        self.const[
            "temperature_kelvin"] = condition_atmospherique_node.getpropertyfloat(
                "temperature") + 273.15
        self.const["humidite"] = condition_atmospherique_node.getpropertyfloat(
            "humidite")
        self.const["frequencies"] = [
            int(freq.getproperty("freq")) for freq in
            self.rootnode["simulation"]["freq_enum"].lstnodesenum("bfreq")
            if freq.getproperty("docalc") == "1"
        ]
        self.const["frequencies"].sort()
        self.const["allfrequencies"] = [
            int(freq.getproperty("freq")) for freq in
            self.rootnode["simulation"]["freq_enum"].lstnodesenum("bfreq")
        ]
        self.const["allfrequencies"].sort()
        self.const["pression"] = condition_atmospherique_node.getpropertyfloat(
            "pression")
        self.const["with_direct_sound"] = bool(
            int(simunode.getproperty("with_direct_sound", "1")))
        self.const['timestep'] = simunode.getpropertyfloat('pasdetemps', 0.01)
        self.const['tolerance'] = simunode.getpropertyfloat('tolerance', 1e-6)
        self.const['maxint'] = simunode.getpropertyint('maxint', 200)
        self.const['duration'] = simunode.getpropertyfloat(
            'duree_simulation', 2)
        self.const['do_abs_atmo'] = bool(
            int(simunode.getproperty("do_abs_atmo", "1")))
        self.const['stationary'] = bool(
            int(simunode.getproperty("stationary", "0")))

        # Load surface receiver
        for recsurf in self.rootnode["recepteurss"].lstnodesenum(
                "recepteur_surfacique"):
            self.recepteurssurf[int(recsurf.getproperty("id"))] = {
                "name": recsurf.getproperty("name"),
                "id": int(recsurf.getproperty("id"))
            }
        for recsurf in self.rootnode["recepteurss"].lstnodesenum(
                "recepteur_surfacique_coupe"):
            self.recepteurssurf[int(recsurf.getproperty("id"))] = {
                "name":
                recsurf.getproperty("name"),
                "a":
                vec3(float(recsurf.getpropertyfloat("ax")),
                     float(recsurf.getpropertyfloat("ay")),
                     float(recsurf.getpropertyfloat("az"))),
                "b":
                vec3(float(recsurf.getpropertyfloat("bx")),
                     float(recsurf.getpropertyfloat("by")),
                     float(recsurf.getpropertyfloat("bz"))),
                "c":
                vec3(float(recsurf.getpropertyfloat("cx")),
                     float(recsurf.getpropertyfloat("cy")),
                     float(recsurf.getpropertyfloat("cz"))),
                "resolution":
                recsurf.getpropertyfloat("resolution")
            }
        for recponct in self.rootnode["recepteursp"].lstnodesenum(
                "recepteur_ponctuel"):
            self.recepteursponct[int(recponct.getproperty("id"))] = {
                "name":
                recponct.getproperty("name"),
                "power_statio": [],
                "power_insta": [],
                "pos":
                libsimpa.vec3(recponct.getpropertyfloat("x"),
                              recponct.getpropertyfloat("y"),
                              recponct.getpropertyfloat("z"))
            }
        self.load_materials()
        self.load_sources(self.rootnode["sources"])
        self.load_fittings()
Esempio n. 23
0
 def test_init(self):
     v = ls.vec3(1.2, 1.5, -2.8)