diff --git a/CAvToolSurfTm.cpp b/CAvToolSurfTm.cpp index 9b14181..1484e0e 100644 --- a/CAvToolSurfTm.cpp +++ b/CAvToolSurfTm.cpp @@ -17,9 +17,14 @@ #include "DistPointLine.h" #include "DllMain.h" #include "/EgtDev/Include/EGnStringUtils.h" +#include +#include using namespace std ; +//---------------------------------------------------------------------------- +const int STEP_PE = 50 ; + //---------------------------------------------------------------------------- ICAvToolSurfTm* CreateCAvToolSurfTm( void) @@ -32,7 +37,7 @@ CreateCAvToolSurfTm( void) // CAvToolSurfTm //---------------------------------------------------------------------------- CAvToolSurfTm::CAvToolSurfTm( void) - : m_pSTm( nullptr), m_Tool( false), m_nTriaCAv( 0) + : m_pSTm( nullptr), m_Tool( false) { } @@ -98,10 +103,74 @@ CAvToolSurfTm::TestPath( PNTULIST& lPntM, const Vector3d& vtDir, double dLinTol) // Predispongo Hash Grid if ( ! PrepareHashGrid()) return false ; + // Determino il numero di punti del path + m_nTotPnt = int( lPntM.size()) ; + // Recupero il numero massimo di thread concorrenti + int nThreadMax = thread::hardware_concurrency() ; + bool bOk = true ; + // Se un solo thread o pochi punti + if ( nThreadMax <= 1 || m_nTotPnt < 500) { + bOk = TestSubPath( -1, lPntM, vtDir, dLinTol) ; + ProcessEvents( 100, 0) ; + } + // altrimenti + else { + const int MAX_PARTS = 16 ; + PNTULIST vlPntM[MAX_PARTS] ; + // divido la lista in parti + int nPartCnt = min( nThreadMax, MAX_PARTS) ; + int nPartDim = m_nTotPnt / nPartCnt ; + for ( int i = nPartCnt - 1 ; i > 0 ; -- i) { + auto itSplit = prev( lPntM.end(), nPartDim) ; + vlPntM[i].splice( vlPntM[i].end(), lPntM, itSplit, lPntM.end()) ; + vlPntM[i].push_front( lPntM.back()) ; + } + vlPntM[0].splice( vlPntM[0].end(), lPntM) ; + // processo le parti + m_nCurrPnt = 0 ; + m_bBreak = false ; + future vRes[MAX_PARTS] ; + for ( int i = 0 ; i < nPartCnt ; ++ i) + vRes[i] = async( launch::any, &CAvToolSurfTm::TestSubPath, this, i, ref( vlPntM[i]), vtDir, dLinTol) ; + // attendo i risultati + int nFin = 0 ; + int nNextPE = 0 ; + while ( nFin < nPartCnt) { + for ( int i = 0 ; i < nPartCnt ; ++ i) { + if ( vRes[i].valid() && vRes[i].wait_for( chrono::milliseconds{ 1}) == future_status::ready) { + bOk = vRes[i].get() && bOk ; + ++ nFin ; + } + } + if ( m_nCurrPnt > nNextPE) { + int nRes = ProcessEvents( int( m_nCurrPnt * 100. / m_nTotPnt), 10) ; + nNextPE += STEP_PE ; + if ( nRes == 0) + m_bBreak = true ; + } + } + // unisco le liste risultati + for ( int i = 0 ; i < nPartCnt ; ++ i) { + if ( i > 0) + lPntM.pop_back() ; + lPntM.splice( lPntM.end(), vlPntM[i]) ; + } + ProcessEvents( 100, 0) ; + } + // pulisco HashGrid 2d + m_HGrids.Clear() ; + return bOk ; +} + +//---------------------------------------------------------------------------- +bool +CAvToolSurfTm::TestSubPath( int nId, PNTULIST& lPntM, const Vector3d& vtDir, double dLinTol) +{ + // Se lista vuota, non devo fare alcunché + if ( lPntM.empty()) + return true ; // Ciclo sui punti int nCount = int( lPntM.size()) ; - int nCurr = 0 ; - m_nTriaCAv = 0 ; Point3d ptPrev, ptCurr ; auto itPntMPrev = lPntM.end() ; auto itPntMCurr = lPntM.begin() ; @@ -109,11 +178,8 @@ CAvToolSurfTm::TestPath( PNTULIST& lPntM, const Vector3d& vtDir, double dLinTol) // verifico il punto ptCurr = itPntMCurr->first ; itPntMCurr->second = MyTestPositionHG( itPntMCurr->first, vtDir) ; - if ( itPntMCurr->second < - EPS_SMALL) { - // pulisco HashGrid 2d - m_HGrids.Clear() ; + if ( itPntMCurr->second < - EPS_SMALL) return false ; - } // se esiste il punto precedente devo verificare il medio if ( itPntMPrev != lPntM.end()) { MyTestMidPointHG( lPntM, itPntMPrev, itPntMCurr, ptPrev, ptCurr, vtDir, dLinTol, 1) ; @@ -122,24 +188,22 @@ CAvToolSurfTm::TestPath( PNTULIST& lPntM, const Vector3d& vtDir, double dLinTol) ptPrev = ptCurr ; itPntMPrev = itPntMCurr ; ++ itPntMCurr ; - // gestione eventi (ogni 50 punti) - ++ nCurr ; - if ( ( nCurr % 50) == 0) { - int nRes = ProcessEvents( int( nCurr * 100. / nCount), 0) ; - if ( nRes == 0) { - // pulisco HashGrid 2d - m_HGrids.Clear() ; - return false ; + ++ m_nCurrPnt ; + // se singolo thread + if ( nId == -1) { + // gestione eventi (ogni STEP_PE punti) + if (( m_nCurrPnt % STEP_PE) == 0) { + int nRes = ProcessEvents( int( m_nCurrPnt * 100. / m_nTotPnt), 0) ; + if ( nRes == 0) + return false ; } } + // altrimenti multithread + else { + if ( m_bBreak) + return false ; + } } - // evento completamento - ProcessEvents( 100, 0) ; - // pulisco HashGrid 2d - m_HGrids.Clear() ; - // Per debug - string sLog = "TriaCav=" + ToString( m_nTriaCAv) ; - LOG_INFO( GetEGkLogger(), sLog.c_str()) ; return true ; } @@ -185,7 +249,6 @@ CAvToolSurfTm::MyTestPosition( Point3d& ptT, const Vector3d& vtDir) for ( int nTria = m_pSTm->GetFirstTriangle( Tria) ; nTria != SVT_NULL ; nTria = m_pSTm->GetNextTriangle( nTria, Tria)) { - ++ m_nTriaCAv ; double dDist = CAvToolTriangle( m_Tool, ptT, vtDir, Tria, m_frMove.VersZ()) ; if ( dDist < - EPS_SMALL) return -1 ; @@ -239,7 +302,6 @@ CAvToolSurfTm::MyTestPositionHG( Point3d& ptT, const Vector3d& vtDir) Triangle3d Tria ; if ( ! m_pSTm->GetTriangle( nT, Tria)) return -1 ; - ++ m_nTriaCAv ; double dDist = CAvToolTriangle( m_Tool, ptT, vtDir, Tria, m_frMove.VersZ()) ; if ( dDist > EPS_SMALL) { dTotDist += dDist ; diff --git a/CAvToolSurfTm.h b/CAvToolSurfTm.h index fd42100..f4caa27 100644 --- a/CAvToolSurfTm.h +++ b/CAvToolSurfTm.h @@ -17,6 +17,7 @@ #include "SurfTriMesh.h" #include "Tool.h" #include "/EgtDev/Include/EGkCAvToolSurfTm.h" +#include //----------------------------------------------------------------------------- @@ -42,6 +43,7 @@ class CAvToolSurfTm : public ICAvToolSurfTm CAvToolSurfTm( void) ; private : + bool TestSubPath( int nId, PNTULIST& lPntM, const Vector3d& vtDir, double dLinTol) ; double MyTestPosition( Point3d& ptT, const Vector3d& vtDir) ; double MyTestPositionHG( Point3d& ptT, const Vector3d& vtDir) ; bool MyTestMidPointHG( PNTULIST& lPntM, const PNTULIST::iterator& itPntMPrev, const PNTULIST::iterator& itPntMCurr, @@ -53,5 +55,7 @@ class CAvToolSurfTm : public ICAvToolSurfTm const SurfTriMesh* m_pSTm ; HashGrids2d m_HGrids ; Tool m_Tool ; - int m_nTriaCAv ; + int m_nTotPnt ; + std::atomic m_nCurrPnt ; + std::atomic m_bBreak ; } ; diff --git a/CAvToolTriangle.cpp b/CAvToolTriangle.cpp index 635ed37..7af19c7 100644 --- a/CAvToolTriangle.cpp +++ b/CAvToolTriangle.cpp @@ -1,7 +1,7 @@ //---------------------------------------------------------------------------- // EgalTech 2018-2018 //---------------------------------------------------------------------------- -// File : CAvToolTriangle.cpp Data : 19.07.18 Versione : 1.9g2 +// File : CAvToolTriangle.cpp Data : 19.07.18 Versione : 1.9h1 // Contenuto : Implementazione delle funzioni ToolTriangleCollisionAvoid. // // @@ -34,7 +34,7 @@ GetTopTapFromPrevCurve( const ICurve* pPrevCurve) const Point3d& ptPrevStart = pPrevLine->GetStart() ; const Point3d& ptPrevEnd = pPrevLine->GetEnd() ; if ( abs( ptPrevStart.y - ptPrevEnd.y) > EPS_SMALL || - ptPrevStart.x > ptPrevEnd.x) + ptPrevStart.x > ptPrevEnd.x) return true ; } else if ( pPrevCurve->GetType() == CRV_ARC) { @@ -56,7 +56,8 @@ GetBotTapFromNextCurve( const ICurve* pNextCurve) const ICurveLine* pNextLine = GetCurveLine( pNextCurve) ; const Point3d& ptNextStart = pNextLine->GetStart() ; const Point3d& ptNextEnd = pNextLine->GetEnd() ; - if ( abs( ptNextStart.y - ptNextEnd.y) > EPS_SMALL || ptNextStart.x < ptNextEnd.x) + if ( abs( ptNextStart.y - ptNextEnd.y) > EPS_SMALL || + ptNextStart.x < ptNextEnd.x) return true ; } else if ( pNextCurve->GetType() == CRV_ARC) { @@ -77,6 +78,9 @@ double CAvToolTriangle( const Tool& tlTool, const Point3d& ptToolOrig, const Vector3d& vtToolAx, const Triangle3d& trTria, const Vector3d& vtMove) { + // Non ha senso che il movimento sia in direzione "opposta" a quella dell'asse utensile + if ( vtMove * vtToolAx < - EPS_ZERO) + return -1. ; // Se avvicinamento non devo fare nulla if ( vtMove * trTria.GetN() < - EPS_ZERO) return 0. ; @@ -85,9 +89,15 @@ CAvToolTriangle( const Tool& tlTool, const Point3d& ptToolOrig, const Vector3d& // parametri geometrici double dHeigth = tlTool.GetHeigth() ; double dRadius = tlTool.GetRadius() ; - // distanza di allontanamento del cilindro - double dDist = CAvCylinderTriangle( ptToolOrig, vtToolAx, dHeigth, dRadius, trTria, vtMove, false, false) ; - return dDist ; + // prima determino l'allontanamento del disco inferiore + double dDist = CAvDiskTriangle( ptToolOrig - dHeigth * vtToolAx, vtToolAx, dRadius, trTria, vtMove) ; + if ( dDist < - EPS_SMALL) + return dDist ; + // poi verifico quello del cilindro (tenendo conto di quanto è stata allontanato il disco) + double dDist2 = CAvCylinderTriangle( ptToolOrig + dDist * vtMove, vtToolAx, dHeigth, dRadius, trTria, vtMove, false, false) ; + if ( dDist2 < - EPS_SMALL) + return dDist2 ; + return ( dDist + dDist2) ; } // se utensile sferico else if ( tlTool.GetType() == Tool::BALLMILL) { @@ -102,7 +112,7 @@ CAvToolTriangle( const Tool& tlTool, const Point3d& ptToolOrig, const Vector3d& // poi verifico quello del cilindro (tenendo conto di quanto è stata allontanata la sfera) if ( dCylHeigth < EPS_SMALL) return dDist ; - Point3d ptCylOrig = ptToolOrig + vtMove * max( dDist, 0.) ; + Point3d ptCylOrig = ptToolOrig + vtMove * dDist ; double dDist2 = CAvCylinderTriangle( ptCylOrig, vtToolAx, dCylHeigth, dRadius, trTria, vtMove, false, true) ; if ( dDist2 < - EPS_SMALL) return dDist2 ; @@ -111,21 +121,28 @@ CAvToolTriangle( const Tool& tlTool, const Point3d& ptToolOrig, const Vector3d& // se utensile a naso di toro else if ( tlTool.GetType() == Tool::BULLNOSEMILL) { // parametri geometrici - double dCylHeigth = tlTool.GetHeigth() - tlTool.GetTipHeigth() ; - Point3d ptTorusCen = ptToolOrig - dCylHeigth * vtToolAx ; - // prima determino l'allontanamento del toro - double dDist = CAvTorusTriangle( ptTorusCen, vtToolAx, tlTool.GetRadius() - tlTool.GetCornRadius(), tlTool.GetCornRadius(), - trTria, vtMove, true, false) ; + double dCylHeigth = tlTool.GetHeigth() - tlTool.GetTipHeigth() ; + // prima determino l'allontanamento del disco inferiore + double dDist = CAvDiskTriangle( ptToolOrig - tlTool.GetHeigth() * vtToolAx, vtToolAx, tlTool.GetTipRadius(), + trTria, vtMove) ; if ( dDist < - EPS_SMALL) return dDist ; - // poi verifico quello del cilindro (tenendo conto di quanto è stata allontanato il toro) - if ( dCylHeigth < EPS_SMALL) - return dDist ; - Point3d ptCylOrig = ptToolOrig + vtMove * max( dDist, 0.) ; - double dDist2 = CAvCylinderTriangle( ptCylOrig, vtToolAx, dCylHeigth, tlTool.GetRadius(), trTria, vtMove, false, true) ; + // poi verifico quello del toro (tenendo conto di quanto è stata allontanato il disco) + Point3d ptTorusCen = ptToolOrig - dCylHeigth * vtToolAx ; + double dDist2 = CAvTorusTriangle( ptTorusCen + dDist * vtMove, vtToolAx, + tlTool.GetRadius() - tlTool.GetCornRadius(), tlTool.GetCornRadius(), + trTria, vtMove, true, false) ; if ( dDist2 < - EPS_SMALL) return dDist2 ; - return ( dDist + dDist2) ; + // infine verifico quello del cilindro (tenendo conto dei precedenti allontanamenti) + if ( dCylHeigth < EPS_SMALL) + return ( dDist + dDist2) ; + Point3d ptCylOrig = ptToolOrig + vtMove * ( dDist + dDist2) ; + double dDist3 = CAvCylinderTriangle( ptCylOrig, vtToolAx, dCylHeigth, tlTool.GetRadius(), + trTria, vtMove, false, true) ; + if ( dDist3 < - EPS_SMALL) + return dDist3 ; + return ( dDist + dDist2 + dDist3) ; } // se utensile conico else if ( tlTool.GetType() == Tool::CONEMILL) { @@ -143,18 +160,25 @@ CAvToolTriangle( const Tool& tlTool, const Point3d& ptToolOrig, const Vector3d& double dMinR = min( tlTool.GetRadius(), tlTool.GetTipRadius()) ; double dMaxR = max( tlTool.GetRadius(), tlTool.GetTipRadius()) ; double dCylHeigth = tlTool.GetHeigth() - tlTool.GetTipHeigth() ; - // prima determino l'allontanamento del cono - double dDist = CAvTrConeTriangle( ptMinBase, vtConeAx, dMinR, dMaxR, tlTool.GetTipHeigth(), trTria, vtMove, true, false) ; + // prima determino l'allontanamento del disco inferiore + double dDist = CAvDiskTriangle( ptToolOrig - tlTool.GetHeigth() * vtToolAx, vtToolAx, tlTool.GetTipRadius(), + trTria, vtMove) ; if ( dDist < - EPS_SMALL) return dDist ; - // poi verifico quello del cilindro (tenendo conto di quanto è stata allontanato il cono) - if ( dCylHeigth < EPS_SMALL) - return dDist ; - Point3d ptCylOrig = ptToolOrig + vtMove * max( dDist, 0.) ; - double dDist2 = CAvCylinderTriangle( ptCylOrig, vtToolAx, dCylHeigth, tlTool.GetRadius(), trTria, vtMove, false, true) ; + // poi verifico quello del cono (tenendo conto di quanto è stata allontanato il disco) + double dDist2 = CAvTrConeTriangle( ptMinBase + dDist * vtMove, vtConeAx, dMinR, dMaxR, tlTool.GetTipHeigth(), + trTria, vtMove, true, false) ; if ( dDist2 < - EPS_SMALL) return dDist2 ; - return ( dDist + dDist2) ; + // infine verifico quello del cilindro (tenendo conto dei precedenti allontanamenti) + if ( dCylHeigth < EPS_SMALL) + return ( dDist + dDist2) ; + Point3d ptCylOrig = ptToolOrig + vtMove * ( dDist + dDist2) ; + double dDist3 = CAvCylinderTriangle( ptCylOrig, vtToolAx, dCylHeigth, tlTool.GetRadius(), + trTria, vtMove, false, true) ; + if ( dDist3 < - EPS_SMALL) + return dDist3 ; + return ( dDist + dDist2 + dDist3) ; } // se utensile generico else if ( tlTool.GetType() == Tool::GEN) { @@ -164,13 +188,14 @@ CAvToolTriangle( const Tool& tlTool, const Point3d& ptToolOrig, const Vector3d& Point3d ptCompOrig = ptToolOrig - tlTool.GetHeigth() * vtToolAx ; // analizzo le curve del profilo a partire dall'ultima const CurveComposite* pToolProfile = tlTool.GetOutline() ; - const ICurve* pCurve = pToolProfile->GetLastCurve() ; + int nCrv = pToolProfile->GetCurveCount() - 1 ; + const ICurve* pCurve = pToolProfile->GetCurve( nCrv) ; const ICurve* pNextCurve = nullptr ; while ( pCurve != nullptr) { // distanza di allontanamento del tratto corrente double dDist2 = 0 ; // curva precedente - const ICurve* pPrevCurve = pToolProfile->GetPrevCurve() ; + const ICurve* pPrevCurve = pToolProfile->GetCurve( -- nCrv) ; // Se segmento if ( pCurve->GetType() == CRV_LINE) { // Recupero gli estremi @@ -179,7 +204,14 @@ CAvToolTriangle( const Tool& tlTool, const Point3d& ptToolOrig, const Vector3d& const Point3d& ptEnd = pLine->GetEnd() ; // Ne determino l'altezza double dHeight = abs( ptStart.y - ptEnd.y) ; - if ( dHeight > EPS_SMALL) { + if ( dHeight <= EPS_SMALL) { + // solo se disco verso il basso dell'utensile + if ( ptStart.x > ptEnd.x) { + double dRadius = max( ptStart.x, ptEnd.x) ; + dDist2 = CAvDiskTriangle( ptCompOrig, vtToolAx, dRadius, trTria, vtMove) ; + } + } + else { // Verifiche curva precedente per eventuale tappo sopra bool bTop = GetTopTapFromPrevCurve( pPrevCurve) ; // Verifiche curva successiva per eventuale tappo sotto @@ -361,7 +393,7 @@ SphereSegmentLeakDist( const Point3d& ptSpheCen, double dSpheRad, { // Controllo con l'interno del segmento double dU[2] ; - int nTanPointNum = SphereLineTangentPoints( ptSpheCen, dSpheRad, ptSeg, vtSegDir, dSegLen, vtMove, dU[0], dU[1]) ; + int nTanPointNum = SphereLineTangentPoints( ptSpheCen, dSpheRad - EPS_SMALL, ptSeg, vtSegDir, dSegLen, vtMove, dU[0], dU[1]) ; double dLeakDistIn = 0. ; for ( int nSol = 0 ; nSol < nTanPointNum && nTanPointNum != 3 ; ++ nSol) { if ( dU[nSol] < 0.) @@ -404,71 +436,14 @@ double CAvCylinderTriangle( const Point3d& ptCylOrig, const Vector3d& vtCylAx, double dHeigth, double dRad, const Triangle3d& trTria, const Vector3d& vtMove, bool bTop, bool bBot) { - // Classificazione del moto - int nMotionType = 0 ; - if ( AreSameVectorApprox( vtCylAx, vtMove)) - nMotionType = 1 ; - else if ( AreOppositeVectorApprox( vtCylAx, vtMove)) - nMotionType = 2 ; - else if ( AreOrthoApprox( vtCylAx, vtMove)) - nMotionType = 3 ; - // Movimento lungo la direzione dell'asse del cilindro - if ( nMotionType == 1 || nMotionType == 2) { - // In questo caso il problema si riduce alla determinazione della distanza di allontanamento - // del disco all'estremità opposta rispetto alla direzione di moto. - // Il punto base di questo disco viene così calcolato - Point3d ptBase = ptCylOrig ; - if ( nMotionType == 1) - ptBase -= dHeigth * vtCylAx ; - // Valuto le distanze con segno dei vertici dal piano del disco : - // se sono tutte negative non interferiscono. - double dDistV[3] ; - dDistV[0] = PointPlaneSignedDist( trTria.GetP( 0), ptBase, vtMove) ; - dDistV[1] = PointPlaneSignedDist( trTria.GetP( 1), ptBase, vtMove) ; - dDistV[2] = PointPlaneSignedDist( trTria.GetP( 2), ptBase, vtMove) ; - double dMaxDistV = max( dDistV[0], max( dDistV[1], dDistV[2])) ; - if ( dMaxDistV < 0.) - return 0. ; - // Se tutti i punti distano dall'asse di movimento meno del raggio, l'ultimo - // punto di contatto deve essere un vertice del triangolo. - double dSqRad = dRad * dRad ; - bool bInV[3] ; - bInV[0] = ( GetPointLineSqDist( trTria.GetP( 0), ptBase, vtMove) < dSqRad) ; - bInV[1] = ( GetPointLineSqDist( trTria.GetP( 1), ptBase, vtMove) < dSqRad) ; - bInV[2] = ( GetPointLineSqDist( trTria.GetP( 2), ptBase, vtMove) < dSqRad) ; - if ( bInV[0] && bInV[1] && bInV[2]) - return max( dMaxDistV, 0.) ; - // Distanza di allontanamento dall'interno del triangolo - double dMaxDistI = DiskTriaInteriorLeakDistLongMot( ptBase, dRad, trTria, vtMove) ; - if ( dMaxDistI > EPS_SMALL) - return dMaxDistI ; - // Ciclo sui segmenti del triangolo e calcolo la loro distanza di allontanamento, calcolo - // anche la distanza di allontanamento dai vertici distanti dall'asse meno del raggio. - double dMaxDistVS = 0. ; - for ( int nVS = 0 ; nVS < 3 ; ++ nVS) { - // Vertici - if ( bInV[nVS] && dDistV[nVS] > dMaxDistVS) - dMaxDistVS = dDistV[nVS] ; - // Se un lato del triangolo ha entrambi gli estremi con distanza negativa dal piano del disco, - // non può interferire con esso. - int nVE = ( nVS + 1) % 3 ; - if ( dDistV[nVS] < 0 && dDistV[nVE] < 0) - continue ; - // Versore e lunghezza del segmento - Vector3d vtSeg = trTria.GetP( nVE) - trTria.GetP( nVS) ; - double dSegLen = vtSeg.Len() ; - vtSeg /= dSegLen ; - // Distanza dal piano del segmento corrente - double dCurDist = DiskSegmentLeakDistLongMot( ptBase, dRad, trTria.GetP( nVS), vtSeg, dSegLen, vtMove) ; - if ( dCurDist > dMaxDistVS) - dMaxDistVS = dCurDist ; - } - return dMaxDistVS ; + if ( AreSameVectorApprox( vtCylAx, vtMove)) { + // la distanza di fuga è determinata dal disco + // o dai componenti sotto il cilindro. + return 0. ; } - // Movimento perpendicolare all'asse del cilindro - else if ( nMotionType == 3) { + else if ( AreOrthoApprox( vtCylAx, vtMove)) { double dLeakDist = 0. ; // INTERNO : se distanza di allontanamento da interno è positiva, abbiamo finito Point3d ptTopCont, ptBotCont ; @@ -516,9 +491,11 @@ CAvCylinderTriangle( const Point3d& ptCylOrig, const Vector3d& vtCylAx, double d } return dLeakDist ; } - // Movimento generico - else + else if ( vtMove * vtCylAx > 0) + return 0. ; + // Errore + else return -1. ; } @@ -649,14 +626,19 @@ CAvTrConeTriangle( const Point3d& ptMinBase, const Vector3d& vtTrConeAx, double if ( AreSameOrOppositeVectorApprox( vtTrConeAx, vtMove)) { // Verifica preliminare che la fetta di spazio delimitata dal piano sotto del cono rispetto alla direzione // di allontanamento non sia già sopra al triangolo (tutti i vertici del triangolo sono sotto). - Point3d ptBase = ptMinBase ; + Point3d ptInfLim = ptMinBase ; if ( AreOppositeVectorApprox( vtTrConeAx, vtMove)) - ptBase += dTrConeH * vtTrConeAx ; - double dMaxDistV = PointPlaneSignedDist( trTria.GetP( 0), ptBase, vtMove) ; - dMaxDistV = max( dMaxDistV, PointPlaneSignedDist( trTria.GetP( 1), ptBase, vtMove)) ; - dMaxDistV = max( dMaxDistV, PointPlaneSignedDist( trTria.GetP( 2), ptBase, vtMove)) ; + ptInfLim += dTrConeH * vtTrConeAx ; + double dMaxDistV = PointPlaneSignedDist( trTria.GetP( 0), ptInfLim, vtMove) ; + dMaxDistV = max( dMaxDistV, PointPlaneSignedDist( trTria.GetP( 1), ptInfLim, vtMove)) ; + dMaxDistV = max( dMaxDistV, PointPlaneSignedDist( trTria.GetP( 2), ptInfLim, vtMove)) ; if ( dMaxDistV < 0.) return 0. ; + bool bInside[3] = { GetPointLineSqDist( trTria.GetP( 0), ptMinBase, vtMove) < dMinBaseR * dMinBaseR, + GetPointLineSqDist( trTria.GetP( 1), ptMinBase, vtMove) < dMinBaseR * dMinBaseR, + GetPointLineSqDist( trTria.GetP( 2), ptMinBase, vtMove) < dMinBaseR * dMinBaseR} ; + if ( bInside[0] && bInside[1] && bInside[2]) + return 0. ; // Distanza di allontanamento dall'interno double dInnLeakDist = TrConeTriangleInteriorLeakDistLongMot( ptMinBase, vtTrConeAx, dMinBaseR, dMaxBaseR, dTrConeH, trTria, vtMove) ; @@ -665,10 +647,12 @@ CAvTrConeTriangle( const Point3d& ptMinBase, const Vector3d& vtTrConeAx, double // Distanza di allontanamento dai vertici e lati double dOutLeakDist = 0 ; for ( int nV = 0 ; nV < 3 ; ++ nV) { + if ( bInside[nV] && bInside[( nV + 1) % 3]) + continue ; // dal vertice double dCurVertDist = TrConePointLeakDistLongMot( ptMinBase, vtTrConeAx, dMinBaseR, dMaxBaseR, dTrConeH, trTria.GetP( nV), vtMove) ; - dOutLeakDist = max( dCurVertDist, dOutLeakDist) ; + dOutLeakDist = max( dCurVertDist, dOutLeakDist) ; // dal lato Vector3d vtSeg = trTria.GetP( ( nV + 1) % 3) - trTria.GetP( nV) ; double dSegLen = vtSeg.Len() ; @@ -706,8 +690,8 @@ CAvTrConeTriangle( const Point3d& ptMinBase, const Vector3d& vtTrConeAx, double return dLeakDist ; } // Movimento generico - else - return -1 ; + else + return 0. ; } //---------------------------------------------------------------------------- @@ -716,9 +700,9 @@ TrConePointLeakDistLongMot( const Point3d& ptMinBase, const Vector3d& vtTrConeAx double dTrConeH, const Point3d& ptP, const Vector3d& vtMove) { double dPointAxisSqDist = GetPointLineSqDist( ptP, ptMinBase, vtTrConeAx) ; - if ( dPointAxisSqDist > dMaxBaseR * dMaxBaseR + 2 * dMaxBaseR * EPS_SMALL) + if ( dPointAxisSqDist > dMaxBaseR * dMaxBaseR || dPointAxisSqDist < dMinBaseR * dMinBaseR) return 0. ; - else if ( dPointAxisSqDist > dMinBaseR * dMinBaseR + 2 * dMinBaseR * EPS_SMALL) { + else { double dMinBaseLeakDist = PointPlaneSignedDist( ptP, ptMinBase, vtMove) ; double dMaxBaseLeakDist = PointPlaneSignedDist( ptP, ptMinBase + dTrConeH * vtTrConeAx, vtMove) ; if ( dMinBaseLeakDist < - EPS_SMALL && dMaxBaseLeakDist < - EPS_SMALL) @@ -735,11 +719,7 @@ TrConePointLeakDistLongMot( const Point3d& ptMinBase, const Vector3d& vtTrConeAx else return max( PointPlaneSignedDist( ptP, ptMinBase + dTrConeH * vtTrConeAx, vtMove), 0.) ; } - else { - double dMinBaseLeakDist = PointPlaneSignedDist( ptP, ptMinBase, vtMove) ; - double dMaxBaseLeakDist = PointPlaneSignedDist( ptP, ptMinBase + dTrConeH * vtTrConeAx, vtMove) ; - return max( max( dMinBaseLeakDist, dMaxBaseLeakDist), 0.) ; - } + } //---------------------------------------------------------------------------- @@ -869,6 +849,11 @@ TrConeSegmentLeakDistOrtMot( const Point3d& ptMinBase, const Vector3d& vtTrConeA { double dTopTol = bTop ? EPS_SMALL : - EPS_SMALL ; double dBotTol = bBot ? - EPS_SMALL : EPS_SMALL ; + double dStH = ( ptSeg - ptMinBase) * vtTrConeAx ; + double dEnH = ( ptSeg + dSegLen * vtSeg - ptMinBase) * vtTrConeAx ; + if ( ( dStH < dBotTol && dEnH < dBotTol) || + ( dStH > dTrConeH + dTopTol && dEnH > dTrConeH + dTopTol)) + return 0. ; // Distanza di allontanamento delle basi Point3d ptMaxBase = ptMinBase + dTrConeH * vtTrConeAx ; double dMinBaseLeakDist = DiskSegmentLeakDistOrtMot( ptMinBase, vtTrConeAx, dMinBaseR, ptSeg, vtSeg, dSegLen, vtMove) ; @@ -1047,6 +1032,21 @@ CAvTorusTriangle( const Point3d& ptTorusCen, const Vector3d& vtTorusAx, double d return -1 ; } +//---------------------------------------------------------------------------- +double +EvalLeakDist( const Point3d& ptTorusCen, double dMaxRad, double dMinRad, + const Point3d& ptSeg, const Vector3d& vtSeg, double dPar, const Vector3d& vtMove) +{ + double dSqMinRad = dMinRad * dMinRad ; + Point3d ptCurPoint = ptSeg + dPar * vtSeg ; + double dPointAxSqLen = GetPointLineSqDist( ptCurPoint, ptTorusCen, vtMove) ; + double dDeltaRad = sqrt( dPointAxSqLen) - dMaxRad ; + double dSQAddLeakDist = dSqMinRad - dDeltaRad * dDeltaRad ; + double dAddLeakDist = ( dSQAddLeakDist > 0. ? sqrt( dSQAddLeakDist) : 0.) ; + double dLeakDist = ( ptCurPoint - ptTorusCen) * vtMove + dAddLeakDist ; + return dLeakDist ; +} + //---------------------------------------------------------------------------- double TorusSegmentLeakDistLongMot( const Point3d& ptTorusCen, double dMaxRad, double dMinRad, @@ -1071,6 +1071,8 @@ TorusSegmentLeakDistLongMot( const Point3d& ptTorusCen, double dMaxRad, double d dOutLen1, dOutLen2) ; if ( nOutInters == CC_TWO_INT || nOutInters == CC_ONE_INT_TAN) SegLimits.Intersect( dOutLen1, dOutLen2) ; + else if ( nOutInters == CC_NO_INTERS) + SegLimits.Reset() ; if ( SegLimits.IsEmpty()) return 0. ; // Tolgo eventuale cilindro interno alla corona del toro @@ -1083,32 +1085,39 @@ TorusSegmentLeakDistLongMot( const Point3d& ptTorusCen, double dMaxRad, double d } // Eseguo controllo sugli intervalli - double dSqMinRad = dMinRad * dMinRad ; - double dSqMaxRad = dMaxRad * dMaxRad ; - double dSqTotRad = ( dMaxRad + dMinRad) * ( dMaxRad + dMinRad) ; - double dMaxLeakDist = 0.0 ; + double dMaxLeakDist = 0. ; double dLen1, dLen2 ; bool bFound = SegLimits.GetFirst( dLen1, dLen2) ; while ( bFound) { // verifico l'intervallo Point3d ptStart = ptSeg + vtSeg * dLen1 ; - double dLen = dLen2 - dLen1 ; - double dStep = max( 0.1 * dMinRad, EPS_SMALL) ; // !!! USARE ALGORITMO GOLDEN SECTION !!! - int nStepNum = int( dLen / dStep) + 1 ; - dStep = dLen / nStepNum ; - for ( int n = 0 ; n <= nStepNum ; ++ n) { - double dPar = n * dStep ; - Point3d ptCurPoint = ptStart + dPar * vtSeg ; - double dPointAxSqLen = GetPointLineSqDist( ptCurPoint, ptTorusCen, vtMove) ; - if ( dPointAxSqLen > dSqMaxRad && dPointAxSqLen < dSqTotRad) { - double dDeltaRad = sqrt( dPointAxSqLen) - dMaxRad ; - double dSQAddLeakDist = dSqMinRad - dDeltaRad * dDeltaRad ; - double dAddLeakDist = ( dSQAddLeakDist > 0. ? sqrt( dSQAddLeakDist) : 0.) ; - double dLeakDist = ( ptCurPoint - ptTorusCen) * vtMove + dAddLeakDist ; - if ( dLeakDist > dMaxLeakDist) - dMaxLeakDist = dLeakDist ; + double dLen = dLen2 - dLen1 ; + const double INV_GOLDEN_RATIO = ( sqrt( 5.) - 1.) / 2. ; + double dTol = max( 0.05 * dMinRad, EPS_SMALL) ; + double dPSt = 0 ; + double dPEn = dLen ; + double dPIn1 = dPEn - ( dPEn - dPSt) * INV_GOLDEN_RATIO ; + double dPIn2 = dPSt + ( dPEn - dPSt) * INV_GOLDEN_RATIO ; + double dLeakDist1 = EvalLeakDist( ptTorusCen, dMaxRad, dMinRad, ptStart, vtSeg, dPIn1, vtMove) ; + double dLeakDist2 = EvalLeakDist( ptTorusCen, dMaxRad, dMinRad, ptStart, vtSeg, dPIn2, vtMove) ; + while ( dPEn - dPSt > dTol) { + if ( dLeakDist1 > dLeakDist2) { + dPEn = dPIn2 ; + dPIn2 = dPIn1 ; + dLeakDist2 = dLeakDist1 ; + dPIn1 = dPEn - ( dPEn - dPSt) * INV_GOLDEN_RATIO ; + dLeakDist1 = EvalLeakDist( ptTorusCen, dMaxRad, dMinRad, ptStart, vtSeg, dPIn1, vtMove) ; + } + else { + dPSt = dPIn1 ; + dPIn1 = dPIn2 ; + dLeakDist1 = dLeakDist2 ; + dPIn2 = dPSt + ( dPEn - dPSt) * INV_GOLDEN_RATIO ; + dLeakDist2 = EvalLeakDist( ptTorusCen, dMaxRad, dMinRad, ptStart, vtSeg, dPIn2, vtMove) ; } } + double dPMax = 0.5 * ( dPSt + dPEn) ; + dMaxLeakDist = max( dMaxLeakDist, EvalLeakDist( ptTorusCen, dMaxRad, dMinRad, ptStart, vtSeg, dPMax, vtMove)) ; // passo al successivo intervallo bFound = SegLimits.GetNext( dLen1, dLen2) ; } @@ -1228,7 +1237,7 @@ TorusSegmentLeakDistOrtMot( const Point3d& ptTorusCen, const Vector3d& vtTorusAx double dMaxLeakDist = 0. ; if ( bInsideLateral && bInsideOrizontal) { double dSqMinRad = dMinRad * dMinRad ; - double dStep = max( 0.1 * dMinRad, EPS_SMALL) ; + double dStep = max( /*0.1*/0.05 * dMinRad, EPS_SMALL) ; int nStepNum = int( dMySegLen / dStep) ; for ( int n = 0 ; n <= nStepNum ; ++ n) { Point3d ptCurPoint = ptMySeg + ( n * dStep) * vtSeg ; @@ -1245,7 +1254,7 @@ TorusSegmentLeakDistOrtMot( const Point3d& ptTorusCen, const Vector3d& vtTorusAx double dCurDist = dL + sqrt( dSqDeltaL) ; if ( dCurDist > dMaxLeakDist) dMaxLeakDist = dCurDist ; - } + } } } return dMaxLeakDist ; @@ -1332,6 +1341,23 @@ CAvConcaveTorusTriangle( const Point3d& ptTorusCen, const Vector3d& vtTorusAx, d return 0. ; } +//---------------------------------------------------------------------------- +double +ConcaveEvalLeakDist( const Point3d& ptTorusCen, double dMaxRad, double dMinRad, + const Point3d& ptSeg, const Vector3d& vtSeg, double dPar, const Vector3d& vtMove) +{ + double dSqMinRad = dMinRad * dMinRad ; + double dSqMaxRad = dMaxRad * dMaxRad ; + double dSqInnRad = ( dMaxRad - dMinRad) * ( dMaxRad - dMinRad) ; + Point3d ptCurPoint = ptSeg + dPar * vtSeg ; + double dPointAxSqLen = Clamp( GetPointLineSqDist( ptCurPoint, ptTorusCen, vtMove), dSqInnRad, dSqMaxRad) ; + double dDeltaRad = dMaxRad - sqrt( dPointAxSqLen) ; + double dSqDeltaLeakDist = dSqMinRad - dDeltaRad * dDeltaRad ; + double dDeltaLeakDist = ( dSqDeltaLeakDist > 0. ? sqrt( dSqDeltaLeakDist) : 0.) ; + double dLeakDist = ( ptCurPoint - ptTorusCen) * vtMove - dDeltaLeakDist ; + return dLeakDist ; +} + //---------------------------------------------------------------------------- double ConcaveTorusSegmentLeakDistLongMot( const Point3d& ptTorusCen, double dMaxRad, double dMinRad, @@ -1357,6 +1383,8 @@ ConcaveTorusSegmentLeakDistLongMot( const Point3d& ptTorusCen, double dMaxRad, d dOutLen1, dOutLen2) ; if ( nOutInters == CC_TWO_INT || nOutInters == CC_ONE_INT_TAN) SegLimits.Intersect( dOutLen1, dOutLen2) ; + else if ( nOutInters == CC_NO_INTERS) + SegLimits.Reset() ; if ( SegLimits.IsEmpty()) return 0. ; // Tolgo eventuale cilindro interno alla corona del toro @@ -1368,33 +1396,29 @@ ConcaveTorusSegmentLeakDistLongMot( const Point3d& ptTorusCen, double dMaxRad, d SegLimits.Subtract( dIntLen1, dIntLen2) ; } - // Eseguo controllo sugli intervalli - double dSqMinRad = dMinRad * dMinRad ; - double dSqMaxRad = dMaxRad * dMaxRad ; - double dSqInnRad = ( dMaxRad - dMinRad) * ( dMaxRad - dMinRad) ; double dMaxLeakDist = 0.0 ; double dLen1, dLen2 ; bool bFound = SegLimits.GetFirst( dLen1, dLen2) ; while ( bFound) { // verifico l'intervallo Point3d ptStart = ptSeg + vtSeg * dLen1 ; - double dLen = dLen2 - dLen1 ; - double dStep = max( 0.1 * dMinRad, EPS_SMALL) ; // !!! USARE ALGORITMO GOLDEN SECTION !!! - int nStepNum = int( dLen / dStep) + 1 ; - dStep = dLen / nStepNum ; - for ( int n = 0 ; n <= nStepNum ; ++ n) { - double dPar = n * dStep ; - Point3d ptCurPoint = ptStart + dPar * vtSeg ; - double dPointAxSqLen = GetPointLineSqDist( ptCurPoint, ptTorusCen, vtMove) ; - if ( dPointAxSqLen > dSqInnRad && dPointAxSqLen < dSqMaxRad) { - double dDeltaRad = dMaxRad - sqrt( dPointAxSqLen) ; - double dSqDeltaLeakDist = dSqMinRad - dDeltaRad * dDeltaRad ; - double dDeltaLeakDist = ( dSqDeltaLeakDist > 0. ? sqrt( dSqDeltaLeakDist) : 0.) ; - double dLeakDist = ( ptCurPoint - ptTorusCen) * vtMove - dDeltaLeakDist ; - if ( dLeakDist > dMaxLeakDist) - dMaxLeakDist = dLeakDist ; - } + double dLen = dLen2 - dLen1 ; + const double GOLDEN_RATIO = ( sqrt( 5) - 1) * 0.5 ; + double dTol = max( /*0.1*/0.05 * dMinRad, EPS_SMALL) ; + double dPSt = 0 ; + double dPEn = dLen ; + while ( dPEn - dPSt > dTol) { + double dPIn1 = dPEn - ( dPEn - dPSt) * GOLDEN_RATIO ; + double dPIn2 = dPSt + ( dPEn - dPSt) * GOLDEN_RATIO ; + double dLeakDist1 = ConcaveEvalLeakDist( ptTorusCen, dMaxRad, dMinRad, ptStart, vtSeg, dPIn1, vtMove) ; + double dLeakDist2 = ConcaveEvalLeakDist( ptTorusCen, dMaxRad, dMinRad, ptStart, vtSeg, dPIn2, vtMove) ; + if ( dLeakDist1 > dLeakDist2) + dPEn = dPIn2 ; + else + dPSt = dPIn1 ; } + double dMaxPar = 0.5 * ( dPSt + dPEn) ; + dMaxLeakDist = max( dMaxLeakDist, ConcaveEvalLeakDist( ptTorusCen, dMaxRad, dMinRad, ptStart, vtSeg, dMaxPar, vtMove)) ; // passo al successivo intervallo bFound = SegLimits.GetNext( dLen1, dLen2) ; } @@ -1498,7 +1522,7 @@ ConcaveTorusSegmentLeakDistOrtMot( const Point3d& ptTorusCen, const Vector3d& vt double dMaxLeakDist = 0. ; if ( bInsideLateral && bInsideOrizontal) { double dSqMinRad = dMinRad * dMinRad ; - double dStep = max( 0.1 * dMinRad, EPS_SMALL) ; + double dStep = max( /*0.1*/0.05 * dMinRad, EPS_SMALL) ; int nStepNum = int( dMySegLen / dStep) ; for ( int n = 0 ; n <= nStepNum ; ++ n) { Point3d ptCurPoint = ptMySeg + ( n * dStep) * vtSeg ; @@ -1549,24 +1573,94 @@ ConcaveTorusTriangleInteriorLeakDistOrtMot( const Point3d& ptTorusCen, const Vec // DISTANZA DI ALLONTANAMENTO PER DISCHI +//---------------------------------------------------------------------------- +double +CAvDiskTriangle( const Point3d& ptDiskCen, const Vector3d& vtDiskAx, double dDiskRad, + const Triangle3d& trTria, const Vector3d& vtMove) +{ + // Direzione di allontanamento diretta come normale al disco + if ( AreSameVectorApprox( vtDiskAx, vtMove)) { + // Valuto le distanze con segno dei vertici dal piano del disco : + // se sono tutte negative non interferiscono. + double dDistV[3] ; + dDistV[0] = PointPlaneSignedDist( trTria.GetP( 0), ptDiskCen, vtMove) ; + dDistV[1] = PointPlaneSignedDist( trTria.GetP( 1), ptDiskCen, vtMove) ; + dDistV[2] = PointPlaneSignedDist( trTria.GetP( 2), ptDiskCen, vtMove) ; + double dMaxDistV = max( dDistV[0], max( dDistV[1], dDistV[2])) ; + if ( dMaxDistV < 0.) + return 0. ; + // Se tutti i punti distano dall'asse di movimento meno del raggio, l'ultimo + // punto di contatto deve essere un vertice del triangolo. + double dSqRad = dDiskRad * dDiskRad ; + bool bInV[3] ; + bInV[0] = ( GetPointLineSqDist( trTria.GetP( 0), ptDiskCen, vtMove) < dSqRad) ; + bInV[1] = ( GetPointLineSqDist( trTria.GetP( 1), ptDiskCen, vtMove) < dSqRad) ; + bInV[2] = ( GetPointLineSqDist( trTria.GetP( 2), ptDiskCen, vtMove) < dSqRad) ; + if ( bInV[0] && bInV[1] && bInV[2]) + return max( dMaxDistV, 0.) ; + // Distanza di allontanamento dall'interno del triangolo + double dMaxDistI = DiskTriaInteriorLeakDistLongMot( ptDiskCen, dDiskRad, trTria, vtMove) ; + if ( dMaxDistI > EPS_SMALL) + return dMaxDistI ; + // Se disco è un punto, inutile fare controlli con i lati e i vertici del triangolo + if ( dDiskRad < EPS_SMALL) + return 0. ; + // Ciclo sui segmenti del triangolo e calcolo la loro distanza di allontanamento, calcolo + // anche la distanza di allontanamento dai vertici distanti dall'asse meno del raggio. + double dMaxDistVS = 0. ; + for ( int nVS = 0 ; nVS < 3 ; ++ nVS) { + // Vertici + if ( bInV[nVS] && dDistV[nVS] > dMaxDistVS) + dMaxDistVS = dDistV[nVS] ; + // Se un lato del triangolo ha entrambi gli estremi con distanza negativa dal piano del disco, + // non può interferire con esso. + int nVE = ( nVS + 1) % 3 ; + if ( dDistV[nVS] < 0 && dDistV[nVE] < 0) + continue ; + // Versore e lunghezza del segmento + Vector3d vtSeg = trTria.GetP( nVE) - trTria.GetP( nVS) ; + double dSegLen = vtSeg.Len() ; + vtSeg /= dSegLen ; + // Distanza dal piano del segmento corrente + double dCurDist = DiskSegmentLeakDistLongMot( ptDiskCen, dDiskRad, trTria.GetP( nVS), vtSeg, dSegLen, vtMove) ; + if ( dCurDist > dMaxDistVS) + dMaxDistVS = dCurDist ; + } + return dMaxDistVS ; + } + // Direzione di allontanamento perpendicolare all'asse del disco + else if ( AreOrthoApprox( vtDiskAx, vtMove)) { + return 0. ; + } + // Direzione di allontanamento generica + else if ( vtDiskAx * vtMove > 0.) { + // Non trattato al momento + return - 1. ; + } + // Errore + else + return -1. ; +} + //---------------------------------------------------------------------------- double DiskPointLeakDistLongMot( const Point3d& ptDiskCen, double dDiskRad, const Point3d& ptP, const Vector3d& vtMove) { - if ( GetPointLineSqDist( ptP, ptDiskCen, vtMove) < dDiskRad * dDiskRad) + if ( GetPointLineSqDist( ptP, ptDiskCen, vtMove) < dDiskRad * dDiskRad - 2 * dDiskRad * EPS_SMALL) return PointPlaneSignedDist( ptP, ptDiskCen, vtMove) ; return 0. ; } //---------------------------------------------------------------------------- -double +double DiskSegmentLeakDistLongMot( const Point3d& ptDiskCen, double dDiskRad, - const Point3d& ptSeg, const Vector3d& vtSeg, double dSegLen, const Vector3d& vtMove) + const Point3d& ptSeg, const Vector3d& vtSeg, double dSegLen, + const Vector3d& vtMove) { // Il disco non può interferire col segmento nel suo moto, se la distanza del - // segmento dall'asse di traslazione è maggiore del raggio. - if ( LineSegmentSqDist( ptDiskCen, vtMove, ptSeg, vtSeg, dSegLen) > dDiskRad * dDiskRad) + // segmento dall'asse di traslazione è maggiore del raggio. + if ( LineSegmentSqDist( ptDiskCen, vtMove, ptSeg, vtSeg, dSegLen) > dDiskRad * dDiskRad - 2 * dDiskRad * EPS_SMALL) return 0. ; // Imposto l'equazione: la distanza quadrata del generico punto della retta associata al @@ -1579,92 +1673,65 @@ DiskSegmentLeakDistLongMot( const Point3d& ptDiskCen, double dDiskRad, vdCoef[1] = 2 * vtLineSegOrt * vtSegOrt ; vdCoef[2] = vtSegOrt.SqLen() ; // Segmento e asse paralleli - if ( vdCoef[2] < SQ_EPS_ZERO) { - if ( abs( vdCoef[0]) < 2 * dDiskRad * EPS_SMALL) { - double dLenSt = PointPlaneSignedDist( ptSeg, ptDiskCen, vtMove) ; - double dLenEn = PointPlaneSignedDist( ptSeg + dSegLen * vtSeg, ptDiskCen, vtMove) ; - return max( max( dLenSt, dLenEn), 0.) ; - } - else - return 0. ; - } + if ( vdCoef[2] < SQ_EPS_ZERO) + return 0. ; // Soluzione dell'equazione - else { - int nRoot = PolynomialRoots( 2, vdCoef, vdRoots) ; - // Ciclo sulle soluzioni per trovare la distanza di allontanamento - double dSegDist = 0. ; - for ( int nSol = 0 ; nSol < nRoot ; ++ nSol) { - // Soluzione interna al segmento - if ( vdRoots[nSol] > 0. && vdRoots[nSol] < dSegLen) { - Point3d ptC = ptSeg + vdRoots[nSol] * vtSeg ; - // Distanza del punto soluzione dal piano del disco nella posizione iniziale - double dCurDist = PointPlaneSignedDist( ptC, ptDiskCen, vtMove) ; - if ( dCurDist > dSegDist) - dSegDist = dCurDist ; - } + int nRoot = PolynomialRoots( 2, vdCoef, vdRoots) ; + // Ciclo sulle soluzioni per trovare la distanza di allontanamento + double dSegDist = 0. ; + for ( int nSol = 0 ; nSol < nRoot ; ++ nSol) { + // Soluzione interna al segmento + if ( vdRoots[nSol] > 0. && vdRoots[nSol] < dSegLen) { + Point3d ptC = ptSeg + vdRoots[nSol] * vtSeg ; + // Distanza del punto soluzione dal piano del disco nella posizione iniziale + double dCurDist = PointPlaneSignedDist( ptC, ptDiskCen, vtMove) ; + if ( dCurDist > dSegDist) + dSegDist = dCurDist ; } - return dSegDist ; } + return dSegDist ; } + //---------------------------------------------------------------------------- // Determina la distanza di allontanamento di un disco, che trasla lungo il suo asse di simmetria, // dall'interno di un triangolo. Il disco è descritto dal suo raggio e il moto dal // centro nella posizione iniziale e dal versore del suo asse di simmetria // (COINCIDENTE CON IL VERSORE DELLA DIREZIONE DI ALLONTANAMENTO). -double +//---------------------------------------------------------------------------- +double DiskTriaInteriorLeakDistLongMot( const Point3d& ptDiskCen, double dDiskRad, - const Triangle3d& trTria, const Vector3d& vtMove) + const Triangle3d& trTria, const Vector3d& vtMove) { // Se disco e triangolo sono complanari if ( AreSameVectorApprox( vtMove, trTria.GetN())) { - // verifico solo il centro, se centro esterno non più del raggio sicuramente toccherebbe i lati - double dDist = PointPlaneSignedDist( ptDiskCen, trTria.GetP( 0), trTria.GetN()) ; - if ( IsPointInsideTriangle( ptDiskCen - dDist * trTria.GetN(), trTria)) - return max( -dDist, 0.) ; + double dDist = max( PointPlaneSignedDist( ptDiskCen, trTria.GetP( 0), trTria.GetN()), 0.) ; + if ( CoplanarDiscTriangleInterferance( ptDiskCen + dDist * vtMove, dDiskRad, trTria)) + return dDist ; } - // Cerco un punto di contatto nell'interno del triangolo. Se tale punto - // esiste, la retta intersezione fra il piano del triangolo e quello del - // disco è tangente alla circonferenza. - // Vettore tangente alla circonferenza e vettore radiale - Vector3d vtRadLine = vtMove * ( trTria.GetN() * vtMove) - trTria.GetN() ; - vtRadLine.Normalize() ; + // Se disco e triangolo sono ortogonali non può esserci contatto con interno + if ( AreOrthoApprox( vtMove, trTria.GetN())) + return 0. ; + // Cerco un punto di contatto nell'interno del triangolo. + double dLeakDist = 0. ; + // Vettore radiale + Vector3d vtRad = trTria.GetN() - ( trTria.GetN() * vtMove) * vtMove ; + vtRad.Normalize() ; // Punti delle due rette candidate all'intersezione col triangolo - Point3d ptStPlus = ptDiskCen + dDiskRad * vtRadLine ; - Point3d ptStMinus = ptDiskCen - dDiskRad * vtRadLine ; - // Intersezioni con la prima retta - double dDistPlus = 0. ; - Point3d ptIntPlus1, ptIntPlus2 ; - int nIntPlus = IntersLineTria( ptStPlus, vtMove, 10, trTria, ptIntPlus1, ptIntPlus2, false) ; - if ( nIntPlus != ILTT_NO) { - double dDist1 = PointPlaneSignedDist( ptIntPlus1, ptDiskCen, vtMove) ; - // Se l'intersezione è doppia, ha senso anche dDist2. - if ( nIntPlus == ILTT_SEGM || - nIntPlus == ILTT_SEGM_ON_EDGE) { - double dDist2 = PointPlaneSignedDist( ptIntPlus2, ptDiskCen, vtMove) ; - dDistPlus = max( dDist1, dDist2) ; - } - // Altrimenti ha senso solo dDist1 - else - dDistPlus = dDist1 ; + Point3d ptStPlus = ptDiskCen + dDiskRad * vtRad ; + Point3d ptStMinus = ptDiskCen - dDiskRad * vtRad ; + + // Intersezioni con le rette + double dDistPlus = ( ( trTria.GetP( 0) - ptStPlus) * trTria.GetN()) / ( vtMove * trTria.GetN()) ; + double dDistMinus = ( ( trTria.GetP( 0) - ptStMinus) * trTria.GetN()) / ( vtMove * trTria.GetN()) ; + if ( dDistPlus > dDistMinus) { + if ( IsPointInsideTriangle( ptStPlus + dDistPlus * vtMove, trTria)) + dLeakDist = max( dLeakDist, dDistPlus) ; } - // Intersezioni con la seconda retta - double dDistMinus = 0. ; - Point3d ptIntMinus1, ptIntMinus2 ; - int nIntMinus = IntersLineTria( ptStMinus, vtMove, 10, trTria, ptIntMinus1, ptIntMinus2, false) ; - if ( nIntMinus != ILTT_NO) { - double dDist1 = PointPlaneSignedDist( ptIntMinus1, ptDiskCen, vtMove) ; - // Se l'intersezione è doppia, ha senso anche dDist2. - if ( nIntMinus == ILTT_SEGM || - nIntMinus == ILTT_SEGM_ON_EDGE) { - double dDist2 = PointPlaneSignedDist( ptIntMinus2, ptDiskCen, vtMove) ; - dDistMinus = max( dDist1, dDist2) ; - } - // Altrimenti ha senso solo dDist1 - else - dDistMinus = dDist1 ; - } - return max( dDistPlus, dDistMinus) ; + else if ( IsPointInsideTriangle( ptStMinus + dDistMinus * vtMove, trTria)) + dLeakDist = max( dLeakDist, dDistMinus) ; + + return dLeakDist ; } //---------------------------------------------------------------------------- @@ -1696,7 +1763,7 @@ DiskPlaneLeakDistLongMot( const Point3d& ptDiskCen, double dDiskRad, else { ptTouch = ptStMinus + dLeakMinus * vtMove ; return dLeakMinus ; - } + } } //---------------------------------------------------------------------------- @@ -1758,11 +1825,6 @@ DiskSegmentLeakDistOrtMot( const Point3d& ptDiskCen, const Vector3d& vtDiskAx, d } //---------------------------------------------------------------------------- -// Restituisce la distanza di allontanamento di un disco, che trasla ortogonalmente al suo asse -// di simmetria, da un piano. -// Il disco è descritto dal suo raggio. Il moto è descritto dal centro nella posizione -// iniziale, dal versore (NORMA UNITARIA) dell'asse di simmetria del disco e dal versore -// della direzione del moto. double DiskPlaneLeakDistOrtMot( const Point3d& ptDiscCen, const Vector3d& vtDiskAx, double dDiskRad, const Point3d& ptPlane, const Vector3d& vtPlane, @@ -1770,6 +1832,13 @@ DiskPlaneLeakDistOrtMot( const Point3d& ptDiscCen, const Vector3d& vtDiskAx, dou { Vector3d vtLine = vtPlane ^ vtDiskAx ; if ( vtLine.Normalize()) { + // Se il raggio è minore di epsilon, lo consideriamo un punto + if ( dDiskRad < EPS_SMALL) { + // Denominatore sempre diverso da zero + double dDesplacement = ( ( ptPlane - ptDiscCen)) * vtPlane / ( vtMove * vtPlane) ; + ptContact = ptDiscCen + dDesplacement * vtMove ; + return dDesplacement ; + } Vector3d vtRad = dDiskRad * vtLine ^ vtDiskAx ; if ( vtRad * vtMove > 0) vtRad *= - 1 ; @@ -1777,7 +1846,7 @@ DiskPlaneLeakDistOrtMot( const Point3d& ptDiscCen, const Vector3d& vtDiskAx, dou double dRadCos = abs( vtRad * vtMove) ; // Se la retta intersezione fra i piani è parallela alla direzione di // allontanamento la distanza di fuga è determinata da punti e segmenti. - if ( dRadCos < EPS_SMALL) + if ( dDiskRad && dRadCos < EPS_SMALL) return 0. ; double dDeltaPar = dDiskRad * dDiskRad / dRadCos ; double dDesplacement = max( dPar + dDeltaPar, 0.) ; @@ -1787,7 +1856,6 @@ DiskPlaneLeakDistOrtMot( const Point3d& ptDiscCen, const Vector3d& vtDiskAx, dou return 0. ; } - // FUNZIONI GEOMETRICHE DI BASE PER IL CALCOLO DELLA DISTANZA DI ALLONTANAMENTO //---------------------------------------------------------------------------- diff --git a/CAvToolTriangle.h b/CAvToolTriangle.h index 62e3f03..59c48cc 100644 --- a/CAvToolTriangle.h +++ b/CAvToolTriangle.h @@ -84,11 +84,14 @@ double ConcaveTorusTriangleInteriorLeakDistOrtMot( const Point3d& ptTorusCen, co const Triangle3d& trTria, const Vector3d& vtMove) ; // Dischi +double CAvDiskTriangle( const Point3d& ptDiskCen, const Vector3d& vtDiskAx, double dDiskRad, + const Triangle3d& trTria, const Vector3d& vtMove) ; double DiskPointLeakDistLongMot( const Point3d& ptDiskCen, double dDiskRad, const Point3d& ptP, const Vector3d& vtMove) ; double DiskSegmentLeakDistLongMot( const Point3d& ptDiskCen, double dDiskRad, - const Point3d& ptSeg, const Vector3d& vtSeg, double dSegLen, const Vector3d& vtMove) ; -double DiskTriaInteriorLeakDistLongMot( const Point3d& ptDiskCen, double dDiskRad, + const Point3d& ptSeg, const Vector3d& vtSeg, double dSegLen, + const Vector3d& vtMove) ; +double DiskTriaInteriorLeakDistLongMot( const Point3d& ptDiskCen, double dDiskRad, const Triangle3d& trTria, const Vector3d& vtMove) ; double DiskPlaneLeakDistLongMot( const Point3d& ptDiskCen, double dDiskRad, const Point3d& ptPlane, const Vector3d& vtPlane, diff --git a/CurveArc.cpp b/CurveArc.cpp index 445418a..024399a 100644 --- a/CurveArc.cpp +++ b/CurveArc.cpp @@ -548,7 +548,7 @@ CurveArc* CurveArc::Clone( void) const { // alloco oggetto - CurveArc* pCrv = new(nothrow) CurveArc ; + CurveArc* pCrv = new( nothrow) CurveArc ; if ( pCrv != nullptr) { if ( ! pCrv->CopyFrom( *this)) { delete pCrv ; diff --git a/CurveBezier.cpp b/CurveBezier.cpp index 24015c3..8f90c0c 100644 --- a/CurveBezier.cpp +++ b/CurveBezier.cpp @@ -81,12 +81,12 @@ CurveBezier::Init( int nDeg, bool bIsRational) delete [] m_aWeCtrl ; } // alloco punti - m_aPtCtrl = new Point3d [ nDeg + 1] ; + m_aPtCtrl = new( nothrow) Point3d [ nDeg + 1] ; if ( m_aPtCtrl == nullptr) return false ; // se razionale, alloco pesi if ( bIsRational) { - m_aWeCtrl = new double [ nDeg + 1] ; + m_aWeCtrl = new( nothrow) double [ nDeg + 1] ; if ( m_aWeCtrl == nullptr) { delete [] m_aPtCtrl ; return false ; @@ -296,7 +296,7 @@ CurveBezier* CurveBezier::Clone( void) const { // alloco oggetto - CurveBezier* pCrv = new(nothrow) CurveBezier ; + CurveBezier* pCrv = new( nothrow) CurveBezier ; if ( pCrv != nullptr) { if ( ! pCrv->CopyFrom( *this)) { delete pCrv ; diff --git a/CurveComposite.cpp b/CurveComposite.cpp index d7ccefa..10647fa 100644 --- a/CurveComposite.cpp +++ b/CurveComposite.cpp @@ -498,7 +498,7 @@ CurveComposite* CurveComposite::Clone( void) const { // alloco oggetto - CurveComposite* pCrv = new(nothrow) CurveComposite ; + CurveComposite* pCrv = new( nothrow) CurveComposite ; if ( pCrv != nullptr) { if ( ! pCrv->CopyFrom( *this)) { delete pCrv ; @@ -1447,7 +1447,7 @@ CurveComposite::CopyParamRange( double dUStart, double dUEnd) const int nIdStart = static_cast( floor( dUStart)) ; int nIdEnd = static_cast( ceil( dUEnd)) ; // creo la curva composita copia - PtrOwner pCopy( new CurveComposite()) ; + PtrOwner pCopy( new( nothrow) CurveComposite()) ; if ( IsNull( pCopy)) return nullptr ; // eseguo la copia delle sole curve semplici necessarie diff --git a/CurveLine.cpp b/CurveLine.cpp index ffce654..7229159 100644 --- a/CurveLine.cpp +++ b/CurveLine.cpp @@ -94,7 +94,7 @@ CurveLine* CurveLine::Clone( void) const { // alloco oggetto - CurveLine* pCrv = new(nothrow) CurveLine ; + CurveLine* pCrv = new( nothrow) CurveLine ; if ( pCrv != nullptr) { if ( ! pCrv->CopyFrom( *this)) { delete pCrv ; diff --git a/EGkDllMain.cpp b/EGkDllMain.cpp index 9289217..fe279e2 100644 --- a/EGkDllMain.cpp +++ b/EGkDllMain.cpp @@ -39,7 +39,7 @@ using namespace std ; const int STR_DIM = 40 ; //----------------------------------------------------------------------------- -static HINSTANCE s_hModule = NULL ; +static HINSTANCE s_hModule = nullptr ; static char s_szEGkNameVer[STR_DIM] ; //----------------------------------------------------------------------------- @@ -59,7 +59,7 @@ DllMain( HMODULE hModule, DWORD dwReason, LPVOID lpReserved) EGT_TRACE( "EgtGeomKernel.dll Initializing!\n") ; } else if ( dwReason == DLL_PROCESS_DETACH) { - s_hModule = NULL ; + s_hModule = nullptr ; EGT_TRACE( "EgtGeomKernel.dll Terminating!\n") ; } diff --git a/EgtGeomKernel.rc b/EgtGeomKernel.rc index 80fd6ea..4e1e649 100644 Binary files a/EgtGeomKernel.rc and b/EgtGeomKernel.rc differ diff --git a/ExtText.cpp b/ExtText.cpp index 9d2be8a..2b60012 100644 --- a/ExtText.cpp +++ b/ExtText.cpp @@ -136,7 +136,7 @@ ExtText* ExtText::Clone( void) const { // alloco oggetto - ExtText* pGPt = new(nothrow) ExtText ; + ExtText* pGPt = new( nothrow) ExtText ; if ( pGPt != nullptr) { if ( ! pGPt->CopyFrom( *this)) { delete pGPt ; diff --git a/FontOs.cpp b/FontOs.cpp index aee1a7b..8f5ae38 100644 --- a/FontOs.cpp +++ b/FontOs.cpp @@ -628,7 +628,7 @@ OsFont::GetCharOutline( unsigned int nChar, double& dAdvance, ICURVEPLIST& lstPC DWORD dwSize = GetGlyphOutlineW( m_hDC, nChar, GGO_NATIVE, &gm, 0, NULL, &mat) ; if ( dwSize == GDI_ERROR) return false ; - PtrOwner pBuffer( new char[dwSize]) ; + PtrOwner pBuffer( new( nothrow) char[dwSize]) ; if ( IsNull( pBuffer)) return false ; // recupero l'outline diff --git a/GdbExecutor.cpp b/GdbExecutor.cpp index 5f188d3..1c528f6 100644 --- a/GdbExecutor.cpp +++ b/GdbExecutor.cpp @@ -68,7 +68,7 @@ static const int POLYG_SIDE = 3 ; IGdbExecutor* CreateGdbExecutor( void) { - return static_cast ( new GdbExecutor) ; + return static_cast ( new( nothrow) GdbExecutor) ; } //---------------------------------------------------------------------------- @@ -2649,7 +2649,7 @@ GdbExecutor::VolZmapCreate( const STRVECTOR& vsParams) bTriDexel = true ; // creo Zmap - PtrOwner pZprova( new VolZmap) ; + PtrOwner pZprova( new( nothrow) VolZmap) ; pZprova->Create( ptO, dLengthX, dLengthY, dLengthZ, dPrec, bTriDexel) ; // inserisco nel DB @@ -2687,7 +2687,7 @@ GdbExecutor::VolZmapCreateFromFlatRegion( const STRVECTOR& vsParams) bTriDexel = true ; // creo Zmap - PtrOwner pZprova( new VolZmap) ; + PtrOwner pZprova( new( nothrow) VolZmap) ; pZprova->CreateFromFlatRegion( *pRegion, dLengthZ, dPrec, bTriDexel) ; // inserisco nel DB @@ -2720,7 +2720,7 @@ GdbExecutor::VolZmapCreateFromTriMesh( const STRVECTOR& vsParams) if ( pSurf == nullptr) return false ; // creo Zmap - PtrOwner pZprova( new VolZmap) ; + PtrOwner pZprova( new( nothrow) VolZmap) ; pZprova->CreateFromTriMesh( * pSurf, dPrec, bType) ; // inserisco nel DB @@ -3013,25 +3013,25 @@ GdbExecutor::LineDiscInters( const STRVECTOR& vsParams) if ( nIntType == D_NO_INTERS) int nSol = 0 ; if ( nIntType == D_BOUNDARY_INT_LINE_NOT_IN_PLANE) { - PtrOwner pLine( new CurveLine) ; + PtrOwner pLine( new( nothrow) CurveLine) ; pLine->Set( ptPS - vtLine, ptPS + vtLine) ; // inserisco nel DB return AddGeoObj( vsParams[0], vsParams[1], Release( pLine)) ; } if ( nIntType == D_INNER_INT_LINE_NOT_IN_PLANE) { - PtrOwner pLine( new CurveLine) ; + PtrOwner pLine( new( nothrow) CurveLine) ; pLine->Set( ptPS - 3 * vtLine, ptPS + 3 * vtLine) ; // inserisco nel DB return AddGeoObj( vsParams[0], vsParams[1], Release( pLine)) ; } if ( nIntType == D_ONE_INT_LINE_ON_PLANE) { - PtrOwner pLine( new CurveLine) ; + PtrOwner pLine( new( nothrow) CurveLine) ; pLine->Set( ptPS - 5 * vtLine, ptPS + 5 * vtLine) ; // inserisco nel DB return AddGeoObj( vsParams[0], vsParams[1], Release( pLine)) ; } if ( nIntType == D_INFINITE_INT_LINE_ON_PLANE) { - PtrOwner pLine( new CurveLine) ; + PtrOwner pLine( new( nothrow) CurveLine) ; pLine->Set( ptPS, ptPE) ; // inserisco nel DB return AddGeoObj( vsParams[0], vsParams[1], Release( pLine)) ; @@ -3083,25 +3083,25 @@ GdbExecutor::RayDiscInters( const STRVECTOR& vsParams) if ( nIntType == D_NO_INTERS) int nSol = 0 ; if ( nIntType == D_BOUNDARY_INT_LINE_NOT_IN_PLANE) { - PtrOwner pLine( new CurveLine) ; + PtrOwner pLine( new( nothrow) CurveLine) ; pLine->Set( ptPS - vtLine, ptPS + vtLine) ; // inserisco nel DB return AddGeoObj( vsParams[0], vsParams[1], Release( pLine)) ; } if ( nIntType == D_INNER_INT_LINE_NOT_IN_PLANE) { - PtrOwner pLine( new CurveLine) ; + PtrOwner pLine( new( nothrow) CurveLine) ; pLine->Set( ptPS - 3 * vtLine, ptPS + 3 * vtLine) ; // inserisco nel DB return AddGeoObj( vsParams[0], vsParams[1], Release( pLine)) ; } if ( nIntType == D_ONE_INT_LINE_ON_PLANE) { - PtrOwner pLine( new CurveLine) ; + PtrOwner pLine( new( nothrow) CurveLine) ; pLine->Set( ptPS - 5 * vtLine, ptPS + 5 * vtLine) ; // inserisco nel DB return AddGeoObj( vsParams[0], vsParams[1], Release( pLine)) ; } if ( nIntType == D_INFINITE_INT_LINE_ON_PLANE) { - PtrOwner pLine( new CurveLine) ; + PtrOwner pLine( new( nothrow) CurveLine) ; pLine->Set( ptPS, ptPE) ; // inserisco nel DB return AddGeoObj( vsParams[0], vsParams[1], Release( pLine)) ; @@ -3157,25 +3157,25 @@ GdbExecutor::SegmentDiscInters( const STRVECTOR& vsParams) if ( nIntType == D_NO_INTERS) int nSol = 0 ; if ( nIntType == D_BOUNDARY_INT_LINE_NOT_IN_PLANE) { - PtrOwner pLine( new CurveLine) ; + PtrOwner pLine( new( nothrow) CurveLine) ; pLine->Set( ptPS - vtLine, ptPS + vtLine) ; // inserisco nel DB return AddGeoObj( vsParams[0], vsParams[1], Release( pLine)) ; } if ( nIntType == D_INNER_INT_LINE_NOT_IN_PLANE) { - PtrOwner pLine( new CurveLine) ; + PtrOwner pLine( new( nothrow) CurveLine) ; pLine->Set( ptPS - 3 * vtLine, ptPS + 3 * vtLine) ; // inserisco nel DB return AddGeoObj( vsParams[0], vsParams[1], Release( pLine)) ; } if ( nIntType == D_ONE_INT_LINE_ON_PLANE) { - PtrOwner pLine( new CurveLine) ; + PtrOwner pLine( new( nothrow) CurveLine) ; pLine->Set( ptPS - 5 * vtLine, ptPS + 5 * vtLine) ; // inserisco nel DB return AddGeoObj( vsParams[0], vsParams[1], Release( pLine)) ; } if ( nIntType == D_INFINITE_INT_LINE_ON_PLANE) { - PtrOwner pLine( new CurveLine) ; + PtrOwner pLine( new( nothrow) CurveLine) ; pLine->Set( ptPS, ptPE) ; // inserisco nel DB return AddGeoObj( vsParams[0], vsParams[1], Release( pLine)) ; @@ -3222,13 +3222,13 @@ GdbExecutor::LineSphereInters( const STRVECTOR& vsParams) if ( nIntType == S_NO_INTERS) int nSol = 0 ; if ( nIntType == S_TWO_INT) { - PtrOwner pLine( new CurveLine) ; + PtrOwner pLine( new( nothrow) CurveLine) ; pLine->Set( ptPS, ptPE) ; // inserisco nel DB return AddGeoObj (vsParams[0], vsParams[1], Release( pLine)) ; } if ( nIntType == S_ONE_INT_TAN) { - PtrOwner pLine( new CurveLine) ; + PtrOwner pLine( new( nothrow) CurveLine) ; pLine->Set( ptPS - vtV, ptPS + vtV) ; // inserisco nel DB return AddGeoObj( vsParams[0], vsParams[1], Release( pLine)) ; @@ -3275,19 +3275,19 @@ GdbExecutor::RaySphereInters( const STRVECTOR& vsParams) if ( nIntType == S_NO_INTERS) int nSol = 0 ; if ( nIntType == S_TWO_INT) { - PtrOwner pLine( new CurveLine) ; + PtrOwner pLine( new( nothrow) CurveLine) ; pLine->Set( ptPS, ptPE) ; // inserisco nel DB return AddGeoObj (vsParams[0], vsParams[1], Release( pLine)) ; } if ( nIntType == S_ONE_INT_TAN) { - PtrOwner pLine( new CurveLine) ; + PtrOwner pLine( new( nothrow) CurveLine) ; pLine->Set( ptPS - vtV, ptPS + vtV) ; // inserisco nel DB return AddGeoObj( vsParams[0], vsParams[1], Release( pLine)) ; } if ( nIntType == S_ONE_INT_SEC) { - PtrOwner pLine( new CurveLine) ; + PtrOwner pLine( new( nothrow) CurveLine) ; pLine->Set( ptPS - 3 * vtV, ptPS + 3 * vtV) ; // inserisco nel DB return AddGeoObj( vsParams[0], vsParams[1], Release( pLine)) ; @@ -3339,21 +3339,21 @@ GdbExecutor::SegmentSphereInters( const STRVECTOR& vsParams) if ( nIntType == S_TWO_INT) { Point3d ptPS = ptP + dU1 * vtV ; Point3d ptPE = ptP + dU2 * vtV ; - PtrOwner pLine( new CurveLine) ; + PtrOwner pLine( new( nothrow) CurveLine) ; pLine->Set( ptPS, ptPE) ; // inserisco nel DB return AddGeoObj (vsParams[0], vsParams[1], Release( pLine)) ; } if ( nIntType == S_ONE_INT_TAN) { Point3d ptPS = ptP + dU1 * vtV ; - PtrOwner pLine( new CurveLine) ; + PtrOwner pLine( new( nothrow) CurveLine) ; pLine->Set( ptPS - vtV, ptPS + vtV) ; // inserisco nel DB return AddGeoObj( vsParams[0], vsParams[1], Release( pLine)) ; } if ( nIntType == S_ONE_INT_SEC) { Point3d ptPS = ptP + dU1 * vtV ; - PtrOwner pLine( new CurveLine) ; + PtrOwner pLine( new( nothrow) CurveLine) ; pLine->Set( ptPS - 3 * vtV, ptPS + 3 * vtV) ; // inserisco nel DB return AddGeoObj( vsParams[0], vsParams[1], Release( pLine)) ; @@ -3406,13 +3406,13 @@ GdbExecutor::LineSemiSphereInters( const STRVECTOR& vsParams) if ( nIntType == S_NO_INTERS) int nSol = 0 ; if ( nIntType == S_TWO_INT) { - PtrOwner pLine( new CurveLine) ; + PtrOwner pLine( new( nothrow) CurveLine) ; pLine->Set( ptPS, ptPE) ; // inserisco nel DB return AddGeoObj (vsParams[0], vsParams[1], Release( pLine)) ; } if ( nIntType == S_ONE_INT_TAN) { - PtrOwner pLine( new CurveLine) ; + PtrOwner pLine( new( nothrow) CurveLine) ; pLine->Set( ptPS - vtV, ptPS + vtV) ; // inserisco nel DB return AddGeoObj( vsParams[0], vsParams[1], Release( pLine)) ; @@ -3465,19 +3465,19 @@ GdbExecutor::RaySemiSphereInters( const STRVECTOR& vsParams) if ( nIntType == S_NO_INTERS) int nSol = 0 ; if ( nIntType == S_TWO_INT) { - PtrOwner pLine( new CurveLine) ; + PtrOwner pLine( new( nothrow) CurveLine) ; pLine->Set( ptPS, ptPE) ; // inserisco nel DB return AddGeoObj (vsParams[0], vsParams[1], Release( pLine)) ; } if ( nIntType == S_ONE_INT_SEC) { - PtrOwner pLine( new CurveLine) ; + PtrOwner pLine( new( nothrow) CurveLine) ; pLine->Set( ptPS - vtV, ptPS + vtV) ; // inserisco nel DB return AddGeoObj (vsParams[0], vsParams[1], Release( pLine)) ; } if ( nIntType == S_ONE_INT_TAN) { - PtrOwner pLine( new CurveLine) ; + PtrOwner pLine( new( nothrow) CurveLine) ; pLine->Set( ptPS - vtV, ptPS + vtV) ; // inserisco nel DB return AddGeoObj( vsParams[0], vsParams[1], Release( pLine)) ; @@ -3534,21 +3534,21 @@ GdbExecutor::SegmentSemiSphereInters( const STRVECTOR& vsParams) if ( nIntType == S_TWO_INT) { Point3d ptPS = ptP + dU1 * vtV ; Point3d ptPE = ptP + dU2 * vtV ; - PtrOwner pLine( new CurveLine) ; + PtrOwner pLine( new( nothrow) CurveLine) ; pLine->Set( ptPS, ptPE) ; // inserisco nel DB return AddGeoObj (vsParams[0], vsParams[1], Release( pLine)) ; } if ( nIntType == S_ONE_INT_TAN) { Point3d ptPS = ptP + dU1 * vtV ; - PtrOwner pLine( new CurveLine) ; + PtrOwner pLine( new( nothrow) CurveLine) ; pLine->Set( ptPS - vtV, ptPS + vtV) ; // inserisco nel DB return AddGeoObj( vsParams[0], vsParams[1], Release( pLine)) ; } if ( nIntType == S_ONE_INT_SEC) { Point3d ptPS = ptP + dU1 * vtV ; - PtrOwner pLine( new CurveLine) ; + PtrOwner pLine( new( nothrow) CurveLine) ; pLine->Set( ptPS - 3 * vtV, ptPS + 3 * vtV) ; // inserisco nel DB return AddGeoObj( vsParams[0], vsParams[1], Release( pLine)) ; @@ -3607,21 +3607,21 @@ GdbExecutor::LinCompSemiSphereInters( const STRVECTOR& vsParams) if ( nIntType == S_TWO_INT) { Point3d ptPS = ptP + dU1 * vtV ; Point3d ptPE = ptP + dU2 * vtV ; - PtrOwner pLine( new CurveLine) ; + PtrOwner pLine( new( nothrow) CurveLine) ; pLine->Set( ptPS, ptPE) ; // inserisco nel DB return AddGeoObj (vsParams[0], vsParams[1], Release( pLine)) ; } if ( nIntType == S_ONE_INT_TAN) { Point3d ptPS = ptP + dU1 * vtV ; - PtrOwner pLine( new CurveLine) ; + PtrOwner pLine( new( nothrow) CurveLine) ; pLine->Set( ptPS - vtV, ptPS + vtV) ; // inserisco nel DB return AddGeoObj( vsParams[0], vsParams[1], Release( pLine)) ; } if ( nIntType == S_ONE_INT_SEC) { Point3d ptPS = ptP + dU1 * vtV ; - PtrOwner pLine( new CurveLine) ; + PtrOwner pLine( new( nothrow) CurveLine) ; pLine->Set( ptPS - 3 * vtV, ptPS + 3 * vtV) ; // inserisco nel DB return AddGeoObj( vsParams[0], vsParams[1], Release( pLine)) ; @@ -3674,25 +3674,25 @@ GdbExecutor::LineInfiniteCylinderInters( const STRVECTOR& vsParams) if ( nTypeInt == CC_NO_INTERS) int nSol = 0 ; if ( nTypeInt == CC_ONE_INT_SEC) { - PtrOwner pLine( new CurveLine) ; + PtrOwner pLine( new( nothrow) CurveLine) ; pLine->Set( ptPS - 3 * vtLine, ptPS + 3 * vtLine) ; // inserisco nel DB return AddGeoObj( vsParams[0], vsParams[1], Release( pLine)) ; } if ( nTypeInt == CC_ONE_INT_TAN) { - PtrOwner pLine( new CurveLine) ; + PtrOwner pLine( new( nothrow) CurveLine) ; pLine->Set( ptPS - vtLine, ptPS + vtLine) ; // inserisco nel DB return AddGeoObj( vsParams[0], vsParams[1], Release( pLine)) ; } if ( nTypeInt == CC_TWO_INT) { - PtrOwner pLine( new CurveLine) ; + PtrOwner pLine( new( nothrow) CurveLine) ; pLine->Set( ptPS, ptPE) ; // inserisco nel DB return AddGeoObj( vsParams[0], vsParams[1], Release( pLine)) ; } if ( nTypeInt == CC_INF_INT) { - PtrOwner pLine( new CurveLine) ; + PtrOwner pLine( new( nothrow) CurveLine) ; pLine->Set( ptPS, ptPE) ; // inserisco nel DB return AddGeoObj( vsParams[0], vsParams[1], Release( pLine)) ; @@ -3745,25 +3745,25 @@ GdbExecutor::RayInfiniteCylinderInters( const STRVECTOR& vsParams) if ( nTypeInt == CC_NO_INTERS) int nSol = 0 ; if ( nTypeInt == CC_ONE_INT_SEC) { - PtrOwner pLine( new CurveLine) ; + PtrOwner pLine( new( nothrow) CurveLine) ; pLine->Set( ptPS - 3 * vtLine, ptPS + 3 * vtLine) ; // inserisco nel DB return AddGeoObj( vsParams[0], vsParams[1], Release( pLine)) ; } if ( nTypeInt == CC_ONE_INT_TAN) { - PtrOwner pLine( new CurveLine) ; + PtrOwner pLine( new( nothrow) CurveLine) ; pLine->Set( ptPS - vtLine, ptPS + vtLine) ; // inserisco nel DB return AddGeoObj( vsParams[0], vsParams[1], Release( pLine)) ; } if ( nTypeInt == CC_TWO_INT) { - PtrOwner pLine( new CurveLine) ; + PtrOwner pLine( new( nothrow) CurveLine) ; pLine->Set( ptPS, ptPE) ; // inserisco nel DB return AddGeoObj( vsParams[0], vsParams[1], Release( pLine)) ; } if ( nTypeInt == CC_INF_INT) { - PtrOwner pLine( new CurveLine) ; + PtrOwner pLine( new( nothrow) CurveLine) ; pLine->Set( ptPS, ptPE) ; // inserisco nel DB return AddGeoObj( vsParams[0], vsParams[1], Release( pLine)) ; @@ -3819,25 +3819,25 @@ GdbExecutor::SegmentInfiniteCylinderInters( const STRVECTOR& vsParams) if ( nTypeInt == CC_NO_INTERS) int nSol = 0 ; if ( nTypeInt == CC_ONE_INT_SEC) { - PtrOwner pLine( new CurveLine) ; + PtrOwner pLine( new( nothrow) CurveLine) ; pLine->Set( ptPS - 3 * vtLine, ptPS + 3 * vtLine) ; // inserisco nel DB return AddGeoObj( vsParams[0], vsParams[1], Release( pLine)) ; } if ( nTypeInt == CC_ONE_INT_TAN) { - PtrOwner pLine( new CurveLine) ; + PtrOwner pLine( new( nothrow) CurveLine) ; pLine->Set( ptPS - vtLine, ptPS + vtLine) ; // inserisco nel DB return AddGeoObj( vsParams[0], vsParams[1], Release( pLine)) ; } if ( nTypeInt == CC_TWO_INT) { - PtrOwner pLine( new CurveLine) ; + PtrOwner pLine( new( nothrow) CurveLine) ; pLine->Set( ptPS, ptPE) ; // inserisco nel DB return AddGeoObj( vsParams[0], vsParams[1], Release( pLine)) ; } if ( nTypeInt == CC_INF_INT) { - PtrOwner pLine( new CurveLine) ; + PtrOwner pLine( new( nothrow) CurveLine) ; pLine->Set( ptPS, ptPE) ; // inserisco nel DB return AddGeoObj( vsParams[0], vsParams[1], Release( pLine)) ; @@ -3897,25 +3897,25 @@ GdbExecutor::SegmentCylinderInters( const STRVECTOR& vsParams) if ( nTypeInt == CC_NO_INTERS) int nSol = 0 ; if ( nTypeInt == CC_ONE_INT_SEC) { - PtrOwner pLine( new CurveLine) ; + PtrOwner pLine( new( nothrow) CurveLine) ; pLine->Set( ptPS - 3 * vtLine, ptPS + 3 * vtLine) ; // inserisco nel DB return AddGeoObj( vsParams[0], vsParams[1], Release( pLine)) ; } if ( nTypeInt == CC_ONE_INT_TAN) { - PtrOwner pLine( new CurveLine) ; + PtrOwner pLine( new( nothrow) CurveLine) ; pLine->Set( ptPS - vtLine, ptPS + vtLine) ; // inserisco nel DB return AddGeoObj( vsParams[0], vsParams[1], Release( pLine)) ; } if ( nTypeInt == CC_TWO_INT) { - PtrOwner pLine( new CurveLine) ; + PtrOwner pLine( new( nothrow) CurveLine) ; pLine->Set( ptPS, ptPE) ; // inserisco nel DB return AddGeoObj( vsParams[0], vsParams[1], Release( pLine)) ; } if ( nTypeInt == CC_INF_INT) { - PtrOwner pLine( new CurveLine) ; + PtrOwner pLine( new( nothrow) CurveLine) ; pLine->Set( ptPS, ptPE) ; // inserisco nel DB return AddGeoObj( vsParams[0], vsParams[1], Release( pLine)) ; @@ -3975,31 +3975,31 @@ GdbExecutor::SegmentConeInters( const STRVECTOR& vsParams) if ( nTypeInt == CC_NO_INTERS) int nSol = 0 ; if ( nTypeInt == CC_ONE_INT_SEC) { - PtrOwner pLine( new CurveLine) ; + PtrOwner pLine( new( nothrow) CurveLine) ; pLine->Set( ptPS - 3 * vtLine, ptPS + 3 * vtLine) ; // inserisco nel DB return AddGeoObj( vsParams[0], vsParams[1], Release( pLine)) ; } if ( nTypeInt == CC_ONE_INT_TAN) { - PtrOwner pLine( new CurveLine) ; + PtrOwner pLine( new( nothrow) CurveLine) ; pLine->Set( ptPS - vtLine, ptPS + vtLine) ; // inserisco nel DB return AddGeoObj( vsParams[0], vsParams[1], Release( pLine)) ; } if ( nTypeInt == CC_TWO_INT) { - PtrOwner pLine( new CurveLine) ; + PtrOwner pLine( new( nothrow) CurveLine) ; pLine->Set( ptPS, ptPE) ; // inserisco nel DB return AddGeoObj( vsParams[0], vsParams[1], Release( pLine)) ; } if ( nTypeInt == CC_INF_INT) { - PtrOwner pLine( new CurveLine) ; + PtrOwner pLine( new( nothrow) CurveLine) ; pLine->Set( ptPS, ptPE) ; // inserisco nel DB return AddGeoObj( vsParams[0], vsParams[1], Release( pLine)) ; } if ( nTypeInt == CC_ON_VERT) { - PtrOwner pLine( new CurveLine) ; + PtrOwner pLine( new( nothrow) CurveLine) ; pLine->Set( ptPS - 6 * vtLine, ptPS + 6 * vtLine) ; // inserisco nel DB return AddGeoObj( vsParams[0], vsParams[1], Release( pLine)) ; @@ -4058,31 +4058,31 @@ GdbExecutor::LineTruncateConeInters( const STRVECTOR& vsParams) if ( nTypeInt == CC_NO_INTERS) int nSol = 0 ; if ( nTypeInt == CC_ONE_INT_SEC) { - PtrOwner pLine( new CurveLine) ; + PtrOwner pLine( new( nothrow) CurveLine) ; pLine->Set( ptPS - 3 * vtLine, ptPS + 3 * vtLine) ; // inserisco nel DB return AddGeoObj( vsParams[0], vsParams[1], Release( pLine)) ; } if ( nTypeInt == CC_ONE_INT_TAN) { - PtrOwner pLine( new CurveLine) ; + PtrOwner pLine( new( nothrow) CurveLine) ; pLine->Set( ptPS - vtLine, ptPS + vtLine) ; // inserisco nel DB return AddGeoObj( vsParams[0], vsParams[1], Release( pLine)) ; } if ( nTypeInt == CC_TWO_INT) { - PtrOwner pLine( new CurveLine) ; + PtrOwner pLine( new( nothrow) CurveLine) ; pLine->Set( ptPS, ptPE) ; // inserisco nel DB return AddGeoObj( vsParams[0], vsParams[1], Release( pLine)) ; } if ( nTypeInt == CC_INF_INT) { - PtrOwner pLine( new CurveLine) ; + PtrOwner pLine( new( nothrow) CurveLine) ; pLine->Set( ptPS, ptPE) ; // inserisco nel DB return AddGeoObj( vsParams[0], vsParams[1], Release( pLine)) ; } if ( nTypeInt == CC_ON_VERT) { - PtrOwner pLine( new CurveLine) ; + PtrOwner pLine( new( nothrow) CurveLine) ; pLine->Set( ptPS - 6 * vtLine, ptPS + 6 * vtLine) ; // inserisco nel DB return AddGeoObj( vsParams[0], vsParams[1], Release( pLine)) ; @@ -4142,31 +4142,31 @@ GdbExecutor::RayTruncateConeInters( const STRVECTOR& vsParams) if ( nTypeInt == CC_NO_INTERS) int nSol = 0 ; if ( nTypeInt == CC_ONE_INT_SEC) { - PtrOwner pLine( new CurveLine) ; + PtrOwner pLine( new( nothrow) CurveLine) ; pLine->Set( ptPS - 3 * vtLine, ptPS + 3 * vtLine) ; // inserisco nel DB return AddGeoObj( vsParams[0], vsParams[1], Release( pLine)) ; } if ( nTypeInt == CC_ONE_INT_TAN) { - PtrOwner pLine( new CurveLine) ; + PtrOwner pLine( new( nothrow) CurveLine) ; pLine->Set( ptPS - vtLine, ptPS + vtLine) ; // inserisco nel DB return AddGeoObj( vsParams[0], vsParams[1], Release( pLine)) ; } if ( nTypeInt == CC_TWO_INT) { - PtrOwner pLine( new CurveLine) ; + PtrOwner pLine( new( nothrow) CurveLine) ; pLine->Set( ptPS, ptPE) ; // inserisco nel DB return AddGeoObj( vsParams[0], vsParams[1], Release( pLine)) ; } if ( nTypeInt == CC_INF_INT) { - PtrOwner pLine( new CurveLine) ; + PtrOwner pLine( new( nothrow) CurveLine) ; pLine->Set( ptPS, ptPE) ; // inserisco nel DB return AddGeoObj( vsParams[0], vsParams[1], Release( pLine)) ; } if ( nTypeInt == CC_ON_VERT) { - PtrOwner pLine( new CurveLine) ; + PtrOwner pLine( new( nothrow) CurveLine) ; pLine->Set( ptPS - 6 * vtLine, ptPS + 6 * vtLine) ; // inserisco nel DB return AddGeoObj( vsParams[0], vsParams[1], Release( pLine)) ; @@ -4229,31 +4229,31 @@ GdbExecutor::SegmentTruncateConeInters( const STRVECTOR& vsParams) if ( nTypeInt == CC_NO_INTERS) int nSol = 0 ; if ( nTypeInt == CC_ONE_INT_SEC) { - PtrOwner pLine( new CurveLine) ; + PtrOwner pLine( new( nothrow) CurveLine) ; pLine->Set( ptPS - 3 * vtLine, ptPS + 3 * vtLine) ; // inserisco nel DB return AddGeoObj( vsParams[0], vsParams[1], Release( pLine)) ; } if ( nTypeInt == CC_ONE_INT_TAN) { - PtrOwner pLine( new CurveLine) ; + PtrOwner pLine( new( nothrow) CurveLine) ; pLine->Set( ptPS - vtLine, ptPS + vtLine) ; // inserisco nel DB return AddGeoObj( vsParams[0], vsParams[1], Release( pLine)) ; } if ( nTypeInt == CC_TWO_INT) { - PtrOwner pLine( new CurveLine) ; + PtrOwner pLine( new( nothrow) CurveLine) ; pLine->Set( ptPS, ptPE) ; // inserisco nel DB return AddGeoObj( vsParams[0], vsParams[1], Release( pLine)) ; } if ( nTypeInt == CC_INF_INT) { - PtrOwner pLine( new CurveLine) ; + PtrOwner pLine( new( nothrow) CurveLine) ; pLine->Set( ptPS, ptPE) ; // inserisco nel DB return AddGeoObj( vsParams[0], vsParams[1], Release( pLine)) ; } if ( nTypeInt == CC_ON_VERT) { - PtrOwner pLine( new CurveLine) ; + PtrOwner pLine( new( nothrow) CurveLine) ; pLine->Set( ptPS - 6 * vtLine, ptPS + 6 * vtLine) ; // inserisco nel DB return AddGeoObj( vsParams[0], vsParams[1], Release( pLine)) ; @@ -4308,7 +4308,7 @@ GdbExecutor::LineTorusInters( const STRVECTOR& vsParams) int nSol = 0 ; if ( nTypeInt == T_ONE_TAN) { Point3d ptInt = ptLine + vdP[0] * vtLine ; - PtrOwner pLine( new CurveLine) ; + PtrOwner pLine( new( nothrow) CurveLine) ; pLine->Set( ptInt - vtLine, ptInt + vtLine) ; // inserisco nel DB return AddGeoObj( vsParams[0], vsParams[1], Release( pLine)) ; @@ -4316,8 +4316,8 @@ GdbExecutor::LineTorusInters( const STRVECTOR& vsParams) if ( nTypeInt == T_TWO_TAN) { Point3d ptInt0 = ptLine + vdP[0] * vtLine ; Point3d ptInt1 = ptLine + vdP[1] * vtLine ; - PtrOwner pLine0( new CurveLine) ; - PtrOwner pLine1( new CurveLine) ; + PtrOwner pLine0( new( nothrow) CurveLine) ; + PtrOwner pLine1( new( nothrow) CurveLine) ; pLine0->Set( ptInt0 - vtLine, ptInt0 + vtLine) ; pLine1->Set( ptInt1 - vtLine, ptInt1 + vtLine) ; // inserisco nel DB @@ -4327,7 +4327,7 @@ GdbExecutor::LineTorusInters( const STRVECTOR& vsParams) if ( nTypeInt == T_TWO_SEC) { Point3d ptInt0 = ptLine + vdP[0] * vtLine ; Point3d ptInt1 = ptLine + vdP[1] * vtLine ; - PtrOwner pLine( new CurveLine) ; + PtrOwner pLine( new( nothrow) CurveLine) ; pLine->Set( ptInt0, ptInt1) ; // inserisco nel DB return AddGeoObj( vsParams[0], vsParams[1], Release( pLine)) ; @@ -4337,24 +4337,24 @@ GdbExecutor::LineTorusInters( const STRVECTOR& vsParams) Point3d ptInt1 = ptLine + vdP[1] * vtLine ; Point3d ptInt2 = ptLine + vdP[2] * vtLine ; if ( vbT[0] && vbT[1] && ( ! vbT[2])) { - PtrOwner pLine0( new CurveLine) ; + PtrOwner pLine0( new( nothrow) CurveLine) ; pLine0->Set( ptInt0, ptInt1) ; - PtrOwner pLine1( new CurveLine) ; + PtrOwner pLine1( new( nothrow) CurveLine) ; pLine1->Set( ptInt2 - vtLine, ptInt2 + vtLine) ; // inserisco nel DB return ( AddGeoObj( vsParams[0], vsParams[1], Release( pLine0)) && AddGeoObj( "$NN", vsParams[1], Release( pLine1))) ; } else if ( vbT[0] && ( ! vbT[1]) && vbT[2]) { - PtrOwner pLine( new CurveLine) ; + PtrOwner pLine( new( nothrow) CurveLine) ; pLine->Set( ptInt0, ptInt2) ; // inserisco nel DB return AddGeoObj( vsParams[0], vsParams[1], Release( pLine)) ; } else if ( ( ! vbT[0]) && vbT[1] && vbT[2]) { - PtrOwner pLine0( new CurveLine) ; + PtrOwner pLine0( new( nothrow) CurveLine) ; pLine0->Set( ptInt0 - vtLine, ptInt0 + vtLine) ; - PtrOwner pLine1( new CurveLine) ; + PtrOwner pLine1( new( nothrow) CurveLine) ; pLine1->Set( ptInt1, ptInt2) ; // inserisco nel DB return ( AddGeoObj( vsParams[0], vsParams[1], Release( pLine0)) && @@ -4366,9 +4366,9 @@ GdbExecutor::LineTorusInters( const STRVECTOR& vsParams) Point3d ptInt1 = ptLine + vdP[1] * vtLine ; Point3d ptInt2 = ptLine + vdP[2] * vtLine ; Point3d ptInt3 = ptLine + vdP[3] * vtLine ; - PtrOwner pLine0( new CurveLine) ; + PtrOwner pLine0( new( nothrow) CurveLine) ; pLine0->Set( ptInt0, ptInt1) ; - PtrOwner pLine1( new CurveLine) ; + PtrOwner pLine1( new( nothrow) CurveLine) ; pLine1->Set( ptInt2, ptInt3) ; // inserisco nel DB return ( AddGeoObj( vsParams[0], vsParams[1], Release( pLine0)) && @@ -4425,14 +4425,14 @@ GdbExecutor::RayTorusInters( const STRVECTOR& vsParams) int nSol = 0 ; if ( nTypeInt == T_ONE_TAN) { Point3d ptInt = ptLine + vdP[0] * vtLine ; - PtrOwner pLine( new CurveLine) ; + PtrOwner pLine( new( nothrow) CurveLine) ; pLine->Set( ptInt - vtLine, ptInt + vtLine) ; // inserisco nel DB return AddGeoObj( vsParams[0], vsParams[1], Release( pLine)) ; } if ( nTypeInt == T_ONE_SEC) { Point3d ptInt = ptLine + vdP[0] * vtLine ; - PtrOwner pLine( new CurveLine) ; + PtrOwner pLine( new( nothrow) CurveLine) ; pLine->Set( ptInt - 4 * vtLine, ptInt + 4 * vtLine) ; // inserisco nel DB return AddGeoObj( vsParams[0], vsParams[1], Release( pLine)) ; @@ -4440,8 +4440,8 @@ GdbExecutor::RayTorusInters( const STRVECTOR& vsParams) if ( nTypeInt == T_TWO_TAN) { Point3d ptInt0 = ptLine + vdP[0] * vtLine ; Point3d ptInt1 = ptLine + vdP[1] * vtLine ; - PtrOwner pLine0( new CurveLine) ; - PtrOwner pLine1( new CurveLine) ; + PtrOwner pLine0( new( nothrow) CurveLine) ; + PtrOwner pLine1( new( nothrow) CurveLine) ; pLine0->Set( ptInt0 - vtLine, ptInt0 + vtLine) ; pLine1->Set( ptInt1 - vtLine, ptInt1 + vtLine) ; // inserisco nel DB @@ -4451,7 +4451,7 @@ GdbExecutor::RayTorusInters( const STRVECTOR& vsParams) if ( nTypeInt == T_TWO_SEC) { Point3d ptInt0 = ptLine + vdP[0] * vtLine ; Point3d ptInt1 = ptLine + vdP[1] * vtLine ; - PtrOwner pLine( new CurveLine) ; + PtrOwner pLine( new( nothrow) CurveLine) ; pLine->Set( ptInt0, ptInt1) ; // inserisco nel DB return AddGeoObj( vsParams[0], vsParams[1], Release( pLine)) ; @@ -4461,9 +4461,9 @@ GdbExecutor::RayTorusInters( const STRVECTOR& vsParams) Point3d ptInt1 = ptLine + vdP[1] * vtLine ; double dDil0 = ( vbT[0] ? 4 : 1) ; double dDil1 = ( vbT[1] ? 4 : 1) ; - PtrOwner pLine0( new CurveLine) ; + PtrOwner pLine0( new( nothrow) CurveLine) ; pLine0->Set( ptInt0 - dDil0 * vtLine, ptInt0 + dDil0 * vtLine) ; - PtrOwner pLine1( new CurveLine) ; + PtrOwner pLine1( new( nothrow) CurveLine) ; pLine1->Set( ptInt1 - dDil1 * vtLine, ptInt1 + dDil1 * vtLine) ; // inserisco nel DB return ( AddGeoObj( vsParams[0], vsParams[1], Release( pLine0)) && @@ -4473,11 +4473,11 @@ GdbExecutor::RayTorusInters( const STRVECTOR& vsParams) Point3d ptInt0 = ptLine + vdP[0] * vtLine ; Point3d ptInt1 = ptLine + vdP[1] * vtLine ; Point3d ptInt2 = ptLine + vdP[2] * vtLine ; - PtrOwner pLine0( new CurveLine) ; + PtrOwner pLine0( new( nothrow) CurveLine) ; pLine0->Set( ptInt0 - 4 * vtLine, ptInt0 + 4 * vtLine) ; - PtrOwner pLine1( new CurveLine) ; + PtrOwner pLine1( new( nothrow) CurveLine) ; pLine1->Set( ptInt1 - 4 * vtLine, ptInt1 + 4 * vtLine) ; - PtrOwner pLine2( new CurveLine) ; + PtrOwner pLine2( new( nothrow) CurveLine) ; pLine2->Set( ptInt2 - 4 * vtLine, ptInt2 + 4 * vtLine) ; // inserisco nel DB return ( AddGeoObj( vsParams[0], vsParams[1], Release( pLine0)) && @@ -4489,24 +4489,24 @@ GdbExecutor::RayTorusInters( const STRVECTOR& vsParams) Point3d ptInt1 = ptLine + vdP[1] * vtLine ; Point3d ptInt2 = ptLine + vdP[2] * vtLine ; if ( vbT[0] && vbT[1] && ( ! vbT[2])) { - PtrOwner pLine0( new CurveLine) ; + PtrOwner pLine0( new( nothrow) CurveLine) ; pLine0->Set( ptInt0, ptInt1) ; - PtrOwner pLine1( new CurveLine) ; + PtrOwner pLine1( new( nothrow) CurveLine) ; pLine1->Set( ptInt2 - vtLine, ptInt2 + vtLine) ; // inserisco nel DB return ( AddGeoObj( vsParams[0], vsParams[1], Release( pLine0)) && AddGeoObj( "$NN", vsParams[1], Release( pLine1))) ; } else if ( vbT[0] && ( ! vbT[1]) && vbT[2]) { - PtrOwner pLine( new CurveLine) ; + PtrOwner pLine( new( nothrow) CurveLine) ; pLine->Set( ptInt0, ptInt2) ; // inserisco nel DB return AddGeoObj( vsParams[0], vsParams[1], Release( pLine)) ; } else if ( ( ! vbT[0]) && vbT[1] && vbT[2]) { - PtrOwner pLine0( new CurveLine) ; + PtrOwner pLine0( new( nothrow) CurveLine) ; pLine0->Set( ptInt0 - vtLine, ptInt0 + vtLine) ; - PtrOwner pLine1( new CurveLine) ; + PtrOwner pLine1( new( nothrow) CurveLine) ; pLine1->Set( ptInt1, ptInt2) ; // inserisco nel DB return ( AddGeoObj( vsParams[0], vsParams[1], Release( pLine0)) && @@ -4518,9 +4518,9 @@ GdbExecutor::RayTorusInters( const STRVECTOR& vsParams) Point3d ptInt1 = ptLine + vdP[1] * vtLine ; Point3d ptInt2 = ptLine + vdP[2] * vtLine ; Point3d ptInt3 = ptLine + vdP[3] * vtLine ; - PtrOwner pLine0( new CurveLine) ; + PtrOwner pLine0( new( nothrow) CurveLine) ; pLine0->Set( ptInt0, ptInt1) ; - PtrOwner pLine1( new CurveLine) ; + PtrOwner pLine1( new( nothrow) CurveLine) ; pLine1->Set( ptInt2, ptInt3) ; // inserisco nel DB return ( AddGeoObj( vsParams[0], vsParams[1], Release( pLine0)) && @@ -4581,14 +4581,14 @@ GdbExecutor::SegmentTorusInters( const STRVECTOR& vsParams) int nSol = 0 ; if ( nTypeInt == T_ONE_TAN) { Point3d ptInt = ptLine + vdP[0] * vtLine ; - PtrOwner pLine( new CurveLine) ; + PtrOwner pLine( new( nothrow) CurveLine) ; pLine->Set( ptInt - vtLine, ptInt + vtLine) ; // inserisco nel DB return AddGeoObj( vsParams[0], vsParams[1], Release( pLine)) ; } if ( nTypeInt == T_ONE_SEC) { Point3d ptInt = ptLine + vdP[0] * vtLine ; - PtrOwner pLine( new CurveLine) ; + PtrOwner pLine( new( nothrow) CurveLine) ; pLine->Set( ptInt - 4 * vtLine, ptInt + 4 * vtLine) ; // inserisco nel DB return AddGeoObj( vsParams[0], vsParams[1], Release( pLine)) ; @@ -4596,8 +4596,8 @@ GdbExecutor::SegmentTorusInters( const STRVECTOR& vsParams) if ( nTypeInt == T_TWO_TAN) { Point3d ptInt0 = ptLine + vdP[0] * vtLine ; Point3d ptInt1 = ptLine + vdP[1] * vtLine ; - PtrOwner pLine0( new CurveLine) ; - PtrOwner pLine1( new CurveLine) ; + PtrOwner pLine0( new( nothrow) CurveLine) ; + PtrOwner pLine1( new( nothrow) CurveLine) ; pLine0->Set( ptInt0 - vtLine, ptInt0 + vtLine) ; pLine1->Set( ptInt1 - vtLine, ptInt1 + vtLine) ; // inserisco nel DB @@ -4607,8 +4607,8 @@ GdbExecutor::SegmentTorusInters( const STRVECTOR& vsParams) if ( nTypeInt == T_TWO_SEC) { Point3d ptInt0 = ptLine + vdP[0] * vtLine ; Point3d ptInt1 = ptLine + vdP[1] * vtLine ; - PtrOwner pLine0( new CurveLine) ; - PtrOwner pLine1( new CurveLine) ; + PtrOwner pLine0( new( nothrow) CurveLine) ; + PtrOwner pLine1( new( nothrow) CurveLine) ; pLine0->Set( ptInt0 - 4 * vtLine, ptInt0 + 4 * vtLine) ; pLine1->Set( ptInt1 - 4 * vtLine, ptInt1 + 4 * vtLine) ; // inserisco nel DB @@ -4620,9 +4620,9 @@ GdbExecutor::SegmentTorusInters( const STRVECTOR& vsParams) Point3d ptInt1 = ptLine + vdP[1] * vtLine ; double dDil0 = ( vbT[0] ? 4 : 1) ; double dDil1 = ( vbT[1] ? 4 : 1) ; - PtrOwner pLine0( new CurveLine) ; + PtrOwner pLine0( new( nothrow) CurveLine) ; pLine0->Set( ptInt0 - dDil0 * vtLine, ptInt0 + dDil0 * vtLine) ; - PtrOwner pLine1( new CurveLine) ; + PtrOwner pLine1( new( nothrow) CurveLine) ; pLine1->Set( ptInt1 - dDil1 * vtLine, ptInt1 + dDil1 * vtLine) ; // inserisco nel DB return ( AddGeoObj( vsParams[0], vsParams[1], Release( pLine0)) && @@ -4632,11 +4632,11 @@ GdbExecutor::SegmentTorusInters( const STRVECTOR& vsParams) Point3d ptInt0 = ptLine + vdP[0] * vtLine ; Point3d ptInt1 = ptLine + vdP[1] * vtLine ; Point3d ptInt2 = ptLine + vdP[2] * vtLine ; - PtrOwner pLine0( new CurveLine) ; + PtrOwner pLine0( new( nothrow) CurveLine) ; pLine0->Set( ptInt0 - 4 * vtLine, ptInt0 + 4 * vtLine) ; - PtrOwner pLine1( new CurveLine) ; + PtrOwner pLine1( new( nothrow) CurveLine) ; pLine1->Set( ptInt1 - 4 * vtLine, ptInt1 + 4 * vtLine) ; - PtrOwner pLine2( new CurveLine) ; + PtrOwner pLine2( new( nothrow) CurveLine) ; pLine2->Set( ptInt2 - 4 * vtLine, ptInt2 + 4 * vtLine) ; // inserisco nel DB return ( AddGeoObj( vsParams[0], vsParams[1], Release( pLine0)) && @@ -4648,11 +4648,11 @@ GdbExecutor::SegmentTorusInters( const STRVECTOR& vsParams) Point3d ptInt1 = ptLine + vdP[1] * vtLine ; Point3d ptInt2 = ptLine + vdP[2] * vtLine ; if ( vbT[0] && vbT[1] && ( ! vbT[2])) { - PtrOwner pLine0( new CurveLine) ; + PtrOwner pLine0( new( nothrow) CurveLine) ; pLine0->Set( ptInt0 - 4 * vtLine, ptInt0 + 4 * vtLine) ; - PtrOwner pLine1( new CurveLine) ; + PtrOwner pLine1( new( nothrow) CurveLine) ; pLine1->Set( ptInt1 - 4 * vtLine, ptInt1 + 4 * vtLine) ; - PtrOwner pLine2( new CurveLine) ; + PtrOwner pLine2( new( nothrow) CurveLine) ; pLine2->Set( ptInt2 - vtLine, ptInt2 + vtLine) ; // inserisco nel DB return ( AddGeoObj( vsParams[0], vsParams[1], Release( pLine0)) && @@ -4660,11 +4660,11 @@ GdbExecutor::SegmentTorusInters( const STRVECTOR& vsParams) AddGeoObj( "$NN", vsParams[1], Release( pLine2))) ; } else if ( vbT[0] && ( ! vbT[1]) && vbT[2]) { - PtrOwner pLine0( new CurveLine) ; + PtrOwner pLine0( new( nothrow) CurveLine) ; pLine0->Set( ptInt0 - 4 * vtLine, ptInt0 + 4 * vtLine) ; - PtrOwner pLine1( new CurveLine) ; + PtrOwner pLine1( new( nothrow) CurveLine) ; pLine1->Set( ptInt1 - vtLine, ptInt1 + vtLine) ; - PtrOwner pLine2( new CurveLine) ; + PtrOwner pLine2( new( nothrow) CurveLine) ; pLine2->Set( ptInt2 - 4 * vtLine, ptInt2 + 4 * vtLine) ; // inserisco nel DB return ( AddGeoObj( vsParams[0], vsParams[1], Release( pLine0)) && @@ -4672,11 +4672,11 @@ GdbExecutor::SegmentTorusInters( const STRVECTOR& vsParams) AddGeoObj( "$NN", vsParams[1], Release( pLine2))) ; } else if ( ( ! vbT[0]) && vbT[1] && vbT[2]) { - PtrOwner pLine0( new CurveLine) ; + PtrOwner pLine0( new( nothrow) CurveLine) ; pLine0->Set( ptInt0 - vtLine, ptInt0 + vtLine) ; - PtrOwner pLine1( new CurveLine) ; + PtrOwner pLine1( new( nothrow) CurveLine) ; pLine1->Set( ptInt1 - 4 * vtLine, ptInt1 + 4 * vtLine) ; - PtrOwner pLine2( new CurveLine) ; + PtrOwner pLine2( new( nothrow) CurveLine) ; pLine2->Set( ptInt2 - 4 * vtLine, ptInt2 + 4 * vtLine) ; // inserisco nel DB return ( AddGeoObj( vsParams[0], vsParams[1], Release( pLine0)) && @@ -4689,9 +4689,9 @@ GdbExecutor::SegmentTorusInters( const STRVECTOR& vsParams) Point3d ptInt1 = ptLine + vdP[1] * vtLine ; Point3d ptInt2 = ptLine + vdP[2] * vtLine ; Point3d ptInt3 = ptLine + vdP[3] * vtLine ; - PtrOwner pLine0( new CurveLine) ; + PtrOwner pLine0( new( nothrow) CurveLine) ; pLine0->Set( ptInt0, ptInt1) ; - PtrOwner pLine1( new CurveLine) ; + PtrOwner pLine1( new( nothrow) CurveLine) ; pLine1->Set( ptInt2, ptInt3) ; // inserisco nel DB return ( AddGeoObj( vsParams[0], vsParams[1], Release( pLine0)) && @@ -4755,14 +4755,14 @@ GdbExecutor::LinCompTorusPartInters( const STRVECTOR& vsParams) int nSol = 0 ; if ( nTypeInt == T_ONE_TAN) { Point3d ptInt = ptLine + vdP[0] * vtLine ; - PtrOwner pLine( new CurveLine) ; + PtrOwner pLine( new( nothrow) CurveLine) ; pLine->Set( ptInt - vtLine, ptInt + vtLine) ; // inserisco nel DB return AddGeoObj( vsParams[0], vsParams[1], Release( pLine)) ; } if ( nTypeInt == T_ONE_SEC) { Point3d ptInt = ptLine + vdP[0] * vtLine ; - PtrOwner pLine( new CurveLine) ; + PtrOwner pLine( new( nothrow) CurveLine) ; pLine->Set( ptInt - 4 * vtLine, ptInt + 4 * vtLine) ; // inserisco nel DB return AddGeoObj( vsParams[0], vsParams[1], Release( pLine)) ; @@ -4770,8 +4770,8 @@ GdbExecutor::LinCompTorusPartInters( const STRVECTOR& vsParams) if ( nTypeInt == T_TWO_TAN) { Point3d ptInt0 = ptLine + vdP[0] * vtLine ; Point3d ptInt1 = ptLine + vdP[1] * vtLine ; - PtrOwner pLine0( new CurveLine) ; - PtrOwner pLine1( new CurveLine) ; + PtrOwner pLine0( new( nothrow) CurveLine) ; + PtrOwner pLine1( new( nothrow) CurveLine) ; pLine0->Set( ptInt0 - vtLine, ptInt0 + vtLine) ; pLine1->Set( ptInt1 - vtLine, ptInt1 + vtLine) ; // inserisco nel DB @@ -4781,8 +4781,8 @@ GdbExecutor::LinCompTorusPartInters( const STRVECTOR& vsParams) if ( nTypeInt == T_TWO_SEC) { Point3d ptInt0 = ptLine + vdP[0] * vtLine ; Point3d ptInt1 = ptLine + vdP[1] * vtLine ; - PtrOwner pLine0( new CurveLine) ; - PtrOwner pLine1( new CurveLine) ; + PtrOwner pLine0( new( nothrow) CurveLine) ; + PtrOwner pLine1( new( nothrow) CurveLine) ; pLine0->Set( ptInt0 - 4 * vtLine, ptInt0 + 4 * vtLine) ; pLine1->Set( ptInt1 - 4 * vtLine, ptInt1 + 4 * vtLine) ; // inserisco nel DB @@ -4794,9 +4794,9 @@ GdbExecutor::LinCompTorusPartInters( const STRVECTOR& vsParams) Point3d ptInt1 = ptLine + vdP[1] * vtLine ; double dDil0 = ( vbT[0] ? 4 : 1) ; double dDil1 = ( vbT[1] ? 4 : 1) ; - PtrOwner pLine0( new CurveLine) ; + PtrOwner pLine0( new( nothrow) CurveLine) ; pLine0->Set( ptInt0 - dDil0 * vtLine, ptInt0 + dDil0 * vtLine) ; - PtrOwner pLine1( new CurveLine) ; + PtrOwner pLine1( new( nothrow) CurveLine) ; pLine1->Set( ptInt1 - dDil1 * vtLine, ptInt1 + dDil1 * vtLine) ; // inserisco nel DB return ( AddGeoObj( vsParams[0], vsParams[1], Release( pLine0)) && @@ -4806,11 +4806,11 @@ GdbExecutor::LinCompTorusPartInters( const STRVECTOR& vsParams) Point3d ptInt0 = ptLine + vdP[0] * vtLine ; Point3d ptInt1 = ptLine + vdP[1] * vtLine ; Point3d ptInt2 = ptLine + vdP[2] * vtLine ; - PtrOwner pLine0( new CurveLine) ; + PtrOwner pLine0( new( nothrow) CurveLine) ; pLine0->Set( ptInt0 - 4 * vtLine, ptInt0 + 4 * vtLine) ; - PtrOwner pLine1( new CurveLine) ; + PtrOwner pLine1( new( nothrow) CurveLine) ; pLine1->Set( ptInt1 - 4 * vtLine, ptInt1 + 4 * vtLine) ; - PtrOwner pLine2( new CurveLine) ; + PtrOwner pLine2( new( nothrow) CurveLine) ; pLine2->Set( ptInt2 - 4 * vtLine, ptInt2 + 4 * vtLine) ; // inserisco nel DB return ( AddGeoObj( vsParams[0], vsParams[1], Release( pLine0)) && @@ -4822,11 +4822,11 @@ GdbExecutor::LinCompTorusPartInters( const STRVECTOR& vsParams) Point3d ptInt1 = ptLine + vdP[1] * vtLine ; Point3d ptInt2 = ptLine + vdP[2] * vtLine ; if ( vbT[0] && vbT[1] && ( ! vbT[2])) { - PtrOwner pLine0( new CurveLine) ; + PtrOwner pLine0( new( nothrow) CurveLine) ; pLine0->Set( ptInt0 - 4 * vtLine, ptInt0 + 4 * vtLine) ; - PtrOwner pLine1( new CurveLine) ; + PtrOwner pLine1( new( nothrow) CurveLine) ; pLine1->Set( ptInt1 - 4 * vtLine, ptInt1 + 4 * vtLine) ; - PtrOwner pLine2( new CurveLine) ; + PtrOwner pLine2( new( nothrow) CurveLine) ; pLine2->Set( ptInt2 - vtLine, ptInt2 + vtLine) ; // inserisco nel DB return ( AddGeoObj( vsParams[0], vsParams[1], Release( pLine0)) && @@ -4834,11 +4834,11 @@ GdbExecutor::LinCompTorusPartInters( const STRVECTOR& vsParams) AddGeoObj( "$NN", vsParams[1], Release( pLine2))) ; } else if ( vbT[0] && ( ! vbT[1]) && vbT[2]) { - PtrOwner pLine0( new CurveLine) ; + PtrOwner pLine0( new( nothrow) CurveLine) ; pLine0->Set( ptInt0 - 4 * vtLine, ptInt0 + 4 * vtLine) ; - PtrOwner pLine1( new CurveLine) ; + PtrOwner pLine1( new( nothrow) CurveLine) ; pLine1->Set( ptInt1 - vtLine, ptInt1 + vtLine) ; - PtrOwner pLine2( new CurveLine) ; + PtrOwner pLine2( new( nothrow) CurveLine) ; pLine2->Set( ptInt2 - 4 * vtLine, ptInt2 + 4 * vtLine) ; // inserisco nel DB return ( AddGeoObj( vsParams[0], vsParams[1], Release( pLine0)) && @@ -4846,11 +4846,11 @@ GdbExecutor::LinCompTorusPartInters( const STRVECTOR& vsParams) AddGeoObj( "$NN", vsParams[1], Release( pLine2))) ; } else if ( ( ! vbT[0]) && vbT[1] && vbT[2]) { - PtrOwner pLine0( new CurveLine) ; + PtrOwner pLine0( new( nothrow) CurveLine) ; pLine0->Set( ptInt0 - vtLine, ptInt0 + vtLine) ; - PtrOwner pLine1( new CurveLine) ; + PtrOwner pLine1( new( nothrow) CurveLine) ; pLine1->Set( ptInt1 - 4 * vtLine, ptInt1 + 4 * vtLine) ; - PtrOwner pLine2( new CurveLine) ; + PtrOwner pLine2( new( nothrow) CurveLine) ; pLine2->Set( ptInt2 - 4 * vtLine, ptInt2 + 4 * vtLine) ; // inserisco nel DB return ( AddGeoObj( vsParams[0], vsParams[1], Release( pLine0)) && @@ -4863,9 +4863,9 @@ GdbExecutor::LinCompTorusPartInters( const STRVECTOR& vsParams) Point3d ptInt1 = ptLine + vdP[1] * vtLine ; Point3d ptInt2 = ptLine + vdP[2] * vtLine ; Point3d ptInt3 = ptLine + vdP[3] * vtLine ; - PtrOwner pLine0( new CurveLine) ; + PtrOwner pLine0( new( nothrow) CurveLine) ; pLine0->Set( ptInt0, ptInt1) ; - PtrOwner pLine1( new CurveLine) ; + PtrOwner pLine1( new( nothrow) CurveLine) ; pLine1->Set( ptInt2, ptInt3) ; // inserisco nel DB return ( AddGeoObj( vsParams[0], vsParams[1], Release( pLine0)) && diff --git a/GdbIterator.cpp b/GdbIterator.cpp index 9953a06..07b7e9d 100644 --- a/GdbIterator.cpp +++ b/GdbIterator.cpp @@ -26,7 +26,7 @@ CreateGdbIterator( IGeomDB* pGDB) { if ( dynamic_cast( pGDB) == nullptr) return nullptr ; - return static_cast ( new GdbIterator( pGDB)) ; + return static_cast ( new( nothrow) GdbIterator( pGDB)) ; } //---------------------------------------------------------------------------- diff --git a/GdbObj.cpp b/GdbObj.cpp index ed6f34e..6bf4aaa 100644 --- a/GdbObj.cpp +++ b/GdbObj.cpp @@ -368,7 +368,7 @@ Attribs* GdbObj::GetSafeAttribs( void) { if ( m_pAttribs == nullptr) { - Attribs* pAttribs = new (nothrow) Attribs ; + Attribs* pAttribs = new( nothrow) Attribs ; if ( pAttribs == nullptr) return nullptr ; m_pAttribs = pAttribs ; @@ -1052,7 +1052,7 @@ TextureData* GdbObj::GetSafeTextureData( void) { if ( m_pTxrData == nullptr) { - TextureData* pTxrData = new (nothrow) TextureData ; + TextureData* pTxrData = new( nothrow) TextureData ; if ( pTxrData == nullptr) return nullptr ; m_pTxrData = pTxrData ; @@ -1183,7 +1183,7 @@ GdbObj::LoadUserObj( NgeReader& ngeIn, int nBaseGdbId) m_pUserObj = USEROBJ_CREATE( sName) ; // se non trovato uso quello di default if ( m_pUserObj == nullptr) - m_pUserObj = new(nothrow) UserObjDefault( sName) ; ; + m_pUserObj = new( nothrow) UserObjDefault( sName) ; ; if ( m_pUserObj == nullptr) return false ; // carico i dati nell'oggetto diff --git a/GeoFrame3d.cpp b/GeoFrame3d.cpp index b197825..363074b 100644 --- a/GeoFrame3d.cpp +++ b/GeoFrame3d.cpp @@ -87,7 +87,7 @@ GeoFrame3d* GeoFrame3d::Clone( void) const { // alloco oggetto - GeoFrame3d* pGFr = new(nothrow) GeoFrame3d ; + GeoFrame3d* pGFr = new( nothrow) GeoFrame3d ; if ( pGFr != nullptr) { if ( ! pGFr->CopyFrom( *this)) { delete pGFr ; diff --git a/GeoPoint3d.cpp b/GeoPoint3d.cpp index 6adc021..72d129f 100644 --- a/GeoPoint3d.cpp +++ b/GeoPoint3d.cpp @@ -55,7 +55,7 @@ GeoPoint3d* GeoPoint3d::Clone( void) const { // alloco oggetto - GeoPoint3d* pGPt = new(nothrow) GeoPoint3d ; + GeoPoint3d* pGPt = new( nothrow) GeoPoint3d ; if ( pGPt != nullptr) { if ( ! pGPt->CopyFrom( *this)) { delete pGPt ; diff --git a/GeoVector3d.cpp b/GeoVector3d.cpp index 1ae7e36..c4f812d 100644 --- a/GeoVector3d.cpp +++ b/GeoVector3d.cpp @@ -71,7 +71,7 @@ GeoVector3d* GeoVector3d::Clone( void) const { // alloco oggetto - GeoVector3d* pGVt = new(nothrow) GeoVector3d ; + GeoVector3d* pGVt = new( nothrow) GeoVector3d ; if ( pGVt != nullptr) { if ( ! pGVt->CopyFrom( *this)) { delete pGVt ; diff --git a/GeomDB.cpp b/GeomDB.cpp index 8ca56a2..3ace107 100644 --- a/GeomDB.cpp +++ b/GeomDB.cpp @@ -54,7 +54,7 @@ CreateGeomDB( void) } } // creo il GeomDB - return static_cast ( new(nothrow) GeomDB) ; + return static_cast ( new( nothrow) GeomDB) ; } //---------------------------------------------------------------------------- @@ -547,7 +547,7 @@ GeomDB::InsertGroup( int nId, int nRefId, int nSonBeforeAfter, const Frame3d& fr if ( ExistsObj( nId)) return GDB_ID_NULL ; // alloco gruppo Gdb - GdbGroup* pGdbGroup = new(nothrow) GdbGroup ; + GdbGroup* pGdbGroup = new( nothrow) GdbGroup ; if ( pGdbGroup == nullptr) return GDB_ID_NULL ; // assegno identificativo @@ -585,7 +585,7 @@ GeomDB::InsertGeoObj( int nId, int nRefId, int nSonBeforeAfter, IGeoObj* pGeoObj if ( IsNull( pRPGeoObj) || ! pRPGeoObj->IsValid()) return GDB_ID_NULL ; // alloco oggetto Gdb - GdbGeo* pGdbGeo = new(nothrow) GdbGeo ; + GdbGeo* pGdbGeo = new( nothrow) GdbGeo ; if ( pGdbGeo == nullptr) return GDB_ID_NULL ; // assegno identificativo diff --git a/HashGrids2d.cpp b/HashGrids2d.cpp index 12a9607..e09af88 100644 --- a/HashGrids2d.cpp +++ b/HashGrids2d.cpp @@ -103,7 +103,7 @@ HashGrid2d::HashGrid2d( double dCellSpan) m_enlargementThreshold = m_xyCellCount / minimalGridDensity ; // allocazione dell'array lineare che rappresenta lo hash grid. - m_cell = new Cell[ m_xyCellCount] ; + m_cell = new( nothrow) Cell[ m_xyCellCount] ; // ogni cella è già inizializzata come vuota // imposto gli offset ai vicini @@ -274,7 +274,7 @@ HashGrid2d::InitNeighborOffsets( void) if ( x == 0 || x == (xc - 1) || y == 0 || y == (yc - 1)) { - c->m_neighborOffset = new int[9] ; + c->m_neighborOffset = new( nothrow) int[9] ; i = 0 ; for ( int yy = -xc ; yy <= xc ; yy += xc) { @@ -352,7 +352,7 @@ HashGrid2d::Add( HashGrids2d::ObjData& obj, Cell* cell) // reserved). Furthermore, the cell must be inserted into the grid-global vector 'm_occupiedCells' // in which all cells that are currently occupied by bodies are recorded. else { - cell->m_Objs = new HashGrids2d::PtrObjVector ; + cell->m_Objs = new( nothrow) HashGrids2d::PtrObjVector ; cell->m_Objs->reserve( cellVectorSize) ; obj.nCellId = 0 ; @@ -441,7 +441,7 @@ HashGrid2d::Enlarge( void) m_enlargementThreshold = m_xyCellCount / minimalGridDensity ; // ... a new linear array of cells representing this enlarged hash grid is allocated and ... - m_cell = new Cell[ m_xyCellCount] ; + m_cell = new( nothrow) Cell[ m_xyCellCount] ; // ... initialized, and finally ... InitNeighborOffsets() ; @@ -695,7 +695,7 @@ HashGrids2d::addGrid( ObjData& obj) // If no hash grid yet exists in the hierarchy, an initial hash grid is created // based on the body's size. - pGrid = new HashGrid2d( size * sqrt( hierarchyFactor)) ; + pGrid = new( nothrow) HashGrid2d( size * sqrt( hierarchyFactor)) ; } else { // Check the hierarchy for a hash grid with suitably sized cells - if such a grid does not @@ -711,7 +711,7 @@ HashGrids2d::addGrid( ObjData& obj) if ( size < cellSpan ) { while ( size < cellSpan) cellSpan /= hierarchyFactor ; - pGrid = new HashGrid2d( cellSpan * hierarchyFactor) ; + pGrid = new( nothrow) HashGrid2d( cellSpan * hierarchyFactor) ; m_GridList.insert( g, pGrid) ; } @@ -724,7 +724,7 @@ HashGrids2d::addGrid( ObjData& obj) while ( size >= cellSpan) cellSpan *= hierarchyFactor ; - pGrid = new HashGrid2d( cellSpan) ; + pGrid = new( nothrow) HashGrid2d( cellSpan) ; } pGrid->Add( obj) ; diff --git a/HashGrids3d.cpp b/HashGrids3d.cpp index a5009db..d3558ad 100644 --- a/HashGrids3d.cpp +++ b/HashGrids3d.cpp @@ -110,7 +110,7 @@ HashGrid3d::HashGrid3d( double dCellSpan) m_enlargementThreshold = m_xyzCellCount / minimalGridDensity ; // allocazione dell'array lineare che rappresenta lo hash grid. - m_cell = new Cell[ m_xyzCellCount] ; + m_cell = new( nothrow) Cell[ m_xyzCellCount] ; // ogni cella è già inizializzata come vuota // imposto gli offset ai vicini @@ -294,7 +294,7 @@ HashGrid3d::InitNeighborOffsets( void) y == 0 || y == (yc - 1) || z == 0 || z == (zc - 1)) { - c->m_neighborOffset = new int[27] ; + c->m_neighborOffset = new( nothrow) int[27] ; i = 0 ; for ( int zz = -xyc; zz <= xyc; zz += xyc ) { @@ -485,7 +485,7 @@ HashGrid3d::Enlarge( void) m_enlargementThreshold = m_xyzCellCount / minimalGridDensity ; // ... a new linear array of cells representing this enlarged hash grid is allocated and ... - m_cell = new Cell[ m_xyzCellCount] ; + m_cell = new( nothrow) Cell[ m_xyzCellCount] ; // ... initialized, and finally ... InitNeighborOffsets() ; @@ -738,7 +738,7 @@ HashGrids3d::addGrid( ObjData& obj) // If no hash grid yet exists in the hierarchy, an initial hash grid is created // based on the body's size. - pGrid = new HashGrid3d( size * sqrt( hierarchyFactor)) ; + pGrid = new( nothrow) HashGrid3d( size * sqrt( hierarchyFactor)) ; } else { // Check the hierarchy for a hash grid with suitably sized cells - if such a grid does not @@ -754,7 +754,7 @@ HashGrids3d::addGrid( ObjData& obj) if ( size < cellSpan ) { while ( size < cellSpan) cellSpan /= hierarchyFactor ; - pGrid = new HashGrid3d( cellSpan * hierarchyFactor) ; + pGrid = new( nothrow) HashGrid3d( cellSpan * hierarchyFactor) ; m_GridList.insert( g, pGrid) ; } @@ -767,7 +767,7 @@ HashGrids3d::addGrid( ObjData& obj) while ( size >= cellSpan) cellSpan *= hierarchyFactor ; - pGrid = new HashGrid3d( cellSpan) ; + pGrid = new( nothrow) HashGrid3d( cellSpan) ; } pGrid->Add( obj) ; diff --git a/NgeReader.cpp b/NgeReader.cpp index 5877176..365eeda 100644 --- a/NgeReader.cpp +++ b/NgeReader.cpp @@ -315,7 +315,7 @@ NgeReader::ReadString( string& sVal, const char* szSep, bool bEndL) m_InFile.read( (char*) &nDim, sizeof( nDim)) ; if ( nDim > MAX_STR_DIM || ! m_InFile.good()) return false ; - char* szBuff = new char[ nDim + 1] ; + char* szBuff = new( nothrow) char[ nDim + 1] ; if ( szBuff == nullptr) return false ; m_InFile.read( szBuff, nDim) ; diff --git a/SurfFlatRegion.cpp b/SurfFlatRegion.cpp index 97cb705..15990d3 100644 --- a/SurfFlatRegion.cpp +++ b/SurfFlatRegion.cpp @@ -330,7 +330,7 @@ SurfFlatRegion* SurfFlatRegion::Clone( void) const { // alloco oggetto - SurfFlatRegion* pSfr = new(nothrow) SurfFlatRegion ; + SurfFlatRegion* pSfr = new( nothrow) SurfFlatRegion ; if ( pSfr != nullptr) { if ( ! pSfr->CopyFrom( *this)) { delete pSfr ; diff --git a/SurfFlatRegionBooleans.cpp b/SurfFlatRegionBooleans.cpp index 3d50a8a..19e7a35 100644 --- a/SurfFlatRegionBooleans.cpp +++ b/SurfFlatRegionBooleans.cpp @@ -165,7 +165,7 @@ SurfFlatRegion::Subtract( const ISurfFlatRegion& Other) // creo una nuova regione a partire da questi loop PtrOwner pSfr ; if ( vpLoop.size() == 0) - pSfr.Set( new SurfFlatRegion) ; + pSfr.Set( new( nothrow) SurfFlatRegion) ; else pSfr.Set( MyNewSurfFromLoops( vpLoop)) ; if ( IsNull( pSfr)) { @@ -252,7 +252,7 @@ SurfFlatRegion::Intersect( const ISurfFlatRegion& Other) // creo una nuova regione a partire da questi loop PtrOwner pSfr ; if ( vpLoop.size() == 0) - pSfr.Set( new SurfFlatRegion) ; + pSfr.Set( new( nothrow) SurfFlatRegion) ; else pSfr.Set( MyNewSurfFromLoops( vpLoop)) ; if ( IsNull( pSfr)) { diff --git a/SurfFlatRegionOffset.cpp b/SurfFlatRegionOffset.cpp index 977bc50..be335b2 100644 --- a/SurfFlatRegionOffset.cpp +++ b/SurfFlatRegionOffset.cpp @@ -28,14 +28,14 @@ SurfFlatRegion::Offset( double dDist, int nType) if ( nChunk == 0) return false ; // creo una nuova regione - PtrOwner pSfr( new SurfFlatRegion) ; + PtrOwner pSfr( new( nothrow) SurfFlatRegion) ; if ( IsNull( pSfr)) return false ; bool bFirstRegion = true ; // ciclo sui chunk for ( int i = 0 ; i < nChunk ; ++ i) { // creo la regione del chunk - PtrOwner pSfrChk( new SurfFlatRegion) ; + PtrOwner pSfrChk( new( nothrow) SurfFlatRegion) ; if ( IsNull( pSfrChk)) return false ; bool bFirstCurve = true ; @@ -69,7 +69,7 @@ SurfFlatRegion::Offset( double dDist, int nType) if ( ! bExtLoop) pOffs->Invert() ; // creo la regione - PtrOwner pSfr2( new SurfFlatRegion) ; + PtrOwner pSfr2( new( nothrow) SurfFlatRegion) ; if ( IsNull( pSfr2) || ! pSfr2->AddExtLoop( Release( pOffs))) return false ; // se era loop esterno, lo aggiungo alla nuova regione diff --git a/SurfTriMesh.cpp b/SurfTriMesh.cpp index 5c7e956..d7e16ac 100644 --- a/SurfTriMesh.cpp +++ b/SurfTriMesh.cpp @@ -373,14 +373,14 @@ SurfTriMesh::GetVertex( int nId, Point3d& ptP) const //---------------------------------------------------------------------------- int -SurfTriMesh::GetFirstVertex( Point3d& ptP) const +SurfTriMesh::GetFirstVertex( Point3d& ptP) const { - return GetNextVertex( SVT_NULL, ptP) ; + return GetNextVertex( SVT_NULL, ptP) ; } //---------------------------------------------------------------------------- int -SurfTriMesh::GetNextVertex( int nId, Point3d& ptP) const +SurfTriMesh::GetNextVertex( int nId, Point3d& ptP) const { // cerco il primo successivo valido do { @@ -392,12 +392,12 @@ SurfTriMesh::GetNextVertex( int nId, Point3d& ptP) const // recupero i dati ptP = m_vVert[nId].ptP ; // ritorno indice triangolo corrente - return nId ; + return nId ; } //---------------------------------------------------------------------------- bool -SurfTriMesh::GetTriangle( int nId, int nIdVert[3]) const +SurfTriMesh::GetTriangle( int nId, int nIdVert[3]) const { // verifico esistenza del triangolo if ( nId < 0 || nId >= GetTriangleSize() || m_vTria[nId].nIdVert[0] == SVT_DEL) @@ -406,19 +406,19 @@ SurfTriMesh::GetTriangle( int nId, int nIdVert[3]) const nIdVert[0] = m_vTria[nId].nIdVert[0] ; nIdVert[1] = m_vTria[nId].nIdVert[1] ; nIdVert[2] = m_vTria[nId].nIdVert[2] ; - return true ; + return true ; } //---------------------------------------------------------------------------- int -SurfTriMesh::GetFirstTriangle( int nIdVert[3]) const +SurfTriMesh::GetFirstTriangle( int nIdVert[3]) const { - return GetNextTriangle( SVT_NULL, nIdVert) ; + return GetNextTriangle( SVT_NULL, nIdVert) ; } //---------------------------------------------------------------------------- int -SurfTriMesh::GetNextTriangle( int nId, int nIdVert[3]) const +SurfTriMesh::GetNextTriangle( int nId, int nIdVert[3]) const { // cerco il primo successivo valido do { @@ -432,12 +432,12 @@ SurfTriMesh::GetNextTriangle( int nId, int nIdVert[3]) const nIdVert[1] = m_vTria[nId].nIdVert[1] ; nIdVert[2] = m_vTria[nId].nIdVert[2] ; // ritorno indice triangolo corrente - return nId ; + return nId ; } //---------------------------------------------------------------------------- bool -SurfTriMesh::GetTriangle( int nId, Triangle3d& Tria) const +SurfTriMesh::GetTriangle( int nId, Triangle3d& Tria) const { // verifico esistenza del triangolo if ( nId < 0 || nId >= GetTriangleSize() || m_vTria[nId].nIdVert[0] == SVT_DEL) @@ -447,19 +447,19 @@ SurfTriMesh::GetTriangle( int nId, Triangle3d& Tria) const m_vVert[m_vTria[nId].nIdVert[1]].ptP, m_vVert[m_vTria[nId].nIdVert[2]].ptP, m_vTria[nId].vtN) ; - return true ; + return true ; } //---------------------------------------------------------------------------- int -SurfTriMesh::GetFirstTriangle( Triangle3d& Tria) const +SurfTriMesh::GetFirstTriangle( Triangle3d& Tria) const { - return GetNextTriangle( SVT_NULL, Tria) ; + return GetNextTriangle( SVT_NULL, Tria) ; } //---------------------------------------------------------------------------- int -SurfTriMesh::GetNextTriangle( int nId, Triangle3d& Tria) const +SurfTriMesh::GetNextTriangle( int nId, Triangle3d& Tria) const { // cerco il primo successivo valido do { @@ -474,7 +474,7 @@ SurfTriMesh::GetNextTriangle( int nId, Triangle3d& Tria) const m_vVert[m_vTria[nId].nIdVert[2]].ptP, m_vTria[nId].vtN) ; // ritorno indice triangolo corrente - return nId ; + return nId ; } //---------------------------------------------------------------------------- @@ -500,17 +500,20 @@ SurfTriMesh::GetAllTriaAroundVertex( int nV, INTVECTOR& vT, bool& bCirc) const int k ; int nTa = nT ; do { + // ricerco triangolo if ( FindVertexInTria( nV, nTa, k)) nTa = m_vTria[nTa].nIdAdjac[Prev(k)] ; else nTa = SVT_NULL ; - // per evitare cicli infiniti dovuti a triangoli invertiti - if ( vT.size() >= 2 && nTa == vT[vT.size()-2]) + // se non valido, esco + if ( nTa == nT || nTa == SVT_NULL) break ; - // se valido - if ( nTa != nT && nTa != SVT_NULL) - vT.push_back( nTa) ; - } while ( nTa != nT && nTa != SVT_NULL && vT.size() < MAX_VT_SIZE) ; + // per evitare cicli infiniti dovuti a triangoli invertiti + if ( find( vT.begin(), vT.end(), nTa) != vT.end()) + break ; + // inserisco in elenco + vT.push_back( nTa) ; + } while ( vT.size() < MAX_VT_SIZE) ; // se sono ritornato al triangolo di partenza ho fatto un giro e concluso la ricerca if ( nTa == nT) { @@ -521,17 +524,20 @@ SurfTriMesh::GetAllTriaAroundVertex( int nV, INTVECTOR& vT, bool& bCirc) const // altrimenti, devo cercare i triangoli adiacenti con lo stesso vertice in CW nTa = nT ; do { + // ricerco triangolo if ( FindVertexInTria( nV, nTa, k)) nTa = m_vTria[nTa].nIdAdjac[k] ; else nTa = SVT_NULL ; - // per evitare cicli infiniti dovuti a triangoli invertiti - if ( vT.size() >= 2 && nTa == vT[vT.size()-2]) + // se non valido, esco + if ( nTa == nT || nTa == SVT_NULL) break ; - // se valido - if ( nTa != nT && nTa != SVT_NULL) - vT.insert( vT.begin(), nTa) ; - } while ( nTa != nT && nTa != SVT_NULL && vT.size() < MAX_VT_SIZE) ; + // per evitare cicli infiniti dovuti a triangoli invertiti + if ( find( vT.begin(), vT.end(), nTa) != vT.end()) + break ; + // inserisco in elenco + vT.insert( vT.begin(), nTa) ; + } while ( vT.size() < MAX_VT_SIZE) ; bCirc = ( nTa == nT) ; return int( vT.size()) ; @@ -873,7 +879,7 @@ SurfTriMesh* SurfTriMesh::Clone( void) const { // alloco oggetto - SurfTriMesh* pStm = new(nothrow) SurfTriMesh ; + SurfTriMesh* pStm = new( nothrow) SurfTriMesh ; if ( pStm != nullptr) { if ( ! pStm->CopyFrom( *this)) { delete pStm ; diff --git a/UserObjDefault.cpp b/UserObjDefault.cpp index 039f9b0..1491bcf 100644 --- a/UserObjDefault.cpp +++ b/UserObjDefault.cpp @@ -36,7 +36,7 @@ UserObjDefault* UserObjDefault::Clone( void) const { // alloco oggetto - UserObjDefault* pOUD = new(nothrow) UserObjDefault ; + UserObjDefault* pOUD = new( nothrow) UserObjDefault ; // eseguo copia dei dati if ( pOUD != nullptr) { try { pOUD->m_sName = m_sName ; diff --git a/VolZmap.cpp b/VolZmap.cpp index b1daaaf..b3c152a 100644 --- a/VolZmap.cpp +++ b/VolZmap.cpp @@ -82,7 +82,7 @@ VolZmap* VolZmap::Clone( void) const { // alloco oggetto - VolZmap* pVzm = new(nothrow) VolZmap ; + VolZmap* pVzm = new( nothrow) VolZmap ; if ( pVzm != nullptr) { if ( ! pVzm->CopyFrom( *this)) { delete pVzm ;