tudelft3d / ifc2citygml

Automatic conversion of IFC models 2x3 to CityGML LOD 1/2/3/4
GNU General Public License v3.0
73 stars 20 forks source link

Converting .obj file to .citygml #4

Open Pravesh-Jamgade opened 6 years ago

Pravesh-Jamgade commented 6 years ago

I have installed all the dependencies on ubuntu and successfully converted the .ifc file to .obj . I need help for converting .obj to .citygml .Thank you!

grivy commented 6 years ago

The code is split in 2 parts: ifc2off and off2citygml

The latter converts the OFF and OFFX files generated from the first step to a valid LOD3 CityGML file. Dependencies: CGAL

In ifc2off remove all references to CityGMLgrivySerializer. Use the .tmp output format to get off and offx. Then run the files through the second stage.

At no point are .obj files mentioned in this project.

Pravesh-Jamgade commented 6 years ago

I have installed all the dependencies necessary to run the project. can you provide step by step procedure to run your project and get citygml output. I had gone through the previous issues but that's not helping.Thank you!

grivy commented 6 years ago

You're not giving me any information to work with.

What happens if you run ifc2off to get .tmp output?

Pravesh-Jamgade commented 6 years ago

.obj file was resulted from IfcOpenshell,i mistaken it to off file 1.ifc2off i have build all the required dependencies. i have moved the files ( CityGMLSemantics.cpp, CityGMLSemantics.h, grivySerializer.cpp, grivySerializer.h ) from ifc3citygml/ifc2off to IfcOpenshell/src/grivy . Replace the ifcconvert/IfcConvert.cpp file with project ifc2citygml/ifc2off/IfcConvert.cpp file.And removed the CityGMLgrivySerializer.h reference. Then i build the IfcOpenshell/src/ifcconvert folder containing .cpp and .h files. this giving the few errors as shown in figure.

screenshot from 2018-06-27 17-21-26

grivy commented 6 years ago

Are you using IfcOpenShell_CGAL instead of the original? See: https://github.com/tudelft3d/ifc2citygml/issues/3

Pravesh-Jamgade commented 6 years ago

No, im using IfcOpenShell only.

grivy commented 6 years ago

The 0.4.0 branch has the SurfaceStyle.h header. https://github.com/IfcOpenShell/IfcOpenShell/tree/v0.4.0?files=1 Could you try that one?

Pravesh-Jamgade commented 6 years ago

yes I'm trying. from the image i sent above, did i do it correctly? i mean the files required for compiling.

grivy commented 6 years ago

The image shows you are missing the file ifcconvert/SurfaceStyle.h. The 0.4.0 branch contains this files. So you are either using an older (0.3.0.) or an newer (0.6.0) branch, because otherwise it would be able to find that file.

Pravesh-Jamgade commented 6 years ago

hello , it took me really long time to build the dependencies. All are set to implement the conversion. As you have instructed in the comment I followed the same procedure. But i have few errors with IfcConvert.cpp . Here the screenshot: screenshot 24

grivy commented 6 years ago

You missed step 3: Remove references to CityGMLgrivySerializer.h, Its not needed

I think you did not remove the #include "CityGMLgrivySerializer.h" at the top of the file.

The other error might be related to not remiving everything as well. But I would at least have to see the corresponding lines of code and relevant variable declarations.

Pravesh-Jamgade commented 6 years ago

hello, All of the steps I have followed and commented the CityGMLgrivySerializer.h I have the screenshot where I'm having trouble.

screenshot 25

grivy commented 6 years ago

Could you add the following two lines to the GeometrySerializer class and try again: std::string semantics; void setCurrentSemantics(std::string sem) {semantics = sem;}

Pravesh-Jamgade commented 6 years ago

hey it did work. But still few errors are remain here.i tried to remove those error myself and I got pretty messed up. Ifcopenshell itself was showing errors again. if your having the working code can you post here?

Pravesh-Jamgade commented 6 years ago

I have commented the //#include "../ifcconvert/CityGMLgrivySerializer.h"

screenshot 41 and also the object initialization of CityGMLgrivySerializer

Pravesh-Jamgade commented 6 years ago

Build error screenshot 42 screenshot 43 IntelliSense error screenshot 44

