mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-29 00:03:17 +00:00
Site local placement (#240)
* ifcgeom: Add placement_rel_to for convert() Change geometry conversion in `convert()` for `ObjectPlacement` such that we can stop the `PlacementRelTo()` recursion when we hit an `ObjectPlacement` that places a certain type, e.g. a `IfcSite'. Introduce a new IteratorSetting `SITE_LOCAL_PLACEMENT` which will be exposed in `IfcConvert`. * IfcConvert: Add --site-local-placement Some IFC authoring tools may put the global origo at a large distance away from the actual building geometry. Also, the global X- and Y-axes may be at arbitrary angles with natural building axes. Using --center-model or --model-offset may place the converted geometry closer to origo, but will still use the global IFC definition of axis directions. Also, in a scenario with multiple IFC files for one construction site, using --center-model on each of them would not generate consistent geometry across OBJ or DAE files. Solve this by introducing --site-local-placement which will disregard the ObjectPlacement at the IfcSite level.
This commit is contained in:
committed by
Thomas Krijnen
parent
7bea054c1e
commit
475b8554a8
@@ -99,6 +99,10 @@ private:
|
||||
std::map<int, SurfaceStyle> style_cache;
|
||||
|
||||
const SurfaceStyle* internalize_surface_style(const std::pair<IfcSchema::IfcSurfaceStyle*, IfcSchema::IfcSurfaceStyleShading*>& shading_style);
|
||||
|
||||
// For stopping PlacementRelTo recursion in convert(const IfcSchema::IfcObjectPlacement* l, gp_Trsf& trsf)
|
||||
IfcSchema::Type::Enum placement_rel_to;
|
||||
|
||||
public:
|
||||
Kernel()
|
||||
: deflection_tolerance(0.001)
|
||||
@@ -109,6 +113,7 @@ public:
|
||||
, ifc_planeangle_unit(-1.0)
|
||||
, modelling_precision(0.00001)
|
||||
, dimensionality(1.)
|
||||
, placement_rel_to(IfcSchema::Type::UNDEFINED)
|
||||
{}
|
||||
|
||||
Kernel(const Kernel& other) {
|
||||
@@ -313,6 +318,8 @@ public:
|
||||
#endif
|
||||
}
|
||||
|
||||
void set_conversion_placement_rel_to(IfcSchema::Type::Enum type);
|
||||
|
||||
#include "IfcRegisterGeomHeader.h"
|
||||
|
||||
};
|
||||
|
||||
@@ -357,6 +357,10 @@ bool IfcGeom::Kernel::convert(const IfcSchema::IfcAxis2Placement2D* l, gp_Trsf2d
|
||||
return true;
|
||||
}
|
||||
|
||||
void IfcGeom::Kernel::set_conversion_placement_rel_to(IfcSchema::Type::Enum type) {
|
||||
placement_rel_to = type;
|
||||
}
|
||||
|
||||
bool IfcGeom::Kernel::convert(const IfcSchema::IfcObjectPlacement* l, gp_Trsf& trsf) {
|
||||
IN_CACHE(IfcObjectPlacement,l,gp_Trsf,trsf)
|
||||
if ( ! l->is(IfcSchema::Type::IfcLocalPlacement) ) {
|
||||
@@ -372,12 +376,20 @@ bool IfcGeom::Kernel::convert(const IfcSchema::IfcObjectPlacement* l, gp_Trsf& t
|
||||
trsf.PreMultiply(trsf2);
|
||||
}
|
||||
if ( current->hasPlacementRelTo() ) {
|
||||
IfcSchema::IfcObjectPlacement* relto = current->PlacementRelTo();
|
||||
if ( relto->is(IfcSchema::Type::IfcLocalPlacement) )
|
||||
IfcSchema::IfcObjectPlacement* parent = current->PlacementRelTo();
|
||||
IfcSchema::IfcProduct::list::ptr parentPlaces = parent->PlacesObject();
|
||||
bool parentPlacesType = false;
|
||||
for ( IfcSchema::IfcProduct::list::it iter = parentPlaces->begin();
|
||||
iter != parentPlaces->end(); ++iter) {
|
||||
if ( (*iter)->is(placement_rel_to) ) parentPlacesType = true;
|
||||
}
|
||||
|
||||
if ( parentPlacesType ) break;
|
||||
else if ( parent->is(IfcSchema::Type::IfcLocalPlacement) )
|
||||
current = (IfcSchema::IfcLocalPlacement*)current->PlacementRelTo();
|
||||
else break;
|
||||
else break;
|
||||
} else break;
|
||||
}
|
||||
CACHE(IfcObjectPlacement,l,trsf)
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -755,6 +755,9 @@ namespace IfcGeom {
|
||||
kernel.setValue(IfcGeom::Kernel::GV_MAX_FACES_TO_SEW, settings.get(IteratorSettings::SEW_SHELLS) ? 1000 : -1);
|
||||
kernel.setValue(IfcGeom::Kernel::GV_DIMENSIONALITY, (settings.get(IteratorSettings::INCLUDE_CURVES)
|
||||
? (settings.get(IteratorSettings::EXCLUDE_SOLIDS_AND_SURFACES) ? -1. : 0.) : +1.));
|
||||
if (settings.get(IteratorSettings::SITE_LOCAL_PLACEMENT)) {
|
||||
kernel.set_conversion_placement_rel_to(IfcSchema::Type::IfcSite);
|
||||
}
|
||||
}
|
||||
|
||||
bool owns_ifc_file;
|
||||
|
||||
@@ -80,8 +80,10 @@ namespace IfcGeom
|
||||
APPLY_LAYERSETS = 1 << 13,
|
||||
/// Search for a parent of type IfcBuildingStorey for each representation
|
||||
SEARCH_FLOOR = 1 << 14,
|
||||
///
|
||||
SITE_LOCAL_PLACEMENT = 1 << 15,
|
||||
/// Number of different setting flags.
|
||||
NUM_SETTINGS = 14
|
||||
NUM_SETTINGS = 15
|
||||
};
|
||||
/// Used to store logical OR combination of setting flags.
|
||||
typedef unsigned SettingField;
|
||||
|
||||
Reference in New Issue
Block a user