@@ -1751,7 +1751,7 @@ namespace {
17511751 // @todo this is a very minimal implementation for specific cases
17521752 class instance_by_property_map_filter : public instance_filter_t {
17531753 public:
1754- typedef std::vector<std::pair<std::string, int > > values_t ;
1754+ typedef std::vector<std::pair<std::string, function_arg_value_type > > values_t ;
17551755 private:
17561756 values_t attr_pattern_;
17571757 public:
@@ -1775,13 +1775,48 @@ namespace {
17751775 for (auto & prop : *props) {
17761776 if (prop->declaration ().is (" IfcPropertySingleValue" )) {
17771777 auto name = (std::string) *((IfcUtil::IfcBaseEntity*)prop)->get (" Name" );
1778+
1779+ /*
1780+ // In the voxelfile grammer we can also have keywords starting with an alpha character
1781+ // so for the string comparison we need to trim off any others.
1782+ auto it = std::find_if(name.begin(), name.end(), [](char c) { return std::isalpha(c); });
1783+ if (it == name.end()) {
1784+ return false;
1785+ }
1786+ name = name.substr(std::distance(name.begin(), it));
1787+ */
1788+
1789+ std::replace_if (name.begin (), name.end (), [](char c) { return std::isdigit (c); }, ' n' );
1790+
1791+ std::cout << name << " == " << p.first << std::endl;
1792+
17781793 if (name == p.first ) {
17791794 has_match = true ;
17801795 IfcUtil::IfcBaseClass* val = *((IfcUtil::IfcBaseEntity*)prop)->get (" NominalValue" );
17811796 auto val_attr = val->data ().getArgument (0 );
17821797 if (val_attr->type () == IfcUtil::Argument_BOOL) {
1783- auto b = (bool )*val_attr;
1784- bool match = (b ? 1 : 0 ) == p.second ;
1798+ auto v_ifc = (bool )*val_attr;
1799+ int v_filter = 0 ;
1800+ try {
1801+ v_filter = boost::get<int >(p.second );
1802+ } catch (boost::bad_get&) {
1803+ return false ;
1804+ }
1805+ bool match = (v_ifc ? 1 : 0 ) == v_filter;
1806+ if (!match) {
1807+ return false ;
1808+ }
1809+ } else if (val_attr->type () == IfcUtil::Argument_STRING) {
1810+ auto v_ifc = (std::string)*val_attr;
1811+ std::string v_filter;
1812+ try {
1813+ v_filter = boost::get<std::string>(p.second );
1814+ } catch (boost::bad_get&) {
1815+ return false ;
1816+ }
1817+ // v_filter = v_filter.substr(1, v_filter.size() - 2);
1818+ std::cout << v_ifc << " == " << v_filter << std::endl;
1819+ bool match = v_ifc == v_filter;
17851820 if (!match) {
17861821 return false ;
17871822 }
@@ -1852,7 +1887,7 @@ class op_create_prop_filter : public voxel_operation {
18521887 instance_by_property_map_filter::values_t vs;
18531888 for (auto & p : scope) {
18541889 if (to_exclude.find (p.first ) == to_exclude.end ()) {
1855- auto s = boost::get<int >(boost::get< function_arg_value_type>(p.second ) );
1890+ auto s = boost::get<function_arg_value_type>(p.second );
18561891 vs.push_back ({ p.first , s });
18571892 }
18581893 }
0 commit comments