Hide menu
Loading...
Searching...
No Matches
exploring/brepgeometry/Program.cs

Refer to the B-Rep Geometry Exploration Example.

base_explorer.cs

// ****************************************************************************
// $Id$
//
// Copyright (C) 2008-2014, Roman Lygin. All rights reserved.
// Copyright (C) 2014-2023, CADEX. All rights reserved.
//
// This file is part of the CAD Exchanger 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;
using System.Collections.Generic;
using System.Runtime.InteropServices;
namespace brepgeometry
{
class BaseExplorer
{
public static void PrintElementary(ModelData_Conic theGeometry)
{
PrintDomain(theGeometry);
ModelData_Axis2Placement aPosition = theGeometry.Position();
ModelData_Point aLoc = aPosition.Location();
ModelData_Direction anAxis = aPosition.Axis();
ModelData_Direction aXDir = aPosition.XDirection();
ModelData_Direction aYDir = aPosition.YDirection();
PrintParameter("Location", aLoc);
PrintParameter("Axis", anAxis);
PrintParameter("X Direction", aXDir);
PrintParameter("Y Direction", aYDir);
}
public static void PrintElementary(ModelData_ElementarySurface theGeometry)
{
PrintDomain(theGeometry);
ModelData_Axis3Placement aPosition = theGeometry.Position();
ModelData_Point aLoc = aPosition.Location();
ModelData_Direction anAxis = aPosition.Axis();
ModelData_Direction aXDir = aPosition.XDirection();
ModelData_Direction aYDir = aPosition.YDirection();
PrintParameter("Location", aLoc);
PrintParameter("Axis", anAxis);
PrintParameter("X Direction", aXDir);
PrintParameter("Y Direction", aYDir);
}
public static void PrintElementary2d(ModelData_Conic2d theGeometry)
{
PrintDomain(theGeometry);
ModelData_Axis2Placement2d aPosition = theGeometry.Position();
ModelData_Point2d aLoc = aPosition.Location();
ModelData_Direction2d aXDir = aPosition.XDirection();
ModelData_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(ModelData_Curve theCurve)
{
PrintRange("Domain", theCurve.UMin(), theCurve.UMax());
}
public static void PrintDomain(ModelData_Curve2d theCurve)
{
PrintRange("Domain", theCurve.UMin(), theCurve.UMax());
}
public static void PrintDomain(ModelData_Surface theSurface)
{
PrintRange("Domain U", theSurface.UMin(), theSurface.UMax());
PrintRange("V", theSurface.VMin(), theSurface.VMax());
}
public static void PrintParameter(ModelData_Point theValue)
{
Console.Write("({0}, {1}); ", theValue.X(), theValue.Y());
}
public static void PrintParameter(ModelData_Direction theValue)
{
Console.Write("({0}, {1}, {2}); ", theValue.X(), theValue.Y(), theValue.Z());
}
public static void PrintParameter(ModelData_Point2d theValue)
{
Console.Write("({0}, {1}); ", theValue.X(), theValue.Y());
}
public static void PrintParameter(ModelData_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, ModelData_Point theValue)
{
Console.Write("{0} = ", theName);
PrintParameter(theValue);
}
public static void PrintParameter(string theName, ModelData_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, ModelData_Point2d theValue)
{
Console.Write("{0} = ", theName);
PrintParameter(theValue);
}
public static void PrintParameter(string theName, ModelData_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(ModelData_ShapeOrientation theOrientation)
{
Console.Write("Orientation = ");
switch (theOrientation)
{
case ModelData_ShapeOrientation.ModelData_SO_Forward: Console.Write("Forward"); break;
case ModelData_ShapeOrientation.ModelData_SO_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 axis placement in 3D.
Definition: ModelData_Axis2Placement.hxx:38
const ModelData_Direction & XDirection() const
Returns a X-direction of the axis placement.
Definition: ModelData_Axis2Placement.cxx:118
const ModelData_Direction & YDirection() const
Returns a Y-direction of the axis placement.
Definition: ModelData_Axis2Placement.cxx:127
const ModelData_Point & Location() const
Returns a location point of the axis placement.
Definition: ModelData_Axis2Placement.cxx:100
const ModelData_Direction & Axis() const
Returns a Z-direction of the axis placement.
Definition: ModelData_Axis2Placement.cxx:109
Defines a right-handed or left-handed axis placement in 3D.
Definition: ModelData_Axis3Placement.hxx:38
const ModelData_Direction & Axis() const
Returns a Z-direction of the axis placement.
Definition: ModelData_Axis3Placement.cxx:90
const ModelData_Direction & YDirection() const
Returns a Y-direction of the axis placement.
Definition: ModelData_Axis3Placement.cxx:108
const ModelData_Point & Location() const
Returns a location point of the axis placement.
Definition: ModelData_Axis3Placement.cxx:81
const ModelData_Direction & XDirection() const
Returns a X-direction of the axis placement.
Definition: ModelData_Axis3Placement.cxx:99
Base class for 2D conic curves.
Definition: ModelData_Conic2d.hxx:34
const ModelData_Axis2Placement2d & Position() const
Returns an axis placement.
Definition: ModelData_Conic2d.cxx:47
Base class for 3D conic curves.
Definition: ModelData_Conic.hxx:34
const ModelData_Axis2Placement & Position() const
Returns an axis placement.
Definition: ModelData_Conic.cxx:59
Base class for 2D curves.
Definition: ModelData_Curve2d.hxx:42
double UMin() const
Returns a minimum parameter of a definition domain.
Definition: ModelData_Curve2d.cxx:155
double UMax() const
Returns a maximum parameter of a definition domain.
Definition: ModelData_Curve2d.cxx:162
Base class for 3D curves.
Definition: ModelData_Curve.hxx:44
double UMin() const
Returns a minimum parameter of a definition domain.
Definition: ModelData_Curve.cxx:232
double UMax() const
Returns a maximum parameter of a definition domain.
Definition: ModelData_Curve.cxx:239
Defines a 2D direction.
Definition: ModelData_Direction2d.hxx:176
Defines a 3D direction.
Definition: ModelData_Direction.hxx:180
Base class for elementary surfaces.
Definition: ModelData_ElementarySurface.hxx:38
const ModelData_Axis3Placement & Position() const
Returns a surface axis.
Definition: ModelData_ElementarySurface.cxx:65
Defines a 2D point.
Definition: ModelData_Point2d.hxx:193
Defines a 3D point.
Definition: ModelData_Point.hxx:295
Base class for geometrical surfaces.
Definition: ModelData_Surface.hxx:44
double VMax() const
Returns a maximum parameter of a definition domain in V direction.
Definition: ModelData_Surface.cxx:262
double UMax() const
Returns a maximum parameter of a definition domain in U direction.
Definition: ModelData_Surface.cxx:242
double VMin() const
Returns a minimum parameter of a definition domain in V direction.
Definition: ModelData_Surface.cxx:252
double UMin() const
Returns a minimum parameter of a definition domain in U direction.
Definition: ModelData_Surface.cxx:233
Defines classes, types, and global functions related to CAD Exchanger.
Definition: A3DSTestLib.hxx:22
ModelData_ShapeOrientation
Defines shape orientation.
Definition: ModelData_ShapeOrientation.hxx:25

curve_explorer.cs

// ****************************************************************************
// $Id$
//
// Copyright (C) 2008-2014, Roman Lygin. All rights reserved.
// Copyright (C) 2014-2023, CADEX. All rights reserved.
//
// This file is part of the CAD Exchanger 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;
using System.Collections.Generic;
using System.Runtime.InteropServices;
namespace brepgeometry
{
class CurveExplorer : BaseExplorer
{
// Prints curve type name and prints shape info in some cases
public static void PrintCurveInfo(ModelData_Curve theCurve)
{
switch (theCurve.Type())
{
case ModelData_CurveType.ModelData_CT_Line:
PrintLine(ModelData_Line.Cast(theCurve));
break;
case ModelData_CurveType.ModelData_CT_Circle:
PrintCircle(ModelData_Circle.Cast(theCurve));
break;
case ModelData_CurveType.ModelData_CT_Ellipse:
PrintEllipse(ModelData_Ellipse.Cast(theCurve));
break;
case ModelData_CurveType.ModelData_CT_Hyperbola:
PrintHyperbola(ModelData_Hyperbola.Cast(theCurve));
break;
case ModelData_CurveType.ModelData_CT_Parabola:
PrintParabola(ModelData_Parabola.Cast(theCurve));
break;
case ModelData_CurveType.ModelData_CT_Bezier:
PrintBezierCurve(ModelData_BezierCurve.Cast(theCurve));
break;
case ModelData_CurveType.ModelData_CT_BSpline:
PrintBSplineCurve(ModelData_BSplineCurve.Cast(theCurve));
break;
case ModelData_CurveType.ModelData_CT_Offset:
PrintOffsetCurve(ModelData_OffsetCurve.Cast(theCurve));
break;
case ModelData_CurveType.ModelData_CT_Trimmed:
PrintTrimmedCurve(ModelData_TrimmedCurve.Cast(theCurve));
break;
default:
break;
}
}
public static void PrintLine(ModelData_Line theLine)
{
PrintName("Line");
ModelData_Point aLoc = theLine.Location();
ModelData_Direction aDir = theLine.Direction();
PrintDomain(theLine);
PrintParameter("Location", aLoc);
PrintParameter("Direction", aDir);
}
public static void PrintCircle(ModelData_Circle theCircle)
{
PrintName("Circle");
double aRadius = theCircle.Radius();
PrintElementary(theCircle);
PrintParameter("Radius", aRadius);
}
public static void PrintEllipse(ModelData_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(ModelData_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(ModelData_Parabola theParabola)
{
PrintName("Parabola");
double aFocal = theParabola.Focal();
PrintElementary(theParabola);
PrintParameter("Focal", aFocal);
}
public static void PrintBezierCurve(ModelData_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) =>
{
ModelData_Point aPole = theBezier.Pole(i);
PrintParameter(aPole);
});
PrintCollection("Weights", aNumberOfPoles, (int i) =>
{
double aWeight = theBezier.Weight(i);
PrintParameter(aWeight);
});
}
public static void PrintBSplineCurve(ModelData_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) =>
{
ModelData_Point aPole = theBSpline.Pole(i);
PrintParameter(aPole);
});
PrintCollection("Weights", aNumberOfPoles, (int i) =>
{
double aWeight = theBSpline.Weight(i);
PrintParameter(aWeight);
});
}
public static void PrintOffsetCurve(ModelData_OffsetCurve theOffset)
{
PrintName("Offset Curve");
ModelData_Direction aDir = theOffset.Direction();
double anOffset = theOffset.Offset();
PrintDomain(theOffset);
PrintParameter("Direction", aDir);
PrintParameter("Offset", anOffset);
Console.Write("Basis Curve = ");
PrintCurveInfo(theOffset.BasisCurve());
}
public static void PrintTrimmedCurve(ModelData_TrimmedCurve theTrimmed)
{
PrintName("Trimmed Curve");
PrintDomain(theTrimmed);
Console.Write("Basis Curve = ");
PrintCurveInfo(theTrimmed.BasisCurve());
}
}
}
Defines 3D B-Spline curve.
Definition: ModelData_BSplineCurve.hxx:34
int NumberOfKnots() const
Returns number of unique knots.
Definition: ModelData_BSplineCurve.cxx:176
int Multiplicity(int theIndex) const
Returns a knot multiplicity.
Definition: ModelData_BSplineCurve.cxx:228
double Knot(int theIndex) const
Returns a knot value.
Definition: ModelData_BSplineCurve.cxx:195
double Weight(int theIndex) const
Returns a weight value.
Definition: ModelData_BSplineCurve.cxx:304
int Degree() const
Returns degree.
Definition: ModelData_BSplineCurve.cxx:168
ModelData_Point Pole(int theIndex) const
Returns a pole value.
Definition: ModelData_BSplineCurve.cxx:261
int NumberOfPoles() const
Returns number of poles.
Definition: ModelData_BSplineCurve.cxx:184
Defines 3D Bezier curve.
Definition: ModelData_BezierCurve.hxx:36
double Weight(const int theIndex) const
Returns a weight value.
Definition: ModelData_BezierCurve.cxx:177
ModelData_Point Pole(const int theIndex) const
Returns a pole value.
Definition: ModelData_BezierCurve.cxx:143
int Degree() const
Returns degree.
Definition: ModelData_BezierCurve.cxx:124
int NumberOfPoles() const
Returns number of poles.
Definition: ModelData_BezierCurve.cxx:132
Defines 3D circle.
Definition: ModelData_Circle.hxx:33
double Radius() const
Returns radius.
Definition: ModelData_Circle.cxx:68
ModelData_CurveType Type() const
Returns a curve type.
Definition: ModelData_Curve.cxx:205
Defines 3D ellipse.
Definition: ModelData_Ellipse.hxx:32
double MinorRadius() const
Returns a minor radius.
Definition: ModelData_Ellipse.cxx:83
double MajorRadius() const
Returns a major radius.
Definition: ModelData_Ellipse.cxx:75
Defines 3D hyperbola.
Definition: ModelData_Hyperbola.hxx:32
double MinorRadius() const
Returns a minor radius.
Definition: ModelData_Hyperbola.cxx:80
double MajorRadius() const
Returns a major radius.
Definition: ModelData_Hyperbola.cxx:72
Defines 3D line.
Definition: ModelData_Line.hxx:36
const ModelData_Direction & Direction() const
Returns a direction.
Definition: ModelData_Line.cxx:70
const ModelData_Point & Location() const
Returns an origin point.
Definition: ModelData_Line.cxx:60
Defines 3D offset curve.
Definition: ModelData_OffsetCurve.hxx:33
const ModelData_Direction & Direction() const
Returns reference direction.
Definition: ModelData_OffsetCurve.cxx:97
ModelData_Curve BasisCurve() const
Returns basis curve.
Definition: ModelData_OffsetCurve.cxx:90
double Offset() const
Returns offset value.
Definition: ModelData_OffsetCurve.cxx:104
Defines 3D parabola.
Definition: ModelData_Parabola.hxx:32
double Focal() const
Returns a focal.
Definition: ModelData_Parabola.cxx:70
Defines explicitly trimmed 3D curve.
Definition: ModelData_TrimmedCurve.hxx:32
ModelData_CurveType
Defines curve type.
Definition: ModelData_CurveType.hxx:25

pcurve_explorer.cs

// ****************************************************************************
// $Id$
//
// Copyright (C) 2008-2014, Roman Lygin. All rights reserved.
// Copyright (C) 2014-2023, CADEX. All rights reserved.
//
// This file is part of the CAD Exchanger 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;
using System.Collections.Generic;
using System.Runtime.InteropServices;
namespace brepgeometry
{
class PCurveExplorer : BaseExplorer
{
// Prints 2d curve type name and prints shape info in some cases
public static void PrintPCurveInfo(ModelData_Curve2d theCurve)
{
switch (theCurve.Type())
{
case ModelData_CurveType.ModelData_CT_Line:
PrintLine(ModelData_Line2d.Cast(theCurve));
break;
case ModelData_CurveType.ModelData_CT_Circle:
PrintCircle(ModelData_Circle2d.Cast(theCurve));
break;
case ModelData_CurveType.ModelData_CT_Ellipse:
PrintEllipse(ModelData_Ellipse2d.Cast(theCurve));
break;
case ModelData_CurveType.ModelData_CT_Hyperbola:
PrintHyperbola(ModelData_Hyperbola2d.Cast(theCurve));
break;
case ModelData_CurveType.ModelData_CT_Parabola:
PrintParabola(ModelData_Parabola2d.Cast(theCurve));
break;
case ModelData_CurveType.ModelData_CT_Bezier:
PrintBezierCurve(ModelData_BezierCurve2d.Cast(theCurve));
break;
case ModelData_CurveType.ModelData_CT_BSpline:
PrintBSplineCurve(ModelData_BSplineCurve2d.Cast(theCurve));
break;
case ModelData_CurveType.ModelData_CT_Offset:
PrintOffsetCurve(ModelData_OffsetCurve2d.Cast(theCurve));
break;
case ModelData_CurveType.ModelData_CT_Trimmed:
PrintTrimmedCurve(ModelData_TrimmedCurve2d.Cast(theCurve));
break;
default:
break;
}
}
public static void PrintLine(ModelData_Line2d theLine)
{
PrintName("Line 2d");
ModelData_Point2d aLoc = theLine.Location();
ModelData_Direction2d aDir = theLine.Direction();
PrintDomain(theLine);
PrintParameter("Location", aLoc);
PrintParameter("Direction", aDir);
}
public static void PrintCircle(ModelData_Circle2d theCircle)
{
PrintName("Circle 2d");
double aRadius = theCircle.Radius();
PrintElementary2d(theCircle);
PrintParameter("Radius", aRadius);
}
public static void PrintEllipse(ModelData_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(ModelData_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(ModelData_Parabola2d theParabola)
{
PrintName("Parabola 2d");
double aFocal = theParabola.Focal();
PrintElementary2d(theParabola);
PrintParameter("Focal", aFocal);
}
public static void PrintBezierCurve(ModelData_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) => {
ModelData_Point2d aPole = theBezier.Pole(i);
PrintParameter(aPole);
});
PrintCollection("Weights", aNumberOfPoles, (int i) => {
double aWeight = theBezier.Weight(i);
PrintParameter(aWeight);
});
}
public static void PrintBSplineCurve(ModelData_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) => {
ModelData_Point2d aPole = theBSpline.Pole(i);
PrintParameter(aPole);
});
PrintCollection("Weights", aNumberOfPoles, (int i) => {
double aWeight = theBSpline.Weight(i);
PrintParameter(aWeight);
});
}
public static void PrintOffsetCurve(ModelData_OffsetCurve2d theOffset)
{
PrintName("Offset Curve 2d");
double anOffset = theOffset.Offset();
PrintDomain(theOffset);
PrintParameter("Offset", anOffset);
Console.Write("Basis Curve = ");
PrintPCurveInfo(theOffset.BasisCurve());
}
public static void PrintTrimmedCurve(ModelData_TrimmedCurve2d theTrimmed)
{
PrintName("Trimmed Curve 2d");
PrintDomain(theTrimmed);
Console.Write("Basis Curve = ");
PrintPCurveInfo(theTrimmed.BasisCurve());
}
}
}
Defines 2D B-Spline curve.
Definition: ModelData_BSplineCurve2d.hxx:34
double Knot(int theIndex) const
Returns a knot value.
Definition: ModelData_BSplineCurve2d.cxx:172
int NumberOfKnots() const
Returns number of unique knots.
Definition: ModelData_BSplineCurve2d.cxx:153
double Weight(int theIndex) const
Returns a weight value.
Definition: ModelData_BSplineCurve2d.cxx:281
ModelData_Point2d Pole(int theIndex) const
Returns a pole value.
Definition: ModelData_BSplineCurve2d.cxx:238
int Multiplicity(int theIndex) const
Returns a knot multiplicity.
Definition: ModelData_BSplineCurve2d.cxx:205
int Degree() const
Returns degree.
Definition: ModelData_BSplineCurve2d.cxx:145
int NumberOfPoles() const
Returns number of poles.
Definition: ModelData_BSplineCurve2d.cxx:161
Defines 2D Bezier curve.
Definition: ModelData_BezierCurve2d.hxx:34
int NumberOfPoles() const
Returns number of poles.
Definition: ModelData_BezierCurve2d.cxx:114
ModelData_Point2d Pole(const int theIndex) const
Returns a pole value.
Definition: ModelData_BezierCurve2d.cxx:125
int Degree() const
Returns degree.
Definition: ModelData_BezierCurve2d.cxx:106
double Weight(const int theIndex) const
Returns a weight value.
Definition: ModelData_BezierCurve2d.cxx:159
Defines 2D circle.
Definition: ModelData_Circle2d.hxx:32
double Radius() const
Returns radius.
Definition: ModelData_Circle2d.cxx:59
ModelData_CurveType Type() const
Returns a curve type.
Definition: ModelData_Curve2d.cxx:128
Defines 2D ellipse.
Definition: ModelData_Ellipse2d.hxx:32
double MajorRadius() const
Returns a major radius.
Definition: ModelData_Ellipse2d.cxx:62
double MinorRadius() const
Returns a minor radius.
Definition: ModelData_Ellipse2d.cxx:70
Defines 2D hyperbola.
Definition: ModelData_Hyperbola2d.hxx:32
double MajorRadius() const
Returns a major radius.
Definition: ModelData_Hyperbola2d.cxx:62
double MinorRadius() const
Returns a minor radius.
Definition: ModelData_Hyperbola2d.cxx:70
Defines 2D line.
Definition: ModelData_Line2d.hxx:35
const ModelData_Point2d & Location() const
Returns an origin point.
Definition: ModelData_Line2d.cxx:53
const ModelData_Direction2d & Direction() const
Returns a direction.
Definition: ModelData_Line2d.cxx:63
Defines 2D offset curve.
Definition: ModelData_OffsetCurve2d.hxx:32
Defines 2D parabola.
Definition: ModelData_Parabola2d.hxx:32
double Focal() const
Returns a focal.
Definition: ModelData_Parabola2d.cxx:61
Defines explicitly trimmed 2D curve.
Definition: ModelData_TrimmedCurve2d.hxx:32

shape_explorer.cs

// ****************************************************************************
// $Id$
//
// Copyright (C) 2008-2014, Roman Lygin. All rights reserved.
// Copyright (C) 2014-2023, CADEX. All rights reserved.
//
// This file is part of the CAD Exchanger 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;
using System.Collections.Generic;
using System.Runtime.InteropServices;
namespace brepgeometry
{
class ShapeExplorer : ModelData_Model.VoidElementVisitor
{
public override void Apply(ModelData_Part thePart)
{
if (aBRep != null)
{
Console.WriteLine("Part = \"{0}\"", thePart.Name());
ExploreBRep(aBRep);
}
}
private void ExploreBRep(ModelData_BRepRepresentation theBRep)
{
// Get() method retrieves bodies listed in B-Rep representation by calling data providers flushing
// Flushing isn't an elementary process so it can take a significant time (seconds, minutes depending on a model structure)
ModelData_BodyList aBodyList = theBRep.Get();
// Iterate over bodies
for (uint i = 0; i < aBodyList.Size(); ++i)
{
ModelData_Body aBody = aBodyList.Access(i);
Console.WriteLine("Body {0}: -type {1}", i, BodyType(aBody));
ExploreShape(aBody);
}
}
// Recursive iterating over the Shape until reaching vertices
private void ExploreShape(ModelData_Shape theShape)
{
if (theShape.Type() == ModelData_ShapeType.ModelData_ST_Face)
{
myCurrentFace = ModelData_Face.Cast(theShape);
}
++myBase.myNestingLevel;
while (aShapeIt.HasNext())
{
ModelData_Shape aShape = aShapeIt.Next();
PrintShape(aShape);
ExploreShape(aShape);
}
if (theShape.Type() == ModelData_ShapeType.ModelData_ST_Face)
{
myCurrentFace = null;
}
--myBase.myNestingLevel;
}
// Returns body type name
private string BodyType(ModelData_Body theBody)
{
switch (theBody.BodyType())
{
case ModelData_BodyType.ModelData_BT_Solid: return "Solid";
case ModelData_BodyType.ModelData_BT_Sheet: return "Sheet";
case ModelData_BodyType.ModelData_BT_Wireframe: return "Wireframe";
case ModelData_BodyType.ModelData_BT_Acorn: return "Acorn";
}
return "Undefined";
}
// Prints shape type name and prints shape info in some cases
private void PrintShape(ModelData_Shape theShape)
{
myBase.PrintTabulation();
switch (theShape.Type())
{
case ModelData_ShapeType.ModelData_ST_Solid:
Console.Write("Solid");
break;
case ModelData_ShapeType.ModelData_ST_Shell:
PrintShell(ModelData_Shell.Cast(theShape));
break;
case ModelData_ShapeType.ModelData_ST_Wire:
PrintWire(ModelData_Wire.Cast(theShape));
break;
case ModelData_ShapeType.ModelData_ST_Face:
PrintFace(ModelData_Face.Cast(theShape));
break;
case ModelData_ShapeType.ModelData_ST_Edge:
PrintEdge(ModelData_Edge.Cast(theShape));
break;
case ModelData_ShapeType.ModelData_ST_Vertex:
PrintVertex(ModelData_Vertex.Cast(theShape));
break;
default: Console.Write("Undefined"); break;
}
Console.WriteLine();
}
private void PrintShell(ModelData_Shell theWire)
{
BaseExplorer.PrintName("Shell");
++myBase.myNestingLevel;
BaseExplorer.PrintOrientation(theWire.Orientation());
--myBase.myNestingLevel;
}
private void PrintWire(ModelData_Wire theWire)
{
BaseExplorer.PrintName("Wire");
++myBase.myNestingLevel;
BaseExplorer.PrintOrientation(theWire.Orientation());
--myBase.myNestingLevel;
}
private void PrintFace(ModelData_Face theFace)
{
BaseExplorer.PrintName("Face");
++myBase.myNestingLevel;
BaseExplorer.PrintOrientation(theFace.Orientation());
Console.WriteLine();
ModelData_Surface aSurface = theFace.Surface();
myBase.PrintTabulation();
BaseExplorer.PrintName("Surface");
SurfaceExplorer.PrintSurface(aSurface);
--myBase.myNestingLevel;
}
private void PrintEdge(ModelData_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;
ModelData_Curve aCurve = theEdge.Curve(ref aFirstParameter, ref 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;
ModelData_Curve2d aPCurve = theEdge.PCurve(myCurrentFace,
ref aFirstParameter2d,
ref aLastParameter2d);
Console.WriteLine();
myBase.PrintTabulation();
BaseExplorer.PrintName("PCurve");
BaseExplorer.PrintRange("Edge Range", aFirstParameter2d, aLastParameter2d);
PCurveExplorer.PrintPCurveInfo(aPCurve);
}
--myBase.myNestingLevel;
}
private void PrintVertex(ModelData_Vertex theVertex)
{
BaseExplorer.PrintName("Vertex");
ModelData_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 ModelData_Face myCurrentFace = null;
}
}
Defines precise Boundary Representation of part.
Definition: ModelData_BRepRepresentation.hxx:39
const ModelData_BodyList & Get() const
Returns an associated topological object.
Definition: ModelData_BRepRepresentation.cxx:626
Base_UTF16String Name() const
Definition: ModelData_BaseObject.cxx:218
Defines a root topological shape that can be owned by B-Rep representation.
Definition: ModelData_Body.hxx:28
ModelData_BodyType BodyType() const
Returns a body type.
Definition: ModelData_Body.cxx:139
Defines a list of bodies.
Definition: ModelData_BodyList.hxx:31
Defines an edge.
Definition: ModelData_Edge.hxx:36
ModelData_Curve2d PCurve(const ModelData_Face &theFace, double &theFirstParameter, double &theLastParameter) const
Returns edge p-curve on a face and its limits.
Definition: ModelData_Edge.cxx:643
static const ModelData_Edge & Cast(const ModelData_Shape &theShape)
Casts a base class object to ModelData_Edge.
Definition: ModelData_Edge.cxx:688
bool IsDegenerated() const
Returns true if the edge is degenerated.
Definition: ModelData_Edge.cxx:671
double Tolerance() const
Returns edge tolerance.
Definition: ModelData_Edge.cxx:664
ModelData_Curve Curve(double &theFirstParameter, double &theLastParameter) const
Returns edge 3D curve and its limits.
Definition: ModelData_Edge.cxx:632
Defines a topological face.
Definition: ModelData_Face.hxx:32
ModelData_Surface Surface() const
Returns underlying surface.
Definition: ModelData_Face.cxx:253
static const ModelData_Face & Cast(const ModelData_Shape &theShape)
Cast operator.
Definition: ModelData_Face.cxx:282
Provides CAD Exchanger data model.
Definition: ModelData_Model.hxx:43
Defines a leaf node in the scene graph hiearchy.
Definition: ModelData_Part.hxx:35
ModelData_BRepRepresentation BRepRepresentation() const
Definition: ModelData_Part.cxx:360
Iterates over subshapes in a shape.
Definition: ModelData_Shape.hxx:41
Base class of topological shapes.
Definition: ModelData_Shape.hxx:37
ModelData_ShapeType Type() const
Returns a shape type.
Definition: ModelData_Shape.cxx:358
ModelData_ShapeOrientation Orientation() const
Returns orientation flag.
Definition: ModelData_Shape.cxx:392
Defines a connected set of faces.
Definition: ModelData_Shell.hxx:31
Defines topological vertex.
Definition: ModelData_Vertex.hxx:31
ModelData_Point Point() const
Returns a 3D point this vertex resides at.
Definition: ModelData_Vertex.cxx:68
double Tolerance() const
Returns vertex tolerance.
Definition: ModelData_Vertex.cxx:89
Defines a connected set of edges.
Definition: ModelData_Wire.hxx:31
ModelData_ShapeType
Defines shape type.
Definition: ModelData_ShapeType.hxx:25
ModelData_BodyType
Defines a body type.
Definition: ModelData_BodyType.hxx:25

surface_explorer.cs

// ****************************************************************************
// $Id$
//
// Copyright (C) 2008-2014, Roman Lygin. All rights reserved.
// Copyright (C) 2014-2023, CADEX. All rights reserved.
//
// This file is part of the CAD Exchanger 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;
using System.Collections.Generic;
using System.Runtime.InteropServices;
namespace brepgeometry
{
class SurfaceExplorer : BaseExplorer
{
// Prints surface type name and prints shape info in some cases
public static void PrintSurface(ModelData_Surface theSurface)
{
switch (theSurface.Type())
{
case ModelData_SurfaceType.ModelData_ST_Plane:
PrintPlane(ModelData_Plane.Cast(theSurface));
break;
case ModelData_SurfaceType.ModelData_ST_Cylinder:
PrintCylinder(ModelData_CylindricalSurface.Cast(theSurface));
break;
case ModelData_SurfaceType.ModelData_ST_Cone:
PrintCone(ModelData_ConicalSurface.Cast(theSurface));
break;
case ModelData_SurfaceType.ModelData_ST_Sphere:
PrintSphere(ModelData_SphericalSurface.Cast(theSurface));
break;
case ModelData_SurfaceType.ModelData_ST_Torus:
PrintTorus(ModelData_ToroidalSurface.Cast(theSurface));
break;
case ModelData_SurfaceType.ModelData_ST_LinearExtrusion:
PrintLinearExtrusion(ModelData_SurfaceOfLinearExtrusion.Cast(theSurface));
break;
case ModelData_SurfaceType.ModelData_ST_Revolution:
PrintRevolution(ModelData_SurfaceOfRevolution.Cast(theSurface));
break;
case ModelData_SurfaceType.ModelData_ST_Bezier:
PrintBezierSurface(ModelData_BezierSurface.Cast(theSurface));
break;
case ModelData_SurfaceType.ModelData_ST_BSpline:
PrintBSplineSurface(ModelData_BSplineSurface.Cast(theSurface));
break;
case ModelData_SurfaceType.ModelData_ST_Offset:
PrintOffsetSurface(ModelData_OffsetSurface.Cast(theSurface));
break;
case ModelData_SurfaceType.ModelData_ST_Trimmed:
PrintTrimmedSurface(ModelData_RectangularTrimmedSurface.Cast(theSurface));
break;
default:
break;
}
}
public static void PrintPlane(ModelData_Plane thePlane)
{
PrintName("Plane");
PrintElementary(thePlane);
}
public static void PrintCylinder(ModelData_CylindricalSurface theCylinder)
{
PrintName("Cylinder");
double aRadius = theCylinder.Radius();
PrintElementary(theCylinder);
PrintParameter("Radius", aRadius);
}
public static void PrintCone(ModelData_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(ModelData_SphericalSurface theSphere)
{
PrintName("Sphere");
double aRadius = theSphere.Radius();
PrintElementary(theSphere);
PrintParameter("Radius", aRadius);
}
public static void PrintTorus(ModelData_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(ModelData_SurfaceOfLinearExtrusion theLinearExtrusion)
{
PrintName("Linear Extrusion Surface");
ModelData_Direction aDir = theLinearExtrusion.Direction();
PrintDomain(theLinearExtrusion);
PrintParameter("Direction", aDir);
Console.Write("Basis Curve = ");
CurveExplorer.PrintCurveInfo(theLinearExtrusion.BasisCurve());
}
public static void PrintRevolution(ModelData_SurfaceOfRevolution theRevolution)
{
PrintName("Revolution Surface");
ModelData_Direction aDir = theRevolution.Direction();
ModelData_Point aLoc = theRevolution.Location();
PrintDomain(theRevolution);
PrintParameter("Location", aLoc);
PrintParameter("Direction", aDir);
Console.Write("Basis Curve = ");
CurveExplorer.PrintCurveInfo(theRevolution.BasisCurve());
}
public static void PrintBezierSurface(ModelData_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) => {
ModelData_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(ModelData_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) => {
ModelData_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(ModelData_OffsetSurface theOffset)
{
PrintName("Offset Surface");
double anOffset = theOffset.Offset();
PrintDomain(theOffset);
PrintParameter("Offset", anOffset);
Console.Write("Basis Surface = ");
PrintSurface(theOffset.BasisSurface());
}
public static void PrintTrimmedSurface(ModelData_RectangularTrimmedSurface theTrimmed)
{
PrintName("Trimmed Surface");
PrintDomain(theTrimmed);
Console.Write("Basis Surface = ");
PrintSurface(theTrimmed.BasisSurface());
}
}
}
Defines a B-Spline surface.
Definition: ModelData_BSplineSurface.hxx:34
ModelData_Point Pole(int theUIndex, int theVIndex) const
Returns a pole value.
Definition: ModelData_BSplineSurface.cxx:380
double UKnot(int theUIndex) const
Returns a U-knot value.
Definition: ModelData_BSplineSurface.cxx:250
double Weight(int theUIndex, int theVIndex) const
Returns a weight value.
Definition: ModelData_BSplineSurface.cxx:434
int UMultiplicity(int theUIndex) const
Returns a U knot multiplicity.
Definition: ModelData_BSplineSurface.cxx:314
int NumberOfUKnots() const
Returns number of unique U-knots.
Definition: ModelData_BSplineSurface.cxx:219
int VDegree() const
Returns V-degree.
Definition: ModelData_BSplineSurface.cxx:212
int UDegree() const
Returns U-degree.
Definition: ModelData_BSplineSurface.cxx:205
int NumberOfUPoles() const
Returns number of U-poles.
Definition: ModelData_BSplineSurface.cxx:233
double VKnot(int theVIndex) const
Returns a V-knot value.
Definition: ModelData_BSplineSurface.cxx:261
int NumberOfVKnots() const
Returns number of unique V-knots.
Definition: ModelData_BSplineSurface.cxx:226
int NumberOfVPoles() const
Returns number of V-poles.
Definition: ModelData_BSplineSurface.cxx:240
int VMultiplicity(int theVIndex) const
Returns a V knot multiplicity.
Definition: ModelData_BSplineSurface.cxx:326
Defines a Bezier surface.
Definition: ModelData_BezierSurface.hxx:34
int NumberOfVPoles() const
Returns number of V-poles.
Definition: ModelData_BezierSurface.cxx:154
ModelData_Point Pole(const int theUIndex, const int theVIndex) const
Returns a pole value.
Definition: ModelData_BezierSurface.cxx:165
int VDegree() const
Returns degree.
Definition: ModelData_BezierSurface.cxx:138
int NumberOfUPoles() const
Returns number of U-poles.
Definition: ModelData_BezierSurface.cxx:146
int UDegree() const
Returns degree.
Definition: ModelData_BezierSurface.cxx:130
double Weight(const int theUIndex, const int theVIndex) const
Returns a weight value.
Definition: ModelData_BezierSurface.cxx:203
Defines a conical surface.
Definition: ModelData_ConicalSurface.hxx:32
double Radius() const
Returns reference radius.
Definition: ModelData_ConicalSurface.cxx:108
double SemiAngle() const
Returns semi-angle.
Definition: ModelData_ConicalSurface.cxx:101
Defines a cylindrical surface.
Definition: ModelData_CylindricalSurface.hxx:32
double Radius() const
Returns radius.
Definition: ModelData_CylindricalSurface.cxx:85
Defines an offset surface.
Definition: ModelData_OffsetSurface.hxx:32
double Offset() const
Returns offset value.
Definition: ModelData_OffsetSurface.cxx:106
ModelData_Surface BasisSurface() const
Returns basis surface.
Definition: ModelData_OffsetSurface.cxx:99
Defines a plane.
Definition: ModelData_Plane.hxx:32
Defines an explicitly trimmed surface.
Definition: ModelData_RectangularTrimmedSurface.hxx:32
ModelData_Surface BasisSurface() const
Returns basis surface.
Definition: ModelData_RectangularTrimmedSurface.cxx:88
Defines a spherical surface.
Definition: ModelData_SphericalSurface.hxx:32
double Radius() const
Returns radius.
Definition: ModelData_SphericalSurface.cxx:89
ModelData_SurfaceType Type() const
Returns a surface type.
Definition: ModelData_Surface.cxx:195
Defines a surface of linear extrusion.
Definition: ModelData_SurfaceOfLinearExtrusion.hxx:34
Defines a surface of revolution.
Definition: ModelData_SurfaceOfRevolution.hxx:35
const ModelData_Point & Location() const
Returns an origin point of a rotation axis.
Definition: ModelData_SurfaceOfRevolution.cxx:103
Defines a toroidal surface.
Definition: ModelData_ToroidalSurface.hxx:32
double MinorRadius() const
Returns minor radius.
Definition: ModelData_ToroidalSurface.cxx:99
double MajorRadius() const
Returns major radius.
Definition: ModelData_ToroidalSurface.cxx:90
ModelData_SurfaceType
Defines surface type.
Definition: ModelData_SurfaceType.hxx:25

Program.cs

// ****************************************************************************
// $Id$
//
// Copyright (C) 2008-2014, Roman Lygin. All rights reserved.
// Copyright (C) 2014-2023, CADEX. All rights reserved.
//
// This file is part of the CAD Exchanger 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;
using System.Collections.Generic;
using System.Runtime.InteropServices;
namespace brepgeometry
{
class Program
{
// For more information see https://stackoverflow.com/questions/8836093/how-can-i-specify-a-dllimport-path-at-runtime
[DllImport("kernel32.dll", CharSet = CharSet.Auto, SetLastError = true)]
static extern bool SetDllDirectory(string lpPathName);
static int Main(string[] args)
{
// Add runtime path to CAD Exchanger libraries (e.g. compiled with Visual Studio 2015)
SetDllDirectory("../../../../../../win64/vc14.1/bin");
string aKey = LicenseKey.Value();
// Activate the license (aKey must be defined in cadex_license.cs)
if (!LicenseManager.Activate(aKey))
{
Console.WriteLine("Failed to activate CAD Exchanger 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 XML file to be read");
return 1;
}
string aSource = args[0];
if (!new ModelData_ModelReader().Read(new Base_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;
}
}
}
Defines a Unicode (UTF-16) string wrapping a standard string.
Definition: Base_UTF16String.hxx:34
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