📄 chgecurvecurveint2d.h
字号:
#ifndef CH_GECURVECURVEINT2D_H
#define CH_GECURVECURVEINT2D_H
#ifndef ACGEXCONFIGARRAY
#define ACGEXCONFIGARRAY
typedef AcArray<AcGeXConfig> AcGeXConfigArray;
#endif
#include <gecint2d.h>
class ChGeCurveCurveInt2d : public AcGeCurveCurveInt2d
{
public:
ChGeCurveCurveInt2d() {}
ChGeCurveCurveInt2d(const AcGeCurve2d& curve1,const AcGeCurve2d& curve2,
const AcGeTol& tol = AcGeContext::gTol);
ChGeCurveCurveInt2d(const AcGeCurve2d& curve1,const AcGeCurve2d& curve2,
const AcGeInterval& range1,const AcGeInterval& range2,
const AcGeTol& tol = AcGeContext::gTol);
ChGeCurveCurveInt2d(const ChGeCurveCurveInt2d& src);
ChGeCurveCurveInt2d& set(const AcGeCurve2d& curve1,const AcGeCurve2d& curve2,
const AcGeTol& tol=AcGeContext::gTol);
ChGeCurveCurveInt2d& set(const AcGeCurve2d& curve1,const AcGeCurve2d& curve2,
const AcGeInterval& range1,const AcGeInterval& range2,
const AcGeTol& tol=AcGeContext::gTol);
ChGeCurveCurveInt2d & orderWrt1();
ChGeCurveCurveInt2d & orderWrt2();
void getParams(AcGeDoubleArray& ps1,AcGeDoubleArray& ps2) { ps1 = params1; ps2 = params2; }
void getXConfigs(AcGeXConfigArray& cs1,AcGeXConfigArray& cs2) { cs1 = confs1; cs2 = confs2; }
void getIntPoints(AcGePoint2dArray& ps) { ps = pnts; }
protected:
AcGeXConfigArray confs1,confs2; // 曲线交点的config
AcGeDoubleArray params1,params2; // 曲线交点参数
AcGePoint2dArray pnts; // 曲线交点
};
inline ChGeCurveCurveInt2d::ChGeCurveCurveInt2d(const AcGeCurve2d& curve1,const AcGeCurve2d& curve2,
const AcGeTol& tol)
: AcGeCurveCurveInt2d(curve1,curve2,tol)
{
int i,intNum;
intNum = numIntPoints();
confs1.setLogicalLength(intNum);
confs2.setLogicalLength(intNum);
params1.setLogicalLength(intNum);
params2.setLogicalLength(intNum);
pnts.setLogicalLength(intNum);
for (i=0; i<intNum; i++) {
pnts[i] = intPoint(i);
getIntConfigs(i,confs1[i],confs2[i]);
getIntParams(i,params1[i],params2[i]);
}
}
inline ChGeCurveCurveInt2d& ChGeCurveCurveInt2d::set(const AcGeCurve2d& curve1,const AcGeCurve2d& curve2,
const AcGeTol& tol)
{
// ?
AcGeCurveCurveInt2d::set(curve1,curve2,tol);
int i,intNum;
intNum = numIntPoints();
confs1.setLogicalLength(intNum);
confs2.setLogicalLength(intNum);
params1.setLogicalLength(intNum);
params2.setLogicalLength(intNum);
pnts.setLogicalLength(intNum);
for (i=0; i<intNum; i++) {
pnts[i] = intPoint(i);
getIntConfigs(i,confs1[i],confs2[i]);
getIntParams(i,params1[i],params2[i]);
}
return *this;
}
inline ChGeCurveCurveInt2d::ChGeCurveCurveInt2d(const AcGeCurve2d& curve1,const AcGeCurve2d& curve2,
const AcGeInterval& range1,const AcGeInterval& range2,
const AcGeTol& tol)
: AcGeCurveCurveInt2d(curve1,curve2,range1,range2,tol)
{
int i,intNum;
intNum = numIntPoints();
confs1.setLogicalLength(intNum);
confs2.setLogicalLength(intNum);
params1.setLogicalLength(intNum);
params2.setLogicalLength(intNum);
pnts.setLogicalLength(intNum);
for (i=0; i<intNum; i++) {
pnts[i] = intPoint(i);
getIntConfigs(i,confs1[i],confs2[i]);
getIntParams(i,params1[i],params2[i]);
}
}
inline ChGeCurveCurveInt2d& ChGeCurveCurveInt2d::set(const AcGeCurve2d& curve1,const AcGeCurve2d& curve2,
const AcGeInterval& range1,const AcGeInterval& range2,
const AcGeTol& tol)
{
AcGeCurveCurveInt2d::set(curve1,curve2,range1,range2,tol);
int i,intNum;
intNum = numIntPoints();
confs1.setLogicalLength(intNum);
confs2.setLogicalLength(intNum);
params1.setLogicalLength(intNum);
params2.setLogicalLength(intNum);
pnts.setLogicalLength(intNum);
for (i=0; i<intNum; i++) {
pnts[i] = intPoint(i);
getIntConfigs(i,confs1[i],confs2[i]);
getIntParams(i,params1[i],params2[i]);
}
return *this;
}
inline ChGeCurveCurveInt2d::ChGeCurveCurveInt2d(const ChGeCurveCurveInt2d& src)
{
// ?
// AcGeCurve2d *cu1,*cu2;
// AcGeTol tol;
// cu1 = src.curve1();
// cu2 = src.curve2();
// tol = src.tolerance();
// *this = ChGeCurveCurveInt2d(*(src.curve1()),*(src.curve2()),tol);
*this = src;
}
inline ChGeCurveCurveInt2d & ChGeCurveCurveInt2d::orderWrt1()
{
if (!numIntPoints()) return *this; // 没有交点
int i,intNum;
bool bAlready = true; // 是否已经是按照curve1排序
intNum = numIntPoints();
for (i=1; i<intNum; i++) {
if (params1[i] < params1[i-1]) {
bAlready = false;
break;
}
}
if (!bAlready) {
int j,min;
for (i=0; i<intNum-1; i++) {
min = i;
for (j=i+1; j<intNum; j++) {
if (params1[min]>params1[j]) min = j;
}
if (min != i) {
params1.swap(i,min);
params2.swap(i,min);
confs1.swap(i,min);
confs2.swap(i,min);
pnts.swap(i,min);
}
}
}
return *this;
}
inline ChGeCurveCurveInt2d & ChGeCurveCurveInt2d::orderWrt2()
{
if (!numIntPoints()) return *this; // 没有交点
int i,intNum;
bool bAlready = true; // 是否已经是按照curve1排序
intNum = numIntPoints();
for (i=1; i<intNum; i++) {
if (params2[i] < params2[i-1]) {
bAlready = false;
break;
}
}
if (!bAlready) {
int j,min;
for (i=0; i<intNum-1; i++) {
min = i;
for (j=i+1; j<intNum; j++) {
if (params2[min]>params2[j]) min = j;
}
if (min != i) {
params1.swap(i,min);
params2.swap(i,min);
confs1.swap(i,min);
confs2.swap(i,min);
pnts.swap(i,min);
}
}
}
return *this;
}
#endif // CH_GECURVECURVEINT2D_H
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -