Hide menu
Loading...
Searching...
No Matches
exploring/brep_geometry/brep_geometry.java

Refer to the B-Rep Geometry Exploration Example.

base_explorer.java

// ****************************************************************************
// $Id$
//
// Copyright (C) 2008-2014, Roman Lygin. All rights reserved.
// Copyright (C) 2014-2025, 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.
//
// ****************************************************************************
import java.util.function.Consumer;
import java.util.function.BiConsumer;
import cadex.*;
import cadex.ModelData.*;
import cadex.Geom.*;
public class base_explorer {
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) {
System.out.print(aName + " = [" + aFirstParameter + ", " + aLastParameter + "]; ");
}
public static void PrintDomain(final Curve theCurve) {
PrintRange("Domain", theCurve.UMin(), theCurve.UMax());
}
public static void PrintDomain(final Curve2d theCurve) {
PrintRange("Domain", theCurve.UMin(), theCurve.UMax());
}
public static void PrintDomain(final Surface theSurface) {
PrintRange("Domain U", theSurface.UMin(), theSurface.UMax());
PrintRange("V", theSurface.VMin(), theSurface.VMax());
}
public static void PrintParameter(Point theValue) {
System.out.print("(" + theValue.X() + ", " + theValue.Y() + ", " + theValue.Z() + "); ");
}
public static void PrintParameter(Direction theValue) {
System.out.print("(" + theValue.X() + ", " + theValue.Y() + ", " + theValue.Z() + "); ");
}
public static void PrintParameter(Point2d theValue) {
System.out.print("(" + theValue.X() + ", " + theValue.Y() + "); ");
}
public static void PrintParameter(Direction2d theValue) {
System.out.print("(" + theValue.X() + ", " + theValue.Y() + "); ");
}
public static void PrintParameter(double theValue) {
System.out.print(theValue + "; ");
}
public static void PrintParameter(String theName, Point theValue) {
System.out.print(theName + " = ");
PrintParameter(theValue);
}
public static void PrintParameter(String theName, Direction theValue) {
System.out.print(theName + " = ");
PrintParameter(theValue);
}
public static void PrintParameter(String theName, double theValue) {
System.out.print(theName + " = ");
PrintParameter(theValue);
}
public static void PrintParameter(String theName, Point2d theValue) {
System.out.print(theName + " = ");
PrintParameter(theValue);
}
public static void PrintParameter(String theName, Direction2d theValue) {
System.out.print(theName + " = ");
PrintParameter(theValue);
}
public static void PrintName(String theName) {
System.out.print(theName + ": ");
}
public static void PrintCollection(String theName,
int theFinalIndex,
Consumer<Integer> thePrintElement) {
if (theName != null) {
System.out.print(theName + " = ");
}
System.out.print("[");
for (Integer i = 1; i <= theFinalIndex; ++i) {
if (i > 3) {
System.out.print("...");
break;
}
thePrintElement.accept(i);
}
System.out.print("]; ");
}
public static void PrintCollection(String theName,
int theFinalIndex1,
int theFinalIndex2,
BiConsumer<Integer, Integer> thePrintElement) {
PrintCollection(theName, theFinalIndex1, (Integer i) ->
{
PrintCollection(null, theFinalIndex2, (Integer j) -> {
thePrintElement.accept(i, j);
});
});
}
public static void PrintOrientation(final ShapeOrientation theOrientation) {
System.out.print("Orientation = ");
switch (theOrientation) {
case Forward:
System.out.print("Forward");
break;
case Reversed:
System.out.print("Reversed");
break;
default:
System.out.print("Undefined");
break;
}
System.out.print("; ");
}
public void PrintTabulation() {
for (int i = 0; i < myNestingLevel; ++i) {
System.out.print("--- ");
}
}
public int myNestingLevel = 0;
}
Defines a 3D Direction.
Definition Direction.hxx:34
Contains classes, types, enums, and functions related to geometric entities.
Defines classes, types, enums, and functions related to topological entities and scene graph elements...
Contains classes, namespaces, enums, types, and global functions related to Manufacturing Toolkit.
Definition LicenseManager_LicenseError.hxx:30

curve_explorer.java

