#include <cadex/LicenseManager_Activate.h>
#include <cadex/ModelData/Body.hxx>
#include <cadex/ModelData/ModelReader.hxx>
#include <cadex/ModelData/Model.hxx>
#include <cadex/ModelData/Solid.hxx>
#include <cadex/WallThickness_Data.hxx>
#include <cadex/WallThickness_Analyzer.hxx>
#include <iostream>
#include "../../helpers/shape_processor.hxx"
#include "../../mtk_license.cxx"
using namespace std;
class PartProcessor : public SolidProcessor
{
public:
void ProcessSolid (const ModelData::Solid& theSolid) override
{
auto aWTData = myAnalyzer.Perform (theSolid, myResolution);
PrintWTData (aWTData);
}
void PrintWTData (const WallThickness_Data& theData)
{
if (!theData.IsEmpty()) {
cout << " Min thickness = " << theData.MinThickness() << " mm" << endl;
cout << " Max thickness = " << theData.MaxThickness() << " mm\n" << endl;
} else {
cerr << " Failed to analyze the wall thickness of this entity.\n";
}
}
size_t myResolution = 1000;
private:
WallThickness_Analyzer myAnalyzer;
};
int main (int argc, char* argv[])
{
auto aKey = MTKLicenseKey::Value();
if (!CADExLicense_Activate (aKey)) {
cerr << "Failed to activate Manufacturing Toolkit license." << endl;
return 1;
}
if (argc < 2 || argc > 3) {
cerr << "Usage: " << argv[0] << " <input_file> <input_resolution>, where:" << endl;
cerr << " <input_file> is a name of the file to be read" << endl;
cerr << " <input_resolution> is an optional argument that determine accuracy"
<< " of wall thickness calculation."
<< " The larger the value, the higher the accuracy of the calculations,"
<< " but greatly increase computation time and memory usage."
<< " Should be at least 100." << endl;
return 1;
}
const char* aSource = argv[1];
size_t aResolution = 1000;
if (argc == 3) {
aResolution = std::atoi (argv[2]);
}
if (aResolution < 100) {
cout << "WARNING: Input resolution \"" << aResolution << "\" < 100. Will be used default resolution." << "\n" << endl;
aResolution = 1000;
}
ModelData::Model aModel;
ModelData::ModelReader aReader;
if (!aReader.Read (aSource, aModel)) {
cerr << "Failed to read the file " << aSource << endl;
return 1;
}
cout << "Model: " << aModel.Name() << "\n" << endl;
PartProcessor aPartProcessor;
aPartProcessor.myResolution = aResolution;
ModelData::ModelElementUniqueVisitor aVisitor (aPartProcessor);
aModel.Accept (aVisitor);
return 0;
}
Contains classes, namespaces, enums, types, and global functions related to Manufacturing Toolkit.