.. _rhino_plugins:

Plug-ins for Rhinoceros 6
===================================

This chapter describes the ComFLOW plug-ins for Rhinoceros 6 (Rhino) which can be used for generating
tetrahedral volume meshes for defining the ComFLOW geometry and triangular surface meshes for defining monitor surfaces.
The plug-ins provide the following functionality:

- tetrahedral mesh generator (Rhino command ``cmfTetFill``)
- import/export ComFLOW geometry files (\*.in)
- import/export ComFLOW monitor surfaces (\*.in)


Prerequisites
------------------------------

The ComFLOW plug-ins for Rhino require:

* Rhinoceros version 6 (visit the `Rhinoceros webpage <http://rhino3d.com>`_ for more information)
* Microsoft .NET Framework 4.5. Usually this is already installed, but can otherwise be downloaded from the Microsoft website.

.. _rhino_plugins/installation:

Installation
----------------

To install the plug-ins perform the following steps:

* download the ComFLOW plug-ins for Rhino from the user group website
* unzip the folder at a convenient location (for example in ``%AppData%\ComFLOW\Rhino Plugins``)
* start Rhino
* open the folder ``%AppData%\ComFLOW\Rhino Plugins`` in the Windows Explorer
* drag the below mentioned ``*.rhp`` files from the Explorer to the Rhino window (alternatively install the files via the Rhino menu **Tools/Options**, subsection **Plug-ins**)

    - ``cmf_rhino_commands.rhp``
    - ``cmf_rhino_import_plugins.rhp``
    - ``cmf_rhino_export_plugins.rhp``

* restart Rhino

.. figure:: figures/rhino_plugin_menu.png
   :scale: 100%

   The Rhino plug-in menu.


Generating monitor surfaces and geometry volume meshes
-----------------------------------------------------------

For illustration purposes consider the simulation of flow around a simple sphere.
A volume mesh has to be created to define the ComFLOW geometry and a monitor surface has to be created
for monitoring the forces acting on the sphere.
As starting point an example Rhino 3D file can be downloaded :download:`here <./downloads/sphere.3dm>`,
in which all of the steps mentioned below have already been performed.

.. figure:: figures/rhino_meshed_sphere.png
   :scale: 100%

   From left to right: surface (``Sphere``), surface mesh (``Mesh``), triangulated surface mesh (``TriangulateMesh``), tetrahedral volume mesh (``cmfTetFill``).


The first step consists of creating a sphere and meshing its surface:

*   create a sphere surface object:

    - type ``Sphere``
    - type ``0`` and hit Enter to create a sphere around the origin
    - drag the mouse to choose the desired size

*   select the sphere, type ``Mesh`` and hit Enter (a dialog pops up, adjust the meshing settings to your needs)
*   select the resulting mesh and triangulate it by typing ``TriangulateMesh`` and hitting Enter

Having created the surface mesh, it can now be exported as ComFLOW monitor surface via the menu **File/Export selected...** or **File/Save as...**, selecting file
type *ComFLOW monitor surface (\*.in)*.

To create a tetrahedral volume mesh for the geometry definition, perform the following steps:

* select the triangulated surface mesh
* type ``cmfTetFill`` to fill the interior with tetrahedra; hit Enter to accept default settings (or make your preferred changes to the settings)
* select the created unstructured volume grid and export it via the menu **File/Export selected...** or **File/Save as...**, selecting file
  type *ComFLOW geometry (\*.in)*.


Importing and exporting files
-----------------------------------

Surface and volume meshes can be imported in two ways:

1. drag files from the Windows Explorer to the Rhino window
2. via the menu **File/Import...**

To export a volume or surface mesh, select the object in the Rhino GUI and click the menu **File/Export selected...** or **File/Save as...**:

* when exporting tetrahedral volume meshes for GEODEF, save as type *ComFLOW geometry (\*.in)*,
* when exporting triangular surface meshes for monitoring, save as type *ComFLOW monitor surface (\*.in)*.



.. ..rubric:: Footnotes

.. ..rubric:: References

.. ..bibliography:: references.bib