.. role:: ts-api-decorator

########
Geometry
########

.. js:module:: cee.usg
   :noindex:

.. container:: ts-api-section

   .. js:class:: Geometry

      The geometry class defines a CAE surface geometry that can be used in one or more ``States``.

      A geometry has one or more ``Parts``. Each part defines a mesh with surface elements and nodes, as well
      as settings on how to render a part. There is no limit on the number of nodes per element. A mesh
      can also be shared between parts (in the same or different geometries).

      The common case is to use one geometry for all states and then use displacements and/or
      transformation results to animate the model. Scalar and vector results can also be defined per state.

      Example:

      .. code-block:: javascript

         let model = new cee.usg.UnstructGridModel();
         this.m_view.addModel(model);
         this.m_view.background.setSingleColor({r: 1, g: 1, b:1, a: 1});

         let geometry = new cee.usg.Geometry();

         const vertexArr = [ 
             0,0,0, 
             1,0,0, 1,3,0,
             2,0,0, 4,0,0, 3,3,0,
             5,0,0, 7,0,0, 7,3,0, 5,3,0,
             9,0,0, 10,0,0, 11,1,0, 11,2,0, 10,3,0, 9,3,0, 8,2,0, 8,1,0,
             12,0,0, 14,0,0, 16,0,0, 
             12,3,0, 14,3,0, 16,3,0
         ];

         const elConnArr = [
             0,
             1,2,
             3,4,5,
             6,7,8,9,
             10,11,12,13,14,15,16,17,
             18,19,22,21,
             19,20,23,22
         ];

         const elNodeCountArr = [1, 2, 3, 4, 8, 4, 4];

         // Create the first part
         let part1 = geometry.addPart();
         part1.mesh = new cee.usg.Mesh(vertexArr, elNodeCountArr, elConnArr);
         part1.settings.color = new cee.Color3(1,0,0);

         // Create the second part - same mesh with transform
         let part2 = geometry.addPart();
         part2.mesh = part1.mesh;
         part2.settings.color = new cee.Color3(0,1,0);
         part2.settings.drawStyle = cee.usg.DrawStyle.SURFACE_MESH;

         // Create a state, set the geometry and add the scalar result
         let state = model.addState();
         state.geometry = geometry;

         // Transform the second part
         state.setPartTransformationAt(1, cee.Mat4.fromTranslation(new cee.Vec3(0,5,0)));



      This code sample produces the following image in the 3D Viewer:
      .. image:: /images/UsgGeometry.png





.. container:: api-index-section

   .. rubric:: Constructors

   .. rst-class:: api-index-list-item api-kind-constructor api-parent-kind-class

   * :js:meth:`~cee.usg.Geometry.constructor`



.. container:: api-index-section

   .. rubric:: Accessors

   .. rst-class:: api-index-list-item api-kind-accessor api-parent-kind-class

   * :js:attr:`~cee.usg.Geometry.partCount`



.. container:: api-index-section

   .. rubric:: Methods

   .. rst-class:: api-index-list-item api-kind-method api-parent-kind-class

   * :js:meth:`~cee.usg.Geometry.addPart`
   * :js:meth:`~cee.usg.Geometry.deleteAllParts`
   * :js:meth:`~cee.usg.Geometry.deletePartAt`
   * :js:meth:`~cee.usg.Geometry.getPartArray`
   * :js:meth:`~cee.usg.Geometry.getPartAt`





------------

Constructors
============

.. container:: ts-api-section

   .. js:function:: Geometry.constructor()



      :rtype: Geometry



Accessors
=========

.. container:: ts-api-section

   .. js:function:: Geometry.partCount()



      The number of parts in the model.


      :rtype: number



Methods
=======

.. rst-class:: ts-api-section

addPart
-------

.. js:method:: Geometry.addPart()



   Creates a new part and adds it to the geometry.

   Returns the newly created part.


   :rtype: Part

.. rst-class:: ts-api-section

deleteAllParts
--------------

.. js:method:: Geometry.deleteAllParts()



   Delete all parts in the geometry


   :rtype: void

.. rst-class:: ts-api-section

deletePartAt
------------

.. js:method:: Geometry.deletePartAt( partIndex)

   :param partIndex: None
   :type partIndex: number


   Delete the part at the given zero based index


   :rtype: void

.. rst-class:: ts-api-section

getPartArray
------------

.. js:method:: Geometry.getPartArray()



   Returns a read only array with all parts


   :rtype: unknown

.. rst-class:: ts-api-section

getPartAt
---------

.. js:method:: Geometry.getPartAt( partIndex)

   :param partIndex: None
   :type partIndex: number


   Returns an active reference to the part at the given (zero based) index.


   :rtype: Part

