Fix Operazioni booleane e taglio trimesh con un piano

This commit is contained in:
LorenzoM
2021-04-21 17:52:35 +02:00
parent f989b402fd
commit 0b37e12df9
6 changed files with 2777 additions and 97 deletions
+63
View File
@@ -18,6 +18,7 @@
#include "CurveComposite.h"
#include "SurfFlatRegion.h"
#include "GeoConst.h"
#include "/EgtDev/Include/EgkPolyLine.h"
#include "/EgtDev/Include/EgkBiArcs.h"
#include "/EgtDev/Include/EgkOffsetCurve.h"
#include "/EgtDev/Include/EGkSfrCreate.h"
@@ -275,6 +276,68 @@ GetSurfFlatRegionFromFatCurve( ICurve* pCrv, double dRadius, bool bSquareEnds, b
}
}
//----------------------------------------------------------------------------
ISurfFlatRegion*
GetSurfFlatRegionFromPolyLine( const PolyLine& ContourPolyLine)
{
// Creo la regione.
PtrOwner<SurfFlatRegion> pSfr( CreateBasicSurfFlatRegion()) ;
if ( IsNull( pSfr))
return nullptr ;
// Creo curva composita.
PtrOwner<CurveComposite> pLoop( CreateBasicCurveComposite()) ;
if ( IsNull( pLoop))
return nullptr ;
Point3d ptSt, ptEn ;
bool bContinue = ContourPolyLine.GetFirstPoint( ptSt) &&
ContourPolyLine.GetNextPoint( ptEn) ;
while ( bContinue) {
CurveLine cvLine ;
cvLine.Set( ptSt, ptEn) ;
pLoop->AddCurve( cvLine) ;
ptSt = ptEn ;
bContinue = ContourPolyLine.GetNextPoint( ptEn) ;
}
pSfr->AddExtLoop( Release( pLoop)) ;
return Release( pSfr) ;
}
//----------------------------------------------------------------------------
ISurfFlatRegion*
GetSurfFlatRegionFromPolyLineVector( const POLYLINEVECTOR& vContoursPolyLineVec)
{
// Creo la regione.
PtrOwner<SurfFlatRegion> pSfr( CreateBasicSurfFlatRegion()) ;
if ( IsNull( pSfr))
return nullptr ;
// Ciclo sulle PolyLine.
for ( int nL = 0 ; nL < int( vContoursPolyLineVec.size()) ; ++ nL) {
// Creo curva composita.
PtrOwner<CurveComposite> pLoop( CreateBasicCurveComposite()) ;
if ( IsNull( pLoop))
return nullptr ;
Point3d ptSt, ptEn ;
bool bContinue = vContoursPolyLineVec[nL].GetFirstPoint( ptSt) &&
vContoursPolyLineVec[nL].GetNextPoint( ptEn) ;
while ( bContinue) {
CurveLine cvLine ;
cvLine.Set( ptSt, ptEn) ;
pLoop->AddCurve( cvLine) ;
ptSt = ptEn ;
bContinue = vContoursPolyLineVec[nL].GetNextPoint( ptEn) ;
}
// Loop esterno
if ( nL == 0) {
pSfr->AddExtLoop( Release( pLoop)) ;
}
// Loop interno
else {
pSfr->AddIntLoop( Release( pLoop)) ;
}
}
return Release( pSfr) ;
}
//-------------------------------------------------------------------------------
// Classe SurfFlatRegionByContours
//-------------------------------------------------------------------------------