Acad::ErrorStatus TrimPolyline(AcDbPolyline *&pPline, AAcGePoint3d ptBefore, AcGePoint3d ptAfter) { AcGeDoubleArray params; AcDbVoidPtrArray polylineSegments; double dStartParam, dEndParam, dParam1, dParam2; pPline->getStartParam(dStartParam); pPline->getEndParam(dEndParam); if (pPline->getParamAtPoint(ptBefore, dParam1) == Acad::eOk && pPline->getParamAtPoint(ptAfter, dParam2) == Acad::eOk) { if (dParam1 < dParam2) { params.append(dParam1); params.append(dParam2); } else { params.append(dParam2); params.append(dParam1); } if (pPline->getSplitCurves(params, polylineSegments) == Acad::eOk) { switch (polylineSegments.length()) { case 3: pPline = (AcDbPolyline*)polylineSegments.at(1); break; case 2: if (params.at(0) == dStartParam) { pPline = (AcDbPolyline*)polylineSegments.at(0); } else { pPline = (AcDbPolyline*)polylineSegments.at(1); } break; case 1: break; } return Acad::eOk; } } return Acad::eInvalidInput; } |