AMCAX Kernel 1.0.0.0
Loading...
Searching...
No Matches
Geometry modeling

Construction of Curve and Surface

Abstract Curve and Surface

Curve

Line

AMCAX::MakeLine2 is used to create a two-dimensional line, while AMCAX::MakeLine3 is used to create a three-dimensional line.

//2d
AMCAX::Point2 p(1., 2.);
AMCAX::Line2 l1 = l.Value();
AMCAX::TopoShape line2d = AMCAX::MakeEdge2d(l1, 0., 1.);
AMCAX::OCCTIO::OCCTTool::Write(line2d, "./lind2d.brep");
//3d
AMCAX::Point3 p2(1., 2., 3.);
AMCAX::MakeLine3 ll(p2, d2);
AMCAX::Line3 l2 = ll.Value();
AMCAX::TopoShape line3d = AMCAX::MakeEdge(l2, 0., 1.);
AMCAX::OCCTIO::OCCTTool::Write(line3d, "./lind3d.brep");
Class of making a 2D edge.
Definition MakeEdge2d.hpp:24
Class of making an edge.
Definition MakeEdge.hpp:26
Class of making 2D lines.
Definition MakeLine2.hpp:13
Class of making 3D lines.
Definition MakeLine3.hpp:13
static AMCAX_API bool Write(const TopoShape &s, std::ostream &os, int format=3)
Write a shape to a stream.
Base class of shape, containing an underlying shape with a location and an orientation.
Definition TopoShape.hpp:15
LineS< 2 > Line2
2D line
Definition LineT.hpp:454
LineS< 3 > Line3
3D line
Definition LineT.hpp:457
DirectionT< double, 2 > Direction2
2D direction
Definition DirectionT.hpp:563
DirectionT< double, 3 > Direction3
3D direction
Definition DirectionT.hpp:566
PointT< double, 3 > Point3
3D point
Definition PointT.hpp:459
PointT< double, 2 > Point2
2D point
Definition PointT.hpp:456

Circle

AMCAX::MakeCircle2 is used to create a two-dimensional circle, while AMCAX::MakeCircle3 is used to create a three-dimensional circle.

//2d
AMCAX::Frame2 frame2d;
AMCAX::MakeCircle2 c(frame2d, 2.0);
AMCAX::Circle2 c1 = c.Value();
AMCAX::OCCTIO::OCCTTool::Write(circle2d, "./circle2d.brep");
//3d
AMCAX::Frame3 frame3d;
AMCAX::MakeCircle3 cc(frame3d, 2.0);
AMCAX::Circle3 c2 = cc.Value();
AMCAX::OCCTIO::OCCTTool::Write(circle3d, "./circle3d.brep");
Class of making 2D circles.
Definition MakeCircle2.hpp:13
Class of making 3D circles.
Definition MakeCircle3.hpp:15
CircleS< 3 > Circle3
3D circle
Definition CircleT.hpp:187
FrameT< double, 2 > Frame2
2D frame
Definition FrameT.hpp:884
CircleS< 2 > Circle2
2D circle
Definition CircleT.hpp:184
FrameT< double, 3 > Frame3
3D frame
Definition FrameT.hpp:887

A circle can also be constructed using three points , here's a 2D example.

int create_arc(double x1, double y1, double x2, double y2, double x3, double y3) {
// Define three point
AMCAX::Point2 A(x1, y1);
AMCAX::Point2 B(x2, y2);
AMCAX::Point2 C(x3, y3);
// Make full 2d circle
AMCAX::Circle2 fullCircle = AMCAX::MakeCircle2(A, B, C).Value();
// Make 2d edge
auto maker = AMCAX::MakeEdge2d(fullCircle, A, C);
maker.Build();
if (maker.IsDone()) {
// Get the center of the circle
AMCAX::Point2 center = fullCircle.Location();
std::cout << "Arc construction successful" << std::endl;
std::cout << "Center coordinates: (" << center.X() << ", " << center.Y() << ")" << std::endl;
std::cout << "Calculated radius: " << fullCircle.Radius() << std::endl;
// Cast shape to edge
AMCAX::TopoEdge arcEdge = AMCAX::TopoCast::Edge(maker.Shape());
AMCAX::STEP::StepDataTool::Write(arcEdge, "./arcEdge.step");
}
return 0;
}
int main()
{
create_arc(1., 0., 0., 1., 0., -1.);
}
constexpr double Radius() const noexcept
Get the radius.
Definition CircleT.hpp:58
constexpr const PointT< double, DIM > & Location() const noexcept
Get the location point.
Definition ConicBase.hpp:58
AMCAX_API const Circle2 & Value() const
Get the constructed circle.
constexpr const Scalar & X() const noexcept
Get x-coordinate of a point, only available when DIM >= 1.
Definition PointT.hpp:120
constexpr const Scalar & Y() const noexcept
Get y-coordinate of a point, only available when DIM >= 2.
Definition PointT.hpp:128
static AMCAX_API bool Write(const AMCAX::TopoShape &s, std::ostream &os)
Write a TopoShape to a stream in STEP format.
static AMCAX_API const TopoEdge & Edge(const TopoShape &s)
Cast shape to edge.
Class of edge.
Definition TopoEdge.hpp:12

Alternatively, in 2D space, given a point on the arc, the center point, and the radius, a 2D circular arc can be constructed using the following code approach.

AMCAX::Point2 rotatePoint(const AMCAX::Point2& A, const AMCAX::Point2& center, double theta) {
//Convert angle from degree to radian
double thetaRad = theta * AMCAX::Constants::pi / 180.0;
// Rotate by thetaRad around center
transform.SetRotation(center, thetaRad);
// Apply transformation and return the result
return A.Transformed(transform);
}
int create_arc(double x1, double y1, double x2, double y2, double theta) {
// Define input points
AMCAX::Point2 A(x1, y1);
AMCAX::Point2 center(x2, y2);
// Calculate circle radius
double radius = center.Distance(A);
// Rotate point A around center by theta degree to get point B
auto B = rotatePoint(A, center, theta);
// Create full circle
AMCAX::Circle2 fullCircle = AMCAX::MakeCircle2(center, radius).Value();
AMCAX::TopoEdge arcEdge = AMCAX::MakeEdge2d(fullCircle, A, B);
// Calculate parameter value at point A
double t1 = AMCAX::CurveCalculation::Parameter(fullCircle, A);
// Convert Circle2 to Geom2Curve
std::shared_ptr<AMCAX::Geom2Curve> curve = std::make_shared<AMCAX::Geom2Circle>(fullCircle);
// Create trimmed curve
double dheta = theta / 180.0 * AMCAX::Constants::pi;
std::shared_ptr<AMCAX::Geom2TrimmedCurve> trimC = std::make_shared<AMCAX::Geom2TrimmedCurve>(curve, t1, t1 + dheta);
// Convert a 2D curve to 3D curve
std::shared_ptr<AMCAX::Geom3Curve> c = AMCAX::GeometryTool::To3d(AMCAX::Frame3(), trimC);
// Make edge
std::cout << "Arc constructed successfully" << std::endl;
std::cout << "Center coordinates: (" << center.X() << ", " << center.Y() << ")" << std::endl;
std::cout << "Calculated radius: " << radius << std::endl;
std::cout << "Central angle: " << theta << " degrees" << std::endl;
return 0;
}
int main()
{
create_arc(1., 0., 0., 0., 270.);
}
static AMCAX_API double Parameter(const Line3 &line, const Point3 &p) noexcept
Compute the parameter of a given point on a 3D line.
static AMCAX_API std::shared_ptr< Geom3Curve > To3d(const Frame3 &position, const std::shared_ptr< Geom2Curve > &curve)
Convert a 2D curve to 3D curve.
auto Distance(const PointT< OtherScalar, DIM > &other) const noexcept
Compute the Euclidean distance from the other point.
Definition PointT.hpp:180
constexpr PointT Transformed(const TransformationT< OtherScalar, DIM > &tr) const noexcept
Compute the transformed point.
Definition PointT.hpp:375
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
constexpr double pi
Mathematical constant Pi, ratio of a circle's circumference to its diameter.
Definition Constants.hpp:42
TransformationT< double, 2 > Transformation2
2D transformation
Definition TransformationT.hpp:1112

