using cadex.Collections;
using System;
namespace mesh
{
class Program
{
static int Main(string[] args)
{
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 aKey = MTKLicenseKey.Value();
if (!LicenseHelper.SetupRuntimeKey())
{
return 1;
}
try
{
}
{
Console.WriteLine(
"Failed to activate Manufacturing Toolkit license: " + theException.
what());
return 1;
}
string aSource = args[0];
var aModel =
new Model();
{
Console.WriteLine("Failed to read the file " + aSource);
return 1;
}
PartMeshVisitor aVisitor = new PartMeshVisitor();
aModel.Accept(aVisitor);
return 0;
}
{
public override void Apply(
Part thePart)
{
Console.WriteLine($"Part = \"{thePart.Name()}\"");
var aBodies = thePart.
Bodies();
if (!aBodies.IsEmpty)
{
ExploreMeshBodies(aBodies);
}
}
private void ExploreMeshBodies(BodyList theBodies)
{
for (int i = 0; i < theBodies.Count; ++i)
{
var aBody = theBodies[i];
{
Console.WriteLine($"MeshBody {i}");
var aMeshShapes = aMeshBody.
Shapes();
for (int j = 0; j < aMeshShapes.Count; ++j)
{
var aMeshShape = aMeshShapes[j];
Console.Write($"MeshShape {j}");
PrintMeshShapeInfo(aMeshShape);
}
}
}
}
private void PrintMeshShapeInfo(
MeshShape theMeshShape)
{
{
Console.WriteLine(" IndexedTriangleSet type.");
DumpTriangleSet(aITS);
}
{
Console.WriteLine(" PolyLineSet type");
DumpPolylineSet(aPLS);
}
{
Console.WriteLine(" PolyLine2dSet type");
DumpPolyline2dSet(aPL2dS);
}
else if (
PointSet.
CompareType(theMeshShape))
{
Console.WriteLine(" PolyPointSet type");
DumpPointSet(aPPS);
}
else
{
Console.WriteLine(" Undefined type");
}
}
private void DumpPointSet(
PointSet thePS)
{
Console.WriteLine($"PointSet: {aNumberOfPoints} points");
for (uint i = 0; i < aNumberOfPoints; ++i)
{
Console.WriteLine($"Point {i}: ({aP.X()}, {aP.Y()}, {aP.Z()})");
}
}
{
Console.WriteLine($"PolylineSet: {aNumberOfPolylines} polylines");
for (uint i = 0; i < aNumberOfPolylines; ++i)
{
Console.WriteLine($"Polyline {i}:");
Console.WriteLine(" Node coordinates:");
for (uint j = 0; j < aPoly.NumberOfPoints(); ++j)
{
Console.WriteLine($"({aP.X()}, {aP.Y()}, {aP.Z()})");
}
}
}
{
Console.WriteLine($"Polyline2dSet: {aNumberOfPolylines2d} polylines");
for (uint i = 0; i < aNumberOfPolylines2d; ++i)
{
Console.WriteLine($"Polyline2d {i}:");
Console.WriteLine(" Node coordinates:");
for (uint j = 0; j < aPoly.NumberOfPoints(); ++j)
{
Console.WriteLine($"({aP.X()}, {aP.Y()})");
}
}
}
{
Console.WriteLine($"IndexedTriangleSet: {aNumberOfTriangles} triangles:");
for (uint i = 0; i < aNumberOfTriangles; ++i)
{
Console.WriteLine($"Triangle {i}:");
for (uint j = 0; j < 3; ++j)
{
Console.WriteLine($" Node {j}: Vertex {aVI} ({aV.X()}, {aV.Y()}, {aV.Z()})");
{
Console.WriteLine($" Normal: ({aN.X()}, {aN.Y()}, {aN.Z()})");
}
}
}
}
}
}
}
const PointType & Point(size_t theIndex) const
Returns the point at position theIndex in polyline.
Definition Polyline2d.cxx:83
const PointType & Point(size_t theIndex) const
Returns the point at position theIndex in polyline.
Definition Polyline.cxx:83
Defines a polygonal shape consisting of triangles.
Definition IndexedTriangleSet.hxx:32
bool HasNormals() const
Returns true if the triangle set has explicitly defined normals.
Definition IndexedTriangleSet.cxx:299
size_t NumberOfTriangles() const
Returns a number of triangles.
Definition IndexedTriangleSet.cxx:467
const VertexType & TriangleVertex(size_t theTriangleIndex, size_t theVertexSlot) const
Returns a vertex of a triangle.
Definition IndexedTriangleSet.cxx:349
const NormalType & TriangleVertexNormal(size_t theTriangleIndex, size_t theVertexSlot) const
Returns a normal at vertex in a triangle.
Definition IndexedTriangleSet.cxx:381
int TriangleVertexIndex(size_t theTriangleIndex, size_t theVertexSlot) const
Returns a vertex index in a triangle.
Definition IndexedTriangleSet.cxx:363
Defines a body that represents a polygonal mesh (faceted or tessellated).
Definition MeshBody.hxx:30
Base class for all polygonal geometry containers.
Definition MeshShape.hxx:27
Element visitor with empty implementation.
Definition ModelElementVisitor.hxx:63
Provides MTK data model.
Definition Model.hxx:39
Reads supported formats, see Import section.
Definition ModelReader.hxx:32
Defines a leaf node in the scene graph hierarchy.
Definition Part.hxx:32
Defines a polygonal shape consisting of individual points.
Definition PointSet.hxx:30
size_t NumberOfPoints() const
Returns a number of points in point set.
Definition PointSet.cxx:67
const Geom::Point & Point(size_t theIndex) const
Returns the point at position theIndex in point set.
Definition PointSet.cxx:61
Defines a polygonal shape consisting of polylines.
Definition Polyline2dSet.hxx:30
const Geom::Polyline2d & Polyline(size_t theIndex) const
Returns the polyline at position theIndex in polyline set.
Definition Polyline2dSet.cxx:64
size_t NumberOfPolylines() const
Returns a number of polylines in polyline set.
Definition Polyline2dSet.cxx:70
Defines a polygonal shape consisting of polylines.
Definition PolylineSet.hxx:30
size_t NumberOfPolylines() const
Returns a number of polylines in polyline set.
Definition PolylineSet.cxx:72
const Geom::Polyline & Polyline(size_t theIndex) const
Returns the polyline at position theIndex in polyline set.
Definition PolylineSet.cxx:66
Defines a Unicode (UTF-16) string wrapping a standard string.
Definition UTF16String.hxx:29
Defines an exception thrown by a license manager when a valid license could not be acquired.
Definition LicenseError.hxx:37
const char * what() const noexcept override
Returns an error string.
Definition LicenseError.cxx:50
Provides MTK licensing activation and deactivation API.
Definition LicenseManager.hxx:33
static bool Deactivate()
Closes the active licensing session.
Definition LicenseManager.cxx:640
static bool Activate(const std::string &theDeveloperKey)
Activates MTK licensing using the development license key.
Definition LicenseManager.cxx:191
Contains classes, types, enums, and functions related to geometric entities.
Defines classes, types, enums, and functions related to topological entities and scene graph elements...
The mtk namespace is intended to become the primary namespace for MTK and replace direct use of the c...
Definition LicenseError.hxx:27
Contains classes, namespaces, enums, types, and global functions related to Manufacturing Toolkit.
Definition LicenseError.hxx:27