de.grogra.mtg
Class MTGRoot

java.lang.Object
  extended by de.grogra.graph.impl.Edge
      extended by de.grogra.graph.impl.Node
          extended by de.grogra.imp3d.objects.Null
              extended by de.grogra.imp3d.objects.ShadedNull
                  extended by de.grogra.imp3d.objects.AxisBase
                      extended by de.grogra.turtle.TurtleStep
                          extended by de.grogra.turtle.Shoot
                              extended by de.grogra.turtle.F
                                  extended by de.grogra.mtg.MTGNode
                                      extended by de.grogra.mtg.MTGRoot
All Implemented Interfaces:
Transformation, VertexSequence.Vertex, Renderable, Manageable, PersistenceCapable, Shareable, UserFields, XObject, TurtleModifier, Map, java.io.Serializable

public class MTGRoot
extends MTGNode
implements Renderable

Class representing an MTG. Contents are in HashMap retrievable by keys specified in section "//MTGNode contents" of MTGKeys.java.

Since:
2012-02-01
Author:
yong
See Also:
MTGKeys, Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class de.grogra.turtle.F
F.Pattern
 
Nested classes/interfaces inherited from class de.grogra.graph.impl.Node
Node.AccessorBridge, Node.FieldAttributeAccessor, Node.NType
 
Nested classes/interfaces inherited from interface de.grogra.util.Map
Map.Chain
 
Field Summary
static Node.NType $TYPE
           
static Node.NType.Field dist$FIELD
           
protected  PolygonMesh polygons
           
protected  int visibleSides
           
static Node.NType.Field visibleSides$FIELD
           
 
Fields inherited from class de.grogra.mtg.MTGNode
AA, AA$FIELD, Alpha, Alpha$FIELD, Azimut, Azimut$FIELD, BB, BB$FIELD, BotDia, BotDia$FIELD, Category, Category$FIELD, CC, CC$FIELD, DAB, DAB$FIELD, DAC, DAC$FIELD, dataFlag, dataFlag$FIELD, DBC, DBC$FIELD, DirectionPrimary, DirectionPrimary$FIELD, L1, L1$FIELD, L2, L2$FIELD, L3, L3$FIELD, Length, Length$FIELD, mtgClass, mtgClass$FIELD, mtgClassID, mtgClassID$FIELD, mtgID, mtgID$FIELD, mtgScale, mtgScale$FIELD, Order, Order$FIELD, Position, Position$FIELD, stdAttFlag, stdAttFlag$FIELD, TopDia, TopDia$FIELD, XX, XX$FIELD, YY, YY$FIELD, ZZ, ZZ$FIELD
 
Fields inherited from class de.grogra.turtle.F
color, color$FIELD, diameter, diameter$FIELD, length, length$FIELD
 
Fields inherited from class de.grogra.turtle.Shoot
localRegisters$FIELD
 
Fields inherited from class de.grogra.imp3d.objects.AxisBase
SCALE_V_MASK, scaleV$FIELD, USED_BITS
 
Fields inherited from class de.grogra.imp3d.objects.ShadedNull
INFINITE_MASK, interior, interior$FIELD, shader, shader$FIELD, treatedAsInfinite$FIELD
 
Fields inherited from class de.grogra.imp3d.objects.Null
transform, transform$FIELD, TRANSFORMING_MASK, transforming$FIELD
 
Fields inherited from class de.grogra.graph.impl.Node
ADDITIONAL_FIELDS, bits, DELETED, EXTENT_BIT, EXTENT_MASK, extentIndex$FIELD, extentTail$FIELD, HAS_OBSERVERS, IS_INTERPRETIVE, isInterpretive$FIELD, LAST_EXTENT_INDEX, layer$FIELD, MARK, mark$FIELD, MIME_TYPE, MIN_UNUSED_SPECIAL_OF_SOURCE, MIN_UNUSED_SPECIAL_OF_TARGET, name$FIELD
 
Fields inherited from interface de.grogra.util.Map
DEFAULT_VALUE, EMPTY_MAP
 