Ellipse

AMCAX::MakeEllipse2 is used to create a two-dimensional ellipse, while AMCAX::MakeEllipse3 is used to create a three-dimensional ellipse.

//2d
AMCAX::Frame2 frame2d;
AMCAX::MakeEllipse2 e(frame2d, 2.0,1.0);
AMCAX::Ellipse2 e1 = e.Value();
AMCAX::OCCTIO::OCCTTool::Write(ellipse2d, "./ellipse2d.brep");
//3d
AMCAX::Frame3 frame3d;
AMCAX::MakeEllipse3 ee(frame3d, 2.0,1.0);
AMCAX::Ellipse3 e2 = ee.Value();
AMCAX::OCCTIO::OCCTTool::Write(ellipse3d, "./ellipse3d.brep");
Class of making 2D ellipses.
Definition MakeEllipse2.hpp:13
Class of making 3D ellipses.
Definition MakeEllipse3.hpp:13
EllipseS< 2 > Ellipse2
2D ellipse
Definition EllipseT.hpp:264
EllipseS< 3 > Ellipse3
3D ellipse
Definition EllipseT.hpp:267

Hyperbola

AMCAX::MakeHyperbola2 is used to create a two-dimensional hyperbola, while AMCAX::MakeHyperbola3 is used to create a three-dimensional hyperbola.

//2d
AMCAX::Frame2 frame2d;
AMCAX::MakeHyperbola2 h(frame2d, 2.0, 1.0);
AMCAX::Hyperbola2 h1 = h.Value();
AMCAX::TopoShape hyperbola2d = AMCAX::MakeEdge2d(h1,-1.,1.);
AMCAX::OCCTIO::OCCTTool::Write(hyperbola2d, "./hyperbola2d.brep");
//3d
AMCAX::Frame3 frame3d;
AMCAX::MakeHyperbola3 hh(frame3d, 2.0, 1.0);
AMCAX::Hyperbola3 h2 = hh.Value();
AMCAX::TopoShape hyperbola3d = AMCAX::MakeEdge(h2, -1., 1.);
AMCAX::OCCTIO::OCCTTool::Write(hyperbola3d, "./hyperbola3d.brep");
Class of making 2D hyperbolas.
Definition MakeHyperbola2.hpp:13
Class of making 3D hyperbolas.
Definition MakeHyperbola3.hpp:13
HyperbolaS< 2 > Hyperbola2
2D hyperbola
Definition HyperbolaT.hpp:327
HyperbolaS< 3 > Hyperbola3
3D hyperbola
Definition HyperbolaT.hpp:330

Parabola

AMCAX::MakeParabola2 is used to create a two-dimensional parabola, while AMCAX::MakeParabola3 is used to create a three-dimensional parabola.

//2d
AMCAX::Frame2 frame2d;
AMCAX::MakeParabola2 pa(frame2d, 2.0);
AMCAX::Parabola2 pa1 = pa.Value();
AMCAX::TopoShape parabola2d = AMCAX::MakeEdge2d(pa1, -1., 1.);
AMCAX::OCCTIO::OCCTTool::Write(parabola2d, "./parabola2d.brep");
//3d
AMCAX::Frame3 frame3d;
AMCAX::MakeParabola3 paa(frame3d, 2.0);
AMCAX::Parabola3 pa2 = paa.Value();
AMCAX::TopoShape Parabola3d = AMCAX::MakeEdge(pa2, -1., 1.);
AMCAX::OCCTIO::OCCTTool::Write(Parabola3d, "./Parabola3d.brep");
Class of making 2D parabolas.
Definition MakeParabola2.hpp:13
Class of making 3D parabolas.
Definition MakeParabola3.hpp:13
ParabolaS< 2 > Parabola2
2D parabola
Definition ParabolaT.hpp:204
ParabolaS< 3 > Parabola3
3D parabola
Definition ParabolaT.hpp:207

Surface

Plane

AMCAX::MakePlane3 is used to create a three-dimensional plane. Note that planes are infinite, so to output files, you need to use AMCAX::MakeFace and set the start and end parameters in the u and v directions.

AMCAX::Frame3 frame3d;
AMCAX::MakePlane3 pl(frame3d);
AMCAX::Plane pl1 = pl.Value();
AMCAX::TopoShape plane3d = AMCAX::MakeFace(pl1,0.,2.,0.,2.);
AMCAX::OCCTIO::OCCTTool::Write(plane3d, "./plane3d.brep");
Class of making a face.
Definition MakeFace.hpp:24
Class of making planes.
Definition MakePlane3.hpp:13
Class of Plane.
Definition Plane.hpp:13

Cone Surface

AMCAX::MakeCone3 is used to create a cone surface. Note that cone surfaces are infinite, so to output files, you need to use AMCAX::MakeFace and set the start and end parameters in the u and v directions.

AMCAX::Point3 pp1(0., 0., 0.);
AMCAX::Point3 pp2(1., 2., 3.);
AMCAX::MakeCone3 co(pp1,pp2,2.0,1.0);
AMCAX::Cone co1 = co.Value();
AMCAX::TopoShape cone3d = AMCAX::MakeFace(co1, 0., 2., 0., 2.);
AMCAX::OCCTIO::OCCTTool::Write(cone3d, "./cone3d.brep");
Class of cone.
Definition Cone.hpp:12
Class of making cones.
Definition MakeCone3.hpp:14

Cylinder Surface

AMCAX::MakeCylinder3 is used to create a cylinder surface. Note that cylinder surfaces are infinite, so to output files, you need to use AMCAX::MakeFace and set the start and end parameters in the u and v directions.

AMCAX::Frame3 frame3d;
AMCAX::MakeCylinder3 cy(frame3d, 2.0);
AMCAX::Cylinder cy1 = cy.Value();
AMCAX::TopoShape cylinder3d = AMCAX::MakeFace(cy1, 0., 2., 0., 2.);
AMCAX::OCCTIO::OCCTTool::Write(cylinder3d, "./cylinder3d.brep");
Class of cylinder.
Definition Cylinder.hpp:12
Class of making cylinders.
Definition MakeCylinder3.hpp:14

Complete Geometric Curves and Surfaces

Curves

Line

AMCAX::MakeGeom2Line is used to create a 2D geometric line, and AMCAX::MakeGeom3Line is used to create a 3D geometric line.

