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.
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
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.
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) {
maker.Build();
if (maker.IsDone()) {
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;
}
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 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.
}
int create_arc(double x1, double y1, double x2, double y2, double theta) {
auto B = rotatePoint(A, center, theta);
std::shared_ptr<AMCAX::Geom2Curve> curve = std::make_shared<AMCAX::Geom2Circle>(fullCircle);
std::shared_ptr<AMCAX::Geom2TrimmedCurve> trimC = std::make_shared<AMCAX::Geom2TrimmedCurve>(curve, t1, t1 + dheta);
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.
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
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.
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.
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.
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.
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.
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.
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.
std::shared_ptr< AMCAX::Geom2Line > geomline2d = geom2line.Value();
std::shared_ptr< AMCAX::Geom3Line > geomline3d = geom3line.Value();
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.
std::shared_ptr< AMCAX::Geom2Circle > geomcircle2d = geom2circle.Value();
std::shared_ptr< AMCAX::Geom3Circle > geomcircle3d = geom3circle.Value();
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.
std::shared_ptr< AMCAX::Geom2Ellipse >geomellipse2d = geom2ellipse.Value();
std::shared_ptr< AMCAX::Geom3Ellipse >geomellipse3d = geom3ellipse.Value();
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.
std::shared_ptr< AMCAX::Geom2Hyperbola > geomhyperbola2d = geom2hyperbola.Value();
std::shared_ptr< AMCAX::Geom3Hyperbola > geomhyperbola3d = geom3hyperbola.Value();
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.
std::shared_ptr< AMCAX::Geom2Parabola > geomparabola2d = geom2parabola.Value();
std::shared_ptr< AMCAX::Geom3Parabola > geomparabola3d = geom3parabola.Value();
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.
std::shared_ptr< AMCAX::Geom3Plane > geomplane = geom3plane.Value();
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.
std::shared_ptr< AMCAX::Geom3ConicalSurface > geomconicalsurface = geom3conicalsurface.Value();
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();
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.
std::shared_ptr< AMCAX::Geom2TrimmedCurve > segment2d = makesegment2d.Value();
std::shared_ptr< AMCAX::Geom3TrimmedCurve > segment3d = makesegment.Value();
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.
std::shared_ptr< AMCAX::Geom2TrimmedCurve >arcofcircle2d = makearcofcircle2d.Value();
std::shared_ptr< AMCAX::Geom3TrimmedCurve >arcofcircle3d = makearcofcircle.Value();
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.
std::shared_ptr< AMCAX::Geom2TrimmedCurve > arcofellipse2d = makearcofellipse2d.Value();
std::shared_ptr< AMCAX::Geom3TrimmedCurve > arcofellipse3d = makearcofellipse.Value();
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.
std::shared_ptr< AMCAX::Geom2TrimmedCurve > arcofhyperbola2d = makearcofhyperbola2d.Value();
std::shared_ptr< AMCAX::Geom3TrimmedCurve > arcofhyperbola3d = makearcofhyperbola.Value();
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.
std::shared_ptr< AMCAX::Geom2TrimmedCurve > arcofparabola2d = makearcofparabola2d.Value();
std::shared_ptr< AMCAX::Geom3TrimmedCurve > arcofparabola3d = makearcofparabola.Value();
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.
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.
std::shared_ptr< AMCAX::Geom3TrimmedSurface > trimmedcylinder = maketrimmedcylinder.Value();
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().
std::shared_ptr< AMCAX::Geom3TrimmedSurface > trimmedcylinder = maketrimmedcylinder.Value();
double u = 2., v = 0.9;
trimmedcylinder->
D0(u, v, P);
std::cout << "P:" << P << std::endl;
std::cout << trimmedcylinder->
Value(u, v) << std::endl;
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.
std::vector<AMCAX::Point2> points = {
};
std::vector<double> parameters = { 0.0, 0.25, 0.5, 0.75, 1.0 };
bool periodic = false;
interpolate.Perform();
if (interpolate.IsDone())
{
std::shared_ptr<AMCAX::Geom2BSplineCurve> curve2d = interpolate.Curve();
}
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 = {
};
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:
interpolate.Load(firstTangent, lastTangent, true);
3D Interpolated Curves
AMCAX::GeomAPIInterpolate3 is used to compute 3D interpolated curves.
std::vector<AMCAX::Point3> points2 = {
};
std::vector<double> parameters2 = { 0.0, 0.25, 0.5, 0.75, 1.0 };
bool periodic2 = false;
interpolate2.Perform();
if (interpolate2.IsDone()) {
std::shared_ptr<AMCAX::Geom3BSplineCurve> curve3d = interpolate2.Curve();
}
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 = {
};
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:
interpolate2.Load(firstTangent3, lastTangent3, true);
Curve Fitting
2D Curve Fitting
AMCAX::GeomAPIPointsToBSpline2 is used to compute a 2D fitted curve.
std::vector<AMCAX::Point2> points3 = {
};
std::vector<double> parameters3 = { 0.0, 0.25, 0.5, 0.75, 1.0 };
int degMin1 = 3;
int degMax1 = 8;
double tol1 = 1e-3;
if (bsplineFitter1.IsDone()) {
std::shared_ptr<AMCAX::Geom2BSplineCurve> BSplineCurve2d = bsplineFitter1.Curve();
}
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;
if (bsplineFitter2.IsDone()) {
std::shared_ptr<AMCAX::Geom2BSplineCurve> BSplineCurve2d_2 = bsplineFitter2.Curve();
}
else {
std::cout << "error: Bspline curve fitting failed" << std::endl;
}
3D Curve Fitting
AMCAX::GeomAPIPointsToBSpline3 is used to compute a 3D fitted curve.
std::vector<AMCAX::Point3> points5 = {
};
std::vector<double> parameters4 = { 0.0, 0.25, 0.5, 0.75, 1.0 };
int degMin2 = 3;
int degMax2 = 8;
double tol2 = 1e-3;
if (bsplineFitter2.IsDone()) {
std::shared_ptr<AMCAX::Geom3BSplineCurve> BSplineCurve3d = bsplineFitter3.Curve();
}
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.
if (bsplineSurfaceFitter.IsDone()) {
std::shared_ptr<AMCAX::Geom3BSplineSurface> bsplinesurface = bsplineSurfaceFitter.Surface();
}
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.
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;
if (bsplineSurfaceFitter2.IsDone()) {
std::shared_ptr<AMCAX::Geom3BSplineSurface> bsplinesurface2 = bsplineSurfaceFitter2.Surface();
}
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().
std::vector<AMCAX::Point2> pts1 = {
};
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);
auto circle = std::make_shared<AMCAX::Geom2Circle>(frame, 1.0);
std::cout << cc.NPoints() << std::endl;
std::cout << cc.Point(0) << std::endl;
std::cout << cc.Point(1) << std::endl;
std::cout << cc.ParamOnCurve1(0) << std::endl;
std::cout << cc.ParamOnCurve1(1) << std::endl;
std::cout << cc.ParamOnCurve2(0) << std::endl;
std::cout << cc.ParamOnCurve2(1) << std::endl;
auto trimline1 = std::make_shared<AMCAX::Geom2TrimmedCurve>(line1, 0.0, 3.0);
auto trimline2 = std::make_shared<AMCAX::Geom2TrimmedCurve>(line2, 2.0, 4.0);
std::cout << cc2.NSegments() << std::endl;
std::pair< double, double > paramOnCurve1;
std::pair< double, double > paramOnCurve2;
cc2.Segment(0, paramOnCurve1, paramOnCurve2);
std::cout << paramOnCurve1.first << std::endl;
std::cout << paramOnCurve1.second << std::endl;
std::cout << paramOnCurve2.first << std::endl;
std::cout << paramOnCurve2.second << std::endl;
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 = {
};
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;
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().
std::vector<AMCAX::Point3> pts3 = {
};
auto bezier = std::make_shared<AMCAX::Geom3BezierCurve>(pts3);
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);
cs.Perform(bezier, TrimmedSurface);
std::cout << cs.IsDone() << std::endl;
std::cout << cs.NPoints() << std::endl;
double u = 0., v = 0., w = 0.;
cs.Parameters(0, u, v, w);
std::cout << "u:" << u << std::endl;
std::cout << "v:" << v << std::endl;
std::cout << "w:" << w << std::endl;
std::cout << "point:" << cs.Point(0) << std::endl;
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().
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.);
std::cout << ss.IsDone() << std::endl;
std::cout << ss.NLines() << std::endl;
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.
std::vector<AMCAX::Point2> pts1 = {
};
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);
std::vector<AMCAX::Point2> pts2;
for (const auto& pt : pts1) {
}
auto bspline2 = std::make_shared<AMCAX::Geom2BSplineCurve>(pts2, knots1, mults1, 4);
AMCAX::GeomAPIExtremaCurveCurve2 ex(bspline1, bspline2, bspline1->FirstParameter(), bspline1->LastParameter(), bspline2->FirstParameter(), bspline2->LastParameter());
{
if (ex.IsParallel())
double dist = ex.LowerDistance();
}
else
{
if (ex.NExtrema() > 0)
{
ex.NearestPoints(p1, p2);
double param1, param2;
ex.LowerDistanceParameters(param1, param2);
double nearestdist = ex.LowerDistance();
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 << "nearestdist:" << nearestdist << std::endl;
}
for (int i = 0; i < ex.NExtrema(); i++)
{
ex.Points(i, p1, p2);
double param1, param2;
ex.Parameters(i, param1, param2);
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.
std::vector<AMCAX::Point3> points;
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;
nodes.push_back({ p1,true,v1,false,v2 });
nodes.push_back({ p2,true,v1,false,v2 });
std::vector<double> parameterization1{ 0.0,0.5 };
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;
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.