- UID
- 114481
- 积分
- 40
- 精华
- 贡献
-
- 威望
-
- 活跃度
-
- D豆
-
- 在线时间
- 小时
- 注册时间
- 2004-3-17
- 最后登录
- 1970-1-1
|
马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有账号?立即注册
×
本人现在做一个3维实体,可是在同一个平面上好用,在空间就出现问题了,主要是圆锥不符合要求,请高手们指点改正!!谢谢
下面是程序:
AcGePoint3d pt3,pt4;
double slopy1,cosy1,siny1;
CString strSql;
acedCommand(RTSTR,"shademode",RTSTR,"g",RTNONE);
double length;
CDatabase db1;
if (db1.Open(_T( "vendata" ), FALSE, FALSE, _T( "ODBC;UID=sa;PWD=" )))
{
CFcData fdb;
int j;
strSql.Format("select * from fcariways");
j=fdb.Open(AFX_DB_USE_DEFAULT_TYPE,strSql);
if (j==0)
{
acutPrintf("\n 读取网络图数据失败!");
}
else
{
fdb.MoveFirst();
while(!fdb.IsEOF())
{
pt4.x=fdb.m_strpointx; pt4.y=fdb.m_strpointy; pt4.z=fdb.m_strpointz;
pt3.x=fdb.m_endpointx; pt3.y=fdb.m_endpointy; pt3.z=fdb.m_endpointz;
AcGeMatrix3d xfrom4;
xfrom4(0,3)=pt3.x; xfrom4(1,3)=pt3.y; xfrom4(2,3)=pt3.z;
AcDb3dSolid *pSphere2 = new AcDb3dSolid;
pSphere2->createSphere(4);
AcDbObjectId sphere2Id;
pSphere2->transformBy(xfrom4);
// pBlkTableRecord->appendAcDbEntity(sphereId,pSphere);
pSphere2->setColorIndex(3);
postToDatabase(pSphere2,sphere2Id);
pSphere2->close();
length=sqrt((pt3.x-pt4.x)*(pt3.x-pt4.x)+(pt3.y-pt4.y)*(pt3.y-pt4.y));
slopy1=atan2(length,(pt3.z-pt4.z));
cosy1=cos(slopy1);
siny1=sin(slopy1);
AcDbLine *pLine1 = new AcDbLine(pt3,pt4);
AcDbObjectId pline1Id;
postToDatabase(pLine1,pline1Id);
pLine1->close();
AcGeVector3d nrm1;
nrm1.set(cosy1,siny1,0);
AcDbCircle *pCir1 = new AcDbCircle(pt4,nrm1,1);
AcDbObjectId circle1Id;
postToDatabase(pCir1,circle1Id);
pCir1->close();
AcGeMatrix3d fxform;
fxform(0,3)= pt4.x; fxform(1,3)=pt4.y; fxform(2,3)=pt4.z;
AcDb3dSolid *pSphere3 = new AcDb3dSolid;
pSphere3->createSphere(4);
AcDbObjectId sphere3Id;
pSphere3->transformBy(fxform);
// pBlkTableRecord->appendAcDbEntity(sphereId,pSphere);
pSphere3->setColorIndex(3);
postToDatabase(pSphere3,sphere3Id);
pSphere3->close();
AcGeVector3d faxis(0,1,0);
AcGePoint3d center(0,0,0);
fxform.setToRotation(PI/2,faxis,center);
AcDb3dSolid *pFrustum1 = new AcDb3dSolid;
pFrustum1->createFrustum(35,4,4,0);
AcDbObjectId frustum1Id;
pFrustum1->transformBy(fxform);
faxis.set(0,0,1);
fxform.setToRotation(slopy1,faxis,center);
pFrustum1->transformBy(fxform);
AcGeMatrix3d fxform1;
fxform1(0,3)=(pt3.x+pt4.x)/2; fxform1(1,3)=(pt3.y+pt4.y)/2;fxform1(2,3)=(pt3.z+pt4.z)/2;
pFrustum1->transformBy(fxform1);
pFrustum1->setColorIndex(1);
postToDatabase(pFrustum1 ,frustum1Id);
pFrustum1->close();
AcDbVoidPtrArray flines;
AcDbVoidPtrArray fregions1;
AcDbCircle *fspline;
acdbOpenObject(fspline,circle1Id,AcDb::kForRead);
flines.append((void*) fspline);
AcDbRegion::createFromCurves(flines,fregions1);
AcDbRegion* fregions = AcDbRegion::cast((AcRxObject*)fregions1[0]);
AcDb3dSolid *p3dSolid1 = new AcDb3dSolid;
p3dSolid1->extrudeAlongPath(fregions,pLine1);
p3dSolid1->setColorIndex(2);
AcDbObjectId solid1Id;
postToDatabase(p3dSolid1,solid1Id);
p3dSolid1->close();
fdb.MoveNext();
}
}
}
acedCommand(RTSTR,"3dorbit",RTNONE); |
|