//2d
AMCAX::MakeGeom2Line geom2line(AMCAX::Point2(0.0, 0.0), AMCAX::Direction2(1.0, 0.0));
std::shared_ptr< AMCAX::Geom2Line > geomline2d = geom2line.Value();
AMCAX::OCCTIO::OCCTTool::Write(AMCAX::MakeEdge2d(geomline2d, 0., 1.),"geomline2d.brep");
//3d
AMCAX::MakeGeom3Line geom3line(AMCAX::Point3(0.0, 0.0,0.0), AMCAX::Direction3(1.0, 0.0,0.0));
std::shared_ptr< AMCAX::Geom3Line > geomline3d = geom3line.Value();
AMCAX::OCCTIO::OCCTTool::Write(AMCAX::MakeEdge(geomline3d, 0., 1.), "geomline3d.brep");
Class of making 2D geometric lines.
Definition MakeGeom2Line.hpp:13
Class of making 3D geometric lines.
Definition MakeGeom3Line.hpp:15

Circle

AMCAX::MakeGeom2Circle is used to create a 2D geometric circle, and AMCAX::MakeGeom3Circle is used to create a 3D geometric circle.

//2d
AMCAX::Frame2 frame2d;
AMCAX::MakeGeom2Circle geom2circle(frame2d, 3.0);
std::shared_ptr< AMCAX::Geom2Circle > geomcircle2d = geom2circle.Value();
AMCAX::OCCTIO::OCCTTool::Write(AMCAX::MakeEdge2d(geomcircle2d), "geomcircle2d.brep");
//3d
AMCAX::Frame3 frame3d;
AMCAX::MakeGeom3Circle geom3circle(frame3d, 2.0);
std::shared_ptr< AMCAX::Geom3Circle > geomcircle3d = geom3circle.Value();
AMCAX::OCCTIO::OCCTTool::Write(AMCAX::MakeEdge(geomcircle3d), "geomcircle3d.brep");
Class of making 2D geometric circles.
Definition MakeGeom2Circle.hpp:13
Class of making 3D geometric circles.
Definition MakeGeom3Circle.hpp:13

Ellipse

AMCAX::MakeGeom2Ellipse is used to create a 2D geometric ellipse, and AMCAX::MakeGeom3Ellipse is used to create a 3D geometric ellipse.

//2d
AMCAX::Frame2 frame2d;
AMCAX::MakeGeom2Ellipse geom2ellipse(frame2d, 2.0, 1.0);
std::shared_ptr< AMCAX::Geom2Ellipse >geomellipse2d = geom2ellipse.Value();
AMCAX::OCCTIO::OCCTTool::Write(AMCAX::MakeEdge2d(geomellipse2d), "geomellipse2d.brep");
//3d
AMCAX::Frame3 frame3d;
AMCAX::MakeGeom3Ellipse geom3ellipse(frame3d, 4.0, 2.0);
std::shared_ptr< AMCAX::Geom3Ellipse >geomellipse3d = geom3ellipse.Value();
AMCAX::OCCTIO::OCCTTool::Write(AMCAX::MakeEdge(geomellipse3d), "geomellipse3d.brep");
Class of making 2D geometric ellipses.
Definition MakeGeom2Ellipse.hpp:13
Class of making 3D geometric ellipses.
Definition MakeGeom3Ellipse.hpp:13

Hyperbola

AMCAX::MakeGeom2Hyperbola is used to create a 2D geometric hyperbola, and AMCAX::MakeGeom3Hyperbola is used to create a 3D geometric hyperbola.

//2d
AMCAX::Frame2 frame2d;
AMCAX::MakeGeom2Hyperbola geom2hyperbola(frame2d, 2.0, 1.0);
std::shared_ptr< AMCAX::Geom2Hyperbola > geomhyperbola2d = geom2hyperbola.Value();
AMCAX::OCCTIO::OCCTTool::Write(AMCAX::MakeEdge2d(geomhyperbola2d,-1.0,1.0), "geomhyperbola2d.brep");
//3d
AMCAX::Frame3 frame3d;
AMCAX::MakeGeom3Hyperbola geom3hyperbola(frame3d, 4.0, 2.0);
std::shared_ptr< AMCAX::Geom3Hyperbola > geomhyperbola3d = geom3hyperbola.Value();
AMCAX::OCCTIO::OCCTTool::Write(AMCAX::MakeEdge(geomhyperbola3d, -1.0, 1.0), "geomhyperbola3d.brep");
Class of making 2D geometric hyperbolas.
Definition MakeGeom2Hyperbola.hpp:13
Class of making 3D geometric hyperbolas.
Definition MakeGeom3Hyperbola.hpp:13

Parabola

AMCAX::MakeGeom2Parabola is used to create a 2D geometric parabola, and AMCAX::MakeGeom3Parabola is used to create a 3D geometric parabola.

//2d
AMCAX::Frame2 frame2d;
AMCAX::MakeGeom2Parabola geom2parabola(frame2d, 2.0);
std::shared_ptr< AMCAX::Geom2Parabola > geomparabola2d = geom2parabola.Value();
AMCAX::OCCTIO::OCCTTool::Write(AMCAX::MakeEdge2d(geomparabola2d, -3.0, 3.0), "geomparabola2d.brep");
//3d
AMCAX::Frame3 frame3d;
AMCAX::MakeGeom3Parabola geom3parabola(frame3d, 4.0);
std::shared_ptr< AMCAX::Geom3Parabola > geomparabola3d = geom3parabola.Value();
AMCAX::OCCTIO::OCCTTool::Write(AMCAX::MakeEdge(geomparabola3d, -5.0, 5.0), "geomparabola3d.brep");
Class of making 2D geometric parabolas.
Definition MakeGeom2Parabola.hpp:13
Class of making 3D geometric parabolas.
Definition MakeGeom3Parabola.hpp:13

Surfaces

Plane

AMCAX::MakeGeom3Plane is used to create a geometric plane.

AMCAX::MakeGeom3Plane geom3plane(AMCAX::Point3(0.0,0.0,1.0),AMCAX::Direction3(1.,2.,3.));
std::shared_ptr< AMCAX::Geom3Plane > geomplane = geom3plane.Value();
AMCAX::OCCTIO::OCCTTool::Write(AMCAX::MakeFace(geomplane, -1., 1., -1., 1., AMCAX::Precision::Confusion()),"./geompalne.brep");
Class of making geometric planes.
Definition MakeGeom3Plane.hpp:13
static constexpr double Confusion() noexcept
Get the confusion tolerance.
Definition Precision.hpp:122

Conical Surface

AMCAX::MakeGeom3ConicalSurface is used to create a geometric conical surface.

AMCAX::Frame3 frame3d;
std::shared_ptr< AMCAX::Geom3ConicalSurface > geomconicalsurface = geom3conicalsurface.Value();
AMCAX::OCCTIO::OCCTTool::Write(AMCAX::MakeFace(geomconicalsurface, 0., 2 * AMCAX::Constants::pi * 2.0, 0., 100., AMCAX::Precision::Confusion()), "./geomconicalsurface.brep");
Class of making geometric conical surfaces.
Definition MakeGeom3ConicalSurface.hpp:13
constexpr double quarter_pi
pi/4
Definition Constants.hpp:58

