Hide menu
Loading...
Searching...
No Matches
exploring/brep_geometry/Program.cs
Refer to the B-Rep Geometry Exploration Example.

base_explorer.cs

// ****************************************************************************
//
// Copyright (C) 2008-2014, Roman Lygin. All rights reserved.
// Copyright (C) 2014-2026, CADEX. All rights reserved.
//
// This file is part of the Manufacturing Toolkit software.
//
// You may use this file under the terms of the BSD license as follows:
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
// * Redistributions of source code must retain the above copyright notice,
// this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above copyright notice,
// this list of conditions and the following disclaimer in the documentation
// and/or other materials provided with the distribution.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.
//
// ****************************************************************************
using cadex.Geom;
using System;
namespace brep_geometry
{
class BaseExplorer
{
public static void PrintElementary(Conic theGeometry)
{
PrintDomain(theGeometry);
Axis3d aPosition = theGeometry.Position();
Point aLoc = aPosition.Location();
Direction anAxis = aPosition.Axis();
Direction aXDir = aPosition.XDirection();
Direction aYDir = aPosition.YDirection();
PrintParameter("Location", aLoc);
PrintParameter("Axis", anAxis);
PrintParameter("X Direction", aXDir);
PrintParameter("Y Direction", aYDir);
}
public static void PrintElementary(ElementarySurface theGeometry)
{
PrintDomain(theGeometry);
Axis3d aPosition = theGeometry.Position();
Point aLoc = aPosition.Location();
Direction anAxis = aPosition.Axis();
Direction aXDir = aPosition.XDirection();
Direction aYDir = aPosition.YDirection();
PrintParameter("Location", aLoc);
PrintParameter("Axis", anAxis);
PrintParameter("X Direction", aXDir);
PrintParameter("Y Direction", aYDir);
}
public static void PrintElementary2d(Conic2d theGeometry)
{
PrintDomain(theGeometry);
Axis2d aPosition = theGeometry.Position();
Point2d aLoc = aPosition.Location();
Direction2d aXDir = aPosition.XDirection();
Direction2d aYDir = aPosition.YDirection();
PrintParameter("Location", aLoc);
PrintParameter("X Direction", aXDir);
PrintParameter("Y Direction", aYDir);
}
public static void PrintRange(string aName, double aFirstParameter, double aLastParameter)
{
Console.Write("{0} = [{1}, {2}]; ", aName, aFirstParameter, aLastParameter);
}
public static void PrintDomain(Curve theCurve)
{
PrintRange("Domain", theCurve.UMin(), theCurve.UMax());
}
public static void PrintDomain(Curve2d theCurve)
{
PrintRange("Domain", theCurve.UMin(), theCurve.UMax());
}
public static void PrintDomain(Surface theSurface)
{
PrintRange("Domain U", theSurface.UMin(), theSurface.UMax());
PrintRange("V", theSurface.VMin(), theSurface.VMax());
}
public static void PrintParameter(Point theValue)
{
Console.Write("({0}, {1}, {2}); ", theValue.X(), theValue.Y(), theValue.Z());
}
public static void PrintParameter(Direction theValue)
{
Console.Write("({0}, {1}, {2}); ", theValue.X(), theValue.Y(), theValue.Z());
}
public static void PrintParameter(Point2d theValue)
{
Console.Write("({0}, {1}); ", theValue.X(), theValue.Y());
}
public static void PrintParameter(Direction2d theValue)
{
Console.Write("({0}, {1}); ", theValue.X(), theValue.Y());
}
public static void PrintParameter(double theValue)
{
Console.Write("{0}; ", theValue);
}
public static void PrintParameter(string theName, Point theValue)
{
Console.Write("{0} = ", theName);
PrintParameter(theValue);
}
public static void PrintParameter(string theName, Direction theValue)
{
Console.Write("{0} = ", theName);
PrintParameter(theValue);
}
public static void PrintParameter(string theName, double theValue)
{
Console.Write("{0} = ", theName);
PrintParameter(theValue);
}
public static void PrintParameter(string theName, Point2d theValue)
{
Console.Write("{0} = ", theName);
PrintParameter(theValue);
}
public static void PrintParameter(string theName, Direction2d theValue)
{
Console.Write("{0} = ", theName);
PrintParameter(theValue);
}
public static void PrintName(string theName)
{
Console.Write("{0}: ", theName);
}
public delegate void myPrint1dElement(int i);
public static void PrintCollection(string theName,
int theFinalIndex,
myPrint1dElement thePrintElement)
{
if (theName != null)
{
Console.Write("{0} = ", theName);
}
Console.Write("[");
for (int i = 1; i <= theFinalIndex; ++i)
{
if (i > 3)
{
Console.Write("...");
break;
}
thePrintElement(i);
}
Console.Write("]; ");
}
public delegate void myPrint2dElement(int i, int j);
public static void PrintCollection(string theName,
int theFinalIndex1,
int theFinalIndex2,
myPrint2dElement thePrintElement)
{
PrintCollection(theName, theFinalIndex1, (int i) =>
{
PrintCollection(null, theFinalIndex2, (int j) => { thePrintElement(i, j); });
});
}
public static void PrintOrientation(ShapeOrientation theOrientation)
{
Console.Write("Orientation = ");
switch (theOrientation)
{
case ShapeOrientation.Forward: Console.Write("Forward"); break;
case ShapeOrientation.Reversed: Console.Write("Reversed"); break;
default: Console.Write("Undefined"); break;
}
Console.Write("; ");
}
public void PrintTabulation()
{
for (uint i = 0; i < myNestingLevel; ++i)
{
Console.Write("--- ");
}
}
public uint myNestingLevel = 0;
}
}
Defines a right-hand or left-hand axis in 2D.
Definition Axis2d.hxx:33
Defines a right-handed or left-handed axis in 3D.
Definition Axis3d.hxx:32
const Direction & XDirection() const
Returns a X-direction of the axis.
Definition Axis3d.cxx:112
const Point & Location() const
Returns an origin point.
Definition Axis3d.cxx:97
const Direction & YDirection() const
Returns a Y-direction of the axis placement.
Definition Axis3d.cxx:120
const Direction & Axis() const
Returns a Z-direction of the axis.
Definition Axis3d.cxx:105
Base class for 2D conic curves.
Definition Conic2d.hxx:29
Axis2d Position() const
Returns an axis.
Definition Conic2d.cxx:57
Base class for 3D conic curves.
Definition Conic.hxx:29
Axis3d Position() const
Returns an axis.
Definition Conic.cxx:41
Base class for 2D curves.
Definition Curve2d.hxx:38
double UMin() const
Returns a minimum parameter of a definition domain.
Definition Curve2d.cxx:261
double UMax() const
Returns a maximum parameter of a definition domain.
Definition Curve2d.cxx:269
Base class for 3D curves.
Definition Geom/Curve.hxx:37
double UMax() const
Returns a maximum parameter of a definition domain.
Definition Curve.cxx:131
double UMin() const
Returns a minimum parameter of a definition domain.
Definition Curve.cxx:123
Defines a 2D Direction.
Definition Direction2d.hxx:30
Defines a 3D Direction.
Definition Direction.hxx:32
Base class for elementary surfaces.
Definition ElementarySurface.hxx:32
Geom::Axis3d Position() const
Returns a surface axis.
Definition ElementarySurface.cxx:43
Defines a 3D point.
Definition Point2d.hxx:32
Defines a 3D point.
Definition Point.hxx:34
Base class for geometrical surfaces.
Definition Geom/Surface.hxx:38
double VMax() const
Returns a maximum parameter of a definition domain in V direction.
Definition Surface.cxx:153
double UMax() const
Returns a maximum parameter of a definition domain in U direction.
Definition Surface.cxx:139
double UMin() const
Returns a minimum parameter of a definition domain in U direction.
Definition Surface.cxx:132
double VMin() const
Returns a minimum parameter of a definition domain in V direction.
Definition Surface.cxx:146
Contains classes, types, enums, and functions related to geometric entities.
Defines classes, types, enums, and functions related to topological entities and scene graph elements...
ShapeOrientation
Defines shape orientation.
Definition ShapeOrientation.hxx:25

