This tutorial shows how to create your own parts and use in a model.
The geometry is a very simple structure containing two triangles only.
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 cee::ug::DataSourceMemory object.
Upon creation of the cee::ug::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 identical to number of geometries in the data source the state is added to!
Create the state with an id and number of geometries and add it to the data source.
The cee::ug::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 the first (and only) state.
Create a geometry object and add the geometry to the state at index 0 (since you only have one state).
Create a nodes object. cee::ug::DataNodes is a collection of nodes used for building the part. In this example you will use 5 nodes to create the two triangles. 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 elements object. cee::ug::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 cee::ug::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
When you're done creating the new data source (or have modified it), you need to populate the directory with the latest changes.
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.