EgtGeomKernel 1.5f1 :
- aggiunta entità testo (con font Nfe e di sistema) - in tutte le rotate ora l'angolo è in gradi - aggiunta trasformazione Shear (scorrimento) - aggiunta trsformazione LocToLoc - Set/GetInfo specializzate per i diversi tipi di informazioni - Copy e Relocate con possibilità di indicare l'entità di riferimento rispetto a cui inserire - aggiunte trasformazioni a PolyLine.
This commit is contained in:
+66
-23
@@ -463,7 +463,7 @@ CurveArc::GetTitle( void) const
|
||||
bool
|
||||
CurveArc::Dump( string& sOut, const char* szNewLine) const
|
||||
{
|
||||
// parametri : punti iniziale e finale
|
||||
// parametri : Centro, Normale, DirStart, Rad, AngCenDeg, DeltaN
|
||||
sOut += "C(" + ToString( m_PtCen, 3) + ") " + szNewLine ;
|
||||
sOut += "VN(" + ToString( m_VtN, 6) + ") " + szNewLine ;
|
||||
sOut += "VS(" + ToString( m_VtS, 6) + ") " + szNewLine ;
|
||||
@@ -837,7 +837,7 @@ CurveArc::TrimStartAtLen( double dLenTrim)
|
||||
double dAngRot ;
|
||||
double dMoveN ;
|
||||
dAngRot = m_dAngCenDeg * dLenTrim / dLen ;
|
||||
m_VtS.Rotate( m_VtN, dAngRot * DEGTORAD) ;
|
||||
m_VtS.Rotate( m_VtN, dAngRot) ;
|
||||
m_dAngCenDeg -= dAngRot ;
|
||||
if ( fabs( m_dDeltaN) > EPS_ZERO) {
|
||||
dMoveN = m_dDeltaN * dLenTrim / dLen ;
|
||||
@@ -887,12 +887,12 @@ CurveArc::Translate( const Vector3d& vtMove)
|
||||
if ( m_nStatus != OK)
|
||||
return false ;
|
||||
|
||||
// traslo il centro
|
||||
m_PtCen.Translate( vtMove) ;
|
||||
|
||||
// imposto ricalcolo della grafica
|
||||
m_OGrMgr.Reset() ;
|
||||
|
||||
// traslo il centro
|
||||
m_PtCen.Translate( vtMove) ;
|
||||
|
||||
return true ;
|
||||
}
|
||||
|
||||
@@ -908,14 +908,14 @@ CurveArc::Rotate( const Point3d& ptAx, const Vector3d& vtAx, double dCosAng, dou
|
||||
if ( vtAx.IsSmall())
|
||||
return false ;
|
||||
|
||||
// imposto ricalcolo della grafica
|
||||
m_OGrMgr.Reset() ;
|
||||
|
||||
// ruoto il centro e i versori
|
||||
m_PtCen.Rotate( ptAx, vtAx, dCosAng, dSinAng) ;
|
||||
m_VtN.Rotate( vtAx, dCosAng, dSinAng) ;
|
||||
m_VtS.Rotate( vtAx, dCosAng, dSinAng) ;
|
||||
|
||||
// imposto ricalcolo della grafica
|
||||
m_OGrMgr.Reset() ;
|
||||
|
||||
return true ;
|
||||
}
|
||||
|
||||
@@ -935,6 +935,9 @@ CurveArc::Scale( const Frame3d& frRef, double dCoeffX, double dCoeffY, double dC
|
||||
if ( fabs( dCoeffX) < EPS_ZERO)
|
||||
return false ;
|
||||
|
||||
// imposto ricalcolo della grafica
|
||||
m_OGrMgr.Reset() ;
|
||||
|
||||
// scalo il centro e le dimensioni lineari
|
||||
m_PtCen.Scale( frRef, dCoeffX, dCoeffX, dCoeffX) ;
|
||||
m_dRad *= fabs( dCoeffX) ;
|
||||
@@ -943,9 +946,6 @@ CurveArc::Scale( const Frame3d& frRef, double dCoeffX, double dCoeffY, double dC
|
||||
m_VtS = - m_VtS ;
|
||||
m_nStatus = TO_VERIFY ;
|
||||
|
||||
// imposto ricalcolo della grafica
|
||||
m_OGrMgr.Reset() ;
|
||||
|
||||
return Validate() ;
|
||||
}
|
||||
|
||||
@@ -961,15 +961,41 @@ CurveArc::Mirror( const Point3d& ptOn, const Vector3d& vtNorm)
|
||||
if ( vtNorm.IsSmall())
|
||||
return false ;
|
||||
|
||||
// imposto ricalcolo della grafica
|
||||
m_OGrMgr.Reset() ;
|
||||
|
||||
// specchio il centro e i versori, inverto l'angolo al centro
|
||||
m_PtCen.Mirror( ptOn, vtNorm) ;
|
||||
m_VtN.Mirror( vtNorm) ;
|
||||
m_VtS.Mirror( vtNorm) ;
|
||||
m_dAngCenDeg *= -1 ;
|
||||
|
||||
return true ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
CurveArc::Shear( const Point3d& ptOn, const Vector3d& vtNorm, const Vector3d& vtDir, double dCoeff)
|
||||
{
|
||||
// la curva deve essere validata
|
||||
if ( m_nStatus != OK)
|
||||
return false ;
|
||||
|
||||
// verifico validità dei parametri
|
||||
if ( vtNorm.IsSmall() || vtDir.IsSmall())
|
||||
return false ;
|
||||
|
||||
// possibile solo se l'arco è piatto e il piano di scorrimento coincide con quello dell'arco
|
||||
if ( ! ( fabs( m_dDeltaN) < EPS_SMALL) ||
|
||||
! ( AreSameVectorExact( m_VtN, vtNorm) || AreOppositeVectorExact( m_VtN, vtNorm)))
|
||||
return false ;
|
||||
|
||||
// imposto ricalcolo della grafica
|
||||
m_OGrMgr.Reset() ;
|
||||
|
||||
// eseguo scorrimento del centro
|
||||
m_PtCen.Shear( ptOn, vtNorm, vtDir, dCoeff) ;
|
||||
|
||||
return true ;
|
||||
}
|
||||
|
||||
@@ -985,15 +1011,13 @@ CurveArc::ToGlob( const Frame3d& frRef)
|
||||
if ( frRef.GetType() == Frame3d::ERR)
|
||||
return false ;
|
||||
|
||||
// trasformo il centro e i versori
|
||||
m_PtCen.ToGlob( frRef) ;
|
||||
m_VtN.ToGlob( frRef) ;
|
||||
m_VtS.ToGlob( frRef) ;
|
||||
|
||||
// imposto ricalcolo della grafica
|
||||
m_OGrMgr.Reset() ;
|
||||
|
||||
return true ;
|
||||
// trasformo il centro e i versori
|
||||
return ( m_PtCen.ToGlob( frRef) &&
|
||||
m_VtN.ToGlob( frRef) &&
|
||||
m_VtS.ToGlob( frRef)) ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
@@ -1008,15 +1032,34 @@ CurveArc::ToLoc( const Frame3d& frRef)
|
||||
if ( frRef.GetType() == Frame3d::ERR)
|
||||
return false ;
|
||||
|
||||
// trasformo i punti estremi
|
||||
m_PtCen.ToLoc( frRef) ;
|
||||
m_VtN.ToLoc( frRef) ;
|
||||
m_VtS.ToLoc( frRef) ;
|
||||
|
||||
// imposto ricalcolo della grafica
|
||||
m_OGrMgr.Reset() ;
|
||||
|
||||
return true ;
|
||||
// trasformo il centro e i versori
|
||||
return ( m_PtCen.ToLoc( frRef) &&
|
||||
m_VtN.ToLoc( frRef) &&
|
||||
m_VtS.ToLoc( frRef)) ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
CurveArc::LocToLoc( const Frame3d& frOri, const Frame3d& frDest)
|
||||
{
|
||||
// la curva deve essere validata
|
||||
if ( m_nStatus != OK)
|
||||
return false ;
|
||||
// verifico validità dei frame
|
||||
if ( frOri.GetType() == Frame3d::ERR || frDest.GetType() == Frame3d::ERR)
|
||||
return false ;
|
||||
// se i due riferimenti coincidono, non devo fare alcunché
|
||||
if ( AreSameFrame( frOri, frDest))
|
||||
return true ;
|
||||
// imposto ricalcolo della grafica
|
||||
m_OGrMgr.Reset() ;
|
||||
// trasformo il centro e i versori
|
||||
return ( m_PtCen.ToGlob( frOri) && m_PtCen.ToLoc( frDest) &&
|
||||
m_VtN.ToGlob( frOri) && m_VtN.ToLoc( frDest) &&
|
||||
m_VtS.ToGlob( frOri) && m_VtS.ToLoc( frDest)) ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
+5
-2
@@ -33,13 +33,16 @@ class CurveArc : public ICurveArc, public IGeoObjRW
|
||||
virtual bool GetLocalBBox( BBox3d& b3Loc) const ;
|
||||
virtual bool GetBBox( const Frame3d& frRef, BBox3d& b3Ref) const ;
|
||||
virtual bool Translate( const Vector3d& vtMove) ;
|
||||
virtual bool Rotate( const Point3d& ptAx, const Vector3d& vtAx, double dAngDeg)
|
||||
{ double dAngRad = dAngDeg * DEGTORAD ;
|
||||
return Rotate( ptAx, vtAx, cos( dAngRad), sin( dAngRad)) ; }
|
||||
virtual bool Rotate( const Point3d& ptAx, const Vector3d& vtAx, double dCosAng, double dSinAng) ;
|
||||
virtual bool Rotate( const Point3d& ptAx, const Vector3d& vtAx, double dAngRad)
|
||||
{ return Rotate( ptAx, vtAx, cos( dAngRad), sin( dAngRad)) ; }
|
||||
virtual bool Scale( const Frame3d& frRef, double dCoeffX, double dCoeffY, double dCoeffZ) ;
|
||||
virtual bool Mirror( const Point3d& ptOn, const Vector3d& vtNorm) ;
|
||||
virtual bool Shear( const Point3d& ptOn, const Vector3d& vtNorm, const Vector3d& vtDir, double dCoeff) ;
|
||||
virtual bool ToGlob( const Frame3d& frRef) ;
|
||||
virtual bool ToLoc( const Frame3d& frRef) ;
|
||||
virtual bool LocToLoc( const Frame3d& frOri, const Frame3d& frDest) ;
|
||||
virtual void SetObjGraphics( IObjGraphics* pOGr)
|
||||
{ m_OGrMgr.SetObjGraphics( pOGr) ; }
|
||||
virtual IObjGraphics* GetObjGraphics( void)
|
||||
|
||||
+58
-12
@@ -1328,13 +1328,13 @@ CurveBezier::Translate( const Vector3d& vtMove)
|
||||
if ( m_nStatus != OK)
|
||||
return false ;
|
||||
|
||||
// imposto ricalcolo della grafica
|
||||
m_OGrMgr.Reset() ;
|
||||
|
||||
// traslo i punti di controllo
|
||||
for ( int i = 0 ; i <= m_nDeg ; ++ i)
|
||||
m_aPtCtrl[i].Translate( vtMove) ;
|
||||
|
||||
// imposto ricalcolo della grafica
|
||||
m_OGrMgr.Reset() ;
|
||||
|
||||
return true ;
|
||||
}
|
||||
|
||||
@@ -1350,13 +1350,13 @@ CurveBezier::Rotate( const Point3d& ptAx, const Vector3d& vtAx, double dCosAng,
|
||||
if ( vtAx.IsSmall())
|
||||
return false ;
|
||||
|
||||
// imposto ricalcolo della grafica
|
||||
m_OGrMgr.Reset() ;
|
||||
|
||||
// ruoto i punti di controllo
|
||||
for ( int i = 0 ; i <= m_nDeg ; ++ i)
|
||||
m_aPtCtrl[i].Rotate( ptAx, vtAx, dCosAng, dSinAng) ;
|
||||
|
||||
// imposto ricalcolo della grafica
|
||||
m_OGrMgr.Reset() ;
|
||||
|
||||
return true ;
|
||||
}
|
||||
|
||||
@@ -1372,13 +1372,13 @@ CurveBezier::Scale( const Frame3d& frRef, double dCoeffX, double dCoeffY, double
|
||||
if ( fabs( dCoeffX) < EPS_ZERO && fabs( dCoeffY) < EPS_ZERO && fabs( dCoeffZ) < EPS_ZERO)
|
||||
return false ;
|
||||
|
||||
// imposto ricalcolo della grafica
|
||||
m_OGrMgr.Reset() ;
|
||||
|
||||
// scalo i punti di controllo
|
||||
for ( int i = 0 ; i <= m_nDeg ; ++ i)
|
||||
m_aPtCtrl[i].Scale( frRef, dCoeffX, dCoeffY, dCoeffZ) ;
|
||||
|
||||
// imposto ricalcolo della grafica
|
||||
m_OGrMgr.Reset() ;
|
||||
|
||||
return true ;
|
||||
}
|
||||
|
||||
@@ -1394,13 +1394,35 @@ CurveBezier::Mirror( const Point3d& ptOn, const Vector3d& vtNorm)
|
||||
if ( vtNorm.IsSmall())
|
||||
return false ;
|
||||
|
||||
// imposto ricalcolo della grafica
|
||||
m_OGrMgr.Reset() ;
|
||||
|
||||
// specchio i punti di controllo
|
||||
for ( int i = 0 ; i <= m_nDeg ; ++ i)
|
||||
m_aPtCtrl[i].Mirror( ptOn, vtNorm) ;
|
||||
|
||||
return true ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
CurveBezier::Shear( const Point3d& ptOn, const Vector3d& vtNorm, const Vector3d& vtDir, double dCoeff)
|
||||
{
|
||||
// la curva deve essere validata
|
||||
if ( m_nStatus != OK)
|
||||
return false ;
|
||||
|
||||
// verifico validità dei parametri
|
||||
if ( vtNorm.IsSmall() || vtDir.IsSmall())
|
||||
return false ;
|
||||
|
||||
// imposto ricalcolo della grafica
|
||||
m_OGrMgr.Reset() ;
|
||||
|
||||
// eseguo scorrimento dei punti di controllo
|
||||
for ( int i = 0 ; i <= m_nDeg ; ++ i)
|
||||
m_aPtCtrl[i].Shear( ptOn, vtNorm, vtDir, dCoeff) ;
|
||||
|
||||
return true ;
|
||||
}
|
||||
|
||||
@@ -1416,13 +1438,13 @@ CurveBezier::ToGlob( const Frame3d& frRef)
|
||||
if ( frRef.GetType() == Frame3d::ERR)
|
||||
return false ;
|
||||
|
||||
// imposto ricalcolo della grafica
|
||||
m_OGrMgr.Reset() ;
|
||||
|
||||
// trasformo i punti di controllo
|
||||
for ( int i = 0 ; i <= m_nDeg ; ++ i)
|
||||
m_aPtCtrl[i].ToGlob( frRef) ;
|
||||
|
||||
// imposto ricalcolo della grafica
|
||||
m_OGrMgr.Reset() ;
|
||||
|
||||
return true ;
|
||||
}
|
||||
|
||||
@@ -1438,12 +1460,36 @@ CurveBezier::ToLoc( const Frame3d& frRef)
|
||||
if ( frRef.GetType() == Frame3d::ERR)
|
||||
return false ;
|
||||
|
||||
// imposto ricalcolo della grafica
|
||||
m_OGrMgr.Reset() ;
|
||||
|
||||
// trasformo i punti di controllo
|
||||
for ( int i = 0 ; i <= m_nDeg ; ++ i)
|
||||
m_aPtCtrl[i].ToLoc( frRef) ;
|
||||
|
||||
return true ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
CurveBezier::LocToLoc( const Frame3d& frOri, const Frame3d& frDest)
|
||||
{
|
||||
// la curva deve essere validata
|
||||
if ( m_nStatus != OK)
|
||||
return false ;
|
||||
|
||||
// verifico validità dei frame
|
||||
if ( frOri.GetType() == Frame3d::ERR || frDest.GetType() == Frame3d::ERR)
|
||||
return false ;
|
||||
|
||||
// imposto ricalcolo della grafica
|
||||
m_OGrMgr.Reset() ;
|
||||
|
||||
// trasformo i punti di controllo
|
||||
for ( int i = 0 ; i <= m_nDeg ; ++ i) {
|
||||
m_aPtCtrl[i].ToGlob( frOri) ;
|
||||
m_aPtCtrl[i].ToLoc( frDest) ;
|
||||
}
|
||||
|
||||
return true ;
|
||||
}
|
||||
|
||||
+5
-2
@@ -35,13 +35,16 @@ class CurveBezier : public ICurveBezier, public IGeoObjRW
|
||||
virtual bool GetLocalBBox( BBox3d& b3Loc) const ;
|
||||
virtual bool GetBBox( const Frame3d& frRef, BBox3d& b3Ref) const ;
|
||||
virtual bool Translate( const Vector3d& vtMove) ;
|
||||
virtual bool Rotate( const Point3d& ptAx, const Vector3d& vtAx, double dAngDeg)
|
||||
{ double dAngRad = dAngDeg * DEGTORAD ;
|
||||
return Rotate( ptAx, vtAx, cos( dAngRad), sin( dAngRad)) ; }
|
||||
virtual bool Rotate( const Point3d& ptAx, const Vector3d& vtAx, double dCosAng, double dSinAng) ;
|
||||
virtual bool Rotate( const Point3d& ptAx, const Vector3d& vtAx, double dAngRad)
|
||||
{ return Rotate( ptAx, vtAx, cos( dAngRad), sin( dAngRad)) ; }
|
||||
virtual bool Scale( const Frame3d& frRef, double dCoeffX, double dCoeffY, double dCoeffZ) ;
|
||||
virtual bool Mirror( const Point3d& ptOn, const Vector3d& vtNorm) ;
|
||||
virtual bool Shear( const Point3d& ptOn, const Vector3d& vtNorm, const Vector3d& vtDir, double dCoeff) ;
|
||||
virtual bool ToGlob( const Frame3d& frRef) ;
|
||||
virtual bool ToLoc( const Frame3d& frRef) ;
|
||||
virtual bool LocToLoc( const Frame3d& frOri, const Frame3d& frDest) ;
|
||||
virtual void SetObjGraphics( IObjGraphics* pOGr)
|
||||
{ m_OGrMgr.SetObjGraphics( pOGr) ; }
|
||||
virtual IObjGraphics* GetObjGraphics( void)
|
||||
|
||||
+67
-12
@@ -980,6 +980,9 @@ CurveComposite::TrimEndAtLen( double dLenTrim)
|
||||
bool
|
||||
CurveComposite::Translate( const Vector3d& vtMove)
|
||||
{
|
||||
// imposto ricalcolo della grafica
|
||||
m_OGrMgr.Reset() ;
|
||||
|
||||
// traslo le singole curve
|
||||
PCRVSMPL_LIST::iterator Iter ;
|
||||
for ( Iter = m_CrvSmplS.begin() ; Iter != m_CrvSmplS.end() ; ++Iter)
|
||||
@@ -989,9 +992,6 @@ CurveComposite::Translate( const Vector3d& vtMove)
|
||||
m_PtStart.Translate( vtMove) ;
|
||||
m_PtEnd.Translate( vtMove) ;
|
||||
|
||||
// imposto ricalcolo della grafica
|
||||
m_OGrMgr.Reset() ;
|
||||
|
||||
return true ;
|
||||
}
|
||||
|
||||
@@ -1003,6 +1003,9 @@ CurveComposite::Rotate( const Point3d& ptAx, const Vector3d& vtAx, double dCosAn
|
||||
if ( vtAx.IsSmall())
|
||||
return false ;
|
||||
|
||||
// imposto ricalcolo della grafica
|
||||
m_OGrMgr.Reset() ;
|
||||
|
||||
// ruoto le singole curve
|
||||
PCRVSMPL_LIST::iterator Iter ;
|
||||
for ( Iter = m_CrvSmplS.begin() ; Iter != m_CrvSmplS.end() ; ++Iter)
|
||||
@@ -1012,9 +1015,6 @@ CurveComposite::Rotate( const Point3d& ptAx, const Vector3d& vtAx, double dCosAn
|
||||
m_PtStart.Rotate( ptAx, vtAx, dCosAng, dSinAng) ;
|
||||
m_PtEnd.Rotate( ptAx, vtAx, dCosAng, dSinAng) ;
|
||||
|
||||
// imposto ricalcolo della grafica
|
||||
m_OGrMgr.Reset() ;
|
||||
|
||||
return true ;
|
||||
}
|
||||
|
||||
@@ -1026,6 +1026,9 @@ CurveComposite::Scale( const Frame3d& frRef, double dCoeffX, double dCoeffY, dou
|
||||
if ( fabs( dCoeffX) < EPS_ZERO && fabs( dCoeffY) < EPS_ZERO && fabs( dCoeffZ) < EPS_ZERO)
|
||||
return false ;
|
||||
|
||||
// imposto ricalcolo della grafica
|
||||
m_OGrMgr.Reset() ;
|
||||
|
||||
// se scalatura non omogenea, devo trasformare tutti gli archi in curve di Bezier
|
||||
if ( fabs( dCoeffX - dCoeffY) > EPS_SMALL || fabs( dCoeffX - dCoeffZ) > EPS_SMALL) {
|
||||
if ( ! ArcsToBezierCurves())
|
||||
@@ -1044,9 +1047,6 @@ CurveComposite::Scale( const Frame3d& frRef, double dCoeffX, double dCoeffY, dou
|
||||
m_PtStart.Scale( frRef, dCoeffX, dCoeffY, dCoeffZ) ;
|
||||
m_PtEnd.Scale( frRef, dCoeffX, dCoeffY, dCoeffZ) ;
|
||||
|
||||
// imposto ricalcolo della grafica
|
||||
m_OGrMgr.Reset() ;
|
||||
|
||||
return Validate() ;
|
||||
}
|
||||
|
||||
@@ -1058,6 +1058,9 @@ CurveComposite::Mirror( const Point3d& ptOn, const Vector3d& vtNorm)
|
||||
if ( vtNorm.IsSmall())
|
||||
return false ;
|
||||
|
||||
// imposto ricalcolo della grafica
|
||||
m_OGrMgr.Reset() ;
|
||||
|
||||
// specchio le singole curve
|
||||
PCRVSMPL_LIST::iterator Iter ;
|
||||
for ( Iter = m_CrvSmplS.begin() ; Iter != m_CrvSmplS.end() ; ++Iter)
|
||||
@@ -1067,9 +1070,33 @@ CurveComposite::Mirror( const Point3d& ptOn, const Vector3d& vtNorm)
|
||||
m_PtStart.Mirror( ptOn, vtNorm) ;
|
||||
m_PtEnd.Mirror( ptOn, vtNorm) ;
|
||||
|
||||
return true ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
CurveComposite::Shear( const Point3d& ptOn, const Vector3d& vtNorm, const Vector3d& vtDir, double dCoeff)
|
||||
{
|
||||
// verifico validità dei parametri
|
||||
if ( vtNorm.IsSmall() || vtDir.IsSmall())
|
||||
return false ;
|
||||
|
||||
// imposto ricalcolo della grafica
|
||||
m_OGrMgr.Reset() ;
|
||||
|
||||
// trasformo tutti gli archi in curve di Bezier (potrei controllare gli archi uno ad uno...)
|
||||
if ( ! ArcsToBezierCurves())
|
||||
return false ;
|
||||
|
||||
// eseguo scorrimento delle singole curve
|
||||
PCRVSMPL_LIST::iterator Iter ;
|
||||
for ( Iter = m_CrvSmplS.begin() ; Iter != m_CrvSmplS.end() ; ++Iter)
|
||||
(*Iter)->Shear( ptOn, vtNorm, vtDir, dCoeff) ;
|
||||
|
||||
// eseguo scorrimento dei punti estremi
|
||||
m_PtStart.Shear( ptOn, vtNorm, vtDir, dCoeff) ;
|
||||
m_PtEnd.Shear( ptOn, vtNorm, vtDir, dCoeff) ;
|
||||
|
||||
return true ;
|
||||
}
|
||||
|
||||
@@ -1081,6 +1108,9 @@ CurveComposite::ToGlob( const Frame3d& frRef)
|
||||
if ( frRef.GetType() == Frame3d::ERR)
|
||||
return false ;
|
||||
|
||||
// imposto ricalcolo della grafica
|
||||
m_OGrMgr.Reset() ;
|
||||
|
||||
// trasformo le singole curve
|
||||
PCRVSMPL_LIST::iterator Iter ;
|
||||
for ( Iter = m_CrvSmplS.begin() ; Iter != m_CrvSmplS.end() ; ++Iter)
|
||||
@@ -1090,9 +1120,6 @@ CurveComposite::ToGlob( const Frame3d& frRef)
|
||||
m_PtStart.ToGlob( frRef) ;
|
||||
m_PtEnd.ToGlob( frRef) ;
|
||||
|
||||
// imposto ricalcolo della grafica
|
||||
m_OGrMgr.Reset() ;
|
||||
|
||||
return true ;
|
||||
}
|
||||
|
||||
@@ -1104,6 +1131,9 @@ CurveComposite::ToLoc( const Frame3d& frRef)
|
||||
if ( frRef.GetType() == Frame3d::ERR)
|
||||
return false ;
|
||||
|
||||
// imposto ricalcolo della grafica
|
||||
m_OGrMgr.Reset() ;
|
||||
|
||||
// trasformo le singole curve
|
||||
PCRVSMPL_LIST::iterator Iter ;
|
||||
for ( Iter = m_CrvSmplS.begin() ; Iter != m_CrvSmplS.end() ; ++Iter)
|
||||
@@ -1113,9 +1143,34 @@ CurveComposite::ToLoc( const Frame3d& frRef)
|
||||
m_PtStart.ToLoc( frRef) ;
|
||||
m_PtEnd.ToLoc( frRef) ;
|
||||
|
||||
return true ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
CurveComposite::LocToLoc( const Frame3d& frOri, const Frame3d& frDest)
|
||||
{
|
||||
// verifico validità dei frame
|
||||
if ( frOri.GetType() == Frame3d::ERR || frDest.GetType() == Frame3d::ERR)
|
||||
return false ;
|
||||
|
||||
// se i due riferimenti coincidono, non devo fare alcunché
|
||||
if ( AreSameFrame( frOri, frDest))
|
||||
return true ;
|
||||
|
||||
// imposto ricalcolo della grafica
|
||||
m_OGrMgr.Reset() ;
|
||||
|
||||
// trasformo le singole curve
|
||||
PCRVSMPL_LIST::iterator Iter ;
|
||||
for ( Iter = m_CrvSmplS.begin() ; Iter != m_CrvSmplS.end() ; ++Iter) {
|
||||
(*Iter)->LocToLoc( frOri, frDest) ;
|
||||
}
|
||||
|
||||
// trasformo i punti estremi
|
||||
m_PtStart.LocToLoc( frOri, frDest) ;
|
||||
m_PtEnd.LocToLoc( frOri, frDest) ;
|
||||
|
||||
return true ;
|
||||
}
|
||||
|
||||
|
||||
+5
-2
@@ -35,13 +35,16 @@ class CurveComposite : public ICurveComposite, public IGeoObjRW
|
||||
virtual bool GetLocalBBox( BBox3d& b3Loc) const ;
|
||||
virtual bool GetBBox( const Frame3d& frRef, BBox3d& b3Ref) const ;
|
||||
virtual bool Translate( const Vector3d& vtMove) ;
|
||||
virtual bool Rotate( const Point3d& ptAx, const Vector3d& vtAx, double dAngDeg)
|
||||
{ double dAngRad = dAngDeg * DEGTORAD ;
|
||||
return Rotate( ptAx, vtAx, cos( dAngRad), sin( dAngRad)) ; }
|
||||
virtual bool Rotate( const Point3d& ptAx, const Vector3d& vtAx, double dCosAng, double dSinAng) ;
|
||||
virtual bool Rotate( const Point3d& ptAx, const Vector3d& vtAx, double dAngRad)
|
||||
{ return Rotate( ptAx, vtAx, cos( dAngRad), sin( dAngRad)) ; }
|
||||
virtual bool Scale( const Frame3d& frRef, double dCoeffX, double dCoeffY, double dCoeffZ) ;
|
||||
virtual bool Mirror( const Point3d& ptOn, const Vector3d& vtNorm) ;
|
||||
virtual bool Shear( const Point3d& ptOn, const Vector3d& vtNorm, const Vector3d& vtDir, double dCoeff) ;
|
||||
virtual bool ToGlob( const Frame3d& frRef) ;
|
||||
virtual bool ToLoc( const Frame3d& frRef) ;
|
||||
virtual bool LocToLoc( const Frame3d& frOri, const Frame3d& frDest) ;
|
||||
virtual void SetObjGraphics( IObjGraphics* pOGr)
|
||||
{ m_OGrMgr.SetObjGraphics( pOGr) ; }
|
||||
virtual IObjGraphics* GetObjGraphics( void)
|
||||
|
||||
+48
-17
@@ -444,13 +444,13 @@ CurveLine::TrimEndAtLen( double dLenTrim)
|
||||
bool
|
||||
CurveLine::Translate( const Vector3d& vtMove)
|
||||
{
|
||||
// imposto ricalcolo della grafica
|
||||
m_OGrMgr.Reset() ;
|
||||
|
||||
// traslo i punti estremi
|
||||
m_PtStart.Translate( vtMove) ;
|
||||
m_PtEnd.Translate( vtMove) ;
|
||||
|
||||
// imposto ricalcolo della grafica
|
||||
m_OGrMgr.Reset() ;
|
||||
|
||||
return true ;
|
||||
}
|
||||
|
||||
@@ -462,13 +462,13 @@ CurveLine::Rotate( const Point3d& ptAx, const Vector3d& vtAx, double dCosAng, do
|
||||
if ( vtAx.IsSmall())
|
||||
return false ;
|
||||
|
||||
// imposto ricalcolo della grafica
|
||||
m_OGrMgr.Reset() ;
|
||||
|
||||
// ruoto i punti estremi
|
||||
m_PtStart.Rotate( ptAx, vtAx, dCosAng, dSinAng) ;
|
||||
m_PtEnd.Rotate( ptAx, vtAx, dCosAng, dSinAng) ;
|
||||
|
||||
// imposto ricalcolo della grafica
|
||||
m_OGrMgr.Reset() ;
|
||||
|
||||
return true ;
|
||||
}
|
||||
|
||||
@@ -480,14 +480,14 @@ CurveLine::Scale( const Frame3d& frRef, double dCoeffX, double dCoeffY, double d
|
||||
if ( fabs( dCoeffX) < EPS_ZERO && fabs( dCoeffY) < EPS_ZERO && fabs( dCoeffZ) < EPS_ZERO)
|
||||
return false ;
|
||||
|
||||
// imposto ricalcolo della grafica
|
||||
m_OGrMgr.Reset() ;
|
||||
|
||||
// scalo i punti estremi
|
||||
m_PtStart.Scale( frRef, dCoeffX, dCoeffY, dCoeffZ) ;
|
||||
m_PtEnd.Scale( frRef, dCoeffX, dCoeffY, dCoeffZ) ;
|
||||
m_nStatus = TO_VERIFY ;
|
||||
|
||||
// imposto ricalcolo della grafica
|
||||
m_OGrMgr.Reset() ;
|
||||
|
||||
return Validate() ;
|
||||
}
|
||||
|
||||
@@ -499,13 +499,31 @@ CurveLine::Mirror( const Point3d& ptOn, const Vector3d& vtNorm)
|
||||
if ( vtNorm.IsSmall())
|
||||
return false ;
|
||||
|
||||
// imposto ricalcolo della grafica
|
||||
m_OGrMgr.Reset() ;
|
||||
|
||||
// specchio i punti estremi
|
||||
m_PtStart.Mirror( ptOn, vtNorm) ;
|
||||
m_PtEnd.Mirror( ptOn, vtNorm) ;
|
||||
|
||||
return true ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
CurveLine::Shear( const Point3d& ptOn, const Vector3d& vtNorm, const Vector3d& vtDir, double dCoeff)
|
||||
{
|
||||
// verifico validità dei parametri
|
||||
if ( vtNorm.IsSmall() || vtDir.IsSmall())
|
||||
return false ;
|
||||
|
||||
// imposto ricalcolo della grafica
|
||||
m_OGrMgr.Reset() ;
|
||||
|
||||
// eseguo scorrimento dei punti estremi
|
||||
m_PtStart.Shear( ptOn, vtNorm, vtDir, dCoeff) ;
|
||||
m_PtEnd.Shear( ptOn, vtNorm, vtDir, dCoeff) ;
|
||||
|
||||
return true ;
|
||||
}
|
||||
|
||||
@@ -517,14 +535,11 @@ CurveLine::ToGlob( const Frame3d& frRef)
|
||||
if ( frRef.GetType() == Frame3d::ERR)
|
||||
return false ;
|
||||
|
||||
// trasformo i punti estremi
|
||||
m_PtStart.ToGlob( frRef) ;
|
||||
m_PtEnd.ToGlob( frRef) ;
|
||||
|
||||
// imposto ricalcolo della grafica
|
||||
m_OGrMgr.Reset() ;
|
||||
|
||||
return true ;
|
||||
// trasformo i punti estremi
|
||||
return ( m_PtStart.ToGlob( frRef) && m_PtEnd.ToGlob( frRef)) ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
@@ -535,12 +550,28 @@ CurveLine::ToLoc( const Frame3d& frRef)
|
||||
if ( frRef.GetType() == Frame3d::ERR)
|
||||
return false ;
|
||||
|
||||
// imposto ricalcolo della grafica
|
||||
m_OGrMgr.Reset() ;
|
||||
|
||||
// trasformo i punti estremi
|
||||
m_PtStart.ToLoc( frRef) ;
|
||||
m_PtEnd.ToLoc( frRef) ;
|
||||
return ( m_PtStart.ToLoc( frRef) && m_PtEnd.ToLoc( frRef)) ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
CurveLine::LocToLoc( const Frame3d& frOri, const Frame3d& frDest)
|
||||
{
|
||||
// verifico validità dei frame
|
||||
if ( frOri.GetType() == Frame3d::ERR || frDest.GetType() == Frame3d::ERR)
|
||||
return false ;
|
||||
// se i due riferimenti coincidono, non devo fare alcunché
|
||||
if ( AreSameFrame( frOri, frDest))
|
||||
return true ;
|
||||
|
||||
// imposto ricalcolo della grafica
|
||||
m_OGrMgr.Reset() ;
|
||||
|
||||
return true ;
|
||||
// trasformo i punti estremi
|
||||
return ( m_PtStart.ToGlob( frOri) && m_PtStart.ToLoc( frDest) &&
|
||||
m_PtEnd.ToGlob( frOri) && m_PtEnd.ToLoc( frDest)) ;
|
||||
}
|
||||
|
||||
+5
-2
@@ -33,13 +33,16 @@ class CurveLine : public ICurveLine, public IGeoObjRW
|
||||
virtual bool GetLocalBBox( BBox3d& b3Loc) const ;
|
||||
virtual bool GetBBox( const Frame3d& frRef, BBox3d& b3Ref) const ;
|
||||
virtual bool Translate( const Vector3d& vtMove) ;
|
||||
virtual bool Rotate( const Point3d& ptAx, const Vector3d& vtAx, double dAngDeg)
|
||||
{ double dAngRad = dAngDeg * DEGTORAD ;
|
||||
return Rotate( ptAx, vtAx, cos( dAngRad), sin( dAngRad)) ; }
|
||||
virtual bool Rotate( const Point3d& ptAx, const Vector3d& vtAx, double dCosAng, double dSinAng) ;
|
||||
virtual bool Rotate( const Point3d& ptAx, const Vector3d& vtAx, double dAngRad)
|
||||
{ return Rotate( ptAx, vtAx, cos( dAngRad), sin( dAngRad)) ; }
|
||||
virtual bool Scale( const Frame3d& frRef, double dCoeffX, double dCoeffY, double dCoeffZ) ;
|
||||
virtual bool Mirror( const Point3d& ptOn, const Vector3d& vtNorm) ;
|
||||
virtual bool Shear( const Point3d& ptOn, const Vector3d& vtNorm, const Vector3d& vtDir, double dCoeff) ;
|
||||
virtual bool ToGlob( const Frame3d& frRef) ;
|
||||
virtual bool ToLoc( const Frame3d& frRef) ;
|
||||
virtual bool LocToLoc( const Frame3d& frOri, const Frame3d& frDest) ;
|
||||
virtual void SetObjGraphics( IObjGraphics* pOGr)
|
||||
{ m_OGrMgr.SetObjGraphics( pOGr) ; }
|
||||
virtual IObjGraphics* GetObjGraphics( void)
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
//--------------------------- Include ----------------------------------------
|
||||
#include "stdafx.h"
|
||||
#include "DllMain.h"
|
||||
#include "FontManager.h"
|
||||
#include "\EgtDev\Include\EGkDllMain.h"
|
||||
#include "\EgtDev\Include\EgnGetModuleVer.h"
|
||||
#include "\EgtDev\Include\EgtTrace.h"
|
||||
@@ -83,3 +84,14 @@ GetEGkLogger( void)
|
||||
{
|
||||
return s_pLogger ;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
void
|
||||
InitFontManager( const std::string& sNfeFontDir, const std::string& sDefaultFont)
|
||||
{
|
||||
// recupero il font manager
|
||||
FontManager& fntMgr = FontManager::GetFontManager() ;
|
||||
|
||||
// lo inizializzo
|
||||
fntMgr.Init( sNfeFontDir, sDefaultFont) ;
|
||||
}
|
||||
|
||||
Binary file not shown.
@@ -234,6 +234,8 @@ copy $(TargetPath) \EgtProg\Dll64</Command>
|
||||
<ClCompile Include="DistPointCrvComposite.cpp" />
|
||||
<ClCompile Include="DistPointCurve.cpp" />
|
||||
<ClCompile Include="DistPointLine.cpp" />
|
||||
<ClCompile Include="ExtText.cpp" />
|
||||
<ClCompile Include="FontManager.cpp" />
|
||||
<ClCompile Include="GdbExecutor.cpp" />
|
||||
<ClCompile Include="CurveArc.cpp" />
|
||||
<ClCompile Include="CurveAux.cpp" />
|
||||
@@ -254,7 +256,9 @@ copy $(TargetPath) \EgtProg\Dll64</Command>
|
||||
<ClCompile Include="GeoVector3d.cpp" />
|
||||
<ClCompile Include="IterManager.cpp" />
|
||||
<ClCompile Include="Material.cpp" />
|
||||
<ClCompile Include="NfeFont.cpp" />
|
||||
<ClCompile Include="NgeReader.cpp" />
|
||||
<ClCompile Include="OsFont.cpp" />
|
||||
<ClCompile Include="OutTsc.cpp" />
|
||||
<ClCompile Include="Point3d.cpp" />
|
||||
<ClCompile Include="PointGrid3d.cpp" />
|
||||
@@ -285,6 +289,7 @@ copy $(TargetPath) \EgtProg\Dll64</Command>
|
||||
<ClInclude Include="..\Include\EGkCurvePointDiffGeom.h" />
|
||||
<ClInclude Include="..\Include\EGkDistPointCurve.h" />
|
||||
<ClInclude Include="..\Include\EGkDllMain.h" />
|
||||
<ClInclude Include="..\Include\EGkExtText.h" />
|
||||
<ClInclude Include="..\Include\EGkFrame3d.h" />
|
||||
<ClInclude Include="..\Include\EGkGdbConst.h" />
|
||||
<ClInclude Include="..\Include\EGkGdbFunct.h" />
|
||||
@@ -322,6 +327,8 @@ copy $(TargetPath) \EgtProg\Dll64</Command>
|
||||
<ClInclude Include="DistPointCrvComposite.h" />
|
||||
<ClInclude Include="DistPointLine.h" />
|
||||
<ClInclude Include="DllMain.h" />
|
||||
<ClInclude Include="ExtText.h" />
|
||||
<ClInclude Include="FontManager.h" />
|
||||
<ClInclude Include="GdbExecutor.h" />
|
||||
<ClInclude Include="CurveArc.h" />
|
||||
<ClInclude Include="CurveAux.h" />
|
||||
@@ -344,10 +351,12 @@ copy $(TargetPath) \EgtProg\Dll64</Command>
|
||||
<ClInclude Include="IdManager.h" />
|
||||
<ClInclude Include="IterManager.h" />
|
||||
<ClInclude Include="Material.h" />
|
||||
<ClInclude Include="NfeFont.h" />
|
||||
<ClInclude Include="NgeConst.h" />
|
||||
<ClInclude Include="NgeKeyW.h" />
|
||||
<ClInclude Include="NgeReader.h" />
|
||||
<ClInclude Include="ObjGraphicsMgr.h" />
|
||||
<ClInclude Include="OsFont.h" />
|
||||
<ClInclude Include="OutTsc.h" />
|
||||
<ClInclude Include="PolynomialPoint3d.h" />
|
||||
<ClInclude Include="Resource.h" />
|
||||
|
||||
@@ -162,6 +162,18 @@
|
||||
<ClCompile Include="StmFromTriangleSoup.cpp">
|
||||
<Filter>File di origine\GeoCreate</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="ExtText.cpp">
|
||||
<Filter>File di origine\Geo</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="FontManager.cpp">
|
||||
<Filter>File di origine\Gdb</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="NfeFont.cpp">
|
||||
<Filter>File di origine\Gdb</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="OsFont.cpp">
|
||||
<Filter>File di origine\Gdb</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="stdafx.h">
|
||||
@@ -410,6 +422,21 @@
|
||||
<ClInclude Include="..\Include\EgkCurveAux.h">
|
||||
<Filter>File di intestazione</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="ExtText.h">
|
||||
<Filter>File di intestazione</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\Include\EGkExtText.h">
|
||||
<Filter>File di intestazione</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="FontManager.h">
|
||||
<Filter>File di intestazione</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="NfeFont.h">
|
||||
<Filter>File di intestazione</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="OsFont.h">
|
||||
<Filter>File di intestazione</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ResourceCompile Include="EgtGeomKernel.rc">
|
||||
|
||||
+640
@@ -0,0 +1,640 @@
|
||||
//----------------------------------------------------------------------------
|
||||
// EgalTech 2014-2014
|
||||
//----------------------------------------------------------------------------
|
||||
// File : ExtText.cpp Data : 27.05.14 Versione : 1.5e10
|
||||
// Contenuto : Implementazione della classe Testo.
|
||||
//
|
||||
//
|
||||
//
|
||||
// Modifiche : 27.05.14 DS Creazione modulo.
|
||||
//
|
||||
//
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
//--------------------------- Include ----------------------------------------
|
||||
#include "stdafx.h"
|
||||
#include "ExtText.h"
|
||||
#include "GeoObjFactory.h"
|
||||
#include "NgeWriter.h"
|
||||
#include "NgeReader.h"
|
||||
#include "FontManager.h"
|
||||
#include "\EgtDev\Include\EGkStringUtils3d.h"
|
||||
#include <new>
|
||||
|
||||
using namespace std ;
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
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_nWeight( 400), m_bItalic( false), m_dHeight( 10), m_dRatio( 1), m_dAddAdvance( 0)
|
||||
{
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
ExtText::~ExtText( void)
|
||||
{
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
ExtText::Set( const string& sText, const Point3d& ptP, double dAngDeg, double dH)
|
||||
{
|
||||
// assegno i dati
|
||||
m_ptP = ptP ;
|
||||
m_vtN = Z_AX ;
|
||||
m_vtD.FromPolar( 1, dAngDeg) ;
|
||||
m_sText = sText ;
|
||||
m_sFont.clear() ;
|
||||
m_nWeight = 400 ;
|
||||
m_bItalic = false ;
|
||||
m_dHeight = dH ;
|
||||
m_dRatio = 1 ;
|
||||
m_dAddAdvance = 0 ;
|
||||
|
||||
// imposto ricalcolo della grafica
|
||||
m_OGrMgr.Reset() ;
|
||||
|
||||
return true ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
ExtText::Set( const string& sText, const Point3d& ptP, double dAngDeg,
|
||||
const string& sFont, int nW, bool bItl, double dH, double dRat, double dAddAdv)
|
||||
{
|
||||
// assegno i dati
|
||||
m_ptP = ptP ;
|
||||
m_vtN = Z_AX ;
|
||||
m_vtD.FromPolar( 1, dAngDeg) ;
|
||||
m_sText = sText ;
|
||||
m_sFont = sFont ;
|
||||
m_nWeight = nW ;
|
||||
m_bItalic = bItl ;
|
||||
m_dHeight = dH ;
|
||||
m_dRatio = dRat ;
|
||||
m_dAddAdvance = dAddAdv ;
|
||||
|
||||
// imposto ricalcolo della grafica
|
||||
m_OGrMgr.Reset() ;
|
||||
|
||||
return true ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
ExtText*
|
||||
ExtText::Clone( void) const
|
||||
{
|
||||
// alloco oggetto
|
||||
ExtText* pGPt = new(nothrow) ExtText ;
|
||||
if ( pGPt != nullptr) {
|
||||
if ( ! pGPt->Copy( *this)) {
|
||||
delete pGPt ;
|
||||
return nullptr ;
|
||||
}
|
||||
}
|
||||
|
||||
return pGPt ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
ExtText::Copy( const IGeoObj* pGObjSrc)
|
||||
{
|
||||
const ExtText* pTxt = dynamic_cast<const ExtText*>( pGObjSrc) ;
|
||||
if ( pTxt == nullptr)
|
||||
return false ;
|
||||
return Copy( *pTxt) ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
ExtText::Copy( const ExtText& clSrc)
|
||||
{
|
||||
if ( &clSrc == this)
|
||||
return true ;
|
||||
m_OGrMgr.Reset() ;
|
||||
m_ptP = clSrc.m_ptP ;
|
||||
m_vtN = clSrc.m_vtN ;
|
||||
m_vtD = clSrc.m_vtD ;
|
||||
m_sText = clSrc.m_sText ;
|
||||
m_sFont = clSrc.m_sFont ;
|
||||
m_nWeight = clSrc.m_nWeight ;
|
||||
m_bItalic = clSrc.m_bItalic ;
|
||||
m_dHeight = clSrc.m_dHeight ;
|
||||
m_dRatio = clSrc.m_dRatio ;
|
||||
m_dAddAdvance = clSrc.m_dAddAdvance ;
|
||||
return true ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
GeoObjType
|
||||
ExtText::GetType( void) const
|
||||
{
|
||||
return static_cast<GeoObjType>( GEOOBJ_GETTYPE( ExtText)) ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
const string&
|
||||
ExtText::GetTitle( void) const
|
||||
{
|
||||
static const string sTitle = "Text" ;
|
||||
return sTitle ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
ExtText::Dump( string& sOut, const char* szNewLine) const
|
||||
{
|
||||
// parametri : PtIns, Normale, DirStart, Rad, AngCenDeg, DeltaN
|
||||
sOut += "P(" + ToString( m_ptP, 3) + ") " + szNewLine ;
|
||||
sOut += "VN(" + ToString( m_vtN, 6) + ") " + szNewLine ;
|
||||
sOut += "VS(" + ToString( m_vtD, 6) + ") " + szNewLine ;
|
||||
sOut += "Txt=" + m_sText + szNewLine ;
|
||||
sOut += "Fnt=" + m_sFont + szNewLine ;
|
||||
sOut += "W=" + ToString( m_nWeight) ;
|
||||
sOut += " I=" + ToString( m_bItalic) ;
|
||||
sOut += " H=" + ToString( m_dHeight, 1) ;
|
||||
sOut += " R=" + ToString( m_dRatio, 3) ;
|
||||
sOut += " A=" + ToString( m_dAddAdvance, 1) + szNewLine ;
|
||||
|
||||
return true ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
int
|
||||
ExtText::GetNgeId( void) const
|
||||
{
|
||||
return GEOOBJ_GETNGEID( ExtText) ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
ExtText::Save( NgeWriter& ngeOut) const
|
||||
{
|
||||
// punto di inserimento
|
||||
ngeOut.WritePoint( m_ptP, ";") ;
|
||||
// versore normale
|
||||
ngeOut.WriteVector( m_vtN, ";") ;
|
||||
// versore di direzione
|
||||
ngeOut.WriteVector( m_vtD, ";", true) ;
|
||||
// testo
|
||||
ngeOut.WriteString( m_sText, nullptr, true) ;
|
||||
// font
|
||||
ngeOut.WriteString( m_sFont, ";") ;
|
||||
// spessore del font
|
||||
ngeOut.WriteInt( m_nWeight, ",") ;
|
||||
// flag di italico
|
||||
ngeOut.WriteBool( m_bItalic, ",") ;
|
||||
// altezza del font
|
||||
ngeOut.WriteDouble( m_dHeight, ",") ;
|
||||
// rapporto larghezza su altezza del font
|
||||
ngeOut.WriteDouble( m_dRatio, ",") ;
|
||||
// avanzamento addizionale tra caratteri
|
||||
ngeOut.WriteDouble( m_dAddAdvance, ";", true) ;
|
||||
|
||||
return true ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
ExtText::Load( NgeReader& ngeIn)
|
||||
{
|
||||
// imposto ricalcolo della grafica
|
||||
m_OGrMgr.Reset() ;
|
||||
// leggo la prossima linea : punto, normale, direzione
|
||||
if ( ! ngeIn.ReadPoint( m_ptP, ";"))
|
||||
return false ;
|
||||
if ( ! ngeIn.ReadVector( m_vtN, ";"))
|
||||
return false ;
|
||||
if ( ! ngeIn.ReadVector( m_vtD, ";", true))
|
||||
return false ;
|
||||
// leggo la prossima linea : testo
|
||||
if ( ! ngeIn.ReadString( m_sText, nullptr, true))
|
||||
return false ;
|
||||
// leggo la prossima linea : font, spessore, italico, altezza, ratio, addAdvance
|
||||
if ( ! ngeIn.ReadString( m_sFont, ";"))
|
||||
return false ;
|
||||
if ( ! ngeIn.ReadInt( m_nWeight, ","))
|
||||
return false ;
|
||||
if ( ! ngeIn.ReadBool( m_bItalic, ","))
|
||||
return false ;
|
||||
if ( ! ngeIn.ReadDouble( m_dHeight, ","))
|
||||
return false ;
|
||||
if ( ! ngeIn.ReadDouble( m_dRatio, ","))
|
||||
return false ;
|
||||
if ( ! ngeIn.ReadDouble( m_dAddAdvance, ";", true))
|
||||
return false ;
|
||||
|
||||
return true ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
ExtText::GetLocalBBox( BBox3d& b3Loc) const
|
||||
{
|
||||
// recupero il font manager
|
||||
FontManager& fntMgr = FontManager::GetFontManager() ;
|
||||
|
||||
// imposto il font corrente e i suoi dati
|
||||
if ( ! fntMgr.SetCurrFont( m_sFont, m_nWeight, m_bItalic, m_dHeight, m_dRatio, m_dAddAdvance))
|
||||
return false ;
|
||||
|
||||
// richiedo il box
|
||||
if ( ! fntMgr.GetBBox( m_sText, b3Loc))
|
||||
return false ;
|
||||
|
||||
// calcolo ed eseguo la trasformazione
|
||||
Frame3d frRef ;
|
||||
if ( ! frRef.Set( m_ptP, m_vtN, m_vtD))
|
||||
return false ;
|
||||
b3Loc.ToGlob( frRef) ;
|
||||
|
||||
return true ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
ExtText::GetBBox( const Frame3d& frRef, BBox3d& b3Ref) const
|
||||
{
|
||||
// verifico validità del frame
|
||||
if ( frRef.GetType() == Frame3d::ERR)
|
||||
return false ;
|
||||
|
||||
// recupero il font manager
|
||||
FontManager& fntMgr = FontManager::GetFontManager() ;
|
||||
|
||||
// imposto il font corrente e i suoi dati
|
||||
if ( ! fntMgr.SetCurrFont( m_sFont, m_nWeight, m_bItalic, m_dHeight, m_dRatio, m_dAddAdvance))
|
||||
return false ;
|
||||
|
||||
// richiedo il box
|
||||
if ( ! fntMgr.GetBBox( m_sText, b3Ref))
|
||||
return false ;
|
||||
|
||||
// calcolo ed eseguo la prima trasformazione (per tener conto dell'orientamento del testo)
|
||||
Frame3d frTxt ;
|
||||
if ( ! frTxt.Set( m_ptP, m_vtN, m_vtD))
|
||||
return false ;
|
||||
b3Ref.ToGlob( frTxt) ;
|
||||
|
||||
// porto il box nel riferimento passato
|
||||
b3Ref.ToGlob( frRef) ;
|
||||
|
||||
return true ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
ExtText::Translate( const Vector3d& vtMove)
|
||||
{
|
||||
m_OGrMgr.Reset() ;
|
||||
m_ptP.Translate( vtMove) ;
|
||||
return true ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
ExtText::Rotate( const Point3d& ptAx, const Vector3d& vtAx, double dCosAng, double dSinAng)
|
||||
{
|
||||
m_OGrMgr.Reset() ;
|
||||
return ( m_ptP.Rotate( ptAx, vtAx, dCosAng, dSinAng) &&
|
||||
m_vtN.Rotate( vtAx, dCosAng, dSinAng) &&
|
||||
m_vtD.Rotate( vtAx, dCosAng, dSinAng)) ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
ExtText::Scale( const Frame3d& frRef, double dCoeffX, double dCoeffY, double dCoeffZ)
|
||||
{
|
||||
// verifico non sia nulla
|
||||
if ( fabs( dCoeffX) < EPS_ZERO && fabs( dCoeffY) < EPS_ZERO && fabs( dCoeffZ) < EPS_ZERO)
|
||||
return false ;
|
||||
|
||||
// imposto ricalcolo della grafica
|
||||
m_OGrMgr.Reset() ;
|
||||
|
||||
// scalo il punto di inserimento
|
||||
if ( ! m_ptP.Scale( frRef, dCoeffX, dCoeffY, dCoeffZ))
|
||||
return false ;
|
||||
|
||||
// calcolo il versore altezza testo
|
||||
Vector3d vtH = m_vtN ^ m_vtD ;
|
||||
vtH.Normalize() ;
|
||||
// scalo il versore direzione
|
||||
if ( ! m_vtD.Scale( frRef, dCoeffX, dCoeffY, dCoeffZ))
|
||||
return false ;
|
||||
double dScaleD = m_vtD.Len() ;
|
||||
m_vtD /= dScaleD ;
|
||||
// scalo il versore altezza testo
|
||||
if ( ! vtH.Scale( frRef, dCoeffX, dCoeffY, dCoeffZ))
|
||||
return false ;
|
||||
// per il coeff di scalatura considero solo la parte perpendicolare alla nuova direzione start
|
||||
double dScaleH = sqrt( vtH.SqLen() - ( vtH * m_vtD) *( vtH * m_vtD)) ;
|
||||
// aggiorno il vettore normale
|
||||
m_vtN = m_vtD ^ vtH ;
|
||||
m_vtN.Normalize() ;
|
||||
// aggiorno i parametri altezza testo e ratio
|
||||
m_dHeight *= dScaleH ;
|
||||
if ( dScaleH > EPS_ZERO)
|
||||
m_dRatio *= dScaleD / dScaleH ;
|
||||
|
||||
return true ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
ExtText::Mirror( const Point3d& ptOn, const Vector3d& vtNorm)
|
||||
{
|
||||
// imposto ricalcolo della grafica
|
||||
m_OGrMgr.Reset() ;
|
||||
|
||||
// eseguo il mirror del punto di inserimento
|
||||
if ( ! m_ptP.Mirror( ptOn, vtNorm))
|
||||
return false ;
|
||||
|
||||
// calcolo il versore altezza testo
|
||||
Vector3d vtH = m_vtN ^ m_vtD ;
|
||||
vtH.Normalize() ;
|
||||
// eseguo il mirror del versore direzione
|
||||
if ( ! m_vtD.Mirror( vtNorm))
|
||||
return false ;
|
||||
// eseguo il mirror del versore altezza testo
|
||||
if ( ! vtH.Mirror( vtNorm))
|
||||
return false ;
|
||||
// aggiorno il vettore normale
|
||||
m_vtN = m_vtD ^ vtH ;
|
||||
m_vtN.Normalize() ;
|
||||
|
||||
return true ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
ExtText::Shear( const Point3d& ptOn, const Vector3d& vtNorm, const Vector3d& vtDir, double dCoeff)
|
||||
{
|
||||
// verifico validità dei parametri
|
||||
if ( vtNorm.IsSmall() || vtDir.IsSmall())
|
||||
return false ;
|
||||
|
||||
// imposto ricalcolo della grafica
|
||||
m_OGrMgr.Reset() ;
|
||||
|
||||
// eseguo scorrimento del punto di inserimento
|
||||
if ( ! m_ptP.Shear( ptOn, vtNorm, vtDir, dCoeff))
|
||||
return false ;
|
||||
|
||||
// calcolo il versore altezza testo
|
||||
Vector3d vtH = m_vtN ^ m_vtD ;
|
||||
vtH.Normalize() ;
|
||||
// eseguo scorrimento del versore direzione
|
||||
if ( ! m_vtD.Shear( vtNorm, vtDir, dCoeff))
|
||||
return false ;
|
||||
double dScaleD = m_vtD.Len() ;
|
||||
m_vtD /= dScaleD ;
|
||||
// eseguo scorrimento del versore altezza testo
|
||||
if ( ! vtH.Shear( vtNorm, vtDir, dCoeff))
|
||||
return false ;
|
||||
// per il coeff di scalatura considero solo la parte perpendicolare alla nuova direzione start
|
||||
double dScaleH = sqrt( vtH.SqLen() - ( vtH * m_vtD) *( vtH * m_vtD)) ;
|
||||
// aggiorno il vettore normale
|
||||
m_vtN = m_vtD ^ vtH ;
|
||||
m_vtN.Normalize() ;
|
||||
// aggiorno i parametri altezza testo e ratio
|
||||
m_dHeight *= dScaleH ;
|
||||
if ( dScaleH > EPS_ZERO)
|
||||
m_dRatio *= dScaleD / dScaleH ;
|
||||
|
||||
return true ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
ExtText::ToGlob( const Frame3d& frRef)
|
||||
{
|
||||
// imposto ricalcolo della grafica
|
||||
m_OGrMgr.Reset() ;
|
||||
// trasformo punto e versori
|
||||
return ( m_ptP.ToGlob( frRef) &&
|
||||
m_vtN.ToGlob( frRef) &&
|
||||
m_vtD.ToGlob( frRef)) ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
ExtText::ToLoc( const Frame3d& frRef)
|
||||
{
|
||||
// imposto ricalcolo della grafica
|
||||
m_OGrMgr.Reset() ;
|
||||
// trasformo punto e versori
|
||||
return ( m_ptP.ToLoc( frRef) &&
|
||||
m_vtN.ToLoc( frRef) &&
|
||||
m_vtD.ToLoc( frRef)) ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
ExtText::LocToLoc( const Frame3d& frOri, const Frame3d& frDest)
|
||||
{
|
||||
// verifico validità dei frame
|
||||
if ( frOri.GetType() == Frame3d::ERR || frDest.GetType() == Frame3d::ERR)
|
||||
return false ;
|
||||
// se i due riferimenti coincidono, non devo fare alcunché
|
||||
if ( AreSameFrame( frOri, frDest))
|
||||
return true ;
|
||||
// imposto ricalcolo della grafica
|
||||
m_OGrMgr.Reset() ;
|
||||
// trasformo punto e versori
|
||||
return ( m_ptP.ToGlob( frOri) && m_ptP.ToLoc( frDest) &&
|
||||
m_vtN.ToGlob( frOri) && m_vtN.ToLoc( frDest) &&
|
||||
m_vtD.ToGlob( frOri) && m_vtD.ToLoc( frDest)) ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
ExtText::GetStartPoint( Point3d& ptStart) const
|
||||
{
|
||||
// assegno il punto
|
||||
ptStart = m_ptP ;
|
||||
|
||||
return true ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
ExtText::GetEndPoint( Point3d& ptEnd) 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 false ;
|
||||
|
||||
// richiedo la lunghezza
|
||||
double dLen ;
|
||||
if ( ! fntMgr.GetLength( m_sText, dLen))
|
||||
return false ;
|
||||
|
||||
// calcolo il punto
|
||||
ptEnd = m_ptP + m_vtD * dLen ;
|
||||
|
||||
return true ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
ExtText::GetMidPoint( Point3d& ptMid) 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 false ;
|
||||
|
||||
// richiedo la lunghezza
|
||||
double dLen ;
|
||||
if ( ! fntMgr.GetLength( m_sText, dLen))
|
||||
return false ;
|
||||
|
||||
// calcolo il punto
|
||||
ptMid = m_ptP + m_vtD * ( 0.5 * dLen) ;
|
||||
|
||||
return true ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
ExtText::GetCenterPoint( Point3d& ptCen) 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 false ;
|
||||
|
||||
// richiedo lunghezza e altezza delle maiuscole
|
||||
double dLen ;
|
||||
if ( ! fntMgr.GetLength( m_sText, dLen))
|
||||
return false ;
|
||||
double dCapH ;
|
||||
if ( ! fntMgr.GetCapHeight( dCapH))
|
||||
return false ;
|
||||
|
||||
// vettore diretto come l'altezza
|
||||
Vector3d vtH = m_vtN ^ m_vtD ;
|
||||
if ( ! vtH.Normalize())
|
||||
return false ;
|
||||
|
||||
// calcolo il punto
|
||||
ptCen = m_ptP + m_vtD * ( 0.5 * dLen) + vtH * ( 0.5 * dCapH) ;
|
||||
|
||||
return true ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
ExtText::GetOutline( ICURVEPLIST& lstPC) 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 false ;
|
||||
|
||||
// richiedo l'outline
|
||||
if ( ! fntMgr.GetOutline( m_sText, lstPC))
|
||||
return false ;
|
||||
|
||||
// calcolo la trasformazione
|
||||
Frame3d frRef ;
|
||||
if ( ! frRef.Set( m_ptP, m_vtN, m_vtD))
|
||||
return false ;
|
||||
|
||||
// eseguo la trasformazione
|
||||
ICURVEPLIST::iterator Iter ;
|
||||
for ( Iter = lstPC.begin() ; Iter != lstPC.end() ; ++ Iter)
|
||||
(*Iter)->ToGlob( frRef) ;
|
||||
|
||||
return true ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
ExtText::ApproxWithLines( double dLinTol, double dAngTolDeg, POLYLINELIST& lstPL) 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 false ;
|
||||
|
||||
// richiedo l'outline
|
||||
if ( ! fntMgr.ApproxWithLines( m_sText, dLinTol, dAngTolDeg, lstPL))
|
||||
return false ;
|
||||
|
||||
// calcolo la trasformazione
|
||||
Frame3d frRef ;
|
||||
if ( ! frRef.Set( m_ptP, m_vtN, m_vtD))
|
||||
return false ;
|
||||
|
||||
// eseguo la trasformazione
|
||||
POLYLINELIST::iterator Iter ;
|
||||
for ( Iter = lstPL.begin() ; Iter != lstPL.end() ; ++ Iter)
|
||||
Iter->ToGlob( frRef) ;
|
||||
|
||||
return true ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
ExtText::Flip( void)
|
||||
{
|
||||
// recupero il centro
|
||||
Point3d ptCen ;
|
||||
if ( ! GetCenterPoint( ptCen))
|
||||
return false ;
|
||||
// calcolo il nuovo punto di inserimento
|
||||
m_ptP += 2 * ( ptCen - m_ptP) ;
|
||||
// inverto la direzione di riferimento
|
||||
m_vtD *= -1 ;
|
||||
return true ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
ExtText::Mir( bool bOnLen)
|
||||
{
|
||||
// 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 false ;
|
||||
|
||||
// se auto-mirror sulla lunghezza del testo
|
||||
if ( bOnLen) {
|
||||
// richiedo lunghezza
|
||||
double dLen ;
|
||||
if ( ! fntMgr.GetLength( m_sText, dLen))
|
||||
return false ;
|
||||
// calcolo il punto
|
||||
m_ptP += m_vtD * dLen ;
|
||||
// inverto i versori
|
||||
m_vtN *= - 1 ;
|
||||
m_vtD *= - 1 ;
|
||||
}
|
||||
// altrimenti auto-mirror su altezza del testo
|
||||
else {
|
||||
// richiedo altezza delle maiuscole
|
||||
double dCapH ;
|
||||
if ( ! fntMgr.GetCapHeight( dCapH))
|
||||
return false ;
|
||||
// vettore diretto come l'altezza
|
||||
Vector3d vtH = m_vtN ^ m_vtD ;
|
||||
if ( ! vtH.Normalize())
|
||||
return false ;
|
||||
// calcolo il punto
|
||||
m_ptP += vtH * dCapH ;
|
||||
// inverto il versore normale
|
||||
m_vtN *= - 1 ;
|
||||
}
|
||||
|
||||
return true ;
|
||||
}
|
||||
@@ -0,0 +1,114 @@
|
||||
//----------------------------------------------------------------------------
|
||||
// EgalTech 2014-2014
|
||||
//----------------------------------------------------------------------------
|
||||
// File : ExtText.h Data : 27.05.14 Versione : 1.5f1
|
||||
// Contenuto : Dichiarazione della classe Testo.
|
||||
//
|
||||
//
|
||||
//
|
||||
// Modifiche : 27.05.14 DS Creazione modulo.
|
||||
//
|
||||
//
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "ObjGraphicsMgr.h"
|
||||
#include "DllMain.h"
|
||||
#include "GeoObjRW.h"
|
||||
#include "/EgtDev/Include/EGkExtText.h"
|
||||
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
class ExtText : public IExtText, public IGeoObjRW
|
||||
{
|
||||
public : // IGeoObj
|
||||
virtual ~ExtText( void) ;
|
||||
virtual ExtText* Clone( void) const ;
|
||||
virtual GeoObjType GetType( void) const ;
|
||||
virtual bool IsValid( void) const
|
||||
{ return true ; }
|
||||
virtual const std::string& GetTitle( void) const ;
|
||||
virtual bool Dump( std::string& sOut, const char* szNewLine = "\n") const ;
|
||||
virtual bool GetLocalBBox( BBox3d& b3Loc) const ;
|
||||
virtual bool GetBBox( const Frame3d& frRef, BBox3d& b3Ref) const ;
|
||||
virtual bool Translate( const Vector3d& vtMove) ;
|
||||
virtual bool Rotate( const Point3d& ptAx, const Vector3d& vtAx, double dAngDeg)
|
||||
{ double dAngRad = dAngDeg * DEGTORAD ;
|
||||
return Rotate( ptAx, vtAx, cos( dAngRad), sin( dAngRad)) ; }
|
||||
virtual bool Rotate( const Point3d& ptAx, const Vector3d& vtAx, double dCosAng, double dSinAng) ;
|
||||
virtual bool Scale( const Frame3d& frRef, double dCoeffX, double dCoeffY, double dCoeffZ) ;
|
||||
virtual bool Mirror( const Point3d& ptOn, const Vector3d& vtNorm) ;
|
||||
virtual bool Shear( const Point3d& ptOn, const Vector3d& vtNorm, const Vector3d& vtDir, double dCoeff) ;
|
||||
virtual bool ToGlob( const Frame3d& frRef) ;
|
||||
virtual bool ToLoc( const Frame3d& frRef) ;
|
||||
virtual bool LocToLoc( const Frame3d& frOri, const Frame3d& frDest) ;
|
||||
virtual void SetObjGraphics( IObjGraphics* pOGr)
|
||||
{ m_OGrMgr.SetObjGraphics( pOGr) ; }
|
||||
virtual IObjGraphics* GetObjGraphics( void)
|
||||
{ return m_OGrMgr.GetObjGraphics() ; }
|
||||
virtual const IObjGraphics* GetObjGraphics( void) const
|
||||
{ return m_OGrMgr.GetObjGraphics() ; }
|
||||
|
||||
public : // IExtText
|
||||
virtual bool Copy( const IGeoObj* pGObjSrc) ;
|
||||
virtual bool Set( const std::string& sText, const Point3d& ptP, double dAngDeg, double dH) ;
|
||||
virtual bool Set( const std::string& sText, const Point3d& ptP, double dAngDeg,
|
||||
const std::string& sFont, int nW, bool bItl, double dH, double dRat, double dAddAdv) ;
|
||||
virtual const Point3d& GetPoint( void) const
|
||||
{ return m_ptP ; }
|
||||
virtual const Vector3d& GetNormVersor( void) const
|
||||
{ return m_vtN ; }
|
||||
virtual const Vector3d& GetDirVersor( void) const
|
||||
{ return m_vtD ; }
|
||||
virtual const std::string& GetText( void) const
|
||||
{ return m_sText ; }
|
||||
virtual const std::string& GetFont( void) const
|
||||
{ return m_sFont ; }
|
||||
virtual int GetWeight( void) const
|
||||
{ return m_nWeight ; }
|
||||
virtual bool GetItalic( void) const
|
||||
{ return m_bItalic ; }
|
||||
virtual double GetHeight( void) const
|
||||
{ return m_dHeight ; }
|
||||
virtual double GetRatio( void) const
|
||||
{ return m_dRatio ; }
|
||||
virtual double GetAddAdvance( void) const
|
||||
{ return m_dAddAdvance ; }
|
||||
virtual bool GetStartPoint( Point3d& ptStart) const ;
|
||||
virtual bool GetEndPoint( Point3d& ptEnd) const ;
|
||||
virtual bool GetMidPoint( Point3d& ptMid) const ;
|
||||
virtual bool GetCenterPoint( Point3d& ptCen) const ;
|
||||
virtual bool GetOutline( ICURVEPLIST& lstPC) const ;
|
||||
virtual bool ApproxWithLines( double dLinTol, double dAngTolDeg, POLYLINELIST& lstPL) const ;
|
||||
virtual bool Flip( void) ;
|
||||
virtual bool Mir( bool bOnLen) ;
|
||||
|
||||
public : // IGeoObjRW
|
||||
virtual int GetNgeId( void) const ;
|
||||
virtual bool Save( NgeWriter& ngeOut) const ;
|
||||
virtual bool Load( NgeReader& ngeIn) ;
|
||||
|
||||
public :
|
||||
ExtText( void) ;
|
||||
const ExtText& operator =( const ExtText& gpSrc)
|
||||
{ if ( ! Copy( gpSrc))
|
||||
LOG_ERROR( GetEGkLogger(), "ExtText : copy error")
|
||||
return *this ; }
|
||||
|
||||
private :
|
||||
bool Copy( const ExtText& gpSrc) ;
|
||||
|
||||
private :
|
||||
ObjGraphicsMgr m_OGrMgr ; // gestore grafica dell'oggetto
|
||||
Point3d m_ptP ; // punto di inserimento
|
||||
Vector3d m_vtN ; // versore normale
|
||||
Vector3d m_vtD ; // versore di direzione
|
||||
std::string m_sText ; // testo con codifica UTF-8
|
||||
std::string m_sFont ; // font utilizzato
|
||||
int m_nWeight ; // 0 (don't care), 100 (thin) - 900 (black)
|
||||
bool m_bItalic ; // flag per italico (inclinato)
|
||||
double m_dHeight ; // altezza del carattere
|
||||
double m_dRatio ; // rapporto tra larghezza e altezza
|
||||
double m_dAddAdvance ; // avanzamento addizionale tra caratteri
|
||||
} ;
|
||||
+130
@@ -0,0 +1,130 @@
|
||||
//----------------------------------------------------------------------------
|
||||
// EgalTech 2014-2014
|
||||
//----------------------------------------------------------------------------
|
||||
// File : FontManager.cpp Data : 28.05.14 Versione : 1.5f1
|
||||
// Contenuto : Implementazione della classe FontManager.
|
||||
//
|
||||
//
|
||||
//
|
||||
// Modifiche : 28.05.14 DS Creazione modulo.
|
||||
//
|
||||
//
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
//--------------------------- Include ----------------------------------------
|
||||
#include "stdafx.h"
|
||||
#include "FontManager.h"
|
||||
#include "/EgtDev/Include/EGkGeomDB.h"
|
||||
#include "/EgtDev/Include/EGkGdbIterator.h"
|
||||
#include "/EgtDev/Include/EGkCurve.h"
|
||||
#include "/EgtDev/Include/EgtPointerOwner.h"
|
||||
#include "/EgtDev/Include/EgnStringUtils.h"
|
||||
#include "/EgtDev/Include/EgnFileUtils.h"
|
||||
|
||||
using namespace std ;
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
FontManager::Init( const std::string& sNfeFontDir, const std::string& sDefaultFont)
|
||||
{
|
||||
// assegno direttorio file per font Nfe
|
||||
m_sNfeFontDir = sNfeFontDir ;
|
||||
TrimRight( m_sNfeFontDir, " \\") ;
|
||||
// assegno nome font di default
|
||||
m_sDefaultFont = sDefaultFont ;
|
||||
return true ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
FontManager::SetCurrFont( const std::string& sFont, int nWeight, bool bItalic,
|
||||
double dHeight, double dRatio, double dAddAdvance)
|
||||
{
|
||||
// gestione font di default
|
||||
string sTFont = (( sFont.empty()) ? m_sDefaultFont : sFont) ;
|
||||
// lo cerco tra i font Nfe
|
||||
if ( FileExtensionMatches( sTFont, "NFE")) {
|
||||
m_bCurrNfeFont = true ;
|
||||
if ( ! m_NfeFont.SetCurrFont( m_sNfeFontDir + "\\" + sTFont, nWeight, bItalic,
|
||||
dHeight, dRatio, dAddAdvance))
|
||||
return false ;
|
||||
}
|
||||
// altrimenti lo cerco tra i font di sistema
|
||||
else {
|
||||
m_bCurrNfeFont = false ;
|
||||
if ( ! m_OsFont.SetCurrFont( sTFont, nWeight, bItalic, dHeight, dRatio, dAddAdvance))
|
||||
return false ;
|
||||
}
|
||||
|
||||
return true ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
FontManager::GetCapHeight( double& dCapH)
|
||||
{
|
||||
if ( m_bCurrNfeFont)
|
||||
return m_NfeFont.GetCapHeight( dCapH) ;
|
||||
else
|
||||
return m_OsFont.GetCapHeight( dCapH) ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
FontManager::GetAscent( double& dAsc)
|
||||
{
|
||||
if ( m_bCurrNfeFont)
|
||||
return m_NfeFont.GetAscent( dAsc) ;
|
||||
else
|
||||
return m_OsFont.GetAscent( dAsc) ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
FontManager::GetDescent( double& dDesc)
|
||||
{
|
||||
if ( m_bCurrNfeFont)
|
||||
return m_NfeFont.GetDescent( dDesc) ;
|
||||
else
|
||||
return m_OsFont.GetDescent( dDesc) ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
FontManager::GetLength( const string& sText, double& dLen)
|
||||
{
|
||||
if ( m_bCurrNfeFont)
|
||||
return m_NfeFont.GetLength( sText, dLen) ;
|
||||
else
|
||||
return m_OsFont.GetLength( sText, dLen) ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
FontManager::GetBBox( const string& sText, BBox3d& b3Box)
|
||||
{
|
||||
if ( m_bCurrNfeFont)
|
||||
return m_NfeFont.GetBBox( sText, b3Box) ;
|
||||
else
|
||||
return m_OsFont.GetBBox( sText, b3Box) ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
FontManager::GetOutline( const string& sText, ICURVEPLIST& lstPC)
|
||||
{
|
||||
if ( m_bCurrNfeFont)
|
||||
return m_NfeFont.GetOutline( sText, lstPC) ;
|
||||
else
|
||||
return m_OsFont.GetOutline( sText, lstPC) ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
FontManager::ApproxWithLines( const string& sText, double dLinTol, double dAngTolDeg, POLYLINELIST& lstPL)
|
||||
{
|
||||
if ( m_bCurrNfeFont)
|
||||
return m_NfeFont.ApproxWithLines( sText, dLinTol, dAngTolDeg, lstPL) ;
|
||||
else
|
||||
return m_OsFont.ApproxWithLines( sText, dLinTol, dAngTolDeg, lstPL) ;
|
||||
}
|
||||
@@ -0,0 +1,53 @@
|
||||
//----------------------------------------------------------------------------
|
||||
// EgalTech 2014-2014
|
||||
//----------------------------------------------------------------------------
|
||||
// File : FontManager.h Data : 28.05.14 Versione : 1.5f1
|
||||
// Contenuto : Dichiarazione della classe FontManager.
|
||||
//
|
||||
//
|
||||
//
|
||||
// Modifiche : 28.05.14 DS Creazione modulo.
|
||||
//
|
||||
//
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "NfeFont.h"
|
||||
#include "OsFont.h"
|
||||
#include "/EgtDev/Include/EGkBBox3d.h"
|
||||
#include "/EgtDev/Include/EGkPolyLine.h"
|
||||
#include <string>
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
class FontManager
|
||||
{
|
||||
public :
|
||||
bool Init( const std::string& sNfeFontDir, const std::string& sDefaultFont) ;
|
||||
bool SetCurrFont( const std::string& sFont, int nWeight, bool bItalic,
|
||||
double dHeight, double dRatio, double dAddAdvance) ;
|
||||
bool GetCapHeight( double& dCapH) ;
|
||||
bool GetAscent( double& dAsc) ;
|
||||
bool GetDescent( double& dDesc) ;
|
||||
bool GetLength( const std::string& sText, double& dLen) ;
|
||||
bool GetBBox( const std::string& sText, BBox3d& b3Box) ;
|
||||
bool GetOutline( const std::string& sText, ICURVEPLIST& lstPC) ;
|
||||
bool ApproxWithLines( const std::string& sText, double dLinTol, double dAngTolDeg, POLYLINELIST& lstPL) ;
|
||||
|
||||
private :
|
||||
std::string m_sNfeFontDir ;
|
||||
std::string m_sDefaultFont ;
|
||||
bool m_bCurrNfeFont ;
|
||||
NfeFont m_NfeFont ;
|
||||
OsFont m_OsFont ;
|
||||
|
||||
public :
|
||||
static FontManager& GetFontManager( void)
|
||||
{ static FontManager fntMgr ;
|
||||
return fntMgr ; }
|
||||
|
||||
private :
|
||||
FontManager( void) {}
|
||||
FontManager( FontManager const& copy) ; // Not Implemented
|
||||
FontManager& operator=( FontManager const& copy) ; // Not Implemented
|
||||
} ;
|
||||
+72
-8
@@ -117,6 +117,39 @@ Frame3d::Set( const Point3d& ptOrig, const Vector3d& vtDirZ)
|
||||
return true ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
Frame3d::Set( const Point3d& ptOrig, const Vector3d& vtDirZ, const Vector3d& vtNearDirX)
|
||||
{
|
||||
// lo inizializzo come errato
|
||||
m_nType = ERR ;
|
||||
m_nZType = ERR ;
|
||||
|
||||
// origine
|
||||
m_ptOrig = ptOrig ;
|
||||
// versore Z
|
||||
m_vtVersZ = vtDirZ ;
|
||||
if ( ! m_vtVersZ.Normalize())
|
||||
return false ;
|
||||
// versore Y
|
||||
m_vtVersY = m_vtVersZ ^ vtNearDirX ;
|
||||
if ( ! m_vtVersY.Normalize())
|
||||
return false ;
|
||||
// verzsore X
|
||||
m_vtVersX = m_vtVersY ^ m_vtVersZ ;
|
||||
if ( ! m_vtVersX.Normalize())
|
||||
return false ;
|
||||
|
||||
// verifica della ortogonalità dei versori e del senso destrorso
|
||||
if ( ! Verify())
|
||||
return false ;
|
||||
|
||||
// ne determino il tipo
|
||||
CalculateType() ;
|
||||
|
||||
return true ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
Frame3d::Set( const Point3d& ptOrig, Type nType)
|
||||
@@ -201,8 +234,9 @@ Frame3d::Translate( const Vector3d& vtMove)
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
Frame3d::Rotate( const Point3d& ptAx, const Vector3d& vtAx, double dAngRad)
|
||||
Frame3d::Rotate( const Point3d& ptAx, const Vector3d& vtAx, double dAngDeg)
|
||||
{
|
||||
double dAngRad = dAngDeg * DEGTORAD ;
|
||||
return Rotate( ptAx, vtAx, cos( dAngRad), sin( dAngRad)) ;
|
||||
}
|
||||
|
||||
@@ -236,8 +270,8 @@ Frame3d::PseudoScale( const Frame3d& frRef, double dCoeffX, double dCoeffY, doub
|
||||
{
|
||||
const double AXIS_LEN = 100 ;
|
||||
|
||||
// verifico validità del frame
|
||||
if ( GetType() == ERR || frRef.GetType() == ERR)
|
||||
// verifico validità dei frame
|
||||
if ( m_nType == ERR || frRef.GetType() == ERR)
|
||||
return false ;
|
||||
|
||||
// scalatura dell'origine
|
||||
@@ -261,17 +295,20 @@ Frame3d::PseudoScale( const Frame3d& frRef, double dCoeffX, double dCoeffY, doub
|
||||
Point3d ptDirYS = m_ptOrig + AXIS_LEN * m_vtVersY ;
|
||||
ptDirYS.Scale( frRef, dCoeffX, dCoeffY, dCoeffZ) ;
|
||||
Frame3d frRefS ;
|
||||
if ( frRefS.Set( ptOrigS, ptDirXS, ptDirYS)) {
|
||||
*this = frRefS ;
|
||||
return true ;
|
||||
}
|
||||
return false ;
|
||||
if ( ! frRefS.Set( ptOrigS, ptDirXS, ptDirYS))
|
||||
return false ;
|
||||
*this = frRefS ;
|
||||
return true ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
Frame3d::PseudoMirror( const Point3d& ptOn, const Vector3d& vtNorm)
|
||||
{
|
||||
// verifico validità riferimento
|
||||
if ( m_nType == ERR)
|
||||
return false ;
|
||||
|
||||
// mirror dell'origine
|
||||
m_ptOrig.Mirror( ptOn, vtNorm) ;
|
||||
// mirror dei versori Y e Z
|
||||
@@ -286,6 +323,33 @@ Frame3d::PseudoMirror( const Point3d& ptOn, const Vector3d& vtNorm)
|
||||
return true ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
Frame3d::PseudoShear( const Point3d& ptOn, const Vector3d& vtNorm, const Vector3d& vtDir, double dCoeff)
|
||||
{
|
||||
const double AXIS_LEN = 100 ;
|
||||
|
||||
// verifico validità riferimento
|
||||
if ( m_nType == ERR)
|
||||
return false ;
|
||||
|
||||
// shear dell'origine e di due punti sugli assi X e Y
|
||||
Point3d ptOrigS = m_ptOrig ;
|
||||
ptOrigS.Shear( ptOn, vtNorm, vtDir, dCoeff) ;
|
||||
Point3d ptDirXS = m_ptOrig + AXIS_LEN * m_vtVersX ;
|
||||
ptDirXS.Shear( ptOn, vtNorm, vtDir, dCoeff) ;
|
||||
Point3d ptDirYS = m_ptOrig + AXIS_LEN * m_vtVersY ;
|
||||
ptDirYS.Shear( ptOn, vtNorm, vtDir, dCoeff) ;
|
||||
|
||||
// calcolo di un nuovo riferimento
|
||||
Frame3d frRefS ;
|
||||
if ( ! frRefS.Set( ptOrigS, ptDirXS, ptDirYS))
|
||||
return false ;
|
||||
// assegnazione del risultato
|
||||
*this = frRefS ;
|
||||
return true ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
Frame3d::Invert( void)
|
||||
|
||||
+301
-10
@@ -31,6 +31,7 @@
|
||||
#include "/EgtDev/Include/EgkCurveComposite.h"
|
||||
#include "/EgtDev/Include/EgkDistPointCurve.h"
|
||||
#include "/EgtDev/Include/EgkSurfTriMesh.h"
|
||||
#include "/EgtDev/Include/EgkExtText.h"
|
||||
#include "/EgtDev/Include/EgtPointerOwner.h"
|
||||
#include "/EgtDev/Include/EGkStmFromTriangleSoup.h"
|
||||
|
||||
@@ -73,6 +74,7 @@ GdbExecutor::GdbExecutor( void)
|
||||
m_ExecMgr.Insert( "CURVECOMPO", &GdbExecutor::ExecuteCurveCompo) ;
|
||||
m_ExecMgr.Insert( "STM", &GdbExecutor::ExecuteSurfTriMesh) ;
|
||||
m_ExecMgr.Insert( "SURFTRIMESH", &GdbExecutor::ExecuteSurfTriMesh) ;
|
||||
m_ExecMgr.Insert( "TEXT", &GdbExecutor::ExecuteText) ;
|
||||
m_ExecMgr.Insert( "LEV", &GdbExecutor::ExecuteLevel) ;
|
||||
m_ExecMgr.Insert( "LEVEL", &GdbExecutor::ExecuteLevel) ;
|
||||
m_ExecMgr.Insert( "MOD", &GdbExecutor::ExecuteMode) ;
|
||||
@@ -103,6 +105,7 @@ GdbExecutor::GdbExecutor( void)
|
||||
m_ExecMgr.Insert( "SCALE", &GdbExecutor::ExecuteScale) ;
|
||||
m_ExecMgr.Insert( "MIR", &GdbExecutor::ExecuteMirror) ;
|
||||
m_ExecMgr.Insert( "MIRROR", &GdbExecutor::ExecuteMirror) ;
|
||||
m_ExecMgr.Insert( "SHEAR", &GdbExecutor::ExecuteShear) ;
|
||||
m_ExecMgr.Insert( "INVC", &GdbExecutor::ExecuteInvertCurve) ;
|
||||
m_ExecMgr.Insert( "INVERTCURVE", &GdbExecutor::ExecuteInvertCurve) ;
|
||||
m_ExecMgr.Insert( "INVS", &GdbExecutor::ExecuteInvertSurf) ;
|
||||
@@ -1904,6 +1907,186 @@ GdbExecutor::SurfTriMeshDoSewing( const STRVECTOR& vsParams)
|
||||
return true ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
GdbExecutor::ExecuteText( const string& sCmd2, const STRVECTOR& vsParams)
|
||||
{
|
||||
// testo nel piano locale
|
||||
if ( sCmd2 == "XY" || sCmd2 == "PLANEXY") {
|
||||
if ( vsParams.size() == 6)
|
||||
return TextSimple( vsParams) ;
|
||||
else
|
||||
return TextComplete( vsParams) ;
|
||||
}
|
||||
// flip del testo
|
||||
else if ( sCmd2 == "FLIP") {
|
||||
return TextFlip( vsParams) ;
|
||||
}
|
||||
// auto-mirror del testo
|
||||
else if ( sCmd2 == "MIR") {
|
||||
return TextMir( vsParams) ;
|
||||
}
|
||||
// estrazione dei contorni
|
||||
else if ( sCmd2 == "OUTLINE")
|
||||
return TextOutline( vsParams) ;
|
||||
else
|
||||
return false ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
GdbExecutor::TextSimple( const STRVECTOR& vsParams)
|
||||
{
|
||||
// parametri : Id, ParentId, Text, Point, AngDeg, H
|
||||
if ( vsParams.size() != 6)
|
||||
return false ;
|
||||
// recupero il riferimento in cui è immerso
|
||||
Frame3d frRef ;
|
||||
if ( ! m_pGDB->GetGroupGlobFrame( GetIdParam( vsParams[1]), frRef))
|
||||
return false ;
|
||||
// recupero il punto di inserimento
|
||||
Point3d ptP ;
|
||||
if ( ! GetPointParam( vsParams[3], frRef, ptP))
|
||||
return false ;
|
||||
// recupero l'angolo di rotazione
|
||||
double dAngRotDeg ;
|
||||
if ( ! FromString( vsParams[4], dAngRotDeg))
|
||||
return false ;
|
||||
// recupero l'altezza del carattere
|
||||
double dH ;
|
||||
if ( ! FromString( vsParams[5], dH))
|
||||
return false ;
|
||||
// creo il testo
|
||||
PtrOwner<IExtText> pTXT( CreateExtText()) ;
|
||||
if ( ! IsValid( pTXT))
|
||||
return false ;
|
||||
// lo riempio
|
||||
if ( ! pTXT->Set( vsParams[2], ptP, dAngRotDeg, dH))
|
||||
return false ;
|
||||
// inserisco il testo nel DB
|
||||
return AddGeoObj( vsParams[0], vsParams[1], Release( pTXT)) ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
GdbExecutor::TextComplete( const STRVECTOR& vsParams)
|
||||
{
|
||||
// parametri : Id, ParentId, Text, Point, AngDeg, Font, W, Italic, H, Rat, AddAdv
|
||||
if ( vsParams.size() != 11)
|
||||
return false ;
|
||||
// recupero il riferimento in cui è immerso
|
||||
Frame3d frRef ;
|
||||
if ( ! m_pGDB->GetGroupGlobFrame( GetIdParam( vsParams[1]), frRef))
|
||||
return false ;
|
||||
// recupero il punto di inserimento
|
||||
Point3d ptP ;
|
||||
if ( ! GetPointParam( vsParams[3], frRef, ptP))
|
||||
return false ;
|
||||
// recupero l'angolo di rotazione
|
||||
double dAngRotDeg ;
|
||||
if ( ! FromString( vsParams[4], dAngRotDeg))
|
||||
return false ;
|
||||
// font
|
||||
// recupero il peso (larghezza del filamento)
|
||||
int nW ;
|
||||
if ( ! FromString( vsParams[6], nW))
|
||||
return false ;
|
||||
// recupero il flag di italico
|
||||
bool bItl = ( vsParams[7] == "I" || vsParams[7] == "i") ;
|
||||
// recupero l'altezza del carattere
|
||||
double dH ;
|
||||
if ( ! FromString( vsParams[8], dH))
|
||||
return false ;
|
||||
// rapporto larghezza/altezza del carattere
|
||||
double dRat ;
|
||||
if ( ! FromString( vsParams[9], dRat))
|
||||
return false ;
|
||||
// avanzamento aggiuntivo
|
||||
double dAddAdv ;
|
||||
if ( ! FromString( vsParams[10], dAddAdv))
|
||||
return false ;
|
||||
// creo il testo
|
||||
PtrOwner<IExtText> pTXT( CreateExtText()) ;
|
||||
if ( ! IsValid( pTXT))
|
||||
return false ;
|
||||
// lo riempio
|
||||
if ( ! pTXT->Set( vsParams[2], ptP, dAngRotDeg, vsParams[5], nW, bItl, dH, dRat, dAddAdv))
|
||||
return false ;
|
||||
// inserisco il testo nel DB
|
||||
return AddGeoObj( vsParams[0], vsParams[1], Release( pTXT)) ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
GdbExecutor::TextFlip( const STRVECTOR& vsParams)
|
||||
{
|
||||
// 1 parametro : Id
|
||||
if ( vsParams.size() != 1)
|
||||
return false ;
|
||||
// recupero il testo
|
||||
IExtText* pTXT = GetExtText( m_pGDB->GetGeoObj( GetIdParam( vsParams[0]))) ;
|
||||
if ( pTXT == nullptr)
|
||||
return false ;
|
||||
// eseguo l'operazione
|
||||
return pTXT->Flip() ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
GdbExecutor::TextMir( const STRVECTOR& vsParams)
|
||||
{
|
||||
// 1 o 2 parametri : Id [, LorH]
|
||||
if ( vsParams.size() != 1 && vsParams.size() != 2)
|
||||
return false ;
|
||||
// calcolo il flag
|
||||
bool bOnL = true ;
|
||||
if ( vsParams.size() == 2)
|
||||
bOnL = ( vsParams[1] != "H" && vsParams[1] != "h") ;
|
||||
// recupero il testo
|
||||
IExtText* pTXT = GetExtText( m_pGDB->GetGeoObj( GetIdParam( vsParams[0]))) ;
|
||||
if ( pTXT == nullptr)
|
||||
return false ;
|
||||
// eseguo l'operazione
|
||||
return pTXT->Mir( bOnL) ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
GdbExecutor::TextOutline( const STRVECTOR& vsParams)
|
||||
{
|
||||
// 2 parametri : Id , IdDest
|
||||
if ( vsParams.size() != 2)
|
||||
return false ;
|
||||
// recupero il testo
|
||||
int nIdTXT = GetIdParam( vsParams[0]) ;
|
||||
IExtText* pTXT = GetExtText( m_pGDB->GetGeoObj( nIdTXT)) ;
|
||||
if ( pTXT == nullptr)
|
||||
return false ;
|
||||
// recupero il suo outline
|
||||
ICURVEPLIST lstPCRV ;
|
||||
pTXT->GetOutline( lstPCRV) ;
|
||||
// recupero il riferimento del testo
|
||||
Frame3d frTXT ;
|
||||
if ( ! m_pGDB->GetGlobFrame( nIdTXT, frTXT))
|
||||
return false ;
|
||||
// recupero il riferimento del gruppo destinazione
|
||||
int nIdDest = GetIdParam( vsParams[1]) ;
|
||||
Frame3d frDest ;
|
||||
if ( ! m_pGDB->GetGroupGlobFrame( nIdDest, frDest))
|
||||
return false ;
|
||||
// inserisco le curve nel gruppo destinazione dopo aver sistemato il cambio di riferimento
|
||||
bool bOk = true ;
|
||||
ICURVEPLIST::iterator iIter ;
|
||||
for ( iIter = lstPCRV.begin() ; iIter != lstPCRV.end() ; ++ iIter) {
|
||||
(*iIter)->LocToLoc( frTXT, frDest) ;
|
||||
if ( ! m_pGDB->AddGeoObj( GDB_ID_NULL, nIdDest, (*iIter))) {
|
||||
delete (*iIter) ;
|
||||
bOk = false ;
|
||||
}
|
||||
}
|
||||
return bOk ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
GdbExecutor::AddGeoObj( const string& sId, const string& sIdParent, IGeoObj* pGeoObj)
|
||||
@@ -2257,8 +2440,29 @@ GdbExecutor::GetPointParam( const string& sParam, const Frame3d& frPnt, Point3d&
|
||||
case 'O' : // origine
|
||||
ptP = pGF->GetFrame().Orig() ;
|
||||
return ptP.LocToLoc( frEnt, frPnt) ;
|
||||
default :
|
||||
return false ;
|
||||
}
|
||||
}
|
||||
// se testo
|
||||
else if ( pGObj->GetType() == EXT_TEXT) {
|
||||
// recupero il testo
|
||||
const IExtText* pTxt = GetExtText( pGObj) ;
|
||||
switch ( cType) {
|
||||
case 'S' : // punto iniziale
|
||||
if ( ! pTxt->GetStartPoint( ptP))
|
||||
return false ;
|
||||
return ptP.LocToLoc( frEnt, frPnt) ;
|
||||
case 'E' : // punto finale
|
||||
if ( ! pTxt->GetEndPoint( ptP))
|
||||
return false ;
|
||||
return ptP.LocToLoc( frEnt, frPnt) ;
|
||||
case 'M' : // punto medio
|
||||
if ( ! pTxt->GetMidPoint( ptP))
|
||||
return false ;
|
||||
return ptP.LocToLoc( frEnt, frPnt) ;
|
||||
case 'C' : // centro
|
||||
if ( ! pTxt->GetCenterPoint( ptP))
|
||||
return false ;
|
||||
return ptP.LocToLoc( frEnt, frPnt) ;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -3109,18 +3313,28 @@ GdbExecutor::ExecuteMatLibrary( const string& sCmd2, const STRVECTOR& vsParams)
|
||||
bool
|
||||
GdbExecutor::ExecuteCopy( const string& sCmd2, const STRVECTOR& vsParams)
|
||||
{
|
||||
// 3 parametri ( IdSou, IdDest, ParentIdDest)
|
||||
if ( vsParams.size() != 3)
|
||||
// 3 o 4 parametri : IdSou, IdDest, RefIdDest [, SonBeforeAfter]
|
||||
if ( vsParams.size() != 3 && vsParams.size() != 4)
|
||||
return false ;
|
||||
// recupero tipo di inserimento della copia
|
||||
int nSonBeforeAfter = GDB_SON ;
|
||||
if ( vsParams.size() == 4) {
|
||||
string sFlag = vsParams[3] ;
|
||||
ToUpper( sFlag) ;
|
||||
if ( sFlag == "BEFORE")
|
||||
nSonBeforeAfter = GDB_BEFORE ;
|
||||
else if ( sFlag == "AFTER")
|
||||
nSonBeforeAfter = GDB_AFTER ;
|
||||
}
|
||||
// recupero flag per globale
|
||||
bool bGlob = ( sCmd2 == "GLOB" || sCmd2 == "G") ;
|
||||
// esecuzione copia
|
||||
int nIdDest = GetIdParam( vsParams[1], true) ;
|
||||
int nIdNew ;
|
||||
if ( bGlob)
|
||||
nIdNew = m_pGDB->CopyGlob( GetIdParam( vsParams[0]), nIdDest, GetIdParam( vsParams[2])) ;
|
||||
nIdNew = m_pGDB->CopyGlob( GetIdParam( vsParams[0]), nIdDest, GetIdParam( vsParams[2]), nSonBeforeAfter) ;
|
||||
else
|
||||
nIdNew = m_pGDB->Copy( GetIdParam( vsParams[0]), nIdDest, GetIdParam( vsParams[2])) ;
|
||||
nIdNew = m_pGDB->Copy( GetIdParam( vsParams[0]), nIdDest, GetIdParam( vsParams[2]), nSonBeforeAfter) ;
|
||||
// se IdDest da calcolare, può essere una variabili a cui cambiare il valore
|
||||
if ( nIdDest == GDB_ID_NULL)
|
||||
m_pParser->SetVariable( vsParams[1], nIdNew) ;
|
||||
@@ -3132,24 +3346,34 @@ GdbExecutor::ExecuteCopy( const string& sCmd2, const STRVECTOR& vsParams)
|
||||
bool
|
||||
GdbExecutor::ExecuteRelocate( const string& sCmd2, const STRVECTOR& vsParams)
|
||||
{
|
||||
// 2 parametri ( Id, NewParentId)
|
||||
if ( vsParams.size() != 2)
|
||||
// 2 o 3 parametri : Id, NewRefId [, SonBeforeAfter]
|
||||
if ( vsParams.size() != 2 && vsParams.size() != 3)
|
||||
return false ;
|
||||
// recupero lista nomi
|
||||
INTVECTOR vnNames ;
|
||||
if ( ! GetNamesParam( vsParams[0], vnNames))
|
||||
return false ;
|
||||
// recupero tipo di inserimento
|
||||
int nSonBeforeAfter = GDB_SON ;
|
||||
if ( vsParams.size() == 3) {
|
||||
string sFlag = vsParams[2] ;
|
||||
ToUpper( sFlag) ;
|
||||
if ( sFlag == "BEFORE")
|
||||
nSonBeforeAfter = GDB_BEFORE ;
|
||||
else if ( sFlag == "AFTER")
|
||||
nSonBeforeAfter = GDB_AFTER ;
|
||||
}
|
||||
// recupero flag per globale
|
||||
bool bGlob = ( sCmd2 == "GLOB" || sCmd2 == "G") ;
|
||||
// esecuzione rilocazioni
|
||||
INTVECTOR::iterator Iter ;
|
||||
for ( Iter = vnNames.begin() ; Iter != vnNames.end() ; ++Iter) {
|
||||
if ( bGlob) {
|
||||
if ( ! m_pGDB->RelocateGlob( *Iter, GetIdParam( vsParams[1])))
|
||||
if ( ! m_pGDB->RelocateGlob( *Iter, GetIdParam( vsParams[1]), nSonBeforeAfter))
|
||||
return false ;
|
||||
}
|
||||
else {
|
||||
if ( ! m_pGDB->Relocate( *Iter, GetIdParam( vsParams[1])))
|
||||
if ( ! m_pGDB->Relocate( *Iter, GetIdParam( vsParams[1]), nSonBeforeAfter))
|
||||
return false ;
|
||||
}
|
||||
}
|
||||
@@ -3426,6 +3650,73 @@ GdbExecutor::ExecuteMirror( const string& sCmd2, const STRVECTOR& vsParams)
|
||||
return true ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
GdbExecutor::ExecuteShear( const string& sCmd2, const STRVECTOR& vsParams)
|
||||
{
|
||||
// 5 parametri ( Nome, Punto, VettNorm, VettDir, Coeff)
|
||||
if ( vsParams.size() != 5)
|
||||
return false ;
|
||||
// recupero lista nomi
|
||||
INTVECTOR vnNames ;
|
||||
if ( ! GetNamesParam( vsParams[0], vnNames))
|
||||
return false ;
|
||||
// recupero flag e riferimento per globale/gruppo/locale
|
||||
enum { MIR_LOC = 0, MIR_GLOB = 1, MIR_GROUP = 2} ;
|
||||
int nMirType ;
|
||||
Frame3d frRef ;
|
||||
if ( sCmd2 == "GLOB" || sCmd2 == "G") {
|
||||
nMirType = MIR_GLOB ;
|
||||
frRef = GLOB_FRM ;
|
||||
}
|
||||
else if ( sCmd2 == "GROUP" || sCmd2 == "GR") {
|
||||
nMirType = MIR_GROUP ;
|
||||
if ( ! m_pGDB->GetGroupGlobFrame( vnNames[0], frRef))
|
||||
return false ;
|
||||
}
|
||||
else {
|
||||
nMirType = MIR_LOC ;
|
||||
if ( ! m_pGDB->GetGlobFrame( vnNames[0], frRef))
|
||||
return false ;
|
||||
}
|
||||
// recupero il punto
|
||||
Point3d ptPC ;
|
||||
if ( ! GetPointParam( vsParams[1], frRef, ptPC))
|
||||
return false ;
|
||||
// recupero il versore normale
|
||||
Vector3d vtNorm ;
|
||||
if ( ! GetVectorParam( vsParams[2], frRef, vtNorm))
|
||||
return false ;
|
||||
// recupero il versore direzione
|
||||
Vector3d vtDir ;
|
||||
if ( ! GetVectorParam( vsParams[3], frRef, vtDir))
|
||||
return false ;
|
||||
// recupero il coefficiente
|
||||
double dCoeff ;
|
||||
if ( ! FromString( vsParams[4], dCoeff))
|
||||
return false ;
|
||||
// esecuzione scorrimenti
|
||||
INTVECTOR::iterator Iter ;
|
||||
for ( Iter = vnNames.begin() ; Iter != vnNames.end() ; ++Iter) {
|
||||
switch ( nMirType) {
|
||||
case MIR_LOC :
|
||||
if ( ! m_pGDB->Shear( *Iter, ptPC, vtNorm, vtDir, dCoeff))
|
||||
return false ;
|
||||
break ;
|
||||
case MIR_GLOB :
|
||||
if ( ! m_pGDB->ShearGlob( *Iter, ptPC, vtNorm, vtDir, dCoeff))
|
||||
return false ;
|
||||
break ;
|
||||
case MIR_GROUP :
|
||||
if ( ! m_pGDB->ShearGroup( *Iter, ptPC, vtNorm, vtDir, dCoeff))
|
||||
return false ;
|
||||
break ;
|
||||
}
|
||||
}
|
||||
|
||||
return true ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
GdbExecutor::ExecuteInvertCurve( const string& sCmd2, const STRVECTOR& vsParams)
|
||||
|
||||
@@ -93,6 +93,12 @@ class GdbExecutor : public IGdbExecutor
|
||||
bool SurfTriMeshChangeSmoothAng( const STRVECTOR& vsParams) ;
|
||||
bool SurfTriMeshDoCompacting( const STRVECTOR& vsParams) ;
|
||||
bool SurfTriMeshDoSewing( const STRVECTOR& vsParams) ;
|
||||
bool ExecuteText( const std::string& sCmd2, const STRVECTOR& vsParams) ;
|
||||
bool TextSimple( const STRVECTOR& vsParams) ;
|
||||
bool TextComplete( const STRVECTOR& vsParams) ;
|
||||
bool TextFlip( const STRVECTOR& vsParams) ;
|
||||
bool TextMir( const STRVECTOR& vsParams) ;
|
||||
bool TextOutline( const STRVECTOR& vsParams) ;
|
||||
bool ExecuteLevel( const std::string& sCmd2, const STRVECTOR& vsParams) ;
|
||||
bool ExecuteMode( const std::string& sCmd2, const STRVECTOR& vsParams) ;
|
||||
bool ExecuteStatus( const std::string& sCmd2, const STRVECTOR& vsParams) ;
|
||||
@@ -109,6 +115,7 @@ class GdbExecutor : public IGdbExecutor
|
||||
bool ExecuteRotate( const std::string& sCmd2, const STRVECTOR& vsParams) ;
|
||||
bool ExecuteScale( const std::string& sCmd2, const STRVECTOR& vsParams) ;
|
||||
bool ExecuteMirror( const std::string& sCmd2, const STRVECTOR& vsParams) ;
|
||||
bool ExecuteShear( const std::string& sCmd2, const STRVECTOR& vsParams) ;
|
||||
bool ExecuteInvertCurve( const std::string& sCmd2, const STRVECTOR& vsParams) ;
|
||||
bool ExecuteInvertSurf( const std::string& sCmd2, const STRVECTOR& vsParams) ;
|
||||
bool ExecuteTrimCurve( const std::string& sCmd2, const STRVECTOR& vsParams) ;
|
||||
|
||||
+40
@@ -20,6 +20,7 @@
|
||||
#include "NgeWriter.h"
|
||||
#include "NgeReader.h"
|
||||
#include "GeoObjRW.h"
|
||||
#include "/EgtDev/Include/EGkCurveArc.h"
|
||||
#include "/EgtDev/Include/EGkGdbFunct.h"
|
||||
#include "/EgtDev/Include/EGnStringUtils.h"
|
||||
#include <new>
|
||||
@@ -263,6 +264,35 @@ GdbGeo::Mirror( const Point3d& ptOn, const Vector3d& vtNorm)
|
||||
return m_pGeoObj->Mirror( ptOn, vtNorm) ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
GdbGeo::Shear( const Point3d& ptOn, const Vector3d& vtNorm, const Vector3d& vtDir, double dCoeff)
|
||||
{
|
||||
if ( m_pGeoObj == nullptr)
|
||||
return false ;
|
||||
|
||||
// verifiche per arco
|
||||
if ( m_pGeoObj->GetType() == CRV_ARC) {
|
||||
// ricavo puntatore ad arco
|
||||
ICurveArc* pArc = GetCurveArc( m_pGeoObj) ;
|
||||
// se l'arco non è piatto o il piano di scorrimento non coincide con quello dell'arco
|
||||
if ( ! pArc->IsFlat() ||
|
||||
! ( AreSameVectorExact( pArc->GetNormVersor(), vtNorm) ||
|
||||
AreOppositeVectorExact( pArc->GetNormVersor(), vtNorm))) {
|
||||
// trasformo in curva di Bezier (semplice o composta)
|
||||
ICurve* pCrvNew ;
|
||||
if ( ! ArcToBezierCurve( GetCurve( m_pGeoObj), pCrvNew))
|
||||
return false ;
|
||||
// elimino l'arco e lo sostituisco con la curva di Bezier
|
||||
delete m_pGeoObj ;
|
||||
m_pGeoObj = pCrvNew ;
|
||||
}
|
||||
}
|
||||
|
||||
// eseguo scorrimento
|
||||
return m_pGeoObj->Shear( ptOn, vtNorm, vtDir, dCoeff) ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
GdbGeo::ToGlob( const Frame3d& frRef)
|
||||
@@ -283,6 +313,16 @@ GdbGeo::ToLoc( const Frame3d& frRef)
|
||||
return m_pGeoObj->ToLoc( frRef) ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
GdbGeo::LocToLoc( const Frame3d& frOri, const Frame3d& frDest)
|
||||
{
|
||||
if ( m_pGeoObj == nullptr)
|
||||
return false ;
|
||||
|
||||
return m_pGeoObj->LocToLoc( frOri, frDest) ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
GdbGeo::OnSetMaterial( void)
|
||||
|
||||
@@ -36,8 +36,10 @@ class GdbGeo : public GdbObj
|
||||
return Rotate( ptAx, vtAx, cos( dAngRad), sin( dAngRad)) ; }
|
||||
virtual bool Scale( const Frame3d& frRef, double dCoeffX, double dCoeffY, double dCoeffZ) ;
|
||||
virtual bool Mirror( const Point3d& ptOn, const Vector3d& vtNorm) ;
|
||||
virtual bool Shear( const Point3d& ptOn, const Vector3d& vtNorm, const Vector3d& vtDir, double dCoeff) ;
|
||||
virtual bool ToGlob( const Frame3d& frRef) ;
|
||||
virtual bool ToLoc( const Frame3d& frRef) ;
|
||||
virtual bool LocToLoc( const Frame3d& frOri, const Frame3d& frDest) ;
|
||||
virtual bool OnSetMaterial( void) ;
|
||||
|
||||
public :
|
||||
|
||||
@@ -336,6 +336,49 @@ GdbGroup::Mirror( const Point3d& ptOn, const Vector3d& vtNorm)
|
||||
return bOk ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
GdbGroup::Shear( const Point3d& ptOn, const Vector3d& vtNorm, const Vector3d& vtDir, double dCoeff)
|
||||
{
|
||||
GdbObj* pGdbObj ;
|
||||
|
||||
|
||||
// parziale scorrimento del riferimento (non può essere completa)
|
||||
Frame3d frFrameS = m_gfrFrame.GetFrame() ;
|
||||
frFrameS.PseudoShear( ptOn, vtNorm, vtDir, dCoeff) ;
|
||||
|
||||
// porto gli oggetti nel nuovo riferimento, senza modificarne la geometria in globale
|
||||
Frame3d frTrasf = m_gfrFrame.GetFrame() ;
|
||||
frTrasf.ToLoc( frFrameS) ;
|
||||
pGdbObj = GetFirstObj() ;
|
||||
while ( pGdbObj != nullptr) {
|
||||
pGdbObj->ToGlob( frTrasf) ;
|
||||
pGdbObj = pGdbObj->GetNext() ;
|
||||
}
|
||||
|
||||
// assegno il nuovo riferimento
|
||||
m_gfrFrame.Set( frFrameS) ;
|
||||
|
||||
// porto i dati di scorrimento nel riferimento del gruppo
|
||||
Point3d ptOnLoc = ptOn ;
|
||||
ptOnLoc.ToLoc( m_gfrFrame.GetFrame()) ;
|
||||
Vector3d vtNormLoc = vtNorm ;
|
||||
vtNormLoc.ToLoc( m_gfrFrame.GetFrame()) ;
|
||||
Vector3d vtDirLoc = vtDir ;
|
||||
vtDirLoc.ToLoc( m_gfrFrame.GetFrame()) ;
|
||||
|
||||
// ciclo sugli oggetti
|
||||
bool bOk = true ;
|
||||
pGdbObj = GetFirstObj() ;
|
||||
while ( pGdbObj != nullptr) {
|
||||
if ( ! pGdbObj->Shear( ptOnLoc, vtNormLoc, vtDirLoc, dCoeff))
|
||||
bOk = false ;
|
||||
pGdbObj = pGdbObj->GetNext() ;
|
||||
}
|
||||
|
||||
return bOk ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
GdbGroup::OnSetMaterial( void)
|
||||
|
||||
@@ -37,12 +37,16 @@ class GdbGroup : public GdbObj
|
||||
return Rotate( ptAx, vtAx, cos( dAngRad), sin( dAngRad)) ; }
|
||||
virtual bool Scale( const Frame3d& frRef, double dCoeffX, double dCoeffY, double dCoeffZ) ;
|
||||
virtual bool Mirror( const Point3d& ptOn, const Vector3d& vtNorm) ;
|
||||
virtual bool Shear( const Point3d& ptOn, const Vector3d& vtNorm, const Vector3d& vtDir, double dCoeff) ;
|
||||
virtual bool ToGlob( const Frame3d& frRef)
|
||||
{ Frame3d frF = m_gfrFrame.GetFrame() ;
|
||||
return ( frF.ToGlob( frRef) && m_gfrFrame.Set( frF)) ; }
|
||||
virtual bool ToLoc( const Frame3d& frRef)
|
||||
{ Frame3d frF = m_gfrFrame.GetFrame() ;
|
||||
return ( frF.ToLoc( frRef) && m_gfrFrame.Set( frF)) ; }
|
||||
virtual bool LocToLoc( const Frame3d& frOri, const Frame3d& frDest)
|
||||
{ Frame3d frF = m_gfrFrame.GetFrame() ;
|
||||
return ( frF.LocToLoc( frOri, frDest) && m_gfrFrame.Set( frF)) ; }
|
||||
virtual bool OnSetMaterial( void) ;
|
||||
|
||||
public :
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
#include "stdafx.h"
|
||||
#include "GdbIterator.h"
|
||||
#include "Attribs.h"
|
||||
#include "/EgtDev/Include/EGkStringUtils3d.h"
|
||||
#include <new>
|
||||
|
||||
using namespace std ;
|
||||
@@ -731,6 +732,48 @@ GdbIterator::SetInfo( const string& sKey, const string& sInfo)
|
||||
return m_pCurrObj->SetInfo( sKey, sInfo) ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
GdbIterator::SetInfo( const string& sKey, bool bInfo)
|
||||
{
|
||||
return SetInfo( sKey, ToString( bInfo)) ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
GdbIterator::SetInfo( const string& sKey, int nInfo)
|
||||
{
|
||||
return SetInfo( sKey, ToString( nInfo)) ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
GdbIterator::SetInfo( const string& sKey, double dInfo)
|
||||
{
|
||||
return SetInfo( sKey, ToString( dInfo)) ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
GdbIterator::SetInfo( const string& sKey, const Point3d& ptInfo)
|
||||
{
|
||||
return SetInfo( sKey, ToString( ptInfo)) ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
GdbIterator::SetInfo( const string& sKey, const Vector3d& vtInfo)
|
||||
{
|
||||
return SetInfo( sKey, ToString( vtInfo)) ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
GdbIterator::SetInfo( const string& sKey, const Frame3d& frInfo)
|
||||
{
|
||||
return SetInfo( sKey, ToString( frInfo)) ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
GdbIterator::GetInfo( const string& sKey, string& sInfo) const
|
||||
@@ -742,6 +785,54 @@ GdbIterator::GetInfo( const string& sKey, string& sInfo) const
|
||||
return m_pCurrObj->GetInfo( sKey, sInfo) ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
GdbIterator::GetInfo( const string& sKey, bool& bInfo) const
|
||||
{
|
||||
string sInfo ;
|
||||
return ( GetInfo( sKey, sInfo) && FromString( sInfo, bInfo)) ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
GdbIterator::GetInfo( const string& sKey, int& nInfo) const
|
||||
{
|
||||
string sInfo ;
|
||||
return ( GetInfo( sKey, sInfo) && FromString( sInfo, nInfo)) ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
GdbIterator::GetInfo( const string& sKey, double& dInfo) const
|
||||
{
|
||||
string sInfo ;
|
||||
return ( GetInfo( sKey, sInfo) && FromString( sInfo, dInfo)) ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
GdbIterator::GetInfo( const string& sKey, Point3d& ptInfo) const
|
||||
{
|
||||
string sInfo ;
|
||||
return ( GetInfo( sKey, sInfo) && FromString( sInfo, ptInfo)) ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
GdbIterator::GetInfo( const string& sKey, Vector3d& vtInfo) const
|
||||
{
|
||||
string sInfo ;
|
||||
return ( GetInfo( sKey, sInfo) && FromString( sInfo, vtInfo)) ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
GdbIterator::GetInfo( const string& sKey, Frame3d& frInfo) const
|
||||
{
|
||||
string sInfo ;
|
||||
return ( GetInfo( sKey, sInfo) && FromString( sInfo, frInfo)) ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
GdbIterator::ExistsInfo( const string& sKey) const
|
||||
|
||||
@@ -76,7 +76,19 @@ class GdbIterator : public IGdbIterator
|
||||
virtual bool ExistsName( void) const ;
|
||||
virtual bool RemoveName( void) ;
|
||||
virtual bool SetInfo( const std::string& sKey, const std::string& sInfo) ;
|
||||
virtual bool SetInfo( const std::string& sKey, bool bInfo) ;
|
||||
virtual bool SetInfo( const std::string& sKey, int nInfo) ;
|
||||
virtual bool SetInfo( const std::string& sKey, double dInfo) ;
|
||||
virtual bool SetInfo( const std::string& sKey, const Point3d& ptInfo) ;
|
||||
virtual bool SetInfo( const std::string& sKey, const Vector3d& vtInfo) ;
|
||||
virtual bool SetInfo( const std::string& sKey, const Frame3d& frInfo) ;
|
||||
virtual bool GetInfo( const std::string& sKey, std::string& sInfo) const ;
|
||||
virtual bool GetInfo( const std::string& sKey, bool& bInfo) const ;
|
||||
virtual bool GetInfo( const std::string& sKey, int& nInfo) const ;
|
||||
virtual bool GetInfo( const std::string& sKey, double& dInfo) const ;
|
||||
virtual bool GetInfo( const std::string& sKey, Point3d& ptInfo) const ;
|
||||
virtual bool GetInfo( const std::string& sKey, Vector3d& vtInfo) const ;
|
||||
virtual bool GetInfo( const std::string& sKey, Frame3d& frInfo) const ;
|
||||
virtual bool ExistsInfo( const std::string& sKey) const ;
|
||||
virtual bool RemoveInfo( const std::string& sKey) ;
|
||||
|
||||
|
||||
@@ -35,12 +35,14 @@ class GdbObj
|
||||
virtual bool GetLocalBBox( BBox3d& b3Loc, int nFlag, int nLev = 0) const = 0 ;
|
||||
virtual bool GetBBox( const Frame3d& frRef, BBox3d& b3Ref, int nFlag, int nLev = 0) const = 0 ;
|
||||
virtual bool Translate( const Vector3d& vtMove) = 0 ;
|
||||
virtual bool Rotate( const Point3d& ptAx, const Vector3d& vtAx, double dAngDeg) = 0 ;
|
||||
virtual bool Rotate( const Point3d& ptAx, const Vector3d& vtAx, double dCosAng, double dSinAng) = 0 ;
|
||||
virtual bool Rotate( const Point3d& ptAx, const Vector3d& vtAx, double dAngRad) = 0 ;
|
||||
virtual bool Scale( const Frame3d& frRef, double dCoeffX, double dCoeffY, double dCoeffZ) = 0 ;
|
||||
virtual bool Mirror( const Point3d& ptOn, const Vector3d& vtNorm) = 0 ;
|
||||
virtual bool Shear( const Point3d& ptOn, const Vector3d& vtNorm, const Vector3d& vtDir, double dCoeff) = 0 ;
|
||||
virtual bool ToGlob( const Frame3d& frRef) = 0 ;
|
||||
virtual bool ToLoc( const Frame3d& frRef) = 0 ;
|
||||
virtual bool LocToLoc( const Frame3d& frOri, const Frame3d& frDest) = 0 ;
|
||||
virtual bool OnSetMaterial( void) = 0 ;
|
||||
|
||||
public :
|
||||
|
||||
+7
-7
@@ -25,20 +25,20 @@ const double ANG_TOL_MIN_DEG = 0.1 ;
|
||||
// deviazione angolare massima (in gradi) in approssimazioni lineari esterne
|
||||
const double ANG_TOL_EXT_MAX_DEG = 90 ;
|
||||
// tolleranza lineare comune in approssimazioni lineari
|
||||
static const double LIN_TOL_APPROX = 1 ;
|
||||
const double LIN_TOL_APPROX = 1 ;
|
||||
// deviazione angolare comune (in gradi) in approssimazioni lineari
|
||||
static const double ANG_TOL_APPROX_DEG = 45 ;
|
||||
const double ANG_TOL_APPROX_DEG = 45 ;
|
||||
// tolleranza lineare standard
|
||||
static const double LIN_TOL_STD = 0.1 ;
|
||||
const double LIN_TOL_STD = 0.1 ;
|
||||
// deviazione angolare standard (in gradi)
|
||||
static const double ANG_TOL_STD_DEG = 15 ;
|
||||
const double ANG_TOL_STD_DEG = 15 ;
|
||||
|
||||
//----------------- Costanti per archi come curve di Bezier ------------------
|
||||
// massimo angolo al centro di un arco espresso tramite curva di Bezier
|
||||
static const double BEZARC_ANG_CEN_MAX = 90 ;
|
||||
const double BEZARC_ANG_CEN_MAX = 90 ;
|
||||
|
||||
//----------------- Costanti per superfici TriMesh ---------------------------
|
||||
// tolleranza lineare standard
|
||||
static const double STM_STD_LIN_TOL = 0.1 ;
|
||||
const double STM_STD_LIN_TOL = 0.1 ;
|
||||
// angolo limite per mediare le normali in un vertice
|
||||
static const double STM_STD_SMOOTH_ANG = 25.0 ;
|
||||
const double STM_STD_SMOOTH_ANG = 25.0 ;
|
||||
|
||||
+7
-2
@@ -36,18 +36,23 @@ class GeoFrame3d : public IGeoFrame3d, public IGeoObjRW
|
||||
{ frF = m_frF ; return true ;}
|
||||
virtual bool Translate( const Vector3d& vtMove)
|
||||
{ m_OGrMgr.Reset() ; m_frF.Translate( vtMove) ; return true ; }
|
||||
virtual bool Rotate( const Point3d& ptAx, const Vector3d& vtAx, double dAngDeg)
|
||||
{ double dAngRad = dAngDeg * DEGTORAD ;
|
||||
return Rotate( ptAx, vtAx, cos( dAngRad), sin( dAngRad)) ; }
|
||||
virtual bool Rotate( const Point3d& ptAx, const Vector3d& vtAx, double dCosAng, double dSinAng)
|
||||
{ m_OGrMgr.Reset() ; return m_frF.Rotate( ptAx, vtAx, dCosAng, dSinAng) ; }
|
||||
virtual bool Rotate( const Point3d& ptAx, const Vector3d& vtAx, double dAngRad)
|
||||
{ return Rotate( ptAx, vtAx, cos( dAngRad), sin( dAngRad)) ; }
|
||||
virtual bool Scale( const Frame3d& frRef, double dCoeffX, double dCoeffY, double dCoeffZ)
|
||||
{ return false ; }
|
||||
virtual bool Mirror( const Point3d& ptOn, const Vector3d& vtNorm)
|
||||
{ return false ; }
|
||||
virtual bool Shear( const Point3d& ptOn, const Vector3d& vtNorm, const Vector3d& vtDir, double dCoeff)
|
||||
{ return false ; }
|
||||
virtual bool ToGlob( const Frame3d& frRef)
|
||||
{ m_OGrMgr.Reset() ; return m_frF.ToGlob( frRef) ;}
|
||||
virtual bool ToLoc( const Frame3d& frRef)
|
||||
{ m_OGrMgr.Reset() ; return m_frF.ToLoc( frRef) ;}
|
||||
virtual bool LocToLoc( const Frame3d& frOri, const Frame3d& frDest)
|
||||
{ m_OGrMgr.Reset() ; return m_frF.LocToLoc( frOri, frDest) ;}
|
||||
virtual void SetObjGraphics( IObjGraphics* pOGr)
|
||||
{ m_OGrMgr.SetObjGraphics( pOGr) ; }
|
||||
virtual IObjGraphics* GetObjGraphics( void)
|
||||
|
||||
+1
-1
@@ -2,7 +2,7 @@
|
||||
// EgalTech 2013-2013
|
||||
//----------------------------------------------------------------------------
|
||||
// File : GeoObj.cpp Data : 21.11.13 Versione : 1.3a1
|
||||
// Contenuto : Implementazione della classe Punto geometrico.
|
||||
// Contenuto : Funzione di creazione di un oggetto geometrico dato il tipo.
|
||||
//
|
||||
//
|
||||
//
|
||||
|
||||
+7
-4
@@ -32,22 +32,25 @@ class GeoPoint3d : public IGeoPoint3d, public IGeoObjRW
|
||||
virtual bool Dump( std::string& sOut, const char* szNewLine = "\n") const ;
|
||||
virtual bool GetLocalBBox( BBox3d& b3Loc) const ;
|
||||
virtual bool GetBBox( const Frame3d& frRef, BBox3d& b3Ref) const ;
|
||||
virtual bool GetPoint( Point3d& ptP) const
|
||||
{ ptP = m_ptP ; return true ;}
|
||||
virtual bool Translate( const Vector3d& vtMove)
|
||||
{ m_OGrMgr.Reset() ; m_ptP.Translate( vtMove) ; return true ; }
|
||||
virtual bool Rotate( const Point3d& ptAx, const Vector3d& vtAx, double dAngDeg)
|
||||
{ double dAngRad = dAngDeg * DEGTORAD ;
|
||||
return Rotate( ptAx, vtAx, cos( dAngRad), sin( dAngRad)) ; }
|
||||
virtual bool Rotate( const Point3d& ptAx, const Vector3d& vtAx, double dCosAng, double dSinAng)
|
||||
{ m_OGrMgr.Reset() ; return m_ptP.Rotate( ptAx, vtAx, dCosAng, dSinAng) ; }
|
||||
virtual bool Rotate( const Point3d& ptAx, const Vector3d& vtAx, double dAngRad)
|
||||
{ return Rotate( ptAx, vtAx, cos( dAngRad), sin( dAngRad)) ; }
|
||||
virtual bool Scale( const Frame3d& frRef, double dCoeffX, double dCoeffY, double dCoeffZ)
|
||||
{ m_OGrMgr.Reset() ; return m_ptP.Scale( frRef, dCoeffX, dCoeffY, dCoeffZ) ;}
|
||||
virtual bool Mirror( const Point3d& ptOn, const Vector3d& vtNorm)
|
||||
{ m_OGrMgr.Reset() ; return m_ptP.Mirror( ptOn, vtNorm) ;}
|
||||
virtual bool Shear( const Point3d& ptOn, const Vector3d& vtNorm, const Vector3d& vtDir, double dCoeff)
|
||||
{ m_OGrMgr.Reset() ; return m_ptP.Shear( ptOn, vtNorm, vtDir, dCoeff) ;}
|
||||
virtual bool ToGlob( const Frame3d& frRef)
|
||||
{ m_OGrMgr.Reset() ; return m_ptP.ToGlob( frRef) ;}
|
||||
virtual bool ToLoc( const Frame3d& frRef)
|
||||
{ m_OGrMgr.Reset() ; return m_ptP.ToLoc( frRef) ;}
|
||||
virtual bool LocToLoc( const Frame3d& frOri, const Frame3d& frDest)
|
||||
{ m_OGrMgr.Reset() ; return m_ptP.LocToLoc( frOri, frDest) ;}
|
||||
virtual void SetObjGraphics( IObjGraphics* pOGr)
|
||||
{ m_OGrMgr.SetObjGraphics( pOGr) ; }
|
||||
virtual IObjGraphics* GetObjGraphics( void)
|
||||
|
||||
+7
-2
@@ -35,18 +35,23 @@ class GeoVector3d : public IGeoVector3d, public IGeoObjRW
|
||||
{ vtV = m_vtV ; return true ;}
|
||||
virtual bool Translate( const Vector3d& vtMove)
|
||||
{ return true ; }
|
||||
virtual bool Rotate( const Point3d& ptAx, const Vector3d& vtAx, double dAngDeg)
|
||||
{ double dAngRad = dAngDeg * DEGTORAD ;
|
||||
return Rotate( ptAx, vtAx, cos( dAngRad), sin( dAngRad)) ; }
|
||||
virtual bool Rotate( const Point3d& ptAx, const Vector3d& vtAx, double dCosAng, double dSinAng)
|
||||
{ m_OGrMgr.Reset() ; return m_vtV.Rotate( vtAx, dCosAng, dSinAng) ; }
|
||||
virtual bool Rotate( const Point3d& ptAx, const Vector3d& vtAx, double dAngRad)
|
||||
{ return Rotate( ptAx, vtAx, cos( dAngRad), sin( dAngRad)) ; }
|
||||
virtual bool Scale( const Frame3d& frRef, double dCoeffX, double dCoeffY, double dCoeffZ)
|
||||
{ m_OGrMgr.Reset() ; return m_vtV.Scale( frRef, dCoeffX, dCoeffY, dCoeffZ) ;}
|
||||
virtual bool Mirror( const Point3d& ptOn, const Vector3d& vtNorm)
|
||||
{ m_OGrMgr.Reset() ; return m_vtV.Mirror( vtNorm) ;}
|
||||
virtual bool Shear( const Point3d& ptOn, const Vector3d& vtNorm, const Vector3d& vtDir, double dCoeff)
|
||||
{ m_OGrMgr.Reset() ; return m_vtV.Shear( vtNorm, vtDir, dCoeff) ;}
|
||||
virtual bool ToGlob( const Frame3d& frRef)
|
||||
{ m_OGrMgr.Reset() ; return m_vtV.ToGlob( frRef) ;}
|
||||
virtual bool ToLoc( const Frame3d& frRef)
|
||||
{ m_OGrMgr.Reset() ; return m_vtV.ToLoc( frRef) ;}
|
||||
virtual bool LocToLoc( const Frame3d& frOri, const Frame3d& frDest)
|
||||
{ m_OGrMgr.Reset() ; return m_vtV.LocToLoc( frOri, frDest) ;}
|
||||
virtual void SetObjGraphics( IObjGraphics* pOGr)
|
||||
{ m_OGrMgr.SetObjGraphics( pOGr) ; }
|
||||
virtual IObjGraphics* GetObjGraphics( void)
|
||||
|
||||
+208
-66
@@ -306,16 +306,20 @@ GeomDB::GetGdbObj( int nId) const
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
GeomDB::InsertInGeomDB( GdbObj* pGObj, int nRefId, int nSonBeforeAfter)
|
||||
GeomDB::InsertInGeomDB( GdbObj* pGObj, int nRefId, int nSonBeforeAfter, bool bTestId)
|
||||
{
|
||||
// verifico validità oggetto puntato
|
||||
if ( pGObj == nullptr)
|
||||
return false ;
|
||||
|
||||
// verifica validità e unicità del nome
|
||||
if ( pGObj->m_nId <= GDB_ID_ROOT || ExistsObj( pGObj->m_nId))
|
||||
// se richista, verifica validità e unicità del nome
|
||||
if ( bTestId && ( pGObj->m_nId <= GDB_ID_ROOT || ExistsObj( pGObj->m_nId)))
|
||||
return false ;
|
||||
|
||||
// oggetto e riferimento non possono essere la stessa cosa
|
||||
if ( pGObj->m_nId == nRefId)
|
||||
return ( nSonBeforeAfter != GDB_SON) ;
|
||||
|
||||
// cerco il riferimento
|
||||
GdbObj* pGRef = GetGdbObj( nRefId) ;
|
||||
if ( pGRef == nullptr)
|
||||
@@ -341,8 +345,11 @@ GeomDB::InsertInGeomDB( GdbObj* pGObj, int nRefId, int nSonBeforeAfter)
|
||||
return false ;
|
||||
}
|
||||
|
||||
// inserisco in mappa Id
|
||||
return m_IdManager.AddObj( pGObj->m_nId, pGObj) ;
|
||||
// se richiesto, inserisco in mappa Id
|
||||
if ( bTestId)
|
||||
return m_IdManager.AddObj( pGObj->m_nId, pGObj) ;
|
||||
else
|
||||
return true ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
@@ -390,7 +397,7 @@ GeomDB::AddGeoObj( int nId, int nParentId, IGeoObj* pGeoObj)
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
int
|
||||
GeomDB::InsertGeoObj( int nId, int nRefId, int nBeforeAfter, IGeoObj* pGeoObj)
|
||||
GeomDB::InsertGeoObj( int nId, int nRefId, int nSonBeforeAfter, IGeoObj* pGeoObj)
|
||||
{
|
||||
// assegno GeoObj a gestore puntatore con rilascio automatico
|
||||
PtrOwner<IGeoObj> pRPGeoObj( pGeoObj) ;
|
||||
@@ -411,7 +418,7 @@ GeomDB::InsertGeoObj( int nId, int nRefId, int nBeforeAfter, IGeoObj* pGeoObj)
|
||||
// assegno dati
|
||||
pGdbGeo->m_pGeoObj = Release( pRPGeoObj) ;
|
||||
// inserisco nel DB
|
||||
if ( ! InsertInGeomDB( pGdbGeo, nRefId, nBeforeAfter)) {
|
||||
if ( ! InsertInGeomDB( pGdbGeo, nRefId, nSonBeforeAfter)) {
|
||||
delete pGdbGeo ;
|
||||
return GDB_ID_NULL ;
|
||||
}
|
||||
@@ -638,36 +645,7 @@ GeomDB::GetRefBBox( int nId, const Frame3d& frRef, BBox3d& b3Ref, int nFlag) con
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
int
|
||||
GeomDB::Copy( int nIdSou, int nIdDest, int nParentIdDest)
|
||||
{
|
||||
// verifico Id destinazione
|
||||
if ( nIdDest <= GDB_ID_ROOT)
|
||||
nIdDest = m_IdManager.GetNewId() ;
|
||||
if ( ExistsObj( nIdDest))
|
||||
return GDB_ID_NULL ;
|
||||
|
||||
// verifico esistenza del sorgente
|
||||
GdbObj* pGdOSou ;
|
||||
if ( ( pGdOSou = GetGdbObj( nIdSou)) == nullptr)
|
||||
return GDB_ID_NULL ;
|
||||
|
||||
// eseguo la copia
|
||||
GdbObj* pGdODest ;
|
||||
if ( ( pGdODest = pGdOSou->Clone( nIdDest, m_IdManager)) == nullptr)
|
||||
return GDB_ID_NULL ;
|
||||
|
||||
// inserisco nel DB
|
||||
if ( ! InsertInGeomDB( pGdODest, nParentIdDest, GDB_SON)) {
|
||||
delete pGdODest ;
|
||||
return GDB_ID_NULL ;
|
||||
}
|
||||
|
||||
return nIdDest ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
int
|
||||
GeomDB::CopyGlob( int nIdSou, int nIdDest, int nParentIdDest)
|
||||
GeomDB::Copy( int nIdSou, int nIdDest, int nRefId, int nSonBeforeAfter, bool bGlob)
|
||||
{
|
||||
// verifico Id destinazione
|
||||
if ( nIdDest <= GDB_ID_ROOT)
|
||||
@@ -680,40 +658,53 @@ GeomDB::CopyGlob( int nIdSou, int nIdDest, int nParentIdDest)
|
||||
if ( pGdOSou == nullptr)
|
||||
return GDB_ID_NULL ;
|
||||
|
||||
// recupero il riferimento del sorgente
|
||||
Frame3d frSou ;
|
||||
if ( ! GetGlobFrame( nIdSou, frSou))
|
||||
// verifico esistenza del padre
|
||||
GdbGroup* pGroupSou = pGdOSou->GetParent() ;
|
||||
if ( pGroupSou == nullptr)
|
||||
return false ;
|
||||
|
||||
// recupero il riferimento del gruppo destinazione
|
||||
Frame3d frDest ;
|
||||
if ( ! GetGroupGlobFrame( nParentIdDest, frDest))
|
||||
// cerco il padre di destinazione
|
||||
int nParentIdDest = (( nSonBeforeAfter == GDB_SON) ? nRefId : GetParentId( nRefId)) ;
|
||||
GdbGroup* pGroupDest = GetGdbGroup( nParentIdDest) ;
|
||||
if ( pGroupDest == nullptr)
|
||||
return false ;
|
||||
|
||||
// eseguo la copia
|
||||
GdbObj* pGdODest ;
|
||||
if ( ( pGdODest = pGdOSou->Clone( nIdDest, m_IdManager)) == nullptr)
|
||||
PtrOwner<GdbObj> pGdODest( pGdOSou->Clone( nIdDest, m_IdManager)) ;
|
||||
if ( ! ::IsValid( pGdODest))
|
||||
return GDB_ID_NULL ;
|
||||
|
||||
// porto la copia da riferimento sorgente a quello destinazione
|
||||
if ( ! AreSameFrame( frSou, frDest)) {
|
||||
pGdODest->ToGlob( frSou) ;
|
||||
pGdODest->ToLoc( frDest) ;
|
||||
}
|
||||
|
||||
// inserisco nel DB
|
||||
if ( ! InsertInGeomDB( pGdODest, nParentIdDest, GDB_SON)) {
|
||||
delete pGdODest ;
|
||||
return GDB_ID_NULL ;
|
||||
// se in globale
|
||||
if ( bGlob) {
|
||||
// recupero il riferimento del sorgente
|
||||
Frame3d frSou ;
|
||||
if ( ! pGroupSou->GetGlobFrame( frSou))
|
||||
return GDB_ID_NULL ;
|
||||
// recupero il riferimento del gruppo destinazione
|
||||
Frame3d frDest ;
|
||||
if ( ! pGroupDest->GetGlobFrame( frDest))
|
||||
return GDB_ID_NULL ;
|
||||
// porto la copia da riferimento sorgente a quello destinazione
|
||||
pGdODest->LocToLoc( frSou, frDest) ;
|
||||
}
|
||||
|
||||
// inserisco nel DB (non rilascio il puntatore)
|
||||
if ( ! InsertInGeomDB( ::Get( pGdODest), nRefId, nSonBeforeAfter))
|
||||
return GDB_ID_NULL ;
|
||||
|
||||
// rilascio il puntatore
|
||||
::Release( pGdODest) ;
|
||||
return nIdDest ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
GeomDB::Relocate( int nId, int nNewParentId, bool bGlob)
|
||||
GeomDB::Relocate( int nId, int nRefId, int nSonBeforeAfter, bool bGlob)
|
||||
{
|
||||
// l'oggetto e il riferimento non possono coincidere
|
||||
if ( nId == nRefId)
|
||||
return ( nSonBeforeAfter != GDB_SON) ;
|
||||
|
||||
// verifico esistenza dell'oggetto
|
||||
GdbObj* pGdbObj = GetGdbObj( nId) ;
|
||||
if ( pGdbObj == nullptr)
|
||||
@@ -725,29 +716,27 @@ GeomDB::Relocate( int nId, int nNewParentId, bool bGlob)
|
||||
return false ;
|
||||
|
||||
// cerco il nuovo padre
|
||||
int nNewParentId = (( nSonBeforeAfter == GDB_SON) ? nRefId : GetParentId( nRefId)) ;
|
||||
GdbGroup* pNewGroup = GetGdbGroup( nNewParentId) ;
|
||||
if ( pNewGroup == nullptr)
|
||||
return false ;
|
||||
|
||||
// se vecchio e nuovo padre coincidono, non devo fare alcunché
|
||||
if ( pGroup->m_nId == pNewGroup->m_nId)
|
||||
// se riferimento al padre e vecchio e nuovo padre coincidono, non devo fare alcunché
|
||||
if ( nSonBeforeAfter == GDB_SON && pGroup->m_nId == pNewGroup->m_nId)
|
||||
return true ;
|
||||
|
||||
// se rilocazione in globale
|
||||
if ( bGlob) {
|
||||
// recupero il riferimento del sorgente
|
||||
Frame3d frCurr ;
|
||||
Frame3d frCurr ;
|
||||
if ( ! pGroup->GetGlobFrame( frCurr))
|
||||
return false ;
|
||||
// recupero il riferimento del nuovo padre
|
||||
Frame3d frNew ;
|
||||
Frame3d frNew ;
|
||||
if ( ! pNewGroup->GetGlobFrame( frNew))
|
||||
return false ;
|
||||
// porto l'oggetto dal riferimento originale a quello nuovo
|
||||
if ( ! AreSameFrame( frCurr, frNew)) {
|
||||
pGdbObj->ToGlob( frCurr) ;
|
||||
pGdbObj->ToLoc( frNew) ;
|
||||
}
|
||||
pGdbObj->LocToLoc( frCurr, frNew) ;
|
||||
}
|
||||
|
||||
// sistemazioni in eventuali GdbIterator con quell'oggetto corrente
|
||||
@@ -756,8 +745,8 @@ GeomDB::Relocate( int nId, int nNewParentId, bool bGlob)
|
||||
// lo estraggo dalla posizione corrente del DB geometrico
|
||||
pGdbObj->Remove() ;
|
||||
|
||||
// lo inserisco in coda alla lista del padre
|
||||
if ( ! pGdbObj->AddTail( pNewGroup)) {
|
||||
// lo inserisco nella posizione opportuna
|
||||
if ( ! InsertInGeomDB( pGdbObj, nRefId, nSonBeforeAfter, false)) {
|
||||
// in caso di errore (condizione assai remota qui) cancello tutto
|
||||
m_IdManager.RemoveObj( pGdbObj->m_nId) ;
|
||||
m_SelManager.RemoveObj( pGdbObj) ;
|
||||
@@ -1031,6 +1020,69 @@ GeomDB::MirrorGroup( int nId, const Point3d& ptOn, const Vector3d& vtNorm)
|
||||
return pGdbGroup->Mirror( ptOnLoc, vtNormLoc) ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
GeomDB::Shear( int nId, const Point3d& ptOn, const Vector3d& vtNorm, const Vector3d& vtDir, double dCoeff)
|
||||
{
|
||||
// recupero l'oggetto
|
||||
GdbObj* pGdbObj ;
|
||||
if ( ( pGdbObj = GetGdbObj( nId)) == nullptr)
|
||||
return false ;
|
||||
// eseguo l'operazione
|
||||
return pGdbObj->Shear( ptOn, vtNorm, vtDir, dCoeff) ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
GeomDB::ShearGlob( int nId, const Point3d& ptOn, const Vector3d& vtNorm, const Vector3d& vtDir, double dCoeff)
|
||||
{
|
||||
// recupero l'oggetto
|
||||
GdbObj* pGdbObj ;
|
||||
if ( ( pGdbObj = GetGdbObj( nId)) == nullptr)
|
||||
return false ;
|
||||
// recupero il riferimento in cui è immerso
|
||||
Frame3d frObj ;
|
||||
if ( ! GetGlobFrame( nId, frObj))
|
||||
return false ;
|
||||
// porto i parametri di shear in locale
|
||||
Point3d ptOnLoc = ptOn ;
|
||||
if ( ! ptOnLoc.ToLoc( frObj))
|
||||
return false ;
|
||||
Vector3d vtNormLoc = vtNorm ;
|
||||
if ( ! vtNormLoc.ToLoc( frObj))
|
||||
return false ;
|
||||
Vector3d vtDirLoc = vtDir ;
|
||||
if ( ! vtDirLoc.ToLoc( frObj))
|
||||
return false ;
|
||||
// eseguo l'operazione
|
||||
return pGdbObj->Shear( ptOnLoc, vtNormLoc, vtDirLoc, dCoeff) ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
// La specchiatura è espressa nel riferimento del gruppo (ovvero il proprio).
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
GeomDB::ShearGroup( int nId, const Point3d& ptOn, const Vector3d& vtNorm, const Vector3d& vtDir, double dCoeff)
|
||||
{
|
||||
// recupero il gruppo Gdb
|
||||
GdbGroup* pGdbGroup ;
|
||||
if ( ( pGdbGroup = GetGdbGroup( nId)) == nullptr)
|
||||
return false ;
|
||||
// utilizzo il riferimento proprio
|
||||
// porto i parametri di mirror nel riferimento in cui è immerso
|
||||
Point3d ptOnLoc = ptOn ;
|
||||
if ( ! ptOnLoc.ToGlob( pGdbGroup->GetFrame()))
|
||||
return false ;
|
||||
Vector3d vtNormLoc = vtNorm ;
|
||||
if ( ! vtNormLoc.ToGlob( pGdbGroup->GetFrame()))
|
||||
return false ;
|
||||
Vector3d vtDirLoc = vtDir ;
|
||||
if ( ! vtDirLoc.ToLoc( pGdbGroup->GetFrame()))
|
||||
return false ;
|
||||
// eseguo l'operazione
|
||||
return pGdbGroup->Shear( ptOnLoc, vtNormLoc, vtDirLoc, dCoeff) ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
// Selection
|
||||
//----------------------------------------------------------------------------
|
||||
@@ -1798,6 +1850,48 @@ GeomDB::SetInfo( int nId, const string& sKey, const string& sInfo)
|
||||
return pGdbObj->SetInfo( sKey, sInfo) ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
GeomDB::SetInfo( int nId, const string& sKey, bool bInfo)
|
||||
{
|
||||
return SetInfo( nId, sKey, ToString( bInfo)) ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
GeomDB::SetInfo( int nId, const string& sKey, int nInfo)
|
||||
{
|
||||
return SetInfo( nId, sKey, ToString( nInfo)) ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
GeomDB::SetInfo( int nId, const string& sKey, double dInfo)
|
||||
{
|
||||
return SetInfo( nId, sKey, ToString( dInfo)) ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
GeomDB::SetInfo( int nId, const string& sKey, const Point3d& ptInfo)
|
||||
{
|
||||
return SetInfo( nId, sKey, ToString( ptInfo)) ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
GeomDB::SetInfo( int nId, const string& sKey, const Vector3d& vtInfo)
|
||||
{
|
||||
return SetInfo( nId, sKey, ToString( vtInfo)) ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
GeomDB::SetInfo( int nId, const string& sKey, const Frame3d& frInfo)
|
||||
{
|
||||
return SetInfo( nId, sKey, ToString( frInfo)) ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
GeomDB::GetInfo( int nId, const string& sKey, string& sInfo) const
|
||||
@@ -1811,6 +1905,54 @@ GeomDB::GetInfo( int nId, const string& sKey, string& sInfo) const
|
||||
return pGdbObj->GetInfo( sKey, sInfo) ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
GeomDB::GetInfo( int nId, const string& sKey, bool& bInfo) const
|
||||
{
|
||||
string sInfo ;
|
||||
return ( GetInfo( nId, sKey, sInfo) && FromString( sInfo, bInfo)) ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
GeomDB::GetInfo( int nId, const string& sKey, int& nInfo) const
|
||||
{
|
||||
string sInfo ;
|
||||
return ( GetInfo( nId, sKey, sInfo) && FromString( sInfo, nInfo)) ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
GeomDB::GetInfo( int nId, const string& sKey, double& dInfo) const
|
||||
{
|
||||
string sInfo ;
|
||||
return ( GetInfo( nId, sKey, sInfo) && FromString( sInfo, dInfo)) ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
GeomDB::GetInfo( int nId, const string& sKey, Point3d& ptInfo) const
|
||||
{
|
||||
string sInfo ;
|
||||
return ( GetInfo( nId, sKey, sInfo) && FromString( sInfo, ptInfo)) ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
GeomDB::GetInfo( int nId, const string& sKey, Vector3d& vtInfo) const
|
||||
{
|
||||
string sInfo ;
|
||||
return ( GetInfo( nId, sKey, sInfo) && FromString( sInfo, vtInfo)) ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
GeomDB::GetInfo( int nId, const string& sKey, Frame3d& frInfo) const
|
||||
{
|
||||
string sInfo ;
|
||||
return ( GetInfo( nId, sKey, sInfo) && FromString( sInfo, frInfo)) ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
GeomDB::ExistsInfo( int nId, const string& sKey) const
|
||||
|
||||
@@ -54,34 +54,39 @@ class GeomDB : public IGeomDB
|
||||
virtual bool GetLocalBBox( int nId, BBox3d& b3Loc, int nFlag = BBF_NONE) const ;
|
||||
virtual bool GetGlobalBBox( int nId, BBox3d& b3Glob, int nFlag = BBF_NONE) const ;
|
||||
virtual bool GetRefBBox( int nId, const Frame3d& frRef, BBox3d& b3Ref, int nFlag = BBF_NONE) const ;
|
||||
virtual int Copy( int nIdSou, int nIdDest, int nParentIdDest) ;
|
||||
virtual int CopyGlob( int nIdSou, int nIdDest, int nParentIdDest) ;
|
||||
virtual bool Relocate( int nId, int nNewParentId)
|
||||
{ return Relocate( nId, nNewParentId, false) ; }
|
||||
virtual bool RelocateGlob( int nId, int nNewParentId)
|
||||
{ return Relocate( nId, nNewParentId, true) ; }
|
||||
virtual int Copy( int nIdSou, int nIdDest, int nRefId, int nSonBeforeAfter = GDB_SON)
|
||||
{ return Copy( nIdSou, nIdDest, nRefId, nSonBeforeAfter, false) ; }
|
||||
virtual int CopyGlob( int nIdSou, int nIdDest, int nRefId, int nSonBeforeAfter = GDB_SON)
|
||||
{ return Copy( nIdSou, nIdDest, nRefId, nSonBeforeAfter, true) ; }
|
||||
virtual bool Relocate( int nId, int nRefId, int nSonBeforeAfter = GDB_SON)
|
||||
{ return Relocate( nId, nRefId, nSonBeforeAfter, false) ; }
|
||||
virtual bool RelocateGlob( int nId, int nRefId, int nSonBeforeAfter = GDB_SON)
|
||||
{ return Relocate( nId, nRefId, nSonBeforeAfter, true) ; }
|
||||
virtual bool Erase( int nId) ;
|
||||
virtual bool Translate( int nId, const Vector3d& vtMove) ;
|
||||
virtual bool TranslateGlob( int nId, const Vector3d& vtMove) ;
|
||||
virtual bool TranslateGroup( int nId, const Vector3d& vtMove) ;
|
||||
virtual bool Rotate( int nId, const Point3d& ptAx, const Vector3d& vtAx, double dCosAng, double dSinAng) ;
|
||||
virtual bool RotateGlob( int nId, const Point3d& ptAx, const Vector3d& vtAx, double dCosAng, double dSinAng) ;
|
||||
virtual bool RotateGroup( int nId, const Point3d& ptAx, const Vector3d& vtAx, double dCosAng, double dSinAng) ;
|
||||
virtual bool Rotate( int nId, const Point3d& ptAx, const Vector3d& vtAx, double dAngDeg)
|
||||
{ double dAngRad = dAngDeg * DEGTORAD ;
|
||||
return Rotate( nId, ptAx, vtAx, cos( dAngRad), sin( dAngRad)) ; }
|
||||
virtual bool Rotate( int nId, const Point3d& ptAx, const Vector3d& vtAx, double dCosAng, double dSinAng) ;
|
||||
virtual bool RotateGlob( int nId, const Point3d& ptAx, const Vector3d& vtAx, double dAngDeg)
|
||||
{ double dAngRad = dAngDeg * DEGTORAD ;
|
||||
return RotateGlob( nId, ptAx, vtAx, cos( dAngRad), sin( dAngRad)) ; }
|
||||
virtual bool RotateGlob( int nId, const Point3d& ptAx, const Vector3d& vtAx, double dCosAng, double dSinAng) ;
|
||||
virtual bool RotateGroup( int nId, const Point3d& ptAx, const Vector3d& vtAx, double dAngDeg)
|
||||
{ double dAngRad = dAngDeg * DEGTORAD ;
|
||||
return RotateGroup( nId, ptAx, vtAx, cos( dAngRad), sin( dAngRad)) ; }
|
||||
virtual bool RotateGroup( int nId, const Point3d& ptAx, const Vector3d& vtAx, double dCosAng, double dSinAng) ;
|
||||
virtual bool Scale( int nId, const Frame3d& frRef, double dCoeffX, double dCoeffY, double dCoeffZ) ;
|
||||
virtual bool ScaleGlob( int nId, const Frame3d& frRef, double dCoeffX, double dCoeffY, double dCoeffZ) ;
|
||||
virtual bool ScaleGroup( int nId, const Frame3d& frRef, double dCoeffX, double dCoeffY, double dCoeffZ) ;
|
||||
virtual bool Mirror( int nId, const Point3d& ptOn, const Vector3d& vtNorm) ;
|
||||
virtual bool MirrorGlob( int nId, const Point3d& ptOn, const Vector3d& vtNorm) ;
|
||||
virtual bool MirrorGroup( int nId, const Point3d& ptOn, const Vector3d& vtNorm) ;
|
||||
virtual bool Shear( int nId, const Point3d& ptOn, const Vector3d& vtNorm, const Vector3d& vtDir, double dCoeff) ;
|
||||
virtual bool ShearGlob( int nId, const Point3d& ptOn, const Vector3d& vtNorm, const Vector3d& vtDir, double dCoeff) ;
|
||||
virtual bool ShearGroup( int nId, const Point3d& ptOn, const Vector3d& vtNorm, const Vector3d& vtDir, double dCoeff) ;
|
||||
// selection
|
||||
virtual bool SelectObj( int nId) ;
|
||||
virtual bool DeselectObj( int nId) ;
|
||||
@@ -126,7 +131,19 @@ class GeomDB : public IGeomDB
|
||||
virtual bool ExistsName( int nId) const ;
|
||||
virtual bool RemoveName( int nId) ;
|
||||
virtual bool SetInfo( int nId, const std::string& sKey, const std::string& sInfo) ;
|
||||
virtual bool SetInfo( int nId, const std::string& sKey, bool bInfo) ;
|
||||
virtual bool SetInfo( int nId, const std::string& sKey, int nInfo) ;
|
||||
virtual bool SetInfo( int nId, const std::string& sKey, double dInfo) ;
|
||||
virtual bool SetInfo( int nId, const std::string& sKey, const Point3d& ptInfo) ;
|
||||
virtual bool SetInfo( int nId, const std::string& sKey, const Vector3d& vtInfo) ;
|
||||
virtual bool SetInfo( int nId, const std::string& sKey, const Frame3d& frInfo) ;
|
||||
virtual bool GetInfo( int nId, const std::string& sKey, std::string& sInfo) const ;
|
||||
virtual bool GetInfo( int nId, const std::string& sKey, bool& bInfo) const ;
|
||||
virtual bool GetInfo( int nId, const std::string& sKey, int& nInfo) const ;
|
||||
virtual bool GetInfo( int nId, const std::string& sKey, double& dInfo) const ;
|
||||
virtual bool GetInfo( int nId, const std::string& sKey, Point3d& ptInfo) const ;
|
||||
virtual bool GetInfo( int nId, const std::string& sKey, Vector3d& vtInfo) const ;
|
||||
virtual bool GetInfo( int nId, const std::string& sKey, Frame3d& frInfo) const ;
|
||||
virtual bool ExistsInfo( int nId, const std::string& sKey) const ;
|
||||
virtual bool RemoveInfo( int nId, const std::string& sKey) ;
|
||||
// material library
|
||||
@@ -155,8 +172,9 @@ class GeomDB : public IGeomDB
|
||||
{ return dynamic_cast<GdbGroup*>( GetGdbObj( nId)) ; }
|
||||
const GdbGroup* GetGdbGroup( int nId) const
|
||||
{ return dynamic_cast<const GdbGroup*>( GetGdbObj( nId)) ; }
|
||||
bool InsertInGeomDB( GdbObj* pGObj, int nRefId, int nSonBeforeAfter) ;
|
||||
bool Relocate( int nId, int nNewParentId, bool bGlob) ;
|
||||
bool InsertInGeomDB( GdbObj* pGObj, int nRefId, int nSonBeforeAfter, bool bTestId = true) ;
|
||||
int Copy( int nIdSou, int nIdDest, int nRefId, int nSonBeforeAfter, bool bGlob) ;
|
||||
bool Relocate( int nId, int nRefId, int nSonBeforeAfter, bool bGlob) ;
|
||||
bool Erase( GdbObj* pGObj) ;
|
||||
bool LoadHeader( NgeReader& ngeIn) ;
|
||||
bool LoadOneObj( NgeReader& ngeIn, bool& bEnd) ;
|
||||
|
||||
+325
@@ -0,0 +1,325 @@
|
||||
//----------------------------------------------------------------------------
|
||||
// EgalTech 2014-2014
|
||||
//----------------------------------------------------------------------------
|
||||
// File : NfeFont.cpp Data : 29.05.14 Versione : 1.5f1
|
||||
// Contenuto : Implementazione della classe NfeFont (formato font proprietario).
|
||||
//
|
||||
//
|
||||
//
|
||||
// Modifiche : 29.05.14 DS Creazione modulo.
|
||||
//
|
||||
//
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
//--------------------------- Include ----------------------------------------
|
||||
#include "stdafx.h"
|
||||
#include "NfeFont.h"
|
||||
#include "/EgtDev/Include/EGkGeomDB.h"
|
||||
#include "/EgtDev/Include/EGkGdbIterator.h"
|
||||
#include "/EgtDev/Include/EGkCurve.h"
|
||||
#include "/EgtDev/Include/EGkCurveAux.h"
|
||||
#include "/EgtDev/Include/EgtPointerOwner.h"
|
||||
#include "/EgtDev/Include/EgnStringUtils.h"
|
||||
#include "/EgtDev/Include/EGnStringDecoder.h"
|
||||
#include "/EgtDev/Include/EgnFileUtils.h"
|
||||
|
||||
using namespace std ;
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
const string NFE_H = "H" ;
|
||||
const string NFE_HCAP = "HCAP" ;
|
||||
const string NFE_HX = "HX" ;
|
||||
const string NFE_ASC = "ASC" ;
|
||||
const string NFE_DESC = "DESC" ;
|
||||
const string NFE_ADV = "ADV" ;
|
||||
const string NFE_ITALIC = "ITL" ;
|
||||
const double NFE_ITALIC_STD_SHEAR_COEFF = 0.25 ;
|
||||
const int NFE_MIN_CHAR = 32 ;
|
||||
const int NFE_ERR_CHAR = 127 ;
|
||||
const string NFE_LEN_CHAR = "L" ;
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
NfeFont::NfeFont( void)
|
||||
{
|
||||
m_pGDB = nullptr ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
NfeFont::~NfeFont( void)
|
||||
{
|
||||
if ( m_pGDB != nullptr)
|
||||
delete m_pGDB ;
|
||||
m_pGDB = nullptr ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
NfeFont::SetCurrFont( const string& sFont, int nWeight, bool bItalic,
|
||||
double dHeight, double dRatio, double dAddAdvance)
|
||||
{
|
||||
string sFontUp = sFont ;
|
||||
ToUpper( sFontUp) ;
|
||||
|
||||
// se il font non è già caricato
|
||||
if ( m_pGDB == nullptr || m_sFont != sFontUp) {
|
||||
// pulisco la path del font
|
||||
m_sFont.clear() ;
|
||||
// se necessario creo GDB
|
||||
if ( m_pGDB == nullptr) {
|
||||
m_pGDB = CreateGeomDB() ;
|
||||
if ( m_pGDB == nullptr)
|
||||
return false ;
|
||||
}
|
||||
// pulisco e inizializzo GDB
|
||||
m_pGDB->Init() ;
|
||||
// carico il font
|
||||
if ( ! m_pGDB->Load( sFont))
|
||||
return false ;
|
||||
// recupero i parametri generali del font (devono essere nel gruppo 1)
|
||||
PtrOwner<IGdbIterator> pIter( CreateGdbIterator( m_pGDB)) ;
|
||||
if ( ! IsValid( pIter))
|
||||
return false ;
|
||||
if ( ! pIter->GoTo( 1))
|
||||
return false ;
|
||||
if ( ! pIter->GetInfo( NFE_H, m_dH) ||
|
||||
! pIter->GetInfo( NFE_HCAP, m_dHCap) ||
|
||||
! pIter->GetInfo( NFE_HX, m_dHx) ||
|
||||
! pIter->GetInfo( NFE_ASC, m_dAsc) ||
|
||||
! pIter->GetInfo( NFE_DESC, m_dDesc) ||
|
||||
! pIter->GetInfo( NFE_ADV, m_dAdv))
|
||||
return false ;
|
||||
if ( m_dH < EPS_SMALL || m_dHCap < EPS_SMALL || m_dHx < EPS_SMALL)
|
||||
return false ;
|
||||
if ( ! pIter->GetInfo( NFE_ITALIC, m_dItalicShearCoeff))
|
||||
m_dItalicShearCoeff = NFE_ITALIC_STD_SHEAR_COEFF ;
|
||||
// aggiorno la path del font
|
||||
m_sFont = sFontUp ;
|
||||
}
|
||||
|
||||
// salvo i dati
|
||||
m_nWeight = nWeight ;
|
||||
m_bItalic = bItalic ;
|
||||
m_dHeight = dHeight ;
|
||||
m_dRatio = dRatio ;
|
||||
m_dAddAdvance = dAddAdvance ;
|
||||
|
||||
return true ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
NfeFont::GetCapHeight( double& dCapH)
|
||||
{
|
||||
// verifico esistenza font corrente
|
||||
if ( m_pGDB == nullptr || m_sFont.empty())
|
||||
return false ;
|
||||
|
||||
// uso il fattore di scala per Y = m_dHeight / m_dHCap
|
||||
dCapH = m_dHCap * m_dHeight / m_dHCap ;
|
||||
|
||||
return true ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
NfeFont::GetAscent( double& dAsc)
|
||||
{
|
||||
// verifico esistenza font corrente
|
||||
if ( m_pGDB == nullptr || m_sFont.empty())
|
||||
return false ;
|
||||
|
||||
// uso il fattore di scala per Y = m_dHeight / m_dHCap
|
||||
dAsc = m_dAsc * m_dHeight / m_dHCap ;
|
||||
|
||||
return true ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
NfeFont::GetDescent( double& dDesc)
|
||||
{
|
||||
// verifico esistenza font corrente
|
||||
if ( m_pGDB == nullptr || m_sFont.empty())
|
||||
return false ;
|
||||
|
||||
// uso il fattore di scala per Y = m_dHeight / m_dHCap
|
||||
dDesc = m_dDesc * m_dHeight / m_dHCap ;
|
||||
|
||||
return true ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
NfeFont::GetLength( const string& sText, double& dLen)
|
||||
{
|
||||
// verifico esistenza font corrente
|
||||
if ( m_pGDB == nullptr || m_sFont.empty())
|
||||
return false ;
|
||||
|
||||
// creo un iteratore
|
||||
PtrOwner<IGdbIterator> pIter( CreateGdbIterator( m_pGDB)) ;
|
||||
if ( ! IsValid( pIter))
|
||||
return false ;
|
||||
|
||||
// calcolo il fattore di scala
|
||||
double dScaX = m_dHeight / m_dHCap * m_dRatio ;
|
||||
|
||||
// converto i byte della stringa in codici carattere
|
||||
UINTVECTOR vCode ;
|
||||
GetCodePoints( sText, vCode) ;
|
||||
|
||||
// scandisco i codici
|
||||
dLen = 0 ;
|
||||
for ( unsigned int i = 0 ; i < vCode.size() ; ++ i) {
|
||||
// gruppo del carattere
|
||||
int nGroup = sText[i] ;
|
||||
if ( nGroup < NFE_MIN_CHAR || m_pGDB->GetGdbType( nGroup) == GDB_TY_NONE)
|
||||
nGroup = NFE_ERR_CHAR ;
|
||||
// recupero lo spostamento per il prossimo carattere
|
||||
double dAdvance ;
|
||||
if ( ! m_pGDB->GetInfo( nGroup, NFE_LEN_CHAR, dAdvance))
|
||||
dAdvance = m_dAdv ;
|
||||
dLen += dAdvance * dScaX + m_dAddAdvance ;
|
||||
}
|
||||
|
||||
return true ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
NfeFont::GetBBox( const string& sText, BBox3d& b3Box)
|
||||
{
|
||||
// recupero le dimensioni
|
||||
double dAsc ;
|
||||
if ( ! GetAscent( dAsc))
|
||||
return false ;
|
||||
double dDesc ;
|
||||
if ( ! GetDescent( dDesc))
|
||||
return false ;
|
||||
double dLen ;
|
||||
if ( ! GetLength( sText, dLen))
|
||||
return false ;
|
||||
|
||||
// assegno l'ingombro
|
||||
b3Box.Set( 0, - dDesc, 0, dLen, dAsc, 0) ;
|
||||
return true ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
NfeFont::GetOutline( const string& sText, ICURVEPLIST& lstPC)
|
||||
{
|
||||
// verifico esistenza font corrente
|
||||
if ( m_pGDB == nullptr || m_sFont.empty())
|
||||
return false ;
|
||||
|
||||
// creo un iteratore
|
||||
PtrOwner<IGdbIterator> pIter( CreateGdbIterator( m_pGDB)) ;
|
||||
if ( ! IsValid( pIter))
|
||||
return false ;
|
||||
|
||||
// calcolo i fattori di scala
|
||||
double dScaY = m_dHeight / m_dHCap ;
|
||||
double dScaX = dScaY * m_dRatio ;
|
||||
double dScaZ = 1 ;
|
||||
|
||||
// converto i byte della stringa in codici carattere
|
||||
UINTVECTOR vCode ;
|
||||
GetCodePoints( sText, vCode) ;
|
||||
|
||||
// scandisco i codici
|
||||
Vector3d vtMove ;
|
||||
for ( unsigned int i = 0 ; i < vCode.size() ; ++ i) {
|
||||
// verifico esistenza del gruppo del carattere
|
||||
int nGroup = vCode[i] ;
|
||||
if ( nGroup < NFE_MIN_CHAR || m_pGDB->GetGdbType( nGroup) == GDB_TY_NONE)
|
||||
nGroup = NFE_ERR_CHAR ;
|
||||
// ciclo sulle entità geometriche del carattere
|
||||
bool bIter = pIter->GoToFirstInGroup( nGroup) ;
|
||||
while ( bIter) {
|
||||
ICurve* pCrv = GetCurve( pIter->GetGeoObj()) ;
|
||||
if ( pCrv != nullptr) {
|
||||
ICurve* pCopyCrv = GetCurve( pCrv->Clone()) ;
|
||||
if ( pCopyCrv == nullptr)
|
||||
return false ;
|
||||
lstPC.push_back( pCopyCrv) ;
|
||||
if ( m_bItalic) {
|
||||
// se arco, devo trasformarlo in curva di Bezier (semplice o composta)
|
||||
if ( pCopyCrv->GetType() == CRV_ARC) {
|
||||
ICurve* pCrvNew ;
|
||||
if ( ! ArcToBezierCurve( pCopyCrv, pCrvNew))
|
||||
return false ;
|
||||
// elimino l'arco e lo sostituisco con la curva di Bezier
|
||||
delete pCopyCrv ;
|
||||
lstPC.back() = pCrvNew ;
|
||||
}
|
||||
pCopyCrv->Shear( ORIG, Y_AX, X_AX, m_dItalicShearCoeff) ;
|
||||
}
|
||||
pCopyCrv->Scale( GLOB_FRM, dScaX, dScaY, dScaZ) ;
|
||||
pCopyCrv->Translate( vtMove) ;
|
||||
}
|
||||
bIter = pIter->GoToNext() ;
|
||||
}
|
||||
// recupero lo spostamento per il prossimo carattere
|
||||
double dAdvance ;
|
||||
if ( ! m_pGDB->GetInfo( nGroup, NFE_LEN_CHAR, dAdvance))
|
||||
dAdvance = m_dAdv ;
|
||||
vtMove += Vector3d( ( dAdvance * dScaX + m_dAddAdvance), 0, 0) ;
|
||||
}
|
||||
|
||||
return true ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
NfeFont::ApproxWithLines( const string& sText, double dLinTol, double dAngTolDeg, POLYLINELIST& lstPL)
|
||||
{
|
||||
// verifico esistenza font corrente
|
||||
if ( m_pGDB == nullptr || m_sFont.empty())
|
||||
return false ;
|
||||
|
||||
// creo un iteratore
|
||||
PtrOwner<IGdbIterator> pIter( CreateGdbIterator( m_pGDB)) ;
|
||||
if ( ! IsValid( pIter))
|
||||
return false ;
|
||||
|
||||
// calcolo i fattori di scala
|
||||
double dScaY = m_dHeight / m_dHCap ;
|
||||
double dScaX = dScaY * m_dRatio ;
|
||||
double dScaZ = 1 ;
|
||||
double dInvScaMed = 1 / max( ( dScaX + dScaY) / 2, EPS_SMALL) ;
|
||||
|
||||
// converto i byte della stringa in codici carattere
|
||||
UINTVECTOR vCode ;
|
||||
GetCodePoints( sText, vCode) ;
|
||||
|
||||
// scandisco i codici
|
||||
Vector3d vtMove ;
|
||||
for ( unsigned int i = 0 ; i < vCode.size() ; ++ i) {
|
||||
// verifico esistenza del gruppo del carattere
|
||||
int nGroup = vCode[i] ;
|
||||
if ( nGroup < NFE_MIN_CHAR || m_pGDB->GetGdbType( nGroup) == GDB_TY_NONE)
|
||||
nGroup = NFE_ERR_CHAR ;
|
||||
// ciclo sulle entità geometriche del carattere
|
||||
bool bIter = pIter->GoToFirstInGroup( nGroup) ;
|
||||
while ( bIter) {
|
||||
ICurve* pCrv = GetCurve( pIter->GetGeoObj()) ;
|
||||
if ( pCrv != nullptr) {
|
||||
lstPL.push_back( PolyLine()) ;
|
||||
pCrv->ApproxWithLines( dLinTol * dInvScaMed, dAngTolDeg, lstPL.back()) ;
|
||||
if ( m_bItalic)
|
||||
lstPL.back().Shear( ORIG, Y_AX, X_AX, m_dItalicShearCoeff) ;
|
||||
lstPL.back().Scale( GLOB_FRM, dScaX, dScaY, dScaZ) ;
|
||||
lstPL.back().Translate( vtMove) ;
|
||||
}
|
||||
bIter = pIter->GoToNext() ;
|
||||
}
|
||||
// recupero lo spostamento per il prossimo carattere
|
||||
double dAdvance ;
|
||||
if ( ! m_pGDB->GetInfo( nGroup, NFE_LEN_CHAR, dAdvance))
|
||||
dAdvance = m_dAdv ;
|
||||
vtMove += Vector3d( ( dAdvance * dScaX + m_dAddAdvance), 0, 0) ;
|
||||
}
|
||||
|
||||
return true ;
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
//----------------------------------------------------------------------------
|
||||
// EgalTech 2014-2014
|
||||
//----------------------------------------------------------------------------
|
||||
// File : NfeFont.h Data : 29.05.14 Versione : 1.5f1
|
||||
// Contenuto : Dichiarazione della classe NfeFont (formato font proprietario).
|
||||
//
|
||||
//
|
||||
//
|
||||
// Modifiche : 29.05.14 DS Creazione modulo.
|
||||
//
|
||||
//
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "/EgtDev/Include/EGkCurve.h"
|
||||
#include <string>
|
||||
|
||||
class IGeomDB ;
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
class NfeFont
|
||||
{
|
||||
public :
|
||||
NfeFont( void) ;
|
||||
~NfeFont( void) ;
|
||||
bool SetCurrFont( const std::string& sFontPath, int nWeight, bool bItalic,
|
||||
double dHeight, double dRatio, double dAddAdvance) ;
|
||||
bool GetCapHeight( double& dCapH) ;
|
||||
bool GetAscent( double& dAsc) ;
|
||||
bool GetDescent( double& dDesc) ;
|
||||
bool GetLength( const std::string& sText, double& dLen) ;
|
||||
bool GetBBox( const std::string& sText, BBox3d& b3Box) ;
|
||||
bool GetOutline( const std::string& sText, ICURVEPLIST& lstPC) ;
|
||||
bool ApproxWithLines( const std::string& sText, double dLinTol, double dAngTolDeg, POLYLINELIST& lstPL) ;
|
||||
|
||||
private :
|
||||
IGeomDB* m_pGDB ;
|
||||
std::string m_sFont ;
|
||||
int m_nWeight ;
|
||||
bool m_bItalic ;
|
||||
double m_dHeight ;
|
||||
double m_dRatio ;
|
||||
double m_dAddAdvance ;
|
||||
double m_dH ;
|
||||
double m_dHCap ;
|
||||
double m_dHx ;
|
||||
double m_dAsc ;
|
||||
double m_dDesc ;
|
||||
double m_dAdv ;
|
||||
double m_dItalicShearCoeff ;
|
||||
} ;
|
||||
+5
-4
@@ -1,13 +1,13 @@
|
||||
//----------------------------------------------------------------------------
|
||||
// EgalTech 2014-2014
|
||||
//----------------------------------------------------------------------------
|
||||
// File : NgeConst.h Data : 12.04.14 Versione : 1.5d3
|
||||
// File : NgeConst.h Data : 28.05.14 Versione : 1.5e10
|
||||
// Contenuto : Costanti per file Nge.
|
||||
//
|
||||
//
|
||||
//
|
||||
// Modifiche : 12.04.14 DS Creazione modulo.
|
||||
//
|
||||
// 28.05.14 DS 1.5.7 -> aggiunto aggetto Testo.
|
||||
//
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
@@ -21,7 +21,7 @@
|
||||
// versione
|
||||
const int NGE_MAJOR_VER = 1 ;
|
||||
const int NGE_MINOR_VER = 5 ;
|
||||
const int NGE_PATCH_VER = 6 ;
|
||||
const int NGE_PATCH_VER = 7 ;
|
||||
// nome GDB
|
||||
const std::string NGE_GEOMDB = "GeomDB" ;
|
||||
// indici KeyWord
|
||||
@@ -42,4 +42,5 @@ const int NGE_C_ARC = 13 ;
|
||||
const int NGE_C_BEZ = 14 ;
|
||||
const int NGE_C_CMP = 15 ;
|
||||
const int NGE_S_TRM = 16 ;
|
||||
const int NGE_LAST_ID = 16 ; // ultimo valore
|
||||
const int NGE_E_TXT = 17 ;
|
||||
const int NGE_LAST_ID = 17 ; // ultimo valore
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
//----------------------------------------------------------------------------
|
||||
// EgalTech 2014-2014
|
||||
//----------------------------------------------------------------------------
|
||||
// File : NgeKeyW.h Data : 13.04.14 Versione : 1.5d5
|
||||
// File : NgeKeyW.h Data : 28.05.14 Versione : 1.5e10
|
||||
// Contenuto : Parole chiave per file Nge.
|
||||
//
|
||||
//
|
||||
@@ -36,7 +36,8 @@ const std::string NgeAscKeyW[] = { "START", // NGE_START
|
||||
"C_ARC", // NGE_C_ARC
|
||||
"C_BEZ", // NGE_C_BEZ
|
||||
"C_CMP", // NGE_C_CMP
|
||||
"S_TRM"} ; // NGE_S_TRM
|
||||
"S_TRM", // NGE_S_TRM
|
||||
"E_TXT"} ; // NGE_E_TXT
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
// KeyWord per file NGE BINARY
|
||||
@@ -62,4 +63,5 @@ const int NgeBinKeyW[] = { NGEB_GEN_BASE + 0x0F0F, // NGE_START
|
||||
NGEB_GEO_BASE + CRV_ARC, // NGE_C_ARC
|
||||
NGEB_GEO_BASE + CRV_BEZ, // NGE_C_BEZ
|
||||
NGEB_GEO_BASE + CRV_COMPO, // NGE_C_CMP
|
||||
NGEB_GEO_BASE + SRF_TRIMESH} ; // NGE_S_TRM
|
||||
NGEB_GEO_BASE + SRF_TRIMESH, // NGE_S_TRM
|
||||
NGEB_GEO_BASE + EXT_TEXT} ; // NGE_E_TXT
|
||||
+517
@@ -0,0 +1,517 @@
|
||||
//----------------------------------------------------------------------------
|
||||
// EgalTech 2014-2014
|
||||
//----------------------------------------------------------------------------
|
||||
// File : OsFont.cpp Data : 01.06.14 Versione : 1.5f1
|
||||
// Contenuto : Implementazione della classe NfeFont (formato font proprietario).
|
||||
//
|
||||
//
|
||||
//
|
||||
// Modifiche : 01.06.14 DS Creazione modulo.
|
||||
//
|
||||
//
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
//--------------------------- Include ----------------------------------------
|
||||
#include "stdafx.h"
|
||||
#include "OsFont.h"
|
||||
#include "/EgtDev/Include/EGkGeomDB.h"
|
||||
#include "/EgtDev/Include/EGkGdbIterator.h"
|
||||
#include "/EgtDev/Include/EGkCurve.h"
|
||||
#include "/EgtDev/Include/EGkCurveAux.h"
|
||||
#include "/EgtDev/Include/EgkCurveComposite.h"
|
||||
#include "/EgtDev/Include/EgkCurveLine.h"
|
||||
#include "/EgtDev/Include/EgkCurveBezier.h"
|
||||
#include "/EgtDev/Include/EgtPointerOwner.h"
|
||||
#include "/EgtDev/Include/EgnStringUtils.h"
|
||||
#include "/EgtDev/Include/EGnStringConverter.h"
|
||||
#include "/EgtDev/Include/EGnStringDecoder.h"
|
||||
#include "/EgtDev/Include/EgnFileUtils.h"
|
||||
|
||||
using namespace std ;
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
const int OSF_HSTD = 100 ;
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
OsFont::OsFont( void)
|
||||
{
|
||||
m_hDC = nullptr ;
|
||||
m_hFont = nullptr ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
OsFont::~OsFont( void)
|
||||
{
|
||||
if ( m_hFont != nullptr)
|
||||
DeleteObject( m_hFont) ;
|
||||
m_hFont = nullptr ;
|
||||
if ( m_hDC != nullptr)
|
||||
ReleaseDC( NULL, m_hDC) ;
|
||||
m_hDC = nullptr ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
OsFont::SetCurrFont( const string& sFont, int nWeight, bool bItalic,
|
||||
double dHeight, double dRatio, double dAddAdvance)
|
||||
{
|
||||
string sFontUp = sFont ;
|
||||
ToUpper( sFontUp) ;
|
||||
|
||||
// se il font non è già caricato
|
||||
if ( m_sFont != sFontUp) {
|
||||
// pulisco la path del font
|
||||
m_sFont.clear() ;
|
||||
// cancello eventuale precedente font
|
||||
if ( m_hFont != nullptr)
|
||||
DeleteObject( m_hFont) ;
|
||||
// se necessario, recupero il device di schermo
|
||||
if ( m_hDC == nullptr)
|
||||
m_hDC = GetDC( nullptr) ;
|
||||
if ( m_hDC == nullptr)
|
||||
return false ;
|
||||
::SetMapMode( m_hDC, MM_TEXT) ;
|
||||
// creo il font
|
||||
m_hFont = CreateFontW( - OSF_HSTD, 0, 0, 0, nWeight, bItalic, false, false, DEFAULT_CHARSET,
|
||||
OUT_TT_ONLY_PRECIS, CLIP_DEFAULT_PRECIS, PROOF_QUALITY, DEFAULT_PITCH,
|
||||
stringtoW( sFont)) ;
|
||||
if ( m_hFont == nullptr)
|
||||
return false ;
|
||||
// aggiorno dati del font
|
||||
if ( ! CalcFontData())
|
||||
return false ;
|
||||
// aggiorno la path del font
|
||||
m_sFont = sFontUp ;
|
||||
}
|
||||
|
||||
// salvo i dati
|
||||
m_nWeight = nWeight ;
|
||||
m_bItalic = bItalic ;
|
||||
m_dHeight = dHeight ;
|
||||
m_dRatio = dRatio ;
|
||||
m_dAddAdvance = dAddAdvance ;
|
||||
|
||||
return true ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
OsFont::CalcFontData( void)
|
||||
{
|
||||
// verifico esistenza font corrente (non controllo nome)
|
||||
if ( m_hDC == nullptr || m_hFont == nullptr)
|
||||
return false ;
|
||||
|
||||
// rendo corrente il font
|
||||
HFONT hPrevFont = (HFONT) SelectObject( m_hDC, m_hFont) ;
|
||||
if ( hPrevFont == nullptr)
|
||||
return false ;
|
||||
|
||||
// dati generali
|
||||
TEXTMETRIC tm ;
|
||||
if ( ! GetTextMetrics( m_hDC, &tm))
|
||||
return false ;
|
||||
double dCoeff = (( tm.tmHeight > 0) ? double( OSF_HSTD) / tm.tmHeight : 1) ;
|
||||
m_dH = ( tm.tmHeight + tm.tmExternalLeading) * dCoeff ;
|
||||
m_dHCap = ( tm.tmAscent - tm.tmInternalLeading) * dCoeff ;
|
||||
m_dHx = 0.6667 * m_dHCap ; // approx
|
||||
m_dAsc = tm.tmAscent * dCoeff ;
|
||||
m_dDesc = tm.tmDescent * dCoeff ;
|
||||
m_dAdv = tm.tmMaxCharWidth * dCoeff ;
|
||||
|
||||
// cerco dato più preciso su altezza delle maiuscole
|
||||
GLYPHMETRICS gm ;
|
||||
MAT2 mat = { {0,1},{0,0},{0,0},{0,1}} ;
|
||||
// recupero l'altezza della lettera 'H' (72)
|
||||
DWORD dwSize = GetGlyphOutlineW( m_hDC, 72, GGO_NATIVE, &gm, 0, NULL, &mat) ;
|
||||
if ( dwSize != GDI_ERROR) {
|
||||
m_dHCap = gm.gmBlackBoxY ;
|
||||
m_dHx = 0.6667 * m_dHCap ; // approx
|
||||
}
|
||||
|
||||
// ripristino il font originale
|
||||
SelectObject( m_hDC, hPrevFont) ;
|
||||
|
||||
return true ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
OsFont::GetCapHeight( double& dCapH)
|
||||
{
|
||||
// verifico esistenza font corrente
|
||||
if ( m_hDC == nullptr || m_hFont == nullptr || m_sFont.empty())
|
||||
return false ;
|
||||
|
||||
// uso il fattore di scala per Y = m_dHeight / m_dHCap
|
||||
dCapH = m_dHCap * m_dHeight / m_dHCap ;
|
||||
|
||||
return true ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
OsFont::GetAscent( double& dAsc)
|
||||
{
|
||||
// verifico esistenza font corrente
|
||||
if ( m_hDC == nullptr || m_hFont == nullptr || m_sFont.empty())
|
||||
return false ;
|
||||
|
||||
// uso il fattore di scala per Y = m_dHeight / m_dHCap
|
||||
dAsc = m_dAsc * m_dHeight / m_dHCap ;
|
||||
|
||||
return true ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
OsFont::GetDescent( double& dDesc)
|
||||
{
|
||||
// verifico esistenza font corrente
|
||||
if ( m_hDC == nullptr || m_hFont == nullptr || m_sFont.empty())
|
||||
return false ;
|
||||
|
||||
// uso il fattore di scala per Y = m_dHeight / m_dHCap
|
||||
dDesc = m_dDesc * m_dHeight / m_dHCap ;
|
||||
|
||||
return true ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
OsFont::GetLength( const string& sText, double& dLen)
|
||||
{
|
||||
// verifico esistenza font corrente
|
||||
if ( m_hDC == nullptr || m_hFont == nullptr || m_sFont.empty())
|
||||
return false ;
|
||||
|
||||
// rendo corrente il font
|
||||
HFONT hPrevFont = (HFONT) SelectObject( m_hDC, m_hFont) ;
|
||||
if ( hPrevFont == nullptr)
|
||||
return false ;
|
||||
|
||||
// calcolo i fattori di scala
|
||||
double dScaY = m_dHeight / m_dHCap ;
|
||||
double dScaX = dScaY * m_dRatio ;
|
||||
|
||||
// converto i byte della stringa in codici carattere
|
||||
UINTVECTOR vCode ;
|
||||
GetCodePoints( sText, vCode) ;
|
||||
|
||||
// ciclo sui caratteri
|
||||
dLen = 0 ;
|
||||
for ( unsigned int i = 0 ; i < vCode.size() ; ++ i) {
|
||||
// recupero l'avanzamento di ogni carattere
|
||||
ABC abc ;
|
||||
double dAdvance ;
|
||||
if ( GetCharABCWidths( m_hDC, vCode[i], vCode[i], &abc))
|
||||
dAdvance = ( abc.abcA + abc.abcB + abc.abcC) ;
|
||||
else
|
||||
dAdvance = m_dAdv ;
|
||||
dLen += dAdvance * dScaX + m_dAddAdvance ;
|
||||
}
|
||||
|
||||
// ripristino il font originale
|
||||
SelectObject( m_hDC, hPrevFont) ;
|
||||
|
||||
return true ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
OsFont::GetBBox( const string& sText, BBox3d& b3Box)
|
||||
{
|
||||
// recupero le dimensioni
|
||||
double dAsc ;
|
||||
if ( ! GetAscent( dAsc))
|
||||
return false ;
|
||||
double dDesc ;
|
||||
if ( ! GetDescent( dDesc))
|
||||
return false ;
|
||||
double dLen ;
|
||||
if ( ! GetLength( sText, dLen))
|
||||
return false ;
|
||||
|
||||
// assegno l'ingombro
|
||||
b3Box.Set( 0, - dDesc, 0, dLen, dAsc, 0) ;
|
||||
return true ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
OsFont::GetOutline( const string& sText, ICURVEPLIST& lstPC)
|
||||
{
|
||||
// verifico esistenza font corrente
|
||||
if ( m_hDC == nullptr || m_hFont == nullptr || m_sFont.empty())
|
||||
return false ;
|
||||
|
||||
// rendo corrente il font
|
||||
HFONT hPrevFont = (HFONT) SelectObject( m_hDC, m_hFont) ;
|
||||
if ( hPrevFont == nullptr)
|
||||
return false ;
|
||||
|
||||
// calcolo i fattori di scala
|
||||
double dScaY = m_dHeight / m_dHCap ;
|
||||
double dScaX = dScaY * m_dRatio ;
|
||||
double dScaZ = 1 ;
|
||||
|
||||
// converto i byte della stringa in codici carattere
|
||||
UINTVECTOR vCode ;
|
||||
GetCodePoints( sText, vCode) ;
|
||||
|
||||
// ciclo sui caratteri
|
||||
Vector3d vtMove ;
|
||||
ICURVEPLIST lstTmpPC ;
|
||||
for ( unsigned int i = 0 ; i < vCode.size() ; ++ i) {
|
||||
// recupero l'outline
|
||||
double dAdvance ;
|
||||
if ( ! GetCharOutline( vCode[i], dAdvance, lstTmpPC))
|
||||
return false ;
|
||||
// lo trasformo opportunamente
|
||||
ICURVEPLIST::iterator iIter ;
|
||||
for ( iIter = lstTmpPC.begin() ; iIter != lstTmpPC.end() ; ++ iIter) {
|
||||
// trasformazioni
|
||||
(*iIter)->Scale( GLOB_FRM, dScaX, dScaY, dScaZ) ;
|
||||
(*iIter)->Translate( vtMove) ;
|
||||
// inserimento nella lista principale
|
||||
lstPC.push_back( (*iIter)) ;
|
||||
}
|
||||
vtMove += Vector3d( dAdvance * dScaX + m_dAddAdvance, 0, 0) ;
|
||||
// ciclo di pulizia ( non devo cancellare le curve, perchè spostate nella lista principale)
|
||||
lstTmpPC.clear() ;
|
||||
}
|
||||
|
||||
// ripristino il font originale
|
||||
SelectObject( m_hDC, hPrevFont) ;
|
||||
|
||||
return true ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
OsFont::ApproxWithLines( const string& sText, double dLinTol, double dAngTolDeg, POLYLINELIST& lstPL)
|
||||
{
|
||||
// verifico esistenza font corrente
|
||||
if ( m_hDC == nullptr || m_hFont == nullptr || m_sFont.empty())
|
||||
return false ;
|
||||
|
||||
// rendo corrente il font
|
||||
HFONT hPrevFont = (HFONT) SelectObject( m_hDC, m_hFont) ;
|
||||
if ( hPrevFont == nullptr)
|
||||
return false ;
|
||||
|
||||
// calcolo i fattori di scala
|
||||
double dScaY = m_dHeight / m_dHCap ;
|
||||
double dScaX = dScaY * m_dRatio ;
|
||||
double dScaZ = 1 ;
|
||||
|
||||
// converto i byte della stringa in codici carattere
|
||||
UINTVECTOR vCode ;
|
||||
GetCodePoints( sText, vCode) ;
|
||||
|
||||
// ciclo sui caratteri
|
||||
Vector3d vtMove ;
|
||||
ICURVEPLIST lstPC ;
|
||||
for ( unsigned int i = 0 ; i < vCode.size() ; ++ i) {
|
||||
// recupero l'outline
|
||||
double dAdvance ;
|
||||
if ( ! GetCharOutline( vCode[i], dAdvance, lstPC))
|
||||
return false ;
|
||||
// lo approssimo con segmenti di retta
|
||||
ICURVEPLIST::iterator iIter ;
|
||||
for ( iIter = lstPC.begin() ; iIter != lstPC.end() ; ++ iIter) {
|
||||
lstPL.push_back( PolyLine()) ;
|
||||
if ( (*iIter)->ApproxWithLines( dLinTol, dAngTolDeg, lstPL.back())) {
|
||||
lstPL.back().Scale( GLOB_FRM, dScaX, dScaY, dScaZ) ;
|
||||
lstPL.back().Translate( vtMove) ;
|
||||
}
|
||||
}
|
||||
vtMove += Vector3d( dAdvance * dScaX + m_dAddAdvance, 0, 0) ;
|
||||
// ciclo di pulizia
|
||||
for ( iIter = lstPC.begin() ; iIter != lstPC.end() ; ++ iIter)
|
||||
delete (*iIter) ;
|
||||
lstPC.clear() ;
|
||||
}
|
||||
|
||||
// ripristino il font originale
|
||||
SelectObject( m_hDC, hPrevFont) ;
|
||||
|
||||
return true ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
double
|
||||
DoubleFromFixed( FIXED fx)
|
||||
{
|
||||
return ( double( fx.value) + double( fx.fract) * ( 1.0 / 65536.0)) ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
FIXED
|
||||
MediaTwoFixed( FIXED fx1, FIXED fx2)
|
||||
{
|
||||
long l = 0L ;
|
||||
|
||||
l = (*((long*)&(fx1)) + *((long*)&(fx2))) / 2L ;
|
||||
|
||||
return (*(FIXED*)&l) ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
OsFont::GetCharOutline( unsigned int nChar, double& dAdvance, ICURVEPLIST& lstPC)
|
||||
{
|
||||
GLYPHMETRICS gm ;
|
||||
MAT2 mat = { {0,1},{0,0},{0,0},{0,1}} ;
|
||||
// recupero la dimensione necessaria del buffer e lo alloco
|
||||
DWORD dwSize = GetGlyphOutlineW( m_hDC, nChar, GGO_NATIVE, &gm, 0, NULL, &mat) ;
|
||||
if ( dwSize == GDI_ERROR)
|
||||
return false ;
|
||||
PtrOwner<char> pBuffer( new char[dwSize]) ;
|
||||
if ( ! ::IsValid( pBuffer))
|
||||
return false ;
|
||||
// recupero l'outline
|
||||
DWORD dErr = GetGlyphOutlineW( m_hDC, nChar, GGO_NATIVE, &gm, dwSize, ::Get( pBuffer), &mat) ;
|
||||
if ( dErr == GDI_ERROR) {
|
||||
//delete pBuffer ;
|
||||
return false ;
|
||||
}
|
||||
|
||||
// assegno l'avanzamento al prossimo carattere
|
||||
dAdvance = gm.gmCellIncX ;
|
||||
|
||||
// mentre esistono nuovi contorni
|
||||
LPTTPOLYGONHEADER pHeader = (LPTTPOLYGONHEADER) ::Get( pBuffer) ;
|
||||
while ( (LPSTR) pHeader < ( ::Get( pBuffer) + ptrdiff_t( dwSize))) {
|
||||
|
||||
// leggo un nuovo contorno
|
||||
if ( pHeader->dwType == TT_POLYGON_TYPE) {
|
||||
|
||||
// creo curva composita
|
||||
PtrOwner<ICurveComposite> pCCompo( CreateCurveComposite()) ;
|
||||
if ( ! ::IsValid( pCCompo))
|
||||
return false ;
|
||||
|
||||
// posizionamento sul punto iniziale
|
||||
Point3d ptFirst( DoubleFromFixed( pHeader->pfxStart.x),
|
||||
DoubleFromFixed( pHeader->pfxStart.y),
|
||||
0) ;
|
||||
Point3d ptLast = ptFirst ;
|
||||
|
||||
// puntatore alla prima polycurva
|
||||
LPTTPOLYCURVE pCurve = (LPTTPOLYCURVE)( pHeader + 1) ;
|
||||
|
||||
// mentre esistono polycurve
|
||||
while ( (LPSTR) pCurve < ( (LPSTR) pHeader + ptrdiff_t( pHeader->cb))) {
|
||||
// numero punti
|
||||
int nPnt = pCurve->cpfx ;
|
||||
// se rette
|
||||
if ( pCurve->wType == TT_PRIM_LINE) {
|
||||
for ( int i = 0 ; i < nPnt ; ++ i ) {
|
||||
Point3d ptP( DoubleFromFixed( pCurve->apfx[i].x),
|
||||
DoubleFromFixed( pCurve->apfx[i].y),
|
||||
0) ;
|
||||
if ( ! AreSamePointNear( ptLast, ptP)) {
|
||||
// aggiungo la retta alla curva composita
|
||||
if ( ! AddLineToCompo( ::Get( pCCompo), ptLast, ptP))
|
||||
return false ;
|
||||
// salvo punto come ultimo
|
||||
ptLast = ptP ;
|
||||
}
|
||||
}
|
||||
}
|
||||
// se curve di Bezier quadratiche
|
||||
else if ( pCurve->wType == TT_PRIM_QSPLINE) {
|
||||
for ( int i = 0 ; i < nPnt - 1 ; ++ i ) {
|
||||
// punto medio CBezier
|
||||
Point3d ptM( DoubleFromFixed( pCurve->apfx[i].x),
|
||||
DoubleFromFixed( pCurve->apfx[i].y),
|
||||
0) ;
|
||||
// punto finale CBezier
|
||||
POINTFX pfEnd ;
|
||||
// se non è alla fine è il medio dei due punti adiacenti del poligono
|
||||
if ( i < ( nPnt - 2)) {
|
||||
pfEnd.x = MediaTwoFixed( pCurve->apfx[i].x, pCurve->apfx[i+1].x) ;
|
||||
pfEnd.y = MediaTwoFixed( pCurve->apfx[i].y, pCurve->apfx[i+1].y) ;
|
||||
}
|
||||
else
|
||||
pfEnd = pCurve->apfx[i+1] ;
|
||||
Point3d ptE( DoubleFromFixed( pfEnd.x),
|
||||
DoubleFromFixed( pfEnd.y),
|
||||
0) ;
|
||||
// aggiungo la curva di Bezier quadratica alla curva composita
|
||||
if ( ! AddCBezierQuadToCompo( ::Get( pCCompo), ptLast, ptM, ptE))
|
||||
return false ;
|
||||
// salvo punto finale come ultimo
|
||||
ptLast = ptE ;
|
||||
}
|
||||
}
|
||||
// altrimenti errore
|
||||
else {
|
||||
return false ;
|
||||
}
|
||||
// si passa alla polycurva successiva
|
||||
pCurve = (LPTTPOLYCURVE) &( pCurve->apfx[nPnt]) ;
|
||||
}
|
||||
// si aggiunge, se necessario, una linea retta per chiudere la curva
|
||||
if ( ! AreSamePointNear( ptFirst, ptLast)) {
|
||||
// aggiungo la retta alla curva composita
|
||||
if ( ! AddLineToCompo( ::Get( pCCompo), ptLast, ptFirst))
|
||||
return false ;
|
||||
// salvo ultimo punto
|
||||
ptLast = ptFirst ;
|
||||
}
|
||||
// se curva composita ok, la inserisco in lista
|
||||
if ( pCCompo->IsValid())
|
||||
lstPC.push_back( ::Release( pCCompo)) ;
|
||||
}
|
||||
// mi sposto sul prossimo contorno
|
||||
pHeader = (LPTTPOLYGONHEADER) ( (LPSTR) pHeader + ptrdiff_t( pHeader->cb)) ;
|
||||
}
|
||||
|
||||
return true ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
OsFont::AddLineToCompo( ICurveComposite* pCCompo, const Point3d& ptStart, const Point3d& ptEnd)
|
||||
{
|
||||
// verifico curva composita
|
||||
if ( pCCompo == nullptr)
|
||||
return false ;
|
||||
|
||||
// creo retta, la imposto e la inserisco nella curva composita
|
||||
PtrOwner<ICurveLine> pCLine( CreateCurveLine()) ;
|
||||
if ( ! ::IsValid( pCLine))
|
||||
return false ;
|
||||
if ( ! pCLine->Set( ptStart, ptEnd))
|
||||
return false ;
|
||||
if ( ! pCCompo->AddCurve( ::Release( pCLine)))
|
||||
return false ;
|
||||
|
||||
return true ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
OsFont::AddCBezierQuadToCompo( ICurveComposite* pCCompo,
|
||||
const Point3d& ptStart, const Point3d& ptMid, const Point3d& ptEnd)
|
||||
{
|
||||
// verifico curva composita
|
||||
if ( pCCompo == nullptr)
|
||||
return false ;
|
||||
|
||||
// creo curva di Bezier quadratica, la imposto e la inserisco nella curva composita
|
||||
PtrOwner<ICurveBezier> pCBezier( CreateCurveBezier()) ;
|
||||
if ( ! ::IsValid( pCBezier))
|
||||
return false ;
|
||||
if ( ! pCBezier->Init( 2, false) ||
|
||||
! pCBezier->SetControlPoint( 0, ptStart) ||
|
||||
! pCBezier->SetControlPoint( 1, ptMid) ||
|
||||
! pCBezier->SetControlPoint( 2, ptEnd))
|
||||
return false ;
|
||||
if ( ! pCCompo->AddCurve( ::Release( pCBezier)))
|
||||
return false ;
|
||||
|
||||
return true ;
|
||||
}
|
||||
@@ -0,0 +1,61 @@
|
||||
//----------------------------------------------------------------------------
|
||||
// EgalTech 2014-2014
|
||||
//----------------------------------------------------------------------------
|
||||
// File : OsFont.h Data : 01.06.14 Versione : 1.5f1
|
||||
// Contenuto : Dichiarazione della classe OsFont (font di sistema).
|
||||
//
|
||||
//
|
||||
//
|
||||
// Modifiche : 01.06.14 DS Creazione modulo.
|
||||
//
|
||||
//
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "/EgtDev/Include/EGkCurve.h"
|
||||
#include <string>
|
||||
#include <Windows.h>
|
||||
#include <WinGDI.h>
|
||||
|
||||
class ICurveComposite ;
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
class OsFont
|
||||
{
|
||||
public :
|
||||
OsFont( void) ;
|
||||
~OsFont( void) ;
|
||||
bool SetCurrFont( const std::string& sFontPath, int nWeight, bool bItalic,
|
||||
double dHeight, double dRatio, double dAddAdvance) ;
|
||||
bool GetCapHeight( double& dCapH) ;
|
||||
bool GetAscent( double& dAsc) ;
|
||||
bool GetDescent( double& dDesc) ;
|
||||
bool GetLength( const std::string& sText, double& dLen) ;
|
||||
bool GetBBox( const std::string& sText, BBox3d& b3Box) ;
|
||||
bool GetOutline( const std::string& sText, ICURVEPLIST& lstPC) ;
|
||||
bool ApproxWithLines( const std::string& sText, double dLinTol, double dAngTolDeg, POLYLINELIST& lstPL) ;
|
||||
|
||||
private :
|
||||
bool CalcFontData( void) ;
|
||||
bool GetCharOutline( unsigned int nChar, double& dAdvance, ICURVEPLIST& lstPC) ;
|
||||
bool AddLineToCompo( ICurveComposite* pCCompo, const Point3d& ptStart, const Point3d& ptEnd) ;
|
||||
bool AddCBezierQuadToCompo( ICurveComposite* pCCompo,
|
||||
const Point3d& ptStart, const Point3d& ptMid, const Point3d& ptEnd) ;
|
||||
|
||||
private :
|
||||
HDC m_hDC ;
|
||||
HFONT m_hFont ;
|
||||
std::string m_sFont ;
|
||||
int m_nWeight ;
|
||||
bool m_bItalic ;
|
||||
double m_dHeight ;
|
||||
double m_dRatio ;
|
||||
double m_dAddAdvance ;
|
||||
double m_dH ;
|
||||
double m_dHCap ;
|
||||
double m_dHx ;
|
||||
double m_dAsc ;
|
||||
double m_dDesc ;
|
||||
double m_dAdv ;
|
||||
} ;
|
||||
+22
-13
@@ -30,8 +30,9 @@ Point3d::Translate( const Vector3d& vtMove)
|
||||
// Rotazione
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
Point3d::Rotate( const Point3d& ptAx, const Vector3d& vtAx, double dAngRad)
|
||||
Point3d::Rotate( const Point3d& ptAx, const Vector3d& vtAx, double dAngDeg)
|
||||
{
|
||||
double dAngRad = dAngDeg * DEGTORAD ;
|
||||
return Rotate( ptAx, vtAx, cos( dAngRad), sin( dAngRad)) ;
|
||||
}
|
||||
|
||||
@@ -41,11 +42,8 @@ Point3d::Rotate( const Point3d& ptAx, const Vector3d& vtAx, double dAngRad)
|
||||
bool
|
||||
Point3d::Rotate( const Point3d& ptAx, const Vector3d& vtAx, double dCosAng, double dSinAng)
|
||||
{
|
||||
Vector3d vtDiff ;
|
||||
|
||||
|
||||
// vettore dall'asse al punto
|
||||
vtDiff = *this - ptAx ;
|
||||
Vector3d vtDiff = *this - ptAx ;
|
||||
if ( vtDiff.IsZero())
|
||||
return true ;
|
||||
|
||||
@@ -65,11 +63,8 @@ Point3d::Rotate( const Point3d& ptAx, const Vector3d& vtAx, double dCosAng, doub
|
||||
bool
|
||||
Point3d::Scale( const Frame3d& frRef, double dCoeffX, double dCoeffY, double dCoeffZ)
|
||||
{
|
||||
Vector3d vtDiff ;
|
||||
|
||||
|
||||
// vettore dal centro al punto
|
||||
vtDiff = *this - frRef.Orig() ;
|
||||
Vector3d vtDiff = *this - frRef.Orig() ;
|
||||
if ( vtDiff.IsZero())
|
||||
return true ;
|
||||
|
||||
@@ -89,11 +84,8 @@ Point3d::Scale( const Frame3d& frRef, double dCoeffX, double dCoeffY, double dCo
|
||||
bool
|
||||
Point3d::Mirror( const Point3d& ptOn, const Vector3d& vtNorm)
|
||||
{
|
||||
Vector3d vtDiff ;
|
||||
|
||||
|
||||
// vettore dal riferimento al punto
|
||||
vtDiff = *this - ptOn ;
|
||||
Vector3d vtDiff = *this - ptOn ;
|
||||
if ( vtDiff.IsZero())
|
||||
return true ;
|
||||
|
||||
@@ -107,6 +99,23 @@ Point3d::Mirror( const Point3d& ptOn, const Vector3d& vtNorm)
|
||||
return true ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
// Scorrimento
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
Point3d::Shear( const Point3d& ptOn, const Vector3d& vtNorm, const Vector3d& vtDir, double dCoeff)
|
||||
{
|
||||
// vettore dal riferimento al punto
|
||||
Vector3d vtDiff = *this - ptOn ;
|
||||
if ( vtDiff.IsZero())
|
||||
return true ;
|
||||
|
||||
// ricostruisco il punto
|
||||
*this += dCoeff * ( vtDiff * vtNorm) * vtDir ;
|
||||
|
||||
return true ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
// Cambio di riferimento : dal riferimento al globale
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
+88
-2
@@ -87,14 +87,100 @@ bool
|
||||
PolyLine::AddOffsetToU( double dOffset)
|
||||
{
|
||||
UPNTLIST::iterator iter ;
|
||||
|
||||
|
||||
for ( iter = m_lUPoints.begin() ; iter != m_lUPoints.end() ; ++ iter)
|
||||
iter->first += dOffset ;
|
||||
|
||||
return true ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
PolyLine::Translate( const Vector3d& vtMove)
|
||||
{
|
||||
UPNTLIST::iterator iter ;
|
||||
for ( iter = m_lUPoints.begin() ; iter != m_lUPoints.end() ; ++ iter)
|
||||
iter->second.Translate( vtMove) ;
|
||||
|
||||
return true ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
PolyLine::Rotate( const Point3d& ptAx, const Vector3d& vtAx, double dCosAng, double dSinAng)
|
||||
{
|
||||
UPNTLIST::iterator iter ;
|
||||
for ( iter = m_lUPoints.begin() ; iter != m_lUPoints.end() ; ++ iter)
|
||||
iter->second.Rotate( ptAx, vtAx, dCosAng, dSinAng) ;
|
||||
|
||||
return true ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
PolyLine::Scale( const Frame3d& frRef, double dCoeffX, double dCoeffY, double dCoeffZ)
|
||||
{
|
||||
UPNTLIST::iterator iter ;
|
||||
for ( iter = m_lUPoints.begin() ; iter != m_lUPoints.end() ; ++ iter)
|
||||
iter->second.Scale( frRef, dCoeffX, dCoeffY, dCoeffZ) ;
|
||||
|
||||
return true ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
PolyLine::Mirror( const Point3d& ptOn, const Vector3d& vtNorm)
|
||||
{
|
||||
UPNTLIST::iterator iter ;
|
||||
for ( iter = m_lUPoints.begin() ; iter != m_lUPoints.end() ; ++ iter)
|
||||
iter->second.Mirror( ptOn, vtNorm) ;
|
||||
|
||||
return true ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
PolyLine::Shear( const Point3d& ptOn, const Vector3d& vtNorm, const Vector3d& vtDir, double dCoeff)
|
||||
{
|
||||
UPNTLIST::iterator iter ;
|
||||
for ( iter = m_lUPoints.begin() ; iter != m_lUPoints.end() ; ++ iter)
|
||||
iter->second.Shear( ptOn, vtNorm, vtDir, dCoeff) ;
|
||||
|
||||
return true ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
PolyLine::ToGlob( const Frame3d& frRef)
|
||||
{
|
||||
UPNTLIST::iterator iter ;
|
||||
for ( iter = m_lUPoints.begin() ; iter != m_lUPoints.end() ; ++ iter)
|
||||
iter->second.ToGlob( frRef) ;
|
||||
|
||||
return true ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
PolyLine::ToLoc( const Frame3d& frRef)
|
||||
{
|
||||
UPNTLIST::iterator iter ;
|
||||
for ( iter = m_lUPoints.begin() ; iter != m_lUPoints.end() ; ++ iter)
|
||||
iter->second.ToLoc( frRef) ;
|
||||
|
||||
return true ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
PolyLine::LocToLoc( const Frame3d& frOri, const Frame3d& frDest)
|
||||
{
|
||||
UPNTLIST::iterator iter ;
|
||||
for ( iter = m_lUPoints.begin() ; iter != m_lUPoints.end() ; ++ iter)
|
||||
iter->second.LocToLoc( frOri, frDest) ;
|
||||
|
||||
return true ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
PolyLine::Splice( PolyLine& PL)
|
||||
|
||||
+64
-3
@@ -1786,6 +1786,39 @@ SurfTriMesh::Mirror( const Point3d& ptOn, const Vector3d& vtNorm)
|
||||
return true ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
SurfTriMesh::Shear( const Point3d& ptOn, const Vector3d& vtNorm, const Vector3d& vtDir, double dCoeff)
|
||||
{
|
||||
// la superficie deve essere validata
|
||||
if ( m_nStatus != OK)
|
||||
return false ;
|
||||
|
||||
// verifico validità dei parametri
|
||||
if ( vtNorm.IsSmall() || vtDir.IsSmall())
|
||||
return false ;
|
||||
|
||||
// imposto ricalcolo della grafica
|
||||
m_OGrMgr.Reset() ;
|
||||
|
||||
// eseguo scorrimento dei vertici
|
||||
for ( int i = 0 ; i < GetVertexSize() ; ++ i) {
|
||||
if ( m_vVert[i].nIdTria != SVT_DEL)
|
||||
m_vVert[i].ptP.Shear( ptOn, vtNorm, vtDir, dCoeff) ;
|
||||
}
|
||||
|
||||
// aggiorno le facce
|
||||
for ( int i = 0 ; i < GetTriangleSize() ; ++ i) {
|
||||
if ( m_vTria[i].nIdVert[0] != SVT_DEL) {
|
||||
// aggiorno la normale
|
||||
if ( ! CalcTriangleNormal( i))
|
||||
return false ;
|
||||
}
|
||||
}
|
||||
|
||||
return true ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
SurfTriMesh::ToGlob( const Frame3d& frRef)
|
||||
@@ -1798,15 +1831,15 @@ SurfTriMesh::ToGlob( const Frame3d& frRef)
|
||||
if ( frRef.GetType() == Frame3d::ERR)
|
||||
return false ;
|
||||
|
||||
// imposto ricalcolo della grafica
|
||||
m_OGrMgr.Reset() ;
|
||||
|
||||
// trasformo i vertici
|
||||
for ( int i = 0 ; i < GetVertexSize() ; ++ i) {
|
||||
if ( m_vVert[i].nIdTria != SVT_DEL)
|
||||
m_vVert[i].ptP.ToGlob( frRef) ;
|
||||
}
|
||||
|
||||
// imposto ricalcolo della grafica
|
||||
m_OGrMgr.Reset() ;
|
||||
|
||||
return true ;
|
||||
}
|
||||
|
||||
@@ -1822,15 +1855,43 @@ SurfTriMesh::ToLoc( const Frame3d& frRef)
|
||||
if ( frRef.GetType() == Frame3d::ERR)
|
||||
return false ;
|
||||
|
||||
// imposto ricalcolo della grafica
|
||||
m_OGrMgr.Reset() ;
|
||||
|
||||
// trasformo i vertici
|
||||
for ( int i = 0 ; i < GetVertexSize() ; ++ i) {
|
||||
if ( m_vVert[i].nIdTria != SVT_DEL)
|
||||
m_vVert[i].ptP.ToLoc( frRef) ;
|
||||
}
|
||||
|
||||
return true ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
SurfTriMesh::LocToLoc( const Frame3d& frOri, const Frame3d& frDest)
|
||||
{
|
||||
// la superficie deve essere validata
|
||||
if ( m_nStatus != OK)
|
||||
return false ;
|
||||
|
||||
// verifico validità dei frame
|
||||
if ( frOri.GetType() == Frame3d::ERR || frDest.GetType() == Frame3d::ERR)
|
||||
return false ;
|
||||
|
||||
// se i due riferimenti coincidono, non devo fare alcunché
|
||||
if ( AreSameFrame( frOri, frDest))
|
||||
return true ;
|
||||
|
||||
// imposto ricalcolo della grafica
|
||||
m_OGrMgr.Reset() ;
|
||||
|
||||
// trasformo i vertici
|
||||
for ( int i = 0 ; i < GetVertexSize() ; ++ i) {
|
||||
if ( m_vVert[i].nIdTria != SVT_DEL)
|
||||
m_vVert[i].ptP.LocToLoc( frOri, frDest) ;
|
||||
}
|
||||
|
||||
return true ;
|
||||
}
|
||||
|
||||
|
||||
+5
-2
@@ -68,13 +68,16 @@ class SurfTriMesh : public ISurfTriMesh, public IGeoObjRW
|
||||
virtual bool GetLocalBBox( BBox3d& b3Loc) const ;
|
||||
virtual bool GetBBox( const Frame3d& frRef, BBox3d& b3Ref) const ;
|
||||
virtual bool Translate( const Vector3d& vtMove) ;
|
||||
virtual bool Rotate( const Point3d& ptAx, const Vector3d& vtAx, double dAngDeg)
|
||||
{ double dAngRad = dAngDeg * DEGTORAD ;
|
||||
return Rotate( ptAx, vtAx, cos( dAngRad), sin( dAngRad)) ; }
|
||||
virtual bool Rotate( const Point3d& ptAx, const Vector3d& vtAx, double dCosAng, double dSinAng) ;
|
||||
virtual bool Rotate( const Point3d& ptAx, const Vector3d& vtAx, double dAngRad)
|
||||
{ return Rotate( ptAx, vtAx, cos( dAngRad), sin( dAngRad)) ; }
|
||||
virtual bool Scale( const Frame3d& frRef, double dCoeffX, double dCoeffY, double dCoeffZ) ;
|
||||
virtual bool Mirror( const Point3d& ptOn, const Vector3d& vtNorm) ;
|
||||
virtual bool Shear( const Point3d& ptOn, const Vector3d& vtNorm, const Vector3d& vtDir, double dCoeff) ;
|
||||
virtual bool ToGlob( const Frame3d& frRef) ;
|
||||
virtual bool ToLoc( const Frame3d& frRef) ;
|
||||
virtual bool LocToLoc( const Frame3d& frOri, const Frame3d& frDest) ;
|
||||
virtual void SetObjGraphics( IObjGraphics* pOGr)
|
||||
{ m_OGrMgr.SetObjGraphics( pOGr) ; }
|
||||
virtual IObjGraphics* GetObjGraphics( void)
|
||||
|
||||
+28
-37
@@ -24,14 +24,9 @@
|
||||
void
|
||||
Vector3d::FromSpherical( double dLen, double dAngVertDeg, double dAngOrizzDeg)
|
||||
{
|
||||
double dAngVertRad ;
|
||||
double dAngOrizzRad ;
|
||||
double dSinAngVert ;
|
||||
|
||||
|
||||
dAngVertRad = dAngVertDeg * DEGTORAD ;
|
||||
dAngOrizzRad = dAngOrizzDeg * DEGTORAD ;
|
||||
dSinAngVert = sin( dAngVertRad) ;
|
||||
double dAngVertRad = dAngVertDeg * DEGTORAD ;
|
||||
double dAngOrizzRad = dAngOrizzDeg * DEGTORAD ;
|
||||
double dSinAngVert = sin( dAngVertRad) ;
|
||||
x = dLen * dSinAngVert * cos( dAngOrizzRad) ;
|
||||
y = dLen * dSinAngVert * sin( dAngOrizzRad) ;
|
||||
z = dLen * cos( dAngVertRad) ;
|
||||
@@ -43,10 +38,7 @@ Vector3d::FromSpherical( double dLen, double dAngVertDeg, double dAngOrizzDeg)
|
||||
void
|
||||
Vector3d::FromPolar( double dLen, double dAngDeg)
|
||||
{
|
||||
double dAngRad ;
|
||||
|
||||
|
||||
dAngRad = dAngDeg * DEGTORAD ;
|
||||
double dAngRad = dAngDeg * DEGTORAD ;
|
||||
x = dLen * cos( dAngRad) ;
|
||||
y = dLen * sin( dAngRad) ;
|
||||
z = 0 ;
|
||||
@@ -158,8 +150,9 @@ Vector3d::Normalize( double dEps)
|
||||
// Rotazione
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
Vector3d::Rotate( const Vector3d& vtAx, double dAngRad)
|
||||
Vector3d::Rotate( const Vector3d& vtAx, double dAngDeg)
|
||||
{
|
||||
double dAngRad = dAngDeg * DEGTORAD ;
|
||||
return Rotate( vtAx, cos( dAngRad), sin( dAngRad)) ;
|
||||
}
|
||||
|
||||
@@ -169,31 +162,21 @@ Vector3d::Rotate( const Vector3d& vtAx, double dAngRad)
|
||||
bool
|
||||
Vector3d::Rotate( const Vector3d& vtAx, double dCosAng, double dSinAng)
|
||||
{
|
||||
double dCompPar ;
|
||||
Vector3d vtDirAx ;
|
||||
Vector3d vtCompPar ;
|
||||
Vector3d vtCompPerp ;
|
||||
Vector3d vtPerp2 ;
|
||||
Vector3d vtNewCompPerpX ;
|
||||
Vector3d vtNewCompPerpY ;
|
||||
Vector3d vtNewCompPerp ;
|
||||
|
||||
|
||||
// ricavo versore asse di rotazione
|
||||
vtDirAx = vtAx ;
|
||||
Vector3d vtDirAx = vtAx ;
|
||||
if ( ! vtDirAx.Normalize())
|
||||
return false ;
|
||||
|
||||
// separazione del vettore nelle componenti parallela e perp. asse
|
||||
dCompPar = *this * vtDirAx ;
|
||||
vtCompPar = vtDirAx * dCompPar ;
|
||||
vtCompPerp = *this - vtCompPar ;
|
||||
double dCompPar = *this * vtDirAx ;
|
||||
Vector3d vtCompPar = vtDirAx * dCompPar ;
|
||||
Vector3d vtCompPerp = *this - vtCompPar ;
|
||||
// calcolo vettore perp. componente perp. e asse
|
||||
vtPerp2 = vtDirAx ^ vtCompPerp ;
|
||||
Vector3d vtPerp2 = vtDirAx ^ vtCompPerp ;
|
||||
// calcolo componenti perp. del vettore ruotato
|
||||
vtNewCompPerpX = dCosAng * vtCompPerp ;
|
||||
vtNewCompPerpY = dSinAng * vtPerp2 ;
|
||||
vtNewCompPerp = vtNewCompPerpX + vtNewCompPerpY ;
|
||||
Vector3d vtNewCompPerpX = dCosAng * vtCompPerp ;
|
||||
Vector3d vtNewCompPerpY = dSinAng * vtPerp2 ;
|
||||
Vector3d vtNewCompPerp = vtNewCompPerpX + vtNewCompPerpY ;
|
||||
// calcolo del vettore ruotato
|
||||
*this = vtCompPar + vtNewCompPerp ;
|
||||
|
||||
@@ -224,17 +207,13 @@ Vector3d::Scale( const Frame3d& frRef, double dCoeffX, double dCoeffY, double dC
|
||||
bool
|
||||
Vector3d::Mirror( const Vector3d& vtNorm)
|
||||
{
|
||||
double dCompNorm ;
|
||||
Vector3d vtDirNorm ;
|
||||
|
||||
|
||||
// ricavo versore normale al piano di simmetria
|
||||
vtDirNorm = vtNorm ;
|
||||
Vector3d vtDirNorm = vtNorm ;
|
||||
if ( ! vtDirNorm.Normalize())
|
||||
return false ;
|
||||
|
||||
// calcolo la componente parallela alla normale
|
||||
dCompNorm = *this * vtDirNorm ;
|
||||
double dCompNorm = *this * vtDirNorm ;
|
||||
|
||||
// il simmetrico è il vettore originale meno il doppio della componente parallela
|
||||
*this = *this - 2 * dCompNorm * vtDirNorm ;
|
||||
@@ -242,6 +221,18 @@ Vector3d::Mirror( const Vector3d& vtNorm)
|
||||
return true ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
// Scorrimento
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
Vector3d::Shear( const Vector3d& vtNorm, const Vector3d& vtDir, double dCoeff)
|
||||
{
|
||||
// costruisco il vettore
|
||||
*this += dCoeff * ( *this * vtNorm) * vtDir ;
|
||||
|
||||
return true ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
// Cambio di riferimento : dal riferimento al globale
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
Reference in New Issue
Block a user