From bc286fd2ed686d36ab59e65a5785dca11e3942e2 Mon Sep 17 00:00:00 2001 From: Dario Sassi Date: Fri, 26 Mar 2021 11:07:02 +0000 Subject: [PATCH] EgtExchange 2.3c3 : - in importBTL migliorata gestione tasche di mortase a coda di rondine (anche di testa). --- BtlGeom.h | 1 + BtlGeomCoStru.h | 1 + BtlGeomProc.cpp | 97 ++++++++++++++++++++++++++++++++++++++++++++---- EgtExchange.rc | Bin 11670 -> 11670 bytes 4 files changed, 91 insertions(+), 8 deletions(-) diff --git a/BtlGeom.h b/BtlGeom.h index 4b75c72..7c015a7 100644 --- a/BtlGeom.h +++ b/BtlGeom.h @@ -217,6 +217,7 @@ class BtlGeom bool DoSewing( ISurfTriMesh* pStm, const Polygon3d& Polyg) ; bool TrimSurfTmWithBox( ISurfTriMesh* pStm) ; bool TrimFlatCurveWithBox( ICurve* pCurve) ; + ICurve* TrimFlatCurveWithBoxEx( ICurve* pCurve) ; bool TrimSegmentWithBox( Point3d& ptP1, Point3d& ptP2, double dRad) ; ICurveComposite* CurveFromFces( const FCEDEQUE& dqFce, int nStartInd = 0) ; ICurve* GetDirectrixOfRuledSurf( const ISurfTriMesh* pStm, const Vector3d& vtExtr) ; diff --git a/BtlGeomCoStru.h b/BtlGeomCoStru.h index 7d4d46d..9b70f7d 100644 --- a/BtlGeomCoStru.h +++ b/BtlGeomCoStru.h @@ -97,6 +97,7 @@ const double DTMORT_EXTRA_LEN = 10.0 ; // minima e massima dimensione tasca per mortasa a coda di rondine const double MIN_DTMORT_POCKET = 30.0 ; const double MAX_DTMORT_POCKET = 200.0 ; +const double MIN_DTMORT_AREA = 100.0 ; // angolo di fianco per contorno libero default e non definito const double FC_SIDEANG_DEF = 0.0 ; const double FC_SIDEANG_NONE = 999.0 ; diff --git a/BtlGeomProc.cpp b/BtlGeomProc.cpp index 26c2718..843061b 100644 --- a/BtlGeomProc.cpp +++ b/BtlGeomProc.cpp @@ -4126,14 +4126,23 @@ BtlGeom::AddDovetailMortise( int nGroup, int nProc, int nSide, const string& sDe // inserisco eventuale curva della tasca nel DB geometrico int nPId = GDB_ID_NULL ; if ( ! IsNull( pCrvPock)) { - nPId = m_pGDB->AddGeoObj( GDB_ID_NULL, m_nProcsId, Release( pCrvPock)) ; - if ( nPId == GDB_ID_NULL) - return false ; + PtrOwner pNewPock( TrimFlatCurveWithBoxEx( Release( pCrvPock))) ; + Plane3d plPlane ; double dArea ; + if ( IsNull( pNewPock) || ! pNewPock->GetArea( plPlane, dArea) || dArea < MIN_DTMORT_AREA) { + nPock = 0 ; + } + else { + nPId = m_pGDB->AddGeoObj( GDB_ID_NULL, m_nProcsId, Release( pNewPock)) ; + if ( nPId == GDB_ID_NULL) + return false ; + } } // nome e info con tipo SetNameAndInfo( nId, nGroup, nProc, nSide, sDes, nProcId) ; // parametri - SetParams( nId, vnDPar, vdPar, vsUAtt) ; + DBLVECTOR vdMyPar = vdPar ; + vdMyPar[4] = nPock ; + SetParams( nId, vnDPar, vdMyPar, vsUAtt) ; // identificativi di geometrie ausiliarie SetAuxId( nId, {nMId, nPId}) ; @@ -4374,14 +4383,23 @@ BtlGeom::AddDtMortiseFront( int nGroup, int nProc, int nSide, const string& sDes // inserisco eventuale curva della tasca nel DB geometrico int nPId = GDB_ID_NULL ; if ( ! IsNull( pCrvPock)) { - nPId = m_pGDB->AddGeoObj( GDB_ID_NULL, m_nProcsId, Release( pCrvPock)) ; - if ( nPId == GDB_ID_NULL) - return false ; + PtrOwner pNewPock( TrimFlatCurveWithBoxEx( Release( pCrvPock))) ; + Plane3d plPlane ; double dArea ; + if ( IsNull( pNewPock) || ! pNewPock->GetArea( plPlane, dArea) || dArea < MIN_DTMORT_AREA) { + nPock = 0 ; + } + else { + nPId = m_pGDB->AddGeoObj( GDB_ID_NULL, m_nProcsId, Release( pNewPock)) ; + if ( nPId == GDB_ID_NULL) + return false ; + } } // nome e info con tipo SetNameAndInfo( nId, nGroup, nProc, nSide, sDes, nProcId) ; // parametri - SetParams( nId, vnDPar, vdPar, vsUAtt) ; + DBLVECTOR vdMyPar = vdPar ; + vdMyPar[4] = nPock ; + SetParams( nId, vnDPar, vdMyPar, vsUAtt) ; // identificativi di geometrie ausiliarie SetAuxId( nId, { nTId, nPId}) ; @@ -6840,6 +6858,69 @@ BtlGeom::TrimFlatCurveWithBox( ICurve* pCurve) return false ; } +//---------------------------------------------------------------------------- +ICurve* +BtlGeom::TrimFlatCurveWithBoxEx( ICurve* pCurve) +{ + // verifico esistenza curva + PtrOwner< ICurve> pMyCrv( pCurve) ; + if ( IsNull( pMyCrv)) + return nullptr ; + // determino il piano della curva + Plane3d plPlane ; + if ( ! pCurve->IsFlat( plPlane, false, 10 * EPS_SMALL)) + return nullptr ; + // determino la parte di piano (poligono) compresa nel box della trave + Polygon3d Polyg ; + if ( ! Polyg.FromPlaneTrimmedWithBox( plPlane, ORIG, ORIG + m_vtDim, true, true)) + return nullptr ; + // creo la regione corrispondente + PtrOwner pCrv( CreateCurveComposite()) ; + if ( IsNull( pCrv) || ! pCrv->FromPolyLine( Polyg.GetPolyLine())) + return nullptr ; + PtrOwner pSfr( CreateSurfFlatRegion()) ; + if ( IsNull( pSfr) || ! pSfr->AddExtLoop( Release( pCrv))) + return nullptr ; + // se curva aperta + if ( ! pMyCrv->IsClosed()) { + // calcolo la classificazione della curva rispetto alla regione + CRVCVECTOR ccClass ; + if ( ! pSfr->GetCurveClassification( *pMyCrv, ccClass)) + return nullptr ; + // determino gli intervalli di curva da conservare + Intervals inOk ; + for ( auto& ccOne : ccClass) { + if ( ccOne.nClass == CRVC_IN || + ccOne.nClass == CRVC_ON_P || ccOne.nClass == CRVC_ON_M) + inOk.Add( ccOne.dParS, ccOne.dParE) ; + } + // considero solo min-max degli intervalli + if ( inOk.GetCount() >= 1) { + // eseguo il taglio + double dParS, dParE ; + inOk.GetMinMax( dParS, dParE) ; + if ( ! pMyCrv->TrimStartEndAtParam( dParS, dParE)) + return nullptr ; + } + return Release( pMyCrv) ; + } + // altrimenti curva chiusa + else { + // creo la regione delimitata dalla curva chiusa + PtrOwner pSfrCrv( CreateSurfFlatRegion()) ; + if ( IsNull( pSfrCrv) || ! pSfrCrv->AddExtLoop( Release( pMyCrv))) + return nullptr ; + // eseguo l'intersezione tra le due regioni + if ( ! pSfrCrv->Intersect( *pSfr)) + return nullptr ; + // recupero il contorno esterno della nuova regione + PtrOwner pNewCrv( pSfrCrv->GetLoop( 0, 0)) ; + return Release( pNewCrv) ; + } + + return nullptr ; +} + //---------------------------------------------------------------------------- bool BtlGeom::TrimSegmentWithBox( Point3d& ptP1, Point3d& ptP2, double dRad) diff --git a/EgtExchange.rc b/EgtExchange.rc index fe529768dcfd7733dd3ac68942003d89149c13e9..ddd1756305aa391229b879d67c5e3fc021362703 100644 GIT binary patch delta 86 zcmbOhJuP~}FE&Qw&3E|@GELsYnFC~gl&oglyoB3=87yoFqCQGiGH&h=wt@&Dsoczh KrYJz!jSB#V(H`0W delta 86 zcmbOhJuP~}FE&P_&3E|@GELsYnFC~gl&oglyoB3=87yoFqCQGiGH&h=wt@&Dsoczh KrYJz!jSB#Ue;(2R