EgtExecutor 2.4k2 :
- aggiunta funzione Exe e Lua ApproxSurface.
This commit is contained in:
@@ -18,6 +18,7 @@
|
||||
//----------------------------------------------------------------------------
|
||||
// Costanti per tolleranze di appossimazione
|
||||
const double LIN_TOL_STD = 0.1 ;
|
||||
const double LIN_TOL_SRF = 0.05 ;
|
||||
const double LIN_TOL_FINE = 0.01 ;
|
||||
const double LIN_FEA_STD = 20 ;
|
||||
const double LIN_FEA_MAX = 400 ;
|
||||
|
||||
+55
-12
@@ -24,6 +24,7 @@
|
||||
#include "/EgtDev/Include/EGkCurveLocal.h"
|
||||
#include "/EgtDev/Include/EGkSurfFlatRegion.h"
|
||||
#include "/EgtDev/Include/EGkSurfTriMesh.h"
|
||||
#include "/EgtDev/Include/EGkSurfBezier.h"
|
||||
#include "/EgtDev/Include/EGkSurfLocal.h"
|
||||
#include "/EgtDev/Include/EGkStmFromTriangleSoup.h"
|
||||
#include "/EgtDev/Include/EGkCAvSimpleSurfFrMove.h"
|
||||
@@ -204,12 +205,54 @@ ExeExplodeSurface( int nId, int* pnCount)
|
||||
return nFirstId ;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------
|
||||
bool
|
||||
ExeApproxSurface( int nId, double dLinTol)
|
||||
{
|
||||
IGeomDB* pGeomDB = GetCurrGeomDB() ;
|
||||
VERIFY_GEOMDB( pGeomDB, false)
|
||||
// opero secondo il tipo di superficie
|
||||
PtrOwner<ISurfTriMesh> pStm ;
|
||||
int nType = pGeomDB->GetGeoType( nId) ;
|
||||
if ( nType == SRF_TRIMESH) {
|
||||
// copio la superficie
|
||||
const ISurfTriMesh* pStri = GetSurfTriMesh( pGeomDB->GetGeoObj( nId)) ;
|
||||
pStm.Set( pStri != nullptr ? pStri->Clone() : nullptr) ;
|
||||
}
|
||||
else if ( nType == SRF_FLATRGN) {
|
||||
// recupero la superficie ausiliaria della regione
|
||||
const ISurfFlatRegion* pSfr = GetSurfFlatRegion( pGeomDB->GetGeoObj( nId)) ;
|
||||
const ISurfTriMesh* pAuxSurf = ( pSfr != nullptr ? pSfr->GetAuxSurf() : nullptr) ;
|
||||
pStm.Set( pAuxSurf != nullptr ? pAuxSurf->Clone() : nullptr) ;
|
||||
}
|
||||
else if ( nType == SRF_BEZIER) {
|
||||
// recupero la superficie ausiliaria della Bezier
|
||||
const ISurfBezier* pSbez = GetSurfBezier( pGeomDB->GetGeoObj( nId)) ;
|
||||
const ISurfTriMesh* pAuxSurf = ( pSbez != nullptr ? pSbez->GetAuxSurf() : nullptr) ;
|
||||
pStm.Set( pAuxSurf != nullptr ? pAuxSurf->Clone() : nullptr) ;
|
||||
}
|
||||
bool bOk = ( ! IsNull( pStm)) ;
|
||||
// va inserita la semplificazione di una trimesh
|
||||
|
||||
// sostituisco la vecchia superficie con la nuova
|
||||
bOk = bOk && pGeomDB->ReplaceGeoObj( nId, Release( pStm)) ;
|
||||
ExeSetModified() ;
|
||||
// se richiesto, salvo il comando Lua equivalente
|
||||
if ( IsCmdLog()) {
|
||||
string sLua = "EgtApproxSurf(" + ToString( nId) + "," +
|
||||
ToString( dLinTol) + ")" +
|
||||
" -- Ok=" + ToString( bOk) ;
|
||||
LOG_INFO( GetCmdLogger(), sLua.c_str()) ;
|
||||
}
|
||||
return bOk ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
ExeSurfFrAdd( int nId1, int nId2)
|
||||
{
|
||||
IGeomDB* pGeomDB = GetCurrGeomDB() ;
|
||||
VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL)
|
||||
VERIFY_GEOMDB( pGeomDB, false)
|
||||
// recupero la prima superficie FlatRegion
|
||||
ISurfFlatRegion* pSfr1 = GetSurfFlatRegion( pGeomDB->GetGeoObj( nId1)) ;
|
||||
bool bOk = ( pSfr1 != nullptr) ;
|
||||
@@ -238,7 +281,7 @@ bool
|
||||
ExeSurfFrSubtract( int nId1, int nId2)
|
||||
{
|
||||
IGeomDB* pGeomDB = GetCurrGeomDB() ;
|
||||
VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL)
|
||||
VERIFY_GEOMDB( pGeomDB, false)
|
||||
// recupero la prima superficie FlatRegion
|
||||
ISurfFlatRegion* pSfr1 = GetSurfFlatRegion( pGeomDB->GetGeoObj( nId1)) ;
|
||||
bool bOk = ( pSfr1 != nullptr) ;
|
||||
@@ -270,7 +313,7 @@ bool
|
||||
ExeSurfFrIntersect( int nId1, int nId2)
|
||||
{
|
||||
IGeomDB* pGeomDB = GetCurrGeomDB() ;
|
||||
VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL)
|
||||
VERIFY_GEOMDB( pGeomDB, false)
|
||||
// recupero la prima superficie FlatRegion
|
||||
ISurfFlatRegion* pSfr1 = GetSurfFlatRegion( pGeomDB->GetGeoObj( nId1)) ;
|
||||
bool bOk = ( pSfr1 != nullptr) ;
|
||||
@@ -302,7 +345,7 @@ bool
|
||||
ExeSurfFrOffset( int nId, double dDist, int nType)
|
||||
{
|
||||
IGeomDB* pGeomDB = GetCurrGeomDB() ;
|
||||
VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL)
|
||||
VERIFY_GEOMDB( pGeomDB, false)
|
||||
// recupero la superficie FlatRegion
|
||||
ISurfFlatRegion* pSfr = GetSurfFlatRegion( pGeomDB->GetGeoObj( nId)) ;
|
||||
bool bOk = ( pSfr != nullptr) ;
|
||||
@@ -328,7 +371,7 @@ bool
|
||||
ExeSurfFrMoveSimpleNoCollision( int nId1, int nId2, const Vector3d& vtDir, double& dLen, int nRefType)
|
||||
{
|
||||
IGeomDB* pGeomDB = GetCurrGeomDB() ;
|
||||
VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL)
|
||||
VERIFY_GEOMDB( pGeomDB, false)
|
||||
// recupero la prima superficie FlatRegion
|
||||
ISurfFlatRegion* pSfr1 = GetSurfFlatRegion( pGeomDB->GetGeoObj( nId1)) ;
|
||||
bool bOk = ( pSfr1 != nullptr) ;
|
||||
@@ -350,7 +393,7 @@ bool
|
||||
ExeSurfFrRotateSimpleNoCollision( int nId1, int nId2, const Point3d& ptCen, double& dAngDeg, int nRefType)
|
||||
{
|
||||
IGeomDB* pGeomDB = GetCurrGeomDB() ;
|
||||
VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL)
|
||||
VERIFY_GEOMDB( pGeomDB, false)
|
||||
// recupero la prima superficie FlatRegion
|
||||
ISurfFlatRegion* pSfr1 = GetSurfFlatRegion( pGeomDB->GetGeoObj( nId1)) ;
|
||||
bool bOk = ( pSfr1 != nullptr) ;
|
||||
@@ -510,7 +553,7 @@ bool
|
||||
ExeCutSurfTmPlane( int nId, const Point3d& ptOn, const Vector3d& vtN, bool bSaveOnEq, int nRefType)
|
||||
{
|
||||
IGeomDB* pGeomDB = GetCurrGeomDB() ;
|
||||
VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL)
|
||||
VERIFY_GEOMDB( pGeomDB, false)
|
||||
// recupero la superficie TriMesh
|
||||
ISurfTriMesh* pStm = GetSurfTriMesh( pGeomDB->GetGeoObj( nId)) ;
|
||||
bool bOk = ( pStm != nullptr) ;
|
||||
@@ -545,7 +588,7 @@ bool
|
||||
ExeCutSurfTmClosedCurve( int nSurfId, int nCurveId, bool bSaveOnEq)
|
||||
{
|
||||
IGeomDB* pGeomDB = GetCurrGeomDB() ;
|
||||
VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL)
|
||||
VERIFY_GEOMDB( pGeomDB, false)
|
||||
// recupero la superficie TriMesh
|
||||
ISurfTriMesh* pStm = GetSurfTriMesh( pGeomDB->GetGeoObj( nSurfId)) ;
|
||||
bool bOk = ( pStm != nullptr) ;
|
||||
@@ -575,7 +618,7 @@ bool
|
||||
ExeSurfTmAdd( int nId1, int nId2, bool bTwoColors)
|
||||
{
|
||||
IGeomDB* pGeomDB = GetCurrGeomDB() ;
|
||||
VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL)
|
||||
VERIFY_GEOMDB( pGeomDB, false)
|
||||
// recupero la prima superficie TriMesh
|
||||
ISurfTriMesh* pStm1 = GetSurfTriMesh( pGeomDB->GetGeoObj( nId1)) ;
|
||||
bool bOk = ( pStm1 != nullptr) ;
|
||||
@@ -607,7 +650,7 @@ bool
|
||||
ExeSurfTmSubtract( int nId1, int nId2, bool bTwoColors)
|
||||
{
|
||||
IGeomDB* pGeomDB = GetCurrGeomDB() ;
|
||||
VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL)
|
||||
VERIFY_GEOMDB( pGeomDB, false)
|
||||
// recupero la prima superficie TriMesh
|
||||
ISurfTriMesh* pStm1 = GetSurfTriMesh( pGeomDB->GetGeoObj( nId1)) ;
|
||||
bool bOk = ( pStm1 != nullptr) ;
|
||||
@@ -644,7 +687,7 @@ bool
|
||||
ExeSurfTmIntersect( int nId1, int nId2, bool bTwoColors)
|
||||
{
|
||||
IGeomDB* pGeomDB = GetCurrGeomDB() ;
|
||||
VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL)
|
||||
VERIFY_GEOMDB( pGeomDB, false)
|
||||
// recupero la prima superficie TriMesh
|
||||
ISurfTriMesh* pStm1 = GetSurfTriMesh( pGeomDB->GetGeoObj( nId1)) ;
|
||||
bool bOk = ( pStm1 != nullptr) ;
|
||||
@@ -681,7 +724,7 @@ bool
|
||||
ExeSurfTmResetTwoColors( int nId)
|
||||
{
|
||||
IGeomDB* pGeomDB = GetCurrGeomDB() ;
|
||||
VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL)
|
||||
VERIFY_GEOMDB( pGeomDB, false)
|
||||
// recupero la superficie TriMesh
|
||||
ISurfTriMesh* pStm = GetSurfTriMesh( pGeomDB->GetGeoObj( nId)) ;
|
||||
bool bOk = ( pStm != nullptr) ;
|
||||
|
||||
Binary file not shown.
+13
-15
@@ -14,6 +14,7 @@
|
||||
//--------------------------- Include ----------------------------------------
|
||||
#include "stdafx.h"
|
||||
#include "LUA.h"
|
||||
#include "EXE_Const.h"
|
||||
#include "/EgtDev/Include/EXeExecutor.h"
|
||||
#include "/EgtDev/Include/EXeConst.h"
|
||||
#include "/EgtDev/Include/EGkLuaAux.h"
|
||||
@@ -22,9 +23,6 @@
|
||||
|
||||
using namespace std ;
|
||||
|
||||
//-------------------------------------------------------------------------------
|
||||
static const double LIN_TOL_DEF = 0.05 ;
|
||||
|
||||
//-------------------------------------------------------------------------------
|
||||
static int
|
||||
LuaCreateSurfFrRectangle( lua_State* L)
|
||||
@@ -320,7 +318,7 @@ LuaCreateSurfTmCylinder( lua_State* L)
|
||||
LuaCheckParam( L, 4, dRad)
|
||||
double dHeight ;
|
||||
LuaCheckParam( L, 5, dHeight)
|
||||
double dLinTol = LIN_TOL_DEF ;
|
||||
double dLinTol = LIN_TOL_SRF ;
|
||||
int nRefType = RTY_DEFAULT ;
|
||||
if ( LuaGetParam( L, 6, dLinTol))
|
||||
LuaGetParam( L, 7, nRefType) ;
|
||||
@@ -352,7 +350,7 @@ LuaCreateSurfTmCone( lua_State* L)
|
||||
LuaCheckParam( L, 4, dRad)
|
||||
double dHeight ;
|
||||
LuaCheckParam( L, 5, dHeight)
|
||||
double dLinTol = LIN_TOL_DEF ;
|
||||
double dLinTol = LIN_TOL_SRF ;
|
||||
int nRefType = RTY_DEFAULT ;
|
||||
if ( LuaGetParam( L, 6, dLinTol))
|
||||
LuaGetParam( L, 7, nRefType) ;
|
||||
@@ -380,7 +378,7 @@ LuaCreateSurfTmSphere( lua_State* L)
|
||||
LuaCheckParam( L, 2, ptOrig)
|
||||
double dRad ;
|
||||
LuaCheckParam( L, 3, dRad)
|
||||
double dLinTol = LIN_TOL_DEF ;
|
||||
double dLinTol = LIN_TOL_SRF ;
|
||||
int nRefType = RTY_DEFAULT ;
|
||||
if ( LuaGetParam( L, 4, dLinTol))
|
||||
LuaGetParam( L, 5, nRefType) ;
|
||||
@@ -406,7 +404,7 @@ LuaCreateSurfTmByFlatContour( lua_State* L)
|
||||
LuaCheckParam( L, 1, nParentId)
|
||||
int nCrvId ;
|
||||
LuaCheckParam( L, 2, nCrvId)
|
||||
double dLinTol = LIN_TOL_DEF ;
|
||||
double dLinTol = LIN_TOL_SRF ;
|
||||
if ( lua_gettop( L) >= 3)
|
||||
LuaCheckParam( L, 3, dLinTol) ;
|
||||
LuaClearStack( L) ;
|
||||
@@ -429,7 +427,7 @@ LuaCreateSurfTmByRegion( lua_State* L)
|
||||
LuaCheckParam( L, 1, nParentId)
|
||||
INTVECTOR vCrvIds ;
|
||||
LuaCheckParam( L, 2, vCrvIds)
|
||||
double dLinTol = LIN_TOL_DEF ;
|
||||
double dLinTol = LIN_TOL_SRF ;
|
||||
if ( lua_gettop( L) >= 3)
|
||||
LuaCheckParam( L, 3, dLinTol) ;
|
||||
LuaClearStack( L) ;
|
||||
@@ -454,7 +452,7 @@ LuaCreateSurfTmByExtrusion( lua_State* L)
|
||||
LuaCheckParam( L, 2, vCrvIds)
|
||||
Vector3d vtExtr ;
|
||||
LuaCheckParam( L, 3, vtExtr)
|
||||
double dLinTol = LIN_TOL_DEF ;
|
||||
double dLinTol = LIN_TOL_SRF ;
|
||||
int nRefType = RTY_DEFAULT ;
|
||||
if ( LuaGetParam( L, 4, dLinTol))
|
||||
LuaGetParam( L, 5, nRefType) ;
|
||||
@@ -483,7 +481,7 @@ LuaCreateSurfTmByRegionExtrusion( lua_State* L)
|
||||
LuaCheckParam( L, 2, vCrvIds)
|
||||
Vector3d vtExtr ;
|
||||
LuaCheckParam( L, 3, vtExtr)
|
||||
double dLinTol = LIN_TOL_DEF ;
|
||||
double dLinTol = LIN_TOL_SRF ;
|
||||
int nRefType = RTY_DEFAULT ;
|
||||
if ( LuaGetParam( L, 4, dLinTol))
|
||||
LuaGetParam( L, 5, nRefType) ;
|
||||
@@ -515,7 +513,7 @@ LuaCreateSurfTmByRevolve( lua_State* L)
|
||||
LuaCheckParam( L, 4, vtAx)
|
||||
bool bCapEnds ;
|
||||
LuaCheckParam( L, 5, bCapEnds)
|
||||
double dLinTol = LIN_TOL_DEF ;
|
||||
double dLinTol = LIN_TOL_SRF ;
|
||||
int nRefType = RTY_DEFAULT ;
|
||||
if ( LuaGetParam( L, 6, dLinTol))
|
||||
LuaGetParam( L, 7, nRefType) ;
|
||||
@@ -553,7 +551,7 @@ LuaCreateSurfTmByScrewing( lua_State* L)
|
||||
bool bCapEnds = false ;
|
||||
if ( LuaGetParam( L, nPar, bCapEnds))
|
||||
++ nPar ;
|
||||
double dLinTol = LIN_TOL_DEF ;
|
||||
double dLinTol = LIN_TOL_SRF ;
|
||||
if ( LuaGetParam( L, nPar, dLinTol))
|
||||
++ nPar ;
|
||||
int nRefType = RTY_DEFAULT ;
|
||||
@@ -589,7 +587,7 @@ LuaCreateSurfTmRectSwept( lua_State* L)
|
||||
LuaCheckParam( L, 6, nGuideId)
|
||||
int nCapType ;
|
||||
LuaCheckParam( L, 7, nCapType)
|
||||
double dLinTol = LIN_TOL_DEF ;
|
||||
double dLinTol = LIN_TOL_SRF ;
|
||||
LuaGetParam( L, 8, dLinTol) ;
|
||||
LuaClearStack( L) ;
|
||||
// creo STM rectangular swept
|
||||
@@ -615,7 +613,7 @@ LuaCreateSurfTmSwept( lua_State* L)
|
||||
LuaCheckParam( L, 3, nGuideId)
|
||||
bool bCapEnds ;
|
||||
LuaCheckParam( L, 4, bCapEnds)
|
||||
double dLinTol = LIN_TOL_DEF ;
|
||||
double dLinTol = LIN_TOL_SRF ;
|
||||
LuaGetParam( L, 5, dLinTol) ;
|
||||
LuaClearStack( L) ;
|
||||
// creo STM swept
|
||||
@@ -640,7 +638,7 @@ LuaCreateSurfTmRuled( lua_State* L)
|
||||
int nPtOrCrvId2 ;
|
||||
LuaCheckParam( L, 3, nPtOrCrvId2)
|
||||
string sType = "IP" ;
|
||||
double dLinTol = LIN_TOL_DEF ;
|
||||
double dLinTol = LIN_TOL_SRF ;
|
||||
if ( LuaGetParam( L, 4, sType))
|
||||
LuaGetParam( L, 5, dLinTol) ;
|
||||
else
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
//--------------------------- Include ----------------------------------------
|
||||
#include "stdafx.h"
|
||||
#include "LUA.h"
|
||||
#include "EXE_Const.h"
|
||||
#include "/EgtDev/Include/EXeExecutor.h"
|
||||
#include "/EgtDev/Include/EXeConst.h"
|
||||
#include "/EgtDev/Include/EGkCurve.h"
|
||||
@@ -57,6 +58,23 @@ LuaExplodeSurf( lua_State* L)
|
||||
return 2 ;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------
|
||||
static int
|
||||
LuaApproxSurf( lua_State* L)
|
||||
{
|
||||
// 1 o 2 parametri : Id [, dLinTol]
|
||||
int nId ;
|
||||
LuaCheckParam( L, 1, nId)
|
||||
double dLinTol = LIN_TOL_SRF ;
|
||||
LuaGetParam( L, 2, dLinTol) ;
|
||||
LuaClearStack( L) ;
|
||||
// approssimazione della superficie
|
||||
bool bOk = ExeApproxSurface( nId, dLinTol) ;
|
||||
// restituisco il risultato
|
||||
LuaSetParam( L, bOk) ;
|
||||
return 1 ;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------
|
||||
static int
|
||||
LuaSurfFrAdd( lua_State* L)
|
||||
@@ -353,6 +371,7 @@ LuaInstallGdbModifySurf( LuaMgr& luaMgr)
|
||||
bool bOk = ( &luaMgr != nullptr) ;
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtInvertSurf", LuaInvertSurf) ;
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtExplodeSurf", LuaExplodeSurf) ;
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtApproxSurf", LuaApproxSurf) ;
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtSurfFrAdd", LuaSurfFrAdd) ;
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtSurfFrSubtract", LuaSurfFrSubtract) ;
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtSurfFrIntersect", LuaSurfFrIntersect) ;
|
||||
|
||||
Reference in New Issue
Block a user