To simplify the example code, the following helper functions are encapsulated.
Point3 ReadBRepPoint(const std::string& file)
{
TopoShape s;
OCCTIO::OCCTTool::Read(s, file);
TopoExplorer ex(s, ShapeType::Vertex);
TopoVertex v = static_cast<const TopoVertex&>(ex.Value());
return TopoTool::Point(v);
}
shared_ptr<Geom3BSplineCurve> ReadBRepCurve(const string& file)
{
TopoShape s;
OCCTIO::OCCTTool::Read(s, file);
TopoExplorer ex(s, ShapeType::Edge);
TopoEdge e = static_cast<const TopoEdge&>(ex.Value());
shared_ptr<Geom3Curve> curve = NURBSAPIGetGeometry::GetCurve(e);
if (curve->Type() != CurveType::BSplineCurve)
{
auto profile = NURBSAPIConvert::ToBSpline(curve);
return profile;
}
else
{
return dynamic_pointer_cast<Geom3BSplineCurve>(curve);
}
}
shared_ptr<Geom3BSplineSurface> ReadBRepSurface(const string& file)
{
TopoShape s;
OCCTIO::OCCTTool::Read(s, file);
TopoExplorer ex(s, ShapeType::Face);
TopoFace face = static_cast<const TopoFace&>(ex.Value());
shared_ptr< Geom3Surface > surf = NURBSAPIGetGeometry::GetSurface(face);
if (surf->Type() != SurfaceType::BSplineSurface)
{
auto surface = NURBSAPIConvert::ToBSpline(surf);
return surface;
}
else
{
return dynamic_pointer_cast<Geom3BSplineSurface>(surf);
}
}
Free-form Curve and Surface Creation
Free-form curve and surface creation functions include sweeping, lofting, Coons surfaces, curve construction, and surface construction from surface boundaries.
Sweeping
Sweeping functions include single-rail sweep, double-rail sweep, explicit sweep, linear sweep, circular sweep, conic sweep, and rotational sweep.
Single-rail Sweep
A method to construct a surface by taking several u-isoparametric curves as section curves and one v-isoparametric curve as a guide rail is called single-rail sweep.
Principle
Sweeping constructs as many new section curves as possible along the guide rail, and then builds the surface based on all section curves and the guide rail. The method for constructing new section curves involves rotating and translating the original section to new positions, which requires defining a 3D rigid transformation via a frame. The specific implementation is as follows:
1.Find the corresponding point of the section curve on the guide rail, i.e., the position of the red point in the figure below:
2.Sample multiple points on the guide rail and construct a frame at each sample point. The z-axis of the frame is the tangent direction of the guide rail at the sample point.
3.Every two frames define a transformation. Applying the transformation to the section curve yields a new section curve.
4.Construct the surface using the section curves and the guide rail.
The AMCAX::NURBSAPISweep class provides the functionality to obtain a swept surface by sweeping a section curve along a single guide rail.
double radius = 0.5;
std::vector<AMCAX::Point3> points;
int degree = 2.;
bool IsClosed = false;
bool isParallel = false;
double spineRefParam = spine->FirstParameter();
Class of making an edge.
Definition MakeEdge.hpp:26
static AMCAX_API std::shared_ptr< Geom3BSplineCurve > ToBSpline(const std::shared_ptr< Geom3Curve > &curve)
Convert a common curve to a BSpline curve.
static AMCAX_API std::shared_ptr< Geom3Curve > GetCurve(const TopoEdge &edge)
Get not infinite curve from the edge such as part of a line.
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.
static AMCAX_API std::vector< std::shared_ptr< Geom3BSplineSurface > > SweepOneRail(const std::shared_ptr< Geom3BSplineCurve > &profile, const std::shared_ptr< Geom3BSplineCurve > &spine, bool isParallel)
Sweep a profile along a spine.
Class of edge.
Definition TopoEdge.hpp:12
CircleS< 3 > Circle3
3D circle
Definition CircleT.hpp:187
@ Centripetal
Parameters of points are proportional to square roots of distances between them.
Definition ApproxParameterizationType.hpp:17
DirectionT< double, 3 > Direction3
3D direction
Definition DirectionT.hpp:566
PointT< double, 3 > Point3
3D point
Definition PointT.hpp:459
FrameT< double, 3 > Frame3
3D frame
Definition FrameT.hpp:887
The result is shown in the figure below:
The spineRefParam parameter is used to determine which part of the curve to keep. In the example above, it's the first half. If you want the second half, spineRefParam can be set to spine->LastParameter(). The result is shown in the figure below:
Here is a brief introduction to the other input parameters:
1.spineCorrParams is used to provide the corresponding parameters of the section curves on the guide rail.
2.isClosedSweep only takes effect when the guide rail is a periodic curve. When True, it constructs the entire surface of the periodic guide rail; when False, it only constructs part of the surface. The selection rules are as follows:
- If there is 1 section curve, it selects [t0, section] or [section, t1] based on spineRefParam (t0 is the start parameter of the guide rail, t1 is the end parameter of the guide rail);
- If there are 2 section curves, it selects [section 1, section 2] or [section 2, section 1] based on spineRefParam;
- If there are 3 or more section curves, it selects the range based on the input order of the section curves and spineRefParam.
3.isAutoTwist takes effect when there are straight segments and C0 points in the guide rail.
Double-rail Sweep
A method to construct a surface by taking several u-isoparametric curves as section curves and two v-isoparametric curves as guide rails is called double-rail sweep. Compared to single-rail sweep, double-rail sweep offers stronger control over the surface shape.
The AMCAX::NURBSAPISweep2 class provides the functionality to obtain a swept surface by sweeping profile curves along two guide rails.
std::string filedir = "./data/NURBSAPISweep2/";
std::vector<NURBSCurveSection> profiles;
for (int i = 0; i <= 3; i++)
{
auto p = ReadBRepCurve(filedir + "profile" + std::to_string(i) + ".brep");
profiles.push_back(NURBSCurveSection(p));
}
std::shared_ptr<Geom3BSplineCurve> spine1 = ReadBRepCurve(filedir + "spine" + std::to_string(1) + ".brep");
std::shared_ptr<Geom3BSplineCurve> spine2 = ReadBRepCurve(filedir + "spine" + std::to_string(2) + ".brep");
double spine1RefParam = 0.5 * (spine1->FirstParameter() + spine1->LastParameter());
std::vector<std::pair<int, double>> spine1CorrParams, spine2CorrParams;
bool isAutoTwist = true;
bool isClosedSweep = false;
auto surfaces = NURBSAPISweep2::SweepTwoRails(profiles, spine1, spine2, spine1RefParam, spine1CorrParams, spine2CorrParams, isClosedSweep, isAutoTwist);
The result is shown in the figure below:
There is 1 B-spline surface in total.
Explicit Sweep
The AMCAX::NURBSAPIExplicitSweep class provides explicit sweep functionality.
Using a Reference Surface
The AMCAX::NURBSAPIExplicitSweep::SweepWithReferenceSurface class is used to construct a swept surface based on a section curve and a guide curve on a reference surface.
std::string filedir = "./data/ExplicitSweepWithReferenceSurface/";
auto profile = ReadBRepCurve(filedir + "profile.brep");
auto guide = ReadBRepCurve(filedir + "guide.brep");
auto reference = ReadBRepSurface(filedir + "surface.brep");
auto spine = guide;
LawConstant angleLawFunc;
angleLawFunc.Set(0.0, 0.0, 1.0);
double spineLeftBound = spine->FirstParameter();
double spineRightBound = spine->LastParameter();
auto [status, surfaces] = NURBSAPIExplicitSweep::SweepWithReferenceSurface(profile, guide, reference, angleLawFunc, guide, spineLeftBound, spineRightBound);
The result is shown in the figure below:
There are 4 B-spline surfaces in total (the section curve rotates around the guide rail, possible rotations: clockwise/counterclockwise/rotate 180 degrees then clockwise/rotate 180 degrees then counterclockwise).
Using Two Guide Curves
The AMCAX::NURBSAPIExplicitSweep::SweepWithTwoGuideCurves class is used to construct a swept surface based on a section curve and two guide curves. Two modes are supported: selecting two anchor points or selecting one anchor point and one direction.
Selecting Two Anchor Points
Both anchor points are on the section curve. The section curve is transformed (rotated, translated, scaled) so that the anchor points lie on the guide curves, and then the sweep is performed.
std::string filedir = "./data/ExplicitSweepWithTwoGuideCurvesTwoPoints/";
auto profile = ReadBRepCurve(filedir + "profile.brep");
auto guide1 = ReadBRepCurve(filedir + "guide1.brep");
auto guide2 = ReadBRepCurve(filedir + "guide2.brep");
auto anchorPoint1 = ReadBRepPoint(filedir + "point1.brep");
auto anchorPoint2 = ReadBRepPoint(filedir + "point2.brep");
auto spine = guide1;
double spineLeftBound = spine->FirstParameter();
double spineRightBound = spine->LastParameter();
auto [status, surface] = NURBSAPIExplicitSweep::SweepWithTwoGuideCurves(profile, guide1, guide2, anchorPoint1, anchorPoint2, guide1, spineLeftBound, spineRightBound);
The result is shown in the figure below:
There is 1 B-spline surface in total (the yellow curves are the guide curves).
Selecting One Anchor Point and One Direction
The transformation of the section curve is: first translate the section curve so that the anchor point lies on the first guide curve, then rotate it so that its direction aligns with the direction between the guide curves.
std::string filedir = "./data/ExplicitSweepWithTwoGuideCurvesPointDirection/";
auto profile = ReadBRepCurve(filedir + "profile.brep");
auto guide1 = ReadBRepCurve(filedir + "guide1.brep");
auto guide2 = ReadBRepCurve(filedir + "guide2.brep");
auto spine = guide1;
auto anchorPoint = ReadBRepPoint(filedir + "point1.brep");
Direction3 anchorDirection(0.0294018, -0.0429342, -0.998645);
double spineLeftBound = spine->FirstParameter();
double spineRightBound = spine->LastParameter();
auto [status, surface] = NURBSAPIExplicitSweep::SweepWithTwoGuideCurves(profile, guide1, guide2, anchorPoint, anchorDirection, spine, spineLeftBound, spineRightBound);
The result is shown in the figure below:
There is 1 B-spline surface in total (the yellow curves are the guide curves).
Using a Draft Direction
The AMCAX::NURBSAPIExplicitSweep::SweepWithPullingDirection class is used to construct a swept surface based on a section curve, a guide curve, and a draft direction.
std::string filedir = "./data/ExplicitSweepWithPullingDirection/";
auto profile = ReadBRepCurve(filedir + "profile.brep");
auto guide = ReadBRepCurve(filedir + "guide.brep");
auto spine = guide;
Direction3 pullingDirection(0.0, 0.0, 1.0);
LawConstant angleLawFunc;
angleLawFunc.Set(0.0, 0.0, 1.0);
double spineLeftBound = spine->FirstParameter();
double spineRightBound = spine->LastParameter();
auto [status, surfaces] = NURBSAPIExplicitSweep::SweepWithPullingDirection(profile, guide, pullingDirection, angleLawFunc, spine, spineLeftBound, spineRightBound);
The result is shown in the figure below:
There are 4 B-spline surfaces in total (the section curve rotates around the guide rail, possible rotations: clockwise/counterclockwise/rotate 180 degrees then clockwise/rotate 180 degrees then counterclockwise).
Linear Sweep
The AMCAX::NURBSAPILinearSweep class provides linear sweep functionality.
Two Limits
The AMCAX::NURBSAPILinearSweep::SweepWithTwoLimits class is used to construct a linear-section swept surface between two guide curves, where the two guide curves are the surface boundaries.
std::string filedir = "./data/SweepWithTwoLimits/";
auto guide1 = ReadBRepCurve(filedir + "guide1.brep");
auto guide2 = ReadBRepCurve(filedir + "guide2.brep");
auto spine = guide1;
LawConstant length1Law;
length1Law.Set(0., 0., 1.);
LawConstant length2Law;
length2Law.Set(0., 0., 1.);
double spineLeftBound = spine->FirstParameter();
double spineRightBound = spine->LastParameter();
static AMCAX_API std::pair< NURBSSweepStatus, std::shared_ptr< Geom3BSplineSurface > > SweepWithTwoLimits(const std::shared_ptr< Geom3BSplineCurve > &guide1, const std::shared_ptr< Geom3BSplineCurve > &guide2, const std::shared_ptr< Geom3BSplineCurve > &spine, double spineLeftBound, double spineRightBound, const LawFunction &length1Law, const LawFunction &length2Law)
Sweep with two guide curves as surface limit boundaries.
The result is shown in the figure below:
There is 1 B-spline surface in total.
Although the two guide curves are nominally the surface boundaries, the interface provides a LawFunction for length to further extend the linear section segments. For example:
LawConstant length1Law;
length1Law.Set(20., 0., 1.);
LawConstant length2Law;
length2Law.Set(10., 0., 1.);
The result is shown in the figure below:
Limit and Middle
The AMCAX::NURBSAPILinearSweep::SweepWithLimitAndMiddle class is used to construct a linear-section swept surface between two guide curves, where one curve is the surface boundary and the other is the surface centerline.
std::string filedir = "./data/SweepWithLimitAndMiddle/";
auto guide1 = ReadBRepCurve(filedir + "guide1.brep");
auto guide2 = ReadBRepCurve(filedir + "guide2.brep");
auto spine = guide2;
double spineLeftBound = spine->FirstParameter();
double spineRightBound = spine->LastParameter();
auto [status, surface] = NURBSAPILinearSweep::SweepWithLimitAndMiddle(guide1, guide2, spine, spineLeftBound, spineRightBound);
The result is shown in the figure below:
There is 1 B-spline surface in total.
Using a Draft Direction
The AMCAX::NURBSAPILinearSweep::SweepWithDraftDirection class is used to construct a linear-section swept surface based on a guide curve and a draft direction. The direction of the linear section is consistent with the draft direction.
std::string filedir = "./data/SweepWithDraftDirection/";
auto guide = ReadBRepCurve(filedir + "curve.brep");
Direction3 draftDirection(0., 0., 1.);
LawConstant angleLaw;
angleLaw.Set(0.0, 0.0, 1.0);
auto type = NURBSLinearSweepWithDraftDirectionLengthType::FromTo;
double length = 1.;
auto relimitingSurface1 = ReadBRepSurface(filedir + "surf1.brep");
auto relimitingSurface2 = ReadBRepSurface(filedir + "surf2.brep");
NURBSLinearSweepWithDraftDirectionLength length1(type, length, relimitingSurface1);
NURBSLinearSweepWithDraftDirectionLength length2(type, length, relimitingSurface2);
auto [status, result] = NURBSAPILinearSweep::SweepWithDraftDirection(guide, draftDirection, angleLaw, length1, length2);
In the above example, the length mode is set to FromTo (automatically extended to the specified reference surfaces). The result is shown in the figure below (the upper and lower surfaces are the input reference surfaces, and the middle one is the generated linear-section swept surface):
In addition, there are three other modes:
1. FromCurve
Length is 0, the length and relimitingSurface parameters are not used. The result is shown in the figure below:
2. Standard
Length is the specified length. The result is shown in the figure below:
3. FromExtremum
Length is extended to the farthest point of the guide curve in the draft direction. The result is shown in the figure below:
Using a Reference Curve
The AMCAX::NURBSAPILinearSweep::SweepWithReferenceCurve class is used to construct a linear-section swept surface based on two guide curves, where one is the surface centerline and the other is a reference curve, providing the direction of the linear section (the direction from the guide curve to the reference curve is the direction of the linear section segment).
std::string filedir = "./data/SweepWithReferenceCurve/";
auto guide = ReadBRepCurve(filedir + "guide.brep");
auto reference = ReadBRepCurve(filedir + "reference.brep");
auto spine = guide;
LawConstant angleLaw;
angleLaw.Set(Constants::pi / 3.0, 0.0, 1.0);
LawConstant length1Law;
length1Law.Set(3, 0.0, 1.0);
LawConstant length2Law;
length2Law.Set(3, 0.0, 1.0);
double spineLeftBound = spine->FirstParameter();
double spineRightBound = spine->LastParameter();
auto [status, surfaces] = NURBSAPILinearSweep::SweepWithReferenceCurve(guide, reference, angleLaw, length1Law, length2Law, spine, spineLeftBound, spineRightBound);
The result is shown in the figure below:
There are 4 B-spline surfaces in total (the section curve rotates around the guide rail, possible rotations: clockwise/counterclockwise/rotate 180 degrees then clockwise/rotate 180 degrees then counterclockwise). The yellow curve is the surface centerline.
Using a Reference Surface
The AMCAX::NURBSAPILinearSweep::SweepWithReferenceSurface class is used to construct a swept surface based on a guide curve on a reference surface. The normal direction of the reference surface is the direction of the linear section segment.
std::string filedir = "./data/SweepWithReferenceSurface/";
auto guide = ReadBRepCurve(filedir + "guide.brep");
auto reference = ReadBRepSurface(filedir + "surface.brep");
auto spine = guide;
LawConstant angleLaw;
angleLaw.Set(Constants::quarter_pi, 0.0, 1.0);
LawConstant length1Law;
length1Law.Set(3, 0.0, 1.0);
LawConstant length2Law;
length2Law.Set(5, 0.0, 1.0);
double spineLeftBound = spine->FirstParameter();
double spineRightBound = spine->LastParameter();
auto [status, surfaces] = NURBSAPILinearSweep::SweepWithReferenceSurface(guide, reference, angleLaw, length1Law, length2Law, guide, spineLeftBound, spineRightBound);
The result is shown in the figure below:
There are 4 B-spline surfaces in total (the section curve rotates around the guide rail, possible rotations: clockwise/counterclockwise/rotate 180 degrees then clockwise/rotate 180 degrees then counterclockwise).
Using a Tangency Surface
The AMCAX::NURBSAPILinearSweep::SweepWithTangencySurface class is used to construct a linear-section swept surface (passing through the guide curve and tangent to the surface) based on a surface and a guide curve.
std::string filedir = "./data/SweepWithTangencySurface/";
auto guide = ReadBRepCurve(filedir + "curve.brep");
auto tangencySurface = ReadBRepSurface(filedir + "surface.brep");
auto spine = guide;
double spineLeftBound = spine->FirstParameter();
double spineRightBound = spine->LastParameter();
auto [status, surfaces] = NURBSAPILinearSweep::SweepWithTangencySurface(guide, tangencySurface, spine, spineLeftBound, spineRightBound);
The result is shown in the figure below:
There are 2 B-spline surfaces in total.
Using Two Tangency Surfaces
The AMCAX::NURBSAPILinearSweep::SweepWithTwoTangencySurfaces class is used to construct a linear-section swept surface (tangent to the two input surfaces) based on two surfaces and a spine.
std::string filedir = "./data/SweepWithTwoTangencySurfaces/";
auto spine = ReadBRepCurve(filedir + "spine.brep");
auto tangencySurface1 = ReadBRepSurface(filedir + "surface1.brep");
auto tangencySurface2 = ReadBRepSurface(filedir + "surface2.brep");
double spineLeftBound = spine->FirstParameter();
double spineRightBound = spine->LastParameter();
static AMCAX_API std::pair< NURBSSweepStatus, std::vector< std::shared_ptr< Geom3BSplineSurface > > > SweepWithTwoTangencySurfaces(const std::shared_ptr< Geom3BSplineCurve > &spine, const std::shared_ptr< Geom3BSplineSurface > &tangencySurface1, const std::shared_ptr< Geom3BSplineSurface > &tangencySurface2, double spineLeftBound, double spineRightBound)
Build a swept surface tangency to two surfaces.
The result is shown in the figure below:
The left and right surfaces are the two input surfaces, and the middle surface is the linear-section swept surface.
Circular Sweep
The AMCAX::NURBSAPICircularSweep class provides circular sweep functionality.
Using Three Guide Curves
The AMCAX::NURBSAPICircularSweep::SweepWithThreeGuides class is used to construct a circular-section swept surface between three guide curves, where two guide curves are the surface boundaries and the other guide curve lies on the circular section.
Three points on a plane determine a circle. The arc is trimmed in the order 1->2->3.
std::string filedir = "./data/SweepWithThreeGuides/";
auto guide1 = ReadBRepCurve(filedir + "guide1.brep");
auto guide2 = ReadBRepCurve(filedir + "guide2.brep");
auto guide3 = ReadBRepCurve(filedir + "guide3.brep");
auto spine = guide1;
double spineLeftBound = spine->FirstParameter();
double spineRightBound = spine->LastParameter();
auto [status, surface] = NURBSAPICircularSweep::SweepWithThreeGuides(guide1, guide2, guide3, spine, spineLeftBound, spineRightBound);
The result is shown in the figure below:
There is 1 B-spline surface in total.
Two Guide Curves and Radius
The AMCAX::NURBSAPICircularSweep::SweepWithTwoGuidesAndRadius class is used to construct a circular-section swept surface with a given radius between two guide curves, where the two guide curves are the boundaries of the swept surface.
Two points on a plane + a radius determine 2 circles.
Returns 6 B-spline surfaces:
- Counterclockwise arc from guide 1 to guide 2 of circle 1
- Counterclockwise arc from guide 2 to guide 1 of circle 1
- Circle 1
- Counterclockwise arc from guide 1 to guide 2 of circle 2
- Counterclockwise arc from guide 2 to guide 1 of circle 2
- Circle 2
std::string filedir = "./data/SweepWithTwoGuidesAndRadius/";
auto guide1 = ReadBRepCurve(filedir + "guide1.brep");
auto guide2 = ReadBRepCurve(filedir + "guide2.brep");
auto spine = ReadBRepCurve(filedir + "spine.brep");
LawConstant radiusLaw;
radiusLaw.Set(5.0, 0.0, 1.0);
double spineLeftBound = spine->FirstParameter();
double spineRightBound = spine->LastParameter();
auto [status, surfaces] = NURBSAPICircularSweep::SweepWithTwoGuidesAndRadius(guide1, guide2, radiusLaw, spine, spineLeftBound, spineRightBound);
The result is shown in the figure below:
There are 6 B-spline surfaces in total.
The 1st and 2nd surfaces are (different colors represent one curve):
The 3rd surface is:
The 4th and 5th surfaces are (different colors represent one curve):
The 6th surface is:
Center and Two Angles
The AMCAX::NURBSAPICircularSweep::SweepWithCenterAndTwoAngles class is used to construct a circular-section swept surface based on two guide curves and two angles, where the first guide curve is the center of the circular section, the other guide curve lies on the circular section, and the two angles represent the rotation angles of the circular section on the second guide curve.
std::string filedir = "./data/SweepWithCenterAndTwoAngles/";
auto centerCurve = ReadBRepCurve(filedir + "center.brep");
auto referenceCurve = ReadBRepCurve(filedir + "ref.brep");
auto spine = centerCurve;
LawConstant angleLaw1;
angleLaw1.Set(-Constants::quarter_pi, 0.0, 1.0);
LawConstant angleLaw2;
angleLaw2.Set(Constants::quarter_pi, 0.0, 1.0);
double spineLeftBound = spine->FirstParameter();
double spineRightBound = spine->LastParameter();
auto [status, surface] = NURBSAPICircularSweep::SweepWithCenterAndTwoAngles(centerCurve, referenceCurve, angleLaw1, angleLaw2, spine, spineLeftBound, spineRightBound);
The result is shown in the figure below:
There is 1 B-spline surface in total (the yellow curve is the center curve).
Center and Radius
The AMCAX::NURBSAPICircularSweep::SweepWithCenterAndRadius class is used to construct a circular-section swept surface based on a center curve and a radius, where the radius is constructed using a LawFunction.
std::string filedir = "./data/SweepWithCenterAndRadius/";
auto centerCurve = ReadBRepCurve(filedir + "center.brep");
auto spine = centerCurve;
LawConstant radiusLaw;
radiusLaw.Set(5.0, 0.0, 1.0);
double spineLeftBound = spine->FirstParameter();
double spineRightBound = spine->LastParameter();
auto [status, surface] = NURBSAPICircularSweep::SweepWithCenterAndRadius(centerCurve, radiusLaw, spine, spineLeftBound, spineRightBound);
The result is shown in the figure below:
There is 1 B-spline surface in total.
Two Guide Curves and a Tangency Surface
The AMCAX::NURBSAPICircularSweep::SweepWithTwoGuidesAndTangencySurface class is used to construct a circular-section swept surface between two guide curves based on a guide curve on a reference surface and another guide curve, where the two guide curves are the surface boundaries, and the swept surface is tangent to the reference surface.
std::string filedir = "./data/SweepWithTwoGuidesAndTangencySurface/";
auto limitCurveWithTangency = ReadBRepCurve(filedir + "guide1.brep");
auto limitCurve = ReadBRepCurve(filedir + "guide2.brep");
auto tangencySurface = ReadBRepSurface(filedir + "surface.brep");
auto spine = ReadBRepCurve(filedir + "spine.brep");
double spineLeftBound = spine->FirstParameter();
double spineRightBound = spine->LastParameter();
auto [status, surfaces] = NURBSAPICircularSweep::SweepWithTwoGuidesAndTangencySurface(limitCurveWithTangency, tangencySurface, limitCurve, spine, spineLeftBound, spineRightBound);
The result is shown in the figure below:
There are 2 B-spline surfaces in total, which are the swept surfaces from guide curve 1 to guide curve 2 and from guide curve 2 to guide curve 1, both tangent to the reference surface. The yellow curve is the first guide curve.
One Guide Curve and a Tangency Surface
The AMCAX::NURBSAPICircularSweep::SweepWithOneGuideAndTangencySurface class is used to construct a circular-section swept surface based on one guide curve, a reference surface, and a radius, where the guide curve is the surface boundary (not on the given reference surface), the other end of the circular section lies on the reference surface, and the swept surface is tangent to the reference surface.
std::string filedir = "./data/SweepWithOneGuideAndTangencySurface/";
auto guide = ReadBRepCurve(filedir + "guide.brep");
auto tangencySurface = ReadBRepSurface(filedir + "surface.brep");
auto spine = guide;
LawConstant radiusLaw;
radiusLaw.Set(10.0, 0.0, 1.0);
double spineLeftBound = spine->FirstParameter();
double spineRightBound = spine->LastParameter();
auto [status, surfaces] = NURBSAPICircularSweep::SweepWithOneGuideAndTangencySurface(guide, tangencySurface, radiusLaw, spine, spineLeftBound, spineRightBound);
The result is shown in the figure below:
There will be several resulting surfaces. In this example, there are 4 B-spline surfaces in total, all tangent to the reference surface.
Limit Curve and Tangency Surface
The AMCAX::NURBSAPICircularSweep::SweepWithCurveOnTangencySurface class is used to construct a circular-section swept surface based on a guide curve on a reference surface, the arc radius, and the start and end angles of the arc. The surface boundaries are set by two angle LawFunctions, representing the start and end angles of the arc.
std::string filedir = "./data/SweepWithCurveOnTangencySurface/";
auto guide = ReadBRepCurve(filedir + "guide.brep");
auto tangencySurface = ReadBRepSurface(filedir + "surface.brep");
auto spine = ReadBRepCurve(filedir + "spine.brep");
LawConstant radiusLaw;
radiusLaw.Set(10.0, 0.0, 1.0);
LawConstant angleLaw1;
angleLaw1.Set(0.0, 0.0, 1.0);
LawConstant angleLaw2;
angleLaw2.Set(Constants::pi, 0.0, 1.0);
double spineLeftBound = spine->FirstParameter();
double spineRightBound = spine->LastParameter();
auto [status, surfaces] = NURBSAPICircularSweep::SweepWithCurveOnTangencySurface(guide, tangencySurface, radiusLaw, angleLaw1, angleLaw2, spine, spineLeftBound, spineRightBound);
The result is shown in the figure below:
There are 2 B-spline surfaces in total, curving upwards and downwards respectively (the yellow curve is the guide curve).
Conical Sweep
The AMCAX::NURBSAPIConicalSweep class provides conic sweep functionality.
Using Two Guide Curves
The AMCAX::NURBSAPIConicalSweep::SweepWithTwoGuides class is used to construct a conic-section swept surface between two guide curves on two reference surfaces and a shape parameter (value range (0.0,1.0)), where the swept surface is tangent to the two reference surfaces.
The shape parameter represents the curvature of the conic section; the larger the value, the more curved. When the value is in the interval (0.0,0.5), it is an ellipse; when the value equals 0.5, it is a parabola; when the value is in the interval (0.5,1.0), it is a hyperbola.
std::string filedir = "./data/SweepWithTwoGuides/";
auto guide1 = ReadBRepCurve(filedir + "guide1.brep");
auto guide2 = ReadBRepCurve(filedir + "guide2.brep");
auto spine = guide1;
auto tangencySurface1 = ReadBRepSurface(filedir + "tangency1.brep");
auto tangencySurface2 = ReadBRepSurface(filedir + "tangency2.brep");
LawConstant angleLaw1;
angleLaw1.Set(0.0, 0.0, 1.0);
LawConstant angleLaw2;
angleLaw2.Set(0.0, 0.0, 1.0);
LawConstant parameter;
parameter.Set(0.3, 0.0, 1.0);
double spineLeftBound = spine->FirstParameter();
double spineRightBound = spine->LastParameter();
auto [status, surface] = NURBSAPIConicalSweep::SweepWithTwoGuides(guide1, tangencySurface1, angleLaw1, guide2, tangencySurface2, angleLaw2, parameter, spine, spineLeftBound, spineRightBound);
The result is shown in the figure below:
There is 1 B-spline surface in total.
Using Three Guide Curves
The AMCAX::NURBSAPIConicalSweep::SweepWithThreeGuides class is used to construct a conic-section swept surface between the first and third guide curves based on two guide curves on reference surfaces and one reference curve, where the swept surface passes through each reference curve and is tangent to the two reference surfaces (the surfaces on which the first and third guide curves lie).
std::string filedir = "./data/SweepWithThreeGuides/";
auto guide1 = ReadBRepCurve(filedir + "guide1.brep");
auto guide2 = ReadBRepCurve(filedir + "guide2.brep");
auto guide3 = ReadBRepCurve(filedir + "guide3.brep");
auto spine = guide1;
auto tangencySurface1 = ReadBRepSurface(filedir + "surface1.brep");
auto tangencySurface3 = ReadBRepSurface(filedir + "surface2.brep");
LawConstant angleLaw1;
angleLaw1.Set(10.0 * Constants::pi / 180.0, 0.0, 1.0);
LawConstant angleLaw3;
angleLaw3.Set(10.0 * Constants::pi / 180.0, 0.0, 1.0);
double spineLeftBound = spine->FirstParameter();
double spineRightBound = spine->LastParameter();
auto [status, surface] = NURBSAPIConicalSweep::SweepWithThreeGuides(guide1, tangencySurface1, angleLaw1, guide2, guide3, tangencySurface3, angleLaw3, spine, spineLeftBound, spineRightBound);
The result is shown in the figure below:
There is 1 B-spline surface in total.
Using Four Guide Curves
The AMCAX::NURBSAPIConicalSweep::SweepWithFourGuides class is used to construct a conic-section swept surface between the first and fourth reference curves based on one guide curve on a reference surface and three reference curves, where the swept surface passes through each reference curve and is tangent to the reference surface (the surface on which the first guide curve lies).
std::string filedir = "./data/SweepWithFourGuides/";
auto guide1 = ReadBRepCurve(filedir + "guide1.brep");
auto guide2 = ReadBRepCurve(filedir + "guide2.brep");
auto guide3 = ReadBRepCurve(filedir + "guide3.brep");
auto guide4 = ReadBRepCurve(filedir + "guide4.brep");
auto spine = guide2;
auto tangencySurface = ReadBRepSurface(filedir + "surface.brep");
LawConstant angleLaw;
angleLaw.Set(0.0, 0.0, 1.0);
double spineLeftBound = spine->FirstParameter();
double spineRightBound = spine->LastParameter();
auto [status, surface] = NURBSAPIConicalSweep::SweepWithFourGuides(guide1, tangencySurface, angleLaw, guide2, guide3, guide4, spine, spineLeftBound, spineRightBound);
The result is shown in the figure below:
There is 1 B-spline surface in total.
Using Five Guide Curves
The AMCAX::NURBSAPIConicalSweep::SweepWithFiveGuides class is used to construct a conic-section swept surface between the first and fifth reference curves based on five reference curves, where the swept surface passes through each reference curve.
std::string filedir = "./data/SweepWithFiveGuides/";
auto guide1 = ReadBRepCurve(filedir + "guide1.brep");
auto guide2 = ReadBRepCurve(filedir + "guide2.brep");
auto guide3 = ReadBRepCurve(filedir + "guide3.brep");
auto guide4 = ReadBRepCurve(filedir + "guide4.brep");
auto guide5 = ReadBRepCurve(filedir + "guide5.brep");
auto spine = guide2;
double spineLeftBound = spine->FirstParameter();
double spineRightBound = spine->LastParameter();
auto [status, surface] = NURBSAPIConicalSweep::SweepWithFiveGuides(guide1, guide2, guide3, guide4, guide5, spine, spineLeftBound, spineRightBound);
The result is shown in the figure below:
There is 1 B-spline surface in total.
Rotational Sweep
The AMCAX::NURBSAPISweepRotation::RotationSweep class is used to obtain a swept surface by rotating the profile curve around an axis while sweeping it along a rail.
std::string filedir = "./data/RotationSweep/";
std::shared_ptr<Geom3BSplineCurve> spine = ReadBRepCurve(filedir + "spine.brep");
std::shared_ptr<Geom3BSplineCurve> profile = ReadBRepCurve(filedir + "profile.brep");
static AMCAX_API std::shared_ptr< Geom3BSplineSurface > RotationSweep(const std::shared_ptr< Geom3BSplineCurve > &profile, const std::shared_ptr< Geom3BSplineCurve > &spine, const Axis3 &axis)
Sweep the profile along the spine and rotate and scale around the axis.
AxisT< double, 3 > Axis3
3D axis
Definition AxisT.hpp:423
The result is shown in the figure below:
There is 1 B-spline surface in total.
Freeform Curve and Surface Edit
The freeform curve and surface edit functions include rebuil, combine, explode, trim, untrim, extend, approx, interpolation, and conversion.
To be down.
Freeform Modeling
The freeform modeling functions include blend, join, offset on surfaces, edge replacement, and more.
Blend
The AMCAX::NURBSAPIBlend class provides blending functionality. Blending includes:
AMCAX::NURBSAPIBlend::BlendCurves constructs a blend curve between two curves.
AMCAX::NURBSAPIBlend::BlendSurfaces constructs a blend surface between two surfaces.
AMCAX::NURBSAPIBlend::BlendFaces selects two edges from TopoFace (trimmed or untrimmed) and constructs a blended face. The result is similar to BlendSurfaces, except the input changes from geometry to TopoFace.
Blend Curve
To be down.
Blend Surface
To be down.
Join
AMCAX::NURBSAPIJoin class provides join functionality
Join Curve
AMCAX::NURBSAPIJoin::JoinCurvePrepare sorts the input curves in sequence based on their connection and divides them into groups, determining whether each curve in the group should be reversed and whether the curves can form a closed loop. This function supports sorting and grouping both 3D curves and their corresponding pcurves simultaneously.
AMCAX::NURBSAPIJoin::JoinCurves combines several groups of curves into multiple curves or combines one group into a single curve.
To be down.
Join Surface
AMCAX::NURBSAPIJoin::JoinSurfacesPrepare sorts the input surfaces in a sequential order, connecting them end-to-end, and determines whether the connecting edges of the surfaces are U-isoparametric curves or V-isoparametric curves, whether the surfaces should be reversed in the front-to-back direction, whether the direction of the isoparametric curves along the edges should be reversed, and whether these surfaces can be joined to form periodic surfaces in the U and V directions.
AMCAX::NURBSAPIJoin::JoinSurfaces combines several sets of surfaces into multiple surfaces or combines one set of surfaces into a single surface.
To be down.
Offset on Surface
The AMCAX::NURBSAPIOffsetCurveOnSurface class provides the functionality to offset on surfaces. Among them, AMCAX::NURBSAPIOffsetCurveOnSurface::OffsetCurveOnSurface offsets a curve on a surface by a certain length while keeping the result on the surface;
AMCAX::NURBSAPIOffsetCurveOnSurface::OffsetCurveOnSurfaceToPoint offsets a curve on a surface while keeping it on the surface and through a point on the surface.
To be down.
Edge Replacement
The AMCAX::NURBSAPIReplaceEdge class provides edge replacement functionality. AMCAX::NURBSAPIReplaceEdge::ReplaceEdgeWithCurve replaces multiple edges of a face with curves; AMCAX::NURBSAPIReplaceEdge::ReplaceEdgeWithLine replaces multiple edges of a face with straight lines.
To be down.