.. role:: ts-api-decorator

####
Mesh
####

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

.. container:: ts-api-section

   .. js:class:: Mesh

      A mesh defines the surface elements and nodes for a ``Part`` in a ``Geometry``.

      A mesh is defined by a node array with x,y,z values and the element nodes describing the index of 
      the nodes in each element. The number of nodes per element is defined by either a singleElementType
      for meshes where all the elements have the same number of nodes or by an array (elementTypeArr) with
      one item per element describing the number of nodes in that element.

      Mesh is an immutable class, so if you need to change something you will have to construct a new mesh.



.. container:: api-index-section

   .. rubric:: Constructors

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

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



.. container:: api-index-section

   .. rubric:: Accessors

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

   * :js:attr:`~cee.usg.Mesh.elementCount`
   * :js:attr:`~cee.usg.Mesh.elementNodeIndexArray`
   * :js:attr:`~cee.usg.Mesh.elementTypeArray`
   * :js:attr:`~cee.usg.Mesh.nodeArray`
   * :js:attr:`~cee.usg.Mesh.nodeCount`
   * :js:attr:`~cee.usg.Mesh.singleElementType`



.. container:: api-index-section

   .. rubric:: Methods

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

   * :js:meth:`~cee.usg.Mesh.getBoundingBox`





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

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

.. container:: ts-api-section

   .. js:function:: Mesh.constructor( nodeArr, singleElementType, elementNodeIndexArr[, optionalData])

      :param nodeArr: None
      :type nodeArr: ArrayLike <number>
      :param singleElementType: None
      :type singleElementType: number
      :param elementNodeIndexArr: None
      :type elementNodeIndexArr: ArrayLike <number>
      :param optionalData: :ts-api-decorator:`optional` None
      :type optionalData: OptionalMeshData


      Create a mesh.

      For mesh with only one element type (all elements have the same number of element nodes) use the singleElementType version. This is more
      compact for storage.

      The nodeArr is an array of all the nodes in the mesh as an array with [x0, y0, z0, x1, y1, z1, ...].

      If you have a varying number of element nodes in your elements, specify that with an array 
      (elementTypeArr) with one item per element specifying the number of nodes for that element.


      :rtype: Mesh

   .. js:function:: Mesh.constructor( nodeArr, elementTypeArr, elementNodeIndexArr[, optionalData])
      :noindex:

      :param nodeArr: None
      :type nodeArr: ArrayLike <number>
      :param elementTypeArr: None
      :type elementTypeArr: ArrayLike <number>
      :param elementNodeIndexArr: None
      :type elementNodeIndexArr: ArrayLike <number>
      :param optionalData: :ts-api-decorator:`optional` None
      :type optionalData: OptionalMeshData


      :rtype: Mesh



Accessors
=========

.. container:: ts-api-section

   .. js:function:: Mesh.elementCount()



      The number of elements in the mesh.


      :rtype: number



.. container:: ts-api-section

   .. js:function:: Mesh.elementNodeIndexArray()



      Returns an array containing the node indices for each element node in the mesh.


      :rtype: ArrayLike <number>



.. container:: ts-api-section

   .. js:function:: Mesh.elementTypeArray()



      If not single element type, this array contains the number of elements for all elements in the mesh


      :rtype: ArrayLike <number>



.. container:: ts-api-section

   .. js:function:: Mesh.nodeArray()



      A readonly array containing the nodes of the mesh


      :rtype: ArrayLike <number>



.. container:: ts-api-section

   .. js:function:: Mesh.nodeCount()



      The number of nodes in the mesh.


      :rtype: number



.. container:: ts-api-section

   .. js:function:: Mesh.singleElementType()



      Returns the number of nodes in each element if all elements in the mesh have the same number of nodes

      Returns 0 if there are multiple element types.


      :rtype: number



Methods
=======

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

getBoundingBox
--------------

.. js:method:: Mesh.getBoundingBox()



   Returns the ``BoundingBox`` of the mesh.


   :rtype: BoundingBox

