cz.cuni.jagrlib
Class CSGCommonNode

java.lang.Object
  extended by cz.cuni.jagrlib.DefaultSceneNode
      extended by cz.cuni.jagrlib.CSGCommonNode
All Implemented Interfaces:
IntersectionAttributes, SceneNode
Direct Known Subclasses:
CSGLeaf, CSGNode

public abstract class CSGCommonNode
extends DefaultSceneNode

Common code for CSG nodes. Contains support for scene hierarchy and attribute machinery.

Since:
0.11
See Also:
CSGCommonNode.java

Field Summary
protected  java.util.Map<java.lang.String,java.lang.Object> attr
          Attribute dictionary (hashing table of [key,value] pairs).
protected  int order
          Order in the parent node.
protected  SceneNode parent
          Handle of node's parent (or null for root-node).
protected  boolean root
          Root-property.
 
Fields inherited from class cz.cuni.jagrlib.DefaultSceneNode
serial
 
Fields inherited from interface cz.cuni.jagrlib.SceneNode
ATTR_BSSRDF, ATTR_COLOR, ATTR_TEXTURE
 
Constructor Summary
protected CSGCommonNode()
          Default initializing constructor.
 
Method Summary
 int assertAttributes(MicroFacet mf, java.lang.Object tmp, int attributes)
          Asserts validity of the given intersection-attributes.
 java.lang.Object getAttribute(java.lang.String key)
          Returns the given attribute (defined in this SceneNode or inherited from some parent node).
 java.util.List<java.lang.Object> getAttributes(java.lang.String key)
          Returns the whole inherence-sequence for the given attribute.
 int getOrder()
          Returns order of this SceneNode in its parent.
 SceneNode getParent()
          Returns the parent of this node.
 boolean isObjectRoot()
          Returns true if this node is root of object (component) hierarchy.
 boolean selfAttribute(java.lang.String key)
          Is the given attribute defined in the node itself or is it inherited?
 java.lang.Object setAttribute(java.lang.String key, java.lang.Object value)
          Defines the given attribute (key-value pair) in the node.
 void setObjectRoot(boolean root)
          Sets this node as root for the object (component).
 void setOrder(int ord)
          Sets order of this SceneNode in its parent.
 void setParent(SceneNode par)
          Sets handle to the parent node.
 
Methods inherited from class cz.cuni.jagrlib.DefaultSceneNode
getChild, getChildMatrix, getChildMatrixInv, getSerial, children, insertChild, intersection, removeChild, setSerial
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

attr

protected java.util.Map<java.lang.String,java.lang.Object> attr
Attribute dictionary (hashing table of [key,value] pairs).


parent

protected SceneNode parent
Handle of node's parent (or null for root-node).


order

protected int order
Order in the parent node.


root

protected boolean root
Root-property. Is this node root of object (component) hierarchy?

Constructor Detail

CSGCommonNode

protected CSGCommonNode()
Default initializing constructor.

Method Detail

getAttribute

public java.lang.Object getAttribute(java.lang.String key)
Returns the given attribute (defined in this SceneNode or inherited from some parent node).

Returned object can be an original data object and must not be altered outside this SceneNode instance.

Specified by:
getAttribute in interface SceneNode
Overrides:
getAttribute in class DefaultSceneNode
Parameters:
key - Key-string.
Returns:
Attribute object or null. Must not be altered!
See Also:
getAttributes(java.lang.String), setAttribute(java.lang.String, java.lang.Object), selfAttribute(java.lang.String)

selfAttribute

public boolean selfAttribute(java.lang.String key)
Is the given attribute defined in the node itself or is it inherited?

Specified by:
selfAttribute in interface SceneNode
Overrides:
selfAttribute in class DefaultSceneNode
Parameters:
key - Key-string.
Returns:
true if the node defines the given attribute.
See Also:
getAttribute(java.lang.String), setAttribute(java.lang.String, java.lang.Object), getAttributes(java.lang.String)

setAttribute

public java.lang.Object setAttribute(java.lang.String key,
                                     java.lang.Object value)
Defines the given attribute (key-value pair) in the node.

Specified by:
setAttribute in interface SceneNode
Overrides:
setAttribute in class DefaultSceneNode
Parameters:
key - Key-string.
value - Attribute value (arbitrary type).
Returns:
The old attribute value (defined in the node itself!) or null.
See Also:
getAttribute(java.lang.String), selfAttribute(java.lang.String), getAttributes(java.lang.String)

getAttributes

public java.util.List<java.lang.Object> getAttributes(java.lang.String key)
Returns the whole inherence-sequence for the given attribute.

Specified by:
getAttributes in interface SceneNode
Overrides:
getAttributes in class DefaultSceneNode
Parameters:
key - Key-string.
Returns:
List of attribute values: result[0] .. definition in the node itself, result[1] .. definition in parent node, result[2] .. definition in "grand-parent" node, etc.
See Also:
getAttribute(java.lang.String), setAttribute(java.lang.String, java.lang.Object), selfAttribute(java.lang.String)

getParent

public SceneNode getParent()
Returns the parent of this node.

Specified by:
getParent in interface SceneNode
Overrides:
getParent in class DefaultSceneNode
Returns:
The parend node or null for scene-root.
See Also:
setParent(cz.cuni.jagrlib.SceneNode), getOrder(), DefaultSceneNode.children(), DefaultSceneNode.getChild(int)

setParent

public void setParent(SceneNode par)
Sets handle to the parent node.

Specified by:
setParent in interface SceneNode
Overrides:
setParent in class DefaultSceneNode
Parameters:
par - Parent node (or null).
See Also:
getParent()

getOrder

public int getOrder()
Returns order of this SceneNode in its parent.

Specified by:
getOrder in interface SceneNode
Overrides:
getOrder in class DefaultSceneNode
Returns:
Order of this node as a child (or -1 for scene-root).
See Also:
setOrder(int), getParent()

setOrder

public void setOrder(int ord)
Sets order of this SceneNode in its parent.

Specified by:
setOrder in interface SceneNode
Overrides:
setOrder in class DefaultSceneNode
Parameters:
ord - The new order.
See Also:
getOrder()

isObjectRoot

public boolean isObjectRoot()
Returns true if this node is root of object (component) hierarchy.

Specified by:
isObjectRoot in interface SceneNode
Overrides:
isObjectRoot in class DefaultSceneNode
See Also:
setObjectRoot(boolean)

setObjectRoot

public void setObjectRoot(boolean root)
Sets this node as root for the object (component).

Specified by:
setObjectRoot in interface SceneNode
Overrides:
setObjectRoot in class DefaultSceneNode
Parameters:
root - Should this node be treated as root?
See Also:
isObjectRoot()

assertAttributes

public int assertAttributes(MicroFacet mf,
                            java.lang.Object tmp,
                            int attributes)
Asserts validity of the given intersection-attributes. Resolves: VALID_TO_WORLD, VALID_TO_OBJECT, VALID_TEXTURES, VALID_BRDF, VALID_MATERIAL, VALID_COLOR.

Specified by:
assertAttributes in interface IntersectionAttributes
Overrides:
assertAttributes in class DefaultSceneNode
Parameters:
mf - The checked intersection.
tmp - Non-mandatory object holding state-information for deferred computations.
attributes - Attribute mask (required attributes - see MicroFacet.VALID_*).
Returns:
Attributes which were not computed.