AMCAX Kernel
Geometry kernel for CAD/CAE/CAM
AMCAX Kernel 1.0.0.0
Loading...
Searching...
No Matches
Solid modeling

Create Basic Shape

Basic shape include box, cylinder, cone/frustum, sphere, and torus.

Box

AMCAX::MakeBox class provides functionality to create a box.

AMCAX::TopoShape box = AMCAX::MakeBox(AMCAX::Point3(-5.0, -5.0, 0.0), AMCAX::Point3(5.0, 5.0, 3.0));
Class of making a box.
Definition MakeBox.hpp:18
Base class of shape, containing an underlying shape with a location and an orientation.
Definition TopoShape.hpp:15
PointT< double, 3 > Point3
3D point
Definition PointT.hpp:459

Cylinder

AMCAX::MakeCylinder class provides functionality to create a cylinder.

AMCAX::TopoShape cylinder = AMCAX::MakeCylinder(AMCAX::Frame3(AMCAX::Point3(0.0, 0.0, 0.0), AMCAX::Direction3(0.0, 0.0, 1.0)), 3.0, 5.0);
Class of making a cylinder.
Definition MakeCylinder.hpp:16
DirectionT< double, 3 > Direction3
3D direction
Definition DirectionT.hpp:587
FrameT< double, 3 > Frame3
3D frame
Definition FrameT.hpp:885

Cone/Frustum

AMCAX::MakeCone class provides functionality to create a cone or frustum.

AMCAX::TopoShape cone = AMCAX::MakeCone(4.0, 0.0, 4.0);
Class of making a cone.
Definition MakeCone.hpp:16

Sphere

AMCAX::MakeSphere class provides functionality to create a sphere.

AMCAX::TopoShape sphere = AMCAX::MakeSphere(AMCAX::Point3(-3.0, 0.0, 0.0), 1.0);
Class of making a sphere.
Definition MakeSphere.hpp:16

Torus

AMCAX::MakeTorus class provides functionality to create a torus.

AMCAX::TopoShape torus = AMCAX::MakeTorus(AMCAX::Frame3(AMCAX::Point3(0.0, 0.0, 2.0), AMCAX::Direction3(1.0, 0.0, 0.0)), 4.0, 2.0);
Class of making a torus.
Definition MakeTorus.hpp:19

Boolean Operation

Boolean operation functionalities include union, intersection, cut, split, and section.

Union

AMCAX::BoolBRepFuse class provides the union functionality.

AMCAX::TopoShape shape1, shape2;
AMCAX::OCCTIO::OCCTTool::Read(shape1, "./data/part.brep");
AMCAX::OCCTIO::OCCTTool::Read(shape2, "./data/box.brep");
AMCAX::TopoShape fuse = AMCAX::BoolBRepFuse(shape1, shape2);
The class of fuse operation.
Definition BoolBRepFuse.hpp:15
static AMCAX_API bool Read(TopoShape &s, std::istream &is)
Read a shape from a stream.

Intersection

AMCAX::BoolBRepCommon class provides the intersection functionality.

AMCAX::TopoShape shape1, shape2;
AMCAX::OCCTIO::OCCTTool::Read(shape1, "./data/part.brep");
AMCAX::OCCTIO::OCCTTool::Read(shape2, "./data/box.brep");
AMCAX::TopoShape common = AMCAX::BoolBRepCommon(shape1, shape2);
The class of common operation.
Definition BoolBRepCommon.hpp:14

Cut

AMCAX::BoolBRepCut class provides the cut functionality.

The class of cut operation.
Definition BoolBRepCut.hpp:15

Split

AMCAX::BoolBRepSplitter class provides the split functionality.

AMCAX::TopoShape shape1, shape2;
AMCAX::OCCTIO::OCCTTool::Read(shape1, "./data/part.brep");
AMCAX::OCCTIO::OCCTTool::Read(shape2, "./data/box.brep");
auto tool_shape = std::list{ shape1 };
auto tool_argument = std::list{ shape2 };
splitter.SetTools(tool_shape);
splitter.SetArguments(tool_argument);
AMCAX::TopoShape split = splitter.Shape();
The class of splitter operation.
Definition BoolBRepSplitter.hpp:16
AMCAX_API void SetTools(const std::list< TopoShape > &ls)
Set the tool shapes.
AMCAX_API void SetArguments(const std::list< TopoShape > &listargs)
Set the shapes to be processed.
virtual AMCAX_API const TopoShape & Shape()
Get the resulting shape.

