Open Inventor Release 2024.1.3
 
Loading...
Searching...
No Matches
SoCalculator Class Reference

A general-purpose calculator. More...

#include <Inventor/engines/SoCalculator.h>

+ Inheritance diagram for SoCalculator:

Public Member Functions

virtual SoType getTypeId () const
 Returns the type identifier for this specific instance.
 
 SoCalculator ()
 Constructor.
 
- Public Member Functions inherited from SoEngine
virtual int getOutputs (SoEngineOutputList &list) const
 Returns a list of outputs in this engine.
 
SoEngineOutputgetOutput (const SbName &outputName) const
 Returns a reference to the engine output with the given name.
 
SbBool getOutputName (const SoEngineOutput *output, SbName &outputName) const
 Returns (in outputName) the name of the engine output (output).
 
SoEnginecopy () const
 Creates and returns an exact copy of the engine.
 
- Public Member Functions inherited from SoFieldContainer
void setToDefaults ()
 Sets all fields in this object to their default values.
 
SbBool hasDefaultValues () const
 Returns TRUE if all of the object's fields have their default values.
 
SbBool fieldsAreEqual (const SoFieldContainer *fc) const
 Returns TRUE if this object's fields are exactly equal to fc's fields.
 
void copyFieldValues (const SoFieldContainer *fc, SbBool copyConnections=FALSE)
 Copies the contents of fc's fields into this object's fields.
 
SoNONUNICODE SbBool set (const char *fieldDataString)
 Sets one or more fields in this object to the values specified in the given string, which should be a string in the Open Inventor file format.
 
SbBool set (const SbString &fieldDataString)
 Sets one or more fields in this object to the values specified in the given string, which should be a string in the Open Inventor file format.
 
void get (SbString &fieldDataString)
 Returns the values of the fields of this object in the Open Inventor ASCII file format in the given string.
 
virtual int getFields (SoFieldList &list) const
 Appends references to all of this object's fields to resultList, and returns the number of fields appended.
 
virtual int getAllFields (SoFieldList &list) const
 Returns a list of fields, including the eventIn's and eventOut's.
 
virtual SoFieldgetField (const SbName &fieldName) const
 Returns a the field of this object whose name is fieldName.
 
virtual SoFieldgetEventIn (const SbName &fieldName) const
 Returns a the eventIn with the given name.
 
virtual SoFieldgetEventOut (const SbName &fieldName) const
 Returns the eventOut with the given name.
 
SbBool getFieldName (const SoField *field, SbName &fieldName) const
 Returns the name of the given field in the fieldName argument.
 
SbBool enableNotify (SbBool flag)
 Notification at this Field Container is enabled (if flag == TRUE) or disabled (if flag == FALSE).
 
SbBool isNotifyEnabled () const
 Notification is the process of telling interested objects that this object has changed.
 
virtual void setUserData (void *data)
 Sets application data.
 
void * getUserData (void) const
 Gets user application data.
 
- Public Member Functions inherited from SoBase
virtual void touch ()
 Marks an instance as modified, simulating a change to it.
 
virtual SbName getName () const
 Returns the name of an instance.
 
virtual void setName (const SbName &name)
 Sets the name of an instance.
 
void setSynchronizable (const bool b)
 Sets this to be a ScaleViz synchronizable object.
 
bool isSynchronizable () const
 Gets the ScaleViz synchronizable state of this object.
 
- Public Member Functions inherited from SoRefCounter
void ref () const
 Adds a reference to an instance.
 
void unref () const
 Removes a reference from an instance.
 
void unrefNoDelete () const
 unrefNoDelete() should be called when it is desired to decrement the reference count, but not delete the instance if this brings the reference count to zero.
 
int getRefCount () const
 Returns current reference count.
 
void lock () const
 lock this instance.
 
void unlock () const
 unlock this instance.
 
- Public Member Functions inherited from SoTypedObject
SbBool isOfType (const SoType &type) const
 Returns TRUE if this object is of the type specified in type or is derived from that type.
 
template<typename TypedObjectClass >
SbBool isOfType () const
 Returns TRUE if this object is of the type of class TypedObjectClass or is derived from that class.
 

Static Public Member Functions

static SoType getClassTypeId ()
 Returns the type identifier for this class.
 
- Static Public Member Functions inherited from SoEngine
static SoType getClassTypeId ()
 Returns the type identifier for the SoEngine class.
 
static SoEnginegetByName (const SbName &name)
 Looks up engine(s) by name.
 
static int getByName (const SbName &name, SoEngineList &list)
 Looks up engine(s) by name.
 
- Static Public Member Functions inherited from SoFieldContainer
static SoType getClassTypeId ()
 Returns the type of this class.
 
- Static Public Member Functions inherited from SoBase
static SoType getClassTypeId ()
 Returns type identifier for this class.
 
