From d6cd16b86033340ef593e5783c02cb6902bd80c1 Mon Sep 17 00:00:00 2001 From: Daniele Bariletti Date: Wed, 17 Jul 2024 16:16:47 +0200 Subject: [PATCH] EgtExecutor : - cap come superfici separate per BezierByCurves. --- EXE_GdbCreateSurf.cpp | 73 ++++++++++++++++++++++++++----------------- 1 file changed, 45 insertions(+), 28 deletions(-) diff --git a/EXE_GdbCreateSurf.cpp b/EXE_GdbCreateSurf.cpp index 48efc98..420a4ae 100644 --- a/EXE_GdbCreateSurf.cpp +++ b/EXE_GdbCreateSurf.cpp @@ -2182,35 +2182,52 @@ ExeCreateSurfBzByRevolve( int nParentId, int nCrvId, Vector3d vtAxL = GetVectorLocal( pGeomDB, vtAx, nRefType, frLoc) ; // calcolo la superficie ISurfBezier* pSbz = ( bOk ? GetSurfBezierByRevolve( CrvLoc, ptAxL, vtAxL, bCapEnds, dLinTol) : nullptr) ; - //// finché non ho le SurfCompo creo qui i cap - //if ( bCapEnds) { - // // calcola la bbox della superficie - // BBox3d bbox3dSurf ; - // int nDegU, nDegV, nSpanU, nSpanV ; - // bool bTrim, bRat ; - // pSbz->GetInfo( nDegU, nDegV, nSpanU, nSpanV, bTrim, bRat) ; - // int nPointCount = ( nDegU * nSpanU + 1) * ( nDegV * nSpanV + 1) ; - // for ( int p = 0 ; p < nPointCount ; ++p) { - // bool bPointOk = true ; - // Point3d ptCtrl = pSbz->GetControlPoint( p, &bPointOk) ; - // bbox3dSurf.Add( ptCtrl) ; - // } - // // recupero i loop - // ICRVCOMPOPOVECTOR vCCLoop ; - // pSbz->GetLoops( vCCLoop, true) ; - // // devo distinguere tra il loop superiore e quello inferiore - // double dAngTolDeg = 5 ; - // PolyLine plEdge ; vCCLoop[0]->ApproxWithLines( dLinTol, dAngTolDeg, ICurve::APL_STD, plEdge) ; - // Plane3d plPlane ; double dArea ; - // bOk = bOk && ! plEdge.IsClosedAndFlat( plPlane, dArea, 50 * EPS_SMALL) ; - // Vector3d vtN = plPlane.GetVersN() ; - // // vedo come questa normale è orientata rispetto alla bbox della superficie - // Point3d ptCen ; vCCLoop[0]->GetCentroid( ptCen) ; - // double dDist = bbox3dSurf.DistFromPoint( ptCen) ; // questa mi dà anche valori negativi????? sennò è inutile + // finché non ho le SurfCompo creo qui i cap + if ( bCapEnds) { + // calcola la bbox della superficie + BBox3d bbox3dSurf ; + int nDegU, nDegV, nSpanU, nSpanV ; + bool bTrim, bRat ; + pSbz->GetInfo( nDegU, nDegV, nSpanU, nSpanV, bTrim, bRat) ; + int nPointCount = ( nDegU * nSpanU + 1) * ( nDegV * nSpanV + 1) ; + for ( int p = 0 ; p < nPointCount ; ++p) { + bool bPointOk = true ; + Point3d ptCtrl = pSbz->GetControlPoint( p, &bPointOk) ; + bbox3dSurf.Add( ptCtrl) ; + } + // recupero i loop + ICRVCOMPOPOVECTOR vCCLoop ; + pSbz->GetLoops( vCCLoop, true) ; + // il getLoops per superfici non trimmate restituisce 1 elemento per ogni lato dello spazio parametrico. + // in questo caso la superficie è chiusa lungo il parametro V, quindi i lati 0 e 2 saranno null. + double dAngTolDeg = 5 ; + PolyLine plEdge1 ; vCCLoop[1]->ApproxWithLines( dLinTol, dAngTolDeg, ICurve::APL_STD, plEdge1) ; + PolyLine plEdge3 ; vCCLoop[3]->ApproxWithLines( dLinTol, dAngTolDeg, ICurve::APL_STD, plEdge3) ; + plEdge3.Invert() ; - // PtrOwner pSrfBzTop( CreateSurfBezier()) ; - // pSrfBzTop->CreateByFlatContour( ) - //} + //// devo distinguere tra il loop superiore e quello inferiore + //PolyLine plEdge0 ; vCCLoop[0]->ApproxWithLines( dLinTol, dAngTolDeg, ICurve::APL_STD, plEdge0) ; + //Plane3d plPlane ; double dArea ; + //bOk = bOk && ! plEdge0.IsClosedAndFlat( plPlane, dArea, 50 * EPS_SMALL) ; + //Vector3d vtN = plPlane.GetVersN() ; + //// vedo come questa normale è orientata rispetto alla bbox della superficie + //Point3d ptCen ; vCCLoop[0]->GetCentroid( ptCen) ; + //ptCen += vtN ; + //PolyLine plEdge1 ; vCCLoop[1]->ApproxWithLines( dLinTol, dAngTolDeg, ICurve::APL_STD, plEdge1) ; + //// inverto uno dei due bordi + //if ( bbox3dSurf.Encloses( ptCen)) + // plEdge0.Invert() ; + //else + // plEdge1.Invert() ; + + // creo le superfici e le inserisco nel DB + PtrOwner pSrfBzCap1( CreateSurfBezier()) ; + pSrfBzCap1->CreateByFlatContour( plEdge1) ; + pGeomDB->AddGeoObj( GDB_ID_NULL, nParentId, Release( pSrfBzCap1)) ; + PtrOwner pSrfBzCap3( CreateSurfBezier()) ; + pSrfBzCap3->CreateByFlatContour( plEdge3) ; + pGeomDB->AddGeoObj( GDB_ID_NULL, nParentId, Release( pSrfBzCap3)) ; + } // inserisco la superficie nel DB int nNewId = ( bOk ? pGeomDB->AddGeoObj( GDB_ID_NULL, nParentId, pSbz) : GDB_ID_NULL) ;