CShape Class Reference
 
 
 
CShape Class Reference

This reference page is linked to from the following overview topics: Softimage 2014.


#include <xsi_shape.h>


Class Description

A class representing primitive types for particles rendering. Shape objects are read-only and can be accessed with ICEAttribute properties such as ICEAttribute::GetDataArray and ICEAttribute::GetDataArray2D.

See also:
CDataArrayShape
Since:
7.0
Example:
This example shows how to access the shape attributes data from a cloud primitive.
                CValue CreatePrim( const CString& in_presetobj, const CString& in_geometrytype, const CString& in_name, const CString& in_parent )
                CRefArray ApplyOp( const CString& in_presetobj, CString & io_connectionset, const siConstructionMode& in_constructionmode );
                CValue AddICENode( const CValue&  in_presetobj, const CValue&  in_container );
                CValue SetValue( const CString& in_target, const CValue&  in_value, const CValue&  in_time = CValue() );
                void AddAttributeToSetDataICENode( const CValue&  in_setdatanode, const CString& in_attributename, siComponentDataType in_attributetype, siComponentDataContext in_attributecontext, siComponentDataStructure in_attributestructure );
                void ConnectICENodes( const CValue&  in_inputport, const CValue&  in_outputport );

                Application xsi;

                CreatePrim( L"Grid", L"PointCloud", L"", L"");

                Selection selection = xsi.GetSelection();
                X3DObject grid = selection[0];

                // Create shape reference types
                CString strGrid(L"grid");
                ApplyOp( L"ICETree", strGrid, siConstructionModeModeling );
                AddICENode( L"SetData", L"grid.pointcloud.ICETree");
                SetValue( L"grid.pointcloud.ICETree.SetData.PredefinedAttributeName", L"Shape", L"");
                AddAttributeToSetDataICENode(L"grid.pointcloud.ICETree.SetData", L"Shape", siComponentDataTypeShape, siComponentDataContextComponent0D, siComponentDataStructureSingle);
                SetValue(L"grid.pointcloud.ICETree.SetData.shape", 5, L"");
                ConnectICENodes(L"grid.pointcloud.ICETree.port1", L"grid.pointcloud.ICETree.SetData.set");
                AddICENode( L"InstanceShapeNode", L"grid.pointcloud.ICETree" );
                CreatePrim( L"Cylinder", L"MeshSurface", L"", L"" );
                SetValue( L"grid.pointcloud.ICETree.ShapeInstancingNode.Reference", L"cylinder", L"" );
                ConnectICENodes( L"grid.pointcloud.ICETree.SetData.shape", L"grid.pointcloud.ICETree.ShapeInstancingNode.shape" );
                ConnectICENodes( L"grid.pointcloud.ICETree.port2", L"grid.pointcloud.ICETree.SetData.set" );

                CRefArray attrs = grid.GetActivePrimitive().GetGeometry().GetICEAttributes();

                for( ULONG i = 0; i<attrs.GetCount(); i++ )
                {
                        ICEAttribute attr = attrs[i];

                        if ( attr.GetDataType() == XSI::siICENodeDataShape )
                        {
                                xsi.LogMessage( L"*******************************************************************" );
                                xsi.LogMessage( L"Name: " + attr.GetName() );
                                xsi.LogMessage( L"DataType: " + CString(attr.GetDataType()) );
                                xsi.LogMessage( L"StructType: " + CString(attr.GetStructureType()) );
                                xsi.LogMessage( L"ContextType: " + CString(attr.GetContextType()) );
                                xsi.LogMessage( L"IsConstant: " + CString(attr.IsConstant()) );
                                xsi.LogMessage( L"Readonly: " + CString(attr.IsReadonly()) );
                                xsi.LogMessage( L"Category: " + CString(attr.GetAttributeCategory()) );
                                xsi.LogMessage( L"Element count: " + CString(attr.GetElementCount()) );

                                CICEAttributeDataArray< XSI::MATH::CShape > data;
                                attr.GetDataArray( data );

                                for( ULONG i=0; i<data.GetCount( ); i++ )
                                {
                                        xsi.LogMessage( CString( data[ i ] ) );
                                }
                        }
                }

                // %This example shows how to access the shape attributes data from a cloud primitive by using GetDataArrayChunk.
                ULONG nChunkCount = 4;
                for( ULONG i = 0; i<attrs.GetCount(); i++ )
                {
                        ICEAttribute attr = attrs[i];

                        if ( attr.GetDataType() != XSI::siICENodeDataShape )
                        {
                                continue;
                        }

                        xsi.LogMessage( L"*******************************************************************" );

                        //      Compute the chunk vector to access the data
                        ULONG nChunkSize = attr.GetElementCount() / nChunkCount;
                        ULONG nLastChunk = attr.GetElementCount()  % nChunkCount;

                        CLongArray nChunks;
                        for( ULONG iChunk = 0; iChunk < nChunkCount; iChunk++ )
                        {
                                nChunks.Add( nChunkSize );
                        }
                        nChunks.Add( nLastChunk );

                        ULONG nOffset = 0;
                        for ( ULONG j=0; j<nChunks.GetCount(); j++ )
                        {
                                ULONG nChunkSize = nChunks[j];
                                if ( nChunkSize == 0 )
                                {
                                        continue;
                                }

                                CICEAttributeDataArray< XSI::MATH::CShape > data;
                                attr.GetDataArrayChunk( nOffset, nChunkSize, data );

                                xsi.LogMessage( L"Chunk size: " + CString(data.GetCount( )) );
                                for( ULONG i=0; i<data.GetCount( ); i++ )
                                {
                                        xsi.LogMessage( CString( data[ i ] ) );
                                }

                                nOffset += nChunkSize;
                        }
                }

                // Helpers
                CValue CreatePrim( const CString& in_presetobj, const CString& in_geometrytype, const CString& in_name, const CString& in_parent )
                {
                        CValueArray args(4);
                        CValue retval;
                        args[0]= in_presetobj;
                        args[1]= in_geometrytype;
                        args[2]= in_name;
                        args[3]= in_parent;

                        Application app;
                        app.ExecuteCommand( L"CreatePrim", args, retval );
                        return retval;
                }

                CRefArray ApplyOp( const CString& in_presetobj, CString & io_connectionset, const siConstructionMode& in_constructionmode )
                {
                        CValueArray args(6);
                        CValue retval;

                        args[0]=in_presetobj;
                        args[1]=io_connectionset;
                        args[2]=(LONG)siUnspecified;
                        args[3]=(LONG)siPersistentOperation;
                        if ( in_constructionmode != siConstructionModeDefault )
                        {
                                args[5]=(LONG)in_constructionmode;
                        }

                        Application app;
                        CStatus st = app.ExecuteCommand( L"ApplyOp", args, retval );
                        io_connectionset=args[1];
                        return retval;
                }

                CValue AddICENode( const CValue&  in_presetobj, const CValue&  in_container )
                {
                        CValueArray args(2);
                        CValue retval;

                        args[0]= in_presetobj;
                        args[1]= in_container;

                        Application app;
                        CStatus st = app.ExecuteCommand( L"AddICENode", args, retval );

                        return retval;
                }

                void AddAttributeToSetDataICENode( const CValue&  in_setdatanode, const CString& in_attributename, siComponentDataType in_attributetype, siComponentDataContext in_attributecontext, siComponentDataStructure in_attributestructure )
                {
                        CValueArray args(5);
                        CValue retval;

                        args[0]= in_setdatanode;
                        args[1]= in_attributename;
                        args[2]= (LONG)in_attributetype;
                        args[3]= (LONG)in_attributecontext;
                        args[4]= (LONG)in_attributestructure;

                        Application app;
                        CStatus st = app.ExecuteCommand( L"AddAttributeToSetDataICENode", args, retval );

                        return;
                }

                void ConnectICENodes( const CValue&  in_inputport, const CValue&  in_outputport )
                {
                        CValueArray args(2);
                        CValue retval;

                        args[0]= in_inputport;
                        args[1]= in_outputport;

                        Application app;
                        CStatus st = app.ExecuteCommand( L"ConnectICENodes", args, retval );

                        return;
                }

                CValue SetValue( const CString& in_target, const CValue& in_value, const CValue&  in_time )
                {
                        CValueArray args(3);
                        CValue retval;

                        args[0]= in_target;
                        args[1]= in_value;
                        args[2]= in_time;

                        Application app;

                        CStatus st = app.ExecuteCommand( L"SetValue", args, retval );

                        return retval;
                }

