IfcConvert: --bulding-storey filter#150
Conversation
Enables filtering of products, alongside the existing names_to_include_or_exclude and entities_to_include_or_exclude filters. The added set does not follow the --include or --exclude commands, it only includes. The argument for doing this is to enabling filtering of a large sub-set of the IFC, e.g. a building or a storey. --include and --exclude will then only affect the selection within this subset. products_to_include being empty is interpreted as "no sub-set selected", i.e. select entire IFC.
Which will filter away everything that is not contained in the selected building-storey. Uses a simple substring match (std::string::find) on with the provided argument.
|
Hi. I made this a while back: Tridify@91051f0 (the original code here might contain some shortcomings that were fixed later on). I've been planning to submit it to here but never really got around to it yet. So my implementation one can do e.g. |
| if (!building_storey.empty()) { | ||
| bool found_storey = false; | ||
| IfcParse::IfcFile *ifc_file = context_iterator.getFile(); | ||
| IfcEntityList::ptr storeys = ifc_file->entitiesByType("IfcBuildingStorey"); |
There was a problem hiding this comment.
Better use the templated version: ifc_file->entitiesByType<IfcSchema::IfcBuildingStorey>(), than you get a typed list back.
| IfcEntityList::ptr storeys = ifc_file->entitiesByType("IfcBuildingStorey"); | ||
|
|
||
| for (IfcEntityList::it i = storeys->begin(); i != storeys->end(); ++i) { | ||
| if ((*i)->getArgument(2)->toString().find(building_storey) != std::string::npos) { |
There was a problem hiding this comment.
With the typed instances, you can simply say storey->Name(). Beware that the attribute is optional, so check first with storey->hasName().
|
|
||
| for (IfcEntityList::it i = storeys->begin(); i != storeys->end(); ++i) { | ||
| if ((*i)->getArgument(2)->toString().find(building_storey) != std::string::npos) { | ||
| std::cout << "Selecting " << building_storey << " for filtering..." << std::endl; |
There was a problem hiding this comment.
Better use Logger::Message(Logger::LOG_NOTICE, so that users can set the verbosity
| selected->ContainsElements(); | ||
| std::cout << "IfcRelContainedInSpatialStructure size " << in_storey__->size() << std::endl; | ||
| IfcSchema::IfcRelContainedInSpatialStructure* in_storey = *(selected->ContainsElements()->begin()); | ||
| context_iterator.includeProducts(in_storey->RelatedElements()); |
There was a problem hiding this comment.
This needs to be recursive. So that decomposed elements are also included.
|
Thanks for this. I made some comments about the code in-line. The proposal by @Stinkfist0 is more general and I can imagine it is useful to consider for other cases, for example, to process a single wall with its openings and windows. Also the fact that it specifically selects by Is there anyway we can unite these efforts? |
|
I plan to provide a PR in the near future of my implementation, I'm planning also adding |
|
Great, thanks for the review. I don't really know what I'm doing, just hammered on this until I got something working. It seems the proposal of @Stinkfist0 is more general and it covers my specific need here as well. Maybe just close this PR for now? And yeah, the --guid option would be very useful. |
Ok, better luck next time, thanks for your effort though. |
|
@aothms BTW, I'm not really a fan of --with-children name - would you have some better suggestion, something a bit more "IFC-like"? |
|
Well, I agree. It would be a grouping of the following relationships if I'm not mistaken: I am also fine with something like |
|
Perhaps something like |
IMHO it would cover My preference is for something general (recurse, children) and to document it properly in the help message. |
|
Maybe I'll just stick to the original name for now 😄 I'll start working on providing a PR soon. |
…including/excluding decomposition and containment of filtered entities. Usage example: IfcConvert Duplex_A_20110907.ifc Level1.dae --include --with-children --names "Level 1"
When converting large .ifc files to .obj, I wanted to select specific storeys. Is this a feature of general interest?
Especially the second commit is somewhat hacky, let me know if you want me to clean this up.