EgtExecutor 2.3d3 :

- in AddCurveCompoCurve, AddCurveCompoLine, AddCurveCompoArcTg e AddCurveCompoArc2P aggiunto parametro per operare in coda o in testa (in lua è opzionale)
- in ExeRemoveCurveCompoCurve ora si libera correttamente la memoria delle curve.
This commit is contained in:
Dario Sassi
2021-04-12 07:43:20 +00:00
parent 84a721f594
commit 1a786dad93
3 changed files with 45 additions and 25 deletions
+19 -13
View File
@@ -1483,7 +1483,7 @@ ExeCloseCurveCompo( int nId)
//-------------------------------------------------------------------------------
bool
MyAddCurveCompoCurve( int nId, int nAddCrvId, bool bEraseOrig)
MyAddCurveCompoCurve( int nId, int nAddCrvId, bool bEraseOrig, bool bEndVsStart)
{
IGeomDB* pGeomDB = GetCurrGeomDB() ;
VERIFY_GEOMDB( pGeomDB, false)
@@ -1511,7 +1511,7 @@ MyAddCurveCompoCurve( int nId, int nAddCrvId, bool bEraseOrig)
if ( ! AreSameFrame( frSou, frLoc))
pCopCrv->LocToLoc( frSou, frLoc) ;
// aggiungo alla composita
if ( ! pCompo->AddCurve( Release( pCopCrv)))
if ( ! pCompo->AddCurve( Release( pCopCrv), bEndVsStart))
return false ;
// se richiesto, cancello la curva originale
if ( bEraseOrig)
@@ -1521,15 +1521,16 @@ MyAddCurveCompoCurve( int nId, int nAddCrvId, bool bEraseOrig)
//-------------------------------------------------------------------------------
bool
ExeAddCurveCompoCurve( int nId, int nAddCrvId, bool bEraseOrig)
ExeAddCurveCompoCurve( int nId, int nAddCrvId, bool bEraseOrig, bool bEndVsStart)
{
// eseguo
bool bOk = MyAddCurveCompoCurve( nId, nAddCrvId, bEraseOrig) ;
bool bOk = MyAddCurveCompoCurve( nId, nAddCrvId, bEraseOrig, bEndVsStart) ;
// se richiesto, salvo il comando Lua equivalente
if ( IsCmdLog()) {
string sLua = "EgtAddCurveCompoCurve(" + IdToString( nId) + "," +
IdToString( nAddCrvId) + "," +
( bEraseOrig ? "true" : "false") + ")" +
( bEraseOrig ? "true" : "false") + "," +
( bEndVsStart ? "true" : "false") + ")" +
" -- Ok=" + ToString( bOk) ;
LOG_INFO( GetCmdLogger(), sLua.c_str()) ;
}
@@ -1539,7 +1540,7 @@ ExeAddCurveCompoCurve( int nId, int nAddCrvId, bool bEraseOrig)
//-------------------------------------------------------------------------------
bool
ExeAddCurveCompoLine( int nId, const Point3d& ptP, int nRefType)
ExeAddCurveCompoLine( int nId, const Point3d& ptP, bool bEndVsStart, int nRefType)
{
IGeomDB* pGeomDB = GetCurrGeomDB() ;
VERIFY_GEOMDB( pGeomDB, false)
@@ -1553,12 +1554,13 @@ ExeAddCurveCompoLine( int nId, const Point3d& ptP, int nRefType)
// porto in locale il nuovo punto
Point3d ptPL = GetPointLocal( pGeomDB, ptP, nRefType, frLoc) ;
// eseguo la modifica
bOk = bOk && pCompo->AddLine( ptPL) ;
bOk = bOk && pCompo->AddLine( ptPL, bEndVsStart) ;
ExeSetModified() ;
// se richiesto, salvo il comando Lua equivalente
if ( IsCmdLog()) {
string sLua = "EgtAddCurveCompoLine(" + ToString( nId) + "," +
ToString( ptP) + "}," +
( bEndVsStart ? "true" : "false") + "," +
RefTypeToString( nRefType) + ")" +
" -- Ok=" + ToString( bOk) ;
LOG_INFO( GetCmdLogger(), sLua.c_str()) ;
@@ -1569,7 +1571,7 @@ ExeAddCurveCompoLine( int nId, const Point3d& ptP, int nRefType)
//-------------------------------------------------------------------------------
bool
ExeAddCurveCompoArcTg( int nId, const Point3d& ptP, int nRefType)
ExeAddCurveCompoArcTg( int nId, const Point3d& ptP, bool bEndVsStart, int nRefType)
{
IGeomDB* pGeomDB = GetCurrGeomDB() ;
VERIFY_GEOMDB( pGeomDB, false)
@@ -1583,12 +1585,13 @@ ExeAddCurveCompoArcTg( int nId, const Point3d& ptP, int nRefType)
// porto in locale il nuovo punto
Point3d ptPL = GetPointLocal( pGeomDB, ptP, nRefType, frLoc) ;
// eseguo la modifica
bOk = bOk && pCompo->AddArcTg( ptPL) ;
bOk = bOk && pCompo->AddArcTg( ptPL, bEndVsStart) ;
ExeSetModified() ;
// se richiesto, salvo il comando Lua equivalente
if ( IsCmdLog()) {
string sLua = "EgtAddCurveCompoArcTg(" + ToString( nId) + ",{" +
ToString( ptP) + "}," +
( bEndVsStart ? "true" : "false") + "," +
RefTypeToString( nRefType) + ")" +
" -- Ok=" + ToString( bOk) ;
LOG_INFO( GetCmdLogger(), sLua.c_str()) ;
@@ -1599,7 +1602,7 @@ ExeAddCurveCompoArcTg( int nId, const Point3d& ptP, int nRefType)
//-------------------------------------------------------------------------------
bool
ExeAddCurveCompoArc2P( int nId, const Point3d& ptMid, const Point3d& ptP, int nRefType)
ExeAddCurveCompoArc2P( int nId, const Point3d& ptMid, const Point3d& ptP, bool bEndVsStart, int nRefType)
{
IGeomDB* pGeomDB = GetCurrGeomDB() ;
VERIFY_GEOMDB( pGeomDB, false)
@@ -1614,13 +1617,14 @@ ExeAddCurveCompoArc2P( int nId, const Point3d& ptMid, const Point3d& ptP, int nR
Point3d ptMidL = GetPointLocal( pGeomDB, ptMid, nRefType, frLoc) ;
Point3d ptPL = GetPointLocal( pGeomDB, ptP, nRefType, frLoc) ;
// eseguo la modifica
bOk = bOk && pCompo->AddArc2P( ptMidL, ptPL) ;
bOk = bOk && pCompo->AddArc2P( ptMidL, ptPL, bEndVsStart) ;
ExeSetModified() ;
// se richiesto, salvo il comando Lua equivalente
if ( IsCmdLog()) {
string sLua = "EgtAddCurveCompoArc2P(" + ToString( nId) + ",{" +
ToString( ptMid) + "},{" +
ToString( ptP) + "}," +
( bEndVsStart ? "true" : "false") + "," +
RefTypeToString( nRefType) + ")" +
" -- Ok=" + ToString( bOk) ;
LOG_INFO( GetCmdLogger(), sLua.c_str()) ;
@@ -1640,11 +1644,13 @@ ExeRemoveCurveCompoCurve( int nId, bool bLast)
ICurveComposite* pCompo = GetCurveComposite( pGeomDB->GetGeoObj( nId)) ;
bOk = bOk && ( pCompo != nullptr) ;
// eseguo la modifica
bOk = bOk && pCompo->RemoveFirstOrLastCurve( bLast) ;
if ( bOk)
delete( pCompo->RemoveFirstOrLastCurve( bLast)) ;
ExeSetModified() ;
// se richiesto, salvo il comando Lua equivalente
if ( IsCmdLog()) {
string sLua = "EgtRemoveCurveCompoCurve(" + ToString( nId) + ")" +
string sLua = "EgtRemoveCurveCompoCurve(" + ToString( nId) + "," +
( bLast ? "true" : "false") + ")" +
" -- Ok=" + ToString( bOk) ;
LOG_INFO( GetCmdLogger(), sLua.c_str()) ;
}
BIN
View File
Binary file not shown.
+26 -12
View File
@@ -574,16 +574,18 @@ LuaCloseCurveCompo( lua_State* L)
static int
LuaAddCurveCompoCurve( lua_State* L)
{
// 2 o 3 parametri : Id, AddCrvId [, bEraseOrig]
// 2, 3 o 4 parametri : Id, AddCrvId [, bEraseOrig [, bEndVsStart]]
int nId ;
LuaCheckParam( L, 1, nId)
int nAddCrvId ;
LuaCheckParam( L, 2, nAddCrvId)
bool bEraseOrig = true ;
LuaGetParam( L, 3, bEraseOrig) ;
bool bEndVsStart = true ;
if ( LuaGetParam( L, 3, bEraseOrig))
LuaGetParam( L, 4, bEndVsStart) ;
LuaClearStack( L) ;
// aggiungo la curva in coda alla curva composita
bool bOk = ExeAddCurveCompoCurve( nId, nAddCrvId, bEraseOrig) ;
bool bOk = ExeAddCurveCompoCurve( nId, nAddCrvId, bEraseOrig, bEndVsStart) ;
LuaSetParam( L, bOk) ;
return 1 ;
}
@@ -592,16 +594,20 @@ LuaAddCurveCompoCurve( lua_State* L)
static int
LuaAddCurveCompoLine( lua_State* L)
{
// 2 o 3 parametri : Id, ptNew [, nRefType]
// 2, 3 o 4 parametri : Id, ptNew [, bEndVsStart] [, nRefType]
int nId ;
LuaCheckParam( L, 1, nId)
Point3d ptNew ;
LuaCheckParam( L, 2, ptNew)
bool bEndVsStart = true ;
int nRefType = RTY_DEFAULT ;
LuaGetParam( L, 3, nRefType) ;
if ( LuaGetParam( L, 3, bEndVsStart))
LuaGetParam( L, 4, nRefType) ;
else
LuaGetParam( L, 3, nRefType) ;
LuaClearStack( L) ;
// aggiungo una linea in coda alla curva composita
bool bOk = ExeAddCurveCompoLine( nId, ptNew, nRefType) ;
bool bOk = ExeAddCurveCompoLine( nId, ptNew, bEndVsStart, nRefType) ;
LuaSetParam( L, bOk) ;
return 1 ;
}
@@ -610,16 +616,20 @@ LuaAddCurveCompoLine( lua_State* L)
static int
LuaAddCurveCompoArcTg( lua_State* L)
{
// 2 o 3 parametri : Id, ptNew [, nRefType]
// 2, 3 o 4 parametri : Id, ptNew [, bEndVsStart] [, nRefType]
int nId ;
LuaCheckParam( L, 1, nId)
Point3d ptNew ;
LuaCheckParam( L, 2, ptNew)
bool bEndVsStart = true ;
int nRefType = RTY_DEFAULT ;
LuaGetParam( L, 3, nRefType) ;
if ( LuaGetParam( L, 3, bEndVsStart))
LuaGetParam( L, 4, nRefType) ;
else
LuaGetParam( L, 3, nRefType) ;
LuaClearStack( L) ;
// aggiungo un arco tangente in coda alla curva composita
bool bOk = ExeAddCurveCompoArcTg( nId, ptNew, nRefType) ;
bool bOk = ExeAddCurveCompoArcTg( nId, ptNew, bEndVsStart, nRefType) ;
LuaSetParam( L, bOk) ;
return 1 ;
}
@@ -628,18 +638,22 @@ LuaAddCurveCompoArcTg( lua_State* L)
static int
LuaAddCurveCompoArc2P( lua_State* L)
{
// 3 o 4 parametri : Id, ptMid, ptNew [, nRefType]
// 3, 4 o 5 parametri : Id, ptMid, ptNew [, bEndVsStart] [, nRefType]
int nId ;
LuaCheckParam( L, 1, nId)
Point3d ptMid ;
LuaCheckParam( L, 2, ptMid)
Point3d ptNew ;
LuaCheckParam( L, 3, ptNew)
bool bEndVsStart = true ;
int nRefType = RTY_DEFAULT ;
if ( LuaGetParam( L, 4, bEndVsStart))
LuaGetParam( L, 5, nRefType) ;
else
LuaGetParam( L, 4, nRefType) ;
LuaClearStack( L) ;
// aggiungo arco per 3P in coda alla curva composita
bool bOk = ExeAddCurveCompoArc2P( nId, ptMid, ptNew, nRefType) ;
bool bOk = ExeAddCurveCompoArc2P( nId, ptMid, ptNew, bEndVsStart, nRefType) ;
LuaSetParam( L, bOk) ;
return 1 ;
}
@@ -648,7 +662,7 @@ LuaAddCurveCompoArc2P( lua_State* L)
static int
LuaRemoveCurveCompoCurve( lua_State* L)
{
// 1 o 2 parametri : Id, [, bLast]
// 1 o 2 parametri : Id [, bLast]
int nId ;
LuaCheckParam( L, 1, nId)
bool bLast ;