-
-
Notifications
You must be signed in to change notification settings - Fork 923
IfcConvert: --bulding-storey filter #150
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -128,6 +128,7 @@ int main(int argc, char** argv) { | |
| ("output-file", boost::program_options::value<std::string>(), "output geometry file"); | ||
|
|
||
| std::vector<std::string> entity_vector, names; | ||
| std::string building_storey; | ||
| double deflection_tolerance; | ||
| boost::program_options::options_description geom_options("Geometry options"); | ||
| geom_options.add_options() | ||
|
|
@@ -188,6 +189,8 @@ int main(int argc, char** argv) { | |
| "A list of names or wildcard patterns that should be included in or excluded from the " | ||
| "geometrical output, depending on whether --exclude or --include is specified. " | ||
| "The names are handled case-sensitively. Cannot be placed right before input file argument.") | ||
| ("building-storey", boost::program_options::value<std::string>(&building_storey), | ||
| "Only include the specified building storey") | ||
| ("no-normals", | ||
| "Disables computation of normals. Saves time and file size and is useful " | ||
| "in instances where you're going to recompute normals for the exported " | ||
|
|
@@ -429,6 +432,29 @@ int main(int argc, char** argv) { | |
|
|
||
| IfcGeom::Iterator<real_t> context_iterator(settings, input_filename); | ||
|
|
||
| if (!building_storey.empty()) { | ||
| bool found_storey = false; | ||
| IfcParse::IfcFile *ifc_file = context_iterator.getFile(); | ||
| 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) { | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. With the typed instances, you can simply say |
||
| std::cout << "Selecting " << building_storey << " for filtering..." << std::endl; | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Better use |
||
| IfcSchema::IfcBuildingStorey* selected = (*i)->as<IfcSchema::IfcBuildingStorey>(); | ||
| IfcTemplatedEntityList< IfcSchema::IfcRelContainedInSpatialStructure >::ptr in_storey__ = | ||
| selected->ContainsElements(); | ||
| std::cout << "IfcRelContainedInSpatialStructure size " << in_storey__->size() << std::endl; | ||
| IfcSchema::IfcRelContainedInSpatialStructure* in_storey = *(selected->ContainsElements()->begin()); | ||
| context_iterator.includeProducts(in_storey->RelatedElements()); | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This needs to be recursive. So that decomposed elements are also included. |
||
| found_storey = true; | ||
| } | ||
| } | ||
|
|
||
| if (!found_storey) { | ||
| Logger::Message(Logger::LOG_WARNING, "Unable to find storey " + building_storey); | ||
| } | ||
| } | ||
|
|
||
| try { | ||
| if (include_entities) { | ||
| context_iterator.includeEntities(entities); | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Better use the templated version:
ifc_file->entitiesByType<IfcSchema::IfcBuildingStorey>(), than you get a typed list back.