
#################
UnstructGridModel
#################

.. js:class:: cee.usg.UnstructGridModel

   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 :js:class:`State <cee.usg.State>`\ s, which links a :js:class:`Geometry <cee.usg.Geometry>` to scalar, displacement and transformation results for that geometry in that state.
   
   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
      :alt: None
   
   
   
   
   Index
   =====
   
   .. rubric:: Constructors
   
   
   .. rst-class:: api-xref-list
   
   
   * :js:func:`~cee.usg.UnstructGridModel.constructor`
   
   .. rubric:: Accessors
   
   
   .. rst-class:: api-xref-list
   
   
   * :js:func:`~cee.usg.UnstructGridModel.currentState`
   * :js:func:`~cee.usg.UnstructGridModel.currentStateIndex`
   * :js:func:`~cee.usg.UnstructGridModel.displacementSettings`
   * :js:func:`~cee.usg.UnstructGridModel.fringesSettings`
   * :js:func:`~cee.usg.UnstructGridModel.name`
   * :js:func:`~cee.usg.UnstructGridModel.stateCount`
   * :js:func:`~cee.usg.UnstructGridModel.vectorSettings`
   
   .. rubric:: Methods
   
   
   .. rst-class:: api-xref-list
   
   
   * :js:meth:`~cee.usg.UnstructGridModel.addState`
   * :js:meth:`~cee.usg.UnstructGridModel.deleteAllStates`
   * :js:meth:`~cee.usg.UnstructGridModel.deleteStateAt`
   * :js:meth:`~cee.usg.UnstructGridModel.deleteStateRange`
   * :js:meth:`~cee.usg.UnstructGridModel.getBoundingBox`
   * :js:meth:`~cee.usg.UnstructGridModel.getDefaultCameraConfig`
   * :js:meth:`~cee.usg.UnstructGridModel.getFringesResultRange`
   * :js:meth:`~cee.usg.UnstructGridModel.getStateArray`
   * :js:meth:`~cee.usg.UnstructGridModel.getStateAt`
   * :js:meth:`~cee.usg.UnstructGridModel.rayIntersect`
   
   



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

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


.. js:method:: cee.usg.UnstructGridModel.constructor

      .. rst-class:: sig-pretty-signature
      
         | UnstructGridModel(**options**\ : :js:class:`UnstructGridModelOptions <cee.usg.UnstructGridModelOptions>`\ ): :js:class:`UnstructGridModel <cee.usg.UnstructGridModel>`
      
      Create the UnstructGridModel
      
      Use the options to set the resource usage strategy for the model in a multi-state scenario. See :js:class:`UnstructGridModelOptions <cee.usg.UnstructGridModelOptions>` for more info.
      
      **Parameters**
      
      
         **options**\ : :js:class:`UnstructGridModelOptions <cee.usg.UnstructGridModelOptions>`
      
      
      **Returns**\ : :js:class:`UnstructGridModel <cee.usg.UnstructGridModel>`
      



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

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


.. js:method:: cee.usg.UnstructGridModel.currentState

      .. rst-class:: sig-pretty-signature
      
         | *get* currentState(): :js:class:`State <cee.usg.State>`
      
      The zero based index of the state currently shown in the view. Returns null for an invalid :js:func:`currentStateIndex <cee.usg.UnstructGridModel.currentStateIndex>`\ .
      
      **Returns**\ : :js:class:`State <cee.usg.State>`
      



.. js:method:: cee.usg.UnstructGridModel.currentStateIndex

      .. rst-class:: sig-pretty-signature
      
         | *get* currentStateIndex(): *number*
      
      The state to show in the view.
      
      The given zero-based index must be between 0 and :js:func:`stateCount <cee.usg.UnstructGridModel.stateCount>` - 1.
      
      **Returns**\ : *number*
      
      .. rst-class:: sig-pretty-signature
      
         | *set* currentStateIndex(**stateIndex**\ : *number*\ ): *void*
      
      **Parameters**
      
      
         **stateIndex**\ : *number*
      
      
      **Returns**\ : *void*
      



.. js:method:: cee.usg.UnstructGridModel.displacementSettings

      .. rst-class:: sig-pretty-signature
      
         | *get* displacementSettings(): :js:class:`DisplacementSettings <cee.usg.DisplacementSettings>`
      
      Settings for the displacement results
      
      **Returns**\ : :js:class:`DisplacementSettings <cee.usg.DisplacementSettings>`
      



.. js:method:: cee.usg.UnstructGridModel.fringesSettings

      .. rst-class:: sig-pretty-signature
      
         | *get* fringesSettings(): :js:class:`ScalarSettings <cee.usg.ScalarSettings>`
      
      Settings for the scalars shown as fringes on the model
      
      **Returns**\ : :js:class:`ScalarSettings <cee.usg.ScalarSettings>`
      



.. js:method:: cee.usg.UnstructGridModel.name

      Name of the model.
      
      Mainly used for debugging.
      
      .. rst-class:: sig-pretty-signature
      
         | *get* name(): *string*
      
      The name of the geometry model. Mainly used for debugging.
      
      **Returns**\ : *string*
      
      .. rst-class:: sig-pretty-signature
      
         | *set* name(**name**\ : *string*\ ): *void*
      
      Name of the model.
      
      Mainly used for debugging.
      
      **Parameters**
      
      
         **name**\ : *string*
      
      
      **Returns**\ : *void*
      