Cylindrical Surface

AMCAX::MakeGeom3CylindricalSurface is used to create a geometric cylindrical surface.

std::shared_ptr< AMCAX::Geom3CylindricalSurface > geomcylindricalsurface = geom3cylindersurface.Value();
AMCAX::OCCTIO::OCCTTool::Write(AMCAX::MakeFace(geomcylindricalsurface, 0., 2*2.0*AMCAX::Constants::pi, 0., 3., AMCAX::Precision::Confusion()), "./geomcylindricalsurface.brep");
Class of making geometric cylindrical surfaces.
Definition MakeGeom3CylindricalSurface.hpp:14

Parameter Domain Trimmed Curves and Surfaces

Curves

Line Segment

AMCAX::MakeSegment2d is used to create a 2D line segment, and AMCAX::MakeSegment is used to create a 3D line segment.

//2d
AMCAX::Point2 P2(1., 3.);
AMCAX::MakeSegment2d makesegment2d(P1, P2);
std::shared_ptr< AMCAX::Geom2TrimmedCurve > segment2d = makesegment2d.Value();
AMCAX::OCCTIO::OCCTTool::Write(AMCAX::MakeEdge2d(segment2d), "./segment2d.brep");
//3d
AMCAX::Point3 P4(1.,2.,3.);
AMCAX::MakeSegment makesegment(P3,P4);
std::shared_ptr< AMCAX::Geom3TrimmedCurve > segment3d = makesegment.Value();
AMCAX::OCCTIO::OCCTTool::Write(AMCAX::MakeEdge(segment3d), "./segment3d.brep");
Class of making 2D line segments.
Definition MakeSegment2d.hpp:17
Class of making 3D line segments.
Definition MakeSegment.hpp:17

Circular Arc

AMCAX::MakeArcOfCircle2d is used to create a 2D circular arc, and AMCAX::MakeArcOfCircle is used to create a 3D circular arc.

//2d
AMCAX::MakeCircle2 makecircle2(AMCAX::Frame2(), 2.0);
AMCAX::MakeArcOfCircle2d makearcofcircle2d(makecircle2.Value(), 0., 2.,true);
std::shared_ptr< AMCAX::Geom2TrimmedCurve >arcofcircle2d = makearcofcircle2d.Value();
AMCAX::OCCTIO::OCCTTool::Write(AMCAX::MakeEdge2d(arcofcircle2d), "./arcofcircle2d.brep");
//3d
AMCAX::MakeCircle3 makecircle3(AMCAX::Frame3(), 3.0);
AMCAX::MakeArcOfCircle makearcofcircle(makecircle3.Value(), 0., 3.,true);
std::shared_ptr< AMCAX::Geom3TrimmedCurve >arcofcircle3d = makearcofcircle.Value();
AMCAX::OCCTIO::OCCTTool::Write(AMCAX::MakeEdge(arcofcircle3d), "./arcofcircle3d.brep");
Class of making arcs of 2D circle.
Definition MakeArcOfCircle2d.hpp:17
Class of making arcs of 3D circle.
Definition MakeArcOfCircle.hpp:17

Elliptical Arc

AMCAX::MakeArcOfEllipse2d is used to create a 2D elliptical arc, and AMCAX::MakeArcOfEllipse is used to create a 3D elliptical arc.

//2d
AMCAX::MakeEllipse2 makeellipse2(AMCAX::Frame2(), 2., 1.);
AMCAX::MakeArcOfEllipse2d makearcofellipse2d(makeellipse2.Value(), 0., 2.,true);
std::shared_ptr< AMCAX::Geom2TrimmedCurve > arcofellipse2d = makearcofellipse2d.Value();
AMCAX::OCCTIO::OCCTTool::Write(AMCAX::MakeEdge2d(arcofellipse2d), "./arcofellipse2d.brep");
//3d
AMCAX::MakeEllipse3 makeellipse3(AMCAX::Frame3(), 3., 2.);
AMCAX::MakeArcOfEllipse makearcofellipse(makeellipse3.Value(), 0., 2.,true);
std::shared_ptr< AMCAX::Geom3TrimmedCurve > arcofellipse3d = makearcofellipse.Value();
AMCAX::OCCTIO::OCCTTool::Write(AMCAX::MakeEdge(arcofellipse3d), "./arcofellipse3d.brep");
Class of making arcs of 2D ellipse.
Definition MakeArcOfEllipse2d.hpp:17
Class of making arcs of 3D ellipse.
Definition MakeArcOfEllipse.hpp:17

Hyperbolic Arc

AMCAX::MakeArcOfHyperbola2d is used to create a 2D hyperbolic arc, and AMCAX::MakeArcOfHyperbola is used to create a 3D hyperbolic arc.

//2d
AMCAX::MakeHyperbola2 makehyperbola2(AMCAX::Frame2(), 2., 1.);
AMCAX::MakeArcOfHyperbola2d makearcofhyperbola2d(makehyperbola2.Value(), 0., 2.,true);
std::shared_ptr< AMCAX::Geom2TrimmedCurve > arcofhyperbola2d = makearcofhyperbola2d.Value();
AMCAX::OCCTIO::OCCTTool::Write(AMCAX::MakeEdge2d(arcofhyperbola2d), "./arcofhyperbola2d.brep");
//3d
AMCAX::MakeHyperbola3 makehyperbola3(AMCAX::Frame3(), 3., 2.);
AMCAX::MakeArcOfHyperbola makearcofhyperbola(makehyperbola3.Value(), 0., 2.,true);
std::shared_ptr< AMCAX::Geom3TrimmedCurve > arcofhyperbola3d = makearcofhyperbola.Value();
AMCAX::OCCTIO::OCCTTool::Write(AMCAX::MakeEdge(arcofhyperbola3d), "./arcofhyperbola3d.brep");
Class of making arcs of 2D hyperbola.
Definition MakeArcOfHyperbola2d.hpp:17
Class of making arcs of 3D hyperbola.
Definition MakeArcOfHyperbola.hpp:17

Parabolic Arc

AMCAX::MakeArcOfParabola2d is used to create a 2D parabolic arc, and AMCAX::MakeArcOfParabola is used to create a 3D parabolic arc.

//2d
AMCAX::MakeParabola2 makeparabola2(AMCAX::Frame2(), 2.);
AMCAX::MakeArcOfParabola2d makearcofparabola2d(makeparabola2.Value(), 0., 2.,true);
std::shared_ptr< AMCAX::Geom2TrimmedCurve > arcofparabola2d = makearcofparabola2d.Value();
AMCAX::OCCTIO::OCCTTool::Write(AMCAX::MakeEdge2d(arcofparabola2d), "./arcofparabola2d.brep");
//3d
AMCAX::MakeParabola3 makeparabola3(AMCAX::Frame3(), 3.);
AMCAX::MakeArcOfParabola makearcofparabola(makeparabola3.Value(), 0., 2.,true);
std::shared_ptr< AMCAX::Geom3TrimmedCurve > arcofparabola3d = makearcofparabola.Value();
AMCAX::OCCTIO::OCCTTool::Write(AMCAX::MakeEdge(arcofparabola3d), "./arcofparabola3d.brep");
Class of making arcs of 2D parabola.
Definition MakeArcOfParabola2d.hpp:17
Class of making arcs of 3D parabola.
Definition MakeArcOfParabola.hpp:17