- Static Public Member Functions inherited from SoTypedObject
static SoType getClassTypeId ()
 Returns the type identifier for this class.
 

Public Attributes

SoMFFloat a
 Floating point input.
 
SoMFFloat b
 Floating point input.
 
SoMFFloat c
 Floating point input.
 
SoMFFloat d
 Floating point input.
 
SoMFFloat e
 Floating point input.
 
SoMFFloat f
 Floating point input.
 
SoMFFloat g
 Floating point input.
 
SoMFFloat h
 Floating point input.
 
SoMFVec3f A
 Vector input.
 
SoMFVec3f B
 Vector input.
 
SoMFVec3f C
 Vector input.
 
SoMFVec3f D
 Vector input.
 
SoMFVec3f E
 Vector input.
 
SoMFVec3f F
 Vector input.
 
SoMFVec3f G
 Vector input.
 
SoMFVec3f H
 Vector input.
 
SoMFString expression
 Expressions to be evaluated.
 
SoEngineOutput oa
 (SoMFFloat) Outputs oa-od are the floating-point values.
 
SoEngineOutput ob
 (SoMFFloat) Outputs oa-od are the floating-point values.
 
SoEngineOutput oc
 (SoMFFloat) Outputs oa-od are the floating-point values.
 
SoEngineOutput od
 (SoMFFloat) Outputs oa-od are the floating-point values.
 
SoEngineOutput oA
 (SoMFVec3f) Outputs oA-oD are the vectors.
 
SoEngineOutput oB
 (SoMFVec3f) Outputs oA-oD are the vectors.
 
SoEngineOutput oC
 (SoMFVec3f) Outputs oA-oD are the vectors.
 
SoEngineOutput oD
 (SoMFVec3f) Outputs oA-oD are the vectors.
 

Detailed Description

A general-purpose calculator.

This engine is a general-purpose calculator. The calculator operates on floating-point values and 3D floating-point vectors. The engine takes up to eight inputs of each type (SoMFFloat and SoMFVec3f), and produces up to four outputs of each type.

Each input field (a-h, A-H) can have multiple values, allowing the engine to evaluate the expression with different values in parallel. Some inputs may have more values than others. In such cases, the last value of the shorter inputs will be repeated as necessary.

The expression input string specifies the expression to be evaluated. An expression can consist of multiple subexpressions. Several subexpressions can be specified in one string, separated by semicolons (;). Alternatively, the subexpressions can be stored in separate strings in the multiple-valued input field.

Each subexpression is of the form:

   \<lhs\> = \<rhs\>

The <lhs> can be any one of the outputs or a temporary variable. The engine provides 8 temporary floating-point variables (ta, tb, tc, td, te, tf, tg, and th), and 8 temporary vector variables (tA, tB, tC, tD, tE, tF, tG, and tH). You can assign a value to one component of a vector output (A-H) or a vector variable ( tA - tH ) by using the [ ] operator. For example, oA[0] = <rhs>, will evaluate the right hand side and assign the value to the first component of the output vector oA.

The <rhs> supports arithmetic, logical and conditional operators. They are:

   (unary) !, -
   (binary) +, -, *, /, \%, <, > <=, >=, ==, !=, &&, ||
   (ternary) ? :

The ternary operator is a conditional operator. For example, a ? b : c evaluates to b if a != 0, and to c if a==0.

Valid operands for the <rhs> include the inputs, outputs, temporary variables, and their components (e.g. oA[0]). Operands can also be numeric constants (e.g. 1.0), pre-defined named constants, or pre-defined functions.

The named constants are:

   MAXFLOAT
   MINFLOAT
   M_E
   M_LOG2E
   M_LOG10E
   M_LN2
   M_LN10
   M_PI
   M_SQRT2 = sqrt(2)
   M_SQRT1_2 = sqrt(1/2)

Most of the pre-defined functions come from the math library:

   cos, sin, tan,
   acos, asin, atan, atan2,
   cosh, sinh, tanh,
   sqrt, pow, exp, log, log10,
   ceil, floor, fabs, fmod.

Other functions are defined by SoCalculator. They are:

   rand(f) - Random number generator
   cross(v1, v2) - Vector cross
  product
   dot(v1, v2) - Vector dot product
   length(v) - Vector length
   normalize(v) - Normalize vector
   vec3f(f1, f2, f3) - Generate a vector from 3 floats

The subexpressions are evaluated in order, so a variable set in the <lhs> of an earlier expression may be used in the <rhs> of a later expression.

Note, when the input has multiple values, all the subexpressions specified in the expression are applied to all the multiple input values. This is unlike the SoBoolOperation engine, where each operation is applied only to the corresponding entries of the input data. Note also, that even though the inputs and outputs can have multiple values the [ ] operator is only for indexing into the values of a single vector. It does not index into the multiple values of a field. For example, if the floating-point input field a has two values: 1.0, and 2.0, then the expression

   "oA[0]=a; oA[1]=a; oA[2]=0.0"

