diff --git a/EXE_GdbModifySurf.cpp b/EXE_GdbModifySurf.cpp index 314bc83..7ae2864 100644 --- a/EXE_GdbModifySurf.cpp +++ b/EXE_GdbModifySurf.cpp @@ -20,17 +20,11 @@ #include "GeoTools.h" #include "/EgtDev/Include/EXeExecutor.h" #include "/EgtDev/Include/EXeConst.h" -#include "/EgtDev/Include/EGkGeoPoint3d.h" -#include "/EgtDev/Include/EGkCurveLine.h" #include "/EgtDev/Include/EGkCurveComposite.h" #include "/EgtDev/Include/EGkSurfFlatRegion.h" #include "/EgtDev/Include/EGkSurfTriMesh.h" #include "/EgtDev/Include/EGkSurfLocal.h" -#include "/EgtDev/Include/EgkChainCurves.h" -#include "/EgtDev/Include/EGkStmFromTriangleSoup.h" #include "/EgtDev/Include/EGkCAvSimpleSurfFrMove.h" -#include "/EgtDev/Include/EGkIntersPlaneSurfTm.h" -#include "/EgtDev/Include/EGkIntersSurfTmSurfTm.h" #include "/EgtDev/Include/EGkStringUtils3d.h" #include "/EgtDev/Include/EgtPointerOwner.h" @@ -607,385 +601,6 @@ ExeCopySurfTmFacet( int nId, int nFacet, int nDestGrpId) return nFacId ; } -//------------------------------------------------------------------------------- -static int -MyGetSurfTmPlaneInters( int nId, const Point3d& ptOn, const Vector3d& vtN, int nDestGrpId, int nRefType, - int* pnPntCount, int* pnCrvCount, int* pnSrfCount) -{ - IGeomDB* pGeomDB = GetCurrGeomDB() ; - VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL) - // recupero la superficie TriMesh - const ISurfTriMesh* pStm = GetSurfTriMesh( pGeomDB->GetGeoObj( nId)) ; - if ( pStm == nullptr) - return GDB_ID_NULL ; - // recupero il suo riferimento globale - Frame3d frSurf ; - if ( ! pGeomDB->GetGlobFrame( nId, frSurf)) - return GDB_ID_NULL ; - // recupero il riferimento del gruppo di destinazione - Frame3d frDest ; - if ( ! pGeomDB->GetGroupGlobFrame( nDestGrpId, frDest)) - return GDB_ID_NULL ; - // porto in locale il punto e la normale del piano - Point3d ptOnL = GetPointLocal( pGeomDB, ptOn, nRefType, frSurf) ; - Vector3d vtNL = GetVectorLocal( pGeomDB, vtN, nRefType, frSurf) ; - // calcolo il piano di intersezione - Plane3d plPlane ; - if ( ! plPlane.Set( ptOnL, vtNL)) - return GDB_ID_NULL ; - // eseguo l'intersezione - PNTVECTOR vPnt ; - BIPNTVECTOR vBpt ; - TRIA3DVECTOR vTria ; - if ( ! IntersPlaneSurfTm( plPlane, *pStm, vPnt, vBpt, vTria)) - return GDB_ID_NULL ; - // Inserisco il risultato nel DB - int nFirstId = GDB_ID_NULL ; - int nPntCount = 0 ; - int nCrvCount = 0 ; - int nSrfCount = 0 ; - // Inserisco i punti nel DB - for ( size_t i = 0 ; i < vPnt.size() ; ++ i) { - // creo il punto - PtrOwner pGeoPnt( CreateGeoPoint3d()) ; - if ( ! IsNull( pGeoPnt)) - return GDB_ID_NULL ; - // setto il punto - pGeoPnt->Set( vPnt[i]) ; - // porto il punto nel riferimento destinazione - pGeoPnt->LocToLoc( frSurf, frDest) ; - // lo inserisco nel DB geometrico - int nNewId = pGeomDB->AddGeoObj( GDB_ID_NULL, nDestGrpId, Release( pGeoPnt)) ; - if ( nNewId == GDB_ID_NULL) - return GDB_ID_NULL ; - // copio il materiale - if ( ! pGeomDB->CopyMaterial( nId, nNewId)) - return GDB_ID_NULL ; - // aggiorno contatori - if ( nFirstId == GDB_ID_NULL) - nFirstId = nNewId ; - ++ nPntCount ; - } - // Concateno i tratti di curva - double dToler = 20 * EPS_SMALL ; - ChainCurves chainC ; - chainC.Init( false, dToler, int( vBpt.size())) ; - for ( size_t i = 0 ; i < vBpt.size() ; ++ i) { - Vector3d vtDir = vBpt[i].second - vBpt[i].first ; - vtDir.Normalize() ; - if ( ! chainC.AddCurve( int( i) + 1, vBpt[i].first, vtDir, vBpt[i].second, vtDir)) - return GDB_ID_NULL ; - } - // recupero i percorsi concatenati - Point3d ptNear = ( vBpt.empty() ? ORIG : vBpt[0].first) ; - INTVECTOR vId ; - while ( chainC.GetChainFromNear( ptNear, false, vId)) { - // creo una curva composita - PtrOwner pCrvCompo( CreateCurveComposite()) ; - if ( IsNull( pCrvCompo)) - return GDB_ID_NULL ; - // recupero gli estremi dei segmenti, creo le linee e le inserisco nella composita - for ( size_t i = 0 ; i < vId.size() ; ++ i) { - // creo una segmento di retta - int nInd = abs( vId[i]) - 1 ; - bool bInvert = ( vId[i] < 0) ; - PtrOwner pLine( CreateCurveLine()) ; - if ( IsNull( pLine) || ! pLine->Set( vBpt[nInd].first, vBpt[nInd].second)) - return GDB_ID_NULL ; - if ( bInvert) - pLine->Invert() ; - // lo accodo alla composita - if ( ! pCrvCompo->AddCurve( Release( pLine), true, dToler)) - return GDB_ID_NULL ; - // aggiorno il prossimo near - ptNear = vBpt[nInd].second ; - } - // se lunghezza curva inferiore a 5 volte la tolleranza, la salto - double dCrvLen ; - if ( ! pCrvCompo->GetLength( dCrvLen) || dCrvLen < 5. * dToler) - continue ; - // se curva chiusa entro 5 volte la tolleranza ma considerata aperta, la chiudo bene - Point3d ptStart, ptEnd ; - if ( pCrvCompo->GetStartPoint( ptStart) && - pCrvCompo->GetEndPoint( ptEnd) && - AreSamePointEpsilon( ptStart, ptEnd, 5. * dToler) && - ! AreSamePointApprox( ptStart, ptEnd)) { - // porto il punto finale a coincidere esattamente con l'inizio - pCrvCompo->ModifyEnd( ptStart) ; - } - // assegno estrusione come direzione normale al piano - pCrvCompo->SetExtrusion( plPlane.GetVersN()) ; - // unisco segmenti allineati - pCrvCompo->MergeCurves( 0.5 * dToler, ANG_TOL_STD_DEG) ; - // porto la curva nel riferimento destinazione - pCrvCompo->LocToLoc( frSurf, frDest) ; - // la inserisco nel DB geometrico - int nNewId = pGeomDB->AddGeoObj( GDB_ID_NULL, nDestGrpId, Release( pCrvCompo)) ; - if ( nNewId == GDB_ID_NULL) - return GDB_ID_NULL ; - // copio il materiale - if ( ! pGeomDB->CopyMaterial( nId, nNewId)) - return GDB_ID_NULL ; - // aggiorno contatori - if ( nFirstId == GDB_ID_NULL) - nFirstId = nNewId ; - ++ nCrvCount ; - } - // Costruisco una superficie trimesh dall'insieme di triangoli - StmFromTriangleSoup StmFts ; - if ( ! StmFts.Start()) - return GDB_ID_NULL ; - for ( size_t i = 0 ; i < vTria.size() ; ++ i) - // inserisco il triangolo nella nuova superficie - StmFts.AddTriangle( vTria[i]) ; - // valido la superficie e calcolo le adiacenze - if ( ! StmFts.End()) - return GDB_ID_NULL ; - // se superficie con triangoli - PtrOwner pNewStm( StmFts.GetSurf()) ; - if ( ! IsNull( pNewStm) && pNewStm->GetTriangleCount() > 0) { - // porto la superficie nel riferimento destinazione - pNewStm->LocToLoc( frSurf, frDest) ; - // la inserisco nel DB - int nNewId = pGeomDB->AddGeoObj( GDB_ID_NULL, nDestGrpId, Release( pNewStm)) ; - if ( nNewId == GDB_ID_NULL) - return GDB_ID_NULL ; - // copio il materiale - if ( ! pGeomDB->CopyMaterial( nId, nNewId)) - return GDB_ID_NULL ; - // aggiorno contatori - if ( nFirstId == GDB_ID_NULL) - nFirstId = nNewId ; - ++ nSrfCount ; - } - // aggiorno contatori - if ( pnPntCount != nullptr) - *pnPntCount = nPntCount ; - if ( pnCrvCount != nullptr) - *pnCrvCount = nCrvCount ; - if ( pnSrfCount != nullptr) - *pnSrfCount = nSrfCount ; - // restituisco l'identificativo della prima nuova entità - return nFirstId ; -} - -//------------------------------------------------------------------------------- -int -ExeGetSurfTmPlaneInters( int nId, const Point3d& ptOn, const Vector3d& vtN, int nDestGrpId, int nRefType, - int* pnPntCount, int* pnCrvCount, int* pnSrfCount) -{ - // eseguo - int nPntCount = 0 ; - int nCrvCount = 0 ; - int nSrfCount = 0 ; - int nFirstId = MyGetSurfTmPlaneInters( nId, ptOn, vtN, nDestGrpId, nRefType, &nPntCount, &nCrvCount, &nSrfCount) ; - // aggiorno contatori - if ( nFirstId != GDB_ID_NULL) { - if ( pnPntCount != nullptr) - *pnPntCount = nPntCount ; - if ( pnCrvCount != nullptr) - *pnCrvCount = nCrvCount ; - if ( pnSrfCount != nullptr) - *pnSrfCount = nSrfCount ; - ExeSetModified() ; - } - // se richiesto, salvo il comando Lua equivalente - if ( IsCmdLog()) { - string sLua = "EgtGetSurfTmPlaneInters(" + ToString( nId) + ",{" + - ToString( ptOn) + "},{" + - ToString( vtN) + "}," + - ToString( nDestGrpId) + "," + - RefTypeToString( nRefType) + ")" + - " -- Id1=" + ToString( nFirstId) + ", PntNbr=" + ToString( nPntCount) + - ", CrvNbr=" + ToString( nCrvCount) + ", SrfNbr=" + ToString( nSrfCount) ; - LOG_INFO( GetCmdLogger(), sLua.c_str()) ; - } - // restituisco l'identificativo della prima nuova entità - return nFirstId ; -} - -//------------------------------------------------------------------------------- -static int -MyGetSurfTmSurfTmInters( int nId1, int nId2, int nDestGrpId, - int* pnPntCount, int* pnCrvCount, int* pnSrfCount) -{ - IGeomDB* pGeomDB = GetCurrGeomDB() ; - VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL) - // recupero il riferimento del gruppo di destinazione - Frame3d frDest ; - if ( ! pGeomDB->GetGroupGlobFrame( nDestGrpId, frDest)) - return GDB_ID_NULL ; - // recupero la prima superficie TriMesh espressa nel riferimento destinazione - SurfLocal Surf1Loc( pGeomDB, nId1, frDest) ; - const ISurfTriMesh* pStm1L = GetSurfTriMesh( Surf1Loc) ; - if ( pStm1L == nullptr) - return GDB_ID_NULL ; - // recupero la seconda superficie TriMesh espressa nel riferimento destinazione - SurfLocal Surf2Loc( pGeomDB, nId2, frDest) ; - const ISurfTriMesh* pStm2L = GetSurfTriMesh( Surf2Loc) ; - if ( pStm2L == nullptr) - return GDB_ID_NULL ; - // eseguo l'intersezione (già espressa nel riferimento destinazione) - PNTVECTOR vPnt ; - BIPNTVECTOR vBpt ; - TRIA3DVECTOR vTria ; - if ( ! IntersSurfTmSurfTm( *pStm1L, *pStm2L, vPnt, vBpt, vTria)) - return GDB_ID_NULL ; - // Inserisco il risultato nel DB - int nFirstId = GDB_ID_NULL ; - int nPntCount = 0 ; - int nCrvCount = 0 ; - int nSrfCount = 0 ; - // Inserisco i punti nel DB - for ( size_t i = 0 ; i < vPnt.size() ; ++ i) { - // creo il punto - PtrOwner pGeoPnt( CreateGeoPoint3d()) ; - if ( ! IsNull( pGeoPnt)) - return GDB_ID_NULL ; - // setto il punto - pGeoPnt->Set( vPnt[i]) ; - // lo inserisco nel DB geometrico - int nNewId = pGeomDB->AddGeoObj( GDB_ID_NULL, nDestGrpId, Release( pGeoPnt)) ; - if ( nNewId == GDB_ID_NULL) - return GDB_ID_NULL ; - // copio il materiale - if ( ! pGeomDB->CopyMaterial( nId1, nNewId)) - return GDB_ID_NULL ; - // aggiorno contatori - if ( nFirstId == GDB_ID_NULL) - nFirstId = nNewId ; - ++ nPntCount ; - } - // Concateno i tratti di curva - double dToler = 20 * EPS_SMALL ; - ChainCurves chainC ; - chainC.Init( false, dToler, int( vBpt.size())) ; - for ( size_t i = 0 ; i < vBpt.size() ; ++ i) { - Vector3d vtDir = vBpt[i].second - vBpt[i].first ; - vtDir.Normalize() ; - if ( ! chainC.AddCurve( int( i) + 1, vBpt[i].first, vtDir, vBpt[i].second, vtDir)) - return GDB_ID_NULL ; - } - // recupero i percorsi concatenati - Point3d ptNear = ( vBpt.empty() ? ORIG : vBpt[0].first) ; - INTVECTOR vId ; - while ( chainC.GetChainFromNear( ptNear, false, vId)) { - // creo una curva composita - PtrOwner pCrvCompo( CreateCurveComposite()) ; - if ( IsNull( pCrvCompo)) - return GDB_ID_NULL ; - // recupero gli estremi dei segmenti, creo le linee e le inserisco nella composita - for ( size_t i = 0 ; i < vId.size() ; ++ i) { - // creo una segmento di retta - int nInd = abs( vId[i]) - 1 ; - bool bInvert = ( vId[i] < 0) ; - PtrOwner pLine( CreateCurveLine()) ; - if ( IsNull( pLine) || ! pLine->Set( vBpt[nInd].first, vBpt[nInd].second)) - return GDB_ID_NULL ; - if ( bInvert) - pLine->Invert() ; - // lo accodo alla composita - if ( ! pCrvCompo->AddCurve( Release( pLine), true, dToler)) - return GDB_ID_NULL ; - // aggiorno il prossimo near - ptNear = vBpt[nInd].second ; - } - // se lunghezza curva inferiore a 5 volte la tolleranza, la salto - double dCrvLen ; - if ( ! pCrvCompo->GetLength( dCrvLen) || dCrvLen < 5. * dToler) - continue ; - // se curva chiusa entro 5 volte la tolleranza ma considerata aperta, la chiudo bene - Point3d ptStart, ptEnd ; - if ( pCrvCompo->GetStartPoint( ptStart) && - pCrvCompo->GetEndPoint( ptEnd) && - AreSamePointEpsilon( ptStart, ptEnd, 5. * dToler) && - ! AreSamePointApprox( ptStart, ptEnd)) { - // porto il punto finale a coincidere esattamente con l'inizio - pCrvCompo->ModifyEnd( ptStart) ; - } - // unisco segmenti allineati - pCrvCompo->MergeCurves( 0.5 * dToler, ANG_TOL_STD_DEG) ; - // la inserisco nel DB geometrico - int nNewId = pGeomDB->AddGeoObj( GDB_ID_NULL, nDestGrpId, Release( pCrvCompo)) ; - if ( nNewId == GDB_ID_NULL) - return GDB_ID_NULL ; - // copio il materiale - if ( ! pGeomDB->CopyMaterial( nId1, nNewId)) - return GDB_ID_NULL ; - // aggiorno contatori - if ( nFirstId == GDB_ID_NULL) - nFirstId = nNewId ; - ++ nCrvCount ; - } - // Costruisco una superficie trimesh dall'insieme di triangoli - StmFromTriangleSoup StmFts ; - if ( ! StmFts.Start()) - return GDB_ID_NULL ; - for ( size_t i = 0 ; i < vTria.size() ; ++ i) - // inserisco il triangolo nella nuova superficie - StmFts.AddTriangle( vTria[i]) ; - // valido la superficie e calcolo le adiacenze - if ( ! StmFts.End()) - return GDB_ID_NULL ; - // se superficie con triangoli - PtrOwner pNewStm( StmFts.GetSurf()) ; - if ( ! IsNull( pNewStm) && pNewStm->GetTriangleCount() > 0) { - // la inserisco nel DB - int nNewId = pGeomDB->AddGeoObj( GDB_ID_NULL, nDestGrpId, Release( pNewStm)) ; - if ( nNewId == GDB_ID_NULL) - return GDB_ID_NULL ; - // copio il materiale - if ( ! pGeomDB->CopyMaterial( nId1, nNewId)) - return GDB_ID_NULL ; - // aggiorno contatori - if ( nFirstId == GDB_ID_NULL) - nFirstId = nNewId ; - ++ nSrfCount ; - } - // aggiorno contatori - if ( pnPntCount != nullptr) - *pnPntCount = nPntCount ; - if ( pnCrvCount != nullptr) - *pnCrvCount = nCrvCount ; - if ( pnSrfCount != nullptr) - *pnSrfCount = nSrfCount ; - // restituisco l'identificativo della prima nuova entità - return nFirstId ; -} - -//------------------------------------------------------------------------------- -int -ExeGetSurfTmSurfTmInters( int nId1, int nId2, int nDestGrpId, - int* pnPntCount, int* pnCrvCount, int* pnSrfCount) -{ - // eseguo - int nPntCount = 0 ; - int nCrvCount = 0 ; - int nSrfCount = 0 ; - int nFirstId = MyGetSurfTmSurfTmInters( nId1, nId2, nDestGrpId, &nPntCount, &nCrvCount, &nSrfCount) ; - // aggiorno contatori - if ( nFirstId != GDB_ID_NULL) { - if ( pnPntCount != nullptr) - *pnPntCount = nPntCount ; - if ( pnCrvCount != nullptr) - *pnCrvCount = nCrvCount ; - if ( pnSrfCount != nullptr) - *pnSrfCount = nSrfCount ; - ExeSetModified() ; - } - // se richiesto, salvo il comando Lua equivalente - if ( IsCmdLog()) { - string sLua = "EgtGetSurfTmSurfTmInters(" + ToString( nId1) + "," + - ToString( nId2) + "," + - ToString( nDestGrpId) + ")" + - " -- Id1=" + ToString( nFirstId) + ", PntNbr=" + ToString( nPntCount) + - ", CrvNbr=" + ToString( nCrvCount) + ", SrfNbr=" + ToString( nSrfCount) ; - LOG_INFO( GetCmdLogger(), sLua.c_str()) ; - } - // restituisco l'identificativo della prima nuova entità - return nFirstId ; -} - //------------------------------------------------------------------------------- bool ExeCutSurfTmPlane( int nId, const Point3d& ptOn, const Vector3d& vtN, bool bSaveOnEq, int nRefType) diff --git a/EXE_GdbModifyVol.cpp b/EXE_GdbModifyVol.cpp index 158eca6..5b3a3ed 100644 --- a/EXE_GdbModifyVol.cpp +++ b/EXE_GdbModifyVol.cpp @@ -422,74 +422,6 @@ ExeVolZmapGetDepth( int nId, const Point3d& ptP, const Vector3d& vtDir, int nRef return bOk ; } -//---------------------------------------------------------------------------- -int -MyVolZmapIntersPlane( int nId, const Plane3d& plPlane, int nDestGrpId, int nRefType, int* pnCount) -{ - IGeomDB* pGeomDB = GetCurrGeomDB() ; - VERIFY_GEOMDB( pGeomDB, false) - // recupero il riferimento locale - Frame3d frLoc ; - if ( ! pGeomDB->GetGlobFrame( nId, frLoc)) - return GDB_ID_NULL ; - // recupero il riferimento destinazione - Frame3d frDest ; - if ( ! pGeomDB->GetGlobFrame( nDestGrpId, frDest)) - return GDB_ID_NULL ; - // porto in locale il piano - Plane3d plPlaneL = GetPlaneLocal( pGeomDB, plPlane, nRefType, frLoc) ; - // recupero lo Zmap e calcolo l'intersezione - IVolZmap* pVZM = GetVolZmap( pGeomDB->GetGeoObj( nId)) ; - ICURVEPOVECTOR vpLoop ; - if ( pVZM == nullptr || ! pVZM->GetPlaneIntersection( plPlaneL, vpLoop)) - return GDB_ID_NULL ; - // inserisco le curve nel gruppo destinazione - int nFirstId = GDB_ID_NULL ; - int nCount = 0 ; - for ( size_t i = 0 ; i < vpLoop.size() ; ++ i) { - PtrOwner pCrv( Release( vpLoop[i])) ; - if ( IsNull( pCrv)) - continue ; - pCrv->ToLoc( frDest) ; - // inserisco la curva composita nel gruppo destinazione - int nNewId = pGeomDB->AddGeoObj( GDB_ID_NULL, nDestGrpId, ::Release( pCrv)) ; - if ( nNewId == GDB_ID_NULL) - return GDB_ID_NULL ; - if ( nFirstId == GDB_ID_NULL) - nFirstId = nNewId ; - ++ nCount ; - } - // aggiorno contatore - if ( pnCount != nullptr) - *pnCount = nCount ; - // restituisco l'identificativo della prima nuova entità - return nFirstId ; -} - -//---------------------------------------------------------------------------- -int -ExeVolZmapIntersPlane( int nId, const Plane3d& plPlane, int nDestGrpId, int nRefType, int* pnCount) -{ - // eseguo - int nCount = 0 ; - int nFirstId = MyVolZmapIntersPlane( nId, plPlane, nDestGrpId, nRefType, &nCount) ; - if ( pnCount != nullptr) - *pnCount = nCount ; - ExeSetModified() ; - // se richiesto, salvo il comando Lua equivalente - if ( IsCmdLog()) { - string sLua = "EgtVolZmapIntersPlane(" + IdToString( nId) + ",{" + - ToString( ORIG + plPlane.GetVersN() * plPlane.GetDist()) + "},{" + - ToString( plPlane.GetVersN()) + "},{" + - ToString( nDestGrpId) + "}," + - RefTypeToString( nRefType) + ")" + - " -- Id=" + ToString( nFirstId) + ",Nbr=" + ToString( nCount) ; - LOG_INFO( GetCmdLogger(), sLua.c_str()) ; - } - // restituisco l'identificativo della prima nuova entità - return nFirstId ; -} - //---------------------------------------------------------------------------- bool ExeVolZmapAvoidBox( int nId, const Frame3d& frBox, const Vector3d& vtDiag, int nRefType) diff --git a/EXE_GdbObjAttribs.cpp b/EXE_GdbObjAttribs.cpp index 2a1c056..91675d8 100644 --- a/EXE_GdbObjAttribs.cpp +++ b/EXE_GdbObjAttribs.cpp @@ -748,5 +748,5 @@ ExeGetTextureFrame( int nId, int nRefId, Frame3d& frTxrRef) if ( ! pGeomDB->GetTextureFrame( nId, frTxrRef)) return false ; // gestione trasformazione ( eventuale) - return TrasformFrame( pGeomDB, nId, nRefId, frTxrRef) ; + return TransformFrame( pGeomDB, nId, nRefId, frTxrRef) ; } diff --git a/EXE_GeoInters.cpp b/EXE_GeoInters.cpp new file mode 100644 index 0000000..f8bc39b --- /dev/null +++ b/EXE_GeoInters.cpp @@ -0,0 +1,657 @@ +//---------------------------------------------------------------------------- +// EgalTech 2018-2018 +//---------------------------------------------------------------------------- +// File : EXE_GeoInters.cpp Data : 27.09.18 Versione : 1.9i4 +// Contenuto : Funzioni di intersezioni tra oggetto geometrici per EXE. +// +// +// +// Modifiche : 27.09.18 DS Creazione modulo. +// +// +//---------------------------------------------------------------------------- + +//--------------------------- Include ---------------------------------------- +#include "stdafx.h" +#include "EXE.h" +#include "EXE_Const.h" +#include "EXE_Macro.h" +#include "AuxTools.h" +#include "GeoTools.h" +#include "/EgtDev/Include/EXeExecutor.h" +#include "/EgtDev/Include/EXeConst.h" +#include "/EgtDev/Include/EGkGeoPoint3d.h" +#include "/EgtDev/Include/EGkCurveLine.h" +#include "/EgtDev/Include/EGkCurveComposite.h" +#include "/EgtDev/Include/EgkChainCurves.h" +#include "/EgtDev/Include/EGkStmStandard.h" +#include "/EgtDev/Include/EGkStmFromTriangleSoup.h" +#include "/EgtDev/Include/EGkSurfLocal.h" +#include "/EgtDev/Include/EGkVolZmap.h" +#include "/EgtDev/Include/EgkIntersCurves.h" +#include "/EgtDev/Include/EGkIntersLineSurfTm.h" +#include "/EgtDev/Include/EGkIntersPlaneSurfTm.h" +#include "/EgtDev/Include/EGkIntersSurfTmSurfTm.h" +#include "/EgtDev/Include/EGkStringUtils3d.h" +#include "/EgtDev/Include/EgtPointerOwner.h" + +using namespace std ; + +//------------------------------------------------------------------------------- +bool +ExeBoxLineInters( const BBox3d& b3Box, const Point3d& ptP, const Vector3d& vtDir, INTDBLVECTOR& vInters) +{ + // Creo la superficie trimesh + Point3d ptMin ; + double dDimX, dDimY, dDimZ ; + if ( ! b3Box.GetMinDim( ptMin, dDimX, dDimY, dDimZ)) + return false ; + PtrOwner pStm( GetSurfTriMeshBox( dDimX, dDimY, dDimZ)) ; + if ( IsNull( pStm)) + return false ; + pStm->Translate( ptMin - ORIG) ; + // Calcolo l'intersezione + double dLen = b3Box.MaxDistFromPoint( ptP) ; + ILSIVECTOR vInfo ; + if ( ! IntersLineSurfTm( ptP, vtDir, dLen, *pStm, vInfo, false)) + return false ; + // ciclo sulle intersezioni + for ( const auto& Info : vInfo) { + // se intersezione puntuale + if ( Info.nILTT == ILTT_VERT || Info.nILTT == ILTT_EDGE || Info.nILTT == ILTT_IN) { + int nFlag = SLT_TOUCH ; + if ( Info.dCosDN > EPS_ZERO) + nFlag = SLT_OUT ; + else if ( Info.dCosDN < -EPS_ZERO) + nFlag = SLT_IN ; + vInters.emplace_back( nFlag, Info.dU) ; + } + // se altrimenti intersezione con coincidenza + else if ( Info.nILTT == ILTT_SEGM || Info.nILTT == ILTT_SEGM_ON_EDGE) { + vInters.emplace_back( SLT_TG_INI, Info.dU) ; + vInters.emplace_back( SLT_TG_FIN, Info.dU2) ; + } + } + // elimino intersezioni ripetute + for ( size_t j = 1 ; j < vInters.size() ; ) { + // intersezione precedente + size_t i = j - 1 ; + // se hanno lo stesso parametro + if ( abs( vInters[i].second - vInters[j].second) < EPS_SMALL) { + // se sono entrambe entranti o uscenti, elimino la seconda + if ( ( vInters[i].first == SLT_IN && vInters[j].first == SLT_IN) || + ( vInters[i].first == SLT_OUT && vInters[j].first == SLT_OUT)) { + vInters.erase( vInters.begin() + j) ; + continue ; + } + // se una entrante e l'altra uscente, cambio in touch ed elimino la seconda + else if ( ( vInters[i].first == SLT_IN && vInters[j].first == SLT_OUT) || + ( vInters[i].first == SLT_OUT && vInters[j].first == SLT_IN)) { + vInters[i].first = SLT_TOUCH ; + vInters.erase( vInters.begin() + j) ; + continue ; + } + // se una puntuale e l'altra inizio di coincidenza, elimino la prima + else if ( ( vInters[i].first == SLT_IN || vInters[i].first == SLT_OUT || vInters[i].first == SLT_TOUCH) && vInters[j].first == SLT_TG_INI) { + vInters.erase( vInters.begin() + i) ; + continue ; + } + // se una fine di coincidenza e l'altra puntuale, elimino la seconda + else if ( vInters[i].first == SLT_TG_FIN && ( vInters[j].first == SLT_IN || vInters[j].first == SLT_OUT || vInters[j].first == SLT_TOUCH)) { + vInters.erase( vInters.begin() + j) ; + continue ; + } + // se una fine di coincidenza e l'altra inizio di coincidenza, elimino entrambe + else if ( i > 0 && vInters[i].first == SLT_TG_FIN && vInters[j].first == SLT_TG_INI) { + vInters.erase( vInters.begin() + j) ; + vInters.erase( vInters.begin() + i) ; + -- j ; + continue ; + } + } + // passo alla successiva + ++ j ; + } + + return true ; +} + +//------------------------------------------------------------------------------- +bool +ExeSurfTmLineInters( int nId, const Point3d& ptP, const Vector3d& vtDir, int nRefType, INTDBLVECTOR& vInters) +{ + 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 suo riferimento globale + Frame3d frSurf ; + if ( ! pGeomDB->GetGlobFrame( nId, frSurf)) + return false ; + // porto in locale il punto e la direzione della linea + Point3d ptPL = GetPointLocal( pGeomDB, ptP, nRefType, frSurf) ; + Vector3d vtDirL = GetVectorLocal( pGeomDB, vtDir, nRefType, frSurf) ; + vtDirL.Normalize() ; + // calcolo l'ingombro della trimesh + BBox3d b3Surf ; + if ( ! pStm->GetLocalBBox( b3Surf)) + return false ; + // calcolo l'intersezione + double dLen = b3Surf.MaxDistFromPoint( ptPL) ; + ILSIVECTOR vInfo ; + if ( ! IntersLineSurfTm( ptPL, vtDirL, dLen, *pStm, vInfo, false)) + return false ; + // ciclo sulle intersezioni + for ( const auto& Info : vInfo) { + // se intersezione puntuale + if ( Info.nILTT == ILTT_VERT || Info.nILTT == ILTT_EDGE || Info.nILTT == ILTT_IN) { + int nFlag = SLT_TOUCH ; + if ( Info.dCosDN > EPS_ZERO) + nFlag = SLT_OUT ; + else if ( Info.dCosDN < -EPS_ZERO) + nFlag = SLT_IN ; + vInters.emplace_back( nFlag, Info.dU) ; + } + // se altrimenti intersezione con coincidenza + else if ( Info.nILTT == ILTT_SEGM || Info.nILTT == ILTT_SEGM_ON_EDGE) { + vInters.emplace_back( SLT_TG_INI, Info.dU) ; + vInters.emplace_back( SLT_TG_FIN, Info.dU2) ; + } + } + // elimino intersezioni ripetute + for ( size_t j = 1 ; j < vInters.size() ; ) { + // intersezione precedente + size_t i = j - 1 ; + // se hanno lo stesso parametro + if ( abs( vInters[i].second - vInters[j].second) < EPS_SMALL) { + // se sono entrambe entranti o uscenti, elimino la seconda + if ( ( vInters[i].first == SLT_IN && vInters[j].first == SLT_IN) || + ( vInters[i].first == SLT_OUT && vInters[j].first == SLT_OUT)) { + vInters.erase( vInters.begin() + j) ; + continue ; + } + // se una entrante e l'altra uscente, cambio in touch ed elimino la seconda + else if ( ( vInters[i].first == SLT_IN && vInters[j].first == SLT_OUT) || + ( vInters[i].first == SLT_OUT && vInters[j].first == SLT_IN)) { + vInters[i].first = SLT_TOUCH ; + vInters.erase( vInters.begin() + j) ; + continue ; + } + // se una puntuale e l'altra inizio di coincidenza, elimino la prima + else if ( ( vInters[i].first == SLT_IN || vInters[i].first == SLT_OUT || vInters[i].first == SLT_TOUCH) && vInters[j].first == SLT_TG_INI) { + vInters.erase( vInters.begin() + i) ; + continue ; + } + // se una fine di coincidenza e l'altra puntuale, elimino la seconda + else if ( vInters[i].first == SLT_TG_FIN && ( vInters[j].first == SLT_IN || vInters[j].first == SLT_OUT || vInters[j].first == SLT_TOUCH)) { + vInters.erase( vInters.begin() + j) ; + continue ; + } + // se una fine di coincidenza e l'altra inizio di coincidenza, elimino entrambe + else if ( i > 0 && vInters[i].first == SLT_TG_FIN && vInters[j].first == SLT_TG_INI) { + vInters.erase( vInters.begin() + j) ; + vInters.erase( vInters.begin() + i) ; + -- j ; + continue ; + } + } + // passo alla successiva + ++ j ; + } + + return true ; +} + +//------------------------------------------------------------------------------- +static int +MySurfTmPlaneInters( int nId, const Point3d& ptOn, const Vector3d& vtN, int nDestGrpId, int nRefType, + int* pnPntCount, int* pnCrvCount, int* pnSrfCount) +{ + IGeomDB* pGeomDB = GetCurrGeomDB() ; + VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL) + // recupero la superficie TriMesh + const ISurfTriMesh* pStm = GetSurfTriMesh( pGeomDB->GetGeoObj( nId)) ; + if ( pStm == nullptr) + return GDB_ID_NULL ; + // recupero il suo riferimento globale + Frame3d frSurf ; + if ( ! pGeomDB->GetGlobFrame( nId, frSurf)) + return GDB_ID_NULL ; + // recupero il riferimento del gruppo di destinazione + Frame3d frDest ; + if ( ! pGeomDB->GetGroupGlobFrame( nDestGrpId, frDest)) + return GDB_ID_NULL ; + // porto in locale il punto e la normale del piano + Point3d ptOnL = GetPointLocal( pGeomDB, ptOn, nRefType, frSurf) ; + Vector3d vtNL = GetVectorLocal( pGeomDB, vtN, nRefType, frSurf) ; + // calcolo il piano di intersezione + Plane3d plPlane ; + if ( ! plPlane.Set( ptOnL, vtNL)) + return GDB_ID_NULL ; + // eseguo l'intersezione + PNTVECTOR vPnt ; + BIPNTVECTOR vBpt ; + TRIA3DVECTOR vTria ; + if ( ! IntersPlaneSurfTm( plPlane, *pStm, vPnt, vBpt, vTria)) + return GDB_ID_NULL ; + // Inserisco il risultato nel DB + int nFirstId = GDB_ID_NULL ; + int nPntCount = 0 ; + int nCrvCount = 0 ; + int nSrfCount = 0 ; + // Inserisco i punti nel DB + for ( size_t i = 0 ; i < vPnt.size() ; ++ i) { + // creo il punto + PtrOwner pGeoPnt( CreateGeoPoint3d()) ; + if ( ! IsNull( pGeoPnt)) + return GDB_ID_NULL ; + // setto il punto + pGeoPnt->Set( vPnt[i]) ; + // porto il punto nel riferimento destinazione + pGeoPnt->LocToLoc( frSurf, frDest) ; + // lo inserisco nel DB geometrico + int nNewId = pGeomDB->AddGeoObj( GDB_ID_NULL, nDestGrpId, Release( pGeoPnt)) ; + if ( nNewId == GDB_ID_NULL) + return GDB_ID_NULL ; + // copio il materiale + if ( ! pGeomDB->CopyMaterial( nId, nNewId)) + return GDB_ID_NULL ; + // aggiorno contatori + if ( nFirstId == GDB_ID_NULL) + nFirstId = nNewId ; + ++ nPntCount ; + } + // Concateno i tratti di curva + double dToler = 20 * EPS_SMALL ; + ChainCurves chainC ; + chainC.Init( false, dToler, int( vBpt.size())) ; + for ( size_t i = 0 ; i < vBpt.size() ; ++ i) { + Vector3d vtDir = vBpt[i].second - vBpt[i].first ; + vtDir.Normalize() ; + if ( ! chainC.AddCurve( int( i) + 1, vBpt[i].first, vtDir, vBpt[i].second, vtDir)) + return GDB_ID_NULL ; + } + // recupero i percorsi concatenati + Point3d ptNear = ( vBpt.empty() ? ORIG : vBpt[0].first) ; + INTVECTOR vId ; + while ( chainC.GetChainFromNear( ptNear, false, vId)) { + // creo una curva composita + PtrOwner pCrvCompo( CreateCurveComposite()) ; + if ( IsNull( pCrvCompo)) + return GDB_ID_NULL ; + // recupero gli estremi dei segmenti, creo le linee e le inserisco nella composita + for ( size_t i = 0 ; i < vId.size() ; ++ i) { + // creo una segmento di retta + int nInd = abs( vId[i]) - 1 ; + bool bInvert = ( vId[i] < 0) ; + PtrOwner pLine( CreateCurveLine()) ; + if ( IsNull( pLine) || ! pLine->Set( vBpt[nInd].first, vBpt[nInd].second)) + return GDB_ID_NULL ; + if ( bInvert) + pLine->Invert() ; + // lo accodo alla composita + if ( ! pCrvCompo->AddCurve( Release( pLine), true, dToler)) + return GDB_ID_NULL ; + // aggiorno il prossimo near + ptNear = vBpt[nInd].second ; + } + // se lunghezza curva inferiore a 5 volte la tolleranza, la salto + double dCrvLen ; + if ( ! pCrvCompo->GetLength( dCrvLen) || dCrvLen < 5. * dToler) + continue ; + // se curva chiusa entro 5 volte la tolleranza ma considerata aperta, la chiudo bene + Point3d ptStart, ptEnd ; + if ( pCrvCompo->GetStartPoint( ptStart) && + pCrvCompo->GetEndPoint( ptEnd) && + AreSamePointEpsilon( ptStart, ptEnd, 5. * dToler) && + ! AreSamePointApprox( ptStart, ptEnd)) { + // porto il punto finale a coincidere esattamente con l'inizio + pCrvCompo->ModifyEnd( ptStart) ; + } + // assegno estrusione come direzione normale al piano + pCrvCompo->SetExtrusion( plPlane.GetVersN()) ; + // unisco segmenti allineati + pCrvCompo->MergeCurves( 0.5 * dToler, ANG_TOL_STD_DEG) ; + // porto la curva nel riferimento destinazione + pCrvCompo->LocToLoc( frSurf, frDest) ; + // la inserisco nel DB geometrico + int nNewId = pGeomDB->AddGeoObj( GDB_ID_NULL, nDestGrpId, Release( pCrvCompo)) ; + if ( nNewId == GDB_ID_NULL) + return GDB_ID_NULL ; + // copio il materiale + if ( ! pGeomDB->CopyMaterial( nId, nNewId)) + return GDB_ID_NULL ; + // aggiorno contatori + if ( nFirstId == GDB_ID_NULL) + nFirstId = nNewId ; + ++ nCrvCount ; + } + // Costruisco una superficie trimesh dall'insieme di triangoli + StmFromTriangleSoup StmFts ; + if ( ! StmFts.Start()) + return GDB_ID_NULL ; + for ( size_t i = 0 ; i < vTria.size() ; ++ i) + // inserisco il triangolo nella nuova superficie + StmFts.AddTriangle( vTria[i]) ; + // valido la superficie e calcolo le adiacenze + if ( ! StmFts.End()) + return GDB_ID_NULL ; + // se superficie con triangoli + PtrOwner pNewStm( StmFts.GetSurf()) ; + if ( ! IsNull( pNewStm) && pNewStm->GetTriangleCount() > 0) { + // porto la superficie nel riferimento destinazione + pNewStm->LocToLoc( frSurf, frDest) ; + // la inserisco nel DB + int nNewId = pGeomDB->AddGeoObj( GDB_ID_NULL, nDestGrpId, Release( pNewStm)) ; + if ( nNewId == GDB_ID_NULL) + return GDB_ID_NULL ; + // copio il materiale + if ( ! pGeomDB->CopyMaterial( nId, nNewId)) + return GDB_ID_NULL ; + // aggiorno contatori + if ( nFirstId == GDB_ID_NULL) + nFirstId = nNewId ; + ++ nSrfCount ; + } + // aggiorno contatori + if ( pnPntCount != nullptr) + *pnPntCount = nPntCount ; + if ( pnCrvCount != nullptr) + *pnCrvCount = nCrvCount ; + if ( pnSrfCount != nullptr) + *pnSrfCount = nSrfCount ; + // restituisco l'identificativo della prima nuova entità + return nFirstId ; +} + +//------------------------------------------------------------------------------- +int +ExeSurfTmPlaneInters( int nId, const Point3d& ptOn, const Vector3d& vtN, int nDestGrpId, int nRefType, + int* pnPntCount, int* pnCrvCount, int* pnSrfCount) +{ + // eseguo + int nPntCount = 0 ; + int nCrvCount = 0 ; + int nSrfCount = 0 ; + int nFirstId = MySurfTmPlaneInters( nId, ptOn, vtN, nDestGrpId, nRefType, &nPntCount, &nCrvCount, &nSrfCount) ; + // aggiorno contatori + if ( nFirstId != GDB_ID_NULL) { + if ( pnPntCount != nullptr) + *pnPntCount = nPntCount ; + if ( pnCrvCount != nullptr) + *pnCrvCount = nCrvCount ; + if ( pnSrfCount != nullptr) + *pnSrfCount = nSrfCount ; + ExeSetModified() ; + } + // se richiesto, salvo il comando Lua equivalente + if ( IsCmdLog()) { + string sLua = "EgtSurfTmPlaneInters(" + ToString( nId) + ",{" + + ToString( ptOn) + "},{" + + ToString( vtN) + "}," + + ToString( nDestGrpId) + "," + + RefTypeToString( nRefType) + ")" + + " -- Id1=" + ToString( nFirstId) + ", PntNbr=" + ToString( nPntCount) + + ", CrvNbr=" + ToString( nCrvCount) + ", SrfNbr=" + ToString( nSrfCount) ; + LOG_INFO( GetCmdLogger(), sLua.c_str()) ; + } + // restituisco l'identificativo della prima nuova entità + return nFirstId ; +} + +//------------------------------------------------------------------------------- +static int +MySurfTmSurfTmInters( int nId1, int nId2, int nDestGrpId, + int* pnPntCount, int* pnCrvCount, int* pnSrfCount) +{ + IGeomDB* pGeomDB = GetCurrGeomDB() ; + VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL) + // recupero il riferimento del gruppo di destinazione + Frame3d frDest ; + if ( ! pGeomDB->GetGroupGlobFrame( nDestGrpId, frDest)) + return GDB_ID_NULL ; + // recupero la prima superficie TriMesh espressa nel riferimento destinazione + SurfLocal Surf1Loc( pGeomDB, nId1, frDest) ; + const ISurfTriMesh* pStm1L = GetSurfTriMesh( Surf1Loc) ; + if ( pStm1L == nullptr) + return GDB_ID_NULL ; + // recupero la seconda superficie TriMesh espressa nel riferimento destinazione + SurfLocal Surf2Loc( pGeomDB, nId2, frDest) ; + const ISurfTriMesh* pStm2L = GetSurfTriMesh( Surf2Loc) ; + if ( pStm2L == nullptr) + return GDB_ID_NULL ; + // eseguo l'intersezione (già espressa nel riferimento destinazione) + PNTVECTOR vPnt ; + BIPNTVECTOR vBpt ; + TRIA3DVECTOR vTria ; + if ( ! IntersSurfTmSurfTm( *pStm1L, *pStm2L, vPnt, vBpt, vTria)) + return GDB_ID_NULL ; + // Inserisco il risultato nel DB + int nFirstId = GDB_ID_NULL ; + int nPntCount = 0 ; + int nCrvCount = 0 ; + int nSrfCount = 0 ; + // Inserisco i punti nel DB + for ( size_t i = 0 ; i < vPnt.size() ; ++ i) { + // creo il punto + PtrOwner pGeoPnt( CreateGeoPoint3d()) ; + if ( ! IsNull( pGeoPnt)) + return GDB_ID_NULL ; + // setto il punto + pGeoPnt->Set( vPnt[i]) ; + // lo inserisco nel DB geometrico + int nNewId = pGeomDB->AddGeoObj( GDB_ID_NULL, nDestGrpId, Release( pGeoPnt)) ; + if ( nNewId == GDB_ID_NULL) + return GDB_ID_NULL ; + // copio il materiale + if ( ! pGeomDB->CopyMaterial( nId1, nNewId)) + return GDB_ID_NULL ; + // aggiorno contatori + if ( nFirstId == GDB_ID_NULL) + nFirstId = nNewId ; + ++ nPntCount ; + } + // Concateno i tratti di curva + double dToler = 20 * EPS_SMALL ; + ChainCurves chainC ; + chainC.Init( false, dToler, int( vBpt.size())) ; + for ( size_t i = 0 ; i < vBpt.size() ; ++ i) { + Vector3d vtDir = vBpt[i].second - vBpt[i].first ; + vtDir.Normalize() ; + if ( ! chainC.AddCurve( int( i) + 1, vBpt[i].first, vtDir, vBpt[i].second, vtDir)) + return GDB_ID_NULL ; + } + // recupero i percorsi concatenati + Point3d ptNear = ( vBpt.empty() ? ORIG : vBpt[0].first) ; + INTVECTOR vId ; + while ( chainC.GetChainFromNear( ptNear, false, vId)) { + // creo una curva composita + PtrOwner pCrvCompo( CreateCurveComposite()) ; + if ( IsNull( pCrvCompo)) + return GDB_ID_NULL ; + // recupero gli estremi dei segmenti, creo le linee e le inserisco nella composita + for ( size_t i = 0 ; i < vId.size() ; ++ i) { + // creo una segmento di retta + int nInd = abs( vId[i]) - 1 ; + bool bInvert = ( vId[i] < 0) ; + PtrOwner pLine( CreateCurveLine()) ; + if ( IsNull( pLine) || ! pLine->Set( vBpt[nInd].first, vBpt[nInd].second)) + return GDB_ID_NULL ; + if ( bInvert) + pLine->Invert() ; + // lo accodo alla composita + if ( ! pCrvCompo->AddCurve( Release( pLine), true, dToler)) + return GDB_ID_NULL ; + // aggiorno il prossimo near + ptNear = vBpt[nInd].second ; + } + // se lunghezza curva inferiore a 5 volte la tolleranza, la salto + double dCrvLen ; + if ( ! pCrvCompo->GetLength( dCrvLen) || dCrvLen < 5. * dToler) + continue ; + // se curva chiusa entro 5 volte la tolleranza ma considerata aperta, la chiudo bene + Point3d ptStart, ptEnd ; + if ( pCrvCompo->GetStartPoint( ptStart) && + pCrvCompo->GetEndPoint( ptEnd) && + AreSamePointEpsilon( ptStart, ptEnd, 5. * dToler) && + ! AreSamePointApprox( ptStart, ptEnd)) { + // porto il punto finale a coincidere esattamente con l'inizio + pCrvCompo->ModifyEnd( ptStart) ; + } + // unisco segmenti allineati + pCrvCompo->MergeCurves( 0.5 * dToler, ANG_TOL_STD_DEG) ; + // la inserisco nel DB geometrico + int nNewId = pGeomDB->AddGeoObj( GDB_ID_NULL, nDestGrpId, Release( pCrvCompo)) ; + if ( nNewId == GDB_ID_NULL) + return GDB_ID_NULL ; + // copio il materiale + if ( ! pGeomDB->CopyMaterial( nId1, nNewId)) + return GDB_ID_NULL ; + // aggiorno contatori + if ( nFirstId == GDB_ID_NULL) + nFirstId = nNewId ; + ++ nCrvCount ; + } + // Costruisco una superficie trimesh dall'insieme di triangoli + StmFromTriangleSoup StmFts ; + if ( ! StmFts.Start()) + return GDB_ID_NULL ; + for ( size_t i = 0 ; i < vTria.size() ; ++ i) + // inserisco il triangolo nella nuova superficie + StmFts.AddTriangle( vTria[i]) ; + // valido la superficie e calcolo le adiacenze + if ( ! StmFts.End()) + return GDB_ID_NULL ; + // se superficie con triangoli + PtrOwner pNewStm( StmFts.GetSurf()) ; + if ( ! IsNull( pNewStm) && pNewStm->GetTriangleCount() > 0) { + // la inserisco nel DB + int nNewId = pGeomDB->AddGeoObj( GDB_ID_NULL, nDestGrpId, Release( pNewStm)) ; + if ( nNewId == GDB_ID_NULL) + return GDB_ID_NULL ; + // copio il materiale + if ( ! pGeomDB->CopyMaterial( nId1, nNewId)) + return GDB_ID_NULL ; + // aggiorno contatori + if ( nFirstId == GDB_ID_NULL) + nFirstId = nNewId ; + ++ nSrfCount ; + } + // aggiorno contatori + if ( pnPntCount != nullptr) + *pnPntCount = nPntCount ; + if ( pnCrvCount != nullptr) + *pnCrvCount = nCrvCount ; + if ( pnSrfCount != nullptr) + *pnSrfCount = nSrfCount ; + // restituisco l'identificativo della prima nuova entità + return nFirstId ; +} + +//------------------------------------------------------------------------------- +int +ExeSurfTmSurfTmInters( int nId1, int nId2, int nDestGrpId, + int* pnPntCount, int* pnCrvCount, int* pnSrfCount) +{ + // eseguo + int nPntCount = 0 ; + int nCrvCount = 0 ; + int nSrfCount = 0 ; + int nFirstId = MySurfTmSurfTmInters( nId1, nId2, nDestGrpId, &nPntCount, &nCrvCount, &nSrfCount) ; + // aggiorno contatori + if ( nFirstId != GDB_ID_NULL) { + if ( pnPntCount != nullptr) + *pnPntCount = nPntCount ; + if ( pnCrvCount != nullptr) + *pnCrvCount = nCrvCount ; + if ( pnSrfCount != nullptr) + *pnSrfCount = nSrfCount ; + ExeSetModified() ; + } + // se richiesto, salvo il comando Lua equivalente + if ( IsCmdLog()) { + string sLua = "EgtSurfTmSurfTmInters(" + ToString( nId1) + "," + + ToString( nId2) + "," + + ToString( nDestGrpId) + ")" + + " -- Id1=" + ToString( nFirstId) + ", PntNbr=" + ToString( nPntCount) + + ", CrvNbr=" + ToString( nCrvCount) + ", SrfNbr=" + ToString( nSrfCount) ; + LOG_INFO( GetCmdLogger(), sLua.c_str()) ; + } + // restituisco l'identificativo della prima nuova entità + return nFirstId ; +} + +//---------------------------------------------------------------------------- +int +MyVolZmapPlaneInters( int nId, const Point3d& ptOn, const Vector3d& vtN, int nDestGrpId, int nRefType, int* pnCount) +{ + IGeomDB* pGeomDB = GetCurrGeomDB() ; + VERIFY_GEOMDB( pGeomDB, false) + // recupero il riferimento locale + Frame3d frLoc ; + if ( ! pGeomDB->GetGlobFrame( nId, frLoc)) + return GDB_ID_NULL ; + // recupero il riferimento destinazione + Frame3d frDest ; + if ( ! pGeomDB->GetGlobFrame( nDestGrpId, frDest)) + return GDB_ID_NULL ; + // porto in locale il punto e la normale del piano + Point3d ptOnL = GetPointLocal( pGeomDB, ptOn, nRefType, frLoc) ; + Vector3d vtNL = GetVectorLocal( pGeomDB, vtN, nRefType, frLoc) ; + // calcolo il piano di intersezione + Plane3d plPlane ; + if ( ! plPlane.Set( ptOnL, vtNL)) + return GDB_ID_NULL ; + // recupero lo Zmap e calcolo l'intersezione + IVolZmap* pVZM = GetVolZmap( pGeomDB->GetGeoObj( nId)) ; + ICURVEPOVECTOR vpLoop ; + if ( pVZM == nullptr || ! pVZM->GetPlaneIntersection( plPlane, vpLoop)) + return GDB_ID_NULL ; + // inserisco le curve nel gruppo destinazione + int nFirstId = GDB_ID_NULL ; + int nCount = 0 ; + for ( size_t i = 0 ; i < vpLoop.size() ; ++ i) { + PtrOwner pCrv( Release( vpLoop[i])) ; + if ( IsNull( pCrv)) + continue ; + pCrv->ToLoc( frDest) ; + // inserisco la curva composita nel gruppo destinazione + int nNewId = pGeomDB->AddGeoObj( GDB_ID_NULL, nDestGrpId, ::Release( pCrv)) ; + if ( nNewId == GDB_ID_NULL) + return GDB_ID_NULL ; + if ( nFirstId == GDB_ID_NULL) + nFirstId = nNewId ; + ++ nCount ; + } + // aggiorno contatore + if ( pnCount != nullptr) + *pnCount = nCount ; + // restituisco l'identificativo della prima nuova entità + return nFirstId ; +} + +//---------------------------------------------------------------------------- +int +ExeVolZmapPlaneInters( int nId, const Point3d& ptOn, const Vector3d& vtN, int nDestGrpId, int nRefType, int* pnCount) +{ + // eseguo + int nCount = 0 ; + int nFirstId = MyVolZmapPlaneInters( nId, ptOn, vtN, nDestGrpId, nRefType, &nCount) ; + if ( pnCount != nullptr) + *pnCount = nCount ; + ExeSetModified() ; + // se richiesto, salvo il comando Lua equivalente + if ( IsCmdLog()) { + string sLua = "EgtVolZmapPlaneInters(" + IdToString( nId) + ",{" + + ToString( ptOn) + "},{" + + ToString( vtN) + "}," + + ToString( nDestGrpId) + + RefTypeToString( nRefType) + ")" + + " -- Id=" + ToString( nFirstId) + ",Nbr=" + ToString( nCount) ; + LOG_INFO( GetCmdLogger(), sLua.c_str()) ; + } + // restituisco l'identificativo della prima nuova entità + return nFirstId ; +} diff --git a/EXE_GeoSnap.cpp b/EXE_GeoSnap.cpp index 8aef73f..97cef27 100644 --- a/EXE_GeoSnap.cpp +++ b/EXE_GeoSnap.cpp @@ -87,7 +87,7 @@ ExeStartPoint( int nId, int nRefId, Point3d& ptP) else return false ; // gestione trasformazione ( eventuale) - return TrasformPoint( pGeomDB, nId, nRefId, ptP) ; + return TransformPoint( pGeomDB, nId, nRefId, ptP) ; } //---------------------------------------------------------------------------- @@ -124,7 +124,7 @@ ExeEndPoint( int nId, int nRefId, Point3d& ptP) else return false ; // gestione trasformazione ( eventuale) - return TrasformPoint( pGeomDB, nId, nRefId, ptP) ; + return TransformPoint( pGeomDB, nId, nRefId, ptP) ; } //---------------------------------------------------------------------------- @@ -156,7 +156,7 @@ ExeMidPoint( int nId, int nRefId, Point3d& ptP) else return false ; // gestione trasformazione ( eventuale) - return TrasformPoint( pGeomDB, nId, nRefId, ptP) ; + return TransformPoint( pGeomDB, nId, nRefId, ptP) ; } //---------------------------------------------------------------------------- @@ -196,7 +196,7 @@ ExeCenterPoint( int nId, int nRefId, Point3d& ptP) else return false ; // gestione trasformazione ( eventuale) - return TrasformPoint( pGeomDB, nId, nRefId, ptP) ; + return TransformPoint( pGeomDB, nId, nRefId, ptP) ; } //---------------------------------------------------------------------------- @@ -236,7 +236,7 @@ ExeCentroid( int nId, int nRefId, Point3d& ptP) else return false ; // gestione trasformazione ( eventuale) - return TrasformPoint( pGeomDB, nId, nRefId, ptP) ; + return TransformPoint( pGeomDB, nId, nRefId, ptP) ; } //---------------------------------------------------------------------------- @@ -259,7 +259,7 @@ ExeAtParamPoint( int nId, double dU, int nRefId, Point3d& ptP) else return false ; // gestione trasformazione ( eventuale) - return TrasformPoint( pGeomDB, nId, nRefId, ptP) ; + return TransformPoint( pGeomDB, nId, nRefId, ptP) ; } //---------------------------------------------------------------------------- @@ -274,7 +274,7 @@ ExeNearPoint( int nId, const Point3d& ptNear, int nRefId, Point3d& ptP) return false ; // porto il punto near nel riferimento dell'entità Point3d ptNearL = ptNear ; - if ( ! InvTrasformPoint( pGeomDB, nId, nRefId, ptNearL)) + if ( ! InvTransformPoint( pGeomDB, nId, nRefId, ptNearL)) return false ; // se curva if ( ( pGObj->GetType() & GEO_CURVE) != 0) { @@ -289,7 +289,7 @@ ExeNearPoint( int nId, const Point3d& ptNear, int nRefId, Point3d& ptP) else return false ; // gestione trasformazione ( eventuale) - return TrasformPoint( pGeomDB, nId, nRefId, ptP) ; + return TransformPoint( pGeomDB, nId, nRefId, ptP) ; } //---------------------------------------------------------------------------- @@ -311,7 +311,7 @@ ExeIntersectionPoint( int nId1, int nId2, const Point3d& ptNear, int nRefId, Poi const ICurve* pCrv1 = GetCurve( pGObj1) ; // porto il punto Near nel riferimento dell'entità Point3d ptNearL = ptNear ; - if ( ! InvTrasformPoint( pGeomDB, nId1, nRefId, ptNearL)) + if ( ! InvTransformPoint( pGeomDB, nId1, nRefId, ptNearL)) return false ; // calcolo il punto di auto-intersezione sulla curva più vicino al punto di riferimento SelfIntersCurve sintC( *pCrv1) ; @@ -321,7 +321,7 @@ ExeIntersectionPoint( int nId1, int nId2, const Point3d& ptNear, int nRefId, Poi else return false ; // gestione trasformazione ( eventuale) - return TrasformPoint( pGeomDB, nId1, nRefId, ptP) ; + return TransformPoint( pGeomDB, nId1, nRefId, ptP) ; } // devono essere entità geometriche @@ -354,7 +354,7 @@ ExeIntersectionPoint( int nId1, int nId2, const Point3d& ptNear, int nRefId, Poi } // porto il punto Near nel riferimento della prima entità Point3d ptNearL = ptNear ; - if ( ! InvTrasformPoint( pGeomDB, nId1, nRefId, ptNearL)) + if ( ! InvTransformPoint( 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) ; @@ -364,7 +364,7 @@ ExeIntersectionPoint( int nId1, int nId2, const Point3d& ptNear, int nRefId, Poi else return false ; // gestione trasformazione ( eventuale) - return TrasformPoint( pGeomDB, nId1, nRefId, ptP) ; + return TransformPoint( pGeomDB, nId1, nRefId, ptP) ; } //---------------------------------------------------------------------------- @@ -402,7 +402,7 @@ ExeStartVector( int nId, int nRefId, Vector3d& vtV) else return false ; // gestione trasformazione ( eventuale) - return TrasformVector( pGeomDB, nId, nRefId, vtV) ; + return TransformVector( pGeomDB, nId, nRefId, vtV) ; } //---------------------------------------------------------------------------- @@ -426,7 +426,7 @@ ExeEndVector( int nId, int nRefId, Vector3d& vtV) else return false ; // gestione trasformazione ( eventuale) - return TrasformVector( pGeomDB, nId, nRefId, vtV) ; + return TransformVector( pGeomDB, nId, nRefId, vtV) ; } //---------------------------------------------------------------------------- @@ -450,7 +450,7 @@ ExeMidVector( int nId, int nRefId, Vector3d& vtV) else return false ; // gestione trasformazione ( eventuale) - return TrasformVector( pGeomDB, nId, nRefId, vtV) ; + return TransformVector( pGeomDB, nId, nRefId, vtV) ; } //---------------------------------------------------------------------------- @@ -479,7 +479,7 @@ ExeAtParamVector( int nId, double dU, int nSide, int nRefId, Vector3d& vtV) else return false ; // gestione trasformazione ( eventuale) - return TrasformVector( pGeomDB, nId, nRefId, vtV) ; + return TransformVector( pGeomDB, nId, nRefId, vtV) ; } //---------------------------------------------------------------------------- @@ -491,14 +491,14 @@ ExeFrame( int nId, int nRefId, Frame3d& frFrame) // se gruppo if ( pGeomDB->GetGroupFrame( nId, frFrame)) // gestione trasformazione ( eventuale) - return TrasformFrame( pGeomDB, nId, nRefId, frFrame) ; + return TransformFrame( pGeomDB, nId, nRefId, frFrame) ; // se geo frame const IGeoObj* pGObj ; if ( ( pGObj = pGeomDB->GetGeoObj( nId)) != nullptr && pGObj->GetType() == GEO_FRAME3D) { frFrame = GetGeoFrame3d( pGObj)->GetFrame() ; // gestione trasformazione ( eventuale) - return TrasformFrame( pGeomDB, nId, nRefId, frFrame) ; + return TransformFrame( pGeomDB, nId, nRefId, frFrame) ; } // errore return false ; @@ -659,7 +659,7 @@ ExeCurveExtrusion( int nId, int nRefId, Vector3d& vtExtr) if ( pCurve == nullptr || ! pCurve->GetExtrusion( vtExtr)) return false ; // gestione trasformazione ( eventuale) - return TrasformVector( pGeomDB, nId, nRefId, vtExtr) ; + return TransformVector( pGeomDB, nId, nRefId, vtExtr) ; } //---------------------------------------------------------------------------- @@ -881,7 +881,7 @@ ExeArcNormVersor( int nId, int nRefId, Vector3d& vtNorm) // recupero la normale vtNorm = pArc->GetNormVersor() ; // gestione trasformazione ( eventuale) - return TrasformVector( pGeomDB, nId, nRefId, vtNorm) ; + return TransformVector( pGeomDB, nId, nRefId, vtNorm) ; } //---------------------------------------------------------------------------- @@ -902,7 +902,7 @@ ExeCurveCompoCenter( int nId, int nSimpCrv, int nRefId, Point3d& ptCen) if ( ! pSimpCrv->GetCenterPoint( ptCen)) return false ; // gestione trasformazione ( eventuale) - return TrasformPoint( pGeomDB, nId, nRefId, ptCen) ; + return TransformPoint( pGeomDB, nId, nRefId, ptCen) ; } //---------------------------------------------------------------------------- @@ -948,7 +948,7 @@ ExeSurfFrNormVersor( int nId, int nRefId, Vector3d& vtNorm) // recupero la normale vtNorm = pSfr->GetNormVersor() ; // gestione trasformazione ( eventuale) - return TrasformVector( pGeomDB, nId, nRefId, vtNorm) ; + return TransformVector( pGeomDB, nId, nRefId, vtNorm) ; } //---------------------------------------------------------------------------- @@ -1067,13 +1067,13 @@ ExeSurfTmFacetNearestEndPoint( int nId, int nFacet, const Point3d& ptNear, int n return false ; // porto il punto Near nel riferimento dell'entità Point3d ptNearL = ptNear ; - if ( ! InvTrasformPoint( pGeomDB, nId, nRefId, ptNearL)) + if ( ! InvTransformPoint( 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) ; + return TransformPoint( pGeomDB, nId, nRefId, ptEnd) && TransformVector( pGeomDB, nId, nRefId, vtN) ; } //---------------------------------------------------------------------------- @@ -1089,13 +1089,13 @@ ExeSurfTmFacetNearestMidPoint( int nId, int nFacet, const Point3d& ptNear, int n return false ; // porto il punto Near nel riferimento dell'entità Point3d ptNearL = ptNear ; - if ( ! InvTrasformPoint( pGeomDB, nId, nRefId, ptNearL)) + if ( ! InvTransformPoint( 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) ; + return TransformPoint( pGeomDB, nId, nRefId, ptMid) && TransformVector( pGeomDB, nId, nRefId, vtN) ; } //---------------------------------------------------------------------------- @@ -1112,7 +1112,7 @@ ExeSurfTmFacetCenter( int nId, int nFacet, int nRefId, Point3d& ptCen, Vector3d& if ( ! pStm->GetFacetCenter( nFacet, ptCen, vtN)) return false ; // gestione trasformazioni ( eventuali) - return TrasformPoint( pGeomDB, nId, nRefId, ptCen) && TrasformVector( pGeomDB, nId, nRefId, vtN) ; + return TransformPoint( pGeomDB, nId, nRefId, ptCen) && TransformVector( pGeomDB, nId, nRefId, vtN) ; } //---------------------------------------------------------------------------- @@ -1129,12 +1129,13 @@ ExeSurfTmFacetNormVersor( int nId, int nFacet, int nRefId, Vector3d& vtNorm) if ( ! pStm->GetFacetNormal( nFacet, vtNorm)) return false ; // gestione trasformazione ( eventuale) - return TrasformVector( pGeomDB, nId, nRefId, vtNorm) ; + return TransformVector( pGeomDB, nId, nRefId, vtNorm) ; } //---------------------------------------------------------------------------- bool -ExeSurfTmFacetOppositeSide( int nId, int nFacet, const Vector3d& vtDir, int nRefId, Point3d& ptP1, Point3d& ptP2) +ExeSurfTmFacetOppositeSide( int nId, int nFacet, const Vector3d& vtDir, int nRefId, + Point3d& ptP1, Point3d& ptP2, Vector3d& vtIn1, Vector3d& vtOut2) { IGeomDB* pGeomDB = GetCurrGeomDB() ; VERIFY_GEOMDB( pGeomDB, false) @@ -1165,7 +1166,7 @@ ExeSurfTmFacetOppositeSide( int nId, int nFacet, const Vector3d& vtDir, int nRef pCrvCompo->MergeCurves( LIN_TOL_STD, ANG_TOL_STD_DEG) ; // porto la direzione nel riferimento della superficie Vector3d vtDirL = vtDir ; - if ( ! InvTrasformVector( pGeomDB, nId, nRefId, vtDirL)) + if ( ! InvTransformVector( pGeomDB, nId, nRefId, vtDirL)) return false ; // costruisco un riferimento con Z su normale e X vicino a direzione Frame3d frSpec ; @@ -1183,18 +1184,24 @@ ExeSurfTmFacetOppositeSide( int nId, int nFacet, const Vector3d& vtDir, int nRef while ( pCrv != nullptr) { Vector3d vtDir ; pCrv->GetMidDir( vtDir) ; if ( ( Z_AX ^ vtDir) * X_AX < COS_ANG_MAX) { + vtIn1 = vtDir ; + vtOut2 = vtDir ; pCrvCompo->ChangeStartPoint( i) ; break ; } pCrv = pCrvCompo->GetNextCurve() ; ++ i ; } + // se non trovato almeno un lato non valido, errore + if ( pCrv == nullptr) + return false ; // a partire da questo elimino elementi non validi in avanti e indietro pCrv = pCrvCompo->GetFirstCurve() ; while ( pCrv != nullptr) { Vector3d vtDir ; pCrv->GetMidDir( vtDir) ; if ( ( Z_AX ^ vtDir) * X_AX < COS_ANG_MAX) { ICurve* pErase = pCrvCompo->RemoveFirstOrLastCurve( false) ; + pErase->GetMidDir( vtIn1) ; delete( pErase) ; pCrv = pCrvCompo->GetFirstCurve() ; } @@ -1206,6 +1213,7 @@ ExeSurfTmFacetOppositeSide( int nId, int nFacet, const Vector3d& vtDir, int nRef Vector3d vtDir ; pCrv->GetMidDir( vtDir) ; if ( ( Z_AX ^ vtDir) * X_AX < COS_ANG_MAX) { ICurve* pErase = pCrvCompo->RemoveFirstOrLastCurve( true) ; + pErase->GetMidDir( vtOut2) ; delete( pErase) ; pCrv = pCrvCompo->GetLastCurve() ; } @@ -1218,7 +1226,10 @@ ExeSurfTmFacetOppositeSide( int nId, int nFacet, const Vector3d& vtDir, int nRef // li porto nel riferimento della superficie e poi in quello richiesto ptP1.ToGlob( frSpec) ; ptP2.ToGlob( frSpec) ; - return TrasformPoint( pGeomDB, nId, nRefId, ptP1) && TrasformPoint( pGeomDB, nId, nRefId, ptP2) ; + vtIn1.ToGlob( frSpec) ; + vtOut2.ToGlob( frSpec) ; + return ( TransformPoint( pGeomDB, nId, nRefId, ptP1) && TransformPoint( pGeomDB, nId, nRefId, ptP2) && + TransformVector( pGeomDB, nId, nRefId, vtIn1) && TransformVector( pGeomDB, nId, nRefId, vtOut2)) ; } //---------------------------------------------------------------------------- @@ -1236,99 +1247,11 @@ ExeSurfTmFacetsContact( int nId, int nF1, int nF2, int nRefId, bool& bAdjac, Poi return false ; // gestione trasformazione ( eventuale) if ( bAdjac) - return TrasformPoint( pGeomDB, nId, nRefId, ptP1) && TrasformPoint( pGeomDB, nId, nRefId, ptP2) ; + return TransformPoint( pGeomDB, nId, nRefId, ptP1) && TransformPoint( pGeomDB, nId, nRefId, ptP2) ; else return true ; } -//------------------------------------------------------------------------------- -bool -ExeSurfTmLineInters( int nId, const Point3d& ptP, const Vector3d& vtDir, int nRefType, INTDBLVECTOR& vInters) -{ - 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 suo riferimento globale - Frame3d frSurf ; - if ( ! pGeomDB->GetGlobFrame( nId, frSurf)) - return false ; - // porto in locale il punto e la direzione della linea - Point3d ptPL = GetPointLocal( pGeomDB, ptP, nRefType, frSurf) ; - Vector3d vtDirL = GetVectorLocal( pGeomDB, vtDir, nRefType, frSurf) ; - vtDirL.Normalize() ; - // calcolo l'ingombro della trimesh - BBox3d b3Surf ; - if ( ! pStm->GetLocalBBox( b3Surf)) - return false ; - // calcolo l'intersezione - double dLen = b3Surf.MaxDistFromPoint( ptPL) ; - ILSIVECTOR vInfo ; - if ( ! IntersLineSurfTm( ptPL, vtDirL, dLen, *pStm, vInfo, false)) - return false ; - // ciclo sulle intersezioni - for ( const auto& Info : vInfo) { - // se intersezione puntuale - if ( Info.nILTT == ILTT_VERT || Info.nILTT == ILTT_EDGE || Info.nILTT == ILTT_IN) { - int nFlag = SLT_TOUCH ; - if ( Info.dCosDN > EPS_ZERO) - nFlag = SLT_OUT ; - else if ( Info.dCosDN < -EPS_ZERO) - nFlag = SLT_IN ; - vInters.emplace_back( nFlag, Info.dU) ; - } - // se altrimenti intersezione con coincidenza - else if ( Info.nILTT == ILTT_SEGM || Info.nILTT == ILTT_SEGM_ON_EDGE) { - vInters.emplace_back( SLT_TG_INI, Info.dU) ; - vInters.emplace_back( SLT_TG_FIN, Info.dU2) ; - } - } - // elimino intersezioni ripetute - for ( size_t j = 1 ; j < vInters.size() ; ) { - // intersezione precedente - size_t i = j - 1 ; - // se hanno lo stesso parametro - if ( abs( vInters[i].second - vInters[j].second) < EPS_SMALL) { - // se sono entrambe entranti o uscenti, elimino la seconda - if ( ( vInters[i].first == SLT_IN && vInters[j].first == SLT_IN) || - ( vInters[i].first == SLT_OUT && vInters[j].first == SLT_OUT)) { - vInters.erase( vInters.begin() + j) ; - continue ; - } - // se una entrante e l'altra uscente, cambio in touch ed elimino la seconda - else if ( ( vInters[i].first == SLT_IN && vInters[j].first == SLT_OUT) || - ( vInters[i].first == SLT_OUT && vInters[j].first == SLT_IN)) { - vInters[i].first = SLT_TOUCH ; - vInters.erase( vInters.begin() + j) ; - continue ; - } - // se una puntuale e l'altra inizio di coincidenza, elimino la prima - else if ( ( vInters[i].first == SLT_IN || vInters[i].first == SLT_OUT || vInters[i].first == SLT_TOUCH) && vInters[j].first == SLT_TG_INI) { - vInters.erase( vInters.begin() + i) ; - continue ; - } - // se una fine di coincidenza e l'altra puntuale, elimino la seconda - else if ( vInters[i].first == SLT_TG_FIN && ( vInters[j].first == SLT_IN || vInters[j].first == SLT_OUT || vInters[j].first == SLT_TOUCH)) { - vInters.erase( vInters.begin() + j) ; - continue ; - } - // se una fine di coincidenza e l'altra inizio di coincidenza, elimino entrambe - else if ( i > 0 && vInters[i].first == SLT_TG_FIN && vInters[j].first == SLT_TG_INI) { - vInters.erase( vInters.begin() + j) ; - vInters.erase( vInters.begin() + i) ; - -- j ; - continue ; - } - } - // passo alla successiva - ++ j ; - } - - return true ; -} - //---------------------------------------------------------------------------- bool ExeVolZmapVolume( int nId, double& dVol) @@ -1386,7 +1309,7 @@ ExeTextNormVersor( int nId, int nRefId, Vector3d& vtNorm) // recupero la normale vtNorm = pTxt->GetNormVersor() ; // gestione trasformazione ( eventuale) - return TrasformVector( pGeomDB, nId, nRefId, vtNorm) ; + return TransformVector( pGeomDB, nId, nRefId, vtNorm) ; } //---------------------------------------------------------------------------- diff --git a/EgtExecutor.rc b/EgtExecutor.rc index b83b3c7..1cc6cbc 100644 Binary files a/EgtExecutor.rc and b/EgtExecutor.rc differ diff --git a/EgtExecutor.vcxproj b/EgtExecutor.vcxproj index 2738e8d..7959772 100644 --- a/EgtExecutor.vcxproj +++ b/EgtExecutor.vcxproj @@ -239,6 +239,7 @@ copy $(TargetPath) \EgtProg\Dll64 + @@ -277,6 +278,7 @@ copy $(TargetPath) \EgtProg\Dll64 + diff --git a/EgtExecutor.vcxproj.filters b/EgtExecutor.vcxproj.filters index a202da3..c732106 100644 --- a/EgtExecutor.vcxproj.filters +++ b/EgtExecutor.vcxproj.filters @@ -323,6 +323,12 @@ File di origine\LUA + + File di origine\EXE + + + File di origine\LUA + diff --git a/GeoTools.cpp b/GeoTools.cpp index 77db7cb..f12227e 100644 --- a/GeoTools.cpp +++ b/GeoTools.cpp @@ -84,7 +84,7 @@ GetFrameLocal( IGeomDB* pGeomDB, const Frame3d& frRef, int nRefType, const Frame //---------------------------------------------------------------------------- bool -TrasformPoint( IGeomDB* pGeomDB, int nId, int nRefId, Point3d& ptP) +TransformPoint( IGeomDB* pGeomDB, int nId, int nRefId, Point3d& ptP) { // se non va trasformato, esco if ( nRefId == nId) @@ -112,7 +112,7 @@ TrasformPoint( IGeomDB* pGeomDB, int nId, int nRefId, Point3d& ptP) //---------------------------------------------------------------------------- bool -InvTrasformPoint( IGeomDB* pGeomDB, int nId, int nRefId, Point3d& ptP) +InvTransformPoint( IGeomDB* pGeomDB, int nId, int nRefId, Point3d& ptP) { // se non va trasformato, esco if ( nRefId == nId) @@ -140,7 +140,7 @@ InvTrasformPoint( IGeomDB* pGeomDB, int nId, int nRefId, Point3d& ptP) //---------------------------------------------------------------------------- bool -TrasformVector( IGeomDB* pGeomDB, int nId, int nRefId, Vector3d& vtV) +TransformVector( IGeomDB* pGeomDB, int nId, int nRefId, Vector3d& vtV) { // se non va trasformato, esco if ( nRefId == nId) @@ -168,7 +168,7 @@ TrasformVector( IGeomDB* pGeomDB, int nId, int nRefId, Vector3d& vtV) //---------------------------------------------------------------------------- bool -InvTrasformVector( IGeomDB* pGeomDB, int nId, int nRefId, Vector3d& vtV) +InvTransformVector( IGeomDB* pGeomDB, int nId, int nRefId, Vector3d& vtV) { // se non va trasformato, esco if ( nRefId == nId) @@ -196,7 +196,7 @@ InvTrasformVector( IGeomDB* pGeomDB, int nId, int nRefId, Vector3d& vtV) //---------------------------------------------------------------------------- bool -TrasformFrame( IGeomDB* pGeomDB, int nId, int nRefId, Frame3d& frF) +TransformFrame( IGeomDB* pGeomDB, int nId, int nRefId, Frame3d& frF) { // se non va trasformato, esco if ( nRefId == nId) diff --git a/GeoTools.h b/GeoTools.h index a4553e2..fd66328 100644 --- a/GeoTools.h +++ b/GeoTools.h @@ -30,15 +30,15 @@ Plane3d GetPlaneLocal( IGeomDB* pGeomDB, const Plane3d& plPlane, int nRefType, c // Riferimento espresso nel riferimento desiderato partendo da riferimento nel riferimento RefType Frame3d GetFrameLocal( IGeomDB* pGeomDB, const Frame3d& frRef, int nRefType, const Frame3d& frLoc) ; // Punto portato dal riferimento di nId a quello di nRefId -bool TrasformPoint( IGeomDB* pGeomDB, int nId, int nRefId, Point3d& ptP) ; +bool TransformPoint( IGeomDB* pGeomDB, int nId, int nRefId, Point3d& ptP) ; // Trasformazione inversa della precedente, dal riferimento di nRefId a quello di nId -bool InvTrasformPoint( IGeomDB* pGeomDB, int nId, int nRefId, Point3d& ptP) ; +bool InvTransformPoint( IGeomDB* pGeomDB, int nId, int nRefId, Point3d& ptP) ; // Vettore portato dal riferimento di nId a quello di nRefId -bool TrasformVector( IGeomDB* pGeomDB, int nId, int nRefId, Vector3d& vtV) ; +bool TransformVector( IGeomDB* pGeomDB, int nId, int nRefId, Vector3d& vtV) ; // Trasformazione inversa della precedente, dal riferimento di nRefId a quello di nId -bool InvTrasformVector( IGeomDB* pGeomDB, int nId, int nRefId, Vector3d& vtV) ; +bool InvTransformVector( IGeomDB* pGeomDB, int nId, int nRefId, Vector3d& vtV) ; // Riferimento portato dal riferimento di nId a quello di nRefId -bool TrasformFrame( IGeomDB* pGeomDB, int nId, int nRefId, Frame3d& frF) ; +bool TransformFrame( IGeomDB* pGeomDB, int nId, int nRefId, Frame3d& frF) ; // Verifica che tutti gli oggetti dell'insieme abbiano lo stesso riferimento bool VerifySameFrame( IGeomDB* pGeomDB, const INTVECTOR& vIds) ; diff --git a/LUA.h b/LUA.h index 14b6c12..5948afd 100644 --- a/LUA.h +++ b/LUA.h @@ -69,6 +69,9 @@ bool LuaInstallGeoSnap( LuaMgr& luaMgr) ; //-------------------------- GeoTransform ------------------------------------ bool LuaInstallGeoTransform( LuaMgr& luaMgr) ; +//-------------------------- GeoInters --------------------------------------- +bool LuaInstallGeoInters( LuaMgr& luaMgr) ; + //-------------------------- MachMgr ----------------------------------------- bool LuaInstallMachMgr( LuaMgr& luaMgr) ; diff --git a/LUA_Base.cpp b/LUA_Base.cpp index 2347254..1e1c539 100644 --- a/LUA_Base.cpp +++ b/LUA_Base.cpp @@ -98,6 +98,10 @@ LuaInstallEgtFunctions( LuaMgr& LuaMgr) LOG_ERROR( GetLogger(), "Error in LuaInstallGeoTransform (" __FUNCTION__ ")") return false ; } + if ( ! LuaInstallGeoInters( LuaMgr)) { + LOG_ERROR( GetLogger(), "Error in LuaInstallGeoInters (" __FUNCTION__ ")") + return false ; + } if ( ! LuaInstallMachMgr( LuaMgr)) { LOG_ERROR( GetLogger(), "Error in LuaInstallMachMgr (" __FUNCTION__ ")") return false ; diff --git a/LUA_GdbModifySurf.cpp b/LUA_GdbModifySurf.cpp index 7b15568..434ec53 100644 --- a/LUA_GdbModifySurf.cpp +++ b/LUA_GdbModifySurf.cpp @@ -293,66 +293,6 @@ LuaCopySurfTmFacet( lua_State* L) return 1 ; } -//---------------------------------------------------------------------------- -static int -LuaGetSurfTmPlaneInters( lua_State* L) -{ - // 4 o 5 parametri : Id, ptOn, vtN, nDestGrpId [, nRefType] - int nId ; - LuaCheckParam( L, 1, nId) - Point3d ptOn ; - LuaCheckParam( L, 2, ptOn) - Vector3d vtN ; - LuaCheckParam( L, 3, vtN) - int nDestGrpId ; - LuaGetParam( L, 4, nDestGrpId) ; - int nRefType = RTY_DEFAULT ; - LuaGetParam( L, 5, nRefType) ; - LuaClearStack( L) ; - // eseguo l'intersezione - int nPntCount = 0 ; - int nCrvCount = 0 ; - int nSrfCount = 0 ; - int nNewId = ExeGetSurfTmPlaneInters( nId, ptOn, vtN, nDestGrpId, nRefType, &nPntCount, &nCrvCount, &nSrfCount) ; - // restituisco il risultato - if ( nNewId != GDB_ID_NULL) - LuaSetParam( L, nNewId) ; - else - LuaSetParam( L) ; - LuaSetParam( L, nPntCount) ; - LuaSetParam( L, nCrvCount) ; - LuaSetParam( L, nSrfCount) ; - return 4 ; -} - -//---------------------------------------------------------------------------- -static int -LuaGetSurfTmSurfTmInters( lua_State* L) -{ - // 3 parametri : Id1, nId2, nDestGrpId - int nId1 ; - LuaCheckParam( L, 1, nId1) - int nId2 ; - LuaCheckParam( L, 2, nId2) - int nDestGrpId ; - LuaCheckParam( L, 3, nDestGrpId) ; - LuaClearStack( L) ; - // eseguo l'intersezione - int nPntCount = 0 ; - int nCrvCount = 0 ; - int nSrfCount = 0 ; - int nNewId = ExeGetSurfTmSurfTmInters( nId1, nId2, nDestGrpId, &nPntCount, &nCrvCount, &nSrfCount) ; - // restituisco il risultato - if ( nNewId != GDB_ID_NULL) - LuaSetParam( L, nNewId) ; - else - LuaSetParam( L) ; - LuaSetParam( L, nPntCount) ; - LuaSetParam( L, nCrvCount) ; - LuaSetParam( L, nSrfCount) ; - return 4 ; -} - //---------------------------------------------------------------------------- static int LuaCutSurfTmPlane( lua_State* L) @@ -394,8 +334,6 @@ LuaInstallGdbModifySurf( LuaMgr& luaMgr) bOk = bOk && luaMgr.RegisterFunction( "EgtGetSurfTmSilhouette", LuaGetSurfTmSilhouette) ; bOk = bOk && luaMgr.RegisterFunction( "EgtExtractSurfTmFacetLoops", LuaExtractSurfTmFacetLoops) ; bOk = bOk && luaMgr.RegisterFunction( "EgtCopySurfTmFacet", LuaCopySurfTmFacet) ; - bOk = bOk && luaMgr.RegisterFunction( "EgtGetSurfTmPlaneInters", LuaGetSurfTmPlaneInters) ; - bOk = bOk && luaMgr.RegisterFunction( "EgtGetSurfTmSurfTmInters", LuaGetSurfTmSurfTmInters) ; bOk = bOk && luaMgr.RegisterFunction( "EgtCutSurfTmPlane", LuaCutSurfTmPlane) ; return bOk ; } diff --git a/LUA_GdbModifyVol.cpp b/LUA_GdbModifyVol.cpp index 8b981ea..008adb5 100644 --- a/LUA_GdbModifyVol.cpp +++ b/LUA_GdbModifyVol.cpp @@ -319,39 +319,6 @@ LuaVolZmapGetDepth( lua_State* L) return 2 ; } -//---------------------------------------------------------------------------- -static int -LuaVolZmapIntersPlane( lua_State* L) -{ - // 4 o 5 parametri : nId, ptP, vtN, nDestGrpId [, nRefType] - int nId ; - LuaCheckParam( L, 1, nId) - Point3d ptP ; - LuaCheckParam( L, 2, ptP) - Vector3d vtN ; - LuaCheckParam( L, 3, vtN) - int nDestGrpId ; - LuaCheckParam( L, 4, nDestGrpId) - int nRefType = RTY_DEFAULT ; - LuaGetParam( L, 5, nRefType) ; - LuaClearStack( L) ; - // eseguo calcolo intersezione - Plane3d plPlane ; - plPlane.Set( ptP, vtN) ; - int nCount ; - int nFirstId = ExeVolZmapIntersPlane( nId, plPlane, nDestGrpId, nRefType, &nCount) ; - // restituisco il risultato - if ( nFirstId != GDB_ID_NULL) { - LuaSetParam( L, nFirstId) ; - LuaSetParam( L, nCount) ; - } - else { - LuaSetParam( L) ; - LuaSetParam( L) ; - } - return 2 ; -} - //---------------------------------------------------------------------------- static int LuaVolZmapAvoidBox( lua_State* L) @@ -410,9 +377,7 @@ LuaInstallGdbModifyVol( LuaMgr& luaMgr) bOk = bOk && luaMgr.RegisterFunction( "EgtVolZmapSetChiselTool", LuaVolZmapSetChiselTool) ; bOk = bOk && luaMgr.RegisterFunction( "EgtVolZmapMillingStep", LuaVolZmapMillingStep) ; bOk = bOk && luaMgr.RegisterFunction( "EgtVolZmapGetDepth", LuaVolZmapGetDepth) ; - bOk = bOk && luaMgr.RegisterFunction( "EgtVolZmapIntersPlane", LuaVolZmapIntersPlane) ; bOk = bOk && luaMgr.RegisterFunction( "EgtVolZmapAvoidBox", LuaVolZmapAvoidBox) ; bOk = bOk && luaMgr.RegisterFunction( "EgtVolZmapAvoidSphere", LuaVolZmapAvoidSphere) ; - return bOk ; } \ No newline at end of file diff --git a/LUA_GeoInters.cpp b/LUA_GeoInters.cpp new file mode 100644 index 0000000..9c393e4 --- /dev/null +++ b/LUA_GeoInters.cpp @@ -0,0 +1,193 @@ +//---------------------------------------------------------------------------- +// EgalTech 2018-2018 +//---------------------------------------------------------------------------- +// File : LUA_GeoInters.cpp Data : 27.09.18 Versione : 1.9i4 +// Contenuto : Funzioni di intersezioni tra oggetto geometrici per LUA. +// +// +// +// Modifiche : 27.09.18 DS Creazione modulo. +// +// +//---------------------------------------------------------------------------- + +//--------------------------- Include ---------------------------------------- +#include "stdafx.h" +#include "LUA.h" +#include "/EgtDev/Include/EXeExecutor.h" +#include "/EgtDev/Include/EXeConst.h" +#include "/EgtDev/Include/EGkLuaAux.h" + +using namespace std ; + +//---------------------------------------------------------------------------- +static int +LuaBoxLineInters( lua_State* L) +{ + // 3 parametri : b3Box, ptP, vtDir + BBox3d b3Box ; + LuaCheckParam( L, 1, b3Box) + Point3d ptP ; + LuaCheckParam( L, 2, ptP) + Vector3d vtDir ; + LuaCheckParam( L, 3, vtDir) + LuaClearStack( L) ; + // recupero i punti di intersezione tra linea e superficie trimesh + INTDBLVECTOR vInters ; + if ( ExeBoxLineInters( b3Box, ptP, vtDir, vInters)) { + LuaSetParam( L, true) ; + INTVECTOR vType( vInters.size()) ; + DBLVECTOR vPar( vInters.size()) ; + for ( size_t i = 0 ; i < vInters.size() ; ++ i) { + vType[i] = vInters[i].first ; + vPar[i] = vInters[i].second ; + } + LuaSetParam( L, vType) ; + LuaSetParam( L, vPar) ; + } + else { + LuaSetParam( L) ; + LuaSetParam( L) ; + LuaSetParam( L) ; + } + return 3 ; +} + +//---------------------------------------------------------------------------- +static int +LuaSurfTmLineInters( lua_State* L) +{ + // 3 o 4 parametri : Id, ptP, vtDir [, nRefId] + int nId ; + LuaCheckParam( L, 1, nId) + Point3d ptP ; + LuaCheckParam( L, 2, ptP) + Vector3d vtDir ; + LuaCheckParam( L, 3, vtDir) + int nRefType = nId ; + LuaGetParam( L, 4, nRefType) ; + LuaClearStack( L) ; + // recupero i punti di intersezione tra linea e superficie trimesh + INTDBLVECTOR vInters ; + if ( ExeSurfTmLineInters( nId, ptP, vtDir, nRefType, vInters)) { + LuaSetParam( L, true) ; + INTVECTOR vType( vInters.size()) ; + DBLVECTOR vPar( vInters.size()) ; + for ( size_t i = 0 ; i < vInters.size() ; ++ i) { + vType[i] = vInters[i].first ; + vPar[i] = vInters[i].second ; + } + LuaSetParam( L, vType) ; + LuaSetParam( L, vPar) ; + } + else { + LuaSetParam( L) ; + LuaSetParam( L) ; + LuaSetParam( L) ; + } + return 3 ; +} + +//---------------------------------------------------------------------------- +static int +LuaSurfTmPlaneInters( lua_State* L) +{ + // 4 o 5 parametri : Id, ptOn, vtN, nDestGrpId [, nRefType] + int nId ; + LuaCheckParam( L, 1, nId) + Point3d ptOn ; + LuaCheckParam( L, 2, ptOn) + Vector3d vtN ; + LuaCheckParam( L, 3, vtN) + int nDestGrpId ; + LuaGetParam( L, 4, nDestGrpId) ; + int nRefType = RTY_DEFAULT ; + LuaGetParam( L, 5, nRefType) ; + LuaClearStack( L) ; + // eseguo l'intersezione + int nPntCount = 0 ; + int nCrvCount = 0 ; + int nSrfCount = 0 ; + int nNewId = ExeSurfTmPlaneInters( nId, ptOn, vtN, nDestGrpId, nRefType, &nPntCount, &nCrvCount, &nSrfCount) ; + // restituisco il risultato + if ( nNewId != GDB_ID_NULL) + LuaSetParam( L, nNewId) ; + else + LuaSetParam( L) ; + LuaSetParam( L, nPntCount) ; + LuaSetParam( L, nCrvCount) ; + LuaSetParam( L, nSrfCount) ; + return 4 ; +} + +//---------------------------------------------------------------------------- +static int +LuaSurfTmSurfTmInters( lua_State* L) +{ + // 3 parametri : Id1, nId2, nDestGrpId + int nId1 ; + LuaCheckParam( L, 1, nId1) + int nId2 ; + LuaCheckParam( L, 2, nId2) + int nDestGrpId ; + LuaCheckParam( L, 3, nDestGrpId) ; + LuaClearStack( L) ; + // eseguo l'intersezione + int nPntCount = 0 ; + int nCrvCount = 0 ; + int nSrfCount = 0 ; + int nNewId = ExeSurfTmSurfTmInters( nId1, nId2, nDestGrpId, &nPntCount, &nCrvCount, &nSrfCount) ; + // restituisco il risultato + if ( nNewId != GDB_ID_NULL) + LuaSetParam( L, nNewId) ; + else + LuaSetParam( L) ; + LuaSetParam( L, nPntCount) ; + LuaSetParam( L, nCrvCount) ; + LuaSetParam( L, nSrfCount) ; + return 4 ; +} + +//---------------------------------------------------------------------------- +static int +LuaVolZmapPlaneInters( lua_State* L) +{ + // 4 o 5 parametri : nId, ptP, vtN, nDestGrpId [, nRefType] + int nId ; + LuaCheckParam( L, 1, nId) + Point3d ptP ; + LuaCheckParam( L, 2, ptP) + Vector3d vtN ; + LuaCheckParam( L, 3, vtN) + int nDestGrpId ; + LuaCheckParam( L, 4, nDestGrpId) + int nRefType = RTY_DEFAULT ; + LuaGetParam( L, 5, nRefType) ; + LuaClearStack( L) ; + // eseguo calcolo intersezione + int nCount ; + int nFirstId = ExeVolZmapPlaneInters( nId, ptP, vtN, nDestGrpId, nRefType, &nCount) ; + // restituisco il risultato + if ( nFirstId != GDB_ID_NULL) { + LuaSetParam( L, nFirstId) ; + LuaSetParam( L, nCount) ; + } + else { + LuaSetParam( L) ; + LuaSetParam( L) ; + } + return 2 ; +} + +//------------------------------------------------------------------------------- +bool +LuaInstallGeoInters( LuaMgr& luaMgr) +{ + bool bOk = ( &luaMgr != nullptr) ; + bOk = bOk && luaMgr.RegisterFunction( "EgtBoxLineInters", LuaBoxLineInters) ; + bOk = bOk && luaMgr.RegisterFunction( "EgtSurfTmLineInters", LuaSurfTmLineInters) ; + bOk = bOk && luaMgr.RegisterFunction( "EgtSurfTmPlaneInters", LuaSurfTmPlaneInters) ; + bOk = bOk && luaMgr.RegisterFunction( "EgtSurfTmSurfTmInters", LuaSurfTmSurfTmInters) ; + bOk = bOk && luaMgr.RegisterFunction( "EgtVolZmapPlaneInters", LuaVolZmapPlaneInters) ; + return bOk ; +} diff --git a/LUA_GeoSnap.cpp b/LUA_GeoSnap.cpp index 721a286..4e8a11d 100644 --- a/LUA_GeoSnap.cpp +++ b/LUA_GeoSnap.cpp @@ -19,7 +19,6 @@ using namespace std ; - //---------------------------------------------------------------------------- static int LuaStartPoint( lua_State* L) @@ -841,15 +840,20 @@ LuaSurfTmFacetOppositeSide( lua_State* L) LuaClearStack( L) ; // recupero i punti estremi della parte di faccia opposta alla direzione Point3d ptP1, ptP2 ; - if ( ExeSurfTmFacetOppositeSide( nId, nFacet, vtDir, nRefId, ptP1, ptP2)) { + Vector3d vtIn1, vtOut2 ; + if ( ExeSurfTmFacetOppositeSide( nId, nFacet, vtDir, nRefId, ptP1, ptP2, vtIn1, vtOut2)) { LuaSetParam( L, ptP1) ; LuaSetParam( L, ptP2) ; + LuaSetParam( L, vtIn1) ; + LuaSetParam( L, vtOut2) ; } else { LuaSetParam( L) ; LuaSetParam( L) ; + LuaSetParam( L) ; + LuaSetParam( L) ; } - return 2 ; + return 4 ; } //---------------------------------------------------------------------------- @@ -885,41 +889,6 @@ LuaSurfTmFacetsContact( lua_State* L) return 4 ; } -//---------------------------------------------------------------------------- -static int -LuaSurfTmLineInters( lua_State* L) -{ - // 3 o 4 parametri : Id, ptP, vtDir [, nRefId] - int nId ; - LuaCheckParam( L, 1, nId) - Point3d ptP ; - LuaCheckParam( L, 2, ptP) - Vector3d vtDir ; - LuaCheckParam( L, 3, vtDir) - int nRefType = nId ; - LuaGetParam( L, 4, nRefType) ; - LuaClearStack( L) ; - // recupero i punti di intersezione tra linea e superficie trimesh - INTDBLVECTOR vInters ; - if ( ExeSurfTmLineInters( nId, ptP, vtDir, nRefType, vInters)) { - LuaSetParam( L, true) ; - INTVECTOR vType( vInters.size()) ; - DBLVECTOR vPar( vInters.size()) ; - for ( size_t i = 0 ; i < vInters.size() ; ++ i) { - vType[i] = vInters[i].first ; - vPar[i] = vInters[i].second ; - } - LuaSetParam( L, vType) ; - LuaSetParam( L, vPar) ; - } - else { - LuaSetParam( L) ; - LuaSetParam( L) ; - LuaSetParam( L) ; - } - return 3 ; -} - //---------------------------------------------------------------------------- static int LuaVolZmapVolume( lua_State* L) @@ -1074,7 +1043,6 @@ LuaInstallGeoSnap( LuaMgr& luaMgr) bOk = bOk && luaMgr.RegisterFunction( "EgtSurfTmFacetNormVersor", LuaSurfTmFacetNormVersor) ; bOk = bOk && luaMgr.RegisterFunction( "EgtSurfTmFacetOppositeSide", LuaSurfTmFacetOppositeSide) ; bOk = bOk && luaMgr.RegisterFunction( "EgtSurfTmFacetsContact", LuaSurfTmFacetsContact) ; - bOk = bOk && luaMgr.RegisterFunction( "EgtSurfTmLineInters", LuaSurfTmLineInters) ; bOk = bOk && luaMgr.RegisterFunction( "EgtVolZmapVolume", LuaVolZmapVolume) ; bOk = bOk && luaMgr.RegisterFunction( "EgtVolZmapPartCount", LuaVolZmapPartCount) ; bOk = bOk && luaMgr.RegisterFunction( "EgtVolZmapPartVolume", LuaVolZmapPartVolume) ;