Surfaces

Trimmed Conical Surface

AMCAX::MakeTrimmedCone is used to create a trimmed conical surface.

AMCAX::MakeTrimmedCone maketrimmedcone(AMCAX::Point3(), AMCAX::Point3(0., 0., 1.), 2., 1.);
std::shared_ptr< AMCAX::Geom3TrimmedSurface > trimmedcone = maketrimmedcone.Value();
Class of making trimmed cones.
Definition MakeTrimmedCone.hpp:17

Trimmed Cylindrical Surface

AMCAX::MakeTrimmedCylinder is used to create a trimmed cylindrical surface.

AMCAX::MakeTrimmedCylinder maketrimmedcylinder(AMCAX::Point3(), AMCAX::Point3(0., 0., 2.), AMCAX::Point3(2., 0., 0.));
std::shared_ptr< AMCAX::Geom3TrimmedSurface > trimmedcylinder = maketrimmedcylinder.Value();
AMCAX::OCCTIO::OCCTTool::Write(AMCAX::MakeFace(trimmedcylinder, AMCAX::Precision::Confusion()), "./trimmedcylinder.brep");
Class of making trimmed cylinders.
Definition MakeTrimmedCylinder.hpp:17

Evaluation of Curves and Surfaces

The evaluation of curves and surfaces can be achieved using Value() or D0().

AMCAX::MakeTrimmedCylinder maketrimmedcylinder(AMCAX::Point3(), AMCAX::Point3(0., 0., 2.), AMCAX::Point3(2., 0., 0.));
std::shared_ptr< AMCAX::Geom3TrimmedSurface > trimmedcylinder = maketrimmedcylinder.Value();
AMCAX::OCCTIO::OCCTTool::Write(AMCAX::MakeFace(trimmedcylinder, AMCAX::Precision::Confusion()), "./trimmedcylinder.brep");
//Method 1
double u = 2., v = 0.9;
trimmedcylinder->D0(u, v, P);
std::cout << "P:" << P << std::endl;//P:-0.832294 1.81859 0.9
//Method 2
std::cout << trimmedcylinder->Value(u, v) << std::endl;//-0.832294 1.81859 0.9
virtual AMCAX_API Point3 Value(double u, double v) const
Compute the point at given parameters.
AMCAX_API void D0(double u, double v, Point3 &p) const override
Compute the point at given parameters.

Parametric Curve and Surface Creation through Interpolation and Fitting

Interpolated Curves

2D Interpolated Curves

AMCAX::GeomAPIInterpolate2 is used to compute 2D interpolated curves.

//Define point
std::vector<AMCAX::Point2> points = {
AMCAX::Point2(0.0, 0.0),
AMCAX::Point2(1.0, 1.0),
AMCAX::Point2(2.0, 0.0),
AMCAX::Point2(3.0, -1.0),
AMCAX::Point2(4.0, 0.0)
};
std::vector<double> parameters = { 0.0, 0.25, 0.5, 0.75, 1.0 };
bool periodic = false;
//Compute a curve interpolating 2D points
AMCAX::GeomAPIInterpolate2 interpolate(points, parameters, periodic, AMCAX::Precision::Confusion());
interpolate.Perform();
if (interpolate.IsDone())
{
//Get the resulting curve
std::shared_ptr<AMCAX::Geom2BSplineCurve> curve2d = interpolate.Curve();
AMCAX::OCCTIO::OCCTTool::Write(AMCAX::MakeEdge2d(curve2d, AMCAX::Point2(0.0, 0.0), AMCAX::Point2(4.0, 0.0)), "./curve2d.brep");
}
else
std::cout << "error:interpolate failed" << std::endl;
Class of computing a curve interpolating 2D points.
Definition GeomAPIInterpolate2.hpp:18

Additionally, you can add tangent vector constraints during interpolation using AMCAX::GeomAPIInterpolate2::Load to control the shape of the generated curve. You can add tangents for all points or only for the start and end points. For the above example:
Adding tangents for all points as constraints:

std::vector<AMCAX::Vector2> tangents1 = {
AMCAX::Vector2(1.0, 0.0),
AMCAX::Vector2(0.0, 1.0),
AMCAX::Vector2(-1.0, 0.0),
AMCAX::Vector2(0.0, -1.0),
AMCAX::Vector2(1.0, 0.0)
};
std::vector<bool> tangentFlags1 = { true, true, true, true, true };
interpolate.Load(tangents1, tangentFlags1, true);
VectorT< double, 2 > Vector2
2D vector
Definition VectorT.hpp:704

Adding tangents for the start and end points as constraints:

AMCAX::Vector2 firstTangent(1.0, 0.0);
AMCAX::Vector2 lastTangent(0.0, -1.0);
interpolate.Load(firstTangent, lastTangent, true);

3D Interpolated Curves

AMCAX::GeomAPIInterpolate3 is used to compute 3D interpolated curves.

//Define point
std::vector<AMCAX::Point3> points2 = {
AMCAX::Point3(0.0, 0.0, 0.0),
AMCAX::Point3(1.0, 1.0, 1.0),
AMCAX::Point3(2.0, 0.0, 2.0),
AMCAX::Point3(3.0, -1.0, 3.0),
AMCAX::Point3(4.0, 0.0, 4.0)
};
//
std::vector<double> parameters2 = { 0.0, 0.25, 0.5, 0.75, 1.0 };
bool periodic2 = false;
//Compute a curve interpolating 3D points
AMCAX::GeomAPIInterpolate3 interpolate2(points2, parameters2, periodic2, AMCAX::Precision::Confusion());
interpolate2.Perform();
if (interpolate2.IsDone()) {
//Get the resulting curve
std::shared_ptr<AMCAX::Geom3BSplineCurve> curve3d = interpolate2.Curve();
AMCAX::OCCTIO::OCCTTool::Write(AMCAX::MakeEdge(curve3d, AMCAX::Point3(0.0, 0.0, 0.0), AMCAX::Point3(4.0, 0.0, 4.0)), "./curve3d.brep");
}
else {
std::cout << "error: interpolate failed" << std::endl;
}
Class of computing a curve interpolating 3D points.
Definition GeomAPIInterpolate3.hpp:18

Additionally, tangent vector constraints can be added during the interpolation process using AMCAX::GeomAPIInterpolate3::Load to control the shape of the generated curve. Tangent vectors can be added as constraints for all points or only for the start and end points. Using the above example:
Adding tangent vectors for all points as constraints:

std::vector<AMCAX::Vector3> tangents2 = {
AMCAX::Vector3(1.0, 0.0, 0.0),
AMCAX::Vector3(0.0, 1.0, 0.0),
AMCAX::Vector3(0.0, 0.0, 1.0),
AMCAX::Vector3(-1.0, 0.0, 0.0),
AMCAX::Vector3(0.0, -1.0, 0.0)
};
std::vector<bool> tangentFlags2 = { true, true, true, true, true };
interpolate2.Load(tangents2, tangentFlags2, true);
VectorT< double, 3 > Vector3
3D vector
Definition VectorT.hpp:707

Adding tangent vectors for the start and end points as constraints:

