WIP: integration of new features

This commit is contained in:
Matthias Koefferlein 2025-07-28 23:11:21 +02:00
parent 8d7919e054
commit 3a612f9b04
3 changed files with 218 additions and 19 deletions

View File

@ -33,6 +33,7 @@
#include "dbPropertiesFilter.h"
#include "gsiDeclDbContainerHelpers.h"
#include "gsiDeclDbMeasureHelpers.h"
namespace gsi
{
@ -89,6 +90,11 @@ static gsi::EdgePairFilterBase *make_pg (const tl::Variant &name, const std::str
return new EdgePairPropertiesFilter (name, pattern, inverse);
}
static gsi::EdgePairFilterBase *make_pe (const std::string &expression, bool inverse, double dbu)
{
return new gsi::expression_filter<gsi::EdgePairFilterBase, db::EdgePairs> (expression, inverse, dbu);
}
Class<gsi::EdgePairFilterBase> decl_EdgePairFilterBase ("db", "EdgePairFilterBase",
gsi::EdgePairFilterBase::method_decls (true) +
gsi::constructor ("property_glob", &make_pg, gsi::arg ("name"), gsi::arg ("pattern"), gsi::arg ("inverse", false), gsi::arg ("case_sensitive", true),
@ -129,6 +135,25 @@ Class<gsi::EdgePairFilterBase> decl_EdgePairFilterBase ("db", "EdgePairFilterBas
"Apply this filter with \\EdgePairs#filtered. See \\property_glob for an example.\n"
"\n"
"This feature has been introduced in version 0.30."
) +
gsi::constructor ("expression_filter", &make_pe, gsi::arg ("expression"), gsi::arg ("inverse", false), gsi::arg ("dbu", 0.0),
"@brief Creates an expression-based filter\n"
"@param expression The expression to evaluate.\n"
"@param inverse If true, inverts the selection - i.e. all edge pairs without a property with the given name and value range are selected.\n"
"@param dbu If given and greater than zero, the shapes delivered by the 'shape' function will be in micrometer units.\n"
"\n"
"Creates a filter that will evaluate the given expression on every shape and select the shape "
"when the expression renders a boolean true value. "
"The expression may use the following variables and functions:\n"
"\n"
"@ul\n"
"@li @b shape @/b: The current shape (i.e. 'EdgePair' without DBU specified or 'DEdgePair' otherwise) @/li\n"
"@li @b value(<name>) @/b: The value of the property with the given name (the first one if there are multiple properties with the same name) @/li\n"
"@li @b values(<name>) @/b: All values of the properties with the given name (returns a list) @/li\n"
"@li @b <name> @/b: A shortcut for 'value(<name>)' (<name> is used as a symbol) @/li\n"
"@/ul\n"
"\n"
"This feature has been introduced in version 0.30.3."
),
"@hide"
);
@ -184,7 +209,9 @@ Class<gsi::EdgePairFilterImpl> decl_EdgePairFilterImpl (decl_EdgePairFilterBase,
// ---------------------------------------------------------------------------------
// EdgePairProcessor binding
Class<shape_processor_impl<db::EdgePairProcessorBase> > decl_EdgePairProcessor ("db", "EdgePairOperator",
Class<db::EdgePairProcessorBase> decl_EdgePairProcessorBase ("db", "EdgePairProcessorBase", "@hide");
Class<shape_processor_impl<db::EdgePairProcessorBase> > decl_EdgePairProcessor (decl_EdgePairProcessorBase, "db", "EdgePairOperator",
shape_processor_impl<db::EdgePairProcessorBase>::method_decls (false),
"@brief A generic edge-pair operator\n"
"\n"
@ -227,7 +254,45 @@ Class<shape_processor_impl<db::EdgePairProcessorBase> > decl_EdgePairProcessor (
"This class has been introduced in version 0.29.\n"
);
Class<shape_processor_impl<db::EdgePairToPolygonProcessorBase> > decl_EdgePairToPolygonProcessor ("db", "EdgePairToPolygonOperator",
static
property_computation_processor<db::EdgePairProcessorBase, db::EdgePairs> *
new_pcp (const db::EdgePairs *container, const std::map<tl::Variant, std::string> &expressions, bool copy_properties, double dbu)
{
return new property_computation_processor<db::EdgePairProcessorBase, db::EdgePairs> (container, expressions, copy_properties, dbu);
}
Class<property_computation_processor<db::EdgePairProcessorBase, db::EdgePairs> > decl_EdgePairPropertiesExpressions (decl_EdgePairProcessorBase, "db", "EdgePairPropertiesExpressions",
property_computation_processor<db::EdgePairProcessorBase, db::EdgePairs>::method_decls (true) +
gsi::constructor ("new", &new_pcp, gsi::arg ("edge_pairs"), gsi::arg ("expressions"), gsi::arg ("copy_properties", false), gsi::arg ("dbu", 0.0),
"@brief Creates a new properties expressions operator\n"
"\n"
"@param edge_pairs The edge pair collection, the processor will be used on. Can be nil, but if given, allows some optimization.\n"
"@param expressions A map of property names and expressions used to generate the values of the properties (see class description for details).\n"
"@param copy_properties If true, new properties will be added to existing ones.\n"
"@param dbu If not zero, this value specifies the database unit to use. If given, the shapes returned by the 'shape' function will be micrometer-unit objects.\n"
),
"@brief An operator attaching computed properties to the edge pairs\n"
"\n"
"This operator will execute a number of expressions and attach the results as new properties. "
"The expression inputs can be taken either from the edge pairs themselves or from existing properties.\n"
"\n"
"A number of expressions can be supplied with a name. The expressions will be evaluated and the result "
"is attached to the output edge pairs as user properties with the given names.\n"
"The expression may use the following variables and functions:\n"
"\n"
"@ul\n"
"@li @b shape @/b: The current shape (i.e. 'EdgePair' without DBU specified or 'DEdgePair' otherwise) @/li\n"
"@li @b value(<name>) @/b: The value of the property with the given name (the first one if there are multiple properties with the same name) @/li\n"
"@li @b values(<name>) @/b: All values of the properties with the given name (returns a list) @/li\n"
"@li @b <name> @/b: A shortcut for 'value(<name>)' (<name> is used as a symbol) @/li\n"
"@/ul\n"
"\n"
"This class has been introduced in version 0.30.3.\n"
);
Class<db::EdgePairToPolygonProcessorBase> decl_EdgePairToPolygonProcessorBase ("db", "EdgePairToPolygonProcessorBase", "@hide");
Class<shape_processor_impl<db::EdgePairToPolygonProcessorBase> > decl_EdgePairToPolygonProcessor (decl_EdgePairToPolygonProcessorBase, "db", "EdgePairToPolygonOperator",
shape_processor_impl<db::EdgePairToPolygonProcessorBase>::method_decls (false),
"@brief A generic edge-pair-to-polygon operator\n"
"\n"
@ -251,7 +316,9 @@ Class<shape_processor_impl<db::EdgePairToPolygonProcessorBase> > decl_EdgePairTo
"This class has been introduced in version 0.29.\n"
);
Class<shape_processor_impl<db::EdgePairToEdgeProcessorBase> > decl_EdgePairToEdgeProcessor ("db", "EdgePairToEdgeOperator",
Class<db::EdgePairToEdgeProcessorBase> decl_EdgePairToEdgeProcessorBase ("db", "EdgePairProcessorBase", "@hide");
Class<shape_processor_impl<db::EdgePairToEdgeProcessorBase> > decl_EdgePairToEdgeProcessor (decl_EdgePairToEdgeProcessorBase, "db", "EdgePairToEdgeOperator",
shape_processor_impl<db::EdgePairToEdgeProcessorBase>::method_decls (false),
"@brief A generic edge-pair-to-edge operator\n"
"\n"
@ -491,24 +558,24 @@ static std::vector<db::EdgePairs> split_filter (const db::EdgePairs *r, const Ed
return as_2edge_pairs_vector (r->split_filter (*f));
}
static db::EdgePairs processed_epep (const db::EdgePairs *r, const shape_processor_impl<db::EdgePairProcessorBase> *f)
static db::EdgePairs processed_epep (const db::EdgePairs *r, const db::EdgePairProcessorBase *f)
{
return r->processed (*f);
}
static void process_epep (db::EdgePairs *r, const shape_processor_impl<db::EdgePairProcessorBase> *f)
static void process_epep (db::EdgePairs *r, const db::EdgePairProcessorBase *f)
{
r->process (*f);
}
static db::Edges processed_epe (const db::EdgePairs *r, const shape_processor_impl<db::EdgePairToEdgeProcessorBase> *f)
static db::Edges processed_epe (const db::EdgePairs *r, const db::EdgePairToEdgeProcessorBase *f)
{
db::Edges out;
r->processed (out, *f);
return out;
}
static db::Region processed_epp (const db::EdgePairs *r, const shape_processor_impl<db::EdgePairToPolygonProcessorBase> *f)
static db::Region processed_epp (const db::EdgePairs *r, const db::EdgePairToPolygonProcessorBase *f)
{
db::Region out;
r->processed (out, *f);

View File

@ -34,6 +34,7 @@
#include "dbPropertiesFilter.h"
#include "gsiDeclDbContainerHelpers.h"
#include "gsiDeclDbMeasureHelpers.h"
namespace gsi
{
@ -90,6 +91,11 @@ static gsi::EdgeFilterBase *make_pg (const tl::Variant &name, const std::string
return new EdgePropertiesFilter (name, pattern, inverse);
}
static gsi::EdgeFilterBase *make_pe (const std::string &expression, bool inverse, double dbu)
{
return new gsi::expression_filter<gsi::EdgeFilterBase, db::Edges> (expression, inverse, dbu);
}
Class<gsi::EdgeFilterBase> decl_EdgeFilterBase ("db", "EdgeFilterBase",
gsi::EdgeFilterBase::method_decls (true) +
gsi::constructor ("property_glob", &make_pg, gsi::arg ("name"), gsi::arg ("pattern"), gsi::arg ("inverse", false), gsi::arg ("case_sensitive", true),
@ -130,6 +136,25 @@ Class<gsi::EdgeFilterBase> decl_EdgeFilterBase ("db", "EdgeFilterBase",
"Apply this filter with \\Edges#filtered. See \\property_glob for an example.\n"
"\n"
"This feature has been introduced in version 0.30."
) +
gsi::constructor ("expression_filter", &make_pe, gsi::arg ("expression"), gsi::arg ("inverse", false), gsi::arg ("dbu", 0.0),
"@brief Creates an expression-based filter\n"
"@param expression The expression to evaluate.\n"
"@param inverse If true, inverts the selection - i.e. all edges without a property with the given name and value range are selected.\n"
"@param dbu If given and greater than zero, the shapes delivered by the 'shape' function will be in micrometer units.\n"
"\n"
"Creates a filter that will evaluate the given expression on every shape and select the shape "
"when the expression renders a boolean true value. "
"The expression may use the following variables and functions:\n"
"\n"
"@ul\n"
"@li @b shape @/b: The current shape (i.e. 'Edge' without DBU specified or 'DEdge' otherwise) @/li\n"
"@li @b value(<name>) @/b: The value of the property with the given name (the first one if there are multiple properties with the same name) @/li\n"
"@li @b values(<name>) @/b: All values of the properties with the given name (returns a list) @/li\n"
"@li @b <name> @/b: A shortcut for 'value(<name>)' (<name> is used as a symbol) @/li\n"
"@/ul\n"
"\n"
"This feature has been introduced in version 0.30.3."
),
"@hide"
);
@ -187,7 +212,9 @@ Class<gsi::EdgeFilterImpl> decl_EdgeFilterImpl (decl_EdgeFilterBase, "db", "Edge
// ---------------------------------------------------------------------------------
// EdgeProcessor binding
Class<shape_processor_impl<db::EdgeProcessorBase> > decl_EdgeProcessorBase ("db", "EdgeOperator",
Class<db::EdgeProcessorBase> decl_EdgeProcessorBase ("db", "EdgeProcessorBase", "@hide");
Class<shape_processor_impl<db::EdgeProcessorBase> > decl_EdgeOperator (decl_EdgeProcessorBase, "db", "EdgeOperator",
shape_processor_impl<db::EdgeProcessorBase>::method_decls (true),
"@brief A generic edge-to-polygon operator\n"
"\n"
@ -232,7 +259,45 @@ Class<shape_processor_impl<db::EdgeProcessorBase> > decl_EdgeProcessorBase ("db"
"This class has been introduced in version 0.29.\n"
);
Class<shape_processor_impl<db::EdgeToPolygonProcessorBase> > decl_EdgeToPolygonProcessor ("db", "EdgeToPolygonOperator",
static
property_computation_processor<db::EdgeProcessorBase, db::Edges> *
new_pcp (const db::Edges *container, const std::map<tl::Variant, std::string> &expressions, bool copy_properties, double dbu)
{
return new property_computation_processor<db::EdgeProcessorBase, db::Edges> (container, expressions, copy_properties, dbu);
}
Class<property_computation_processor<db::EdgeProcessorBase, db::Edges> > decl_EdgePropertiesExpressions (decl_EdgeProcessorBase, "db", "EdgePropertiesExpressions",
property_computation_processor<db::EdgeProcessorBase, db::Edges>::method_decls (true) +
gsi::constructor ("new", &new_pcp, gsi::arg ("edges"), gsi::arg ("expressions"), gsi::arg ("copy_properties", false), gsi::arg ("dbu", 0.0),
"@brief Creates a new properties expressions operator\n"
"\n"
"@param edges The edge collection, the processor will be used on. Can be nil, but if given, allows some optimization.\n"
"@param expressions A map of property names and expressions used to generate the values of the properties (see class description for details).\n"
"@param copy_properties If true, new properties will be added to existing ones.\n"
"@param dbu If not zero, this value specifies the database unit to use. If given, the shapes returned by the 'shape' function will be micrometer-unit objects.\n"
),
"@brief An operator attaching computed properties to the edges\n"
"\n"
"This operator will execute a number of expressions and attach the results as new properties. "
"The expression inputs can be taken either from the edges themselves or from existing properties.\n"
"\n"
"A number of expressions can be supplied with a name. The expressions will be evaluated and the result "
"is attached to the output edges as user properties with the given names.\n"
"The expression may use the following variables and functions:\n"
"\n"
"@ul\n"
"@li @b shape @/b: The current shape (i.e. 'Edge' without DBU specified or 'DEdge' otherwise) @/li\n"
"@li @b value(<name>) @/b: The value of the property with the given name (the first one if there are multiple properties with the same name) @/li\n"
"@li @b values(<name>) @/b: All values of the properties with the given name (returns a list) @/li\n"
"@li @b <name> @/b: A shortcut for 'value(<name>)' (<name> is used as a symbol) @/li\n"
"@/ul\n"
"\n"
"This class has been introduced in version 0.30.3.\n"
);
Class<db::EdgeToPolygonProcessorBase> decl_EdgeToPolygonProcessorBase ("db", "EdgeToPolygonProcessorBase", "@hide");
Class<shape_processor_impl<db::EdgeToPolygonProcessorBase> > decl_EdgeToPolygonProcessor (decl_EdgeToPolygonProcessorBase, "db", "EdgeToPolygonOperator",
shape_processor_impl<db::EdgeToPolygonProcessorBase>::method_decls (true),
"@brief A generic edge-to-polygon operator\n"
"\n"
@ -256,7 +321,9 @@ Class<shape_processor_impl<db::EdgeToPolygonProcessorBase> > decl_EdgeToPolygonP
"This class has been introduced in version 0.29.\n"
);
Class<shape_processor_impl<db::EdgeToEdgePairProcessorBase> > decl_EdgeToEdgePairProcessor ("db", "EdgeToEdgePairOperator",
Class<db::EdgeToEdgePairProcessorBase> decl_EdgeToEdgePairProcessorBase ("db", "EdgeToEdgePairProcessorBase", "@hide");
Class<shape_processor_impl<db::EdgeToEdgePairProcessorBase> > decl_EdgeToEdgePairProcessor (decl_EdgeToEdgePairProcessorBase, "db", "EdgeToEdgePairOperator",
shape_processor_impl<db::EdgeToEdgePairProcessorBase>::method_decls (true),
"@brief A generic edge-to-edge-pair operator\n"
"\n"
@ -516,22 +583,22 @@ static std::vector<db::Edges> split_filter (const db::Edges *r, const gsi::EdgeF
return as_2edges_vector (r->split_filter (*f));
}
static db::Edges processed_ee (const db::Edges *r, const shape_processor_impl<db::EdgeProcessorBase> *f)
static db::Edges processed_ee (const db::Edges *r, const db::EdgeProcessorBase *f)
{
return r->processed (*f);
}
static void process_ee (db::Edges *r, const shape_processor_impl<db::EdgeProcessorBase> *f)
static void process_ee (db::Edges *r, const db::EdgeProcessorBase *f)
{
r->process (*f);
}
static db::EdgePairs processed_eep (const db::Edges *r, const shape_processor_impl<db::EdgeToEdgePairProcessorBase> *f)
static db::EdgePairs processed_eep (const db::Edges *r, const db::EdgeToEdgePairProcessorBase *f)
{
return r->processed (*f);
}
static db::Region processed_ep (const db::Edges *r, const shape_processor_impl<db::EdgeToPolygonProcessorBase> *f)
static db::Region processed_ep (const db::Edges *r, const db::EdgeToPolygonProcessorBase *f)
{
db::Region out;
r->processed (out, *f);

View File

@ -30,6 +30,7 @@
#include "dbPropertiesFilter.h"
#include "gsiDeclDbContainerHelpers.h"
#include "gsiDeclDbMeasureHelpers.h"
namespace gsi
{
@ -86,6 +87,11 @@ static gsi::TextFilterBase *make_pg (const tl::Variant &name, const std::string
return new TextPropertiesFilter (name, pattern, inverse);
}
static gsi::TextFilterBase *make_pe (const std::string &expression, bool inverse, double dbu)
{
return new gsi::expression_filter<gsi::TextFilterBase, db::Texts> (expression, inverse, dbu);
}
Class<gsi::TextFilterBase> decl_TextFilterBase ("db", "TextFilterBase",
gsi::TextFilterBase::method_decls (false) +
gsi::constructor ("property_glob", &make_pg, gsi::arg ("name"), gsi::arg ("pattern"), gsi::arg ("inverse", false), gsi::arg ("case_sensitive", true),
@ -126,6 +132,25 @@ Class<gsi::TextFilterBase> decl_TextFilterBase ("db", "TextFilterBase",
"Apply this filter with \\Texts#filtered. See \\property_glob for an example.\n"
"\n"
"This feature has been introduced in version 0.30."
) +
gsi::constructor ("expression_filter", &make_pe, gsi::arg ("expression"), gsi::arg ("inverse", false), gsi::arg ("dbu", 0.0),
"@brief Creates an expression-based filter\n"
"@param expression The expression to evaluate.\n"
"@param inverse If true, inverts the selection - i.e. all texts without a property with the given name and value range are selected.\n"
"@param dbu If given and greater than zero, the shapes delivered by the 'shape' function will be in micrometer units.\n"
"\n"
"Creates a filter that will evaluate the given expression on every shape and select the shape "
"when the expression renders a boolean true value. "
"The expression may use the following variables and functions:\n"
"\n"
"@ul\n"
"@li @b shape @/b: The current shape (i.e. 'Text' without DBU specified or 'DText' otherwise) @/li\n"
"@li @b value(<name>) @/b: The value of the property with the given name (the first one if there are multiple properties with the same name) @/li\n"
"@li @b values(<name>) @/b: All values of the properties with the given name (returns a list) @/li\n"
"@li @b <name> @/b: A shortcut for 'value(<name>)' (<name> is used as a symbol) @/li\n"
"@/ul\n"
"\n"
"This feature has been introduced in version 0.30.3."
),
"@hide"
);
@ -182,7 +207,9 @@ Class<gsi::TextFilterImpl> decl_TextFilterImpl (decl_TextFilterBase, "db", "Text
// ---------------------------------------------------------------------------------
// TextProcessor binding
Class<shape_processor_impl<db::TextProcessorBase> > decl_TextProcessor ("db", "TextOperator",
Class<db::TextProcessorBase> decl_TextProcessorBase ("db", "TextProcessorBase", "@hide");
Class<shape_processor_impl<db::TextProcessorBase> > decl_TextProcessor (decl_TextProcessorBase, "db", "TextOperator",
shape_processor_impl<db::TextProcessorBase>::method_decls (false),
"@brief A generic text operator\n"
"\n"
@ -227,7 +254,45 @@ Class<shape_processor_impl<db::TextProcessorBase> > decl_TextProcessor ("db", "T
"This class has been introduced in version 0.29.\n"
);
Class<shape_processor_impl<db::TextToPolygonProcessorBase> > decl_TextToPolygonProcessor ("db", "TextToPolygonOperator",
static
property_computation_processor<db::TextProcessorBase, db::Texts> *
new_pcp (const db::Texts *container, const std::map<tl::Variant, std::string> &expressions, bool copy_properties, double dbu)
{
return new property_computation_processor<db::TextProcessorBase, db::Texts> (container, expressions, copy_properties, dbu);
}
Class<property_computation_processor<db::TextProcessorBase, db::Texts> > decl_TextPropertiesExpressions (decl_TextProcessorBase, "db", "TextPropertiesExpressions",
property_computation_processor<db::TextProcessorBase, db::Texts>::method_decls (true) +
gsi::constructor ("new", &new_pcp, gsi::arg ("texts"), gsi::arg ("expressions"), gsi::arg ("copy_properties", false), gsi::arg ("dbu", 0.0),
"@brief Creates a new properties expressions operator\n"
"\n"
"@param texts The text collection, the processor will be used on. Can be nil, but if given, allows some optimization.\n"
"@param expressions A map of property names and expressions used to generate the values of the properties (see class description for details).\n"
"@param copy_properties If true, new properties will be added to existing ones.\n"
"@param dbu If not zero, this value specifies the database unit to use. If given, the shapes returned by the 'shape' function will be micrometer-unit objects.\n"
),
"@brief An operator attaching computed properties to the texts\n"
"\n"
"This operator will execute a number of expressions and attach the results as new properties. "
"The expression inputs can be taken either from the texts themselves or from existing properties.\n"
"\n"
"A number of expressions can be supplied with a name. The expressions will be evaluated and the result "
"is attached to the output texts as user properties with the given names.\n"
"The expression may use the following variables and functions:\n"
"\n"
"@ul\n"
"@li @b shape @/b: The current shape (i.e. 'Text' without DBU specified or 'DText' otherwise) @/li\n"
"@li @b value(<name>) @/b: The value of the property with the given name (the first one if there are multiple properties with the same name) @/li\n"
"@li @b values(<name>) @/b: All values of the properties with the given name (returns a list) @/li\n"
"@li @b <name> @/b: A shortcut for 'value(<name>)' (<name> is used as a symbol) @/li\n"
"@/ul\n"
"\n"
"This class has been introduced in version 0.30.3.\n"
);
Class<db::TextToPolygonProcessorBase> decl_TextToPolygonProcessorBase ("db", "TextToPolygonProcessorBase", "@hide");
Class<shape_processor_impl<db::TextToPolygonProcessorBase> > decl_TextToPolygonProcessor (decl_TextToPolygonProcessorBase, "db", "TextToPolygonOperator",
shape_processor_impl<db::TextToPolygonProcessorBase>::method_decls (false),
"@brief A generic text-to-polygon operator\n"
"\n"
@ -407,17 +472,17 @@ static std::vector<db::Texts> split_filter (const db::Texts *r, const TextFilter
return as_2texts_vector (r->split_filter (*f));
}
static db::Texts processed_tt (const db::Texts *r, const shape_processor_impl<db::TextProcessorBase> *f)
static db::Texts processed_tt (const db::Texts *r, const db::TextProcessorBase *f)
{
return r->processed (*f);
}
static void process_tt (db::Texts *r, const shape_processor_impl<db::TextProcessorBase> *f)
static void process_tt (db::Texts *r, const db::TextProcessorBase *f)
{
r->process (*f);
}
static db::Region processed_tp (const db::Texts *r, const shape_processor_impl<db::TextToPolygonProcessorBase> *f)
static db::Region processed_tp (const db::Texts *r, const db::TextToPolygonProcessorBase *f)
{
db::Region out;
r->processed (out, *f);