.. role:: ts-api-decorator

#######
cee.usg
#######

.. container:: ts-api-section

   .. js:module:: cee.usg

   The **usg** sub-module provides functionality for working client side with unstructured surface grids

   Assuming that the EnvisionWeb client component has been imported into the variable ``cee``, members of
   the usg module may be referenced using the ``cee.usg`` prefix, e.g.:


   .. code-block:: javascript

      var model = new cee.usg.UnstructGridModel();



   .. image:: ../../images/Usg.png

 

   The ``UnstructGridModel`` implements a client side model for handling surface CAE models. It handles 
   surface elements with any number of nodes. A model has one or more ``State``s, which links a ``Geometry`` to 
   scalar, displacement and transformation results for that geometry in that state.

   The example application **DemoAppUsg** shows an example on how to use the UnstructGridModel to simulate streaming of 
   scalar and displacement results.

   Here is a simple example of how to create an usg model containing a single quad element 
   with a per node scalar result in one state:


   .. code-block:: javascript

      let model = new cee.usg.UnstructGridModel();
      this.m_view.addModel(model);

      let geometry = new cee.usg.Geometry();
      let part = geometry.addPart();
       
      // Create a single quad mesh
      const nodeArr = [0,0,0, 1,0,0, 1,1,0, 0,1,0];
      const elConnArr = [0,1,2,3];
      part.mesh = new cee.usg.Mesh(nodeArr, 4, elConnArr);
       
      // Configure the visual appearance of the part
      part.settings.color = new cee.Color3(1,0,0);
      part.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;

      let scalarArr = [1,2,3,4];
      state.setPartFringesAt(0, new cee.usg.PartScalars(cee.usg.ResultMapping.PER_NODE, scalarArr));

      // Configure the mapper to use, and 
      const mapper = new cee.ScalarMapperFilledContoursUniform();
      mapper.colorArray = cee.ColorTableFactory.color4TableArray(cee.ColorTable.RAINBOW, 15);
      mapper.setRange(1,4);
      model.fringesSettings.scalarMapper = mapper;

      // Add a color legend based on the mapper
      this.m_view.overlay.addCustomColorLegendForScalarMapper(mapper, "Demo result", 1);


   This code sample produces the following image in the 3D Viewer:

   .. image:: ../../images/UsgModel.png






.. toctree::
   :titlesonly:
   :hidden:

   /c3_reference/classes/cee.usg.DisplacementSettings
   /c3_reference/enum/cee.usg.DrawStyle
   /c3_reference/classes/cee.usg.ElementHighlighter
   /c3_reference/classes/cee.usg.Geometry
   /c3_reference/interfaces/cee.usg.HitItem
   /c3_reference/classes/cee.usg.Mesh
   /c3_reference/classes/cee.usg.MeshQuery
   /c3_reference/interfaces/cee.usg.OptionalMeshData
   /c3_reference/classes/cee.usg.Part
   /c3_reference/classes/cee.usg.PartDisplacements
   /c3_reference/classes/cee.usg.PartScalars
   /c3_reference/classes/cee.usg.PartSettings
   /c3_reference/classes/cee.usg.PartVectors
   /c3_reference/enum/cee.usg.ResultMapping
   /c3_reference/classes/cee.usg.ScalarSettings
   /c3_reference/enum/cee.usg.ScaleMode
   /c3_reference/classes/cee.usg.State
   /c3_reference/classes/cee.usg.UnstructGridModel
   /c3_reference/interfaces/cee.usg.UnstructGridModelOptions
   /c3_reference/classes/cee.usg.VectorSettings
   /c3_reference/enum/cee.usg.VizStateStrategy

.. container:: api-index-section

   .. rubric:: Enumerations

   .. rst-class:: api-index-list-item api-kind-enum api-parent-kind-module

   * :ref:`cee.usg.DrawStyle`
   * :ref:`cee.usg.ResultMapping`
   * :ref:`cee.usg.ScaleMode`
   * :ref:`cee.usg.VizStateStrategy`



.. container:: api-index-section

   .. rubric:: Classes

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

   * :js:class:`~cee.usg.DisplacementSettings`
   * :js:class:`~cee.usg.ElementHighlighter`
   * :js:class:`~cee.usg.Geometry`
   * :js:class:`~cee.usg.Mesh`
   * :js:class:`~cee.usg.MeshQuery`
   * :js:class:`~cee.usg.Part`
   * :js:class:`~cee.usg.PartDisplacements`
   * :js:class:`~cee.usg.PartScalars`
   * :js:class:`~cee.usg.PartSettings`
   * :js:class:`~cee.usg.PartVectors`
   * :js:class:`~cee.usg.ScalarSettings`
   * :js:class:`~cee.usg.State`
   * :js:class:`~cee.usg.UnstructGridModel`
   * :js:class:`~cee.usg.VectorSettings`



.. container:: api-index-section

   .. rubric:: Interfaces

   .. rst-class:: api-index-list-item api-kind-interface api-parent-kind-module

   * :js:class:`~cee.usg.HitItem`
   * :js:class:`~cee.usg.OptionalMeshData`
   * :js:class:`~cee.usg.UnstructGridModelOptions`



