double CalcMPtArea(const AcGePoint3dArray& PtArr) { double dblArea = 0.0; int nSize = PtArr.length(); if (nSize < 3) { return dblArea; } AcGePoint3d Pt1, Pt2, Pt3, Pt4;  t1 = PtArr[0];  t2 = PtArr[1];  t3 = PtArr[nSize - 1];  t4 = PtArr[nSize - 2]; dblArea = Pt1.y * (Pt3.x - Pt2.x) + Pt3.y * (Pt4.x - Pt1.x);  t3 = Pt1; for (int i = 1; i < nSize - 1; i++) {  t1 = PtArr;  t2 = PtArr[i + 1]; dblArea += Pt1.y * (Pt3.x - Pt2.x);  t3 = Pt1; } return fabs(dblArea / 2); } void ChangePLineArea() { AcDbObjectId m_objId; AcGePoint3dArray m_PtArr; double newArea,oldArea; ads_name ssName, ent; if (acedSSGet(":S", NULL, NULL, NULL, ssName) != RTNORM ) { return; } long lNum = 0; acedSSLength(ssName, &lNum); if (lNum != 1) { return; } acedSSName(ssName, 0, ent); acedSSFree(ssName); acdbGetObjectId(m_objId, ent); if (acedGetReal("Input the new area:", &newArea)!= RTNORM ) { return; } AcDbPolyline * pPolyline = NULL; if(acdbOpenObject(pPolyline,m_objId,AcDb::kForRead) != Acad::eOk) { return; } unsigned int pnums=pPolyline->numVerts(); for (unsigned int num = 0 ; num < pnums; num++) { AcGePoint3d pos; Acad :: ErrorStatus es = pPolyline->getPointAt(num,pos); if(es != Acad::eOk) { return; } m_PtArr.append(pos); } oldArea = CalcMPtArea(m_PtArr);//计算多边形面积 acutPrintf("\n已求得面积"); AcGePoint3d pickPoint; ads_point pt; if (acedGetPoint(NULL,"\nPick a point :",pt)!=RTNORM) { return; } pickPoint.x=pt[X]; pickPoint.y=pt[Y]; pickPoint.z=pt[Z]; double dScale=sqrt(newArea/oldArea); pPolyline->transformBy(AcGeMatrix3d::scaling(dScale,pickPoint)); pPolyline->close(); } 兄台,为啥运行到 pPolyline->transformBy(AcGeMatrix3d::scaling(dScale,pickPoint));就崩溃了?帮忙指点一下
|