curve_explorer.cs

// ****************************************************************************
//
// Copyright (C) 2008-2014, Roman Lygin. All rights reserved.
// Copyright (C) 2014-2026, CADEX. All rights reserved.
//
// This file is part of the Manufacturing Toolkit software.
//
// You may use this file under the terms of the BSD license as follows:
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
// * Redistributions of source code must retain the above copyright notice,
// this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above copyright notice,
// this list of conditions and the following disclaimer in the documentation
// and/or other materials provided with the distribution.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.
//
// ****************************************************************************
using cadex.Geom;
using System;
namespace brep_geometry
{
class CurveExplorer : BaseExplorer
{
// Prints curve type name and prints shape info in some cases
public static void PrintCurveInfo(Curve theCurve)
{
switch (theCurve.Type())
{
PrintLine(Line.Cast(theCurve));
break;
case CurveType.Circle:
PrintCircle(Circle.Cast(theCurve));
break;
case CurveType.Ellipse:
PrintEllipse(Ellipse.Cast(theCurve));
break;
case CurveType.Hyperbola:
PrintHyperbola(Hyperbola.Cast(theCurve));
break;
case CurveType.Parabola:
PrintParabola(Parabola.Cast(theCurve));
break;
case CurveType.Bezier:
PrintBezierCurve(BezierCurve.Cast(theCurve));
break;
case CurveType.BSpline:
PrintBSplineCurve(BSplineCurve.Cast(theCurve));
break;
case CurveType.Offset:
PrintOffsetCurve(OffsetCurve.Cast(theCurve));
break;
default:
break;
}
}
public static void PrintLine(Line theLine)
{
PrintName("Line");
Point aLoc = theLine.Location();
Direction aDir = theLine.Direction();
PrintDomain(theLine);
PrintParameter("Location", aLoc);
PrintParameter("Direction", aDir);
}
public static void PrintCircle(Circle theCircle)
{
PrintName("Circle");
double aRadius = theCircle.Radius();
PrintElementary(theCircle);
PrintParameter("Radius", aRadius);
}
public static void PrintEllipse(Ellipse theEllipse)
{
PrintName("Ellipse");
double aMajorRadius = theEllipse.MajorRadius();
double aMinorRadius = theEllipse.MinorRadius();
PrintElementary(theEllipse);
PrintParameter("Major Radius", aMajorRadius);
PrintParameter("Minor Radius", aMinorRadius);
}
public static void PrintHyperbola(Hyperbola theHyperbola)
{
PrintName("Hyperbola");
double aMajorRadius = theHyperbola.MajorRadius();
double aMinorRadius = theHyperbola.MinorRadius();
PrintElementary(theHyperbola);
PrintParameter("Major Radius", aMajorRadius);
PrintParameter("Minor Radius", aMinorRadius);
}
public static void PrintParabola(Parabola theParabola)
{
PrintName("Parabola");
double aFocal = theParabola.Focal();
PrintElementary(theParabola);
PrintParameter("Focal", aFocal);
}
public static void PrintBezierCurve(BezierCurve theBezier)
{
PrintName("Bezier Curve");
int aDegree = theBezier.Degree();
int aNumberOfPoles = theBezier.NumberOfPoles();
PrintDomain(theBezier);
PrintParameter("Degree", aDegree);
PrintParameter("Number Of Poles", aNumberOfPoles);
PrintCollection("Poles", aNumberOfPoles, (int i) =>
{
Point aPole = theBezier.Pole(i);
PrintParameter(aPole);
});
PrintCollection("Weights", aNumberOfPoles, (int i) =>
{
double aWeight = theBezier.Weight(i);
PrintParameter(aWeight);
});
}
public static void PrintBSplineCurve(BSplineCurve theBSpline)
{
PrintName("BSpline Curve");
int aDegree = theBSpline.Degree();
int aNumberOfKnots = theBSpline.NumberOfKnots();
int aNumberOfPoles = theBSpline.NumberOfPoles();
PrintDomain(theBSpline);
PrintParameter("Degree", aDegree);
PrintParameter("Number Of Knots", aNumberOfKnots);
PrintParameter("Number Of Poles", aNumberOfPoles);
PrintCollection("Knots", aNumberOfKnots, (int i) =>
{
double aKnot = theBSpline.Knot(i);
PrintParameter(aKnot);
});
PrintCollection("Multiplicities", aNumberOfKnots, (int i) =>
{
int aMultiplicity = theBSpline.Multiplicity(i);
PrintParameter(aMultiplicity);
});
PrintCollection("Poles", aNumberOfPoles, (int i) =>
{
Point aPole = theBSpline.Pole(i);
PrintParameter(aPole);
});
PrintCollection("Weights", aNumberOfPoles, (int i) =>
{
double aWeight = theBSpline.Weight(i);
PrintParameter(aWeight);
});
}
public static void PrintOffsetCurve(OffsetCurve theOffset)
{
PrintName("Offset Curve");
Direction aDir = theOffset.Direction();
double anOffset = theOffset.Offset();
PrintDomain(theOffset);
PrintParameter("Direction", aDir);
PrintParameter("Offset", anOffset);
Console.Write("Basis Curve = ");
PrintCurveInfo(theOffset.BasisCurve());
}
}
}
Defines 3D B-Spline curve.
Definition BSplineCurve.hxx:29
int NumberOfKnots() const
Returns number of unique knots.
Definition BSplineCurve.cxx:115
double Knot(int theIndex) const
Returns a knot value.
Definition BSplineCurve.cxx:133
Point Pole(int theIndex) const
Returns a pole value.
Definition BSplineCurve.cxx:177
int NumberOfPoles() const
Returns number of poles.
Definition BSplineCurve.cxx:123
int Multiplicity(int theIndex) const
Returns a knot multiplicity.
Definition BSplineCurve.cxx:155
int Degree() const
Returns degree.
Definition BSplineCurve.cxx:107
double Weight(int theIndex) const
Returns a weight value.
Definition BSplineCurve.cxx:201
Defines 3D Bezier curve.
Definition BezierCurve.hxx:29
Point Pole(int theIndex) const
Returns a pole value.
Definition BezierCurve.cxx:91
int NumberOfPoles() const
Returns number of poles.
Definition BezierCurve.cxx:81
int Degree() const
Returns degree.
Definition BezierCurve.cxx:73
double Weight(int theIndex) const
Returns a weight value.
Definition BezierCurve.cxx:117
Defines 3D circle.
Definition Circle.hxx:27
double Radius() const
Returns radius.
Definition Circle.cxx:54
CurveType Type() const
Returns a curve type.
Definition Curve.cxx:109
Defines 3D ellipse.
Definition Ellipse.hxx:27
double MinorRadius() const
Returns a minor radius.
Definition Ellipse.cxx:68
double MajorRadius() const
Returns a major radius.
Definition Ellipse.cxx:60
Defines 3D hyperbola.
Definition Hyperbola.hxx:29
double MinorRadius() const
Returns a minor radius.
Definition Hyperbola.cxx:66
double MajorRadius() const
Returns a major radius.
Definition Hyperbola.cxx:58
Defines 3D line.
Definition Line.hxx:29
Geom::Point Location() const
Returns an origin point.
Definition Line.cxx:55
Geom::Direction Direction() const
Returns a direction.
Definition Line.cxx:63
Defines 3D offset curve.
Definition OffsetCurve.hxx:27
double Offset() const
Returns offset value.
Definition OffsetCurve.cxx:77
Curve BasisCurve() const
Returns basis curve.
Definition OffsetCurve.cxx:69
Geom::Direction Direction() const
Returns reference direction.
Definition OffsetCurve.cxx:85
Defines 3D parabola.
Definition Parabola.hxx:27
double Focal() const
Returns a focal.
Definition Parabola.cxx:57
CurveType
Defines curve type.
Definition CurveType.hxx:25

