Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

errors of convert obj to off #36

Open
zouwenqin opened this issue Apr 14, 2021 · 2 comments
Open

errors of convert obj to off #36

zouwenqin opened this issue Apr 14, 2021 · 2 comments

Comments

@zouwenqin
Copy link

Dear Julian
image
image

i noticed the command line above and tried to uncomment the annotation but still error, my enviroment is ubuntu18, and i found that i can't find xvfb-run package. help!!!

@elhamravanbakhsh
Copy link

I faced the same issue. Help please!

@zouwenqin
Copy link
Author

I faced the same issue. Help please!

maybe you can convert the obj to off manually by above code

`def obj2off(objpath, offpath):
    '''
    将obj文件转换为off文件
    :param objpath: .obj文件的路径
    :param offpath: .off文件的路径的保存地址
    :return: 无
    '''
    line = ""

    vset = []
    fset = []
    with open(objpath,'r') as f:
        lines = f.readlines()
    p = re.compile(r'/+')
    space = re.compile(r' +')

    for line in lines:
        #拿到obj文件中一行,作为一个字符串
        tailMark = " "
        line = line+tailMark
        if line[0]!='v' and line[0]!='f' :
            continue

        parameters = space.split(line.strip())
        if parameters[0] == "v":   #如果是顶点的话
                Point = []
                Point.append(eval( parameters[1]) )
                Point.append(eval( parameters[2]) )
                Point.append(eval( parameters[3]) )
                vset.append(Point)

        elif parameters[0] == "f":   #如果是面的话,存放顶点的索引
                vIndexSets = []          #临时存放点的集合
                for i in range(1,len(parameters) ):
                    x = parameters[i]
                    ans = p.split(x)[0]
                    index = eval(ans)
                    index -= 1          #因为顶点索引在obj文件中是从1开始的,而我们存放的顶点是从0开始的,因此要减1
                    vIndexSets.append(index)

                fset.append(vIndexSets)

    with open(offpath, 'w') as out:
        out = open(offpath, 'w')
        out.write("OFF\n")
        out.write(str(vset.__len__()) + " " + str(fset.__len__()) + " 0\n")
        for j in range(len(vset)):
            out.write(str(vset[j][0]) + " " + str(vset[j][1]) + " " + str(vset[j][2]) + "\n")

        for i in range(len(fset)):
            s = str(len( fset[i] ))
            for j in range( len( fset[i] ) ):
                s = s+ " "+ str(fset[i][j])
            s += "\n"
            out.write(s)
   

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants