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 .

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:40
Reads STEP and native format.
Definition ModelReader.hxx:33
Contains classes, namespaces, enums, types, and global functions related to Manufacturing Toolkit.
Definition LicenseManager_LicenseError.hxx:30
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:45
Defines an RGBA color.
Definition Color.hxx:32
Writes an image file with graphical content of a model.
Definition ImageWriter.hxx:41
Defines parameters of the ImageWriter.
Definition ImageWriterParameters.hxx:34
  • 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