diff --git a/src/examples/IfcOpenHouse.cpp b/src/examples/IfcOpenHouse.cpp index 97883b10bb..7dbc711b9f 100644 --- a/src/examples/IfcOpenHouse.cpp +++ b/src/examples/IfcOpenHouse.cpp @@ -48,6 +48,7 @@ int main(int argc, char** argv) { // The IfcHierarchyHelper is a subclass of the regular IfcFile that provides several // convenience functions for working with geometry in IFC files. IfcHierarchyHelper file; + file.filename("IfcOpenHouse.ifc"); // Start by adding a wall to the file, initially leaving most attributes blank. Ifc2x3::IfcWallStandardCase* south_wall = new Ifc2x3::IfcWallStandardCase( diff --git a/src/ifcparse/IfcParse.cpp b/src/ifcparse/IfcParse.cpp index 6e88453ce0..24abaac998 100644 --- a/src/ifcparse/IfcParse.cpp +++ b/src/ifcparse/IfcParse.cpp @@ -21,6 +21,7 @@ #include #include #include +#include #include "../ifcparse/IfcCharacterDecoder.h" #include "../ifcparse/IfcParse.h" @@ -643,6 +644,7 @@ IfcFile::IfcFile() { lastId = 0; tokens = 0; MaxId = 0; + initTimestamp(); } // @@ -849,7 +851,15 @@ std::ostream& operator<< (std::ostream& os, const IfcParse::IfcFile& f) { os << "ISO-10303-21;" << std::endl; os << "HEADER;" << std::endl; os << "FILE_DESCRIPTION(('ViewDefinition []'),'2;1');" << std::endl; - os << "FILE_NAME('','',(''),('',''),'IfcOpenShell','IfcOpenShell','');" << std::endl; + os << "FILE_NAME(" + << static_cast(IfcWrite::IfcCharacterEncoder(f.filename())) << "," + << static_cast(IfcWrite::IfcCharacterEncoder(f.timestamp())) << ",(" + << static_cast(IfcWrite::IfcCharacterEncoder(f.authorOrganisation())) << "),(" + << static_cast(IfcWrite::IfcCharacterEncoder(f.authorName())) << "," + << static_cast(IfcWrite::IfcCharacterEncoder(f.authorEmail())) + << "),'IfcOpenShell " << IFCOPENSHELL_VERSION + << "','IfcOpenShell " << IFCOPENSHELL_VERSION + << "','');" << std::endl; os << "FILE_SCHEMA(('IFC2X3'));" << std::endl; os << "ENDSEC;" << std::endl; os << "DATA;" << std::endl; @@ -864,3 +874,25 @@ std::ostream& operator<< (std::ostream& os, const IfcParse::IfcFile& f) { return os; } + +void IfcFile::filename(const std::string& s) { _filename = s; } +std::string IfcFile::filename() const { return _filename; } +void IfcFile::timestamp(const std::string& s) { _timestamp = s; } +std::string IfcFile::timestamp() const { return _timestamp; } +void IfcFile::author(const std::string& name, const std::string& email, const std::string& organisation) { + _author = name; + _author_email = email; + _author_organisation = organisation; +} +std::string IfcFile::authorName() const { return _author; } +std::string IfcFile::authorEmail() const { return _author_email; } +std::string IfcFile::authorOrganisation() const { return _author_organisation; } +void IfcFile::initTimestamp() { + char buf[255]; + time_t t; + time(&t); + struct tm * ti = localtime (&t); + if (strftime(buf,255,"%Y-%m-%dT%H:%M:%S",ti)) { + _timestamp = std::string(buf); + } +} \ No newline at end of file diff --git a/src/ifcparse/IfcParse.h b/src/ifcparse/IfcParse.h index 1ea57d9095..e1796c0d6e 100644 --- a/src/ifcparse/IfcParse.h +++ b/src/ifcparse/IfcParse.h @@ -229,6 +229,12 @@ private: MapOffsetById offsets; unsigned int lastId; unsigned int MaxId; + std::string _filename; + std::string _timestamp; + std::string _author; + std::string _author_email; + std::string _author_organisation; + void initTimestamp(); public: typedef MapEntityById::const_iterator const_iterator; IfcFile(); @@ -273,6 +279,15 @@ public: unsigned int FreshId() { MaxId ++; return MaxId; } void AddEntity(IfcUtil::IfcSchemaEntity e); void AddEntities(IfcEntities es); + + void filename(const std::string& s); + std::string filename() const; + void timestamp(const std::string& s); + std::string timestamp() const; + void author(const std::string& name, const std::string& email, const std::string& organisation); + std::string authorName() const; + std::string authorEmail() const; + std::string authorOrganisation() const; }; double UnitPrefixToValue( Ifc2x3::IfcSIPrefix::IfcSIPrefix v );