Menu

IFC to OBJ problems

Help
guparan
2012-06-11
2012-12-29
  • guparan

    guparan - 2012-06-11

    Hi !

    I am trying to work with your IFC to OBJ converter but I have some problems.

    I converted a simple IFC wall into an OBJ file but when I tried to open it with a Qt Viewer … nothing.
    I tried with 2 other viewers (GLC Player and LynX3DViewerLite) and the result was the same : loading error.

    With Blender, it works fine ! I can import my OBJ and see it.

    I tried to export my OBJ into a new OBJ with Blender and my 3 other viewers loaded it.

    It is not possible to load your OBJ in another viewer than Blender ?

    Tank you for your help !

    The IFC Wall :
    http://ssi.wikidot.com/local-files/2012-blog-posts/120510%20wall%20standard%20case.ifc

     
  • Thomas Krijnen

    Thomas Krijnen - 2012-06-11

    Hi,

    That's unfortunate. The .obj format was chosen because it is one of the simplest formats around, which can be imported by a lot of application. I only verified the IfcObj output to work with both Blender and Autodesk 3ds Max.

    It would be interesting to see what the reason behind the malfunctioning is. There are several options in the .obj format, but there is currently no way to configure IfcObj. One can specify faces using positive or negative vertex indices (IfcObj uses negative). One can specify normals and uv-coords (IfcObj exports only normals). One can group objects by group or by object (IfcObj uses group). One can use normal smoothing (IfcObj does). Do you have an idea whether any of these options could be the problem, maybe you can check with your viewers what options they support. Also it would help to know what are the differences between the .obj file by IfcObj and by Blender?

    Kind regards,
    Thomas

     
  • guparan

    guparan - 2012-06-12

    Relative indices (negatives) seems to be the problem.
    I made some change in your code to fix this in IfcObj.cpp line 96 :

    for ( IfcGeomObjects::IntIt it = o->mesh->faces.begin(); it != o->mesh->faces.end(); ) {
        const int v1 = *(it++)+1; // no more -vcount;
        const int v2 = *(it++)+1; // no more -vcount;
        const int v3 = *(it++)+1; // no more -vcount;
        fObj << "f " << v1 << "//" << v1 << " " << v2 << "//" << v2 << " " << v3 << "//" << v3 << std::endl;
    }
    

    I can now load all obj converted files in my viewers with no error but I still have another problem.

    On very simple examples with just a wall or a cube, everything is fine (conversion OK, loading OK, printing OK).
    On complicated examples with several elements or big structures, the obj file seems to be OK but my viewers don't print what they should (Blender too, it is not a viewer problem) : I have just one wall (with acad2010_walls.ifc), one bar (with geometrygym_great_court_roof.ifc), or a big mess (with acad2010_objects.ifc).

    Any idea ?
    Thank you for your support.

     
  • Thomas Krijnen

    Thomas Krijnen - 2012-06-12

    Hi,

    Positive vertex indices are on file-wide basis, so you should keep track of how many vertices already exist in the file. I am currently not able to test this, but something like this should do the trick:

        const int vcount_start = 1;
        do {
    ...
            for ( IfcGeomObjects::IntIt it = o->mesh->faces.begin(); it != o->mesh->faces.end(); ) {
                const int v1 = *(it++)+vcount_start;
                const int v2 = *(it++)+vcount_start;
                const int v3 = *(it++)+vcount_start;
                fObj << "f " << v1 << "//" << v1 << " " << v2 << "//" << v2 << " " << v3 << "//" << v3 << std::endl;
            }
            vcount_start += vcount;
    

    Kind regards,
    Thomas

     
  • Thomas Krijnen

    Thomas Krijnen - 2012-06-12

    Hi,

    Whoops, obviously vcount_start should be of type int, not const int

    Kind regards,
    Thomas

     
  • guparan

    guparan - 2012-06-12

    Ok everything is fine now, thank you :)

     

Log in to post a comment.