AMCAX::Vector3 firstTangent3(1.0, 0.0, 0.0);
AMCAX::Vector3 lastTangent3(0.0, -1.0, 0.0);
interpolate2.Load(firstTangent3, lastTangent3, true);

Curve Fitting

2D Curve Fitting

AMCAX::GeomAPIPointsToBSpline2 is used to compute a 2D fitted curve.

//Define point
std::vector<AMCAX::Point2> points3 = {
AMCAX::Point2(0.0, 0.0),
AMCAX::Point2(1.0, 1.0),
AMCAX::Point2(2.0, 0.0),
AMCAX::Point2(3.0, -1.0),
AMCAX::Point2(4.0, 0.0)
};
//
std::vector<double> parameters3 = { 0.0, 0.25, 0.5, 0.75, 1.0 };
int degMin1 = 3;
int degMax1 = 8;
AMCAX::ContinuityType continuity1 = AMCAX::ContinuityType::C2;
double tol1 = 1e-3;
//Compute a 2D B spline curve approximating 2D points
AMCAX::GeomAPIPointsToBSpline2 bsplineFitter1(points3, parameters3, degMin1, degMax1, continuity1, tol1);
if (bsplineFitter1.IsDone()) {
//Get the resulting curve
std::shared_ptr<AMCAX::Geom2BSplineCurve> BSplineCurve2d = bsplineFitter1.Curve();
AMCAX::OCCTIO::OCCTTool::Write(AMCAX::MakeEdge2d(BSplineCurve2d, AMCAX::Point2(0.0, 0.0), AMCAX::Point2(4.0, 0.0)), "./BSplineCurve2d.brep");
}
else {
std::cout << "error: Bspline curve fitting failed" << std::endl;
}
Class of computing a 2D B spline curve approximating 2D points.
Definition GeomAPIPointsToBSpline2.hpp:19
ContinuityType
Type of continuity.
Definition GeometryMacros.hpp:84

Additionally, a B-spline curve can be fitted based on the starting point's x-coordinate, a constant increment in the x-coordinate, and a set of y-coordinate points. In the following example, the starting point's x-coordinate is 0.0, the constant increment in the x-coordinate is 1.0, and the size of the y-coordinate point set is 5, so the end point's x-coordinate can be inferred as 4.0.

std::vector<double> yValues = {
0.0, 1.0, 0.5, 2.0, 1.5
};
double x0 = 0.0;
double dx = 1.0;
AMCAX::GeomAPIPointsToBSpline2 bsplineFitter2(yValues, x0, dx, 3, 8, AMCAX::ContinuityType::C2, 1e-6);
if (bsplineFitter2.IsDone()) {
std::shared_ptr<AMCAX::Geom2BSplineCurve> BSplineCurve2d_2 = bsplineFitter2.Curve();
AMCAX::OCCTIO::OCCTTool::Write(AMCAX::MakeEdge2d(BSplineCurve2d_2), "./BSplineCurve2d_2.brep");
}
else {
std::cout << "error: Bspline curve fitting failed" << std::endl;
}

3D Curve Fitting

AMCAX::GeomAPIPointsToBSpline3 is used to compute a 3D fitted curve.

//Define point
std::vector<AMCAX::Point3> points5 = {
AMCAX::Point3(0.0, 0.0, 0.0),
AMCAX::Point3(1.0, 1.0, 1.0),
AMCAX::Point3(2.0, 0.0, 2.0),
AMCAX::Point3(3.0, -1.0, 3.0),
AMCAX::Point3(4.0, 0.0, 4.0)
};
std::vector<double> parameters4 = { 0.0, 0.25, 0.5, 0.75, 1.0 };
int degMin2 = 3;
int degMax2 = 8;
AMCAX::ContinuityType continuity2 = AMCAX::ContinuityType::C2;
double tol2 = 1e-3;
//Compute a 3D B spline curve approximating 3D points
AMCAX::GeomAPIPointsToBSpline3 bsplineFitter3(points5, parameters4, degMin2, degMax2, continuity2, tol2);
if (bsplineFitter2.IsDone()) {
//Get the resulting curve
std::shared_ptr<AMCAX::Geom3BSplineCurve> BSplineCurve3d = bsplineFitter3.Curve();
AMCAX::OCCTIO::OCCTTool::Write(AMCAX::MakeEdge(BSplineCurve3d, AMCAX::Point3(0.0, 0.0, 0.0), AMCAX::Point3(4.0, 0.0, 4.0)), "./BSplineCurve3d.brep");
}
else {
std::cout << "error: Bspline curve fitting failed" << std::endl;
}
Class of computing a 3D B spline curve approximating 3D points.
Definition GeomAPIPointsToBSpline3.hpp:19

Surface Fitting

AMCAX::GeomAPIPointsToBSplineSurface is used to compute a fitted surface.

//Define point
controls(0, 0) = AMCAX::Point3(-6., -6., 0.);
controls(0, 1) = AMCAX::Point3(-3., -6., -2.);
controls(0, 2) = AMCAX::Point3(3., -6., -2.);
controls(0, 3) = AMCAX::Point3(6., -6., 0.);
controls(1, 0) = AMCAX::Point3(-6., -3., -2.);
controls(1, 1) = AMCAX::Point3(-3., -3., -2.);
controls(1, 2) = AMCAX::Point3(3., -3., 2.);
controls(1, 3) = AMCAX::Point3(6., -3., 2.);
controls(2, 0) = AMCAX::Point3(-6., 3., -2.);
controls(2, 1) = AMCAX::Point3(-3., 3., 2.);
controls(2, 2) = AMCAX::Point3(3., 3., -2.);
controls(2, 3) = AMCAX::Point3(6., 3., 2.);
controls(3, 0) = AMCAX::Point3(-6., 6., 0.);
controls(3, 1) = AMCAX::Point3(-3., 6., 2.);
controls(3, 2) = AMCAX::Point3(3., 6., 2.);
controls(3, 3) = AMCAX::Point3(6., 6., 0.);
//Compute a B spline surface approximating points
AMCAX::GeomAPIPointsToBSplineSurface bsplineSurfaceFitter(controls, 3, 8, AMCAX::ContinuityType::C2, 1e-3);
if (bsplineSurfaceFitter.IsDone()) {
//Get the resulting surface
std::shared_ptr<AMCAX::Geom3BSplineSurface> bsplinesurface = bsplineSurfaceFitter.Surface();
AMCAX::OCCTIO::OCCTTool::Write(AMCAX::MakeFace(bsplinesurface,AMCAX::Precision::Confusion()), "./BSplineSurface.brep");
}
else {
std::cout << "error: Bspline surface fitting failed" << std::endl;
}
Template class of two dimensional array.
Definition Array2.hpp:17
Class of computing a B spline surface approximating points.
Definition GeomAPIPointsToBSplineSurface.hpp:19

Additionally, a B-spline surface can be fitted based on the starting point's x and y coordinates, constant increments in the x and y coordinates, and a set of z-coordinate points.

