@@ -1751,7 +1751,7 @@ namespace {
1751
1751
// @todo this is a very minimal implementation for specific cases
1752
1752
class instance_by_property_map_filter : public instance_filter_t {
1753
1753
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 ;
1755
1755
private:
1756
1756
values_t attr_pattern_;
1757
1757
public:
@@ -1775,13 +1775,48 @@ namespace {
1775
1775
for (auto & prop : *props) {
1776
1776
if (prop->declaration ().is (" IfcPropertySingleValue" )) {
1777
1777
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
+
1778
1793
if (name == p.first ) {
1779
1794
has_match = true ;
1780
1795
IfcUtil::IfcBaseClass* val = *((IfcUtil::IfcBaseEntity*)prop)->get (" NominalValue" );
1781
1796
auto val_attr = val->data ().getArgument (0 );
1782
1797
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;
1785
1820
if (!match) {
1786
1821
return false ;
1787
1822
}
@@ -1852,7 +1887,7 @@ class op_create_prop_filter : public voxel_operation {
1852
1887
instance_by_property_map_filter::values_t vs;
1853
1888
for (auto & p : scope) {
1854
1889
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 );
1856
1891
vs.push_back ({ p.first , s });
1857
1892
}
1858
1893
}
0 commit comments