using System;
namespace pmi
{
class Program
{
static int Main(string[] args)
{
string aKey = MTKLicenseKey.Value();
if (!LicenseManager.Activate(aKey))
{
Console.WriteLine("Failed to activate Manufacturing Toolkit license.");
return 1;
}
if (args.Length != 1)
{
Console.WriteLine("Usage: " +
$"{System.Reflection.Assembly.GetExecutingAssembly().Location} <input_file>, where:");
Console.WriteLine($" <input_file> is a name of the file to be read");
Console.WriteLine($"");
return 1;
}
string aSource = args[0];
var aModel =
new Model();
aParams.SetReadPMI(true);
aReader.SetParameters(aParams);
{
Console.WriteLine($"Failed to read the file {aSource}");
return 1;
}
Console.WriteLine($"Model: {aModel.Name()}\n");
SceneGraphVisitor aVisitor = new SceneGraphVisitor();
aModel.Accept(aVisitor);
return 0;
}
}
class TabulatedOutput
{
public static void WriteLine(Object theObject)
{
PrintTabulation();
Console.WriteLine(theObject);
}
public static void IncreaseIndent() { ++myNestingLevel; }
public static void DecreaseIndent() { --myNestingLevel; }
private static void PrintTabulation()
{
if (myNestingLevel <= 0)
{
return;
}
for (int i = 0; i < myNestingLevel - 1; i++)
{
if (i < 2 || i == 3)
{
Console.Write("| ");
}
else
{
Console.Write(" ");
}
}
Console.Write("|__");
if (myNestingLevel > 3)
{
Console.Write(" ");
}
}
private static int myNestingLevel = 0;
}
{
public override void Apply(
Part thePart)
{
PrintName(
"Part", thePart.
Name());
ExplorePMI(thePart);
}
public override bool VisitEnter(
Instance theInstance)
{
TabulatedOutput.IncreaseIndent();
PrintName(
"Instance", theInstance.
Name());
ExplorePMI(theInstance);
return true;
}
public override bool VisitEnter(
Assembly theAssembly)
{
TabulatedOutput.IncreaseIndent();
PrintName(
"Assembly", theAssembly.
Name());
ExplorePMI(theAssembly);
return true;
}
public override void VisitLeave(
Instance theInstance)
{
TabulatedOutput.DecreaseIndent();
}
public override void VisitLeave(
Assembly theAssembly)
{
TabulatedOutput.DecreaseIndent();
}
{
var aPMIData = theSGE.
PMI();
if (aPMIData != null)
{
TabulatedOutput.WriteLine("PMI Data:");
TabulatedOutput.IncreaseIndent();
if (aPMIData.NumberOfElements() == 0)
{
return;
}
foreach (var anElement in aPMIData.Elements())
{
TabulatedOutput.WriteLine("PMI Data: " + anElement.Name());
TabulatedOutput.IncreaseIndent();
if (aSemanticRepresentation !=
null && !aSemanticRepresentation.
IsEmpty())
{
TabulatedOutput.WriteLine("Semantic Representation:");
TabulatedOutput.IncreaseIndent();
PMISemanticVisitor aVisitor = new PMISemanticVisitor();
aSemanticRepresentation.
Accept(aVisitor);
TabulatedOutput.DecreaseIndent();
}
if (aGraphicalRepresentation !=
null && !aGraphicalRepresentation.
IsEmpty())
{
TabulatedOutput.WriteLine("Graphical Representation:");
TabulatedOutput.IncreaseIndent();
PMIGraphicalVisitor aVisitor = new PMIGraphicalVisitor();
aGraphicalRepresentation.
Accept(aVisitor);
TabulatedOutput.DecreaseIndent();
}
TabulatedOutput.DecreaseIndent();
}
TabulatedOutput.DecreaseIndent();
}
}
private void PrintName(
string theSGElement,
UTF16String theName)
{
{
TabulatedOutput.WriteLine(theSGElement + ": " + theName);
}
else
{
TabulatedOutput.WriteLine(theSGElement + ": <noname>");
}
}
}
{
{
TabulatedOutput.WriteLine("Datum");
TabulatedOutput.IncreaseIndent();
TabulatedOutput.WriteLine(
"Label: " + theComponent.
Label());
printAttributes(theComponent);
TabulatedOutput.DecreaseIndent();
}
{
TabulatedOutput.WriteLine("Dimension");
TabulatedOutput.IncreaseIndent();
TabulatedOutput.WriteLine(
"Nominal Value: " + theComponent.
NominalValue());
TabulatedOutput.WriteLine(
"Type of dimension: " + (
int)theComponent.
TypeOfDimension());
printAttributes(theComponent);
TabulatedOutput.DecreaseIndent();
}
{
TabulatedOutput.WriteLine("Geometric tolerance");
TabulatedOutput.IncreaseIndent();
TabulatedOutput.WriteLine(
"Magnitude: " + theComponent.
Magnitude());
TabulatedOutput.WriteLine(
"Type of tolerance: " + (
int)theComponent.
TypeOfTolerance());
TabulatedOutput.WriteLine(
"Tolerance zone form: " + (
int)theComponent.
ToleranceZoneForm());
printAttributes(theComponent);
TabulatedOutput.DecreaseIndent();
}
{
TabulatedOutput.WriteLine("Surface Finish");
TabulatedOutput.IncreaseIndent();
TabulatedOutput.WriteLine(
"Material removal: " + (
int)theComponent.
MaterialRemoval());
TabulatedOutput.WriteLine(
"Lay direction: " + (
int)theComponent.
LayDirection());
TabulatedOutput.WriteLine(
"All around flag: " + theComponent.
IsAllAround());
printAttributes(theComponent);
TabulatedOutput.DecreaseIndent();
}
{
{
PMISemanticAttributeVisitor aVisitor = new PMISemanticAttributeVisitor();
theComponent.
Accept(aVisitor);
}
}
}
{
{
TabulatedOutput.WriteLine(
"Modifier: " + theAttribute.
Modifier());
}
{
TabulatedOutput.WriteLine(
"ModifierWithValue: modifier=" + theAttribute.Modifier() +
", value=" + theAttribute.
Value());
}
{
TabulatedOutput.WriteLine(
"Qualifier: " + theAttribute.
Qualifier());
}
{
TabulatedOutput.WriteLine(
"PlusMinusBounds: (" + theAttribute.
LowerBound() +
", " + theAttribute.
UpperBound() +
")");
}
{
TabulatedOutput.WriteLine(
"Range: [" + theAttribute.
LowerLimit() +
", " + theAttribute.
UpperLimit() +
"]");
}
{
TabulatedOutput.WriteLine(
"LimitsAndFits: value=" + theAttribute.
Value() +
", type=" + theAttribute.
Type());
}
{
TabulatedOutput.WriteLine(
"DatumTarget: index=" + theAttribute.
Index() +
", description=" + theAttribute.
Description());
}
{
TabulatedOutput.WriteLine(
"DatumRef: precedence=" + theAttribute.
Precedence() +
", targetLabel=" + theAttribute.
TargetLabel());
}
{
TabulatedOutput.WriteLine("DatumRefCompartment:");
TabulatedOutput.IncreaseIndent();
if (aNumberOfReferences > 0)
{
TabulatedOutput.WriteLine("References:");
TabulatedOutput.IncreaseIndent();
for (uint i = 0; i < aNumberOfReferences; i++)
{
}
TabulatedOutput.DecreaseIndent();
}
if (aNumberOfModifierAttributes > 0)
{
TabulatedOutput.WriteLine("Modifiers:");
TabulatedOutput.IncreaseIndent();
for (uint i = 0; i < aNumberOfModifierAttributes; i++)
{
}
TabulatedOutput.DecreaseIndent();
}
TabulatedOutput.DecreaseIndent();
}
{
TabulatedOutput.WriteLine(
"MaximumValue: " + theAttribute.
MaxValue());
}
{
TabulatedOutput.WriteLine(
"Displacement: " + theAttribute.
Displacement());
}
{
TabulatedOutput.WriteLine(
"LengthUnit: " + theAttribute.
Unit());
}
{
TabulatedOutput.WriteLine(
"AngleUnit: " + theAttribute.
Unit());
}
{
TabulatedOutput.WriteLine("Machining allowance");
TabulatedOutput.IncreaseIndent();
TabulatedOutput.WriteLine(
"Value: " + theAttribute.
Value());
TabulatedOutput.WriteLine(
"Upper bound: " + theAttribute.
UpperBound());
TabulatedOutput.WriteLine(
"Lower bound: " + theAttribute.
LowerBound());
TabulatedOutput.DecreaseIndent();
}
{
TabulatedOutput.WriteLine(
"Surface texture requirement #" + (
int)theAttribute.
Precedence());
TabulatedOutput.IncreaseIndent();
TabulatedOutput.WriteLine(
"Specification limit: " + (
int)theAttribute.
SpecificationLimit());
TabulatedOutput.WriteLine(
"Filter name: " + theAttribute.
FilterName());
TabulatedOutput.WriteLine(
"Short wave filter: " + theAttribute.
ShortWaveFilter());
TabulatedOutput.WriteLine(
"Long wave filter: " + theAttribute.
LongWaveFilter());
TabulatedOutput.WriteLine(
"Surface parameter: " + (
int)theAttribute.
SurfaceParameter());
TabulatedOutput.WriteLine(
"Evaluation length: " + theAttribute.
EvaluationLength());
TabulatedOutput.WriteLine(
"Comparison rule: " + (
int)theAttribute.
ComparisonRule());
TabulatedOutput.WriteLine(
"Limit value: " + theAttribute.
LimitValue());
TabulatedOutput.DecreaseIndent();
}
}
{
{
TabulatedOutput.WriteLine("Outline");
TabulatedOutput.IncreaseIndent();
PMIOutlineVisitor aVisitor = new PMIOutlineVisitor();
theComponent.
Outline().
Accept(aVisitor);
TabulatedOutput.DecreaseIndent();
}
{
TabulatedOutput.WriteLine(
"Text [" + theComponent.
Text() +
"]");
}
{
}
}
{
{
}
{
}
{
TabulatedOutput.WriteLine(
"Curve set [" + theOutline.
NumberOfCurves() +
" curves]");
}
{
TabulatedOutput.WriteLine(
"Curve2d set [" + theOutline.
NumberOfCurves() +
" curves]");
}
{
TabulatedOutput.WriteLine("Outline set:");
TabulatedOutput.IncreaseIndent();
return true;
}
{
TabulatedOutput.DecreaseIndent();
}
}
}
Defines a group of model element.
Definition Assembly.hxx:33
size_t NumberOfTriangles() const
Returns a number of triangles.
Definition IndexedTriangleSet.cxx:326
Defines an occurrence of assembly or part in a scene graph.
Definition Instance.hxx:31
Base class for part, instance and assembly.
Definition ModelElement.hxx:38
PMI::Data PMI() const
Returns the object PMI.
Definition ModelElement.cxx:96
UTF16String Name() const
Returns a name.
Definition ModelElement.cxx:55
Defines a visitor of the scene graph elements.
Definition ModelElementVisitor.hxx:53
Provides MTK data model.
Definition Model.hxx:40
Reads STEP and native format.
Definition ModelReader.hxx:31
Defines parameters of the ModelReader.
Definition ModelReaderParameters.hxx:29
Defines a leaf node in the scene graph hiearchy.
Definition Part.hxx:34
size_t NumberOfPolylines() const
Returns a number of polylines in polyline set.
Definition Polyline2dSet.cxx:70
size_t NumberOfPolylines() const
Returns a number of polylines in polyline set.
Definition PolylineSet.cxx:72
Defines an angle unit.
Definition SemanticAttribute.hxx:260
ModelData::AngleUnit Unit() const
Returns the unit.
Definition SemanticAttribute.cxx:639
Defines a collection of outlines.
Definition Outline.hxx:121
Defines an outline consist of 2d curves.
Definition Outline.hxx:102
size_t NumberOfCurves() const
Returns the number of the added curves.
Definition Outline.cxx:302
Defines an outline consist of curves.
Definition Outline.hxx:83
size_t NumberOfCurves() const
Returns the number of the added curves.
Definition Outline.cxx:231
Defines a component represented by a datum, datum feature symbol or datum target.
Definition SemanticComponent.hxx:147
UTF16String Label() const
Returns the label of the datum.
Definition SemanticComponent.cxx:300
Defines a datum reference.
Definition SemanticAttribute.hxx:172
size_t Precedence() const
Returns the precedence value.
Definition SemanticAttribute.cxx:420
const UTF16String & TargetLabel() const
Returns the target lable.
Definition SemanticAttribute.cxx:432
Defines a compartment of datum references or compartments.
Definition SemanticAttribute.hxx:191
size_t NumberOfReferences() const
Returns the number of the datum compartment references.
Definition SemanticAttribute.cxx:470
const PMI::ModifierAttribute & ModifierAttribute(size_t theIndex) const
Returns the specific modifier attribute.
Definition SemanticAttribute.cxx:494
size_t NumberOfModifierAttributes() const
Returns the number of the modifier attributes.
Definition SemanticAttribute.cxx:488
const SemanticAttribute & Reference(size_t theIndex) const
Returns the specific datum compartment reference.
Definition SemanticAttribute.cxx:476
Defines a datum target data.
Definition SemanticAttribute.hxx:153
size_t Index() const
Returns the index.
Definition SemanticAttribute.cxx:368
const UTF16String & Description() const
Returns the description.
Definition SemanticAttribute.cxx:380
Defines a component represented by a dimensional tolerance.
Definition SemanticComponent.hxx:54
double NominalValue() const
Returns the nominal value of the dimension.
Definition SemanticComponent.cxx:157
DimensionType TypeOfDimension() const
Returns the type of the dimension.
Definition SemanticComponent.cxx:173
Defines a displacement value for an unequally disposed geometric tolerance.
Definition SemanticAttribute.hxx:228
double Displacement() const
Returns the displacement value.
Definition SemanticAttribute.cxx:568
Defines a component represented by a geometric tolerance.
Definition SemanticComponent.hxx:91
double Magnitude() const
Returns the magnitude value of the tolerance.
Definition SemanticComponent.cxx:226
ToleranceZoneFormType ToleranceZoneForm() const
Returns the tolerance zone form.
Definition SemanticComponent.cxx:242
ToleranceType TypeOfTolerance() const
Returns the type of the tolerance.
Definition SemanticComponent.cxx:258
Defines a visitor of the components.
Definition GraphicalComponentVisitor.hxx:34
Defines a PMI graphical element.
Definition GraphicalRepresentation.hxx:34
Defines a length unit.
Definition SemanticAttribute.hxx:244
ModelData::LengthUnit Unit() const
Returns the unit.
Definition SemanticAttribute.cxx:604
Defines a kind of a tolerance class dimension.
Definition SemanticAttribute.hxx:134
const UTF16String & Value() const
Returns the value.
Definition SemanticAttribute.cxx:327
const UTF16String & Type() const
Returns the type.
Definition SemanticAttribute.cxx:315
Defines a machining allowance and its bound (deviations).
Definition SemanticAttribute.hxx:276
double Value() const
Returns the machining allowance value.
Definition SemanticAttribute.cxx:679
double UpperBound() const
Returns upper bound.
Definition SemanticAttribute.cxx:692
double LowerBound() const
Returns the lower bound.
Definition SemanticAttribute.cxx:705
Defines a maximum value.
Definition SemanticAttribute.hxx:212
double MaxValue() const
Returns the maximum value.
Definition SemanticAttribute.cxx:531
Defines a type of the modification.
Definition SemanticAttribute.hxx:48
Defines the type of the modification with additional value.
Definition SemanticAttribute.hxx:64
double Value() const
Returns the value.
Definition SemanticAttribute.cxx:138
Defines the visitor of the outline elements.
Definition OutlineVisitor.hxx:35
Defines a component represented by an outline.
Definition GraphicalComponent.hxx:50
PMI::Outline Outline() const
Returns the outline.
Definition GraphicalComponent.cxx:226
Defines a plus and minus bounds (deviations) of a tolerance.
Definition SemanticAttribute.hxx:96
double UpperBound() const
Returns the upper bound.
Definition SemanticAttribute.cxx:213
double LowerBound() const
Returns lower bound.
Definition SemanticAttribute.cxx:226
Defines an outline consist of 2d polylines.
Definition Outline.hxx:67
ModelData::Polyline2dSet LineSet() const
Returns the line set.
Definition Outline.cxx:184
Defines an outline consist of polylines.
Definition Outline.hxx:51
ModelData::PolylineSet LineSet() const
Returns the line set.
Definition Outline.cxx:141
Defines the type of a qualifier.
Definition SemanticAttribute.hxx:80
const UTF16String & Qualifier() const
Retruns the qualifier.
Definition SemanticAttribute.cxx:176
Defines the range of a value.
Definition SemanticAttribute.hxx:115
double UpperLimit() const
Returns the upper limit.
Definition SemanticAttribute.cxx:263
double LowerLimit() const
Returns the lower limit.
Definition SemanticAttribute.cxx:276
Defines a visitor of the attributes.
Definition SemanticAttributeVisitor.hxx:45
The base class for various component types.
Definition SemanticComponent.hxx:34
void Accept(SemanticAttributeVisitor &theVisitor) const
Accepts an attribute visitor.
Definition SemanticComponent.cxx:101
bool HasAttributes() const
Returns true if semantic attributes were added and false otherwise.
Definition SemanticComponent.cxx:70
Defines a visitor of the components.
Definition SemanticComponentVisitor.hxx:34
Defines a PMI semantic representation.
Definition SemanticRepresentation.hxx:32
bool IsEmpty() const
Returns true if no semantic components were added.
Definition SemanticRepresentation.cxx:109
void Accept(SemanticComponentVisitor &theVisitor) const
Accepts the visitor.
Definition SemanticRepresentation.cxx:119
Defines a component represented by a suface texture.
Definition SemanticComponent.hxx:159
LayDirectionType LayDirection() const
Returns the type of the lay direction.
Definition SemanticComponent.cxx:368
bool IsAllAround() const
Returns true if the same surface texture is required on all surfaces around a workpiece outline and f...
Definition SemanticComponent.cxx:383
MaterialRemovalType MaterialRemoval() const
Returns the type of the material removal.
Definition SemanticComponent.cxx:353
UTF16String ManufacturingMethod() const
Returns the manufacturing method.
Definition SemanticComponent.cxx:398
Defines a surface texture requirement.
Definition SemanticAttribute.hxx:299
double LongWaveFilter() const
Returns the long wave filter value.
Definition SemanticAttribute.cxx:821
SurfaceParameterType SurfaceParameter() const
Returns the surface parameter.
Definition SemanticAttribute.cxx:833
double LimitValue() const
Returns the limit value.
Definition SemanticAttribute.cxx:874
double EvaluationLength() const
Returns the evaluation length value.
Definition SemanticAttribute.cxx:846
size_t Precedence() const
Returns the precedence value.
Definition SemanticAttribute.cxx:769
SpecificationLimitType SpecificationLimit() const
Returns the specification limit.
Definition SemanticAttribute.cxx:782
ComparisonRuleType ComparisonRule() const
Returns the comparison rule.
Definition SemanticAttribute.cxx:859
const UTF16String & FilterName() const
Returns filter name.
Definition SemanticAttribute.cxx:795
double ShortWaveFilter() const
Returns short wave filter value.
Definition SemanticAttribute.cxx:808
Defines a component represented by text.
Definition GraphicalComponent.hxx:62
UTF16String Text() const
Returns the text component.
Definition GraphicalComponent.cxx:273
Defines a component represented by a triangulation.
Definition GraphicalComponent.hxx:86
ModelData::IndexedTriangleSet TriangleSet() const
Returns the triangle set.
Definition GraphicalComponent.cxx:388
Defines a Unicode (UTF-16) string wrapping a standard string.
Definition UTF16String.hxx:30
bool IsEmpty() const
Returns true if the string is empty.
Definition UTF16String.cxx:336
Defines classes, types, enums, and functions related to topological entities and scene graph elements...
Defines classes, types, enums, and functions related to PMI entities.
Defines classes, namespaces, enums, types, and global functions related to Manufacturing Toolkit.
Definition LicenseManager_LicenseError.hxx:30