#define __CADEX_PREVIEW_PMI 1
#include <cadex/Base_String.hxx>
#include <cadex/LicenseManager_Activate.h>
#include <cadex/ModelData_Assembly.hxx>
#include <cadex/ModelData_Instance.hxx>
#include <cadex/ModelData_IndexedTriangleSet.hxx>
#include <cadex/ModelData_ModelReader.hxx>
#include <cadex/ModelData_Part.hxx>
#include <cadex/ModelData_SceneGraphElement.hxx>
#include <cadex/ModelData_PMIData.hxx>
#include <cadex/ModelData_PMISemanticAttribute.hxx>
#include <cadex/ModelData_PMISemanticAttributeVisitor.hxx>
#include <cadex/ModelData_PMISemanticElement.hxx>
#include <cadex/ModelData_PMISemanticElementComponent.hxx>
#include <cadex/ModelData_PMISemanticElementComponentVisitor.hxx>
#include <cadex/ModelData_PMIGraphicalElement.hxx>
#include <cadex/ModelData_PMIGraphicalElementComponent.hxx>
#include <cadex/ModelData_PMIGraphicalElementComponentVisitor.hxx>
#include <cadex/ModelData_PMIOutline.hxx>
#include <cadex/ModelData_PMIOutlineVisitor.hxx>
#include <cadex/ModelData_PMITable.hxx>
#include <cadex/ModelData_PolyLineSet.hxx>
#include <cadex/ModelData_PolyLine2dSet.hxx>
#include <cadex/STEP_ReaderParameters.hxx>
#include <iostream>
#include "../../cadex_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();
const size_t aNumberOfReferences = theAttribute.
NumberOfReferences();
if (aNumberOfReferences > 0) {
theOutput << "References:" << endl;
theOutput.IncreaseIndent();
for (size_t i = 0; i < aNumberOfReferences; i++) {
theAttribute.
Reference (i).
Accept (*
this);
}
theOutput.DecreaseIndent();
}
const size_t aNumberOfModifierAttributes = theAttribute.
NumberOfModifierAttributes();
if (aNumberOfModifierAttributes > 0) {
theOutput << "Modifiers:" << endl;
theOutput.IncreaseIndent();
for (size_t i = 0; i < aNumberOfModifierAttributes; i++) {
theAttribute.
ModifierAttribute (i).Accept (*
this);
}
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().
NumberOfFaces() <<
" triangles]" << endl;
}
};
{
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:
{
if (aPMITable) {
theOutput << "PMI Table:" << endl;
theOutput.IncreaseIndent();
while (aDataIt.HasNext()) {
theOutput <<
"PMI Data: " << aData.
Name() << endl;
theOutput.IncreaseIndent();
if (aSemanticElement) {
theOutput << "Semantic element:" << endl;
theOutput.IncreaseIndent();
PMISemanticVisitor aVisitor;
aSemanticElement.
Accept (aVisitor);
theOutput.DecreaseIndent();
}
if (aGraphicalElement) {
theOutput << "Graphical element:" << endl;
theOutput.IncreaseIndent();
PMIGraphicalVisitor aVisitor;
aGraphicalElement.
Accept (aVisitor);
theOutput.DecreaseIndent();
}
theOutput.DecreaseIndent();
}
theOutput.DecreaseIndent();
}
}
{
theOutput << theSGElement << ": " << theName << endl;
} else {
theOutput << theSGElement << ": <noname>" << endl;
}
}
};
int main (int argc, char *argv[])
{
auto aKey = LicenseKey::Value();
if (!CADExLicense_Activate (aKey)) {
cerr << "Failed to activate CAD Exchanger license." << endl;
return 1;
}
if (argc != 2) {
cerr << "Usage: " << argv[0] << " <input_file>, where:" << endl;
cerr << " <input_file> is a name of the STEP file to Read() model from" << endl;
return 1;
}
const char* aSource = argv[1];
if (!aReader.
Read (aSource, aModel)) {
cerr << "Failed to open and convert the file " << aSource << endl;
return 1;
}
SceneGraphVisitor aVisitor;
return 0;
}
bool ReadPMI() const
Specifies whether Product and Manufacturing Information (PMI) should be read from the file....
Definition: Base_ReaderParameters.cxx:164
Defines a Unicode (UTF-16) string wrapping a standard string.
Definition: Base_UTF16String.hxx:34
bool IsEmpty() const
Returns true if the string is empty.
Definition: Base_UTF16String.cxx:233
Defines a group of scene graph element.
Definition: ModelData_Assembly.hxx:33
Base_UTF16String Name() const
Definition: ModelData_BaseObject.cxx:218
IndexType NumberOfFaces() const
Returns a number of faces (triangles).
Definition: ModelData_IndexedTriangleSet.cxx:179
Defines an occurrence of assembly or part in a scene graph.
Definition: ModelData_Instance.hxx:34
Defines a visitor of the scene graph elements.
Definition: ModelData_Model.hxx:102
Provides CAD Exchanger data model.
Definition: ModelData_Model.hxx:43
void Accept(ElementVisitor &theVisitor) const
Accepts a visitor.
Definition: ModelData_Model.cxx:882
Reads any format that CAD Exchanger can import.
Definition: ModelData_ModelReader.hxx:33
void SetReaderParameters(const Base_ReaderParameters &theParameters)
Sets reader parameters.
Definition: ModelData_ModelReader.cxx:216
bool Read(const Base_UTF16String &theFilePath, ModelData_Model &theModel)
Reads the file at the specified path into the specified model.
Definition: ModelData_ModelReader.cxx:182
Defines an angle unit.
Definition: ModelData_PMISemanticAttribute.hxx:286
Defines a collection of outlines.
Definition: ModelData_PMIOutline.hxx:130
Defines an outline consist of 2d curves.
Definition: ModelData_PMIOutline.hxx:114
size_t NumberOfCurves() const
Returns number of added curves.
Definition: ModelData_PMIOutline.cxx:315
Defines an outline consist of curves.
Definition: ModelData_PMIOutline.hxx:98
size_t NumberOfCurves() const
Returns number of added curves.
Definition: ModelData_PMIOutline.cxx:248
Defines a complete PMI element.
Definition: ModelData_PMIData.hxx:40
ModelData_PMISemanticElement SemanticElement() const
Returns a semantic element.
Definition: ModelData_PMIData.cxx:117
ModelData_PMIGraphicalElement GraphicalElement() const
Returns a graphical element.
Definition: ModelData_PMIData.cxx:97
Defines a component represented by a datum, datum feature symbol or datum target.
Definition: ModelData_PMISemanticElementComponent.hxx:172
const Base_UTF16String & Label() const
Returns a label of a datum.
Definition: ModelData_PMISemanticElementComponent.cxx:317
Defines a datum reference.
Definition: ModelData_PMISemanticAttribute.hxx:199
size_t Precedence() const
Returns precedence value.
Definition: ModelData_PMISemanticAttribute.cxx:378
Defines a compartment of datum references or compartments.
Definition: ModelData_PMISemanticAttribute.hxx:218
Defines a datum target data.
Definition: ModelData_PMISemanticAttribute.hxx:180
size_t Index() const
Returns index.
Definition: ModelData_PMISemanticAttribute.cxx:335
Defines a component represented by a dimensional tolerance.
Definition: ModelData_PMISemanticElementComponent.hxx:75
double NominalValue() const
Returns nominal value of a dimension.
Definition: ModelData_PMISemanticElementComponent.cxx:197
DimensionType TypeOfDimension() const
Returns type of dimension.
Definition: ModelData_PMISemanticElementComponent.cxx:210
Defines a displacement value for an unequally disposed geometric tolerance.
Definition: ModelData_PMISemanticAttribute.hxx:254
double Displacement() const
Returns displacement value.
Definition: ModelData_PMISemanticAttribute.cxx:503
Defines a component represented by a geometric tolerance.
Definition: ModelData_PMISemanticElementComponent.hxx:116
ToleranceType TypeOfTolerance() const
Returns type of tolerance.
Definition: ModelData_PMISemanticElementComponent.cxx:279
ToleranceZoneFormType ToleranceZoneForm() const
Returns tolerance zone form.
Definition: ModelData_PMISemanticElementComponent.cxx:265
double Magnitude() const
Returns a magnitude value of a tolerance.
Definition: ModelData_PMISemanticElementComponent.cxx:251
Defines a visitor of the components.
Definition: ModelData_PMIGraphicalElementComponentVisitor.hxx:32
Defines a PMI graphical element.
Definition: ModelData_PMIGraphicalElement.hxx:40
void Accept(ModelData_PMIGraphicalElementComponentVisitor &theVisitor) const
Accepts the visitor.
Definition: ModelData_PMIGraphicalElement.cxx:160
Defines a length unit.
Definition: ModelData_PMISemanticAttribute.hxx:270
Defines a kind of a tolerance class dimension.
Definition: ModelData_PMISemanticAttribute.hxx:160
Defines a machining allowance and its bound (deviations).
Definition: ModelData_PMISemanticAttribute.hxx:302
double UpperBound() const
Returns upper bound.
Definition: ModelData_PMISemanticAttribute.cxx:598
double Value() const
Returns machining allowance value.
Definition: ModelData_PMISemanticAttribute.cxx:586
double LowerBound() const
Returns lower bound.
Definition: ModelData_PMISemanticAttribute.cxx:610
Defines a maximum value.
Definition: ModelData_PMISemanticAttribute.hxx:238
double MaxValue() const
Returns maximum value.
Definition: ModelData_PMISemanticAttribute.cxx:474
Defines a type of modification.
Definition: ModelData_PMISemanticAttribute.hxx:74
Defines a type of modification with additional value.
Definition: ModelData_PMISemanticAttribute.hxx:90
Defines a visitor of the outlines.
Definition: ModelData_PMIOutlineVisitor.hxx:34
Defines a component represented by outline.
Definition: ModelData_PMIGraphicalElementComponent.hxx:66
Defines a plus and minus bounds (deviations) of a tolerance.
Definition: ModelData_PMISemanticAttribute.hxx:122
double UpperBound() const
Returns upper bound.
Definition: ModelData_PMISemanticAttribute.cxx:207
double LowerBound() const
Returns lower bound.
Definition: ModelData_PMISemanticAttribute.cxx:219
Defines an outline consist of 2d polylines.
Definition: ModelData_PMIOutline.hxx:82
Defines an outline consist of polylines.
Definition: ModelData_PMIOutline.hxx:66
Defines a type of qualifier.
Definition: ModelData_PMISemanticAttribute.hxx:106
Defines range of value.
Definition: ModelData_PMISemanticAttribute.hxx:141
double LowerLimit() const
Returns lower limit.
Definition: ModelData_PMISemanticAttribute.cxx:260
double UpperLimit() const
Returns upper limit.
Definition: ModelData_PMISemanticAttribute.cxx:248
Defines a visitor of the attributes.
Definition: ModelData_PMISemanticAttributeVisitor.hxx:44
Base class for various component types.
Definition: ModelData_PMISemanticElementComponent.hxx:43
void Accept(ModelData_PMISemanticAttributeVisitor &theVisitor) const
Accepts an attribute visitor.
Definition: ModelData_PMISemanticElementComponent.cxx:117
bool HasAttributes() const
Returns true if semantic attributes were added and false otherwise.
Definition: ModelData_PMISemanticElementComponent.cxx:94
Defines a visitor of the components.
Definition: ModelData_PMISemanticElementComponentVisitor.hxx:33
Defines a PMI semantic element.
Definition: ModelData_PMISemanticElement.hxx:38
void Accept(ModelData_PMISemanticElementComponentVisitor &theVisitor) const
Accepts the visitor.
Definition: ModelData_PMISemanticElement.cxx:123
Defines a component represented by a suface texture.
Definition: ModelData_PMISemanticElementComponent.hxx:188
LayDirectionType LayDirection() const
Returns type of lay direction.
Definition: ModelData_PMISemanticElementComponent.cxx:374
const Base_UTF16String & ManufacturingMethod() const
Returns a manufacturing method.
Definition: ModelData_PMISemanticElementComponent.cxx:397
bool IsAllAround() const
Returns true if the same surface texture is required on all surfaces around a workpiece outline and f...
Definition: ModelData_PMISemanticElementComponent.cxx:385
MaterialRemovalType MaterialRemoval() const
Returns type of material removal.
Definition: ModelData_PMISemanticElementComponent.cxx:361
Defines a surface texture requirement.
Definition: ModelData_PMISemanticAttribute.hxx:324
double LimitValue() const
Returns limit value.
Definition: ModelData_PMISemanticAttribute.cxx:762
const Base_UTF16String & FilterName() const
Returns filter name.
Definition: ModelData_PMISemanticAttribute.cxx:687
double ShortWaveFilter() const
Returns short wave filter value.
Definition: ModelData_PMISemanticAttribute.cxx:699
double LongWaveFilter() const
Returns long wave filter value.
Definition: ModelData_PMISemanticAttribute.cxx:711
size_t Precedence() const
Returns precedence value.
Definition: ModelData_PMISemanticAttribute.cxx:664
ComparisonRuleType ComparisonRule() const
Returns comparison rule.
Definition: ModelData_PMISemanticAttribute.cxx:747
double EvaluationLength() const
Returns evaluation length value.
Definition: ModelData_PMISemanticAttribute.cxx:734
Iterator over added PMIData items, which contains graphical and semantical elements.
Definition: ModelData_PMITable.hxx:81
Defines a container storing PMI data.
Definition: ModelData_PMITable.hxx:40
Defines a component represented by text.
Definition: ModelData_PMIGraphicalElementComponent.hxx:82
Defines a component represented by triangulation.
Definition: ModelData_PMIGraphicalElementComponent.hxx:109
Defines a leaf node in the scene graph hiearchy.
Definition: ModelData_Part.hxx:35
IndexType NumberOfPolyLines() const
Returns a number of polylines.
Definition: ModelData_PolyLine2dSet.cxx:98
IndexType NumberOfPolyLines() const
Returns a number of polylines.
Definition: ModelData_PolyLineSet.cxx:89
Base class for part, instance and assembly.
Definition: ModelData_SceneGraphElement.hxx:39
ModelData_PMITable PMI() const
Returns a PMI table.
Definition: ModelData_SceneGraphElement.cxx:255
Defines parameters of the STEP_Reader.
Definition: STEP_ReaderParameters.hxx:27
Defines classes, types, and global functions related to CAD Exchanger.
Definition: A3DSTestLib.hxx:22