Constructor Summary
MTGRoot()
           
 
Method Summary
 void changeBenchmark(Vector3d ori, Vector3d u, Vector3d v, Vector3d w)
           
 int classScale(java.lang.String classSymbol)
          Returns scale of a given class
 int[] classSymbolsToClassIndices(java.lang.String[] classSymbols)
           
 int classSymbolToClassIndex(java.lang.String classSymbol)
           
 Matrix4d combinePriSecRotation(double x, double y, double z, double x2, double y2, double z2)
           
 int compoFather(int nodeIndex)
          Nodes - Returns refinement father of the specified node.
 MTGNode compoFather(MTGNode node)
          Nodes - Returns refinement father of the specified node.
 int[] compoSonsIds(int nodeIndex)
          Nodes - Returns refinement sons of the specified node.
 int[] compoSonsIds(int nodeIndex, int scale)
          Returns compositional sons of a node, given that the compositional sons are of a lower scale than the given scale.
 void deleteNodeList()
           
 void draw(java.lang.Object object, boolean asNode, RenderState rs)
           
 int edgeType(int sourceIndex, int targetIndex)
          Nodes - Get the edge bits (int) between a source node and a target node.
 int findLocalTopoRoot(int startv, int etype)
          Find root(first node) of the compositional group node 'startv' belongs to.
 java.util.ArrayList<MTGBranch> getBranches()
          Branches - Get the branches or plant frame.
 int getBranchesCount()
          Branches - Get number of branches.
 java.util.ArrayList<MTGNodeDataClasses> getClassesInfo()
          Classes - Returns information of MTG classes defined.
 MTGNodeData getData()
           
 java.util.ArrayList<MTGNodeDataFeature> getFeaturesInfo()
          Features - Returns information of MTG features defined.
 int getIndex(MTGNode node)
          Nodes - Returns index of MTGNode given its instance.
 MTGNode getNode(int nodeIndex)
          Nodes - Returns MTGNode instance given its index.
protected  Node.NType getNTypeImpl()
          This method returns the Node.NType which describes the managed fields of the class of this node.
 java.lang.Object getObject(java.lang.String key)
           
 int getPlantCount()
          Plant - Gets the number of plants recognized in this MTG so far.
 PolygonMesh getPolygons()
           
 int[] getRootIds(int scale)
          Obtain a list of indices of root nodes refined the specified node.
 MTGNode[] getRoots(int scale)
           
 int getScale(int nodeIndex)
          Nodes - Returns scale of node at index specified.
 int height(MTGNode startNode, MTGNode endNode)
          Number of successor or branch edges from a start node to an end node.
 void incrementPlantCount()
          Plant - Increment the counter for the number of plants specified in this MTG.
 int mtgType()
          Coordinates - Get the MTG geometric reference system type.
protected  Node newInstance()
          This method returns a new instance of the class of this node.
 int pathLength(int father, int vertex, int edge)
           
 void plantFrame(int scale, double dist)
          Computes the frame of the plant at the specified scale.
 void plantFrameDelete(int scale)
           
 void refreshNodeIndices()
          Refreshes cached node list.
 void removeInterScaleTopoRelations()
          Removes inter-scale topological relations (i.e. successor and branching edges).
 MTGBranchElement searchForElement(int nodeIndex)
          Branches - Returns branch element that corresponds to the node of the given index.
 void setData(MTGNodeData data)
           
 void setElevationAzimuth(Vector3d vec, double ele, double azi)
           
 void setObject(java.lang.String key, java.lang.Object obj)
           
 void setPolygons(PolygonMesh mesh)
           
 int topoFather(int nodeIndex, int edgeType)
          Nodes - Returns index of node that is topological father of node specified by input nodeIndex.
 int[] topoSons(int nodeIndex, int edgeType)
          Nodes - For usage by root MTG node.
 