pcurve_explorer.cs

// ****************************************************************************
//
// Copyright (C) 2008-2014, Roman Lygin. All rights reserved.
// Copyright (C) 2014-2026, CADEX. All rights reserved.
//
// This file is part of the Manufacturing Toolkit software.
//
// You may use this file under the terms of the BSD license as follows:
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
// * Redistributions of source code must retain the above copyright notice,
// this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above copyright notice,
// this list of conditions and the following disclaimer in the documentation
// and/or other materials provided with the distribution.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.
//
// ****************************************************************************
using cadex.Geom;
using System;
namespace brep_geometry
{
class PCurveExplorer : BaseExplorer
{
// Prints 2D curve type name and prints shape info in some cases
public static void PrintPCurveInfo(Curve2d theCurve)
{
switch (theCurve.Type())
{
PrintLine(Line2d.Cast(theCurve));
break;
case CurveType.Circle:
PrintCircle(Circle2d.Cast(theCurve));
break;
case CurveType.Ellipse:
PrintEllipse(Ellipse2d.Cast(theCurve));
break;
case CurveType.Hyperbola:
PrintHyperbola(Hyperbola2d.Cast(theCurve));
break;
case CurveType.Parabola:
PrintParabola(Parabola2d.Cast(theCurve));
break;
case CurveType.Bezier:
PrintBezierCurve(BezierCurve2d.Cast(theCurve));
break;
case CurveType.BSpline:
PrintBSplineCurve(BSplineCurve2d.Cast(theCurve));
break;
case CurveType.Offset:
PrintOffsetCurve(OffsetCurve2d.Cast(theCurve));
break;
default:
break;
}
}
public static void PrintLine(Line2d theLine)
{
PrintName("Line 2d");
Point2d aLoc = theLine.Location();
Direction2d aDir = theLine.Direction();
PrintDomain(theLine);
PrintParameter("Location", aLoc);
PrintParameter("Direction", aDir);
}
public static void PrintCircle(Circle2d theCircle)
{
PrintName("Circle 2d");
double aRadius = theCircle.Radius();
PrintElementary2d(theCircle);
PrintParameter("Radius", aRadius);
}
public static void PrintEllipse(Ellipse2d theEllipse)
{
PrintName("Ellipse 2d");
double aMajorRadius = theEllipse.MajorRadius();
double aMinorRadius = theEllipse.MinorRadius();
PrintElementary2d(theEllipse);
PrintParameter("Major Radius", aMajorRadius);
PrintParameter("Minor Radius", aMinorRadius);
}
public static void PrintHyperbola(Hyperbola2d theHyperbola)
{
PrintName("Hyperbola 2d");
double aMajorRadius = theHyperbola.MajorRadius();
double aMinorRadius = theHyperbola.MinorRadius();
PrintElementary2d(theHyperbola);
PrintParameter("Major Radius", aMajorRadius);
PrintParameter("Minor Radius", aMinorRadius);
}
public static void PrintParabola(Parabola2d theParabola)
{
PrintName("Parabola 2d");
double aFocal = theParabola.Focal();
PrintElementary2d(theParabola);
PrintParameter("Focal", aFocal);
}
public static void PrintBezierCurve(BezierCurve2d theBezier)
{
PrintName("Bezier Curve 2d");
int aDegree = theBezier.Degree();
int aNumberOfPoles = theBezier.NumberOfPoles();
PrintDomain(theBezier);
PrintParameter("Degree", aDegree);
PrintParameter("Number Of Poles", aNumberOfPoles);
PrintCollection("Poles", aNumberOfPoles, (int i) =>
{
Point2d aPole = theBezier.Pole(i);
PrintParameter(aPole);
});
PrintCollection("Weights", aNumberOfPoles, (int i) =>
{
double aWeight = theBezier.Weight(i);
PrintParameter(aWeight);
});
}
public static void PrintBSplineCurve(BSplineCurve2d theBSpline)
{
PrintName("BSpline Curve 2d");
int aDegree = theBSpline.Degree();
int aNumberOfKnots = theBSpline.NumberOfKnots();
int aNumberOfPoles = theBSpline.NumberOfPoles();
PrintDomain(theBSpline);
PrintParameter("Degree", aDegree);
PrintParameter("Number Of Knots", aNumberOfKnots);
PrintParameter("Number Of Poles", aNumberOfPoles);
PrintCollection("Knots", aNumberOfKnots, (int i) =>
{
double aKnot = theBSpline.Knot(i);
PrintParameter(aKnot);
});
PrintCollection("Multiplicities", aNumberOfKnots, (int i) =>
{
int aMultiplicity = theBSpline.Multiplicity(i);
PrintParameter(aMultiplicity);
});
PrintCollection("Poles", aNumberOfPoles, (int i) =>
{
Point2d aPole = theBSpline.Pole(i);
PrintParameter(aPole);
});
PrintCollection("Weights", aNumberOfPoles, (int i) =>
{
double aWeight = theBSpline.Weight(i);
PrintParameter(aWeight);
});
}
public static void PrintOffsetCurve(OffsetCurve2d theOffset)
{
PrintName("Offset Curve 2d");
double anOffset = theOffset.Offset();
PrintDomain(theOffset);
PrintParameter("Offset", anOffset);
Console.Write("Basis Curve = ");
PrintPCurveInfo(theOffset.BasisCurve());
}
}
}
Defines 2D B-Spline curve.
Definition BSplineCurve2d.hxx:29
double Weight(int theIndex) const
Returns a weight value.
Definition BSplineCurve2d.cxx:308
int NumberOfKnots() const
Returns number of unique knots.
Definition BSplineCurve2d.cxx:222
int Multiplicity(int theIndex) const
Returns a knot multiplicity.
Definition BSplineCurve2d.cxx:262
int NumberOfPoles() const
Returns number of poles.
Definition BSplineCurve2d.cxx:230
double Knot(int theIndex) const
Returns a knot value.
Definition BSplineCurve2d.cxx:240
int Degree() const
Returns degree.
Definition BSplineCurve2d.cxx:214
Point2d Pole(int theIndex) const
Returns a pole value.
Definition BSplineCurve2d.cxx:284
Defines 2D Bezier curve.
Definition BezierCurve2d.hxx:29
int NumberOfPoles() const
Returns number of poles.
Definition BezierCurve2d.cxx:126
double Weight(int theIndex) const
Returns a weight value.
Definition BezierCurve2d.cxx:160
Point2d Pole(int theIndex) const
Returns a pole value.
Definition BezierCurve2d.cxx:136
int Degree() const
Returns degree.
Definition BezierCurve2d.cxx:119
Defines 2D circle.
Definition Circle2d.hxx:29
double Radius() const
Returns radius.
Definition Circle2d.cxx:77
CurveType Type() const
Returns a curve type.
Definition Curve2d.cxx:253
Defines 2D ellipse.
Definition Ellipse2d.hxx:29
double MinorRadius() const
Returns a minor radius.
Definition Ellipse2d.cxx:92
double MajorRadius() const
Returns a major radius.
Definition Ellipse2d.cxx:84
Defines 2D hyperbola.
Definition Hyperbola2d.hxx:29
double MinorRadius() const
Returns a minor radius.
Definition Hyperbola2d.cxx:92
double MajorRadius() const
Returns a major radius.
Definition Hyperbola2d.cxx:84
Defines 2D line.
Definition Line2d.hxx:30
Point2d Location() const
Returns an origin point.
Definition Line2d.cxx:88
Direction2d Direction() const
Returns a direction.
Definition Line2d.cxx:96
Defines 2D offset curve.
Definition OffsetCurve2d.hxx:29
double Offset() const
Returns offset value.
Definition OffsetCurve2d.cxx:78
Curve2d BasisCurve() const
Returns basis curve.
Definition OffsetCurve2d.cxx:70
Defines 2D parabola.
Definition Parabola2d.hxx:29
double Focal() const
Returns a focal.
Definition Parabola2d.cxx:79

