diff --git a/EgtGeomKernel.vcxproj b/EgtGeomKernel.vcxproj index b63dc82..de1e5d1 100644 --- a/EgtGeomKernel.vcxproj +++ b/EgtGeomKernel.vcxproj @@ -252,7 +252,7 @@ copy $(TargetPath) \EgtProg\Dll64 - + @@ -329,7 +329,7 @@ copy $(TargetPath) \EgtProg\Dll64 - + diff --git a/EgtGeomKernel.vcxproj.filters b/EgtGeomKernel.vcxproj.filters index f75ba10..6a06a31 100644 --- a/EgtGeomKernel.vcxproj.filters +++ b/EgtGeomKernel.vcxproj.filters @@ -75,9 +75,6 @@ File di origine\Gdb - - File di origine\Script - File di origine\Script @@ -135,6 +132,9 @@ File di origine\Gdb + + File di origine\Script + @@ -218,9 +218,6 @@ File di intestazione - - File di intestazione - File di intestazione @@ -341,6 +338,9 @@ File di intestazione + + File di intestazione + diff --git a/GdbExecutor.cpp b/GdbExecutor.cpp index d19f06f..21f3a3f 100644 --- a/GdbExecutor.cpp +++ b/GdbExecutor.cpp @@ -101,7 +101,7 @@ GdbExecutor::GdbExecutor( void) m_ExecMgr.Insert( "NEW", &GdbExecutor::ExecuteNew) ; m_ExecMgr.Insert( "LOAD", &GdbExecutor::ExecuteLoad) ; m_ExecMgr.Insert( "SAVE", &GdbExecutor::ExecuteSave) ; - m_ExecMgr.Insert( "OUTSCL", &GdbExecutor::ExecuteOutScl) ; + m_ExecMgr.Insert( "OUTTSC", &GdbExecutor::ExecuteOutTsc) ; } //---------------------------------------------------------------------------- @@ -776,6 +776,21 @@ GdbExecutor::GetVectorParam( const std::string& sParam, Vector3d& vtV) FromString( vsParams[1], vtV.y) && FromString( vsParams[2], vtV.z)) ; } + // se altrimenti vettore predefinito X_AX + else if ( sParam == "X_AX") { + vtV = X_AX ; + return true ; + } + // se altrimenti vettore predefinito Y_AX + else if ( sParam == "Y_AX") { + vtV = Y_AX ; + return true ; + } + // se altrimenti vettore predefinito Z_AX + else if ( sParam == "Z_AX") { + vtV = Z_AX ; + return true ; + } // altrimenti nome di vettore giā nel DB else { const IGeoVector3d* pV ; @@ -805,6 +820,11 @@ GdbExecutor::GetPointParam( const std::string& sParam, Point3d& ptP) FromString( vsParams[1], ptP.y) && FromString( vsParams[2], ptP.z)) ; } + // se altrimenti punto predefinito ORIG + else if ( sParam == "ORIG") { + ptP = ORIG ; + return true ; + } // altrimenti nome di punto giā nel DB else { const IGeoPoint3d* pPt ; @@ -837,13 +857,18 @@ GdbExecutor::GetPointWParam( const std::string& sParam, Point3d& ptP, double& dW FromString( vsParams[2], ptP.z) && FromString( vsParams[3], dW)) ; } - // se 2 parti, nome di punto giā nel DB e un peso + // se 2 parti, nome di punto predefinito o giā nel DB e un peso else if ( vsParams.size() == 2) { - const IGeoPoint3d* pPt ; // recupero il punto - if ( ( pPt = GetGeoPoint3d( m_pGDB->GetGeoObj( GetIdParam( vsParams[0])))) == nullptr) - return false ; - ptP = pPt->GetPoint() ; + if ( vsParams[0] == "ORIG") { + ptP = ORIG ; + } + else { + const IGeoPoint3d* pPt ; + if ( ( pPt = GetGeoPoint3d( m_pGDB->GetGeoObj( GetIdParam( vsParams[0])))) == nullptr) + return false ; + ptP = pPt->GetPoint() ; + } // recupero il peso return FromString( vsParams[1], dW) ; } @@ -880,6 +905,11 @@ GdbExecutor::GetFrameParam( const std::string& sParam, Frame3d& frF) else return false ; } + // se altrimenti riferimento predefinito GLOB + else if ( sParam == "GLOB") { + frF = GLOB_FRM ; + return true ; + } // altrimenti nome di frame giā nel DB else { const IGeoFrame3d* pFr ; @@ -923,7 +953,7 @@ GdbExecutor::GetColorParam( const std::string& sParam, bool& bByParent, Color& c bByParent = false ; return true ; } - // altrimeti + // altrimenti else { // verifico se colore dal padre string sTemp = sParam ; @@ -1585,23 +1615,23 @@ GdbExecutor::ExecuteSave( const std::string& sCmd2, const STRVECTOR& vsParams) //---------------------------------------------------------------------------- bool -GdbExecutor::ExecuteOutScl( const string& sCmd2, const STRVECTOR& vsParams) +GdbExecutor::ExecuteOutTsc( const string& sCmd2, const STRVECTOR& vsParams) { - // apro il file di uscita Scl + // apro il file di uscita Tsc if ( sCmd2 == "OPEN") { // 1 parametro if ( vsParams.size() != 1) return false ; // apro il file e scrivo intestazione - return m_OutScl.Open( vsParams[0]) ; + return m_OutTsc.Open( vsParams[0]) ; } - // chiudo il file di uscita Scl + // chiudo il file di uscita Tsc else if ( sCmd2 == "CLOSE") { // nessun parametro if ( vsParams.size() != 0) return false ; // scrivo terminazioni e chiudo il file - return m_OutScl.Close() ; + return m_OutTsc.Close() ; } // imposto materiale corrente else if ( sCmd2 == "SETRGB") { @@ -1615,17 +1645,29 @@ GdbExecutor::ExecuteOutScl( const string& sCmd2, const STRVECTOR& vsParams) ! FromString( vsParams[2], dBlue)) return false ; // definisco il materiale opportuno - return m_OutScl.SetMaterial( dRed, dGreen, dBlue) ; + return m_OutTsc.SetMaterial( dRed, dGreen, dBlue) ; } - // imposto pezzo e layer correnti - else if ( sCmd2 == "SETPL") { - // 2 parametri - if ( vsParams.size() != 2) + // imposto nuovo gruppo + else if ( sCmd2 == "SETGR") { + Frame3d frF ; + // nessun parametro + if ( vsParams.size() == 0) + frF.Reset() ; + // un parametro ( Id del gruppo) + else if ( vsParams.size() == 1) { + // recupero l'indice del gruppo + int nId = GetIdParam( vsParams[0]) ; + // recupero il riferimento del gruppo + if ( ! m_pGDB->GetGroupGlobFrame( nId, frF)) + return false ; + } + // altrimenti, errore + else return false ; // eseguo - return m_OutScl.SetPartLay( vsParams[0], vsParams[1]) ; + return m_OutTsc.NewGroupRef( frF, 0) ; } - // emetto gruppo + // emetto gruppo con tutto il suo contenuto else if ( sCmd2 == "PUTGR") { // almeno un parametro if ( vsParams.size() < 1) @@ -1644,7 +1686,7 @@ GdbExecutor::ExecuteOutScl( const string& sCmd2, const STRVECTOR& vsParams) INTVECTOR::iterator Iter ; for ( Iter = vnNames.begin() ; Iter != vnNames.end() ; ++Iter) { // recupero l'oggetto ed eseguo l'output - if ( ! OutGroupScl( *Iter, nFlag)) + if ( ! OutGroupTsc( *Iter, nFlag)) return false ; } return true ; @@ -1668,7 +1710,7 @@ GdbExecutor::ExecuteOutScl( const string& sCmd2, const STRVECTOR& vsParams) INTVECTOR::iterator Iter ; for ( Iter = vnNames.begin() ; Iter != vnNames.end() ; ++Iter) { // recupero l'oggetto ed eseguo l'output - if ( ! m_OutScl.PutGeoObj( m_pGDB->GetGeoObj( *Iter), nFlag)) + if ( ! m_OutTsc.PutGeoObj( m_pGDB->GetGeoObj( *Iter), nFlag)) return false ; } return true ; @@ -1679,49 +1721,51 @@ GdbExecutor::ExecuteOutScl( const string& sCmd2, const STRVECTOR& vsParams) //---------------------------------------------------------------------------- bool -GdbExecutor::OutGroupScl( int nId, int nFlag) +GdbExecutor::OutGroupTsc( int nId, int nFlag, int nLev) { - bool bNext ; - int nParentId ; - int nGdbType ; - Frame3d frFrame ; - - - m_OutScl.Remark( "Start Group ---") ; - // emetto dati gruppo - if ( m_pGDB->GetGroupGlobFrame( nId, frFrame)) { - nParentId = m_pGDB->GetParentId( nId) ; - if ( nParentId > GDB_ID_ROOT) { - if ( ! m_OutScl.SetPartLayRef( ToString( nParentId), ToString( nId), frFrame)) + m_OutTsc.Remark( "Start Group ---") ; + // emetto dati gruppo ( se non č radice) + if ( nId > GDB_ID_ROOT) { + Frame3d frFrame ; + if ( ( nLev == 0 && m_pGDB->GetGroupGlobFrame( nId, frFrame)) || + ( nLev > 0 && m_pGDB->GetGroupFrame( nId, frFrame))) { + if ( ! m_OutTsc.NewGroupRef( frFrame, nLev)) return false ; - m_OutScl.PutCurrRef() ; + m_OutTsc.PutCurrRef() ; + } + else + return false ; + // emetto eventuale box + if ( ( nFlag & 8) != 0) { + BBox3d b3Loc ; + if ( m_pGDB->GetLocalBBox( nId, b3Loc)) { + m_OutTsc.PushGroup() ; + if ( ! m_OutTsc.NewGroup( nLev)) + return false ; + m_OutTsc.PutBBox( b3Loc) ; + m_OutTsc.PopGroup() ; + } } } - else - return false ; - // emetto eventuale box - if ( ( nFlag & 8) != 0) { - BBox3d b3Loc ; - if ( m_pGDB->GetLocalBBox( nId, b3Loc)) - m_OutScl.PutBBox( b3Loc) ; - } // emetto entitā gruppo - m_OutScl.Remark( "Entities :") ; + m_OutTsc.Remark( "Entities :") ; GdbIterator Iter( m_pGDB) ; - bNext = Iter.GoToFirstInGroup( nId) ; + bool bNext = Iter.GoToFirstInGroup( nId) ; while ( bNext) { - nGdbType = Iter.GetGdbType() ; + int nGdbType = Iter.GetGdbType() ; if ( nGdbType == GDB_TY_GEO) { - if ( ! m_OutScl.PutGeoObj( Iter.GetGeoObj(), nFlag)) + if ( ! m_OutTsc.PutGeoObj( Iter.GetGeoObj(), nFlag)) return false ; } else if ( nGdbType == GDB_TY_GROUP) { - if ( ! OutGroupScl( Iter.GetId(), nFlag)) + m_OutTsc.PushGroup() ; + if ( ! OutGroupTsc( Iter.GetId(), nFlag, nLev + 1)) return false ; + m_OutTsc.PopGroup() ; } bNext = Iter.GoToNext() ; } - m_OutScl.Remark( "End Group ---") ; + m_OutTsc.Remark( "End Group ---") ; return true ; } diff --git a/GdbExecutor.h b/GdbExecutor.h index fe5ad85..ecc03e3 100644 --- a/GdbExecutor.h +++ b/GdbExecutor.h @@ -13,7 +13,7 @@ #pragma once -#include "OutScl.h" +#include "OutTsc.h" #include "/EgtDev/Include/EgkGdbExecutor.h" #include "/EgtDev/Include/EgtPerfCounter.h" #include "/EgtDev/Include/EgtExecMgr.h" @@ -75,12 +75,12 @@ class GdbExecutor : public IGdbExecutor bool ExecuteNew( const std::string& sCmd2, const STRVECTOR& vsParams) ; bool ExecuteLoad( const std::string& sCmd2, const STRVECTOR& vsParams) ; bool ExecuteSave( const std::string& sCmd2, const STRVECTOR& vsParams) ; - bool ExecuteOutScl( const std::string& sCmd2, const STRVECTOR& vsParams) ; - bool OutGroupScl( int nId, int nFlag) ; + bool ExecuteOutTsc( const std::string& sCmd2, const STRVECTOR& vsParams) ; + bool OutGroupTsc( int nId, int nFlag, int nLev = 0) ; private : IGeomDB* m_pGDB ; ICmdParser* m_pParser ; ExecManager m_ExecMgr ; - OutScl m_OutScl ; + OutTsc m_OutTsc ; } ; diff --git a/OutScl.cpp b/OutScl.cpp deleted file mode 100644 index 1f13734..0000000 --- a/OutScl.cpp +++ /dev/null @@ -1,512 +0,0 @@ -//---------------------------------------------------------------------------- -// EgalTech 2013-2013 -//---------------------------------------------------------------------------- -// File : OutScl.cpp Data : 31.12.12 Versione : 1.1a1 -// Contenuto : Implementazione della classe output SCL. -// -// -// -// Modifiche : 31.12.12 DS Creazione modulo. -// -// -//---------------------------------------------------------------------------- - -//--------------------------- Include ---------------------------------------- -#include "stdafx.h" -#include "OutScl.h" -#include "/EgtDev/Include/EgkPoint3d.h" -#include "/EgtDev/Include/EgkCurveLine.h" -#include "/EgtDev/Include/EgkCurveArc.h" -#include "/EgtDev/Include/EgkCurveBezier.h" -#include "/EgtDev/Include/EgkCurveComposite.h" -#include "/EgtDev/Include/EGkStringUtils3d.h" -#include "/EgtDev/Include/EGnStringConverter.h" - -using namespace std ; - -//---------------------------------------------------------------------------- -OutScl::OutScl( void) -{ -} - -//---------------------------------------------------------------------------- -OutScl::~OutScl( void) -{ - Close() ; -} - -//---------------------------------------------------------------------------- -bool -OutScl::Open( const string& sOutScl) -{ - // apro il file - m_ofFile.open( stringtoW( sOutScl)) ; - if ( ! m_ofFile.good()) - return false ; - // inizializzo - m_sMaterial.clear() ; - m_sPartLay.clear() ; - // scrivo linee iniziali - Start() ; - New() ; - - return true ; -} - -//---------------------------------------------------------------------------- -bool -OutScl::Close( void) -{ - // verifico sia aperto - if ( ! m_ofFile.is_open()) - return false ; - // scrivo linee finali - End() ; - // chiudo il file - m_ofFile.close() ; - - return true ; -} - -//---------------------------------------------------------------------------- -bool -OutScl::Start( void) -{ - // verifico sia aperto - if ( ! m_ofFile.is_open()) - return false ; - // emetto stringa - m_ofFile << "{" << endl ; - - return true ; -} - -//---------------------------------------------------------------------------- -bool -OutScl::End( void) -{ - // verifico sia aperto - if ( ! m_ofFile.is_open()) - return false ; - // emetto stringa - m_ofFile << "}" << endl ; - - return true ; -} - -//---------------------------------------------------------------------------- -bool -OutScl::New( void) -{ - // verifico sia aperto - if ( ! m_ofFile.is_open()) - return false ; - // emetto stringa - m_ofFile << "NewFile() ;" << endl ; - - return true ; -} - -//---------------------------------------------------------------------------- -bool -OutScl::Remark( const string& sRemark) -{ - // verifico sia aperto - if ( ! m_ofFile.is_open()) - return false ; - // emetto stringa - m_ofFile << "// " << sRemark << endl ; - - return true ; -} - -//---------------------------------------------------------------------------- -bool -OutScl::SetMaterial( double dRed, double dGreen, double dBlue) -{ - int nRed ; - int nGreen ; - int nBlue ; - string sMat ; - - - // componenti colore nell'intervallo 0-255 - nRed = max( 0, min( int( 255 * dRed), 255)) ; - nGreen = max( 0, min( int( 255 * dGreen), 255)) ; - nBlue = max( 0, min( int( 255 * dBlue), 255)) ; - // calcolo nome materiale - sMat = "RGB" + ToString( nRed, 3) + ToString( nGreen, 3) + ToString( nBlue, 3) ; - // definizione materiale - return SetMaterial( sMat, ( nRed / 255.), ( nGreen / 255.), ( nBlue / 255.)) ; -} - -//---------------------------------------------------------------------------- -bool -OutScl::SetMaterial( const string& sMaterial, double dRed, double dGreen, double dBlue) -{ - // verifico sia aperto - if ( ! m_ofFile.is_open()) - return false ; - - // salvo nome materiale - m_sMaterial = sMaterial ; - - // emetto comando di creazione materiale - m_ofFile << "AddMaterial( \"" << sMaterial << "\", " << - ToString( dRed, 3) << ", " << ToString( dGreen, 3) << ", " << ToString( dBlue, 3) << ") ;" << endl ; - - return true ; -} - -//---------------------------------------------------------------------------- -bool -OutScl::SetPartLay( const string& sPart, const string& sLay) -{ - // verifico sia aperto - if ( ! m_ofFile.is_open()) - return false ; - - m_sPartLay = sPart + "\\" + sLay ; - - // emetto comando di creazione pezzo - m_ofFile << "CreatePart( \"" << sPart << "\") ;" << endl ; - // emetto comando di creazione layer - m_ofFile << "CreateLayer( \"" << sLay << "\", \"" << sPart << "\") ;" << endl ; - - return true ; -} - -//---------------------------------------------------------------------------- -bool -OutScl::SetPartLayRef( const string& sPart, const string& sLay, const Frame3d& frFrame) -{ - double dAngC ; - double dAngA ; - double dAngC1 ; - - - // verifico sia aperto - if ( ! m_ofFile.is_open()) - return false ; - - m_sPartLay = sPart + "\\" + sLay ; - - // calcolo angoli di rotazione del frame - frFrame.GetRotationsCAC1( dAngC, dAngA, dAngC1) ; - - // emetto comando di creazione pezzo - m_ofFile << "CreatePart( \"" << sPart << "\") ;" << endl ; - // emetto comando di creazione layer - m_ofFile << "CreateLayer( \"" << sLay << "\", \"" << sPart << "\") ;" << endl ; - // emetto comando di modifica riferimento - m_ofFile << "ModifyLayerRef( \"" << sLay << "\", \"" << sPart << "\"," ; - m_ofFile << "30,0," << ToString( frFrame.Orig()) << "," ; - m_ofFile << ToString( dAngC) << "," << ToString( dAngA) << "," << ToString( dAngC1) << ") ;" << endl ; - - return true ; -} - -//---------------------------------------------------------------------------- -bool -OutScl::PutCurrRef( void) -{ - // salvo il materiale corrente - string sOldMat = m_sMaterial ; - - // asse X - SetMaterial( "Red", 1, 0, 0) ; - Line2P( Point3d( 0,0,0), Point3d( 10,0,0)) ; - // asse Y - SetMaterial( "Green", 0, 1, 0) ; - Line2P( Point3d( 0,0,0), Point3d( 0,10,0)) ; - // asse Z - SetMaterial( "Blue", 0, 0, 1) ; - Line2P( Point3d( 0,0,0), Point3d( 0,0,10)) ; - - // ripristino il materiale corrente - m_sMaterial = sOldMat ; - - return true ; -} - -//---------------------------------------------------------------------------- -bool -OutScl::Line2P( const Point3d& ptP1, const Point3d& ptP2) -{ - // verifico sia aperto - if ( ! m_ofFile.is_open()) - return false ; - - // verifico non sia praticamente nulla - if ( AreSamePointNear( ptP1, ptP2)) - return true ; - - // emetto linea - m_ofFile << "Line3D( \"" << m_sPartLay << "\", \"" << m_sMaterial << "\", " ; - m_ofFile << ToString( ptP1) << ", " << ToString( ptP2) ; - m_ofFile << ") ;" << endl ; - - return true ; -} - -//---------------------------------------------------------------------------- -bool -OutScl::Arc3P( const Point3d& ptP1, const Point3d& ptP2, const Point3d& ptP3) -{ - // verifico sia aperto - if ( ! m_ofFile.is_open()) - return false ; - - // emetto arco - m_ofFile << "Arc3P( \"" << m_sPartLay << "\", \"" << m_sMaterial << "\", " ; - m_ofFile << ToString( ptP1) << ", " << ToString( ptP2) << ", " << ToString( ptP3) ; - m_ofFile << ") ;" << endl ; - - return true ; -} - -//---------------------------------------------------------------------------- -bool -OutScl::ArcCPA( const Point3d& ptCen, const Point3d& ptMed, double dAngCenDeg) -{ - Point3d ptP1 ; - Point3d ptP3 ; - - - // verifico sia aperto - if ( ! m_ofFile.is_open()) - return false ; - - // calcolo i due punti estremi - ptP1 = ptMed ; - ptP1.Rotate( ptCen, Vector3d( 0, 0, 1), - 0.5 * dAngCenDeg * DEGTORAD) ; - ptP3 = ptMed ; - ptP3.Rotate( ptCen, Vector3d( 0, 0, 1), 0.5 * dAngCenDeg * DEGTORAD) ; - - // emetto arco - m_ofFile << "Arc3P( \"" << m_sPartLay << "\", \"" << m_sMaterial << "\", " ; - m_ofFile << ToString( ptP1, 8) << ", " << ToString( ptMed, 8) << ", " << ToString( ptP3, 8) ; - m_ofFile << ") ;" << endl ; - - return true ; -} - -//---------------------------------------------------------------------------- -bool -OutScl::CircleCR( const Point3d& ptCen, double dRad) -{ - // verifico sia aperto - if ( ! m_ofFile.is_open()) - return false ; - - // emetto arco - m_ofFile << "CircCR( \"" << m_sPartLay << "\", \"" << m_sMaterial << "\", " ; - m_ofFile << ToString( ptCen.x) << "," << ToString( ptCen.y) << ", " << ToString( dRad) ; - m_ofFile << ") ;" << endl ; - - return true ; -} - -//---------------------------------------------------------------------------- -bool -OutScl::ArcCurvOrTgOrNone( const CrvPointDiffGeom& oDiffG) -{ - bool bCCW ; - double dAngCenDeg ; - Point3d ptCen ; - - - // curvatura - if ( oDiffG.nStatus == CrvPointDiffGeom::NCRV && fabs( oDiffG.dCurv) > EPS_ZERO) { - // tratto di arco - ptCen = oDiffG.ptP + oDiffG.vtN / oDiffG.dCurv ; - bCCW = ( oDiffG.vtT ^ oDiffG.vtN).z > 0 ; - dAngCenDeg = ( bCCW ? 1 : -1) * 4 * oDiffG.dCurv * RADTODEG ; - ArcCPA( ptCen, oDiffG.ptP, dAngCenDeg) ; - // raggio - Line2P( oDiffG.ptP, ptCen) ; - } - // altrimenti, tangente - else if ( oDiffG.nStatus == CrvPointDiffGeom::TANG && ! oDiffG.vtT.IsSmall()) - Line2P( oDiffG.ptP - oDiffG.vtT, oDiffG.ptP + oDiffG.vtT) ; - // altrimenti cerchietto - else - CircleCR( oDiffG.ptP, 1) ; - - return true ; -} - -//---------------------------------------------------------------------------- -bool -OutScl::NormalOrNone( const CrvPointDiffGeom& oDiffG) -{ - const double NORM_LEN = 10 ; - - - // normale - if ( oDiffG.nStatus == CrvPointDiffGeom::NCRV && fabs( oDiffG.dCurv) > EPS_ZERO) { - double dLen = __min( NORM_LEN, 1 / oDiffG.dCurv) ; - Line2P( oDiffG.ptP - NORM_LEN * oDiffG.vtN, oDiffG.ptP + dLen * oDiffG.vtN) ; - } - // segmento perpendicolare alla tangente - else if ( oDiffG.nStatus == CrvPointDiffGeom::TANG && ! oDiffG.vtT.IsSmall()) { - Vector3d vtN = oDiffG.vtT ^ Z_AX ; - if ( ! vtN.Normalize()) { - vtN = oDiffG.vtT ^ Y_AX ; - vtN.Normalize() ; - } - Line2P( oDiffG.ptP - NORM_LEN * vtN, oDiffG.ptP + NORM_LEN * vtN) ; - } - // altrimenti cerchietto - else - CircleCR( oDiffG.ptP, 1) ; - - return true ; -} - -//---------------------------------------------------------------------------- -bool -OutScl::PutGeoObj( const IGeoObj* pGeoObj, int nFlag) -{ - if (( pGeoObj->GetType() & GEO_CURVE) != 0) { - const ICurve* pCurve ; - // recupero e controllo la curva - if ( ( pCurve = GetCurve( pGeoObj)) == nullptr) - return false ; - // eseguo output - return PutCurve( pCurve, nFlag) ; - } - else - return true ; -} - -//---------------------------------------------------------------------------- -bool -OutScl::PutCurve( const ICurve* pCurve, int nFlag) -{ - bool bFound ; - PolyLine PL ; - - - // ciclo per disegnare i segmenti - Remark( "Curve") ; - Point3d ptIni ; - Point3d ptFin ; - pCurve->ApproxWithLines( 0.1, 5, PL) ; - for ( bFound = PL.GetFirstLine( ptIni, ptFin) ; bFound ; bFound = PL.GetNextLine( ptIni, ptFin)) - Line2P( ptIni, ptFin) ; - - // se richieste tangenti e curvature - if ( ( nFlag & 1) != 0) { - // ciclo per disegnare le derivate e le curvature - Remark( "Curve:Tangents+Der2") ; - double dU ; - for ( bFound = PL.GetFirstU( dU) ; bFound ; bFound = PL.GetNextU( dU)) { - // ricavo il punto, la tangente, la normale e la curvatura - CrvPointDiffGeom oDiffG ; - pCurve->GetPointDiffGeom( dU, ICurve::FROM_MINUS, oDiffG) ; - // curvatura o tangente o niente - ArcCurvOrTgOrNone( oDiffG) ; - // se punto con possibili discontinuitā - if ( oDiffG.nFlag == CrvPointDiffGeom::TO_VERIFY) { - // ricavo il punto, la tangente, la normale e la curvatura dall'intorno superiore - CrvPointDiffGeom oDiffGs ; - pCurve->GetPointDiffGeom( dU, ICurve::FROM_PLUS, oDiffGs) ; - // se ci sono delle discontinuitā - if ( ThereIsDiscontinuity( oDiffG, oDiffGs)) - // emetto curvatura o tangente o niente - ArcCurvOrTgOrNone( oDiffGs) ; - } - } - } - - // se richieste normali - if ( ( nFlag & 2) != 0) { - // ciclo per disegnare le derivate e le curvature - Remark( "Curve:Normals") ; - double dU ; - for ( bFound = PL.GetFirstU( dU) ; bFound ; bFound = PL.GetNextU( dU)) { - // ricavo il punto, la tangente, la normale e la curvatura - CrvPointDiffGeom oDiffG ; - pCurve->GetPointDiffGeom( dU, ICurve::FROM_MINUS, oDiffG) ; - // curvatura o tangente o niente - NormalOrNone( oDiffG) ; - // se punto con possibili discontinuitā - if ( oDiffG.nFlag == CrvPointDiffGeom::TO_VERIFY) { - // ricavo il punto, la tangente, la normale e la curvatura dall'intorno superiore - CrvPointDiffGeom oDiffGs ; - pCurve->GetPointDiffGeom( dU, ICurve::FROM_PLUS, oDiffGs) ; - // se ci sono delle discontinuitā - if ( ThereIsDiscontinuity( oDiffG, oDiffGs)) - // normale o niente - NormalOrNone( oDiffGs) ; - } - } - } - - // se curva di Bezier e richiesto anche il poligono di controllo - if ( pCurve->GetType() == CRV_BEZ && ( nFlag & 4) != 0) - PutPolygBez( *(GetCurveBezier( pCurve))) ; - - // se richiesto il box - if ( ( nFlag & 8) != 0) { - BBox3d b3B ; - if ( pCurve->GetLocalBBox( b3B)) - PutBBox( b3B) ; - } - - return true ; -} - -//---------------------------------------------------------------------------- -bool -OutScl::PutPolygBez( const ICurveBezier& CrvBez) -{ - int i ; - Point3d ptIni ; - Point3d ptFin ; - - - // ciclo per disegnare il poligono di controllo - Remark( "BezierPolygon") ; - ptIni = CrvBez.GetControlPoint( 0) ; - for ( i = 1 ; i <= CrvBez.GetDegree() ; ++ i) { - ptFin = CrvBez.GetControlPoint( i) ; - // disegno - Line2P( ptIni, ptFin) ; - // nuovo iniziale prende i valori del finale - ptIni = ptFin ; - } - - return true ; -} - -//---------------------------------------------------------------------------- -bool -OutScl::PutBBox( const BBox3d& b3B) -{ - Point3d ptMin ; - Point3d ptMax ; - - - if ( b3B.GetMinMax( ptMin, ptMax)) { - Remark( "BoundingBox") ; - // giro a Zmin - Line2P( Point3d( ptMin.x, ptMin.y, ptMin.z), Point3d( ptMax.x, ptMin.y, ptMin.z)) ; - Line2P( Point3d( ptMax.x, ptMin.y, ptMin.z), Point3d( ptMax.x, ptMax.y, ptMin.z)) ; - Line2P( Point3d( ptMax.x, ptMax.y, ptMin.z), Point3d( ptMin.x, ptMax.y, ptMin.z)) ; - Line2P( Point3d( ptMin.x, ptMax.y, ptMin.z), Point3d( ptMin.x, ptMin.y, ptMin.z)) ; - // giro a Zmax - Line2P( Point3d( ptMin.x, ptMin.y, ptMax.z), Point3d( ptMax.x, ptMin.y, ptMax.z)) ; - Line2P( Point3d( ptMax.x, ptMin.y, ptMax.z), Point3d( ptMax.x, ptMax.y, ptMax.z)) ; - Line2P( Point3d( ptMax.x, ptMax.y, ptMax.z), Point3d( ptMin.x, ptMax.y, ptMax.z)) ; - Line2P( Point3d( ptMin.x, ptMax.y, ptMax.z), Point3d( ptMin.x, ptMin.y, ptMax.z)) ; - // giunzione tra i due giri - Line2P( Point3d( ptMin.x, ptMin.y, ptMin.z), Point3d( ptMin.x, ptMin.y, ptMax.z)) ; - Line2P( Point3d( ptMax.x, ptMin.y, ptMin.z), Point3d( ptMax.x, ptMin.y, ptMax.z)) ; - Line2P( Point3d( ptMax.x, ptMax.y, ptMin.z), Point3d( ptMax.x, ptMax.y, ptMax.z)) ; - Line2P( Point3d( ptMin.x, ptMax.y, ptMin.z), Point3d( ptMin.x, ptMax.y, ptMax.z)) ; - } - - return true ; -} \ No newline at end of file diff --git a/OutTsc.cpp b/OutTsc.cpp new file mode 100644 index 0000000..f63b6f8 --- /dev/null +++ b/OutTsc.cpp @@ -0,0 +1,633 @@ +//---------------------------------------------------------------------------- +// EgalTech 2013-2014 +//---------------------------------------------------------------------------- +// File : OutTsc.cpp Data : 23.03.14 Versione : 1.5c9 +// Contenuto : Implementazione della classe output Tsc. +// +// +// +// Modifiche : 23.03.14 DS Creazione modulo. +// +// +//---------------------------------------------------------------------------- + +//--------------------------- Include ---------------------------------------- +#include "stdafx.h" +#include "OutTsc.h" +#include "/EgtDev/Include/EgkGeoVector3d.h" +#include "/EgtDev/Include/EgkGeoPoint3d.h" +#include "/EgtDev/Include/EgkGeoFrame3d.h" +#include "/EgtDev/Include/EgkCurveLine.h" +#include "/EgtDev/Include/EgkCurveArc.h" +#include "/EgtDev/Include/EgkCurveBezier.h" +#include "/EgtDev/Include/EgkCurveComposite.h" +#include "/EgtDev/Include/EGkStringUtils3d.h" +#include "/EgtDev/Include/EGnStringConverter.h" + +using namespace std ; + +//---------------------------------------------------------------------------- +OutTsc::OutTsc( void) +{ + m_nId = 0 ; + m_nGroup.push( 0) ; + m_bOutCol = false ; +} + +//---------------------------------------------------------------------------- +OutTsc::~OutTsc( void) +{ + Close() ; +} + +//---------------------------------------------------------------------------- +bool +OutTsc::Open( const string& sOutTsc) +{ + // apro il file + m_ofFile.open( stringtoW( sOutTsc)) ; + if ( ! m_ofFile.good()) + return false ; + // scrivo linee iniziali + Start() ; + New() ; + + return true ; +} + +//---------------------------------------------------------------------------- +bool +OutTsc::Close( void) +{ + // verifico sia aperto + if ( ! m_ofFile.is_open()) + return false ; + // scrivo linee finali + End() ; + // chiudo il file + m_ofFile.close() ; + + return true ; +} + +//---------------------------------------------------------------------------- +bool +OutTsc::Start( void) +{ + // verifico sia aperto + if ( ! m_ofFile.is_open()) + return false ; + // inizializzazioni + m_nId = 0 ; + m_nGroup.top() = 0 ; + m_bOutCol = false ; + + return true ; +} + +//---------------------------------------------------------------------------- +bool +OutTsc::End( void) +{ + // verifico sia aperto + if ( ! m_ofFile.is_open()) + return false ; + + return true ; +} + +//---------------------------------------------------------------------------- +bool +OutTsc::New( void) +{ + // verifico sia aperto + if ( ! m_ofFile.is_open()) + return false ; + // emetto stringa + m_ofFile << "NEW" << endl ; + + return true ; +} + +//---------------------------------------------------------------------------- +bool +OutTsc::Remark( const string& sRemark) +{ + // verifico sia aperto + if ( ! m_ofFile.is_open()) + return false ; + // emetto stringa + m_ofFile << "// " << sRemark << endl ; + + return true ; +} + +//---------------------------------------------------------------------------- +bool +OutTsc::SetMaterial( double dRed, double dGreen, double dBlue) +{ + m_bOutCol = true ; + m_cCol.Set( dRed, dGreen, dBlue) ; + return true ; +} + +//---------------------------------------------------------------------------- +bool +OutTsc::PutMaterial( int nObjId, bool bGroup) +{ + // se necessario emetto il materiale + if ( m_bOutCol || bGroup) { + m_ofFile << "MAT( " << ToString( nObjId) << ", (" << ToString( m_cCol) << "))" << endl ; + if ( bGroup) + m_bOutCol = false ; + } + return true ; +} + +//---------------------------------------------------------------------------- +bool +OutTsc::PushGroup( void) +{ + int nVal = ( m_nGroup.empty() ? 0 : m_nGroup.top()) ; + m_nGroup.push( nVal) ; + return true ; +} + +//---------------------------------------------------------------------------- +bool +OutTsc::PopGroup( void) +{ + if ( m_nGroup.size() <= 1) + return false ; + m_nGroup.pop() ; + return true ; +} + +//---------------------------------------------------------------------------- +bool +OutTsc::NewGroup( int nLev) +{ + // verifico sia aperto + if ( ! m_ofFile.is_open()) + return false ; + + // calcolo gruppo di appartenenza + string sParent = (( nLev == 0) ? "$ROOT" : ToString( m_nGroup.top())) ; + + // incremento indice corrente + ++ m_nId ; + + // assegno indice gruppo corrente + m_nGroup.top() = m_nId ; + + // creo il gruppo del pezzo + m_ofFile << "GR.XY( " << ToString( m_nGroup.top()) << ", " << sParent << ", (0,0,0))" << endl ; + + // emetto il materiale + PutMaterial( m_nGroup.top(), true) ; + + return true ; +} + +//---------------------------------------------------------------------------- +bool +OutTsc::NewGroupRef( const Frame3d& frFrame, int nLev) +{ + // verifico sia aperto + if ( ! m_ofFile.is_open()) + return false ; + + // calcolo gruppo di appartenenza + string sParent = (( nLev == 0) ? "$ROOT" : ToString( m_nGroup.top())) ; + + // incremento indice corrente + ++ m_nId ; + + // assegno indice layer corrente + m_nGroup.top() = m_nId ; + + // creo il gruppo del layer + m_ofFile << "GR( " << ToString( m_nGroup.top()) << ", " << sParent << ", " ; + m_ofFile << "(" << ToString( frFrame.Orig()) << "), " ; + m_ofFile << "(" << ToString( frFrame.VersX()) << "), " ; + m_ofFile << "(" << ToString( frFrame.VersY()) << "), " ; + m_ofFile << "(" << ToString( frFrame.VersZ()) << "))" << endl ; + + // emetto il materiale + PutMaterial( m_nGroup.top(), true) ; + + return true ; +} + +//---------------------------------------------------------------------------- +bool +OutTsc::PutCurrRef( void) +{ + return Frame( Frame3d()) ; +} + +//---------------------------------------------------------------------------- +bool +OutTsc::Vector( const Vector3d& vtV) +{ + // verifico sia aperto + if ( ! m_ofFile.is_open()) + return false ; + + // verifico non sia praticamente nullo + if ( vtV.IsSmall()) + return true ; + + // incremento indice corrente + ++ m_nId ; + + // emetto vettore + m_ofFile << "V( " << ToString( m_nId) << ", " << ToString( m_nGroup.top()) << ", " ; + m_ofFile << ToString( vtV) << ")" << endl ; + + // se necessario emetto il materiale + PutMaterial( m_nId) ; + + return true ; +} + +//---------------------------------------------------------------------------- +bool +OutTsc::Point( const Point3d& ptP) +{ + // verifico sia aperto + if ( ! m_ofFile.is_open()) + return false ; + + // incremento indice corrente + ++ m_nId ; + + // emetto punto + m_ofFile << "P( " << ToString( m_nId) << ", " << ToString( m_nGroup.top()) << ", " ; + m_ofFile << ToString( ptP) << ")" << endl ; + + // se necessario emetto il materiale + PutMaterial( m_nId) ; + + return true ; +} + +//---------------------------------------------------------------------------- +bool +OutTsc::Frame( const Frame3d& frF) +{ + // verifico sia aperto + if ( ! m_ofFile.is_open()) + return false ; + + // incremento indice corrente + ++ m_nId ; + + // emetto riferimento + m_ofFile << "FR( " << ToString( m_nId) << ", " << ToString( m_nGroup.top()) << ", " ; + m_ofFile << "(" << ToString( frF.Orig()) << "), " ; + m_ofFile << "(" << ToString( frF.VersX()) << "), " ; + m_ofFile << "(" << ToString( frF.VersY()) << "), " ; + m_ofFile << "(" << ToString( frF.VersZ()) << "))" << endl ; + + // non usa materiale + + return true ; +} + +//---------------------------------------------------------------------------- +bool +OutTsc::Line2P( const Point3d& ptP1, const Point3d& ptP2) +{ + // verifico sia aperto + if ( ! m_ofFile.is_open()) + return false ; + + // verifico non sia praticamente nulla + if ( AreSamePointNear( ptP1, ptP2)) + return true ; + + // incremento indice corrente + ++ m_nId ; + + // emetto linea + m_ofFile << "CL( " << ToString( m_nId) << ", " << ToString( m_nGroup.top()) << ", " ; + m_ofFile << "(" << ToString( ptP1) << "), (" << ToString( ptP2) << "))" << endl ; + + // se necessario emetto il materiale + PutMaterial( m_nId) ; + + return true ; +} + +//---------------------------------------------------------------------------- +bool +OutTsc::ArcCPA( const Point3d& ptCen, const Point3d& ptMed, double dAngCenDeg) +{ + // verifico sia aperto + if ( ! m_ofFile.is_open()) + return false ; + + // calcolo il raggio e l'angolo iniziale + double dRad ; + double dAngIniDeg ; + Vector3d( ptMed - ptCen).ToSpherical( &dRad, nullptr, &dAngIniDeg) ; + dAngIniDeg -= 0.5 * dAngCenDeg ; + + // verifico non sia praticamente nulla + if ( fabs( dRad) < EPS_SMALL || fabs( dAngCenDeg) < EPS_ANG_SMALL) + return true ; + + // incremento indice corrente + ++ m_nId ; + + // emetto arco + m_ofFile << "CA.XY( " << ToString( m_nId) << ", " << ToString( m_nGroup.top()) << ", " ; + m_ofFile << "(" << ToString( ptCen) << "), " << ToString( dRad) << ", " ; + m_ofFile << ToString( dAngIniDeg) << ", " << ToString( dAngCenDeg) << ", 0)" << endl ; + + // se necessario emetto il materiale + PutMaterial( m_nId) ; + + return true ; +} + +//---------------------------------------------------------------------------- +bool +OutTsc::CircleCR( const Point3d& ptCen, double dRad) +{ + // verifico sia aperto + if ( ! m_ofFile.is_open()) + return false ; + + // incremento indice corrente + ++ m_nId ; + + // emetto circonferenza + m_ofFile << "CA.CXY( " << ToString( m_nId) << ", " << ToString( m_nGroup.top()) << ", " ; + m_ofFile << "(" << ToString( ptCen) << "), " << ToString( dRad) << ")" << endl ; + + // se necessario emetto il materiale + PutMaterial( m_nId) ; + + return true ; +} + +//---------------------------------------------------------------------------- +bool +OutTsc::ArcCurvOrTgOrNone( const CrvPointDiffGeom& oDiffG) +{ + // curvatura + if ( oDiffG.nStatus == CrvPointDiffGeom::NCRV && fabs( oDiffG.dCurv) > EPS_ZERO) { + // tratto di arco + Point3d ptCen = oDiffG.ptP + oDiffG.vtN / oDiffG.dCurv ; + bool bCCW = ( oDiffG.vtT ^ oDiffG.vtN).z > 0 ; + double dAngCenDeg = ( bCCW ? 1 : -1) * 4 * oDiffG.dCurv * RADTODEG ; + ArcCPA( ptCen, oDiffG.ptP, dAngCenDeg) ; + // raggio + Line2P( oDiffG.ptP, ptCen) ; + } + // altrimenti, tangente + else if ( oDiffG.nStatus == CrvPointDiffGeom::TANG && ! oDiffG.vtT.IsSmall()) + Line2P( oDiffG.ptP - oDiffG.vtT, oDiffG.ptP + oDiffG.vtT) ; + // altrimenti cerchietto + else + CircleCR( oDiffG.ptP, 1) ; + + return true ; +} + +//---------------------------------------------------------------------------- +bool +OutTsc::NormalOrNone( const CrvPointDiffGeom& oDiffG) +{ + const double NORM_LEN = 10 ; + + + // normale + if ( oDiffG.nStatus == CrvPointDiffGeom::NCRV && fabs( oDiffG.dCurv) > EPS_ZERO) { + double dLen = __min( NORM_LEN, 1 / oDiffG.dCurv) ; + Line2P( oDiffG.ptP - NORM_LEN * oDiffG.vtN, oDiffG.ptP + dLen * oDiffG.vtN) ; + } + // segmento perpendicolare alla tangente + else if ( oDiffG.nStatus == CrvPointDiffGeom::TANG && ! oDiffG.vtT.IsSmall()) { + Vector3d vtN = oDiffG.vtT ^ Z_AX ; + if ( ! vtN.Normalize()) { + vtN = oDiffG.vtT ^ Y_AX ; + vtN.Normalize() ; + } + Line2P( oDiffG.ptP - NORM_LEN * vtN, oDiffG.ptP + NORM_LEN * vtN) ; + } + // altrimenti cerchietto + else + CircleCR( oDiffG.ptP, 1) ; + + return true ; +} + +//---------------------------------------------------------------------------- +bool +OutTsc::PutGeoObj( const IGeoObj* pGeoObj, int nFlag) +{ + // GeoVector3d + if ( pGeoObj->GetType() == GEO_VECT3D) { + const IGeoVector3d* pGVector ; + // recupero e controllo il vettore + if ( ( pGVector = GetGeoVector3d( pGeoObj)) == nullptr) + return false ; + // eseguo output + return Vector( pGVector->GetVector()) ; + } + // GeoPoint3d + else if ( pGeoObj->GetType() == GEO_PNT3D) { + const IGeoPoint3d* pGPoint ; + // recupero e controllo il punto + if ( ( pGPoint = GetGeoPoint3d( pGeoObj)) == nullptr) + return false ; + // eseguo output + return Point( pGPoint->GetPoint()) ; + } + // GeoFrame3d + else if ( pGeoObj->GetType() == GEO_FRAME3D) { + const IGeoFrame3d* pGFrame ; + // recupero e controllo il punto + if ( ( pGFrame = GetGeoFrame3d( pGeoObj)) == nullptr) + return false ; + // eseguo output + return Frame( pGFrame->GetFrame()) ; + } + // Curve (Line, Arc, Bezier, Composite) + else if (( pGeoObj->GetType() & GEO_CURVE) != 0) { + const ICurve* pCurve ; + // recupero e controllo la curva + if ( ( pCurve = GetCurve( pGeoObj)) == nullptr) + return false ; + // eseguo output + return PutCurve( pCurve, nFlag) ; + } + else + return true ; +} + +//---------------------------------------------------------------------------- +bool +OutTsc::PutCurve( const ICurve* pCurve, int nFlag) +{ + // ciclo per disegnare i segmenti + Remark( "Curve") ; + Point3d ptIni ; + Point3d ptFin ; + PolyLine PL ; + pCurve->ApproxWithLines( 0.1, 5, PL) ; + for ( bool bFound = PL.GetFirstLine( ptIni, ptFin) ; bFound ; bFound = PL.GetNextLine( ptIni, ptFin)) + Line2P( ptIni, ptFin) ; + + // se richieste tangenti e curvature + if ( ( nFlag & 1) != 0) { + // ciclo per disegnare le derivate e le curvature + Remark( "Curve:Tangents+Der2") ; + double dU ; + for ( bool bFound = PL.GetFirstU( dU) ; bFound ; bFound = PL.GetNextU( dU)) { + // ricavo il punto, la tangente, la normale e la curvatura + CrvPointDiffGeom oDiffG ; + pCurve->GetPointDiffGeom( dU, ICurve::FROM_MINUS, oDiffG) ; + // curvatura o tangente o niente + ArcCurvOrTgOrNone( oDiffG) ; + // se punto con possibili discontinuitā + if ( oDiffG.nFlag == CrvPointDiffGeom::TO_VERIFY) { + // ricavo il punto, la tangente, la normale e la curvatura dall'intorno superiore + CrvPointDiffGeom oDiffGs ; + pCurve->GetPointDiffGeom( dU, ICurve::FROM_PLUS, oDiffGs) ; + // se ci sono delle discontinuitā + if ( ThereIsDiscontinuity( oDiffG, oDiffGs)) + // emetto curvatura o tangente o niente + ArcCurvOrTgOrNone( oDiffGs) ; + } + } + } + + // se richieste normali + if ( ( nFlag & 2) != 0) { + // ciclo per disegnare le derivate e le curvature + Remark( "Curve:Normals") ; + double dU ; + for ( bool bFound = PL.GetFirstU( dU) ; bFound ; bFound = PL.GetNextU( dU)) { + // ricavo il punto, la tangente, la normale e la curvatura + CrvPointDiffGeom oDiffG ; + pCurve->GetPointDiffGeom( dU, ICurve::FROM_MINUS, oDiffG) ; + // curvatura o tangente o niente + NormalOrNone( oDiffG) ; + // se punto con possibili discontinuitā + if ( oDiffG.nFlag == CrvPointDiffGeom::TO_VERIFY) { + // ricavo il punto, la tangente, la normale e la curvatura dall'intorno superiore + CrvPointDiffGeom oDiffGs ; + pCurve->GetPointDiffGeom( dU, ICurve::FROM_PLUS, oDiffGs) ; + // se ci sono delle discontinuitā + if ( ThereIsDiscontinuity( oDiffG, oDiffGs)) + // normale o niente + NormalOrNone( oDiffGs) ; + } + } + } + + // se curva di Bezier e richiesto anche il poligono di controllo + if ( pCurve->GetType() == CRV_BEZ && ( nFlag & 4) != 0) + PutPolygBez( *(GetCurveBezier( pCurve))) ; + + // se richiesto il box + if ( ( nFlag & 8) != 0) { + BBox3d b3B ; + if ( pCurve->GetLocalBBox( b3B)) + PutBBox( b3B) ; + } + + return true ; +} + +//---------------------------------------------------------------------------- +bool +OutTsc::PutPolygBez( const ICurveBezier& CrvBez) +{ + int i ; + Point3d ptIni ; + Point3d ptFin ; + + + // ciclo per disegnare il poligono di controllo + Remark( "BezierPolygon") ; + ptIni = CrvBez.GetControlPoint( 0) ; + for ( i = 1 ; i <= CrvBez.GetDegree() ; ++ i) { + ptFin = CrvBez.GetControlPoint( i) ; + // disegno + Line2P( ptIni, ptFin) ; + // nuovo iniziale prende i valori del finale + ptIni = ptFin ; + } + + return true ; +} + +//---------------------------------------------------------------------------- +bool +OutTsc::PutBBox( const BBox3d& b3B) +{ + Point3d ptMin ; + Point3d ptMax ; + + + if ( b3B.GetMinMax( ptMin, ptMax)) { + Remark( "BoundingBox") ; + // se ridotto a un punto + if ( AreSamePointNear( ptMin, ptMax)) + Point( ptMin) ; + // se ridotto ad una linea + else if ( (( ptMax.x - ptMin.x) < EPS_SMALL && ( ptMax.y - ptMin.y) < EPS_SMALL) || + (( ptMax.y - ptMin.y) < EPS_SMALL && ( ptMax.z - ptMin.z) < EPS_SMALL) || + (( ptMax.z - ptMin.z) < EPS_SMALL && ( ptMax.x - ptMin.x) < EPS_SMALL)) + Line2P( ptMin, ptMax) ; + // se ridotto ad un rettangolo nel piano XY + else if ( ( ptMax.z - ptMin.z) < EPS_SMALL) { + // giro a Zmin + Line2P( Point3d( ptMin.x, ptMin.y, ptMin.z), Point3d( ptMax.x, ptMin.y, ptMin.z)) ; + Line2P( Point3d( ptMax.x, ptMin.y, ptMin.z), Point3d( ptMax.x, ptMax.y, ptMin.z)) ; + Line2P( Point3d( ptMax.x, ptMax.y, ptMin.z), Point3d( ptMin.x, ptMax.y, ptMin.z)) ; + Line2P( Point3d( ptMin.x, ptMax.y, ptMin.z), Point3d( ptMin.x, ptMin.y, ptMin.z)) ; + } + // se ridotto ad un rettangolo nel piano YZ + else if ( ( ptMax.x - ptMin.x) < EPS_SMALL) { + // giro a Xmin + Line2P( Point3d( ptMin.x, ptMin.y, ptMin.z), Point3d( ptMin.x, ptMax.y, ptMin.z)) ; + Line2P( Point3d( ptMin.x, ptMax.y, ptMin.z), Point3d( ptMin.x, ptMax.y, ptMax.z)) ; + Line2P( Point3d( ptMin.x, ptMax.y, ptMax.z), Point3d( ptMin.x, ptMin.y, ptMax.z)) ; + Line2P( Point3d( ptMin.x, ptMin.y, ptMax.z), Point3d( ptMin.x, ptMin.y, ptMin.z)) ; + } + // se ridotto ad un rettangolo nel piano ZX + else if ( ( ptMax.y - ptMin.y) < EPS_SMALL) { + // giro a Ymin + Line2P( Point3d( ptMin.x, ptMin.y, ptMin.z), Point3d( ptMax.x, ptMin.y, ptMin.z)) ; + Line2P( Point3d( ptMax.x, ptMin.y, ptMax.z), Point3d( ptMax.x, ptMin.y, ptMax.z)) ; + Line2P( Point3d( ptMax.x, ptMin.y, ptMax.z), Point3d( ptMin.x, ptMin.y, ptMax.z)) ; + Line2P( Point3d( ptMin.x, ptMin.y, ptMax.z), Point3d( ptMin.x, ptMin.y, ptMin.z)) ; + } + // caso generico + else { + // giro a Zmin + Line2P( Point3d( ptMin.x, ptMin.y, ptMin.z), Point3d( ptMax.x, ptMin.y, ptMin.z)) ; + Line2P( Point3d( ptMax.x, ptMin.y, ptMin.z), Point3d( ptMax.x, ptMax.y, ptMin.z)) ; + Line2P( Point3d( ptMax.x, ptMax.y, ptMin.z), Point3d( ptMin.x, ptMax.y, ptMin.z)) ; + Line2P( Point3d( ptMin.x, ptMax.y, ptMin.z), Point3d( ptMin.x, ptMin.y, ptMin.z)) ; + // giro a Zmax + Line2P( Point3d( ptMin.x, ptMin.y, ptMax.z), Point3d( ptMax.x, ptMin.y, ptMax.z)) ; + Line2P( Point3d( ptMax.x, ptMin.y, ptMax.z), Point3d( ptMax.x, ptMax.y, ptMax.z)) ; + Line2P( Point3d( ptMax.x, ptMax.y, ptMax.z), Point3d( ptMin.x, ptMax.y, ptMax.z)) ; + Line2P( Point3d( ptMin.x, ptMax.y, ptMax.z), Point3d( ptMin.x, ptMin.y, ptMax.z)) ; + // giunzione tra i due giri + Line2P( Point3d( ptMin.x, ptMin.y, ptMin.z), Point3d( ptMin.x, ptMin.y, ptMax.z)) ; + Line2P( Point3d( ptMax.x, ptMin.y, ptMin.z), Point3d( ptMax.x, ptMin.y, ptMax.z)) ; + Line2P( Point3d( ptMax.x, ptMax.y, ptMin.z), Point3d( ptMax.x, ptMax.y, ptMax.z)) ; + Line2P( Point3d( ptMin.x, ptMax.y, ptMin.z), Point3d( ptMin.x, ptMax.y, ptMax.z)) ; + } + } + + return true ; +} \ No newline at end of file diff --git a/OutScl.h b/OutTsc.h similarity index 55% rename from OutScl.h rename to OutTsc.h index 5650284..354ce51 100644 --- a/OutScl.h +++ b/OutTsc.h @@ -1,21 +1,24 @@ //---------------------------------------------------------------------------- -// EgalTech 2013-2013 +// EgalTech 2013-2014 //---------------------------------------------------------------------------- -// File : OutScl.h Data : 25.11.13 Versione : 1.3a1 -// Contenuto : Dichiarazione della classe output SCL. +// File : OutTsc.h Data : 23.03.14 Versione : 1.5c9 +// Contenuto : Dichiarazione della classe output Tsc. // // // -// Modifiche : 31.12.12 DS Creazione modulo. +// Modifiche : 23.03.14 DS Creazione modulo. // // //---------------------------------------------------------------------------- #pragma once +#include "/EgtDev/Include/EGkColor.h" #include +#include #include +class Vector3d ; class Point3d ; class BBox3d ; class Frame3d ; @@ -26,17 +29,19 @@ class CrvPointDiffGeom ; //---------------------------------------------------------------------------- -class OutScl +class OutTsc { public : - OutScl( void) ; - ~OutScl( void) ; - bool Open( const std::string& sOutScl) ; + OutTsc( void) ; + ~OutTsc( void) ; + bool Open( const std::string& sOutTsc) ; bool Close( void) ; bool Remark( const std::string& sRemark) ; bool SetMaterial( double dRed, double dGreen, double dBlue) ; - bool SetPartLay( const std::string& sPart, const std::string& sLay) ; - bool SetPartLayRef( const std::string& sPart, const std::string& sLay, const Frame3d& frFrame) ; + bool PushGroup( void) ; + bool PopGroup( void) ; + bool NewGroup( int nLev) ; + bool NewGroupRef( const Frame3d& frFrame, int nLev) ; bool PutCurrRef( void) ; bool PutGeoObj( const IGeoObj* pGeoObj, int nFlag) ; bool PutBBox( const BBox3d& b3B) ; @@ -45,9 +50,11 @@ class OutScl bool Start( void) ; bool End( void) ; bool New( void) ; - bool SetMaterial( const std::string& sMaterial, double dRed, double dGreen, double dBlue) ; + bool PutMaterial( int nObjId, bool bGroup = false) ; + bool Vector( const Vector3d& vtV) ; + bool Point( const Point3d& ptP) ; + bool Frame( const Frame3d& frF) ; bool Line2P( const Point3d& ptP1, const Point3d& ptP2) ; - bool Arc3P( const Point3d& ptP1, const Point3d& ptP2, const Point3d& ptP3) ; bool ArcCPA( const Point3d& ptCen, const Point3d& ptMed, double dAngCenDeg) ; bool CircleCR( const Point3d& ptCen, double dRad) ; bool ArcCurvOrTgOrNone( const CrvPointDiffGeom& oDiffG) ; @@ -55,9 +62,14 @@ class OutScl bool PutCurve( const ICurve* pCurve, int nFlag) ; bool PutPolygBez( const ICurveBezier& CrvBez) ; + private : + typedef std::stack INTSTACK ; + private : std::ofstream m_ofFile ; - std::string m_sMaterial ; - std::string m_sPartLay ; + int m_nId ; // Id dell'ultimo oggetto emesso + INTSTACK m_nGroup ; // stack con Id dei gruppi correnti + bool m_bOutCol ; // flag per emissione colore + Color m_cCol ; // colore corrente } ;