EgtExecutor 1.6h3 :
- rettangoli sempre disegnati CCW - aggiunta creazione di Regioni rettangolo, stadium e disco - correzioni a ExeSplitCurveAtSel - aggiunta ExeProjectCurveOnPlane - aggiunte funzioni per normale a regione piana e numero di chunk - sostituzione di Num o Nbr con Count.
This commit is contained in:
+141
-58
@@ -57,9 +57,115 @@ ExeInvertSurface( const INTVECTOR& vIds)
|
||||
return bOk ;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------
|
||||
static int
|
||||
MyExplodeSurfTriMesh( int nId, int* pnCount)
|
||||
{
|
||||
IGeomDB* pGeomDB = GetCurrGeomDB() ;
|
||||
VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL)
|
||||
// recupero la superficie TriMesh
|
||||
const ISurfTriMesh* pStm = GetSurfTriMesh( pGeomDB->GetGeoObj( nId)) ;
|
||||
if ( pStm == nullptr)
|
||||
return GDB_ID_NULL ;
|
||||
// copio tutte le facce
|
||||
int nFirstId = GDB_ID_NULL ;
|
||||
int nCount = 0 ;
|
||||
int nFacet = pStm->GetFacetCount() ;
|
||||
for ( int i = 0 ; i < nFacet ; ++ i) {
|
||||
ISurfTriMesh* pFac = pStm->CloneFacet( i) ;
|
||||
if ( pFac == nullptr)
|
||||
continue ;
|
||||
// inserisco la superficie nello stesso gruppo e nello stesso posto del GeomDB
|
||||
int nFacId = pGeomDB->InsertGeoObj( GDB_ID_NULL, nId, GDB_BEFORE, pFac) ;
|
||||
if ( nFacId == GDB_ID_NULL)
|
||||
return GDB_ID_NULL ;
|
||||
// copio gli attributi
|
||||
if ( ! pGeomDB->CopyAttributes( nId, nFacId))
|
||||
return GDB_ID_NULL ;
|
||||
// aggiorno contatori
|
||||
if ( nFirstId == GDB_ID_NULL)
|
||||
nFirstId = nFacId ;
|
||||
++ nCount ;
|
||||
}
|
||||
// elimino la superficie
|
||||
pGeomDB->Erase( nId) ;
|
||||
// restituisco risultati
|
||||
if ( pnCount != nullptr)
|
||||
*pnCount = nCount ;
|
||||
return nFirstId ;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------
|
||||
static int
|
||||
MyExplodeSurfFlatRegion( int nId, int* pnCount)
|
||||
{
|
||||
IGeomDB* pGeomDB = GetCurrGeomDB() ;
|
||||
VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL)
|
||||
// recupero la superficie FlatRegion
|
||||
const ISurfFlatRegion* pSfr = GetSurfFlatRegion( pGeomDB->GetGeoObj( nId)) ;
|
||||
if ( pSfr == nullptr)
|
||||
return GDB_ID_NULL ;
|
||||
// copio tutti i componenti connessi (chunk)
|
||||
int nFirstId = GDB_ID_NULL ;
|
||||
int nCount = 0 ;
|
||||
int nChunk = pSfr->GetChunkCount() ;
|
||||
for ( int i = 0 ; i < nChunk ; ++ i) {
|
||||
ISurfFlatRegion* pChk = pSfr->CloneChunk( i) ;
|
||||
if ( pChk == nullptr)
|
||||
continue ;
|
||||
// inserisco la superficie nello stesso gruppo e nello stesso posto del GeomDB
|
||||
int nNewId = pGeomDB->InsertGeoObj( GDB_ID_NULL, nId, GDB_BEFORE, pChk) ;
|
||||
if ( nNewId == GDB_ID_NULL)
|
||||
return GDB_ID_NULL ;
|
||||
// copio gli attributi
|
||||
if ( ! pGeomDB->CopyAttributes( nId, nNewId))
|
||||
return GDB_ID_NULL ;
|
||||
// aggiorno contatori
|
||||
if ( nFirstId == GDB_ID_NULL)
|
||||
nFirstId = nNewId ;
|
||||
++ nCount ;
|
||||
}
|
||||
// elimino la superficie
|
||||
pGeomDB->Erase( nId) ;
|
||||
// restituisco risultati
|
||||
if ( pnCount != nullptr)
|
||||
*pnCount = nCount ;
|
||||
return nFirstId ;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------
|
||||
int
|
||||
ExeExplodeSurface( int nId, int* pnCount)
|
||||
{
|
||||
IGeomDB* pGeomDB = GetCurrGeomDB() ;
|
||||
VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL)
|
||||
// recupero il tipo di superficie
|
||||
int nFirstId = GDB_ID_NULL ;
|
||||
int nCount = 0 ;
|
||||
switch ( pGeomDB->GetGeoType( nId)) {
|
||||
case SRF_TRIMESH :
|
||||
nFirstId = MyExplodeSurfTriMesh( nId, &nCount) ;
|
||||
break ;
|
||||
case SRF_FLATRGN :
|
||||
nFirstId = MyExplodeSurfFlatRegion( nId, &nCount) ;
|
||||
break ;
|
||||
}
|
||||
ExeSetModified() ;
|
||||
// se richiesto, salvo il comando Lua equivalente
|
||||
if ( IsCmdLog()) {
|
||||
string sLua = "EgtExplodeSurface(" + ToString( nId) + ")" +
|
||||
" -- Id1=" + ToString( nFirstId) + ",Nbr=" + ToString( nCount) ;
|
||||
LOG_INFO( GetCmdLogger(), sLua.c_str()) ;
|
||||
}
|
||||
// restituisco risultati
|
||||
if ( pnCount != nullptr)
|
||||
*pnCount = nCount ;
|
||||
return nFirstId ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
int
|
||||
ExeExtractSurfFrLoop( int nId, int nLoop, int nDestGrpId)
|
||||
ExeExtractSurfFrChunkLoops( int nId, int nChunk, int nDestGrpId, int* pnCount)
|
||||
{
|
||||
IGeomDB* pGeomDB = GetCurrGeomDB() ;
|
||||
VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL)
|
||||
@@ -72,23 +178,41 @@ ExeExtractSurfFrLoop( int nId, int nLoop, int nDestGrpId)
|
||||
// recupero il riferimento di destinazione
|
||||
Frame3d frDest ;
|
||||
bOk = bOk && pGeomDB->GetGroupGlobFrame( nDestGrpId, frDest) ;
|
||||
// richiedo la curva che costituisce il loop
|
||||
PtrOwner<ICurve> pCrv( pSfr->GetLoop( nLoop)) ;
|
||||
bOk = bOk && ! IsNull( pCrv) ;
|
||||
// la porto nel riferimento destinazione
|
||||
bOk = bOk && pCrv->LocToLoc( frSurf, frDest) ;
|
||||
// la inserisco nel DB geometrico
|
||||
int nNewId = ( bOk ? pGeomDB->AddGeoObj( GDB_ID_NULL, nDestGrpId, Release( pCrv)) : GDB_ID_NULL) ;
|
||||
// richiedo i contorni del componente connesso (chunk) e li inserisco nel DB
|
||||
int nFirstId = GDB_ID_NULL ;
|
||||
int nCount = 0 ;
|
||||
int nL = 0 ;
|
||||
PtrOwner<ICurve> pCrv( bOk ? pSfr->GetLoop( nChunk, nL) : nullptr) ;
|
||||
while ( ! IsNull( pCrv)) {
|
||||
// porto la curva nel riferimento destinazione
|
||||
bOk = bOk && pCrv->LocToLoc( frSurf, frDest) ;
|
||||
// la inserisco nel DB geometrico
|
||||
int nNewId = ( bOk ? pGeomDB->AddGeoObj( GDB_ID_NULL, nDestGrpId, Release( pCrv)) : GDB_ID_NULL) ;
|
||||
bOk = bOk && ( nNewId != GDB_ID_NULL) ;
|
||||
// copio il materiale
|
||||
if ( ! pGeomDB->CopyMaterial( nId, nNewId))
|
||||
return GDB_ID_NULL ;
|
||||
// aggiorno contatori
|
||||
if ( bOk && nFirstId == GDB_ID_NULL)
|
||||
nFirstId = nNewId ;
|
||||
if ( bOk)
|
||||
++ nCount ;
|
||||
// passo alla prossima curva
|
||||
pCrv.Set( bOk ? pSfr->GetLoop( nChunk, ++nL) : nullptr) ;
|
||||
}
|
||||
ExeSetModified() ;
|
||||
// se richiesto, salvo il comando Lua equivalente
|
||||
if ( IsCmdLog()) {
|
||||
string sLua = "EgtExtractSurfFrLoop(" + ToString( nId) + ",{" +
|
||||
ToString( nLoop) + "," +
|
||||
ToString( nDestGrpId) + ")" +
|
||||
" -- Id=" + ToString( nNewId) ;
|
||||
string sLua = "EgtExtractSurfFrChunkLoops(" + ToString( nId) + ",{" +
|
||||
ToString( nChunk) + "," +
|
||||
ToString( nDestGrpId) + ")" +
|
||||
" -- Id=" + ToString( nFirstId) + ",Nbr=" + ToString( nCount) ;
|
||||
LOG_INFO( GetCmdLogger(), sLua.c_str()) ;
|
||||
}
|
||||
return nNewId ;
|
||||
// restituisco risultati
|
||||
if ( pnCount != nullptr)
|
||||
*pnCount = nCount ;
|
||||
return nFirstId ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
@@ -121,6 +245,10 @@ ExeExtractSurfTmFacetLoops( int nId, int nFacet, int nDestGrpId, int* pnCount)
|
||||
// la inserisco nel DB geometrico
|
||||
int nNewId = ( bOk ? pGeomDB->AddGeoObj( GDB_ID_NULL, nDestGrpId, Release( pCrvCompo)) : GDB_ID_NULL) ;
|
||||
bOk = bOk && ( nNewId != GDB_ID_NULL) ;
|
||||
// copio il materiale
|
||||
if ( ! pGeomDB->CopyMaterial( nId, nNewId))
|
||||
return GDB_ID_NULL ;
|
||||
// aggiorno contatori
|
||||
if ( bOk && nFirstId == GDB_ID_NULL)
|
||||
nFirstId = nNewId ;
|
||||
if ( bOk)
|
||||
@@ -140,48 +268,3 @@ ExeExtractSurfTmFacetLoops( int nId, int nFacet, int nDestGrpId, int* pnCount)
|
||||
*pnCount = nCount ;
|
||||
return nFirstId ;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------
|
||||
int
|
||||
ExeExplodeSurfTm( int nId, int* pnCount)
|
||||
{
|
||||
IGeomDB* pGeomDB = GetCurrGeomDB() ;
|
||||
VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL)
|
||||
// recupero la superficie TriMesh
|
||||
const ISurfTriMesh* pStm = GetSurfTriMesh( pGeomDB->GetGeoObj( nId)) ;
|
||||
bool bOk = ( pStm != nullptr) ;
|
||||
// copio tutte le facce
|
||||
int nFirstId = GDB_ID_NULL ;
|
||||
int nCount = 0 ;
|
||||
int nFacet = ( bOk ? pStm->GetFacetNum() : 0) ;
|
||||
for ( int i = 0 ; i < nFacet ; ++ i) {
|
||||
ISurfTriMesh* pFac = pStm->CloneFacet( i) ;
|
||||
if ( pFac == nullptr)
|
||||
continue ;
|
||||
// inserisco la superficie nello stesso gruppo e nello stesso posto del GeomDB
|
||||
int nFacId = pGeomDB->InsertGeoObj( GDB_ID_NULL, nId, GDB_BEFORE, pFac) ;
|
||||
bOk = bOk && ( nFacId != GDB_ID_NULL) ;
|
||||
// copio gli attributi
|
||||
bOk = bOk && pGeomDB->CopyAttributes( nId, nFacId) ;
|
||||
// aggiorno contatori
|
||||
if ( bOk) {
|
||||
if ( nFirstId == GDB_ID_NULL)
|
||||
nFirstId = nFacId ;
|
||||
++ nCount ;
|
||||
}
|
||||
}
|
||||
nFirstId = ( bOk ? nFirstId : GDB_ID_NULL) ;
|
||||
// elimino la superficie
|
||||
bOk = bOk && pGeomDB->Erase( nId) ;
|
||||
ExeSetModified() ;
|
||||
// se richiesto, salvo il comando Lua equivalente
|
||||
if ( IsCmdLog()) {
|
||||
string sLua = "EgtExplodeSurfTm(" + ToString( nId) + ")" +
|
||||
" -- Id1=" + ToString( nFirstId) + ",Nbr=" + ToString( nCount) ;
|
||||
LOG_INFO( GetCmdLogger(), sLua.c_str()) ;
|
||||
}
|
||||
// restituisco risultati
|
||||
if ( pnCount != nullptr)
|
||||
*pnCount = nCount ;
|
||||
return nFirstId ;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user