List of all members.

Classes

struct   ParameterInstance
  A struct to hold the parameters for a shape instance. More...
struct   ParameterReference
  A struct to hold the parameters for a shape reference. More...

Public Member Functions

  CShape (XSI::siICEShapeType in_type=XSI::siICEShapePoint)
  CShape (const CShape &in_shape)
  ~CShape ()
CShape operator= (const CShape &in_shape)
XSI::siICEShapeType  GetType ()
ULONG  GetReferenceID ()
bool  IsBranchSelected ()
bool  operator== (const CShape &in_shape) const
void  SetAsInstance (ULONG in_instanceIndex)
void  SetAsReference (ULONG in_objectId, bool in_branch)
void  SetAsTrivial (XSI::siICEShapeType in_trivialType)
XSI::siICEShapeType  GetType () const
const ParameterReference GetReferenceDescription () const
  Get the reference shape description.
const ParameterInstance GetInstanceDescription () const
  Get the instance shape description.

Constructor & Destructor Documentation

CShape ( XSI::siICEShapeType  in_type = XSI::siICEShapePoint ) [inline]

Constructor. Creates a new object based on the specified shape type.

Parameters:
in_type Type of particle shape to create
CShape ( const CShape in_shape ) [inline]

Copy constructor. Creates a new object as a CShape type.

