User guide

191
CEL and Utilities
There are a number of tasks that Ops are frequently required to complete, such as:
Creating a hierarchy of locations,
Determining whether an Op should run based on a CEL expression argument,
Reporting errors to the user through the scene graph, and
Obtaining well-known attribute values in an easy to use format, for example, bounding boxes.
Currently you can find headers for these utilities in:
$KATANA_HOME/plugin_apis/include/FnGeolib/op/FnGeolibCookInterface.h
$KATANA_HOME/plugin_apis/include/FnGeolib/util/*
The utility implementations live in:
$KATANA_HOME/plugin_apis/src/FnGeolib/op/FnGeolibCookInterfaceUtils.cpp
$KATANA_HOME/plugin_apis/src/FnGeolib/util/*
Many of these utilities are self-documenting and follow similar patterns. The following example demonstrates using
the CEL matching utilities:
// Should we run here? If not, return.
FnAttribute::StringAttribute celAttr = interface.getOpArg("CEL");
if (!celAttr.isValid())
return;
Foundry::Katana::MatchesCELInfo info;
Foundry::Katana::MatchesCEL(info, interface, celAttr);
if (!info.canMatchChildren)
{
interface.stopChildTraversal();
}
if (!info.matches)
return;
In the example above, a couple of things are achieved:
1. We determine whether the CEL expression could potentially match any of the children, and if not, we direct the
Runtime to not evaluate this Op at child locations.
2. We determine whether we should run at this location, and return early if not.
When using the CEL library you are required to link against libCEL.so, which you can find in $KATANA_
HOME/bin/Geolib3/internal/CEL.
Feel free to explore the range of utility functions available, as it can increase your productivity when writing Ops.
24 OP API | THE OP API EXPLAINED