Pravesh-Jamgade commented 6 years ago

Hey , please first look at the following message:

IfcConvert.obj : error LNK2001: unresolved external symbol "public: virtual bool __cdecl grivySerializer::ready(void)" (?ready@grivySerializer@@UEAA_NXZ)

5>

IfcConvert.obj : error LNK2001: unresolved external symbol "public: virtual void __cdecl grivySerializer::writeHeader(void)" (?writeHeader@grivySerializer@@UEAAXXZ)

5>IfcConvert.obj : error LNK2001: unresolved external symbol "public: virtual void __cdecl grivySerializer::writeTesselated(class IfcGeomObjects::IfcGeomObject const *)" (?writeTesselated@grivySerializer@@UEAAXPEBVIfcGeomObject@IfcGeomObjects@@@Z)

5>IfcConvert.obj : error LNK2001: unresolved external symbol "public: virtual void __cdecl grivySerializer::writeShapeModel(class IfcGeomObjects::IfcGeomShapeModelObject const *)" (?writeShapeModel@grivySerializer@@UEAAXPEBVIfcGeomShapeModelObject@IfcGeomObjects@@@Z)

5>IfcConvert.obj : error LNK2001: unresolved external symbol "public: virtual void __cdecl grivySerializer::setUnitNameAndMagnitude(class std::basic_string<char,struct std::char_traits,class std::allocator > const &,float)" (?setUnitNameAndMagnitude@grivySerializer@@UEAAXAEBV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@M@Z)

5>IfcConvert.obj : error LNK2019: unresolved external symbol "class std::basic_string<char,struct std::char_traits,class std::allocator > __cdecl get_semantic(class Ifc2x3::IfcObjectDefinition * const,class std::map<int,class std::map<class std::basic_string<char,struct std::char_traits,class std::allocator >,class std::basic_string<char,struct std::char_traits,class std::allocator >,struct std::less<class std::basic_string<char,struct std::char_traits,class std::allocator > >,class std::allocator<struct std::pair<class std::basic_string<char,struct std::char_traits,class std::allocator > const ,class std::basic_string<char,struct std::char_traits,class std::allocator > > > >,struct std::less,class std::allocator<struct std::pair<int const ,class std::map<class std::basic_string<char,struct std::char_traits,class std::allocator >,class std::basic_string<char,struct std::char_traits,class std::allocator >,struct std::less<class std::basic_string<char,struct std::char_traits,class std::allocator > >,class std::allocator<struct std::pair<class std::basic_string<char,struct std::char_traits,class std::allocator > const ,class std::basic_string<char,struct std::char_traits,class std::allocator > > > > > > >,class std::map<int,class std::map<class std::basic_string<char,struct std::char_traits,class std::allocator >,class std::basic_string<char,struct std::char_traits,class std::allocator >,struct std::less<class std::basic_string<char,struct std::char_traits,class std::allocator > >,class std::allocator<struct std::pair<class std::basic_string<char,struct std::char_traits,class std::allocator > const ,class std::basic_string<char,struct std::char_traits,class std::allocator > > > >,struct std::less,class std::allocator<struct std::pair<int const ,class std::map<class std::basic_string<char,struct std::char_traits,class std::allocator >,class std::basic_string<char,struct std::char_traits,class std::allocator >,struct std::less<class std::basic_string<char,struct std::char_traits,class std::allocator > >,class std::allocator<struct std::pair<class std::basic_string<char,struct std::char_traits,class std::allocator > const ,class std::basic_string<char,struct std::char_traits,class std::allocator > > > > > > >,class std::map<int,class std::map<class std::basic_string<char,struct std::char_traits,class std::allocator >,class std::basic_string<char,struct std::char_traits,class std::allocator >,struct std::less<class std::basic_string<char,struct std::char_traits,class std::allocator > >,class std::allocator<struct std::pair<class std::basic_string<char,struct std::char_traits,class std::allocator > const ,class std::basic_string<char,struct std::char_traits,class std::allocator > > > >,struct std::less,class std::allocator<struct std::pair<int const ,class std::map<class std::basic_string<char,struct std::char_traits,class std::allocator >,class std::basic_string<char,struct std::char_traits,class std::allocator >,struct std::less<class std::basic_string<char,struct std::char_traits,class std::allocator > >,class std::allocator<struct std::pair<class std::basic_string<char,struct std::char_traits,class std::allocator > const ,class std::basic_string<char,struct std::char_traits,class std::allocator > > > > > > >)" (?get_semantic@@YA?AV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QEAVIfcObjectDefinition@Ifc2x3@@V?$map@HV?$map@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@V12@U?$less@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@2@V?$allocator@U?$pair@$$CBV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@V12@@std@@@2@@std@@U?$less@H@2@V?$allocator@U?$pair@$$CBHV?$map@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@V12@U?$less@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@2@V?$allocator@U?$pair@$$CBV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@V12@@std@@@2@@std@@@std@@@2@@2@11@Z) referenced in function main

