#include <cadex/LicenseManager_Activate.h>
#include <cadex/ModelData/Assembly.hxx>
#include <cadex/ModelData/Instance.hxx>
#include <cadex/ModelData/Model.hxx>
#include <cadex/ModelData/ModelReader.hxx>
#include <cadex/ModelData/ModelReaderParameters.hxx>
#include <cadex/ModelData/Part.hxx>
#include <cadex/PMI/Data.hxx>
#include <cadex/PMI/Element.hxx>
#include <cadex/PMI/GraphicalComponent.hxx>
#include <cadex/PMI/GraphicalComponentVisitor.hxx>
#include <cadex/PMI/OutlineVisitor.hxx>
#include <cadex/PMI/SemanticAttribute.hxx>
#include <cadex/PMI/SemanticAttributeVisitor.hxx>
#include <cadex/PMI/SemanticComponent.hxx>
#include <cadex/PMI/SemanticComponentVisitor.hxx>
#include <iostream>
#include "../../mtk_license.cxx"
using namespace std;
class TabulatedOutput
{
public:
template <typename T> std::ostream& operator<< (const T& theObject)
{
PrintTabulation();
cout << theObject;
return cout;
}
void IncreaseIndent()
{
++myNestingLevel;
}
void DecreaseIndent()
{
--myNestingLevel;
}
protected:
void PrintTabulation()
{
if (myNestingLevel <= 0) {
return;
}
for (int i = 0; i < myNestingLevel - 1; i++) {
if (i < 2 || i == 3) {
cout << "| ";
} else {
cout << " ";
}
}
cout << "|__";
if (myNestingLevel > 3) {
cout << " ";
}
}
int myNestingLevel = 0;
};
static TabulatedOutput theOutput;
{
public:
{
theOutput <<
"Modifier: " << theAttribute.
Modifier() << endl;
}
{
theOutput <<
"ModifierWithValue: modifier=" << theAttribute.Modifier() <<
", value=" << theAttribute.
Value()
<< endl;
}
{
theOutput <<
"Qualifier: " << theAttribute.
Qualifier() << endl;
}
{
theOutput <<
"PlusMinusBounds: (" << theAttribute.
LowerBound() <<
", " << theAttribute.
UpperBound() <<
")"
<< endl;
}
{
theOutput <<
"Range: (" << theAttribute.
LowerLimit() <<
", " << theAttribute.
UpperLimit() <<
")" << endl;
}
{
theOutput <<
"LimitsAndFits: value=" << theAttribute.
Value() <<
", type=" << theAttribute.
Type() << endl;
}
{
theOutput <<
"DatumTarget: index=" << theAttribute.
Index() <<
", description=" << theAttribute.
Description()
<< endl;
}
{
theOutput <<
"DatumRef: precedence=" << theAttribute.
Precedence()
<<
", targetLabel=" << theAttribute.
TargetLabel() << endl;
}
{
theOutput << "DatumRefCompartment:" << endl;
theOutput.IncreaseIndent();
if (aNumberOfReferences > 0) {
theOutput << "References:" << endl;
theOutput.IncreaseIndent();
for (size_t i = 0; i < aNumberOfReferences; i++) {
}
theOutput.DecreaseIndent();
}
if (aNumberOfModifierAttributes > 0) {
theOutput << "Modifiers:" << endl;
theOutput.IncreaseIndent();
for (size_t i = 0; i < aNumberOfModifierAttributes; i++) {
}
theOutput.DecreaseIndent();
}
theOutput.DecreaseIndent();
}
{
theOutput <<
"MaximumValue: " << theAttribute.
MaxValue() << endl;
}
{
theOutput <<
"Displacement: " << theAttribute.
Displacement() << endl;
}
{
theOutput <<
"LengthUnit: " <<
static_cast<int> (theAttribute.
Unit()) << endl;
}
{
theOutput <<
"AngleUnit: " <<
static_cast<int> (theAttribute.
Unit()) << endl;
}
{
theOutput << "Machining allowance" << endl;
theOutput.IncreaseIndent();
theOutput <<
"Value: " << theAttribute.
Value() << endl;
theOutput <<
"Upper bound: " << theAttribute.
UpperBound() << endl;
theOutput <<
"Lower bound: " << theAttribute.
LowerBound() << endl;
theOutput.DecreaseIndent();
}
{
theOutput <<
"Surface texture requirement #" << theAttribute.
Precedence() << endl;
theOutput.IncreaseIndent();
theOutput <<
"Specification limit: " <<
static_cast<int> (theAttribute.
SpecificationLimit()) << endl;
theOutput <<
"Filter name: " << theAttribute.
FilterName() << endl;
theOutput <<
"Short wave filter: " << theAttribute.
ShortWaveFilter() << endl;
theOutput <<
"Long wave filter: " << theAttribute.
LongWaveFilter() << endl;
theOutput <<
"Surface parameter: " <<
static_cast<int> (theAttribute.
SurfaceParameter()) << endl;
theOutput <<
"Comparison rule: " <<
static_cast<int> (theAttribute.
ComparisonRule()) << endl;
theOutput <<
"Limit value: " << theAttribute.
LimitValue() << endl;
theOutput.DecreaseIndent();
}
};
{
public:
{
theOutput << "Datum" << endl;
theOutput.IncreaseIndent();
theOutput <<
"Label: " << theComponent.
Label() << endl;
printAttributes (theComponent);
theOutput.DecreaseIndent();
}
{
theOutput << "Dimension" << endl;
theOutput.IncreaseIndent();
theOutput <<
"Nominal Value: " << theComponent.
NominalValue() << endl;
theOutput <<
"Type of dimension: " <<
static_cast<int> (theComponent.
TypeOfDimension()) << endl;
printAttributes (theComponent);
theOutput.DecreaseIndent();
}
{
theOutput << "Geometric tolerance" << endl;
theOutput.IncreaseIndent();
theOutput <<
"Magnitude: " << theComponent.
Magnitude() << endl;
theOutput <<
"Type of tolerance: " <<
static_cast<int> (theComponent.
TypeOfTolerance()) << endl;
theOutput <<
"Tolerance zone form: " <<
static_cast<int> (theComponent.
ToleranceZoneForm()) << endl;
printAttributes (theComponent);
theOutput.DecreaseIndent();
}
{
theOutput << "Surface Finish" << endl;
theOutput.IncreaseIndent();
theOutput <<
"Material removal: " <<
static_cast<int> (theComponent.
MaterialRemoval()) << endl;
theOutput <<
"Lay direction: " <<
static_cast<int> (theComponent.
LayDirection()) << endl;
theOutput <<
"All around flag: " << theComponent.
IsAllAround() << endl;
printAttributes (theComponent);
theOutput.DecreaseIndent();
}
{
PMISemanticAttributeVisitor aVisitor;
theComponent.
Accept (aVisitor);
}
}
};
{
public:
{
theOutput <<
"PolyLine set [" << theOutline.
LineSet().NumberOfPolylines() <<
" polylines]" << endl;
}
{
theOutput <<
"PolyLine2d set [" << theOutline.
LineSet().NumberOfPolylines() <<
" polylines]" << endl;
}
{
theOutput <<
"Curve set [" << theOutline.
NumberOfCurves() <<
" curves]" << endl;
}
{
theOutput <<
"Curve2d set [" << theOutline.
NumberOfCurves() <<
" curves]" << endl;
}
{
theOutput << "Outline set:" << endl;
theOutput.IncreaseIndent();
return true;
}
{
theOutput.DecreaseIndent();
}
};
{
public:
{
theOutput << "Outline" << endl;
theOutput.IncreaseIndent();
PMIOutlineVisitor aVisitor;
theComponent.
Outline().
Accept (aVisitor);
theOutput.DecreaseIndent();
}
{
theOutput <<
"Text [" << theComponent.
Text() <<
"]" << endl;
}
{
theOutput <<
"Triangulation [" << theComponent.
TriangleSet().NumberOfTriangles() <<
" triangles]" << endl;
}
};
class SceneGraphVisitor : public ModelData::ModelElementVisitor
{
public:
{
PrintName (
"Part", thePart.
Name());
ExplorePMI (thePart);
}
{
theOutput.IncreaseIndent();
PrintName (
"Instance", theInstance.
Name());
ExplorePMI (theInstance);
return true;
}
{
theOutput.IncreaseIndent();
PrintName (
"Assembly", theAssembly.
Name());
ExplorePMI (theAssembly);
return true;
}
{
theOutput.DecreaseIndent();
}
{
theOutput.DecreaseIndent();
}
private:
{
PMI::Data aPMIData = theSGE.
PMI();
if (aPMIData) {
theOutput << "PMI Data:" << endl;
theOutput.IncreaseIndent();
for (const auto& anElement : aPMIData.Elements()) {
theOutput << "PMI Element: " << anElement.Name() << endl;
theOutput.IncreaseIndent();
if (aSemanticRepresentation) {
theOutput << "Semantic Representation:" << endl;
theOutput.IncreaseIndent();
PMISemanticVisitor aVisitor;
aSemanticRepresentation.
Accept (aVisitor);
theOutput.DecreaseIndent();
}
PMI::GraphicalRepresentation aGraphicalRepresentation = anElement.GraphicalRepresentation();
if (aGraphicalRepresentation) {
theOutput << "Graphical Representation:" << endl;
theOutput.IncreaseIndent();
PMIGraphicalVisitor aVisitor;
aGraphicalRepresentation.
Accept (aVisitor);
theOutput.DecreaseIndent();
}
theOutput.DecreaseIndent();
}
theOutput.DecreaseIndent();
}
}
void PrintName (
string theSGElement,
UTF16String theName)
{
theOutput << theSGElement << ": " << theName << endl;
} else {
theOutput << theSGElement << ": <noname>" << endl;
}
}
};
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) {
cerr << "Usage: " << argv[0] << " <input_file>, where:" << endl;
cerr << " <input_file> is a name of the file to be read" << endl;
return 1;
}
const char* aSource = argv[1];
if (!aReader.
Read (aSource, aModel)) {
cerr << "Failed to read the file " << aSource << endl;
return 1;
}
cout <<
"Model: " << aModel.
Name() <<
"\n" << endl;
SceneGraphVisitor aVisitor;
return 0;
}
Defines a group of model elements.
Definition Assembly.cs:19
Defines an occurrence of an assembly or a part in a scene graph.
Definition Instance.cs:20
Base class for part, instance and assembly.
Definition ModelElement.cs:17
cadex.PMI.Data PMI()
Returns the object PMI.
Definition ModelElement.cs:118
cadex.UTF16String Name()
Returns a name.
Definition ModelElement.cs:67
Provides MTK data model.
Definition Model.cs:30
void Accept(cadex.ModelData.ModelElementVisitor theVisitor)
Accepts a visitor.
Definition Model.cs:179
cadex.UTF16String Name()
Returns a model name.
Definition Model.cs:93
Reads supported formats, see Import section.
Definition ModelReader.cs:17
bool Read(cadex.UTF16String theFilePath, cadex.ModelData.Model theModel)
Reads the file at the specified path into the specified model.
Definition ModelReader.cs:86
void SetParameters(cadex.ModelData.ModelReaderParameters theParameters)
Sets reader parameters.
Definition ModelReader.cs:67
Defines parameters of the ModelReader.
Definition ModelReaderParameters.cs:19
void SetReadPMI(bool theReadPMI)
Sets whether Product and Manufacturing Information (PMI) should be read from the file.
Definition ModelReaderParameters.cs:76
Defines a leaf node in the scene graph hierarchy.
Definition Part.cs:23
Defines an angle unit.
Definition AngleUnitAttribute.cs:18
cadex.ModelData.AngleUnit Unit()
Returns the unit.
Definition AngleUnitAttribute.cs:69
Defines a collection of outlines.
Definition CompositeOutline.cs:19
Defines an outline consisting of 2D curves.
Definition Curve2dOutline.cs:19
uint NumberOfCurves()
Returns the number of added curves.
Definition Curve2dOutline.cs:80
Defines an outline consisting of curves.
Definition CurveOutline.cs:19
uint NumberOfCurves()
Returns the number of added curves.
Definition CurveOutline.cs:80
Defines a component represented by a datum, datum feature symbol or datum target.
Definition DatumComponent.cs:21
cadex.UTF16String Label()
Returns the label of the datum.
Definition DatumComponent.cs:74
Defines a datum reference.
Definition DatumRefAttribute.cs:21
cadex.UTF16String TargetLabel()
Returns the target label.
Definition DatumRefAttribute.cs:86
uint Precedence()
Returns the precedence value.
Definition DatumRefAttribute.cs:74
Defines a compartment of datum references or compartments.
Definition DatumRefCompartmentAttribute.cs:22
cadex.PMI.SemanticAttribute Reference(uint theIndex)
Returns the specific datum compartment reference.
Definition DatumRefCompartmentAttribute.cs:84
uint NumberOfModifierAttributes()
Returns the number of the modifier attributes.
Definition DatumRefCompartmentAttribute.cs:99
cadex.PMI.ModifierAttribute ModifierAttribute(uint theIndex)
Returns the specific modifier attribute.
Definition DatumRefCompartmentAttribute.cs:105
uint NumberOfReferences()
Returns the number of the datum compartment references.
Definition DatumRefCompartmentAttribute.cs:78
Defines a datum target data.
Definition DatumTargetAttribute.cs:22
uint Index()
Returns the index.
Definition DatumTargetAttribute.cs:75
cadex.UTF16String Description()
Returns the description.
Definition DatumTargetAttribute.cs:86
Defines a component represented by a dimensional tolerance.
Definition DimensionComponent.cs:24
cadex.PMI.DimensionComponent.DimensionType TypeOfDimension()
Returns the type of the dimension.
Definition DimensionComponent.cs:90
double NominalValue()
Returns the nominal value of the dimension.
Definition DimensionComponent.cs:79
Defines a displacement value for an unequally disposed geometric tolerance.
Definition DisplacementAttribute.cs:19
double Displacement()
Returns the displacement value.
Definition DisplacementAttribute.cs:71
Defines a component represented by a geometric tolerance.
Definition GeometricToleranceComponent.cs:24
cadex.PMI.GeometricToleranceComponent.ToleranceType TypeOfTolerance()
Returns the type of the tolerance.
Definition GeometricToleranceComponent.cs:101
cadex.PMI.GeometricToleranceComponent.ToleranceZoneFormType ToleranceZoneForm()
Returns the tolerance zone form.
Definition GeometricToleranceComponent.cs:91
double Magnitude()
Returns the magnitude value of the tolerance.
Definition GeometricToleranceComponent.cs:80
Defines a visitor for components.
Definition GraphicalComponentVisitor.cs:17
Defines a length unit.
Definition LengthUnitAttribute.cs:19
cadex.ModelData.LengthUnit Unit()
Returns the unit.
Definition LengthUnitAttribute.cs:70
Defines a kind of a tolerance class dimension.
Definition LimitsAndFitsAttribute.cs:21
cadex.UTF16String Value()
Returns the value.
Definition LimitsAndFitsAttribute.cs:87
cadex.UTF16String Type()
Returns the type.
Definition LimitsAndFitsAttribute.cs:74
Defines a machining allowance and its bound (deviations).
Definition MachiningAllowanceAttribute.cs:19
double UpperBound()
Returns the upper bound.
Definition MachiningAllowanceAttribute.cs:87
double Value()
Returns the machining allowance value.
Definition MachiningAllowanceAttribute.cs:75
double LowerBound()
Returns the lower bound.
Definition MachiningAllowanceAttribute.cs:99
Defines a maximum value.
Definition MaximumValueAttribute.cs:19
double MaxValue()
Returns the maximum value.
Definition MaximumValueAttribute.cs:71
Defines a type of the modification.
Definition ModifierAttribute.cs:22
Defines the type of the modification with additional value.
Definition ModifierWithValueAttribute.cs:21
double Value()
Returns the value.
Definition ModifierWithValueAttribute.cs:73
Defines the visitor of the outline elements.
Definition OutlineVisitor.cs:17
Defines a component represented by an outline.
Definition OutlinedComponent.cs:23
cadex.PMI.Outline Outline()
Returns the outline.
Definition OutlinedComponent.cs:74
Defines plus and minus bounds (deviations) of a tolerance.
Definition PlusMinusBoundsAttribute.cs:18
double UpperBound()
Returns the upper bound.
Definition PlusMinusBoundsAttribute.cs:70
double LowerBound()
Returns the lower bound.
Definition PlusMinusBoundsAttribute.cs:82
Defines an outline consisting of 2D polylines.
Definition Poly2dOutline.cs:19
cadex.ModelData.Polyline2dSet LineSet()
Returns the line set.
Definition Poly2dOutline.cs:70
Defines an outline consisting of polylines.
Definition PolyOutline.cs:19
cadex.ModelData.PolylineSet LineSet()
Returns the line set.
Definition PolyOutline.cs:70
Defines the type of a qualifier.
Definition QualifierAttribute.cs:21
cadex.UTF16String Qualifier()
Retruns the qualifier.
Definition QualifierAttribute.cs:74
Defines the range of a value.
Definition RangeAttribute.cs:18
double LowerLimit()
Returns the lower limit.
Definition RangeAttribute.cs:82
double UpperLimit()
Returns the upper limit.
Definition RangeAttribute.cs:70
Defines a visitor for attributes.
Definition SemanticAttributeVisitor.cs:17
The base class for various component types.
Definition SemanticComponent.cs:19
void Accept(cadex.PMI.SemanticAttributeVisitor theVisitor)
Accepts the visitor.
Definition SemanticComponent.cs:90
bool HasAttributes()
Returns true if semantic attributes were added and false otherwise.
Definition SemanticComponent.cs:73
Defines a visitor for components.
Definition SemanticComponentVisitor.cs:17
Defines a PMI semantic representation.
Definition SemanticRepresentation.cs:28
void Accept(cadex.PMI.SemanticComponentVisitor theVisitor)
Accepts the visitor.
Definition SemanticRepresentation.cs:103
Defines a component represented by a suface texture.
Definition SurfaceFinishComponent.cs:27
cadex.PMI.SurfaceFinishComponent.LayDirectionType LayDirection()
Returns the type of the lay direction.
Definition SurfaceFinishComponent.cs:94
cadex.PMI.SurfaceFinishComponent.MaterialRemovalType MaterialRemoval()
Returns the type of the material removal.
Definition SurfaceFinishComponent.cs:83
bool IsAllAround()
Returns true if the same surface texture is required on all surfaces around a workpiece outline and f...
Definition SurfaceFinishComponent.cs:105
cadex.UTF16String ManufacturingMethod()
Returns the manufacturing method.
Definition SurfaceFinishComponent.cs:117
Defines a surface texture requirement.
Definition SurfaceTextureRequirementAttribute.cs:42
double LimitValue()
Returns the limit value.
Definition SurfaceTextureRequirementAttribute.cs:189
double LongWaveFilter()
Returns the long wave filter value.
Definition SurfaceTextureRequirementAttribute.cs:143
cadex.PMI.SurfaceTextureRequirementAttribute.SurfaceParameterType SurfaceParameter()
Returns the surface parameter.
Definition SurfaceTextureRequirementAttribute.cs:154
double ShortWaveFilter()
Returns short wave filter value.
Definition SurfaceTextureRequirementAttribute.cs:131
double EvaluationLength()
Returns the evaluation length value.
Definition SurfaceTextureRequirementAttribute.cs:166
cadex.UTF16String FilterName()
Returns filter name.
Definition SurfaceTextureRequirementAttribute.cs:118
cadex.PMI.SurfaceTextureRequirementAttribute.ComparisonRuleType ComparisonRule()
Returns the comparison rule.
Definition SurfaceTextureRequirementAttribute.cs:178
uint Precedence()
Returns the precedence value.
Definition SurfaceTextureRequirementAttribute.cs:94
cadex.PMI.SurfaceTextureRequirementAttribute.SpecificationLimitType SpecificationLimit()
Returns the specification limit.
Definition SurfaceTextureRequirementAttribute.cs:105
Defines a component represented by text.
Definition TextComponent.cs:25
cadex.UTF16String Text()
Returns the text component.
Definition TextComponent.cs:78
Defines a component represented by a triangulation.
Definition TriangulatedComponent.cs:24
cadex.ModelData.IndexedTriangleSet TriangleSet()
Returns the triangle set.
Definition TriangulatedComponent.cs:75
Defines a Unicode (UTF-16) string wrapping a standard string.
Definition UTF16String.cs:17
bool IsEmpty()
Returns true if the string is empty.
Definition UTF16String.cs:96
Contains classes, namespaces, enums, types, and global functions related to Manufacturing Toolkit.
Definition BaseObject.cs:12