Class TX3DGraphTraverseStateStack

Unit

Declaration

type TX3DGraphTraverseStateStack = class(TObject)

Description

Stack of TX3DGraphTraverseState.

Allows you for much faster creation/destruction of TX3DGraphTraverseState instances. Although you can always construct / destruct TX3DGraphTraverseState as normal objects, in some cases this is too slow: when traversing VRML/X3D graph (e.g. profile animate_3d_model_by_code_2), merely creating/destroying TX3DGraphTraverseState instances takes a noticeable amount of time.

This stack allows you to do this faster, first of all by internally using a prepared pool of instances.

Each PushClear call creates a clear state instance, and places it on the stack. Each Push call creates a copy of current top and places it on the stack. Each Pop removes and destroys the last instance added by Push.

Naturally, you can call Push and Top only when the stack is not empty. In practice, using the stack always starts in TX3DNode.Traverse, where we push initial clear state. So the stack passed to various callbacks, TX3DNode.BeforeTraverse and such is always guaranteed non-empty.

Note that for speed purposes all Traverse calls actually share a single stack. That is, to avoid creating TX3DGraphTraverseStateStack instance each time (because even creating TX3DGraphTraverseStateStack takes some time (as it prepares a pool of TX3DGraphTraverseState instances, to allow fast push/pop)), TX3DNode simply reuses a single global TX3DGraphTraverseStateStack instance. This means that, if you execute Traverse while being inside other Traverse, you must first finish innermost Traverse before continuing with the outer.

Hierarchy

  • TObject
  • TX3DGraphTraverseStateStack

Overview

Methods

Public constructor Create;
Public destructor Destroy; override;
Public procedure Clear;
Public procedure PushClear;
Public procedure Push; overload;
Public procedure Push(const Item: TX3DGraphTraverseState); overload;
Public procedure Pop;
Public function Top: TX3DGraphTraverseState;
Public function PreviousTop: TX3DGraphTraverseState;

Description

Methods

Public constructor Create;
 
Public destructor Destroy; override;
 
Public procedure Clear;

Remove everything.

Public procedure PushClear;

Push a clear state on the stack. Clear state has everything set like a TX3DGraphTraverseState right after creating.

Public procedure Push; overload;

Push a copy of current top on the stack.

Public procedure Push(const Item: TX3DGraphTraverseState); overload;

Push a copy of given Item on the stack. We copy by TX3DGraphTraverseState.Assign, we don't copy the reference.

Public procedure Pop;
 
Public function Top: TX3DGraphTraverseState;

Peek at the top of the stack.

Public function PreviousTop: TX3DGraphTraverseState;
 

Generated by PasDoc 0.15.0.