5>IfcConvert.obj : error LNK2019: unresolved external symbol "class std::vector<class std::map<int,class std::map<class std::basic_string<char,struct std::char_traits,class std::allocator >,class std::basic_string<char,struct std::char_traits,class std::allocator >,struct std::less<class std::basic_string<char,struct std::char_traits,class std::allocator > >,class std::allocator<struct std::pair<class std::basic_string<char,struct std::char_traits,class std::allocator > const ,class std::basic_string<char,struct std::char_traits,class std::allocator > > > >,struct std::less,class std::allocator<struct std::pair<int const ,class std::map<class std::basic_string<char,struct std::char_traits,class std::allocator >,class std::basic_string<char,struct std::char_traits,class std::allocator >,struct std::less<class std::basic_string<char,struct std::char_traits,class std::allocator > >,class std::allocator<struct std::pair<class std::basic_string<char,struct std::char_traits,class std::allocator > const ,class std::basic_string<char,struct std::char_traits,class std::allocator > > > > > > >,class std::allocator<class std::map<int,class std::map<class std::basic_string<char,struct std::char_traits,class std::allocator >,class std::basic_string<char,struct std::char_traits,class std::allocator >,struct std::less<class std::basic_string<char,struct std::char_traits,class std::allocator > >,class std::allocator<struct std::pair<class std::basic_string<char,struct std::char_traits,class std::allocator > const ,class std::basic_string<char,struct std::char_traits,class std::allocator > > > >,struct std::less,class std::allocator<struct std::pair<int const ,class std::map<class std::basic_string<char,struct std::char_traits,class std::allocator >,class std::basic_string<char,struct std::char_traits,class std::allocator >,struct std::less<class std::basic_string<char,struct std::char_traits,class std::allocator > >,class std::allocator<struct std::pair<class std::basic_string<char,struct std::char_traits,class std::allocator > const ,class std::basic_string<char,struct std::char_traits,class std::allocator > > > > > > > > > __cdecl read_semanticSettings(void)" (?read_semanticSettings@@YA?AV?$vector@V?$map@HV?$map@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@V12@U?$less@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@2@V?$allocator@U?$pair@$$CBV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@V12@@std@@@2@@std@@U?$less@H@2@V?$allocator@U?$pair@$$CBHV?$map@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@V12@U?$less@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@2@V?$allocator@U?$pair@$$CBV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@V12@@std@@@2@@std@@@std@@@2@@std@@V?$allocator@V?$map@HV?$map@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@V12@U?$less@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@2@V?$allocator@U?$pair@$$CBV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@V12@@std@@@2@@std@@U?$less@H@2@V?$allocator@U?$pair@$$CBHV?$map@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@V12@U?$less@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@2@V?$allocator@U?$pair@$$CBV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@V12@@std@@@2@@std@@@std@@@2@@std@@@2@@std@@XZ) referenced in function main 5>D:\New\src\Debug\IfcConvert.exe : fatal error LNK1120: 7 unresolved externals

grivy commented 6 years ago

Hmm I believe the setUnitNameAndMagnitude function was added to ifcopenshell in a later revision.. I do not have the code running on my machine, but I can gather more source files which might be useful to you. Ill have to do that later. Remind me if I do not post anything within 12h.

Pravesh-Jamgade commented 6 years ago

Hey, If you see in the error it says "Unresolved external errors" for all of the methods in grivySerializer.h file even though the header file is included in the IfcConvert.cpp file.

