.. _group__a3d__feature__tree__module:

############
Feature Tree
############

CAD model are represented by a feature tree.

A model tree is composed by nodes. Each of these nodes is a build step, whose definition parameters are stored in a feature. The following model is defined with construction entities, then a pad, and a hole.

The model trees are accessible through the product occurrence by using the function :c:func:`~A3DAsmProductOccurrenceGet`\ , and the function :c:func:`~A3DFRMTreeGet`\ will populate the data structure. An array of feature trees is stored in :c:struct:`~A3DAsmProductOccurrenceData`\ , usually there is only one feature tree by model.


::

   A3DUns32u;
   A3DAsmProductOccurrenceDatasData=A3D_MAKE_DATA(A3DAsmProductOccurrenceData);
   if(A3DAsmProductOccurrenceGet(pOccurrence,&sData)==A3D_SUCCESS)
   {
   for(u=0;u<sData.m_uiFeatureBasedEntitiesSize;++u)
   {
   A3D_INITIALIZE_DATA(A3DFRMTreeData,sTreeData);
   A3DFRMTreeGet(sData.m_ppFeatureBasedEntities[u],&sTreeData);
   //...
   A3DFRMTreeGet(A3D_NULL_HANDLE,&sTreeData);
   }
   A3DAsmProductOccurrenceGet(A3D_NULL_HANDLE,&sData);
   }

In addition, the function :c:func:`~A3DFRMGetSpecificNodes`\ allows to directly get a list of features with a specific cad type. For instance, to get all features HOLE defined in the tree. In this case,


::

   A3DUns32iSize;
   A3DFRMFeature**ppFeatureNodes;
   A3DFRMGetSpecificNodes(pFRMFeatureTree,kA3DFRMEnumValue_CadType_Hole,&iSize,&ppFeatureNodes);
   //...
   A3DFRMGetSpecificNodes(A3D_NULL_HANDLE,kA3DFRMEnumValue_CadType_Hole,&iSize,&ppFeatureNodes);

Note that :c:type:`~A3DFRMTree`\ object is an abstraction of :c:type:`~A3DRiSet`\ , so it possible to directly call the function :c:func:`~A3DFRMTreeGet`\ on a set


::

   A3DEEntityTypeeType=kA3DTypeUnknown;
   A3DEntityGetType(pRepresentationItem,&eType);
   if(eType==kA3DTypeRiSet)
   {
   A3DFRMTreeDataoData=A3D_MAKE_DATA(A3DFRMTreeData);
   if(A3DFRMTreeGet(pRepresentationItem,&sTreeData)==A3D_SUCCESS)
   {
   A3DFRMTreeGet(A3D_NULL_HANDLE,&sTreeData);
   }
   else
   {
   //regularRiSet
   }
   }

**Parameters**


   **pTree**\ : The feature tree to query features from.

   **eCADType**\ : CAD type of feature (Hole, Pattern, ...).

   **piSize**\ : The number of feature founds. Corresponds to the size of pppFeatureNodes.

   **pppFeatureNodes**\ : An array of size piSize containing the found features (Hole, Pattern, ...).


**Returns**


   ``A3D_SUCCESS``\ on success, or an error code on failure


.. rst-class:: kind-group kind-record

.. rubric:: Structures
   :class: kind-group-title


.. rst-class:: api-xref-list


* :c:struct:`~A3DFRMTreeData`

.. rst-class:: kind-group kind-enumeration

.. rubric:: Enumerations
   :class: kind-group-title


.. rst-class:: api-xref-list


* :c:enum:`~A3DEFRMEnumValue_ModeType`

.. rst-class:: kind-group kind-function

.. rubric:: Functions
   :class: kind-group-title


.. rst-class:: api-xref-list


* :c:func:`~A3DFRMTreeGet`
* :c:func:`~A3DFRMGetSpecificNodes`

.. toctree::
   :maxdepth: 1
   :hidden:

   ../structures/A3DFRMTreeData
   ../functions/A3DFRMTreeGet
   ../functions/A3DFRMGetSpecificNodes
   ../enums/A3DEFRMEnumValue_ModeType


