Пример #1
0
def colormaps() -> List[Colormap]:
    shadersPath = utils.getPath(__file__, '../../../libs/colormap_shaders/glsl')

    with open(utils.getPath(__file__, '../../../data/colormap_shaders.txt')) as file:
        names = [Colormap.formatName(line) for line in file.readlines() if len(line) > 3]

    cmaps = []
    for i, name in enumerate(names):
        preview = str(shadersPath.parent.joinpath('previews', f'{name}.png'))
        with open(f'{shadersPath}/{name}.frag') as f:
            colormap = Colormap(i, name, f.read(), preview)
            cmaps.append(colormap)

    return cmaps
Пример #2
0
def vertexSrc() -> str:
    shaders = ""
    function = 'vec4 colormap(int i, float z){\n'
    function += '    switch(i){\n'
    for i, cmap in enumerate(colormaps()):
        shaders += cmap.parsedSrc + "\n"
        function += f'        case {cmap.id}:\n'
        function += f'            return {cmap.name}(z);\n'
    function += '        default:\n'
    function += '            return vec4(1,0,0,1);\n'
    function += '    }\n'
    function += '}'

    config = ''
    for name, conf in uiConfig().items():
        config += f'uniform {conf["type"]} {name}; // {conf["value"]}\n'

    # Activate program and use it
    with open(utils.getPath(__file__, 'shader_vertex.glsl')) as f:
        src = f.read()
        src = src.replace("#include <colormap_shaders>", shaders)
        src = src.replace("#include <colormap_function>", function)
        src = src.replace("#include <ui_config>", config)
        src = src.replace("#include <model_types>", modelTypes())
        with open('shader_vertex_compiled.glsl', 'w') as f:
            f.write(src)
        return src
Пример #3
0
    def __init__(self):
        self.inited = False
        self.optimizer = None
        self.iterationsLeft = None

        super(MainWindow,
              self).__init__()  # Call the inherited classes __init__ method
        uic.loadUi(utils.getPath(__file__, 'ui/MainWindow.ui'),
                   self)  # Load the .ui file

        self.normalW: OpenGLWidget = OpenGLWidget(self)
        self.zoomW: OpenGLWidget = OpenGLWidget(self)
        self.widgetsHL.addWidget(self.normalW)
        self.widgetsHL.addWidget(self.zoomW)
        self.widgets = [self.normalW, self.zoomW]

        self.__initUI()
        self.__initController()
        self.__initShortcuts()
        self.__initTimers()
Пример #4
0
def functions() -> List[Function]:
    gbfh = {}
    with open(
            utils.getPath(
                __file__,
                '../../data/go_benchmark_functions_hardness.csv')) as f:
        csvf = csv.DictReader(f)
        for row in csvf:
            gbfh[row['name']] = {
                'hardness': 100 - float(row['hardness']),
                'dim': int(row['dim'])
            }

    funs = []
    for funName, benchmark in go_benchmark_functions.__dict__.items():
        if inspect.isclass(benchmark):
            if issubclass(benchmark,
                          Benchmark) and funName not in ['Benchmark']:
                info = gbfh.get(funName, {})
                fun = Function(f=benchmark, hardness=info.get('hardness', -1))
                funs.append(fun)

    return sorted(funs, key=lambda f: f.hardness, reverse=True)
Пример #5
0
def fragmentSrc() -> str:
    with open(utils.getPath(__file__, 'shader_fragments.glsl')) as f:
        return f.read()
Пример #6
0
 def add_dragon(self, color):
     mesh = meshio.read(
         utils.getPath(__file__,
                       '../../../data/models/dragon_vrip_res2.ply'))
     return self.__addMesh(mesh.points, mesh.cells[0].data, color)
Пример #7
0
 def add_bunny(self, color):
     mesh = meshio.read(
         utils.getPath(__file__, '../../../data/models/bun_zipper.ply'))
     return self.__addMesh(mesh.points, mesh.cells[0].data, color)