Personal tools
You are here: Home / cmgui / Wiki / Creating A Mesh Interactively in CMGUI
Log in

Forgot your password?

Creating A Mesh Interactively in CMGUI

In a nutshell to create a mesh manually you simply need to have a bunch of nodes in cmgui and then you "connect the dots" to build the elements of the mesh.

There are a number of ways to get suitable nodes into cmgui:<br><ol><li>Pick node points on a physical model using the faro arm.</li><li>Convert relevant points from a data cloud into nodes. You can create a data cloud using a laser scanner or using the visible human digitiser utilities as described in Cmiss example a/digitise.</li></ol>Assuming that you have a data cloud then you will already have one or more exdata files. To convert these into exnode format simply change the name from *.exdata to *.exnode. If you have a number of files then the perl script on the RenamingFiles page might be useful.

If you have a single exnode file then you can now just read that into cmgui using <pre>gfx read nodes &lt;filename&gt; </pre> If you have multiple files then you can use cmCombine to concatenate them or just read them in one at a time. Here is an example script that allows you to load multple groups and set the colours and glyphs.

Now you have a bunch of nodes which can be used for building elements. It is also necessary to set up some fields for the elements that are to be created. Example a/as shows how to do this.<br><br>The order in which nodes are selected is important. When selecting nodes to create a hexahedral element (eg a cube) in the nodes must be selected in this order: <pre> Xi1 Xi2 Xi3 node # 1 0 0 0 node # 2 1 0 0 node # 3 0 1 0 node # 4 1 1 0 node # 5 0 0 1 node # 6 1 0 1 node # 7 0 1 1 node # 8 1 1 1<br><br></pre>

Where the table entries are the local coordinate values for each node. The following diagrams show this graphically:<br><pre>Line:



3---4 | | | | 1---2



5/__6/| | : | | | 3.|.4 1/__2/ </pre>A common (well, I know of at least one other person that did it!) beginner's mistake is to just create a bunch of randomly oriented elements that look pretty in cmgui and fit the geometry. Don't do that. You need to make sure that the local coordinate directions of each element are aligned in some sort of consistent manner. This is especially important if the mesh will will fitted to data. The best alignment will depend on what the mesh will be used for (see DesigningAMesh).

To make things a bit more ordered you may find it convenient to put nodes into groups. This can be done using the following commands

<pre># create a new node group gfx create ngroup &lt;ngroup_name&gt; region &lt;region_name&gt;

# now select some nodes with the mouse # add the selected node to the new group gfx modify ngroup &lt;ngroup_name&gt; add selection region &lt;region_name&gt;

# note that the nodes are now in both the root group and your new group<br></pre>

The following commands (cmgui 2.9) can be used to load some nodes and set up the element creator (part of the node tool in the graphics window):<br><pre>gfx read nodes mynodes.exnode # assume these get loaded into region reg1<br><br># visualise the nodes<br>gfx modify g_element reg1 node_points coordinate coordinates glyph diamond select_on material default selected_material default_selected;<br>gfx create window 1 double_buffer;<br><br># create a coordinate field and an element group for the elements that will be created<br>gfx define field coordinates finite_element number_of_components 3 real coordinate component_names x y z<br>gfx create egroup mesh reg reg1<br>gfx define field cmiss_number cmiss_number<br><br># add visualisation for the created elements<br>gfx modify g_element reg1 lines coordinate coordinates<br>gfx modify g_element reg1 surfaces coordinate coordinates<br>gfx modify g_element reg1 element_points glyph sphere coordinate coordinates material red use_elements label cmiss_number<br><br># set up the element creator<br>gfx modify window 1 node_tool element_create group reg1/mesh element_dimension 3 coordinate_field coordinates</pre>Once you have created the mesh it can be exported to the old cm ip* format using<br><pre>gfx export cm ...</pre>or by using the element export scripts in the CMISS perl utilites ( see MeshExportCmgui2Cm ).<br><h2><br></h2><h2>Deleting elements</h2><p>To delete an element enable the visualisation of "element_points" so that elements can be selected and use the "destroy selected" button in the element tool panel in the graphics window. Alternatively use the command:</p><pre>gfx destroy element # group &lt;region_name&gt;<br></pre><h2><br></h2><h2>Cancelling element creation<br></h2><p>If you are creating elements from a set of existing nodes (a common case) and you select the wrong node then the current element can be cancelled by unchecking and rechecking the "create elements" checkbox in the "element creator" panel.</p><p><br></p>