diff --git a/OffsetCurve3d.cpp b/OffsetCurve3d.cpp index 678ac65..54f78da 100644 --- a/OffsetCurve3d.cpp +++ b/OffsetCurve3d.cpp @@ -156,10 +156,14 @@ OffsetCurve3d::Make( const PNT5AXVECTOR& vPnt5Ax, double dOffDist, int nType) Vector3d vtDirPrevOff = V_INVALID ; for ( int i = 1 ; i <= pCrv->GetCurveCount() ; ++i) { pCrvCurr = pCrv->GetNextCurve() ; - if ( pCrvCurr == nullptr && bClosed && vFlag[i] == OffsetCurve3d::AngType::ANG_CVEX) + if ( pCrvCurr == nullptr && bClosed) pCrvCurr = pCrv->GetFirstCurve() ; Vector3d vtOffDir = vOffDir[i] ; - Vector3d vtDirCurr ; pCrvCurr->GetStartDir( vtDirCurr) ; + Vector3d vtDirCurr ; + if ( pCrvCurr != nullptr) + pCrvCurr->GetStartDir( vtDirCurr) ; + else + vtDirCurr = vtDirPrev ; pCrvPrev->GetStartDir( vtDirPrev) ; Vector3d vtTang ; if ( vFlag[i] != OffsetCurve3d::AngType::ANG_CVEX) @@ -176,7 +180,11 @@ OffsetCurve3d::Make( const PNT5AXVECTOR& vPnt5Ax, double dOffDist, int nType) dCorrK = 1 / sin( 90 - dHalfAlfa) ; } - Point3d ptP ; pCrvCurr->GetStartPoint( ptP) ; + Point3d ptP ; + if ( pCrvCurr != nullptr) + pCrvCurr->GetStartPoint( ptP) ; + else + pCrvPrev->GetEndPoint( ptP) ; dRadCorr = dOffDist ; ptP = ptP + dRadCorr * dCorrK * vtCorr ; // se secondo punto di angolo esterno di fianco, inserisco movimenti intermedi