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
+5 -5
View File
@@ -1432,7 +1432,7 @@ namespace latebound_access {
void fix_quantities(IfcParse::IfcFile& f, bool no_progress, bool quiet, bool stderr_progress) {
{
auto delete_reversed = [&f](const IfcEntityList::ptr& insts) {
auto delete_reversed = [&f](const aggregate_of_instance::ptr& insts) {
if (!insts) {
return;
}
@@ -1518,7 +1518,7 @@ void fix_quantities(IfcParse::IfcFile& f, bool no_progress, bool quiet, bool std
latebound_access::set(ownerhist, "CreationDate", (int)time(0));
IfcUtil::IfcBaseClass* quantity = nullptr;
IfcEntityList::ptr objects;
aggregate_of_instance::ptr objects;
boost::shared_ptr<IfcGeom::Representation::BRep> previous_geometry_pointer;
for (;; ++num_created) {
@@ -1545,7 +1545,7 @@ void fix_quantities(IfcParse::IfcFile& f, bool no_progress, bool quiet, bool std
break;
}
IfcEntityList::ptr quantities(new IfcEntityList);
aggregate_of_instance::ptr quantities(new aggregate_of_instance);
double a, b, c;
if (geom_object->geometry().calculate_surface_area(a)) {
@@ -1573,7 +1573,7 @@ void fix_quantities(IfcParse::IfcFile& f, bool no_progress, bool quiet, bool std
latebound_access::set(quantity_complex, "Name", std::string("Shape Validation Properties"));
quantities->push(quantity_complex);
IfcEntityList::ptr quantities_2(new IfcEntityList);
aggregate_of_instance::ptr quantities_2(new aggregate_of_instance);
for (auto& part : geom_object->geometry()) {
auto quantity_count = latebound_access::create(f, "IfcQuantityCount");
@@ -1592,7 +1592,7 @@ void fix_quantities(IfcParse::IfcFile& f, bool no_progress, bool quiet, bool std
latebound_access::set(quantity, "Quantities", quantities);
}
objects.reset(new IfcEntityList);
objects.reset(new aggregate_of_instance);
objects->push(geom_object->product());
}
+4 -4
View File
@@ -450,8 +450,8 @@ public:
std::vector<IfcSchema::IfcPresentationStyle*> prs_styles;
#ifdef SCHEMA_HAS_IfcStyleAssignmentSelect
IfcEntityList::ptr style_assignments = si->Styles();
for (IfcEntityList::it kt = style_assignments->begin(); kt != style_assignments->end(); ++kt) {
aggregate_of_instance::ptr style_assignments = si->Styles();
for (aggregate_of_instance::it kt = style_assignments->begin(); kt != style_assignments->end(); ++kt) {
// Using IfcPresentationStyleAssignment is deprecated, use the direct assignment of a subtype of IfcPresentationStyle instead.
auto style_k = (*kt)->as<IfcSchema::IfcPresentationStyle>();
@@ -496,8 +496,8 @@ public:
if (style->declaration().is(IfcSchema::IfcSurfaceStyle::Class())) {
IfcSchema::IfcSurfaceStyle* surface_style = (IfcSchema::IfcSurfaceStyle*) style;
if (surface_style->Side() != IfcSchema::IfcSurfaceSide::IfcSurfaceSide_NEGATIVE) {
IfcEntityList::ptr styles_elements = surface_style->Styles();
for (IfcEntityList::it mt = styles_elements->begin(); mt != styles_elements->end(); ++mt) {
aggregate_of_instance::ptr styles_elements = surface_style->Styles();
for (aggregate_of_instance::it mt = styles_elements->begin(); mt != styles_elements->end(); ++mt) {
if ((*mt)->declaration().is(T::Class())) {
return std::make_pair(surface_style, (T*) *mt);
}
+42 -42
View File
@@ -534,11 +534,11 @@ bool IfcGeom::Kernel::convert(const IfcSchema::IfcRectangleHollowProfileDef* l,
const double y = l->YDim() / 2.0f * getValue(GV_LENGTH_UNIT);
const double d = l->WallThickness() * getValue(GV_LENGTH_UNIT);
const bool fr1 = l->hasOuterFilletRadius();
const bool fr2 = l->hasInnerFilletRadius();
const bool fr1 = !l->OuterFilletRadius();
const bool fr2 = !l->InnerFilletRadius();
const double r1 = fr1 ? l->OuterFilletRadius() * getValue(GV_LENGTH_UNIT) : 0.;
const double r2 = fr2 ? l->InnerFilletRadius() * getValue(GV_LENGTH_UNIT) : 0.;
const double r1 = fr1 ? (*l->OuterFilletRadius()) * getValue(GV_LENGTH_UNIT) : 0.;
const double r2 = fr2 ? (*l->InnerFilletRadius()) * getValue(GV_LENGTH_UNIT) : 0.;
if ( x < ALMOST_ZERO || y < ALMOST_ZERO ) {
Logger::Message(Logger::LOG_NOTICE,"Skipping zero sized profile:",l);
@@ -622,10 +622,10 @@ bool IfcGeom::Kernel::convert(const IfcSchema::IfcIShapeProfileDef* l, TopoDS_Sh
const double d1 = l->WebThickness() / 2.0f * getValue(GV_LENGTH_UNIT);
const double dy1 = l->FlangeThickness() * getValue(GV_LENGTH_UNIT);
bool doFillet1 = l->hasFilletRadius();
bool doFillet1 = !!l->FilletRadius();
double f1 = 0.;
if ( doFillet1 ) {
f1 = l->FilletRadius() * getValue(GV_LENGTH_UNIT);
f1 = *l->FilletRadius() * getValue(GV_LENGTH_UNIT);
}
bool doFillet2 = doFillet1;
@@ -635,12 +635,12 @@ bool IfcGeom::Kernel::convert(const IfcSchema::IfcIShapeProfileDef* l, TopoDS_Sh
if (l->declaration().is(IfcSchema::IfcAsymmetricIShapeProfileDef::Class())) {
IfcSchema::IfcAsymmetricIShapeProfileDef* assym = (IfcSchema::IfcAsymmetricIShapeProfileDef*) l;
x2 = assym->TopFlangeWidth() / 2. * getValue(GV_LENGTH_UNIT);
doFillet2 = assym->hasTopFlangeFilletRadius();
doFillet2 = !!assym->TopFlangeFilletRadius();
if (doFillet2) {
f2 = assym->TopFlangeFilletRadius() * getValue(GV_LENGTH_UNIT);
f2 = *assym->TopFlangeFilletRadius() * getValue(GV_LENGTH_UNIT);
}
if (assym->hasTopFlangeThickness()) {
dy2 = assym->TopFlangeThickness() * getValue(GV_LENGTH_UNIT);
if (assym->TopFlangeThickness()) {
dy2 = *assym->TopFlangeThickness() * getValue(GV_LENGTH_UNIT);
}
}
@@ -670,17 +670,17 @@ bool IfcGeom::Kernel::convert(const IfcSchema::IfcZShapeProfileDef* l, TopoDS_Sh
const double dx = l->WebThickness() / 2.0f * getValue(GV_LENGTH_UNIT);
const double dy = l->FlangeThickness() * getValue(GV_LENGTH_UNIT);
bool doFillet = l->hasFilletRadius();
bool doEdgeFillet = l->hasEdgeRadius();
bool doFillet = !!l->FilletRadius();
bool doEdgeFillet = !!l->EdgeRadius();
double f1 = 0.;
double f2 = 0.;
if ( doFillet ) {
f1 = l->FilletRadius() * getValue(GV_LENGTH_UNIT);
f1 = *l->FilletRadius() * getValue(GV_LENGTH_UNIT);
}
if ( doEdgeFillet ) {
f2 = l->EdgeRadius() * getValue(GV_LENGTH_UNIT);
f2 = *l->EdgeRadius() * getValue(GV_LENGTH_UNIT);
}
if ( x == 0.0f || y == 0.0f || dx == 0.0f || dy == 0.0f ) {
@@ -708,11 +708,11 @@ bool IfcGeom::Kernel::convert(const IfcSchema::IfcCShapeProfileDef* l, TopoDS_Sh
const double x = l->Width() / 2.0f * getValue(GV_LENGTH_UNIT);
const double d1 = l->WallThickness() * getValue(GV_LENGTH_UNIT);
const double d2 = l->Girth() * getValue(GV_LENGTH_UNIT);
bool doFillet = l->hasInternalFilletRadius();
bool doFillet = !!l->InternalFilletRadius();
double f1 = 0;
double f2 = 0;
if ( doFillet ) {
f1 = l->InternalFilletRadius() * getValue(GV_LENGTH_UNIT);
f1 = *l->InternalFilletRadius() * getValue(GV_LENGTH_UNIT);
f2 = f1 + d1;
}
@@ -737,22 +737,22 @@ bool IfcGeom::Kernel::convert(const IfcSchema::IfcCShapeProfileDef* l, TopoDS_Sh
}
bool IfcGeom::Kernel::convert(const IfcSchema::IfcLShapeProfileDef* l, TopoDS_Shape& face) {
const bool hasSlope = l->hasLegSlope();
const bool doEdgeFillet = l->hasEdgeRadius();
const bool doFillet = l->hasFilletRadius();
const bool hasSlope = !!l->LegSlope();
const bool doEdgeFillet = !!l->EdgeRadius();
const bool doFillet = !!l->FilletRadius();
const double y = l->Depth() / 2.0f * getValue(GV_LENGTH_UNIT);
const double x = (l->hasWidth() ? l->Width() : l->Depth()) / 2.0f * getValue(GV_LENGTH_UNIT);
const double x = l->Width().get_value_or(l->Depth()) / 2.0f * getValue(GV_LENGTH_UNIT);
const double d = l->Thickness() * getValue(GV_LENGTH_UNIT);
const double slope = hasSlope ? (l->LegSlope() * getValue(GV_PLANEANGLE_UNIT)) : 0.;
const double slope = l->LegSlope().get_value_or(0.) * getValue(GV_PLANEANGLE_UNIT);
double f1 = 0.0f;
double f2 = 0.0f;
if (doFillet) {
f1 = l->FilletRadius() * getValue(GV_LENGTH_UNIT);
f1 = *l->FilletRadius() * getValue(GV_LENGTH_UNIT);
}
if ( doEdgeFillet) {
f2 = l->EdgeRadius() * getValue(GV_LENGTH_UNIT);
f2 = *l->EdgeRadius() * getValue(GV_LENGTH_UNIT);
}
if ( x < ALMOST_ZERO || y < ALMOST_ZERO || d < ALMOST_ZERO ) {
@@ -812,15 +812,15 @@ bool IfcGeom::Kernel::convert(const IfcSchema::IfcLShapeProfileDef* l, TopoDS_Sh
}
bool IfcGeom::Kernel::convert(const IfcSchema::IfcUShapeProfileDef* l, TopoDS_Shape& face) {
const bool doEdgeFillet = l->hasEdgeRadius();
const bool doFillet = l->hasFilletRadius();
const bool hasSlope = l->hasFlangeSlope();
const bool doEdgeFillet = !!l->EdgeRadius();
const bool doFillet = !!l->FilletRadius();
const bool hasSlope = !!l->FlangeSlope();
const double y = l->Depth() / 2.0f * getValue(GV_LENGTH_UNIT);
const double x = l->FlangeWidth() / 2.0f * getValue(GV_LENGTH_UNIT);
const double d1 = l->WebThickness() * getValue(GV_LENGTH_UNIT);
const double d2 = l->FlangeThickness() * getValue(GV_LENGTH_UNIT);
const double slope = hasSlope ? (l->FlangeSlope() * getValue(GV_PLANEANGLE_UNIT)) : 0.;
const double slope = l->FlangeSlope().get_value_or(0.) * getValue(GV_PLANEANGLE_UNIT);
double dy1 = 0.0f;
double dy2 = 0.0f;
@@ -828,10 +828,10 @@ bool IfcGeom::Kernel::convert(const IfcSchema::IfcUShapeProfileDef* l, TopoDS_Sh
double f2 = 0.0f;
if (doFillet) {
f1 = l->FilletRadius() * getValue(GV_LENGTH_UNIT);
f1 = *l->FilletRadius() * getValue(GV_LENGTH_UNIT);
}
if (doEdgeFillet) {
f2 = l->EdgeRadius() * getValue(GV_LENGTH_UNIT);
f2 = *l->EdgeRadius() * getValue(GV_LENGTH_UNIT);
}
if (hasSlope) {
@@ -860,18 +860,18 @@ bool IfcGeom::Kernel::convert(const IfcSchema::IfcUShapeProfileDef* l, TopoDS_Sh
}
bool IfcGeom::Kernel::convert(const IfcSchema::IfcTShapeProfileDef* l, TopoDS_Shape& face) {
const bool doFlangeEdgeFillet = l->hasFlangeEdgeRadius();
const bool doWebEdgeFillet = l->hasWebEdgeRadius();
const bool doFillet = l->hasFilletRadius();
const bool hasFlangeSlope = l->hasFlangeSlope();
const bool hasWebSlope = l->hasWebSlope();
const bool doFlangeEdgeFillet = !!l->FlangeEdgeRadius();
const bool doWebEdgeFillet = !!l->WebEdgeRadius();
const bool doFillet = !!l->FilletRadius();
const bool hasFlangeSlope = !!l->FlangeSlope();
const bool hasWebSlope = !!l->WebSlope();
const double y = l->Depth() / 2.0f * getValue(GV_LENGTH_UNIT);
const double x = l->FlangeWidth() / 2.0f * getValue(GV_LENGTH_UNIT);
const double d1 = l->WebThickness() * getValue(GV_LENGTH_UNIT);
const double d2 = l->FlangeThickness() * getValue(GV_LENGTH_UNIT);
const double flangeSlope = hasFlangeSlope ? (l->FlangeSlope() * getValue(GV_PLANEANGLE_UNIT)) : 0.;
const double webSlope = hasWebSlope ? (l->WebSlope() * getValue(GV_PLANEANGLE_UNIT)) : 0.;
const double flangeSlope = hasFlangeSlope ? (*l->FlangeSlope() * getValue(GV_PLANEANGLE_UNIT)) : 0.;
const double webSlope = hasWebSlope ? (*l->WebSlope() * getValue(GV_PLANEANGLE_UNIT)) : 0.;
if ( x < ALMOST_ZERO || y < ALMOST_ZERO || d1 < ALMOST_ZERO || d2 < ALMOST_ZERO ) {
Logger::Message(Logger::LOG_NOTICE,"Skipping zero sized profile:",l);
@@ -887,13 +887,13 @@ bool IfcGeom::Kernel::convert(const IfcSchema::IfcTShapeProfileDef* l, TopoDS_Sh
double f3 = 0.0f;
if (doFillet) {
f1 = l->FilletRadius() * getValue(GV_LENGTH_UNIT);
f1 = *l->FilletRadius() * getValue(GV_LENGTH_UNIT);
}
if (doWebEdgeFillet) {
f2 = l->WebEdgeRadius() * getValue(GV_LENGTH_UNIT);
f2 = *l->WebEdgeRadius() * getValue(GV_LENGTH_UNIT);
}
if (doFlangeEdgeFillet) {
f3 = l->FlangeEdgeRadius() * getValue(GV_LENGTH_UNIT);
f3 = *l->FlangeEdgeRadius() * getValue(GV_LENGTH_UNIT);
}
double xx, xy;
@@ -1201,7 +1201,7 @@ bool IfcGeom::Kernel::convert(const IfcSchema::IfcPlane* l, TopoDS_Shape& face)
#ifdef SCHEMA_HAS_IfcBSplineSurfaceWithKnots
bool IfcGeom::Kernel::convert(const IfcSchema::IfcBSplineSurfaceWithKnots* l, TopoDS_Shape& face) {
boost::shared_ptr< IfcTemplatedEntityListList<IfcSchema::IfcCartesianPoint> > cps = l->ControlPointsList();
boost::shared_ptr< aggregate_of_aggregate_of<IfcSchema::IfcCartesianPoint> > cps = l->ControlPointsList();
std::vector<double> uknots = l->UKnots();
std::vector<double> vknots = l->VKnots();
std::vector<int> umults = l->UMultiplicities();
@@ -1216,9 +1216,9 @@ bool IfcGeom::Kernel::convert(const IfcSchema::IfcBSplineSurfaceWithKnots* l, To
Standard_Integer VDegree = l->VDegree();
int i = 0, j;
for (IfcTemplatedEntityListList<IfcSchema::IfcCartesianPoint>::outer_it it = cps->begin(); it != cps->end(); ++it, ++i) {
for (aggregate_of_aggregate_of<IfcSchema::IfcCartesianPoint>::outer_it it = cps->begin(); it != cps->end(); ++it, ++i) {
j = 0;
for (IfcTemplatedEntityListList<IfcSchema::IfcCartesianPoint>::inner_it jt = (*it).begin(); jt != (*it).end(); ++jt, ++j) {
for (aggregate_of_aggregate_of<IfcSchema::IfcCartesianPoint>::inner_it jt = (*it).begin(); jt != (*it).end(); ++jt, ++j) {
IfcSchema::IfcCartesianPoint* p = *jt;
gp_Pnt pnt;
if (!convert(p, pnt)) return false;
+42 -44
View File
@@ -200,9 +200,9 @@ namespace {
for (it = contexts->begin(); it != contexts->end(); ++it) {
IfcSchema::IfcGeometricRepresentationContext* context = *it;
if (context->hasPrecision() && context->Precision() < lowest_precision_encountered) {
if (context->Precision() && (*context->Precision() * unit_magnitude * 10.) < lowest_precision_encountered) {
// Some arbitrary factor that has proven to work better for the models in the set of test files.
lowest_precision_encountered = context->Precision() * unit_magnitude * 10.;
lowest_precision_encountered = *context->Precision() * unit_magnitude * 10.;
any_precision_encountered = true;
}
}
@@ -749,16 +749,16 @@ bool IfcGeom::Kernel::convert_openings(const IfcSchema::IfcProduct* entity, cons
// Iterate over IfcOpeningElements
IfcGeom::IfcRepresentationShapeItems opening_shapes;
unsigned int last_size = 0;
size_t last_size = 0;
for ( IfcSchema::IfcRelVoidsElement::list::it it = openings->begin(); it != openings->end(); ++ it ) {
IfcSchema::IfcRelVoidsElement* v = *it;
IfcSchema::IfcFeatureElementSubtraction* fes = v->RelatedOpeningElement();
if ( fes->declaration().is(IfcSchema::IfcOpeningElement::Class()) ) {
if (!fes->hasRepresentation()) continue;
if (!fes->Representation()) continue;
// Convert the IfcRepresentation of the IfcOpeningElement
gp_Trsf opening_trsf;
if (fes->hasObjectPlacement()) {
if (fes->ObjectPlacement()) {
try {
convert(fes->ObjectPlacement(),opening_trsf);
} catch (const std::exception& e) {
@@ -778,8 +778,8 @@ bool IfcGeom::Kernel::convert_openings(const IfcSchema::IfcProduct* entity, cons
convert_shapes(*it2,opening_shapes);
}
const unsigned int current_size = opening_shapes.size();
for ( unsigned int i = last_size; i < current_size; ++ i ) {
auto current_size = opening_shapes.size();
for ( auto i = last_size; i < current_size; ++ i ) {
opening_shapes[i].prepend(opening_trsf);
}
last_size = current_size;
@@ -1015,11 +1015,11 @@ bool IfcGeom::Kernel::convert_openings_fast(const IfcSchema::IfcProduct* entity,
IfcSchema::IfcRelVoidsElement* v = *it;
IfcSchema::IfcFeatureElementSubtraction* fes = v->RelatedOpeningElement();
if (fes->declaration().is(IfcSchema::IfcOpeningElement::Class())) {
if (!fes->hasRepresentation()) continue;
if (!fes->Representation()) continue;
// Convert the IfcRepresentation of the IfcOpeningElement
gp_Trsf opening_trsf;
if (fes->hasObjectPlacement()) {
if (fes->ObjectPlacement()) {
try {
convert(fes->ObjectPlacement(), opening_trsf);
} catch (const std::exception& e) {
@@ -1795,9 +1795,9 @@ IfcSchema::IfcRelVoidsElement::list::ptr IfcGeom::Kernel::find_openings(IfcSchem
// Filter openings in Reference view, solely marked as Reference.
IfcSchema::IfcRelVoidsElement::list::ptr openings(new IfcSchema::IfcRelVoidsElement::list);
std::for_each(rs.begin(), rs.end(), [&openings](IfcSchema::IfcRelVoidsElement* rel) {
if (rel->RelatedOpeningElement()->hasObjectPlacement() && rel->RelatedOpeningElement()->hasRepresentation()) {
if (rel->RelatedOpeningElement()->ObjectPlacement() && rel->RelatedOpeningElement()->Representation()) {
auto reps = rel->RelatedOpeningElement()->Representation()->Representations();
if (!(reps->size() == 1 && (*reps->begin())->RepresentationIdentifier() == "Reference")) {
if (!(reps->size() == 1 && (*reps->begin())->RepresentationIdentifier().get_value_or("") == "Reference")) {
openings->push(rel);
}
}
@@ -1819,7 +1819,7 @@ const IfcSchema::IfcMaterial* IfcGeom::Kernel::get_single_material_association(c
IfcSchema::IfcMaterialLayerSet* layerset = associated_material->as<IfcSchema::IfcMaterialLayerSetUsage>()->ForLayerSet();
if (getValue(GV_LAYERSET_FIRST) > 0.0 ? layerset->MaterialLayers()->size() >= 1 : layerset->MaterialLayers()->size() == 1) {
IfcSchema::IfcMaterialLayer* layer = (*layerset->MaterialLayers()->begin());
if (layer->hasMaterial()) {
if (layer->Material()) {
single_material = layer->Material();
}
}
@@ -1936,7 +1936,7 @@ IfcGeom::BRepElement* IfcGeom::Kernel::create_brep_for_representation_and_produc
Logger::Error(e);
}
const std::string name = product->hasName() ? product->Name() : "";
const std::string name = product->Name().get_value_or("");
const std::string guid = product->GlobalId();
gp_Trsf trsf;
@@ -2013,10 +2013,10 @@ IfcGeom::BRepElement* IfcGeom::Kernel::create_brep_for_representation_and_produc
}
std::string context_string = "";
if (representation->hasRepresentationIdentifier()) {
context_string = representation->RepresentationIdentifier();
} else if (representation->ContextOfItems()->hasContextType()) {
context_string = representation->ContextOfItems()->ContextType();
if (representation->RepresentationIdentifier()) {
context_string = *representation->RepresentationIdentifier();
} else if (representation->ContextOfItems()->ContextType()) {
context_string = *representation->ContextOfItems()->ContextType();
}
auto elem = new BRepElement(
@@ -2075,9 +2075,9 @@ IfcGeom::BRepElement* IfcGeom::Kernel::create_brep_for_representation_and_produc
auto qs2 = q->as<IfcSchema::IfcPhysicalComplexQuantity>()->HasQuantities();
bool all_succeeded = qs2->size() > 0;
for (auto& q2 : *qs2) {
if (q2->as<IfcSchema::IfcQuantityCount>() && q2->Name() == "Surface Genus" && q2->hasDescription()) {
int item_id = boost::lexical_cast<int>(q2->Description().substr(1));
int genus = q2->as<IfcSchema::IfcQuantityCount>()->CountValue();
if (q2->as<IfcSchema::IfcQuantityCount>() && q2->Name() == "Surface Genus" && q2->Description()) {
int item_id = boost::lexical_cast<int>((*q2->Description()).substr(1));
int genus = (int) q2->as<IfcSchema::IfcQuantityCount>()->CountValue();
for (auto& part : elem->geometry()) {
if (part.ItemId() == item_id) {
if (surface_genus(part.Shape()) != genus) {
@@ -2200,7 +2200,7 @@ IfcGeom::BRepElement* IfcGeom::Kernel::create_brep_for_processed_representation(
Logger::Error(e);
}
const std::string name = product->hasName() ? product->Name() : "";
const std::string name = product->Name().get_value_or("");
const std::string guid = product->GlobalId();
gp_Trsf trsf;
@@ -2213,10 +2213,10 @@ IfcGeom::BRepElement* IfcGeom::Kernel::create_brep_for_processed_representation(
}
std::string context_string = "";
if (representation->hasRepresentationIdentifier()) {
context_string = representation->RepresentationIdentifier();
} else if (representation->ContextOfItems()->hasContextType()) {
context_string = representation->ContextOfItems()->ContextType();
if (representation->RepresentationIdentifier()) {
context_string = *representation->RepresentationIdentifier();
} else if (representation->ContextOfItems()->ContextType()) {
context_string = *representation->ContextOfItems()->ContextType();
}
const std::string product_type = product->declaration().name();
@@ -2245,11 +2245,11 @@ std::pair<std::string, double> IfcGeom::Kernel::initializeUnits(IfcSchema::IfcUn
bool length_unit_encountered = false, angle_unit_encountered = false;
try {
IfcEntityList::ptr units = unit_assignment->Units();
aggregate_of_instance::ptr units = unit_assignment->Units();
if (!units || !units->size()) {
Logger::Warning("No unit information found");
} else {
for (IfcEntityList::it it = units->begin(); it != units->end(); ++it) {
for (aggregate_of_instance::it it = units->begin(); it != units->end(); ++it) {
IfcUtil::IfcBaseClass* base = *it;
if (base->declaration().is(IfcSchema::IfcNamedUnit::Class())) {
IfcSchema::IfcNamedUnit* named_unit = base->as<IfcSchema::IfcNamedUnit>();
@@ -2264,8 +2264,8 @@ std::pair<std::string, double> IfcGeom::Kernel::initializeUnits(IfcSchema::IfcUn
current_unit_name = u->Name();
} else if (named_unit->declaration().is(IfcSchema::IfcSIUnit::Class())) {
IfcSchema::IfcSIUnit* si_unit = named_unit->as<IfcSchema::IfcSIUnit>();
if (si_unit->hasPrefix()) {
current_unit_name = IfcSchema::IfcSIPrefix::ToString(si_unit->Prefix()) + unit_name;
if (si_unit->Prefix()) {
current_unit_name = IfcSchema::IfcSIPrefix::ToString(*si_unit->Prefix()) + unit_name;
}
current_unit_name += IfcSchema::IfcSIUnitName::ToString(si_unit->Name());
}
@@ -3255,11 +3255,11 @@ bool IfcGeom::Kernel::apply_layerset(const IfcRepresentationShapeItems& items, c
}
IfcSchema::IfcRepresentation* IfcGeom::Kernel::find_representation(const IfcSchema::IfcProduct* product, const std::string& identifier) {
if (!product->hasRepresentation()) return 0;
if (!product->Representation()) return 0;
IfcSchema::IfcProductRepresentation* prod_rep = product->Representation();
IfcSchema::IfcRepresentation::list::ptr reps = prod_rep->Representations();
for (IfcSchema::IfcRepresentation::list::it it = reps->begin(); it != reps->end(); ++it) {
if ((**it).hasRepresentationIdentifier() && (**it).RepresentationIdentifier() == identifier) {
if ((**it).RepresentationIdentifier() && (*(**it).RepresentationIdentifier()) == identifier) {
return *it;
}
}
@@ -3824,7 +3824,7 @@ namespace {
bounded_int& operator--() {
--i;
if (i == -1) {
i = n - 1;
i = (int) n - 1;
}
return *this;
}
@@ -4310,8 +4310,8 @@ bool IfcGeom::Kernel::boolean_operation(const TopoDS_Shape& a_, const TopTools_L
if (op == BOPAlgo_CUT) {
TopTools_IndexedMapOfShape edges;
TopTools_IndexedDataMapOfShapeListOfShape map;
for (TopTools_ListIteratorOfListOfShape it(B); it.More(); it.Next()) {
auto& bb = it.Value();
for (TopTools_ListIteratorOfListOfShape it2(B); it2.More(); it2.Next()) {
auto& bb = it2.Value();
TopExp::MapShapes(bb, TopAbs_EDGE, edges);
TopExp::MapShapesAndAncestors(bb, TopAbs_EDGE, TopAbs_FACE, map);
}
@@ -4321,10 +4321,10 @@ bool IfcGeom::Kernel::boolean_operation(const TopoDS_Shape& a_, const TopTools_L
}
for (int i = 1; i <= edges.Extent(); ++i) {
const TopoDS_Edge& ei = TopoDS::Edge(edges.FindKey(i));
Bnd_Box b;
BRepBndLib::Add(ei, b);
b.Enlarge(fuzziness);
auto ii = tree.select_box(b, false);
Bnd_Box bb;
BRepBndLib::Add(ei, bb);
bb.Enlarge(fuzziness);
auto ii = tree.select_box(bb, false);
for (int j : ii) {
if (j != i) {
const TopoDS_Edge& ej = TopoDS::Edge(edges.FindKey(j));
@@ -4337,8 +4337,8 @@ bool IfcGeom::Kernel::boolean_operation(const TopoDS_Shape& a_, const TopTools_L
auto faces_i = map.FindFromKey(edges.FindKey(i));
auto faces_j = map.FindFromKey(edges.FindKey(j));
bool overlap = false;
for (TopTools_ListIteratorOfListOfShape it(faces_i); it.More(); it.Next()) {
auto& fi = it.Value();
for (TopTools_ListIteratorOfListOfShape it4(faces_i); it4.More(); it4.Next()) {
auto& fi = it4.Value();
for (TopTools_ListIteratorOfListOfShape it2(faces_j); it2.More(); it2.Next()) {
auto& fj = it2.Value();
if (faces_overlap(TopoDS::Face(fi), TopoDS::Face(fj))) {
@@ -4650,7 +4650,7 @@ namespace {
return &p;
}
const std::vector<std::vector<double>>* store_cache(const std::vector<const IfcSchema::IfcCartesianPoint*>& p) {
const std::vector<std::vector<double>>* store_cache(const std::vector<const IfcSchema::IfcCartesianPoint*>& /*p*/) {
return nullptr;
}
}
@@ -4669,8 +4669,6 @@ IfcGeom::Kernel::faceset_helper<CP, LP>::faceset_helper(
std::vector<std::unique_ptr<gp_Pnt>> pnts(std::distance(points.begin(), points.end()));
std::vector<TopoDS_Vertex> vertices(pnts.size());
auto LU = kernel_->getValue(GV_LENGTH_UNIT);
IfcGeom::impl::tree<int> tree;
BRep_Builder B;
@@ -4681,7 +4679,7 @@ IfcGeom::Kernel::faceset_helper<CP, LP>::faceset_helper(
if (construct(points[i], p)) {
pnts[i].reset(p);
B.MakeVertex(vertices[i], *p, Precision::Confusion());
tree.add(i, vertices[i]);
tree.add((int) i, vertices[i]);
box.Add(*p);
} else {
delete p;
+29 -26
View File
@@ -176,8 +176,8 @@ bool IfcGeom::Kernel::convert(const IfcSchema::IfcAxis2Placement3D* l, gp_Trsf&
}
IfcGeom::Kernel::convert((const IfcSchema::IfcCartesianPoint*) l->Location(), o);
const bool hasAxis = l->hasAxis();
const bool hasRef = l->hasRefDirection();
const bool hasAxis = !!l->Axis();
const bool hasRef = !!l->RefDirection();
if (hasAxis != hasRef) {
Logger::Warning("Axis and RefDirection should be specified together", l);
@@ -221,7 +221,7 @@ bool IfcGeom::Kernel::convert(const IfcSchema::IfcAxis1Placement* l, gp_Ax1& ax)
}
IfcGeom::Kernel::convert((const IfcSchema::IfcCartesianPoint*) l->Location(),o);
if ( l->hasAxis() ) IfcGeom::Kernel::convert(l->Axis(), axis);
if ( l->Axis() ) IfcGeom::Kernel::convert(l->Axis(), axis);
ax = gp_Ax1(o, axis);
CACHE(IfcAxis1Placement,l,ax)
return true;
@@ -234,9 +234,9 @@ bool IfcGeom::Kernel::convert(const IfcSchema::IfcCartesianTransformationOperato
gp_Dir axis1 (1.,0.,0.);
gp_Dir axis2 (0.,1.,0.);
gp_Dir axis3 (0.,0.,1.);
if ( l->hasAxis1() ) IfcGeom::Kernel::convert(l->Axis1(),axis1);
if ( l->hasAxis2() ) IfcGeom::Kernel::convert(l->Axis2(),axis2);
if ( l->hasAxis3() ) IfcGeom::Kernel::convert(l->Axis3(),axis3);
if ( l->Axis1() ) IfcGeom::Kernel::convert(l->Axis1(),axis1);
if ( l->Axis2() ) IfcGeom::Kernel::convert(l->Axis2(),axis2);
if ( l->Axis3() ) IfcGeom::Kernel::convert(l->Axis3(),axis3);
gp_Ax3 ax3 (origin,axis3,axis1);
if ( axis2.Dot(ax3.YDirection()) < 0 ) ax3.YReverse();
@@ -245,8 +245,8 @@ bool IfcGeom::Kernel::convert(const IfcSchema::IfcCartesianTransformationOperato
trsf.Invert();
}
if (l->hasScale() && !ALMOST_THE_SAME(l->Scale(), 1.)) {
trsf.SetScaleFactor(l->Scale());
if (l->Scale() && !ALMOST_THE_SAME(*l->Scale(), 1.)) {
trsf.SetScaleFactor(*l->Scale());
}
CACHE(IfcCartesianTransformationOperator3D,l,trsf)
@@ -261,8 +261,8 @@ bool IfcGeom::Kernel::convert(const IfcSchema::IfcCartesianTransformationOperato
gp_Dir axis2 (0.,1.,0.);
IfcGeom::Kernel::convert(l->LocalOrigin(),origin);
if ( l->hasAxis1() ) IfcGeom::Kernel::convert(l->Axis1(),axis1);
if ( l->hasAxis2() ) IfcGeom::Kernel::convert(l->Axis2(),axis2);
if ( l->Axis1() ) IfcGeom::Kernel::convert(l->Axis1(),axis1);
if ( l->Axis2() ) IfcGeom::Kernel::convert(l->Axis2(),axis2);
const gp_Pnt2d origin2d(origin.X(), origin.Y());
const gp_Dir2d axis12d(axis1.X(), axis1.Y());
@@ -282,7 +282,9 @@ bool IfcGeom::Kernel::convert(const IfcSchema::IfcCartesianTransformationOperato
}
trsf.Invert();
if ( l->hasScale() && !ALMOST_THE_SAME(l->Scale(), 1.) ) trsf.SetScaleFactor(l->Scale());
if (l->Scale() && !ALMOST_THE_SAME(*l->Scale(), 1.)) {
trsf.SetScaleFactor(*l->Scale());
}
if (is_identity(trsf, getValue(GV_PRECISION))) {
trsf = gp_Trsf2d();
@@ -300,16 +302,16 @@ bool IfcGeom::Kernel::convert(const IfcSchema::IfcCartesianTransformationOperato
gp_Dir axis1 (1.,0.,0.);
gp_Dir axis2 (0.,1.,0.);
gp_Dir axis3 (0.,0.,1.);
if ( l->hasAxis1() ) IfcGeom::Kernel::convert(l->Axis1(),axis1);
if ( l->hasAxis2() ) IfcGeom::Kernel::convert(l->Axis2(),axis2);
if ( l->hasAxis3() ) IfcGeom::Kernel::convert(l->Axis3(),axis3);
if ( l->Axis1() ) IfcGeom::Kernel::convert(l->Axis1(),axis1);
if ( l->Axis2() ) IfcGeom::Kernel::convert(l->Axis2(),axis2);
if ( l->Axis3() ) IfcGeom::Kernel::convert(l->Axis3(),axis3);
gp_Ax3 ax3 (origin,axis3,axis1);
if ( axis2.Dot(ax3.YDirection()) < 0 ) ax3.YReverse();
trsf.SetTransformation(ax3);
trsf.Invert();
const double scale1 = l->hasScale() ? l->Scale() : 1.0f;
const double scale2 = l->hasScale2() ? l->Scale2() : scale1;
const double scale3 = l->hasScale3() ? l->Scale3() : scale1;
const double scale1 = l->Scale().get_value_or(1.);
const double scale2 = l->Scale2().get_value_or(scale1);
const double scale3 = l->Scale3().get_value_or(scale1);
gtrsf = gp_GTrsf();
gtrsf.SetValue(1,1,scale1);
gtrsf.SetValue(2,2,scale2);
@@ -333,8 +335,8 @@ bool IfcGeom::Kernel::convert(const IfcSchema::IfcCartesianTransformationOperato
gp_Dir axis2 (0.,1.,0.);
IfcGeom::Kernel::convert(l->LocalOrigin(),origin);
if ( l->hasAxis1() ) IfcGeom::Kernel::convert(l->Axis1(),axis1);
if ( l->hasAxis2() ) IfcGeom::Kernel::convert(l->Axis2(),axis2);
if ( l->Axis1() ) IfcGeom::Kernel::convert(l->Axis1(),axis1);
if ( l->Axis2() ) IfcGeom::Kernel::convert(l->Axis2(),axis2);
const gp_Pnt2d origin2d(origin.X(), origin.Y());
const gp_Dir2d axis12d(axis1.X(), axis1.Y());
@@ -350,8 +352,8 @@ bool IfcGeom::Kernel::convert(const IfcSchema::IfcCartesianTransformationOperato
trsf.Invert();
const double scale1 = l->hasScale() ? l->Scale() : 1.0f;
const double scale2 = l->hasScale2() ? l->Scale2() : scale1;
const double scale1 = l->Scale().get_value_or(1.);
const double scale2 = l->Scale2().get_value_or(scale1);
gtrsf = gp_GTrsf2d();
gtrsf.SetValue(1,1,scale1);
gtrsf.SetValue(2,2,scale2);
@@ -377,8 +379,8 @@ bool IfcGeom::Kernel::convert(const IfcSchema::IfcPlane* pln, gp_Pln& plane) {
}
IfcGeom::Kernel::convert((const IfcSchema::IfcCartesianPoint*) l->Location(),o);
bool hasRef = l->hasRefDirection();
if ( l->hasAxis() ) IfcGeom::Kernel::convert(l->Axis(),axis);
bool hasRef = !!l->RefDirection();
if ( l->Axis() ) IfcGeom::Kernel::convert(l->Axis(),axis);
if ( hasRef ) IfcGeom::Kernel::convert(l->RefDirection(),refDirection);
gp_Ax3 ax3;
if ( hasRef ) ax3 = gp_Ax3(o,axis,refDirection);
@@ -399,8 +401,9 @@ bool IfcGeom::Kernel::convert(const IfcSchema::IfcAxis2Placement2D* l, gp_Trsf2d
}
IfcGeom::Kernel::convert((const IfcSchema::IfcCartesianPoint*) l->Location(),P);
if ( l->hasRefDirection() )
IfcGeom::Kernel::convert(l->RefDirection(),V);
if (l->RefDirection()) {
IfcGeom::Kernel::convert(l->RefDirection(), V);
}
gp_Ax2d axis(gp_Pnt2d(P.X(),P.Y()), gp_Dir2d(V.X(),V.Y()));
@@ -430,7 +433,7 @@ bool IfcGeom::Kernel::convert(const IfcSchema::IfcObjectPlacement* l, gp_Trsf& t
IfcGeom::Kernel::convert((IfcSchema::IfcAxis2Placement3D*)relplacement,trsf2);
trsf.PreMultiply(trsf2);
}
if ( current->hasPlacementRelTo() ) {
if ( current->PlacementRelTo() ) {
IfcSchema::IfcObjectPlacement* parent = current->PlacementRelTo();
IfcSchema::IfcProduct::list::ptr parentPlaces = parent->PlacesObject();
bool parentPlacesType = false;
+7 -7
View File
@@ -294,12 +294,12 @@ namespace IfcGeom {
continue;
}
try {
if (context->hasContextType()) {
std::string context_type = context->ContextType();
if (context->ContextType()) {
std::string context_type = *context->ContextType();
boost::to_lower(context_type);
if (allowed_context_types.find(context_type) == allowed_context_types.end()) {
Logger::Warning(std::string("ContextType '") + context->ContextType() + "' not allowed:", context);
Logger::Warning(std::string("ContextType '") + *context->ContextType() + "' not allowed:", context);
}
if (context_types.find(context_type) != context_types.end()) {
filtered_contexts->push(context);
@@ -326,8 +326,8 @@ namespace IfcGeom {
representations->push(context->RepresentationsInContext());
try {
if (context->hasPrecision() && context->Precision() < lowest_precision_encountered) {
lowest_precision_encountered = context->Precision();
if (context->Precision() && *context->Precision() < lowest_precision_encountered) {
lowest_precision_encountered = *context->Precision();
any_precision_encountered = true;
}
} catch (const std::exception& e) {
@@ -522,7 +522,7 @@ namespace IfcGeom {
IfcSchema::IfcProduct::list::ptr products = ifc_file->instances_by_type<IfcSchema::IfcProduct>();
for (IfcSchema::IfcProduct::list::it iter = products->begin(); iter != products->end(); ++iter) {
IfcSchema::IfcProduct* product = *iter;
if (product->hasObjectPlacement()) {
if (product->ObjectPlacement()) {
// Use a fresh trsf every time in order to prevent the result to be concatenated
gp_Trsf trsf;
bool success = false;
@@ -890,7 +890,7 @@ namespace IfcGeom {
if (ifc_entity->declaration().is(IfcSchema::IfcRoot::Class())) {
IfcSchema::IfcRoot* ifc_root = ifc_entity->as<IfcSchema::IfcRoot>();
product_guid = ifc_root->GlobalId();
product_name = ifc_root->hasName() ? ifc_root->Name() : "";
product_name = ifc_root->Name().get_value_or("");
}
if (ifc_entity->declaration().is(IfcSchema::IfcProduct::Class())) {
+10 -10
View File
@@ -70,8 +70,8 @@ const IfcGeom::SurfaceStyle* IfcGeom::Kernel::internalize_surface_style(const st
IfcSchema::IfcSurfaceStyle* style = shading_styles.first->as<IfcSchema::IfcSurfaceStyle>();
IfcSchema::IfcSurfaceStyleShading* shading = shading_styles.second->as<IfcSchema::IfcSurfaceStyleShading>();
if (style->hasName()) {
surface_style = SurfaceStyle(surface_style_id, style->Name());
if (style->Name()) {
surface_style = SurfaceStyle(surface_style_id, *style->Name());
} else {
surface_style = SurfaceStyle(surface_style_id);
}
@@ -81,20 +81,20 @@ const IfcGeom::SurfaceStyle* IfcGeom::Kernel::internalize_surface_style(const st
}
if (shading_styles.second->declaration().is(IfcSchema::IfcSurfaceStyleRendering::Class())) {
IfcSchema::IfcSurfaceStyleRendering* rendering_style = static_cast<IfcSchema::IfcSurfaceStyleRendering*>(shading_styles.second);
if (rendering_style->hasDiffuseColour() && process_colour(rendering_style->DiffuseColour(), rgb)) {
if (rendering_style->DiffuseColour() && process_colour(rendering_style->DiffuseColour(), rgb)) {
SurfaceStyle::ColorComponent diffuse = surface_style.Diffuse().get_value_or(SurfaceStyle::ColorComponent(1,1,1));
surface_style.Diffuse().reset(SurfaceStyle::ColorComponent(diffuse.R() * rgb[0], diffuse.G() * rgb[1], diffuse.B() * rgb[2]));
}
if (rendering_style->hasDiffuseTransmissionColour()) {
if (rendering_style->DiffuseTransmissionColour()) {
// Not supported
}
if (rendering_style->hasReflectionColour()) {
if (rendering_style->ReflectionColour()) {
// Not supported
}
if (rendering_style->hasSpecularColour() && process_colour(rendering_style->SpecularColour(), rgb)) {
if (rendering_style->SpecularColour() && process_colour(rendering_style->SpecularColour(), rgb)) {
surface_style.Specular().reset(SurfaceStyle::ColorComponent(rgb[0], rgb[1], rgb[2]));
}
if (rendering_style->hasSpecularHighlight()) {
if (rendering_style->SpecularHighlight()) {
IfcSchema::IfcSpecularHighlightSelect* highlight = rendering_style->SpecularHighlight();
if (highlight->declaration().is(IfcSchema::IfcSpecularRoughness::Class())) {
double roughness = *((IfcSchema::IfcSpecularRoughness*)highlight);
@@ -105,11 +105,11 @@ const IfcGeom::SurfaceStyle* IfcGeom::Kernel::internalize_surface_style(const st
surface_style.Specularity().reset(*((IfcSchema::IfcSpecularExponent*)highlight));
}
}
if (rendering_style->hasTransmissionColour()) {
if (rendering_style->TransmissionColour()) {
// Not supported
}
if (rendering_style->hasTransparency()) {
const double d = rendering_style->Transparency();
if (rendering_style->Transparency()) {
const double d = *rendering_style->Transparency();
surface_style.Transparency().reset(d);
}
}
+6 -6
View File
@@ -274,7 +274,7 @@ int convert_to_ifc(const Handle_Geom_Surface& s, IfcSchema::IfcSurface*& surface
surface = new IfcSchema::IfcCylindricalSurface(place, cyl->Radius());
return 1;
} else if (s->DynamicType() == STANDARD_TYPE(Geom_BSplineSurface)) {
typedef IfcTemplatedEntityListList<IfcSchema::IfcCartesianPoint> points_t;
typedef aggregate_of_aggregate_of<IfcSchema::IfcCartesianPoint> points_t;
Handle_Geom_BSplineSurface bspline = Handle_Geom_BSplineSurface::DownCast(s);
points_t::ptr points(new points_t);
@@ -384,8 +384,8 @@ int convert_to_ifc(const TopoDS_Edge& e, IfcSchema::IfcCurve*& c, bool advanced)
return 0;
}
IfcEntityList::ptr trim1(new IfcEntityList);
IfcEntityList::ptr trim2(new IfcEntityList);
aggregate_of_instance::ptr trim1(new aggregate_of_instance);
aggregate_of_instance::ptr trim2(new aggregate_of_instance);
trim1->push(new IfcSchema::IfcParameterValue(a));
trim2->push(new IfcSchema::IfcParameterValue(b));
@@ -552,8 +552,8 @@ int convert_to_ifc(const TopoDS_Shape& s, U*& item, bool advanced) {
} else {
/// Cleanup:
for (IfcSchema::IfcFace::list::it it = faces->begin(); it != faces->end(); ++it) {
IfcEntityList::ptr data = IfcParse::traverse(*it)->unique();
for (IfcEntityList::it jt = data->begin(); jt != data->end(); ++jt) {
aggregate_of_instance::ptr data = IfcParse::traverse(*it)->unique();
for (aggregate_of_instance::it jt = data->begin(); jt != data->end(); ++jt) {
delete *jt;
}
}
@@ -647,7 +647,7 @@ IfcUtil::IfcBaseClass* IfcGeom::MAKE_TYPE_NAME(serialise_)(const TopoDS_Shape& s
// they are not commonly top-level geometrical descriptions in IFC.
// Also note that edges are written as trimmed curves rather than edges.
IfcEntityList::ptr edges(new IfcEntityList);
aggregate_of_instance::ptr edges(new aggregate_of_instance);
for (TopExp_Explorer exp(shape, TopAbs_EDGE); exp.More(); exp.Next()) {
IfcSchema::IfcCurve* c;
+6 -6
View File
@@ -526,9 +526,9 @@ bool IfcGeom::Kernel::convert(const IfcSchema::IfcPolygonalBoundedHalfSpace* l,
}
bool IfcGeom::Kernel::convert(const IfcSchema::IfcShellBasedSurfaceModel* l, IfcRepresentationShapeItems& shapes) {
IfcEntityList::ptr shells = l->SbsmBoundary();
aggregate_of_instance::ptr shells = l->SbsmBoundary();
const SurfaceStyle* collective_style = get_style(l);
for( IfcEntityList::it it = shells->begin(); it != shells->end(); ++ it ) {
for( aggregate_of_instance::it it = shells->begin(); it != shells->end(); ++ it ) {
TopoDS_Shape s;
const SurfaceStyle* shell_style = 0;
if ((*it)->declaration().is(IfcSchema::IfcRepresentationItem::Class())) {
@@ -890,11 +890,11 @@ bool IfcGeom::Kernel::convert(const IfcSchema::IfcGeometricSet* l, IfcRepresenta
const bool include_curves = getValue(GV_DIMENSIONALITY) != +1;
const bool include_solids_and_surfaces = getValue(GV_DIMENSIONALITY) != -1;
IfcEntityList::ptr elements = l->Elements();
aggregate_of_instance::ptr elements = l->Elements();
if ( !elements->size() ) return false;
bool part_succes = false;
const IfcGeom::SurfaceStyle* parent_style = get_style(l);
for (IfcEntityList::it it = elements->begin(); it != elements->end(); ++it) {
for (aggregate_of_instance::it it = elements->begin(); it != elements->end(); ++it) {
IfcSchema::IfcGeometricSetSelect* element = *it;
TopoDS_Shape s;
if (shape_type(element) == ST_SHAPELIST) {
@@ -1526,7 +1526,7 @@ namespace {
bool IfcGeom::Kernel::convert(const IfcSchema::IfcSweptDiskSolid* l, TopoDS_Shape& shape) {
TopoDS_Wire wire, section1, section2;
bool hasInnerRadius = l->hasInnerRadius();
bool hasInnerRadius = !!l->InnerRadius();
if (!convert_wire(l->Directrix(), wire)) {
return false;
@@ -1569,7 +1569,7 @@ bool IfcGeom::Kernel::convert(const IfcSchema::IfcSweptDiskSolid* l, TopoDS_Shap
if (hasInnerRadius) {
// Subtraction of pipes with small radii is unstable.
r2 = l->InnerRadius() * getValue(GV_LENGTH_UNIT);
r2 = *l->InnerRadius() * getValue(GV_LENGTH_UNIT);
}
if (r2 > getValue(GV_PRECISION) * 10.) {
+7 -7
View File
@@ -436,7 +436,7 @@ bool IfcGeom::Kernel::convert(const IfcSchema::IfcCompositeCurve* l, TopoDS_Wire
TopTools_ListIteratorOfListOfShape it(converted_segments);
IfcEntityList::ptr profile = l->data().getInverse(&IfcSchema::IfcProfileDef::Class(), -1);
aggregate_of_instance::ptr profile = l->data().getInverse(&IfcSchema::IfcProfileDef::Class(), -1);
const bool force_close = profile && profile->size() > 0;
wire_builder bld(getValue(GV_PRECISION), l);
@@ -494,8 +494,8 @@ bool IfcGeom::Kernel::convert(const IfcSchema::IfcTrimmedCurve* l, TopoDS_Wire&
}
bool trim_cartesian = l->MasterRepresentation() != IfcSchema::IfcTrimmingPreference::IfcTrimmingPreference_PARAMETER;
IfcEntityList::ptr trims1 = l->Trim1();
IfcEntityList::ptr trims2 = l->Trim2();
aggregate_of_instance::ptr trims1 = l->Trim1();
aggregate_of_instance::ptr trims2 = l->Trim2();
unsigned sense_agreement = l->SenseAgreement() ? 0 : 1;
double flts[2];
@@ -505,7 +505,7 @@ bool IfcGeom::Kernel::convert(const IfcSchema::IfcTrimmedCurve* l, TopoDS_Wire&
TopoDS_Edge e;
for ( IfcEntityList::it it = trims1->begin(); it != trims1->end(); it ++ ) {
for ( aggregate_of_instance::it it = trims1->begin(); it != trims1->end(); it ++ ) {
IfcUtil::IfcBaseClass* i = *it;
if ( i->declaration().is(IfcSchema::IfcCartesianPoint::Class()) ) {
IfcGeom::Kernel::convert((IfcSchema::IfcCartesianPoint*)i, pnts[sense_agreement] );
@@ -517,7 +517,7 @@ bool IfcGeom::Kernel::convert(const IfcSchema::IfcTrimmedCurve* l, TopoDS_Wire&
}
}
for ( IfcEntityList::it it = trims2->begin(); it != trims2->end(); it ++ ) {
for ( aggregate_of_instance::it it = trims2->begin(); it != trims2->end(); it ++ ) {
IfcUtil::IfcBaseClass* i = *it;
if ( i->declaration().is(IfcSchema::IfcCartesianPoint::Class()) ) {
IfcGeom::Kernel::convert((IfcSchema::IfcCartesianPoint*)i, pnts[1-sense_agreement] );
@@ -1004,8 +1004,8 @@ bool IfcGeom::Kernel::convert(const IfcSchema::IfcIndexedPolyCurve* l, TopoDS_Wi
BRepBuilderAPI_MakeWire w;
if(l->hasSegments()) {
IfcEntityList::ptr segments = l->Segments();
for (IfcEntityList::it it = segments->begin(); it != segments->end(); ++it) {
aggregate_of_instance::ptr segments = l->Segments();
for (aggregate_of_instance::it it = segments->begin(); it != segments->end(); ++it) {
IfcUtil::IfcBaseClass* segment = *it;
if (segment->declaration().is(IfcSchema::IfcLineIndex::Class())) {
IfcSchema::IfcLineIndex* line = (IfcSchema::IfcLineIndex*) segment;
+4 -4
View File
@@ -140,9 +140,9 @@ IfcSchema::IfcObjectDefinition* get_decomposing_entity_impl(IfcSchema::IfcProduc
\
/* Parent decompositions to the RelatingObject */ \
if (!parent) { \
IfcEntityList::ptr parents = product->data().getInverse((&IfcSchema::IfcRelAggregates::Class()), -1); \
aggregate_of_instance::ptr parents = product->data().getInverse((&IfcSchema::IfcRelAggregates::Class()), -1); \
parents->push(product->data().getInverse((&IfcSchema::IfcRelNests::Class()), -1)); \
for (IfcEntityList::it it = parents->begin(); it != parents->end(); ++it) { \
for (aggregate_of_instance::it it = parents->begin(); it != parents->end(); ++it) { \
IfcSchema::IfcRelDecomposes* decompose = (IfcSchema::IfcRelDecomposes*)*it; \
IfcUtil::IfcBaseEntity* ifc_objectdef; \
\
@@ -263,8 +263,8 @@ namespace {
template <typename Schema>
static std::map<std::string, IfcUtil::IfcBaseEntity*> get_layers_impl(typename Schema::IfcProduct* prod) {
std::map<std::string, IfcUtil::IfcBaseEntity*> layers;
if (prod->hasRepresentation()) {
IfcEntityList::ptr r = IfcParse::traverse(prod->Representation());
if (prod->Representation()) {
aggregate_of_instance::ptr r = IfcParse::traverse(prod->Representation());
typename Schema::IfcRepresentation::list::ptr representations = r->as<typename Schema::IfcRepresentation>();
for (typename Schema::IfcRepresentation::list::it it = representations->begin(); it != representations->end(); ++it) {
typename Schema::IfcPresentationLayerAssignment::list::ptr a = (*it)->LayerAssignments();
+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;
+5 -5
View File
@@ -454,7 +454,7 @@ namespace {
if (!pset->get("Name")->isNull()) {
pset_name = (std::string) *pset->get("Name");
}
IfcEntityList::ptr props = *pset->get("HasProperties");
aggregate_of_instance::ptr props = *pset->get("HasProperties");
for (auto& prop : *props) {
if (prop->declaration().is("IfcPropertySingleValue")) {
std::string name = *((IfcUtil::IfcBaseEntity*) prop)->get("Name");
@@ -476,12 +476,12 @@ namespace {
auto refs = item->get_inverse("StyledByItem");
for (auto& ref : *refs) {
if (ref->declaration().is("IfcStyledItem")) {
IfcEntityList::ptr styles = *((IfcUtil::IfcBaseEntity*)ref)->get("Styles");
aggregate_of_instance::ptr styles = *((IfcUtil::IfcBaseEntity*)ref)->get("Styles");
for (auto& s_ : *styles) {
auto s = (IfcUtil::IfcBaseEntity*) s_;
std::vector<IfcUtil::IfcBaseEntity*> pss;
if (s->declaration().is("IfcPresentationStyleAssignment")) {
IfcEntityList::ptr pstyles = *s->get("Styles");
aggregate_of_instance::ptr pstyles = *s->get("Styles");
for (auto& ssss : *pstyles) {
pss.push_back((IfcUtil::IfcBaseEntity*) ssss);
}
@@ -748,7 +748,7 @@ void SvgSerializer::write(const geometry_data& data) {
boost::optional<std::string> operation_type;
try {
IfcEntityList::ptr rels;
aggregate_of_instance::ptr rels;
if (data.product->declaration().schema()->name() == "IFC2X3") {
rels = data.product->get_inverse("IsDefinedBy");
} else {
@@ -2107,7 +2107,7 @@ void SvgSerializer::setFile(IfcParse::IfcFile* f) {
to_derive_from.push_back(f->schema()->declaration_by_name("IfcBuilding"));
to_derive_from.push_back(f->schema()->declaration_by_name("IfcSite"));
for (auto it = to_derive_from.begin(); it != to_derive_from.end(); ++it) {
IfcEntityList::ptr insts = f->instances_by_type(*it);
aggregate_of_instance::ptr insts = f->instances_by_type(*it);
if (insts) {
for (auto jt = insts->begin(); jt != insts->end(); ++jt) {
IfcUtil::IfcBaseEntity* product = (IfcUtil::IfcBaseEntity*) *jt;
@@ -115,8 +115,8 @@ boost::optional<std::string> format_attribute(const Argument* argument, IfcUtil:
if (e->declaration().is(IfcSchema::IfcSIUnit::Class())) {
IfcSchema::IfcSIUnit* unit = (IfcSchema::IfcSIUnit*) e;
unit_name = IfcSchema::IfcSIUnitName::ToString(unit->Name());
if (unit->hasPrefix()) {
unit_name = IfcSchema::IfcSIPrefix::ToString(unit->Prefix()) + unit_name;
if (unit->Prefix()) {
unit_name = IfcSchema::IfcSIPrefix::ToString(*unit->Prefix()) + unit_name;
}
} else {
IfcSchema::IfcConversionBasedUnit* unit = (IfcSchema::IfcConversionBasedUnit*) e;
@@ -482,8 +482,8 @@ void MAKE_TYPE_NAME(XmlSerializer)::finalize() {
IfcSchema::IfcTypeObject* type_object = *it;
ptree* node = descend(type_object, types);
if (node && type_object->hasHasPropertySets()) {
IfcSchema::IfcPropertySetDefinition::list::ptr property_sets = type_object->HasPropertySets();
if (node && type_object->HasPropertySets()) {
IfcSchema::IfcPropertySetDefinition::list::ptr property_sets = *type_object->HasPropertySets();
for (IfcSchema::IfcPropertySetDefinition::list::it jt = property_sets->begin(); jt != property_sets->end(); ++jt) {
IfcSchema::IfcPropertySetDefinition* pset = *jt;
if (pset->declaration().is(IfcSchema::IfcPropertySet::Class())) {
@@ -494,8 +494,8 @@ void MAKE_TYPE_NAME(XmlSerializer)::finalize() {
}
// Write all assigned units as XML nodes.
IfcEntityList::ptr unit_assignments = project->UnitsInContext()->Units();
for (IfcEntityList::it it = unit_assignments->begin(); it != unit_assignments->end(); ++it) {
aggregate_of_instance::ptr unit_assignments = project->UnitsInContext()->Units();
for (aggregate_of_instance::it it = unit_assignments->begin(); it != unit_assignments->end(); ++it) {
if ((*it)->declaration().is(IfcSchema::IfcNamedUnit::Class())) {
IfcSchema::IfcNamedUnit* named_unit = (*it)->as<IfcSchema::IfcNamedUnit>();
ptree* node = format_entity_instance(named_unit, units);
@@ -535,13 +535,13 @@ void MAKE_TYPE_NAME(XmlSerializer)::finalize() {
if (!layerset) {
layerset = mat->as<IfcSchema::IfcMaterialLayerSetUsage>()->ForLayerSet();
}
if (layerset->hasLayerSetName()) {
node.put("<xmlattr>.LayerSetName", layerset->LayerSetName());
if (layerset->LayerSetName()) {
node.put("<xmlattr>.LayerSetName", *layerset->LayerSetName());
}
IfcSchema::IfcMaterialLayer::list::ptr ls = layerset->MaterialLayers();
for (IfcSchema::IfcMaterialLayer::list::it jt = ls->begin(); jt != ls->end(); ++jt) {
ptree subnode;
if ((*jt)->hasMaterial()) {
if ((*jt)->Material()) {
subnode.put("<xmlattr>.Name", (*jt)->Material()->Name());
}
format_entity_instance(*jt, subnode, node);