Section

AMCAX::BoolBRepSection provides functionality to calculate the section line.

AMCAX::TopoShape section = AMCAX::BoolBRepSection(cone, sphere);
The class of section operation.
Definition BoolBRepSection.hpp:17

Extrude (Sweep) Creation Functionality

AMCAX::MakePrism provides the extrude (sweep) functionality.

AMCAX::MakeGeom3Ellipse makeEllipse(AMCAX::Frame3(), 3.0, 1.0);
std::shared_ptr<AMCAX::Geom3Curve> curve = makeEllipse.Value();
Class of making an edge.
Definition MakeEdge.hpp:24
Class of making a face.
Definition MakeFace.hpp:22
Class of making 3D geometric ellipses.
Definition MakeGeom3Ellipse.hpp:13
Class of making a prism or an extrusion shape.
Definition MakePrism.hpp:16
Class of making a wire.
Definition MakeWire.hpp:17
Class of edge.
Definition TopoEdge.hpp:12
Class of face.
Definition TopoFace.hpp:12
Class of wire.
Definition TopoWire.hpp:12
VectorT< double, 3 > Vector3
3D vector
Definition VectorT.hpp:707

Rotation (Sweep) Creation Functionality

AMCAX::MakeRevol class provides the rotation (sweep) functionality.

std::vector<AMCAX::Point3> poles{ AMCAX::Point3(1.0, 0.0, 0.0), AMCAX::Point3(0.8, 0.0, 0.5), AMCAX::Point3(1.0, 0.0, 1.0) };
auto bz = std::make_shared<AMCAX::Geom3BezierCurve>(poles);
static AMCAX_API const Axis3 & OZ() noexcept
Get the z-axis in 3D, including the origin and the z-direction.
Class of making a revolved shape.
Definition MakeRevol.hpp:18

Pipe Functionality

The pipe is created by specifying the spine (wire) and profile (shape). This can be done using AMCAX::MakePipe or AMCAX::MakePipeShell. MakePipe is for simpler pipe algorithms, suitable for a single section (planar shape) and a smooth path. MakePipeShell is a more complete pipe algorithm, supporting multiple sections and non-smooth paths, but the path must intersect with the section plane. Note that Add can only be TopoWire or TopoVertex.