AMCAX::Array2<double> zPoints(3, 3);
zPoints(0, 0) = 0.0; zPoints(0, 1) = 1.0; zPoints(0, 2) = 0.0;
zPoints(1, 0) = 1.0; zPoints(1, 1) = 2.0; zPoints(1, 2) = 1.0;
zPoints(2, 0) = 0.0; zPoints(2, 1) = 1.0; zPoints(2, 2) = 0.0;
double x0 = 0.0;
double dx = 1.0;
double y0 = 0.0;
double dy = 1.0;
AMCAX::GeomAPIPointsToBSplineSurface bsplineSurfaceFitter2(zPoints, x0, dx, y0, dy, 3, 8, AMCAX::ContinuityType::C2, 1e-3);
if (bsplineSurfaceFitter2.IsDone()) {
std::shared_ptr<AMCAX::Geom3BSplineSurface> bsplinesurface2 = bsplineSurfaceFitter2.Surface();
AMCAX::OCCTIO::OCCTTool::Write(AMCAX::MakeFace(bsplinesurface2, AMCAX::Precision::Confusion()), "./BSplineSurface2.brep");
}
else {
std::cout << "error: Bspline surface fitting failed" << std::endl;
}

Intersection of 2D Curves, Curve-Surface Intersection, and Surface-Surface Intersection

2D Curve Intersection

AMCAX::GeomAPIIntCurveCurve2 is used to compute the intersection result of two 2D curves, which may be intersection points or segments.
If the intersection result is points, the number of intersection points can be obtained using AMCAX::GeomAPIIntCurveCurve2::NPoints(), and the coordinates of the intersection points can be obtained using AMCAX::GeomAPIIntCurveCurve2::Point(). Additionally, the parameters of the intersection points on the curves can be obtained using AMCAX::GeomAPIIntCurveCurve2::ParamOnCurve1() and AMCAX::GeomAPIIntCurveCurve2::ParamOnCurve2().
If the intersection result is segments, the number of segments can be obtained using AMCAX::GeomAPIIntCurveCurve2::NSegments(), and a specific segment can be obtained using AMCAX::GeomAPIIntCurveCurve2::Segment().

//Define point
std::vector<AMCAX::Point2> pts1 = {
AMCAX::Point2(0.0, 2.0),
AMCAX::Point2(1.0, 3.0),
AMCAX::Point2(2.0, 1.0),
AMCAX::Point2(3.0, 3.0),
AMCAX::Point2(4.0, 1.0),
AMCAX::Point2(5.0, 3.0),
AMCAX::Point2(6.0, 2.0)
};
std::vector<double> knots1 = { 0.0, 0.2, 0.4, 0.6, 0.8, 1.0 };
std::vector<int> mults1 = { 4, 1, 1, 1, 1, 4 };
//Make a 2D BSplineCurve
auto bspline1 = std::make_shared< AMCAX::Geom2BSplineCurve>(pts1, knots1, mults1, 4);
//Make a 2D circle
AMCAX::Frame2 frame(AMCAX::Point2(3.0, 3.0), AMCAX::Direction2(1.0, 0.0),AMCAX::Direction2(0.0,1.0));
auto circle = std::make_shared<AMCAX::Geom2Circle>(frame, 1.0);
//Compute intersection points for two 2D curves
std::cout << cc.NPoints() << std::endl;//2
std::cout << cc.Point(0) << std::endl;//2.59489 2.08573
std::cout << cc.Point(1) << std::endl;//3.40511 2.08573
std::cout << cc.ParamOnCurve1(0) << std::endl;//0.420769
std::cout << cc.ParamOnCurve1(1) << std::endl;//0.579231
std::cout << cc.ParamOnCurve2(0) << std::endl;//4.29529
std::cout << cc.ParamOnCurve2(1) << std::endl;//5.12949
//Make 2D TrimmedCurve
auto line1 = std::make_shared<AMCAX::Geom2Line>(AMCAX::Point2(0., 0.), AMCAX::Direction2(1., 0.));
auto trimline1 = std::make_shared<AMCAX::Geom2TrimmedCurve>(line1, 0.0, 3.0);
AMCAX::OCCTIO::OCCTTool::Write(AMCAX::MakeEdge2d(trimline1), "trimline1.brep");
auto line2 = std::make_shared<AMCAX::Geom2Line>(AMCAX::Point2(0., 0.), AMCAX::Direction2(1., 0.));
auto trimline2 = std::make_shared<AMCAX::Geom2TrimmedCurve>(line2, 2.0, 4.0);
AMCAX::OCCTIO::OCCTTool::Write(AMCAX::MakeEdge2d(trimline2), "trimline2.brep");
//Compute intersection section for two 2D curves
std::cout << cc2.NSegments() << std::endl;//1
std::pair< double, double > paramOnCurve1;
std::pair< double, double > paramOnCurve2;
//Get the intersection segments at a given index
cc2.Segment(0, paramOnCurve1, paramOnCurve2);
std::cout << paramOnCurve1.first << std::endl;//2
std::cout << paramOnCurve1.second << std::endl;//3
std::cout << paramOnCurve2.first << std::endl;//2
std::cout << paramOnCurve2.second << std::endl;//3
Class of computing intersection points for two 2D curves.
Definition GeomAPIIntCurveCurve2.hpp:19

Additionally, AMCAX::GeomAPIIntCurveCurve2 can be used to determine if a 2D curve is self-intersecting and to compute the number of self-intersection points.

std::vector<AMCAX::Point2> pts2 = {
AMCAX::Point2(0.5, 0.5),
AMCAX::Point2(1.0, 3.0),
AMCAX::Point2(3.0, 1.0),
AMCAX::Point2(3.8,2.0),
AMCAX::Point2(2.5,3.5),
AMCAX::Point2(1.0,0.5),
AMCAX::Point2(0.3,2.0)
};
std::vector<double> knots2 = { 0.0, 0.25, 0.5,0.75,1.0 };
std::vector<int> mults2 = { 4, 1, 1,1,4 };
auto bspline = std::make_shared< AMCAX::Geom2BSplineCurve>(pts2, knots2, mults2, 3);
std::cout << cc3.NPoints() << std::endl;//2

Curve and Surface Intersection

AMCAX::GeomAPIIntCurveSurface is used to calculate the intersection results between a curve and a surface, where the result could be either a point or a segment.
If the intersection result is a point, the number of points can be obtained through AMCAX::GeomAPIIntCurveSurface::NPoints(), and a specific point's coordinates can be retrieved through AMCAX::GeomAPIIntCurveSurface::Point() at a given index. Additionally, the parameters of the intersection points on both the curve and the surface at a given index can be obtained through AMCAX::GeomAPIIntCurveSurface::Parameters().
If the intersection result is a segment, the number of segments can be obtained through AMCAX::GeomAPIIntCurveSurface::NSegments(). To get a specific segment, it can be retrieved through AMCAX::GeomAPIIntCurveSurface::Segment().

