EgtGeomKernel :
- correzione alla triangolazione delle Bezier - correzione alla conversione da NURBS razionali a Bezier - correzione della funzione Invert per le Bezier.
This commit is contained in:
+9
-6
@@ -259,14 +259,17 @@ NurbsToBezierSurface(const SNurbsSurfData& snData)
|
||||
}
|
||||
|
||||
if ( b < nU - 1 ) {
|
||||
for ( int i = snData.nDegU - mult ; i <= snData.nDegU ; ++ i) {
|
||||
for (int row = 0 ; row < snData.nCPV ; ++ row ) {
|
||||
mBC[i][row] = snData.mCP[b - snData.nDegU + i + 1][row] ;
|
||||
}
|
||||
}
|
||||
if ( snData.bRat ) {
|
||||
if ( ! snData.bRat ) {
|
||||
for ( int i = snData.nDegU - mult ; i <= snData.nDegU ; ++ i) {
|
||||
for (int row = 0 ; row < snData.nCPV ; ++ row ) {
|
||||
mBC[i][row] = snData.mCP[b - snData.nDegU + i + 1][row] ;
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
for ( int i = snData.nDegU - mult ; i <= snData.nDegU ; ++ i) {
|
||||
for (int row = 0 ; row < snData.nCPV ; ++ row ) {
|
||||
mBC[i][row] = snData.mCP[b - snData.nDegU + i + 1][row] * snData.mW[b - snData.nDegU + i + 1][row] ;
|
||||
mW[i][row] = snData.mW[b - snData.nDegU + i + 1][row] ;
|
||||
}
|
||||
}
|
||||
|
||||
+16
-21
@@ -1019,28 +1019,21 @@ SurfBezier::Invert( void)
|
||||
ResetAuxSurf() ;
|
||||
m_OGrMgr.Reset() ;
|
||||
|
||||
// inverto
|
||||
PNTVECTOR vPtCtrl = m_vPtCtrl ;
|
||||
int l = 0 ;
|
||||
for ( int i = 0 ; i <= m_nDegU ; ++ i) {
|
||||
for ( int j = 0 ; j <= m_nDegV ; ++ j) {
|
||||
int k = i + ( m_nDegU + 1) * j ;
|
||||
m_vPtCtrl[l] = vPtCtrl[k] ;
|
||||
++ l ;
|
||||
// inverto i punti del parametro U
|
||||
PNTVECTOR vPtCtrl_inv( m_vPtCtrl.size()) ;
|
||||
|
||||
for ( int j = 0 ; j < m_nDegV * m_nSpanV + 1; ++j) {
|
||||
for ( int i = 0 ; i < m_nDegU * m_nSpanU + 1; ++i) {
|
||||
vPtCtrl_inv[ i + j * ( m_nDegU * m_nSpanU + 1)] = m_vPtCtrl[ ( m_nDegU * m_nSpanU - i) + j * ( m_nDegU * m_nSpanU + 1)] ;
|
||||
}
|
||||
}
|
||||
if ( m_bRat) {
|
||||
DBLVECTOR vWeCtrl = m_vWeCtrl ;
|
||||
int lr = 0 ;
|
||||
for ( int i = 0 ; i <= m_nDegU ; ++ i) {
|
||||
for ( int j = 0 ; j <= m_nDegV ; ++ j) {
|
||||
int k = i + ( m_nDegU + 1) * j ;
|
||||
m_vWeCtrl[lr] = vWeCtrl[k] ;
|
||||
++ lr ;
|
||||
}
|
||||
}
|
||||
}
|
||||
swap( m_nDegU, m_nDegV) ;
|
||||
m_vPtCtrl = vPtCtrl_inv ;
|
||||
|
||||
// inverto la flat region di trim
|
||||
//( la specchio rispetto all'asse verticale)
|
||||
Point3d pt( m_nSpanU * SBZ_TREG_COEFF/2, 0, 0) ;
|
||||
Vector3d vt( 1, 0, 0) ;
|
||||
m_pTrimReg->Mirror( pt, vt) ;
|
||||
|
||||
return true ;
|
||||
}
|
||||
@@ -1504,13 +1497,15 @@ SurfBezier::GetAuxSurf( void) const
|
||||
Tree Tree( this, true) ;
|
||||
std::vector<std::tuple<Point3d,Point3d>> vTrees ;
|
||||
Tree.GetIndependentTrees( vTrees) ;
|
||||
static int a = 0 ;
|
||||
++a ;
|
||||
for ( int i = 0 ; i < (int) vTrees.size() ; ++ i) {
|
||||
Point3d ptMin = std::get<0>( vTrees[i]) ;
|
||||
Point3d ptMax = std::get<1>( vTrees[i]) ;
|
||||
Tree.SetSurf( this, true, ptMin, ptMax) ;
|
||||
//Tree.BuildTree_test() ; // per debug
|
||||
//Tree.BuildTree( 5 * LIN_TOL_FINE, 1) ;
|
||||
Tree.BuildTree( LIN_TOL_FINE, 0.1) ;
|
||||
Tree.BuildTree( 5 * LIN_TOL_FINE, 0.1) ;
|
||||
Tree.GetPolygons( vvPL) ;
|
||||
//Tree.GetPolygonsBasic( vPL) ; // per usare i polygon basic
|
||||
}
|
||||
|
||||
@@ -217,21 +217,24 @@ Tree::SetSurf( const SurfBezier* pSrfBz, const bool bSplitPatches, const Point3d
|
||||
m_bClosedV = true ;
|
||||
}
|
||||
for ( int i = 1 ; i < nSpanU ; ++i) {
|
||||
if ( i * SBZ_TREG_COEFF > ptMin.x && i * SBZ_TREG_COEFF < ptTop.x){
|
||||
// chiedo che il taglio disti dal bordo almeno il 2% della singola patch (1000 x 1000)
|
||||
if ( i * SBZ_TREG_COEFF > ptMin.x + 5 && i * SBZ_TREG_COEFF < ptTop.x - 5){
|
||||
m_mTree[nId].SetSplitDirVert( true) ;
|
||||
Split( nId, i * SBZ_TREG_COEFF) ;
|
||||
++ nId ;
|
||||
++ nId ;
|
||||
if ( Split( nId, i * SBZ_TREG_COEFF)) {
|
||||
++ nId ;
|
||||
++ nId ;
|
||||
}
|
||||
}
|
||||
}
|
||||
INTVECTOR vLeaves ;
|
||||
GetHeightLeaves( -1, vLeaves) ;
|
||||
for ( int nId : vLeaves) {
|
||||
for ( int j = nSpanV - 1 ; j > 0 ; --j) {
|
||||
if ( j * SBZ_TREG_COEFF > ptMin.y && j * SBZ_TREG_COEFF < ptTop.y){
|
||||
// chiedo che il taglio disti dal bordo almeno il 2% della singola patch (1000 x 1000)
|
||||
if ( j * SBZ_TREG_COEFF > ptMin.y + 5 && j * SBZ_TREG_COEFF < ptTop.y - 5){
|
||||
m_mTree[nId].SetSplitDirVert( false) ;
|
||||
Split( nId, j * SBZ_TREG_COEFF) ;
|
||||
nId = m_mTree[nId].m_nChild2 ;
|
||||
if ( Split( nId, j * SBZ_TREG_COEFF))
|
||||
nId = m_mTree[nId].m_nChild2 ;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -428,7 +431,7 @@ Tree::GetIndependentTrees( std::vector<std::tuple<Point3d,Point3d>>& vTrees)
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
void
|
||||
bool
|
||||
Tree::Split( const int& nId, const double& dSplitValue)
|
||||
{
|
||||
// controllo che lo split non venga fatto sul lato della cella
|
||||
@@ -511,11 +514,13 @@ Tree::Split( const int& nId, const double& dSplitValue)
|
||||
}
|
||||
m_mTree[m_mTree[nId].m_nChild1].SetParent( nId) ;
|
||||
m_mTree[m_mTree[nId].m_nChild2].SetParent( nId) ;
|
||||
return true ;
|
||||
}
|
||||
return false ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
void
|
||||
bool
|
||||
Tree::Split( const int& nId)
|
||||
{
|
||||
double dValue ;
|
||||
@@ -523,7 +528,7 @@ Tree::Split( const int& nId)
|
||||
dValue = ( m_mTree[nId].GetBottomLeft().x + m_mTree[nId].GetTopRight().x) / 2 ;
|
||||
else
|
||||
dValue = ( m_mTree[nId].GetBottomLeft().y + m_mTree[nId].GetTopRight().y) / 2 ;
|
||||
Split( nId, dValue) ;
|
||||
return Split( nId, dValue) ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
@@ -606,7 +611,8 @@ Tree::BuildTree( const double& dLinTol, const double& dSideMin, const double& dS
|
||||
double dCurvU = 0, dCurvV = 0 ;
|
||||
double dLenParU = ( m_mTree[nCToSplit].GetTopRight().x - m_mTree[nCToSplit].GetBottomLeft().x) / SBZ_TREG_COEFF ;
|
||||
double dLenParV = ( m_mTree[nCToSplit].GetTopRight().y - m_mTree[nCToSplit].GetBottomLeft().y) / SBZ_TREG_COEFF ;
|
||||
if ( dLenParU <= 1. / m_nDegV || dLenParV <= 1. / m_nDegU) {
|
||||
if ( dLenParU <= 1. / m_nDegV || dLenParV <= 1. / m_nDegU || Dist(m_mVert[nCToSplit][0], m_mVert[nCToSplit][2]) < dSideMin * 2
|
||||
|| Dist(m_mVert[nCToSplit][1], m_mVert[nCToSplit][3]) < dSideMin * 2) {
|
||||
double dU = ( m_mTree[nCToSplit].GetTopRight().x + m_mTree[nCToSplit].GetBottomLeft().x) / 2 / SBZ_TREG_COEFF ;
|
||||
double dV = ( m_mTree[nCToSplit].GetTopRight().y + m_mTree[nCToSplit].GetBottomLeft().y) / 2 / SBZ_TREG_COEFF ;
|
||||
double dULoc = 0.5, dVLoc = 0.5 ;
|
||||
@@ -625,8 +631,8 @@ Tree::BuildTree( const double& dLinTol, const double& dSideMin, const double& dS
|
||||
// se sto ancora guardando una cella abbastanza grande
|
||||
else{
|
||||
Point3d ptPSrf, ptP00P10, ptP10P11, ptP11P01, ptP01P00, ptPSrfMid ;
|
||||
double dStep = 1. / m_nDegU ;
|
||||
for ( double k = dStep ; k < 1 ; k = k + dStep) {
|
||||
double dStep = 1. / ( m_nDegU * 2) ;
|
||||
for ( double k = dStep ; k < 1 + EPS_SMALL ; k = k + dStep) {
|
||||
double dU = ( k * m_mTree[nCToSplit].GetTopRight().x + ( 1 - k) * m_mTree[nCToSplit].GetBottomLeft().x) / SBZ_TREG_COEFF ;
|
||||
double dV = ( m_mTree[nCToSplit].GetTopRight().y + m_mTree[nCToSplit].GetBottomLeft().y) / 2 / SBZ_TREG_COEFF ;
|
||||
m_pSrfBz->GetPointD1D2( dU, dV, ISurfBezier::FROM_MINUS, ISurfBezier::FROM_MINUS, ptPSrf) ;
|
||||
@@ -641,11 +647,11 @@ Tree::BuildTree( const double& dLinTol, const double& dSideMin, const double& dS
|
||||
dpc.GetDist( dDist) ;
|
||||
dCurvV = std::max( dCurvV, dDist) ;
|
||||
}
|
||||
dStep = 1. / m_nDegV ;
|
||||
for ( double k = dStep ; k < 1 ; k = k + dStep) {
|
||||
dStep = 1. / ( m_nDegV * 2) ;
|
||||
for ( double k = dStep ; k < 1 + EPS_SMALL ; k = k + dStep) {
|
||||
double dU = ( m_mTree[nCToSplit].GetTopRight().x + m_mTree[nCToSplit].GetBottomLeft().x) / 2 / SBZ_TREG_COEFF ;
|
||||
double dV = ( k * m_mTree[nCToSplit].GetTopRight().y + ( 1 - k) * m_mTree[nCToSplit].GetBottomLeft().y) / SBZ_TREG_COEFF ;
|
||||
if ( k == 0.5)
|
||||
if ( k == 0.5 && ! AreSamePointApprox( ORIG, ptPSrfMid))
|
||||
ptPSrf = ptPSrfMid ;
|
||||
else
|
||||
m_pSrfBz->GetPointD1D2( dU, dV, ISurfBezier::FROM_MINUS, ISurfBezier::FROM_MINUS, ptPSrf) ;
|
||||
|
||||
@@ -149,8 +149,8 @@ public :
|
||||
bool GetLeaves ( std::vector<Cell>& vLeaves) const ;
|
||||
|
||||
private :
|
||||
void Split( const int& nId, const double& dSplitValue) ; // funzione di split di una cella al parametro indicato nella direzione data da bVert
|
||||
void Split( const int& nId) ; // funzione di split di una cella dell'albero a metà nella direzione data da bVert
|
||||
bool Split( const int& nId, const double& dSplitValue) ; // funzione di split di una cella al parametro indicato nella direzione data da bVert
|
||||
bool Split( const int& nId) ; // funzione di split di una cella dell'albero a metà nella direzione data da bVert
|
||||
void Balance () ; // creo rami in modo che tutte tutte le foglie abbiano come adiacenti foglie ad una profonditù di +- 1
|
||||
int GetHeightLeaves ( const int& nId, INTVECTOR& vnLeaves, int d = 0) const ; // altezza del subtree a partire dal nodo nId
|
||||
int GetDepth ( const int& nId, const int& nRef) const ; // livello del nodo nId
|
||||
|
||||
Reference in New Issue
Block a user