Enzo
Loading...
Searching...
No Matches
enzo::expr::PointScript Class Reference

A compiled script that runs once per point and edits the point's attributes. More...

#include <PointScript.h>

Public Member Functions

const std::vector< AttributeBinding > & getBindings () const
 Returns every attribute the code binds, in the order they first appear.
 
std::shared_ptr< PointScriptclone () const
 Returns a copy that runs in its own context.
 
bool addWrittenAttributes (geo::Primitive &output, String &error) const
 Adds every attribute the script writes to the output, filled with the default value.
 
bool run (const geo::Primitive &input, geo::Primitive &output, Offset begin, Offset end, const ExpressionContext *context, String &error)
 Runs the script for each valid point in a range.
 

Static Public Member Functions

static std::shared_ptr< PointScriptcompile (const String &code, String &error)
 Returns the compiled script for the user's code.
 

Detailed Description

A compiled script that runs once per point and edits the point's attributes.

The user's code is the body of a function that takes the point offset as pt and reads and writes the point's attributes as @name.

@Position.y += sin(@Position.x) * prm("amplitude")
i@id = pt
Note
Each thread runs its own clone over its own range of points.

Member Function Documentation

◆ addWrittenAttributes()

bool enzo::expr::PointScript::addWrittenAttributes ( geo::Primitive & output,
String & error ) const

Adds every attribute the script writes to the output, filled with the default value.

Returns
False when the output cannot hold one of them.

◆ clone()

std::shared_ptr< PointScript > enzo::expr::PointScript::clone ( ) const

Returns a copy that runs in its own context.

Returns
The copy, or null when its globals fail to initialise.

◆ compile()

std::shared_ptr< PointScript > enzo::expr::PointScript::compile ( const String & code,
String & error )
static

Returns the compiled script for the user's code.

Returns
The compiled script, or null when the code fails to compile.

◆ run()

bool enzo::expr::PointScript::run ( const geo::Primitive & input,
geo::Primitive & output,
Offset begin,
Offset end,
const ExpressionContext * context,
String & error )

Runs the script for each valid point in a range.

Reads bindings from the input and stores written ones to the output.

Returns
False when the script fails on a point.
Note
The output needs the written attributes added first.

The documentation for this class was generated from the following files: