EgtInterface 1.6e2 :
- esecutore e lua scorporato in EgtExecutor.
This commit is contained in:
+4
-122
@@ -14,15 +14,8 @@
|
||||
//--------------------------- Include ----------------------------------------
|
||||
#include "stdafx.h"
|
||||
#include "API.h"
|
||||
#include "API_Macro.h"
|
||||
#include "AuxTools.h"
|
||||
#include "GeoTools.h"
|
||||
#include "/EgtDev/Include/EInAPI.h"
|
||||
#include "/EgtDev/Include/EInConst.h"
|
||||
#include "/EgtDev/Include/EgkCurveComposite.h"
|
||||
#include "/EgtDev/Include/EgkSurfTriMesh.h"
|
||||
#include "/EgtDev/Include/EGkStringUtils3d.h"
|
||||
#include "/EgtDev/Include/EgtPointerOwner.h"
|
||||
#include "/EgtDev/Include/EXeExecutor.h"
|
||||
|
||||
using namespace std ;
|
||||
|
||||
@@ -32,130 +25,19 @@ __stdcall EgtInvertSurface( int nId)
|
||||
{
|
||||
INTVECTOR vIds ;
|
||||
vIds.push_back( nId) ;
|
||||
return ( EgtInvertSurface( vIds) ? TRUE : FALSE) ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
EgtInvertSurface( const INTVECTOR& vIds)
|
||||
{
|
||||
IGeomDB* pGeomDB = GetCurrGeomDB() ;
|
||||
VERIFY_GEOMDB( pGeomDB, false)
|
||||
// eseguo inversione
|
||||
bool bOk = true ;
|
||||
for ( size_t i = 0 ; i < vIds.size() && bOk ; ++ i) {
|
||||
int nId = (( vIds[i] != GDB_ID_SEL) ? vIds[i] : pGeomDB->GetFirstSelectedObj()) ;
|
||||
while ( nId != GDB_ID_NULL && bOk) {
|
||||
// recupero la superficie e la inverto
|
||||
ISurf* pSurf = GetSurf( pGeomDB->GetGeoObj( nId)) ;
|
||||
if ( pSurf != nullptr && ! pSurf->Invert())
|
||||
bOk = false ;
|
||||
// passo alla successiva
|
||||
nId = (( vIds[i] != GDB_ID_SEL) ? GDB_ID_NULL : pGeomDB->GetNextSelectedObj()) ;
|
||||
}
|
||||
}
|
||||
EgtSetModified() ;
|
||||
// se richiesto, salvo il comando Lua equivalente
|
||||
if ( IsCmdLog()) {
|
||||
string sLua = "EgtInvertSurf({" + IdListToString( vIds) + "})" +
|
||||
" -- Ok=" + ToString( bOk) ;
|
||||
LOG_INFO( GetCmdLogger(), sLua.c_str()) ;
|
||||
}
|
||||
// restituisco risultato
|
||||
return bOk ;
|
||||
return ( ExeInvertSurface( vIds) ? TRUE : FALSE) ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
int
|
||||
__stdcall EgtExtractSurfTmFacetLoops( int nId, int nFacet, int nDestGrpId, 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) ;
|
||||
// recupero il riferimento della superficie
|
||||
Frame3d frSurf ;
|
||||
bOk = bOk && pGeomDB->GetGlobFrame( nId, frSurf) ;
|
||||
// recupero il riferimento di destinazione
|
||||
Frame3d frDest ;
|
||||
bOk = bOk && pGeomDB->GetGroupGlobFrame( nDestGrpId, frDest) ;
|
||||
// recupero i loop come polilinee
|
||||
POLYLINEVECTOR vPL ;
|
||||
bOk = bOk && pStm->GetFacetLoops( nFacet, vPL) ;
|
||||
// dalle polilinee creo le curve e le inserisco nel DB
|
||||
int nFirstId = GDB_ID_NULL ;
|
||||
int nCount = 0 ;
|
||||
for ( size_t i = 0 ; i < vPL.size() ; ++ i) {
|
||||
// creo la curva
|
||||
PtrOwner<ICurveComposite> pCrvCompo( CreateCurveComposite()) ;
|
||||
bOk = bOk && pCrvCompo->FromPolyLine( vPL[i]) ;
|
||||
// la porto nel riferimento destinazione
|
||||
bOk = bOk && pCrvCompo->LocToLoc( frSurf, frDest) ;
|
||||
// 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) ;
|
||||
if ( bOk && nFirstId == GDB_ID_NULL)
|
||||
nFirstId = nNewId ;
|
||||
if ( bOk)
|
||||
++ nCount ;
|
||||
}
|
||||
EgtSetModified() ;
|
||||
// se richiesto, salvo il comando Lua equivalente
|
||||
if ( IsCmdLog()) {
|
||||
string sLua = "EgtExtractSurfTmFacetLoops(" + ToString( nId) + ",{" +
|
||||
ToString( nFacet) + "," +
|
||||
ToString( nDestGrpId) + ")" +
|
||||
" -- Id1=" + ToString( nFirstId) + ",Nbr=" + ToString( nCount) ;
|
||||
LOG_INFO( GetCmdLogger(), sLua.c_str()) ;
|
||||
}
|
||||
// restituisco risultati
|
||||
if ( pnCount != nullptr)
|
||||
*pnCount = nCount ;
|
||||
return nFirstId ;
|
||||
return ExeExtractSurfTmFacetLoops( nId, nFacet, nDestGrpId, pnCount) ;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------
|
||||
int
|
||||
__stdcall EgtExplodeSurfTm( 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 = pStm->GetFacetNum() ;
|
||||
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) ;
|
||||
EgtSetModified() ;
|
||||
// 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 ;
|
||||
return ExeExplodeSurfTm( nId, pnCount) ;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user