EgtInterface 1.6b5 :
- in CurveCompoByChain si cancellano gli originali solo se ok - in EgtModifyCurveThickness gestito vettore di Id - aggiunto Snap Point Baricentro (Gravity Center) - aggiunte EgtCurveArcRadius, EgtCurveCompoCenter - aggiunte funzioni lua EgtGP, EgtET, EgtCurveLength, EgtCurveArcRadius e EgtCurveCompoCenter.
This commit is contained in:
@@ -70,6 +70,7 @@ bool EgtChangeTextFont( int nId, const std::string& sNewFont) ;
|
||||
|
||||
//--------------------------- GdbModifyCurve ---------------------------------
|
||||
bool EgtModifyCurveExtrusion( INTVECTOR& vIds, const Vector3d& vtExtr, int nRefType) ;
|
||||
bool EgtModifyCurveThickness( INTVECTOR& vIds, double dThick) ;
|
||||
|
||||
//--------------------------- GdbObjects -------------------------------------
|
||||
int EgtGetFirstNameInGroup( int nGroupId, const std::string& sName) ;
|
||||
@@ -90,6 +91,7 @@ bool EgtStartPoint( int nId, int nRefId, Point3d& ptP) ;
|
||||
bool EgtEndPoint( int nId, int nRefId, Point3d& ptP) ;
|
||||
bool EgtMidPoint( int nId, int nRefId, Point3d& ptP) ;
|
||||
bool EgtCenterPoint( int nId, int nRefId, Point3d& ptP) ;
|
||||
bool EgtCentroid( int nId, int nRefId, Point3d& ptP) ;
|
||||
bool EgtAtParamPoint( int nId, double dU, int nRefId, Point3d& ptP) ;
|
||||
bool EgtNearPoint( int nId, const Point3d& ptNear, int nRefId, Point3d& ptP) ;
|
||||
bool EgtIntersectionPoint( int nId1, int nId2, const Point3d& ptNear, int nRefId, Point3d& ptP) ;
|
||||
@@ -101,6 +103,7 @@ bool EgtFrame( int nId, int nRefId, Frame3d& frFrame) ;
|
||||
bool EgtCurveExtrusion( int nId, int nRefId, Vector3d& vtExtr) ;
|
||||
// EgtCurveThickness vedi EinAPI.h
|
||||
bool EgtCurveArcNormVersor( int nId, int nRefId, Vector3d& vtNorm) ;
|
||||
bool EgtCurveCompoCenter( int nId, int nSimpCrv, int nRefId, Point3d& ptCen) ;
|
||||
bool EgtExtTextNormVersor( int nId, int nRefId, Vector3d& vtNorm) ;
|
||||
bool EgtPointToIdGlob( Point3d& ptP, int nId) ;
|
||||
bool EgtPointToIdLoc( Point3d& ptP, int nId) ;
|
||||
|
||||
@@ -1298,8 +1298,8 @@ MyCreateCurveCompoByChain( int nParentId, const INTVECTOR& vIds,
|
||||
if ( nFirstId == GDB_ID_NULL)
|
||||
nFirstId = nNewId ;
|
||||
}
|
||||
// se richiesto, cancello le curve originali
|
||||
if ( bErase) {
|
||||
// se richiesto e ok, cancello le curve originali
|
||||
if ( bErase && nFirstId != GDB_ID_NULL) {
|
||||
for ( Iter = vIds.begin() ; Iter != vIds.end() ; ++Iter) {
|
||||
if ( ! pGeomDB->Erase( *Iter))
|
||||
return GDB_ID_NULL ;
|
||||
|
||||
+33
-19
@@ -232,11 +232,9 @@ EgtModifyCurveExtrusion( INTVECTOR& vIds, const Vector3d& vtExtr, int nRefType)
|
||||
// se richiesto, salvo il comando Lua equivalente
|
||||
if ( IsCmdLog()) {
|
||||
string sIds ;
|
||||
for ( size_t i = 0 ; i < vIds.size() ; ++ i) {
|
||||
if ( i > 0)
|
||||
sIds += "," ;
|
||||
sIds += ( vIds[i] != GDB_ID_SEL ? ToString( vIds[i]) : "GDB_ID_SEL") ;
|
||||
}
|
||||
for ( size_t i = 0 ; i < vIds.size() ; ++ i)
|
||||
sIds += ( vIds[i] != GDB_ID_SEL ? ToString( vIds[i]) : "GDB_ID_SEL") + "," ;
|
||||
sIds.pop_back() ;
|
||||
string sLua = "EgtModifyCurveExtrusion({" + sIds + "},{" +
|
||||
ToString( Vector3d( vtExtr)) + "}," +
|
||||
RefTypeToString( nRefType) + ")" +
|
||||
@@ -279,29 +277,45 @@ ModifyOneCurveThickness( IGeomDB* pGeomDB, int nId, double dThick)
|
||||
//----------------------------------------------------------------------------
|
||||
BOOL
|
||||
__stdcall EgtModifyCurveThickness( int nId, double dThick)
|
||||
{
|
||||
INTVECTOR vIds ;
|
||||
vIds.push_back( nId) ;
|
||||
return ( EgtModifyCurveThickness( vIds, dThick) ? TRUE : FALSE) ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
EgtModifyCurveThickness( INTVECTOR& vIds, double dThick)
|
||||
{
|
||||
IGeomDB* pGeomDB = GetCurrGeomDB() ;
|
||||
VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL)
|
||||
bool bOk = true ;
|
||||
// eseguo impostazione spessore singola
|
||||
if ( nId != GDB_ID_SEL) {
|
||||
bOk = ModifyOneCurveThickness( pGeomDB, nId, dThick) ;
|
||||
}
|
||||
// eseguo impostazione spessore dei selezionati
|
||||
else {
|
||||
int nI = pGeomDB->GetFirstSelectedObj() ;
|
||||
while ( nI != GDB_ID_NULL && bOk) {
|
||||
if ( ! ModifyOneCurveThickness( pGeomDB, nI, dThick))
|
||||
bOk = false ;
|
||||
// passo alla successiva
|
||||
nI = pGeomDB->GetNextSelectedObj() ;
|
||||
// ciclo sul vettore degli identificativi
|
||||
for ( size_t i = 0 ; i < vIds.size() && bOk ; ++ i) {
|
||||
// eseguo impostazione spessore singola
|
||||
if ( vIds[i] != GDB_ID_SEL) {
|
||||
bOk = bOk && ModifyOneCurveThickness( pGeomDB, vIds[i], dThick) ;
|
||||
}
|
||||
// eseguo impostazione spessore dei selezionati
|
||||
else {
|
||||
int nI = pGeomDB->GetFirstSelectedObj() ;
|
||||
while ( nI != GDB_ID_NULL && bOk) {
|
||||
if ( ! ModifyOneCurveThickness( pGeomDB, nI, dThick))
|
||||
bOk = false ;
|
||||
// passo alla successiva
|
||||
nI = pGeomDB->GetNextSelectedObj() ;
|
||||
}
|
||||
}
|
||||
}
|
||||
EgtSetModified() ;
|
||||
// se richiesto, salvo il comando Lua equivalente
|
||||
if ( IsCmdLog()) {
|
||||
string sLua = "EgtModifyCurveThickness(" + ( nId != GDB_ID_SEL ? ToString( nId) : "GDB_ID_SEL") + "," +
|
||||
ToString( dThick) + ")" +
|
||||
string sIds ;
|
||||
for ( size_t i = 0 ; i < vIds.size() ; ++ i)
|
||||
sIds += ( vIds[i] != GDB_ID_SEL ? ToString( vIds[i]) : "GDB_ID_SEL") + "," ;
|
||||
sIds.pop_back() ;
|
||||
string sLua = "EgtModifyCurveThickness({" + sIds + "}," +
|
||||
ToString( dThick) + ")" +
|
||||
" -- Ok=" + ToString( bOk) ;
|
||||
LOG_INFO( GetCmdLogger(), sLua.c_str()) ;
|
||||
}
|
||||
|
||||
+100
-3
@@ -20,6 +20,7 @@
|
||||
#include "/EgtDev/Include/EgkGeoVector3d.h"
|
||||
#include "/EgtDev/Include/EgkCurve.h"
|
||||
#include "/EgtDev/Include/EgkCurveArc.h"
|
||||
#include "/EgtDev/Include/EgkCurveComposite.h"
|
||||
#include "/EgtDev/Include/EgkExtText.h"
|
||||
#include "/EgtDev/Include/EgkDistPointCurve.h"
|
||||
#include "/EgtDev/Include/EgkIntersCurveCurve.h"
|
||||
@@ -309,6 +310,51 @@ EgtCenterPoint( int nId, int nRefId, Point3d& ptP)
|
||||
return TrasformPoint( pGeomDB, nId, nRefId, ptP) ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
BOOL
|
||||
__stdcall EgtCentroid( int nId, int nRefId, double ptP[3])
|
||||
{
|
||||
// recupero il punto
|
||||
Point3d ptCent ;
|
||||
if ( ! EgtCentroid( nId, nRefId, ptCent))
|
||||
return FALSE ;
|
||||
// ritorno il punto
|
||||
VEC_FROM_3D( ptP, ptCent)
|
||||
return TRUE ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
EgtCentroid( int nId, int nRefId, Point3d& ptP)
|
||||
{
|
||||
IGeomDB* pGeomDB = GetCurrGeomDB() ;
|
||||
VERIFY_GEOMDB( pGeomDB, false)
|
||||
// se non è entità geometrica
|
||||
const IGeoObj* pGObj ;
|
||||
if ( ( pGObj = pGeomDB->GetGeoObj( nId)) == nullptr)
|
||||
return false ;
|
||||
// se curva
|
||||
if ( ( pGObj->GetType() & GEO_CURVE) != 0) {
|
||||
// recupero la curva
|
||||
const ICurve* pCrv = GetCurve( pGObj) ;
|
||||
// assegno il punto
|
||||
if ( pCrv == nullptr || ! pCrv->GetCentroid( ptP))
|
||||
return false ;
|
||||
}
|
||||
// se testo
|
||||
else if ( pGObj->GetType() == EXT_TEXT) {
|
||||
// recupero il testo
|
||||
const IExtText* pTxt = GetExtText( pGObj) ;
|
||||
// assegno il punto
|
||||
if ( pTxt == nullptr || ! pTxt->GetCenterPoint( ptP))
|
||||
return false ;
|
||||
}
|
||||
else
|
||||
return false ;
|
||||
// gestione trasformazione ( eventuale)
|
||||
return TrasformPoint( pGeomDB, nId, nRefId, ptP) ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
BOOL
|
||||
__stdcall EgtAtParamPoint( int nId, double dU, int nRefId, double ptP[3])
|
||||
@@ -784,6 +830,23 @@ __stdcall EgtGetMinDistPntSidePointCurve( const double ptP[3], int nId, double v
|
||||
return TRUE ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
BOOL
|
||||
__stdcall EgtCurveArcRadius( int nId, double* pdRad)
|
||||
{
|
||||
IGeomDB* pGeomDB = GetCurrGeomDB() ;
|
||||
VERIFY_GEOMDB( pGeomDB, FALSE)
|
||||
// recupero l'arco
|
||||
const ICurveArc* pArc = GetCurveArc( pGeomDB->GetGeoObj( nId)) ;
|
||||
if ( pArc == nullptr)
|
||||
return FALSE ;
|
||||
// recupero il raggio
|
||||
if ( pdRad == nullptr)
|
||||
return FALSE ;
|
||||
*pdRad = pArc->GetRadius() ;
|
||||
return TRUE ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
BOOL
|
||||
__stdcall EgtCurveArcNormVersor( int nId, int nRefId, double vtNorm[3])
|
||||
@@ -802,9 +865,9 @@ bool
|
||||
EgtCurveArcNormVersor( int nId, int nRefId, Vector3d& vtNorm)
|
||||
{
|
||||
IGeomDB* pGeomDB = GetCurrGeomDB() ;
|
||||
VERIFY_GEOMDB( pGeomDB, FALSE)
|
||||
VERIFY_GEOMDB( pGeomDB, false)
|
||||
// recupero l'arco
|
||||
ICurveArc* pArc = GetCurveArc( pGeomDB->GetGeoObj( nId)) ;
|
||||
const ICurveArc* pArc = GetCurveArc( pGeomDB->GetGeoObj( nId)) ;
|
||||
if ( pArc == nullptr)
|
||||
return false ;
|
||||
// recupero la normale
|
||||
@@ -813,6 +876,40 @@ EgtCurveArcNormVersor( int nId, int nRefId, Vector3d& vtNorm)
|
||||
return TrasformVector( pGeomDB, nId, nRefId, vtNorm) ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
BOOL
|
||||
__stdcall EgtCurveCompoCenter( int nId, int nSimpCrv, int nRefId, double ptCen[3])
|
||||
{
|
||||
// recupero il vettore normale
|
||||
Point3d ptTmp ;
|
||||
if ( ! EgtCurveCompoCenter( nId, nSimpCrv, nRefId, ptTmp))
|
||||
return FALSE ;
|
||||
// lo assegno
|
||||
VEC_FROM_3D( ptCen, ptTmp)
|
||||
return TRUE ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
EgtCurveCompoCenter( int nId, int nSimpCrv, int nRefId, Point3d& ptCen)
|
||||
{
|
||||
IGeomDB* pGeomDB = GetCurrGeomDB() ;
|
||||
VERIFY_GEOMDB( pGeomDB, false)
|
||||
// recupero la curva composita
|
||||
const ICurveComposite* pCompoCrv = GetCurveComposite( pGeomDB->GetGeoObj( nId)) ;
|
||||
if ( pCompoCrv == nullptr)
|
||||
return false ;
|
||||
// recupero la curva semplice di indice richiesto
|
||||
const ICurve* pSimpCrv = pCompoCrv->GetCurve( nSimpCrv) ;
|
||||
if ( pSimpCrv == nullptr)
|
||||
return false ;
|
||||
// recupero il centro
|
||||
if ( ! pSimpCrv->GetCenterPoint( ptCen))
|
||||
return false ;
|
||||
// gestione trasformazione ( eventuale)
|
||||
return TrasformPoint( pGeomDB, nId, nRefId, ptCen) ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
BOOL
|
||||
__stdcall EgtExtTextNormVersor( int nId, int nRefId, double vtNorm[3])
|
||||
@@ -831,7 +928,7 @@ bool
|
||||
EgtExtTextNormVersor( int nId, int nRefId, Vector3d& vtNorm)
|
||||
{
|
||||
IGeomDB* pGeomDB = GetCurrGeomDB() ;
|
||||
VERIFY_GEOMDB( pGeomDB, FALSE)
|
||||
VERIFY_GEOMDB( pGeomDB, false)
|
||||
// recupero il testo
|
||||
const IExtText* pTxt = GetExtText( pGeomDB->GetGeoObj( nId)) ;
|
||||
if ( pTxt == nullptr)
|
||||
|
||||
Binary file not shown.
@@ -132,12 +132,8 @@ LuaModifyCurveThickness( lua_State* L)
|
||||
double dThick ;
|
||||
LuaCheckParam( L, 2, dThick)
|
||||
LuaClearStack( L) ;
|
||||
// modifico il vettore estrusione
|
||||
bool bOk = true ;
|
||||
for ( size_t i = 0 ; i < vId.size() && bOk ; ++ i) {
|
||||
if ( EgtModifyCurveThickness( vId[i], dThick) == 0)
|
||||
bOk = false ;
|
||||
}
|
||||
// modifico lo spessore di estrusione
|
||||
bool bOk = EgtModifyCurveThickness( vId, dThick) ;
|
||||
// restituisco il risultato
|
||||
LuaSetReturn( L, bOk) ;
|
||||
return 1 ;
|
||||
|
||||
+101
-1
@@ -98,6 +98,25 @@ LuaCenterPoint( lua_State* L)
|
||||
return 1 ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
static int
|
||||
LuaCentroid( lua_State* L)
|
||||
{
|
||||
// 1 o 2 parametri : Id [, nRefId]
|
||||
int nId ;
|
||||
LuaCheckParam( L, 1, nId)
|
||||
int nRefId = nId ;
|
||||
LuaGetRefId( L, 2, nRefId) ;
|
||||
LuaClearStack( L) ;
|
||||
// recupero il centro geometrico dell'entità
|
||||
Point3d ptP ;
|
||||
if ( EgtCentroid( nId, nRefId, ptP))
|
||||
LuaSetReturn( L, ptP) ;
|
||||
else
|
||||
LuaSetReturn( L) ;
|
||||
return 1 ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
static int
|
||||
LuaAtParamPoint( lua_State* L)
|
||||
@@ -265,6 +284,23 @@ LuaFrame( lua_State* L)
|
||||
return 1 ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
static int
|
||||
LuaCurveLength( lua_State* L)
|
||||
{
|
||||
// 1 parametro : Id
|
||||
int nId ;
|
||||
LuaCheckParam( L, 1, nId)
|
||||
LuaClearStack( L) ;
|
||||
// recupero la lunghezza della curva
|
||||
double dLen ;
|
||||
if ( EgtCurveLength( nId, &dLen) != FALSE)
|
||||
LuaSetReturn( L, dLen) ;
|
||||
else
|
||||
LuaSetReturn( L) ;
|
||||
return 1 ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
static int
|
||||
LuaCurveExtrusion( lua_State* L)
|
||||
@@ -291,7 +327,6 @@ LuaCurveThickness( lua_State* L)
|
||||
// 1 parametro : Id
|
||||
int nId ;
|
||||
LuaCheckParam( L, 1, nId)
|
||||
int nRefId = nId ;
|
||||
LuaClearStack( L) ;
|
||||
// recupero lo spessore
|
||||
double dThick ;
|
||||
@@ -302,6 +337,45 @@ LuaCurveThickness( lua_State* L)
|
||||
return 1 ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
static int
|
||||
LuaExtrusionByThickness( lua_State* L)
|
||||
{
|
||||
// 1 o 2 parametri : Id [, nRefId]
|
||||
int nId ;
|
||||
LuaCheckParam( L, 1, nId)
|
||||
int nRefId = nId ;
|
||||
LuaGetRefId( L, 2, nRefId) ;
|
||||
LuaClearStack( L) ;
|
||||
// recupero il versore e lo spessore
|
||||
Vector3d vtExtr ;
|
||||
double dThick ;
|
||||
if ( EgtCurveExtrusion( nId, nRefId, vtExtr) && ! vtExtr.IsSmall() &&
|
||||
EgtCurveThickness( nId, &dThick) && fabs( dThick) > EPS_SMALL)
|
||||
vtExtr *= dThick ;
|
||||
else
|
||||
vtExtr = V_NULL ;
|
||||
LuaSetReturn( L, vtExtr) ;
|
||||
return 1 ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
static int
|
||||
LuaCurveArcRadius( lua_State* L)
|
||||
{
|
||||
// 1 parametro : Id
|
||||
int nId ;
|
||||
LuaCheckParam( L, 1, nId)
|
||||
LuaClearStack( L) ;
|
||||
// recupero il raggio
|
||||
double dRad ;
|
||||
if ( EgtCurveArcRadius( nId, &dRad) != FALSE)
|
||||
LuaSetReturn( L, dRad) ;
|
||||
else
|
||||
LuaSetReturn( L) ;
|
||||
return 1 ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
static int
|
||||
LuaCurveArcNormVersor( lua_State* L)
|
||||
@@ -321,6 +395,27 @@ LuaCurveArcNormVersor( lua_State* L)
|
||||
return 1 ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
static int
|
||||
LuaCurveCompoCenter( lua_State* L)
|
||||
{
|
||||
// 2 o 3 parametri : Id, nCrv [, nRefId]
|
||||
int nId ;
|
||||
LuaCheckParam( L, 1, nId)
|
||||
int nCrv ;
|
||||
LuaCheckParam( L, 2, nCrv)
|
||||
int nRefId = nId ;
|
||||
LuaGetRefId( L, 3, nRefId) ;
|
||||
LuaClearStack( L) ;
|
||||
// recupero il centro della curva semplice indicizzata
|
||||
Point3d ptCen ;
|
||||
if ( EgtCurveCompoCenter( nId, nCrv, nRefId, ptCen))
|
||||
LuaSetReturn( L, ptCen) ;
|
||||
else
|
||||
LuaSetReturn( L) ;
|
||||
return 1 ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
static int
|
||||
LuaExtTextNormVersor( lua_State* L)
|
||||
@@ -349,6 +444,7 @@ LuaInstallGeoSnap( lua_State* L)
|
||||
lua_register( L, "EgtEP", LuaEndPoint) ;
|
||||
lua_register( L, "EgtMP", LuaMidPoint) ;
|
||||
lua_register( L, "EgtCP", LuaCenterPoint) ;
|
||||
lua_register( L, "EgtGP", LuaCentroid) ;
|
||||
lua_register( L, "EgtUP", LuaAtParamPoint) ;
|
||||
lua_register( L, "EgtNP", LuaNearPoint) ;
|
||||
lua_register( L, "EgtIP", LuaIntersectionPoint) ;
|
||||
@@ -357,9 +453,13 @@ LuaInstallGeoSnap( lua_State* L)
|
||||
lua_register( L, "EgtMV", LuaMidVector) ;
|
||||
lua_register( L, "EgtUV", LuaAtParamVector) ;
|
||||
lua_register( L, "EgtFR", LuaFrame) ;
|
||||
lua_register( L, "EgtET", LuaExtrusionByThickness) ;
|
||||
lua_register( L, "EgtCurveLength", LuaCurveLength) ;
|
||||
lua_register( L, "EgtCurveExtrusion", LuaCurveExtrusion) ;
|
||||
lua_register( L, "EgtCurveThickness", LuaCurveThickness) ;
|
||||
lua_register( L, "EgtCurveArcRadius", LuaCurveArcRadius) ;
|
||||
lua_register( L, "EgtCurveArcNormVersor", LuaCurveArcNormVersor) ;
|
||||
lua_register( L, "EgtCurveCompoCenter", LuaCurveCompoCenter) ;
|
||||
lua_register( L, "EgtExtTextNormVersor", LuaExtTextNormVersor) ;
|
||||
}
|
||||
catch ( ...) {
|
||||
|
||||
Reference in New Issue
Block a user