Methods inherited from class de.grogra.mtg.MTGNode
compoFather, compoSons, compoSonsCount, compoSonsIds, copyStdAttributes, findAdjacentMTG, getLength, getOrder, getType, hasAA, hasAlpha, hasAzimut, hasBB, hasBotDia, hasCategory, hasCC, hasDAB, hasDAC, hasDBC, hasDirectionPrimary, hasL1, hasL2, hasL3, hasLength, hasOrder, hasPosition, hasStdAtt, hasTopDia, hasXX, hasYY, hasZZ, height, order, setDirectoryPrimary, setStdAttFlagOff, setStdAttFlagOn, topoSonNodes, topoSons
 
Methods inherited from class de.grogra.turtle.F
getFloat, getInt, getLength
 
Methods inherited from class de.grogra.turtle.Shoot
execute, getBoolean, getLocalRegisters, getObject, getSymbolColor, getVertexTransformation, setLocalRegisters
 
Methods inherited from class de.grogra.turtle.TurtleStep
getDouble, postTransform
 
Methods inherited from class de.grogra.imp3d.objects.AxisBase
isScaleV, setScaleV
 
Methods inherited from class de.grogra.imp3d.objects.ShadedNull
getInterior, getShader, isTreatedAsInfinite, setBackShader, setColor, setColor, setFrontShader, setInterior, setMaterial, setShader, setShaders, setTreatedAsInfinite
 
Methods inherited from class de.grogra.imp3d.objects.Null
getLocalTransformation, getTransform, getTranslation, isTransforming, preTransform, setRotation, setScale, setTransform, setTransform, setTransform, setTransform, setTransform, setTransform, setTransform, setTransform, setTransforming, setTranslation
 
Methods inherited from class de.grogra.graph.impl.Node
addEdgeBitsTo, addReference, appendBranchNode, appendBranchNode, appendReferencesTo, clone, clone, cloneGraph, dump, dumpTree, dup, dupUnmanagedFields, edgeChanged, fieldModified, findAdjacent, get, getAccessor, getAccessor, getAttributes, getAxisParent, getBranch, getBranchLength, getBranchNode, getBranchTail, getByte, getChar, getCommonAncestor, getCurrentGraphState, getDirectChildCount, getEdgeAttributeAccessor, getEdgeAttributes, getEdgeBitsTo, getEdgeTo, getExtentIndex, getFirst, getFirstEdge, getGraph, getId, getIndex, getInstantiator, getLayer, getLong, getManageableType, getName, getNeighbor, getNext, getNType, getOrCreateEdgeTo, getOrNull, getPersistenceManager, getPredecessor, getProvider, getShort, getSource, getStamp, getSuccessor, getSymbol, getTarget, getTransaction, getUserField, getUserFieldCount, getXClass, getXData, hasName, initProvider, initXClass, insertBranchNode, insertBranchNode, instantiateGraph, isAncestorOf, isDirection, isManagingInstance, isMarked, isRoot, isSource, isTarget, manageableReadResolve, manageableWriteReplace, paramString, removeAll, removeEdgeBitsTo, removeFromChain, removeFromChain, removeReference, setBranch, setBranch, setExtentIndex, setGraphForDeserialization, setLayer, setMark, setName, setSuccessor, setSuccessor, specialEdgeAdded, specialEdgeRefModified, specialEdgeRemoved, toString, writeReplace
 
Methods inherited from class de.grogra.graph.impl.Edge
addEdgeBits, getBitMark, getEdgeBits, getObjectMark, getSpecialEdgeDescriptor, parseEdgeKeys, remove, removeEdgeBits, setBitMark, setEdgeBits, setObjectMark, testEdgeBits
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface de.grogra.persistence.PersistenceCapable
getBitMark, getObjectMark, setBitMark, setObjectMark
 

Field Detail

$TYPE

public static final Node.NType $TYPE

dist$FIELD

public static final Node.NType.Field dist$FIELD

polygons

protected PolygonMesh polygons

visibleSides

protected int visibleSides

visibleSides$FIELD

public static final Node.NType.Field visibleSides$FIELD
Constructor Detail

MTGRoot

public MTGRoot()
Method Detail

