
.. _model-page:

#####
Model	  
#####

.. image:: ../../images/uml_model.png

A Model is responsible for collecting the information needed to compose a view. It serves as an abstract base class, 
and all models are required to implement this interface.

The Model class has three main subclasses:

-   UnstructGridModel
-	MarkupModel
-   GeometryModel

*****************
UnstructGridModel
*****************

The :class:`UnstructGridModel <cee::ug::UnstructGridModel>` class is a 
subclass of :class:`Model <cee::vis::Model>` which adds specific model structure and functionality for representing 
scientific and engineering models, e.g. finite element data. 
Essential to UnstructGridModel is :class:`DataSource <cee::ug::DataSource>` which represents the actual source of model 
information. Subclasses to DataSource distinguish between file based and programmatic input of 
model information. 

See topic :ref:`Getting data into UnstructGridModel <input-ug-page>` for further descriptions of data sources.

UnstructGridModel employs a model specification, the :class:`ModelSpec <cee::ug::ModelSpec>` class, to specify what to 
visualize at any given time. ModelSpec enables selection of states (e.g. load cases, time steps, 
and frequencies), and results (scalar, vector, and displacements). 

The data model consists of nodes, elements, element connectivity, and aggregations to parts.
Nodes and elements can be index- or id-based. Elements also have optional user properties. 
The parts bind elements and nodes. A geometry consists of a collection of parts. The Unstructured Grid component
supports multiple geometries per state and allows combination of static and dynamic geometries. All parts
have its own :class:`part settings <cee::ug::PartSettings>`. 
The data model may contain multiple scalar, vector results, displacement results and transformations. 
The Unstructured Grid component supports partial results (results available only for a subset of parts).

See the :any:`Unstruct Grid Component documentation <cee::ug>` for further information.

.. image:: ../../images/uml_unstruct.png

.. |img_tt| image:: ../../images/tut_twotriangles.png
   :width: 150
   :target: ../../tutorials/two-triangles.html

.. |img_twr| image:: ../../images/tut_triangle_with_results.png
   :width: 150
   :target: ../../tutorials/triangle-with-results.html

.. |img_lf| image:: ../../images/tut_loadvtf.png
   :width: 150
   :target: ../../tutorials/simple-load-vtf.html

+-----------------+--------------------------------------------------------------------------+
| |img_tt|        | **Tutorial**\ : :ref:`two-triangles-tutorial` |br|                       |
|                 | Shows how to create your own part and to use it in a model.  |br|        |
|                 | The geometry is a very simple structure containing two triangles  |br|   |
|                 | only.  |br|                                                              |
+-----------------+--------------------------------------------------------------------------+
| |img_twr|       | **Tutorial**\ : :ref:`triangle-with-results-tutorial` |br|               |
|                 | Shows how to build an UnstructGridModel geometry, part and results. |br| | 
|                 | The geometry is a very simple structure containing a single  |br|        |
|                 | triangle and a scalar result mapped as fringes, a vector result  |br|    | 
|                 | and a displacement result.  |br|                                         |
+-----------------+--------------------------------------------------------------------------+
| |img_lf|        | **Tutorial**\ : :ref:`simple-load-vtf-tutorial` |br|                     |
|                 | Shows how to create a data source by loading a VTFx file and how to |br| |
|                 | setup a model specification.  |br|                                       |
+-----------------+--------------------------------------------------------------------------+



***********
MarkupModel 
***********

The :class:`cee::vis::MarkupModel` class is a subclass of :class:`cee::vis::Model` which 
draws simple object and markups such as annotations, distance measurements etc.

The following markup part types are available:

-   :class:`Labels <cee::vis::MarkupPartLabels>`
-   :class:`Triangles <cee::vis::MarkupPartTriangles>`
-   :class:`Lines <cee::vis::MarkupPartLines>`
-   :class:`Points <cee::vis::MarkupPartPoints>`
-   :class:`Arrows <cee::vis::MarkupPartArrows>`
-   :class:`Fixed size arrow <cee::vis::MarkupPartFixedSizeArrow>`
-   :class:`Fixed size glyph <cee::vis::MarkupPartFixedSizeGlyph>`
-   :class:`Fixed size spheres <cee::vis::MarkupPartFixedSizeSphere>`
-   :class:`Text 3D <cee::vis::MarkupPartText3d>`
-   :class:`Instanced geometry <cee::vis::MarkupPartInstancedGeometry>`



.. |img_m| image:: ../../images/tut_markup.png
   :width: 150
   :target: ../../tutorials/markup.html

+-----------------+--------------------------------------------------------------------------+
| |img_m|         | **Tutorial**\ : :ref:`markup-tutorial` |br|                              |
|                 | Shows how to create a data source by loading a VTFx file and  |br|       |
|                 | drawing the models bounding box as a markup model. |br|                  |
+-----------------+--------------------------------------------------------------------------+


*************
GeometryModel 
*************

The GeometryModel class is a subclass of :class:`Model <cee::vis::Model>` which
can handle a large number of :class:`Parts <cee::geo::Part>` efficiently.

It supports the following part types:

-   :class:`Indexed triangles <cee::geo::DataIndexedTriangles>`
-   :class:`Indexed polylines <cee::geo::DataIndexedPolylines>`
-   :class:`Points <cee::geo::DataPoints>`
-   :class:`Triangle fan <cee::geo::DataTriangleFan>`
-   :class:`Triangle strip <cee::geo::DataTriangleStrip>`

Each part has with relevant effects/attributes like color, textures, opacity/transparency, size/width, halo/silhouetted 
edges, lighting etc.

The GeometryModel supports ray and region intersects which may be used to mimic e.g. picking/selection schemes.


.. |img_gm| image:: ../../images/tut_geometrymodel.png
   :width: 150
   :target: ../../tutorials/geometry.html

.. |img_gt| image:: ../../images/tut_geometrytexture.png
   :width: 150
   :target: ../../tutorials/geometry-texture.html

.. |img_gp| image:: ../../images/tut_geometry_primitives.png
   :width: 150
   :target: ../../tutorials/geometry-primitives.html

+-----------------+--------------------------------------------------------------------------+
| |img_gm|        | **Tutorial**\ : :ref:`geometry-tutorial` |br|                            |
|                 | Shows how to create a geometry model with different parts and |br|       |
|                 | effects.  |br|                                                           |
+-----------------+--------------------------------------------------------------------------+
| |img_gt|        | **Tutorial**\ : :ref:`geometry-texture-tutorial` |br|                    |
|                 | Shows how to create a geometry model using the texture effect to |br|    |
|                 | show a scalar result. |br|                                               | 
+-----------------+--------------------------------------------------------------------------+
| |img_gp|        | **Tutorial**\ : :ref:`geometry-primitives-tutorial` |br|                 |
|                 | Shows how to create a geometry with geometric primitives like |br|       |
|                 | spheres, boxes and cylinders.                                            |
+-----------------+--------------------------------------------------------------------------+


.. seealso::

    -   :class:`cee::vis::Model`
    -   :class:`cee::ug::UnstructGridModel`
    -   :class:`cee::vis::MarkupModel`
    -   :class:`cee::geo::GeometryModel`
