diff --git a/EGkDllMain.cpp b/EGkDllMain.cpp index 366e6be..c4bf4f1 100644 --- a/EGkDllMain.cpp +++ b/EGkDllMain.cpp @@ -13,9 +13,9 @@ //--------------------------- Include ---------------------------------------- #include "stdafx.h" -#include -#include <\EgtDev\Include\EgtTrace.h> #include <\EgtDev\Include\EGkVersion.h> +#include <\EgtDev\Include\EgnGetModuleVer.h> +#include <\EgtDev\Include\EgtTrace.h> //--------------------------- Costanti ---------------------------------------- #if defined( _DEBUG) @@ -50,38 +50,10 @@ DllMain( HMODULE hModule, DWORD dwReason, LPVOID lpReserved) const char* GetEGkVersion( void) { - wchar_t szFileName[_MAX_PATH] ; - DWORD dwNULL ; - DWORD dwSize ; - UINT dwUsefulSize ; - LPVOID lpData ; - LPVOID lpUsefulData ; - VS_FIXEDFILEINFO* pvsInfo ; + std::string sVer ; - - // trovo nome del file dato l'hInstance - ::GetModuleFileNameW( s_hModule, szFileName, _MAX_PATH) ; - - // mi faccio dare il buffer delle informazioni dal file - dwSize = ::GetFileVersionInfoSizeW( szFileName, &dwNULL) ; - lpData = malloc( size_t( dwSize)); - GetFileVersionInfoW( szFileName, dwNULL, dwSize, lpData) ; - - // Chiedo le info standard - if ( ::VerQueryValueW( lpData, L"\\", &lpUsefulData, &dwUsefulSize)) { - pvsInfo = (VS_FIXEDFILEINFO*) lpUsefulData ; - sprintf_s( s_szEGkNameVer, STR_DIM, "%s%d.%d%c%d", - EGK_STR, - pvsInfo->dwFileVersionMS >> 16, - pvsInfo->dwFileVersionMS % 0x10000, - (pvsInfo->dwFileVersionLS >> 16) + 96, - pvsInfo->dwFileVersionLS % 0x10000); - } - else - sprintf_s( s_szEGkNameVer, STR_DIM, "%s0.0a0", EGK_STR) ; - - // disalloco il buffer - free( lpData) ; + GetModuleVersion( s_hModule, sVer) ; + sprintf_s( s_szEGkNameVer, STR_DIM, "%s%s", EGK_STR, sVer.c_str()) ; return s_szEGkNameVer ; } diff --git a/EgtGeomKernel.rc b/EgtGeomKernel.rc index 4f3d753..cfed786 100644 Binary files a/EgtGeomKernel.rc and b/EgtGeomKernel.rc differ diff --git a/GdbExecutor.cpp b/GdbExecutor.cpp index e6c3342..4b7040d 100644 --- a/GdbExecutor.cpp +++ b/GdbExecutor.cpp @@ -1,7 +1,7 @@ //---------------------------------------------------------------------------- // EgalTech 2013-2013 //---------------------------------------------------------------------------- -// File : GdbExecutor.cpp Data : 25.11.13 Versione : 1.3a1 +// File : GdbExecutor.cpp Data : 25.11.13 Versione : 1.3a5 // Contenuto : Implementazione della classe GdbExecutor. // // @@ -13,8 +13,8 @@ //--------------------------- Include ---------------------------------------- #include "stdafx.h" -#include -#include +#include "GdbExecutor.h" +#include "GdbIterator.h" #include "/EgtDev/Include/EgnStringUtils.h" #include "/EgtDev/Include/EgnStringConverter.h" #include "/EgtDev/Include/EgkGeoPoint3d.h" @@ -25,8 +25,6 @@ #include "/EgtDev/Include/EgkCurveBezier.h" #include "/EgtDev/Include/EgkCurveComposite.h" #include "/EgtDev/Include/EgtPointerOwner.h" -#include "GdbIterator.h" -#include "GdbExecutor.h" using namespace std ; @@ -40,6 +38,8 @@ CreateGdbExecutor( void) //---------------------------------------------------------------------------- GdbExecutor::GdbExecutor( void) { + m_pGDB = nullptr ; + m_pLogger = nullptr ; } //---------------------------------------------------------------------------- @@ -49,22 +49,23 @@ GdbExecutor::~GdbExecutor( void) //---------------------------------------------------------------------------- bool -GdbExecutor::Set( IGeomDB* pGdb) +GdbExecutor::Init( IGeomDB* pGdb, ILogger* pLogger) { m_pGDB = pGdb ; + m_pLogger = pLogger ; return ( m_pGDB != nullptr) ; } //---------------------------------------------------------------------------- bool -GdbExecutor::Load( const wstring& sFile) +GdbExecutor::Load( const string& sFile) { bool bOk ; ifstream ifLoad ; - ifLoad.open( sFile) ; + ifLoad.open( stringtoW( sFile)) ; if ( ifLoad.good()) { bOk = m_pGDB->Load( ifLoad) ; ifLoad.close() ; @@ -77,13 +78,13 @@ GdbExecutor::Load( const wstring& sFile) //---------------------------------------------------------------------------- bool -GdbExecutor::Save( const wstring& sFile) +GdbExecutor::Save( const string& sFile) { bool bOk ; ofstream ofSave ; - ofSave.open( sFile) ; + ofSave.open( stringtoW( sFile)) ; if ( ofSave.good()) { bOk = m_pGDB->Save( ofSave) ; ofSave.close() ; @@ -98,18 +99,19 @@ GdbExecutor::Save( const wstring& sFile) bool GdbExecutor::Execute( const string& sCmd1, const string& sCmd2, const STRVECTOR& vsParams) { + string sOut ; STRVECTOR::const_iterator theConstIter ; // output di debug - cout << "Cmd = [" << sCmd1 << "/" << sCmd2 << "]" ; - cout << " Par = [" ; + sOut = "Cmd = [" + sCmd1 + "/" + sCmd2 + "] Par = [" ; for ( theConstIter = vsParams.begin() ; theConstIter != vsParams.end() ; ++theConstIter) { if ( theConstIter != vsParams.begin()) - cout << "/" ; - cout << *theConstIter ; + sOut += "/" ; + sOut += *theConstIter ; } - cout << "]" << endl ; + sOut += "]" ; + LOG_DEBUG( m_pLogger, sOut.c_str()) ; // esecuzione comando if ( sCmd1 == "ALIAS") @@ -244,7 +246,7 @@ GdbExecutor::ExecutePoint( const string& sCmd2, const STRVECTOR& vsParams) if ( pGPnt == nullptr) return false ; pGPnt->Set( Pnt) ; - return ( m_pGDB->AddGeoObj( GetIdParam( vsParams[0]), GetIdParam( vsParams[1]),pGPnt) != GDB_ID_NULL) ; + return AddGeoObj( vsParams[0], vsParams[1], pGPnt) ; } return false ; @@ -270,7 +272,7 @@ GdbExecutor::ExecuteVector( const string& sCmd2, const STRVECTOR& vsParams) if ( pGVect == nullptr) return false ; pGVect->Set( Vect) ; - return ( m_pGDB->AddGeoObj( GetIdParam( vsParams[0]), GetIdParam( vsParams[1]), pGVect) != GDB_ID_NULL) ; + return AddGeoObj( vsParams[0], vsParams[1], pGVect) ; } return false ; @@ -300,7 +302,7 @@ GdbExecutor::ExecuteFrame( const string& sCmd2, const STRVECTOR& vsParams) if ( pGFrame == nullptr) return false ; pGFrame->Set( ptOrig, vtDirX, vtDirY, vtDirZ) ; - return ( m_pGDB->AddGeoObj( GetIdParam( vsParams[0]), GetIdParam( vsParams[1]), pGFrame) != GDB_ID_NULL) ; + return AddGeoObj( vsParams[0], vsParams[1], pGFrame) ; } return false ; @@ -325,7 +327,7 @@ GdbExecutor::ExecuteCurveLine( const string& sCmd2, const STRVECTOR& vsParams) PtrOwner pCrvLine( CreateCurveLine()) ; if ( ! IsValid( pCrvLine) || ! pCrvLine->Set( ptStart, ptEnd)) return false ; - return ( m_pGDB->AddGeoObj( GetIdParam( vsParams[0]), GetIdParam( vsParams[1]), Release( pCrvLine)) != GDB_ID_NULL) ; + return AddGeoObj( vsParams[0], vsParams[1], Release( pCrvLine)) ; } return false ; @@ -407,7 +409,7 @@ GdbExecutor::ExecuteCurveArc( const string& sCmd2, const STRVECTOR& vsParams) return false ; // inserisco l'arco nel DB - return ( m_pGDB->AddGeoObj( GetIdParam( vsParams[0]), GetIdParam( vsParams[1]), Release( pCrvArc)) != GDB_ID_NULL) ; + return AddGeoObj( vsParams[0], vsParams[1], Release( pCrvArc)) ; } //---------------------------------------------------------------------------- @@ -467,7 +469,7 @@ GdbExecutor::ExecuteCurveBez( const string& sCmd2, const STRVECTOR& vsParams) return false ; // inserisco la curva di Bezier nel DB - return ( m_pGDB->AddGeoObj( GetIdParam( vsParams[0]), GetIdParam( vsParams[1]), Release( pCrvBez)) != GDB_ID_NULL) ; + return AddGeoObj( vsParams[0], vsParams[1], Release( pCrvBez)) ; } //---------------------------------------------------------------------------- @@ -503,7 +505,7 @@ GdbExecutor::ExecuteCurveCompo( const string& sCmd2, const STRVECTOR& vsParams) return false ; } // inserisco la curva composita nel DB - if ( m_pGDB->AddGeoObj( GetIdParam( vsParams[0]), GetIdParam( vsParams[1]), Release( pCrvCompo))) { + if ( AddGeoObj( vsParams[0], vsParams[1], Release( pCrvCompo))) { // se richiesto, cancello le curve originali if ( bErase) { for ( Iter = vsNames.begin() ; Iter != vsNames.end() ; ++Iter) { @@ -520,6 +522,20 @@ GdbExecutor::ExecuteCurveCompo( const string& sCmd2, const STRVECTOR& vsParams) return false ; } +//---------------------------------------------------------------------------- +bool +GdbExecutor::AddGeoObj( const string& sId, const string& sIdParent, IGeoObj* pGeoObj) +{ + // creo il gruppo + int nId = GetIdParam( sId) ; + int nIdNew = m_pGDB->AddGeoObj( nId, GetIdParam( sIdParent), pGeoObj) ; + // se IdDest da calcolare e indicato da Alias, ne cambio il valore + if ( nId == GDB_ID_NULL && m_AliasMap.find( sId) != m_AliasMap.end()) + m_AliasMap[sId] = nIdNew ; + + return ( nIdNew != GDB_ID_NULL) ; +} + //---------------------------------------------------------------------------- int GdbExecutor::GetIdParam( const std::string& sParam) @@ -829,9 +845,9 @@ GdbExecutor::ExecuteLoad( const STRVECTOR& vsParams) return false ; // pulizia e reinizializzazione del DB geometrico m_pGDB->Clear() ; - m_pGDB->Init() ; + m_pGDB->ReInit() ; // esecuzione caricamento - return Load( stringtoW( vsParams[0])) ; + return Load( vsParams[0]) ; } //---------------------------------------------------------------------------- @@ -842,20 +858,20 @@ GdbExecutor::ExecuteSave( const STRVECTOR& vsParams) if ( vsParams.size() != 1) return false ; // esecuzione salvataggio - return Save( stringtoW( vsParams[0])) ; + return Save( vsParams[0]) ; } //---------------------------------------------------------------------------- bool GdbExecutor::ExecuteOutScl( const string& sCmd2, const STRVECTOR& vsParams) { - // apro il file di uscita Scl + // apro il file di uscita Scl if ( sCmd2 == "OPEN") { // 1 parametro if ( vsParams.size() != 1) return false ; // apro il file e scrivo intestazione - return m_OutScl.Open( stringtoW( vsParams[0])) ; + return m_OutScl.Open( vsParams[0]) ; } // chiudo il file di uscita Scl else if ( sCmd2 == "CLOSE") { @@ -899,8 +915,8 @@ GdbExecutor::ExecuteOutScl( const string& sCmd2, const STRVECTOR& vsParams) } // emetto oggetto geometrico else if ( sCmd2 == "PUT") { - bool bCrvVsPolyg ; - int nId ; + int nFlag ; + int nId ; STRVECTOR vsNames ; STRVECTOR::iterator Iter ; // almeno un parametro @@ -908,9 +924,9 @@ GdbExecutor::ExecuteOutScl( const string& sCmd2, const STRVECTOR& vsParams) return false ; // se esiste il secondo if ( vsParams.size() == 2) - bCrvVsPolyg = ( vsParams[1] != "CPS") ; + FromString( vsParams[1], nFlag) ; else - bCrvVsPolyg = TRUE ; + nFlag = 0 ; // recupero lista nomi if ( ! GetNamesParam( vsParams[0], vsNames)) return false ; @@ -918,7 +934,7 @@ GdbExecutor::ExecuteOutScl( const string& sCmd2, const STRVECTOR& vsParams) for ( Iter = vsNames.begin() ; Iter != vsNames.end() ; ++Iter) { // recupero l'oggetto ed eseguo l'output nId = GetIdParam( *Iter) ; - if ( ! m_OutScl.PutCurve( m_pGDB->GetGeoObj( nId), bCrvVsPolyg)) + if ( ! m_OutScl.PutCurve( m_pGDB->GetGeoObj( nId), nFlag)) return false ; } return true ; @@ -946,13 +962,15 @@ GdbExecutor::OutGroupScl( int nId) return false ; } } + else + return false ; // emetto entità gruppo Iter.SetGDB( m_pGDB) ; bNext = Iter.GoToFirstInGroup( nId) ; while ( bNext) { nGdbType = Iter.GetGdbType() ; if ( nGdbType == GDB_GEO) { - if ( ! m_OutScl.PutCurve( Iter.GetGeoObj(), true)) + if ( ! m_OutScl.PutCurve( Iter.GetGeoObj(), 0)) return false ; } else if ( nGdbType == GDB_GROUP) { diff --git a/GdbExecutor.h b/GdbExecutor.h index e8092c4..e92c8d9 100644 --- a/GdbExecutor.h +++ b/GdbExecutor.h @@ -22,15 +22,16 @@ class GdbExecutor : public IGdbExecutor { public : virtual bool Execute( const std::string& sCmd1, const std::string& sCmd2, const STRVECTOR& vsParams) ; - virtual bool Set( IGeomDB* pGdb) ; + virtual bool Init( IGeomDB* pGdb, ILogger* pLogger) ; public : GdbExecutor( void) ; ~GdbExecutor( void) ; - bool Load( const std::wstring& sFile) ; - bool Save( const std::wstring& sFile) ; + bool Load( const std::string& sFile) ; + bool Save( const std::string& sFile) ; private : + bool AddGeoObj( const std::string& sId, const std::string& sIdParent, IGeoObj* pGeoObj) ; int GetIdParam( const std::string& sParam) ; bool GetNamesParam( const std::string& sParam, STRVECTOR& vsNames) ; bool GetVectorParam( const std::string& sParam, Vector3d& vtV) ; @@ -58,6 +59,7 @@ class GdbExecutor : public IGdbExecutor private : IGeomDB* m_pGDB ; + ILogger* m_pLogger ; OutScl m_OutScl ; typedef std::unordered_map AliasMap ; AliasMap m_AliasMap ; diff --git a/GeomDB.cpp b/GeomDB.cpp index 0f2af98..1937601 100644 --- a/GeomDB.cpp +++ b/GeomDB.cpp @@ -1,7 +1,7 @@ //---------------------------------------------------------------------------- // EgalTech 2013-2013 //---------------------------------------------------------------------------- -// File : GeomDB.cpp Data : 08.04.13 Versione : 1.1c1 +// File : GeomDB.cpp Data : 08.04.13 Versione : 1.3a5 // Contenuto : Implementazione della classe GeomDB. // // @@ -13,12 +13,11 @@ //--------------------------- Include ---------------------------------------- #include "stdafx.h" -#include -#include +#include "GeomDB.h" +#include "GdbObj.h" #include "/EgtDev/Include/EgnStringUtils.h" #include "/EgtDev/Include/EgtPointerOwner.h" -#include "GdbObj.h" -#include "GeomDB.h" +#include using namespace std ; @@ -26,7 +25,7 @@ using namespace std ; IGeomDB* CreateGeomDB( void) { - return static_cast ( new GeomDB) ; + return static_cast ( new(nothrow) GeomDB) ; } //---------------------------------------------------------------------------- @@ -45,8 +44,21 @@ GeomDB::~GeomDB( void) //---------------------------------------------------------------------------- bool -GeomDB::Init( void) +GeomDB::Init( ILogger* pLogger) { + m_pLogger = pLogger ; + + // imposto numero minimo buckets del map degli Id + m_IdManager.Init( 1024) ; + + return true ; +} + +//---------------------------------------------------------------------------- +bool +GeomDB::ReInit( void) +{ + // imposto numero minimo buckets del map degli Id m_IdManager.Init( 1024) ; @@ -76,14 +88,15 @@ GeomDB::Load( std::ifstream& osIn) // inizializzo lo scanner - if ( ! TheScanner.Initialize( osIn)) { - cout << "GeomDbLoad : Error on Init " << endl ; + if ( ! TheScanner.Init( osIn)) { + LOG_ERROR( m_pLogger, "GeomDbLoad : Error on Init ") ; return false ; } // leggo l'intestazione if ( ! LoadStart( TheScanner)) { - cout << "GeomDbLoad : Error on line " << TheScanner.GetCurrLineNbr() << endl ; + string sOut = "GeomDbLoad : Error on line " + ToString( TheScanner.GetCurrLineNbr()) ; + LOG_ERROR( m_pLogger, sOut.c_str()) ; return false ; } @@ -92,7 +105,8 @@ GeomDB::Load( std::ifstream& osIn) do { if ( ! LoadOneNode( TheScanner, bEnd)) { bOk = false ; - cout << "GeomDbLoad : Error on line " << TheScanner.GetCurrLineNbr() << endl ; + string sOut = "GeomDbLoad : Error on line " + ToString( TheScanner.GetCurrLineNbr()) ; + LOG_ERROR( m_pLogger, sOut.c_str()) ; } } while ( ! bEnd) ; diff --git a/GeomDB.h b/GeomDB.h index ad3e5b5..7085c19 100644 --- a/GeomDB.h +++ b/GeomDB.h @@ -30,7 +30,8 @@ class GeomDB : public IGeomDB public : virtual ~GeomDB( void) ; - virtual bool Init( void) ; + virtual bool Init( ILogger* pLogger) ; + virtual bool ReInit( void) ; virtual bool Clear( void) ; virtual bool Load( std::ifstream& osIn) ; virtual bool Save( std::ofstream& osOut) const ; @@ -66,6 +67,7 @@ class GeomDB : public IGeomDB private : GdbGroup m_GrpRadix ; // gruppo radice di tutto il DB IdManager m_IdManager ; // gestore del nuovo Id + ILogger* m_pLogger ; } ; //---------------------------------------------------------------------------- diff --git a/OutScl.cpp b/OutScl.cpp index 6b280b1..292c772 100644 --- a/OutScl.cpp +++ b/OutScl.cpp @@ -13,17 +13,12 @@ //--------------------------- Include ---------------------------------------- #include "stdafx.h" -#include -#include -#include -#include -#include "/EgtDev/Include/EgnStringUtils.h" -//#include "GeoObjTypeFun.h" #include "OutScl.h" +#include "/EgtDev/Include/EgnStringUtils.h" +#include "/EgtDev/Include/EgnStringConverter.h" using namespace std ; - //---------------------------------------------------------------------------- OutScl::OutScl( void) { @@ -37,10 +32,10 @@ OutScl::~OutScl( void) //---------------------------------------------------------------------------- bool -OutScl::Open( const wstring& sOutScl) +OutScl::Open( const string& sOutScl) { // apro il file - m_ofFile.open( sOutScl) ; + m_ofFile.open( stringtoW( sOutScl)) ; if ( ! m_ofFile.good()) return false ; // scrivo linee iniziali @@ -263,7 +258,7 @@ OutScl::ArcCPA( Point3d ptCen, Point3d ptMed, double dAngCenDeg) //---------------------------------------------------------------------------- bool -OutScl::PutCurve( const IGeoObj* pCurve, bool bCrvVsPoly) +OutScl::PutCurve( const IGeoObj* pCurve, int nFlag) { if ( pCurve == nullptr) return false ; @@ -272,14 +267,11 @@ OutScl::PutCurve( const IGeoObj* pCurve, bool bCrvVsPoly) case CRV_LINE : return PutCurveLine( *GetCurveLine( pCurve)) ; case CRV_ARC : - return PutCurveArc( *GetCurveArc( pCurve)) ; + return PutCurveArc( *GetCurveArc( pCurve), nFlag) ; case CRV_BEZ : - if ( bCrvVsPoly) - return PutCurveBez( *GetCurveBezier( pCurve)) ; - else - return PutPolygBez( *GetCurveBezier( pCurve)) ; + return PutCurveBez( *GetCurveBezier( pCurve), nFlag) ; case CRV_COMPO : - return PutCurveCompo( *GetCurveComposite( pCurve)) ; + return PutCurveCompo( *GetCurveComposite( pCurve), nFlag) ; } return false ; @@ -298,7 +290,7 @@ OutScl::PutCurveLine( const ICurveLine& CrvLine) //---------------------------------------------------------------------------- bool -OutScl::PutCurveArc( const ICurveArc& CrvArc) +OutScl::PutCurveArc( const ICurveArc& CrvArc, int nFlag) { const double DELTA_ANG = 15 ; int nNumSeg ; @@ -325,17 +317,20 @@ OutScl::PutCurveArc( const ICurveArc& CrvArc) // nuovo iniziale prende i valori del finale ptIni = ptFin ; } - // ciclo per disegnare le derivate - Remark( "ArcTangents+Der2") ; - for ( i = 0 ; i <= nNumSeg ; ++ i) { - // ricavo il punto - dU = i / (double) nNumSeg ; - CrvArc.GetPointTangNormCurv( dU, ptFin, vtT, vtN, dCurv) ; - // tangente - Line2P( ptFin - vtT, ptFin + vtT) ; - // derivata - if ( fabs( dCurv) > EPS_ZERO) - Line2P( ptFin, ptFin + vtN * ( 1 / dCurv)) ; + // se richieste derivate e curvature + if ( ( nFlag & 1) != 0) { + // ciclo per disegnare le derivate + Remark( "ArcTangents+Der2") ; + for ( i = 0 ; i <= nNumSeg ; ++ i) { + // ricavo il punto + dU = i / (double) nNumSeg ; + CrvArc.GetPointTangNormCurv( dU, ptFin, vtT, vtN, dCurv) ; + // tangente + Line2P( ptFin - vtT, ptFin + vtT) ; + // curvatura + if ( fabs( dCurv) > EPS_ZERO) + Line2P( ptFin, ptFin + vtN * ( 1 / dCurv)) ; + } } return true ; @@ -343,7 +338,7 @@ OutScl::PutCurveArc( const ICurveArc& CrvArc) //---------------------------------------------------------------------------- bool -OutScl::PutCurveBez( const ICurveBezier& CrvBez) +OutScl::PutCurveBez( const ICurveBezier& CrvBez, int nFlag) { const int NUM_SEG = 20 ; bool bCCW ; @@ -358,6 +353,10 @@ OutScl::PutCurveBez( const ICurveBezier& CrvBez) Vector3d vtN ; + // se richiesto anche il poligono di controllo + if ( ( nFlag & 2) != 0) + PutPolygBez( CrvBez) ; + // ciclo per disegnare i segmenti Remark( "BezierCurve") ; for ( i = 0 ; i <= NUM_SEG ; ++ i) { @@ -370,25 +369,28 @@ OutScl::PutCurveBez( const ICurveBezier& CrvBez) // nuovo iniziale prende i valori del finale ptIni = ptFin ; } - // ciclo per disegnare le derivate - Remark( "BezierTangents+Der2") ; - for ( i = 0 ; i <= NUM_SEG ; ++ i) { - // ricavo il punto - dU = i / (double) NUM_SEG ; - CrvBez.GetPointTangNormCurv( dU, ptFin, vtT, vtN, dCurv) ; - // curvatura - if ( fabs( dCurv) > EPS_ZERO) { - // tratto di arco - ptCen = ptFin + vtN * ( 1 / dCurv) ; - bCCW = ( vtT ^ vtN).z > 0 ; - dAngCenDeg = ( bCCW ? 1 : -1) * 4 * dCurv * RADTODEG ; - ArcCPA( ptCen, ptFin, dAngCenDeg) ; - // raggio - Line2P( ptFin, ptCen) ; + // se richieste derivate e curvature + if ( ( nFlag & 1) != 0) { + // ciclo per disegnare le derivate e le curvature + Remark( "BezierTangents+Der2") ; + for ( i = 0 ; i <= NUM_SEG ; ++ i) { + // ricavo il punto + dU = i / (double) NUM_SEG ; + CrvBez.GetPointTangNormCurv( dU, ptFin, vtT, vtN, dCurv) ; + // curvatura + if ( fabs( dCurv) > EPS_ZERO) { + // tratto di arco + ptCen = ptFin + vtN * ( 1 / dCurv) ; + bCCW = ( vtT ^ vtN).z > 0 ; + dAngCenDeg = ( bCCW ? 1 : -1) * 4 * dCurv * RADTODEG ; + ArcCPA( ptCen, ptFin, dAngCenDeg) ; + // raggio + Line2P( ptFin, ptCen) ; + } + // altrimenti, tangente + else if ( ! vtT.IsSmall()) + Line2P( ptFin - vtT, ptFin + vtT) ; } - // altrimenti, tangente - else if ( ! vtT.IsSmall()) - Line2P( ptFin - vtT, ptFin + vtT) ; } return true ; @@ -419,7 +421,7 @@ OutScl::PutPolygBez( const ICurveBezier& CrvBez) //---------------------------------------------------------------------------- bool -OutScl::PutCurveCompo( const ICurveComposite& CrvCompo) +OutScl::PutCurveCompo( const ICurveComposite& CrvCompo, int nFlag) { const ICurve* pCrvSmpl ; @@ -434,10 +436,10 @@ OutScl::PutCurveCompo( const ICurveComposite& CrvCompo) PutCurveLine( *::GetCurveLine( pCrvSmpl)) ; break ; case CRV_ARC : - PutCurveArc( *::GetCurveArc( pCrvSmpl)) ; + PutCurveArc( *::GetCurveArc( pCrvSmpl), nFlag) ; break ; case CRV_BEZ : - PutCurveBez( *::GetCurveBezier( pCrvSmpl)) ; + PutCurveBez( *::GetCurveBezier( pCrvSmpl), nFlag) ; break ; } // passo alla successiva diff --git a/OutScl.h b/OutScl.h index fe15fbf..5aa29ef 100644 --- a/OutScl.h +++ b/OutScl.h @@ -28,18 +28,18 @@ class OutScl public : OutScl( void) ; ~OutScl( void) ; - bool Open( const std::wstring& sOutScl) ; + bool Open( const std::string& sOutScl) ; bool Close( void) ; bool Remark( std::string sRemark) ; bool SetMaterial( double dRed, double dGreen, double dBlue) ; bool SetPartLay( std::string sPart, std::string sLay) ; bool SetPartLayRef( std::string sPart, std::string sLay, const Frame3d& frFrame) ; - bool PutCurve( const IGeoObj* pCurve, bool bCrvVsPoly) ; + bool PutCurve( const IGeoObj* pCurve, int nFlag) ; bool PutCurveLine( const ICurveLine& CrvLine) ; - bool PutCurveArc( const ICurveArc& CrvArc) ; - bool PutCurveBez( const ICurveBezier& CrvBez) ; + bool PutCurveArc( const ICurveArc& CrvArc, int nFlag) ; + bool PutCurveBez( const ICurveBezier& CrvBez, int nFlag) ; bool PutPolygBez( const ICurveBezier& CrvBez) ; - bool PutCurveCompo( const ICurveComposite& CrvCompo) ; + bool PutCurveCompo( const ICurveComposite& CrvCompo, int nFlag) ; private : bool Start( void) ;