> KonstantinM
Функция, которая замыкает уже существующий сплайн. Замыкает аналогично тому, как это делает команда _SPLINEDIT _Close.
Если убрать проверку pSpline->hasFitData() - IMHO будет замыкать прямым участком.
static Acad::ErrorStatus [b]MakeSplineClosed[/b](AcDbSpline *pSpline)
{
Acad::ErrorStatus es = Acad::eOk, esOpen = 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;
AcGeNurbCurve3d *curv = NULL;
if (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; fitTol.setEqualPoint(fitTolerance);
curv = new AcGeNurbCurve3d(fitPoints,startTangent,endTangent,tangentStartDef,tangentEndDef,fitTol);
curv->makeClosed();
curv->getFitData(fitPoints,fitTol,tangentsExist,startTangent,endTangent);
if ((esOpen = pSpline->upgradeOpen()) == Acad::eOk || (esOpen == Acad::eWasOpenForWrite)) {
es = pSpline->setFitData(fitPoints,degree,fitTol.equalPoint(),startTangent,endTangent);
if (esOpen != Acad::eWasOpenForWrite) pSpline->downgradeOpen();
}
delete curv;
}
} else {
if ((es = pSpline->getNurbsData(degree,rational,closed,periodic,controlPoints,knots,weights,controlPtTol,knotTol)) == Acad::eOk) {
if ((esOpen = pSpline->upgradeOpen()) == Acad::eOk || (esOpen == Acad::eWasOpenForWrite)) {
es = pSpline->setNurbsData(degree,rational,Adesk::kTrue,periodic,controlPoints,knots,weights,controlPtTol,knotTol);
if (esOpen != Acad::eWasOpenForWrite) pSpline->downgradeOpen();
}
}
}
return es;
}