- UID
- 10108
- 积分
- 5956
- 精华
- 贡献
-
- 威望
-
- 活跃度
-
- D豆
-
- 在线时间
- 小时
- 注册时间
- 2002-9-17
- 最后登录
- 1970-1-1
|
马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有账号?立即注册
×
[ 本帖最后由 st788796 于 2014-7-12 09:06 编辑 ]\n\n#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 |
|