Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions src/ifcconvert/IfcConvert.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -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 "
Expand Down Expand Up @@ -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");

Copy link
Copy Markdown
Member

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.


for (IfcEntityList::it i = storeys->begin(); i != storeys->end(); ++i) {
if ((*i)->getArgument(2)->toString().find(building_storey) != std::string::npos) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With the typed instances, you can simply say storey->Name(). Beware that the attribute is optional, so check first with storey->hasName().

std::cout << "Selecting " << building_storey << " for filtering..." << std::endl;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Better use Logger::Message(Logger::LOG_NOTICE, so that users can set the verbosity

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());

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The 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);
Expand Down
16 changes: 15 additions & 1 deletion src/ifcgeom/IfcGeomIterator.h
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@ namespace IfcGeom {

std::set<boost::regex> names_to_include_or_exclude; // regex containing a name or a wildcard expression
std::set<IfcSchema::Type::Enum> entities_to_include_or_exclude;
std::set<IfcSchema::IfcProduct*> products_to_include;
bool include_entities_in_processing;

void populate_set(const std::set<std::string>& include_or_ignore) {
Expand Down Expand Up @@ -340,6 +341,14 @@ namespace IfcGeom {
include_entities_in_processing = false;
}

void includeProducts(IfcTemplatedEntityList< IfcSchema::IfcProduct >::ptr products)
{
products_to_include.insert(products->begin(), products->end());
std::stringstream ss;
ss << "Including " << products_to_include.size() << " products...";
Logger::Message(Logger::LOG_NOTICE, ss.str());
}

static boost::regex wildcard_string_to_regex(std::string str)
{
// Escape all non-"*?" regex special chars
Expand Down Expand Up @@ -540,8 +549,13 @@ namespace IfcGeom {
break;
}
}

bool in_product_set = true;
if (!products_to_include.empty() && products_to_include.find((*jt)) == products_to_include.end()) {
in_product_set = false;
}

if (found == include_entities_in_processing) {
if (found == include_entities_in_processing && in_product_set) {
ifcproducts->push(*jt);
}
}
Expand Down