Geometry: Create a Geometry Model with Texture
The geometry model
offers optimized part drawing with different parts and effects.
This example creates a simple triangle part and use texture effect to show scalar values.

void TutorialRunnerMainWindow::createGeometryModelWithTexture()
{
//--------------------------------------------------------------------------
// Create a geometry model and triangle part
//--------------------------------------------------------------------------
cee::vis::View* gcView = getTutorialView();
gcView->removeAllModels();
cee::PtrRef<cee::geo::GeometryModel> model = new cee::geo::GeometryModel;
gcView->addModel(model.get());
// Create the geometry part
std::vector<cee::Vec3d> vertices;
vertices.push_back(cee::Vec3d(0,0,0));
vertices.push_back(cee::Vec3d(2,0,0));
vertices.push_back(cee::Vec3d(0,1,0));
vertices.push_back(cee::Vec3d(2,1,0));
vertices.push_back(cee::Vec3d(2,2,0));
std::vector<unsigned int> indices;
indices.push_back(0); indices.push_back(1); indices.push_back(3);
indices.push_back(0); indices.push_back(3); indices.push_back(2);
indices.push_back(2); indices.push_back(3); indices.push_back(4);
cee::PtrRef<cee::geo::Part> part = new cee::geo::Part;
cee::PtrRef<cee::geo::DataIndexedTriangles> triangleData = new cee::geo::DataIndexedTriangles(vertices, indices);
part->setData(triangleData.get());
//--------------------------------------------------------------------------
// Create the scalar mapper and the legend
//--------------------------------------------------------------------------
// Create a color legend and add to view
cee::PtrRef<cee::vis::OverlayColorLegendContinuousDomain> legend = new cee::vis::OverlayColorLegendContinuousDomain(cee::vis::Font::createNormalFont().get());
legend->setTitle("Results Test \nGeometry Model");
legend->setSize(100,500);
legend->setTextColor(cee::Color3f(1,1,1));
gcView->overlay().addItem(legend.get(), cee::vis::OverlayItem::BOTTOM_LEFT, cee::vis::OverlayItem::VERTICAL);
// Create scalar mapper with 16 uniform levels
cee::PtrRef<cee::vis::ScalarMapperFilledContoursUniform> mapper = new cee::vis::ScalarMapperFilledContoursUniform;
mapper->setColors(cee::vis::ColorTableFactory::NORMAL, 16);
mapper->setRange(0, 100);
legend->setupFromScalarMapper(mapper.get());
//--------------------------------------------------------------------------
// Map texture coordinates
//--------------------------------------------------------------------------
// Create texture coordinates from scalar values
std::vector<cee::Vec2f> textureCoordinates;
textureCoordinates.push_back(mapper->mapToTextureCoordinate(2.0));
textureCoordinates.push_back(mapper->mapToTextureCoordinate(42.0));
textureCoordinates.push_back(mapper->mapToTextureCoordinate(93.0));
textureCoordinates.push_back(mapper->mapToTextureCoordinate(27.0));
textureCoordinates.push_back(mapper->mapToTextureCoordinate(68.0));
part->setTextureCoordinates(new cee::geo::TextureCoordinates(textureCoordinates));
//--------------------------------------------------------------------------
// Setup and add effects
//--------------------------------------------------------------------------
// Create texture image from mapper
cee::PtrRef<cee::Image> textureImage = new cee::Image;
mapper->updateTexture(textureImage.get());
// Add triangle and texture effects
part->settings().addEffect(cee::geo::EffectTexture::createResultMapping(textureImage.get()).get());
//--------------------------------------------------------------------------
// Add all parts to model
//--------------------------------------------------------------------------
model->addPart(part.get());
cee::BoundingBox bb = gcView->boundingBox();
gcView->camera().fitView(bb, cee::Vec3d(0, 0, -1), cee::Vec3d(0, 1, 0));
gcView->camera().inputHandler()->setRotationPoint(bb.center());
gcView->requestRedraw();
}