Compare commits
116 Commits
Zmap
...
MoreBezier
| Author | SHA1 | Date | |
|---|---|---|---|
| e9404b11cf | |||
| 0a645512f2 | |||
| 32565dbc3a | |||
| f7a8981491 | |||
| 1b8b5266f2 | |||
| 9a6482d4cf | |||
| da68acdc6d | |||
| 64b7e47d1c | |||
| 4a2c0904fe | |||
| a5d9ede6ee | |||
| 829961033e | |||
| 1aec3526bf | |||
| 9a62d76115 | |||
| c602a4f2ac | |||
| 9a2a906c96 | |||
| a3f32536d0 | |||
| b87d9ce4dd | |||
| e1b2f0caaf | |||
| 8290f47a80 | |||
| e3213299aa | |||
| 6214ff5926 | |||
| ea83cb985d | |||
| 7e9005a009 | |||
| bcefcc65fd | |||
| 7672783be9 | |||
| bbc7a31157 | |||
| 3faae6b3df | |||
| e463ba5500 | |||
| 5e8004ac4b | |||
| 6f118b80bf | |||
| a3bcc57f31 | |||
| e8b664002e | |||
| 1cc3d4bdbb | |||
| 9135fe039f | |||
| cd6258031f | |||
| b46d3449de | |||
| d6cd16b860 | |||
| 2fc0e4994d | |||
| 9bc89dfc35 | |||
| ddbc2a81e6 | |||
| 560d7af700 | |||
| ee585114fd | |||
| 94814adf67 | |||
| 387c10b72c | |||
| fd5566fceb | |||
| 450097fdca | |||
| 7f4b18567b | |||
| f735b1ea46 | |||
| 5d7206528b | |||
| 9a61f93e7e | |||
| 5420a212aa | |||
| c1dd1cfb53 | |||
| 6d619351e4 | |||
| 9023508027 | |||
| b327853564 | |||
| f7922678ec | |||
| 9bc1f2d55c | |||
| 3de9f5c1c3 | |||
| 40d784806b | |||
| 3d6a6071a9 | |||
| 7d04a27151 | |||
| e138020432 | |||
| 99675027ac | |||
| 517249b59d | |||
| 0d9e35580e | |||
| b3aa7518f8 | |||
| 7a522541da | |||
| b84940378c | |||
| f680c20b18 | |||
| f95caff7d8 | |||
| 8304298122 | |||
| 7b7ca66c6a | |||
| 4be2039c00 | |||
| 717107cc2d | |||
| 00dcccfe24 | |||
| 217ce9b589 | |||
| 8fba665c27 | |||
| dcae61ef24 | |||
| 37c6e26a43 | |||
| 7aeabafeb7 | |||
| 16b7208962 | |||
| 7c6c48b8b8 | |||
| 2f3d1a84ef | |||
| 2eeb25584c | |||
| c65a29fc2b | |||
| fb4b13c258 | |||
| f10cbcca39 | |||
| 41929b4a8b | |||
| d08de0dce8 | |||
| 13e9eea977 | |||
| 2221934f3c | |||
| 0424900a2b | |||
| e4f45df79a | |||
| 868efb69f1 | |||
| 7b991f4526 | |||
| 3d59a7ec24 | |||
| 9219fe9792 | |||
| bf069c7f7a | |||
| f949e39d47 | |||
| 88904db10f | |||
| 429b8d828c | |||
| 1bf59acd00 | |||
| a5a85a6723 | |||
| c523c46670 | |||
| fb0b4f9621 | |||
| 7070032120 | |||
| 0b1461984c | |||
| 4f7f5d97b2 | |||
| 8cd72b2a4c | |||
| 7b3c24c2be | |||
| e5f296e712 | |||
| 9e1f151bbc | |||
| ed6c8fb11d | |||
| 9ef30272b4 | |||
| 22774303af | |||
| a3c905c33a |
@@ -1,7 +1,7 @@
|
||||
//----------------------------------------------------------------------------
|
||||
// EgalTech 2014-2023
|
||||
// EgalTech 2014-2024
|
||||
//----------------------------------------------------------------------------
|
||||
// File : EXE.h Data : 05.02.23 Versione : 2.5a6
|
||||
// File : EXE.h Data : 15.05.24 Versione : 2.6e4
|
||||
// Contenuto : Dichiarazioni locali per moduli EXE.
|
||||
//
|
||||
//
|
||||
@@ -26,6 +26,7 @@ const std::string& ExeGetIniFile( void) ;
|
||||
const std::string& ExeGetKey( void) ;
|
||||
const std::string& ExeGetNestKey( void) ;
|
||||
const std::string& ExeGetLockId( void) ;
|
||||
bool ExeVerifyKeyOption( int nOptInd) ;
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
ILogger* GetLogger( void) ;
|
||||
|
||||
+14
-6
@@ -175,16 +175,23 @@ ExeCAvToolPathStm( int nCrvId, const Vector3d& vtAx, int nSurfTmId, const Vector
|
||||
// verifico oggetto per evitare collisioni
|
||||
if ( IsNull( s_pCAvTlStm))
|
||||
return false ;
|
||||
// Controllo la tolleranza lineare (se negativa non vanno fatti controlli sui punti medi)
|
||||
if ( dLinTol > -EPS_ZERO)
|
||||
dLinTol = max( dLinTol, EPS_SMALL) ;
|
||||
else
|
||||
dLinTol = -1 ;
|
||||
// approssimo la curva con una polilinea
|
||||
PolyLine PL ;
|
||||
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
|
||||
@@ -198,7 +205,8 @@ ExeCAvToolPathStm( int nCrvId, const Vector3d& vtAx, int nSurfTmId, const Vector
|
||||
// riporto la polilinea nel riferimento della curva
|
||||
PL.LocToLoc( frSurf, frCrv) ;
|
||||
// elimino i punti allineati
|
||||
PL.RemoveAlignedPoints( 0.8 * dLinTol) ;
|
||||
if ( dLinTol > 0)
|
||||
PL.RemoveAlignedPoints( 0.8 * dLinTol) ;
|
||||
// creo una curva composita a partire dalla polilinea
|
||||
PtrOwner< ICurveComposite> pCompo( CreateCurveComposite()) ;
|
||||
if ( IsNull( pCompo) || ! pCompo->FromPolyLine( PL))
|
||||
|
||||
+109
-1
@@ -40,11 +40,12 @@
|
||||
#include "/EgtDev/Include/EGkChainCurves.h"
|
||||
#include "/EgtDev/Include/EGkCurveByInterp.h"
|
||||
#include "/EgtDev/Include/EGkCurveByApprox.h"
|
||||
#include "/EgtDev/Include/EGkCurveAux.h"
|
||||
#include "/EgtDev/Include/EGkOffsetCurve.h"
|
||||
#include "/EgtDev/Include/EGkCurveLocal.h"
|
||||
#include "/EgtDev/Include/EGkSurfTriMesh.h"
|
||||
#include "/EgtDev/Include/EGkDistPointCurve.h"
|
||||
#include "/EgtDev/Include/EGkStringUtils3d.h"
|
||||
#include "/EgtDev/Include/EGkCurveLocal.h"
|
||||
#include "/EgtDev/Include/EgtPointerOwner.h"
|
||||
|
||||
using namespace std ;
|
||||
@@ -1088,6 +1089,45 @@ ExeCreateArc3P( int nParentId, const Point3d& ptP1,
|
||||
return nId ;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------
|
||||
int
|
||||
ExeCreateArc2PR( int nParentId, const Point3d& ptStart, const Point3d& ptEnd,
|
||||
double dRad, bool bCCW, int nRefType)
|
||||
{
|
||||
IGeomDB* pGeomDB = GetCurrGeomDB() ;
|
||||
VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL)
|
||||
nParentId = AdjustId( nParentId) ;
|
||||
// recupero il riferimento locale
|
||||
Frame3d frLoc ;
|
||||
bool bOk = pGeomDB->GetGroupGlobFrame( nParentId, frLoc) ;
|
||||
// porto in locale i punti, il versore normale e quelloe estrusione
|
||||
Point3d ptStartL = GetPointLocal( pGeomDB, ptStart, nRefType, frLoc) ;
|
||||
Point3d ptEndL = GetPointLocal( pGeomDB, ptEnd, nRefType, frLoc) ;
|
||||
Vector3d vtNormL = GetVectorLocal( pGeomDB, Z_AX, nRefType, frLoc) ;
|
||||
Vector3d vtExtrL = GetVectorLocal( pGeomDB, Z_AX, nRefType, frLoc) ;
|
||||
// creo l'arco
|
||||
PtrOwner<ICurveArc> pCrvArc( CreateCurveArc()) ;
|
||||
bOk = bOk && ( ! IsNull( pCrvArc) &&
|
||||
pCrvArc->Set2PNRS( ptStartL, ptEndL, vtNormL, dRad, bCCW)) ;
|
||||
// assegno il versore estrusione
|
||||
bOk = bOk && pCrvArc->SetExtrusion( vtExtrL) ;
|
||||
// inserisco l'arco nel DB
|
||||
int nId = ( bOk ? pGeomDB->AddGeoObj( GDB_ID_NULL, nParentId, Release( pCrvArc)) : GDB_ID_NULL) ;
|
||||
ExeSetModified() ;
|
||||
// se richiesto, salvo il comando Lua equivalente
|
||||
if ( IsCmdLog()) {
|
||||
string sLua = "EgtArc2PR(" + IdToString( nParentId) + ",{" +
|
||||
ToString( ptStart) + "},{" +
|
||||
ToString( ptEnd) + "}," +
|
||||
ToString( dRad) + "," +
|
||||
RefTypeToString( nRefType) + ")" +
|
||||
" -- Id=" + ToString( nId) ;
|
||||
LOG_INFO( GetCmdLogger(), sLua.c_str()) ;
|
||||
}
|
||||
// restituisco l'identificativo della nuova entità
|
||||
return nId ;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------
|
||||
int
|
||||
ExeCreateArc2PB( int nParentId, const Point3d& ptStart, const Point3d& ptEnd,
|
||||
@@ -2545,3 +2585,71 @@ CalcExtrusion( IGeomDB* pGeomDB, int nParentId, int nRefType)
|
||||
vtExtr.LocToLoc( pGeomDB->GetGridFrame(), frEnt) ;
|
||||
return vtExtr ;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------
|
||||
static int
|
||||
MyCreateCurveBezierForm( int nParentId, int nCrvId)
|
||||
{
|
||||
IGeomDB* pGeomDB = GetCurrGeomDB() ;
|
||||
VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL)
|
||||
nParentId = AdjustId( nParentId) ;
|
||||
// recupero il riferimento della curva
|
||||
Frame3d frCrv ;
|
||||
if ( ! pGeomDB->GetGlobFrame( nCrvId, frCrv))
|
||||
return GDB_ID_NULL ;
|
||||
// recupero il riferimento di destinazione
|
||||
Frame3d frLoc ;
|
||||
if ( ! pGeomDB->GetGroupGlobFrame( nParentId, frLoc))
|
||||
return GDB_ID_NULL ;
|
||||
// recupero la curva
|
||||
const ICurve* pCurve = GetCurve( pGeomDB->GetGeoObj( nCrvId)) ;
|
||||
if ( pCurve == nullptr || ! pCurve->IsValid())
|
||||
return GDB_ID_NULL ;
|
||||
// recupero il vettore estrusione della curva e lo porto in locale al gruppo destinazione
|
||||
Vector3d vtExtr ;
|
||||
pCurve->GetExtrusion( vtExtr) ;
|
||||
vtExtr.LocToLoc( frCrv, frLoc) ;
|
||||
PtrOwner<ICurve> pCrvBez ( CurveToBezierCurve( pCurve)) ;
|
||||
|
||||
//int nType = pCurve->GetType() ;
|
||||
//switch ( nType ) {
|
||||
//case CRV_LINE :
|
||||
// pCrvBez.Set( LineToBezierCurve( GetCurveLine( pCurve))) ;
|
||||
// break ;
|
||||
//case CRV_ARC :
|
||||
// pCrvBez.Set( ArcToBezierCurve( GetCurveArc( pCurve))) ;
|
||||
// break ;
|
||||
//case CRV_BEZIER :
|
||||
// pCrvBez.Set( BezierToBasicBezierCurve( GetCurveBezier( pCurve))) ;
|
||||
// break ;
|
||||
//case CRV_COMPO :
|
||||
// pCrvBez.Set( CompositeToBezierCurve( GetCurveComposite( pCurve))) ;
|
||||
// break ;
|
||||
//default :
|
||||
// break ;
|
||||
//}
|
||||
// setto l'estrusione
|
||||
pCrvBez->SetExtrusion( vtExtr) ;
|
||||
// aggiungo la curva in forma di Bezier al DB
|
||||
int nId = pGeomDB->AddGeoObj( GDB_ID_NULL, nParentId, Release( pCrvBez)) ;
|
||||
return nId ;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------
|
||||
int
|
||||
ExeCreateCurveBezierForm( int nParentId, int nCrvId, int nDeg)
|
||||
{
|
||||
// eseguo
|
||||
int nId = MyCreateCurveBezierForm( nParentId, nCrvId) ;
|
||||
ExeSetModified() ;
|
||||
// se richiesto, salvo il comando Lua equivalente
|
||||
if ( IsCmdLog()) {
|
||||
string sLua = "EgtCurveBezierForm(" + IdToString( nParentId) + "," +
|
||||
IdToString( nCrvId) + "," +
|
||||
ToString( nDeg) + ")"
|
||||
" -- Id=" + ToString( nId) ;
|
||||
LOG_INFO( GetCmdLogger(), sLua.c_str()) ;
|
||||
}
|
||||
// restituisco l'identificativo della nuova entità
|
||||
return nId ;
|
||||
}
|
||||
|
||||
+767
-17
@@ -1,4 +1,4 @@
|
||||
//----------------------------------------------------------------------------
|
||||
//----------------------------------------------------------------------------
|
||||
// EgalTech 2014-2015
|
||||
//----------------------------------------------------------------------------
|
||||
// File : EXE_GdbCreateSurf.cpp Data : 04.05.15 Versione : 1.6e1
|
||||
@@ -19,6 +19,7 @@
|
||||
#include "GeoTools.h"
|
||||
#include "/EgtDev/Include/EXeExecutor.h"
|
||||
#include "/EgtDev/Include/EXeConst.h"
|
||||
#include "/EgtDev/Include/EGkDistPointLine.h"
|
||||
#include "/EgtDev/Include/EGkSurfFlatRegion.h"
|
||||
#include "/EgtDev/Include/EGkSfrCreate.h"
|
||||
#include "/EgtDev/Include/EGkSurfTriMesh.h"
|
||||
@@ -35,6 +36,7 @@
|
||||
#include "/EgtDev/Include/EgtPointerOwner.h"
|
||||
#include "/EgtDev/Include/EGkExtText.h"
|
||||
#include "/EgtDev/Include/EGkSbzStandard.h"
|
||||
#include "/EgtDev/Include/EGkSbzFromCurves.h"
|
||||
|
||||
using namespace std ;
|
||||
|
||||
@@ -1173,6 +1175,43 @@ ExeCreateSurfTmByRevolve( int nParentId, int nCrvId,
|
||||
return nNewId ;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------
|
||||
int
|
||||
ExeCreateSurfBzByPointCurve( int nParentId, int nCrvId, const Point3d& ptTop,
|
||||
bool bCapEnds, double dLinTol, int nRefType)
|
||||
{
|
||||
IGeomDB* pGeomDB = GetCurrGeomDB() ;
|
||||
VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL)
|
||||
nParentId = AdjustId( nParentId) ;
|
||||
bool bOk = true ;
|
||||
// recupero il riferimento locale
|
||||
Frame3d frLoc ;
|
||||
bOk = bOk && pGeomDB->GetGroupGlobFrame( nParentId, frLoc) ;
|
||||
// recupero la curva in locale
|
||||
CurveLocal CrvLoc( pGeomDB, nCrvId, frLoc) ;
|
||||
bOk = bOk && ( CrvLoc.Get() != nullptr) ;
|
||||
// porto in locale punto e vettore asse
|
||||
Point3d ptTopL = GetPointLocal( pGeomDB, ptTop, nRefType, frLoc) ;
|
||||
// calcolo la superficie
|
||||
ISurfBezier* pSTM = ( bOk ? GetSurfBezierRuled( ptTopL, CrvLoc, dLinTol) : nullptr) ;
|
||||
// inserisco la superficie nel DB
|
||||
int nNewId = ( bOk ? pGeomDB->AddGeoObj( GDB_ID_NULL, nParentId, pSTM) : GDB_ID_NULL) ;
|
||||
ExeSetModified() ;
|
||||
// se richiesto, salvo il comando Lua equivalente
|
||||
if ( IsCmdLog()) {
|
||||
string sLua = "EgtSurfBzByPointCurve(" + IdToString( nParentId) + "," +
|
||||
ToString( nCrvId) + ",{" +
|
||||
ToString( ptTop) + "},{" +
|
||||
( bCapEnds ? "true" : "false") + "," +
|
||||
ToString( dLinTol) + "," +
|
||||
RefTypeToString( nRefType) + ")" +
|
||||
" -- Id=" + ToString( nNewId) ;
|
||||
LOG_INFO( GetCmdLogger(), sLua.c_str()) ;
|
||||
}
|
||||
// restituisco l'identificativo della nuova entità
|
||||
return nNewId ;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------
|
||||
int
|
||||
ExeCreateSurfTmByScrewing( int nParentId, int nCrvId,
|
||||
@@ -1668,8 +1707,6 @@ ExeCreateSurfBezier( int nParentId, int nDegU, int nDegV, int nSpanU, int nSpanV
|
||||
if ( ! pSurfBez->SetControlPoint( i, ptCtrl))
|
||||
bOk = false ;
|
||||
}
|
||||
// calcolo eventuali poli
|
||||
pSurfBez->CalcPoles() ;
|
||||
// se superficie nulla (ovvero ridotta a punto), errore
|
||||
bOk = bOk && ! pSurfBez->IsAPoint() ;
|
||||
// inserisco la superficie nel DB
|
||||
@@ -1722,8 +1759,6 @@ ExeCreateSurfBezierRational( int nParentId, int nDegU, int nDegV, int nSpanU, in
|
||||
if ( ! pSurfBez->SetControlPoint( i, ptCtrl, vPntW[i].second))
|
||||
bOk = false ;
|
||||
}
|
||||
// calcolo eventuali poli
|
||||
pSurfBez->CalcPoles() ;
|
||||
// se superficie nulla (ovvero ridotta a punto), errore
|
||||
bOk = bOk && ! pSurfBez->IsAPoint() ;
|
||||
// inserisco la superficie nel DB
|
||||
@@ -1837,9 +1872,9 @@ ExeCreateSurfBezierTria2D( int nParentId, int nSurfBzId, int nTextHeight, bool b
|
||||
for ( int k = 0 ; k < (int)vTria2D.size() ; ++ k) {
|
||||
PtrOwner<ISurfTriMesh> pStm( CreateSurfTriMesh()) ;
|
||||
bOk = bOk && ! IsNull( pStm) ;
|
||||
Point3d ptP1L = get<1>(vTria2D[k]) ;
|
||||
Point3d ptP2L = get<2>(vTria2D[k]) ;
|
||||
Point3d ptP3L = get<3>(vTria2D[k]) ;
|
||||
Point3d ptP1L = get<1>(vTria2D[k]) ;
|
||||
Point3d ptP2L = get<2>(vTria2D[k]) ;
|
||||
Point3d ptP3L = get<3>(vTria2D[k]) ;
|
||||
// assegno il triangolo
|
||||
if ( bOk) {
|
||||
pStm->Init( 3, 1, 1) ;
|
||||
@@ -1887,7 +1922,8 @@ ExeCreateSurfBezierTria2D( int nParentId, int nSurfBzId, int nTextHeight, bool b
|
||||
|
||||
//-------------------------------------------------------------------------------
|
||||
int
|
||||
ExeCreateBezierSphere( int nParentId, const Point3d& ptCenter, double dR, int nRefType) {
|
||||
ExeCreateBezierSphere( int nParentId, const Point3d& ptCenter, double dR, int nRefType)
|
||||
{
|
||||
IGeomDB* pGeomDB = GetCurrGeomDB() ;
|
||||
VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL)
|
||||
nParentId = AdjustId( nParentId) ;
|
||||
@@ -1898,19 +1934,733 @@ ExeCreateBezierSphere( int nParentId, const Point3d& ptCenter, double dR, int nR
|
||||
// reucpero il punto in locale
|
||||
Point3d ptCenterLoc = GetPointLocal( pGeomDB, ptCenter, nRefType, frLoc) ;
|
||||
// Creo la superficie
|
||||
PtrOwner<ISurfBezier> pSurfBez( CreateBezierSphere( ptCenterLoc, dR)) ;
|
||||
pSurfBez->CalcPoles() ;
|
||||
PtrOwner<ISurfBezier> pSurfBez( GetSurfBezierSphere( ptCenterLoc, dR)) ;
|
||||
bOk = bOk && ! IsNull( pSurfBez) ;
|
||||
int nId = ( bOk ? pGeomDB->AddGeoObj( GDB_ID_NULL, nParentId, Release( pSurfBez)) : GDB_ID_NULL) ;
|
||||
ExeSetModified() ;
|
||||
// se richiesto, salvo il comando Lua equivalente
|
||||
if ( IsCmdLog()) {
|
||||
string sLua = "EgtCreateBezierSphere(" + IdToString( nParentId) + "," +
|
||||
ToString( ptCenter) + "," +
|
||||
ToString( dR) + "," +
|
||||
RefTypeToString( nRefType) + ")" +
|
||||
" -- Id=" + ToString( nId) ;
|
||||
string sLua = "EgtSurfBzSphere(" + IdToString( nParentId) + "," +
|
||||
ToString( ptCenter) + "," +
|
||||
ToString( dR) + "," +
|
||||
RefTypeToString( nRefType) + ")" +
|
||||
" -- Id=" + ToString( nId) ;
|
||||
LOG_INFO( GetCmdLogger(), sLua.c_str()) ;
|
||||
}
|
||||
// resituisco l'identificativo dell'entit� creata
|
||||
// resituisco l'identificativo dell'entità creata
|
||||
return nId ;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------
|
||||
int
|
||||
ExeCreateSurfBzByFlatContour( int nParentId, int nCrvId, double dLinTol)
|
||||
{
|
||||
IGeomDB* pGeomDB = GetCurrGeomDB() ;
|
||||
VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL)
|
||||
nParentId = AdjustId( nParentId) ;
|
||||
bool bOk = true ;
|
||||
// recupero il riferimento locale
|
||||
Frame3d frLoc ;
|
||||
bOk = bOk && pGeomDB->GetGroupGlobFrame( nParentId, frLoc) ;
|
||||
// recupero la curva in locale
|
||||
CurveLocal CrvLoc( pGeomDB, nCrvId, frLoc) ;
|
||||
bOk = bOk && ( CrvLoc.Get() != nullptr) ;
|
||||
// calcolo la superficie
|
||||
PtrOwner<ISurfBezier> pSbz( bOk ? GetSurfBezierByFlatContour( CrvLoc, dLinTol) : nullptr) ;
|
||||
bOk = bOk && ! IsNull( pSbz) ;
|
||||
// inserisco la superficie nel DB
|
||||
int nNewId = ( bOk ? pGeomDB->AddGeoObj( GDB_ID_NULL, nParentId, Release( pSbz)) : GDB_ID_NULL) ;
|
||||
ExeSetModified() ;
|
||||
// se richiesto, salvo il comando Lua equivalente
|
||||
if ( IsCmdLog()) {
|
||||
string sLua = "EgtSurfBzByFlatContour(" + IdToString( nParentId) + "," +
|
||||
ToString( nCrvId) + "," +
|
||||
ToString( dLinTol) + ")" +
|
||||
" -- Id=" + ToString( nNewId) ;
|
||||
LOG_INFO( GetCmdLogger(), sLua.c_str()) ;
|
||||
}
|
||||
// restituisco l'identificativo della nuova entità
|
||||
return nNewId ;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------
|
||||
int
|
||||
ExeCreateSurfBzByRegion( int nParentId, const INTVECTOR& vCrvIds, double dLinTol)
|
||||
{
|
||||
IGeomDB* pGeomDB = GetCurrGeomDB() ;
|
||||
VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL)
|
||||
nParentId = AdjustId( nParentId) ;
|
||||
bool bOk = true ;
|
||||
// recupero il riferimento locale
|
||||
Frame3d frLoc ;
|
||||
bOk = bOk && pGeomDB->GetGroupGlobFrame( nParentId, frLoc) ;
|
||||
// recupero le curve in locale
|
||||
CURVELOCALVECTOR vCrvLoc ;
|
||||
vCrvLoc.reserve( vCrvIds.size()) ;
|
||||
CICURVEPVECTOR vCrvP ;
|
||||
vCrvP.reserve( vCrvIds.size()) ;
|
||||
for ( size_t i = 0 ; i < vCrvIds.size() ; ++ i) {
|
||||
int nId = (( vCrvIds[i] != GDB_ID_SEL) ? vCrvIds[i] : pGeomDB->GetFirstSelectedObj()) ;
|
||||
while ( nId != GDB_ID_NULL) {
|
||||
vCrvLoc.emplace_back( pGeomDB, nId, frLoc) ;
|
||||
vCrvP.push_back( vCrvLoc.back().Get()) ;
|
||||
bOk = bOk && ( vCrvLoc[i].Get() != nullptr) ;
|
||||
// passo al successivo
|
||||
nId = (( vCrvIds[i] != GDB_ID_SEL) ? GDB_ID_NULL : pGeomDB->GetNextSelectedObj()) ;
|
||||
}
|
||||
}
|
||||
// calcolo la superficie
|
||||
PtrOwner<ISurfBezier> pSbz( bOk ? GetSurfBezierByRegion( vCrvP, dLinTol) : nullptr) ;
|
||||
bOk = bOk && ! IsNull( pSbz) ;
|
||||
// inserisco la superficie nel DB
|
||||
int nNewId = ( bOk ? pGeomDB->AddGeoObj( GDB_ID_NULL, nParentId, Release( pSbz)) : GDB_ID_NULL) ;
|
||||
ExeSetModified() ;
|
||||
// se richiesto, salvo il comando Lua equivalente
|
||||
if ( IsCmdLog()) {
|
||||
string sLua = "EgtSurfBzByRegion(" + IdToString( nParentId) + ",{" +
|
||||
IdListToString( vCrvIds) + "}," +
|
||||
ToString( dLinTol) + ")" +
|
||||
" -- Id=" + ToString( nNewId) ;
|
||||
LOG_INFO( GetCmdLogger(), sLua.c_str()) ;
|
||||
}
|
||||
// restituisco l'identificativo della nuova entità
|
||||
return nNewId ;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------
|
||||
int
|
||||
ExeCreateSurfBzByExtrusion( int nParentId, int nCrvId, const Vector3d& vtExtr, bool bCapEnds,
|
||||
double dLinTol, int nRefType)
|
||||
{
|
||||
IGeomDB* pGeomDB = GetCurrGeomDB() ;
|
||||
VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL)
|
||||
nParentId = AdjustId( nParentId) ;
|
||||
bool bOk = true ;
|
||||
// recupero il riferimento locale
|
||||
Frame3d frLoc ;
|
||||
bOk = bOk && pGeomDB->GetGroupGlobFrame( nParentId, frLoc) ;
|
||||
// recupero il riferimento della curva
|
||||
Frame3d frCrv ;
|
||||
bOk = bOk && pGeomDB->GetGlobFrame( nCrvId, frCrv) ;
|
||||
// recupero la curva in locale
|
||||
const ICurve* pCrvOrig = GetCurve( pGeomDB->GetGeoObj( nCrvId)) ;
|
||||
PtrOwner<ICurve> pCrv( pCrvOrig->Clone()) ;
|
||||
// porto in locale il vettore estrusione
|
||||
Vector3d vtExtrL = GetVectorLocal( pGeomDB, vtExtr, nRefType, frLoc) ;
|
||||
// creo la superficie e la inserisco nel DB
|
||||
int nFirstId = GDB_ID_NULL ;
|
||||
double dAndTolStdDeg = 15 ;
|
||||
Plane3d plPlane ;
|
||||
double dArea ;
|
||||
PolyLine plApprox ;
|
||||
pCrv->ApproxWithLines( dLinTol, dAndTolStdDeg, ICurve::APL_STD, plApprox) ;
|
||||
double dOrthoExtr = 0 ;
|
||||
if ( bCapEnds && plApprox.IsClosedAndFlat( plPlane, dArea, 50 * EPS_SMALL)){
|
||||
dOrthoExtr = plPlane.GetVersN() * vtExtr ;
|
||||
if ( ( abs( dOrthoExtr) < EPS_SMALL))
|
||||
return GDB_ID_NULL ;
|
||||
if ( dOrthoExtr < 0)
|
||||
pCrv->Invert() ;
|
||||
}
|
||||
// creo l'estrusione della curva
|
||||
PtrOwner<ISurfBezier> pSbz( bOk ? GetSurfBezierByExtrusion( pCrv, vtExtrL, false, dLinTol) : nullptr ) ;
|
||||
bOk = bOk && ! IsNull( pSbz) ;
|
||||
// inserisco la superficie nel DB
|
||||
int nNewId = ( bOk ? pGeomDB->AddGeoObj( GDB_ID_NULL, nParentId, Release( pSbz)) : GDB_ID_NULL) ;
|
||||
bOk = bOk && ( nNewId != GDB_ID_NULL) ;
|
||||
|
||||
// se richiesta chiusura agli estremi
|
||||
if ( bCapEnds && bOk) {
|
||||
PtrOwner<ISurfBezier> pSrfBzTop( CreateSurfBezier()) ;
|
||||
pSrfBzTop->CreateByFlatContour( plApprox) ;
|
||||
pSrfBzTop->Translate( vtExtrL) ;
|
||||
pGeomDB->AddGeoObj( GDB_ID_NULL, nParentId, Release( pSrfBzTop)) ;
|
||||
PtrOwner<ISurfBezier> pSrfBzBottom( CreateSurfBezier()) ;
|
||||
pSrfBzBottom->CreateByFlatContour( plApprox) ;
|
||||
pSrfBzBottom->Invert() ;
|
||||
pGeomDB->AddGeoObj( GDB_ID_NULL, nParentId, Release( pSrfBzBottom)) ;
|
||||
}
|
||||
|
||||
ExeSetModified() ;
|
||||
// se richiesto, salvo il comando Lua equivalente
|
||||
if ( IsCmdLog()) {
|
||||
string sLua = "EgtSurfBzByExtrusion(" + IdToString( nParentId) + "," +
|
||||
IdToString( nCrvId) + ",{" +
|
||||
ToString( vtExtr) + "}," +
|
||||
( bCapEnds ? "true" : "false") + "," +
|
||||
ToString( dLinTol) + "," +
|
||||
RefTypeToString( nRefType) + ")" +
|
||||
" -- Id=" + ToString( nFirstId) ;
|
||||
LOG_INFO( GetCmdLogger(), sLua.c_str()) ;
|
||||
}
|
||||
// restituisco l'identificativo della nuova entità
|
||||
return nFirstId ;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------
|
||||
int
|
||||
ExeCreateSurfBzByRegionExtrusion( int nParentId, const INTVECTOR& vCrvIds, const Vector3d& vtExtr, bool bCapEnds,
|
||||
double dLinTol, int nRefType)
|
||||
{
|
||||
IGeomDB* pGeomDB = GetCurrGeomDB() ;
|
||||
VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL)
|
||||
nParentId = AdjustId( nParentId) ;
|
||||
bool bOk = true ;
|
||||
// recupero il riferimento locale
|
||||
Frame3d frLoc ;
|
||||
bOk = bOk && pGeomDB->GetGroupGlobFrame( nParentId, frLoc) ;
|
||||
// recupero le curve in locale
|
||||
CURVELOCALVECTOR vCrvLoc ;
|
||||
vCrvLoc.reserve( vCrvIds.size()) ;
|
||||
CICURVEPVECTOR vCrvP ;
|
||||
vCrvP.reserve( vCrvIds.size()) ;
|
||||
for ( size_t i = 0 ; i < vCrvIds.size() ; ++ i) {
|
||||
int nId = (( vCrvIds[i] != GDB_ID_SEL) ? vCrvIds[i] : pGeomDB->GetFirstSelectedObj()) ;
|
||||
while ( nId != GDB_ID_NULL) {
|
||||
vCrvLoc.emplace_back( pGeomDB, nId, frLoc) ;
|
||||
vCrvP.push_back( const_cast<ICurve*>( vCrvLoc.back().Get())) ;
|
||||
bOk = bOk && ( vCrvLoc[i].Get() != nullptr) ;
|
||||
// passo al successivo
|
||||
nId = (( vCrvIds[i] != GDB_ID_SEL) ? GDB_ID_NULL : pGeomDB->GetNextSelectedObj()) ;
|
||||
}
|
||||
}
|
||||
// porto in locale il vettore estrusione
|
||||
Vector3d vtExtrL = GetVectorLocal( pGeomDB, vtExtr, nRefType, frLoc) ;
|
||||
// creo le superfici e le inserisco nel DB
|
||||
int nFirstId = GDB_ID_NULL ;
|
||||
double dAndTolStdDeg = 15 ;
|
||||
|
||||
// riordino le curve in modo che la prima sia quella esterna e tutte le altre dopo
|
||||
POLYLINEVECTOR vPL ;
|
||||
for ( int i = 0 ; i < int( vCrvP.size()) ; ++ i) {
|
||||
vPL.emplace_back() ;
|
||||
if ( ! vCrvP[i]->ApproxWithLines( dLinTol, dAndTolStdDeg, ICurve::APL_SPECIAL, vPL.back()))
|
||||
return false ;
|
||||
}
|
||||
Vector3d vtN ;
|
||||
INTMATRIX vnPLIndMat ;
|
||||
BOOLVECTOR vbInvert ;
|
||||
if ( ! CalcRegionPolyLines( vPL, vtN, vnPLIndMat, vbInvert))
|
||||
return nFirstId ;
|
||||
|
||||
// creo una copia delle curve, orientate giuste
|
||||
ICURVEPOVECTOR vpCrvOr ;
|
||||
for (int i = 0 ; i < int( vnPLIndMat.size()) ; ++i) {
|
||||
for ( int j = 0 ; j< int( vnPLIndMat[i].size()) ; ++j) {
|
||||
vpCrvOr.emplace_back( vCrvP[vnPLIndMat[i][j]]->Clone()) ;
|
||||
if ( vbInvert[vnPLIndMat[i][j]])
|
||||
vpCrvOr.back()->Invert() ;
|
||||
}
|
||||
}
|
||||
|
||||
// controlo se il vettore di estrusione è orientato come la normale della curva più grande o no
|
||||
bool bOrientedAsExtrusion = false ;
|
||||
Plane3d plPlane ;
|
||||
double dArea ;
|
||||
double dOrthoExtr = 0 ;
|
||||
// verifico che la curva sia chiusa e piatta
|
||||
if ( vPL[0].IsClosedAndFlat(plPlane, dArea, dLinTol)) {
|
||||
dOrthoExtr = plPlane.GetVersN() * vtExtr ;
|
||||
// controllo che ci sia una componente dell'estrusione perpendicolare al piano della curva
|
||||
if ( abs( dOrthoExtr) < EPS_SMALL)
|
||||
return GDB_ID_NULL ;
|
||||
if ( dOrthoExtr > EPS_SMALL)
|
||||
bOrientedAsExtrusion = true ;
|
||||
}
|
||||
else
|
||||
bCapEnds = false ;
|
||||
|
||||
// creo l'estrusione delle curve
|
||||
for ( int i = 0 ; i < int( vpCrvOr.size()) ; ++ i) {
|
||||
// calcolo la superficie
|
||||
ISurfBezier* pSbz = ( bOk ? GetSurfBezierByExtrusion( vpCrvOr[i], vtExtrL, false, dLinTol) : nullptr ) ;
|
||||
if ( ! bOrientedAsExtrusion)
|
||||
pSbz->Invert() ;
|
||||
// inserisco la superficie nel DB
|
||||
int nNewId = ( bOk ? pGeomDB->AddGeoObj( GDB_ID_NULL, nParentId, pSbz) : GDB_ID_NULL) ;
|
||||
bOk = bOk && ( nNewId != GDB_ID_NULL) ;
|
||||
if ( bOk && nFirstId == GDB_ID_NULL)
|
||||
nFirstId = nNewId ;
|
||||
}
|
||||
|
||||
// se richiesta chiusura agli estremi
|
||||
if ( bCapEnds) {
|
||||
PtrOwner<ISurfBezier> pSrfBzTop( CreateSurfBezier()) ;
|
||||
pSrfBzTop->CreateByRegion( vPL) ;
|
||||
pSrfBzTop->Translate( vtExtrL) ;
|
||||
if ( ! bOrientedAsExtrusion)
|
||||
pSrfBzTop->Invert() ;
|
||||
pGeomDB->AddGeoObj( GDB_ID_NULL, nParentId, Release( pSrfBzTop)) ;
|
||||
PtrOwner<ISurfBezier> pSrfBzBottom( CreateSurfBezier()) ;
|
||||
pSrfBzBottom->CreateByRegion( vPL) ;
|
||||
if ( bOrientedAsExtrusion)
|
||||
pSrfBzBottom->Invert() ;
|
||||
pGeomDB->AddGeoObj( GDB_ID_NULL, nParentId, Release( pSrfBzBottom)) ;
|
||||
}
|
||||
|
||||
ExeSetModified() ;
|
||||
// se richiesto, salvo il comando Lua equivalente
|
||||
if ( IsCmdLog()) {
|
||||
string sLua = "EgtSurfBzByRegionExtrusion(" + IdToString( nParentId) + ",{" +
|
||||
IdListToString( vCrvIds) + "},{" +
|
||||
ToString( vtExtr) + "}," +
|
||||
( bCapEnds ? "true" : "false") + "," +
|
||||
ToString( dLinTol) + "," +
|
||||
RefTypeToString( nRefType) + ")" +
|
||||
" -- Id=" + ToString( nFirstId) ;
|
||||
LOG_INFO( GetCmdLogger(), sLua.c_str()) ;
|
||||
}
|
||||
// restituisco l'identificativo della nuova entità
|
||||
return nFirstId ;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------
|
||||
int
|
||||
ExeCreateSurfBzByScrewing( int nParentId, int nCrvId,
|
||||
const Point3d& ptAx, const Vector3d& vtAx,
|
||||
double dAngRotDeg, double dMove, bool bCapEnds, double dLinTol, int nRefType)
|
||||
{
|
||||
IGeomDB* pGeomDB = GetCurrGeomDB() ;
|
||||
VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL)
|
||||
nParentId = AdjustId( nParentId) ;
|
||||
bool bOk = true ;
|
||||
// recupero il riferimento locale
|
||||
Frame3d frLoc ;
|
||||
bOk = bOk && pGeomDB->GetGroupGlobFrame( nParentId, frLoc) ;
|
||||
// recupero la curva in locale
|
||||
CurveLocal CrvLoc( pGeomDB, nCrvId, frLoc) ;
|
||||
bOk = bOk && ( CrvLoc.Get() != nullptr) ;
|
||||
// porto in locale punto e vettore asse
|
||||
Point3d ptAxL = GetPointLocal( pGeomDB, ptAx, nRefType, frLoc) ;
|
||||
Vector3d vtAxL = GetVectorLocal( pGeomDB, vtAx, nRefType, frLoc) ;
|
||||
vtAxL.Normalize() ;
|
||||
|
||||
// la curva che fa da sezione alla superficie è chiusa e piana ed è richiesto il capping verifico se la superficie è da invertire
|
||||
// lo screwing non deve essere una semplice rivoluzione
|
||||
bool bOrientedAsScrewing = false ;
|
||||
Plane3d plPlane ;
|
||||
double dArea = 0 ;
|
||||
double dAngTolDeg = 15 ;
|
||||
PolyLine pl ; CrvLoc->ApproxWithLines( dLinTol, dAngTolDeg, ICurve::APL_STD, pl) ;
|
||||
if ( pl.IsClosedAndFlat( plPlane, dArea, dLinTol) && ! (abs(abs(dAngRotDeg) - ANG_FULL) < EPS_SMALL && abs( dMove) < EPS_SMALL)) {
|
||||
double dOrthoMove = plPlane.GetVersN() * vtAxL * dMove ;
|
||||
if( bCapEnds) {
|
||||
// se la curva sta in un piano passante per l'asse allora devo fare qualche conto per capire come è orientata
|
||||
if( abs( dOrthoMove) < EPS_SMALL) {
|
||||
// ruoto il centroide della curva di un minimo angolo e poi controllo se mi sono spostato in verso concorde alla normale al piano della curva
|
||||
Point3d ptCen ; CrvLoc->GetCentroid( ptCen) ;
|
||||
Point3d ptCenRot = ptCen ;
|
||||
ptCenRot.Rotate( ptAxL, vtAxL, 2) ;
|
||||
Vector3d vtRot = ptCenRot - ptCen ;
|
||||
dOrthoMove = vtRot * plPlane.GetVersN() ;
|
||||
}
|
||||
|
||||
if ( dOrthoMove > EPS_SMALL)
|
||||
bOrientedAsScrewing = true ;
|
||||
}
|
||||
}
|
||||
else
|
||||
bCapEnds = false ;
|
||||
|
||||
// calcolo la superficie
|
||||
PtrOwner<ISurfBezier> pSbz( bOk ? GetSurfBezierByScrewing( CrvLoc, ptAxL, vtAxL, dAngRotDeg, dMove, bCapEnds, dLinTol) : nullptr) ;
|
||||
bOk = bOk && ! IsNull( pSbz) ;
|
||||
if ( ! bOrientedAsScrewing && bCapEnds && bOk)
|
||||
pSbz->Invert() ;
|
||||
// inserisco la superficie nel DB
|
||||
int nNewId = ( bOk ? pGeomDB->AddGeoObj( GDB_ID_NULL, nParentId, Release( pSbz)) : GDB_ID_NULL) ;
|
||||
|
||||
// se richiesto creo anche i cap
|
||||
if ( bCapEnds && bOk) {
|
||||
ISurfBezier* pSbzBase1 = GetSurfBezierByFlatContour(CrvLoc,dLinTol) ;
|
||||
if ( bOrientedAsScrewing)
|
||||
pSbzBase1->Invert() ;
|
||||
bOk = bOk && pGeomDB->AddGeoObj( GDB_ID_NULL, nParentId, pSbzBase1) ;
|
||||
ISurfBezier* pSbzBase2 = GetSurfBezierByFlatContour( CrvLoc,dLinTol) ;
|
||||
pSbzBase2->Translate( vtAxL * dMove) ;
|
||||
pSbzBase2->Rotate( ptAxL, vtAxL, dAngRotDeg) ;
|
||||
if( ! bOrientedAsScrewing)
|
||||
pSbzBase2->Invert() ;
|
||||
bOk = bOk && pGeomDB->AddGeoObj( GDB_ID_NULL, nParentId, pSbzBase2) ;
|
||||
}
|
||||
ExeSetModified() ;
|
||||
// se richiesto, salvo il comando Lua equivalente
|
||||
if ( IsCmdLog()) {
|
||||
string sLua = "EgtSurfbzByScrewing(" + IdToString( nParentId) + "," +
|
||||
ToString( nCrvId) + ",{" +
|
||||
ToString( ptAx) + "},{" +
|
||||
ToString( vtAx) + "}," +
|
||||
ToString( dAngRotDeg) + "," +
|
||||
ToString( dMove) + "," +
|
||||
( bCapEnds ? "true" : "false") + "," +
|
||||
ToString( dLinTol) + "," +
|
||||
RefTypeToString( nRefType) + ")" +
|
||||
" -- Id=" + ToString( nNewId) ;
|
||||
LOG_INFO( GetCmdLogger(), sLua.c_str()) ;
|
||||
}
|
||||
// restituisco l'identificativo della nuova entità
|
||||
return nNewId ;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------
|
||||
int
|
||||
ExeCreateSurfBzByRevolve( int nParentId, int nCrvId,
|
||||
const Point3d& ptAx, const Vector3d& vtAx,
|
||||
bool bCapEnds, double dLinTol, int nRefType)
|
||||
{
|
||||
IGeomDB* pGeomDB = GetCurrGeomDB() ;
|
||||
VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL)
|
||||
nParentId = AdjustId( nParentId) ;
|
||||
bool bOk = true ;
|
||||
// recupero il riferimento locale
|
||||
Frame3d frLoc ;
|
||||
bOk = bOk && pGeomDB->GetGroupGlobFrame( nParentId, frLoc) ;
|
||||
// recupero la curva in locale
|
||||
CurveLocal CrvLoc( pGeomDB, nCrvId, frLoc) ;
|
||||
bOk = bOk && ( CrvLoc.Get() != nullptr) ;
|
||||
// porto in locale punto e vettore asse
|
||||
Point3d ptAxL = GetPointLocal( pGeomDB, ptAx, nRefType, frLoc) ;
|
||||
Vector3d vtAxL = GetVectorLocal( pGeomDB, vtAx, nRefType, frLoc) ;
|
||||
// calcolo la superficie
|
||||
PtrOwner<ISurfBezier> pSbz (( bOk ? GetSurfBezierByRevolve( CrvLoc, ptAxL, vtAxL, bCapEnds, dLinTol) : nullptr)) ;
|
||||
if( IsNull( pSbz) || ! pSbz->IsValid())
|
||||
return GDB_ID_NULL ;
|
||||
// controllo se devo invertire la superficie
|
||||
Point3d ptStart ; CrvLoc->GetStartPoint( ptStart) ;
|
||||
DistPointLine dplS( ptStart, ptAxL, vtAxL, 1, false) ;
|
||||
double dDistS = 0 ; dplS.GetDist( dDistS) ;
|
||||
bool bStartOnAx = dDistS > EPS_SMALL ;
|
||||
Point3d ptEnd ; CrvLoc->GetEndPoint( ptEnd) ;
|
||||
DistPointLine dplE( ptEnd, ptAxL, vtAxL, 1, false) ;
|
||||
double dDistE = 0 ; dplE.GetDist( dDistE) ;
|
||||
bool bEndOnAx = dDistE > EPS_SMALL ;
|
||||
Vector3d vtDir = ptEnd - ptStart ;
|
||||
double dParallel = vtDir * vtAxL ;
|
||||
if ( dParallel > EPS_SMALL)
|
||||
pSbz->Invert() ;
|
||||
|
||||
// finché non ho le SurfCompo creo qui i cap
|
||||
if ( bCapEnds && bOk) {
|
||||
// calcola il bbox della superficie
|
||||
BBox3d bbox3dSurf ;
|
||||
int nDegU, nDegV, nSpanU, nSpanV ;
|
||||
bool bTrim, bRat ;
|
||||
pSbz->GetInfo( nDegU, nDegV, nSpanU, nSpanV, bTrim, bRat) ;
|
||||
int nPointCount = ( nDegU * nSpanU + 1) * ( nDegV * nSpanV + 1) ;
|
||||
for ( int p = 0 ; p < nPointCount ; ++p) {
|
||||
bool bPointOk = true ;
|
||||
Point3d ptCtrl = pSbz->GetControlPoint( p, &bPointOk) ;
|
||||
bbox3dSurf.Add( ptCtrl) ;
|
||||
}
|
||||
// recupero i loop
|
||||
ICRVCOMPOPOVECTOR vCCLoop ;
|
||||
pSbz->GetLoops( vCCLoop, true) ;
|
||||
// controllo se i loop trovati sono validi
|
||||
bool bValidLoop1 = false ;
|
||||
bool bValidLoop3 = false ;
|
||||
if( ! IsNull(vCCLoop[1]) && vCCLoop[1]->IsValid())
|
||||
bValidLoop1 = true ;
|
||||
if( ! IsNull(vCCLoop[3]) && vCCLoop[3]->IsValid())
|
||||
bValidLoop3 = true ;
|
||||
|
||||
if( ! IsNull(vCCLoop[1]) && ! vCCLoop[1]->IsValid() && ! bStartOnAx)
|
||||
return GDB_ID_NULL ;
|
||||
if( ! IsNull(vCCLoop[3]) && ! vCCLoop[3]->IsValid() && ! bEndOnAx)
|
||||
return GDB_ID_NULL ;
|
||||
// il getLoops per superfici non trimmate restituisce 1 elemento per ogni lato dello spazio parametrico.
|
||||
// in questo caso la superficie è chiusa lungo il parametro V, quindi i lati 0 e 2 saranno null.
|
||||
double dAngTolDeg = 5 ;
|
||||
PolyLine plEdge1 ;
|
||||
if( bValidLoop1)
|
||||
vCCLoop[1]->ApproxWithLines( dLinTol, dAngTolDeg, ICurve::APL_STD, plEdge1) ;
|
||||
PolyLine plEdge3 ;
|
||||
if( bValidLoop3)
|
||||
vCCLoop[3]->ApproxWithLines( dLinTol, dAngTolDeg, ICurve::APL_STD, plEdge3) ;
|
||||
|
||||
// devo distinguere tra il loop superiore e quello inferiore
|
||||
Point3d ptCen ;
|
||||
Vector3d vtN ;
|
||||
Plane3d plPlane ; double dArea ;
|
||||
if( bValidLoop1){
|
||||
bOk = bOk && plEdge1.IsClosedAndFlat( plPlane, dArea, 50 * EPS_SMALL) ;
|
||||
vtN = plPlane.GetVersN() ;
|
||||
// vedo come questa normale è orientata rispetto alla bbox della superficie
|
||||
vCCLoop[1]->GetCentroid( ptCen) ;
|
||||
ptCen += vtN ;
|
||||
if ( bbox3dSurf.Encloses( ptCen))
|
||||
plEdge1.Invert() ;
|
||||
}
|
||||
if ( bValidLoop3) {
|
||||
bOk = bOk && plEdge3.IsClosedAndFlat( plPlane, dArea, 50 * EPS_SMALL) ;
|
||||
vtN = plPlane.GetVersN() ;
|
||||
// vedo come questa normale è orientata rispetto alla bbox della superficie
|
||||
vCCLoop[3]->GetCentroid( ptCen) ;
|
||||
ptCen += vtN ;
|
||||
if ( bbox3dSurf.Encloses( ptCen))
|
||||
plEdge3.Invert() ;
|
||||
}
|
||||
|
||||
// creo le superfici e le inserisco nel DB
|
||||
if( bValidLoop1) {
|
||||
PtrOwner<ISurfBezier> pSrfBzCap1( CreateSurfBezier()) ;
|
||||
pSrfBzCap1->CreateByFlatContour( plEdge1) ;
|
||||
pGeomDB->AddGeoObj( GDB_ID_NULL, nParentId, Release( pSrfBzCap1)) ;
|
||||
}
|
||||
if( bValidLoop3) {
|
||||
PtrOwner<ISurfBezier> pSrfBzCap3( CreateSurfBezier()) ;
|
||||
pSrfBzCap3->CreateByFlatContour( plEdge3) ;
|
||||
pGeomDB->AddGeoObj( GDB_ID_NULL, nParentId, Release( pSrfBzCap3)) ;
|
||||
}
|
||||
}
|
||||
|
||||
// inserisco la superficie nel DB
|
||||
int nNewId = ( bOk ? pGeomDB->AddGeoObj( GDB_ID_NULL, nParentId, Release( pSbz)) : GDB_ID_NULL) ;
|
||||
ExeSetModified() ;
|
||||
// se richiesto, salvo il comando Lua equivalente
|
||||
if ( IsCmdLog()) {
|
||||
string sLua = "EgtSurfBzByRevolve(" + IdToString( nParentId) + "," +
|
||||
ToString( nCrvId) + ",{" +
|
||||
ToString( ptAx) + "},{" +
|
||||
ToString( vtAx) + "}," +
|
||||
( bCapEnds ? "true" : "false") + "," +
|
||||
ToString( dLinTol) + "," +
|
||||
RefTypeToString( nRefType) + ")" +
|
||||
" -- Id=" + ToString( nNewId) ;
|
||||
LOG_INFO( GetCmdLogger(), sLua.c_str()) ;
|
||||
}
|
||||
// restituisco l'identificativo della nuova entità
|
||||
return nNewId ;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------
|
||||
int
|
||||
ExeCreateSurfBzRuled( int nParentId, int nCrvId1, int nCrvId2, int nRuledType, bool bCapEnds, double dLinTol)
|
||||
{
|
||||
IGeomDB* pGeomDB = GetCurrGeomDB() ;
|
||||
VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL)
|
||||
nParentId = AdjustId( nParentId) ;
|
||||
bool bOk = true ;
|
||||
// recupero il riferimento locale
|
||||
Frame3d frLoc ;
|
||||
bOk = bOk && pGeomDB->GetGroupGlobFrame( nParentId, frLoc) ;
|
||||
// recupero le curve in locale
|
||||
CurveLocal CrvLoc1( pGeomDB, nCrvId1, frLoc) ;
|
||||
bOk = bOk && ( CrvLoc1.Get() != nullptr) ;
|
||||
CurveLocal CrvLoc2( pGeomDB, nCrvId2, frLoc) ;
|
||||
bOk = bOk && ( CrvLoc2.Get() != nullptr) ;
|
||||
// calcolo la superficie
|
||||
PtrOwner<ISurfBezier> pSbz( bOk ? GetSurfBezierRuled( CrvLoc1, CrvLoc2, nRuledType, dLinTol) : nullptr) ;
|
||||
bOk = bOk && ! IsNull( pSbz) ;
|
||||
// verifiche per orientamento se con tappi
|
||||
bool bWithCaps = false ;
|
||||
bool bStdOrient = true ;
|
||||
Plane3d plPlane1, plPlane2 ;
|
||||
double dArea1, dArea2 ;
|
||||
if ( bOk && bCapEnds &&
|
||||
CrvLoc1->IsClosed() && CrvLoc2->IsClosed() && CrvLoc1->GetArea( plPlane1, dArea1) && CrvLoc2->GetArea( plPlane2, dArea2)) {
|
||||
bWithCaps = true ;
|
||||
Point3d ptStart1 ; CrvLoc1->GetStartPoint( ptStart1) ;
|
||||
Point3d ptStart2 ; CrvLoc2->GetStartPoint( ptStart2) ;
|
||||
Vector3d vtRuling = ptStart2 - ptStart1 ;
|
||||
bStdOrient = ( vtRuling * plPlane1.GetVersN() > 0) ;
|
||||
if ( ! bStdOrient)
|
||||
pSbz->Invert() ;
|
||||
}
|
||||
|
||||
// inserisco la superficie nel DB
|
||||
int nNewId = ( bOk ? pGeomDB->AddGeoObj( GDB_ID_NULL, nParentId, Release( pSbz)) : GDB_ID_NULL) ;
|
||||
|
||||
// se richiesto inserisco anche il cap
|
||||
if ( bOk && bWithCaps) {
|
||||
// costruisco la superficie dalla curva 1
|
||||
PtrOwner<ISurfBezier> pSbzFlat1( CreateSurfBezier()) ;
|
||||
double dAngTolDeg = 5 ;
|
||||
PolyLine pl1 ; CrvLoc1->ApproxWithLines(dLinTol, dAngTolDeg, ICurve::APL_STD, pl1) ;
|
||||
pSbzFlat1->CreateByFlatContour( pl1) ;
|
||||
if ( bStdOrient)
|
||||
pSbzFlat1->Invert() ;
|
||||
// inserisco la superficie nel DB
|
||||
bOk = bOk && pGeomDB->AddGeoObj( GDB_ID_NULL, nParentId, Release( pSbzFlat1)) ;
|
||||
// costruisco la superficie dalla curva 2
|
||||
PtrOwner<ISurfBezier> pSbzFlat2( CreateSurfBezier()) ;
|
||||
PolyLine pl2 ; CrvLoc2->ApproxWithLines(dLinTol, dAngTolDeg, ICurve::APL_STD, pl2) ;
|
||||
pSbzFlat2->CreateByFlatContour( pl2) ;
|
||||
if ( ! bStdOrient)
|
||||
pSbzFlat2->Invert() ;
|
||||
// inserisco la superficie nel DB
|
||||
bOk = bOk && pGeomDB->AddGeoObj( GDB_ID_NULL, nParentId, Release( pSbzFlat2)) ;
|
||||
}
|
||||
ExeSetModified() ;
|
||||
// se richiesto, salvo il comando Lua equivalente
|
||||
if ( IsCmdLog()) {
|
||||
string sLua = "EgtSurfBzRuled(" + IdToString( nParentId) + "," +
|
||||
ToString( nCrvId1) + "," +
|
||||
ToString( nCrvId2) + "," +
|
||||
ToString( nRuledType) + "," +
|
||||
( bCapEnds ? "true" : "false") + "," +
|
||||
ToString( dLinTol) + ")" +
|
||||
" -- Id=" + ToString( nNewId) ;
|
||||
LOG_INFO( GetCmdLogger(), sLua.c_str()) ;
|
||||
}
|
||||
// restituisco l'identificativo della nuova entità
|
||||
return nNewId ;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------
|
||||
int
|
||||
ExeCreateSurfBzSkinned( int nParentId, const INTVECTOR& vCrvIds, bool bCapEnds, double dLinTol)
|
||||
{
|
||||
IGeomDB* pGeomDB = GetCurrGeomDB() ;
|
||||
VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL)
|
||||
nParentId = AdjustId( nParentId) ;
|
||||
bool bOk = true ;
|
||||
// recupero il riferimento locale
|
||||
Frame3d frLoc ;
|
||||
bOk = bOk && pGeomDB->GetGroupGlobFrame( nParentId, frLoc) ;
|
||||
// recupero le curve in locale
|
||||
CURVELOCALVECTOR vCrvLoc ;
|
||||
vCrvLoc.reserve( vCrvIds.size()) ;
|
||||
CICURVEPVECTOR vCrvP ;
|
||||
vCrvP.reserve( vCrvIds.size()) ;
|
||||
for ( size_t i = 0 ; i < vCrvIds.size() ; ++ i) {
|
||||
int nId = vCrvIds[i] ;
|
||||
vCrvLoc.emplace_back( pGeomDB, nId, frLoc) ;
|
||||
vCrvP.push_back( vCrvLoc.back().Get()) ;
|
||||
bOk = bOk && ( vCrvLoc[i].Get() != nullptr) ;
|
||||
}
|
||||
|
||||
// calcolo la superficie
|
||||
PtrOwner<ISurfBezier> pSbz( bOk ? GetSurfBezierSkinned( vCrvP, dLinTol) : nullptr ) ;
|
||||
bOk = bOk && ! IsNull( pSbz) ;
|
||||
// inserisco la superficie nel DB
|
||||
int nNewId = ( bOk ? pGeomDB->AddGeoObj( GDB_ID_NULL, nParentId, Release( pSbz)) : GDB_ID_NULL) ;
|
||||
ExeSetModified() ;
|
||||
// se richiesto, salvo il comando Lua equivalente
|
||||
if ( IsCmdLog()) {
|
||||
string sLua = "EgtSurfBzSkinned(" + IdToString( nParentId) + ",{" +
|
||||
IdListToString( vCrvIds) + "}," +
|
||||
( bCapEnds ? "true" : "false") + "," +
|
||||
ToString( dLinTol) + ")" +
|
||||
" -- Id=" + ToString( nNewId) ;
|
||||
LOG_INFO( GetCmdLogger(), sLua.c_str()) ;
|
||||
}
|
||||
// restituisco l'identificativo della nuova entità
|
||||
return nNewId ;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------
|
||||
int
|
||||
ExeCreateSurfBzSwept( int nParentId, int nSectId, int nGuideId, const Vector3d& vtAx,
|
||||
bool bCapEnds, double dLinTol, int nRefType)
|
||||
{
|
||||
IGeomDB* pGeomDB = GetCurrGeomDB() ;
|
||||
VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL)
|
||||
nParentId = AdjustId( nParentId) ;
|
||||
bool bOk = true ;
|
||||
// recupero il riferimento locale
|
||||
Frame3d frLoc ;
|
||||
bOk = bOk && pGeomDB->GetGroupGlobFrame( nParentId, frLoc) ;
|
||||
// recupero le curve in locale
|
||||
CurveLocal CrvSect( pGeomDB, nSectId, frLoc) ;
|
||||
CurveLocal CrvGuide( pGeomDB, nGuideId, frLoc) ;
|
||||
// porto in locale vettore asse
|
||||
Vector3d vtAxL = GetVectorLocal( pGeomDB, vtAx, nRefType, frLoc) ;
|
||||
|
||||
PolyLine plGuide ;
|
||||
double dAngTolDeg = 15 ;
|
||||
CrvGuide->ApproxWithLines( dLinTol, dAngTolDeg, ICurve::APL_STD, plGuide) ;
|
||||
Plane3d plPlane ;
|
||||
bool bFlatGuide = plGuide.IsFlat( plPlane) ;
|
||||
// calcolo la superficie
|
||||
PtrOwner<ISurfBezier> pSbz( CreateSurfBezier()) ;
|
||||
if( bFlatGuide)
|
||||
pSbz.Set( bOk ? GetSurfBezierSweptInPlane( CrvSect, CrvGuide, vtAxL, bCapEnds, dLinTol) : nullptr ) ;
|
||||
else
|
||||
pSbz.Set( bOk ? GetSurfBezierSwept3d( CrvSect, CrvGuide, vtAxL, bCapEnds, dLinTol) : nullptr ) ;
|
||||
|
||||
// se richiesto il capping verifico che la superficie abbia il gisto orientamento
|
||||
bool bOrientedAsGuide = false ;
|
||||
ICRVCOMPOPOVECTOR vCCLoop ;
|
||||
if( bCapEnds) {
|
||||
// controlo se il vettore di start della guida è orientato come la normale della curva o no
|
||||
Vector3d vtStart ; CrvGuide->GetStartDir( vtStart) ;
|
||||
Plane3d plPlane ;
|
||||
double dArea ;
|
||||
double dOrthoGuide = 0 ;
|
||||
// verifico che la curva sia chiusa e piatta
|
||||
PolyLine PL ;
|
||||
CrvSect->ApproxWithLines(dLinTol, dAngTolDeg, ICurve::APL_STD, PL) ;
|
||||
if ( PL.IsClosedAndFlat(plPlane, dArea, dLinTol)) {
|
||||
dOrthoGuide = plPlane.GetVersN() * vtStart ;
|
||||
// controllo che ci sia una componente dell'estrusione perpendicolare al piano della curva
|
||||
if( abs( dOrthoGuide) < EPS_SMALL)
|
||||
return GDB_ID_NULL ;
|
||||
// recupero i loop
|
||||
pSbz->GetLoops( vCCLoop, true) ;
|
||||
// se necessario inverto la superficie
|
||||
if( dOrthoGuide > EPS_SMALL)
|
||||
bOrientedAsGuide = true ;
|
||||
else
|
||||
pSbz->Invert() ;
|
||||
}
|
||||
else
|
||||
bCapEnds = false ;
|
||||
}
|
||||
|
||||
|
||||
|
||||
// inserisco la superficie nel DB
|
||||
int nNewId = ( bOk ? pGeomDB->AddGeoObj( GDB_ID_NULL, nParentId, Release( pSbz)) : GDB_ID_NULL) ;
|
||||
|
||||
// se richiesto aggiungo anche i cap
|
||||
if ( bCapEnds) {
|
||||
// controllo se i loop trovati sono validi
|
||||
bool bValidLoop0 = false ;
|
||||
bool bValidLoop2 = false ;
|
||||
if( ! IsNull(vCCLoop[0]) && vCCLoop[0]->IsValid())
|
||||
bValidLoop0 = true ;
|
||||
if( ! IsNull(vCCLoop[2]) && vCCLoop[2]->IsValid())
|
||||
bValidLoop2 = true ;
|
||||
|
||||
if( ! IsNull(vCCLoop[0]) && ! vCCLoop[0]->IsValid())
|
||||
return GDB_ID_NULL ;
|
||||
if( ! IsNull(vCCLoop[2]) && ! vCCLoop[2]->IsValid())
|
||||
return GDB_ID_NULL ;
|
||||
// il getLoops per superfici non trimmate restituisce 1 elemento per ogni lato dello spazio parametrico.
|
||||
// in questo caso la superficie è chiusa lungo il parametro V, quindi i lati 1 e 3 saranno null.
|
||||
double dAngTolDeg = 5 ;
|
||||
PolyLine plEdge0 ;
|
||||
if( bValidLoop0)
|
||||
vCCLoop[0]->ApproxWithLines( dLinTol, dAngTolDeg, ICurve::APL_STD, plEdge0) ;
|
||||
PolyLine plEdge2 ;
|
||||
if( bValidLoop2)
|
||||
vCCLoop[2]->ApproxWithLines( dLinTol, dAngTolDeg, ICurve::APL_STD, plEdge2) ;
|
||||
|
||||
PtrOwner<ISurfBezier> pSrfBezStart( CreateSurfBezier()) ;
|
||||
pSrfBezStart->CreateByFlatContour( plEdge2) ;
|
||||
// se necessario inverto
|
||||
if( bOrientedAsGuide) // edge 2, che è la prima riga della matrice dei punti di controllo è orientato nello stesso verso della curva di sezione
|
||||
pSrfBezStart->Invert() ;
|
||||
// aggiungo al database
|
||||
pGeomDB->AddGeoObj( GDB_ID_NULL, nParentId, Release( pSrfBezStart)) ;
|
||||
PtrOwner<ISurfBezier> pSrfBezEnd( CreateSurfBezier()) ;
|
||||
pSrfBezEnd->CreateByFlatContour( plEdge0) ;
|
||||
// se necessario inverto
|
||||
if( bOrientedAsGuide) // edge 0, che è l'ultima riga della matrice dei punti di controllo è orientato in verso opposto alla curva di sezione
|
||||
pSrfBezEnd->Invert() ;
|
||||
// aggiungo al database
|
||||
pGeomDB->AddGeoObj( GDB_ID_NULL, nParentId, Release( pSrfBezEnd)) ;
|
||||
}
|
||||
ExeSetModified() ;
|
||||
// se richiesto, salvo il comando Lua equivalente
|
||||
if ( IsCmdLog()) {
|
||||
string sLua = "EgtSurfbzByScrewing(" + IdToString( nParentId) + "," +
|
||||
IdToString( nSectId) + "," +
|
||||
IdToString( nGuideId) + "," +
|
||||
ToString( dLinTol) + ")" +
|
||||
" -- Id=" + ToString( nNewId) ;
|
||||
LOG_INFO( GetCmdLogger(), sLua.c_str()) ;
|
||||
}
|
||||
// restituisco l'identificativo della nuova entità
|
||||
return nNewId ;
|
||||
}
|
||||
|
||||
+101
-4
@@ -1,4 +1,4 @@
|
||||
//----------------------------------------------------------------------------
|
||||
//----------------------------------------------------------------------------
|
||||
// EgalTech 2016-2016
|
||||
//----------------------------------------------------------------------------
|
||||
// File : EXE_GdbCreateVol.cpp Data : 27.10.16 Versione : 1.6v7
|
||||
@@ -64,7 +64,50 @@ ExeCreateVolZmap( int nParentId, const Point3d& ptIni, double dDimX, double dDim
|
||||
" -- Id=" + ToString( nNewId) ;
|
||||
LOG_INFO( GetCmdLogger(), sLua.c_str()) ;
|
||||
}
|
||||
// restituisco l'identificativo della nuova entità
|
||||
// restituisco l'identificativo della nuova entità
|
||||
return nNewId ;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------
|
||||
int ExeCreateVolZmapEmpty( int nParentId, const Point3d& ptIni, double dDimX, double dDimY, double dDimZ,
|
||||
double dPrec, bool bTriDex, int nRefType)
|
||||
{
|
||||
IGeomDB* pGeomDB = GetCurrGeomDB() ;
|
||||
VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL)
|
||||
nParentId = AdjustId( nParentId) ;
|
||||
// recupero il riferimento locale
|
||||
Frame3d frLoc ;
|
||||
bool bOk = pGeomDB->GetGroupGlobFrame( nParentId, frLoc) ;
|
||||
// porto in locale i punti
|
||||
Point3d ptIniL = GetPointLocal( pGeomDB, ptIni, nRefType, frLoc) ;
|
||||
Point3d ptOnXL = GetPointLocal( pGeomDB, ptIni + X_AX, nRefType, frLoc) ;
|
||||
Point3d ptOnYL = GetPointLocal( pGeomDB, ptIni + Y_AX, nRefType, frLoc) ;
|
||||
// ne ricavo un riferimento intrinseco
|
||||
Frame3d frBox ;
|
||||
bOk = bOk && frBox.Set( ptIniL, ptOnXL, ptOnYL) ;
|
||||
// creo lo Zmap nel suo riferimento intrinseco
|
||||
PtrOwner<IVolZmap> pVZM( CreateVolZmap()) ;
|
||||
bOk = bOk && ! IsNull( pVZM) ;
|
||||
bOk = bOk && pVZM->CreateEmpty( ORIG, dDimX, dDimY, dDimZ, dPrec, bTriDex) ;
|
||||
// lo porto nel riferimento locale
|
||||
bOk = bOk && pVZM->ToGlob( frBox) ;
|
||||
// inserisco lo Zmap nel DB
|
||||
int nNewId = ( bOk ? pGeomDB->AddGeoObj( GDB_ID_NULL, nParentId, Release( pVZM)) : GDB_ID_NULL) ;
|
||||
ExeSetModified() ;
|
||||
// se richiesto, salvo il comando Lua equivalente
|
||||
if ( IsCmdLog()) {
|
||||
string sLua = "EgtVolZmapEmpty(" + IdToString( nParentId) + ",{" +
|
||||
ToString( ptIni) + "}," +
|
||||
ToString( dDimX) + "," +
|
||||
ToString( dDimY) + "," +
|
||||
ToString( dDimZ) + "," +
|
||||
ToString( dPrec) + "," +
|
||||
( bTriDex ? "true" : "false") + "," +
|
||||
RefTypeToString( nRefType) + ")" +
|
||||
" -- Id=" + ToString( nNewId) ;
|
||||
LOG_INFO( GetCmdLogger(), sLua.c_str()) ;
|
||||
}
|
||||
// restituisco l'identificativo della nuova entità
|
||||
return nNewId ;
|
||||
}
|
||||
|
||||
@@ -103,7 +146,7 @@ ExeCreateVolZmapByRegionExtrusion( int nParentId, int nSfrId, double dDimZ, doub
|
||||
" -- Id=" + ToString( nNewId) ;
|
||||
LOG_INFO( GetCmdLogger(), sLua.c_str()) ;
|
||||
}
|
||||
// restituisco l'identificativo della nuova entità
|
||||
// restituisco l'identificativo della nuova entità
|
||||
return nNewId ;
|
||||
}
|
||||
|
||||
@@ -141,6 +184,60 @@ ExeCreateVolZmapFromSurfTm( int nParentId, int nStmId, double dPrec, bool bTriDe
|
||||
" -- Id=" + ToString( nNewId) ;
|
||||
LOG_INFO( GetCmdLogger(), sLua.c_str()) ;
|
||||
}
|
||||
// restituisco l'identificativo della nuova entità
|
||||
// restituisco l'identificativo della nuova entità
|
||||
return nNewId ;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------
|
||||
bool
|
||||
ExeUpdateVolZmapByAddingSurfTm( int nVolZmapId, int nStmId)
|
||||
{
|
||||
IGeomDB* pGeomDB = GetCurrGeomDB() ;
|
||||
VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL)
|
||||
// recupero lo Zmap
|
||||
IVolZmap* pVZM = GetVolZmap( pGeomDB->GetGeoObj( nVolZmapId)) ;
|
||||
bool bOk = ( pVZM != nullptr) ;
|
||||
// recupero la trimesh
|
||||
PtrOwner<ISurfTriMesh> pStm( CloneSurfTriMesh( pGeomDB->GetGeoObj( nStmId))) ;
|
||||
bOk = bOk && !IsNull( pStm) ;
|
||||
// recupero il frame dello Zmap e della Trimesh
|
||||
Frame3d frZmap, frStm ;
|
||||
bOk = bOk && pGeomDB->GetGlobFrame( nVolZmapId, frZmap) &&
|
||||
pGeomDB->GetGlobFrame( nStmId, frStm) ;
|
||||
// porto la Stm nel frame dello Zmap
|
||||
bOk = bOk && pStm->LocToLoc( frStm, frZmap) ;
|
||||
// aggiorno lo Zmap con la nuova superficie
|
||||
bOk = bOk && pVZM->AddSurfTm( pStm) ;
|
||||
ExeSetModified() ;
|
||||
// se richiesto, salvo il comando Lua equivalente
|
||||
if ( IsCmdLog()) {
|
||||
string sLua = "EgtUpdateVolZmapByAddingSurfTm(" + ToString( nVolZmapId) + "," +
|
||||
ToString( nStmId) + ")"
|
||||
" -- bOk =" + ToString( bOk) ;
|
||||
LOG_INFO( GetCmdLogger(), sLua.c_str()) ;
|
||||
}
|
||||
return bOk ;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------
|
||||
bool
|
||||
ExeUniformVolZmap( int nVolZmapId, double dToler)
|
||||
{
|
||||
IGeomDB* pGeomDB = GetCurrGeomDB() ;
|
||||
VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL)
|
||||
// recupero lo Zmap
|
||||
IVolZmap* pVZM = GetVolZmap( pGeomDB->GetGeoObj( nVolZmapId)) ;
|
||||
bool bOk = ( pVZM != nullptr) ;
|
||||
// aggiorno lo Zmap
|
||||
dToler = max( dToler, EPS_SMALL) ;
|
||||
bOk = bOk && pVZM->MakeUniform( dToler) ;
|
||||
ExeSetModified() ;
|
||||
// se richiesto, salvo il comando Lua equivalente
|
||||
if ( IsCmdLog()) {
|
||||
string sLua = "EgtUniformZmap(" + ToString( nVolZmapId) + "," +
|
||||
ToString( dToler) + ")"
|
||||
" -- bOk =" + ToString( bOk) ;
|
||||
LOG_INFO( GetCmdLogger(), sLua.c_str()) ;
|
||||
}
|
||||
return bOk ;
|
||||
}
|
||||
|
||||
+159
-3
@@ -19,6 +19,8 @@
|
||||
#include "GeoTools.h"
|
||||
#include "/EgtDev/Include/EXeExecutor.h"
|
||||
#include "/EgtDev/Include/EXeConst.h"
|
||||
#include "/EgtDev/Include/EGkGeoPoint3d.h"
|
||||
#include "/EgtDev/Include/EGkGeoPoint3d.h"
|
||||
#include "/EgtDev/Include/EGkCurve.h"
|
||||
#include "/EgtDev/Include/EGkCurveArc.h"
|
||||
#include "/EgtDev/Include/EGkCurveBezier.h"
|
||||
@@ -58,6 +60,21 @@ ExeCurveLength( int nId, double* pdLen)
|
||||
return ( pCurve != nullptr && pCurve->GetLength( *pdLen)) ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
ExeCurveLengthAtParam( int nId, double dPar, double* pdLen)
|
||||
{
|
||||
IGeomDB* pGeomDB = GetCurrGeomDB() ;
|
||||
VERIFY_GEOMDB( pGeomDB, false)
|
||||
// verifico il parametro
|
||||
if ( pdLen == nullptr)
|
||||
return false ;
|
||||
// recupero la curva
|
||||
ICurve* pCurve = GetCurve( pGeomDB->GetGeoObj( nId)) ;
|
||||
// recupero la lunghezza
|
||||
return ( pCurve != nullptr && pCurve->GetLengthAtParam( dPar, *pdLen)) ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
ExeCurveParamAtLength( int nId, double dLen, double* pdPar)
|
||||
@@ -161,7 +178,7 @@ ExeCurveIsFlat( int nId, Plane3d& Plane, bool bUseExtrusion, double dToler)
|
||||
return false ;
|
||||
// recupero la curva
|
||||
ICurve* pCurve = GetCurve( pGeomDB->GetGeoObj( nId)) ;
|
||||
// ne verifico la planarità
|
||||
// ne verifico la planarit�
|
||||
return ( pCurve != nullptr && pCurve->IsFlat( Plane, bUseExtrusion, dToler)) ;
|
||||
}
|
||||
|
||||
@@ -206,6 +223,8 @@ ExeCurveIsACircle( int nId, Point3d& ptCen, Vector3d& vtN, double& dRad, bool& b
|
||||
return false ;
|
||||
return pCompo->IsACircle( dToler, ptCen, vtN, dRad, bCCW) ;
|
||||
}
|
||||
default :
|
||||
return false ;
|
||||
}
|
||||
|
||||
return false ;
|
||||
@@ -291,7 +310,7 @@ ExeCurveNearestExtremityToPoint( int nId, const Point3d& ptP, bool& bStart)
|
||||
VERIFY_GEOMDB( pGeomDB, false)
|
||||
// recupero la curva
|
||||
ICurve* pCurve = GetCurve( pGeomDB->GetGeoObj( nId)) ;
|
||||
// recupero quale estremo è più vicino al punto
|
||||
// recupero quale estremo � pi� vicino al punto
|
||||
return ( pCurve != nullptr && pCurve->GetNearestExtremityToPoint( ptP, bStart)) ;
|
||||
}
|
||||
|
||||
@@ -367,7 +386,7 @@ ExeCurveMinAreaRectangleXY( int nId, int nRefId, Frame3d& frRect, double& dDimX,
|
||||
PL.LocToLoc( frCrv, pGeomDB->GetGridFrame()) ;
|
||||
else if ( bOk && nRefId != nId) {
|
||||
Frame3d frDest ;
|
||||
// nRefId può essere un gruppo o una entità
|
||||
// nRefId pu� essere un gruppo o una entit�
|
||||
if ( pGeomDB->GetGroupGlobFrame( nRefId, frDest) ||
|
||||
pGeomDB->GetGlobFrame( nRefId, frDest))
|
||||
PL.LocToLoc( frCrv, frDest) ;
|
||||
@@ -615,6 +634,9 @@ ExeCurveCompoRadius( int nId, int nSimpCrv, double& dRad)
|
||||
case CRV_BEZIER :
|
||||
dRad = -2 ;
|
||||
break ;
|
||||
default :
|
||||
dRad = -3 ;
|
||||
break ;
|
||||
}
|
||||
return true ;
|
||||
}
|
||||
@@ -644,6 +666,9 @@ ExeCurveCompoAngCenter( int nId, int nSimpCrv, double& dAngCen)
|
||||
case CRV_BEZIER :
|
||||
dAngCen = 0 ;
|
||||
break ;
|
||||
default :
|
||||
dAngCen = 0 ;
|
||||
break ;
|
||||
}
|
||||
return true ;
|
||||
}
|
||||
@@ -673,7 +698,138 @@ ExeCurveCompoNormVersor( int nId, int nSimpCrv, int nRefId, Vector3d& vtNorm)
|
||||
case CRV_BEZIER :
|
||||
vtNorm = V_NULL ;
|
||||
break ;
|
||||
default :
|
||||
vtNorm = V_NULL ;
|
||||
break ;
|
||||
}
|
||||
// gestione trasformazione ( eventuale)
|
||||
return TransformVector( pGeomDB, nId, nRefId, vtNorm) ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
ExeCurveCompoGetTempProp( int nId, INTVECTOR& vProp, int nPropInd)
|
||||
{
|
||||
IGeomDB* pGeomDB = GetCurrGeomDB() ;
|
||||
VERIFY_GEOMDB( pGeomDB, false)
|
||||
// recupero la curva composita
|
||||
const ICurveComposite* pCompo = GetCurveComposite( pGeomDB->GetGeoObj( nId)) ;
|
||||
if ( pCompo == nullptr)
|
||||
return false ;
|
||||
// recupero i valori
|
||||
vProp.clear() ;
|
||||
vProp.reserve( pCompo->GetCurveCount()) ;
|
||||
const ICurve* pSmplCrv = pCompo->GetFirstCurve() ;
|
||||
while ( pSmplCrv != nullptr) {
|
||||
vProp.push_back( pSmplCrv->GetTempProp( nPropInd)) ;
|
||||
pSmplCrv = pCompo->GetNextCurve() ;
|
||||
}
|
||||
return true ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
ExeCurveCompoGetTempParam( int nId, DBLVECTOR& vParam, int nParamInd)
|
||||
{
|
||||
IGeomDB* pGeomDB = GetCurrGeomDB() ;
|
||||
VERIFY_GEOMDB( pGeomDB, false)
|
||||
// recupero la curva composita
|
||||
const ICurveComposite* pCompo = GetCurveComposite( pGeomDB->GetGeoObj( nId)) ;
|
||||
if ( pCompo == nullptr)
|
||||
return false ;
|
||||
// recupero i valori
|
||||
vParam.clear() ;
|
||||
vParam.reserve( pCompo->GetCurveCount()) ;
|
||||
const ICurve* pSmplCrv = pCompo->GetFirstCurve() ;
|
||||
while ( pSmplCrv != nullptr) {
|
||||
vParam.push_back( pSmplCrv->GetTempParam( nParamInd)) ;
|
||||
pSmplCrv = pCompo->GetNextCurve() ;
|
||||
}
|
||||
return true ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
int
|
||||
ExeShowCurveBezierControlPoints( int nCrvId, int nDestGrpId, int* pnCount)
|
||||
{
|
||||
IGeomDB* pGeomDB = GetCurrGeomDB() ;
|
||||
VERIFY_GEOMDB( pGeomDB, false)
|
||||
// recupero la curva di bezier
|
||||
IGeoObj* pGeoObj = pGeomDB->GetGeoObj( nCrvId) ;
|
||||
if ( pGeoObj->GetType() != CRV_BEZIER && pGeoObj->GetType() != CRV_COMPO)
|
||||
return GDB_ID_NULL ;
|
||||
// recupero il riferimento della curva
|
||||
Frame3d frCrv ;
|
||||
bool bOk = true ;
|
||||
bOk = bOk && pGeomDB->GetGlobFrame( nCrvId, frCrv) ;
|
||||
// recupero il riferimento di destinazione
|
||||
Frame3d frDest ;
|
||||
bOk = bOk && pGeomDB->GetGroupGlobFrame( nDestGrpId, frDest) ;
|
||||
if ( ! bOk)
|
||||
return GDB_ID_NULL ;
|
||||
int nType = pGeoObj->GetType() ;
|
||||
if ( nType == CRV_COMPO) {
|
||||
const ICurveComposite* pCrvCompo = GetCurveComposite( pGeoObj) ;
|
||||
if ( pCrvCompo == nullptr)
|
||||
return false ;
|
||||
int nFirstId = -1 ;
|
||||
int nCount = 0 ;
|
||||
for ( int i = 0 ; i < pCrvCompo->GetCurveCount() ; ++i) {
|
||||
const ICurveBezier* pCrvBezier = GetCurveBezier( pCrvCompo->GetCurve(i)) ;
|
||||
if ( pCrvBezier == nullptr) {
|
||||
if ( pnCount != nullptr)
|
||||
*pnCount = nCount ;
|
||||
return nFirstId ;
|
||||
}
|
||||
int nDeg = pCrvBezier->GetDegree() ;
|
||||
//bool bRat = pCrvBezier->IsRational() ;
|
||||
for ( int i = 0 ; i < nDeg + 1 ; ++i) {
|
||||
IGeoPoint3d* pGeoPt( CreateGeoPoint3d()) ;
|
||||
//if ( ! bRat)
|
||||
// pGeoPt->Set( pCrvBezier->GetControlPoint( i)) ;
|
||||
//else
|
||||
// pGeoPt->Set( pCrvBezier->GetControlPoint( i) * pCrvBezier->GetControlWeight( i)) ;
|
||||
pGeoPt->Set( pCrvBezier->GetControlPoint( i)) ;
|
||||
pGeoPt->LocToLoc( frCrv, frDest) ;
|
||||
int nId = pGeomDB->AddGeoObj( GDB_ID_NULL, nDestGrpId, pGeoPt) ;
|
||||
if ( nFirstId == GDB_ID_NULL)
|
||||
nFirstId = nId ;
|
||||
if ( nId != GDB_ID_NULL)
|
||||
++nCount ;
|
||||
}
|
||||
}
|
||||
// restituisco i risultati
|
||||
if ( pnCount != nullptr)
|
||||
*pnCount = nCount ;
|
||||
return nFirstId ;
|
||||
}
|
||||
else if ( nType == CRV_BEZIER) {
|
||||
const ICurveBezier* pCrvBezier = GetCurveBezier( pGeoObj) ;
|
||||
if ( pCrvBezier == nullptr)
|
||||
return false ;
|
||||
int nDeg = pCrvBezier->GetDegree() ;
|
||||
//bool bRat = pCrvBezier->IsRational() ;
|
||||
int nFirstId = -1 ;
|
||||
int nCount = 0 ;
|
||||
for ( int i = 0 ; i < nDeg + 1 ; ++i) {
|
||||
IGeoPoint3d* pGeoPt( CreateGeoPoint3d()) ;
|
||||
//if ( ! bRat)
|
||||
// pGeoPt->Set( pCrvBezier->GetControlPoint( i)) ;
|
||||
//else
|
||||
// pGeoPt->Set( pCrvBezier->GetControlPoint( i) * pCrvBezier->GetControlWeight( i)) ;
|
||||
pGeoPt->Set( pCrvBezier->GetControlPoint( i)) ;
|
||||
pGeoPt->LocToLoc( frCrv, frDest) ;
|
||||
int nId = pGeomDB->AddGeoObj( GDB_ID_NULL, nDestGrpId, pGeoPt) ;
|
||||
if ( nFirstId == GDB_ID_NULL)
|
||||
nFirstId = nId ;
|
||||
if ( nId != GDB_ID_NULL)
|
||||
++nCount ;
|
||||
}
|
||||
// restituisco i risultati
|
||||
if ( pnCount != nullptr)
|
||||
*pnCount = nCount ;
|
||||
return nFirstId ;
|
||||
}
|
||||
else
|
||||
return GDB_ID_NULL ;
|
||||
}
|
||||
@@ -59,7 +59,7 @@ ExePocketing( const int nId, double dRad, double dStep, double dAngle, int nType
|
||||
|
||||
// eseguo Pocketing
|
||||
ICRVCOMPOPOVECTOR vCrvCompoRes ;
|
||||
bool bOk = CalcPocketing( pSfr, dRad, dStep, dAngle, nType, bSmooth, vCrvCompoRes) ;
|
||||
bool bOk = CalcPocketing( pSfr, dRad, 0, dStep, dAngle, nType, bSmooth, false, false, false, P_INVALID, nullptr, vCrvCompoRes) ;
|
||||
nFirstId = GDB_ID_NULL ;
|
||||
nCrvCount = int( vCrvCompoRes.size()) ;
|
||||
if ( bOk && nCrvCount > 0) {
|
||||
|
||||
+329
-53
@@ -29,10 +29,12 @@
|
||||
#include "/EgtDev/Include/EGkSurfFlatRegion.h"
|
||||
#include "/EgtDev/Include/EGkSurfTriMesh.h"
|
||||
#include "/EgtDev/Include/EGkSurfBezier.h"
|
||||
#include "/EgtDev/Include/EGkDistPointSurfFr.h"
|
||||
#include "/EgtDev/Include/EGkDistPointSurfTm.h"
|
||||
#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"
|
||||
@@ -63,7 +65,7 @@ ExeSurfIsClosed( int nId)
|
||||
VERIFY_GEOMDB( pGeomDB, false)
|
||||
// recupero la superficie
|
||||
ISurf* pSurf = GetSurf( pGeomDB->GetGeoObj( nId)) ;
|
||||
// verifico se è superficie chiusa
|
||||
// verifico se è superficie chiusa
|
||||
return ( pSurf != nullptr && pSurf->IsClosed()) ;
|
||||
}
|
||||
|
||||
@@ -78,7 +80,7 @@ ExeSurfVolume( int nId, double& dVol)
|
||||
return false ;
|
||||
// recupero la superficie
|
||||
ISurf* pSurf = GetSurf( pGeomDB->GetGeoObj( nId)) ;
|
||||
// ne restituisco l'eventuale volume (se è chiusa)
|
||||
// ne restituisco l'eventuale volume (se è chiusa)
|
||||
return ( pSurf != nullptr && pSurf->GetVolume( dVol)) ;
|
||||
}
|
||||
|
||||
@@ -118,24 +120,26 @@ bool
|
||||
ExeSurfFrTestExternal( int nId1, int nId2, double dMinDist)
|
||||
{
|
||||
IGeomDB* pGeomDB = GetCurrGeomDB() ;
|
||||
VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL)
|
||||
VERIFY_GEOMDB( pGeomDB, false)
|
||||
// recupero la prima superficie FlatRegion
|
||||
ISurfFlatRegion* pSfr1 = GetSurfFlatRegion( pGeomDB->GetGeoObj( nId1)) ;
|
||||
const ISurfFlatRegion* pSfr1 = GetSurfFlatRegion( pGeomDB->GetGeoObj( nId1)) ;
|
||||
if ( pSfr1 == nullptr)
|
||||
return false ;
|
||||
// se richiesta distanza di sicurezza, ne faccio l'offset
|
||||
PtrOwner<ISurfFlatRegion> pSfr1O( pSfr1->Clone()) ;
|
||||
if ( IsNull( pSfr1O))
|
||||
return false ;
|
||||
if ( dMinDist > 10 * EPS_SMALL)
|
||||
pSfr1O->Offset( dMinDist, ICurve::OFF_FILLET) ;
|
||||
PtrOwner<ISurfFlatRegion> pSfr1O ;
|
||||
if ( abs( dMinDist) > 5 * EPS_SMALL) {
|
||||
pSfr1O.Set( pSfr1->Clone()) ;
|
||||
if ( IsNull( pSfr1O) || ! pSfr1O->Offset( dMinDist, ICurve::OFF_FILLET))
|
||||
return false ;
|
||||
pSfr1 = Get( pSfr1O) ;
|
||||
}
|
||||
// recupero il riferimento della superficie
|
||||
Frame3d frSurf1 ;
|
||||
if ( ! pGeomDB->GetGlobFrame( nId1, frSurf1))
|
||||
return false ;
|
||||
// recupero il tipo della seconda entità
|
||||
// recupero il tipo della seconda entità
|
||||
int nType2 = pGeomDB->GetGeoType( nId2) ;
|
||||
// se seconda entità regione
|
||||
// se seconda entità regione
|
||||
if ( nType2 == SRF_FLATRGN) {
|
||||
// recupero la seconda superficie FlatRegion in locale alla prima
|
||||
SurfLocal Surf2Loc( pGeomDB, nId2, frSurf1) ;
|
||||
@@ -143,9 +147,9 @@ ExeSurfFrTestExternal( int nId1, int nId2, double dMinDist)
|
||||
if ( pSfr2L == nullptr)
|
||||
return false ;
|
||||
// eseguo il test di intersezione tra le due regioni
|
||||
for ( int i = 0 ; i < pSfr1O->GetChunkCount() ; ++ i) {
|
||||
for ( int i = 0 ; i < pSfr1->GetChunkCount() ; ++ i) {
|
||||
for ( int j = 0 ; j < pSfr2L->GetChunkCount() ; ++ j) {
|
||||
if ( pSfr1O->GetChunkSimpleClassification( i, *pSfr2L, j) != REGC_OUT)
|
||||
if ( pSfr1->GetChunkSimpleClassification( i, *pSfr2L, j) != REGC_OUT)
|
||||
return false ;
|
||||
}
|
||||
}
|
||||
@@ -159,8 +163,8 @@ ExeSurfFrTestExternal( int nId1, int nId2, double dMinDist)
|
||||
if ( pCrv2L == nullptr)
|
||||
return false ;
|
||||
// eseguo il test di intersezione tra regione e curva
|
||||
for ( int i = 0 ; i < pSfr1O->GetChunkCount() ; ++ i) {
|
||||
PtrOwner<ICurve> pCrv1( pSfr1O->GetLoop( i, 0)) ;
|
||||
for ( int i = 0 ; i < pSfr1->GetChunkCount() ; ++ i) {
|
||||
PtrOwner<ICurve> pCrv1( pSfr1->GetLoop( i, 0)) ;
|
||||
if ( pCrv1 == nullptr)
|
||||
return false ;
|
||||
IntersCurveCurve ccInt( *pCrv1, *pCrv2L) ;
|
||||
@@ -168,7 +172,8 @@ ExeSurfFrTestExternal( int nId1, int nId2, double dMinDist)
|
||||
if ( ! ccInt.GetCurveClassification( 1, EPS_SMALL, vcClass) || vcClass.empty())
|
||||
return false ;
|
||||
for ( auto& cClass : vcClass) {
|
||||
if ( cClass.nClass == CRVC_IN || cClass.nClass == CRVC_NULL)
|
||||
if ( cClass.nClass == CRVC_IN || cClass.nClass == CRVC_ON_M ||
|
||||
cClass.nClass == CRVC_ON_P || cClass.nClass == CRVC_NULL)
|
||||
return false ;
|
||||
}
|
||||
}
|
||||
@@ -178,34 +183,17 @@ ExeSurfFrTestExternal( int nId1, int nId2, double dMinDist)
|
||||
else if ( nType2 == GEO_PNT3D) {
|
||||
// recupero il punto
|
||||
IGeoPoint3d* pGeoPt = GetGeoPoint3d( pGeomDB->GetGeoObj( nId2)) ;
|
||||
Point3d pt = pGeoPt->GetPoint() ;
|
||||
Point3d ptP = pGeoPt->GetPoint() ;
|
||||
// porto il punto in locale
|
||||
Frame3d frPt ;
|
||||
if ( ! pGeomDB->GetGlobFrame( nId2, frPt))
|
||||
return false ;
|
||||
pt.LocToLoc( frPt, frSurf1) ;
|
||||
|
||||
for ( int i = 0 ; i < pSfr1O->GetChunkCount() ; i ++) {
|
||||
// verifico se è contenuto nel loop esterno
|
||||
PtrOwner<ICurve> pCrv( pSfr1O->GetLoop( i, 0)) ;
|
||||
PolyLine PL ;
|
||||
pCrv->ApproxWithLines( 10 * EPS_SMALL, 15, ICurve::APL_STD, PL) ;
|
||||
if ( IsPointInsidePolyLine( pt, PL, EPS_SMALL)) {
|
||||
bool bInsideHole = false ;
|
||||
// verifico se è contenuto in un loop interno
|
||||
for ( int j = 1 ; j < pSfr1O->GetLoopCount( i) ; j ++) {
|
||||
PtrOwner<ICurve> pCrv( pSfr1O->GetLoop( i, j)) ;
|
||||
pCrv->ApproxWithLines( 10 * EPS_SMALL, 15, ICurve::APL_STD, PL) ;
|
||||
PL.Invert() ;
|
||||
if ( IsPointInsidePolyLine( pt, PL, EPS_SMALL))
|
||||
bInsideHole = true ;
|
||||
}
|
||||
// se è contenuto nel loop esterno ma non è contenuto in nessuno dei loop interni allora il punto è interno
|
||||
if ( ! bInsideHole)
|
||||
return false ;
|
||||
}
|
||||
}
|
||||
return true ;
|
||||
ptP.LocToLoc( frPt, frSurf1) ;
|
||||
// determino se interno (comprende la frontiera)
|
||||
bool bInside ;
|
||||
if ( ! IsPointInsideSurfFr( ptP, pSfr1, 0, bInside))
|
||||
return false ;
|
||||
return ( ! bInside) ;
|
||||
}
|
||||
// altrimenti non valida
|
||||
else
|
||||
@@ -226,6 +214,20 @@ ExeSurfFrChunkCount( int nId)
|
||||
return pSfr->GetChunkCount() ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
ExeSurfFrChunkMaxOffset( int nId, int nChunk, double& dMaxOffset)
|
||||
{
|
||||
IGeomDB* pGeomDB = GetCurrGeomDB() ;
|
||||
VERIFY_GEOMDB( pGeomDB, false)
|
||||
// verifico il parametro
|
||||
if ( &dMaxOffset == nullptr)
|
||||
return false ;
|
||||
// recupero la Regione
|
||||
const ISurfFlatRegion* pSfr = GetSurfFlatRegion( pGeomDB->GetGeoObj( nId)) ;
|
||||
return ( pSfr != nullptr && pSfr->GetChunkMaxOffset( nChunk, dMaxOffset)) ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
int
|
||||
ExeSurfFrChunkSimpleClassify( int nId1, int nChunk1, int nId2, int nChunk2, double dToler)
|
||||
@@ -259,6 +261,25 @@ ExeSurfFrChunkSimpleClassify( int nId1, int nChunk1, int nId2, int nChunk2, doub
|
||||
return nRes ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
ExeSurfFrChunkCenter( int nId, int nChunk, int nRefId, Point3d& ptCen, Vector3d& vtN)
|
||||
{
|
||||
IGeomDB* pGeomDB = GetCurrGeomDB() ;
|
||||
VERIFY_GEOMDB( pGeomDB, false)
|
||||
// recupero la superficie FlatRegion
|
||||
ISurfFlatRegion* pSfr = GetSurfFlatRegion( pGeomDB->GetGeoObj( nId)) ;
|
||||
if ( pSfr == nullptr)
|
||||
return false ;
|
||||
// recupero il centro della parte
|
||||
if ( ! pSfr->GetChunkCentroid( nChunk, ptCen))
|
||||
return false ;
|
||||
// recupero la normale della regione
|
||||
vtN = pSfr->GetNormVersor() ;
|
||||
// gestione trasformazioni ( eventuali)
|
||||
return TransformPoint( pGeomDB, nId, nRefId, ptCen) && TransformVector( pGeomDB, nId, nRefId, vtN) ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
int
|
||||
ExeExtractSurfFrChunkLoops( int nId, int nChunk, int nDestGrpId, int* pnCount)
|
||||
@@ -380,11 +401,11 @@ ExeSurfTmGetNearestVertex( int nId, const Point3d& ptNear, int nRefId, int& nVer
|
||||
const ISurfTriMesh* pStm = GetSurfTriMesh( pGeomDB->GetGeoObj( nId)) ;
|
||||
if ( pStm == nullptr)
|
||||
return false ;
|
||||
// porto il punto Near nel riferimento dell'entità
|
||||
// porto il punto Near nel riferimento dell'entità
|
||||
Point3d ptNearL = ptNear ;
|
||||
if ( ! InvTransformPoint( pGeomDB, nId, nRefId, ptNearL))
|
||||
return false ;
|
||||
// recupero il vertice più vicino della superficie
|
||||
// recupero il vertice più vicino della superficie
|
||||
nVert = GetSurfTmNearestVertex( ptNearL, *pStm) ;
|
||||
if ( ! pStm->GetVertex( nVert, ptVert))
|
||||
return false ;
|
||||
@@ -392,6 +413,26 @@ ExeSurfTmGetNearestVertex( int nId, const Point3d& ptNear, int nRefId, int& nVer
|
||||
return TransformPoint( pGeomDB, nId, nRefId, ptVert) ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
ExeSurfTmTriangleNormVersor( int nId, int nTria, int nRefId, Vector3d& vtNorm)
|
||||
{
|
||||
IGeomDB* pGeomDB = GetCurrGeomDB() ;
|
||||
VERIFY_GEOMDB( pGeomDB, false)
|
||||
// recupero la superficie trimesh
|
||||
const ISurfTriMesh* pStm = GetSurfTriMesh( pGeomDB->GetGeoObj( nId)) ;
|
||||
if ( pStm == nullptr)
|
||||
return false ;
|
||||
// recupero il triangolo
|
||||
Triangle3d Tria ;
|
||||
if ( ! pStm->GetTriangle( nTria, Tria))
|
||||
return false ;
|
||||
// assegno la normale
|
||||
vtNorm = Tria.GetN() ;
|
||||
// gestione trasformazione ( eventuale)
|
||||
return TransformVector( pGeomDB, nId, nRefId, vtNorm) ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
int
|
||||
ExeSurfTmFacetFromTria( int nId, int nT)
|
||||
@@ -431,11 +472,11 @@ ExeSurfTmFacetNearestEndPoint( int nId, int nFacet, const Point3d& ptNear, int n
|
||||
const ISurfTriMesh* pStm = GetSurfTriMesh( pGeomDB->GetGeoObj( nId)) ;
|
||||
if ( pStm == nullptr)
|
||||
return false ;
|
||||
// porto il punto Near nel riferimento dell'entità
|
||||
// porto il punto Near nel riferimento dell'entità
|
||||
Point3d ptNearL = ptNear ;
|
||||
if ( ! InvTransformPoint( pGeomDB, nId, nRefId, ptNearL))
|
||||
return false ;
|
||||
// recupero il punto End più vicino della faccia
|
||||
// recupero il punto End più vicino della faccia
|
||||
if ( ! pStm->GetFacetNearestEndPoint( nFacet, ptNearL, ptEnd, vtN))
|
||||
return false ;
|
||||
// gestione trasformazioni ( eventuali)
|
||||
@@ -453,11 +494,11 @@ ExeSurfTmFacetNearestMidPoint( int nId, int nFacet, const Point3d& ptNear, int n
|
||||
const ISurfTriMesh* pStm = GetSurfTriMesh( pGeomDB->GetGeoObj( nId)) ;
|
||||
if ( pStm == nullptr)
|
||||
return false ;
|
||||
// porto il punto Near nel riferimento dell'entità
|
||||
// porto il punto Near nel riferimento dell'entità
|
||||
Point3d ptNearL = ptNear ;
|
||||
if ( ! InvTransformPoint( pGeomDB, nId, nRefId, ptNearL))
|
||||
return false ;
|
||||
// recupero il punto Mid più vicino della faccia
|
||||
// recupero il punto Mid più vicino della faccia
|
||||
if ( ! pStm->GetFacetNearestMidPoint( nFacet, ptNearL, ptMid, vtN))
|
||||
return false ;
|
||||
// gestione trasformazioni ( eventuali)
|
||||
@@ -555,7 +596,7 @@ ExeSurfTmFacetElevationInBBox( int nId, int nFacet, const BBox3d& b3Box, bool bA
|
||||
else if ( nRefId == GDB_ID_GRID)
|
||||
frBox = pGeomDB->GetGridFrame() ;
|
||||
else {
|
||||
// nRefId può essere un gruppo o una entità
|
||||
// nRefId può essere un gruppo o una entità
|
||||
if ( ! pGeomDB->GetGroupGlobFrame( nRefId, frBox) &&
|
||||
! pGeomDB->GetGlobFrame( nRefId, frBox))
|
||||
return false ;
|
||||
@@ -663,7 +704,7 @@ ExeSurfTmFacetOppositeSideEx( int nId, int nFacet, const Vector3d& vtDir, int nR
|
||||
pCrvCompo->ToLoc( frSpec) ;
|
||||
// ne faccio una copia per usi successivi
|
||||
PtrOwner<ICurveComposite> pCrvCopy( pCrvCompo->Clone()) ;
|
||||
// la direzione di riferimento è l'asse X, la sostituisco con quella perpendicolare alla curva più adatta
|
||||
// la direzione di riferimento è l'asse X, la sostituisco con quella perpendicolare alla curva più adatta
|
||||
Vector3d vtRef = X_AX ;
|
||||
double dCosMax = -1 ;
|
||||
const ICurve* pCrv = pCrvCompo->GetFirstCurve() ;
|
||||
@@ -913,6 +954,108 @@ ExeGetSurfTmSilhouette( int nId, const Vector3d& vtDir, double dToler, int nDest
|
||||
return nFirstId ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
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)
|
||||
// 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 ;
|
||||
if ( ! pGeomDB->GetGlobFrame( vIds[0], frSurf))
|
||||
return GDB_ID_NULL ;
|
||||
// recupero il riferimento di destinazione
|
||||
Frame3d frDest ;
|
||||
if ( ! pGeomDB->GetGroupGlobFrame( nDestGrpId, frDest))
|
||||
return GDB_ID_NULL ;
|
||||
// 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) ;
|
||||
Frame3d frPlanes ;
|
||||
if ( ! frPlanes.Set( ptOnL, vtNL))
|
||||
return GDB_ID_NULL ;
|
||||
// recupero i contorni delle varie silhouette
|
||||
int nFirstId = GDB_ID_NULL ;
|
||||
int nTempCount = 0 ;
|
||||
PtrOwner<ICAvParSilhouettesSurfTm> pCavParSilh( CreateCAvParSilhouettesSurfTm()) ;
|
||||
if ( IsNull( pCavParSilh) || ! pCavParSilh->SetData( vpStm, frPlanes, dToler))
|
||||
return GDB_ID_NULL ;
|
||||
for ( auto dDist : vdDist) {
|
||||
// recupero i loop come polilinee
|
||||
POLYLINEVECTOR vPL ;
|
||||
if ( ! pCavParSilh->GetSilhouette( dDist, vPL))
|
||||
return GDB_ID_NULL ;
|
||||
// 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 ;
|
||||
// assegno direzione di estrusione
|
||||
pCrvCompo->SetExtrusion( vtNL) ;
|
||||
// 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 ;
|
||||
}
|
||||
}
|
||||
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 = "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()) ;
|
||||
}
|
||||
// restituisco risultati
|
||||
if ( pnCount != nullptr)
|
||||
*pnCount = nCount ;
|
||||
return nFirstId ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
int
|
||||
ExeExtractSurfTmFacetLoops( int nId, int nFacet, int nDestGrpId, int* pnCount)
|
||||
@@ -1081,6 +1224,98 @@ ExeSurfTmGetFacetBBoxRef( int nId, int nFacet, int nFlag, const Frame3d& frRef,
|
||||
return pStm->GetFacetBBox( nFacet, frGlobL, b3Box, nFlag) ;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
bool
|
||||
ExeSurfTmGetFacetOutlineInfo( int nId, int nFacet, int nRefId,
|
||||
int& nStatus, BOOLVECTOR& vbOpen, INTVECTOR& vnAdj, DBLVECTOR& vdLen, VCT3DVECTOR& vvtNorm, DBLVECTOR& vdElev)
|
||||
{
|
||||
IGeomDB* pGeomDB = GetCurrGeomDB() ;
|
||||
VERIFY_GEOMDB( pGeomDB, false)
|
||||
// recupero la superficie TriMesh
|
||||
const ISurfTriMesh* pStm = GetSurfTriMesh( pGeomDB->GetGeoObj( nId)) ;
|
||||
if ( pStm == nullptr)
|
||||
return false ;
|
||||
// recupero normale della faccia
|
||||
Vector3d vtNorm ;
|
||||
if ( ! pStm->GetFacetNormal( nFacet, vtNorm))
|
||||
return false ;
|
||||
// recupero i loop come polilinee
|
||||
POLYLINEVECTOR vPL ;
|
||||
if ( ! pStm->GetFacetLoops( nFacet, vPL) || vPL.empty())
|
||||
return false ;
|
||||
// calcolo lo stato
|
||||
if ( vPL.size() == 1)
|
||||
nStatus = 0 ;
|
||||
else {
|
||||
nStatus = -1 ;
|
||||
for ( int i = 1 ; nStatus == -1 && i < int( vPL.size()) ; ++ i) {
|
||||
double dIni, dFin ;
|
||||
Point3d ptIni, ptFin ;
|
||||
bool bFound = vPL[i].GetFirstULine( &dIni, &ptIni, &dFin, &ptFin) ;
|
||||
while ( bFound) {
|
||||
int nAdj = lround( dIni) ;
|
||||
Vector3d vtNf ;
|
||||
if ( nAdj >= 0 && pStm->GetFacetNormal( nAdj, vtNf)) {
|
||||
Vector3d vtTg = ptFin - ptIni ;
|
||||
vtTg.Normalize() ;
|
||||
if ( ( vtTg ^ vtNf) * vtNorm > EPS_SMALL) {
|
||||
nStatus = 1 ;
|
||||
break ;
|
||||
}
|
||||
}
|
||||
bFound = vPL[i].GetNextULine( &dIni, &ptIni, &dFin, &ptFin) ;
|
||||
}
|
||||
}
|
||||
}
|
||||
// pulisco e prealloco i vettori del risultato
|
||||
int nDim = vPL[0].GetLineNbr() ;
|
||||
vbOpen.clear() ; vbOpen.reserve( nDim) ;
|
||||
vnAdj.clear() ; vnAdj.reserve( nDim) ;
|
||||
vdLen.clear() ; vdLen.reserve( nDim) ;
|
||||
vvtNorm.clear() ; vvtNorm.reserve( nDim) ;
|
||||
vdElev.clear() ; vdElev.reserve( nDim) ;
|
||||
// recupero riferimento alla lista dei punti
|
||||
PNTULIST& lstPU = vPL[0].GetUPointList() ;
|
||||
// ciclo sui lati del loop esterno (il primo)
|
||||
double dIni, dFin ;
|
||||
Point3d ptIni, ptFin ;
|
||||
bool bFound = vPL[0].GetFirstULine( &dIni, &ptIni, &dFin, &ptFin) ;
|
||||
while ( bFound) {
|
||||
// faccia adiacente
|
||||
int nAdj = lround( dIni) ;
|
||||
// lunghezza lato
|
||||
double dLen = Dist( ptIni, ptFin) ;
|
||||
// aperto se senza adiacenza o con faccia adiacente che va da parte negativa (tipo foro)
|
||||
bool bOpen = true ;
|
||||
Vector3d vtTg = ptFin - ptIni ;
|
||||
vtTg.Normalize() ;
|
||||
Vector3d vtNf ;
|
||||
if ( nAdj >= 0 && pStm->GetFacetNormal( nAdj, vtNf))
|
||||
bOpen = ((vtTg ^ vtNf) * vtNorm < EPS_SMALL) ;
|
||||
// normale al lato (verso interno se chiuso, verso esterno se aperto)
|
||||
Vector3d vtN = vtTg ;
|
||||
vtN.Rotate( vtNorm, 0, ( bOpen ? -1 : 1)) ;
|
||||
// elevazione secondo direzione della normale al lato
|
||||
double dElev = 0 ;
|
||||
for ( const auto& PU : lstPU) {
|
||||
double dDist = ( PU.first - ptIni) * vtN ;
|
||||
dElev = ( bOpen ? min( dElev, dDist) : max( dElev, dDist)) ;
|
||||
}
|
||||
// porto normale nel riferimento desiderato
|
||||
TransformVector( pGeomDB, nId, nRefId, vtN) ;
|
||||
// inserisco dati nei parametri di ritorno
|
||||
vbOpen.emplace_back( bOpen) ;
|
||||
vnAdj.emplace_back( nAdj) ;
|
||||
vdLen.emplace_back( dLen) ;
|
||||
vvtNorm.emplace_back( vtN) ;
|
||||
vdElev.emplace_back( dElev) ;
|
||||
// passo al prossimo lato
|
||||
bFound = vPL[0].GetNextULine( &dIni, &ptIni, &dFin, &ptFin) ;
|
||||
}
|
||||
|
||||
return true ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
int
|
||||
ExeSurfTmGetEdges( int nId, int nDestGrpId, bool bSmoothAng, int* pnCount)
|
||||
@@ -1260,7 +1495,7 @@ MySurfBezierGetCurveUV( int nSurfId, bool bIsU, double dPar, int nDestGrpId)
|
||||
PtrOwner<ICurveComposite> pCrv( bIsU ? pSbz->GetCurveOnU( dPar) : pSbz->GetCurveOnV( dPar)) ;
|
||||
if ( IsNull( pCrv))
|
||||
return GDB_ID_NULL ;
|
||||
// se è una curva
|
||||
// se è una curva
|
||||
if ( ! pCrv->IsAPoint()) {
|
||||
// porto la curva nel riferimento destinazione
|
||||
pCrv->LocToLoc( frSurf, frDest) ;
|
||||
@@ -1270,7 +1505,7 @@ MySurfBezierGetCurveUV( int nSurfId, bool bIsU, double dPar, int nDestGrpId)
|
||||
pGeomDB->CopyMaterial( nSurfId, nNewId) ;
|
||||
return nNewId ;
|
||||
}
|
||||
// altrimenti è collassata in un punto
|
||||
// altrimenti è collassata in un punto
|
||||
else {
|
||||
Point3d ptP ; pCrv->GetStartPoint( ptP) ;
|
||||
PtrOwner<IGeoPoint3d> pGeoPnt( CreateGeoPoint3d()) ;
|
||||
@@ -1374,7 +1609,7 @@ MySurfBezierGetControlCurveUV( int nSurfId, bool bIsU, int nInd, int nDestGrpId)
|
||||
pSbz->GetControlCurveOnU( nInd, PL) ;
|
||||
else
|
||||
pSbz->GetControlCurveOnV( nInd, PL) ;
|
||||
// se è una curva
|
||||
// se è una curva
|
||||
if ( PL.GetPointNbr() > 1) {
|
||||
PtrOwner<ICurveComposite> pCrvCo( CreateCurveComposite()) ;
|
||||
if ( IsNull( pCrvCo) || ! pCrvCo->FromPolyLine( PL))
|
||||
@@ -1387,7 +1622,7 @@ MySurfBezierGetControlCurveUV( int nSurfId, bool bIsU, int nInd, int nDestGrpId)
|
||||
pGeomDB->CopyMaterial( nSurfId, nNewId) ;
|
||||
return nNewId ;
|
||||
}
|
||||
// se altrimenti è collassata in un punto
|
||||
// se altrimenti è collassata in un punto
|
||||
else if ( PL.GetPointNbr() == 1) {
|
||||
Point3d ptP ; PL.GetFirstPoint( ptP) ;
|
||||
PtrOwner<IGeoPoint3d> pGeoPnt( CreateGeoPoint3d()) ;
|
||||
@@ -1401,7 +1636,7 @@ MySurfBezierGetControlCurveUV( int nSurfId, bool bIsU, int nInd, int nDestGrpId)
|
||||
pGeomDB->CopyMaterial( nSurfId, nNewId) ;
|
||||
return nNewId ;
|
||||
}
|
||||
// altrimenti è errore
|
||||
// altrimenti è errore
|
||||
else
|
||||
return GDB_ID_NULL ;
|
||||
}
|
||||
@@ -1494,4 +1729,45 @@ ExeExtractSurfBezierLoops( int nId, int nDestGrpId, int* pnCount)
|
||||
if ( pnCount != nullptr)
|
||||
*pnCount = nCount ;
|
||||
return nFirstId ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
int
|
||||
ExeShowSurfBezierControlPoints( int nSrfId, int nDestGrpId, int* pnCount)
|
||||
{
|
||||
IGeomDB* pGeomDB = GetCurrGeomDB() ;
|
||||
VERIFY_GEOMDB( pGeomDB, false)
|
||||
// recupero la superficie di bezier
|
||||
IGeoObj* pGeoObj = pGeomDB->GetGeoObj( nSrfId) ;
|
||||
if ( pGeoObj->GetType() != SRF_BEZIER)
|
||||
return GDB_ID_NULL ;
|
||||
// recupero il riferimento della superficie
|
||||
Frame3d frSurf ;
|
||||
bool bOk = true ;
|
||||
bOk = bOk && pGeomDB->GetGlobFrame( nSrfId, frSurf) ;
|
||||
// recupero il riferimento di destinazione
|
||||
Frame3d frDest ;
|
||||
bOk = bOk && pGeomDB->GetGroupGlobFrame( nDestGrpId, frDest) ;
|
||||
if ( ! bOk)
|
||||
return GDB_ID_NULL ;
|
||||
int nDegU = - 1, nDegV = - 1, nSpanU = - 1, nSpanV = - 1 ;
|
||||
bool bRat = false, bTrimmed = false ;
|
||||
ISurfBezier* pSrfBez = GetSurfBezier( pGeoObj) ;
|
||||
pSrfBez->GetInfo( nDegU, nDegV, nSpanU, nSpanV, bRat, bTrimmed) ;
|
||||
int nFirstId = -1 ;
|
||||
int nCount = 0 ;
|
||||
for ( int i = 0 ; i < (nDegU * nSpanU + 1) * ( nDegV * nSpanV + 1) ; ++i) {
|
||||
IGeoPoint3d* pGeoPt( CreateGeoPoint3d()) ;
|
||||
pGeoPt->Set( pSrfBez->GetControlPoint( i, &bOk)) ;
|
||||
pGeoPt->LocToLoc( frSurf, frDest) ;
|
||||
int nId = pGeomDB->AddGeoObj( GDB_ID_NULL, nDestGrpId, pGeoPt) ;
|
||||
if ( nFirstId == GDB_ID_NULL)
|
||||
nFirstId = nId ;
|
||||
if ( nId != GDB_ID_NULL)
|
||||
++nCount ;
|
||||
}
|
||||
// restituisco i risultati
|
||||
if ( pnCount != nullptr)
|
||||
*pnCount = nCount ;
|
||||
return nFirstId ;
|
||||
}
|
||||
+621
-39
@@ -20,6 +20,8 @@
|
||||
#include "GeoTools.h"
|
||||
#include "/EgtDev/Include/EXeExecutor.h"
|
||||
#include "/EgtDev/Include/EXeConst.h"
|
||||
#include "/EgtDev/Include/EGkGeoPoint3d.h"
|
||||
#include "/EgtDev/Include/EGkGeoVector3d.h"
|
||||
#include "/EgtDev/Include/EGkCurve.h"
|
||||
#include "/EgtDev/Include/EGkCurveArc.h"
|
||||
#include "/EgtDev/Include/EGkCurveBezier.h"
|
||||
@@ -34,16 +36,15 @@
|
||||
#include "/EgtDev/Include/EGkChainCurves.h"
|
||||
#include "/EgtDev/Include/EGkProjectCurveSurfTm.h"
|
||||
#include "/EgtDev/Include/EGkSurfFlatRegion.h"
|
||||
#include "/EgtDev/Include/EGkSfrCreate.h"
|
||||
#include "/EgtDev/Include/EGkSurfBezier.h"
|
||||
#include "/EgtDev/Include/EGkExtTExt.h"
|
||||
#include "/EgtDev/Include/EGkGdbIterator.h"
|
||||
#include "/EgtDev/Include/EGkStringUtils3d.h"
|
||||
#include "/EgtDev/Include/EGkIntervals.h"
|
||||
#include "/EgtDev/Include/EGkPolygon3d.h"
|
||||
#include "/EgtDev/Include/EGkGeoPoint3d.h"
|
||||
#include "/EgtDev/Include/EGkGeoVector3d.h"
|
||||
#include "/EgtDev/Include/EgtPointerOwner.h"
|
||||
#include "/EgtDev/Include/EGkCalcPocketing.h"
|
||||
#include <EgtDev/Include/EGkSfrCreate.h>
|
||||
#include "/EgtDev/Include/EgtPointerOwner.h"
|
||||
#include <functional>
|
||||
|
||||
|
||||
@@ -333,10 +334,9 @@ ExeChangeClosedCurveStartPoint( int nId, const Point3d& ptP, int nRefType)
|
||||
// porto in locale il punto vicino ad iniziale
|
||||
Point3d ptPL = GetPointLocal( pGeomDB, ptP, nRefType, frLoc) ;
|
||||
// recupero la posizione parametrica della proiezione di questo punto sulla curva
|
||||
DistPointCurve distPC( ptPL, *pCurve) ;
|
||||
double dPar ;
|
||||
int nFlag ;
|
||||
bOk = bOk && distPC.GetParamAtMinDistPoint( 0, dPar, nFlag) ;
|
||||
bOk = bOk && DistPointCurve( ptPL, *pCurve).GetParamAtMinDistPoint( 0, dPar, nFlag) ;
|
||||
// cambio il punto iniziale
|
||||
if ( bOk && pCurve->GetType() == CRV_ARC)
|
||||
bOk = bOk && GetCurveArc(pCurve)->ChangeStartPoint(dPar) ;
|
||||
@@ -876,7 +876,7 @@ ExeTrimExtendCurveByLen( int nId, double dLen, const Point3d& ptNear, int nRefTy
|
||||
bOk = bOk && pGeomDB->GetGlobFrame( nId, frLoc) ;
|
||||
// porto in locale il punto
|
||||
Point3d ptNearL = GetPointLocal( pGeomDB, ptNear, nRefType, frLoc) ;
|
||||
// cerco l'estremo più vicino al punto passato
|
||||
// cerco l'estremo più vicino al punto passato
|
||||
bool bStart ;
|
||||
if ( bOk && pCurve->GetNearestExtremityToPoint( ptNearL, bStart)) {
|
||||
if ( bStart) {
|
||||
@@ -971,7 +971,7 @@ MyTrimCurveWithRegion( int nCrvId, int nRegId, bool bInVsOut, bool bOn, int& nCo
|
||||
// passo alla successiva divisione
|
||||
bFound = inOk.GetNext( dParS, dParE) ;
|
||||
}
|
||||
// cancello l'ultima copia (se non c'erano intervalli validi è l'originale)
|
||||
// cancello l'ultima copia (se non c'erano intervalli validi è l'originale)
|
||||
pGeomDB->Erase( nCurrId) ;
|
||||
return nFirstId ;
|
||||
}
|
||||
@@ -1016,7 +1016,7 @@ MyTrimFlatCurveWithBox( int nCrvId, const Frame3d& frBox, const Vector3d& vtDiag
|
||||
Plane3d plPlane ;
|
||||
if ( ! pCrv->IsFlat( plPlane, false, 10 * EPS_SMALL))
|
||||
return GDB_ID_NULL ;
|
||||
// porto in locale alla curva il riferimento del box (il vettore è già in locale a questo stesso riferimento)
|
||||
// porto in locale alla curva il riferimento del box (il vettore è già in locale a questo stesso riferimento)
|
||||
Frame3d frBoxL = GetFrameLocal( pGeomDB, frBox, nRefType, frCrv) ;
|
||||
// determino la parte di piano (poligono) compresa nel box (applicando le opportune trasformazioni di riferimento)
|
||||
plPlane.ToLoc( frBoxL) ;
|
||||
@@ -1080,7 +1080,7 @@ MyTrimFlatCurveWithBox( int nCrvId, const Frame3d& frBox, const Vector3d& vtDiag
|
||||
// passo alla successiva divisione
|
||||
bFound = inOk.GetNext( dParS, dParE) ;
|
||||
}
|
||||
// cancello l'ultima copia (se non c'erano intervalli validi è l'originale)
|
||||
// cancello l'ultima copia (se non c'erano intervalli validi è l'originale)
|
||||
pGeomDB->Erase( nCurrId) ;
|
||||
return nFirstId ;
|
||||
}
|
||||
@@ -1118,7 +1118,7 @@ ExeSplitCurve( int nId, int nParts)
|
||||
// recupero la curva
|
||||
ICurve* pCurve = GetCurve( pGeomDB->GetGeoObj( nId)) ;
|
||||
bool bOk = ( pCurve != nullptr) ;
|
||||
// il numero di parti non può essere inferiore a 1
|
||||
// il numero di parti non può essere inferiore a 1
|
||||
nParts = max( nParts, 1) ;
|
||||
// lunghezza totale della curva
|
||||
double dLenTot = 0 ;
|
||||
@@ -1179,7 +1179,7 @@ ExeSplitCurveAtPoint( int nId, const Point3d& ptOn, int nRefType)
|
||||
int nFlag ;
|
||||
if ( ! dstPC.GetParamAtMinDistPoint( 0, dU, nFlag) || nFlag != MDPCI_NORMAL)
|
||||
bOk = false ;
|
||||
// se sull'inizio, provo se c'è una soluzione successiva
|
||||
// se sull'inizio, provo se c'è una soluzione successiva
|
||||
if ( bOk && dU < EPS_PARAM)
|
||||
dstPC.GetParamAtMinDistPoint( 1, dU, nFlag) ;
|
||||
}
|
||||
@@ -1196,7 +1196,7 @@ ExeSplitCurveAtPoint( int nId, const Point3d& ptOn, int nRefType)
|
||||
if ( bOk && dCutLen > EPS_SMALL && dLen - dCutLen > EPS_SMALL)
|
||||
bIsInside = true ;
|
||||
}
|
||||
// se il punto di taglio è interno, devo realmente tagliare
|
||||
// se il punto di taglio è interno, devo realmente tagliare
|
||||
int nNewId = GDB_ID_NULL ;
|
||||
if ( bIsInside) {
|
||||
// copio la curva
|
||||
@@ -1243,7 +1243,7 @@ ExeSplitCurveAtParam( int nId, double dParam)
|
||||
if ( bOk && dCutLen > EPS_SMALL && dLen - dCutLen > EPS_SMALL)
|
||||
bIsInside = true ;
|
||||
}
|
||||
// se il punto di taglio è interno, devo realmente tagliare
|
||||
// se il punto di taglio è interno, devo realmente tagliare
|
||||
int nNewId = GDB_ID_NULL ;
|
||||
if ( bIsInside) {
|
||||
// copio la curva
|
||||
@@ -1465,7 +1465,7 @@ ExeGetCurveLinearConvexHullXY( int nId, double dLinTol, int nRefType)
|
||||
" -- Id=" + ToString( nNewId) ;
|
||||
LOG_INFO( GetCmdLogger(), sLua.c_str()) ;
|
||||
}
|
||||
// restituisco l'identificativo della nuova entità
|
||||
// restituisco l'identificativo della nuova entità
|
||||
return nNewId ;
|
||||
}
|
||||
|
||||
@@ -1562,7 +1562,7 @@ MyModifyArcRadiusEx( IGeomDB* pGeomDB, int nId, double dRad)
|
||||
// se angolo al centro maggiore o uguale ad un giro o estremi coincidenti, conservo il centro
|
||||
if ( abs( pArc->GetAngCenter()) >= ANG_FULL - EPS_ANG_ZERO || dPlaneDist < 2 * EPS_SMALL)
|
||||
return MyModifyArcRadius( pGeomDB, nId, dRad) ;
|
||||
// mantengo i punti estremi (pertanto il nuovo raggio non può essere inferiore a metà della loro distanza nel piano)
|
||||
// mantengo i punti estremi (pertanto il nuovo raggio non può essere inferiore a metà della loro distanza nel piano)
|
||||
if ( dRad < dPlaneDist / 2 - EPS_ZERO)
|
||||
return false ;
|
||||
// creo arco con gli stessi estremi, con identica normale e con nuovo raggio
|
||||
@@ -1765,7 +1765,7 @@ ExeAddCurveCompoCurve( int nId, int nAddCrvId, bool bEraseOrig, bool bEndVsStart
|
||||
" -- Ok=" + ToString( bOk) ;
|
||||
LOG_INFO( GetCmdLogger(), sLua.c_str()) ;
|
||||
}
|
||||
// restituisco l'identificativo della nuova entità
|
||||
// restituisco l'identificativo della nuova entità
|
||||
return bOk ;
|
||||
}
|
||||
|
||||
@@ -1979,7 +1979,7 @@ ExeGetCurveCompoJointCount( int nId)
|
||||
ICurveComposite* pCompo = GetCurveComposite( pGeomDB->GetGeoObj( nId)) ;
|
||||
if ( pCompo == nullptr)
|
||||
return 0 ;
|
||||
// calcolo il numero di giunzioni (se chiusa è uguale al numero delle curve altrimenti -1)
|
||||
// calcolo il numero di giunzioni (se chiusa è uguale al numero delle curve altrimenti -1)
|
||||
if ( pCompo->IsClosed())
|
||||
return pCompo->GetCurveCount() ;
|
||||
else
|
||||
@@ -2183,6 +2183,52 @@ ExeRemoveCurveCompoUndercutOnY( int nId, double dLinTol)
|
||||
return bOk ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
ExeCurveCompoSetTempProp( int nId, int nCrv, int nProp, int nPropInd)
|
||||
{
|
||||
IGeomDB* pGeomDB = GetCurrGeomDB() ;
|
||||
VERIFY_GEOMDB( pGeomDB, false)
|
||||
// recupero la curva composita
|
||||
ICurveComposite* pCompo = GetCurveComposite( pGeomDB->GetGeoObj( nId)) ;
|
||||
bool bOk = ( pCompo != nullptr) ;
|
||||
// imposto il valore
|
||||
bOk = bOk && pCompo->SetCurveTempProp( nCrv, nProp, nPropInd) ;
|
||||
ExeSetModified() ;
|
||||
// se richiesto, salvo il comando Lua equivalente
|
||||
if ( IsCmdLog()) {
|
||||
string sLua = "EgtCurveCompoSetTempProp(" + ToString( nId) + "," +
|
||||
ToString( nCrv) + "," +
|
||||
ToString( nProp) + ")" +
|
||||
" -- Ok=" + ToString( bOk) ;
|
||||
LOG_INFO( GetCmdLogger(), sLua.c_str()) ;
|
||||
}
|
||||
return bOk ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
ExeCurveCompoSetTempParam( int nId, int nCrv, double dParam, int nParamInd)
|
||||
{
|
||||
IGeomDB* pGeomDB = GetCurrGeomDB() ;
|
||||
VERIFY_GEOMDB( pGeomDB, false)
|
||||
// recupero la curva composita
|
||||
ICurveComposite* pCompo = GetCurveComposite( pGeomDB->GetGeoObj( nId)) ;
|
||||
bool bOk = ( pCompo != nullptr) ;
|
||||
// imposto il valore
|
||||
bOk = bOk && pCompo->SetCurveTempParam( nCrv, dParam, nParamInd) ;
|
||||
ExeSetModified() ;
|
||||
// se richiesto, salvo il comando Lua equivalente
|
||||
if ( IsCmdLog()) {
|
||||
string sLua = "EgtCurveCompoSetTempParam(" + ToString( nId) + "," +
|
||||
ToString( nCrv) + "," +
|
||||
ToString( dParam) + ")" +
|
||||
" -- Ok=" + ToString( bOk) ;
|
||||
LOG_INFO( GetCmdLogger(), sLua.c_str()) ;
|
||||
}
|
||||
return bOk ;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------
|
||||
static bool
|
||||
MyChainCurvesInGroup( int nGroupId, const Point3d& ptNear, bool bAllowInvert, int nRefType)
|
||||
@@ -2384,7 +2430,7 @@ MyProjectCurveOnSurfTmExt( int nCurveId, int nSurfTmId, int nGuideId, int nDestG
|
||||
Frame3d frStm ;
|
||||
if ( ! pGeomDB->GetGlobFrame( nSurfTmId, frStm))
|
||||
return false ;
|
||||
// recupero l'entità guida (punto, curva o superficie) e il suo riferimento
|
||||
// recupero l'entità guida (punto, curva o superficie) e il suo riferimento
|
||||
const IGeoPoint3d* pGdePnt = nullptr ;
|
||||
const ICurve* pGdeCrv = nullptr ;
|
||||
const ISurfTriMesh* pGdeStm = nullptr ;
|
||||
@@ -2409,7 +2455,7 @@ MyProjectCurveOnSurfTmExt( int nCurveId, int nSurfTmId, int nGuideId, int nDestG
|
||||
CurveLocal CrvLoc( pCrv, frCrv, frStm) ;
|
||||
if ( CrvLoc.Get() == nullptr)
|
||||
return false ;
|
||||
// eseguo l'opportuna proiezione dopo aver portato l'entità guida nel riferimento della superficie
|
||||
// eseguo l'opportuna proiezione dopo aver portato l'entità guida nel riferimento della superficie
|
||||
PNT5AXVECTOR vPt5ax ;
|
||||
if ( pGdePnt != nullptr) {
|
||||
PtrOwner<IGeoPoint3d> pGdeLoc( pGdePnt->Clone()) ;
|
||||
@@ -2491,19 +2537,243 @@ ExeProjectCurveOnSurfTmExt( int nCurveId, int nSurfTmId, int nGuideId, int nDest
|
||||
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------
|
||||
static bool
|
||||
MyProjectCurveOnSurfBz( int nCurveId, int nSurfBzId, const Vector3d& vtDir, int nDestGrpId,
|
||||
double dLinTol, double dMaxSegmLen, int nRefType)
|
||||
{
|
||||
IGeomDB* pGeomDB = GetCurrGeomDB() ;
|
||||
VERIFY_GEOMDB( pGeomDB, false)
|
||||
// recupero la curva e il suo riferimento
|
||||
const ICurve* pCrv = GetCurve( pGeomDB->GetGeoObj( nCurveId)) ;
|
||||
if ( pCrv == nullptr)
|
||||
return false ;
|
||||
Frame3d frCrv ;
|
||||
if ( ! pGeomDB->GetGlobFrame( nCurveId, frCrv))
|
||||
return false ;
|
||||
// recupero la superficie bezier e il suo riferimento
|
||||
const ISurfBezier* pSbz = GetSurfBezier( pGeomDB->GetGeoObj( nSurfBzId)) ;
|
||||
// recupero la superficie trimesh
|
||||
const ISurfTriMesh* pStm = pSbz->GetAuxSurf() ;
|
||||
if ( pStm == nullptr)
|
||||
return false ;
|
||||
Frame3d frSbz ;
|
||||
if ( ! pGeomDB->GetGlobFrame( nSurfBzId, frSbz))
|
||||
return false ;
|
||||
// recupero il riferimento del gruppo di destinazione
|
||||
nDestGrpId = AdjustId( nDestGrpId) ;
|
||||
Frame3d frDest ;
|
||||
if ( ! pGeomDB->GetGroupGlobFrame( nDestGrpId, frDest))
|
||||
return false ;
|
||||
// porto la curva e il vettore nel riferimento della superficie
|
||||
CurveLocal CrvLoc( pCrv, frCrv, frSbz) ;
|
||||
if ( CrvLoc.Get() == nullptr)
|
||||
return false ;
|
||||
Vector3d vtDirL = GetVectorLocal( pGeomDB, vtDir, nRefType, frCrv) ;
|
||||
vtDirL.LocToLoc( frCrv, frSbz) ;
|
||||
// eseguo la proiezione
|
||||
PNT5AXVECTOR vPt5ax ;
|
||||
if ( ! ProjectCurveOnSurfTm( *CrvLoc.Get(), *pStm, vtDirL, dLinTol, dMaxSegmLen, vPt5ax))
|
||||
return false ;
|
||||
// inserisco la composita nel gruppo destinazione
|
||||
PtrOwner<ICurveComposite> pCompo ;
|
||||
for ( const auto& Pt5ax : vPt5ax) {
|
||||
if ( IsNull( pCompo)) {
|
||||
pCompo.Set( CreateCurveComposite()) ;
|
||||
if ( IsNull( pCompo))
|
||||
return false ;
|
||||
pCompo->AddPoint( GetLocToLoc( Pt5ax.ptP, frSbz, frDest)) ;
|
||||
}
|
||||
else
|
||||
pCompo->AddLine( GetLocToLoc( Pt5ax.ptP, frSbz, frDest)) ;
|
||||
}
|
||||
int nCompoId = pGeomDB->AddGeoObj( GDB_ID_NULL, nDestGrpId, Release( pCompo)) ;
|
||||
if ( nCompoId == GDB_ID_NULL)
|
||||
return false ;
|
||||
// aggiungo i versori nel gruppo destinazione
|
||||
int nInd = 0 ;
|
||||
for ( const auto& Pt5ax : vPt5ax) {
|
||||
PtrOwner<IGeoVector3d> pGeoVct( CreateGeoVector3d()) ;
|
||||
if ( IsNull( pGeoVct))
|
||||
return false ;
|
||||
pGeoVct->Set( 10 * GetLocToLoc( Pt5ax.vtDir, frSbz, frDest), GetLocToLoc( Pt5ax.ptP, frSbz, frDest)) ;
|
||||
int nNewId = pGeomDB->AddGeoObj( GDB_ID_NULL, nDestGrpId, Release( pGeoVct)) ;
|
||||
if ( nNewId == GDB_ID_NULL)
|
||||
return false ;
|
||||
pGeomDB->SetInfo( nNewId, "Ind", nInd ++) ;
|
||||
pGeomDB->SetInfo( nNewId, "Par", Pt5ax.dPar) ;
|
||||
pGeomDB->SetInfo( nNewId, "Flag", Pt5ax.nFlag) ;
|
||||
}
|
||||
|
||||
return true ;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------
|
||||
bool
|
||||
ExeProjectCurveOnSurfBz( int nCurveId, int nSurfBzId, const Vector3d& vtDir, int nDestGrpId,
|
||||
double dLinTol, double dMaxSegmLen, int nRefType)
|
||||
{
|
||||
bool bOk = MyProjectCurveOnSurfBz( nCurveId, nSurfBzId, vtDir, nDestGrpId, dLinTol, dMaxSegmLen, nRefType) ;
|
||||
ExeSetModified() ;
|
||||
// se richiesto, salvo il comando Lua equivalente
|
||||
if ( IsCmdLog()) {
|
||||
string sLua = "EgtProjectCurveOnSurfBz(" + ToString( nCurveId) + "," +
|
||||
ToString( nSurfBzId) + ",{" +
|
||||
ToString( vtDir) + "}," +
|
||||
ToString( nDestGrpId) + "," +
|
||||
ToString( dLinTol) + "," +
|
||||
ToString( dMaxSegmLen) + "," +
|
||||
RefTypeToString( nRefType) + ")" +
|
||||
" -- Ok=" + ToString( bOk) ;
|
||||
LOG_INFO( GetCmdLogger(), sLua.c_str()) ;
|
||||
}
|
||||
return bOk ;
|
||||
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------
|
||||
static bool
|
||||
MyProjectCurveOnSurfBzExt( int nCurveId, int nSurfBzId, int nGuideId, int nDestGrpId,
|
||||
double dLinTol, double dMaxSegmLen, bool bDirFromGuide)
|
||||
{
|
||||
IGeomDB* pGeomDB = GetCurrGeomDB() ;
|
||||
VERIFY_GEOMDB( pGeomDB, false)
|
||||
// recupero la curva e il suo riferimento
|
||||
const ICurve* pCrv = GetCurve( pGeomDB->GetGeoObj( nCurveId)) ;
|
||||
if ( pCrv == nullptr)
|
||||
return false ;
|
||||
Frame3d frCrv ;
|
||||
if ( ! pGeomDB->GetGlobFrame( nCurveId, frCrv))
|
||||
return false ;
|
||||
// recupero la superficie Bezier e il suo riferimento
|
||||
const ISurfBezier* pSbz = GetSurfBezier( pGeomDB->GetGeoObj( nSurfBzId)) ;
|
||||
// recupero la superficie trimesh
|
||||
const ISurfTriMesh* pStm = pSbz->GetAuxSurf() ;
|
||||
if ( pStm == nullptr)
|
||||
return false ;
|
||||
Frame3d frSbz ;
|
||||
if ( ! pGeomDB->GetGlobFrame( nSurfBzId, frSbz))
|
||||
return false ;
|
||||
// recupero l'entità guida (punto, curva o superficie) e il suo riferimento
|
||||
const IGeoPoint3d* pGdePnt = nullptr ;
|
||||
const ICurve* pGdeCrv = nullptr ;
|
||||
const ISurfTriMesh* pGdeStm = nullptr ;
|
||||
pGdePnt = GetGeoPoint3d( pGeomDB->GetGeoObj( nGuideId)) ;
|
||||
if ( pGdePnt == nullptr) {
|
||||
pGdeCrv = GetCurve( pGeomDB->GetGeoObj( nGuideId)) ;
|
||||
if ( pGdeCrv == nullptr) {
|
||||
pGdeStm = GetSurfTriMesh( pGeomDB->GetGeoObj( nGuideId)) ;
|
||||
if ( pGdeStm == nullptr)
|
||||
return false ;
|
||||
}
|
||||
}
|
||||
Frame3d frGde ;
|
||||
if ( ! pGeomDB->GetGlobFrame( nGuideId, frGde))
|
||||
return false ;
|
||||
// recupero il riferimento del gruppo di destinazione
|
||||
nDestGrpId = AdjustId( nDestGrpId) ;
|
||||
Frame3d frDest ;
|
||||
if ( ! pGeomDB->GetGroupGlobFrame( nDestGrpId, frDest))
|
||||
return false ;
|
||||
// porto la curva nel riferimento della superficie
|
||||
CurveLocal CrvLoc( pCrv, frCrv, frSbz) ;
|
||||
if ( CrvLoc.Get() == nullptr)
|
||||
return false ;
|
||||
// eseguo l'opportuna proiezione dopo aver portato l'entità guida nel riferimento della superficie
|
||||
PNT5AXVECTOR vPt5ax ;
|
||||
if ( pGdePnt != nullptr) {
|
||||
PtrOwner<IGeoPoint3d> pGdeLoc( pGdePnt->Clone()) ;
|
||||
if ( pGdeLoc == nullptr)
|
||||
return false ;
|
||||
pGdeLoc->LocToLoc( frGde, frSbz) ;
|
||||
if ( ! ProjectCurveOnSurfTm( *CrvLoc.Get(), *pStm, *pGdeLoc, dLinTol, dMaxSegmLen, vPt5ax))
|
||||
return false ;
|
||||
}
|
||||
else if ( pGdeCrv != nullptr) {
|
||||
CurveLocal GdeLoc( pGdeCrv, frGde, frSbz) ;
|
||||
if ( GdeLoc.Get() == nullptr)
|
||||
return false ;
|
||||
if ( ! ProjectCurveOnSurfTm( *CrvLoc.Get(), *pStm, *GdeLoc.Get(), dLinTol, dMaxSegmLen, vPt5ax))
|
||||
return false ;
|
||||
}
|
||||
else { // pGdeStm != nullptr
|
||||
SurfLocal GdeLoc( pGdeStm, frGde, frSbz) ;
|
||||
const ISurfTriMesh* pGdeLoc = GetSurfTriMesh( GdeLoc.Get()) ;
|
||||
if ( pGdeLoc == nullptr)
|
||||
return false ;
|
||||
if ( ! ProjectCurveOnSurfTm( *CrvLoc.Get(), *pStm, *pGdeLoc, dLinTol, dMaxSegmLen, vPt5ax))
|
||||
return false ;
|
||||
}
|
||||
// inserisco la composita nel gruppo destinazione
|
||||
PtrOwner<ICurveComposite> pCompo ;
|
||||
for ( const auto& Pt5ax : vPt5ax) {
|
||||
if ( IsNull( pCompo)) {
|
||||
pCompo.Set( CreateCurveComposite()) ;
|
||||
if ( IsNull( pCompo))
|
||||
return false ;
|
||||
pCompo->AddPoint( GetLocToLoc( Pt5ax.ptP, frSbz, frDest)) ;
|
||||
}
|
||||
else
|
||||
pCompo->AddLine( GetLocToLoc( Pt5ax.ptP, frSbz, frDest)) ;
|
||||
}
|
||||
int nCompoId = pGeomDB->AddGeoObj( GDB_ID_NULL, nDestGrpId, Release( pCompo)) ;
|
||||
if ( nCompoId == GDB_ID_NULL)
|
||||
return false ;
|
||||
// aggiungo i versori nel gruppo destinazione
|
||||
int nInd = 0 ;
|
||||
for ( const auto& Pt5ax : vPt5ax) {
|
||||
PtrOwner<IGeoVector3d> pGeoVct( CreateGeoVector3d()) ;
|
||||
if ( IsNull( pGeoVct))
|
||||
return false ;
|
||||
Vector3d vtDir = ( bDirFromGuide ? Pt5ax.vtDir2 : Pt5ax.vtDir) ;
|
||||
pGeoVct->Set( 10 * GetLocToLoc( vtDir, frSbz, frDest), GetLocToLoc( Pt5ax.ptP, frSbz, frDest)) ;
|
||||
int nNewId = pGeomDB->AddGeoObj( GDB_ID_NULL, nDestGrpId, Release( pGeoVct)) ;
|
||||
if ( nNewId == GDB_ID_NULL)
|
||||
return false ;
|
||||
pGeomDB->SetInfo( nNewId, "Ind", nInd ++) ;
|
||||
pGeomDB->SetInfo( nNewId, "Par", Pt5ax.dPar) ;
|
||||
pGeomDB->SetInfo( nNewId, "Flag", Pt5ax.nFlag) ;
|
||||
}
|
||||
|
||||
return true ;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------
|
||||
bool
|
||||
ExeProjectCurveOnSurfBzExt( int nCurveId, int nSurfBzId, int nGuideId, int nDestGrpId,
|
||||
double dLinTol, double dMaxSegmLen, bool bDirFromGuide)
|
||||
{
|
||||
bool bOk = MyProjectCurveOnSurfBzExt( nCurveId, nSurfBzId, nGuideId, nDestGrpId, dLinTol, dMaxSegmLen, bDirFromGuide) ;
|
||||
ExeSetModified() ;
|
||||
// se richiesto, salvo il comando Lua equivalente
|
||||
if ( IsCmdLog()) {
|
||||
string sLua = "EgtProjectCurveOnSurfBzExt(" + ToString( nCurveId) + "," +
|
||||
ToString( nSurfBzId) + ",{" +
|
||||
ToString( nGuideId) + "}," +
|
||||
ToString( nDestGrpId) + "," +
|
||||
ToString( dLinTol) + "," +
|
||||
ToString( dMaxSegmLen) + "," +
|
||||
( bDirFromGuide ? "true" : "false") + ")" +
|
||||
" -- Ok=" + ToString( bOk) ;
|
||||
LOG_INFO( GetCmdLogger(), sLua.c_str()) ;
|
||||
}
|
||||
return bOk ;
|
||||
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
int
|
||||
ExeCurveGetVoronoi( int nId, int nDestGrpId, int nBound, int* pnCount)
|
||||
ExeCurveGetVoronoi( const INTVECTOR& vIds, int nDestGrpId, int nBound, int* pnCount)
|
||||
{
|
||||
IGeomDB* pGeomDB = GetCurrGeomDB() ;
|
||||
VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL)
|
||||
// recupero la curva
|
||||
const ICurve* pCrv = GetCurve( pGeomDB->GetGeoObj( nId)) ;
|
||||
if ( pCrv == nullptr)
|
||||
return GDB_ID_NULL ;
|
||||
// recupero il riferimento della curva
|
||||
|
||||
if ( vIds.empty())
|
||||
return false ;
|
||||
|
||||
// recupero il riferimento della prima curva che sarà utilizzato da Voronoi
|
||||
Frame3d frCrv ;
|
||||
if ( ! pGeomDB->GetGlobFrame( nId, frCrv))
|
||||
if ( ! pGeomDB->GetGlobFrame( vIds[0], frCrv))
|
||||
return GDB_ID_NULL ;
|
||||
// recupero il riferimento di destinazione
|
||||
Frame3d frDest ;
|
||||
@@ -2512,7 +2782,32 @@ ExeCurveGetVoronoi( int nId, int nDestGrpId, int nBound, int* pnCount)
|
||||
|
||||
// Calcolo diagramma di Voronoi
|
||||
ICURVEPOVECTOR vCrv ;
|
||||
CalcCurveVoronoiDiagram( *pCrv, vCrv, nBound) ;
|
||||
if ( int( vIds.size()) == 1) {
|
||||
// recupero la curva
|
||||
const ICurve* pCrv = GetCurve( pGeomDB->GetGeoObj( vIds[0])) ;
|
||||
if ( pCrv == nullptr)
|
||||
return GDB_ID_NULL ;
|
||||
// calcolo
|
||||
CalcCurveVoronoiDiagram( *pCrv, vCrv, nBound) ;
|
||||
}
|
||||
else {
|
||||
// recupero le curve e le porto in locale al frame della prima curva
|
||||
CICURVEPVECTOR vOrigCrvs ;
|
||||
for ( int i = 0 ; i < int( vIds.size()) ; i ++) {
|
||||
CurveLocal CrvLoc( pGeomDB, vIds[i], frCrv) ;
|
||||
if ( CrvLoc.Get() == nullptr) {
|
||||
for ( auto pCrv : vOrigCrvs)
|
||||
delete( pCrv) ;
|
||||
return GDB_ID_NULL ;
|
||||
}
|
||||
vOrigCrvs.emplace_back( CrvLoc->Clone()) ;
|
||||
}
|
||||
// calcolo
|
||||
CalcCurvesVoronoiDiagram( vOrigCrvs, vCrv, nBound) ;
|
||||
// libero la memoria
|
||||
for ( auto pCrv : vOrigCrvs)
|
||||
delete( pCrv) ;
|
||||
}
|
||||
|
||||
// inserisco i risultati nel DB geometrico
|
||||
int nFirstId = GDB_ID_NULL ;
|
||||
@@ -2529,7 +2824,7 @@ ExeCurveGetVoronoi( int nId, int nDestGrpId, int nBound, int* pnCount)
|
||||
ExeSetModified() ;
|
||||
|
||||
if ( IsCmdLog()) {
|
||||
string sLua = "EgtCurveGetVoronoi(" + ToString( nId) + "," +
|
||||
string sLua = "EgtCurveGetVoronoi(" + ToString( vIds[0]) + "," +
|
||||
ToString( nDestGrpId) + ")" +
|
||||
" FirstId=" + ToString( nFirstId) + " nCurveCount=" + ToString( nCount) ;
|
||||
LOG_INFO( GetCmdLogger(), sLua.c_str()) ;
|
||||
@@ -2543,26 +2838,51 @@ ExeCurveGetVoronoi( int nId, int nDestGrpId, int nBound, int* pnCount)
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
int
|
||||
ExeCurveGetMedialAxis( int nId, int nDestGrpId, int nSide, int* pnCount)
|
||||
ExeCurveGetMedialAxis( const INTVECTOR& vIds, int nDestGrpId, int nSide, int* pnCount)
|
||||
{
|
||||
IGeomDB* pGeomDB = GetCurrGeomDB() ;
|
||||
VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL)
|
||||
// recupero la curva
|
||||
const ICurve* pCrv = GetCurve( pGeomDB->GetGeoObj( nId)) ;
|
||||
if ( pCrv == nullptr)
|
||||
return GDB_ID_NULL ;
|
||||
// recupero il riferimento della curva
|
||||
|
||||
if ( vIds.empty())
|
||||
return false ;
|
||||
|
||||
// recupero il riferimento della prima curva che sarà utilizzato da Voronoi
|
||||
Frame3d frCrv ;
|
||||
if ( ! pGeomDB->GetGlobFrame( nId, frCrv))
|
||||
if ( ! pGeomDB->GetGlobFrame( vIds[0], frCrv))
|
||||
return GDB_ID_NULL ;
|
||||
// recupero il riferimento di destinazione
|
||||
Frame3d frDest ;
|
||||
if ( ! pGeomDB->GetGroupGlobFrame( nDestGrpId, frDest))
|
||||
return GDB_ID_NULL ;
|
||||
return GDB_ID_NULL ;
|
||||
|
||||
// Calcolo il Medial Axis
|
||||
ICURVEPOVECTOR vCrv ;
|
||||
CalcCurveMedialAxis( *pCrv, vCrv, nSide) ;
|
||||
if ( int( vIds.size()) == 1) {
|
||||
// recupero la curva
|
||||
const ICurve* pCrv = GetCurve( pGeomDB->GetGeoObj( vIds[0])) ;
|
||||
if ( pCrv == nullptr)
|
||||
return GDB_ID_NULL ;
|
||||
// calcolo
|
||||
CalcCurveMedialAxis( *pCrv, vCrv, nSide) ;
|
||||
}
|
||||
else {
|
||||
// recupero le curve e le porto in locale al frame della prima curva
|
||||
CICURVEPVECTOR vOrigCrvs ;
|
||||
for ( int i = 0 ; i < int( vIds.size()) ; i ++) {
|
||||
CurveLocal CrvLoc( pGeomDB, vIds[i], frCrv) ;
|
||||
if ( CrvLoc.Get() == nullptr) {
|
||||
for ( auto pCrv : vOrigCrvs)
|
||||
delete( pCrv) ;
|
||||
return GDB_ID_NULL ;
|
||||
}
|
||||
vOrigCrvs.emplace_back( CrvLoc->Clone()) ;
|
||||
}
|
||||
// calcolo
|
||||
CalcCurvesMedialAxis( vOrigCrvs, vCrv, nSide) ;
|
||||
// libero la memoria
|
||||
for ( auto pCrv : vOrigCrvs)
|
||||
delete( pCrv) ;
|
||||
}
|
||||
|
||||
// inserisco i risultati nel DB geometrico
|
||||
int nFirstId = GDB_ID_NULL ;
|
||||
@@ -2579,7 +2899,7 @@ ExeCurveGetMedialAxis( int nId, int nDestGrpId, int nSide, int* pnCount)
|
||||
ExeSetModified() ;
|
||||
|
||||
if ( IsCmdLog()) {
|
||||
string sLua = "EgtCurveMedialAxisAdv(" + ToString( nId) + "," +
|
||||
string sLua = "EgtCurveMedialAxisAdv(" + ToString( vIds[0]) + "," +
|
||||
ToString( nSide) + "," +
|
||||
ToString( nDestGrpId) + ")" +
|
||||
" FirstId=" + ToString( nFirstId) + " nCurveCount=" + ToString( nCount) ;
|
||||
@@ -2641,3 +2961,265 @@ ExeCurveGetFatCurve( int nId, int nDestGrpId, double dRad, bool bSquareEnds, boo
|
||||
*pnCount = nCount ;
|
||||
return nFirstId ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
ExeCurveBezierIncreaseDegree( int nCrvId)
|
||||
{
|
||||
IGeomDB* pGeomDB = GetCurrGeomDB() ;
|
||||
VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL)
|
||||
// recupero la curva
|
||||
const ICurve* pCrv = GetCurve( pGeomDB->GetGeoObj( nCrvId)) ;
|
||||
if ( pCrv == nullptr)
|
||||
return false ;
|
||||
//// recupero il riferimento della curva
|
||||
//Frame3d frCrv ;
|
||||
//if ( ! pGeomDB->GetGlobFrame( nCrvId, frCrv))
|
||||
// return GDB_ID_NULL ;
|
||||
|
||||
if( pCrv->GetType() != CRV_BEZIER)
|
||||
return false ;
|
||||
|
||||
// aumento il grado della curva
|
||||
bool bOk = true ;
|
||||
PtrOwner<ICurveBezier> pCrvBezierNew ( BezierIncreaseDegree( GetCurveBezier( pCrv))) ;
|
||||
Vector3d vtExtr ;
|
||||
if ( bOk && pCrv->GetExtrusion( vtExtr))
|
||||
pCrvBezierNew->SetExtrusion( vtExtr) ;
|
||||
double dThick = 0 ;
|
||||
if ( bOk && pCrv->GetThickness( dThick))
|
||||
pCrvBezierNew->SetThickness(dThick) ;
|
||||
// sostituisco la vecchia curva con la nuova
|
||||
bOk = bOk && pGeomDB->ReplaceGeoObj( nCrvId, Release( pCrvBezierNew)) ;
|
||||
ExeSetModified() ;
|
||||
|
||||
if ( IsCmdLog()) {
|
||||
string sLua = "EgtCurveBezierIncreaseDegree(" + ToString( nCrvId) + ")"
|
||||
" -- Ok=" + ToString( bOk) ;
|
||||
LOG_INFO( GetCmdLogger(), sLua.c_str()) ;
|
||||
}
|
||||
|
||||
return bOk ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
ExeCurveBezierDecreaseDegree( int nCrvId, double dTol)
|
||||
{
|
||||
IGeomDB* pGeomDB = GetCurrGeomDB() ;
|
||||
VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL)
|
||||
// recupero la curva
|
||||
const ICurve* pCrv = GetCurve( pGeomDB->GetGeoObj( nCrvId)) ;
|
||||
if ( pCrv == nullptr)
|
||||
return false ;
|
||||
//// recupero il riferimento della curva
|
||||
//Frame3d frCrv ;
|
||||
//if ( ! pGeomDB->GetGlobFrame( nCrvId, frCrv))
|
||||
// return GDB_ID_NULL ;
|
||||
|
||||
if( pCrv->GetType() != CRV_BEZIER)
|
||||
return false ;
|
||||
|
||||
// riduco il grado della curva
|
||||
bool bOk = true ;
|
||||
PtrOwner<ICurveBezier> pCrvBezierNew ( BezierDecreaseDegree( GetCurveBezier( pCrv), dTol)) ;
|
||||
bOk = bOk && ! IsNull( pCrvBezierNew) && pCrvBezierNew->IsValid() ;
|
||||
Vector3d vtExtr ;
|
||||
if ( bOk && pCrv->GetExtrusion( vtExtr))
|
||||
pCrvBezierNew->SetExtrusion( vtExtr) ;
|
||||
double dThick = 0 ;
|
||||
if ( bOk && pCrv->GetThickness( dThick))
|
||||
pCrvBezierNew->SetThickness(dThick) ;
|
||||
// sostituisco la vecchia curva con la nuova
|
||||
bOk = bOk && pGeomDB->ReplaceGeoObj( nCrvId, Release( pCrvBezierNew)) ;
|
||||
ExeSetModified() ;
|
||||
|
||||
if ( IsCmdLog()) {
|
||||
string sLua = "EgtCurveBezierDecreaseDegree(" + ToString( nCrvId) + ")"
|
||||
" -- Ok=" + ToString( bOk) ;
|
||||
LOG_INFO( GetCmdLogger(), sLua.c_str()) ;
|
||||
}
|
||||
|
||||
return bOk ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
ExeCurveBezierApproxToNonRat( int nCrvId, double dTol)
|
||||
{
|
||||
IGeomDB* pGeomDB = GetCurrGeomDB() ;
|
||||
VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL)
|
||||
// recupero la curva
|
||||
const ICurve* pCrv = GetCurve( pGeomDB->GetGeoObj( nCrvId)) ;
|
||||
if ( pCrv == nullptr)
|
||||
return false ;
|
||||
//// recupero il riferimento della curva
|
||||
//Frame3d frCrv ;
|
||||
//if ( ! pGeomDB->GetGlobFrame( nCrvId, frCrv))
|
||||
// return GDB_ID_NULL ;
|
||||
|
||||
// controllo che il tipo sia giusto
|
||||
if( pCrv->GetType() != CRV_BEZIER) {
|
||||
if( pCrv->GetType() != CRV_COMPO)
|
||||
return false ;
|
||||
else {
|
||||
const ICurveComposite* pCC = GetCurveComposite( pCrv) ;
|
||||
for ( int i = 0 ; i < pCC->GetCurveCount() ; ++i) {
|
||||
const ICurve* pSubCrv = pCC->GetCurve( i) ;
|
||||
if( pSubCrv->GetType() != CRV_BEZIER)
|
||||
return false ;
|
||||
}
|
||||
}
|
||||
}
|
||||
bool bOk = true ;
|
||||
if( pCrv->GetType() == CRV_BEZIER) {
|
||||
const ICurveBezier* pCrvBez = GetCurveBezier( pCrv) ;
|
||||
if( ! pCrvBez->IsRational())
|
||||
return true ;
|
||||
|
||||
// approssimo la curva con una corrispettiva non razionale
|
||||
PtrOwner<ICurveBezier> pCrvBezierNew ( pCrvBez->Clone()) ;
|
||||
bOk = bOk && pCrvBezierNew->MakeNonRational( dTol) ;
|
||||
PtrOwner<ICurve> pCrvNew ;
|
||||
if ( ! bOk) {
|
||||
pCrvNew.Set( ApproxBezierWithCubics( pCrvBezierNew, dTol)) ;
|
||||
bOk = bOk && ! IsNull( pCrvNew) && pCrvNew->IsValid() ;
|
||||
}
|
||||
else
|
||||
pCrvNew.Set( Release( pCrvBezierNew)) ;
|
||||
bOk = bOk && ! IsNull( pCrvNew) && pCrvNew->IsValid() ;
|
||||
Vector3d vtExtr ;
|
||||
if ( bOk && pCrv->GetExtrusion( vtExtr))
|
||||
pCrvNew->SetExtrusion( vtExtr) ;
|
||||
double dThick = 0 ;
|
||||
if ( bOk && pCrv->GetThickness( dThick))
|
||||
pCrvNew->SetThickness(dThick) ;
|
||||
// sostituisco la vecchia curva con la nuova
|
||||
bOk = bOk && pGeomDB->ReplaceGeoObj( nCrvId, Release( pCrvNew)) ;
|
||||
}
|
||||
else {
|
||||
const ICurveComposite* pCC = GetCurveComposite( pCrv) ;
|
||||
PtrOwner<ICurveComposite> pCCNew( CreateCurveComposite()) ;
|
||||
for( int i = 0 ; i < pCC->GetCurveCount() ; ++i) {
|
||||
const ICurveBezier* pCrvBez = GetCurveBezier( pCC->GetCurve( i)) ;
|
||||
if( ! pCrvBez->IsRational()) {
|
||||
continue ;
|
||||
}
|
||||
|
||||
// approssimo la curva con una corrispettiva non razionale
|
||||
PtrOwner<ICurveBezier> pCrvBezierNew ( pCrvBez->Clone()) ;
|
||||
bOk = bOk && pCrvBezierNew->MakeNonRational( dTol) ;
|
||||
PtrOwner<ICurve> pCrvNew ;
|
||||
if ( ! bOk) {
|
||||
pCrvNew.Set( ApproxBezierWithCubics( pCrvBezierNew, dTol)) ;
|
||||
bOk = bOk && ! IsNull( pCrvNew) && pCrvNew->IsValid() ;
|
||||
}
|
||||
else
|
||||
pCrvNew.Set( Release( pCrvBezierNew)) ;
|
||||
bOk = bOk && ! IsNull( pCrvNew) && pCrvNew->IsValid() ;
|
||||
Vector3d vtExtr ;
|
||||
if ( bOk && pCrv->GetExtrusion( vtExtr))
|
||||
pCrvNew->SetExtrusion( vtExtr) ;
|
||||
double dThick = 0 ;
|
||||
if ( bOk && pCrv->GetThickness( dThick))
|
||||
pCrvNew->SetThickness(dThick) ;
|
||||
if( bOk)
|
||||
pCCNew->AddCurve( Release(pCrvNew)) ;
|
||||
else
|
||||
break ;
|
||||
}
|
||||
// sostituisco la vecchia curva con la nuova
|
||||
bOk = bOk && pGeomDB->ReplaceGeoObj( nCrvId, Release( pCCNew)) ;
|
||||
}
|
||||
ExeSetModified() ;
|
||||
|
||||
if ( IsCmdLog()) {
|
||||
string sLua = "EgtCurveBezierApproxToNonRat(" + ToString( nCrvId) + ", "
|
||||
+ ToString( dTol) + ")"
|
||||
" -- Ok=" + ToString( bOk) ;
|
||||
LOG_INFO( GetCmdLogger(), sLua.c_str()) ;
|
||||
}
|
||||
|
||||
return bOk ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
ExeCurveBezierApproxWithCubicBeziers( int nCrvId, double dTol)
|
||||
{
|
||||
IGeomDB* pGeomDB = GetCurrGeomDB() ;
|
||||
VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL)
|
||||
// recupero la curva
|
||||
const ICurve* pCrv = GetCurve( pGeomDB->GetGeoObj( nCrvId)) ;
|
||||
if ( pCrv == nullptr)
|
||||
return false ;
|
||||
|
||||
// controllo che il tipo sia giusto
|
||||
if( pCrv->GetType() != CRV_BEZIER) {
|
||||
if( pCrv->GetType() != CRV_COMPO)
|
||||
return false ;
|
||||
else {
|
||||
const ICurveComposite* pCC = GetCurveComposite( pCrv) ;
|
||||
for ( int i = 0 ; i < pCC->GetCurveCount() ; ++i) {
|
||||
const ICurve* pSubCrv = pCC->GetCurve( i) ;
|
||||
if( pSubCrv->GetType() != CRV_BEZIER)
|
||||
return false ;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// converto in bezier cubiche
|
||||
bool bOk = true ;
|
||||
if( pCrv->GetType() == CRV_BEZIER) {
|
||||
const ICurveBezier* pCrvBez = GetCurveBezier( pCrv) ;
|
||||
|
||||
// approssimo la curva con una serie di bezier
|
||||
PtrOwner<ICurve> pCrvBezierNew ( ApproxBezierWithCubics( pCrvBez, dTol)) ;
|
||||
bOk = bOk && ! IsNull( pCrvBezierNew) && pCrvBezierNew->IsValid() ;
|
||||
Vector3d vtExtr ;
|
||||
if ( bOk && pCrv->GetExtrusion( vtExtr))
|
||||
pCrvBezierNew->SetExtrusion( vtExtr) ;
|
||||
double dThick = 0 ;
|
||||
if ( bOk && pCrv->GetThickness( dThick))
|
||||
pCrvBezierNew->SetThickness(dThick) ;
|
||||
// sostituisco la vecchia curva con la nuova
|
||||
bOk = bOk && pGeomDB->ReplaceGeoObj( nCrvId, Release( pCrvBezierNew)) ;
|
||||
}
|
||||
else {
|
||||
const ICurveComposite* pCC = GetCurveComposite( pCrv) ;
|
||||
PtrOwner<ICurveComposite> pCCNew( CreateCurveComposite()) ;
|
||||
for( int i = 0 ; i < pCC->GetCurveCount() ; ++i) {
|
||||
const ICurveBezier* pCrvBez = GetCurveBezier( pCC->GetCurve( i)) ;
|
||||
if( ! pCrvBez->IsRational()) {
|
||||
continue ;
|
||||
}
|
||||
|
||||
// approssimo la curva con una serie di bezier
|
||||
PtrOwner<ICurve> pCrvBezierNew ( ApproxBezierWithCubics( pCrvBez, dTol)) ;
|
||||
bOk = bOk && ! IsNull( pCrvBezierNew) && pCrvBezierNew->IsValid() ;
|
||||
Vector3d vtExtr ;
|
||||
if ( bOk && pCrv->GetExtrusion( vtExtr))
|
||||
pCrvBezierNew->SetExtrusion( vtExtr) ;
|
||||
double dThick = 0 ;
|
||||
if ( bOk && pCrv->GetThickness( dThick))
|
||||
pCrvBezierNew->SetThickness(dThick) ;
|
||||
if( bOk)
|
||||
pCCNew->AddCurve( Release(pCrvBezierNew)) ;
|
||||
else
|
||||
break ;
|
||||
}
|
||||
// sostituisco la vecchia curva con la nuova
|
||||
bOk = bOk && pGeomDB->ReplaceGeoObj( nCrvId, Release( pCCNew)) ;
|
||||
}
|
||||
|
||||
ExeSetModified() ;
|
||||
|
||||
if ( IsCmdLog()) {
|
||||
string sLua = "EgtCurveBezierApproxWithCubicBeziers(" + ToString( nCrvId) + ", "
|
||||
+ ToString( dTol) + ")"
|
||||
" -- Ok=" + ToString( bOk) ;
|
||||
LOG_INFO( GetCmdLogger(), sLua.c_str()) ;
|
||||
}
|
||||
|
||||
return bOk ;
|
||||
}
|
||||
+132
-5
@@ -102,6 +102,33 @@ MyExplodeSurfTriMesh( int nId, int& nCount)
|
||||
// restituisco risultati
|
||||
return nFirstId ;
|
||||
}
|
||||
// recupero il numero di gusci
|
||||
int nShells = pStm->GetShellCount() ;
|
||||
// se ci sono più gusci, separo questi
|
||||
if ( nShells > 1) {
|
||||
int nFirstId = GDB_ID_NULL ;
|
||||
nCount = 0 ;
|
||||
for ( int i = 0 ; i < nShells ; ++ i) {
|
||||
ISurfTriMesh* pFac = pStm->CloneShell( i) ;
|
||||
if ( pFac == nullptr)
|
||||
continue ;
|
||||
// inserisco la superficie nello stesso gruppo e nello stesso posto del GeomDB
|
||||
int nNewId = pGeomDB->InsertGeoObj( GDB_ID_NULL, nId, GDB_BEFORE, pFac) ;
|
||||
if ( nNewId == GDB_ID_NULL)
|
||||
return GDB_ID_NULL ;
|
||||
// copio gli attributi
|
||||
if ( ! pGeomDB->CopyAttributes( nId, nNewId))
|
||||
return GDB_ID_NULL ;
|
||||
// aggiorno contatori
|
||||
if ( nFirstId == GDB_ID_NULL)
|
||||
nFirstId = nNewId ;
|
||||
++ nCount ;
|
||||
}
|
||||
// elimino la superficie originale
|
||||
pGeomDB->Erase( nId) ;
|
||||
// restituisco risultati
|
||||
return nFirstId ;
|
||||
}
|
||||
// recupero il numero di facce
|
||||
int nFacets = pStm->GetFacetCount() ;
|
||||
// se ci sono più facce, separo queste
|
||||
@@ -297,7 +324,7 @@ ExeSurfFrSubtract( int nId1, int nId2)
|
||||
// eseguo la sottrazione della seconda superficie dalla prima
|
||||
bOk = bOk && pSfr1->Subtract( *pSfr2L) ;
|
||||
// se il risultato è vuoto, cancello la FlatRegion
|
||||
if ( bOk && ! pSfr1->IsValid())
|
||||
if ( bOk && ! pSfr1->IsValid())
|
||||
pGeomDB->Erase( nId1) ;
|
||||
ExeSetModified() ;
|
||||
// se richiesto, salvo il comando Lua equivalente
|
||||
@@ -329,7 +356,7 @@ ExeSurfFrIntersect( int nId1, int nId2)
|
||||
// eseguo l'intersezione tra le due superfici
|
||||
bOk = bOk && pSfr1->Intersect( *pSfr2L) ;
|
||||
// se il risultato è vuoto, cancello la FlatRegion
|
||||
if ( bOk && ! pSfr1->IsValid())
|
||||
if ( bOk && ! pSfr1->IsValid())
|
||||
pGeomDB->Erase( nId1) ;
|
||||
ExeSetModified() ;
|
||||
// se richiesto, salvo il comando Lua equivalente
|
||||
@@ -354,7 +381,7 @@ ExeSurfFrOffset( int nId, double dDist, int nType)
|
||||
// eseguo l'offset
|
||||
bOk = bOk && pSfr->Offset( dDist, nType) ;
|
||||
// se il risultato è vuoto, cancello la FlatRegion
|
||||
if ( bOk && ! pSfr->IsValid())
|
||||
if ( bOk && ! pSfr->IsValid())
|
||||
pGeomDB->Erase( nId) ;
|
||||
ExeSetModified() ;
|
||||
// se richiesto, salvo il comando Lua equivalente
|
||||
@@ -373,7 +400,7 @@ bool
|
||||
ExeSurfFrOffsetAdv( int nId, double dDist, int nType, int& nNewId)
|
||||
{
|
||||
IGeomDB* pGeomDB = GetCurrGeomDB() ;
|
||||
VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL)
|
||||
VERIFY_GEOMDB( pGeomDB, false)
|
||||
// recupero la superficie FlatRegion
|
||||
ISurfFlatRegion* pSfr = GetSurfFlatRegion( pGeomDB->GetGeoObj( nId)) ;
|
||||
if ( pSfr == nullptr)
|
||||
@@ -394,6 +421,32 @@ ExeSurfFrOffsetAdv( int nId, double dDist, int nType, int& nNewId)
|
||||
return true ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
ExeSurfFrEraseChunk( int nId, int nChunk)
|
||||
{
|
||||
IGeomDB* pGeomDB = GetCurrGeomDB() ;
|
||||
VERIFY_GEOMDB( pGeomDB, false)
|
||||
// recupero la superficie FlatRegion
|
||||
ISurfFlatRegion* pSfr = GetSurfFlatRegion( pGeomDB->GetGeoObj( nId)) ;
|
||||
if ( pSfr == nullptr)
|
||||
return false ;
|
||||
// elimino il chunk indicato
|
||||
bool bOk = pSfr->EraseChunk( nChunk) ;
|
||||
// se il risultato è vuoto, cancello la FlatRegion
|
||||
if ( bOk && ! pSfr->IsValid())
|
||||
pGeomDB->Erase( nId) ;
|
||||
ExeSetModified() ;
|
||||
// se richiesto, salvo il comando Lua equivalente
|
||||
if ( IsCmdLog()) {
|
||||
string sLua = "EgtSurfFrEraseChunk(" + ToString( nId) + "," +
|
||||
ToString( nChunk) + ")" +
|
||||
" -- Ok=" + ToString( bOk) ;
|
||||
LOG_INFO( GetCmdLogger(), sLua.c_str()) ;
|
||||
}
|
||||
return bOk ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
ExeSurfFrMoveSimpleNoCollision( int nId1, int nId2, const Vector3d& vtDir, double& dLen, int nRefType)
|
||||
@@ -1074,6 +1127,45 @@ ExeSurfTmSubtractProjectedFacesOnFace( int nSurfId, int nFaceInd, int nDestGrpId
|
||||
return bOk ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
ExeSurfTmSetFaceColor( int nId, int nFacet, int nColor)
|
||||
{
|
||||
IGeomDB* pGeomDB = GetCurrGeomDB() ;
|
||||
VERIFY_GEOMDB( pGeomDB, false)
|
||||
// recupero la superficie TriMesh
|
||||
ISurfTriMesh* pStm = GetSurfTriMesh( pGeomDB->GetGeoObj( nId)) ;
|
||||
bool bOk = ( pStm != nullptr) ;
|
||||
// recupero tutti i triangoli della faccia e imposto il flag opportuno per il colore
|
||||
INTVECTOR vTria ;
|
||||
bOk = bOk && pStm->GetAllTriaInFacet( nFacet, vTria) ;
|
||||
for ( const auto nT : vTria)
|
||||
pStm->SetTFlag( nT, nColor) ;
|
||||
ExeSetModified() ;
|
||||
// se richiesto, salvo il comando Lua equivalente
|
||||
if ( IsCmdLog()) {
|
||||
string sLua = "EgtSurfTmSetFaceColor(" + ToString( nId) + "," +
|
||||
ToString( nFacet) + "," +
|
||||
ToString( nColor) + ")" +
|
||||
" -- Ok=" + ToString( bOk) ;
|
||||
LOG_INFO( GetCmdLogger(), sLua.c_str()) ;
|
||||
}
|
||||
return bOk ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
ExeSurfTmGetTriaColor( int nId, int nTria, int& nColor)
|
||||
{
|
||||
IGeomDB* pGeomDB = GetCurrGeomDB() ;
|
||||
VERIFY_GEOMDB( pGeomDB, false)
|
||||
// recupero la superficie TriMesh
|
||||
ISurfTriMesh* pStm = GetSurfTriMesh( pGeomDB->GetGeoObj( nId)) ;
|
||||
bool bOk = ( pStm != nullptr) ;
|
||||
// recupero il colore del triangolo
|
||||
return ( bOk && pStm->GetTFlag( nTria, nColor)) ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
ExeSurfTmResetTwoColors( int nId)
|
||||
@@ -1118,6 +1210,20 @@ ExeSurfTmSetShowEdges( int nId, bool bShow)
|
||||
return bOk ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
ExeSurfTmGetShowEdges( int nId, bool& bShow)
|
||||
{
|
||||
IGeomDB* pGeomDB = GetCurrGeomDB() ;
|
||||
VERIFY_GEOMDB( pGeomDB, false)
|
||||
// recupero la superficie trimesh
|
||||
ISurfTriMesh* pStm = GetSurfTriMesh( pGeomDB->GetGeoObj( nId)) ;
|
||||
bool bOk = ( pStm != nullptr) ;
|
||||
// recupero lo stato di visualizzazione degli spigoli vivi
|
||||
bShow = ( bOk && pStm->GetShowEdges()) ;
|
||||
return bOk ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
static bool
|
||||
MySurfBzTrim( int nId, int nTrimmerId)
|
||||
@@ -1154,10 +1260,31 @@ ExeSurfBzTrim( int nId, int nCutterId)
|
||||
ExeSetModified() ;
|
||||
// se richiesto, salvo il comando Lua equivalente
|
||||
if ( IsCmdLog()) {
|
||||
string sLua = "EgtSurfTmCut(" + ToString( nId) + "," +
|
||||
string sLua = "EgtSurfBzCut(" + ToString( nId) + "," +
|
||||
ToString( nCutterId) + "," +
|
||||
" -- Ok=" + ToString( bOk) ;
|
||||
LOG_INFO( GetCmdLogger(), sLua.c_str()) ;
|
||||
}
|
||||
return bOk ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
ExeSurfTmSetSmoothAng( int nId, double dAngDeg)
|
||||
{
|
||||
IGeomDB* pGeomDB = GetCurrGeomDB() ;
|
||||
VERIFY_GEOMDB( pGeomDB, false)
|
||||
// recupero la superficie trimseh da trimmare
|
||||
ISurfTriMesh* pSrfTm = GetSurfTriMesh( pGeomDB->GetGeoObj( nId)) ;
|
||||
if ( pSrfTm == nullptr)
|
||||
return false ;
|
||||
pSrfTm->SetSmoothAngle( dAngDeg) ;
|
||||
ExeSetModified() ;
|
||||
// se richiesto, salvo il comando Lua equivalente
|
||||
if ( IsCmdLog()) {
|
||||
string sLua = "EgtSurfTmSetSmoothAng(" + ToString( nId) + "," +
|
||||
ToString( dAngDeg) ;
|
||||
LOG_INFO( GetCmdLogger(), sLua.c_str()) ;
|
||||
}
|
||||
return true ;
|
||||
}
|
||||
|
||||
@@ -337,6 +337,34 @@ ExeVolZmapSetChiselTool( const INTVECTOR& vIds, const string& sToolName,
|
||||
return bOk ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
ExeVolZmapSetAdditiveTool( const INTVECTOR& vIds, const string& sToolName,
|
||||
double dLen, double dDiam, double dCornR, int nFlag, bool bFirst)
|
||||
{
|
||||
IGeomDB* pGeomDB = GetCurrGeomDB() ;
|
||||
VERIFY_GEOMDB( pGeomDB, false)
|
||||
// recupero gli Zmap e assegno i dati dell'utensile
|
||||
bool bOk = true ;
|
||||
for ( int i = 0 ; i < int( vIds.size()) ; ++ i) {
|
||||
IVolZmap* pVZM = GetVolZmap( pGeomDB->GetGeoObj( vIds[i])) ;
|
||||
bOk = ( bOk && pVZM != nullptr && pVZM->SetAdditiveTool( sToolName, dLen, dDiam / 2, dCornR, nFlag, bFirst)) ;
|
||||
}
|
||||
// se richiesto, salvo il comando Lua equivalente
|
||||
if ( IsCmdLog()) {
|
||||
string sLua = "EgtVolZmapSetAdditiveTool({" + IdListToString( vIds) + "}," +
|
||||
sToolName + "," +
|
||||
ToString( dLen) + "," +
|
||||
ToString( dDiam) + "," +
|
||||
ToString( dCornR) + "," +
|
||||
ToString( nFlag) + ")" +
|
||||
" -- Ok=" + ToString( bOk) ;
|
||||
LOG_INFO( GetCmdLogger(), sLua.c_str()) ;
|
||||
}
|
||||
// restituisco risultato
|
||||
return bOk ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
ExeVolZmapResetTools( const INTVECTOR& vIds)
|
||||
|
||||
@@ -232,12 +232,12 @@ ExeGetCalcStatus( int nId, int* pnStat)
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
bool
|
||||
ExeSetMark( int nId)
|
||||
ExeSetMark( int nId, int nMark)
|
||||
{
|
||||
IGeomDB* pGeomDB = GetCurrGeomDB() ;
|
||||
VERIFY_GEOMDB( pGeomDB, false)
|
||||
// imposto l'evidenziazione
|
||||
bool bOk = pGeomDB->SetMark( nId) ;
|
||||
bool bOk = pGeomDB->SetMark( nId, nMark) ;
|
||||
// non produce modifica perchè mark ignorato in salvataggio
|
||||
return bOk ;
|
||||
}
|
||||
|
||||
@@ -35,6 +35,7 @@
|
||||
#include "/EgtDev/Include/EgtIniFile.h"
|
||||
#include "/EgtDev/Include/EgtLogger.h"
|
||||
#include "/EgtDev/Include/EgtStringConverter.h"
|
||||
#include "/EgtDev/Include/EgtKeyCodes.h"
|
||||
#include "/EgtDev/Include/SELkLockId.h"
|
||||
#include "/EgtDev/Include/SELkKeyProc.h"
|
||||
#include <fstream>
|
||||
@@ -352,6 +353,34 @@ ExeGetNetHwKey( void)
|
||||
return s_bNetHwKey ;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
bool
|
||||
ExeVerifyKeyOption( int nOptInd)
|
||||
{
|
||||
// recupero le opzioni abilitate
|
||||
unsigned int nOpt1, nOpt2 ;
|
||||
int nOptExpDays ;
|
||||
int nRet = GetEGnKeyOptions( KEY_BASELIB_PROD, KEY_BASELIB_VER, KEY_BASELIB_LEV,
|
||||
nOpt1, nOpt2, nOptExpDays) ;
|
||||
if ( ! ExeGetNetHwKey())
|
||||
nRet = GetKeyOptions( ExeGetKey(), KEY_BASELIB_PROD, KEY_BASELIB_VER, KEY_BASELIB_LEV,
|
||||
nOpt1, nOpt2, nOptExpDays) ;
|
||||
// verifico validità chiave con licenza
|
||||
if ( nRet != KEY_OK || nOptExpDays < GetCurrDay())
|
||||
return false ;
|
||||
// verifico le opzioni (nOptInd = 100 -> bit 0 di Opt1 ... = 200 -> bit 0 di Opt2 ... = 231 -> bit 31 di Opt2)
|
||||
if ( nOptInd >= 100 && nOptInd <= 131) {
|
||||
unsigned int nOptVal = ( 1 << ( nOptInd - 100)) ;
|
||||
return ( ( nOpt1 & nOptVal) != 0) ;
|
||||
}
|
||||
else if ( nOptInd >= 200 && nOptInd <= 231) {
|
||||
unsigned int nOptVal = ( 1 << ( nOptInd - 200)) ;
|
||||
return ( ( nOpt2 & nOptVal) != 0) ;
|
||||
}
|
||||
else
|
||||
return false ;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
bool
|
||||
ExeSetFont( const string& sNfeFontDir, const string& sDefaultFont)
|
||||
|
||||
+40
-3
@@ -21,9 +21,11 @@
|
||||
#include "/EgtDev/Include/EXeExecutor.h"
|
||||
#include "/EgtDev/Include/EXeConst.h"
|
||||
#include "/EgtDev/Include/EGkStringUtils3d.h"
|
||||
#include "/EgtDev/Include/EMkToolConst.h"
|
||||
#include "/EgtDev/Include/EMkOperationConst.h"
|
||||
#include "/EgtDev/Include/EMkSimuGenConst.h"
|
||||
#include "/EgtDev/Include/EGnFileUtils.h"
|
||||
#include "/EgtDev/Include/EGnEgtUUID.h"
|
||||
#include "/EgtDev/Include/EgtStringConverter.h"
|
||||
#include "/EgtDev/Include/EgtPointerOwner.h"
|
||||
|
||||
@@ -1472,6 +1474,21 @@ ExeTdbGetCurrToolThLength( double& dThLen)
|
||||
return pMachMgr->TdbGetCurrToolThLength( dThLen) ;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
bool
|
||||
ExeTdbCurrToolIsStandardDraw( bool& bStandard)
|
||||
{
|
||||
IMachMgr* pMachMgr = GetCurrMachMgr() ;
|
||||
VERIFY_MACHMGR( pMachMgr, false)
|
||||
// recupero il nome del disegno dell'utensile
|
||||
string sDraw ;
|
||||
if ( ! pMachMgr->TdbGetCurrToolParam( TPA_DRAW, sDraw))
|
||||
return false ;
|
||||
// verifico il tipo
|
||||
bStandard = IsUUID( GetFileTitleEgt( sDraw)) ;
|
||||
return true ;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
int
|
||||
ExeTdbCurrToolDraw( int nGenCtx, int nToolCtx)
|
||||
@@ -2634,12 +2651,22 @@ ExeRemovePreviewMachiningTool( void)
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
int
|
||||
ExePreviewMachiningTool( int nEntId, int nFlag)
|
||||
ExeGetPreviewMachiningToolStepCount( void)
|
||||
{
|
||||
IMachMgr* pMachMgr = GetCurrMachMgr() ;
|
||||
VERIFY_MACHMGR( pMachMgr, false)
|
||||
VERIFY_MACHMGR( pMachMgr, -1)
|
||||
// restituisce il numero di passi per anteprima utensile presenti nella lavorazione
|
||||
return pMachMgr->GetPreviewMachiningToolStepCount() ;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
int
|
||||
ExePreviewMachiningTool( int nEntId, int nStep)
|
||||
{
|
||||
IMachMgr* pMachMgr = GetCurrMachMgr() ;
|
||||
VERIFY_MACHMGR( pMachMgr, GDB_ID_NULL)
|
||||
// visualizzazione anteprima utensile su lavorazione
|
||||
return pMachMgr->PreviewMachiningTool( nEntId, nFlag) ;
|
||||
return pMachMgr->PreviewMachiningTool( nEntId, nStep) ;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
@@ -3421,6 +3448,16 @@ ExeGetHeadExitCount( const string& sHead)
|
||||
return pMachMgr->GetHeadExitCount( sHead) ;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
int
|
||||
ExeGetExitId( const string& sHead, int nExit)
|
||||
{
|
||||
IMachMgr* pMachMgr = GetCurrMachMgr() ;
|
||||
VERIFY_MACHMGR( pMachMgr, GDB_ID_NULL)
|
||||
// restituisco identificativo dell'uscita della testa indicata nella macchina della macchinata corrente
|
||||
return pMachMgr->GetExitId( sHead, nExit) ;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
int
|
||||
ExeGetTcPosId( const string& sTcPos)
|
||||
|
||||
+2
-2
@@ -109,12 +109,12 @@ ExeSetLineAttribs( int nWidth)
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
bool
|
||||
ExeSetMarkAttribs( Color MarkCol)
|
||||
ExeSetMarkAttribs( Color MarkCol, Color Mark2Col)
|
||||
{
|
||||
IEGrScene* pScene = GetCurrScene() ;
|
||||
VERIFY_SCENE( pScene, false)
|
||||
// imposto il colore del Mark
|
||||
return pScene->SetMark( MarkCol) ;
|
||||
return ( pScene->SetMark( MarkCol) && pScene->SetMark2( Mark2Col)) ;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
Binary file not shown.
@@ -425,6 +425,34 @@ LuaCreateArc3P( lua_State* L)
|
||||
return 1 ;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------
|
||||
static int
|
||||
LuaCreateArc2PR( lua_State* L)
|
||||
{
|
||||
// 5 o 6 parametri : ParentId, PtStart, PtEnd, dRad, bCCW [, nRefType]
|
||||
int nParentId ;
|
||||
LuaCheckParam( L, 1, nParentId)
|
||||
Point3d ptStart ;
|
||||
LuaCheckParam( L, 2, ptStart)
|
||||
Point3d ptEnd ;
|
||||
LuaCheckParam( L, 3, ptEnd)
|
||||
double dRad ;
|
||||
LuaCheckParam( L, 4, dRad)
|
||||
bool bCCW ;
|
||||
LuaCheckParam( L, 5, bCCW) ;
|
||||
int nRefType = RTY_DEFAULT ;
|
||||
LuaGetParam( L, 6, nRefType) ;
|
||||
LuaClearStack( L) ;
|
||||
// creo l'arco
|
||||
int nId = ExeCreateArc2PR( nParentId, ptStart, ptEnd, dRad, bCCW, nRefType) ;
|
||||
// restituisco il risultato
|
||||
if ( nId != GDB_ID_NULL)
|
||||
LuaSetParam( L, nId) ;
|
||||
else
|
||||
LuaSetParam( L) ;
|
||||
return 1 ;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------
|
||||
static int
|
||||
LuaCreateArc2PB( lua_State* L)
|
||||
@@ -1063,6 +1091,27 @@ LuaCreateCirclesAlongCurve( lua_State* L)
|
||||
return 2 ;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------
|
||||
static int
|
||||
LuaCreateCurveBezierForm( lua_State* L)
|
||||
{
|
||||
// 2 o 3 parametri : ParentId, nCrvId [, nDeg]
|
||||
int nParentId ;
|
||||
LuaCheckParam( L, 1, nParentId)
|
||||
int nCrvId ;
|
||||
LuaCheckParam( L, 2, nCrvId)
|
||||
int nDeg = 3 ;
|
||||
LuaGetParam( L, 3, nDeg) ;
|
||||
// creo la versione bezier della curva
|
||||
int nId = ExeCreateCurveBezierForm( nParentId, nCrvId, nDeg) ;
|
||||
// restituisco il risultato
|
||||
if ( nId != GDB_ID_NULL)
|
||||
LuaSetParam( L, nId) ;
|
||||
else
|
||||
LuaSetParam( L) ;
|
||||
return 1 ;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------
|
||||
bool
|
||||
LuaInstallGdbCreateCurve( LuaMgr& luaMgr)
|
||||
@@ -1083,6 +1132,7 @@ LuaInstallGdbCreateCurve( LuaMgr& luaMgr)
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtArcC2P", LuaCreateArcC2P) ;
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtArcC2PEx", LuaCreateArcC2PEx) ;
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtArc3P", LuaCreateArc3P) ;
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtArc2PR", LuaCreateArc2PR) ;
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtArc2PB", LuaCreateArc2PB) ;
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtArc2PD", LuaCreateArc2PD) ;
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtArc2PDEx", LuaCreateArc2PDEx) ;
|
||||
@@ -1106,5 +1156,6 @@ LuaInstallGdbCreateCurve( LuaMgr& luaMgr)
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtPolygonFromApothem", LuaCreatePolygonFromApothem) ;
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtPolygonFromSide", LuaCreatePolygonFromSide) ;
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtCirclesAlongCurve", LuaCreateCirclesAlongCurve) ;
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtCurveBezierForm", LuaCreateCurveBezierForm) ;
|
||||
return bOk ;
|
||||
}
|
||||
|
||||
+315
-1
@@ -977,6 +977,310 @@ LuaCreateBezierSphere( lua_State* L)
|
||||
return 2 ;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------
|
||||
static int
|
||||
LuaCreateSurfBzByFlatContour( lua_State* L)
|
||||
{
|
||||
// 2 o 3 parametri : ParentId, CrvId [, dTol]
|
||||
int nParentId ;
|
||||
LuaCheckParam( L, 1, nParentId)
|
||||
int nCrvId ;
|
||||
LuaCheckParam( L, 2, nCrvId)
|
||||
double dLinTol = LIN_TOL_SRF ;
|
||||
if ( lua_gettop( L) >= 3)
|
||||
LuaCheckParam( L, 3, dLinTol) ;
|
||||
LuaClearStack( L) ;
|
||||
// creo Sbz piana e la trimmo con il contorno
|
||||
int nId = ExeCreateSurfBzByFlatContour( nParentId, nCrvId, dLinTol) ;
|
||||
// restituisco il risultato
|
||||
if ( nId != GDB_ID_NULL)
|
||||
LuaSetParam( L, nId) ;
|
||||
else
|
||||
LuaSetParam( L) ;
|
||||
return 1 ;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------
|
||||
static int
|
||||
LuaCreateSurfBzByRegion( lua_State* L)
|
||||
{
|
||||
// 2 o 3 parametri : ParentId, CrvIds [, dTol]
|
||||
int nParentId ;
|
||||
LuaCheckParam( L, 1, nParentId)
|
||||
INTVECTOR vCrvIds ;
|
||||
LuaCheckParam( L, 2, vCrvIds)
|
||||
double dLinTol = LIN_TOL_SRF ;
|
||||
if ( lua_gettop( L) >= 3)
|
||||
LuaCheckParam( L, 3, dLinTol) ;
|
||||
LuaClearStack( L) ;
|
||||
// creo una Sbz piana a cui aggiungo le curve come trim
|
||||
int nId = ExeCreateSurfBzByRegion( nParentId, vCrvIds, dLinTol) ;
|
||||
// restituisco il risultato
|
||||
if ( nId != GDB_ID_NULL)
|
||||
LuaSetParam( L, nId) ;
|
||||
else
|
||||
LuaSetParam( L) ;
|
||||
return 1 ;
|
||||
}
|
||||
|
||||
|
||||
//-------------------------------------------------------------------------------
|
||||
static int
|
||||
LuaCreateSurfBzByExtrusion( lua_State* L)
|
||||
{
|
||||
// 3 o 4 o 5 o 6 parametri : ParentId, CrvId, vtExtr [, bool bCapEnds] [, dTol] [, nRefType]
|
||||
int nParentId ;
|
||||
LuaCheckParam( L, 1, nParentId)
|
||||
int nCrvId ;
|
||||
LuaCheckParam( L, 2, nCrvId)
|
||||
Vector3d vtExtr ;
|
||||
LuaCheckParam( L, 3, vtExtr)
|
||||
bool bCapEnds = false ;
|
||||
int nPar = 4 ;
|
||||
if ( LuaGetParam( L, nPar, bCapEnds))
|
||||
++ nPar ;
|
||||
double dLinTol = LIN_TOL_SRF ;
|
||||
if ( LuaGetParam( L, nPar, dLinTol))
|
||||
++ nPar ;
|
||||
int nRefType = RTY_DEFAULT ;
|
||||
LuaGetParam( L, nPar, nRefType) ;
|
||||
LuaClearStack( L) ;
|
||||
// creo STM estrudendo uno o più percorsi, se piani si possono mettere i tappi
|
||||
int nId = ExeCreateSurfBzByExtrusion( nParentId, nCrvId, vtExtr, bCapEnds, dLinTol, nRefType) ;
|
||||
// restituisco il risultato
|
||||
if ( nId != GDB_ID_NULL)
|
||||
LuaSetParam( L, nId) ;
|
||||
else
|
||||
LuaSetParam( L) ;
|
||||
return 1 ;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------
|
||||
static int
|
||||
LuaCreateSurfBzByRegionExtrusion( lua_State* L)
|
||||
{
|
||||
// 3 o 4 o 5 o 6 parametri : ParentId, CrvIds, vtExtr [, bool bCapEnds] [, dTol] [, nRefType]
|
||||
int nParentId ;
|
||||
LuaCheckParam( L, 1, nParentId)
|
||||
INTVECTOR vCrvIds ;
|
||||
LuaCheckParam( L, 2, vCrvIds)
|
||||
Vector3d vtExtr ;
|
||||
LuaCheckParam( L, 3, vtExtr)
|
||||
bool bCapEnds = false ;
|
||||
int nPar = 4 ;
|
||||
if ( LuaGetParam( L, nPar, bCapEnds))
|
||||
++ nPar ;
|
||||
double dLinTol = LIN_TOL_SRF ;
|
||||
if ( LuaGetParam( L, nPar, dLinTol))
|
||||
++ nPar ;
|
||||
int nRefType = RTY_DEFAULT ;
|
||||
LuaGetParam( L, nPar, nRefType) ;
|
||||
LuaClearStack( L) ;
|
||||
// creo STM estrudendo uno o più percorsi, se piani si possono mettere i tappi
|
||||
int nId = ExeCreateSurfBzByRegionExtrusion( nParentId, vCrvIds, vtExtr, bCapEnds, dLinTol, nRefType) ;
|
||||
// restituisco il risultato
|
||||
if ( nId != GDB_ID_NULL)
|
||||
LuaSetParam( L, nId) ;
|
||||
else
|
||||
LuaSetParam( L) ;
|
||||
return 1 ;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------
|
||||
static int
|
||||
LuaCreateSurfBzByScrewing( lua_State* L)
|
||||
{
|
||||
// 6 o 7 o 8 o 9 parametri : ParentId, CrvId, ptAx, vtAx, dAngRotDeg, dMove [, bCapEnds] [, dTol] [, nRefType]
|
||||
int nParentId ;
|
||||
LuaCheckParam( L, 1, nParentId)
|
||||
int nCrvId ;
|
||||
LuaCheckParam( L, 2, nCrvId)
|
||||
Point3d ptAx ;
|
||||
LuaCheckParam( L, 3, ptAx)
|
||||
Vector3d vtAx ;
|
||||
LuaCheckParam( L, 4, vtAx)
|
||||
double dAngRotDeg ;
|
||||
LuaCheckParam( L, 5, dAngRotDeg)
|
||||
double dMove ;
|
||||
LuaCheckParam( L, 6, dMove)
|
||||
int nPar = 7 ;
|
||||
bool bCapEnds = false ;
|
||||
if ( LuaGetParam( L, nPar, bCapEnds))
|
||||
++ nPar ;
|
||||
double dLinTol = LIN_TOL_SRF ;
|
||||
if ( LuaGetParam( L, nPar, dLinTol))
|
||||
++ nPar ;
|
||||
int nRefType = RTY_DEFAULT ;
|
||||
if ( LuaGetParam( L, nPar, nRefType))
|
||||
++ nPar ;
|
||||
LuaClearStack( L) ;
|
||||
// creo STM riempiendo un contorno piano
|
||||
int nId = ExeCreateSurfBzByScrewing( nParentId, nCrvId, ptAx, vtAx, dAngRotDeg, dMove, bCapEnds, dLinTol, nRefType) ;
|
||||
// restituisco il risultato
|
||||
if ( nId != GDB_ID_NULL)
|
||||
LuaSetParam( L, nId) ;
|
||||
else
|
||||
LuaSetParam( L) ;
|
||||
return 1 ;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------
|
||||
static int
|
||||
LuaCreateSurfBzByRevolve( lua_State* L)
|
||||
{
|
||||
// 4 o 5 o 6 o 7 parametri : ParentId, CrvId, ptAx, vtAx [, bCapEnds] [, dTol] [, nRefType]
|
||||
int nParentId ;
|
||||
LuaCheckParam( L, 1, nParentId)
|
||||
int nCrvId ;
|
||||
LuaCheckParam( L, 2, nCrvId)
|
||||
Point3d ptAx ;
|
||||
LuaCheckParam( L, 3, ptAx)
|
||||
Vector3d vtAx ;
|
||||
LuaCheckParam( L, 4, vtAx)
|
||||
int nPar = 5 ;
|
||||
bool bCapEnds = false ;
|
||||
if ( LuaGetParam( L, nPar, bCapEnds))
|
||||
++ nPar ;
|
||||
double dLinTol = LIN_TOL_SRF ;
|
||||
if ( LuaGetParam( L, nPar, dLinTol))
|
||||
++ nPar ;
|
||||
int nRefType = RTY_DEFAULT ;
|
||||
if ( LuaGetParam( L, nPar, nRefType))
|
||||
++ nPar ;
|
||||
LuaClearStack( L) ;
|
||||
// creo STM riempiendo un contorno piano
|
||||
int nId = ExeCreateSurfBzByRevolve( nParentId, nCrvId, ptAx, vtAx, bCapEnds, dLinTol, nRefType) ;
|
||||
// restituisco il risultato
|
||||
if ( nId != GDB_ID_NULL)
|
||||
LuaSetParam( L, nId) ;
|
||||
else
|
||||
LuaSetParam( L) ;
|
||||
return 1 ;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------
|
||||
static int
|
||||
LuaCreateSurfBzByPointCurve( lua_State* L)
|
||||
{
|
||||
// 4 o 5 o 6 o 7 parametri : ParentId, CrvId, ptAx, vtAx [, bCapEnds] [, dTol] [, nRefType]
|
||||
int nParentId ;
|
||||
LuaCheckParam( L, 1, nParentId)
|
||||
int nCrvId ;
|
||||
LuaCheckParam( L, 2, nCrvId)
|
||||
Point3d ptTop ;
|
||||
LuaCheckParam( L, 3, ptTop)
|
||||
int nPar = 4 ;
|
||||
bool bCapEnds = false ;
|
||||
if ( LuaGetParam( L, nPar, bCapEnds))
|
||||
++ nPar ;
|
||||
double dLinTol = LIN_TOL_SRF ;
|
||||
if ( LuaGetParam( L, nPar, dLinTol))
|
||||
++ nPar ;
|
||||
int nRefType = RTY_DEFAULT ;
|
||||
if ( LuaGetParam( L, nPar, nRefType))
|
||||
++ nPar ;
|
||||
LuaClearStack( L) ;
|
||||
// creo STM riempiendo un contorno piano
|
||||
int nId = ExeCreateSurfBzByPointCurve( nParentId, nCrvId, ptTop, bCapEnds, dLinTol, nRefType) ;
|
||||
// restituisco il risultato
|
||||
if ( nId != GDB_ID_NULL)
|
||||
LuaSetParam( L, nId) ;
|
||||
else
|
||||
LuaSetParam( L) ;
|
||||
return 1 ;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------
|
||||
static int
|
||||
LuaCreateSurfBzRuled( lua_State* L)
|
||||
{
|
||||
// 4 o 5 o 6 parametri : ParentId, CrvId1, CrvId2, nRuledType [, bCapEnds] [, dTol]
|
||||
int nParentId ;
|
||||
LuaCheckParam( L, 1, nParentId)
|
||||
int nCrvId1 ;
|
||||
LuaCheckParam( L, 2, nCrvId1)
|
||||
int nCrvId2 ;
|
||||
LuaCheckParam( L, 3, nCrvId2)
|
||||
int nRuledType ;
|
||||
LuaCheckParam( L, 4, nRuledType)
|
||||
bool bCapEnds = false ;
|
||||
int nPar = 5 ;
|
||||
if ( LuaGetParam( L, nPar, bCapEnds))
|
||||
++ nPar ;
|
||||
double dLinTol = LIN_TOL_SRF ;
|
||||
LuaGetParam( L, nPar, dLinTol) ;
|
||||
LuaClearStack( L) ;
|
||||
// creo STM riempiendo un contorno piano
|
||||
int nId = ExeCreateSurfBzRuled( nParentId, nCrvId1, nCrvId2, nRuledType, bCapEnds, dLinTol) ;
|
||||
// restituisco il risultato
|
||||
if ( nId != GDB_ID_NULL)
|
||||
LuaSetParam( L, nId) ;
|
||||
else
|
||||
LuaSetParam( L) ;
|
||||
return 1 ;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------
|
||||
static int
|
||||
LuaCreateSurfBzSkinned( lua_State* L)
|
||||
{
|
||||
// 2 o 3 o 4 parametri : ParentId, vCrvIds [, bCapEnds] [, dTol]
|
||||
int nParentId ;
|
||||
LuaCheckParam( L, 1, nParentId)
|
||||
INTVECTOR vCrvIds ;
|
||||
LuaCheckParam( L, 2, vCrvIds)
|
||||
bool bCapEnds = false ;
|
||||
int nPar = 3 ;
|
||||
if ( LuaGetParam( L, nPar, bCapEnds))
|
||||
++ nPar ;
|
||||
double dLinTol = LIN_TOL_SRF ;
|
||||
LuaGetParam( L, nPar, dLinTol) ;
|
||||
LuaClearStack( L) ;
|
||||
// creo STM riempiendo un contorno piano
|
||||
int nId = ExeCreateSurfBzSkinned( nParentId, vCrvIds, bCapEnds, dLinTol) ;
|
||||
// restituisco il risultato
|
||||
if ( nId != GDB_ID_NULL)
|
||||
LuaSetParam( L, nId) ;
|
||||
else
|
||||
LuaSetParam( L) ;
|
||||
return 1 ;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------
|
||||
static int
|
||||
LuaCreateSurfBzSwept( lua_State* L)
|
||||
{
|
||||
// 3 o 4 o 5 o 6 o 7 parametri : ParentId, nSectCrvId, nGuideCrvId [, vtAx] [, bCapEnds] [, dTol] [, nRefType]
|
||||
int nParentId ;
|
||||
LuaCheckParam( L, 1, nParentId)
|
||||
int nSectId ;
|
||||
LuaCheckParam( L, 2, nSectId)
|
||||
int nGuideId ;
|
||||
LuaCheckParam( L, 3, nGuideId)
|
||||
Vector3d vtAx = V_NULL ;
|
||||
int nPar = 4 ;
|
||||
if ( LuaGetParam( L, nPar, vtAx))
|
||||
++ nPar ;
|
||||
bool bCapEnds = false ;
|
||||
if ( LuaGetParam( L, nPar, bCapEnds))
|
||||
++ nPar ;
|
||||
double dLinTol = LIN_TOL_SRF ;
|
||||
if ( LuaGetParam( L, nPar, dLinTol))
|
||||
++ nPar ;
|
||||
int nRefType = RTY_DEFAULT ;
|
||||
if ( LuaGetParam( L, nPar, dLinTol))
|
||||
++ nPar ;
|
||||
LuaClearStack( L) ;
|
||||
// creo STM riempiendo un contorno piano
|
||||
int nId = ExeCreateSurfBzSwept( nParentId, nSectId, nGuideId, vtAx, bCapEnds, dLinTol, nRefType) ;
|
||||
// restituisco il risultato
|
||||
if ( nId != GDB_ID_NULL)
|
||||
LuaSetParam( L, nId) ;
|
||||
else
|
||||
LuaSetParam( L) ;
|
||||
return 1 ;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------
|
||||
bool
|
||||
LuaInstallGdbCreateSurf( LuaMgr& luaMgr)
|
||||
@@ -1015,6 +1319,16 @@ LuaInstallGdbCreateSurf( LuaMgr& luaMgr)
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtSurfBezierRat", LuaCreateSurfBezierRational) ;
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtSurfBezierLeaves", LuaCreateSurfBezierLeaves) ;
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtSurfBezierTria2D", LuaCreateSurfBezierTria2D) ;
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtCreateBezierSphere", LuaCreateBezierSphere) ;
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtSurfBzSphere", LuaCreateBezierSphere) ;
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtSurfBzByFlatContour", LuaCreateSurfBzByFlatContour) ;
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtSurfBzByRegion", LuaCreateSurfBzByRegion) ;
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtSurfBzByExtrusion", LuaCreateSurfBzByExtrusion) ;
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtSurfBzByRegionExtrusion", LuaCreateSurfBzByRegionExtrusion) ;
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtSurfBzByScrewing", LuaCreateSurfBzByScrewing) ;
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtSurfBzByRevolve", LuaCreateSurfBzByRevolve) ;
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtSurfBzByPointCurve", LuaCreateSurfBzByPointCurve) ;
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtSurfBzRuled", LuaCreateSurfBzRuled) ;
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtSurfBzSkinned", LuaCreateSurfBzSkinned) ;
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtSurfBzSwept", LuaCreateSurfBzSwept) ;
|
||||
return bOk ;
|
||||
}
|
||||
|
||||
@@ -54,6 +54,42 @@ LuaCreateVolZmapBox( lua_State* L)
|
||||
return 1 ;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------
|
||||
static int
|
||||
LuaCreateVolZmapEmpty( lua_State* L)
|
||||
{
|
||||
// 6 o 7 o 8 parametri : ParentId, PtIni, dDimX, dDimY, dDimZ, dPrec [, bTriDex] [, nRefType]
|
||||
int nParentId ;
|
||||
LuaCheckParam( L, 1, nParentId)
|
||||
Point3d ptIni ;
|
||||
LuaCheckParam( L, 2, ptIni)
|
||||
double dDimX ;
|
||||
LuaCheckParam( L, 3, dDimX)
|
||||
double dDimY ;
|
||||
LuaCheckParam( L, 4, dDimY)
|
||||
double dDimZ ;
|
||||
LuaCheckParam( L, 5, dDimZ)
|
||||
double dPrec ;
|
||||
LuaCheckParam( L, 6, dPrec)
|
||||
bool bTriDex = true ;
|
||||
int nRefType = RTY_DEFAULT ;
|
||||
if ( ! LuaGetParam( L, 7, bTriDex))
|
||||
LuaGetParam( L, 7, nRefType) ;
|
||||
else
|
||||
LuaGetParam( L, 8, nRefType) ;
|
||||
LuaClearStack( L) ;
|
||||
// creo VZM parallelepipedo
|
||||
int nId = ExeCreateVolZmapEmpty( nParentId, ptIni, dDimX, dDimY, dDimZ, dPrec, bTriDex, nRefType) ;
|
||||
// restituisco il risultato
|
||||
if ( nId != GDB_ID_NULL)
|
||||
LuaSetParam( L, nId) ;
|
||||
else
|
||||
LuaSetParam( L) ;
|
||||
return 1 ;
|
||||
}
|
||||
|
||||
|
||||
|
||||
//-------------------------------------------------------------------------------
|
||||
static int
|
||||
LuaCreateVolZmapByRegionExtrusion( lua_State* L)
|
||||
@@ -104,13 +140,47 @@ LuaCreateVolZmapFromSurfTm( lua_State* L)
|
||||
return 1 ;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------
|
||||
static int
|
||||
LuaUpdateVolZmapByAddingSurfTm( lua_State* L)
|
||||
{
|
||||
// 2 parametri : nVolZmapId, StmId,
|
||||
int nVolZmapId ;
|
||||
LuaCheckParam( L, 1, nVolZmapId) ;
|
||||
int nStmId ;
|
||||
LuaCheckParam( L, 2, nStmId) ;
|
||||
LuaClearStack( L) ;
|
||||
bool bOk = ExeUpdateVolZmapByAddingSurfTm( nVolZmapId, nStmId) ;
|
||||
LuaSetParam( L, bOk) ;
|
||||
return 1 ;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------
|
||||
static int
|
||||
LuaUniformVolZmap( lua_State* L)
|
||||
{
|
||||
// 1 o 2 parametri : nVolZmapId [, dToler]
|
||||
int nVolZmapId ;
|
||||
LuaCheckParam( L, 1, nVolZmapId) ;
|
||||
double dToler = EPS_SMALL ;
|
||||
LuaGetParam( L, 2, dToler) ;
|
||||
LuaClearStack( L) ;
|
||||
bool bOk = ExeUniformVolZmap( nVolZmapId, dToler) ;
|
||||
LuaSetParam( L, bOk) ;
|
||||
return 1 ;
|
||||
}
|
||||
|
||||
|
||||
//-------------------------------------------------------------------------------
|
||||
bool
|
||||
LuaInstallGdbCreateVol( LuaMgr& luaMgr)
|
||||
{
|
||||
bool bOk = ( &luaMgr != nullptr) ;
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtVolZmapBox", LuaCreateVolZmapBox) ;
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtVolZmapEmpty", LuaCreateVolZmapEmpty) ;
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtVolZmapByRegionExtrusion", LuaCreateVolZmapByRegionExtrusion) ;
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtVolZmapFromSurfTm", LuaCreateVolZmapFromSurfTm) ;
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtUpdateVolZmapByAddingSurfTm", LuaUpdateVolZmapByAddingSurfTm ) ;
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtUniformZmap", LuaUniformVolZmap) ;
|
||||
return bOk ;
|
||||
}
|
||||
|
||||
+84
-3
@@ -57,6 +57,25 @@ LuaCurveLength( lua_State* L)
|
||||
return 1 ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
static int
|
||||
LuaCurveLengthAtParam( lua_State* L)
|
||||
{
|
||||
// 2 parametri : Id, dPar
|
||||
int nId ;
|
||||
LuaCheckParam( L, 1, nId)
|
||||
double dPar ;
|
||||
LuaCheckParam( L, 2, dPar) ;
|
||||
LuaClearStack( L) ;
|
||||
// recupero la lunghezza della curva
|
||||
double dLen ;
|
||||
if ( ExeCurveLengthAtParam( nId, dPar, &dLen))
|
||||
LuaSetParam( L, dLen) ;
|
||||
else
|
||||
LuaSetParam( L) ;
|
||||
return 1 ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
static int
|
||||
LuaCurveParamAtLength( lua_State* L)
|
||||
@@ -142,7 +161,7 @@ LuaCurveIsACircle( lua_State* L)
|
||||
double dToler = EPS_SMALL ;
|
||||
LuaGetParam( L, 2, dToler) ;
|
||||
LuaClearStack( L) ;
|
||||
// verifico se curva è equivalente ad una circonferenza
|
||||
// verifico se curva � equivalente ad una circonferenza
|
||||
Point3d ptCen ;
|
||||
Vector3d vtN ;
|
||||
double dRad ;
|
||||
@@ -166,7 +185,7 @@ LuaCurveIsARectangle( lua_State* L)
|
||||
double dToler = EPS_SMALL ;
|
||||
LuaGetParam( L, 2, dToler) ;
|
||||
LuaClearStack( L) ;
|
||||
// verifico se curva è equivalente ad un rettangolo
|
||||
// verifico se curva � equivalente ad un rettangolo
|
||||
Point3d ptP ;
|
||||
Vector3d vtL1 ;
|
||||
Vector3d vtL2 ;
|
||||
@@ -188,7 +207,7 @@ LuaCurveIsATrapezoid( lua_State* L)
|
||||
double dToler = EPS_SMALL ;
|
||||
LuaGetParam( L, 2, dToler) ;
|
||||
LuaClearStack( L) ;
|
||||
// verifico se curva è equivalente ad un trapezio
|
||||
// verifico se curva � equivalente ad un trapezio
|
||||
Point3d ptP ;
|
||||
Vector3d vtB1 ;
|
||||
Vector3d vtL1 ;
|
||||
@@ -531,6 +550,64 @@ LuaCurveCompoNormVersor( lua_State* L)
|
||||
return 1 ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
static int
|
||||
LuaCurveCompoGetTempProp( lua_State* L)
|
||||
{
|
||||
// 1 parametro : Id
|
||||
int nId ;
|
||||
LuaCheckParam( L, 1, nId)
|
||||
LuaClearStack( L) ;
|
||||
// recupero l'angolo al centro della curva semplice indicizzata
|
||||
INTVECTOR vProp ;
|
||||
if ( ExeCurveCompoGetTempProp( nId, vProp, 0))
|
||||
LuaSetParam( L, vProp) ;
|
||||
else
|
||||
LuaSetParam( L) ;
|
||||
return 1 ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
static int
|
||||
LuaCurveCompoGetTempParam( lua_State* L)
|
||||
{
|
||||
// 1 parametro : Id
|
||||
int nId ;
|
||||
LuaCheckParam( L, 1, nId)
|
||||
LuaClearStack( L) ;
|
||||
// recupero l'angolo al centro della curva semplice indicizzata
|
||||
DBLVECTOR vParam ;
|
||||
if ( ExeCurveCompoGetTempParam( nId, vParam, 0))
|
||||
LuaSetParam( L, vParam) ;
|
||||
else
|
||||
LuaSetParam( L) ;
|
||||
return 1 ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
static int
|
||||
LuaShowCurveBezierControlPoints( lua_State* L)
|
||||
{
|
||||
// 2 parametri : nCrvId, nDestGrpId
|
||||
int nCrvId ;
|
||||
LuaCheckParam( L, 1, nCrvId)
|
||||
int nDestGrpId ;
|
||||
LuaCheckParam( L, 2, nDestGrpId)
|
||||
LuaClearStack( L) ;
|
||||
int nCount = 0 ;
|
||||
int nId = ExeShowCurveBezierControlPoints( nCrvId, nDestGrpId, &nCount) ;
|
||||
// restituisco il risultato
|
||||
if ( nId != GDB_ID_NULL) {
|
||||
LuaSetParam( L, nId) ;
|
||||
LuaSetParam( L, nCount) ;
|
||||
}
|
||||
else {
|
||||
LuaSetParam( L) ;
|
||||
LuaSetParam( L) ;
|
||||
}
|
||||
return 2 ;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------
|
||||
bool
|
||||
LuaInstallGdbGetCurve( LuaMgr& luaMgr)
|
||||
@@ -538,6 +615,7 @@ LuaInstallGdbGetCurve( LuaMgr& luaMgr)
|
||||
bool bOk = ( &luaMgr != nullptr) ;
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtCurveDomain", LuaCurveDomain) ;
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtCurveLength", LuaCurveLength) ;
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtCurveLengthAtParam", LuaCurveLengthAtParam) ;
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtCurveParamAtLength", LuaCurveParamAtLength) ;
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtCurveParamAtPoint", LuaCurveParamAtPoint) ;
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtCurveIsClosed", LuaCurveIsClosed) ;
|
||||
@@ -562,5 +640,8 @@ LuaInstallGdbGetCurve( LuaMgr& luaMgr)
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtCurveCompoRadius", LuaCurveCompoRadius) ;
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtCurveCompoAngCenter", LuaCurveCompoAngCenter) ;
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtCurveCompoNormVersor", LuaCurveCompoNormVersor) ;
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtCurveCompoGetTempProp", LuaCurveCompoGetTempProp) ;
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtCurveCompoGetTempParam", LuaCurveCompoGetTempParam) ;
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtShowCurveBezierControlPoints", LuaShowCurveBezierControlPoints) ;
|
||||
return bOk ;
|
||||
}
|
||||
|
||||
@@ -121,6 +121,25 @@ LuaSurfFrChunkCount( lua_State* L)
|
||||
return 1 ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
static int
|
||||
LuaSurfFrChunkMaxOffset( lua_State* L)
|
||||
{
|
||||
// 2 parametri : Id, nChunk
|
||||
int nId ;
|
||||
LuaCheckParam( L, 1, nId)
|
||||
int nChunk ;
|
||||
LuaCheckParam( L, 2, nChunk)
|
||||
LuaClearStack( L) ;
|
||||
// recupero la sua area senza eventuali buchi
|
||||
double dMaxOffset ;
|
||||
if ( ExeSurfFrChunkMaxOffset( nId, nChunk, dMaxOffset))
|
||||
LuaSetParam( L, dMaxOffset) ;
|
||||
else
|
||||
LuaSetParam( L) ;
|
||||
return 1 ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
static int
|
||||
LuaSurfFrChunkSimpleClassify( lua_State* L)
|
||||
@@ -331,6 +350,27 @@ LuaSurfTmGetNearestVertex( lua_State* L)
|
||||
return 2 ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
static int
|
||||
LuaSurfTmTriangleNormVersor( lua_State* L)
|
||||
{
|
||||
// 2 o 3 parametri : nId, nTria [, nRefId]
|
||||
int nId ;
|
||||
LuaCheckParam( L, 1, nId)
|
||||
int nTria ;
|
||||
LuaCheckParam( L, 2, nTria)
|
||||
int nRefId = nId ;
|
||||
LuaGetParam( L, 3, nRefId) ;
|
||||
LuaClearStack( L) ;
|
||||
// recupero la normale del triangolo della superficie
|
||||
Vector3d vtNorm ;
|
||||
if ( ExeSurfTmTriangleNormVersor( nId, nTria, nRefId, vtNorm))
|
||||
LuaSetParam( L, vtNorm) ;
|
||||
else
|
||||
LuaSetParam( L) ;
|
||||
return 1 ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
static int
|
||||
LuaSurfTmFacetFromTria( lua_State* L)
|
||||
@@ -443,6 +483,42 @@ LuaSurfTmGetFacetBBoxRef( lua_State* L)
|
||||
return 1 ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
static int
|
||||
LuaSurfTmGetFacetOutlineInfo( lua_State* L)
|
||||
{
|
||||
// 2 o 3 parametri : Id, nFacet [, nRefId]
|
||||
int nId ;
|
||||
LuaCheckParam( L, 1, nId)
|
||||
int nFacet ;
|
||||
LuaCheckParam( L, 2, nFacet)
|
||||
int nRefId = nId ;
|
||||
LuaGetParam( L, 3, nRefId) ;
|
||||
LuaClearStack( L) ;
|
||||
// recupero le informazioni
|
||||
int nStatus ;
|
||||
BOOLVECTOR vbOpen ;
|
||||
INTVECTOR vnAdj ;
|
||||
VCT3DVECTOR vvtNorm ;
|
||||
DBLVECTOR vdElev ;
|
||||
DBLVECTOR vdLen ;
|
||||
bool bOk = ExeSurfTmGetFacetOutlineInfo( nId, nFacet, nRefId, nStatus, vbOpen, vnAdj, vdLen, vvtNorm, vdElev) ;
|
||||
// restituisco il risultato
|
||||
if ( bOk) {
|
||||
LuaSetParam( L, nStatus) ;
|
||||
LuaSetParam( L, vbOpen) ;
|
||||
LuaSetParam( L, vnAdj) ;
|
||||
LuaSetParam( L, vdLen) ;
|
||||
LuaSetParam( L, vvtNorm) ;
|
||||
LuaSetParam( L, vdElev) ;
|
||||
return 6 ;
|
||||
}
|
||||
else {
|
||||
LuaSetParam( L) ;
|
||||
return 1 ;
|
||||
}
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
static int
|
||||
LuaSurfTmFacetAdjacencies( lua_State* L)
|
||||
@@ -772,6 +848,38 @@ LuaGetSurfTmSilhouette( lua_State* L)
|
||||
return 2 ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
static int
|
||||
LuaGetSurfTmParSilhouettes( lua_State* L)
|
||||
{
|
||||
// 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, 5, dToler)
|
||||
int nDestGrpId ;
|
||||
LuaCheckParam( L, 6, nDestGrpId)
|
||||
int nRefType = RTY_DEFAULT ;
|
||||
LuaGetParam( L, 7, nRefType) ;
|
||||
LuaClearStack( L) ;
|
||||
// recupero i contorni della superficie
|
||||
int nCount = 0 ;
|
||||
int nNewId = ExeGetSurfTmParSilhouettes( vIds, ptOn, vtN, vdDist, dToler, nDestGrpId, nRefType, &nCount) ;
|
||||
// restituisco il risultato
|
||||
if ( nCount >= 0)
|
||||
LuaSetParam( L, nNewId) ;
|
||||
else
|
||||
LuaSetParam( L) ;
|
||||
LuaSetParam( L, nCount) ;
|
||||
return 2 ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
static int
|
||||
LuaExtractSurfTmFacetLoops( lua_State* L)
|
||||
@@ -1080,6 +1188,30 @@ LuaExtractSurfBezierLoops( lua_State* L)
|
||||
return 2 ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
static int
|
||||
LuaShowSurfBezierControlPoints( lua_State* L)
|
||||
{
|
||||
// 2 parametri : nCrvId, nDestGrpId
|
||||
int nCrvId ;
|
||||
LuaCheckParam( L, 1, nCrvId)
|
||||
int nDestGrpId ;
|
||||
LuaCheckParam( L, 2, nDestGrpId)
|
||||
LuaClearStack( L) ;
|
||||
int nCount = 0 ;
|
||||
int nId = ExeShowSurfBezierControlPoints( nCrvId, nDestGrpId, &nCount) ;
|
||||
// restituisco il risultato
|
||||
if ( nId != GDB_ID_NULL) {
|
||||
LuaSetParam( L, nId) ;
|
||||
LuaSetParam( L, nCount) ;
|
||||
}
|
||||
else {
|
||||
LuaSetParam( L) ;
|
||||
LuaSetParam( L) ;
|
||||
}
|
||||
return 2 ;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------
|
||||
bool
|
||||
LuaInstallGdbGetSurf( LuaMgr& luaMgr)
|
||||
@@ -1091,6 +1223,7 @@ LuaInstallGdbGetSurf( LuaMgr& luaMgr)
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtSurfFrNormVersor", LuaSurfFrNormVersor) ;
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtSurfFrGrossArea", LuaSurfFrGrossArea) ;
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtSurfFrChunkCount", LuaSurfFrChunkCount) ;
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtSurfFrChunkMaxOffset", LuaSurfFrChunkMaxOffset) ;
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtSurfFrChunkSimpleClassify", LuaSurfFrChunkSimpleClassify) ;
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtSurfFrTestExternal", LuaSurfFrTestExternal) ;
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtExtractSurfFrChunkLoops", LuaExtractSurfFrChunkLoops) ;
|
||||
@@ -1101,11 +1234,13 @@ LuaInstallGdbGetSurf( LuaMgr& luaMgr)
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtSurfTmPartCount", LuaSurfTmPartCount) ;
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtSurfTmGetVertex", LuaSurfTmGetVertex) ;
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtSurfTmGetNearestVertex", LuaSurfTmGetNearestVertex) ;
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtSurfTmTriangleNormVersor", LuaSurfTmTriangleNormVersor) ;
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtSurfTmFacetFromTria", LuaSurfTmFacetFromTria) ;
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtSurfTmGetAllVertInFacet", LuaSurfTmGetAllVertInFacet) ;
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtSurfTmGetFacetBBox", LuaSurfTmGetFacetBBox) ;
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtSurfTmGetFacetBBoxGlob", LuaSurfTmGetFacetBBoxGlob) ;
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtSurfTmGetFacetBBoxRef", LuaSurfTmGetFacetBBoxRef) ;
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtSurfTmGetFacetOutlineInfo", LuaSurfTmGetFacetOutlineInfo) ;
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtSurfTmFacetAdjacencies", LuaSurfTmFacetAdjacencies) ;
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtSurfTmFacetNearestEndPoint", LuaSurfTmFacetNearestEndPoint) ;
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtSurfTmFacetNearestMidPoint", LuaSurfTmFacetNearestMidPoint) ;
|
||||
@@ -1118,6 +1253,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( "EgtGetSurfTmParSilhouettes", LuaGetSurfTmParSilhouettes) ;
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtExtractSurfTmFacetLoops", LuaExtractSurfTmFacetLoops) ;
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtCopySurfTmFacet", LuaCopySurfTmFacet) ;
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtSurfTmGetEdges", LuaSurfTmGetEdges) ;
|
||||
@@ -1130,5 +1266,6 @@ LuaInstallGdbGetSurf( LuaMgr& luaMgr)
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtSurfBezierGetControlCurveU", LuaSurfBezierGetControlCurveU) ;
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtSurfBezierGetControlCurveV", LuaSurfBezierGetControlCurveV) ;
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtExtractSurfBezierLoops", LuaExtractSurfBezierLoops) ;
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtShowSurfBezierControlPoints", LuaShowSurfBezierControlPoints) ;
|
||||
return bOk ;
|
||||
}
|
||||
|
||||
+168
-8
@@ -913,6 +913,42 @@ LuaRemoveCurveCompoUndercutOnY( lua_State* L)
|
||||
return 1 ;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------
|
||||
static int
|
||||
LuaCurveCompoSetTempProp( lua_State* L)
|
||||
{
|
||||
// 3 parametri : Id, nCrv, nProp
|
||||
int nId ;
|
||||
LuaCheckParam( L, 1, nId)
|
||||
int nCrv ;
|
||||
LuaCheckParam( L, 2, nCrv)
|
||||
int nProp ;
|
||||
LuaCheckParam( L, 3, nProp)
|
||||
LuaClearStack( L) ;
|
||||
// imposto sulla curva della composita la proprietà temporanea
|
||||
bool bOk = ExeCurveCompoSetTempProp( nId, nCrv, nProp) ;
|
||||
LuaSetParam( L, bOk) ;
|
||||
return 1 ;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------
|
||||
static int
|
||||
LuaCurveCompoSetTempParam( lua_State* L)
|
||||
{
|
||||
// 3 parametri : Id, nCrv, dParam
|
||||
int nId ;
|
||||
LuaCheckParam( L, 1, nId)
|
||||
int nCrv ;
|
||||
LuaCheckParam( L, 2, nCrv)
|
||||
double dParam ;
|
||||
LuaCheckParam( L, 3, dParam)
|
||||
LuaClearStack( L) ;
|
||||
// imposto sulla curva della composita il parametro temporaneo
|
||||
bool bOk = ExeCurveCompoSetTempParam( nId, nCrv, dParam) ;
|
||||
LuaSetParam( L, bOk) ;
|
||||
return 1 ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
static int
|
||||
LuaChainCurvesInGroup( lua_State* L)
|
||||
@@ -1001,13 +1037,65 @@ LuaProjectCurveOnSurfTmExt( lua_State* L)
|
||||
return 1 ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
static int
|
||||
LuaProjectCurveOnSurfBz( lua_State* L)
|
||||
{
|
||||
// 4, 5, 6 o 7 parametri : nCurveId, nSurfBzId, vtDir, nDestGrpId [, dLinTol [, dMaxSegmLen] [, nRefType]]
|
||||
int nCurveId ;
|
||||
LuaCheckParam( L, 1, nCurveId)
|
||||
int nSurfBzId ;
|
||||
LuaCheckParam( L, 2, nSurfBzId)
|
||||
Vector3d vtDir ;
|
||||
LuaCheckParam( L, 3, vtDir)
|
||||
int nDestGrpId ;
|
||||
LuaCheckParam( L, 4, nDestGrpId)
|
||||
double dLinTol = 0.01 ;
|
||||
double dMaxSegmLen = INFINITO ;
|
||||
int nRefType = RTY_DEFAULT ;
|
||||
if ( LuaGetParam( L, 5, dLinTol) &&
|
||||
LuaGetParam( L, 6, dMaxSegmLen))
|
||||
LuaGetParam( L, 7, nRefType) ;
|
||||
LuaClearStack( L) ;
|
||||
// proietto la curva su una trimesh secondo la direzione data
|
||||
bool bOk = ExeProjectCurveOnSurfBz( nCurveId, nSurfBzId, vtDir, nDestGrpId, dLinTol, dMaxSegmLen, nRefType) ;
|
||||
LuaSetParam( L, bOk) ;
|
||||
return 1 ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
static int
|
||||
LuaProjectCurveOnSurfBzExt( lua_State* L)
|
||||
{
|
||||
// 4, 5, 6 o 7 parametri : nCurveId, nSurfBzId, nGuideId, nDestGrpId [, dLinTol [, dMaxSegmLen] [, bDirFromGuide]]
|
||||
int nCurveId ;
|
||||
LuaCheckParam( L, 1, nCurveId)
|
||||
int nSurfBzId ;
|
||||
LuaCheckParam( L, 2, nSurfBzId)
|
||||
int nGuideId ;
|
||||
LuaCheckParam( L, 3, nGuideId)
|
||||
int nDestGrpId ;
|
||||
LuaCheckParam( L, 4, nDestGrpId)
|
||||
double dLinTol = 0.01 ;
|
||||
double dMaxSegmLen = INFINITO ;
|
||||
bool bDirFromGuide = false ;
|
||||
if ( LuaGetParam( L, 5, dLinTol) &&
|
||||
LuaGetParam( L, 6, dMaxSegmLen))
|
||||
LuaGetParam( L, 7, bDirFromGuide) ;
|
||||
LuaClearStack( L) ;
|
||||
// proietto la curva su una trimesh secondo la direzione data
|
||||
bool bOk = ExeProjectCurveOnSurfBzExt( nCurveId, nSurfBzId, nGuideId, nDestGrpId, dLinTol, dMaxSegmLen, bDirFromGuide) ;
|
||||
LuaSetParam( L, bOk) ;
|
||||
return 1 ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
static int
|
||||
LuaCurveGetVoronoi( lua_State* L)
|
||||
{
|
||||
// 2 o 3 parametri : Id, nDestGrpId [, nBound]
|
||||
int nId ;
|
||||
LuaCheckParam( L, 1, nId)
|
||||
// 2 o 3 parametri : Id/s, nDestGrpId [, nBound]
|
||||
INTVECTOR vIds ;
|
||||
LuaCheckParam( L, 1, vIds)
|
||||
int nDestGrpId ;
|
||||
LuaCheckParam( L, 2, nDestGrpId)
|
||||
int nBound = 3 ; // VORONOI_STD_BOUND
|
||||
@@ -1015,7 +1103,7 @@ LuaCurveGetVoronoi( lua_State* L)
|
||||
LuaClearStack( L) ;
|
||||
// eseguo
|
||||
int nCount = 0 ;
|
||||
int nNewId = ExeCurveGetVoronoi( nId, nDestGrpId, nBound, &nCount) ;
|
||||
int nNewId = ExeCurveGetVoronoi( vIds, nDestGrpId, nBound, &nCount) ;
|
||||
if ( nNewId != GDB_ID_NULL)
|
||||
LuaSetParam( L, nNewId) ;
|
||||
else
|
||||
@@ -1029,9 +1117,9 @@ LuaCurveGetVoronoi( lua_State* L)
|
||||
static int
|
||||
LuaCurveMedialAxisAdv( lua_State* L)
|
||||
{
|
||||
// 2 o 3 parametri : Id, nDestGrpId [, nSide]
|
||||
int nId ;
|
||||
LuaCheckParam( L, 1, nId)
|
||||
// 2 o 3 parametri : Id/s, nDestGrpId [, nSide]
|
||||
INTVECTOR vIds ;
|
||||
LuaCheckParam( L, 1, vIds)
|
||||
int nDestGrpId ;
|
||||
LuaCheckParam( L, 2, nDestGrpId)
|
||||
int nSide = 1 ; // WMAT_LEFT
|
||||
@@ -1039,7 +1127,7 @@ LuaCurveMedialAxisAdv( lua_State* L)
|
||||
LuaClearStack( L) ;
|
||||
// eseguo
|
||||
int nCount = 0 ;
|
||||
int nNewId = ExeCurveGetMedialAxis( nId, nDestGrpId, nSide, &nCount) ;
|
||||
int nNewId = ExeCurveGetMedialAxis( vIds, nDestGrpId, nSide, &nCount) ;
|
||||
if ( nNewId != GDB_ID_NULL)
|
||||
LuaSetParam( L, nNewId) ;
|
||||
else
|
||||
@@ -1077,6 +1165,70 @@ LuaCurveGetFatCurve( lua_State* L)
|
||||
return 2 ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
static int
|
||||
LuaCurveBezierIncreaseDegree( lua_State* L)
|
||||
{
|
||||
// 1 parametro : CrvId
|
||||
int nId ;
|
||||
LuaCheckParam( L, 1, nId)
|
||||
LuaClearStack( L) ;
|
||||
// eseguo
|
||||
bool bOk = ExeCurveBezierIncreaseDegree( nId) ;
|
||||
LuaSetParam( L, bOk) ;
|
||||
|
||||
return 1 ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
static int
|
||||
LuaCurveBezierDecreaseDegree( lua_State* L)
|
||||
{
|
||||
// 1 parametro : CrvId
|
||||
int nId ;
|
||||
LuaCheckParam( L, 1, nId)
|
||||
LuaClearStack( L) ;
|
||||
// eseguo
|
||||
bool bOk = ExeCurveBezierDecreaseDegree( nId) ;
|
||||
LuaSetParam( L, bOk) ;
|
||||
|
||||
return 1 ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
static int
|
||||
LuaCurveBezierApproxToNonRat( lua_State* L)
|
||||
{
|
||||
// 1 o 2 parametri : CrvId [, dTol]
|
||||
int nId ;
|
||||
LuaCheckParam( L, 1, nId)
|
||||
double dTol = 10 * EPS_SMALL ;
|
||||
LuaGetParam( L, 2, dTol) ;
|
||||
LuaClearStack( L) ;
|
||||
// eseguo
|
||||
bool bOk = ExeCurveBezierApproxToNonRat( nId, dTol) ;
|
||||
LuaSetParam( L, bOk) ;
|
||||
|
||||
return 1 ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
static int
|
||||
LuaCurveBezierApproxWithCubicBeziers( lua_State* L)
|
||||
{
|
||||
// 1 o 2 parametri : CrvId [, dTol]
|
||||
int nId ;
|
||||
LuaCheckParam( L, 1, nId)
|
||||
double dTol = 10 * EPS_SMALL ;
|
||||
LuaGetParam( L, 2, dTol) ;
|
||||
LuaClearStack( L) ;
|
||||
// eseguo
|
||||
bool bOk = ExeCurveBezierApproxWithCubicBeziers( nId, dTol) ;
|
||||
LuaSetParam( L, bOk) ;
|
||||
|
||||
return 1 ;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------
|
||||
bool
|
||||
LuaInstallGdbModifyCurve( LuaMgr& luaMgr)
|
||||
@@ -1130,6 +1282,8 @@ LuaInstallGdbModifyCurve( LuaMgr& luaMgr)
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtExplodeCurveCompo", LuaExplodeCurveCompo) ;
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtMergeCurvesInCurveCompo", LuaMergeCurvesInCurveCompo) ;
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtRemoveCurveCompoUndercutOnY", LuaRemoveCurveCompoUndercutOnY) ;
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtCurveCompoSetTempProp", LuaCurveCompoSetTempProp) ;
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtCurveCompoSetTempParam", LuaCurveCompoSetTempParam) ;
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtChainCurvesInGroup", LuaChainCurvesInGroup) ;
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtReorderCurvesInGroup", LuaReorderCurvesInGroup) ;
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtProjectCurveOnSurfTm", LuaProjectCurveOnSurfTm) ;
|
||||
@@ -1137,5 +1291,11 @@ LuaInstallGdbModifyCurve( LuaMgr& luaMgr)
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtCurveGetVoronoi", LuaCurveGetVoronoi) ;
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtCurveMedialAxisAdv", LuaCurveMedialAxisAdv) ;
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtCurveGetFatCurve", LuaCurveGetFatCurve) ;
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtProjectCurveOnSurfBz", LuaProjectCurveOnSurfBz) ;
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtProjectCurveOnSurfBzExt", LuaProjectCurveOnSurfBzExt) ;
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtCurveBezierIncreaseDeg", LuaCurveBezierIncreaseDegree) ;
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtCurveBezierDecreaseDeg", LuaCurveBezierDecreaseDegree) ;
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtCurveBezierApproxToNonRat", LuaCurveBezierApproxToNonRat) ;
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtApproxBezierWithCubics", LuaCurveBezierApproxWithCubicBeziers) ;
|
||||
return bOk ;
|
||||
}
|
||||
|
||||
@@ -165,6 +165,23 @@ LuaSurfFrOffsetAdv( lua_State* L)
|
||||
return 1 ;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------
|
||||
static int
|
||||
LuaSurfFrEraseChunk( lua_State* L)
|
||||
{
|
||||
// 2 parametri : Id, nChunk
|
||||
int nId ;
|
||||
LuaCheckParam( L, 1, nId)
|
||||
int nChunk ;
|
||||
LuaCheckParam( L, 2, nChunk)
|
||||
LuaClearStack( L) ;
|
||||
// eseguo l'offset della regione
|
||||
bool bOk = ExeSurfFrEraseChunk( nId, nChunk) ;
|
||||
LuaSetParam( L, bOk) ;
|
||||
|
||||
return 1 ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
static int
|
||||
LuaSurfTmMoveVertex( lua_State* L)
|
||||
@@ -479,6 +496,44 @@ LuaSurfTmSubtractProjectedFacesOnFace( lua_State* L)
|
||||
return 4 ;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------
|
||||
static int
|
||||
LuaSurfTmSetFaceColor( lua_State* L)
|
||||
{
|
||||
// 3 parametri : Id, nFacet, nColor
|
||||
int nId ;
|
||||
LuaCheckParam( L, 1, nId)
|
||||
int nFacet ;
|
||||
LuaCheckParam( L, 2, nFacet)
|
||||
int nColor ;
|
||||
LuaCheckParam( L, 3, nColor)
|
||||
LuaClearStack( L) ;
|
||||
// imposto il colore alla faccia della superficie TM
|
||||
bool bOk = ExeSurfTmSetFaceColor( nId, nFacet, nColor) ;
|
||||
LuaSetParam( L, bOk) ;
|
||||
return 1 ;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------
|
||||
static int
|
||||
LuaSurfTmGetTriaColor( lua_State* L)
|
||||
{
|
||||
// 2 parametri : Id, nTria
|
||||
int nId ;
|
||||
LuaCheckParam( L, 1, nId)
|
||||
int nTria ;
|
||||
LuaCheckParam( L, 2, nTria)
|
||||
LuaClearStack( L) ;
|
||||
// recupero il flag di colore del triangolo della superficie TM
|
||||
int nColor ;
|
||||
bool bOk = ExeSurfTmGetTriaColor( nId, nTria, nColor) ;
|
||||
if ( bOk)
|
||||
LuaSetParam( L, nColor) ;
|
||||
else
|
||||
LuaSetParam( L) ;
|
||||
return 1 ;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------
|
||||
static int
|
||||
LuaSurfTmResetTwoColors( lua_State* L)
|
||||
@@ -510,6 +565,24 @@ LuaSurfTmSetShowEdges( lua_State* L)
|
||||
return 1 ;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------
|
||||
static int
|
||||
LuaSurfTmGetShowEdges( lua_State* L)
|
||||
{
|
||||
// 1 parametro : Id
|
||||
int nId ;
|
||||
LuaCheckParam( L, 1, nId)
|
||||
LuaClearStack( L) ;
|
||||
// recupero il flag di visualizzazione degli spigoli vivi della superficie TM
|
||||
bool bShow ;
|
||||
bool bOk = ExeSurfTmGetShowEdges( nId, bShow) ;
|
||||
if ( bOk)
|
||||
LuaSetParam( L, bShow) ;
|
||||
else
|
||||
LuaSetParam( L) ;
|
||||
return 1 ;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------
|
||||
static int
|
||||
LuaSurfBzTrim( lua_State* L)
|
||||
@@ -526,6 +599,22 @@ LuaSurfBzTrim( lua_State* L)
|
||||
return 1 ;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------
|
||||
static int
|
||||
LuaSurfTmSetSmoothAng( lua_State* L)
|
||||
{
|
||||
// 2 parametri : nId, nCutterId
|
||||
int nId ;
|
||||
LuaCheckParam( L, 1, nId)
|
||||
double dAngDeg ;
|
||||
LuaCheckParam( L, 2, dAngDeg)
|
||||
LuaClearStack( L) ;
|
||||
// aggiorno lo smooth angle della superficie
|
||||
bool bOk = ExeSurfTmSetSmoothAng( nId, dAngDeg) ;
|
||||
LuaSetParam( L, bOk) ;
|
||||
return 1 ;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------
|
||||
bool
|
||||
LuaInstallGdbModifySurf( LuaMgr& luaMgr)
|
||||
@@ -539,6 +628,7 @@ LuaInstallGdbModifySurf( LuaMgr& luaMgr)
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtSurfFrIntersect", LuaSurfFrIntersect) ;
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtSurfFrOffset", LuaSurfFrOffset) ;
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtSurfFrOffsetAdv", LuaSurfFrOffsetAdv) ;
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtSurfFrEraseChunk", LuaSurfFrEraseChunk) ;
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtSurfTmMoveVertex", LuaSurfTmMoveVertex) ;
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtSurfTmMoveFacet", LuaSurfTmMoveFacet) ;
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtSurfTmToTriangles", LuaSurfTmToTriangles) ;
|
||||
@@ -554,8 +644,12 @@ LuaInstallGdbModifySurf( LuaMgr& luaMgr)
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtSurfTmSplit", LuaSurfTmSplit) ;
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtSurfTmCut", LuaSurfTmCut) ;
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtSurfTmSubtractProjectedFacesOnFace", LuaSurfTmSubtractProjectedFacesOnFace) ;
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtSurfTmSetFaceColor", LuaSurfTmSetFaceColor) ;
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtSurfTmGetTriaColor", LuaSurfTmGetTriaColor) ;
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtSurfTmResetTwoColors", LuaSurfTmResetTwoColors) ;
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtSurfTmSetShowEdges", LuaSurfTmSetShowEdges) ;
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtSurfTmGetShowEdges", LuaSurfTmGetShowEdges) ;
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtSurfBzTrim", LuaSurfBzTrim) ;
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtSurfTmSetSmoothAng", LuaSurfTmSetSmoothAng) ;
|
||||
return bOk ;
|
||||
}
|
||||
|
||||
+30
-4
@@ -152,7 +152,7 @@ LuaVolZmapSetAdvTool( lua_State* L)
|
||||
static int
|
||||
LuaVolZmapSetSawTool( lua_State* L)
|
||||
{
|
||||
// 7 o 8 parametri : vIds, sToolName, dLen, dDiam, dThick, dStemDiam, dCornR, nFlag
|
||||
// 7 o 8 parametri : vIds, sToolName, dLen, dDiam, dThick, dStemDiam, dCornR [, nFlag]
|
||||
INTVECTOR vIds ;
|
||||
LuaCheckParam( L, 1, vIds)
|
||||
string sToolName ;
|
||||
@@ -181,7 +181,7 @@ LuaVolZmapSetSawTool( lua_State* L)
|
||||
static int
|
||||
LuaVolZmapSetGenTool( lua_State* L)
|
||||
{
|
||||
// 3 o 4 parametri : vIds, sToolName, ToolSectId, nFlag
|
||||
// 3 o 4 parametri : vIds, sToolName, ToolSectId [, nFlag]
|
||||
INTVECTOR vIds ;
|
||||
LuaCheckParam( L, 1, vIds)
|
||||
string sToolName ;
|
||||
@@ -202,7 +202,7 @@ LuaVolZmapSetGenTool( lua_State* L)
|
||||
static int
|
||||
LuaVolZmapSetMortiserTool( lua_State* L)
|
||||
{
|
||||
// 6 o 7 parametri : Id, sToolName, dLen, dWidth, dThick, dCornR, nFlag
|
||||
// 6 o 7 parametri : Id, sToolName, dLen, dWidth, dThick, dCornR [, nFlag]
|
||||
INTVECTOR vIds ;
|
||||
LuaCheckParam( L, 1, vIds)
|
||||
string sToolName ;
|
||||
@@ -229,7 +229,7 @@ LuaVolZmapSetMortiserTool( lua_State* L)
|
||||
static int
|
||||
LuaVolZmapSetChiselTool( lua_State* L)
|
||||
{
|
||||
// 5 o 6 parametri : vIds, sToolName, dLen, dWidth, dThick, nFlag
|
||||
// 5 o 6 parametri : vIds, sToolName, dLen, dWidth, dThick [, nFlag]
|
||||
INTVECTOR vIds ;
|
||||
LuaCheckParam( L, 1, vIds)
|
||||
string sToolName ;
|
||||
@@ -250,6 +250,31 @@ LuaVolZmapSetChiselTool( lua_State* L)
|
||||
return 1 ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
static int
|
||||
LuaVolZmapSetAdditiveTool( lua_State* L)
|
||||
{
|
||||
// 5 o 6 parametri : vIds, sToolName, dLen, dDiam, dCornR [, nFlag]
|
||||
INTVECTOR vIds ;
|
||||
LuaCheckParam( L, 1, vIds)
|
||||
string sToolName ;
|
||||
LuaCheckParam( L, 2, sToolName)
|
||||
double dLen ;
|
||||
LuaCheckParam( L, 3, dLen)
|
||||
double dDiam ;
|
||||
LuaCheckParam( L, 4, dDiam)
|
||||
double dCornR ;
|
||||
LuaCheckParam( L, 5, dCornR)
|
||||
int nFlag = 1 ;
|
||||
LuaGetParam( L, 6, nFlag) ;
|
||||
LuaClearStack( L) ;
|
||||
// imposto utensile additivo a Zmap indicati
|
||||
bool bOk = ExeVolZmapSetAdditiveTool( vIds, sToolName, dLen, dDiam, dCornR, nFlag, true) ;
|
||||
// restituisco il risultato
|
||||
LuaSetParam( L, bOk) ;
|
||||
return 1 ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
static int
|
||||
LuaVolZmapResetTool( lua_State* L)
|
||||
@@ -375,6 +400,7 @@ LuaInstallGdbModifyVol( LuaMgr& luaMgr)
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtVolZmapSetGenTool", LuaVolZmapSetGenTool) ;
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtVolZmapSetMortiserTool", LuaVolZmapSetMortiserTool) ;
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtVolZmapSetChiselTool", LuaVolZmapSetChiselTool) ;
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtVolZmapSetAdditiveTool", LuaVolZmapSetAdditiveTool) ;
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtVolZmapResetTool", LuaVolZmapResetTool) ;
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtVolZmapGetToolOutline", LuaVolZmapGetToolOutline) ;
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtVolZmapMillingStep", LuaVolZmapMillingStep) ;
|
||||
|
||||
@@ -247,12 +247,14 @@ LuaGetCalcStatus( lua_State* L)
|
||||
static int
|
||||
LuaSetMark( lua_State* L)
|
||||
{
|
||||
// 1 parametro : Id
|
||||
// 1 o 2 parametri : Id [, nMark]
|
||||
int nId ;
|
||||
LuaCheckParam( L, 1, nId)
|
||||
int nMark = 1 ;
|
||||
LuaGetParam( L, 2, nMark) ;
|
||||
LuaClearStack( L) ;
|
||||
// imposto l'evidenziazione
|
||||
bool bOk = ExeSetMark( nId) ;
|
||||
bool bOk = ExeSetMark( nId, nMark) ;
|
||||
// restituisco il risultato
|
||||
LuaSetParam( L, bOk) ;
|
||||
return 1 ;
|
||||
|
||||
@@ -107,6 +107,24 @@ LuaPause( lua_State* L)
|
||||
return 1 ;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------
|
||||
static int
|
||||
LuaGetKeyPressed( lua_State* L)
|
||||
{
|
||||
// 1 parametro : nKeyCode
|
||||
int nKeyCode ;
|
||||
LuaCheckParam( L, 1, nKeyCode)
|
||||
LuaClearStack( L) ;
|
||||
// se abilitata UI, controllo se il tasto indicato è premuto
|
||||
bool bPressed = false ;
|
||||
if ( ExeGetEnableUI()) {
|
||||
bPressed = (( GetAsyncKeyState( nKeyCode) & 0x8000) != 0) ;
|
||||
}
|
||||
// restituisco il risultato
|
||||
LuaSetParam( L, bPressed) ;
|
||||
return 1 ;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------
|
||||
static int
|
||||
LuaStartCounter( lua_State* L)
|
||||
@@ -1065,6 +1083,20 @@ LuaGetMsg( lua_State* L)
|
||||
return 1 ;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------
|
||||
static int
|
||||
LuaVerifyKeyOption( lua_State* L)
|
||||
{
|
||||
// 1 parametro : nOptInd
|
||||
int nOptInd ;
|
||||
LuaCheckParam( L, 1, nOptInd)
|
||||
LuaClearStack( L) ;
|
||||
// verifico l'abilitazione dell'opzione (da chiave + licenza)
|
||||
bool bOk = ExeVerifyKeyOption( nOptInd) ;
|
||||
LuaSetParam( L, bOk) ;
|
||||
return 1 ;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------
|
||||
static int
|
||||
LuaWinExec( lua_State* L)
|
||||
@@ -1322,6 +1354,7 @@ LuaInstallGeneral( LuaMgr& luaMgr)
|
||||
bOk = bOk && luaMgr.RegisterFunction( "print", MyPrint) ;
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtEvalNumExpr", LuaEvalNumExpr) ;
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtPause", LuaPause) ;
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtGetKeyPressed", LuaGetKeyPressed) ;
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtStartCounter", LuaStartCounter) ;
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtStopCounter", LuaStopCounter) ;
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtNumToString", LuaNumToString) ;
|
||||
@@ -1365,6 +1398,7 @@ LuaInstallGeneral( LuaMgr& luaMgr)
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtIs64bit", LuaIs64bit) ;
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtGetLanguage", LuaGetLanguage) ;
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtMsg", LuaGetMsg) ;
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtVerifyKeyOption", LuaVerifyKeyOption) ;
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtDialogBox", LuaDialogBox) ;
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtWinExec", LuaWinExec) ;
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtCloseExe", LuaCloseExe) ;
|
||||
|
||||
@@ -1629,6 +1629,22 @@ LuaTdbGetCurrToolThLength( lua_State* L)
|
||||
return 1 ;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------
|
||||
static int
|
||||
LuaTdbIsCurrToolStandardDraw( lua_State* L)
|
||||
{
|
||||
// nessun parametro
|
||||
LuaClearStack( L) ;
|
||||
// recupero lo stato
|
||||
bool bStandard ;
|
||||
bool bOk = ExeTdbCurrToolIsStandardDraw( bStandard) ;
|
||||
if ( bOk)
|
||||
LuaSetParam( L, bStandard) ;
|
||||
else
|
||||
LuaSetParam( L) ;
|
||||
return 1 ;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------
|
||||
static int
|
||||
LuaTdbGetCurrToolDraw( lua_State* L)
|
||||
@@ -3737,6 +3753,26 @@ LuaGetHeadExitCount( lua_State* L)
|
||||
return 1 ;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------
|
||||
static int
|
||||
LuaGetExitId( lua_State* L)
|
||||
{
|
||||
// 2 parametri : sHead, nExit
|
||||
string sHead ;
|
||||
LuaCheckParam( L, 1, sHead)
|
||||
int nExit ;
|
||||
LuaCheckParam( L, 2, nExit)
|
||||
LuaClearStack( L) ;
|
||||
// recupero l'identificativo dell'Uscita della Testa indicata della macchina
|
||||
int nId = ExeGetExitId( sHead, nExit) ;
|
||||
// restituisco il risultato
|
||||
if ( nId != GDB_ID_NULL)
|
||||
LuaSetParam( L, nId) ;
|
||||
else
|
||||
LuaSetParam( L) ;
|
||||
return 1 ;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------
|
||||
static int
|
||||
LuaGetTcPosId( lua_State* L)
|
||||
@@ -4194,6 +4230,7 @@ LuaInstallMachMgr( LuaMgr& luaMgr)
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtTdbGetCurrToolMaxDepth", LuaTdbGetCurrToolMaxDepth) ;
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtTdbGetCurrToolThDiam", LuaTdbGetCurrToolThDiam) ;
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtTdbGetCurrToolThLength", LuaTdbGetCurrToolThLength) ;
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtTdbIsCurrToolStandardDraw", LuaTdbIsCurrToolStandardDraw) ;
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtTdbGetCurrToolDraw", LuaTdbGetCurrToolDraw) ;
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtTdbReload", LuaTdbReload) ;
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtTdbSave", LuaTdbSave) ;
|
||||
@@ -4299,6 +4336,7 @@ LuaInstallMachMgr( LuaMgr& luaMgr)
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtGetAxisId", LuaGetAxisId) ;
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtGetHeadId", LuaGetHeadId) ;
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtGetHeadExitCount", LuaGetHeadExitCount) ;
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtGetExitId", LuaGetExitId) ;
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtGetTcPosId", LuaGetTcPosId) ;
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtGetAxisToken", LuaGetAxisToken) ;
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtGetAxisType", LuaGetAxisType) ;
|
||||
|
||||
Reference in New Issue
Block a user