EgtGeomKernel :

- - modifiche a NgeReader per semplificare e velocizzare lettura file binari.
This commit is contained in:
Dario Sassi
2025-12-29 11:55:09 +01:00
parent 51c584c6c4
commit d92344f2bb
4 changed files with 72 additions and 73 deletions
+15 -15
View File
@@ -90,7 +90,7 @@ NgeWriter::WriteUchar( unsigned char ucVal, const char* szSep, bool bEndL)
if ( m_bBinary) {
if ( m_OutFile == nullptr)
return false ;
return ( gzwrite( m_OutFile, (char*) &ucVal, sizeof( ucVal)) > 0) ;
return ( gzwrite( m_OutFile, &ucVal, sizeof( ucVal)) > 0) ;
}
else {
return WriteStringOutTxt( m_OutFile, ToString( ucVal).c_str(), szSep, bEndL) ;
@@ -104,7 +104,7 @@ NgeWriter::WriteBool( bool bVal, const char* szSep, bool bEndL)
if ( m_bBinary) {
if ( m_OutFile == nullptr)
return false ;
return ( gzwrite( m_OutFile, (char*) &bVal, sizeof( bVal)) > 0) ;
return ( gzwrite( m_OutFile, &bVal, sizeof( bVal)) > 0) ;
}
else {
return WriteStringOutTxt( m_OutFile, ToString( bVal).c_str(), szSep, bEndL) ;
@@ -118,7 +118,7 @@ NgeWriter::WriteInt( int nVal, const char* szSep, bool bEndL)
if ( m_bBinary) {
if ( m_OutFile == nullptr)
return false ;
return ( gzwrite( m_OutFile, (char*) &nVal, sizeof( nVal)) > 0) ;
return ( gzwrite( m_OutFile, &nVal, sizeof( nVal)) > 0) ;
}
else {
return WriteStringOutTxt( m_OutFile, ToString( nVal).c_str(), szSep, bEndL) ;
@@ -132,7 +132,7 @@ NgeWriter::WriteDouble( double dVal, const char* szSep, bool bEndL, int nPrec)
if ( m_bBinary) {
if ( m_OutFile == nullptr)
return false ;
return ( gzwrite( m_OutFile, (char*) &dVal, sizeof( dVal)) > 0) ;
return ( gzwrite( m_OutFile, &dVal, sizeof( dVal)) > 0) ;
}
else {
return WriteStringOutTxt( m_OutFile, ToString( dVal, nPrec).c_str(), szSep, bEndL) ;
@@ -147,7 +147,7 @@ NgeWriter::WriteString( const string& sVal, const char* szSep, bool bEndL)
if ( m_OutFile == nullptr)
return false ;
int nDim = ssize( sVal) ;
return ( gzwrite( m_OutFile, (char*) &nDim, sizeof( nDim)) > 0 &&
return ( gzwrite( m_OutFile, &nDim, sizeof( nDim)) > 0 &&
( nDim == 0 || gzwrite( m_OutFile, sVal.c_str(), sVal.size()) > 0)) ;
}
else {
@@ -162,7 +162,7 @@ NgeWriter::WriteVector( const Vector3d& vtV, const char* szSep, bool bEndL, int
if ( m_bBinary) {
if ( m_OutFile == nullptr)
return false ;
return ( gzwrite( m_OutFile, (char*) &vtV.v, sizeof( vtV.v)) > 0) ;
return ( gzwrite( m_OutFile, &vtV.v, sizeof( vtV.v)) > 0) ;
}
else {
return WriteStringOutTxt( m_OutFile, ToString( vtV, nPrec).c_str(), szSep, bEndL) ;
@@ -176,7 +176,7 @@ NgeWriter::WritePoint( const Point3d& ptP, const char* szSep, bool bEndL, int nP
if ( m_bBinary) {
if ( m_OutFile == nullptr)
return false ;
return ( gzwrite( m_OutFile, (char*) &ptP.v, sizeof( ptP.v)) > 0) ;
return ( gzwrite( m_OutFile, &ptP.v, sizeof( ptP.v)) > 0) ;
}
else {
return WriteStringOutTxt( m_OutFile, ToString( ptP, nPrec).c_str(), szSep, bEndL) ;
@@ -190,8 +190,8 @@ NgeWriter::WritePointW( const Point3d& ptP, double dW, const char* szSep, bool b
if ( m_bBinary) {
if ( m_OutFile == nullptr)
return false ;
return ( gzwrite( m_OutFile, (char*) &ptP.v, sizeof( ptP.v)) > 0 &&
gzwrite( m_OutFile, (char*) &dW, sizeof( dW)) > 0) ;
return ( gzwrite( m_OutFile, &ptP.v, sizeof( ptP.v)) > 0 &&
gzwrite( m_OutFile, &dW, sizeof( dW)) > 0) ;
}
else {
return WriteStringOutTxt( m_OutFile, ToString( ptP, dW, nPrecP, nPrecW).c_str(), szSep, bEndL) ;
@@ -205,10 +205,10 @@ NgeWriter::WriteFrame( const Frame3d& frF, const char* szSep, bool bEndL, int nP
if ( m_bBinary) {
if ( m_OutFile == nullptr)
return false ;
return ( gzwrite( m_OutFile, (char*) &frF.Orig().v, sizeof( frF.Orig().v)) > 0 &&
gzwrite( m_OutFile, (char*) &frF.VersX().v, sizeof( frF.VersX().v)) > 0 &&
gzwrite( m_OutFile, (char*) &frF.VersY().v, sizeof( frF.VersY().v)) > 0 &&
gzwrite( m_OutFile, (char*) &frF.VersZ().v, sizeof( frF.VersZ().v)) > 0) ;
return ( gzwrite( m_OutFile, &frF.Orig().v, sizeof( frF.Orig().v)) > 0 &&
gzwrite( m_OutFile, &frF.VersX().v, sizeof( frF.VersX().v)) > 0 &&
gzwrite( m_OutFile, &frF.VersY().v, sizeof( frF.VersY().v)) > 0 &&
gzwrite( m_OutFile, &frF.VersZ().v, sizeof( frF.VersZ().v)) > 0) ;
}
else {
return WriteStringOutTxt( m_OutFile, ToString( frF, nPrecP, nPrecV).c_str(), szSep, bEndL) ;
@@ -225,7 +225,7 @@ NgeWriter::WriteKey( int nKey)
if ( m_bBinary) {
if ( m_OutFile == nullptr)
return false ;
return ( gzwrite( m_OutFile, (char*) &NgeBinKeyW[nKey], sizeof( int)) > 0) ;
return ( gzwrite( m_OutFile, &NgeBinKeyW[nKey], sizeof( int)) > 0) ;
}
else {
return WriteStringOutTxt( m_OutFile, NgeAscKeyW[nKey].c_str(), nullptr, true) ;
@@ -244,7 +244,7 @@ NgeWriter::WriteCol( const Color& cCol, const char* szSep, bool bEndL)
ucCol[1] = cCol.GetIntGreen() ;
ucCol[2] = cCol.GetIntBlue() ;
ucCol[3] = cCol.GetIntAlpha() ;
return ( gzwrite( m_OutFile, (char*) ucCol, sizeof( ucCol)) > 0) ;
return ( gzwrite( m_OutFile, ucCol, sizeof( ucCol)) > 0) ;
}
else {
return WriteStringOutTxt( m_OutFile, ToString( cCol).c_str(), szSep, bEndL) ;