From 48df8ea18c21c7f8b1719f58257ef81ce0b95d3f Mon Sep 17 00:00:00 2001 From: Dario Sassi Date: Mon, 2 Feb 2015 16:13:56 +0000 Subject: [PATCH] EgtGeomKernel 1.6b2 : - aggiunta funzione di inerti poliarco - roportate in executor migliorie su costruzione superfici trimesh. --- EgtGeomKernel.rc | Bin 11710 -> 11710 bytes GdbExecutor.cpp | 200 ++++++++++++++--------------------------------- GdbExecutor.h | 2 - PolyArc.cpp | 28 +++++++ PolyLine.cpp | 2 +- 5 files changed, 86 insertions(+), 146 deletions(-) diff --git a/EgtGeomKernel.rc b/EgtGeomKernel.rc index b6410ac66ecb835a187f86279ae0f86be81d052f..15e1d957fb6536572284a565a1c77c49f24c7b6e 100644 GIT binary patch delta 94 zcmdlNy)SyhFE&P_&A-_cnHh~HD{|{@_Trkr0u;H;XNwSVW8B;$>;>dw2zN+>g;Df- LFmBFL4&ed-Vf-5U delta 94 zcmdlNy)SyhFE&QQ&A-_cnHdcyD{|{@_Trkr0u;H;XNwSVW8B;$>;>dw2zN+>g;Df- LFmBFL4&ed-U|t&X diff --git a/GdbExecutor.cpp b/GdbExecutor.cpp index 09192eb..984ca5f 100644 --- a/GdbExecutor.cpp +++ b/GdbExecutor.cpp @@ -38,7 +38,9 @@ #include "/EgtDev/Include/EGkCurveByInterp.h" #include "/EgtDev/Include/EgkSurfTriMesh.h" #include "/EgtDev/Include/EgkExtText.h" +#include "/EgtDev/Include/EGkStmFromCurves.h" #include "/EgtDev/Include/EGkStmFromTriangleSoup.h" +#include "/EgtDev/Include/EGkCurveLocal.h" #include "/EgtDev/Include/EgnStringConverter.h" #include "/EgtDev/Include/EgnCmdParser.h" #include "/EgtDev/Include/EgtPointerOwner.h" @@ -1830,8 +1832,11 @@ GdbExecutor::CurveCompoFromCurveApproximation( const STRVECTOR& vsParams) Frame3d frDest ; if ( ! m_pGDB->GetGroupGlobFrame( GetIdParam( vsParams[1]), frDest)) return false ; - // recupero Id della curva sorgente + // recupero la curva in locale int nSouId = GetIdParam( vsParams[2]) ; + CurveLocal CrvLoc( m_pGDB, nSouId, frDest) ; + if ( CrvLoc.Get() == nullptr) + return false ; // recupero il tipo di approssimazione string sType = vsParams[3] ; ToUpper( sType) ; @@ -1850,13 +1855,13 @@ GdbExecutor::CurveCompoFromCurveApproximation( const STRVECTOR& vsParams) return false ; if ( nType == 1) { // con linee PolyLine PL ; - if ( ! GetPolyLineFromCurve( nSouId,frDest, dLinTol, PL) || + if ( ! CrvLoc.Get()->ApproxWithLines( dLinTol, ANG_TOL_STD_DEG, PL) || ! pCC->FromPolyLine( PL)) return false ; } else { // con bi-archi PolyArc PA ; - if ( ! GetPolyArcFromCurve( nSouId,frDest, dLinTol, PA) || + if ( ! CrvLoc.Get()->ApproxWithArcs( dLinTol, ANG_TOL_STD_DEG, PA) || ! pCC->FromPolyArc( PA)) return false ; } @@ -2321,29 +2326,25 @@ GdbExecutor::SurfTriMeshByContour( const STRVECTOR& vsParams) // 3 o 4 parametri : Id, ParentId, IdCurve[, dLinTol] if ( vsParams.size() != 3 && vsParams.size() != 4) return false ; - // recupero la tolleranza lineare - double dLinTol = LIN_TOL_STD ; - if ( vsParams.size() == 4) - FromString( vsParams[3], dLinTol) ; - // recupero l'identificativo della curva - int nIdCrv = GetIdParam( vsParams[2]) ; // recupero il riferimento del gruppo destinazione Frame3d frDest ; if ( ! m_pGDB->GetGroupGlobFrame( GetIdParam( vsParams[1]), frDest)) return false ; - // calcolo la polilinea che approssima la curva - PolyLine PL ; - if ( ! GetPolyLineFromCurve( nIdCrv, frDest, dLinTol, PL)) + // recupero la curva in locale + int nCrvId = GetIdParam( vsParams[2]) ; + CurveLocal CrvLoc( m_pGDB, nCrvId, frDest) ; + if ( CrvLoc.Get() == nullptr) return false ; - // creo la superficie - PtrOwner pSTM( CreateSurfTriMesh()) ; - if ( IsNull( pSTM)) - return false ; - // costruisco la triangolazione - if ( ! pSTM->CreateByFlatContour( PL)) + // recupero la tolleranza lineare + double dLinTol = LIN_TOL_STD ; + if ( vsParams.size() == 4) + FromString( vsParams[3], dLinTol) ; + // calcolo la superficie + ISurfTriMesh* pSTM = GetSurfTriMeshByContour( *CrvLoc.Get(), dLinTol) ; + if ( pSTM == nullptr) return false ; // inserisco la superficie trimesh nel DB - return AddGeoObj( vsParams[0], vsParams[1], Release( pSTM)) ; + return AddGeoObj( vsParams[0], vsParams[1], pSTM) ; } //---------------------------------------------------------------------------- @@ -2353,33 +2354,29 @@ GdbExecutor::SurfTriMeshByExtrusion( const STRVECTOR& vsParams) // 4 o 5 parametri : Id, ParentId, IdCurve, vtExtr[, dLinTol] if ( vsParams.size() != 4 && vsParams.size() != 5) return false ; - // recupero la tolleranza lineare - double dLinTol = LIN_TOL_STD ; - if ( vsParams.size() == 5) - FromString( vsParams[4], dLinTol) ; - // recupero la curva - int nIdCrv = GetIdParam( vsParams[2]) ; // recupero il riferimento del gruppo destinazione Frame3d frDest ; if ( ! m_pGDB->GetGroupGlobFrame( GetIdParam( vsParams[1]), frDest)) return false ; - // calcolo la polilinea che approssima la curva - PolyLine PL ; - if ( ! GetPolyLineFromCurve( nIdCrv, frDest, dLinTol, PL)) + // recupero la curva in locale + int nCrvId = GetIdParam( vsParams[2]) ; + CurveLocal CrvLoc( m_pGDB, nCrvId, frDest) ; + if ( CrvLoc.Get() == nullptr) return false ; - // recupero il vettore di estrusione + // recupero il vettore di estrusione (già in locale) Vector3d vtExtr ; if ( ! GetVectorParam( vsParams[3], frDest, vtExtr)) return false ; - // creo la superficie - PtrOwner pSTM( CreateSurfTriMesh()) ; - if ( IsNull( pSTM)) - return false ; - // costruisco l'estrusione - if ( ! pSTM->CreateByExtrusion( PL, vtExtr)) + // recupero la tolleranza lineare + double dLinTol = LIN_TOL_STD ; + if ( vsParams.size() == 5) + FromString( vsParams[4], dLinTol) ; + // calcolo la superficie + ISurfTriMesh* pSTM = GetSurfTriMeshByExtrusion( *CrvLoc.Get(), vtExtr, false, dLinTol) ; + if ( pSTM == nullptr) return false ; // inserisco la superficie trimesh nel DB - return AddGeoObj( vsParams[0], vsParams[1], Release( pSTM)) ; + return AddGeoObj( vsParams[0], vsParams[1], pSTM) ; } //---------------------------------------------------------------------------- @@ -2389,35 +2386,30 @@ GdbExecutor::SurfTriMeshByTwoPaths( const STRVECTOR& vsParams) // 4 o 5 parametri : Id, ParentId, IdCurve1, IdCurve2[, dLinTol] if ( vsParams.size() != 4 && vsParams.size() != 5) return false ; - // recupero la tolleranza lineare - double dLinTol = LIN_TOL_STD ; - if ( vsParams.size() == 5) - FromString( vsParams[4], dLinTol) ; // recupero il riferimento del gruppo destinazione Frame3d frDest ; if ( ! m_pGDB->GetGroupGlobFrame( GetIdParam( vsParams[1]), frDest)) return false ; - // recupero l'identificativo della prima curva - int nIdCrv1 = GetIdParam( vsParams[2]) ; - // calcolo la polilinea che approssima la prima curva - PolyLine PL1 ; - if ( ! GetPolyLineFromCurve( nIdCrv1, frDest, dLinTol, PL1)) + // recupero la prima curva in locale + int nCrvId1 = GetIdParam( vsParams[2]) ; + CurveLocal CrvLoc1( m_pGDB, nCrvId1, frDest) ; + if ( CrvLoc1.Get() == nullptr) return false ; - // recupero l'identificativo della seconda curva - int nIdCrv2 = GetIdParam( vsParams[3]) ; - // calcolo la polilinea che approssima la seconda curva - PolyLine PL2 ; - if ( ! GetPolyLineFromCurve( nIdCrv2, frDest, dLinTol, PL2)) + // recupero la seconda curva in locale + int nCrvId2 = GetIdParam( vsParams[3]) ; + CurveLocal CrvLoc2( m_pGDB, nCrvId2, frDest) ; + if ( CrvLoc2.Get() == nullptr) return false ; - // creo la superficie - PtrOwner pSTM( CreateSurfTriMesh()) ; - if ( IsNull( pSTM)) - return false ; - // costruisco la rigata tra le due curve - if ( ! pSTM->CreateByTwoCurves( PL1, PL2)) + // recupero la tolleranza lineare + double dLinTol = LIN_TOL_STD ; + if ( vsParams.size() == 5) + FromString( vsParams[4], dLinTol) ; + // calcolo la superficie + ISurfTriMesh* pSTM = GetSurfTriMeshRuled( *CrvLoc1.Get(), *CrvLoc2.Get(), dLinTol) ; + if ( pSTM == nullptr) return false ; // inserisco la superficie trimesh nel DB - return AddGeoObj( vsParams[0], vsParams[1], Release( pSTM)) ; + return AddGeoObj( vsParams[0], vsParams[1], pSTM) ; } //---------------------------------------------------------------------------- @@ -2449,15 +2441,14 @@ GdbExecutor::SurfTriMeshByScrewing( bool bMove, const STRVECTOR& vsParams) FromString( vsParams[6], dLinTol) ; // non c'é movimento lungo l'asse } - // recupero l'identificativo della curva - int nIdCrv = GetIdParam( vsParams[2]) ; // recupero il riferimento del gruppo destinazione Frame3d frDest ; if ( ! m_pGDB->GetGroupGlobFrame( GetIdParam( vsParams[1]), frDest)) return false ; - // calcolo la polilinea che approssima la curva - PolyLine PL ; - if ( ! GetPolyLineFromCurve( nIdCrv, frDest, dLinTol, PL)) + // recupero la curva in locale + int nCrvId = GetIdParam( vsParams[2]) ; + CurveLocal CrvLoc( m_pGDB, nCrvId, frDest) ; + if ( CrvLoc.Get() == nullptr) return false ; // recupero il punto dell'asse di rivoluzione Point3d ptAx ; @@ -2471,89 +2462,12 @@ GdbExecutor::SurfTriMeshByScrewing( bool bMove, const STRVECTOR& vsParams) double dAngRotDeg ; if ( ! FromString( vsParams[5], dAngRotDeg)) return false ; - // calcolo lo step di rotazione - double dMaxRad = 0 ; - PL.GetMaxDistanceFromLine( dMaxRad, ptAx, vtAx, 1, false) ; - if ( dMaxRad < EPS_SMALL) - return false ; - double dStepRotDeg = sqrt( 8 * dLinTol / dMaxRad) * RADTODEG ; - // creo la superficie - PtrOwner pSTM( CreateSurfTriMesh()) ; - if ( IsNull( pSTM)) - return false ; - // costruisco la rivoluzione - if ( ! pSTM->CreateByScrewing( PL, ptAx, vtAx, dAngRotDeg, dStepRotDeg, dMove)) + // calcolo la superficie + ISurfTriMesh* pSTM = GetSurfTriMeshByScrewing( *CrvLoc.Get(), ptAx, vtAx, dAngRotDeg, dMove, dLinTol) ; + if ( pSTM == nullptr) return false ; // inserisco la superficie trimesh nel DB - return AddGeoObj( vsParams[0], vsParams[1], Release( pSTM)) ; -} - -//---------------------------------------------------------------------------- -bool -GdbExecutor::GetPolyLineFromCurve( int nId, const Frame3d& frDest, double dLinTol, PolyLine& PL) -{ - // recupero la curva - const ICurve* pCrv = GetCurve( m_pGDB->GetGeoObj( nId)) ; - if ( pCrv == nullptr) - return false ; - // recupero il riferimento della curva - Frame3d frCrv ; - if ( ! m_pGDB->GetGlobFrame( nId, frCrv)) - return false ; - // calcolo la polilinea che approssima la curva - // se i riferimenti sono uguali - if ( AreSameFrame( frCrv, frDest)) { - // ricavo l'approssimazione - if ( ! pCrv->ApproxWithLines( dLinTol, ANG_TOL_STD_DEG, PL)) - return false ; - } - // altrimenti devo prima trasformare la curva - else { - // creo una copia della curva (da buttare alla fine) - PtrOwner pModCrv( pCrv->Clone()) ; - if ( IsNull( pModCrv)) - return false ; - // eseguo la trasformazione - pModCrv->LocToLoc( frCrv, frDest) ; - // ricavo l'approssimazione - if ( ! pModCrv->ApproxWithLines( dLinTol, ANG_TOL_STD_DEG, PL)) - return false ; - } - return true ; -} - -//---------------------------------------------------------------------------- -bool -GdbExecutor::GetPolyArcFromCurve( int nId, const Frame3d& frDest, double dLinTol, PolyArc& PA) -{ - // recupero la curva - const ICurve* pCrv = GetCurve( m_pGDB->GetGeoObj( nId)) ; - if ( pCrv == nullptr) - return false ; - // recupero il riferimento della curva - Frame3d frCrv ; - if ( ! m_pGDB->GetGlobFrame( nId, frCrv)) - return false ; - // calcolo la polilinea che approssima la curva - // se i riferimenti sono uguali - if ( AreSameFrame( frCrv, frDest)) { - // ricavo l'approssimazione - if ( ! pCrv->ApproxWithArcs( dLinTol, ANG_TOL_STD_DEG, PA)) - return false ; - } - // altrimenti devo prima trasformare la curva - else { - // creo una copia della curva (da buttare alla fine) - PtrOwner pModCrv( pCrv->Clone()) ; - if ( IsNull( pModCrv)) - return false ; - // eseguo la trasformazione - pModCrv->LocToLoc( frCrv, frDest) ; - // ricavo l'approssimazione - if ( ! pModCrv->ApproxWithArcs( dLinTol, ANG_TOL_STD_DEG, PA)) - return false ; - } - return true ; + return AddGeoObj( vsParams[0], vsParams[1], pSTM) ; } //---------------------------------------------------------------------------- diff --git a/GdbExecutor.h b/GdbExecutor.h index eecec23..046cb46 100644 --- a/GdbExecutor.h +++ b/GdbExecutor.h @@ -52,8 +52,6 @@ class GdbExecutor : public IGdbExecutor bool GetColorParam( const std::string& sParam, bool& bByParent, Color& cCol) ; bool GetMaterialParam( const std::string& sParam, bool& bByParent, int& nMat) ; bool GetStringParam( const std::string& sParam, std::string& sString) ; - bool GetPolyLineFromCurve( int nId, const Frame3d& frDest, double dLinTol, PolyLine& PL) ; - bool GetPolyArcFromCurve( int nId, const Frame3d& frDest, double dLinTol, PolyArc& PA) ; bool ExecuteGroup( const std::string& sCmd2, const STRVECTOR& vsParams) ; bool ExecutePoint( const std::string& sCmd2, const STRVECTOR& vsParams) ; bool ExecuteVector( const std::string& sCmd2, const STRVECTOR& vsParams) ; diff --git a/PolyArc.cpp b/PolyArc.cpp index 5ac6766..b9f6428 100644 --- a/PolyArc.cpp +++ b/PolyArc.cpp @@ -475,3 +475,31 @@ PolyArc::IsFlat( int& nRank, Point3d& ptCen, Vector3d& vtDir, double dToler) con return ( nRank == 0 || nRank == 2) ; } + +//---------------------------------------------------------------------------- +bool +PolyArc::Invert( bool bInvertU) +{ + // verifico non sia vuota + if ( m_lUPointBs.empty()) + return true ; + // inverto la lista + m_lUPointBs.reverse() ; + // sposto il bulge all'estremo iniziale di ogni tratto (l'ultimo non conta) + for ( UPNTBLIST::iterator iter = m_lUPointBs.begin() ; iter != m_lUPointBs.end() ; ++ iter) { + if ( next( iter) != m_lUPointBs.end()) + iter->dB = next( iter)->dB ; + else + iter->dB = 0 ; + } + // se richiesto, inverto anche il parametro U + if ( bInvertU) { + // recupero il primo valore di U che è il vecchio finale ed è il riferimento di inversione + double dUfin = m_lUPointBs.front().dU ; + // ciclo su tutti gli elementi + for ( UPNTBLIST::iterator iter = m_lUPointBs.begin() ; iter != m_lUPointBs.end() ; ++ iter) { + iter->dU = dUfin - iter->dU ; + } + } + return true ; +} \ No newline at end of file diff --git a/PolyLine.cpp b/PolyLine.cpp index d329322..727bdea 100644 --- a/PolyLine.cpp +++ b/PolyLine.cpp @@ -676,4 +676,4 @@ PolyLine::Invert( bool bInvertU) } } return true ; -} \ No newline at end of file +}