mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-25 09:22:28 +00:00
Don't consider openings as children in geom filters
This commit is contained in:
@@ -268,7 +268,7 @@ public:
|
|||||||
|
|
||||||
std::pair<std::string, double> initializeUnits(IfcSchema::IfcUnitAssignment*);
|
std::pair<std::string, double> initializeUnits(IfcSchema::IfcUnitAssignment*);
|
||||||
|
|
||||||
static IfcSchema::IfcObjectDefinition* get_decomposing_entity(IfcSchema::IfcProduct*);
|
static IfcSchema::IfcObjectDefinition* get_decomposing_entity(IfcSchema::IfcProduct*, bool include_openings=true);
|
||||||
|
|
||||||
static std::map<std::string, IfcSchema::IfcPresentationLayerAssignment*> get_layers(IfcSchema::IfcProduct* prod);
|
static std::map<std::string, IfcSchema::IfcPresentationLayerAssignment*> get_layers(IfcSchema::IfcProduct* prod);
|
||||||
|
|
||||||
|
|||||||
@@ -42,13 +42,15 @@ namespace IfcGeom
|
|||||||
|
|
||||||
struct filter
|
struct filter
|
||||||
{
|
{
|
||||||
filter() : include(false), traverse(false) {}
|
filter() : include(false), traverse(false), traverse_openings(false) {}
|
||||||
filter(bool incl, bool trav) : include(incl), traverse(trav) {}
|
filter(bool incl, bool trav, bool trav_openings = false) : include(incl), traverse(trav), traverse_openings(trav_openings) {}
|
||||||
/// Should the product be included (true) or excluded (false).
|
/// Should the product be included (true) or excluded (false).
|
||||||
bool include;
|
bool include;
|
||||||
/// If traversal requested, traverse to the parents to see if they satisfy the criteria. E.g. we might be looking for
|
/// If traversal requested, traverse to the parents to see if they satisfy the criteria. E.g. we might be looking for
|
||||||
/// children of a storey named "Level 20", or children of entities that have no representation, e.g. IfcCurtainWall.
|
/// children of a storey named "Level 20", or children of entities that have no representation, e.g. IfcCurtainWall.
|
||||||
bool traverse;
|
bool traverse;
|
||||||
|
/// Include opening relationships as part of traversal.
|
||||||
|
bool traverse_openings;
|
||||||
/// Optional description for the filtering criteria of this filter.
|
/// Optional description for the filtering criteria of this filter.
|
||||||
std::string description;
|
std::string description;
|
||||||
|
|
||||||
@@ -61,10 +63,10 @@ namespace IfcGeom
|
|||||||
return is_match == include;
|
return is_match == include;
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool traverse_match(IfcSchema::IfcProduct* prod, const filter_t& pred)
|
bool traverse_match(IfcSchema::IfcProduct* prod, const filter_t& pred) const
|
||||||
{
|
{
|
||||||
IfcSchema::IfcProduct* parent, *current = prod;
|
IfcSchema::IfcProduct* parent, *current = prod;
|
||||||
while ((parent = dynamic_cast<IfcSchema::IfcProduct*>(IfcGeom::Kernel::get_decomposing_entity(current))) != 0) {
|
while ((parent = dynamic_cast<IfcSchema::IfcProduct*>(IfcGeom::Kernel::get_decomposing_entity(current, traverse_openings))) != 0) {
|
||||||
if (pred(parent)) {
|
if (pred(parent)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -248,11 +250,9 @@ namespace IfcGeom
|
|||||||
struct entity_filter : public filter
|
struct entity_filter : public filter
|
||||||
{
|
{
|
||||||
entity_filter() {}
|
entity_filter() {}
|
||||||
entity_filter(bool include, bool traverse/*, const std::set<std::string>& types*/)
|
entity_filter(bool include, bool traverse)
|
||||||
: filter(include, traverse)
|
: filter(include, traverse)
|
||||||
{
|
{}
|
||||||
//populate(types);
|
|
||||||
}
|
|
||||||
|
|
||||||
std::set<IfcSchema::Type::Enum> values;
|
std::set<IfcSchema::Type::Enum> values;
|
||||||
|
|
||||||
|
|||||||
@@ -1739,11 +1739,11 @@ IfcGeom::BRepElement<P>* IfcGeom::Kernel::create_brep_for_processed_representati
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
IfcSchema::IfcObjectDefinition* IfcGeom::Kernel::get_decomposing_entity(IfcSchema::IfcProduct* product) {
|
IfcSchema::IfcObjectDefinition* IfcGeom::Kernel::get_decomposing_entity(IfcSchema::IfcProduct* product, bool include_openings) {
|
||||||
IfcSchema::IfcObjectDefinition* parent = 0;
|
IfcSchema::IfcObjectDefinition* parent = 0;
|
||||||
|
|
||||||
// In case of an opening element, parent to the RelatingBuildingElement
|
// In case of an opening element, parent to the RelatingBuildingElement
|
||||||
if ( product->is(IfcSchema::Type::IfcOpeningElement ) ) {
|
if (include_openings && product->is(IfcSchema::Type::IfcOpeningElement)) {
|
||||||
IfcSchema::IfcOpeningElement* opening = (IfcSchema::IfcOpeningElement*)product;
|
IfcSchema::IfcOpeningElement* opening = (IfcSchema::IfcOpeningElement*)product;
|
||||||
IfcSchema::IfcRelVoidsElement::list::ptr voids = opening->VoidsElements();
|
IfcSchema::IfcRelVoidsElement::list::ptr voids = opening->VoidsElements();
|
||||||
if (voids->size()) {
|
if (voids->size()) {
|
||||||
@@ -1754,7 +1754,7 @@ IfcSchema::IfcObjectDefinition* IfcGeom::Kernel::get_decomposing_entity(IfcSchem
|
|||||||
IfcSchema::IfcElement* element = (IfcSchema::IfcElement*)product;
|
IfcSchema::IfcElement* element = (IfcSchema::IfcElement*)product;
|
||||||
IfcSchema::IfcRelFillsElement::list::ptr fills = element->FillsVoids();
|
IfcSchema::IfcRelFillsElement::list::ptr fills = element->FillsVoids();
|
||||||
// In case of a RelatedBuildingElement parent to the opening element
|
// In case of a RelatedBuildingElement parent to the opening element
|
||||||
if ( fills->size() ) {
|
if (fills->size() && include_openings) {
|
||||||
for (IfcSchema::IfcRelFillsElement::list::it it = fills->begin(); it != fills->end(); ++ it) {
|
for (IfcSchema::IfcRelFillsElement::list::it it = fills->begin(); it != fills->end(); ++ it) {
|
||||||
IfcSchema::IfcRelFillsElement* fill = *it;
|
IfcSchema::IfcRelFillsElement* fill = *it;
|
||||||
IfcSchema::IfcObjectDefinition* ifc_objectdef = fill->RelatingOpeningElement();
|
IfcSchema::IfcObjectDefinition* ifc_objectdef = fill->RelatingOpeningElement();
|
||||||
|
|||||||
Reference in New Issue
Block a user