Skip to content

Commit 578dce4

Browse files
committed
Provide more contextual information in the IFC SPF file header
1 parent f132299 commit 578dce4

3 files changed

Lines changed: 49 additions & 1 deletion

File tree

src/examples/IfcOpenHouse.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ int main(int argc, char** argv) {
4848
// The IfcHierarchyHelper is a subclass of the regular IfcFile that provides several
4949
// convenience functions for working with geometry in IFC files.
5050
IfcHierarchyHelper file;
51+
file.filename("IfcOpenHouse.ifc");
5152

5253
// Start by adding a wall to the file, initially leaving most attributes blank.
5354
Ifc2x3::IfcWallStandardCase* south_wall = new Ifc2x3::IfcWallStandardCase(

src/ifcparse/IfcParse.cpp

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
#include <string>
2222
#include <stdio.h>
2323
#include <stdlib.h>
24+
#include <ctime>
2425

2526
#include "../ifcparse/IfcCharacterDecoder.h"
2627
#include "../ifcparse/IfcParse.h"
@@ -643,6 +644,7 @@ IfcFile::IfcFile() {
643644
lastId = 0;
644645
tokens = 0;
645646
MaxId = 0;
647+
initTimestamp();
646648
}
647649

648650
//
@@ -849,7 +851,15 @@ std::ostream& operator<< (std::ostream& os, const IfcParse::IfcFile& f) {
849851
os << "ISO-10303-21;" << std::endl;
850852
os << "HEADER;" << std::endl;
851853
os << "FILE_DESCRIPTION(('ViewDefinition []'),'2;1');" << std::endl;
852-
os << "FILE_NAME('','',(''),('',''),'IfcOpenShell','IfcOpenShell','');" << std::endl;
854+
os << "FILE_NAME("
855+
<< static_cast<std::string>(IfcWrite::IfcCharacterEncoder(f.filename())) << ","
856+
<< static_cast<std::string>(IfcWrite::IfcCharacterEncoder(f.timestamp())) << ",("
857+
<< static_cast<std::string>(IfcWrite::IfcCharacterEncoder(f.authorOrganisation())) << "),("
858+
<< static_cast<std::string>(IfcWrite::IfcCharacterEncoder(f.authorName())) << ","
859+
<< static_cast<std::string>(IfcWrite::IfcCharacterEncoder(f.authorEmail()))
860+
<< "),'IfcOpenShell " << IFCOPENSHELL_VERSION
861+
<< "','IfcOpenShell " << IFCOPENSHELL_VERSION
862+
<< "','');" << std::endl;
853863
os << "FILE_SCHEMA(('IFC2X3'));" << std::endl;
854864
os << "ENDSEC;" << std::endl;
855865
os << "DATA;" << std::endl;
@@ -864,3 +874,25 @@ std::ostream& operator<< (std::ostream& os, const IfcParse::IfcFile& f) {
864874

865875
return os;
866876
}
877+
878+
void IfcFile::filename(const std::string& s) { _filename = s; }
879+
std::string IfcFile::filename() const { return _filename; }
880+
void IfcFile::timestamp(const std::string& s) { _timestamp = s; }
881+
std::string IfcFile::timestamp() const { return _timestamp; }
882+
void IfcFile::author(const std::string& name, const std::string& email, const std::string& organisation) {
883+
_author = name;
884+
_author_email = email;
885+
_author_organisation = organisation;
886+
}
887+
std::string IfcFile::authorName() const { return _author; }
888+
std::string IfcFile::authorEmail() const { return _author_email; }
889+
std::string IfcFile::authorOrganisation() const { return _author_organisation; }
890+
void IfcFile::initTimestamp() {
891+
char buf[255];
892+
time_t t;
893+
time(&t);
894+
struct tm * ti = localtime (&t);
895+
if (strftime(buf,255,"%Y-%m-%dT%H:%M:%S",ti)) {
896+
_timestamp = std::string(buf);
897+
}
898+
}

src/ifcparse/IfcParse.h

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -229,6 +229,12 @@ class IfcFile {
229229
MapOffsetById offsets;
230230
unsigned int lastId;
231231
unsigned int MaxId;
232+
std::string _filename;
233+
std::string _timestamp;
234+
std::string _author;
235+
std::string _author_email;
236+
std::string _author_organisation;
237+
void initTimestamp();
232238
public:
233239
typedef MapEntityById::const_iterator const_iterator;
234240
IfcFile();
@@ -273,6 +279,15 @@ class IfcFile {
273279
unsigned int FreshId() { MaxId ++; return MaxId; }
274280
void AddEntity(IfcUtil::IfcSchemaEntity e);
275281
void AddEntities(IfcEntities es);
282+
283+
void filename(const std::string& s);
284+
std::string filename() const;
285+
void timestamp(const std::string& s);
286+
std::string timestamp() const;
287+
void author(const std::string& name, const std::string& email, const std::string& organisation);
288+
std::string authorName() const;
289+
std::string authorEmail() const;
290+
std::string authorOrganisation() const;
276291
};
277292

278293
double UnitPrefixToValue( Ifc2x3::IfcSIPrefix::IfcSIPrefix v );

0 commit comments

Comments
 (0)