This example shows how to write two different geometries to the same database. This could be useful if you have separate entities in your model, and especially so if you are going to read this file into a Ceetron Desktop Components based application where you want to use multiple geometries for structural reasons.
It is also useful to use multiple geometries if some parts of your model/scene have a static topology and some parts have an adaptive topology.
The example shows how to create two geometries in the same model. There are two time steps, and the first part has an adaptive topology and has a different mesh in the two time steps, whereas the second part has the same topology in both states.
const cee::Str fileName =
"ExampleTwoGeometries.vtfx";
if (!file->
create(fileName, fileSettings))
{
return EXIT_FAILURE;
}
{
{
const float NODES[] =
{
0.0f, 0.0f, 0.0f,
2.0f, 0.0f, 0.0f,
2.0f, 2.0f, 0.0f,
};
std::vector<float> nodesPart(NODES, NODES + sizeof(NODES) / sizeof(NODES[0]));
{
return EXIT_FAILURE;
}
{
return EXIT_FAILURE;
}
}
{
const int CONNECTS[] = { 0, 1, 2};
std::vector<int> elementNodes(CONNECTS, CONNECTS + sizeof(CONNECTS) / sizeof(CONNECTS[0]));
{
return EXIT_FAILURE;
}
{
return EXIT_FAILURE;
}
}
}
{
{
const float NODES[] =
{
0.0f, 0.0f, 0.0f,
2.0f, 0.0f, 0.0f,
2.0f, 2.0f, 0.0f,
0.9f, 1.1f, 0.0f,
};
std::vector<float> nodesPart(NODES, NODES + sizeof(NODES) / sizeof(NODES[0]));
{
return EXIT_FAILURE;
}
{
return EXIT_FAILURE;
}
}
{
const int CONNECTS[] = { 0, 1, 3, 1, 2, 3};
std::vector<int> elementNodes(CONNECTS, CONNECTS + sizeof(CONNECTS) / sizeof(CONNECTS[0]));
{
return EXIT_FAILURE;
}
{
return EXIT_FAILURE;
}
}
}
{
{
const float NODES[] =
{
3.0f, 0.0f, 0.0f,
4.0f, 0.0f, 0.0f,
4.0f, 1.0f, 0.0f,
3.0f, 1.0f, 0.0f,
};
std::vector<float> nodesPart(NODES, NODES + sizeof(NODES) / sizeof(NODES[0]));
{
return EXIT_FAILURE;
}
{
return EXIT_FAILURE;
}
}
{
const int CONNECTS[] = { 0, 1, 2, 3 };
std::vector<int> elementNodes(CONNECTS, CONNECTS + sizeof(CONNECTS) / sizeof(CONNECTS[0]));
{
return EXIT_FAILURE;
}
{
return EXIT_FAILURE;
}
}
}
int state1Id = 1;
int state2Id = 2;
{
size_t adaptiveGeoIdx = 0;
size_t staticGeoIdx = 1;
int partId = 1;
{
return EXIT_FAILURE;
}
partId = 2;
{
return EXIT_FAILURE;
}
{
return EXIT_FAILURE;
}
{
return EXIT_FAILURE;
}
}
{
{
return EXIT_FAILURE;
}
}
{
{
{
const float RESULT_VALUES[] = { 1.0f };
std::vector<float> resultValues(RESULT_VALUES, RESULT_VALUES + sizeof(RESULT_VALUES) / sizeof(RESULT_VALUES[0]));
{
return EXIT_FAILURE;
}
}
{
const float RESULT_VALUES[] = { 1.0f, 2.0f };
std::vector<float> resultValues(RESULT_VALUES, RESULT_VALUES + sizeof(RESULT_VALUES) / sizeof(RESULT_VALUES[0]));
{
return EXIT_FAILURE;
}
}
}
{
{
const float RESULT_VALUES[] = { 1.2f };
std::vector<float> resultValues(RESULT_VALUES, RESULT_VALUES + sizeof(RESULT_VALUES) / sizeof(RESULT_VALUES[0]));
{
return EXIT_FAILURE;
}
}
{
const float RESULT_VALUES[] = { 1.4f };
std::vector<float> resultValues(RESULT_VALUES, RESULT_VALUES + sizeof(RESULT_VALUES) / sizeof(RESULT_VALUES[0]));
{
return EXIT_FAILURE;
}
}
}
scalarResult->
setName(
"My scalar result");
{
return EXIT_FAILURE;
}
}
{
partSettings->
setValue(
"context_geometry_index", static_cast<unsigned int>(0));
partSettings->
setValue(
"context_part_id", 1);
partSettings->
setValue(
"draw_style",
"surface_mesh");
scalarSelection->
setValue(
"fringes_result_id", 1);
std::vector<cee::Variant> stateIds(STATE_IDS, STATE_IDS + sizeof(STATE_IDS) / sizeof(STATE_IDS[0]));
stateSelection->
setValue(
"state_ids", stateIds);
viewer->
setValue(
"start_animation",
true);
if (!singleCase->setProperties(vtfxProps.
get()))
{
return EXIT_FAILURE;
}
}
{
return EXIT_FAILURE;
}
std::cout <<
"Exported successfully to file: " << fileName.
toStdString() << std::endl;
std::cout << std::endl << "Press enter to exit" << std::endl;
std::cin.ignore();
return EXIT_SUCCESS;