From e58b19da455636e16928df74c99deaf699227c86 Mon Sep 17 00:00:00 2001 From: Dario Sassi Date: Thu, 26 Mar 2020 11:52:42 +0000 Subject: [PATCH] EgtGraphics 2.2c3 : - aggiunta gestione superfici di Bezier. --- EgtGraphics.rc | Bin 11604 -> 11604 bytes SceneGeom.cpp | 5 ++++- SceneSelect.cpp | 36 ++++++++++++++++++++++++++++++++++++ SceneSnap.cpp | 10 ++++++++++ 4 files changed, 50 insertions(+), 1 deletion(-) diff --git a/EgtGraphics.rc b/EgtGraphics.rc index 96529f784d1e038bacfb8c1c105ac0e922e4cb57..7ed2a58d97e65842de610ea2a6fa183de256a12a 100644 GIT binary patch delta 127 zcmcZ-btP)UH#Syd1|0_D%?J7RGfm>rnVhGn!ko-tJo%us?&d#|K8%~&xXqa1YP6Z* Xk}^UKEZD^VNH!tFahS=c?8XHE$f_mH delta 127 zcmcZ-btP)UH#Sy71|0^&%?J7RGfm>rnVhGn!koxpIQgKo?&d#|K8%~&xXqa1YP6Z* Xk}^UKEZD^VNH!tFahS=c?8XHEz=9>M diff --git a/SceneGeom.cpp b/SceneGeom.cpp index 0f9e8f1..e5c2fde 100644 --- a/SceneGeom.cpp +++ b/SceneGeom.cpp @@ -27,6 +27,7 @@ #include "/EgtDev/Include/EGkCurveComposite.h" #include "/EgtDev/Include/EGkSurfTriMesh.h" #include "/EgtDev/Include/EGkSurfFlatRegion.h" +#include "/EgtDev/Include/EGkSurfBezier.h" #include "/EgtDev/Include/EGkVolZmap.h" #include "/EgtDev/Include/EGkExtText.h" #include "/EgtDev/Include/EGkExtDimension.h" @@ -227,6 +228,7 @@ Scene::DrawGeoObj( const IGdbIterator& iIter, int nPass, const MdStMkCol& siObj) switch ( nGeoType) { case SRF_TRIMESH : pSTM = GetSurfTriMesh( pGeoObj) ; break ; case SRF_FLATRGN : pSTM = GetSurfFlatRegion( pGeoObj)->GetAuxSurf() ; break ; + case SRF_BEZIER : pSTM = GetSurfBezier( pGeoObj)->GetAuxSurf() ; break ; } if ( pSTM != nullptr && pSTM->GetTriangleCount() > N_MIN_TRIA_NEWWAY) bNewWay = true ; @@ -318,7 +320,7 @@ Scene::DrawGeoObj( const IGdbIterator& iIter, int nPass, const MdStMkCol& siObj) pCurve->GetThickness( dTh) && abs( dTh) > EPS_SMALL) { // segmenti di raccordo PNTVECTOR vPnt ; - bool bDense = ( nGeoType == CRV_ARC || nGeoType == CRV_BEZ) ; + bool bDense = ( nGeoType == CRV_ARC || nGeoType == CRV_BEZIER) ; if ( CalcConnectingLines( PL, dTh * vtExtr, bDense, vPnt)) pGraphics->AddLines( vPnt) ; // percorso traslato @@ -333,6 +335,7 @@ Scene::DrawGeoObj( const IGdbIterator& iIter, int nPass, const MdStMkCol& siObj) switch (nGeoType) { case SRF_TRIMESH : pSTM = GetSurfTriMesh( pGeoObj) ; break ; case SRF_FLATRGN : pSTM = GetSurfFlatRegion( pGeoObj)->GetAuxSurf() ; break ; + case SRF_BEZIER : pSTM = GetSurfBezier( pGeoObj)->GetAuxSurf() ; break ; } if ( pSTM == nullptr) return false ; diff --git a/SceneSelect.cpp b/SceneSelect.cpp index 5f3837c..ea4fef8 100644 --- a/SceneSelect.cpp +++ b/SceneSelect.cpp @@ -24,6 +24,7 @@ #include "/EgtDev/Include/EGkDistPointCurve.h" #include "/EgtDev/Include/EGkSurfTriMesh.h" #include "/EgtDev/Include/EGkSurfFlatRegion.h" +#include "/EgtDev/Include/EGkSurfBezier.h" #include "/EgtDev/Include/EGkExtText.h" #include "/EgtDev/Include/EGkExtDimension.h" #include "/EgtDev/Include/EGkIntersLinePlane.h" @@ -415,6 +416,41 @@ Scene::GetPointFromSelect( int nSelId, const Point3d& ptView, Point3d& ptSel, in } } } + // se superficie di Bezier + else if ( pGObj->GetType() == SRF_BEZIER) { + // recupero la superficie + const ISurfBezier* pSbz = GetSurfBezier( pGObj) ; + const ISurfTriMesh* pStm = pSbz->GetAuxSurf() ; + // il punto di riferimento deriva da XY su viewport e Z da selezione + Point3d ptWinZ( ptView.x, ptView.y, GetSelectedObjWinZ()) ; + // lo porto da spazio grafico a spazio geometrico globale + Point3d ptRef ; + UnProject( ptWinZ, ptRef) ; + // lo porto nel frame della superficie + ptRef.ToLoc( frEnt) ; + // recupero la direzione di mira e la porto nel riferimento della superficie + Vector3d vtDir = - m_vtDirCamera ; + vtDir.ToLoc( frEnt) ; + // recupero il raggio del box di ingombro + double dBlRad = 1000 ; + const ObjEGrGraphics* pGraphics = GetObjEGrGraphics( pStm) ; + if ( pGraphics != nullptr) { + BBox3d b3Loc ; + if ( pGraphics->GetLocalBBox( b3Loc)) + b3Loc.GetRadius( dBlRad) ; + } + // punto davanti all'oggetto lungo il raggio di mira + Point3d ptMir = ptRef - vtDir * 2 * dBlRad ; + double dLenMir = 4 * dBlRad ; + // cerco i triangoli intersecati dalla linea di mira + ILSIVECTOR vInfo ; + if ( ! IntersLineSurfTm( ptMir, vtDir, dLenMir, *pStm, vInfo) || vInfo.size() == 0) + return false ; + // recupero il primo punto + ptSel = vInfo[0].ptI ; + ptSel.ToGlob( frEnt) ; + nAux = 0 ; + } // se testo else if ( pGObj->GetType() == EXT_TEXT) { // recupero il testo diff --git a/SceneSnap.cpp b/SceneSnap.cpp index 4c32d84..2db9c02 100644 --- a/SceneSnap.cpp +++ b/SceneSnap.cpp @@ -25,6 +25,7 @@ #include "/EgtDev/Include/EGkDistPointCurve.h" #include "/EgtDev/Include/EGkSurfTriMesh.h" #include "/EgtDev/Include/EGkSurfFlatRegion.h" +#include "/EgtDev/Include/EGkSurfBezier.h" #include "/EgtDev/Include/EGkVolZmap.h" #include "/EgtDev/Include/EGkExtText.h" #include "/EgtDev/Include/EGkExtDimension.h" @@ -343,6 +344,15 @@ Scene::FindSelectedSnapPoint( int nSnap, const Point3d& ptWin, int nW, int nH) if ( FindSurfFRSnapPoint( nSnap, ptWin, nId, frEnt, pReg, dMinSqDist)) bFound = true ; } + // se superficie di Bezier + else if ( pGObj->GetType() == SRF_BEZIER) { + // recupero la superficie + const ISurfBezier* pSbz = GetSurfBezier( pGObj) ; + const ISurfTriMesh* pStm = pSbz->GetAuxSurf() ; + // verifico i punti notevoli della superficie ausiliaria associata + if ( FindSurfTMSnapPoint( nSnap, ptWin, nId, frEnt, pStm, dMinSqDist)) + bFound = true ; + } // se solido Zmap else if ( pGObj->GetType() == VOL_ZMAP) { // recupero il solido