// ****************************************************************************
// $Id$
//
// Copyright (C) 2008-2014, Roman Lygin. All rights reserved.
// Copyright (C) 2014-2025, 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.
//
// ****************************************************************************
import cadex.Geom.*;
public class curve_explorer extends base_explorer {
public static void PrintCurveInfo(final Curve theCurve) {
switch (theCurve.Type()) {
case Line:
PrintLine(Line.Cast(theCurve));
break;
case Circle:
PrintCircle(Circle.Cast(theCurve));
break;
case Ellipse:
PrintEllipse(Ellipse.Cast(theCurve));
break;
case Hyperbola:
PrintHyperbola(Hyperbola.Cast(theCurve));
break;
case Parabola:
PrintParabola(Parabola.Cast(theCurve));
break;
case Bezier:
PrintBezierCurve(BezierCurve.Cast(theCurve));
break;
case BSpline:
PrintBSplineCurve(BSplineCurve.Cast(theCurve));
break;
case Offset:
PrintOffsetCurve(OffsetCurve.Cast(theCurve));
break;
default:
break;
}
}
public static void PrintLine(final Line theLine) {
PrintName("Line");
Point aLoc = theLine.Location();
Direction aDir = theLine.Direction();
PrintDomain(theLine);
PrintParameter("Location", aLoc);
PrintParameter("Direction", aDir);
}
public static void PrintCircle(final Circle theCircle) {
PrintName("Circle");
double aRadius = theCircle.Radius();
PrintElementary(theCircle);
PrintParameter("Radius", aRadius);
}
public static void PrintEllipse(final 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(final 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(final Parabola theParabola) {
PrintName("Parabola");
double aFocal = theParabola.Focal();
PrintElementary(theParabola);
PrintParameter("Focal", aFocal);
}
public static void PrintBezierCurve(final 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, (Integer i) -> {
Point aPole = theBezier.Pole(i);
PrintParameter(aPole);
});
PrintCollection("Weights", aNumberOfPoles, (Integer i) -> {
double aWeight = theBezier.Weight(i);
PrintParameter(aWeight);
});
}
public static void PrintBSplineCurve(final 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, (Integer i) -> {
double aKnot = theBSpline.Knot(i);
PrintParameter(aKnot);
});
PrintCollection("Multiplicities", aNumberOfKnots, (Integer i) -> {
int aMultiplicity = theBSpline.Multiplicity(i);
PrintParameter(aMultiplicity);
});
PrintCollection("Poles", aNumberOfPoles, (Integer i) -> {
Point aPole = theBSpline.Pole(i);
PrintParameter(aPole);
});
PrintCollection("Weights", aNumberOfPoles, (Integer i) -> {
double aWeight = theBSpline.Weight(i);
PrintParameter(aWeight);
});
}
public static void PrintOffsetCurve(final OffsetCurve theOffset) {
PrintName("Offset Curve");
final Direction aDir = theOffset.Direction();
double anOffset = theOffset.Offset();
PrintDomain(theOffset);
PrintParameter("Direction", aDir);
PrintParameter("Offset", anOffset);
System.out.print("Basis Curve = ");
PrintCurveInfo(theOffset.BasisCurve());
}
}

pcurve_explorer.java

