概述
本教程提供了 AMCAX NURBS模组对管道模型进行建模的基本用法。
模型预览
本教程使用管道模型来展示 AMCAX NURBS模组中的一些主要建模功能。模型如下图所示:
管道模型
该模型由三个NURBS曲面组成:
- 左侧的管道。
- 中间过渡管道。
- 右侧圆形截面管道。
我们将逐步介绍这些结构,并尽可能详细地提供解释。
构建左侧管道
创建椭圆截面曲线
第一步是使用 AMCAX::Geom3Ellipse 类创建一个椭圆。
std::shared_ptr<AMCAX::Geom3Ellipse> gellipse = std::make_shared<AMCAX::Geom3Ellipse>(
AMCAX::Frame3(), 0.7, 0.5);
VectorT< double, 3 > Vector3
三维向量
定义 VectorT.hpp:707
FrameT< double, 3 > Frame3
三维标架
定义 FrameT.hpp:885
创建B样条截面曲线
第二步是使用 AMCAX::NURBSAPIBuildCurve 类创建一个B样条曲线。
std::vector<AMCAX::Point3> sectionPoles;
static AMCAX_API std::shared_ptr< Geom3BSplineCurve > BuildCurve(const std::vector< Point3 > &poles, int degree, bool isPeriodic)
Build BSpline curve
PointT< double, 3 > Point3
三维点
定义 PointT.hpp:459
创建引导曲线
第三步是使用 AMCAX::NURBSAPIBuildCurve 类创建两个B样条曲线作为引导曲线。
std::vector<AMCAX::Point3> guidePoles;
应用 单轨扫掠
然后,使用 AMCAX::NURBSAPISweep 类创建扫掠曲面。
std::vector<std::pair<int, double>> guideCorrParams;
std::vector<AMCAX::NURBSCurveSection> profiles;
std::shared_ptr<AMCAX::Geom3BSplineSurface> complexPipe = sweptSurfaces.front();
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 curve section
定义 NURBSCurveSection.hpp:17
点击这里example01可获得以上示例完整源码,大家根据学习需要自行下载。
构建右侧圆形截面管道
构建扫掠路径
扫掠路径是一个形状接近于四分之一椭圆的路径。
std::vector<AMCAX::Point3> centerCurvePoles;
设置扫掠脊线
这里我们将脊线简单地设置为扫掠路径。
std::shared_ptr<AMCAX::Geom3BSplineCurve> spine = centerCurve;
double spineLeftBound = spine->FirstParameter();
double spineRightBound = spine->LastParameter();
构建圆形截面半径
这里我们将圆形截面的半径简单地设置为固定值0.5。
radiusLaw.
Set(0.5, 0.0, 1.0);
常值法则函数的类
定义 LawConstant.hpp:12
AMCAX_API void Set(double r, double pf, double pl)
设置参数
创建扫掠面
接下来,我们使用 AMCAX::NURBSAPICircularSweep 类生成扫掠面。
if (status != AMCAX::NURBSSweepStatus::Success || !circlePipe)
{
return;
}
static AMCAX_API std::pair< NURBSSweepStatus, std::shared_ptr< Geom3BSplineSurface > > SweepWithCenterAndRadius(const std::shared_ptr< Geom3BSplineCurve > ¢erCurve, const LawFunction &radiusLaw, const std::shared_ptr< Geom3BSplineCurve > &spine, double spineLeftBound, double spineRightBound)
根据中心曲线和半径构造圆弧截面扫掠曲面
点击这里example02可获得以上示例完整源码,大家根据学习需要自行下载。
构建中间过渡曲面
最后,我们中间的过渡曲面。
设置过渡曲面参数
std::vector<double> parameters1 = {1.0, 1.0};
std::vector<double> parameters2 = {1.0, 1.0};
std::vector<double> tol = {0.001, 0.1 * M_PI / 180.0, 0.05};
构建过渡曲面
std::shared_ptr<AMCAX::Geom3BSplineSurface> blendSurface =
AMCAX::NURBSAPIBlend::BlendSurfaces(circlePipe,
false,
false, AMCAX::ContinuityType::G2, parameters1, complexPipe,
false,
false, AMCAX::ContinuityType::G2, parameters2,
true,
true, tol);
static AMCAX_API std::shared_ptr< Geom3BSplineSurface > BlendSurfaces(const std::shared_ptr< Geom3BSplineSurface > &surf1, bool isUIso1, bool isFront1, ContinuityType cont1, std::vector< double > ¶meters1, const std::shared_ptr< Geom3BSplineSurface > &surf2, bool isUIso2, bool isFront2, ContinuityType cont2, std::vector< double > ¶meters2, bool autoReverse, bool isPrecise, const std::vector< double > &tol)
给定两个曲面,构造两个曲面的混接曲面
点击这里example03可获得NURBS建模示例完整源码,大家根据学习需要自行下载。
附录
下面列出了此示例的完整代码:
#include <memory>
#include <vector>
void TestPipe()
{
std::shared_ptr<AMCAX::Geom3Ellipse> gellipse = std::make_shared<AMCAX::Geom3Ellipse>(
AMCAX::Frame3(), 0.7, 0.5);
std::vector<AMCAX::Point3> sectionPoles;
std::vector<AMCAX::Point3> guidePoles;
std::vector<std::pair<int, double>> guideCorrParams;
std::vector<AMCAX::NURBSCurveSection> profiles;
std::shared_ptr<AMCAX::Geom3BSplineSurface> complexPipe = sweptSurfaces.front();
std::vector<AMCAX::Point3> centerCurvePoles;
std::shared_ptr<AMCAX::Geom3BSplineCurve> spine = centerCurve;
double spineLeftBound = spine->FirstParameter();
double spineRightBound = spine->LastParameter();
radiusLaw.
Set(0.5, 0.0, 1.0);
if (status != AMCAX::NURBSSweepStatus::Success || !circlePipe)
{
return;
}
std::vector<double> parameters1 = {1.0, 1.0};
std::vector<double> parameters2 = {1.0, 1.0};
std::vector<double> tol = {0.001, 0.1 * M_PI / 180.0, 0.05};
std::shared_ptr<AMCAX::Geom3BSplineSurface> blendSurface =
AMCAX::NURBSAPIBlend::BlendSurfaces(circlePipe,
false,
false, AMCAX::ContinuityType::G2, parameters1, complexPipe,
false,
false, AMCAX::ContinuityType::G2, parameters2,
true,
true, tol);
}
Class of NURBS curve building
The class of one-rail sweeping