shape_explorer.cs

// ****************************************************************************
//
// Copyright (C) 2008-2014, Roman Lygin. All rights reserved.
// Copyright (C) 2014-2026, CADEX. All rights reserved.
//
// This file is part of the Manufacturing Toolkit software.
//
// You may use this file under the terms of the BSD license as follows:
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
// * Redistributions of source code must retain the above copyright notice,
// this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above copyright notice,
// this list of conditions and the following disclaimer in the documentation
// and/or other materials provided with the distribution.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.
//
// ****************************************************************************
using cadex.Collections;
using cadex.Geom;
using System;
namespace brep_geometry
{
class ShapeExplorer : ModelElementVoidVisitor
{
public override void Apply(Part thePart)
{
Console.WriteLine("Part = \"{0}\"", thePart.Name());
var aBodies = thePart.Bodies();
if (!aBodies.IsEmpty)
{
ExploreBRep(aBodies);
}
}
private void ExploreBRep(BodyList theBodies)
{
// Iterate over bodies
for (int i = 0; i < theBodies.Count; ++i)
{
var aBody = theBodies[i];
Console.WriteLine("Body {0}: type {1}", i, BodyType(aBody));
ShapeIterator aFaceIt = new ShapeIterator(aBody);
for (var j = new ShapeIterator(aBody); j.HasNext();)
{
var aShape = j.Next();
ExploreShape(aShape);
}
}
}
// Recursive iterating over the Shape until reaching vertices
private void ExploreShape(Shape theShape)
{
if (theShape.Type() == ShapeType.Face)
{
myCurrentFace = Face.Cast(theShape);
}
++myBase.myNestingLevel;
ShapeIterator aShapeIt = new ShapeIterator(theShape);
while (aShapeIt.HasNext())
{
Shape aShape = aShapeIt.Next();
PrintShape(aShape);
ExploreShape(aShape);
}
if (theShape.Type() == ShapeType.Face)
{
myCurrentFace = null;
}
--myBase.myNestingLevel;
}
// Returns body type name
private string BodyType(Body theBody)
{
if (SheetBody.CompareType(theBody))
{
return "Sheet";
}
else if (SolidBody.CompareType(theBody))
{
return "Solid";
}
else if (WireframeBody.CompareType(theBody))
{
return "Wireframe";
}
return "Undefined";
}
// Prints shape type name and prints shape info in some cases
private void PrintShape(Shape theShape)
{
myBase.PrintTabulation();
switch (theShape.Type())
{
case ShapeType.Solid:
Console.Write("Solid");
break;
case ShapeType.Shell:
PrintShell(Shell.Cast(theShape));
break;
case ShapeType.Wire:
PrintWire(Wire.Cast(theShape));
break;
case ShapeType.Face:
PrintFace(Face.Cast(theShape));
break;
case ShapeType.Edge:
PrintEdge(Edge.Cast(theShape));
break;
case ShapeType.Vertex:
PrintVertex(Vertex.Cast(theShape));
break;
default: Console.Write("Undefined"); break;
}
Console.WriteLine();
}
private void PrintShell(Shell theWire)
{
BaseExplorer.PrintName("Shell");
++myBase.myNestingLevel;
BaseExplorer.PrintOrientation(theWire.Orientation());
--myBase.myNestingLevel;
}
private void PrintWire(Wire theWire)
{
BaseExplorer.PrintName("Wire");
++myBase.myNestingLevel;
BaseExplorer.PrintOrientation(theWire.Orientation());
--myBase.myNestingLevel;
}
private void PrintFace(Face theFace)
{
BaseExplorer.PrintName("Face");
++myBase.myNestingLevel;
BaseExplorer.PrintOrientation(theFace.Orientation());
Console.WriteLine();
Surface aSurface = theFace.Surface();
myBase.PrintTabulation();
BaseExplorer.PrintName("Surface");
SurfaceExplorer.PrintSurface(aSurface);
--myBase.myNestingLevel;
}
private void PrintEdge(Edge theEdge)
{
BaseExplorer.PrintName("Edge");
++myBase.myNestingLevel;
if (theEdge.IsDegenerated())
{
Console.Write("Degenerated: ");
}
BaseExplorer.PrintOrientation(theEdge.Orientation());
BaseExplorer.PrintParameter("Tolerance", theEdge.Tolerance());
if (!theEdge.IsDegenerated())
{
double aFirstParameter = 0, aLastParameter = 0;
Curve aCurve = theEdge.Curve(out aFirstParameter, out aLastParameter);
Console.WriteLine();
myBase.PrintTabulation();
BaseExplorer.PrintName("Curve");
BaseExplorer.PrintRange("Edge Range", aFirstParameter, aLastParameter);
CurveExplorer.PrintCurveInfo(aCurve);
}
if (myCurrentFace != null)
{
double aFirstParameter2d = 0, aLastParameter2d = 0;
Curve2d aPCurve = theEdge.PCurve(myCurrentFace, out aFirstParameter2d, out aLastParameter2d);
Console.WriteLine();
myBase.PrintTabulation();
BaseExplorer.PrintName("PCurve");
BaseExplorer.PrintRange("Edge Range", aFirstParameter2d, aLastParameter2d);
PCurveExplorer.PrintPCurveInfo(aPCurve);
}
--myBase.myNestingLevel;
}
private void PrintVertex(Vertex theVertex)
{
BaseExplorer.PrintName("Vertex");
Point aLoc = theVertex.Point();
double aTolerance = theVertex.Tolerance();
BaseExplorer.PrintOrientation(theVertex.Orientation());
BaseExplorer.PrintParameter("Tolerance", aTolerance);
BaseExplorer.PrintParameter("Location", aLoc);
}
private BaseExplorer myBase = new BaseExplorer();
private Face myCurrentFace = null;
}
}
Provides a base body class.
Definition Body.hxx:28
Defines an edge.
Definition ModelData/Edge.hxx:31
Geom::Curve Curve(double &theFirstParameter, double &theLastParameter) const
Returns edge 3D curve and its limits.
Definition Edge.cxx:405
double Tolerance() const
Returns edge tolerance.
Definition Edge.cxx:703
Geom::Curve2d PCurve(const Face &theFace, double &theFirstParameter, double &theLastParameter) const
Returns edge p-curve on a face and its limits.
Definition Edge.cxx:657
bool IsDegenerated() const
Returns true if the edge is degenerated.
Definition Edge.cxx:710
static const Edge & Cast(const Shape &theShape)
Casts a base class object to Edge.
Definition Edge.cxx:735
Defines a topological face.
Definition ModelData/Face.hxx:31
Geom::Surface Surface() const
Returns underlying surface.
Definition Face.cxx:322
static const Face & Cast(const Shape &theShape)
Cast operator.
Definition Face.cxx:353
UTF16String Name() const
Returns a name.
Definition ModelElement.cxx:54
Element visitor with empty implementation.
Definition ModelElementVisitor.hxx:63
Defines a leaf node in the scene graph hierarchy.
Definition Part.hxx:32
Base class of topological shapes.
Definition ModelData/Shape.hxx:37
ShapeOrientation Orientation() const
Returns orientation flag.
Definition Shape.cxx:272
ShapeType Type() const
Returns a shape type. For a null object returns Undefined.
Definition Shape.cxx:260
Iterates over subshapes in a shape.
Definition ShapeIterator.hxx:30
Provides a sheet body composed of faces and shells.
Definition SheetBody.hxx:32
Defines a connected set of faces.
Definition Shell.hxx:30
Provides a solid body composed of solids.
Definition SolidBody.hxx:28
Defines topological vertex.
Definition Vertex.hxx:28
Geom::Point Point() const
Returns a 3D point this vertex resides at.
Definition Vertex.cxx:98
double Tolerance() const
Returns vertex tolerance.
Definition Vertex.cxx:118
Defines a connected set of edges.
Definition ModelData/Wire.hxx:30
Provides a wireframe body composed of edges and wires.
Definition WireframeBody.hxx:32
ShapeType
Defines shape type.
Definition ShapeType.hxx:25