// ****************************************************************************
// $Id$
//
// Copyright (C) 2008-2014, Roman Lygin. All rights reserved.
// Copyright (C) 2014-2025, 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.
//
// ****************************************************************************
import cadex.Geom.*;
public class pcurve_explorer extends base_explorer {
public static void PrintPCurveInfo(Curve2d theCurve) {
switch (theCurve.Type()) {
case Line:
PrintLine(Line2d.Cast(theCurve));
break;
case Circle:
PrintCircle(Circle2d.Cast(theCurve));
break;
case Ellipse:
PrintEllipse(Ellipse2d.Cast(theCurve));
break;
case Hyperbola:
PrintHyperbola(Hyperbola2d.Cast(theCurve));
break;
case Parabola:
PrintParabola(Parabola2d.Cast(theCurve));
break;
case Bezier:
PrintBezierCurve(BezierCurve2d.Cast(theCurve));
break;
case BSpline:
PrintBSplineCurve(BSplineCurve2d.Cast(theCurve));
break;
case 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, (Integer i) -> {
Point2d aPole = theBezier.Pole(i);
PrintParameter(aPole);
});
PrintCollection("Weights", aNumberOfPoles, (Integer 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, (Integer i) ->
{
double aKnot = theBSpline.Knot(i);
PrintParameter(aKnot);
});
PrintCollection("Multiplicities", aNumberOfKnots, (Integer i) -> {
int aMultiplicity = theBSpline.Multiplicity(i);
PrintParameter(aMultiplicity);
});
PrintCollection("Poles", aNumberOfPoles, (Integer i) -> {
Point2d aPole = theBSpline.Pole(i);
PrintParameter(aPole);
});
PrintCollection("Weights", aNumberOfPoles, (Integer 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);
System.out.print("Basis Curve = ");
PrintPCurveInfo(theOffset.BasisCurve());
}
}

shape_explorer.java

// ****************************************************************************
// $Id$
//
// Copyright (C) 2008-2014, Roman Lygin. All rights reserved.
// Copyright (C) 2014-2025, 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.
//
// ****************************************************************************
import cadex.ModelData.*;
import cadex.Geom.*;
import cadex.Collections.*;
public class shape_explorer extends ModelElementVoidVisitor {
@Override
public void Apply(Part thePart) {
System.out.println("Part = \"" + thePart.Name() + "\"");
BodyList aBodies = thePart.Bodies();
if (!aBodies.isEmpty()) {
System.out.println("Part = \"" + thePart.Name() + "\"");
ExploreBRep(aBodies);
}
}
private void ExploreBRep(final BodyList theBodies) {
// Iterate over bodies
for (int i = 0; i < theBodies.size(); ++i) {
myBase.PrintTabulation();
Body aBody = theBodies.get(i);
System.out.println("Body " + i + ": " + BodyType(aBody));
for (ShapeIterator j = new ShapeIterator(aBody); j.HasNext(); ) {
Shape aShape = j.Next();
ExploreShape(aShape);
}
}
}
// Recursive iterating over the Shape until reaching vertices
private void ExploreShape(final 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 final String BodyType(final Body theBody) {
if (SheetBody.CompareType(theBody)) {
return "Sheet";
} else if (SolidBody.CompareType(theBody)) {
return "Solid";
} else if (WireframeBody.CompareType(theBody)) {
return "Wireframe";
}
return "Undefined";
}
// Returns shape type name and prints shape info in some cases
private void PrintShape(final Shape theShape) {
myBase.PrintTabulation();
switch (theShape.Type()) {
case Solid:
System.out.print("Solid");
break;
case Shell:
PrintShell(Shell.Cast(theShape));
break;
case Wire:
PrintWire(Wire.Cast(theShape));
break;
case Face:
PrintFace(Face.Cast(theShape));
break;
case Edge:
PrintEdge(Edge.Cast(theShape));
break;
case Vertex:
PrintVertex(Vertex.Cast(theShape));
break;
default:
System.out.print("Undefined");
break;
}
System.out.println("");
}
private void PrintShell(final Shell theWire) {
myBase.PrintName("Shell");
++myBase.myNestingLevel;
myBase.PrintOrientation(theWire.Orientation());
--myBase.myNestingLevel;
}
private void PrintWire(final Wire theWire) {
myBase.PrintName("Wire");
++myBase.myNestingLevel;
myBase.PrintOrientation(theWire.Orientation());
--myBase.myNestingLevel;
}
private void PrintFace(final Face theFace) {
myBase.PrintName("Face");
++myBase.myNestingLevel;
myBase.PrintOrientation(theFace.Orientation());
System.out.println("");
Surface aSurface = theFace.Surface();
myBase.PrintTabulation();
myBase.PrintName("Surface");
surface_explorer.PrintSurface(aSurface);
--myBase.myNestingLevel;
}
private void PrintEdge(final Edge theEdge) {
myBase.PrintName("Edge");
++myBase.myNestingLevel;
if (theEdge.IsDegenerated()) {
System.out.print("Degenerated: ");
}
myBase.PrintOrientation(theEdge.Orientation());
myBase.PrintParameter("Tolerance", theEdge.Tolerance());
if (!theEdge.IsDegenerated()) {
double[] aFirstParameter = {0}, aLastParameter = {0};
Curve aCurve = theEdge.Curve(aFirstParameter, aLastParameter);
System.out.println("");
myBase.PrintTabulation();
myBase.PrintName("Curve");
myBase.PrintRange("Edge Range", aFirstParameter[0], aLastParameter[0]);
curve_explorer.PrintCurveInfo(aCurve);
}
if (myCurrentFace != null) {
double[] aFirstParameter2d = {0}, aLastParameter2d = {0};
final Curve2d aPCurve = theEdge.PCurve(myCurrentFace, aFirstParameter2d, aLastParameter2d);
System.out.println("");
myBase.PrintTabulation();
myBase.PrintName("PCurve");
myBase.PrintRange("Edge Range", aFirstParameter2d[0], aLastParameter2d[0]);
pcurve_explorer.PrintPCurveInfo(aPCurve);
}
--myBase.myNestingLevel;
}
private void PrintVertex(final Vertex theVertex) {
myBase.PrintName("Vertex");
Point aLoc = theVertex.Point();
double aTolerance = theVertex.Tolerance();
myBase.PrintOrientation(theVertex.Orientation());
myBase.PrintParameter("Tolerance", aTolerance);
myBase.PrintParameter("Location", aLoc);
}
private base_explorer myBase = new base_explorer();
private Face myCurrentFace = null;
}

surface_explorer.java

// ****************************************************************************
// $Id$
//
// Copyright (C) 2008-2014, Roman Lygin. All rights reserved.
// Copyright (C) 2014-2025, 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.
//
// ****************************************************************************
import cadex.Geom.*;
public class surface_explorer extends base_explorer {
public static void PrintSurface(Surface theSurface) {
switch (theSurface.Type()) {
case Plane:
PrintPlane(Plane.Cast(theSurface));
break;
case Cylinder:
PrintCylinder(CylindricalSurface.Cast(theSurface));
break;
case Cone:
PrintCone(ConicalSurface.Cast(theSurface));
break;
case Sphere:
PrintSphere(SphericalSurface.Cast(theSurface));
break;
case Torus:
PrintTorus(ToroidalSurface.Cast(theSurface));
break;
case LinearExtrusion:
PrintLinearExtrusion(SurfaceOfLinearExtrusion.Cast(theSurface));
break;
case Revolution:
PrintRevolution(SurfaceOfRevolution.Cast(theSurface));
break;
case Bezier:
PrintBezierSurface(BezierSurface.Cast(theSurface));
break;
case BSpline:
PrintBSplineSurface(BSplineSurface.Cast(theSurface));
break;
case 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);
System.out.print("Basis Curve = ");
curve_explorer.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);
System.out.print("Basis Curve = ");
curve_explorer.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, (Integer i, Integer j) -> {
Point aPole = theBezier.Pole(i, j);
PrintParameter(aPole);
});
PrintCollection("Weights", aNumberOfUPoles, aNumberOfVPoles, (Integer i, Integer 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, (Integer i) -> {
double aKnot = theBSpline.UKnot(i);
PrintParameter(aKnot);
});
PrintCollection("V Knots", aNumberOfVKnots, (Integer i) -> {
double aKnot = theBSpline.VKnot(i);
PrintParameter(aKnot);
});
PrintCollection("U Multiplicities", aNumberOfUKnots, (Integer i) -> {
int aUMultiplicity = theBSpline.UMultiplicity(i);
PrintParameter(aUMultiplicity);
});
PrintCollection("V Multiplicities", aNumberOfVKnots, (Integer i) -> {
int aVMultiplicity = theBSpline.VMultiplicity(i);
PrintParameter(aVMultiplicity);
});
PrintCollection("Poles", aNumberOfUPoles, aNumberOfVPoles, (Integer i, Integer j) -> {
Point aPole = theBSpline.Pole(i, j);
PrintParameter(aPole);
});
PrintCollection("Weights", aNumberOfUPoles, aNumberOfVPoles, (Integer i, Integer 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);
System.out.print("Basis Surface = ");
PrintSurface(theOffset.BasisSurface());
}
}

brep_geometry.java

// ****************************************************************************
// $Id$
//
// Copyright (C) 2008-2014, Roman Lygin. All rights reserved.
// Copyright (C) 2014-2025, 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.
//
// ****************************************************************************
import cadex.*;
import cadex.ModelData.*;
public class brep_geometry {
static {
try {
System.loadLibrary("CadExMTK");
} catch (UnsatisfiedLinkError e) {
System.err.println("Native code library failed to load.\n" + e);
System.exit(1);
}
}
public static void main(String[] args) {
String aKey = MTKLicenseKey.Value();
// Activate the license (the key must be defined in MTKLicenseKey.java)
if (!LicenseManager.Activate(aKey)) {
System.out.println("Failed to activate Manufacturing Toolkit license.");
System.exit(1);
}
if (args.length != 1) {
System.out.println("Usage: " + " <input_file>, where:");
System.out.println(" <input_file> is a name of the file to be read");
System.exit(1);
}
String aSource = args[0];
Model aModel = new Model();
if (!new ModelReader().Read(new UTF16String(aSource), aModel)) {
System.out.println("Failed to read the file");
System.exit(1);
}
shape_explorer aVisitor = new shape_explorer();
aModel.Accept(aVisitor);
}
}