From 08831a6849784c8e49bf22af805ec483c6288098 Mon Sep 17 00:00:00 2001 From: Dario Sassi Date: Thu, 16 Apr 2015 06:47:52 +0000 Subject: [PATCH] =?UTF-8?q?EgtGeomKernel=201.6d2=20:=20-=20BBox3d=20aggiun?= =?UTF-8?q?ta=20LocToLoc=20e=20migliorati=20i=20controlli=20per=20validit?= =?UTF-8?q?=C3=A0=20-=20aggiunta=20gestione=20estrusione=20nell'ingombro?= =?UTF-8?q?=20delle=20curve=20-=20a=20CurveComposite=20aggiunta=20funzione?= =?UTF-8?q?=20che=20la=20chiude=20-=20in=20GdbIterator=20aggiunte=20GoTo?= =?UTF-8?q?=20con=20nome=20-=20in=20GeomDB=20aggiunte=20Get=20con=20nome?= =?UTF-8?q?=20-=20in=20GeomDB=20aggiunto=20swap=20tra=20gruppi=20con=20ges?= =?UTF-8?q?tione=20di=20base,=20sorgente=20e=20lista=20referenti=20-=20mig?= =?UTF-8?q?liorata=20gestione=20materiale=20ereditato=20in=20Relocate=20-?= =?UTF-8?q?=20aggiunte=20SetInfo=20e=20GetInfo=20con=20INTVECTOR=20e=20DBL?= =?UTF-8?q?VECTOR=20-=20aggiunte=20FromString=20e=20ToString=20con=20BBox3?= =?UTF-8?q?d.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Attribs.cpp | 20 +- BBox3d.cpp | 77 ++++++- CurveArc.cpp | 15 +- CurveArc.h | 2 + CurveAux.cpp | 26 ++- CurveAux.h | 1 + CurveBezier.cpp | 13 +- CurveBezier.h | 2 + CurveComposite.cpp | 32 ++- CurveComposite.h | 3 + CurveLine.cpp | 13 +- CurveLine.h | 2 + EgtGeomKernel.rc | Bin 11710 -> 11710 bytes EgtGeomKernel.vcxproj | 1 + EgtGeomKernel.vcxproj.filters | 3 + GdbGroup.cpp | 22 ++ GdbIterator.cpp | 418 +++++++++++++++++++++++++++++++++- GdbIterator.h | 16 ++ GdbObj.cpp | 187 ++++++++++++++- GdbObj.h | 20 ++ GeomDB.cpp | 267 +++++++++++++++++++--- GeomDB.h | 19 +- OutTsc.cpp | 2 +- StringUtils3d.cpp | 13 ++ 24 files changed, 1082 insertions(+), 92 deletions(-) diff --git a/Attribs.cpp b/Attribs.cpp index b77cb4a..cebf155 100644 --- a/Attribs.cpp +++ b/Attribs.cpp @@ -292,8 +292,7 @@ Attribs::SetInfo( const string& sKey, const string& sVal) return SetName( sVal) ; // se esiste già una stringa con quella chiave la sostituisco - STRLIST::iterator iIter ; - for ( iIter = m_slInfo.begin() ; iIter != m_slInfo.end() ; ++ iIter) { + for ( STRLIST::iterator iIter = m_slInfo.begin() ; iIter != m_slInfo.end() ; ++ iIter) { if ( FindKey( *iIter, sKey)) { *iIter = sKey + EQUAL + sVal ; return true ; @@ -316,16 +315,13 @@ Attribs::GetInfo( const string& sKey, string& sVal) const // se chiave non valida, esco con errore if ( ! IsValidString( sKey)) return false ; - // cerco una stringa con la chiave - STRLIST::const_iterator iIter ; - for ( iIter = m_slInfo.begin() ; iIter != m_slInfo.end() ; ++ iIter) { + for ( STRLIST::const_iterator iIter = m_slInfo.begin() ; iIter != m_slInfo.end() ; ++ iIter) { if ( FindKey( *iIter, sKey)) { - sVal = iIter->substr( sKey.length() + 1) ; ; + sVal = iIter->substr( sKey.length() + 1) ; return true ; } } - return false ; } @@ -336,14 +332,11 @@ Attribs::ExistsInfo( const string& sKey) const // se chiave non valida, esco con errore if ( ! IsValidString( sKey)) return false ; - // cerco una stringa con la chiave - STRLIST::const_iterator iIter ; - for ( iIter = m_slInfo.begin() ; iIter != m_slInfo.end() ; ++ iIter) { + for ( STRLIST::const_iterator iIter = m_slInfo.begin() ; iIter != m_slInfo.end() ; ++ iIter) { if ( FindKey( *iIter, sKey)) return true ; } - return false ; } @@ -354,16 +347,13 @@ Attribs::RemoveInfo( const string& sKey) // se chiave non valida, esco con errore if ( ! IsValidString( sKey)) return false ; - // cerco una stringa con la chiave - STRLIST::iterator iIter ; - for ( iIter = m_slInfo.begin() ; iIter != m_slInfo.end() ; ++ iIter) { + for ( STRLIST::iterator iIter = m_slInfo.begin() ; iIter != m_slInfo.end() ; ++ iIter) { if ( FindKey( *iIter, sKey)) { m_slInfo.erase( iIter) ; return true ; } } - // non trovata, la info non richiede rimozione return true ; } diff --git a/BBox3d.cpp b/BBox3d.cpp index eb5777a..655e40d 100644 --- a/BBox3d.cpp +++ b/BBox3d.cpp @@ -15,36 +15,38 @@ #include "stdafx.h" #include "\EgtDev\Include\EGkBBox3d.h" #include "\EgtDev\Include\EGkFrame3d.h" -#include +#include + +using namespace std ; //---------------------------------------------------------------------------- BBox3d::BBox3d( const Point3d& ptP1, const Point3d& ptP2) { - m_ptMin.Set( __min( ptP1.x, ptP2.x), __min( ptP1.y, ptP2.y), __min( ptP1.z, ptP2.z)) ; - m_ptMax.Set( __max( ptP1.x, ptP2.x), __max( ptP1.y, ptP2.y), __max( ptP1.z, ptP2.z)) ; + m_ptMin.Set( min( ptP1.x, ptP2.x), min( ptP1.y, ptP2.y), min( ptP1.z, ptP2.z)) ; + m_ptMax.Set( max( ptP1.x, ptP2.x), max( ptP1.y, ptP2.y), max( ptP1.z, ptP2.z)) ; } //---------------------------------------------------------------------------- BBox3d::BBox3d( double dX1, double dY1, double dZ1, double dX2, double dY2, double dZ2) { - m_ptMin.Set( __min( dX1, dX2), __min( dY1, dY2), __min( dZ1, dZ2)) ; - m_ptMax.Set( __max( dX1, dX2), __max( dY1, dY2), __max( dZ1, dZ2)) ; + m_ptMin.Set( min( dX1, dX2), min( dY1, dY2), min( dZ1, dZ2)) ; + m_ptMax.Set( max( dX1, dX2), max( dY1, dY2), max( dZ1, dZ2)) ; } //---------------------------------------------------------------------------- void BBox3d::Set( const Point3d& ptP1, const Point3d& ptP2) { - m_ptMin.Set( __min( ptP1.x, ptP2.x), __min( ptP1.y, ptP2.y), __min( ptP1.z, ptP2.z)) ; - m_ptMax.Set( __max( ptP1.x, ptP2.x), __max( ptP1.y, ptP2.y), __max( ptP1.z, ptP2.z)) ; + m_ptMin.Set( min( ptP1.x, ptP2.x), min( ptP1.y, ptP2.y), min( ptP1.z, ptP2.z)) ; + m_ptMax.Set( max( ptP1.x, ptP2.x), max( ptP1.y, ptP2.y), max( ptP1.z, ptP2.z)) ; } //---------------------------------------------------------------------------- void BBox3d::Set( double dX1, double dY1, double dZ1, double dX2, double dY2, double dZ2) { - m_ptMin.Set( __min( dX1, dX2), __min( dY1, dY2), __min( dZ1, dZ2)) ; - m_ptMax.Set( __max( dX1, dX2), __max( dY1, dY2), __max( dZ1, dZ2)) ; + m_ptMin.Set( min( dX1, dX2), min( dY1, dY2), min( dZ1, dZ2)) ; + m_ptMax.Set( max( dX1, dX2), max( dY1, dY2), max( dZ1, dZ2)) ; } //---------------------------------------------------------------------------- @@ -141,6 +143,19 @@ BBox3d::GetMinMax( Point3d& ptMin, Point3d& ptMax) const return true ; } +//---------------------------------------------------------------------------- +bool +BBox3d::GetMinDim( Point3d& ptMin, double& dDimX, double& dDimY, double& dDimZ) const +{ + if ( ! IsValid()) + return false ; + ptMin = m_ptMin ; + dDimX = m_ptMax.x - m_ptMin.x ; + dDimY = m_ptMax.y - m_ptMin.y ; + dDimZ = m_ptMax.z - m_ptMin.z ; + return true ; +} + //---------------------------------------------------------------------------- bool BBox3d::GetCenterExtent( Point3d& ptCenter, Vector3d& vtExtent) const @@ -176,6 +191,8 @@ BBox3d::GetRadius( double& dRad) const bool BBox3d::ToGlob( const Frame3d& frRef) { + if ( ! IsValid()) + return false ; // trasformo il minimo Point3d ptMinGlob = m_ptMin ; if ( ! ptMinGlob.ToGlob( frRef)) @@ -200,6 +217,8 @@ BBox3d::ToGlob( const Frame3d& frRef) bool BBox3d::ToLoc( const Frame3d& frRef) { + if ( ! IsValid()) + return false ; // trasformo il minimo Point3d ptMinLoc = m_ptMin ; if ( ! ptMinLoc.ToLoc( frRef)) @@ -223,6 +242,38 @@ BBox3d::ToLoc( const Frame3d& frRef) return true ; } +//---------------------------------------------------------------------------- +bool +BBox3d::LocToLoc( const Frame3d& frOri, const Frame3d& frDest) +{ + if ( ! IsValid()) + return false ; + // se i due riferimenti coincidono, non devo fare alcunché + if ( AreSameFrame( frOri, frDest)) + return true ; + // trasformo il minimo + Point3d ptMinNewLoc = m_ptMin ; + if ( ! ptMinNewLoc.LocToLoc( frOri, frDest)) + return false ; + // trasformo i vettori dal Min al Max diretti come gli assi locali + Vector3d vtXNewLoc( m_ptMax.x - m_ptMin.x, 0, 0) ; + vtXNewLoc.LocToLoc( frOri, frDest) ; + Vector3d vtYNewLoc( 0, m_ptMax.y - m_ptMin.y, 0) ; + vtYNewLoc.LocToLoc( frOri, frDest) ; + Vector3d vtZNewLoc( 0, 0, m_ptMax.z - m_ptMin.z) ; + vtZNewLoc.LocToLoc( frOri, frDest) ; + // calcolo il box trasformato + Set( ptMinNewLoc) ; + Add( ptMinNewLoc + vtXNewLoc) ; + Add( ptMinNewLoc + vtYNewLoc) ; + Add( ptMinNewLoc + vtZNewLoc) ; + Add( ptMinNewLoc + vtXNewLoc + vtYNewLoc) ; + Add( ptMinNewLoc + vtYNewLoc + vtZNewLoc) ; + Add( ptMinNewLoc + vtZNewLoc + vtXNewLoc) ; + Add( ptMinNewLoc + vtXNewLoc + vtYNewLoc + vtZNewLoc) ; + return true ; +} + //---------------------------------------------------------------------------- bool BBox3d::Encloses( const Point3d& ptP) const @@ -268,6 +319,8 @@ BBox3d::OverlapsXY( const BBox3d& b3B) const bool BBox3d::FindIntersection( const BBox3d& b3B, BBox3d& b3Int) const { + if ( ! IsValid() || ! b3B.IsValid()) + return false ; // verifico direttamente la sovrapposizione if ( m_ptMax.x < b3B.m_ptMin.x - EPS_SMALL || m_ptMin.x > b3B.m_ptMax.x + EPS_SMALL) return false ; @@ -289,6 +342,8 @@ BBox3d::FindIntersection( const BBox3d& b3B, BBox3d& b3Int) const bool BBox3d::FindIntersectionXY( const BBox3d& b3B, BBox3d& b3Int) const { + if ( ! IsValid() || ! b3B.IsValid()) + return false ; // verifico direttamente la sovrapposizione if ( m_ptMax.x < b3B.m_ptMin.x - EPS_SMALL || m_ptMin.x > b3B.m_ptMax.x + EPS_SMALL) return false ; @@ -308,6 +363,8 @@ BBox3d::FindIntersectionXY( const BBox3d& b3B, BBox3d& b3Int) const double BBox3d::SqDistFromPoint( const Point3d& ptP) const { + if ( ! IsValid()) + return INFINITO ; double dSqDist = 0 ; if ( ptP.x < m_ptMin.x) dSqDist += ( m_ptMin.x - ptP.x) * ( m_ptMin.x - ptP.x) ; @@ -328,6 +385,8 @@ BBox3d::SqDistFromPoint( const Point3d& ptP) const double BBox3d::SqDistFromPointXY( const Point3d& ptP) const { + if ( ! IsValid()) + return INFINITO ; double dSqDist = 0 ; if ( ptP.x < m_ptMin.x) dSqDist += ( m_ptMin.x - ptP.x) * ( m_ptMin.x - ptP.x) ; diff --git a/CurveArc.cpp b/CurveArc.cpp index 9a58309..08445d8 100644 --- a/CurveArc.cpp +++ b/CurveArc.cpp @@ -673,6 +673,15 @@ CurveArc::GetBBox( const Frame3d& frRef, BBox3d& b3Ref, int nFlag) const ptPos.ToGlob( frRef) ; b3Ref.Add( ptPos) ; } + // se c'è estrusione, devo tenerne conto + if ( ! m_VtExtr.IsSmall() && fabs( m_dThick) > EPS_SMALL) { + Vector3d vtFrExtr = m_VtExtr ; + vtFrExtr.ToGlob( frRef) ; + Point3d ptMinExtr = b3Ref.GetMin() + vtFrExtr * m_dThick ; + Point3d ptMaxExtr = b3Ref.GetMax() + vtFrExtr * m_dThick ; + b3Ref.Add( ptMinExtr) ; + b3Ref.Add( ptMaxExtr) ; + } return true ; } @@ -1327,7 +1336,7 @@ bool CurveArc::TrimStartAtLen( double dLenTrim) { // lunghezze negative vengono considerate nulle - dLenTrim = __max( dLenTrim, 0) ; + dLenTrim = max( dLenTrim, 0.) ; // verifico che sia abbastanza lunga double dLen ; @@ -1361,7 +1370,7 @@ bool CurveArc::TrimEndAtLen( double dLenTrim) { // lunghezze negative vengono considerate nulle - dLenTrim = __max( dLenTrim, 0) ; + dLenTrim = max( dLenTrim, 0.) ; // verifico che sia abbastanza lunga double dLen ; @@ -1850,7 +1859,7 @@ ArcApproxer::ArcApproxer( double dLinTol, double dAngTolDeg, bool bInside, const // dall'angolo al centro ricavo il numero di passi nStep = (int) ( fabs( arArc.GetAngCenter()) / dAngStepDeg + 0.999) ; - nStep = __max( nStep, 1) ; + nStep = max( nStep, 1) ; // sistemo lo step (per il numero intero di passi) dAngStepDeg = arArc.GetAngCenter() / nStep ; diff --git a/CurveArc.h b/CurveArc.h index e8ff0eb..5a850e2 100644 --- a/CurveArc.h +++ b/CurveArc.h @@ -96,6 +96,8 @@ class CurveArc : public ICurveArc, public IGeoObjRW virtual bool IsPointOn( const Point3d& ptP, double dTol = EPS_SMALL) const ; virtual bool GetParamAtPoint( const Point3d& ptP, double& dPar, double dTol = EPS_SMALL) const ; virtual bool GetLengthAtPoint( const Point3d& ptP, double& dLen, double dTol = EPS_SMALL) const ; + virtual bool GetAreaXY( double& dArea) const + { return CurveGetAreaXY( *this, dArea) ; } virtual bool ApproxWithLines( double dLinTol, double dAngTolDeg, PolyLine& PL) const ; virtual bool ApproxWithArcs( double dLinTol, double dAngTolDeg, PolyArc& PA) const ; virtual ICurve* CopyParamRange( double dUStart, double dUEnd) const ; diff --git a/CurveAux.cpp b/CurveAux.cpp index 280a924..e8e4319 100644 --- a/CurveAux.cpp +++ b/CurveAux.cpp @@ -226,6 +226,25 @@ GetPointDiffGeom( const ICurve& crvC, double dU, ICurve::Side nS, CrvPointDiffGe return true ; } +//---------------------------------------------------------------------------- +bool +CurveGetAreaXY( const ICurve& crvC, double& dArea) +{ + // verifico sia chiusa + if ( ! crvC.IsClosed()) + return false ; + // approssimo la curva con una polilinea + PolyLine PL ; + crvC.ApproxWithLines( LIN_TOL_STD, ANG_TOL_STD_DEG, PL) ; + // calcolo l'area + double dAreaXY = 0 ; + PL.GetAreaXY( dAreaXY) ; + // restituisco il valore + if ( &dArea != nullptr) + dArea = dAreaXY ; + return true ; +} + //---------------------------------------------------------------------------- bool CurveDump( const ICurve& crvC, string& sOut, const char* szNewLine) @@ -261,11 +280,8 @@ CurveDump( const ICurve& crvC, string& sOut, const char* szNewLine) crvC.GetLength( dLen) ; sOut += "Len=" + ToString( dLen,3) + szNewLine ; // altri dati per curva chiusa - if ( crvC.IsClosed()) { - PolyLine PL ; - crvC.ApproxWithLines( LIN_TOL_STD, ANG_TOL_STD_DEG, PL) ; - double dAreaXY = 0 ; - PL.GetAreaXY( dAreaXY) ; + double dAreaXY ; + if ( CurveGetAreaXY( crvC, dAreaXY)) { bool bCCW = ( dAreaXY > 0) ; sOut += string( "Closed") + ( bCCW ? " CCW" : " CW") + " AreaXY=" + ToString( fabs( dAreaXY),1) + szNewLine ; } diff --git a/CurveAux.h b/CurveAux.h index 974df6c..8666789 100644 --- a/CurveAux.h +++ b/CurveAux.h @@ -24,6 +24,7 @@ bool MoveParamToAvoidTg( double& dU, ICurve::Side nSide, const ICurve& Curve) ; bool GetTang( const ICurve& crvC, double dU, ICurve::Side nS, Vector3d& vtTang) ; bool GetPointTang( const ICurve& crvC, double dU, ICurve::Side nS, Point3d& ptPos, Vector3d& vtTang) ; bool GetPointDiffGeom( const ICurve& crvC, double dU, ICurve::Side nS, CrvPointDiffGeom& oDiffG) ; +bool CurveGetAreaXY( const ICurve& crvC, double& dArea) ; bool CurveDump( const ICurve& crvC, std::string& sOut, const char* szNewLine) ; bool CopyExtrusion( const ICurve* pSouCrv, ICurve* pDestCrv) ; bool CopyThickness( const ICurve* pSouCrv, ICurve* pDestCrv) ; diff --git a/CurveBezier.cpp b/CurveBezier.cpp index 763b497..78ba233 100644 --- a/CurveBezier.cpp +++ b/CurveBezier.cpp @@ -541,6 +541,15 @@ CurveBezier::GetBBox( const Frame3d& frRef, BBox3d& b3Ref, int nFlag) const b3Ref.Add( ptTemp) ; } } + // se c'è estrusione, devo tenerne conto + if ( ! m_VtExtr.IsSmall() && fabs( m_dThick) > EPS_SMALL) { + Vector3d vtFrExtr = m_VtExtr ; + vtFrExtr.ToGlob( frRef) ; + Point3d ptMinExtr = b3Ref.GetMin() + vtFrExtr * m_dThick ; + Point3d ptMaxExtr = b3Ref.GetMax() + vtFrExtr * m_dThick ; + b3Ref.Add( ptMinExtr) ; + b3Ref.Add( ptMaxExtr) ; + } return true ; } @@ -1743,7 +1752,7 @@ bool CurveBezier::TrimStartAtLen( double dLenTrim) { // lunghezze negative vengono considerate nulle - dLenTrim = __max( dLenTrim, 0) ; + dLenTrim = max( dLenTrim, 0.) ; // converto le lunghezze in valori parametrici double dUTrim ; @@ -1759,7 +1768,7 @@ bool CurveBezier::TrimEndAtLen( double dLenTrim) { // lunghezze negative vengono considerate nulle - dLenTrim = __max( dLenTrim, 0) ; + dLenTrim = max( dLenTrim, 0.) ; // converto le lunghezze in valori parametrici double dUTrim ; diff --git a/CurveBezier.h b/CurveBezier.h index 4296114..dc46242 100644 --- a/CurveBezier.h +++ b/CurveBezier.h @@ -97,6 +97,8 @@ class CurveBezier : public ICurveBezier, public IGeoObjRW virtual bool IsPointOn( const Point3d& ptP, double dTol = EPS_SMALL) const ; virtual bool GetParamAtPoint( const Point3d& ptP, double& dPar, double dTol = EPS_SMALL) const ; virtual bool GetLengthAtPoint( const Point3d& ptP, double& dLen, double dTol = EPS_SMALL) const ; + virtual bool GetAreaXY( double& dArea) const + { return CurveGetAreaXY( *this, dArea) ; } virtual bool ApproxWithLines( double dLinTol, double dAngTolDeg, PolyLine& PL) const ; virtual bool ApproxWithArcs( double dLinTol, double dAngTolDeg, PolyArc& PA) const ; virtual ICurve* CopyParamRange( double dUStart, double dUEnd) const ; diff --git a/CurveComposite.cpp b/CurveComposite.cpp index 770ad2c..c5f3d79 100644 --- a/CurveComposite.cpp +++ b/CurveComposite.cpp @@ -248,6 +248,27 @@ CurveComposite::AddSimpleCurve( ICurve* pSmplCrv, bool bEndOrStart, double dLinT return true ; } +//---------------------------------------------------------------------------- +bool +CurveComposite::Close( void) +{ + // verifico curva valida + if ( m_nStatus != OK) + return false ; + // se già chiusa, non faccio alcunché + if ( m_bClosed) + return true ; + // aggiungo la linea di chiusura + PtrOwner pLine( CreateBasicCurveLine()) ; + if ( ! pLine->Set( m_PtEnd, m_PtStart) || + ! AddSimpleCurve( Release( pLine))) + return false ; + // imposto ricalcolo della grafica + m_OGrMgr.Reset() ; + + return true ; +} + //---------------------------------------------------------------------------- bool CurveComposite::FromSplit( const ICurve& cCrv, int nParts) @@ -720,7 +741,7 @@ CurveComposite::GetBBox( const Frame3d& frRef, BBox3d& b3Ref, int nFlag) const return false ; // inizializzo il box b3Ref.Reset() ; - // ciclo sulle curve componenti + // ciclo sulle curve componenti (sempre senza estrusione) const ICurve* pCrvSmpl ; pCrvSmpl = GetFirstCurve() ; while ( pCrvSmpl != nullptr) { @@ -732,6 +753,15 @@ CurveComposite::GetBBox( const Frame3d& frRef, BBox3d& b3Ref, int nFlag) const // passo alla curva successiva pCrvSmpl = GetNextCurve() ; } + // se c'è estrusione, devo tenerne conto + if ( ! m_VtExtr.IsSmall() && fabs( m_dThick) > EPS_SMALL) { + Vector3d vtFrExtr = m_VtExtr ; + vtFrExtr.ToGlob( frRef) ; + Point3d ptMinExtr = b3Ref.GetMin() + vtFrExtr * m_dThick ; + Point3d ptMaxExtr = b3Ref.GetMax() + vtFrExtr * m_dThick ; + b3Ref.Add( ptMinExtr) ; + b3Ref.Add( ptMaxExtr) ; + } return true ; } diff --git a/CurveComposite.h b/CurveComposite.h index 89f84d6..ce4e03b 100644 --- a/CurveComposite.h +++ b/CurveComposite.h @@ -96,6 +96,8 @@ class CurveComposite : public ICurveComposite, public IGeoObjRW virtual bool IsPointOn( const Point3d& ptP, double dTol = EPS_SMALL) const ; virtual bool GetParamAtPoint( const Point3d& ptP, double& dPar, double dTol = EPS_SMALL) const ; virtual bool GetLengthAtPoint( const Point3d& ptP, double& dLen, double dTol = EPS_SMALL) const ; + virtual bool GetAreaXY( double& dArea) const + { return CurveGetAreaXY( *this, dArea) ; } virtual bool ApproxWithLines( double dLinTol, double dAngTolDeg, PolyLine& PL) const ; virtual bool ApproxWithArcs( double dLinTol, double dAngTolDeg, PolyArc& PA) const ; virtual ICurve* CopyParamRange( double dUStart, double dUEnd) const ; @@ -120,6 +122,7 @@ class CurveComposite : public ICurveComposite, public IGeoObjRW virtual bool Clear( void) ; virtual bool AddCurve( const ICurve& cCrv, bool bEndOrStart = true, double dLinTol = EPS_SMALL) ; virtual bool AddCurve( ICurve* pCrv, bool bEndOrStart = true, double dLinTol = EPS_SMALL) ; + virtual bool Close( void) ; virtual bool FromSplit( const ICurve& cCrv, int nParts) ; virtual bool FromPolyLine( const PolyLine& PL) ; virtual bool FromPolyArc( const PolyArc& PA) ; diff --git a/CurveLine.cpp b/CurveLine.cpp index d32e398..6ebff3d 100644 --- a/CurveLine.cpp +++ b/CurveLine.cpp @@ -230,6 +230,15 @@ CurveLine::GetBBox( const Frame3d& frRef, BBox3d& b3Ref, int nFlag) const ptFrEnd.ToGlob( frRef) ; // assegno il box nel riferimento b3Ref.Set( ptFrStart, ptFrEnd) ; + // se c'è estrusione, devo tenerne conto + if ( ! m_VtExtr.IsSmall() && fabs( m_dThick) > EPS_SMALL) { + Vector3d vtFrExtr = m_VtExtr ; + vtFrExtr.ToGlob( frRef) ; + Point3d ptMinExtr = b3Ref.GetMin() + vtFrExtr * m_dThick ; + Point3d ptMaxExtr = b3Ref.GetMax() + vtFrExtr * m_dThick ; + b3Ref.Add( ptMinExtr) ; + b3Ref.Add( ptMaxExtr) ; + } return true ; } @@ -663,7 +672,7 @@ bool CurveLine::TrimStartAtLen( double dLenTrim) { // lunghezze negative vengono considerate nulle - dLenTrim = __max( dLenTrim, 0) ; + dLenTrim = max( dLenTrim, 0.) ; // verifico che sia abbastanza lunga double dLen ; @@ -687,7 +696,7 @@ bool CurveLine::TrimEndAtLen( double dLenTrim) { // lunghezze negative vengono considerate nulle - dLenTrim = __max( dLenTrim, 0) ; + dLenTrim = max( dLenTrim, 0.) ; // verifico che sia abbastanza lunga double dLen ; diff --git a/CurveLine.h b/CurveLine.h index 5083a72..682ac26 100644 --- a/CurveLine.h +++ b/CurveLine.h @@ -97,6 +97,8 @@ class CurveLine : public ICurveLine, public IGeoObjRW virtual bool IsPointOn( const Point3d& ptP, double dTol = EPS_SMALL) const ; virtual bool GetParamAtPoint( const Point3d& ptP, double& dPar, double dTol = EPS_SMALL) const ; virtual bool GetLengthAtPoint( const Point3d& ptP, double& dLen, double dTol = EPS_SMALL) const ; + virtual bool GetAreaXY( double& dArea) const + { return false ; } virtual bool ApproxWithLines( double dLinTol, double dAngTolDeg, PolyLine& PL) const ; virtual bool ApproxWithArcs( double dLinTol, double dAngTolDeg, PolyArc& PA) const ; virtual ICurve* CopyParamRange( double dUStart, double dUEnd) const ; diff --git a/EgtGeomKernel.rc b/EgtGeomKernel.rc index 40572d3a5c56a94d0ee6ee6897ac658b92a45a2a..6564e65b57c0cf097d8cc4a875b241bb9509f177 100644 GIT binary patch delta 94 zcmdlNy)SyhFE&P_&A-_cnHh~HD{|{@_Trkr0u;H;XNwSVW8B;$>;>dw2zN+>g;Df- LFmBFL4&ed-Vf-5U delta 94 zcmdlNy)SyhFE&QQ&A-_cnHdcyD{|{@_Trkr0u;H;XNwSVW8B;$>;>dw2zN+>g;Df- LFmBFL4&ed-U|t&X diff --git a/EgtGeomKernel.vcxproj b/EgtGeomKernel.vcxproj index d93fc51..094097e 100644 --- a/EgtGeomKernel.vcxproj +++ b/EgtGeomKernel.vcxproj @@ -383,6 +383,7 @@ copy $(TargetPath) \EgtProg\Dll64 + diff --git a/EgtGeomKernel.vcxproj.filters b/EgtGeomKernel.vcxproj.filters index 88d5a18..d783e0c 100644 --- a/EgtGeomKernel.vcxproj.filters +++ b/EgtGeomKernel.vcxproj.filters @@ -641,6 +641,9 @@ File di intestazione\Include + + File di intestazione\Include + diff --git a/GdbGroup.cpp b/GdbGroup.cpp index 3c58d07..225b8b6 100644 --- a/GdbGroup.cpp +++ b/GdbGroup.cpp @@ -34,6 +34,28 @@ GdbGroup::~GdbGroup( void) { // elimino i figli Clear() ; + // se ha un sorgente + int nSou ; + if ( ! GetInfo( GDB_SI_SOURCE, nSou)) + return ; + GdbObj* pGdbObj ; + if ( m_pGDB == nullptr || ( pGdbObj = m_pGDB->GetGdbObj( nSou)) == nullptr) + return ; + // nel sorgente aggiorno lista dei riferimenti + INTVECTOR vnList ; + pGdbObj->GetInfo( GDB_SI_LIST, vnList) ; + INTVECTOR::const_iterator iFind = find( vnList.begin(), vnList.end(), m_nId) ; + if ( iFind != vnList.end()) + vnList.erase( iFind) ; + if ( vnList.empty()) + pGdbObj->RemoveInfo( GDB_SI_LIST) ; + else + pGdbObj->SetInfo( GDB_SI_LIST, vnList) ; + // nel sorgente aggiorno base + int nRef ; + pGdbObj->GetInfo( GDB_SI_BASE, nRef) ; + if ( nRef == m_nId) + pGdbObj->RemoveInfo( GDB_SI_BASE) ; } //---------------------------------------------------------------------------- diff --git a/GdbIterator.cpp b/GdbIterator.cpp index b5d7288..1b54c13 100644 --- a/GdbIterator.cpp +++ b/GdbIterator.cpp @@ -202,7 +202,6 @@ GdbIterator::EraseAndGoToNext( void) { if ( m_pGDB == nullptr || m_pCurrObj == nullptr) return false ; - // passo al successivo GdbObj* pObjToErase = m_pCurrObj ; m_pCurrObj = m_pCurrObj->GetNext() ; @@ -217,7 +216,6 @@ GdbIterator::EraseAndGoToPrev( void) { if ( m_pGDB == nullptr || m_pCurrObj == nullptr) return false ; - // passo al precedente GdbObj* pObjToErase = m_pCurrObj ; m_pCurrObj = m_pCurrObj->GetPrev() ; @@ -226,6 +224,422 @@ GdbIterator::EraseAndGoToPrev( void) return true ; } +//---------------------------------------------------------------------------- +bool +GdbIterator::GoToFirstNameInGroup( int nIdGroup, const string& sName) +{ + if ( m_pGDB == nullptr) { + m_pCurrObj = nullptr ; + return false ; + } + // recupero il gruppo + GdbGroup* pGdbGroup = m_pGDB->GetGdbGroup( nIdGroup) ; + if ( pGdbGroup == nullptr) { + m_pCurrObj = nullptr ; + return false ; + } + // recupero l'oggetto + m_pCurrObj = pGdbGroup->GetFirstObj() ; + while ( m_pCurrObj != nullptr) { + // se ha il nome cercato + string sObjName ; + if ( m_pCurrObj->GetName( sObjName) && sObjName == sName) + return true ; + // passo al successivo + m_pCurrObj = m_pCurrObj->GetNext() ; + } + // non trovato + return false ; +} + +//---------------------------------------------------------------------------- +bool +GdbIterator::GoToFirstNameInGroup( const IGdbIterator& iIter, const string& sName) +{ + if ( m_pGDB == nullptr) { + m_pCurrObj = nullptr ; + return false ; + } + // converto in oggetto iteratore di base + const GdbIterator* pIter = dynamic_cast (&iIter) ; + if ( pIter == nullptr || pIter->m_pGDB != m_pGDB) { + m_pCurrObj = nullptr ; + return false ; + } + // recupero il gruppo + GdbGroup* pGdbGroup = GetGdbGroup( pIter->m_pCurrObj) ; + if ( pGdbGroup == nullptr) { + m_pCurrObj = nullptr ; + return false ; + } + // recupero l'oggetto + m_pCurrObj = pGdbGroup->GetFirstObj() ; + while ( m_pCurrObj != nullptr) { + // se ha il nome cercato + string sObjName ; + if ( m_pCurrObj->GetName( sObjName) && sObjName == sName) + return true ; + // passo al successivo + m_pCurrObj = m_pCurrObj->GetNext() ; + } + // non trovato + return false ; +} + +//---------------------------------------------------------------------------- +bool +GdbIterator::GoToNextName( const string& sName) +{ + if ( m_pGDB == nullptr || m_pCurrObj == nullptr) + return false ; + // ciclo fino al prossimo gruppo + m_pCurrObj = m_pCurrObj->GetNext() ; + while ( m_pCurrObj != nullptr) { + // se ha il nome cercato + string sObjName ; + if ( m_pCurrObj->GetName( sObjName) && sObjName == sName) + return true ; + // passo al successivo + m_pCurrObj = m_pCurrObj->GetNext() ; + } + // non trovato + return false ; +} + +//---------------------------------------------------------------------------- +bool +GdbIterator::GoToLastNameInGroup( int nIdGroup, const string& sName) +{ + if ( m_pGDB == nullptr) { + m_pCurrObj = nullptr ; + return false ; + } + // recupero il gruppo + GdbGroup* pGdbGroup = m_pGDB->GetGdbGroup( nIdGroup) ; + if ( pGdbGroup == nullptr) { + m_pCurrObj = nullptr ; + return false ; + } + // recupero l'oggetto + m_pCurrObj = pGdbGroup->GetLastObj() ; + while ( m_pCurrObj != nullptr) { + // se ha il nome cercato + string sObjName ; + if ( m_pCurrObj->GetName( sObjName) && sObjName == sName) + return true ; + // passo al precedente + m_pCurrObj = m_pCurrObj->GetPrev() ; + } + // non trovato + return false ; +} + +//---------------------------------------------------------------------------- +bool +GdbIterator::GoToLastNameInGroup( const IGdbIterator& iIter, const string& sName) +{ + if ( m_pGDB == nullptr) { + m_pCurrObj = nullptr ; + return false ; + } + // converto in oggetto iteratore di base + const GdbIterator* pIter = dynamic_cast (&iIter) ; + if ( pIter == nullptr || pIter->m_pGDB != m_pGDB) { + m_pCurrObj = nullptr ; + return false ; + } + // recupero il gruppo + GdbGroup* pGdbGroup = GetGdbGroup( pIter->m_pCurrObj) ; + if ( pGdbGroup == nullptr) { + m_pCurrObj = nullptr ; + return false ; + } + // recupero l'oggetto + m_pCurrObj = pGdbGroup->GetLastObj() ; + while ( m_pCurrObj != nullptr) { + // se ha il nome cercato + string sObjName ; + if ( m_pCurrObj->GetName( sObjName) && sObjName == sName) + return true ; + // passo al precedente + m_pCurrObj = m_pCurrObj->GetPrev() ; + } + // non trovato + return false ; +} + +//---------------------------------------------------------------------------- +bool +GdbIterator::GoToPrevName( const string& sName) +{ + if ( m_pGDB == nullptr || m_pCurrObj == nullptr) + return false ; + // ciclo fino al precedente gruppo + m_pCurrObj = m_pCurrObj->GetPrev() ; + while ( m_pCurrObj != nullptr) { + // se ha il nome cercato + string sObjName ; + if ( m_pCurrObj->GetName( sObjName) && sObjName == sName) + return true ; + // passo al precedente + m_pCurrObj = m_pCurrObj->GetPrev() ; + } + // non trovato + return false ; +} + +//---------------------------------------------------------------------------- +bool +GdbIterator::EraseAndGoToNextName( const string& sName) +{ + if ( m_pGDB == nullptr || m_pCurrObj == nullptr) + return false ; + // passo al successivo + GdbObj* pObjToErase = m_pCurrObj ; + m_pCurrObj = m_pCurrObj->GetNext() ; + // eseguo cancellazione + m_pGDB->Erase( pObjToErase) ; + // se corrente non gruppo, passo al successivo gruppo + while ( m_pCurrObj != nullptr) { + // se ha il nome cercato + string sObjName ; + if ( m_pCurrObj->GetName( sObjName) && sObjName == sName) + return true ; + // passo al successivo + m_pCurrObj = m_pCurrObj->GetNext() ; + } + // non trovato + return false ; +} + +//---------------------------------------------------------------------------- +bool +GdbIterator::EraseAndGoToPrevName( const string& sName) +{ + if ( m_pGDB == nullptr || m_pCurrObj == nullptr) + return false ; + // passo al precedente + GdbObj* pObjToErase = m_pCurrObj ; + m_pCurrObj = m_pCurrObj->GetPrev() ; + // eseguo cancellazione + m_pGDB->Erase( pObjToErase) ; + // se corrente non gruppo, passo al precedente gruppo + while ( m_pCurrObj != nullptr) { + // se ha il nome cercato + string sObjName ; + if ( m_pCurrObj->GetName( sObjName) && sObjName == sName) + return true ; + // passo al precedente + m_pCurrObj = m_pCurrObj->GetPrev() ; + } + // non trovato + return false ; +} + +//---------------------------------------------------------------------------- +bool +GdbIterator::GoToFirstGroupInGroup( int nIdGroup) +{ + if ( m_pGDB == nullptr) { + m_pCurrObj = nullptr ; + return false ; + } + // recupero il gruppo + GdbGroup* pGdbGroup = m_pGDB->GetGdbGroup( nIdGroup) ; + if ( pGdbGroup == nullptr) { + m_pCurrObj = nullptr ; + return false ; + } + // recupero l'oggetto + m_pCurrObj = pGdbGroup->GetFirstObj() ; + while ( m_pCurrObj != nullptr) { + // se di tipo gruppo + if ( GetGdbGroup( m_pCurrObj) != nullptr) + return true ; + // passo al successivo + m_pCurrObj = m_pCurrObj->GetNext() ; + } + // non trovato + return false ; +} + +//---------------------------------------------------------------------------- +bool +GdbIterator::GoToFirstGroupInGroup( const IGdbIterator& iIter) +{ + if ( m_pGDB == nullptr) { + m_pCurrObj = nullptr ; + return false ; + } + // converto in oggetto iteratore di base + const GdbIterator* pIter = dynamic_cast (&iIter) ; + if ( pIter == nullptr || pIter->m_pGDB != m_pGDB) { + m_pCurrObj = nullptr ; + return false ; + } + // recupero il gruppo + GdbGroup* pGdbGroup = GetGdbGroup( pIter->m_pCurrObj) ; + if ( pGdbGroup == nullptr) { + m_pCurrObj = nullptr ; + return false ; + } + // recupero l'oggetto + m_pCurrObj = pGdbGroup->GetFirstObj() ; + while ( m_pCurrObj != nullptr) { + // se di tipo gruppo + if ( GetGdbGroup( m_pCurrObj) != nullptr) + return true ; + // passo al successivo + m_pCurrObj = m_pCurrObj->GetNext() ; + } + // non trovato + return false ; +} + +//---------------------------------------------------------------------------- +bool +GdbIterator::GoToNextGroup( void) +{ + if ( m_pGDB == nullptr || m_pCurrObj == nullptr) + return false ; + // ciclo fino al prossimo gruppo + m_pCurrObj = m_pCurrObj->GetNext() ; + while ( m_pCurrObj != nullptr) { + // se di tipo gruppo + if ( GetGdbGroup( m_pCurrObj) != nullptr) + return true ; + // passo al successivo + m_pCurrObj = m_pCurrObj->GetNext() ; + } + // non trovato + return false ; +} + +//---------------------------------------------------------------------------- +bool +GdbIterator::GoToLastGroupInGroup( int nIdGroup) +{ + if ( m_pGDB == nullptr) { + m_pCurrObj = nullptr ; + return false ; + } + // recupero il gruppo + GdbGroup* pGdbGroup = m_pGDB->GetGdbGroup( nIdGroup) ; + if ( pGdbGroup == nullptr) { + m_pCurrObj = nullptr ; + return false ; + } + // recupero l'oggetto + m_pCurrObj = pGdbGroup->GetLastObj() ; + while ( m_pCurrObj != nullptr) { + // se di tipo gruppo + if ( GetGdbGroup( m_pCurrObj) != nullptr) + return true ; + // passo al precedente + m_pCurrObj = m_pCurrObj->GetPrev() ; + } + // non trovato + return false ; +} + +//---------------------------------------------------------------------------- +bool +GdbIterator::GoToLastGroupInGroup( const IGdbIterator& iIter) +{ + if ( m_pGDB == nullptr) { + m_pCurrObj = nullptr ; + return false ; + } + // converto in oggetto iteratore di base + const GdbIterator* pIter = dynamic_cast (&iIter) ; + if ( pIter == nullptr || pIter->m_pGDB != m_pGDB) { + m_pCurrObj = nullptr ; + return false ; + } + // recupero il gruppo + GdbGroup* pGdbGroup = GetGdbGroup( pIter->m_pCurrObj) ; + if ( pGdbGroup == nullptr) { + m_pCurrObj = nullptr ; + return false ; + } + // recupero l'oggetto + m_pCurrObj = pGdbGroup->GetLastObj() ; + while ( m_pCurrObj != nullptr) { + // se di tipo gruppo + if ( GetGdbGroup( m_pCurrObj) != nullptr) + return true ; + // passo al precedente + m_pCurrObj = m_pCurrObj->GetPrev() ; + } + // non trovato + return false ; +} + +//---------------------------------------------------------------------------- +bool +GdbIterator::GoToPrevGroup( void) +{ + if ( m_pGDB == nullptr || m_pCurrObj == nullptr) + return false ; + // ciclo fino al precedente gruppo + m_pCurrObj = m_pCurrObj->GetPrev() ; + while ( m_pCurrObj != nullptr) { + // se di tipo gruppo + if ( GetGdbGroup( m_pCurrObj) != nullptr) + return true ; + // passo al precedente + m_pCurrObj = m_pCurrObj->GetPrev() ; + } + // non trovato + return false ; +} + +//---------------------------------------------------------------------------- +bool +GdbIterator::EraseAndGoToNextGroup( void) +{ + if ( m_pGDB == nullptr || m_pCurrObj == nullptr) + return false ; + // passo al successivo + GdbObj* pObjToErase = m_pCurrObj ; + m_pCurrObj = m_pCurrObj->GetNext() ; + // eseguo cancellazione + m_pGDB->Erase( pObjToErase) ; + // se corrente non gruppo, passo al successivo gruppo + while ( m_pCurrObj != nullptr) { + // se di tipo gruppo + if ( GetGdbGroup( m_pCurrObj) != nullptr) + return true ; + // passo al successivo + m_pCurrObj = m_pCurrObj->GetNext() ; + } + // non trovato + return false ; +} + +//---------------------------------------------------------------------------- +bool +GdbIterator::EraseAndGoToPrevGroup( void) +{ + if ( m_pGDB == nullptr || m_pCurrObj == nullptr) + return false ; + // passo al precedente + GdbObj* pObjToErase = m_pCurrObj ; + m_pCurrObj = m_pCurrObj->GetPrev() ; + // eseguo cancellazione + m_pGDB->Erase( pObjToErase) ; + // se corrente non gruppo, passo al precedente gruppo + while ( m_pCurrObj != nullptr) { + // se di tipo gruppo + if ( GetGdbGroup( m_pCurrObj) != nullptr) + return true ; + // passo al precedente + m_pCurrObj = m_pCurrObj->GetPrev() ; + } + // non trovato + return false ; +} + //---------------------------------------------------------------------------- int GdbIterator::GetGdbType( void) const diff --git a/GdbIterator.h b/GdbIterator.h index 5920336..3e92841 100644 --- a/GdbIterator.h +++ b/GdbIterator.h @@ -33,6 +33,22 @@ class GdbIterator : public IGdbIterator virtual bool GoToPrev( void) ; virtual bool EraseAndGoToNext( void) ; virtual bool EraseAndGoToPrev( void) ; + virtual bool GoToFirstNameInGroup( int nIdGroup, const std::string& sName) ; + virtual bool GoToFirstNameInGroup( const IGdbIterator& iIter, const std::string& sName) ; + virtual bool GoToNextName( const std::string& sName) ; + virtual bool GoToLastNameInGroup( int nIdGroup, const std::string& sName) ; + virtual bool GoToLastNameInGroup( const IGdbIterator& iIter, const std::string& sName) ; + virtual bool GoToPrevName( const std::string& sName) ; + virtual bool EraseAndGoToNextName( const std::string& sName) ; + virtual bool EraseAndGoToPrevName( const std::string& sName) ; + virtual bool GoToFirstGroupInGroup( int nIdGroup) ; + virtual bool GoToFirstGroupInGroup( const IGdbIterator& iIter) ; + virtual bool GoToNextGroup( void) ; + virtual bool GoToLastGroupInGroup( int nIdGroup) ; + virtual bool GoToLastGroupInGroup( const IGdbIterator& iIter) ; + virtual bool GoToPrevGroup( void) ; + virtual bool EraseAndGoToNextGroup( void) ; + virtual bool EraseAndGoToPrevGroup( void) ; virtual int GetGdbType( void) const ; virtual int GetGeoType( void) const ; diff --git a/GdbObj.cpp b/GdbObj.cpp index ed9fdd3..fe219d5 100644 --- a/GdbObj.cpp +++ b/GdbObj.cpp @@ -18,7 +18,7 @@ #include "GdbGroup.h" #include "Attribs.h" #include "/EgtDev/Include/EGkGdbFunct.h" -#include "/EgtDev/Include/EGnStringUtils.h" +#include "/EgtDev/Include/EGkStringUtils3d.h" #include using namespace std ; @@ -214,6 +214,42 @@ GdbObj::InsertBefore( GdbObj* pRef) return true ; } +/*-------------------------------------------------------------------------*/ +bool +GdbObj::Swap( GdbObj* pOther) +{ + // verifico esistenza dell'altro + if ( pOther == nullptr) + return false ; + // sistemazione degli eventuali padri + if ( m_pParent != nullptr) { + if ( m_pParent->m_pFirstObj == this) + m_pParent->m_pFirstObj = pOther ; + if ( m_pParent->m_pLastObj == this) + m_pParent->m_pLastObj = pOther ; + } + if ( pOther->m_pParent != nullptr) { + if ( pOther->m_pParent->m_pFirstObj == pOther) + pOther->m_pParent->m_pFirstObj = this ; + if ( pOther->m_pParent->m_pLastObj == pOther) + pOther->m_pParent->m_pLastObj = this ; + } + swap( m_pParent, pOther->m_pParent) ; + // sistemazione dei precedenti + if ( m_pPrev != nullptr) + m_pPrev->m_pNext = pOther ; + if ( pOther->m_pPrev != nullptr) + pOther->m_pPrev->m_pNext = this ; + swap( m_pPrev, pOther->m_pPrev) ; + // sistemazione dei successivi + if ( m_pNext != nullptr) + m_pNext->m_pPrev = pOther ; + if ( pOther->m_pNext != nullptr) + pOther->m_pNext->m_pPrev = this ; + swap( m_pNext, pOther->m_pNext) ; + return true ; +} + /*-------------------------------------------------------------------------*/ bool GdbObj::Remove( void) @@ -682,7 +718,6 @@ GdbObj::SetName( const string& sName) // verifico esistenza (con eventuale creazione) degli attributi if ( GetSafeAttribs() == nullptr) return false ; - // assegno il nome return m_pAttribs->SetName( sName) ; } @@ -694,7 +729,6 @@ GdbObj::GetName( string& sName) const // se non ci sono attributi if ( m_pAttribs == nullptr) return false ; - // restituisco il nome return m_pAttribs->GetName( sName) ; } @@ -706,7 +740,6 @@ GdbObj::ExistsName( void) const // se non ci sono attributi if ( m_pAttribs == nullptr) return false ; - // restituisco il nome return m_pAttribs->ExistsName() ; } @@ -717,8 +750,7 @@ GdbObj::RemoveName( void) { // se non ci sono attributi if ( m_pAttribs == nullptr) - return false ; - + return true ; // cancello il nome return m_pAttribs->RemoveName() ; } @@ -730,11 +762,73 @@ GdbObj::SetInfo( const string& sKey, const string& sInfo) // verifico esistenza (con eventuale creazione) degli attributi if ( GetSafeAttribs() == nullptr) return false ; - // assegno l'Info return m_pAttribs->SetInfo( sKey, sInfo) ; } +//---------------------------------------------------------------------------- +bool +GdbObj::SetInfo( const string& sKey, bool bInfo) +{ + return SetInfo( sKey, ToString( bInfo)) ; +} + +//---------------------------------------------------------------------------- +bool +GdbObj::SetInfo( const string& sKey, int nInfo) +{ + return SetInfo( sKey, ToString( nInfo)) ; +} + +//---------------------------------------------------------------------------- +bool +GdbObj::SetInfo( const string& sKey, double dInfo) +{ + return SetInfo( sKey, ToString( dInfo)) ; +} + +//---------------------------------------------------------------------------- +bool +GdbObj::SetInfo( const string& sKey, const Vector3d& vtInfo) +{ + return SetInfo( sKey, ToString( vtInfo)) ; +} + +//---------------------------------------------------------------------------- +bool +GdbObj::SetInfo( const string& sKey, const Point3d& ptInfo) +{ + return SetInfo( sKey, ToString( ptInfo)) ; +} + +//---------------------------------------------------------------------------- +bool +GdbObj::SetInfo( const string& sKey, const BBox3d& b3Info) +{ + return SetInfo( sKey, ToString( b3Info)) ; +} + +//---------------------------------------------------------------------------- +bool +GdbObj::SetInfo( const string& sKey, const Frame3d& frInfo) +{ + return SetInfo( sKey, ToString( frInfo)) ; +} + +//---------------------------------------------------------------------------- +bool +GdbObj::SetInfo( const string& sKey, const INTVECTOR& vnInfo) +{ + return SetInfo( sKey, ToString( vnInfo)) ; +} + +//---------------------------------------------------------------------------- +bool +GdbObj::SetInfo( const string& sKey, const DBLVECTOR& vdInfo) +{ + return SetInfo( sKey, ToString( vdInfo)) ; +} + //---------------------------------------------------------------------------- bool GdbObj::GetInfo( const string& sKey, string& sInfo) const @@ -742,11 +836,84 @@ GdbObj::GetInfo( const string& sKey, string& sInfo) const // se non ci sono attributi if ( m_pAttribs == nullptr) return false ; - // restituisco l'Info return m_pAttribs->GetInfo( sKey, sInfo) ; } +//---------------------------------------------------------------------------- +bool +GdbObj::GetInfo( const string& sKey, bool& bInfo) const +{ + string sInfo ; + return ( GetInfo( sKey, sInfo) && FromString( sInfo, bInfo)) ; +} + +//---------------------------------------------------------------------------- +bool +GdbObj::GetInfo( const string& sKey, int& nInfo) const +{ + string sInfo ; + return ( GetInfo( sKey, sInfo) && FromString( sInfo, nInfo)) ; +} + +//---------------------------------------------------------------------------- +bool +GdbObj::GetInfo( const string& sKey, double& dInfo) const +{ + string sInfo ; + return ( GetInfo( sKey, sInfo) && FromString( sInfo, dInfo)) ; +} + +//---------------------------------------------------------------------------- +bool +GdbObj::GetInfo( const string& sKey, Vector3d& vtInfo) const +{ + string sInfo ; + return ( GetInfo( sKey, sInfo) && FromString( sInfo, vtInfo)) ; +} + +//---------------------------------------------------------------------------- +bool +GdbObj::GetInfo( const string& sKey, Point3d& ptInfo) const +{ + string sInfo ; + return ( GetInfo( sKey, sInfo) && FromString( sInfo, ptInfo)) ; +} + +//---------------------------------------------------------------------------- +bool +GdbObj::GetInfo( const string& sKey, BBox3d& b3Info) const +{ + string sInfo ; + return ( GetInfo( sKey, sInfo) && FromString( sInfo, b3Info)) ; +} + +//---------------------------------------------------------------------------- +bool +GdbObj::GetInfo( const string& sKey, Frame3d& frInfo) const +{ + string sInfo ; + return ( GetInfo( sKey, sInfo) && FromString( sInfo, frInfo)) ; +} + +//---------------------------------------------------------------------------- +bool +GdbObj::GetInfo( const string& sKey, INTVECTOR& vnInfo) const +{ + vnInfo.clear() ; + string sInfo ; + return ( GetInfo( sKey, sInfo) && FromString( sInfo, vnInfo)) ; +} + +//---------------------------------------------------------------------------- +bool +GdbObj::GetInfo( const string& sKey, DBLVECTOR& vdInfo) const +{ + vdInfo.clear() ; + string sInfo ; + return ( GetInfo( sKey, sInfo) && FromString( sInfo, vdInfo)) ; +} + //---------------------------------------------------------------------------- bool GdbObj::ExistsInfo( const string& sKey) const @@ -754,7 +921,6 @@ GdbObj::ExistsInfo( const string& sKey) const // se non ci sono attributi if ( m_pAttribs == nullptr) return false ; - // verifico l'esistenza dell'Info return m_pAttribs->ExistsInfo( sKey) ; } @@ -765,8 +931,7 @@ GdbObj::RemoveInfo( const string& sKey) { // se non ci sono attributi if ( m_pAttribs == nullptr) - return false ; - + return true ; // cancello l'Info return m_pAttribs->RemoveInfo( sKey) ; } diff --git a/GdbObj.h b/GdbObj.h index 96ffe1b..53e3eb8 100644 --- a/GdbObj.h +++ b/GdbObj.h @@ -16,6 +16,7 @@ #include "/EgtDev/Include/EGkGdbConst.h" #include "/EgtDev/Include/EGkColor.h" #include "/EgtDev/Include/EGkBBox3d.h" +#include "/EgtDev/Include/EgtNumCollection.h" #include class GeomDB ; @@ -87,7 +88,25 @@ class GdbObj bool ExistsName( void) const ; bool RemoveName( void) ; bool SetInfo( const std::string& sKey, const std::string& sInfo) ; + bool SetInfo( const std::string& sKey, bool bInfo) ; + bool SetInfo( const std::string& sKey, int nInfo) ; + bool SetInfo( const std::string& sKey, double dInfo) ; + bool SetInfo( const std::string& sKey, const Vector3d& vtInfo) ; + bool SetInfo( const std::string& sKey, const Point3d& ptInfo) ; + bool SetInfo( const std::string& sKey, const BBox3d& b3Info) ; + bool SetInfo( const std::string& sKey, const Frame3d& frInfo) ; + bool SetInfo( const std::string& sKey, const INTVECTOR& vnInfo) ; + bool SetInfo( const std::string& sKey, const DBLVECTOR& vdInfo) ; bool GetInfo( const std::string& sKey, std::string& sInfo) const ; + bool GetInfo( const std::string& sKey, bool& bInfo) const ; + bool GetInfo( const std::string& sKey, int& nInfo) const ; + bool GetInfo( const std::string& sKey, double& dInfo) const ; + bool GetInfo( const std::string& sKey, Vector3d& vtInfo) const ; + bool GetInfo( const std::string& sKey, Point3d& ptInfo) const ; + bool GetInfo( const std::string& sKey, BBox3d& b3Info) const ; + bool GetInfo( const std::string& sKey, Frame3d& frInfo) const ; + bool GetInfo( const std::string& sKey, INTVECTOR& vnInfo) const ; + bool GetInfo( const std::string& sKey, DBLVECTOR& vdInfo) const ; bool ExistsInfo( const std::string& sKey) const ; bool RemoveInfo( const std::string& sKey) ; @@ -111,6 +130,7 @@ class GdbObj bool AddHead( GdbGroup* pParent) ; bool InsertAfter( GdbObj* pRef) ; bool InsertBefore( GdbObj* pRef) ; + bool Swap( GdbObj* pOther) ; bool Remove( void) ; public : diff --git a/GeomDB.cpp b/GeomDB.cpp index e126808..97200f8 100644 --- a/GeomDB.cpp +++ b/GeomDB.cpp @@ -518,13 +518,12 @@ GeomDB::InsertGeoObj( int nId, int nRefId, int nSonBeforeAfter, IGeoObj* pGeoObj //---------------------------------------------------------------------------- int -GeomDB::GetFirstInGroup( int nIdGroup) const +GeomDB::GetFirstInGroup( int nGroupId) const { // recupero il gruppo - const GdbGroup* pGdbGroup = GetGdbGroup( nIdGroup) ; + const GdbGroup* pGdbGroup = GetGdbGroup( nGroupId) ; if ( pGdbGroup == nullptr) return GDB_ID_NULL ; - // recupero il primo oggetto del gruppo const GdbObj* pGdbO = pGdbGroup->GetFirstObj() ; if ( pGdbO == nullptr) @@ -551,13 +550,12 @@ GeomDB::GetNext( int nId) const //---------------------------------------------------------------------------- int -GeomDB::GetLastInGroup( int nIdGroup) const +GeomDB::GetLastInGroup( int nGroupId) const { // recupero il gruppo - const GdbGroup* pGdbGroup = GetGdbGroup( nIdGroup) ; + const GdbGroup* pGdbGroup = GetGdbGroup( nGroupId) ; if ( pGdbGroup == nullptr) return GDB_ID_NULL ; - // recupero l'ultimo oggetto del gruppo const GdbObj* pGdbO = pGdbGroup->GetLastObj() ; if ( pGdbO == nullptr) @@ -584,16 +582,104 @@ GeomDB::GetPrev( int nId) const //---------------------------------------------------------------------------- int -GeomDB::GetFirstGroupInGroup( int nIdGroup) const +GeomDB::GetFirstNameInGroup( int nGroupId, const string& sName) const { + // recupero il gruppo + const GdbGroup* pGdbGroup = GetGdbGroup( nGroupId) ; + if ( pGdbGroup == nullptr) + return GDB_ID_NULL ; // recupero il primo oggetto del gruppo - int nIdFirst = GetFirstInGroup( nIdGroup) ; - while ( nIdFirst != GDB_ID_NULL) { - // se di tipo gruppo - if ( GetGdbType( nIdFirst) == GDB_TY_GROUP) - return nIdFirst ; + const GdbObj* pGdbO = pGdbGroup->GetFirstObj() ; + while ( pGdbO != nullptr) { + // se ha il nome cercato + string sObjName ; + if ( pGdbO->GetName( sObjName) && sObjName == sName) + return ( pGdbO->m_nId) ; // passo al successivo - nIdFirst = GetNext( nIdFirst) ; + pGdbO = pGdbO->GetNext() ; + } + return GDB_ID_NULL ; +} + +//---------------------------------------------------------------------------- +int +GeomDB::GetNextName( int nId, const string& sName) const +{ + // recupero l'oggetto + const GdbObj* pGdbObj = GetGdbObj( nId) ; + if ( pGdbObj == nullptr) + return GDB_ID_NULL ; + // recupero il successivo + const GdbObj* pGdbNext = pGdbObj->GetNext() ; + while ( pGdbNext != nullptr) { + // se ha il nome cercato + string sObjName ; + if ( pGdbNext->GetName( sObjName) && sObjName == sName) + return ( pGdbNext->m_nId) ; + // passo al successivo + pGdbNext = pGdbNext->GetNext() ; + } + return GDB_ID_NULL ; +} + +//---------------------------------------------------------------------------- +int +GeomDB::GetLastNameInGroup( int nGroupId, const string& sName) const +{ + // recupero il gruppo + const GdbGroup* pGdbGroup = GetGdbGroup( nGroupId) ; + if ( pGdbGroup == nullptr) + return GDB_ID_NULL ; + // recupero l'ultimo oggetto del gruppo + const GdbObj* pGdbO = pGdbGroup->GetLastObj() ; + while ( pGdbO != nullptr) { + // se ha il nome cercato + string sObjName ; + if ( pGdbO->GetName( sObjName) && sObjName == sName) + return ( pGdbO->m_nId) ; + // passo al precedente + pGdbO = pGdbO->GetPrev() ; + } + return GDB_ID_NULL ; +} + +//---------------------------------------------------------------------------- +int +GeomDB::GetPrevName( int nId, const string& sName) const +{ + // recupero l'oggetto + const GdbObj* pGdbObj = GetGdbObj( nId) ; + if ( pGdbObj == nullptr) + return GDB_ID_NULL ; + // recupero il precedente + const GdbObj* pGdbPrev = pGdbObj->GetPrev() ; + while ( pGdbPrev != nullptr) { + // se ha il nome cercato + string sObjName ; + if ( pGdbPrev->GetName( sObjName) && sObjName == sName) + return ( pGdbPrev->m_nId) ; + // passo al precedente + pGdbPrev = pGdbPrev->GetPrev() ; + } + return GDB_ID_NULL ; +} + +//---------------------------------------------------------------------------- +int +GeomDB::GetFirstGroupInGroup( int nGroupId) const +{ + // recupero il gruppo + const GdbGroup* pGdbGroup = GetGdbGroup( nGroupId) ; + if ( pGdbGroup == nullptr) + return GDB_ID_NULL ; + // recupero il primo oggetto del gruppo + const GdbObj* pGdbO = pGdbGroup->GetFirstObj() ; + while ( pGdbO != nullptr) { + // se di tipo gruppo + if ( ::GetGdbGroup( pGdbO) != nullptr) + return ( pGdbO->m_nId) ; + // passo al successivo + pGdbO = pGdbO->GetNext() ; } return GDB_ID_NULL ; } @@ -602,30 +688,38 @@ GeomDB::GetFirstGroupInGroup( int nIdGroup) const int GeomDB::GetNextGroup( int nId) const { - // recupero il prossimo oggetto - int nIdNext = GetNext( nId) ; - while ( nIdNext != GDB_ID_NULL) { + // recupero l'oggetto + const GdbObj* pGdbObj = GetGdbObj( nId) ; + if ( pGdbObj == nullptr) + return GDB_ID_NULL ; + // recupero il successivo + const GdbObj* pGdbNext = pGdbObj->GetNext() ; + while ( pGdbNext != nullptr) { // se di tipo gruppo - if ( GetGdbType( nIdNext) == GDB_TY_GROUP) - return nIdNext ; + if ( ::GetGdbGroup( pGdbNext) != nullptr) + return ( pGdbNext->m_nId) ; // passo al successivo - nIdNext = GetNext( nIdNext) ; + pGdbNext = pGdbNext->GetNext() ; } return GDB_ID_NULL ; } //---------------------------------------------------------------------------- int -GeomDB::GetLastGroupInGroup( int nIdGroup) const +GeomDB::GetLastGroupInGroup( int nGroupId) const { + // recupero il gruppo + const GdbGroup* pGdbGroup = GetGdbGroup( nGroupId) ; + if ( pGdbGroup == nullptr) + return GDB_ID_NULL ; // recupero l'ultimo oggetto del gruppo - int nIdLast = GetLastInGroup( nIdGroup) ; - while ( nIdLast != GDB_ID_NULL) { + const GdbObj* pGdbO = pGdbGroup->GetLastObj() ; + while ( pGdbO != nullptr) { // se di tipo gruppo - if ( GetGdbType( nIdLast) == GDB_TY_GROUP) - return nIdLast ; - // passo al successivo - nIdLast = GetPrev( nIdLast) ; + if ( ::GetGdbGroup( pGdbO) != nullptr) + return ( pGdbO->m_nId) ; + // passo al precedente + pGdbO = pGdbO->GetPrev() ; } return GDB_ID_NULL ; } @@ -634,14 +728,18 @@ GeomDB::GetLastGroupInGroup( int nIdGroup) const int GeomDB::GetPrevGroup( int nId) const { - // recupero il precedente oggetto - int nIdPrev = GetPrev( nId) ; - while ( nIdPrev != GDB_ID_NULL) { + // recupero l'oggetto + const GdbObj* pGdbObj = GetGdbObj( nId) ; + if ( pGdbObj == nullptr) + return GDB_ID_NULL ; + // recupero il precedente + const GdbObj* pGdbPrev = pGdbObj->GetPrev() ; + while ( pGdbPrev != nullptr) { // se di tipo gruppo - if ( GetGdbType( nIdPrev) == GDB_TY_GROUP) - return nIdPrev ; - // passo al successivo - nIdPrev = GetPrev( nIdPrev) ; + if ( ::GetGdbGroup( pGdbPrev) != nullptr) + return ( pGdbPrev->m_nId) ; + // passo al precedente + pGdbPrev = pGdbPrev->GetPrev() ; } return GDB_ID_NULL ; } @@ -949,8 +1047,60 @@ GeomDB::Relocate( int nId, int nRefId, int nSonBeforeAfter, bool bGlob) return false ; } - // notifico che può essere cambiato il materiale - pGdbObj->OnSetMaterial() ; + // se il materiale è ereditato, notifico che può essere cambiato + int nMat ; + if ( ! pGdbObj->GetMaterial( nMat) || nMat == GDB_MT_PARENT) + pGdbObj->OnSetMaterial() ; + + return true ; +} + +//---------------------------------------------------------------------------- +bool +GeomDB::GroupSwap( int nId1, int nId2, bool bSwapRef, bool bMark) +{ + // se i due oggetti coincidono non devo fare alcunchè + if ( nId1 == nId2) + return true ; + // verifico esistenza dei due gruppi + GdbGroup* pGdbGrp1 = GetGdbGroup( nId1) ; + GdbGroup* pGdbGrp2 = GetGdbGroup( nId2) ; + if ( pGdbGrp1 == nullptr || pGdbGrp2 == nullptr) + return false ; + // annullo eventuali iteratori che riferiscono questi oggetti + m_IterManager.ResetObjIfSame( pGdbGrp1) ; + m_IterManager.ResetObjIfSame( pGdbGrp2) ; + // scambio gli oggetti + pGdbGrp1->Swap( pGdbGrp2) ; + // sistemazioni per materiali ereditati + int nMat ; + if ( ! pGdbGrp1->GetMaterial( nMat) || nMat == GDB_MT_PARENT) + pGdbGrp1->OnSetMaterial() ; + if ( ! pGdbGrp2->GetMaterial( nMat) || nMat == GDB_MT_PARENT) + pGdbGrp2->OnSetMaterial() ; + // se richiesto, scambio i riferimenti + if ( bSwapRef) + swap( pGdbGrp1->GetFrame(), pGdbGrp2->GetFrame()) ; + // se richiesto contrassegno + if ( bMark) { + // sorgente : aggiorno la base e la lista (devo tornare alla stessa base) + pGdbGrp1->RemoveInfo( GDB_SI_SOURCE) ; + int nRef ; + if ( ! pGdbGrp1->GetInfo( GDB_SI_BASE, nRef)) + pGdbGrp1->SetInfo( GDB_SI_BASE, nId2) ; + else if ( nRef == nId2) + pGdbGrp1->RemoveInfo( GDB_SI_BASE) ; + INTVECTOR vnRef ; + pGdbGrp1->GetInfo( GDB_SI_LIST, vnRef) ; + if ( find( vnRef.begin(), vnRef.end(), nId2) == vnRef.end()) { + vnRef.push_back( nId2) ; + pGdbGrp1->SetInfo( GDB_SI_LIST, vnRef) ; + } + // altro : aggiorno il sorgente + pGdbGrp2->RemoveInfo( GDB_SI_BASE) ; + pGdbGrp2->RemoveInfo( GDB_SI_LIST) ; + pGdbGrp2->SetInfo( GDB_SI_SOURCE, nId1) ; + } return true ; } @@ -2183,7 +2333,6 @@ GeomDB::SetInfo( int nId, const string& sKey, const string& sInfo) GdbObj* pGdbObj = GetGdbObj( nId) ; if ( pGdbObj == nullptr) return false ; - // assegno l'Info return pGdbObj->SetInfo( sKey, sInfo) ; } @@ -2223,6 +2372,13 @@ GeomDB::SetInfo( int nId, const string& sKey, const Vector3d& vtInfo) return SetInfo( nId, sKey, ToString( vtInfo)) ; } +//---------------------------------------------------------------------------- +bool +GeomDB::SetInfo( int nId, const string& sKey, const BBox3d& b3Info) +{ + return SetInfo( nId, sKey, ToString( b3Info)) ; +} + //---------------------------------------------------------------------------- bool GeomDB::SetInfo( int nId, const string& sKey, const Frame3d& frInfo) @@ -2230,6 +2386,20 @@ GeomDB::SetInfo( int nId, const string& sKey, const Frame3d& frInfo) return SetInfo( nId, sKey, ToString( frInfo)) ; } +//---------------------------------------------------------------------------- +bool +GeomDB::SetInfo( int nId, const string& sKey, const INTVECTOR& vnInfo) +{ + return SetInfo( nId, sKey, ToString( vnInfo)) ; +} + +//---------------------------------------------------------------------------- +bool +GeomDB::SetInfo( int nId, const string& sKey, const DBLVECTOR& vdInfo) +{ + return SetInfo( nId, sKey, ToString( vdInfo)) ; +} + //---------------------------------------------------------------------------- bool GeomDB::GetInfo( int nId, const string& sKey, string& sInfo) const @@ -2238,7 +2408,6 @@ GeomDB::GetInfo( int nId, const string& sKey, string& sInfo) const const GdbObj* pGdbObj = GetGdbObj( nId) ; if ( pGdbObj == nullptr) return false ; - // recupero l'Info return pGdbObj->GetInfo( sKey, sInfo) ; } @@ -2283,6 +2452,14 @@ GeomDB::GetInfo( int nId, const string& sKey, Vector3d& vtInfo) const return ( GetInfo( nId, sKey, sInfo) && FromString( sInfo, vtInfo)) ; } +//---------------------------------------------------------------------------- +bool +GeomDB::GetInfo( int nId, const string& sKey, BBox3d& b3Info) const +{ + string sInfo ; + return ( GetInfo( nId, sKey, sInfo) && FromString( sInfo, b3Info)) ; +} + //---------------------------------------------------------------------------- bool GeomDB::GetInfo( int nId, const string& sKey, Frame3d& frInfo) const @@ -2291,6 +2468,22 @@ GeomDB::GetInfo( int nId, const string& sKey, Frame3d& frInfo) const return ( GetInfo( nId, sKey, sInfo) && FromString( sInfo, frInfo)) ; } +//---------------------------------------------------------------------------- +bool +GeomDB::GetInfo( int nId, const string& sKey, INTVECTOR& vnInfo) const +{ + string sInfo ; + return ( GetInfo( nId, sKey, sInfo) && FromString( sInfo, vnInfo)) ; +} + +//---------------------------------------------------------------------------- +bool +GeomDB::GetInfo( int nId, const string& sKey, DBLVECTOR& vdInfo) const +{ + string sInfo ; + return ( GetInfo( nId, sKey, sInfo) && FromString( sInfo, vdInfo)) ; +} + //---------------------------------------------------------------------------- bool GeomDB::ExistsInfo( int nId, const string& sKey) const diff --git a/GeomDB.h b/GeomDB.h index 9a6e689..f40968f 100644 --- a/GeomDB.h +++ b/GeomDB.h @@ -41,13 +41,17 @@ class GeomDB : public IGeomDB virtual int InsertGroup( int nId, int nRefId, int nSonBeforeAfter, const Frame3d& frFrame) ; virtual int AddGeoObj( int nId, int nParentId, IGeoObj* pGeoObj) ; virtual int InsertGeoObj( int nId, int nRefId, int nSonBeforeAfter, IGeoObj* pGeoObj) ; - virtual int GetFirstInGroup( int nIdGroup) const ; + virtual int GetFirstInGroup( int nGroupId) const ; virtual int GetNext( int nId) const ; - virtual int GetLastInGroup( int nIdGroup) const ; + virtual int GetLastInGroup( int nGroupId) const ; virtual int GetPrev( int nId) const ; - virtual int GetFirstGroupInGroup( int nIdGroup) const ; + virtual int GetFirstNameInGroup( int nGroupId, const std::string& sName) const ; + virtual int GetNextName( int nId, const std::string& sName) const ; + virtual int GetLastNameInGroup( int nGroupId, const std::string& sName) const ; + virtual int GetPrevName( int nId, const std::string& sName) const ; + virtual int GetFirstGroupInGroup( int nGroupId) const ; virtual int GetNextGroup( int nId) const ; - virtual int GetLastGroupInGroup( int nIdGroup) const ; + virtual int GetLastGroupInGroup( int nGroupId) const ; virtual int GetPrevGroup( int nId) const ; virtual int GetGdbType( int nId) const ; virtual int GetGeoType( int nId) const ; @@ -72,6 +76,7 @@ class GeomDB : public IGeomDB { return Relocate( nId, nRefId, nSonBeforeAfter, false) ; } virtual bool RelocateGlob( int nId, int nRefId, int nSonBeforeAfter = GDB_LAST_SON) { return Relocate( nId, nRefId, nSonBeforeAfter, true) ; } + virtual bool GroupSwap( int nId1, int nId2, bool bSwapRef, bool bMark = false) ; virtual bool ChangeId( int nId, int nNewId) ; virtual bool Erase( int nId) ; virtual bool EmptyGroup( int nId) ; @@ -151,14 +156,20 @@ class GeomDB : public IGeomDB virtual bool SetInfo( int nId, const std::string& sKey, double dInfo) ; virtual bool SetInfo( int nId, const std::string& sKey, const Point3d& ptInfo) ; virtual bool SetInfo( int nId, const std::string& sKey, const Vector3d& vtInfo) ; + virtual bool SetInfo( int nId, const std::string& sKey, const BBox3d& b3Info) ; virtual bool SetInfo( int nId, const std::string& sKey, const Frame3d& frInfo) ; + virtual bool SetInfo( int nId, const std::string& sKey, const INTVECTOR& vnInfo) ; + virtual bool SetInfo( int nId, const std::string& sKey, const DBLVECTOR& vdInfo) ; virtual bool GetInfo( int nId, const std::string& sKey, std::string& sInfo) const ; virtual bool GetInfo( int nId, const std::string& sKey, bool& bInfo) const ; virtual bool GetInfo( int nId, const std::string& sKey, int& nInfo) const ; virtual bool GetInfo( int nId, const std::string& sKey, double& dInfo) const ; virtual bool GetInfo( int nId, const std::string& sKey, Point3d& ptInfo) const ; virtual bool GetInfo( int nId, const std::string& sKey, Vector3d& vtInfo) const ; + virtual bool GetInfo( int nId, const std::string& sKey, BBox3d& b3Info) const ; virtual bool GetInfo( int nId, const std::string& sKey, Frame3d& frInfo) const ; + virtual bool GetInfo( int nId, const std::string& sKey, INTVECTOR& vnInfo) const ; + virtual bool GetInfo( int nId, const std::string& sKey, DBLVECTOR& vdInfo) const ; virtual bool ExistsInfo( int nId, const std::string& sKey) const ; virtual bool RemoveInfo( int nId, const std::string& sKey) ; // Material library diff --git a/OutTsc.cpp b/OutTsc.cpp index 69e1b70..efd280c 100644 --- a/OutTsc.cpp +++ b/OutTsc.cpp @@ -406,7 +406,7 @@ OutTsc::NormalOrNone( const CrvPointDiffGeom& oDiffG) // normale if ( oDiffG.nStatus == CrvPointDiffGeom::NCRV && fabs( oDiffG.dCurv) > EPS_ZERO) { - double dLen = __min( NORM_LEN, 1 / oDiffG.dCurv) ; + double dLen = min( NORM_LEN, 1 / oDiffG.dCurv) ; Line2P( oDiffG.ptP - NORM_LEN * oDiffG.vtN, oDiffG.ptP + dLen * oDiffG.vtN) ; } // segmento perpendicolare alla tangente diff --git a/StringUtils3d.cpp b/StringUtils3d.cpp index bf6dca5..4f9d763 100644 --- a/StringUtils3d.cpp +++ b/StringUtils3d.cpp @@ -31,6 +31,19 @@ FromString( const string& sVal, Point3d& ptVal, double& dW) return true ; } +//---------------------------------------------------------------------------- +bool +FromString( const string& sVal, BBox3d& b3Box) +{ + // devono essere 6 parametri : MinX, MinY, MinZ, MaxX, MaxY, MaxZ + double vdVal[6] ; + if ( ! FromString( sVal, vdVal)) + return false ; + // imposto il box + b3Box.Set( vdVal[0], vdVal[1], vdVal[2], vdVal[3], vdVal[4], vdVal[5]) ; + return true ; +} + //---------------------------------------------------------------------------- bool FromString( const string& sVal, Frame3d& frFrame)