EgtExecutor :
- in ExeCAvToolPathStm disabilitando la tolleranza si disabilita anche il controllo massima lunghezza segmento - eliminata funzione Exe/Lua GetSurfTmSilhouetteEx sostituita con GetSurfTmParSilhouettes.
This commit is contained in:
+7
-5
@@ -185,11 +185,13 @@ ExeCAvToolPathStm( int nCrvId, const Vector3d& vtAx, int nSurfTmId, const Vector
|
||||
if ( ! pCrv->ApproxWithLines( dLinTol, ANG_TOL_STD_DEG, ICurve::APL_SPECIAL, PL))
|
||||
return false ;
|
||||
// eventuale aggiunta di punti per garantire max distanza
|
||||
const double MIN_DIST = 1. ;
|
||||
const double MAX_DIST = 50. ;
|
||||
double dDist = Clamp( s_pCAvTlStm->GetToolRadius(), MIN_DIST, MAX_DIST) ;
|
||||
if ( ! PL.AdjustForMaxSegmentLen( dDist))
|
||||
return false ;
|
||||
if ( dLinTol > 0) {
|
||||
const double MIN_DIST = 1. ;
|
||||
const double MAX_DIST = 50. ;
|
||||
double dDist = Clamp( s_pCAvTlStm->GetToolRadius(), MIN_DIST, MAX_DIST) ;
|
||||
if ( ! PL.AdjustForMaxSegmentLen( dDist))
|
||||
return false ;
|
||||
}
|
||||
// porto nel riferimento della superficie
|
||||
PL.LocToLoc( frCrv, frSurf) ;
|
||||
// porto i dati geometrici in locale alla superficie
|
||||
|
||||
+76
-41
@@ -33,6 +33,7 @@
|
||||
#include "/EgtDev/Include/EGkIntersCurves.h"
|
||||
#include "/EgtDev/Include/EGkIntersLineBox.h"
|
||||
#include "/EgtDev/Include/EGkIntersLineSurfTm.h"
|
||||
#include "/EgtDev/Include/EGkCAvSilhouetteSurfTm.h"
|
||||
#include "/EgtDev/Include/EGkCalcPocketing.h"
|
||||
#include "/EgtDev/Include/EGkPolygonElevation.h"
|
||||
#include "/EgtDev/Include/EGkSurfLocal.h"
|
||||
@@ -914,60 +915,94 @@ ExeGetSurfTmSilhouette( int nId, const Vector3d& vtDir, double dToler, int nDest
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
int
|
||||
ExeGetSurfTmSilhouetteEx( int nId, const Point3d& ptOn, const Vector3d& vtN, double dToler, int nDestGrpId, int nRefType,
|
||||
int* pnCount, bool bAllTria)
|
||||
static int
|
||||
MyGetSurfTmParSilhouettes( const INTVECTOR& vIds, const Point3d& ptOn, const Vector3d& vtN, const DBLVECTOR& vdDist,
|
||||
double dToler, int nDestGrpId, int nRefType, int& nCount)
|
||||
{
|
||||
IGeomDB* pGeomDB = GetCurrGeomDB() ;
|
||||
VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL)
|
||||
// recupero la superficie TriMesh
|
||||
const ISurfTriMesh* pStm = GetSurfTriMesh( pGeomDB->GetGeoObj( nId)) ;
|
||||
bool bOk = ( pStm != nullptr) ;
|
||||
// recupero il riferimento della superficie
|
||||
// inizializzo contatore a valore negativo (errore)
|
||||
nCount = -1 ;
|
||||
// se non ci sono superfici o quote di calcolo, non c'è niente da calcolare
|
||||
if ( vIds.empty() || vdDist.empty())
|
||||
return GDB_ID_NULL ;
|
||||
// recupero il riferimento della prima superficie
|
||||
Frame3d frSurf ;
|
||||
bOk = bOk && pGeomDB->GetGlobFrame( nId, frSurf) ;
|
||||
if ( ! pGeomDB->GetGlobFrame( vIds[0], frSurf))
|
||||
return GDB_ID_NULL ;
|
||||
// recupero il riferimento di destinazione
|
||||
Frame3d frDest ;
|
||||
bOk = bOk && pGeomDB->GetGroupGlobFrame( nDestGrpId, frDest) ;
|
||||
// porto in locale alla superficie il punto e la normale del piano
|
||||
if ( ! pGeomDB->GetGroupGlobFrame( nDestGrpId, frDest))
|
||||
return false ;
|
||||
// recupero le superfici TriMesh e le porto tutte in locale alla prima
|
||||
SURFLOCALVECTOR vSurfL ; vSurfL.reserve( vIds.size()) ;
|
||||
CISURFTMPVECTOR vpStm ; vpStm.reserve( vIds.size()) ;
|
||||
for ( int i = 0 ; i < int( vIds.size()) ; ++ i) {
|
||||
vSurfL.emplace_back( pGeomDB, vIds[i], frSurf) ;
|
||||
if ( vSurfL[i].Get() == nullptr)
|
||||
return GDB_ID_NULL ;
|
||||
vpStm.emplace_back( GetSurfTriMesh( vSurfL[i].Get())) ;
|
||||
}
|
||||
// porto in locale alla superficie il punto e la normale e ne calcolo un riferimento
|
||||
Point3d ptOnL = GetPointLocal( pGeomDB, ptOn, nRefType, frSurf) ;
|
||||
Vector3d vtNL = GetVectorLocal( pGeomDB, vtN, nRefType, frSurf) ;
|
||||
// calcolo il piano
|
||||
Plane3d plPlane ;
|
||||
bOk = bOk && plPlane.Set( ptOnL, vtNL) ;
|
||||
// recupero i loop come polilinee
|
||||
POLYLINEVECTOR vPL ;
|
||||
bOk = bOk && pStm->GetSilhouette( plPlane, dToler, vPL, bAllTria) ;
|
||||
// dalle polilinee creo le curve e le inserisco nel DB
|
||||
Frame3d frPlanes ;
|
||||
if ( ! frPlanes.Set( ptOnL, vtNL))
|
||||
return GDB_ID_NULL ;
|
||||
// recupero i contorni delle varie silhouette
|
||||
int nFirstId = GDB_ID_NULL ;
|
||||
int nCount = 0 ;
|
||||
for ( size_t i = 0 ; i < vPL.size() ; ++ i) {
|
||||
// creo la curva
|
||||
PtrOwner<ICurveComposite> pCrvCompo( CreateCurveComposite()) ;
|
||||
bOk = bOk && pCrvCompo->FromPolyLine( vPL[i]) ;
|
||||
// la porto nel riferimento destinazione
|
||||
bOk = bOk && pCrvCompo->LocToLoc( frSurf, frDest) ;
|
||||
// la inserisco nel DB geometrico
|
||||
int nNewId = ( bOk ? pGeomDB->AddGeoObj( GDB_ID_NULL, nDestGrpId, Release( pCrvCompo)) : GDB_ID_NULL) ;
|
||||
bOk = bOk && ( nNewId != GDB_ID_NULL) ;
|
||||
// copio il materiale
|
||||
if ( ! pGeomDB->CopyMaterial( nId, nNewId))
|
||||
int nTempCount = 0 ;
|
||||
CAvParSilhouettesSurfTm cavParSilh( vpStm, frPlanes, dToler) ;
|
||||
for ( auto dDist : vdDist) {
|
||||
// recupero i loop come polilinee
|
||||
POLYLINEVECTOR vPL ;
|
||||
if ( ! cavParSilh.GetSilhouette( dDist, vPL))
|
||||
return GDB_ID_NULL ;
|
||||
// aggiorno contatori
|
||||
if ( bOk && nFirstId == GDB_ID_NULL)
|
||||
nFirstId = nNewId ;
|
||||
if ( bOk)
|
||||
++ nCount ;
|
||||
// dalle polilinee creo le curve e le inserisco nel DB
|
||||
for ( int i = 0 ; i < int( vPL.size()) ; ++ i) {
|
||||
// creo la curva
|
||||
PtrOwner<ICurveComposite> pCrvCompo( CreateCurveComposite()) ;
|
||||
if ( ! pCrvCompo->FromPolyLine( vPL[i]))
|
||||
return GDB_ID_NULL ;
|
||||
// la porto 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( vIds[0], nNewId))
|
||||
return GDB_ID_NULL ;
|
||||
// aggiorno contatori
|
||||
if ( nFirstId == GDB_ID_NULL)
|
||||
nFirstId = nNewId ;
|
||||
++ nTempCount ;
|
||||
}
|
||||
}
|
||||
ExeSetModified() ;
|
||||
nCount = nTempCount ;
|
||||
return nFirstId ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
int
|
||||
ExeGetSurfTmParSilhouettes( const INTVECTOR& vIds, const Point3d& ptOn, const Vector3d& vtN, const DBLVECTOR& vdDist,
|
||||
double dToler, int nDestGrpId, int nRefType, int* pnCount)
|
||||
{
|
||||
// eseguo
|
||||
int nCount = -1 ;
|
||||
int nFirstId = MyGetSurfTmParSilhouettes( vIds, ptOn, vtN, vdDist, dToler, nDestGrpId, nRefType, nCount) ;
|
||||
// aggiorno contatori
|
||||
if ( nFirstId != GDB_ID_NULL)
|
||||
ExeSetModified() ;
|
||||
// se richiesto, salvo il comando Lua equivalente
|
||||
if ( IsCmdLog()) {
|
||||
string sLua = "EgtGetSurfTmSilhouetteEx(" + ToString( nId) + ",{" +
|
||||
ToString( ptOn) + "},{" +
|
||||
ToString( vtN) + "}," +
|
||||
ToString( nDestGrpId) + "," +
|
||||
RefTypeToString( nRefType) + "," +
|
||||
ToString( bAllTria) + ")" +
|
||||
string sLua = "EgtGetSurfTmParSilhouettes({" + ToString( vIds) + "},{" +
|
||||
ToString( ptOn) + "},{" +
|
||||
ToString( vtN) + "},{" +
|
||||
ToString( vdDist) + "}," +
|
||||
ToString( dToler) + "," +
|
||||
ToString( nDestGrpId) + "," +
|
||||
RefTypeToString( nRefType) + ")" +
|
||||
" -- Id1=" + ToString( nFirstId) + ",Nbr=" + ToString( nCount) ;
|
||||
LOG_INFO( GetCmdLogger(), sLua.c_str()) ;
|
||||
}
|
||||
|
||||
+12
-14
@@ -810,31 +810,29 @@ LuaGetSurfTmSilhouette( lua_State* L)
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
static int
|
||||
LuaGetSurfTmSilhouetteEx( lua_State* L)
|
||||
LuaGetSurfTmParSilhouettes( lua_State* L)
|
||||
{
|
||||
// 5 o 6 o 7 parametri : nId, , ptOn, vtN, dToler, nDestGrpId [, nRefType [, bAllTria]]
|
||||
int nId ;
|
||||
LuaCheckParam( L, 1, nId)
|
||||
// 6 o 7 parametri : vIds, ptOn, vtN, vdDist, dToler, nDestGrpId [, nRefType]
|
||||
INTVECTOR vIds ;
|
||||
LuaCheckParam( L, 1, vIds)
|
||||
Point3d ptOn ;
|
||||
LuaCheckParam( L, 2, ptOn)
|
||||
Vector3d vtN ;
|
||||
LuaCheckParam( L, 3, vtN)
|
||||
DBLVECTOR vdDist ;
|
||||
LuaCheckParam( L, 4, vdDist)
|
||||
double dToler ;
|
||||
LuaCheckParam( L, 4, dToler)
|
||||
LuaCheckParam( L, 5, dToler)
|
||||
int nDestGrpId ;
|
||||
LuaCheckParam( L, 5, nDestGrpId)
|
||||
LuaCheckParam( L, 6, nDestGrpId)
|
||||
int nRefType = RTY_DEFAULT ;
|
||||
bool bAllTria = false ;
|
||||
if ( LuaGetParam( L, 6, nRefType))
|
||||
LuaGetParam( L, 7, bAllTria) ;
|
||||
else
|
||||
LuaGetParam( L, 6, bAllTria) ;
|
||||
LuaGetParam( L, 7, nRefType) ;
|
||||
LuaClearStack( L) ;
|
||||
// recupero i contorni della superficie
|
||||
int nCount = 0 ;
|
||||
int nNewId = ExeGetSurfTmSilhouetteEx( nId, ptOn, vtN, dToler, nDestGrpId, nRefType, &nCount, bAllTria) ;
|
||||
int nNewId = ExeGetSurfTmParSilhouettes( vIds, ptOn, vtN, vdDist, dToler, nDestGrpId, nRefType, &nCount) ;
|
||||
// restituisco il risultato
|
||||
if ( nNewId != GDB_ID_NULL)
|
||||
if ( nCount >= 0)
|
||||
LuaSetParam( L, nNewId) ;
|
||||
else
|
||||
LuaSetParam( L) ;
|
||||
@@ -1189,7 +1187,7 @@ LuaInstallGdbGetSurf( LuaMgr& luaMgr)
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtSurfTmFacetsContact", LuaSurfTmFacetsContact) ;
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtExtractSurfTmLoops", LuaExtractSurfTmLoops) ;
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtGetSurfTmSilhouette", LuaGetSurfTmSilhouette) ;
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtGetSurfTmSilhouetteEx", LuaGetSurfTmSilhouetteEx) ;
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtGetSurfTmParSilhouettes", LuaGetSurfTmParSilhouettes) ;
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtExtractSurfTmFacetLoops", LuaExtractSurfTmFacetLoops) ;
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtCopySurfTmFacet", LuaCopySurfTmFacet) ;
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtSurfTmGetEdges", LuaSurfTmGetEdges) ;
|
||||
|
||||
Reference in New Issue
Block a user