mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-20 15:08:51 +00:00
Fix --exclude=arg when --traverse used also.
This commit is contained in:
committed by
Thomas Krijnen
parent
4b5790e83a
commit
9074f25e93
@@ -206,7 +206,7 @@ int main(int argc, char** argv)
|
|||||||
"to their associated IfcMaterialLayerSet.")
|
"to their associated IfcMaterialLayerSet.")
|
||||||
("include", po::value<inclusion_filter>(&include_filter)->multitoken(),
|
("include", po::value<inclusion_filter>(&include_filter)->multitoken(),
|
||||||
"Specifies that the entities that match a specific filtering criteria are to be included in the geometrical output:\n"
|
"Specifies that the entities that match a specific filtering criteria are to be included in the geometrical output:\n"
|
||||||
"1) 'entities': the following list of types should be included . SVG output defaults "
|
"1) 'entities': the following list of types should be included. SVG output defaults "
|
||||||
"to IfcSpace to be included. The entity names are handled case-insensitively.\n"
|
"to IfcSpace to be included. The entity names are handled case-insensitively.\n"
|
||||||
"2) 'layers': the entities that are assigned to presentation layers of which names "
|
"2) 'layers': the entities that are assigned to presentation layers of which names "
|
||||||
"match the given values should be included.\n"
|
"match the given values should be included.\n"
|
||||||
|
|||||||
@@ -33,8 +33,13 @@
|
|||||||
#include <boost/algorithm/string/replace.hpp>
|
#include <boost/algorithm/string/replace.hpp>
|
||||||
#include <boost/algorithm/string/case_conv.hpp>
|
#include <boost/algorithm/string/case_conv.hpp>
|
||||||
|
|
||||||
|
#include <functional>
|
||||||
|
|
||||||
namespace IfcGeom
|
namespace IfcGeom
|
||||||
{
|
{
|
||||||
|
/// The filter function (free or member function) or function object (use boost::ref() to reference to it)
|
||||||
|
/// should return true if the geometry for the product is wanted to be included in the output.
|
||||||
|
/// http://www.boost.org/doc/libs/1_62_0/doc/html/function/tutorial.html
|
||||||
typedef boost::function<bool(IfcSchema::IfcProduct*)> filter_t;
|
typedef boost::function<bool(IfcSchema::IfcProduct*)> filter_t;
|
||||||
|
|
||||||
struct filter
|
struct filter
|
||||||
@@ -92,7 +97,7 @@ namespace IfcGeom
|
|||||||
static boost::regex wildcard_string_to_regex(std::string str)
|
static boost::regex wildcard_string_to_regex(std::string str)
|
||||||
{
|
{
|
||||||
// Escape all non-"*?" regex special chars
|
// Escape all non-"*?" regex special chars
|
||||||
std::string special_chars = "\\^.$|()[]+/";
|
static const std::string special_chars = "\\^.$|()[]+/";
|
||||||
foreach(char c, special_chars) {
|
foreach(char c, special_chars) {
|
||||||
std::string char_str(1, c);
|
std::string char_str(1, c);
|
||||||
boost::replace_all(str, char_str, "\\" + char_str);
|
boost::replace_all(str, char_str, "\\" + char_str);
|
||||||
@@ -138,9 +143,9 @@ namespace IfcGeom
|
|||||||
std::string value(IfcSchema::IfcProduct* prod) const
|
std::string value(IfcSchema::IfcProduct* prod) const
|
||||||
{
|
{
|
||||||
for (arg_map_t::const_iterator it = args.begin(); it != args.end(); ++it) {
|
for (arg_map_t::const_iterator it = args.begin(); it != args.end(); ++it) {
|
||||||
if (prod->is(it->first)) {
|
if (prod->is(it->first) && it->second < prod->entity->getArgumentCount()) {
|
||||||
Argument *arg = (it->second < prod->entity->getArgumentCount() ? prod->entity->getArgument(it->second) : 0);
|
Argument *arg = prod->entity->getArgument(it->second);
|
||||||
if (arg && !arg->isNull()) {
|
if (!arg->isNull()) {
|
||||||
return *arg;
|
return *arg;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -148,11 +153,15 @@ namespace IfcGeom
|
|||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool match(IfcSchema::IfcProduct* prod) const { return wildcard_filter::match(value(prod)); }
|
||||||
|
|
||||||
bool operator()(IfcSchema::IfcProduct* prod) const
|
bool operator()(IfcSchema::IfcProduct* prod) const
|
||||||
{
|
{
|
||||||
bool is_match = match(value(prod));
|
bool is_match = match(prod);
|
||||||
if (is_match != include && traverse) {
|
if (!is_match && traverse) {
|
||||||
is_match = traverse_match(prod, boost::ref(*this));
|
// @note bind1st() and mem_fun() deprecated in C++11, use bind() and mem_fn() when migrating to C++11.
|
||||||
|
filter_t pred = std::bind1st(std::mem_fun(&string_arg_filter::match), this);
|
||||||
|
is_match = traverse_match(prod, pred);
|
||||||
}
|
}
|
||||||
return is_match == include;
|
return is_match == include;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user