diff --git a/API.h b/API.h index 9a7e3fe..25d7389 100644 --- a/API.h +++ b/API.h @@ -56,27 +56,37 @@ int EgtCreateCurveCompoFromPoints( int nParentId, const PolyLine& PL, int nRefT 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) ; +int EgtCreateSurfTmByRegion( int nParentId, INTVECTOR& vCrvIds, double dLinTol) ; +int EgtCreateSurfTmByExtrusion( int nParentId, INTVECTOR& vCrvIds, const Vector3d& vtExtr, + double dLinTol, int nRefType) ; +int EgtCreateSurfTmByRegionExtrusion( int nParentId, INTVECTOR& vCrvIds, const Vector3d& vtExtr, + double dLinTol, int nRefType) ; +int EgtCreateSurfTmByTriangles( int nParentId, const INTVECTOR& vIds, bool bErase) ; +int EgtCreateSurfTmBySewing( int nParentId, const INTVECTOR& vIds, bool bErase) ; //--------------------------- GdbModify -------------------------------------- bool EgtChangeGroupFrame( int nId, const Frame3d& frNewRef, int nRefType) ; -bool EgtSurfTmDoSewing( const INTVECTOR& vIds, bool bErase) ; bool EgtModifyText( int nId, const std::string& sNewText) ; bool EgtChangeTextFont( int nId, const std::string& sNewFont) ; //--------------------------- GdbModifyCurve --------------------------------- -bool EgtModifyCurveExtrusion( INTVECTOR& vIds, const Vector3d& vtExtr, int nRefType) ; -bool EgtModifyCurveThickness( INTVECTOR& vIds, double dThick) ; +bool EgtInvertCurve( const INTVECTOR& vIds) ; +bool EgtModifyCurveExtrusion( const INTVECTOR& vIds, const Vector3d& vtExtr, int nRefType) ; +bool EgtModifyCurveThickness( const INTVECTOR& vIds, double dThick) ; + +//--------------------------- GdbModifySurf ---------------------------------- +bool EgtInvertSurface( const INTVECTOR& vIds) ; //--------------------------- GdbObjects ------------------------------------- int EgtGetFirstNameInGroup( int nGroupId, const std::string& sName) ; int EgtGetNextName( int nId, const std::string& sName) ; +bool EgtErase( const INTVECTOR& vIds) ; //--------------------------- GdbObjAttribs ---------------------------------- +bool EgtSetStatus( const INTVECTOR& vIds, int nStat) ; +bool EgtSetColor( const INTVECTOR& vIds, const Color& cCol, bool bSetAlpha) ; +bool EgtSetAlpha( const INTVECTOR& vIds, int nAlpha) ; +bool EgtResetColor( const INTVECTOR& vIds) ; bool EgtSetName( int nId, const std::string& sName) ; bool EgtGetName( int nId, std::string& sName) ; bool EgtSetInfo( int nId, const std::string& sKey, const std::string& sInfo) ; @@ -104,6 +114,12 @@ bool EgtCurveExtrusion( int nId, int nRefId, Vector3d& vtExtr) ; // EgtCurveThickness vedi EinAPI.h bool EgtCurveArcNormVersor( int nId, int nRefId, Vector3d& vtNorm) ; bool EgtCurveCompoCenter( int nId, int nSimpCrv, int nRefId, Point3d& ptCen) ; +bool EgtSurfTmFacetNearestEndPoint( int nId, int nFacet, const Point3d& ptNear, int nRefId, + Point3d& ptEnd, Vector3d& vtN) ; +bool EgtSurfTmFacetNearestMidPoint( int nId, int nFacet, const Point3d& ptNear, int nRefId, + Point3d& ptMid, Vector3d& vtN) ; +bool EgtSurfTmFacetCenter( int nId, int nFacet, int nRefId, Point3d& ptCen, Vector3d& vtN) ; +bool EgtSurfTmFacetNormVersor( int nId, int nFacet, int nRefId, Vector3d& vtNorm) ; bool EgtExtTextNormVersor( int nId, int nRefId, Vector3d& vtNorm) ; bool EgtPointToIdGlob( Point3d& ptP, int nId) ; bool EgtPointToIdLoc( Point3d& ptP, int nId) ; diff --git a/API_GdbCreateCurve.cpp b/API_GdbCreateCurve.cpp index 991a03a..5d53a30 100644 --- a/API_GdbCreateCurve.cpp +++ b/API_GdbCreateCurve.cpp @@ -1216,27 +1216,31 @@ MyCreateCurveCompoByChain( int nParentId, const INTVECTOR& vIds, double dToler = 10 * EPS_SMALL ; ChainCurves chainC ; chainC.Init( true, dToler, int( vIds.size())) ; - INTVECTOR::const_iterator Iter ; - for ( Iter = vIds.begin() ; Iter != vIds.end() ; ++Iter) { - // recupero la curva e il suo riferimento - ICurve* pCrv = GetCurve( pGeomDB->GetGeoObj( *Iter)) ; - if ( pCrv == nullptr) - return GDB_ID_NULL ; - Frame3d frCrv ; - if ( ! pGeomDB->GetGlobFrame( *Iter, frCrv)) - return GDB_ID_NULL ; - // recupero i dati della curva necessari al concatenamento e li assegno - Point3d ptStart, ptEnd ; - Vector3d vtStart, vtEnd ; - if ( ! pCrv->GetStartPoint( ptStart) || ! pCrv->GetStartDir( vtStart) || - ! pCrv->GetEndPoint( ptEnd) || ! pCrv->GetEndDir( vtEnd)) - return GDB_ID_NULL ; - ptStart.LocToLoc( frCrv, frDest) ; - vtStart.LocToLoc( frCrv, frDest) ; - ptEnd.LocToLoc( frCrv, frDest) ; - vtEnd.LocToLoc( frCrv, frDest) ; - if ( ! chainC.AddCurve( *Iter, ptStart, vtStart, ptEnd, vtEnd)) - return GDB_ID_NULL ; + for ( size_t i = 0 ; i < vIds.size() ; ++ i) { + int nId = (( vIds[i] != GDB_ID_SEL) ? vIds[i] : pGeomDB->GetFirstSelectedObj()) ; + while ( nId != GDB_ID_NULL) { + // recupero la curva e il suo riferimento + ICurve* pCrv = GetCurve( pGeomDB->GetGeoObj( nId)) ; + if ( pCrv == nullptr) + return GDB_ID_NULL ; + Frame3d frCrv ; + if ( ! pGeomDB->GetGlobFrame( nId, frCrv)) + return GDB_ID_NULL ; + // recupero i dati della curva necessari al concatenamento e li assegno + Point3d ptStart, ptEnd ; + Vector3d vtStart, vtEnd ; + if ( ! pCrv->GetStartPoint( ptStart) || ! pCrv->GetStartDir( vtStart) || + ! pCrv->GetEndPoint( ptEnd) || ! pCrv->GetEndDir( vtEnd)) + return GDB_ID_NULL ; + ptStart.LocToLoc( frCrv, frDest) ; + vtStart.LocToLoc( frCrv, frDest) ; + ptEnd.LocToLoc( frCrv, frDest) ; + vtEnd.LocToLoc( frCrv, frDest) ; + if ( ! chainC.AddCurve( nId, ptStart, vtStart, ptEnd, vtEnd)) + return GDB_ID_NULL ; + // passo al successivo + nId = (( vIds[i] != GDB_ID_SEL) ? GDB_ID_NULL : pGeomDB->GetNextSelectedObj()) ; + } } // recupero i percorsi concatenati int nFirstId = GDB_ID_NULL ; @@ -1251,10 +1255,9 @@ MyCreateCurveCompoByChain( int nParentId, const INTVECTOR& vIds, Vector3d vtExtr = CalcExtrusion( pGeomDB, nParentId, nRefType) ; double dThick = 0 ; // recupero le curve semplici e le inserisco nella curva composita - INTVECTOR::iterator Iter ; - for ( Iter = vId2s.begin() ; Iter != vId2s.end() ; ++Iter) { - int nId = abs( *Iter) ; - bool bInvert = ( *Iter < 0) ; + for ( size_t i = 0 ; i < vId2s.size() ; ++ i) { + int nId = abs( vId2s[i]) ; + bool bInvert = ( vId2s[i] < 0) ; // recupero la curva e il suo riferimento ICurve* pCrv = GetCurve( pGeomDB->GetGeoObj( nId)) ; if ( pCrv == nullptr) @@ -1300,9 +1303,13 @@ MyCreateCurveCompoByChain( int nParentId, const INTVECTOR& vIds, } // se richiesto e ok, cancello le curve originali if ( bErase && nFirstId != GDB_ID_NULL) { - for ( Iter = vIds.begin() ; Iter != vIds.end() ; ++Iter) { - if ( ! pGeomDB->Erase( *Iter)) - return GDB_ID_NULL ; + for ( size_t i = 0 ; i < vIds.size() ; ++ i) { + int nId = (( vIds[i] != GDB_ID_SEL) ? vIds[i] : pGeomDB->GetFirstSelectedObj()) ; + while ( nId != GDB_ID_NULL) { + pGeomDB->Erase( nId) ; + // passo al successivo + nId = (( vIds[i] != GDB_ID_SEL) ? GDB_ID_NULL : pGeomDB->GetFirstSelectedObj()) ; + } } } // restituisco l'identificativo della prima nuova entità @@ -1320,11 +1327,9 @@ EgtCreateCurveCompoByChain( int nParentId, const INTVECTOR& vIds, // se richiesto, salvo il comando Lua equivalente if ( IsCmdLog()) { string sIds ; - for ( size_t i = 0 ; i < vIds.size() ; ++ i) { - if ( i > 0) - sIds += "," ; - sIds += ToString( vIds[i]) ; - } + for ( size_t i = 0 ; i < vIds.size() ; ++ i) + sIds += ( vIds[i] != GDB_ID_SEL ? ToString( vIds[i]) : "GDB_ID_SEL") + "," ; + sIds.pop_back() ; string sLua = "EgtCurveCompoByChain(" + ToString( nParentId) + ",{" + sIds + "},{" + ToString( ptNear) + "}," + diff --git a/API_GdbCreateSurf.cpp b/API_GdbCreateSurf.cpp index 33c8707..154a281 100644 --- a/API_GdbCreateSurf.cpp +++ b/API_GdbCreateSurf.cpp @@ -20,6 +20,7 @@ #include "/EgtDev/Include/EInAPI.h" #include "/EgtDev/Include/EInConst.h" #include "/EgtDev/Include/EGkStmFromCurves.h" +#include "/EgtDev/Include/EGkStmFromTriangleSoup.h" #include "/EgtDev/Include/EgkStringUtils3d.h" #include "/EgtDev/Include/EgkCurveLocal.h" #include "/EgtDev/Include/EgtPointerOwner.h" @@ -28,7 +29,7 @@ using namespace std ; //------------------------------------------------------------------------------- int -__stdcall EgtCreateSurfTriMeshByFlatContour( int nParentId, int nCrvId, double dLinTol) +__stdcall EgtCreateSurfTmByFlatContour( int nParentId, int nCrvId, double dLinTol) { IGeomDB* pGeomDB = GetCurrGeomDB() ; VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL) @@ -58,19 +59,19 @@ __stdcall EgtCreateSurfTriMeshByFlatContour( int nParentId, int nCrvId, double d //------------------------------------------------------------------------------- int -__stdcall EgtCreateSurfTriMeshByRegion( int nParentId, int nNumId, const int nCrvIds[], double dLinTol) +__stdcall EgtCreateSurfTmByRegion( 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) ; + return EgtCreateSurfTmByRegion( nParentId, vCrvIds, dLinTol) ; } //------------------------------------------------------------------------------- int -EgtCreateSurfTriMeshByRegion( int nParentId, INTVECTOR& vCrvIds, double dLinTol) +EgtCreateSurfTmByRegion( int nParentId, INTVECTOR& vCrvIds, double dLinTol) { IGeomDB* pGeomDB = GetCurrGeomDB() ; VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL) @@ -114,21 +115,21 @@ EgtCreateSurfTriMeshByRegion( int nParentId, INTVECTOR& vCrvIds, double dLinTol) //------------------------------------------------------------------------------- int -__stdcall EgtCreateSurfTriMeshByExtrusion( int nParentId, int nNumId, const int nCrvIds[], - const double vtExtr[3], double dLinTol, int nRefType) +__stdcall EgtCreateSurfTmByExtrusion( 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) ; + return EgtCreateSurfTmByExtrusion( nParentId, vCrvIds, vtExtr, dLinTol, nRefType) ; } //------------------------------------------------------------------------------- int -EgtCreateSurfTriMeshByExtrusion( int nParentId, INTVECTOR& vCrvIds, const Vector3d& vtExtr, - double dLinTol, int nRefType) +EgtCreateSurfTmByExtrusion( int nParentId, INTVECTOR& vCrvIds, const Vector3d& vtExtr, + double dLinTol, int nRefType) { IGeomDB* pGeomDB = GetCurrGeomDB() ; VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL) @@ -180,21 +181,21 @@ EgtCreateSurfTriMeshByExtrusion( int nParentId, INTVECTOR& vCrvIds, const Vector //------------------------------------------------------------------------------- int -__stdcall EgtCreateSurfTriMeshByRegionExtrusion( int nParentId, int nNumId, const int nCrvIds[], - const double vtExtr[3], double dLinTol, int nRefType) +__stdcall EgtCreateSurfTmByRegionExtrusion( 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) ; + return EgtCreateSurfTmByRegionExtrusion( nParentId, vCrvIds, vtExtr, dLinTol, nRefType) ; } //------------------------------------------------------------------------------- int -EgtCreateSurfTriMeshByRegionExtrusion( int nParentId, INTVECTOR& vCrvIds, const Vector3d& vtExtr, - double dLinTol, int nRefType) +EgtCreateSurfTmByRegionExtrusion( int nParentId, INTVECTOR& vCrvIds, const Vector3d& vtExtr, + double dLinTol, int nRefType) { IGeomDB* pGeomDB = GetCurrGeomDB() ; VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL) @@ -240,9 +241,9 @@ EgtCreateSurfTriMeshByRegionExtrusion( int nParentId, INTVECTOR& vCrvIds, const //------------------------------------------------------------------------------- int -__stdcall EgtCreateSurfTriMeshByRevolve( int nParentId, int nCrvId, - const double ptAx[3], const double vtAx[3], - BOOL bCapEnds, double dLinTol, int nRefType) +__stdcall EgtCreateSurfTmByRevolve( int nParentId, int nCrvId, + const double ptAx[3], const double vtAx[3], + BOOL bCapEnds, double dLinTol, int nRefType) { IGeomDB* pGeomDB = GetCurrGeomDB() ; VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL) @@ -279,9 +280,9 @@ __stdcall EgtCreateSurfTriMeshByRevolve( int nParentId, int nCrvId, //------------------------------------------------------------------------------- int -__stdcall EgtCreateSurfTriMeshByScrewing( int nParentId, int nCrvId, - const double ptAx[3], const double vtAx[3], - double dAngRotDeg, double dMove, double dLinTol, int nRefType) +__stdcall EgtCreateSurfTmByScrewing( int nParentId, int nCrvId, + const double ptAx[3], const double vtAx[3], + double dAngRotDeg, double dMove, double dLinTol, int nRefType) { IGeomDB* pGeomDB = GetCurrGeomDB() ; VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL) @@ -319,7 +320,7 @@ __stdcall EgtCreateSurfTriMeshByScrewing( int nParentId, int nCrvId, //------------------------------------------------------------------------------- int -__stdcall EgtCreateSurfTriMeshRuled( int nParentId, int nCrvId1, int nCrvId2, double dLinTol) +__stdcall EgtCreateSurfTmRuled( int nParentId, int nCrvId1, int nCrvId2, double dLinTol) { IGeomDB* pGeomDB = GetCurrGeomDB() ; VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL) @@ -350,3 +351,172 @@ __stdcall EgtCreateSurfTriMeshRuled( int nParentId, int nCrvId1, int nCrvId2, do // restituisco l'identificativo della nuova entità return nNewId ; } + +//---------------------------------------------------------------------------- +int +__stdcall EgtCreateSurfTmByTriangles( int nParentId, int nNumId, const int nIds[], BOOL bErase) +{ + INTVECTOR vIds ; + vIds.reserve( nNumId) ; + for ( int i = 0 ; i < nNumId ; ++i) { + vIds.push_back( nIds[i]) ; + } + return EgtCreateSurfTmByTriangles( nParentId, vIds, ( bErase != FALSE)) ; +} + +//---------------------------------------------------------------------------- +int +EgtCreateSurfTmByTriangles( int nParentId, const INTVECTOR& vIds, bool bErase) +{ + IGeomDB* pGeomDB = GetCurrGeomDB() ; + VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL) + // almeno un oggetto nell'elenco + bool bOk = ( vIds.size() > 0) ; + // recupero il riferimento locale + Frame3d frLoc ; + bOk = bOk && pGeomDB->GetGroupGlobFrame( nParentId, frLoc) ; + // Costruttore di trimesh da insieme disordinato di triangoli + StmFromTriangleSoup StmFts ; + bOk = bOk && StmFts.Start() ; + // Recupero tutti i triangoli delle superfici sorgenti e li inserisco nella nuova + for ( size_t i = 0 ; i < vIds.size() ; ++ i) { + int nId = (( vIds[i] != GDB_ID_SEL) ? vIds[i] : pGeomDB->GetFirstSelectedObj()) ; + while ( nId != GDB_ID_NULL) { + // recupero la superficie sorgente + const ISurfTriMesh* pStmS = GetSurfTriMesh( pGeomDB->GetGeoObj( nId)) ; + bOk = bOk && ( pStmS != nullptr) ; + // recupero il riferimento della superficie sorgente + Frame3d frSou ; + bOk = bOk && pGeomDB->GetGlobFrame( nId, frSou) ; + // recupero tutti i triangoli + Triangle3d Tria ; + int nT = ( bOk ? pStmS->GetFirstTriangle( Tria) : SVT_NULL) ; + while ( nT != SVT_NULL) { + // aggiusto per i sistemi di riferimento + Tria.LocToLoc( frSou, frLoc) ; + // inserisco il triangolo nella nuova superficie + if ( ! StmFts.AddTriangle( Tria)) + return false ; + // passo al triangolo successivo + nT = pStmS->GetNextTriangle( nT, Tria) ; + } + // passo al successivo + nId = (( vIds[i] != GDB_ID_SEL) ? GDB_ID_NULL : pGeomDB->GetNextSelectedObj()) ; + } + } + // valido la superficie e calcolo le adiacenze + bOk = bOk && StmFts.End() ; + // inserisco la superficie trimesh nel DB + PtrOwner pStm( StmFts.GetSurf()) ; + int nNewId = ( bOk ? pGeomDB->AddGeoObj( GDB_ID_NULL, nParentId, Release( pStm)) : GDB_ID_NULL) ; + // se richiesto, cancello le superfici originali + if ( nNewId != GDB_ID_NULL && bErase) { + for ( size_t i = 0 ; i < vIds.size() ; ++ i) { + int nId = (( vIds[i] != GDB_ID_SEL) ? vIds[i] : pGeomDB->GetFirstSelectedObj()) ; + while ( nId != GDB_ID_NULL) { + pGeomDB->Erase( nId) ; + // passo al successivo + nId = (( vIds[i] != GDB_ID_SEL) ? GDB_ID_NULL : pGeomDB->GetFirstSelectedObj()) ; + } + } + } + EgtSetModified() ; + // se richiesto, salvo il comando Lua equivalente + if ( IsCmdLog()) { + string sIds ; + for ( size_t i = 0 ; i < vIds.size() ; ++ i) + sIds += ( vIds[i] != GDB_ID_SEL ? ToString( vIds[i]) : "GDB_ID_SEL") + "," ; + sIds.pop_back() ; + string sLua = "EgtSurfTmByTriangles(" + ToString( nParentId) + ",{" + + sIds + "}," + + ( bErase ? "true" : "false") + ")" + + " -- Ok=" + ToString( bOk) ; + LOG_INFO( GetCmdLogger(), sLua.c_str()) ; + } + // restituisco il risultato + return nNewId ; +} + +//---------------------------------------------------------------------------- +int +__stdcall EgtCreateSurfTmBySewing( int nParentId, int nNumId, const int nIds[], BOOL bErase) +{ + INTVECTOR vIds ; + vIds.reserve( nNumId) ; + for ( int i = 0 ; i < nNumId ; ++i) { + vIds.push_back( nIds[i]) ; + } + return EgtCreateSurfTmBySewing( nParentId, vIds, ( bErase != FALSE)) ; +} + +//---------------------------------------------------------------------------- +int +EgtCreateSurfTmBySewing( int nParentId, const INTVECTOR& vIds, bool bErase) +{ + IGeomDB* pGeomDB = GetCurrGeomDB() ; + VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL) + // almeno un oggetto nell'elenco + bool bOk = ( vIds.size() > 0) ; + // recupero il riferimento locale + Frame3d frLoc ; + bOk = bOk && pGeomDB->GetGroupGlobFrame( nParentId, frLoc) ; + // puntatore alla nuova superficie + PtrOwner pStm( CreateSurfTriMesh()) ; + bOk = bOk && ! IsNull( pStm) ; + // esecuzione + bool bFirst = true ; + for ( size_t i = 0 ; bOk && i < vIds.size() ; ++ i) { + int nId = (( vIds[i] != GDB_ID_SEL) ? vIds[i] : pGeomDB->GetFirstSelectedObj()) ; + while ( nId != GDB_ID_NULL) { + // recupero la superficie da cucire + const ISurfTriMesh* pStmS = GetSurfTriMesh( pGeomDB->GetGeoObj( nId)) ; + bOk = bOk && ( pStmS != nullptr) ; + // recupero il riferimento + Frame3d frStmS ; + bOk = bOk && pGeomDB->GetGlobFrame( nId, frStmS) ; + // lo esprimo rispetto a quello della prima superficie + frStmS.ToLoc( frLoc) ; + // se è la prima, copio + if ( bFirst) { + bOk = bOk && pStm->CopyFrom( pStmS) ; + bOk = bOk && pStm->ToGlob( frStmS) ; + bFirst = false ; + } + // altrimenti eseguo la cucitura + else + bOk = bOk && pStm->DoSewing( *pStmS, frStmS) ; + // passo alla successiva + nId = (( vIds[i] != GDB_ID_SEL) ? GDB_ID_NULL : pGeomDB->GetNextSelectedObj()) ; + } + } + // compatto + bOk = bOk && pStm->DoCompacting() ; + // inserisco la superficie trimesh nel DB + int nNewId = ( bOk ? pGeomDB->AddGeoObj( GDB_ID_NULL, nParentId, Release( pStm)) : GDB_ID_NULL) ; + // se richiesto, cancello le superfici originali + if ( nNewId != GDB_ID_NULL && bErase) { + for ( size_t i = 0 ; i < vIds.size() ; ++ i) { + int nId = (( vIds[i] != GDB_ID_SEL) ? vIds[i] : pGeomDB->GetFirstSelectedObj()) ; + while ( nId != GDB_ID_NULL) { + pGeomDB->Erase( nId) ; + // passo al successivo + nId = (( vIds[i] != GDB_ID_SEL) ? GDB_ID_NULL : pGeomDB->GetFirstSelectedObj()) ; + } + } + } + EgtSetModified() ; + // se richiesto, salvo il comando Lua equivalente + if ( IsCmdLog()) { + string sIds ; + for ( size_t i = 0 ; i < vIds.size() ; ++ i) + sIds += ( vIds[i] != GDB_ID_SEL ? ToString( vIds[i]) : "GDB_ID_SEL") + "," ; + sIds.pop_back() ; + string sLua = "EgtSurfTmBySewing(" + ToString( nParentId) + ",{" + + sIds + "}," + + ( bErase ? "true" : "false") + ")" + + " -- Ok=" + ToString( bOk) ; + LOG_INFO( GetCmdLogger(), sLua.c_str()) ; + } + // restituisco il risultato + return nNewId ; +} diff --git a/API_GdbModify.cpp b/API_GdbModify.cpp index 9baf407..4c17fed 100644 --- a/API_GdbModify.cpp +++ b/API_GdbModify.cpp @@ -22,7 +22,6 @@ #include "/EgtDev/Include/EInConst.h" #include "/EgtDev/Include/EgkGeoPoint3d.h" #include "/EgtDev/Include/EgkGeoVector3d.h" -#include "/EgtDev/Include/EgkSurfTriMesh.h" #include "/EgtDev/Include/EgkExtText.h" #include "/EgtDev/Include/EGkStringUtils3d.h" #include "/EgtDev/Include/EGnStringConverter.h" @@ -112,108 +111,6 @@ __stdcall EgtChangeVectorBase( int nId, const double ptB[3], int nRefType) return ( bOk ? TRUE : FALSE) ; } -//---------------------------------------------------------------------------- -BOOL -__stdcall EgtInvertSurface( int nId) -{ - IGeomDB* pGeomDB = GetCurrGeomDB() ; - VERIFY_GEOMDB( pGeomDB, FALSE) - bool bOk = true ; - // eseguo inversione singola - if ( nId != GDB_ID_SEL) { - // recupero la superficie e la inverto - ISurf* pSurf = GetSurf( pGeomDB->GetGeoObj( nId)) ; - if ( pSurf != nullptr && ! pSurf->Invert()) - bOk = false ; - } - // eseguo inversione dei selezionati - else { - int nI = pGeomDB->GetFirstSelectedObj() ; - while ( nI != GDB_ID_NULL && bOk) { - // recupero la superficie e la inverto - ISurf* pSurf = GetSurf( pGeomDB->GetGeoObj( nI)) ; - if ( pSurf != nullptr && ! pSurf->Invert()) - bOk = false ; - // passo alla successiva - nI = pGeomDB->GetNextSelectedObj() ; - } - } - EgtSetModified() ; - // se richiesto, salvo il comando Lua equivalente - if ( IsCmdLog()) { - string sLua = "EgtInvertSurf(" + ( nId != GDB_ID_SEL ? ToString( nId) : "GDB_ID_SEL") + ")" + - " -- Ok=" + ToString( bOk) ; - LOG_INFO( GetCmdLogger(), sLua.c_str()) ; - } - // restituisco risultato - return ( bOk ? TRUE : FALSE) ; -} - -//---------------------------------------------------------------------------- -BOOL -__stdcall EgtSurfTmDoSewing( int nNumId, const int nIds[], BOOL bErase) -{ - INTVECTOR vIds ; - vIds.reserve( nNumId) ; - for ( int i = 0 ; i < nNumId ; ++i) { - vIds.push_back( nIds[i]) ; - } - return ( EgtSurfTmDoSewing( vIds, ( bErase != FALSE)) ? TRUE : FALSE) ; -} - -//---------------------------------------------------------------------------- -bool -EgtSurfTmDoSewing( const INTVECTOR& vIds, bool bErase) -{ - // --- tutte le superfici vengono cucite alla prima --- - IGeomDB* pGeomDB = GetCurrGeomDB() ; - VERIFY_GEOMDB( pGeomDB, false) - // almeno un oggetto nell'elenco - bool bOk = ( vIds.size() > 0) ; - // recupero la prima superficie - ISurfTriMesh* pStm = GetSurfTriMesh( pGeomDB->GetGeoObj( vIds[0])) ; - bOk = bOk && ( pStm != nullptr) ; - // ne recupero il riferimento - Frame3d frStm ; - bOk = bOk && pGeomDB->GetGlobFrame( vIds[0], frStm) ; - // esecuzione - for ( size_t i = 1 ; bOk && i < vIds.size() ; ++ i) { - // recupero la superficie da cucire - const ISurfTriMesh* pStmS = GetSurfTriMesh( pGeomDB->GetGeoObj( vIds[i])) ; - bOk = bOk && ( pStmS != nullptr) ; - // recupero il riferimento - Frame3d frStmS ; - bOk = bOk && pGeomDB->GetGlobFrame( vIds[i], frStmS) ; - // lo esprimo rispetto a quello della prima superficie - frStmS.ToLoc( frStm) ; - // 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) - pGeomDB->Erase( vIds[i]) ; - } - EgtSetModified() ; - // se richiesto, salvo il comando Lua equivalente - if ( IsCmdLog()) { - string sIds ; - for ( size_t i = 0 ; i < vIds.size() ; ++ i) { - if ( i > 0) - sIds += "," ; - sIds += vIds[i] ; - } - string sLua = "EgtSurfTmDoSewing({" + sIds + "}," + - ( bErase ? "true" : "false") + ")" + - " -- Ok=" + ToString( bOk) ; - LOG_INFO( GetCmdLogger(), sLua.c_str()) ; - } - // restituisco il risultato - return bOk ; -} - //------------------------------------------------------------------------------- BOOL __stdcall EgtModifyText( int nId, const wchar_t* wsNewText) @@ -300,7 +197,7 @@ __stdcall EgtExplodeText( int nId) bOk = bOk && pTXT->GetOutline( lstPCRV) ; // inserisco le curve nella stessa posizione del testo ICURVEPLIST::iterator iIter ; - for ( iIter = lstPCRV.begin() ; bOk && iIter != lstPCRV.end() ; ++ iIter) { + for ( iIter = lstPCRV.begin() ; iIter != lstPCRV.end() ; ++ iIter) { // inserisco la curva nello stesso gruppo e nello stesso posto del GeomDB int nCrvId = pGeomDB->InsertGeoObj( GDB_ID_NULL, nId, GDB_BEFORE, (*iIter)) ; if ( nCrvId == GDB_ID_NULL) diff --git a/API_GdbModifyCurve.cpp b/API_GdbModifyCurve.cpp index 9cecc5c..ab18db6 100644 --- a/API_GdbModifyCurve.cpp +++ b/API_GdbModifyCurve.cpp @@ -34,38 +34,44 @@ using namespace std ; //---------------------------------------------------------------------------- BOOL __stdcall EgtInvertCurve( int nId) +{ + INTVECTOR vIds ; + vIds.push_back( nId) ; + return ( EgtInvertCurve( vIds) ? TRUE : FALSE) ; +} + +//---------------------------------------------------------------------------- +bool +EgtInvertCurve( const INTVECTOR& vIds) { IGeomDB* pGeomDB = GetCurrGeomDB() ; - VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL) + VERIFY_GEOMDB( pGeomDB, false) + // eseguo inversione bool bOk = true ; - // eseguo inversione singola - if ( nId != GDB_ID_SEL) { - // recupero la curva e la inverto - ICurve* pCurve = GetCurve( pGeomDB->GetGeoObj( nId)) ; - if ( pCurve != nullptr && ! pCurve->Invert()) - bOk = false ; - } - // eseguo inversione dei selezionati - else { - int nI = pGeomDB->GetFirstSelectedObj() ; - while ( nI != GDB_ID_NULL && bOk) { + 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 curva e la inverto - ICurve* pCurve = GetCurve( pGeomDB->GetGeoObj( nI)) ; + ICurve* pCurve = GetCurve( pGeomDB->GetGeoObj( nId)) ; if ( pCurve != nullptr && ! pCurve->Invert()) bOk = false ; // passo alla successiva - nI = pGeomDB->GetNextSelectedObj() ; + nId = (( vIds[i] != GDB_ID_SEL) ? GDB_ID_NULL : pGeomDB->GetNextSelectedObj()) ; } } EgtSetModified() ; // se richiesto, salvo il comando Lua equivalente if ( IsCmdLog()) { - string sLua = "EgtInvertCurve(" + ( nId != GDB_ID_SEL ? ToString( nId): "GDB_ID_SEL") + ")" + + string sIds ; + for ( size_t i = 0 ; i < vIds.size() ; ++ i) + sIds += ( vIds[i] != GDB_ID_SEL ? ToString( vIds[i]) : "GDB_ID_SEL") + "," ; + sIds.pop_back() ; + string sLua = "EgtInvertCurve({" + sIds + "})" + " -- Ok=" + ToString( bOk) ; LOG_INFO( GetCmdLogger(), sLua.c_str()) ; } // restituisco risultato - return ( bOk ? TRUE : FALSE) ; + return bOk ; } //---------------------------------------------------------------------------- @@ -203,7 +209,7 @@ __stdcall EgtModifyCurveExtrusion( int nId, const double vtExtr[3], int nRefType //---------------------------------------------------------------------------- bool -EgtModifyCurveExtrusion( INTVECTOR& vIds, const Vector3d& vtExtr, int nRefType) +EgtModifyCurveExtrusion( const INTVECTOR& vIds, const Vector3d& vtExtr, int nRefType) { IGeomDB* pGeomDB = GetCurrGeomDB() ; VERIFY_GEOMDB( pGeomDB, false) @@ -285,7 +291,7 @@ __stdcall EgtModifyCurveThickness( int nId, double dThick) //---------------------------------------------------------------------------- bool -EgtModifyCurveThickness( INTVECTOR& vIds, double dThick) +EgtModifyCurveThickness( const INTVECTOR& vIds, double dThick) { IGeomDB* pGeomDB = GetCurrGeomDB() ; VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL) diff --git a/API_GdbModifySurf.cpp b/API_GdbModifySurf.cpp new file mode 100644 index 0000000..54ca937 --- /dev/null +++ b/API_GdbModifySurf.cpp @@ -0,0 +1,115 @@ +//---------------------------------------------------------------------------- +// EgalTech 2015-2015 +//---------------------------------------------------------------------------- +// File : API_ModifySurf.cpp Data : 09.03.15 Versione : 1.6b6 +// Contenuto : Funzioni di modifica delle superfici per API. +// +// +// +// Modifiche : 09.03.15 DS Creazione modulo. +// +// +//---------------------------------------------------------------------------- + +//--------------------------- 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" + +using namespace std ; + +//---------------------------------------------------------------------------- +BOOL +__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 sIds ; + for ( size_t i = 0 ; i < vIds.size() ; ++ i) + sIds += ( vIds[i] != GDB_ID_SEL ? ToString( vIds[i]) : "GDB_ID_SEL") + "," ; + sIds.pop_back() ; + string sLua = "EgtInvertSurf({" + sIds + "})" + + " -- Ok=" + ToString( bOk) ; + LOG_INFO( GetCmdLogger(), sLua.c_str()) ; + } + // restituisco risultato + return bOk ; +} + +//---------------------------------------------------------------------------- +int +__stdcall EgtExtractSurfTmFacetLoops( int nId, int nFacet, int nDestGrpId) +{ + 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 ; + for ( size_t i = 0 ; i < vPL.size() ; ++ i) { + // creo la curva + PtrOwner 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 ; + } + EgtSetModified() ; + // se richiesto, salvo il comando Lua equivalente + if ( IsCmdLog()) { + string sLua = "EgtExtractSurfTmFacetLoops(" + ToString( nId) + ",{" + + ToString( nFacet) + "," + + ToString( nDestGrpId) + ")" + + " -- Id=" + ToString( nFirstId) ; + LOG_INFO( GetCmdLogger(), sLua.c_str()) ; + } + // restituisco l'identificativo della nuova entità + return nFirstId ; +} diff --git a/API_GdbObjAttribs.cpp b/API_GdbObjAttribs.cpp index 53ec26e..e24a946 100644 --- a/API_GdbObjAttribs.cpp +++ b/API_GdbObjAttribs.cpp @@ -126,35 +126,68 @@ __stdcall EgtGetCalcMode( int nId, int* pnMode) //----------------------------------------------------------------------------- BOOL __stdcall EgtSetStatus( int nId, int nStat) +{ + INTVECTOR vIds ; + vIds.push_back( nId) ; + return ( EgtSetStatus( vIds, nStat) ? TRUE : FALSE) ; +} + +//----------------------------------------------------------------------------- +bool +EgtSetStatus( const INTVECTOR& vIds, int nStat) { IGeomDB* pGeomDB = GetCurrGeomDB() ; - VERIFY_GEOMDB( pGeomDB, FALSE) - // imposto il modo - bool bOk = pGeomDB->SetStatus( nId, nStat) ; - // se nascosto pezzo corrente o layer corrente - if ( nStat == GDB_ST_OFF) { - int nCurrPartId = EgtGetCurrPart() ; - if ( nId == nCurrPartId) - EgtResetCurrPartLayer() ; - else if ( nId == EgtGetCurrLayer()) - EgtSetCurrPartLayer( nCurrPartId, EgtGetFirstVisibleLayer( nCurrPartId)) ; + VERIFY_GEOMDB( pGeomDB, false) + // recupero pezzo e layer correnti + bool bCurrPartOff = false ; + bool bCurrLayerOff = false ; + int nCurrPartId = EgtGetCurrPart() ; + int nCurrLayerId = EgtGetCurrLayer() ; + // ciclo sul vettore degli identificativi + bool bOk = true ; + for ( size_t i = 0 ; i < vIds.size() && bOk ; ++ i) { + // impostazione stato + int nId = (( vIds[i] != GDB_ID_SEL) ? vIds[i] : pGeomDB->GetFirstSelectedObj()) ; + while ( nId != GDB_ID_NULL) { + // imposto il modo + if ( ! pGeomDB->SetStatus( nId, nStat)) + bOk = false ; + // se nascosto pezzo corrente o layer corrente + if ( nStat == GDB_ST_OFF) { + if ( nId == nCurrPartId) + bCurrPartOff = true ; + else if ( nId == nCurrLayerId) + bCurrLayerOff = true ; + } + // passo al successivo + nId = (( vIds[i] != GDB_ID_SEL) ? GDB_ID_NULL : pGeomDB->GetNextSelectedObj()) ; + } } + // se pezzo o layer correnti da rideterminare + if ( bCurrPartOff) + EgtResetCurrPartLayer() ; + else if ( bCurrLayerOff) + EgtSetCurrPartLayer( nCurrPartId, EgtGetFirstVisibleLayer( nCurrPartId)) ; // dichiaro progetto modificato EgtSetModified() ; // se richiesto, salvo il comando Lua equivalente if ( IsCmdLog()) { + string sIds ; + for ( size_t i = 0 ; i < vIds.size() ; ++ i) + sIds += ( vIds[i] != GDB_ID_SEL ? ToString( vIds[i]) : "GDB_ID_SEL") + "," ; + sIds.pop_back() ; string sStat = "'ON'" ; if ( nStat == GDB_ST_SEL) sStat = "'SEL'" ; else if ( nStat == GDB_ST_OFF) sStat = "'OFF'" ; - string sLua = "EgtSetStatus(" + ToString( nId) + "," + - sStat + ")" + + string sLua = "EgtSetStatus({" + sIds + "}," + + sStat + ")" + " -- Ok=" + ToString( bOk) ; LOG_INFO( GetCmdLogger(), sLua.c_str()) ; } // restituisco risultato - return ( bOk ? TRUE : FALSE) ; + return bOk ; } //----------------------------------------------------------------------------- @@ -264,123 +297,146 @@ __stdcall EgtStdColor( const wchar_t* wsName, int StdCol[4]) BOOL __stdcall EgtSetColor( int nId, const int ObjCol[4], BOOL bSetAlpha) { - IGeomDB* pGeomDB = GetCurrGeomDB() ; - VERIFY_GEOMDB( pGeomDB, FALSE) + // assegno indice entità + INTVECTOR vIds ; + vIds.push_back( nId) ; // sistemo il colore Color cCol( ObjCol) ; + // eseguo + return ( EgtSetColor( vIds, cCol, (bSetAlpha != FALSE)) ? TRUE : FALSE) ; +} + +//----------------------------------------------------------------------------- +bool +EgtSetColor( const INTVECTOR& vIds, const Color& cCol, bool bSetAlpha) +{ + IGeomDB* pGeomDB = GetCurrGeomDB() ; + VERIFY_GEOMDB( pGeomDB, false) + // assegno il colore bool bOk = true ; - // assegno il colore a un singolo oggetto - if ( nId != GDB_ID_SEL) { - // se richiesto, recupero alpha originale - if ( ! bSetAlpha) { - Color cOri ; - if ( pGeomDB->GetCalcMaterial( nId, cOri)) - cCol.SetAlpha( cOri.GetIntAlpha()) ; - } - // eseguo assegnazione - bOk = pGeomDB->SetMaterial( nId, cCol) ; - } - // assegno il colore ai selezionati - else { - int nI = pGeomDB->GetFirstSelectedObj() ; - while ( nI != GDB_ID_NULL && bOk) { + for ( size_t i = 0 ; i < vIds.size() ; ++ i) { + int nId = (( vIds[i] != GDB_ID_SEL) ? vIds[i] : pGeomDB->GetFirstSelectedObj()) ; + while ( nId != GDB_ID_NULL) { + Color cNew = cCol ; // se richiesto, recupero alpha originale if ( ! bSetAlpha) { Color cOri ; - if ( pGeomDB->GetCalcMaterial( nI, cOri)) - cCol.SetAlpha( cOri.GetIntAlpha()) ; + if ( pGeomDB->GetCalcMaterial( nId, cOri)) + cNew.SetAlpha( cOri.GetIntAlpha()) ; } // eseguo assegnazione - if ( ! pGeomDB->SetMaterial( nI, cCol)) + if ( ! pGeomDB->SetMaterial( nId, cNew)) bOk = false ; // passo al successivo - nI = pGeomDB->GetNextSelectedObj() ; + nId = (( vIds[i] != GDB_ID_SEL) ? GDB_ID_NULL : pGeomDB->GetNextSelectedObj()) ; } } EgtSetModified() ; // se richiesto, salvo il comando Lua equivalente if ( IsCmdLog()) { - string sLua = "EgtSetColor(" + ( nId != GDB_ID_SEL ? ToString( nId): "GDB_ID_SEL") + ",{" + - ToString( cCol) + "}," + - ( bSetAlpha ? "true" : "false") + ")" + + string sIds ; + for ( size_t i = 0 ; i < vIds.size() ; ++ i) + sIds += ( vIds[i] != GDB_ID_SEL ? ToString( vIds[i]) : "GDB_ID_SEL") + "," ; + sIds.pop_back() ; + string sLua = "EgtSetColor({" + sIds + "},{" + + ToString( cCol) + "}," + + ( bSetAlpha ? "true" : "false") + ")" + " -- Ok=" + ToString( bOk) ; LOG_INFO( GetCmdLogger(), sLua.c_str()) ; } // restituisco risultato - return ( bOk ? TRUE : FALSE) ; + return bOk ; } //----------------------------------------------------------------------------- BOOL __stdcall EgtSetAlpha( int nId, int nAlpha) +{ + // assegno indice entità + INTVECTOR vIds ; + vIds.push_back( nId) ; + // eseguo + return ( EgtSetAlpha( vIds, nAlpha) ? TRUE : FALSE) ; +} + +//----------------------------------------------------------------------------- +bool +EgtSetAlpha( const INTVECTOR& vIds, int nAlpha) { IGeomDB* pGeomDB = GetCurrGeomDB() ; - VERIFY_GEOMDB( pGeomDB, FALSE) + VERIFY_GEOMDB( pGeomDB, false) bool bOk = true ; - // assegno il colore a un singolo oggetto - if ( nId != GDB_ID_SEL) { - // recupero il colore originale - Color cCol ; - bOk = bOk && pGeomDB->GetCalcMaterial( nId, cCol) ; - cCol.SetAlpha( nAlpha) ; - // eseguo assegnazione - bOk = bOk && pGeomDB->SetMaterial( nId, cCol) ; - } - // assegno il colore ai selezionati - else { - int nI = pGeomDB->GetFirstSelectedObj() ; - while ( nI != GDB_ID_NULL && bOk) { + // assegno la trasparenza + for ( size_t i = 0 ; i < vIds.size() ; ++ i) { + int nId = (( vIds[i] != GDB_ID_SEL) ? vIds[i] : pGeomDB->GetFirstSelectedObj()) ; + while ( nId != GDB_ID_NULL) { // recupero il colore originale Color cCol ; - bOk = bOk && pGeomDB->GetCalcMaterial( nI, cCol) ; + bOk = bOk && pGeomDB->GetCalcMaterial( nId, cCol) ; cCol.SetAlpha( nAlpha) ; // eseguo assegnazione - bOk = bOk && pGeomDB->SetMaterial( nI, cCol) ; + bOk = bOk && pGeomDB->SetMaterial( nId, cCol) ; // passo al successivo - nI = pGeomDB->GetNextSelectedObj() ; + nId = (( vIds[i] != GDB_ID_SEL) ? GDB_ID_NULL : pGeomDB->GetNextSelectedObj()) ; } } EgtSetModified() ; // se richiesto, salvo il comando Lua equivalente if ( IsCmdLog()) { - string sLua = "EgtSetAlpha(" + ( nId != GDB_ID_SEL ? ToString( nId): "GDB_ID_SEL") + "," + - ToString( nAlpha) + ")" + + string sIds ; + for ( size_t i = 0 ; i < vIds.size() ; ++ i) + sIds += ( vIds[i] != GDB_ID_SEL ? ToString( vIds[i]) : "GDB_ID_SEL") + "," ; + sIds.pop_back() ; + string sLua = "EgtSetAlpha({" + sIds + "}," + + ToString( nAlpha) + ")" + " -- Ok=" + ToString( bOk) ; LOG_INFO( GetCmdLogger(), sLua.c_str()) ; } // restituisco risultato - return ( bOk ? TRUE : FALSE) ; + return bOk ; } //----------------------------------------------------------------------------- BOOL __stdcall EgtResetColor( int nId) +{ + // assegno indice entità + INTVECTOR vIds ; + vIds.push_back( nId) ; + // eseguo + return ( EgtResetColor( vIds) ? TRUE : FALSE) ; +} + +//----------------------------------------------------------------------------- +bool +EgtResetColor( const INTVECTOR& vIds) { IGeomDB* pGeomDB = GetCurrGeomDB() ; - VERIFY_GEOMDB( pGeomDB, FALSE) + VERIFY_GEOMDB( pGeomDB, false) + // tolgo il colore bool bOk = true ; - // tolgo il colore a un singolo oggetto - if ( nId != GDB_ID_SEL) { - bOk = pGeomDB->SetMaterial( nId, GDB_MT_PARENT) ; - } - // tolgo il colore ai selezionati - else { - int nI = pGeomDB->GetFirstSelectedObj() ; - while ( nI != GDB_ID_NULL && bOk) { - if ( ! pGeomDB->SetMaterial( nI, GDB_MT_PARENT)) + for ( size_t i = 0 ; i < vIds.size() ; ++ i) { + int nId = (( vIds[i] != GDB_ID_SEL) ? vIds[i] : pGeomDB->GetFirstSelectedObj()) ; + while ( nId != GDB_ID_NULL) { + if ( ! pGeomDB->SetMaterial( nId, GDB_MT_PARENT)) bOk = false ; - nI = pGeomDB->GetNextSelectedObj() ; + // passo al successivo + nId = (( vIds[i] != GDB_ID_SEL) ? GDB_ID_NULL : pGeomDB->GetNextSelectedObj()) ; } } EgtSetModified() ; // se richiesto, salvo il comando Lua equivalente if ( IsCmdLog()) { - string sLua = "EgtResetColor(" + ( nId != GDB_ID_SEL ? ToString( nId): "GDB_ID_SEL") + ")" + + string sIds ; + for ( size_t i = 0 ; i < vIds.size() ; ++ i) + sIds += ( vIds[i] != GDB_ID_SEL ? ToString( vIds[i]) : "GDB_ID_SEL") + "," ; + sIds.pop_back() ; + string sLua = "EgtResetColor({" + sIds + "})" + " -- Ok=" + ToString( bOk) ; LOG_INFO( GetCmdLogger(), sLua.c_str()) ; } // restituisco risultato - return ( bOk ? TRUE : FALSE) ; + return bOk ; } //----------------------------------------------------------------------------- diff --git a/API_GdbObjects.cpp b/API_GdbObjects.cpp index a623e5c..ec9d124 100644 --- a/API_GdbObjects.cpp +++ b/API_GdbObjects.cpp @@ -278,7 +278,7 @@ BOOL __stdcall EgtRelocate( int nSouId, int nRefId, int nSonBeforeAfter) { IGeomDB* pGeomDB = GetCurrGeomDB() ; - VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL) + VERIFY_GEOMDB( pGeomDB, FALSE) // eseguo la rilocazione bool bOk = pGeomDB->Relocate( nSouId, nRefId, nSonBeforeAfter) ; EgtSetModified() ; @@ -305,7 +305,7 @@ BOOL __stdcall EgtRelocateGlob( int nSouId, int nRefId, int nSonBeforeAfter) { IGeomDB* pGeomDB = GetCurrGeomDB() ; - VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL) + VERIFY_GEOMDB( pGeomDB, FALSE) // eseguo la rilocazione mantenendo la posizione in globale bool bOk = pGeomDB->RelocateGlob( nSouId, nRefId, nSonBeforeAfter) ; EgtSetModified() ; @@ -332,7 +332,7 @@ BOOL __stdcall EgtChangeId( int nId, int nNewId) { IGeomDB* pGeomDB = GetCurrGeomDB() ; - VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL) + VERIFY_GEOMDB( pGeomDB, FALSE) // eseguo cambio di Id bool bOk = pGeomDB->ChangeId( nId, nNewId) ; // se pezzo corrente o layer corrente @@ -356,54 +356,57 @@ __stdcall EgtChangeId( int nId, int nNewId) //----------------------------------------------------------------------------- BOOL __stdcall EgtErase( int nId) +{ + INTVECTOR vIds ; + vIds.push_back( nId) ; + return ( EgtErase( vIds) ? TRUE : FALSE) ; +} + +//----------------------------------------------------------------------------- +bool +EgtErase( const INTVECTOR& vIds) { IGeomDB* pGeomDB = GetCurrGeomDB() ; - VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL) + VERIFY_GEOMDB( pGeomDB, false) + // eseguo cancellazione bool bOk = true ; - // eseguo cancellazione singola - if ( nId != GDB_ID_SEL) { - bOk = pGeomDB->Erase( nId) ; - // se cancellato pezzo corrente o layer corrente - int nCurrPartId = EgtGetCurrPart() ; - if ( nId == nCurrPartId) - EgtResetCurrPartLayer() ; - else if ( nId == EgtGetCurrLayer()) - EgtSetCurrPartLayer( nCurrPartId, EgtGetFirstVisibleLayer( nCurrPartId)) ; - } - // eseguo cancellazione dei selezionati - else { - int nCurrPartId = EgtGetCurrPart() ; - int nCurrLayerId = EgtGetCurrLayer() ; - bool bErasedCurrPart = false ; - bool bErasedCurrLayer = false ; - int nI = pGeomDB->GetFirstSelectedObj() ; - while ( nI != GDB_ID_NULL && bOk) { + bool bErasedCurrPart = false ; + bool bErasedCurrLayer = false ; + int nCurrPartId = EgtGetCurrPart() ; + int nCurrLayerId = EgtGetCurrLayer() ; + for ( size_t i = 0 ; i < vIds.size() ; ++ i) { + int nId = (( vIds[i] != GDB_ID_SEL) ? vIds[i] : pGeomDB->GetFirstSelectedObj()) ; + while ( nId != GDB_ID_NULL) { // cancello - if ( ! pGeomDB->Erase( nI)) + if ( ! pGeomDB->Erase( nId)) bOk = false ; // verifico se cancellato pezzo corrente o layer corrente - if ( nI == nCurrPartId) + if ( nId == nCurrPartId) bErasedCurrPart = true ; - else if ( nI == nCurrLayerId) + else if ( nId == nCurrLayerId) bErasedCurrLayer = true ; // passo al successivo - nI = pGeomDB->GetFirstSelectedObj() ; + nId = (( vIds[i] != GDB_ID_SEL) ? GDB_ID_NULL : pGeomDB->GetFirstSelectedObj()) ; } - // se cancellato pezzo corrente o layer corrente - if ( bErasedCurrPart) - EgtResetCurrPartLayer() ; - else if ( bErasedCurrLayer) - EgtSetCurrPartLayer( nCurrPartId, EgtGetFirstVisibleLayer( nCurrPartId)) ; } + // se cancellato pezzo corrente o layer corrente + if ( bErasedCurrPart) + EgtResetCurrPartLayer() ; + else if ( bErasedCurrLayer) + EgtSetCurrPartLayer( nCurrPartId, EgtGetFirstVisibleLayer( nCurrPartId)) ; EgtSetModified() ; // se richiesto, salvo il comando Lua equivalente if ( IsCmdLog()) { - string sLua = "EgtErase(" + ( nId != GDB_ID_SEL ? ToString( nId) : "GDB_ID_SEL") + ")" + + string sIds ; + for ( size_t i = 0 ; i < vIds.size() ; ++ i) + sIds += ( vIds[i] != GDB_ID_SEL ? ToString( vIds[i]) : "GDB_ID_SEL") + "," ; + sIds.pop_back() ; + string sLua = "EgtErase({" + sIds + "})" + " -- Ok=" + ToString( bOk) ; LOG_INFO( GetCmdLogger(), sLua.c_str()) ; } // restituisco risultato - return ( bOk ? TRUE : FALSE) ; + return bOk ; } //----------------------------------------------------------------------------- @@ -411,7 +414,7 @@ BOOL __stdcall EgtEmptyGroup( int nId) { IGeomDB* pGeomDB = GetCurrGeomDB() ; - VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL) + VERIFY_GEOMDB( pGeomDB, FALSE) // svuoto il gruppo bool bOk = pGeomDB->EmptyGroup( nId) ; // se cancellato pezzo corrente o layer corrente diff --git a/API_GeoSnap.cpp b/API_GeoSnap.cpp index 4eacf3a..4912904 100644 --- a/API_GeoSnap.cpp +++ b/API_GeoSnap.cpp @@ -21,6 +21,8 @@ #include "/EgtDev/Include/EgkCurve.h" #include "/EgtDev/Include/EgkCurveArc.h" #include "/EgtDev/Include/EgkCurveComposite.h" +#include "/EgtDev/Include/EgkSurf.h" +#include "/EgtDev/Include/EgkSurfTriMesh.h" #include "/EgtDev/Include/EgkExtText.h" #include "/EgtDev/Include/EgkDistPointCurve.h" #include "/EgtDev/Include/EgkIntersCurveCurve.h" @@ -55,6 +57,34 @@ TrasformPoint( IGeomDB* pGeomDB, int nId, int nRefId, Point3d& ptP) return ptP.LocToLoc( frSou, frDest) ; } +//---------------------------------------------------------------------------- +static bool +InvTrasformPoint( IGeomDB* pGeomDB, int nId, int nRefId, Point3d& ptP) +{ + // se non va trasformato, esco + if ( nRefId == nId) + return true ; + // recupero il riferimento in cui va espresso il punto (quello dell'entità a cui va riferito) + Frame3d frSou ; + if ( ! pGeomDB->GetGlobFrame( nId, frSou)) + return false ; + // se viene da globale, trasformo ed esco + if ( nRefId == GDB_ID_ROOT) + return ptP.ToLoc( frSou) ; + // recupero il riferimento da cui proviene + Frame3d frDest ; + if ( nRefId == GDB_ID_GRID) + frDest = pGeomDB->GetGridFrame() ; + else { + // nRefId può essere un gruppo o una entità + if ( ! pGeomDB->GetGroupGlobFrame( nRefId, frDest) && + ! pGeomDB->GetGlobFrame( nRefId, frDest)) + return false ; + } + // eseguo la trasformazione inversa + return ptP.LocToLoc( frDest, frSou) ; +} + //---------------------------------------------------------------------------- static bool TrasformVector( IGeomDB* pGeomDB, int nId, int nRefId, Vector3d& vtV) @@ -341,6 +371,14 @@ EgtCentroid( int nId, int nRefId, Point3d& ptP) if ( pCrv == nullptr || ! pCrv->GetCentroid( ptP)) return false ; } + // se superficie + else if ( ( pGObj->GetType() & GEO_SURF) != 0) { + // recupero la superficie + const ISurf* pSrf = GetSurf( pGObj) ; + // assegno il punto + if ( pSrf == nullptr || ! pSrf->GetCentroid( ptP)) + return false ; + } // se testo else if ( pGObj->GetType() == EXT_TEXT) { // recupero il testo @@ -414,12 +452,16 @@ EgtNearPoint( int nId, const Point3d& ptNear, int nRefId, Point3d& ptP) const IGeoObj* pGObj = pGeomDB->GetGeoObj( nId) ; if ( pGObj == nullptr) return false ; + // porto il punto near nel riferimento dell'entità + Point3d ptNearL = ptNear ; + if ( ! InvTrasformPoint( pGeomDB, nId, nRefId, ptNearL)) + return false ; // se curva if ( ( pGObj->GetType() & GEO_CURVE) != 0) { // recupero la curva const ICurve* pCrv = GetCurve( pGObj) ; // calcolo il punto della curva più vicino al punto di riferimento - DistPointCurve dstPC( ptNear, *pCrv) ; + DistPointCurve dstPC( ptNearL, *pCrv) ; int nFlag ; if ( ! dstPC.GetMinDistPoint( 0, ptP, nFlag)) return false ; @@ -477,12 +519,13 @@ EgtIntersectionPoint( int nId1, int nId2, const Point3d& ptNear, int nRefId, Poi crvTrans->LocToLoc( frEnt2, frEnt1) ; pCrv2 = ::Get( crvTrans) ; } - // porto il punto vicino nel riferimento della prima curva - Point3d ptNearLoc( ptNear) ; - ptNearLoc.ToLoc( frEnt1) ; + // porto il punto Near nel riferimento della prima entità + Point3d ptNearL = ptNear ; + if ( ! InvTrasformPoint( pGeomDB, nId1, nRefId, ptNearL)) + return false ; // calcolo il punto di intersezione sulla prima curva più vicino al punto di riferimento IntersCurveCurve intCC( *pCrv1, *pCrv2, true) ; - if ( ! intCC.GetIntersPointNearTo( 0, ptNearLoc, ptP)) + if ( ! intCC.GetIntersPointNearTo( 0, ptNearL, ptP)) return false ; } else @@ -880,7 +923,7 @@ EgtCurveArcNormVersor( int nId, int nRefId, Vector3d& vtNorm) BOOL __stdcall EgtCurveCompoCenter( int nId, int nSimpCrv, int nRefId, double ptCen[3]) { - // recupero il vettore normale + // recupero il centro Point3d ptTmp ; if ( ! EgtCurveCompoCenter( nId, nSimpCrv, nRefId, ptTmp)) return FALSE ; @@ -910,6 +953,170 @@ EgtCurveCompoCenter( int nId, int nSimpCrv, int nRefId, Point3d& ptCen) return TrasformPoint( pGeomDB, nId, nRefId, ptCen) ; } +//---------------------------------------------------------------------------- +int +__stdcall EgtSurfTmFacetNbr( int nId) +{ + IGeomDB* pGeomDB = GetCurrGeomDB() ; + VERIFY_GEOMDB( pGeomDB, 0) + // recupero la superficie trimesh + const ISurfTriMesh* pStm = GetSurfTriMesh( pGeomDB->GetGeoObj( nId)) ; + if ( pStm == nullptr) + return 0 ; + // recupero il numero delle facce + return pStm->GetFacetNum() ; +} + +//---------------------------------------------------------------------------- +int +__stdcall EgtSurfTmFacetFromTria( int nId, int nT) +{ + IGeomDB* pGeomDB = GetCurrGeomDB() ; + VERIFY_GEOMDB( pGeomDB, SVT_NULL) + // recupero la superficie trimesh + const ISurfTriMesh* pStm = GetSurfTriMesh( pGeomDB->GetGeoObj( nId)) ; + if ( pStm == nullptr) + return SVT_NULL ; + // recupero il numero della faccia da quello di un suo triangolo + return pStm->GetFacetFromTria( nT) ; +} + +//---------------------------------------------------------------------------- +BOOL +__stdcall EgtSurfTmFacetNearestEndPoint( int nId, int nFacet, const double ptNear[3], int nRefId, + double ptEnd[3], double vtNorm[3]) +{ + // recupero il punto e la normale + Point3d ptTmp ; + Vector3d vtN ; + if ( ! EgtSurfTmFacetNearestEndPoint( nId, nFacet, ptNear, nRefId, ptTmp, vtN)) + return FALSE ; + // li assegno + VEC_FROM_3D( ptEnd, ptTmp) + VEC_FROM_3D( vtNorm, vtN) + return TRUE ; +} + +//---------------------------------------------------------------------------- +bool +EgtSurfTmFacetNearestEndPoint( int nId, int nFacet, const Point3d& ptNear, int nRefId, Point3d& ptEnd, Vector3d& vtN) +{ + IGeomDB* pGeomDB = GetCurrGeomDB() ; + VERIFY_GEOMDB( pGeomDB, false) + // recupero la superficie trimesh + const ISurfTriMesh* pStm = GetSurfTriMesh( pGeomDB->GetGeoObj( nId)) ; + if ( pStm == nullptr) + return false ; + // porto il punto Near nel riferimento dell'entità + Point3d ptNearL = ptNear ; + if ( ! InvTrasformPoint( pGeomDB, nId, nRefId, ptNearL)) + return false ; + // recupero il punto End più vicino della faccia + if ( ! pStm->GetFacetNearestEndPoint( nFacet, ptNearL, ptEnd, vtN)) + return false ; + // gestione trasformazioni ( eventuali) + return TrasformPoint( pGeomDB, nId, nRefId, ptEnd) && TrasformVector( pGeomDB, nId, nRefId, vtN) ; +} + +//---------------------------------------------------------------------------- +bool +EgtSurfTmFacetNearestMidPoint( int nId, int nFacet, const Point3d& ptNear, int nRefId, Point3d& ptMid, Vector3d& vtN) +{ + IGeomDB* pGeomDB = GetCurrGeomDB() ; + VERIFY_GEOMDB( pGeomDB, false) + // recupero la superficie trimesh + const ISurfTriMesh* pStm = GetSurfTriMesh( pGeomDB->GetGeoObj( nId)) ; + if ( pStm == nullptr) + return false ; + // porto il punto Near nel riferimento dell'entità + Point3d ptNearL = ptNear ; + if ( ! InvTrasformPoint( pGeomDB, nId, nRefId, ptNearL)) + return false ; + // recupero il punto Mid più vicino della faccia + if ( ! pStm->GetFacetNearestMidPoint( nFacet, ptNearL, ptMid, vtN)) + return false ; + // gestione trasformazioni ( eventuali) + return TrasformPoint( pGeomDB, nId, nRefId, ptMid) && TrasformVector( pGeomDB, nId, nRefId, vtN) ; +} + +//---------------------------------------------------------------------------- +BOOL +__stdcall EgtSurfTmFacetNearestMidPoint( int nId, int nFacet, const double ptNear[3], int nRefId, + double ptMid[3], double vtNorm[3]) +{ + // recupero il punto e la normale + Point3d ptTmp ; + Vector3d vtN ; + if ( ! EgtSurfTmFacetNearestMidPoint( nId, nFacet, ptNear, nRefId, ptTmp, vtN)) + return FALSE ; + // li assegno + VEC_FROM_3D( ptMid, ptTmp) + VEC_FROM_3D( vtNorm, vtN) + return TRUE ; +} + +//---------------------------------------------------------------------------- +BOOL +__stdcall EgtSurfTmFacetCenter( int nId, int nFacet, int nRefId, double ptCen[3], double vtNorm[3]) +{ + // recupero il centro e la normale + Point3d ptTmp ; + Vector3d vtN ; + if ( ! EgtSurfTmFacetCenter( nId, nFacet, nRefId, ptTmp, vtN)) + return FALSE ; + // li assegno + VEC_FROM_3D( ptCen, ptTmp) + VEC_FROM_3D( vtNorm, vtN) + return TRUE ; +} + +//---------------------------------------------------------------------------- +bool +EgtSurfTmFacetCenter( int nId, int nFacet, int nRefId, Point3d& ptCen, Vector3d& vtN) +{ + IGeomDB* pGeomDB = GetCurrGeomDB() ; + VERIFY_GEOMDB( pGeomDB, false) + // recupero la superficie trimesh + const ISurfTriMesh* pStm = GetSurfTriMesh( pGeomDB->GetGeoObj( nId)) ; + if ( pStm == nullptr) + return false ; + // recupero il centro della faccia + if ( ! pStm->GetFacetCenter( nFacet, ptCen, vtN)) + return false ; + // gestione trasformazioni ( eventuali) + return TrasformPoint( pGeomDB, nId, nRefId, ptCen) && TrasformVector( pGeomDB, nId, nRefId, vtN) ; +} + +//---------------------------------------------------------------------------- +BOOL +__stdcall EgtSurfTmFacetNormVersor( int nId, int nFacet, int nRefId, double vtNorm[3]) +{ + // recupero il vettore normale + Vector3d vtTmp ; + if ( ! EgtSurfTmFacetNormVersor( nId, nFacet, nRefId, vtTmp)) + return FALSE ; + // lo assegno + VEC_FROM_3D( vtNorm, vtTmp) + return TRUE ; +} + +//---------------------------------------------------------------------------- +bool +EgtSurfTmFacetNormVersor( int nId, int nFacet, int nRefId, Vector3d& vtNorm) +{ + IGeomDB* pGeomDB = GetCurrGeomDB() ; + VERIFY_GEOMDB( pGeomDB, false) + // recupero la superficie trimesh + const ISurfTriMesh* pStm = GetSurfTriMesh( pGeomDB->GetGeoObj( nId)) ; + if ( pStm == nullptr) + return false ; + // recupero il centro della faccia + if ( ! pStm->GetFacetNormal( nFacet, vtNorm)) + return false ; + // gestione trasformazione ( eventuale) + return TrasformVector( pGeomDB, nId, nRefId, vtNorm) ; +} + //---------------------------------------------------------------------------- BOOL __stdcall EgtExtTextNormVersor( int nId, int nRefId, double vtNorm[3]) diff --git a/API_GeoTransform.cpp b/API_GeoTransform.cpp index 68d4820..9fcc270 100644 --- a/API_GeoTransform.cpp +++ b/API_GeoTransform.cpp @@ -45,18 +45,13 @@ EgtMove( INTVECTOR& vIds, const Vector3d& vtMove, int nRefType) bOk = bOk && VerifySameFrame( pGeomDB, vIds) ; // ciclo sul vettore degli identificativi for ( size_t i = 0 ; i < vIds.size() && bOk ; ++ i) { - // eseguo traslazione singola - if ( vIds[i] != GDB_ID_SEL) { - bOk = pGeomDB->Translate( vIds[i], vtMove) ; - } - // eseguo traslazione dei selezionati - else { - int nI = pGeomDB->GetFirstSelectedObj() ; - while ( nI != GDB_ID_NULL && bOk) { - if ( ! pGeomDB->Translate( nI, vtMove)) - bOk = false ; - nI = pGeomDB->GetNextSelectedObj() ; - } + int nId = (( vIds[i] != GDB_ID_SEL) ? vIds[i] : pGeomDB->GetFirstSelectedObj()) ; + while ( nId != GDB_ID_NULL) { + // eseguo traslazione + if ( ! pGeomDB->Translate( nId, vtMove)) + bOk = false ; + // passo alla successiva + nId = (( vIds[i] != GDB_ID_SEL) ? GDB_ID_NULL : pGeomDB->GetNextSelectedObj()) ; } } } @@ -68,18 +63,13 @@ EgtMove( INTVECTOR& vIds, const Vector3d& vtMove, int nRefType) vtMoveG.ToGlob( pGeomDB->GetGridFrame()) ; // ciclo sul vettore degli identificativi for ( size_t i = 0 ; i < vIds.size() && bOk ; ++ i) { - // eseguo traslazione singola - if ( vIds[i] != GDB_ID_SEL) { - bOk = pGeomDB->TranslateGlob( vIds[i], vtMoveG) ; - } - // eseguo traslazione dei selezionati - else { - int nI = pGeomDB->GetFirstSelectedObj() ; - while ( nI != GDB_ID_NULL && bOk) { - if ( ! pGeomDB->TranslateGlob( nI, vtMoveG)) - bOk = false ; - nI = pGeomDB->GetNextSelectedObj() ; - } + int nId = (( vIds[i] != GDB_ID_SEL) ? vIds[i] : pGeomDB->GetFirstSelectedObj()) ; + while ( nId != GDB_ID_NULL) { + // eseguo traslazione + if ( ! pGeomDB->TranslateGlob( nId, vtMoveG)) + bOk = false ; + // passo alla successiva + nId = (( vIds[i] != GDB_ID_SEL) ? GDB_ID_NULL : pGeomDB->GetNextSelectedObj()) ; } } } @@ -87,11 +77,9 @@ EgtMove( INTVECTOR& vIds, const Vector3d& vtMove, int nRefType) // se richiesto, salvo il comando Lua equivalente if ( IsCmdLog()) { string sIds ; - for ( size_t i = 0 ; i < vIds.size() ; ++ i) { - if ( i > 0) - sIds += "," ; - sIds += ( vIds[i] != GDB_ID_SEL ? ToString( vIds[i]) : "GDB_ID_SEL") ; - } + for ( size_t i = 0 ; i < vIds.size() ; ++ i) + sIds += ( vIds[i] != GDB_ID_SEL ? ToString( vIds[i]) : "GDB_ID_SEL") + "," ; + sIds.pop_back() ; string sLua = "EgtMove({" + sIds + "},{" + ToString( vtMove) + "}," + RefTypeToString( nRefType) + ")" + @@ -124,18 +112,13 @@ EgtRotate( INTVECTOR& vIds, const Point3d& ptAx, const Vector3d& vtAx, double dA bOk = bOk && VerifySameFrame( pGeomDB, vIds) ; // ciclo sul vettore degli identificativi for ( size_t i = 0 ; i < vIds.size() && bOk ; ++ i) { - // eseguo rotazione singola - if ( vIds[i] != GDB_ID_SEL) { - bOk = pGeomDB->Rotate( vIds[i], ptAx, vtAx, dAngRotDeg) ; - } - // eseguo rotazione dei selezionati - else { - int nI = pGeomDB->GetFirstSelectedObj() ; - while ( nI != GDB_ID_NULL && bOk) { - if ( ! pGeomDB->Rotate( nI, ptAx, vtAx, dAngRotDeg)) - bOk = false ; - nI = pGeomDB->GetNextSelectedObj() ; - } + int nId = (( vIds[i] != GDB_ID_SEL) ? vIds[i] : pGeomDB->GetFirstSelectedObj()) ; + while ( nId != GDB_ID_NULL) { + // eseguo rotazione + if ( ! pGeomDB->Rotate( nId, ptAx, vtAx, dAngRotDeg)) + bOk = false ; + // passo alla successiva + nId = (( vIds[i] != GDB_ID_SEL) ? GDB_ID_NULL : pGeomDB->GetNextSelectedObj()) ; } } } @@ -150,18 +133,13 @@ EgtRotate( INTVECTOR& vIds, const Point3d& ptAx, const Vector3d& vtAx, double dA } // ciclo sul vettore degli identificativi for ( size_t i = 0 ; i < vIds.size() && bOk ; ++ i) { - // eseguo rotazione singola - if ( vIds[i] != GDB_ID_SEL) { - bOk = pGeomDB->RotateGlob( vIds[i], ptAxG, vtAxG, dAngRotDeg) ; - } - // eseguo rotazione dei selezionati - else { - int nI = pGeomDB->GetFirstSelectedObj() ; - while ( nI != GDB_ID_NULL && bOk) { - if ( ! pGeomDB->RotateGlob( nI, ptAxG, vtAxG, dAngRotDeg)) - bOk = false ; - nI = pGeomDB->GetNextSelectedObj() ; - } + int nId = (( vIds[i] != GDB_ID_SEL) ? vIds[i] : pGeomDB->GetFirstSelectedObj()) ; + while ( nId != GDB_ID_NULL) { + // eseguo rotazione + if ( ! pGeomDB->RotateGlob( nId, ptAxG, vtAxG, dAngRotDeg)) + bOk = false ; + // passo alla successiva + nId = (( vIds[i] != GDB_ID_SEL) ? GDB_ID_NULL : pGeomDB->GetNextSelectedObj()) ; } } } @@ -169,11 +147,9 @@ EgtRotate( INTVECTOR& vIds, const Point3d& ptAx, const Vector3d& vtAx, double dA // se richiesto, salvo il comando Lua equivalente if ( IsCmdLog()) { string sIds ; - for ( size_t i = 0 ; i < vIds.size() ; ++ i) { - if ( i > 0) - sIds += "," ; - sIds += ( vIds[i] != GDB_ID_SEL ? ToString( vIds[i]) : "GDB_ID_SEL") ; - } + for ( size_t i = 0 ; i < vIds.size() ; ++ i) + sIds += ( vIds[i] != GDB_ID_SEL ? ToString( vIds[i]) : "GDB_ID_SEL") + "," ; + sIds.pop_back() ; string sLua = "EgtRotate({" + sIds + "},{" + ToString( ptAx) + "},{" + ToString( vtAx) + "}," + @@ -216,18 +192,13 @@ EgtScale( INTVECTOR& vIds, const Frame3d& frRef, bOk = bOk && VerifySameFrame( pGeomDB, vIds) ; // ciclo sul vettore degli identificativi for ( size_t i = 0 ; i < vIds.size() && bOk ; ++ i) { - // eseguo scalatura singola - if ( vIds[i] != GDB_ID_SEL) { - bOk = bOk && pGeomDB->Scale( vIds[i], frRef, dCoeffX, dCoeffY, dCoeffZ) ; - } - // eseguo scalatura dei selezionati - else { - int nI = pGeomDB->GetFirstSelectedObj() ; - while ( nI != GDB_ID_NULL && bOk) { - if ( ! pGeomDB->Scale( nI, frRef, dCoeffX, dCoeffY, dCoeffZ)) - bOk = false ; - nI = pGeomDB->GetNextSelectedObj() ; - } + int nId = (( vIds[i] != GDB_ID_SEL) ? vIds[i] : pGeomDB->GetFirstSelectedObj()) ; + while ( nId != GDB_ID_NULL) { + // eseguo scalature + if ( ! pGeomDB->Scale( nId, frRef, dCoeffX, dCoeffY, dCoeffZ)) + bOk = false ; + // passo alla successiva + nId = (( vIds[i] != GDB_ID_SEL) ? GDB_ID_NULL : pGeomDB->GetNextSelectedObj()) ; } } } @@ -239,18 +210,13 @@ EgtScale( INTVECTOR& vIds, const Frame3d& frRef, frRefG.ToGlob( pGeomDB->GetGridFrame()) ; // ciclo sul vettore degli identificativi for ( size_t i = 0 ; i < vIds.size() && bOk ; ++ i) { - // eseguo scalatura singola - if ( vIds[i] != GDB_ID_SEL) { - bOk = bOk && pGeomDB->ScaleGlob( vIds[i], frRefG, dCoeffX, dCoeffY, dCoeffZ) ; - } - // eseguo scalatura dei selezionati - else { - int nI = pGeomDB->GetFirstSelectedObj() ; - while ( nI != GDB_ID_NULL && bOk) { - if ( ! pGeomDB->ScaleGlob( nI, frRefG, dCoeffX, dCoeffY, dCoeffZ)) - bOk = false ; - nI = pGeomDB->GetNextSelectedObj() ; - } + int nId = (( vIds[i] != GDB_ID_SEL) ? vIds[i] : pGeomDB->GetFirstSelectedObj()) ; + while ( nId != GDB_ID_NULL) { + // eseguo scalature + if ( ! pGeomDB->ScaleGlob( nId, frRefG, dCoeffX, dCoeffY, dCoeffZ)) + bOk = false ; + // passo alla successiva + nId = (( vIds[i] != GDB_ID_SEL) ? GDB_ID_NULL : pGeomDB->GetNextSelectedObj()) ; } } } @@ -258,11 +224,9 @@ EgtScale( INTVECTOR& vIds, const Frame3d& frRef, // se richiesto, salvo il comando Lua equivalente if ( IsCmdLog()) { string sIds ; - for ( size_t i = 0 ; i < vIds.size() ; ++ i) { - if ( i > 0) - sIds += "," ; - sIds += ( vIds[i] != GDB_ID_SEL ? ToString( vIds[i]) : "GDB_ID_SEL") ; - } + for ( size_t i = 0 ; i < vIds.size() ; ++ i) + sIds += ( vIds[i] != GDB_ID_SEL ? ToString( vIds[i]) : "GDB_ID_SEL") + "," ; + sIds.pop_back() ; string sLua = "EgtScale({" + sIds + "},{{" + ToString( frRef.Orig()) + "},{" + ToString( frRef.VersX()) + "},{" + @@ -301,18 +265,13 @@ EgtMirror( INTVECTOR& vIds, const Point3d& ptP, const Vector3d& vtN, int nRefTyp bOk = bOk && VerifySameFrame( pGeomDB, vIds) ; // ciclo sul vettore degli identificativi for ( size_t i = 0 ; i < vIds.size() && bOk ; ++ i) { - // eseguo specularità singola - if ( vIds[i] != GDB_ID_SEL) { - bOk = pGeomDB->Mirror( vIds[i], ptP, vtN) ; - } - // eseguo specularità dei selezionati - else { - int nI = pGeomDB->GetFirstSelectedObj() ; - while ( nI != GDB_ID_NULL && bOk) { - if ( ! pGeomDB->Mirror( nI, ptP, vtN)) - bOk = false ; - nI = pGeomDB->GetNextSelectedObj() ; - } + int nId = (( vIds[i] != GDB_ID_SEL) ? vIds[i] : pGeomDB->GetFirstSelectedObj()) ; + while ( nId != GDB_ID_NULL) { + // eseguo riflessione + if ( ! pGeomDB->Mirror( nId, ptP, vtN)) + bOk = false ; + // passo alla successiva + nId = (( vIds[i] != GDB_ID_SEL) ? GDB_ID_NULL : pGeomDB->GetNextSelectedObj()) ; } } } @@ -327,18 +286,13 @@ EgtMirror( INTVECTOR& vIds, const Point3d& ptP, const Vector3d& vtN, int nRefTyp } // ciclo sul vettore degli identificativi for ( size_t i = 0 ; i < vIds.size() && bOk ; ++ i) { - // eseguo specularità singola - if ( vIds[i] != GDB_ID_SEL) { - bOk = pGeomDB->MirrorGlob( vIds[i], ptPG, vtNG) ; - } - // eseguo specularità dei selezionati - else { - int nI = pGeomDB->GetFirstSelectedObj() ; - while ( nI != GDB_ID_NULL && bOk) { - if ( ! pGeomDB->MirrorGlob( nI, ptPG, vtNG)) - bOk = false ; - nI = pGeomDB->GetNextSelectedObj() ; - } + int nId = (( vIds[i] != GDB_ID_SEL) ? vIds[i] : pGeomDB->GetFirstSelectedObj()) ; + while ( nId != GDB_ID_NULL) { + // eseguo riflessione + if ( ! pGeomDB->MirrorGlob( nId, ptPG, vtNG)) + bOk = false ; + // passo alla successiva + nId = (( vIds[i] != GDB_ID_SEL) ? GDB_ID_NULL : pGeomDB->GetNextSelectedObj()) ; } } } @@ -346,11 +300,9 @@ EgtMirror( INTVECTOR& vIds, const Point3d& ptP, const Vector3d& vtN, int nRefTyp // se richiesto, salvo il comando Lua equivalente if ( IsCmdLog()) { string sIds ; - for ( size_t i = 0 ; i < vIds.size() ; ++ i) { - if ( i > 0) - sIds += "," ; - sIds += ( vIds[i] != GDB_ID_SEL ? ToString( vIds[i]) : "GDB_ID_SEL") ; - } + for ( size_t i = 0 ; i < vIds.size() ; ++ i) + sIds += ( vIds[i] != GDB_ID_SEL ? ToString( vIds[i]) : "GDB_ID_SEL") + "," ; + sIds.pop_back() ; string sLua = "EgtMirror({" + sIds + "},{" + ToString( ptP) + "},{" + ToString( vtN) + "}," + @@ -386,18 +338,13 @@ EgtShear( INTVECTOR& vIds, const Point3d& ptP, const Vector3d& vtN, bOk = bOk && VerifySameFrame( pGeomDB, vIds) ; // ciclo sul vettore degli identificativi for ( size_t i = 0 ; i < vIds.size() && bOk ; ++ i) { - // eseguo stiramento singolo - if ( vIds[i] != GDB_ID_SEL) { - bOk = pGeomDB->Shear( vIds[i], ptP, vtN, vtDir, dCoeff) ; - } - // eseguo stiramento dei selezionati - else { - int nI = pGeomDB->GetFirstSelectedObj() ; - while ( nI != GDB_ID_NULL && bOk) { - if ( ! pGeomDB->Shear( nI, ptP, vtN, vtDir, dCoeff)) - bOk = false ; - nI = pGeomDB->GetNextSelectedObj() ; - } + int nId = (( vIds[i] != GDB_ID_SEL) ? vIds[i] : pGeomDB->GetFirstSelectedObj()) ; + while ( nId != GDB_ID_NULL) { + // eseguo stiramento + if ( ! pGeomDB->Shear( nId, ptP, vtN, vtDir, dCoeff)) + bOk = false ; + // passo alla successiva + nId = (( vIds[i] != GDB_ID_SEL) ? GDB_ID_NULL : pGeomDB->GetNextSelectedObj()) ; } } } @@ -414,18 +361,13 @@ EgtShear( INTVECTOR& vIds, const Point3d& ptP, const Vector3d& vtN, } // ciclo sul vettore degli identificativi for ( size_t i = 0 ; i < vIds.size() && bOk ; ++ i) { - // eseguo stiramento singolo - if ( vIds[i] != GDB_ID_SEL) { - bOk = pGeomDB->ShearGlob( vIds[i], ptPG, vtNG, vtDirG, dCoeff) ; - } - // eseguo stiramento dei selezionati - else { - int nI = pGeomDB->GetFirstSelectedObj() ; - while ( nI != GDB_ID_NULL && bOk) { - if ( ! pGeomDB->ShearGlob( nI, ptPG, vtNG, vtDirG, dCoeff)) - bOk = false ; - nI = pGeomDB->GetNextSelectedObj() ; - } + int nId = (( vIds[i] != GDB_ID_SEL) ? vIds[i] : pGeomDB->GetFirstSelectedObj()) ; + while ( nId != GDB_ID_NULL) { + // eseguo stiramento + if ( ! pGeomDB->ShearGlob( nId, ptPG, vtNG, vtDirG, dCoeff)) + bOk = false ; + // passo alla successiva + nId = (( vIds[i] != GDB_ID_SEL) ? GDB_ID_NULL : pGeomDB->GetNextSelectedObj()) ; } } } @@ -433,11 +375,9 @@ EgtShear( INTVECTOR& vIds, const Point3d& ptP, const Vector3d& vtN, // se richiesto, salvo il comando Lua equivalente if ( IsCmdLog()) { string sIds ; - for ( size_t i = 0 ; i < vIds.size() ; ++ i) { - if ( i > 0) - sIds += "," ; - sIds += ( vIds[i] != GDB_ID_SEL ? ToString( vIds[i]) : "GDB_ID_SEL") ; - } + for ( size_t i = 0 ; i < vIds.size() ; ++ i) + sIds += ( vIds[i] != GDB_ID_SEL ? ToString( vIds[i]) : "GDB_ID_SEL") + "," ; + sIds.pop_back() ; string sLua = "EgtShear({" + sIds + "},{" + ToString( ptP) + "},{" + ToString( vtN) + "},{" + @@ -457,20 +397,8 @@ __stdcall EgtMoveGroup( int nId, double vVtMove[3]) { IGeomDB* pGeomDB = GetCurrGeomDB() ; VERIFY_GEOMDB( pGeomDB, FALSE) - bool bOk = true ; - // eseguo traslazione singola - if ( nId != GDB_ID_SEL) { - bOk = pGeomDB->TranslateGroup( nId, vVtMove) ; - } - // eseguo traslazione dei selezionati - else { - int nI = pGeomDB->GetFirstSelectedObj() ; - while ( nI != GDB_ID_NULL && bOk) { - if ( ! pGeomDB->TranslateGroup( nI, vVtMove)) - bOk = false ; - nI = pGeomDB->GetNextSelectedObj() ; - } - } + // eseguo traslazione ( solo singola) + bool bOk = pGeomDB->TranslateGroup( nId, vVtMove) ; EgtSetModified() ; // restituisco risultato return ( bOk ? TRUE : FALSE) ; @@ -482,20 +410,8 @@ __stdcall EgtRotateGroup( int nId, double vPtAx[3], double vVtAx[3], double dAng { IGeomDB* pGeomDB = GetCurrGeomDB() ; VERIFY_GEOMDB( pGeomDB, FALSE) - bool bOk = true ; - // eseguo rotazione singola - if ( nId != GDB_ID_SEL) { - bOk = pGeomDB->RotateGroup( nId, vPtAx, vVtAx, dAngRotDeg) ; - } - // eseguo rotazione dei selezionati - else { - int nI = pGeomDB->GetFirstSelectedObj() ; - while ( nI != GDB_ID_NULL && bOk) { - if ( ! pGeomDB->RotateGroup( nI, vPtAx, vVtAx, dAngRotDeg)) - bOk = false ; - nI = pGeomDB->GetNextSelectedObj() ; - } - } + // eseguo rotazione ( solo singola) + bool bOk = pGeomDB->RotateGroup( nId, vPtAx, vVtAx, dAngRotDeg) ; EgtSetModified() ; // restituisco risultato return ( bOk ? TRUE : FALSE) ; @@ -514,19 +430,8 @@ __stdcall EgtScaleGroup( int nId, const double vOrig[3], Frame3d frFrame ; if ( ! frFrame.Set( vOrig, vX, vY, vZ)) bOk = false ; - // eseguo scalatura singola - if ( nId != GDB_ID_SEL) { - bOk = bOk && pGeomDB->ScaleGroup( nId, frFrame, dCoeffX, dCoeffY, dCoeffZ) ; - } - // eseguo scalatura dei selezionati - else { - int nI = pGeomDB->GetFirstSelectedObj() ; - while ( nI != GDB_ID_NULL && bOk) { - if ( ! pGeomDB->ScaleGroup( nI, frFrame, dCoeffX, dCoeffY, dCoeffZ)) - bOk = false ; - nI = pGeomDB->GetNextSelectedObj() ; - } - } + // eseguo scalatura ( solo singola) + bOk = bOk && pGeomDB->ScaleGroup( nId, frFrame, dCoeffX, dCoeffY, dCoeffZ) ; EgtSetModified() ; // restituisco risultato return ( bOk ? TRUE : FALSE) ; @@ -538,20 +443,8 @@ __stdcall EgtMirrorGroup( int nId, const double vPnt[3], const double vN[3]) { IGeomDB* pGeomDB = GetCurrGeomDB() ; VERIFY_GEOMDB( pGeomDB, FALSE) - bool bOk = true ; - // eseguo specularità singola - if ( nId != GDB_ID_SEL) { - bOk = pGeomDB->MirrorGroup( nId, vPnt, vN) ; - } - // eseguo specularità dei selezionati - else { - int nI = pGeomDB->GetFirstSelectedObj() ; - while ( nI != GDB_ID_NULL && bOk) { - if ( ! pGeomDB->MirrorGroup( nI, vPnt, vN)) - bOk = false ; - nI = pGeomDB->GetNextSelectedObj() ; - } - } + // eseguo riflessione ( solo singola) + bool bOk = pGeomDB->MirrorGroup( nId, vPnt, vN) ; EgtSetModified() ; // restituisco risultato return ( bOk ? TRUE : FALSE) ; @@ -564,20 +457,8 @@ __stdcall EgtShearGroup( int nId, const double vPnt[3], const double vN[3], { IGeomDB* pGeomDB = GetCurrGeomDB() ; VERIFY_GEOMDB( pGeomDB, FALSE) - bool bOk = true ; - // eseguo stiramento singolo - if ( nId != GDB_ID_SEL) { - bOk = pGeomDB->ShearGroup( nId, vPnt, vN, vDir, dCoeff) ; - } - // eseguo stiramento dei selezionati - else { - int nI = pGeomDB->GetFirstSelectedObj() ; - while ( nI != GDB_ID_NULL && bOk) { - if ( ! pGeomDB->ShearGroup( nI, vPnt, vN, vDir, dCoeff)) - bOk = false ; - nI = pGeomDB->GetNextSelectedObj() ; - } - } + // eseguo stiramento ( solo singolo) + bool bOk = pGeomDB->ShearGroup( nId, vPnt, vN, vDir, dCoeff) ; EgtSetModified() ; // restituisco risultato return ( bOk ? TRUE : FALSE) ; diff --git a/API_Scene.cpp b/API_Scene.cpp index 365e510..73b09ed 100644 --- a/API_Scene.cpp +++ b/API_Scene.cpp @@ -305,13 +305,13 @@ __stdcall EgtUnselectableClearAll( void) //----------------------------------------------------------------------------- BOOL -__stdcall EgtGetPointFromSelect( int nSelId, int nWinX, int nWinY, double ptSel[3]) +__stdcall EgtGetPointFromSelect( int nSelId, int nWinX, int nWinY, double ptSel[3], int* pnAux) { GseContext* pGseCtx = GetCurrGseContext() ; VERIFY_CTX_SCENE( pGseCtx, FALSE) // trovo il punto usato in selezione Point3d ptTmp ; - if ( ! pGseCtx->m_pScene->GetPointFromSelect( nSelId, Point3d( nWinX, nWinY), ptTmp)) + if ( ! pGseCtx->m_pScene->GetPointFromSelect( nSelId, Point3d( nWinX, nWinY), ptTmp, *pnAux)) return FALSE ; VEC_FROM_3D( ptSel, ptTmp) return TRUE ; diff --git a/EgtInterface.rc b/EgtInterface.rc index e77070d..409793a 100644 Binary files a/EgtInterface.rc and b/EgtInterface.rc differ diff --git a/EgtInterface.vcxproj b/EgtInterface.vcxproj index 839bf50..9aad807 100644 --- a/EgtInterface.vcxproj +++ b/EgtInterface.vcxproj @@ -223,6 +223,7 @@ copy $(TargetPath) \EgtProg\Dll64 + @@ -247,6 +248,7 @@ copy $(TargetPath) \EgtProg\Dll64 + diff --git a/EgtInterface.vcxproj.filters b/EgtInterface.vcxproj.filters index c5978a2..10d33a3 100644 --- a/EgtInterface.vcxproj.filters +++ b/EgtInterface.vcxproj.filters @@ -191,6 +191,12 @@ File di origine\API + + File di origine\API + + + File di origine\LUA + diff --git a/GeoTools.cpp b/GeoTools.cpp index a985582..0543738 100644 --- a/GeoTools.cpp +++ b/GeoTools.cpp @@ -42,7 +42,7 @@ GetPointLocal( IGeomDB* pGeomDB, const double ptP[3], int nRefType, const Frame3 //---------------------------------------------------------------------------- bool -VerifySameFrame( IGeomDB* pGeomDB, INTVECTOR& vIds) +VerifySameFrame( IGeomDB* pGeomDB, const INTVECTOR& vIds) { // verifico puntatore a GeomDB if ( pGeomDB == nullptr) diff --git a/GeoTools.h b/GeoTools.h index 597e803..3e1afef 100644 --- a/GeoTools.h +++ b/GeoTools.h @@ -22,5 +22,5 @@ Vector3d GetVectorLocal( IGeomDB* pGeomDB, const double vtV[3], int nRefType, co // Punto espresso nel riferimento desiderato partendo da punto nel riferimento RefType Point3d GetPointLocal( IGeomDB* pGeomDB, const double ptP[3], int nRefType, const Frame3d& frLoc) ; // Verifica che tutti gli oggetti dell'insieme abbiano lo stesso riferimento -bool VerifySameFrame( IGeomDB* pGeomDB, INTVECTOR& vIds) ; +bool VerifySameFrame( IGeomDB* pGeomDB, const INTVECTOR& vIds) ; diff --git a/LUA.h b/LUA.h index f895579..8313ee9 100644 --- a/LUA.h +++ b/LUA.h @@ -83,6 +83,9 @@ bool LuaInstallGdbModify( lua_State* L) ; //-------------------------- GdbModifyCurve ---------------------------------- bool LuaInstallGdbModifyCurve( lua_State* L) ; +//-------------------------- GdbModifySurf ----------------------------------- +bool LuaInstallGdbModifySurf( lua_State* L) ; + //-------------------------- GdbPartLayer ------------------------------------ bool LuaInstallGdbPartLayer( lua_State* L) ; diff --git a/LUA_GdbCreateCurve.cpp b/LUA_GdbCreateCurve.cpp index f10f1c2..7bd11c6 100644 --- a/LUA_GdbCreateCurve.cpp +++ b/LUA_GdbCreateCurve.cpp @@ -413,7 +413,7 @@ LuaCreateCurveCompo( lua_State* L) LuaCheckParam( L, 3, bErase) ; LuaClearStack( L) ; // creo la curva composita - int nId = EgtCreateCurveCompo( nParentId, vIds, ( bErase ? TRUE : FALSE)) ; + int nId = EgtCreateCurveCompo( nParentId, vIds, bErase) ; // restituisco il risultato if ( nId != GDB_ID_NULL) LuaSetReturn( L, nId) ; diff --git a/LUA_GdbCreateSurf.cpp b/LUA_GdbCreateSurf.cpp index 35d2b36..9872690 100644 --- a/LUA_GdbCreateSurf.cpp +++ b/LUA_GdbCreateSurf.cpp @@ -28,7 +28,7 @@ static const double LIN_TOL_DEF = 0.05 ; //------------------------------------------------------------------------------- static int -LuaCreateSurfTriMeshByFlatContour( lua_State* L) +LuaCreateSurfTmByFlatContour( lua_State* L) { // 2 o 3 parametri : ParentId, CrvId [, dTol] int nParentId ; @@ -40,7 +40,7 @@ LuaCreateSurfTriMeshByFlatContour( lua_State* L) LuaCheckParam( L, 3, dLinTol) ; LuaClearStack( L) ; // creo STM riempiendo un contorno piano - int nId = EgtCreateSurfTriMeshByFlatContour( nParentId, nCrvId, dLinTol) ; + int nId = EgtCreateSurfTmByFlatContour( nParentId, nCrvId, dLinTol) ; // restituisco il risultato if ( nId != GDB_ID_NULL) LuaSetReturn( L, nId) ; @@ -51,7 +51,7 @@ LuaCreateSurfTriMeshByFlatContour( lua_State* L) //------------------------------------------------------------------------------- static int -LuaCreateSurfTriMeshByRegion( lua_State* L) +LuaCreateSurfTmByRegion( lua_State* L) { // 2 o 3 parametri : ParentId, CrvIds [, dTol] int nParentId ; @@ -63,7 +63,7 @@ LuaCreateSurfTriMeshByRegion( lua_State* L) LuaCheckParam( L, 3, dLinTol) ; LuaClearStack( L) ; // creo STM riempiendo una regione (piana) - int nId = EgtCreateSurfTriMeshByRegion( nParentId, vCrvIds, dLinTol) ; + int nId = EgtCreateSurfTmByRegion( nParentId, vCrvIds, dLinTol) ; // restituisco il risultato if ( nId != GDB_ID_NULL) LuaSetReturn( L, nId) ; @@ -74,7 +74,7 @@ LuaCreateSurfTriMeshByRegion( lua_State* L) //------------------------------------------------------------------------------- static int -LuaCreateSurfTriMeshByExtrusion( lua_State* L) +LuaCreateSurfTmByExtrusion( lua_State* L) { // 3 o 4 o 5 parametri : ParentId, CrvIds, vtExtr [, dTol] [, sRefType] int nParentId ; @@ -91,8 +91,8 @@ LuaCreateSurfTriMeshByExtrusion( lua_State* L) LuaGetRefType( L, 4, nRefType) ; LuaClearStack( L) ; // creo STM estrudendo uno o più percorsi, se piani si possono mettere i tappi - int nId = EgtCreateSurfTriMeshByExtrusion( nParentId, vCrvIds, vtExtr, - dLinTol, nRefType) ; + int nId = EgtCreateSurfTmByExtrusion( nParentId, vCrvIds, vtExtr, + dLinTol, nRefType) ; // restituisco il risultato if ( nId != GDB_ID_NULL) LuaSetReturn( L, nId) ; @@ -103,7 +103,7 @@ LuaCreateSurfTriMeshByExtrusion( lua_State* L) //------------------------------------------------------------------------------- static int -LuaCreateSurfTriMeshByRegionExtrusion( lua_State* L) +LuaCreateSurfTmByRegionExtrusion( lua_State* L) { // 3 o 4 o 5 parametri : ParentId, CrvIds, vtExtr [, dTol] [, sRefType] int nParentId ; @@ -120,8 +120,7 @@ LuaCreateSurfTriMeshByRegionExtrusion( lua_State* L) 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) ; + int nId = EgtCreateSurfTmByRegionExtrusion( nParentId, vCrvIds, vtExtr, dLinTol, nRefType) ; // restituisco il risultato if ( nId != GDB_ID_NULL) LuaSetReturn( L, nId) ; @@ -132,7 +131,7 @@ LuaCreateSurfTriMeshByRegionExtrusion( lua_State* L) //------------------------------------------------------------------------------- static int -LuaCreateSurfTriMeshByRevolve( lua_State* L) +LuaCreateSurfTmByRevolve( lua_State* L) { // 5 o 6 o 7 parametri : ParentId, CrvId, ptAx, vtAx, bCapEnds [, dTol] [, sRefType] int nParentId ; @@ -153,7 +152,7 @@ LuaCreateSurfTriMeshByRevolve( lua_State* L) LuaGetRefType( L, 6, nRefType) ; LuaClearStack( L) ; // creo STM riempiendo un contorno piano - int nId = EgtCreateSurfTriMeshByRevolve( nParentId, nCrvId, ptAx.v, vtAx.v, bCapEnds, dLinTol, nRefType) ; + int nId = EgtCreateSurfTmByRevolve( nParentId, nCrvId, ptAx.v, vtAx.v, bCapEnds, dLinTol, nRefType) ; // restituisco il risultato if ( nId != GDB_ID_NULL) LuaSetReturn( L, nId) ; @@ -164,7 +163,7 @@ LuaCreateSurfTriMeshByRevolve( lua_State* L) //------------------------------------------------------------------------------- static int -LuaCreateSurfTriMeshByScrewing( lua_State* L) +LuaCreateSurfTmByScrewing( lua_State* L) { // 6 o 7 o 8 parametri : ParentId, CrvId, ptAx, vtAx, dAngRotDeg, dMove [, dTol] [, sRefType] int nParentId ; @@ -187,7 +186,7 @@ LuaCreateSurfTriMeshByScrewing( lua_State* L) LuaGetRefType( L, 7, nRefType) ; LuaClearStack( L) ; // creo STM riempiendo un contorno piano - int nId = EgtCreateSurfTriMeshByScrewing( nParentId, nCrvId, ptAx.v, vtAx.v, dAngRotDeg, dMove, dLinTol, nRefType) ; + int nId = EgtCreateSurfTmByScrewing( nParentId, nCrvId, ptAx.v, vtAx.v, dAngRotDeg, dMove, dLinTol, nRefType) ; // restituisco il risultato if ( nId != GDB_ID_NULL) LuaSetReturn( L, nId) ; @@ -198,7 +197,7 @@ LuaCreateSurfTriMeshByScrewing( lua_State* L) //------------------------------------------------------------------------------- static int -LuaCreateSurfTriMeshRuled( lua_State* L) +LuaCreateSurfTmRuled( lua_State* L) { // 3 o 4 parametri : ParentId, CrvId1, CrvId2, [, dTol] int nParentId ; @@ -212,7 +211,53 @@ LuaCreateSurfTriMeshRuled( lua_State* L) LuaCheckParam( L, 4, dLinTol) ; LuaClearStack( L) ; // creo STM riempiendo un contorno piano - int nId = EgtCreateSurfTriMeshRuled( nParentId, nCrvId1, nCrvId2, dLinTol) ; + int nId = EgtCreateSurfTmRuled( nParentId, nCrvId1, nCrvId2, dLinTol) ; + // restituisco il risultato + if ( nId != GDB_ID_NULL) + LuaSetReturn( L, nId) ; + else + LuaSetReturn( L) ; + return 1 ; +} + +//---------------------------------------------------------------------------- +static int +LuaCreateSurfTmByTriangles( lua_State* L) +{ + // 2 o 3 parametri : ParentId, Id/s [, bErase] + int nParentId ; + LuaCheckParam( L, 1, nParentId) + INTVECTOR vId ; + LuaCheckParam( L, 2, vId) + bool bErase = true ; + if ( lua_gettop( L) >= 3) + LuaCheckParam( L, 3, bErase) ; + LuaClearStack( L) ; + // creo STM mediante cucitura di superfici + int nId = EgtCreateSurfTmByTriangles( nParentId, vId, bErase) ; + // restituisco il risultato + if ( nId != GDB_ID_NULL) + LuaSetReturn( L, nId) ; + else + LuaSetReturn( L) ; + return 1 ; +} + +//---------------------------------------------------------------------------- +static int +LuaCreateSurfTmBySewing( lua_State* L) +{ + // 2 o 3 parametri : ParentId, Id/s [, bErase] + int nParentId ; + LuaCheckParam( L, 1, nParentId) + INTVECTOR vId ; + LuaCheckParam( L, 2, vId) + bool bErase = true ; + if ( lua_gettop( L) >= 3) + LuaCheckParam( L, 3, bErase) ; + LuaClearStack( L) ; + // creo STM mediante cucitura di superfici + int nId = EgtCreateSurfTmBySewing( nParentId, vId, bErase) ; // restituisco il risultato if ( nId != GDB_ID_NULL) LuaSetReturn( L, nId) ; @@ -226,13 +271,15 @@ bool LuaInstallGdbCreateSurf( lua_State* L) { try { - 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) ; + lua_register( L, "EgtSurfTmByFlatContour", LuaCreateSurfTmByFlatContour) ; + lua_register( L, "EgtSurfTmByRegion", LuaCreateSurfTmByRegion) ; + lua_register( L, "EgtSurfTmByExtrusion", LuaCreateSurfTmByExtrusion) ; + lua_register( L, "EgtSurfTmByRegionExtrusion", LuaCreateSurfTmByRegionExtrusion) ; + lua_register( L, "EgtSurfTmByRevolve", LuaCreateSurfTmByRevolve) ; + lua_register( L, "EgtSurfTmByScrewing", LuaCreateSurfTmByScrewing) ; + lua_register( L, "EgtSurfTmRuled", LuaCreateSurfTmRuled) ; + lua_register( L, "EgtSurfTmByTriangles", LuaCreateSurfTmByTriangles) ; + lua_register( L, "EgtSurfTmBySewing", LuaCreateSurfTmBySewing) ; } catch ( ...) { return false ; diff --git a/LUA_GdbModify.cpp b/LUA_GdbModify.cpp index 5b07422..5fbaabe 100644 --- a/LUA_GdbModify.cpp +++ b/LUA_GdbModify.cpp @@ -58,43 +58,6 @@ LuaChangeVectorBase( lua_State* L) return 1 ; } -//---------------------------------------------------------------------------- -static int -LuaInvertSurf( lua_State* L) -{ - // 1 parametro : Id/s - INTVECTOR vId ; - LuaCheckParam( L, 1, vId) - LuaClearStack( L) ; - // eseguo inversione superfici - bool bOk = true ; - for ( size_t i = 0 ; i < vId.size() && bOk ; ++ i) { - if ( EgtInvertSurface( vId[i]) == FALSE) - bOk = false ; - } - // restituisco il risultato - LuaSetReturn( L, bOk) ; - return 1 ; -} - -//---------------------------------------------------------------------------- -static int -LuaSurfTmDoSewing( lua_State* L) -{ - // 1 o 2 parametri : Id/s [, bErase] - INTVECTOR vId ; - LuaCheckParam( L, 1, vId) - bool bErase = true ; - if ( lua_gettop( L) >= 2) - LuaCheckParam( L, 2, bErase) ; - LuaClearStack( L) ; - // eseguo cucitura superfici - bool bOk = EgtSurfTmDoSewing( vId, bErase) ; - // restituisco il risultato - LuaSetReturn( L, bOk) ; - return 1 ; -} - //------------------------------------------------------------------------------- static int LuaModifyText( lua_State* L) @@ -198,8 +161,6 @@ LuaInstallGdbModify( lua_State* L) try { lua_register( L, "EgtChangeGroupFrame", LuaChangeGroupFrame) ; lua_register( L, "EgtChangeVectorBase", LuaChangeVectorBase) ; - lua_register( L, "EgtInvertSurf", LuaInvertSurf) ; - lua_register( L, "EgtSurfTmDoSewing", LuaSurfTmDoSewing) ; lua_register( L, "EgtModifyText", LuaModifyText) ; lua_register( L, "EgtChangeTextFont", LuaChangeTextFont) ; lua_register( L, "EgtFlipText", LuaFlipText) ; diff --git a/LUA_GdbModifyCurve.cpp b/LUA_GdbModifyCurve.cpp index 6c73743..2b40afd 100644 --- a/LUA_GdbModifyCurve.cpp +++ b/LUA_GdbModifyCurve.cpp @@ -32,11 +32,7 @@ LuaInvertCurve( lua_State* L) LuaCheckParam( L, 1, vId) LuaClearStack( L) ; // eseguo inversione curve - bool bOk = true ; - for ( size_t i = 0 ; i < vId.size() && bOk ; ++ i) { - if ( EgtInvertCurve( vId[i]) == FALSE) - bOk = false ; - } + bool bOk = EgtInvertCurve( vId) ; // restituisco il risultato LuaSetReturn( L, bOk) ; return 1 ; diff --git a/LUA_GdbModifySurf.cpp b/LUA_GdbModifySurf.cpp new file mode 100644 index 0000000..e83afe0 --- /dev/null +++ b/LUA_GdbModifySurf.cpp @@ -0,0 +1,75 @@ +//---------------------------------------------------------------------------- +// EgalTech 2015-2015 +//---------------------------------------------------------------------------- +// File : LUA_GdbModifySurf.cpp Data : 09.03.15 Versione : 1.6b6 +// Contenuto : Funzioni di modifica delle superfici per LUA. +// +// +// +// Modifiche : 09.03.15 DS Creazione modulo. +// +// +//---------------------------------------------------------------------------- + +//--------------------------- Include ---------------------------------------- +#include "stdafx.h" +#include "LUA.h" +#include "API.h" +#include "/EgtDev/Include/EInAPI.h" +#include "/EgtDev/Include/EInConst.h" +#include "/EgtDev/Include/EgnStringUtils.h" +#include "/EgtDev/Extern/Lua/Include/lua.hpp" + +using namespace std ; + + +//---------------------------------------------------------------------------- +static int +LuaInvertSurf( lua_State* L) +{ + // 1 parametro : Id/s + INTVECTOR vId ; + LuaCheckParam( L, 1, vId) + LuaClearStack( L) ; + // eseguo inversione superfici + bool bOk = EgtInvertSurface( vId) ; + // restituisco il risultato + LuaSetReturn( L, bOk) ; + return 1 ; +} + +//---------------------------------------------------------------------------- +static int +LuaExtractSurfTmFacetLoops( lua_State* L) +{ + // 3 parametri : nId, nFacet, nDestGrpId + int nId ; + LuaCheckParam( L, 1, nId) + int nFacet ; + LuaCheckParam( L, 2, nFacet) + int nDestGrpId ; + LuaCheckParam( L, 3, nDestGrpId) + LuaClearStack( L) ; + // eseguo inversione superfici + int nNewId = EgtExtractSurfTmFacetLoops( nId, nFacet, nDestGrpId) ; + // restituisco il risultato + if ( nNewId != GDB_ID_NULL) + LuaSetReturn( L, nNewId) ; + else + LuaSetReturn( L) ; + return 1 ; +} + +//------------------------------------------------------------------------------- +bool +LuaInstallGdbModifySurf( lua_State* L) +{ + try { + lua_register( L, "EgtInvertSurf", LuaInvertSurf) ; + lua_register( L, "EgtExtractSurfTmFacetLoops", LuaExtractSurfTmFacetLoops) ; + } + catch ( ...) { + return false ; + } + return true ; +} diff --git a/LUA_GdbObjAttribs.cpp b/LUA_GdbObjAttribs.cpp index 18fff88..e0b8232 100644 --- a/LUA_GdbObjAttribs.cpp +++ b/LUA_GdbObjAttribs.cpp @@ -174,8 +174,8 @@ static int LuaSetStatus( lua_State* L) { // 2 parametri : Id, Stato - int nId ; - LuaCheckParam( L, 1, nId) + INTVECTOR vId ; + LuaCheckParam( L, 1, vId) string sStatus ; LuaCheckParam( L, 2, sStatus) ToUpper( sStatus) ; @@ -186,7 +186,7 @@ LuaSetStatus( lua_State* L) nStatus = GDB_ST_SEL ; LuaClearStack( L) ; // imposto lo stato - bool bOk = ( EgtSetStatus( nId, nStatus) != FALSE) ; + bool bOk = EgtSetStatus( vId, nStatus) ; // restituisco il risultato LuaSetReturn( L, bOk) ; return 1 ; @@ -341,13 +341,7 @@ LuaSetColor( lua_State* L) LuaGetParam( L, 3, bSetAlpha) ; LuaClearStack( L) ; // assegno il colore - int vCol[4] ; - cCol.GetInt( vCol) ; - bool bOk = true ; - for ( size_t i = 0 ; i < vId.size() && bOk ; ++ i) { - if ( EgtSetColor( vId[i], vCol, bSetAlpha) == FALSE) - bOk = false ; - } + bool bOk = EgtSetColor( vId, cCol, bSetAlpha) ; // restituisco il risultato LuaSetReturn( L, bOk) ; return 1 ; @@ -364,11 +358,7 @@ LuaSetAlpha( lua_State* L) LuaCheckParam( L, 2, nAlpha) LuaClearStack( L) ; // assegno la trasparenza - bool bOk = true ; - for ( size_t i = 0 ; i < vId.size() && bOk ; ++ i) { - if ( EgtSetAlpha( vId[i], nAlpha) == FALSE) - bOk = false ; - } + bool bOk = EgtSetAlpha( vId, nAlpha) ; // restituisco il risultato LuaSetReturn( L, bOk) ; return 1 ; @@ -383,11 +373,7 @@ LuaResetColor( lua_State* L) LuaCheckParam( L, 1, vId) LuaClearStack( L) ; // tolgo il colore - bool bOk = true ; - for ( size_t i = 0 ; i < vId.size() && bOk ; ++ i) { - if ( EgtResetColor( vId[i]) == FALSE) - bOk = false ; - } + bool bOk = EgtResetColor( vId) ; // restituisco il risultato LuaSetReturn( L, bOk) ; return 1 ; diff --git a/LUA_GdbObjects.cpp b/LUA_GdbObjects.cpp index 43cdda7..d648e6c 100644 --- a/LUA_GdbObjects.cpp +++ b/LUA_GdbObjects.cpp @@ -304,11 +304,7 @@ LuaErase( lua_State* L) LuaCheckParam( L, 1, vId) LuaClearStack( L) ; // eseguo la cancellazione - bool bOk = true ; - for ( size_t i = 0 ; i < vId.size() && bOk ; ++ i) { - if ( EgtErase( vId[i]) == FALSE) - bOk = false ; - } + bool bOk = EgtErase( vId) ; // restituisco il risultato LuaSetReturn( L, bOk) ; return 1 ; diff --git a/LUA_General.cpp b/LUA_General.cpp index bb82b2c..2062dab 100644 --- a/LUA_General.cpp +++ b/LUA_General.cpp @@ -79,6 +79,10 @@ LuaInit( void) LOG_ERROR( GetLogger(), "Error in LuaInstallGdbModifyCurve (" __FUNCTION__ ")") return false ; } + if ( ! LuaInstallGdbModifySurf( s_L)) { + LOG_ERROR( GetLogger(), "Error in LuaInstallGdbModifySurf (" __FUNCTION__ ")") + return false ; + } if ( ! LuaInstallGdbPartLayer( s_L)) { LOG_ERROR( GetLogger(), "Error in LuaInstallGdbPartLayer (" __FUNCTION__ ")") return false ; diff --git a/LUA_GeoSnap.cpp b/LUA_GeoSnap.cpp index 73bc5a4..1f5b986 100644 --- a/LUA_GeoSnap.cpp +++ b/LUA_GeoSnap.cpp @@ -416,6 +416,123 @@ LuaCurveCompoCenter( lua_State* L) return 1 ; } +//---------------------------------------------------------------------------- +static int +LuaSurfTmFacetNbr( lua_State* L) +{ + // 1 parametro : Id + int nId ; + LuaCheckParam( L, 1, nId) + LuaClearStack( L) ; + // recupero il numero di facce della superficie trimesh + int nNbr = EgtSurfTmFacetNbr( nId) ; + LuaSetReturn( L, nNbr) ; + return 1 ; +} + +//---------------------------------------------------------------------------- +static int +LuaSurfTmFacetNearestEndPoint( lua_State* L) +{ + // 3 o 4 parametri : Id, nFacet, ptNear [, nRefId] + int nId ; + LuaCheckParam( L, 1, nId) + int nFacet ; + LuaCheckParam( L, 2, nFacet) + Point3d ptNear ; + LuaCheckParam( L, 3, ptNear) + int nRefId = nId ; + LuaGetRefId( L, 4, nRefId) ; + LuaClearStack( L) ; + // recupero il punto End più vicino della faccia della superficie trimesh + Point3d ptEnd ; + Vector3d vtN ; + if ( EgtSurfTmFacetNearestEndPoint( nId, nFacet, ptNear, nRefId, ptEnd, vtN)) { + LuaSetReturn( L, ptEnd) ; + LuaSetReturn( L, vtN) ; + } + else { + LuaSetReturn( L) ; + LuaSetReturn( L) ; + } + return 2 ; +} + +//---------------------------------------------------------------------------- +static int +LuaSurfTmFacetNearestMidPoint( lua_State* L) +{ + // 3 o 4 parametri : Id, nFacet, ptNear [, nRefId] + int nId ; + LuaCheckParam( L, 1, nId) + int nFacet ; + LuaCheckParam( L, 2, nFacet) + Point3d ptNear ; + LuaCheckParam( L, 3, ptNear) + int nRefId = nId ; + LuaGetRefId( L, 4, nRefId) ; + LuaClearStack( L) ; + // recupero il punto Mid più vicino della faccia della superficie trimesh + Point3d ptMid ; + Vector3d vtN ; + if ( EgtSurfTmFacetNearestMidPoint( nId, nFacet, ptNear, nRefId, ptMid, vtN)) { + LuaSetReturn( L, ptMid) ; + LuaSetReturn( L, vtN) ; + } + else { + LuaSetReturn( L) ; + LuaSetReturn( L) ; + } + return 2 ; +} + +//---------------------------------------------------------------------------- +static int +LuaSurfTmFacetCenter( lua_State* L) +{ + // 2 o 3 parametri : Id, nFacet [, nRefId] + int nId ; + LuaCheckParam( L, 1, nId) + int nFacet ; + LuaCheckParam( L, 2, nFacet) + int nRefId = nId ; + LuaGetRefId( L, 3, nRefId) ; + LuaClearStack( L) ; + // recupero il centro della faccia della superficie trimesh + Point3d ptCen ; + Vector3d vtN ; + if ( EgtSurfTmFacetCenter( nId, nFacet, nRefId, ptCen, vtN)) { + LuaSetReturn( L, ptCen) ; + LuaSetReturn( L, vtN) ; + } + else { + LuaSetReturn( L) ; + LuaSetReturn( L) ; + } + return 2 ; +} + +//---------------------------------------------------------------------------- +static int +LuaSurfTmFacetNormVersor( lua_State* L) +{ + // 2 o 3 parametri : Id, nFacet [, nRefId] + int nId ; + LuaCheckParam( L, 1, nId) + int nFacet ; + LuaCheckParam( L, 2, nFacet) + int nRefId = nId ; + LuaGetRefId( L, 3, nRefId) ; + LuaClearStack( L) ; + // recupero la normale della faccia della superficie trimesh + Vector3d vtNorm ; + if ( EgtSurfTmFacetNormVersor( nId, nFacet, nRefId, vtNorm)) + LuaSetReturn( L, vtNorm) ; + else + LuaSetReturn( L) ; + return 1 ; +} + //---------------------------------------------------------------------------- static int LuaExtTextNormVersor( lua_State* L) @@ -460,6 +577,11 @@ LuaInstallGeoSnap( lua_State* L) lua_register( L, "EgtCurveArcRadius", LuaCurveArcRadius) ; lua_register( L, "EgtCurveArcNormVersor", LuaCurveArcNormVersor) ; lua_register( L, "EgtCurveCompoCenter", LuaCurveCompoCenter) ; + lua_register( L, "EgtSurfTmFacetNbr", LuaSurfTmFacetNbr) ; + lua_register( L, "EgtSurfTmFacetNearestEndPoint", LuaSurfTmFacetNearestEndPoint) ; + lua_register( L, "EgtSurfTmFacetNearestMidPoint", LuaSurfTmFacetNearestMidPoint) ; + lua_register( L, "EgtSurfTmFacetCenter", LuaSurfTmFacetCenter) ; + lua_register( L, "EgtSurfTmFacetNormVersor", LuaSurfTmFacetNormVersor) ; lua_register( L, "EgtExtTextNormVersor", LuaExtTextNormVersor) ; } catch ( ...) { diff --git a/LUA_GeoTransform.cpp b/LUA_GeoTransform.cpp index a626910..b233c39 100644 --- a/LUA_GeoTransform.cpp +++ b/LUA_GeoTransform.cpp @@ -103,7 +103,7 @@ LuaMirror( lua_State* L) int nRefType = RTY_DEFAULT ; LuaGetRefType( L, 4, nRefType) ; LuaClearStack( L) ; - // eseguo scalatura + // eseguo riflessione bool bOk = EgtMirror( vId, ptOn, vtN, nRefType) ; // restituisco il risultato LuaSetReturn( L, bOk) ; @@ -128,7 +128,7 @@ LuaShear( lua_State* L) int nRefType = RTY_DEFAULT ; LuaGetRefType( L, 6, nRefType) ; LuaClearStack( L) ; - // eseguo scalatura + // eseguo stiramento bool bOk = EgtShear( vId, ptOn, vtN, vtDir, dCoeff, nRefType) ; // restituisco il risultato LuaSetReturn( L, bOk) ; diff --git a/LUA_Scene.cpp b/LUA_Scene.cpp index 5dfdffe..e1f4bbb 100644 --- a/LUA_Scene.cpp +++ b/LUA_Scene.cpp @@ -143,7 +143,7 @@ LuaZoom( lua_State* L) static int LuaSetView( lua_State* L) { - // 1 o 2 parametri : ViewDir ("T","F","R","B","L","BO","SWI","SEI","NEI","NWI","CPL") [, flag ridisegna] + // 1 o 2 parametri : ViewDir ("T","F","R","B","L","BO","SW","SE","NE","NW","GRID") [, flag ridisegna] string sViewDir ; LuaCheckParam( L, 1, sViewDir) int nViewDir = CT_TOP ; @@ -156,15 +156,15 @@ LuaSetView( lua_State* L) nViewDir = CT_BACK ; else if ( sViewDir == "L") nViewDir = CT_LEFT ; - else if ( sViewDir == "SWI") + else if ( sViewDir == "SW") nViewDir = CT_ISO_SW ; - else if ( sViewDir == "SEI") + else if ( sViewDir == "SE") nViewDir = CT_ISO_SE ; - else if ( sViewDir == "NEI") + else if ( sViewDir == "NE") nViewDir = CT_ISO_NE ; - else if ( sViewDir == "NWI") + else if ( sViewDir == "NW") nViewDir = CT_ISO_NW ; - else if ( sViewDir == "CPL") + else if ( sViewDir == "GRID") nViewDir = CT_CPLANE ; bool bRedraw = true ; if ( lua_gettop( L) >= 2)