double radius = 0.1;
AMCAX::Frame3 aFrame(AMCAX::Point3(0., 0., 0.), AMCAX::Direction3(-8.57143, 0., 4.));
AMCAX::Circle3 aCircle = AMCAX::Circle3(aFrame, radius);
std::vector<AMCAX::Point3> pointSet;
pointSet.push_back(AMCAX::Point3(0., 0., 0.));
pointSet.push_back(AMCAX::Point3(-1., 0., 1.));
pointSet.push_back(AMCAX::Point3(0., 0., 2.));
pointSet.push_back(AMCAX::Point3(1., 0., 3.));
pointSet.push_back(AMCAX::Point3(0., 0., 4.));
std::shared_ptr<AMCAX::Geom3BSplineCurve> aBSplineCurve = AMCAX::NURBSAPIInterpolate::InterpolatePoints(pointSet,
AMCAX::TopoEdge aSpineEdge = AMCAX::MakeEdge(aBSplineCurve);
AMCAX::TopoWire aSpineWire = AMCAX::MakeWire(aSpineEdge);
AMCAX::TopoShape aPipe = AMCAX::MakePipe(aSpineWire, aFace);
//MakePipeShell
AMCAX::MakePipeShell ps(aSpineWire);
ps.Add(aWire,false,false);
ps.Build();
Class of make pipe algorithm.
Definition MakePipe.hpp:20
Class of making pipe shell algorithm.
Definition MakePipeShell.hpp:35
static AMCAX_API std::shared_ptr< Geom3BSplineCurve > InterpolatePoints(const std::vector< Point3 > &points, int degree=3, bool isClosed=false, ApproxParameterizationType ptype=ApproxParameterizationType::ChordLength)
The curve which interpolate the points is constructed.
CircleS< 3 > Circle3
3D circle
Definition CircleT.hpp:178
@ Centripetal
Parameters of points are proportional to square roots of distances between them.
Definition ApproxParameterizationType.hpp:17

Loft Operation

AMCAX::MakeLoft class provides loft functionality. By adding multiple wires, a shell or solid can be lofted.

AMCAX::Point3 aPoint1(1.0, 0.0, 0.0);
AMCAX::Point3 aPoint2(-0.5, std::sqrt(3.0) * 0.5, 0.0);
AMCAX::Point3 aPoint3(-0.5, -std::sqrt(3.0) * 0.5, 0.0);
AMCAX::MakePolygon aPolygon(aPoint1, aPoint2, aPoint3, true);
AMCAX::TopoWire bottomWire = aPolygon.Wire();
aTransform.SetTranslationPart(AMCAX::Vector3(0.0, 0.0, 3.0));
AMCAX::TopoWire topWire = AMCAX::TopoCast::Wire(AMCAX::TransformShape(bottomWire, aTransform));
AMCAX::MakeLoft aMakeLoft(true, true);
aMakeLoft.AddWire(bottomWire);
aMakeLoft.AddWire(topWire);
aMakeLoft.Build();
AMCAX::TopoShape loft = aMakeLoft.Shape();
Class of making a lofting shape.
Definition MakeLoft.hpp:30
Class of making a polygon.
Definition MakePolygon.hpp:18
static AMCAX_API const TopoWire & Wire(const TopoShape &s)
Cast shape to wire.
Class of transforming a shape.
Definition TransformShape.hpp:12
constexpr void SetTranslationPart(const VectorT< OtherScalar, DIM > &vec) noexcept
Set the translation part of the transformation.
Definition TransformationT.hpp:337
void SetRotation(const PointT< OtherScalar, DIM > &point, const OtherScalar2 &angle) noexcept
Set the transformation as rotation around a point with an angle in 2D.
Definition TransformationT.hpp:138
TransformationT< double, 3 > Transformation3
3D transformation
Definition TransformationT.hpp:1102

Fillet and Chamfer Features (Support Variable Radius)

Fillet

Fillet replaces sharp edges with smooth surfaces. The AMCAX::MakeFillet class and the AMCAX::MakeFillet2d class provide fillet functionality.

MakeFillet

AMCAX::TopoShape box = AMCAX::MakeBox(AMCAX::Point3(-5.0, -5.0, -5.0), AMCAX::Point3(5.0, 5.0, 5.0));
AMCAX::TopoExplorerTool::MapShapes(box, AMCAX::ShapeType::Edge, edges);
AMCAX::TopoShape e1 = edges[0];
mf.Add(1.0, AMCAX::TopoCast::Edge(e1));
mf.Build();
AMCAX::TopoShape box_fillet = mf.Shape();
Template class of indexed set.
Definition IndexSet.hpp:20
The class of fillet.
Definition MakeFillet.hpp:23
static AMCAX_API const TopoEdge & Edge(const TopoShape &s)
Cast shape to edge.
static AMCAX_API void MapShapes(const TopoShape &s, ShapeType t, IndexSet< TopoShape > &shapeSet)
Construct a set of sub-shapes of given type.

MakeFillet2d

AMCAX::TopoShape box = AMCAX::MakeBox(AMCAX::Point3(-5.0, -5.0, -5.0), AMCAX::Point3(5.0, 5.0, 5.0));
AMCAX::TopoExplorerTool::MapShapes(box, AMCAX::ShapeType::Face, faces);
AMCAX::TopoShape f = faces[0];
AMCAX::TopoExplorerTool::MapShapes(f1, AMCAX::ShapeType::Vertex, vertex);
AMCAX::TopoShape v1 = vertex[0];
mf2d.AddFillet(AMCAX::TopoCast::Vertex(v1), 1.0);
mf2d.Build();
AMCAX::TopoShape box_fillet2d = mf2d.Shape();
Class of make fillet and chamfer on a vertex of a planar face.
Definition MakeFillet2d.hpp:20
static AMCAX_API const TopoVertex & Vertex(const TopoShape &s)
Cast shape to vertex.
static AMCAX_API const TopoFace & Face(const TopoShape &s)
Cast shape to face.

Chamfer

AMCAX::MakeChamfer class provides the chamfer functionality.

AMCAX::TopoShape box = AMCAX::MakeBox(AMCAX::Point3(-5.0, -5.0, -5.0), AMCAX::Point3(5.0, 5.0, 5.0));
AMCAX::TopoExplorerTool::MapShapes(box, AMCAX::ShapeType::Edge, edges);
AMCAX::TopoShape e1 = edges[0];
mc.Add(1.0, AMCAX::TopoCast::Edge(e1));
mc.Build();
AMCAX::TopoShape box_chamfer = mc.Shape();
The class of chamfer.
Definition MakeChamfer.hpp:20

Shape Offset Function

The AMCAX::MakeOffset class and AMCAX::MakeOffsetShape class provide the functionality for shape offset.

MakeOffset (Offset for 2D Shapes)

The input is a wire for offset, and for a face, the boundary of the face is offset, returning the wire after offset.

AMCAX::TopoShape box = AMCAX::MakeBox(AMCAX::Point3(-5.0, -5.0, -5.0), AMCAX::Point3(5.0, 5.0, 5.0));
AMCAX::TopoExplorerTool::MapShapes(box, AMCAX::ShapeType::Face, faces);
AMCAX::TopoShape f = faces[0];
AMCAX::TopoExplorerTool::MapShapes(f, AMCAX::ShapeType::Wire, wire);
//wire
double offset = 1.5;
AMCAX::JoinType theJoin = AMCAX::JoinType::Arc;
bool isOpenResult = false;
AMCAX::MakeOffset MakeOffset(w, theJoin, isOpenResult);
MakeOffset.Perform(offset);
AMCAX::TopoShape offset1 = MakeOffset.Shape();
//face
AMCAX::MakeOffset MakeOffset2(f1, theJoin, isOpenResult);
MakeOffset2.Perform(offset);
AMCAX::TopoShape offset2 = MakeOffset2.Shape();
Class of making offset wires.
Definition MakeOffset.hpp:19
static AMCAX_API bool Write(const TopoShape &s, std::ostream &os, int format=3)
Write a shape to a stream.
JoinType
Type of join.
Definition GeometryMacros.hpp:74

MakeOffsetShape (Offset for 3D Shapes)

Input face for offset, input shell for offset the entire solid, returning the offset face or solid.

AMCAX::TopoShape box = AMCAX::MakeBox(AMCAX::Point3(-5.0, -5.0, -5.0), AMCAX::Point3(5.0, 5.0, 5.0));
AMCAX::TopoExplorerTool::MapShapes(box, AMCAX::ShapeType::Face, faces);
AMCAX::TopoShape f = faces[0];
//face
AMCAX::MakeOffsetShape MakeOffsetShape;
double offsetvalue = 1.2;
MakeOffsetShape.PerformBySimple(f, offsetvalue);
MakeOffsetShape.Build();
AMCAX::TopoShape offsetshape1 = MakeOffsetShape.Shape();
AMCAX::OCCTIO::OCCTTool::Write(offsetshape1, "MakeOffsetShape-face.brep");
//shell
AMCAX::MakeOffsetShape MakeOffsetShape2;
AMCAX::TopoExplorerTool::MapShapes(box, AMCAX::ShapeType::Shell, shell);
AMCAX::TopoShape s = shell[0];
MakeOffsetShape2.PerformBySimple(s, offsetvalue);
MakeOffsetShape2.Build();
AMCAX::TopoShape offsetshape2 = MakeOffsetShape2.Shape();
Class of build a shell out of a shape algorithm.
Definition MakeOffsetShape.hpp:18
AMCAX_API void PerformBySimple(const TopoShape &s, double offsetValue)
Construct an offset shape using the simple algorithm without intersections computation.
AMCAX_API void Build() override
Perform the algorithm.

Shape Thicken

AMCAX::MakeThickSolid class provides the functionality to thicken shape.

AMCAX::TopoShape box = AMCAX::MakeBox(AMCAX::Point3(-5.0, -5.0, -5.0), AMCAX::Point3(5.0, 5.0, 5.0));
AMCAX::TopoExplorerTool::MapShapes(box, AMCAX::ShapeType::Face, faces);
AMCAX::TopoShape f = faces[0];
double offsetvalue=1.5;
ts.MakeThickBySimple(f,offsetvalue);
ts.Build();
AMCAX::TopoShape thicksolid = ts.Shape();
Class of making a thick solid shape.
Definition MakeThickSolid.hpp:12
AMCAX_API void Build() override
Perform the algorithm.
AMCAX_API void MakeThickBySimple(const TopoShape &s, double offsetValue)
Make a thick solid using simple algorithm, only for a non-closed single face or shell which contain t...

Replace Face

The AMCAX::BoolBRepReplaceFace class provides the functionality to replace a face. This allows you to select a face from a solid and replace it with another surface. The basic logic involves extending the surrounding faces of the replaced face, intersecting them with the new surface, and reconstructing the topology. If the surface cannot cover the replaced face, the replacement will fail.

AMCAX::TopoExplorerTool::MapShapes(cylinder, AMCAX::ShapeType::Face, shapeFaces);
AMCAX::TopoFace upface = static_cast<const AMCAX::TopoFace&>(shapeFaces[1]);
AMCAX::Plane plane(AMCAX::Point3(0., 0., 12.), AMCAX::Direction3(0.2, 0.2, 1.0));
std::shared_ptr<AMCAX::Geom3Plane> surf = std::make_shared<AMCAX::Geom3Plane>(plane);
rf.SetShape(cylinder);
rf.AddFaceToReplace(upface);
rf.Build();
if (rf.IsDone())
{
AMCAX::TopoShape result = rf.Shape();
AMCAX::OCCTIO::OCCTTool::Write(result, "BoolBRepReplaceFace.brep");
}
The class of replace the feature faces in solid with surface.
Definition BoolBRepReplaceFace.hpp:17
AMCAX_API void SetReplaceSurface(const std::shared_ptr< Geom3Surface > &surface)
Set the surface with which the feature face is replaced.
AMCAX_API void AddFaceToReplace(const TopoShape &face)
Adds the face to be replaced from the input shape;.
AMCAX_API void SetShape(const TopoShape &shape)
Set the shape for replace face feature algorithm.
AMCAX_API void Build() override
Perform the algorithm.
virtual AMCAX_API bool IsDone() const
Is the construction algorithm done.
Class of Plane.
Definition Plane.hpp:13

Thin Plate Spline Interpolation of Curves

When interpolating, it is apparent that the curve passing through these points is not unique.

Generally speaking, the blue curve is more in line with the CAD design intent than the green one. To ensure the curve has a manageable length and the curvature changes smoothly, we use the thin-plate energy to measure the quality of the curve:

E1 controls the length of the curve, and E2 controls the rate of change of the curve. The larger the alpha, the shorter the curve. The larger the beta, the smoother the curve's shape. The AMCAX::NURBSAPIInterpolate class provides functionality for thin-plate spline interpolation. Details are as follows:
AMCAX::NURBSAPIInterpolate::InterpolatePointsThinPlate:Takes input data point coordinates, corresponding curve parameters (optional), and some information about the interpolation curve (periodicity, thin-plate energy weight), and constructs a NURBS curve passing through each data point while minimizing the thin-plate energy.
AMCAX::NURBSAPIInterpolate::InterpolateNodesThinPlate:Takes input data point coordinates, gradient orders (optional), corresponding curve parameters (optional), and some information about the interpolation curve (periodicity, thin-plate energy weight), and constructs a NURBS curve passing through each data point while minimizing the thin-plate energy.

std::vector<AMCAX::Point3> points;
points.push_back(AMCAX::Point3(0.0, 0.0, 0.0));
points.push_back(AMCAX::Point3(-0.1, 1.0, -0.2));
points.push_back(AMCAX::Point3(0.1, 2.0, -0.1));
points.push_back(AMCAX::Point3(0.2, 3.0, 0.1));
points.push_back(AMCAX::Point3(0.1, 4.0, 0.0));
points.push_back(AMCAX::Point3(0.0, 5.0, -0.1));
bool isClosed = false;
double alpha = 1e-2;
double beta = 1e-2;
std::vector< double > parameterization = { 0.0,0.1,0.2,0.3,0.4,0.5 };
std::vector<AMCAX::InterpolationNode> nodes;
AMCAX::Point3 p1(0., 0., 0.);
AMCAX::Point3 p2(1., 1., 1.);
AMCAX::Vector3 v1(2.,0.,0.), v2;
nodes.push_back({ p1,true,v1,false,v2 });
nodes.push_back({ p2,true,v1,false,v2 });
std::vector<double> parameterization1{ 0.0,0.5 };
auto thinplate1 = AMCAX::NURBSAPIInterpolate::InterpolatePointsThinPlate(points, isClosed, ptype, alpha, beta);
auto thinplate2 = AMCAX::NURBSAPIInterpolate::InterpolatePointsThinPlate(points, parameterization, isClosed, alpha, beta);
auto thinplate3 = AMCAX::NURBSAPIInterpolate::InterpolateNodesThinPlate(nodes, isClosed, ptype,alpha, beta);
auto thinplate4 = AMCAX::NURBSAPIInterpolate::InterpolateNodesThinPlate(nodes, parameterization1, isClosed, alpha, beta);
AMCAX::OCCTIO::OCCTTool::Write(AMCAX::MakeEdge(thinplate1), "InterpolatePointsThinPlate1.brep");
AMCAX::OCCTIO::OCCTTool::Write(AMCAX::MakeEdge(thinplate2), "InterpolatePointsThinPlate2.brep");
AMCAX::OCCTIO::OCCTTool::Write(AMCAX::MakeEdge(thinplate3), "InterpolatePointsThinPlate3.brep");
AMCAX::OCCTIO::OCCTTool::Write(AMCAX::MakeEdge(thinplate4), "InterpolatePointsThinPlate4.brep");
Class of constant law function.
Definition LawConstant.hpp:12
static AMCAX_API std::shared_ptr< Geom3BSplineCurve > InterpolateNodesThinPlate(const std::vector< InterpolationNode > &nodes, bool isClosed=false, ApproxParameterizationType ptype=ApproxParameterizationType::ChordLength, double alpha=1e-3, double beta=1e-3)
The curve which interpolate the points with gradients is constructed with Thin Plate Energy.
static AMCAX_API std::shared_ptr< Geom3BSplineCurve > InterpolatePointsThinPlate(const std::vector< Point3 > &points, bool isClosed, ApproxParameterizationType ptype, double alpha, double beta)
Interpolate points to make a BSpline curve with Thin Plate Energy.
ApproxParameterizationType
Type of the parameterization used in curve approximation.
Definition ApproxParameterizationType.hpp:12
@ ChordLength
Parameters of points are proportional to distances between them.
Definition ApproxParameterizationType.hpp:14

Convert Law Curve to 3D Geometric Curve

Using AMCAX::LawFunction::ToCurve() to convert a law curve to a 3D geometric curve.
For example, using a constant value function, r corresponds to the value of y, and pf and pl are the start and end parameters of x.

double r = 5.0;
double pr = 1.0;
double pl = 10.0;
law.Set(r, pr, pl);
auto e1 = law.ToCurve();
AMCAX_API void Set(double r, double pf, double pl)
Set the parameters.
AMCAX_API std::shared_ptr< Geom3Curve > ToCurve() const override
Turn the law function to a curve.

Some images are sourced from: https://dev.opencascade.org/doc/overview/html/index.html , the copyright belongs to its owner.