surface_explorer.cs

// ****************************************************************************
//
// Copyright (C) 2008-2014, Roman Lygin. All rights reserved.
// Copyright (C) 2014-2026, CADEX. All rights reserved.
//
// This file is part of the Manufacturing Toolkit software.
//
// You may use this file under the terms of the BSD license as follows:
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
// * Redistributions of source code must retain the above copyright notice,
// this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above copyright notice,
// this list of conditions and the following disclaimer in the documentation
// and/or other materials provided with the distribution.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.
//
// ****************************************************************************
using cadex.Geom;
using System;
namespace brep_geometry
{
class SurfaceExplorer : BaseExplorer
{
// Prints surface type name and prints shape info in some cases
public static void PrintSurface(Surface theSurface)
{
switch (theSurface.Type())
{
PrintPlane(Plane.Cast(theSurface));
break;
case SurfaceType.Cylinder:
PrintCylinder(CylindricalSurface.Cast(theSurface));
break;
case SurfaceType.Cone:
PrintCone(ConicalSurface.Cast(theSurface));
break;
case SurfaceType.Sphere:
PrintSphere(SphericalSurface.Cast(theSurface));
break;
case SurfaceType.Torus:
PrintTorus(ToroidalSurface.Cast(theSurface));
break;
case SurfaceType.LinearExtrusion:
PrintLinearExtrusion(SurfaceOfLinearExtrusion.Cast(theSurface));
break;
case SurfaceType.Revolution:
PrintRevolution(SurfaceOfRevolution.Cast(theSurface));
break;
case SurfaceType.Bezier:
PrintBezierSurface(BezierSurface.Cast(theSurface));
break;
case SurfaceType.BSpline:
PrintBSplineSurface(BSplineSurface.Cast(theSurface));
break;
case SurfaceType.Offset:
PrintOffsetSurface(OffsetSurface.Cast(theSurface));
break;
default:
break;
}
}
public static void PrintPlane(Plane thePlane)
{
PrintName("Plane");
PrintElementary(thePlane);
}
public static void PrintCylinder(CylindricalSurface theCylinder)
{
PrintName("Cylinder");
double aRadius = theCylinder.Radius();
PrintElementary(theCylinder);
PrintParameter("Radius", aRadius);
}
public static void PrintCone(ConicalSurface theCone)
{
PrintName("Cone");
double aRadius = theCone.Radius();
double aSemiAngle = theCone.SemiAngle();
PrintElementary(theCone);
PrintParameter("Radius", aRadius);
PrintParameter("Semi-Angle", aSemiAngle);
}
public static void PrintSphere(SphericalSurface theSphere)
{
PrintName("Sphere");
double aRadius = theSphere.Radius();
PrintElementary(theSphere);
PrintParameter("Radius", aRadius);
}
public static void PrintTorus(ToroidalSurface theTorus)
{
PrintName("Torus");
double aMajorRadius = theTorus.MajorRadius();
double aMinorRadius = theTorus.MinorRadius();
PrintElementary(theTorus);
PrintParameter("Major Radius", aMajorRadius);
PrintParameter("Minor Radius", aMinorRadius);
}
public static void PrintLinearExtrusion(SurfaceOfLinearExtrusion theLinearExtrusion)
{
PrintName("Linear Extrusion Surface");
Direction aDir = theLinearExtrusion.Direction();
PrintDomain(theLinearExtrusion);
PrintParameter("Direction", aDir);
Console.Write("Basis Curve = ");
CurveExplorer.PrintCurveInfo(theLinearExtrusion.BasisCurve());
}
public static void PrintRevolution(SurfaceOfRevolution theRevolution)
{
PrintName("Revolution Surface");
Direction aDir = theRevolution.Direction();
Point aLoc = theRevolution.Location();
PrintDomain(theRevolution);
PrintParameter("Location", aLoc);
PrintParameter("Direction", aDir);
Console.Write("Basis Curve = ");
CurveExplorer.PrintCurveInfo(theRevolution.BasisCurve());
}
public static void PrintBezierSurface(BezierSurface theBezier)
{
PrintName("Bezier Surface");
int aUDegree = theBezier.UDegree();
int aVDegree = theBezier.VDegree();
int aNumberOfUPoles = theBezier.NumberOfUPoles();
int aNumberOfVPoles = theBezier.NumberOfVPoles();
PrintDomain(theBezier);
PrintParameter("U Degree", aUDegree);
PrintParameter("V Degree", aVDegree);
PrintParameter("Number Of U Poles", aNumberOfUPoles);
PrintParameter("Number Of V Poles", aNumberOfVPoles);
PrintCollection("Poles", aNumberOfUPoles, aNumberOfVPoles, (int i, int j) =>
{
Point aPole = theBezier.Pole(i, j);
PrintParameter(aPole);
});
PrintCollection("Weights", aNumberOfUPoles, aNumberOfVPoles, (int i, int j) =>
{
double aWeight = theBezier.Weight(i, j);
PrintParameter(aWeight);
});
}
public static void PrintBSplineSurface(BSplineSurface theBSpline)
{
PrintName("BSpline Surface");
int aUDegree = theBSpline.UDegree();
int aVDegree = theBSpline.VDegree();
int aNumberOfUKnots = theBSpline.NumberOfUKnots();
int aNumberOfVKnots = theBSpline.NumberOfVKnots();
int aNumberOfUPoles = theBSpline.NumberOfUPoles();
int aNumberOfVPoles = theBSpline.NumberOfVPoles();
PrintDomain(theBSpline);
PrintParameter("U Degree", aUDegree);
PrintParameter("V Degree", aVDegree);
PrintParameter("Number Of U Knots", aNumberOfUKnots);
PrintParameter("Number Of V Knots", aNumberOfVKnots);
PrintParameter("Number Of U Poles", aNumberOfUPoles);
PrintParameter("Number Of V Poles", aNumberOfVPoles);
PrintCollection("U Knots", aNumberOfUKnots, (int i) =>
{
double aKnot = theBSpline.UKnot(i);
PrintParameter(aKnot);
});
PrintCollection("V Knots", aNumberOfVKnots, (int i) =>
{
double aKnot = theBSpline.VKnot(i);
PrintParameter(aKnot);
});
PrintCollection("U Multiplicities", aNumberOfUKnots, (int i) =>
{
int aUMultiplicity = theBSpline.UMultiplicity(i);
PrintParameter(aUMultiplicity);
});
PrintCollection("V Multiplicities", aNumberOfVKnots, (int i) =>
{
int aVMultiplicity = theBSpline.VMultiplicity(i);
PrintParameter(aVMultiplicity);
});
PrintCollection("Poles", aNumberOfUPoles, aNumberOfVPoles, (int i, int j) =>
{
Point aPole = theBSpline.Pole(i, j);
PrintParameter(aPole);
});
PrintCollection("Weights", aNumberOfUPoles, aNumberOfVPoles, (int i, int j) =>
{
double aWeight = theBSpline.Weight(i, j);
PrintParameter(aWeight);
});
}
public static void PrintOffsetSurface(OffsetSurface theOffset)
{
PrintName("Offset Surface");
double anOffset = theOffset.Offset();
PrintDomain(theOffset);
PrintParameter("Offset", anOffset);
Console.Write("Basis Surface = ");
PrintSurface(theOffset.BasisSurface());
}
}
}
Defines a B-Spline surface.
Definition BSplineSurface.hxx:31
int NumberOfUKnots() const
Returns number of unique U-knots.
Definition BSplineSurface.cxx:178
int UMultiplicity(int theUIndex) const
Returns a U knot multiplicity.
Definition BSplineSurface.cxx:290
int UDegree() const
Returns U-degree.
Definition BSplineSurface.cxx:146
int VDegree() const
Returns V-degree.
Definition BSplineSurface.cxx:154
int NumberOfVPoles() const
Returns number of V-poles.
Definition BSplineSurface.cxx:170
double VKnot(int theVIndex) const
Returns a V-knot value.
Definition BSplineSurface.cxx:256
int VMultiplicity(int theVIndex) const
Returns a V knot multiplicity.
Definition BSplineSurface.cxx:300
double UKnot(int theUIndex) const
Returns a U-knot value.
Definition BSplineSurface.cxx:246
double Weight(int theUIndex, int theVIndex) const
Returns a weight value.
Definition BSplineSurface.cxx:221
int NumberOfUPoles() const
Returns number of U-poles.
Definition BSplineSurface.cxx:162
Point Pole(int theUIndex, int theVIndex) const
Returns a pole value.
Definition BSplineSurface.cxx:196
int NumberOfVKnots() const
Returns number of unique V-knots.
Definition BSplineSurface.cxx:186
Defines a Bezier surface.
Definition BezierSurface.hxx:30
int NumberOfUPoles() const
Returns number of U-poles.
Definition BezierSurface.cxx:92
double Weight(int theUIndex, int theVIndex) const
Returns a weight value.
Definition BezierSurface.cxx:134
Point Pole(int theUIndex, int theVIndex) const
Returns a pole value.
Definition BezierSurface.cxx:109
int UDegree() const
Returns degree.
Definition BezierSurface.cxx:78
int VDegree() const
Returns degree.
Definition BezierSurface.cxx:85
int NumberOfVPoles() const
Returns number of V-poles.
Definition BezierSurface.cxx:99
Defines a conical surface.
Definition ConicalSurface.hxx:27
double Radius() const
Returns reference radius.
Definition ConicalSurface.cxx:92
double SemiAngle() const
Returns semi-angle.
Definition ConicalSurface.cxx:84
Defines a cylindrical surface.
Definition CylindricalSurface.hxx:29
double Radius() const
Returns radius.
Definition CylindricalSurface.cxx:68
Defines an offset surface.
Definition OffsetSurface.hxx:27
Surface BasisSurface() const
Returns basis surface.
Definition OffsetSurface.cxx:59
double Offset() const
Returns offset value.
Definition OffsetSurface.cxx:67
Defines a plane.
Definition Plane.hxx:31
Defines a spherical surface.
Definition SphericalSurface.hxx:29
double Radius() const
Returns radius.
Definition SphericalSurface.cxx:74
SurfaceType Type() const
Returns a surface type.
Definition Surface.cxx:111
Defines a surface of linear extrusion.
Definition SurfaceOfLinearExtrusion.hxx:27
Defines a surface of revolution.
Definition SurfaceOfRevolution.hxx:29
Geom::Point Location() const
Returns an origin point of a rotation axis.
Definition SurfaceOfRevolution.cxx:81
Defines a toroidal surface.
Definition ToroidalSurface.hxx:29
double MajorRadius() const
Returns major radius.
Definition ToroidalSurface.cxx:75
double MinorRadius() const
Returns minor radius.
Definition ToroidalSurface.cxx:82
SurfaceType
Defines surface type.
Definition SurfaceType.hxx:25

