<commit_before>#! /usr/bin/python
# -*- coding: utf-8 -*-

"""
Read pklz with Pyplasm and LAR
"""
import logging
logger = logging.getLogger(__name__)
import argparse
# import sys
# import os
# path_to_script = os.path.dirname(os.path.abspath(__file__))
# sys.path.append(os.path.join(path_to_script, "./py/computation/"))

# import traceback

# $PYBIN ./py/computation/step_calcchains_serial_tobinary_filter_proc_lisa.py\
# -r -b $BORDER_DIR/$BORDER_FILE -x $BORDER_X -y $BORDER_Y -z $BORDER_Z\
# -i $DIRINPUT -c $COLORS -d $CHAINCURR -q $BESTFILE -o $COMPUTATION_DIR_BIN
import os
import errno
import numpy as np
import shutil
# import py
# import py.computation
# from py.computation import step_remove_boxes_iner_faces
import py.computation.step_calcchains_serial_tobinary_filter_proc_lisa as s2bin
from py.computation.fileio import readFile, writeFile
# import step_calcchains_serial_tobinary_filter_proc_lisa as s2bin
import py.computation.step_remove_boxes_iner_faces as rmbox
import py.computation.step_generatebordermtx as gbmatrix
from py.computation.step_triangularmesh import triangulate_quads
import laplacianSmoothing as ls
import visualize

import py.computation.step_squaremesh as sq


def convert(
    filename,
    bordersize=[2, 2, 2],
    outputdir='tmp/output',
    borderdir='./tmp/border'
):

    bindir = os.path.join(outputdir, 'compbin')
    stldir = os.path.join(outputdir, 'stl')
    binfile = os.path.join(bindir, 'model-2.bin')
    stlfile = os.path.join(stldir, 'model-2.obj')

    if os.path.exists(outputdir):
        shutil.rmtree(outputdir)
    mkdir_p(outputdir)
    mkdir_p(stldir)
    mkdir_p(bindir)
    mkdir_p(borderdir)

    nx, ny, nz = bordersize
    brodo3path = gbmatrix.getOrientedBordo3Path(nx, ny, nz, borderdir)
    logger.debug("in convert()")

# read data per blocks, find boundary, write each block to binary file
    s2bin.calcchains_main(
        nx=nx, ny=ny, nz=nz,
        calculateout=True,
        input_filename=filename,
        # BORDER_FILE='./tmp/border/bordo3_2-2-2.json',
        BORDER_FILE=brodo3path,
        # BORDER_FILE=border_file,
        DIR_O=bindir,
        # colors=,
        coloridx=2
        )
    logger.debug("calcchains_main finished")

    concatenate_files(
        bindir + "/*.bin",
        binfile)
    logger.debug("concatenate() finished")
    # nx, ny, nz = boxsize
    sq.make_obj(
        nx, ny, nz,
        binfile,
        stldir)
    logger.debug("obj file  finished")

    concatenate_files(stldir + '/output-*-*.stl', stlfile)


def makeAll(
    inputfile,
    bordersize,
    outputdir,
    outputfile,
    visualization,
    borderdir,
    make_triangulation=True
):
    print 'before pklz read'
    convert(inputfile, bordersize, outputdir, borderdir=borderdir)
    print 'after pklz read'
    # V, F = readFile(args.inputfile)
    V, F = readFile(os.path.join(outputdir, 'stl/model-2.obj'))
    print "Before"
    print "Number of vertexes: %i    Number of faces %i" % (len(V), len(F))
    # F = rmbox.shiftFaces(F, -1)
    V, F = makeCleaningAndSmoothing(
        V, F,
        os.path.join(outputdir, outputfile))
    print "After"
    print "Number of vertexes: %i    Number of faces %i" % (len(V), len(F))
# write to ints
# fill empty vertexes
    V = [v if len(v) == 3 else [0, 0, 0] for v in V]
# make tenimes bigger
    Vint = (np.asarray(V) * 10).astype(np.int).tolist()
    if outputfile is not None:
        writeFile(
            os.path.join(outputdir, outputfile + "_sm_i.obj"),
            Vint, F,
            ignore_empty_vertex_warning=True)
# make triangulation
    if make_triangulation:
        print 'triang'
        save_triangulated(V, Vint, F, outputdir, outputfile)

    if visualization:
        visualize.visualize(V, F)

    return V, F


def save_triangulated(V, Vint, F, outputdir, outputfile):
    logger.debug("triangulation")
    Ftr = triangulate_quads(F)
    if outputfile is not None:
        outputfile = os.path.join(outputdir, outputfile)
        writeFile(
            outputfile + "_sm_i_tr.obj",
            Vint, Ftr)
        writeFile(
            outputfile + "_sm_tr.obj",
            V, Ftr)
<commit_msg>triangulation in visualization<commit_after>#! /usr/bin/python
# -*- coding: utf-8 -*-

