EgtGraphics 2.2f1 :

- gestione visualizzazione testi con superfici triangolari.
This commit is contained in:
Dario Sassi
2020-06-02 10:11:23 +00:00
parent 334c744a78
commit 1a608646ca
2 changed files with 49 additions and 12 deletions
+49 -12
View File
@@ -219,7 +219,7 @@ Scene::DrawGeoObj( const IGdbIterator& iIter, int nPass, const MdStMkCol& siObj)
nCount += 1 ;
}
}
// nuova modalità grafica solo per superfici con molti triangoli o solidi Zmap
// nuova modalità grafica solo per superfici e testi con molti triangoli o solidi Zmap
const int N_MIN_TRIA_NEWWAY = 100 ;
bool bNewWay = false ;
if ( m_bNewWay) {
@@ -236,6 +236,11 @@ Scene::DrawGeoObj( const IGdbIterator& iIter, int nPass, const MdStMkCol& siObj)
else if (( nGeoType & GEO_VOLUME) != 0) {
bNewWay = true ;
}
else if ( nGeoType == EXT_TEXT) {
const ISurfTriMesh* pSTM = GetExtText( pGeoObj)->GetAuxSurf() ;
if ( pSTM != nullptr && pSTM->GetTriangleCount() > N_MIN_TRIA_NEWWAY)
bNewWay = true ;
}
}
ObjEGrGraphics* pGraphics = CreateObjEGrGraphics( nCount, bNewWay) ;
if ( pGraphics == nullptr)
@@ -339,7 +344,7 @@ Scene::DrawGeoObj( const IGdbIterator& iIter, int nPass, const MdStMkCol& siObj)
}
if ( pSTM == nullptr)
return false ;
// recupero il materiale
// recupero il materiale
Material mMat ;
if ( ! iIter.GetCalcMaterial( mMat))
mMat.Set( m_colDef) ;
@@ -490,12 +495,41 @@ Scene::DrawGeoObj( const IGdbIterator& iIter, int nPass, const MdStMkCol& siObj)
if ( pTXT == nullptr)
return false ;
// calcolo la grafica
POLYLINELIST lstPL ;
pTXT->ApproxWithLines( 10 * EPS_SMALL, ANG_TOL_GRAPH_DEG, lstPL) ;
pGraphics->Clear() ;
pGraphics->AddColor( siObj.colObj) ;
for ( const auto& PL : lstPL)
pGraphics->AddPolyLine( PL) ;
const ISurfTriMesh* pSTM = pTXT->GetAuxSurf() ;
if ( pSTM != nullptr) {
// recupero il materiale
Material mMat ;
if ( ! iIter.GetCalcMaterial( mMat))
mMat.Set( m_colDef) ;
// impostazioni iniziali
pGraphics->Clear() ;
pGraphics->AddColor( siObj.colObj) ; // per wireframe
pGraphics->AddMaterial( mMat.GetAmbient(), mMat.GetDiffuse(),
mMat.GetSpecular(), mMat.GetShininess()) ;
pGraphics->AddBackMaterial( GetSurfBackColor( mMat.GetDiffuse())) ;
// ciclo sui triangoli della superficie
pGraphics->StartTriangles( pSTM->GetTriangleCount()) ;
Triangle3dEx Tria ;
int nId = pSTM->GetFirstTriangle( Tria) ;
while ( nId != SVT_NULL) {
// se visualizzazione avanzata : edge solo se boundary e normali ai vertici smussate
if ( m_bShowTriaAdvanced)
pGraphics->AddTriangle( Tria, Tria.GetTriFlags(), Tria.GetTriNormals()) ;
// altrimenti : tutti gli edge e normali ai vertici prendono quella del triangolo
else
pGraphics->AddTriangle( Tria, TriFlags3d(), TriNormals3d( Tria.GetN())) ;
nId = pSTM->GetNextTriangle( nId, Tria) ;
}
pGraphics->EndTriangles() ;
}
else {
POLYLINELIST lstPL ;
pTXT->ApproxWithLines( 10 * EPS_SMALL, ANG_TOL_GRAPH_DEG, lstPL) ;
pGraphics->Clear() ;
pGraphics->AddColor( siObj.colObj) ;
for ( const auto& PL : lstPL)
pGraphics->AddPolyLine( PL) ;
}
}
// se quota
else if ( nGeoType == EXT_DIMENSION) {
@@ -526,17 +560,20 @@ Scene::DrawGeoObj( const IGdbIterator& iIter, int nPass, const MdStMkCol& siObj)
if ( (( nGeoType & GEO_CURVE) != 0 || pUserObj != nullptr) && m_bShowCurveDirection)
bShowAux = true ;
// verifico se oggetto con superficie
bool bSurf = ( nGeoType & ( GEO_SURF | GEO_VOLUME)) != 0 || ( nGeoType == EXT_TEXT && GetExtText( pGeoObj)->GetAuxSurf() != nullptr) ;
// recupero il valore di opacità (solo per le superfici e i solidi può esserci trasparenza)
int nAlpha = siObj.colObj.GetIntAlpha() ;
// salto in ogni caso le superfici e i solidi completamente trasparenti
if ( nAlpha == 0 && ( nGeoType & ( GEO_SURF | GEO_VOLUME)) != 0)
if ( nAlpha == 0 && bSurf)
return true ;
// se hiddenline e non selezione
if ( m_nShowMode == SM_HIDDENLINE && ! m_bSelect) {
// in prima passata disegno solo le superfici opache
if ( nPass == 1 && ( ( nGeoType & ( GEO_SURF | GEO_VOLUME)) == 0 || nAlpha <= ALPHA_LIM))
if ( nPass == 1 && ( ! bSurf || nAlpha <= ALPHA_LIM))
return true ;
}
@@ -545,7 +582,7 @@ Scene::DrawGeoObj( const IGdbIterator& iIter, int nPass, const MdStMkCol& siObj)
if ( m_nShowMode == SM_SHADING && ! m_bSelect) {
// in prima passata disegno solo le superfici opache e metto in un vettore quelle semitrasparenti
if ( nPass == 1) {
if ( ( nGeoType & ( GEO_SURF | GEO_VOLUME)) == 0)
if ( ! bSurf)
return true ;
else {
if ( nAlpha > ALPHA_LIM)
@@ -568,7 +605,7 @@ Scene::DrawGeoObj( const IGdbIterator& iIter, int nPass, const MdStMkCol& siObj)
}
}
// in seconda passata disegno solo dimensioni 0 e curve
if ( nPass == 2 && ( nGeoType & ( GEO_SURF | GEO_VOLUME)) != 0)
if ( nPass == 2 && bSurf)
return true ;
}