Program.cs

// ****************************************************************************
//
// Copyright (C) 2008-2014, Roman Lygin. All rights reserved.
// Copyright (C) 2014-2026, CADEX. All rights reserved.
//
// This file is part of the Manufacturing Toolkit software.
//
// You may use this file under the terms of the BSD license as follows:
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
// * Redistributions of source code must retain the above copyright notice,
// this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above copyright notice,
// this list of conditions and the following disclaimer in the documentation
// and/or other materials provided with the distribution.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.
//
// ****************************************************************************
using cadex;
using System;
namespace brep_geometry
{
class Program
{
static int Main(string[] args)
{
string aKey = MTKLicenseKey.Value();
// Activate the license (aKey must be defined in mtk_license.cs)
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");
return 1;
}
string aSource = args[0];
Model aModel = new Model();
if (!new ModelReader().Read(new UTF16String(aSource), aModel))
{
Console.WriteLine("Failed to read the file " + aSource);
return 1;
}
// Explore B-Rep representation of model parts
ShapeExplorer aVisitor = new ShapeExplorer();
aModel.Accept(aVisitor);
return 0;
}
}
}
Provides MTK data model.
Definition Model.hxx:39
void Accept(ModelElementVisitor &theVisitor) const
Accepts a visitor.
Definition Model.cxx:276
Reads supported formats, see Import section.
Definition ModelReader.hxx:32
Defines a Unicode (UTF-16) string wrapping a standard string.
Definition UTF16String.hxx:29
Contains classes, namespaces, enums, types, and global functions related to Manufacturing Toolkit.
Definition LicenseManager_LicenseError.hxx:29