From cc86dbd73d5d7e81880e89fbb394d03bdcc2bf05 Mon Sep 17 00:00:00 2001 From: Dario Sassi Date: Thu, 10 Apr 2014 07:02:37 +0000 Subject: [PATCH] EgtGeomKernel 1.5d3 : - aggiunte Move, Rot, Mirror e Scale di gruppo espresse nel suo proprio rif. --- EgtGeomKernel.rc | Bin 11710 -> 11710 bytes GdbExecutor.cpp | 100 ++++++++++++++++++++++++++++++++++------------- GdbGroup.h | 2 + GeomDB.cpp | 82 ++++++++++++++++++++++++++++++++++++++ GeomDB.h | 7 ++++ 5 files changed, 163 insertions(+), 28 deletions(-) diff --git a/EgtGeomKernel.rc b/EgtGeomKernel.rc index d3db20e8847ebd1443643fd3f42f28a848bdcbf0..c90eb8ae4d5426e1fd1ac9d2c3891d48248c6100 100644 GIT binary patch delta 81 zcmdlNy)SyhH#SD&&FAG5nSsTranslateGlob( *Iter, vtVN)) - return false ; - } - else { + switch ( nTraType) { + case TRA_LOC : if ( ! m_pGDB->Translate( *Iter, vtVN)) return false ; + break ; + case TRA_GLOB : + if ( ! m_pGDB->TranslateGlob( *Iter, vtVN)) + return false ; + break ; + case TRA_GROUP : + if ( ! m_pGDB->TranslateGroup( *Iter, vtVN)) + return false ; + break ; } } @@ -1583,18 +1594,29 @@ GdbExecutor::ExecuteRotate( const std::string& sCmd2, const STRVECTOR& vsParams) double dAngDeg ; if ( ! FromString( vsParams[3], dAngDeg)) return false ; - // recupero flag per globale - bool bGlob = ( sCmd2 == "GLOB" || sCmd2 == "G") ; + // recupero flag per locale/globale/gruppo + enum { ROT_LOC = 0, ROT_GLOB = 1, ROT_GROUP = 2} ; + int nRotType = ROT_LOC ; + if ( sCmd2 == "GLOB" || sCmd2 == "G") + nRotType = ROT_GLOB ; + else if ( sCmd2 == "GROUP" || sCmd2 == "GR") + nRotType = ROT_GROUP ; // esecuzione rotazioni INTVECTOR::iterator Iter ; for ( Iter = vnNames.begin() ; Iter != vnNames.end() ; ++Iter) { - if ( bGlob) { - if ( ! m_pGDB->RotateGlob( *Iter, ptPC, vtVN, dAngDeg)) - return false ; - } - else { + switch ( nRotType) { + case ROT_LOC : if ( ! m_pGDB->Rotate( *Iter, ptPC, vtVN, dAngDeg)) return false ; + break ; + case ROT_GLOB : + if ( ! m_pGDB->RotateGlob( *Iter, ptPC, vtVN, dAngDeg)) + return false ; + break ; + case ROT_GROUP : + if ( ! m_pGDB->RotateGroup( *Iter, ptPC, vtVN, dAngDeg)) + return false ; + break ; } } @@ -1629,18 +1651,29 @@ GdbExecutor::ExecuteScale( const std::string& sCmd2, const STRVECTOR& vsParams) ! FromString( vsParams[3], dCoeffY) || ! FromString( vsParams[4], dCoeffZ)) return false ; - // recupero flag per globale - bool bGlob = ( sCmd2 == "GLOB" || sCmd2 == "G") ; + // recupero flag per locale/globale/gruppo + enum { SCA_LOC = 0, SCA_GLOB = 1, SCA_GROUP = 2} ; + int nScaType = SCA_LOC ; + if ( sCmd2 == "GLOB" || sCmd2 == "G") + nScaType = SCA_GLOB ; + else if ( sCmd2 == "GROUP" || sCmd2 == "GR") + nScaType = SCA_GROUP ; // esecuzione scalature INTVECTOR::iterator Iter ; for ( Iter = vnNames.begin() ; Iter != vnNames.end() ; ++Iter) { - if ( bGlob) { - if ( ! m_pGDB->ScaleGlob( *Iter, frRef, dCoeffX, dCoeffY, dCoeffZ)) - return false ; - } - else { + switch ( nScaType) { + case SCA_LOC : if ( ! m_pGDB->Scale( *Iter, frRef, dCoeffX, dCoeffY, dCoeffZ)) return false ; + break ; + case SCA_GLOB : + if ( ! m_pGDB->ScaleGlob( *Iter, frRef, dCoeffX, dCoeffY, dCoeffZ)) + return false ; + break ; + case SCA_GROUP : + if ( ! m_pGDB->ScaleGroup( *Iter, frRef, dCoeffX, dCoeffY, dCoeffZ)) + return false ; + break ; } } @@ -1666,18 +1699,29 @@ GdbExecutor::ExecuteMirror( const std::string& sCmd2, const STRVECTOR& vsParams) Vector3d vtVN ; if ( ! GetVectorParam( vsParams[2], vtVN)) return false ; - // recupero flag per globale - bool bGlob = ( sCmd2 == "GLOB" || sCmd2 == "G") ; + // recupero flag per locale/globale/gruppo + enum { MIR_LOC = 0, MIR_GLOB = 1, MIR_GROUP = 2} ; + int nMirType = MIR_LOC ; + if ( sCmd2 == "GLOB" || sCmd2 == "G") + nMirType = MIR_GLOB ; + else if ( sCmd2 == "GROUP" || sCmd2 == "GR") + nMirType = MIR_GROUP ; // esecuzione specchiature INTVECTOR::iterator Iter ; for ( Iter = vnNames.begin() ; Iter != vnNames.end() ; ++Iter) { - if ( bGlob) { - if ( ! m_pGDB->MirrorGlob( *Iter, ptPC, vtVN)) - return false ; - } - else { + switch ( nMirType) { + case MIR_LOC : if ( ! m_pGDB->Mirror( *Iter, ptPC, vtVN)) return false ; + break ; + case MIR_GLOB : + if ( ! m_pGDB->MirrorGlob( *Iter, ptPC, vtVN)) + return false ; + break ; + case MIR_GROUP : + if ( ! m_pGDB->MirrorGroup( *Iter, ptPC, vtVN)) + return false ; + break ; } } diff --git a/GdbGroup.h b/GdbGroup.h index 1c54807..f2d98b3 100644 --- a/GdbGroup.h +++ b/GdbGroup.h @@ -68,6 +68,8 @@ class GdbGroup : public GdbObj { static std::string s_sKey = "A_GRP" ; return s_sKey ; } public : + const Frame3d& GetFrame( void) const + { return m_gfrFrame.GetFrame() ; } bool GetGlobFrame( Frame3d& frGlob) const ; public : diff --git a/GeomDB.cpp b/GeomDB.cpp index 753ab3d..a4fd7c1 100644 --- a/GeomDB.cpp +++ b/GeomDB.cpp @@ -685,6 +685,25 @@ GeomDB::TranslateGlob( int nId, const Vector3d& vtMove) return pGdbObj->Translate( vtMoveLoc) ; } +//---------------------------------------------------------------------------- +// La traslazione è espressa nel riferimento del gruppo (ovvero il proprio). +//---------------------------------------------------------------------------- +bool +GeomDB::TranslateGroup( int nId, const Vector3d& vtMove) +{ + // recupero il gruppo Gdb + GdbGroup* pGdbGroup ; + if ( ( pGdbGroup = GetGdbGroup( nId)) == nullptr) + return false ; + // utilizzo il riferimento proprio + // porto il movimento nel riferimento in cui è immerso + Vector3d vtMoveLoc = vtMove ; + if ( ! vtMoveLoc.ToGlob( pGdbGroup->GetFrame())) + return false ; + // eseguo la traslazione + return pGdbGroup->Translate( vtMoveLoc) ; +} + //---------------------------------------------------------------------------- bool GeomDB::Rotate( int nId, const Point3d& ptAx, const Vector3d& vtAx, double dCosAng, double dSinAng) @@ -720,6 +739,28 @@ GeomDB::RotateGlob( int nId, const Point3d& ptAx, const Vector3d& vtAx, double d return pGdbObj->Rotate( ptAxLoc, vtAxLoc, dCosAng, dSinAng) ; } +//---------------------------------------------------------------------------- +// La rotazione è espressa nel riferimento del gruppo (ovvero il proprio). +//---------------------------------------------------------------------------- +bool +GeomDB::RotateGroup( int nId, const Point3d& ptAx, const Vector3d& vtAx, double dCosAng, double dSinAng) +{ + // recupero il gruppo Gdb + GdbGroup* pGdbGroup ; + if ( ( pGdbGroup = GetGdbGroup( nId)) == nullptr) + return false ; + // utilizzo il riferimento proprio + // porto i parametri di rotazione nel riferimento in cui è immerso + Point3d ptAxLoc = ptAx ; + if ( ! ptAxLoc.ToGlob( pGdbGroup->GetFrame())) + return false ; + Vector3d vtAxLoc = vtAx ; + if ( ! vtAxLoc.ToGlob( pGdbGroup->GetFrame())) + return false ; + // eseguo la rotazione + return pGdbGroup->Rotate( ptAxLoc, vtAxLoc, dCosAng, dSinAng) ; +} + //---------------------------------------------------------------------------- bool GeomDB::Scale( int nId, const Frame3d& frRef, double dCoeffX, double dCoeffY, double dCoeffZ) @@ -752,6 +793,25 @@ GeomDB::ScaleGlob( int nId, const Frame3d& frRef, double dCoeffX, double dCoeffY return pGdbObj->Scale( frRefLoc, dCoeffX, dCoeffY, dCoeffZ) ; } +//---------------------------------------------------------------------------- +// La scalatura è espressa nel riferimento del gruppo (ovvero il proprio). +//---------------------------------------------------------------------------- +bool +GeomDB::ScaleGroup( int nId, const Frame3d& frRef, double dCoeffX, double dCoeffY, double dCoeffZ) +{ + // recupero il gruppo Gdb + GdbGroup* pGdbGroup ; + if ( ( pGdbGroup = GetGdbGroup( nId)) == nullptr) + return false ; + // utilizzo il riferimento proprio + // porto il riferimento di scalatura nel riferimento in cui è immerso + Frame3d frRefLoc = frRef ; + if ( ! frRefLoc.ToGlob( pGdbGroup->GetFrame())) + return false ; + // eseguo la scalatura + return pGdbGroup->Scale( frRefLoc, dCoeffX, dCoeffY, dCoeffZ) ; +} + //---------------------------------------------------------------------------- bool GeomDB::Mirror( int nId, const Point3d& ptOn, const Vector3d& vtNorm) @@ -787,6 +847,28 @@ GeomDB::MirrorGlob( int nId, const Point3d& ptOn, const Vector3d& vtNorm) return pGdbObj->Mirror( ptOnLoc, vtNormLoc) ; } +//---------------------------------------------------------------------------- +// La specchiatura è espressa nel riferimento del gruppo (ovvero il proprio). +//---------------------------------------------------------------------------- +bool +GeomDB::MirrorGroup( int nId, const Point3d& ptOn, const Vector3d& vtNorm) +{ + // recupero il gruppo Gdb + GdbGroup* pGdbGroup ; + if ( ( pGdbGroup = GetGdbGroup( nId)) == nullptr) + return false ; + // utilizzo il riferimento proprio + // porto i parametri di mirror nel riferimento in cui è immerso + Point3d ptOnLoc = ptOn ; + if ( ! ptOnLoc.ToGlob( pGdbGroup->GetFrame())) + return false ; + Vector3d vtNormLoc = vtNorm ; + if ( ! vtNormLoc.ToGlob( pGdbGroup->GetFrame())) + return false ; + // eseguo l'operazione + return pGdbGroup->Mirror( ptOnLoc, vtNormLoc) ; +} + //---------------------------------------------------------------------------- // Selection //---------------------------------------------------------------------------- diff --git a/GeomDB.h b/GeomDB.h index 67a7ada..d4a994e 100644 --- a/GeomDB.h +++ b/GeomDB.h @@ -52,18 +52,25 @@ class GeomDB : public IGeomDB virtual bool Erase( int nId) ; virtual bool Translate( int nId, const Vector3d& vtMove) ; virtual bool TranslateGlob( int nId, const Vector3d& vtMove) ; + virtual bool TranslateGroup( int nId, const Vector3d& vtMove) ; virtual bool Rotate( int nId, const Point3d& ptAx, const Vector3d& vtAx, double dCosAng, double dSinAng) ; virtual bool RotateGlob( int nId, const Point3d& ptAx, const Vector3d& vtAx, double dCosAng, double dSinAng) ; + virtual bool RotateGroup( int nId, const Point3d& ptAx, const Vector3d& vtAx, double dCosAng, double dSinAng) ; virtual bool Rotate( int nId, const Point3d& ptAx, const Vector3d& vtAx, double dAngDeg) { double dAngRad = dAngDeg * DEGTORAD ; return Rotate( nId, ptAx, vtAx, cos( dAngRad), sin( dAngRad)) ; } virtual bool RotateGlob( int nId, const Point3d& ptAx, const Vector3d& vtAx, double dAngDeg) { double dAngRad = dAngDeg * DEGTORAD ; return RotateGlob( nId, ptAx, vtAx, cos( dAngRad), sin( dAngRad)) ; } + virtual bool RotateGroup( int nId, const Point3d& ptAx, const Vector3d& vtAx, double dAngDeg) + { double dAngRad = dAngDeg * DEGTORAD ; + return RotateGroup( nId, ptAx, vtAx, cos( dAngRad), sin( dAngRad)) ; } virtual bool Scale( int nId, const Frame3d& frRef, double dCoeffX, double dCoeffY, double dCoeffZ) ; virtual bool ScaleGlob( int nId, const Frame3d& frRef, double dCoeffX, double dCoeffY, double dCoeffZ) ; + virtual bool ScaleGroup( int nId, const Frame3d& frRef, double dCoeffX, double dCoeffY, double dCoeffZ) ; virtual bool Mirror( int nId, const Point3d& ptOn, const Vector3d& vtNorm) ; virtual bool MirrorGlob( int nId, const Point3d& ptOn, const Vector3d& vtNorm) ; + virtual bool MirrorGroup( int nId, const Point3d& ptOn, const Vector3d& vtNorm) ; // selection virtual bool SelectObj( int nId) ; virtual bool DeselectObj( int nId) ;