明经CAD社区

 找回密码
 注册

QQ登录

只需一步,快速开始

搜索
查看: 1190|回复: 0

好心人帮忙解释一下程序

[复制链接]
发表于 2004-7-31 12:32:00 | 显示全部楼层 |阅读模式

void lwpoly()
{
AcDbDatabase *pCurDb;
AcDbBlockTable *pBlkTable;
AcDbBlockTableRecord *pBlkTableRecord;
AcDbPolyline *pPolyEnt;
AcDbObjectId polyId;
AcGePoint2d pkPt;
AcGePoint2dArray arPts;
ads_point pick, lastpt;
AcGeMatrix3d ucsMat;
AcGeMatrix2d ucsMat2d;

int retCode;
int numPts;

Adesk::Boolean keepPicking = Adesk::kTrue;
Adesk::Boolean firstPick = Adesk::kTrue

acdbUcsMatrix(ucsMat);

ucsMat2d(0,0) = ucsMat(0,0);
ucsMat2d(0,1) = ucsMat(0,1);
ucsMat2d(0,2) = ucsMat(0,3);
ucsMat2d(1,0) = ucsMat(1,0);
ucsMat2d(1,1) = ucsMat(1,1);
ucsMat2d(1,2) = ucsMat(1,3);

while(keepPicking)
{
if(firstPick)
{
retCode = acedGetPoint(NULL, "\nPick first point: ", pick);
firstPick = Adesk::kFalse;
}
else
{
acdbPointSet(pick, lastpt);
retCode = acedGetPoint(pick, "\nPick another point - [ENTER] for no more: ", pick);
acedGrDraw(lastpt, pick, 1, 0);
}
if(retCode != RTNORM)
{
keepPicking = Adesk::kFalse;
break;
}

pkPt.x = pick[X];
pkPt.y = pick[Y];

AcGePoint2dArray arPts.append(pkPt);
}
acedRedraw(NULL, 1);
if(arPts.isEmpty())
{
acutPrintf("\nEmpty array.");
return;
}

if(arPts.length() < 2)
{
acutPrintf("\nArray only contains one point.");
return;
}

numPts = arPts.length();

pCurDb = acdbHostApplicationServices()->workingDatabase();
pCurDb->getBlockTable(pBlkTable, AcDb::kForRead);
pBlkTable->getAt(ACDB_MODEL_SPACE, pBlkTableRecord, AcDb::kForWrite);
pBlkTable->close();

pPolyEnt = new AcDbPolyline(numPts);
for(int idx = 0; idx < numPts; idx++)
{
pkPt = arPts.at(idx);
pkPt.transformBy(ucsMat2d);
pPolyEnt->addVertexAt(idx, pkPt);
}

pBlkTableRecord->appendAcDbEntity(polyId, pPolyEnt);
pBlkTableRecord->close();
pPolyEnt->close();
}


主要是pPolyEnt = new AcDbPolyline(numPts)前的部分
AcArray类模板不好理解
最好能帮助帮助注释一下
谢谢
您需要登录后才可以回帖 登录 | 注册

本版积分规则

小黑屋|手机版|CAD论坛|CAD教程|CAD下载|联系我们|关于明经|明经通道 ( 粤ICP备05003914号 )  
©2000-2023 明经通道 版权所有 本站代码,在未取得本站及作者授权的情况下,不得用于商业用途

GMT+8, 2024-11-26 06:54 , Processed in 0.146442 second(s), 23 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表