EgtExecutor 2.4e1 :
- aggiunte funzioni Exe e Lua ParPlanesSurfTmInters.
This commit is contained in:
+147
-43
@@ -371,36 +371,10 @@ ExeLineSurfTmInters( const Point3d& ptP, const Vector3d& vtDir, int nId, int nRe
|
||||
|
||||
//-------------------------------------------------------------------------------
|
||||
static int
|
||||
MyPlaneSurfTmInters( const Point3d& ptOn, const Vector3d& vtN, int nId, int nDestGrpId, int nRefType, double dToler,
|
||||
int& nPntCount, int& nCrvCount, int& nSrfCount)
|
||||
MyAddPlaneStmIntersResultToGeomDB( IGeomDB * pGeomDB, const PNTVECTOR& vPnt, const BIPNTVECTOR& vBpt, const TRIA3DVECTOR& vTria,
|
||||
const Frame3d& frOrig, const Frame3d& frDest, int nId, int nDestGrpId, const Vector3d& vtExtr,
|
||||
double dToler, int& nPntCount, int& nCrvCount, int& nSrfCount)
|
||||
{
|
||||
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 ;
|
||||
// Inserisco i punti nel DB
|
||||
@@ -412,13 +386,13 @@ MyPlaneSurfTmInters( const Point3d& ptOn, const Vector3d& vtN, int nId, int nDes
|
||||
// setto il punto
|
||||
pGeoPnt->Set( vPnt[i]) ;
|
||||
// porto il punto nel riferimento destinazione
|
||||
pGeoPnt->LocToLoc( frSurf, frDest) ;
|
||||
pGeoPnt->LocToLoc( frOrig, 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))
|
||||
if ( ! pGeomDB->CopyMaterial( nId, nNewId))
|
||||
return GDB_ID_NULL ;
|
||||
// aggiorno contatori
|
||||
if ( nFirstId == GDB_ID_NULL)
|
||||
@@ -455,8 +429,8 @@ MyPlaneSurfTmInters( const Point3d& ptOn, const Vector3d& vtN, int nId, int nDes
|
||||
Point3d ptEnd = vBpt[nInd].second ;
|
||||
// provo ad accodarlo alla composita
|
||||
bAdded = ( Dist( ptStart, ptEnd) > dToler / 2 &&
|
||||
pLine->Set( ptStart, ptEnd) &&
|
||||
pCrvCompo->AddCurve( Release( pLine), true, dToler)) ;
|
||||
pLine->Set( ptStart, ptEnd) &&
|
||||
pCrvCompo->AddCurve( Release( pLine), true, dToler)) ;
|
||||
ptNear = ( bAdded ? ptEnd : ptStart) ;
|
||||
}
|
||||
// se lunghezza curva inferiore a 5 volte la tolleranza, la ignoro
|
||||
@@ -466,24 +440,24 @@ MyPlaneSurfTmInters( const Point3d& ptOn, const Vector3d& vtN, int nId, int nDes
|
||||
// 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->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()) ;
|
||||
pCrvCompo->SetExtrusion( vtExtr) ;
|
||||
// unisco segmenti allineati
|
||||
pCrvCompo->MergeCurves( 0.5 * dToler, ANG_TOL_STD_DEG) ;
|
||||
// porto la curva nel riferimento destinazione
|
||||
pCrvCompo->LocToLoc( frSurf, frDest) ;
|
||||
pCrvCompo->LocToLoc( frOrig, 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))
|
||||
if ( ! pGeomDB->CopyMaterial( nId, nNewId))
|
||||
return GDB_ID_NULL ;
|
||||
// aggiorno contatori
|
||||
if ( nFirstId == GDB_ID_NULL)
|
||||
@@ -495,7 +469,7 @@ MyPlaneSurfTmInters( const Point3d& ptOn, const Vector3d& vtN, int nId, int nDes
|
||||
if ( ! StmFts.Start())
|
||||
return GDB_ID_NULL ;
|
||||
for ( int i = 0 ; i < int( vTria.size()) ; ++ i)
|
||||
// inserisco il triangolo nella nuova superficie
|
||||
// inserisco il triangolo nella nuova superficie
|
||||
StmFts.AddTriangle( vTria[i]) ;
|
||||
// valido la superficie e calcolo le adiacenze
|
||||
if ( ! StmFts.End())
|
||||
@@ -504,19 +478,57 @@ MyPlaneSurfTmInters( const Point3d& ptOn, const Vector3d& vtN, int nId, int nDes
|
||||
PtrOwner<ISurfTriMesh> pNewStm( StmFts.GetSurf()) ;
|
||||
if ( ! IsNull( pNewStm) && pNewStm->GetTriangleCount() > 0) {
|
||||
// porto la superficie nel riferimento destinazione
|
||||
pNewStm->LocToLoc( frSurf, frDest) ;
|
||||
pNewStm->LocToLoc( frOrig, 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))
|
||||
if ( ! pGeomDB->CopyMaterial( nId, nNewId))
|
||||
return GDB_ID_NULL ;
|
||||
// aggiorno contatori
|
||||
if ( nFirstId == GDB_ID_NULL)
|
||||
nFirstId = nNewId ;
|
||||
++ nSrfCount ;
|
||||
}
|
||||
|
||||
return nFirstId ;
|
||||
}
|
||||
//-------------------------------------------------------------------------------
|
||||
static int
|
||||
MyPlaneSurfTmInters( const Point3d& ptOn, const Vector3d& vtN, int nId, int nDestGrpId, int nRefType, double dToler,
|
||||
int& nPntCount, int& nCrvCount, int& nSrfCount)
|
||||
{
|
||||
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 dell'intersezione nel DB
|
||||
int nFirstId = MyAddPlaneStmIntersResultToGeomDB( pGeomDB, vPnt, vBpt, vTria, frSurf, frDest, nId, nDestGrpId, plPlane.GetVersN(), dToler,
|
||||
nPntCount, nCrvCount, nSrfCount) ;
|
||||
// restituisco l'identificativo della prima nuova entità
|
||||
return nFirstId ;
|
||||
}
|
||||
@@ -555,6 +567,98 @@ ExePlaneSurfTmInters( const Point3d& ptOn, const Vector3d& vtN, int nId, int nDe
|
||||
return nFirstId ;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------
|
||||
static int
|
||||
MyParPlanesSurfTmInters( const Vector3d& vtN, const PNTVECTOR& vPntPlanes, int nId, int nDestGrpId, int nRefType, double dToler, int& nGrpCount)
|
||||
{
|
||||
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 la normale del piano
|
||||
Vector3d vtNL = GetVectorLocal( pGeomDB, vtN, nRefType, frSurf) ;
|
||||
// costruisco il frame dei piani
|
||||
Frame3d frPlanes ;
|
||||
frPlanes.Set( ORIG, vtNL) ;
|
||||
|
||||
// intersezione fra superficie e piani paralleli
|
||||
IntersParPlanesSurfTm intPlStm( frPlanes, *pStm) ;
|
||||
|
||||
int nFirstGrpId = GDB_ID_NULL ;
|
||||
for ( size_t i = 0 ; i < vPntPlanes.size() ; i++) {
|
||||
|
||||
// creo il layer in cui salvare
|
||||
int nGrpId = pGeomDB->AddGroup( GDB_ID_NULL, nDestGrpId, GLOB_FRM) ;
|
||||
nGrpCount ++ ;
|
||||
if ( nFirstGrpId == GDB_ID_NULL)
|
||||
nFirstGrpId = nGrpId ;
|
||||
|
||||
// cerco l'intersezione con il piano
|
||||
Point3d ptOnL = GetPointLocal( pGeomDB, vPntPlanes[i], nRefType, frSurf) ;
|
||||
PNTVECTOR vPnt ;
|
||||
BIPNTVECTOR vBpt ;
|
||||
TRIA3DVECTOR vTria ;
|
||||
if ( ! intPlStm.GetInters( ptOnL, vPnt, vBpt, vTria)) {
|
||||
string sErr = "Error on ParPlanesStmInters at plane passing through " + ToString( vPntPlanes[i]) ;
|
||||
LOG_ERROR( GetLogger(), sErr.c_str()) ;
|
||||
continue ;
|
||||
}
|
||||
|
||||
// inserisco il risultato nel DB
|
||||
int nTmp{ 0} ;
|
||||
MyAddPlaneStmIntersResultToGeomDB( pGeomDB, vPnt, vBpt, vTria, frSurf, frDest, nId, nGrpId, vtN, dToler, nTmp, nTmp, nTmp) ;
|
||||
}
|
||||
|
||||
// restituisco l'identificativo del primo gruppo creato
|
||||
return nFirstGrpId ;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------
|
||||
int
|
||||
ExeParPlanesSurfTmInters( const Vector3d& vtN, const PNTVECTOR& vPnt, int nId, int nDestGrpId, int nRefType, double dToler,
|
||||
int* pnGrpCount)
|
||||
{
|
||||
// eseguo
|
||||
int nGrpCount{ 0} ;
|
||||
int nFirstId = MyParPlanesSurfTmInters( vtN, vPnt, nId, nDestGrpId, nRefType, dToler, nGrpCount) ;
|
||||
// aggiorno contatori
|
||||
if ( nFirstId != GDB_ID_NULL) {
|
||||
if ( pnGrpCount != nullptr)
|
||||
*pnGrpCount = nGrpCount ;
|
||||
ExeSetModified() ;
|
||||
}
|
||||
|
||||
// se richiesto, salvo il comando Lua equivalente
|
||||
if ( IsCmdLog()) {
|
||||
string sPC ;
|
||||
for ( size_t i = 0 ; i < vPnt.size() ; ++ i) {
|
||||
sPC += ( i == 0 ? "{" : ",{") + ToString( vPnt[i]) + "}" ;
|
||||
}
|
||||
string sLua = "EgtParPlanesSurfTmInters({" + ToString( vtN) + "},{" +
|
||||
sPC + "}," +
|
||||
ToString( nId) + "," +
|
||||
ToString( nDestGrpId) + "," +
|
||||
RefTypeToString( nRefType) + "," +
|
||||
ToString( dToler) + ")" +
|
||||
" -- Id=" + ToString( nFirstId) + ", GrpCnt=" + ToString( nGrpCount) ;
|
||||
LOG_INFO( GetCmdLogger(), sLua.c_str()) ;
|
||||
}
|
||||
|
||||
// restituisco l'identificativo della prima nuova entità
|
||||
return nFirstId ;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------
|
||||
static bool
|
||||
MyChainCurvesForSurfSurfInters( const BIPNTVECTOR& vBpt, IGeomDB* pGeomDB, int nDestGrpId, int nId1, double dToler,
|
||||
|
||||
Binary file not shown.
+33
-2
@@ -65,7 +65,7 @@ LuaPlaneBoxInters( lua_State* L)
|
||||
BBox3d b3Box ;
|
||||
LuaCheckParam( L, 3, b3Box)
|
||||
int nDestGrpId ;
|
||||
LuaGetParam( L, 4, nDestGrpId) ;
|
||||
LuaCheckParam( L, 4, nDestGrpId) ;
|
||||
int nRefType = RTY_DEFAULT ;
|
||||
LuaGetParam( L, 5, nRefType) ;
|
||||
LuaClearStack( L) ;
|
||||
@@ -132,7 +132,7 @@ LuaPlaneSurfTmInters( lua_State* L)
|
||||
int nId ;
|
||||
LuaCheckParam( L, 3, nId)
|
||||
int nDestGrpId ;
|
||||
LuaGetParam( L, 4, nDestGrpId) ;
|
||||
LuaCheckParam( L, 4, nDestGrpId) ;
|
||||
int nRefType = RTY_DEFAULT ;
|
||||
double dToler = 20 * EPS_SMALL ;
|
||||
if ( LuaGetParam( L, 5, nRefType))
|
||||
@@ -154,6 +154,36 @@ LuaPlaneSurfTmInters( lua_State* L)
|
||||
return 4 ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
static int
|
||||
LuaParPlanesSurfTmInters( lua_State* L)
|
||||
{
|
||||
// 4 o 5 o 6 parametri : vtN, vPnt, nId, nDestGrpId [, nRefType] [, dToler]
|
||||
Vector3d vtN ;
|
||||
LuaCheckParam( L, 1, vtN)
|
||||
PNTVECTOR vPnt ;
|
||||
LuaCheckParam( L, 2, vPnt)
|
||||
int nId ;
|
||||
LuaCheckParam( L, 3, nId)
|
||||
int nDestGrpId ;
|
||||
LuaCheckParam( L, 4, nDestGrpId) ;
|
||||
int nRefType = RTY_DEFAULT ;
|
||||
double dToler = 20 * EPS_SMALL ;
|
||||
if ( LuaGetParam( L, 5, nRefType))
|
||||
LuaGetParam( L, 6, dToler) ;
|
||||
LuaClearStack( L) ;
|
||||
// eseguo l'intersezione
|
||||
int nGrpCount = 0 ;
|
||||
int nNewId = ExeParPlanesSurfTmInters( vtN, vPnt, nId, nDestGrpId, nRefType, dToler, &nGrpCount) ;
|
||||
// restituisco il risultato
|
||||
if ( nNewId != GDB_ID_NULL)
|
||||
LuaSetParam( L, nNewId) ;
|
||||
else
|
||||
LuaSetParam( L) ;
|
||||
LuaSetParam( L, nGrpCount) ;
|
||||
return 2 ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
static int
|
||||
LuaSurfTmSurfTmInters( lua_State* L)
|
||||
@@ -259,6 +289,7 @@ LuaInstallGeoInters( LuaMgr& luaMgr)
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtPlaneBoxInters", LuaPlaneBoxInters) ;
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtLineSurfTmInters", LuaLineSurfTmInters) ;
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtPlaneSurfTmInters", LuaPlaneSurfTmInters) ;
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtParPlanesSurfTmInters", LuaParPlanesSurfTmInters) ;
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtSurfTmSurfTmInters", LuaSurfTmSurfTmInters) ;
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtLineVolZmapInters", LuaLineVolZmapInters) ;
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtPlaneVolZmapInters", LuaPlaneVolZmapInters) ;
|
||||
|
||||
Reference in New Issue
Block a user