- 积分
- 776
- 明经币
- 个
- 注册时间
- 2002-11-21
- 在线时间
- 小时
- 威望
-
- 金钱
- 个
- 贡献
-
- 激情
-
|
发表于 2003-5-20 12:29:00
|
显示全部楼层
自定义实体实现
你可以自定义一个数据库实体类
class AcDbNurbsCurve3D:public AcDbEntity
重载其worldDraw(AcGiWorldDraw* mode)函数如下
{
AcGeKnotVector cKnot;
AcGeDoubleArray cWeight;
AcGePoint3dArray ctrlPt;
double knots[9]={0, 0, 0, 0, 0.5, 1.0, 1.0, 1.0, 1.0};
cKnot.setLogicalLength(9);
cWeight.setLogicalLength(5);
ctrlPt.setLogicalLength(5);
cKnot.set(9, knots, 1.0e-3);
cWeight[0]=1.0;
cWeight[1]=2.0;
cWeight[2]=1.0;
cWeight[3]=1.0;
cWeight[4]=1.0;
ctrlPt[0].set(0, 0, 0.0);
ctrlPt[1].set(50, 50, 0.0);
ctrlPt[2].set(100, 20, 0.0);
ctrlPt[3].set(150, 70, 0.0);
ctrlPt[4].set(200, 0, 0.0);
AcGeNurbCurve3d *pConic = new AcGeNurbCurve3d(3, cKnot, ctrlPt, cWeight, false);
/*
AcGePoint3dArray fitPt;
fitPt.setLogicalLength(5);
fitPt[0].set(0, 0, 0.0);
fitPt[1].set(50, 50, 0.0);
fitPt[2].set(100, 20, 0.0);
fitPt[3].set(150, 70, 0.0);
fitPt[4].set(200, 0, 0.0);
AcGeNurbCurve3d *pConic = new AcGeNurbCurve3d(fitPt,
AcGeVector3d(0,0,0),AcGeVector3d(0,0,0),Adesk::kFalse,Adesk::kFalse);
*/
double param, startParam, endParam, step;
AcGePoint3dArray pVertex;
startParam = pConic->startParam();
endParam = pConic->endParam();
step = (endParam-startParam)/50;
for(param=startParam; (endParam-param)>-1e-3; param=param+step)
{
pVertex.append(pConic->evalPoint(param)) ;
}
mode->geometry().polyline(pVertex.logicalLength(),pVertex.asArrayPtr());
// mode->geometry().polyline(fitPt.logicalLength(),fitPt.asArrayPtr());
mode->geometry().polyline(ctrlPt.logicalLength(),ctrlPt.asArrayPtr());
return AcDbEntity::worldDraw(mode);
}
然后创建该自定义类的一个实例,加入数据库中, |
|