EgtExecutor 1.6g7 :

- aggiunte ExeCreateCurveCompoByApproximation e la corrispondente per LUA_GdbCreateCurve.cpp
- corretta ExeCurveDomain
This commit is contained in:
Dario Sassi
2015-07-27 13:35:47 +00:00
parent de05786c53
commit b19dc441e7
5 changed files with 90 additions and 8 deletions
+3 -3
View File
@@ -143,10 +143,10 @@ const char*
InterpTypeToString( int nIntpType)
{
switch ( nIntpType) {
case ITT_AKIMA : return "GDB_PI.AKIMA" ;
case ITT_ARCS : return "GDB_PI.ARCS" ;
default :
case ITT_AKIMA_CORNER : return "GDB_PI.AKIMA_CORNER" ;
case ITT_BESSEL : return "GDB_PI.BESSEL" ;
case ITT_ARCS_CORNER : return "GDB_PI.ARCS_CORNER" ;
case ITT_CUBICS : return "GDB_PI.CUBICS" ;
}
}
+55 -4
View File
@@ -37,6 +37,7 @@
#include "/EgtDev/Include/EgkCurveComposite.h"
#include "/EgtDev/Include/EgkChainCurves.h"
#include "/EgtDev/Include/EGkCurveByInterp.h"
#include "/EgtDev/Include/EGkCurveByApprox.h"
#include "/EgtDev/Include/EgkSurfTriMesh.h"
#include "/EgtDev/Include/EGkDistPointCurve.h"
#include "/EgtDev/Include/EGkStringUtils3d.h"
@@ -1743,23 +1744,21 @@ ExeCreateCurveCompoByInterpolation( int nParentId, const PolyLine& PL, int nType
// assegno metodo di interpolazione e tipo del risultato
int nMethod = CurveByInterp::AKIMA_CORNER ;
int nCrvType = CurveByInterp::BIARCS ;
if ( nType == ITT_AKIMA) {
if ( nType == ITT_ARCS) {
nMethod = CurveByInterp::AKIMA ;
nCrvType = CurveByInterp::BIARCS ;
}
else if ( nType == ITT_BESSEL) {
else if ( nType == ITT_CUBICS) {
nMethod = CurveByInterp::BESSEL ;
nCrvType = CurveByInterp::CUBIC_BEZIERS ;
}
// oggetto interpolatore
CurveByInterp crvByInterp ;
crvByInterp.Start() ;
Point3d ptP ;
for ( bool bFound = PL.GetFirstPoint( ptP) ;
bFound ;
bFound = PL.GetNextPoint( ptP))
crvByInterp.AddPoint( ptP) ;
crvByInterp.End() ;
PtrOwner<ICurve> pCrvCompo( crvByInterp.GetCurve( nMethod, nType)) ;
bOk = bOk && ! IsNull( pCrvCompo) ;
// assegno il versore estrusione
@@ -1791,6 +1790,58 @@ ExeCreateCurveCompoByInterpolation( int nParentId, const PolyLine& PL, int nType
return nId ;
}
//-------------------------------------------------------------------------------
int
ExeCreateCurveCompoByApproximation( int nParentId, const PolyLine& PL, int nType, double dLinTol, int nRefType)
{
IGeomDB* pGeomDB = GetCurrGeomDB() ;
VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL)
nParentId = AdjustId( nParentId) ;
bool bOk = true ;
// recupero il riferimento del gruppo destinazione
Frame3d frDest ;
bOk = bOk && pGeomDB->GetGroupGlobFrame( nParentId, frDest) ;
// eseguo approssimazione
const double ANG_TOL_STD_DEG = 15 ;
const double LIN_FEA_STD = 20 ;
CurveByApprox crvByApprox ;
Point3d ptP ;
for ( bool bFound = PL.GetFirstPoint( ptP) ;
bFound ;
bFound = PL.GetNextPoint( ptP))
crvByApprox.AddPoint( ptP) ;
PtrOwner<ICurve> pCrvCompo( crvByApprox.GetCurve( nType, dLinTol, ANG_TOL_STD_DEG, LIN_FEA_STD)) ;
bOk = bOk && ! IsNull( pCrvCompo) ;
// assegno il versore estrusione
bOk = bOk && pCrvCompo->SetExtrusion( Z_AX) ;
// eventuale trasformazione per riferimento di espressione dei punti
if ( bOk && nRefType == RTY_GLOB)
pCrvCompo->ToLoc( frDest) ;
else if ( bOk && nRefType == RTY_GRID)
pCrvCompo->LocToLoc( pGeomDB->GetGridFrame(), frDest) ;
// inserisco la curva composita nel DB
int nId = ( bOk ? pGeomDB->AddGeoObj( GDB_ID_NULL, nParentId, Release( pCrvCompo)) : GDB_ID_NULL) ;
ExeSetModified() ;
// se richiesto, salvo il comando Lua equivalente
if ( IsCmdLog()) {
string sPnt ;
Point3d ptP ;
if ( PL.GetFirstPoint( ptP))
sPnt += "{" + ToString( ptP) + "}" ;
while ( PL.GetNextPoint( ptP))
sPnt += ",{" + ToString( ptP) + "}" ;
string sLua = "EgtCurveCompoByApproximation(" + IdToString( nParentId) + ",{" +
sPnt + "}," +
InterpTypeToString( nType) + "," +
ToString( dLinTol) + "," +
RefTypeToString( nRefType) + ")" +
" -- Id=" + ToString( nId) ;
LOG_INFO( GetCmdLogger(), sLua.c_str()) ;
}
// restituisco l'identificativo della nuova entità
return nId ;
}
//-------------------------------------------------------------------------------
int
ExeCreateCurveCompoFromPoints( int nParentId, const PolyLine& PL, int nRefType)
+1 -1
View File
@@ -613,7 +613,7 @@ ExeCurveDomain( int nId, double* pdStart, double* pdEnd)
if ( pCurve == nullptr)
return false ;
// recupero il dominio
return pCurve->GetDomain( *pdEnd, *pdEnd) ;
return pCurve->GetDomain( *pdStart, *pdEnd) ;
}
//----------------------------------------------------------------------------
BIN
View File
Binary file not shown.
+31
View File
@@ -702,6 +702,36 @@ LuaCreateCurveCompoByInterpolation( lua_State* L)
return 1 ;
}
//-------------------------------------------------------------------------------
static int
LuaCreateCurveCompoByApproximation( lua_State* L)
{
// 4 o 5 parametri : ParentId, ptPs, nType, dLinTol [, nRefType]
int nParentId ;
LuaCheckParam( L, 1, nParentId)
PNTVECTOR vPnt ;
LuaCheckParam( L, 2, vPnt)
int nType ;
LuaGetParam( L, 3, nType) ;
double dLinTol ;
LuaGetParam( L, 4, dLinTol) ;
int nRefType = RTY_DEFAULT ;
LuaGetParam( L, 5, nRefType) ;
LuaClearStack( L) ;
PolyLine PL ;
// creo una polilinea a partire dai punti
for ( size_t i = 0 ; i < vPnt.size() ; ++ i)
PL.AddUPoint( 0, vPnt[i]) ;
// creo la curva composita
int nId = ExeCreateCurveCompoByApproximation( nParentId, PL, nType, dLinTol, nRefType) ;
// restituisco il risultato
if ( nId != GDB_ID_NULL)
LuaSetParam( L, nId) ;
else
LuaSetParam( L) ;
return 1 ;
}
//-------------------------------------------------------------------------------
static int
LuaCreateCurveCompoFromPoints( lua_State* L)
@@ -912,6 +942,7 @@ LuaInstallGdbCreateCurve( LuaMgr& luaMgr)
bOk = bOk && luaMgr.RegisterFunction( "EgtCurveCompo", LuaCreateCurveCompo) ;
bOk = bOk && luaMgr.RegisterFunction( "EgtCurveCompoByChain", LuaCreateCurveCompoByChain) ;
bOk = bOk && luaMgr.RegisterFunction( "EgtCurveCompoByInterpolation", LuaCreateCurveCompoByInterpolation) ;
bOk = bOk && luaMgr.RegisterFunction( "EgtCurveCompoByApproximation", LuaCreateCurveCompoByApproximation) ;
bOk = bOk && luaMgr.RegisterFunction( "EgtCurveCompoFromPoints", LuaCreateCurveCompoFromPoints) ;
bOk = bOk && luaMgr.RegisterFunction( "EgtCurveCompoFromPointBulges", LuaCreateCurveCompoFromPointBulges) ;
bOk = bOk && luaMgr.RegisterFunction( "EgtRectangle2P", LuaCreateRectangle2P) ;