"""
Read pklz with Pyplasm and LAR
"""
import logging
logger = logging.getLogger(__name__)
import argparse
# import sys
# import os
# path_to_script = os.path.dirname(os.path.abspath(__file__))
# sys.path.append(os.path.join(path_to_script, "./py/computation/"))

# import traceback

# $PYBIN ./py/computation/step_calcchains_serial_tobinary_filter_proc_lisa.py\
# -r -b $BORDER_DIR/$BORDER_FILE -x $BORDER_X -y $BORDER_Y -z $BORDER_Z\
# -i $DIRINPUT -c $COLORS -d $CHAINCURR -q $BESTFILE -o $COMPUTATION_DIR_BIN
import os
import errno
import numpy as np
import shutil
# import py
# import py.computation
# from py.computation import step_remove_boxes_iner_faces
import py.computation.step_calcchains_serial_tobinary_filter_proc_lisa as s2bin
from py.computation.fileio import readFile, writeFile
# import step_calcchains_serial_tobinary_filter_proc_lisa as s2bin
import py.computation.step_remove_boxes_iner_faces as rmbox
import py.computation.step_generatebordermtx as gbmatrix
from py.computation.step_triangularmesh import triangulate_quads
import laplacianSmoothing as ls
import visualize

import py.computation.step_squaremesh as sq


def convert(
    filename,
    bordersize=[2, 2, 2],
    outputdir='tmp/output',
    borderdir='./tmp/border'
):

    bindir = os.path.join(outputdir, 'compbin')
    stldir = os.path.join(outputdir, 'stl')
    binfile = os.path.join(bindir, 'model-2.bin')
    stlfile = os.path.join(stldir, 'model-2.obj')

    if os.path.exists(outputdir):
        shutil.rmtree(outputdir)
    mkdir_p(outputdir)
    mkdir_p(stldir)
    mkdir_p(bindir)
    mkdir_p(borderdir)

    nx, ny, nz = bordersize
    brodo3path = gbmatrix.getOrientedBordo3Path(nx, ny, nz, borderdir)
    logger.debug("in convert()")

# read data per blocks, find boundary, write each block to binary file
    s2bin.calcchains_main(
        nx=nx, ny=ny, nz=nz,
        calculateout=True,
        input_filename=filename,
        # BORDER_FILE='./tmp/border/bordo3_2-2-2.json',
        BORDER_FILE=brodo3path,
        # BORDER_FILE=border_file,
        DIR_O=bindir,
        # colors=,
        coloridx=2
        )
    logger.debug("calcchains_main finished")

    concatenate_files(
        bindir + "/*.bin",
        binfile)
    logger.debug("concatenate() finished")
    # nx, ny, nz = boxsize
    sq.make_obj(
        nx, ny, nz,
        binfile,
        stldir)
    logger.debug("obj file  finished")

    concatenate_files(stldir + '/output-*-*.stl', stlfile)


def makeAll(
    inputfile,
    bordersize,
    outputdir,
    outputfile,
    visualization,
    borderdir,
    make_triangulation=True
):
    print 'before pklz read'
    convert(inputfile, bordersize, outputdir, borderdir=borderdir)
    print 'after pklz read'
    # V, F = readFile(args.inputfile)
    V, F = readFile(os.path.join(outputdir, 'stl/model-2.obj'))
    print "Before"
    print "Number of vertexes: %i    Number of faces %i" % (len(V), len(F))
    # F = rmbox.shiftFaces(F, -1)
    V, F = makeCleaningAndSmoothing(
        V, F,
        os.path.join(outputdir, outputfile))
    print "After"
    print "Number of vertexes: %i    Number of faces %i" % (len(V), len(F))
# write to ints
# fill empty vertexes
    V = [v if len(v) == 3 else [0, 0, 0] for v in V]
# make tenimes bigger
    Vint = (np.asarray(V) * 10).astype(np.int).tolist()
    if outputfile is not None:
        writeFile(
            os.path.join(outputdir, outputfile + "_sm_i.obj"),
            Vint, F,
            ignore_empty_vertex_warning=True)
# make triangulation
    if make_triangulation:
        print 'triang'
        save_triangulated(V, Vint, F, outputdir, outputfile)

    if visualization:
        Ftr = triangulate_quads(F)
        visualize.visualize(V, Ftr)

    return V, F


def save_triangulated(V, Vint, F, outputdir, outputfile):
    logger.debug("triangulation")
    Ftr = triangulate_quads(F)
    if outputfile is not None:
        outputfile = os.path.join(outputdir, outputfile)
        writeFile(
            outputfile + "_sm_i_tr.obj",
            Vint, Ftr)
        writeFile(
            outputfile + "_sm_tr.obj",
            V, Ftr)


{'fraction_non_alphanumeric': 0.11297071129707113, 'fraction_numerical': 0.005977286312014346, 'mean_word_length': 3.082967301122499, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3054494', 'n_tokens_mistral': 3038, 'n_tokens_neox': 2960, 'n_words': 668}