EgtExecutor 2.2c3 :
- aggiustamenti per cambio nome costante Curva di Bezier - aggiunte funzioni Exe e Lua per superfici di Bezier.
This commit is contained in:
@@ -1422,9 +1422,7 @@ ExeCreateCurveBezier( int nParentId, int nDegree, const PNTVECTOR& vPnt, int nRe
|
||||
if ( IsCmdLog()) {
|
||||
string sPC ;
|
||||
for ( size_t i = 0 ; i < vPnt.size() ; ++ i) {
|
||||
if ( i > 0)
|
||||
sPC += "," ;
|
||||
sPC += "{" + ToString( vPnt[i]) + "}" ;
|
||||
sPC += ( i == 0 ? "{" : ",{") + ToString( vPnt[i]) + "}" ;
|
||||
}
|
||||
string sLua = "EgtCurveBezier(" + IdToString( nParentId) + "," +
|
||||
ToString( nDegree) + ",{" +
|
||||
@@ -1475,9 +1473,7 @@ ExeCreateCurveBezierRational( int nParentId, int nDegree, const PNTUVECTOR& vPnt
|
||||
if ( IsCmdLog()) {
|
||||
string sPC ;
|
||||
for ( size_t i = 0 ; i < vPntW.size() ; ++ i) {
|
||||
if ( i > 0)
|
||||
sPC += "," ;
|
||||
sPC += "{" + ToString( vPntW[i].first, vPntW[i].second) + "}" ;
|
||||
sPC += ( i == 0 ? "{" : ",{") + ToString( vPntW[i].first, vPntW[i].second) + "}" ;
|
||||
}
|
||||
string sLua = "EgtCurveBezierRat(" + IdToString( nParentId) + "," +
|
||||
ToString( nDegree) + ",{" +
|
||||
|
||||
@@ -21,9 +21,11 @@
|
||||
#include "/EgtDev/Include/EXeConst.h"
|
||||
#include "/EgtDev/Include/EGkSurfFlatRegion.h"
|
||||
#include "/EgtDev/Include/EGkSfrCreate.h"
|
||||
#include "/EgtDev/Include/EGkSurfTriMesh.h"
|
||||
#include "/EgtDev/Include/EGkStmStandard.h"
|
||||
#include "/EgtDev/Include/EGkStmFromCurves.h"
|
||||
#include "/EgtDev/Include/EGkStmFromTriangleSoup.h"
|
||||
#include "/EgtDev/Include/EGkSurfBezier.h"
|
||||
#include "/EgtDev/Include/EGkPolygon3d.h"
|
||||
#include "/EgtDev/Include/EGkVolZmap.h"
|
||||
#include "/EgtDev/Include/EgkStringUtils3d.h"
|
||||
@@ -1439,3 +1441,103 @@ ExeCreateSurfTmByVolZmap( int nParentId, int nZmapId, int nPart)
|
||||
// restituisco il risultato
|
||||
return nNewId ;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------
|
||||
int
|
||||
ExeCreateSurfBezier( int nParentId, int nDegU, int nDegV, const PNTVECTOR& vPnt, int nRefType)
|
||||
{
|
||||
IGeomDB* pGeomDB = GetCurrGeomDB() ;
|
||||
VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL)
|
||||
nParentId = AdjustId( nParentId) ;
|
||||
bool bOk = true ;
|
||||
// il numero dei punti deve essere pari al prodotto dei gradi + 1
|
||||
int nDim = ( nDegU + 1) * ( nDegV + 1) ;
|
||||
bOk = bOk && ( vPnt.size() == nDim) ;
|
||||
// recupero il riferimento di immersione della superficie
|
||||
Frame3d frLoc ;
|
||||
bOk = bOk && pGeomDB->GetGroupGlobFrame( nParentId, frLoc) ;
|
||||
// creo la superficie di Bezier
|
||||
PtrOwner<ISurfBezier> pSurfBez( CreateSurfBezier()) ;
|
||||
bOk = bOk && ! IsNull( pSurfBez) ;
|
||||
// inizializzo la superficie di Bezier
|
||||
bOk = bOk && pSurfBez->Init( nDegU, nDegV, false) ;
|
||||
// setto i punti di controllo
|
||||
for ( int i = 0 ; i < nDim && bOk ; ++ i) {
|
||||
// eventuale trasformazione del punto nel riferimento locale
|
||||
Point3d ptCtrl = GetPointLocal( pGeomDB, vPnt[i], nRefType, frLoc) ;
|
||||
// inserimento del punto di controllo
|
||||
if ( ! pSurfBez->SetControlPoint( i, ptCtrl))
|
||||
bOk = false ;
|
||||
}
|
||||
// se superficie nulla (ovvero ridotta a punto), errore
|
||||
bOk = bOk && ! pSurfBez->IsAPoint() ;
|
||||
// inserisco la superficie nel DB
|
||||
int nId = ( bOk ? pGeomDB->AddGeoObj( GDB_ID_NULL, nParentId, Release( pSurfBez)) : GDB_ID_NULL) ;
|
||||
ExeSetModified() ;
|
||||
// se richiesto, salvo il comando Lua equivalente
|
||||
if ( IsCmdLog()) {
|
||||
string sPC ;
|
||||
for ( size_t i = 0 ; i < vPnt.size() ; ++ i) {
|
||||
sPC += ( i == 0 ? "{" : ",{") + ToString( vPnt[i]) + "}" ;
|
||||
}
|
||||
string sLua = "EgtSurfBezier(" + IdToString( nParentId) + "," +
|
||||
ToString( nDegU) + "," +
|
||||
ToString( nDegV) + ",{" +
|
||||
sPC + "}," +
|
||||
RefTypeToString( nRefType) + ")" +
|
||||
" -- Id=" + ToString( nId) ;
|
||||
LOG_INFO( GetCmdLogger(), sLua.c_str()) ;
|
||||
}
|
||||
// restituisco l'identificativo della nuova entità
|
||||
return nId ;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------
|
||||
int
|
||||
ExeCreateSurfBezierRational( int nParentId, int nDegU, int nDegV, const PNTUVECTOR& vPntW, int nRefType)
|
||||
{
|
||||
IGeomDB* pGeomDB = GetCurrGeomDB() ;
|
||||
VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL)
|
||||
nParentId = AdjustId( nParentId) ;
|
||||
bool bOk = true ;
|
||||
// il numero dei punti deve essere pari al prodotto dei gradi + 1
|
||||
int nDim = ( nDegU + 1) * ( nDegV + 1) ;
|
||||
bOk = bOk && ( vPntW.size() == nDim) ;
|
||||
// recupero il riferimento di immersione della superficie
|
||||
Frame3d frLoc ;
|
||||
bOk = bOk && pGeomDB->GetGroupGlobFrame( nParentId, frLoc) ;
|
||||
// creo la superficie di Bezier
|
||||
PtrOwner<ISurfBezier> pSurfBez( CreateSurfBezier()) ;
|
||||
bOk = bOk && ! IsNull( pSurfBez) ;
|
||||
// inizializzo la superficie di Bezier
|
||||
bOk = bOk && pSurfBez->Init( nDegU, nDegV, true) ;
|
||||
// setto i punti di controllo
|
||||
for ( int i = 0 ; i < nDim && bOk ; ++ i) {
|
||||
// eventuale trasformazione del punto nel riferimento locale
|
||||
Point3d ptCtrl = GetPointLocal( pGeomDB, vPntW[i].first, nRefType, frLoc) ;
|
||||
// inserimento del punto di controllo
|
||||
if ( ! pSurfBez->SetControlPoint( i, ptCtrl, vPntW[i].second))
|
||||
bOk = false ;
|
||||
}
|
||||
// se superficie nulla (ovvero ridotta a punto), errore
|
||||
bOk = bOk && ! pSurfBez->IsAPoint() ;
|
||||
// inserisco la superficie nel DB
|
||||
int nId = ( bOk ? pGeomDB->AddGeoObj( GDB_ID_NULL, nParentId, Release( pSurfBez)) : GDB_ID_NULL) ;
|
||||
ExeSetModified() ;
|
||||
// se richiesto, salvo il comando Lua equivalente
|
||||
if ( IsCmdLog()) {
|
||||
string sPC ;
|
||||
for ( size_t i = 0 ; i < vPntW.size() ; ++ i) {
|
||||
sPC += ( i == 0 ? "{" : ",{") + ToString( vPntW[i].first, vPntW[i].second) + "}" ;
|
||||
}
|
||||
string sLua = "EgtSurfBezierRat(" + IdToString( nParentId) + "," +
|
||||
ToString( nDegU) + "," +
|
||||
ToString( nDegV) + ",{" +
|
||||
sPC + "}," +
|
||||
RefTypeToString( nRefType) + ")" +
|
||||
" -- Id=" + ToString( nId) ;
|
||||
LOG_INFO( GetCmdLogger(), sLua.c_str()) ;
|
||||
}
|
||||
// restituisco l'identificativo della nuova entità
|
||||
return nId ;
|
||||
}
|
||||
|
||||
+100
@@ -0,0 +1,100 @@
|
||||
//----------------------------------------------------------------------------
|
||||
// EgalTech 2020-2020
|
||||
//----------------------------------------------------------------------------
|
||||
// File : EXE_GdbGet.cpp Data : 23.03.20 Versione : 2.2c3
|
||||
// Contenuto : Funzioni di interrogazione di entità del DBG per EXE.
|
||||
//
|
||||
//
|
||||
//
|
||||
// Modifiche : 23.03.20 DS Creazione modulo.
|
||||
//
|
||||
//
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
//--------------------------- Include ----------------------------------------
|
||||
#include "stdafx.h"
|
||||
#include "EXE.h"
|
||||
#include "EXE_Const.h"
|
||||
#include "EXE_Macro.h"
|
||||
#include "GeoTools.h"
|
||||
#include "/EgtDev/Include/EXeExecutor.h"
|
||||
#include "/EgtDev/Include/EXeConst.h"
|
||||
#include "/EgtDev/Include/EGkExtText.h"
|
||||
|
||||
using namespace std ;
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
ExeTextNormVersor( int nId, int nRefId, Vector3d& vtNorm)
|
||||
{
|
||||
IGeomDB* pGeomDB = GetCurrGeomDB() ;
|
||||
VERIFY_GEOMDB( pGeomDB, false)
|
||||
// recupero il testo
|
||||
const IExtText* pTxt = GetExtText( pGeomDB->GetGeoObj( nId)) ;
|
||||
if ( pTxt == nullptr)
|
||||
return false ;
|
||||
// recupero la normale
|
||||
vtNorm = pTxt->GetNormVersor() ;
|
||||
// gestione trasformazione ( eventuale)
|
||||
return TransformVector( pGeomDB, nId, nRefId, vtNorm) ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
ExeTextGetContent( int nId, string& sText)
|
||||
{
|
||||
IGeomDB* pGeomDB = GetCurrGeomDB() ;
|
||||
VERIFY_GEOMDB( pGeomDB, false)
|
||||
// recupero il testo
|
||||
const IExtText* pTxt = GetExtText( pGeomDB->GetGeoObj( nId)) ;
|
||||
if ( pTxt == nullptr)
|
||||
return false ;
|
||||
// recupero il contenuto
|
||||
sText = pTxt->GetText() ;
|
||||
return true ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
ExeTextGetFont( int nId, string& sFont)
|
||||
{
|
||||
IGeomDB* pGeomDB = GetCurrGeomDB() ;
|
||||
VERIFY_GEOMDB( pGeomDB, false)
|
||||
// recupero il testo
|
||||
const IExtText* pTxt = GetExtText( pGeomDB->GetGeoObj( nId)) ;
|
||||
if ( pTxt == nullptr)
|
||||
return false ;
|
||||
// recupero il font
|
||||
sFont = pTxt->GetFont() ;
|
||||
return true ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
ExeTextGetHeight( int nId, double& dH)
|
||||
{
|
||||
IGeomDB* pGeomDB = GetCurrGeomDB() ;
|
||||
VERIFY_GEOMDB( pGeomDB, false)
|
||||
// recupero il testo
|
||||
const IExtText* pTxt = GetExtText( pGeomDB->GetGeoObj( nId)) ;
|
||||
if ( pTxt == nullptr)
|
||||
return false ;
|
||||
// recupero l'altezza
|
||||
dH = pTxt->GetHeight() ;
|
||||
return true ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
ExeTextGetItalic( int nId, bool& bItl)
|
||||
{
|
||||
IGeomDB* pGeomDB = GetCurrGeomDB() ;
|
||||
VERIFY_GEOMDB( pGeomDB, false)
|
||||
// recupero il testo
|
||||
const IExtText* pTxt = GetExtText( pGeomDB->GetGeoObj( nId)) ;
|
||||
if ( pTxt == nullptr)
|
||||
return false ;
|
||||
// recupero l'altezza
|
||||
bItl = pTxt->GetItalic() ;
|
||||
return true ;
|
||||
}
|
||||
@@ -0,0 +1,476 @@
|
||||
//----------------------------------------------------------------------------
|
||||
// EgalTech 2020-2020
|
||||
//----------------------------------------------------------------------------
|
||||
// File : EXE_GeoSnap.cpp Data : 23.03.20 Versione : 2.2c3
|
||||
// Contenuto : Funzioni di interrogazione di curve del DBG per EXE.
|
||||
//
|
||||
//
|
||||
//
|
||||
// Modifiche : 23.03.20 DS Creazione modulo.
|
||||
//
|
||||
//
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
//--------------------------- Include ----------------------------------------
|
||||
#include "stdafx.h"
|
||||
#include "EXE.h"
|
||||
#include "EXE_Const.h"
|
||||
#include "EXE_Macro.h"
|
||||
#include "GeoTools.h"
|
||||
#include "/EgtDev/Include/EXeExecutor.h"
|
||||
#include "/EgtDev/Include/EXeConst.h"
|
||||
#include "/EgtDev/Include/EGkCurve.h"
|
||||
#include "/EgtDev/Include/EGkCurveArc.h"
|
||||
#include "/EgtDev/Include/EGkCurveComposite.h"
|
||||
#include "/EgtDev/Include/EGkDistPointCurve.h"
|
||||
#include "/EgtDev/Include/EGkIntersCurves.h"
|
||||
#include "/EgtDev/Include/EGkSurfFlatRegion.h"
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
ExeCurveDomain( int nId, double* pdStart, double* pdEnd)
|
||||
{
|
||||
IGeomDB* pGeomDB = GetCurrGeomDB() ;
|
||||
VERIFY_GEOMDB( pGeomDB, false)
|
||||
// verifico i parametri
|
||||
if ( pdStart == nullptr || pdEnd == nullptr)
|
||||
return false ;
|
||||
// recupero la curva
|
||||
ICurve* pCurve = GetCurve( pGeomDB->GetGeoObj( nId)) ;
|
||||
// recupero il dominio
|
||||
return ( pCurve != nullptr && pCurve->GetDomain( *pdStart, *pdEnd)) ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
ExeCurveLength( int nId, double* pdLen)
|
||||
{
|
||||
IGeomDB* pGeomDB = GetCurrGeomDB() ;
|
||||
VERIFY_GEOMDB( pGeomDB, false)
|
||||
// verifico il parametro
|
||||
if ( pdLen == nullptr)
|
||||
return false ;
|
||||
// recupero la curva
|
||||
ICurve* pCurve = GetCurve( pGeomDB->GetGeoObj( nId)) ;
|
||||
// recupero la lunghezza
|
||||
return ( pCurve != nullptr && pCurve->GetLength( *pdLen)) ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
ExeCurveLengthAtPoint( int nId, const Point3d& ptOn, double dExtend, double* pdLen)
|
||||
{
|
||||
IGeomDB* pGeomDB = GetCurrGeomDB() ;
|
||||
VERIFY_GEOMDB( pGeomDB, false)
|
||||
// verifico il parametro
|
||||
if ( pdLen == nullptr)
|
||||
return false ;
|
||||
// recupero la curva
|
||||
const ICurve* pCurve = GetCurve( pGeomDB->GetGeoObj( nId)) ;
|
||||
if ( pCurve == nullptr)
|
||||
return false ;
|
||||
// determino la posizione parametrica del punto sulla curva (con tolleranza)
|
||||
int nFlag ;
|
||||
double dU ;
|
||||
if ( ! DistPointCurve( ptOn, *pCurve).GetParamAtMinDistPoint( 0, dU, nFlag) || nFlag != MDPCI_NORMAL)
|
||||
return false ;
|
||||
// se non richiesta estensione o punto interno alla curva, recupero la lunghezza alla posizione parametrica
|
||||
if ( dExtend < EPS_SMALL ||
|
||||
( ! pCurve->IsStartParam( dU) && ! pCurve->IsEndParam( dU)))
|
||||
return ( pCurve->GetLengthAtParam( dU, *pdLen) ? true : false) ;
|
||||
// allungo la curva dalla parte del punto
|
||||
PtrOwner<ICurve> pCopy( pCurve->Clone()) ;
|
||||
if ( IsNull( pCopy))
|
||||
return false ;
|
||||
double dDeltaIni ;
|
||||
if ( pCopy->IsStartParam( dU)) {
|
||||
pCopy->ExtendStartByLen( dExtend) ;
|
||||
dDeltaIni = dExtend ;
|
||||
}
|
||||
else {
|
||||
pCopy->ExtendEndByLen( dExtend) ;
|
||||
dDeltaIni = 0 ;
|
||||
}
|
||||
if ( ! DistPointCurve( ptOn, *pCopy).GetParamAtMinDistPoint( 0, dU, nFlag) || nFlag != MDPCI_NORMAL)
|
||||
return false ;
|
||||
if ( pCopy->GetLengthAtParam( dU, *pdLen)) {
|
||||
*pdLen -= dDeltaIni ;
|
||||
return true ;
|
||||
}
|
||||
return false ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
ExeCurveIsClosed( int nId)
|
||||
{
|
||||
IGeomDB* pGeomDB = GetCurrGeomDB() ;
|
||||
VERIFY_GEOMDB( pGeomDB, false)
|
||||
// recupero la curva
|
||||
ICurve* pCurve = GetCurve( pGeomDB->GetGeoObj( nId)) ;
|
||||
// verifico se chiusa
|
||||
return ( pCurve != nullptr && pCurve->IsClosed()) ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
ExeCurveIsFlat( int nId, Plane3d& Plane, double dToler)
|
||||
{
|
||||
IGeomDB* pGeomDB = GetCurrGeomDB() ;
|
||||
VERIFY_GEOMDB( pGeomDB, false)
|
||||
// verifico il parametro
|
||||
if ( &Plane == nullptr)
|
||||
return false ;
|
||||
// recupero la curva
|
||||
ICurve* pCurve = GetCurve( pGeomDB->GetGeoObj( nId)) ;
|
||||
// ne verifico la planarità
|
||||
return ( pCurve != nullptr && pCurve->IsFlat( Plane, dToler)) ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
ExeCurveAreaXY( int nId, double& dArea)
|
||||
{
|
||||
IGeomDB* pGeomDB = GetCurrGeomDB() ;
|
||||
VERIFY_GEOMDB( pGeomDB, false)
|
||||
// verifico il parametro
|
||||
if ( &dArea == nullptr)
|
||||
return false ;
|
||||
// recupero la curva
|
||||
ICurve* pCurve = GetCurve( pGeomDB->GetGeoObj( nId)) ;
|
||||
// determino l'area nel piano XY
|
||||
return ( pCurve != nullptr && pCurve->GetAreaXY( dArea)) ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
ExeCurveArea( int nId, Plane3d& Plane, double& dArea)
|
||||
{
|
||||
IGeomDB* pGeomDB = GetCurrGeomDB() ;
|
||||
VERIFY_GEOMDB( pGeomDB, false)
|
||||
// verifico i parametri
|
||||
if ( &Plane == nullptr || &dArea == nullptr)
|
||||
return false ;
|
||||
// recupero la curva
|
||||
ICurve* pCurve = GetCurve( pGeomDB->GetGeoObj( nId)) ;
|
||||
// determino il piano medio della curva e la sua area su di esso (deve essere chiusa)
|
||||
return ( pCurve != nullptr && pCurve->GetArea( Plane, dArea)) ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
ExeCurveNearestExtremityToPoint( int nId, const Point3d& ptP, bool& bStart)
|
||||
{
|
||||
IGeomDB* pGeomDB = GetCurrGeomDB() ;
|
||||
VERIFY_GEOMDB( pGeomDB, false)
|
||||
// recupero la curva
|
||||
ICurve* pCurve = GetCurve( pGeomDB->GetGeoObj( nId)) ;
|
||||
// recupero quale estremo è più vicino al punto
|
||||
return ( pCurve != nullptr && pCurve->GetNearestExtremityToPoint( ptP, bStart)) ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
ExeCurveExtrusion( int nId, int nRefId, Vector3d& vtExtr)
|
||||
{
|
||||
IGeomDB* pGeomDB = GetCurrGeomDB() ;
|
||||
VERIFY_GEOMDB( pGeomDB, false)
|
||||
// recupero la curva
|
||||
ICurve* pCurve = GetCurve( pGeomDB->GetGeoObj( nId)) ;
|
||||
// ne ricavo il vettore estrusione
|
||||
if ( pCurve == nullptr || ! pCurve->GetExtrusion( vtExtr))
|
||||
return false ;
|
||||
// gestione trasformazione ( eventuale)
|
||||
return TransformVector( pGeomDB, nId, nRefId, vtExtr) ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
ExeCurveThickness( int nId, double* pdThick)
|
||||
{
|
||||
IGeomDB* pGeomDB = GetCurrGeomDB() ;
|
||||
VERIFY_GEOMDB( pGeomDB, false)
|
||||
// verifico il parametro
|
||||
if ( pdThick == nullptr)
|
||||
return false ;
|
||||
// recupero la curva
|
||||
ICurve* pCurve = GetCurve( pGeomDB->GetGeoObj( nId)) ;
|
||||
// recupero lo spessore
|
||||
return ( pCurve != nullptr && pCurve->GetThickness( *pdThick)) ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
ExeCurveSelfIntersCount( int nId, int* pnCount)
|
||||
{
|
||||
IGeomDB* pGeomDB = GetCurrGeomDB() ;
|
||||
VERIFY_GEOMDB( pGeomDB, false)
|
||||
// verifico il parametro
|
||||
if ( pnCount == nullptr)
|
||||
return false ;
|
||||
// recupero la curva
|
||||
ICurve* pCurve = GetCurve( pGeomDB->GetGeoObj( nId)) ;
|
||||
if ( pCurve == nullptr)
|
||||
return false ;
|
||||
// calcolo le auto-intersezioni
|
||||
SelfIntersCurve sintC( *pCurve) ;
|
||||
// ne recupero il numero
|
||||
*pnCount = sintC.GetIntersCount() ;
|
||||
return true ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
ExeCurveMinAreaRectangleXY( int nId, int nRefId, Frame3d& frRect, double& dDimX, double& dDimY)
|
||||
{
|
||||
IGeomDB* pGeomDB = GetCurrGeomDB() ;
|
||||
VERIFY_GEOMDB( pGeomDB, false)
|
||||
// recupero la curva
|
||||
ICurve* pCurve = GetCurve( pGeomDB->GetGeoObj( nId)) ;
|
||||
bool bOk = ( pCurve != nullptr) ;
|
||||
// recupero il riferimento della curva
|
||||
Frame3d frCrv ;
|
||||
bOk = bOk && pGeomDB->GetGlobFrame( nId, frCrv) ;
|
||||
// derivo la polilinea di approssimazione della curva entro la tolleranza standard
|
||||
PolyLine PL ;
|
||||
bOk = bOk && pCurve->ApproxWithLines( LIN_TOL_FINE, ANG_TOL_STD_DEG, APP_LINES, PL) ;
|
||||
// eventuale trasformazione per riferimento di espressione
|
||||
if ( bOk && nRefId == GDB_ID_ROOT)
|
||||
PL.ToGlob( frCrv) ;
|
||||
else if ( bOk && nRefId == GDB_ID_GRID)
|
||||
PL.LocToLoc( frCrv, pGeomDB->GetGridFrame()) ;
|
||||
else if ( bOk && nRefId != nId) {
|
||||
Frame3d frDest ;
|
||||
// nRefId può essere un gruppo o una entità
|
||||
if ( pGeomDB->GetGroupGlobFrame( nRefId, frDest) ||
|
||||
pGeomDB->GetGlobFrame( nRefId, frDest))
|
||||
PL.LocToLoc( frCrv, frDest) ;
|
||||
else
|
||||
bOk = false ;
|
||||
}
|
||||
// derivo il rettangolo in XY di area minima di questa
|
||||
Point3d ptCen ;
|
||||
Vector3d vtAx ;
|
||||
bOk = bOk && PL.GetMinAreaRectangleXY( ptCen, vtAx, dDimX, dDimY) &&
|
||||
frRect.Set( ptCen, Z_AX, vtAx) ;
|
||||
return bOk ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
int
|
||||
ExeClosedCurveClassify( int nId1, int nId2)
|
||||
{
|
||||
IGeomDB* pGeomDB = GetCurrGeomDB() ;
|
||||
VERIFY_GEOMDB( pGeomDB, 0)
|
||||
// recupero la prima curva
|
||||
const ICurve* pCrv1 = GetCurve( pGeomDB->GetGeoObj( nId1)) ;
|
||||
if ( pCrv1 == nullptr || ! pCrv1->IsClosed())
|
||||
return CCREGC_NULL ;
|
||||
// recupero il riferimento della curva
|
||||
Frame3d frCrv1 ;
|
||||
if ( ! pGeomDB->GetGlobFrame( nId1, frCrv1))
|
||||
return CCREGC_NULL ;
|
||||
// recupero la seconda curva
|
||||
const ICurve* pCrv2 = GetCurve( pGeomDB->GetGeoObj( nId2)) ;
|
||||
if ( pCrv2 == nullptr || ! pCrv2->IsClosed())
|
||||
return CCREGC_NULL ;
|
||||
// recupero il riferimento della curva
|
||||
Frame3d frCrv2 ;
|
||||
if ( ! pGeomDB->GetGlobFrame( nId2, frCrv2))
|
||||
return CCREGC_NULL ;
|
||||
// se riferimenti diversi, porto una copia della seconda nel riferimento della prima
|
||||
const ICurve* pCrv2L = pCrv2 ;
|
||||
PtrOwner<ICurve> pTmp ;
|
||||
if ( ! AreSameFrame( frCrv1, frCrv2)) {
|
||||
pTmp.Set( pCrv2->Clone()) ;
|
||||
if ( IsNull( pTmp) || ! pTmp->LocToLoc( frCrv2, frCrv1))
|
||||
return CCREGC_NULL ;
|
||||
pCrv2L = pTmp ;
|
||||
}
|
||||
|
||||
// classifico la prima curva rispetto alla seconda
|
||||
IntersCurveCurve ccInt( *pCrv1, *pCrv2L) ;
|
||||
return ccInt.GetRegionCurveClassification() ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
int
|
||||
ExeCurveWithRegionClassify( int nCurveId, int nRegionId)
|
||||
{
|
||||
IGeomDB* pGeomDB = GetCurrGeomDB() ;
|
||||
VERIFY_GEOMDB( pGeomDB, 0)
|
||||
// recupero la curva e il suo riferimento
|
||||
const ICurve* pCrv = GetCurve( pGeomDB->GetGeoObj( nCurveId)) ;
|
||||
if ( pCrv == nullptr)
|
||||
return CRC_NULL ;
|
||||
// recupero il riferimento della curva
|
||||
Frame3d frCrv ;
|
||||
if ( ! pGeomDB->GetGlobFrame( nCurveId, frCrv))
|
||||
return CRC_NULL ;
|
||||
// recupero la superficie FlatRegion e il suo riferimento
|
||||
ISurfFlatRegion* pSfr = GetSurfFlatRegion( pGeomDB->GetGeoObj( nRegionId)) ;
|
||||
if ( pSfr == nullptr)
|
||||
return CRC_NULL ;
|
||||
// recupero il riferimento della superficie
|
||||
Frame3d frSurf ;
|
||||
if ( ! pGeomDB->GetGlobFrame( nRegionId, frSurf))
|
||||
return CRC_NULL ;
|
||||
// se riferimenti diversi, porto una copia della curva nel riferimento della superficie
|
||||
const ICurve* pCrvL = pCrv ;
|
||||
PtrOwner<ICurve> pTmp ;
|
||||
if ( ! AreSameFrame( frCrv, frSurf)) {
|
||||
pTmp.Set( pCrv->Clone()) ;
|
||||
if ( IsNull( pTmp))
|
||||
return CRC_NULL ;
|
||||
pTmp->LocToLoc( frCrv, frSurf) ;
|
||||
pCrvL = pTmp ;
|
||||
}
|
||||
// classifico la curva rispetto alla regione
|
||||
CRVCVECTOR vcClass ;
|
||||
if ( ! pSfr->GetCurveClassification( *pCrvL, vcClass))
|
||||
return CRC_NULL ;
|
||||
int nRes = CRC_NULL ;
|
||||
for ( auto& cClass : vcClass) {
|
||||
switch ( cClass.nClass) {
|
||||
case CRVC_NULL :
|
||||
return CRC_NULL ;
|
||||
break ;
|
||||
case CRVC_IN :
|
||||
if ( nRes == CRC_NULL || nRes == CRC_IN || nRes == CRC_ON)
|
||||
nRes = CRC_IN ;
|
||||
else
|
||||
nRes = CRC_INTERS ;
|
||||
break ;
|
||||
case CRVC_OUT :
|
||||
if ( nRes == CRC_NULL || nRes == CRC_OUT || nRes == CRC_ON)
|
||||
nRes = CRC_OUT ;
|
||||
else
|
||||
nRes = CRC_INTERS ;
|
||||
break ;
|
||||
case CRVC_ON_P :
|
||||
case CRVC_ON_M :
|
||||
if ( nRes == CRC_NULL)
|
||||
nRes = CRC_ON ;
|
||||
break ;
|
||||
}
|
||||
}
|
||||
|
||||
return nRes ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
ExeArcRadius( int nId, double* pdRad)
|
||||
{
|
||||
IGeomDB* pGeomDB = GetCurrGeomDB() ;
|
||||
VERIFY_GEOMDB( pGeomDB, false)
|
||||
// verifico il parametro
|
||||
if ( pdRad == nullptr)
|
||||
return false ;
|
||||
// recupero l'arco
|
||||
const ICurveArc* pArc = GetCurveArc( pGeomDB->GetGeoObj( nId)) ;
|
||||
if ( pArc == nullptr)
|
||||
return false ;
|
||||
*pdRad = pArc->GetRadius() ;
|
||||
return true ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
ExeArcAngCenter( int nId, double* pdAngDeg)
|
||||
{
|
||||
IGeomDB* pGeomDB = GetCurrGeomDB() ;
|
||||
VERIFY_GEOMDB( pGeomDB, false)
|
||||
// verifico il parametro
|
||||
if ( pdAngDeg == nullptr)
|
||||
return false ;
|
||||
// recupero l'arco
|
||||
const ICurveArc* pArc = GetCurveArc( pGeomDB->GetGeoObj( nId)) ;
|
||||
if ( pArc == nullptr)
|
||||
return false ;
|
||||
*pdAngDeg = pArc->GetAngCenter() ;
|
||||
return true ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
ExeArcDeltaN( int nId, double* pdDeltaN)
|
||||
{
|
||||
IGeomDB* pGeomDB = GetCurrGeomDB() ;
|
||||
VERIFY_GEOMDB( pGeomDB, false)
|
||||
// verifico il parametro
|
||||
if ( pdDeltaN == nullptr)
|
||||
return false ;
|
||||
// recupero l'arco
|
||||
const ICurveArc* pArc = GetCurveArc( pGeomDB->GetGeoObj( nId)) ;
|
||||
if ( pArc == nullptr)
|
||||
return false ;
|
||||
*pdDeltaN = pArc->GetDeltaN() ;
|
||||
return true ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
ExeArcNormVersor( int nId, int nRefId, Vector3d& vtNorm)
|
||||
{
|
||||
IGeomDB* pGeomDB = GetCurrGeomDB() ;
|
||||
VERIFY_GEOMDB( pGeomDB, false)
|
||||
// recupero l'arco
|
||||
const ICurveArc* pArc = GetCurveArc( pGeomDB->GetGeoObj( nId)) ;
|
||||
if ( pArc == nullptr)
|
||||
return false ;
|
||||
// recupero la normale
|
||||
vtNorm = pArc->GetNormVersor() ;
|
||||
// gestione trasformazione ( eventuale)
|
||||
return TransformVector( pGeomDB, nId, nRefId, vtNorm) ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
ExeCurveCompoCenter( 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 TransformPoint( pGeomDB, nId, nRefId, ptCen) ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
ExeCurveCompoRadius( int nId, int nSimpCrv, double& dRad)
|
||||
{
|
||||
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 ;
|
||||
// a seconda del tipo di curva
|
||||
switch ( pSimpCrv->GetType()) {
|
||||
case CRV_LINE :
|
||||
dRad = -1 ;
|
||||
break ;
|
||||
case CRV_ARC :
|
||||
dRad = GetCurveArc( pSimpCrv)->GetRadius() ;
|
||||
break ;
|
||||
case CRV_BEZIER :
|
||||
dRad = -2 ;
|
||||
break ;
|
||||
}
|
||||
return true ;
|
||||
}
|
||||
@@ -0,0 +1,821 @@
|
||||
//----------------------------------------------------------------------------
|
||||
// EgalTech 2020-2020
|
||||
//----------------------------------------------------------------------------
|
||||
// File : EXE_GeoSnap.cpp Data : 23.03.20 Versione : 2.2c3
|
||||
// Contenuto : Funzioni di interrogazione di superfici del DBG per EXE.
|
||||
//
|
||||
//
|
||||
//
|
||||
// Modifiche : 23.03.20 DS Creazione modulo.
|
||||
//
|
||||
//
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
//--------------------------- Include ----------------------------------------
|
||||
#include "stdafx.h"
|
||||
#include "EXE.h"
|
||||
#include "EXE_Const.h"
|
||||
#include "EXE_Macro.h"
|
||||
#include "GeoTools.h"
|
||||
#include "/EgtDev/Include/EXeExecutor.h"
|
||||
#include "/EgtDev/Include/EXeConst.h"
|
||||
#include "/EgtDev/Include/EGkCurveComposite.h"
|
||||
#include "/EgtDev/Include/EGkCurveLocal.h"
|
||||
#include "/EgtDev/Include/EGkSurf.h"
|
||||
#include "/EgtDev/Include/EGkSurfFlatRegion.h"
|
||||
#include "/EgtDev/Include/EGkSurfTriMesh.h"
|
||||
#include "/EgtDev/Include/EGkSurfBezier.h"
|
||||
#include "/EgtDev/Include/EGkSurfLocal.h"
|
||||
#include "/EgtDev/Include/EGkStringUtils3d.h"
|
||||
|
||||
using namespace std ;
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
ExeSurfArea( int nId, double& dArea)
|
||||
{
|
||||
IGeomDB* pGeomDB = GetCurrGeomDB() ;
|
||||
VERIFY_GEOMDB( pGeomDB, false)
|
||||
// verifico il parametro
|
||||
if ( &dArea == nullptr)
|
||||
return false ;
|
||||
// recupero la superficie
|
||||
ISurf* pSurf = GetSurf( pGeomDB->GetGeoObj( nId)) ;
|
||||
// ne restituisco l'area
|
||||
return ( pSurf != nullptr && pSurf->GetArea( dArea)) ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
ExeSurfVolume( int nId, double& dVol)
|
||||
{
|
||||
IGeomDB* pGeomDB = GetCurrGeomDB() ;
|
||||
VERIFY_GEOMDB( pGeomDB, false)
|
||||
// verifico il parametro
|
||||
if ( &dVol == nullptr)
|
||||
return false ;
|
||||
// recupero la superficie
|
||||
ISurf* pSurf = GetSurf( pGeomDB->GetGeoObj( nId)) ;
|
||||
// ne restituisco l'eventuale volume (se è chiusa)
|
||||
return ( pSurf != nullptr && pSurf->GetVolume( dVol)) ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
ExeSurfFrNormVersor( int nId, int nRefId, Vector3d& vtNorm)
|
||||
{
|
||||
IGeomDB* pGeomDB = GetCurrGeomDB() ;
|
||||
VERIFY_GEOMDB( pGeomDB, false)
|
||||
// recupero la Regione
|
||||
const ISurfFlatRegion* pSfr = GetSurfFlatRegion( pGeomDB->GetGeoObj( nId)) ;
|
||||
if ( pSfr == nullptr)
|
||||
return false ;
|
||||
// recupero la normale
|
||||
vtNorm = pSfr->GetNormVersor() ;
|
||||
// gestione trasformazione ( eventuale)
|
||||
return TransformVector( pGeomDB, nId, nRefId, vtNorm) ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
ExeSurfFrGrossArea( int nId, double& dArea)
|
||||
{
|
||||
IGeomDB* pGeomDB = GetCurrGeomDB() ;
|
||||
VERIFY_GEOMDB( pGeomDB, false)
|
||||
// verifico il parametro
|
||||
if ( &dArea == nullptr)
|
||||
return false ;
|
||||
// recupero la Regione
|
||||
const ISurfFlatRegion* pSfr = GetSurfFlatRegion( pGeomDB->GetGeoObj( nId)) ;
|
||||
// ne restituisco l'area senza eventuali buchi
|
||||
return ( pSfr != nullptr && pSfr->GetGrossArea( dArea)) ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
int
|
||||
ExeSurfFrChunkCount( int nId)
|
||||
{
|
||||
IGeomDB* pGeomDB = GetCurrGeomDB() ;
|
||||
VERIFY_GEOMDB( pGeomDB, 0)
|
||||
// recupero la regione
|
||||
const ISurfFlatRegion* pSfr = GetSurfFlatRegion( pGeomDB->GetGeoObj( nId)) ;
|
||||
if ( pSfr == nullptr)
|
||||
return false ;
|
||||
// recupero il numero di chunk
|
||||
return pSfr->GetChunkCount() ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
int
|
||||
ExeSurfFrChunkSimpleClassify( int nId1, int nChunk1, int nId2, int nChunk2)
|
||||
{
|
||||
IGeomDB* pGeomDB = GetCurrGeomDB() ;
|
||||
VERIFY_GEOMDB( pGeomDB, 0)
|
||||
// recupero la prima superficie FlatRegion
|
||||
ISurfFlatRegion* pSfr1 = GetSurfFlatRegion( pGeomDB->GetGeoObj( nId1)) ;
|
||||
bool bOk = ( pSfr1 != nullptr) ;
|
||||
// recupero il riferimento della superficie
|
||||
Frame3d frSurf1 ;
|
||||
bOk = bOk && pGeomDB->GetGlobFrame( nId1, frSurf1) ;
|
||||
// recupero la seconda superficie FlatRegion
|
||||
const ISurfFlatRegion* pSfr2 = GetSurfFlatRegion( pGeomDB->GetGeoObj( nId2)) ;
|
||||
bOk = bOk && ( pSfr2 != nullptr) ;
|
||||
// recupero il riferimento della superficie
|
||||
Frame3d frSurf2 ;
|
||||
bOk = bOk && pGeomDB->GetGlobFrame( nId2, frSurf2) ;
|
||||
// se riferimenti diversi, porto una copia della seconda nel riferimento della prima
|
||||
const ISurfFlatRegion* pSfr2L = pSfr2 ;
|
||||
PtrOwner<ISurfFlatRegion> pTmp ;
|
||||
if ( ! AreSameFrame( frSurf1, frSurf2)) {
|
||||
pTmp.Set( pSfr2->Clone()) ;
|
||||
bOk = bOk && ! IsNull( pTmp) ;
|
||||
bOk = bOk && pTmp->LocToLoc( frSurf2, frSurf1) ;
|
||||
pSfr2L = pTmp ;
|
||||
}
|
||||
// classifico il chunk della prima regione rispetto a quello della seconda
|
||||
int nRes = ( bOk ? pSfr1->GetChunkSimpleClassification( nChunk1, *pSfr2L, nChunk2) : REGC_NULL) ;
|
||||
return nRes ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
ExeSurfFrTestExternal( int nId1, int nId2, double dMinDist)
|
||||
{
|
||||
IGeomDB* pGeomDB = GetCurrGeomDB() ;
|
||||
VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL)
|
||||
// recupero la prima superficie FlatRegion
|
||||
ISurfFlatRegion* pSfr1 = GetSurfFlatRegion( pGeomDB->GetGeoObj( nId1)) ;
|
||||
if ( pSfr1 == nullptr)
|
||||
return false ;
|
||||
// se richiesta distanza di sicurezza, ne faccio l'offset
|
||||
PtrOwner<ISurfFlatRegion> pSfr1O( pSfr1->Clone()) ;
|
||||
if ( IsNull( pSfr1O))
|
||||
return false ;
|
||||
if ( dMinDist > 10 * EPS_SMALL)
|
||||
pSfr1O->Offset( dMinDist, ICurve::OFF_FILLET) ;
|
||||
// recupero il riferimento della superficie
|
||||
Frame3d frSurf1 ;
|
||||
if ( ! pGeomDB->GetGlobFrame( nId1, frSurf1))
|
||||
return false ;
|
||||
// recupero il tipo della seconda entità
|
||||
int nType2 = pGeomDB->GetGeoType( nId2) ;
|
||||
// se seconda entità regione
|
||||
if ( nType2 == SRF_FLATRGN) {
|
||||
// recupero la seconda superficie FlatRegion in locale alla prima
|
||||
SurfLocal Surf2Loc( pGeomDB, nId2, frSurf1) ;
|
||||
const ISurfFlatRegion* pSfr2L = GetSurfFlatRegion( Surf2Loc) ;
|
||||
if ( pSfr2L == nullptr)
|
||||
return false ;
|
||||
// eseguo il test di intersezione tra le due regioni
|
||||
for ( int i = 0 ; i < pSfr1O->GetChunkCount() ; ++ i) {
|
||||
for ( int j = 0 ; j < pSfr2L->GetChunkCount() ; ++ j) {
|
||||
if ( pSfr1O->GetChunkSimpleClassification( i, *pSfr2L, j) != REGC_OUT)
|
||||
return false ;
|
||||
}
|
||||
}
|
||||
return true ;
|
||||
}
|
||||
// se altrimenti curva
|
||||
else if ( (nType2 & GEO_CURVE) != 0) {
|
||||
// recupero la curva in locale alla regione
|
||||
CurveLocal Crv2Loc( pGeomDB, nId2, frSurf1) ;
|
||||
const ICurve* pCrv2L = Crv2Loc.Get() ;
|
||||
if ( pCrv2L == nullptr)
|
||||
return false ;
|
||||
// eseguo il test di intersezione tra regione e curva
|
||||
for ( int i = 0 ; i < pSfr1O->GetChunkCount() ; ++ i) {
|
||||
PtrOwner<ICurve> pCrv1( pSfr1O->GetLoop( i, 0)) ;
|
||||
if ( pCrv1 == nullptr)
|
||||
return false ;
|
||||
IntersCurveCurve ccInt( *pCrv1, *pCrv2L) ;
|
||||
CRVCVECTOR vcClass ;
|
||||
if ( ! ccInt.GetCurveClassification( 1, vcClass) || vcClass.empty())
|
||||
return false ;
|
||||
for ( auto& cClass : vcClass) {
|
||||
if ( cClass.nClass == CRVC_IN || cClass.nClass == CRVC_NULL)
|
||||
return false ;
|
||||
}
|
||||
}
|
||||
return true ;
|
||||
}
|
||||
// altrimenti non valida
|
||||
else
|
||||
return false ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
int
|
||||
ExeSurfTmFacetCount( int nId)
|
||||
{
|
||||
IGeomDB* pGeomDB = GetCurrGeomDB() ;
|
||||
VERIFY_GEOMDB( pGeomDB, 0)
|
||||
// recupero la superficie trimesh
|
||||
const ISurfTriMesh* pStm = GetSurfTriMesh( pGeomDB->GetGeoObj( nId)) ;
|
||||
if ( pStm == nullptr)
|
||||
return 0 ;
|
||||
// recupero il numero delle facce
|
||||
return pStm->GetFacetCount() ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
int
|
||||
ExeSurfTmFacetFromTria( int nId, int nT)
|
||||
{
|
||||
IGeomDB* pGeomDB = GetCurrGeomDB() ;
|
||||
VERIFY_GEOMDB( pGeomDB, SVT_NULL)
|
||||
// recupero la superficie trimesh
|
||||
const ISurfTriMesh* pStm = GetSurfTriMesh( pGeomDB->GetGeoObj( nId)) ;
|
||||
if ( pStm == nullptr)
|
||||
return SVT_NULL ;
|
||||
// recupero il numero della faccia da quello di un suo triangolo
|
||||
return pStm->GetFacetFromTria( nT) ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
ExeSurfTmFacetAdjacencies( int nId, int nFacet, INTMATRIX& vAdj)
|
||||
{
|
||||
IGeomDB* pGeomDB = GetCurrGeomDB() ;
|
||||
VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL)
|
||||
// recupero la superficie TriMesh
|
||||
const ISurfTriMesh* pStm = GetSurfTriMesh( pGeomDB->GetGeoObj( nId)) ;
|
||||
bool bOk = ( pStm != nullptr) ;
|
||||
// recupero le adiacenze
|
||||
bOk = bOk && pStm->GetFacetAdjacencies( nFacet, vAdj) ;
|
||||
return bOk ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
ExeSurfTmFacetNearestEndPoint( int nId, int nFacet, const Point3d& ptNear, int nRefId,
|
||||
Point3d& ptEnd, Vector3d& vtN)
|
||||
{
|
||||
IGeomDB* pGeomDB = GetCurrGeomDB() ;
|
||||
VERIFY_GEOMDB( pGeomDB, false)
|
||||
// recupero la superficie trimesh
|
||||
const ISurfTriMesh* pStm = GetSurfTriMesh( pGeomDB->GetGeoObj( nId)) ;
|
||||
if ( pStm == nullptr)
|
||||
return false ;
|
||||
// porto il punto Near nel riferimento dell'entità
|
||||
Point3d ptNearL = ptNear ;
|
||||
if ( ! InvTransformPoint( pGeomDB, nId, nRefId, ptNearL))
|
||||
return false ;
|
||||
// recupero il punto End più vicino della faccia
|
||||
if ( ! pStm->GetFacetNearestEndPoint( nFacet, ptNearL, ptEnd, vtN))
|
||||
return false ;
|
||||
// gestione trasformazioni ( eventuali)
|
||||
return TransformPoint( pGeomDB, nId, nRefId, ptEnd) && TransformVector( pGeomDB, nId, nRefId, vtN) ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
ExeSurfTmFacetNearestMidPoint( int nId, int nFacet, const Point3d& ptNear, int nRefId,
|
||||
Point3d& ptMid, Vector3d& vtN)
|
||||
{
|
||||
IGeomDB* pGeomDB = GetCurrGeomDB() ;
|
||||
VERIFY_GEOMDB( pGeomDB, false)
|
||||
// recupero la superficie trimesh
|
||||
const ISurfTriMesh* pStm = GetSurfTriMesh( pGeomDB->GetGeoObj( nId)) ;
|
||||
if ( pStm == nullptr)
|
||||
return false ;
|
||||
// porto il punto Near nel riferimento dell'entità
|
||||
Point3d ptNearL = ptNear ;
|
||||
if ( ! InvTransformPoint( pGeomDB, nId, nRefId, ptNearL))
|
||||
return false ;
|
||||
// recupero il punto Mid più vicino della faccia
|
||||
if ( ! pStm->GetFacetNearestMidPoint( nFacet, ptNearL, ptMid, vtN))
|
||||
return false ;
|
||||
// gestione trasformazioni ( eventuali)
|
||||
return TransformPoint( pGeomDB, nId, nRefId, ptMid) && TransformVector( pGeomDB, nId, nRefId, vtN) ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
ExeSurfTmFacetCenter( int nId, int nFacet, int nRefId, Point3d& ptCen, Vector3d& vtN)
|
||||
{
|
||||
IGeomDB* pGeomDB = GetCurrGeomDB() ;
|
||||
VERIFY_GEOMDB( pGeomDB, false)
|
||||
// recupero la superficie trimesh
|
||||
const ISurfTriMesh* pStm = GetSurfTriMesh( pGeomDB->GetGeoObj( nId)) ;
|
||||
if ( pStm == nullptr)
|
||||
return false ;
|
||||
// recupero il centro della faccia
|
||||
if ( ! pStm->GetFacetCenter( nFacet, ptCen, vtN))
|
||||
return false ;
|
||||
// gestione trasformazioni ( eventuali)
|
||||
return TransformPoint( pGeomDB, nId, nRefId, ptCen) && TransformVector( pGeomDB, nId, nRefId, vtN) ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
ExeSurfTmFacetNormVersor( int nId, int nFacet, int nRefId, Vector3d& vtNorm)
|
||||
{
|
||||
IGeomDB* pGeomDB = GetCurrGeomDB() ;
|
||||
VERIFY_GEOMDB( pGeomDB, false)
|
||||
// recupero la superficie trimesh
|
||||
const ISurfTriMesh* pStm = GetSurfTriMesh( pGeomDB->GetGeoObj( nId)) ;
|
||||
if ( pStm == nullptr)
|
||||
return false ;
|
||||
// recupero il centro della faccia
|
||||
if ( ! pStm->GetFacetNormal( nFacet, vtNorm))
|
||||
return false ;
|
||||
// gestione trasformazione ( eventuale)
|
||||
return TransformVector( pGeomDB, nId, nRefId, vtNorm) ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
ExeSurfTmFacetMinAreaRectangle( int nId, int nFacet, int nRefId, Frame3d& frRect, double& dDimX, double& dDimY)
|
||||
{
|
||||
IGeomDB* pGeomDB = GetCurrGeomDB() ;
|
||||
VERIFY_GEOMDB( pGeomDB, false)
|
||||
// recupero la superficie trimesh
|
||||
const ISurfTriMesh* pStm = GetSurfTriMesh( pGeomDB->GetGeoObj( nId)) ;
|
||||
if ( pStm == nullptr)
|
||||
return false ;
|
||||
// recupero il centro e la normale della faccia
|
||||
Point3d ptCen ; Vector3d vtN ;
|
||||
if ( ! pStm->GetFacetCenter( nFacet, ptCen, vtN))
|
||||
return false ;
|
||||
// calcolo il riferimento OCS della faccia
|
||||
Frame3d frFac ;
|
||||
if ( ! frFac.Set( ptCen, vtN))
|
||||
return false ;
|
||||
// recupero il contorno esterno della faccia e lo porto nel suo riferimento
|
||||
POLYLINEVECTOR vPL ;
|
||||
pStm->GetFacetLoops( nFacet, vPL) ;
|
||||
if ( vPL.empty())
|
||||
return false ;
|
||||
vPL[0].ToLoc( frFac) ;
|
||||
// derivo il rettangolo in XY di area minima di questa
|
||||
Point3d ptOri ;
|
||||
Vector3d vtAx ;
|
||||
if ( ! vPL[0].GetMinAreaRectangleXY( ptOri, vtAx, dDimX, dDimY) || ! frRect.Set( ptOri, Z_AX, vtAx))
|
||||
return false ;
|
||||
// esprimo il riferimento rispetto a quello richiesto
|
||||
frRect.ToGlob( frFac) ;
|
||||
return TransformFrame( pGeomDB, nId, nRefId, frRect) ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
ExeSurfTmFacetOppositeSide( int nId, int nFacet, const Vector3d& vtDir, int nRefId,
|
||||
Point3d& ptP1, Point3d& ptP2)
|
||||
{
|
||||
Point3d ptPm ;
|
||||
Vector3d vtIn1, vtOut2;
|
||||
double dLen, dWidth ;
|
||||
return ExeSurfTmFacetOppositeSideEx( nId, nFacet, vtDir, nRefId, ptP1, ptPm, ptP2, vtIn1, vtOut2, dLen, dWidth) ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
ExeSurfTmFacetOppositeSideEx( int nId, int nFacet, const Vector3d& vtDir, int nRefId,
|
||||
Point3d& ptP1, Point3d& ptPm, Point3d& ptP2, Vector3d& vtIn1, Vector3d& vtOut2, double& dLen, double& dWidth)
|
||||
{
|
||||
IGeomDB* pGeomDB = GetCurrGeomDB() ;
|
||||
VERIFY_GEOMDB( pGeomDB, false)
|
||||
// recupero il riferimento della trimesh
|
||||
Frame3d frStm ;
|
||||
if ( ! pGeomDB->GetGlobFrame( nId, frStm))
|
||||
return false ;
|
||||
// recupero la superficie trimesh
|
||||
const ISurfTriMesh* pStm = GetSurfTriMesh( pGeomDB->GetGeoObj( nId)) ;
|
||||
if ( pStm == nullptr)
|
||||
return false ;
|
||||
// recupero i contorni della faccia
|
||||
POLYLINEVECTOR vPL ;
|
||||
pStm->GetFacetLoops( nFacet, vPL) ;
|
||||
if ( vPL.empty())
|
||||
return false ;
|
||||
// recupero la normale esterna della faccia
|
||||
Point3d ptCen ;
|
||||
Vector3d vtN ;
|
||||
if ( ! pStm->GetFacetCenter( nFacet, ptCen, vtN))
|
||||
return false ;
|
||||
// creo la curva a partire dal contorno esterno
|
||||
PtrOwner<ICurveComposite> pCrvCompo( CreateCurveComposite()) ;
|
||||
if ( IsNull( pCrvCompo) || ! pCrvCompo->FromPolyLine( vPL[0]))
|
||||
return false ;
|
||||
// unisco parti allineate
|
||||
pCrvCompo->MergeCurves( LIN_TOL_STD, ANG_TOL_STD_DEG) ;
|
||||
// porto la direzione nel riferimento della superficie
|
||||
Vector3d vtDirL = vtDir ;
|
||||
if ( ! InvTransformVector( pGeomDB, nId, nRefId, vtDirL))
|
||||
return false ;
|
||||
// costruisco un riferimento con Z su normale e X vicino a direzione
|
||||
Frame3d frSpec ;
|
||||
if ( ! frSpec.Set( ptCen, vtN, vtDirL))
|
||||
return false ;
|
||||
// porto il contorno in questo riferimento
|
||||
pCrvCompo->ToLoc( frSpec) ;
|
||||
// ne faccio una copia per usi successivi
|
||||
PtrOwner<ICurveComposite> pCrvCopy( pCrvCompo->Clone()) ;
|
||||
// la direzione di riferimento è l'asse X, la sostituisco con quella perpendicolare alla curva più adatta
|
||||
Vector3d vtRef = X_AX ;
|
||||
double dCosMax = -1 ;
|
||||
const ICurve* pCrv = pCrvCompo->GetFirstCurve() ;
|
||||
while ( pCrv != nullptr) {
|
||||
Vector3d vtDir ; pCrv->GetMidDir( vtDir) ;
|
||||
Vector3d vtPerp = Z_AX ^ vtDir ;
|
||||
double dCos = vtPerp * X_AX ;
|
||||
if ( dCos > dCosMax) {
|
||||
dCosMax = dCos ;
|
||||
vtRef = vtPerp ;
|
||||
}
|
||||
pCrv = pCrvCompo->GetNextCurve() ;
|
||||
}
|
||||
// la curva gira in senso antiorario attorno al contorno faccia vista dalla normale uscente
|
||||
// elimino i segmenti che hanno la direzione di riferimento a destra o quasi (46deg)
|
||||
const double COS_ANG_MAX = cos( 46 * DEGTORAD) ;
|
||||
const double MIN_DIR_LEN = 0.999 ;
|
||||
// cerco primo elemento del contorno non valido e vi pongo inizio/fine della curva
|
||||
int i = 0 ;
|
||||
pCrv = pCrvCompo->GetFirstCurve() ;
|
||||
while ( pCrv != nullptr) {
|
||||
double dCrvLen = 0 ; pCrv->GetLength( dCrvLen) ;
|
||||
Vector3d vtDir ; pCrv->GetMidDir( vtDir) ;
|
||||
if ( dCrvLen > MIN_DIR_LEN && ( Z_AX ^ vtDir) * vtRef < COS_ANG_MAX) {
|
||||
vtIn1 = vtDir ;
|
||||
vtOut2 = vtDir ;
|
||||
pCrvCompo->ChangeStartPoint( i) ;
|
||||
break ;
|
||||
}
|
||||
pCrv = pCrvCompo->GetNextCurve() ;
|
||||
++ i ;
|
||||
}
|
||||
// se non trovato almeno un lato non valido, errore
|
||||
if ( pCrv == nullptr)
|
||||
return false ;
|
||||
// a partire da questo elimino elementi non validi in avanti e indietro
|
||||
pCrv = pCrvCompo->GetFirstCurve() ;
|
||||
while ( pCrv != nullptr) {
|
||||
Vector3d vtDir ; pCrv->GetMidDir( vtDir) ;
|
||||
if ( ( Z_AX ^ vtDir) * vtRef < COS_ANG_MAX) {
|
||||
double dCrvLen = 0 ; pCrv->GetLength( dCrvLen) ;
|
||||
if ( dCrvLen > MIN_DIR_LEN)
|
||||
pCrv->GetMidDir( vtIn1) ;
|
||||
delete( pCrvCompo->RemoveFirstOrLastCurve( false)) ;
|
||||
pCrv = pCrvCompo->GetFirstCurve() ;
|
||||
}
|
||||
else
|
||||
break ;
|
||||
}
|
||||
pCrv = pCrvCompo->GetLastCurve() ;
|
||||
while ( pCrv != nullptr) {
|
||||
Vector3d vtDir ; pCrv->GetMidDir( vtDir) ;
|
||||
if ( ( Z_AX ^ vtDir) * vtRef < COS_ANG_MAX) {
|
||||
double dCrvLen = 0 ; pCrv->GetLength( dCrvLen) ;
|
||||
if ( dCrvLen > MIN_DIR_LEN)
|
||||
pCrv->GetMidDir( vtOut2) ;
|
||||
delete( pCrvCompo->RemoveFirstOrLastCurve( true)) ;
|
||||
pCrv = pCrvCompo->GetLastCurve() ;
|
||||
}
|
||||
else
|
||||
break ;
|
||||
}
|
||||
// elimino le curve estreme molto corte ( 0.1 mm)
|
||||
const double REF_LEN = 10.0 ;
|
||||
double dCompoLen ;
|
||||
if ( pCrvCompo->GetLength( dCompoLen) && dCompoLen > REF_LEN) {
|
||||
const double MIN_LEN = 0.1 ;
|
||||
double dCrvLen ;
|
||||
pCrv = pCrvCompo->GetFirstCurve() ;
|
||||
if ( pCrv != nullptr && pCrv->GetLength( dCrvLen) && dCrvLen < MIN_LEN)
|
||||
delete( pCrvCompo->RemoveFirstOrLastCurve( false)) ;
|
||||
pCrv = pCrvCompo->GetLastCurve() ;
|
||||
if ( pCrv != nullptr && pCrv->GetLength( dCrvLen) && dCrvLen < MIN_LEN)
|
||||
delete( pCrvCompo->RemoveFirstOrLastCurve( true)) ;
|
||||
}
|
||||
// recupero i punti estremi della curva
|
||||
if ( ! pCrvCompo->GetStartPoint( ptP1) || ! pCrvCompo->GetEndPoint( ptP2))
|
||||
return false ;
|
||||
// ricavo il punto intermedio
|
||||
if ( pCrvCompo->GetCurveCount() == 1)
|
||||
ptPm = Media( ptP1, ptP2, 0.5) ;
|
||||
else if ( pCrvCompo->GetCurveCount() == 2)
|
||||
pCrvCompo->GetPointD1D2( 1.0, ICurve::FROM_MINUS, ptPm) ;
|
||||
else {
|
||||
double dLen ;
|
||||
pCrvCompo->GetLength( dLen) ;
|
||||
double dU ;
|
||||
pCrvCompo->GetParamAtLength( 0.5 * dLen, dU) ;
|
||||
pCrvCompo->GetPointD1D2( dU, ICurve::FROM_MINUS, ptPm) ;
|
||||
}
|
||||
// determino la lunghezza e l'elevazione della faccia rispetto alla curva trovata
|
||||
Vector3d vtTg = ptP2 - ptP1 ;
|
||||
Frame3d frExtr ;
|
||||
if ( ! frExtr.Set( ORIG, Z_AX, vtTg) || ! frExtr.Invert())
|
||||
return false ;
|
||||
BBox3d b3Extr ; pCrvCopy->GetBBox( frExtr, b3Extr) ;
|
||||
if ( ! b3Extr.IsEmpty()) {
|
||||
dLen = b3Extr.GetMax().x - b3Extr.GetMin().x ;
|
||||
dWidth = b3Extr.GetMax().y - b3Extr.GetMin().y ;
|
||||
}
|
||||
else {
|
||||
dLen = 0 ;
|
||||
dWidth = 0 ;
|
||||
}
|
||||
// porto i punti nel riferimento della superficie e poi in quello richiesto
|
||||
ptP1.ToGlob( frSpec) ;
|
||||
ptPm.ToGlob( frSpec) ;
|
||||
ptP2.ToGlob( frSpec) ;
|
||||
vtIn1.ToGlob( frSpec) ;
|
||||
vtOut2.ToGlob( frSpec) ;
|
||||
return ( TransformPoint( pGeomDB, nId, nRefId, ptP1) &&
|
||||
TransformPoint( pGeomDB, nId, nRefId, ptPm) &&
|
||||
TransformPoint( pGeomDB, nId, nRefId, ptP2) &&
|
||||
TransformVector( pGeomDB, nId, nRefId, vtIn1) &&
|
||||
TransformVector( pGeomDB, nId, nRefId, vtOut2)) ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
ExeSurfTmFacetsContact( int nId, int nF1, int nF2, int nRefId, bool& bAdjac, Point3d& ptP1, Point3d& ptP2, double& dAng)
|
||||
{
|
||||
IGeomDB* pGeomDB = GetCurrGeomDB() ;
|
||||
VERIFY_GEOMDB( pGeomDB, false)
|
||||
// recupero la superficie trimesh
|
||||
const ISurfTriMesh* pStm = GetSurfTriMesh( pGeomDB->GetGeoObj( nId)) ;
|
||||
if ( pStm == nullptr)
|
||||
return false ;
|
||||
// recupero i dati di contatto tra le due facce
|
||||
if ( ! pStm->GetFacetsContact( nF1, nF2, bAdjac, ptP1, ptP2, dAng))
|
||||
return false ;
|
||||
// gestione trasformazione ( eventuale)
|
||||
if ( bAdjac)
|
||||
return TransformPoint( pGeomDB, nId, nRefId, ptP1) && TransformPoint( pGeomDB, nId, nRefId, ptP2) ;
|
||||
else
|
||||
return true ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
ExeSurfBezierGetPoint( int nSurfId, double dU, double dV, int nRefId, Point3d& ptP)
|
||||
{
|
||||
IGeomDB* pGeomDB = GetCurrGeomDB() ;
|
||||
VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL)
|
||||
// recupero la superficie di Bezier
|
||||
const ISurfBezier* pSbz = GetSurfBezier( pGeomDB->GetGeoObj( nSurfId)) ;
|
||||
bool bOk = ( pSbz != nullptr) ;
|
||||
// richiedo il punto
|
||||
bOk = bOk && pSbz->GetPointD1D2( dU, dV, ptP) ;
|
||||
// gestione trasformazioni ( eventuali)
|
||||
bOk = bOk && TransformPoint( pGeomDB, nSurfId, nRefId, ptP) ;
|
||||
// se richiesto, salvo il comando Lua equivalente
|
||||
if ( IsCmdLog()) {
|
||||
string sLua = "EgtSurfBezierGetPoint(" + ToString( nSurfId) + "," +
|
||||
ToString( dU) + "," +
|
||||
ToString( dV) + "," +
|
||||
ToString( nRefId) + ")" +
|
||||
" -- Pnt=" + ( bOk ? "{" + ToString( ptP) + "}" : "nil") ;
|
||||
LOG_INFO( GetCmdLogger(), sLua.c_str()) ;
|
||||
}
|
||||
// restituisco risultati
|
||||
return bOk ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
ExeSurfBezierGetPointD1( int nSurfId, double dU, double dV, int nRefId, Point3d& ptP, Vector3d& vtDerU, Vector3d& vtDerV)
|
||||
{
|
||||
IGeomDB* pGeomDB = GetCurrGeomDB() ;
|
||||
VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL)
|
||||
// recupero la superficie di Bezier
|
||||
const ISurfBezier* pSbz = GetSurfBezier( pGeomDB->GetGeoObj( nSurfId)) ;
|
||||
bool bOk = ( pSbz != nullptr) ;
|
||||
// richiedo il punto
|
||||
bOk = bOk && pSbz->GetPointD1D2( dU, dV, ptP, &vtDerU, &vtDerV) ;
|
||||
// gestione trasformazioni ( eventuali)
|
||||
bOk = bOk && TransformPoint( pGeomDB, nSurfId, nRefId, ptP) &&
|
||||
TransformVector( pGeomDB, nSurfId, nRefId, vtDerU) &&
|
||||
TransformVector( pGeomDB, nSurfId, nRefId, vtDerV) ;
|
||||
// se richiesto, salvo il comando Lua equivalente
|
||||
if ( IsCmdLog()) {
|
||||
string sLua = "EgtSurfBezierGetPointD1(" + ToString( nSurfId) + "," +
|
||||
ToString( dU) + "," +
|
||||
ToString( dV) + "," +
|
||||
ToString( nRefId) + ")" +
|
||||
" -- Pnt=" + ( bOk ? "{" + ToString( ptP) + "}" : "nil") +
|
||||
" DerU=" + ( bOk ? "{" + ToString( vtDerU) + "}" : "nil") +
|
||||
" DerV=" + ( bOk ? "{" + ToString( vtDerV) + "}" : "nil") ;
|
||||
LOG_INFO( GetCmdLogger(), sLua.c_str()) ;
|
||||
}
|
||||
// restituisco risultati
|
||||
return bOk ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
ExeSurfBezierGetPointNrmD1( int nSurfId, double dU, double dV, int nRefId, Point3d& ptP, Vector3d& vtN, Vector3d& vtDerU, Vector3d& vtDerV)
|
||||
{
|
||||
IGeomDB* pGeomDB = GetCurrGeomDB() ;
|
||||
VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL)
|
||||
// recupero la superficie di Bezier
|
||||
const ISurfBezier* pSbz = GetSurfBezier( pGeomDB->GetGeoObj( nSurfId)) ;
|
||||
bool bOk = ( pSbz != nullptr) ;
|
||||
// richiedo il punto
|
||||
bOk = bOk && pSbz->GetPointNrmD1D2( dU, dV, ptP, vtN, &vtDerU, &vtDerV) ;
|
||||
// gestione trasformazioni ( eventuali)
|
||||
bOk = bOk && TransformPoint( pGeomDB, nSurfId, nRefId, ptP) &&
|
||||
TransformVector( pGeomDB, nSurfId, nRefId, vtN) &&
|
||||
TransformVector( pGeomDB, nSurfId, nRefId, vtDerU) &&
|
||||
TransformVector( pGeomDB, nSurfId, nRefId, vtDerV) ;
|
||||
// se richiesto, salvo il comando Lua equivalente
|
||||
if ( IsCmdLog()) {
|
||||
string sLua = "EgtSurfBezierGetPointNrmD1(" + ToString( nSurfId) + "," +
|
||||
ToString( dU) + "," +
|
||||
ToString( dV) + "," +
|
||||
ToString( nRefId) + ")" +
|
||||
" -- Pnt=" + ( bOk ? "{" + ToString( ptP) + "}" : "nil") +
|
||||
" Nrm=" + ( bOk ? "{" + ToString( vtN) + "}" : "nil") +
|
||||
" DerU=" + ( bOk ? "{" + ToString( vtDerU) + "}" : "nil") +
|
||||
" DerV=" + ( bOk ? "{" + ToString( vtDerV) + "}" : "nil") ;
|
||||
LOG_INFO( GetCmdLogger(), sLua.c_str()) ;
|
||||
}
|
||||
// restituisco risultati
|
||||
return bOk ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
int
|
||||
ExeSurfBezierGetCurveU( int nSurfId, double dV, int nDestGrpId)
|
||||
{
|
||||
IGeomDB* pGeomDB = GetCurrGeomDB() ;
|
||||
VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL)
|
||||
// recupero la superficie di Bezier
|
||||
const ISurfBezier* pSbz = GetSurfBezier( pGeomDB->GetGeoObj( nSurfId)) ;
|
||||
bool bOk = ( pSbz != nullptr) ;
|
||||
// recupero il riferimento della superficie
|
||||
Frame3d frSurf ;
|
||||
bOk = bOk && pGeomDB->GetGlobFrame( nSurfId, frSurf) ;
|
||||
// recupero il riferimento di destinazione
|
||||
Frame3d frDest ;
|
||||
bOk = bOk && pGeomDB->GetGroupGlobFrame( nDestGrpId, frDest) ;
|
||||
// richiedo la curva e la inserisco nel DB
|
||||
PolyLine PL ;
|
||||
bOk = bOk && pSbz->GetCurveOnU( dV, PL) ;
|
||||
PtrOwner<ICurveComposite> pCrvCo( CreateCurveComposite()) ;
|
||||
bOk = bOk && ! IsNull( pCrvCo) && pCrvCo->FromPolyLine( PL) ;
|
||||
// porto la curva nel riferimento destinazione
|
||||
bOk = bOk && pCrvCo->LocToLoc( frSurf, frDest) ;
|
||||
// la inserisco nel DB geometrico
|
||||
int nNewId = ( bOk ? pGeomDB->AddGeoObj( GDB_ID_NULL, nDestGrpId, Release( pCrvCo)) : GDB_ID_NULL) ;
|
||||
bOk = bOk && ( nNewId != GDB_ID_NULL) ;
|
||||
// copio il materiale
|
||||
bOk = bOk && pGeomDB->CopyMaterial( nSurfId, nNewId) ;
|
||||
ExeSetModified() ;
|
||||
// se richiesto, salvo il comando Lua equivalente
|
||||
if ( IsCmdLog()) {
|
||||
string sLua = "EgtSurfBezierGetCurveU(" + ToString( nSurfId) + "," +
|
||||
ToString( dV) + "," +
|
||||
ToString( nDestGrpId) + ")" +
|
||||
" -- Id=" + ToString( nNewId) ;
|
||||
LOG_INFO( GetCmdLogger(), sLua.c_str()) ;
|
||||
}
|
||||
// restituisco risultati
|
||||
return nNewId ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
int
|
||||
ExeSurfBezierGetCurveV( int nSurfId, double dU, int nDestGrpId)
|
||||
{
|
||||
IGeomDB* pGeomDB = GetCurrGeomDB() ;
|
||||
VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL)
|
||||
// recupero la superficie di Bezier
|
||||
const ISurfBezier* pSbz = GetSurfBezier( pGeomDB->GetGeoObj( nSurfId)) ;
|
||||
bool bOk = ( pSbz != nullptr) ;
|
||||
// recupero il riferimento della superficie
|
||||
Frame3d frSurf ;
|
||||
bOk = bOk && pGeomDB->GetGlobFrame( nSurfId, frSurf) ;
|
||||
// recupero il riferimento di destinazione
|
||||
Frame3d frDest ;
|
||||
bOk = bOk && pGeomDB->GetGroupGlobFrame( nDestGrpId, frDest) ;
|
||||
// richiedo la curva e la inserisco nel DB
|
||||
PolyLine PL ;
|
||||
bOk = bOk && pSbz->GetCurveOnV( dU, PL) ;
|
||||
PtrOwner<ICurveComposite> pCrvCo( CreateCurveComposite()) ;
|
||||
bOk = bOk && ! IsNull( pCrvCo) && pCrvCo->FromPolyLine( PL) ;
|
||||
// porto la curva nel riferimento destinazione
|
||||
bOk = bOk && pCrvCo->LocToLoc( frSurf, frDest) ;
|
||||
// la inserisco nel DB geometrico
|
||||
int nNewId = ( bOk ? pGeomDB->AddGeoObj( GDB_ID_NULL, nDestGrpId, Release( pCrvCo)) : GDB_ID_NULL) ;
|
||||
bOk = bOk && ( nNewId != GDB_ID_NULL) ;
|
||||
// copio il materiale
|
||||
bOk = bOk && pGeomDB->CopyMaterial( nSurfId, nNewId) ;
|
||||
ExeSetModified() ;
|
||||
// se richiesto, salvo il comando Lua equivalente
|
||||
if ( IsCmdLog()) {
|
||||
string sLua = "EgtSurfBezierGetCurveV(" + ToString( nSurfId) + "," +
|
||||
ToString( dU) + "," +
|
||||
ToString( nDestGrpId) + ")" +
|
||||
" -- Id=" + ToString( nNewId) ;
|
||||
LOG_INFO( GetCmdLogger(), sLua.c_str()) ;
|
||||
}
|
||||
// restituisco risultati
|
||||
return nNewId ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
ExeSurfBezierGetInfo( int nSurfId, int& nDegU, int& nDegV, bool& bIsRat)
|
||||
{
|
||||
IGeomDB* pGeomDB = GetCurrGeomDB() ;
|
||||
VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL)
|
||||
// recupero la superficie di Bezier
|
||||
const ISurfBezier* pSbz = GetSurfBezier( pGeomDB->GetGeoObj( nSurfId)) ;
|
||||
bool bOk = ( pSbz != nullptr) ;
|
||||
// recupero le info (gradi in U e V, flag di razionale)
|
||||
bOk = bOk && pSbz->GetInfo( nDegU, nDegV, bIsRat) ;
|
||||
// se richiesto, salvo il comando Lua equivalente
|
||||
if ( IsCmdLog()) {
|
||||
string sLua = "EgtSurfBezierGetInfo(" + ToString( nSurfId) + ")" +
|
||||
" -- DegU=" + ( bOk ? ToString( nDegU) : "nil") +
|
||||
" -- DegV=" + ( bOk ? ToString( nDegV) : "nil") +
|
||||
" -- IsRat=" + ( bOk ? ToString( bIsRat) : "nil") ;
|
||||
LOG_INFO( GetCmdLogger(), sLua.c_str()) ;
|
||||
}
|
||||
// restituisco risultati
|
||||
return bOk ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
int
|
||||
ExeSurfBezierGetControlCurveU( int nSurfId, int nIndV, int nDestGrpId)
|
||||
{
|
||||
IGeomDB* pGeomDB = GetCurrGeomDB() ;
|
||||
VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL)
|
||||
// recupero la superficie di Bezier
|
||||
const ISurfBezier* pSbz = GetSurfBezier( pGeomDB->GetGeoObj( nSurfId)) ;
|
||||
bool bOk = ( pSbz != nullptr) ;
|
||||
// recupero il riferimento della superficie
|
||||
Frame3d frSurf ;
|
||||
bOk = bOk && pGeomDB->GetGlobFrame( nSurfId, frSurf) ;
|
||||
// recupero il riferimento di destinazione
|
||||
Frame3d frDest ;
|
||||
bOk = bOk && pGeomDB->GetGroupGlobFrame( nDestGrpId, frDest) ;
|
||||
// richiedo la curva e la inserisco nel DB
|
||||
PolyLine PL ;
|
||||
bOk = bOk && pSbz->GetControlCurveOnU( nIndV, PL) ;
|
||||
PtrOwner<ICurveComposite> pCrvCo( CreateCurveComposite()) ;
|
||||
bOk = bOk && ! IsNull( pCrvCo) && pCrvCo->FromPolyLine( PL) ;
|
||||
// porto la curva nel riferimento destinazione
|
||||
bOk = bOk && pCrvCo->LocToLoc( frSurf, frDest) ;
|
||||
// la inserisco nel DB geometrico
|
||||
int nNewId = ( bOk ? pGeomDB->AddGeoObj( GDB_ID_NULL, nDestGrpId, Release( pCrvCo)) : GDB_ID_NULL) ;
|
||||
bOk = bOk && ( nNewId != GDB_ID_NULL) ;
|
||||
// copio il materiale
|
||||
bOk = bOk && pGeomDB->CopyMaterial( nSurfId, nNewId) ;
|
||||
ExeSetModified() ;
|
||||
// se richiesto, salvo il comando Lua equivalente
|
||||
if ( IsCmdLog()) {
|
||||
string sLua = "EgtSurfBezierGetControlCurveU(" + ToString( nSurfId) + "," +
|
||||
ToString( nIndV) + "," +
|
||||
ToString( nDestGrpId) + ")" +
|
||||
" -- Id=" + ToString( nNewId) ;
|
||||
LOG_INFO( GetCmdLogger(), sLua.c_str()) ;
|
||||
}
|
||||
// restituisco risultati
|
||||
return nNewId ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
int
|
||||
ExeSurfBezierGetControlCurveV( int nSurfId, int nIndU, int nDestGrpId)
|
||||
{
|
||||
IGeomDB* pGeomDB = GetCurrGeomDB() ;
|
||||
VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL)
|
||||
// recupero la superficie di Bezier
|
||||
const ISurfBezier* pSbz = GetSurfBezier( pGeomDB->GetGeoObj( nSurfId)) ;
|
||||
bool bOk = ( pSbz != nullptr) ;
|
||||
// recupero il riferimento della superficie
|
||||
Frame3d frSurf ;
|
||||
bOk = bOk && pGeomDB->GetGlobFrame( nSurfId, frSurf) ;
|
||||
// recupero il riferimento di destinazione
|
||||
Frame3d frDest ;
|
||||
bOk = bOk && pGeomDB->GetGroupGlobFrame( nDestGrpId, frDest) ;
|
||||
// richiedo la curva e la inserisco nel DB
|
||||
PolyLine PL ;
|
||||
bOk = bOk && pSbz->GetControlCurveOnV( nIndU, PL) ;
|
||||
PtrOwner<ICurveComposite> pCrvCo( CreateCurveComposite()) ;
|
||||
bOk = bOk && ! IsNull( pCrvCo) && pCrvCo->FromPolyLine( PL) ;
|
||||
// porto la curva nel riferimento destinazione
|
||||
bOk = bOk && pCrvCo->LocToLoc( frSurf, frDest) ;
|
||||
// la inserisco nel DB geometrico
|
||||
int nNewId = ( bOk ? pGeomDB->AddGeoObj( GDB_ID_NULL, nDestGrpId, Release( pCrvCo)) : GDB_ID_NULL) ;
|
||||
bOk = bOk && ( nNewId != GDB_ID_NULL) ;
|
||||
// copio il materiale
|
||||
bOk = bOk && pGeomDB->CopyMaterial( nSurfId, nNewId) ;
|
||||
ExeSetModified() ;
|
||||
// se richiesto, salvo il comando Lua equivalente
|
||||
if ( IsCmdLog()) {
|
||||
string sLua = "EgtSurfBezierGetControlCurveV(" + ToString( nSurfId) + "," +
|
||||
ToString( nIndU) + "," +
|
||||
ToString( nDestGrpId) + ")" +
|
||||
" -- Id=" + ToString( nNewId) ;
|
||||
LOG_INFO( GetCmdLogger(), sLua.c_str()) ;
|
||||
}
|
||||
// restituisco risultati
|
||||
return nNewId ;
|
||||
}
|
||||
@@ -0,0 +1,66 @@
|
||||
//----------------------------------------------------------------------------
|
||||
// EgalTech 2020-2020
|
||||
//----------------------------------------------------------------------------
|
||||
// File : EXE_GeoSnap.cpp Data : 23.03.20 Versione : 2.2c3
|
||||
// Contenuto : Funzioni di interrogazione di volumi del DBG per EXE.
|
||||
//
|
||||
//
|
||||
//
|
||||
// Modifiche : 23.03.20 DS Creazione modulo.
|
||||
//
|
||||
//
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
//--------------------------- Include ----------------------------------------
|
||||
#include "stdafx.h"
|
||||
#include "EXE.h"
|
||||
#include "EXE_Const.h"
|
||||
#include "EXE_Macro.h"
|
||||
#include "GeoTools.h"
|
||||
#include "/EgtDev/Include/EXeExecutor.h"
|
||||
#include "/EgtDev/Include/EXeConst.h"
|
||||
#include "/EgtDev/Include/EGkVolZmap.h"
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
ExeVolZmapVolume( int nId, double& dVol)
|
||||
{
|
||||
IGeomDB* pGeomDB = GetCurrGeomDB() ;
|
||||
VERIFY_GEOMDB( pGeomDB, false)
|
||||
// verifico il parametro
|
||||
if ( &dVol == nullptr)
|
||||
return false ;
|
||||
// recupero il solido Zmap
|
||||
const IVolZmap* pVZM = GetVolZmap( pGeomDB->GetGeoObj( nId)) ;
|
||||
// ne restituisco il volume
|
||||
return ( pVZM != nullptr && pVZM->GetVolume( dVol)) ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
int
|
||||
ExeVolZmapPartCount( int nId)
|
||||
{
|
||||
IGeomDB* pGeomDB = GetCurrGeomDB() ;
|
||||
VERIFY_GEOMDB( pGeomDB, -1)
|
||||
// recupero il solido Zmap
|
||||
const IVolZmap* pVZM = GetVolZmap( pGeomDB->GetGeoObj( nId)) ;
|
||||
if ( pVZM == nullptr)
|
||||
return -1 ;
|
||||
// recupero il numero di parti
|
||||
return pVZM->GetPartCount() ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
ExeVolZmapPartVolume( int nId, int nPart, double& dVol)
|
||||
{
|
||||
IGeomDB* pGeomDB = GetCurrGeomDB() ;
|
||||
VERIFY_GEOMDB( pGeomDB, false)
|
||||
// verifico il parametro
|
||||
if ( &dVol == nullptr)
|
||||
return false ;
|
||||
// recupero il solido Zmap
|
||||
const IVolZmap* pVZM = GetVolZmap( pGeomDB->GetGeoObj( nId)) ;
|
||||
// restituisco il volume della eventuale parte richiesta
|
||||
return ( pVZM != nullptr && pVZM->GetPartVolume( nPart, dVol)) ;
|
||||
}
|
||||
-1101
File diff suppressed because it is too large
Load Diff
@@ -74,7 +74,7 @@ ApproxCurveIfNeeded( IGdbIterator* pEnt, double dToler)
|
||||
bool bSomeBezier = false ;
|
||||
const ICurve* pCrv = pCrvCo->GetFirstCurve() ;
|
||||
while ( pCrv != nullptr) {
|
||||
if ( pCrv->GetType() == CRV_BEZ)
|
||||
if ( pCrv->GetType() == CRV_BEZIER)
|
||||
bSomeBezier = true ;
|
||||
pCrv = pCrvCo->GetNextCurve() ;
|
||||
}
|
||||
|
||||
Binary file not shown.
@@ -245,6 +245,10 @@ copy $(TargetPath) \EgtProg\Dll64</Command>
|
||||
<ClCompile Include="EXE_CAvTool.cpp" />
|
||||
<ClCompile Include="EXE_CDeObjSolid.cpp" />
|
||||
<ClCompile Include="EXE_GdbCreateVol.cpp" />
|
||||
<ClCompile Include="EXE_GdbGet.cpp" />
|
||||
<ClCompile Include="EXE_GdbGetCurve.cpp" />
|
||||
<ClCompile Include="EXE_GdbGetSurf.cpp" />
|
||||
<ClCompile Include="EXE_GdbGetVol.cpp" />
|
||||
<ClCompile Include="EXE_GdbModifyVol.cpp" />
|
||||
<ClCompile Include="EXE_GeoDist.cpp" />
|
||||
<ClCompile Include="EXE_GeoInters.cpp" />
|
||||
@@ -288,6 +292,10 @@ copy $(TargetPath) \EgtProg\Dll64</Command>
|
||||
<ClCompile Include="GseContext.cpp" />
|
||||
<ClCompile Include="LUA_CAvTool.cpp" />
|
||||
<ClCompile Include="LUA_CDeObjSolid.cpp" />
|
||||
<ClCompile Include="LUA_GdbGet.cpp" />
|
||||
<ClCompile Include="LUA_GdbGetCurve.cpp" />
|
||||
<ClCompile Include="LUA_GdbGetSurf.cpp" />
|
||||
<ClCompile Include="LUA_GdbGetVol.cpp" />
|
||||
<ClCompile Include="LUA_GeoDist.cpp" />
|
||||
<ClCompile Include="LUA_GeoInters.cpp" />
|
||||
<ClCompile Include="LUA_Picture.cpp" />
|
||||
|
||||
@@ -350,6 +350,30 @@
|
||||
<ClCompile Include="LUA_CDeObjSolid.cpp">
|
||||
<Filter>File di origine\LUA</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="EXE_GdbGetSurf.cpp">
|
||||
<Filter>File di origine\EXE</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="EXE_GdbGetVol.cpp">
|
||||
<Filter>File di origine\EXE</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="EXE_GdbGetCurve.cpp">
|
||||
<Filter>File di origine\EXE</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="EXE_GdbGet.cpp">
|
||||
<Filter>File di origine\EXE</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="LUA_GdbGetSurf.cpp">
|
||||
<Filter>File di origine\LUA</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="LUA_GdbGetCurve.cpp">
|
||||
<Filter>File di origine\LUA</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="LUA_GdbGetVol.cpp">
|
||||
<Filter>File di origine\LUA</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="LUA_GdbGet.cpp">
|
||||
<Filter>File di origine\LUA</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ResourceCompile Include="EgtExecutor.rc">
|
||||
|
||||
@@ -50,6 +50,18 @@ bool LuaInstallGdbModifySurf( LuaMgr& luaMgr) ;
|
||||
|
||||
//-------------------------- GdbModifyVol -----------------------------------
|
||||
bool LuaInstallGdbModifyVol( LuaMgr& luaMgr) ;
|
||||
|
||||
//-------------------------- GdbGet ------------------------------------------
|
||||
bool LuaInstallGdbGet( LuaMgr& luaMgr) ;
|
||||
|
||||
//-------------------------- GdbGetCurve -------------------------------------
|
||||
bool LuaInstallGdbGetCurve( LuaMgr& luaMgr) ;
|
||||
|
||||
//-------------------------- GdbGetSurf --------------------------------------
|
||||
bool LuaInstallGdbGetSurf( LuaMgr& luaMgr) ;
|
||||
|
||||
//-------------------------- GdbGetVol ---------------------------------------
|
||||
bool LuaInstallGdbGetVol( LuaMgr& luaMgr) ;
|
||||
|
||||
//-------------------------- GdbPartLayer ------------------------------------
|
||||
bool LuaInstallGdbPartLayer( LuaMgr& luaMgr) ;
|
||||
|
||||
@@ -74,6 +74,22 @@ LuaInstallEgtFunctions( LuaMgr& LuaMgr)
|
||||
LOG_ERROR( GetLogger(), "Error in LuaInstallGdbModifyVol (" __FUNCTION__ ")")
|
||||
return false ;
|
||||
}
|
||||
if ( ! LuaInstallGdbGet( LuaMgr)) {
|
||||
LOG_ERROR( GetLogger(), "Error in LuaInstallGdbGet (" __FUNCTION__ ")")
|
||||
return false ;
|
||||
}
|
||||
if ( ! LuaInstallGdbGetCurve( LuaMgr)) {
|
||||
LOG_ERROR( GetLogger(), "Error in LuaInstallGdbGetCurve (" __FUNCTION__ ")")
|
||||
return false ;
|
||||
}
|
||||
if ( ! LuaInstallGdbGetSurf( LuaMgr)) {
|
||||
LOG_ERROR( GetLogger(), "Error in LuaInstallGdbGetSurf (" __FUNCTION__ ")")
|
||||
return false ;
|
||||
}
|
||||
if ( ! LuaInstallGdbGetVol( LuaMgr)) {
|
||||
LOG_ERROR( GetLogger(), "Error in LuaInstallGdbGetVol (" __FUNCTION__ ")")
|
||||
return false ;
|
||||
}
|
||||
if ( ! LuaInstallGdbPartLayer( LuaMgr)) {
|
||||
LOG_ERROR( GetLogger(), "Error in LuaInstallGdbPartLayer (" __FUNCTION__ ")")
|
||||
return false ;
|
||||
|
||||
@@ -696,6 +696,58 @@ LuaCreateSurfTmByVolZmap( lua_State* L)
|
||||
return 1 ;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------
|
||||
static int
|
||||
LuaCreateSurfBezier( lua_State* L)
|
||||
{
|
||||
// 4 o 5 parametri : ParentId, DegreeU, DegreeV, CtrlPnts [, nRefType]
|
||||
int nParentId ;
|
||||
LuaCheckParam( L, 1, nParentId)
|
||||
int nDegU ;
|
||||
LuaCheckParam( L, 2, nDegU)
|
||||
int nDegV ;
|
||||
LuaCheckParam( L, 3, nDegV)
|
||||
PNTVECTOR vPnt ;
|
||||
LuaCheckParam( L, 4, vPnt)
|
||||
int nRefType = RTY_DEFAULT ;
|
||||
LuaGetParam( L, 5, nRefType) ;
|
||||
LuaClearStack( L) ;
|
||||
// creo la superficie
|
||||
int nId = ExeCreateSurfBezier( nParentId, nDegU, nDegV, vPnt, nRefType) ;
|
||||
// restituisco il risultato
|
||||
if ( nId != GDB_ID_NULL)
|
||||
LuaSetParam( L, nId) ;
|
||||
else
|
||||
LuaSetParam( L) ;
|
||||
return 1 ;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------
|
||||
static int
|
||||
LuaCreateSurfBezierRational( lua_State* L)
|
||||
{
|
||||
// 4 o 5 parametri : ParentId, DegreeU, DegreeV, CtrlPntWs [, nRefType]
|
||||
int nParentId ;
|
||||
LuaCheckParam( L, 1, nParentId)
|
||||
int nDegU ;
|
||||
LuaCheckParam( L, 2, nDegU)
|
||||
int nDegV ;
|
||||
LuaCheckParam( L, 3, nDegV)
|
||||
PNTUVECTOR vPntW ;
|
||||
LuaCheckParam( L, 4, vPntW)
|
||||
int nRefType = RTY_DEFAULT ;
|
||||
LuaGetParam( L, 5, nRefType) ;
|
||||
LuaClearStack( L) ;
|
||||
// creo la superficie
|
||||
int nId = ExeCreateSurfBezierRational( nParentId, nDegU, nDegV, vPntW, nRefType) ;
|
||||
// restituisco il risultato
|
||||
if ( nId != GDB_ID_NULL)
|
||||
LuaSetParam( L, nId) ;
|
||||
else
|
||||
LuaSetParam( L) ;
|
||||
return 1 ;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------
|
||||
bool
|
||||
LuaInstallGdbCreateSurf( LuaMgr& luaMgr)
|
||||
@@ -726,5 +778,7 @@ LuaInstallGdbCreateSurf( LuaMgr& luaMgr)
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtSurfTmByTriangles", LuaCreateSurfTmByTriangles) ;
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtSurfTmBySewing", LuaCreateSurfTmBySewing) ;
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtSurfTmByVolZmap", LuaCreateSurfTmByVolZmap) ;
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtSurfBezier", LuaCreateSurfBezier) ;
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtSurfBezierRat", LuaCreateSurfBezierRational) ;
|
||||
return bOk ;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,86 @@
|
||||
//----------------------------------------------------------------------------
|
||||
// EgalTech 2020-2020
|
||||
//----------------------------------------------------------------------------
|
||||
// File : LUA_GdbGetVol.cpp Data : 23.03.20 Versione : 2.2c3
|
||||
// Contenuto : Funzioni di interrogazione dei solidi per LUA.
|
||||
//
|
||||
//
|
||||
//
|
||||
// Modifiche : 23.03.20 DS Creazione modulo.
|
||||
//
|
||||
//
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
//--------------------------- Include ----------------------------------------
|
||||
#include "stdafx.h"
|
||||
#include "LUA.h"
|
||||
#include "/EgtDev/Include/EXeExecutor.h"
|
||||
#include "/EgtDev/Include/EXeConst.h"
|
||||
#include "/EgtDev/Include/EGkGdbConst.h"
|
||||
#include "/EgtDev/Include/EGkLuaAux.h"
|
||||
|
||||
using namespace std ;
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
static int
|
||||
LuaTextNormVersor( lua_State* L)
|
||||
{
|
||||
// 1 o 2 parametri : Id [, nRefId]
|
||||
int nId ;
|
||||
LuaCheckParam( L, 1, nId)
|
||||
int nRefId = nId ;
|
||||
LuaGetParam( L, 2, nRefId) ;
|
||||
LuaClearStack( L) ;
|
||||
// recupero il versore
|
||||
Vector3d vtNorm ;
|
||||
if ( ExeTextNormVersor( nId, nRefId, vtNorm))
|
||||
LuaSetParam( L, vtNorm) ;
|
||||
else
|
||||
LuaSetParam( L) ;
|
||||
return 1 ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
static int
|
||||
LuaTextContent( lua_State* L)
|
||||
{
|
||||
// 1 parametro : Id
|
||||
int nId ;
|
||||
LuaCheckParam( L, 1, nId)
|
||||
LuaClearStack( L) ;
|
||||
// recupero il contenuto
|
||||
string sText ;
|
||||
if ( ExeTextGetContent( nId, sText))
|
||||
LuaSetParam( L, sText) ;
|
||||
else
|
||||
LuaSetParam( L) ;
|
||||
return 1 ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
static int
|
||||
LuaTextFont( lua_State* L)
|
||||
{
|
||||
// 1 parametro : Id
|
||||
int nId ;
|
||||
LuaCheckParam( L, 1, nId)
|
||||
LuaClearStack( L) ;
|
||||
// recupero il font
|
||||
string sFont ;
|
||||
if ( ExeTextGetFont( nId, sFont))
|
||||
LuaSetParam( L, sFont) ;
|
||||
else
|
||||
LuaSetParam( L) ;
|
||||
return 1 ;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------
|
||||
bool
|
||||
LuaInstallGdbGet( LuaMgr& luaMgr)
|
||||
{
|
||||
bool bOk = ( &luaMgr != nullptr) ;
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtTextNormVersor", LuaTextNormVersor) ;
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtTextContent", LuaTextContent) ;
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtTextFont", LuaTextFont) ;
|
||||
return bOk ;
|
||||
}
|
||||
@@ -0,0 +1,387 @@
|
||||
//----------------------------------------------------------------------------
|
||||
// EgalTech 2020-2020
|
||||
//----------------------------------------------------------------------------
|
||||
// File : LUA_GdbGetCurve.cpp Data : 23.03.20 Versione : 2.2c3
|
||||
// Contenuto : Funzioni di interrogazione delle curve per LUA.
|
||||
//
|
||||
//
|
||||
//
|
||||
// Modifiche : 23.03.20 DS Creazione modulo.
|
||||
//
|
||||
//
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
//--------------------------- Include ----------------------------------------
|
||||
#include "stdafx.h"
|
||||
#include "EXE_Const.h"
|
||||
#include "LUA.h"
|
||||
#include "/EgtDev/Include/EXeExecutor.h"
|
||||
#include "/EgtDev/Include/EXeConst.h"
|
||||
#include "/EgtDev/Include/EGkLuaAux.h"
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
static int
|
||||
LuaCurveDomain( lua_State* L)
|
||||
{
|
||||
// 1 parametro : Id
|
||||
int nId ;
|
||||
LuaCheckParam( L, 1, nId)
|
||||
LuaClearStack( L) ;
|
||||
// recupero il dominio della curva
|
||||
double dStart, dEnd ;
|
||||
if ( ExeCurveDomain( nId, &dStart, &dEnd)) {
|
||||
LuaSetParam( L, dStart) ;
|
||||
LuaSetParam( L, dEnd) ;
|
||||
return 2 ;
|
||||
}
|
||||
else {
|
||||
LuaSetParam( 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 ( ExeCurveLength( nId, &dLen))
|
||||
LuaSetParam( L, dLen) ;
|
||||
else
|
||||
LuaSetParam( L) ;
|
||||
return 1 ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
static int
|
||||
LuaCurveIsClosed( lua_State* L)
|
||||
{
|
||||
// 1 parametro : Id
|
||||
int nId ;
|
||||
LuaCheckParam( L, 1, nId)
|
||||
LuaClearStack( L) ;
|
||||
// verifico se curva chiusa
|
||||
bool bClosed = ExeCurveIsClosed( nId) ;
|
||||
LuaSetParam( L, bClosed) ;
|
||||
return 1 ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
static int
|
||||
LuaCurveIsFlat( lua_State* L)
|
||||
{
|
||||
// 1 o 2 parametri : Id [, dToler]
|
||||
int nId ;
|
||||
LuaCheckParam( L, 1, nId)
|
||||
double dToler = EPS_SMALL ;
|
||||
LuaGetParam( L, 2, dToler) ;
|
||||
LuaClearStack( L) ;
|
||||
// verifico se curva piatta e restituisco il piano medio
|
||||
Plane3d Plane ;
|
||||
bool bFlat = ExeCurveIsFlat( nId, Plane, dToler) ;
|
||||
LuaSetParam( L, bFlat) ;
|
||||
LuaSetParam( L, Plane.GetVersN()) ;
|
||||
LuaSetParam( L, Plane.GetDist()) ;
|
||||
return 3 ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
static int
|
||||
LuaCurveAreaXY( lua_State* L)
|
||||
{
|
||||
// 1 parametro : Id
|
||||
int nId ;
|
||||
LuaCheckParam( L, 1, nId)
|
||||
LuaClearStack( L) ;
|
||||
// recupero l'area della curva proiettata sul piano XY
|
||||
double dArea ;
|
||||
if ( ExeCurveAreaXY( nId, dArea))
|
||||
LuaSetParam( L, dArea) ;
|
||||
else
|
||||
LuaSetParam( L) ;
|
||||
return 1 ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
static int
|
||||
LuaCurveArea( lua_State* L)
|
||||
{
|
||||
// 1 parametro : Id
|
||||
int nId ;
|
||||
LuaCheckParam( L, 1, nId)
|
||||
LuaClearStack( L) ;
|
||||
// recupero il piano medio della curva e la sua area su di esso
|
||||
Plane3d Plane ;
|
||||
double dArea ;
|
||||
if ( ExeCurveArea( nId, Plane, dArea)) {
|
||||
LuaSetParam( L, Plane.GetVersN()) ;
|
||||
LuaSetParam( L, Plane.GetDist()) ;
|
||||
LuaSetParam( L, dArea) ;
|
||||
return 3 ;
|
||||
}
|
||||
else {
|
||||
LuaSetParam( L) ;
|
||||
return 1 ;
|
||||
}
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
static int
|
||||
LuaCurveExtrusion( lua_State* L)
|
||||
{
|
||||
// 1 o 2 parametri : Id [, nRefId]
|
||||
int nId ;
|
||||
LuaCheckParam( L, 1, nId)
|
||||
int nRefId = nId ;
|
||||
LuaGetParam( L, 2, nRefId) ;
|
||||
LuaClearStack( L) ;
|
||||
// recupero il versore
|
||||
Vector3d vtExtr ;
|
||||
if ( ExeCurveExtrusion( nId, nRefId, vtExtr))
|
||||
LuaSetParam( L, vtExtr) ;
|
||||
else
|
||||
LuaSetParam( L) ;
|
||||
return 1 ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
static int
|
||||
LuaCurveThickness( lua_State* L)
|
||||
{
|
||||
// 1 parametro : Id
|
||||
int nId ;
|
||||
LuaCheckParam( L, 1, nId)
|
||||
LuaClearStack( L) ;
|
||||
// recupero lo spessore
|
||||
double dThick ;
|
||||
if ( ExeCurveThickness( nId, &dThick))
|
||||
LuaSetParam( L, dThick) ;
|
||||
else
|
||||
LuaSetParam( L) ;
|
||||
return 1 ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
static int
|
||||
LuaCurveSelfIntersCount( lua_State* L)
|
||||
{
|
||||
// 1 parametro : Id
|
||||
int nId ;
|
||||
LuaCheckParam( L, 1, nId)
|
||||
LuaClearStack( L) ;
|
||||
// recupero il numero di auto-intersezioni
|
||||
int nCount ;
|
||||
if ( ExeCurveSelfIntersCount( nId, &nCount))
|
||||
LuaSetParam( L, nCount) ;
|
||||
else
|
||||
LuaSetParam( L) ;
|
||||
return 1 ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
static int
|
||||
LuaCurveMinAreaRectangleXY( lua_State* L)
|
||||
{
|
||||
// 1 o 2 parametri : Id [, nRefId]
|
||||
int nId ;
|
||||
LuaCheckParam( L, 1, nId)
|
||||
int nRefId = nId ;
|
||||
LuaGetParam( L, 2, nRefId) ;
|
||||
LuaClearStack( L) ;
|
||||
// recupero i dati del rettangolo
|
||||
Frame3d frRect ;
|
||||
double dDimX ;
|
||||
double dDimY ;
|
||||
bool bOk = ExeCurveMinAreaRectangleXY( nId, nRefId, frRect, dDimX, dDimY) ;
|
||||
if ( bOk) {
|
||||
LuaSetParam( L, frRect) ;
|
||||
LuaSetParam( L, dDimX) ;
|
||||
LuaSetParam( L, dDimY) ;
|
||||
return 3 ;
|
||||
}
|
||||
else {
|
||||
LuaSetParam( L) ;
|
||||
return 1 ;
|
||||
}
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
static int
|
||||
LuaGetCurveLinearConvexHullXY( lua_State* L)
|
||||
{
|
||||
// 1 o 2 o 3 parametri : nId [, dLinTol [, nRefType]]
|
||||
int nId ;
|
||||
LuaCheckParam( L, 1, nId)
|
||||
double dLinTol = LIN_TOL_STD ;
|
||||
LuaGetParam( L, 2, dLinTol) ;
|
||||
int nRefType = RTY_DEFAULT ;
|
||||
LuaGetParam( L, 3, nRefType) ;
|
||||
LuaClearStack( L) ;
|
||||
// calcolo il convex hull della curva nel piano XY del riferimento indicato
|
||||
int nNewId = ExeGetCurveLinearConvexHullXY( nId, dLinTol, nRefType) ;
|
||||
if ( nNewId != GDB_ID_NULL)
|
||||
LuaSetParam( L, nNewId) ;
|
||||
else
|
||||
LuaSetParam( L) ;
|
||||
return 1 ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
static int
|
||||
LuaCurveWithRegionClassify( lua_State* L)
|
||||
{
|
||||
// 2 parametri : nCurveId, nRegionId
|
||||
int nCurveId ;
|
||||
LuaCheckParam( L, 1, nCurveId)
|
||||
int nRegionId ;
|
||||
LuaCheckParam( L, 2, nRegionId) ;
|
||||
LuaClearStack( L) ;
|
||||
// eseguo la classificazione
|
||||
int nRes = ExeCurveWithRegionClassify( nCurveId, nRegionId) ;
|
||||
if ( nRes != CRC_NULL)
|
||||
LuaSetParam( L, nRes) ;
|
||||
else
|
||||
LuaSetParam( L) ;
|
||||
return 1 ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
static int
|
||||
LuaArcRadius( lua_State* L)
|
||||
{
|
||||
// 1 parametro : Id
|
||||
int nId ;
|
||||
LuaCheckParam( L, 1, nId)
|
||||
LuaClearStack( L) ;
|
||||
// recupero il raggio
|
||||
double dRad ;
|
||||
if ( ExeArcRadius( nId, &dRad))
|
||||
LuaSetParam( L, dRad) ;
|
||||
else
|
||||
LuaSetParam( L) ;
|
||||
return 1 ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
static int
|
||||
LuaArcAngCenter( lua_State* L)
|
||||
{
|
||||
// 1 parametro : Id
|
||||
int nId ;
|
||||
LuaCheckParam( L, 1, nId)
|
||||
LuaClearStack( L) ;
|
||||
// recupero l'angolo al centro in gradi
|
||||
double pdAngDeg ;
|
||||
if ( ExeArcAngCenter( nId, &pdAngDeg))
|
||||
LuaSetParam( L, pdAngDeg) ;
|
||||
else
|
||||
LuaSetParam( L) ;
|
||||
return 1 ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
static int
|
||||
LuaArcDeltaN( lua_State* L)
|
||||
{
|
||||
// 1 parametro : Id
|
||||
int nId ;
|
||||
LuaCheckParam( L, 1, nId)
|
||||
LuaClearStack( L) ;
|
||||
// recupero il delta su normale al suo piano
|
||||
double dDeltaN ;
|
||||
if ( ExeArcDeltaN( nId, &dDeltaN))
|
||||
LuaSetParam( L, dDeltaN) ;
|
||||
else
|
||||
LuaSetParam( L) ;
|
||||
return 1 ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
static int
|
||||
LuaArcNormVersor( lua_State* L)
|
||||
{
|
||||
// 1 o 2 parametri : Id [, nRefId]
|
||||
int nId ;
|
||||
LuaCheckParam( L, 1, nId)
|
||||
int nRefId = nId ;
|
||||
LuaGetParam( L, 2, nRefId) ;
|
||||
LuaClearStack( L) ;
|
||||
// recupero il versore
|
||||
Vector3d vtNorm ;
|
||||
if ( ExeArcNormVersor( nId, nRefId, vtNorm))
|
||||
LuaSetParam( L, vtNorm) ;
|
||||
else
|
||||
LuaSetParam( 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 ;
|
||||
LuaGetParam( L, 3, nRefId) ;
|
||||
LuaClearStack( L) ;
|
||||
// recupero il centro della curva semplice indicizzata
|
||||
Point3d ptCen ;
|
||||
if ( ExeCurveCompoCenter( nId, nCrv, nRefId, ptCen))
|
||||
LuaSetParam( L, ptCen) ;
|
||||
else
|
||||
LuaSetParam( L) ;
|
||||
return 1 ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
static int
|
||||
LuaCurveCompoRadius( lua_State* L)
|
||||
{
|
||||
// 2 parametri : Id, nCrv
|
||||
int nId ;
|
||||
LuaCheckParam( L, 1, nId)
|
||||
int nCrv ;
|
||||
LuaCheckParam( L, 2, nCrv)
|
||||
LuaClearStack( L) ;
|
||||
// recupero il raggio della curva semplice indicizzata
|
||||
double dRadius ;
|
||||
if ( ExeCurveCompoRadius( nId, nCrv, dRadius))
|
||||
LuaSetParam( L, dRadius) ;
|
||||
else
|
||||
LuaSetParam( L) ;
|
||||
return 1 ;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------
|
||||
bool
|
||||
LuaInstallGdbGetCurve( LuaMgr& luaMgr)
|
||||
{
|
||||
bool bOk = ( &luaMgr != nullptr) ;
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtCurveDomain", LuaCurveDomain) ;
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtCurveLength", LuaCurveLength) ;
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtCurveIsClosed", LuaCurveIsClosed) ;
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtCurveIsFlat", LuaCurveIsFlat) ;
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtCurveAreaXY", LuaCurveAreaXY) ;
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtCurveArea", LuaCurveArea) ;
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtCurveExtrusion", LuaCurveExtrusion) ;
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtCurveThickness", LuaCurveThickness) ;
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtCurveSelfIntersCount", LuaCurveSelfIntersCount) ;
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtCurveMinAreaRectangleXY", LuaCurveMinAreaRectangleXY) ;
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtGetCurveLinearConvexHullXY", LuaGetCurveLinearConvexHullXY) ;
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtCurveWithRegionClassify", LuaCurveWithRegionClassify) ;
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtArcRadius", LuaArcRadius) ;
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtArcAngCenter", LuaArcAngCenter) ;
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtArcDeltaN", LuaArcDeltaN) ;
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtArcNormVersor", LuaArcNormVersor) ;
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtCurveCompoCenter", LuaCurveCompoCenter) ;
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtCurveCompoRadius", LuaCurveCompoRadius) ;
|
||||
return bOk ;
|
||||
}
|
||||
@@ -0,0 +1,859 @@
|
||||
//----------------------------------------------------------------------------
|
||||
// EgalTech 2020-2020
|
||||
//----------------------------------------------------------------------------
|
||||
// File : LUA_GdbGetSurf.cpp Data : 23.03.20 Versione : 2.2c3
|
||||
// Contenuto : Funzioni di interrogazione delle superfici per LUA.
|
||||
//
|
||||
//
|
||||
//
|
||||
// Modifiche : 23.03.20 DS Creazione modulo.
|
||||
//
|
||||
//
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
//--------------------------- Include ----------------------------------------
|
||||
#include "stdafx.h"
|
||||
#include "LUA.h"
|
||||
#include "/EgtDev/Include/EXeExecutor.h"
|
||||
#include "/EgtDev/Include/EXeConst.h"
|
||||
#include "/EgtDev/Include/EGkCurve.h"
|
||||
#include "/EgtDev/Include/EGkGdbConst.h"
|
||||
#include "/EgtDev/Include/EGkSurfTriMesh.h"
|
||||
#include "/EgtDev/Include/EGkLuaAux.h"
|
||||
|
||||
using namespace std ;
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
static int
|
||||
LuaSurfArea( lua_State* L)
|
||||
{
|
||||
// 1 parametro : Id
|
||||
int nId ;
|
||||
LuaCheckParam( L, 1, nId)
|
||||
LuaClearStack( L) ;
|
||||
// recupero la sua area
|
||||
double dArea ;
|
||||
if ( ExeSurfArea( nId, dArea))
|
||||
LuaSetParam( L, dArea) ;
|
||||
else
|
||||
LuaSetParam( L) ;
|
||||
return 1 ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
static int
|
||||
LuaSurfVolume( lua_State* L)
|
||||
{
|
||||
// 1 parametro : Id
|
||||
int nId ;
|
||||
LuaCheckParam( L, 1, nId)
|
||||
LuaClearStack( L) ;
|
||||
// recupero il suo eventuale volume (se chiusa)
|
||||
double dVol ;
|
||||
if ( ExeSurfVolume( nId, dVol))
|
||||
LuaSetParam( L, dVol) ;
|
||||
else
|
||||
LuaSetParam( L) ;
|
||||
return 1 ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
static int
|
||||
LuaSurfFrNormVersor( lua_State* L)
|
||||
{
|
||||
// 1 o 2 parametri : Id [, nRefId]
|
||||
int nId ;
|
||||
LuaCheckParam( L, 1, nId)
|
||||
int nRefId = nId ;
|
||||
LuaGetParam( L, 2, nRefId) ;
|
||||
LuaClearStack( L) ;
|
||||
// recupero il versore
|
||||
Vector3d vtNorm ;
|
||||
if ( ExeSurfFrNormVersor( nId, nRefId, vtNorm))
|
||||
LuaSetParam( L, vtNorm) ;
|
||||
else
|
||||
LuaSetParam( L) ;
|
||||
return 1 ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
static int
|
||||
LuaSurfFrGrossArea( lua_State* L)
|
||||
{
|
||||
// 1 parametro : Id
|
||||
int nId ;
|
||||
LuaCheckParam( L, 1, nId)
|
||||
LuaClearStack( L) ;
|
||||
// recupero la sua area senza eventuali buchi
|
||||
double dArea ;
|
||||
if ( ExeSurfFrGrossArea( nId, dArea))
|
||||
LuaSetParam( L, dArea) ;
|
||||
else
|
||||
LuaSetParam( L) ;
|
||||
return 1 ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
static int
|
||||
LuaSurfFrChunkCount( lua_State* L)
|
||||
{
|
||||
// 1 parametro : Id
|
||||
int nId ;
|
||||
LuaCheckParam( L, 1, nId)
|
||||
LuaClearStack( L) ;
|
||||
// recupero il numero di componenti connessi (chunk) della regione
|
||||
int nNbr = ExeSurfFrChunkCount( nId) ;
|
||||
LuaSetParam( L, nNbr) ;
|
||||
return 1 ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
static int
|
||||
LuaSurfFrChunkSimpleClassify( lua_State* L)
|
||||
{
|
||||
// 4 parametro : Id1, Chunk1, Id2, Chunk2
|
||||
int nId1 ;
|
||||
LuaCheckParam( L, 1, nId1)
|
||||
int nChunk1 ;
|
||||
LuaCheckParam( L, 2, nChunk1)
|
||||
int nId2 ;
|
||||
LuaCheckParam( L, 3, nId2)
|
||||
int nChunk2 ;
|
||||
LuaCheckParam( L, 4, nChunk2)
|
||||
LuaClearStack( L) ;
|
||||
// classifico il chunk della prima regione rispetto a quello della seconda
|
||||
int nClass = ExeSurfFrChunkSimpleClassify( nId1, nChunk1, nId2, nChunk2) ;
|
||||
LuaSetParam( L, nClass) ;
|
||||
return 1 ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
static int
|
||||
LuaSurfFrTestExternal( lua_State* L)
|
||||
{
|
||||
// 2 o 3 parametri : Id1, Id2 [, dMinDist]
|
||||
int nId1 ;
|
||||
LuaCheckParam( L, 1, nId1)
|
||||
int nId2 ;
|
||||
LuaCheckParam( L, 2, nId2)
|
||||
double dMinDist = 0 ;
|
||||
LuaGetParam( L, 3, dMinDist) ;
|
||||
LuaClearStack( L) ;
|
||||
// verifico se le due regioni sono esterne con distanza superiore al minimo
|
||||
bool bOk = ExeSurfFrTestExternal( nId1, nId2, dMinDist) ;
|
||||
LuaSetParam( L, bOk) ;
|
||||
return 1 ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
static int
|
||||
LuaExtractSurfFrChunkLoops( lua_State* L)
|
||||
{
|
||||
// 3 parametri : nId, nChunk, nDestGrpId
|
||||
int nId ;
|
||||
LuaCheckParam( L, 1, nId)
|
||||
int nChunk ;
|
||||
LuaCheckParam( L, 2, nChunk)
|
||||
int nDestGrpId ;
|
||||
LuaCheckParam( L, 3, nDestGrpId)
|
||||
LuaClearStack( L) ;
|
||||
// recupero i contorni del chunk della regione
|
||||
int nCount = 0 ;
|
||||
int nNewId = ExeExtractSurfFrChunkLoops( nId, nChunk, nDestGrpId, &nCount) ;
|
||||
// restituisco il risultato
|
||||
if ( nNewId != GDB_ID_NULL)
|
||||
LuaSetParam( L, nNewId) ;
|
||||
else
|
||||
LuaSetParam( L) ;
|
||||
LuaSetParam( L, nCount) ;
|
||||
return 2 ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
static int
|
||||
LuaSurfFrMoveSimpleNoCollision( lua_State* L)
|
||||
{
|
||||
// 3 o 4 parametri : nId1, nId2, vtMove [, nRefType]
|
||||
int nId1 ;
|
||||
LuaCheckParam( L, 1, nId1)
|
||||
int nId2 ;
|
||||
LuaCheckParam( L, 2, nId2)
|
||||
Vector3d vtMove ;
|
||||
LuaCheckParam( L, 3, vtMove)
|
||||
int nRefType = RTY_DEFAULT ;
|
||||
LuaGetParam( L, 4, nRefType) ;
|
||||
LuaClearStack( L) ;
|
||||
// verifico quale è la massima traslazione possibile
|
||||
double dLen = vtMove.Len() ;
|
||||
Vector3d vtDir = ( dLen > EPS_SMALL ? vtMove / dLen : V_NULL) ;
|
||||
bool bOk = ExeSurfFrMoveSimpleNoCollision( nId1, nId2, vtDir, dLen, nRefType) ;
|
||||
// restituisco il risultato
|
||||
if ( bOk)
|
||||
LuaSetParam( L, dLen) ;
|
||||
else
|
||||
LuaSetParam( L) ;
|
||||
return 1 ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
static int
|
||||
LuaSurfFrRotateSimpleNoCollision( lua_State* L)
|
||||
{
|
||||
// 4 o 5 parametri : nId1, nId2, ptCen, dAngDeg [, nRefType]
|
||||
int nId1 ;
|
||||
LuaCheckParam( L, 1, nId1)
|
||||
int nId2 ;
|
||||
LuaCheckParam( L, 2, nId2)
|
||||
Point3d ptCen ;
|
||||
LuaCheckParam( L, 3, ptCen)
|
||||
double dAngDeg ;
|
||||
LuaCheckParam( L, 4, dAngDeg)
|
||||
int nRefType = RTY_DEFAULT ;
|
||||
LuaGetParam( L, 5, nRefType) ;
|
||||
LuaClearStack( L) ;
|
||||
// verifico quale è la massima (in valore assoluto) rotazione possibile
|
||||
bool bOk = ExeSurfFrRotateSimpleNoCollision( nId1, nId2, ptCen, dAngDeg, nRefType) ;
|
||||
// restituisco il risultato
|
||||
if ( bOk)
|
||||
LuaSetParam( L, dAngDeg) ;
|
||||
else
|
||||
LuaSetParam( L) ;
|
||||
return 1 ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
static int
|
||||
LuaSurfTmFacetCount( lua_State* L)
|
||||
{
|
||||
// 1 parametro : Id
|
||||
int nId ;
|
||||
LuaCheckParam( L, 1, nId)
|
||||
LuaClearStack( L) ;
|
||||
// recupero il numero di facce della superficie trimesh
|
||||
int nNbr = ExeSurfTmFacetCount( nId) ;
|
||||
LuaSetParam( L, nNbr) ;
|
||||
return 1 ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
static int
|
||||
LuaSurfTmFacetFromTria( lua_State* L)
|
||||
{
|
||||
// 2 parametri : nId, nTria
|
||||
int nId ;
|
||||
LuaCheckParam( L, 1, nId)
|
||||
int nTria ;
|
||||
LuaCheckParam( L, 2, nTria)
|
||||
LuaClearStack( L) ;
|
||||
// recupero l'indice della faccia cui appartiene il triangolo della superficie
|
||||
int nFacet = ExeSurfTmFacetFromTria( nId, nTria) ;
|
||||
// restituisco il risultato
|
||||
if ( nFacet != SVT_NULL)
|
||||
LuaSetParam( L, nFacet) ;
|
||||
else
|
||||
LuaSetParam( L) ;
|
||||
return 1 ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
static int
|
||||
LuaSurfTmGetFacetBBox( lua_State* L)
|
||||
{
|
||||
// 3 parametri : nId, nFacet, nFlag
|
||||
int nId ;
|
||||
LuaCheckParam( L, 1, nId)
|
||||
int nFacet ;
|
||||
LuaCheckParam( L, 2, nFacet)
|
||||
int nFlag ;
|
||||
LuaCheckParam( L, 3, nFlag)
|
||||
LuaClearStack( L) ;
|
||||
// recupero il bounding box della faccia in locale
|
||||
BBox3d b3Box ;
|
||||
bool bOk = ExeSurfTmGetFacetBBox( nId, nFacet, nFlag, b3Box) ;
|
||||
// restituisco il risultato
|
||||
if ( bOk)
|
||||
LuaSetParam( L, b3Box) ;
|
||||
else
|
||||
LuaSetParam( L) ;
|
||||
return 1 ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
static int
|
||||
LuaSurfTmGetFacetBBoxGlob( lua_State* L)
|
||||
{
|
||||
// 3 parametri : nId, nFacet, nFlag
|
||||
int nId ;
|
||||
LuaCheckParam( L, 1, nId)
|
||||
int nFacet ;
|
||||
LuaCheckParam( L, 2, nFacet)
|
||||
int nFlag ;
|
||||
LuaCheckParam( L, 3, nFlag)
|
||||
LuaClearStack( L) ;
|
||||
// recupero il bounding box della faccia in globale
|
||||
BBox3d b3Box ;
|
||||
bool bOk = ExeSurfTmGetFacetBBoxGlob( nId, nFacet, nFlag, b3Box) ;
|
||||
// restituisco il risultato
|
||||
if ( bOk)
|
||||
LuaSetParam( L, b3Box) ;
|
||||
else
|
||||
LuaSetParam( L) ;
|
||||
return 1 ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
static int
|
||||
LuaSurfTmFacetAdjacencies( lua_State* L)
|
||||
{
|
||||
// 2 parametri : nId, nFacet
|
||||
int nId ;
|
||||
LuaCheckParam( L, 1, nId)
|
||||
int nFacet ;
|
||||
LuaCheckParam( L, 2, nFacet)
|
||||
LuaClearStack( L) ;
|
||||
// recupero le adiacenze della faccetta della superficie
|
||||
INTMATRIX vAdj ;
|
||||
bool bOk = ExeSurfTmFacetAdjacencies( nId, nFacet, vAdj) ;
|
||||
// restituisco il risultato
|
||||
if ( bOk)
|
||||
LuaSetParam( L, vAdj) ;
|
||||
else
|
||||
LuaSetParam( L) ;
|
||||
return 1 ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
static int
|
||||
LuaSurfTmFacetNearestEndPoint( lua_State* L)
|
||||
{
|
||||
// 3 o 4 parametri : Id, nFacet, ptNear [, nRefId]
|
||||
int nId ;
|
||||
LuaCheckParam( L, 1, nId)
|
||||
int nFacet ;
|
||||
LuaCheckParam( L, 2, nFacet)
|
||||
Point3d ptNear ;
|
||||
LuaCheckParam( L, 3, ptNear)
|
||||
int nRefId = nId ;
|
||||
LuaGetParam( L, 4, nRefId) ;
|
||||
LuaClearStack( L) ;
|
||||
// recupero il punto End più vicino della faccia della superficie trimesh
|
||||
Point3d ptEnd ;
|
||||
Vector3d vtN ;
|
||||
if ( ExeSurfTmFacetNearestEndPoint( nId, nFacet, ptNear, nRefId, ptEnd, vtN)) {
|
||||
LuaSetParam( L, ptEnd) ;
|
||||
LuaSetParam( L, vtN) ;
|
||||
}
|
||||
else {
|
||||
LuaSetParam( L) ;
|
||||
LuaSetParam( L) ;
|
||||
}
|
||||
return 2 ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
static int
|
||||
LuaSurfTmFacetNearestMidPoint( lua_State* L)
|
||||
{
|
||||
// 3 o 4 parametri : Id, nFacet, ptNear [, nRefId]
|
||||
int nId ;
|
||||
LuaCheckParam( L, 1, nId)
|
||||
int nFacet ;
|
||||
LuaCheckParam( L, 2, nFacet)
|
||||
Point3d ptNear ;
|
||||
LuaCheckParam( L, 3, ptNear)
|
||||
int nRefId = nId ;
|
||||
LuaGetParam( L, 4, nRefId) ;
|
||||
LuaClearStack( L) ;
|
||||
// recupero il punto Mid più vicino della faccia della superficie trimesh
|
||||
Point3d ptMid ;
|
||||
Vector3d vtN ;
|
||||
if ( ExeSurfTmFacetNearestMidPoint( nId, nFacet, ptNear, nRefId, ptMid, vtN)) {
|
||||
LuaSetParam( L, ptMid) ;
|
||||
LuaSetParam( L, vtN) ;
|
||||
}
|
||||
else {
|
||||
LuaSetParam( L) ;
|
||||
LuaSetParam( L) ;
|
||||
}
|
||||
return 2 ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
static int
|
||||
LuaSurfTmFacetCenter( lua_State* L)
|
||||
{
|
||||
// 2 o 3 parametri : Id, nFacet [, nRefId]
|
||||
int nId ;
|
||||
LuaCheckParam( L, 1, nId)
|
||||
int nFacet ;
|
||||
LuaCheckParam( L, 2, nFacet)
|
||||
int nRefId = nId ;
|
||||
LuaGetParam( L, 3, nRefId) ;
|
||||
LuaClearStack( L) ;
|
||||
// recupero il centro della faccia della superficie trimesh
|
||||
Point3d ptCen ;
|
||||
Vector3d vtN ;
|
||||
if ( ExeSurfTmFacetCenter( nId, nFacet, nRefId, ptCen, vtN)) {
|
||||
LuaSetParam( L, ptCen) ;
|
||||
LuaSetParam( L, vtN) ;
|
||||
}
|
||||
else {
|
||||
LuaSetParam( L) ;
|
||||
LuaSetParam( L) ;
|
||||
}
|
||||
return 2 ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
static int
|
||||
LuaSurfTmFacetNormVersor( lua_State* L)
|
||||
{
|
||||
// 2 o 3 parametri : Id, nFacet [, nRefId]
|
||||
int nId ;
|
||||
LuaCheckParam( L, 1, nId)
|
||||
int nFacet ;
|
||||
LuaCheckParam( L, 2, nFacet)
|
||||
int nRefId = nId ;
|
||||
LuaGetParam( L, 3, nRefId) ;
|
||||
LuaClearStack( L) ;
|
||||
// recupero la normale della faccia della superficie trimesh
|
||||
Vector3d vtNorm ;
|
||||
if ( ExeSurfTmFacetNormVersor( nId, nFacet, nRefId, vtNorm))
|
||||
LuaSetParam( L, vtNorm) ;
|
||||
else
|
||||
LuaSetParam( L) ;
|
||||
return 1 ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
static int
|
||||
LuaSurfTmFacetMinAreaRectangle( lua_State* L)
|
||||
{
|
||||
// 2 o 3 parametri : Id, nFacet [, nRefId]
|
||||
int nId ;
|
||||
LuaCheckParam( L, 1, nId)
|
||||
int nFacet ;
|
||||
LuaCheckParam( L, 2, nFacet)
|
||||
int nRefId = nId ;
|
||||
LuaGetParam( L, 3, nRefId) ;
|
||||
LuaClearStack( L) ;
|
||||
// recupero il rettangolo di minima area della faccia della superficie trimesh
|
||||
Frame3d frRect ;
|
||||
double dDimX, dDimY ;
|
||||
if ( ExeSurfTmFacetMinAreaRectangle( nId, nFacet, nRefId, frRect, dDimX, dDimY)) {
|
||||
LuaSetParam( L, frRect) ;
|
||||
LuaSetParam( L, dDimX) ;
|
||||
LuaSetParam( L, dDimY) ;
|
||||
return 3 ;
|
||||
}
|
||||
else {
|
||||
LuaSetParam( L) ;
|
||||
return 1 ;
|
||||
}
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
static int
|
||||
LuaSurfTmFacetOppositeSide( lua_State* L)
|
||||
{
|
||||
// 3 o 4 parametri : Id, nFacet, vtDir [, nRefId]
|
||||
int nId ;
|
||||
LuaCheckParam( L, 1, nId)
|
||||
int nFacet ;
|
||||
LuaCheckParam( L, 2, nFacet)
|
||||
Vector3d vtDir ;
|
||||
LuaCheckParam( L, 3, vtDir)
|
||||
int nRefId = nId ;
|
||||
LuaGetParam( L, 4, nRefId) ;
|
||||
LuaClearStack( L) ;
|
||||
// recupero i punti estremi della parte di faccia opposta alla direzione
|
||||
Point3d ptP1, ptPm, ptP2 ;
|
||||
Vector3d vtIn1, vtOut2 ;
|
||||
double dLen, dWidth ;
|
||||
if ( ExeSurfTmFacetOppositeSideEx( nId, nFacet, vtDir, nRefId, ptP1, ptPm, ptP2, vtIn1, vtOut2, dLen, dWidth)) {
|
||||
LuaSetParam( L, ptP1) ;
|
||||
LuaSetParam( L, ptPm) ;
|
||||
LuaSetParam( L, ptP2) ;
|
||||
LuaSetParam( L, vtIn1) ;
|
||||
LuaSetParam( L, vtOut2) ;
|
||||
LuaSetParam( L, dLen) ;
|
||||
LuaSetParam( L, dWidth) ;
|
||||
}
|
||||
else {
|
||||
LuaSetParam( L) ;
|
||||
LuaSetParam( L) ;
|
||||
LuaSetParam( L) ;
|
||||
LuaSetParam( L) ;
|
||||
LuaSetParam( L) ;
|
||||
LuaSetParam( L) ;
|
||||
LuaSetParam( L) ;
|
||||
}
|
||||
return 7 ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
static int
|
||||
LuaSurfTmFacetsContact( lua_State* L)
|
||||
{
|
||||
// 3 o 4 parametri : Id, nF1, nF2 [, nRefId]
|
||||
int nId ;
|
||||
LuaCheckParam( L, 1, nId)
|
||||
int nF1 ;
|
||||
LuaCheckParam( L, 2, nF1)
|
||||
int nF2 ;
|
||||
LuaCheckParam( L, 3, nF2)
|
||||
int nRefId = nId ;
|
||||
LuaGetParam( L, 4, nRefId) ;
|
||||
LuaClearStack( L) ;
|
||||
// recupero i dati di contatto tra le due facce
|
||||
bool bAdjac ;
|
||||
Point3d ptP1, ptP2 ;
|
||||
double dAng = 0 ;
|
||||
if ( ExeSurfTmFacetsContact( nId, nF1, nF2, nRefId, bAdjac, ptP1, ptP2, dAng)) {
|
||||
LuaSetParam( L, bAdjac) ;
|
||||
LuaSetParam( L, ptP1) ;
|
||||
LuaSetParam( L, ptP2) ;
|
||||
LuaSetParam( L, dAng) ;
|
||||
}
|
||||
else {
|
||||
LuaSetParam( L) ;
|
||||
LuaSetParam( L) ;
|
||||
LuaSetParam( L) ;
|
||||
LuaSetParam( L) ;
|
||||
}
|
||||
return 4 ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
static int
|
||||
LuaExtractSurfTmLoops( lua_State* L)
|
||||
{
|
||||
// 2 parametri : nId, nDestGrpId
|
||||
int nId ;
|
||||
LuaCheckParam( L, 1, nId)
|
||||
int nDestGrpId ;
|
||||
LuaCheckParam( L, 2, nDestGrpId)
|
||||
LuaClearStack( L) ;
|
||||
// recupero i contorni della superficie
|
||||
int nCount = 0 ;
|
||||
int nNewId = ExeExtractSurfTmLoops( nId, nDestGrpId, &nCount) ;
|
||||
// restituisco il risultato
|
||||
if ( nNewId != GDB_ID_NULL)
|
||||
LuaSetParam( L, nNewId) ;
|
||||
else
|
||||
LuaSetParam( L) ;
|
||||
LuaSetParam( L, nCount) ;
|
||||
return 2 ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
static int
|
||||
LuaGetSurfTmSilhouette( lua_State* L)
|
||||
{
|
||||
// 3 o 4 parametri : nId, vtDir, nDestGrpId [, nRefType]
|
||||
int nId ;
|
||||
LuaCheckParam( L, 1, nId)
|
||||
Vector3d vtDir ;
|
||||
LuaCheckParam( L, 2, vtDir)
|
||||
int nDestGrpId ;
|
||||
LuaCheckParam( L, 3, nDestGrpId)
|
||||
int nRefType = RTY_DEFAULT ;
|
||||
LuaGetParam( L, 4, nRefType) ;
|
||||
LuaClearStack( L) ;
|
||||
// recupero i contorni della superficie
|
||||
int nCount = 0 ;
|
||||
int nNewId = ExeGetSurfTmSilhouette( nId, vtDir, nDestGrpId, nRefType, &nCount) ;
|
||||
// restituisco il risultato
|
||||
if ( nNewId != GDB_ID_NULL)
|
||||
LuaSetParam( L, nNewId) ;
|
||||
else
|
||||
LuaSetParam( L) ;
|
||||
LuaSetParam( L, nCount) ;
|
||||
return 2 ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
static int
|
||||
LuaExtractSurfTmFacetLoops( lua_State* L)
|
||||
{
|
||||
// 3 parametri : nId, nFacet, nDestGrpId
|
||||
int nId ;
|
||||
LuaCheckParam( L, 1, nId)
|
||||
int nFacet ;
|
||||
LuaCheckParam( L, 2, nFacet)
|
||||
int nDestGrpId ;
|
||||
LuaCheckParam( L, 3, nDestGrpId)
|
||||
LuaClearStack( L) ;
|
||||
// recupero i contorni della faccetta della superficie
|
||||
int nCount ;
|
||||
int nNewId = ExeExtractSurfTmFacetLoops( nId, nFacet, nDestGrpId, &nCount) ;
|
||||
// restituisco il risultato
|
||||
if ( nNewId != GDB_ID_NULL)
|
||||
LuaSetParam( L, nNewId) ;
|
||||
else
|
||||
LuaSetParam( L) ;
|
||||
LuaSetParam( L, nCount) ;
|
||||
return 2 ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
static int
|
||||
LuaCopySurfTmFacet( lua_State* L)
|
||||
{
|
||||
// 3 parametri : nId, nFacet, nDestGrpId
|
||||
int nId ;
|
||||
LuaCheckParam( L, 1, nId)
|
||||
int nFacet ;
|
||||
LuaCheckParam( L, 2, nFacet)
|
||||
int nDestGrpId ;
|
||||
LuaCheckParam( L, 3, nDestGrpId)
|
||||
LuaClearStack( L) ;
|
||||
// copio la faccia della superficie nel gruppo indicato
|
||||
int nNewId = ExeCopySurfTmFacet( nId, nFacet, nDestGrpId) ;
|
||||
// restituisco il risultato
|
||||
if ( nNewId != GDB_ID_NULL)
|
||||
LuaSetParam( L, nNewId) ;
|
||||
else
|
||||
LuaSetParam( L) ;
|
||||
return 1 ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
static int
|
||||
LuaSurfBezierGetPoint( lua_State* L)
|
||||
{
|
||||
// 3 o 4 parametri : nSurfId, dU, dV [, nRefId]
|
||||
int nSurfId ;
|
||||
LuaCheckParam( L, 1, nSurfId)
|
||||
double dU ;
|
||||
LuaCheckParam( L, 2, dU)
|
||||
double dV ;
|
||||
LuaCheckParam( L, 3, dV)
|
||||
int nRefId = nSurfId ;
|
||||
LuaGetParam( L, 4, nRefId) ;
|
||||
LuaClearStack( L) ;
|
||||
// recupero i dati del punto
|
||||
Point3d ptP ;
|
||||
bool bOk = ExeSurfBezierGetPoint( nSurfId, dU, dV, nRefId, ptP) ;
|
||||
if ( bOk)
|
||||
LuaSetParam( L, ptP) ;
|
||||
else
|
||||
LuaSetParam( L) ;
|
||||
return 1 ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
static int
|
||||
LuaSurfBezierGetPointD1( lua_State* L)
|
||||
{
|
||||
// 3 o 4 parametri : nSurfId, dU, dV [, nRefId]
|
||||
int nSurfId ;
|
||||
LuaCheckParam( L, 1, nSurfId)
|
||||
double dU ;
|
||||
LuaCheckParam( L, 2, dU)
|
||||
double dV ;
|
||||
LuaCheckParam( L, 3, dV)
|
||||
int nRefId = nSurfId ;
|
||||
LuaGetParam( L, 4, nRefId) ;
|
||||
LuaClearStack( L) ;
|
||||
// recupero i dati del punto
|
||||
Point3d ptP ;
|
||||
Vector3d vtDerU, vtDerV ;
|
||||
bool bOk = ExeSurfBezierGetPointD1( nSurfId, dU, dV, nRefId, ptP, vtDerU, vtDerV) ;
|
||||
if ( bOk) {
|
||||
LuaSetParam( L, ptP) ;
|
||||
LuaSetParam( L, vtDerU) ;
|
||||
LuaSetParam( L, vtDerV) ;
|
||||
}
|
||||
else {
|
||||
LuaSetParam( L) ;
|
||||
LuaSetParam( L) ;
|
||||
LuaSetParam( L) ;
|
||||
}
|
||||
return 3 ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
static int
|
||||
LuaSurfBezierGetPointNrmD1( lua_State* L)
|
||||
{
|
||||
// 3 o 4 parametri : nSurfId, dU, dV [, nRefId]
|
||||
int nSurfId ;
|
||||
LuaCheckParam( L, 1, nSurfId)
|
||||
double dU ;
|
||||
LuaCheckParam( L, 2, dU)
|
||||
double dV ;
|
||||
LuaCheckParam( L, 3, dV)
|
||||
int nRefId = nSurfId ;
|
||||
LuaGetParam( L, 4, nRefId) ;
|
||||
LuaClearStack( L) ;
|
||||
// recupero i dati del punto
|
||||
Point3d ptP ;
|
||||
Vector3d vtN ;
|
||||
Vector3d vtDerU, vtDerV ;
|
||||
bool bOk = ExeSurfBezierGetPointNrmD1( nSurfId, dU, dV, nRefId, ptP, vtN, vtDerU, vtDerV) ;
|
||||
if ( bOk) {
|
||||
LuaSetParam( L, ptP) ;
|
||||
LuaSetParam( L, vtN) ;
|
||||
LuaSetParam( L, vtDerU) ;
|
||||
LuaSetParam( L, vtDerV) ;
|
||||
}
|
||||
else {
|
||||
LuaSetParam( L) ;
|
||||
LuaSetParam( L) ;
|
||||
LuaSetParam( L) ;
|
||||
LuaSetParam( L) ;
|
||||
}
|
||||
return 4 ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
static int
|
||||
LuaSurfBezierGetCurveU( lua_State* L)
|
||||
{
|
||||
// 3 parametri : nSurfId, dV, nDestGrp
|
||||
int nSurfId ;
|
||||
LuaCheckParam( L, 1, nSurfId)
|
||||
double dV ;
|
||||
LuaCheckParam( L, 2, dV)
|
||||
int nDestGrp ;
|
||||
LuaCheckParam( L, 3, nDestGrp)
|
||||
LuaClearStack( L) ;
|
||||
// recupero la curva
|
||||
int nNewId = ExeSurfBezierGetCurveU( nSurfId, dV, nDestGrp) ;
|
||||
if ( nNewId != GDB_ID_NULL)
|
||||
LuaSetParam( L, nNewId) ;
|
||||
else
|
||||
LuaSetParam( L) ;
|
||||
return 1 ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
static int
|
||||
LuaSurfBezierGetCurveV( lua_State* L)
|
||||
{
|
||||
// 3 parametri : nSurfId, dU, nDestGrp
|
||||
int nSurfId ;
|
||||
LuaCheckParam( L, 1, nSurfId)
|
||||
double dU ;
|
||||
LuaCheckParam( L, 2,dU)
|
||||
int nDestGrp ;
|
||||
LuaCheckParam( L, 3, nDestGrp)
|
||||
LuaClearStack( L) ;
|
||||
// recupero la curva
|
||||
int nNewId = ExeSurfBezierGetCurveV( nSurfId, dU, nDestGrp) ;
|
||||
if ( nNewId != GDB_ID_NULL)
|
||||
LuaSetParam( L, nNewId) ;
|
||||
else
|
||||
LuaSetParam( L) ;
|
||||
return 1 ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
static int
|
||||
LuaSurfBezierGetInfo( lua_State* L)
|
||||
{
|
||||
// 1 parametro : nSurfId
|
||||
int nSurfId ;
|
||||
LuaCheckParam( L, 1, nSurfId)
|
||||
LuaClearStack( L) ;
|
||||
// recupero la curva
|
||||
int nDegU, nDegV ;
|
||||
bool bIsRat ;
|
||||
bool bOk = ExeSurfBezierGetInfo( nSurfId, nDegU, nDegV, bIsRat) ;
|
||||
if ( bOk) {
|
||||
LuaSetParam( L, nDegU) ;
|
||||
LuaSetParam( L, nDegV) ;
|
||||
LuaSetParam( L, bIsRat) ;
|
||||
}
|
||||
else {
|
||||
LuaSetParam( L) ;
|
||||
LuaSetParam( L) ;
|
||||
LuaSetParam( L) ;
|
||||
}
|
||||
return 3 ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
static int
|
||||
LuaSurfBezierGetControlCurveU( lua_State* L)
|
||||
{
|
||||
// 3 parametri : nSurfId, nIndV, nDestGrp
|
||||
int nSurfId ;
|
||||
LuaCheckParam( L, 1, nSurfId)
|
||||
int nIndV ;
|
||||
LuaCheckParam( L, 2, nIndV)
|
||||
int nDestGrp ;
|
||||
LuaCheckParam( L, 3, nDestGrp)
|
||||
LuaClearStack( L) ;
|
||||
// recupero la curva
|
||||
int nNewId = ExeSurfBezierGetControlCurveU( nSurfId, nIndV, nDestGrp) ;
|
||||
if ( nNewId != GDB_ID_NULL)
|
||||
LuaSetParam( L, nNewId) ;
|
||||
else
|
||||
LuaSetParam( L) ;
|
||||
return 1 ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
static int
|
||||
LuaSurfBezierGetControlCurveV( lua_State* L)
|
||||
{
|
||||
// 3 parametri : nSurfId, nIndU, nDestGrp
|
||||
int nSurfId ;
|
||||
LuaCheckParam( L, 1, nSurfId)
|
||||
int nIndU ;
|
||||
LuaCheckParam( L, 2, nIndU)
|
||||
int nDestGrp ;
|
||||
LuaCheckParam( L, 3, nDestGrp)
|
||||
LuaClearStack( L) ;
|
||||
// recupero la curva
|
||||
int nNewId = ExeSurfBezierGetControlCurveV( nSurfId, nIndU, nDestGrp) ;
|
||||
if ( nNewId != GDB_ID_NULL)
|
||||
LuaSetParam( L, nNewId) ;
|
||||
else
|
||||
LuaSetParam( L) ;
|
||||
return 1 ;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------
|
||||
bool
|
||||
LuaInstallGdbGetSurf( LuaMgr& luaMgr)
|
||||
{
|
||||
bool bOk = ( &luaMgr != nullptr) ;
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtSurfArea", LuaSurfArea) ;
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtSurfVolume", LuaSurfVolume) ;
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtSurfFrNormVersor", LuaSurfFrNormVersor) ;
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtSurfFrGrossArea", LuaSurfFrGrossArea) ;
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtSurfFrChunkCount", LuaSurfFrChunkCount) ;
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtSurfFrChunkSimpleClassify", LuaSurfFrChunkSimpleClassify) ;
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtSurfFrTestExternal", LuaSurfFrTestExternal) ;
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtExtractSurfFrChunkLoops", LuaExtractSurfFrChunkLoops) ;
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtSurfFrMoveSimpleNoCollision", LuaSurfFrMoveSimpleNoCollision) ;
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtSurfFrRotateSimpleNoCollision", LuaSurfFrRotateSimpleNoCollision) ;
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtSurfTmFacetCount", LuaSurfTmFacetCount) ;
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtSurfTmFacetFromTria", LuaSurfTmFacetFromTria) ;
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtSurfTmGetFacetBBox", LuaSurfTmGetFacetBBox) ;
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtSurfTmGetFacetBBoxGlob", LuaSurfTmGetFacetBBoxGlob) ;
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtSurfTmFacetAdjacencies", LuaSurfTmFacetAdjacencies) ;
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtSurfTmFacetNearestEndPoint", LuaSurfTmFacetNearestEndPoint) ;
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtSurfTmFacetNearestMidPoint", LuaSurfTmFacetNearestMidPoint) ;
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtSurfTmFacetCenter", LuaSurfTmFacetCenter) ;
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtSurfTmFacetNormVersor", LuaSurfTmFacetNormVersor) ;
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtSurfTmFacetMinAreaRectangle", LuaSurfTmFacetMinAreaRectangle) ;
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtSurfTmFacetOppositeSide", LuaSurfTmFacetOppositeSide) ;
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtSurfTmFacetsContact", LuaSurfTmFacetsContact) ;
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtExtractSurfTmLoops", LuaExtractSurfTmLoops) ;
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtGetSurfTmSilhouette", LuaGetSurfTmSilhouette) ;
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtExtractSurfTmFacetLoops", LuaExtractSurfTmFacetLoops) ;
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtCopySurfTmFacet", LuaCopySurfTmFacet) ;
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtSurfBezierGetPoint", LuaSurfBezierGetPoint) ;
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtSurfBezierGetPointD1", LuaSurfBezierGetPointD1) ;
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtSurfBezierGetPointNrmD1", LuaSurfBezierGetPointNrmD1) ;
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtSurfBezierGetCurveU", LuaSurfBezierGetCurveU) ;
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtSurfBezierGetCurveV", LuaSurfBezierGetCurveV) ;
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtSurfBezierGetInfo", LuaSurfBezierGetInfo) ;
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtSurfBezierGetControlCurveU", LuaSurfBezierGetControlCurveU) ;
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtSurfBezierGetControlCurveV", LuaSurfBezierGetControlCurveV) ;
|
||||
return bOk ;
|
||||
}
|
||||
@@ -0,0 +1,214 @@
|
||||
//----------------------------------------------------------------------------
|
||||
// EgalTech 2020-2020
|
||||
//----------------------------------------------------------------------------
|
||||
// File : LUA_GdbGetVol.cpp Data : 23.03.20 Versione : 2.2c3
|
||||
// Contenuto : Funzioni di interrogazione dei solidi per LUA.
|
||||
//
|
||||
//
|
||||
//
|
||||
// Modifiche : 23.03.20 DS Creazione modulo.
|
||||
//
|
||||
//
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
//--------------------------- Include ----------------------------------------
|
||||
#include "stdafx.h"
|
||||
#include "LUA.h"
|
||||
#include "/EgtDev/Include/EXeExecutor.h"
|
||||
#include "/EgtDev/Include/EXeConst.h"
|
||||
#include "/EgtDev/Include/EGkGdbConst.h"
|
||||
#include "/EgtDev/Include/EGkLuaAux.h"
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
static int
|
||||
LuaVolZmapVolume( lua_State* L)
|
||||
{
|
||||
// 1 parametro : Id
|
||||
int nId ;
|
||||
LuaCheckParam( L, 1, nId)
|
||||
LuaClearStack( L) ;
|
||||
// recupero il suo volume
|
||||
double dVol ;
|
||||
if ( ExeVolZmapVolume( nId, dVol))
|
||||
LuaSetParam( L, dVol) ;
|
||||
else
|
||||
LuaSetParam( L) ;
|
||||
return 1 ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
static int
|
||||
LuaVolZmapPartCount( lua_State* L)
|
||||
{
|
||||
// 1 parametro : Id
|
||||
int nId ;
|
||||
LuaCheckParam( L, 1, nId)
|
||||
LuaClearStack( L) ;
|
||||
// recupero il numero di parti del solido Zmap
|
||||
int nParts = ExeVolZmapPartCount( nId) ;
|
||||
if ( nParts >= 0)
|
||||
LuaSetParam( L, nParts) ;
|
||||
else
|
||||
LuaSetParam( L) ;
|
||||
return 1 ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
static int
|
||||
LuaVolZmapPartVolume( lua_State* L)
|
||||
{
|
||||
// 2 parametri : Id, nPartInd (0-based)
|
||||
int nId ;
|
||||
LuaCheckParam( L, 1, nId)
|
||||
int nPartInd ;
|
||||
LuaCheckParam( L, 2, nPartInd)
|
||||
LuaClearStack( L) ;
|
||||
// recupero il suo eventuale volume
|
||||
double dVol ;
|
||||
if ( ExeVolZmapPartVolume( nId, nPartInd, dVol))
|
||||
LuaSetParam( L, dVol) ;
|
||||
else
|
||||
LuaSetParam( L) ;
|
||||
return 1 ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
static int
|
||||
LuaVolZmapGetPartBBox( lua_State* L)
|
||||
{
|
||||
// 3 parametri : nId, nPart, nFlag
|
||||
int nId ;
|
||||
LuaCheckParam( L, 1, nId)
|
||||
int nPart ;
|
||||
LuaCheckParam( L, 2, nPart)
|
||||
int nFlag ;
|
||||
LuaCheckParam( L, 3, nFlag)
|
||||
LuaClearStack( L) ;
|
||||
// recupero il bounding box della parte in locale
|
||||
BBox3d b3Box ;
|
||||
bool bOk = ExeVolZmapGetPartBBox( nId, nPart, nFlag, b3Box) ;
|
||||
// restituisco il risultato
|
||||
if ( bOk)
|
||||
LuaSetParam( L, b3Box) ;
|
||||
else
|
||||
LuaSetParam( L) ;
|
||||
return 1 ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
static int
|
||||
LuaVolZmapGetPartBBoxGlob( lua_State* L)
|
||||
{
|
||||
// 3 parametri : nId, nPart, nFlag
|
||||
int nId ;
|
||||
LuaCheckParam( L, 1, nId)
|
||||
int nPart ;
|
||||
LuaCheckParam( L, 2, nPart)
|
||||
int nFlag ;
|
||||
LuaCheckParam( L, 3, nFlag)
|
||||
LuaClearStack( L) ;
|
||||
// recupero il bounding box della parte in globale
|
||||
BBox3d b3Box ;
|
||||
bool bOk = ExeVolZmapGetPartBBoxGlob( nId, nPart, nFlag, b3Box) ;
|
||||
// restituisco il risultato
|
||||
if ( bOk)
|
||||
LuaSetParam( L, b3Box) ;
|
||||
else
|
||||
LuaSetParam( L) ;
|
||||
return 1 ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
static int
|
||||
LuaCopyVolZmapPart( lua_State* L)
|
||||
{
|
||||
// 3 parametri : Id, nPart(0-based), nDestGrpId
|
||||
int nId ;
|
||||
LuaCheckParam( L, 1, nId)
|
||||
int nPart ;
|
||||
LuaCheckParam( L, 2, nPart)
|
||||
int nDestGrpId ;
|
||||
LuaCheckParam( L, 3, nDestGrpId)
|
||||
LuaClearStack( L) ;
|
||||
// copio la parte indicata nel gruppo specificato
|
||||
int nNewId = ExeCopyVolZmapPart( nId, nPart, nDestGrpId) ;
|
||||
// restituisco il risultato
|
||||
if ( nNewId != GDB_ID_NULL)
|
||||
LuaSetParam( L, nNewId) ;
|
||||
else
|
||||
LuaSetParam( L) ;
|
||||
return 1 ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
static int
|
||||
LuaVolZmapGetDepth( lua_State* L)
|
||||
{
|
||||
// 3 o 4 o 5 parametri : nId, ptP, vtDir [, nRefType] [, bExact]
|
||||
int nId ;
|
||||
LuaCheckParam( L, 1, nId)
|
||||
Point3d ptP ;
|
||||
LuaCheckParam( L, 2, ptP)
|
||||
Vector3d vtDir ;
|
||||
LuaCheckParam( L, 3, vtDir)
|
||||
int nRefType = RTY_DEFAULT ;
|
||||
bool bExact = false ;
|
||||
if ( LuaGetParam( L, 4, nRefType))
|
||||
LuaGetParam( L, 5, bExact) ;
|
||||
else
|
||||
LuaGetParam( L, 4, bExact) ;
|
||||
LuaClearStack( L) ;
|
||||
// eseguo calcolo profondità dal punto lungo la direzione
|
||||
double dLen1, dLen2 ;
|
||||
bool bOk = ExeVolZmapGetDepth( nId, ptP, vtDir, nRefType, bExact, dLen1, dLen2) ;
|
||||
// restituisco il risultato
|
||||
if ( bOk) {
|
||||
LuaSetParam( L, dLen1) ;
|
||||
LuaSetParam( L, dLen2) ;
|
||||
}
|
||||
else {
|
||||
LuaSetParam( L) ;
|
||||
LuaSetParam( L) ;
|
||||
}
|
||||
return 2 ;
|
||||
}
|
||||
//----------------------------------------------------------------------------
|
||||
static int
|
||||
LuaVolZmapGetEdges( lua_State* L)
|
||||
{
|
||||
// 2 parametri : nId, nDestGrpId
|
||||
int nId ;
|
||||
LuaCheckParam( L, 1, nId)
|
||||
int nDestGrpId ;
|
||||
LuaCheckParam( L, 2, nDestGrpId)
|
||||
LuaClearStack( L) ;
|
||||
// eseguo calcolo profondità dal punto lungo la direzione
|
||||
int nCount ;
|
||||
int nFirstId = ExeVolZmapGetEdges( nId, nDestGrpId, &nCount) ;
|
||||
// restituisco il risultato
|
||||
if ( nFirstId != GDB_ID_NULL) {
|
||||
LuaSetParam( L, nFirstId) ;
|
||||
LuaSetParam( L, nCount) ;
|
||||
}
|
||||
else {
|
||||
LuaSetParam( L) ;
|
||||
LuaSetParam( L) ;
|
||||
}
|
||||
return 2 ;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------
|
||||
bool
|
||||
LuaInstallGdbGetVol( LuaMgr& luaMgr)
|
||||
{
|
||||
bool bOk = ( &luaMgr != nullptr) ;
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtVolZmapVolume", LuaVolZmapVolume) ;
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtVolZmapPartCount", LuaVolZmapPartCount) ;
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtVolZmapPartVolume", LuaVolZmapPartVolume) ;
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtVolZmapGetPartBBox", LuaVolZmapGetPartBBox) ;
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtVolZmapGetPartBBoxGlob", LuaVolZmapGetPartBBoxGlob) ;
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtCopyVolZmapPart", LuaCopyVolZmapPart) ;
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtVolZmapGetDepth", LuaVolZmapGetDepth) ;
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtVolZmapGetEdges", LuaVolZmapGetEdges) ;
|
||||
return bOk ;
|
||||
}
|
||||
@@ -483,27 +483,6 @@ LuaSplitCurveAtSelfInters( lua_State* L)
|
||||
return 2 ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
static int
|
||||
LuaGetCurveLinearConvexHullXY( lua_State* L)
|
||||
{
|
||||
// 1 o 2 o 3 parametri : nId [, dLinTol [, nRefType]]
|
||||
int nId ;
|
||||
LuaCheckParam( L, 1, nId)
|
||||
double dLinTol = LIN_TOL_STD ;
|
||||
LuaGetParam( L, 2, dLinTol) ;
|
||||
int nRefType = RTY_DEFAULT ;
|
||||
LuaGetParam( L, 3, nRefType) ;
|
||||
LuaClearStack( L) ;
|
||||
// calcolo il convex hull della curva nel piano XY del riferimento indicato
|
||||
int nNewId = ExeGetCurveLinearConvexHullXY( nId, dLinTol, nRefType) ;
|
||||
if ( nNewId != GDB_ID_NULL)
|
||||
LuaSetParam( L, nNewId) ;
|
||||
else
|
||||
LuaSetParam( L) ;
|
||||
return 1 ;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------
|
||||
static int
|
||||
LuaModifyArcRadius( lua_State* L)
|
||||
@@ -825,7 +804,6 @@ LuaInstallGdbModifyCurve( LuaMgr& luaMgr)
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtSplitCurveAtParam", LuaSplitCurveAtParam) ;
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtSplitCurveAtCorners", LuaSplitCurveAtCorners) ;
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtSplitCurveAtSelfInters", LuaSplitCurveAtSelfInters) ;
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtGetCurveLinearConvexHullXY", LuaGetCurveLinearConvexHullXY) ;
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtModifyArcRadius", LuaModifyArcRadius) ;
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtModifyArcToExplementary", LuaModifyArcToExplementary) ;
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtModifyArcByFlip", LuaModifyArcByFlip) ;
|
||||
|
||||
@@ -123,176 +123,6 @@ LuaSurfFrOffset( lua_State* L)
|
||||
return 1 ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
static int
|
||||
LuaExtractSurfFrChunkLoops( lua_State* L)
|
||||
{
|
||||
// 3 parametri : nId, nChunk, nDestGrpId
|
||||
int nId ;
|
||||
LuaCheckParam( L, 1, nId)
|
||||
int nChunk ;
|
||||
LuaCheckParam( L, 2, nChunk)
|
||||
int nDestGrpId ;
|
||||
LuaCheckParam( L, 3, nDestGrpId)
|
||||
LuaClearStack( L) ;
|
||||
// recupero i contorni del chunk della regione
|
||||
int nCount = 0 ;
|
||||
int nNewId = ExeExtractSurfFrChunkLoops( nId, nChunk, nDestGrpId, &nCount) ;
|
||||
// restituisco il risultato
|
||||
if ( nNewId != GDB_ID_NULL)
|
||||
LuaSetParam( L, nNewId) ;
|
||||
else
|
||||
LuaSetParam( L) ;
|
||||
LuaSetParam( L, nCount) ;
|
||||
return 2 ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
static int
|
||||
LuaSurfFrMoveSimpleNoCollision( lua_State* L)
|
||||
{
|
||||
// 3 o 4 parametri : nId1, nId2, vtMove [, nRefType]
|
||||
int nId1 ;
|
||||
LuaCheckParam( L, 1, nId1)
|
||||
int nId2 ;
|
||||
LuaCheckParam( L, 2, nId2)
|
||||
Vector3d vtMove ;
|
||||
LuaCheckParam( L, 3, vtMove)
|
||||
int nRefType = RTY_DEFAULT ;
|
||||
LuaGetParam( L, 4, nRefType) ;
|
||||
LuaClearStack( L) ;
|
||||
// verifico quale è la massima traslazione possibile
|
||||
double dLen = vtMove.Len() ;
|
||||
Vector3d vtDir = ( dLen > EPS_SMALL ? vtMove / dLen : V_NULL) ;
|
||||
bool bOk = ExeSurfFrMoveSimpleNoCollision( nId1, nId2, vtDir, dLen, nRefType) ;
|
||||
// restituisco il risultato
|
||||
if ( bOk)
|
||||
LuaSetParam( L, dLen) ;
|
||||
else
|
||||
LuaSetParam( L) ;
|
||||
return 1 ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
static int
|
||||
LuaSurfFrRotateSimpleNoCollision( lua_State* L)
|
||||
{
|
||||
// 4 o 5 parametri : nId1, nId2, ptCen, dAngDeg [, nRefType]
|
||||
int nId1 ;
|
||||
LuaCheckParam( L, 1, nId1)
|
||||
int nId2 ;
|
||||
LuaCheckParam( L, 2, nId2)
|
||||
Point3d ptCen ;
|
||||
LuaCheckParam( L, 3, ptCen)
|
||||
double dAngDeg ;
|
||||
LuaCheckParam( L, 4, dAngDeg)
|
||||
int nRefType = RTY_DEFAULT ;
|
||||
LuaGetParam( L, 5, nRefType) ;
|
||||
LuaClearStack( L) ;
|
||||
// verifico quale è la massima (in valore assoluto) rotazione possibile
|
||||
bool bOk = ExeSurfFrRotateSimpleNoCollision( nId1, nId2, ptCen, dAngDeg, nRefType) ;
|
||||
// restituisco il risultato
|
||||
if ( bOk)
|
||||
LuaSetParam( L, dAngDeg) ;
|
||||
else
|
||||
LuaSetParam( L) ;
|
||||
return 1 ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
static int
|
||||
LuaExtractSurfTmLoops( lua_State* L)
|
||||
{
|
||||
// 2 parametri : nId, nDestGrpId
|
||||
int nId ;
|
||||
LuaCheckParam( L, 1, nId)
|
||||
int nDestGrpId ;
|
||||
LuaCheckParam( L, 2, nDestGrpId)
|
||||
LuaClearStack( L) ;
|
||||
// recupero i contorni della superficie
|
||||
int nCount = 0 ;
|
||||
int nNewId = ExeExtractSurfTmLoops( nId, nDestGrpId, &nCount) ;
|
||||
// restituisco il risultato
|
||||
if ( nNewId != GDB_ID_NULL)
|
||||
LuaSetParam( L, nNewId) ;
|
||||
else
|
||||
LuaSetParam( L) ;
|
||||
LuaSetParam( L, nCount) ;
|
||||
return 2 ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
static int
|
||||
LuaGetSurfTmSilhouette( lua_State* L)
|
||||
{
|
||||
// 3 o 4 parametri : nId, vtDir, nDestGrpId [, nRefType]
|
||||
int nId ;
|
||||
LuaCheckParam( L, 1, nId)
|
||||
Vector3d vtDir ;
|
||||
LuaCheckParam( L, 2, vtDir)
|
||||
int nDestGrpId ;
|
||||
LuaCheckParam( L, 3, nDestGrpId)
|
||||
int nRefType = RTY_DEFAULT ;
|
||||
LuaGetParam( L, 4, nRefType) ;
|
||||
LuaClearStack( L) ;
|
||||
// recupero i contorni della superficie
|
||||
int nCount = 0 ;
|
||||
int nNewId = ExeGetSurfTmSilhouette( nId, vtDir, nDestGrpId, nRefType, &nCount) ;
|
||||
// restituisco il risultato
|
||||
if ( nNewId != GDB_ID_NULL)
|
||||
LuaSetParam( L, nNewId) ;
|
||||
else
|
||||
LuaSetParam( L) ;
|
||||
LuaSetParam( L, nCount) ;
|
||||
return 2 ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
static int
|
||||
LuaExtractSurfTmFacetLoops( lua_State* L)
|
||||
{
|
||||
// 3 parametri : nId, nFacet, nDestGrpId
|
||||
int nId ;
|
||||
LuaCheckParam( L, 1, nId)
|
||||
int nFacet ;
|
||||
LuaCheckParam( L, 2, nFacet)
|
||||
int nDestGrpId ;
|
||||
LuaCheckParam( L, 3, nDestGrpId)
|
||||
LuaClearStack( L) ;
|
||||
// recupero i contorni della faccetta della superficie
|
||||
int nCount ;
|
||||
int nNewId = ExeExtractSurfTmFacetLoops( nId, nFacet, nDestGrpId, &nCount) ;
|
||||
// restituisco il risultato
|
||||
if ( nNewId != GDB_ID_NULL)
|
||||
LuaSetParam( L, nNewId) ;
|
||||
else
|
||||
LuaSetParam( L) ;
|
||||
LuaSetParam( L, nCount) ;
|
||||
return 2 ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
static int
|
||||
LuaCopySurfTmFacet( lua_State* L)
|
||||
{
|
||||
// 3 parametri : nId, nFacet, nDestGrpId
|
||||
int nId ;
|
||||
LuaCheckParam( L, 1, nId)
|
||||
int nFacet ;
|
||||
LuaCheckParam( L, 2, nFacet)
|
||||
int nDestGrpId ;
|
||||
LuaCheckParam( L, 3, nDestGrpId)
|
||||
LuaClearStack( L) ;
|
||||
// copio la faccia della superficie nel gruppo indicato
|
||||
int nNewId = ExeCopySurfTmFacet( nId, nFacet, nDestGrpId) ;
|
||||
// restituisco il risultato
|
||||
if ( nNewId != GDB_ID_NULL)
|
||||
LuaSetParam( L, nNewId) ;
|
||||
else
|
||||
LuaSetParam( L) ;
|
||||
return 1 ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
static int
|
||||
LuaSurfTmSwapFacets( lua_State* L)
|
||||
@@ -312,52 +142,6 @@ LuaSurfTmSwapFacets( lua_State* L)
|
||||
return 1 ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
static int
|
||||
LuaSurfTmGetFacetBBox( lua_State* L)
|
||||
{
|
||||
// 3 parametri : nId, nFacet, nFlag
|
||||
int nId ;
|
||||
LuaCheckParam( L, 1, nId)
|
||||
int nFacet ;
|
||||
LuaCheckParam( L, 2, nFacet)
|
||||
int nFlag ;
|
||||
LuaCheckParam( L, 3, nFlag)
|
||||
LuaClearStack( L) ;
|
||||
// recupero il bounding box della faccia in locale
|
||||
BBox3d b3Box ;
|
||||
bool bOk = ExeSurfTmGetFacetBBox( nId, nFacet, nFlag, b3Box) ;
|
||||
// restituisco il risultato
|
||||
if ( bOk)
|
||||
LuaSetParam( L, b3Box) ;
|
||||
else
|
||||
LuaSetParam( L) ;
|
||||
return 1 ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
static int
|
||||
LuaSurfTmGetFacetBBoxGlob( lua_State* L)
|
||||
{
|
||||
// 3 parametri : nId, nFacet, nFlag
|
||||
int nId ;
|
||||
LuaCheckParam( L, 1, nId)
|
||||
int nFacet ;
|
||||
LuaCheckParam( L, 2, nFacet)
|
||||
int nFlag ;
|
||||
LuaCheckParam( L, 3, nFlag)
|
||||
LuaClearStack( L) ;
|
||||
// recupero il bounding box della faccia in globale
|
||||
BBox3d b3Box ;
|
||||
bool bOk = ExeSurfTmGetFacetBBoxGlob( nId, nFacet, nFlag, b3Box) ;
|
||||
// restituisco il risultato
|
||||
if ( bOk)
|
||||
LuaSetParam( L, b3Box) ;
|
||||
else
|
||||
LuaSetParam( L) ;
|
||||
return 1 ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
static int
|
||||
LuaCutSurfTmPlane( lua_State* L)
|
||||
@@ -480,16 +264,7 @@ LuaInstallGdbModifySurf( LuaMgr& luaMgr)
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtSurfFrSubtract", LuaSurfFrSubtract) ;
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtSurfFrIntersect", LuaSurfFrIntersect) ;
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtSurfFrOffset", LuaSurfFrOffset) ;
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtExtractSurfFrChunkLoops", LuaExtractSurfFrChunkLoops) ;
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtSurfFrMoveSimpleNoCollision", LuaSurfFrMoveSimpleNoCollision) ;
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtSurfFrRotateSimpleNoCollision", LuaSurfFrRotateSimpleNoCollision) ;
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtExtractSurfTmLoops", LuaExtractSurfTmLoops) ;
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtGetSurfTmSilhouette", LuaGetSurfTmSilhouette) ;
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtExtractSurfTmFacetLoops", LuaExtractSurfTmFacetLoops) ;
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtCopySurfTmFacet", LuaCopySurfTmFacet) ;
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtSurfTmSwapFacets", LuaSurfTmSwapFacets) ;
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtSurfTmGetFacetBBox", LuaSurfTmGetFacetBBox) ;
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtSurfTmGetFacetBBoxGlob", LuaSurfTmGetFacetBBoxGlob) ;
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtCutSurfTmPlane", LuaCutSurfTmPlane) ;
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtCutSurfTmClosedCurve", LuaCutSurfTmClosedCurve) ;
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtSurfTmAdd", LuaSurfTmAdd) ;
|
||||
|
||||
@@ -39,74 +39,6 @@ LuaExplodeVolume( lua_State* L)
|
||||
return 2 ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
static int
|
||||
LuaVolZmapGetPartBBox( lua_State* L)
|
||||
{
|
||||
// 3 parametri : nId, nPart, nFlag
|
||||
int nId ;
|
||||
LuaCheckParam( L, 1, nId)
|
||||
int nPart ;
|
||||
LuaCheckParam( L, 2, nPart)
|
||||
int nFlag ;
|
||||
LuaCheckParam( L, 3, nFlag)
|
||||
LuaClearStack( L) ;
|
||||
// recupero il bounding box della parte in locale
|
||||
BBox3d b3Box ;
|
||||
bool bOk = ExeVolZmapGetPartBBox( nId, nPart, nFlag, b3Box) ;
|
||||
// restituisco il risultato
|
||||
if ( bOk)
|
||||
LuaSetParam( L, b3Box) ;
|
||||
else
|
||||
LuaSetParam( L) ;
|
||||
return 1 ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
static int
|
||||
LuaVolZmapGetPartBBoxGlob( lua_State* L)
|
||||
{
|
||||
// 3 parametri : nId, nPart, nFlag
|
||||
int nId ;
|
||||
LuaCheckParam( L, 1, nId)
|
||||
int nPart ;
|
||||
LuaCheckParam( L, 2, nPart)
|
||||
int nFlag ;
|
||||
LuaCheckParam( L, 3, nFlag)
|
||||
LuaClearStack( L) ;
|
||||
// recupero il bounding box della parte in globale
|
||||
BBox3d b3Box ;
|
||||
bool bOk = ExeVolZmapGetPartBBoxGlob( nId, nPart, nFlag, b3Box) ;
|
||||
// restituisco il risultato
|
||||
if ( bOk)
|
||||
LuaSetParam( L, b3Box) ;
|
||||
else
|
||||
LuaSetParam( L) ;
|
||||
return 1 ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
static int
|
||||
LuaCopyVolZmapPart( lua_State* L)
|
||||
{
|
||||
// 3 parametri : Id, nPart(0-based), nDestGrpId
|
||||
int nId ;
|
||||
LuaCheckParam( L, 1, nId)
|
||||
int nPart ;
|
||||
LuaCheckParam( L, 2, nPart)
|
||||
int nDestGrpId ;
|
||||
LuaCheckParam( L, 3, nDestGrpId)
|
||||
LuaClearStack( L) ;
|
||||
// copio la parte indicata nel gruppo specificato
|
||||
int nNewId = ExeCopyVolZmapPart( nId, nPart, nDestGrpId) ;
|
||||
// restituisco il risultato
|
||||
if ( nNewId != GDB_ID_NULL)
|
||||
LuaSetParam( L, nNewId) ;
|
||||
else
|
||||
LuaSetParam( L) ;
|
||||
return 1 ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
static int
|
||||
LuaRemoveVolZmapPart( lua_State* L)
|
||||
@@ -369,63 +301,6 @@ LuaVolZmapMillingStep( lua_State* L)
|
||||
}
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
static int
|
||||
LuaVolZmapGetDepth( lua_State* L)
|
||||
{
|
||||
// 3 o 4 o 5 parametri : nId, ptP, vtDir [, nRefType] [, bExact]
|
||||
int nId ;
|
||||
LuaCheckParam( L, 1, nId)
|
||||
Point3d ptP ;
|
||||
LuaCheckParam( L, 2, ptP)
|
||||
Vector3d vtDir ;
|
||||
LuaCheckParam( L, 3, vtDir)
|
||||
int nRefType = RTY_DEFAULT ;
|
||||
bool bExact = false ;
|
||||
if ( LuaGetParam( L, 4, nRefType))
|
||||
LuaGetParam( L, 5, bExact) ;
|
||||
else
|
||||
LuaGetParam( L, 4, bExact) ;
|
||||
LuaClearStack( L) ;
|
||||
// eseguo calcolo profondità dal punto lungo la direzione
|
||||
double dLen1, dLen2 ;
|
||||
bool bOk = ExeVolZmapGetDepth( nId, ptP, vtDir, nRefType, bExact, dLen1, dLen2) ;
|
||||
// restituisco il risultato
|
||||
if ( bOk) {
|
||||
LuaSetParam( L, dLen1) ;
|
||||
LuaSetParam( L, dLen2) ;
|
||||
}
|
||||
else {
|
||||
LuaSetParam( L) ;
|
||||
LuaSetParam( L) ;
|
||||
}
|
||||
return 2 ;
|
||||
}
|
||||
//----------------------------------------------------------------------------
|
||||
static int
|
||||
LuaVolZmapGetEdges( lua_State* L)
|
||||
{
|
||||
// 2 parametri : nId, nDestGrpId
|
||||
int nId ;
|
||||
LuaCheckParam( L, 1, nId)
|
||||
int nDestGrpId ;
|
||||
LuaCheckParam( L, 2, nDestGrpId)
|
||||
LuaClearStack( L) ;
|
||||
// eseguo calcolo profondità dal punto lungo la direzione
|
||||
int nCount ;
|
||||
int nFirstId = ExeVolZmapGetEdges( nId, nDestGrpId, &nCount) ;
|
||||
// restituisco il risultato
|
||||
if ( nFirstId != GDB_ID_NULL) {
|
||||
LuaSetParam( L, nFirstId) ;
|
||||
LuaSetParam( L, nCount) ;
|
||||
}
|
||||
else {
|
||||
LuaSetParam( L) ;
|
||||
LuaSetParam( L) ;
|
||||
}
|
||||
return 2 ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
static int
|
||||
LuaCutVolZmapPlane( lua_State* L)
|
||||
@@ -453,9 +328,6 @@ LuaInstallGdbModifyVol( LuaMgr& luaMgr)
|
||||
{
|
||||
bool bOk = ( &luaMgr != nullptr) ;
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtExplodeVolume", LuaExplodeVolume) ;
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtVolZmapGetPartBBox", LuaVolZmapGetPartBBox) ;
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtVolZmapGetPartBBoxGlob", LuaVolZmapGetPartBBoxGlob) ;
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtCopyVolZmapPart", LuaCopyVolZmapPart) ;
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtRemoveVolZmapPart", LuaRemoveVolZmapPart) ;
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtVolZmapSetStdTool", LuaVolZmapSetStdTool) ;
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtVolZmapSetAdvTool", LuaVolZmapSetAdvTool) ;
|
||||
@@ -466,8 +338,6 @@ LuaInstallGdbModifyVol( LuaMgr& luaMgr)
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtVolZmapResetTool", LuaVolZmapResetTool) ;
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtVolZmapGetToolOutline", LuaVolZmapGetToolOutline) ;
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtVolZmapMillingStep", LuaVolZmapMillingStep) ;
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtVolZmapGetDepth", LuaVolZmapGetDepth) ;
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtVolZmapGetEdges", LuaVolZmapGetEdges) ;
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtCutVolZmapPlane", LuaCutVolZmapPlane) ;
|
||||
return bOk ;
|
||||
}
|
||||
-848
@@ -16,11 +16,8 @@
|
||||
#include "LUA.h"
|
||||
#include "/EgtDev/Include/EXeExecutor.h"
|
||||
#include "/EgtDev/Include/EXeConst.h"
|
||||
#include "/EgtDev/Include/EGkSurfTriMesh.h"
|
||||
#include "/EgtDev/Include/EGkLuaAux.h"
|
||||
|
||||
using namespace std ;
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
static int
|
||||
LuaStartPoint( lua_State* L)
|
||||
@@ -280,153 +277,6 @@ LuaFrame( lua_State* L)
|
||||
return 1 ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
static int
|
||||
LuaCurveDomain( lua_State* L)
|
||||
{
|
||||
// 1 parametro : Id
|
||||
int nId ;
|
||||
LuaCheckParam( L, 1, nId)
|
||||
LuaClearStack( L) ;
|
||||
// recupero il dominio della curva
|
||||
double dStart, dEnd ;
|
||||
if ( ExeCurveDomain( nId, &dStart, &dEnd)) {
|
||||
LuaSetParam( L, dStart) ;
|
||||
LuaSetParam( L, dEnd) ;
|
||||
return 2 ;
|
||||
}
|
||||
else {
|
||||
LuaSetParam( 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 ( ExeCurveLength( nId, &dLen))
|
||||
LuaSetParam( L, dLen) ;
|
||||
else
|
||||
LuaSetParam( L) ;
|
||||
return 1 ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
static int
|
||||
LuaCurveIsClosed( lua_State* L)
|
||||
{
|
||||
// 1 parametro : Id
|
||||
int nId ;
|
||||
LuaCheckParam( L, 1, nId)
|
||||
LuaClearStack( L) ;
|
||||
// verifico se curva chiusa
|
||||
bool bClosed = ExeCurveIsClosed( nId) ;
|
||||
LuaSetParam( L, bClosed) ;
|
||||
return 1 ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
static int
|
||||
LuaCurveIsFlat( lua_State* L)
|
||||
{
|
||||
// 1 o 2 parametri : Id [, dToler]
|
||||
int nId ;
|
||||
LuaCheckParam( L, 1, nId)
|
||||
double dToler = EPS_SMALL ;
|
||||
LuaGetParam( L, 2, dToler) ;
|
||||
LuaClearStack( L) ;
|
||||
// verifico se curva piatta e restituisco il piano medio
|
||||
Plane3d Plane ;
|
||||
bool bFlat = ExeCurveIsFlat( nId, Plane, dToler) ;
|
||||
LuaSetParam( L, bFlat) ;
|
||||
LuaSetParam( L, Plane.GetVersN()) ;
|
||||
LuaSetParam( L, Plane.GetDist()) ;
|
||||
return 3 ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
static int
|
||||
LuaCurveAreaXY( lua_State* L)
|
||||
{
|
||||
// 1 parametro : Id
|
||||
int nId ;
|
||||
LuaCheckParam( L, 1, nId)
|
||||
LuaClearStack( L) ;
|
||||
// recupero l'area della curva proiettata sul piano XY
|
||||
double dArea ;
|
||||
if ( ExeCurveAreaXY( nId, dArea))
|
||||
LuaSetParam( L, dArea) ;
|
||||
else
|
||||
LuaSetParam( L) ;
|
||||
return 1 ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
static int
|
||||
LuaCurveArea( lua_State* L)
|
||||
{
|
||||
// 1 parametro : Id
|
||||
int nId ;
|
||||
LuaCheckParam( L, 1, nId)
|
||||
LuaClearStack( L) ;
|
||||
// recupero il piano medio della curva e la sua area su di esso
|
||||
Plane3d Plane ;
|
||||
double dArea ;
|
||||
if ( ExeCurveArea( nId, Plane, dArea)) {
|
||||
LuaSetParam( L, Plane.GetVersN()) ;
|
||||
LuaSetParam( L, Plane.GetDist()) ;
|
||||
LuaSetParam( L, dArea) ;
|
||||
return 3 ;
|
||||
}
|
||||
else {
|
||||
LuaSetParam( L) ;
|
||||
return 1 ;
|
||||
}
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
static int
|
||||
LuaCurveExtrusion( lua_State* L)
|
||||
{
|
||||
// 1 o 2 parametri : Id [, nRefId]
|
||||
int nId ;
|
||||
LuaCheckParam( L, 1, nId)
|
||||
int nRefId = nId ;
|
||||
LuaGetParam( L, 2, nRefId) ;
|
||||
LuaClearStack( L) ;
|
||||
// recupero il versore
|
||||
Vector3d vtExtr ;
|
||||
if ( ExeCurveExtrusion( nId, nRefId, vtExtr))
|
||||
LuaSetParam( L, vtExtr) ;
|
||||
else
|
||||
LuaSetParam( L) ;
|
||||
return 1 ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
static int
|
||||
LuaCurveThickness( lua_State* L)
|
||||
{
|
||||
// 1 parametro : Id
|
||||
int nId ;
|
||||
LuaCheckParam( L, 1, nId)
|
||||
LuaClearStack( L) ;
|
||||
// recupero lo spessore
|
||||
double dThick ;
|
||||
if ( ExeCurveThickness( nId, &dThick))
|
||||
LuaSetParam( L, dThick) ;
|
||||
else
|
||||
LuaSetParam( L) ;
|
||||
return 1 ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
static int
|
||||
LuaExtrusionByThickness( lua_State* L)
|
||||
@@ -449,664 +299,6 @@ LuaExtrusionByThickness( lua_State* L)
|
||||
return 1 ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
static int
|
||||
LuaCurveSelfIntersCount( lua_State* L)
|
||||
{
|
||||
// 1 parametro : Id
|
||||
int nId ;
|
||||
LuaCheckParam( L, 1, nId)
|
||||
LuaClearStack( L) ;
|
||||
// recupero il numero di auto-intersezioni
|
||||
int nCount ;
|
||||
if ( ExeCurveSelfIntersCount( nId, &nCount))
|
||||
LuaSetParam( L, nCount) ;
|
||||
else
|
||||
LuaSetParam( L) ;
|
||||
return 1 ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
static int
|
||||
LuaCurveMinAreaRectangleXY( lua_State* L)
|
||||
{
|
||||
// 1 o 2 parametri : Id [, nRefId]
|
||||
int nId ;
|
||||
LuaCheckParam( L, 1, nId)
|
||||
int nRefId = nId ;
|
||||
LuaGetParam( L, 2, nRefId) ;
|
||||
LuaClearStack( L) ;
|
||||
// recupero i dati del rettangolo
|
||||
Frame3d frRect ;
|
||||
double dDimX ;
|
||||
double dDimY ;
|
||||
bool bOk = ExeCurveMinAreaRectangleXY( nId, nRefId, frRect, dDimX, dDimY) ;
|
||||
if ( bOk) {
|
||||
LuaSetParam( L, frRect) ;
|
||||
LuaSetParam( L, dDimX) ;
|
||||
LuaSetParam( L, dDimY) ;
|
||||
return 3 ;
|
||||
}
|
||||
else {
|
||||
LuaSetParam( L) ;
|
||||
return 1 ;
|
||||
}
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
static int
|
||||
LuaCurveWithRegionClassify( lua_State* L)
|
||||
{
|
||||
// 2 parametri : nCurveId, nRegionId
|
||||
int nCurveId ;
|
||||
LuaCheckParam( L, 1, nCurveId)
|
||||
int nRegionId ;
|
||||
LuaCheckParam( L, 2, nRegionId) ;
|
||||
LuaClearStack( L) ;
|
||||
// eseguo la classificazione
|
||||
int nRes = ExeCurveWithRegionClassify( nCurveId, nRegionId) ;
|
||||
if ( nRes != CRC_NULL)
|
||||
LuaSetParam( L, nRes) ;
|
||||
else
|
||||
LuaSetParam( L) ;
|
||||
return 1 ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
static int
|
||||
LuaArcRadius( lua_State* L)
|
||||
{
|
||||
// 1 parametro : Id
|
||||
int nId ;
|
||||
LuaCheckParam( L, 1, nId)
|
||||
LuaClearStack( L) ;
|
||||
// recupero il raggio
|
||||
double dRad ;
|
||||
if ( ExeArcRadius( nId, &dRad))
|
||||
LuaSetParam( L, dRad) ;
|
||||
else
|
||||
LuaSetParam( L) ;
|
||||
return 1 ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
static int
|
||||
LuaArcAngCenter( lua_State* L)
|
||||
{
|
||||
// 1 parametro : Id
|
||||
int nId ;
|
||||
LuaCheckParam( L, 1, nId)
|
||||
LuaClearStack( L) ;
|
||||
// recupero l'angolo al centro in gradi
|
||||
double pdAngDeg ;
|
||||
if ( ExeArcAngCenter( nId, &pdAngDeg))
|
||||
LuaSetParam( L, pdAngDeg) ;
|
||||
else
|
||||
LuaSetParam( L) ;
|
||||
return 1 ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
static int
|
||||
LuaArcDeltaN( lua_State* L)
|
||||
{
|
||||
// 1 parametro : Id
|
||||
int nId ;
|
||||
LuaCheckParam( L, 1, nId)
|
||||
LuaClearStack( L) ;
|
||||
// recupero il delta su normale al suo piano
|
||||
double dDeltaN ;
|
||||
if ( ExeArcDeltaN( nId, &dDeltaN))
|
||||
LuaSetParam( L, dDeltaN) ;
|
||||
else
|
||||
LuaSetParam( L) ;
|
||||
return 1 ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
static int
|
||||
LuaArcNormVersor( lua_State* L)
|
||||
{
|
||||
// 1 o 2 parametri : Id [, nRefId]
|
||||
int nId ;
|
||||
LuaCheckParam( L, 1, nId)
|
||||
int nRefId = nId ;
|
||||
LuaGetParam( L, 2, nRefId) ;
|
||||
LuaClearStack( L) ;
|
||||
// recupero il versore
|
||||
Vector3d vtNorm ;
|
||||
if ( ExeArcNormVersor( nId, nRefId, vtNorm))
|
||||
LuaSetParam( L, vtNorm) ;
|
||||
else
|
||||
LuaSetParam( 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 ;
|
||||
LuaGetParam( L, 3, nRefId) ;
|
||||
LuaClearStack( L) ;
|
||||
// recupero il centro della curva semplice indicizzata
|
||||
Point3d ptCen ;
|
||||
if ( ExeCurveCompoCenter( nId, nCrv, nRefId, ptCen))
|
||||
LuaSetParam( L, ptCen) ;
|
||||
else
|
||||
LuaSetParam( L) ;
|
||||
return 1 ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
static int
|
||||
LuaCurveCompoRadius( lua_State* L)
|
||||
{
|
||||
// 2 parametri : Id, nCrv
|
||||
int nId ;
|
||||
LuaCheckParam( L, 1, nId)
|
||||
int nCrv ;
|
||||
LuaCheckParam( L, 2, nCrv)
|
||||
LuaClearStack( L) ;
|
||||
// recupero il raggio della curva semplice indicizzata
|
||||
double dRadius ;
|
||||
if ( ExeCurveCompoRadius( nId, nCrv, dRadius))
|
||||
LuaSetParam( L, dRadius) ;
|
||||
else
|
||||
LuaSetParam( L) ;
|
||||
return 1 ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
static int
|
||||
LuaSurfArea( lua_State* L)
|
||||
{
|
||||
// 1 parametro : Id
|
||||
int nId ;
|
||||
LuaCheckParam( L, 1, nId)
|
||||
LuaClearStack( L) ;
|
||||
// recupero la sua area
|
||||
double dArea ;
|
||||
if ( ExeSurfArea( nId, dArea))
|
||||
LuaSetParam( L, dArea) ;
|
||||
else
|
||||
LuaSetParam( L) ;
|
||||
return 1 ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
static int
|
||||
LuaSurfVolume( lua_State* L)
|
||||
{
|
||||
// 1 parametro : Id
|
||||
int nId ;
|
||||
LuaCheckParam( L, 1, nId)
|
||||
LuaClearStack( L) ;
|
||||
// recupero il suo eventuale volume (se chiusa)
|
||||
double dVol ;
|
||||
if ( ExeSurfVolume( nId, dVol))
|
||||
LuaSetParam( L, dVol) ;
|
||||
else
|
||||
LuaSetParam( L) ;
|
||||
return 1 ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
static int
|
||||
LuaSurfFrNormVersor( lua_State* L)
|
||||
{
|
||||
// 1 o 2 parametri : Id [, nRefId]
|
||||
int nId ;
|
||||
LuaCheckParam( L, 1, nId)
|
||||
int nRefId = nId ;
|
||||
LuaGetParam( L, 2, nRefId) ;
|
||||
LuaClearStack( L) ;
|
||||
// recupero il versore
|
||||
Vector3d vtNorm ;
|
||||
if ( ExeSurfFrNormVersor( nId, nRefId, vtNorm))
|
||||
LuaSetParam( L, vtNorm) ;
|
||||
else
|
||||
LuaSetParam( L) ;
|
||||
return 1 ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
static int
|
||||
LuaSurfFrGrossArea( lua_State* L)
|
||||
{
|
||||
// 1 parametro : Id
|
||||
int nId ;
|
||||
LuaCheckParam( L, 1, nId)
|
||||
LuaClearStack( L) ;
|
||||
// recupero la sua area senza eventuali buchi
|
||||
double dArea ;
|
||||
if ( ExeSurfFrGrossArea( nId, dArea))
|
||||
LuaSetParam( L, dArea) ;
|
||||
else
|
||||
LuaSetParam( L) ;
|
||||
return 1 ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
static int
|
||||
LuaSurfFrChunkCount( lua_State* L)
|
||||
{
|
||||
// 1 parametro : Id
|
||||
int nId ;
|
||||
LuaCheckParam( L, 1, nId)
|
||||
LuaClearStack( L) ;
|
||||
// recupero il numero di componenti connessi (chunk) della regione
|
||||
int nNbr = ExeSurfFrChunkCount( nId) ;
|
||||
LuaSetParam( L, nNbr) ;
|
||||
return 1 ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
static int
|
||||
LuaSurfFrChunkSimpleClassify( lua_State* L)
|
||||
{
|
||||
// 4 parametro : Id1, Chunk1, Id2, Chunk2
|
||||
int nId1 ;
|
||||
LuaCheckParam( L, 1, nId1)
|
||||
int nChunk1 ;
|
||||
LuaCheckParam( L, 2, nChunk1)
|
||||
int nId2 ;
|
||||
LuaCheckParam( L, 3, nId2)
|
||||
int nChunk2 ;
|
||||
LuaCheckParam( L, 4, nChunk2)
|
||||
LuaClearStack( L) ;
|
||||
// classifico il chunk della prima regione rispetto a quello della seconda
|
||||
int nClass = ExeSurfFrChunkSimpleClassify( nId1, nChunk1, nId2, nChunk2) ;
|
||||
LuaSetParam( L, nClass) ;
|
||||
return 1 ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
static int
|
||||
LuaSurfFrTestExternal( lua_State* L)
|
||||
{
|
||||
// 2 o 3 parametri : Id1, Id2 [, dMinDist]
|
||||
int nId1 ;
|
||||
LuaCheckParam( L, 1, nId1)
|
||||
int nId2 ;
|
||||
LuaCheckParam( L, 2, nId2)
|
||||
double dMinDist = 0 ;
|
||||
LuaGetParam( L, 3, dMinDist) ;
|
||||
LuaClearStack( L) ;
|
||||
// verifico se le due regioni sono esterne con distanza superiore al minimo
|
||||
bool bOk = ExeSurfFrTestExternal( nId1, nId2, dMinDist) ;
|
||||
LuaSetParam( L, bOk) ;
|
||||
return 1 ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
static int
|
||||
LuaSurfTmFacetCount( lua_State* L)
|
||||
{
|
||||
// 1 parametro : Id
|
||||
int nId ;
|
||||
LuaCheckParam( L, 1, nId)
|
||||
LuaClearStack( L) ;
|
||||
// recupero il numero di facce della superficie trimesh
|
||||
int nNbr = ExeSurfTmFacetCount( nId) ;
|
||||
LuaSetParam( L, nNbr) ;
|
||||
return 1 ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
static int
|
||||
LuaSurfTmFacetFromTria( lua_State* L)
|
||||
{
|
||||
// 2 parametri : nId, nTria
|
||||
int nId ;
|
||||
LuaCheckParam( L, 1, nId)
|
||||
int nTria ;
|
||||
LuaCheckParam( L, 2, nTria)
|
||||
LuaClearStack( L) ;
|
||||
// recupero l'indice della faccia cui appartiene il triangolo della superficie
|
||||
int nFacet = ExeSurfTmFacetFromTria( nId, nTria) ;
|
||||
// restituisco il risultato
|
||||
if ( nFacet != SVT_NULL)
|
||||
LuaSetParam( L, nFacet) ;
|
||||
else
|
||||
LuaSetParam( L) ;
|
||||
return 1 ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
static int
|
||||
LuaSurfTmFacetAdjacencies( lua_State* L)
|
||||
{
|
||||
// 2 parametri : nId, nFacet
|
||||
int nId ;
|
||||
LuaCheckParam( L, 1, nId)
|
||||
int nFacet ;
|
||||
LuaCheckParam( L, 2, nFacet)
|
||||
LuaClearStack( L) ;
|
||||
// recupero le adiacenze della faccetta della superficie
|
||||
INTMATRIX vAdj ;
|
||||
bool bOk = ExeSurfTmFacetAdjacencies( nId, nFacet, vAdj) ;
|
||||
// restituisco il risultato
|
||||
if ( bOk)
|
||||
LuaSetParam( L, vAdj) ;
|
||||
else
|
||||
LuaSetParam( L) ;
|
||||
return 1 ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
static int
|
||||
LuaSurfTmFacetNearestEndPoint( lua_State* L)
|
||||
{
|
||||
// 3 o 4 parametri : Id, nFacet, ptNear [, nRefId]
|
||||
int nId ;
|
||||
LuaCheckParam( L, 1, nId)
|
||||
int nFacet ;
|
||||
LuaCheckParam( L, 2, nFacet)
|
||||
Point3d ptNear ;
|
||||
LuaCheckParam( L, 3, ptNear)
|
||||
int nRefId = nId ;
|
||||
LuaGetParam( L, 4, nRefId) ;
|
||||
LuaClearStack( L) ;
|
||||
// recupero il punto End più vicino della faccia della superficie trimesh
|
||||
Point3d ptEnd ;
|
||||
Vector3d vtN ;
|
||||
if ( ExeSurfTmFacetNearestEndPoint( nId, nFacet, ptNear, nRefId, ptEnd, vtN)) {
|
||||
LuaSetParam( L, ptEnd) ;
|
||||
LuaSetParam( L, vtN) ;
|
||||
}
|
||||
else {
|
||||
LuaSetParam( L) ;
|
||||
LuaSetParam( L) ;
|
||||
}
|
||||
return 2 ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
static int
|
||||
LuaSurfTmFacetNearestMidPoint( lua_State* L)
|
||||
{
|
||||
// 3 o 4 parametri : Id, nFacet, ptNear [, nRefId]
|
||||
int nId ;
|
||||
LuaCheckParam( L, 1, nId)
|
||||
int nFacet ;
|
||||
LuaCheckParam( L, 2, nFacet)
|
||||
Point3d ptNear ;
|
||||
LuaCheckParam( L, 3, ptNear)
|
||||
int nRefId = nId ;
|
||||
LuaGetParam( L, 4, nRefId) ;
|
||||
LuaClearStack( L) ;
|
||||
// recupero il punto Mid più vicino della faccia della superficie trimesh
|
||||
Point3d ptMid ;
|
||||
Vector3d vtN ;
|
||||
if ( ExeSurfTmFacetNearestMidPoint( nId, nFacet, ptNear, nRefId, ptMid, vtN)) {
|
||||
LuaSetParam( L, ptMid) ;
|
||||
LuaSetParam( L, vtN) ;
|
||||
}
|
||||
else {
|
||||
LuaSetParam( L) ;
|
||||
LuaSetParam( L) ;
|
||||
}
|
||||
return 2 ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
static int
|
||||
LuaSurfTmFacetCenter( lua_State* L)
|
||||
{
|
||||
// 2 o 3 parametri : Id, nFacet [, nRefId]
|
||||
int nId ;
|
||||
LuaCheckParam( L, 1, nId)
|
||||
int nFacet ;
|
||||
LuaCheckParam( L, 2, nFacet)
|
||||
int nRefId = nId ;
|
||||
LuaGetParam( L, 3, nRefId) ;
|
||||
LuaClearStack( L) ;
|
||||
// recupero il centro della faccia della superficie trimesh
|
||||
Point3d ptCen ;
|
||||
Vector3d vtN ;
|
||||
if ( ExeSurfTmFacetCenter( nId, nFacet, nRefId, ptCen, vtN)) {
|
||||
LuaSetParam( L, ptCen) ;
|
||||
LuaSetParam( L, vtN) ;
|
||||
}
|
||||
else {
|
||||
LuaSetParam( L) ;
|
||||
LuaSetParam( L) ;
|
||||
}
|
||||
return 2 ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
static int
|
||||
LuaSurfTmFacetNormVersor( lua_State* L)
|
||||
{
|
||||
// 2 o 3 parametri : Id, nFacet [, nRefId]
|
||||
int nId ;
|
||||
LuaCheckParam( L, 1, nId)
|
||||
int nFacet ;
|
||||
LuaCheckParam( L, 2, nFacet)
|
||||
int nRefId = nId ;
|
||||
LuaGetParam( L, 3, nRefId) ;
|
||||
LuaClearStack( L) ;
|
||||
// recupero la normale della faccia della superficie trimesh
|
||||
Vector3d vtNorm ;
|
||||
if ( ExeSurfTmFacetNormVersor( nId, nFacet, nRefId, vtNorm))
|
||||
LuaSetParam( L, vtNorm) ;
|
||||
else
|
||||
LuaSetParam( L) ;
|
||||
return 1 ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
static int
|
||||
LuaSurfTmFacetMinAreaRectangle( lua_State* L)
|
||||
{
|
||||
// 2 o 3 parametri : Id, nFacet [, nRefId]
|
||||
int nId ;
|
||||
LuaCheckParam( L, 1, nId)
|
||||
int nFacet ;
|
||||
LuaCheckParam( L, 2, nFacet)
|
||||
int nRefId = nId ;
|
||||
LuaGetParam( L, 3, nRefId) ;
|
||||
LuaClearStack( L) ;
|
||||
// recupero il rettangolo di minima area della faccia della superficie trimesh
|
||||
Frame3d frRect ;
|
||||
double dDimX, dDimY ;
|
||||
if ( ExeSurfTmFacetMinAreaRectangle( nId, nFacet, nRefId, frRect, dDimX, dDimY)) {
|
||||
LuaSetParam( L, frRect) ;
|
||||
LuaSetParam( L, dDimX) ;
|
||||
LuaSetParam( L, dDimY) ;
|
||||
return 3 ;
|
||||
}
|
||||
else {
|
||||
LuaSetParam( L) ;
|
||||
return 1 ;
|
||||
}
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
static int
|
||||
LuaSurfTmFacetOppositeSide( lua_State* L)
|
||||
{
|
||||
// 3 o 4 parametri : Id, nFacet, vtDir [, nRefId]
|
||||
int nId ;
|
||||
LuaCheckParam( L, 1, nId)
|
||||
int nFacet ;
|
||||
LuaCheckParam( L, 2, nFacet)
|
||||
Vector3d vtDir ;
|
||||
LuaCheckParam( L, 3, vtDir)
|
||||
int nRefId = nId ;
|
||||
LuaGetParam( L, 4, nRefId) ;
|
||||
LuaClearStack( L) ;
|
||||
// recupero i punti estremi della parte di faccia opposta alla direzione
|
||||
Point3d ptP1, ptPm, ptP2 ;
|
||||
Vector3d vtIn1, vtOut2 ;
|
||||
double dLen, dWidth ;
|
||||
if ( ExeSurfTmFacetOppositeSideEx( nId, nFacet, vtDir, nRefId, ptP1, ptPm, ptP2, vtIn1, vtOut2, dLen, dWidth)) {
|
||||
LuaSetParam( L, ptP1) ;
|
||||
LuaSetParam( L, ptPm) ;
|
||||
LuaSetParam( L, ptP2) ;
|
||||
LuaSetParam( L, vtIn1) ;
|
||||
LuaSetParam( L, vtOut2) ;
|
||||
LuaSetParam( L, dLen) ;
|
||||
LuaSetParam( L, dWidth) ;
|
||||
}
|
||||
else {
|
||||
LuaSetParam( L) ;
|
||||
LuaSetParam( L) ;
|
||||
LuaSetParam( L) ;
|
||||
LuaSetParam( L) ;
|
||||
LuaSetParam( L) ;
|
||||
LuaSetParam( L) ;
|
||||
LuaSetParam( L) ;
|
||||
}
|
||||
return 7 ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
static int
|
||||
LuaSurfTmFacetsContact( lua_State* L)
|
||||
{
|
||||
// 3 o 4 parametri : Id, nF1, nF2 [, nRefId]
|
||||
int nId ;
|
||||
LuaCheckParam( L, 1, nId)
|
||||
int nF1 ;
|
||||
LuaCheckParam( L, 2, nF1)
|
||||
int nF2 ;
|
||||
LuaCheckParam( L, 3, nF2)
|
||||
int nRefId = nId ;
|
||||
LuaGetParam( L, 4, nRefId) ;
|
||||
LuaClearStack( L) ;
|
||||
// recupero i dati di contatto tra le due facce
|
||||
bool bAdjac ;
|
||||
Point3d ptP1, ptP2 ;
|
||||
double dAng = 0 ;
|
||||
if ( ExeSurfTmFacetsContact( nId, nF1, nF2, nRefId, bAdjac, ptP1, ptP2, dAng)) {
|
||||
LuaSetParam( L, bAdjac) ;
|
||||
LuaSetParam( L, ptP1) ;
|
||||
LuaSetParam( L, ptP2) ;
|
||||
LuaSetParam( L, dAng) ;
|
||||
}
|
||||
else {
|
||||
LuaSetParam( L) ;
|
||||
LuaSetParam( L) ;
|
||||
LuaSetParam( L) ;
|
||||
LuaSetParam( L) ;
|
||||
}
|
||||
return 4 ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
static int
|
||||
LuaVolZmapVolume( lua_State* L)
|
||||
{
|
||||
// 1 parametro : Id
|
||||
int nId ;
|
||||
LuaCheckParam( L, 1, nId)
|
||||
LuaClearStack( L) ;
|
||||
// recupero il suo volume
|
||||
double dVol ;
|
||||
if ( ExeVolZmapVolume( nId, dVol))
|
||||
LuaSetParam( L, dVol) ;
|
||||
else
|
||||
LuaSetParam( L) ;
|
||||
return 1 ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
static int
|
||||
LuaVolZmapPartCount( lua_State* L)
|
||||
{
|
||||
// 1 parametro : Id
|
||||
int nId ;
|
||||
LuaCheckParam( L, 1, nId)
|
||||
LuaClearStack( L) ;
|
||||
// recupero il numero di parti del solido Zmap
|
||||
int nParts = ExeVolZmapPartCount( nId) ;
|
||||
if ( nParts >= 0)
|
||||
LuaSetParam( L, nParts) ;
|
||||
else
|
||||
LuaSetParam( L) ;
|
||||
return 1 ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
static int
|
||||
LuaVolZmapPartVolume( lua_State* L)
|
||||
{
|
||||
// 2 parametri : Id, nPartInd (0-based)
|
||||
int nId ;
|
||||
LuaCheckParam( L, 1, nId)
|
||||
int nPartInd ;
|
||||
LuaCheckParam( L, 2, nPartInd)
|
||||
LuaClearStack( L) ;
|
||||
// recupero il suo eventuale volume
|
||||
double dVol ;
|
||||
if ( ExeVolZmapPartVolume( nId, nPartInd, dVol))
|
||||
LuaSetParam( L, dVol) ;
|
||||
else
|
||||
LuaSetParam( L) ;
|
||||
return 1 ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
static int
|
||||
LuaTextNormVersor( lua_State* L)
|
||||
{
|
||||
// 1 o 2 parametri : Id [, nRefId]
|
||||
int nId ;
|
||||
LuaCheckParam( L, 1, nId)
|
||||
int nRefId = nId ;
|
||||
LuaGetParam( L, 2, nRefId) ;
|
||||
LuaClearStack( L) ;
|
||||
// recupero il versore
|
||||
Vector3d vtNorm ;
|
||||
if ( ExeTextNormVersor( nId, nRefId, vtNorm))
|
||||
LuaSetParam( L, vtNorm) ;
|
||||
else
|
||||
LuaSetParam( L) ;
|
||||
return 1 ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
static int
|
||||
LuaTextContent( lua_State* L)
|
||||
{
|
||||
// 1 parametro : Id
|
||||
int nId ;
|
||||
LuaCheckParam( L, 1, nId)
|
||||
LuaClearStack( L) ;
|
||||
// recupero il contenuto
|
||||
string sText ;
|
||||
if ( ExeTextGetContent( nId, sText))
|
||||
LuaSetParam( L, sText) ;
|
||||
else
|
||||
LuaSetParam( L) ;
|
||||
return 1 ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
static int
|
||||
LuaTextFont( lua_State* L)
|
||||
{
|
||||
// 1 parametro : Id
|
||||
int nId ;
|
||||
LuaCheckParam( L, 1, nId)
|
||||
LuaClearStack( L) ;
|
||||
// recupero il font
|
||||
string sFont ;
|
||||
if ( ExeTextGetFont( nId, sFont))
|
||||
LuaSetParam( L, sFont) ;
|
||||
else
|
||||
LuaSetParam( L) ;
|
||||
return 1 ;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------
|
||||
bool
|
||||
LuaInstallGeoSnap( LuaMgr& luaMgr)
|
||||
@@ -1126,45 +318,5 @@ LuaInstallGeoSnap( LuaMgr& luaMgr)
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtUV", LuaAtParamVector) ;
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtFR", LuaFrame) ;
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtET", LuaExtrusionByThickness) ;
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtCurveDomain", LuaCurveDomain) ;
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtCurveLength", LuaCurveLength) ;
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtCurveIsClosed", LuaCurveIsClosed) ;
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtCurveIsFlat", LuaCurveIsFlat) ;
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtCurveAreaXY", LuaCurveAreaXY) ;
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtCurveArea", LuaCurveArea) ;
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtCurveExtrusion", LuaCurveExtrusion) ;
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtCurveThickness", LuaCurveThickness) ;
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtCurveSelfIntersCount", LuaCurveSelfIntersCount) ;
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtCurveMinAreaRectangleXY", LuaCurveMinAreaRectangleXY) ;
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtCurveWithRegionClassify", LuaCurveWithRegionClassify) ;
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtArcRadius", LuaArcRadius) ;
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtArcAngCenter", LuaArcAngCenter) ;
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtArcDeltaN", LuaArcDeltaN) ;
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtArcNormVersor", LuaArcNormVersor) ;
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtCurveCompoCenter", LuaCurveCompoCenter) ;
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtCurveCompoRadius", LuaCurveCompoRadius) ;
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtSurfArea", LuaSurfArea) ;
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtSurfVolume", LuaSurfVolume) ;
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtSurfFrNormVersor", LuaSurfFrNormVersor) ;
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtSurfFrGrossArea", LuaSurfFrGrossArea) ;
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtSurfFrChunkCount", LuaSurfFrChunkCount) ;
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtSurfFrChunkSimpleClassify", LuaSurfFrChunkSimpleClassify) ;
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtSurfFrTestExternal", LuaSurfFrTestExternal) ;
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtSurfTmFacetCount", LuaSurfTmFacetCount) ;
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtSurfTmFacetFromTria", LuaSurfTmFacetFromTria) ;
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtSurfTmFacetAdjacencies", LuaSurfTmFacetAdjacencies) ;
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtSurfTmFacetNearestEndPoint", LuaSurfTmFacetNearestEndPoint) ;
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtSurfTmFacetNearestMidPoint", LuaSurfTmFacetNearestMidPoint) ;
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtSurfTmFacetCenter", LuaSurfTmFacetCenter) ;
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtSurfTmFacetNormVersor", LuaSurfTmFacetNormVersor) ;
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtSurfTmFacetMinAreaRectangle", LuaSurfTmFacetMinAreaRectangle) ;
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtSurfTmFacetOppositeSide", LuaSurfTmFacetOppositeSide) ;
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtSurfTmFacetsContact", LuaSurfTmFacetsContact) ;
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtVolZmapVolume", LuaVolZmapVolume) ;
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtVolZmapPartCount", LuaVolZmapPartCount) ;
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtVolZmapPartVolume", LuaVolZmapPartVolume) ;
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtTextNormVersor", LuaTextNormVersor) ;
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtTextContent", LuaTextContent) ;
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtTextFont", LuaTextFont) ;
|
||||
return bOk ;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user