Hide menu
Loading...
Searching...
No Matches
Thumbnail Generation Example

Table of Contents

Demonstrates how to generate and save an image of a model.

Overview

In this example we create a View::ImageWriter object which allows us to generate and save an image of ModelData::Model .

Note
Thumbnail generation uses OpenGL 2.1+ rendering (FBO support is required). On Linux it typically requires an X11 display; the DISPLAY environment variable must point to a running X server (e.g. :0, or :99 when using Xvfb). On headless servers/containers, run under Xvfb/xvfb-run.

Implementation

The main function will have the following structure:

using namespace cadex;
// Opening and converting the file
if (!ModelData::ModelReader().Read (aSource, aModel)) {
cerr << "Failed to read the file " << aSource << endl;
return 1;
}
Provides MTK data model.
Definition Model.hxx:39
Reads supported formats, see Import section.
Definition ModelReader.hxx:32
Contains classes, namespaces, enums, types, and global functions related to Manufacturing Toolkit.
Definition LicenseManager_LicenseError.hxx:29
using namespace cadex;
View::ImageWriterParameters aWriterParameters;
// Set writer parameters
aWriterParameters.SetImageWidth (750);
aWriterParameters.SetImageHeight (500);
aWriterParameters.SetViewIsFitAll (true);
View::ColorBackgroundStyle aBackground (View::Color (255, 255, 255));
aWriterParameters.SetViewBackground (aBackground);
aWriter.SetParameters (aWriterParameters);
Defines color background style.
Definition BackgroundStyle.hxx:37
Writes an image file with graphical content of a model.
Definition ImageWriter.hxx:38
Defines parameters of the ImageWriter.
Definition ImageWriterParameters.hxx:32
  • Generate an image of a model and save it into a file:
using namespace cadex;
// Generate the model image and save it into the file
if (!aWriter.WriteFile (aModel, aDest)) {
cerr << "Failed to write the image file " << aDest << endl;
return 1;
}

Files