EgtExecutor :
- aggiunta una funzione per mostrare i punti di controllo di una curva di Bezier.
This commit is contained in:
+69
-26
@@ -19,6 +19,7 @@
|
||||
#include "GeoTools.h"
|
||||
#include "/EgtDev/Include/EXeExecutor.h"
|
||||
#include "/EgtDev/Include/EXeConst.h"
|
||||
#include "/EgtDev/Include/EGkGeoPoint3d.h"
|
||||
#include "/EgtDev/Include/EGkCurve.h"
|
||||
#include "/EgtDev/Include/EGkCurveArc.h"
|
||||
#include "/EgtDev/Include/EGkCurveBezier.h"
|
||||
@@ -27,7 +28,7 @@
|
||||
#include "/EgtDev/Include/EGkDistPointCurve.h"
|
||||
#include "/EgtDev/Include/EGkIntersCurves.h"
|
||||
#include "/EgtDev/Include/EGkSurfFlatRegion.h"
|
||||
#include "/EgtDev/Include/EGkGeoPoint3d.h"
|
||||
#include "/EgtDev/Include/EGkSurfBezier.h"
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
@@ -680,34 +681,76 @@ ExeCurveCompoNormVersor( int nId, int nSimpCrv, int nRefId, Vector3d& vtNorm)
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
ExeShowBezierCurveControlPoints( int nCrvId, int* pnCount)
|
||||
int
|
||||
ExeShowCurveBezierControlPoints( int nCrvId, int* pnCount)
|
||||
{
|
||||
IGeomDB* pGeomDB = GetCurrGeomDB() ;
|
||||
VERIFY_GEOMDB( pGeomDB, false)
|
||||
// recupero la curva di bezier
|
||||
const ICurveBezier* pCrvBezier = GetCurveBezier( pGeomDB->GetGeoObj( nCrvId)) ;
|
||||
if ( pCrvBezier == nullptr || pCrvBezier->GetType() != CRV_BEZIER)
|
||||
return false ;
|
||||
int nParent = pGeomDB->GetParentId( nCrvId) ;
|
||||
int nDeg = pCrvBezier->GetDegree() ;
|
||||
bool bRat = pCrvBezier->IsRational() ;
|
||||
int nFirstId = -1 ;
|
||||
int nCount = 0 ;
|
||||
for ( int i = 0 ; i < nDeg + 1 ; ++i) {
|
||||
IGeoPoint3d* pGeoPt( CreateGeoPoint3d()) ;
|
||||
if ( ! bRat)
|
||||
pGeoPt->Set( pCrvBezier->GetControlPoint( i)) ;
|
||||
else
|
||||
pGeoPt->Set( pCrvBezier->GetControlPoint( i) * pCrvBezier->GetControlWeight( i)) ;
|
||||
int nId = pGeomDB->AddGeoObj( GDB_ID_NULL, nParent, pGeoPt) ;
|
||||
if ( nFirstId == GDB_ID_NULL)
|
||||
nFirstId = nId ;
|
||||
if ( nId != GDB_ID_NULL)
|
||||
++nCount ;
|
||||
IGeoObj* pGeoObj = pGeomDB->GetGeoObj( nCrvId) ;
|
||||
int nType = pGeoObj->GetType() ;
|
||||
if ( nType == CRV_COMPO) {
|
||||
const ICurveComposite* pCrvCompo = GetCurveComposite( pGeoObj) ;
|
||||
if ( pCrvCompo == nullptr)
|
||||
return false ;
|
||||
int nParent = pGeomDB->GetParentId( nCrvId) ;
|
||||
int nFirstId = -1 ;
|
||||
int nCount = 0 ;
|
||||
for ( int i = 0 ; i < pCrvCompo->GetCurveCount() ; ++i) {
|
||||
const ICurveBezier* pCrvBezier = GetCurveBezier( pCrvCompo->GetCurve(i)) ;
|
||||
if ( pCrvBezier == nullptr) {
|
||||
if ( pnCount != nullptr)
|
||||
*pnCount = nCount ;
|
||||
return nFirstId ;
|
||||
}
|
||||
int nDeg = pCrvBezier->GetDegree() ;
|
||||
bool bRat = pCrvBezier->IsRational() ;
|
||||
for ( int i = 0 ; i < nDeg + 1 ; ++i) {
|
||||
IGeoPoint3d* pGeoPt( CreateGeoPoint3d()) ;
|
||||
//if ( ! bRat)
|
||||
// pGeoPt->Set( pCrvBezier->GetControlPoint( i)) ;
|
||||
//else
|
||||
// pGeoPt->Set( pCrvBezier->GetControlPoint( i) * pCrvBezier->GetControlWeight( i)) ;
|
||||
pGeoPt->Set( pCrvBezier->GetControlPoint( i)) ;
|
||||
int nId = pGeomDB->AddGeoObj( GDB_ID_NULL, nParent, pGeoPt) ;
|
||||
if ( nFirstId == GDB_ID_NULL)
|
||||
nFirstId = nId ;
|
||||
if ( nId != GDB_ID_NULL)
|
||||
++nCount ;
|
||||
}
|
||||
}
|
||||
// restituisco i risultati
|
||||
if ( pnCount != nullptr)
|
||||
*pnCount = nCount ;
|
||||
return nFirstId ;
|
||||
}
|
||||
// restituisco i risultati
|
||||
if ( pnCount != nullptr)
|
||||
*pnCount = nCount ;
|
||||
return nFirstId ;
|
||||
else if ( nType == CRV_BEZIER) {
|
||||
const ICurveBezier* pCrvBezier = GetCurveBezier( pGeoObj) ;
|
||||
if ( pCrvBezier == nullptr)
|
||||
return false ;
|
||||
int nParent = pGeomDB->GetParentId( nCrvId) ;
|
||||
int nDeg = pCrvBezier->GetDegree() ;
|
||||
bool bRat = pCrvBezier->IsRational() ;
|
||||
int nFirstId = -1 ;
|
||||
int nCount = 0 ;
|
||||
for ( int i = 0 ; i < nDeg + 1 ; ++i) {
|
||||
IGeoPoint3d* pGeoPt( CreateGeoPoint3d()) ;
|
||||
//if ( ! bRat)
|
||||
// pGeoPt->Set( pCrvBezier->GetControlPoint( i)) ;
|
||||
//else
|
||||
// pGeoPt->Set( pCrvBezier->GetControlPoint( i) * pCrvBezier->GetControlWeight( i)) ;
|
||||
pGeoPt->Set( pCrvBezier->GetControlPoint( i)) ;
|
||||
int nId = pGeomDB->AddGeoObj( GDB_ID_NULL, nParent, pGeoPt) ;
|
||||
if ( nFirstId == GDB_ID_NULL)
|
||||
nFirstId = nId ;
|
||||
if ( nId != GDB_ID_NULL)
|
||||
++nCount ;
|
||||
}
|
||||
// restituisco i risultati
|
||||
if ( pnCount != nullptr)
|
||||
*pnCount = nCount ;
|
||||
return nFirstId ;
|
||||
}
|
||||
else
|
||||
return GDB_ID_NULL ;
|
||||
}
|
||||
|
||||
+3
-3
@@ -533,14 +533,14 @@ LuaCurveCompoNormVersor( lua_State* L)
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
static int
|
||||
LuaShowBezierCurveControlPoint( lua_State* L)
|
||||
LuaShowCurveBezierControlPoints( lua_State* L)
|
||||
{
|
||||
// 1 parametro : nCrvId
|
||||
int nCrvId ;
|
||||
LuaCheckParam( L, 1, nCrvId)
|
||||
LuaClearStack( L) ;
|
||||
int nCount = 0 ;
|
||||
int nId = ExeShowBezierCurveControlPoints( nCrvId, &nCount) ;
|
||||
int nId = ExeShowCurveBezierControlPoints( nCrvId, &nCount) ;
|
||||
// restituisco il risultato
|
||||
if ( nId != GDB_ID_NULL) {
|
||||
LuaSetParam( L, nId) ;
|
||||
@@ -584,6 +584,6 @@ LuaInstallGdbGetCurve( LuaMgr& luaMgr)
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtCurveCompoRadius", LuaCurveCompoRadius) ;
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtCurveCompoAngCenter", LuaCurveCompoAngCenter) ;
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtCurveCompoNormVersor", LuaCurveCompoNormVersor) ;
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtShowBezierCurveControlPoints", LuaShowBezierCurveControlPoint) ;
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtShowCurveBezierControlPoints", LuaShowCurveBezierControlPoints) ;
|
||||
return bOk ;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user