EgtGeomKernel :

- correzioni ad Edges3D della Bezier. #11
This commit is contained in:
Daniele Bariletti
2024-03-22 16:11:51 +01:00
parent a6d9811595
commit 4ab4a2fc81
2 changed files with 44 additions and 56 deletions
+35 -51
View File
@@ -1452,20 +1452,9 @@ SurfBezier::UpdateEdgesFromTree( Tree& tr) const
for ( int i= 0 ; i < int( mPlEdges.size()); ++i) {
for ( int j = 0 ; j < int ( mPlEdges[i].size()) ; ++j) {
m_mCCEdge[i].emplace_back(CreateBasicCurveComposite()) ;
PolyLine pl3D ;
Point3d pt ; mPlEdges[i][j].GetFirstPoint( pt) ;
Point3d pt3D ; GetPointD1D2( pt.x / SBZ_TREG_COEFF, pt.y / SBZ_TREG_COEFF, ISurfBezier::FROM_MINUS, ISurfBezier::FROM_MINUS, pt3D) ;
int nCount = 0 ;
pl3D.AddUPoint( nCount, pt3D) ;
++ nCount ;
while( mPlEdges[i][j].GetNextPoint( pt)){
GetPointD1D2( pt.x / SBZ_TREG_COEFF, pt.y / SBZ_TREG_COEFF, ISurfBezier::FROM_MINUS, ISurfBezier::FROM_MINUS, pt3D) ;
pl3D.AddUPoint( nCount, pt3D) ;
++ nCount ;
}
if ( ! m_mCCEdge[i].back()->FromPolyLine(pl3D)) {
if ( ! m_mCCEdge[i].back()->FromPolyLine(mPlEdges[i][j]) ) {
Point3d ptStart ;
if ( ! pl3D.GetFirstPoint( ptStart))
if ( ! mPlEdges[i][j].GetFirstPoint( ptStart))
continue ;
m_mCCEdge[i].back()->FromPoint( ptStart) ;
}
@@ -1509,6 +1498,7 @@ SurfBezier::GetAuxSurf( void) const
// resetto il vettore degli edge
m_mCCEdge.clear() ;
m_mCCEdge = vector<ICRVCOMPOPVECTOR>(4) ;
m_vCCLoop.clear() ;
for ( int i = 0 ; i < (int) vTrees.size() ; ++ i) {
Point3d ptMin = std::get<0>( vTrees[i]) ;
Point3d ptMax = std::get<1>( vTrees[i]) ;
@@ -1862,34 +1852,6 @@ struct hash<TRINT> {
bool
SurfBezier::Cut( const Plane3d& plPlane, bool bSaveOnEq)
{
//// debug per controllare le autointersezione degli edge 3D
//ICRVCOMPOPOVECTOR vCCEdge ;
//GetOpenEdges3D(vCCEdge, true, -1) ;
//SelfIntersCurve sic( *vCCEdge[0]) ;
//PNTVECTOR vPnt0 ;
//DBLVECTOR vdU ;
//IntCrvCrvInfo iccInfo0 ;
//for ( int i = 0 ; sic.GetIntCrvCrvInfo( i, iccInfo0) ; ++ i) {
// if ( ! iccInfo0.bOverlap) {
// vPnt0.push_back( iccInfo0.IciA[0].ptI) ;
// vPnt0.push_back( iccInfo0.IciB[0].ptI) ;
// vdU.push_back(iccInfo0.IciA[0].dU) ;
// vdU.push_back(iccInfo0.IciB[0].dU) ;
// }
// else {
// vPnt0.push_back( iccInfo0.IciA[0].ptI) ;
// vPnt0.push_back( iccInfo0.IciA[1].ptI) ;
// vPnt0.push_back( iccInfo0.IciB[0].ptI) ;
// vPnt0.push_back( iccInfo0.IciB[1].ptI) ;
// vdU.push_back(iccInfo0.IciA[0].dU) ;
// vdU.push_back(iccInfo0.IciA[1].dU) ;
// vdU.push_back(iccInfo0.IciB[0].dU) ;
// vdU.push_back(iccInfo0.IciB[1].dU) ;
// }
//}
//int a = 0 ;
// faccio l'intersezione della trimesh ausiliaria con il piano posso ottenere: punti, curve 3d e triangoli( coplanari al piano di taglio)
// i punti li escludo
// le curve 3d le trasformo in curve 2d e le aggiungo alle curve di trim
@@ -2333,11 +2295,11 @@ SurfBezier::UnprojectPointFromStm( int nT, const Point3d& ptI, Point3d& ptSP, in
if ( ! m_mCCEdge[c][i]->GetOnlyPoint(pt))
return false ;
vInters[c] = AreSamePointApprox( pt, ptI) ? 1 : 0 ;
nInters += vInters.back() ;
nInters += vInters[c] ;
}
else {
vInters[c] = m_mCCEdge[c][i]->IsPointOn(ptI) ? 1 : 0 ;
nInters += vInters.back() ;
nInters += vInters[c] ;
}
}
}
@@ -2398,10 +2360,11 @@ SurfBezier::UnprojectPointFromStm( int nT, const Point3d& ptI, Point3d& ptSP, in
INTVECTOR vOn(3) ;
fill( vOn.begin(), vOn.end(), -1) ;
int nVertOnPole = -1 ;
INTVECTOR vEdgesClosed = { 1, 3} ;
// scorro sui vertici
for ( int p = 0 ; p < 3; ++p ) {
// scorro sugli edge
for ( int ed = 0 ; ed < 4; ++ed) {
for ( int ed : vEdgesClosed) {
// scorro sui tratti che compongono l'edge
for ( int i = 0 ; i < int( m_mCCEdge[ed].size()) ; ++i) {
if ( ! m_mCCEdge[ed][i]->IsValid()) {
@@ -2451,10 +2414,11 @@ SurfBezier::UnprojectPointFromStm( int nT, const Point3d& ptI, Point3d& ptSP, in
INTVECTOR vOn(3) ;
fill( vOn.begin(), vOn.end(), -1) ;
int nVertOnPole = -1 ;
INTVECTOR vEdgesClosed = { 0, 2} ;
// scorro sui vertici
for ( int p = 0 ; p < 3; ++p ) {
//scorro sugli edge
for (int ed = 0 ; ed < 4 ; ++ed) {
for (int ed : vEdgesClosed) {
// scorro sui tratti che compongono l'edge
for ( int i = 0 ; i < int( m_mCCEdge[ed].size()) ; ++i) {
if ( ! m_mCCEdge[ed][i]->IsValid()) {
@@ -2570,7 +2534,27 @@ SurfBezier::UnprojectPointFromStm( int nT, const Point3d& ptI, Point3d& ptSP, in
mA.col(0) << vPT[0].x, vPT[0].y , vPT[0].z ;
mA.col(1) << vPT[1].x, vPT[1].y , vPT[1].z ;
mA.col(2) << vPT[2].x, vPT[2].y , vPT[2].z ;
Eigen::Vector3d b ( ptI.x, ptI.y, ptI.z) ;
int nCount = 0 ;
Vector3d vtMod( 0, 0, 0) ;
while ( abs( mA.determinant()) < EPS_SMALL) {
if ( nCount %3 == 0) {
mA.row(0) << vPT[0].x + 1, vPT[1].x + 1, vPT[2].x + 1 ;
vtMod.x += 1 ;
}
else if ( nCount %3 == 1) {
mA.row(1) << vPT[0].y + 1, vPT[1].y + 1, vPT[2].y + 1 ;
vtMod.y += 1 ;
}
else if ( nCount %3 == 2) {
mA.row(2) << vPT[0].z + 1, vPT[1].z + 1, vPT[2].z + 1 ;
vtMod.z += 1 ;
}
++nCount ;
if ( nCount == 10)
return false ;
}
Point3d ptNewI = ptI + vtMod ;
Eigen::Vector3d b ( ptNewI.x, ptNewI.y, ptNewI.z) ;
Eigen::Vector3d x = mA.fullPivLu().solve(b) ;
// applico questa composizione alle loro coordinate parametriche
Eigen::Matrix3d mB ;
@@ -2852,8 +2836,8 @@ SurfBezier::GetLoops( ICRVCOMPOPOVECTOR& vCC, bool bLineOrBezier, int nEdge) con
// come ptStart2 prendo quello con la x maggiore
if ( ptStart2.x < ptEnd2.x)
swap( ptStart2, ptEnd2) ;
if ( (( ptEnd0.x - EPS_SMALL< ptStart2.x && ptStart2.x < ptStart0.x + EPS_SMALL) && ( ptEnd0.x - EPS_SMALL < ptEnd2.x && ptEnd2.x < ptStart0.x + EPS_SMALL)) ||
(( ptEnd2.x - EPS_SMALL < ptStart0.x && ptStart0.x < ptStart2.x + EPS_SMALL) && ( ptEnd2.x - EPS_SMALL < ptEnd0.x && ptEnd0.x < ptStart2.x + EPS_SMALL))) {
if ( (( ptEnd0.x - EPS_SMALL< ptStart2.x && ptStart2.x < ptStart0.x + EPS_SMALL) || ( ptEnd0.x - EPS_SMALL < ptEnd2.x && ptEnd2.x < ptStart0.x + EPS_SMALL)) ||
(( ptEnd2.x - EPS_SMALL < ptStart0.x && ptStart0.x < ptStart2.x + EPS_SMALL) || ( ptEnd2.x - EPS_SMALL < ptEnd0.x && ptEnd0.x < ptStart2.x + EPS_SMALL))) {
PtrOwner<ICurveLine> pCL( CreateBasicCurveLine()) ;
pCL->Set( ptStart0, ptEnd0) ;
// devo scorrere su tutte le curve che sono state ottenute dallo split del loop originale
@@ -2955,8 +2939,8 @@ SurfBezier::GetLoops( ICRVCOMPOPOVECTOR& vCC, bool bLineOrBezier, int nEdge) con
// come ptStart3 prendo quello con la y maggiore
if ( ptStart3.y < ptEnd3.y)
swap( ptStart3, ptEnd3) ;
if ( (( ptEnd1.y - EPS_SMALL< ptStart3.y && ptStart3.y < ptStart1.y + EPS_SMALL) && ( ptEnd1.y - EPS_SMALL < ptEnd3.y && ptEnd3.y < ptStart1.y + EPS_SMALL)) ||
(( ptEnd3.y - EPS_SMALL < ptStart1.y && ptStart1.y < ptStart3.y + EPS_SMALL) && ( ptEnd3.y - EPS_SMALL < ptEnd1.y && ptEnd1.y < ptStart3.y + EPS_SMALL))) {
if ( (( ptEnd1.y - EPS_SMALL< ptStart3.y && ptStart3.y < ptStart1.y + EPS_SMALL) || ( ptEnd1.y - EPS_SMALL < ptEnd3.y && ptEnd3.y < ptStart1.y + EPS_SMALL)) ||
(( ptEnd3.y - EPS_SMALL < ptStart1.y && ptStart1.y < ptStart3.y + EPS_SMALL) || ( ptEnd3.y - EPS_SMALL < ptEnd1.y && ptEnd1.y < ptStart3.y + EPS_SMALL))) {
PtrOwner<ICurveLine> pCL( CreateBasicCurveLine()) ;
pCL->Set( ptStart1, ptEnd1) ;
// devo scorrere su tutte le curve che sono state ottenute dallo split del loop originale
@@ -3000,7 +2984,7 @@ SurfBezier::GetLoops( ICRVCOMPOPOVECTOR& vCC, bool bLineOrBezier, int nEdge) con
ptOverlapE.x = 0 ;
double dStart1, dEnd1 ;
// scorro tutte le curve in cui è stato splittato il loop iniziale
for ( int j = 0 ; int( mSplitLoop[vInters1.first].size()) ; ++j ) {
for ( int j = 0 ; j < int( mSplitLoop[vInters1.first].size()) ; ++j ) {
int nIndex1 = mSplitLoop[vInters1.first][j] ;
if ( ! m_vCCLoop[nIndex1]->GetParamAtPoint( ptOverlapS, dStart1) || ! m_vCCLoop[nIndex1]->GetParamAtPoint( ptOverlapE, dEnd1))
continue ;
+9 -5
View File
@@ -3641,10 +3641,10 @@ Tree::GetEdges3D( POLYLINEMATRIX& mPLEdges)
// scorro sui gruppi di polyline che rappresentano i poligoni delle celle lungo un lato
for ( int i = 0 ; i < int( mPL.size()) ; ++i) {
mPLEdges.emplace_back() ;
mPLEdges.back().emplace_back() ;
int nPtCount = 0 ;
// scorro sui poligoni delle celle di un lato
for ( int c = 0 ; c < int( mPL[i].size()) ; ++c) {
mPLEdges.back().emplace_back() ;
Point3d pt ; mPL[i][c].GetFirstPoint( pt) ;
Point3d pt3d ;
// a seconda del lato controllo di stare scorrendo il poligono prendendo solo i punti su quel lato
@@ -3719,17 +3719,21 @@ Tree::GetEdges3D( POLYLINEMATRIX& mPLEdges)
INTVECTOR vId ;
Point3d ptNear = m_mTree.at(-1).GetBottomLeft() ;
while( m_vCEdge2D[i].second.GetChainFromNear(ptNear, false, vId) ) {
PolyLine pl2D ;
PolyLine pl3D ;
int nInd = abs( vId[0]) - 1 ;
pl2D.AddUPoint( 0, m_vCEdge2D[i].first[nInd].first) ;
Point3d pt2D = m_vCEdge2D[i].first[nInd].first ;
Point3d pt3D ; m_pSrfBz->GetPointD1D2( pt2D.x / SBZ_TREG_COEFF, pt2D.y / SBZ_TREG_COEFF, ISurfBezier::FROM_MINUS, ISurfBezier::FROM_MINUS, pt3D) ;
pl3D.AddUPoint( 0, pt3D) ;
int nCount = 1 ;
for ( int j = 1 ; j < int( vId.size()) ; ++j) {
nInd = abs( vId[j]) - 1 ;
if ( pl2D.AddUPoint( nCount, m_vCEdge2D[i].first[nInd].second))
pt2D = m_vCEdge2D[i].first[nInd].second ;
m_pSrfBz->GetPointD1D2( pt2D.x / SBZ_TREG_COEFF, pt2D.y / SBZ_TREG_COEFF, ISurfBezier::FROM_MINUS, ISurfBezier::FROM_MINUS, pt3D) ;
if ( pl3D.AddUPoint( nCount, pt3D))
++ nCount ;
}
// qui devo fare dei controlli prima di aggiungere questa polyline?
mPLEdges[i].emplace_back( pl2D) ;
mPLEdges[i].emplace_back( pl3D) ;
}
}
}