EgtInterface 1.6b2 :

- razionalizzazione
- modificati comandi per creazione superfici per gestione piani di regioni con buchi
- aggiunta SplitCurve.
This commit is contained in:
Dario Sassi
2015-02-11 11:46:14 +00:00
parent 4e1dddee86
commit 1e24540dc1
15 changed files with 345 additions and 60 deletions
+8
View File
@@ -21,6 +21,7 @@
//----------------------------------------------------------------------------
ILogger* GetLogger( void) ;
ILogger* GetCmdLogger( void) ;
bool SetCmdLog( bool bVal) ;
bool IsCmdLog( void) ;
//--------------------------- General ----------------------------------------
@@ -54,6 +55,13 @@ int EgtCreateCurveCompoByChain( int nParentId, const INTVECTOR& vIds,
int EgtCreateCurveCompoFromPoints( int nParentId, const PolyLine& PL, int nRefType) ;
int EgtCreateCurveCompoFromPointBulges( int nParentId, const PolyArc& PA, int nRefType) ;
//--------------------------- GeomDBCreateSurface ----------------------------
int EgtCreateSurfTriMeshByRegion( int nParentId, INTVECTOR& vCrvIds, double dLinTol) ;
int EgtCreateSurfTriMeshByExtrusion( int nParentId, INTVECTOR& vCrvIds, const Vector3d& vtExtr,
double dLinTol, int nRefType) ;
int EgtCreateSurfTriMeshByRegionExtrusion( int nParentId, INTVECTOR& vCrvIds, const Vector3d& vtExtr,
double dLinTol, int nRefType) ;
//--------------------------- GdbModify --------------------------------------
bool EgtChangeGroupFrame( int nId, const Frame3d& frNewRef, int nRefType) ;
bool EgtSurfTmDoSewing( const INTVECTOR& vIds, bool bErase) ;
+8 -4
View File
@@ -914,7 +914,7 @@ __stdcall EgtCreateCurveBezier( int nParentId, int nDegree, const double ptCtrls
PNTVECTOR vPnt ;
vPnt.reserve( nDegree + 1) ;
for ( int i = 0 ; i <= nDegree ; ++i) {
vPnt.push_back( Point3d( ptCtrls[3*i], ptCtrls[3*i+1], ptCtrls[3*i+2])) ;
vPnt.emplace_back( ptCtrls[3*i], ptCtrls[3*i+1], ptCtrls[3*i+2]) ;
}
return EgtCreateCurveBezier( nParentId, nDegree, vPnt, nRefType) ;
}
@@ -978,7 +978,7 @@ __stdcall EgtCreateCurveBezierRational( int nParentId, int nDegree, const double
PNTUVECTOR vPntW ;
vPntW.reserve( nDegree + 1) ;
for ( int i = 0 ; i <= nDegree ; ++i) {
vPntW.push_back( make_pair( Point3d( ptCtrlWs[4*i], ptCtrlWs[4*i+1], ptCtrlWs[4*i+2]), ptCtrlWs[4*i+3])) ;
vPntW.emplace_back( Point3d( ptCtrlWs[4*i], ptCtrlWs[4*i+1], ptCtrlWs[4*i+2]), ptCtrlWs[4*i+3]) ;
}
return EgtCreateCurveBezierRational( nParentId, nDegree, vPntW, nRefType) ;
}
@@ -1382,7 +1382,7 @@ EgtCreateCurveCompoFromPoints( int nParentId, const PolyLine& PL, int nRefType)
while ( PL.GetNextPoint( ptP))
sPnt += ",{" + ToString( ptP) + "}" ;
string sLua = "EgtCurveCompoFromPoints(" + ToString( nParentId) + ",{" +
sPnt + "},{" +
sPnt + "}," +
RefTypeToString( nRefType) + ")" +
" -- Id=" + ToString( nId) ;
LOG_INFO( GetCmdLogger(), sLua.c_str()) ;
@@ -1437,7 +1437,7 @@ EgtCreateCurveCompoFromPointBulges( int nParentId, const PolyArc& PA, int nRefTy
while ( PA.GetNextPoint( ptP, dB))
sPnt += ",{" + ToString( ptP) + "," + ToString( dB) + "}" ;
string sLua = "EgtCurveCompoFromPointBulges(" + ToString( nParentId) + ",{" +
sPnt + "},{" +
sPnt + "}," +
RefTypeToString( nRefType) + ")" +
" -- Id=" + ToString( nId) ;
LOG_INFO( GetCmdLogger(), sLua.c_str()) ;
@@ -1533,8 +1533,12 @@ __stdcall EgtCreateRectangle3P( int nParentId, const double ptIni[3],
PL.AddUPoint( 2, ptCrossL) ;
PL.AddUPoint( 3, Point3d( ptCrossL) - vtLatoX) ;
PL.AddUPoint( 4, ptIniL) ;
// disabilito log dei comandi e salvo stato precedente
bool bPrevCmdLog = SetCmdLog( false) ;
// creo la curva e la inserisco nel GDB
nId = EgtCreateCurveCompoFromPoints( nParentId, PL, RTY_LOC) ;
// ripristino precedente stato dei comandi
SetCmdLog( bPrevCmdLog) ;
// ne sistemo il vettore estrusione
ICurve* pCurve = GetCurve( pGeomDB->GetGeoObj( nId)) ;
if ( pCurve != nullptr)
+165 -19
View File
@@ -28,7 +28,7 @@ using namespace std ;
//-------------------------------------------------------------------------------
int
__stdcall EgtCreateSurfTriMeshByContour( int nParentId, int nCrvId, double dLinTol)
__stdcall EgtCreateSurfTriMeshByFlatContour( int nParentId, int nCrvId, double dLinTol)
{
IGeomDB* pGeomDB = GetCurrGeomDB() ;
VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL)
@@ -40,15 +40,15 @@ __stdcall EgtCreateSurfTriMeshByContour( int nParentId, int nCrvId, double dLinT
CurveLocal CrvLoc( pGeomDB, nCrvId, frLoc) ;
bOk = bOk && ( CrvLoc.Get() != nullptr) ;
// calcolo la superficie
ISurfTriMesh* pSTM = ( bOk ? GetSurfTriMeshByContour( *CrvLoc.Get(), dLinTol) : nullptr) ;
ISurfTriMesh* pSTM = ( bOk ? GetSurfTriMeshByFlatContour( CrvLoc.Get(), dLinTol) : nullptr) ;
// inserisco la superficie nel DB
int nNewId = ( bOk ? pGeomDB->AddGeoObj( GDB_ID_NULL, nParentId, pSTM) : GDB_ID_NULL) ;
EgtSetModified() ;
// se richiesto, salvo il comando Lua equivalente
if ( IsCmdLog()) {
string sLua = "EgtSurfTmByContour(" + ToString( nParentId) + "," +
ToString( nCrvId) + "," +
ToString( dLinTol) + ")" +
string sLua = "EgtSurfTmByFlatContour(" + ToString( nParentId) + "," +
ToString( nCrvId) + "," +
ToString( dLinTol) + ")" +
" -- Id=" + ToString( nNewId) ;
LOG_INFO( GetCmdLogger(), sLua.c_str()) ;
}
@@ -58,8 +58,19 @@ __stdcall EgtCreateSurfTriMeshByContour( int nParentId, int nCrvId, double dLinT
//-------------------------------------------------------------------------------
int
__stdcall EgtCreateSurfTriMeshByExtrusion( int nParentId, int nCrvId, const double vtExtr[3],
BOOL bCapEnds, double dLinTol, int nRefType)
__stdcall EgtCreateSurfTriMeshByRegion( int nParentId, int nNumId, const int nCrvIds[], double dLinTol)
{
INTVECTOR vCrvIds ;
vCrvIds.reserve( nNumId) ;
for ( int i = 0 ; i < nNumId ; ++i) {
vCrvIds.push_back( nCrvIds[i]) ;
}
return EgtCreateSurfTriMeshByRegion( nParentId, vCrvIds, dLinTol) ;
}
//-------------------------------------------------------------------------------
int
EgtCreateSurfTriMeshByRegion( int nParentId, INTVECTOR& vCrvIds, double dLinTol)
{
IGeomDB* pGeomDB = GetCurrGeomDB() ;
VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL)
@@ -67,24 +78,159 @@ __stdcall EgtCreateSurfTriMeshByExtrusion( int nParentId, int nCrvId, const doub
// recupero il riferimento locale
Frame3d frLoc ;
bOk = bOk && pGeomDB->GetGroupGlobFrame( nParentId, frLoc) ;
// recupero la curva in locale
CurveLocal CrvLoc( pGeomDB, nCrvId, frLoc) ;
bOk = bOk && ( CrvLoc.Get() != nullptr) ;
// porto in locale il vettore estrusione
Vector3d vtExtrL = GetVectorLocal( pGeomDB, vtExtr, nRefType, frLoc) ;
// recupero le curve in locale
CURVELOCALVECTOR vCrvLoc ;
vCrvLoc.reserve( vCrvIds.size()) ;
ICURVEPVECTOR vCrvP ;
vCrvP.reserve( vCrvIds.size()) ;
for ( size_t i = 0 ; i < vCrvIds.size() ; ++ i) {
vCrvLoc.emplace_back( pGeomDB, vCrvIds[i], frLoc) ;
vCrvP.push_back( const_cast<ICurve*>( vCrvLoc[i].Get())) ;
bOk = bOk && ( vCrvLoc[i].Get() != nullptr) ;
}
// calcolo la superficie
ISurfTriMesh* pSTM = ( bOk ? GetSurfTriMeshByExtrusion( *CrvLoc.Get(), vtExtrL, ( bCapEnds != FALSE), dLinTol) : nullptr) ;
ISurfTriMesh* pSTM = ( bOk ? GetSurfTriMeshByRegion( vCrvP, dLinTol) : nullptr) ;
bOk = bOk && ( pSTM != nullptr) ;
// elimino punti ripetuti
bOk = bOk && pSTM->DoCompacting() ;
// inserisco la superficie nel DB
int nNewId = ( bOk ? pGeomDB->AddGeoObj( GDB_ID_NULL, nParentId, pSTM) : GDB_ID_NULL) ;
EgtSetModified() ;
// se richiesto, salvo il comando Lua equivalente
if ( IsCmdLog()) {
string sLua = "EgtSurfTmByExtrusion(" + ToString( nParentId) + "," +
ToString( nCrvId) + ",{" +
string sIds ;
for ( size_t i = 0 ; i < vCrvIds.size() ; ++ i)
sIds += ToString( vCrvIds[i]) + "," ;
sIds.pop_back() ;
string sLua = "EgtSurfTmByRegion(" + ToString( nParentId) + ",{" +
sIds + "}," +
ToString( dLinTol) + ")" +
" -- Id=" + ToString( nNewId) ;
LOG_INFO( GetCmdLogger(), sLua.c_str()) ;
}
// restituisco l'identificativo della nuova entità
return nNewId ;
}
//-------------------------------------------------------------------------------
int
__stdcall EgtCreateSurfTriMeshByExtrusion( int nParentId, int nNumId, const int nCrvIds[],
const double vtExtr[3], double dLinTol, int nRefType)
{
INTVECTOR vCrvIds ;
vCrvIds.reserve( nNumId) ;
for ( int i = 0 ; i < nNumId ; ++i) {
vCrvIds.push_back( nCrvIds[i]) ;
}
return EgtCreateSurfTriMeshByExtrusion( nParentId, vCrvIds, vtExtr, dLinTol, nRefType) ;
}
//-------------------------------------------------------------------------------
int
EgtCreateSurfTriMeshByExtrusion( int nParentId, INTVECTOR& vCrvIds, const Vector3d& vtExtr,
double dLinTol, int nRefType)
{
IGeomDB* pGeomDB = GetCurrGeomDB() ;
VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL)
bool bOk = true ;
// recupero il riferimento locale
Frame3d frLoc ;
bOk = bOk && pGeomDB->GetGroupGlobFrame( nParentId, frLoc) ;
// recupero le curve in locale
CURVELOCALVECTOR vCrvLoc ;
vCrvLoc.reserve( vCrvIds.size()) ;
ICURVEPVECTOR vCrvP ;
vCrvP.reserve( vCrvIds.size()) ;
for ( size_t i = 0 ; i < vCrvIds.size() ; ++ i) {
vCrvLoc.emplace_back( pGeomDB, vCrvIds[i], frLoc) ;
vCrvP.push_back( const_cast<ICurve*>( vCrvLoc[i].Get())) ;
bOk = bOk && ( vCrvLoc[i].Get() != nullptr) ;
}
// porto in locale il vettore estrusione
Vector3d vtExtrL = GetVectorLocal( pGeomDB, vtExtr.v, nRefType, frLoc) ;
// creo le superfici e le inserisco nel DB
int nFirstId = GDB_ID_NULL ;
for ( int i = 0 ; i < int( vCrvP.size()) ; ++ i) {
// calcolo la superficie
ISurfTriMesh* pSTM = ( bOk ? GetSurfTriMeshByExtrusion( vCrvP[i], vtExtrL, false, dLinTol) : nullptr) ;
// inserisco la superficie nel DB
int nNewId = ( bOk ? pGeomDB->AddGeoObj( GDB_ID_NULL, nParentId, pSTM) : GDB_ID_NULL) ;
bOk = bOk && ( nNewId != GDB_ID_NULL) ;
if ( bOk && nFirstId == GDB_ID_NULL)
nFirstId = nNewId ;
}
EgtSetModified() ;
// se richiesto, salvo il comando Lua equivalente
if ( IsCmdLog()) {
string sIds ;
for ( size_t i = 0 ; i < vCrvIds.size() ; ++ i)
sIds += ToString( vCrvIds[i]) + "," ;
sIds.pop_back() ;
string sLua = "EgtSurfTmByExtrusion(" + ToString( nParentId) + ",{" +
sIds + "},{" +
ToString( Vector3d( vtExtr)) + "}," +
( bCapEnds ? "true" : "false") + "," +
ToString( dLinTol) + "," +
RefTypeToString( nRefType) + ")" +
" -- Id=" + ToString( nFirstId) ;
LOG_INFO( GetCmdLogger(), sLua.c_str()) ;
}
// restituisco l'identificativo della nuova entità
return nFirstId ;
}
//-------------------------------------------------------------------------------
int
__stdcall EgtCreateSurfTriMeshByRegionExtrusion( int nParentId, int nNumId, const int nCrvIds[],
const double vtExtr[3], double dLinTol, int nRefType)
{
INTVECTOR vCrvIds ;
vCrvIds.reserve( nNumId) ;
for ( int i = 0 ; i < nNumId ; ++i) {
vCrvIds.push_back( nCrvIds[i]) ;
}
return EgtCreateSurfTriMeshByRegionExtrusion( nParentId, vCrvIds, vtExtr, dLinTol, nRefType) ;
}
//-------------------------------------------------------------------------------
int
EgtCreateSurfTriMeshByRegionExtrusion( int nParentId, INTVECTOR& vCrvIds, const Vector3d& vtExtr,
double dLinTol, int nRefType)
{
IGeomDB* pGeomDB = GetCurrGeomDB() ;
VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL)
bool bOk = true ;
// recupero il riferimento locale
Frame3d frLoc ;
bOk = bOk && pGeomDB->GetGroupGlobFrame( nParentId, frLoc) ;
// recupero le curve in locale
CURVELOCALVECTOR vCrvLoc ;
vCrvLoc.reserve( vCrvIds.size()) ;
ICURVEPVECTOR vCrvP ;
vCrvP.reserve( vCrvIds.size()) ;
for ( size_t i = 0 ; i < vCrvIds.size() ; ++ i) {
vCrvLoc.emplace_back( pGeomDB, vCrvIds[i], frLoc) ;
vCrvP.push_back( const_cast<ICurve*>( vCrvLoc[i].Get())) ;
bOk = bOk && ( vCrvLoc[i].Get() != nullptr) ;
}
// porto in locale il vettore estrusione
Vector3d vtExtrL = GetVectorLocal( pGeomDB, vtExtr.v, nRefType, frLoc) ;
int nNewId = GDB_ID_NULL ;
// creo la superficie
ISurfTriMesh* pSTM = ( bOk ? GetSurfTriMeshByRegionExtrusion( vCrvP, vtExtrL, dLinTol) : nullptr) ;
// inserisco la superficie nel DB
nNewId = ( bOk ? pGeomDB->AddGeoObj( GDB_ID_NULL, nParentId, pSTM) : GDB_ID_NULL) ;
EgtSetModified() ;
// se richiesto, salvo il comando Lua equivalente
if ( IsCmdLog()) {
string sIds ;
for ( size_t i = 0 ; i < vCrvIds.size() ; ++ i)
sIds += ToString( vCrvIds[i]) + "," ;
sIds.pop_back() ;
string sLua = "EgtSurfTmByRegionExtrusion(" + ToString( nParentId) + ",{" +
sIds + "},{" +
ToString( Vector3d( vtExtr)) + "}," +
ToString( dLinTol) + "," +
RefTypeToString( nRefType) + ")" +
" -- Id=" + ToString( nNewId) ;
LOG_INFO( GetCmdLogger(), sLua.c_str()) ;
}
@@ -111,7 +257,7 @@ __stdcall EgtCreateSurfTriMeshByRevolve( int nParentId, int nCrvId,
Point3d ptAxL = GetPointLocal( pGeomDB, ptAx, nRefType, frLoc) ;
Vector3d vtAxL = GetVectorLocal( pGeomDB, vtAx, nRefType, frLoc) ;
// calcolo la superficie
ISurfTriMesh* pSTM = ( bOk ? GetSurfTriMeshByRevolve( *CrvLoc.Get(), ptAxL, vtAxL, ( bCapEnds != FALSE), dLinTol) : nullptr) ;
ISurfTriMesh* pSTM = ( bOk ? GetSurfTriMeshByRevolve( CrvLoc.Get(), ptAxL, vtAxL, ( bCapEnds != FALSE), dLinTol) : nullptr) ;
// inserisco la superficie nel DB
int nNewId = ( bOk ? pGeomDB->AddGeoObj( GDB_ID_NULL, nParentId, pSTM) : GDB_ID_NULL) ;
EgtSetModified() ;
@@ -150,7 +296,7 @@ __stdcall EgtCreateSurfTriMeshByScrewing( int nParentId, int nCrvId,
Point3d ptAxL = GetPointLocal( pGeomDB, ptAx, nRefType, frLoc) ;
Vector3d vtAxL = GetVectorLocal( pGeomDB, vtAx, nRefType, frLoc) ;
// calcolo la superficie
ISurfTriMesh* pSTM = ( bOk ? GetSurfTriMeshByScrewing( *CrvLoc.Get(), ptAxL, vtAxL, dAngRotDeg, dMove, dLinTol) : nullptr) ;
ISurfTriMesh* pSTM = ( bOk ? GetSurfTriMeshByScrewing( CrvLoc.Get(), ptAxL, vtAxL, dAngRotDeg, dMove, dLinTol) : nullptr) ;
// inserisco la superficie nel DB
int nNewId = ( bOk ? pGeomDB->AddGeoObj( GDB_ID_NULL, nParentId, pSTM) : GDB_ID_NULL) ;
EgtSetModified() ;
@@ -188,7 +334,7 @@ __stdcall EgtCreateSurfTriMeshRuled( int nParentId, int nCrvId1, int nCrvId2, do
CurveLocal CrvLoc2( pGeomDB, nCrvId2, frLoc) ;
bOk = bOk && ( CrvLoc2.Get() != nullptr) ;
// calcolo la superficie
ISurfTriMesh* pSTM = ( bOk ? GetSurfTriMeshRuled( *CrvLoc1.Get(), *CrvLoc2.Get(), dLinTol) : nullptr) ;
ISurfTriMesh* pSTM = ( bOk ? GetSurfTriMeshRuled( CrvLoc1.Get(), CrvLoc2.Get(), dLinTol) : nullptr) ;
// inserisco la superficie trimesh nel DB
int nNewId = ( bOk ? pGeomDB->AddGeoObj( GDB_ID_NULL, nParentId, pSTM) : GDB_ID_NULL) ;
EgtSetModified() ;
+2
View File
@@ -187,6 +187,8 @@ EgtSurfTmDoSewing( const INTVECTOR& vIds, bool bErase)
// eseguo la cucitura
bOk = bOk && pStm->DoSewing( *pStmS, frStm) ;
}
// compatto
bOk = bOk && pStm->DoCompacting() ;
// se richiesto, cancello le superfici cucite alla prima
if ( bOk && bErase) {
for ( size_t i = 1 ; i < vIds.size() ; ++ i)
+42 -4
View File
@@ -469,6 +469,44 @@ __stdcall EgtTrimExtendCurveByLen( int nId, double dLen, const double ptNear[3],
return ( bOk ? TRUE : FALSE) ;
}
//----------------------------------------------------------------------------
BOOL
__stdcall EgtSplitCurve( int nId, int nParts)
{
IGeomDB* pGeomDB = GetCurrGeomDB() ;
VERIFY_GEOMDB( pGeomDB, FALSE)
// recupero la curva
ICurve* pCurve = GetCurve( pGeomDB->GetGeoObj( nId)) ;
bool bOk = ( pCurve != nullptr) ;
// il numero di parti non può essere inferiore a 1
nParts = max( nParts, 1) ;
// lunghezza totale della curva
double dLenTot = 0 ;
bOk = bOk && pCurve->GetLength( dLenTot) ;
// lunghezza di una parte
double dLen = dLenTot / nParts ;
// eseguo la divisione
for ( int i = 1; i < nParts ; ++ i) {
// copio la curva
int nCopyId = pGeomDB->Copy( nId, GDB_ID_NULL, nId, GDB_BEFORE) ;
ICurve* pCopyCrv = GetCurve( pGeomDB->GetGeoObj( nCopyId)) ;
bOk = bOk && ( pCopyCrv != nullptr) ;
// tengo la prima parte della copia e la seconda parte dell'originale
bOk = bOk && pCopyCrv->TrimEndAtLen( dLen) ;
bOk = bOk && pCurve->TrimStartAtLen( dLen) ;
}
EgtSetModified() ;
// se richiesto, salvo il comando Lua equivalente
if ( IsCmdLog()) {
string sLua = "EgtSplitCurve(" + ToString( nId) + "," +
ToString( nParts) + ")" +
" -- Ok=" + ToString( bOk) ;
LOG_INFO( GetCmdLogger(), sLua.c_str()) ;
}
// restituisco risultato
return ( bOk ? TRUE : FALSE) ;
}
//----------------------------------------------------------------------------
BOOL
__stdcall EgtSplitCurveAtPoint( int nId, double ptOn[3], int nRefType)
@@ -507,12 +545,12 @@ __stdcall EgtSplitCurveAtPoint( int nId, double ptOn[3], int nRefType)
// se il punto di taglio è interno, devo realmente tagliare
if ( bIsInside) {
// copio la curva
int nCopyId = GDB_ID_NULL ;
if ( bOk && ( nCopyId = pGeomDB->Copy( nId, GDB_ID_NULL, nId, GDB_AFTER)) == GDB_ID_NULL)
bOk = false ;
int nCopyId = pGeomDB->Copy( nId, GDB_ID_NULL, nId, GDB_AFTER) ;
ICurve* pCopyCrv = GetCurve( pGeomDB->GetGeoObj( nCopyId)) ;
bOk = bOk && ( pCopyCrv != nullptr) ;
// tengo la prima parte dell'originale e la seconda parte della copia
bOk = bOk && pCurve->TrimEndAtParam( dU) ;
bOk = bOk && ( EgtTrimCurveStartAtParam( nCopyId, dU) != FALSE) ;
bOk = bOk && pCopyCrv->TrimStartAtParam( dU) ;
}
EgtSetModified() ;
// se richiesto, salvo il comando Lua equivalente
+2 -2
View File
@@ -203,7 +203,7 @@ __stdcall EgtSetMark( int nId)
VERIFY_GEOMDB( pGeomDB, FALSE)
// imposto l'evidenziazione
bool bOk = pGeomDB->SetMark( nId) ;
EgtSetModified() ;
// non produce modifica perchè mark ignorato in salvataggio
return ( bOk ? TRUE : FALSE) ;
}
@@ -215,7 +215,7 @@ __stdcall EgtResetMark( int nId)
VERIFY_GEOMDB( pGeomDB, FALSE)
// cancello l'evidenziazione
bool bOk = pGeomDB->ResetMark( nId) ;
EgtSetModified() ;
// non produce modifica perchè mark ignorato in salvataggio
return ( bOk ? TRUE : FALSE) ;
}
+14 -3
View File
@@ -37,7 +37,7 @@ static bool s_bCmdLog = false ;
//-----------------------------------------------------------------------------
BOOL
__stdcall EgtInit( int nDebug, const wchar_t* sLogFile)
__stdcall EgtInit( int nDebug, const wchar_t* sLogFile, const wchar_t* sLogMsg)
{
// cancello eventuali vecchi contesti
ClearAllGseContexts() ;
@@ -59,6 +59,9 @@ __stdcall EgtInit( int nDebug, const wchar_t* sLogFile)
// dichiaro inizio programma
LOG_DATETIME( s_pGenLog, " Init")
// eventuale messaggio dall'applicazione
if ( sLogMsg != nullptr && sLogMsg[0] != L'\0')
LOG_INFO( s_pGenLog, LPSTR( WtoA( sLogMsg)))
// versione dell'interfaccia
LOG_INFO( s_pGenLog, GetEInVersion())
// versione delle librerie
@@ -180,14 +183,14 @@ __stdcall EgtSetCommandLogger( const wchar_t* sLogFile)
void
__stdcall EgtEnableCommandLogger( void)
{
s_bCmdLog = true ;
SetCmdLog( true) ;
}
//-----------------------------------------------------------------------------
void
__stdcall EgtDisableCommandLogger( void)
{
s_bCmdLog = false ;
SetCmdLog( false) ;
}
//-----------------------------------------------------------------------------
@@ -257,6 +260,14 @@ GetCmdLogger( void)
return s_pCmdLog ;
}
//-----------------------------------------------------------------------------
bool
SetCmdLog( bool bVal)
{
swap( bVal, s_bCmdLog) ;
return bVal ;
}
//-----------------------------------------------------------------------------
bool
IsCmdLog( void)
+3 -5
View File
@@ -52,15 +52,13 @@ __stdcall EgtLuaEvalStringExpr( const wchar_t* wsExpr, wchar_t*& wsVal)
BOOL
__stdcall EgtLuaExecLine( const wchar_t* wsLine)
{
// disabilito il log dei comandi
bool bPrevCmdLog = IsCmdLog() ;
EgtDisableCommandLogger() ;
// disabilito log dei comandi e salvo stato precedente
bool bPrevCmdLog = SetCmdLog( false) ;
// eseguo il comando
string sLine = wstrztoA( wsLine) ;
bool bOk = LuaExecLine( sLine) ;
// ripristino lo stato originale del log dei comandi
if ( bPrevCmdLog)
EgtEnableCommandLogger() ;
SetCmdLog( bPrevCmdLog) ;
// se richiesto, salvo il comando Lua
if ( IsCmdLog()) {
string sLua = sLine +
+5
View File
@@ -50,6 +50,11 @@ DllMain( HMODULE hModule, DWORD dwReason, LPVOID lpReserved)
// if ( IsDbgPresent)
// return 0 ;
//#endif
// se debug, imposto stampe memory leaks all'uscita
#if defined ( _DEBUG)
_CrtSetDbgFlag( _CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF) ;
#endif
// eseguo
s_hModule = hModule ;
EGT_TRACE( "EgtInterface.dll Initializing!\n") ;
}
BIN
View File
Binary file not shown.
+4 -4
View File
@@ -147,14 +147,14 @@ copy $(TargetPath) \EgtProg\DllD64</Command>
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<PrecompiledHeader>Use</PrecompiledHeader>
<Optimization>Full</Optimization>
<Optimization>MaxSpeed</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<PreprocessorDefinitions>WIN32;I_AM_EIN;NDEBUG;_WINDOWS;_USRDLL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<FavorSizeOrSpeed>Speed</FavorSizeOrSpeed>
<InlineFunctionExpansion>AnySuitable</InlineFunctionExpansion>
<MultiProcessorCompilation>true</MultiProcessorCompilation>
<OmitFramePointers>false</OmitFramePointers>
<OmitFramePointers>true</OmitFramePointers>
<OpenMPSupport>true</OpenMPSupport>
<EnableEnhancedInstructionSet>StreamingSIMDExtensions2</EnableEnhancedInstructionSet>
</ClCompile>
@@ -177,13 +177,13 @@ copy $(TargetPath) \EgtProg\Dll32</Command>
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<PrecompiledHeader>Use</PrecompiledHeader>
<Optimization>Full</Optimization>
<Optimization>MaxSpeed</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<PreprocessorDefinitions>WIN32;I_AM_EIN;NDEBUG;_WINDOWS;_USRDLL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<FavorSizeOrSpeed>Speed</FavorSizeOrSpeed>
<InlineFunctionExpansion>AnySuitable</InlineFunctionExpansion>
<OmitFramePointers>false</OmitFramePointers>
<OmitFramePointers>true</OmitFramePointers>
<MultiProcessorCompilation>true</MultiProcessorCompilation>
<OpenMPSupport>true</OpenMPSupport>
</ClCompile>
+1
View File
@@ -16,6 +16,7 @@
#include "/EgtDev/Include/EGkGeomDB.h"
#include "/EgtDev/Include/EGrScene.h"
#include "/EgtDev/Include/EGnCmdParser.h"
#define NOMINMAX
#include <windows.h>
//----------------------------------------------------------------------------
+73 -18
View File
@@ -23,21 +23,47 @@
using namespace std ;
//-------------------------------------------------------------------------------
static const double LIN_TOL_DEF = 0.05 ;
//-------------------------------------------------------------------------------
static int
LuaCreateSurfTriMeshByContour( lua_State* L)
LuaCreateSurfTriMeshByFlatContour( lua_State* L)
{
// 2 o 3 parametri : ParentId, CrvId [, dTol]
int nParentId ;
LuaCheckParam( L, 1, nParentId)
int nCrvId ;
LuaCheckParam( L, 2, nCrvId)
double dLinTol = 0.1 ;
double dLinTol = LIN_TOL_DEF ;
if ( lua_gettop( L) >= 3)
LuaCheckParam( L, 3, dLinTol) ;
LuaClearStack( L) ;
// creo STM riempiendo un contorno piano
int nId = EgtCreateSurfTriMeshByContour( nParentId, nCrvId, dLinTol) ;
int nId = EgtCreateSurfTriMeshByFlatContour( nParentId, nCrvId, dLinTol) ;
// restituisco il risultato
if ( nId != GDB_ID_NULL)
LuaSetReturn( L, nId) ;
else
LuaSetReturn( L) ;
return 1 ;
}
//-------------------------------------------------------------------------------
static int
LuaCreateSurfTriMeshByRegion( lua_State* L)
{
// 2 o 3 parametri : ParentId, CrvIds [, dTol]
int nParentId ;
LuaCheckParam( L, 1, nParentId)
INTVECTOR vCrvIds ;
LuaCheckParam( L, 2, vCrvIds)
double dLinTol = LIN_TOL_DEF ;
if ( lua_gettop( L) >= 3)
LuaCheckParam( L, 3, dLinTol) ;
LuaClearStack( L) ;
// creo STM riempiendo una regione (piana)
int nId = EgtCreateSurfTriMeshByRegion( nParentId, vCrvIds, dLinTol) ;
// restituisco il risultato
if ( nId != GDB_ID_NULL)
LuaSetReturn( L, nId) ;
@@ -50,25 +76,52 @@ LuaCreateSurfTriMeshByContour( lua_State* L)
static int
LuaCreateSurfTriMeshByExtrusion( lua_State* L)
{
// 4 o 5 o 6 parametri : ParentId, CrvId, vtExtr, bCapEnds [, dTol] [, sRefType]
// 3 o 4 o 5 parametri : ParentId, CrvIds, vtExtr [, dTol] [, sRefType]
int nParentId ;
LuaCheckParam( L, 1, nParentId)
int nCrvId ;
LuaCheckParam( L, 2, nCrvId)
INTVECTOR vCrvIds ;
LuaCheckParam( L, 2, vCrvIds)
Vector3d vtExtr ;
LuaCheckParam( L, 3, vtExtr)
bool bCapEnds ;
LuaCheckParam( L, 4, bCapEnds)
double dLinTol = 0.1 ;
double dLinTol = LIN_TOL_DEF ;
int nRefType = RTY_DEFAULT ;
if ( LuaGetParam( L, 5, dLinTol))
LuaGetRefType( L, 6, nRefType) ;
else
if ( LuaGetParam( L, 4, dLinTol))
LuaGetRefType( L, 5, nRefType) ;
else
LuaGetRefType( L, 4, nRefType) ;
LuaClearStack( L) ;
// creo STM riempiendo un contorno piano
int nId = EgtCreateSurfTriMeshByExtrusion( nParentId, nCrvId, vtExtr.v,
( bCapEnds ? TRUE : FALSE), dLinTol, nRefType) ;
// creo STM estrudendo uno o più percorsi, se piani si possono mettere i tappi
int nId = EgtCreateSurfTriMeshByExtrusion( nParentId, vCrvIds, vtExtr,
dLinTol, nRefType) ;
// restituisco il risultato
if ( nId != GDB_ID_NULL)
LuaSetReturn( L, nId) ;
else
LuaSetReturn( L) ;
return 1 ;
}
//-------------------------------------------------------------------------------
static int
LuaCreateSurfTriMeshByRegionExtrusion( lua_State* L)
{
// 3 o 4 o 5 parametri : ParentId, CrvIds, vtExtr [, dTol] [, sRefType]
int nParentId ;
LuaCheckParam( L, 1, nParentId)
INTVECTOR vCrvIds ;
LuaCheckParam( L, 2, vCrvIds)
Vector3d vtExtr ;
LuaCheckParam( L, 3, vtExtr)
double dLinTol = LIN_TOL_DEF ;
int nRefType = RTY_DEFAULT ;
if ( LuaGetParam( L, 4, dLinTol))
LuaGetRefType( L, 5, nRefType) ;
else
LuaGetRefType( L, 4, nRefType) ;
LuaClearStack( L) ;
// creo STM estrudendo uno o più percorsi, con aggiunta dei tappi
int nId = EgtCreateSurfTriMeshByRegionExtrusion( nParentId, vCrvIds, vtExtr,
dLinTol, nRefType) ;
// restituisco il risultato
if ( nId != GDB_ID_NULL)
LuaSetReturn( L, nId) ;
@@ -126,7 +179,7 @@ LuaCreateSurfTriMeshByScrewing( lua_State* L)
LuaCheckParam( L, 5, dAngRotDeg)
double dMove ;
LuaCheckParam( L, 6, dMove)
double dLinTol = 0.1 ;
double dLinTol = LIN_TOL_DEF ;
int nRefType = RTY_DEFAULT ;
if ( LuaGetParam( L, 7, dLinTol))
LuaGetRefType( L, 8, nRefType) ;
@@ -154,7 +207,7 @@ LuaCreateSurfTriMeshRuled( lua_State* L)
LuaCheckParam( L, 2, nCrvId1)
int nCrvId2 ;
LuaCheckParam( L, 3, nCrvId2)
double dLinTol = 0.1 ;
double dLinTol = LIN_TOL_DEF ;
if ( lua_gettop( L) >= 4)
LuaCheckParam( L, 4, dLinTol) ;
LuaClearStack( L) ;
@@ -173,8 +226,10 @@ bool
LuaInstallGdbCreateSurf( lua_State* L)
{
try {
lua_register( L, "EgtSurfTmByContour", LuaCreateSurfTriMeshByContour) ;
lua_register( L, "EgtSurfTmByFlatContour", LuaCreateSurfTriMeshByFlatContour) ;
lua_register( L, "EgtSurfTmByRegion", LuaCreateSurfTriMeshByRegion) ;
lua_register( L, "EgtSurfTmByExtrusion", LuaCreateSurfTriMeshByExtrusion) ;
lua_register( L, "EgtSurfTmByRegionExtrusion", LuaCreateSurfTriMeshByRegionExtrusion) ;
lua_register( L, "EgtSurfTmByRevolve", LuaCreateSurfTriMeshByRevolve) ;
lua_register( L, "EgtSurfTmByScrewing", LuaCreateSurfTriMeshByScrewing) ;
lua_register( L, "EgtSurfTmRuled", LuaCreateSurfTriMeshRuled) ;
+1 -1
View File
@@ -88,7 +88,7 @@ LuaSurfTmDoSewing( lua_State* L)
if ( lua_gettop( L) >= 2)
LuaCheckParam( L, 2, bErase) ;
LuaClearStack( L) ;
// eseguo inversione superfici
// eseguo cucitura superfici
bool bOk = EgtSurfTmDoSewing( vId, bErase) ;
// restituisco il risultato
LuaSetReturn( L, bOk) ;
+17
View File
@@ -245,6 +245,22 @@ LuaTrimExtendCurveByLen( lua_State* L)
return 1 ;
}
//----------------------------------------------------------------------------
static int
LuaSplitCurve( lua_State* L)
{
// 2 parametri : Id, nParts
int nId ;
LuaCheckParam( L, 1, nId)
int nParts ;
LuaCheckParam( L, 2, nParts)
LuaClearStack( L) ;
// divido la curva nel punto
bool bOk = ( EgtSplitCurve( nId, nParts) != FALSE) ;
LuaSetReturn( L, bOk) ;
return 1 ;
}
//----------------------------------------------------------------------------
static int
LuaSplitCurveAtPoint( lua_State* L)
@@ -333,6 +349,7 @@ LuaInstallGdbModifyCurve( lua_State* L)
lua_register( L, "EgtTrimCurveEndAtParam", LuaTrimCurveEndAtParam) ;
lua_register( L, "EgtTrimCurveStartEndAtParam", LuaTrimCurveStartEndAtParam) ;
lua_register( L, "EgtTrimExtendCurveByLen", LuaTrimExtendCurveByLen) ;
lua_register( L, "EgtSplitCurve", LuaSplitCurve) ;
lua_register( L, "EgtSplitCurveAtPoint", LuaSplitCurveAtPoint) ;
lua_register( L, "EgtModifyCurveArcRadius", LuaModifyCurveArcRadius) ;
lua_register( L, "EgtExplodeCurveCompo", LuaExplodeCurveCompo) ;