IfcConvert: print information about the used filters.

This commit is contained in:
Stinkfist0
2017-02-23 17:25:13 +02:00
committed by Thomas Krijnen
parent 678d422ec8
commit 0383221d00
2 changed files with 53 additions and 7 deletions
+6 -5
View File
@@ -39,7 +39,6 @@
#include <Standard_Version.hxx>
#include <boost/program_options.hpp>
#include <boost/algorithm/string.hpp>
#include <fstream>
#include <sstream>
@@ -400,7 +399,12 @@ int main(int argc, char** argv)
return EXIT_FAILURE;
}
///@ todo Logger::Message(Logger::LOG_NOTICE, "Filtering by X, Y and Z.")
if (!entity_filter.values.empty()) { entity_filter.update_description(); Logger::Message(Logger::LOG_NOTICE, entity_filter.description); }
if (!layer_filter.values.empty()) { layer_filter.update_description(); Logger::Message(Logger::LOG_NOTICE, layer_filter.description); }
if (!guid_filter.values.empty()) { guid_filter.update_description(); Logger::Message(Logger::LOG_NOTICE, guid_filter.description); }
if (!name_filter.values.empty()) { name_filter.update_description(); Logger::Message(Logger::LOG_NOTICE, name_filter.description); }
if (!desc_filter.values.empty()) { desc_filter.update_description(); Logger::Message(Logger::LOG_NOTICE, desc_filter.description); }
if (!tag_filter.values.empty()) { tag_filter.update_description(); Logger::Message(Logger::LOG_NOTICE, tag_filter.description); }
if (output_extension == ".xml") {
int exit_code = 1;
@@ -677,9 +681,6 @@ std::vector<IfcGeom::filter_t> setup_filters(
entities.insert("IfcOpeningElement");
}
entity_filter.populate(entities);
Logger::Message(Logger::LOG_NOTICE, entity_filter.include ? "Including" : "Excluding" +
std::string(" by default entities ") + boost::algorithm::join(entities, ", "));
}
} catch (const IfcParse::IfcException& e) {
std::cerr << "[Error] " << e.what() << std::endl;
+47 -2
View File
@@ -24,9 +24,7 @@
#define IFCGEOMFILTER_H
#include "IfcGeom.h"
#ifndef NDEBUG
#include "../ifcparse/IfcWritableEntity.h"
#endif
#include <boost/function.hpp>
#include <boost/regex.hpp>
@@ -51,6 +49,8 @@ namespace IfcGeom
/// 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.
bool traverse;
/// Optional description for the filtering criteria of this filter.
std::string description;
bool match(IfcSchema::IfcProduct* prod, const filter_t& pred) const
{
@@ -171,6 +171,29 @@ namespace IfcGeom
// @note bind1st() and mem_fun() deprecated in C++11, use bind() and mem_fn() when migrating to C++11.
return filter::match(prod, std::bind1st(std::mem_fun(&string_arg_filter::match), this));
}
void update_description()
{
std::stringstream ss;
ss << (traverse ? "traverse " : "") << (include ? "include" : "exclude");
std::vector<std::string> patterns;
foreach(const boost::regex& r, values) {
patterns.push_back(" \"" + r.str() + "\"");
}
for (arg_map_t::const_iterator it = args.begin(); it != args.end(); ++it) {
IfcWrite::IfcWritableEntity dummy(it->first);
IfcUtil::IfcBaseClass* base = IfcSchema::SchemaEntity(&dummy);
try {
ss << " " << IfcSchema::Type::ToString(it->first) << "." << base->getArgumentName(it->second);
} catch(...) {}
delete base;
}
ss << " values " << boost::algorithm::join(patterns, " ");
description = ss.str();
}
};
struct layer_filter : public wildcard_filter
@@ -204,6 +227,18 @@ namespace IfcGeom
std::set<boost::regex> patterns;
};
void update_description()
{
std::stringstream ss;
ss << (traverse ? "traverse " : "") << (include ? "include" : "exclude") << " layers";
std::vector<std::string> str_values;
foreach(const boost::regex& r, values) {
str_values.push_back(" \"" + r.str() + "\"");
}
ss << " " << boost::algorithm::join(str_values, " ");
description = ss.str();
}
};
struct entity_filter : public filter
@@ -247,6 +282,16 @@ namespace IfcGeom
{
return filter::match(prod, std::bind1st(std::mem_fun(&entity_filter::match), this));
}
void update_description()
{
std::stringstream ss;
ss << (traverse ? "traverse " : "") << (include ? "include" : "exclude") << " entities";
foreach(IfcSchema::Type::Enum type, values) {
ss << " " << IfcSchema::Type::ToString(type);
}
description = ss.str();
}
};
}