EgtExecutor 2.2d2 :
- aggiustamenti vari per IsFlat, FromPlaneTrimmedWithBox e GetSurfTriMeshPlaneInBox - aggiunta funzione Exe e Lua TrimFlatCurveWithBox.
This commit is contained in:
@@ -354,7 +354,7 @@ MyCreateSurfTmPlaneInBBox( int nParentId, const Point3d& ptP, const Vector3d& vt
|
||||
// costruisco il piano nel box
|
||||
Plane3d plPlane ;
|
||||
plPlane.Set( ptP, vtN) ;
|
||||
PtrOwner<ISurfTriMesh> pStm( GetSurfTriMeshPlaneInBox( plPlane, b3Box)) ;
|
||||
PtrOwner<ISurfTriMesh> pStm( GetSurfTriMeshPlaneInBox( plPlane, b3Box, true, false)) ;
|
||||
if ( IsNull( pStm))
|
||||
return GDB_ID_NULL ;
|
||||
// recupero il riferimento locale del gruppo destinazione
|
||||
@@ -534,12 +534,12 @@ MyCreateSurfTmConvexHullInBBox( int nParentId, int nId, const BBox3d& b3Box, int
|
||||
return MyCreateSurfTmPlaneInBBox( nParentId, vTria[nPlane1].GetP( 0), vTria[nPlane1].GetN(), b3Box, nRefType) ;
|
||||
// altrimenti due piani validi
|
||||
Polygon3d Polyg1 ;
|
||||
if ( ! Polyg1.FromPlaneTrimmedWithBox( vTria[nPlane1].GetPlane(), b3Box.GetMin(), b3Box.GetMax()))
|
||||
if ( ! Polyg1.FromPlaneTrimmedWithBox( vTria[nPlane1].GetPlane(), b3Box.GetMin(), b3Box.GetMax(), true, false))
|
||||
return GDB_ID_NULL ;
|
||||
Polygon3d Polyg2 ;
|
||||
if ( ! Polyg2.FromPlaneTrimmedWithBox( vTria[nPlane2].GetPlane(), b3Box.GetMin(), b3Box.GetMax()))
|
||||
if ( ! Polyg2.FromPlaneTrimmedWithBox( vTria[nPlane2].GetPlane(), b3Box.GetMin(), b3Box.GetMax(), true, false))
|
||||
return GDB_ID_NULL ;
|
||||
if ( ! Polyg1.Trim( Polyg2, true, true) || ! Polyg2.Trim( Polyg1, true, false))
|
||||
if ( ! Polyg1.Trim( Polyg2, true, true, false) || ! Polyg2.Trim( Polyg1, true, false, false))
|
||||
return GDB_ID_NULL ;
|
||||
// creo la trimesh dalle due facce
|
||||
PtrOwner<ISurfTriMesh> pChStm( CreateSurfTriMesh()) ;
|
||||
|
||||
+2
-2
@@ -114,7 +114,7 @@ ExeCurveIsClosed( int nId)
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
ExeCurveIsFlat( int nId, Plane3d& Plane, double dToler)
|
||||
ExeCurveIsFlat( int nId, Plane3d& Plane, bool bUseExtrusion, double dToler)
|
||||
{
|
||||
IGeomDB* pGeomDB = GetCurrGeomDB() ;
|
||||
VERIFY_GEOMDB( pGeomDB, false)
|
||||
@@ -124,7 +124,7 @@ ExeCurveIsFlat( int nId, Plane3d& Plane, double dToler)
|
||||
// recupero la curva
|
||||
ICurve* pCurve = GetCurve( pGeomDB->GetGeoObj( nId)) ;
|
||||
// ne verifico la planarità
|
||||
return ( pCurve != nullptr && pCurve->IsFlat( Plane, dToler)) ;
|
||||
return ( pCurve != nullptr && pCurve->IsFlat( Plane, bUseExtrusion, dToler)) ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
@@ -35,6 +35,7 @@
|
||||
#include "/EgtDev/Include/EGkGdbIterator.h"
|
||||
#include "/EgtDev/Include/EGkStringUtils3d.h"
|
||||
#include "/EgtDev/Include/EGkIntervals.h"
|
||||
#include "/EgtDev/Include/EGkPolygon3d.h"
|
||||
#include "/EgtDev/Include/EgtPointerOwner.h"
|
||||
#include <functional>
|
||||
|
||||
@@ -801,6 +802,115 @@ ExeTrimCurveWithRegion( int nCrvId, int nRegId, bool bInVsOut, bool bOn, int* pn
|
||||
return nFirstId ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
static int
|
||||
MyTrimFlatCurveWithBox( int nCrvId, const Frame3d& frBox, const Vector3d& vtDiag, bool bInVsOut, bool bOn, int nRefType, int& nCount)
|
||||
{
|
||||
IGeomDB* pGeomDB = GetCurrGeomDB() ;
|
||||
VERIFY_GEOMDB( pGeomDB, GDB_ID_NULL)
|
||||
// recupero la curva
|
||||
ICurve* pCrv = GetCurve( pGeomDB->GetGeoObj( nCrvId)) ;
|
||||
if ( pCrv == nullptr)
|
||||
return GDB_ID_NULL ;
|
||||
// recupero il riferimento della curva
|
||||
Frame3d frCrv ;
|
||||
if ( ! pGeomDB->GetGlobFrame( nCrvId, frCrv))
|
||||
return GDB_ID_NULL ;
|
||||
// determino il piano della curva (annullo temporaneamente l'estrusione per non avere problemi)
|
||||
Plane3d plPlane ;
|
||||
if ( ! pCrv->IsFlat( plPlane, false, 10 * EPS_SMALL))
|
||||
return GDB_ID_NULL ;
|
||||
// porto in locale alla curva il riferimento del box (il vettore è già in locale a questo stesso riferimento)
|
||||
Frame3d frBoxL = GetFrameLocal( pGeomDB, frBox, nRefType, frCrv) ;
|
||||
// determino la parte di piano (poligono) compresa nel box (applicando le opportune trasformazioni di riferimento)
|
||||
plPlane.ToLoc( frBoxL) ;
|
||||
Polygon3d Polyg ;
|
||||
if ( ! Polyg.FromPlaneTrimmedWithBox( plPlane, ORIG, ORIG + vtDiag, bOn, bOn))
|
||||
return GDB_ID_NULL ;
|
||||
Polyg.ToGlob( frBoxL) ;
|
||||
// se poligono vuoto, la curva non interseca il box
|
||||
if ( Polyg.GetSideCount() == 0) {
|
||||
if ( bInVsOut) {
|
||||
pGeomDB->Erase( nCrvId) ;
|
||||
nCount = 0 ;
|
||||
}
|
||||
else
|
||||
nCount = 1 ;
|
||||
return nCrvId ;
|
||||
}
|
||||
// creo la regione corrispondente
|
||||
PtrOwner<ICurveComposite> pContour( CreateCurveComposite()) ;
|
||||
if ( IsNull( pContour) || ! pContour->FromPolyLine( Polyg.GetPolyLine()))
|
||||
return false ;
|
||||
PtrOwner<ISurfFlatRegion> pSfr( CreateSurfFlatRegion()) ;
|
||||
if ( IsNull( pSfr) || ! pSfr->AddExtLoop( Release( pContour)))
|
||||
return false ;
|
||||
// calcolo la classificazione della curva rispetto alla regione
|
||||
CRVCVECTOR ccClass ;
|
||||
if ( ! pSfr->GetCurveClassification( *pCrv, ccClass))
|
||||
return GDB_ID_NULL ;
|
||||
// determino gli intervalli di curva da conservare
|
||||
Intervals inOk ;
|
||||
for ( auto& ccOne : ccClass) {
|
||||
if ( ( bInVsOut && ccOne.nClass == CRVC_IN) ||
|
||||
( ! bInVsOut && ccOne.nClass == CRVC_OUT) ||
|
||||
( bOn && ( ccOne.nClass == CRVC_ON_P || ccOne.nClass == CRVC_ON_M)))
|
||||
inOk.Add( ccOne.dParS, ccOne.dParE) ;
|
||||
}
|
||||
// recupero un intervallo di id contigui per tutte le parti
|
||||
int nFirstId = pGeomDB->GetNewId() ;
|
||||
if ( ! pGeomDB->ChangeId( nCrvId, nFirstId))
|
||||
return GDB_ID_NULL ;
|
||||
int nCurrId = nFirstId ;
|
||||
// eseguo la divisione
|
||||
nCount = 0 ;
|
||||
double dParS, dParE ;
|
||||
bool bFound = inOk.GetFirst( dParS, dParE) ;
|
||||
while ( bFound) {
|
||||
// copio la curva
|
||||
int nCopyId = pGeomDB->Copy( nCurrId, GDB_ID_NULL, nCurrId, GDB_AFTER) ;
|
||||
ICurve* pCopyCrv = GetCurve( pGeomDB->GetGeoObj( nCopyId)) ;
|
||||
if ( pCopyCrv == nullptr)
|
||||
return GDB_ID_NULL ;
|
||||
++ nCount ;
|
||||
// modifico l'originale
|
||||
if ( ! pCrv->TrimStartEndAtParam( dParS, dParE))
|
||||
return GDB_ID_NULL ;
|
||||
// la copia diventa il nuovo corrente
|
||||
nCurrId = nCopyId ;
|
||||
pCrv = pCopyCrv ;
|
||||
// passo alla successiva divisione
|
||||
bFound = inOk.GetNext( dParS, dParE) ;
|
||||
}
|
||||
// cancello l'ultima copia (se non c'erano intervalli validi è l'originale)
|
||||
pGeomDB->Erase( nCurrId) ;
|
||||
return nFirstId ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
int
|
||||
ExeTrimFlatCurveWithBox( int nCrvId, const Frame3d& frBox, const Vector3d& vtDiag, bool bInVsOut, bool bOn, int nRefType, int* pnCount)
|
||||
{
|
||||
int nCount ;
|
||||
int nFirstId = MyTrimFlatCurveWithBox( nCrvId, frBox, vtDiag, bInVsOut, bOn, nRefType, nCount) ;
|
||||
ExeSetModified() ;
|
||||
// se richiesto, salvo il comando Lua equivalente
|
||||
if ( IsCmdLog()) {
|
||||
string sLua = "EgtTrimFlatCurveWithBox(" + ToString( nCrvId) + "," +
|
||||
ToString( frBox) + "," +
|
||||
ToString( vtDiag) + "," +
|
||||
ToString( bInVsOut) + "," +
|
||||
ToString( bOn) + "," +
|
||||
RefTypeToString( nRefType) + ")" +
|
||||
" -- Id1=" + ToString( nFirstId) + ",Nbr=" + ToString( nCount) ;
|
||||
LOG_INFO( GetCmdLogger(), sLua.c_str()) ;
|
||||
}
|
||||
// restituisco risultati
|
||||
if ( pnCount != nullptr)
|
||||
*pnCount = nCount ;
|
||||
return nFirstId ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
int
|
||||
ExeSplitCurve( int nId, int nParts)
|
||||
|
||||
Binary file not shown.
+1
-1
@@ -83,7 +83,7 @@ LuaCurveIsFlat( lua_State* L)
|
||||
LuaClearStack( L) ;
|
||||
// verifico se curva piatta e restituisco il piano medio
|
||||
Plane3d Plane ;
|
||||
bool bFlat = ExeCurveIsFlat( nId, Plane, dToler) ;
|
||||
bool bFlat = ExeCurveIsFlat( nId, Plane, false, dToler) ;
|
||||
LuaSetParam( L, bFlat) ;
|
||||
LuaSetParam( L, Plane.GetVersN()) ;
|
||||
LuaSetParam( L, Plane.GetDist()) ;
|
||||
|
||||
+31
-1
@@ -363,7 +363,7 @@ LuaTrimExtendCurveByLen( lua_State* L)
|
||||
static int
|
||||
LuaTrimCurveWithRegion( lua_State* L)
|
||||
{
|
||||
// 4 parametro : nCrvId, nRegId, bInVsOut, bOn
|
||||
// 4 parametri : nCrvId, nRegId, bInVsOut, bOn
|
||||
int nCrvId ;
|
||||
LuaCheckParam( L, 1, nCrvId)
|
||||
int nRegId ;
|
||||
@@ -384,6 +384,35 @@ LuaTrimCurveWithRegion( lua_State* L)
|
||||
return 2 ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
static int
|
||||
LuaTrimFlatCurveWithBox( lua_State* L)
|
||||
{
|
||||
// 5 o 6 parametri : nCrvId, frBox, vtDiag, bInVsOut, bOn [, nRefType]
|
||||
int nCrvId ;
|
||||
LuaCheckParam( L, 1, nCrvId)
|
||||
Frame3d frBox ;
|
||||
LuaCheckParam( L, 2, frBox)
|
||||
Vector3d vtDiag ;
|
||||
LuaCheckParam( L, 3, vtDiag)
|
||||
bool bInVsOut ;
|
||||
LuaCheckParam( L, 4, bInVsOut)
|
||||
bool bOn ;
|
||||
LuaCheckParam( L, 5, bOn)
|
||||
int nRefType = RTY_DEFAULT ;
|
||||
LuaGetParam( L, 6, nRefType) ;
|
||||
LuaClearStack( L) ;
|
||||
// conservo le parti di curva desiderate
|
||||
int nCount ;
|
||||
int nNewId = ExeTrimFlatCurveWithBox( nCrvId, frBox, vtDiag, bInVsOut, bOn, nRefType, &nCount) ;
|
||||
if ( nNewId != GDB_ID_NULL)
|
||||
LuaSetParam( L, nNewId) ;
|
||||
else
|
||||
LuaSetParam( L) ;
|
||||
LuaSetParam( L, nCount) ;
|
||||
return 2 ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
static int
|
||||
LuaSplitCurve( lua_State* L)
|
||||
@@ -799,6 +828,7 @@ LuaInstallGdbModifyCurve( LuaMgr& luaMgr)
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtExtendCurveEndByLen", LuaExtendCurveEndByLen) ;
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtTrimExtendCurveByLen", LuaTrimExtendCurveByLen) ;
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtTrimCurveWithRegion", LuaTrimCurveWithRegion) ;
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtTrimFlatCurveWithBox", LuaTrimFlatCurveWithBox) ;
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtSplitCurve", LuaSplitCurve) ;
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtSplitCurveAtPoint", LuaSplitCurveAtPoint) ;
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtSplitCurveAtParam", LuaSplitCurveAtParam) ;
|
||||
|
||||
Reference in New Issue
Block a user