An unresolved symbol is one that you've declared somewhere but never defined. Usually, it means you've #included some third party library's header file but not told the linker where to find the corresponding .obj files for the library---from definition

is it the case with files inside "grivy" folder created inside the "ifcopenshell/src" ? and linker don't know where to find the .obj files created for "grivy" folder files.

Pravesh-Jamgade commented 6 years ago

hey, you got something?? According to the error message, it seems to be the linker problem as it is not able to find symbols. I think grivy folder containing cpp and header files didn't get compiled and that's why the linker may not be able to identify the symbols created with IfcConvert.obj .So should I try to compile grivy folder separately?

grivy commented 6 years ago

src.zip Here is everything except the bimserver dlls which I removed. It apparently is based on a late 0.3.0 version I guess a version that is not on github.. In the grivy folder there also is a grivyproject, I think you can just ignore that one.

Pravesh-Jamgade commented 6 years ago

I used your files...not working still same errors.Now I'm replacing my src by urs.Hope it may work. Also, do I need to compile grivy folder separately before I can use it in the project? https://github.com/tudelft3d/ifc2citygml/issues/4#issuecomment-407652077

Pravesh-Jamgade commented 6 years ago

with additions of your grivy folder files: screenshot 45

*I don't have added Collada support.

grivy commented 6 years ago

I think you know have the same information I have. The source I provided is exactly what I used in the past so building the solution in there should work (after perhaps fixing opencascade dependencies)

Pravesh-Jamgade commented 6 years ago

ifcopenshell --version? OpenCascade is working correctly.

Pravesh-Jamgade commented 6 years ago

Tell me when I did created folder grivy inside which I have added .h and .cpp files. The grivy folder should be get compiled or I have to do it by myself.

Pravesh-Jamgade commented 6 years ago

I build it successfully! Still I'm confused how to used it as I did made few changes that might be wrong. I did removed CityGMLgrivySerializer.h which caused me to remove:(As u instructed in here ) screenshot 47 And now when I run exe file I see these: screenshot 46 Here the option citygml would not work as I did remove the references to CityGMLgrivySerializer.h

Need little help! Again.Thanks! Tell me the procedure to convert ifc to off.

I did give the try: without options as I didnt find the off format option: **input : sample.ifc screenshot 51

output : sample.obj screenshot 48 sample.mtl screenshot 49 **

Pravesh-Jamgade commented 6 years ago

hey I got it. I successfully created OFF and OFFx file. Actually, I was using wrong ifc file. Ifc file was not for building. Now, please guide me with the conversion of OFF to citygml ?

grivy commented 6 years ago

Great to here! This part should be easier. So off to CityGML is based on CGAL. The library was already much more stable at the time I used it so I expect it to work with newer version, but I used v 4.1.

