adapt code for previous commits

This commit is contained in:
Thomas Krijnen
2021-07-29 14:54:51 +02:00
parent e529eeb540
commit d1fe1117be
26 changed files with 447 additions and 394 deletions
+18 -6
View File
@@ -28,15 +28,27 @@
#include "ifc_parse_api.h"
#include "../ifcparse/IfcEntityList.h"
#include "../ifcparse/aggregate_of_instance.h"
#include <boost/shared_ptr.hpp>
#include <boost/dynamic_bitset.hpp>
#include <boost/logic/tribool.hpp>
/*
namespace boost {
namespace logic {
class tribool {
};
}
}
*/
class Argument;
class IfcEntityList;
class IfcEntityListList;
class aggregate_of_instance;
class aggregate_of_aggregate_of_instance;
class IfcEntityInstanceData;
namespace IfcParse {
class IfcFile;
@@ -54,8 +66,8 @@ class IFC_PARSE_API Argument {
public:
virtual operator int() const;
virtual operator bool() const;
virtual operator double() const;
virtual operator boost::logic::tribool() const;
virtual operator double() const;
virtual operator std::string() const;
virtual operator boost::dynamic_bitset<>() const;
virtual operator IfcUtil::IfcBaseClass*() const;
@@ -64,11 +76,11 @@ public:
virtual operator std::vector<double>() const;
virtual operator std::vector<std::string>() const;
virtual operator std::vector<boost::dynamic_bitset<> >() const;
virtual operator IfcEntityList::ptr() const;
virtual operator aggregate_of_instance::ptr() const;
virtual operator std::vector< std::vector<int> >() const;
virtual operator std::vector< std::vector<double> >() const;
virtual operator IfcEntityListList::ptr() const;
virtual operator aggregate_of_aggregate_of_instance::ptr() const;
virtual bool isNull() const = 0;
virtual unsigned int size() const = 0;
+2 -2
View File
@@ -29,7 +29,7 @@
#include <boost/shared_ptr.hpp>
class Argument;
class IfcEntityList;
class aggregate_of_instance;
namespace IfcUtil {
@@ -95,7 +95,7 @@ namespace IfcUtil {
Argument* get(const std::string& name) const;
boost::shared_ptr<IfcEntityList> get_inverse(const std::string& a) const;
boost::shared_ptr<aggregate_of_instance> get_inverse(const std::string& a) const;
};
// TODO: Investigate whether these should be template classes instead
+2 -2
View File
@@ -28,7 +28,7 @@
#include <vector>
class Argument;
class IfcEntityList;
class aggregate_of_instance;
namespace IfcParse {
class IfcFile;
}
@@ -62,7 +62,7 @@ public:
virtual ~IfcEntityInstanceData();
boost::shared_ptr<IfcEntityList> getInverse (const IfcParse::declaration* type, int attribute_index) const;
boost::shared_ptr<aggregate_of_instance> getInverse (const IfcParse::declaration* type, int attribute_index) const;
Argument* getArgument(size_t i) const;
+13 -13
View File
@@ -67,11 +67,11 @@ public:
/// and provide access to the entities in an IFC file
class IFC_PARSE_API IfcFile {
public:
typedef std::map<const IfcParse::declaration*, IfcEntityList::ptr> entities_by_type_t;
typedef std::map<const IfcParse::declaration*, aggregate_of_instance::ptr> entities_by_type_t;
typedef boost::unordered_map<unsigned int, IfcUtil::IfcBaseClass*> entity_by_id_t;
typedef std::map<std::string, IfcUtil::IfcBaseClass*> entity_by_guid_t;
typedef std::map<unsigned int, std::vector<unsigned int> > entities_by_ref_t;
typedef std::map<unsigned int, IfcEntityList::ptr> ref_map_t;
typedef std::map<unsigned int, aggregate_of_instance::ptr> ref_map_t;
typedef entity_by_id_t::const_iterator const_iterator;
class type_iterator : private entities_by_type_t::const_iterator {
@@ -172,7 +172,7 @@ public:
/// IfcWall will also return IfcWallStandardCase entities
template <class T>
typename T::list::ptr instances_by_type() {
IfcEntityList::ptr untyped_list = instances_by_type(&T::Class());
aggregate_of_instance::ptr untyped_list = instances_by_type(&T::Class());
if (untyped_list) {
return untyped_list->as<T>();
} else {
@@ -182,7 +182,7 @@ public:
template <class T>
typename T::list::ptr instances_by_type_excl_subtypes() {
IfcEntityList::ptr untyped_list = instances_by_type_excl_subtypes(&T::Class());
aggregate_of_instance::ptr untyped_list = instances_by_type_excl_subtypes(&T::Class());
if (untyped_list) {
return untyped_list->as<T>();
} else {
@@ -193,21 +193,21 @@ public:
/// Returns all entities in the file that match the positional argument.
/// NOTE: This also returns subtypes of the requested type, for example:
/// IfcWall will also return IfcWallStandardCase entities
IfcEntityList::ptr instances_by_type(const IfcParse::declaration*);
aggregate_of_instance::ptr instances_by_type(const IfcParse::declaration*);
/// Returns all entities in the file that match the positional argument.
IfcEntityList::ptr instances_by_type_excl_subtypes(const IfcParse::declaration*);
aggregate_of_instance::ptr instances_by_type_excl_subtypes(const IfcParse::declaration*);
/// Returns all entities in the file that match the positional argument.
/// NOTE: This also returns subtypes of the requested type, for example:
/// IfcWall will also return IfcWallStandardCase entities
IfcEntityList::ptr instances_by_type(const std::string& t);
aggregate_of_instance::ptr instances_by_type(const std::string& t);
/// Returns all entities in the file that match the positional argument.
IfcEntityList::ptr instances_by_type_excl_subtypes(const std::string& t);
aggregate_of_instance::ptr instances_by_type_excl_subtypes(const std::string& t);
/// Returns all entities in the file that reference the id
IfcEntityList::ptr instances_by_reference(int id);
aggregate_of_instance::ptr instances_by_reference(int id);
/// Returns the entity with the specified id
IfcUtil::IfcBaseClass* instance_by_id(int id);
@@ -218,9 +218,9 @@ public:
/// Performs a depth-first traversal, returning all entity instance
/// attributes as a flat list. NB: includes the root instance specified
/// in the first function argument.
IfcEntityList::ptr traverse(IfcUtil::IfcBaseClass* instance, int max_level=-1);
aggregate_of_instance::ptr traverse(IfcUtil::IfcBaseClass* instance, int max_level=-1);
IfcEntityList::ptr getInverse(int instance_id, const IfcParse::declaration* type, int attribute_index);
aggregate_of_instance::ptr getInverse(int instance_id, const IfcParse::declaration* type, int attribute_index);
/// Marks entity as modified so that potential cache for it is invalidated.
/// @todo Currently the whole cache is invalidated. Implement more fine-grained invalidation.
@@ -231,7 +231,7 @@ public:
void recalculate_id_counter();
IfcUtil::IfcBaseClass* addEntity(IfcUtil::IfcBaseClass* entity, int id=-1);
void addEntities(IfcEntityList::ptr es);
void addEntities(aggregate_of_instance::ptr es);
void batch() { batch_mode_ = true; }
void unbatch() { process_deletion_(); batch_mode_ = false; }
@@ -240,7 +240,7 @@ public:
///
/// Attention when running removeEntity inside a loop over a list of entities to be removed.
/// This invalidates the iterator. A workaround is to reverse the loop:
/// boost::shared_ptr<IfcEntityList> entities = ...;
/// boost::shared_ptr<aggregate_of_instance> entities = ...;
/// for (auto it = entities->end() - 1; it >= entities->begin(); --it) {
/// IfcUtil::IfcBaseClass *const inst = *it;
/// model->removeEntity(inst);
+17 -15
View File
@@ -29,6 +29,8 @@
#include "../ifcparse/IfcHierarchyHelper.h"
using namespace std::string_literals;
template <typename Schema>
typename Schema::IfcAxis2Placement3D* IfcHierarchyHelper<Schema>::addPlacement3d(
double ox, double oy, double oz,
@@ -97,7 +99,7 @@ template <typename Schema>
typename Schema::IfcProject* IfcHierarchyHelper<Schema>::addProject(typename Schema::IfcOwnerHistory* owner_hist) {
typename Schema::IfcRepresentationContext::list::ptr rep_contexts (new typename Schema::IfcRepresentationContext::list);
IfcEntityList::ptr units (new IfcEntityList);
aggregate_of_instance::ptr units (new aggregate_of_instance);
typename Schema::IfcDimensionalExponents* dimexp = new typename Schema::IfcDimensionalExponents(0, 0, 0, 0, 0, 0, 0);
typename Schema::IfcSIUnit* unit1 = new typename Schema::IfcSIUnit(Schema::IfcUnitEnum::IfcUnit_LENGTHUNIT,
Schema::IfcSIPrefix::IfcSIPrefix_MILLI, Schema::IfcSIUnitName::IfcSIUnitName_METRE);
@@ -129,10 +131,10 @@ typename Schema::IfcProject* IfcHierarchyHelper<Schema>::addProject(typename Sch
template <typename Schema>
void IfcHierarchyHelper<Schema>::relatePlacements(typename Schema::IfcProduct* parent, typename Schema::IfcProduct* product) {
typename Schema::IfcObjectPlacement* place = product->hasObjectPlacement() ? product->ObjectPlacement() : 0;
typename Schema::IfcObjectPlacement* place = product->ObjectPlacement();
if (place && place->declaration().is(Schema::IfcLocalPlacement::Class())) {
typename Schema::IfcLocalPlacement* local_place = (typename Schema::IfcLocalPlacement*) place;
if (parent->hasObjectPlacement()) {
if (parent->ObjectPlacement()) {
local_place->setPlacementRelTo(parent->ObjectPlacement());
}
}
@@ -384,12 +386,12 @@ template <typename Schema>
void IfcHierarchyHelper<Schema>::clipRepresentation(typename Schema::IfcRepresentation* rep,
typename Schema::IfcAxis2Placement3D* place, bool agree)
{
if (rep->RepresentationIdentifier() != "Body") return;
if (!rep->RepresentationIdentifier() || *rep->RepresentationIdentifier() != "Body") return;
typename Schema::IfcPlane* plane = new typename Schema::IfcPlane(place);
typename Schema::IfcHalfSpaceSolid* half_space = new typename Schema::IfcHalfSpaceSolid(plane, agree);
addEntity(plane);
addEntity(half_space);
rep->setRepresentationType("Clipping");
rep->setRepresentationType("Clipping"s);
typename Schema::IfcRepresentationItem::list::ptr items = rep->Items();
typename Schema::IfcRepresentationItem::list::ptr new_items (new typename Schema::IfcRepresentationItem::list);
for (typename Schema::IfcRepresentationItem::list::it i = items->begin(); i != items->end(); ++i) {
@@ -412,7 +414,7 @@ typename Schema::IfcSurfaceStyle* getSurfaceStyle(IfcHierarchyHelper<Schema>& fi
: new typename Schema::IfcSurfaceStyleRendering(colour, 1.0 - a, 0, 0, 0, 0,
0, 0, Schema::IfcReflectanceMethodEnum::IfcReflectanceMethod_FLAT);
IfcEntityList::ptr styles(new IfcEntityList());
aggregate_of_instance::ptr styles(new aggregate_of_instance());
styles->push(rendering);
typename Schema::IfcSurfaceStyle* surface_style = new typename Schema::IfcSurfaceStyle(
boost::none, Schema::IfcSurfaceSide::IfcSurfaceSide_BOTH, styles);
@@ -428,7 +430,7 @@ template<typename Schema>
typename Schema::IfcPresentationStyleAssignment* addStyleAssignment_2x3(IfcHierarchyHelper<Schema>& file, double r, double g, double b, double a = 1.0)
{
auto surface_style = getSurfaceStyle<Schema>(file, r, g, b, a);
IfcEntityList::ptr surface_styles(new IfcEntityList());
aggregate_of_instance::ptr surface_styles(new aggregate_of_instance());
surface_styles->push(surface_style);
typename Schema::IfcPresentationStyleAssignment* style_assignment =
new typename Schema::IfcPresentationStyleAssignment(surface_styles);
@@ -502,7 +504,7 @@ Ifc2x3::IfcStyledItem* create_styled_item(Ifc2x3::IfcRepresentationItem* item, I
#ifdef HAS_SCHEMA_4
Ifc4::IfcStyledItem* create_styled_item(Ifc4::IfcRepresentationItem* item, Ifc4::IfcPresentationStyleAssignment* style_assignment) {
IfcEntityList::ptr style_assignments(new IfcEntityList);
aggregate_of_instance::ptr style_assignments(new aggregate_of_instance);
style_assignments->push(style_assignment);
return new Ifc4::IfcStyledItem(item, style_assignments, boost::none);
}
@@ -510,7 +512,7 @@ Ifc4::IfcStyledItem* create_styled_item(Ifc4::IfcRepresentationItem* item, Ifc4:
#ifdef HAS_SCHEMA_4x1
Ifc4x1::IfcStyledItem* create_styled_item(Ifc4x1::IfcRepresentationItem* item, Ifc4x1::IfcPresentationStyleAssignment* style_assignment) {
IfcEntityList::ptr style_assignments(new IfcEntityList);
aggregate_of_instance::ptr style_assignments(new aggregate_of_instance);
style_assignments->push(style_assignment);
return new Ifc4x1::IfcStyledItem(item, style_assignments, boost::none);
}
@@ -518,7 +520,7 @@ Ifc4x1::IfcStyledItem* create_styled_item(Ifc4x1::IfcRepresentationItem* item, I
#ifdef HAS_SCHEMA_4x2
Ifc4x2::IfcStyledItem* create_styled_item(Ifc4x2::IfcRepresentationItem* item, Ifc4x2::IfcPresentationStyleAssignment* style_assignment) {
IfcEntityList::ptr style_assignments(new IfcEntityList);
aggregate_of_instance::ptr style_assignments(new aggregate_of_instance);
style_assignments->push(style_assignment);
return new Ifc4x2::IfcStyledItem(item, style_assignments, boost::none);
}
@@ -526,7 +528,7 @@ Ifc4x2::IfcStyledItem* create_styled_item(Ifc4x2::IfcRepresentationItem* item, I
#ifdef HAS_SCHEMA_4x3_rc1
Ifc4x3_rc1::IfcStyledItem* create_styled_item(Ifc4x3_rc1::IfcRepresentationItem* item, Ifc4x3_rc1::IfcPresentationStyleAssignment* style_assignment) {
IfcEntityList::ptr style_assignments(new IfcEntityList);
aggregate_of_instance::ptr style_assignments(new aggregate_of_instance);
style_assignments->push(style_assignment);
return new Ifc4x3_rc1::IfcStyledItem(item, style_assignments, boost::none);
}
@@ -534,7 +536,7 @@ Ifc4x3_rc1::IfcStyledItem* create_styled_item(Ifc4x3_rc1::IfcRepresentationItem*
#ifdef HAS_SCHEMA_4x3_rc2
Ifc4x3_rc2::IfcStyledItem* create_styled_item(Ifc4x3_rc2::IfcRepresentationItem* item, Ifc4x3_rc2::IfcPresentationStyleAssignment* style_assignment) {
IfcEntityList::ptr style_assignments(new IfcEntityList);
aggregate_of_instance::ptr style_assignments(new aggregate_of_instance);
style_assignments->push(style_assignment);
return new Ifc4x3_rc2::IfcStyledItem(item, style_assignments, boost::none);
}
@@ -542,7 +544,7 @@ Ifc4x3_rc2::IfcStyledItem* create_styled_item(Ifc4x3_rc2::IfcRepresentationItem*
#ifdef HAS_SCHEMA_4x3_rc3
Ifc4x3_rc3::IfcStyledItem* create_styled_item(Ifc4x3_rc3::IfcRepresentationItem* item, Ifc4x3_rc3::IfcPresentationStyle* style) {
boost::shared_ptr<IfcTemplatedEntityList<Ifc4x3_rc3::IfcPresentationStyle>> styles(new IfcTemplatedEntityList<Ifc4x3_rc3::IfcPresentationStyle>());
boost::shared_ptr<aggregate_of<Ifc4x3_rc3::IfcPresentationStyle>> styles(new aggregate_of<Ifc4x3_rc3::IfcPresentationStyle>());
styles->push(style);
return new Ifc4x3_rc3::IfcStyledItem(item, styles, boost::none);
}
@@ -550,7 +552,7 @@ Ifc4x3_rc3::IfcStyledItem* create_styled_item(Ifc4x3_rc3::IfcRepresentationItem*
#ifdef HAS_SCHEMA_4x3_rc4
Ifc4x3_rc4::IfcStyledItem* create_styled_item(Ifc4x3_rc4::IfcRepresentationItem* item, Ifc4x3_rc4::IfcPresentationStyle* style) {
boost::shared_ptr<IfcTemplatedEntityList<Ifc4x3_rc4::IfcPresentationStyle>> styles(new IfcTemplatedEntityList<Ifc4x3_rc4::IfcPresentationStyle>());
boost::shared_ptr<aggregate_of<Ifc4x3_rc4::IfcPresentationStyle>> styles(new aggregate_of<Ifc4x3_rc4::IfcPresentationStyle>());
styles->push(style);
return new Ifc4x3_rc4::IfcStyledItem(item, styles, boost::none);
}
@@ -824,7 +826,7 @@ typename Schema::IfcProductDefinitionShape* IfcHierarchyHelper<Schema>::addMappe
typename Schema::IfcRepresentationItem::list::ptr items(new typename Schema::IfcRepresentationItem::list);
items->push(item);
typename Schema::IfcRepresentation* new_rep = new typename Schema::IfcShapeRepresentation(rep->ContextOfItems(), boost::none, std::string("MappedRepresentation"), items);
if (rep->hasRepresentationIdentifier()) {
if (rep->RepresentationIdentifier()) {
new_rep->setRepresentationIdentifier(rep->RepresentationIdentifier());
}
addEntity(item);
+38 -38
View File
@@ -67,19 +67,19 @@ namespace {
return t->RelatingStructure();
}
IfcEntityList::ptr get_children_of_relation(Ifc2x3::IfcRelContainedInSpatialStructure* t) {
aggregate_of_instance::ptr get_children_of_relation(Ifc2x3::IfcRelContainedInSpatialStructure* t) {
return t->RelatedElements()->generalize();
}
IfcEntityList::ptr get_children_of_relation(Ifc2x3::IfcRelAggregates* t) {
aggregate_of_instance::ptr get_children_of_relation(Ifc2x3::IfcRelAggregates* t) {
return t->RelatedObjects()->generalize();
}
void set_children_of_relation(Ifc2x3::IfcRelContainedInSpatialStructure* t, IfcEntityList::ptr& cs) {
void set_children_of_relation(Ifc2x3::IfcRelContainedInSpatialStructure* t, aggregate_of_instance::ptr& cs) {
t->setRelatedElements(cs->as<Ifc2x3::IfcProduct>());
}
void set_children_of_relation(Ifc2x3::IfcRelAggregates* t, IfcEntityList::ptr& cs) {
void set_children_of_relation(Ifc2x3::IfcRelAggregates* t, aggregate_of_instance::ptr& cs) {
t->setRelatedObjects(cs->as<Ifc2x3::IfcObjectDefinition>());
}
#endif
@@ -89,19 +89,19 @@ namespace {
return t->RelatingStructure();
}
IfcEntityList::ptr get_children_of_relation(Ifc4::IfcRelContainedInSpatialStructure* t) {
aggregate_of_instance::ptr get_children_of_relation(Ifc4::IfcRelContainedInSpatialStructure* t) {
return t->RelatedElements()->generalize();
}
IfcEntityList::ptr get_children_of_relation(Ifc4::IfcRelAggregates* t) {
aggregate_of_instance::ptr get_children_of_relation(Ifc4::IfcRelAggregates* t) {
return t->RelatedObjects()->generalize();
}
void set_children_of_relation(Ifc4::IfcRelContainedInSpatialStructure* t, IfcEntityList::ptr& cs) {
void set_children_of_relation(Ifc4::IfcRelContainedInSpatialStructure* t, aggregate_of_instance::ptr& cs) {
t->setRelatedElements(cs->as<Ifc4::IfcProduct>());
}
void set_children_of_relation(Ifc4::IfcRelAggregates* t, IfcEntityList::ptr& cs) {
void set_children_of_relation(Ifc4::IfcRelAggregates* t, aggregate_of_instance::ptr& cs) {
t->setRelatedObjects(cs->as<Ifc4::IfcObjectDefinition>());
}
#endif
@@ -111,19 +111,19 @@ namespace {
return t->RelatingStructure();
}
IfcEntityList::ptr get_children_of_relation(Ifc4x1::IfcRelContainedInSpatialStructure* t) {
aggregate_of_instance::ptr get_children_of_relation(Ifc4x1::IfcRelContainedInSpatialStructure* t) {
return t->RelatedElements()->generalize();
}
IfcEntityList::ptr get_children_of_relation(Ifc4x1::IfcRelAggregates* t) {
aggregate_of_instance::ptr get_children_of_relation(Ifc4x1::IfcRelAggregates* t) {
return t->RelatedObjects()->generalize();
}
void set_children_of_relation(Ifc4x1::IfcRelContainedInSpatialStructure* t, IfcEntityList::ptr& cs) {
void set_children_of_relation(Ifc4x1::IfcRelContainedInSpatialStructure* t, aggregate_of_instance::ptr& cs) {
t->setRelatedElements(cs->as<Ifc4x1::IfcProduct>());
}
void set_children_of_relation(Ifc4x1::IfcRelAggregates* t, IfcEntityList::ptr& cs) {
void set_children_of_relation(Ifc4x1::IfcRelAggregates* t, aggregate_of_instance::ptr& cs) {
t->setRelatedObjects(cs->as<Ifc4x1::IfcObjectDefinition>());
}
#endif
@@ -133,19 +133,19 @@ namespace {
return t->RelatingStructure();
}
IfcEntityList::ptr get_children_of_relation(Ifc4x2::IfcRelContainedInSpatialStructure* t) {
aggregate_of_instance::ptr get_children_of_relation(Ifc4x2::IfcRelContainedInSpatialStructure* t) {
return t->RelatedElements()->generalize();
}
IfcEntityList::ptr get_children_of_relation(Ifc4x2::IfcRelAggregates* t) {
aggregate_of_instance::ptr get_children_of_relation(Ifc4x2::IfcRelAggregates* t) {
return t->RelatedObjects()->generalize();
}
void set_children_of_relation(Ifc4x2::IfcRelContainedInSpatialStructure* t, IfcEntityList::ptr& cs) {
void set_children_of_relation(Ifc4x2::IfcRelContainedInSpatialStructure* t, aggregate_of_instance::ptr& cs) {
t->setRelatedElements(cs->as<Ifc4x2::IfcProduct>());
}
void set_children_of_relation(Ifc4x2::IfcRelAggregates* t, IfcEntityList::ptr& cs) {
void set_children_of_relation(Ifc4x2::IfcRelAggregates* t, aggregate_of_instance::ptr& cs) {
t->setRelatedObjects(cs->as<Ifc4x2::IfcObjectDefinition>());
}
#endif
@@ -155,19 +155,19 @@ namespace {
return t->RelatingStructure();
}
IfcEntityList::ptr get_children_of_relation(Ifc4x3_rc1::IfcRelContainedInSpatialStructure* t) {
aggregate_of_instance::ptr get_children_of_relation(Ifc4x3_rc1::IfcRelContainedInSpatialStructure* t) {
return t->RelatedElements()->generalize();
}
IfcEntityList::ptr get_children_of_relation(Ifc4x3_rc1::IfcRelAggregates* t) {
aggregate_of_instance::ptr get_children_of_relation(Ifc4x3_rc1::IfcRelAggregates* t) {
return t->RelatedObjects()->generalize();
}
void set_children_of_relation(Ifc4x3_rc1::IfcRelContainedInSpatialStructure* t, IfcEntityList::ptr& cs) {
void set_children_of_relation(Ifc4x3_rc1::IfcRelContainedInSpatialStructure* t, aggregate_of_instance::ptr& cs) {
t->setRelatedElements(cs->as<Ifc4x3_rc1::IfcProduct>());
}
void set_children_of_relation(Ifc4x3_rc1::IfcRelAggregates* t, IfcEntityList::ptr& cs) {
void set_children_of_relation(Ifc4x3_rc1::IfcRelAggregates* t, aggregate_of_instance::ptr& cs) {
t->setRelatedObjects(cs->as<Ifc4x3_rc1::IfcObjectDefinition>());
}
#endif
@@ -177,19 +177,19 @@ namespace {
return t->RelatingStructure();
}
IfcEntityList::ptr get_children_of_relation(Ifc4x3_rc2::IfcRelContainedInSpatialStructure* t) {
aggregate_of_instance::ptr get_children_of_relation(Ifc4x3_rc2::IfcRelContainedInSpatialStructure* t) {
return t->RelatedElements()->generalize();
}
IfcEntityList::ptr get_children_of_relation(Ifc4x3_rc2::IfcRelAggregates* t) {
aggregate_of_instance::ptr get_children_of_relation(Ifc4x3_rc2::IfcRelAggregates* t) {
return t->RelatedObjects()->generalize();
}
void set_children_of_relation(Ifc4x3_rc2::IfcRelContainedInSpatialStructure* t, IfcEntityList::ptr& cs) {
void set_children_of_relation(Ifc4x3_rc2::IfcRelContainedInSpatialStructure* t, aggregate_of_instance::ptr& cs) {
t->setRelatedElements(cs->as<Ifc4x3_rc2::IfcProduct>());
}
void set_children_of_relation(Ifc4x3_rc2::IfcRelAggregates* t, IfcEntityList::ptr& cs) {
void set_children_of_relation(Ifc4x3_rc2::IfcRelAggregates* t, aggregate_of_instance::ptr& cs) {
t->setRelatedObjects(cs->as<Ifc4x3_rc2::IfcObjectDefinition>());
}
#endif
@@ -199,19 +199,19 @@ namespace {
return t->RelatingStructure();
}
IfcEntityList::ptr get_children_of_relation(Ifc4x3_rc3::IfcRelContainedInSpatialStructure* t) {
aggregate_of_instance::ptr get_children_of_relation(Ifc4x3_rc3::IfcRelContainedInSpatialStructure* t) {
return t->RelatedElements()->generalize();
}
IfcEntityList::ptr get_children_of_relation(Ifc4x3_rc3::IfcRelAggregates* t) {
aggregate_of_instance::ptr get_children_of_relation(Ifc4x3_rc3::IfcRelAggregates* t) {
return t->RelatedObjects()->generalize();
}
void set_children_of_relation(Ifc4x3_rc3::IfcRelContainedInSpatialStructure* t, IfcEntityList::ptr& cs) {
void set_children_of_relation(Ifc4x3_rc3::IfcRelContainedInSpatialStructure* t, aggregate_of_instance::ptr& cs) {
t->setRelatedElements(cs->as<Ifc4x3_rc3::IfcProduct>());
}
void set_children_of_relation(Ifc4x3_rc3::IfcRelAggregates* t, IfcEntityList::ptr& cs) {
void set_children_of_relation(Ifc4x3_rc3::IfcRelAggregates* t, aggregate_of_instance::ptr& cs) {
t->setRelatedObjects(cs->as<Ifc4x3_rc3::IfcObjectDefinition>());
}
#endif
@@ -221,19 +221,19 @@ namespace {
return t->RelatingStructure();
}
IfcEntityList::ptr get_children_of_relation(Ifc4x3_rc4::IfcRelContainedInSpatialStructure* t) {
aggregate_of_instance::ptr get_children_of_relation(Ifc4x3_rc4::IfcRelContainedInSpatialStructure* t) {
return t->RelatedElements()->generalize();
}
IfcEntityList::ptr get_children_of_relation(Ifc4x3_rc4::IfcRelAggregates* t) {
aggregate_of_instance::ptr get_children_of_relation(Ifc4x3_rc4::IfcRelAggregates* t) {
return t->RelatedObjects()->generalize();
}
void set_children_of_relation(Ifc4x3_rc4::IfcRelContainedInSpatialStructure* t, IfcEntityList::ptr& cs) {
void set_children_of_relation(Ifc4x3_rc4::IfcRelContainedInSpatialStructure* t, aggregate_of_instance::ptr& cs) {
t->setRelatedElements(cs->as<Ifc4x3_rc4::IfcProduct>());
}
void set_children_of_relation(Ifc4x3_rc4::IfcRelAggregates* t, IfcEntityList::ptr& cs) {
void set_children_of_relation(Ifc4x3_rc4::IfcRelAggregates* t, aggregate_of_instance::ptr& cs) {
t->setRelatedObjects(cs->as<Ifc4x3_rc4::IfcObjectDefinition>());
}
#endif
@@ -244,13 +244,13 @@ namespace {
);
}
IfcEntityList::ptr get_children_of_relation(IfcUtil::IfcBaseClass* t) {
aggregate_of_instance::ptr get_children_of_relation(IfcUtil::IfcBaseClass* t) {
return *t->data().getArgument(
t->declaration().as_entity()->attribute_index("RelatedElements")
);
}
void set_children_of_relation(IfcUtil::IfcBaseClass* t, IfcEntityList::ptr& cs) {
void set_children_of_relation(IfcUtil::IfcBaseClass* t, aggregate_of_instance::ptr& cs) {
IfcWrite::IfcWriteArgument* attr = new IfcWrite::IfcWriteArgument;
attr->set(cs);
t->data().setArgument(
@@ -309,7 +309,7 @@ public:
T* rel = *i;
try {
if (get_parent_of_relation(rel) == relating_object) {
IfcEntityList::ptr products = get_children_of_relation(rel);
aggregate_of_instance::ptr products = get_children_of_relation(rel);
products->push(related_object);
set_children_of_relation(rel, products);
found = true;
@@ -329,7 +329,7 @@ public:
owner_hist = addOwnerHistory();
}
IfcEntityList::ptr related_objects (new IfcEntityList);
aggregate_of_instance::ptr related_objects (new aggregate_of_instance);
related_objects->push(related_object);
IfcEntityInstanceData* data = new IfcEntityInstanceData(&T::Class());
@@ -488,7 +488,7 @@ inline void IfcHierarchyHelper::addRelatedObject <typename Schema::IfcRelContain
if (! owner_hist) {
owner_hist = addOwnerHistory();
}
typename Schema::IfcProduct::list::ptr related_objects (new IfcTemplatedEntityList<typename Schema::IfcProduct>());
typename Schema::IfcProduct::list::ptr related_objects (new aggregate_of<typename Schema::IfcProduct>());
related_objects->push((typename Schema::IfcProduct*)related_object);
typename Schema::IfcRelContainedInSpatialStructure* t = new typename Schema::IfcRelContainedInSpatialStructure(IfcParse::IfcGlobalId(), owner_hist,
boost::none, boost::none, related_objects, (typename Schema::IfcSpatialStructureElement*)relating_structure);
@@ -520,7 +520,7 @@ inline void IfcHierarchyHelper::addRelatedObject <typename Schema::IfcRelDefines
if (! owner_hist) {
owner_hist = addOwnerHistory();
}
typename Schema::IfcObject::list::ptr related_objects (new IfcTemplatedEntityList<typename Schema::IfcObject>());
typename Schema::IfcObject::list::ptr related_objects (new aggregate_of<typename Schema::IfcObject>());
related_objects->push((typename Schema::IfcObject*)related_object);
typename Schema::IfcRelDefinesByType* t = new typename Schema::IfcRelDefinesByType(IfcParse::IfcGlobalId(), owner_hist,
boost::none, boost::none, related_objects, (typename Schema::IfcTypeObject*)relating_type);
+109 -82
View File
@@ -409,14 +409,21 @@ bool ParseFloat(const char *pStart, double &val) {
return true;
}
bool ParseBool(const char *pStart, bool &val) {
bool ParseBool(const char *pStart, int &val) {
if (strlen(pStart) != 3 || pStart[0] != '.' || pStart[2] != '.')
return false;
char mid = pStart[1];
/// @todo https://github.com/IfcOpenShell/IfcOpenShell/issues/95
if (!(mid == 'T' || mid == 'F' || mid == 'U'))
if (mid == 'T') {
val = 1;
} else if (mid == 'F') {
val = 0;
} else if (mid == 'U') {
val = 2;
} else {
return false;
val = (mid == 'T');
}
return true;
}
@@ -445,7 +452,7 @@ Token IfcParse::GeneralTokenPtr(IfcSpfLexer* lexer, unsigned start, unsigned end
token.type = Token_STRING;
else if (first == '.') {
token.type = Token_ENUMERATION;
if (ParseBool(tokenStr.c_str(), token.value_bool)) //bool is also enumeration
if (ParseBool(tokenStr.c_str(), token.value_int)) //bool is also enumeration
token.type = Token_BOOL;
}
else if (first == '"')
@@ -495,6 +502,11 @@ bool TokenFunc::isInt(const Token& t) {
}
bool TokenFunc::isBool(const Token& t) {
// Bool and logical share the same storage type, just logical unknown is stored as 2.
return t.type == Token_BOOL && t.value_int != 2;
}
bool TokenFunc::isLogical(const Token& t) {
return t.type == Token_BOOL;
}
@@ -525,7 +537,21 @@ bool TokenFunc::asBool(const Token& t) {
if (t.type != Token_BOOL) {
throw IfcInvalidTokenException(t.startPos, toString(t), "boolean");
}
return t.value_bool;
return t.value_int == 1;
}
boost::logic::tribool TokenFunc::asLogical(const Token& t) {
if (t.type != Token_BOOL) {
throw IfcInvalidTokenException(t.startPos, toString(t), "boolean");
}
if (t.value_int == 0) {
return false;
} else if (t.value_int == 1) {
return true;
} else {
return boost::logic::indeterminate;
}
}
double TokenFunc::asFloat(const Token& t) {
@@ -752,8 +778,8 @@ ArgumentList::operator std::vector<boost::dynamic_bitset<> >() const {
return read_aggregate_as_vector<boost::dynamic_bitset<> >(list_, size_);
}
ArgumentList::operator IfcEntityList::ptr() const {
IfcEntityList::ptr l ( new IfcEntityList() );
ArgumentList::operator aggregate_of_instance::ptr() const {
aggregate_of_instance::ptr l ( new aggregate_of_instance() );
for (size_t i = 0; i < size_; ++i) {
// FIXME: account for $
IfcUtil::IfcBaseClass* entity = *list_[i];
@@ -770,13 +796,13 @@ ArgumentList::operator std::vector< std::vector<double> >() const {
return read_aggregate_of_aggregate_as_vector2<double>(list_, size_);
}
ArgumentList::operator IfcEntityListList::ptr() const {
IfcEntityListList::ptr l ( new IfcEntityListList() );
ArgumentList::operator aggregate_of_aggregate_of_instance::ptr() const {
aggregate_of_aggregate_of_instance::ptr l ( new aggregate_of_aggregate_of_instance() );
for (size_t i = 0; i < size_; ++i) {
const Argument* arg = list_[i];
const ArgumentList* arg_list;
if ((arg_list = dynamic_cast<const ArgumentList*>(arg)) != 0) {
IfcEntityList::ptr e = *arg_list;
aggregate_of_instance::ptr e = *arg_list;
l->push(e);
} else {
auto token = dynamic_cast<const TokenArgument*>(arg);
@@ -863,6 +889,7 @@ 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); }
@@ -1007,7 +1034,7 @@ unsigned IfcEntityInstanceData::set_id(boost::optional<unsigned> i) {
//
// Returns the entities of Entity type that have this entity in their ArgumentList
//
IfcEntityList::ptr IfcEntityInstanceData::getInverse(const IfcParse::declaration* type, int attribute_index) const {
aggregate_of_instance::ptr IfcEntityInstanceData::getInverse(const IfcParse::declaration* type, int attribute_index) const {
static std::mutex m;
std::lock_guard<std::mutex> lk(m);
@@ -1098,10 +1125,10 @@ public:
class add_to_instance_list_visitor {
private:
IfcEntityList::ptr& list_;
aggregate_of_instance::ptr& list_;
public:
add_to_instance_list_visitor(IfcEntityList::ptr& list)
add_to_instance_list_visitor(aggregate_of_instance::ptr& list)
: list_(list)
{}
@@ -1125,14 +1152,14 @@ private:
IfcUtil::IfcBaseClass* inst = *attr;
t(inst);
} else if (attr->type() == IfcUtil::Argument_AGGREGATE_OF_ENTITY_INSTANCE) {
IfcEntityList::ptr entity_list_attribute = *attr;
for (IfcEntityList::it it = entity_list_attribute->begin(); it != entity_list_attribute->end(); ++it) {
aggregate_of_instance::ptr entity_list_attribute = *attr;
for (aggregate_of_instance::it it = entity_list_attribute->begin(); it != entity_list_attribute->end(); ++it) {
t(*it);
}
} else if (attr->type() == IfcUtil::Argument_AGGREGATE_OF_AGGREGATE_OF_ENTITY_INSTANCE) {
IfcEntityListList::ptr entity_list_attribute = *attr;
for (IfcEntityListList::outer_it it = entity_list_attribute->begin(); it != entity_list_attribute->end(); ++it) {
for (IfcEntityListList::inner_it jt = it->begin(); jt != it->end(); ++jt) {
aggregate_of_aggregate_of_instance::ptr entity_list_attribute = *attr;
for (aggregate_of_aggregate_of_instance::outer_it it = entity_list_attribute->begin(); it != entity_list_attribute->end(); ++it) {
for (aggregate_of_aggregate_of_instance::inner_it jt = it->begin(); jt != it->end(); ++jt) {
t(*jt);
}
}
@@ -1234,10 +1261,10 @@ void IfcEntityInstanceData::setArgument(size_t i, Argument* a, IfcUtil::Argument
copy->set(static_cast<IfcUtil::IfcBaseClass*>(*a));
break; }
case IfcUtil::Argument_AGGREGATE_OF_ENTITY_INSTANCE: {
IfcEntityList::ptr instances = *a;
IfcEntityList::ptr mapped_instances(new IfcEntityList);
aggregate_of_instance::ptr instances = *a;
aggregate_of_instance::ptr mapped_instances(new aggregate_of_instance);
// @todo mapped_instances are not actually mapped to the file using add().
for (IfcEntityList::it it = instances->begin(); it != instances->end(); ++it) {
for (aggregate_of_instance::it it = instances->begin(); it != instances->end(); ++it) {
mapped_instances->push(*it);
}
copy->set(mapped_instances);
@@ -1251,11 +1278,11 @@ void IfcEntityInstanceData::setArgument(size_t i, Argument* a, IfcUtil::Argument
copy->set(attr_value);
break; }
case IfcUtil::Argument_AGGREGATE_OF_AGGREGATE_OF_ENTITY_INSTANCE: {
IfcEntityListList::ptr instances = *a;
IfcEntityListList::ptr mapped_instances(new IfcEntityListList);
for (IfcEntityListList::outer_it it = instances->begin(); it != instances->end(); ++it) {
aggregate_of_aggregate_of_instance::ptr instances = *a;
aggregate_of_aggregate_of_instance::ptr mapped_instances(new aggregate_of_aggregate_of_instance);
for (aggregate_of_aggregate_of_instance::outer_it it = instances->begin(); it != instances->end(); ++it) {
std::vector<IfcUtil::IfcBaseClass*> inner;
for (IfcEntityListList::inner_it jt = it->begin(); jt != it->end(); ++jt) {
for (aggregate_of_aggregate_of_instance::inner_it jt = it->begin(); jt != it->end(); ++jt) {
inner.push_back(*jt);
}
mapped_instances->push(inner);
@@ -1437,18 +1464,18 @@ void IfcFile::initialize_(IfcParse::IfcSpfStream* s) {
const IfcParse::declaration* ty = &instance->declaration();
{
IfcEntityList::ptr insts = instances_by_type_excl_subtypes(ty);
aggregate_of_instance::ptr insts = instances_by_type_excl_subtypes(ty);
if (!insts) {
insts = IfcEntityList::ptr(new IfcEntityList());
insts = aggregate_of_instance::ptr(new aggregate_of_instance());
bytype_excl[ty] = insts;
}
insts->push(instance);
}
for (;;) {
IfcEntityList::ptr insts = instances_by_type(ty);
aggregate_of_instance::ptr insts = instances_by_type(ty);
if (!insts) {
insts = IfcEntityList::ptr(new IfcEntityList());
insts = aggregate_of_instance::ptr(new aggregate_of_instance());
bytype[ty] = insts;
}
insts->push(instance);
@@ -1507,12 +1534,12 @@ void IfcFile::recalculate_id_counter() {
class traversal_visitor {
private:
std::set<IfcUtil::IfcBaseClass*>& visited_;
IfcEntityList::ptr& list_;
aggregate_of_instance::ptr& list_;
int level_;
int max_level_;
public:
traversal_visitor(std::set<IfcUtil::IfcBaseClass*>& visited, IfcEntityList::ptr& list, int level, int max_level)
traversal_visitor(std::set<IfcUtil::IfcBaseClass*>& visited, aggregate_of_instance::ptr& list, int level, int max_level)
: visited_(visited)
, list_(list)
, level_(level)
@@ -1522,7 +1549,7 @@ public:
void operator()(IfcUtil::IfcBaseClass* inst);
};
void traverse_(IfcUtil::IfcBaseClass* instance, std::set<IfcUtil::IfcBaseClass*>& visited, IfcEntityList::ptr list, int level, int max_level) {
void traverse_(IfcUtil::IfcBaseClass* instance, std::set<IfcUtil::IfcBaseClass*>& visited, aggregate_of_instance::ptr list, int level, int max_level) {
if (visited.find(instance) != visited.end()) {
return;
}
@@ -1539,15 +1566,15 @@ void traversal_visitor::operator()(IfcUtil::IfcBaseClass* inst) {
traverse_(inst, visited_, list_, level_, max_level_);
}
IfcEntityList::ptr IfcParse::traverse(IfcUtil::IfcBaseClass* instance, int max_level) {
aggregate_of_instance::ptr IfcParse::traverse(IfcUtil::IfcBaseClass* instance, int max_level) {
std::set<IfcUtil::IfcBaseClass*> visited;
IfcEntityList::ptr return_value(new IfcEntityList);
aggregate_of_instance::ptr return_value(new aggregate_of_instance);
traverse_(instance, visited, return_value, 0, max_level);
return return_value;
}
/// @note: for backwards compatibility
IfcEntityList::ptr IfcFile::traverse(IfcUtil::IfcBaseClass* instance, int max_level) {
aggregate_of_instance::ptr IfcFile::traverse(IfcUtil::IfcBaseClass* instance, int max_level) {
return IfcParse::traverse(instance, max_level);
}
@@ -1556,8 +1583,8 @@ void IfcFile::mark_entity_as_modified(int /*id*/)
by_ref_cached_.clear();
}
void IfcFile::addEntities(IfcEntityList::ptr es) {
for( IfcEntityList::it i = es->begin(); i != es->end(); ++ i ) {
void IfcFile::addEntities(aggregate_of_instance::ptr es) {
for( aggregate_of_instance::it i = es->begin(); i != es->end(); ++ i ) {
addEntity(*i);
}
}
@@ -1584,8 +1611,8 @@ IfcUtil::IfcBaseClass* IfcFile::addEntity(IfcUtil::IfcBaseClass* entity, int id)
// traversal and add them to the file.
if (parsing_complete_) {
try {
IfcEntityList::ptr entity_attributes = traverse(entity, 1);
for (IfcEntityList::it it = entity_attributes->begin(); it != entity_attributes->end(); ++it) {
aggregate_of_instance::ptr entity_attributes = traverse(entity, 1);
for (aggregate_of_instance::it it = entity_attributes->begin(); it != entity_attributes->end(); ++it) {
if (*it != entity) {
entity_entity_map_t::iterator mit2 = entity_file_map.find(*it);
if (mit2 == entity_file_map.end()) {
@@ -1641,9 +1668,9 @@ IfcUtil::IfcBaseClass* IfcFile::addEntity(IfcUtil::IfcBaseClass* entity, int id)
copy->set(eit->second);
we->setArgument(i, copy);
} else if (attr_type == IfcUtil::Argument_AGGREGATE_OF_ENTITY_INSTANCE) {
IfcEntityList::ptr instances = *attr;
IfcEntityList::ptr new_instances(new IfcEntityList);
for (IfcEntityList::it it = instances->begin(); it != instances->end(); ++it) {
aggregate_of_instance::ptr instances = *attr;
aggregate_of_instance::ptr new_instances(new aggregate_of_instance);
for (aggregate_of_instance::it it = instances->begin(); it != instances->end(); ++it) {
entity_entity_map_t::const_iterator eit = entity_file_map.find(*it);
if (eit == entity_file_map.end()) throw IfcParse::IfcException("Unable to map instance to file");
new_instances->push(eit->second);
@@ -1653,11 +1680,11 @@ IfcUtil::IfcBaseClass* IfcFile::addEntity(IfcUtil::IfcBaseClass* entity, int id)
copy->set(new_instances);
we->setArgument(i, copy);
} else if (attr_type == IfcUtil::Argument_AGGREGATE_OF_AGGREGATE_OF_ENTITY_INSTANCE) {
IfcEntityListList::ptr instances = *attr;
IfcEntityListList::ptr new_instances(new IfcEntityListList);
for (IfcEntityListList::outer_it it = instances->begin(); it != instances->end(); ++it) {
aggregate_of_aggregate_of_instance::ptr instances = *attr;
aggregate_of_aggregate_of_instance::ptr new_instances(new aggregate_of_aggregate_of_instance);
for (aggregate_of_aggregate_of_instance::outer_it it = instances->begin(); it != instances->end(); ++it) {
std::vector<IfcUtil::IfcBaseClass*> list;
for (IfcEntityListList::inner_it jt = it->begin(); jt != it->end(); ++jt) {
for (aggregate_of_aggregate_of_instance::inner_it jt = it->begin(); jt != it->end(); ++jt) {
entity_entity_map_t::const_iterator eit = entity_file_map.find(*jt);
if (eit == entity_file_map.end()) throw IfcParse::IfcException("Unable to map instance to file");
list.push_back(eit->second);
@@ -1735,18 +1762,18 @@ IfcUtil::IfcBaseClass* IfcFile::addEntity(IfcUtil::IfcBaseClass* entity, int id)
const IfcParse::declaration* ty = &new_entity->declaration();
if (ty->as_entity()) {
IfcEntityList::ptr insts = instances_by_type_excl_subtypes(ty);
aggregate_of_instance::ptr insts = instances_by_type_excl_subtypes(ty);
if (!insts) {
insts = IfcEntityList::ptr(new IfcEntityList());
insts = aggregate_of_instance::ptr(new aggregate_of_instance());
bytype_excl[ty] = insts;
}
insts->push(new_entity);
}
for (; ty->as_entity();) {
IfcEntityList::ptr insts = instances_by_type(ty);
aggregate_of_instance::ptr insts = instances_by_type(ty);
if (!insts) {
insts = IfcEntityList::ptr(new IfcEntityList());
insts = aggregate_of_instance::ptr(new aggregate_of_instance());
bytype[ty] = insts;
}
insts->push(new_entity);
@@ -1802,7 +1829,7 @@ void IfcFile::removeEntity(IfcUtil::IfcBaseClass* entity) {
// Attention when running removeEntity inside a loop over a list of entities to be removed.
// This invalidates the iterator. A workaround is to reverse the loop:
// boost::shared_ptr<IfcEntityList> entities = ...;
// boost::shared_ptr<aggregate_of_instance> entities = ...;
// for (auto it = entities->end() - 1; it >= entities->begin(); --it) {
// IfcUtil::IfcBaseClass *const inst = *it;
// model->removeEntity(inst);
@@ -1831,7 +1858,7 @@ void IfcFile::process_deletion_() {
for (auto& id : batch_deletion_ids_) {
auto entity = instance_by_id(id);
IfcEntityList::ptr references = instances_by_reference(id);
aggregate_of_instance::ptr references = instances_by_reference(id);
// Alter entity instances with INVERSE relations to the entity being
// deleted. This is necessary to maintain a valid IFC file, because
@@ -1839,7 +1866,7 @@ void IfcFile::process_deletion_() {
// moment, inversely related instances affected by the removal of the
// entity being deleted are not deleted themselves.
if (references) {
for (IfcEntityList::it iit = references->begin(); iit != references->end(); ++iit) {
for (aggregate_of_instance::it iit = references->begin(); iit != references->end(); ++iit) {
IfcUtil::IfcBaseEntity* related_instance = (IfcUtil::IfcBaseEntity*) *iit;
if (std::find(batch_deletion_ids_.begin(), batch_deletion_ids_.end(), related_instance->data().id()) != batch_deletion_ids_.end()) {
@@ -1861,7 +1888,7 @@ void IfcFile::process_deletion_() {
} }
break;
case IfcUtil::Argument_AGGREGATE_OF_ENTITY_INSTANCE: {
IfcEntityList::ptr instance_list = *attr;
aggregate_of_instance::ptr instance_list = *attr;
if (instance_list->contains(entity)) {
instance_list->remove(entity);
@@ -1871,10 +1898,10 @@ void IfcFile::process_deletion_() {
} }
break;
case IfcUtil::Argument_AGGREGATE_OF_AGGREGATE_OF_ENTITY_INSTANCE: {
IfcEntityListList::ptr instance_list_list = *attr;
aggregate_of_aggregate_of_instance::ptr instance_list_list = *attr;
if (instance_list_list->contains(entity)) {
IfcEntityListList::ptr new_list(new IfcEntityListList);
for (IfcEntityListList::outer_it it = instance_list_list->begin(); it != instance_list_list->end(); ++it) {
aggregate_of_aggregate_of_instance::ptr new_list(new aggregate_of_aggregate_of_instance);
for (aggregate_of_aggregate_of_instance::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()) {
@@ -1899,8 +1926,8 @@ void IfcFile::process_deletion_() {
// This is based on traversal which needs instances to still be contained in the map.
// another option would be to keep byid intact for the remainder of this loop
IfcEntityList::ptr entity_attributes = traverse(entity, 1);
for (IfcEntityList::it it = entity_attributes->begin(); it != entity_attributes->end(); ++it) {
aggregate_of_instance::ptr entity_attributes = traverse(entity, 1);
for (aggregate_of_instance::it it = entity_attributes->begin(); it != entity_attributes->end(); ++it) {
IfcUtil::IfcBaseClass* entity_attribute = *it;
if (entity_attribute == entity) continue;
const unsigned int name = entity_attribute->data().id();
@@ -1932,7 +1959,7 @@ void IfcFile::process_deletion_() {
const IfcParse::declaration* ty = &entity->declaration();
{
IfcEntityList::ptr instances_of_same_type = instances_by_type_excl_subtypes(ty);
aggregate_of_instance::ptr instances_of_same_type = instances_by_type_excl_subtypes(ty);
instances_of_same_type->remove(entity);
if (instances_of_same_type->size() == 0) {
bytype_excl.erase(ty);
@@ -1940,7 +1967,7 @@ void IfcFile::process_deletion_() {
}
for (;;) {
IfcEntityList::ptr instances_of_same_type = instances_by_type(ty);
aggregate_of_instance::ptr instances_of_same_type = instances_by_type(ty);
if (instances_of_same_type) {
instances_of_same_type->remove(entity);
}
@@ -1995,27 +2022,27 @@ void IfcFile::process_deletion_() {
batch_deletion_ids_.clear();
}
IfcEntityList::ptr IfcFile::instances_by_type(const IfcParse::declaration* t) {
aggregate_of_instance::ptr IfcFile::instances_by_type(const IfcParse::declaration* t) {
entities_by_type_t::const_iterator it = bytype.find(t);
return (it == bytype.end()) ? IfcEntityList::ptr() : it->second;
return (it == bytype.end()) ? aggregate_of_instance::ptr() : it->second;
}
IfcEntityList::ptr IfcFile::instances_by_type_excl_subtypes(const IfcParse::declaration* t) {
aggregate_of_instance::ptr IfcFile::instances_by_type_excl_subtypes(const IfcParse::declaration* t) {
entities_by_type_t::const_iterator it = bytype_excl.find(t);
return (it == bytype_excl.end()) ? IfcEntityList::ptr() : it->second;
return (it == bytype_excl.end()) ? aggregate_of_instance::ptr() : it->second;
}
IfcEntityList::ptr IfcFile::instances_by_type(const std::string& t) {
aggregate_of_instance::ptr IfcFile::instances_by_type(const std::string& t) {
return instances_by_type(schema()->declaration_by_name(t));
}
IfcEntityList::ptr IfcFile::instances_by_type_excl_subtypes(const std::string& t) {
aggregate_of_instance::ptr IfcFile::instances_by_type_excl_subtypes(const std::string& t) {
return instances_by_type_excl_subtypes(schema()->declaration_by_name(t));
}
IfcEntityList::ptr IfcFile::instances_by_reference(int t) {
aggregate_of_instance::ptr IfcFile::instances_by_reference(int t) {
entities_by_ref_t::const_iterator it = byref.find(t);
IfcEntityList::ptr ret;
aggregate_of_instance::ptr ret;
if (it != byref.end()) {
ref_map_t::const_iterator cached_it = by_ref_cached_.find(t);
if (cached_it != by_ref_cached_.end()) {
@@ -2023,7 +2050,7 @@ IfcEntityList::ptr IfcFile::instances_by_reference(int t) {
}
else {
if (it->second.size()) {
ret.reset(new IfcEntityList);
ret.reset(new aggregate_of_instance);
ret->reserve((unsigned)it->second.size());
const std::vector<unsigned>& ids = it->second;
for (std::vector<unsigned>::const_iterator jt = ids.begin(); jt != ids.end(); ++jt) {
@@ -2130,14 +2157,14 @@ std::string IfcFile::createTimestamp() const {
return result;
}
IfcEntityList::ptr IfcFile::getInverse(int instance_id, const IfcParse::declaration* type, int attribute_index) {
aggregate_of_instance::ptr IfcFile::getInverse(int instance_id, const IfcParse::declaration* type, int attribute_index) {
IfcUtil::IfcBaseClass* instance = instance_by_id(instance_id);
IfcEntityList::ptr l = IfcEntityList::ptr(new IfcEntityList);
IfcEntityList::ptr all = instances_by_reference(instance_id);
aggregate_of_instance::ptr l = aggregate_of_instance::ptr(new aggregate_of_instance);
aggregate_of_instance::ptr all = instances_by_reference(instance_id);
if (!all) return l;
for(IfcEntityList::it it = all->begin(); it != all->end(); ++it) {
for(aggregate_of_instance::it it = all->begin(); it != all->end(); ++it) {
bool valid = type == 0 || (*it)->declaration().is(*type);
if (valid && attribute_index >= 0) {
try {
@@ -2145,10 +2172,10 @@ IfcEntityList::ptr IfcFile::getInverse(int instance_id, const IfcParse::declarat
if (arg->type() == IfcUtil::Argument_ENTITY_INSTANCE) {
valid = instance == *arg;
} else if (arg->type() == IfcUtil::Argument_AGGREGATE_OF_ENTITY_INSTANCE) {
IfcEntityList::ptr li = *arg;
aggregate_of_instance::ptr li = *arg;
valid = li->contains(instance);
} else if (arg->type() == IfcUtil::Argument_AGGREGATE_OF_AGGREGATE_OF_ENTITY_INSTANCE) {
IfcEntityListList::ptr li = *arg;
aggregate_of_aggregate_of_instance::ptr li = *arg;
valid = li->contains(instance);
}
} catch (const IfcException& e) {
@@ -2189,7 +2216,7 @@ void IfcFile::setDefaultHeaderValues() {
std::pair<IfcUtil::IfcBaseClass*, double> IfcFile::getUnit(const std::string& unit_type) {
std::pair<IfcUtil::IfcBaseClass*, double> return_value(0, 1.);
IfcEntityList::ptr projects = instances_by_type(schema()->declaration_by_name("IfcProject"));
aggregate_of_instance::ptr projects = instances_by_type(schema()->declaration_by_name("IfcProject"));
if (projects && projects->size() == 1) {
IfcUtil::IfcBaseClass* project = *projects->begin();
@@ -2198,11 +2225,11 @@ std::pair<IfcUtil::IfcBaseClass*, double> IfcFile::getUnit(const std::string& un
project->declaration().as_entity()->attribute_index("UnitsInContext")
);
IfcEntityList::ptr units = *unit_assignment->data().getArgument(
aggregate_of_instance::ptr units = *unit_assignment->data().getArgument(
unit_assignment->declaration().as_entity()->attribute_index("Units")
);
for (IfcEntityList::it it = units->begin(); it != units->end(); ++it) {
for (aggregate_of_instance::it it = units->begin(); it != units->end(); ++it) {
IfcUtil::IfcBaseClass* unit = *it;
if (unit->declaration().is("IfcNamedUnit")) {
const std::string file_unit_type = *unit->data().getArgument(
@@ -2255,14 +2282,14 @@ std::pair<IfcUtil::IfcBaseClass*, double> IfcFile::getUnit(const std::string& un
}
void IfcParse::IfcFile::build_inverses_(IfcUtil::IfcBaseClass* inst) {
IfcEntityList::ptr entity_attributes(new IfcEntityList);
aggregate_of_instance::ptr entity_attributes(new aggregate_of_instance);
try {
entity_attributes = traverse(inst, 1);
} catch (const std::exception& e) {
Logger::Error(e);
}
for (IfcEntityList::it it = entity_attributes->begin(); it != entity_attributes->end(); ++it) {
for (aggregate_of_instance::it it = entity_attributes->begin(); it != entity_attributes->end(); ++it) {
IfcUtil::IfcBaseClass* entity_attribute = *it;
if (*it == inst) continue;
try {
+8 -4
View File
@@ -84,7 +84,6 @@ namespace IfcParse {
unsigned startPos;
TokenType type;
union {
bool value_bool; //types: BOOL
char value_char; //types: OPERATOR
int value_int; //types: INT, IDENTIFIER
double value_double; //types: FLOAT
@@ -119,6 +118,8 @@ namespace IfcParse {
static bool isInt(const Token& t);
/// Returns whether the token can be interpreted as a boolean
static bool isBool(const Token& t);
/// Returns whether the token can be interpreted as a logical
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
@@ -129,6 +130,8 @@ namespace IfcParse {
static int asIdentifier(const Token& t);
/// Returns the token interpreted as an boolean (.T. or .F.)
static bool asBool(const Token& t);
/// Returns the token interpreted as an logical (.T. or .F. or .U.)
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)
@@ -189,11 +192,11 @@ namespace IfcParse {
operator std::vector<double>() const;
operator std::vector<std::string>() const;
operator std::vector<boost::dynamic_bitset<> >() const;
operator IfcEntityList::ptr() const;
operator aggregate_of_instance::ptr() const;
operator std::vector< std::vector<int> >() const;
operator std::vector< std::vector<double> >() const;
operator IfcEntityListList::ptr() const;
operator aggregate_of_aggregate_of_instance::ptr() const;
bool isNull() const;
unsigned int size() const;
@@ -233,6 +236,7 @@ namespace IfcParse {
operator int() const;
operator bool() const;
operator boost::logic::tribool() const;
operator double() const;
operator std::string() const;
operator boost::dynamic_bitset<>() const;
@@ -268,7 +272,7 @@ namespace IfcParse {
IFC_PARSE_API IfcEntityInstanceData* read(unsigned int i, IfcFile* t, boost::optional<unsigned> offset = boost::none);
IFC_PARSE_API IfcEntityList::ptr traverse(IfcUtil::IfcBaseClass* instance, int max_level = -1);
IFC_PARSE_API aggregate_of_instance::ptr traverse(IfcUtil::IfcBaseClass* instance, int max_level = -1);
}
IFC_PARSE_API std::ostream& operator<< (std::ostream& os, const IfcParse::IfcFile& f);
+2 -2
View File
@@ -82,8 +82,8 @@ double IfcParse::get_SI_equivalent(typename Schema::IfcNamedUnit* named_unit) {
si_unit = named_unit->template as<typename Schema::IfcSIUnit>();
}
if (si_unit) {
if (si_unit->hasPrefix()) {
scale *= IfcSIPrefixToValue(Schema::IfcSIPrefix::ToString(si_unit->Prefix()));
if (si_unit->Prefix()) {
scale *= IfcSIPrefixToValue(Schema::IfcSIPrefix::ToString(*si_unit->Prefix()));
}
} else {
scale = 0.;
+21 -19
View File
@@ -55,7 +55,7 @@
#include "../ifcparse/Argument.h"
#include "../ifcparse/utils.h"
#include "../ifcparse/IfcException.h"
#include "../ifcparse/IfcEntityList.h"
#include "../ifcparse/aggregate_of_instance.h"
#include <boost/algorithm/string/replace.hpp>
#include <boost/optional.hpp>
@@ -64,37 +64,37 @@
#include <algorithm>
void IfcEntityList::push(IfcUtil::IfcBaseClass* l) {
void aggregate_of_instance::push(IfcUtil::IfcBaseClass* l) {
if (l) {
ls.push_back(l);
}
}
void IfcEntityList::push(const IfcEntityList::ptr& l) {
void aggregate_of_instance::push(const aggregate_of_instance::ptr& l) {
if (l) {
for( it i = l->begin(); i != l->end(); ++i ) {
if ( *i ) ls.push_back(*i);
}
}
}
unsigned int IfcEntityList::size() const { return (unsigned int) ls.size(); }
void IfcEntityList::reserve(unsigned capacity) { ls.reserve((size_t)capacity); }
IfcEntityList::it IfcEntityList::begin() { return ls.begin(); }
IfcEntityList::it IfcEntityList::end() { return ls.end(); }
IfcUtil::IfcBaseClass* IfcEntityList::operator[] (int i) {
unsigned int aggregate_of_instance::size() const { return (unsigned int) ls.size(); }
void aggregate_of_instance::reserve(unsigned capacity) { ls.reserve((size_t)capacity); }
aggregate_of_instance::it aggregate_of_instance::begin() { return ls.begin(); }
aggregate_of_instance::it aggregate_of_instance::end() { return ls.end(); }
IfcUtil::IfcBaseClass* aggregate_of_instance::operator[] (int i) {
return ls[i];
}
bool IfcEntityList::contains(IfcUtil::IfcBaseClass* instance) const {
bool aggregate_of_instance::contains(IfcUtil::IfcBaseClass* instance) const {
return std::find(ls.begin(), ls.end(), instance) != ls.end();
}
void IfcEntityList::remove(IfcUtil::IfcBaseClass* instance) {
void aggregate_of_instance::remove(IfcUtil::IfcBaseClass* instance) {
std::vector<IfcUtil::IfcBaseClass*>::iterator it;
while ((it = std::find(ls.begin(), ls.end(), instance)) != ls.end()) {
ls.erase(it);
}
}
IfcEntityList::ptr IfcEntityList::filtered(const std::set<const IfcParse::declaration*>& entities) {
IfcEntityList::ptr return_value(new IfcEntityList);
aggregate_of_instance::ptr aggregate_of_instance::filtered(const std::set<const IfcParse::declaration*>& entities) {
aggregate_of_instance::ptr return_value(new aggregate_of_instance);
for (it it = begin(); it != end(); ++it) {
bool contained = false;
for (std::set<const IfcParse::declaration*>::const_iterator jt = entities.begin(); jt != entities.end(); ++jt) {
@@ -110,9 +110,9 @@ IfcEntityList::ptr IfcEntityList::filtered(const std::set<const IfcParse::declar
return return_value;
}
IfcEntityList::ptr IfcEntityList::unique() {
aggregate_of_instance::ptr aggregate_of_instance::unique() {
std::set<IfcUtil::IfcBaseClass*> encountered;
IfcEntityList::ptr return_value(new IfcEntityList);
aggregate_of_instance::ptr return_value(new aggregate_of_instance);
for (it it = begin(); it != end(); ++it) {
if (encountered.find(*it) == encountered.end()) {
return_value->push(*it);
@@ -125,6 +125,7 @@ IfcEntityList::ptr IfcEntityList::unique() {
//Note: some of these methods are overloaded in derived classes
Argument::operator int() const { throw IfcParse::IfcException("Argument is not an integer"); }
Argument::operator bool() const { throw IfcParse::IfcException("Argument is not a boolean"); }
Argument::operator boost::logic::tribool() const { throw IfcParse::IfcException("Argument is not a logical"); }
Argument::operator double() const { throw IfcParse::IfcException("Argument is not a number"); }
Argument::operator std::string() const { throw IfcParse::IfcException("Argument is not a string"); }
Argument::operator boost::dynamic_bitset<>() const { throw IfcParse::IfcException("Argument is not a binary"); }
@@ -133,10 +134,10 @@ Argument::operator std::vector<double>() const { throw IfcParse::IfcException("A
Argument::operator std::vector<int>() const { throw IfcParse::IfcException("Argument is not a list of ints"); }
Argument::operator std::vector<std::string>() const { throw IfcParse::IfcException("Argument is not a list of strings"); }
Argument::operator std::vector<boost::dynamic_bitset<> >() const { throw IfcParse::IfcException("Argument is not a list of binaries"); }
Argument::operator IfcEntityList::ptr() const { throw IfcParse::IfcException("Argument is not a list of entity instances"); }
Argument::operator aggregate_of_instance::ptr() const { throw IfcParse::IfcException("Argument is not a list of entity instances"); }
Argument::operator std::vector< std::vector<int> >() const { throw IfcParse::IfcException("Argument is not a list of list of ints"); }
Argument::operator std::vector< std::vector<double> >() const { throw IfcParse::IfcException("Argument is not a list of list of floats"); }
Argument::operator IfcEntityListList::ptr() const { throw IfcParse::IfcException("Argument is not a list of list of entity instances"); }
Argument::operator aggregate_of_aggregate_of_instance::ptr() const { throw IfcParse::IfcException("Argument is not a list of list of entity instances"); }
static const char* const argument_type_string[] = {
@@ -144,6 +145,7 @@ static const char* const argument_type_string[] = {
"DERIVED",
"INT",
"BOOL",
"LOGICAL",
"DOUBLE",
"STRING",
"BINARY",
@@ -205,14 +207,14 @@ Argument* IfcUtil::IfcBaseEntity::get(const std::string& name) const {
return data().getArgument(declaration().attribute_index(name));
}
IfcEntityList::ptr IfcUtil::IfcBaseEntity::get_inverse(const std::string& name) const {
aggregate_of_instance::ptr IfcUtil::IfcBaseEntity::get_inverse(const std::string& name) const {
const std::vector<const IfcParse::inverse_attribute*> attrs = declaration().as_entity()->all_inverse_attributes();
std::vector<const IfcParse::inverse_attribute*>::const_iterator it = attrs.begin();
for (; it != attrs.end(); ++it) {
if ((*it)->name() == name) {
return data().getInverse(
(*it)->entity_reference(),
(*it)->entity_reference()->attribute_index((*it)->attribute_reference()));
(int) (*it)->entity_reference()->attribute_index((*it)->attribute_reference()));
}
}
throw IfcParse::IfcException(name + " not found on " + declaration().name());
@@ -275,7 +277,7 @@ IfcUtil::ArgumentType IfcUtil::from_parameter_type(const IfcParse::parameter_typ
case IfcParse::simple_type::integer_type:
return IfcUtil::Argument_INT;
case IfcParse::simple_type::logical_type:
return IfcUtil::Argument_BOOL;
return IfcUtil::Argument_LOGICAL;
case IfcParse::simple_type::number_type:
return IfcUtil::Argument_DOUBLE;
case IfcParse::simple_type::real_type:
+13 -11
View File
@@ -36,6 +36,7 @@ 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; }
@@ -49,8 +50,8 @@ public:
int operator()(const std::vector< boost::dynamic_bitset<> >& i) const { return (int)i.size(); }
int operator()(const IfcWriteArgument::EnumerationReference& /*i*/) const { return -1; }
int operator()(const IfcUtil::IfcBaseClass* const& /*i*/) const { return -1; }
int operator()(const IfcEntityList::ptr& i) const { return i->size(); }
int operator()(const IfcEntityListList::ptr& i) const { return i->size(); }
int operator()(const aggregate_of_instance::ptr& i) const { return i->size(); }
int operator()(const aggregate_of_aggregate_of_instance::ptr& i) const { return i->size(); }
};
class StringBuilderVisitor : public boost::static_visitor<void> {
@@ -120,6 +121,7 @@ public:
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 boost::logic::tribool& i) { data << (i ? ".T." : (boost::logic::indeterminate(i) ? ".U." : ".F.")); }
void operator()(const double& i) { data << format_double(i); }
void operator()(const boost::dynamic_bitset<>& i) { data << format_binary(i); }
void operator()(const std::string& i) {
@@ -145,9 +147,9 @@ public:
data << "#" << e.id();
}
}
void operator()(const IfcEntityList::ptr& i) {
void operator()(const aggregate_of_instance::ptr& i) {
data << "(";
for (IfcEntityList::it it = i->begin(); it != i->end(); ++it) {
for (aggregate_of_instance::it it = i->begin(); it != i->end(); ++it) {
if (it != i->begin()) data << ",";
(*this)(*it);
}
@@ -155,12 +157,12 @@ public:
}
void operator()(const std::vector< std::vector<int> >& i);
void operator()(const std::vector< std::vector<double> >& i);
void operator()(const IfcEntityListList::ptr& i) {
void operator()(const aggregate_of_aggregate_of_instance::ptr& i) {
data << "(";
for (IfcEntityListList::outer_it outer_it = i->begin(); outer_it != i->end(); ++outer_it) {
for (aggregate_of_aggregate_of_instance::outer_it outer_it = i->begin(); outer_it != i->end(); ++outer_it) {
if (outer_it != i->begin()) data << ",";
data << "(";
for (IfcEntityListList::inner_it inner_it = outer_it->begin(); inner_it != outer_it->end(); ++inner_it) {
for (aggregate_of_aggregate_of_instance::inner_it inner_it = outer_it->begin(); inner_it != outer_it->end(); ++inner_it) {
if (inner_it != outer_it->begin()) data << ",";
(*this)(*inner_it);
}
@@ -240,10 +242,10 @@ IfcWriteArgument::operator std::vector<double>() const { return as<std::vector<d
IfcWriteArgument::operator std::vector<int>() const { return as<std::vector<int> >(); }
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 aggregate_of_instance::ptr() const { return as<aggregate_of_instance::ptr>(); }
IfcWriteArgument::operator std::vector< std::vector<int> >() const { return as<std::vector< std::vector<int> > >(); }
IfcWriteArgument::operator std::vector< std::vector<double> >() const { return as<std::vector< std::vector<double> > >(); }
IfcWriteArgument::operator IfcEntityListList::ptr() const { return as<IfcEntityListList::ptr>(); }
IfcWriteArgument::operator aggregate_of_aggregate_of_instance::ptr() const { return as<aggregate_of_aggregate_of_instance::ptr>(); }
bool IfcWriteArgument::isNull() const { return type() == IfcUtil::Argument_NULL; }
Argument* IfcWriteArgument::operator [] (unsigned int /*i*/) const { throw IfcParse::IfcException("Invalid cast"); }
std::string IfcWriteArgument::toString(bool upper) const {
@@ -268,7 +270,7 @@ IfcUtil::ArgumentType IfcWriteArgument::type() const {
}
// Overload to detect null values
void IfcWriteArgument::set(const IfcEntityList::ptr& v) {
void IfcWriteArgument::set(const aggregate_of_instance::ptr& v) {
if (v) {
container = v;
} else {
@@ -277,7 +279,7 @@ void IfcWriteArgument::set(const IfcEntityList::ptr& v) {
}
// Overload to detect null values
void IfcWriteArgument::set(const IfcEntityListList::ptr& v) {
void IfcWriteArgument::set(const aggregate_of_aggregate_of_instance::ptr& v) {
if (v) {
container = v;
} else {
+9 -6
View File
@@ -31,6 +31,7 @@
#include <boost/variant.hpp>
#include <boost/optional.hpp>
#include <boost/dynamic_bitset.hpp>
// #include <boost/logic/tribool.hpp>
#include <boost/utility/enable_if.hpp>
#include <boost/type_traits/is_base_of.hpp>
@@ -72,6 +73,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'
@@ -103,7 +106,7 @@ namespace IfcWrite {
// An aggregate of entity instances. It will either serialize to
// e.g. (#1,#2,#3) or datatype identifier for simple types,
// e.g. (IFCREAL(1.2),IFCINTEGER(3.))
IfcEntityList::ptr,
aggregate_of_instance::ptr,
// AGGREGATES OF AGGREGATES:
empty_aggregate_of_aggregate_t,
@@ -112,7 +115,7 @@ namespace IfcWrite {
// 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))
IfcEntityListList::ptr
aggregate_of_aggregate_of_instance::ptr
> container;
public:
@@ -132,10 +135,10 @@ namespace IfcWrite {
}
// Overload to detect null values
void set(const IfcEntityList::ptr& v);
void set(const aggregate_of_instance::ptr& v);
// Overload to detect null values
void set(const IfcEntityListList::ptr& v);
void set(const aggregate_of_aggregate_of_instance::ptr& v);
// Overload to detect null values
void set(IfcUtil::IfcBaseClass*const & v);
@@ -151,11 +154,11 @@ namespace IfcWrite {
operator std::vector<double>() const;
operator std::vector<std::string>() const;
operator std::vector<boost::dynamic_bitset<> >() const;
operator IfcEntityList::ptr() const;
operator aggregate_of_instance::ptr() const;
operator std::vector< std::vector<int> >() const;
operator std::vector< std::vector<double> >() const;
operator IfcEntityListList::ptr() const;
operator aggregate_of_aggregate_of_instance::ptr() const;
bool isNull() const;
Argument* operator [] (unsigned int i) const;
@@ -27,12 +27,12 @@
#include <set>
template <class T>
class IfcTemplatedEntityList;
class aggregate_of;
class IFC_PARSE_API IfcEntityList {
class IFC_PARSE_API aggregate_of_instance {
std::vector<IfcUtil::IfcBaseClass*> ls;
public:
typedef boost::shared_ptr<IfcEntityList> ptr;
typedef boost::shared_ptr<aggregate_of_instance> ptr;
typedef std::vector<IfcUtil::IfcBaseClass*>::const_iterator it;
void push(IfcUtil::IfcBaseClass* l);
void push(const ptr& l);
@@ -50,23 +50,23 @@ public:
return r;
}
void remove(IfcUtil::IfcBaseClass*);
IfcEntityList::ptr filtered(const std::set<const IfcParse::declaration*>& entities);
IfcEntityList::ptr unique();
aggregate_of_instance::ptr filtered(const std::set<const IfcParse::declaration*>& entities);
aggregate_of_instance::ptr unique();
};
template <class T>
class IfcTemplatedEntityList {
class aggregate_of {
std::vector<T*> ls;
public:
typedef boost::shared_ptr< IfcTemplatedEntityList<T> > ptr;
typedef boost::shared_ptr< aggregate_of<T> > ptr;
typedef typename std::vector<T*>::const_iterator it;
void push(T* t) { if (t) { ls.push_back(t); } }
void push(ptr t) { if (t) { for (typename T::list::it it = t->begin(); it != t->end(); ++it) push(*it); } }
it begin() { return ls.begin(); }
it end() { return ls.end(); }
unsigned int size() const { return (unsigned int)ls.size(); }
IfcEntityList::ptr generalize() {
IfcEntityList::ptr r(new IfcEntityList());
aggregate_of_instance::ptr generalize() {
aggregate_of_instance::ptr r(new aggregate_of_instance());
for (it i = begin(); i != end(); ++i) r->push(*i);
return r;
}
@@ -87,18 +87,18 @@ public:
};
template <class T>
class IfcTemplatedEntityListList;
class aggregate_of_aggregate_of;
class IFC_PARSE_API IfcEntityListList {
class IFC_PARSE_API aggregate_of_aggregate_of_instance {
std::vector< std::vector<IfcUtil::IfcBaseClass*> > ls;
public:
typedef boost::shared_ptr< IfcEntityListList > ptr;
typedef boost::shared_ptr< aggregate_of_aggregate_of_instance > ptr;
typedef std::vector< std::vector<IfcUtil::IfcBaseClass*> >::const_iterator outer_it;
typedef std::vector<IfcUtil::IfcBaseClass*>::const_iterator inner_it;
void push(const std::vector<IfcUtil::IfcBaseClass*>& l) {
ls.push_back(l);
}
void push(const IfcEntityList::ptr& l) {
void push(const aggregate_of_instance::ptr& l) {
if (l) {
std::vector<IfcUtil::IfcBaseClass*> li;
for (std::vector<IfcUtil::IfcBaseClass*>::const_iterator jt = l->begin(); jt != l->end(); ++jt) {
@@ -127,8 +127,8 @@ public:
return false;
}
template <class U>
typename IfcTemplatedEntityListList<U>::ptr as() {
typename IfcTemplatedEntityListList<U>::ptr r(new IfcTemplatedEntityListList<U>);
typename aggregate_of_aggregate_of<U>::ptr as() {
typename aggregate_of_aggregate_of<U>::ptr r(new aggregate_of_aggregate_of<U>);
const bool all = !U::Class().as_entity();
for (outer_it outer = begin(); outer != end(); ++outer) {
const std::vector<IfcUtil::IfcBaseClass*>& from = *outer;
@@ -143,10 +143,10 @@ public:
};
template <class T>
class IfcTemplatedEntityListList {
class aggregate_of_aggregate_of {
std::vector< std::vector<T*> > ls;
public:
typedef typename boost::shared_ptr< IfcTemplatedEntityListList<T> > ptr;
typedef typename boost::shared_ptr< aggregate_of_aggregate_of<T> > ptr;
typedef typename std::vector< std::vector<T*> >::const_iterator outer_it;
typedef typename std::vector<T*>::const_iterator inner_it;
void push(const std::vector<T*>& t) { ls.push_back(t); }
@@ -169,8 +169,8 @@ public:
}
return false;
}
IfcEntityListList::ptr generalize() {
IfcEntityListList::ptr r(new IfcEntityListList());
aggregate_of_aggregate_of_instance::ptr generalize() {
aggregate_of_aggregate_of_instance::ptr r(new aggregate_of_aggregate_of_instance());
for (outer_it outer = begin(); outer != end(); ++outer) {
const std::vector<T*>& from = *outer;
std::vector<IfcUtil::IfcBaseClass*> to;