SEARCH
TOOLBOX
LANGUAGES
Basic Tutorial for the Modeler

Basic Tutorial for the Modeler

From SOFAWiki

Jump to: navigation, search
First Tutorial with the Modeler : Basic Cube

Contents

Small Description of the Modeler

The Modeler is a tool designed to help the new-comers in Sofa to get an overview of the whole framework, and accelerate the process of creation and configuration of a complex simulation for expert users. It is composed of a Library, on the left part of the application, displaying all the components currently available in Sofa, sorted by the name of the Base Class. A click on one of the component will display information about the usage, authors, possibly a licence, and a link to an example. At any time, you can test a scene within Sofa using the menu Run In Sofa.

The Graph Editor is the located in the right part of the application. It allows you to put new components inside a scene, and configure them. You can at each time modify, delete it, or even do some copy/cut/paste operations.

The link between the Library and the Graph Editor is done by simply Drag & Dropping a component from the Library to the Graph Editor. A mechanism exists to prevent some basic errors, and pop up some warnings if your components is bad-created (problem in the type of template).

Image:Modeler.png


First Steps

We will now create the scene graph corresponding to the first tutorial of Sofa TutorialBasicCube.

XML Description

We want to generate this kind scene described by this xml file:

<?xml version="1.0" ?>
<!-- See http://wiki.sofa-framework.org/mediawiki/index.php/TutorialBasicCube -->
<Node name="root" dt="0.01" gravity="0 0 -9.81" showBehavior="1">
 
  <EulerImplicitSolver name="EulerImplicit" />
  <CGLinearSolver name="CG Solver" />
 
  <MechanicalObject name="Particles" template="Vec3"
                    position="0 0 1  1 0 1  0 1 1  1 1 1  0 0 2  1 0 2  0 1 2  1 1 2" />
  <MeshTopology name="Topology" hexas="0 2 1 3 4 6 5 7" />
 
  <UniformMass name="Mass" totalmass="1" />
  <MeshSpringForceField name="Springs" stiffness="100" damping="1" />
 
  <PlaneForceField name="Floor" normal="0 0.2 1" stiffness="100" damping="1" draw="1" />
  <PlaneForceField name="Wall" normal="0 -1 0" d="-4" stiffness="100" damping="1" draw="1" color="1 1 1" />
 
</Node>


Modeler Usage

Launch the Modeler
The binary for the Modeler is located at the same location as the binary for Sofa. Just launch it.


First Launch
  1. By default, an almost empty scene graph is created, containing only a root node, and 5 components to perform the collision detection.
  2. Clear the scene graph: menu->file->Clear (CTRL+N)
  3. At any time, you can undo or redo an operation by going to menu->edit->undo (CTRL+Z), menu->edit->redo (CTRL+Y)


Configure your Root
  1. Double-click on the Root to open up a configuration window. Inside this window, all the parameters available are displayed, and modifiable.
  2. Modify the Gravity set by default to 0 -9.81 0, to 0 0 -9.81 . Click on Update.
  3. Modify Visualization flags: click on the tab named Visualization, then click on Behavior. Click on Ok to update the parameters, and close the window.


Add the Solvers
  • Find the EulerImplicitSolver in the Library: you can filter the components displayed inside the library by using the field Filter above the Sofa Components list.

Image:Modeler-Filter.png

    1. One click on the component will display a little description, and information about the namespace.
    2. Drag the EulerImplicitSolver, and drop inside the Root Node. You mouse MUST be above a node or a component of the Graph Editor, when you drop your EulerImplicitSolver.
    3. You should now see a little green box bellow the Root Node, with the text: "EulerImplicitSolver unnamed". The first part is the class of the component, the second is its name. The color depends on the type of component, you will see the same colors inside the scene graph used by Sofa.
    4. Double-click on the EulerImplicitSolver you just created, to open up a configuration window. Change the name from unnamed to EulerImplicit, then click on OK to validate the change and close the window.
    5. REMEMBER If you drop your component above:
      • a Node, it will be automatically placed at the last position, inside the Node.
      • a Component, it will automatically be inserted at this position.
  • Find the CGLinearSolver in the Library: again you can use the filter, by typing directly CGLinearSolver inside the text field. This time, a new field appears on the right of the component CGLinearSolver inside the Library. It is a list of the available templates for the component, it gives the possibility to improve the computation time, in special occasion, by using different kind of internal storage: Sparse Matrix, Full Matrix, ... Just keep the default template, GraphScattered.
    1. Perform the same operations: Drag&Drop
    2. Configure the component.


Add the Mechanical Object.
  • Find the MechanicalObject. This time again, a field appears on the right of the component MechanicalObject, inside the Library. At this time, you have to chose the type of mechanical object you desire. We will chose a deformable body, in 3 dimensions, using a double precision, Vec3d.
    1. Add the component to the graph, and open its configuration window.
    2. Change its name
    3. If you click on the Infos Tab, located at the very right of the Properties tabs, you can see a small description of the instance of the object. You can verify that you put the Vec3d as template for the Mechanical Object.
    4. Add the 8 points of the Cube.
      • In the Properties 1/4 tab, put 8 points, instead of just 1. The Table will be automatically resized, and display an array composed of 8 rows, and 3 columns.
      • Put the 8 points at their initial position:

Image:Modeler-ConfigurePosition.png

position coordinates of the degrees of freedom

0 0 1
1 0 1
0 1 1
1 1 1
0 0 2
1 0 2
0 1 2
1 1 2

Press Ok to save the changes, and close the window


Add the MeshTopology.
  • Find MeshTopology in the Library, and Drag&Drop it inside the Graph Editor.
  • Edit the MeshTopology, by adding one Hexahedron.
    1. Click on the Properties 2/3 to see the tables describing the hexas, and put 1 in the counter of hexas.
    2. Fill the row of the table with the indices of the points describing your hexahedron: 0 2 1 3 4 6 5 7
Add the UniformMass
  • Find the Uniform Mass in the Library. Use the same template as the previous Mechanical Object added, and Drag&Drop it inside the Graph Editor.
  • Modify the field totalmass, and put 1 instead of 0.
Add the MeshSpringForceField
  • Find the MeshSpringForceField in the Library, and remind to use the same template as the Mechanical Object. Drag&Drop it inside the Graph Editor.
  • You can configure it if you want. By default, it will use a stiffness of 100 for the springs, and a damping coefficient of 5.
Add the PlaneForceField
  • Find the PlaneForceField in the Library, and remind to use the same template as the Mechanical Object. Drag&Drop it twice inside the Graph Editor, to get two PlaneForceFields.
  • Configure them correctly, according to the xml description given. The parameters written in a XML file corresponds to the boxes with the same name inside the configuration window.
    1. Find the box named normal and set it to the value you want.
    2. Continue with the others parameters.
Test the Scene
  • Your scene is ready to be used with Sofa: Go to menu->Run In Sofa->Run In Sofa. Sofa should launch, using your scene graph.
  • Try to modify some parameters inside the Modeler, and Run In Sofa to see the difference.