Steps: Make CGAL (I can't remember how, I just followed the instructions) and create a project add the files and link to CGAL. KeepSemantics contains the main(). After having build the exe there are several input paramaeters to run the exe (closing distance, LoDs etc), you'd have to read the main I think to learn what to input..

Here is a known working input fileset: ifcopenhouse.zip

Here is the msvc proj file: nef_3_construction.zip Perhaps it contains more files as I evaluated many different techniques for solving the problem. But you only need the ones on github.

grivy commented 6 years ago

Another example file with input, intermediate and output files.

Bien-Zenker_Jasmin-Sun-AC14-V2.zip

Pravesh-Jamgade commented 6 years ago

hello, I'm facing the problems with cgal installation, specially with qt5. can u tell me why we qt5? Only qt creator installation will be sufficient or I need to install complete qt package?

Pravesh-Jamgade commented 6 years ago

i build the cgal. I'm little bit confused! After compiling the off2citygml project, where should I link it in cgal project. Like last tym in case of ifc2off, we link ifc2off to IfcConvert project of Ifcopenshell.

Pravesh-Jamgade commented 6 years ago

Hey, can you provide the working code from your system. It seems that few files are missing from off2citygml. like, PrimitiveShape.cpp ,ExteriorGenerator.cpp ,GrowPolyhe.h and My_nef_polhedron.h , My_SNC_index_item.h file. Please tell me where in the CGAL I should link. Or do I have to link it to the KeepSemantics.cpp in off2citygml.

Pravesh-Jamgade commented 6 years ago

hello, I have been facing little problems with second part of installation.Please guide me!

grivy commented 6 years ago

For missing files please read my previous post with instructions properly. As for linking I think most or all cgal headers are in stdafx.h. There are also some boost headers like in FileIO.h

Create new solution, create new project, add files, include external/library headers. I don't know whether cgal is statically or dynamically linked.

Pravesh-Jamgade commented 6 years ago

It worked.it did read the input file and give the msg "Done Reading". Took 45 min. At the end program terminated with "unhandelled exception" msg indicating towards cgal file.

grivy commented 6 years ago

How was the memory usage? I remember there was a memory leak in the nef part of cgal that was just patched at the time probably released in the version after the one I used. Which Cgal version are you using? And try ifcopenhouse as input since it is small. The processing time seems normal. My thesis rapport should have the processing times for several input files.

Pravesh-Jamgade commented 6 years ago

hey, here the screenshot of the error:

assert insert_nt h_144

Pravesh-Jamgade commented 6 years ago

I'm using qt5 5.11.1, cgal - 4.13.

grivy commented 6 years ago

I am not familiar with this exception. I'd recommend debugging it as usual using breakpoints and Google. Are you using one of the datasets that is known to work?

Pravesh-Jamgade commented 6 years ago

yess. im using your given input files

Pravesh-Jamgade commented 6 years ago

I have created the project and linked all the necessary libraries.

Pravesh-Jamgade commented 6 years ago

hey, can you give me your input sequence. May be im not giving the correct input commands.

Pravesh-Jamgade commented 6 years ago

Hey, I tried debugging and found location where the message I get " CGAL::Uncertain_conversion_exception at memory location " see in the screenshot: overall

At line 166, normally program runs and reads the OFF file. But in the output window,it shows the above message. Still program continues. The error remain unhandelled. I think that may cause the application stop later in the execution process . exception later in the process execution:

finally

I use try-catch around the suspected code:

caught

These gives me: microsoft c++ exception:int cdecl main(int,char * ptr64 * __ptr64 const)`

err0r

NEED HELP !

grivy commented 6 years ago

I managed to put "CGAL::Uncertain_conversion_exception" into the google machine which told me it is an warning we can ignore. You've added a throw exception statement and now the code throws an exception? Hmm. Use catch(...) to catch everything and don't throw yourself, but the problem does not appear to be here. Try getting the call stack from the point where the actual exception is thrown.

For input sequence I would start without closing so '0' and only LoD3, not sure whether there were other options..

Pravesh-Jamgade commented 6 years ago

you mean I can simple ignore and "CGAL::Uncertain_conversion_exception" and its not the main cause of crashing application.

grivy commented 6 years ago

Correct: https://www.cgal.org/FAQ.html#uncertain_exception

Pravesh-Jamgade commented 6 years ago

ok. I got it. But do you have the any idea why it keeps crashing? I tried gatting call stack for actual exception. I found it was comming from file

FileIO.h

and method is

CGAL::OFF_to_nef_3(offSStream, nefPolyhe);

Again I continued as you instructed to set offset = 0, then it did aborted with

CGAL_precondition

message inside of the KeepSemantics.cpp at the execution of

CGAL::Timer T.stop()

method.

Pravesh-Jamgade commented 6 years ago

hey, I followed your instructions for input sequences and generated the lod1 and lod2 for ifcopenhouse.ifc file. Although I didn't understand , why we set offset = 0,otherwise it wont work. The other files https://github.com/tudelft3d/ifc2citygml/issues/4#issuecomment-408675685 you sent me in past is failed to give gml files. Also, LOD3 and LO4 is not generating on ifcopenhouse.ifc In case of Ifcopenhouse.ifc, After concluding the total elapsed time, it starts again reading for off file and failed in middle with the same assertion error that we encountered in the past.

Thanks for the help till now, i really appreciate your help.

grivy commented 6 years ago

It is not possible to generate lod 1 and 2 without lod 3. The output file just doesn't contain lod3 in the filename. The LoD4 rooms are also in the same file as the LoD3 exterior. I think you just didn't see the file.

We use 0mm on ifcopenhouse because this input is topology correct, thus does not contain holes/gaps in the geometry. The closing distance is the size of the holes that will be fixed.