changeBenchmark

public void changeBenchmark(Vector3d ori,
                            Vector3d u,
                            Vector3d v,
                            Vector3d w)

classScale

public int classScale(java.lang.String classSymbol)
Returns scale of a given class

Parameters:
classSymbol -
Returns:

classSymbolsToClassIndices

public int[] classSymbolsToClassIndices(java.lang.String[] classSymbols)

classSymbolToClassIndex

public int classSymbolToClassIndex(java.lang.String classSymbol)

combinePriSecRotation

public Matrix4d combinePriSecRotation(double x,
                                      double y,
                                      double z,
                                      double x2,
                                      double y2,
                                      double z2)

compoFather

public int compoFather(int nodeIndex)
Nodes - Returns refinement father of the specified node.

Parameters:
nodeIndex -
Returns:
index of refinement father node.

compoFather

public MTGNode compoFather(MTGNode node)
Nodes - Returns refinement father of the specified node.

Parameters:
nodeIndex -
Returns:
index of refinement father node.

compoSonsIds

public int[] compoSonsIds(int nodeIndex)
Nodes - Returns refinement sons of the specified node.

Parameters:
nodeIndex -
Returns:
indices of refinement son nodes.

compoSonsIds

public int[] compoSonsIds(int nodeIndex,
                          int scale)
                   throws MTGError.MTGPlantFrameException
Returns compositional sons of a node, given that the compositional sons are of a lower scale than the given scale.

Parameters:
nodeIndex -
scale -
Returns:
Throws:
MTGError.MTGPlantFrameException

deleteNodeList

public void deleteNodeList()

draw

public void draw(java.lang.Object object,
                 boolean asNode,
                 RenderState rs)
Specified by:
draw in interface Renderable

edgeType

public int edgeType(int sourceIndex,
                    int targetIndex)
Nodes - Get the edge bits (int) between a source node and a target node.

Parameters:
sourceIndex -
targetIndex -
Returns:
edge type

findLocalTopoRoot

public int findLocalTopoRoot(int startv,
                             int etype)
                      throws MTGError.MTGPlantFrameException
Find root(first node) of the compositional group node 'startv' belongs to.

Parameters:
startv -
etype -
Returns:
Throws:
MTGError.MTGPlantFrameException

getBranches

public java.util.ArrayList<MTGBranch> getBranches()
Branches - Get the branches or plant frame.

Returns:
List of branches.

getBranchesCount

public int getBranchesCount()
Branches - Get number of branches.

Returns:
Number of branches

getClassesInfo

public java.util.ArrayList<MTGNodeDataClasses> getClassesInfo()
                                                       throws MTGError.MTGPlantFrameException
Classes - Returns information of MTG classes defined.

Returns:
List of class information
Throws:
MTGError.MTGPlantFrameException

getData

public MTGNodeData getData()

getFeaturesInfo

public java.util.ArrayList<MTGNodeDataFeature> getFeaturesInfo()
                                                        throws MTGError.MTGPlantFrameException
Features - Returns information of MTG features defined.

Returns:
List of feature information.
Throws:
MTGError.MTGPlantFrameException

getIndex

public int getIndex(MTGNode node)
Nodes - Returns index of MTGNode given its instance.

Parameters:
node -
Returns:
index of node.

getNode

public MTGNode getNode(int nodeIndex)
Nodes - Returns MTGNode instance given its index.

Parameters:
nodeIndex -
Returns:
MTGNode at specified index

getNTypeImpl

protected Node.NType getNTypeImpl()
Description copied from class: Node
This method returns the Node.NType which describes the managed fields of the class of this node. This method has to be implemented in every concrete subclass.

Overrides:
getNTypeImpl in class MTGNode
Returns:
type describing the managed fields of the class of this node

getObject

public java.lang.Object getObject(java.lang.String key)

getPlantCount

public int getPlantCount()
                  throws MTGError.MTGPlantFrameException
Plant - Gets the number of plants recognized in this MTG so far.

