EgtExecutor 1.6f3 :

- eliminata ExeCreateCurveCompoByApprox
- le diverse ExeApproxCurve riunite in una sola
- aggiunta ExeMergeCurvesInCurveCompo
- riportate le medesime modifiche in lua.
This commit is contained in:
Dario Sassi
2015-06-21 17:01:26 +00:00
parent 7f9a18849b
commit ff53dcb8e3
8 changed files with 99 additions and 186 deletions
+13
View File
@@ -113,6 +113,19 @@ OffsTypeToString( int nOffsType)
}
}
//----------------------------------------------------------------------------
const char*
ApproxTypeToString( int nApprType)
{
switch ( nApprType) {
case APP_LINES : return "GDB_CA.LINES" ;
case APP_LEFT_LINES : return "GDB_CA.LEFT_LINES" ;
case APP_RIGHT_LINES : return "GDB_CA.RIGHT_LINES" ;
default :
case APP_ARCS : return "GDB_CA.ARCS" ;
}
}
//----------------------------------------------------------------------------
const char*
RawPartCornerPosToString( int nFlag)
+3 -1
View File
@@ -29,8 +29,10 @@ const char* InsToString( int nIns) ;
const char* RefTypeToString( int nRefType) ;
// Posizione inserimento testo
const char* ETxtInsPosToString( int nETxtInsPos) ;
// tipo di offset di curva
// Tipo di offset di curva
const char* OffsTypeToString( int nOffsType) ;
// Tipo di approssimazione di curva
const char* ApproxTypeToString( int nApprType) ;
// Flag per posizione corner rispetto a grezzo
const char* RawPartCornerPosToString( int nFlag) ;
// Flag per posizione center rispetto a grezzo
+6 -57
View File
@@ -929,6 +929,12 @@ ExeCreateCurveArc3P( int nParentId, const Point3d& ptP1,
bOk = bOk && ! ( IsNull( pCrv)) ;
// assegno il versore estrusione
bOk = bOk && pCrv->SetExtrusion( vtExtrL) ;
// se arco, verifico che normale al suo piano e versore estrusione non siano controversi
if ( bOk && pCrv->GetType() == CRV_ARC) {
ICurveArc* pArc = GetCurveArc( Get( pCrv)) ;
if ( ( pArc->GetNormVersor() * vtExtrL) < 0)
pArc->InvertN() ;
}
// inserisco l'arco nel DB
int nId = ( bOk ? pGeomDB->AddGeoObj( GDB_ID_NULL, nParentId, Release( pCrv)) : GDB_ID_NULL) ;
ExeSetModified() ;
@@ -1658,63 +1664,6 @@ ExeCreateCurveCompoFromPointBulges( int nParentId, const PolyArc& PA, int nRefTy
return nId ;
}
//-------------------------------------------------------------------------------
int
ExeCreateCurveCompoByApprox( int nParentId, int nSouId, bool bArcsVsLines, double dLinTol)
{
IGeomDB* pGeomDB = GetCurrGeomDB() ;
VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL)
bool bOk = true ;
// recupero il riferimento di inserimento
Frame3d frEnt ;
bOk = bOk && pGeomDB->GetGroupGlobFrame( nParentId, frEnt) ;
// recupero la curva in locale
CurveLocal CrvLoc( pGeomDB, nSouId, frEnt) ;
bOk = bOk && ( CrvLoc.Get() != nullptr) ;
// eseguo l'approssimazione
PtrOwner<ICurveComposite> pCC( CreateCurveComposite()) ;
bOk = bOk && ! IsNull( pCC) ;
const double ANG_TOL_STD_DEG = 15 ;
if ( ! bArcsVsLines) { // con linee
PolyLine PL ;
bOk = bOk && CrvLoc.Get()->ApproxWithLines( dLinTol, ANG_TOL_STD_DEG, PL) && pCC->FromPolyLine( PL) ;
}
else { // con bi-archi
PolyArc PA ;
bOk = bOk && CrvLoc.Get()->ApproxWithArcs( dLinTol, ANG_TOL_STD_DEG, PA) && pCC->FromPolyArc( PA) ;
}
// copio estrusione e spessore della curva sorgente
const ICurve* pSouCrv = GetCurve( pGeomDB->GetGeoObj( nSouId)) ;
if ( bOk && pSouCrv != nullptr) {
// recupero estrusione e spessore
Vector3d vtExtr ;
pSouCrv->GetExtrusion( vtExtr) ;
double dThick ;
pSouCrv->GetThickness( dThick) ;
// sistemo per eventuale cambio di riferimento
Frame3d frSou ;
bOk = bOk && pGeomDB->GetGlobFrame( nSouId, frSou) ;
vtExtr.LocToLoc( frSou, frEnt) ;
// assegno
pCC->SetExtrusion( vtExtr) ;
pCC->SetThickness( dThick) ;
}
// inserisco la curva composita nel DB
int nId = ( bOk ? pGeomDB->AddGeoObj( GDB_ID_NULL, nParentId, Release( pCC)) : GDB_ID_NULL) ;
ExeSetModified() ;
// se richiesto, salvo il comando Lua equivalente
if ( IsCmdLog()) {
string sLua = "EgtCurveCompoByApprox(" + ToString( nParentId) + "," +
ToString( nSouId) + "," +
( bArcsVsLines ? "GDB_CA.ARCS" : "GDB_CA.LINES") + "," +
ToString( dLinTol) + ")" +
" -- Id=" + ToString( nId) ;
LOG_INFO( GetCmdLogger(), sLua.c_str()) ;
}
// restituisco l'identificativo della nuova entità
return nId ;
}
//-------------------------------------------------------------------------------
int
ExeCreateRectangle3P( int nParentId, const Point3d& ptIni,
+47 -69
View File
@@ -469,23 +469,6 @@ ExeTrimExtendCurveByLen( int nId, double dLen, const Point3d& ptNear, int nRefTy
bOk = pCurve->ExtendEndByLen( dLen) ;
}
}
//Point3d ptStart, ptEnd ;
//if ( bOk && pCurve->GetStartPoint( ptStart) && pCurve->GetEndPoint( ptEnd)) {
// if ( SqDist( ptStart, ptNearL) < SqDist( ptEnd, ptNearL)) {
// 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
bOk = false ;
ExeSetModified() ;
@@ -764,76 +747,71 @@ ExeExplodeCurveCompo( int nId, int* pnCount)
}
//-------------------------------------------------------------------------------
int
ExeApproxCurveArc( int nId, double dLinTol)
bool
ExeMergeCurvesInCurveCompo( int nId, double dLinTol)
{
IGeomDB* pGeomDB = GetCurrGeomDB() ;
VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL)
// recupero l'arco
ICurveArc* pArc = GetCurveArc( pGeomDB->GetGeoObj( nId)) ;
bool bOk = ( pArc != nullptr) ;
// eseguo l'approssimazione con segmenti di linea
// recupero la curva composita
ICurveComposite* pCompo = GetCurveComposite( pGeomDB->GetGeoObj( nId)) ;
bool bOk = ( pCompo != nullptr) ;
// lancio il merge delle curve componenti
const double ANG_TOL_STD_DEG = 15 ;
bOk = bOk && pCompo->MergeCurves( dLinTol, ANG_TOL_STD_DEG) ;
ExeSetModified() ;
// se richiesto, salvo il comando Lua equivalente
if ( IsCmdLog()) {
string sLua = "EgtMergeCurvesInCurveCompo(" + ToString( nId) + ")" +
" -- Ok=" + ToString( bOk) ;
LOG_INFO( GetCmdLogger(), sLua.c_str()) ;
}
return bOk ;
}
//-------------------------------------------------------------------------------
int
ExeApproxCurve( int nId, int nApprType, double dLinTol)
{
IGeomDB* pGeomDB = GetCurrGeomDB() ;
VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL)
// recupero la curva
ICurve* pCurve = GetCurve( pGeomDB->GetGeoObj( nId)) ;
bool bOk = ( pCurve != nullptr) ;
// eseguo l'approssimazione
const double ANG_TOL_MAX_DEG = 90 ;
PtrOwner<ICurveComposite> pCC( CreateCurveComposite()) ;
bOk = bOk && ! IsNull( pCC) ;
PolyLine PL ;
bOk = bOk && pArc->ApproxWithLines( dLinTol, ANG_TOL_STD_DEG, PL) && pCC->FromPolyLine( PL) ;
if ( nApprType == APP_LINES || nApprType == APP_LEFT_LINES || nApprType == APP_RIGHT_LINES) {
PolyLine PL ;
bOk = bOk && pCurve->ApproxWithLines( dLinTol, ANG_TOL_MAX_DEG, nApprType, PL) && pCC->FromPolyLine( PL) ;
}
else { // con bi-archi
PolyArc PA ;
bOk = bOk && pCurve->ApproxWithArcs( dLinTol, ANG_TOL_MAX_DEG, PA) && pCC->FromPolyArc( PA) ;
}
// copio estrusione e spessore
Vector3d vtExtr ;
if ( bOk && pCurve->GetExtrusion( vtExtr))
pCC->SetExtrusion( vtExtr) ;
double dThick ;
if ( bOk && pCurve->GetThickness( dThick))
pCC->SetThickness(dThick) ;
// inserisco la curva composita nello stesso posto del GeomDB
int nCrvId = ( bOk ? pGeomDB->InsertGeoObj( GDB_ID_NULL, nId, GDB_BEFORE, Release( pCC)) : GDB_ID_NULL) ;
bOk = bOk && ( nCrvId != GDB_ID_NULL) ;
// copio gli attributi
bOk = bOk && pGeomDB->CopyAttributes( nId, nCrvId) ;
// elimino l'arco
// elimino la curva originale
bOk = bOk && pGeomDB->Erase( nId) ;
ExeSetModified() ;
// se richiesto, salvo il comando Lua equivalente
if ( IsCmdLog()) {
string sLua = "EgtApproxCurveArc(" + ToString( nId) + "," +
ToString( dLinTol) + ")" +
string sLua = "EgtApproxCurve(" + ToString( nId) + "," +
ApproxTypeToString( nApprType) + "," +
ToString( dLinTol) + ")" +
" -- Id=" + ToString( nCrvId) ;
LOG_INFO( GetCmdLogger(), sLua.c_str()) ;
}
// restituisco risultato
return nCrvId ;
}
//-------------------------------------------------------------------------------
int
ExeApproxCurveBezier( int nId, bool bArcsVsLines, double dLinTol)
{
IGeomDB* pGeomDB = GetCurrGeomDB() ;
VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL)
// recupero la curva di Bezier
ICurveBezier* pCBezier = GetCurveBezier( pGeomDB->GetGeoObj( nId)) ;
bool bOk = ( pCBezier != nullptr) ;
// eseguo l'approssimazione
const double ANG_TOL_STD_DEG = 15 ;
PtrOwner<ICurveComposite> pCC( CreateCurveComposite()) ;
bOk = bOk && ! IsNull( pCC) ;
if ( bArcsVsLines) { // con bi-archi
PolyArc PA ;
bOk = bOk && pCBezier->ApproxWithArcs( dLinTol, ANG_TOL_STD_DEG, PA) && pCC->FromPolyArc( PA) ;
}
else { // con linee
PolyLine PL ;
bOk = bOk && pCBezier->ApproxWithLines( dLinTol, ANG_TOL_STD_DEG, PL) && pCC->FromPolyLine( PL) ;
}
// inserisco la curva composita nello stesso posto del GeomDB
int nCrvId = ( bOk ? pGeomDB->InsertGeoObj( GDB_ID_NULL, nId, GDB_BEFORE, Release( pCC)) : GDB_ID_NULL) ;
bOk = bOk && ( nCrvId != GDB_ID_NULL) ;
// copio gli attributi
bOk = bOk && pGeomDB->CopyAttributes( nId, nCrvId) ;
// elimino la curva di Bezier
bOk = bOk && pGeomDB->Erase( nId) ;
ExeSetModified() ;
// se richiesto, salvo il comando Lua equivalente
if ( IsCmdLog()) {
string sLua = "EgtApproxCurveBezier(" + ToString( nId) + "," +
( bArcsVsLines ? "GDB_CA.ARCS" : "GDB_CA.LINES") + "," +
ToString( dLinTol) + ")" +
" -- Id=" + ToString( nCrvId) ;
LOG_INFO( GetCmdLogger(), sLua.c_str()) ;
}
// restituisco risultato
return nCrvId ;
}
BIN
View File
Binary file not shown.
-26
View File
@@ -664,31 +664,6 @@ LuaCreateCurveCompoFromPointBulges( lua_State* L)
return 1 ;
}
//-------------------------------------------------------------------------------
static int
LuaCreateCurveCompoByApprox( lua_State* L)
{
// 3 o 4 parametri : ParentId, nSouId, nArcsVsLines [, dLinTol]
int nParentId ;
LuaCheckParam( L, 1, nParentId)
int nSouId ;
LuaCheckParam( L, 2, nSouId)
int nTemp ;
LuaCheckParam( L, 3, nTemp)
bool bArcsVsLines = ( nTemp != 0) ;
double dLinTol = 0.01 ;
LuaGetParam( L, 4, dLinTol) ;
LuaClearStack( L) ;
// creo la curva composita
int nId = ExeCreateCurveCompoByApprox( nParentId, nSouId, bArcsVsLines, dLinTol) ;
// restituisco il risultato
if ( nId != GDB_ID_NULL)
LuaSetReturn( L, nId) ;
else
LuaSetReturn( L) ;
return 1 ;
}
//-------------------------------------------------------------------------------
static int
LuaCreateRectangle3P( lua_State* L)
@@ -827,7 +802,6 @@ LuaInstallGdbCreateCurve( LuaMgr& luaMgr)
bOk = bOk && luaMgr.RegisterFunction( "EgtCurveCompoByChain", LuaCreateCurveCompoByChain) ;
bOk = bOk && luaMgr.RegisterFunction( "EgtCurveCompoFromPoints", LuaCreateCurveCompoFromPoints) ;
bOk = bOk && luaMgr.RegisterFunction( "EgtCurveCompoFromPointBulges", LuaCreateCurveCompoFromPointBulges) ;
bOk = bOk && luaMgr.RegisterFunction( "EgtCurveCompoByApprox", LuaCreateCurveCompoByApprox) ;
bOk = bOk && luaMgr.RegisterFunction( "EgtRectangle3P", LuaCreateRectangle3P) ;
bOk = bOk && luaMgr.RegisterFunction( "EgtPolygonFromRadius", LuaCreatePolygonFromRadius) ;
bOk = bOk && luaMgr.RegisterFunction( "EgtPolygonFromApothem", LuaCreatePolygonFromApothem) ;
+27 -31
View File
@@ -286,6 +286,27 @@ LuaSplitCurveAtPoint( lua_State* L)
return 1 ;
}
//-------------------------------------------------------------------------------
static int
LuaApproxCurve( lua_State* L)
{
// 2 o 3 parametri : Id, nApprType [, dLinTol]
int nId ;
LuaCheckParam( L, 1, nId)
int nApprType ;
LuaCheckParam( L, 2, nApprType)
double dLinTol = 0.01 ;
LuaGetParam( L, 3, dLinTol) ;
LuaClearStack( L) ;
// approssimazione della curva con rette
int nNewId = ExeApproxCurve( nId, nApprType, dLinTol) ;
if ( nNewId != GDB_ID_NULL)
LuaSetReturn( L, nNewId) ;
else
LuaSetReturn( L) ;
return 1 ;
}
//-------------------------------------------------------------------------------
static int
LuaModifyCurveArcRadius( lua_State* L)
@@ -323,7 +344,7 @@ LuaExplodeCurveCompo( lua_State* L)
//-------------------------------------------------------------------------------
static int
LuaApproxCurveArc( lua_State* L)
LuaMergeCurvesInCurveCompo( lua_State* L)
{
// 1 o 2 parametri : Id [, dLinTol]
int nId ;
@@ -331,34 +352,9 @@ LuaApproxCurveArc( lua_State* L)
double dLinTol = 0.01 ;
LuaGetParam( L, 2, dLinTol) ;
LuaClearStack( L) ;
// approssimazione dell'arco con rette
int nNewId = ExeApproxCurveArc( nId, dLinTol) ;
if ( nNewId != GDB_ID_NULL)
LuaSetReturn( L, nNewId) ;
else
LuaSetReturn( L) ;
return 1 ;
}
//-------------------------------------------------------------------------------
static int
LuaApproxCurveBezier( lua_State* L)
{
// 2 o 3 parametri : Id, nArcsVsLines [, dLinTol]
int nId ;
LuaCheckParam( L, 1, nId)
int nTemp ;
LuaCheckParam( L, 2, nTemp)
bool bArcsVsLines = ( nTemp != 0) ;
double dLinTol = 0.01 ;
LuaGetParam( L, 3, dLinTol) ;
LuaClearStack( L) ;
// approssimazione della curva di Bezier con archi o rette
int nNewId = ExeApproxCurveBezier( nId, bArcsVsLines, dLinTol) ;
if ( nNewId != GDB_ID_NULL)
LuaSetReturn( L, nNewId) ;
else
LuaSetReturn( L) ;
// esplosione della curva composita
bool bOk = ExeMergeCurvesInCurveCompo( nId, dLinTol) ;
LuaSetReturn( L, bOk) ;
return 1 ;
}
@@ -382,9 +378,9 @@ LuaInstallGdbModifyCurve( LuaMgr& luaMgr)
bOk = bOk && luaMgr.RegisterFunction( "EgtTrimExtendCurveByLen", LuaTrimExtendCurveByLen) ;
bOk = bOk && luaMgr.RegisterFunction( "EgtSplitCurve", LuaSplitCurve) ;
bOk = bOk && luaMgr.RegisterFunction( "EgtSplitCurveAtPoint", LuaSplitCurveAtPoint) ;
bOk = bOk && luaMgr.RegisterFunction( "EgtApproxCurve", LuaApproxCurve) ;
bOk = bOk && luaMgr.RegisterFunction( "EgtModifyCurveArcRadius", LuaModifyCurveArcRadius) ;
bOk = bOk && luaMgr.RegisterFunction( "EgtExplodeCurveCompo", LuaExplodeCurveCompo) ;
bOk = bOk && luaMgr.RegisterFunction( "EgtApproxCurveArc", LuaApproxCurveArc) ;
bOk = bOk && luaMgr.RegisterFunction( "EgtApproxCurveBezier", LuaApproxCurveBezier) ;
bOk = bOk && luaMgr.RegisterFunction( "EgtMergeCurvesInCurveCompo", LuaMergeCurvesInCurveCompo) ;
return bOk ;
}
+3 -2
View File
@@ -43,9 +43,10 @@ LuaSetDefaultMaterial( lua_State* L)
static int
LuaSetGridFrame( lua_State* L)
{
// 1 parametro : Frame
// 1 o nessun parametro : [Frame]
Frame3d frFrame ;
LuaCheckParam( L, 1, frFrame) ;
if ( lua_gettop( L) >= 1)
LuaCheckParam( L, 1, frFrame) ;
LuaClearStack( L) ;
// imposto il riferimento della Griglia (o CPlane)
bool bOk = ( ExeSetGridFrame( frFrame)) ;