EgtGeomKernel :
- modifiche per RotationMinimizingFrame e RotationXplaneFrame - aggiornato calcolo superfici TriMesh da Swept di curva o di regione.
This commit is contained in:
+77
-114
@@ -1,5 +1,5 @@
|
||||
//----------------------------------------------------------------------------
|
||||
// EgalTech 2015-2024
|
||||
// EgalTech 2024-2024
|
||||
//----------------------------------------------------------------------------
|
||||
// File : RotationMinimizingFrame.cpp Data : 05.03.24 Versione : 2.6d1
|
||||
// Contenuto : Classe per RotationMinimizeFrame
|
||||
@@ -13,23 +13,26 @@
|
||||
|
||||
//--------------------------- Include ----------------------------------------
|
||||
#include "stdafx.h"
|
||||
#include "RotationMinimizingFrame.h"
|
||||
#include "GeoConst.h"
|
||||
#include "/EgtDev/Include/EGkRotationMinimizingFrame.h"
|
||||
|
||||
using namespace std ;
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
RotationMinimizingFrame::RotationMinimizingFrame( const ICurve* pCrv, const Frame3d& fr_Start)
|
||||
bool
|
||||
RotationMinimizingFrame::Set( const ICurve* pCrv, const Frame3d& fr_Start)
|
||||
{
|
||||
// pulisco
|
||||
Clear() ;
|
||||
// verifico i parametri
|
||||
if ( pCrv == nullptr || ! pCrv->IsValid() ||
|
||||
! fr_Start.IsValid())
|
||||
return false ;
|
||||
// assegno i parametri
|
||||
m_pCrv = pCrv->Clone() ;
|
||||
m_Frame0 = fr_Start ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
RotationMinimizingFrame::~RotationMinimizingFrame( void)
|
||||
{
|
||||
Clear() ;
|
||||
return true ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
@@ -40,7 +43,6 @@ RotationMinimizingFrame::Clear( void)
|
||||
if ( m_pCrv != nullptr)
|
||||
delete m_pCrv ;
|
||||
m_pCrv = nullptr ;
|
||||
|
||||
// reset del frame di partenza
|
||||
m_Frame0.Reset() ;
|
||||
|
||||
@@ -49,7 +51,7 @@ RotationMinimizingFrame::Clear( void)
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
RotationMinimizingFrame::IsValid()
|
||||
RotationMinimizingFrame::IsValid( void)
|
||||
{
|
||||
// controllo validità della curva
|
||||
if ( m_pCrv == nullptr || ! m_pCrv->IsValid())
|
||||
@@ -69,12 +71,11 @@ RotationMinimizingFrame::IsValid()
|
||||
return false ;
|
||||
|
||||
return true ;
|
||||
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
RotationMinimizingFrame::GetFrameAtLength( const Frame3d& frAct, const double dLenNext, Frame3d& frNext)
|
||||
RotationMinimizingFrame::GetFrameAtParam( const Frame3d& frAct, const double dParNext, Frame3d& frNext)
|
||||
{
|
||||
/*
|
||||
Double Reflection
|
||||
@@ -86,28 +87,21 @@ RotationMinimizingFrame::GetFrameAtLength( const Frame3d& frAct, const double dL
|
||||
if ( ! frAct.IsValid())
|
||||
return false ;
|
||||
|
||||
// origine del frame e versori ( ptAct, [ vt_r, vt_s, vt_t])
|
||||
// origine del frame e versori ( ptCurr, [ vtCurrR, vtCurrS, vtCurrT])
|
||||
Point3d ptCurr = frAct.Orig() ;
|
||||
Vector3d vt_r = frAct.VersX() ;
|
||||
Vector3d vt_t = frAct.VersZ() ;
|
||||
// ( vt_s è implicito )
|
||||
Vector3d vtCurrR = frAct.VersX() ;
|
||||
Vector3d vtCurrT = frAct.VersZ() ;
|
||||
|
||||
double dUNext ; // parametro sulla curva nello step successivo
|
||||
Point3d ptNext ; // punto sulla curva allo step successivo
|
||||
|
||||
// parametro (i+1)-esimo sulla curva
|
||||
if ( ! m_pCrv->GetParamAtLength( dLenNext, dUNext))
|
||||
return false ;
|
||||
|
||||
// punto (i+1)-esimo sulla curva e suo vettore tangente
|
||||
Vector3d vt_t_next ;
|
||||
if ( ! m_pCrv->GetPointD1D2( dUNext, ICurve::FROM_MINUS, ptNext, &vt_t_next) ||
|
||||
! vt_t_next.IsValid() || ! vt_t_next.Normalize()) // versore tangente
|
||||
// punto i-esimo sulla curva e suo vettore tangente
|
||||
Point3d ptNext ;
|
||||
Vector3d vtNextT ;
|
||||
if ( ! m_pCrv->GetPointD1D2( dParNext, ICurve::FROM_MINUS, ptNext, &vtNextT) ||
|
||||
! vtNextT.Normalize())
|
||||
return false ;
|
||||
|
||||
// controllo per casi degeneri
|
||||
if ( AreSamePointEpsilon( ptCurr, ptNext, EPS_ZERO) || // non esiste il piano R1
|
||||
abs(( ptNext - ptCurr) * ( vt_t_next + vt_t)) < EPS_ZERO) // non esiste il piano R2
|
||||
if ( AreSamePointEpsilon( ptCurr, ptNext, EPS_ZERO) || // non esiste il piano R1
|
||||
abs( ( ptNext - ptCurr) * ( vtNextT + vtCurrT)) < EPS_ZERO) // non esiste il piano R2
|
||||
return false ;
|
||||
|
||||
// ricavo il vettore di riflessione rispetto al piano R1
|
||||
@@ -119,11 +113,11 @@ RotationMinimizingFrame::GetFrameAtLength( const Frame3d& frAct, const double dL
|
||||
double dPar1 = vR1_norm * vR1_norm ;
|
||||
|
||||
// riflessione rispetto al piano R1 ( sistema sinistrorso L )
|
||||
Vector3d vt_r_L = vt_r - ( 2 / dPar1) * ( vR1_norm * vt_r) * vR1_norm ;
|
||||
Vector3d vt_t_L = vt_t - ( 2 / dPar1) * ( vR1_norm * vt_t) * vR1_norm ;
|
||||
Vector3d vt_r_L = vtCurrR - ( 2 / dPar1) * ( vR1_norm * vtCurrR) * vR1_norm ;
|
||||
Vector3d vt_t_L = vtCurrT - ( 2 / dPar1) * ( vR1_norm * vtCurrT) * vR1_norm ;
|
||||
|
||||
// ricavo il vettore di riflessione rispetto al piano R1
|
||||
Vector3d vR2_norm = vt_t_next - vt_t_L ;
|
||||
Vector3d vR2_norm = vtNextT - vt_t_L ;
|
||||
if ( ! vR2_norm.IsValid())
|
||||
return false ;
|
||||
|
||||
@@ -131,65 +125,47 @@ RotationMinimizingFrame::GetFrameAtLength( const Frame3d& frAct, const double dL
|
||||
double dPar2 = vR2_norm * vR2_norm ;
|
||||
// versore r del nuovo frame
|
||||
Vector3d vt_r_next = vt_r_L - ( 2 / dPar2) * ( vR2_norm * vt_r_L) * vR2_norm ;
|
||||
// versore t del nuovo frame
|
||||
Vector3d vt_s_next = vt_t_next ^ vt_r_next ;
|
||||
|
||||
// imposto il nuovo frame
|
||||
frNext.Set( ptNext, vt_r_next, vt_s_next, vt_t_next) ;
|
||||
if ( ! frNext.IsValid()) { // il frame potrebbe non essere nelle tolleranze...
|
||||
// ... sistemo ricavando il versore "s" mediante "t" ed "r" ...
|
||||
frNext.Set( ptNext, vt_t_next, vt_r_next) ;
|
||||
if ( ! frNext.IsValid())
|
||||
return false ;
|
||||
}
|
||||
|
||||
return true ;
|
||||
|
||||
return frNext.Set( ptNext, vtNextT, vt_r_next) ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
RotationMinimizingFrame::GetFramesByStep( FRAME3DVECTOR& vRMFrames, double dStep, bool bUniform)
|
||||
RotationMinimizingFrame::GetFramesByStep( double dStep, bool bUniform, FRAME3DVECTOR& vRMFrames)
|
||||
{
|
||||
// controllo validità
|
||||
if ( ! IsValid())
|
||||
return false ;
|
||||
|
||||
// controllo sullo step
|
||||
dStep = max( 10 * EPS_SMALL, dStep) ;
|
||||
|
||||
// controllo validità
|
||||
if ( ! IsValid()) {
|
||||
Clear() ;
|
||||
// lunghezza della curva
|
||||
double dCrvLen = 0. ;
|
||||
if ( ! m_pCrv->GetLength( dCrvLen) || dCrvLen < 10 * EPS_SMALL)
|
||||
return false ;
|
||||
}
|
||||
|
||||
// calcolo lunghezza della curva
|
||||
double dLen = 0. ;
|
||||
if ( ! m_pCrv->GetLength( dLen))
|
||||
return false ;
|
||||
|
||||
// in prima posizione viene inserito il frame iniziale
|
||||
vRMFrames.push_back( m_Frame0) ;
|
||||
|
||||
// ricavo il numero degli step
|
||||
int nStep = int( ceil( dLen / dStep)) ;
|
||||
if ( nStep == 0) // se non ho step allora serve sono il frame iniziale
|
||||
return true ;
|
||||
int nStep = int( ceil( dCrvLen / dStep)) ;
|
||||
double dMyStep = ( bUniform ? dCrvLen / nStep : dStep) ;
|
||||
|
||||
// lunghezza della curva identificata dal punto successivo
|
||||
double dLenNext ;
|
||||
|
||||
// step corrente
|
||||
double dMyStep = dStep ;
|
||||
if ( bUniform)
|
||||
dMyStep = dLen / nStep ;
|
||||
// inserisco il frame iniziale nel vettore dei riferimenti
|
||||
vRMFrames.clear() ;
|
||||
vRMFrames.reserve( nStep + 1) ;
|
||||
vRMFrames.push_back( m_Frame0) ;
|
||||
|
||||
// ciclo sugli step in cui la curva è suddivisa
|
||||
for ( int i = 0 ; i < nStep ; ++ i) {
|
||||
// ricavo la lunghezza della curva relativo allo step (i+1)-esimo
|
||||
dLenNext = min( dLen - 10 * EPS_SMALL, ( i + 1) * dMyStep) ;
|
||||
// ricavo il frame alla lunghezza calcolata
|
||||
Frame3d frNext ;
|
||||
if ( ! GetFrameAtLength( vRMFrames[i], dLenNext, frNext))
|
||||
for ( int i = 1 ; i <= nStep ; ++ i) {
|
||||
// ricavo il parametro della curva allo step i-esimo
|
||||
double dParNext ;
|
||||
if ( ! m_pCrv->GetParamAtLength( min( i * dMyStep, dCrvLen - EPS_SMALL), dParNext))
|
||||
return false ;
|
||||
// aggiornamento vettore dei frame
|
||||
// ricavo il frame alla posizione calcolata
|
||||
Frame3d frNext ;
|
||||
if ( ! GetFrameAtParam( vRMFrames[i-1], dParNext, frNext))
|
||||
return false ;
|
||||
// inserisco nuovo frame nel vettore dei riferimenti
|
||||
vRMFrames.push_back( frNext) ;
|
||||
}
|
||||
|
||||
@@ -198,70 +174,57 @@ RotationMinimizingFrame::GetFramesByStep( FRAME3DVECTOR& vRMFrames, double dStep
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
RotationMinimizingFrame::GetFramesBySplit( FRAME3DVECTOR& vRMFrames, int nIntervals)
|
||||
RotationMinimizingFrame::GetFramesBySplit( int nIntervals, FRAME3DVECTOR& vRMFrames)
|
||||
{
|
||||
// controllo validità
|
||||
if ( ! IsValid())
|
||||
return false ;
|
||||
|
||||
// controllo sul numero di intervalli
|
||||
nIntervals = max( 1, nIntervals) ;
|
||||
|
||||
// ricavo lo step associato
|
||||
// ricavo lo step
|
||||
double dLen = 0 ;
|
||||
if ( ! m_pCrv->GetLength( dLen))
|
||||
return false ;
|
||||
|
||||
// ricavo lo step associato
|
||||
double dStep = dLen / nIntervals ;
|
||||
|
||||
return GetFramesByStep( vRMFrames, dStep) ;
|
||||
return GetFramesByStep( dStep, true, vRMFrames) ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
RotationMinimizingFrame::GetFramesByTollerance( FRAME3DVECTOR& vRMFrames, double dTol)
|
||||
RotationMinimizingFrame::GetFramesByTolerance( double dTol, FRAME3DVECTOR& vRMFrames)
|
||||
{
|
||||
// controllo validità
|
||||
if ( ! IsValid())
|
||||
return false ;
|
||||
|
||||
// controllo sulla tolleranza
|
||||
dTol = max( EPS_SMALL, dTol) ;
|
||||
|
||||
// controllo validità
|
||||
if ( ! IsValid()) {
|
||||
Clear() ;
|
||||
return false ;
|
||||
}
|
||||
|
||||
// ricavo la PolyLine associata alla curva mediante tale tolleranza
|
||||
PolyLine PL ;
|
||||
if ( ! m_pCrv->ApproxWithLines( dTol, ANG_TOL_STD_DEG, ICurve::APL_SPECIAL, PL))
|
||||
return false ;
|
||||
int nStep = PL.GetLineNbr() ;
|
||||
|
||||
// ricavo la lunghezza della curva
|
||||
double dCrvLen = 0 ;
|
||||
if ( ! m_pCrv->GetLength( dCrvLen))
|
||||
return false ;
|
||||
// inserisco il frame iniziale nel vettore dei riferimenti
|
||||
vRMFrames.clear() ;
|
||||
vRMFrames.reserve( nStep + 1) ;
|
||||
vRMFrames.push_back( m_Frame0) ;
|
||||
|
||||
// devo calcolare il RMF su ogni punto ricavato dall'approssimazione
|
||||
// eseguo il calcolo dei frame su ogni punto ricavato dall'approssimazione
|
||||
Point3d ptCurr ;
|
||||
bool bPoint = PL.GetFirstPoint( ptCurr) ;
|
||||
bool bFirst = true ;
|
||||
while ( bPoint) {
|
||||
if ( bFirst) {
|
||||
// in prima posizione viene inserito il frame iniziale
|
||||
vRMFrames.push_back( m_Frame0) ;
|
||||
bFirst = false ;
|
||||
}
|
||||
else {
|
||||
// ricavo la lunghezza della curva al punto corrente
|
||||
double dLen = 0. ;
|
||||
if ( ! m_pCrv->GetLengthAtPoint( ptCurr, dLen))
|
||||
return false ;
|
||||
// per sicurezza controllo che sia minore della lunghezza complessiva
|
||||
dLen = min( dCrvLen - 10 * EPS_SMALL , dLen) ;
|
||||
// ricavo il Frame associato a tale lunghezza
|
||||
Frame3d frNext ;
|
||||
if ( ! GetFrameAtLength( vRMFrames.back(), dLen, frNext))
|
||||
return false ;
|
||||
vRMFrames.emplace_back( frNext) ;
|
||||
}
|
||||
// passo al punto successivo
|
||||
bPoint = PL.GetNextPoint( ptCurr) ;
|
||||
PL.GetFirstPoint( ptCurr) ;
|
||||
double dParNext ;
|
||||
Point3d ptNext ;
|
||||
while ( PL.GetNextUPoint( &dParNext, &ptNext)) {
|
||||
// ricavo il Frame associato a questa posizione
|
||||
Frame3d frNext ;
|
||||
if ( ! GetFrameAtParam( vRMFrames.back(), dParNext, frNext))
|
||||
return false ;
|
||||
vRMFrames.emplace_back( frNext) ;
|
||||
}
|
||||
|
||||
return true ;
|
||||
|
||||
Reference in New Issue
Block a user