www.mxdraw.com
内容索引主面
前一个向上下一个
McDbCircle 类
C++
class McDbCircle : public McDbCurve;

dbents.h

// 绘制一个圆心为100,100,0.0,半径为20的圆 McGePoint3d cnePt(100,100,0.0); double radius = 20.0; 

McDbCircle* pCircle = new McDbCircle(cnePt,McGeVector3d::kZAxis,radius); 

return AddToModelSpace(pCircle,pDatabase,true);

例如: 绘制圆环,或填充的圆点代码

            bool    GetArcBulge(McGePoint2d pt1,McGePoint2d pt2,McGePoint2d pt3,OUT double& dBulge)
            {
                try
                {
                    dBulge = 0.0;
                    if(pt1.isEqualTo(pt2) || pt1.isEqualTo(pt3) || pt2.isEqualTo(pt3) )
                    {
                        // 点相等,无法构成圆弧
                        return false;
                    }

                    McGeCircArc2d tmpArc(pt1,pt2,pt3 );
                    dBulge = tan(0.25 * (tmpArc.endAng() - tmpArc.startAng()) );
                    if(tmpArc.isClockWise())
                    {
                        dBulge = -dBulge;
                    }
                    return true;
                }
                catch (...)
                {
                    dBulge = 0.0;
                    return false;
                }
            }


            McDbObjectId DrawCircle(double dCenterX, double dCenterY, double dRadius,double dLineWidth)
            {
                if(MxDraw::IsZero(dLineWidth) || MxDraw::IsZero(dRadius) )
                {
                    McGePoint3d center(dCenterX,dCenterY,0.0);
                    McDbCircle* pCircle = new McDbCircle;
                    pCircle->setCenter(center);
                    pCircle->setRadius(dRadius);

                    MrxDbgUtils::addToCurrentSpaceAndClose(pCircle);
                    return pCircle->objectId();
                }
                else
                {
                    // 使用有宽度的PL线来代替。

                    McGePoint2d ptLeft(dCenterX - dRadius,dCenterY);
                    McGePoint2d ptRight(dCenterX + dRadius,dCenterY);

                    McGePoint2d ptTop(dCenterX,dCenterY + dRadius);
                    McGePoint2d ptBottom(dCenterX,dCenterY - dRadius);

                    double dBulge1 = 0.0;
                    double dBulge2 = 0.0;


                    GetArcBulge(ptLeft,ptTop,ptRight,dBulge1);
                    GetArcBulge(ptRight,ptBottom,ptLeft,dBulge2);

                    McDbPolyline* pPL = new McDbPolyline;
                    pPL->addVertexAt(ptLeft,dBulge1,dLineWidth,dLineWidth);
                    pPL->addVertexAt(ptRight,dBulge2,dLineWidth,dLineWidth);
                    pPL->setClosed(Mdesk::kTrue);

                    MrxDbgUtils::addToCurrentSpaceAndClose(pPL);
                    return pPL->objectId();
                }
            }
Copyright (c) 2010. All rights reserved.
你认为该帮助怎么样? 发送反馈信息!