diff --git a/EXE_GdbCreateSurf.cpp b/EXE_GdbCreateSurf.cpp index d65f43a..e4b27ee 100644 --- a/EXE_GdbCreateSurf.cpp +++ b/EXE_GdbCreateSurf.cpp @@ -2125,7 +2125,6 @@ ExeCreateSurfBzByRegionExtrusion( int nParentId, const INTVECTOR& vCrvIds, const double dAndTolStdDeg = 15 ; // riordino le curve in modo che la prima sia quella esterna e tutte le altre dopo - POLYLINEVECTOR vPLOrd ; POLYLINEVECTOR vPL ; for ( int i = 0 ; i < int( vCrvP.size()) ; ++ i) { vPL.emplace_back() ; @@ -2135,7 +2134,7 @@ ExeCreateSurfBzByRegionExtrusion( int nParentId, const INTVECTOR& vCrvIds, const Vector3d vtN ; INTMATRIX vnPLIndMat ; BOOLVECTOR vbInvert ; - if ( ! CalcRegionPolyLines( vPL, vPLOrd, vtN, vnPLIndMat, vbInvert)) + if ( ! CalcRegionPolyLines( vPL, vtN, vnPLIndMat, vbInvert)) return nFirstId ; // creo una copia delle curve, orientate giuste @@ -2227,18 +2226,46 @@ ExeCreateSurfBzByScrewing( int nParentId, int nCrvId, // porto in locale punto e vettore asse Point3d ptAxL = GetPointLocal( pGeomDB, ptAx, nRefType, frLoc) ; Vector3d vtAxL = GetVectorLocal( pGeomDB, vtAx, nRefType, frLoc) ; + + // la curva che fa da sezione alla superficie è chiusa e piana ed è richiesto il capping verifico se la superficie è da invertire + // lo screwing non deve essere una semplice rivoluzione + bool bOrientedAsScrewing = false ; + Plane3d plPlane ; + double dArea = 0 ; + double dAngTolDeg = 15 ; + PolyLine pl ; CrvLoc->ApproxWithLines( dLinTol, dAngTolDeg, ICurve::APL_STD, pl) ; + if ( pl.IsClosedAndFlat( plPlane, dArea, dLinTol) && abs(abs(dAngRotDeg) - ANG_FULL) < EPS_SMALL && abs( dMove) < EPS_SMALL) { + double dOrthoMove = plPlane.GetVersN() * vtAx * dMove ; + // controllo che lo spostamento non sia perpendicolare alla normale della superficie + if ( abs(dOrthoMove) < EPS_SMALL ) + return GDB_ID_NULL ; + if( bCapEnds) { + if ( dOrthoMove > EPS_SMALL) + bOrientedAsScrewing = true ; + } + } + else + bCapEnds = false ; + // calcolo la superficie ISurfBezier* pSbz = ( bOk ? GetSurfBezierByScrewing( CrvLoc, ptAxL, vtAxL, dAngRotDeg, dMove, bCapEnds, dLinTol) : nullptr) ; + if( bOrientedAsScrewing && bCapEnds) + pSbz->Invert() ; // inserisco la superficie nel DB int nNewId = ( bOk ? pGeomDB->AddGeoObj( GDB_ID_NULL, nParentId, pSbz) : GDB_ID_NULL) ; // se richiesto creo anche i cap if ( bCapEnds && bOk) { - // la curva che fa da sezione alla superficie deve essere chiusa e piana - // lo screwing non deve essere una semplice rivoluzione - Plane3d plPlane ; - if ( CrvLoc->IsClosed() && CrvLoc->IsFlat( plPlane) && abs(abs(dAngRotDeg) - ANG_FULL) < EPS_SMALL && abs( dMove) < EPS_SMALL) { - } + ISurfBezier* pSbzBase1 = GetSurfBezierByFlatContour(CrvLoc,dLinTol) ; + if( bOrientedAsScrewing) + pSbzBase1->Invert() ; + bOk = bOk && pGeomDB->AddGeoObj( GDB_ID_NULL, nParentId, pSbzBase1) ; + ISurfBezier* pSbzBase2 = GetSurfBezierByFlatContour( CrvLoc,dLinTol) ; + pSbzBase2->Translate( vtAx * dMove) ; + pSbzBase2->Rotate(ptAx, vtAx, dAngRotDeg) ; + if( ! bOrientedAsScrewing) + pSbzBase1->Invert() ; + bOk = bOk && pGeomDB->AddGeoObj( GDB_ID_NULL, nParentId, pSbzBase1) ; } ExeSetModified() ; // se richiesto, salvo il comando Lua equivalente