Merge branch 'master' into FasterVMill5Axis
This commit is contained in:
+32
-667
@@ -95,56 +95,17 @@ ISurfBezier*
|
||||
GetSurfBezierByExtrusion( const ICurve* pCurve, const Vector3d& vtExtr,
|
||||
bool bCapEnds, double dLinTol)
|
||||
{
|
||||
// verifica parametri
|
||||
// verifica parametri
|
||||
if ( pCurve == nullptr || &vtExtr == nullptr)
|
||||
return nullptr ;
|
||||
// calcolo la polilinea che approssima la curva
|
||||
PolyLine PL ;
|
||||
if ( ! pCurve->ApproxWithLines( dLinTol, ANG_TOL_STD_DEG, ICurve::APL_SPECIAL, PL))
|
||||
return nullptr ;
|
||||
//// se richiesta chiusura agli estremi
|
||||
//bool bDoCapEnds = false ;
|
||||
//if ( bCapEnds) {
|
||||
// // verifico che la curva sia chiusa e piatta
|
||||
// Plane3d plPlane ;
|
||||
// double dArea ;
|
||||
// if ( PL.IsClosedAndFlat( plPlane, dArea, 50 * EPS_SMALL)) {
|
||||
// // componente dell'estrusione perpendicolare al piano della curva
|
||||
// double dOrthoExtr = plPlane.GetVersN() * vtExtr ;
|
||||
// if ( ( abs( dOrthoExtr) > EPS_SMALL)) {
|
||||
// bDoCapEnds = true ;
|
||||
// // se negativa, inverto il senso del contorno
|
||||
// if ( dOrthoExtr < 0)
|
||||
// PL.Invert() ;
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
|
||||
PtrOwner<const ICurve> pBezierForm( CurveToBezierCurve( pCurve)) ;
|
||||
// creo e setto la superficie trimesh
|
||||
// creo e setto la superficie di Bezier
|
||||
PtrOwner<SurfBezier> pSbz( CreateBasicSurfBezier()) ;
|
||||
if ( IsNull( pSbz) || ! pSbz->CreateByExtrusion( pBezierForm, vtExtr))
|
||||
return nullptr ;
|
||||
|
||||
//// se da fare, metto i tappi sulle estremità
|
||||
//if ( bDoCapEnds) {
|
||||
// // creo la prima superficie di estremità
|
||||
// SurfTriMesh STM1 ;
|
||||
// if ( ! STM1.CreateByFlatContour( PL))
|
||||
// return nullptr ;
|
||||
// // la copio
|
||||
// SurfTriMesh STM2 = STM1 ;
|
||||
// // inverto la prima superficie
|
||||
// STM1.Invert() ;
|
||||
// // traslo la seconda
|
||||
// STM2.Translate( vtExtr) ;
|
||||
|
||||
// ////// SurfCompo?
|
||||
// //// le unisco alla superficie del fianco
|
||||
// //if ( ! pSbz->DoSewing( STM1) || ! pSTM->DoSewing( STM2))
|
||||
// // return nullptr ;
|
||||
//}
|
||||
// restituisco la superficie
|
||||
// restituisco la superficie
|
||||
return Release( pSbz) ;
|
||||
}
|
||||
|
||||
@@ -201,45 +162,6 @@ GetSurfBezierByRevolve( const ICurve* pCurve, const Point3d& ptAx, const Vector3
|
||||
return nullptr ;
|
||||
// limite minimo su tolleranza
|
||||
dLinTol = max( dLinTol, EPS_SMALL) ;
|
||||
//// calcolo la polilinea che approssima la curva
|
||||
//PolyLine PL ;
|
||||
//if ( ! pCurve->ApproxWithLines( dLinTol, ANG_TOL_STD_DEG, ICurve::APL_SPECIAL, PL))
|
||||
// return nullptr ;
|
||||
|
||||
//// se richiesta chiusura degli estremi
|
||||
//if ( bCapEnds && ! PL.IsClosed()) { // serve la SURFCOMPO
|
||||
// Vector3d vtAxN = vtAx ;
|
||||
// vtAxN.Normalize() ;
|
||||
// double dPosIni = 0, dPosFin = 0 ;
|
||||
// Point3d ptP ;
|
||||
// // proietto l'ultimo punto sull'asse di rotazione
|
||||
// if ( PL.GetLastPoint( ptP)) {
|
||||
// dPosFin = ( ptP - ptAx) * vtAxN ;
|
||||
// Point3d ptPOnAx = ptAx + dPosFin * vtAxN ;
|
||||
// // se non giace sull'asse, aggiungo il punto proiettato
|
||||
// if ( ! AreSamePointApprox( ptP, ptPOnAx)) {
|
||||
// double dU ;
|
||||
// PL.GetLastU( dU) ;
|
||||
// PL.AddUPoint( ( dU + 1), ptPOnAx) ;
|
||||
// }
|
||||
// }
|
||||
// // inverto la polilinea
|
||||
// PL.Invert() ;
|
||||
// // proietto l'ultimo punto (era il primo) sull'asse di rotazione
|
||||
// if ( PL.GetLastPoint( ptP)) {
|
||||
// dPosIni = ( ptP - ptAx) * vtAxN ;
|
||||
// Point3d ptPOnAx = ptAx + dPosIni * vtAxN ;
|
||||
// // se non giace sull'asse, aggiungo il punto proiettato
|
||||
// if ( ! AreSamePointApprox( ptP, ptPOnAx)) {
|
||||
// double dU ;
|
||||
// PL.GetLastU( dU) ;
|
||||
// PL.AddUPoint( ( dU + 1), ptPOnAx) ;
|
||||
// }
|
||||
// }
|
||||
// // decido se reinvertire la polilinea
|
||||
// if ( dPosFin > dPosIni)
|
||||
// PL.Invert() ;
|
||||
//}
|
||||
|
||||
// creo e setto la superficie trimesh
|
||||
PtrOwner<SurfBezier> pSbz( CreateBasicSurfBezier()) ;
|
||||
@@ -259,392 +181,31 @@ ISurfBezier*
|
||||
GetSurfBezierByScrewing( const ICurve* pCurve, const Point3d& ptAx, const Vector3d& vtAx,
|
||||
double dAngRotDeg, double dMove, bool bCapEnds, double dLinTol)
|
||||
{
|
||||
// verifica parametri
|
||||
// verifica parametri
|
||||
if ( pCurve == nullptr || &ptAx == nullptr || &vtAx == nullptr)
|
||||
return nullptr ;
|
||||
// limite minimo su tolleranza
|
||||
// limite minimo su tolleranza
|
||||
dLinTol = max( dLinTol, EPS_SMALL) ;
|
||||
// calcolo la polilinea che approssima la curva
|
||||
PolyLine PL ;
|
||||
if ( ! pCurve->ApproxWithLines( dLinTol, ANG_TOL_STD_DEG, ICurve::APL_SPECIAL, PL))
|
||||
return nullptr ;
|
||||
|
||||
// creo e setto la superficie bezier
|
||||
// creo e setto la superficie bezier
|
||||
PtrOwner<SurfBezier> pSbz( CreateBasicSurfBezier()) ;
|
||||
if ( IsNull( pSbz) || ! pSbz->CreateByScrewing( pCurve, ptAx, vtAx, dAngRotDeg, dMove))
|
||||
return nullptr ;
|
||||
//// se richiesti caps /// richiede la SurfCompo
|
||||
//if ( bCapEnds) {
|
||||
// // determino se la sezione è chiusa e piatta
|
||||
// Plane3d plPlane ; double dArea ;
|
||||
// bool bSectClosedFlat = PL.IsClosedAndFlat( plPlane, dArea, 10 * EPS_SMALL) ;
|
||||
// // determino non sia una semplice rivoluzione
|
||||
// bool bRevolved = ( abs( abs( dAngRotDeg) - ANG_FULL) < EPS_ANG_SMALL && abs( dMove) < EPS_SMALL) ;
|
||||
// // se sezione chiusa e piatta e non rivoluzione, posso aggiungere i tappi
|
||||
// if ( bSectClosedFlat && ! bRevolved) {
|
||||
// // aggiungo il cap sull'inizio
|
||||
// PtrOwner<SurfTriMesh> pSci( CreateBasicSurfTriMesh()) ;
|
||||
// if ( IsNull( pSci) || ! pSci->CreateByFlatContour( PL))
|
||||
// return nullptr ;
|
||||
// pSTM->DoSewing( *pSci) ;
|
||||
// // aggiungo il cap sulla fine
|
||||
// Vector3d vtMove = vtAx ;
|
||||
// vtMove.Normalize() ;
|
||||
// vtMove *= dMove ;
|
||||
// PL.Translate( vtMove) ;
|
||||
// PL.Rotate( ptAx, vtAx, dAngRotDeg) ;
|
||||
// PtrOwner<SurfTriMesh> pSce( CreateBasicSurfTriMesh()) ;
|
||||
// if ( IsNull( pSce) || ! pSce->CreateByFlatContour( PL))
|
||||
// return nullptr ;
|
||||
// pSce->Invert() ;
|
||||
// pSTM->DoSewing( *pSce) ;
|
||||
// }
|
||||
//}
|
||||
// se superficie risultante chiusa, verifico che la normale sia verso l'esterno
|
||||
|
||||
// se superficie risultante chiusa, verifico che la normale sia verso l'esterno
|
||||
double dVol ;
|
||||
if ( pSbz->GetVolume( dVol) && dVol < 0)
|
||||
pSbz->Invert() ;
|
||||
|
||||
// restituisco la superficie
|
||||
// restituisco la superficie
|
||||
return Release( pSbz) ;
|
||||
}
|
||||
//
|
||||
////-------------------------------------------------------------------------------
|
||||
//static ISurfBezier*
|
||||
//GetSurfBezierSharpRectSwept( double dDimH, double dDimV, const ICurve* pGuide, int nCapType, double dLinTol) // DA SISTEMARE - ancora copia della versione stm, cambia solo il nome della funzione//////////////////////
|
||||
//{
|
||||
// // verifico che la linea guida sia piana
|
||||
// Plane3d plGuide ;
|
||||
// if ( ! pGuide->IsFlat( plGuide, false, 10 * EPS_SMALL))
|
||||
// return nullptr ;
|
||||
// Vector3d vtNorm = plGuide.GetVersN() ;
|
||||
// // determino se la guida è chiusa
|
||||
// bool bGuideClosed = pGuide->IsClosed() ;
|
||||
// // curve di offset
|
||||
// OffsetCurve OffsCrvR ;
|
||||
// if ( ! OffsCrvR.Make( pGuide, dDimH / 2, ICurve::OFF_FILLET) || OffsCrvR.GetCurveCount() == 0)
|
||||
// return nullptr ;
|
||||
// PtrOwner<ICurve> pCrvR( OffsCrvR.GetLongerCurve()) ;
|
||||
// if ( IsNull( pCrvR))
|
||||
// return nullptr ;
|
||||
// OffsetCurve OffsCrvL ;
|
||||
// if ( ! OffsCrvL.Make( pGuide, -dDimH / 2, ICurve::OFF_FILLET) || OffsCrvL.GetCurveCount() == 0)
|
||||
// return nullptr ;
|
||||
// PtrOwner<ICurve> pCrvL( OffsCrvL.GetLongerCurve()) ;
|
||||
// if ( IsNull( pCrvL))
|
||||
// return nullptr ;
|
||||
// // costruisco le parti di superficie
|
||||
// PtrOwner<ISurfTriMesh> pSrfTop( GetSurfTriMeshRuled( pCrvR, pCrvL, ISurfTriMesh::RLT_MINDIST, dLinTol)) ;
|
||||
// if ( IsNull( pSrfTop))
|
||||
// return nullptr ;
|
||||
// PtrOwner<ISurfTriMesh> pSrfBot( pSrfTop->Clone()) ;
|
||||
// if ( IsNull( pSrfBot))
|
||||
// return nullptr ;
|
||||
// pSrfBot->Translate( -dDimV * vtNorm) ;
|
||||
// pSrfBot->Invert() ;
|
||||
// PtrOwner<ISurfTriMesh> pSrfRgt( GetSurfTriMeshByExtrusion( pCrvR, -dDimV * vtNorm, false, dLinTol)) ;
|
||||
// if ( IsNull( pSrfRgt))
|
||||
// return nullptr ;
|
||||
// pSrfRgt->Invert() ;
|
||||
// PtrOwner<ISurfTriMesh> pSrfLft( GetSurfTriMeshByExtrusion( pCrvL, -dDimV * vtNorm, false, dLinTol)) ;
|
||||
// if ( IsNull( pSrfLft))
|
||||
// return nullptr ;
|
||||
// // unisco le parti
|
||||
// PtrOwner<ISurfTriMesh> pSTM( Release( pSrfTop)) ;
|
||||
// pSTM->DoSewing( *pSrfRgt) ;
|
||||
// pSTM->DoSewing( *pSrfLft) ;
|
||||
// pSTM->DoSewing( *pSrfBot) ;
|
||||
// // salvo tolleranza lineare usata e imposto angolo per smooth
|
||||
// pSTM->SetLinearTolerance( dLinTol) ;
|
||||
// pSTM->SetSmoothAngle( 20) ;
|
||||
// // se guida aperta e tappi piatti
|
||||
// if ( ! bGuideClosed && nCapType == RSCAP_FLAT) {
|
||||
// // verifico che le due estremità siano chiuse e piatte
|
||||
// POLYLINEVECTOR vPL ;
|
||||
// if ( ! pSTM->GetLoops( vPL) || vPL.size() != 2)
|
||||
// return nullptr ;
|
||||
// Plane3d plEnds ; double dArea ;
|
||||
// if ( ! vPL[0].IsClosedAndFlat( plEnds, dArea, 100 * EPS_SMALL))
|
||||
// return nullptr ;
|
||||
// if ( ! vPL[1].IsClosedAndFlat( plEnds, dArea, 100 * EPS_SMALL))
|
||||
// return nullptr ;
|
||||
// // aggiungo il cap sull'inizio
|
||||
// PtrOwner<SurfTriMesh> pSci( CreateBasicSurfTriMesh()) ;
|
||||
// if ( IsNull( pSci) || ! pSci->CreateByFlatContour( vPL[0]))
|
||||
// return nullptr ;
|
||||
// pSci->Invert() ;
|
||||
// pSTM->DoSewing( *pSci) ;
|
||||
// // aggiungo il cap sulla fine
|
||||
// PtrOwner<SurfTriMesh> pSce( CreateBasicSurfTriMesh()) ;
|
||||
// if ( IsNull( pSce) || ! pSce->CreateByFlatContour( vPL[1]))
|
||||
// return nullptr ;
|
||||
// pSce->Invert() ;
|
||||
// pSTM->DoSewing( *pSce) ;
|
||||
// }
|
||||
// // se altrimenti guida aperta e tappi arrotondati
|
||||
// if ( ! bGuideClosed && ( nCapType == RSCAP_ROUND || nCapType == RSCAP_BEVEL)) {
|
||||
// // step di rotazione per rispettare la tolleranza
|
||||
// double dStepRotDeg = ( nCapType == RSCAP_BEVEL ? ANG_STRAIGHT / 4 : sqrt( 8 * dLinTol / dDimH) * RADTODEG) ;
|
||||
// // aggiungo il cap sull'inizio
|
||||
// Point3d ptStart ;
|
||||
// pGuide->GetStartPoint( ptStart) ;
|
||||
// Vector3d vtStart ;
|
||||
// pGuide->GetStartDir( vtStart) ;
|
||||
// vtStart.Rotate( vtNorm, 0, 1) ;
|
||||
// PolyLine PLStart ;
|
||||
// PLStart.AddUPoint( 0, ptStart) ;
|
||||
// PLStart.AddUPoint( 1, ptStart + dDimH / 2 * vtStart) ;
|
||||
// PLStart.AddUPoint( 2, ptStart + dDimH / 2 * vtStart - dDimV * vtNorm) ;
|
||||
// PLStart.AddUPoint( 3, ptStart - dDimV * vtNorm) ;
|
||||
// PtrOwner<SurfTriMesh> pSci( CreateBasicSurfTriMesh()) ;
|
||||
// if ( IsNull( pSci) || ! pSci->CreateByScrewing( PLStart, ptStart, vtNorm, ANG_STRAIGHT, dStepRotDeg, 0))
|
||||
// return nullptr ;
|
||||
// pSci->Invert() ;
|
||||
// pSTM->DoSewing( *pSci) ;
|
||||
// // aggiungo il cap sulla fine
|
||||
// Point3d ptEnd ;
|
||||
// pGuide->GetEndPoint( ptEnd) ;
|
||||
// Vector3d vtEnd ;
|
||||
// pGuide->GetEndDir( vtEnd) ;
|
||||
// vtEnd.Rotate( vtNorm, 0, -1) ;
|
||||
// PolyLine PLEnd ;
|
||||
// PLEnd.AddUPoint( 0, ptEnd) ;
|
||||
// PLEnd.AddUPoint( 1, ptEnd + dDimH / 2 * vtEnd) ;
|
||||
// PLEnd.AddUPoint( 2, ptEnd + dDimH / 2 * vtEnd - dDimV * vtNorm) ;
|
||||
// PLEnd.AddUPoint( 3, ptEnd - dDimV * vtNorm) ;
|
||||
// PtrOwner<SurfTriMesh> pSce( CreateBasicSurfTriMesh()) ;
|
||||
// if ( IsNull( pSce) || ! pSce->CreateByScrewing( PLEnd, ptEnd, vtNorm, ANG_STRAIGHT, dStepRotDeg, 0))
|
||||
// return nullptr ;
|
||||
// pSce->Invert() ;
|
||||
// pSTM->DoSewing( *pSce) ;
|
||||
// }
|
||||
// // restituisco la superficie
|
||||
// return Release( pSTM) ;
|
||||
//}
|
||||
//
|
||||
////-------------------------------------------------------------------------------
|
||||
//static ISurfBezier*
|
||||
//GetSurfBezierBeveledRectSwept( double dDimH, double dDimV, double dBevelH, double dBevelV, const ICurve* pGuide, int nCapType, double dLinTol) // DA SISTEMARE - ancora copia della versione stm, cambia solo il nome della funzione//////////////////////
|
||||
//{
|
||||
// // metodo di calcolo impostato da USE_VORONOI
|
||||
//
|
||||
// // verifico che la linea guida sia piana
|
||||
// Plane3d plGuide ;
|
||||
// if ( ! pGuide->IsFlat( plGuide, false, 10 * EPS_SMALL))
|
||||
// return nullptr ;
|
||||
// // assegno la normale del piano
|
||||
// Vector3d vtNorm = plGuide.GetVersN() ;
|
||||
// // determino il punto centrale della sezione
|
||||
// Point3d ptCen ;
|
||||
// pGuide->GetStartPoint( ptCen) ;
|
||||
// ptCen -= dDimV / 2 * vtNorm ;
|
||||
// // determino se la guida è chiusa
|
||||
// bool bGuideClosed = pGuide->IsClosed() ;
|
||||
// // curve di offset
|
||||
// const int NUM_OFFS = 4 ;
|
||||
// OffsetCurve vOffsCrv[NUM_OFFS] ;
|
||||
// double vDist[NUM_OFFS] = { dDimH / 2 - dBevelH, -dDimH / 2 + dBevelH, dDimH / 2, -dDimH / 2} ;
|
||||
// bool bOk = true ;
|
||||
// if ( ! USE_VORONOI) {
|
||||
// future<bool> vRes[NUM_OFFS] ;
|
||||
// for ( int i = 0 ; i < NUM_OFFS ; ++ i)
|
||||
// vRes[i] = async( launch::async, &OffsetCurve::Make, &vOffsCrv[i], pGuide, vDist[i], ICurve::OFF_FILLET) ;
|
||||
// bool bOk = true ;
|
||||
// int nFin = 0 ;
|
||||
// while ( nFin < NUM_OFFS) {
|
||||
// for ( int i = 0 ; i < NUM_OFFS ; ++ i) {
|
||||
// if ( vRes[i].valid() && vRes[i].wait_for( chrono::nanoseconds{ 1}) == future_status::ready) {
|
||||
// bOk = vRes[i].get() && bOk ;
|
||||
// ++ nFin ;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// else {
|
||||
// // se Voronoi non è possibile calcolare gli offset di una stessa curva in parallelo
|
||||
// for ( int i = 0 ; i < NUM_OFFS && bOk ; ++ i)
|
||||
// bOk = vOffsCrv[i].Make( pGuide, vDist[i], ICurve::OFF_FILLET) ;
|
||||
// }
|
||||
//
|
||||
// if ( ! bOk ||
|
||||
// vOffsCrv[0].GetCurveCount() == 0 || vOffsCrv[1].GetCurveCount() == 0 ||
|
||||
// vOffsCrv[2].GetCurveCount() == 0 || vOffsCrv[3].GetCurveCount() == 0)
|
||||
// return nullptr ;
|
||||
// PtrOwner<ICurve> pCrvR( vOffsCrv[0].GetLongerCurve()) ;
|
||||
// if ( IsNull( pCrvR))
|
||||
// return nullptr ;
|
||||
// PtrOwner<ICurve> pCrvL( vOffsCrv[1].GetLongerCurve()) ;
|
||||
// if ( IsNull( pCrvL))
|
||||
// return nullptr ;
|
||||
// PtrOwner<ICurve> pCrvRb( vOffsCrv[2].GetLongerCurve()) ;
|
||||
// if ( IsNull( pCrvRb))
|
||||
// return nullptr ;
|
||||
// pCrvRb->Translate( - dBevelV * vtNorm) ;
|
||||
// PtrOwner<ICurve> pCrvLb( vOffsCrv[3].GetLongerCurve()) ;
|
||||
// if ( IsNull( pCrvLb))
|
||||
// return nullptr ;
|
||||
// pCrvLb->Translate( - dBevelV * vtNorm) ;
|
||||
// // costruisco le parti di superficie
|
||||
// PtrOwner<ISurfTriMesh> pSrfTop( GetSurfTriMeshRuled( pCrvR, pCrvL, ISurfTriMesh::RLT_MINDIST, dLinTol)) ;
|
||||
// if ( IsNull( pSrfTop))
|
||||
// return nullptr ;
|
||||
// PtrOwner<ISurfTriMesh> pSrfBot( pSrfTop->Clone()) ;
|
||||
// if ( IsNull( pSrfBot))
|
||||
// return nullptr ;
|
||||
// pSrfBot->Translate( -dDimV * vtNorm) ;
|
||||
// pSrfBot->Invert() ;
|
||||
// PtrOwner<ISurfTriMesh> pSrfTopR( GetSurfTriMeshRuled( pCrvRb, pCrvR, ISurfTriMesh::RLT_MINDIST, dLinTol)) ;
|
||||
// if ( IsNull( pSrfTopR))
|
||||
// return nullptr ;
|
||||
// PtrOwner<ISurfTriMesh> pSrfBotR( pSrfTopR->Clone()) ;
|
||||
// if ( IsNull( pSrfBotR))
|
||||
// return nullptr ;
|
||||
// pSrfBotR->Mirror( ptCen, vtNorm) ;
|
||||
// PtrOwner<ISurfTriMesh> pSrfTopL( GetSurfTriMeshRuled( pCrvL, pCrvLb, ISurfTriMesh::RLT_MINDIST, dLinTol)) ;
|
||||
// if ( IsNull( pSrfTopL))
|
||||
// return nullptr ;
|
||||
// PtrOwner<ISurfTriMesh> pSrfBotL( pSrfTopL->Clone()) ;
|
||||
// if ( IsNull( pSrfBotL))
|
||||
// return nullptr ;
|
||||
// pSrfBotL->Mirror( ptCen, vtNorm) ;
|
||||
// PtrOwner<ISurfTriMesh> pSrfRgt( GetSurfTriMeshByExtrusion( pCrvRb, ( -dDimV + 2 * dBevelV) * vtNorm, false, dLinTol)) ;
|
||||
// if ( IsNull( pSrfRgt))
|
||||
// return nullptr ;
|
||||
// pSrfRgt->Invert() ;
|
||||
// PtrOwner<ISurfTriMesh> pSrfLft( GetSurfTriMeshByExtrusion( pCrvLb, ( -dDimV + 2 * dBevelV) * vtNorm, false, dLinTol)) ;
|
||||
// if ( IsNull( pSrfLft))
|
||||
// return nullptr ;
|
||||
// // unisco le parti
|
||||
// int nBuckets = max( 4 * ( pSrfRgt->GetVertexSize() + pSrfLft->GetVertexSize()), 1000) ;
|
||||
// StmFromTriangleSoup stmSoup ;
|
||||
// if ( ! stmSoup.Start( nBuckets))
|
||||
// return nullptr ;
|
||||
// stmSoup.AddSurfTriMesh( *pSrfTop) ;
|
||||
// stmSoup.AddSurfTriMesh( *pSrfTopR) ;
|
||||
// stmSoup.AddSurfTriMesh( *pSrfTopL) ;
|
||||
// stmSoup.AddSurfTriMesh( *pSrfRgt) ;
|
||||
// stmSoup.AddSurfTriMesh( *pSrfLft) ;
|
||||
// stmSoup.AddSurfTriMesh( *pSrfBotR) ;
|
||||
// stmSoup.AddSurfTriMesh( *pSrfBotL) ;
|
||||
// stmSoup.AddSurfTriMesh( *pSrfBot) ;
|
||||
// PtrOwner<ISurfTriMesh> pSTM ;
|
||||
// // se guida aperta e tappi piatti
|
||||
// if ( ! bGuideClosed && nCapType == RSCAP_FLAT) {
|
||||
// // completo unione e recupero la superficie risultante
|
||||
// if ( ! stmSoup.End())
|
||||
// return nullptr ;
|
||||
// pSTM.Set( stmSoup.GetSurf()) ;
|
||||
// // preparo seconda zuppa di triangoli per inserire i tappi
|
||||
// StmFromTriangleSoup stmCapSoup ;
|
||||
// if ( ! stmCapSoup.Start( nBuckets))
|
||||
// return nullptr ;
|
||||
// // verifico che le due estremità siano chiuse e piatte
|
||||
// POLYLINEVECTOR vPL ;
|
||||
// if ( ! pSTM->GetLoops( vPL) || vPL.size() != 2)
|
||||
// return nullptr ;
|
||||
// Plane3d plEnds ; double dArea ;
|
||||
// if ( ! vPL[0].IsClosedAndFlat( plEnds, dArea, 50 * EPS_SMALL))
|
||||
// return nullptr ;
|
||||
// if ( ! vPL[1].IsClosedAndFlat( plEnds, dArea, 50 * EPS_SMALL))
|
||||
// return nullptr ;
|
||||
// // calcolo il cap sull'inizio
|
||||
// PtrOwner<SurfTriMesh> pSci( CreateBasicSurfTriMesh()) ;
|
||||
// if ( IsNull( pSci) || ! pSci->CreateByFlatContour( vPL[0]))
|
||||
// return nullptr ;
|
||||
// pSci->Invert() ;
|
||||
// // calcolo il cap sulla fine
|
||||
// PtrOwner<SurfTriMesh> pSce( CreateBasicSurfTriMesh()) ;
|
||||
// if ( IsNull( pSce) || ! pSce->CreateByFlatContour( vPL[1]))
|
||||
// return nullptr ;
|
||||
// pSce->Invert() ;
|
||||
// // cucio i tappi all'estrusione
|
||||
// if ( ! pSTM->DoSewing( *pSci) || ! pSTM->DoSewing( *pSce))
|
||||
// return nullptr ;
|
||||
// }
|
||||
// // se altrimenti guida aperta e tappi arrotondati
|
||||
// else if ( ! bGuideClosed && ( nCapType == RSCAP_ROUND || nCapType == RSCAP_BEVEL)) {
|
||||
// // step di rotazione per rispettare il tipo o la tolleranza
|
||||
// double dStepRotDeg = ( nCapType == RSCAP_BEVEL ? ANG_STRAIGHT / 4 : sqrt( 8 * dLinTol / dDimH) * RADTODEG) ;
|
||||
// // aggiungo il cap sull'inizio
|
||||
// Point3d ptStart ;
|
||||
// pGuide->GetStartPoint( ptStart) ;
|
||||
// Vector3d vtStart ;
|
||||
// pGuide->GetStartDir( vtStart) ;
|
||||
// vtStart.Rotate( vtNorm, 0, 1) ;
|
||||
// PolyLine PLStart ;
|
||||
// PLStart.AddUPoint( 0, ptStart) ;
|
||||
// PLStart.AddUPoint( 1, ptStart + ( dDimH / 2 - dBevelH) * vtStart) ;
|
||||
// PLStart.AddUPoint( 2, ptStart + dDimH / 2 * vtStart - dBevelV * vtNorm) ;
|
||||
// PLStart.AddUPoint( 3, ptStart + dDimH / 2 * vtStart - ( dDimV - dBevelV) * vtNorm) ;
|
||||
// PLStart.AddUPoint( 4, ptStart + ( dDimH / 2 - dBevelH) * vtStart - dDimV * vtNorm) ;
|
||||
// PLStart.AddUPoint( 5, ptStart - dDimV * vtNorm) ;
|
||||
// PtrOwner<SurfTriMesh> pSci( CreateBasicSurfTriMesh()) ;
|
||||
// if ( IsNull( pSci) || ! pSci->CreateByScrewing( PLStart, ptStart, vtNorm, ANG_STRAIGHT, dStepRotDeg, 0))
|
||||
// return nullptr ;
|
||||
// pSci->Invert() ;
|
||||
// stmSoup.AddSurfTriMesh( *pSci) ;
|
||||
// // aggiungo il cap sulla fine
|
||||
// Point3d ptEnd ;
|
||||
// pGuide->GetEndPoint( ptEnd) ;
|
||||
// Vector3d vtEnd ;
|
||||
// pGuide->GetEndDir( vtEnd) ;
|
||||
// vtEnd.Rotate( vtNorm, 0, -1) ;
|
||||
// PolyLine PLEnd ;
|
||||
// PLEnd.AddUPoint( 0, ptEnd) ;
|
||||
// PLEnd.AddUPoint( 1, ptEnd + ( dDimH / 2 - dBevelH) * vtEnd) ;
|
||||
// PLEnd.AddUPoint( 2, ptEnd + dDimH / 2 * vtEnd - dBevelV * vtNorm) ;
|
||||
// PLEnd.AddUPoint( 3, ptEnd + dDimH / 2 * vtEnd - ( dDimV - dBevelV) * vtNorm) ;
|
||||
// PLEnd.AddUPoint( 4, ptEnd + ( dDimH / 2 - dBevelH) * vtEnd - dDimV * vtNorm) ;
|
||||
// PLEnd.AddUPoint( 5, ptEnd - dDimV * vtNorm) ;
|
||||
// PtrOwner<SurfTriMesh> pSce( CreateBasicSurfTriMesh()) ;
|
||||
// if ( IsNull( pSce) || ! pSce->CreateByScrewing( PLEnd, ptEnd, vtNorm, ANG_STRAIGHT, dStepRotDeg, 0))
|
||||
// return nullptr ;
|
||||
// pSce->Invert() ;
|
||||
// stmSoup.AddSurfTriMesh( *pSce) ;
|
||||
// // completo unione e recupero la superficie risultante
|
||||
// if ( ! stmSoup.End())
|
||||
// return nullptr ;
|
||||
// pSTM.Set( stmSoup.GetSurf()) ;
|
||||
// }
|
||||
// else {
|
||||
// // completo unione e recupero la superficie risultante
|
||||
// if ( ! stmSoup.End())
|
||||
// return nullptr ;
|
||||
// pSTM.Set( stmSoup.GetSurf()) ;
|
||||
// }
|
||||
// // salvo tolleranza lineare usata e imposto angolo per smooth
|
||||
// pSTM->SetLinearTolerance( dLinTol) ;
|
||||
// pSTM->SetSmoothAngle( 20) ;
|
||||
// // restituisco la superficie
|
||||
// return Release( pSTM) ;
|
||||
//}
|
||||
//
|
||||
////-------------------------------------------------------------------------------
|
||||
//ISurfBezier*
|
||||
//GetSurfBezierRectSwept( double dDimH, double dDimV, double dBevelH, double dBevelV, const ICurve* pGuide, int nCapType, double dLinTol) // DA SISTEMARE - ancora copia della versione stm, cambia solo il nome della funzione//////////////////////
|
||||
//{
|
||||
// // verifica parametri
|
||||
// if ( pGuide == nullptr || dBevelH > 0.4 * dDimH || dBevelV > 0.4 * dDimV)
|
||||
// return nullptr ;
|
||||
// // determino se sezione squadrata o con smusso
|
||||
// bool bSharp = ( dBevelH < 100 * EPS_SMALL || dBevelV < 100 * EPS_SMALL) ;
|
||||
// // eseguo
|
||||
// if ( bSharp)
|
||||
// return GetSurfBezierSharpRectSwept( dDimH, dDimV, pGuide, nCapType, dLinTol) ;
|
||||
// else
|
||||
// return GetSurfBezierBeveledRectSwept( dDimH, dDimV, dBevelH, dBevelV, pGuide, nCapType, dLinTol) ;
|
||||
//}
|
||||
|
||||
//-------------------------------------------------------------------------------
|
||||
ISurfBezier*
|
||||
GetSurfBezierSweptInPlane( const ICurve* pSect, const ICurve* pGuide, const Vector3d& vtNorm, bool bCapEnds, double dLinTol)
|
||||
{
|
||||
//// determino se la sezione è chiusa
|
||||
//bool bSectClosed = pSect->IsClosed() ;
|
||||
//// determino se la guida è chiusa
|
||||
//bool bGuideClosed = pGuide->IsClosed() ;
|
||||
|
||||
// riferimento all'inizio della linea guida
|
||||
// riferimento all'inizio della linea guida
|
||||
Frame3d frStart ;
|
||||
Point3d ptStart ;
|
||||
pGuide->GetStartPoint( ptStart) ;
|
||||
@@ -654,7 +215,7 @@ GetSurfBezierSweptInPlane( const ICurve* pSect, const ICurve* pGuide, const Vect
|
||||
|
||||
// capisco se la guida è una linea spezzata o una curva
|
||||
bool bGuideIsPolyLine = false ;
|
||||
switch( pGuide->GetType()) {
|
||||
switch ( pGuide->GetType()) {
|
||||
case CRV_COMPO : {
|
||||
bGuideIsPolyLine = true ;
|
||||
const ICurveComposite* pCC = GetCurveComposite( pGuide) ;
|
||||
@@ -925,14 +486,10 @@ GetSurfBezierSweptInPlane( const ICurve* pSect, const ICurve* pGuide, const Vect
|
||||
ISurfBezier*
|
||||
GetSurfBezierSwept3d( const ICurve* pSect, const ICurve* pGuide, const Vector3d& vtAx, bool bCapEnds, double dLinTol) // DA SISTEMARE - ancora copia della versione stm, cambia solo il nome della funzione//////////////////////
|
||||
{
|
||||
//// determino se la sezione è chiusa
|
||||
//bool bSectClosed = pSect->IsClosed() ;
|
||||
//// determino se la guida è chiusa
|
||||
//bool bGuideClosed = pGuide->IsClosed() ;
|
||||
// determino algoritmo da usare per calcolare i riferimenti lungo la curva
|
||||
// determino algoritmo da usare per calcolare i riferimenti lungo la curva
|
||||
bool bRMF = vtAx.IsSmall() ;
|
||||
|
||||
// riferimento all'inizio della linea guida
|
||||
// riferimento all'inizio della linea guida
|
||||
Point3d ptStart ;
|
||||
pGuide->GetStartPoint( ptStart) ;
|
||||
Vector3d vtStart ;
|
||||
@@ -952,7 +509,7 @@ GetSurfBezierSwept3d( const ICurve* pSect, const ICurve* pGuide, const Vector3d&
|
||||
return nullptr ;
|
||||
}
|
||||
|
||||
// capisco se la guida è una linea spezzata o una curva
|
||||
// capisco se la guida è una linea spezzata o una curva
|
||||
bool bGuideIsPolyLine = false ;
|
||||
switch( pGuide->GetType()) {
|
||||
case CRV_COMPO : {
|
||||
@@ -960,7 +517,7 @@ GetSurfBezierSwept3d( const ICurve* pSect, const ICurve* pGuide, const Vector3d&
|
||||
const ICurveComposite* pCC = GetCurveComposite( pGuide) ;
|
||||
for ( int i = 0 ; i < pCC->GetCurveCount() && bGuideIsPolyLine ; ++i) {
|
||||
const ICurve* pCrv = pCC->GetCurve( i) ;
|
||||
if( pCrv->GetType() != CRV_LINE) {
|
||||
if ( pCrv->GetType() != CRV_LINE) {
|
||||
if ( pCrv->GetType() == CRV_BEZIER) {
|
||||
const ICurveBezier* pCrvBez = GetCurveBezier( pCrv) ;
|
||||
bGuideIsPolyLine = pCrvBez->IsALine() ;
|
||||
@@ -988,18 +545,18 @@ GetSurfBezierSwept3d( const ICurve* pSect, const ICurve* pGuide, const Vector3d&
|
||||
int nSpanV = 0 ;
|
||||
PtrOwner<ICurveComposite> pCrvV( CreateCurveComposite()) ;
|
||||
if ( bGuideIsPolyLine) {
|
||||
if( pGuide->GetType() == CRV_LINE)
|
||||
if ( pGuide->GetType() == CRV_LINE)
|
||||
nSpanV = 1 ;
|
||||
else if ( pGuide->GetType() == CRV_COMPO)
|
||||
nSpanV = GetCurveComposite( pGuide)->GetCurveCount() ;
|
||||
}
|
||||
else {
|
||||
//converto in bezier la guida ( grado 3, non razionale)
|
||||
// converto in bezier la guida ( grado 3, non razionale)
|
||||
if ( pGuide->GetType() != CRV_BEZIER)
|
||||
pCrvV->AddCurve( CurveToBezierCurve( pGuide, 3, false)) ;
|
||||
else {
|
||||
const ICurveBezier* pGuideBez = GetCurveBezier( pGuide) ;
|
||||
if( ! pGuideBez->IsRational())
|
||||
if ( ! pGuideBez->IsRational())
|
||||
pCrvV->AddCurve( pGuide->Clone()) ;
|
||||
else
|
||||
pCrvV->AddCurve( EditBezierCurve( pGuideBez, 3, false)) ;
|
||||
@@ -1009,7 +566,7 @@ GetSurfBezierSwept3d( const ICurve* pSect, const ICurve* pGuide, const Vector3d&
|
||||
nSpanV = pCrvV->GetCurveCount() ;
|
||||
}
|
||||
|
||||
// converto in bezier la sezione ( grado 3, non razionale)
|
||||
// converto in bezier la sezione ( grado 3, non razionale)
|
||||
PtrOwner<ICurveComposite> pCrvU( CreateCurveComposite()) ;
|
||||
if ( pSect->GetType() != CRV_BEZIER)
|
||||
pCrvU->AddCurve( CurveToBezierCurve( pSect, 3, false)) ;
|
||||
@@ -1023,46 +580,44 @@ GetSurfBezierSwept3d( const ICurve* pSect, const ICurve* pGuide, const Vector3d&
|
||||
if ( IsNull( pCrvU) || ! pCrvU->IsValid())
|
||||
return nullptr ;
|
||||
|
||||
// calcolo il vettore di Frames campionati lungo la guida mediante la tolleranza definita
|
||||
// calcolo il vettore di Frames campionati lungo la guida mediante la tolleranza definita
|
||||
FRAME3DVECTOR vFrames ;
|
||||
if ( bRMF) {
|
||||
RotationMinimizingFrame RMF ;
|
||||
if( bGuideIsPolyLine) {
|
||||
if ( bGuideIsPolyLine) {
|
||||
if ( ! RMF.Set( pGuide, frStart) ||
|
||||
! RMF.GetFramesBySplit( nSpanV, vFrames) || vFrames.empty())
|
||||
! RMF.GetFramesBySplit( nSpanV, vFrames) || vFrames.empty())
|
||||
return nullptr ;
|
||||
}
|
||||
else {
|
||||
if ( ! RMF.Set( pGuide, frStart) ||
|
||||
! RMF.GetFramesByTolerance( dLinTol, vFrames) || vFrames.empty())
|
||||
! RMF.GetFramesByTolerance( dLinTol, vFrames) || vFrames.empty())
|
||||
return nullptr ;
|
||||
}
|
||||
}
|
||||
else {
|
||||
RotationXplaneFrame RXF ;
|
||||
if( bGuideIsPolyLine) {
|
||||
if ( bGuideIsPolyLine) {
|
||||
if ( ! RXF.Set( pGuide, vtAx, frStart.VersX()) ||
|
||||
! RXF.GetFramesBySplit( nSpanV, vFrames) || vFrames.empty())
|
||||
! RXF.GetFramesBySplit( nSpanV, vFrames) || vFrames.empty())
|
||||
return nullptr ;
|
||||
}
|
||||
else {
|
||||
if ( ! RXF.Set( pGuide, vtAx, frStart.VersX()) ||
|
||||
! RXF.GetFramesByTolerance( dLinTol, vFrames) || vFrames.empty())
|
||||
! RXF.GetFramesByTolerance( dLinTol, vFrames) || vFrames.empty())
|
||||
return nullptr ;
|
||||
}
|
||||
}
|
||||
|
||||
//// per ogni Frame calcolato, la sezione va roto-traslata lungo la guida
|
||||
// per ogni Frame calcolato, la sezione va roto-traslata lungo la guida
|
||||
int nSpanU = int( pCrvU->GetCurveCount()) ;
|
||||
int nDegU = 9 ; // debug
|
||||
|
||||
|
||||
int nDegV = 3 ;
|
||||
if ( bGuideIsPolyLine){
|
||||
nDegV = 1 ;
|
||||
// superficie swept
|
||||
PtrOwner<ISurfBezier> pSurfBez( CreateSurfBezier()) ;
|
||||
pSurfBez->Init( nDegU,nDegV, nSpanU, nSpanV, bRat) ;
|
||||
pSurfBez->Init( nDegU, nDegV, nSpanU, nSpanV, bRat) ;
|
||||
pCrvU->ToLoc( frStart) ;
|
||||
for ( int f = 0 ; f < int( vFrames.size()) ; ++f) {
|
||||
PtrOwner<ICurveComposite> pNewSect( pCrvU->Clone()) ;
|
||||
@@ -1125,191 +680,6 @@ GetSurfBezierSwept3d( const ICurve* pSect, const ICurve* pGuide, const Vector3d&
|
||||
return nullptr ;
|
||||
}
|
||||
|
||||
////-------------------------------------------------------------------------------
|
||||
//ISurfBezier*
|
||||
//GetSurfTriMeshSwept( const ICurve* pSect, const ICurve* pGuide, const Vector3d& vtAx,
|
||||
// bool bCapEnds, double dLinTol) // DA SISTEMARE - ancora copia della versione stm, cambia solo il nome della funzione//////////////////////
|
||||
//{
|
||||
// // verifica parametri
|
||||
// if ( pSect == nullptr || pGuide == nullptr)
|
||||
// return nullptr ;
|
||||
//
|
||||
// bool bIsLine = false ;
|
||||
// if ( pGuide->GetType() == CRV_LINE)
|
||||
// bIsLine = true ;
|
||||
// else {
|
||||
// const CurveComposite* pCompo = GetBasicCurveComposite( pGuide) ;
|
||||
// Point3d ptStart, ptEnd ;
|
||||
// if ( pCompo != nullptr && pCompo->IsALine( 10 * EPS_SMALL, ptStart, ptEnd))
|
||||
// bIsLine = true ;
|
||||
// }
|
||||
// // se la guida è piana
|
||||
// Plane3d plGuide ;
|
||||
// if ( pGuide->IsFlat( plGuide, bIsLine, 10 * EPS_SMALL))
|
||||
// return GetSurfBezierSweptInPlane( pSect, pGuide, plGuide.GetVersN(), bCapEnds, dLinTol) ;
|
||||
//
|
||||
// // altrimenti swept 3d
|
||||
// return GetSurfBezierSwept3d( pSect, pGuide, vtAx, bCapEnds, dLinTol) ;
|
||||
//}
|
||||
//
|
||||
////-------------------------------------------------------------------------------
|
||||
//ISurfBezier*
|
||||
//GetSurfBezierSwept( const ISurfFlatRegion* pSfrSect, const ICurve* pGuide, const Vector3d& vtAx,
|
||||
// bool bCapEnds, double dLinTol) // DA SISTEMARE - ancora copia della versione stm, cambia solo il nome della funzione//////////////////////
|
||||
//{
|
||||
// // verifica dei parametri
|
||||
// if ( pSfrSect == nullptr || pGuide == nullptr)
|
||||
// return nullptr ;
|
||||
//
|
||||
// // predispongo collettore superfici componenti
|
||||
// StmFromTriangleSoup StmSoup ;
|
||||
// StmSoup.Start() ;
|
||||
//
|
||||
// // per ogni loop della superficie, creo una Swept
|
||||
// for ( int nC = 0 ; nC < pSfrSect->GetChunkCount() ; ++ nC) {
|
||||
// for ( int nL = 0 ; nL < pSfrSect->GetLoopCount( nC) ; ++ nL) {
|
||||
// // recupero il loop
|
||||
// PtrOwner<ICurve> pCrvLoop( pSfrSect->GetLoop( nC, nL)) ;
|
||||
// if ( IsNull( pCrvLoop) || ! pCrvLoop->IsValid())
|
||||
// return nullptr ;
|
||||
// // creo la Trimesh Swept
|
||||
// PtrOwner<ISurfTriMesh> pStmLoopSwept( GetSurfTriMeshSwept( pCrvLoop, pGuide, vtAx, false, dLinTol)) ;
|
||||
// if ( IsNull( pStmLoopSwept) || ! pStmLoopSwept->IsValid())
|
||||
// return nullptr ;
|
||||
// // aggiungo la Swept ricavata al risultato finale ( come triangoli )
|
||||
// StmSoup.AddSurfTriMesh( *pStmLoopSwept) ;
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// // Recupero la superficie
|
||||
// if ( ! StmSoup.End())
|
||||
// return nullptr ;
|
||||
// PtrOwner<ISurfTriMesh> pStmSwept( StmSoup.GetSurf()) ;
|
||||
// if ( IsNull( pStmSwept))
|
||||
// return nullptr ;
|
||||
//
|
||||
// // se rischiesta chiusura...
|
||||
// // Controllo solo che la guida non sia chiusa, la sezione derivando da una Flatregion è sempre chiusa
|
||||
// if ( bCapEnds && ! pGuide->IsClosed()) {
|
||||
// // recupero i loop all'inizio (dalla regione e apportunamente approssimati)
|
||||
// POLYLINEVECTOR vPLi ;
|
||||
// for ( int nC = 0 ; nC < pSfrSect->GetChunkCount() ; ++ nC) {
|
||||
// for ( int nL = 0 ; nL < pSfrSect->GetLoopCount( nC) ; ++ nL) {
|
||||
// vPLi.emplace_back() ;
|
||||
// if ( ! pSfrSect->ApproxLoopWithLines( nC, nL, dLinTol, ANG_TOL_STD_DEG, ICurve::APL_SPECIAL, vPLi.back()))
|
||||
// return nullptr ;
|
||||
// }
|
||||
// }
|
||||
// // creo il cap sull'inizio e lo attacco alla swept ( è già in posizione giusta)
|
||||
// PtrOwner<ISurfTriMesh> pSci( CreateSurfTriMesh()) ;
|
||||
// if ( ! pSci->CreateByRegion( vPLi))
|
||||
// return nullptr ;
|
||||
// pStmSwept->DoSewing( *pSci) ;
|
||||
// // recupero i loops alla fine
|
||||
// POLYLINEVECTOR vPLe ;
|
||||
// if ( ! pStmSwept->GetLoops( vPLe))
|
||||
// return nullptr ;
|
||||
// // creo la superficie alla fine e la attacco
|
||||
// PtrOwner<ISurfTriMesh> pSce( CreateSurfTriMesh()) ;
|
||||
// if ( ! pSce->CreateByRegion( vPLe))
|
||||
// return nullptr ;
|
||||
// // attacco la superficie finale alla swept
|
||||
// pSce->Invert() ;
|
||||
// pStmSwept->DoSewing( *pSce) ;
|
||||
// }
|
||||
// // se superficie risultante chiusa, verifico che la normale sia verso l'esterno
|
||||
// double dVol ;
|
||||
// if ( pStmSwept->GetVolume( dVol) && dVol < 0)
|
||||
// pStmSwept->Invert() ;
|
||||
//
|
||||
// return Release( pStmSwept) ;
|
||||
//}
|
||||
//
|
||||
////-------------------------------------------------------------------------------
|
||||
//ISurfBezier*
|
||||
//GetSurfBezierTransSwept( const ICurve* pSect, const ICurve* pGuide, bool bCapEnds, double dLinTol) // DA SISTEMARE - ancora copia della versione stm, cambia solo il nome della funzione//////////////////////
|
||||
//{
|
||||
// // verifica parametri
|
||||
// if ( pSect == nullptr || pGuide == nullptr)
|
||||
// return nullptr ;
|
||||
// // determino se la sezione è chiusa
|
||||
// bool bSectClosed = pSect->IsClosed() ;
|
||||
// // punto iniziale della sezione e vettore a inizio guida
|
||||
// Point3d ptStart ;
|
||||
// if ( ! pSect->GetStartPoint( ptStart))
|
||||
// return nullptr ;
|
||||
// Point3d ptGuide ;
|
||||
// if ( ! pGuide->GetStartPoint( ptGuide))
|
||||
// return nullptr ;
|
||||
// Vector3d vtDelta = ptStart - ptGuide ;
|
||||
// // calcolo la polilinea che approssima la guida
|
||||
// PolyLine PLG ;
|
||||
// if ( ! pGuide->ApproxWithLines( dLinTol, ANG_TOL_STD_DEG, ICurve::APL_SPECIAL, PLG))
|
||||
// return nullptr ;
|
||||
// // determino se la guida è chiusa
|
||||
// bool bGuideClosed = PLG.IsClosed() ;
|
||||
// // calcolo la superficie
|
||||
// PtrOwner<SurfTriMesh> pSTM( CreateBasicSurfTriMesh()) ;
|
||||
// if ( IsNull( pSTM))
|
||||
// return nullptr ;
|
||||
// // salvo tolleranza lineare usata
|
||||
// pSTM->SetLinearTolerance( dLinTol) ;
|
||||
// // superficie swept
|
||||
// PtrOwner<ICurve> pPrevCrv ;
|
||||
// Point3d ptP ;
|
||||
// bool bPoint = PLG.GetFirstPoint( ptP) ;
|
||||
// while ( bPoint) {
|
||||
// // nuova curva
|
||||
// PtrOwner<ICurve> pCurrCrv( pSect->Clone()) ;
|
||||
// if ( IsNull( pCurrCrv))
|
||||
// return nullptr ;
|
||||
// pCurrCrv->Translate( ptP - ptStart + vtDelta) ;
|
||||
// // se esiste la curva precedente, costruisco la rigata (di tipo minima distanza)
|
||||
// if ( ! IsNull( pPrevCrv)) {
|
||||
// PtrOwner<ISurfTriMesh> pSr( GetSurfTriMeshRuled( pPrevCrv, pCurrCrv, ISurfTriMesh::RLT_ISOPAR, dLinTol)) ;
|
||||
// if ( IsNull( pSr))
|
||||
// return nullptr ;
|
||||
// pSTM->DoSewing( *pSr) ;
|
||||
// }
|
||||
// // salvo la curva come prossima precedente
|
||||
// pPrevCrv.Set( pCurrCrv) ;
|
||||
// // prossimo punto
|
||||
// bPoint = PLG.GetNextPoint( ptP) ;
|
||||
// }
|
||||
// // se richiesti caps e sezione chiusa e guida aperta
|
||||
// if ( bCapEnds && bSectClosed && ! bGuideClosed) {
|
||||
// // calcolo la polilinea che approssima la sezione
|
||||
// PolyLine PLS ;
|
||||
// if ( ! pSect->ApproxWithLines( dLinTol, ANG_TOL_STD_DEG, ICurve::APL_SPECIAL, PLS))
|
||||
// return nullptr ;
|
||||
// // verifico che la sezione sia chiusa e piatta
|
||||
// Plane3d plSect ; double dArea ;
|
||||
// if ( PLS.IsClosedAndFlat( plSect, dArea, 100 * EPS_SMALL)) {
|
||||
// // aggiungo il cap sull'inizio
|
||||
// PtrOwner<SurfTriMesh> pSci( CreateBasicSurfTriMesh()) ;
|
||||
// if ( IsNull( pSci) || ! pSci->CreateByFlatContour( PLS))
|
||||
// return nullptr ;
|
||||
// pSci->Invert() ;
|
||||
// Point3d ptGi ; PLG.GetFirstPoint( ptGi) ;
|
||||
// pSci->Translate( ptGi - ptStart + vtDelta) ;
|
||||
// pSTM->DoSewing( *pSci) ;
|
||||
// // aggiungo il cap sulla fine
|
||||
// PtrOwner<SurfTriMesh> pSce( CreateBasicSurfTriMesh()) ;
|
||||
// if ( IsNull( pSce) || ! pSce->CreateByFlatContour( PLS))
|
||||
// return nullptr ;
|
||||
// Point3d ptGe ; PLG.GetLastPoint( ptGe) ;
|
||||
// pSce->Translate( ptGe - ptStart + vtDelta) ;
|
||||
// pSTM->DoSewing( *pSce) ;
|
||||
// }
|
||||
// }
|
||||
// // se superficie risultante chiusa, verifico che la normale sia verso l'esterno
|
||||
// double dVol ;
|
||||
// if ( pSTM->GetVolume( dVol) && dVol < 0)
|
||||
// pSTM->Invert() ;
|
||||
// // restituisco la superficie
|
||||
// return Release( pSTM) ;
|
||||
//}
|
||||
|
||||
//-------------------------------------------------------------------------------
|
||||
ISurfBezier*
|
||||
GetSurfBezierRuled( const Point3d& ptP, const ICurve* pCurve, double dLinTol)
|
||||
@@ -1317,16 +687,12 @@ GetSurfBezierRuled( const Point3d& ptP, const ICurve* pCurve, double dLinTol)
|
||||
// verifica parametri
|
||||
if ( &ptP == nullptr || pCurve == nullptr)
|
||||
return nullptr ;
|
||||
//// calcolo la polilinea che approssima la curva
|
||||
//PolyLine PL ;
|
||||
//if ( ! pCurve->ApproxWithLines( dLinTol, ANG_TOL_STD_DEG, ICurve::APL_SPECIAL, PL))
|
||||
// return nullptr ;
|
||||
|
||||
// creo e setto la superficie trimesh
|
||||
PtrOwner<SurfBezier> pSbz( CreateBasicSurfBezier()) ;
|
||||
if ( IsNull( pSbz) || ! pSbz->CreateByPointCurve( ptP, pCurve))
|
||||
return nullptr ;
|
||||
//// salvo tolleranza lineare usata
|
||||
//pSbz->SetLinearTolerance( dLinTol) ;
|
||||
|
||||
// restituisco la superficie
|
||||
return Release( pSbz) ;
|
||||
}
|
||||
@@ -1362,8 +728,7 @@ GetSurfBezierRuled( const ICurve* pCurve1, const ICurve* pCurve2, int nType, dou
|
||||
PtrOwner<SurfBezier> pSbz( CreateBasicSurfBezier()) ;
|
||||
if ( IsNull( pSbz) || ! pSbz->CreateByTwoCurves( pCC1, pCC2, nType))
|
||||
return nullptr ;
|
||||
//// salvo tolleranza lineare usata
|
||||
//pSbz->SetLinearTolerance( dLinTol) ;
|
||||
|
||||
// restituisco la superficie
|
||||
return Release( pSbz) ;
|
||||
}
|
||||
@@ -1404,4 +769,4 @@ GetSurfBezierSkinned( const CICURVEPVECTOR& vCrv, double dLinTol)
|
||||
return nullptr ;
|
||||
// restituisco la superficie
|
||||
return Release( pSbz) ;
|
||||
}
|
||||
}
|
||||
|
||||
+225
-145
@@ -18,6 +18,7 @@
|
||||
#include "NgeWriter.h"
|
||||
#include "NgeReader.h"
|
||||
#include "Bernstein.h"
|
||||
#include "CurveArc.h"
|
||||
#include "CurveBezier.h"
|
||||
#include "CurveComposite.h"
|
||||
#include "Tree.h"
|
||||
@@ -299,6 +300,62 @@ SurfBezier::GetArea( double& dArea) const
|
||||
return m_pSTM->GetArea( dArea) ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
SurfBezier::IsClosed( void) const
|
||||
{
|
||||
// altrimenti verifico a mano
|
||||
if ( m_nSpanU == 1 || m_nSpanV == 1)
|
||||
return false ;
|
||||
|
||||
// controllo la prima riga con l'ultima
|
||||
m_bClosedV = true ;
|
||||
for ( int i = 0 ; i < m_nDegU * m_nSpanU + 1 && m_bClosedV ; ++i)
|
||||
m_bClosedV = AreSamePointApprox( m_vPtCtrl[GetInd( i, 0)], m_vPtCtrl[ GetInd(i, m_nDegV * m_nSpanV)]) ;
|
||||
|
||||
// controllo la prima colonna con l'ultima
|
||||
m_bClosedU = true ;
|
||||
for ( int j = 0 ; j < m_nDegV * m_nSpanV + 1 && m_bClosedU ; ++j)
|
||||
m_bClosedU = AreSamePointApprox( m_vPtCtrl[GetInd(0,j)], m_vPtCtrl[GetInd(m_nDegU * m_nSpanU,j)]) ;
|
||||
|
||||
// se ho la chiusura su entrambi i parametri ho la chiusura "in stile toro"
|
||||
if( m_bClosedU && m_bClosedV)
|
||||
return true ;
|
||||
|
||||
//verifico se ci sono dei poli che chiudono la superficie, per vedere se ho la chiusura "in stile sfera, da polo a polo" ( classica superficie di rivoluzione)
|
||||
CalcPoles() ;
|
||||
// chiusa in U e con poli sugli altri 2 lati
|
||||
if( m_bClosedU && ! m_bClosedV && m_vbPole[0] && m_vbPole[2])
|
||||
return true ;
|
||||
// chiusa in V e con poli sugli altri due lati
|
||||
if( m_bClosedV && ! m_bClosedU && m_vbPole[1] && m_vbPole[3])
|
||||
return true ;
|
||||
|
||||
// se ho due lati opposti che sono dei poli e sono anche coincidenti allora la superficie potrebbe essere chiusa "in stile sfera a saccoccia"
|
||||
if ( m_vbPole[0] && m_vbPole[2] && AreSamePointApprox( m_vPtCtrl[GetInd(0,0)], m_vPtCtrl[GetInd(m_nDegU * m_nSpanU, m_nDegV * m_nSpanV)]) ) {
|
||||
bool bV0BackAndForth = true ;
|
||||
bool bV1BackAndForth = true ;
|
||||
for ( int i = 0 ; i < (m_nDegV * m_nSpanV + 1) / 2 && bV0BackAndForth && bV1BackAndForth; ++i) {
|
||||
bV0BackAndForth = AreSamePointApprox( m_vPtCtrl[GetInd(0,i)], m_vPtCtrl[GetInd(0,m_nDegV * m_nSpanV - i)]) ;
|
||||
bV1BackAndForth = AreSamePointApprox( m_vPtCtrl[GetInd(m_nDegU * m_nSpanU,i)], m_vPtCtrl[GetInd(m_nDegU * m_nSpanU,m_nDegV * m_nSpanV - i)]) ;
|
||||
}
|
||||
if ( bV0BackAndForth && bV1BackAndForth)
|
||||
return true ;
|
||||
}
|
||||
if ( m_vbPole[1] && m_vbPole[3] && AreSamePointApprox( m_vPtCtrl[GetInd(0,0)], m_vPtCtrl[GetInd(m_nDegU * m_nSpanU, m_nDegV * m_nSpanV)]) ) {
|
||||
bool bU0BackAndForth = true ;
|
||||
bool bU1BackAndForth = true ;
|
||||
for ( int i = 0 ; i < (m_nDegU * m_nSpanU + 1) / 2 && bU0BackAndForth && bU1BackAndForth; ++i) {
|
||||
bU0BackAndForth = AreSamePointApprox( m_vPtCtrl[GetInd( i,0)], m_vPtCtrl[GetInd( m_nDegU * m_nSpanU - i, 0)]) ;
|
||||
bU1BackAndForth = AreSamePointApprox( m_vPtCtrl[GetInd( i, m_nDegV * m_nSpanV)], m_vPtCtrl[GetInd( m_nDegU * m_nSpanU - i, m_nDegV * m_nSpanV)]) ;
|
||||
}
|
||||
if ( bU0BackAndForth && bU1BackAndForth)
|
||||
return true ;
|
||||
}
|
||||
|
||||
return false ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
SurfBezier::GetCentroid( Point3d& ptCen) const
|
||||
@@ -812,15 +869,21 @@ SurfBezier::Dump( string& sOut, bool bMM, const char* szNewLine) const
|
||||
double dArea ;
|
||||
GetArea( dArea) ;
|
||||
sOut += "Area=" + ToString( GetAreaInUiUnits( dArea, bMM),1) + szNewLine ;
|
||||
// altri dati per superficie chiusa
|
||||
if ( IsClosed()) {
|
||||
double dVolume ;
|
||||
GetVolume( dVolume) ;
|
||||
sOut += "Closed Volume=" + ToString( GetVolumeInUiUnits( dVolume, bMM), 1) + szNewLine ;
|
||||
}
|
||||
// parametri : flag razionale
|
||||
sOut += ( m_bRat ? "Rat" : "Int") ;
|
||||
// flag trimmata
|
||||
// flag trimmata
|
||||
sOut += ( m_bTrimmed ? " Trim " : " Full") ;
|
||||
// gradi in U e V
|
||||
// gradi in U e V
|
||||
sOut += " DegU=" + ToString( m_nDegU) + " DegV=" + ToString( m_nDegV) ;
|
||||
// pezze in U e V
|
||||
// pezze in U e V
|
||||
sOut += " SpanU=" + ToString( m_nSpanU) + " SpanV=" + ToString( m_nSpanV) + szNewLine ;
|
||||
// ciclo sui punti di controllo ( con pesi se razionale)
|
||||
// ciclo sui punti di controllo ( con pesi se razionale)
|
||||
for ( int i = 0 ; i < GetDim() ; ++ i) {
|
||||
sOut += "PC(" + ToString( GetInUiUnits( m_vPtCtrl[i], bMM), 3) ;
|
||||
if ( m_bRat)
|
||||
@@ -2097,6 +2160,10 @@ SurfBezier::IncreaseUV( double& dUV, double dxy, bool bUOrV, double* dUVCopy, bo
|
||||
bool
|
||||
SurfBezier::UnprojectCurveFromStm( const ICurveComposite* pCC, ICRVCOMPOPVECTOR& vpCC, const Plane3d* pPlCut) const
|
||||
{
|
||||
// calcolo la superficie se non già calcolata
|
||||
if ( m_pSTMRefined == nullptr)
|
||||
GetAuxSurfRefined() ;
|
||||
|
||||
// se necessario calcolo i poli
|
||||
if ( m_vbPole.empty())
|
||||
CalcPoles() ;
|
||||
@@ -2726,6 +2793,10 @@ SurfBezier::UnprojectPointFromStm( int nT, const Point3d& ptI, Point3d& ptSP, in
|
||||
bool
|
||||
SurfBezier::UnprojectPointFromStm( int nT, const Point3d& ptI, Point3d& ptSP, int nIL, const Point3d& ptIPrevOrNext, bool* bThroughEdge) const
|
||||
{
|
||||
// calcolo la superficie se non già calcolata
|
||||
if ( m_pSTMRefined == nullptr)
|
||||
GetAuxSurfRefined() ;
|
||||
|
||||
ptSP = ORIG ;
|
||||
if ( bThroughEdge != nullptr)
|
||||
*bThroughEdge = false ;
|
||||
@@ -3050,6 +3121,10 @@ SurfBezier::UnprojectPointFromStm( int nT, const Point3d& ptI, Point3d& ptSP, in
|
||||
bool
|
||||
SurfBezier::UnprojectPoint( const Point3d& pt3D, Point3d& ptParam, const Point3d& ptIPrev, bool* bThroughEdge, const Plane3d* pPlCut) const
|
||||
{
|
||||
// calcolo la superficie se non già calcolata
|
||||
if ( m_pSTMRefined == nullptr)
|
||||
GetAuxSurfRefined() ;
|
||||
|
||||
// se necessario calcolo i poli
|
||||
if ( m_vbPole.empty())
|
||||
CalcPoles() ;
|
||||
@@ -3866,14 +3941,14 @@ SurfBezier::CreateByExtrusion( const ICurve* pCrv, const Vector3d& vtExtr, bool
|
||||
return false ;
|
||||
// se composita verifico che curve siano con lo stesso grado e uniformi come tipo
|
||||
|
||||
PtrOwner<ICurveComposite> pCC( CreateCurveComposite()) ;
|
||||
pCC->AddCurve( pCrv->Clone()) ;
|
||||
CurveComposite CC ;
|
||||
CC.AddCurve( pCrv->Clone()) ;
|
||||
bool bRat = false ;
|
||||
int nDegU = 1 ;
|
||||
for ( int i = 0 ; i < pCC->GetCurveCount() ; ++i) {
|
||||
if ( pCC->GetCurve( i)->GetType() != CRV_BEZIER)
|
||||
for ( int i = 0 ; i < CC.GetCurveCount() ; ++i) {
|
||||
if ( CC.GetCurve( i)->GetType() != CRV_BEZIER)
|
||||
return false ;
|
||||
const ICurveBezier* pCrvBez = static_cast<const ICurveBezier*>( pCC->GetCurve( i)) ;
|
||||
const ICurveBezier* pCrvBez = GetCurveBezier( CC.GetCurve( i)) ;
|
||||
if ( i == 0 ) {
|
||||
bRat = pCrvBez->IsRational() ;
|
||||
nDegU = pCrvBez->GetDegree() ;
|
||||
@@ -3887,12 +3962,12 @@ SurfBezier::CreateByExtrusion( const ICurve* pCrv, const Vector3d& vtExtr, bool
|
||||
// riempio la matrice dei punti di controllo
|
||||
// parto dalla curva che sto estrudendo e mi alzo progressivamente seguendo il vettore vtExtr
|
||||
int nDegV = bDeg3orDeg2 ? 3 : 2 ;
|
||||
int nSpanU = pCC->GetCurveCount() ;
|
||||
int nSpanU = CC.GetCurveCount() ;
|
||||
int nSpanV = 1 ;
|
||||
Init(nDegU, nDegV, nSpanU, nSpanV, bRat) ;
|
||||
|
||||
for ( int k = 0 ; k < nSpanU ; ++k) {
|
||||
const ICurveBezier* pCrvBezier = static_cast<const ICurveBezier*>( pCC->GetCurve( k)) ;
|
||||
const ICurveBezier* pCrvBezier = GetCurveBezier( CC.GetCurve( k)) ;
|
||||
for ( int i = 0 ; i < nDegU + 1 ; ++i) {
|
||||
if ( k != 0 && i == 0)
|
||||
continue ;
|
||||
@@ -3937,32 +4012,38 @@ SurfBezier::CreateByExtrusion( const ICurve* pCrv, const Vector3d& vtExtr, bool
|
||||
bool
|
||||
SurfBezier::CreateByScrewing( const ICurve* pCurve, const Point3d& ptAx, const Vector3d& vtAx, double dAngRotDeg, double dMove)
|
||||
{
|
||||
// verifico che l'asse di rotazione sia non nullo
|
||||
// verifico validità curva
|
||||
if ( pCurve == nullptr || ! pCurve->IsValid())
|
||||
return false ;
|
||||
// verifico che l'asse di rotazione sia non nullo
|
||||
if ( vtAx.IsSmall())
|
||||
return false ;
|
||||
// verifico se solo rivoluzione
|
||||
bool bOnlyRev = ( abs( dMove) < EPS_SMALL) ;
|
||||
// verifico che l'angolo di rotazione sia significativo e, se solo rivoluzione, non superi un giro
|
||||
// verifico che l'angolo di rotazione sia significativo
|
||||
if ( abs( dAngRotDeg) < EPS_ANG_SMALL)
|
||||
return false ;
|
||||
// verifico se solo rivoluzione
|
||||
bool bOnlyRev = ( abs( dMove) < EPS_SMALL) ;
|
||||
// se solo rivoluzione, limito la rotazione entro un giro
|
||||
if ( bOnlyRev && abs( dAngRotDeg) > ANG_FULL)
|
||||
dAngRotDeg = _copysign( ANG_FULL, dAngRotDeg) ;
|
||||
|
||||
// se sto facendo una rivoluzione e la curva è piana faccio un controllo
|
||||
// se la curva attraversa l'asse allora mi fermo
|
||||
// se sto facendo una rivoluzione e la curva è piana, controllo che la curva non attraversi l'asse
|
||||
if ( abs( dMove) < EPS_SMALL ) {
|
||||
Plane3d plPlane ;
|
||||
if ( pCurve->IsFlat(plPlane, false, EPS_SMALL) ) {
|
||||
PtrOwner<ICurveLine> pAx( CreateCurveLine()) ;
|
||||
pAx->Set( ptAx - vtAx * 5e5, ptAx + vtAx * 5e5) ;
|
||||
IntersCurveCurve icc( *pCurve, *pAx) ;
|
||||
if ( pCurve->IsFlat( plPlane, false, 10 * EPS_SMALL)) {
|
||||
BBox3d b3Crv ;
|
||||
pCurve->GetLocalBBox( b3Crv) ;
|
||||
double dAxLen = b3Crv.MaxDistFromPoint( ptAx) ;
|
||||
CurveLine crvAx ;
|
||||
crvAx.Set( ptAx - dAxLen * vtAx, ptAx + dAxLen * vtAx) ;
|
||||
IntersCurveCurve icc( *pCurve, crvAx) ;
|
||||
Point3d ptStart ; pCurve->GetStartPoint( ptStart) ;
|
||||
Point3d ptEnd ; pCurve->GetStartPoint( ptEnd) ;
|
||||
for ( int i = 0 ; i < int(icc.GetIntersCount()) ; ++i) {
|
||||
Point3d ptEnd ; pCurve->GetEndPoint( ptEnd) ;
|
||||
for ( int i = 0 ; i < icc.GetIntersCount() ; ++i) {
|
||||
IntCrvCrvInfo iccInfo ;
|
||||
icc.GetIntCrvCrvInfo( i, iccInfo) ;
|
||||
//controllo che sia una vera intersezione in 3D, sennò passo alla successiva
|
||||
if( ! AreSamePointApprox( iccInfo.IciA[0].ptI, iccInfo.IciB[0].ptI))
|
||||
// controllo che sia una vera intersezione in 3D, altrimenti passo alla successiva
|
||||
if ( ! AreSamePointApprox( iccInfo.IciA[0].ptI, iccInfo.IciB[0].ptI))
|
||||
continue ;
|
||||
// se è il punto di inizio o di fine va bene e procedo
|
||||
if ( AreSamePointApprox( ptStart, iccInfo.IciA[0].ptI) || AreSamePointApprox( ptEnd, iccInfo.IciA[0].ptI))
|
||||
@@ -3974,41 +4055,41 @@ SurfBezier::CreateByScrewing( const ICurve* pCurve, const Point3d& ptAx, const V
|
||||
}
|
||||
}
|
||||
|
||||
// converto in bezier la curva iniziale
|
||||
PtrOwner<ICurveComposite> pCrvU ( CreateCurveComposite()) ;
|
||||
// se la curva è già una bezier singola la tengo, sennò la converto
|
||||
// converto in bezier la curva iniziale
|
||||
CurveComposite CrvU ;
|
||||
// se la curva è già una bezier singola la tengo, sennò la converto
|
||||
if ( pCurve->GetType() != CRV_BEZIER)
|
||||
pCrvU->AddCurve( CurveToBezierCurve( pCurve, 3, true)) ;
|
||||
CrvU.AddCurve( CurveToBezierCurve( pCurve, 3, true)) ;
|
||||
else {
|
||||
if( GetCurveBezier(pCurve)->IsRational())
|
||||
pCrvU->AddCurve( pCurve->Clone()) ;
|
||||
if ( GetCurveBezier(pCurve)->IsRational())
|
||||
CrvU.AddCurve( pCurve->Clone()) ;
|
||||
else {
|
||||
ICurveBezier* pCrvCopy = GetCurveBezier( pCurve->Clone()) ;
|
||||
pCrvCopy->MakeRational() ;
|
||||
pCrvU->AddCurve( pCrvCopy) ;
|
||||
CrvU.AddCurve( pCrvCopy) ;
|
||||
}
|
||||
}
|
||||
if ( IsNull( pCrvU) || ! pCrvU->IsValid())
|
||||
if ( ! CrvU.IsValid())
|
||||
return false ;
|
||||
int nSpanU = int( pCrvU->GetCurveCount()) ;
|
||||
int nDegU = ( GetCurveBezier( pCrvU->GetCurve(0)))->GetDegree() ;
|
||||
int nSpanU = int( CrvU.GetCurveCount()) ;
|
||||
int nDegU = ( GetCurveBezier( CrvU.GetCurve(0)))->GetDegree() ;
|
||||
|
||||
// creo la spirale su cui far la rail della curva ( in questo caso sarà la curva di bezier che delimita il bordo sinistro dello spazio parametrico tra il punto P00 e il punto P01)
|
||||
PtrOwner<ICurveComposite> pCrvV ( CreateCurveComposite()) ;
|
||||
// devo trovare un punto che NON stia sull'asse per poter costruire una spirale e sapere quante span in V avrò
|
||||
// creo la spirale su cui fare la rail della curva ( in questo caso sarà la curva di bezier che delimita il bordo sinistro dello spazio parametrico tra il punto P00 e il punto P01)
|
||||
CurveComposite CrvVSpiral ;
|
||||
// devo trovare un punto che NON stia sull'asse per poter costruire una spirale e sapere quante span in V avrò
|
||||
DBLVECTOR vdSpiralW ;
|
||||
bool bFound = false ;
|
||||
for ( int j = 0 ; j < nSpanU && ! bFound ; ++j) {
|
||||
const ICurveBezier* pSubCrvBezU = GetCurveBezier( pCrvU->GetCurve( j)) ;
|
||||
const ICurveBezier* pSubCrvBezU = GetCurveBezier( CrvU.GetCurve( j)) ;
|
||||
for ( int i = 0 ; i < nDegU + 1 && ! bFound ; ++i) {
|
||||
Point3d ptCtrlU = pSubCrvBezU->GetControlPoint( i) ;
|
||||
DistPointLine dpl( ptCtrlU, ptAx, vtAx, 1, false) ;
|
||||
if ( ! dpl.IsSmall()) {
|
||||
PtrOwner<ICurveArc> pSpiral( CreateCurveArc()) ;
|
||||
pSpiral->SetCPAN( ptAx, ptCtrlU, dAngRotDeg, dMove, vtAx) ;
|
||||
// converto in bezier la spirale
|
||||
pCrvV->AddCurve( ArcToBezierCurve( pSpiral,3 , true)) ;
|
||||
const ICurveBezier* pFirstBez = GetCurveBezier( pCrvV->GetCurve( 0)) ;
|
||||
CurveArc crvSpiral ;
|
||||
crvSpiral.SetCPAN( ptAx, ptCtrlU, dAngRotDeg, dMove, vtAx) ;
|
||||
// converto in bezier la spirale
|
||||
CrvVSpiral.AddCurve( ArcToBezierCurve( &crvSpiral, 3 , true)) ;
|
||||
const ICurveBezier* pFirstBez = GetCurveBezier( CrvVSpiral.GetCurve( 0)) ;
|
||||
int nDeg = pFirstBez->GetDegree() ;
|
||||
for ( int k = 0 ; k < nDeg + 1 ; ++k)
|
||||
vdSpiralW.push_back( pFirstBez->GetControlWeight( k)) ;
|
||||
@@ -4019,72 +4100,71 @@ SurfBezier::CreateByScrewing( const ICurve* pCurve, const Point3d& ptAx, const V
|
||||
if ( ! bFound)
|
||||
return false ;
|
||||
|
||||
if ( IsNull( pCrvV) || ! pCrvV->IsValid())
|
||||
if ( ! CrvVSpiral.IsValid())
|
||||
return false ;
|
||||
int nSpanV = int( pCrvV->GetCurveCount()) ;
|
||||
int nDegV = ( GetCurveBezier( pCrvV->GetCurve(0)))->GetDegree() ;
|
||||
// inizializzo la superficie
|
||||
bool bRat = true ; // perché nella direzione del parametro V ho sicuramente delle razioniali
|
||||
int nSpanV = CrvVSpiral.GetCurveCount() ;
|
||||
int nDegV = GetCurveBezier( CrvVSpiral.GetCurve(0))->GetDegree() ;
|
||||
// inizializzo la superficie (deve essere razionale)
|
||||
bool bRat = true ;
|
||||
Init( nDegU, nDegV, nSpanU, nSpanV, bRat) ;
|
||||
|
||||
|
||||
// per ogni punto di controllo della curva di base creo la spirale che rappresenta la screw di quel punto
|
||||
// scorro le sottocurve della curva di base
|
||||
// per ogni punto di controllo della curva di base creo la spirale che rappresenta la screw di quel punto
|
||||
// scorro le sottocurve della curva di base
|
||||
for ( int k = 0 ; k < nSpanU ; ++k ) {
|
||||
const ICurveBezier* pSubCrvBezU = GetCurveBezier( pCrvU->GetCurve( k)) ;
|
||||
//scorro i punti di controllo
|
||||
const ICurveBezier* pSubCrvBezU = GetCurveBezier( CrvU.GetCurve( k)) ;
|
||||
// scorro i punti di controllo
|
||||
for ( int i = 0 ; i < nDegU + 1 ; ++i) {
|
||||
if ( k != 0 && i == 0)
|
||||
continue ;
|
||||
Point3d ptCtrlU = pSubCrvBezU->GetControlPoint( i) ;
|
||||
double dWU = pSubCrvBezU->GetControlWeight( i) ;
|
||||
|
||||
PtrOwner<ICurveComposite> pCrvV( CreateCurveComposite()) ;
|
||||
// verifico se il punto di controllo sta sull'asse
|
||||
// in tal caso anziché una spirale creo semplicemente una linea lungo l'asse
|
||||
CurveComposite CrvV ;
|
||||
// verifico se il punto di controllo sta sull'asse
|
||||
// in tal caso anziché una spirale creo semplicemente una linea lungo l'asse
|
||||
DistPointLine dpl( ptCtrlU, ptAx, vtAx, 1, false) ;
|
||||
if ( ! dpl.IsSmall()) {
|
||||
// creo la spirale e la converto in bezier
|
||||
PtrOwner<ICurveArc> pSpiral( CreateCurveArc()) ;
|
||||
pSpiral->SetCPAN( ptAx, ptCtrlU, dAngRotDeg, dMove, vtAx) ;
|
||||
ICurve* pSpiralBezier( ArcToBezierCurve( pSpiral)) ; // converto in curva bezier di grado 3 perché l'arco è una spirale
|
||||
pCrvV->AddCurve( pSpiralBezier) ;
|
||||
// creo la spirale e la converto in bezier
|
||||
CurveArc CrvSpiral ;
|
||||
CrvSpiral.SetCPAN( ptAx, ptCtrlU, dAngRotDeg, dMove, vtAx) ;
|
||||
ICurve* pSpiralBezier( ArcToBezierCurve( &CrvSpiral)) ; // converto in curva bezier di grado 3 perché l'arco è una spirale
|
||||
CrvV.AddCurve( pSpiralBezier) ;
|
||||
}
|
||||
else if ( abs( dMove) > EPS_SMALL){
|
||||
// creo un segmento in forma bezier con il giusto numero di span
|
||||
PtrOwner<ICurveLine> pCL( CreateBasicCurveLine()) ;
|
||||
pCL->Set( ptCtrlU, ptCtrlU + vtAx * dMove) ;
|
||||
// creo un segmento in forma bezier con il giusto numero di span
|
||||
CurveLine CL ;
|
||||
CL.Set( ptCtrlU, ptCtrlU + vtAx * dMove) ;
|
||||
double dStep = 1. / nSpanV ;
|
||||
for ( int j = 0 ; j < nSpanV ; ++j) {
|
||||
PtrOwner<ICurveLine> pCLSingleSpan( GetCurveLine( pCL->CopyParamRange( j * dStep, ( j + 1) * dStep))) ;
|
||||
PtrOwner<ICurveLine> pCLSingleSpan( GetCurveLine( CL.CopyParamRange( j * dStep, ( j + 1) * dStep))) ;
|
||||
PtrOwner<ICurveBezier> pCrvBezForm( LineToBezierCurve( pCLSingleSpan, 3, true)) ;
|
||||
// prima di aggiungere le curve alla composito setto i pesi
|
||||
// prima di aggiungere le curve alla composito setto i pesi
|
||||
for ( int z = 0 ; z < pCrvBezForm->GetDegree() + 1 ; ++z)
|
||||
pCrvBezForm->SetControlWeight( z, vdSpiralW[z]) ;
|
||||
pCrvV->AddCurve( Release( pCrvBezForm)) ;
|
||||
CrvV.AddCurve( Release( pCrvBezForm)) ;
|
||||
}
|
||||
}
|
||||
// se sto facendo una rivoluzione ( dMove == 0) e ho un punto di controllo sull'asse allora ho un polo
|
||||
// devo aggiungere sempre lo stesso punto per tutta la riga della matrice dei punti di controllo, con i pesi giusti
|
||||
// se sto facendo una rivoluzione ( dMove == 0) e ho un punto di controllo sull'asse allora ho un polo
|
||||
// devo aggiungere sempre lo stesso punto per tutta la riga della matrice dei punti di controllo, con i pesi giusti
|
||||
else {
|
||||
PtrOwner<ICurveBezier> pCrvBezier( CreateCurveBezier()) ;
|
||||
pCrvBezier->Init( nDegV, bRat) ;
|
||||
CurveBezier CrvBezier ;
|
||||
CrvBezier.Init( nDegV, bRat) ;
|
||||
for ( int z = 0 ; z < nDegV + 1 ; ++z) {
|
||||
pCrvBezier->SetControlPoint( z, ptCtrlU, vdSpiralW[z]) ;
|
||||
CrvBezier.SetControlPoint( z, ptCtrlU, vdSpiralW[z]) ;
|
||||
}
|
||||
for ( int j = 0 ; j < nSpanV ; ++j)
|
||||
pCrvV->AddCurve( pCrvBezier->Clone()) ;
|
||||
CrvV.AddCurve( CrvBezier.Clone()) ;
|
||||
}
|
||||
|
||||
if( ! pCrvV->IsValid())
|
||||
if ( ! CrvV.IsValid())
|
||||
return false ;
|
||||
|
||||
// aggiungo i punti di controllo
|
||||
// scorro le sottocurve della spirale
|
||||
// aggiungo i punti di controllo
|
||||
// scorro le sottocurve della spirale
|
||||
for ( int j = 0 ; j < nSpanV ; ++j) {
|
||||
const ICurveBezier* pSubCrvBezV = GetCurveBezier( pCrvV->GetCurve( j)) ;
|
||||
// scorro i punti di controllo
|
||||
for( int z = 0 ; z < nDegV + 1 ; ++z) {
|
||||
const ICurveBezier* pSubCrvBezV = GetCurveBezier( CrvV.GetCurve( j)) ;
|
||||
// scorro i punti di controllo
|
||||
for ( int z = 0 ; z < nDegV + 1 ; ++z) {
|
||||
double dWV = pSubCrvBezV->GetControlWeight( z) ;
|
||||
Point3d ptCtrlV = pSubCrvBezV->GetControlPoint( z) ;
|
||||
SetControlPoint( nDegU * k + i, nDegV * j + z, ptCtrlV, dWU * dWV) ;
|
||||
@@ -4101,18 +4181,18 @@ bool
|
||||
SurfBezier::CreateByPointCurve( const Point3d& pt, const ICurve* pCurve)
|
||||
{
|
||||
// converto in bezier la curva iniziale
|
||||
PtrOwner<ICurveComposite> pCrvU ( CreateCurveComposite()) ;
|
||||
CurveComposite CrvU ;
|
||||
// se la curva è già una bezier singola la tengo, sennò la converto
|
||||
if ( pCurve->GetType() != CRV_BEZIER)
|
||||
pCrvU->AddCurve( CurveToBezierCurve( pCurve)) ;
|
||||
CrvU.AddCurve( CurveToBezierCurve( pCurve)) ;
|
||||
else
|
||||
pCrvU->AddCurve( pCurve->Clone()) ;
|
||||
if ( IsNull( pCrvU) || ! pCrvU->IsValid())
|
||||
CrvU.AddCurve( pCurve->Clone()) ;
|
||||
if ( ! CrvU.IsValid())
|
||||
return false ;
|
||||
// recupero span e grado nel parametro U
|
||||
int nSpanU = int( pCrvU->GetCurveCount()) ;
|
||||
int nDegU = ( GetCurveBezier( pCrvU->GetCurve(0)))->GetDegree() ;
|
||||
bool bRat = (GetCurveBezier( pCrvU->GetCurve(0)))->IsRational() ;
|
||||
int nSpanU = int( CrvU.GetCurveCount()) ;
|
||||
int nDegU = ( GetCurveBezier( CrvU.GetCurve(0)))->GetDegree() ;
|
||||
bool bRat = (GetCurveBezier( CrvU.GetCurve(0)))->IsRational() ;
|
||||
// in V decido che la funzione è una patch di grado 1
|
||||
int nSpanV = 1 ;
|
||||
int nDegV = 1 ;
|
||||
@@ -4120,7 +4200,7 @@ SurfBezier::CreateByPointCurve( const Point3d& pt, const ICurve* pCurve)
|
||||
Init( nDegU, nDegV, nSpanU, nSpanV, bRat) ;
|
||||
// scorro le patch nel parametro U
|
||||
for ( int k = 0 ; k < nSpanU ; ++k) {
|
||||
const ICurveBezier* pSubCrvU = GetCurveBezier( pCrvU->GetCurve( k)) ;
|
||||
const ICurveBezier* pSubCrvU = GetCurveBezier( CrvU.GetCurve( k)) ;
|
||||
// scorro i punti di controllo in U
|
||||
for ( int i = 0 ; i < nDegU + 1 ; ++i ) {
|
||||
|
||||
@@ -4144,7 +4224,7 @@ bool
|
||||
SurfBezier::CreateByTwoCurves( const ICurve* pCurve0, const ICurve* pCurve1, int nRuledType)
|
||||
{
|
||||
// converto in bezier la curva iniziale
|
||||
PtrOwner<ICurveComposite> pCrvU0 ( CreateCurveComposite()) ;
|
||||
CurveComposite CrvU0 ;
|
||||
// se la curva è già una bezier singola la tengo, sennò la converto
|
||||
if ( pCurve0->GetType() != CRV_BEZIER) {
|
||||
// se è una compo controllo che siano già tutte bezier
|
||||
@@ -4161,20 +4241,20 @@ SurfBezier::CreateByTwoCurves( const ICurve* pCurve0, const ICurve* pCurve1, int
|
||||
else
|
||||
bAlreadyBez = false ;
|
||||
if ( ! bAlreadyBez)
|
||||
pCrvU0->AddCurve( CurveToBezierCurve( pCurve0)) ;
|
||||
CrvU0.AddCurve( CurveToBezierCurve( pCurve0)) ;
|
||||
else
|
||||
pCrvU0->AddCurve( pCurve0->Clone()) ;
|
||||
CrvU0.AddCurve( pCurve0->Clone()) ;
|
||||
}
|
||||
else
|
||||
pCrvU0->AddCurve( pCurve0->Clone()) ;
|
||||
if ( IsNull( pCrvU0) || ! pCrvU0->IsValid())
|
||||
CrvU0.AddCurve( pCurve0->Clone()) ;
|
||||
if ( ! CrvU0.IsValid())
|
||||
return false ;
|
||||
// recupero span e grado nel parametro U
|
||||
int nSpanU0 = int( pCrvU0->GetCurveCount()) ;
|
||||
int nDegU0 = ( GetCurveBezier( pCrvU0->GetCurve(0)))->GetDegree() ;
|
||||
bool bRat0 = (GetCurveBezier( pCrvU0->GetCurve(0)))->IsRational() ;
|
||||
int nSpanU0 = int( CrvU0.GetCurveCount()) ;
|
||||
int nDegU0 = ( GetCurveBezier( CrvU0.GetCurve(0)))->GetDegree() ;
|
||||
bool bRat0 = (GetCurveBezier( CrvU0.GetCurve(0)))->IsRational() ;
|
||||
// se la curva è già una bezier singola la tengo, sennò la converto
|
||||
PtrOwner<ICurveComposite> pCrvU1 ( CreateCurveComposite()) ;
|
||||
CurveComposite CrvU1 ;
|
||||
// se la curva è già una bezier singola la tengo, sennò la converto
|
||||
if ( pCurve1->GetType() != CRV_BEZIER) {
|
||||
// se è una compo controllo che siano già tutte bezier
|
||||
@@ -4191,16 +4271,16 @@ SurfBezier::CreateByTwoCurves( const ICurve* pCurve0, const ICurve* pCurve1, int
|
||||
else
|
||||
bAlreadyBez = false ;
|
||||
if ( ! bAlreadyBez)
|
||||
pCrvU1->AddCurve( CurveToBezierCurve( pCurve1)) ;
|
||||
CrvU1.AddCurve( CurveToBezierCurve( pCurve1)) ;
|
||||
else
|
||||
pCrvU1->AddCurve( pCurve1->Clone()) ;
|
||||
CrvU1.AddCurve( pCurve1->Clone()) ;
|
||||
}
|
||||
else
|
||||
pCrvU1->AddCurve( pCurve1->Clone()) ;
|
||||
CrvU1.AddCurve( pCurve1->Clone()) ;
|
||||
// recupero span e grado nel parametro U
|
||||
int nSpanU1 = int( pCrvU1->GetCurveCount()) ;
|
||||
int nDegU1 = ( GetCurveBezier( pCrvU1->GetCurve(0)))->GetDegree() ;
|
||||
bool bRat1 = (GetCurveBezier( pCrvU1->GetCurve(0)))->IsRational() ;
|
||||
int nSpanU1 = int( CrvU1.GetCurveCount()) ;
|
||||
int nDegU1 = ( GetCurveBezier( CrvU1.GetCurve(0)))->GetDegree() ;
|
||||
bool bRat1 = (GetCurveBezier( CrvU1.GetCurve(0)))->IsRational() ;
|
||||
//// se non ho lo stesso numero di span nelle due curve devo capire come gestire il caso.
|
||||
//// per il momento non implementato
|
||||
//if ( nSpanU0 != nSpanU1)
|
||||
@@ -4208,40 +4288,40 @@ SurfBezier::CreateByTwoCurves( const ICurve* pCurve0, const ICurve* pCurve1, int
|
||||
// se le due curve hanno grado diverso allora aumento il grado di quella con grado inferiore
|
||||
if ( nDegU0 != nDegU1) {
|
||||
while ( nDegU0 < nDegU1) {
|
||||
ICurveComposite* pCC( CreateCurveComposite()) ;
|
||||
CurveComposite CC ;
|
||||
for( int k = 0 ; k < nSpanU0 ; ++k)
|
||||
pCC->AddCurve( BezierIncreaseDegree( GetCurveBezier( pCrvU0->GetCurve( k)))) ;
|
||||
CC.AddCurve( BezierIncreaseDegree( GetCurveBezier( CrvU0.GetCurve( k)))) ;
|
||||
++nDegU0 ;
|
||||
pCrvU0.Set( pCC) ;
|
||||
CrvU0 = CC ;
|
||||
}
|
||||
while ( nDegU0 > nDegU1) {
|
||||
ICurveComposite* pCC( CreateCurveComposite()) ;
|
||||
CurveComposite CC ;
|
||||
for( int k = 0 ; k < nSpanU0 ; ++k)
|
||||
pCC->AddCurve( BezierIncreaseDegree( GetCurveBezier( pCrvU1->GetCurve( k)))) ;
|
||||
CC.AddCurve( BezierIncreaseDegree( GetCurveBezier( CrvU1.GetCurve( k)))) ;
|
||||
++nDegU1 ;
|
||||
pCrvU1.Set( pCC) ;
|
||||
CrvU1 = CC ;
|
||||
}
|
||||
}
|
||||
// omogenizzo la razionalità
|
||||
if ( bRat0 != bRat1) {
|
||||
if ( ! bRat0) {
|
||||
ICurveComposite* pCC( CreateCurveComposite()) ;
|
||||
CurveComposite CC ;
|
||||
for ( int k = 0 ; k < nSpanU0 ; ++k) {
|
||||
ICurveBezier* pCrvBez = GetCurveBezier( pCrvU0->GetCurve( k)->Clone()) ;
|
||||
ICurveBezier* pCrvBez = GetCurveBezier( CrvU0.GetCurve( k)->Clone()) ;
|
||||
pCrvBez->MakeRational() ;
|
||||
pCC->AddCurve( pCrvBez) ;
|
||||
CC.AddCurve( pCrvBez) ;
|
||||
}
|
||||
pCrvU0.Set( pCC) ;
|
||||
CrvU0 = CC ;
|
||||
bRat0 = true ;
|
||||
}
|
||||
if ( ! bRat1) {
|
||||
ICurveComposite* pCC( CreateCurveComposite()) ;
|
||||
CurveComposite CC ;
|
||||
for ( int k = 0 ; k < nSpanU1 ; ++k) {
|
||||
ICurveBezier* pCrvBez = GetCurveBezier( pCrvU1->GetCurve( k)->Clone()) ;
|
||||
ICurveBezier* pCrvBez = GetCurveBezier( CrvU1.GetCurve( k)->Clone()) ;
|
||||
pCrvBez->MakeRational() ;
|
||||
pCC->AddCurve( pCrvBez) ;
|
||||
CC.AddCurve( pCrvBez) ;
|
||||
}
|
||||
pCrvU1.Set( pCC) ;
|
||||
CrvU1 = CC ;
|
||||
bRat1 = true ;
|
||||
}
|
||||
}
|
||||
@@ -4282,7 +4362,7 @@ SurfBezier::CreateByTwoCurves( const ICurve* pCurve0, const ICurve* pCurve1, int
|
||||
int nCount0 = 0 ;
|
||||
DBLVECTOR vdW0 ;
|
||||
for ( int k = 0 ; k < nSpanU0 ; ++k ) {
|
||||
const ICurveBezier* pSubCrv0 = GetCurveBezier( pCrvU0->GetCurve( k)) ;
|
||||
const ICurveBezier* pSubCrv0 = GetCurveBezier( CrvU0.GetCurve( k)) ;
|
||||
for ( int i = 0 ; i < nDegU + 1 ; ++i ) {
|
||||
if( i != nDegU && !( i == 0 && k == 0))
|
||||
continue ;
|
||||
@@ -4297,7 +4377,7 @@ SurfBezier::CreateByTwoCurves( const ICurve* pCurve0, const ICurve* pCurve1, int
|
||||
int nCount1 = 0 ;
|
||||
DBLVECTOR vdW1 ;
|
||||
for ( int k = 0 ; k < nSpanU1 ; ++k ) {
|
||||
const ICurveBezier* pSubCrv1 = GetCurveBezier( pCrvU1->GetCurve( k)) ;
|
||||
const ICurveBezier* pSubCrv1 = GetCurveBezier( CrvU1.GetCurve( k)) ;
|
||||
for ( int i = 0 ; i < nDegU1 + 1 ; ++i ) {
|
||||
if( i != nDegU && !( i == 0 && k == 0))
|
||||
continue ;
|
||||
@@ -4324,7 +4404,7 @@ SurfBezier::CreateByTwoCurves( const ICurve* pCurve0, const ICurve* pCurve1, int
|
||||
int nSecondRowInd = nDegU * nSpanU + 1 ;
|
||||
|
||||
// se sono chiuse devo controllare che gli start siano il più allineati possibile, se non lo sono cambio gli start
|
||||
ChangeStartForClosed( plU0, plU1, pCrvU0, pCrvU1) ;
|
||||
ChangeStartForClosed( plU0, plU1, &CrvU0, &CrvU1) ;
|
||||
|
||||
// se sto usando la ISOPARM o la MINDIST semplice allora collego più span di una curva allo stesso punto
|
||||
if ( nRuledType == RLT_B_MINDIST) {
|
||||
@@ -4365,7 +4445,7 @@ SurfBezier::CreateByTwoCurves( const ICurve* pCurve0, const ICurve* pCurve1, int
|
||||
nIndMatchNext = vPnt0Match[i+1].second ;
|
||||
const ICurveBezier* pSubCrv0 ;
|
||||
if ( nIndMatch == nIndMatchNext) {
|
||||
pSubCrv0 = GetCurveBezier( pCrvU0->GetCurve( i)) ;
|
||||
pSubCrv0 = GetCurveBezier( CrvU0.GetCurve( i)) ;
|
||||
for ( int j = nCount0 == 0 ? 0 : 1 ; j < nLastPoint ; ++j) {
|
||||
if ( ! bRat0)
|
||||
SetControlPoint( nCount0 * nDegU + j, pSubCrv0->GetControlPoint( j)) ;
|
||||
@@ -4375,7 +4455,7 @@ SurfBezier::CreateByTwoCurves( const ICurve* pCurve0, const ICurve* pCurve1, int
|
||||
++ nCount0 ;
|
||||
// ripeto l'ultimo punto aggiunto alla riga U1 della superificie
|
||||
int nInd = nIndMatch > 0 ? nIndMatch - 1 : 0 ;
|
||||
const ICurveBezier* pSubCrv0 = GetCurveBezier( pCrvU1->GetCurve( nInd)) ;
|
||||
const ICurveBezier* pSubCrv0 = GetCurveBezier( CrvU1.GetCurve( nInd)) ;
|
||||
for ( int j = nCount1 == 0 ? 0 : 1 ; j < nLastPoint ; ++j) {
|
||||
int nPoint = nCount1 == 0 ? 0 : nDegU ;
|
||||
if ( ! bRat0)
|
||||
@@ -4395,7 +4475,7 @@ SurfBezier::CreateByTwoCurves( const ICurve* pCurve0, const ICurve* pCurve1, int
|
||||
|
||||
if( bSubCurveAddedFirst) {
|
||||
// aggiungo una sottocurva dalla curva U0
|
||||
pSubCrv0 = GetCurveBezier( pCrvU0->GetCurve( i)) ;
|
||||
pSubCrv0 = GetCurveBezier( CrvU0.GetCurve( i)) ;
|
||||
for ( int j = nCount0 == 0 ? 0 : 1 ; j < nLastPoint ; ++j) {
|
||||
if ( ! bRat0)
|
||||
SetControlPoint( nCount0 * nDegU + j, pSubCrv0->GetControlPoint( j)) ;
|
||||
@@ -4407,7 +4487,7 @@ SurfBezier::CreateByTwoCurves( const ICurve* pCurve0, const ICurve* pCurve1, int
|
||||
|
||||
// ripeto l'ultimo punto aggiunto per il numero di curve balzate - 1 della curva U1
|
||||
for( int k = 0 ; k < nIndMatchNext - nIndMatch - 1 ; ++k) {
|
||||
pSubCrv0 = GetCurveBezier( pCrvU0->GetCurve( i != 0 ? i - 1 : i)) ;
|
||||
pSubCrv0 = GetCurveBezier( CrvU0.GetCurve( i != 0 ? i - 1 : i)) ;
|
||||
for ( int j = nCount0 == 0 ? 0 : 1 ; j < nLastPoint ; ++j) {
|
||||
int nPoint = i == 0 && ! bSubCurveAddedFirst ? 0 : nDegU ;
|
||||
if ( ! bRat0)
|
||||
@@ -4419,7 +4499,7 @@ SurfBezier::CreateByTwoCurves( const ICurve* pCurve0, const ICurve* pCurve1, int
|
||||
}
|
||||
// se non l'ho già aggiunta prima aggiungo una sottocurva della U0
|
||||
if( ! bSubCurveAddedFirst) {
|
||||
pSubCrv0 = GetCurveBezier( pCrvU0->GetCurve( i)) ;
|
||||
pSubCrv0 = GetCurveBezier( CrvU0.GetCurve( i)) ;
|
||||
for ( int j = nCount0 == 0 ? 0 : 1 ; j < nLastPoint ; ++j) {
|
||||
if ( ! bRat0)
|
||||
SetControlPoint( nCount0 * nDegU + j, pSubCrv0->GetControlPoint( j)) ;
|
||||
@@ -4432,7 +4512,7 @@ SurfBezier::CreateByTwoCurves( const ICurve* pCurve0, const ICurve* pCurve1, int
|
||||
|
||||
// aggiungo tutte le sottocurve che ho balzato della curva U1
|
||||
for( int k = 0 ; k < nIndMatchNext - nIndMatch ; ++k) {
|
||||
pSubCrv0 = GetCurveBezier( pCrvU1->GetCurve( nIndMatch + k)) ;
|
||||
pSubCrv0 = GetCurveBezier( CrvU1.GetCurve( nIndMatch + k)) ;
|
||||
for ( int j = nCount1 == 0 ? 0 : 1 ; j < nLastPoint ; ++j ) {
|
||||
if ( ! bRat)
|
||||
SetControlPoint( nSecondRowInd + nCount1 * nDegU + j, pSubCrv0->GetControlPoint( j)) ;
|
||||
@@ -4447,7 +4527,7 @@ SurfBezier::CreateByTwoCurves( const ICurve* pCurve0, const ICurve* pCurve1, int
|
||||
//controllo se ho aggiunto tutti i punti della curva U1
|
||||
if ( vPnt0Match.back().second != nSpanU1) {
|
||||
// riaggiungo l'ultimo punto della U0
|
||||
const ICurveBezier* pSubCrv0 = GetCurveBezier( pCrvU0->GetCurve( nSpanU0 - 1)) ;
|
||||
const ICurveBezier* pSubCrv0 = GetCurveBezier( CrvU0.GetCurve( nSpanU0 - 1)) ;
|
||||
int nPoint = nDegU ;
|
||||
while( nCount0 < nSpanU) {
|
||||
for ( int j = 1 ; j < nLastPoint ; ++j) {
|
||||
@@ -4462,7 +4542,7 @@ SurfBezier::CreateByTwoCurves( const ICurve* pCurve0, const ICurve* pCurve1, int
|
||||
// aggiungo le restanti sottocurve della curva U1
|
||||
int nCrv1 = vPnt0Match.back().second ;
|
||||
while( nCrv1 < nSpanU1) {
|
||||
const ICurveBezier* pSubCrv1 = GetCurveBezier( pCrvU1->GetCurve( nCrv1)) ;
|
||||
const ICurveBezier* pSubCrv1 = GetCurveBezier( CrvU1.GetCurve( nCrv1)) ;
|
||||
for ( int j = 1 ; j < nLastPoint ; ++j) {
|
||||
if ( ! bRat1)
|
||||
SetControlPoint( nSecondRowInd + nCount1 * nDegU + j, pSubCrv1->GetControlPoint( j)) ;
|
||||
@@ -4477,8 +4557,8 @@ SurfBezier::CreateByTwoCurves( const ICurve* pCurve0, const ICurve* pCurve1, int
|
||||
else if ( nRuledType == RLT_B_ISOPAR) {
|
||||
// inizializzo la superficie
|
||||
Init( nDegU, nDegV, nSpanU, nSpanV, bRat) ;
|
||||
Point3d ptP0Start ; pCrvU0->GetStartPoint( ptP0Start) ;
|
||||
Point3d ptP1Start ; pCrvU1->GetStartPoint( ptP1Start) ;
|
||||
Point3d ptP0Start ; CrvU0.GetStartPoint( ptP0Start) ;
|
||||
Point3d ptP1Start ; CrvU1.GetStartPoint( ptP1Start) ;
|
||||
// setto i primi due punti delle righe
|
||||
nCount0 = 0 ; // sottocurva su pCrvU0
|
||||
if ( ! bRat)
|
||||
@@ -4508,7 +4588,7 @@ SurfBezier::CreateByTwoCurves( const ICurve* pCurve0, const ICurve* pCurve1, int
|
||||
if ( nLong == 0) {
|
||||
// aggiungo la curva sulla prima riga
|
||||
for ( int i = 1 ; i < nLastPoint ; ++i) {
|
||||
const ICurveBezier* pSubCrv0 = GetCurveBezier( pCrvU0->GetCurve( nCount0)) ;
|
||||
const ICurveBezier* pSubCrv0 = GetCurveBezier( CrvU0.GetCurve( nCount0)) ;
|
||||
Point3d ptCtrl = pSubCrv0->GetControlPoint( i) ;
|
||||
if ( ! bRat)
|
||||
SetControlPoint( nCount * nDegU + i, ptCtrl) ;
|
||||
@@ -4522,7 +4602,7 @@ SurfBezier::CreateByTwoCurves( const ICurve* pCurve0, const ICurve* pCurve1, int
|
||||
// o end point se ho già aggiunto tutte le curve
|
||||
int nInd = nCount1 < nSpanU1 ? 0 : nDegU ;
|
||||
int nSubCrv = nCount1 < nSpanU1 ? nCount1 : nSpanU1 - 1 ;
|
||||
const ICurveBezier* pSubCrv1 = GetCurveBezier( pCrvU1->GetCurve( nSubCrv)) ;
|
||||
const ICurveBezier* pSubCrv1 = GetCurveBezier( CrvU1.GetCurve( nSubCrv)) ;
|
||||
Point3d ptCtrl = pSubCrv1->GetControlPoint( nInd) ;
|
||||
for ( int i = 1 ; i < nLastPoint ; ++i) {
|
||||
if ( ! bRat)
|
||||
@@ -4536,7 +4616,7 @@ SurfBezier::CreateByTwoCurves( const ICurve* pCurve0, const ICurve* pCurve1, int
|
||||
else {
|
||||
// aggiungo la curva sulla seconda riga
|
||||
for ( int i = 1 ; i < nLastPoint ; ++i) {
|
||||
const ICurveBezier* pSubCrv1 = GetCurveBezier( pCrvU1->GetCurve( nCount1)) ;
|
||||
const ICurveBezier* pSubCrv1 = GetCurveBezier( CrvU1.GetCurve( nCount1)) ;
|
||||
Point3d ptCtrl = pSubCrv1->GetControlPoint( i) ;
|
||||
if ( ! bRat)
|
||||
SetControlPoint( nSecondRowInd + nCount * nDegU + i, ptCtrl) ;
|
||||
@@ -4550,7 +4630,7 @@ SurfBezier::CreateByTwoCurves( const ICurve* pCurve0, const ICurve* pCurve1, int
|
||||
// o end point se ho già aggiunto tutte le curve
|
||||
int nInd = nCount0 < nSpanU0 ? 0 : nDegU ;
|
||||
int nSubCrv = nCount0 < nSpanU0 ? nCount0 : nSpanU0 - 1 ;
|
||||
const ICurveBezier* pSubCrv0 = GetCurveBezier( pCrvU0->GetCurve( nSubCrv)) ;
|
||||
const ICurveBezier* pSubCrv0 = GetCurveBezier( CrvU0.GetCurve( nSubCrv)) ;
|
||||
Point3d ptCtrl = pSubCrv0->GetControlPoint( nInd) ;
|
||||
for ( int i = 1 ; i < nLastPoint ; ++i) {
|
||||
if ( ! bRat)
|
||||
@@ -4566,7 +4646,7 @@ SurfBezier::CreateByTwoCurves( const ICurve* pCurve0, const ICurve* pCurve1, int
|
||||
else {
|
||||
// aggiungo la curva sulla prima riga
|
||||
for ( int i = 1 ; i < nLastPoint ; ++i) {
|
||||
const ICurveBezier* pSubCrv0 = GetCurveBezier( pCrvU0->GetCurve( nCount0)) ;
|
||||
const ICurveBezier* pSubCrv0 = GetCurveBezier( CrvU0.GetCurve( nCount0)) ;
|
||||
Point3d ptCtrl = pSubCrv0->GetControlPoint( i) ;
|
||||
if ( ! bRat)
|
||||
SetControlPoint( nCount * nDegU + i, ptCtrl) ;
|
||||
@@ -4578,7 +4658,7 @@ SurfBezier::CreateByTwoCurves( const ICurve* pCurve0, const ICurve* pCurve1, int
|
||||
++ nCount0 ;
|
||||
// aggiungo la curva sulla seconda riga
|
||||
for ( int i = 1 ; i < nLastPoint ; ++i) {
|
||||
const ICurveBezier* pSubCrv1 = GetCurveBezier( pCrvU1->GetCurve( nCount1)) ;
|
||||
const ICurveBezier* pSubCrv1 = GetCurveBezier( CrvU1.GetCurve( nCount1)) ;
|
||||
Point3d ptCtrl = pSubCrv1->GetControlPoint( i) ;
|
||||
if ( ! bRat)
|
||||
SetControlPoint( nSecondRowInd + nCount * nDegU + i, ptCtrl) ;
|
||||
@@ -4600,7 +4680,7 @@ SurfBezier::CreateByTwoCurves( const ICurve* pCurve0, const ICurve* pCurve1, int
|
||||
Point3d ptP1 ; plU1.GetFirstPoint( ptP1) ;
|
||||
vector<pair<Point3d,double>> vMatch1 ;
|
||||
while ( plU1.GetNextPoint( ptP1, true)) {
|
||||
DistPointCurve dpc( ptP1, *pCrvU0, false) ;
|
||||
DistPointCurve dpc( ptP1, CrvU0, false) ;
|
||||
int nFlag = 0 ;
|
||||
double dParam ; dpc.GetParamAtMinDistPoint( 0, dParam, nFlag) ;
|
||||
Point3d ptJoint ; dpc.GetMinDistPoint( 0, ptJoint, nFlag) ;
|
||||
@@ -4622,7 +4702,7 @@ SurfBezier::CreateByTwoCurves( const ICurve* pCurve0, const ICurve* pCurve1, int
|
||||
fill( vbRep0.begin(), vbRep0.end(), false) ;
|
||||
while ( plU0.GetNextPoint( ptP0, true)) {
|
||||
// devo salvarmi se matcho più punti con lo start o l'end della curva totale
|
||||
DistPointCurve dpc( ptP0, *pCrvU1, false) ;
|
||||
DistPointCurve dpc( ptP0, CrvU1, false) ;
|
||||
int nFlag = 0 ;
|
||||
double dParam ; dpc.GetParamAtMinDistPoint( 0, dParam, nFlag) ;
|
||||
Point3d ptJoint ; dpc.GetMinDistPoint( 0, ptJoint, nFlag) ;
|
||||
@@ -4696,7 +4776,7 @@ SurfBezier::CreateByTwoCurves( const ICurve* pCurve0, const ICurve* pCurve1, int
|
||||
BOOLVECTOR vbRep1( plU1.GetPointNbr() - 1) ;
|
||||
fill( vbRep1.begin(), vbRep1.end(), false) ;
|
||||
while ( plU1.GetNextPoint( ptP1, true)) {
|
||||
DistPointCurve dpc( ptP1, *pCrvU0, false) ;
|
||||
DistPointCurve dpc( ptP1, CrvU0, false) ;
|
||||
int nFlag = 0 ;
|
||||
double dParam ; dpc.GetParamAtMinDistPoint( 0, dParam, nFlag) ;
|
||||
Point3d ptJoint ; dpc.GetMinDistPoint( 0, ptJoint, nFlag) ;
|
||||
@@ -4772,7 +4852,7 @@ SurfBezier::CreateByTwoCurves( const ICurve* pCurve0, const ICurve* pCurve1, int
|
||||
dSplit = nSplit + ( dSplit - nSplit) / (vdSplit0[z+1] - nSplit);
|
||||
}
|
||||
nUnit = nSplit ;
|
||||
pCrvU1->AddJoint( dSplit) ;
|
||||
CrvU1.AddJoint( dSplit) ;
|
||||
switch( vnAddedOrNextIsRep0[z]) {
|
||||
case 0 : if( vbRep1[nSplit])
|
||||
++ nRep1 ;
|
||||
@@ -4797,7 +4877,7 @@ SurfBezier::CreateByTwoCurves( const ICurve* pCurve0, const ICurve* pCurve1, int
|
||||
dSplit = nSplit + ( dSplit - nSplit) / (vdSplit1[z+1] - nSplit);
|
||||
}
|
||||
nUnit = nSplit ;
|
||||
pCrvU0->AddJoint( dSplit) ;
|
||||
CrvU0.AddJoint( dSplit) ;
|
||||
switch( vnAddedOrNextIsRep1[z]) {
|
||||
case 0 : if( vbRep0[nSplit])
|
||||
++ nRep0 ;
|
||||
@@ -4812,8 +4892,8 @@ SurfBezier::CreateByTwoCurves( const ICurve* pCurve0, const ICurve* pCurve1, int
|
||||
}
|
||||
}
|
||||
|
||||
nSpanU0 = pCrvU0->GetCurveCount() ;
|
||||
nSpanU1 = pCrvU1->GetCurveCount() ;
|
||||
nSpanU0 = CrvU0.GetCurveCount() ;
|
||||
nSpanU1 = CrvU1.GetCurveCount() ;
|
||||
//aggiusto i vettori delle ripetizioni in modo in modo che non arrivino mai ad essere contemporaneamente true
|
||||
int nAddedSpan = 0 ;
|
||||
int nCrv0 = 0 ;
|
||||
@@ -4879,7 +4959,7 @@ SurfBezier::CreateByTwoCurves( const ICurve* pCurve0, const ICurve* pCurve1, int
|
||||
}
|
||||
bool bRep0 = vbRep0[nCrv0] ;
|
||||
bool bRep1 = vbRep1[nCrv1] ;
|
||||
const ICurveBezier* pSubCrv0 = GetCurveBezier( pCrvU0->GetCurve( nCrv0)) ;
|
||||
const ICurveBezier* pSubCrv0 = GetCurveBezier( CrvU0.GetCurve( nCrv0)) ;
|
||||
for( int i = nAddedSpan == 0 ? 0 : 1 ; i < nLastPoint ; ++ i) {
|
||||
int nInd = i ;
|
||||
// se ho una ripetizione allora riaggiungo l'ultimo punto. Se sono ancora alla curva 0 invece devo aggiungere lo start della curva U0
|
||||
@@ -4892,7 +4972,7 @@ SurfBezier::CreateByTwoCurves( const ICurve* pCurve0, const ICurve* pCurve1, int
|
||||
}
|
||||
if ( ! bRep1)
|
||||
++ nCrv0 ;
|
||||
const ICurveBezier* pSubCrv1 = GetCurveBezier( pCrvU1->GetCurve( nCrv1)) ;
|
||||
const ICurveBezier* pSubCrv1 = GetCurveBezier( CrvU1.GetCurve( nCrv1)) ;
|
||||
for( int i = nAddedSpan == 0 ? 0 : 1 ; i < nLastPoint ; ++ i) {
|
||||
int nInd = i ;
|
||||
// se ho una ripetizione allora riaggiungo l'ultimo punto. Se sono ancora alla curva 0 invece devo aggiungere lo start della curva U0
|
||||
|
||||
+21
-22
@@ -77,8 +77,7 @@ class SurfBezier : public ISurfBezier, public IGeoObjRW
|
||||
public : // ISurf
|
||||
bool IsSimple( void) const override
|
||||
{ return true ; }
|
||||
bool IsClosed( void) const override
|
||||
{ return false ; }
|
||||
bool IsClosed( void) const override ;
|
||||
bool GetArea( double& dArea) const override ;
|
||||
bool GetVolume( double& dVolume) const override
|
||||
{ if ( &dVolume == nullptr)
|
||||
@@ -221,27 +220,27 @@ class SurfBezier : public ISurfBezier, public IGeoObjRW
|
||||
bool GetBernstein( double dU, int nDegU, DBLVECTOR& vBernU) const ;
|
||||
|
||||
private :
|
||||
ObjGraphicsMgr m_OGrMgr ; // gestore grafica dell'oggetto
|
||||
mutable SurfTriMesh* m_pSTM ; // superficie trimesh ausiliaria per la visualizzazione
|
||||
ObjGraphicsMgr m_OGrMgr ; // gestore grafica dell'oggetto
|
||||
mutable SurfTriMesh* m_pSTM ; // superficie trimesh ausiliaria per la visualizzazione
|
||||
mutable SurfTriMesh* m_pSTMRefined ; // superficie trimesh ausiliaria raffinata per i calcoli
|
||||
Status m_nStatus ; // stato
|
||||
int m_nDegU ; // grado in U
|
||||
int m_nDegV ; // grado in V
|
||||
int m_nSpanU ; // numero di pezze in U
|
||||
int m_nSpanV ; // numero di pezze in V
|
||||
bool m_bRat ; // flag di razionale/polinomiale
|
||||
bool m_bTrimmed ; // flag per presenza regione di trim
|
||||
mutable bool m_bClosedU ; // flag che indica se la superficie è chiusa lungo il parametro U
|
||||
mutable bool m_bClosedV ; // flag che indica se la superficie è chiusa lungo il parametro V
|
||||
mutable BOOLVECTOR m_vbPole ; // vettore di flag che indicano se i lati sono collassati in dei poli
|
||||
PNTVECTOR m_vPtCtrl ; // vettore dei punti di controllo
|
||||
DBLVECTOR m_vWeCtrl ; // vettore dei pesi di controllo
|
||||
SurfFlatRegion* m_pTrimReg ; // eventuale regione di trim
|
||||
int m_nTempProp[2] ; // vettore proprietà temporanee
|
||||
double m_dTempParam[2] ; // vettore parametri temporanei
|
||||
mutable vector<ICRVCOMPOPOVECTOR> m_mCCEdge ;// vettore dei vettori che contengono le curve compo degli edge della superficie nello spazio 3D
|
||||
mutable ICRVCOMPOPOVECTOR m_vCCLoop ; // vettore dei loop della superficie trimmata
|
||||
mutable int m_nIsPlanar ; // enum che indica se la superficie è piana ( -1, non è stato calcolato)
|
||||
Status m_nStatus ; // stato
|
||||
int m_nDegU ; // grado in U
|
||||
int m_nDegV ; // grado in V
|
||||
int m_nSpanU ; // numero di pezze in U
|
||||
int m_nSpanV ; // numero di pezze in V
|
||||
bool m_bRat ; // flag di razionale/polinomiale
|
||||
bool m_bTrimmed ; // flag per presenza regione di trim
|
||||
mutable bool m_bClosedU ; // flag che indica se la superficie è chiusa lungo il parametro U
|
||||
mutable bool m_bClosedV ; // flag che indica se la superficie è chiusa lungo il parametro V
|
||||
mutable BOOLVECTOR m_vbPole ; // vettore di flag che indicano se i lati sono collassati in dei poli
|
||||
PNTVECTOR m_vPtCtrl ; // vettore dei punti di controllo
|
||||
DBLVECTOR m_vWeCtrl ; // vettore dei pesi di controllo
|
||||
SurfFlatRegion* m_pTrimReg ; // eventuale regione di trim
|
||||
int m_nTempProp[2] ; // vettore proprietà temporanee
|
||||
double m_dTempParam[2] ; // vettore parametri temporanei
|
||||
mutable vector<ICRVCOMPOPOVECTOR> m_mCCEdge ; // vettore dei vettori che contengono le curve compo degli edge della superficie nello spazio 3D
|
||||
mutable ICRVCOMPOPOVECTOR m_vCCLoop ; // vettore dei loop della superficie trimmata
|
||||
mutable int m_nIsPlanar ; // enum che indica se la superficie è piana ( -1, non è stato calcolato)
|
||||
mutable DBLVECTOR m_vBernU ;
|
||||
mutable PNTVECTOR m_ptTemp ;
|
||||
mutable DBLVECTOR m_vBernV ;
|
||||
|
||||
Reference in New Issue
Block a user