This tutorial shows how to build your own UnstructGridModel geometry, part and results.
The geometry is a very simple structure containing a single triangle and the following results:
Create a model and set a data source.
Since you will be building our own geometry and not read from a file, we use a DataSourceMemory object.
Upon creation of the DataSourceMemory, you must specify a unique id for this data source and how many geometries it will contain. Number of geometries cannot be changed once the data source has been created. In this example you only have one geometry.
Each data source can have many data states. This simple model will only have one state. In the construction of a state, you need to give the state an unique id and set how many geometries it contains. The number of geometries for a state must always be the same as for the data source it belongs to!
Create the state with an id and number of geometries and add it to the data source.
The ModelSpec object is the model specification. Among many other settings, the model specification tells which state(s) are current. Tell the model specification to use this state.
Create a geometry object and add the geometry to the state at index 0 (since you only have one state).
Create a DataNodes object. DataNodes is a collection of nodes used for building the triangle. In this example you will use 3 nodes to create a triangle. Important! The nodes object must be set to the correct size before setting the actual node coordinates!
Create the connectivities array for the nodes in the elements. These are specified as one std::vector<unsigned int> for each element. In this example that means two arrays, one for each triangle.
Create the DataElements object. DataElements is a collection of elements used to define a part. Each element has a element type (here TRIANGLE) and a connectivities array towards the matching DataNodes object.
Add the two triangle elements.
Create the DataPart object.
A part consists of:
Set the nodes and elements created above into the part.
Add the part to the geometry
Create a scalar result using node mapping. The scalar result takes a unique id and the result mapping type upon construction.
Number of parts in the DataResultScalar must match number of parts in the geometry. Scalar values and mapping type must also fit the corresponding part in the geometry. Here the part is a single triangle with three nodes, hence a results array with three values using node mappings will fit.
Create a scalar result part and add it to the scalar result.
Each state has a result group for storing available results for each of its geometries. Add the scalar result to the result group for the corresponding geometry.
Create a vector result using node mapping. The vector result takes a unique id and the result mapping type upon construction.
As for scalars, the number of parts in the DataResultVector must match the number of parts in the geometry. And result values and mapping type must match the corresponding part. This means that the vector result array must have three vectors.
Add the vector result to the result group for the corresponding geometry.
The displacement result takes a unique id upon construction.
As for scalars and vectors, the number of parts in the DataResultDisplacement must match the number of parts in the geometry. And result values must match the corresponding part. This means that the displacement result array must have three displacement vectors.
Add the displacement result to the result group for the corresponding geometry.
As for scalars and vectors, the number of parts in the DataResultTransformation must match the number of parts in the geometry. The part in this case is a transformation matrix which applies to the part as whole.
Add the transformation result to the result group for the corresponding geometry.
When you're done creating the new data source (or have modified it), you need to populate the directory with the latest changes.
Then update the model spec to show all results
The model is ready to use and can be added to the view. Exactly where the view exists depends on the platform and solution. These examples uses Qt and the view is set up in a cee::qt::ViewerWidget.