# Geometry Info

## Summary

Below is an example demonstrating the use of the geometry pipeline to inspect information about the geometry for a node.

## Example

Geometry_Info.dsa
```// Define an anonymous function;
// serves as our main loop,
// limits the scope of variables
(function(){

/*********************************************************************/
// DzNode : A function for getting the root of a node
function getRootNode( oNode )
{
// If a node is selected and it is a bone
if( oNode && oNode.inherits( "DzBone" ) ){
// We want the skeleton
return oNode.getSkeleton();
}

// Return the original node
return oNode;
};

/*********************************************************************/
// DzObject : A function for getting the object for the root of a node
function getObjectForRootNode( oNode )
{
// Get the root node
var oRootNode = getRootNode( oNode );
// If we don't have a root node
if( !oRootNode ){
// We're done...
return null;
}

// Get the object of the root node
var oObject = oRootNode.getObject();
// If we don't have an object
if( !oObject ){
// We're done...
return null;
}

// Return the object
return oObject;
};

/*********************************************************************/
// DzShape : A function for getting the shape for the root of a node
function getShapeForRootNode( oNode )
{
// Get the object of the root node
var oObject = getObjectForRootNode( oNode );
// If we don't have an object
if( !oObject ){
// We're done...
return null;
}

// Get the shape of the root node
var oShape = oObject.getCurrentShape();
// If we don't have a shape
if( !oShape ){
// We're done...
return null;
}

// Return the shape
return oShape;
};

/*********************************************************************/
// DzGeometry : A function for getting the geometry for the root of a node
function getGeometryForRootNode( oNode )
{
// Get the shape of the root node
var oShape = getShapeForRootNode( oNode );
// If we don't have a shape
if( !oShape ){
// We're done...
return null;
}

// Get the geometry of the root node
var oGeometry = oShape.getGeometry();
// If we don't have a geometry
if( !oGeometry ){
// We're done...
return null;
}

// Return the geometry
return oGeometry;
};

/*********************************************************************/
// DzFacetMesh : A function for getting the facet mesh for the root of a node
function getFacetMeshForRootNode( oNode )
{
// Get the geometry of the root node
var oGeometry = getGeometryForRootNode( oNode );
// If we don't have a facet mesh
if( !oGeometry.inherits("DzFacetMesh") ){
// We're done...
return null;
}

// Return the geometry
return oGeometry;
};

/*********************************************************************/
// void : A method to print geometry information for a node
function printNodeGeometry( oNode )
{
// Get the facet mesh of the root node
var oMesh = getFacetMeshForRootNode( oNode );
// If we don't have a facet mesh
if( !oMesh ){
// We're done...
return;
}

// Declare working variable
var oFacet;

// Get the number of facets
var nFacets = oMesh.getNumFacets();
// Iterate over the facets
for( var i = 0; i < nFacets; i += 1 ){
// Get the 'current' facet
oFacet = oMesh.getFacet( i );

print( String("Facet #%1").arg(i) );

print( String("\tVertex Indices: [%1, %2, %3, %4]")
.arg( oFacet.vertIdx1 )
.arg( oFacet.vertIdx2 )
.arg( oFacet.vertIdx3 )
.arg( oFacet.vertIdx4 )// will be -1 for triangles
);

print( String("\tNormal Indices: [%1, %2, %3, %4]")
.arg( oFacet.normIdx1 )
.arg( oFacet.normIdx2 )
.arg( oFacet.normIdx3 )
.arg( oFacet.normIdx4 )// will be -1 for triangles
);

print( String("\tUVW Indices: [%1, %2, %3, %4]")
.arg( oFacet.uvwIdx1 )
.arg( oFacet.uvwIdx2 )
.arg( oFacet.uvwIdx3 )
.arg( oFacet.uvwIdx4 )// will be -1 for triangles
);
}
};

/*********************************************************************/
// Get the primary selection
var oNode = Scene.getPrimarySelection();
// If nothing is selected
if( !oNode ){
// We're done...
return;
}

// Print geometry information
printNodeGeometry( oNode );

// Finalize the function and invoke
})();```