From a52d73aa7a89f8a79ea2080b44b062a1a4738e62 Mon Sep 17 00:00:00 2001 From: Dario Sassi Date: Tue, 27 May 2014 16:05:28 +0000 Subject: [PATCH] EgtGeomKernel : - aggiunti due nuovi comandi a TSC per creazione CurveComposte da punti e da punti con bulge. --- GdbExecutor.cpp | 127 +++++++++++++++++++++++++++++++++++++++++++++--- GdbExecutor.h | 6 ++- 2 files changed, 124 insertions(+), 9 deletions(-) diff --git a/GdbExecutor.cpp b/GdbExecutor.cpp index 481b24a..8172457 100644 --- a/GdbExecutor.cpp +++ b/GdbExecutor.cpp @@ -1147,6 +1147,12 @@ GdbExecutor::ExecuteCurveCompo( const string& sCmd2, const STRVECTOR& vsParams) // creazione generica if ( sCmd2 == "" || sCmd2 == "MAKE") return CurveCompoMake( vsParams) ; + // creazione per congiunzione di punti (segmenti di retta) + else if ( sCmd2 == "P" || sCmd2 == "FROMPOINTS") + return CurveCompoFromPoints( vsParams) ; + // creazione per congiunzione di punti con bulge (segmenti di retta e arco) + else if ( sCmd2 == "PB" || sCmd2 == "FROMPOINTBULGES") + return CurveCompoFromPointBulges( vsParams) ; // creazione da split di curva semplice else if ( sCmd2 == "S" || sCmd2 == "FROMSPLIT") return CurveCompoFromSplit( vsParams) ; @@ -1229,6 +1235,58 @@ GdbExecutor::CurveCompoMake( const STRVECTOR& vsParams) return false ; } +//---------------------------------------------------------------------------- +bool +GdbExecutor::CurveCompoFromPoints( const STRVECTOR& vsParams) +{ + // 3 parametri : Id, ParentId, Points + if ( vsParams.size() != 3) + return false ; + // recupero il riferimento del gruppo destinazione + Frame3d frDest ; + if ( ! m_pGDB->GetGroupGlobFrame( GetIdParam( vsParams[1]), frDest)) + return false ; + // recupero i punti + PNTVECTOR vPoints ; + if ( ! GetPointsParam( vsParams[2], frDest, vPoints)) + return false ; + // creo la curva composita + PtrOwner pCrvCompo( CreateCurveComposite()) ; + if ( ! IsValid( pCrvCompo)) + return false ; + // inserisco i segmenti che uniscono i punti + if ( ! pCrvCompo->FromPointVector( vPoints)) + return false ; + // inserisco la curva composita nel DB + return AddGeoObj( vsParams[0], vsParams[1], Release( pCrvCompo)) ; +} + +//---------------------------------------------------------------------------- +bool +GdbExecutor::CurveCompoFromPointBulges( const STRVECTOR& vsParams) +{ + // 3 parametri : Id, ParentId, PointWs + if ( vsParams.size() != 3) + return false ; + // recupero il riferimento del gruppo destinazione + Frame3d frDest ; + if ( ! m_pGDB->GetGroupGlobFrame( GetIdParam( vsParams[1]), frDest)) + return false ; + // recupero i punti + UPNTVECTOR vPointWs ; + if ( ! GetPointWsParam( vsParams[2], frDest, vPointWs)) + return false ; + // creo la curva composita + PtrOwner pCrvCompo( CreateCurveComposite()) ; + if ( ! IsValid( pCrvCompo)) + return false ; + // inserisco i segmenti che uniscono i punti + if ( ! pCrvCompo->FromPointBulgeVector( vPointWs, Z_AX)) + return false ; + // inserisco la curva composita nel DB + return AddGeoObj( vsParams[0], vsParams[1], Release( pCrvCompo)) ; +} + //---------------------------------------------------------------------------- bool GdbExecutor::CurveCompoFromSplit( const STRVECTOR& vsParams) @@ -2082,7 +2140,7 @@ GdbExecutor::GetVectorParam( const string& sParam, const Frame3d& frVect, Vector bool GdbExecutor::GetPointParam( const string& sParam, const Frame3d& frPnt, Point3d& ptP) { - // se insieme di tre coordinate (considerate già nel riferimento frPnt) + // se insieme di 2 o 3 coordinate (considerate già nel riferimento frPnt) if ( sParam[0] == '(') { // divido in parti STRVECTOR vsParams ; @@ -2090,12 +2148,21 @@ GdbExecutor::GetPointParam( const string& sParam, const Frame3d& frPnt, Point3d& STRVECTOR::iterator Iter ; for ( Iter = vsParams.begin() ; Iter != vsParams.end() ; ++Iter) Trim( (*Iter), " \t\r\n()") ; - // verifico siano 3 parti e le converto - if ( vsParams.size() != 3) + // se 2 parti, allora Z = 0 + if ( vsParams.size() == 2) { + ptP.z = 0 ; + return ( FromString( vsParams[0], ptP.x) && + FromString( vsParams[1], ptP.y)) ; + } + // se 3 parti + else if ( vsParams.size() == 3) { + return ( FromString( vsParams[0], ptP.x) && + FromString( vsParams[1], ptP.y) && + FromString( vsParams[2], ptP.z)) ; + } + // altrimenti errore + else return false ; - return ( FromString( vsParams[0], ptP.x) && - FromString( vsParams[1], ptP.y) && - FromString( vsParams[2], ptP.z)) ; } // se altrimenti punto predefinito ORIG (considerato già nel riferimento frPnt) else if ( sParam == "ORIG") { @@ -2212,6 +2279,28 @@ GdbExecutor::GetPointParam( const string& sParam, const Frame3d& frPnt, Point3d& } } +//---------------------------------------------------------------------------- +bool +GdbExecutor::GetPointsParam( const string& sParam, const Frame3d& frPnt, PNTVECTOR& vPoints) +{ + // divido in parti + STRVECTOR vsPoints ; + Tokenize( sParam.substr( 1, sParam.length()-2), ",", "(", ")", vsPoints) ; + // converto in punti + vPoints.clear() ; + vPoints.reserve( vsPoints.size()) ; + STRVECTOR::iterator Iter ; + for ( Iter = vsPoints.begin() ; Iter != vsPoints.end() ; ++Iter) { + Trim( (*Iter), " \t\r\n") ; + Point3d ptP ; + if ( ! GetPointParam( *Iter, frPnt, ptP)) + return false ; + vPoints.push_back( ptP) ; + } + + return true ; +} + //---------------------------------------------------------------------------- bool GdbExecutor::GetPointWParam( const string& sParam, const Frame3d& frPnt, Point3d& ptP, double& dW) @@ -2222,10 +2311,10 @@ GdbExecutor::GetPointWParam( const string& sParam, const Frame3d& frPnt, Point3d // divido in parti STRVECTOR vsParams ; - Tokenize( sParam, ",", vsParams) ; + Tokenize( sParam.substr( 1, sParam.length()-2), ",", "(", ")", vsParams) ; STRVECTOR::iterator Iter ; for ( Iter = vsParams.begin() ; Iter != vsParams.end() ; ++Iter) - Trim( (*Iter), " \t\r\n()") ; + Trim( (*Iter), " \t\r\n") ; // se 4 parti, sono 3 coordinate e un peso if ( vsParams.size() == 4) { @@ -2247,6 +2336,28 @@ GdbExecutor::GetPointWParam( const string& sParam, const Frame3d& frPnt, Point3d return false ; } +//---------------------------------------------------------------------------- +bool +GdbExecutor::GetPointWsParam( const string& sParam, const Frame3d& frPnt, UPNTVECTOR& vPointWs) +{ + // divido in parti + STRVECTOR vsPointWs ; + Tokenize( sParam.substr( 1, sParam.length()-2), ",", "(", ")", vsPointWs) ; + // converto in punti + vPointWs.clear() ; + vPointWs.reserve( vsPointWs.size()) ; + STRVECTOR::iterator Iter ; + for ( Iter = vsPointWs.begin() ; Iter != vsPointWs.end() ; ++Iter) { + Trim( (*Iter), " \t\r\n") ; + UPOINT ptPW ; + if ( ! GetPointWParam( *Iter, frPnt, ptPW.second, ptPW.first)) + return false ; + vPointWs.push_back( ptPW) ; + } + + return true ; +} + //---------------------------------------------------------------------------- bool GdbExecutor::GetLengthParam( const string& sParam, double& dLen) diff --git a/GdbExecutor.h b/GdbExecutor.h index b97163b..35b2f02 100644 --- a/GdbExecutor.h +++ b/GdbExecutor.h @@ -17,7 +17,7 @@ #include "/EgtDev/Include/EgkGdbExecutor.h" #include "/EgtDev/Include/EgtPerfCounter.h" #include "/EgtDev/Include/EgtExecMgr.h" -#include "/EgtDev/Include/EgtNumCollection.h" +#include "/EgtDev/Include/EgkGeoCollection.h" class PolyLine ; @@ -42,7 +42,9 @@ class GdbExecutor : public IGdbExecutor bool GetNamesParam( const std::string& sParam, INTVECTOR& vnNames) ; bool GetVectorParam( const std::string& sParam, const Frame3d& frVect, Vector3d& vtV) ; bool GetPointParam( const std::string& sParam, const Frame3d& frPnt, Point3d& ptP) ; + bool GetPointsParam( const std::string& sParam, const Frame3d& frPnt, PNTVECTOR& vPoints) ; bool GetPointWParam( const std::string& sParam, const Frame3d& frPnt, Point3d& ptP, double& dW) ; + bool GetPointWsParam( const std::string& sParam, const Frame3d& frPnt, UPNTVECTOR& vPointWs) ; bool GetLengthParam( const std::string& sParam, double& dLen) ; bool GetDirParam( const std::string& sParam, const Frame3d& frDir, double& dDir) ; bool GetFrameParam( const std::string& sParam, const Frame3d& frRef, Frame3d& frF) ; @@ -74,6 +76,8 @@ class GdbExecutor : public IGdbExecutor bool ExecuteCurveBez( const std::string& sCmd2, const STRVECTOR& vsParams) ; bool ExecuteCurveCompo( const std::string& sCmd2, const STRVECTOR& vsParams) ; bool CurveCompoMake( const STRVECTOR& vsParams) ; + bool CurveCompoFromPoints( const STRVECTOR& vsParams) ; + bool CurveCompoFromPointBulges( const STRVECTOR& vsParams) ; bool CurveCompoFromSplit( const STRVECTOR& vsParams) ; bool CurveCompoAddCurve( const STRVECTOR& vsParams) ; bool ExecuteSurfTriMesh( const std::string& sCmd2, const STRVECTOR& vsParams) ;