diff --git a/src/examples/IfcOpenHouse.cpp b/src/examples/IfcOpenHouse.cpp index 115144deb2..97883b10bb 100644 --- a/src/examples/IfcOpenHouse.cpp +++ b/src/examples/IfcOpenHouse.cpp @@ -34,7 +34,7 @@ #include "../ifcparse/IfcHierarchyHelper.h" #include "../ifcgeom/IfcGeom.h" -// Some convinience typedefs and definitions. +// Some convenience typedefs and definitions. typedef std::string S; typedef IfcWrite::IfcGuidHelper guid; typedef std::pair XY; @@ -45,8 +45,8 @@ void createGroundShape(TopoDS_Shape& shape); int main(int argc, char** argv) { - // The IfcHierarchyHelper is a subclass of the regular IfcFile that provides several convience - // functions for working with geometry in IFC files. + // The IfcHierarchyHelper is a subclass of the regular IfcFile that provides several + // convenience functions for working with geometry in IFC files. IfcHierarchyHelper file; // Start by adding a wall to the file, initially leaving most attributes blank. @@ -66,7 +66,7 @@ int main(int argc, char** argv) { // structure: IfcProject > IfcSite > IfcBuilding > IfcBuildingStorey > IfcWall // Lateron changing the name of the IfcProject can be done by obtaining a reference to the - // project, which was automatically created. since we know it exists. + // project, which has been created automatically. file.getSingle()->setName("IfcOpenHouse"); // An IfcOwnerHistory has been initialized as well, which should be assigned to the wall. @@ -234,7 +234,7 @@ int main(int argc, char** argv) { // can be a composition of multiple solids. The following door will be composed of four boxes // which constitute the door and its frame. Ifc2x3::IfcDoor* door = new Ifc2x3::IfcDoor(guid(), file.getSingle(), null, null, null, - file.addLocalPlacement(4800, 1600, 0, 0, 0, 1, 0, 1, 0), 0, null, 2120, 1000); + file.addLocalPlacement(4800, 1600, 0, 0, 0, 1, 0, 1, 0), 0, null, 2200, 1000); door->setRepresentation(file.addBox(80, 80, 2120, 0, file.addPlacement3d(460, 0, 0))); Ifc2x3::IfcRepresentation::list door_representations = door->Representation()->Representations(); Ifc2x3::IfcShapeRepresentation* door_body = 0; @@ -258,6 +258,10 @@ int main(int argc, char** argv) { // only the plate will have a transparent material assigned. // The window frame will consists of four seperate beams. + // AutoCAD Architecture will create an internal window type for the IfcWindow created. + // Therefore the OverallWidth and OverallHeight of the window attributes will need to + // match the bounding box of the representation. Furthermore, the window placement needs + // to align with the lowerleft corner of the constituent parts. Ifc2x3::IfcProductDefinitionShape::list frame_representations (new IfcTemplatedEntityList()); frame_representations->push(file.addBox(1860, 90, 90)); frame_representations->push(*frame_representations->begin()); // Add a reference to the shape created above @@ -277,18 +281,18 @@ int main(int argc, char** argv) { // This window will be placed at five locations within the building. A list of placements is // created and is iterated over to create all window instances. Ifc2x3::IfcLocalPlacement::list window_placements (new IfcTemplatedEntityList()); - window_placements->push(file.addLocalPlacement(2*-1770-430, 0, 400)); - window_placements->push(file.addLocalPlacement( -1770-430, 0, 400)); - window_placements->push(file.addLocalPlacement( -430, 0, 400)); - window_placements->push(file.addLocalPlacement( 3000, 0, 400)); - window_placements->push(file.addLocalPlacement( -4855, 885, 400, 0, 0, 1, 0, 1, 0)); + window_placements->push(file.addLocalPlacement(2*-1770-430-930, -45, 400)); + window_placements->push(file.addLocalPlacement( -1770-430-930, -45, 400)); + window_placements->push(file.addLocalPlacement( -430-930, -45, 400)); + window_placements->push(file.addLocalPlacement( 3000-930, -45, 400)); + window_placements->push(file.addLocalPlacement( -4855+45, 885-930, 400, 0, 0, 1, 0, 1, 0)); for (Ifc2x3::IfcLocalPlacement::it it = window_placements->begin(); it != window_placements->end(); ++it) { // Create the window at the current location Ifc2x3::IfcLocalPlacement* place = *it; Ifc2x3::IfcWindow* window = new Ifc2x3::IfcWindow(guid(), file.getSingle(), - null, null, null, place, 0, null, 2000, 1600); + null, null, null, place, 0, null, 1600, 1860); file.addBuildingProduct(window); // Initalize a list of parts for the window to be composed of @@ -297,10 +301,10 @@ int main(int argc, char** argv) { // The placements for the beams are not shared accross the different windows because every // beam is placed relative to its parent window entity. Ifc2x3::IfcLocalPlacement::list frame_placements (new IfcTemplatedEntityList()); - frame_placements->push(file.addLocalPlacement()); - frame_placements->push(file.addLocalPlacement( 0, 0, 1510)); - frame_placements->push(file.addLocalPlacement(-885, 0, 90)); - frame_placements->push(file.addLocalPlacement( 885, 0, 90)); + frame_placements->push(file.addLocalPlacement( 930,45)); + frame_placements->push(file.addLocalPlacement( 930, 45, 1510)); + frame_placements->push(file.addLocalPlacement(-885+930, 45, 90)); + frame_placements->push(file.addLocalPlacement( 885+930, 45, 90)); // Now iterate over the placements and representations of the beam and add them to list of parts Ifc2x3::IfcLocalPlacement::it frame_placement; @@ -318,7 +322,7 @@ int main(int argc, char** argv) { // Add the glass plate to the list of parts Ifc2x3::IfcPlate* glass_part = new Ifc2x3::IfcPlate(guid(), file.getSingle(), null, - null, null, file.addLocalPlacement(0, 0, 90), file.addBox(1680, 10, 1420), null); + null, null, file.addLocalPlacement(930, 45, 90), file.addBox(1680, 10, 1420), null); file.AddEntity(glass_part); window_parts->push(glass_part); file.relatePlacements(window, glass_part); diff --git a/src/ifcexpressparser/IfcExpressParser.py b/src/ifcexpressparser/IfcExpressParser.py index 8d5867b3f4..a482ad2570 100644 --- a/src/ifcexpressparser/IfcExpressParser.py +++ b/src/ifcexpressparser/IfcExpressParser.py @@ -348,18 +348,22 @@ class InverseList: return s class Classdef: def __init__(self,l): - self.class_name, self.parent_class, self.arguments, self.inverse = l + self.class_name, self.parent_class, self.arguments, derive, self.inverse = l self.arguments.class_name = self.class_name self.arguments.parent_class = self.parent_class entity_names.add(self.class_name) parent_relations[self.class_name] = self.parent_class argument_count[self.class_name] = len(self.arguments) entity_map[self.class_name] = self - def get_constructor_args(self): - s = entity_map[self.parent_class].get_constructor_args() if self.parent_class else [] + # For derived attributes only a reference is kepts to overridden attributes in parent classes + self.derive = [x[0].split('.')[-1] for x in derive[1] if x[0].startswith("SELF\\")] if derive else [] + def list_constructor_args(self): + s = entity_map[self.parent_class].list_constructor_args() if self.parent_class else [] i = len(s) + 1 - s += ["%s v%d_%s"%(a.type_str(),b+i,a.name) for a,b in zip(self.arguments.l,range(len(self.arguments)))] + s += [(a.type_str(),b+i,a.name) for a,b in zip(self.arguments.l,range(len(self.arguments)))] return s + def get_constructor_args(self): + return ["%s v%d_%s"%x for x in self.list_constructor_args() if x[2] not in self.get_derived()] def get_constructor_implementation(self): s = entity_map[self.parent_class].get_constructor_implementation() if self.parent_class else [] i = len(s) + 1 @@ -378,10 +382,13 @@ class Classdef: else: impl = "e->setArgument(%d,(%sv%d_%s)%s)"%(b+i-1,dereference,b+i,a.name,generalize) if use_boost_optional: - s.append("if (v%d_%s) { %s; } else { e->setArgument(%d); } "%(b+i,a.name,impl,b+i-1)) - else: s.append(impl) + s.append(["if (v%d_%s) { %s; } else { e->setArgument(%d); } "%(b+i,a.name,impl,b+i-1),a.name,i-1]) + else: s.append([impl,a.name,i-1]) b += 1 - return s#"; ".join(s) + return s + def get_derived(self): + s = entity_map[self.parent_class].get_derived() if self.parent_class else [] + return s + self.derive def __str__(self): self.constructor_args_list = self.get_constructor_args() self.constructor_args = ", ".join(self.constructor_args_list) @@ -403,7 +410,7 @@ class Classdef: ) elif generator_mode == 'SOURCE': self.arguments.argstart = argument_start(self.class_name) - self.constructor_implementation = "; ".join(self.get_constructor_implementation()) + self.constructor_implementation = "; ".join([x[0] if x[1] not in self.get_derived() else "e->setArgumentDerived(%d)"%x[2] for x in self.get_constructor_implementation()]) return (("\n// Function implementations for %(class_name)s"+str(self.arguments)+str(self.inverse)+ ("\nbool %(class_name)s::is(Type::Enum v) const { return v == Type::%(class_name)s; }" if self.parent_class is None else "\nbool %(class_name)s::is(Type::Enum v) const { return v == Type::%(class_name)s || %(parent_class)s::is(v); }")+ @@ -462,9 +469,9 @@ unique_value = s + x(':') + s + many(a(',')+s) + a(';') unique = skip(a('UNIQUE') + many(unique_value)) inverse_def = s + x(':') + (array|single) + x('FOR') + s + x(';') >> inverse_type inverse = maybe(x('INVERSE') + many( inverse_def )) >> inverse_list -derive = skip(a('DERIVE') + many(clause)) +derive = a('DERIVE') + many(clause) -entity = entity_start + arguments + skip(maybe(unique)) + skip(maybe(derive)) + inverse + skip(maybe(where)) + entity_end >> Classdef +entity = entity_start + arguments + skip(maybe(unique)) + maybe(derive) + inverse + skip(maybe(where)) + entity_end >> Classdef schema = skip(a('SCHEMA')) + s + x(';') diff --git a/src/ifcparse/Ifc2x3.cpp b/src/ifcparse/Ifc2x3.cpp index 1b33e0d84e..9bc474df70 100644 --- a/src/ifcparse/Ifc2x3.cpp +++ b/src/ifcparse/Ifc2x3.cpp @@ -7539,7 +7539,7 @@ bool IfcGeometricRepresentationSubContext::is(Type::Enum v) const { return v == Type::Enum IfcGeometricRepresentationSubContext::type() const { return Type::IfcGeometricRepresentationSubContext; } Type::Enum IfcGeometricRepresentationSubContext::Class() { return Type::IfcGeometricRepresentationSubContext; } IfcGeometricRepresentationSubContext::IfcGeometricRepresentationSubContext(IfcAbstractEntityPtr e) { if (!is(Type::IfcGeometricRepresentationSubContext)) throw IfcException("Unable to find find keyword in schema"); entity = e; } -IfcGeometricRepresentationSubContext::IfcGeometricRepresentationSubContext(optional< IfcLabel > v1_ContextIdentifier, optional< IfcLabel > v2_ContextType, IfcDimensionCount v3_CoordinateSpaceDimension, optional< double > v4_Precision, IfcAxis2Placement v5_WorldCoordinateSystem, IfcDirection* v6_TrueNorth, IfcGeometricRepresentationContext* v7_ParentContext, optional< IfcPositiveRatioMeasure > v8_TargetScale, IfcGeometricProjectionEnum::IfcGeometricProjectionEnum v9_TargetView, optional< IfcLabel > v10_UserDefinedTargetView) { IfcWritableEntity* e = new IfcWritableEntity(Class()); if (v1_ContextIdentifier) { e->setArgument(0,(*v1_ContextIdentifier)); } else { e->setArgument(0); } ; if (v2_ContextType) { e->setArgument(1,(*v2_ContextType)); } else { e->setArgument(1); } ; e->setArgument(2,(v3_CoordinateSpaceDimension)); if (v4_Precision) { e->setArgument(3,(*v4_Precision)); } else { e->setArgument(3); } ; e->setArgument(4,(v5_WorldCoordinateSystem)); e->setArgument(5,(v6_TrueNorth)); e->setArgument(6,(v7_ParentContext)); if (v8_TargetScale) { e->setArgument(7,(*v8_TargetScale)); } else { e->setArgument(7); } ; e->setArgument(8,v9_TargetView,IfcGeometricProjectionEnum::ToString(v9_TargetView)); if (v10_UserDefinedTargetView) { e->setArgument(9,(*v10_UserDefinedTargetView)); } else { e->setArgument(9); } ; entity = e; EntityBuffer::Add(this); } +IfcGeometricRepresentationSubContext::IfcGeometricRepresentationSubContext(optional< IfcLabel > v1_ContextIdentifier, optional< IfcLabel > v2_ContextType, IfcGeometricRepresentationContext* v7_ParentContext, optional< IfcPositiveRatioMeasure > v8_TargetScale, IfcGeometricProjectionEnum::IfcGeometricProjectionEnum v9_TargetView, optional< IfcLabel > v10_UserDefinedTargetView) { IfcWritableEntity* e = new IfcWritableEntity(Class()); if (v1_ContextIdentifier) { e->setArgument(0,(*v1_ContextIdentifier)); } else { e->setArgument(0); } ; if (v2_ContextType) { e->setArgument(1,(*v2_ContextType)); } else { e->setArgument(1); } ; e->setArgumentDerived(2); e->setArgumentDerived(2); e->setArgumentDerived(2); e->setArgumentDerived(2); e->setArgument(6,(v7_ParentContext)); if (v8_TargetScale) { e->setArgument(7,(*v8_TargetScale)); } else { e->setArgument(7); } ; e->setArgument(8,v9_TargetView,IfcGeometricProjectionEnum::ToString(v9_TargetView)); if (v10_UserDefinedTargetView) { e->setArgument(9,(*v10_UserDefinedTargetView)); } else { e->setArgument(9); } ; entity = e; EntityBuffer::Add(this); } // Function implementations for IfcGeometricSet SHARED_PTR< IfcTemplatedEntityList< IfcAbstractSelect > > IfcGeometricSet::Elements() { RETURN_AS_LIST(IfcAbstractSelect,0) } void IfcGeometricSet::setElements(SHARED_PTR< IfcTemplatedEntityList< IfcAbstractSelect > > v) { if ( ! entity->isWritable() ) { entity = new IfcWritableEntity(entity); } ((IfcWritableEntity*)entity)->setArgument(0,v->generalize()); } @@ -8405,7 +8405,7 @@ bool IfcOrientedEdge::is(Type::Enum v) const { return v == Type::IfcOrientedEdge Type::Enum IfcOrientedEdge::type() const { return Type::IfcOrientedEdge; } Type::Enum IfcOrientedEdge::Class() { return Type::IfcOrientedEdge; } IfcOrientedEdge::IfcOrientedEdge(IfcAbstractEntityPtr e) { if (!is(Type::IfcOrientedEdge)) throw IfcException("Unable to find find keyword in schema"); entity = e; } -IfcOrientedEdge::IfcOrientedEdge(IfcVertex* v1_EdgeStart, IfcVertex* v2_EdgeEnd, IfcEdge* v3_EdgeElement, bool v4_Orientation) { IfcWritableEntity* e = new IfcWritableEntity(Class()); e->setArgument(0,(v1_EdgeStart)); e->setArgument(1,(v2_EdgeEnd)); e->setArgument(2,(v3_EdgeElement)); e->setArgument(3,(v4_Orientation)); entity = e; EntityBuffer::Add(this); } +IfcOrientedEdge::IfcOrientedEdge(IfcEdge* v3_EdgeElement, bool v4_Orientation) { IfcWritableEntity* e = new IfcWritableEntity(Class()); e->setArgumentDerived(0); e->setArgumentDerived(0); e->setArgument(2,(v3_EdgeElement)); e->setArgument(3,(v4_Orientation)); entity = e; EntityBuffer::Add(this); } // Function implementations for IfcOutletType IfcOutletTypeEnum::IfcOutletTypeEnum IfcOutletType::PredefinedType() { return IfcOutletTypeEnum::FromString(*entity->getArgument(9)); } void IfcOutletType::setPredefinedType(IfcOutletTypeEnum::IfcOutletTypeEnum v) { if ( ! entity->isWritable() ) { entity = new IfcWritableEntity(entity); } ((IfcWritableEntity*)entity)->setArgument(9,v,IfcOutletTypeEnum::ToString(v)); } @@ -10110,7 +10110,7 @@ bool IfcSIUnit::is(Type::Enum v) const { return v == Type::IfcSIUnit || IfcNamed Type::Enum IfcSIUnit::type() const { return Type::IfcSIUnit; } Type::Enum IfcSIUnit::Class() { return Type::IfcSIUnit; } IfcSIUnit::IfcSIUnit(IfcAbstractEntityPtr e) { if (!is(Type::IfcSIUnit)) throw IfcException("Unable to find find keyword in schema"); entity = e; } -IfcSIUnit::IfcSIUnit(IfcDimensionalExponents* v1_Dimensions, IfcUnitEnum::IfcUnitEnum v2_UnitType, optional< IfcSIPrefix::IfcSIPrefix > v3_Prefix, IfcSIUnitName::IfcSIUnitName v4_Name) { IfcWritableEntity* e = new IfcWritableEntity(Class()); e->setArgument(0,(v1_Dimensions)); e->setArgument(1,v2_UnitType,IfcUnitEnum::ToString(v2_UnitType)); if (v3_Prefix) { e->setArgument(2,*v3_Prefix,IfcSIPrefix::ToString(*v3_Prefix)); } else { e->setArgument(2); } ; e->setArgument(3,v4_Name,IfcSIUnitName::ToString(v4_Name)); entity = e; EntityBuffer::Add(this); } +IfcSIUnit::IfcSIUnit(IfcUnitEnum::IfcUnitEnum v2_UnitType, optional< IfcSIPrefix::IfcSIPrefix > v3_Prefix, IfcSIUnitName::IfcSIUnitName v4_Name) { IfcWritableEntity* e = new IfcWritableEntity(Class()); e->setArgumentDerived(0); e->setArgument(1,v2_UnitType,IfcUnitEnum::ToString(v2_UnitType)); if (v3_Prefix) { e->setArgument(2,*v3_Prefix,IfcSIPrefix::ToString(*v3_Prefix)); } else { e->setArgument(2); } ; e->setArgument(3,v4_Name,IfcSIUnitName::ToString(v4_Name)); entity = e; EntityBuffer::Add(this); } // Function implementations for IfcSanitaryTerminalType IfcSanitaryTerminalTypeEnum::IfcSanitaryTerminalTypeEnum IfcSanitaryTerminalType::PredefinedType() { return IfcSanitaryTerminalTypeEnum::FromString(*entity->getArgument(9)); } void IfcSanitaryTerminalType::setPredefinedType(IfcSanitaryTerminalTypeEnum::IfcSanitaryTerminalTypeEnum v) { if ( ! entity->isWritable() ) { entity = new IfcWritableEntity(entity); } ((IfcWritableEntity*)entity)->setArgument(9,v,IfcSanitaryTerminalTypeEnum::ToString(v)); } diff --git a/src/ifcparse/Ifc2x3.h b/src/ifcparse/Ifc2x3.h index 688ef39083..fdd3ca1571 100644 --- a/src/ifcparse/Ifc2x3.h +++ b/src/ifcparse/Ifc2x3.h @@ -9733,7 +9733,7 @@ public: Type::Enum type() const; static Type::Enum Class(); IfcSIUnit (IfcAbstractEntityPtr e = IfcAbstractEntityPtr()); - IfcSIUnit (IfcDimensionalExponents* v1_Dimensions, IfcUnitEnum::IfcUnitEnum v2_UnitType, optional< IfcSIPrefix::IfcSIPrefix > v3_Prefix, IfcSIUnitName::IfcSIUnitName v4_Name); + IfcSIUnit (IfcUnitEnum::IfcUnitEnum v2_UnitType, optional< IfcSIPrefix::IfcSIPrefix > v3_Prefix, IfcSIUnitName::IfcSIUnitName v4_Name); typedef IfcSIUnit* ptr; typedef SHARED_PTR< IfcTemplatedEntityList< IfcSIUnit > > list; typedef IfcTemplatedEntityList< IfcSIUnit >::it it; @@ -13205,7 +13205,7 @@ public: Type::Enum type() const; static Type::Enum Class(); IfcGeometricRepresentationSubContext (IfcAbstractEntityPtr e = IfcAbstractEntityPtr()); - IfcGeometricRepresentationSubContext (optional< IfcLabel > v1_ContextIdentifier, optional< IfcLabel > v2_ContextType, IfcDimensionCount v3_CoordinateSpaceDimension, optional< double > v4_Precision, IfcAxis2Placement v5_WorldCoordinateSystem, IfcDirection* v6_TrueNorth, IfcGeometricRepresentationContext* v7_ParentContext, optional< IfcPositiveRatioMeasure > v8_TargetScale, IfcGeometricProjectionEnum::IfcGeometricProjectionEnum v9_TargetView, optional< IfcLabel > v10_UserDefinedTargetView); + IfcGeometricRepresentationSubContext (optional< IfcLabel > v1_ContextIdentifier, optional< IfcLabel > v2_ContextType, IfcGeometricRepresentationContext* v7_ParentContext, optional< IfcPositiveRatioMeasure > v8_TargetScale, IfcGeometricProjectionEnum::IfcGeometricProjectionEnum v9_TargetView, optional< IfcLabel > v10_UserDefinedTargetView); typedef IfcGeometricRepresentationSubContext* ptr; typedef SHARED_PTR< IfcTemplatedEntityList< IfcGeometricRepresentationSubContext > > list; typedef IfcTemplatedEntityList< IfcGeometricRepresentationSubContext >::it it; @@ -14111,7 +14111,7 @@ public: Type::Enum type() const; static Type::Enum Class(); IfcOrientedEdge (IfcAbstractEntityPtr e = IfcAbstractEntityPtr()); - IfcOrientedEdge (IfcVertex* v1_EdgeStart, IfcVertex* v2_EdgeEnd, IfcEdge* v3_EdgeElement, bool v4_Orientation); + IfcOrientedEdge (IfcEdge* v3_EdgeElement, bool v4_Orientation); typedef IfcOrientedEdge* ptr; typedef SHARED_PTR< IfcTemplatedEntityList< IfcOrientedEdge > > list; typedef IfcTemplatedEntityList< IfcOrientedEdge >::it it; diff --git a/src/ifcparse/IfcHierarchyHelper.cpp b/src/ifcparse/IfcHierarchyHelper.cpp index e6ea5e1ed8..9ce9bcc13f 100644 --- a/src/ifcparse/IfcHierarchyHelper.cpp +++ b/src/ifcparse/IfcHierarchyHelper.cpp @@ -98,9 +98,9 @@ Ifc2x3::IfcProject* IfcHierarchyHelper::addProject(Ifc2x3::IfcOwnerHistory* owne IfcEntities units (new IfcEntityList()); Ifc2x3::IfcDimensionalExponents* dimexp = new Ifc2x3::IfcDimensionalExponents(0, 0, 0, 0, 0, 0, 0); - Ifc2x3::IfcSIUnit* unit1 = new Ifc2x3::IfcSIUnit(dimexp, Ifc2x3::IfcUnitEnum::IfcUnit_LENGTHUNIT, + Ifc2x3::IfcSIUnit* unit1 = new Ifc2x3::IfcSIUnit(Ifc2x3::IfcUnitEnum::IfcUnit_LENGTHUNIT, Ifc2x3::IfcSIPrefix::IfcSIPrefix_MILLI, Ifc2x3::IfcSIUnitName::IfcSIUnitName_METRE); - Ifc2x3::IfcSIUnit* unit2a = new Ifc2x3::IfcSIUnit(dimexp, Ifc2x3::IfcUnitEnum::IfcUnit_PLANEANGLEUNIT, + Ifc2x3::IfcSIUnit* unit2a = new Ifc2x3::IfcSIUnit(Ifc2x3::IfcUnitEnum::IfcUnit_PLANEANGLEUNIT, boost::none, Ifc2x3::IfcSIUnitName::IfcSIUnitName_RADIAN); Ifc2x3::IfcMeasureWithUnit* unit2b = new Ifc2x3::IfcMeasureWithUnit( new IfcWrite::IfcSelectHelper(0.017453293, Ifc2x3::Type::IfcPlaneAngleMeasure), unit2a); diff --git a/src/ifcparse/IfcWritableEntity.h b/src/ifcparse/IfcWritableEntity.h index b43eb798fa..b1886fd9d7 100644 --- a/src/ifcparse/IfcWritableEntity.h +++ b/src/ifcparse/IfcWritableEntity.h @@ -59,6 +59,7 @@ namespace IfcWrite { unsigned int id(); bool isWritable(); void setArgument(int i); + void setArgumentDerived(int i); void setArgument(int i,bool v); void setArgument(int i,int v); void setArgument(int i,int v, const char* c); diff --git a/src/ifcparse/IfcWrite.cpp b/src/ifcparse/IfcWrite.cpp index d544addf5b..8a6ffcc70b 100644 --- a/src/ifcparse/IfcWrite.cpp +++ b/src/ifcparse/IfcWrite.cpp @@ -105,6 +105,11 @@ void IfcWritableEntity::setArgument(int i) { args[i] = new IfcWriteNullArgument(this); arg_writable(i,true); } +void IfcWritableEntity::setArgumentDerived(int i) { + if ( arg_writable(i) ) delete args[i]; + args[i] = new IfcWriteDerivedArgument(this); + arg_writable(i,true); +} void IfcWritableEntity::setArgument(int i,int v) { if ( arg_writable(i) ) delete args[i]; args[i] = new IfcWriteIntegralArgument(this,v); @@ -172,6 +177,20 @@ ArgumentPtr IfcWriteNullArgument::operator [] (unsigned int i) const { throw Ifc std::string IfcWriteNullArgument::toString(bool upper) const { return "$"; } unsigned int IfcWriteNullArgument::Size() const { throw IfcParse::IfcException("Invalid cast"); } +IfcWriteDerivedArgument::operator int() const { throw IfcParse::IfcException("Invalid cast"); } +IfcWriteDerivedArgument::operator bool() const { throw IfcParse::IfcException("Invalid cast"); } +IfcWriteDerivedArgument::operator double() const { throw IfcParse::IfcException("Invalid cast"); } +IfcWriteDerivedArgument::operator std::string() const { throw IfcParse::IfcException("Invalid cast"); } +IfcWriteDerivedArgument::operator std::vector() const { throw IfcParse::IfcException("Invalid cast"); } +IfcWriteDerivedArgument::operator std::vector() const { throw IfcParse::IfcException("Invalid cast"); } +IfcWriteDerivedArgument::operator std::vector() const { throw IfcParse::IfcException("Invalid cast"); } +IfcWriteDerivedArgument::operator IfcUtil::IfcSchemaEntity() const { throw IfcParse::IfcException("Invalid cast"); } +IfcWriteDerivedArgument::operator IfcEntities() const { throw IfcParse::IfcException("Invalid cast"); } +bool IfcWriteDerivedArgument::isNull() const { throw IfcParse::IfcException("Invalid cast"); } +ArgumentPtr IfcWriteDerivedArgument::operator [] (unsigned int i) const { throw IfcParse::IfcException("Invalid cast"); } +std::string IfcWriteDerivedArgument::toString(bool upper) const { return "*"; } +unsigned int IfcWriteDerivedArgument::Size() const { throw IfcParse::IfcException("Invalid cast"); } + IfcWriteEntityListArgument::IfcWriteEntityListArgument(IfcAbstractEntity* e, const IfcEntities& v) : IfcWriteArgument(e) { value = v; } IfcWriteEntityListArgument::operator int() const { throw IfcParse::IfcException("Invalid cast"); } IfcWriteEntityListArgument::operator bool() const { throw IfcParse::IfcException("Invalid cast"); } diff --git a/src/ifcparse/IfcWrite.h b/src/ifcparse/IfcWrite.h index ac385922ea..27801abb9a 100644 --- a/src/ifcparse/IfcWrite.h +++ b/src/ifcparse/IfcWrite.h @@ -58,6 +58,25 @@ namespace IfcWrite { std::string toString(bool upper=false) const; unsigned int Size() const; }; + + /// A derived argument. It will always serialize to * + class IfcWriteDerivedArgument : public IfcWriteArgument { + public: + IfcWriteDerivedArgument(IfcAbstractEntity* e) : IfcWriteArgument(e) {}; + operator int() const; + operator bool() const; + operator double() const; + operator std::string() const; + operator std::vector() const; + operator std::vector() const; + operator std::vector() const; + operator IfcUtil::IfcSchemaEntity() const; + operator IfcEntities() const; + bool isNull() const; + ArgumentPtr operator [] (unsigned int i) const; + std::string toString(bool upper=false) const; + unsigned int Size() const; + }; /// An entity list argument. It will serialize to (#1,#2,#3) /// with possibly a datatype identifier for SELECT types, e.g: