Compare commits

...

69 Commits

Author SHA1 Message Date
Thomas Krijnen 16f2b0a0d2 Renumber instances, add comments, update federate for group structure 2018-02-13 14:50:39 +01:00
Thomas Krijnen 6dd22fda82 Consistent IFC4 schema 2018-02-06 14:45:22 +01:00
Thomas Krijnen 1e772a7ea9 Inverse attributes 2018-02-06 13:31:00 +01:00
Thomas Krijnen 7e14d4389e Fixes for reading proper select types 2018-02-05 15:19:38 +01:00
Thomas Krijnen 852e3e28ee Create objects group, separate some string definitions 2018-02-02 16:44:35 +01:00
Thomas Krijnen e962872549 Only *ambiguous* selects with type path, numeric code in padded profile 2018-02-02 14:12:14 +01:00
Thomas Krijnen f16b2e59ae Fix set_unset_bitmap_value 2018-01-26 11:53:04 +01:00
Thomas Krijnen 844428fefd Fix IfcBinary default instantiation as part of select 2018-01-23 11:59:24 +01:00
Thomas Krijnen a53ffd2662 Fix padded serialization of aggregate of IfcInteger 2018-01-18 18:05:32 +01:00
Thomas Krijnen fd02665e5e Add missing ifc4 schema 2018-01-18 14:15:42 +01:00
Thomas Krijnen fa3fdcd273 Fix for IfcPropertyEnumeratedValue padded profile 2018-01-18 13:56:38 +01:00
Thomas Krijnen e6499ef3b1 gcc compatibility 2018-01-17 17:00:27 +01:00
Thomas Krijnen cf1de365e7 Fix federation example 2018-01-12 17:05:39 +01:00
Thomas Krijnen 3bdf429c30 Correct bounding boxes on LOD case 2018-01-12 12:39:39 +01:00
Thomas Krijnen 1bef19a87a Update types for LOD segmentation 2018-01-08 12:17:28 +01:00
Thomas Krijnen e07189e6b1 Work on LOD use case 2017-12-08 13:26:23 +01:00
Thomas Krijnen f851a7188f Fix set_unset mask on padded profile 2017-12-07 19:26:51 +01:00
Thomas Krijnen d8d82eb6ec Work on LOD example 2017-12-06 17:51:18 +01:00
Thomas Krijnen 89e97e5d7c Separate properties 2017-12-04 18:14:52 +01:00
Thomas Krijnen 388c717317 Work on LOD use case 2017-12-04 17:20:04 +01:00
Thomas Krijnen 20eb913b65 Work on LOD use case 2017-12-04 17:19:31 +01:00
Thomas Krijnen 6ca5c90517 Work around for H5cpp memory leak 2017-12-04 16:49:03 +01:00
Thomas Krijnen 5e2d5129bb Work on LOD use case 2017-12-01 15:38:28 +01:00
Thomas Krijnen 226a02adfc Work on LOD use case 2017-11-25 09:47:42 +01:00
Thomas Krijnen 03a82fe301 Start working on LOD example 2017-11-24 15:20:21 +01:00
Thomas Krijnen b40a21743b Separate h file 2017-11-24 15:19:58 +01:00
Thomas Krijnen 2562d6c208 Rename federation use case example 2017-11-24 13:20:46 +01:00
Thomas Krijnen cab7716bdf No mounting in federation example 2017-11-24 13:15:24 +01:00
Thomas Krijnen 83af36dc60 common prefix and postfix 2017-11-24 13:14:46 +01:00
Thomas Krijnen 34fd334fcb Check dereference error 2017-11-24 12:15:30 +01:00
Thomas Krijnen 839dd9aed6 Specify mount points from command line 2017-11-24 12:15:08 +01:00
Thomas Krijnen 0f0d060177 Option to renumber instances 2017-11-21 15:45:42 +01:00
Thomas Krijnen 6dc9ff6fa3 Mount: Create new owner history 2017-11-21 13:24:20 +01:00
Thomas Krijnen c2da3b9e82 Write populations to distinct groups 2017-11-20 14:48:40 +01:00
Thomas Krijnen 621859453a Configurable instance locator 2017-11-20 14:38:54 +01:00
Thomas Krijnen 01ab21a69a Incrementing id when enumerating arbitrary instances 2017-11-18 10:40:10 +01:00
Thomas Krijnen 9c81735cbd Begin working on some hdf5 use cases 2017-11-17 14:58:13 +01:00
Thomas Krijnen 659f05bda3 attempts to make hdf5 generation process more configurable 2017-11-17 14:57:33 +01:00
Thomas Krijnen 59020a22ee set_default() on spf header 2017-11-17 14:57:03 +01:00
Thomas Krijnen 693444d4d2 Fix traversal 2017-11-13 14:58:02 +01:00
Thomas Krijnen 93a33a8507 Quotes in comment 2017-11-12 08:30:02 +01:00
Thomas Krijnen e1b1940d83 Conversion back from hdf to spf, referenced profile 2017-11-11 09:43:45 +01:00
Thomas Krijnen 9a2e5d698a Conversion back from hdf to spf, padded profile 2017-11-09 13:49:49 +01:00
Thomas Krijnen 71dcc96ac2 Hacky support for LOGICAL 2017-10-13 14:51:09 +02:00
Thomas Krijnen 2422da4048 Run codegen 2017-10-13 13:12:43 +02:00
Thomas Krijnen f6403c81e1 Ignore line comment in express parser 2017-10-13 13:11:08 +02:00
Thomas Krijnen de78c6c5dc Map LOGICAL to separate type 2017-10-13 13:09:08 +02:00
Thomas Krijnen f24c996bc1 Backport some codegen fixes wrt unicode 2017-10-13 13:08:50 +02:00
Thomas Krijnen 3dbb52a4f3 Read and write header fields in HDF; clean-up 2017-10-13 12:19:50 +02:00
Thomas Krijnen d9c4920d37 Conversion back from hdf to spf, standard profile only ftm 2017-10-11 16:15:27 +02:00
Thomas Krijnen dcf331a78d Correct instance lookup 2017-10-09 15:43:51 +02:00
Thomas Krijnen 09679050c2 Fix iso_10303_26_data_set_names 2017-10-09 14:57:14 +02:00
Thomas Krijnen d13a7b613b Work on padded and referenced profiles 2017-10-09 13:58:29 +02:00
Thomas Krijnen 61fba3f406 Work on padded profile 2017-09-24 13:48:16 +02:00
Thomas Krijnen b8001ea05d Refactor 2017-09-20 17:08:11 +02:00
Thomas Krijnen 4163f817a6 Update win build script and cmake for HDF5 library 2017-08-18 15:29:05 +02:00
aothms 2a0471ec27 Add support for storing aggregate values in separate datasets 2016-02-24 11:26:47 +01:00
aothms 418b78cdd5 Fix wrapper code 2016-02-24 11:26:15 +01:00
aothms c1c738390f Add support for aggregate of bool 2016-02-24 11:25:45 +01:00
aothms 766d45e0cb Add missing include 2016-02-19 14:25:56 +01:00
aothms df88474bc5 Merge remote-tracking branch 'origin/master' into hdf5
Conflicts:
	src/ifcexpressparser/bootstrap.py
	src/ifcexpressparser/templates.py
	src/ifcgeom/IfcGeomFaces.cpp
	src/ifcgeom/IfcGeomFunctions.cpp
	src/ifcgeom/IfcGeomIterator.h
	src/ifcgeom/IfcGeomWires.cpp
	src/ifcparse/Ifc2x3.h
	src/ifcparse/Ifc4.h
	src/ifcparse/IfcLateBoundEntity.cpp
	src/ifcparse/IfcParse.cpp
	src/ifcparse/IfcUtil.h
2016-02-19 14:19:57 +01:00
aothms 6716423a68 Sort instances on name rather than on std::map occurrence. Add chunk-size command line argument. 2016-01-08 06:35:53 +01:00
aothms 83c4b6a642 More serialization options for HDF5 2015-11-30 22:34:48 +01:00
aothms ac8cf298fa Commit override types for efficiency 2015-11-16 10:37:02 +01:00
aothms 579d3713fd hdf5 2015-11-10 11:16:00 +01:00
aothms d076fa588b Work on runtime representation of schema 2015-11-05 11:55:19 +01:00
Thomas Krijnen 23beb5691c Detect abstract entities in schema parser 2015-09-17 10:33:19 +02:00
aothms 822fa91f4d Work on a C++ representation of the parsed EXPRESS schema 2015-08-13 14:28:50 +02:00
aothms 266d6f4c97 Cache the output of the parsed express schema as a Python pickle stream for speedier code generation 2015-08-13 14:26:14 +02:00
72 changed files with 51097 additions and 28409 deletions
+39 -2
View File
@@ -23,6 +23,7 @@ project (IfcOpenShell)
OPTION(UNICODE_SUPPORT "Build IfcOpenShell with Unicode support (requires ICU)." ON)
OPTION(COLLADA_SUPPORT "Build IfcConvert with COLLADA support (requires OpenCOLLADA)." ON)
OPTION(HDF5_SUPPORT "Enable HDF5 support (requires HDF5, zlib)" ON)
OPTION(ENABLE_BUILD_OPTIMIZATIONS "Enable certain compiler and linker optimizations on RelWithDebInfo and Release builds." OFF)
#TODO OPTION(IFCCONVERT_DOUBLE_PRECISION "IfcConvert: Use double precision floating-point numbers." OFF)
OPTION(USE_IFC4 "Use IFC 4 instead of IFC 2x3 (full rebuild recommended when switching this)" OFF)
@@ -46,6 +47,8 @@ UNIFY_ENVVARS_AND_CACHE(ICU_INCLUDE_DIR)
UNIFY_ENVVARS_AND_CACHE(ICU_LIBRARY_DIR)
UNIFY_ENVVARS_AND_CACHE(OPENCOLLADA_INCLUDE_DIR)
UNIFY_ENVVARS_AND_CACHE(OPENCOLLADA_LIBRARY_DIR)
UNIFY_ENVVARS_AND_CACHE(HDF5_INCLUDE_DIR)
UNIFY_ENVVARS_AND_CACHE(HDF5_LIBRARY_DIR)
UNIFY_ENVVARS_AND_CACHE(PCRE_LIBRARY_DIR)
UNIFY_ENVVARS_AND_CACHE(PYTHON_EXECUTABLE)
@@ -187,6 +190,27 @@ IF(COLLADA_SUPPORT)
ENDIF()
ENDIF()
if(HDF5_SUPPORT)
IF("${HDF5_INCLUDE_DIR}" STREQUAL "")
MESSAGE(STATUS "No HDF5 include directory specified")
ElSE()
SET(HDF5_INCLUDE_DIR "${HDF5_INCLUDE_DIR}" CACHE FILEPATH "HDF5 header files")
ENDIF()
IF("${HDF5_LIBRARY_DIR}" STREQUAL "")
MESSAGE(STATUS "No HDF5 library directory specified")
ElSE()
SET(HDF5_LIBRARY_DIR "${HDF5_LIBRARY_DIR}" CACHE FILEPATH "HDF5 library files")
ENDIF()
IF(WIN32)
# An additional lib- prefix is added by HDF5 to denote static libraries
SET(HDF5_LIBRARIES libhdf5_cpp libhdf5 libzlib)
ELSE()
SET(HDF5_LIBRARIES hdf5_cpp hdf5 z szip)
ENDIF()
endif()
# TODO Are these needed on other platforms still or can these be removed for good?
IF (NOT WIN32)
INCLUDE(CheckIncludeFileCXX)
@@ -269,7 +293,7 @@ ElSE()
ENDIF()
INCLUDE_DIRECTORIES(${INCLUDE_DIRECTORIES} ${OCC_INCLUDE_DIR} ${OPENCOLLADA_INCLUDE_DIRS}
${ICU_INCLUDE_DIR} ${Boost_INCLUDE_DIRS}
${ICU_INCLUDE_DIR} ${Boost_INCLUDE_DIRS} ${HDF5_INCLUDE_DIR}
)
if(NOT WIN32)
INCLUDE_DIRECTORIES(${INCLUDE_DIRECTORIES} /usr/inc /usr/local/inc /usr/local/include/oce)
@@ -283,6 +307,7 @@ function(files_for_ifc_version IFC_VERSION RESULT_NAME)
${IFC_PARSE_DIR}/Ifc${IFC_VERSION}-latebound.h
${IFC_PARSE_DIR}/Ifc${IFC_VERSION}.cpp
${IFC_PARSE_DIR}/Ifc${IFC_VERSION}-latebound.cpp
${IFC_PARSE_DIR}/Ifc${IFC_VERSION}-schema.cpp
PARENT_SCOPE
)
endfunction()
@@ -372,6 +397,10 @@ IF(UNICODE_SUPPORT)
TARGET_LINK_LIBRARIES(IfcParse ${ICU_LIBRARIES})
ENDIF()
if(HDF5_SUPPORT)
TARGET_LINK_LIBRARIES(IfcParse ${HDF5_LIBRARIES})
endif()
# IfcGeom
file(GLOB IFCGEOM_H_FILES ../src/ifcgeom/*.h)
file(GLOB IFCGEOM_CPP_FILES ../src/ifcgeom/*.cpp)
@@ -382,7 +411,7 @@ ADD_LIBRARY(IfcGeom STATIC ${IFCGEOM_FILES})
TARGET_LINK_LIBRARIES(IfcGeom IfcParse)
LINK_DIRECTORIES(${LINK_DIRECTORIES} ${IfcOpenShell_BINARY_DIR} ${OCC_LIBRARY_DIR} ${OPENCOLLADA_LIBRARY_DIR}
${ICU_LIBRARY_DIR} ${Boost_LIBRARY_DIRS}
${ICU_LIBRARY_DIR} ${Boost_LIBRARY_DIRS} ${HDF5_LIBRARY_DIR}
)
if(NOT WIN32)
LINK_DIRECTORIES(${LINK_DIRECTORIES} /usr/lib /usr/lib64 /usr/local/lib /usr/local/lib64)
@@ -419,6 +448,14 @@ IF(BUILD_EXAMPLES)
ADD_SUBDIRECTORY(../src/examples examples)
ENDIF()
IF(HDF5_SUPPORT)
ADD_SUBDIRECTORY(../src/hdf5_usecases hdf5_usecases)
ENDIF()
if(NOT MSVC)
add_definitions(-std=c++14)
endif()
# CMake installation targets
INSTALL(FILES ${IFCPARSE_H_FILES} DESTINATION include/ifcparse)
INSTALL(FILES ${IFCGEOM_H_FILES} DESTINATION include/ifcgeom)
+24
View File
@@ -0,0 +1,24 @@
################################################################################
# #
# This file is part of IfcOpenShell. #
# #
# IfcOpenShell is free software: you can redistribute it and/or modify #
# it under the terms of the Lesser GNU General Public License as published by #
# the Free Software Foundation, either version 3.0 of the License, or #
# (at your option) any later version. #
# #
# IfcOpenShell is distributed in the hope that it will be useful, #
# but WITHOUT ANY WARRANTY; without even the implied warranty of #
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
# Lesser GNU General Public License for more details. #
# #
# You should have received a copy of the Lesser GNU General Public License #
# along with this program. If not, see <http://www.gnu.org/licenses/>. #
# #
################################################################################
ADD_EXECUTABLE(hdf5_federate federate.cpp)
TARGET_LINK_LIBRARIES(hdf5_federate IfcParse ${ICU_LIBRARIES} ${Boost_LIBRARIES})
ADD_EXECUTABLE(hdf5_lod lod.cpp)
TARGET_LINK_LIBRARIES(hdf5_lod IfcParse IfcGeom ${OPENCASCADE_LIBRARIES} ${Boost_LIBRARIES} ${ICU_LIBRARIES})
+361
View File
@@ -0,0 +1,361 @@
/********************************************************************************
* *
* This file is part of IfcOpenShell. *
* *
* IfcOpenShell is free software: you can redistribute it and/or modify *
* it under the terms of the Lesser GNU General Public License as published by *
* the Free Software Foundation, either version 3.0 of the License, or *
* (at your option) any later version. *
* *
* IfcOpenShell is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* Lesser GNU General Public License for more details. *
* *
* You should have received a copy of the Lesser GNU General Public License *
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
* *
********************************************************************************/
#include "../../../src/ifcparse/IfcHdf5File.h"
#include "../../../src/ifcparse/IfcWritableEntity.h"
#include <boost/lexical_cast.hpp>
#include <set>
#include <algorithm>
#include "multifile_instance_locator.h"
#pragma warning(disable:4100)
// A comparison operator that is used to isolate the shared hierarchy
class ifc_inst_cmp {
public:
// For these we simply assume that only a single instance exists
bool operator()(IfcSchema::IfcSite* a, IfcSchema::IfcSite* b) const { return false; }
bool operator()(IfcSchema::IfcProject* a, IfcSchema::IfcProject* b) const { return false; }
bool operator()(IfcSchema::IfcBuilding* a, IfcSchema::IfcBuilding* b) const { return false; }
bool operator()(IfcSchema::IfcPostalAddress* a, IfcSchema::IfcPostalAddress* b) const { return false; }
bool operator()(IfcSchema::IfcUnitAssignment* a, IfcSchema::IfcUnitAssignment* b) const { return false; }
bool operator()(IfcSchema::IfcConversionBasedUnit* a, IfcSchema::IfcConversionBasedUnit* b) const {
return a->Name() < b->Name();
}
bool operator()(IfcSchema::IfcDimensionalExponents* a, IfcSchema::IfcDimensionalExponents* b) const {
// For every attribute (which are all integers) check equality
unsigned num_attrs = a->data().getArgumentCount();
for (unsigned i = 0; i < num_attrs; ++i) {
const int v1 = *a->data().getArgument(i);
const int v2 = *b->data().getArgument(i);
if (v1 != v2) {
return v1 < v2;
}
}
return false;
}
bool operator()(IfcSchema::IfcMeasureWithUnit* a, IfcSchema::IfcMeasureWithUnit* b) const {
// Assume the value component is enough to differentiate
double v1 = *a->ValueComponent()->data().getArgument(0);
double v2 = *b->ValueComponent()->data().getArgument(0);
return v1 < v2;
}
bool operator()(IfcSchema::IfcGeometricRepresentationSubContext* a, IfcSchema::IfcGeometricRepresentationSubContext* b) const {
return a->ContextType() < b->ContextType();
}
bool operator()(IfcSchema::IfcGeometricRepresentationContext* a, IfcSchema::IfcGeometricRepresentationContext* b) const {
return a->ContextType() < b->ContextType();
}
bool operator()(IfcSchema::IfcSIUnit* a, IfcSchema::IfcSIUnit* b) const {
// Assume same units accross files
return a->UnitType() < b->UnitType();
}
bool operator()(IfcSchema::IfcBuildingStorey* a, IfcSchema::IfcBuildingStorey* b) const {
return a->Name() < b->Name();
}
bool operator()(IfcSchema::IfcCartesianPoint* a, IfcSchema::IfcCartesianPoint* b) const {
return a->Coordinates() < b->Coordinates();
}
bool operator()(IfcSchema::IfcDirection* a, IfcSchema::IfcDirection* b) const {
return a->DirectionRatios() < b->DirectionRatios();
}
bool operator()(IfcSchema::IfcAxis2Placement3D* a, IfcSchema::IfcAxis2Placement3D* b) const {
if (a->Location()->Coordinates() != b->Location()->Coordinates()) {
return (*this)(a->Location(), b->Location());
}
if (b->hasAxis()) {
if (!a->hasAxis()) {
return true;
} else {
return (*this)(a->Axis(), b->Axis());
}
}
if (b->hasRefDirection()) {
if (!a->hasRefDirection()) {
return true;
} else {
return (*this)(a->RefDirection(), b->RefDirection());
}
}
return false;
}
bool operator()(IfcSchema::IfcLocalPlacement* a, IfcSchema::IfcLocalPlacement* b) const {
if (b->hasPlacementRelTo()) {
if (!a->hasPlacementRelTo()) {
return true;
} else {
return (*this)(a->PlacementRelTo(), b->PlacementRelTo());
}
}
return (*this)(a->RelativePlacement(), b->RelativePlacement());
}
bool operator()(IfcUtil::IfcBaseClass* a, IfcUtil::IfcBaseClass* b) const {
if (a->declaration().type() != b->declaration().type()) {
return a->declaration().type() < b->declaration().type();
// throw std::runtime_error("Types not matching");
}
if (a->declaration().type() == IfcSchema::Type::IfcSite) { return (*this)((IfcSchema::IfcSite*) a, (IfcSchema::IfcSite*) b); }
if (a->declaration().type() == IfcSchema::Type::IfcConversionBasedUnit) { return (*this)((IfcSchema::IfcConversionBasedUnit*) a, (IfcSchema::IfcConversionBasedUnit*) b); }
if (a->declaration().type() == IfcSchema::Type::IfcDimensionalExponents) { return (*this)((IfcSchema::IfcDimensionalExponents*) a, (IfcSchema::IfcDimensionalExponents*) b); }
if (a->declaration().type() == IfcSchema::Type::IfcMeasureWithUnit) { return (*this)((IfcSchema::IfcMeasureWithUnit*) a, (IfcSchema::IfcMeasureWithUnit*) b); }
if (a->declaration().type() == IfcSchema::Type::IfcProject) { return (*this)((IfcSchema::IfcProject*) a, (IfcSchema::IfcProject*) b); }
if (a->declaration().type() == IfcSchema::Type::IfcBuilding) { return (*this)((IfcSchema::IfcBuilding*) a, (IfcSchema::IfcBuilding*) b); }
if (a->declaration().type() == IfcSchema::Type::IfcPostalAddress) { return (*this)((IfcSchema::IfcPostalAddress*) a, (IfcSchema::IfcPostalAddress*) b); }
if (a->declaration().type() == IfcSchema::Type::IfcUnitAssignment) { return (*this)((IfcSchema::IfcUnitAssignment*) a, (IfcSchema::IfcUnitAssignment*) b); }
if (a->declaration().type() == IfcSchema::Type::IfcGeometricRepresentationSubContext) { return (*this)((IfcSchema::IfcGeometricRepresentationSubContext*) a, (IfcSchema::IfcGeometricRepresentationSubContext*) b); }
if (a->declaration().type() == IfcSchema::Type::IfcGeometricRepresentationContext) { return (*this)((IfcSchema::IfcGeometricRepresentationContext*) a, (IfcSchema::IfcGeometricRepresentationContext*) b); }
if (a->declaration().type() == IfcSchema::Type::IfcSIUnit) { return (*this)((IfcSchema::IfcSIUnit*) a, (IfcSchema::IfcSIUnit*) b); }
if (a->declaration().type() == IfcSchema::Type::IfcBuildingStorey) { return (*this)((IfcSchema::IfcBuildingStorey*) a, (IfcSchema::IfcBuildingStorey*) b); }
if (a->declaration().type() == IfcSchema::Type::IfcCartesianPoint) { return (*this)((IfcSchema::IfcCartesianPoint*) a, (IfcSchema::IfcCartesianPoint*) b); }
if (a->declaration().type() == IfcSchema::Type::IfcDirection) { return (*this)((IfcSchema::IfcDirection*) a, (IfcSchema::IfcDirection*) b); }
if (a->declaration().type() == IfcSchema::Type::IfcAxis2Placement3D) { return (*this)((IfcSchema::IfcAxis2Placement3D*) a, (IfcSchema::IfcAxis2Placement3D*) b); }
if (a->declaration().type() == IfcSchema::Type::IfcLocalPlacement) { return (*this)((IfcSchema::IfcLocalPlacement*) a, (IfcSchema::IfcLocalPlacement*) b); }
// Should these be removed if an owner history is created manually?
if (a->declaration().type() == IfcSchema::Type::IfcPerson) { return (a->data().id() & 0x1000000) < (b->data().id() & 0x1000000); }
if (a->declaration().type() == IfcSchema::Type::IfcOrganization) { return (a->data().id() & 0x1000000) < (b->data().id() & 0x1000000); }
if (a->declaration().type() == IfcSchema::Type::IfcPersonAndOrganization) { return (a->data().id() & 0x1000000) < (b->data().id() & 0x1000000); }
if (a->declaration().type() == IfcSchema::Type::IfcOwnerHistory) { return (a->data().id() & 0x1000000) < (b->data().id() & 0x1000000); }
if (a->declaration().type() == IfcSchema::Type::IfcApplication) { return (a->data().id() & 0x1000000) < (b->data().id() & 0x1000000); }
std::cerr << "Unexpected type: " + IfcSchema::Type::ToString(a->declaration().type()) << std::endl;
throw std::runtime_error("Unexpected type: " + IfcSchema::Type::ToString(a->declaration().type()));
}
};
// Usage: hdf5_federate Office_A_20110811_optimized.ifc Office_S_20110811_optimized.ifc Office_MEP_20110811_optimized.ifc
int main(int argc, char** argv) {
// A set of datatypes for the shared hierarchy
std::set<IfcSchema::Type::Enum> shared {
IfcSchema::Type::IfcSite,
IfcSchema::Type::IfcConversionBasedUnit,
IfcSchema::Type::IfcDimensionalExponents,
IfcSchema::Type::IfcMeasureWithUnit,
IfcSchema::Type::IfcProject,
IfcSchema::Type::IfcBuilding,
IfcSchema::Type::IfcPostalAddress,
IfcSchema::Type::IfcUnitAssignment,
IfcSchema::Type::IfcGeometricRepresentationSubContext,
IfcSchema::Type::IfcGeometricRepresentationContext,
IfcSchema::Type::IfcSIUnit,
IfcSchema::Type::IfcBuildingStorey
};
// Open the set of input files
std::vector<IfcParse::IfcFile*> files;
for (int i = 1; i < argc; ++i) {
files.push_back(new IfcParse::IfcFile());
files.back()->Init(argv[i]);
}
// Detect shared instances
std::set<IfcUtil::IfcBaseClass*> shared_instances;
for (auto& ty : shared) {
std::cout << IfcSchema::Type::ToString(ty) << std::endl;
for (auto& file : files) {
IfcEntityList::ptr insts = file->entitiesByType(ty);
std::vector<IfcUtil::IfcBaseClass*> no_subtypes;
std::copy_if(insts->begin(), insts->end(), std::back_inserter(no_subtypes), [ty](IfcUtil::IfcBaseClass* inst) {
return inst->declaration().type() == ty;
});
std::set<IfcUtil::IfcBaseClass*, ifc_inst_cmp> insts_unique(no_subtypes.begin(), no_subtypes.end());
if (insts_unique.size() != no_subtypes.size()) {
throw std::runtime_error("Non-unique instances encountered within file");
}
shared_instances.insert(insts_unique.begin(), insts_unique.end());
}
}
// Follow forward references for shared instances
std::set<IfcUtil::IfcBaseClass*> shared_instances_and_refs;
for (auto& inst : shared_instances) {
IfcEntityList::ptr insts = inst->data().file->traverse(inst);
// Filter out simple types
std::vector<IfcUtil::IfcBaseClass*> insts_without_types;
std::copy_if(insts->begin(), insts->end(), std::back_inserter(insts_without_types), [](IfcUtil::IfcBaseClass* inst) {
return inst->declaration().as_entity() != nullptr;
});
shared_instances_and_refs.insert(insts_without_types.begin(), insts_without_types.end());
}
time_t now_;
time(&now_);
int now = (int)now_;
// Create a novel ownerhistory for the shared hierarchy
IfcSchema::IfcPerson* person = new IfcSchema::IfcPerson(std::string("tfk"), std::string("Krijnen"), std::string("Thomas"), boost::none, boost::none, boost::none, boost::none, boost::none);
IfcSchema::IfcOrganization* org = new IfcSchema::IfcOrganization(std::string("TU/e"), "Eindhoven University of Technology", boost::none, boost::none, boost::none);
IfcSchema::IfcPersonAndOrganization* pando = new IfcSchema::IfcPersonAndOrganization(person, org, boost::none);
IfcSchema::IfcApplication* appl = new IfcSchema::IfcApplication(org, "v1", "IfcOpenShell-HDF5", "IfcOpenShell-HDF5");
IfcSchema::IfcOwnerHistory* owner_history = new IfcSchema::IfcOwnerHistory(pando, appl, IfcSchema::IfcStateEnum::IfcState_READONLY, IfcSchema::IfcChangeActionEnum::IfcChangeAction_ADDED, now, pando, appl, now);
std::vector<IfcUtil::IfcBaseClass*> replacements{ person, org, pando, appl, owner_history};
std::vector<IfcUtil::IfcBaseClass*> shared_instances_and_refs_vector(shared_instances_and_refs.begin(), shared_instances_and_refs.end());
IfcParse::IfcFile temp;
for (int i = 0; i < 0x1000001; ++i) temp.FreshId();
std::for_each(replacements.begin(), replacements.end(), [&shared_instances_and_refs_vector, &temp](IfcUtil::IfcBaseClass* new_inst) {
temp.addEntity(new_inst);
shared_instances_and_refs_vector.erase(
std::remove_if(shared_instances_and_refs_vector.begin(), shared_instances_and_refs_vector.end(), [new_inst](IfcUtil::IfcBaseClass* orig_inst) {
return orig_inst->declaration().type() == new_inst->declaration().type();
}),
shared_instances_and_refs_vector.end()
);
shared_instances_and_refs_vector.push_back(new_inst);
});
shared_instances_and_refs.clear();
shared_instances_and_refs.insert(shared_instances_and_refs_vector.begin(), shared_instances_and_refs_vector.end());
// Assign the new ownerhistory to rooted elements in the shared hierarchy
std::for_each(shared_instances_and_refs.begin(), shared_instances_and_refs.end(), [owner_history](IfcUtil::IfcBaseClass* inst) {
const IfcParse::entity* e = inst->declaration().as_entity();
if (e) {
auto attributes = e->all_attributes();
int index = 0;
std::for_each(attributes.begin(), attributes.end(), [&index, inst, owner_history](const IfcParse::entity::attribute* attr) {
const IfcParse::named_type* nt = attr->type_of_attribute()->as_named_type();
if (nt) {
const IfcParse::entity* e2 = nt->declared_type()->as_entity();
if (e2 && e2->type() == IfcSchema::Type::IfcOwnerHistory) {
IfcWrite::IfcWritableEntity* writable = new IfcWrite::IfcWritableEntity(&inst->data());
writable->setArgument(index, owner_history);
inst->data(writable);
}
}
index++;
});
}
});
std::set<IfcUtil::IfcBaseClass*, ifc_inst_cmp> shared_instances_and_refs_unique(shared_instances_and_refs.begin(), shared_instances_and_refs.end());
// Serialize models into different groups
IfcParse::Hdf5Settings settings;
settings.profile() = IfcParse::Hdf5Settings::standard_referenced;
settings.compress() = true;
settings.chunk_size() = 1024;
std::vector<std::string> names;
std::vector<std::pair<std::string::const_iterator, std::string::const_iterator>> fixes;
std::string common_prefix, common_postfix;
for (int i = 1; i < argc; ++i) {
names.push_back(argv[i]);
fixes.push_back({ names.back().begin(), names.back().end() - 1 });
}
while (true) {
std::vector<char> chars;
std::transform(fixes.begin(), fixes.end(), std::back_inserter(chars), [](auto& pair) {
if (pair.first == pair.second) return '\0';
return (*pair.first++);
});
auto pred = std::bind(std::equal_to<char>(), std::placeholders::_1, chars.front());
if (chars.front() != 0 && std::all_of(chars.begin()+1, chars.end(), pred)) {
common_prefix.push_back(chars.front());
} else {
break;
}
}
while (true) {
std::vector<char> chars;
std::transform(fixes.begin(), fixes.end(), std::back_inserter(chars), [](auto& pair) {
if (pair.first == pair.second) return '\0';
return (*pair.second--);
});
auto pred = std::bind(std::equal_to<char>(), std::placeholders::_1, chars.front());
if (chars.front() != 0 && std::all_of(chars.begin() + 1, chars.end(), pred)) {
common_postfix.insert(common_postfix.begin(), chars.front());
} else {
break;
}
}
H5::H5File file(common_prefix + common_postfix + ".hdf", H5F_ACC_TRUNC);
H5::Group group1 = file.createGroup("population");
IfcParse::IfcHdf5File ifc_hdf5(file, get_schema(), settings);
IfcParse::IfcSpfHeader header;
header.set_default();
IfcParse::instance_enumerator shared_insts_enum(&header, shared_instances_and_refs_unique.begin(), shared_instances_and_refs_unique.end());
multifile_instance_locator* locator = new multifile_instance_locator(file, group1, [&shared_instances_and_refs_unique](IfcUtil::IfcBaseClass* inst) {
auto it = shared_instances_and_refs_unique.find(inst);
if (it == shared_instances_and_refs_unique.end()) {
return inst;
} else {
return *it;
}
}, shared_instances_and_refs_unique.begin(), shared_instances_and_refs_unique.end());
ifc_hdf5.write_schema();
ifc_hdf5.write_population(group1, shared_insts_enum, locator);
int n = 0;
for (auto f : files) {
auto filename = argv[n++ + 1];
H5::Group discipline_group = file.createGroup(filename);
H5::Group child_group = discipline_group.createGroup("population");
locator->next(filename, child_group, f);
IfcParse::instance_enumerator inst_enum(&f->header(), locator->full_begin(), locator->full_end());
ifc_hdf5.write_population(child_group, inst_enum, locator);
}
return 0;
}
+472
View File
@@ -0,0 +1,472 @@
/********************************************************************************
* *
* This file is part of IfcOpenShell. *
* *
* IfcOpenShell is free software: you can redistribute it and/or modify *
* it under the terms of the Lesser GNU General Public License as published by *
* the Free Software Foundation, either version 3.0 of the License, or *
* (at your option) any later version. *
* *
* IfcOpenShell is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* Lesser GNU General Public License for more details. *
* *
* You should have received a copy of the Lesser GNU General Public License *
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
* *
********************************************************************************/
#include "../../../src/ifcparse/IfcHdf5File.h"
#include "../../../src/ifcgeom/IfcGeom.h"
#include "../../../src/ifcparse/IfcWritableEntity.h"
#include <Bnd_Box.hxx>
#include <BRepBndLib.hxx>
#include <BRep_Builder.hxx>
#include <TopoDS_Compound.hxx>
#include <BRepBuilderAPI_Transform.hxx>
#include <BRepBuilderAPI_GTransform.hxx>
#include <algorithm>
#include "multifile_instance_locator.h"
void generate_bounding_boxes(IfcParse::IfcFile& f, const std::string& fn) {
IfcGeom::Kernel kernel;
auto unit_factor = kernel.initializeUnits(*f.entitiesByType<IfcSchema::IfcUnitAssignment>()->begin());
IfcGeom::IteratorSettings settings;
settings.convert_back_units() = true;
settings.disable_triangulation() = true;
settings.disable_opening_subtractions() = true;
IfcSchema::IfcProductDefinitionShape::list::ptr defs_ = f.entitiesByType<IfcSchema::IfcProductDefinitionShape>();
std::vector<IfcSchema::IfcProductDefinitionShape*> defs(defs_->begin(), defs_->end());
// Make sure to sort by id to have new definitions lining up in the same order
std::sort(defs.begin(), defs.end(), [](IfcSchema::IfcProductDefinitionShape* a, IfcSchema::IfcProductDefinitionShape* b) {
return a->data().id() < b->data().id();
});
std::ofstream str(fn.c_str(), std::ios_base::binary);
int N = defs.size(), n = 0;
std::cerr << "boxes:" << std::endl;
// In newer versions of IfcOpenShell this is a method Kernel::apply_transformation()
auto apply_transformation = [](const TopoDS_Shape& s, const gp_GTrsf& gt) {
if (gt.Form() == gp_Other) {
return BRepBuilderAPI_GTransform(s, gt, true).Shape();
}
gp_Trsf t = gt.Trsf();
if (t.Form() == gp_Identity) {
return s;
} else {
/// @todo set to 1. and exactly 1. or use epsilon?
if (t.ScaleFactor() != 1.) {
return BRepBuilderAPI_Transform(s, t, true).Shape();
} else {
return s.Moved(t);
}
}
};
// In newer versions of IfcOpenShell this is a method BRep::as_compound()
auto brep_as_compound = [&apply_transformation](const IfcGeom::Representation::BRep& brep) {
TopoDS_Compound compound;
BRep_Builder builder;
builder.MakeCompound(compound);
for (IfcGeom::IfcRepresentationShapeItems::const_iterator it = brep.begin(); it != brep.end(); ++it) {
const TopoDS_Shape& s = it->Shape();
gp_GTrsf trsf = it->Placement();
if (brep.settings().convert_back_units()) {
gp_Trsf scale;
scale.SetScaleFactor(1.0 / brep.settings().unit_magnitude());
trsf.PreMultiply(scale);
}
const TopoDS_Shape moved_shape = apply_transformation(s, trsf);
builder.Add(compound, moved_shape);
}
return compound;
};
// Generate non-aa bounding boxes in local coordinates as a tuple of six doubles from existing IfcProductDefinitionShape instances
std::for_each(defs.begin(), defs.end(), [&kernel, &brep_as_compound, &str, N, &n, &settings](IfcSchema::IfcProductDefinitionShape* def) {
Bnd_Box box;
auto prods = def->data().getInverse(IfcSchema::Type::IfcProduct, -1)->as<IfcSchema::IfcProduct>();
if (prods->size() != 1) return;
IfcSchema::IfcProduct* prod = *prods->begin();
auto reps = def->Representations();
std::for_each(reps->begin(), reps->end(), [&kernel, &brep_as_compound, &settings, &box, prod](auto rep) {
if (rep->RepresentationIdentifier() == "Body") {
IfcGeom::BRepElement<double>* elem = kernel.create_brep_for_representation_and_product<double>(settings, rep, prod);
BRepBndLib::AddClose(brep_as_compound(elem->geometry()), box);
delete elem;
}
});
const size_t name = def->data().id();
double xyz[6];
box.Get(xyz[0], xyz[1], xyz[2], xyz[3], xyz[4], xyz[5]);
str.write((char*)&name, sizeof(size_t));
str.write((char*)xyz, sizeof(double) * 6);
if (n++ % 1000 == 0) {
std::cerr << "\r" << n * 100 / N << std::flush;
}
});
std::cerr << std::endl;
}
void find_geometric_types(IfcParse::IfcFile& f, const std::string& tfn) {
std::ofstream str(tfn.c_str(), std::ios_base::binary);
IfcSchema::IfcProductDefinitionShape::list::ptr defs_ = f.entitiesByType<IfcSchema::IfcProductDefinitionShape>();
std::vector<IfcSchema::IfcProductDefinitionShape*> defs(defs_->begin(), defs_->end());
// Make sure to sort by id to have new definitions lining up in the same order
std::sort(defs.begin(), defs.end(), [](IfcSchema::IfcProductDefinitionShape* a, IfcSchema::IfcProductDefinitionShape* b) {
return a->data().id() < b->data().id();
});
// Initial choice of geometric types
std::set<IfcSchema::Type::Enum> geometric_types{
IfcSchema::Type::IfcStyledItem, IfcSchema::Type::IfcMaterialDefinitionRepresentation, IfcSchema::Type::IfcStyledRepresentation,
IfcSchema::Type::IfcSurfaceStyleRendering, IfcSchema::Type::IfcSurfaceStyle, IfcSchema::Type::IfcPresentationLayerAssignment,
IfcSchema::Type::IfcPresentationStyleAssignment, IfcSchema::Type::IfcColourRgb
};
std::set<IfcSchema::Type::Enum> other_types;
// Find all instances
std::set<IfcUtil::IfcBaseClass*> geometric_instances;
for (auto ty : geometric_types) {
auto insts = f.entitiesByType(ty);
std::for_each(insts->begin(), insts->end(), [&geometric_instances](IfcUtil::IfcBaseClass* inst) {
geometric_instances.insert(inst);
});
}
int N, n;
// Not referenced. Revit generates unused IfcExtrudedAreaSolids some times.
auto repitems = f.entitiesByType(IfcSchema::Type::IfcRepresentationItem);
std::for_each(repitems->begin(), repitems->end(), [&f, &geometric_instances](IfcUtil::IfcBaseClass* inst) {
auto invs = f.getInverse(inst->data().id(), IfcSchema::Type::UNDEFINED, -1);
if (invs->size() == 0) {
auto refs = f.traverse(inst);
std::for_each(refs->begin(), refs->end(), [&geometric_instances](IfcUtil::IfcBaseClass* inst2) {
if (inst2->declaration().as_entity()) {
geometric_instances.insert(inst2);
}
});
}
});
// Recurse over forward attributes
auto vist_geometric = [&f, &geometric_types, &geometric_instances, &N, &n](IfcUtil::IfcBaseEntity* def) {
auto refs = f.traverse(def);
geometric_instances.insert(refs->begin(), refs->end());
std::for_each(refs->begin(), refs->end(), [&geometric_types](IfcUtil::IfcBaseClass* inst) {
if (inst->declaration().as_entity()) {
geometric_types.insert(inst->declaration().type());
}
});
if (n++ % 1000 == 0) {
std::cerr << "\r" << (n * 100 / N) << std::flush;
}
};
n = 0;
N = defs.size();
std::for_each(defs.begin(), defs.end(), vist_geometric);
// Include connection geometry (e.g space boundaries) as well
auto connection_geom = f.entitiesByType<IfcSchema::IfcConnectionGeometry>();
n = 0;
N = connection_geom->size();
std::for_each(connection_geom->begin(), connection_geom->end(), vist_geometric);
// Traverse again all instances, but now to detect which geometric types are fully and only shared by geometric instances
std::function<void(IfcUtil::IfcBaseClass*, IfcUtil::IfcBaseClass*)> fn;
fn = [&f, &geometric_instances, &other_types, &fn](IfcUtil::IfcBaseClass* root, IfcUtil::IfcBaseClass* inst) {
if (geometric_instances.find(inst) == geometric_instances.end()) {
auto ty = inst->declaration().type();
other_types.insert(ty);
auto refs = f.traverse(inst, 1);
std::for_each(refs->begin() + 1, refs->end(), [&fn, root](IfcUtil::IfcBaseClass* inst) {
if (inst->declaration().as_entity()) {
fn(root, inst);
}
});
}
};
N = std::distance(f.begin(), f.end());
n = 0;
std::for_each(f.begin(), f.end(), [&fn, N, &n](const auto& pair) {
fn(pair.second, pair.second);
if (n++ % 1000 == 0) {
std::cerr << "\r" << n * 100 / N << std::flush;
}
});
std::set<IfcSchema::Type::Enum> only_geometric;
std::set_difference(geometric_types.begin(), geometric_types.end(),
other_types.begin(), other_types.end(),
std::inserter(only_geometric, only_geometric.begin()));
only_geometric.erase(IfcSchema::Type::IfcGeometricRepresentationContext);
only_geometric.erase(IfcSchema::Type::IfcGeometricRepresentationSubContext);
std::cerr << "\nOnly geometric:" << std::endl;
for (auto ty : only_geometric) {
std::cerr << IfcSchema::Type::ToString(ty) << std::endl;
const size_t name = ty;
str.write((char*)&name, sizeof(size_t));
}
}
int main(int argc, char** argv) {
const std::string cache_fn = argv[1] + std::string(".boxes.bin");
const std::string types_fn = argv[1] + std::string(".types.bin");
if (argc == 2 && !ifstream(cache_fn).good()) {
std::string command = std::string("\"\"") + argv[0] + "\" \"" + argv[1] + "\" -b\"";
if (system(command.c_str()) != 0) {
return 1;
}
}
if (argc == 2 && !ifstream(types_fn).good()) {
std::string command = std::string("\"\"") + argv[0] + "\" \"" + argv[1] + "\" -t\"";
if (system(command.c_str()) != 0) {
return 1;
}
}
IfcParse::IfcFile f;
f.Init(argv[1]);
if (argc == 3 && std::string(argv[2]) == "-b") {
generate_bounding_boxes(f, cache_fn);
return 0;
}
if (argc == 3 && std::string(argv[2]) == "-t") {
find_geometric_types(f, types_fn);
return 0;
}
std::set<IfcSchema::Type::Enum> only_geometric;
{
std::ifstream str(types_fn.c_str(), std::ios_base::binary);
while (!str.eof()) {
size_t name;
str.read((char*)&name, sizeof(size_t));
only_geometric.insert((IfcSchema::Type::Enum) name);
}
}
std::set<IfcSchema::Type::Enum> property_types {
IfcSchema::Type::IfcRelDefines,
IfcSchema::Type::IfcPropertySetDefinition,
IfcSchema::Type::IfcTypeObject,
IfcSchema::Type::IfcProperty,
IfcSchema::Type::IfcPhysicalQuantity,
IfcSchema::Type::IfcRelAssociatesClassification,
IfcSchema::Type::IfcClassification,
IfcSchema::Type::IfcClassificationReference,
IfcSchema::Type::IfcRelAssociatesMaterial,
IfcSchema::Type::IfcMaterialList,
IfcSchema::Type::IfcMaterialLayerSetUsage,
IfcSchema::Type::IfcMaterialLayerSet,
IfcSchema::Type::IfcMaterialLayer,
IfcSchema::Type::IfcMaterial
};
std::vector<IfcUtil::IfcBaseClass*> new_defs, old_defs, old_prop_defs, old_geom_defs, old_box_defs, all_old_defs, all_defs;
std::for_each(only_geometric.begin(), only_geometric.end(), [&f, &old_geom_defs](IfcSchema::Type::Enum t) {
auto insts = f.entitiesByType(t);
std::for_each(insts->begin(), insts->end(), [t, &old_geom_defs](IfcUtil::IfcBaseClass* inst) {
if (inst->declaration().type() == t) {
old_geom_defs.push_back(inst);
}
});
});
std::for_each(f.begin(), f.end(), [&only_geometric, &old_defs, &old_prop_defs, &property_types](const auto& pair) {
IfcUtil::IfcBaseClass* inst = pair.second;
// This is checked the other way around to include subtypes
bool is_property = false;
for (auto pty : property_types) {
if (inst->declaration().is(pty)) {
is_property = true;
break;
}
}
auto ty = inst->declaration().type();
if (is_property) {
old_prop_defs.push_back(inst);
} else if (only_geometric.find(ty) == only_geometric.end()) {
old_defs.push_back(inst);
}
});
IfcSchema::IfcRepresentationContext* context = 0;
auto reps = (*f.entitiesByType<IfcSchema::IfcProductDefinitionShape>()->begin())->Representations();
std::for_each(reps->begin(), reps->end(), [&context](auto rep) {
IfcGeom::IfcRepresentationShapeItems items;
if (rep->RepresentationIdentifier() == "Body") {
context = rep->ContextOfItems();
}
});
auto id = f.FreshId();
int num_points_added = 0;
// Create bounding box representation from the 6-tuple definitions
{
std::ifstream str(cache_fn.c_str(), std::ios_base::binary);
while (!str.eof()) {
size_t name;
double xyz[6];
str.read((char*)&name, sizeof(size_t));
str.read((char*)xyz, sizeof(double) * 6);
IfcSchema::IfcCartesianPoint* corner = new IfcSchema::IfcCartesianPoint(std::vector<double>{xyz[0], xyz[1], xyz[2]});;
IfcSchema::IfcBoundingBox* bbox = new IfcSchema::IfcBoundingBox(corner, xyz[3] - xyz[0], xyz[4] - xyz[1], xyz[5] - xyz[2]);
IfcSchema::IfcRepresentationItem::list::ptr items(new IfcSchema::IfcRepresentationItem::list);
items->push(bbox);
IfcSchema::IfcShapeRepresentation* rep = new IfcSchema::IfcShapeRepresentation(context, std::string("Body"), std::string("BoundingBox"), items);
IfcSchema::IfcRepresentation::list::ptr new_reps(new IfcSchema::IfcRepresentation::list);
new_reps->push(rep);
IfcSchema::IfcProductDefinitionShape* new_def = new IfcSchema::IfcProductDefinitionShape(boost::none, boost::none, new_reps);
corner->data().isWritable()->setId(id++);
// NB: Corner is added to existing definitions
old_defs.push_back(corner); ++num_points_added;
new_defs.push_back(bbox);
new_defs.push_back(rep);
new_defs.push_back(new_def);
}
}
std::for_each(new_defs.begin(), new_defs.end(), [&id](auto new_def) {
new_def->data().isWritable()->setId(id++);
});
auto iden = [](IfcUtil::IfcBaseClass* inst) { return inst; };
std::set<IfcSchema::Type::Enum> old_new_geom_types;
std::vector<std::vector<IfcUtil::IfcBaseClass*>*> all_vectors = std::vector<std::vector<IfcUtil::IfcBaseClass*>*>{ &new_defs, &old_prop_defs, &old_defs, &old_geom_defs };
for (auto vec_ : all_vectors) {
auto& vec = *vec_;
for (auto& inst : vec) {
old_new_geom_types.insert(inst->declaration().type());
}
}
// Generate proper buckets of data and serialize
all_old_defs.insert(all_old_defs.end(), old_defs.begin(), old_defs.end());
all_old_defs.insert(all_old_defs.end(), old_prop_defs.begin(), old_prop_defs.end());
all_old_defs.insert(all_old_defs.end(), old_geom_defs.begin(), old_geom_defs.end());
all_defs.insert(all_defs.end(), all_old_defs.begin(), all_old_defs.end());
all_defs.insert(all_defs.end(), new_defs.begin(), new_defs.end());
old_box_defs.insert(old_box_defs.end(), old_defs.begin(), old_defs.end());
old_box_defs.insert(old_box_defs.end(), new_defs.begin(), new_defs.end());
auto contexts = f.entitiesByType<IfcSchema::IfcRepresentationContext>();
old_box_defs.insert(old_box_defs.end(), contexts->begin(), contexts->end());
{
int num_insts1 = std::distance(all_old_defs.begin(), all_old_defs.end());
int num_insts2 = std::distance(f.begin(), f.end());
if ((num_insts1 - num_points_added) != num_insts2) {
std::cerr << "Missign instances " << num_insts1 << " - " << num_points_added << " != " << num_insts2 << std::endl;
abort();
}
}
multifile_instance_locator* locator = new multifile_instance_locator(
old_new_geom_types.begin(), old_new_geom_types.end(),
all_old_defs.begin(), all_old_defs.end());
IfcParse::Hdf5Settings settings;
settings.profile() = IfcParse::Hdf5Settings::padded;
settings.compress() = true;
settings.chunk_size() = 1024;
H5::H5File hdf(argv[1] + std::string(".hdf"), H5F_ACC_TRUNC);
H5::H5File geom_hdf(argv[1] + std::string("-geometry.hdf"), H5F_ACC_TRUNC);
H5::H5File box_hdf(argv[1] + std::string("-bounding-boxes.hdf"), H5F_ACC_TRUNC);
H5::H5File prop_hdf(argv[1] + std::string("-properties.hdf"), H5F_ACC_TRUNC);
hdf.createGroup("geometry").close();
hdf.createGroup("bounding-boxes").close();
hdf.createGroup("properties").close();
hdf.mount("geometry", geom_hdf, H5::PropList::DEFAULT);
hdf.mount("bounding-boxes", box_hdf, H5::PropList::DEFAULT);
hdf.mount("properties", prop_hdf, H5::PropList::DEFAULT);
H5::Group main_population = hdf.createGroup("population");
H5::Group geom_population = hdf.createGroup("geometry/population");
H5::Group box_population = hdf.createGroup("bounding-boxes/population");
H5::Group prop_population = hdf.createGroup("properties/population");
{
IfcParse::IfcHdf5File ifc_hdf5(hdf, get_schema(), settings);
IfcParse::instance_categorizer categorizer(all_defs.begin(), all_defs.end());
ifc_hdf5.write_schema(&categorizer);
{
IfcParse::instance_enumerator enumerator(&f.header(), old_defs.begin(), old_defs.end());
ifc_hdf5.write_population(main_population, enumerator, locator);
}
{
IfcParse::instance_enumerator enumerator(&f.header(), old_geom_defs.begin(), old_geom_defs.end());
ifc_hdf5.write_population(geom_population, enumerator, locator);
}
{
IfcParse::instance_enumerator enumerator(&f.header(), old_prop_defs.begin(), old_prop_defs.end());
ifc_hdf5.write_population(prop_population, enumerator, locator);
}
{
// locator is setup with all_old_defs, need to switch to new_defs + old_defs for the cartesian points
// NB: also geom rep context
locator->next(box_population, old_box_defs.begin(), old_box_defs.end());
IfcParse::instance_enumerator enumerator(&f.header(), new_defs.begin(), new_defs.end());
ifc_hdf5.write_population(box_population, enumerator, locator);
}
}
}
@@ -0,0 +1,275 @@
/********************************************************************************
* *
* This file is part of IfcOpenShell. *
* *
* IfcOpenShell is free software: you can redistribute it and/or modify *
* it under the terms of the Lesser GNU General Public License as published by *
* the Free Software Foundation, either version 3.0 of the License, or *
* (at your option) any later version. *
* *
* IfcOpenShell is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* Lesser GNU General Public License for more details. *
* *
* You should have received a copy of the Lesser GNU General Public License *
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
* *
********************************************************************************/
class multifile_instance_locator : public IfcParse::abstract_instance_locator {
public:
typedef std::function<IfcUtil::IfcBaseClass*(IfcUtil::IfcBaseClass*)> mapping_t;
typedef std::pair<
std::vector<IfcSchema::Type::Enum>,
std::vector< std::vector<IfcUtil::IfcBaseEntity*> >
> population_t;
typedef std::vector<IfcUtil::IfcBaseClass*>::const_iterator full_const_iterator;
private:
H5::H5File* root_file_;
mapping_t mapping_;
std::set<IfcUtil::IfcBaseClass*> initial_population_set_;
std::set<IfcSchema::Type::Enum> initial_types_included_set_;
population_t initial_population_;
population_t subsequent_population_;
std::vector<IfcUtil::IfcBaseClass*> subsequent_minus_initial_;
H5::Group* initial_group_;
H5::Group* subsequent_group_;
H5::H5File* subsequent_file_;
std::string root_;
public:
template <typename ForwardIterator>
multifile_instance_locator(H5::H5File& root_file, H5::Group& group, mapping_t mapping, ForwardIterator b, ForwardIterator e)
: root_file_(&root_file)
, mapping_(mapping)
, initial_group_(&group)
, subsequent_group_(nullptr)
{
initial_population_set_.insert(b, e);
std::set<IfcSchema::Type::Enum> names_set;
std::for_each(b, e, [this, &names_set](IfcUtil::IfcBaseClass* inst) {
IfcSchema::Type::Enum ty = inst->declaration().type();
if (names_set.find(ty) == names_set.end()) {
initial_population_.first.push_back(ty);
names_set.insert(ty);
}
});
std::sort(initial_population_.first.begin(), initial_population_.first.end());
std::for_each(this->begin(), this->end(), [this, &b, &e](IfcSchema::Type::Enum t) {
std::vector<IfcUtil::IfcBaseEntity*> by_type;
std::for_each(b, e, [t,&by_type](IfcUtil::IfcBaseClass* inst) {
if (inst->declaration().type() == t && inst->declaration().as_entity()) {
by_type.push_back((IfcUtil::IfcBaseEntity*) inst);
}
});
std::sort(by_type.begin(), by_type.end(), [](IfcUtil::IfcBaseEntity* i1, IfcUtil::IfcBaseEntity* i2) {
return i1->data().id() < i2->data().id();
});
initial_population_.second.emplace_back(by_type);
});
}
template <typename ForwardIteratorTypes, typename ForwardIteratorInsts>
multifile_instance_locator(ForwardIteratorTypes types_all_begin, ForwardIteratorTypes types_all_end, ForwardIteratorInsts insts_begin, ForwardIteratorInsts insts_end)
: subsequent_group_(nullptr)
{
initial_population_.first.assign(types_all_begin, types_all_end);
std::sort(initial_population_.first.begin(), initial_population_.first.end());
std::for_each(this->begin(), this->end(), [this, &insts_begin, &insts_end](IfcSchema::Type::Enum t) {
std::vector<IfcUtil::IfcBaseEntity*> by_type;
std::for_each(insts_begin, insts_end, [t, &by_type](IfcUtil::IfcBaseClass* inst) {
if (inst->declaration().type() == t && inst->declaration().as_entity()) {
by_type.push_back((IfcUtil::IfcBaseEntity*) inst);
}
});
std::sort(by_type.begin(), by_type.end(), [](IfcUtil::IfcBaseEntity* i1, IfcUtil::IfcBaseEntity* i2) {
return i1->data().id() < i2->data().id();
});
initial_population_.second.emplace_back(by_type);
});
}
const_iterator begin() const {
if (subsequent_group_) {
return subsequent_population_.first.begin();
} else {
return initial_population_.first.begin();
}
}
const_iterator end() const {
if (subsequent_group_) {
return subsequent_population_.first.end();
} else {
return initial_population_.first.end();
}
}
full_const_iterator full_begin() const {
return subsequent_minus_initial_.begin();
}
full_const_iterator full_end() const {
return subsequent_minus_initial_.end();
}
const std::vector<IfcUtil::IfcBaseEntity*>& instances(IfcSchema::Type::Enum t) {
if (subsequent_group_) {
return subsequent_population_.second[std::lower_bound(begin(), end(), t) - begin()];
} else {
return initial_population_.second[std::lower_bound(begin(), end(), t) - begin()];
}
}
std::pair<int, int> operator()(IfcUtil::IfcBaseClass* v) {
if (IfcSchema::Type::IsSimple(v->declaration().type())) {
throw std::exception("Simple type not expected here");
}
IfcSchema::Type::Enum t = v->declaration().type();
// This remains constant for subsequent model serializations?
auto& dataset_names = initial_population_.first;
auto tt = std::lower_bound(dataset_names.begin(), dataset_names.end(), t);
int a = std::distance(dataset_names.begin(), tt);
int b;
const std::vector<IfcUtil::IfcBaseEntity*>& insts = instances(t);
auto it = std::lower_bound(insts.begin(), insts.end(), v, [](IfcUtil::IfcBaseClass* other, IfcUtil::IfcBaseClass* val) {
// An ordering based on ID is not equivalent to an ordering based on pointer address!
return other->data().id() < val->data().id();
});
if (it == insts.end()) {
throw std::runtime_error("Unable to find instance");
}
b = std::distance(insts.begin(), it);
return std::make_pair(a, b);
}
void make_reference(IfcUtil::IfcBaseClass* v, void*& ptr) {
v = mapping_(v);
IfcSchema::Type::Enum t = v->declaration().type();
population_t* pop;
H5::Group* group;
boost::optional<std::string> current_root;
if (initial_population_set_.find(v) != initial_population_set_.end()) {
pop = &initial_population_;
group = initial_group_;
current_root = boost::none;
} else {
pop = &subsequent_population_;
group = subsequent_group_;
current_root = root_;
}
int a = std::lower_bound(pop->first.begin(), pop->first.end(), t) - pop->first.begin();
auto& vec = pop->second[a];
hsize_t coord = std::lower_bound(vec.begin(), vec.end(), v, [](IfcUtil::IfcBaseClass* other, IfcUtil::IfcBaseClass* val) {
return other->data().id() < val->data().id();
}) - vec.begin();
hsize_t dims = instances(v->declaration().type()).size();
H5::DataSpace space(1, &dims);
space.selectElements(H5S_SELECT_SET, 1, &coord);
const std::string path = IfcSchema::Type::ToString(pop->first[a]);
std::string full_path = group->getObjName() + "/" + path + "_objects" + "/" + path + "_instances";
root_file_->reference(ptr, full_path, space);
ptr = static_cast<uint8_t*>(ptr) + sizeof(hdset_reg_ref_t);
}
template <typename ForwardIt>
void next(H5::Group& group, ForwardIt insts_begin, ForwardIt insts_end) {
subsequent_group_ = &group;
subsequent_population_.first = initial_population_.first;
subsequent_population_.second.clear();
std::for_each(this->begin(), this->end(), [this, &insts_begin, &insts_end](IfcSchema::Type::Enum t) {
std::vector<IfcUtil::IfcBaseEntity*> by_type;
std::for_each(insts_begin, insts_end, [t, &by_type](IfcUtil::IfcBaseClass* inst) {
if (inst->declaration().type() == t && inst->declaration().as_entity()) {
by_type.push_back((IfcUtil::IfcBaseEntity*) inst);
}
});
std::sort(by_type.begin(), by_type.end(), [](IfcUtil::IfcBaseEntity* i1, IfcUtil::IfcBaseEntity* i2) {
return i1->data().id() < i2->data().id();
});
subsequent_population_.second.emplace_back(by_type);
});
}
void next(const std::string& name, H5::Group& group, IfcParse::IfcFile* f) {
subsequent_group_ = &group;
root_ = name;
subsequent_population_.first.clear();
subsequent_population_.second.clear();
subsequent_minus_initial_.clear();
auto f_begin = f->begin();
auto f_end = f->end();
std::set<IfcSchema::Type::Enum> names_set;
std::for_each(f_begin, f_end, [this, &names_set](auto& pair) {
IfcUtil::IfcBaseClass* inst = mapping_(pair.second);
if (initial_population_set_.find(inst) == initial_population_set_.end()) {
IfcSchema::Type::Enum ty = inst->declaration().type();
if (names_set.find(ty) == names_set.end()) {
subsequent_population_.first.push_back(ty);
names_set.insert(ty);
}
subsequent_minus_initial_.push_back(inst);
}
});
auto& names = subsequent_population_.first;
std::sort(names.begin(), names.end());
auto& vecs = subsequent_population_.second;
vecs.resize(names.size());
std::for_each(f_begin, f_end, [this, &names, &vecs](auto& pair) {
IfcUtil::IfcBaseClass* inst = mapping_(pair.second);
if (initial_population_set_.find(inst) == initial_population_set_.end() && inst->declaration().as_entity()) {
IfcSchema::Type::Enum ty = inst->declaration().type();
auto a = std::lower_bound(names.begin(), names.end(), ty) - names.begin();
auto& by_type = vecs[a];
by_type.push_back((IfcUtil::IfcBaseEntity*) inst);
}
});
std::for_each(vecs.begin(), vecs.end(), [](auto& vec) {
std::sort(vec.begin(), vec.end(), [](IfcUtil::IfcBaseEntity* i1, IfcUtil::IfcBaseEntity* i2) {
return i1->data().id() < i2->data().id();
});
});
}
};
+75 -1
View File
@@ -26,6 +26,9 @@
* *
********************************************************************************/
#define BOOST_MPL_CFG_NO_PREPROCESSED_HEADERS
#define BOOST_MPL_LIMIT_LIST_SIZE 30
#include <fstream>
#include <sstream>
#include <set>
@@ -34,6 +37,9 @@
#include <boost/program_options.hpp>
#include <boost/algorithm/string.hpp>
#include "../ifcparse/Hdf5Settings.h"
#include "../ifcparse/IfcHdf5File.h"
#include "../ifcgeom/IfcGeomIterator.h"
#include "../ifcconvert/ColladaSerializer.h"
@@ -69,6 +75,8 @@ void printUsage(const boost::program_options::options_description& generic_optio
<< " .igs IGES Initial Graphics Exchange Specification" << std::endl
<< " .xml XML Property definitions and decomposition tree" << std::endl
<< " .svg SVG Scalable Vector Graphics (2d floor plan)" << std::endl
<< " .hdf HDF5 Efficient binary IFC serialization" << std::endl
<< " .ifc IFC-SPF Standard p21 IFC serialization" << std::endl
<< std::endl
<< "Command line options" << std::endl << generic_options << std::endl
<< "Advanced options" << std::endl << geom_options << std::endl;
@@ -98,8 +106,13 @@ int main(int argc, char** argv) {
("input-file", boost::program_options::value<std::string>(), "input IFC file")
("output-file", boost::program_options::value<std::string>(), "output geometry file");
std::string bounds;
std::string bounds, hdf5_profile;
uint32_t hdf5_chunk_size;
std::vector<std::string> entity_vector;
std::vector<std::string> hdf5_ref_attributes;
std::vector<std::string> hdf5_mount_points;
boost::program_options::options_description geom_options;
geom_options.add_options()
("plan",
@@ -145,6 +158,17 @@ int main(int argc, char** argv) {
("bounds", boost::program_options::value<std::string>(&bounds),
"Specifies the bounding rectangle, for example 512x512, to which the "
"output will be scaled. Only used when converting to SVG.")
("hdf5-profile", boost::program_options::value<std::string>(&hdf5_profile), "")
("hdf5-compress", "")
("hdf5-fix-cartesian-point", "")
("hdf5-fix-global-id", "")
("hdf5-instantiate-inverse", "")
("hdf5-instantiate-select", "")
("hdf5-mount", boost::program_options::value< std::vector<std::string> >(&hdf5_mount_points)->multitoken(),
"")
("hdf5-chunk-size", boost::program_options::value(&hdf5_chunk_size), "")
("hdf5-ref-attributes", boost::program_options::value< std::vector<std::string> >(&hdf5_ref_attributes)->multitoken(),
"")
("include",
"Specifies that the entities listed after --entities are to be included")
("exclude",
@@ -261,6 +285,56 @@ int main(int argc, char** argv) {
} catch (...) {}
write_log();
return exit_code;
} else if (output_extension == ".hdf") {
int exit_code = 1;
// try {
IfcParse::IfcFile f;
if (!f.Init(input_filename)) {
Logger::Message(Logger::LOG_ERROR, "Unable to parse .ifc file");
} else {
IfcParse::Hdf5Settings settings;
settings.compress() = vmap.count("hdf5-compress") != 0;
settings.fix_cartesian_point() = vmap.count("hdf5-fix-cartesian-point") != 0;
settings.fix_global_id() = vmap.count("hdf5-fix-global-id") != 0;
settings.instantiate_inverse() = vmap.count("hdf5-instantiate-inverse") != 0;
settings.instantiate_select() = vmap.count("hdf5-instantiate-select") != 0;
std::sort(hdf5_ref_attributes.begin(), hdf5_ref_attributes.end());
settings.ref_attributes() = hdf5_ref_attributes;
if (vmap.count("hdf5-chunk-size") == 1) {
settings.chunk_size() = hdf5_chunk_size;
}
if (vmap.count("hdf5-profile") == 1) {
settings.profile() = IfcParse::Hdf5Settings::ProfileFromString(hdf5_profile);
}
f.write_hdf5(output_filename, settings);
exit_code = 0;
}
// } catch (...) {}
write_log();
// std::cin.get();
return exit_code;
} else if (output_extension == ".ifc") {
bool success = false;
const std::string input_extension = input_filename.substr(input_filename.size() - 4);
if (input_extension == ".ifc") {
IfcParse::IfcFile f;
if (f.Init(input_filename)) {
std::ofstream of(output_filename.c_str());
of << f;
success = true;
} else {
Logger::Message(Logger::LOG_ERROR, "Unable to parse .ifc file");
}
} else if (input_extension == ".hdf") {
std::ofstream fs(output_filename.c_str());
IfcParse::IfcHdf5File::convert_to_spf(input_filename, fs, hdf5_mount_points);
success = true;
} else {
Logger::Message(Logger::LOG_ERROR, "Unknown input extension");
}
write_log();
return success ? 0 : 1;
}
IfcGeom::IteratorSettings settings;
+4 -4
View File
@@ -182,7 +182,7 @@ void SvgSerializer::write(const IfcGeom::BRepElement<double>* o) {
// Iterate over the decomposing element to find the parent IfcBuildingStorey
decomposition_element::list::ptr decomposes = obdef->Decomposes();
if (!decomposes->size()) {
if (obdef->is(IfcSchema::Type::IfcElement)) {
if (obdef->declaration().is(IfcSchema::Type::IfcElement)) {
IfcSchema::IfcRelContainedInSpatialStructure::list::ptr containment = ((IfcSchema::IfcElement*)obdef)->ContainedInStructure();
if (!containment->size()) {
break;
@@ -204,7 +204,7 @@ void SvgSerializer::write(const IfcGeom::BRepElement<double>* o) {
}
}
}
if (obdef->is(IfcSchema::Type::IfcBuildingStorey)) {
if (obdef->declaration().is(IfcSchema::Type::IfcBuildingStorey)) {
storey = static_cast<IfcSchema::IfcBuildingStorey*>(obdef);
break;
}
@@ -349,7 +349,7 @@ std::string SvgSerializer::nameElement(const IfcGeom::Element<double>* elem) {
std::string SvgSerializer::nameElement(const IfcSchema::IfcProduct* elem) {
std::ostringstream oss;
const std::string type = elem->is(IfcSchema::Type::IfcBuildingStorey) ? "storey" : "product";
const std::string type = elem->declaration().is(IfcSchema::Type::IfcBuildingStorey) ? "storey" : "product";
oss << "id=\"product-" << IfcParse::IfcGlobalId(elem->GlobalId()).formatted() << "\"";
return oss.str();
}
}
+16 -14
View File
@@ -60,15 +60,15 @@ boost::optional<std::string> format_attribute(const Argument* argument, IfcUtil:
break; }
case IfcUtil::Argument_ENTITY_INSTANCE: {
IfcUtil::IfcBaseClass* e = *argument;
if (Type::IsSimple(e->type())) {
if (Type::IsSimple(e->declaration().type())) {
IfcUtil::IfcBaseType* f = (IfcUtil::IfcBaseType*) e;
value = format_attribute(f->getArgument(0), f->getArgumentType(0));
} else if (e->is(IfcSchema::Type::IfcSIUnit) || e->is(IfcSchema::Type::IfcConversionBasedUnit)) {
value = format_attribute(f->data().getArgument(0), f->data().getArgument(0)->type());
} else if (e->declaration().is(IfcSchema::Type::IfcSIUnit) || e->declaration().is(IfcSchema::Type::IfcConversionBasedUnit)) {
// Some string concatenation to have a unit name as a XML attribute.
std::string unit_name;
if (e->is(IfcSchema::Type::IfcSIUnit)) {
if (e->declaration().is(IfcSchema::Type::IfcSIUnit)) {
IfcSchema::IfcSIUnit* unit = (IfcSchema::IfcSIUnit*) e;
unit_name = IfcSchema::IfcSIUnitName::ToString(unit->Name());
if (unit->hasPrefix()) {
@@ -93,18 +93,20 @@ boost::optional<std::string> format_attribute(const Argument* argument, IfcUtil:
// over the entity attributes and writes them as xml attributes of the node.
ptree& format_entity_instance(IfcUtil::IfcBaseEntity* instance, ptree& tree, bool as_link = false) {
ptree child;
const unsigned n = instance->getArgumentCount();
const unsigned n = instance->data().getArgumentCount();
std::vector<const IfcParse::entity::attribute*> attributes = instance->declaration().all_attributes();
for (unsigned i = 0; i < n; ++i) {
const Argument* argument = instance->getArgument(i);
const Argument* argument = instance->data().getArgument(i);
if (argument->isNull()) continue;
std::string argument_name = instance->getArgumentName(i);
std::string argument_name = attributes[i]->name();
std::map<std::string, std::string>::const_iterator argument_name_it;
argument_name_it = argument_name_map.find(argument_name);
if (argument_name_it != argument_name_map.end()) {
argument_name = argument_name_it->second;
}
const IfcUtil::ArgumentType argument_type = instance->getArgumentType(i);
const IfcUtil::ArgumentType argument_type = instance->data().getArgument(i)->type();
boost::optional<std::string> value;
try {
@@ -123,7 +125,7 @@ ptree& format_entity_instance(IfcUtil::IfcBaseEntity* instance, ptree& tree, boo
}
}
}
return tree.add_child(Type::ToString(instance->type()), child);
return tree.add_child(Type::ToString(instance->declaration().type()), child);
}
// A function to be called recursively. Template specialization is used
@@ -152,7 +154,7 @@ template <>
void descend(IfcProduct* product, ptree& tree) {
ptree& child = format_entity_instance(product, tree);
if (product->is(Type::IfcSpatialStructureElement)) {
if (product->declaration().is(Type::IfcSpatialStructureElement)) {
IfcSpatialStructureElement* structure = (IfcSpatialStructureElement*) product;
IfcProduct::list::ptr elements = get_related
@@ -176,7 +178,7 @@ void descend(IfcProduct* product, ptree& tree) {
for (IfcObjectDefinition::list::it it = structures->begin(); it != structures->end(); ++it) {
IfcObjectDefinition* ob = *it;
if (ob->is(Type::IfcSpatialStructureElement)) {
if (ob->declaration().is(Type::IfcSpatialStructureElement)) {
descend((IfcProduct*)ob, child);
} else {
descend(ob, child);
@@ -189,7 +191,7 @@ void descend(IfcProduct* product, ptree& tree) {
for (IfcPropertySetDefinition::list::it it = property_sets->begin(); it != property_sets->end(); ++it) {
IfcPropertySetDefinition* pset = *it;
if (pset->is(Type::IfcPropertySet)) {
if (pset->declaration().is(Type::IfcPropertySet)) {
format_entity_instance(pset, child, true);
}
}
@@ -212,7 +214,7 @@ void descend(IfcProject* project, ptree& tree) {
for (IfcObjectDefinition::list::it it = structures->begin(); it != structures->end(); ++it) {
IfcObjectDefinition* ob = *it;
if (ob->is(Type::IfcSpatialStructureElement)) {
if (ob->declaration().is(Type::IfcSpatialStructureElement)) {
descend((IfcProduct*)ob, child);
} else {
descend(ob, child);
@@ -224,7 +226,7 @@ void descend(IfcProject* project, ptree& tree) {
void format_properties(IfcProperty::list::ptr properties, ptree& node) {
for (IfcProperty::list::it it = properties->begin(); it != properties->end(); ++it) {
IfcProperty* p = *it;
if (p->is(Type::IfcComplexProperty)) {
if (p->declaration().is(Type::IfcComplexProperty)) {
IfcComplexProperty* complex = (IfcComplexProperty*) p;
format_properties(complex->HasProperties(), node);
} else {
+28 -15
View File
@@ -115,7 +115,7 @@ actions = {
'general_aggregation_types' : "lambda t: AggregationType(t)",
'select_type' : "lambda t: SelectType(t)",
'binary_type' : "lambda t: BinaryType(t)",
'subtype_declaration' : "lambda t: SubtypeExpression(t)",
'subtype_declaration' : "lambda t: SubTypeExpression(t)",
'derive_clause' : "lambda t: AttributeList('derive', t)",
'derived_attr' : "lambda t: DerivedAttribute(t)",
'inverse_clause' : "lambda t: AttributeList('inverse', t)",
@@ -158,32 +158,45 @@ for id in to_emit:
stmt = "Suppress%s" % stmt
statements.append("%s << %s" % (id, stmt))
print ("""import sys
from pyparsing import *
from nodes import *
print ("""import os
import sys
import pickle
%s
cache_file = sys.argv[1] + ".cache.dat"
if os.path.exists(cache_file):
with open(cache_file, "rb") as f:
mapping = pickle.load(f)
else:
from pyparsing import *
from nodes import *
import schema
import mapping
%s
syntax.ignore("--" + restOfLine)
syntax.ignore(Regex(r"\((?:\*(?:[^*]*\*+)+?\))"))
ast = syntax.parseFile(sys.argv[1])
schema = schema.Schema(ast)
mapping = mapping.Mapping(schema)
import schema
import mapping
with open(cache_file, "wb") as f:
pickle.dump(mapping, f, protocol=0)
import header
import enum_header
import implementation
import latebound_header
import latebound_implementation
syntax.ignore("--" + restOfLine)
syntax.ignore(Regex(r"\((?:\*(?:[^*]*\*+)+?\))"))
ast = syntax.parseFile(sys.argv[1])
schema = schema.Schema(ast)
mapping = mapping.Mapping(schema)
import schema_class
header.Header(mapping).emit()
enum_header.EnumHeader(mapping).emit()
implementation.Implementation(mapping).emit()
latebound_header.LateBoundHeader(mapping).emit()
latebound_implementation.LateBoundImplementation(mapping).emit()
schema_class.SchemaClass(mapping).emit()
sys.stdout.write(schema.name)
"""%('\n'.join(statements)))
sys.stdout.write(mapping.schema.name)
"""%('\n '.join(statements)))
+3 -2
View File
@@ -26,9 +26,10 @@ class Base(object):
import platform
if tuple(map(int, platform.python_version_tuple())) < (2, 8):
from io import open as unicode_open
unicode_type = unicode
else:
unicode_open = open
unicode = lambda x, *args, **kwargs: x
unicode_type = lambda x, *args, **kwargs: x
f = unicode_open(self.file_name, 'w', encoding='utf-8')
f.write(unicode(repr(self), encoding='utf-8', errors='ignore'))
f.write(unicode_type(repr(self), encoding='utf-8', errors='ignore'))
f.close()
+5 -3
View File
@@ -31,6 +31,8 @@ import re
import os
import csv
from builtins import open
try: from html.entities import entitydefs
except: from htmlentitydefs import entitydefs
@@ -45,17 +47,17 @@ regices = list(zip([re.compile(s,re.M) for s in [r'<[\w\n=" \-/\.;_\t:%#,\?\(\)]
definition_files = ['DocEntity.csv', 'DocEnumeration.csv', 'DocDefined.csv', 'DocSelect.csv']
definition_files = map(make_absolute, definition_files)
for fn in definition_files:
with open(fn) as f:
with open(fn, encoding='utf-8', errors='ignore') as f:
for oid, name, desc in csv.reader(f, delimiter=';', quotechar='"'):
name_to_oid[name] = oid
oid_to_name[oid] = name
oid_to_desc[oid] = desc
with open(make_absolute('DocEntityAttributes.csv')) as f:
with open(make_absolute('DocEntityAttributes.csv'), encoding='utf-8', errors='ignore') as f:
for pid, x, oid in csv.reader(f, delimiter=';', quotechar='"'):
oid_to_pid[oid] = pid
with open(make_absolute('DocAttribute.csv')) as f:
with open(make_absolute('DocAttribute.csv'), encoding='utf-8', errors='ignore') as f:
for oid, name, desc in csv.reader(f, delimiter=';', quotechar='"'):
pid = oid_to_pid[oid]
pname = oid_to_name[pid]
+1 -1
View File
@@ -22,7 +22,7 @@ import codegen
class EnumHeader(codegen.Base):
def __init__(self, mapping):
enumerable_types = sorted(set([name for name, type in mapping.schema.types.items()] + [name for name, type in mapping.schema.entities.items()]))
enumerable_types = sorted(set([name for name, type in mapping.schema.types.items()] + [name for name, type in mapping.schema.entities.items()]), key=lambda s: s.lower())
self.str = templates.enum_header % {
'schema_name_upper' : mapping.schema.name.upper(),
+11 -6
View File
@@ -159,7 +159,7 @@ class Implementation(codegen.Base):
schema_entity_statements += [templates.schema_entity_stmt%locals() for name, type in mapping.schema.simpletypes.items()]
schema_entity_statements += [templates.schema_entity_stmt%locals() for name, type in mapping.schema.entities.items()]
enumerable_types = sorted(set([name for name, type in mapping.schema.types.items()] + [name for name, type in mapping.schema.entities.items()]))
enumerable_types = sorted(set([name for name, type in mapping.schema.types.items()] + [name for name, type in mapping.schema.entities.items()]), key=lambda s: s.lower())
max_len = max(map(len, enumerable_types))
type_name_strings = catc(map(stringify, enumerable_types))
string_map_statements = [templates.string_map_statement % {
@@ -205,16 +205,20 @@ class Implementation(codegen.Base):
simple_type_impl.append(templates.simpletype_impl_comment % {'name': class_name})
simple_type_impl.extend(map(compose, map(lambda x: (class_name, attr_type, superclass, "(IfcAbstractEntity*)0")+x, (
('getArgumentType', templates.const_function, 'IfcUtil::ArgumentType', ('unsigned int i',), templates.simpletype_impl_argument_type ),
('getArgument', templates.const_function, 'Argument*', ('unsigned int i',), templates.simpletype_impl_argument ),
('is', templates.const_function, 'bool', ('Type::Enum v',), simpletype_impl_is ),
('type', templates.const_function, 'Type::Enum', (), templates.simpletype_impl_type ),
#('getArgumentType', templates.const_function, 'IfcUtil::ArgumentType', ('unsigned int i',), templates.simpletype_impl_argument_type ),
#('getArgument', templates.const_function, 'Argument*', ('unsigned int i',), templates.simpletype_impl_argument ),
#('is', templates.const_function, 'bool', ('Type::Enum v',), simpletype_impl_is ),
#('type', templates.const_function, 'Type::Enum', (), templates.simpletype_impl_type ),
('Class', templates.function, 'Type::Enum', (), templates.simpletype_impl_class ),
('declaration', templates.const_function, 'const IfcParse::type_declaration&', (), templates.simpletype_impl_declaration ),
('', constructor, '', ('IfcAbstractEntity* e',), templates.simpletype_impl_explicit_constructor),
('', constructor, '', ("%s v" % type_str,), simpletype_impl_constructor ),
('', templates.cast_function, type_str, (), simpletype_impl_cast )
))))
simple_type_impl.append('')
external_definitions = ["extern entity* %s_type;" % n for n in mapping.schema.entities.keys() ] + \
["extern type_declaration* %s_type;" % n for n in mapping.schema.simpletypes.keys()]
self.str = templates.implementation % {
'schema_name_upper' : mapping.schema.name.upper(),
@@ -227,7 +231,8 @@ class Implementation(codegen.Base):
'simple_type_statement' : simple_type_statements,
'parent_type_statements' : catnl(parent_type_statements),
'entity_implementations' : catnl(entity_implementations),
'simple_type_impl' : catnl(simple_type_impl)
'simple_type_impl' : catnl(simple_type_impl),
'external_definitions' : catnl(external_definitions)
}
self.schema_name = mapping.schema.name.capitalize()
+5 -5
View File
@@ -27,7 +27,7 @@ class Mapping:
express_to_cpp_typemapping = {
'boolean' : 'bool',
'logical' : 'bool',
'logical' : 'boost::logic::tribool',
'integer' : 'int',
'real' : 'double',
'number' : 'double',
@@ -36,9 +36,9 @@ class Mapping:
}
supported_argument_types = set([
'INT', 'BOOL', 'DOUBLE', 'STRING', 'BINARY', 'ENUMERATION', 'ENTITY_INSTANCE',
'AGGREGATE_OF_INT', 'AGGREGATE_OF_DOUBLE', 'AGGREGATE_OF_STRING', 'AGGREGATE_OF_BINARY', 'AGGREGATE_OF_ENTITY_INSTANCE',
'AGGREGATE_OF_AGGREGATE_OF_INT', 'AGGREGATE_OF_AGGREGATE_OF_DOUBLE', 'AGGREGATE_OF_AGGREGATE_OF_ENTITY_INSTANCE',
'INT', 'BOOL', 'TRIBOOL', 'DOUBLE', 'STRING', 'BINARY', 'ENUMERATION', 'ENTITY_INSTANCE',
'AGGREGATE_OF_INT', 'AGGREGATE_OF_BOOL', 'AGGREGATE_OF_TRIBOOL', 'AGGREGATE_OF_DOUBLE', 'AGGREGATE_OF_STRING', 'AGGREGATE_OF_BINARY', 'AGGREGATE_OF_ENTITY_INSTANCE',
'AGGREGATE_OF_AGGREGATE_OF_INT', 'AGGREGATE_OF_AGGREGATE_OF_BOOL', 'AGGREGATE_OF_AGGREGATE_OF_TRIBOOL', 'AGGREGATE_OF_AGGREGATE_OF_DOUBLE', 'AGGREGATE_OF_AGGREGATE_OF_ENTITY_INSTANCE',
])
def __init__(self, schema):
@@ -103,7 +103,7 @@ class Mapping:
raise ValueError("Unable to map type %r for attribute %r" % (type, attr))
ty = _make_argument_type(attr.type if hasattr(attr, 'type') else attr)
if ty not in self.supported_argument_types:
print("Attribute %r mapped as 'unknown'" % (attr), file=sys.stderr)
print("Attribute %r (%s) mapped as 'unknown'" % (attr, ty), file=sys.stderr)
ty = 'UNKNOWN'
return "IfcUtil::Argument_%s" % ty
+16 -6
View File
@@ -44,15 +44,17 @@ class TypeDeclaration(Node):
class EntityDeclaration(Node):
name = property(lambda self: self.tokens[1])
attributes = property(lambda self: self.tokens_of_type(ExplicitAttribute))
abstract = property(lambda self: self.single_token_of_type(SuperTypeExpression) is not None and \
self.single_token_of_type(SuperTypeExpression).abstract)
def init(self):
assert self.tokens[0] == 'entity'
s = self.single_token_of_type(SubtypeExpression)
s = self.single_token_of_type(SubTypeExpression)
self.inverse = self.single_token_of_type(AttributeList, 'type', 'inverse')
self.derive = self.single_token_of_type(AttributeList, 'type', 'derive')
self.supertypes = s.types if s else []
def __repr__(self):
builder = ""
builder += "Entity(%s)" % (self.name)
builder += "%sEntity(%s)" % ("Abstract " if self.abstract else "", self.name)
if len(self.supertypes):
builder += "\n Supertypes: %s"%(",".join(self.supertypes))
if len(self.attributes):
@@ -106,12 +108,20 @@ class SelectType(Node):
class SubSuperTypeExpression(Node):
type = property(lambda self: self.tokens[0])
types = property(lambda self: self.tokens[3::2])
abstract = False
def init(self):
assert self.type == self.class_type
if self.tokens[0] == 'abstract':
self.tokens = self.tokens[1:]
self.abstract = True
assert self.type == self.type_relationship
class SubtypeExpression(SubSuperTypeExpression):
class_type = 'subtype'
class SubTypeExpression(SubSuperTypeExpression):
type_relationship = 'subtype'
class SuperTypeExpression(SubSuperTypeExpression):
type_relationship = 'supertype'
class AttributeList(Node):
@@ -127,7 +137,7 @@ class AttributeList(Node):
class InverseAttribute(Node):
name = property(lambda self: self.tokens[0])
type = property(lambda self: self.tokens[2])
type = property(lambda self: None if len(self.tokens) == 6 else self.tokens[2])
bounds = property(lambda self: None if len(self.tokens) == 6 else self.tokens[3])
entity = property(lambda self: self.tokens[-4])
attribute = property(lambda self: self.tokens[-2])
+215
View File
@@ -0,0 +1,215 @@
###############################################################################
# #
# This file is part of IfcOpenShell. #
# #
# IfcOpenShell is free software: you can redistribute it and/or modify #
# it under the terms of the Lesser GNU General Public License as published by #
# the Free Software Foundation, either version 3.0 of the License, or #
# (at your option) any later version. #
# #
# IfcOpenShell is distributed in the hope that it will be useful, #
# but WITHOUT ANY WARRANTY; without even the implied warranty of #
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
# Lesser GNU General Public License for more details. #
# #
# You should have received a copy of the Lesser GNU General Public License #
# along with this program. If not, see <http://www.gnu.org/licenses/>. #
# #
###############################################################################
import operator
import nodes
import codegen
import templates
class SchemaClass(codegen.Base):
def __init__(self, mapping):
class UnmetDependenciesException(Exception): pass
schema_name = mapping.schema.name
declared_types = []
def get_declared_type(type, emitted_names=None):
if isinstance(type, nodes.AggregationType):
aggr_type = type.aggregate_type
make_bound = lambda b: -1 if b == '?' else int(b)
bound1, bound2 = map(make_bound, (type.bounds.lower, type.bounds.upper))
decl_type = get_declared_type(type.type, emitted_names)
return "new aggregation_type(aggregation_type::%(aggr_type)s_type, %(bound1)d, %(bound2)d, %(decl_type)s)" % locals()
elif isinstance(type, nodes.BinaryType):
return "new simple_type(simple_type::binary_type)"
elif isinstance(type, str):
if mapping.schema.is_type(type) or mapping.schema.is_entity(type):
if emitted_names is None or type in emitted_types:
return "new named_type(%s_type)" % type
else:
raise UnmetDependenciesException(type)
else:
return "new simple_type(simple_type::%s_type)" % type
def find_inverse_name_and_index(entity_name, attribute_name):
attributes_per_subtype = []
while True:
entity = mapping.schema.entities[entity_name]
attr_names = list(map(operator.attrgetter('name'), entity.attributes))
if len(attr_names):
attributes_per_subtype.append((entity_name, attr_names))
if len(entity.supertypes) != 1: break
entity_name = entity.supertypes[0]
index = 0
for et, attrs in attributes_per_subtype[::-1]:
try: return et, attrs.index(attribute_name)
except: pass
self.schema_name = mapping.schema.name.capitalize()
statements = ['',
'#include "../ifcparse/IfcSchema.h"',
'',
'using namespace IfcParse;'
'']
collections_by_type = (('entity', mapping.schema.entities ),
('type_declaration', mapping.schema.simpletypes ),
('select_type', mapping.schema.selects ),
('enumeration_type', mapping.schema.enumerations))
for cpp_type, collection in collections_by_type:
for name in collection.keys():
statements.append('%(cpp_type)s* %(name)s_type = 0;' % locals())
statements.append("""
#if defined(__clang__)
#elif defined(__GNUC__) || defined(__GNUG__)
#pragma GCC push_options
#pragma GCC optimize ("O0")
#elif defined(_MSC_VER)
#pragma optimize("", off)
#endif
""")
statements.append('schema_definition* populate_schema() {')
emitted_types = set()
# while len(emitted_types) < len(set(mapping.schema.simpletypes.keys()) - {"IfcPropertySetDefinitionSet"}):
while len(emitted_types) < len(set(mapping.schema.simpletypes.keys()) - {"IfcPropertySetDefinitionSet"}):
for name, type in mapping.schema.simpletypes.items():
if name in emitted_types: continue
# No support for types refering to entities :(
if name == "IfcPropertySetDefinitionSet": continue
try:
declared_type = get_declared_type(type, emitted_types)
except UnmetDependenciesException:
continue
statements.append(' %(name)s_type = new type_declaration(IfcSchema::Type::%(name)s, %(declared_type)s);' % locals())
emitted_types.add(name)
declared_types.append('%(name)s_type' % locals())
for name, enum in mapping.schema.enumerations.items():
statements.append(' {')
statements.append(' std::vector<std::string> items; items.reserve(%d);' % len(enum.values))
statements.extend(map(lambda v: ' items.push_back("%s");' % v, sorted(enum.values)))
statements.append(' %(name)s_type = new enumeration_type(IfcSchema::Type::%(name)s, items);' % locals())
statements.append(' }')
declared_types.append('%(name)s_type' % locals())
emitted_entities = set()
while len(emitted_entities) < len(mapping.schema.entities):
for name, type in mapping.schema.entities.items():
if name in emitted_entities: continue
if len(type.supertypes) == 0 or set(type.supertypes) < emitted_entities:
supertype = '0' if len(type.supertypes) == 0 else '%s_type' % type.supertypes[0]
statements.append(' %(name)s_type = new entity(IfcSchema::Type::%(name)s, %(supertype)s);' % locals())
emitted_entities.add(name)
declared_types.append('%(name)s_type' % locals())
emmited = emitted_types | emitted_entities | set(mapping.schema.enumerations.keys())
emitted_selects = set()
while len(emitted_selects) < len(mapping.schema.selects):
for name, type in mapping.schema.selects.items():
if name in emitted_selects: continue
type_values = sorted(set(type.values) - {"IfcPropertySetDefinitionSet"})
if set(type_values) < emmited:
statements.append(' {')
statements.append(' std::vector<const declaration*> items; items.reserve(%d);' % len(type_values))
statements.extend(map(lambda v: ' items.push_back(%s_type);' % v, sorted(type_values)))
statements.append(' %(name)s_type = new select_type(IfcSchema::Type::%(name)s, items);' % locals())
statements.append(' }')
emitted_selects.add(name)
emmited.add(name)
declared_types.append('%(name)s_type' % locals())
num_declarations = len(declared_types)
for name, type in mapping.schema.entities.items():
derived = set(mapping.derived_in_supertype(type))
attribute_names = list(map(operator.attrgetter('name'), mapping.arguments(type)))
statements.append(' {')
statements.append(' std::vector<const entity::attribute*> attributes; attributes.reserve(%d);' % len(type.attributes))
for attr in type.attributes:
attr_name, optional = attr.name, str(attr.optional).lower()
decl_type = get_declared_type(attr.type)
statements.append(' attributes.push_back(new entity::attribute("%(attr_name)s", %(decl_type)s, %(optional)s));' % locals())
statements.append(' std::vector<bool> derived; derived.reserve(%d);' % len(attribute_names))
statements.append(' ' + " ".join(map(lambda b: 'derived.push_back(%s);' % str(b in derived).lower(), attribute_names)))
statements.append(' %(name)s_type->set_attributes(attributes, derived);' % locals())
statements.append(' }')
for name, type in mapping.schema.entities.items():
if type.inverse:
statements.append(' {')
statements.append(' std::vector<const entity::inverse_attribute*> attributes; attributes.reserve(%d);' % len(type.inverse.elements))
for attr in type.inverse.elements:
if attr.bounds:
make_bound = lambda b: -1 if b == '?' else int(b)
bound1, bound2 = map(make_bound, (attr.bounds.lower, attr.bounds.upper))
else:
bound1, bound2 = -1, -1
attr_name, aggr_type, entity_ref = attr.name, attr.type, attr.entity
if aggr_type is None: aggr_type = 'unspecified'
attribute_entity, attribute_entity_index = find_inverse_name_and_index(entity_ref, attr.attribute)
statements.append(' attributes.push_back(new entity::inverse_attribute("%(attr_name)s", entity::inverse_attribute::%(aggr_type)s_type, %(bound1)d, %(bound2)d, %(entity_ref)s_type, %(attribute_entity)s_type->attributes()[%(attribute_entity_index)d]));' % locals())
statements.append(' %(name)s_type->set_inverse_attributes(attributes);' % locals())
statements.append(' }')
statements.append('')
statements.append(' std::vector<const declaration*> declarations; declarations.reserve(%(num_declarations)d);' % locals())
for type_name in declared_types:
statements.append(' declarations.push_back(%(type_name)s);' % locals())
statements.append(' return new schema_definition("%(schema_name)s", declarations, true);' % locals())
statements.extend(('}',''))
statements.append("""
#if defined(__clang__)
#elif defined(__GNUC__) || defined(__GNUG__)
#pragma GCC pop_options
#elif defined(_MSC_VER)
#pragma optimize("", on)
#endif
""")
statements.extend(('const schema_definition& get_schema() {',
'',
' static const schema_definition* s = populate_schema();',
' return *s;',
'}','',''))
self.str = "\n".join(statements)
self.file_name = '%s-schema.cpp'%self.schema_name
def __repr__(self):
return self.str
+44 -38
View File
@@ -27,9 +27,12 @@ header = """
#include <boost/optional.hpp>
#include "../ifcparse/IfcUtil.h"
#include "../ifcparse/IfcSchema.h"
#include "../ifcparse/IfcException.h"
#include "../ifcparse/%(schema_name)senum.h"
const IfcParse::schema_definition& get_schema();
#ifdef _MSC_VER
#pragma warning(push)
#pragma warning(disable : 4100)
@@ -111,6 +114,7 @@ namespace Type {
implementation= """
#include "../ifcparse/%(schema_name)s.h"
#include "../ifcparse/IfcSchema.h"
#include "../ifcparse/IfcException.h"
#include "../ifcparse/IfcWrite.h"
#include "../ifcparse/IfcWritableEntity.h"
@@ -121,6 +125,9 @@ using namespace %(schema_name)s;
using namespace IfcParse;
using namespace IfcWrite;
// External definitions
%(external_definitions)s
IfcUtil::IfcBaseClass* %(schema_name)s::SchemaEntity(IfcAbstractEntity* e) {
switch(e->type()) {
%(schema_entity_statements)s
@@ -189,9 +196,12 @@ enumeration_descriptor_map_t enumeration_descriptor_map;
inverse_map_t inverse_map;
derived_map_t derived_map;
#ifdef _MSC_VER
# pragma optimize( "", off )
#if defined(__clang__)
#elif defined(__GNUC__) || defined(__GNUG__)
#pragma GCC push_options
#pragma GCC optimize ("O0")
#elif defined(_MSC_VER)
#pragma optimize("", off)
#endif
void InitDescriptorMap() {
@@ -203,10 +213,6 @@ void InitDescriptorMap() {
%(enumeration_descriptors)s
}
#ifdef _MSC_VER
# pragma optimize( "", on )
#endif
void InitInverseMap() {
%(inverse_implementations)s
}
@@ -215,6 +221,13 @@ void InitDerivedMap() {
%(derived_field_statements)s
}
#if defined(__clang__)
#elif defined(__GNUC__) || defined(__GNUG__)
#pragma GCC pop_options
#elif defined(_MSC_VER)
#pragma optimize("", on)
#endif
int Type::GetAttributeIndex(Enum t, const std::string& a) {
if (entity_descriptor_map.empty()) ::InitDescriptorMap();
std::map<Type::Enum,IfcEntityDescriptor*>::const_iterator i = entity_descriptor_map.find(t);
@@ -336,10 +349,7 @@ derived_field_statement_attrs = 'idxs.insert(%d); '
simpletype = """%(documentation)s
class %(name)s : public %(superclass)s {
public:
virtual IfcUtil::ArgumentType getArgumentType(unsigned int i) const;
virtual Argument* getArgument(unsigned int i) const;
bool is(Type::Enum v) const;
Type::Enum type() const;
virtual const IfcParse::type_declaration& declaration() const;
static Type::Enum Class();
explicit %(name)s (IfcAbstractEntity* e);
%(name)s (%(type)s v);
@@ -349,16 +359,17 @@ public:
simpletype_impl_comment = "// Function implementations for %(name)s"
simpletype_impl_argument_type = "if (i == 0) { return %(attr_type)s; } else { throw IfcParse::IfcAttributeOutOfRangeException(\"Argument index out of range\"); }"
simpletype_impl_argument = "return entity->getArgument(i);"
simpletype_impl_argument = "return data_->getArgument(i);"
simpletype_impl_is_with_supertype = "return v == Type::%(class_name)s || %(superclass)s::is(v);"
simpletype_impl_is_without_supertype = "return v == %(class_name)s::Class();"
simpletype_impl_type = "return Type::%(class_name)s;"
simpletype_impl_class = "return Type::%(class_name)s;"
simpletype_impl_explicit_constructor = "entity = e;"
simpletype_impl_constructor = "IfcWritableEntity* e = new IfcWritableEntity(Type::%(class_name)s); e->setArgument(0, v); entity = e;"
simpletype_impl_constructor_templated = "IfcWritableEntity* e = new IfcWritableEntity(Type::%(class_name)s); e->setArgument(0, v->generalize()); entity = e;"
simpletype_impl_cast = "return *entity->getArgument(0);"
simpletype_impl_cast_templated = "IfcEntityList::ptr es = *entity->getArgument(0); return es->as<%(underlying_type)s>();"
simpletype_impl_explicit_constructor = "data_ = e;"
simpletype_impl_constructor = "IfcWritableEntity* e = new IfcWritableEntity(Type::%(class_name)s); e->setArgument(0, v); data_ = e;"
simpletype_impl_constructor_templated = "IfcWritableEntity* e = new IfcWritableEntity(Type::%(class_name)s); e->setArgument(0, v->generalize()); data_ = e;"
simpletype_impl_cast = "return *data_->getArgument(0);"
simpletype_impl_cast_templated = "IfcEntityList::ptr es = *data_->getArgument(0); return es->as<%(underlying_type)s>();"
simpletype_impl_declaration = "return *%(class_name)s_type;"
select = """%(documentation)s
typedef IfcUtil::IfcBaseClass %(name)s;
@@ -375,13 +386,7 @@ const char* ToString(%(name)s v);
entity = """%(documentation)s
class %(name)s %(superclass)s{
public:
%(attributes)s virtual unsigned int getArgumentCount() const { return %(argument_count)d; }
virtual IfcUtil::ArgumentType getArgumentType(unsigned int i) const {%(argument_type_function_body)s}
virtual Type::Enum getArgumentEntity(unsigned int i) const {%(argument_entity_function_body)s}
virtual const char* getArgumentName(unsigned int i) const {%(argument_name_function_body)s}
virtual Argument* getArgument(unsigned int i) const { return entity->getArgument(i); }
%(inverse)s bool is(Type::Enum v) const;
Type::Enum type() const;
%(attributes)s %(inverse)s virtual const IfcParse::entity& declaration() const;
static Type::Enum Class();
%(name)s (IfcAbstractEntity* e);
%(name)s (%(constructor_arguments)s);
@@ -403,11 +408,12 @@ const char* %(name)s::ToString(%(name)s v) {
"""
entity_implementation = """// Function implementations for %(name)s
%(attributes)s%(inverse)sbool %(name)s::is(Type::Enum v) const { return v == Type::%(name)s%(parent_type_test)s; }
Type::Enum %(name)s::type() const { return Type::%(name)s; }
%(attributes)s
%(inverse)s
const IfcParse::entity& %(name)s::declaration() const { return *%(name)s_type; }
Type::Enum %(name)s::Class() { return Type::%(name)s; }
%(name)s::%(name)s(IfcAbstractEntity* e) : %(superclass)s { if (!e) return; if (!e->is(Type::%(name)s)) throw IfcException("Unable to find find keyword in schema"); entity = e; }
%(name)s::%(name)s(%(constructor_arguments)s) : %(superclass)s { IfcWritableEntity* e = new IfcWritableEntity(Class());%(constructor_implementation)s entity = e; EntityBuffer::Add(this); }
%(name)s::%(name)s(IfcAbstractEntity* e) : %(superclass)s { if (!e) return; if (!e->is(Type::%(name)s)) throw IfcException("Unable to find find keyword in schema"); data_ = e; }
%(name)s::%(name)s(%(constructor_arguments)s) : %(superclass)s { IfcWritableEntity* e = new IfcWritableEntity(Class());%(constructor_implementation)s data_ = e; EntityBuffer::Add(this); }
"""
optional_attribute_description = "/// Whether the optional attribute %s is defined for this %s"
@@ -433,19 +439,19 @@ parent_type_stmt = ' if(v==%(name)s%(padding)s) { return %(parent)s; }'
parent_type_test = " || %s::is(v)"
optional_attr_stmt = "return !entity->getArgument(%(index)d)->isNull();"
optional_attr_stmt = "return !data_->getArgument(%(index)d)->isNull();"
get_attr_stmt = "return *entity->getArgument(%(index)d);"
get_attr_stmt_enum = "return %(type)s::FromString(*entity->getArgument(%(index)d));"
get_attr_stmt_entity = "return (%(type)s)((IfcUtil::IfcBaseClass*)(*entity->getArgument(%(index)d)));"
get_attr_stmt_array = "IfcEntityList::ptr es = *entity->getArgument(%(index)d); return es->as<%(list_instance_type)s>();"
get_attr_stmt_nested_array = "IfcEntityListList::ptr es = *entity->getArgument(%(index)d); return es->as<%(list_instance_type)s>();"
get_attr_stmt = "return *data_->getArgument(%(index)d);"
get_attr_stmt_enum = "return %(type)s::FromString(*data_->getArgument(%(index)d));"
get_attr_stmt_entity = "return (%(type)s)((IfcUtil::IfcBaseClass*)(*data_->getArgument(%(index)d)));"
get_attr_stmt_array = "IfcEntityList::ptr es = *data_->getArgument(%(index)d); return es->as<%(list_instance_type)s>();"
get_attr_stmt_nested_array = "IfcEntityListList::ptr es = *data_->getArgument(%(index)d); return es->as<%(list_instance_type)s>();"
get_inverse = "return entity->getInverse(Type::%(type)s, %(index)d)->as<%(type)s>();"
get_inverse = "return data_->getInverse(Type::%(type)s, %(index)d)->as<%(type)s>();"
set_attr_stmt = "if ( ! entity->isWritable() ) { entity = new IfcWritableEntity(entity); } ((IfcWritableEntity*)entity)->setArgument(%(index)d,v);"
set_attr_stmt_enum = "if ( ! entity->isWritable() ) { entity = new IfcWritableEntity(entity); } ((IfcWritableEntity*)entity)->setArgument(%(index)d,v,%(type)s::ToString(v));"
set_attr_stmt_array = "if ( ! entity->isWritable() ) { entity = new IfcWritableEntity(entity); } ((IfcWritableEntity*)entity)->setArgument(%(index)d,v->generalize());"
set_attr_stmt = "if ( ! data_->isWritable() ) { data_ = new IfcWritableEntity(data_); } ((IfcWritableEntity*)data_)->setArgument(%(index)d,v);"
set_attr_stmt_enum = "if ( ! data_->isWritable() ) { data_ = new IfcWritableEntity(data_); } ((IfcWritableEntity*)data_)->setArgument(%(index)d,v,%(type)s::ToString(v));"
set_attr_stmt_array = "if ( ! data_->isWritable() ) { data_ = new IfcWritableEntity(data_); } ((IfcWritableEntity*)data_)->setArgument(%(index)d,v->generalize());"
constructor_stmt = " e->setArgument(%(index)d,(%(name)s));"
constructor_stmt_enum = " e->setArgument(%(index)d,%(name)s,%(type)s::ToString(%(name)s));"
+5 -5
View File
@@ -46,9 +46,9 @@
#include "../ifcgeom/IfcRepresentationShapeItem.h"
#include "../ifcgeom/IfcGeomShapeType.h"
#define IN_CACHE(T,E,t,e) std::map<int,t>::const_iterator it = cache.T.find(E->entity->id());\
#define IN_CACHE(T,E,t,e) std::map<int,t>::const_iterator it = cache.T.find(E->data().id());\
if ( it != cache.T.end() ) { e = it->second; return true; }
#define CACHE(T,E,e) cache.T[E->entity->id()] = e;
#define CACHE(T,E,e) cache.T[E->data().id()] = e;
namespace IfcGeom {
@@ -148,7 +148,7 @@ public:
#ifdef USE_IFC4
IfcEntityList::ptr style_assignments = (*jt)->Styles();
for (IfcEntityList::it kt = style_assignments->begin(); kt != style_assignments->end(); ++kt) {
if (!(*kt)->is(IfcSchema::Type::IfcPresentationStyleAssignment)) {
if (!(*kt)->declaration().is(IfcSchema::Type::IfcPresentationStyleAssignment)) {
continue;
}
IfcSchema::IfcPresentationStyleAssignment* style_assignment = (IfcSchema::IfcPresentationStyleAssignment*) *kt;
@@ -160,12 +160,12 @@ public:
IfcEntityList::ptr styles = style_assignment->Styles();
for (IfcEntityList::it lt = styles->begin(); lt != styles->end(); ++lt) {
IfcUtil::IfcBaseClass* style = *lt;
if (style->is(IfcSchema::Type::IfcSurfaceStyle)) {
if (style->declaration().is(IfcSchema::Type::IfcSurfaceStyle)) {
IfcSchema::IfcSurfaceStyle* surface_style = (IfcSchema::IfcSurfaceStyle*) style;
if (surface_style->Side() != IfcSchema::IfcSurfaceSide::IfcSurfaceSide_NEGATIVE) {
IfcEntityList::ptr styles_elements = surface_style->Styles();
for (IfcEntityList::it mt = styles_elements->begin(); mt != styles_elements->end(); ++mt) {
if ((*mt)->is(T::Class())) {
if ((*mt)->declaration().is(T::Class())) {
return std::make_pair(surface_style, (T*) *mt);
}
}
+4 -4
View File
@@ -86,12 +86,12 @@
bool IfcGeom::Kernel::convert(const IfcSchema::IfcCircle* l, Handle(Geom_Curve)& curve) {
const double r = l->Radius() * getValue(GV_LENGTH_UNIT);
if ( r < ALMOST_ZERO ) {
Logger::Message(Logger::LOG_ERROR, "Radius not greater than zero for:", l->entity);
Logger::Message(Logger::LOG_ERROR, "Radius not greater than zero for:", l);
return false;
}
gp_Trsf trsf;
IfcSchema::IfcAxis2Placement* placement = l->Position();
if (placement->is(IfcSchema::Type::IfcAxis2Placement3D)) {
if (placement->declaration().is(IfcSchema::Type::IfcAxis2Placement3D)) {
IfcGeom::Kernel::convert((IfcSchema::IfcAxis2Placement3D*)placement,trsf);
} else {
gp_Trsf2d trsf2d;
@@ -106,7 +106,7 @@ bool IfcGeom::Kernel::convert(const IfcSchema::IfcEllipse* l, Handle(Geom_Curve)
double x = l->SemiAxis1() * getValue(GV_LENGTH_UNIT);
double y = l->SemiAxis2() * getValue(GV_LENGTH_UNIT);
if (x < ALMOST_ZERO || y < ALMOST_ZERO) {
Logger::Message(Logger::LOG_ERROR, "Radius not greater than zero for:", l->entity);
Logger::Message(Logger::LOG_ERROR, "Radius not greater than zero for:", l);
return false;
}
// Open Cascade does not allow ellipses of which the minor radius
@@ -116,7 +116,7 @@ bool IfcGeom::Kernel::convert(const IfcSchema::IfcEllipse* l, Handle(Geom_Curve)
const bool rotated = y > x;
gp_Trsf trsf;
IfcSchema::IfcAxis2Placement* placement = l->Position();
if (placement->is(IfcSchema::Type::IfcAxis2Placement3D)) {
if (placement->declaration().is(IfcSchema::Type::IfcAxis2Placement3D)) {
convert((IfcSchema::IfcAxis2Placement3D*)placement,trsf);
} else {
gp_Trsf2d trsf2d;
+23 -23
View File
@@ -103,7 +103,7 @@ bool IfcGeom::Kernel::convert(const IfcSchema::IfcFace* l, TopoDS_Shape& face) {
IfcSchema::IfcFaceBound::list::ptr bounds = l->Bounds();
Handle(Geom_Surface) face_surface;
const bool is_face_surface = l->is(IfcSchema::Type::IfcFaceSurface);
const bool is_face_surface = l->declaration().is(IfcSchema::Type::IfcFaceSurface);
if (is_face_surface) {
IfcSchema::IfcFaceSurface* fs = (IfcSchema::IfcFaceSurface*) l;
@@ -125,7 +125,7 @@ bool IfcGeom::Kernel::convert(const IfcSchema::IfcFace* l, TopoDS_Shape& face) {
for (IfcSchema::IfcFaceBound::list::it it = bounds->begin(); it != bounds->end(); ++it) {
IfcSchema::IfcFaceBound* bound = *it;
if (bound->is(IfcSchema::Type::IfcFaceOuterBound)) num_outer_bounds ++;
if (bound->declaration().is(IfcSchema::Type::IfcFaceOuterBound)) num_outer_bounds ++;
}
// The number of outer bounds should be one according to the schema. Also Open Cascade
@@ -133,7 +133,7 @@ bool IfcGeom::Kernel::convert(const IfcSchema::IfcFace* l, TopoDS_Shape& face) {
// the face will still be processed as long as there are no holes. A compound of faces
// is returned in that case.
if (num_bounds > 1 && num_outer_bounds > 1 && num_bounds != num_outer_bounds) {
Logger::Message(Logger::LOG_ERROR, "Invalid configuration of boundaries for:", l->entity);
Logger::Message(Logger::LOG_ERROR, "Invalid configuration of boundaries for:", l);
return false;
}
@@ -157,7 +157,7 @@ bool IfcGeom::Kernel::convert(const IfcSchema::IfcFace* l, TopoDS_Shape& face) {
bool same_sense = bound->Orientation();
const bool is_interior =
!bound->is(IfcSchema::Type::IfcFaceOuterBound) &&
!bound->declaration().is(IfcSchema::Type::IfcFaceOuterBound) &&
(num_bounds > 1) &&
(num_outer_bounds < num_bounds);
@@ -166,14 +166,14 @@ bool IfcGeom::Kernel::convert(const IfcSchema::IfcFace* l, TopoDS_Shape& face) {
TopoDS_Wire wire;
if (!convert_wire(loop, wire)) {
Logger::Message(Logger::LOG_ERROR, "Failed to process face boundary loop", loop->entity);
Logger::Message(Logger::LOG_ERROR, "Failed to process face boundary loop", loop);
delete mf;
return false;
}
/*
The approach below does not result in a significant speed-up
if (loop->is(IfcSchema::Type::IfcPolyLoop) && processed == 0 && face_surface.IsNull()) {
if (loop->declaration().is(IfcSchema::Type::IfcPolyLoop) && processed == 0 && face_surface.IsNull()) {
IfcSchema::IfcPolyLoop* polyloop = (IfcSchema::IfcPolyLoop*) loop;
IfcSchema::IfcCartesianPoint::list::ptr points = polyloop->Polygon();
@@ -264,7 +264,7 @@ bool IfcGeom::Kernel::convert(const IfcSchema::IfcFace* l, TopoDS_Shape& face) {
success = true;
}
} else {
Logger::Message(Logger::LOG_ERROR, "Failed to process face boundary", bound->entity);
Logger::Message(Logger::LOG_ERROR, "Failed to process face boundary", bound);
delete mf;
return false;
}
@@ -331,7 +331,7 @@ bool IfcGeom::Kernel::convert(const IfcSchema::IfcRectangleProfileDef* l, TopoDS
const double y = l->YDim() / 2.0f * getValue(GV_LENGTH_UNIT);
if ( x < ALMOST_ZERO || y < ALMOST_ZERO ) {
Logger::Message(Logger::LOG_NOTICE,"Skipping zero sized profile:",l->entity);
Logger::Message(Logger::LOG_NOTICE, "Skipping zero sized profile:", l);
return false;
}
@@ -347,7 +347,7 @@ bool IfcGeom::Kernel::convert(const IfcSchema::IfcRoundedRectangleProfileDef* l,
const double r = l->RoundingRadius() * getValue(GV_LENGTH_UNIT);
if ( x < ALMOST_ZERO || y < ALMOST_ZERO || r < ALMOST_ZERO ) {
Logger::Message(Logger::LOG_NOTICE,"Skipping zero sized profile:",l->entity);
Logger::Message(Logger::LOG_NOTICE, "Skipping zero sized profile:", l);
return false;
}
@@ -371,7 +371,7 @@ bool IfcGeom::Kernel::convert(const IfcSchema::IfcRectangleHollowProfileDef* l,
const double r2 = fr2 ? l->InnerFilletRadius() * getValue(GV_LENGTH_UNIT) : 0.;
if ( x < ALMOST_ZERO || y < ALMOST_ZERO ) {
Logger::Message(Logger::LOG_NOTICE,"Skipping zero sized profile:",l->entity);
Logger::Message(Logger::LOG_NOTICE, "Skipping zero sized profile:", l);
return false;
}
@@ -413,7 +413,7 @@ bool IfcGeom::Kernel::convert(const IfcSchema::IfcTrapeziumProfileDef* l, TopoDS
const double y = l->YDim() / 2.0f * getValue(GV_LENGTH_UNIT);
if ( x1 < ALMOST_ZERO || w < ALMOST_ZERO || y < ALMOST_ZERO ) {
Logger::Message(Logger::LOG_NOTICE,"Skipping zero sized profile:",l->entity);
Logger::Message(Logger::LOG_NOTICE, "Skipping zero sized profile:", l);
return false;
}
@@ -438,7 +438,7 @@ bool IfcGeom::Kernel::convert(const IfcSchema::IfcIShapeProfileDef* l, TopoDS_Sh
bool doFillet2 = doFillet1;
double x2 = x1, dy2 = dy1, f2 = f1;
if (l->is(IfcSchema::Type::IfcAsymmetricIShapeProfileDef)) {
if (l->declaration().is(IfcSchema::Type::IfcAsymmetricIShapeProfileDef)) {
IfcSchema::IfcAsymmetricIShapeProfileDef* assym = (IfcSchema::IfcAsymmetricIShapeProfileDef*) l;
x2 = assym->TopFlangeWidth() / 2. * getValue(GV_LENGTH_UNIT);
doFillet2 = assym->hasTopFlangeFilletRadius();
@@ -451,7 +451,7 @@ bool IfcGeom::Kernel::convert(const IfcSchema::IfcIShapeProfileDef* l, TopoDS_Sh
}
if ( x1 < ALMOST_ZERO || x2 < ALMOST_ZERO || y < ALMOST_ZERO || d1 < ALMOST_ZERO || dy1 < ALMOST_ZERO || dy2 < ALMOST_ZERO ) {
Logger::Message(Logger::LOG_NOTICE,"Skipping zero sized profile:",l->entity);
Logger::Message(Logger::LOG_NOTICE, "Skipping zero sized profile:", l);
return false;
}
@@ -484,7 +484,7 @@ bool IfcGeom::Kernel::convert(const IfcSchema::IfcZShapeProfileDef* l, TopoDS_Sh
}
if ( x == 0.0f || y == 0.0f || dx == 0.0f || dy == 0.0f ) {
Logger::Message(Logger::LOG_NOTICE,"Skipping zero sized profile:",l->entity);
Logger::Message(Logger::LOG_NOTICE, "Skipping zero sized profile:", l);
return false;
}
@@ -511,7 +511,7 @@ bool IfcGeom::Kernel::convert(const IfcSchema::IfcCShapeProfileDef* l, TopoDS_Sh
}
if ( x < ALMOST_ZERO || y < ALMOST_ZERO || d1 < ALMOST_ZERO || d2 < ALMOST_ZERO ) {
Logger::Message(Logger::LOG_NOTICE,"Skipping zero sized profile:",l->entity);
Logger::Message(Logger::LOG_NOTICE, "Skipping zero sized profile:", l);
return false;
}
@@ -544,7 +544,7 @@ bool IfcGeom::Kernel::convert(const IfcSchema::IfcLShapeProfileDef* l, TopoDS_Sh
}
if ( x < ALMOST_ZERO || y < ALMOST_ZERO || d < ALMOST_ZERO ) {
Logger::Message(Logger::LOG_NOTICE,"Skipping zero sized profile:",l->entity);
Logger::Message(Logger::LOG_NOTICE, "Skipping zero sized profile:", l);
return false;
}
@@ -576,7 +576,7 @@ bool IfcGeom::Kernel::convert(const IfcSchema::IfcLShapeProfileDef* l, TopoDS_Sh
const double det = a1*b2 - a2*b1;
if (ALMOST_THE_SAME(det, 0.)) {
Logger::Message(Logger::LOG_NOTICE, "Legs do not intersect for:",l->entity);
Logger::Message(Logger::LOG_NOTICE, "Legs do not intersect for:", l);
return false;
}
@@ -622,7 +622,7 @@ bool IfcGeom::Kernel::convert(const IfcSchema::IfcUShapeProfileDef* l, TopoDS_Sh
}
if ( x < ALMOST_ZERO || y < ALMOST_ZERO || d1 < ALMOST_ZERO || d2 < ALMOST_ZERO ) {
Logger::Message(Logger::LOG_NOTICE,"Skipping zero sized profile:",l->entity);
Logger::Message(Logger::LOG_NOTICE, "Skipping zero sized profile:", l);
return false;
}
@@ -650,7 +650,7 @@ bool IfcGeom::Kernel::convert(const IfcSchema::IfcTShapeProfileDef* l, TopoDS_Sh
const double webSlope = hasWebSlope ? (l->WebSlope() * getValue(GV_PLANEANGLE_UNIT)) : 0.;
if ( x < ALMOST_ZERO || y < ALMOST_ZERO || d1 < ALMOST_ZERO || d2 < ALMOST_ZERO ) {
Logger::Message(Logger::LOG_NOTICE,"Skipping zero sized profile:",l->entity);
Logger::Message(Logger::LOG_NOTICE, "Skipping zero sized profile:", l);
return false;
}
@@ -698,7 +698,7 @@ bool IfcGeom::Kernel::convert(const IfcSchema::IfcTShapeProfileDef* l, TopoDS_Sh
const double det = a1*b2 - a2*b1;
if (ALMOST_THE_SAME(det, 0.)) {
Logger::Message(Logger::LOG_NOTICE, "Web and flange do not intersect for:",l->entity);
Logger::Message(Logger::LOG_NOTICE, "Web and flange do not intersect for:", l);
return false;
}
@@ -721,7 +721,7 @@ bool IfcGeom::Kernel::convert(const IfcSchema::IfcTShapeProfileDef* l, TopoDS_Sh
bool IfcGeom::Kernel::convert(const IfcSchema::IfcCircleProfileDef* l, TopoDS_Shape& face) {
const double r = l->Radius() * getValue(GV_LENGTH_UNIT);
if ( r == 0.0f ) {
Logger::Message(Logger::LOG_NOTICE,"Skipping zero sized profile:",l->entity);
Logger::Message(Logger::LOG_NOTICE, "Skipping zero sized profile:", l);
return false;
}
@@ -745,7 +745,7 @@ bool IfcGeom::Kernel::convert(const IfcSchema::IfcCircleHollowProfileDef* l, Top
const double t = l->WallThickness() * getValue(GV_LENGTH_UNIT);
if ( r == 0.0f || t == 0.0f ) {
Logger::Message(Logger::LOG_NOTICE,"Skipping zero sized profile:",l->entity);
Logger::Message(Logger::LOG_NOTICE, "Skipping zero sized profile:", l);
return false;
}
@@ -774,7 +774,7 @@ bool IfcGeom::Kernel::convert(const IfcSchema::IfcEllipseProfileDef* l, TopoDS_S
double ry = l->SemiAxis2() * getValue(GV_LENGTH_UNIT);
if ( rx < ALMOST_ZERO || ry < ALMOST_ZERO ) {
Logger::Message(Logger::LOG_NOTICE,"Skipping zero sized profile:",l->entity);
Logger::Message(Logger::LOG_NOTICE, "Skipping zero sized profile:", l);
return false;
}
+32 -32
View File
@@ -171,7 +171,7 @@ bool IfcGeom::Kernel::convert_openings(const IfcSchema::IfcProduct* entity, cons
for ( IfcSchema::IfcRelVoidsElement::list::it it = openings->begin(); it != openings->end(); ++ it ) {
IfcSchema::IfcRelVoidsElement* v = *it;
IfcSchema::IfcFeatureElementSubtraction* fes = v->RelatedOpeningElement();
if ( fes->is(IfcSchema::Type::IfcOpeningElement) ) {
if ( fes->declaration().is(IfcSchema::Type::IfcOpeningElement) ) {
if (!fes->hasRepresentation()) continue;
// Convert the IfcRepresentation of the IfcOpeningElement
@@ -207,7 +207,7 @@ bool IfcGeom::Kernel::convert_openings(const IfcSchema::IfcProduct* entity, cons
const gp_GTrsf& entity_shape_gtrsf = it3->Placement();
TopoDS_Shape entity_shape;
if ( entity_shape_gtrsf.Form() == gp_Other ) {
Logger::Message(Logger::LOG_WARNING,"Applying non uniform transformation to:",entity->entity);
Logger::Message(Logger::LOG_WARNING, "Applying non uniform transformation to:", entity);
entity_shape = BRepBuilderAPI_GTransform(entity_shape_unlocated,entity_shape_gtrsf,true).Shape();
} else {
entity_shape = entity_shape_unlocated.Moved(entity_shape_gtrsf.Trsf());
@@ -219,7 +219,7 @@ bool IfcGeom::Kernel::convert_openings(const IfcSchema::IfcProduct* entity, cons
const TopoDS_Shape& opening_shape_unlocated = ensure_fit_for_subtraction(it4->Shape(),opening_shape_solid);
const gp_GTrsf& opening_shape_gtrsf = it4->Placement();
if ( opening_shape_gtrsf.Form() == gp_Other ) {
Logger::Message(Logger::LOG_WARNING,"Applying non uniform transformation to opening of:",entity->entity);
Logger::Message(Logger::LOG_WARNING, "Applying non uniform transformation to opening of:", entity);
}
const TopoDS_Shape& opening_shape = opening_shape_gtrsf.Form() == gp_Other
? BRepBuilderAPI_GTransform(opening_shape_unlocated,opening_shape_gtrsf,true).Shape()
@@ -229,7 +229,7 @@ bool IfcGeom::Kernel::convert_openings(const IfcSchema::IfcProduct* entity, cons
if ( Logger::Verbosity() >= Logger::LOG_WARNING ) {
opening_volume = shape_volume(opening_shape);
if ( opening_volume <= ALMOST_ZERO )
Logger::Message(Logger::LOG_WARNING,"Empty opening for:",entity->entity);
Logger::Message(Logger::LOG_WARNING, "Empty opening for:", entity);
}
if (entity_shape.ShapeType() == TopAbs_COMPSOLID) {
@@ -276,7 +276,7 @@ bool IfcGeom::Kernel::convert_openings(const IfcSchema::IfcProduct* entity, cons
// Add the original in case subtraction fails
builder.Add(compound, exp.Current());
} else {
Logger::Message(Logger::LOG_ERROR,"Failed to process subtraction:",entity->entity);
Logger::Message(Logger::LOG_ERROR, "Failed to process subtraction:", entity);
}
}
@@ -305,7 +305,7 @@ bool IfcGeom::Kernel::convert_openings(const IfcSchema::IfcProduct* entity, cons
fix.Perform();
brep_cut_result = fix.Shape();
} catch (...) {
Logger::Message(Logger::LOG_WARNING, "Shape healing failed on opening subtraction result", entity->entity);
Logger::Message(Logger::LOG_WARNING, "Shape healing failed on opening subtraction result", entity);
}
BRepCheck_Analyzer analyser(brep_cut_result);
@@ -316,13 +316,13 @@ bool IfcGeom::Kernel::convert_openings(const IfcSchema::IfcProduct* entity, cons
const double volume_after_subtraction = shape_volume(entity_shape);
double original_shape_volume = shape_volume(entity_shape);
if ( ALMOST_THE_SAME(original_shape_volume,volume_after_subtraction) )
Logger::Message(Logger::LOG_WARNING,"Subtraction yields unchanged volume:",entity->entity);
Logger::Message(Logger::LOG_WARNING, "Subtraction yields unchanged volume:", entity);
}
} else {
Logger::Message(Logger::LOG_ERROR,"Invalid result from subtraction:",entity->entity);
Logger::Message(Logger::LOG_ERROR, "Invalid result from subtraction:", entity);
}
} else {
Logger::Message(Logger::LOG_ERROR,"Failed to process subtraction:",entity->entity);
Logger::Message(Logger::LOG_ERROR, "Failed to process subtraction:", entity);
}
}
@@ -345,7 +345,7 @@ bool IfcGeom::Kernel::convert_openings_fast(const IfcSchema::IfcProduct* entity,
for ( IfcSchema::IfcRelVoidsElement::list::it it = openings->begin(); it != openings->end(); ++ it ) {
IfcSchema::IfcRelVoidsElement* v = *it;
IfcSchema::IfcFeatureElementSubtraction* fes = v->RelatedOpeningElement();
if ( fes->is(IfcSchema::Type::IfcOpeningElement) ) {
if ( fes->declaration().is(IfcSchema::Type::IfcOpeningElement) ) {
if (!fes->hasRepresentation()) continue;
// Convert the IfcRepresentation of the IfcOpeningElement
@@ -387,7 +387,7 @@ bool IfcGeom::Kernel::convert_openings_fast(const IfcSchema::IfcProduct* entity,
const gp_GTrsf& entity_shape_gtrsf = it3->Placement();
TopoDS_Shape entity_shape;
if ( entity_shape_gtrsf.Form() == gp_Other ) {
Logger::Message(Logger::LOG_WARNING,"Applying non uniform transformation to:",entity->entity);
Logger::Message(Logger::LOG_WARNING, "Applying non uniform transformation to:", entity);
entity_shape = BRepBuilderAPI_GTransform(entity_shape_unlocated,entity_shape_gtrsf,true).Shape();
} else {
entity_shape = entity_shape_unlocated.Moved(entity_shape_gtrsf.Trsf());
@@ -409,7 +409,7 @@ bool IfcGeom::Kernel::convert_openings_fast(const IfcSchema::IfcProduct* entity,
// Apparently processing the boolean operation failed or resulted in an invalid result
// in which case the original shape without the subtractions is returned instead
// we try convert the openings in the original way, one by one.
Logger::Message(Logger::LOG_WARNING,"Subtracting combined openings compound failed:",entity->entity);
Logger::Message(Logger::LOG_WARNING, "Subtracting combined openings compound failed:", entity);
return false;
}
@@ -1063,7 +1063,7 @@ IfcGeom::BRepElement<P>* IfcGeom::Kernel::create_brep_for_representation_and_pro
try {
IfcSchema::IfcObjectDefinition* parent_object = get_decomposing_entity(product);
if (parent_object) {
parent_id = parent_object->entity->id();
parent_id = parent_object->data().id();
}
} catch (...) {}
@@ -1078,12 +1078,12 @@ IfcGeom::BRepElement<P>* IfcGeom::Kernel::create_brep_for_representation_and_pro
// Does the IfcElement have any IfcOpenings?
// Note that openings for IfcOpeningElements are not processed
IfcSchema::IfcRelVoidsElement::list::ptr openings;
if ( product->is(IfcSchema::Type::IfcElement) && !product->is(IfcSchema::Type::IfcOpeningElement) ) {
if ( product->declaration().is(IfcSchema::Type::IfcElement) && !product->declaration().is(IfcSchema::Type::IfcOpeningElement) ) {
IfcSchema::IfcElement* element = (IfcSchema::IfcElement*)product;
openings = element->HasOpenings();
}
// Is the IfcElement a decomposition of an IfcElement with any IfcOpeningElements?
if ( product->is(IfcSchema::Type::IfcBuildingElementPart ) ) {
if ( product->declaration().is(IfcSchema::Type::IfcBuildingElementPart ) ) {
IfcSchema::IfcBuildingElementPart* part = (IfcSchema::IfcBuildingElementPart*)product;
#ifdef USE_IFC4
IfcSchema::IfcRelAggregates::list::ptr decomposes = part->Decomposes();
@@ -1093,14 +1093,14 @@ IfcGeom::BRepElement<P>* IfcGeom::Kernel::create_brep_for_representation_and_pro
for ( IfcSchema::IfcRelDecomposes::list::it it = decomposes->begin(); it != decomposes->end(); ++ it ) {
#endif
IfcSchema::IfcObjectDefinition* obdef = (*it)->RelatingObject();
if ( obdef->is(IfcSchema::Type::IfcElement) ) {
if ( obdef->declaration().is(IfcSchema::Type::IfcElement) ) {
IfcSchema::IfcElement* element = (IfcSchema::IfcElement*)obdef;
openings->push(element->HasOpenings());
}
}
}
const std::string product_type = IfcSchema::Type::ToString(product->type());
const std::string product_type = IfcSchema::Type::ToString(product->declaration().type());
ElementSettings element_settings(settings, getValue(GV_LENGTH_UNIT), product_type);
if ( !settings.disable_opening_subtractions() && openings && openings->size() ) {
@@ -1121,7 +1121,7 @@ IfcGeom::BRepElement<P>* IfcGeom::Kernel::create_brep_for_representation_and_pro
convert_openings(product,openings,shapes,trsf,opened_shapes);
}
} catch(...) {
Logger::Message(Logger::LOG_ERROR,"Error processing openings for:",product->entity);
Logger::Message(Logger::LOG_ERROR, "Error processing openings for:", product);
}
if ( settings.use_world_coords() ) {
for ( IfcGeom::IfcRepresentationShapeItems::iterator it = opened_shapes.begin(); it != opened_shapes.end(); ++ it ) {
@@ -1129,15 +1129,15 @@ IfcGeom::BRepElement<P>* IfcGeom::Kernel::create_brep_for_representation_and_pro
}
trsf = gp_Trsf();
}
shape = new IfcGeom::Representation::BRep(element_settings, representation->entity->id(), opened_shapes);
shape = new IfcGeom::Representation::BRep(element_settings, representation->data().id(), opened_shapes);
} else if ( settings.use_world_coords() ) {
for ( IfcGeom::IfcRepresentationShapeItems::iterator it = shapes.begin(); it != shapes.end(); ++ it ) {
it->prepend(trsf);
}
trsf = gp_Trsf();
shape = new IfcGeom::Representation::BRep(element_settings, representation->entity->id(), shapes);
shape = new IfcGeom::Representation::BRep(element_settings, representation->data().id(), shapes);
} else {
shape = new IfcGeom::Representation::BRep(element_settings, representation->entity->id(), shapes);
shape = new IfcGeom::Representation::BRep(element_settings, representation->data().id(), shapes);
}
std::string context_string = "";
@@ -1148,7 +1148,7 @@ IfcGeom::BRepElement<P>* IfcGeom::Kernel::create_brep_for_representation_and_pro
}
return new BRepElement<P>(
product->entity->id(),
product->data().id(),
parent_id,
name,
product_type,
@@ -1163,14 +1163,14 @@ IfcSchema::IfcObjectDefinition* IfcGeom::Kernel::get_decomposing_entity(IfcSchem
IfcSchema::IfcObjectDefinition* parent = 0;
// In case of an opening element, parent to the RelatingBuildingElement
if ( product->is(IfcSchema::Type::IfcOpeningElement ) ) {
if ( product->declaration().is(IfcSchema::Type::IfcOpeningElement ) ) {
IfcSchema::IfcOpeningElement* opening = (IfcSchema::IfcOpeningElement*)product;
IfcSchema::IfcRelVoidsElement::list::ptr voids = opening->VoidsElements();
if ( voids->size() ) {
IfcSchema::IfcRelVoidsElement* ifc_void = *voids->begin();
parent = ifc_void->RelatingBuildingElement();
}
} else if ( product->is(IfcSchema::Type::IfcElement ) ) {
} else if ( product->declaration().is(IfcSchema::Type::IfcElement ) ) {
IfcSchema::IfcElement* element = (IfcSchema::IfcElement*)product;
IfcSchema::IfcRelFillsElement::list::ptr fills = element->FillsVoids();
// Incase of a RelatedBuildingElement parent to the opening element
@@ -1193,13 +1193,13 @@ IfcSchema::IfcObjectDefinition* IfcGeom::Kernel::get_decomposing_entity(IfcSchem
}
// Parent decompositions to the RelatingObject
if (!parent) {
IfcEntityList::ptr parents = product->entity->getInverse(IfcSchema::Type::IfcRelAggregates, -1);
parents->push(product->entity->getInverse(IfcSchema::Type::IfcRelNests, -1));
IfcEntityList::ptr parents = product->data().getInverse(IfcSchema::Type::IfcRelAggregates, -1);
parents->push(product->data().getInverse(IfcSchema::Type::IfcRelNests, -1));
for ( IfcEntityList::it it = parents->begin(); it != parents->end(); ++ it ) {
IfcSchema::IfcRelDecomposes* decompose = (IfcSchema::IfcRelDecomposes*)*it;
IfcSchema::IfcObjectDefinition* ifc_objectdef;
#ifdef USE_IFC4
if (decompose->is(IfcSchema::Type::IfcRelAggregates)) {
if (decompose->declaration().is(IfcSchema::Type::IfcRelAggregates)) {
ifc_objectdef = ((IfcSchema::IfcRelAggregates*)decompose)->RelatingObject();
} else {
continue;
@@ -1235,19 +1235,19 @@ std::pair<std::string, double> IfcGeom::Kernel::initializeUnits(IfcSchema::IfcUn
IfcUtil::IfcBaseClass* base = *it;
IfcSchema::IfcSIUnit* unit = 0;
double value = 1.f;
if ( base->is(IfcSchema::Type::IfcConversionBasedUnit) ) {
if ( base->declaration().is(IfcSchema::Type::IfcConversionBasedUnit) ) {
IfcSchema::IfcConversionBasedUnit* u = (IfcSchema::IfcConversionBasedUnit*)base;
current_unit_name = u->Name();
IfcSchema::IfcMeasureWithUnit* u2 = u->ConversionFactor();
IfcSchema::IfcUnit* u3 = u2->UnitComponent();
if ( u3->is(IfcSchema::Type::IfcSIUnit) ) {
if ( u3->declaration().is(IfcSchema::Type::IfcSIUnit) ) {
unit = (IfcSchema::IfcSIUnit*) u3;
}
IfcSchema::IfcValue* v = u2->ValueComponent();
// Quick hack to get the numeric value from an IfcValue:
const double f = *v->entity->getArgument(0);
const double f = *v->data().getArgument(0);
value *= f;
} else if ( base->is(IfcSchema::Type::IfcSIUnit) ) {
} else if ( base->declaration().is(IfcSchema::Type::IfcSIUnit) ) {
unit = (IfcSchema::IfcSIUnit*)base;
}
if ( unit ) {
@@ -1285,7 +1285,7 @@ const IfcSchema::IfcRepresentationItem* IfcGeom::Kernel::find_item_carrying_styl
return item;
}
while (item->is(IfcSchema::Type::IfcBooleanClippingResult)) {
while (item->declaration().is(IfcSchema::Type::IfcBooleanClippingResult)) {
// All instantiations of IfcBooleanOperand (type of FirstOperand) are subtypes of
// IfcGeometricRepresentationItem
item = (IfcSchema::IfcGeometricRepresentationItem*) ((IfcSchema::IfcBooleanClippingResult*) item)->FirstOperand();
+4 -4
View File
@@ -282,21 +282,21 @@ bool IfcGeom::Kernel::convert(const IfcSchema::IfcAxis2Placement2D* l, gp_Trsf2d
bool IfcGeom::Kernel::convert(const IfcSchema::IfcObjectPlacement* l, gp_Trsf& trsf) {
IN_CACHE(IfcObjectPlacement,l,gp_Trsf,trsf)
if ( ! l->is(IfcSchema::Type::IfcLocalPlacement) ) {
Logger::Message(Logger::LOG_ERROR, "Unsupported IfcObjectPlacement:", l->entity);
if ( ! l->declaration().is(IfcSchema::Type::IfcLocalPlacement) ) {
Logger::Message(Logger::LOG_ERROR, "Unsupported IfcObjectPlacement:", l);
return false;
}
IfcSchema::IfcLocalPlacement* current = (IfcSchema::IfcLocalPlacement*)l;
for (;;) {
gp_Trsf trsf2;
IfcSchema::IfcAxis2Placement* relplacement = current->RelativePlacement();
if ( relplacement->is(IfcSchema::Type::IfcAxis2Placement3D) ) {
if ( relplacement->declaration().is(IfcSchema::Type::IfcAxis2Placement3D) ) {
IfcGeom::Kernel::convert((IfcSchema::IfcAxis2Placement3D*)relplacement,trsf2);
trsf.PreMultiply(trsf2);
}
if ( current->hasPlacementRelTo() ) {
IfcSchema::IfcObjectPlacement* relto = current->PlacementRelTo();
if ( relto->is(IfcSchema::Type::IfcLocalPlacement) )
if ( relto->declaration().is(IfcSchema::Type::IfcLocalPlacement) )
current = (IfcSchema::IfcLocalPlacement*)current->PlacementRelTo();
else break;
} else break;
+8 -8
View File
@@ -175,7 +175,7 @@ namespace IfcGeom {
for (it = contexts->begin(); it != contexts->end(); ++it) {
IfcSchema::IfcGeometricRepresentationContext* context = *it;
if (context->is(IfcSchema::Type::IfcGeometricRepresentationSubContext)) {
if (context->declaration().is(IfcSchema::Type::IfcGeometricRepresentationSubContext)) {
// Continue, as the list of subcontexts will be considered
// by the parent's context inverse attributes.
continue;
@@ -196,7 +196,7 @@ namespace IfcGeom {
if (filtered_contexts->size() == 0) {
for (it = contexts->begin(); it != contexts->end(); ++it) {
IfcSchema::IfcGeometricRepresentationContext* context = *it;
if (!context->is(IfcSchema::Type::IfcGeometricRepresentationSubContext)) {
if (!context->declaration().is(IfcSchema::Type::IfcGeometricRepresentationSubContext)) {
filtered_contexts->push(context);
}
}
@@ -307,7 +307,7 @@ namespace IfcGeom {
IfcSchema::IfcProduct::list::ptr unfiltered_products(new IfcSchema::IfcProduct::list);
for ( IfcSchema::IfcProductRepresentation::list::it it = prodreps->begin(); it != prodreps->end(); ++it ) {
if ( (*it)->is(IfcSchema::Type::IfcProductDefinitionShape) ) {
if ( (*it)->declaration().is(IfcSchema::Type::IfcProductDefinitionShape) ) {
IfcSchema::IfcProductDefinitionShape* pds = (IfcSchema::IfcProductDefinitionShape*)*it;
unfiltered_products->push(pds->ShapeOfProduct());
} else {
@@ -317,7 +317,7 @@ namespace IfcGeom {
// IfcProductRepresentation also lacks the INVERSE relation to IfcProduct
// Let's find the IfcProducts that reference the IfcProductRepresentation anyway
unfiltered_products->push((*it)->entity->getInverse(IfcSchema::Type::IfcProduct, -1)->as<IfcSchema::IfcProduct>());
unfiltered_products->push((*it)->data().getInverse(IfcSchema::Type::IfcProduct, -1)->as<IfcSchema::IfcProduct>());
}
// Filter the products based on the set of entities being included or excluded for
@@ -325,7 +325,7 @@ namespace IfcGeom {
for ( IfcSchema::IfcProduct::list::it jt = unfiltered_products->begin(); jt != unfiltered_products->end(); ++jt ) {
bool found = false;
for (std::set<IfcSchema::Type::Enum>::const_iterator kt = entities_to_include_or_exclude.begin(); kt != entities_to_include_or_exclude.end(); ++kt) {
if ((*jt)->is(*kt)) {
if ((*jt)->declaration().is(*kt)) {
found = true;
break;
}
@@ -398,8 +398,8 @@ namespace IfcGeom {
try {
const IfcUtil::IfcBaseClass* ifc_entity = ifc_file->entityById(id);
instance_type = IfcSchema::Type::ToString(ifc_entity->type());
if ( ifc_entity->is(IfcSchema::Type::IfcProduct) ) {
instance_type = IfcSchema::Type::ToString(ifc_entity->declaration().type());
if ( ifc_entity->declaration().is(IfcSchema::Type::IfcProduct) ) {
IfcSchema::IfcProduct* ifc_product = (IfcSchema::IfcProduct*)ifc_entity;
product_guid = ifc_product->GlobalId();
@@ -409,7 +409,7 @@ namespace IfcGeom {
try {
IfcSchema::IfcObjectDefinition* parent_object = kernel.get_decomposing_entity(ifc_product);
if (parent_object) {
parent_id = parent_object->entity->id();
parent_id = parent_object->data().id();
}
} catch (...) {}
+6 -6
View File
@@ -41,9 +41,9 @@ bool process_colour(IfcSchema::IfcNormalisedRatioMeasure* factor, double* rgb) {
bool process_colour(IfcSchema::IfcColourOrFactor* colour_or_factor, double* rgb) {
if (colour_or_factor == 0) {
return false;
} else if (colour_or_factor->is(IfcSchema::Type::IfcColourRgb)) {
} else if (colour_or_factor->declaration().is(IfcSchema::Type::IfcColourRgb)) {
return process_colour(static_cast<IfcSchema::IfcColourRgb*>(colour_or_factor), rgb);
} else if (colour_or_factor->is(IfcSchema::Type::IfcNormalisedRatioMeasure)) {
} else if (colour_or_factor->declaration().is(IfcSchema::Type::IfcNormalisedRatioMeasure)) {
return process_colour(static_cast<IfcSchema::IfcNormalisedRatioMeasure*>(colour_or_factor), rgb);
} else {
return false;
@@ -55,7 +55,7 @@ const IfcGeom::SurfaceStyle* IfcGeom::Kernel::get_style(const IfcSchema::IfcRepr
if (shading_styles.second == 0) {
return 0;
}
int surface_style_id = shading_styles.first->entity->id();
int surface_style_id = shading_styles.first->data().id();
std::map<int,SurfaceStyle>::const_iterator it = cache.Style.find(surface_style_id);
if (it != cache.Style.end()) {
return &(it->second);
@@ -70,7 +70,7 @@ const IfcGeom::SurfaceStyle* IfcGeom::Kernel::get_style(const IfcSchema::IfcRepr
if (process_colour(shading_styles.second->SurfaceColour(), rgb)) {
surface_style.Diffuse().reset(SurfaceStyle::ColorComponent(rgb[0], rgb[1], rgb[2]));
}
if (shading_styles.second->is(IfcSchema::Type::IfcSurfaceStyleRendering)) {
if (shading_styles.second->declaration().is(IfcSchema::Type::IfcSurfaceStyleRendering)) {
IfcSchema::IfcSurfaceStyleRendering* rendering_style = static_cast<IfcSchema::IfcSurfaceStyleRendering*>(shading_styles.second);
if (rendering_style->hasDiffuseColour() && process_colour(rendering_style->DiffuseColour(), rgb)) {
SurfaceStyle::ColorComponent diffuse = surface_style.Diffuse().get_value_or(SurfaceStyle::ColorComponent(1,1,1));
@@ -87,12 +87,12 @@ const IfcGeom::SurfaceStyle* IfcGeom::Kernel::get_style(const IfcSchema::IfcRepr
}
if (rendering_style->hasSpecularHighlight()) {
IfcSchema::IfcSpecularHighlightSelect* highlight = rendering_style->SpecularHighlight();
if (highlight->is(IfcSchema::Type::IfcSpecularRoughness)) {
if (highlight->declaration().is(IfcSchema::Type::IfcSpecularRoughness)) {
double roughness = *((IfcSchema::IfcSpecularRoughness*)highlight);
if (roughness >= 1e-9) {
surface_style.Specularity().reset(1.0 / roughness);
}
} else if (highlight->is(IfcSchema::Type::IfcSpecularExponent)) {
} else if (highlight->declaration().is(IfcSchema::Type::IfcSpecularExponent)) {
surface_style.Specularity().reset(*((IfcSchema::IfcSpecularExponent*)highlight));
}
}
+1 -3
View File
@@ -150,10 +150,8 @@ namespace IfcGeom {
try {
BRepMesh_IncrementalMesh(s, settings().deflection_tolerance());
} catch(...) {
// TODO: Catch outside
// Logger::Message(Logger::LOG_ERROR,"Failed to triangulate shape:",ifc_file->entityById(_id)->entity);
Logger::Message(Logger::LOG_ERROR,"Failed to triangulate shape");
Logger::Message(Logger::LOG_ERROR, "Failed to triangulate shape");
continue;
}
+35 -35
View File
@@ -103,7 +103,7 @@
bool IfcGeom::Kernel::convert(const IfcSchema::IfcExtrudedAreaSolid* l, TopoDS_Shape& shape) {
const double height = l->Depth() * getValue(GV_LENGTH_UNIT);
if (height < getValue(GV_PRECISION)) {
Logger::Message(Logger::LOG_ERROR, "Non-positive extrusion height encountered for:", l->entity);
Logger::Message(Logger::LOG_ERROR, "Non-positive extrusion height encountered for:", l);
return false;
}
@@ -237,8 +237,8 @@ bool IfcGeom::Kernel::convert(const IfcSchema::IfcFaceBasedSurfaceModel* l, IfcR
bool IfcGeom::Kernel::convert(const IfcSchema::IfcHalfSpaceSolid* l, TopoDS_Shape& shape) {
IfcSchema::IfcSurface* surface = l->BaseSurface();
if ( ! surface->is(IfcSchema::Type::IfcPlane) ) {
Logger::Message(Logger::LOG_ERROR, "Unsupported BaseSurface:", surface->entity);
if ( ! surface->declaration().is(IfcSchema::Type::IfcPlane) ) {
Logger::Message(Logger::LOG_ERROR, "Unsupported BaseSurface:", surface);
return false;
}
gp_Pln pln;
@@ -278,7 +278,7 @@ bool IfcGeom::Kernel::convert(const IfcSchema::IfcShellBasedSurfaceModel* l, Ifc
for( IfcEntityList::it it = shells->begin(); it != shells->end(); ++ it ) {
TopoDS_Shape s;
const SurfaceStyle* shell_style = 0;
if ((*it)->is(IfcSchema::Type::IfcRepresentationItem)) {
if ((*it)->declaration().is(IfcSchema::Type::IfcRepresentationItem)) {
shell_style = get_style((IfcSchema::IfcRepresentationItem*)*it);
}
if (convert_shape(*it,s)) {
@@ -295,7 +295,7 @@ bool IfcGeom::Kernel::convert(const IfcSchema::IfcBooleanResult* l, TopoDS_Shape
TopoDS_Wire boundary_wire;
IfcSchema::IfcBooleanOperand* operand1 = l->FirstOperand();
IfcSchema::IfcBooleanOperand* operand2 = l->SecondOperand();
bool is_halfspace = operand2->is(IfcSchema::Type::IfcHalfSpaceSolid);
bool is_halfspace = operand2->declaration().is(IfcSchema::Type::IfcHalfSpaceSolid);
if ( shape_type(operand1) == ST_SHAPELIST ) {
if (!(convert_shapes(operand1, items1) && flatten_shape_list(items1, s1, true))) {
@@ -308,13 +308,13 @@ bool IfcGeom::Kernel::convert(const IfcSchema::IfcBooleanResult* l, TopoDS_Shape
{ TopoDS_Solid temp_solid;
s1 = ensure_fit_for_subtraction(s1, temp_solid); }
} else {
Logger::Message(Logger::LOG_ERROR, "Invalid representation item for boolean operation", operand1->entity);
Logger::Message(Logger::LOG_ERROR, "Invalid representation item for boolean operation", operand1);
return false;
}
const double first_operand_volume = shape_volume(s1);
if ( first_operand_volume <= ALMOST_ZERO )
Logger::Message(Logger::LOG_WARNING,"Empty solid for:",l->FirstOperand()->entity);
Logger::Message(Logger::LOG_WARNING, "Empty solid for:", l->FirstOperand());
bool shape2_processed = false;
if ( shape_type(operand2) == ST_SHAPELIST ) {
@@ -326,19 +326,19 @@ bool IfcGeom::Kernel::convert(const IfcSchema::IfcBooleanResult* l, TopoDS_Shape
s2 = ensure_fit_for_subtraction(s2, temp_solid);
}
} else {
Logger::Message(Logger::LOG_ERROR, "Invalid representation item for boolean operation", operand2->entity);
Logger::Message(Logger::LOG_ERROR, "Invalid representation item for boolean operation", operand2);
}
if (!shape2_processed) {
shape = s1;
Logger::Message(Logger::LOG_ERROR,"Failed to convert SecondOperand of:",l->entity);
Logger::Message(Logger::LOG_ERROR, "Failed to convert SecondOperand of:", l);
return true;
}
if (!is_halfspace) {
const double second_operand_volume = shape_volume(s2);
if ( second_operand_volume <= ALMOST_ZERO )
Logger::Message(Logger::LOG_WARNING,"Empty solid for:",operand2->entity);
Logger::Message(Logger::LOG_WARNING, "Empty solid for:", operand2);
}
const IfcSchema::IfcBooleanOperator::IfcBooleanOperator op = l->Operator();
@@ -381,7 +381,7 @@ bool IfcGeom::Kernel::convert(const IfcSchema::IfcBooleanResult* l, TopoDS_Shape
fix.Perform();
result = fix.Shape();
} catch (...) {
Logger::Message(Logger::LOG_WARNING, "Shape healing failed on boolean result", l->entity);
Logger::Message(Logger::LOG_WARNING, "Shape healing failed on boolean result", l);
}
bool is_valid = BRepCheck_Analyzer(result).IsValid() != 0;
@@ -394,9 +394,9 @@ bool IfcGeom::Kernel::convert(const IfcSchema::IfcBooleanResult* l, TopoDS_Shape
if ( valid_cut ) {
const double volume_after_subtraction = shape_volume(shape);
if ( ALMOST_THE_SAME(first_operand_volume,volume_after_subtraction) )
Logger::Message(Logger::LOG_WARNING,"Subtraction yields unchanged volume:",l->entity);
Logger::Message(Logger::LOG_WARNING, "Subtraction yields unchanged volume:", l);
} else {
Logger::Message(Logger::LOG_ERROR,"Failed to process subtraction:",l->entity);
Logger::Message(Logger::LOG_ERROR, "Failed to process subtraction:", l);
shape = s1;
}
@@ -460,7 +460,7 @@ bool IfcGeom::Kernel::convert(const IfcSchema::IfcConnectedFaceSet* l, TopoDS_Sh
builder.Add(face);
facesAdded = true;
} else {
Logger::Message(Logger::LOG_WARNING,"Invalid face:",(*it)->entity);
Logger::Message(Logger::LOG_WARNING, "Invalid face:", *it);
}
}
if ( ! facesAdded ) return false;
@@ -482,7 +482,7 @@ bool IfcGeom::Kernel::convert(const IfcSchema::IfcConnectedFaceSet* l, TopoDS_Sh
}
} catch(...) {}
} else {
Logger::Message(Logger::LOG_WARNING,"Failed to sew faceset:",l->entity);
Logger::Message(Logger::LOG_WARNING, "Failed to sew faceset:", l);
}
}
if (!valid_shell) {
@@ -499,7 +499,7 @@ bool IfcGeom::Kernel::convert(const IfcSchema::IfcConnectedFaceSet* l, TopoDS_Sh
builder.Add(compound,face);
facesAdded = true;
} else {
Logger::Message(Logger::LOG_WARNING,"Invalid face:",(*it)->entity);
Logger::Message(Logger::LOG_WARNING, "Invalid face:", *it);
}
}
if ( ! facesAdded ) return false;
@@ -511,16 +511,16 @@ bool IfcGeom::Kernel::convert(const IfcSchema::IfcConnectedFaceSet* l, TopoDS_Sh
bool IfcGeom::Kernel::convert(const IfcSchema::IfcMappedItem* l, IfcRepresentationShapeItems& shapes) {
gp_GTrsf gtrsf;
IfcSchema::IfcCartesianTransformationOperator* transform = l->MappingTarget();
if ( transform->is(IfcSchema::Type::IfcCartesianTransformationOperator3DnonUniform) ) {
if ( transform->declaration().is(IfcSchema::Type::IfcCartesianTransformationOperator3DnonUniform) ) {
IfcGeom::Kernel::convert((IfcSchema::IfcCartesianTransformationOperator3DnonUniform*)transform,gtrsf);
} else if ( transform->is(IfcSchema::Type::IfcCartesianTransformationOperator2DnonUniform) ) {
Logger::Message(Logger::LOG_ERROR, "Unsupported MappingTarget:", transform->entity);
} else if ( transform->declaration().is(IfcSchema::Type::IfcCartesianTransformationOperator2DnonUniform) ) {
Logger::Message(Logger::LOG_ERROR, "Unsupported MappingTarget:", transform);
return false;
} else if ( transform->is(IfcSchema::Type::IfcCartesianTransformationOperator3D) ) {
} else if ( transform->declaration().is(IfcSchema::Type::IfcCartesianTransformationOperator3D) ) {
gp_Trsf trsf;
IfcGeom::Kernel::convert((IfcSchema::IfcCartesianTransformationOperator3D*)transform,trsf);
gtrsf = trsf;
} else if ( transform->is(IfcSchema::Type::IfcCartesianTransformationOperator2D) ) {
} else if ( transform->declaration().is(IfcSchema::Type::IfcCartesianTransformationOperator2D) ) {
gp_Trsf2d trsf_2d;
IfcGeom::Kernel::convert((IfcSchema::IfcCartesianTransformationOperator2D*)transform,trsf_2d);
gtrsf = (gp_Trsf) trsf_2d;
@@ -528,7 +528,7 @@ bool IfcGeom::Kernel::convert(const IfcSchema::IfcMappedItem* l, IfcRepresentati
IfcSchema::IfcRepresentationMap* map = l->MappingSource();
IfcSchema::IfcAxis2Placement* placement = map->MappingOrigin();
gp_Trsf trsf;
if (placement->is(IfcSchema::Type::IfcAxis2Placement3D)) {
if (placement->declaration().is(IfcSchema::Type::IfcAxis2Placement3D)) {
IfcGeom::Kernel::convert((IfcSchema::IfcAxis2Placement3D*)placement,trsf);
} else {
gp_Trsf2d trsf_2d;
@@ -586,11 +586,11 @@ bool IfcGeom::Kernel::convert(const IfcSchema::IfcGeometricSet* l, IfcRepresenta
if (convert_shape(element, s)) {
part_succes = true;
const IfcGeom::SurfaceStyle* style = 0;
if (element->is(IfcSchema::Type::IfcPoint)) {
if (element->declaration().is(IfcSchema::Type::IfcPoint)) {
style = get_style((IfcSchema::IfcPoint*) element);
} else if (element->is(IfcSchema::Type::IfcCurve)) {
} else if (element->declaration().is(IfcSchema::Type::IfcCurve)) {
style = get_style((IfcSchema::IfcCurve*) element);
} else if (element->is(IfcSchema::Type::IfcSurface)) {
} else if (element->declaration().is(IfcSchema::Type::IfcSurface)) {
style = get_style((IfcSchema::IfcSurface*) element);
}
shapes.push_back(IfcRepresentationShapeItem(s, style ? style : parent_style));
@@ -699,8 +699,8 @@ bool IfcGeom::Kernel::convert(const IfcSchema::IfcCurveBoundedPlane* l, TopoDS_S
}
bool IfcGeom::Kernel::convert(const IfcSchema::IfcRectangularTrimmedSurface* l, TopoDS_Shape& face) {
if (!l->BasisSurface()->is(IfcSchema::Type::IfcPlane)) {
Logger::Message(Logger::LOG_ERROR, "Unsupported BasisSurface:", l->BasisSurface()->entity);
if (!l->BasisSurface()->declaration().is(IfcSchema::Type::IfcPlane)) {
Logger::Message(Logger::LOG_ERROR, "Unsupported BasisSurface:", l->BasisSurface());
return false;
}
gp_Pln pln;
@@ -718,8 +718,8 @@ bool IfcGeom::Kernel::convert(const IfcSchema::IfcSurfaceCurveSweptAreaSolid* l,
TopoDS_Shape face;
TopoDS_Wire wire, section;
if (!l->ReferenceSurface()->is(IfcSchema::Type::IfcPlane)) {
Logger::Message(Logger::LOG_WARNING, "Reference surface not supported", l->ReferenceSurface()->entity);
if (!l->ReferenceSurface()->declaration().is(IfcSchema::Type::IfcPlane)) {
Logger::Message(Logger::LOG_WARNING, "Reference surface not supported", l->ReferenceSurface());
return false;
}
@@ -744,7 +744,7 @@ bool IfcGeom::Kernel::convert(const IfcSchema::IfcSurfaceCurveSweptAreaSolid* l,
for (TopExp_Explorer exp(wire, TopAbs_VERTEX); exp.More(); exp.Next()) {
if (pln.Distance(BRep_Tool::Pnt(TopoDS::Vertex(exp.Current()))) > ALMOST_ZERO) {
directrix_on_plane = false;
Logger::Message(Logger::LOG_WARNING, "The Directrix does not lie on the ReferenceSurface", l->entity);
Logger::Message(Logger::LOG_WARNING, "The Directrix does not lie on the ReferenceSurface", l);
break;
}
}
@@ -859,7 +859,7 @@ bool IfcGeom::Kernel::convert(const IfcSchema::IfcSweptDiskSolid* l, TopoDS_Shap
}
if (!is_valid) {
Logger::Message(Logger::LOG_WARNING, "Failed to subtract inner radius void for:", l->entity);
Logger::Message(Logger::LOG_WARNING, "Failed to subtract inner radius void for:", l);
}
}
@@ -892,7 +892,7 @@ bool IfcGeom::Kernel::convert(const IfcSchema::IfcTriangulatedFaceSet* l, TopoDS
for (std::vector< std::vector<double> >::const_iterator it = coordinates.begin(); it != coordinates.end(); ++it) {
const std::vector<double>& coords = *it;
if (coords.size() != 3) {
Logger::Message(Logger::LOG_ERROR, "Invalid dimensions encountered on Coordinates", l->entity);
Logger::Message(Logger::LOG_ERROR, "Invalid dimensions encountered on Coordinates", l);
return false;
}
points.push_back(gp_Pnt(coords[0] * getValue(GV_LENGTH_UNIT),
@@ -908,7 +908,7 @@ bool IfcGeom::Kernel::convert(const IfcSchema::IfcTriangulatedFaceSet* l, TopoDS
for(std::vector< std::vector<int> >::const_iterator it = indices.begin(); it != indices.end(); ++ it) {
const std::vector<int>& tri = *it;
if (tri.size() != 3) {
Logger::Message(Logger::LOG_ERROR, "Invalid dimensions encountered on CoordIndex", l->entity);
Logger::Message(Logger::LOG_ERROR, "Invalid dimensions encountered on CoordIndex", l);
return false;
}
@@ -916,7 +916,7 @@ bool IfcGeom::Kernel::convert(const IfcSchema::IfcTriangulatedFaceSet* l, TopoDS
const int max_index = *std::max_element(tri.begin(), tri.end());
if (min_index < 1 || max_index > points.size()) {
Logger::Message(Logger::LOG_ERROR, "Contents of CoordIndex out of bounds", l->entity);
Logger::Message(Logger::LOG_ERROR, "Contents of CoordIndex out of bounds", l);
return false;
}
@@ -973,7 +973,7 @@ bool IfcGeom::Kernel::convert(const IfcSchema::IfcTriangulatedFaceSet* l, TopoDS
}
} catch(...) {}
} else {
Logger::Message(Logger::LOG_WARNING, "Failed to sew faceset:", l->entity);
Logger::Message(Logger::LOG_WARNING, "Failed to sew faceset:", l);
}
}
+23 -23
View File
@@ -87,7 +87,7 @@
bool IfcGeom::Kernel::convert(const IfcSchema::IfcCompositeCurve* l, TopoDS_Wire& wire) {
if ( getValue(GV_PLANEANGLE_UNIT)<0 ) {
Logger::Message(Logger::LOG_WARNING,"Creating a composite curve without unit information:",l->entity);
Logger::Message(Logger::LOG_WARNING, "Creating a composite curve without unit information:", l);
// Temporarily pretend we do have unit information
setValue(GV_PLANEANGLE_UNIT,1.0);
@@ -148,7 +148,7 @@ bool IfcGeom::Kernel::convert(const IfcSchema::IfcCompositeCurve* l, TopoDS_Wire
IfcSchema::IfcCurve* curve = (*it)->ParentCurve();
TopoDS_Wire wire2;
if ( !convert_wire(curve,wire2) ) {
Logger::Message(Logger::LOG_ERROR,"Failed to convert curve:",curve->entity);
Logger::Message(Logger::LOG_ERROR, "Failed to convert curve:", curve);
continue;
}
if ( ! (*it)->SameSense() ) wire2.Reverse();
@@ -167,7 +167,7 @@ bool IfcGeom::Kernel::convert(const IfcSchema::IfcCompositeCurve* l, TopoDS_Wire
w.Add(wire2);
//last_vertex = w.Vertex();
if ( w.Error() != BRepBuilderAPI_WireDone ) {
Logger::Message(Logger::LOG_ERROR,"Failed to join curve segments:",l->entity);
Logger::Message(Logger::LOG_ERROR, "Failed to join curve segments:", l);
TopoDS_Vertex v1, v2, last;
last = w.Vertex();
@@ -184,7 +184,7 @@ bool IfcGeom::Kernel::convert(const IfcSchema::IfcCompositeCurve* l, TopoDS_Wire
std::stringstream ss;
gp_Pnt p = BRep_Tool::Pnt(v1);
ss << std::setprecision(4) << "Segment starts at (" << p.X() << " " << p.Y() << " " << p.Z() << ") for:";
Logger::Message(Logger::LOG_NOTICE, ss.str(), (*it)->entity);
Logger::Message(Logger::LOG_NOTICE, ss.str(), *it);
}
return false;
@@ -196,7 +196,7 @@ bool IfcGeom::Kernel::convert(const IfcSchema::IfcCompositeCurve* l, TopoDS_Wire
bool IfcGeom::Kernel::convert(const IfcSchema::IfcTrimmedCurve* l, TopoDS_Wire& wire) {
IfcSchema::IfcCurve* basis_curve = l->BasisCurve();
bool isConic = basis_curve->is(IfcSchema::Type::IfcConic);
bool isConic = basis_curve->declaration().is(IfcSchema::Type::IfcConic);
double parameterFactor = isConic ? getValue(GV_PLANEANGLE_UNIT) : getValue(GV_LENGTH_UNIT);
Handle(Geom_Curve) curve;
if ( !convert_curve(basis_curve,curve) ) return false;
@@ -211,10 +211,10 @@ bool IfcGeom::Kernel::convert(const IfcSchema::IfcTrimmedCurve* l, TopoDS_Wire&
BRepBuilderAPI_MakeWire w;
for ( IfcEntityList::it it = trims1->begin(); it != trims1->end(); it ++ ) {
IfcUtil::IfcBaseClass* i = *it;
if ( i->is(IfcSchema::Type::IfcCartesianPoint) ) {
if ( i->declaration().is(IfcSchema::Type::IfcCartesianPoint) ) {
IfcGeom::Kernel::convert((IfcSchema::IfcCartesianPoint*)i, pnts[sense_agreement] );
has_pnts[sense_agreement] = true;
} else if ( i->is(IfcSchema::Type::IfcParameterValue) ) {
} else if ( i->declaration().is(IfcSchema::Type::IfcParameterValue) ) {
const double value = *((IfcSchema::IfcParameterValue*)i);
flts[sense_agreement] = value * parameterFactor;
has_flts[sense_agreement] = true;
@@ -222,10 +222,10 @@ bool IfcGeom::Kernel::convert(const IfcSchema::IfcTrimmedCurve* l, TopoDS_Wire&
}
for ( IfcEntityList::it it = trims2->begin(); it != trims2->end(); it ++ ) {
IfcUtil::IfcBaseClass* i = *it;
if ( i->is(IfcSchema::Type::IfcCartesianPoint) ) {
if ( i->declaration().is(IfcSchema::Type::IfcCartesianPoint) ) {
IfcGeom::Kernel::convert((IfcSchema::IfcCartesianPoint*)i, pnts[1-sense_agreement] );
has_pnts[1-sense_agreement] = true;
} else if ( i->is(IfcSchema::Type::IfcParameterValue) ) {
} else if ( i->declaration().is(IfcSchema::Type::IfcParameterValue) ) {
const double value = *((IfcSchema::IfcParameterValue*)i);
flts[1-sense_agreement] = value * parameterFactor;
has_flts[1-sense_agreement] = true;
@@ -235,7 +235,7 @@ bool IfcGeom::Kernel::convert(const IfcSchema::IfcTrimmedCurve* l, TopoDS_Wire&
bool trim_cartesian_failed = !trim_cartesian;
if ( trim_cartesian ) {
if ( pnts[0].Distance(pnts[1]) < getValue(GV_WIRE_CREATION_TOLERANCE) ) {
Logger::Message(Logger::LOG_WARNING,"Skipping segment with length below tolerance level:",l->entity);
Logger::Message(Logger::LOG_WARNING, "Skipping segment with length below tolerance level:", l);
return false;
}
ShapeFix_ShapeTolerance FTol;
@@ -247,7 +247,7 @@ bool IfcGeom::Kernel::convert(const IfcSchema::IfcTrimmedCurve* l, TopoDS_Wire&
if ( ! e.IsDone() ) {
BRepBuilderAPI_EdgeError err = e.Error();
if ( err == BRepBuilderAPI_PointProjectionFailed ) {
Logger::Message(Logger::LOG_WARNING,"Point projection failed for:",l->entity);
Logger::Message(Logger::LOG_WARNING, "Point projection failed for:", l);
trim_cartesian_failed = true;
}
} else {
@@ -259,12 +259,12 @@ bool IfcGeom::Kernel::convert(const IfcSchema::IfcTrimmedCurve* l, TopoDS_Wire&
// is defined by an IfcCartesianPoint and an IfcVector with Magnitude. Because
// the vector is normalised when passed to Geom_Line constructor the magnitude
// needs to be factored in with the IfcParameterValue here.
if ( basis_curve->is(IfcSchema::Type::IfcLine) ) {
if ( basis_curve->declaration().is(IfcSchema::Type::IfcLine) ) {
IfcSchema::IfcLine* line = static_cast<IfcSchema::IfcLine*>(basis_curve);
const double magnitude = line->Dir()->Magnitude();
flts[0] *= magnitude; flts[1] *= magnitude;
}
if ( basis_curve->is(IfcSchema::Type::IfcEllipse) ) {
if ( basis_curve->declaration().is(IfcSchema::Type::IfcEllipse) ) {
IfcSchema::IfcEllipse* ellipse = static_cast<IfcSchema::IfcEllipse*>(basis_curve);
double x = ellipse->SemiAxis1() * getValue(GV_LENGTH_UNIT);
double y = ellipse->SemiAxis2() * getValue(GV_LENGTH_UNIT);
@@ -328,7 +328,7 @@ bool IfcGeom::Kernel::convert(const IfcSchema::IfcPolyLoop* l, TopoDS_Wire& resu
// A loop should consist of at least three vertices
int original_count = polygon.Length();
if (original_count < 3) {
Logger::Message(Logger::LOG_ERROR, "Not enough edges for:", l->entity);
Logger::Message(Logger::LOG_ERROR, "Not enough edges for:", l);
return false;
}
@@ -338,11 +338,11 @@ bool IfcGeom::Kernel::convert(const IfcSchema::IfcPolyLoop* l, TopoDS_Wire& resu
int count = polygon.Length();
if (original_count - count != 0) {
std::stringstream ss; ss << (original_count - count) << " edges removed for:";
Logger::Message(Logger::LOG_WARNING, ss.str(), l->entity);
Logger::Message(Logger::LOG_WARNING, ss.str(), l);
}
if (count < 3) {
Logger::Message(Logger::LOG_ERROR, "Not enough edges for:", l->entity);
Logger::Message(Logger::LOG_ERROR, "Not enough edges for:", l);
return false;
}
@@ -363,8 +363,8 @@ bool IfcGeom::Kernel::convert(const IfcSchema::IfcArbitraryOpenProfileDef* l, To
bool IfcGeom::Kernel::convert(const IfcSchema::IfcEdgeCurve* l, TopoDS_Wire& result) {
IfcSchema::IfcPoint* pnt1 = ((IfcSchema::IfcVertexPoint*) l->EdgeStart())->VertexGeometry();
IfcSchema::IfcPoint* pnt2 = ((IfcSchema::IfcVertexPoint*) l->EdgeEnd())->VertexGeometry();
if (!pnt1->is(IfcSchema::Type::IfcCartesianPoint) || !pnt2->is(IfcSchema::Type::IfcCartesianPoint)) {
Logger::Message(Logger::LOG_ERROR, "Only IfcCartesianPoints are supported for VertexGeometry", l->entity);
if (!pnt1->declaration().is(IfcSchema::Type::IfcCartesianPoint) || !pnt2->declaration().is(IfcSchema::Type::IfcCartesianPoint)) {
Logger::Message(Logger::LOG_ERROR, "Only IfcCartesianPoints are supported for VertexGeometry", l);
return false;
}
@@ -383,7 +383,7 @@ bool IfcGeom::Kernel::convert(const IfcSchema::IfcEdgeCurve* l, TopoDS_Wire& res
// assumed that a topological wire can be crafted from it. After which an
// attempt is made to reconstruct it from the individual curves and the vertices
// of the IfcEdgeCurve.
const bool is_bounded = l->EdgeGeometry()->is(IfcSchema::Type::IfcBoundedCurve);
const bool is_bounded = l->EdgeGeometry()->declaration().is(IfcSchema::Type::IfcBoundedCurve);
if (!is_bounded && convert_curve(l->EdgeGeometry(), crv)) {
mw.Add(BRepBuilderAPI_MakeEdge(crv, p1, p2));
@@ -441,15 +441,15 @@ bool IfcGeom::Kernel::convert(const IfcSchema::IfcEdgeLoop* l, TopoDS_Wire& resu
}
bool IfcGeom::Kernel::convert(const IfcSchema::IfcEdge* l, TopoDS_Wire& result) {
if (!l->EdgeStart()->is(IfcSchema::Type::IfcVertexPoint) || !l->EdgeEnd()->is(IfcSchema::Type::IfcVertexPoint)) {
Logger::Message(Logger::LOG_ERROR, "Only IfcVertexPoints are supported for EdgeStart and -End", l->entity);
if (!l->EdgeStart()->declaration().is(IfcSchema::Type::IfcVertexPoint) || !l->EdgeEnd()->declaration().is(IfcSchema::Type::IfcVertexPoint)) {
Logger::Message(Logger::LOG_ERROR, "Only IfcVertexPoints are supported for EdgeStart and -End", l);
return false;
}
IfcSchema::IfcPoint* pnt1 = ((IfcSchema::IfcVertexPoint*) l->EdgeStart())->VertexGeometry();
IfcSchema::IfcPoint* pnt2 = ((IfcSchema::IfcVertexPoint*) l->EdgeEnd())->VertexGeometry();
if (!pnt1->is(IfcSchema::Type::IfcCartesianPoint) || !pnt2->is(IfcSchema::Type::IfcCartesianPoint)) {
Logger::Message(Logger::LOG_ERROR, "Only IfcCartesianPoints are supported for VertexGeometry", l->entity);
if (!pnt1->declaration().is(IfcSchema::Type::IfcCartesianPoint) || !pnt2->declaration().is(IfcSchema::Type::IfcCartesianPoint)) {
Logger::Message(Logger::LOG_ERROR, "Only IfcCartesianPoints are supported for VertexGeometry", l);
return false;
}
+6 -6
View File
@@ -34,7 +34,7 @@ bool IfcGeom::Kernel::convert_shapes(const IfcBaseClass* l, IfcRepresentationSha
}
#include "IfcRegisterConvertShapes.h"
Logger::Message(Logger::LOG_ERROR,"No operation defined for:",l->entity);
Logger::Message(Logger::LOG_ERROR, "No operation defined for:", l);
return false;
}
@@ -44,7 +44,7 @@ IfcGeom::ShapeType IfcGeom::Kernel::shape_type(const IfcBaseClass* l) {
}
bool IfcGeom::Kernel::convert_shape(const IfcBaseClass* l, TopoDS_Shape& r) {
const unsigned int id = l->entity->id();
const unsigned int id = l->data().id();
bool success = false;
bool processed = false;
bool ignored = false;
@@ -90,7 +90,7 @@ bool IfcGeom::Kernel::convert_shape(const IfcBaseClass* l, TopoDS_Shape& r) {
const char* const msg = processed
? "Failed to convert:"
: "No operation defined for:";
Logger::Message(Logger::LOG_ERROR, msg, l->entity);
Logger::Message(Logger::LOG_ERROR, msg, l);
}
return success;
}
@@ -101,18 +101,18 @@ bool IfcGeom::Kernel::convert_wire(const IfcBaseClass* l, TopoDS_Wire& r) {
if (IfcGeom::Kernel::convert_curve(l, curve)) {
return IfcGeom::Kernel::convert_curve_to_wire(curve, r);
}
Logger::Message(Logger::LOG_ERROR,"No operation defined for:",l->entity);
Logger::Message(Logger::LOG_ERROR, "No operation defined for:", l);
return false;
}
bool IfcGeom::Kernel::convert_face(const IfcBaseClass* l, TopoDS_Shape& r) {
#include "IfcRegisterConvertFace.h"
Logger::Message(Logger::LOG_ERROR,"No operation defined for:",l->entity);
Logger::Message(Logger::LOG_ERROR, "No operation defined for:", l);
return false;
}
bool IfcGeom::Kernel::convert_curve(const IfcBaseClass* l, Handle(Geom_Curve)& r) {
#include "IfcRegisterConvertCurve.h"
Logger::Message(Logger::LOG_ERROR,"No operation defined for:",l->entity);
Logger::Message(Logger::LOG_ERROR, "No operation defined for:", l);
return false;
}
+1 -1
View File
@@ -1,6 +1,6 @@
#include "IfcRegisterUndef.h"
#define CURVE(T) \
if ( l->is(T::Class()) ) return convert((T*)l,r);
if ( l->declaration().is(T::Class()) ) return convert(l->as<T>(), r);
#include "IfcRegisterDef.h"
#include "IfcRegister.h"
+1 -1
View File
@@ -1,6 +1,6 @@
#include "IfcRegisterUndef.h"
#define FACE(T) \
if ( l->is(T::Class()) ) return convert((T*)l,r);
if ( l->declaration().is(T::Class()) ) return convert(l->as<T>(), r);
#include "IfcRegisterDef.h"
#include "IfcRegister.h"
+3 -3
View File
@@ -1,14 +1,14 @@
#include "IfcRegisterUndef.h"
#define SHAPE(T) \
if ( !processed && l->is(T::Class()) ) { \
if ( !processed && l->declaration().is(T::Class()) ) { \
processed = true; \
try { \
if ( convert((T*)l,r) ) { \
if ( convert(l->as<T>(), r) ) { \
success = true; \
} \
} catch(...) { } \
if ( !success) { \
Logger::Message(Logger::LOG_ERROR,"Failed to convert:",l->entity); \
Logger::Message(Logger::LOG_ERROR, "Failed to convert:", l); \
return false; \
} \
}
+3 -3
View File
@@ -1,10 +1,10 @@
#include "IfcRegisterUndef.h"
#define SHAPES(T) \
if ( l->is(T::Class()) ) { \
if ( l->declaration().is(T::Class()) ) { \
try { \
return convert((T*)l,r); \
return convert(l->as<T>(), r); \
} catch (...) { } \
Logger::Message(Logger::LOG_ERROR,"Failed to convert:",l->entity); \
Logger::Message(Logger::LOG_ERROR, "Failed to convert:", l); \
return false; \
}
#include "IfcRegisterDef.h"
+1 -1
View File
@@ -1,6 +1,6 @@
#include "IfcRegisterUndef.h"
#define WIRE(T) \
if ( l->is(T::Class()) ) return convert((T*)l,r);
if ( l->declaration().is(T::Class()) ) return convert((T*)l,r);
#include "IfcRegisterDef.h"
#include "IfcRegister.h"
+5 -5
View File
@@ -1,14 +1,14 @@
#include "IfcRegisterUndef.h"
#define SHAPES(T) \
if ( l->is(T::Class()) ) return ST_SHAPELIST;
if ( l->declaration().is(T::Class()) ) return ST_SHAPELIST;
#define SHAPE(T) \
if ( l->is(T::Class()) ) return ST_SHAPE;
if ( l->declaration().is(T::Class()) ) return ST_SHAPE;
#define WIRE(T) \
if ( l->is(T::Class()) ) return ST_WIRE;
if ( l->declaration().is(T::Class()) ) return ST_WIRE;
#define FACE(T) \
if ( l->is(T::Class()) ) return ST_FACE;
if ( l->declaration().is(T::Class()) ) return ST_FACE;
#define CURVE(T) \
if ( l->is(T::Class()) ) return ST_CURVE;
if ( l->declaration().is(T::Class()) ) return ST_CURVE;
#include "IfcRegisterDef.h"
#include "IfcRegister.h"
+89
View File
@@ -0,0 +1,89 @@
/********************************************************************************
* *
* This file is part of IfcOpenShell. *
* *
* IfcOpenShell is free software: you can redistribute it and/or modify *
* it under the terms of the Lesser GNU General Public License as published by *
* the Free Software Foundation, either version 3.0 of the License, or *
* (at your option) any later version. *
* *
* IfcOpenShell is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* Lesser GNU General Public License for more details. *
* *
* You should have received a copy of the Lesser GNU General Public License *
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
* *
********************************************************************************/
#ifndef HDF5SETTINGS_H
#define HDF5SETTINGS_H
#include <string>
#include <vector>
#include <stdexcept>
namespace IfcParse {
struct Hdf5Settings {
private:
bool compress_, fix_cartesian_point_, fix_global_id_, instantiate_select_, instantiate_inverse_;
unsigned int chunk_size_;
std::vector<std::string> ref_attributes_;
public:
enum Profile {
standard,
padded,
standard_referenced,
padded_referenced
};
static Profile ProfileFromString(const std::string& s) {
if (s == "standard") return standard;
if (s == "padded") return padded;
if (s == "referenced") return standard_referenced;
if (s == "padded-referenced") return padded_referenced;
throw std::runtime_error("Unrecognized profile");
}
private:
Profile profile_;
public:
Hdf5Settings()
: compress_(false)
, fix_cartesian_point_(false)
, fix_global_id_(false)
, instantiate_select_(false)
, instantiate_inverse_(false)
, chunk_size_(false)
, profile_(standard)
{}
bool compress() const { return compress_; }
bool fix_cartesian_point() const { return fix_cartesian_point_; }
bool fix_global_id() const { return fix_global_id_; }
bool instantiate_select() const { return instantiate_select_; }
bool instantiate_inverse() const { return instantiate_inverse_; }
bool& compress() { return compress_; }
bool& fix_cartesian_point() { return fix_cartesian_point_; }
bool& fix_global_id() { return fix_global_id_; }
bool& instantiate_select() { return instantiate_select_; }
bool& instantiate_inverse() { return instantiate_inverse_; }
unsigned int chunk_size() const { return chunk_size_; }
unsigned int& chunk_size() { return chunk_size_; }
Profile profile() const { return profile_; }
Profile& profile() { return profile_; }
const std::vector<std::string>& ref_attributes() const { return ref_attributes_; }
std::vector<std::string>& ref_attributes() { return ref_attributes_; }
};
}
#endif
+24 -18
View File
@@ -51,9 +51,12 @@ enumeration_descriptor_map_t enumeration_descriptor_map;
inverse_map_t inverse_map;
derived_map_t derived_map;
#ifdef _MSC_VER
# pragma optimize( "", off )
#if defined(__clang__)
#elif defined(__GNUC__) || defined(__GNUG__)
#pragma GCC push_options
#pragma GCC optimize ("O0")
#elif defined(_MSC_VER)
#pragma optimize("", off)
#endif
void InitDescriptorMap() {
@@ -155,7 +158,7 @@ void InitDescriptorMap() {
current = entity_descriptor_map[Type::IfcLinearVelocityMeasure] = new IfcEntityDescriptor(Type::IfcLinearVelocityMeasure,0);
current->add("wrappedValue",false,IfcUtil::Argument_DOUBLE);
current = entity_descriptor_map[Type::IfcLogical] = new IfcEntityDescriptor(Type::IfcLogical,0);
current->add("wrappedValue",false,IfcUtil::Argument_BOOL);
current->add("wrappedValue",false,IfcUtil::Argument_TRIBOOL);
current = entity_descriptor_map[Type::IfcLuminousFluxMeasure] = new IfcEntityDescriptor(Type::IfcLuminousFluxMeasure,0);
current->add("wrappedValue",false,IfcUtil::Argument_DOUBLE);
current = entity_descriptor_map[Type::IfcLuminousIntensityDistributionMeasure] = new IfcEntityDescriptor(Type::IfcLuminousIntensityDistributionMeasure,0);
@@ -540,7 +543,7 @@ void InitDescriptorMap() {
current = entity_descriptor_map[Type::IfcMaterialLayer] = new IfcEntityDescriptor(Type::IfcMaterialLayer,0);
current->add("Material",true,IfcUtil::Argument_ENTITY_INSTANCE,Type::IfcMaterial);
current->add("LayerThickness",false,IfcUtil::Argument_DOUBLE,Type::IfcPositiveLengthMeasure);
current->add("IsVentilated",true,IfcUtil::Argument_BOOL,Type::IfcLogical);
current->add("IsVentilated",true,IfcUtil::Argument_TRIBOOL,Type::IfcLogical);
current = entity_descriptor_map[Type::IfcMaterialLayerSet] = new IfcEntityDescriptor(Type::IfcMaterialLayerSet,0);
current->add("MaterialLayers",false,IfcUtil::Argument_AGGREGATE_OF_ENTITY_INSTANCE,Type::IfcMaterialLayer);
current->add("LayerSetName",true,IfcUtil::Argument_STRING,Type::IfcLabel);
@@ -656,9 +659,9 @@ void InitDescriptorMap() {
current->add("AssignedItems",false,IfcUtil::Argument_AGGREGATE_OF_ENTITY_INSTANCE,Type::IfcLayeredItem);
current->add("Identifier",true,IfcUtil::Argument_STRING,Type::IfcIdentifier);
current = entity_descriptor_map[Type::IfcPresentationLayerWithStyle] = new IfcEntityDescriptor(Type::IfcPresentationLayerWithStyle,entity_descriptor_map.find(Type::IfcPresentationLayerAssignment)->second);
current->add("LayerOn",false,IfcUtil::Argument_BOOL,Type::UNDEFINED);
current->add("LayerFrozen",false,IfcUtil::Argument_BOOL,Type::UNDEFINED);
current->add("LayerBlocked",false,IfcUtil::Argument_BOOL,Type::UNDEFINED);
current->add("LayerOn",false,IfcUtil::Argument_TRIBOOL,Type::UNDEFINED);
current->add("LayerFrozen",false,IfcUtil::Argument_TRIBOOL,Type::UNDEFINED);
current->add("LayerBlocked",false,IfcUtil::Argument_TRIBOOL,Type::UNDEFINED);
current->add("LayerStyles",false,IfcUtil::Argument_AGGREGATE_OF_ENTITY_INSTANCE,Type::IfcPresentationStyleSelect);
current = entity_descriptor_map[Type::IfcPresentationStyle] = new IfcEntityDescriptor(Type::IfcPresentationStyle,0);
current->add("Name",true,IfcUtil::Argument_STRING,Type::IfcLabel);
@@ -766,7 +769,7 @@ void InitDescriptorMap() {
current->add("ShapeRepresentations",false,IfcUtil::Argument_AGGREGATE_OF_ENTITY_INSTANCE,Type::IfcShapeModel);
current->add("Name",true,IfcUtil::Argument_STRING,Type::IfcLabel);
current->add("Description",true,IfcUtil::Argument_STRING,Type::IfcText);
current->add("ProductDefinitional",false,IfcUtil::Argument_BOOL,Type::UNDEFINED);
current->add("ProductDefinitional",false,IfcUtil::Argument_TRIBOOL,Type::UNDEFINED);
current->add("PartOfProductDefinitionShape",false,IfcUtil::Argument_ENTITY_INSTANCE,Type::IfcProductDefinitionShape);
current = entity_descriptor_map[Type::IfcShapeModel] = new IfcEntityDescriptor(Type::IfcShapeModel,entity_descriptor_map.find(Type::IfcRepresentation)->second);
@@ -1574,11 +1577,11 @@ void InitDescriptorMap() {
current = entity_descriptor_map[Type::IfcOffsetCurve2D] = new IfcEntityDescriptor(Type::IfcOffsetCurve2D,entity_descriptor_map.find(Type::IfcCurve)->second);
current->add("BasisCurve",false,IfcUtil::Argument_ENTITY_INSTANCE,Type::IfcCurve);
current->add("Distance",false,IfcUtil::Argument_DOUBLE,Type::IfcLengthMeasure);
current->add("SelfIntersect",false,IfcUtil::Argument_BOOL,Type::UNDEFINED);
current->add("SelfIntersect",false,IfcUtil::Argument_TRIBOOL,Type::UNDEFINED);
current = entity_descriptor_map[Type::IfcOffsetCurve3D] = new IfcEntityDescriptor(Type::IfcOffsetCurve3D,entity_descriptor_map.find(Type::IfcCurve)->second);
current->add("BasisCurve",false,IfcUtil::Argument_ENTITY_INSTANCE,Type::IfcCurve);
current->add("Distance",false,IfcUtil::Argument_DOUBLE,Type::IfcLengthMeasure);
current->add("SelfIntersect",false,IfcUtil::Argument_BOOL,Type::UNDEFINED);
current->add("SelfIntersect",false,IfcUtil::Argument_TRIBOOL,Type::UNDEFINED);
current->add("RefDirection",false,IfcUtil::Argument_ENTITY_INSTANCE,Type::IfcDirection);
current = entity_descriptor_map[Type::IfcPermeableCoveringProperties] = new IfcEntityDescriptor(Type::IfcPermeableCoveringProperties,entity_descriptor_map.find(Type::IfcPropertySetDefinition)->second);
current->add("OperationType",false,IfcUtil::Argument_ENUMERATION,Type::IfcPermeableCoveringOperationEnum);
@@ -1846,7 +1849,7 @@ void InitDescriptorMap() {
current->add("PredefinedType",false,IfcUtil::Argument_ENUMERATION,Type::IfcColumnTypeEnum);
current = entity_descriptor_map[Type::IfcCompositeCurve] = new IfcEntityDescriptor(Type::IfcCompositeCurve,entity_descriptor_map.find(Type::IfcBoundedCurve)->second);
current->add("Segments",false,IfcUtil::Argument_AGGREGATE_OF_ENTITY_INSTANCE,Type::IfcCompositeCurveSegment);
current->add("SelfIntersect",false,IfcUtil::Argument_BOOL,Type::UNDEFINED);
current->add("SelfIntersect",false,IfcUtil::Argument_TRIBOOL,Type::UNDEFINED);
current = entity_descriptor_map[Type::IfcConic] = new IfcEntityDescriptor(Type::IfcConic,entity_descriptor_map.find(Type::IfcCurve)->second);
current->add("Position",false,IfcUtil::Argument_ENTITY_INSTANCE,Type::IfcAxis2Placement);
current = entity_descriptor_map[Type::IfcConstructionResource] = new IfcEntityDescriptor(Type::IfcConstructionResource,entity_descriptor_map.find(Type::IfcResource)->second);
@@ -2203,8 +2206,8 @@ void InitDescriptorMap() {
current->add("Degree",false,IfcUtil::Argument_INT,Type::UNDEFINED);
current->add("ControlPointsList",false,IfcUtil::Argument_AGGREGATE_OF_ENTITY_INSTANCE,Type::IfcCartesianPoint);
current->add("CurveForm",false,IfcUtil::Argument_ENUMERATION,Type::IfcBSplineCurveForm);
current->add("ClosedCurve",false,IfcUtil::Argument_BOOL,Type::UNDEFINED);
current->add("SelfIntersect",false,IfcUtil::Argument_BOOL,Type::UNDEFINED);
current->add("ClosedCurve",false,IfcUtil::Argument_TRIBOOL,Type::UNDEFINED);
current->add("SelfIntersect",false,IfcUtil::Argument_TRIBOOL,Type::UNDEFINED);
current = entity_descriptor_map[Type::IfcBeamType] = new IfcEntityDescriptor(Type::IfcBeamType,entity_descriptor_map.find(Type::IfcBuildingElementType)->second);
current->add("PredefinedType",false,IfcUtil::Argument_ENUMERATION,Type::IfcBeamTypeEnum);
current = entity_descriptor_map[Type::IfcBezierCurve] = new IfcEntityDescriptor(Type::IfcBezierCurve,entity_descriptor_map.find(Type::IfcBSplineCurve)->second);
@@ -4063,10 +4066,6 @@ void InitDescriptorMap() {
current_enum = enumeration_descriptor_map[Type::IfcWorkControlTypeEnum] = new IfcEnumerationDescriptor(Type::IfcWorkControlTypeEnum, values);
}
#ifdef _MSC_VER
# pragma optimize( "", on )
#endif
void InitInverseMap() {
inverse_map[Type::IfcActor].insert(std::make_pair("IsActingUpon", std::make_pair(Type::IfcRelAssignsToActor, 6)));
inverse_map[Type::IfcAddress].insert(std::make_pair("OfPerson", std::make_pair(Type::IfcPerson, 7)));
@@ -4191,6 +4190,13 @@ void InitDerivedMap() {
{std::set<int> idxs; idxs.insert(0); derived_map[Type::IfcSIUnit] = idxs;}
}
#if defined(__clang__)
#elif defined(__GNUC__) || defined(__GNUG__)
#pragma GCC pop_options
#elif defined(_MSC_VER)
#pragma optimize("", on)
#endif
int Type::GetAttributeIndex(Enum t, const std::string& a) {
if (entity_descriptor_map.empty()) ::InitDescriptorMap();
std::map<Type::Enum,IfcEntityDescriptor*>::const_iterator i = entity_descriptor_map.find(t);
+3
View File
@@ -24,6 +24,8 @@
* *
********************************************************************************/
#ifndef USE_IFC4
#ifndef IFC2X3RT_H
#define IFC2X3RT_H
@@ -49,3 +51,4 @@ namespace Type {
}}
#endif
#endif
File diff suppressed because it is too large Load Diff
+7898 -6823
View File
File diff suppressed because one or more lines are too long
+2144 -6446
View File
File diff suppressed because it is too large Load Diff
File diff suppressed because one or more lines are too long
+147 -89
View File
@@ -51,9 +51,12 @@ enumeration_descriptor_map_t enumeration_descriptor_map;
inverse_map_t inverse_map;
derived_map_t derived_map;
#ifdef _MSC_VER
# pragma optimize( "", off )
#if defined(__clang__)
#elif defined(__GNUC__) || defined(__GNUG__)
#pragma GCC push_options
#pragma GCC optimize ("O0")
#elif defined(_MSC_VER)
#pragma optimize("", off)
#endif
void InitDescriptorMap() {
@@ -66,10 +69,14 @@ void InitDescriptorMap() {
current->add("wrappedValue",false,IfcUtil::Argument_DOUBLE);
current = entity_descriptor_map[Type::IfcAngularVelocityMeasure] = new IfcEntityDescriptor(Type::IfcAngularVelocityMeasure,0);
current->add("wrappedValue",false,IfcUtil::Argument_DOUBLE);
current = entity_descriptor_map[Type::IfcArcIndex] = new IfcEntityDescriptor(Type::IfcArcIndex,0);
current->add("wrappedValue",false,IfcUtil::Argument_AGGREGATE_OF_INT);
current = entity_descriptor_map[Type::IfcAreaDensityMeasure] = new IfcEntityDescriptor(Type::IfcAreaDensityMeasure,0);
current->add("wrappedValue",false,IfcUtil::Argument_DOUBLE);
current = entity_descriptor_map[Type::IfcAreaMeasure] = new IfcEntityDescriptor(Type::IfcAreaMeasure,0);
current->add("wrappedValue",false,IfcUtil::Argument_DOUBLE);
current = entity_descriptor_map[Type::IfcBinary] = new IfcEntityDescriptor(Type::IfcBinary,0);
current->add("wrappedValue",false,IfcUtil::Argument_BINARY);
current = entity_descriptor_map[Type::IfcBoolean] = new IfcEntityDescriptor(Type::IfcBoolean,0);
current->add("wrappedValue",false,IfcUtil::Argument_BOOL);
current = entity_descriptor_map[Type::IfcBoxAlignment] = new IfcEntityDescriptor(Type::IfcBoxAlignment,0);
@@ -156,6 +163,8 @@ void InitDescriptorMap() {
current->add("wrappedValue",false,IfcUtil::Argument_STRING);
current = entity_descriptor_map[Type::IfcLengthMeasure] = new IfcEntityDescriptor(Type::IfcLengthMeasure,0);
current->add("wrappedValue",false,IfcUtil::Argument_DOUBLE);
current = entity_descriptor_map[Type::IfcLineIndex] = new IfcEntityDescriptor(Type::IfcLineIndex,0);
current->add("wrappedValue",false,IfcUtil::Argument_AGGREGATE_OF_INT);
current = entity_descriptor_map[Type::IfcLinearForceMeasure] = new IfcEntityDescriptor(Type::IfcLinearForceMeasure,0);
current->add("wrappedValue",false,IfcUtil::Argument_DOUBLE);
current = entity_descriptor_map[Type::IfcLinearMomentMeasure] = new IfcEntityDescriptor(Type::IfcLinearMomentMeasure,0);
@@ -165,7 +174,7 @@ void InitDescriptorMap() {
current = entity_descriptor_map[Type::IfcLinearVelocityMeasure] = new IfcEntityDescriptor(Type::IfcLinearVelocityMeasure,0);
current->add("wrappedValue",false,IfcUtil::Argument_DOUBLE);
current = entity_descriptor_map[Type::IfcLogical] = new IfcEntityDescriptor(Type::IfcLogical,0);
current->add("wrappedValue",false,IfcUtil::Argument_BOOL);
current->add("wrappedValue",false,IfcUtil::Argument_TRIBOOL);
current = entity_descriptor_map[Type::IfcLuminousFluxMeasure] = new IfcEntityDescriptor(Type::IfcLuminousFluxMeasure,0);
current->add("wrappedValue",false,IfcUtil::Argument_DOUBLE);
current = entity_descriptor_map[Type::IfcLuminousIntensityDistributionMeasure] = new IfcEntityDescriptor(Type::IfcLuminousIntensityDistributionMeasure,0);
@@ -216,6 +225,8 @@ void InitDescriptorMap() {
current->add("wrappedValue",false,IfcUtil::Argument_DOUBLE);
current = entity_descriptor_map[Type::IfcPlaneAngleMeasure] = new IfcEntityDescriptor(Type::IfcPlaneAngleMeasure,0);
current->add("wrappedValue",false,IfcUtil::Argument_DOUBLE);
current = entity_descriptor_map[Type::IfcPositiveInteger] = new IfcEntityDescriptor(Type::IfcPositiveInteger,0);
current->add("wrappedValue",false,IfcUtil::Argument_INT);
current = entity_descriptor_map[Type::IfcPositiveLengthMeasure] = new IfcEntityDescriptor(Type::IfcPositiveLengthMeasure,0);
current->add("wrappedValue",false,IfcUtil::Argument_DOUBLE);
current = entity_descriptor_map[Type::IfcPositivePlaneAngleMeasure] = new IfcEntityDescriptor(Type::IfcPositivePlaneAngleMeasure,0);
@@ -264,6 +275,8 @@ void InitDescriptorMap() {
current->add("wrappedValue",false,IfcUtil::Argument_DOUBLE);
current = entity_descriptor_map[Type::IfcSpecularRoughness] = new IfcEntityDescriptor(Type::IfcSpecularRoughness,0);
current->add("wrappedValue",false,IfcUtil::Argument_DOUBLE);
current = entity_descriptor_map[Type::IfcStrippedOptional] = new IfcEntityDescriptor(Type::IfcStrippedOptional,0);
current->add("wrappedValue",false,IfcUtil::Argument_BOOL);
current = entity_descriptor_map[Type::IfcTemperatureGradientMeasure] = new IfcEntityDescriptor(Type::IfcTemperatureGradientMeasure,0);
current->add("wrappedValue",false,IfcUtil::Argument_DOUBLE);
current = entity_descriptor_map[Type::IfcTemperatureRateOfChangeMeasure] = new IfcEntityDescriptor(Type::IfcTemperatureRateOfChangeMeasure,0);
@@ -389,9 +402,9 @@ void InitDescriptorMap() {
current->add("SourceCRS",false,IfcUtil::Argument_ENTITY_INSTANCE,Type::IfcCoordinateReferenceSystemSelect);
current->add("TargetCRS",false,IfcUtil::Argument_ENTITY_INSTANCE,Type::IfcCoordinateReferenceSystem);
current = entity_descriptor_map[Type::IfcCoordinateReferenceSystem] = new IfcEntityDescriptor(Type::IfcCoordinateReferenceSystem,0);
current->add("Name",true,IfcUtil::Argument_STRING,Type::IfcLabel);
current->add("Name",false,IfcUtil::Argument_STRING,Type::IfcLabel);
current->add("Description",true,IfcUtil::Argument_STRING,Type::IfcText);
current->add("GeodeticDatum",false,IfcUtil::Argument_STRING,Type::IfcIdentifier);
current->add("GeodeticDatum",true,IfcUtil::Argument_STRING,Type::IfcIdentifier);
current->add("VerticalDatum",true,IfcUtil::Argument_STRING,Type::IfcIdentifier);
current = entity_descriptor_map[Type::IfcCostValue] = new IfcEntityDescriptor(Type::IfcCostValue,entity_descriptor_map.find(Type::IfcAppliedValue)->second);
@@ -462,11 +475,11 @@ void InitDescriptorMap() {
current = entity_descriptor_map[Type::IfcMaterialLayer] = new IfcEntityDescriptor(Type::IfcMaterialLayer,entity_descriptor_map.find(Type::IfcMaterialDefinition)->second);
current->add("Material",true,IfcUtil::Argument_ENTITY_INSTANCE,Type::IfcMaterial);
current->add("LayerThickness",false,IfcUtil::Argument_DOUBLE,Type::IfcNonNegativeLengthMeasure);
current->add("IsVentilated",true,IfcUtil::Argument_BOOL,Type::IfcLogical);
current->add("IsVentilated",true,IfcUtil::Argument_TRIBOOL,Type::IfcLogical);
current->add("Name",true,IfcUtil::Argument_STRING,Type::IfcLabel);
current->add("Description",true,IfcUtil::Argument_STRING,Type::IfcText);
current->add("Category",true,IfcUtil::Argument_STRING,Type::IfcLabel);
current->add("Priority",true,IfcUtil::Argument_DOUBLE,Type::IfcNormalisedRatioMeasure);
current->add("Priority",true,IfcUtil::Argument_INT,Type::IfcInteger);
current = entity_descriptor_map[Type::IfcMaterialLayerSet] = new IfcEntityDescriptor(Type::IfcMaterialLayerSet,entity_descriptor_map.find(Type::IfcMaterialDefinition)->second);
current->add("MaterialLayers",false,IfcUtil::Argument_AGGREGATE_OF_ENTITY_INSTANCE,Type::IfcMaterialLayer);
current->add("LayerSetName",true,IfcUtil::Argument_STRING,Type::IfcLabel);
@@ -481,7 +494,7 @@ void InitDescriptorMap() {
current->add("Description",true,IfcUtil::Argument_STRING,Type::IfcText);
current->add("Material",true,IfcUtil::Argument_ENTITY_INSTANCE,Type::IfcMaterial);
current->add("Profile",false,IfcUtil::Argument_ENTITY_INSTANCE,Type::IfcProfileDef);
current->add("Priority",true,IfcUtil::Argument_DOUBLE,Type::IfcNormalisedRatioMeasure);
current->add("Priority",true,IfcUtil::Argument_INT,Type::IfcInteger);
current->add("Category",true,IfcUtil::Argument_STRING,Type::IfcLabel);
current = entity_descriptor_map[Type::IfcMaterialProfileSet] = new IfcEntityDescriptor(Type::IfcMaterialProfileSet,entity_descriptor_map.find(Type::IfcMaterialDefinition)->second);
current->add("Name",true,IfcUtil::Argument_STRING,Type::IfcLabel);
@@ -498,7 +511,7 @@ void InitDescriptorMap() {
current = entity_descriptor_map[Type::IfcMetric] = new IfcEntityDescriptor(Type::IfcMetric,entity_descriptor_map.find(Type::IfcConstraint)->second);
current->add("Benchmark",false,IfcUtil::Argument_ENUMERATION,Type::IfcBenchmarkEnum);
current->add("ValueSource",true,IfcUtil::Argument_STRING,Type::IfcLabel);
current->add("DataValue",false,IfcUtil::Argument_ENTITY_INSTANCE,Type::IfcMetricValueSelect);
current->add("DataValue",true,IfcUtil::Argument_ENTITY_INSTANCE,Type::IfcMetricValueSelect);
current->add("ReferencePath",true,IfcUtil::Argument_ENTITY_INSTANCE,Type::IfcReference);
current = entity_descriptor_map[Type::IfcMonetaryUnit] = new IfcEntityDescriptor(Type::IfcMonetaryUnit,0);
current->add("Currency",false,IfcUtil::Argument_STRING,Type::IfcLabel);
@@ -561,9 +574,9 @@ void InitDescriptorMap() {
current->add("AssignedItems",false,IfcUtil::Argument_AGGREGATE_OF_ENTITY_INSTANCE,Type::IfcLayeredItem);
current->add("Identifier",true,IfcUtil::Argument_STRING,Type::IfcIdentifier);
current = entity_descriptor_map[Type::IfcPresentationLayerWithStyle] = new IfcEntityDescriptor(Type::IfcPresentationLayerWithStyle,entity_descriptor_map.find(Type::IfcPresentationLayerAssignment)->second);
current->add("LayerOn",false,IfcUtil::Argument_BOOL,Type::UNDEFINED);
current->add("LayerFrozen",false,IfcUtil::Argument_BOOL,Type::UNDEFINED);
current->add("LayerBlocked",false,IfcUtil::Argument_BOOL,Type::UNDEFINED);
current->add("LayerOn",false,IfcUtil::Argument_TRIBOOL,Type::IfcLogical);
current->add("LayerFrozen",false,IfcUtil::Argument_TRIBOOL,Type::IfcLogical);
current->add("LayerBlocked",false,IfcUtil::Argument_TRIBOOL,Type::IfcLogical);
current->add("LayerStyles",false,IfcUtil::Argument_AGGREGATE_OF_ENTITY_INSTANCE,Type::IfcPresentationStyle);
current = entity_descriptor_map[Type::IfcPresentationStyle] = new IfcEntityDescriptor(Type::IfcPresentationStyle,0);
current->add("Name",true,IfcUtil::Argument_STRING,Type::IfcLabel);
@@ -617,7 +630,7 @@ void InitDescriptorMap() {
current->add("TypeIdentifier",true,IfcUtil::Argument_STRING,Type::IfcIdentifier);
current->add("AttributeIdentifier",true,IfcUtil::Argument_STRING,Type::IfcIdentifier);
current->add("InstanceName",true,IfcUtil::Argument_STRING,Type::IfcLabel);
current->add("ListPositions",true,IfcUtil::Argument_AGGREGATE_OF_INT,Type::UNDEFINED);
current->add("ListPositions",true,IfcUtil::Argument_AGGREGATE_OF_INT,Type::IfcInteger);
current->add("InnerReference",true,IfcUtil::Argument_ENTITY_INSTANCE,Type::IfcReference);
current = entity_descriptor_map[Type::IfcRepresentation] = new IfcEntityDescriptor(Type::IfcRepresentation,0);
current->add("ContextOfItems",false,IfcUtil::Argument_ENTITY_INSTANCE,Type::IfcRepresentationContext);
@@ -651,7 +664,7 @@ void InitDescriptorMap() {
current->add("ShapeRepresentations",false,IfcUtil::Argument_AGGREGATE_OF_ENTITY_INSTANCE,Type::IfcShapeModel);
current->add("Name",true,IfcUtil::Argument_STRING,Type::IfcLabel);
current->add("Description",true,IfcUtil::Argument_STRING,Type::IfcText);
current->add("ProductDefinitional",false,IfcUtil::Argument_BOOL,Type::UNDEFINED);
current->add("ProductDefinitional",false,IfcUtil::Argument_TRIBOOL,Type::IfcLogical);
current->add("PartOfProductDefinitionShape",true,IfcUtil::Argument_ENTITY_INSTANCE,Type::IfcProductRepresentationSelect);
current = entity_descriptor_map[Type::IfcShapeModel] = new IfcEntityDescriptor(Type::IfcShapeModel,entity_descriptor_map.find(Type::IfcRepresentation)->second);
@@ -697,11 +710,12 @@ void InitDescriptorMap() {
current->add("DispersionFactor",true,IfcUtil::Argument_DOUBLE,Type::IfcReal);
current = entity_descriptor_map[Type::IfcSurfaceStyleShading] = new IfcEntityDescriptor(Type::IfcSurfaceStyleShading,entity_descriptor_map.find(Type::IfcPresentationItem)->second);
current->add("SurfaceColour",false,IfcUtil::Argument_ENTITY_INSTANCE,Type::IfcColourRgb);
current->add("Transparency",true,IfcUtil::Argument_DOUBLE,Type::IfcNormalisedRatioMeasure);
current = entity_descriptor_map[Type::IfcSurfaceStyleWithTextures] = new IfcEntityDescriptor(Type::IfcSurfaceStyleWithTextures,entity_descriptor_map.find(Type::IfcPresentationItem)->second);
current->add("Textures",false,IfcUtil::Argument_AGGREGATE_OF_ENTITY_INSTANCE,Type::IfcSurfaceTexture);
current = entity_descriptor_map[Type::IfcSurfaceTexture] = new IfcEntityDescriptor(Type::IfcSurfaceTexture,entity_descriptor_map.find(Type::IfcPresentationItem)->second);
current->add("RepeatS",false,IfcUtil::Argument_BOOL,Type::UNDEFINED);
current->add("RepeatT",false,IfcUtil::Argument_BOOL,Type::UNDEFINED);
current->add("RepeatS",false,IfcUtil::Argument_BOOL,Type::IfcBoolean);
current->add("RepeatT",false,IfcUtil::Argument_BOOL,Type::IfcBoolean);
current->add("Mode",true,IfcUtil::Argument_STRING,Type::IfcIdentifier);
current->add("TextureTransform",true,IfcUtil::Argument_ENTITY_INSTANCE,Type::IfcCartesianTransformationOperator2D);
current->add("Parameter",true,IfcUtil::Argument_AGGREGATE_OF_STRING,Type::IfcIdentifier);
@@ -717,7 +731,7 @@ void InitDescriptorMap() {
current->add("ReferencePath",true,IfcUtil::Argument_ENTITY_INSTANCE,Type::IfcReference);
current = entity_descriptor_map[Type::IfcTableRow] = new IfcEntityDescriptor(Type::IfcTableRow,0);
current->add("RowCells",true,IfcUtil::Argument_AGGREGATE_OF_ENTITY_INSTANCE,Type::IfcValue);
current->add("IsHeading",true,IfcUtil::Argument_BOOL,Type::UNDEFINED);
current->add("IsHeading",true,IfcUtil::Argument_BOOL,Type::IfcBoolean);
current = entity_descriptor_map[Type::IfcTaskTime] = new IfcEntityDescriptor(Type::IfcTaskTime,entity_descriptor_map.find(Type::IfcSchedulingTime)->second);
current->add("DurationType",true,IfcUtil::Argument_ENUMERATION,Type::IfcTaskDurationEnum);
current->add("ScheduleDuration",true,IfcUtil::Argument_STRING,Type::IfcDuration);
@@ -729,7 +743,7 @@ void InitDescriptorMap() {
current->add("LateFinish",true,IfcUtil::Argument_STRING,Type::IfcDateTime);
current->add("FreeFloat",true,IfcUtil::Argument_STRING,Type::IfcDuration);
current->add("TotalFloat",true,IfcUtil::Argument_STRING,Type::IfcDuration);
current->add("IsCritical",true,IfcUtil::Argument_BOOL,Type::UNDEFINED);
current->add("IsCritical",true,IfcUtil::Argument_BOOL,Type::IfcBoolean);
current->add("StatusTime",true,IfcUtil::Argument_STRING,Type::IfcDateTime);
current->add("ActualDuration",true,IfcUtil::Argument_STRING,Type::IfcDuration);
current->add("ActualStart",true,IfcUtil::Argument_STRING,Type::IfcDateTime);
@@ -737,7 +751,7 @@ void InitDescriptorMap() {
current->add("RemainingTime",true,IfcUtil::Argument_STRING,Type::IfcDuration);
current->add("Completion",true,IfcUtil::Argument_DOUBLE,Type::IfcPositiveRatioMeasure);
current = entity_descriptor_map[Type::IfcTaskTimeRecurring] = new IfcEntityDescriptor(Type::IfcTaskTimeRecurring,entity_descriptor_map.find(Type::IfcTaskTime)->second);
current->add("Recurrance",false,IfcUtil::Argument_ENTITY_INSTANCE,Type::IfcRecurrencePattern);
current->add("Recurrence",false,IfcUtil::Argument_ENTITY_INSTANCE,Type::IfcRecurrencePattern);
current = entity_descriptor_map[Type::IfcTelecomAddress] = new IfcEntityDescriptor(Type::IfcTelecomAddress,entity_descriptor_map.find(Type::IfcAddress)->second);
current->add("TelephoneNumbers",true,IfcUtil::Argument_AGGREGATE_OF_STRING,Type::IfcLabel);
current->add("FacsimileNumbers",true,IfcUtil::Argument_AGGREGATE_OF_STRING,Type::IfcLabel);
@@ -749,7 +763,7 @@ void InitDescriptorMap() {
current->add("TextCharacterAppearance",true,IfcUtil::Argument_ENTITY_INSTANCE,Type::IfcTextStyleForDefinedFont);
current->add("TextStyle",true,IfcUtil::Argument_ENTITY_INSTANCE,Type::IfcTextStyleTextModel);
current->add("TextFontStyle",false,IfcUtil::Argument_ENTITY_INSTANCE,Type::IfcTextFontSelect);
current->add("ModelOrDraughting",true,IfcUtil::Argument_BOOL,Type::UNDEFINED);
current->add("ModelOrDraughting",true,IfcUtil::Argument_BOOL,Type::IfcBoolean);
current = entity_descriptor_map[Type::IfcTextStyleForDefinedFont] = new IfcEntityDescriptor(Type::IfcTextStyleForDefinedFont,entity_descriptor_map.find(Type::IfcPresentationItem)->second);
current->add("Colour",false,IfcUtil::Argument_ENTITY_INSTANCE,Type::IfcColour);
current->add("BackgroundColour",true,IfcUtil::Argument_ENTITY_INSTANCE,Type::IfcColour);
@@ -815,7 +829,7 @@ void InitDescriptorMap() {
current->add("InnerCurves",false,IfcUtil::Argument_AGGREGATE_OF_ENTITY_INSTANCE,Type::IfcCurve);
current = entity_descriptor_map[Type::IfcBlobTexture] = new IfcEntityDescriptor(Type::IfcBlobTexture,entity_descriptor_map.find(Type::IfcSurfaceTexture)->second);
current->add("RasterFormat",false,IfcUtil::Argument_STRING,Type::IfcIdentifier);
current->add("RasterCode",false,IfcUtil::Argument_BINARY,Type::UNDEFINED);
current->add("RasterCode",false,IfcUtil::Argument_BINARY,Type::IfcBinary);
current = entity_descriptor_map[Type::IfcCenterLineProfileDef] = new IfcEntityDescriptor(Type::IfcCenterLineProfileDef,entity_descriptor_map.find(Type::IfcArbitraryOpenProfileDef)->second);
current->add("Thickness",false,IfcUtil::Argument_DOUBLE,Type::IfcPositiveLengthMeasure);
current = entity_descriptor_map[Type::IfcClassification] = new IfcEntityDescriptor(Type::IfcClassification,entity_descriptor_map.find(Type::IfcExternalInformation)->second);
@@ -863,7 +877,7 @@ void InitDescriptorMap() {
current->add("CurveFont",true,IfcUtil::Argument_ENTITY_INSTANCE,Type::IfcCurveFontOrScaledCurveFontSelect);
current->add("CurveWidth",true,IfcUtil::Argument_ENTITY_INSTANCE,Type::IfcSizeSelect);
current->add("CurveColour",true,IfcUtil::Argument_ENTITY_INSTANCE,Type::IfcColour);
current->add("ModelOrDraughting",true,IfcUtil::Argument_BOOL,Type::UNDEFINED);
current->add("ModelOrDraughting",true,IfcUtil::Argument_BOOL,Type::IfcBoolean);
current = entity_descriptor_map[Type::IfcCurveStyleFont] = new IfcEntityDescriptor(Type::IfcCurveStyleFont,entity_descriptor_map.find(Type::IfcPresentationItem)->second);
current->add("Name",true,IfcUtil::Argument_STRING,Type::IfcLabel);
current->add("PatternList",false,IfcUtil::Argument_AGGREGATE_OF_ENTITY_INSTANCE,Type::IfcCurveStyleFontPattern);
@@ -908,7 +922,7 @@ void InitDescriptorMap() {
current->add("EdgeEnd",false,IfcUtil::Argument_ENTITY_INSTANCE,Type::IfcVertex);
current = entity_descriptor_map[Type::IfcEdgeCurve] = new IfcEntityDescriptor(Type::IfcEdgeCurve,entity_descriptor_map.find(Type::IfcEdge)->second);
current->add("EdgeGeometry",false,IfcUtil::Argument_ENTITY_INSTANCE,Type::IfcCurve);
current->add("SameSense",false,IfcUtil::Argument_BOOL,Type::UNDEFINED);
current->add("SameSense",false,IfcUtil::Argument_BOOL,Type::IfcBoolean);
current = entity_descriptor_map[Type::IfcEventTime] = new IfcEntityDescriptor(Type::IfcEventTime,entity_descriptor_map.find(Type::IfcSchedulingTime)->second);
current->add("ActualDate",true,IfcUtil::Argument_STRING,Type::IfcDateTime);
current->add("EarlyDate",true,IfcUtil::Argument_STRING,Type::IfcDateTime);
@@ -925,12 +939,12 @@ void InitDescriptorMap() {
current->add("Bounds",false,IfcUtil::Argument_AGGREGATE_OF_ENTITY_INSTANCE,Type::IfcFaceBound);
current = entity_descriptor_map[Type::IfcFaceBound] = new IfcEntityDescriptor(Type::IfcFaceBound,entity_descriptor_map.find(Type::IfcTopologicalRepresentationItem)->second);
current->add("Bound",false,IfcUtil::Argument_ENTITY_INSTANCE,Type::IfcLoop);
current->add("Orientation",false,IfcUtil::Argument_BOOL,Type::UNDEFINED);
current->add("Orientation",false,IfcUtil::Argument_BOOL,Type::IfcBoolean);
current = entity_descriptor_map[Type::IfcFaceOuterBound] = new IfcEntityDescriptor(Type::IfcFaceOuterBound,entity_descriptor_map.find(Type::IfcFaceBound)->second);
current = entity_descriptor_map[Type::IfcFaceSurface] = new IfcEntityDescriptor(Type::IfcFaceSurface,entity_descriptor_map.find(Type::IfcFace)->second);
current->add("FaceSurface",false,IfcUtil::Argument_ENTITY_INSTANCE,Type::IfcSurface);
current->add("SameSense",false,IfcUtil::Argument_BOOL,Type::UNDEFINED);
current->add("SameSense",false,IfcUtil::Argument_BOOL,Type::IfcBoolean);
current = entity_descriptor_map[Type::IfcFailureConnectionCondition] = new IfcEntityDescriptor(Type::IfcFailureConnectionCondition,entity_descriptor_map.find(Type::IfcStructuralConnectionCondition)->second);
current->add("TensionFailureX",true,IfcUtil::Argument_DOUBLE,Type::IfcForceMeasure);
current->add("TensionFailureY",true,IfcUtil::Argument_DOUBLE,Type::IfcForceMeasure);
@@ -940,10 +954,10 @@ void InitDescriptorMap() {
current->add("CompressionFailureZ",true,IfcUtil::Argument_DOUBLE,Type::IfcForceMeasure);
current = entity_descriptor_map[Type::IfcFillAreaStyle] = new IfcEntityDescriptor(Type::IfcFillAreaStyle,entity_descriptor_map.find(Type::IfcPresentationStyle)->second);
current->add("FillStyles",false,IfcUtil::Argument_AGGREGATE_OF_ENTITY_INSTANCE,Type::IfcFillStyleSelect);
current->add("ModelorDraughting",true,IfcUtil::Argument_BOOL,Type::UNDEFINED);
current->add("ModelorDraughting",true,IfcUtil::Argument_BOOL,Type::IfcBoolean);
current = entity_descriptor_map[Type::IfcGeometricRepresentationContext] = new IfcEntityDescriptor(Type::IfcGeometricRepresentationContext,entity_descriptor_map.find(Type::IfcRepresentationContext)->second);
current->add("CoordinateSpaceDimension",false,IfcUtil::Argument_INT,Type::IfcDimensionCount);
current->add("Precision",true,IfcUtil::Argument_DOUBLE,Type::UNDEFINED);
current->add("Precision",true,IfcUtil::Argument_DOUBLE,Type::IfcReal);
current->add("WorldCoordinateSystem",false,IfcUtil::Argument_ENTITY_INSTANCE,Type::IfcAxis2Placement);
current->add("TrueNorth",true,IfcUtil::Argument_ENTITY_INSTANCE,Type::IfcDirection);
current = entity_descriptor_map[Type::IfcGeometricRepresentationItem] = new IfcEntityDescriptor(Type::IfcGeometricRepresentationItem,entity_descriptor_map.find(Type::IfcRepresentationItem)->second);
@@ -960,19 +974,19 @@ void InitDescriptorMap() {
current->add("PlacementRefDirection",true,IfcUtil::Argument_ENTITY_INSTANCE,Type::IfcGridPlacementDirectionSelect);
current = entity_descriptor_map[Type::IfcHalfSpaceSolid] = new IfcEntityDescriptor(Type::IfcHalfSpaceSolid,entity_descriptor_map.find(Type::IfcGeometricRepresentationItem)->second);
current->add("BaseSurface",false,IfcUtil::Argument_ENTITY_INSTANCE,Type::IfcSurface);
current->add("AgreementFlag",false,IfcUtil::Argument_BOOL,Type::UNDEFINED);
current->add("AgreementFlag",false,IfcUtil::Argument_BOOL,Type::IfcBoolean);
current = entity_descriptor_map[Type::IfcImageTexture] = new IfcEntityDescriptor(Type::IfcImageTexture,entity_descriptor_map.find(Type::IfcSurfaceTexture)->second);
current->add("URLReference",false,IfcUtil::Argument_STRING,Type::IfcURIReference);
current = entity_descriptor_map[Type::IfcIndexedColourMap] = new IfcEntityDescriptor(Type::IfcIndexedColourMap,entity_descriptor_map.find(Type::IfcPresentationItem)->second);
current->add("MappedTo",false,IfcUtil::Argument_ENTITY_INSTANCE,Type::IfcTessellatedFaceSet);
current->add("Overrides",true,IfcUtil::Argument_ENTITY_INSTANCE,Type::IfcSurfaceStyleShading);
current->add("Opacity",true,IfcUtil::Argument_DOUBLE,Type::IfcNormalisedRatioMeasure);
current->add("Colours",false,IfcUtil::Argument_ENTITY_INSTANCE,Type::IfcColourRgbList);
current->add("ColourIndex",false,IfcUtil::Argument_AGGREGATE_OF_INT,Type::UNDEFINED);
current->add("ColourIndex",false,IfcUtil::Argument_AGGREGATE_OF_INT,Type::IfcPositiveInteger);
current = entity_descriptor_map[Type::IfcIndexedTextureMap] = new IfcEntityDescriptor(Type::IfcIndexedTextureMap,entity_descriptor_map.find(Type::IfcTextureCoordinate)->second);
current->add("MappedTo",false,IfcUtil::Argument_ENTITY_INSTANCE,Type::IfcTessellatedFaceSet);
current->add("TexCoords",false,IfcUtil::Argument_ENTITY_INSTANCE,Type::IfcTextureVertexList);
current = entity_descriptor_map[Type::IfcIndexedTriangleTextureMap] = new IfcEntityDescriptor(Type::IfcIndexedTriangleTextureMap,entity_descriptor_map.find(Type::IfcIndexedTextureMap)->second);
current->add("TexCoordIndex",true,IfcUtil::Argument_AGGREGATE_OF_AGGREGATE_OF_INT,Type::UNDEFINED);
current->add("TexCoordIndex",true,IfcUtil::Argument_AGGREGATE_OF_AGGREGATE_OF_INT,Type::IfcPositiveInteger);
current = entity_descriptor_map[Type::IfcIrregularTimeSeries] = new IfcEntityDescriptor(Type::IfcIrregularTimeSeries,entity_descriptor_map.find(Type::IfcTimeSeries)->second);
current->add("Values",false,IfcUtil::Argument_AGGREGATE_OF_ENTITY_INSTANCE,Type::IfcIrregularTimeSeriesValue);
current = entity_descriptor_map[Type::IfcLagTime] = new IfcEntityDescriptor(Type::IfcLagTime,entity_descriptor_map.find(Type::IfcSchedulingTime)->second);
@@ -1059,7 +1073,7 @@ void InitDescriptorMap() {
current->add("RelatedOrganizations",false,IfcUtil::Argument_AGGREGATE_OF_ENTITY_INSTANCE,Type::IfcOrganization);
current = entity_descriptor_map[Type::IfcOrientedEdge] = new IfcEntityDescriptor(Type::IfcOrientedEdge,entity_descriptor_map.find(Type::IfcEdge)->second);
current->add("EdgeElement",false,IfcUtil::Argument_ENTITY_INSTANCE,Type::IfcEdge);
current->add("Orientation",false,IfcUtil::Argument_BOOL,Type::UNDEFINED);
current->add("Orientation",false,IfcUtil::Argument_BOOL,Type::IfcBoolean);
current = entity_descriptor_map[Type::IfcParameterizedProfileDef] = new IfcEntityDescriptor(Type::IfcParameterizedProfileDef,entity_descriptor_map.find(Type::IfcProfileDef)->second);
current->add("Position",true,IfcUtil::Argument_ENTITY_INSTANCE,Type::IfcAxis2Placement2D);
current = entity_descriptor_map[Type::IfcPath] = new IfcEntityDescriptor(Type::IfcPath,entity_descriptor_map.find(Type::IfcTopologicalRepresentationItem)->second);
@@ -1073,7 +1087,7 @@ void InitDescriptorMap() {
current->add("Width",false,IfcUtil::Argument_INT,Type::IfcInteger);
current->add("Height",false,IfcUtil::Argument_INT,Type::IfcInteger);
current->add("ColourComponents",false,IfcUtil::Argument_INT,Type::IfcInteger);
current->add("Pixel",false,IfcUtil::Argument_AGGREGATE_OF_BINARY,Type::UNDEFINED);
current->add("Pixel",false,IfcUtil::Argument_AGGREGATE_OF_BINARY,Type::IfcBinary);
current = entity_descriptor_map[Type::IfcPlacement] = new IfcEntityDescriptor(Type::IfcPlacement,entity_descriptor_map.find(Type::IfcGeometricRepresentationItem)->second);
current->add("Location",false,IfcUtil::Argument_ENTITY_INSTANCE,Type::IfcCartesianPoint);
current = entity_descriptor_map[Type::IfcPlanarExtent] = new IfcEntityDescriptor(Type::IfcPlanarExtent,entity_descriptor_map.find(Type::IfcGeometricRepresentationItem)->second);
@@ -1146,7 +1160,7 @@ void InitDescriptorMap() {
current->add("ScheduleFinish",true,IfcUtil::Argument_STRING,Type::IfcDateTime);
current->add("ScheduleContour",true,IfcUtil::Argument_STRING,Type::IfcLabel);
current->add("LevelingDelay",true,IfcUtil::Argument_STRING,Type::IfcDuration);
current->add("IsOverAllocated",true,IfcUtil::Argument_BOOL,Type::UNDEFINED);
current->add("IsOverAllocated",true,IfcUtil::Argument_BOOL,Type::IfcBoolean);
current->add("StatusTime",true,IfcUtil::Argument_STRING,Type::IfcDateTime);
current->add("ActualWork",true,IfcUtil::Argument_STRING,Type::IfcDuration);
current->add("ActualUsage",true,IfcUtil::Argument_DOUBLE,Type::IfcPositiveRatioMeasure);
@@ -1216,7 +1230,6 @@ void InitDescriptorMap() {
current = entity_descriptor_map[Type::IfcSurface] = new IfcEntityDescriptor(Type::IfcSurface,entity_descriptor_map.find(Type::IfcGeometricRepresentationItem)->second);
current = entity_descriptor_map[Type::IfcSurfaceStyleRendering] = new IfcEntityDescriptor(Type::IfcSurfaceStyleRendering,entity_descriptor_map.find(Type::IfcSurfaceStyleShading)->second);
current->add("Transparency",true,IfcUtil::Argument_DOUBLE,Type::IfcNormalisedRatioMeasure);
current->add("DiffuseColour",true,IfcUtil::Argument_ENTITY_INSTANCE,Type::IfcColourOrFactor);
current->add("TransmissionColour",true,IfcUtil::Argument_ENTITY_INSTANCE,Type::IfcColourOrFactor);
current->add("DiffuseTransmissionColour",true,IfcUtil::Argument_ENTITY_INSTANCE,Type::IfcColourOrFactor);
@@ -1298,8 +1311,8 @@ void InitDescriptorMap() {
current = entity_descriptor_map[Type::IfcWindowStyle] = new IfcEntityDescriptor(Type::IfcWindowStyle,entity_descriptor_map.find(Type::IfcTypeProduct)->second);
current->add("ConstructionType",false,IfcUtil::Argument_ENUMERATION,Type::IfcWindowStyleConstructionEnum);
current->add("OperationType",false,IfcUtil::Argument_ENUMERATION,Type::IfcWindowStyleOperationEnum);
current->add("ParameterTakesPrecedence",false,IfcUtil::Argument_BOOL,Type::UNDEFINED);
current->add("Sizeable",false,IfcUtil::Argument_BOOL,Type::UNDEFINED);
current->add("ParameterTakesPrecedence",false,IfcUtil::Argument_BOOL,Type::IfcBoolean);
current->add("Sizeable",false,IfcUtil::Argument_BOOL,Type::IfcBoolean);
current = entity_descriptor_map[Type::IfcZShapeProfileDef] = new IfcEntityDescriptor(Type::IfcZShapeProfileDef,entity_descriptor_map.find(Type::IfcParameterizedProfileDef)->second);
current->add("Depth",false,IfcUtil::Argument_DOUBLE,Type::IfcPositiveLengthMeasure);
current->add("FlangeWidth",false,IfcUtil::Argument_DOUBLE,Type::IfcPositiveLengthMeasure);
@@ -1355,22 +1368,24 @@ void InitDescriptorMap() {
current->add("Coordinates",false,IfcUtil::Argument_AGGREGATE_OF_DOUBLE,Type::IfcLengthMeasure);
current = entity_descriptor_map[Type::IfcCartesianPointList] = new IfcEntityDescriptor(Type::IfcCartesianPointList,entity_descriptor_map.find(Type::IfcGeometricRepresentationItem)->second);
current = entity_descriptor_map[Type::IfcCartesianPointList2D] = new IfcEntityDescriptor(Type::IfcCartesianPointList2D,entity_descriptor_map.find(Type::IfcCartesianPointList)->second);
current->add("CoordList",false,IfcUtil::Argument_AGGREGATE_OF_AGGREGATE_OF_DOUBLE,Type::IfcLengthMeasure);
current = entity_descriptor_map[Type::IfcCartesianPointList3D] = new IfcEntityDescriptor(Type::IfcCartesianPointList3D,entity_descriptor_map.find(Type::IfcCartesianPointList)->second);
current->add("CoordList",false,IfcUtil::Argument_AGGREGATE_OF_AGGREGATE_OF_DOUBLE,Type::IfcLengthMeasure);
current = entity_descriptor_map[Type::IfcCartesianTransformationOperator] = new IfcEntityDescriptor(Type::IfcCartesianTransformationOperator,entity_descriptor_map.find(Type::IfcGeometricRepresentationItem)->second);
current->add("Axis1",true,IfcUtil::Argument_ENTITY_INSTANCE,Type::IfcDirection);
current->add("Axis2",true,IfcUtil::Argument_ENTITY_INSTANCE,Type::IfcDirection);
current->add("LocalOrigin",false,IfcUtil::Argument_ENTITY_INSTANCE,Type::IfcCartesianPoint);
current->add("Scale",true,IfcUtil::Argument_DOUBLE,Type::UNDEFINED);
current->add("Scale",true,IfcUtil::Argument_DOUBLE,Type::IfcReal);
current = entity_descriptor_map[Type::IfcCartesianTransformationOperator2D] = new IfcEntityDescriptor(Type::IfcCartesianTransformationOperator2D,entity_descriptor_map.find(Type::IfcCartesianTransformationOperator)->second);
current = entity_descriptor_map[Type::IfcCartesianTransformationOperator2DnonUniform] = new IfcEntityDescriptor(Type::IfcCartesianTransformationOperator2DnonUniform,entity_descriptor_map.find(Type::IfcCartesianTransformationOperator2D)->second);
current->add("Scale2",true,IfcUtil::Argument_DOUBLE,Type::UNDEFINED);
current->add("Scale2",true,IfcUtil::Argument_DOUBLE,Type::IfcReal);
current = entity_descriptor_map[Type::IfcCartesianTransformationOperator3D] = new IfcEntityDescriptor(Type::IfcCartesianTransformationOperator3D,entity_descriptor_map.find(Type::IfcCartesianTransformationOperator)->second);
current->add("Axis3",true,IfcUtil::Argument_ENTITY_INSTANCE,Type::IfcDirection);
current = entity_descriptor_map[Type::IfcCartesianTransformationOperator3DnonUniform] = new IfcEntityDescriptor(Type::IfcCartesianTransformationOperator3DnonUniform,entity_descriptor_map.find(Type::IfcCartesianTransformationOperator3D)->second);
current->add("Scale2",true,IfcUtil::Argument_DOUBLE,Type::UNDEFINED);
current->add("Scale3",true,IfcUtil::Argument_DOUBLE,Type::UNDEFINED);
current->add("Scale2",true,IfcUtil::Argument_DOUBLE,Type::IfcReal);
current->add("Scale3",true,IfcUtil::Argument_DOUBLE,Type::IfcReal);
current = entity_descriptor_map[Type::IfcCircleProfileDef] = new IfcEntityDescriptor(Type::IfcCircleProfileDef,entity_descriptor_map.find(Type::IfcParameterizedProfileDef)->second);
current->add("Radius",false,IfcUtil::Argument_DOUBLE,Type::IfcPositiveLengthMeasure);
current = entity_descriptor_map[Type::IfcClosedShell] = new IfcEntityDescriptor(Type::IfcClosedShell,entity_descriptor_map.find(Type::IfcConnectedFaceSet)->second);
@@ -1384,7 +1399,7 @@ void InitDescriptorMap() {
current->add("HasProperties",false,IfcUtil::Argument_AGGREGATE_OF_ENTITY_INSTANCE,Type::IfcProperty);
current = entity_descriptor_map[Type::IfcCompositeCurveSegment] = new IfcEntityDescriptor(Type::IfcCompositeCurveSegment,entity_descriptor_map.find(Type::IfcGeometricRepresentationItem)->second);
current->add("Transition",false,IfcUtil::Argument_ENUMERATION,Type::IfcTransitionCode);
current->add("SameSense",false,IfcUtil::Argument_BOOL,Type::UNDEFINED);
current->add("SameSense",false,IfcUtil::Argument_BOOL,Type::IfcBoolean);
current->add("ParentCurve",false,IfcUtil::Argument_ENTITY_INSTANCE,Type::IfcCurve);
current = entity_descriptor_map[Type::IfcConstructionResourceType] = new IfcEntityDescriptor(Type::IfcConstructionResourceType,entity_descriptor_map.find(Type::IfcTypeResource)->second);
current->add("BaseCosts",true,IfcUtil::Argument_AGGREGATE_OF_ENTITY_INSTANCE,Type::IfcAppliedValue);
@@ -1410,14 +1425,14 @@ void InitDescriptorMap() {
current = entity_descriptor_map[Type::IfcCurveBoundedSurface] = new IfcEntityDescriptor(Type::IfcCurveBoundedSurface,entity_descriptor_map.find(Type::IfcBoundedSurface)->second);
current->add("BasisSurface",false,IfcUtil::Argument_ENTITY_INSTANCE,Type::IfcSurface);
current->add("Boundaries",false,IfcUtil::Argument_AGGREGATE_OF_ENTITY_INSTANCE,Type::IfcBoundaryCurve);
current->add("ImplicitOuter",false,IfcUtil::Argument_BOOL,Type::UNDEFINED);
current->add("ImplicitOuter",false,IfcUtil::Argument_BOOL,Type::IfcBoolean);
current = entity_descriptor_map[Type::IfcDirection] = new IfcEntityDescriptor(Type::IfcDirection,entity_descriptor_map.find(Type::IfcGeometricRepresentationItem)->second);
current->add("DirectionRatios",false,IfcUtil::Argument_AGGREGATE_OF_DOUBLE,Type::UNDEFINED);
current->add("DirectionRatios",false,IfcUtil::Argument_AGGREGATE_OF_DOUBLE,Type::IfcReal);
current = entity_descriptor_map[Type::IfcDoorStyle] = new IfcEntityDescriptor(Type::IfcDoorStyle,entity_descriptor_map.find(Type::IfcTypeProduct)->second);
current->add("OperationType",false,IfcUtil::Argument_ENUMERATION,Type::IfcDoorStyleOperationEnum);
current->add("ConstructionType",false,IfcUtil::Argument_ENUMERATION,Type::IfcDoorStyleConstructionEnum);
current->add("ParameterTakesPrecedence",false,IfcUtil::Argument_BOOL,Type::UNDEFINED);
current->add("Sizeable",false,IfcUtil::Argument_BOOL,Type::UNDEFINED);
current->add("ParameterTakesPrecedence",false,IfcUtil::Argument_BOOL,Type::IfcBoolean);
current->add("Sizeable",false,IfcUtil::Argument_BOOL,Type::IfcBoolean);
current = entity_descriptor_map[Type::IfcEdgeLoop] = new IfcEntityDescriptor(Type::IfcEdgeLoop,entity_descriptor_map.find(Type::IfcLoop)->second);
current->add("EdgeList",false,IfcUtil::Argument_AGGREGATE_OF_ENTITY_INSTANCE,Type::IfcOrientedEdge);
current = entity_descriptor_map[Type::IfcElementQuantity] = new IfcEntityDescriptor(Type::IfcElementQuantity,entity_descriptor_map.find(Type::IfcQuantitySet)->second);
@@ -1473,6 +1488,10 @@ void InitDescriptorMap() {
current->add("FilletRadius",true,IfcUtil::Argument_DOUBLE,Type::IfcNonNegativeLengthMeasure);
current->add("FlangeEdgeRadius",true,IfcUtil::Argument_DOUBLE,Type::IfcNonNegativeLengthMeasure);
current->add("FlangeSlope",true,IfcUtil::Argument_DOUBLE,Type::IfcPlaneAngleMeasure);
current = entity_descriptor_map[Type::IfcIndexedPolygonalFace] = new IfcEntityDescriptor(Type::IfcIndexedPolygonalFace,entity_descriptor_map.find(Type::IfcTessellatedItem)->second);
current->add("CoordIndex",false,IfcUtil::Argument_AGGREGATE_OF_INT,Type::IfcPositiveInteger);
current = entity_descriptor_map[Type::IfcIndexedPolygonalFaceWithVoids] = new IfcEntityDescriptor(Type::IfcIndexedPolygonalFaceWithVoids,entity_descriptor_map.find(Type::IfcIndexedPolygonalFace)->second);
current->add("InnerCoordIndices",false,IfcUtil::Argument_AGGREGATE_OF_AGGREGATE_OF_INT,Type::IfcPositiveInteger);
current = entity_descriptor_map[Type::IfcLShapeProfileDef] = new IfcEntityDescriptor(Type::IfcLShapeProfileDef,entity_descriptor_map.find(Type::IfcParameterizedProfileDef)->second);
current->add("Depth",false,IfcUtil::Argument_DOUBLE,Type::IfcPositiveLengthMeasure);
current->add("Width",true,IfcUtil::Argument_DOUBLE,Type::IfcPositiveLengthMeasure);
@@ -1492,11 +1511,11 @@ void InitDescriptorMap() {
current = entity_descriptor_map[Type::IfcOffsetCurve2D] = new IfcEntityDescriptor(Type::IfcOffsetCurve2D,entity_descriptor_map.find(Type::IfcCurve)->second);
current->add("BasisCurve",false,IfcUtil::Argument_ENTITY_INSTANCE,Type::IfcCurve);
current->add("Distance",false,IfcUtil::Argument_DOUBLE,Type::IfcLengthMeasure);
current->add("SelfIntersect",false,IfcUtil::Argument_BOOL,Type::UNDEFINED);
current->add("SelfIntersect",false,IfcUtil::Argument_TRIBOOL,Type::IfcLogical);
current = entity_descriptor_map[Type::IfcOffsetCurve3D] = new IfcEntityDescriptor(Type::IfcOffsetCurve3D,entity_descriptor_map.find(Type::IfcCurve)->second);
current->add("BasisCurve",false,IfcUtil::Argument_ENTITY_INSTANCE,Type::IfcCurve);
current->add("Distance",false,IfcUtil::Argument_DOUBLE,Type::IfcLengthMeasure);
current->add("SelfIntersect",false,IfcUtil::Argument_BOOL,Type::UNDEFINED);
current->add("SelfIntersect",false,IfcUtil::Argument_TRIBOOL,Type::IfcLogical);
current->add("RefDirection",false,IfcUtil::Argument_ENTITY_INSTANCE,Type::IfcDirection);
current = entity_descriptor_map[Type::IfcPcurve] = new IfcEntityDescriptor(Type::IfcPcurve,entity_descriptor_map.find(Type::IfcCurve)->second);
current->add("BasisSurface",false,IfcUtil::Argument_ENTITY_INSTANCE,Type::IfcSurface);
@@ -1572,8 +1591,8 @@ void InitDescriptorMap() {
current->add("V1",false,IfcUtil::Argument_DOUBLE,Type::IfcParameterValue);
current->add("U2",false,IfcUtil::Argument_DOUBLE,Type::IfcParameterValue);
current->add("V2",false,IfcUtil::Argument_DOUBLE,Type::IfcParameterValue);
current->add("Usense",false,IfcUtil::Argument_BOOL,Type::UNDEFINED);
current->add("Vsense",false,IfcUtil::Argument_BOOL,Type::UNDEFINED);
current->add("Usense",false,IfcUtil::Argument_BOOL,Type::IfcBoolean);
current->add("Vsense",false,IfcUtil::Argument_BOOL,Type::IfcBoolean);
current = entity_descriptor_map[Type::IfcReinforcementDefinitionProperties] = new IfcEntityDescriptor(Type::IfcReinforcementDefinitionProperties,entity_descriptor_map.find(Type::IfcPreDefinedPropertySet)->second);
current->add("DefinitionType",true,IfcUtil::Argument_STRING,Type::IfcLabel);
current->add("ReinforcementSectionDefinitions",false,IfcUtil::Argument_AGGREGATE_OF_ENTITY_INSTANCE,Type::IfcSectionReinforcementProperties);
@@ -1618,8 +1637,8 @@ void InitDescriptorMap() {
current->add("RelatingElement",false,IfcUtil::Argument_ENTITY_INSTANCE,Type::IfcElement);
current->add("RelatedElement",false,IfcUtil::Argument_ENTITY_INSTANCE,Type::IfcElement);
current = entity_descriptor_map[Type::IfcRelConnectsPathElements] = new IfcEntityDescriptor(Type::IfcRelConnectsPathElements,entity_descriptor_map.find(Type::IfcRelConnectsElements)->second);
current->add("RelatingPriorities",false,IfcUtil::Argument_AGGREGATE_OF_DOUBLE,Type::UNDEFINED);
current->add("RelatedPriorities",false,IfcUtil::Argument_AGGREGATE_OF_DOUBLE,Type::UNDEFINED);
current->add("RelatingPriorities",false,IfcUtil::Argument_AGGREGATE_OF_INT,Type::IfcInteger);
current->add("RelatedPriorities",false,IfcUtil::Argument_AGGREGATE_OF_INT,Type::IfcInteger);
current->add("RelatedConnectionType",false,IfcUtil::Argument_ENUMERATION,Type::IfcConnectionTypeEnum);
current->add("RelatingConnectionType",false,IfcUtil::Argument_ENUMERATION,Type::IfcConnectionTypeEnum);
current = entity_descriptor_map[Type::IfcRelConnectsPortToElement] = new IfcEntityDescriptor(Type::IfcRelConnectsPortToElement,entity_descriptor_map.find(Type::IfcRelConnects)->second);
@@ -1683,7 +1702,7 @@ void InitDescriptorMap() {
current->add("RelatedElement",false,IfcUtil::Argument_ENTITY_INSTANCE,Type::IfcElement);
current->add("InterferenceGeometry",true,IfcUtil::Argument_ENTITY_INSTANCE,Type::IfcConnectionGeometry);
current->add("InterferenceType",true,IfcUtil::Argument_STRING,Type::IfcIdentifier);
current->add("ImpliedOrder",false,IfcUtil::Argument_BOOL,Type::UNDEFINED);
current->add("ImpliedOrder",false,IfcUtil::Argument_TRIBOOL,Type::UNDEFINED);
current = entity_descriptor_map[Type::IfcRelNests] = new IfcEntityDescriptor(Type::IfcRelNests,entity_descriptor_map.find(Type::IfcRelDecomposes)->second);
current->add("RelatingObject",false,IfcUtil::Argument_ENTITY_INSTANCE,Type::IfcObjectDefinition);
current->add("RelatedObjects",false,IfcUtil::Argument_AGGREGATE_OF_ENTITY_INSTANCE,Type::IfcObjectDefinition);
@@ -1755,6 +1774,8 @@ void InitDescriptorMap() {
current->add("LongName",true,IfcUtil::Argument_STRING,Type::IfcLabel);
current = entity_descriptor_map[Type::IfcSphere] = new IfcEntityDescriptor(Type::IfcSphere,entity_descriptor_map.find(Type::IfcCsgPrimitive3D)->second);
current->add("Radius",false,IfcUtil::Argument_DOUBLE,Type::IfcPositiveLengthMeasure);
current = entity_descriptor_map[Type::IfcSphericalSurface] = new IfcEntityDescriptor(Type::IfcSphericalSurface,entity_descriptor_map.find(Type::IfcElementarySurface)->second);
current->add("Radius",false,IfcUtil::Argument_DOUBLE,Type::IfcPositiveLengthMeasure);
current = entity_descriptor_map[Type::IfcStructuralActivity] = new IfcEntityDescriptor(Type::IfcStructuralActivity,entity_descriptor_map.find(Type::IfcProduct)->second);
current->add("AppliedLoad",false,IfcUtil::Argument_ENTITY_INSTANCE,Type::IfcStructuralLoad);
current->add("GlobalOrLocal",false,IfcUtil::Argument_ENUMERATION,Type::IfcGlobalOrLocalEnum);
@@ -1773,6 +1794,10 @@ void InitDescriptorMap() {
current->add("PredefinedType",false,IfcUtil::Argument_ENUMERATION,Type::IfcStructuralSurfaceActivityTypeEnum);
current = entity_descriptor_map[Type::IfcSubContractResourceType] = new IfcEntityDescriptor(Type::IfcSubContractResourceType,entity_descriptor_map.find(Type::IfcConstructionResourceType)->second);
current->add("PredefinedType",false,IfcUtil::Argument_ENUMERATION,Type::IfcSubContractResourceTypeEnum);
current = entity_descriptor_map[Type::IfcSurfaceCurve] = new IfcEntityDescriptor(Type::IfcSurfaceCurve,entity_descriptor_map.find(Type::IfcCurve)->second);
current->add("Curve3D",false,IfcUtil::Argument_ENTITY_INSTANCE,Type::IfcCurve);
current->add("AssociatedGeometry",false,IfcUtil::Argument_AGGREGATE_OF_ENTITY_INSTANCE,Type::IfcPcurve);
current->add("MasterRepresentation",false,IfcUtil::Argument_ENUMERATION,Type::IfcPreferredSurfaceCurveRepresentation);
current = entity_descriptor_map[Type::IfcSurfaceCurveSweptAreaSolid] = new IfcEntityDescriptor(Type::IfcSurfaceCurveSweptAreaSolid,entity_descriptor_map.find(Type::IfcSweptAreaSolid)->second);
current->add("Directrix",false,IfcUtil::Argument_ENTITY_INSTANCE,Type::IfcCurve);
current->add("StartParam",true,IfcUtil::Argument_DOUBLE,Type::IfcParameterValue);
@@ -1788,8 +1813,8 @@ void InitDescriptorMap() {
current = entity_descriptor_map[Type::IfcTask] = new IfcEntityDescriptor(Type::IfcTask,entity_descriptor_map.find(Type::IfcProcess)->second);
current->add("Status",true,IfcUtil::Argument_STRING,Type::IfcLabel);
current->add("WorkMethod",true,IfcUtil::Argument_STRING,Type::IfcLabel);
current->add("IsMilestone",false,IfcUtil::Argument_BOOL,Type::UNDEFINED);
current->add("Priority",true,IfcUtil::Argument_INT,Type::UNDEFINED);
current->add("IsMilestone",false,IfcUtil::Argument_BOOL,Type::IfcBoolean);
current->add("Priority",true,IfcUtil::Argument_INT,Type::IfcInteger);
current->add("TaskTime",true,IfcUtil::Argument_ENTITY_INSTANCE,Type::IfcTaskTime);
current->add("PredefinedType",true,IfcUtil::Argument_ENUMERATION,Type::IfcTaskTypeEnum);
current = entity_descriptor_map[Type::IfcTaskType] = new IfcEntityDescriptor(Type::IfcTaskType,entity_descriptor_map.find(Type::IfcTypeProcess)->second);
@@ -1797,13 +1822,16 @@ void InitDescriptorMap() {
current->add("WorkMethod",true,IfcUtil::Argument_STRING,Type::IfcLabel);
current = entity_descriptor_map[Type::IfcTessellatedFaceSet] = new IfcEntityDescriptor(Type::IfcTessellatedFaceSet,entity_descriptor_map.find(Type::IfcTessellatedItem)->second);
current->add("Coordinates",false,IfcUtil::Argument_ENTITY_INSTANCE,Type::IfcCartesianPointList3D);
current->add("Normals",true,IfcUtil::Argument_AGGREGATE_OF_AGGREGATE_OF_DOUBLE,Type::IfcParameterValue);
current->add("Closed",true,IfcUtil::Argument_BOOL,Type::UNDEFINED);
current = entity_descriptor_map[Type::IfcToroidalSurface] = new IfcEntityDescriptor(Type::IfcToroidalSurface,entity_descriptor_map.find(Type::IfcElementarySurface)->second);
current->add("MajorRadius",false,IfcUtil::Argument_DOUBLE,Type::IfcPositiveLengthMeasure);
current->add("MinorRadius",false,IfcUtil::Argument_DOUBLE,Type::IfcPositiveLengthMeasure);
current = entity_descriptor_map[Type::IfcTransportElementType] = new IfcEntityDescriptor(Type::IfcTransportElementType,entity_descriptor_map.find(Type::IfcElementType)->second);
current->add("PredefinedType",false,IfcUtil::Argument_ENUMERATION,Type::IfcTransportElementTypeEnum);
current = entity_descriptor_map[Type::IfcTriangulatedFaceSet] = new IfcEntityDescriptor(Type::IfcTriangulatedFaceSet,entity_descriptor_map.find(Type::IfcTessellatedFaceSet)->second);
current->add("CoordIndex",false,IfcUtil::Argument_AGGREGATE_OF_AGGREGATE_OF_INT,Type::UNDEFINED);
current->add("NormalIndex",true,IfcUtil::Argument_AGGREGATE_OF_AGGREGATE_OF_INT,Type::UNDEFINED);
current->add("Normals",true,IfcUtil::Argument_AGGREGATE_OF_AGGREGATE_OF_DOUBLE,Type::IfcParameterValue);
current->add("Closed",true,IfcUtil::Argument_BOOL,Type::IfcBoolean);
current->add("CoordIndex",false,IfcUtil::Argument_AGGREGATE_OF_AGGREGATE_OF_INT,Type::IfcPositiveInteger);
current->add("PnIndex",true,IfcUtil::Argument_AGGREGATE_OF_INT,Type::IfcPositiveInteger);
current = entity_descriptor_map[Type::IfcWindowLiningProperties] = new IfcEntityDescriptor(Type::IfcWindowLiningProperties,entity_descriptor_map.find(Type::IfcPreDefinedPropertySet)->second);
current->add("LiningDepth",true,IfcUtil::Argument_DOUBLE,Type::IfcPositiveLengthMeasure);
current->add("LiningThickness",true,IfcUtil::Argument_DOUBLE,Type::IfcNonNegativeLengthMeasure);
@@ -1832,16 +1860,16 @@ void InitDescriptorMap() {
current = entity_descriptor_map[Type::IfcAnnotation] = new IfcEntityDescriptor(Type::IfcAnnotation,entity_descriptor_map.find(Type::IfcProduct)->second);
current = entity_descriptor_map[Type::IfcBSplineSurface] = new IfcEntityDescriptor(Type::IfcBSplineSurface,entity_descriptor_map.find(Type::IfcBoundedSurface)->second);
current->add("UDegree",false,IfcUtil::Argument_INT,Type::UNDEFINED);
current->add("VDegree",false,IfcUtil::Argument_INT,Type::UNDEFINED);
current->add("UDegree",false,IfcUtil::Argument_INT,Type::IfcInteger);
current->add("VDegree",false,IfcUtil::Argument_INT,Type::IfcInteger);
current->add("ControlPointsList",false,IfcUtil::Argument_AGGREGATE_OF_AGGREGATE_OF_ENTITY_INSTANCE,Type::IfcCartesianPoint);
current->add("SurfaceForm",false,IfcUtil::Argument_ENUMERATION,Type::IfcBSplineSurfaceForm);
current->add("UClosed",false,IfcUtil::Argument_BOOL,Type::UNDEFINED);
current->add("VClosed",false,IfcUtil::Argument_BOOL,Type::UNDEFINED);
current->add("SelfIntersect",false,IfcUtil::Argument_BOOL,Type::UNDEFINED);
current->add("UClosed",false,IfcUtil::Argument_TRIBOOL,Type::IfcLogical);
current->add("VClosed",false,IfcUtil::Argument_TRIBOOL,Type::IfcLogical);
current->add("SelfIntersect",false,IfcUtil::Argument_TRIBOOL,Type::IfcLogical);
current = entity_descriptor_map[Type::IfcBSplineSurfaceWithKnots] = new IfcEntityDescriptor(Type::IfcBSplineSurfaceWithKnots,entity_descriptor_map.find(Type::IfcBSplineSurface)->second);
current->add("UMultiplicities",false,IfcUtil::Argument_AGGREGATE_OF_INT,Type::UNDEFINED);
current->add("VMultiplicities",false,IfcUtil::Argument_AGGREGATE_OF_INT,Type::UNDEFINED);
current->add("UMultiplicities",false,IfcUtil::Argument_AGGREGATE_OF_INT,Type::IfcInteger);
current->add("VMultiplicities",false,IfcUtil::Argument_AGGREGATE_OF_INT,Type::IfcInteger);
current->add("UKnots",false,IfcUtil::Argument_AGGREGATE_OF_DOUBLE,Type::IfcParameterValue);
current->add("VKnots",false,IfcUtil::Argument_AGGREGATE_OF_DOUBLE,Type::IfcParameterValue);
current->add("KnotSpec",false,IfcUtil::Argument_ENUMERATION,Type::IfcKnotType);
@@ -1875,7 +1903,7 @@ void InitDescriptorMap() {
current->add("HasPropertyTemplates",true,IfcUtil::Argument_AGGREGATE_OF_ENTITY_INSTANCE,Type::IfcPropertyTemplate);
current = entity_descriptor_map[Type::IfcCompositeCurve] = new IfcEntityDescriptor(Type::IfcCompositeCurve,entity_descriptor_map.find(Type::IfcBoundedCurve)->second);
current->add("Segments",false,IfcUtil::Argument_AGGREGATE_OF_ENTITY_INSTANCE,Type::IfcCompositeCurveSegment);
current->add("SelfIntersect",false,IfcUtil::Argument_BOOL,Type::UNDEFINED);
current->add("SelfIntersect",false,IfcUtil::Argument_TRIBOOL,Type::IfcLogical);
current = entity_descriptor_map[Type::IfcCompositeCurveOnSurface] = new IfcEntityDescriptor(Type::IfcCompositeCurveOnSurface,entity_descriptor_map.find(Type::IfcCompositeCurve)->second);
current = entity_descriptor_map[Type::IfcConic] = new IfcEntityDescriptor(Type::IfcConic,entity_descriptor_map.find(Type::IfcCurve)->second);
@@ -1936,7 +1964,7 @@ void InitDescriptorMap() {
current = entity_descriptor_map[Type::IfcDoorType] = new IfcEntityDescriptor(Type::IfcDoorType,entity_descriptor_map.find(Type::IfcBuildingElementType)->second);
current->add("PredefinedType",false,IfcUtil::Argument_ENUMERATION,Type::IfcDoorTypeEnum);
current->add("OperationType",false,IfcUtil::Argument_ENUMERATION,Type::IfcDoorTypeOperationEnum);
current->add("ParameterTakesPrecedence",true,IfcUtil::Argument_BOOL,Type::UNDEFINED);
current->add("ParameterTakesPrecedence",true,IfcUtil::Argument_BOOL,Type::IfcBoolean);
current->add("UserDefinedOperationType",true,IfcUtil::Argument_STRING,Type::IfcLabel);
current = entity_descriptor_map[Type::IfcDraughtingPreDefinedColour] = new IfcEntityDescriptor(Type::IfcDraughtingPreDefinedColour,entity_descriptor_map.find(Type::IfcPreDefinedColour)->second);
@@ -2020,8 +2048,14 @@ void InitDescriptorMap() {
current->add("PredefinedType",false,IfcUtil::Argument_ENUMERATION,Type::IfcHeatExchangerTypeEnum);
current = entity_descriptor_map[Type::IfcHumidifierType] = new IfcEntityDescriptor(Type::IfcHumidifierType,entity_descriptor_map.find(Type::IfcEnergyConversionDeviceType)->second);
current->add("PredefinedType",false,IfcUtil::Argument_ENUMERATION,Type::IfcHumidifierTypeEnum);
current = entity_descriptor_map[Type::IfcIndexedPolyCurve] = new IfcEntityDescriptor(Type::IfcIndexedPolyCurve,entity_descriptor_map.find(Type::IfcBoundedCurve)->second);
current->add("Points",false,IfcUtil::Argument_ENTITY_INSTANCE,Type::IfcCartesianPointList);
current->add("Segments",true,IfcUtil::Argument_AGGREGATE_OF_ENTITY_INSTANCE,Type::IfcSegmentIndexSelect);
current->add("SelfIntersect",true,IfcUtil::Argument_BOOL,Type::IfcBoolean);
current = entity_descriptor_map[Type::IfcInterceptorType] = new IfcEntityDescriptor(Type::IfcInterceptorType,entity_descriptor_map.find(Type::IfcFlowTreatmentDeviceType)->second);
current->add("PredefinedType",false,IfcUtil::Argument_ENUMERATION,Type::IfcInterceptorTypeEnum);
current = entity_descriptor_map[Type::IfcIntersectionCurve] = new IfcEntityDescriptor(Type::IfcIntersectionCurve,entity_descriptor_map.find(Type::IfcSurfaceCurve)->second);
current = entity_descriptor_map[Type::IfcInventory] = new IfcEntityDescriptor(Type::IfcInventory,entity_descriptor_map.find(Type::IfcGroup)->second);
current->add("PredefinedType",true,IfcUtil::Argument_ENUMERATION,Type::IfcInventoryTypeEnum);
current->add("Jurisdiction",true,IfcUtil::Argument_ENTITY_INSTANCE,Type::IfcActorSelect);
@@ -2080,6 +2114,10 @@ void InitDescriptorMap() {
current->add("PredefinedType",false,IfcUtil::Argument_ENUMERATION,Type::IfcPipeSegmentTypeEnum);
current = entity_descriptor_map[Type::IfcPlateType] = new IfcEntityDescriptor(Type::IfcPlateType,entity_descriptor_map.find(Type::IfcBuildingElementType)->second);
current->add("PredefinedType",false,IfcUtil::Argument_ENUMERATION,Type::IfcPlateTypeEnum);
current = entity_descriptor_map[Type::IfcPolygonalFaceSet] = new IfcEntityDescriptor(Type::IfcPolygonalFaceSet,entity_descriptor_map.find(Type::IfcTessellatedFaceSet)->second);
current->add("Closed",true,IfcUtil::Argument_BOOL,Type::IfcBoolean);
current->add("Faces",false,IfcUtil::Argument_AGGREGATE_OF_ENTITY_INSTANCE,Type::IfcIndexedPolygonalFace);
current->add("PnIndex",true,IfcUtil::Argument_AGGREGATE_OF_INT,Type::IfcPositiveInteger);
current = entity_descriptor_map[Type::IfcPolyline] = new IfcEntityDescriptor(Type::IfcPolyline,entity_descriptor_map.find(Type::IfcBoundedCurve)->second);
current->add("Points",false,IfcUtil::Argument_AGGREGATE_OF_ENTITY_INSTANCE,Type::IfcCartesianPoint);
current = entity_descriptor_map[Type::IfcPort] = new IfcEntityDescriptor(Type::IfcPort,entity_descriptor_map.find(Type::IfcProduct)->second);
@@ -2103,7 +2141,7 @@ void InitDescriptorMap() {
current = entity_descriptor_map[Type::IfcRampType] = new IfcEntityDescriptor(Type::IfcRampType,entity_descriptor_map.find(Type::IfcBuildingElementType)->second);
current->add("PredefinedType",false,IfcUtil::Argument_ENUMERATION,Type::IfcRampTypeEnum);
current = entity_descriptor_map[Type::IfcRationalBSplineSurfaceWithKnots] = new IfcEntityDescriptor(Type::IfcRationalBSplineSurfaceWithKnots,entity_descriptor_map.find(Type::IfcBSplineSurfaceWithKnots)->second);
current->add("WeightsData",false,IfcUtil::Argument_AGGREGATE_OF_AGGREGATE_OF_DOUBLE,Type::UNDEFINED);
current->add("WeightsData",false,IfcUtil::Argument_AGGREGATE_OF_AGGREGATE_OF_DOUBLE,Type::IfcReal);
current = entity_descriptor_map[Type::IfcReinforcingElement] = new IfcEntityDescriptor(Type::IfcReinforcingElement,entity_descriptor_map.find(Type::IfcElementComponent)->second);
current->add("SteelGrade",true,IfcUtil::Argument_STRING,Type::IfcLabel);
current = entity_descriptor_map[Type::IfcReinforcingElementType] = new IfcEntityDescriptor(Type::IfcReinforcingElementType,entity_descriptor_map.find(Type::IfcElementComponentType)->second);
@@ -2137,6 +2175,8 @@ void InitDescriptorMap() {
current->add("PredefinedType",false,IfcUtil::Argument_ENUMERATION,Type::IfcRoofTypeEnum);
current = entity_descriptor_map[Type::IfcSanitaryTerminalType] = new IfcEntityDescriptor(Type::IfcSanitaryTerminalType,entity_descriptor_map.find(Type::IfcFlowTerminalType)->second);
current->add("PredefinedType",false,IfcUtil::Argument_ENUMERATION,Type::IfcSanitaryTerminalTypeEnum);
current = entity_descriptor_map[Type::IfcSeamCurve] = new IfcEntityDescriptor(Type::IfcSeamCurve,entity_descriptor_map.find(Type::IfcSurfaceCurve)->second);
current = entity_descriptor_map[Type::IfcShadingDeviceType] = new IfcEntityDescriptor(Type::IfcShadingDeviceType,entity_descriptor_map.find(Type::IfcBuildingElementType)->second);
current->add("PredefinedType",false,IfcUtil::Argument_ENUMERATION,Type::IfcShadingDeviceTypeEnum);
current = entity_descriptor_map[Type::IfcSite] = new IfcEntityDescriptor(Type::IfcSite,entity_descriptor_map.find(Type::IfcSpatialStructureElement)->second);
@@ -2164,7 +2204,7 @@ void InitDescriptorMap() {
current = entity_descriptor_map[Type::IfcStairType] = new IfcEntityDescriptor(Type::IfcStairType,entity_descriptor_map.find(Type::IfcBuildingElementType)->second);
current->add("PredefinedType",false,IfcUtil::Argument_ENUMERATION,Type::IfcStairTypeEnum);
current = entity_descriptor_map[Type::IfcStructuralAction] = new IfcEntityDescriptor(Type::IfcStructuralAction,entity_descriptor_map.find(Type::IfcStructuralActivity)->second);
current->add("DestabilizingLoad",true,IfcUtil::Argument_BOOL,Type::UNDEFINED);
current->add("DestabilizingLoad",true,IfcUtil::Argument_BOOL,Type::IfcBoolean);
current = entity_descriptor_map[Type::IfcStructuralConnection] = new IfcEntityDescriptor(Type::IfcStructuralConnection,entity_descriptor_map.find(Type::IfcStructuralItem)->second);
current->add("AppliedCondition",true,IfcUtil::Argument_ENTITY_INSTANCE,Type::IfcBoundaryCondition);
current = entity_descriptor_map[Type::IfcStructuralCurveAction] = new IfcEntityDescriptor(Type::IfcStructuralCurveAction,entity_descriptor_map.find(Type::IfcStructuralAction)->second);
@@ -2196,7 +2236,7 @@ void InitDescriptorMap() {
current = entity_descriptor_map[Type::IfcStructuralResultGroup] = new IfcEntityDescriptor(Type::IfcStructuralResultGroup,entity_descriptor_map.find(Type::IfcGroup)->second);
current->add("TheoryType",false,IfcUtil::Argument_ENUMERATION,Type::IfcAnalysisTheoryTypeEnum);
current->add("ResultForLoadGroup",true,IfcUtil::Argument_ENTITY_INSTANCE,Type::IfcStructuralLoadGroup);
current->add("IsLinear",false,IfcUtil::Argument_BOOL,Type::UNDEFINED);
current->add("IsLinear",false,IfcUtil::Argument_BOOL,Type::IfcBoolean);
current = entity_descriptor_map[Type::IfcStructuralSurfaceAction] = new IfcEntityDescriptor(Type::IfcStructuralSurfaceAction,entity_descriptor_map.find(Type::IfcStructuralAction)->second);
current->add("ProjectedOrTrue",true,IfcUtil::Argument_ENUMERATION,Type::IfcProjectedOrTrueLengthEnum);
current->add("PredefinedType",false,IfcUtil::Argument_ENUMERATION,Type::IfcStructuralSurfaceActivityTypeEnum);
@@ -2231,7 +2271,7 @@ void InitDescriptorMap() {
current->add("PredefinedType",false,IfcUtil::Argument_ENUMERATION,Type::IfcTendonTypeEnum);
current->add("NominalDiameter",true,IfcUtil::Argument_DOUBLE,Type::IfcPositiveLengthMeasure);
current->add("CrossSectionArea",true,IfcUtil::Argument_DOUBLE,Type::IfcAreaMeasure);
current->add("SheethDiameter",true,IfcUtil::Argument_DOUBLE,Type::IfcPositiveLengthMeasure);
current->add("SheathDiameter",true,IfcUtil::Argument_DOUBLE,Type::IfcPositiveLengthMeasure);
current = entity_descriptor_map[Type::IfcTransformerType] = new IfcEntityDescriptor(Type::IfcTransformerType,entity_descriptor_map.find(Type::IfcEnergyConversionDeviceType)->second);
current->add("PredefinedType",false,IfcUtil::Argument_ENUMERATION,Type::IfcTransformerTypeEnum);
current = entity_descriptor_map[Type::IfcTransportElement] = new IfcEntityDescriptor(Type::IfcTransportElement,entity_descriptor_map.find(Type::IfcElement)->second);
@@ -2240,7 +2280,7 @@ void InitDescriptorMap() {
current->add("BasisCurve",false,IfcUtil::Argument_ENTITY_INSTANCE,Type::IfcCurve);
current->add("Trim1",false,IfcUtil::Argument_AGGREGATE_OF_ENTITY_INSTANCE,Type::IfcTrimmingSelect);
current->add("Trim2",false,IfcUtil::Argument_AGGREGATE_OF_ENTITY_INSTANCE,Type::IfcTrimmingSelect);
current->add("SenseAgreement",false,IfcUtil::Argument_BOOL,Type::UNDEFINED);
current->add("SenseAgreement",false,IfcUtil::Argument_BOOL,Type::IfcBoolean);
current->add("MasterRepresentation",false,IfcUtil::Argument_ENUMERATION,Type::IfcTrimmingPreference);
current = entity_descriptor_map[Type::IfcTubeBundleType] = new IfcEntityDescriptor(Type::IfcTubeBundleType,entity_descriptor_map.find(Type::IfcEnergyConversionDeviceType)->second);
current->add("PredefinedType",false,IfcUtil::Argument_ENUMERATION,Type::IfcTubeBundleTypeEnum);
@@ -2263,7 +2303,7 @@ void InitDescriptorMap() {
current = entity_descriptor_map[Type::IfcWindowType] = new IfcEntityDescriptor(Type::IfcWindowType,entity_descriptor_map.find(Type::IfcBuildingElementType)->second);
current->add("PredefinedType",false,IfcUtil::Argument_ENUMERATION,Type::IfcWindowTypeEnum);
current->add("PartitioningType",false,IfcUtil::Argument_ENUMERATION,Type::IfcWindowTypePartitioningEnum);
current->add("ParameterTakesPrecedence",true,IfcUtil::Argument_BOOL,Type::UNDEFINED);
current->add("ParameterTakesPrecedence",true,IfcUtil::Argument_BOOL,Type::IfcBoolean);
current->add("UserDefinedPartitioningType",true,IfcUtil::Argument_STRING,Type::IfcLabel);
current = entity_descriptor_map[Type::IfcWorkCalendar] = new IfcEntityDescriptor(Type::IfcWorkCalendar,entity_descriptor_map.find(Type::IfcControl)->second);
current->add("WorkingTimes",true,IfcUtil::Argument_AGGREGATE_OF_ENTITY_INSTANCE,Type::IfcWorkTime);
@@ -2306,13 +2346,13 @@ void InitDescriptorMap() {
current = entity_descriptor_map[Type::IfcAudioVisualApplianceType] = new IfcEntityDescriptor(Type::IfcAudioVisualApplianceType,entity_descriptor_map.find(Type::IfcFlowTerminalType)->second);
current->add("PredefinedType",false,IfcUtil::Argument_ENUMERATION,Type::IfcAudioVisualApplianceTypeEnum);
current = entity_descriptor_map[Type::IfcBSplineCurve] = new IfcEntityDescriptor(Type::IfcBSplineCurve,entity_descriptor_map.find(Type::IfcBoundedCurve)->second);
current->add("Degree",false,IfcUtil::Argument_INT,Type::UNDEFINED);
current->add("Degree",false,IfcUtil::Argument_INT,Type::IfcInteger);
current->add("ControlPointsList",false,IfcUtil::Argument_AGGREGATE_OF_ENTITY_INSTANCE,Type::IfcCartesianPoint);
current->add("CurveForm",false,IfcUtil::Argument_ENUMERATION,Type::IfcBSplineCurveForm);
current->add("ClosedCurve",false,IfcUtil::Argument_BOOL,Type::UNDEFINED);
current->add("SelfIntersect",false,IfcUtil::Argument_BOOL,Type::UNDEFINED);
current->add("ClosedCurve",false,IfcUtil::Argument_TRIBOOL,Type::IfcLogical);
current->add("SelfIntersect",false,IfcUtil::Argument_TRIBOOL,Type::IfcLogical);
current = entity_descriptor_map[Type::IfcBSplineCurveWithKnots] = new IfcEntityDescriptor(Type::IfcBSplineCurveWithKnots,entity_descriptor_map.find(Type::IfcBSplineCurve)->second);
current->add("KnotMultiplicities",false,IfcUtil::Argument_AGGREGATE_OF_INT,Type::UNDEFINED);
current->add("KnotMultiplicities",false,IfcUtil::Argument_AGGREGATE_OF_INT,Type::IfcInteger);
current->add("Knots",false,IfcUtil::Argument_AGGREGATE_OF_DOUBLE,Type::IfcParameterValue);
current->add("KnotSpec",false,IfcUtil::Argument_ENUMERATION,Type::IfcKnotType);
current = entity_descriptor_map[Type::IfcBeamType] = new IfcEntityDescriptor(Type::IfcBeamType,entity_descriptor_map.find(Type::IfcBuildingElementType)->second);
@@ -2333,6 +2373,7 @@ void InitDescriptorMap() {
current->add("PredefinedType",false,IfcUtil::Argument_ENUMERATION,Type::IfcBuildingElementProxyTypeEnum);
current = entity_descriptor_map[Type::IfcBuildingSystem] = new IfcEntityDescriptor(Type::IfcBuildingSystem,entity_descriptor_map.find(Type::IfcSystem)->second);
current->add("PredefinedType",true,IfcUtil::Argument_ENUMERATION,Type::IfcBuildingSystemTypeEnum);
current->add("LongName",true,IfcUtil::Argument_STRING,Type::IfcLabel);
current = entity_descriptor_map[Type::IfcBurnerType] = new IfcEntityDescriptor(Type::IfcBurnerType,entity_descriptor_map.find(Type::IfcEnergyConversionDeviceType)->second);
current->add("PredefinedType",false,IfcUtil::Argument_ENUMERATION,Type::IfcBurnerTypeEnum);
current = entity_descriptor_map[Type::IfcCableCarrierFittingType] = new IfcEntityDescriptor(Type::IfcCableCarrierFittingType,entity_descriptor_map.find(Type::IfcFlowFittingType)->second);
@@ -2508,7 +2549,7 @@ void InitDescriptorMap() {
current = entity_descriptor_map[Type::IfcRampFlight] = new IfcEntityDescriptor(Type::IfcRampFlight,entity_descriptor_map.find(Type::IfcBuildingElement)->second);
current->add("PredefinedType",true,IfcUtil::Argument_ENUMERATION,Type::IfcRampFlightTypeEnum);
current = entity_descriptor_map[Type::IfcRationalBSplineCurveWithKnots] = new IfcEntityDescriptor(Type::IfcRationalBSplineCurveWithKnots,entity_descriptor_map.find(Type::IfcBSplineCurveWithKnots)->second);
current->add("WeightsData",false,IfcUtil::Argument_AGGREGATE_OF_DOUBLE,Type::UNDEFINED);
current->add("WeightsData",false,IfcUtil::Argument_AGGREGATE_OF_DOUBLE,Type::IfcReal);
current = entity_descriptor_map[Type::IfcReinforcingBar] = new IfcEntityDescriptor(Type::IfcReinforcingBar,entity_descriptor_map.find(Type::IfcReinforcingElement)->second);
current->add("NominalDiameter",true,IfcUtil::Argument_DOUBLE,Type::IfcPositiveLengthMeasure);
current->add("CrossSectionArea",true,IfcUtil::Argument_DOUBLE,Type::IfcAreaMeasure);
@@ -2546,8 +2587,8 @@ void InitDescriptorMap() {
current = entity_descriptor_map[Type::IfcStair] = new IfcEntityDescriptor(Type::IfcStair,entity_descriptor_map.find(Type::IfcBuildingElement)->second);
current->add("PredefinedType",true,IfcUtil::Argument_ENUMERATION,Type::IfcStairTypeEnum);
current = entity_descriptor_map[Type::IfcStairFlight] = new IfcEntityDescriptor(Type::IfcStairFlight,entity_descriptor_map.find(Type::IfcBuildingElement)->second);
current->add("NumberOfRiser",true,IfcUtil::Argument_INT,Type::UNDEFINED);
current->add("NumberOfTreads",true,IfcUtil::Argument_INT,Type::UNDEFINED);
current->add("NumberOfRisers",true,IfcUtil::Argument_INT,Type::IfcInteger);
current->add("NumberOfTreads",true,IfcUtil::Argument_INT,Type::IfcInteger);
current->add("RiserHeight",true,IfcUtil::Argument_DOUBLE,Type::IfcPositiveLengthMeasure);
current->add("TreadLength",true,IfcUtil::Argument_DOUBLE,Type::IfcPositiveLengthMeasure);
current->add("PredefinedType",true,IfcUtil::Argument_ENUMERATION,Type::IfcStairFlightTypeEnum);
@@ -2889,6 +2930,7 @@ void InitDescriptorMap() {
values.push_back("ELEMENT");
values.push_back("PARTIAL");
values.push_back("PROVISIONFORVOID");
values.push_back("PROVISIONFORSPACE");
values.push_back("USERDEFINED");
values.push_back("NOTDEFINED");
current_enum = enumeration_descriptor_map[Type::IfcBuildingElementProxyTypeEnum] = new IfcEnumerationDescriptor(Type::IfcBuildingElementProxyTypeEnum, values);
@@ -3533,7 +3575,7 @@ void InitDescriptorMap() {
values.push_back("EXTERNAL_WATER");
values.push_back("EXTERNAL_FIRE");
values.push_back("USERDEFINED");
values.push_back("NOTDEFIEND");
values.push_back("NOTDEFINED");
current_enum = enumeration_descriptor_map[Type::IfcExternalSpatialElementTypeEnum] = new IfcEnumerationDescriptor(Type::IfcExternalSpatialElementTypeEnum, values);
values.clear(); values.reserve(128);
values.push_back("CENTRIFUGALFORWARDCURVED");
@@ -3953,6 +3995,11 @@ void InitDescriptorMap() {
values.push_back("NOTDEFINED");
current_enum = enumeration_descriptor_map[Type::IfcPlateTypeEnum] = new IfcEnumerationDescriptor(Type::IfcPlateTypeEnum, values);
values.clear(); values.reserve(128);
values.push_back("CURVE3D");
values.push_back("PCURVE_S1");
values.push_back("PCURVE_S2");
current_enum = enumeration_descriptor_map[Type::IfcPreferredSurfaceCurveRepresentation] = new IfcEnumerationDescriptor(Type::IfcPreferredSurfaceCurveRepresentation, values);
values.clear(); values.reserve(128);
values.push_back("ADVICE_CAUTION");
values.push_back("ADVICE_NOTE");
values.push_back("ADVICE_WARNING");
@@ -4212,13 +4259,17 @@ void InitDescriptorMap() {
values.push_back("TAPERED");
current_enum = enumeration_descriptor_map[Type::IfcSectionTypeEnum] = new IfcEnumerationDescriptor(Type::IfcSectionTypeEnum, values);
values.clear(); values.reserve(128);
values.push_back("COSENSOR");
values.push_back("CO2SENSOR");
values.push_back("CONDUCTANCESENSOR");
values.push_back("CONTACTSENSOR");
values.push_back("FIRESENSOR");
values.push_back("FLOWSENSOR");
values.push_back("FROSTSENSOR");
values.push_back("GASSENSOR");
values.push_back("HEATSENSOR");
values.push_back("HUMIDITYSENSOR");
values.push_back("IDENTIFIERSENSOR");
values.push_back("IONCONCENTRATIONSENSOR");
values.push_back("LEVELSENSOR");
values.push_back("LIGHTSENSOR");
@@ -4722,10 +4773,6 @@ void InitDescriptorMap() {
current_enum = enumeration_descriptor_map[Type::IfcWorkScheduleTypeEnum] = new IfcEnumerationDescriptor(Type::IfcWorkScheduleTypeEnum, values);
}
#ifdef _MSC_VER
# pragma optimize( "", on )
#endif
void InitInverseMap() {
inverse_map[Type::IfcActor].insert(std::make_pair("IsActingUpon", std::make_pair(Type::IfcRelAssignsToActor, 6)));
inverse_map[Type::IfcActorRole].insert(std::make_pair("HasExternalReference", std::make_pair(Type::IfcExternalReferenceRelationship, 3)));
@@ -4738,7 +4785,6 @@ void InitInverseMap() {
inverse_map[Type::IfcApproval].insert(std::make_pair("ApprovedResources", std::make_pair(Type::IfcResourceApprovalRelationship, 3)));
inverse_map[Type::IfcApproval].insert(std::make_pair("IsRelatedWith", std::make_pair(Type::IfcApprovalRelationship, 3)));
inverse_map[Type::IfcApproval].insert(std::make_pair("Relates", std::make_pair(Type::IfcApprovalRelationship, 2)));
inverse_map[Type::IfcBuildingElement].insert(std::make_pair("HasCoverings", std::make_pair(Type::IfcRelCoversBldgElements, 4)));
inverse_map[Type::IfcClassification].insert(std::make_pair("ClassificationForObjects", std::make_pair(Type::IfcRelAssociatesClassification, 5)));
inverse_map[Type::IfcClassification].insert(std::make_pair("HasReferences", std::make_pair(Type::IfcClassificationReference, 3)));
inverse_map[Type::IfcClassificationReference].insert(std::make_pair("ClassificationRefForObjects", std::make_pair(Type::IfcRelAssociatesClassification, 5)));
@@ -4751,6 +4797,7 @@ void InitInverseMap() {
inverse_map[Type::IfcContextDependentUnit].insert(std::make_pair("HasExternalReference", std::make_pair(Type::IfcExternalReferenceRelationship, 3)));
inverse_map[Type::IfcControl].insert(std::make_pair("Controls", std::make_pair(Type::IfcRelAssignsToControl, 6)));
inverse_map[Type::IfcConversionBasedUnit].insert(std::make_pair("HasExternalReference", std::make_pair(Type::IfcExternalReferenceRelationship, 3)));
inverse_map[Type::IfcCoordinateReferenceSystem].insert(std::make_pair("HasCoordinateOperation", std::make_pair(Type::IfcCoordinateOperation, 0)));
inverse_map[Type::IfcCovering].insert(std::make_pair("CoversSpaces", std::make_pair(Type::IfcRelCoversSpaces, 5)));
inverse_map[Type::IfcCovering].insert(std::make_pair("CoversElements", std::make_pair(Type::IfcRelCoversBldgElements, 5)));
inverse_map[Type::IfcDistributionControlElement].insert(std::make_pair("AssignedToFlowElement", std::make_pair(Type::IfcRelFlowControlElements, 4)));
@@ -4772,18 +4819,21 @@ void InitInverseMap() {
inverse_map[Type::IfcElement].insert(std::make_pair("ProvidesBoundaries", std::make_pair(Type::IfcRelSpaceBoundary, 5)));
inverse_map[Type::IfcElement].insert(std::make_pair("ConnectedFrom", std::make_pair(Type::IfcRelConnectsElements, 6)));
inverse_map[Type::IfcElement].insert(std::make_pair("ContainedInStructure", std::make_pair(Type::IfcRelContainedInSpatialStructure, 4)));
inverse_map[Type::IfcElement].insert(std::make_pair("HasCoverings", std::make_pair(Type::IfcRelCoversBldgElements, 4)));
inverse_map[Type::IfcExternalReference].insert(std::make_pair("ExternalReferenceForResources", std::make_pair(Type::IfcExternalReferenceRelationship, 2)));
inverse_map[Type::IfcExternalSpatialElement].insert(std::make_pair("BoundedBy", std::make_pair(Type::IfcRelSpaceBoundary, 4)));
inverse_map[Type::IfcFace].insert(std::make_pair("HasTextureMaps", std::make_pair(Type::IfcTextureMap, 2)));
inverse_map[Type::IfcFeatureElementAddition].insert(std::make_pair("ProjectsElements", std::make_pair(Type::IfcRelProjectsElement, 5)));
inverse_map[Type::IfcFeatureElementSubtraction].insert(std::make_pair("VoidsElements", std::make_pair(Type::IfcRelVoidsElement, 5)));
inverse_map[Type::IfcGeometricRepresentationContext].insert(std::make_pair("HasSubContexts", std::make_pair(Type::IfcGeometricRepresentationSubContext, 6)));
inverse_map[Type::IfcGeometricRepresentationContext].insert(std::make_pair("HasCoordinateOperation", std::make_pair(Type::IfcCoordinateOperation, 0)));
inverse_map[Type::IfcGrid].insert(std::make_pair("ContainedInStructure", std::make_pair(Type::IfcRelContainedInSpatialStructure, 4)));
inverse_map[Type::IfcGridAxis].insert(std::make_pair("PartOfW", std::make_pair(Type::IfcGrid, 9)));
inverse_map[Type::IfcGridAxis].insert(std::make_pair("PartOfV", std::make_pair(Type::IfcGrid, 8)));
inverse_map[Type::IfcGridAxis].insert(std::make_pair("PartOfU", std::make_pair(Type::IfcGrid, 7)));
inverse_map[Type::IfcGridAxis].insert(std::make_pair("HasIntersections", std::make_pair(Type::IfcVirtualGridIntersection, 0)));
inverse_map[Type::IfcGroup].insert(std::make_pair("IsGroupedBy", std::make_pair(Type::IfcRelAssignsToGroup, 6)));
inverse_map[Type::IfcIndexedPolygonalFace].insert(std::make_pair("ToFaceSet", std::make_pair(Type::IfcPolygonalFaceSet, 2)));
inverse_map[Type::IfcLibraryInformation].insert(std::make_pair("LibraryInfoForObjects", std::make_pair(Type::IfcRelAssociatesLibrary, 5)));
inverse_map[Type::IfcLibraryInformation].insert(std::make_pair("HasLibraryReferences", std::make_pair(Type::IfcLibraryReference, 5)));
inverse_map[Type::IfcLibraryReference].insert(std::make_pair("LibraryRefForObjects", std::make_pair(Type::IfcRelAssociatesLibrary, 5)));
@@ -4832,6 +4882,8 @@ void InitInverseMap() {
inverse_map[Type::IfcProperty].insert(std::make_pair("PropertyForDependance", std::make_pair(Type::IfcPropertyDependencyRelationship, 2)));
inverse_map[Type::IfcProperty].insert(std::make_pair("PropertyDependsOn", std::make_pair(Type::IfcPropertyDependencyRelationship, 3)));
inverse_map[Type::IfcProperty].insert(std::make_pair("PartOfComplex", std::make_pair(Type::IfcComplexProperty, 3)));
inverse_map[Type::IfcProperty].insert(std::make_pair("HasConstraints", std::make_pair(Type::IfcResourceConstraintRelationship, 3)));
inverse_map[Type::IfcProperty].insert(std::make_pair("HasApprovals", std::make_pair(Type::IfcResourceApprovalRelationship, 2)));
inverse_map[Type::IfcPropertyAbstraction].insert(std::make_pair("HasExternalReferences", std::make_pair(Type::IfcExternalReferenceRelationship, 3)));
inverse_map[Type::IfcPropertyDefinition].insert(std::make_pair("HasContext", std::make_pair(Type::IfcRelDeclares, 5)));
inverse_map[Type::IfcPropertyDefinition].insert(std::make_pair("HasAssociations", std::make_pair(Type::IfcRelAssociates, 4)));
@@ -4868,7 +4920,6 @@ void InitInverseMap() {
inverse_map[Type::IfcSurfaceTexture].insert(std::make_pair("IsMappedBy", std::make_pair(Type::IfcTextureCoordinate, 0)));
inverse_map[Type::IfcSurfaceTexture].insert(std::make_pair("UsedInStyles", std::make_pair(Type::IfcSurfaceStyleWithTextures, 0)));
inverse_map[Type::IfcSystem].insert(std::make_pair("ServicesBuildings", std::make_pair(Type::IfcRelServicesBuildings, 4)));
inverse_map[Type::IfcTableRow].insert(std::make_pair("OfTable", std::make_pair(Type::IfcTable, 1)));
inverse_map[Type::IfcTessellatedFaceSet].insert(std::make_pair("HasColours", std::make_pair(Type::IfcIndexedColourMap, 0)));
inverse_map[Type::IfcTessellatedFaceSet].insert(std::make_pair("HasTextures", std::make_pair(Type::IfcIndexedTextureMap, 1)));
inverse_map[Type::IfcTimeSeries].insert(std::make_pair("HasExternalReference", std::make_pair(Type::IfcExternalReferenceRelationship, 3)));
@@ -4885,6 +4936,13 @@ void InitDerivedMap() {
{std::set<int> idxs; idxs.insert(0); derived_map[Type::IfcSIUnit] = idxs;}
}
#if defined(__clang__)
#elif defined(__GNUC__) || defined(__GNUG__)
#pragma GCC pop_options
#elif defined(_MSC_VER)
#pragma optimize("", on)
#endif
int Type::GetAttributeIndex(Enum t, const std::string& a) {
if (entity_descriptor_map.empty()) ::InitDescriptorMap();
std::map<Type::Enum,IfcEntityDescriptor*>::const_iterator i = entity_descriptor_map.find(t);
+3
View File
@@ -24,6 +24,8 @@
* *
********************************************************************************/
#ifdef USE_IFC4
#ifndef IFC4RT_H
#define IFC4RT_H
@@ -49,3 +51,4 @@ namespace Type {
}}
#endif
#endif
File diff suppressed because it is too large Load Diff
+9421 -7906
View File
File diff suppressed because one or more lines are too long
+1684 -6521
View File
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
+7 -4
View File
@@ -23,6 +23,7 @@
#include <map>
#include <set>
#include "../ifcparse/Hdf5Settings.h"
#include "../ifcparse/IfcParse.h"
#include "../ifcparse/IfcSpfHeader.h"
@@ -36,18 +37,18 @@ public:
typedef std::map<unsigned int, IfcUtil::IfcBaseClass*> entity_by_id_t;
typedef std::map<std::string, IfcSchema::IfcRoot*> entity_by_guid_t;
typedef std::map<unsigned int, IfcEntityList::ptr> entities_by_ref_t;
typedef std::map<unsigned int, unsigned int> offset_by_id_t;
typedef entity_by_id_t::const_iterator const_iterator;
private:
typedef std::map<IfcUtil::IfcBaseClass*, IfcUtil::IfcBaseClass*> entity_entity_map_t;
const schema_definition* schema_;
bool _create_latebound_entities;
entity_by_id_t byid;
entities_by_type_t bytype;
entities_by_ref_t byref;
entity_by_guid_t byguid;
offset_by_id_t offsets;
entity_entity_map_t entity_file_map;
@@ -126,11 +127,13 @@ public:
const IfcSpfHeader& header() const { return _header; }
IfcSpfHeader& header() { return _header; }
std::string createTimestamp() const;
bool create_latebound_entities() const { return _create_latebound_entities; }
std::pair<IfcSchema::IfcNamedUnit*, double> getUnit(IfcSchema::IfcUnitEnum::IfcUnitEnum);
const IfcParse::schema_definition* schema() const { return schema_; }
void write_hdf5(const std::string&, const IfcParse::Hdf5Settings&);
};
}
File diff suppressed because it is too large Load Diff
+286
View File
@@ -0,0 +1,286 @@
/********************************************************************************
* *
* This file is part of IfcOpenShell. *
* *
* IfcOpenShell is free software: you can redistribute it and/or modify *
* it under the terms of the Lesser GNU General Public License as published by *
* the Free Software Foundation, either version 3.0 of the License, or *
* (at your option) any later version. *
* *
* IfcOpenShell is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* Lesser GNU General Public License for more details. *
* *
* You should have received a copy of the Lesser GNU General Public License *
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
* *
********************************************************************************/
#ifndef IFCHDF5FILE_H
#define IFCHDF5FILE_H
#define SORT_ON_NAME
#include <H5Cpp.h>
#include "../ifcparse/Hdf5Settings.h"
#include "../ifcparse/IfcUtil.h"
#include "../ifcparse/IfcFile.h"
namespace IfcParse {
class abstract_instance_locator {
public:
typedef std::vector< IfcSchema::Type::Enum >::const_iterator const_iterator;
virtual const_iterator begin() const = 0;
virtual const_iterator end() const = 0;
virtual const std::vector<IfcUtil::IfcBaseEntity*>& instances(IfcSchema::Type::Enum) = 0;
virtual std::pair<int, int> operator()(IfcUtil::IfcBaseClass* v) = 0;
virtual void make_reference(IfcUtil::IfcBaseClass*, void*&) = 0;
};
template <typename T>
class vector_vector_iterator {
private:
const std::vector<std::vector<T> >& container_;
const typename std::vector<std::vector<T> >::const_iterator a_;
boost::optional<typename std::vector<T>::const_iterator> b_;
public:
vector_vector_iterator(const std::vector<std::vector<T> >& container)
: container_(container)
, a_(container_.begin())
{
if (a_ != container_.end()) {
b_ = a_->begin();
}
}
vector_vector_iterator(const std::vector<std::vector<T> >& container, typename std::vector<std::vector<T> >::const_iterator x)
: container_(container)
, a_(x)
{
if (a_ != container_.end()) {
b_ = a_->begin();
}
}
bool operator==(const vector_vector_iterator<T>& other) const {
if (a_ != container_.end()) {
return a_ == other.a_ && b_ == other.b_;
} else {
return other.a_ == container_.end();
}
}
bool operator!=(const vector_vector_iterator<T>& other) const {
return !((*this) == other);
}
T& operator*() { return *b_; }
const T& operator*() const { return *b_; }
T* operator->() { return b_.operator->(); }
vector_vector_iterator<T>& operator++() {
if (!b_) {
throw std::runtime_error("");
}
++(*b_);
if ((*b_) == a_->end()) {
do {
++a_;
} while (a_ != container_.end() && a_->size() == 0);
if (a_ != container_.end()) {
b_ = a_->begin();
}
}
}
};
class instance_categorizer {
private:
std::vector< IfcSchema::Type::Enum > dataset_names_;
std::vector< std::vector<IfcUtil::IfcBaseEntity*> > instances_;
std::vector<IfcUtil::IfcBaseEntity*> empty_;
public:
typedef vector_vector_iterator<IfcUtil::IfcBaseEntity*> const_iterator;
template <typename ForwardIt>
instance_categorizer(ForwardIt begin, ForwardIt end) {
std::set<IfcSchema::Type::Enum> dataset_names_set;
std::map<IfcSchema::Type::Enum, std::vector<IfcUtil::IfcBaseEntity*> > instances_map;
std::for_each(begin, end, [&dataset_names_set, &instances_map](IfcUtil::IfcBaseClass* inst) {
if (inst->declaration().as_entity()) {
dataset_names_set.insert(inst->declaration().type());
instances_map[inst->declaration().type()].push_back((IfcUtil::IfcBaseEntity*) inst);
}
});
dataset_names_.assign(dataset_names_set.begin(), dataset_names_set.end());
for (IfcSchema::Type::Enum ty : dataset_names_) {
auto&& insts = instances_map[ty];
std::sort(insts.begin(), insts.end(), [](IfcUtil::IfcBaseEntity* i1, IfcUtil::IfcBaseEntity* i2) {
return i1->data().id() < i2->data().id();
});
instances_.emplace_back(insts);
}
}
const std::vector<IfcUtil::IfcBaseEntity*>& instances(IfcSchema::Type::Enum t) {
auto it = std::lower_bound(dataset_names_.begin(), dataset_names_.end(), t);
if (it == dataset_names_.end() || (*it) != t) return empty_;
return instances_[std::distance(dataset_names_.begin(), it)];
}
const std::vector<IfcSchema::Type::Enum>& dataset_names() const { return dataset_names_; };
const_iterator begin() const { return const_iterator(instances_); }
const_iterator end() const { return const_iterator(instances_, instances_.end()); }
};
class instance_enumerator {
private:
const IfcSpfHeader* header_;
instance_categorizer* categories_;
public:
typedef instance_categorizer::const_iterator const_iterator;
instance_enumerator()
: header_(nullptr)
, categories_(nullptr)
{}
explicit instance_enumerator(IfcFile* file)
: header_(&file->header())
{
std::vector<IfcUtil::IfcBaseClass*> temp;
std::transform(file->begin(), file->end(), std::back_inserter(temp), [](auto& pair) {
return pair.second;
});
categories_ = new instance_categorizer(temp.begin(), temp.end());
}
template <typename T>
instance_enumerator(IfcSpfHeader* header, T begin, T end)
: header_(header)
, categories_(new instance_categorizer(begin, end))
{}
const IfcSpfHeader& header() const {
return *header_;
}
const std::vector<IfcUtil::IfcBaseEntity*>& by_type(IfcSchema::Type::Enum t) {
return categories_->instances(t);
}
const_iterator begin() const { return categories_->begin(); }
const_iterator end() const { return categories_->end(); }
const std::vector<IfcSchema::Type::Enum>& dataset_names() const { return categories_->dataset_names(); }
instance_categorizer* categorizer() const { return categories_; }
};
class IfcHdf5File {
private:
class allocator_t {
private:
// TODO: Change this?
mutable std::vector<uint8_t*> buffers;
public:
void* allocate(size_t n) const {
return new uint8_t[n];
}
void free() {
std::vector<uint8_t*>::const_iterator it;
for (it = buffers.begin(); it != buffers.end(); ++it) {
delete[] *it;
}
buffers.clear();
}
~allocator_t() {
free();
}
};
allocator_t allocator;
Hdf5Settings settings_;
boost::optional<std::string> name_;
const schema_definition* schema_;
instance_enumerator ifcfile_;
H5::H5File* file_;
H5::Group schema_group;
// H5::Group population_group;
// TODO: const
H5::CompType* instance_reference;
const H5::DataType* object_reference_type;
std::map<IfcSchema::Type::Enum, H5::DataType*> declared_types;
#ifdef SORT_ON_NAME
std::map<IfcSchema::Type::Enum, std::vector<uint32_t> > sorted_entities;
#else
std::map<IfcSchema::Type::Enum, std::vector<IfcUtil::IfcBaseClass*> > sorted_entities;
#endif
std::vector<IfcSchema::Type::Enum> dataset_names;
H5::DataType* map_type(const IfcParse::parameter_type* pt);
H5::CompType* map_entity(const IfcParse::entity* e);
H5::DataType* map_select(const IfcParse::select_type* pt);
H5::DataType* commit(H5::DataType* dt, const std::string& name);
void init_default_types();
void visit_select(const IfcParse::select_type* pt, std::set<const IfcParse::declaration*>& leafs);
std::string flatten_aggregate_name(const IfcParse::parameter_type* at) const;
std::pair<size_t, size_t> make_instance_reference(const IfcUtil::IfcBaseClass* instance) const;
// void write_select(void*& ptr, IfcUtil::IfcBaseClass* instance, const H5::CompType* datatype) const;
H5::DataSet create_dataset(H5::Group* population_group, const std::string& path, H5::DataType datatype, int rank, hsize_t* dimensions);
void write_header(H5::Group& group, const IfcSpfHeader& header);
template <typename T>
void write_instance(void*& ptr, T& visitor, H5::DataType& datatype, IfcUtil::IfcBaseEntity* v);
// TODO: Obviously change this;
void* mapper_;
public:
typedef std::pair<std::string, const H5::DataType*> compound_member;
void write_schema(IfcParse::instance_categorizer* ifc_file = nullptr);
void write_population(H5::Group&, instance_enumerator&, IfcParse::abstract_instance_locator* locator = nullptr);
IfcHdf5File(IfcFile* f, const std::string& name, const Hdf5Settings& settings)
: name_(name)
, file_(nullptr)
, schema_(f->schema())
, ifcfile_(f)
, settings_(settings)
{
write_schema(ifcfile_.categorizer());
H5::Group population_group = file_->createGroup("population");
write_population(population_group, ifcfile_);
};
IfcHdf5File(H5::H5File& file, const IfcParse::schema_definition& schema, const Hdf5Settings& settings)
: file_(&file)
, schema_(&schema)
, settings_(settings)
{
};
static void convert_to_spf(const std::string& name, std::ostream& output, const boost::optional< std::vector<std::string> >& mount_points = boost::none);
};
}
#endif
+1 -1
View File
@@ -124,7 +124,7 @@ IfcSchema::IfcProject* IfcHierarchyHelper::addProject(IfcSchema::IfcOwnerHistory
void IfcHierarchyHelper::relatePlacements(IfcSchema::IfcProduct* parent, IfcSchema::IfcProduct* product) {
IfcSchema::IfcObjectPlacement* place = product->hasObjectPlacement() ? product->ObjectPlacement() : 0;
if (place && place->is(IfcSchema::Type::IfcLocalPlacement)) {
if (place && place->declaration().is(IfcSchema::Type::IfcLocalPlacement)) {
IfcSchema::IfcLocalPlacement* local_place = (IfcSchema::IfcLocalPlacement*) place;
if (parent->hasObjectPlacement()) {
local_place->setPlacementRelTo(parent->ObjectPlacement());
+36 -11
View File
@@ -25,6 +25,7 @@
#include "../ifcparse/IfcUtil.h"
#include "../ifcparse/IfcWrite.h"
#include "../ifcparse/IfcFile.h"
#ifdef USE_IFC4
#include "../ifcparse/Ifc4-latebound.h"
@@ -38,29 +39,36 @@ using namespace IfcUtil;
IfcWrite::IfcWritableEntity* IfcParse::IfcLateBoundEntity::writable_entity() {
IfcWrite::IfcWritableEntity* e;
if (entity->isWritable()) {
e = (IfcWrite::IfcWritableEntity*) entity;
if (data_->isWritable()) {
e = (IfcWrite::IfcWritableEntity*) data_;
} else {
entity = e = new IfcWrite::IfcWritableEntity(entity);
data_ = e = new IfcWrite::IfcWritableEntity(data_);
}
return e;
}
IfcParse::IfcLateBoundEntity::IfcLateBoundEntity(const std::string& s) {
_type = IfcSchema::Type::FromString(boost::to_upper_copy(s));
entity = new IfcWrite::IfcWritableEntity(_type);
data_ = new IfcWrite::IfcWritableEntity(_type);
for (unsigned i = 0; i < getArgumentCount(); ++i) {
// Side effect of this is that a NULL attribute is created.
entity->getArgument(i);
data_->getArgument(i);
}
IfcSchema::Type::PopulateDerivedFields(writable_entity());
}
IfcParse::IfcLateBoundEntity::IfcLateBoundEntity(IfcAbstractEntity* e) {
entity = e;
data_ = e;
_type = e->type();
}
/*
const IfcParse::entity& IfcParse::IfcLateBoundEntity::entity() {
return *get_schema().declaration_by_name(IfcSchema::Type::ToString(_type));
}
*/
unsigned int IfcParse::IfcLateBoundEntity::id() const {
if (entity->file) {
return static_cast<unsigned int>(entity->id());
if (data_->file) {
return static_cast<unsigned int>(data_->id());
} else {
throw IfcException("Entity not bound to a file");
}
@@ -95,7 +103,7 @@ IfcSchema::Type::Enum IfcParse::IfcLateBoundEntity::getArgumentEntity(unsigned i
return IfcSchema::Type::GetAttributeEntity(_type, (unsigned char)i);
}
Argument* IfcParse::IfcLateBoundEntity::getArgument(unsigned int i) const {
return entity->getArgument(i);
return data_->getArgument(i);
}
const char* IfcParse::IfcLateBoundEntity::getArgumentName(unsigned int i) const {
return IfcSchema::Type::GetAttributeName(_type, (unsigned char)i).c_str();
@@ -156,6 +164,12 @@ void IfcParse::IfcLateBoundEntity::setArgumentAsAggregateOfInt(unsigned int i, c
writable_entity()->setArgument(i,v);
} else invalid_argument(i,"AGGREGATE OF INT");
}
void IfcParse::IfcLateBoundEntity::setArgumentAsAggregateOfBool(unsigned int i, const std::vector<bool>& v) {
IfcUtil::ArgumentType arg_type = IfcSchema::Type::GetAttributeType(_type, (unsigned char)i);
if (arg_type == Argument_AGGREGATE_OF_BOOL) {
writable_entity()->setArgument(i,v);
} else invalid_argument(i,"AGGREGATE OF BOOL");
}
void IfcParse::IfcLateBoundEntity::setArgumentAsAggregateOfDouble(unsigned int i, const std::vector<double>& v) {
IfcUtil::ArgumentType arg_type = IfcSchema::Type::GetAttributeType(_type, (unsigned char)i);
if (arg_type == Argument_AGGREGATE_OF_DOUBLE) {
@@ -197,6 +211,12 @@ void IfcParse::IfcLateBoundEntity::setArgumentAsAggregateOfAggregateOfInt(unsign
writable_entity()->setArgument(i,v);
} else invalid_argument(i,"AGGREGATE OF AGGREGATE OF INT");
}
void IfcParse::IfcLateBoundEntity::setArgumentAsAggregateOfAggregateOfBool(unsigned int i, const std::vector< std::vector<bool> >& v) {
IfcUtil::ArgumentType arg_type = IfcSchema::Type::GetAttributeType(_type, (unsigned char)i);
if (arg_type == Argument_AGGREGATE_OF_AGGREGATE_OF_BOOL) {
writable_entity()->setArgument(i,v);
} else invalid_argument(i,"AGGREGATE OF AGGREGATE OF BOOL");
}
void IfcParse::IfcLateBoundEntity::setArgumentAsAggregateOfAggregateOfDouble(unsigned int i, const std::vector< std::vector<double> >& v) {
IfcUtil::ArgumentType arg_type = IfcSchema::Type::GetAttributeType(_type, (unsigned char)i);
if (arg_type == Argument_AGGREGATE_OF_AGGREGATE_OF_DOUBLE) {
@@ -213,11 +233,11 @@ unsigned IfcParse::IfcLateBoundEntity::getArgumentIndex(const std::string& a) co
return IfcSchema::Type::GetAttributeIndex(_type,a);
}
std::string IfcParse::IfcLateBoundEntity::toString() {
return entity->toString(false);
return data_->toString(false);
}
IfcEntityList::ptr IfcParse::IfcLateBoundEntity::get_inverse(const std::string& a) {
std::pair<IfcSchema::Type::Enum, unsigned> inv = IfcSchema::Type::GetInverseAttribute(_type, a);
return entity->getInverse(inv.first, inv.second);
return data_->getInverse(inv.first, inv.second);
}
bool IfcParse::IfcLateBoundEntity::is_valid() {
const unsigned arg_count = getArgumentCount();
@@ -260,3 +280,8 @@ std::vector<std::string> IfcParse::IfcLateBoundEntity::getInverseAttributeNames(
std::copy(values.begin(), values.end(), std::back_inserter(return_value));
return return_value;
}
const IfcParse::declaration& IfcParse::IfcLateBoundEntity::declaration() const {
// TODO: Bound instances to a file and use according schema
return *get_schema().declaration_by_name(_type);
}
+10 -1
View File
@@ -32,7 +32,7 @@ namespace IfcParse {
// that in the IfcFile class the distinction what entity type to be created is
// no longer necessary and weird diagonal casts when creating geometry from
// IfcLateBoundEntities are eliminated.
class IfcLateBoundEntity : public IfcUtil::IfcBaseEntity {
class IfcLateBoundEntity : public IfcUtil::IfcBaseClass { // TODO: -Entity or -Type?
private:
IfcSchema::Type::Enum _type;
IfcWrite::IfcWritableEntity* writable_entity();
@@ -68,17 +68,26 @@ namespace IfcParse {
void setArgumentAsEntityInstance(unsigned int i, IfcLateBoundEntity* v);
void setArgumentAsAggregateOfInt(unsigned int i, const std::vector<int>& v);
void setArgumentAsAggregateOfBool(unsigned int i, const std::vector<bool>& v);
void setArgumentAsAggregateOfDouble(unsigned int i, const std::vector<double>& v);
void setArgumentAsAggregateOfString(unsigned int i, const std::vector<std::string>& v);
void setArgumentAsAggregateOfEntityInstance(unsigned int i, IfcEntityList::ptr v);
void setArgumentAsAggregateOfAggregateOfInt(unsigned int i, const std::vector< std::vector<int> >& v);
void setArgumentAsAggregateOfAggregateOfBool(unsigned int i, const std::vector< std::vector<bool> >& v);
void setArgumentAsAggregateOfAggregateOfDouble(unsigned int i, const std::vector< std::vector<double> >& v);
void setArgumentAsAggregateOfAggregateOfEntityInstance(unsigned int i, IfcEntityListList::ptr v);
std::string toString();
bool is_valid();
// const IfcParse::entity& entity();
const IfcAbstractEntity& data() const { return *data_; }
IfcAbstractEntity& data() { return *data_; }
const IfcParse::declaration& declaration() const;
};
}
+263 -222
View File
@@ -39,6 +39,8 @@
#include "../ifcparse/IfcLateBoundEntity.h"
#include "../ifcparse/IfcFile.h"
#include "../ifcparse/IfcSIPrefix.h"
#include "../ifcparse/IfcSchema.h"
#include "../ifcparse/IfcHdf5File.h"
using namespace IfcParse;
@@ -411,6 +413,12 @@ bool TokenFunc::isBool(const Token& t) {
return str == "T" || str == "F";
}
bool TokenFunc::isLogical(const Token& t) {
if (!isEnumeration(t)) return false;
const std::string str = asString(t);
return str == "U"; // T and F covered as part of bool.
}
bool TokenFunc::isFloat(const Token& t) {
if (isOperator(t) || isString(t) || isEnumeration(t)) {
return false;
@@ -441,6 +449,15 @@ bool TokenFunc::asBool(const Token& t) {
return str == "T";
}
boost::logic::tribool TokenFunc::asLogical(const Token& t) {
if (isBool(t)) {
return asBool(t);
} else {
boost::logic::indeterminate_keyword_t x;
return boost::logic::tribool(x);
}
}
double TokenFunc::asFloat(const Token& t) {
const std::string str = asString(t);
const char* start = str.c_str();
@@ -549,6 +566,10 @@ IfcUtil::ArgumentType ArgumentList::type() const {
const IfcUtil::ArgumentType elem_type = list[0]->type();
if (elem_type == IfcUtil::Argument_INT) {
return IfcUtil::Argument_AGGREGATE_OF_INT;
} else if (elem_type == IfcUtil::Argument_BOOL) {
return IfcUtil::Argument_AGGREGATE_OF_BOOL;
} else if (elem_type == IfcUtil::Argument_TRIBOOL) {
return IfcUtil::Argument_AGGREGATE_OF_TRIBOOL;
} else if (elem_type == IfcUtil::Argument_DOUBLE) {
return IfcUtil::Argument_AGGREGATE_OF_DOUBLE;
} else if (elem_type == IfcUtil::Argument_STRING) {
@@ -559,6 +580,10 @@ IfcUtil::ArgumentType ArgumentList::type() const {
return IfcUtil::Argument_AGGREGATE_OF_ENTITY_INSTANCE;
} else if (elem_type == IfcUtil::Argument_AGGREGATE_OF_INT) {
return IfcUtil::Argument_AGGREGATE_OF_AGGREGATE_OF_INT;
} else if (elem_type == IfcUtil::Argument_AGGREGATE_OF_BOOL) {
return IfcUtil::Argument_AGGREGATE_OF_AGGREGATE_OF_BOOL;
} else if (elem_type == IfcUtil::Argument_AGGREGATE_OF_TRIBOOL) {
return IfcUtil::Argument_AGGREGATE_OF_AGGREGATE_OF_TRIBOOL;
} else if (elem_type == IfcUtil::Argument_AGGREGATE_OF_DOUBLE) {
return IfcUtil::Argument_AGGREGATE_OF_AGGREGATE_OF_DOUBLE;
} else if (elem_type == IfcUtil::Argument_AGGREGATE_OF_ENTITY_INSTANCE) {
@@ -599,18 +624,27 @@ std::vector< std::vector<T> > read_aggregate_of_aggregate_as_vector2(const std::
//
ArgumentList::operator int() const { throw IfcException("Argument is not an integer"); }
ArgumentList::operator bool() const { throw IfcException("Argument is not a boolean"); }
ArgumentList::operator boost::logic::tribool() const { throw IfcException("Argument is not a boolean"); }
ArgumentList::operator double() const { throw IfcException("Argument is not a number"); }
ArgumentList::operator std::string() const { throw IfcException("Argument is not a string"); }
ArgumentList::operator boost::dynamic_bitset<>() const { throw IfcException("Argument is not a binary"); }
ArgumentList::operator std::vector<double>() const {
return read_aggregate_as_vector<double>(list);
}
ArgumentList::operator std::vector<int>() const {
return read_aggregate_as_vector<int>(list);
}
ArgumentList::operator std::vector<bool>() const {
return read_aggregate_as_vector<bool>(list);
}
ArgumentList::operator std::vector<boost::logic::tribool>() const {
return read_aggregate_as_vector<boost::logic::tribool>(list);
}
ArgumentList::operator std::vector<double>() const {
return read_aggregate_as_vector<double>(list);
}
ArgumentList::operator std::vector<std::string>() const {
return read_aggregate_as_vector<std::string>(list);
}
@@ -636,6 +670,14 @@ ArgumentList::operator std::vector< std::vector<int> >() const {
return read_aggregate_of_aggregate_as_vector2<int>(list);
}
ArgumentList::operator std::vector< std::vector<bool> >() const {
return read_aggregate_of_aggregate_as_vector2<bool>(list);
}
ArgumentList::operator std::vector< std::vector<boost::logic::tribool> >() const {
return read_aggregate_of_aggregate_as_vector2<boost::logic::tribool>(list);
}
ArgumentList::operator std::vector< std::vector<double> >() const {
return read_aggregate_of_aggregate_as_vector2<double>(list);
}
@@ -701,6 +743,8 @@ IfcUtil::ArgumentType TokenArgument::type() const {
return IfcUtil::Argument_INT;
} else if (TokenFunc::isBool(token)) {
return IfcUtil::Argument_BOOL;
} else if (TokenFunc::isLogical(token)) {
return IfcUtil::Argument_TRIBOOL;
} else if (TokenFunc::isFloat(token)) {
return IfcUtil::Argument_DOUBLE;
} else if (TokenFunc::isString(token)) {
@@ -725,16 +769,21 @@ IfcUtil::ArgumentType TokenArgument::type() const {
//
TokenArgument::operator int() const { return TokenFunc::asInt(token); }
TokenArgument::operator bool() const { return TokenFunc::asBool(token); }
TokenArgument::operator boost::logic::tribool() const { return TokenFunc::asLogical(token); }
TokenArgument::operator double() const { return TokenFunc::asFloat(token); }
TokenArgument::operator std::string() const { return TokenFunc::asString(token); }
TokenArgument::operator boost::dynamic_bitset<>() const { return TokenFunc::asBinary(token); }
TokenArgument::operator std::vector<double>() const { throw IfcException("Argument is not a list of floats"); }
TokenArgument::operator std::vector<int>() const { throw IfcException("Argument is not a list of ints"); }
TokenArgument::operator std::vector<bool>() const { throw IfcException("Argument is not a list of bools"); }
TokenArgument::operator std::vector<boost::logic::tribool>() const { throw IfcException("Argument is not a list of logicals"); }
TokenArgument::operator std::vector<double>() const { throw IfcException("Argument is not a list of floats"); }
TokenArgument::operator std::vector<std::string>() const { throw IfcException("Argument is not a list of strings"); }
TokenArgument::operator std::vector<boost::dynamic_bitset<> >() const { throw IfcException("Argument is not a list of binaries"); }
TokenArgument::operator IfcUtil::IfcBaseClass*() const { return token.first->file->entityById(TokenFunc::asInt(token)); }
TokenArgument::operator IfcEntityList::ptr() const { throw IfcException("Argument is not a list of entity instances"); }
TokenArgument::operator std::vector< std::vector<int> >() const { throw IfcException("Argument is not a list of list of ints"); }
TokenArgument::operator std::vector< std::vector<bool> >() const { throw IfcException("Argument is not a list of list of bools"); }
TokenArgument::operator std::vector< std::vector<boost::logic::tribool> >() const { throw IfcException("Argument is not a list of list of logicals"); }
TokenArgument::operator std::vector< std::vector<double> >() const { throw IfcException("Argument is not a list of list of floats"); }
TokenArgument::operator IfcEntityListList::ptr() const { throw IfcException("Argument is not a list of list of entity instances"); }
unsigned int TokenArgument::size() const { return 1; }
@@ -757,22 +806,27 @@ IfcUtil::ArgumentType EntityArgument::type() const {
//
EntityArgument::operator int() const { throw IfcException("Argument is not an integer"); }
EntityArgument::operator bool() const { throw IfcException("Argument is not a boolean"); }
EntityArgument::operator boost::logic::tribool() const { throw IfcException("Argument is not a logical"); }
EntityArgument::operator double() const { throw IfcException("Argument is not a number"); }
EntityArgument::operator boost::dynamic_bitset<>() const { throw IfcException("Argument is not a binary"); }
EntityArgument::operator std::string() const { throw IfcException("Argument is not a string"); }
EntityArgument::operator std::vector<double>() const { throw IfcException("Argument is not a list of floats"); }
EntityArgument::operator std::vector<int>() const { throw IfcException("Argument is not a list of ints"); }
EntityArgument::operator std::vector<bool>() const { throw IfcException("Argument is not a list of bools"); }
EntityArgument::operator std::vector<boost::logic::tribool>() const { throw IfcException("Argument is not a list of logicals"); }
EntityArgument::operator std::vector<double>() const { throw IfcException("Argument is not a list of floats"); }
EntityArgument::operator std::vector<std::string>() const { throw IfcException("Argument is not a list of strings"); }
EntityArgument::operator std::vector<boost::dynamic_bitset<> >() const { throw IfcException("Argument is not a list of binaries"); }
EntityArgument::operator IfcUtil::IfcBaseClass*() const { return entity; }
EntityArgument::operator IfcEntityList::ptr() const { throw IfcException("Argument is not a list of entity instances"); }
EntityArgument::operator std::vector< std::vector<int> >() const { throw IfcException("Argument is not a list of list of ints"); }
EntityArgument::operator std::vector< std::vector<bool> >() const { throw IfcException("Argument is not a list of list of bools"); }
EntityArgument::operator std::vector< std::vector<boost::logic::tribool> >() const { throw IfcException("Argument is not a list of list of logicals"); }
EntityArgument::operator std::vector< std::vector<double> >() const { throw IfcException("Argument is not a list of list of floats"); }
EntityArgument::operator IfcEntityListList::ptr() const { throw IfcException("Argument is not a list of list of entity instances"); }
unsigned int EntityArgument::size() const { return 1; }
Argument* EntityArgument::operator [] (unsigned int /*i*/) const { throw IfcException("Argument is not a list of arguments"); }
std::string EntityArgument::toString(bool upper) const {
return entity->entity->toString(upper);
return entity->data().toString(upper);
}
//return entity->entity->toString(); }
bool EntityArgument::isNull() const { return false; }
@@ -837,6 +891,11 @@ void Entity::Load(std::vector<unsigned int>& ids, bool seek) const {
if ( ! TokenFunc::isOperator(semilocon,';') ) file->tokens->stream->Seek(old_offset);
}
void Entity::Unload() {
delete args;
args = 0;
}
IfcSchema::Type::Enum Entity::type() const {
return _type;
}
@@ -887,11 +946,10 @@ IfcEntityList::ptr Entity::getInverse(IfcSchema::Type::Enum type, int attribute_
}
bool Entity::is(IfcSchema::Type::Enum v) const { return _type == v; }
unsigned int Entity::id() { return _id; }
unsigned int Entity::id() const { return _id; }
IfcWrite::IfcWritableEntity* Entity::isWritable() {
return 0;
}
const IfcWrite::IfcWritableEntity* Entity::isWritable() const { return 0; }
IfcWrite::IfcWritableEntity* Entity::isWritable() { return 0; }
IfcFile::IfcFile(bool create_latebound_entities)
: _create_latebound_entities(create_latebound_entities)
@@ -900,6 +958,7 @@ IfcFile::IfcFile(bool create_latebound_entities)
, tokens(0)
, MaxId(0)
{
schema_ = &get_schema();
setDefaultHeaderValues();
}
@@ -919,6 +978,73 @@ bool IfcFile::Init(void* data, int len) {
return IfcFile::Init(new IfcSpfStream(data,len));
}
class RegisterInstancesToFile {
private:
IfcFile::entity_by_id_t& byid_;
IfcFile::entity_by_guid_t& byguid_;
IfcFile::entities_by_type_t& bytype_;
IfcFile::entities_by_ref_t& byref_;
bool populate_guid_mapping_;
public:
RegisterInstancesToFile(
IfcFile::entity_by_id_t& byid,
IfcFile::entity_by_guid_t& byguid,
IfcFile::entities_by_type_t& bytype,
IfcFile::entities_by_ref_t& byref
)
: byid_(byid)
, byguid_(byguid)
, bytype_(bytype)
, byref_(byref)
, populate_guid_mapping_(true)
{}
const bool& populate_guid_mapping() const { return populate_guid_mapping_; }
bool& populate_guid_mapping() { return populate_guid_mapping_; }
void operator()(IfcUtil::IfcBaseClass* instance) {
if (populate_guid_mapping_ && instance->declaration().is(IfcSchema::Type::IfcRoot)) {
IfcSchema::IfcRoot* ifc_root = (IfcSchema::IfcRoot*) instance;
try {
const std::string guid = ifc_root->GlobalId();
if (byguid_.insert(std::make_pair(guid, ifc_root)).second == false) {
std::stringstream ss;
ss << "Duplicate instance with guid '" << guid << "' not stored";
Logger::Message(Logger::LOG_WARNING,ss.str());
}
} catch (const IfcException& ex) {
Logger::Message(Logger::LOG_ERROR,ex.what());
}
}
const IfcParse::entity* entity = instance->declaration().as_entity();
while(entity) {
IfcEntityList::ptr& instances_by_type = bytype_[entity->type()];
if (!instances_by_type) {
instances_by_type.reset(new IfcEntityList);
}
instances_by_type->push(instance);
entity = entity->supertype();
}
unsigned int id = instance->data().id();
if (byid_.insert(std::make_pair(id, instance)).second == false) {
std::stringstream ss;
ss << "Duplicate instance with id '" << id << "' not stored";
Logger::Message(Logger::LOG_WARNING,ss.str());
}
}
void operator()(IfcUtil::IfcBaseClass* instance, unsigned int refering_inst_name) {
IfcEntityList::ptr& instances_by_ref = byref_[refering_inst_name];
if (!instances_by_ref) {
instances_by_ref.reset(new IfcEntityList);
}
instances_by_ref->push(instance);
}
};
bool IfcFile::Init(IfcParse::IfcSpfStream* s) {
// Initialize a "C" locale for locale-independent
// number parsing. See comment above on line 41.
@@ -941,92 +1067,12 @@ bool IfcFile::Init(IfcParse::IfcSpfStream* s) {
Logger::Message(Logger::LOG_ERROR, std::string("File schema encountered different from expected '") + IfcSchema::Identifier + "'");
}
Token token = TokenPtr();
Token previous = TokenPtr();
unsigned int currentId = 0;
lastId = 0;
int x = 0;
Entity* e;
IfcUtil::IfcBaseClass* entity = 0;
Logger::Status("Scanning file...");
while ( ! stream->eof ) {
if ( currentId ) {
try {
e = new Entity(currentId,this);
if (this->create_latebound_entities()) {
entity = new IfcLateBoundEntity(e);
} else {
entity = IfcSchema::SchemaEntity(e);
}
} catch (const IfcException& ex) {
currentId = 0;
Logger::Message(Logger::LOG_ERROR,ex.what());
continue;
}
// Update the status after every 1000 instances parsed
if ( !((++x)%1000) ) {
std::stringstream ss; ss << "\r#" << currentId;
Logger::Status(ss.str(), false);
}
if ( entity->is(IfcSchema::Type::IfcRoot) ) {
IfcSchema::IfcRoot* ifc_root = (IfcSchema::IfcRoot*) entity;
try {
const std::string guid = ifc_root->GlobalId();
if ( byguid.find(guid) != byguid.end() ) {
std::stringstream ss;
ss << "Instance encountered with non-unique GlobalId " << guid;
Logger::Message(Logger::LOG_WARNING,ss.str());
}
byguid[guid] = ifc_root;
} catch (const IfcException& ex) {
Logger::Message(Logger::LOG_ERROR,ex.what());
}
}
IfcSchema::Type::Enum ty = entity->type();
do {
IfcEntityList::ptr instances_by_type = entitiesByType(ty);
if (!instances_by_type) {
instances_by_type = IfcEntityList::ptr(new IfcEntityList());
bytype[ty] = instances_by_type;
}
instances_by_type->push(entity);
ty = IfcSchema::Type::Parent(ty);
} while ( ty > -1 );
if ( byid.find(currentId) != byid.end() ) {
std::stringstream ss;
ss << "Overwriting instance with name #" << currentId;
Logger::Message(Logger::LOG_WARNING,ss.str());
}
byid[currentId] = entity;
MaxId = (std::max)(MaxId,currentId);
currentId = 0;
} else {
try { token = tokens->Next(); }
catch (... ) { token = TokenPtr(); }
}
if ( ! (token.second || token.first) ) break;
if ( (previous.second || previous.first) && TokenFunc::isIdentifier(previous) ) {
int id = TokenFunc::asInt(previous);
if ( TokenFunc::isOperator(token,'=') ) {
currentId = id;
} else if (entity) {
IfcEntityList::ptr instances_by_ref = entitiesByReference(id);
if (!instances_by_ref) {
instances_by_ref = IfcEntityList::ptr(new IfcEntityList());
byref[id] = instances_by_ref;
}
instances_by_ref->push(entity);
}
}
previous = token;
}
Logger::Status("\rDone scanning file ");
RegisterInstancesToFile populate(byid, byguid, bytype, byref);
populate.populate_guid_mapping() = false;
InstanceStreamer<RegisterInstancesToFile, RegisterInstancesToFile> streamer(this, *stream, *tokens, populate, populate);
streamer.stream();
MaxId = streamer.max_inst_name_encountered();
return true;
}
@@ -1039,8 +1085,16 @@ void IfcFile::traverse(IfcUtil::IfcBaseClass* instance, std::set<IfcUtil::IfcBas
if (level >= max_level && max_level > 0) return;
for (unsigned i = 0; i < instance->getArgumentCount(); ++i) {
Argument* arg = instance->getArgument(i);
auto entity = instance->declaration().as_entity();
if (!entity) {
// This is a simple type instance, don't traverse attributes.
return;
}
auto attributes = entity->all_attributes();
for (unsigned i = 0; i < attributes.size(); ++i) {
Argument* arg = instance->data().getArgument(i);
if (arg->type() == IfcUtil::Argument_ENTITY_INSTANCE) {
traverse(*arg, visited, list, level + 1, max_level);
@@ -1073,10 +1127,10 @@ void IfcFile::addEntities(IfcEntityList::ptr es) {
}
}
IfcUtil::IfcBaseClass* IfcFile::addEntity(IfcUtil::IfcBaseClass* entity) {
IfcUtil::IfcBaseClass* IfcFile::addEntity(IfcUtil::IfcBaseClass* instance) {
// If this instance has been inserted before, return
// a reference to the copy that was created from it.
entity_entity_map_t::iterator mit = entity_file_map.find(entity);
entity_entity_map_t::iterator mit = entity_file_map.find(instance);
if (mit != entity_file_map.end()) {
return mit->second;
}
@@ -1084,39 +1138,44 @@ IfcUtil::IfcBaseClass* IfcFile::addEntity(IfcUtil::IfcBaseClass* entity) {
// Obtain all forward references by a depth-first
// traversal and add them to the file.
try {
IfcEntityList::ptr entity_attributes = traverse(entity, 1);
IfcEntityList::ptr entity_attributes = traverse(instance, 1);
for (IfcEntityList::it it = entity_attributes->begin(); it != entity_attributes->end(); ++it) {
if (*it != entity) {
if (*it != instance) {
entity_file_map.insert(entity_entity_map_t::value_type(*it, addEntity(*it)));
}
}
} catch (...) {
Logger::Message(Logger::LOG_ERROR, "Failed to visit forward references of", entity->entity);
Logger::Message(Logger::LOG_ERROR, "Failed to visit forward references of", instance);
}
// See whether the instance is already part of a file
if (entity->entity->file != 0) {
if (entity->entity->file == this) {
if (instance->data().file != 0) {
if (instance->data().file == this) {
// If it is part of this file
// nothing needs to be done.
return entity;
return instance;
}
// An instance is being added from another file. A copy of the
// container and entity is created. The attribute references
// container and instance is created. The attribute references
// need to be updated to point to instances in this file.
IfcFile* other_file = entity->entity->file;
IfcWrite::IfcWritableEntity* we = new IfcWrite::IfcWritableEntity(entity->entity);
IfcFile* other_file = instance->data().file;
// TODO: Proper copy constructor
IfcWrite::IfcWritableEntity* we = new IfcWrite::IfcWritableEntity(&instance->data());
if (this->create_latebound_entities()) {
entity = new IfcLateBoundEntity(we);
instance = new IfcLateBoundEntity(we);
} else {
entity = IfcSchema::SchemaEntity(we);
instance = IfcSchema::SchemaEntity(we);
}
// In case an entity is added that contains geometry, the unit
// In case an instance is added that contains geometry, the unit
// information needs to be accounted for for IfcLengthMeasures.
boost::optional<double> conversion_factor;
const schema_definition* s = schema();
for (unsigned i = 0; i < we->getArgumentCount(); ++i) {
Argument* attr = we->getArgument(i);
IfcUtil::ArgumentType attr_type = attr->type();
@@ -1146,23 +1205,31 @@ IfcUtil::IfcBaseClass* IfcFile::addEntity(IfcUtil::IfcBaseClass* entity) {
new_instances->push(list);
}
we->setArgument(i, new_instances);
} else if (entity->getArgumentEntity(i) == IfcSchema::Type::IfcLengthMeasure ||
entity->getArgumentEntity(i) == IfcSchema::Type::IfcPositiveLengthMeasure)
{
if (!conversion_factor) {
conversion_factor = other_file->getUnit(IfcSchema::IfcUnitEnum::IfcUnit_LENGTHUNIT).second /
getUnit(IfcSchema::IfcUnitEnum::IfcUnit_LENGTHUNIT).second;
}
if (attr_type == IfcUtil::Argument_DOUBLE) {
double v = *attr;
v *= *conversion_factor;
we->setArgument(i, v);
} else if (attr_type == IfcUtil::Argument_AGGREGATE_OF_DOUBLE) {
std::vector<double> v = *attr;
for (std::vector<double>::iterator it = v.begin(); it != v.end(); ++it) {
(*it) *= *conversion_factor;
} else if (s) {
const entity* e = instance->declaration().as_entity();
if (e) {
const std::vector<const entity::attribute*> attrs = e->all_attributes();
const parameter_type* pt = attrs[i]->type_of_attribute();
while (pt->as_aggregation_type()) {
pt = pt->as_aggregation_type()->type_of_element();
}
if (pt->is(IfcSchema::Type::IfcLengthMeasure)) {
if (!conversion_factor) {
conversion_factor = other_file->getUnit(IfcSchema::IfcUnitEnum::IfcUnit_LENGTHUNIT).second /
getUnit(IfcSchema::IfcUnitEnum::IfcUnit_LENGTHUNIT).second;
}
if (attr_type == IfcUtil::Argument_DOUBLE) {
double v = *attr;
v *= *conversion_factor;
we->setArgument(i, v);
} else if (attr_type == IfcUtil::Argument_AGGREGATE_OF_DOUBLE) {
std::vector<double> v = *attr;
for (std::vector<double>::iterator it = v.begin(); it != v.end(); ++it) {
(*it) *= *conversion_factor;
}
we->setArgument(i, v);
}
}
we->setArgument(i, v);
}
}
}
@@ -1174,13 +1241,13 @@ IfcUtil::IfcBaseClass* IfcFile::addEntity(IfcUtil::IfcBaseClass* entity) {
}
// For subtypes of IfcRoot, the GUID mapping needs to be updated.
if (entity->is(IfcSchema::Type::IfcRoot)) {
IfcSchema::IfcRoot* ifc_root = (IfcSchema::IfcRoot*) entity;
if (instance->declaration().is(IfcSchema::Type::IfcRoot)) {
IfcSchema::IfcRoot* ifc_root = (IfcSchema::IfcRoot*) instance;
try {
const std::string guid = ifc_root->GlobalId();
if ( byguid.find(guid) != byguid.end() ) {
std::stringstream ss;
ss << "Overwriting entity with guid " << guid;
ss << "Overwriting instance with guid " << guid;
Logger::Message(Logger::LOG_WARNING,ss.str());
}
byguid[guid] = ifc_root;
@@ -1189,74 +1256,75 @@ IfcUtil::IfcBaseClass* IfcFile::addEntity(IfcUtil::IfcBaseClass* entity) {
}
}
// The mapping by entity type is updated.
IfcSchema::Type::Enum ty = entity->type();
// The mapping by instance type is updated.
IfcSchema::Type::Enum ty = instance->declaration().type();
do {
IfcEntityList::ptr instances_by_type = entitiesByType(ty);
if (!instances_by_type) {
instances_by_type = IfcEntityList::ptr(new IfcEntityList());
bytype[ty] = instances_by_type;
}
instances_by_type->push(entity);
instances_by_type->push(instance);
ty = IfcSchema::Type::Parent(ty);
} while ( ty > -1 );
int new_id = -1;
if (entity->entity->isWritable() && !entity->entity->file) {
if (instance->data().isWritable() && !instance->data().file) {
// For newly created entities ensure a valid ENTITY_INSTANCE_NAME is set
entity->entity->file = this;
new_id = entity->entity->isWritable()->setId();
instance->data().file = this;
new_id = instance->data().isWritable()->setId();
} else {
new_id = entity->entity->id();
new_id = instance->data().id();
}
if (byid.find(new_id) != byid.end()) {
// This should not happen
std::stringstream ss;
ss << "Overwriting entity with id " << new_id;
ss << "Overwriting instance with id " << new_id;
Logger::Message(Logger::LOG_WARNING, ss.str());
}
// The mapping by entity instance name is updated.
byid[new_id] = entity;
byid[new_id] = instance;
// The mapping by reference is updated.
IfcEntityList::ptr entity_attributes(new IfcEntityList);
try {
entity_attributes = traverse(entity, 1);
entity_attributes = traverse(instance, 1);
} catch (...) {}
for (IfcEntityList::it it = entity_attributes->begin(); it != entity_attributes->end(); ++it) {
IfcUtil::IfcBaseClass* entity_attribute = *it;
if (*it == entity) continue;
if (*it == instance) continue;
try {
if (!IfcSchema::Type::IsSimple(entity_attribute->type())) {
unsigned entity_attribute_id = entity_attribute->entity->id();
// if (!IfcSchema::Type::IsSimple(entity_attribute->type())) {
if (!entity_attribute->declaration().as_entity()) {
unsigned entity_attribute_id = entity_attribute->data().id();
IfcEntityList::ptr refs = entitiesByReference(entity_attribute_id);
if (!refs) {
refs = IfcEntityList::ptr(new IfcEntityList);
byref[entity_attribute_id] = refs;
}
refs->push(entity);
refs->push(instance);
}
} catch (const IfcParse::IfcException&) {}
}
return entity;
return instance;
}
IfcWrite::IfcWritableEntity* make_writable(IfcUtil::IfcBaseClass* instance) {
if (instance->entity->isWritable()) {
return instance->entity->isWritable();
if (instance->data().isWritable()) {
return instance->data().isWritable();
}
IfcWrite::IfcWritableEntity* return_value;
instance->entity = return_value = new IfcWrite::IfcWritableEntity(instance->entity);
IfcWrite::IfcWritableEntity* return_value = new IfcWrite::IfcWritableEntity(&instance->data());
instance->data(return_value);
return return_value;
}
void IfcFile::removeEntity(IfcUtil::IfcBaseClass* entity) {
const unsigned id = entity->entity->id();
IfcUtil::IfcBaseClass* file_entity = entityById(id);
void IfcFile::removeEntity(IfcUtil::IfcBaseClass* instance) {
const unsigned id = instance->data().id();
IfcUtil::IfcBaseClass* file_instance = entityById(id);
// TODO: Create a set of weak relations. Inverse relations that do not dictate an
// instance to be retained. For example: when deleting an IfcRepresentation, the
@@ -1265,38 +1333,41 @@ void IfcFile::removeEntity(IfcUtil::IfcBaseClass* entity) {
// characterized as weak.
std::set<IfcSchema::Type::Enum> weak_roots;
if (entity != file_entity) {
if (instance != file_instance) {
throw IfcParse::IfcException("Instance not part of this file");
}
std::set<IfcUtil::IfcBaseClass*> deletion_queue;
IfcEntityList::ptr references = entitiesByReference(id);
// Alter entity instances with INVERSE relations to the entity being
// Alter entity instances with INVERSE relations to the instance being
// deleted. This is necessary to maintain a valid IFC file, because
// dangling references to it's entities name should be removed. At this
// moment, inversely related instances affected by the removal of the
// entity being deleted are not deleted themselves.
// instance being deleted are not deleted themselves.
if (references) {
for (IfcEntityList::it iit = references->begin(); iit != references->end(); ++iit) {
IfcUtil::IfcBaseEntity* related_instance = (IfcUtil::IfcBaseEntity*) *iit;
for (unsigned i = 0; i < related_instance->getArgumentCount(); ++i) {
Argument* attr = related_instance->getArgument(i);
for (unsigned i = 0; i < related_instance->data().getArgumentCount(); ++i) {
Argument* attr = related_instance->data().getArgument(i);
if (attr->isNull()) continue;
IfcUtil::ArgumentType attr_type = related_instance->getArgumentType(i);
IfcUtil::ArgumentType attr_type = attr->type();
switch(attr_type) {
case IfcUtil::Argument_ENTITY_INSTANCE: {
IfcUtil::IfcBaseClass* instance_attribute = *attr;
if (instance_attribute == entity) {
if (instance_attribute == instance) {
make_writable(related_instance)->setArgument(i);
// deletion_queue.insert(related_instance);
} }
break;
case IfcUtil::Argument_AGGREGATE_OF_ENTITY_INSTANCE: {
IfcEntityList::ptr instance_list = *attr;
if (instance_list->contains(entity)) {
instance_list->remove(entity);
if (instance_list->contains(instance)) {
instance_list->remove(instance);
make_writable(related_instance)->setArgument(i, instance_list);
/* if (instance_list->size() == 0) {
deletion_queue.insert(related_instance);
@@ -1305,12 +1376,12 @@ void IfcFile::removeEntity(IfcUtil::IfcBaseClass* entity) {
break;
case IfcUtil::Argument_AGGREGATE_OF_AGGREGATE_OF_ENTITY_INSTANCE: {
IfcEntityListList::ptr instance_list_list = *attr;
if (instance_list_list->contains(entity)) {
if (instance_list_list->contains(instance)) {
IfcEntityListList::ptr new_list(new IfcEntityListList);
for (IfcEntityListList::outer_it it = instance_list_list->begin(); it != instance_list_list->end(); ++it) {
std::vector<IfcUtil::IfcBaseClass*> instances = *it;
std::vector<IfcUtil::IfcBaseClass*>::iterator jt;
while ((jt = std::find(instances.begin(), instances.end(), entity)) != instances.end()) {
while ((jt = std::find(instances.begin(), instances.end(), instance)) != instances.end()) {
instances.erase(jt);
}
new_list->push(instances);
@@ -1328,33 +1399,33 @@ void IfcFile::removeEntity(IfcUtil::IfcBaseClass* entity) {
byref.erase(byref.find(id));
}
IfcEntityList::ptr entity_attributes = traverse(entity, 1);
for (IfcEntityList::it it = entity_attributes->begin(); it != entity_attributes->end(); ++it) {
IfcUtil::IfcBaseClass* entity_attribute = *it;
if (entity_attribute == entity) continue;
entitiesByReference(entity_attribute->entity->id())->remove(entity);
if (entitiesByReference(entity_attribute->entity->id())->filtered(weak_roots)->size() == 0) {
deletion_queue.insert(entity_attribute);
IfcEntityList::ptr instance_attributes = traverse(instance, 1);
for (IfcEntityList::it it = instance_attributes->begin(); it != instance_attributes->end(); ++it) {
IfcUtil::IfcBaseClass* instance_attribute = *it;
if (instance_attribute == instance) continue;
entitiesByReference(instance_attribute->data().id())->remove(instance);
if (entitiesByReference(instance_attribute->data().id())->filtered(weak_roots)->size() == 0) {
deletion_queue.insert(instance_attribute);
}
}
if (entity->is(IfcSchema::Type::IfcRoot)) {
const std::string global_id = ((IfcSchema::IfcRoot*) entity)->GlobalId();
IfcSchema::IfcRoot* root = instance->as<IfcSchema::IfcRoot>();
if (root) {
const std::string global_id = root->GlobalId();
byguid.erase(byguid.find(global_id));
}
byid.erase(byid.find(id));
IfcEntityList::ptr instances_of_same_type = entitiesByType(entity->type());
instances_of_same_type->remove(entity);
IfcEntityList::ptr instances_of_same_type = entitiesByType(instance->declaration().type());
instances_of_same_type->remove(instance);
while (!deletion_queue.empty()) {
removeEntity(*deletion_queue.begin());
deletion_queue.erase(deletion_queue.begin());
}
delete entity->entity;
delete entity;
delete instance;
}
IfcEntityList::ptr IfcFile::entitiesByType(IfcSchema::Type::Enum t) {
@@ -1391,7 +1462,6 @@ IfcSchema::IfcRoot* IfcFile::entityByGuid(const std::string& guid) {
// FIXME: Test destructor to delete entity and arg allocations
IfcFile::~IfcFile() {
for( entity_by_id_t::const_iterator it = byid.begin(); it != byid.end(); ++ it ) {
delete it->second->entity;
delete it->second;
}
delete stream;
@@ -1411,8 +1481,8 @@ std::ostream& operator<< (std::ostream& os, const IfcParse::IfcFile& f) {
for ( IfcFile::entity_by_id_t::const_iterator it = f.begin(); it != f.end(); ++ it ) {
const IfcUtil::IfcBaseClass* e = it->second;
if (!IfcSchema::Type::IsSimple(e->type())) {
os << e->entity->toString(true) << ";" << std::endl;
if (!IfcSchema::Type::IsSimple(e->data().type())) {
os << e->data().toString(true) << ";" << std::endl;
}
}
@@ -1422,22 +1492,6 @@ std::ostream& operator<< (std::ostream& os, const IfcParse::IfcFile& f) {
return os;
}
std::string IfcFile::createTimestamp() const {
char buf[255];
time_t t;
time(&t);
struct tm* ti = localtime (&t);
std::string result = "";
if (strftime(buf,255,"%Y-%m-%dT%H:%M:%S",ti)) {
result = std::string(buf);
}
return result;
}
IfcEntityList::ptr IfcFile::getInverse(int instance_id, IfcSchema::Type::Enum type, int attribute_index) {
IfcUtil::IfcBaseClass* instance = entityById(instance_id);
@@ -1446,9 +1500,9 @@ IfcEntityList::ptr IfcFile::getInverse(int instance_id, IfcSchema::Type::Enum ty
if (!all) return l;
for(IfcEntityList::it it = all->begin(); it != all->end(); ++it) {
bool valid = type == IfcSchema::Type::UNDEFINED || (*it)->is(type);
bool valid = type == IfcSchema::Type::UNDEFINED || (*it)->declaration().is(type);
if (valid && attribute_index >= 0) {
Argument* arg = (*it)->entity->getArgument(attribute_index);
Argument* arg = (*it)->data().getArgument(attribute_index);
if (arg->type() == IfcUtil::Argument_ENTITY_INSTANCE) {
valid = instance == *arg;
} else if (arg->type() == IfcUtil::Argument_AGGREGATE_OF_ENTITY_INSTANCE) {
@@ -1468,24 +1522,7 @@ IfcEntityList::ptr IfcFile::getInverse(int instance_id, IfcSchema::Type::Enum ty
}
void IfcFile::setDefaultHeaderValues() {
const std::string empty_string = "";
std::vector<std::string> file_description, schema_identifiers, empty_vector;
file_description.push_back("ViewDefinition [CoordinationView]");
schema_identifiers.push_back(IfcSchema::Identifier);
header().file_description().description(file_description);
header().file_description().implementation_level("2;1");
header().file_name().name(empty_string);
header().file_name().time_stamp(createTimestamp());
header().file_name().author(empty_vector);
header().file_name().organization(empty_vector);
header().file_name().preprocessor_version("IfcOpenShell " IFCOPENSHELL_VERSION);
header().file_name().originating_system("IfcOpenShell " IFCOPENSHELL_VERSION);
header().file_name().authorization(empty_string);
header().file_schema().schema_identifiers(schema_identifiers);
header().set_default();
}
std::pair<IfcSchema::IfcNamedUnit*, double> IfcFile::getUnit(IfcSchema::IfcUnitEnum::IfcUnitEnum type) {
@@ -1496,21 +1533,21 @@ std::pair<IfcSchema::IfcNamedUnit*, double> IfcFile::getUnit(IfcSchema::IfcUnitE
IfcEntityList::ptr units = project->UnitsInContext()->Units();
for (IfcEntityList::it it = units->begin(); it != units->end(); ++it) {
IfcSchema::IfcUnit* unit = *it;
if (unit->is(IfcSchema::Type::IfcNamedUnit)) {
if (unit->declaration().is(IfcSchema::Type::IfcNamedUnit)) {
IfcSchema::IfcNamedUnit* named_unit = (IfcSchema::IfcNamedUnit*) unit;
if (named_unit->UnitType() != type) {
continue;
}
IfcSchema::IfcSIUnit* siunit = 0;
if (named_unit->is(IfcSchema::Type::IfcConversionBasedUnit)) {
if (named_unit->declaration().is(IfcSchema::Type::IfcConversionBasedUnit)) {
IfcSchema::IfcConversionBasedUnit* u = (IfcSchema::IfcConversionBasedUnit*)named_unit;
IfcSchema::IfcMeasureWithUnit* mu = u->ConversionFactor();
return_value.second *= static_cast<double>(*mu->ValueComponent()->entity->getArgument(0));
return_value.second *= static_cast<double>(*mu->ValueComponent()->data().getArgument(0));
return_value.first = named_unit;
if (mu->UnitComponent()->is(IfcSchema::Type::IfcSIUnit)) {
if (mu->UnitComponent()->declaration().is(IfcSchema::Type::IfcSIUnit)) {
siunit = (IfcSchema::IfcSIUnit*) mu->UnitComponent();
}
} else if (named_unit->is(IfcSchema::Type::IfcSIUnit)) {
} else if (named_unit->declaration().is(IfcSchema::Type::IfcSIUnit)) {
return_value.first = siunit = (IfcSchema::IfcSIUnit*) named_unit;
}
if (siunit) {
@@ -1522,4 +1559,8 @@ std::pair<IfcSchema::IfcNamedUnit*, double> IfcFile::getUnit(IfcSchema::IfcUnitE
}
}
return return_value;
}
void IfcFile::write_hdf5(const std::string& name, const Hdf5Settings& settings) {
IfcHdf5File(this, name, settings);
}
+115 -3
View File
@@ -81,6 +81,7 @@ namespace IfcParse {
static bool isInt(const Token& t);
/// Returns whether the token can be interpreted as a boolean
static bool isBool(const Token& t);
static bool isLogical(const Token& t);
/// Returns whether the token can be interpreted as a floating point number
static bool isFloat(const Token& t);
/// Returns whether the token can be interpreted as a binary type
@@ -89,6 +90,7 @@ namespace IfcParse {
static int asInt(const Token& t);
/// Returns the token interpreted as an boolean (.T. or .F.)
static bool asBool(const Token& t);
static boost::logic::tribool asLogical(const Token& t);
/// Returns the token as a floating point number
static double asFloat(const Token& t);
/// Returns the token as a string (without the dot or apostrophe)
@@ -130,7 +132,7 @@ namespace IfcParse {
std::vector<Argument*> list;
void push(Argument* l);
public:
~ArgumentList();
virtual ~ArgumentList();
void read(IfcSpfLexer* t, std::vector<unsigned int>& ids);
@@ -144,15 +146,21 @@ namespace IfcParse {
operator IfcUtil::IfcBaseClass*() const;
operator std::vector<int>() const;
operator std::vector<bool>() const;
operator std::vector<double>() const;
operator std::vector<std::string>() const;
operator std::vector<boost::dynamic_bitset<> >() const;
operator IfcEntityList::ptr() const;
operator std::vector< std::vector<int> >() const;
operator std::vector< std::vector<bool> >() const;
operator std::vector< std::vector<double> >() const;
operator IfcEntityListList::ptr() const;
operator boost::logic::tribool() const;
operator std::vector<boost::logic::tribool>() const;
operator std::vector< std::vector<boost::logic::tribool> >() const;
bool isNull() const;
unsigned int size() const;
@@ -182,15 +190,21 @@ namespace IfcParse {
operator IfcUtil::IfcBaseClass*() const;
operator std::vector<int>() const;
operator std::vector<bool>() const;
operator std::vector<double>() const;
operator std::vector<std::string>() const;
operator std::vector<boost::dynamic_bitset<> >() const;
operator IfcEntityList::ptr() const;
operator std::vector< std::vector<int> >() const;
operator std::vector< std::vector<bool> >() const;
operator std::vector< std::vector<double> >() const;
operator IfcEntityListList::ptr() const;
operator boost::logic::tribool() const;
operator std::vector<boost::logic::tribool>() const;
operator std::vector< std::vector<boost::logic::tribool> >() const;
bool isNull() const;
unsigned int size() const;
@@ -206,7 +220,7 @@ namespace IfcParse {
IfcUtil::IfcBaseClass* entity;
public:
EntityArgument(const Token& t);
~EntityArgument();
virtual ~EntityArgument();
IfcUtil::ArgumentType type() const;
@@ -218,15 +232,21 @@ namespace IfcParse {
operator IfcUtil::IfcBaseClass*() const;
operator std::vector<int>() const;
operator std::vector<bool>() const;
operator std::vector<double>() const;
operator std::vector<std::string>() const;
operator std::vector<boost::dynamic_bitset<> >() const;
operator IfcEntityList::ptr() const;
operator std::vector< std::vector<int> >() const;
operator std::vector< std::vector<bool> >() const;
operator std::vector< std::vector<double> >() const;
operator IfcEntityListList::ptr() const;
operator boost::logic::tribool() const;
operator std::vector<boost::logic::tribool>() const;
operator std::vector< std::vector<boost::logic::tribool> >() const;
bool isNull() const;
unsigned int size() const;
@@ -251,16 +271,108 @@ namespace IfcParse {
virtual ~Entity();
IfcEntityList::ptr getInverse(IfcSchema::Type::Enum type, int attribute_index);
void Load(std::vector<unsigned int>& ids, bool seek=false) const;
void Unload();
Argument* getArgument (unsigned int i);
unsigned int getArgumentCount() const;
std::string toString(bool upper=false) const;
std::string datatype() const;
IfcSchema::Type::Enum type() const;
bool is(IfcSchema::Type::Enum v) const;
unsigned int id();
unsigned int id() const;
const IfcWrite::IfcWritableEntity* isWritable() const;
IfcWrite::IfcWritableEntity* isWritable();
};
template <typename Fn1, typename Fn2>
class InstanceStreamer {
private:
IfcFile* file_;
IfcSpfStream& stream_;
IfcSpfLexer& lexer_;
Fn1& fn1_;
Fn2& fn2_;
unsigned int current_inst_name_,
last_inst_name_,
num_insts_encountered_,
max_inst_name_encountered_;
public:
InstanceStreamer(IfcFile* file, IfcSpfStream& stream, IfcSpfLexer& lexer, Fn1& fn1, Fn2& fn2)
: file_(file)
, stream_(stream)
, lexer_(lexer)
, fn1_(fn1)
, fn2_(fn2)
, current_inst_name_(0)
, last_inst_name_(0)
, num_insts_encountered_(0)
, max_inst_name_encountered_(0)
{}
unsigned int current_inst_name() { return current_inst_name_; }
unsigned int last_inst_name() { return last_inst_name_; }
unsigned int num_insts_encountered() { return num_insts_encountered_; }
unsigned int max_inst_name_encountered() { return max_inst_name_encountered_; }
void stream() {
Logger::Status("Scanning file...");
Token token = TokenPtr();
Token previous = TokenPtr();
Entity* inst_data;
IfcUtil::IfcBaseClass* entity_instance = 0;
while (!stream_.eof) {
if (current_inst_name_ != 0) {
try {
inst_data = new Entity(current_inst_name_, file_);
entity_instance = IfcSchema::SchemaEntity(inst_data);
} catch (const IfcException& ex) {
current_inst_name_ = 0;
Logger::Message(Logger::LOG_ERROR, ex.what());
continue;
}
// Update the status after every 1000 instances parsed
if (((++num_insts_encountered_) % 1000) == 0) {
std::stringstream ss; ss << "\r#" << current_inst_name_;
Logger::Status(ss.str(), false);
}
fn1_(entity_instance);
max_inst_name_encountered_ = (std::max)(max_inst_name_encountered_, current_inst_name_);
current_inst_name_ = 0;
} else {
try {
token = lexer_.Next();
} catch (...) {
token = TokenPtr();
}
}
if (!(token.second || token.first)) {
break;
}
if ((previous.second || previous.first) && TokenFunc::isIdentifier(previous)) {
int id = TokenFunc::asInt(previous);
if (TokenFunc::isOperator(token, '=')) {
current_inst_name_ = id;
} else if (entity_instance) {
fn2_(entity_instance, id);
}
}
previous = token;
}
Logger::Status("\rDone scanning file ");
}
};
}
std::ostream& operator<< (std::ostream& os, const IfcParse::IfcFile& f);
+21
View File
@@ -0,0 +1,21 @@
#include "IfcSchema.h"
bool IfcParse::declaration::is(const std::string& name) const {
return is(IfcSchema::Type::FromString(name));
}
bool IfcParse::declaration::is(IfcSchema::Type::Enum name) const {
if (this->as_entity()) {
return this->as_entity()->is(name);
} else {
return this->name() == IfcSchema::Type::ToString(name);
}
}
bool IfcParse::named_type::is(const std::string& name) const {
return declared_type()->is(name);
}
bool IfcParse::named_type::is(IfcSchema::Type::Enum name) const {
return declared_type()->is(name);
}
+431
View File
@@ -0,0 +1,431 @@
/********************************************************************************
* *
* This file is part of IfcOpenShell. *
* *
* IfcOpenShell is free software: you can redistribute it and/or modify *
* it under the terms of the Lesser GNU General Public License as published by *
* the Free Software Foundation, either version 3.0 of the License, or *
* (at your option) any later version. *
* *
* IfcOpenShell is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* Lesser GNU General Public License for more details. *
* *
* You should have received a copy of the Lesser GNU General Public License *
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
* *
********************************************************************************/
#ifndef IFCSCHEMA_H
#define IFCSCHEMA_H
#include <string>
#include <vector>
#include <algorithm>
#include <iterator>
#include <boost/algorithm/string.hpp>
#include "../ifcparse/IfcException.h"
#ifdef USE_IFC4
#include "../ifcparse/Ifc4enum.h"
#else
#include "../ifcparse/Ifc2x3enum.h"
#endif
namespace IfcParse {
class declaration;
class type_declaration;
class select_type;
class enumeration_type;
class entity;
class named_type;
class simple_type;
class aggregation_type;
class parameter_type {
public:
virtual const named_type* as_named_type() const { return static_cast<named_type*>(0); }
virtual const simple_type* as_simple_type() const { return static_cast<simple_type*>(0); }
virtual const aggregation_type* as_aggregation_type() const { return static_cast<aggregation_type*>(0); }
virtual bool is(const std::string& /*name*/) const { return false; }
virtual bool is(IfcSchema::Type::Enum /*name*/) const { return false; }
};
class named_type : public parameter_type {
protected:
declaration* declared_type_;
public:
named_type(declaration* declared_type)
: declared_type_(declared_type) {}
declaration* declared_type() const { return declared_type_; }
virtual const named_type* as_named_type() const { return this; }
virtual bool is(const std::string& name) const;
virtual bool is(IfcSchema::Type::Enum name) const;
};
class simple_type : public parameter_type {
public:
typedef enum { binary_type, boolean_type, integer_type, logical_type, number_type, real_type, string_type, datatype_COUNT } data_type;
protected:
data_type declared_type_;
public:
simple_type(data_type declared_type)
: declared_type_(declared_type) {}
data_type declared_type() const { return declared_type_; }
virtual const simple_type* as_simple_type() const { return this; }
};
class aggregation_type : public parameter_type {
public:
typedef enum { array_type, bag_type, list_type, set_type } aggregate_type;
protected:
aggregate_type type_of_aggregation_;
int bound1_, bound2_;
parameter_type* type_of_element_;
public:
aggregation_type(aggregate_type type_of_aggregation, int bound1, int bound2, parameter_type* type_of_element)
: type_of_aggregation_(type_of_aggregation)
, bound1_(bound1)
, bound2_(bound2)
, type_of_element_(type_of_element)
{}
aggregate_type type_of_aggregation() const { type_of_aggregation_; }
int bound1() const { return bound1_; }
int bound2() const { return bound2_; }
parameter_type* type_of_element() const { return type_of_element_; }
virtual const aggregation_type* as_aggregation_type() const { return this; }
};
class declaration {
protected:
// std::string name_;
IfcSchema::Type::Enum name_;
public:
declaration(IfcSchema::Type::Enum name)
: name_(name) {}
declaration(const std::string& name)
: name_(IfcSchema::Type::FromString(name)) {}
std::string name() const { return IfcSchema::Type::ToString(name_); }
virtual const type_declaration* as_type_declaration() const { return static_cast<type_declaration*>(0); }
virtual const select_type* as_select_type() const { return static_cast<select_type*>(0); }
virtual const enumeration_type* as_enumeration_type() const { return static_cast<enumeration_type*>(0); }
virtual const entity* as_entity() const { return static_cast<entity*>(0); }
// TODO: Type checking by Enum value
bool is(const std::string& name) const;
bool is(IfcSchema::Type::Enum name) const;
IfcSchema::Type::Enum type() const {
return name_;
}
};
class type_declaration : public declaration {
protected:
const parameter_type* declared_type_;
public:
type_declaration(const std::string& name, const parameter_type* declared_type)
: declaration(name)
, declared_type_(declared_type) {}
type_declaration(IfcSchema::Type::Enum name, const parameter_type* declared_type)
: declaration(name)
, declared_type_(declared_type) {}
const parameter_type* declared_type() const { return declared_type_; }
virtual const type_declaration* as_type_declaration() const { return this; }
};
class select_type : public declaration {
protected:
std::vector<const declaration*> select_list_;
public:
select_type(const std::string& name, const std::vector<const declaration*>& select_list)
: declaration(name)
, select_list_(select_list) {}
select_type(IfcSchema::Type::Enum name, const std::vector<const declaration*>& select_list)
: declaration(name)
, select_list_(select_list) {}
const std::vector<const declaration*>& select_list() const { return select_list_; }
virtual const select_type* as_select_type() const { return this; }
};
class enumeration_type : public declaration {
protected:
std::vector<std::string> enumeration_items_;
public:
enumeration_type(const std::string& name, const std::vector<std::string>& enumeration_items)
: declaration(name)
, enumeration_items_(enumeration_items) {}
enumeration_type(IfcSchema::Type::Enum name, const std::vector<std::string>& enumeration_items)
: declaration(name)
, enumeration_items_(enumeration_items) {}
const std::vector<std::string>& enumeration_items() const { return enumeration_items_; }
virtual const enumeration_type* as_enumeration_type() const { return this; }
};
class entity : public declaration {
public:
class attribute {
protected:
std::string name_;
const parameter_type* type_of_attribute_;
bool optional_;
public:
attribute(const std::string& name, parameter_type* type_of_attribute, bool optional)
: name_(name)
, type_of_attribute_(type_of_attribute)
, optional_(optional) {}
const std::string& name() const { return name_; }
const parameter_type* type_of_attribute() const { return type_of_attribute_; }
bool optional() const { return optional_; }
};
class inverse_attribute {
public:
typedef enum { bag_type, set_type, unspecified_type } aggregate_type;
protected:
std::string name_;
aggregate_type type_of_aggregation_;
int bound1_, bound2_;
const entity* entity_reference_;
const attribute* attribute_reference_;
public:
inverse_attribute(const std::string& name, aggregate_type type_of_aggregation, int bound1, int bound2, const entity* entity_reference, const attribute* attribute_reference)
: name_(name)
, type_of_aggregation_(type_of_aggregation)
, bound1_(bound1)
, bound2_(bound2)
, entity_reference_(entity_reference)
, attribute_reference_(attribute_reference)
{}
const std::string& name() const { return name_; }
aggregate_type type_of_aggregation() const { type_of_aggregation_; }
int bound1() const { return bound1_; }
int bound2() const { return bound2_; }
const entity* entity_reference() const { return entity_reference_; }
const attribute* attribute_reference() const { return attribute_reference_; }
};
protected:
const entity* supertype_; /* NB: IFC explicitly allows only single inheritance */
std::vector<const entity*> subtypes_;
std::vector<const attribute*> attributes_;
std::vector<bool> derived_;
std::vector<const inverse_attribute*> inverse_attributes_;
class attribute_by_name_cmp : public std::unary_function<const attribute*, bool> {
private:
std::string name_;
public:
attribute_by_name_cmp(const std::string name)
: name_(name) {}
bool operator()(const attribute* attr) {
return attr->name() == name_;
}
};
public:
entity(const std::string& name, entity* supertype)
: declaration(name)
, supertype_(supertype)
{}
entity(IfcSchema::Type::Enum name, entity* supertype)
: declaration(name)
, supertype_(supertype)
{}
bool is(const std::string& name) const {
return is(IfcSchema::Type::FromString(name));
}
bool is(IfcSchema::Type::Enum name) const {
if (name == name_) return true;
else if (supertype_) return supertype_->is(name);
else return false;
}
void set_subtypes(const std::vector<const entity*>& subtypes) {
subtypes_ = subtypes;
}
void set_attributes(const std::vector<const attribute*>& attributes, const std::vector<bool>& derived) {
attributes_ = attributes;
derived_ = derived;
}
void set_inverse_attributes(const std::vector<const inverse_attribute*>& inverse_attributes) {
inverse_attributes_ = inverse_attributes;
}
const std::vector<const entity*>& subtypes() const { return subtypes_; }
const std::vector<const attribute*>& attributes() const { return attributes_; }
const std::vector<bool>& derived() const { return derived_; }
const std::vector<const attribute*> all_attributes() const {
std::vector<const attribute*> attrs;
attrs.reserve(derived_.size());
if (supertype_) {
const std::vector<const attribute*> supertype_attrs = supertype_->all_attributes();
std::copy(supertype_attrs.begin(), supertype_attrs.end(), std::back_inserter(attrs));
}
std::copy(attributes_.begin(), attributes_.end(), std::back_inserter(attrs));
return attrs;
}
const std::vector<const inverse_attribute*> all_inverse_attributes() const {
std::vector<const inverse_attribute*> attrs;
if (supertype_) {
const std::vector<const inverse_attribute*> supertype_inv_attrs = supertype_->all_inverse_attributes();
std::copy(supertype_inv_attrs.begin(), supertype_inv_attrs.end(), std::back_inserter(attrs));
}
std::copy(inverse_attributes_.begin(), inverse_attributes_.end(), std::back_inserter(attrs));
return attrs;
}
ptrdiff_t attribute_index(const attribute* attr) const {
const entity* current = this;
ptrdiff_t index = -1;
do {
if (index > -1) {
index += current->attributes().size();
} else {
auto it = std::find(current->attributes().begin(), current->attributes().end(), attr);
if (it != current->attributes().end()) {
index = std::distance(current->attributes().begin(), it);
}
}
} while (current = current->supertype_);
return index;
}
ptrdiff_t attribute_index(const std::string& attr_name) const {
const entity* current = this;
ptrdiff_t index = -1;
attribute_by_name_cmp cmp(attr_name);
do {
if (index > -1) {
index += current->attributes().size();
} else {
auto it = std::find_if(current->attributes().begin(), current->attributes().end(), cmp);
if (it != current->attributes().end()) {
index = std::distance(current->attributes().begin(), it);
}
}
} while (current = current->supertype_);
return index;
}
const entity* supertype() const { return supertype_; }
virtual const entity* as_entity() const { return this; }
};
class schema_definition {
private:
bool built_in_;
std::string name_;
std::vector<const declaration*> declarations_;
std::vector<const type_declaration*> type_declarations_;
std::vector<const select_type*> select_types_;
std::vector<const enumeration_type*> enumeration_types_;
std::vector<const entity*> entities_;
class declaration_by_name_cmp : public std::binary_function<const declaration*, const std::string&, bool> {
public:
bool operator()(const declaration* decl, const std::string& name) {
// TODO: Efficiency?
return boost::to_lower_copy(decl->name()) < boost::to_lower_copy(name);
}
};
class declaration_by_enum_cmp : public std::binary_function<const declaration*, IfcSchema::Type::Enum, bool> {
public:
bool operator()(const declaration* decl, IfcSchema::Type::Enum name) {
return decl->type() < name;
}
};
class declaration_by_enum_sort : public std::binary_function<const declaration*, const declaration*, bool> {
public:
bool operator()(const declaration* a, const declaration* b) {
return a->type() < b->type();
}
};
public:
schema_definition(const std::string& name, const std::vector<const declaration*>& declarations, const bool built_in = false)
: name_(name)
, declarations_(declarations)
, built_in_(built_in)
{
std::sort(declarations_.begin(), declarations_.end(), declaration_by_enum_sort());
for (std::vector<const declaration*>::const_iterator it = declarations_.begin(); it != declarations_.end(); ++it) {
if ((**it).as_type_declaration()) type_declarations_.push_back((**it).as_type_declaration());
if ((**it).as_select_type()) select_types_.push_back((**it).as_select_type());
if ((**it).as_enumeration_type()) enumeration_types_.push_back((**it).as_enumeration_type());
if ((**it).as_entity()) entities_.push_back((**it).as_entity());
}
}
~schema_definition() {
for (std::vector<const declaration*>::const_iterator it = declarations_.begin(); it != declarations_.end(); ++it) {
delete *it;
}
}
const declaration* declaration_by_name(const std::string& name) const {
std::vector<const declaration*>::const_iterator it = std::lower_bound(declarations_.begin(), declarations_.end(), name, declaration_by_name_cmp());
if (it == declarations_.end() || boost::to_lower_copy((**it).name()) != boost::to_lower_copy(name)) {
throw IfcParse::IfcException("Entity with '" + name + "' not found");
} else {
return *it;
}
}
const declaration* declaration_by_name(IfcSchema::Type::Enum name) const {
if (!built_in_) throw;
return declarations_[name];
}
const std::vector<const declaration*>& declarations() const { return declarations_; }
const std::vector<const type_declaration*>& type_declarations() const { return type_declarations_; }
const std::vector<const select_type*>& select_types() const { return select_types_; }
const std::vector<const enumeration_type*>& enumeration_types() const { return enumeration_types_; }
const std::vector<const entity*>& entities() const { return entities_; }
const std::string& name() const { return name_; }
};
}
#endif
+38 -1
View File
@@ -147,4 +147,41 @@ FileSchema& IfcSpfHeader::file_schema() {
FileDescription::FileDescription(IfcSpfLexer* lexer) : HeaderEntity(FILE_DESCRIPTION, lexer) {}
FileName::FileName(IfcSpfLexer* lexer) : HeaderEntity(FILE_NAME, lexer) {}
FileSchema::FileSchema(IfcSpfLexer* lexer) : HeaderEntity(FILE_SCHEMA, lexer) {}
FileSchema::FileSchema(IfcSpfLexer* lexer) : HeaderEntity(FILE_SCHEMA, lexer) {}
std::string createTimestamp() {
char buf[255];
time_t t;
time(&t);
struct tm* ti = localtime(&t);
std::string result = "";
if (strftime(buf, 255, "%Y-%m-%dT%H:%M:%S", ti)) {
result = std::string(buf);
}
return result;
}
void IfcSpfHeader::set_default() {
const std::string empty_string = "";
std::vector<std::string> file_description_vector, schema_identifiers, empty_vector;
file_description_vector.push_back("ViewDefinition [CoordinationView]");
schema_identifiers.push_back(IfcSchema::Identifier);
file_description().description(file_description_vector);
file_description().implementation_level("2;1");
file_name().name(empty_string);
file_name().time_stamp(createTimestamp());
file_name().author(empty_vector);
file_name().organization(empty_vector);
file_name().preprocessor_version("IfcOpenShell " IFCOPENSHELL_VERSION);
file_name().originating_system("IfcOpenShell " IFCOPENSHELL_VERSION);
file_name().authorization(empty_string);
file_schema().schema_identifiers(schema_identifiers);
}
+7 -1
View File
@@ -94,7 +94,11 @@ public:
return ss.str();
}
unsigned int id() {
unsigned int id() const {
return 0;
}
const IfcWrite::IfcWritableEntity* isWritable() const {
return 0;
}
@@ -189,6 +193,8 @@ public:
FileDescription& file_description();
FileName& file_name();
FileSchema& file_schema();
void set_default();
};
}
+17 -6
View File
@@ -56,7 +56,7 @@ IfcEntityList::ptr IfcEntityList::filtered(const std::set<IfcSchema::Type::Enum>
for (it it = begin(); it != end(); ++it) {
bool contained = false;
for (std::set<IfcSchema::Type::Enum>::const_iterator jt = entities.begin(); jt != entities.end(); ++jt) {
if ((*it)->is(*jt)) {
if ((*it)->declaration().is(*jt)) {
contained = true;
break;
}
@@ -69,9 +69,9 @@ IfcEntityList::ptr IfcEntityList::filtered(const std::set<IfcSchema::Type::Enum>
}
unsigned int IfcUtil::IfcBaseType::getArgumentCount() const { return 1; }
Argument* IfcUtil::IfcBaseType::getArgument(unsigned int i) const { return entity->getArgument(i); }
const char* IfcUtil::IfcBaseType::getArgumentName(unsigned int i) const { if (i == 0) { return "wrappedValue"; } else { throw IfcParse::IfcAttributeOutOfRangeException("Argument index out of range"); } }
// unsigned int IfcUtil::IfcBaseType::getArgumentCount() const { return 1; }
// Argument* IfcUtil::IfcBaseType::getArgument(unsigned int i) const { return entity->getArgument(i); }
// const char* IfcUtil::IfcBaseType::getArgumentName(unsigned int i) const { if (i == 0) { return "wrappedValue"; } else { throw IfcParse::IfcAttributeOutOfRangeException("Argument index out of range"); } }
void Logger::SetOutput(std::ostream* l1, std::ostream* l2) {
log1 = l1;
@@ -80,10 +80,10 @@ void Logger::SetOutput(std::ostream* l1, std::ostream* l2) {
log2 = &log_stream;
}
}
void Logger::Message(Logger::Severity type, const std::string& message, IfcAbstractEntity* entity) {
void Logger::Message(Logger::Severity type, const std::string& message, const IfcUtil::IfcBaseClass* entity) {
if ( log2 && type >= verbosity ) {
(*log2) << "[" << severity_strings[type] << "] " << message << std::endl;
if ( entity ) (*log2) << entity->toString() << std::endl;
if ( entity ) (*log2) << entity->data().toString() << std::endl;
}
}
void Logger::Status(const std::string& message, bool new_line) {
@@ -122,12 +122,14 @@ static const char* const argument_type_string[] = {
"ENTITY INSTANCE",
"AGGREGATE OF INT",
"AGGREGATE OF BOOL",
"AGGREGATE OF DOUBLE",
"AGGREGATE OF STRING",
"AGGREGATE OF BINARY",
"AGGREGATE OF ENTITY INSTANCE",
"AGGREGATE OF AGGREGATE OF INT",
"AGGREGATE OF AGGREGATE OF BOOL",
"AGGREGATE OF AGGREGATE OF DOUBLE",
"AGGREGATE OF AGGREGATE OF ENTITY INSTANCE",
@@ -143,4 +145,13 @@ bool IfcUtil::valid_binary_string(const std::string& s) {
if (*it != '0' && *it != '1') return false;
}
return true;
}
IfcUtil::IfcBaseClass::~IfcBaseClass() {
delete data_;
}
void IfcUtil::IfcBaseClass::data(IfcAbstractEntity* d) {
delete data_;
data_ = d;
}
+100 -22
View File
@@ -20,6 +20,9 @@
#ifndef IFCUTIL_H
#define IFCUTIL_H
#define BOOST_MPL_CFG_NO_PREPROCESSED_HEADERS
#define BOOST_MPL_LIMIT_LIST_SIZE 30
#include <set>
#include <string>
#include <vector>
@@ -28,6 +31,9 @@
#include <boost/shared_ptr.hpp>
#include <boost/dynamic_bitset.hpp>
#include <boost/logic/tribool.hpp>
#include "../ifcparse/IfcSchema.h"
#ifdef USE_IFC4
#include "../ifcparse/Ifc4enum.h"
@@ -39,6 +45,13 @@ class Argument;
class IfcEntityList;
class IfcEntityListList;
class IfcAbstractEntity;
namespace IfcParse { // these have to be declared first in order for the virtual function below to be covariant. separate into different header file
class declaration;
class entity;
class type_declaration;
}
namespace IfcWrite {
class IfcWritableEntity;
}
@@ -49,6 +62,7 @@ namespace IfcUtil {
Argument_DERIVED,
Argument_INT,
Argument_BOOL,
Argument_TRIBOOL,
Argument_DOUBLE,
Argument_STRING,
Argument_BINARY,
@@ -56,12 +70,16 @@ namespace IfcUtil {
Argument_ENTITY_INSTANCE,
Argument_AGGREGATE_OF_INT,
Argument_AGGREGATE_OF_DOUBLE,
Argument_AGGREGATE_OF_BOOL,
Argument_AGGREGATE_OF_TRIBOOL,
Argument_AGGREGATE_OF_DOUBLE,
Argument_AGGREGATE_OF_STRING,
Argument_AGGREGATE_OF_BINARY,
Argument_AGGREGATE_OF_ENTITY_INSTANCE,
Argument_AGGREGATE_OF_AGGREGATE_OF_INT,
Argument_AGGREGATE_OF_AGGREGATE_OF_BOOL,
Argument_AGGREGATE_OF_AGGREGATE_OF_TRIBOOL,
Argument_AGGREGATE_OF_AGGREGATE_OF_DOUBLE,
Argument_AGGREGATE_OF_AGGREGATE_OF_ENTITY_INSTANCE,
@@ -71,45 +89,73 @@ namespace IfcUtil {
const char* ArgumentTypeToString(ArgumentType argument_type);
class IfcBaseClass {
protected:
IfcAbstractEntity* data_;
public:
IfcAbstractEntity* entity;
virtual bool is(IfcSchema::Type::Enum v) const = 0;
virtual IfcSchema::Type::Enum type() const = 0;
IfcBaseClass() : data_(0) {}
IfcBaseClass(IfcAbstractEntity* d) : data_(d) {}
virtual ~IfcBaseClass();
virtual unsigned int getArgumentCount() const = 0;
virtual ArgumentType getArgumentType(unsigned int i) const = 0;
virtual IfcSchema::Type::Enum getArgumentEntity(unsigned int i) const = 0;
virtual Argument* getArgument(unsigned int i) const = 0;
virtual const char* getArgumentName(unsigned int i) const = 0;
const IfcAbstractEntity& data() const { return *data_; }
IfcAbstractEntity& data() { return *data_; }
void data(IfcAbstractEntity* d);
virtual const IfcParse::declaration& declaration() const = 0;
template <class T>
T* as() {
return is(T::Class())
return declaration().is(T::Class())
? static_cast<T*>(this)
: static_cast<T*>(0);
}
template <class T>
const T* as() const {
return is(T::Class())
return declaration().is(T::Class())
? static_cast<const T*>(this)
: static_cast<const T*>(0);
}
private:
IfcBaseClass(const IfcBaseClass&);
IfcBaseClass& operator=(const IfcBaseClass&);
};
class IfcBaseEntity : public IfcBaseClass {
public:
IfcBaseEntity() : IfcBaseClass() {}
IfcBaseEntity(IfcAbstractEntity* d) : IfcBaseClass(d) {}
virtual const IfcParse::entity& declaration() const = 0;
};
// TODO: Investigate whether these should be template classes instead
class IfcBaseType : public IfcBaseEntity {
class IfcBaseType : public IfcBaseClass {
public:
unsigned int getArgumentCount() const;
Argument* getArgument(unsigned int i) const;
const char* getArgumentName(unsigned int i) const;
IfcSchema::Type::Enum getArgumentEntity(unsigned int /*i*/) const { return IfcSchema::Type::UNDEFINED; }
IfcBaseType() : IfcBaseClass() {}
IfcBaseType(IfcAbstractEntity* d) : IfcBaseClass(d) {}
virtual const IfcParse::type_declaration& declaration() const = 0;
};
bool valid_binary_string(const std::string& s);
template <typename T> struct cpp_to_schema_type;
template <> struct cpp_to_schema_type < boost::dynamic_bitset<> > { static const IfcParse::simple_type::data_type schema_type = IfcParse::simple_type::binary_type; };
template <> struct cpp_to_schema_type < bool > { static const IfcParse::simple_type::data_type schema_type = IfcParse::simple_type::boolean_type; };
template <> struct cpp_to_schema_type < int > { static const IfcParse::simple_type::data_type schema_type = IfcParse::simple_type::integer_type; };
template <> struct cpp_to_schema_type < double > { static const IfcParse::simple_type::data_type schema_type = IfcParse::simple_type::real_type; };
template <> struct cpp_to_schema_type < std::string > { static const IfcParse::simple_type::data_type schema_type = IfcParse::simple_type::string_type; };
template <IfcParse::simple_type::data_type T>
struct schema_to_cpp_type;
template <> struct schema_to_cpp_type < IfcParse::simple_type::binary_type > { typedef boost::dynamic_bitset<> cpp_type; };
template <> struct schema_to_cpp_type < IfcParse::simple_type::boolean_type > { typedef bool cpp_type; };
template <> struct schema_to_cpp_type < IfcParse::simple_type::integer_type > { typedef int cpp_type; };
template <> struct schema_to_cpp_type < IfcParse::simple_type::logical_type > { typedef bool cpp_type; };
template <> struct schema_to_cpp_type < IfcParse::simple_type::number_type > { typedef double cpp_type; };
template <> struct schema_to_cpp_type < IfcParse::simple_type::real_type > { typedef double cpp_type; };
template <> struct schema_to_cpp_type < IfcParse::simple_type::string_type > { typedef std::string cpp_type; };
}
template <class T>
@@ -131,7 +177,7 @@ public:
typename U::list::ptr as() {
typename U::list::ptr r(new typename U::list);
const bool all = U::Class() == IfcSchema::Type::UNDEFINED;
for ( it i = begin(); i != end(); ++ i ) if (all || (*i)->is(U::Class())) r->push((U*)*i);
for ( it i = begin(); i != end(); ++ i ) if (all || (*i)->declaration().is(U::Class())) r->push((U*)*i);
return r;
}
void remove(IfcUtil::IfcBaseClass*);
@@ -159,7 +205,7 @@ public:
typename U::list::ptr as() {
typename U::list::ptr r(new typename U::list);
const bool all = U::Class() == IfcSchema::Type::UNDEFINED;
for ( it i = begin(); i != end(); ++ i ) if (all || (*i)->is(U::Class())) r->push((U*)*i);
for ( it i = begin(); i != end(); ++ i ) if (all || (*i)->declaration().is(U::Class())) r->push((U*)*i);
return r;
}
void remove(T* t) {
@@ -193,7 +239,7 @@ public:
}
outer_it begin() const { return ls.begin(); }
outer_it end() const { return ls.end(); }
int size() const { return (int)ls.size(); }
unsigned int size() const { return (unsigned int)ls.size(); }
int totalSize() const {
int accum = 0;
for (outer_it it = begin(); it != end(); ++it) {
@@ -218,7 +264,7 @@ public:
const std::vector<IfcUtil::IfcBaseClass*>& from = *outer;
typename std::vector<U*> to;
for (inner_it inner = from.begin(); inner != from.end(); ++ inner) {
if (all || (*inner)->is(U::Class())) to.push_back((U*)*inner);
if (all || (*inner)->declaration().is(U::Class())) to.push_back((U*)*inner);
}
r->push(to);
}
@@ -275,18 +321,23 @@ class Argument {
public:
virtual operator int() const = 0;
virtual operator bool() const = 0;
virtual operator boost::logic::tribool() const = 0;
virtual operator double() const = 0;
virtual operator std::string() const = 0;
virtual operator boost::dynamic_bitset<>() const = 0;
virtual operator IfcUtil::IfcBaseClass*() const = 0;
virtual operator std::vector<int>() const = 0;
virtual operator std::vector<bool>() const = 0;
virtual operator std::vector<boost::logic::tribool>() const = 0;
virtual operator std::vector<double>() const = 0;
virtual operator std::vector<std::string>() const = 0;
virtual operator std::vector<boost::dynamic_bitset<> >() const = 0;
virtual operator IfcEntityList::ptr() const = 0;
virtual operator std::vector< std::vector<int> >() const = 0;
virtual operator std::vector< std::vector<bool> >() const = 0;
virtual operator std::vector< std::vector<boost::logic::tribool> >() const = 0;
virtual operator std::vector< std::vector<double> >() const = 0;
virtual operator IfcEntityListList::ptr() const = 0;
@@ -311,7 +362,8 @@ public:
virtual IfcSchema::Type::Enum type() const = 0;
virtual bool is(IfcSchema::Type::Enum v) const = 0;
virtual std::string toString(bool upper=false) const = 0;
virtual unsigned int id() = 0;
virtual unsigned int id() const = 0;
virtual const IfcWrite::IfcWritableEntity* isWritable() const = 0;
virtual IfcWrite::IfcWritableEntity* isWritable() = 0;
};
@@ -331,10 +383,36 @@ public:
static void Verbosity(Severity v);
static Severity Verbosity();
/// Log a message to the output stream
static void Message(Severity type, const std::string& message, IfcAbstractEntity* entity=0);
static void Message(Severity type, const std::string& message, const IfcUtil::IfcBaseClass* instance=0);
static void Status(const std::string& message, bool new_line=true);
static void ProgressBar(int progress);
static std::string GetLog();
};
namespace IfcUtil {
template <ArgumentType>
struct attr_type_to_cpp_type;
template <> struct attr_type_to_cpp_type <Argument_INT> { typedef int cpp_type; };
template <> struct attr_type_to_cpp_type <Argument_BOOL> { typedef bool cpp_type; };
template <> struct attr_type_to_cpp_type <Argument_TRIBOOL> { typedef boost::logic::tribool cpp_type; };
template <> struct attr_type_to_cpp_type <Argument_DOUBLE> { typedef double cpp_type; };
template <> struct attr_type_to_cpp_type <Argument_STRING> { typedef std::string cpp_type; };
template <> struct attr_type_to_cpp_type <Argument_BINARY> { typedef boost::dynamic_bitset<> cpp_type; };
template <> struct attr_type_to_cpp_type <Argument_ENTITY_INSTANCE> { typedef IfcUtil::IfcBaseClass* cpp_type; };
template <> struct attr_type_to_cpp_type <Argument_AGGREGATE_OF_INT> { typedef std::vector<int> cpp_type; };
template <> struct attr_type_to_cpp_type <Argument_AGGREGATE_OF_BOOL> { typedef std::vector<bool> cpp_type; };
template <> struct attr_type_to_cpp_type <Argument_AGGREGATE_OF_TRIBOOL> { typedef std::vector<boost::logic::tribool> cpp_type; };
template <> struct attr_type_to_cpp_type <Argument_AGGREGATE_OF_DOUBLE> { typedef std::vector<double> cpp_type; };
template <> struct attr_type_to_cpp_type <Argument_AGGREGATE_OF_STRING> { typedef std::vector<std::string> cpp_type; };
template <> struct attr_type_to_cpp_type <Argument_AGGREGATE_OF_BINARY> { typedef std::vector< boost::dynamic_bitset<> > cpp_type; };
template <> struct attr_type_to_cpp_type <Argument_AGGREGATE_OF_ENTITY_INSTANCE> { typedef IfcEntityList::ptr cpp_type; };
template <> struct attr_type_to_cpp_type <Argument_AGGREGATE_OF_AGGREGATE_OF_INT> { typedef std::vector< std::vector<int> > cpp_type; };
template <> struct attr_type_to_cpp_type <Argument_AGGREGATE_OF_AGGREGATE_OF_BOOL> { typedef std::vector< std::vector<bool> > cpp_type; };
template <> struct attr_type_to_cpp_type <Argument_AGGREGATE_OF_AGGREGATE_OF_TRIBOOL> { typedef std::vector< std::vector<boost::logic::tribool> > cpp_type; };
template <> struct attr_type_to_cpp_type <Argument_AGGREGATE_OF_AGGREGATE_OF_DOUBLE> { typedef std::vector< std::vector<double> > cpp_type; };
template <> struct attr_type_to_cpp_type <Argument_AGGREGATE_OF_AGGREGATE_OF_ENTITY_INSTANCE> { typedef IfcEntityListList::ptr cpp_type; };
}
#endif
+10 -2
View File
@@ -40,12 +40,17 @@
namespace IfcWrite {
class IfcWritableEntity : public IfcAbstractEntity {
private:
// Mutable because calling id() will generate a fresh id on
// the current file, in case none has been assigned previously
mutable int* _id;
std::map<int,bool> writemask;
std::map<int,Argument*> args;
IfcSchema::Type::Enum _type;
int* _id;
bool arg_writable(int i);
void arg_writable(int i, bool b);
template <typename T> void _setArgument(int i, const T&);
public:
IfcWritableEntity(IfcSchema::Type::Enum t);
@@ -60,7 +65,8 @@ namespace IfcWrite {
IfcSchema::Type::Enum type() const;
bool is(IfcSchema::Type::Enum v) const;
std::string toString(bool upper=false) const;
unsigned int id();
unsigned int id() const;
const IfcWritableEntity* isWritable() const;
IfcWritableEntity* isWritable();
void setArgument(int i, Argument* a);
@@ -77,12 +83,14 @@ namespace IfcWrite {
void setArgument(int i,IfcUtil::IfcBaseClass* v);
void setArgument(int i,const std::vector<int>& v);
void setArgument(int i,const std::vector<bool>& v);
void setArgument(int i,const std::vector<double>& v);
void setArgument(int i,const std::vector<std::string>& v);
void setArgument(int i,const std::vector< boost::dynamic_bitset<> >& v);
void setArgument(int i,IfcEntityList::ptr v);
void setArgument(int i,const std::vector< std::vector<int> >& v);
void setArgument(int i,const std::vector< std::vector<bool> >& v);
void setArgument(int i,const std::vector< std::vector<double> >& v);
void setArgument(int i,IfcEntityListList::ptr v);
};
+140 -60
View File
@@ -111,12 +111,13 @@ std::string IfcWritableEntity::toString(bool upper) const {
return ss.str();
}
unsigned int IfcWritableEntity::id() {
unsigned int IfcWritableEntity::id() const {
if ( !_id ) {
_id = new int(file->FreshId());
}
return *_id;
}
const IfcWritableEntity* IfcWritableEntity::isWritable() const { return this; }
IfcWritableEntity* IfcWritableEntity::isWritable() { return this; }
bool IfcWritableEntity::arg_writable(int i) {
std::map<int,bool>::const_iterator it = writemask.find(i);
@@ -154,6 +155,9 @@ void IfcWritableEntity::setArgument(int i, Argument* a) {
case IfcUtil::Argument_BOOL:
this->setArgument(i, static_cast<bool>(*a));
break;
case IfcUtil::Argument_TRIBOOL:
this->setArgument(i, a->operator boost::logic::tribool());
break;
case IfcUtil::Argument_DOUBLE:
this->setArgument(i, static_cast<double>(*a));
break;
@@ -168,6 +172,10 @@ void IfcWritableEntity::setArgument(int i, Argument* a) {
std::vector<int> attr_value = *a;
this->setArgument(i, attr_value); }
break;
case IfcUtil::Argument_AGGREGATE_OF_BOOL: {
std::vector<bool> attr_value = *a;
this->setArgument(i, attr_value); }
break;
case IfcUtil::Argument_AGGREGATE_OF_DOUBLE: {
std::vector<double> attr_value = *a;
this->setArgument(i, attr_value); }
@@ -203,6 +211,10 @@ void IfcWritableEntity::setArgument(int i, Argument* a) {
std::vector< std::vector<int> > attr_value = *a;
this->setArgument(i, attr_value); }
break;
case IfcUtil::Argument_AGGREGATE_OF_AGGREGATE_OF_BOOL: {
std::vector< std::vector<bool> > attr_value = *a;
this->setArgument(i, attr_value); }
break;
case IfcUtil::Argument_AGGREGATE_OF_AGGREGATE_OF_DOUBLE: {
std::vector< std::vector<double> > attr_value = *a;
this->setArgument(i, attr_value); }
@@ -269,19 +281,25 @@ void IfcWritableEntity::setArgument(int i,IfcEntityListList::ptr v){
_setArgument(i, boost::none);
}
}
void IfcWritableEntity::setArgument(int i,const std::vector<double>& v){
void IfcWritableEntity::setArgument(int i,const std::vector<int>& v){
_setArgument(i, v);
}
void IfcWritableEntity::setArgument(int i,const std::vector< std::vector<double> >& v){
void IfcWritableEntity::setArgument(int i,const std::vector<bool>& v){
_setArgument(i, v);
}
void IfcWritableEntity::setArgument(int i,const std::vector<double>& v){
_setArgument(i, v);
}
void IfcWritableEntity::setArgument(int i,const std::vector<std::string>& v){
_setArgument(i, v);
}
void IfcWritableEntity::setArgument(int i,const std::vector<int>& v){
void IfcWritableEntity::setArgument(int i,const std::vector< std::vector<int> >& v){
_setArgument(i, v);
}
void IfcWritableEntity::setArgument(int i,const std::vector< std::vector<int> >& v){
void IfcWritableEntity::setArgument(int i,const std::vector< std::vector<bool> >& v){
_setArgument(i, v);
}
void IfcWritableEntity::setArgument(int i,const std::vector< std::vector<double> >& v){
_setArgument(i, v);
}
void IfcWritableEntity::setArgument(int i,const std::vector< boost::dynamic_bitset<> >& v){
@@ -294,12 +312,17 @@ public:
int operator()(const IfcWriteArgument::Derived& /*i*/) const { return -1; }
int operator()(const int& /*i*/) const { return -1; }
int operator()(const bool& /*i*/) const { return -1; }
int operator()(const boost::logic::tribool& /*i*/) const { return -1; }
int operator()(const double& /*i*/) const { return -1; }
int operator()(const std::string& /*i*/) const { return -1; }
int operator()(const boost::dynamic_bitset<>& /*i*/) const { return -1; }
int operator()(const std::vector<int>& i) const { return (int)i.size(); }
int operator()(const std::vector<bool>& i) const { return (int)i.size(); }
int operator()(const std::vector<boost::logic::tribool>& i) const { return (int)i.size(); }
int operator()(const std::vector<double>& i) const { return (int)i.size(); }
int operator()(const std::vector< std::vector<int> >& i) const { return (int)i.size(); }
int operator()(const std::vector< std::vector<bool> >& i) const { return (int)i.size(); }
int operator()(const std::vector< std::vector<boost::logic::tribool> >& i) const { return (int)i.size(); }
int operator()(const std::vector< std::vector<double> >& i) const { return (int)i.size(); }
int operator()(const std::vector<std::string>& i) const { return (int)i.size(); }
int operator()(const std::vector< boost::dynamic_bitset<> >& i) const { return (int)i.size(); }
@@ -309,6 +332,59 @@ public:
int operator()(const IfcEntityListList::ptr& i) const { return i->size(); }
};
// The REAL token definition from the IFC SPF standard does not necessarily match
// the output of the C++ ostream formatting operation.
// REAL = [ SIGN ] DIGIT { DIGIT } "." { DIGIT } [ "E" [ SIGN ] DIGIT { DIGIT } ] .
std::string IfcWrite::format(double d) {
std::ostringstream oss;
oss.imbue(std::locale::classic());
oss << std::setprecision(std::numeric_limits<double>::digits10 + 1) << d;
const std::string str = oss.str();
oss.str("");
std::string::size_type e = str.find('e');
if (e == std::string::npos) {
e = str.find('E');
}
const std::string mantissa = str.substr(0, e);
oss << mantissa;
if (mantissa.find('.') == std::string::npos) {
oss << ".";
}
if (e != std::string::npos) {
oss << "E";
oss << str.substr(e + 1);
}
return oss.str();
}
std::string IfcWrite::format(const boost::dynamic_bitset<>& b) {
std::ostringstream oss;
oss.imbue(std::locale::classic());
oss.put('"');
oss << std::hex << std::setw(1);
unsigned c = (unsigned)b.size();
unsigned n = (4 - (c % 4)) & 3;
oss << n;
for (unsigned i = 0; i < c + n;) {
unsigned accum = 0;
for (int j = 0; j < 4; ++j, ++i) {
unsigned bit = i < n ? 0 : b.test(c - i + n - 1) ? 1 : 0;
accum |= bit << (3 - j);
}
oss << accum;
}
oss.put('"');
return oss.str();
}
std::string IfcWrite::format(bool b) {
return b ? ".T." : ".F.";
}
std::string IfcWrite::format(boost::logic::tribool b) {
return std::string(".") + "FTU"[b.value] + ".";
}
class StringBuilderVisitor : public boost::static_visitor<void> {
private:
StringBuilderVisitor(const StringBuilderVisitor&); //N/A
@@ -323,51 +399,7 @@ private:
}
data << ")";
}
// The REAL token definition from the IFC SPF standard does not necessarily match
// the output of the C++ ostream formatting operation.
// REAL = [ SIGN ] DIGIT { DIGIT } "." { DIGIT } [ "E" [ SIGN ] DIGIT { DIGIT } ] .
std::string format_double(const double& d) {
std::ostringstream oss;
oss.imbue(std::locale::classic());
oss << std::setprecision(std::numeric_limits<double>::digits10) << d;
const std::string str = oss.str();
oss.str("");
std::string::size_type e = str.find('e');
if (e == std::string::npos) {
e = str.find('E');
}
const std::string mantissa = str.substr(0,e);
oss << mantissa;
if (mantissa.find('.') == std::string::npos) {
oss << ".";
}
if (e != std::string::npos) {
oss << "E";
oss << str.substr(e+1);
}
return oss.str();
}
std::string format_binary(const boost::dynamic_bitset<>& b) {
std::ostringstream oss;
oss.imbue(std::locale::classic());
oss.put('"');
oss << std::hex << std::setw(1);
unsigned c = (unsigned)b.size();
unsigned n = (4 - (c % 4)) & 3;
oss << n;
for (unsigned i = 0; i < c + n;) {
unsigned accum = 0;
for (int j = 0; j < 4; ++j, ++i) {
unsigned bit = i < n ? 0 : b.test(c - i + n - 1) ? 1 : 0;
accum |= bit << (3-j);
}
oss << accum;
}
oss.put('"');
return oss.str();
}
bool upper;
public:
StringBuilderVisitor(std::ostringstream& stream, bool upper = false)
@@ -375,9 +407,10 @@ public:
void operator()(const boost::none_t& /*i*/) { data << "$"; }
void operator()(const IfcWriteArgument::Derived& /*i*/) { data << "*"; }
void operator()(const int& i) { data << i; }
void operator()(const bool& i) { data << (i ? ".T." : ".F."); }
void operator()(const double& i) { data << format_double(i); }
void operator()(const boost::dynamic_bitset<>& i) { data << format_binary(i); }
void operator()(const bool& i) { data << IfcWrite::format(i); }
void operator()(const boost::logic::tribool& i) { data << IfcWrite::format(i); }
void operator()(const double& i) { data << IfcWrite::format(i); }
void operator()(const boost::dynamic_bitset<>& i) { data << IfcWrite::format(i); }
void operator()(const std::string& i) {
std::string s = i;
if (upper) {
@@ -387,6 +420,8 @@ public:
}
}
void operator()(const std::vector<int>& i);
void operator()(const std::vector<bool>& i);
void operator()(const std::vector<boost::logic::tribool>& i);
void operator()(const std::vector<double>& i);
void operator()(const std::vector<std::string>& i);
void operator()(const std::vector< boost::dynamic_bitset<> >& i);
@@ -394,11 +429,11 @@ public:
data << "." << i.enumeration_value << ".";
}
void operator()(const IfcUtil::IfcBaseClass* const& i) {
IfcAbstractEntity* e = i->entity;
if ( IfcSchema::Type::IsSimple(e->type()) ) {
data << e->toString(upper);
const IfcAbstractEntity& e = i->data();
if ( IfcSchema::Type::IsSimple(e.type()) ) {
data << e.toString(upper);
} else {
data << "#" << e->id();
data << "#" << e.id();
}
}
void operator()(const IfcEntityList::ptr& i) {
@@ -410,6 +445,8 @@ public:
data << ")";
}
void operator()(const std::vector< std::vector<int> >& i);
void operator()(const std::vector< std::vector<bool> >& i);
void operator()(const std::vector< std::vector<boost::logic::tribool> >& i);
void operator()(const std::vector< std::vector<double> >& i);
void operator()(const IfcEntityListList::ptr& i) {
data << "(";
@@ -447,7 +484,27 @@ void StringBuilderVisitor::serialize(const std::vector<double>& i) {
data << "(";
for (std::vector<double>::const_iterator it = i.begin(); it != i.end(); ++it) {
if (it != i.begin()) data << ",";
data << format_double(*it);
data << IfcWrite::format(*it);
}
data << ")";
}
template <>
void StringBuilderVisitor::serialize(const std::vector<bool>& i) {
data << "(";
for (std::vector<bool>::const_iterator it = i.begin(); it != i.end(); ++it) {
if (it != i.begin()) data << ",";
data << IfcWrite::format(*it);
}
data << ")";
}
template <>
void StringBuilderVisitor::serialize(const std::vector<boost::logic::tribool>& i) {
data << "(";
for (std::vector<boost::logic::tribool>::const_iterator it = i.begin(); it != i.end(); ++it) {
if (it != i.begin()) data << ",";
data << IfcWrite::format(*it);
}
data << ")";
}
@@ -457,12 +514,14 @@ void StringBuilderVisitor::serialize(const std::vector< boost::dynamic_bitset<>
data << "(";
for (std::vector< boost::dynamic_bitset<> >::const_iterator it = i.begin(); it != i.end(); ++it) {
if (it != i.begin()) data << ",";
data << format_binary(*it);
data << IfcWrite::format(*it);
}
data << ")";
}
void StringBuilderVisitor::operator()(const std::vector<int>& i) { serialize(i); }
void StringBuilderVisitor::operator()(const std::vector<bool>& i) { serialize(i); }
void StringBuilderVisitor::operator()(const std::vector<boost::logic::tribool>& i) { serialize(i); }
void StringBuilderVisitor::operator()(const std::vector<double>& i) { serialize(i); }
void StringBuilderVisitor::operator()(const std::vector<std::string>& i) { serialize(i); }
void StringBuilderVisitor::operator()(const std::vector< boost::dynamic_bitset<> >& i) { serialize(i); }
@@ -474,6 +533,22 @@ void StringBuilderVisitor::operator()(const std::vector< std::vector<int> >& i)
}
data << ")";
}
void StringBuilderVisitor::operator()(const std::vector< std::vector<bool> >& i) {
data << "(";
for (std::vector< std::vector<bool> >::const_iterator it = i.begin(); it != i.end(); ++it) {
if (it != i.begin()) data << ",";
serialize(*it);
}
data << ")";
}
void StringBuilderVisitor::operator()(const std::vector< std::vector<boost::logic::tribool> >& i) {
data << "(";
for (std::vector< std::vector<boost::logic::tribool> >::const_iterator it = i.begin(); it != i.end(); ++it) {
if (it != i.begin()) data << ",";
serialize(*it);
}
data << ")";
}
void StringBuilderVisitor::operator()(const std::vector< std::vector<double> >& i) {
data << "(";
for (std::vector< std::vector<double> >::const_iterator it = i.begin(); it != i.end(); ++it) {
@@ -485,6 +560,7 @@ void StringBuilderVisitor::operator()(const std::vector< std::vector<double> >&
IfcWriteArgument::operator int() const { return as<int>(); }
IfcWriteArgument::operator bool() const { return as<bool>(); }
IfcWriteArgument::operator boost::logic::tribool() const { return as<boost::logic::tribool>(); }
IfcWriteArgument::operator double() const { return as<double>(); }
IfcWriteArgument::operator std::string() const {
if (type() == IfcUtil::Argument_ENUMERATION) {
@@ -494,12 +570,16 @@ IfcWriteArgument::operator std::string() const {
}
IfcWriteArgument::operator IfcUtil::IfcBaseClass*() const { return as<IfcUtil::IfcBaseClass*>(); }
IfcWriteArgument::operator boost::dynamic_bitset<>() const { return as< boost::dynamic_bitset<> >(); }
IfcWriteArgument::operator std::vector<double>() const { return as<std::vector<double> >(); }
IfcWriteArgument::operator std::vector<int>() const { return as<std::vector<int> >(); }
IfcWriteArgument::operator std::vector<bool>() const { return as<std::vector<bool> >(); }
IfcWriteArgument::operator std::vector<boost::logic::tribool>() const { return as<std::vector<boost::logic::tribool> >(); }
IfcWriteArgument::operator std::vector<double>() const { return as<std::vector<double> >(); }
IfcWriteArgument::operator std::vector<std::string>() const { return as<std::vector<std::string > >(); }
IfcWriteArgument::operator std::vector< boost::dynamic_bitset<> >() const { return as< std::vector< boost::dynamic_bitset<> > >(); }
IfcWriteArgument::operator IfcEntityList::ptr() const { return as<IfcEntityList::ptr>(); }
IfcWriteArgument::operator std::vector< std::vector<int> >() const { return as<std::vector< std::vector<int> > >(); }
IfcWriteArgument::operator std::vector< std::vector<bool> >() const { return as<std::vector< std::vector<bool> > >(); }
IfcWriteArgument::operator std::vector< std::vector<boost::logic::tribool> >() const { return as<std::vector< std::vector<boost::logic::tribool> > >(); }
IfcWriteArgument::operator std::vector< std::vector<double> >() const { return as<std::vector< std::vector<double> > >(); }
IfcWriteArgument::operator IfcEntityListList::ptr() const { throw; }
bool IfcWriteArgument::isNull() const { return type() == IfcUtil::Argument_NULL; }
+19
View File
@@ -37,6 +37,11 @@
namespace IfcWrite {
std::string format(bool b);
std::string format(double d);
std::string format(const boost::dynamic_bitset<>& b);
std::string format(boost::logic::tribool b);
/// This class is a writable container for attributes. A fundamental
/// difference with the attribute types counterparts defined in the
/// IfcParse namespace is that this class has a Boost.Variant member
@@ -65,6 +70,8 @@ namespace IfcWrite {
int,
// A boolean argument, it will serialize to either .T. or .F.
bool,
// A logical argument, it will serialize to either .T. or .F. or .U.
boost::logic::tribool,
// A floating point argument, e.g. 12.3
double,
// A character string argument, e.g. 'IfcOpenShell'
@@ -86,6 +93,9 @@ namespace IfcWrite {
// AGGREGATES:
// An aggregate of integers, e.g. (1,2,3)
std::vector<int>,
// An aggregate of bools, e.g. (.T.,.F.)
std::vector<bool>,
std::vector<boost::logic::tribool>,
// An aggregate of floats, e.g. (12.3,4.)
std::vector<double>,
// An aggregate of strings, e.g. ('Ifc','Open','Shell')
@@ -100,6 +110,9 @@ namespace IfcWrite {
// AGGREGATES OF AGGREGATES:
// An aggregate of an aggregate of ints. E.g. ((1, 2), (3))
std::vector< std::vector<int> >,
// An aggregate of bools, e.g. (.T.,(.T.,.F.))
std::vector< std::vector<bool> >,
std::vector< std::vector<boost::logic::tribool> >,
// An aggregate of an aggregate of floats. E.g. ((1., 2.3), (4.))
std::vector< std::vector<double> >,
// An aggregate of an aggregate of entities. E.g. ((#1, #2), (#3))
@@ -126,15 +139,21 @@ namespace IfcWrite {
operator IfcUtil::IfcBaseClass*() const;
operator std::vector<int>() const;
operator std::vector<bool>() const;
operator std::vector<double>() const;
operator std::vector<std::string>() const;
operator std::vector<boost::dynamic_bitset<> >() const;
operator IfcEntityList::ptr() const;
operator std::vector< std::vector<int> >() const;
operator std::vector< std::vector<bool> >() const;
operator std::vector< std::vector<double> >() const;
operator IfcEntityListList::ptr() const;
operator boost::logic::tribool() const;
operator std::vector<boost::logic::tribool>() const;
operator std::vector< std::vector<boost::logic::tribool> >() const;
bool isNull() const;
Argument* operator [] (unsigned int i) const;
std::string toString(bool upper=false) const;
+7 -7
View File
@@ -236,7 +236,7 @@ struct ShapeRTTI : public boost::static_visitor<PyObject*>
%inline %{
boost::variant<IfcGeom::Element<double>*, IfcGeom::Representation::Representation*> create_shape(IfcGeom::IteratorSettings& settings, IfcParse::IfcLateBoundEntity* instance, IfcParse::IfcLateBoundEntity* representation = 0) {
IfcParse::IfcFile* file = instance->entity->file;
IfcParse::IfcFile* file = instance->data().file;
IfcSchema::IfcProject::list::ptr projects = file->entitiesByType<IfcSchema::IfcProject>();
if (projects->size() != 1) {
throw IfcParse::IfcException("Not a single IfcProject instance");
@@ -248,9 +248,9 @@ struct ShapeRTTI : public boost::static_visitor<PyObject*>
kernel.setValue(IfcGeom::Kernel::GV_DIMENSIONALITY, (settings.include_curves() ? (settings.exclude_solids_and_surfaces() ? -1. : 0.) : +1.));
std::pair<std::string, double> length_unit = kernel.initializeUnits(project->UnitsInContext());
if (instance->is(IfcSchema::Type::IfcProduct)) {
if (instance->declaration().is(IfcSchema::Type::IfcProduct)) {
if (representation) {
if (!representation->is(IfcSchema::Type::IfcRepresentation)) {
if (!representation->declaration().is(IfcSchema::Type::IfcRepresentation)) {
throw IfcParse::IfcException("Supplied representation not of type IfcRepresentation");
}
}
@@ -323,11 +323,11 @@ struct ShapeRTTI : public boost::static_visitor<PyObject*>
}
IfcSchema::IfcRepresentationContext* ctx = ifc_representation->ContextOfItems();
if (!ctx->is(IfcSchema::Type::IfcGeometricRepresentationContext)) {
if (!ctx->declaration().is(IfcSchema::Type::IfcGeometricRepresentationContext)) {
throw IfcParse::IfcException("Context not of type IfcGeometricRepresentationContext");
}
IfcSchema::IfcGeometricRepresentationContext* context = (IfcSchema::IfcGeometricRepresentationContext*) ctx;
if (context->is(IfcSchema::Type::IfcGeometricRepresentationSubContext)) {
if (context->declaration().is(IfcSchema::Type::IfcGeometricRepresentationSubContext)) {
IfcSchema::IfcGeometricRepresentationSubContext* subcontext = (IfcSchema::IfcGeometricRepresentationSubContext*) context;
context = subcontext->ParentContext();
}
@@ -360,11 +360,11 @@ struct ShapeRTTI : public boost::static_visitor<PyObject*>
}
} else {
if (!representation) {
if (instance->is(IfcSchema::Type::IfcRepresentationItem) || instance->is(IfcSchema::Type::IfcRepresentation)) {
if (instance->declaration().is(IfcSchema::Type::IfcRepresentationItem) || instance->declaration().is(IfcSchema::Type::IfcRepresentation)) {
IfcGeom::IfcRepresentationShapeItems shapes;
if (kernel.convert_shapes(instance, shapes)) {
IfcGeom::ElementSettings element_settings(settings, kernel.getValue(IfcGeom::Kernel::GV_LENGTH_UNIT), IfcSchema::Type::ToString(instance->type()));
IfcGeom::Representation::BRep brep(element_settings, instance->entity->id(), shapes);
IfcGeom::Representation::BRep brep(element_settings, instance->data().id(), shapes);
try {
if (settings.use_brep_data()) {
return new IfcGeom::Representation::Serialization(brep);
+2
View File
@@ -70,6 +70,8 @@
#include "../ifcparse/IfcFile.h"
#include "../ifcparse/IfcLateBoundEntity.h"
#include "../ifcparse/IfcSchema.h"
#include "../ifcparse/Hdf5Settings.h"
#ifdef USE_IFC4
#include "../ifcparse/Ifc4-latebound.h"
+7 -1
View File
@@ -21,6 +21,7 @@
%{
template <typename T> void* get_python_type();
template <> void* get_python_type<double>() { return &PyFloat_Type; }
template <> void* get_python_type<bool>() { return &PyBool_Type; }
#if PY_VERSION_HEX >= 0x03000000
template <> void* get_python_type<int>() { return &PyLong_Type; }
template <> void* get_python_type<std::string>() { return &PyUnicode_Type; }
@@ -59,6 +60,11 @@
return static_cast<int>(PyInt_AsLong(element));
}
template <>
bool cast_pyobject(PyObject* element) {
return cast_pyobject<int>(element) != 0;
}
template <>
double cast_pyobject(PyObject* element) {
return PyFloat_AsDouble(element);
@@ -107,8 +113,8 @@
// Conversion functions to convert STL vectors into Python objects
%{
PyObject* pythonize(const int& t) { return PyInt_FromLong(t); }
PyObject* pythonize(const unsigned int& t) { return PyInt_FromLong(t); }
PyObject* pythonize(const bool& t) { return PyBool_FromLong(t); }
PyObject* pythonize(const unsigned int& t) { return PyInt_FromLong(t); }
PyObject* pythonize(const double& t) { return PyFloat_FromDouble(t); }
PyObject* pythonize(const std::string& t) { return PyUnicode_FromString(t.c_str()); }
PyObject* pythonize(const IfcUtil::IfcBaseClass* t) { return SWIG_NewPointerObj(SWIG_as_voidptr(t), SWIGTYPE_p_IfcParse__IfcLateBoundEntity, 0); }
+1
View File
@@ -62,6 +62,7 @@
%enddef
CREATE_VECTOR_TYPEMAP_IN(int, INTEGER, int)
CREATE_VECTOR_TYPEMAP_IN(bool, BOOLEAN, bool)
CREATE_VECTOR_TYPEMAP_IN(double, REAL, float)
CREATE_VECTOR_TYPEMAP_IN(std::string, STRING, str)
+9
View File
@@ -47,6 +47,10 @@
std::vector<int> v = arg;
$result = pythonize_vector(v);
break; }
case IfcUtil::Argument_AGGREGATE_OF_BOOL: {
std::vector<bool> v = arg;
$result = pythonize_vector(v);
break; }
case IfcUtil::Argument_AGGREGATE_OF_DOUBLE: {
std::vector<double> v = arg;
$result = pythonize_vector(v);
@@ -71,6 +75,10 @@
std::vector< std::vector<int> > v = arg;
$result = pythonize_vector2(v);
break; }
case IfcUtil::Argument_AGGREGATE_OF_AGGREGATE_OF_BOOL: {
std::vector< std::vector<bool> > v = arg;
$result = pythonize_vector2(v);
break; }
case IfcUtil::Argument_AGGREGATE_OF_AGGREGATE_OF_DOUBLE: {
std::vector< std::vector<double> > v = arg;
$result = pythonize_vector2(v);
@@ -102,6 +110,7 @@
%enddef
CREATE_VECTOR_TYPEMAP_OUT(int)
CREATE_VECTOR_TYPEMAP_OUT(bool)
CREATE_VECTOR_TYPEMAP_OUT(unsigned int)
CREATE_VECTOR_TYPEMAP_OUT(double)
CREATE_VECTOR_TYPEMAP_OUT(std::string)
+30 -1
View File
@@ -131,6 +131,35 @@ cd %DEPS_DIR%
:: Note all of the depedencies have approriate label so that user can easily skip something if wanted
:: by modifying this file and using goto.
:HDF5
set HDF5_VERSION=1.8.19
set HDF5_VERSION_MAJOR=1.8
set HDF5_CMAKE_ZIP=CMake-hdf5-%HDF5_VERSION%.zip
set HDF5_INSTALL_ZIP_NAME=HDF5-%HDF5_VERSION%-win%ARCH_BITS%
if "%ARCH_BITS%"==64. set ARCH_BITS_64=64
call :DownloadFile http://support.hdfgroup.org/ftp/HDF5/releases/hdf5-%HDF5_VERSION_MAJOR%/hdf5-%HDF5_VERSION%/src/CMake-hdf5-%HDF5_VERSION%.zip "%DEPS_DIR%" %HDF5_CMAKE_ZIP%
IF NOT %ERRORLEVEL%==0 GOTO :Error
call :ExtractArchive %HDF5_CMAKE_ZIP% "%DEPS_DIR%" "%DEPS_DIR%\CMake-hdf5-%HDF5_VERSION%"
IF NOT %ERRORLEVEL%==0 GOTO :Error
pushd "%DEPS_DIR%\CMake-hdf5-%HDF5_VERSION%"
copy /y "%~dp0patches\HDF5config.cmake" HDF5config.cmake
copy /y "%~dp0patches\hdf5-src-CMakeLists.txt" hdf5-%HDF5_VERSION%\CMakeLists.txt
REM This will build ZLIB initially linking against dynamic runtime
ctest -S HDF5config.cmake,BUILD_GENERATOR=VS%VS_VER%%ARCH_BITS_64% -C %BUILD_CFG% -V -O hdf5.log
call :ExtractArchive %HDF5_INSTALL_ZIP_NAME%.zip "%INSTALL_DIR%" "%INSTALL_DIR%\%HDF5_INSTALL_ZIP_NAME%"
pushd build\ZLIB-prefix\src\ZLIB
copy /y "%~dp0patches\hdf5-zlib-CMakeLists.txt" CMakeLists.txt
pushd ..\ZLIB-build
cmake ..\ZLIB "-DCMAKE_INSTALL_PREFIX=%INSTALL_DIR%\%HDF5_INSTALL_ZIP_NAME%"
cmake --build . --config %BUILD_CFG% --target INSTALL
popd
popd
echo HDF5_VERSION=%HDF5_VERSION%>>"%~dp0\BuildDepsCache-%TARGET_ARCH%.txt"
popd
goto :Finish
:Boost
set BOOST_VERSION=1.59.0
:: DEPENDENCY_NAME is used for logging and DEPENDENCY_DIR for saving from some redundant typing
@@ -264,7 +293,7 @@ set PYTHON_INSTALLER=python-%PYTHON_VERSION%%PYTHON_AMD64_POSTFIX%.msi
:: NOTE/TODO 3.5.0 doesn't use MSI any longer, but exe: set PYTHON_INSTALLER=python-%PYTHON_VERSION%%PYTHON_AMD64_POSTFIX%.exe
IF "%IFCOS_INSTALL_PYTHON%"=="TRUE" (
REM Store Python versions to BuildDepsCache.txt for run-cmake.bat
echo PY_VER_MAJOR_MINOR=%PY_VER_MAJOR_MINOR%>"%~dp0\BuildDepsCache-%TARGET_ARCH%.txt"
echo PY_VER_MAJOR_MINOR=%PY_VER_MAJOR_MINOR%>>"%~dp0\BuildDepsCache-%TARGET_ARCH%.txt"
echo PYTHONHOME=%PYTHONHOME%>>"%~dp0\BuildDepsCache-%TARGET_ARCH%.txt"
cd "%DEPS_DIR%"
+4
View File
@@ -52,6 +52,8 @@ set OCC_INCLUDE_DIR=%INSTALL_DIR%\oce\include\oce
set OCC_LIBRARY_DIR=%INSTALL_DIR%\oce\Win%ARCH_BITS%\lib
set OPENCOLLADA_INCLUDE_DIR=%INSTALL_DIR%\OpenCOLLADA\include\opencollada
set OPENCOLLADA_LIBRARY_DIR=%INSTALL_DIR%\OpenCOLLADA\lib\opencollada
set HDF5_INCLUDE_DIR=%INSTALL_DIR%\HDF5-%HDF5_VERSION%-win%ARCH_BITS%\include
set HDF5_LIBRARY_DIR=%INSTALL_DIR%\HDF5-%HDF5_VERSION%-win%ARCH_BITS%\lib
if not defined PY_VER_MAJOR_MINOR set PY_VER_MAJOR_MINOR=34
if not defined PYTHONHOME set PYTHONHOME=%INSTALL_DIR%\Python%PY_VER_MAJOR_MINOR%
set PYTHON_INCLUDE_DIR=%PYTHONHOME%\include
@@ -75,6 +77,8 @@ echo OCC_INCLUDE_DIR = %OCC_INCLUDE_DIR%
echo OCC_LIBRARY_DIR = %OCC_LIBRARY_DIR%
echo OPENCOLLADA_INCLUDE_DIR = %OPENCOLLADA_INCLUDE_DIR%
echo OPENCOLLADA_LIBRARY_DIR = %OPENCOLLADA_LIBRARY_DIR%
echo HDF5_INCLUDE_DIR = %HDF5_INCLUDE_DIR%
echo HDF5_LIBRARY_DIR = %HDF5_LIBRARY_DIR%
echo PYTHONHOME = %PYTHONHOME%
echo PYTHON_INCLUDE_DIR = %PYTHON_INCLUDE_DIR%
echo PYTHON_LIBRARY = %PYTHON_LIBRARY%
+2 -1
View File
@@ -1,4 +1,5 @@
:: Usage: call cecho.cmd background foreground "message here"
:: NOTES/TODOS 1) This is super slow 2) leading spaces are omitted 3) printing string with quotes doesn't work (quotes must be escaped awkwardly)
@powershell -command write-host -background %~1 -foreground "%~2" "%3"
:: @powershell -command write-host -background %~1 -foreground "%~2" "%3"
echo %3
@exit /b