//Define point
std::vector<AMCAX::Point3> pts3 = {
AMCAX::Point3(0.0, 0.0,0.0),
AMCAX::Point3(2.0, 2.0,2.0),
AMCAX::Point3(4.0, 3.0,5.0),
AMCAX::Point3(6.0,2.0,4.0)
};
//Make a BezierCurve
auto bezier = std::make_shared<AMCAX::Geom3BezierCurve>(pts3);
//Make a TrimmedSurface
std::shared_ptr<AMCAX::Geom3CylindricalSurface> CylindricalSurface = std::make_shared< AMCAX::Geom3CylindricalSurface>(AMCAX::Frame3(), 3.0);
std::shared_ptr<AMCAX::Geom3TrimmedSurface> TrimmedSurface = std::make_shared<AMCAX::Geom3TrimmedSurface>(CylindricalSurface, 0., 5., false);
//Compute intersection points for a curve and a surface
AMCAX::GeomAPIIntCurveSurface cs(bezier, TrimmedSurface);
cs.Perform(bezier, TrimmedSurface);
std::cout << cs.IsDone() << std::endl;//1
std::cout << cs.NPoints() << std::endl;//1
//Get the parameters of the intersection point at a given index
double u = 0., v = 0., w = 0.;
cs.Parameters(0, u, v, w);
std::cout << "u:" << u << std::endl;//u:0.660279
std::cout << "v:" << v << std::endl;//v:2.52939
std::cout << "w:" << w << std::endl;//w:0.394911
std::cout << "point:" << cs.Point(0) << std::endl;//point:2.36946 1.84001 2.52939
Class of computing intersection points for a curve and a surface.
Definition GeomAPIIntCurveSurface.hpp:20

Surface and Surface Intersection

AMCAX::GeomAPIIntSurfaceSurface is used to calculate the intersection results between two surfaces. The number of intersection curves can be obtained through AMCAX::GeomAPIIntSurfaceSurface::NLines(). If you want to retrieve a specific intersection curve, you can get it using AMCAX::GeomAPIIntSurfaceSurface::Line().

//Make Trimmedsurface
std::shared_ptr<AMCAX::Geom3CylindricalSurface> CylindricalSurface3 = std::make_shared< AMCAX::Geom3CylindricalSurface>(AMCAX::Frame3(), 2.0);
std::shared_ptr<AMCAX::Geom3TrimmedSurface> trimcylinder = std::make_shared<AMCAX::Geom3TrimmedSurface>(CylindricalSurface3, 0., 5., false);
auto plane2 = std::make_shared<AMCAX::Geom3Plane>(frame2);
std::shared_ptr<AMCAX::Geom3TrimmedSurface> trimplane2 = std::make_shared<AMCAX::Geom3TrimmedSurface>(plane2, 0., 5., 0., 5.);
//Compute intersection curves for two surfaces
ss.Perform(trimcylinder, trimplane2, AMCAX::Precision::Confusion());
std::cout << ss.IsDone() << std::endl;//1
std::cout << ss.NLines() << std::endl;//1
//Get the intersection curve at a given index.
std::shared_ptr< AMCAX::Geom3Curve >line3 = ss.Line(0);
Class of computing intersection curves for two surfaces.
Definition GeomAPIIntSurfaceSurface.hpp:20

Calculating Extreme Values Between Geometrical Objects

Extreme Values Between 2D Curves

AMCAX::GeomAPIExtremaCurveCurve2 is used to calculate the minimum distance points between two 2D curves. For the two input curves, you can first use AMCAX::GeomAPIExtremaCurveCurve2::IsParallel to check if the curves are parallel. If they are parallel, no extreme points exist, and NExtrema() will return 1. When trying to get the closest distance or closest points, an OutOfRange exception will be thrown.If the two curves are not parallel, you can obtain the following information:

AMCAX::GeomAPIExtremaCurveCurve2::NExtrema: Used to obtain the number of minimum distance points.
AMCAX::GeomAPIExtremaCurveCurve2::Points: Used to obtain the minimum distance points.
AMCAX::GeomAPIExtremaCurveCurve2::Distance: Used to obtain the distance between the minimum distance points.
AMCAX::GeomAPIExtremaCurveCurve2::Parameters: Used to obtain the parameters of the minimum distance points.
AMCAX::GeomAPIExtremaCurveCurve2::LowerDistance: Used to obtain the minimum distance between the extreme points.
AMCAX::GeomAPIExtremaCurveCurve2::LowerDistanceParameters: Used to obtain the parameters of the extreme points with the minimum distance between the two curves.

//Define point
std::vector<AMCAX::Point2> pts1 = {
AMCAX::Point2(0.0, 2.0),
AMCAX::Point2(1.0, 3.0),
AMCAX::Point2(2.0, 1.0),
AMCAX::Point2(3.0, 3.0),
AMCAX::Point2(4.0, 1.0),
AMCAX::Point2(5.0, 3.0),
AMCAX::Point2(6.0, 2.0)
};
//Make a BSplineCurve
std::vector<double> knots1 = { 0.0, 0.2, 0.4, 0.6, 0.8, 1.0 };
std::vector<int> mults1 = { 4, 1, 1, 1, 1, 4 };
auto bspline1 = std::make_shared< AMCAX::Geom2BSplineCurve>(pts1, knots1, mults1, 4);
//Define point
std::vector<AMCAX::Point2> pts2;
for (const auto& pt : pts1) {
pts2.push_back(AMCAX::Point2(pt.X() , -pt.Y()));
}
//Make a BSplineCurve
auto bspline2 = std::make_shared<AMCAX::Geom2BSplineCurve>(pts2, knots1, mults1, 4);
//Compute extremal points for two 2D curves
AMCAX::GeomAPIExtremaCurveCurve2 ex(bspline1, bspline2, bspline1->FirstParameter(), bspline1->LastParameter(), bspline2->FirstParameter(), bspline2->LastParameter());
// Parallel case, no extremal points, only extremal distance
{
if (ex.IsParallel())
double dist = ex.LowerDistance(); // minimum distance
}
else
{
if (ex.NExtrema() > 0)
{
AMCAX::Point2 p1, p2;
// Get nearest points
ex.NearestPoints(p1, p2);
// Get parameters of nearest points
double param1, param2;
ex.LowerDistanceParameters(param1, param2);
// Get nearest distance
double nearestdist = ex.LowerDistance();
std::cout << "p1:" << p1 << std::endl;//p1:2.07541 1.9023
std::cout << "p2:" << p2 << std::endl;//p2:2.07541 -1.9023
std::cout << "param1:" << param1 << std::endl;//p1:2.07541 1.9023
std::cout << "param2:" << param2 << std::endl;//p2:2.07541 -1.9023
std::cout << "nearestdist:" << nearestdist << std::endl;//p2:2.07541 -1.9023
}
for (int i = 0; i < ex.NExtrema(); i++)
{
// Get the i-th extremal points
AMCAX::Point2 p1, p2;
ex.Points(i, p1, p2);
// Get the i-th parameters of extremal points
double param1, param2;
ex.Parameters(i, param1, param2);
// Get the i-th extremal distance
double dist = ex.Distance(i);
std::cout << "the" <<" " << i <<" " << "extremal point:" << std::endl;
std::cout << "p1: " << p1 << std::endl;
std::cout << "p2: " << p2 << std::endl;
std::cout << "param1: " << param1 << std::endl;
std::cout << "param2: " << param2 << std::endl;
std::cout << "dist: " << dist << std::endl;
std::cout << std::endl;
}
}
Class of computing extremal points for two 2D curves.
Definition GeomAPIExtremaCurveCurve2.hpp:20

Extreme Values Between 3D Curves

To be down.

Extreme Values Between Curves and Surfaces

To be down.

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.

//Define Point
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));
//Configure Parameterization
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 };
//Interpolate points to make a BSpline curve with Thin Plate Energy
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);
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();
Class of constant law function.
Definition LawConstant.hpp:12
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.