diff --git a/EXE_NstCreateFlatParts.cpp b/EXE_NstCreateFlatParts.cpp index d4c95e2..b5d1e23 100644 --- a/EXE_NstCreateFlatParts.cpp +++ b/EXE_NstCreateFlatParts.cpp @@ -322,6 +322,58 @@ CreateFlatPartsByLayers( void) return true ; } +//---------------------------------------------------------------------------- +static bool +CreateFlatPartsByClosedCurves( void) +{ + IGeomDB* pGeomDB = GetCurrGeomDB() ; + VERIFY_GEOMDB( pGeomDB, false) + // preparo gli iteratori + PtrOwner pPar( CreateGdbIterator( pGeomDB)) ; + PtrOwner pLay( CreateGdbIterator( pGeomDB)) ; + PtrOwner pEnt( CreateGdbIterator( pGeomDB)) ; + if ( IsNull( pPar) || IsNull( pLay) || IsNull( pEnt)) + return false ; + // ciclo su tutti i gruppi della radice (pezzi) + bool bPok = pPar->GoToFirstGroupInGroup( GDB_ID_ROOT) ; + int nFirstId = pPar->GetId() ; + while ( bPok) { + // ciclo su tutti i sottogruppi (layer) + bool bLok = pLay->GoToFirstGroupInGroup( *Get( pPar)) ; + while ( bLok) { + // ciclo su tutte le entità + bool bEok = pEnt->GoToFirstInGroup( *Get( pLay)) ; + while ( bEok) { + // se curva chiusa + if ( ( pEnt->GetGeoType() & GEO_CURVE) != 0 && + GetCurve( pEnt->GetGeoObj())->IsClosed()) { + // creo pezzo e layer per questa geometria + int nPartId = pGeomDB->InsertGroup( GDB_ID_NULL, nFirstId, GDB_BEFORE, Frame3d()) ; + int nLayerId = pGeomDB->InsertGroup( GDB_ID_NULL, nPartId, GDB_LAST_SON, Frame3d()) ; + int nEntId = pEnt->GetId() ; + // recupero successiva entità + bEok = pEnt->GoToNext() ; + // sposto l'entità sotto questo layer + if ( ! pGeomDB->RelocateGlob( nEntId, nLayerId)) + return false ; + } + // altrimenti cancello + else + bEok = pEnt->EraseAndGoToNext() ; + } + // altro layer del gruppo originale + bLok = pLay->GoToNextGroup() ; + } + // passo al successivo + bPok = pPar->GoToNextGroup() ; + } + // cancello i gruppi svuotati + bPok = pPar->GoTo( nFirstId) ; + while ( bPok) + bPok = pPar->EraseAndGoToNext() ; + return true ; +} + //---------------------------------------------------------------------------- static bool VerifyAndAdjustFlatParts( void) @@ -368,6 +420,11 @@ VerifyAndAdjustFlatParts( void) bEok = pEnt->EraseAndGoToNext() ; } else { + // verifico sia orientata in senso CCW + double dArea ; + pCrv->GetAreaXY( dArea) ; + if ( dArea < 0) + pCrv->Invert() ; // salvo Id entità corrente e preparo passaggio a prossima int nEntId = pEnt->GetId() ; bEok = pEnt->GoToNext() ; @@ -526,6 +583,11 @@ ExeCreateFlatParts( int nType) // creazione dei pezzi bOk = bOk && CreateFlatPartsByLayers() ; } + // creazione basata su curve chiuse + else if ( nType == FPC_CLOSEDCURVE) { + // creazione dei pezzi + bOk = bOk && CreateFlatPartsByClosedCurves() ; + } // creazione basata sui pezzi NGE // sono già a posto // verifica e aggiustamento dei pezzi