Click or drag to resize
SoCalculator Class

A general-purpose calculator.

Inheritance Hierarchy

Namespace: OIV.Inventor.Engines
Assembly: OIV.Inventor (in OIV.Inventor.dll) Version: 2023.1.3.0 (2023.1.3)
Syntax
public class SoCalculator : SoEngine

The SoCalculator type exposes the following members.

Constructors
  NameDescription
Public methodSoCalculator

Constructor.

Top
Methods
  NameDescription
Public methodCopy

Creates and returns an exact copy of the engine.

(Inherited from SoEngine.)
Public methodCopyFieldValues(SoFieldContainer)
Calls CopyFieldValues(fc, false).
(Inherited from SoFieldContainer.)
Public methodCopyFieldValues(SoFieldContainer, Boolean)

Copies the contents of fc's fields into this object's fields.

(Inherited from SoFieldContainer.)
Public methodDispose
Releases all resources used by SoDisposable.
(Inherited from SoDisposable.)
Public methodEnableNotify

Notification at this Field Container is enabled (if flag == true) or disabled (if flag == false).

(Inherited from SoFieldContainer.)
Public methodEquals
Determines whether the specified Object is equal to the current Object.
(Inherited from Object.)
Public methodFieldsAreEqual

Returns true if this object's fields are exactly equal to fc's fields.

(Inherited from SoFieldContainer.)
Public methodGet

Returns the values of the fields of this object in the Open Inventor ASCII file format in the given string.

(Inherited from SoFieldContainer.)
Public methodGetAllFields

Returns a list of fields, including the eventIn's and eventOut's.

(Inherited from SoFieldContainer.)
Public methodGetEventIn

Returns a the eventIn with the given name.

(Inherited from SoFieldContainer.)
Public methodGetEventOut

Returns the eventOut with the given name.

(Inherited from SoFieldContainer.)
Public methodGetField

Returns a the field of this object whose name is fieldName.

(Inherited from SoFieldContainer.)
Public methodGetFieldName

Returns the name of the given field in the fieldName argument.

(Inherited from SoFieldContainer.)
Public methodGetFields

Appends references to all of this object's fields to resultList, and returns the number of fields appended.

(Inherited from SoFieldContainer.)
Public methodGetHashCode
Overrides GetHashCode().
(Inherited from SoNetBase.)
Public methodGetName

Returns the name of an instance.

(Inherited from SoBase.)
Public methodGetOutput

Returns a reference to the engine output with the given name.

(Inherited from SoEngine.)
Public methodGetOutputName

Returns (in outputName) the name of the engine output (output).

(Inherited from SoEngine.)
Public methodGetOutputs

Returns a list of outputs in this engine.

(Inherited from SoEngine.)
Public methodGetStringName (Inherited from SoBase.)
Public methodGetType
Gets the Type of the current instance.
(Inherited from Object.)
Public methodHasDefaultValues

Returns true if all of the object's fields have their default values.

(Inherited from SoFieldContainer.)
Public methodIsNotifyEnabled

Notification is the process of telling interested objects that this object has changed.

(Inherited from SoFieldContainer.)
Public methodIsSynchronizable

Gets the ScaleViz synchronizable state of this object.

(Inherited from SoBase.)
Public methodSet

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.

(Inherited from SoFieldContainer.)
Public methodSetName (Inherited from SoBase.)
Public methodSetSynchronizable

Sets this to be a ScaleViz synchronizable object.

(Inherited from SoBase.)
Public methodSetToDefaults

Sets all fields in this object to their default values.

(Inherited from SoFieldContainer.)
Public methodToString
Converts this SoBase structure to a human readable string.
(Inherited from SoBase.)
Public methodTouch

Marks an instance as modified, simulating a change to it.

(Inherited from SoBase.)
Top
Properties
  NameDescription
Public propertya

Floating point input.

Public propertyA

Vector input.

Public propertyb

Floating point input.

Public propertyB

Vector input.

Public propertyc

Floating point input.

Public propertyC

Vector input.

Public propertyd

Floating point input.

Public propertyD

Vector input.

Public propertye

Floating point input.

Public propertyE

Vector input.

Public propertyexpression

Expressions to be evaluated.

Public propertyf

Floating point input.

Public propertyF

Vector input.

Public propertyg

Floating point input.

Public propertyG

Vector input.

Public propertyh

Floating point input.

Public propertyH

Vector input.

Public propertyIsDisposable
ISafeDisposable interface implementation.
(Inherited from SoDisposable.)
Public propertyoa

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

Public propertyoA

(OIV.Inventor.Fields.SoMFVec3f) Outputs oA-oD are the vectors.

Public propertyob

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

Public propertyoB

(OIV.Inventor.Fields.SoMFVec3f) Outputs oA-oD are the vectors.

Public propertyoc

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

Public propertyoC

(OIV.Inventor.Fields.SoMFVec3f) Outputs oA-oD are the vectors.

Public propertyod

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

Public propertyoD

(OIV.Inventor.Fields.SoMFVec3f) Outputs oA-oD are the vectors.

Public propertyUserData
Gets or sets the user data to be contained by the field container.
(Inherited from SoFieldContainer.)
Top
Remarks

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 (OIV.Inventor.Fields.SoMFFloat and OIV.Inventor.Fields.SoMFVec3f), and produces up to four outputs of each type.

Each input field (OIV.Inventor.Engines.SoCalculator.a-OIV.Inventor.Engines.SoCalculator.h, OIV.Inventor.Engines.SoCalculator.A-OIV.Inventor.Engines.SoCalculator.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 OIV.Inventor.Engines.SoCalculator.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 (OIV.Inventor.Engines.SoCalculator.A-OIV.Inventor.Engines.SoCalculator.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 OIV.Inventor.Engines.SoCalculator.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 OIV.Inventor.Engines.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 OIV.Inventor.Engines.SoCalculator.expression are applied to all the multiple input values. This is unlike the OIV.Inventor.Engines.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 OIV.Inventor.Engines.SoCalculator.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 OIV.Inventor.Engines.SoCalculator.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