From df864c93a824c1fac8b1cfbd63e07a0949b431df Mon Sep 17 00:00:00 2001 From: Dario Sassi Date: Sat, 1 Nov 2025 17:34:12 +0100 Subject: [PATCH] EgtExchange 2.7k1 : - adattamenti e ricompilazione per passaggio a C++ 20 --- BtlGeomOutline.cpp | 8 ++++---- BtlGeomProc.cpp | 8 ++++---- EgtExchange.rc | Bin 11678 -> 11678 bytes EgtExchange.vcxproj | 8 ++++---- ImportBtl.cpp | 3 ++- ImportBtlx.cpp | 9 +++++---- ImportBtlxProc.cpp | 31 +++++++++++++++++-------------- ImportCnc.cpp | 2 +- ImportCsf.cpp | 2 +- ImportDxfEnts.cpp | 6 +++--- 10 files changed, 41 insertions(+), 36 deletions(-) diff --git a/BtlGeomOutline.cpp b/BtlGeomOutline.cpp index 12d5f57..597a959 100644 --- a/BtlGeomOutline.cpp +++ b/BtlGeomOutline.cpp @@ -1074,8 +1074,8 @@ BtlGeom::AdjustOneOutlineFace( int nSide, ICURVEPOVECTOR& vCrvP) // concateno le linee senza invertirle const double TOLER = 10 * EPS_SMALL ; ChainCurves chainC ; - chainC.Init( false, TOLER, int( vCrvP.size())) ; - for ( size_t i = 0 ; i < vCrvP.size() ; ++ i) { + chainC.Init( false, TOLER, ssize( vCrvP)) ; + for ( int i = 0 ; i < ssize( vCrvP) ; ++ i) { Point3d ptStart, ptEnd ; Vector3d vtStart, vtEnd ; if ( ! vCrvP[i]->GetStartPoint( ptStart) || ! vCrvP[i]->GetStartDir( vtStart) || @@ -1092,7 +1092,7 @@ BtlGeom::AdjustOneOutlineFace( int nSide, ICURVEPOVECTOR& vCrvP) if ( IsNull( pCrvCompo)) return false ; // recupero le curve semplici e le inserisco nella curva composita - for ( size_t i = 0 ; i < vId2s.size() ; ++ i) { + for ( int i = 0 ; i < ssize( vId2s) ; ++ i) { // indice della curva int j = vId2s[i] - 1 ; // la aggiungo alla curva composta @@ -1401,7 +1401,7 @@ BtlGeom::AddShapeBTLX( const INTMATRIX& vFacesVertices, const PNTVECTOR& vPoints // creo il contorno della faccia PtrOwner pCurveCompo( CreateCurveComposite()) ; pCurveCompo->AddPoint( vPoints[vVertices[0]]) ; - for ( size_t i = 1 ; i != vVertices.size() ; i++) + for ( int i = 1 ; i < ssize( vVertices) ; i++) pCurveCompo->AddLine( vPoints[vVertices[i]]) ; pCurveCompo->AddLine( vPoints[vVertices[0]]) ; // creo la faccia e recupero i suoi triangoli diff --git a/BtlGeomProc.cpp b/BtlGeomProc.cpp index af43af4..548ab6e 100644 --- a/BtlGeomProc.cpp +++ b/BtlGeomProc.cpp @@ -5071,7 +5071,7 @@ BtlGeom::AddText( int nGroup, int nProc, int nSide, const string& sDes, int nPro Point3d ptP( vdPar[0], vdPar[1], 0) ; // P01, P02 Vector3d vtD = FromPolar( 1, vdPar[2]) ; // P06 double dH = vdPar[7] ; // P13 - int nInsPos ; + int nInsPos = ETXT_IPMC ; switch ( lround( vdPar[3])) { // P09 case 0 : switch ( lround( vdPar[4])) { // P10 @@ -5105,8 +5105,8 @@ BtlGeom::AddText( int nGroup, int nProc, int nSide, const string& sDes, int nPro // ruoto la direzione di riferimento vtD.Rotate( Z_AX, 90) ; // inserisco un a capo dopo ogni carattere, tranne l'ultimo - size_t nChar = sPar.size() ; - for ( size_t i = 0 ; i < nChar - 1 ; ++ i) + int nChar = ssize( sPar) ; + for ( int i = 0 ; i < nChar - 1 ; ++ i) sText += sPar[i] + ETXT_LINEBREAK ; sText += sPar[nChar-1] ; // sistemo il tipo di inserimento @@ -8704,7 +8704,7 @@ BtlGeom::CurveFromFces( const FCEDEQUE& dqFce, int nStartInd) return nullptr ; // recupero le entità free contour int nEnt = -1 ; - for ( size_t i = nStartInd + 1 ; i < dqFce.size() ; ++ i) { + for ( int i = nStartInd + 1 ; i < ssize( dqFce) ; ++ i) { // se retta if ( dqFce[i].nType == FreeContourEnt::LINE) { // se punti non coincidenti diff --git a/EgtExchange.rc b/EgtExchange.rc index ac74c2fc5517f1e991c074ba61c19505aca5bc9a..402d9791b133db2eece5e88e5ee622252b8239cd 100644 GIT binary patch delta 126 zcmbOiJuiC04>ndq1|0^&%@6qwGELscnZ=yVU^sarx9(;KAs@!gOSmnV;R^JbktADK U;NsXc7D(gL=*PG@O4)@A0EpNmYybcN delta 126 zcmbOiJuiC04>nc<1|0^Y%@6qwGELscnZ=yNU^ICnx9(;KAs@!gOSmnV;R^JbktADK U;NsXc7D(gL=*PG@O4)@A0EoaOYybcN diff --git a/EgtExchange.vcxproj b/EgtExchange.vcxproj index 17a19c3..d8a18f4 100644 --- a/EgtExchange.vcxproj +++ b/EgtExchange.vcxproj @@ -104,7 +104,7 @@ false ProgramDatabase %(AdditionalIncludeDirectories) - stdcpp17 + stdcpp20 Windows @@ -128,7 +128,7 @@ copy $(TargetPath) \EgtProg\DllD32 WIN32;I_AM_EEX;_DEBUG;_WINDOWS;_USRDLL;%(PreprocessorDefinitions) true %(AdditionalIncludeDirectories) - stdcpp17 + stdcpp20 @@ -163,7 +163,7 @@ copy $(TargetPath) \EgtProg\DllD64 true false %(AdditionalIncludeDirectories) - stdcpp17 + stdcpp20 Windows @@ -197,7 +197,7 @@ copy $(TargetPath) \EgtProg\Dll32 true false %(AdditionalIncludeDirectories) - stdcpp17 + stdcpp20 -Wno-tautological-undefined-compare diff --git a/ImportBtl.cpp b/ImportBtl.cpp index f665545..65aed7f 100644 --- a/ImportBtl.cpp +++ b/ImportBtl.cpp @@ -21,6 +21,7 @@ #include "/EgtDev/Include/EGkStringUtils3d.h" #include "/EgtDev/Include/EGnFileUtils.h" #include "/EgtDev/Include/EgtStringEncoder.h" +#include "/EgtDev/Include/EgtNumUtils.h" using namespace std ; @@ -306,7 +307,7 @@ ImportBtl::ReadGeneral( bool& bEnd) Trim( sVal, " \t\r\n\"") ; int nUnit ; if ( FromString( sVal, nUnit)) { - m_dScale = pow( 10, - nUnit) ; + m_dScale = Pow( 10, -nUnit) ; ++ nRead ; } m_BtlGeom.SetUserAttribute( UATD_INFO, sKey, sVal) ; diff --git a/ImportBtlx.cpp b/ImportBtlx.cpp index eee7f85..7af0a54 100644 --- a/ImportBtlx.cpp +++ b/ImportBtlx.cpp @@ -824,7 +824,7 @@ ImportBtlx::CheckGuid( const string& s) vector range = {'a', 'b', 'c', 'd', 'e', 'f', 'A', 'B', 'C', 'D', 'E', 'F', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9'} ; if ( s[0] != '{' || s[37] != '}') return false ; - for ( size_t i = 1 ; i < 37 ; i++) { + for ( int i = 1 ; i < 37 ; i++) { if ( i == 9 || i == 14 || i == 19 || i == 24) { if ( s[i] != '-') return false ; @@ -1509,10 +1509,11 @@ ImportBtlx::ReadShape( pugi::xml_node node) DBLVECTOR vAux2 ; // vettore per salvare le coordinate di un punto if ( sCoordPoints.back() != ' ') sCoordPoints += " " ; - while( ( str_end = sCoordPoints.find( " ", str_start)) != string::npos) { - double val = stod( sCoordPoints.substr( str_start, str_end - str_start)) ; + while ( ( str_end = sCoordPoints.find( " ", str_start)) != string::npos) { + double dVal = 0 ; + FromString( sCoordPoints.substr( str_start, str_end - str_start), dVal) ; str_start = str_end + 1 ; - vAux2.push_back( val) ; + vAux2.push_back( dVal) ; if ( vAux2.size() == 3) { // hai letto 3 coordinate quindi hai un punto vPoints.push_back( Point3d( vAux2[0], vAux2[1], vAux2[2])) ; vAux2.clear() ; diff --git a/ImportBtlxProc.cpp b/ImportBtlxProc.cpp index 6e2fcbd..01787f3 100644 --- a/ImportBtlxProc.cpp +++ b/ImportBtlxProc.cpp @@ -30,12 +30,12 @@ using namespace std ; // ------------------------- Prototipi locali funzioni ausiliarie --------------------------------- static int GetGroup12( const pugi::xml_node& process) ; static int GetGroup34( const pugi::xml_node& process) ; -static double ReadProcessChild( const pugi::xml_node& process, const string& sChild, const double& dVal) ; -static double ReadProcessChildAttribute( const pugi::xml_node& process, const string& sChild, const string& sAttribute, const double& dVal) ; +static double ReadProcessChild( const pugi::xml_node& process, const string& sChild, double dVal) ; +static double ReadProcessChildAttribute( const pugi::xml_node& process, const string& sChild, const string& sAttribute, double dVal) ; static int ReadProcessChildBool( const pugi::xml_node& process, const string& sChild, const int& nDefaultVal, bool bInverted = false) ; static string ReadProcessChildYesNo( const pugi::xml_node& process, const string& sChild, const string& sVal) ; static double ReadProcessChildYesNoToDouble( const pugi::xml_node& process, const string& sChild1, const string& sDefaultOpt, const string& sChild2, - const double& nDefaultVal) ; + double nDefaultVal) ; static int ComputeP04( const STRVECTOR& values) ; static int ComputeP04( const pugi::xml_node& MachiningLimits) ; @@ -605,9 +605,9 @@ ImportBtlx::ReadChamferParams( pugi::xml_node process, int& nGroup, int& nProc, string sCamferEdge41 = ReadProcessChildYesNo( process, "ChamferEdge41", "yes") ; STRVECTOR values = { sCamferEdge12, sCamferEdge23, sCamferEdge34, sCamferEdge41} ; vdPar[1] = 0.0 ; - for ( size_t i = 0 ; i < values.size() ; i++) { + for ( int i = 0 ; i < ssize( values) ; i++) { if ( values[i] == "yes") - vdPar[1] += pow( 2, i) ; + vdPar[1] += Pow( 2, i) ; else if ( values[i] != "no") { LOG_ERROR( GetEExLogger(), " Error reading Part Processing: ChamferEdge value is not valid") ; return false ; @@ -1829,7 +1829,7 @@ ImportBtlx::ReadTyroleanDovetailParams( pugi::xml_node process, int& nGroup, int vdPar[4] = -1 ; else if ( sLapExit == "rebate") { if ( process.child( "RebateLength") != nullptr) - vdPar[4] = std::stod( process.child( "RebateLength").text().get()) ; + FromString( process.child( "RebateLength").text().get(), vdPar[4]) ; else vdPar[4] = 10.0 ; // valore di default } @@ -1936,7 +1936,7 @@ ImportBtlx::ReadDovetailParams( pugi::xml_node process, int& nGroup, int& nProc, vdPar[4] = -1 ; else if ( sLapExit == "rebate") { if ( process.child( "RebateLength") != nullptr) - vdPar[4] = std::stod( process.child( "RebateLength").text().get()) ; + FromString( process.child( "RebateLength").text().get(), vdPar[4]) ; else vdPar[4] = 10.0 ; // valore di default } @@ -2218,17 +2218,20 @@ GetGroup34( const pugi::xml_node& process) //--------------------------------------------------------------------------------------------------------------------------- double -ReadProcessChild( const pugi::xml_node& process, const string& sChild, const double& dVal) +ReadProcessChild( const pugi::xml_node& process, const string& sChild, double dVal) { - if ( process.child( sChild.c_str()) != nullptr && process.child( sChild.c_str()).text().get() != '\0') - return std::stod( process.child( sChild.c_str()).text().get()) ; + if ( process.child( sChild.c_str()) != nullptr && process.child( sChild.c_str()).text().get() != nullptr) { + double dRes = dVal ; + FromString( process.child( sChild.c_str()).text().get(), dRes) ; + return dRes ; + } else return dVal ; } //--------------------------------------------------------------------------------------------------------------------------- double -ReadProcessChildAttribute( const pugi::xml_node& process, const string& sChild, const string& sAttribute, const double& dVal) +ReadProcessChildAttribute( const pugi::xml_node& process, const string& sChild, const string& sAttribute, double dVal) { if ( process.child( sChild.c_str()) != nullptr && process.child( sChild.c_str()).attribute( sAttribute.c_str()) != nullptr) return process.child( sChild.c_str()).attribute( sAttribute.c_str()).as_double() ; @@ -2271,7 +2274,7 @@ ReadProcessChildYesNo( const pugi::xml_node& process, const string& sChild, cons //--------------------------------------------------------------------------------------------------------------------------- double ReadProcessChildYesNoToDouble( const pugi::xml_node& process, const string& sChild1, const string& sDefaultOpt, const string& sChild2, - const double& nDefaultVal) + double nDefaultVal) { string sValue = process.child( sChild1.c_str()).text().get() ; if ( sValue == sDefaultOpt || sValue.empty() || ( sValue != "no" && sValue != "yes")) @@ -2290,9 +2293,9 @@ ComputeP04( const STRVECTOR& values) } int result = 0 ; - for ( size_t i = 0 ; i < values.size() ; i ++) { + for ( int i = 0 ; i < ssize( values) ; i ++) { if ( values[i] == "no") - result += static_cast( pow( 2, i)) ; + result += int( Pow( 2, i)) ; else if ( values[i] != "yes") { LOG_ERROR( GetEExLogger(), " Error reading Part Processing: MachiningLimit value is not valid") ; return -2 ; diff --git a/ImportCnc.cpp b/ImportCnc.cpp index 6793658..de7a6e2 100644 --- a/ImportCnc.cpp +++ b/ImportCnc.cpp @@ -212,7 +212,7 @@ ImportCnc::ProcessLine( const string& sLine) TokenizePlus( sMyLine, "NGXYZIJKPQRUVWABCFTMHhDEL", vsTokens) ; // analizzo ogni singola parte - for ( size_t i = 0 ; i < vsTokens.size() ; ++ i) { + for ( int i = 0 ; i < ssize( vsTokens) ; ++ i) { // analizzo per categorie determinate dal primo carattere del token switch ( vsTokens[i][0]) { case 'G' : diff --git a/ImportCsf.cpp b/ImportCsf.cpp index fb1c26a..c2ad5e3 100644 --- a/ImportCsf.cpp +++ b/ImportCsf.cpp @@ -597,7 +597,7 @@ ImportCsf::ProcessExtendedText( const CsfEnt& csfEnt) } // salvataggio testo con un punto di inserimento per ogni carattere else if ( etData.sText.size() == etData.vPnt.size()) { - for ( size_t i = 0 ; i < etData.sText.size() ; ++ i) { + for ( int i = 0 ; i < ssize( etData.sText) ; ++ i) { // creo il testo PtrOwner pTxt( CreateExtText()) ; if ( IsNull( pTxt)) diff --git a/ImportDxfEnts.cpp b/ImportDxfEnts.cpp index 93abb32..fbe80d3 100644 --- a/ImportDxfEnts.cpp +++ b/ImportDxfEnts.cpp @@ -2695,16 +2695,16 @@ ImportDxf::AdjustMText( string& sText, double dTextMaxWidth, double dW) // coefficiente empirico che in generale migliora l'adattamento const double COEFF_LARGH = 1.2 ; // gestione max lunghezza riga di testo - size_t nLastSp = - 1 ; + int nLastSp = -1 ; double dCurrWidth = 0 ; - for ( size_t i = 0 ; i < sText.size() ; ++ i) { + for ( int i = 0 ; i < ssize( sText) ; ++ i) { // posso dividere solo sugli spazi if ( sText[i] == ' ') nLastSp = i ; // se c'è già un a capo if ( sText[i] == '\n') { dCurrWidth = 0 ; - nLastSp = - 1 ; + nLastSp = -1 ; } // se supera il limite else if ( dCurrWidth > COEFF_LARGH * dTextMaxWidth) {