mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-16 10:34:31 +00:00
Implement filtering created geometry by layer assignments.
This commit is contained in:
committed by
Thomas Krijnen
parent
3abee03b9b
commit
63b0488909
@@ -200,8 +200,8 @@ int main(int argc, char** argv)
|
||||
"geometrical output. The name patterns are handled case-sensitively. Cannot be placed right before input file argument. "
|
||||
"Only single option supported for now.")
|
||||
("exclude", po::value<exclusion_filter>(&exclude_filter)->multitoken(),
|
||||
"Specifies that the 'entities', 'names', or 'guids' provided are to be excluded. Defaults to IfcOpeningElement and IfcSpace "
|
||||
"to be excluded. See --include for syntax and more details.")
|
||||
"Specifies that the 'entities', 'names', 'guids', or 'layers' provided are to be excluded. "
|
||||
"The default value is '--exclude=entities IfcOpeningElement IfcSpace'. See --include for syntax and more details.")
|
||||
("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 "
|
||||
@@ -647,8 +647,8 @@ void validate(boost::any& v, const std::vector<std::string>& values, inclusion_f
|
||||
filter.type = geom_filter::ENTITY_NAME;
|
||||
} else if (type == "guids") {
|
||||
filter.type = geom_filter::ENTITY_GUID;
|
||||
//} else if (type == "layers") {
|
||||
// filter.type = geom_filter::LAYER_NAME;
|
||||
} else if (type == "layers") {
|
||||
filter.type = geom_filter::LAYER_NAME;
|
||||
} else {
|
||||
throw po::validation_error(po::validation_error::invalid_option_value);
|
||||
}
|
||||
@@ -671,8 +671,8 @@ void validate(boost::any& v, const std::vector<std::string>& values, exclusion_f
|
||||
filter.type = geom_filter::ENTITY_NAME;
|
||||
} else if (type == "guids") {
|
||||
filter.type = geom_filter::ENTITY_GUID;
|
||||
//} else if (type == "layers") {
|
||||
// filter.type = geom_filter::LAYER_NAME;
|
||||
} else if (type == "layers") {
|
||||
filter.type = geom_filter::LAYER_NAME;
|
||||
} else {
|
||||
throw po::validation_error(po::validation_error::invalid_option_value);
|
||||
}
|
||||
|
||||
@@ -270,41 +270,14 @@ ptree& descend(IfcObjectDefinition* product, ptree& tree) {
|
||||
}
|
||||
|
||||
if (product->is(Type::IfcProduct)) {
|
||||
IfcProduct* prod = product->as<IfcProduct>();
|
||||
if (prod->hasRepresentation()) {
|
||||
IfcEntityList::ptr r = prod->entity->file->traverse(prod->Representation());
|
||||
|
||||
std::map<std::string, IfcPresentationLayerAssignment*> layers;
|
||||
IfcRepresentation::list::ptr representations = r->as<IfcRepresentation>();
|
||||
for (IfcRepresentation::list::it it = representations->begin(); it != representations->end(); ++it) {
|
||||
IfcPresentationLayerAssignment::list::ptr a = (*it)->LayerAssignments();
|
||||
for (IfcPresentationLayerAssignment::list::it jt = a->begin(); jt != a->end(); ++jt) {
|
||||
layers[(*jt)->Name()] = *jt;
|
||||
}
|
||||
}
|
||||
|
||||
IfcRepresentationItem::list::ptr items = r->as<IfcRepresentationItem>();
|
||||
for (IfcRepresentationItem::list::it it = items->begin(); it != items->end(); ++it) {
|
||||
IfcPresentationLayerAssignment::list::ptr a = (*it)->
|
||||
// LayerAssignments renamed from plural to singular, LayerAssignment, so work around that
|
||||
#ifdef USE_IFC4
|
||||
LayerAssignment();
|
||||
#else
|
||||
LayerAssignments();
|
||||
#endif
|
||||
for (IfcPresentationLayerAssignment::list::it jt = a->begin(); jt != a->end(); ++jt) {
|
||||
layers[(*jt)->Name()] = *jt;
|
||||
}
|
||||
}
|
||||
|
||||
for (std::map<std::string, IfcPresentationLayerAssignment*>::const_iterator it = layers.begin(); it != layers.end(); ++it) {
|
||||
// IfcPresentationLayerAssignments don't have GUIDs (only optional Identifier) so use name as the ID.
|
||||
// Note that the IfcPresentationLayerAssignment passed here doesn't really matter as as_link is true
|
||||
// for the format_entity_instance() call.
|
||||
ptree node;
|
||||
node.put("<xmlattr>.xlink:href", "#" + it->first);
|
||||
format_entity_instance(it->second, node, child, true);
|
||||
}
|
||||
std::map<std::string, IfcPresentationLayerAssignment*> layers = IfcGeom::Kernel::get_layers(product->as<IfcProduct>());
|
||||
for (std::map<std::string, IfcPresentationLayerAssignment*>::const_iterator it = layers.begin(); it != layers.end(); ++it) {
|
||||
// IfcPresentationLayerAssignments don't have GUIDs (only optional Identifier) so use name as the ID.
|
||||
// Note that the IfcPresentationLayerAssignment passed here doesn't really matter as as_link is true
|
||||
// for the format_entity_instance() call.
|
||||
ptree node;
|
||||
node.put("<xmlattr>.xlink:href", "#" + it->first);
|
||||
format_entity_instance(it->second, node, child, true);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user