EgtInterface 1.6a2 :
- numerose modifiche e correzioni - aggiunta registrazione comandi in formato lua - aggiunto valutatore di espressioni.
This commit is contained in:
+321
-98
@@ -23,8 +23,10 @@
|
||||
#include "/EgtDev/Include/EGkDistPointCurve.h"
|
||||
#include "/EgtDev/Include/EGkExtTExt.h"
|
||||
#include "/EgtDev/Include/EGkGdbIterator.h"
|
||||
#include "/EgtDev/Include/EGkStringUtils3d.h"
|
||||
#include "/EgtDev/Include/EgtPointerOwner.h"
|
||||
|
||||
using namespace std ;
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
BOOL
|
||||
@@ -32,12 +34,62 @@ __stdcall EgtInvertCurve( int nId)
|
||||
{
|
||||
IGeomDB* pGeomDB = GetCurrGeomDB() ;
|
||||
VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL)
|
||||
bool bOk = true ;
|
||||
// eseguo inversione singola
|
||||
if ( nId != GDB_ID_SEL) {
|
||||
// recupero la curva e la inverto
|
||||
ICurve* pCurve = GetCurve( pGeomDB->GetGeoObj( nId)) ;
|
||||
if ( pCurve != nullptr && ! pCurve->Invert())
|
||||
bOk = false ;
|
||||
}
|
||||
// eseguo inversione dei selezionati
|
||||
else {
|
||||
int nI = pGeomDB->GetFirstSelectedObj() ;
|
||||
while ( nI != GDB_ID_NULL && bOk) {
|
||||
// recupero la curva e la inverto
|
||||
ICurve* pCurve = GetCurve( pGeomDB->GetGeoObj( nI)) ;
|
||||
if ( pCurve != nullptr && ! pCurve->Invert())
|
||||
bOk = false ;
|
||||
// passo alla successiva
|
||||
nI = pGeomDB->GetNextSelectedObj() ;
|
||||
}
|
||||
}
|
||||
// se richiesto, salvo il comando Lua equivalente
|
||||
if ( IsCmdLog()) {
|
||||
string sLua = "EgtInvertCurve(" + ( nId != GDB_ID_SEL ? ToString( nId): "GDB_ID_SEL") + ")" +
|
||||
" -- Ok=" + ToString( bOk) ;
|
||||
LOG_INFO( GetCmdLogger(), sLua.c_str()) ;
|
||||
}
|
||||
// restituisco risultato
|
||||
return ( bOk ? TRUE : FALSE) ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
BOOL
|
||||
__stdcall EgtOffsetCurve( int nId, double dDist, int nType)
|
||||
{
|
||||
IGeomDB* pGeomDB = GetCurrGeomDB() ;
|
||||
VERIFY_GEOMDB( pGeomDB, FALSE)
|
||||
// recupero la curva
|
||||
ICurve* pCurve = GetCurve( pGeomDB->GetGeoObj( nId)) ;
|
||||
if ( pCurve == nullptr)
|
||||
return FALSE ;
|
||||
// la inverto
|
||||
return ( pCurve->Invert() ? TRUE : FALSE) ;
|
||||
// eseguo l'offset
|
||||
bool bOk = ( pCurve != nullptr) && pCurve->SimpleOffset( dDist, nType) ;
|
||||
// se richiesto, salvo il comando Lua equivalente
|
||||
if ( IsCmdLog()) {
|
||||
string sLua ;
|
||||
if ( nType == ICurve::OFF_FILLET)
|
||||
sLua = "EgtOffsetCurve(" + ToString( nId) + "," +
|
||||
ToString( dDist) + ")" +
|
||||
" -- Ok=" + ToString( bOk) ;
|
||||
else
|
||||
sLua = "EgtOffsetCurve(" + ToString( nId) + "," +
|
||||
ToString( dDist) + "," +
|
||||
( nType == ICurve::OFF_CHAMFER ? "'CHAMFER'" : "'EXTEND'") + ")" +
|
||||
" -- Ok=" + ToString( bOk) ;
|
||||
LOG_INFO( GetCmdLogger(), sLua.c_str()) ;
|
||||
}
|
||||
// restituisco risultato
|
||||
return ( bOk ? TRUE : FALSE) ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
@@ -69,50 +121,153 @@ __stdcall EgtModifyCurveEndPoint( int nId, const double ptP[3])
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
BOOL
|
||||
__stdcall EgtModifyCurveExtrusion( int nId, const double vtExtr[3])
|
||||
static bool
|
||||
__stdcall ModifyOneCurveExtrusion( IGeomDB* pGeomDB, int nId, const Vector3d& vtExtr)
|
||||
{
|
||||
IGeomDB* pGeomDB = GetCurrGeomDB() ;
|
||||
VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL)
|
||||
// se gruppo, agisco sulle sole curve componenti
|
||||
if ( pGeomDB->GetGdbType( nId) == GDB_TY_GROUP) {
|
||||
PtrOwner<IGdbIterator> pIter( CreateGdbIterator( pGeomDB)) ;
|
||||
if ( IsNull( pIter))
|
||||
return FALSE ;
|
||||
return false ;
|
||||
bool bOk = true ;
|
||||
Vector3d vtVE( vtExtr) ;
|
||||
for ( bool bFound = pIter->GoToFirstInGroup( nId) ;
|
||||
bFound ;
|
||||
bFound = pIter->GoToNext()) {
|
||||
// recupero la curva e ne modifico il vettore estrusione
|
||||
ICurve* pCurve = GetCurve( pIter->GetGeoObj()) ;
|
||||
if ( pCurve != nullptr && ! pCurve->SetExtrusion( vtVE))
|
||||
if ( pCurve != nullptr && ! pCurve->SetExtrusion( vtExtr))
|
||||
bOk = false ;
|
||||
}
|
||||
return ( bOk ? TRUE : FALSE) ;
|
||||
return bOk ;
|
||||
}
|
||||
// se oggetto geometrico
|
||||
else {
|
||||
// recupero la curva
|
||||
ICurve* pCurve = GetCurve( pGeomDB->GetGeoObj( nId)) ;
|
||||
if ( pCurve == nullptr)
|
||||
return FALSE ;
|
||||
// ne modifico il vettore estrusione
|
||||
return ( pCurve->SetExtrusion( Vector3d( vtExtr)) ? TRUE : FALSE) ;
|
||||
return ( pCurve == nullptr || pCurve->SetExtrusion( vtExtr)) ;
|
||||
}
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
BOOL
|
||||
__stdcall EgtModifyCurveThickness( int nId, double dThick)
|
||||
__stdcall EgtModifyCurveExtrusion( int nId, const double vtExtr[3])
|
||||
{
|
||||
IGeomDB* pGeomDB = GetCurrGeomDB() ;
|
||||
VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL)
|
||||
VERIFY_GEOMDB( pGeomDB, FALSE)
|
||||
bool bOk = true ;
|
||||
// eseguo impostazione estrusione singola
|
||||
if ( nId != GDB_ID_SEL) {
|
||||
bOk = ModifyOneCurveExtrusion( pGeomDB, nId, vtExtr) ;
|
||||
}
|
||||
// eseguo impostazione estrusione dei selezionati
|
||||
else {
|
||||
int nI = pGeomDB->GetFirstSelectedObj() ;
|
||||
while ( nI != GDB_ID_NULL && bOk) {
|
||||
if ( ! ModifyOneCurveExtrusion( pGeomDB, nI, vtExtr))
|
||||
bOk = false ;
|
||||
// passo alla successiva
|
||||
nI = pGeomDB->GetNextSelectedObj() ;
|
||||
}
|
||||
}
|
||||
// se richiesto, salvo il comando Lua equivalente
|
||||
if ( IsCmdLog()) {
|
||||
string sLua = "EgtModifyCurveExtrusion(" + ( nId != GDB_ID_SEL ? ToString( nId) : "GDB_ID_SEL") + ",{" +
|
||||
ToString( Vector3d( vtExtr)) + "})" +
|
||||
" -- Ok=" + ToString( bOk) ;
|
||||
LOG_INFO( GetCmdLogger(), sLua.c_str()) ;
|
||||
}
|
||||
// restituisco risultato
|
||||
return ( bOk ? TRUE : FALSE) ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
static bool
|
||||
__stdcall SetOneCurveExtrusionFromGrid( IGeomDB* pGeomDB, int nId, const Vector3d& vtExtrGlob)
|
||||
{
|
||||
// se gruppo, agisco sulle sole curve componenti
|
||||
if ( pGeomDB->GetGdbType( nId) == GDB_TY_GROUP) {
|
||||
// recupero il riferimento definito dal gruppo
|
||||
Frame3d frFrame ;
|
||||
if ( ! pGeomDB->GetGroupGlobFrame( nId, frFrame))
|
||||
return false ;
|
||||
// esprimo il versore estrusione in questo riferimento
|
||||
Vector3d vtExtr = vtExtrGlob ;
|
||||
vtExtr.ToLoc( frFrame) ;
|
||||
// ciclo sulle curve del gruppo
|
||||
PtrOwner<IGdbIterator> pIter( CreateGdbIterator( pGeomDB)) ;
|
||||
if ( IsNull( pIter))
|
||||
return false ;
|
||||
bool bOk = true ;
|
||||
for ( bool bFound = pIter->GoToFirstInGroup( nId) ;
|
||||
bFound ;
|
||||
bFound = pIter->GoToNext()) {
|
||||
// recupero la curva e ne modifico il vettore estrusione
|
||||
ICurve* pCurve = GetCurve( pIter->GetGeoObj()) ;
|
||||
if ( pCurve != nullptr && ! pCurve->SetExtrusion( vtExtr))
|
||||
bOk = false ;
|
||||
}
|
||||
return bOk ;
|
||||
}
|
||||
// se oggetto geometrico
|
||||
else {
|
||||
// recupero il riferimento definito dal gruppo
|
||||
Frame3d frFrame ;
|
||||
if ( ! pGeomDB->GetGlobFrame( nId, frFrame))
|
||||
return false ;
|
||||
// esprimo il versore estrusione in questo riferimento
|
||||
Vector3d vtExtr = vtExtrGlob ;
|
||||
vtExtr.ToLoc( frFrame) ;
|
||||
// recupero la curva
|
||||
ICurve* pCurve = GetCurve( pGeomDB->GetGeoObj( nId)) ;
|
||||
// ne modifico il vettore estrusione
|
||||
return ( pCurve == nullptr || pCurve->SetExtrusion( vtExtr)) ;
|
||||
}
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------
|
||||
BOOL
|
||||
__stdcall EgtSetCurveExtrusionFromGrid( int nId)
|
||||
{
|
||||
IGeomDB* pGeomDB = GetCurrGeomDB() ;
|
||||
VERIFY_GEOMDB( pGeomDB, FALSE)
|
||||
bool bOk = true ;
|
||||
// recupero il versore Z della griglia corrente (in globale)
|
||||
Vector3d vtExtrGlob = pGeomDB->GetGridFrame().VersZ() ;
|
||||
|
||||
// eseguo impostazione estrusione singola
|
||||
if ( nId != GDB_ID_SEL) {
|
||||
bOk = SetOneCurveExtrusionFromGrid( pGeomDB, nId, vtExtrGlob) ;
|
||||
}
|
||||
// eseguo impostazione estrusione dei selezionati
|
||||
else {
|
||||
int nI = pGeomDB->GetFirstSelectedObj() ;
|
||||
while ( nI != GDB_ID_NULL && bOk) {
|
||||
if ( ! SetOneCurveExtrusionFromGrid( pGeomDB, nI, vtExtrGlob))
|
||||
bOk = false ;
|
||||
// passo alla successiva
|
||||
nI = pGeomDB->GetNextSelectedObj() ;
|
||||
}
|
||||
}
|
||||
// se richiesto, salvo il comando Lua equivalente
|
||||
if ( IsCmdLog()) {
|
||||
string sLua = "EgtSetCurveExtrusionFromGrid(" + ( nId != GDB_ID_SEL ? ToString( nId) : "GDB_ID_SEL") + ")" +
|
||||
" -- Ok=" + ToString( bOk) ;
|
||||
LOG_INFO( GetCmdLogger(), sLua.c_str()) ;
|
||||
}
|
||||
// restituisco risultato
|
||||
return ( bOk ? TRUE : FALSE) ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
static bool
|
||||
__stdcall ModifyOneCurveThickness( IGeomDB* pGeomDB, int nId, double dThick)
|
||||
{
|
||||
// se gruppo, agisco sulle sole curve componenti
|
||||
if ( pGeomDB->GetGdbType( nId) == GDB_TY_GROUP) {
|
||||
PtrOwner<IGdbIterator> pIter( CreateGdbIterator( pGeomDB)) ;
|
||||
if ( IsNull( pIter))
|
||||
return FALSE ;
|
||||
return false ;
|
||||
bool bOk = true ;
|
||||
for ( bool bFound = pIter->GoToFirstInGroup( nId) ;
|
||||
bFound ;
|
||||
@@ -122,19 +277,49 @@ __stdcall EgtModifyCurveThickness( int nId, double dThick)
|
||||
if ( pCurve != nullptr && ! pCurve->SetThickness( dThick))
|
||||
bOk = false ;
|
||||
}
|
||||
return ( bOk ? TRUE : FALSE) ;
|
||||
return bOk ;
|
||||
}
|
||||
// se oggetto geometrico
|
||||
else {
|
||||
// recupero la curva
|
||||
ICurve* pCurve = GetCurve( pGeomDB->GetGeoObj( nId)) ;
|
||||
if ( pCurve == nullptr)
|
||||
return FALSE ;
|
||||
// ne modifico lo spessore
|
||||
return ( pCurve->SetThickness( dThick) ? TRUE : FALSE) ;
|
||||
// ne modifico lo spessore, se curva
|
||||
return ( pCurve == nullptr || pCurve->SetThickness( dThick)) ;
|
||||
}
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
BOOL
|
||||
__stdcall EgtModifyCurveThickness( int nId, double dThick)
|
||||
{
|
||||
IGeomDB* pGeomDB = GetCurrGeomDB() ;
|
||||
VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL)
|
||||
bool bOk = true ;
|
||||
// eseguo impostazione spessore singola
|
||||
if ( nId != GDB_ID_SEL) {
|
||||
bOk = ModifyOneCurveThickness( pGeomDB, nId, dThick) ;
|
||||
}
|
||||
// eseguo impostazione spessore dei selezionati
|
||||
else {
|
||||
int nI = pGeomDB->GetFirstSelectedObj() ;
|
||||
while ( nI != GDB_ID_NULL && bOk) {
|
||||
if ( ! ModifyOneCurveThickness( pGeomDB, nI, dThick))
|
||||
bOk = false ;
|
||||
// passo alla successiva
|
||||
nI = pGeomDB->GetNextSelectedObj() ;
|
||||
}
|
||||
}
|
||||
// se richiesto, salvo il comando Lua equivalente
|
||||
if ( IsCmdLog()) {
|
||||
string sLua = "EgtModifyCurveThickness(" + ( nId != GDB_ID_SEL ? ToString( nId) : "GDB_ID_SEL") + "," +
|
||||
ToString( dThick) + ")" +
|
||||
" -- Ok=" + ToString( bOk) ;
|
||||
LOG_INFO( GetCmdLogger(), sLua.c_str()) ;
|
||||
}
|
||||
// restituisco risultato
|
||||
return ( bOk ? TRUE : FALSE) ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
BOOL
|
||||
__stdcall EgtTrimCurveStartAtLen( int nId, double dLen)
|
||||
@@ -241,32 +426,37 @@ __stdcall EgtTrimExtendCurveByLen( int nId, double dLen, const double ptNear[3])
|
||||
VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL)
|
||||
// recupero la curva
|
||||
ICurve* pCurve = GetCurve( pGeomDB->GetGeoObj( nId)) ;
|
||||
if ( pCurve == nullptr)
|
||||
return FALSE ;
|
||||
bool bOk = ( pCurve != nullptr) ;
|
||||
// cerco l'estremo più vicino al punto passato
|
||||
Point3d ptStart, ptEnd ;
|
||||
if ( ! pCurve->GetStartPoint( ptStart) || ! pCurve->GetEndPoint( ptEnd))
|
||||
return FALSE ;
|
||||
if ( SqDist( ptStart, ptNear) < SqDist( ptEnd, ptNear)) {
|
||||
if ( dLen < - EPS_SMALL)
|
||||
return ( pCurve->TrimStartAtLen( - dLen) ? TRUE : FALSE) ;
|
||||
else if ( dLen > EPS_SMALL)
|
||||
return ( pCurve->ExtendStartByLen( dLen) ? TRUE : FALSE) ;
|
||||
else
|
||||
return TRUE ;
|
||||
}
|
||||
else {
|
||||
if ( dLen < - EPS_SMALL) {
|
||||
double dCrvLen ;
|
||||
if ( ! pCurve->GetLength( dCrvLen))
|
||||
return FALSE ;
|
||||
return ( pCurve->TrimEndAtLen( dCrvLen + dLen) ? TRUE : FALSE) ;
|
||||
if ( bOk && pCurve->GetStartPoint( ptStart) && pCurve->GetEndPoint( ptEnd)) {
|
||||
if ( SqDist( ptStart, ptNear) < SqDist( ptEnd, ptNear)) {
|
||||
if ( dLen < - EPS_SMALL)
|
||||
bOk = pCurve->TrimStartAtLen( - dLen) ;
|
||||
else if ( dLen > EPS_SMALL)
|
||||
bOk = pCurve->ExtendStartByLen( dLen) ;
|
||||
}
|
||||
else {
|
||||
if ( dLen < - EPS_SMALL) {
|
||||
double dCrvLen ;
|
||||
bOk = pCurve->GetLength( dCrvLen) && pCurve->TrimEndAtLen( dCrvLen + dLen) ;
|
||||
}
|
||||
else if ( dLen > EPS_SMALL)
|
||||
bOk = pCurve->ExtendEndByLen( dLen) ;
|
||||
}
|
||||
else if ( dLen > EPS_SMALL)
|
||||
return ( pCurve->ExtendEndByLen( dLen) ? TRUE : FALSE) ;
|
||||
else
|
||||
return TRUE ;
|
||||
}
|
||||
else
|
||||
bOk = false ;
|
||||
// se richiesto, salvo il comando Lua equivalente
|
||||
if ( IsCmdLog()) {
|
||||
string sLua = "EgtTrimExtendCurveByLen(" + ToString( nId) + "," +
|
||||
ToString( dLen) + ",{" +
|
||||
ToString( Point3d( ptNear)) + "})" +
|
||||
" -- Ok=" + ToString( bOk) ;
|
||||
LOG_INFO( GetCmdLogger(), sLua.c_str()) ;
|
||||
}
|
||||
// restituisco risultato
|
||||
return ( bOk ? TRUE : FALSE) ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
@@ -277,36 +467,47 @@ __stdcall EgtSplitCurveAtPoint( int nId, double ptOn[3])
|
||||
VERIFY_GEOMDB( pGeomDB, FALSE)
|
||||
// recupero la curva
|
||||
ICurve* pCurve = GetCurve( pGeomDB->GetGeoObj( nId)) ;
|
||||
if ( pCurve == nullptr)
|
||||
return FALSE ;
|
||||
bool bOk = ( pCurve != nullptr) ;
|
||||
// determino la posizione parametrica del punto sulla curva (con tolleranza)
|
||||
DistPointCurve dstPC( ptOn, *pCurve) ;
|
||||
int nFlag ;
|
||||
double dU ;
|
||||
if ( ! dstPC.GetParamAtMinDistPoint( 0, dU, nFlag) || nFlag != MDPCI_NORMAL)
|
||||
return FALSE ;
|
||||
// copio la curva
|
||||
int nCopyId = pGeomDB->Copy( nId, GDB_ID_NULL, nId, GDB_AFTER) ;
|
||||
if ( nCopyId == GDB_ID_NULL)
|
||||
return FALSE ;
|
||||
// tengo la prima parte dell'originale e la seconda parte della copia
|
||||
if ( ! pCurve->TrimEndAtParam( dU))
|
||||
return false ;
|
||||
return ( EgtTrimCurveStartAtParam( nCopyId, dU) ? TRUE : FALSE) ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
BOOL
|
||||
__stdcall EgtOffsetCurve( int nId, double dDist, int nType)
|
||||
{
|
||||
IGeomDB* pGeomDB = GetCurrGeomDB() ;
|
||||
VERIFY_GEOMDB( pGeomDB, FALSE)
|
||||
// recupero la curva
|
||||
ICurve* pCurve = GetCurve( pGeomDB->GetGeoObj( nId)) ;
|
||||
if ( pCurve == nullptr)
|
||||
return FALSE ;
|
||||
// eseguo l'offset
|
||||
return ( pCurve->SimpleOffset( dDist, nType) ? TRUE : FALSE) ;
|
||||
double dU = 0 ;
|
||||
if ( bOk) {
|
||||
DistPointCurve dstPC( ptOn, *pCurve) ;
|
||||
int nFlag ;
|
||||
if ( ! dstPC.GetParamAtMinDistPoint( 0, dU, nFlag) || nFlag != MDPCI_NORMAL)
|
||||
bOk = false ;
|
||||
}
|
||||
// verifico che il punto di taglio sia interno alla curva
|
||||
bool bIsInside = false ;
|
||||
if ( bOk) {
|
||||
Point3d ptStart ;
|
||||
Point3d ptEnd ;
|
||||
Point3d ptBreak ;
|
||||
if ( pCurve->GetStartPoint( ptStart) &&
|
||||
pCurve->GetEndPoint( ptEnd) &&
|
||||
pCurve->GetPointD1D2( dU, ICurve::FROM_MINUS, ptBreak)) {
|
||||
bIsInside = ! AreSamePointApprox( ptBreak, ptStart) &&
|
||||
! AreSamePointApprox( ptBreak, ptEnd) ;
|
||||
}
|
||||
}
|
||||
// se il punto di taglio è interno, devo realmente tagliare
|
||||
if ( bIsInside) {
|
||||
// copio la curva
|
||||
int nCopyId = GDB_ID_NULL ;
|
||||
if ( bOk && ( nCopyId = pGeomDB->Copy( nId, GDB_ID_NULL, nId, GDB_AFTER)) == GDB_ID_NULL)
|
||||
bOk = false ;
|
||||
// tengo la prima parte dell'originale e la seconda parte della copia
|
||||
bOk = bOk && pCurve->TrimEndAtParam( dU) ;
|
||||
bOk = bOk && ( EgtTrimCurveStartAtParam( nCopyId, dU) != FALSE) ;
|
||||
}
|
||||
// se richiesto, salvo il comando Lua equivalente
|
||||
if ( IsCmdLog()) {
|
||||
string sLua = "EgtSplitCurveAtPoint(" + ToString( nId) + ",{" +
|
||||
ToString( Point3d( ptOn)) + "})" +
|
||||
" -- Ok=" + ToString( bOk) ;
|
||||
LOG_INFO( GetCmdLogger(), sLua.c_str()) ;
|
||||
}
|
||||
// restituisco risultato
|
||||
return ( bOk ? TRUE : FALSE) ;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------
|
||||
@@ -405,27 +606,36 @@ __stdcall EgtModifyCurveArc3P( int nId, const double ptMid[3])
|
||||
|
||||
//-------------------------------------------------------------------------------
|
||||
BOOL
|
||||
__stdcall EgtSeparateCurveCompo( int nId)
|
||||
__stdcall EgtExplodeCurveCompo( int nId)
|
||||
{
|
||||
IGeomDB* pGeomDB = GetCurrGeomDB() ;
|
||||
VERIFY_GEOMDB( pGeomDB, FALSE)
|
||||
bool bOk = true ;
|
||||
// recupero la curva composita
|
||||
ICurveComposite* pCompo = GetCurveComposite( pGeomDB->GetGeoObj( nId)) ;
|
||||
if ( pCompo == nullptr)
|
||||
return FALSE ;
|
||||
bOk = false ;
|
||||
// estraggo tutte le curve
|
||||
ICurve* pCrv ;
|
||||
while ( ( pCrv = pCompo->RemoveFirstOrLastCurve( false)) != nullptr) {
|
||||
while ( bOk && ( pCrv = pCompo->RemoveFirstOrLastCurve( false)) != nullptr) {
|
||||
// inserisco la curva nello stesso gruppo e nello stesso posto del GeomDB
|
||||
int nCrvId = pGeomDB->InsertGeoObj( GDB_ID_NULL, nId, GDB_BEFORE, pCrv) ;
|
||||
if ( nCrvId == GDB_ID_NULL)
|
||||
return FALSE ;
|
||||
bOk = false ;
|
||||
// copio gli attributi
|
||||
if ( ! pGeomDB->CopyAttributes( nId, nCrvId))
|
||||
return FALSE ;
|
||||
bOk = false ;
|
||||
}
|
||||
// elimino la curva composita ormai vuota
|
||||
return ( pGeomDB->Erase( nId) ? TRUE : FALSE) ;
|
||||
bOk = bOk && pGeomDB->Erase( nId) ;
|
||||
// se richiesto, salvo il comando Lua equivalente
|
||||
if ( IsCmdLog()) {
|
||||
string sLua = "EgtExplodeCurveCompo(" + ToString( nId) + ")" +
|
||||
" -- Ok=" + ToString( bOk) ;
|
||||
LOG_INFO( GetCmdLogger(), sLua.c_str()) ;
|
||||
}
|
||||
// restituisco risultato
|
||||
return ( bOk ? TRUE : FALSE) ;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------
|
||||
@@ -434,38 +644,51 @@ __stdcall EgtExplodeCurveBezier( int nId, double dLinTol, BOOL bArcsVsLines)
|
||||
{
|
||||
IGeomDB* pGeomDB = GetCurrGeomDB() ;
|
||||
VERIFY_GEOMDB( pGeomDB, FALSE)
|
||||
bool bOk = true ;
|
||||
// recupero la curva di Bezier
|
||||
ICurveBezier* pCBezier = GetCurveBezier( pGeomDB->GetGeoObj( nId)) ;
|
||||
if ( pCBezier == nullptr)
|
||||
return FALSE ;
|
||||
bOk = false ;
|
||||
// eseguo l'approssimazione
|
||||
const double ANG_TOL_STD_DEG = 15 ;
|
||||
PtrOwner<ICurveComposite> pCC( CreateCurveComposite()) ;
|
||||
if ( IsNull( pCC))
|
||||
return FALSE ;
|
||||
if ( bArcsVsLines) { // con bi-archi
|
||||
PolyArc PA ;
|
||||
if ( ! pCBezier->ApproxWithArcs( dLinTol, ANG_TOL_STD_DEG, PA) ||
|
||||
! pCC->FromPolyArc( PA))
|
||||
return FALSE ;
|
||||
}
|
||||
else { // con linee
|
||||
PolyLine PL ;
|
||||
if ( ! pCBezier->ApproxWithLines( dLinTol, ANG_TOL_STD_DEG, PL) ||
|
||||
! pCC->FromPolyLine( PL))
|
||||
return FALSE ;
|
||||
if ( ! IsNull( pCC)) {
|
||||
if ( bArcsVsLines) { // con bi-archi
|
||||
PolyArc PA ;
|
||||
if ( ! pCBezier->ApproxWithArcs( dLinTol, ANG_TOL_STD_DEG, PA) ||
|
||||
! pCC->FromPolyArc( PA))
|
||||
bOk = false ;
|
||||
}
|
||||
else { // con linee
|
||||
PolyLine PL ;
|
||||
if ( ! pCBezier->ApproxWithLines( dLinTol, ANG_TOL_STD_DEG, PL) ||
|
||||
! pCC->FromPolyLine( PL))
|
||||
bOk = false ;
|
||||
}
|
||||
}
|
||||
else
|
||||
bOk = false ;
|
||||
// inserisco le curve elementari nel DB
|
||||
ICurve* pCrv ;
|
||||
while ( ( pCrv = pCC->RemoveFirstOrLastCurve( false)) != nullptr) {
|
||||
while ( bOk && ( pCrv = pCC->RemoveFirstOrLastCurve( false)) != nullptr) {
|
||||
// inserisco la curva nello stesso gruppo e nello stesso posto del GeomDB
|
||||
int nCrvId = pGeomDB->InsertGeoObj( GDB_ID_NULL, nId, GDB_BEFORE, pCrv) ;
|
||||
if ( nCrvId == GDB_ID_NULL)
|
||||
return FALSE ;
|
||||
bOk = false ;
|
||||
// copio gli attributi
|
||||
if ( ! pGeomDB->CopyAttributes( nId, nCrvId))
|
||||
return FALSE ;
|
||||
bOk = false ;
|
||||
}
|
||||
// elimino la curva di Bezier
|
||||
return ( pGeomDB->Erase( nId) ? TRUE : FALSE) ;
|
||||
bOk = bOk && pGeomDB->Erase( nId) ;
|
||||
// se richiesto, salvo il comando Lua equivalente
|
||||
if ( IsCmdLog()) {
|
||||
string sLua = "EgtExplodeCurveBezier(" + ToString( nId) + "," +
|
||||
ToString( dLinTol) + "," +
|
||||
( bArcsVsLines ? "true" : "false") + ")"
|
||||
" -- Ok=" + ToString( bOk) ;
|
||||
LOG_INFO( GetCmdLogger(), sLua.c_str()) ;
|
||||
}
|
||||
// restituisco risultato
|
||||
return ( bOk ? TRUE : FALSE) ;
|
||||
}
|
||||
Reference in New Issue
Block a user