diff --git a/CurveComposite.cpp b/CurveComposite.cpp index 625909e..8881ee7 100644 --- a/CurveComposite.cpp +++ b/CurveComposite.cpp @@ -383,13 +383,13 @@ CurveComposite::FromPolyArc( const PolyArc& PA) //---------------------------------------------------------------------------- bool -CurveComposite::PolygonCenterCorner( int nSides, const Point3d& ptCen, const Point3d& ptCorner) +CurveComposite::PolygonCenterCorner( int nSides, const Point3d& ptCen, const Point3d& ptCorner, const Vector3d& vtN) { // verifico lo stato if ( m_nCounter != 0 || m_nStatus != TO_VERIFY) return false ; - // almeno 3 lati - if ( nSides < 3) + // almeno 3 lati e normale ben definita + if ( nSides < 3 || vtN.IsSmall()) return false ; // angolo al centro corrispondente ad un lato @@ -403,7 +403,7 @@ CurveComposite::PolygonCenterCorner( int nSides, const Point3d& ptCen, const Poi for ( int i = 1 ; i <= nSides ; ++ i) { // calcolo il secondo punto del lato ptEnd = ptStart ; - ptEnd.Rotate( ptCen, Z_AX, dCosAng, dSinAng) ; + ptEnd.Rotate( ptCen, vtN, dCosAng, dSinAng) ; // se primo lato, verifico che la lunghezza sia superiore al minimo if ( i == 1) { if ( AreSamePointApprox( ptStart, ptEnd)) @@ -431,36 +431,36 @@ CurveComposite::PolygonCenterCorner( int nSides, const Point3d& ptCen, const Poi //---------------------------------------------------------------------------- bool -CurveComposite::PolygonCenterMidSide( int nSides, const Point3d& ptCen, const Point3d& ptMidSide) +CurveComposite::PolygonCenterMidSide( int nSides, const Point3d& ptCen, const Point3d& ptMidSide, const Vector3d& vtN) { // verifico lo stato if ( m_nCounter != 0 || m_nStatus != TO_VERIFY) return false ; - // almeno 3 lati - if ( nSides < 3) + // almeno 3 lati e normale ben definita + if ( nSides < 3 || vtN.IsSmall()) return false ; // calcolo la posizione del corner double dHalfCentSideAngDeg = ANG_FULL / ( 2 * nSides) ; double dCoeff = tan( dHalfCentSideAngDeg * DEGTORAD) ; Vector3d vtDir = ptCen - ptMidSide ; - vtDir.z = 0 ; - vtDir.Rotate( Z_AX, 0, 1) ; + vtDir -= ( vtDir * vtN) * vtN / vtN.SqLen() ; + vtDir.Rotate( vtN, 0, 1) ; Point3d ptCorner = ptMidSide + vtDir * dCoeff ; // ora costruisco come poligono con centro e corner - return PolygonCenterCorner( nSides, ptCen, ptCorner) ; + return PolygonCenterCorner( nSides, ptCen, ptCorner, vtN) ; } //---------------------------------------------------------------------------- bool -CurveComposite::PolygonSide( int nSides, const Point3d& ptStart, const Point3d& ptEnd) +CurveComposite::PolygonSide( int nSides, const Point3d& ptStart, const Point3d& ptEnd, const Vector3d& vtN) { // verifico lo stato if ( m_nCounter != 0 || m_nStatus != TO_VERIFY) return false ; - // almeno 3 lati - if ( nSides < 3) + // almeno 3 lati e normale ben definita + if ( nSides < 3 || vtN.IsSmall()) return false ; // verifico che la lunghezza sia superiore al minimo if ( AreSamePointApprox( ptStart, ptEnd)) @@ -470,12 +470,12 @@ CurveComposite::PolygonSide( int nSides, const Point3d& ptStart, const Point3d& double dHalfCentSideAngDeg = ANG_FULL / ( 2 * nSides) ; double dCoeff = 1 / ( 2 * tan( dHalfCentSideAngDeg * DEGTORAD)) ; Vector3d vtDir = ptEnd - ptStart ; - vtDir.z = 0 ; - vtDir.Rotate( Z_AX, 0, 1) ; + vtDir -= ( vtDir * vtN) * vtN / vtN.SqLen() ; + vtDir.Rotate( vtN, 0, 1) ; Point3d ptCen = Media( ptStart, ptEnd, 0.5) + vtDir * dCoeff ; // ora costruisco come poligono con centro e corner - return PolygonCenterCorner( nSides, ptCen, ptStart) ; + return PolygonCenterCorner( nSides, ptCen, ptStart, vtN) ; } //---------------------------------------------------------------------------- diff --git a/CurveComposite.h b/CurveComposite.h index 4bc4927..0245d76 100644 --- a/CurveComposite.h +++ b/CurveComposite.h @@ -120,9 +120,9 @@ class CurveComposite : public ICurveComposite, public IGeoObjRW virtual bool FromSplit( const ICurve& cCrv, int nParts) ; virtual bool FromPolyLine( const PolyLine& PL) ; virtual bool FromPolyArc( const PolyArc& PA) ; - virtual bool PolygonCenterCorner( int nSides, const Point3d& ptCen, const Point3d& ptCorner) ; - virtual bool PolygonCenterMidSide( int nSides, const Point3d& ptCen, const Point3d& ptMidSide) ; - virtual bool PolygonSide( int nSides, const Point3d& ptStart, const Point3d& ptEnd) ; + virtual bool PolygonCenterCorner( int nSides, const Point3d& ptCen, const Point3d& ptCorner, const Vector3d& vtN) ; + virtual bool PolygonCenterMidSide( int nSides, const Point3d& ptCen, const Point3d& ptMidSide, const Vector3d& vtN) ; + virtual bool PolygonSide( int nSides, const Point3d& ptStart, const Point3d& ptEnd, const Vector3d& vtN) ; virtual int GetCurveNumber( void) const { return m_nCounter ; } virtual const ICurve* GetFirstCurve( void) const ; diff --git a/EgtGeomKernel.rc b/EgtGeomKernel.rc index 0b16fa0..7a4ae79 100644 Binary files a/EgtGeomKernel.rc and b/EgtGeomKernel.rc differ diff --git a/FontOs.cpp b/FontOs.cpp index 2f1e885..1a531ad 100644 --- a/FontOs.cpp +++ b/FontOs.cpp @@ -60,8 +60,8 @@ OsFont::SetCurrFont( const string& sFont, int nWeight, bool bItalic, string sFontUp = sFont ; ToUpper( sFontUp) ; - // se il font non è già caricato - if ( m_sFont != sFontUp) { + // se il font non è già caricato o sono cambiati dei parametri di creazione + if ( m_sFont != sFontUp || nWeight != m_nWeight || bItalic != m_bItalic) { // pulisco la path del font m_sFont.clear() ; // cancello eventuale precedente font diff --git a/GdbExecutor.cpp b/GdbExecutor.cpp index 2d4f886..29e35fb 100644 --- a/GdbExecutor.cpp +++ b/GdbExecutor.cpp @@ -1952,15 +1952,15 @@ GdbExecutor::CurveCompoFromPolygon( const STRVECTOR& vsParams, int nType) // costruisco il poligono switch ( nType) { case POLYG_INSCR : - if ( ! pCrvCompo->PolygonCenterCorner( nNumLati, ptP1, ptP2)) + if ( ! pCrvCompo->PolygonCenterCorner( nNumLati, ptP1, ptP2, Z_AX)) return false ; break ; case POLYG_CIRC : - if ( ! pCrvCompo->PolygonCenterMidSide( nNumLati, ptP1, ptP2)) + if ( ! pCrvCompo->PolygonCenterMidSide( nNumLati, ptP1, ptP2, Z_AX)) return false ; break ; case POLYG_SIDE : - if ( ! pCrvCompo->PolygonSide( nNumLati, ptP1, ptP2)) + if ( ! pCrvCompo->PolygonSide( nNumLati, ptP1, ptP2, Z_AX)) return false ; break ; default : diff --git a/GeomDB.cpp b/GeomDB.cpp index 1f392dc..076398f 100644 --- a/GeomDB.cpp +++ b/GeomDB.cpp @@ -797,13 +797,13 @@ GeomDB::Copy( int nIdSou, int nIdDest, int nRefId, int nSonBeforeAfter, bool bGl // verifico esistenza del padre GdbGroup* pGroupSou = pGdOSou->GetParent() ; if ( pGroupSou == nullptr) - return false ; + return GDB_ID_NULL ; // cerco il padre di destinazione int nParentIdDest = (( nSonBeforeAfter == GDB_SON) ? nRefId : GetParentId( nRefId)) ; GdbGroup* pGroupDest = GetGdbGroup( nParentIdDest) ; if ( pGroupDest == nullptr) - return false ; + return GDB_ID_NULL ; // eseguo la copia PtrOwner pGdODest( pGdOSou->Clone( nIdDest)) ; @@ -893,6 +893,26 @@ GeomDB::Relocate( int nId, int nRefId, int nSonBeforeAfter, bool bGlob) return true ; } +//---------------------------------------------------------------------------- +bool +GeomDB::ChangeId( int nId, int nNewId) +{ + // verifico nuovo Id + if ( ExistsObj( nNewId)) + return false ; + // recupero l'oggetto + GdbObj* pGdO = GetGdbObj( nId) ; + if ( pGdO == nullptr) + return false ; + // elimino da mappa dei nomi vecchio Id e inserisco nuovo + m_IdManager.RemoveObj( nId) ; + m_IdManager.AddObj( nNewId, pGdO) ; + // lista selezionati e GdbIterator non richiedono modifiche + // cambio Id dell'oggetto + pGdO->m_nId = nNewId ; + return true ; +} + //---------------------------------------------------------------------------- bool GeomDB::Erase( int nId) diff --git a/GeomDB.h b/GeomDB.h index 7bbf1d9..3d51333 100644 --- a/GeomDB.h +++ b/GeomDB.h @@ -71,6 +71,7 @@ class GeomDB : public IGeomDB { return Relocate( nId, nRefId, nSonBeforeAfter, false) ; } virtual bool RelocateGlob( int nId, int nRefId, int nSonBeforeAfter = GDB_SON) { return Relocate( nId, nRefId, nSonBeforeAfter, true) ; } + virtual bool ChangeId( int nId, int nNewId) ; virtual bool Erase( int nId) ; virtual bool Translate( int nId, const Vector3d& vtMove) ; virtual bool TranslateGlob( int nId, const Vector3d& vtMove) ;