- // LINE
- AcGeLineSeg3d * AcDbCurveToAcGeCurve(const AcDbLine * pLine)
- {
- return new AcGeLineSeg3d(pLine->startPoint(), pLine->endPoint());
- }
- AcDbLine * AcGeCurveToAcDbCurve(const AcGeLineSeg3d * pGe)
- {
- return new AcDbLine(pGe->startPoint(),pGe->endPoint());
- }
- // ARC
- AcGeCircArc3d * AcDbCurveToAcGeCurve(const AcDbArc * pDbArc)
- {
- return new AcGeCircArc3d(
- pDbArc->center(),
- pDbArc->normal(),
- pDbArc->normal().perpVector(),
- pDbArc->radius(),
- pDbArc->startAngle(),
- pDbArc->endAngle());
- }
- AcDbCurve * AcGeCurveToAcDbCurve(const AcGeCircArc3d * pGe)
- {
- if (pGe->isClosed() == Adesk::kTrue)
- {
- return new AcDbCircle(
- pGe->center(),
- pGe->normal(),
- pGe->radius());
- }
- else
- {
- return new AcDbArc(
- pGe->center(),
- pGe->normal(),
- pGe->radius(),
- pGe->startAng(),
- pGe->endAng());
- }
- }
- // CIRCLE
- AcGeCircArc3d * AcDbCurveToAcGeCurve(const AcDbCircle * pDbCircle)
- {
- return new AcGeCircArc3d(pDbCircle->center(),pDbCircle->normal(),pDbCircle->radius());
- }
- // ELLIPSE
- AcGeEllipArc3d * AcDbCurveToAcGeCurve(const AcDbEllipse * pDbEllise)
- {
- return new AcGeEllipArc3d(
- pDbEllise->center(),
- pDbEllise->majorAxis(),
- pDbEllise->minorAxis(),
- pDbEllise->majorAxis().length(),
- pDbEllise->minorAxis().length(),
- pDbEllise->startAngle(),
- pDbEllise->endAngle());
- }
- AcDbEllipse * AcGeCurveToAcDbCurve(const AcGeEllipArc3d * pGe)
- {
- return new AcDbEllipse(
- pGe->center(),
- pGe->normal(),
- pGe->majorAxis()*pGe->majorRadius(),
- pGe->minorRadius()/pGe->majorRadius(),
- pGe->startAng(),
- pGe->endAng());
- }
- // SPLINE
- AcGeNurbCurve3d * AcDbCurveToAcGeCurve(const AcDbSpline * pSpline)
- {
- Acad::ErrorStatus es = Acad::eOk;
- AcGePoint3dArray fitPoints;
- int degree;
- double fitTolerance;
- Adesk::Boolean tangentsExist;
- Adesk::Boolean tangentStartDef;
- Adesk::Boolean tangentEndDef;
- AcGeVector3d startTangent;
- AcGeVector3d endTangent;
- Adesk::Boolean rational;
- Adesk::Boolean closed;
- Adesk::Boolean periodic;
- AcGePoint3dArray controlPoints;
- AcGeDoubleArray knots;
- AcGeDoubleArray weights;
- double controlPtTol;
- double knotTol;
- closed = pSpline->isClosed();
- AcGeNurbCurve3d *curv = NULL;
- if (0)//(pSpline->hasFitData())
- {
- AcGeTol tol;
- if ((es = pSpline->getFitData(fitPoints,degree,fitTolerance,tangentsExist,startTangent,endTangent)) == Acad::eOk)
- {
- tangentStartDef = tangentsExist; //&& (startTangent != AcGeVector3d::kIdentity);
- tangentEndDef = tangentsExist; //&& (endTangent != AcGeVector3d::kIdentity);
- AcGeTol fitTol;
- pSpline->fitTolerance();
- fitTol.setEqualPoint(fitTolerance);
- curv = new AcGeNurbCurve3d(fitPoints,startTangent,endTangent,tangentStartDef,tangentEndDef,fitTol);
- if (closed == Adesk::kTrue)
- {
- curv->makeClosed();
- }
- }
- }
- else
- {
- if ((es = pSpline->getNurbsData(degree,rational,closed,periodic,controlPoints,knots,weights,controlPtTol,knotTol)) == Acad::eOk)
- {
- if (rational==Adesk::kTrue)
- {
- curv = new AcGeNurbCurve3d(degree,knots,controlPoints,weights,periodic);
- }
- else
- {
- curv = new AcGeNurbCurve3d(degree,knots,controlPoints,periodic);
- }