Returns:
Number of plants recognized in this MTG so far.
Throws:
MTGError.MTGPlantFrameException

getPolygons

public PolygonMesh getPolygons()

getRootIds

public int[] getRootIds(int scale)
                 throws MTGError.MTGPlantFrameException
Obtain a list of indices of root nodes refined the specified node.

Parameters:
scale -
Returns:
List if indices of root nodes.
Throws:
MTGError.MTGPlantFrameException

getRoots

public MTGNode[] getRoots(int scale)
                   throws MTGError.MTGPlantFrameException
Throws:
MTGError.MTGPlantFrameException

getScale

public int getScale(int nodeIndex)
             throws MTGError.MTGPlantFrameException
Nodes - Returns scale of node at index specified.

Parameters:
nodeIndex -
Returns:
Scale of node.
Throws:
MTGError.MTGPlantFrameException

height

public int height(MTGNode startNode,
                  MTGNode endNode)
           throws MTGError.MTGPlantFrameException
Number of successor or branch edges from a start node to an end node.

Parameters:
startNodeId -
endNodeId -
Returns:
Throws:
MTGError.MTGPlantFrameException

incrementPlantCount

public void incrementPlantCount()
                         throws MTGError.MTGPlantFrameException
Plant - Increment the counter for the number of plants specified in this MTG.

Throws:
MTGError.MTGPlantFrameException

mtgType

public int mtgType()
            throws MTGError.MTGPlantFrameException
Coordinates - Get the MTG geometric reference system type.

Returns:
MTG Type
Throws:
MTGError.MTGPlantFrameException

newInstance

protected Node newInstance()
Description copied from class: Node
This method returns a new instance of the class of this node. This method has to be implemented in every concrete subclass.

Overrides:
newInstance in class MTGNode
Returns:
new instance of class of this node

pathLength

public int pathLength(int father,
                      int vertex,
                      int edge)

plantFrame

public void plantFrame(int scale,
                       double dist)
                throws MTGError.MTGPlantFrameException
Computes the frame of the plant at the specified scale. For a static situation only. The frame of the plant is a collection of branches. The branch elements contain a top diameter, bottom diameter, length, positional coordinates and directional coordinates. Root nodes are nodes without topological parents, i.e. no father node with successor or branching edge to them.

Parameters:
scale -
Throws:
MTGError.MTGPlantFrameException

plantFrameDelete

public void plantFrameDelete(int scale)

refreshNodeIndices

public void refreshNodeIndices()
                        throws MTGError.MTGPlantFrameException
Refreshes cached node list. At the same time reassigns id to the nodes. The plant frame computation is dependent on the cached node list and id of the nodes. This cached list is cleared from memory at the end of method plantFrame.

Throws:
MTGError.MTGPlantFrameException

removeInterScaleTopoRelations

public void removeInterScaleTopoRelations()
                                   throws MTGError.MTGPlantFrameException
Removes inter-scale topological relations (i.e. successor and branching edges).

Throws:
MTGError.MTGPlantFrameException

searchForElement

public MTGBranchElement searchForElement(int nodeIndex)
Branches - Returns branch element that corresponds to the node of the given index.

Parameters:
nodeIndex -
Returns:
MTGBranchElement

setData

public void setData(MTGNodeData data)

setElevationAzimuth

public void setElevationAzimuth(Vector3d vec,
                                double ele,
                                double azi)

setObject

public void setObject(java.lang.String key,
                      java.lang.Object obj)

setPolygons

public void setPolygons(PolygonMesh mesh)

topoFather

public int topoFather(int nodeIndex,
                      int edgeType)
Nodes - Returns index of node that is topological father of node specified by input nodeIndex.

Parameters:
nodeIndex -
edgeType -
Returns:
index of topological father node

topoSons

public int[] topoSons(int nodeIndex,
                      int edgeType)
Nodes - For usage by root MTG node. To find the topological sons of the node found in list of nodes at specified nodeIndex.

Parameters:
nodeIndex -
edgeType -
Returns:
indices of topological son nodes.