EgtExecutor 3.1a2 :

- modifiche e migliorie alla funzioni di Trimming.
This commit is contained in:
Riccardo Elitropi
2026-01-20 17:30:32 +01:00
parent c306967cb2
commit 54a1a882de
3 changed files with 83 additions and 48 deletions
+71 -34
View File
@@ -50,7 +50,7 @@ ExeTrimmingAutoSearch( int nParentId, int nSurfLayerId, double dShapeLinTol, dou
CISURFPVECTOR vSurfs ; vSurfs.reserve( pGeomDB->GetGroupObjs( nSurfLayerId)) ;
int nId = pGeomDB->GetFirstInGroup( nSurfLayerId) ;
while ( nId != GDB_ID_NULL) {
// Recupero l'entità
// Recupero l'entità
const IGeoObj* pGeoObj = pGeomDB->GetGeoObj( nId) ;
if ( pGeoObj != nullptr) {
// Recupero il Tipo
@@ -75,11 +75,11 @@ ExeTrimmingAutoSearch( int nParentId, int nSurfLayerId, double dShapeLinTol, dou
bool bOk = GetTrimmingAutoEntities( vSurfs, dShapeLinTol, dShapeAngTol, dLinTol, dEdgeLinTol, dAngTol, dAngFaceTol, vsShapes,
matSelSurfMatrix, matCompoBorders, vSurfBz) ;
// Per sicurezza verifico che tutte le entità siano a dimensione corretta
// Per sicurezza verifico che tutte le entità siano a dimensione corretta
bOk = bOk && ( ssize( matSelSurfMatrix) == ssize( matCompoBorders)) &&
( ssize( matSelSurfMatrix) == ssize( vSurfBz)) ;
// Per ogni Entità ricavata inserisco le Geometrie nel Layer
// Per ogni Entità ricavata inserisco le Geometrie nel Layer
// NB. Ordine di Inserimento : Surf -> Edges -> bezier
// Una anomalia nella serie blocca il flusso corrente e passa al successivo
int nCount = -1 ;
@@ -141,9 +141,9 @@ ExeTrimmingAutoSearch( int nParentId, int nSurfLayerId, double dShapeLinTol, dou
}
// ---------------------------------------------------------------------------
bool
ExeTrimmingGetSurfTmFaceAdj( int nSurfId, const INTVECTOR& vTria, const PNTVECTOR& vPts,
double dAngTol, double dSize, double dSizeTol, INTVECTOR& vOtherFaces)
int
ExeTrimmingGetSurfTmFaceAdj( int nParentId, int nSurfId, const INTVECTOR& vTria, const PNTVECTOR& vPts,
double dAngTol, double dSize, double dSizeTol)
{
// Verifica database geometrico
IGeomDB* pGeomDB = GetCurrGeomDB() ;
@@ -156,28 +156,32 @@ ExeTrimmingGetSurfTmFaceAdj( int nSurfId, const INTVECTOR& vTria, const PNTVECTO
// Verifico che le facce appartengano alla superficie
bOk = bOk && ( ! vTria.empty()) ;
// Recupero l'insieme dei triangoli
// Recupero la superficie formata dai triangoli di adiacenza
int nNewSurfId = GDB_ID_NULL ;
if ( bOk) {
INTVECTOR vOtherTria ; vOtherTria.reserve( pStm->GetTriangleCount()) ;
bOk = GetTrimmingStmAdjTria( pStm, vTria, vPts, dAngTol, dSize, dSizeTol, vOtherTria) ;
// Per ogni triangolo ricavato, recupero la faccia corrispondente
set<int> setFaces ;
for ( const int& nT : vOtherTria)
setFaces.insert( pStm->GetFacetFromTria( nT)) ;
vOtherFaces.assign( setFaces.begin(), setFaces.end()) ;
PtrOwner<ISurfTriMesh> pStmAdjFace( CreateSurfTriMesh()) ;
bOk = ( ! IsNull( pStmAdjFace) && pStmAdjFace->AdjustTopology()) ;
bOk = GetTrimmingStmAdjTria( pStm, vTria, vPts, dAngTol, dSize, dSizeTol, pStmAdjFace) ;
bOk = ( ! IsNull( pStmAdjFace) && pStmAdjFace->IsValid() && pStmAdjFace->GetTriangleCount() > 0) ;
// Inserisco la Superficie nel DB geometrico
if ( bOk) {
nNewSurfId = pGeomDB->AddGeoObj( GDB_ID_NULL, nParentId, Release( pStmAdjFace)) ;
bOk = ( nNewSurfId != GDB_ID_NULL) ;
}
}
ExeSetModified() ;
// Se richiesto, salvo il comando Lua equivalente
if ( IsCmdLog()) {
string sLua = "EgtTrimmingGetSurfTmFromFaceAdj(" + ToString( nSurfId) + "," +
string sLua = "EgtTrimmingGetSurfTmFromFaceAdj(" + ToString( nParentId) + "," +
ToString( nSurfId) + "," +
ToString( vTria) + "," +
ToString( dAngTol) + ")" +
" -- bOk=" + ToString( bOk) + "vOtherFaces=" + ToString( vOtherFaces) ;
" nNewSurfId=" + ToString( nNewSurfId) ;
LOG_INFO( GetCmdLogger(), sLua.c_str()) ;
}
return bOk ;
return nNewSurfId ;
}
// ---------------------------------------------------------------------------
@@ -330,7 +334,7 @@ ExeTrimmingGetBorders( int nParentId, const SELVECTOR& vIds, double dLinTol, dou
uMapPos[*nIter] = nSurf ;
++ nSurf ;
}
// Recupero il vettore di Selezione associato non più agli Id delle superficie ma alle loro posizioni nel vettore
// Recupero il vettore di Selezione associato non più agli Id delle superficie ma alle loro posizioni nel vettore
SELVECTOR vFaces ; vFaces.reserve( vIds.size()) ;
for ( int i = 0 ; bOk && i < int( vIds.size()) ; ++ i)
vFaces.emplace_back( uMapPos[vIds[i].nId], vIds[i].nSub) ;
@@ -408,7 +412,7 @@ ExeTrimmingGetBordersByNormals( int nParentId, const SELVECTOR& vIds, double dLi
uMapPos[*nIter] = nSurf ;
++ nSurf ;
}
// Recupero il vettore di Selezione associato non più agli Id delle superficie ma alle loro posizioni nel vettore
// Recupero il vettore di Selezione associato non più agli Id delle superficie ma alle loro posizioni nel vettore
SELVECTOR vFaces ; vFaces.reserve( vIds.size()) ;
for ( int i = 0 ; bOk && i < int( vIds.size()) ; ++ i)
vFaces.emplace_back( uMapPos[vIds[i].nId], vIds[i].nSub) ;
@@ -430,9 +434,9 @@ ExeTrimmingGetBordersByNormals( int nParentId, const SELVECTOR& vIds, double dLi
nFirstId = nCurrId ;
}
}
// Se ho un punto di vicinanza, cerco la coppia di curve più vicina
// Se ho un punto di vicinanza, cerco la coppia di curve più vicina
else {
// Se solo una coppia di curve, le inserisco e non ho ambiguità
// Se solo una coppia di curve, le inserisco e non ho ambiguità
if ( int( vBezierEdges.size()) == 2) {
nCount = int( vBezierEdges.size()) ;
// Scorro gli Edges ottenuti
@@ -445,7 +449,7 @@ ExeTrimmingGetBordersByNormals( int nParentId, const SELVECTOR& vIds, double dLi
nFirstId = nCurrId ;
}
}
// altrimenti cerco la coppia più vicia
// altrimenti cerco la coppia più vicia
else {
double dSqMinDist = INFINITO ;
int nInd = 0 ;
@@ -605,34 +609,58 @@ ExeTrimmingGetRuledBezier( int nParentId, const INTVECTOR& vIds, int nEdge1Id, i
// Recupero i punti di sincronizzazione ( se presenti)
BIPNTVECTOR vSyncPoints ; vSyncPoints.reserve( pGeomDB->GetGroupObjs( vnLineId.size())) ;
INTVECTOR vIndPriority ; vIndPriority.reserve( vSyncPoints.size()) ;
INTVECTOR vIndVisible ; vIndVisible.reserve( vSyncPoints.size()) ;
for ( int i = 0 ; bOk && i < int( vnLineId.size()) ; ++ i) {
INTVECTOR vnShown ; vnShown.reserve( vSyncPoints.size()) ;
INTVECTOR vnEdited ; vnEdited.reserve( vSyncPoints.size()) ;
INTVECTOR vnNew ; vnNew.reserve( vSyncPoints.size()) ;
for ( int i = 0 ; bOk && i < ssize( vnLineId) ; ++ i) {
// Recupero la Curva
const ICurve* pLine = GetCurve( pGeomDB->GetGeoObj( vnLineId[i])) ;
bOk = bOk && ( pLine != nullptr && pLine->IsValid()) ;
if ( bOk) {
// Recupero gli Estremi
Point3d ptStart ; pLine->GetStartPoint( ptStart) ;
Point3d ptEnd ; pLine->GetEndPoint( ptEnd) ;
// Mi assicuro che gli estremi siano sulle curve di Bordo e orientati correttamente ( nel caso inverto)
double dSqDistS1 = INFINITO ;
if ( ! DistPointCurve( ptStart, *pCrvEdge1).GetSqDist( dSqDistS1))
continue ;
if ( dSqDistS1 < dLinTol * dLinTol) {
double dSqDistE2 = INFINITO ;
if ( ! DistPointCurve( ptEnd, *pCrvEdge2).GetSqDist( dSqDistE2) ||
dSqDistE2 > dLinTol * dLinTol)
continue ;
}
else {
double dSqDistS2 = INFINITO ;
if ( ! DistPointCurve( ptStart, *pCrvEdge2).GetSqDist( dSqDistS2) ||
dSqDistS2 > dLinTol * dLinTol)
continue ;
double dSqDistE1 = INFINITO ;
if ( ! DistPointCurve( ptEnd, *pCrvEdge1).GetSqDist( dSqDistE1) ||
dSqDistE1 > dLinTol * dLinTol)
continue ;
swap( ptStart, ptEnd) ;
}
vSyncPoints.emplace_back( make_pair( ptStart, ptEnd)) ;
// Verifico se la linea è visibile all'utente
// Verifico se la linea è visibile all'utente
int nStatus = GDB_ST_OFF ;
if ( pGeomDB->GetStatus( vnLineId[i], nStatus) && nStatus == GDB_ST_ON)
vIndVisible.emplace_back( int( vSyncPoints.size() - 1)) ;
// Verifico mediante le Info se la curva è stata modificata o aggiunta ( quindi prioritaria)
vnShown.emplace_back( ssize( vSyncPoints) - 1) ;
// Verifico mediante le Info se la curva è stata modificata o aggiunta
DBLVECTOR vdOldCoor ; vdOldCoor.reserve( 6) ;
if ( ! pGeomDB->GetInfo( vnLineId[i], s_sKey_Sync_Coord, vdOldCoor) ||
int( vdOldCoor.size()) != 6 ||
! AreSamePointApprox( ptStart, Point3d( vdOldCoor[0], vdOldCoor[1], vdOldCoor[2])) ||
! AreSamePointApprox( ptEnd, Point3d( vdOldCoor[3], vdOldCoor[4], vdOldCoor[5])))
vIndPriority.emplace_back( int( vSyncPoints.size()) - 1) ;
int( vdOldCoor.size()) != 6)
vnNew.emplace_back( ssize( vSyncPoints) - 1) ;
else if ( ! AreSamePointApprox( ptStart, Point3d( vdOldCoor[0], vdOldCoor[1], vdOldCoor[2])) ||
! AreSamePointApprox( ptEnd, Point3d( vdOldCoor[3], vdOldCoor[4], vdOldCoor[5])))
vnEdited.emplace_back( ssize( vSyncPoints) - 1) ;
}
}
// Recupero la superficie Bezier rigata
PtrOwner<ISurfBezier> pSurfBzRuled ;
if ( bOk) {
pSurfBzRuled.Set( GetTrimmingRuledBezier( vpSurf, pCrvEdge1, pCrvEdge2, dMyLinTol, vSyncPoints, vIndPriority, vIndVisible)) ;
pSurfBzRuled.Set( GetTrimmingRuledBezier( vpSurf, pCrvEdge1, pCrvEdge2, dMyLinTol, vSyncPoints, vnShown, vnEdited, vnNew)) ;
bOk = bOk && ( ! IsNull( pSurfBzRuled) && pSurfBzRuled->IsValid()) ;
}
@@ -794,7 +822,16 @@ ExeTrimmingSkimSyncPoints( int nEdge1Id, int nEdge2Id, const INTVECTOR& vnLineId
}
// Se richiesto, salvo il comando Lua equivalente
// ?????????????
if ( IsCmdLog()) {
string sLua = "EgtTrimmingGetSurfBzSyncPoints(" + ToString( nEdge1Id) + "," +
ToString( nEdge2Id) + "," +
ToString( vnLineId) + "," +
ToString( dLinTol) + "," +
ToString( dAngTol) + "," +
ToString( nMaxInvLine) + ")" +
" -- bOk=" + ToString( bOk) ;
LOG_INFO( GetCmdLogger(), sLua.c_str()) ;
}
return bOk ;
}
BIN
View File
Binary file not shown.
+12 -14
View File
@@ -55,29 +55,27 @@ LuaTrimmingAutoSearch( lua_State* L)
static int
LuaTrimmingGetSurfTmFaceAdj( lua_State* L)
{
// 6 parametri : nSurfId, vTria, vPts, dAngTol, dSize, dSizeTol
// 7 parametri : nParentId, nSurfId, vTria, vPts, dAngTol, dSize, dSizeTol
int nParentId ;
LuaCheckParam( L, 1, nParentId) ;
int nSurfId ;
LuaCheckParam( L, 1, nSurfId)
LuaCheckParam( L, 2, nSurfId)
INTVECTOR vTria ;
LuaCheckParam( L, 2, vTria)
LuaCheckParam( L, 3, vTria)
PNTVECTOR vPts ;
LuaCheckParam( L, 3, vPts)
LuaCheckParam( L, 4, vPts)
double dAngTol ;
LuaCheckParam( L, 4, dAngTol)
LuaCheckParam( L, 5, dAngTol)
double dSize ;
LuaCheckParam( L, 5, dSize)
LuaCheckParam( L, 6, dSize)
double dSizeTol ;
LuaCheckParam( L, 6, dSizeTol)
LuaCheckParam( L, 7, dSizeTol)
LuaClearStack( L) ;
// Recupero le facce adiacenti in tolleranza angolare
INTVECTOR vOtherFaces ;
bool bOk = ExeTrimmingGetSurfTmFaceAdj( nSurfId, vTria, vPts, dAngTol, dSize, dSizeTol, vOtherFaces) ;
LuaSetParam( L, bOk) ;
if ( bOk)
LuaSetParam( L, vOtherFaces) ;
else
LuaSetParam( L) ;
return 2 ;
int nNewSurfId = ExeTrimmingGetSurfTmFaceAdj( nParentId, nSurfId, vTria, vPts, dAngTol, dSize, dSizeTol) ;
LuaSetParam( L, nNewSurfId) ;
return 1 ;
}
// ------------------------------------------------------------------------------