EgtExecutor :
- aggiunta ExeAdjustFlatPartLayer.
This commit is contained in:
@@ -147,7 +147,7 @@ ChainCurves( int& nLay)
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
static bool
|
||||
CreateFlatPartsByRegions( int nLay)
|
||||
{
|
||||
IGeomDB* pGeomDB = GetCurrGeomDB() ;
|
||||
@@ -596,3 +596,67 @@ ExeCreateFlatParts( int nType)
|
||||
bOldCmdLog = SetCmdLog( bOldCmdLog) ;
|
||||
return bOk ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
ExeAdjustFlatPartLayer( int nLayerId)
|
||||
{
|
||||
// Disabilito registrazione comandi
|
||||
bool bOldCmdLog = SetCmdLog( false) ;
|
||||
bool bOk = true ;
|
||||
// Compatto e poi esplodo le curve composite
|
||||
int nId = ExeGetFirstInGroup( nLayerId) ;
|
||||
while ( nId != GDB_ID_NULL && bOk) {
|
||||
// Recupero successiva
|
||||
int nNextId = ExeGetNext( nId) ;
|
||||
// Se curva composita
|
||||
if ( ExeGetType( nId) == CRV_COMPO) {
|
||||
// Compatto
|
||||
bOk = ExeMergeCurvesInCurveCompo( nId, 10 * EPS_SMALL) ;
|
||||
// Esplodo in curve semplici
|
||||
bOk = bOk && ExeExplodeCurveCompo( nId, nullptr) ;
|
||||
}
|
||||
// Passo all'entità successiva
|
||||
nId = nNextId ;
|
||||
}
|
||||
// Il verso delle curve è corretto, l'ordinamento può essere diretto o inverso
|
||||
int nId1 = ExeGetFirstInGroup( nLayerId) ;
|
||||
int nId2 = ExeGetNext( nId1) ;
|
||||
Point3d ptP1, ptP2 ;
|
||||
bOk = bOk && ExeEndPoint( nId1, nId1, ptP1) && ExeStartPoint( nId2, nId2, ptP2) ;
|
||||
bool bOrdOk = AreSamePointApprox( ptP1, ptP2) ;
|
||||
// Inserisco in ogni curva info su angoli con precedente e successiva
|
||||
int nFirstId = ( bOrdOk ? ExeGetFirstInGroup( nLayerId) : ExeGetLastInGroup( nLayerId)) ;
|
||||
nId = nFirstId ;
|
||||
while ( nId != GDB_ID_NULL && bOk) {
|
||||
// Recupero successiva
|
||||
int nNextId = ( bOrdOk ? ExeGetNext( nId) : ExeGetPrev( nId)) ;
|
||||
// Successiva geometrica (si considera il layer formato da curve contigue che si chiudono)
|
||||
int nCalcId = (( nNextId != GDB_ID_NULL) ? nNextId : nFirstId) ;
|
||||
if ( nCalcId != GDB_ID_NULL) {
|
||||
// Direzione finale curva corrente e iniziale curva successiva
|
||||
Vector3d vtDir1, vtDir2 ;
|
||||
bOk = ExeEndVector( nId, nId, vtDir1) &&
|
||||
ExeStartVector( nCalcId, nCalcId, vtDir2) ;
|
||||
// Determino l'angolo tra le due direzioni
|
||||
double dAngDeg = 0 ;
|
||||
vtDir1.GetAngleXY( vtDir2, dAngDeg) ;
|
||||
// Se angolo nullo (tangenti), verifico se uno dei due è arco orario
|
||||
if ( abs( dAngDeg) < 10 * EPS_ANG_SMALL) {
|
||||
double dAngCenDeg1, dAngCenDeg2 ;
|
||||
if ( ( ExeArcAngCenter( nId, &dAngCenDeg1) && dAngCenDeg1 < 0) ||
|
||||
( ExeArcAngCenter( nCalcId, &dAngCenDeg2) && dAngCenDeg2 < 0))
|
||||
dAngDeg = -1 ;
|
||||
}
|
||||
// Scrivo l'angolo nelle info delle curve
|
||||
ExeSetInfo( nId, "NextAng", dAngDeg) ;
|
||||
ExeSetInfo( nCalcId, "PrevAng", dAngDeg) ;
|
||||
}
|
||||
// Passo all'entità successiva
|
||||
nId = nNextId ;
|
||||
}
|
||||
|
||||
// Ripristino stato registrazione comandi
|
||||
bOldCmdLog = SetCmdLog( bOldCmdLog) ;
|
||||
return bOk ;
|
||||
}
|
||||
Reference in New Issue
Block a user