.. _examples-vtfx-page:

##############
Code Examples
##############

.. image:: ../../../images/vtfx/tut_vtfxwriter.png
    :height: 350
    :align: center

Reading and running the provided examples is a good way to start using the VTFx Component. There are multiple examples 
included in the distribution showcasing a range of features and levels of complexity.
All examples are shipped with Visual Studio project files and Makefiles and are ready to run directly from
the **Examples** folder. The generated VTFx files can be opened in all Envision products, including
our free viewers. Download the HOOPS Envision Demo Viewer for free from the developer zone, 
https://developer.techsoft3d.com/.

The main language for the examples are C++. There is also one C# example and one Python example included, but reading 
and adapting the C++ examples should be trivial. If you are a C# user, please read the topic :ref:`c-sharp-users-page`. 
If you are a Python user, please read the topic :ref:`python-users-page`.

The minimal example is also available as a tutorial and is a good entry point for starting programming using
the VTFx Component. Find this tutorial at :ref:`vtfx-writer-tutorial`.

All the examples are found under the folder **/Examples/VTFx/** in the distribution.


.. |img_m| image:: ../../../images/vtfx/minimal_example.png
   :width: 150
   :target: minimal.html

.. |img_s| image:: ../../../images/vtfx/simple_example.png
   :width: 150
   :target: simple.html

.. |img_e| image:: ../../../images/vtfx/example_example.png
   :width: 150
   :target: advanced.html

.. |img_r| image:: ../../../images/vtfx/read_example.png
   :width: 150
   :target: read-file.html

.. |img_a| image:: ../../../images/vtfx/append_example.png
   :width: 150
   :target: append-case.html

.. |img_a2| image:: ../../../images/vtfx/append2_example.png
   :width: 150
   :target: append-data.html

.. |img_ci| image:: ../../../images/vtfx/cutiso_example.png
   :width: 150
   :target: cutting-plane-and-isosurface.html

.. |img_at| image:: ../../../images/vtfx/adaptivetopology_example.png
   :width: 150
   :target: adaptive-topology.html

.. |img_tg| image:: ../../../images/vtfx/twogeometries_example.png
   :width: 150
   :target: two-geometries.html

.. |img_c| image:: ../../../images/vtfx/cloud_example.png
   :width: 150
   :target: send-to-cloud.html

.. |img_cs| image:: ../../../images/vtfx/crosssections_example.png
   :width: 150
   :target: crosssections.html

.. |img_csa| image:: ../../../images/vtfx/crosssections_all_example.png
   :width: 150
   :target: crosssections-all.html

.. |img_p| image:: ../../../images/vtfx/polyhedron_example.png
   :width: 150
   :target: polyhedron.html

+-----------------------+------------------------------------------------------------------------------------+
| |img_m|               | :ref:`minimal-example`     |br|                                                    |
|                       | This example shows how to create a minimal VTFx file with a simple part |br|       |
|                       | consisting of just one element, with only one state and no results or properties.  |
+-----------------------+------------------------------------------------------------------------------------+
| |img_s|               | :ref:`simple-example`     |br|                                                     |
|                       | Simple VTFx file including result fringes and multiple states. The example |br|    |
|                       | has two simple parts, one scalar result and three time steps. It uses |br|         |
|                       | properties to set up an animation of the results.                                  |
+-----------------------+------------------------------------------------------------------------------------+
| |img_e|               | :ref:`example-example`     |br|                                                    |
|                       | A more advanced example showing multiple parts, two states, various result |br|    |
|                       | types and properties. It demonstrates different ways of populating the blocks.     |
+-----------------------+------------------------------------------------------------------------------------+
| |img_r|               | :ref:`read-example`     |br|                                                       |
|                       | Reads a VTFx file and prints the content of databases, cases and blocks.           |
+-----------------------+------------------------------------------------------------------------------------+
| |img_a|               | :ref:`append-example`     |br|                                                     |
|                       | Opens an existing VTFx file and appends an additional case to it. The |br|         |
|                       | appended case sets draw style on the first part to line and sets color and |br|    |
|                       | opacity on the second part.                                                        |
+-----------------------+------------------------------------------------------------------------------------+
| |img_a2|              | :ref:`append2-example`     |br|                                                    |
|                       | Opens an existing VTFx file and adds a state. This example also adds scalar |br|   |
|                       | result values for this new state and updates the properties to include this |br|   |
|                       | state in the animation.                                                            |
+-----------------------+------------------------------------------------------------------------------------+
| |img_ci|              | :ref:`cutiso-example`     |br|                                                     |
|                       | Showing isosurface and cutting plane features in VTFx. Isosurfaces and |br|        |
|                       | cutting planes are set as properties. This example creates a small part with |br|  |
|                       | a scalar result shown as fringes and adds an isosurface and a cutting plane.       |
+-----------------------+------------------------------------------------------------------------------------+
| |img_tg|              | :ref:`twogeometries-example`     |br|                                              |
|                       | Creating a VTFx using two geometries                                               |
+-----------------------+------------------------------------------------------------------------------------+
| |img_at|              | :ref:`twogeometries-example`     |br|                                              |
|                       | Creating a VTFx using adaptive geometries                                          |
+-----------------------+------------------------------------------------------------------------------------+
| |img_c|               | :ref:`cloud-example`     |br|                                                      |
|                       | Creating a VTFx and sending it to Ceetron Cloud for viewing                        |
+-----------------------+------------------------------------------------------------------------------------+
| |img_cs|              | :ref:`crosssections-example`     |br|                                              |
|                       | Creating a VTFx using cross section element expansion for beams                    |
+-----------------------+------------------------------------------------------------------------------------+
| |img_csa|             | :ref:`crosssections-all-example`     |br|                                          |
|                       | Creating a VTFx showing all available cross section element expansion for beams    |
+-----------------------+------------------------------------------------------------------------------------+
| |img_p|               | :ref:`polyhedron-example`     |br|                                                 |
|                       | Simple example on creating polyhedron elements                                     |
+-----------------------+------------------------------------------------------------------------------------+



.. toctree::
    :maxdepth: 2
    :caption: Examples
    :hidden:
    :titlesonly:

    minimal
    simple
    advanced
    read-file
    append-case
    append-data
    cutting-plane-and-isosurface
    adaptive-topology
    two-geometries
    send-to-cloud
    crosssections
    crosssections-all
    polyhedron