Parameters:
in_shape CShape object.
~CShape ( ) [inline]

Destructor.


Member Function Documentation

CShape& operator= ( const CShape in_shape ) [inline]

Assignment operator.

Parameters:
in_shape Shape to copy
Returns:
A reference to this shape.
XSI::siICEShapeType GetType ( ) [inline]

Returns the shape type.

Returns:
One of the siICEShapeType enum values representing the shape type.
ULONG GetReferenceID ( ) [inline]

Returns the object ID the shape is referring to. Applies only to the siICEShapeReference shape type. The returned ID can be used to access the object with Application::GetObjectFromID.

Returns:
Object ID.
bool IsBranchSelected ( ) [inline]

Returns true if the referenced object is set as branch-selected. Applies to siICEShapeReference shape types only.

Returns:
True if branch selected, false otherwise.
bool operator== ( const CShape in_shape ) const [inline]

Equality operator tests the strict equality of this shape with the specified shape.

Parameters:
in_shape Operand CShape.
Returns:
true if equal else false.
void SetAsInstance ( ULONG  in_instanceIndex ) [inline]

Set as shape instance

Parameters:
in_instanceIndex Instance index
in_rbdType Type for Rigid Body Dynamics
Since:
12.0 (2014)
void SetAsReference ( ULONG  in_objectId,
bool  in_branch 
) [inline]

Set as shape reference

Parameters:
in_objectId Object Id
in_branch Branch
in_rbdType Type for Rigid Body Dynamics
Since:
12.0 (2014)
void SetAsTrivial ( XSI::siICEShapeType  in_trivialType ) [inline]

Set as trivial shape type

Parameters:
in_trivialType Trivial type
Since:
12.0 (2014)
XSI::siICEShapeType GetType ( ) const [inline]

Returns the shape type.

Returns:
One of the siICEShapeType enum values representing the shape type.

The documentation for this class was generated from the following file: