EgtExecutor 2.4h2 :
- aggiunte funzioni Exe e Lua CreateCircle2P - in ExeCreateCurveFillet migliorato trim celle parti rimanenti arrivando anche a cancellazione - estesa ExeModifyArcRadius per modificare raggio di arco mantenendo gli estremi oppure no da parametro bKeepCenter (default true).
This commit is contained in:
+65
-10
@@ -29,6 +29,7 @@
|
||||
#include "/EgtDev/Include/EGkLineTgCurvePerpCurve.h"
|
||||
#include "/EgtDev/Include/EGkCurveArc.h"
|
||||
#include "/EgtDev/Include/EGkCircleCenTgCurve.h"
|
||||
#include "/EgtDev/Include/EGkCircle2P.h"
|
||||
#include "/EgtDev/Include/EGkArcSpecial.h"
|
||||
#include "/EgtDev/Include/EGkArcPntDirTgCurve.h"
|
||||
#include "/EgtDev/Include/EGkArcCenTgCurvePnt.h"
|
||||
@@ -764,6 +765,44 @@ ExeCreateCircleCPEx( int nParentId, const Point3d& ptCen,
|
||||
return nNewId ;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------
|
||||
int
|
||||
ExeCreateCircle2P( int nParentId, const Point3d& ptP1, const Point3d& ptP2, int nRefType)
|
||||
{
|
||||
IGeomDB* pGeomDB = GetCurrGeomDB() ;
|
||||
VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL)
|
||||
nParentId = AdjustId( nParentId) ;
|
||||
// recupero il riferimento locale
|
||||
Frame3d frLoc ;
|
||||
if ( ! pGeomDB->GetGroupGlobFrame( nParentId, frLoc))
|
||||
return GDB_ID_NULL ;
|
||||
// porto in locale i punti e i versori
|
||||
Point3d ptP1L = GetPointLocal( pGeomDB, ptP1, nRefType, frLoc) ;
|
||||
Point3d ptP2L = GetPointLocal( pGeomDB, ptP2, nRefType, frLoc) ;
|
||||
Vector3d vtNL = GetVectorLocal( pGeomDB, Z_AX, nRefType, frLoc) ;
|
||||
Vector3d vtExtrL = GetVectorLocal( pGeomDB, Z_AX, nRefType, frLoc) ;
|
||||
// calcolo la circonferenza
|
||||
PtrOwner<ICurveArc> pCrvArc( GetCircle2P( ptP1L, ptP2L, vtNL)) ;
|
||||
if ( IsNull( pCrvArc))
|
||||
return GDB_ID_NULL ;
|
||||
// assegno il versore estrusione
|
||||
pCrvArc->SetExtrusion( vtExtrL) ;
|
||||
// inserisco l'arco nel DB
|
||||
int nId = pGeomDB->AddGeoObj( GDB_ID_NULL, nParentId, Release( pCrvArc)) ;
|
||||
ExeSetModified() ;
|
||||
// se richiesto, salvo il comando Lua equivalente
|
||||
if ( IsCmdLog()) {
|
||||
string sLua = "EgtCircle2P(" + IdToString( nParentId) + ",{" +
|
||||
ToString( ptP1) + "}," +
|
||||
ToString( ptP2) + "," +
|
||||
RefTypeToString( nRefType) + ")" +
|
||||
" -- Id=" + ToString( nId) ;
|
||||
LOG_INFO( GetCmdLogger(), sLua.c_str()) ;
|
||||
}
|
||||
// restituisco l'identificativo della nuova entità
|
||||
return nId ;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------
|
||||
int
|
||||
ExeCreateCircle3P( int nParentId, const Point3d& ptP1,
|
||||
@@ -1293,18 +1332,34 @@ ExeCreateCurveFillet( int nParentId, int nCrv1, const Point3d& ptNear1,
|
||||
int nNewId = ( bOk ? pGeomDB->AddGeoObj( GDB_ID_NULL, nParentId, Release( pArc)) : GDB_ID_NULL) ;
|
||||
// se richiesto trim
|
||||
if ( nNewId != GDB_ID_NULL && bTrim) {
|
||||
// recupero e aggiusto la prima curva
|
||||
// recupero prima curva
|
||||
ICurve* pCrv1 = GetCurve( pGeomDB->GetGeoObj( nCrv1)) ;
|
||||
if ( dTrim1 > EPS_ZERO)
|
||||
pCrv1->TrimStartAtParam( dTrim1) ;
|
||||
else if ( dTrim1 < - EPS_ZERO)
|
||||
pCrv1->TrimEndAtParam( abs( dTrim1)) ;
|
||||
// recupero e aggiusto la seconda curva
|
||||
double dLen1 = 0 ; pCrv1->GetLength( dLen1) ;
|
||||
double dParS1 = 0, dParE1 = 1 ; pCrv1->GetDomain( dParS1, dParE1) ;
|
||||
// se prima curva da eliminare
|
||||
if ( abs( abs( dTrim1) - dParE1) * dLen1 < EPS_SMALL || abs( abs( dTrim1) - dParS1) * dLen1 < EPS_SMALL)
|
||||
pGeomDB->Erase( nCrv1) ;
|
||||
// altrimenti da trimmare
|
||||
else {
|
||||
if ( dTrim1 > EPS_ZERO)
|
||||
pCrv1->TrimStartAtParam( dTrim1) ;
|
||||
else if ( dTrim1 < - EPS_ZERO)
|
||||
pCrv1->TrimEndAtParam( abs( dTrim1)) ;
|
||||
}
|
||||
// recupero seconda curva
|
||||
ICurve* pCrv2 = GetCurve( pGeomDB->GetGeoObj( nCrv2)) ;
|
||||
if ( dTrim2 > EPS_ZERO)
|
||||
pCrv2->TrimStartAtParam( dTrim2) ;
|
||||
else if ( dTrim2 < - EPS_ZERO)
|
||||
pCrv2->TrimEndAtParam( abs( dTrim2)) ;
|
||||
double dLen2 = 0 ; pCrv2->GetLength( dLen2) ;
|
||||
double dParS2 = 0, dParE2 = 1 ; pCrv2->GetDomain( dParS2, dParE2) ;
|
||||
// se seconda curva da eliminare
|
||||
if ( abs( abs( dTrim2) - dParE2) * dLen2 < EPS_SMALL || abs( abs( dTrim2) - dParS2) * dLen2 < EPS_SMALL)
|
||||
pGeomDB->Erase( nCrv2) ;
|
||||
// altrimenti da trimmare
|
||||
else {
|
||||
if ( dTrim2 > EPS_ZERO)
|
||||
pCrv2->TrimStartAtParam( dTrim2) ;
|
||||
else if ( dTrim2 < - EPS_ZERO)
|
||||
pCrv2->TrimEndAtParam( abs( dTrim2)) ;
|
||||
}
|
||||
}
|
||||
ExeSetModified() ;
|
||||
// se richiesto, salvo il comando Lua equivalente
|
||||
|
||||
+52
-11
@@ -1325,7 +1325,7 @@ ExeModifyCircle3P( int nId, const Point3d& ptP1, const Point3d& ptP2, const Poin
|
||||
// creo l'arco
|
||||
PtrOwner<ICurveArc> pCrvArc( CreateCurveArc()) ;
|
||||
if ( IsNull( pCrvArc))
|
||||
return GDB_ID_NULL ;
|
||||
return false ;
|
||||
// recupero il riferimento locale
|
||||
Frame3d frLoc ;
|
||||
if ( ! pGeomDB->GetGlobFrame( nId, frLoc))
|
||||
@@ -1348,24 +1348,65 @@ ExeModifyCircle3P( int nId, const Point3d& ptP1, const Point3d& ptP2, const Poin
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------
|
||||
bool
|
||||
ExeModifyArcRadius( int nId, double dRad)
|
||||
static bool
|
||||
MyModifyArcRadius( IGeomDB* pGeomDB, int nId, double dRad)
|
||||
{
|
||||
IGeomDB* pGeomDB = GetCurrGeomDB() ;
|
||||
VERIFY_GEOMDB( pGeomDB, false)
|
||||
// recupero l'arco e i suoi dati
|
||||
ICurveArc* pArc = GetCurveArc( pGeomDB->GetGeoObj( nId)) ;
|
||||
if ( pArc == nullptr)
|
||||
return false ;
|
||||
double dOldRad = pArc->GetRadius() ;
|
||||
// imposto il nuovo raggio
|
||||
if ( pArc->ChangeRadius( dRad))
|
||||
return true ;
|
||||
// in caso di errore, ripristino i vecchi dati
|
||||
else {
|
||||
pArc->ChangeRadius( dOldRad) ;
|
||||
return pArc->ChangeRadius( dRad) ;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------
|
||||
static bool
|
||||
MyModifyArcRadiusEx( IGeomDB* pGeomDB, int nId, double dRad)
|
||||
{
|
||||
// recupero l'arco e i suoi dati
|
||||
ICurveArc* pArc = GetCurveArc( pGeomDB->GetGeoObj( nId)) ;
|
||||
if ( pArc == nullptr)
|
||||
return false ;
|
||||
// recupero gli estremi dell'arco e la loro distanza nel piano dell'arco
|
||||
Point3d ptStart, ptEnd ;
|
||||
if ( ! pArc->GetStartPoint( ptStart) || ! pArc->GetEndPoint( ptEnd))
|
||||
return false ;
|
||||
double dPlaneDist = OrthoCompo( ( ptEnd - ptStart), pArc->GetNormVersor()).Len() ;
|
||||
// se angolo al centro maggiore o uguale ad un giro o estremi coincidenti, conservo il centro
|
||||
if ( abs( pArc->GetAngCenter()) >= ANG_FULL - EPS_ANG_ZERO || dPlaneDist < 2 * EPS_SMALL)
|
||||
return MyModifyArcRadius( pGeomDB, nId, dRad) ;
|
||||
// mantengo i punti estremi (pertanto il nuovo raggio non può essere inferiore a metà della loro distanza nel piano)
|
||||
if ( dRad < dPlaneDist / 2 - EPS_ZERO)
|
||||
return false ;
|
||||
// creo arco con gli stessi estremi, con identica normale e con nuovo raggio
|
||||
PtrOwner<ICurveArc> pCrvArc( CreateCurveArc()) ;
|
||||
if ( IsNull( pCrvArc) ||
|
||||
! pCrvArc->Set2PNRS( ptStart, ptEnd, pArc->GetNormVersor(), dRad, pArc->GetAngCenter() > 0))
|
||||
return false ;
|
||||
// lo sostituisco all'originale
|
||||
return pGeomDB->ReplaceGeoObj( nId, Release( pCrvArc)) ;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------
|
||||
bool
|
||||
ExeModifyArcRadius( int nId, double dRad, bool bKeepCenter)
|
||||
{
|
||||
IGeomDB* pGeomDB = GetCurrGeomDB() ;
|
||||
VERIFY_GEOMDB( pGeomDB, false)
|
||||
|
||||
bool bOk = ( bKeepCenter ? MyModifyArcRadius( pGeomDB, nId, dRad) : MyModifyArcRadiusEx( pGeomDB, nId, dRad)) ;
|
||||
if ( bOk)
|
||||
ExeSetModified() ;
|
||||
|
||||
// se richiesto, salvo il comando Lua equivalente
|
||||
if ( IsCmdLog()) {
|
||||
string sLua = "EgtModifyArcRadius(" + IdToString( nId) + "," +
|
||||
ToString( dRad) + ")" +
|
||||
" -- Ok=" + ToString( bOk) ;
|
||||
LOG_INFO( GetCmdLogger(), sLua.c_str()) ;
|
||||
}
|
||||
|
||||
return bOk ;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------
|
||||
|
||||
Binary file not shown.
@@ -235,6 +235,30 @@ LuaCreateCircleCPEx( lua_State* L)
|
||||
return 1 ;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------
|
||||
static int
|
||||
LuaCreateCircle2P( lua_State* L)
|
||||
{
|
||||
// 3 o 4 parametri : ParentId, PtP1, PtP2 [, nRefType]
|
||||
int nParentId ;
|
||||
LuaCheckParam( L, 1, nParentId)
|
||||
Point3d ptP1 ;
|
||||
LuaCheckParam( L, 2, ptP1)
|
||||
Point3d ptP2 ;
|
||||
LuaCheckParam( L, 3, ptP2)
|
||||
int nRefType = RTY_DEFAULT ;
|
||||
LuaGetParam( L, 4, nRefType) ;
|
||||
LuaClearStack( L) ;
|
||||
// creo l'arco
|
||||
int nId = ExeCreateCircle2P( nParentId, ptP1, ptP2, nRefType) ;
|
||||
// restituisco il risultato
|
||||
if ( nId != GDB_ID_NULL)
|
||||
LuaSetParam( L, nId) ;
|
||||
else
|
||||
LuaSetParam( L) ;
|
||||
return 1 ;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------
|
||||
static int
|
||||
LuaCreateCircle3P( lua_State* L)
|
||||
@@ -1026,6 +1050,7 @@ LuaInstallGdbCreateCurve( LuaMgr& luaMgr)
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtCircle", LuaCreateCircle) ;
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtCircleCP", LuaCreateCircleCP) ;
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtCircleCPEx", LuaCreateCircleCPEx) ;
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtCircle2P", LuaCreateCircle2P) ;
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtCircle3P", LuaCreateCircle3P) ;
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtArc", LuaCreateArc) ;
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtArcCPA", LuaCreateArcCPA) ;
|
||||
|
||||
@@ -516,14 +516,16 @@ LuaSplitCurveAtSelfInters( lua_State* L)
|
||||
static int
|
||||
LuaModifyArcRadius( lua_State* L)
|
||||
{
|
||||
// 2 parametri : Id, dNewRad
|
||||
// 2 o 3 parametri : Id, dNewRad [, bKeepCenter]
|
||||
int nId ;
|
||||
LuaCheckParam( L, 1, nId)
|
||||
double dNewRad ;
|
||||
LuaCheckParam( L, 2, dNewRad)
|
||||
bool bKeepCenter = true ;
|
||||
LuaGetParam( L, 3, bKeepCenter) ;
|
||||
LuaClearStack( L) ;
|
||||
// modifica del raggio
|
||||
bool bOk = ExeModifyArcRadius( nId, dNewRad) ;
|
||||
bool bOk = ExeModifyArcRadius( nId, dNewRad, bKeepCenter) ;
|
||||
LuaSetParam( L, bOk) ;
|
||||
return 1 ;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user