Exemplo n.º 1
0
Arquivo: main.py Projeto: Zebreu/mist
def main_multi(files):
    """ Is executed if the user wants to analyze many scenes at once and compare them """
    ### Initialization
    directional_tree = templates.make_directional()
    other_relationships_tree = templates.make_other_relationships()
    tables = []

    for file in files:
        tables.append(database.RelationshipsTable())
        table = tables[-1]
        ### Parsing
        shapes = x3dparser.parse_file(file)
        x3dparser.parse_child_nodes(shapes)

        ### Geometric representation
        for shape in shapes:
            shape.update_shape()
            shape.calculate_bounding_box()
            #print shape.name, shape.type, shape.location, shape.bounding_box
        print ""

        ### Relationships computation
        compute_without_opposites(shapes, directional_tree, other_relationships_tree, table)

        list_relationships(table, [0,"target","reference"], 4)
Exemplo n.º 2
0
Arquivo: main.py Projeto: Zebreu/mist
def main(filename):
    """ Computes relationships and sets up a query interface for the user """
    ### Initialization
    directional_tree = templates.make_directional()
    other_relationships_tree = templates.make_other_relationships()
    table = database.RelationshipsTable()

    ### Parsing
    shapes = x3dparser.parse_file(filename)
    x3dparser.parse_child_nodes(shapes)

    ### Geometric representation
    for shape in shapes:
        shape.update_shape()
        shape.calculate_bounding_box()
        print shape.name, shape.bounding_box
    print ""

    ### Add scene information to shapes

    minCorner = []
    maxCorner = []

    for i in range(3):
        axevertices = [vertex[i] for shape in shapes for vertex in shape.bounding_box]
        minCorner.append(min(axevertices))
        maxCorner.append(max(axevertices))

    scene_bounding_box = [minCorner, maxCorner]

    for shape in shapes:
        shape.scene_bounding_box = scene_bounding_box

    ### Relationships computation

    #compute_without_opposites(shapes, directional_tree, other_relationships_tree, table)
    compute_everything(shapes, directional_tree, other_relationships_tree, table)

    table.shapes = list(shapes)

    for shape in shapes:
        for relation in dir_relations_supported:
            table.find_relevant(shape, relation)
        table.distance_find_relevant(shape,"isFarFrom")
        table.distance_find_relevant(shape,"isCloseTo")
        table.complete_relevant(shape)

    print len(table.relationships)
    print "Calculated", len(table.relevant), "relevant relationships."

    table.fill_vectors()
    
    for v in table.vectors:
        print v

    ### Interface
    command = "None"
    while command != "exit":
        print "\nObjects in the scene: "
        for shape in shapes:
            print shape.name
        command = raw_input('\nPossible queries (optional arguments between square brackets): \n"list [<name1>] [<relationship>] [<name2>]"\n"exit"\n"relevant"\n')
        print ""
        interpret_commands(command, table)