.. js:method:: cee.usg.UnstructGridModel.stateCount

      .. rst-class:: sig-pretty-signature
      
         | *get* stateCount(): *number*
      
      Returns the number of states in this model
      
      **Returns**\ : *number*
      



.. js:method:: cee.usg.UnstructGridModel.vectorSettings

      .. rst-class:: sig-pretty-signature
      
         | *get* vectorSettings(): :js:class:`VectorSettings <cee.usg.VectorSettings>`
      
      Settings for the scalars shown as fringes on the model
      
      **Returns**\ : :js:class:`VectorSettings <cee.usg.VectorSettings>`
      



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

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


.. js:method:: cee.usg.UnstructGridModel.addState

      .. rst-class:: sig-pretty-signature
      
         | addState(): :js:class:`State <cee.usg.State>`
      
      Add a state to the model.
      
      The added state is returned.
      
      **Returns**\ : :js:class:`State <cee.usg.State>`
      



.. js:method:: cee.usg.UnstructGridModel.deleteAllStates

      .. rst-class:: sig-pretty-signature
      
         | deleteAllStates(): *void*
      
      Delete all states in the model.
      
      **Returns**\ : *void*
      



.. js:method:: cee.usg.UnstructGridModel.deleteStateAt

      .. rst-class:: sig-pretty-signature
      
         | deleteStateAt(**stateIndex**\ : *number*\ ): *void*
      
      Delete a state at the given zero based index.
      
      **Parameters**
      
      
         **stateIndex**\ : *number*
      
      
      **Returns**\ : *void*
      



.. js:method:: cee.usg.UnstructGridModel.deleteStateRange

      .. rst-class:: sig-pretty-signature
      
         | deleteStateRange(**startIndex**\ : *number*\ , **deleteCount**\ : *number*\ ): *void*
      
      Delete a range of states. First state that will be deleted is the state with the given index If deleteCount is omitted, all states starting with the given index will be deleted.
      
      Works similar to the splice method on Javascript arrays
      
      **Parameters**
      
      
         **startIndex**\ : *number*
      
         **deleteCount**\ : *number*
      
      
      **Returns**\ : *void*
      



.. js:method:: cee.usg.UnstructGridModel.getBoundingBox

      .. rst-class:: sig-pretty-signature
      
         | getBoundingBox(**_options**\ : :js:class:`ModelBoundingBoxOptions <cee.ModelBoundingBoxOptions>`\ ): :js:class:`BoundingBox <cee.BoundingBox>`
      
      Returns the :js:class:`BoundingBox <cee.BoundingBox>` (in world coordinates) of the current state within the model.
      
      The returned bounding box will reflect the currently visible objects in the model.
      
      Note that this method does not support any :js:class:`ModelBoundingBoxOptions <cee.ModelBoundingBoxOptions>`
      
      **Parameters**
      
      
         **_options**\ : :js:class:`ModelBoundingBoxOptions <cee.ModelBoundingBoxOptions>`
      
      
      **Returns**\ : :js:class:`BoundingBox <cee.BoundingBox>`
      



.. js:method:: cee.usg.UnstructGridModel.getDefaultCameraConfig

      .. rst-class:: sig-pretty-signature
      
         | getDefaultCameraConfig(): *None*
      
      Returns default camera configuration, which is always null for this model.
      
      **Returns**\ : *None*
      



.. js:method:: cee.usg.UnstructGridModel.getFringesResultRange

      .. rst-class:: sig-pretty-signature
      
         | getFringesResultRange(): :js:class:`Range <cee.Range>`
      
      Get the range of the scalar result in this model
      
      **Returns**\ : :js:class:`Range <cee.Range>`
      



.. js:method:: cee.usg.UnstructGridModel.getStateArray

      .. rst-class:: sig-pretty-signature
      
         | getStateArray(): readonly  :js:class:`State <cee.usg.State>`\ []
      
      Returns a readonly array of all the states in the model
      
      **Returns**\ : readonly  :js:class:`State <cee.usg.State>`\ []
      



.. js:method:: cee.usg.UnstructGridModel.getStateAt

      .. rst-class:: sig-pretty-signature
      
         | getStateAt(**stateIndex**\ : *number*\ ): :js:class:`State <cee.usg.State>`
      
      Returns a reference to the state at the given index
      
      **Parameters**
      
      
         **stateIndex**\ : *number*
      
      
      **Returns**\ : :js:class:`State <cee.usg.State>`
      



.. js:method:: cee.usg.UnstructGridModel.rayIntersect

      .. rst-class:: sig-pretty-signature
      
         | rayIntersect(**ray**\ : :js:class:`Ray <cee.Ray>`\ ): :js:class:`HitItem <cee.usg.HitItem>`
      
      Performs picking on the model in the current state.
      
      If something was hit, returns a HitItem containing information about the part and primitive that was hit.
      
      If nothing was hit, returns null.
      
      **Parameters**
      
      
         **ray**\ : :js:class:`Ray <cee.Ray>`
      
      
      **Returns**\ : :js:class:`HitItem <cee.usg.HitItem>`
      




