Menu

Using IfcGeom of IFCOpenShell 0.7

2022-12-02
2022-12-05
  • Mathias Worm

    Mathias Worm - 2022-12-02

    Hello all,

    I have successfully compiled the IfcOpenShell 0.7 on my Ubuntu 20.04. I was able to parse my IFC2x3 file and now I would like to use ifcgeom to extract global coordinate. But when I include the ifcgeom.h file I always get the following Error:

    /usr/local/include/ifcgeom/../ifcgeom_schema_agnostic/Kernel.h:23:1: error: #include expects "FILENAME" or <FILENAME>
       23 | #include INCLUDE_SCHEMA(0)
          | ^~~~~~~~~~~~~~~~~~~~~~~~~~                                             
    /usr/local/include/ifcgeom/../ifcgeom_schema_agnostic/Kernel.h:24:1: error: macro "BOOST_PP_SEQ_ELEM_III" requires 2 arguments, but only 1 given
       24 | #include INCLUDE_SCHEMA(1)
          | ^~~~~~~~~~~~~~~~~~~~~~~~~~      
    In file included from /usr/include/boost/preprocessor/seq/seq.hpp:16,
                     from /usr/include/boost/preprocessor/seq/for_each_i.hpp:21,
                     from /usr/include/boost/concept/detail/concept_def.hpp:6,
                     from /usr/include/boost/concept_check.hpp:32,
                     from /usr/include/boost/range/concepts.hpp:19,
                     from /usr/include/boost/range/size_type.hpp:20,
                     from /usr/include/boost/range/size.hpp:21,
                     from /usr/include/boost/range/functions.hpp:20,
                     from /usr/include/boost/range/iterator_range_core.hpp:38,
                     from /usr/include/boost/range/iterator_range.hpp:13,
                     from /usr/include/boost/range/as_literal.hpp:22,
                     from /usr/include/boost/algorithm/string/trim.hpp:19,
                     from /usr/include/boost/algorithm/string.hpp:19,
                     from /usr/local/include/ifcparse/../ifcparse/../ifcparse/../ifcparse/../ifcparse/../ifcparse/IfcSchema.h:29,
                     from /usr/local/include/ifcparse/../ifcparse/../ifcparse/../ifcparse/../ifcparse/ArgumentType.h:20,
                     from /usr/local/include/ifcparse/../ifcparse/../ifcparse/../ifcparse/IfcEntityInstanceData.h:23,
                     from /usr/local/include/ifcparse/../ifcparse/../ifcparse/IfcBaseClass.h:25,
                     from /usr/local/include/ifcparse/../ifcparse/IfcParse.h:52,
                     from /usr/local/include/ifcparse/IfcFile.h:35,
                     from /home/mathias/VSCode/Projects/IfcOpenShell_tests/main.cpp:6:
    

    That error occurs for all schemas in used in "/ifcgeom_schema_agnostic/Kernel.h". Can anyone help me?
    What do I do wrong?

    My program reads a ifc file and gets information about IfcWindow, it looks like this:


    #define IfcSchema Ifc2x3
    
    #include <string>
    #include <iostream>
    #include "IfcFile.h"
    #include "Ifc2x3.h"
    #include "IfcGeom.h"
    
    /*
    #include <gp_Pnt.hxx> Diese Datei wird nicht gefunden, da OpenCascade an einem anderen Ort liegt ....
    */
    
    int main(int argc, char** argv) {
    
        if ( argc != 2 ) {
            std::cout << "usage: IfcParseExamples <filename.ifc>" << std::endl;
            return 1;
        }
    
        std::cout << "Das hier ist ein IfcParse-Test mit der IfcOpenShell" << std::endl;
        std::string path = argv[1]; // oder "/home/mathias/VSCode/Projects/IfcOpenShell_tests/IfcParse/" 
        IfcParse::IfcFile file(argv[1]);
    
        if (!file.good()) {
            std::cout << "Unable to parse .ifc file" << std::endl;
            //return 1;
        }
    
        IfcSchema::IfcBuildingElement::list::ptr elements = file.instances_by_type<IfcSchema::IfcBuildingElement>();
    
        std::cout << "Found " << elements->size() << " elements in " << path << ":" << std::endl;
    
        for (IfcSchema::IfcBuildingElement::list::it it = elements->begin(); it != elements->end(); ++it) {
    
            const IfcSchema::IfcBuildingElement* element = *it;
            std::cout << element->data().toString() << std::endl;
    
            const IfcSchema::IfcWindow* window;
            if ((window = element->as<IfcSchema::IfcWindow>()) != 0) {
                if (window->OverallWidth() && window->OverallHeight()) {
                    const double area = *window->OverallWidth() * *window->OverallHeight();
                    std::cout << "The area of this window is " << area << std::endl;
                }
            }
    
        }
    
        //IfcGeom::IteratorSettings settings;
        //settings.set(IfcGeom::IteratorSettings::USE_WORLD_COORDS, true);
    
        return 0;
    } 
    

    I compile my program with cmake. The CmakeList looks like this:

    cmake_minimum_required(VERSION 3.0.0)
    project(ReadIfcFile VERSION 0.1.0)
    
    add_executable(ReadIfcFile main.cpp)
    target_link_libraries(ReadIfcFile -L/usr/local/lib/)
    
    target_include_directories(ReadIfcFile PUBLIC /usr/local/include/ifcgeom_schema_agnostic)
    target_include_directories(ReadIfcFile PUBLIC /usr/local/include/ifcparse)
    target_include_directories(ReadIfcFile PUBLIC /usr/local/include/ifcgeom/)
    target_include_directories(ReadIfcFile PUBLIC /usr/include/opencascade)
    
    target_link_libraries(ReadIfcFile
        libIfcParse.a
        libSerializers_ifc2x3.a
        libIfcGeom_ifc2x3.a
        libIfcGeom.a
    )
    
    set(CPACK_PROJECT_NAME ${PROJECT_NAME})
    set(CPACK_PROJECT_VERSION ${PROJECT_VERSION})
    

    I really hope anyone can help.

    Best regards,
    Mathias

     
  • Thomas Krijnen

    Thomas Krijnen - 2022-12-04

    With all the machinery to supply multiple schema versions at runtime, it hasn't become easier to build 3rd party C++ apps using IfcOpenShell. If you have ideas on on streamlining/documenting this process we'd be happy to hear your feedback. You're missing the defines set here: https://github.com/IfcOpenShell/IfcOpenShell/blob/v0.7.0/cmake/CMakeLists.txt#L648-L662

     
  • Mathias Worm

    Mathias Worm - 2022-12-05

    Hello Thomas,

    thank you very much for your answer. Adding the marked lines helped to solve the problems partially. But still I receive the following error:

    /usr/bin/ld: CMakeFiles/ReadIfcFile.dir/main.cpp.o: in function GeomAdaptor_Surface::operator delete(void*)': /usr/include/opencascade/GeomAdaptor_Surface.hxx:65: undefined reference toStandard::Free(void)'
    /usr/bin/ld: CMakeFiles/ReadIfcFile.dir/main.cpp.o: in function BRepAdaptor_Surface::operator delete(void*)': /usr/include/opencascade/BRepAdaptor_Surface.hxx:71: undefined reference toStandard::Free(void
    )'
    /usr/bin/ld: CMakeFiles/ReadIfcFile.dir/main.cpp.o: in function BRepAdaptor_Surface::UContinuity() const': /usr/include/opencascade/BRepAdaptor_Surface.lxx:64: undefined reference toGeomAdaptor_Surface::UContinuity() const'
    /usr/bin/ld: CMakeFiles/ReadIfcFile.dir/main.cpp.o: in function BRepAdaptor_Surface::VContinuity() const': /usr/include/opencascade/BRepAdaptor_Surface.lxx:74: undefined reference toGeomAdaptor_Surface::VContinuity() const'
    /usr/bin/ld: CMakeFiles/ReadIfcFile.dir/main.cpp.o: in function BRepAdaptor_Surface::NbUIntervals(GeomAbs_Shape) const': /usr/include/opencascade/BRepAdaptor_Surface.lxx:85: undefined reference toGeomAdaptor_Surface::NbUIntervals(GeomAbs_Shape) const'
    /usr/bin/ld: CMakeFiles/ReadIfcFile.dir/main.cpp.o: in function BRepAdaptor_Surface::NbVIntervals(GeomAbs_Shape) const': /usr/include/opencascade/BRepAdaptor_Surface.lxx:96: undefined reference toGeomAdaptor_Surface::NbVIntervals(GeomAbs_Shape) const'
    ....


    That means OpenCascade is not linked correctly, right?

    And what I think would be great to have to streamline the whole development process: It would be great if IfcOpenShell would provide basic documentation about dependencies on other software versions. Based on that, a sample project for developing an own applications would also be helpful.
    Probably a FindIfcOpenShell.cmake would help most devs to easily use IfcOpenShell.

    Best regards,
    Mathias

     

    Last edit: Mathias Worm 2022-12-05

Log in to post a comment.