EgtGeomKernel :
- a ExtText aggiunta GetAuxSurf (solo per font di sistema) - molto migliorata gestione anelli e spikes nella creazione di regioni.
This commit is contained in:
+89
-1
@@ -19,7 +19,11 @@
|
||||
#include "NgeReader.h"
|
||||
#include "FontManager.h"
|
||||
#include "FontAux.h"
|
||||
#include "SurfFlatRegion.h"
|
||||
#include "GeoConst.h"
|
||||
#include "/EgtDev/Include/EGkSfrCreate.h"
|
||||
#include "/EgtDev/Include/EGkStringUtils3d.h"
|
||||
#include "/EgtDev/Include/EGkStmFromTriangleSoup.h"
|
||||
#include "/EgtDev/Include/EGkUiUnits.h"
|
||||
#include <new>
|
||||
|
||||
@@ -30,7 +34,7 @@ GEOOBJ_REGISTER( EXT_TEXT, NGE_E_TXT, ExtText) ;
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
ExtText::ExtText( void)
|
||||
: m_ptP(), m_vtN( 0, 0, 1), m_vtD( 1, 0, 0), m_sFont(),
|
||||
: m_pSTM( nullptr), m_ptP(), m_vtN( 0, 0, 1), m_vtD( 1, 0, 0), m_sFont(),
|
||||
m_nWeight( 400), m_bItalic( false), m_dHeight( 10), m_dRatio( 1), m_dAddAdvance( 0), m_nTempProp()
|
||||
{
|
||||
}
|
||||
@@ -38,6 +42,7 @@ ExtText::ExtText( void)
|
||||
//----------------------------------------------------------------------------
|
||||
ExtText::~ExtText( void)
|
||||
{
|
||||
ResetAuxSurf() ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
@@ -61,6 +66,7 @@ ExtText::Set( const Point3d& ptP, double dAngDeg, const string& sText, double dH
|
||||
m_nInsPos = ETXT_IPBL ;
|
||||
|
||||
// imposto ricalcolo della grafica
|
||||
ResetAuxSurf() ;
|
||||
m_OGrMgr.Reset() ;
|
||||
|
||||
return true ;
|
||||
@@ -91,6 +97,7 @@ ExtText::Set( const Point3d& ptP, const Vector3d& vtN, const Vector3d& vtD,
|
||||
m_nInsPos = ETXT_IPBL ;
|
||||
|
||||
// imposto ricalcolo della grafica
|
||||
ResetAuxSurf() ;
|
||||
m_OGrMgr.Reset() ;
|
||||
|
||||
return true ;
|
||||
@@ -126,6 +133,7 @@ ExtText::Set( const Point3d& ptP, const Vector3d& vtN, const Vector3d& vtD,
|
||||
m_nInsPos = (( nInsPos >= ETXT_IPTL && nInsPos <= ETXT_IPBR) ? nInsPos : ETXT_IPBL) ;
|
||||
|
||||
// imposto ricalcolo della grafica
|
||||
ResetAuxSurf() ;
|
||||
m_OGrMgr.Reset() ;
|
||||
|
||||
return true ;
|
||||
@@ -163,6 +171,7 @@ ExtText::CopyFrom( const ExtText& clSrc)
|
||||
{
|
||||
if ( &clSrc == this)
|
||||
return true ;
|
||||
ResetAuxSurf() ;
|
||||
m_OGrMgr.Reset() ;
|
||||
m_ptP = clSrc.m_ptP ;
|
||||
m_vtN = clSrc.m_vtN ;
|
||||
@@ -282,6 +291,7 @@ bool
|
||||
ExtText::Load( NgeReader& ngeIn)
|
||||
{
|
||||
// imposto ricalcolo della grafica
|
||||
ResetAuxSurf() ;
|
||||
m_OGrMgr.Reset() ;
|
||||
// leggo la prossima linea : punto, posiz. inserimento, normale, direzione
|
||||
if ( ! ngeIn.ReadPoint( m_ptP, ";"))
|
||||
@@ -386,6 +396,7 @@ ExtText::GetBBox( const Frame3d& frRef, BBox3d& b3Ref, int nFlag) const
|
||||
bool
|
||||
ExtText::Translate( const Vector3d& vtMove)
|
||||
{
|
||||
ResetAuxSurf() ;
|
||||
m_OGrMgr.Reset() ;
|
||||
m_ptP.Translate( vtMove) ;
|
||||
return true ;
|
||||
@@ -395,6 +406,7 @@ ExtText::Translate( const Vector3d& vtMove)
|
||||
bool
|
||||
ExtText::Rotate( const Point3d& ptAx, const Vector3d& vtAx, double dCosAng, double dSinAng)
|
||||
{
|
||||
ResetAuxSurf() ;
|
||||
m_OGrMgr.Reset() ;
|
||||
return ( m_ptP.Rotate( ptAx, vtAx, dCosAng, dSinAng) &&
|
||||
m_vtN.Rotate( vtAx, dCosAng, dSinAng) &&
|
||||
@@ -410,6 +422,7 @@ ExtText::Scale( const Frame3d& frRef, double dCoeffX, double dCoeffY, double dCo
|
||||
return false ;
|
||||
|
||||
// imposto ricalcolo della grafica
|
||||
ResetAuxSurf() ;
|
||||
m_OGrMgr.Reset() ;
|
||||
|
||||
// scalo il punto di inserimento
|
||||
@@ -449,6 +462,7 @@ ExtText::Mirror( const Point3d& ptOn, const Vector3d& vtNorm)
|
||||
return false ;
|
||||
|
||||
// imposto ricalcolo della grafica
|
||||
ResetAuxSurf() ;
|
||||
m_OGrMgr.Reset() ;
|
||||
|
||||
// eseguo il mirror del punto di inserimento
|
||||
@@ -480,6 +494,7 @@ ExtText::Shear( const Point3d& ptOn, const Vector3d& vtNorm, const Vector3d& vtD
|
||||
return false ;
|
||||
|
||||
// imposto ricalcolo della grafica
|
||||
ResetAuxSurf() ;
|
||||
m_OGrMgr.Reset() ;
|
||||
|
||||
// eseguo scorrimento del punto di inserimento
|
||||
@@ -515,6 +530,7 @@ bool
|
||||
ExtText::ToGlob( const Frame3d& frRef)
|
||||
{
|
||||
// imposto ricalcolo della grafica
|
||||
ResetAuxSurf() ;
|
||||
m_OGrMgr.Reset() ;
|
||||
// trasformo punto e versori
|
||||
return ( m_ptP.ToGlob( frRef) &&
|
||||
@@ -527,6 +543,7 @@ bool
|
||||
ExtText::ToLoc( const Frame3d& frRef)
|
||||
{
|
||||
// imposto ricalcolo della grafica
|
||||
ResetAuxSurf() ;
|
||||
m_OGrMgr.Reset() ;
|
||||
// trasformo punto e versori
|
||||
return ( m_ptP.ToLoc( frRef) &&
|
||||
@@ -545,6 +562,7 @@ ExtText::LocToLoc( const Frame3d& frOri, const Frame3d& frDest)
|
||||
if ( AreSameFrame( frOri, frDest))
|
||||
return true ;
|
||||
// imposto ricalcolo della grafica
|
||||
ResetAuxSurf() ;
|
||||
m_OGrMgr.Reset() ;
|
||||
// trasformo punto e versori
|
||||
return ( m_ptP.ToGlob( frOri) && m_ptP.ToLoc( frDest) &&
|
||||
@@ -791,11 +809,76 @@ ExtText::ApproxWithArcs( double dLinTol, double dAngTolDeg, POLYARCLIST& lstPA)
|
||||
return true ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
const ISurfTriMesh*
|
||||
ExtText::GetAuxSurf( void) const
|
||||
{
|
||||
// imposto il font corrente e i suoi dati
|
||||
FontManager& fntMgr = FontManager::GetFontManager() ;
|
||||
if ( ! fntMgr.SetCurrFont( m_sFont, m_nWeight, m_bItalic, m_dHeight, m_dRatio, m_dAddAdvance))
|
||||
return nullptr ;
|
||||
|
||||
// se già calcolata, la restituisco
|
||||
if ( m_pSTM != nullptr)
|
||||
return m_pSTM ;
|
||||
|
||||
// calcolo la trasformazione
|
||||
Frame3d frRef ;
|
||||
if ( ! frRef.Set( m_ptP, m_vtN, m_vtD))
|
||||
return nullptr ;
|
||||
|
||||
// preparo il generatore della superficie
|
||||
StmFromTriangleSoup StmFts ;
|
||||
if ( ! StmFts.Start())
|
||||
return nullptr ;
|
||||
|
||||
// richiedo la lista delle regioni
|
||||
ISURFFRPLIST lstSfr ;
|
||||
if ( ! fntMgr.GetRegion( m_sText, m_nInsPos, lstSfr))
|
||||
return nullptr ;
|
||||
|
||||
// per ogni regione richiedo la superficie ausiliaria e la aggiungo a quella generale
|
||||
for ( const auto& pSfr : lstSfr) {
|
||||
// recupero la superficie trimesh
|
||||
const ISurfTriMesh* pStm = pSfr->GetAuxSurf() ;
|
||||
if ( pStm != nullptr) {
|
||||
Triangle3d Tria ;
|
||||
int nT = pStm->GetFirstTriangle( Tria) ;
|
||||
while ( nT != SVT_NULL) {
|
||||
StmFts.AddTriangle( Tria) ;
|
||||
nT = pStm->GetNextTriangle( nT, Tria) ;
|
||||
}
|
||||
}
|
||||
// cancello la regione
|
||||
delete pSfr ;
|
||||
}
|
||||
|
||||
// valido e assegno la superficie complessiva
|
||||
if ( ! StmFts.End())
|
||||
return nullptr ;
|
||||
m_pSTM = GetBasicSurfTriMesh( StmFts.GetSurf()) ;
|
||||
|
||||
// eseguo la trasformazione
|
||||
m_pSTM->ToGlob( frRef) ;
|
||||
|
||||
return m_pSTM ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
void
|
||||
ExtText::ResetAuxSurf( void) const
|
||||
{
|
||||
if ( m_pSTM != nullptr)
|
||||
delete( m_pSTM) ;
|
||||
m_pSTM = nullptr ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
ExtText::Flip( void)
|
||||
{
|
||||
// imposto ricalcolo della grafica
|
||||
ResetAuxSurf() ;
|
||||
m_OGrMgr.Reset() ;
|
||||
// recupero il centro
|
||||
Point3d ptCen ;
|
||||
@@ -813,6 +896,7 @@ bool
|
||||
ExtText::Mir( bool bOnLen)
|
||||
{
|
||||
// imposto ricalcolo della grafica
|
||||
ResetAuxSurf() ;
|
||||
m_OGrMgr.Reset() ;
|
||||
|
||||
// se auto-mirror sulla lunghezza del testo
|
||||
@@ -857,6 +941,7 @@ ExtText::ModifyText( const string& sText)
|
||||
return false ;
|
||||
|
||||
// imposto ricalcolo della grafica
|
||||
ResetAuxSurf() ;
|
||||
m_OGrMgr.Reset() ;
|
||||
// assegno nuovo test
|
||||
m_sText = sText ;
|
||||
@@ -869,6 +954,7 @@ bool
|
||||
ExtText::ChangeFont( const string& sFont)
|
||||
{
|
||||
// imposto ricalcolo della grafica
|
||||
ResetAuxSurf() ;
|
||||
m_OGrMgr.Reset() ;
|
||||
// assegno nuovo font
|
||||
m_sFont = sFont ;
|
||||
@@ -881,6 +967,7 @@ bool
|
||||
ExtText::ChangeHeight( double dH)
|
||||
{
|
||||
// imposto ricalcolo della grafica
|
||||
ResetAuxSurf() ;
|
||||
m_OGrMgr.Reset() ;
|
||||
// assegno nuova altezza
|
||||
m_dHeight = dH ;
|
||||
@@ -893,6 +980,7 @@ bool
|
||||
ExtText::ChangeItalic( bool bItl)
|
||||
{
|
||||
// imposto ricalcolo della grafica
|
||||
ResetAuxSurf() ;
|
||||
m_OGrMgr.Reset() ;
|
||||
// assegno nuovo flag di talico
|
||||
m_bItalic = bItl ;
|
||||
|
||||
Reference in New Issue
Block a user