:orphan:

###############
STEP/XML Reader
###############

.. rst-class:: format-title-block

+--------------------------------------------------------------------+
|              **STEP/XML**                                          |
+-------------------------------------+------------------------------+
| **File Extension**:                 | STPX, STPXZ                  |
+-------------------------------------+------------------------------+
| **Supported Versions**              | Any                          |
+-------------------------------------+------------------------------+
| **Platforms**                       | |wy| |ly| |my| |ay| |iy|     | 
+-------------------------------------+------------------------------+
| :ref:`stp_xml_rd_tessellation`      | |c_green| Supported          |
+-------------------------------------+------------------------------+
| :ref:`stp_xml_rd_brep`              | |c_green| Supported          |
+-------------------------------------+------------------------------+
| PMI                                 | |c_green| Supported          |
+-------------------------------------+------------------------------+

STEP/XML is an XML specification used to represent EXPRESS schemas such as :doc:`STEP <step_reader>`.
STEP/XML is standardized under the name `ISO_10303-28 <https://en.wikipedia.org/wiki/ISO_10303-28>`__.

HOOPS Exchange allows you to read STEP/XML files.
Generally such files will have these extensions:

* `.STPX` for uncompressed text files
* `.STPXZ` for compressed binary files

HOOPS Exchange geometry access for STEP/XML includes:

* **B-rep:** Access to exact geometry where present in the source file.
* **Tessellation:** Can be generated by HOOPS Exchange for visualization.


How to Read a STEP/XML File
===========================

.. admonition:: Note

   If you are new to reading models with HOOPS Exchange, see the :doc:`basic load workflow </guide/basic_operations/load_model>` section of the Programming Guide.

To create an :func:`A3DAsmModelFile` from a STEP/XML file, use our standard read functions:

.. code-block:: c

   // ... Initialize HOOPS Exchange ...
   A3DRWParamsLoadData sParams;
   A3D_INITIALIZE_DATA(A3DRWParamsLoadData, sParams);
   
   // set tessellation reader parameters
   sParams.m_sTessellation.m_eTessellationLevelOfDetail = kA3DTessLODMedium;
   sParams.m_sTessellation.m_bKeepUVPoints = A3D_TRUE;
   sParams.m_sTessellation.m_bAccurateSurfaceCurvatures = A3D_TRUE;

   A3DAsmModelFile* pModelFile = NULL;
   A3DStatus eStatus = A3DAsmModelFileLoadFromFile(FILE_OK, &sParams, &pModelFile);
   assert(eStatus <= A3D_SUCCESS);

Note that HOOPS Exchange provides file reading options specific to STEP/XML.
These options can be set in the ``A3DRWParamsLoadData.m_sSpecifics.m_sStep`` field.

Structure
=========

STEP/XML is a structural format which makes use of the hierarchical nature of XML to represent complex assemblies.
The file then references external CAD files which can be :doc:`any supported format </start/supported-formats>`.

Assembly
========

HOOPS Exchange stores model files in memory in the form of a data structure called :doc:`PRC </guide/basic_operations/prc_basics>`.

Upon reading, the PRC structure is created with respect to the hierarchy of the STEP/XML file.
Yet unlike other file formats, each time a CAD file is referenced by an XML node, the reader generates two instances of :struct:`A3DAsmProductOccurrence` instead of one:

#. The first node maps to the PLM semantics of the product occurrence.
   This node has a specific flag bit set in :member:`A3DAsmProductOccurrenceData.m_uiProductFlags`: `FLAG_EXTERNAL_REFERENCE`.
#. A product occurrence which directly maps to the CAD data.

.. rubric:: See also

* :struct:`A3DAsmProductOccurrenceData` specifications.
* :ref:`group__a3d__product__flag`

Attributes
==========

In addition to reading the assembly structure and CAD files, our reader stores the attributes from the STEP/XML file into generic attributes. 
Attributes are general purpose data that can be associated to any entity. 
For more information about how to retrieve them, check out :doc:`/guide/metadata/generic_attributes`.

.. _stp_xml_rd_tessellation:

Tessellation
============

STEP files can contain tessellation data, and this data can be read by HOOPS Exchange. To enable this, set the tessellation parameters using the ``A3DRWParamsTessellationData`` structure found at ``A3DRWParamsLoadData.m_sTessellation`` during the read process. See code sample above for an example.

.. _stp_xml_rd_brep:

B-rep
=====

STEP files can also contain B-rep, and this data can be read by HOOPS Exchange.
