EgtExecutor :
- aggiunta del cap alla funzione Bez by extrusion.
This commit is contained in:
+73
-2
@@ -2025,7 +2025,7 @@ ExeCreateSurfBzByRegion( int nParentId, const INTVECTOR& vCrvIds, double dLinTol
|
||||
|
||||
//-------------------------------------------------------------------------------
|
||||
int
|
||||
ExeCreateSurfBzByExtrusion( int nParentId, const INTVECTOR& vCrvIds, const Vector3d& vtExtr,
|
||||
ExeCreateSurfBzByExtrusion( int nParentId, const INTVECTOR& vCrvIds, const Vector3d& vtExtr, bool bCapEnds,
|
||||
double dLinTol, int nRefType)
|
||||
{
|
||||
IGeomDB* pGeomDB = GetCurrGeomDB() ;
|
||||
@@ -2038,7 +2038,7 @@ ExeCreateSurfBzByExtrusion( int nParentId, const INTVECTOR& vCrvIds, const Vecto
|
||||
// recupero le curve in locale
|
||||
CURVELOCALVECTOR vCrvLoc ;
|
||||
vCrvLoc.reserve( vCrvIds.size()) ;
|
||||
ICURVEPVECTOR vCrvP ;
|
||||
CICURVEPVECTOR vCrvP ;
|
||||
vCrvP.reserve( vCrvIds.size()) ;
|
||||
for ( size_t i = 0 ; i < vCrvIds.size() ; ++ i) {
|
||||
int nId = (( vCrvIds[i] != GDB_ID_SEL) ? vCrvIds[i] : pGeomDB->GetFirstSelectedObj()) ;
|
||||
@@ -2063,6 +2063,47 @@ ExeCreateSurfBzByExtrusion( int nParentId, const INTVECTOR& vCrvIds, const Vecto
|
||||
if ( bOk && nFirstId == GDB_ID_NULL)
|
||||
nFirstId = nNewId ;
|
||||
}
|
||||
// se richiesta chiusura agli estremi
|
||||
if ( bCapEnds) {
|
||||
// verifico che la curva sia chiusa e piatta
|
||||
Plane3d plPlane ;
|
||||
double dArea ;
|
||||
PolyLine plApprox ;
|
||||
double dAndTolDeg = 5 ;
|
||||
vCrvP[0]->ApproxWithLines( dLinTol, dAndTolDeg, ICurve::APL_STD, plApprox) ;
|
||||
if ( plApprox.IsClosedAndFlat( plPlane, dArea, 50 * EPS_SMALL)) {
|
||||
// componente dell'estrusione perpendicolare al piano della curva
|
||||
double dOrthoExtr = plPlane.GetVersN() * vtExtr ;
|
||||
if ( ( abs( dOrthoExtr) > EPS_SMALL)) {
|
||||
if( vCrvIds.size() == 1) {
|
||||
PtrOwner<ISurfBezier> pSrfBzTop( CreateSurfBezier()) ;
|
||||
pSrfBzTop->CreateByFlatContour( plApprox) ;
|
||||
pSrfBzTop->Translate( vtExtrL) ;
|
||||
pGeomDB->AddGeoObj( GDB_ID_NULL, nParentId, Release( pSrfBzTop)) ;
|
||||
PtrOwner<ISurfBezier> pSrfBzBottom( CreateSurfBezier()) ;
|
||||
pSrfBzBottom->CreateByFlatContour( plApprox) ;
|
||||
pSrfBzBottom->Invert() ;
|
||||
pGeomDB->AddGeoObj( GDB_ID_NULL, nParentId, Release( pSrfBzBottom)) ;
|
||||
}
|
||||
else {
|
||||
// riordino le curve in modo che la prima sia quella esterna e tutte le altre dopo
|
||||
POLYLINEVECTOR vPL ;
|
||||
Vector3d vtN ;
|
||||
if ( ! CalcRegionPolyLines( vCrvP, dLinTol, vPL, vtN))
|
||||
return nFirstId ;
|
||||
PtrOwner<ISurfBezier> pSrfBzTop( CreateSurfBezier()) ;
|
||||
pSrfBzTop->CreateByRegion( vPL) ;
|
||||
pSrfBzTop->Translate( vtExtrL) ;
|
||||
pGeomDB->AddGeoObj( GDB_ID_NULL, nParentId, Release( pSrfBzTop)) ;
|
||||
PtrOwner<ISurfBezier> pSrfBzBottom( CreateSurfBezier()) ;
|
||||
pSrfBzBottom->CreateByRegion( vPL) ;
|
||||
pSrfBzBottom->Invert() ;
|
||||
pGeomDB->AddGeoObj( GDB_ID_NULL, nParentId, Release( pSrfBzBottom)) ;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ExeSetModified() ;
|
||||
// se richiesto, salvo il comando Lua equivalente
|
||||
if ( IsCmdLog()) {
|
||||
@@ -2141,6 +2182,36 @@ ExeCreateSurfBzByRevolve( int nParentId, int nCrvId,
|
||||
Vector3d vtAxL = GetVectorLocal( pGeomDB, vtAx, nRefType, frLoc) ;
|
||||
// calcolo la superficie
|
||||
ISurfBezier* pSbz = ( bOk ? GetSurfBezierByRevolve( CrvLoc, ptAxL, vtAxL, bCapEnds, dLinTol) : nullptr) ;
|
||||
//// finché non ho le SurfCompo creo qui i cap
|
||||
//if ( bCapEnds) {
|
||||
// // calcola la bbox della superficie
|
||||
// BBox3d bbox3dSurf ;
|
||||
// int nDegU, nDegV, nSpanU, nSpanV ;
|
||||
// bool bTrim, bRat ;
|
||||
// pSbz->GetInfo( nDegU, nDegV, nSpanU, nSpanV, bTrim, bRat) ;
|
||||
// int nPointCount = ( nDegU * nSpanU + 1) * ( nDegV * nSpanV + 1) ;
|
||||
// for ( int p = 0 ; p < nPointCount ; ++p) {
|
||||
// bool bPointOk = true ;
|
||||
// Point3d ptCtrl = pSbz->GetControlPoint( p, &bPointOk) ;
|
||||
// bbox3dSurf.Add( ptCtrl) ;
|
||||
// }
|
||||
// // recupero i loop
|
||||
// ICRVCOMPOPOVECTOR vCCLoop ;
|
||||
// pSbz->GetLoops( vCCLoop, true) ;
|
||||
// // devo distinguere tra il loop superiore e quello inferiore
|
||||
// double dAngTolDeg = 5 ;
|
||||
// PolyLine plEdge ; vCCLoop[0]->ApproxWithLines( dLinTol, dAngTolDeg, ICurve::APL_STD, plEdge) ;
|
||||
// Plane3d plPlane ; double dArea ;
|
||||
// bOk = bOk && ! plEdge.IsClosedAndFlat( plPlane, dArea, 50 * EPS_SMALL) ;
|
||||
// Vector3d vtN = plPlane.GetVersN() ;
|
||||
// // vedo come questa normale è orientata rispetto alla bbox della superficie
|
||||
// Point3d ptCen ; vCCLoop[0]->GetCentroid( ptCen) ;
|
||||
// double dDist = bbox3dSurf.DistFromPoint( ptCen) ; // questa mi dà anche valori negativi????? sennò è inutile
|
||||
|
||||
// PtrOwner<ISurfBezier> pSrfBzTop( CreateSurfBezier()) ;
|
||||
// pSrfBzTop->CreateByFlatContour( )
|
||||
//}
|
||||
|
||||
// inserisco la superficie nel DB
|
||||
int nNewId = ( bOk ? pGeomDB->AddGeoObj( GDB_ID_NULL, nParentId, pSbz) : GDB_ID_NULL) ;
|
||||
ExeSetModified() ;
|
||||
|
||||
Reference in New Issue
Block a user