will produce two output vectors in oA: (1.0, 1.0, 0.0) and (2.0, 2.0, 0.0).

Examples of expressions:

   "ta = oA[0]*floor(a)"
   "tb = (a+b)*sin(M_PI)"
   "oA = vec3f(ta, tb, ta+tb)"
   "oB = normalize(oA)"
   "ta = a; tb = sin(ta); oA = vec3f(ta, tb, 0)"

FILE FORMAT/DEFAULT

    Calculator {
    a 0
    b 0
    c 0
    d 0
    e 0
    f 0
    g 0
    h 0
    A 0 0 0
    B 0 0 0
    C 0 0 0
    D 0 0 0
    E 0 0 0
    F 0 0 0
    G 0 0 0
    H 0 0 0
    expression ""
    }

SEE ALSO

SoEngineOutput, SoBoolOperation

Definition at line 201 of file SoCalculator.h.

Constructor & Destructor Documentation

◆ SoCalculator()

SoCalculator::SoCalculator ( )

Constructor.

Member Function Documentation

◆ getClassTypeId()

static SoType SoCalculator::getClassTypeId ( )
static

Returns the type identifier for this class.


◆ getTypeId()

virtual SoType SoCalculator::getTypeId ( ) const
virtual

Returns the type identifier for this specific instance.

Implements SoTypedObject.

Member Data Documentation

◆ a

SoMFFloat SoCalculator::a

Floating point input.

Definition at line 211 of file SoCalculator.h.

◆ A

SoMFVec3f SoCalculator::A

Vector input.

Definition at line 243 of file SoCalculator.h.

◆ b

SoMFFloat SoCalculator::b

Floating point input.

Definition at line 215 of file SoCalculator.h.

◆ B

SoMFVec3f SoCalculator::B

Vector input.

Definition at line 247 of file SoCalculator.h.

◆ c

SoMFFloat SoCalculator::c

Floating point input.

Definition at line 219 of file SoCalculator.h.

◆ C

SoMFVec3f SoCalculator::C

Vector input.

Definition at line 251 of file SoCalculator.h.

◆ d

SoMFFloat SoCalculator::d

Floating point input.

Definition at line 223 of file SoCalculator.h.

◆ D

SoMFVec3f SoCalculator::D

Vector input.

Definition at line 255 of file SoCalculator.h.

◆ e

SoMFFloat SoCalculator::e

Floating point input.

Definition at line 227 of file SoCalculator.h.

◆ E

SoMFVec3f SoCalculator::E

Vector input.

Definition at line 259 of file SoCalculator.h.

◆ expression

SoMFString SoCalculator::expression

Expressions to be evaluated.

Definition at line 275 of file SoCalculator.h.

◆ f

SoMFFloat SoCalculator::f

Floating point input.

Definition at line 231 of file SoCalculator.h.

◆ F

SoMFVec3f SoCalculator::F

Vector input.

Definition at line 263 of file SoCalculator.h.

◆ g

SoMFFloat SoCalculator::g

Floating point input.

Definition at line 235 of file SoCalculator.h.

◆ G

SoMFVec3f SoCalculator::G

Vector input.

Definition at line 267 of file SoCalculator.h.

◆ h

SoMFFloat SoCalculator::h

Floating point input.

Definition at line 239 of file SoCalculator.h.

◆ H

SoMFVec3f SoCalculator::H

Vector input.

Definition at line 271 of file SoCalculator.h.

◆ oa

SoEngineOutput SoCalculator::oa

(SoMFFloat) Outputs oa-od are the floating-point values.

Definition at line 280 of file SoCalculator.h.

◆ oA

SoEngineOutput SoCalculator::oA

(SoMFVec3f) Outputs oA-oD are the vectors.

Definition at line 296 of file SoCalculator.h.

◆ ob

SoEngineOutput SoCalculator::ob

(SoMFFloat) Outputs oa-od are the floating-point values.

Definition at line 284 of file SoCalculator.h.

◆ oB

SoEngineOutput SoCalculator::oB

(SoMFVec3f) Outputs oA-oD are the vectors.

Definition at line 300 of file SoCalculator.h.

◆ oc

SoEngineOutput SoCalculator::oc

(SoMFFloat) Outputs oa-od are the floating-point values.

Definition at line 288 of file SoCalculator.h.

◆ oC

SoEngineOutput SoCalculator::oC

(SoMFVec3f) Outputs oA-oD are the vectors.

Definition at line 304 of file SoCalculator.h.

◆ od

SoEngineOutput SoCalculator::od

(SoMFFloat) Outputs oa-od are the floating-point values.

Definition at line 292 of file SoCalculator.h.

◆ oD

SoEngineOutput SoCalculator::oD

(SoMFVec3f) Outputs oA-oD are the vectors.

Definition at line 308 of file SoCalculator.h.


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