EgtGraphics 1.9f1 :
- migliorata gestione punti notevoli con Trimesh e con Region - in selezione con Region si setta chunk toccato come Aux.
This commit is contained in:
Binary file not shown.
+44
-1
@@ -23,7 +23,9 @@
|
||||
#include "/EgtDev/Include/EGkCurve.h"
|
||||
#include "/EgtDev/Include/EGkDistPointCurve.h"
|
||||
#include "/EgtDev/Include/EGkSurfTriMesh.h"
|
||||
#include "/EgtDev/Include/EGkSurfFlatRegion.h"
|
||||
#include "/EgtDev/Include/EGkExtText.h"
|
||||
#include "/EgtDev/Include/EGkIntersLinePlane.h"
|
||||
#include "/EgtDev/Include/EGkIntersLineSurfTm.h"
|
||||
#include "/EgtDev/Include/EGkGdbConst.h"
|
||||
#include "/EgtDev/Include/EGkGeomDB.h"
|
||||
@@ -346,7 +348,7 @@ Scene::GetPointFromSelect( int nSelId, const Point3d& ptView, Point3d& ptSel, in
|
||||
// lo porto da spazio grafico a spazio geometrico globale
|
||||
Point3d ptRef ;
|
||||
UnProject( ptWinZ, ptRef) ;
|
||||
// lo porto nel frame della curva
|
||||
// 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 ;
|
||||
@@ -371,6 +373,47 @@ Scene::GetPointFromSelect( int nSelId, const Point3d& ptView, Point3d& ptSel, in
|
||||
ptSel.ToGlob( frEnt) ;
|
||||
nAux = vInfo[0].nT ;
|
||||
}
|
||||
// se regione
|
||||
else if ( pGObj->GetType() == SRF_FLATRGN) {
|
||||
// recupero la regione
|
||||
const ISurfFlatRegion* pReg = GetSurfFlatRegion( pGObj) ;
|
||||
// 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 regione
|
||||
ptRef.ToLoc( frEnt) ;
|
||||
// recupero la direzione di mira e la porto nel riferimento della regione
|
||||
Vector3d vtDir = - m_vtDirCamera ;
|
||||
vtDir.ToLoc( frEnt) ;
|
||||
// recupero il piano della regione
|
||||
Plane3d plReg ;
|
||||
plReg.Set( pReg->GetPlanePoint(), pReg->GetNormVersor()) ;
|
||||
// interseco la linea di mira con il piano della regione
|
||||
Point3d ptInt ;
|
||||
if ( IntersLinePlane( ptRef, vtDir, INFINITO, plReg, ptInt, false) != ILPT_YES)
|
||||
return false ;
|
||||
// assegno il punto
|
||||
ptSel = ptInt ;
|
||||
ptSel.ToGlob( frEnt) ;
|
||||
// determino il chunk
|
||||
nAux = 0 ;
|
||||
if ( pReg->GetChunkCount() > 1) {
|
||||
// verifico a quale contorno esterno di chunk è più vicino (potrebbe essere appena fuori dal bordo il centro del mirino)
|
||||
double dMinSqDist = INFINITO * INFINITO ;
|
||||
for ( int nC = 0 ; nC < pReg->GetChunkCount() ; ++ nC) {
|
||||
PtrOwner<ICurve> pCrv( pReg->GetLoop( nC, 0)) ;
|
||||
if ( IsNull( pCrv))
|
||||
return false ;
|
||||
double dSqDist ;
|
||||
if ( DistPointCurve( ptInt, *pCrv).GetSqDist( dSqDist) && dSqDist < dMinSqDist) {
|
||||
nAux = nC ;
|
||||
dMinSqDist = dSqDist ;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// se testo
|
||||
else if ( pGObj->GetType() == EXT_TEXT) {
|
||||
// recupero il testo
|
||||
|
||||
+61
-32
@@ -27,9 +27,10 @@
|
||||
#include "/EgtDev/Include/EGkSurfFlatRegion.h"
|
||||
#include "/EgtDev/Include/EGkExtText.h"
|
||||
#include "/EgtDev/Include/EgkIntersCurves.h"
|
||||
#include "/EgtDev/Include/EGkIntersLinePlane.h"
|
||||
#include "/EgtDev/Include/EGkIntersLineSurfTm.h"
|
||||
#include "/EgtDev/Include/EgtPointerOwner.h"
|
||||
|
||||
#include <array>
|
||||
|
||||
using namespace std ;
|
||||
|
||||
@@ -329,12 +330,12 @@ Scene::FindSelectedSnapPoint( int nSnap, const Point3d& ptWin, int nW, int nH)
|
||||
if ( FindSurfTMSnapPoint( nSnap, ptWin, nId, frEnt, pStm, dMinSqDist))
|
||||
bFound = true ;
|
||||
}
|
||||
// se superficie flat region
|
||||
// se regione
|
||||
else if ( pGObj->GetType() == SRF_FLATRGN) {
|
||||
// recupero la superficie
|
||||
const ISurfFlatRegion* pSfr = GetSurfFlatRegion( pGObj) ;
|
||||
// recupero la regione
|
||||
const ISurfFlatRegion* pReg = GetSurfFlatRegion( pGObj) ;
|
||||
// verifico i punti notevoli della regione
|
||||
if ( FindSurfFRSnapPoint( nSnap, ptWin, nId, frEnt, pSfr, dMinSqDist))
|
||||
if ( FindSurfFRSnapPoint( nSnap, ptWin, nId, frEnt, pReg, dMinSqDist))
|
||||
bFound = true ;
|
||||
}
|
||||
// se testo
|
||||
@@ -643,7 +644,25 @@ Scene::FindSurfTMSnapPoint( int nSnap, const Point3d& ptWin, int nId, const Fram
|
||||
|
||||
// cerco i triangoli intersecati dalla linea di mira
|
||||
ILSIVECTOR vInfo ;
|
||||
if ( ! IntersLineSurfTm( ptMir, vtDir, dLenMir, *pStm, vInfo) || vInfo.size() == 0)
|
||||
if ( ! IntersLineSurfTm( ptMir, vtDir, dLenMir, *pStm, vInfo))
|
||||
return false ;
|
||||
// se non trovato alcunchè, cerco le linee che partono dagli angoli del rettangolo di mira
|
||||
Vector3d vtWinD( -1, -1, 0) ;
|
||||
for ( int i = 0 ; i < 4 && vInfo.size() == 0 ; ++ i) {
|
||||
// determino punto su vertice del rettangolo di selezione
|
||||
Point3d ptWinZ2 = ptWinZ + vtWinD.x * m_nSelH * X_AX + vtWinD.y * m_nSelW * Y_AX ;
|
||||
vtWinD.Rotate( Z_AX, 0, 1) ;
|
||||
// ne ricavo punto di mira
|
||||
Point3d ptMir2 ;
|
||||
if ( ! UnProject( ptWinZ2, ptMir2))
|
||||
return false ;
|
||||
ptMir2.ToLoc( frEnt) ;
|
||||
ptMir2 -= vtDir * 2 * dBlRad ;
|
||||
// interseco con la superficie
|
||||
if ( ! IntersLineSurfTm( ptMir2, vtDir, dLenMir, *pStm, vInfo))
|
||||
return false ;
|
||||
}
|
||||
if ( vInfo.size() == 0)
|
||||
return false ;
|
||||
|
||||
// elaborazione a seconda del tipo di snap
|
||||
@@ -798,10 +817,11 @@ Scene::FindSurfFRSnapPoint( int nSnap, const Point3d& ptWin, int nId, const Fram
|
||||
Color cCol ;
|
||||
bool bAlpha = ( m_pGeomDB->GetCalcMaterial( nId, cCol) && cCol.GetIntAlpha() <= ALPHA_LIM) ;
|
||||
|
||||
// elaborazione a seconda del tipo di snap
|
||||
bool bFound = false ;
|
||||
// se richiesto il centro di gravità (baricentro, centroide)
|
||||
if ( nSnap == SP_CENTROID) {
|
||||
Point3d ptP ;
|
||||
bool bFound = false ;
|
||||
if ( pSfr->GetCentroid( ptP)) {
|
||||
// il punto di confronto è quello sulla linea di mira a minima distanza dal centro
|
||||
Point3d ptCfr = ptRef + (( ptP - ptRef) * vtDir) * vtDir ;
|
||||
@@ -816,15 +836,10 @@ Scene::FindSurfFRSnapPoint( int nSnap, const Point3d& ptWin, int nId, const Fram
|
||||
m_bLastSnapDirOk = false ;
|
||||
}
|
||||
}
|
||||
// se trovato e modalità shading o hiddenline, la favorisco perchè davanti alle possibili successive
|
||||
if ( bFound && ! ( bAlpha || m_nShowMode == SM_WIREFRAME))
|
||||
dMinSqDist = 0 ;
|
||||
return bFound ;
|
||||
}
|
||||
// se richiesto il centro (è il centroide del chunk più vicino)
|
||||
else if ( nSnap == SP_CENTER) {
|
||||
Point3d ptP ;
|
||||
bool bFound = false ;
|
||||
for ( int i = 0 ; i < pSfr->GetChunkCount() ; ++ i) {
|
||||
if ( pSfr->GetChunkCentroid( i, ptP)) {
|
||||
// il punto di confronto è quello sulla linea di mira a minima distanza dal centro
|
||||
@@ -841,27 +856,41 @@ Scene::FindSurfFRSnapPoint( int nSnap, const Point3d& ptWin, int nId, const Fram
|
||||
}
|
||||
}
|
||||
}
|
||||
// se trovato e modalità shading o hiddenline, la favorisco perchè davanti alle possibili successive
|
||||
if ( bFound && ! ( bAlpha || m_nShowMode == SM_WIREFRAME))
|
||||
dMinSqDist = 0 ;
|
||||
return bFound ;
|
||||
}
|
||||
|
||||
// cerco sui contorni della regione
|
||||
bool bFound = false ;
|
||||
for ( int i = 0 ; i < pSfr->GetChunkCount() ; ++ i) {
|
||||
for ( int j = 0 ; j < pSfr->GetLoopCount( i) ; ++ j) {
|
||||
PtrOwner<ICurve> pCrv( pSfr->GetLoop( i, j)) ;
|
||||
if ( IsNull( pCrv))
|
||||
return false ;
|
||||
if ( pCrv->GetType() == CRV_COMPO) {
|
||||
ICurveComposite* pCrvCompo = GetCurveComposite( pCrv) ;
|
||||
if ( FindCurveCompoSnapPoint( nSnap, ptWin, nId, frEnt, pCrvCompo, dMinSqDist))
|
||||
bFound = true ;
|
||||
}
|
||||
else {
|
||||
if ( FindCurveSnapPoint( nSnap, ptWin, nId, frEnt, pCrv, dMinSqDist))
|
||||
bFound = true ;
|
||||
// se richiesto punto vicino o assimilabile
|
||||
else if ( nSnap == SP_NEAR || nSnap == SP_TANG || nSnap == SP_PERP || SP_MINDIST) {
|
||||
// recupero il piano della regione
|
||||
Plane3d plReg ;
|
||||
plReg.Set( pSfr->GetPlanePoint(), pSfr->GetNormVersor()) ;
|
||||
// interseco la linea di mira con il piano della regione
|
||||
Point3d ptInt ;
|
||||
if ( IntersLinePlane( ptRef, vtDir, INFINITO, plReg, ptInt, false) != ILPT_YES)
|
||||
return false ;
|
||||
// assegno il risultato
|
||||
bFound = true ;
|
||||
dMinSqDist = 0 ;
|
||||
m_nLastSnapId = nId ;
|
||||
m_ptLastSnapPnt = ptInt ;
|
||||
m_ptLastSnapPnt.ToGlob( frEnt) ;
|
||||
m_bLastSnapDirOk = false ;
|
||||
}
|
||||
// in tutti gli altri casi
|
||||
else {
|
||||
// cerco sui contorni della regione
|
||||
for ( int i = 0 ; i < pSfr->GetChunkCount() ; ++ i) {
|
||||
for ( int j = 0 ; j < pSfr->GetLoopCount( i) ; ++ j) {
|
||||
PtrOwner<ICurve> pCrv( pSfr->GetLoop( i, j)) ;
|
||||
if ( IsNull( pCrv))
|
||||
return false ;
|
||||
if ( pCrv->GetType() == CRV_COMPO) {
|
||||
ICurveComposite* pCrvCompo = GetCurveComposite( pCrv) ;
|
||||
if ( FindCurveCompoSnapPoint( nSnap, ptWin, nId, frEnt, pCrvCompo, dMinSqDist))
|
||||
bFound = true ;
|
||||
}
|
||||
else {
|
||||
if ( FindCurveSnapPoint( nSnap, ptWin, nId, frEnt, pCrv, dMinSqDist))
|
||||
bFound = true ;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user