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

.. js:class:: cee.usg.Geometry

   The geometry class defines a CAE surface geometry that can be used in one or more :js:class:`States <cee.usg.State>`\ .
   
   A geometry has one or more :js:class:`Parts <cee.usg.Part>`\ . 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)));
   
   .. image:: /images/UsgGeometry.png
      :alt: None
   
   This code sample produces the following image in the 3D Viewer: 
   
   
   Index
   =====
   
   .. rubric:: Constructors
   
   
   .. rst-class:: api-xref-list
   
   
   * :js:func:`~cee.usg.Geometry.constructor`
   
   .. rubric:: Accessors
   
   
   .. rst-class:: api-xref-list
   
   
   * :js:func:`~cee.usg.Geometry.partCount`
   
   .. rubric:: Methods
   
   
   .. rst-class:: api-xref-list
   
   
   * :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`
   
   



.. rst-class:: kind-group kind-constructors

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


.. js:method:: cee.usg.Geometry.constructor

      .. rst-class:: sig-pretty-signature
      
         | Geometry(): :js:class:`Geometry <cee.usg.Geometry>`
      
      **Returns**\ : :js:class:`Geometry <cee.usg.Geometry>`
      



.. rst-class:: kind-group kind-accessors

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


.. js:method:: cee.usg.Geometry.partCount

      .. rst-class:: sig-pretty-signature
      
         | *get* partCount(): *number*
      
      The number of parts in the model.
      
      **Returns**\ : *number*
      



.. rst-class:: kind-group kind-methods

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


.. js:method:: cee.usg.Geometry.addPart

      .. rst-class:: sig-pretty-signature
      
         | addPart(): :js:class:`Part <cee.usg.Part>`
      
      Creates a new part and adds it to the geometry.
      
      Returns the newly created part.
      
      **Returns**\ : :js:class:`Part <cee.usg.Part>`
      



.. js:method:: cee.usg.Geometry.deleteAllParts

      .. rst-class:: sig-pretty-signature
      
         | deleteAllParts(): *void*
      
      Delete all parts in the geometry
      
      **Returns**\ : *void*
      



.. js:method:: cee.usg.Geometry.deletePartAt

      .. rst-class:: sig-pretty-signature
      
         | deletePartAt(**partIndex**\ : *number*\ ): *void*
      
      Delete the part at the given zero based index
      
      **Parameters**
      
      
         **partIndex**\ : *number*
      
      
      **Returns**\ : *void*
      



.. js:method:: cee.usg.Geometry.getPartArray

      .. rst-class:: sig-pretty-signature
      
         | getPartArray(): readonly  :js:class:`Part <cee.usg.Part>`\ []
      
      Returns a read only array with all parts
      
      **Returns**\ : readonly  :js:class:`Part <cee.usg.Part>`\ []
      



.. js:method:: cee.usg.Geometry.getPartAt

      .. rst-class:: sig-pretty-signature
      
         | getPartAt(**partIndex**\ : *number*\ ): :js:class:`Part <cee.usg.Part>`
      
      Returns an active reference to the part at the given (zero based) index.
      
      **Parameters**
      
      
         **partIndex**\ : *number*
      
      
      **Returns**\ : :js:class:`Part <cee.usg.Part>`
      




