diff --git a/CAvToolTriangle.cpp b/CAvToolTriangle.cpp index 7bb6afb..c669426 100644 --- a/CAvToolTriangle.cpp +++ b/CAvToolTriangle.cpp @@ -762,7 +762,7 @@ CylTriaInteriorEscapeDistOrtMotion( const Point3d& ptCylOrig, const Vector3d& vt double dU = ( ( trTria.GetP( 0) - ptTouch0) * trTria.GetN()) / ( vtMove * trTria.GetN()) ; // Se avvicinamento, distanza nulla if ( dU < dDist) - dDist ; + dDist = 0. ; ptTouch0 += ( dU * vtMove) ; Point3d ptTouch1 = ptTouch0 - dCylHei * vtCylAx ; Point3d ptInt0, ptInt1 ; diff --git a/CDeBoxClosedSurfTm.cpp b/CDeBoxClosedSurfTm.cpp index a562058..e851ea6 100644 --- a/CDeBoxClosedSurfTm.cpp +++ b/CDeBoxClosedSurfTm.cpp @@ -46,8 +46,8 @@ CDeBoxClosedSurfTm( const Frame3d& frBox, const Vector3d& vtDiag, double dSafeDi if ( ! Stm.IsClosed()) return false ; // Verifico se il box è dentro la superficie tramite calcolo distanza minima. - Point3d ptBoxOrig ; - b3Box.GetMinMax( ptBoxOrig, Point3d()) ; + Point3d ptBoxOrig, ptBoxMax ; + b3Box.GetMinMax( ptBoxOrig, ptBoxMax) ; DistPointSurfTm DistBoxOrigSurfCalc( ptBoxOrig, Stm) ; // Se il box è interno c'è collisione return DistBoxOrigSurfCalc.IsPointInside() ; diff --git a/CDeConeFrustumTria.cpp b/CDeConeFrustumTria.cpp index 25fabb8..7576b0b 100644 --- a/CDeConeFrustumTria.cpp +++ b/CDeConeFrustumTria.cpp @@ -94,7 +94,8 @@ CDeSimpleConeFrustumTria( const Frame3d& frCone, double dMinRad, double dMaxRad, else if ( nMinBaseTriaIndex == IPPT_YES) { double dU1, dU2 ; if ( LineDisc( ptLine, vtLine, ORIG, -Z_AX, dMinRad, dU1, dU2) == D_INFINITE_INT_LINE_ON_PLANE) { - int nLineTriaIndex = IntersLineTria( ptLine + dU1 * vtLine, ptLine + dU2 * vtLine, trMyTria, Point3d(), Point3d()) ; + Point3d ptInt, ptInt2 ; + int nLineTriaIndex = IntersLineTria( ptLine + dU1 * vtLine, ptLine + dU2 * vtLine, trMyTria, ptInt, ptInt2) ; if ( nLineTriaIndex != ILTT_NO && nLineTriaIndex != ILTT_IN) return true ; } @@ -111,7 +112,8 @@ CDeSimpleConeFrustumTria( const Frame3d& frCone, double dMinRad, double dMaxRad, else if ( nMaxBaseTriaIndex == IPPT_YES) { double dU1, dU2 ; if ( LineDisc( ptLine, vtLine, Point3d( 0., 0., dHeight), Z_AX, dMaxRad, dU1, dU2) == D_INFINITE_INT_LINE_ON_PLANE) { - int nLineTriaIndex = IntersLineTria( ptLine + dU1 * vtLine, ptLine + dU2 * vtLine, trMyTria, Point3d(), Point3d()) ; + Point3d ptInt, ptInt2 ; + int nLineTriaIndex = IntersLineTria( ptLine + dU1 * vtLine, ptLine + dU2 * vtLine, trMyTria, ptInt, ptInt2) ; if ( nLineTriaIndex != ILTT_NO && nLineTriaIndex != ILTT_IN) return true ; } @@ -122,7 +124,8 @@ CDeSimpleConeFrustumTria( const Frame3d& frCone, double dMinRad, double dMaxRad, return false ; Point3d ptContactSt( dMinRad * vtTriaNormXY.x, dMinRad * vtTriaNormXY.y, 0.) ; Point3d ptContactEn( dMaxRad * vtTriaNormXY.x, dMaxRad * vtTriaNormXY.y, dHeight) ; - int nContactIndex = IntersLineTria( ptContactSt, ptContactEn, trMyTria, Point3d(), Point3d()) ; + Point3d ptInt, ptInt2 ; + int nContactIndex = IntersLineTria( ptContactSt, ptContactEn, trMyTria, ptInt, ptInt2) ; return ! ( nContactIndex == ILTT_NO || nContactIndex == ILTT_IN) ; } diff --git a/CDeConeTria.cpp b/CDeConeTria.cpp index a7812c9..d4fa5be 100644 --- a/CDeConeTria.cpp +++ b/CDeConeTria.cpp @@ -92,7 +92,8 @@ CDeSimpleConeTria( const Frame3d& frCone, double dRad, double dHeight, const Tri else if ( nBaseTriaIndex == IPPT_YES) { double dU1, dU2; if ( LineDisc( ptLine, vtLine, Point3d( 0., 0., dHeight), Z_AX, dRad, dU1, dU2) == D_INFINITE_INT_LINE_ON_PLANE) { - int nLineTriaIndex = IntersLineTria( ptLine + dU1 * vtLine, ptLine + dU2 * vtLine, trMyTria, Point3d(), Point3d()) ; + Point3d ptInt, ptInt2 ; + int nLineTriaIndex = IntersLineTria( ptLine + dU1 * vtLine, ptLine + dU2 * vtLine, trMyTria, ptInt, ptInt2) ; if ( nLineTriaIndex != ILTT_NO && nLineTriaIndex != ILTT_IN) return true ; } @@ -103,7 +104,8 @@ CDeSimpleConeTria( const Frame3d& frCone, double dRad, double dHeight, const Tri return false ; Point3d ptContactSt( 0., 0., 0.) ; Point3d ptContactEn( dRad * vtTriaNormXY.x, dRad * vtTriaNormXY.y, dHeight) ; - int nContactIndex = IntersLineTria( ptContactSt, ptContactEn, trMyTria, Point3d(), Point3d()) ; + Point3d ptInt, ptInt2 ; + int nContactIndex = IntersLineTria( ptContactSt, ptContactEn, trMyTria, ptInt, ptInt2) ; return ! ( nContactIndex == ILTT_NO || nContactIndex == ILTT_IN) ; } diff --git a/CDeRectPrismoidTria.cpp b/CDeRectPrismoidTria.cpp index 9dff093..9eefc88 100644 --- a/CDeRectPrismoidTria.cpp +++ b/CDeRectPrismoidTria.cpp @@ -50,6 +50,8 @@ CDeSimpleRectPrismoidTria( const Frame3d& frPrismoid, double dLenghtBaseX, doubl // Se c'è collisione con almeno un triangolo delle facce ho finito Triangle3d trFaceTria1, trFaceTria2 ; + Point3d ptInt, ptIn2 ; + TRIA3DVECTOR vTria ; // Faccia base trFaceTria1.Set( Point3d( - dHalfBaseX, - dHalfBaseY, 0.), Point3d( - dHalfBaseX, dHalfBaseY, 0.), @@ -59,8 +61,8 @@ CDeSimpleRectPrismoidTria( const Frame3d& frPrismoid, double dLenghtBaseX, doubl Point3d( dHalfBaseX, dHalfBaseY, 0.), Point3d( dHalfBaseX, - dHalfBaseY, 0.)) ; trFaceTria2.Validate() ; - if ( IntersTriaTria( trMyTria, trFaceTria1, Point3d(), Point3d(), TRIA3DVECTOR()) != ITTT_NO || - IntersTriaTria( trMyTria, trFaceTria2, Point3d(), Point3d(), TRIA3DVECTOR()) != ITTT_NO) + if ( IntersTriaTria( trMyTria, trFaceTria1, ptInt, ptIn2, vTria) != ITTT_NO || + IntersTriaTria( trMyTria, trFaceTria2, ptInt, ptIn2, vTria) != ITTT_NO) return true ; // Faccia top trFaceTria1.Set( Point3d( - dHalfTopX, - dHalfTopY, dHeight), @@ -71,8 +73,8 @@ CDeSimpleRectPrismoidTria( const Frame3d& frPrismoid, double dLenghtBaseX, doubl Point3d( dHalfTopX, - dHalfTopY, dHeight), Point3d( dHalfTopX, dHalfTopY, dHeight)) ; trFaceTria2.Validate() ; - if ( IntersTriaTria( trMyTria, trFaceTria1, Point3d(), Point3d(), TRIA3DVECTOR()) != ITTT_NO || - IntersTriaTria( trMyTria, trFaceTria2, Point3d(), Point3d(), TRIA3DVECTOR()) != ITTT_NO) + if ( IntersTriaTria( trMyTria, trFaceTria1, ptInt, ptIn2, vTria) != ITTT_NO || + IntersTriaTria( trMyTria, trFaceTria2, ptInt, ptIn2, vTria) != ITTT_NO) return true ; // Faccia laterale 1 trFaceTria1.Set( Point3d( - dHalfBaseX, - dHalfBaseY, 0.), @@ -83,8 +85,8 @@ CDeSimpleRectPrismoidTria( const Frame3d& frPrismoid, double dLenghtBaseX, doubl Point3d( dHalfBaseX, - dHalfBaseY, 0.), Point3d( dHalfTopX, - dHalfTopY , dHeight)) ; trFaceTria2.Validate() ; - if ( IntersTriaTria( trMyTria, trFaceTria1, Point3d(), Point3d(), TRIA3DVECTOR()) != ITTT_NO || - IntersTriaTria( trMyTria, trFaceTria2, Point3d(), Point3d(), TRIA3DVECTOR()) != ITTT_NO) + if ( IntersTriaTria( trMyTria, trFaceTria1, ptInt, ptIn2, vTria) != ITTT_NO || + IntersTriaTria( trMyTria, trFaceTria2, ptInt, ptIn2, vTria) != ITTT_NO) return true ; // Faccia laterale 2 trFaceTria1.Set( Point3d( dHalfBaseX, - dHalfBaseY, 0.), @@ -95,8 +97,8 @@ CDeSimpleRectPrismoidTria( const Frame3d& frPrismoid, double dLenghtBaseX, doubl Point3d( dHalfBaseX, dHalfBaseY, 0.), Point3d( dHalfTopX , dHalfTopY , dHeight)) ; trFaceTria2.Validate() ; - if ( IntersTriaTria(trMyTria, trFaceTria1, Point3d(), Point3d(), TRIA3DVECTOR()) != ITTT_NO || - IntersTriaTria(trMyTria, trFaceTria2, Point3d(), Point3d(), TRIA3DVECTOR()) != ITTT_NO) + if ( IntersTriaTria(trMyTria, trFaceTria1, ptInt, ptIn2, vTria) != ITTT_NO || + IntersTriaTria(trMyTria, trFaceTria2, ptInt, ptIn2, vTria) != ITTT_NO) return true ; // Faccia laterale 3 trFaceTria1.Set( Point3d( dHalfBaseX, dHalfBaseY, 0.), @@ -107,8 +109,8 @@ CDeSimpleRectPrismoidTria( const Frame3d& frPrismoid, double dLenghtBaseX, doubl Point3d( - dHalfBaseX, dHalfBaseY, 0.), Point3d( - dHalfTopX , dHalfTopY , dHeight)) ; trFaceTria2.Validate() ; - if ( IntersTriaTria( trMyTria, trFaceTria1, Point3d(), Point3d(), TRIA3DVECTOR()) != ITTT_NO || - IntersTriaTria( trMyTria, trFaceTria2, Point3d(), Point3d(), TRIA3DVECTOR()) != ITTT_NO) + if ( IntersTriaTria( trMyTria, trFaceTria1, ptInt, ptIn2, vTria) != ITTT_NO || + IntersTriaTria( trMyTria, trFaceTria2, ptInt, ptIn2, vTria) != ITTT_NO) return true ; // Faccia laterale 4 trFaceTria1.Set( Point3d( - dHalfBaseX, dHalfBaseY, 0.), @@ -119,8 +121,8 @@ CDeSimpleRectPrismoidTria( const Frame3d& frPrismoid, double dLenghtBaseX, doubl Point3d( - dHalfBaseX, - dHalfBaseY, 0.), Point3d( - dHalfTopX , - dHalfTopY , dHeight)) ; trFaceTria2.Validate() ; - if ( IntersTriaTria( trMyTria, trFaceTria1, Point3d(), Point3d(), TRIA3DVECTOR()) != ITTT_NO || - IntersTriaTria( trMyTria, trFaceTria2, Point3d(), Point3d(), TRIA3DVECTOR()) != ITTT_NO) + if ( IntersTriaTria( trMyTria, trFaceTria1, ptInt, ptIn2, vTria) != ITTT_NO || + IntersTriaTria( trMyTria, trFaceTria2, ptInt, ptIn2, vTria) != ITTT_NO) return true ; return false ; } diff --git a/CDeUtility.cpp b/CDeUtility.cpp index 6aed35d..13b44e4 100644 --- a/CDeUtility.cpp +++ b/CDeUtility.cpp @@ -141,8 +141,8 @@ CoplanarCircleTriangleInterference( const Point3d& ptCen, double dRad, const Tri return false ; // Classifico i vertici del triangolo in base alla loro posizione rispetto alla circonferenza. double dSqRad = dRad * dRad ; - double dSqRadInf = dRad * dRad - 2 * dRad * EPS_SMALL ; - double dSqRadSup = dRad * dRad + 2 * dRad * EPS_SMALL ; + double dSqRadInf = dSqRad - 2 * dRad * EPS_SMALL ; + double dSqRadSup = dSqRad + 2 * dRad * EPS_SMALL ; int nInOutVec[3] ; for ( int n = 0 ; n < 3 ; ++ n) { Point3d ptTriaVert = trTria.GetP( n) ; diff --git a/CurveArc.h b/CurveArc.h index 46d0858..768f5c9 100644 --- a/CurveArc.h +++ b/CurveArc.h @@ -153,7 +153,7 @@ class CurveArc : public ICurveArc, public IGeoObjRW { return m_PtCen ; } const Vector3d& GetNormVersor( void) const override { return m_VtN ; } - const Vector3d& GetStartVersor( void) const + const Vector3d& GetStartVersor( void) const override { return m_VtS ; } double GetRadius( void) const override { return m_dRad ; } diff --git a/CurveAux.cpp b/CurveAux.cpp index 88edcc9..57d456c 100644 --- a/CurveAux.cpp +++ b/CurveAux.cpp @@ -439,7 +439,7 @@ ArcToBezierCurve( const ICurve* pCrv) return nullptr ; // aggiungo la curva di Bezier a quella composita if ( ! pCrvCompo->AddCurve( Release( pCrvBez))) - return false ; + return nullptr ; } // copio estrusione e spessore CopyExtrusion( pArc, pCrvCompo) ; diff --git a/CurveByApprox.cpp b/CurveByApprox.cpp index 3b595a6..afb1d2e 100644 --- a/CurveByApprox.cpp +++ b/CurveByApprox.cpp @@ -60,7 +60,7 @@ CurveByApprox::GetCurve( int nType, double dLinTol, double dAngTolDeg, double dL // calcolo approssimazione PolyArc PA ; if ( ! GetArcs( dLinTol, dAngTolDeg, dLinFea, PA)) - return false ; + return nullptr ; // creo la composita formata da questa approssimazione PtrOwner pCC( CreateBasicCurveComposite()) ; if ( ! pCC->FromPolyArc( PA)) diff --git a/CurveByInterp.cpp b/CurveByInterp.cpp index f6b0acf..f3e9c05 100644 --- a/CurveByInterp.cpp +++ b/CurveByInterp.cpp @@ -91,7 +91,7 @@ CurveByInterp::GetCurve( int nMethod, int nType) // creo una curva di Bezier cubica per ogni intervallo PtrOwner pCBez( CreateCurveBezier()) ; if ( IsNull( pCBez)) - return false ; + return nullptr ; pCBez->Init( 3, false) ; pCBez->SetControlPoint( 0, m_vPnt[i-1]) ; pCBez->SetControlPoint( 1, m_vPnt[i-1] + ( m_vPar[i] - m_vPar[i-1]) / 3 * m_vNextDer[i-1]) ; @@ -103,7 +103,7 @@ CurveByInterp::GetCurve( int nMethod, int nType) return ::Release( pCrvCompo) ; } - return false ; + return nullptr ; } //---------------------------------------------------------------------------- diff --git a/CurveLine.h b/CurveLine.h index 6f5431c..dfb395c 100644 --- a/CurveLine.h +++ b/CurveLine.h @@ -112,7 +112,7 @@ class CurveLine : public ICurveLine, public IGeoObjRW bool SimpleOffset( double dDist, int nType = OFF_FILLET) override ; bool ModifyStart( const Point3d& ptNewStart) override ; bool ModifyEnd( const Point3d& ptNewEnd) override ; - bool SetExtrusion( const Vector3d& vtExtr) + bool SetExtrusion( const Vector3d& vtExtr) override { m_VtExtr = vtExtr ; m_VtExtr.Normalize() ; m_OGrMgr.Reset() ; return true ; } bool SetThickness( double dThick) override { m_dThick = dThick ; m_OGrMgr.Reset() ; return true ; } diff --git a/EgtGeomKernel.rc b/EgtGeomKernel.rc index 0aefca9..6c33734 100644 Binary files a/EgtGeomKernel.rc and b/EgtGeomKernel.rc differ diff --git a/EgtGeomKernel.vcxproj b/EgtGeomKernel.vcxproj index fc4f6b9..d8284cb 100644 --- a/EgtGeomKernel.vcxproj +++ b/EgtGeomKernel.vcxproj @@ -37,7 +37,7 @@ true Unicode false - v142 + ClangCL false @@ -54,7 +54,7 @@ true Unicode false - v142 + ClangCL @@ -148,6 +148,7 @@ copy $(TargetPath) \EgtProg\DllD32 false true ProgramDatabase + stdcpp17 Windows @@ -239,6 +240,7 @@ copy $(TargetPath) \EgtProg\Dll32 true false None + stdcpp17 Windows @@ -395,8 +397,6 @@ copy $(TargetPath) \EgtProg\Dll64 - - @@ -560,7 +560,6 @@ copy $(TargetPath) \EgtProg\Dll64 - @@ -608,10 +607,6 @@ copy $(TargetPath) \EgtProg\Dll64 - - - - diff --git a/EgtGeomKernel.vcxproj.filters b/EgtGeomKernel.vcxproj.filters index bbe214e..c1175ce 100644 --- a/EgtGeomKernel.vcxproj.filters +++ b/EgtGeomKernel.vcxproj.filters @@ -46,12 +46,6 @@ {865b76ee-b10d-41fc-861c-b48ce52fa277} - - {ea332990-ab31-4d28-b107-7f41c7fd22e7} - - - {98651eef-5029-47a8-a19d-ea967c50bf2e} - @@ -459,12 +453,6 @@ File di origine\GeoCollision - - File di origine\TrianglePP - - - File di origine\TrianglePP - @@ -1088,21 +1076,6 @@ File di intestazione - - File di intestazione\TrianglePP - - - File di intestazione\TrianglePP - - - File di intestazione\TrianglePP - - - File di intestazione\TrianglePP - - - File di intestazione\TrianglePP - diff --git a/FontNfe.cpp b/FontNfe.cpp index 3ef55f5..a230b43 100644 --- a/FontNfe.cpp +++ b/FontNfe.cpp @@ -492,7 +492,6 @@ NfeFont::GetTextLines( const string& sText, int nInsPos, PNTVECTOR& vPt, STRVECT // calcolo i fattori di scala double dScaY = m_dHeight / m_dHCap ; double dScaX = dScaY * m_dRatio ; - double dScaZ = 1 ; // recupero altezza maiuscole e interlinea double dHCap = m_dHeight ; diff --git a/FontOs.cpp b/FontOs.cpp index 880cb8a..56cf0d5 100644 --- a/FontOs.cpp +++ b/FontOs.cpp @@ -604,7 +604,6 @@ OsFont::GetTextLines( const string& sText, int nInsPos, PNTVECTOR& vPt, STRVECTO // calcolo i fattori di scala double dScaY = m_dHeight / m_dHCap ; double dScaX = dScaY * m_dRatio ; - double dScaZ = 1 ; // recupero altezza maiuscole e interlinea double dHCap = m_dHeight ; diff --git a/GdbExecutor.cpp b/GdbExecutor.cpp index 9a52c96..a8469ac 100644 --- a/GdbExecutor.cpp +++ b/GdbExecutor.cpp @@ -5529,7 +5529,6 @@ GdbExecutor::ExecuteToolAvoidTriangle( const std::string& sCmd2, const STRVECTOR int nToolType = GetIdParam( vsParams[5], false) ; // Vettore di fuga IGeoVector3d * pGLeakV = GetGeoVector3d( m_pGDB->GetGeoObj( nIdLeakV)) ; - Point3d ptLeakBase = pGLeakV->GetBase() ; Vector3d vtLeakDir = pGLeakV->GetVector() ; // Vettore utensile IGeoVector3d * pGToolV = GetGeoVector3d( m_pGDB->GetGeoObj( nIdToolV)) ; diff --git a/GdbIterator.cpp b/GdbIterator.cpp index 07b7e9d..d35ad15 100644 --- a/GdbIterator.cpp +++ b/GdbIterator.cpp @@ -668,7 +668,7 @@ IGeoObj* GdbIterator::GetGeoObj( void) { if ( m_pGDB == nullptr || m_pCurrObj == nullptr) - return false ; + return nullptr ; // recupero l'oggetto Gdb GdbGeo* pGdbGeo = GetGdbGeo( m_pCurrObj) ; @@ -684,7 +684,7 @@ const IGeoObj* GdbIterator::GetGeoObj( void) const { if ( m_pGDB == nullptr || m_pCurrObj == nullptr) - return false ; + return nullptr ; // recupero l'oggetto Gdb const GdbGeo* pGdbGeo = GetGdbGeo( m_pCurrObj) ; @@ -1715,7 +1715,7 @@ bool GdbIterator::RemoveUserObj( void) { if ( m_pGDB == nullptr || m_pCurrObj == nullptr) - return nullptr ; + return false ; // cancello eventuale precedente UserObj if ( m_pCurrObj->m_pUserObj != nullptr) diff --git a/GdbIterator.h b/GdbIterator.h index c537b8b..d2e6efe 100644 --- a/GdbIterator.h +++ b/GdbIterator.h @@ -140,8 +140,8 @@ class GdbIterator : public IGdbIterator bool GetInfo( const std::string& sKey, INTVECTOR& vnInfo) const override ; bool GetInfo( const std::string& sKey, DBLVECTOR& vdInfo) const override ; bool GetInfo( const std::string& sKey, STRVECTOR& vsInfo) const override ; - bool ExistsInfo( const std::string& sKey) const ; - bool RemoveInfo( const std::string& sKey) ; + bool ExistsInfo( const std::string& sKey) const override ; + bool RemoveInfo( const std::string& sKey) override ; // TextureData bool SetTextureName( const std::string& sTxrName) override ; bool SetTextureFrame( const Frame3d& frTxrRef) override ; diff --git a/GeoFrame3d.h b/GeoFrame3d.h index 10eb25c..575e53a 100644 --- a/GeoFrame3d.h +++ b/GeoFrame3d.h @@ -69,7 +69,7 @@ class GeoFrame3d : public IGeoFrame3d, public IGeoObjRW bool Set( const Point3d& ptOrig, const Point3d& ptOnX, const Point3d& ptNearY) override ; bool Set( const Point3d& ptOrig, const Vector3d& vtDirZ) override ; bool Set( const Frame3d& frF) override ; - const Frame3d& GetFrame( void) const + const Frame3d& GetFrame( void) const override { return m_frF ; } bool GetDrawWithArrowHeads( double dLenA, double dFrazLenAH, PolyLine& plX, PolyLine& plY, PolyLine& plZ) const override ; diff --git a/IntersLineSurfStd.cpp b/IntersLineSurfStd.cpp index 3cfb691..24c8d16 100644 --- a/IntersLineSurfStd.cpp +++ b/IntersLineSurfStd.cpp @@ -299,7 +299,7 @@ SegmentSphere( const Point3d& ptPLine, const Vector3d& vtVLine, double dLen, nIntType = S_NO_INTERS ; } // La retta associata al segmento è secante - else if ( nIntType = S_TWO_INT) { + else if ( nIntType == S_TWO_INT) { // Segmento esterno if ( dU1 > dLen + EPS_SMALL) nIntType = S_NO_INTERS ; @@ -558,12 +558,9 @@ IntersLineInfiniteCylinder( const Point3d& ptPLine, const Vector3d& vtVLine, DBLVECTOR vdRoots ; int nRoot = PolynomialRoots( 2, vdCoef, vdRoots) ; // Studio delle soluzioni - int nIntType ; - // Non ci sono intersezioni - if ( nRoot == 0) - nIntType = CC_NO_INTERS ; + int nIntType = CC_NO_INTERS ; // C'è un punto di tangenza - else if ( nRoot == 1) { + if ( nRoot == 1) { dU1 = vdRoots[0] ; nIntType = CC_ONE_INT_TAN ; } @@ -1085,10 +1082,8 @@ LineInfiniteCone( const Point3d& ptPLine, const Vector3d& vtDLine, int nRoot = PolynomialRoots( 2, vdCoef, vdRoots) ; // Studio le soluzioni - int nIntType ; - if ( nRoot == 0) - nIntType = CC_NO_INTERS ; - else if ( nRoot == 1) { + int nIntType = CC_NO_INTERS ; + if ( nRoot == 1) { dU1 = vdRoots[0] ; Point3d ptInt = ptPLine + dU1 * vtDLine ; // Soluzione sul cono negativo @@ -1748,9 +1743,6 @@ LineTorus( const Point3d& ptLine, const Vector3d& vtLine, } else if ( vdPar.size() == 3) { nIntType = T_THREE_ONE_TAN_TWO_SEC ; - Point3d ptInt1 = ptLn + vdPar[0] * vtLn ; - Point3d ptInt2 = ptLn + vdPar[1] * vtLn ; - Point3d ptInt3 = ptLn + vdPar[2] * vtLn ; } else if ( vdPar.size() == 4) { // Prime due soluzioni distinte diff --git a/NgeReader.cpp b/NgeReader.cpp index 365eeda..b76c4d3 100644 --- a/NgeReader.cpp +++ b/NgeReader.cpp @@ -194,7 +194,7 @@ NgeReader::ReadInt( unsigned int& nVal, const char* szSep, bool bEndL) int nTemp ; if ( ! ReadInt( nTemp, szSep, bEndL)) return false ; - nVal = unsigned int( nTemp) ; + nVal = ( unsigned int) ( nTemp) ; return true ; } @@ -320,12 +320,12 @@ NgeReader::ReadString( string& sVal, const char* szSep, bool bEndL) return false ; m_InFile.read( szBuff, nDim) ; if ( ! m_InFile.good()) { - delete szBuff ; + delete[] szBuff ; return false ; } szBuff[nDim] = '\0' ; sVal = szBuff ; - delete szBuff ; + delete[] szBuff ; return true ; } else { diff --git a/OffsetCurve.cpp b/OffsetCurve.cpp index e67f5ac..5030197 100644 --- a/OffsetCurve.cpp +++ b/OffsetCurve.cpp @@ -199,7 +199,7 @@ OffsetCurve::Make( const ICurve* pCrv, double dDist, int nType) } // verifico relazione con la curva precedente e aggiungo eventuali curve intermedie CurveComposite ccTemp ; - bool bOk = VerifyAndAdjustExternalAngle( pCrv1, pCrv2, vAngs[nInd1], dDist, ICurve::OFF_FILLET, ccTemp) ; + VerifyAndAdjustExternalAngle( pCrv1, pCrv2, vAngs[nInd1], dDist, ICurve::OFF_FILLET, ccTemp) ; // metto in lista curva precedente m_CrvLst.push_back( Release( pCrv1)) ; // se aggiunto qualcosa, lo metto in lista @@ -228,7 +228,7 @@ OffsetCurve::Make( const ICurve* pCrv, double dDist, int nType) ICurve* pCrv2 = m_CrvLst.front() ; // verifico relazione con la curva precedente e aggiungo eventuali curve intermedie CurveComposite ccTemp ; - bool bOk = VerifyAndAdjustExternalAngle( pCrv1, pCrv2, vAngs[nInd1], dDist, ICurve::OFF_FILLET, ccTemp) ; + VerifyAndAdjustExternalAngle( pCrv1, pCrv2, vAngs[nInd1], dDist, ICurve::OFF_FILLET, ccTemp) ; // se aggiunto qualcosa, lo metto in lista if ( ccTemp.GetCurveCount() > 0) { PtrOwner pCrv3( ccTemp.RemoveFirstOrLastCurve( false)) ; @@ -575,7 +575,7 @@ OffsetCurve::Make( const ICurve* pCrv, double dDist, int nType) // se fillet lo trasformo in smusso o estensione if ( IsFillet( pCrv, dDist)) { CurveComposite ccTemp ; - bool bOk = ModifyFillet( pCrv, dDist, nType, ccTemp) ; + ModifyFillet( pCrv, dDist, nType, ccTemp) ; // metto in lista le curve risultanti if ( ccTemp.GetCurveCount() > 0) { PtrOwner pCrv2( ccTemp.RemoveFirstOrLastCurve( false)) ; diff --git a/PolyLine.cpp b/PolyLine.cpp index 212080b..c941d65 100644 --- a/PolyLine.cpp +++ b/PolyLine.cpp @@ -22,8 +22,6 @@ #include "/EgtDev/Include/EGkPolyLine.h" #include "/EgtDev/Include/EGkPlane3d.h" #include "/EgtDev/Include/EGnStringUtils.h" -#include "/EgtDev/Include/EgtNumUtils.h" -#include "/EgtDev/Include/EGkPolygon3d.h" using namespace std ; @@ -1623,4 +1621,4 @@ PolyLine::AddPolyLineToPolyLine( PolyLine& PolyToAdd, double dTol) AddUPoint( 0., it->first) ; } return true ; -} \ No newline at end of file +} diff --git a/StmFromCurves.cpp b/StmFromCurves.cpp index bd122a3..c676f4a 100644 --- a/StmFromCurves.cpp +++ b/StmFromCurves.cpp @@ -354,7 +354,7 @@ GetSurfTriMeshSwept( const ICurve* pSect, const ICurve* pGuide, bool bCapEnds, d // calcolo la superficie PtrOwner pSTM( CreateSurfTriMesh()) ; if ( IsNull( pSTM)) - return false ; + return nullptr ; // salvo tolleranza lineare usata pSTM->SetLinearTolerance( dLinTol) ; // superficie swept @@ -478,7 +478,7 @@ CalcRegionPolyLines( const CICURVEPVECTOR& vpCurve, double dLinTol, vPLtmp.resize( vpCurve.size()) ; for ( int i = 0 ; i < int( vpCurve.size()) ; ++ i) { if ( ! vpCurve[i]->ApproxWithLines( dLinTol, ANG_TOL_STD_DEG, ICurve::APL_SPECIAL, vPLtmp[i])) - return nullptr ; + return false ; } // ne calcolo l'area e genero un ordine in senso decrescente typedef pair INDAREA ; // coppia indice, area @@ -525,4 +525,4 @@ CalcRegionPolyLines( const CICURVEPVECTOR& vpCurve, double dLinTol, // restituisco la normale positiva alla regione vtN = ( bCCW ? vtN0 : - vtN0) ; return true ; -} \ No newline at end of file +} diff --git a/SurfBezier.cpp b/SurfBezier.cpp index d772fc6..88ef863 100644 --- a/SurfBezier.cpp +++ b/SurfBezier.cpp @@ -1046,7 +1046,7 @@ SurfBezier::GetCurveOnU( double dV) const { // controlli if ( dV < - EPS_PARAM || dV > m_nSpanV + EPS_PARAM) - return false ; + return nullptr ; dV = Clamp( dV, 0., double( m_nSpanV)) ; // determino l'intervallo di span in V e riduco i parametri in essi @@ -1131,7 +1131,7 @@ SurfBezier::GetCurveOnV( double dU) const { // controlli if ( dU < - EPS_PARAM || dU > m_nSpanU + EPS_PARAM) - return false ; + return nullptr ; dU = Clamp( dU, 0., double( m_nSpanU)) ; // determino l'intervallo di span in U e riduco i parametri in essi @@ -1217,7 +1217,7 @@ SurfBezier::GetLoop( int nLoop) const // Se superficie completa, basta concatenare le 4 isoparametriche di bordo if ( ! m_bTrimmed) { // Esiste solo il loop esterno - if ( nLoop |= 0) + if ( nLoop != 0) return nullptr ; // Loop PtrOwner pLoop( CreateBasicCurveComposite()) ; diff --git a/SurfTriMeshBooleans.cpp b/SurfTriMeshBooleans.cpp index d452e6e..c4ec162 100644 --- a/SurfTriMeshBooleans.cpp +++ b/SurfTriMeshBooleans.cpp @@ -595,9 +595,6 @@ SurfTriMesh::GeneralizedCut( const ICurve& cvCurve, bool bSaveOnEq) Vector3d vtVecProva = cvOpenChain[nLastOpenLoopN][0].vtOuter ; vtVecProva.Normalize( EPS_ZERO) ; for ( int nLoop = 0 ; nLoop < int( cvBoundClosedLoopVec.size()) ; ++ nLoop) { - // Estremi del loop aperto - Point3d ptOpenLoopStP = cvOpenChain[nLastOpenLoopN][0].ptSt ; - Point3d ptOpenLoopEnP = cvOpenChain[nLastOpenLoopN][0].ptEn ; // Cerco se esistono dei tratti del loop chiuso corrente che sono // toccati dagli estremi del loop aperto corrente int nCvFirst = -1 ; @@ -798,9 +795,6 @@ SurfTriMesh::DecomposeLoop( CHAINVECTOR& cvOpenChain, INTVECTOR& vnDegVec, PNTMA Vector3d vtVecProva = cvOpenChain[nLastOpenLoopN][0].vtOuter ; vtVecProva.Normalize( EPS_ZERO) ; for ( int nLoop = 0 ; nLoop < int( cvBoundClosedLoopVec.size()) ; ++ nLoop) { - // Estremi del loop aperto - Point3d ptOpenLoopStP = cvOpenChain[nLastOpenLoopN][0].ptSt ; - Point3d ptOpenLoopEnP = cvOpenChain[nLastOpenLoopN][0].ptEn ; // Cerco se esistono dei tratti del loop chiuso corrente che sono // toccati dagli estremi del loop aperto corrente int nCvFirst = - 1 ; @@ -1964,7 +1958,6 @@ SurfTriMesh::IntersectTriMeshTriangle( SurfTriMesh& Other) m_vTria[nTA].nTempPart = nInOutNum ; } nVertNum = 0 ; - ptFirstV ; nCurVert = SurfB.GetFirstVertex( ptFirstV) ; nInOutNum = 0 ; while ( nInOutNum == 0 && nCurVert != SVT_NULL) { @@ -3061,6 +3054,247 @@ TrimLineWithExtPolygon( const CurveLine& cvLine, const POLYLINEVECTOR& vContourV return true ; } +//---------------------------------------------------------------------------- +static bool +ChangePolyLineStart( const Point3d& ptNewStart, PolyLine& Loop) +{ + // Rinomino la lista di punti della PolyLine. + PNTULIST& LoopList = Loop.GetUPointList() ; + // Ciclo sui segmenti del loop per cercare il tratto del loop chiuso pi� vicino al punto. + double dMinSqDist = DBL_MAX ; + auto itMinDist = LoopList.end() ; + auto itSt = LoopList.begin() ; + auto itEn = itSt ; + ++ itEn ; + for ( ; itSt != LoopList.end() && itEn != LoopList.end() ; ++ itSt, ++ itEn) { + // Estremi del segmento corrente del loop + Point3d ptSegSt = itSt->first ; + Point3d ptSegEn = itEn->first ; + // Distanza del punto dal segmento del loop + DistPointLine dDistCalc( ptNewStart, ptSegSt, ptSegEn) ; + double dSqDist ; + dDistCalc.GetSqDist( dSqDist) ; + if ( dSqDist < dMinSqDist) { + dMinSqDist = dSqDist ; + itMinDist = itSt ; + } + } + // Se il punto non sta sul loop, errore + if ( dMinSqDist > 100 * SQ_EPS_SMALL) + return false ; + // Se il punto non sta su un vertice del segmento, lo aggiungo. Altrimenti non devo fare nulla. + auto itNewPointSt = LoopList.begin() ; + auto itNext = itMinDist ; + ++ itNext ; + bool bOnStart = AreSamePointApprox( ptNewStart, itMinDist->first) ; + bool bOnEnd = AreSamePointApprox( ptNewStart, itNext->first) ; + itNewPointSt = LoopList.emplace( itNext, ptNewStart, 0) ; + // Sposto i punti precedenti in coda. + bool bStartRemoved = false ; + auto it = LoopList.begin() ; + while ( it != itNewPointSt) { + if ( bStartRemoved) { + LoopList.emplace_back( it->first, it->second) ; + } + bStartRemoved = true ; + it = LoopList.erase( it) ; + } + // Se il punto inserito non coincide con l'inizio del segmento chiudo il loop. + if ( ! bOnStart) { + LoopList.emplace_back( ptNewStart, 0) ; + // Se coincide con la fine tolgo il punto di fine che diviene inutile. + if ( bOnEnd) { + //LoopList.erase( itNext) ; + auto itNewStart = LoopList.begin() ; + ++ itNewStart ; + LoopList.erase( itNewStart) ; + } + } + + return true ; +} + +//---------------------------------------------------------------------------- +// nSegNum 0-based +static bool +PointPositionOnPolyLine( const Point3d& ptPoint, /*const*/ PolyLine& Loop, int& nSegNum, double& dParOnSeg) +{ + // Rinomino la lista di punti della PolyLine. + /*const*/ PNTULIST& LoopList = Loop.GetUPointList() ; + // Ciclo sui segmenti del loop per cercare il tratto del loop chiuso pi� vicino al punto. + nSegNum = - 1 ; + double dMinSqDist = DBL_MAX ; + int nS = 0 ; + auto itMinDistSt = LoopList.end() ; + auto itMinDistEn = itMinDistSt ; + auto itSt = LoopList.begin() ; + auto itEn = itSt ; + ++ itEn ; + for ( ; itSt != LoopList.end() && itEn != LoopList.end() ; ++ itSt, ++ itEn, ++ nS) { + // Estremi del segmento corrente del loop + Point3d ptSegSt = itSt->first ; + Point3d ptSegEn = itEn->first ; + // Distanza del punto dal segmento del loop + DistPointLine dDistCalc( ptPoint, ptSegSt, ptSegEn) ; + double dSqDist ; + dDistCalc.GetSqDist( dSqDist) ; + if ( dSqDist < dMinSqDist) { + nSegNum = nS ; + dMinSqDist = dSqDist ; + itMinDistSt = itSt ; + itMinDistEn = itEn ; + } + } + // Se il punto non sta sul loop, lo segnalo. + if ( dMinSqDist > 100 * SQ_EPS_SMALL) + return false ; + // Calcolo il parametro lungo il segmento. + Vector3d vtSeg = itMinDistEn->first - itMinDistSt->first ; + double dSegLen = vtSeg.Len() ; + if ( dSegLen < EPS_SMALL) + return false ; + vtSeg /= dSegLen ; + dParOnSeg = Clamp( ( ptPoint - itMinDistSt->first) * vtSeg, 0., dSegLen) ; + return true ; +} + +//---------------------------------------------------------------------------- +static bool +IsPointInsidePolyLine( const Point3d& ptP, /*const*/ PolyLine& plPoly) +{ + // Se la PolyLine non � chiusa, il punto non pu� essere interno. + if ( ! plPoly.IsClosed()) + return false ; + // Lista dei punti + /*const*/ PNTULIST& List = plPoly.GetUPointList() ; + // Ciclo sui segmenti della PolyLine per cercarne il tratto pi� vicino al punto. + double dMinSqDist = DBL_MAX ; + Point3d ptMinDist ; + auto itMinDistSt = List.end() ; + auto itSt = List.begin() ; + auto itEn = itSt ; + ++ itEn ; + for ( ; itSt != List.end() && itEn != List.end() ; ++ itSt, ++ itEn) { + // Estremi del segmento corrente del loop + Point3d ptSegSt = itSt->first ; + Point3d ptSegEn = itEn->first ; + // Distanza del punto dal segmento del loop + DistPointLine dDistCalc( ptP, ptSegSt, ptSegEn) ; + double dSqDist ; + dDistCalc.GetSqDist( dSqDist) ; + if ( dSqDist < dMinSqDist) { + dMinSqDist = dSqDist ; + dDistCalc.GetMinDistPoint( ptMinDist) ; + itMinDistSt = itSt ; + } + } + // Termine del segmento di minima distanza. + auto itMinDistEn = itMinDistSt ; + ++ itMinDistEn ; + // Punto di minima distanza nell'estremo iniziale del segento + if ( AreSamePointApprox( ptMinDist, itMinDistSt->first)) { + auto itPrevSt = List.begin() ; + if ( itMinDistSt == List.begin()) { + auto itAuxNext = itPrevSt ; + ++ ( ++ itAuxNext) ; + for ( ; itAuxNext != List.end() ; ++ itPrevSt, ++ itAuxNext) + ; + } + else { + auto itAuxNext = itPrevSt ; + ++ itAuxNext ; + for (; itAuxNext != itMinDistSt; ++itPrevSt, ++itAuxNext) + ; + } + Vector3d vtPrevTan = itMinDistSt->first - itPrevSt->first ; + vtPrevTan.Normalize() ; + Vector3d vtTan = itMinDistEn->first - itMinDistSt->first ; + vtTan.Normalize() ; + Polygon3d AuxPolygon ; + AuxPolygon.FromPolyLine( plPoly) ; + Vector3d vtPolyNorm = AuxPolygon.GetVersN() ; + Vector3d vtPrevOut = vtPrevTan ^ vtPolyNorm ; + Vector3d vtOut = vtTan ^ vtPolyNorm ; + // Caso concavo + if ( vtTan * vtPrevOut > 0) { + Vector3d vtTest = ptP - ptMinDist ; + if ( vtTest * vtPrevOut < 0 || vtTest * vtOut < 0) + return true ; + } + // Caso convesso + else { + Vector3d vtTest = ptP - ptMinDist ; + if ( vtTest * vtPrevOut < 0 && vtTest * vtOut < 0) + return true ; + } + } + // Punto di minima distanza nell'estremo finale del segento + else if ( AreSamePointApprox( ptMinDist, itMinDistEn->first)) { + auto itNextEn = itMinDistEn ; + ++ itNextEn ; + if ( itNextEn == List.end()) { + itNextEn = List.begin() ; + ++ itNextEn ; + } + Vector3d vtTan = itMinDistEn->first - itMinDistSt->first ; + vtTan.Normalize() ; + Vector3d vtNextTan = itNextEn->first - itMinDistEn->first ; + vtNextTan.Normalize() ; + Polygon3d AuxPolygon ; + AuxPolygon.FromPolyLine( plPoly) ; + Vector3d vtPolyNorm = AuxPolygon.GetVersN() ; + Vector3d vtOut = vtTan ^ vtPolyNorm ; + Vector3d vtNextOut = vtNextTan ^ vtPolyNorm ; + // Caso concavo + if ( vtNextTan * vtOut > 0) { + Vector3d vtTest = ptP - ptMinDist ; + if ( vtTest * vtOut < 0 || vtTest * vtNextOut < 0) + return true ; + } + // Caso convesso + else { + Vector3d vtTest = ptP - ptMinDist ; + if ( vtTest * vtOut < 0 && vtTest * vtNextOut < 0) + return true ; + } + } + // Punto di minima distanza interno al segmeno + else { + Vector3d vtP = ptP - itMinDistSt->first ; + Vector3d vtTan = itMinDistEn->first - itMinDistSt->first ; + vtTan.Normalize() ; + Polygon3d AuxPolygon ; + AuxPolygon.FromPolyLine( plPoly) ; + Vector3d vtPolyNorm = AuxPolygon.GetVersN() ; + Vector3d vtOut = vtTan ^ vtPolyNorm ; + vtP -= ( vtP * vtTan) * vtTan ; + if ( vtP * vtOut < - EPS_SMALL) + return true ; + } + return false ; +} + +//---------------------------------------------------------------------------- +bool +DistPointPolyLine( const Point3d& ptP, const PolyLine& plPoly, double& dPointPolyLineDist) +{ + if ( plPoly.GetPointNbr() == 0) + return false ; + dPointPolyLineDist = DBL_MAX ; + Point3d ptSt, ptEn ; + bool bContinue = plPoly.GetFirstPoint( ptSt) && plPoly.GetNextPoint( ptEn) ; + while ( bContinue) { + double dPoinLineDist ; + DistPointLine PointLineDistCalc( ptP, ptSt, ptEn) ; + PointLineDistCalc.GetDist( dPoinLineDist) ; + if ( dPoinLineDist < dPointPolyLineDist) + dPointPolyLineDist = dPoinLineDist ; + ptSt = ptEn ; + bContinue = plPoly.GetNextPoint( ptEn) ; + } + return true ; +} + //---------------------------------------------------------------------------- // Una faccia di una trimesh ha una sola componente connessa. // Si assume che i loop siano corretti e rispettino tale propriet�. @@ -3104,6 +3338,98 @@ DistPointFacet( const Point3d& ptP, /*const*/ POLYLINEVECTOR& vPolyVec, double& return true ; } +//---------------------------------------------------------------------------- +static bool +SplitPolyLineAtPoint( const Point3d& ptPoint, /*const*/ PolyLine& Loop, PolyLine& Loop1, PolyLine& Loop2) +{ + // Rinomino la lista di punti della PolyLine. + /*const*/ PNTULIST& LoopList = Loop.GetUPointList() ; + // Ciclo sui segmenti del loop per cercare il tratto del loop chiuso pi� vicino al punto. + double dMinSqDist = DBL_MAX ; + auto itMinDistSt = LoopList.end() ; + auto itSt = LoopList.begin() ; + auto itEn = itSt ; + ++ itEn ; + for ( ; itSt != LoopList.end() && itEn != LoopList.end() ; ++ itSt, ++ itEn) { + // Estremi del segmento corrente del loop + Point3d ptSegSt = itSt->first ; + Point3d ptSegEn = itEn->first ; + // Distanza del punto dal segmento del loop + DistPointLine dDistCalc( ptPoint, ptSegSt, ptSegEn) ; + double dSqDist ; + dDistCalc.GetSqDist( dSqDist) ; + if ( dSqDist < dMinSqDist) { + dMinSqDist = dSqDist ; + itMinDistSt = itSt ; + } + } + // Se il punto non sta sul loop, lo segnalo. + if ( dMinSqDist > 100 * SQ_EPS_SMALL) + return false ; + // Se il punto di stop sta su un vertice non devo aggiungerlo e il + // punto di stop sar� uno degli estremi del segmento su cui giace. + auto itStop = itMinDistSt ; + auto itNext = itMinDistSt ; + ++ itNext ; + if ( AreSamePointApprox( ptPoint, itStop->first)) + ; + else if ( AreSamePointApprox( ptPoint, itNext->first)) + itStop = itNext ; + else { + itStop = LoopList.emplace( itNext, ptPoint, 0.) ; + } + // Creo i due loop + PNTULIST& LoopList1 = Loop1.GetUPointList() ; + PNTULIST& LoopList2 = Loop2.GetUPointList() ; + for ( auto it = LoopList.begin() ; it != itStop ; ++ it) { + LoopList1.emplace_back( it->first, it->second) ; + } + LoopList1.emplace_back( itStop->first, itStop->second) ; + for ( auto it = itStop ; it != LoopList.end() ; ++ it) { + LoopList2.emplace_back( it->first, it->second) ; + } + return true ; +} + +//---------------------------------------------------------------------------- +static bool +AddPolyLineToPolyLine( PolyLine& Poly, PolyLine& PolyToAdd) +{ + // Se la PolyLine a cui devo aggiungere l'altra � chiusa, non posso aggiungere nulla. + if ( Poly.IsClosed()) + return false ; + // Se la PolyLina che devo aggiungere � vuota, ho finito. + PNTULIST& PolyToAddList = PolyToAdd.GetUPointList() ; + if ( int( PolyToAddList.size()) == 0) + return true ; + // Se Poly non � vuota e la sua fine non coincide con l'inizio di PolyToAdd, non � possibile aggiungere nulla. + Point3d ptLast ; + Poly.GetLastPoint( ptLast) ; + auto it = PolyToAddList.begin() ; + if ( Poly.GetPointNbr() != 0 && ! AreSamePointEpsilon( it->first, ptLast, 10 * EPS_SMALL)) + return false ; + /*if ( Poly.GetPointNbr() == 0) + Poly.AddUPoint( 0., it->first) ; + ++ it ;*/ + // Aggiungo i punti. + for ( ; it != PolyToAddList.end() ; ++ it) { + Poly.AddUPoint( 0., it->first) ; + } + return true ; +} + +//---------------------------------------------------------------------------- +struct PositionOnPolyLine { + int nIndexInVec ; + int nSegNum ; + double dParOnSeg ; + PositionOnPolyLine( int nIndex, int nSeg, double dPar) { + nIndexInVec = nIndex ; + nSegNum = nSeg ; + dParOnSeg = dPar ; + } +} ; + //---------------------------------------------------------------------------- bool SurfTriMesh::SplitFacet( const INTERSCHAINMAP& IntersLineMap, PieceMap& NewFacet) @@ -3299,7 +3625,6 @@ SurfTriMesh::SplitFacet( const INTERSCHAINMAP& IntersLineMap, PieceMap& NewFacet NewLoop2.IsClosedAndFlat(plLoopPlane2, dArea2); vNewPieces[nPart].vPieceLoop[0].IsClosedAndFlat(plContLoopPlane, dAreaCont); Vector3d vtLoopPlaneNorm1 = plLoopPlane1.GetVersN(); - Vector3d vtLoopPlaneNorm2 = plLoopPlane2.GetVersN(); Vector3d vtContLoopPlaneNorm = plContLoopPlane.GetVersN(); PolyLine NewLoopCCW, NewLoopCW; bool bFirstLoopIsCounter = vtLoopPlaneNorm1 * vtContLoopPlaneNorm > EPS_SMALL; @@ -3489,7 +3814,6 @@ SurfTriMesh::SplitFacet( const INTERSCHAINMAP& IntersLineMap, PieceMap& NewFacet NewLoop2.IsClosedAndFlat( plLoopPlane2, dArea2) ; vNewPieces[nPart].vPieceLoop[0].IsClosedAndFlat( plContLoopPlane, dAreaCont) ; Vector3d vtLoopPlaneNorm1 = plLoopPlane1.GetVersN(); - Vector3d vtLoopPlaneNorm2 = plLoopPlane2.GetVersN(); Vector3d vtContLoopPlaneNorm = plContLoopPlane.GetVersN(); PolyLine NewLoopCCW, NewLoopCW; bool bFirstLoopIsCounter = vtLoopPlaneNorm1 * vtContLoopPlaneNorm > EPS_SMALL; @@ -4262,7 +4586,6 @@ SurfTriMesh::RetriangulateFacetPieces( const PieceMap& NewFacet, for ( int& nT : vFacetTria) RemoveTriangle( nT) ; } - int nIndexPosInVec = 0 ; for ( auto it = NewFacet.begin() ; it != NewFacet.end() ; ++ it) { const vector& PiecesVector = it->second ; // Ciclo sui nuovi pezzi di faccia. @@ -4507,7 +4830,6 @@ SurfTriMesh::IntersectTriMeshFacets( SurfTriMesh& Other) } // Ciclo sulle facce delle mesh int nFacetNumA = GetFacetCount() ; - int nFacetNumB = SurfB.GetFacetCount() ; for ( int nFA = 0 ; nFA < nFacetNumA ; ++ nFA) { // Dati della faccia POLYLINEVECTOR LoopVecA ; diff --git a/Tool.cpp b/Tool.cpp index 42c5420..98d4fbd 100644 --- a/Tool.cpp +++ b/Tool.cpp @@ -475,19 +475,19 @@ Tool::SetGenTool( const string& sToolName, const ICurveComposite* pToolOutline, if ( ! pCurve->ApproxWithLines( m_dLinTol, m_dAngTolDeg, ICurve::APL_SPECIAL, plyApprox)) return false ; // Aggiungo i segmenti di retta alla approssimazione - Point3d ptEnd ; + Point3d ptEnd, ptTmp ; plyApprox.GetFirstPoint( ptEnd) ; double dEndU ; pCurve->GetParamAtPoint( ptEnd, dEndU) ; Vector3d vtTanArc, vtExtN ; - pCurve->GetPointTang( dEndU, ICurve::FROM_MINUS, Point3d( 0, 0, 0), vtTanArc) ; + pCurve->GetPointTang( dEndU, ICurve::FROM_MINUS, ptTmp, vtTanArc) ; vtExtN = - vtTanArc ^ Z_AX ; vtExtN.Normalize() ; m_vArcNormals.emplace_back( vtExtN) ; while ( plyApprox.GetNextPoint( ptEnd)) { m_ArcLineApprox.AddLine( ptEnd) ; pCurve->GetParamAtPoint( ptEnd, dEndU) ; - pCurve->GetPointTang( dEndU, ICurve::FROM_MINUS, Point3d(0, 0, 0), vtTanArc) ; + pCurve->GetPointTang( dEndU, ICurve::FROM_MINUS, ptTmp, vtTanArc) ; vtExtN = - vtTanArc ^ Z_AX ; vtExtN.Normalize() ; m_vArcNormals.emplace_back( vtExtN) ; diff --git a/Triangulate.cpp b/Triangulate.cpp index 6462781..905844a 100644 --- a/Triangulate.cpp +++ b/Triangulate.cpp @@ -1,4 +1,4 @@ -//---------------------------------------------------------------------------- +//---------------------------------------------------------------------------- // EgalTech 2014-2014 //---------------------------------------------------------------------------- // File : Triangulate.cpp Data : 23.06.14 Versione : 1.5f6 @@ -16,18 +16,12 @@ #include "DllMain.h" #include "Triangulate.h" #include "ProjPlane.h" -#include "tpp_interface.hpp" -#include "CurveComposite.h" -#include "CurveLine.h" -#include "/EgtDev/Include/EGkIntersCurves.h" -#include "/EgtDev/Include/EGkDistPointCurve.h" #include "/EgtDev/Include/EGkPolyLine.h" #include "/EgtDev/Include/EGkPlane3d.h" #include "/EgtDev/Include/EGkStringUtils3d.h" #include using namespace std ; -using namespace tpp ; //---------------------------------------------------------------------------- enum EarStatus{ EAS_NULL = -1, EAS_NO = 0, EAS_OK = 1} ; @@ -37,22 +31,17 @@ static bool ChangeStartPntVector( int nNewStart, PNTVECTOR& vPi) ; //---------------------------------------------------------------------------- // In : PolyLine -// trgType : triangulation type // Out : PNTVECTOR (Point3d Vector) : points of the polyline // INTVECTOR (int Vector) : 3*T indices of above points for T triangles //---------------------------------------------------------------------------- bool -Triangulate::Make( const PolyLine& PL, PNTVECTOR& vPt, INTVECTOR& vTr, TrgType trgType) +Triangulate::Make( const PolyLine& PL, PNTVECTOR& vPt, INTVECTOR& vTr) { // verifico che la polilinea sia chiusa e piana e calcolo il piano medio del poligono double dArea ; Plane3d plPlane ; if ( ! PL.IsClosedAndFlat( plPlane, dArea, 50 * EPS_SMALL)) return false ; - - if ( trgType != TRG_STANDARD) - return Make( POLYLINEVECTOR{ PL}, vPt, vTr, trgType) ; - // determino il piano ottimale di proiezione e il relativo senso di rotazione bool bCCW ; if ( ! CalcProjPlane( plPlane.GetVersN(), m_nPlane, bCCW)) @@ -93,12 +82,11 @@ Triangulate::Make( const PolyLine& PL, PNTVECTOR& vPt, INTVECTOR& vTr, TrgType t //---------------------------------------------------------------------------- // In : POLYLINEVECTOR : vector of polylines, the first outer, the others inner -// trgType : triangulation type // Out : PNTVECTOR (Point3d Vector) : points of the polyline // INTVECTOR (int Vector) : 3*T indices of above points for T triangles //---------------------------------------------------------------------------- bool -Triangulate::Make( const POLYLINEVECTOR& vPL, PNTVECTOR& vPt, INTVECTOR& vTr, TrgType trgType) +Triangulate::Make( const POLYLINEVECTOR& vPL, PNTVECTOR& vPt, INTVECTOR& vTr) { // pulisco i vettori di ritorno vPt.clear() ; @@ -107,7 +95,7 @@ Triangulate::Make( const POLYLINEVECTOR& vPL, PNTVECTOR& vPt, INTVECTOR& vTr, Tr if ( &vPL == nullptr || vPL.empty()) return false ; // se una sola polilinea mi riconduco al caso precedente - if ( vPL.size() == 1 && trgType == TRG_STANDARD) + if ( vPL.size() == 1) return Make( vPL[0], vPt, vTr) ; // verifico che la polilinea esterna sia chiusa e piana e calcolo il piano medio del poligono double dArea ; @@ -127,31 +115,6 @@ Triangulate::Make( const POLYLINEVECTOR& vPL, PNTVECTOR& vPt, INTVECTOR& vTr, Tr ! AreOppositeVectorApprox( plExtPlane.GetVersN(), plPlane.GetVersN())) return false ; } - - // triangolazione Delaunay - if ( trgType == TRG_DEL_CONFORMING) { - if ( ! MakeByDelaunay( vPL, vPt, vTr, true, true)) { - LOG_ERROR( GetEGkLogger(), "Error in MakeByDelaunay ( conforming)") ; - return false ; - } - return true ; - } - else if ( trgType == TRG_DEL_QUALITY) { - if ( ! MakeByDelaunay( vPL, vPt, vTr, false, true)) { - LOG_ERROR( GetEGkLogger(), "Error in MakeByDelaunay ( quality)") ; - return false ; - } - return true ; - } - else if ( trgType == TRG_DEL_NOQUALITY) { - if ( ! MakeByDelaunay( vPL, vPt, vTr, false, false)) { - LOG_ERROR( GetEGkLogger(), "Error in MakeByDelaunay ( no quality)") ; - return false ; - } - return true ; - } - - // ear clipping // se non CCW inverto tutte le polilinee if ( ! bCCW) { for ( int i = 0 ; i < int( vPL.size()) ; ++i) @@ -209,7 +172,7 @@ Triangulate::Make( const POLYLINEVECTOR& vPL, PNTVECTOR& vPt, INTVECTOR& vTr, Tr INTVECTOR vPol ; int n = int( vPt.size()) ; vPol.reserve( n) ; - // non devo gestire separatamente CCW perchè ho già invertito i punti + // non devo gestire separatamente CCW perch� ho gi� invertito i punti for ( int i = 0 ; i < n ; ++ i) vPol.push_back( i) ; @@ -446,7 +409,7 @@ Triangulate::MakeByEC( const PNTVECTOR& vPt, const INTVECTOR& vPol, INTVECTOR& v vTr.push_back( vPol[i]) ; vTr.push_back( vPol[vNext[i]]) ; } - // ‘Delete’ vertex v[i] by redirecting next and previous links + // �Delete� vertex v[i] by redirecting next and previous links // of neighboring verts past it. Decrement vertex count vNext[vPrev[i]] = vNext[i] ; vPrev[vNext[i]] = vPrev[i] ; @@ -536,7 +499,6 @@ Triangulate::MakeByEC2( const PNTVECTOR& vPt, const INTVECTOR& vPol, INTVECTOR& } // Try with 19 prev int nLimP = min( 19, n / 2) ; - double dSqDist2 = SQ_INFINITO ; for ( int h = 0 ; h < nLimP ; ++ h) { k = vPrev[k] ; if ( vEar[k] == EAS_NULL) @@ -567,7 +529,7 @@ Triangulate::MakeByEC2( const PNTVECTOR& vPt, const INTVECTOR& vPol, INTVECTOR& // Reset earity of diagonal endpoints vEar[vPrev[i]] = EAS_NULL ; vEar[vNext[i]] = EAS_NULL ; - // ‘Delete’ vertex v[i] by redirecting next and previous links + // �Delete� vertex v[i] by redirecting next and previous links // of neighboring verts past it. Decrement vertex count vNext[vPrev[i]] = vNext[i] ; vPrev[vNext[i]] = vPrev[i] ; @@ -680,7 +642,7 @@ Triangulate::MakeByEC3( const PNTVECTOR& vPt, const INTVECTOR& vPol, INTVECTOR& // Reset earity of diagonal endpoints vEar[vPrev[i]] = EAS_NULL ; vEar[vNext[i]] = EAS_NULL ; - // ‘Delete’ vertex v[i] by redirecting next and previous links + // �Delete� vertex v[i] by redirecting next and previous links // of neighboring verts past it. Decrement vertex count vNext[vPrev[i]] = vNext[i] ; vPrev[vNext[i]] = vPrev[i] ; @@ -747,7 +709,7 @@ Triangulate::TestTriangle( const PNTVECTOR& vPt, const INTVECTOR& vPol, } } else { - // The ‘ear’ triangle is clockwise so v[i] is not an ear + // The �ear� triangle is clockwise so v[i] is not an ear bIsEar = false ; } @@ -1073,14 +1035,14 @@ Triangulate::GetOuterPntToJoin( const PNTVECTOR& vPt, const Point3d& ptP, int& n break ; } } - // non ho trovato alcunché, errore + // non ho trovato alcunch�, errore if ( nI == - 1) return false ; // se ho trovato un punto esatto del contorno, non devo fare altri controlli if ( AreSamePointApprox( ptInt, vPt[nI])) return true ; // devo ora verificare che il segmento che unisce i punti non intersechi altri lati del contorno esterno - // altrimenti tengo il punto con raggio più vicino a X_AX o Y_AX o Z_AX secondo m_nPlane + // altrimenti tengo il punto con raggio pi� vicino a X_AX o Y_AX o Z_AX secondo m_nPlane int nJ = nI ; Point3d ptPa = ptP ; Point3d ptPb = vPt[nI] ; @@ -1096,7 +1058,7 @@ Triangulate::GetOuterPntToJoin( const PNTVECTOR& vPt, const Point3d& ptP, int& n double dMinTan = INFINITO ; double dMinSqDist = SQ_INFINITO ; for ( int i = 0 ; i < nNumPt ; ++ i) { - // salto il punto già trovato + // salto il punto gi� trovato if ( i == nJ) continue ; // verifico se sta nel triangolo @@ -1132,7 +1094,7 @@ Triangulate::GetOuterPntToJoin( const PNTVECTOR& vPt, const Point3d& ptP, int& n bool Triangulate::PointInSector( const Point3d& ptTest, const Point3d& ptPrev, const Point3d& ptCorn, const Point3d& ptNext) { - // la parte valida del settore è a sinistra dei segmenti ptPrev --> ptCorn --> ptNext + // la parte valida del settore � a sinistra dei segmenti ptPrev --> ptCorn --> ptNext // se corner convesso if ( TriangleIsCCW( ptPrev, ptCorn, ptNext, 0)) return ( TriangleIsCCW( ptPrev, ptCorn, ptTest) && @@ -1147,10 +1109,10 @@ Triangulate::PointInSector( const Point3d& ptTest, const Point3d& ptPrev, const bool ChangeStartPntVector( int nNewStart, PNTVECTOR& vPi) { - // se il nuovo inizio coincide col vecchio, non devo fare alcunché + // se il nuovo inizio coincide col vecchio, non devo fare alcunch� if ( nNewStart == 0) return true ; - // se il nuovo indice è oltre la dimensione del vettore, errore + // se il nuovo indice � oltre la dimensione del vettore, errore if ( nNewStart >= int( vPi.size())) return false ; // ciclo di aggiustamento diff --git a/Triangulate.h b/Triangulate.h index 2f630a6..c95549a 100644 --- a/Triangulate.h +++ b/Triangulate.h @@ -16,19 +16,12 @@ #include "/EgtDev/Include/EGkPolyLine.h" #include "/EgtDev/Include/EGkPointGrid3d.h" -// -enum TrgType { TRG_STANDARD, // ear clipping - TRG_DEL_CONFORMING, // conforming Delaunay ( with quality constraint) - TRG_DEL_QUALITY, // Delaunay with quality constraints ( no angle smaller than 20 degrees) - TRG_DEL_NOQUALITY // Delaunay without quality constraints - } ; - //---------------------------------------------------------------------------- class Triangulate { public : - bool Make( const PolyLine& PL, PNTVECTOR& vPt, INTVECTOR& vTr, TrgType trgType = TRG_STANDARD) ; - bool Make( const POLYLINEVECTOR& vPL, PNTVECTOR& vPt, INTVECTOR& vTr, TrgType trgType = TRG_STANDARD) ; + bool Make( const PolyLine& PL, PNTVECTOR& vPt, INTVECTOR& vTr) ; + bool Make( const POLYLINEVECTOR& vPL, PNTVECTOR& vPt, INTVECTOR& vTr) ; private : bool PrepareGrid( const PNTVECTOR& vPt, const INTVECTOR& vPol, @@ -36,7 +29,6 @@ class Triangulate bool MakeByEC( const PNTVECTOR& vPt, const INTVECTOR& vPol, INTVECTOR& vTr) ; bool MakeByEC2( const PNTVECTOR& vPt, const INTVECTOR& vPol, INTVECTOR& vTr) ; bool MakeByEC3( const PNTVECTOR& vPt, const INTVECTOR& vPol, INTVECTOR& vTr) ; - bool MakeByDelaunay( const POLYLINEVECTOR& vPL, PNTVECTOR& vPt, INTVECTOR& vTr, bool bConforming, bool bQuality) ; bool TestTriangle( const PNTVECTOR& vPt, const INTVECTOR& vPol, const INTVECTOR& vPrev, INTVECTOR& vNext, int i) ; double CalcTriangleAspectRatio( const Point3d& ptPa, const Point3d& ptPb, const Point3d& ptPc) ; diff --git a/VolZmap.cpp b/VolZmap.cpp index 7b7575a..cc0a5bd 100644 --- a/VolZmap.cpp +++ b/VolZmap.cpp @@ -1287,7 +1287,7 @@ VolZmap::ClonePart( int nPart) const // Definisco il numero di blocchi lungo x,y e z if ( ! pVolume->CalcBlockNum()) - return false ; + return nullptr ; // Sistema di riferimento intrinseco del nuovo solido Point3d ptNewO = m_MapFrame.Orig() + Vector3d( dNewOx, dNewOy, dNewOz) ; diff --git a/VolZmapCalculus.cpp b/VolZmapCalculus.cpp index 160029a..2ce0344 100644 --- a/VolZmapCalculus.cpp +++ b/VolZmapCalculus.cpp @@ -983,8 +983,6 @@ VolZmap::AvoidSimpleCylinder( const Frame3d& frCyl, double dR, double dH, bool b // Ciclo sui dexel. for ( int i = nStI ; i <= nEnI ; ++ i) { for ( int j = nStJ ; j <= nEnJ ; ++ j) { - if ( nMap == 2 && j == 75) - int a = 0 ; int nPos = j * m_nNx[nMap] + i ; int nSize = int( m_Values[nMap][nPos].size()) ; if ( nSize == 0) @@ -1519,71 +1517,72 @@ RectPrismoidSegmentCollision( const Frame3d& frPrismoid, double dLenghtBaseX, do // Se c'è collisione con almeno un triangolo delle facce ho finito Triangle3d trFaceTria1, trFaceTria2 ; + Point3d ptInt, ptInt2 ; // Faccia base trFaceTria1.Set( Point3d( - dHalfBaseX, - dHalfBaseY, 0.), Point3d( - dHalfBaseX, dHalfBaseY, 0.), Point3d( dHalfBaseX, dHalfBaseY, 0.)) ; - if ( trFaceTria1.Validate() && IntersLineTria( ptMySt, ptMyEn, trFaceTria1, Point3d(), Point3d()) != ILTT_NO) + if ( trFaceTria1.Validate() && IntersLineTria( ptMySt, ptMyEn, trFaceTria1, ptInt, ptInt2) != ILTT_NO) return true ; trFaceTria2.Set( Point3d( - dHalfBaseX, - dHalfBaseY, 0.), Point3d( dHalfBaseX, dHalfBaseY, 0.), Point3d( dHalfBaseX, - dHalfBaseY, 0.)) ; - if ( trFaceTria2.Validate() && IntersLineTria( ptMySt, ptMyEn, trFaceTria2, Point3d(), Point3d()) != ILTT_NO) + if ( trFaceTria2.Validate() && IntersLineTria( ptMySt, ptMyEn, trFaceTria2, ptInt, ptInt2) != ILTT_NO) return true ; // Faccia top trFaceTria1.Set( Point3d( - dHalfTopX, - dHalfTopY, dHeight), Point3d( dHalfTopX, dHalfTopY, dHeight), Point3d( - dHalfTopX, dHalfTopY, dHeight)) ; - if ( trFaceTria1.Validate() && IntersLineTria( ptMySt, ptMyEn, trFaceTria1, Point3d(), Point3d()) != ILTT_NO) + if ( trFaceTria1.Validate() && IntersLineTria( ptMySt, ptMyEn, trFaceTria1, ptInt, ptInt2) != ILTT_NO) return true ; trFaceTria2.Set( Point3d( - dHalfTopX, - dHalfTopY, dHeight), Point3d( dHalfTopX, - dHalfTopY, dHeight), Point3d( dHalfTopX, dHalfTopY, dHeight)) ; - if ( trFaceTria2.Validate() && IntersLineTria( ptMySt, ptMyEn, trFaceTria2, Point3d(), Point3d()) != ILTT_NO) + if ( trFaceTria2.Validate() && IntersLineTria( ptMySt, ptMyEn, trFaceTria2, ptInt, ptInt2) != ILTT_NO) return true ; // Faccia laterale 1 trFaceTria1.Set( Point3d( - dHalfBaseX, - dHalfBaseY, 0.), Point3d( dHalfTopX , - dHalfTopY , dHeight), Point3d( - dHalfTopX , - dHalfTopY , dHeight)) ; - if ( trFaceTria1.Validate() && IntersLineTria( ptMySt, ptMyEn, trFaceTria1, Point3d(), Point3d()) != ILTT_NO) + if ( trFaceTria1.Validate() && IntersLineTria( ptMySt, ptMyEn, trFaceTria1, ptInt, ptInt2) != ILTT_NO) return true ; trFaceTria2.Set( Point3d( - dHalfBaseX, - dHalfBaseY, 0.), Point3d( dHalfBaseX, - dHalfBaseY, 0.), Point3d( dHalfTopX, - dHalfTopY , dHeight)) ; - if ( trFaceTria2.Validate() && IntersLineTria( ptMySt, ptMyEn, trFaceTria2, Point3d(), Point3d()) != ILTT_NO) + if ( trFaceTria2.Validate() && IntersLineTria( ptMySt, ptMyEn, trFaceTria2, ptInt, ptInt2) != ILTT_NO) return true ; // Faccia laterale 2 trFaceTria1.Set( Point3d( dHalfBaseX, - dHalfBaseY, 0.), Point3d( dHalfTopX , dHalfTopY , dHeight), Point3d( dHalfTopX , - dHalfTopY , dHeight)) ; - if ( trFaceTria1.Validate() && IntersLineTria( ptMySt, ptMyEn, trFaceTria1, Point3d(), Point3d()) != ILTT_NO) + if ( trFaceTria1.Validate() && IntersLineTria( ptMySt, ptMyEn, trFaceTria1, ptInt, ptInt2) != ILTT_NO) return true ; trFaceTria2.Set( Point3d( dHalfBaseX, - dHalfBaseY, 0.), Point3d( dHalfBaseX, dHalfBaseY, 0.), Point3d( dHalfTopX , dHalfTopY , dHeight)) ; - if ( trFaceTria2.Validate() && IntersLineTria( ptMySt, ptMyEn, trFaceTria2, Point3d(), Point3d()) != ILTT_NO) + if ( trFaceTria2.Validate() && IntersLineTria( ptMySt, ptMyEn, trFaceTria2, ptInt, ptInt2) != ILTT_NO) return true ; // Faccia laterale 3 trFaceTria1.Set( Point3d( dHalfBaseX, dHalfBaseY, 0.), Point3d( - dHalfTopX , dHalfTopY , dHeight), Point3d( dHalfTopX , dHalfTopY , dHeight)) ; - if ( trFaceTria1.Validate() && IntersLineTria( ptMySt, ptMyEn, trFaceTria1, Point3d(), Point3d()) != ILTT_NO) + if ( trFaceTria1.Validate() && IntersLineTria( ptMySt, ptMyEn, trFaceTria1, ptInt, ptInt2) != ILTT_NO) return true ; trFaceTria2.Set( Point3d( dHalfBaseX, dHalfBaseY, 0.), Point3d( - dHalfBaseX, dHalfBaseY, 0.), Point3d( - dHalfTopX , dHalfTopY , dHeight)) ; - if ( trFaceTria2.Validate() && IntersLineTria( ptMySt, ptMyEn, trFaceTria2, Point3d(), Point3d()) != ILTT_NO) + if ( trFaceTria2.Validate() && IntersLineTria( ptMySt, ptMyEn, trFaceTria2, ptInt, ptInt2) != ILTT_NO) return true ; // Faccia laterale 4 trFaceTria1.Set( Point3d( - dHalfBaseX, dHalfBaseY, 0.), Point3d( - dHalfTopX , - dHalfTopY , dHeight), Point3d( - dHalfTopX , dHalfTopY , dHeight)) ; - if ( trFaceTria1.Validate() && IntersLineTria( ptMySt, ptMyEn, trFaceTria1, Point3d(), Point3d()) != ILTT_NO) + if ( trFaceTria1.Validate() && IntersLineTria( ptMySt, ptMyEn, trFaceTria1, ptInt, ptInt2) != ILTT_NO) return true ; trFaceTria2.Set( Point3d( - dHalfBaseX, dHalfBaseY, 0.), Point3d( - dHalfBaseX, - dHalfBaseY, 0.), Point3d( - dHalfTopX , - dHalfTopY , dHeight)) ; - if ( trFaceTria2.Validate() && IntersLineTria( ptMySt, ptMyEn, trFaceTria2, Point3d(), Point3d()) != ILTT_NO) + if ( trFaceTria2.Validate() && IntersLineTria( ptMySt, ptMyEn, trFaceTria2, ptInt, ptInt2) != ILTT_NO) return true ; return false ; @@ -2254,7 +2253,8 @@ VolZmap::AvoidSurfTm( const ISurfTriMesh& tmSurf, double dSafeDist, bool bPrecis trNewTria.Translate( dSafeDist * trTria.GetN()) ; } // Intersezione segento triangolo - int nIntersType = IntersLineTria( ptSegSt, vtLineDir, dSegLen, trNewTria, Point3d(), Point3d()) ; + Point3d ptInt, ptInt2 ; + int nIntersType = IntersLineTria( ptSegSt, vtLineDir, dSegLen, trNewTria, ptInt, ptInt2) ; // Collisione if ( nIntersType != IntLineTriaType::ILTT_NO) return false ; @@ -2356,7 +2356,8 @@ VolZmap::AvoidSurfTm( const ISurfTriMesh& tmSurf, double dSafeDist, bool bPrecis trNewTria.Translate( dSafeDist * trTria.GetN()) ; } // Intersezione segento triangolo - int nIntersType = IntersLineTria( ptSegSt, vtLineDir, dSegLen, trNewTria, Point3d(), Point3d()) ; + Point3d ptInt, ptInt2 ; + int nIntersType = IntersLineTria( ptSegSt, vtLineDir, dSegLen, trNewTria, ptInt, ptInt2) ; // Collisione if ( nIntersType != IntLineTriaType::ILTT_NO) return false ; diff --git a/VolZmapGraphics.cpp b/VolZmapGraphics.cpp index a86b07e..90c85fb 100644 --- a/VolZmapGraphics.cpp +++ b/VolZmapGraphics.cpp @@ -35,18 +35,6 @@ typedef Eigen::Matrix SvdVector ; typedef Eigen::JacobiSVD SvdDecomposer ; -// ------------------------- TABELLA BLOCCHI ADIACENTI ---------------------------------------------------------------------------- -static int NeighbourTable[8][4] = { - {0, -1, -1, -1}, - {1, 1, -1, -1}, - {1, 1, 2, -1}, - {2, 1, 2, -1}, - {1, 3, -1, -1}, - {2, 1, 3, -1}, - {2, 2, 3, -1}, - {3, 1, 2, 3} - } ; - // ------------------------- FUNZIONE TEST SULLE NORMALI -------------------------------------------------------------------------- enum FatureType { NO_FEATURE = 0, CORNER = 1, EDGE = 2} ; enum CanonicDir { X_PLUS = 1, X_MINUS = -1, Y_PLUS = 2, Y_MINUS = -2, Z_PLUS = 3, Z_MINUS = -3} ; @@ -2960,8 +2948,6 @@ VolZmap::FlipEdgesII( int nBlock) const vTria1[nTri1].SetGrade( nCol1) ; vTria2[nTri2].SetGrade( nCol2) ; // Setto le normali - Vector3d vtN1 = vTria1[nTri1].GetVertexNorm( 2) ; - Vector3d vtN2 = vTria2[nTri2].GetVertexNorm( 2) ; vTria1[nTri1].SetVertexNorm( 0, V_NULL) ; vTria1[nTri1].SetVertexNorm( 1, V_NULL) ; vTria2[nTri2].SetVertexNorm( 0, V_NULL) ; diff --git a/VolZmapVolume.cpp b/VolZmapVolume.cpp index 70bf9ab..84383ba 100644 --- a/VolZmapVolume.cpp +++ b/VolZmapVolume.cpp @@ -887,7 +887,7 @@ VolZmap::CylBall_ZDrilling( int nGrid, const Point3d & ptS, const Point3d & ptE, double dSqLen = vtC.SqLen() ; // Se il punto si trova dentro il cerchio taglio - if ( dSqLen < dSqRad - 2 * m_Tool.GetRadius() * EPS_SMALL) + if ( dSqLen < dSqRad - 2 * m_Tool.GetRadius() * EPS_SMALL) { // utensile cilindrico if ( m_Tool.GetType() == Tool::CYLMILL) SubtractIntervals( nGrid, i, j, dMinStemZ, dMaxStemZ, Z_AX, - Z_AX) ; @@ -905,6 +905,7 @@ VolZmap::CylBall_ZDrilling( int nGrid, const Point3d & ptS, const Point3d & ptE, SubtractIntervals( nGrid, i, j, dMinStemZ, dMaxStemZ + dH, - vtToolDir, vtNorm) ; } } + } } } return true ; @@ -1073,11 +1074,6 @@ VolZmap::CylBall_ZMilling( int nGrid, const Point3d & ptS, const Point3d & ptE, double dLenXY = vtMoveXY.LenXY() ; vtMove.Normalize() ; - // Parametri per determinare l'ellisse proiettata - double dCos = vtToolDir * vtMove ; - double dSemiAxMin = m_Tool.GetRadius() * dCos ; // x1^2 = a^2 - (a / b)^2 x2^2 ; a = r dCos e b = r; - double dSqSemiAxMin = dSemiAxMin * dSemiAxMin ; // da cui si ottiene x1^2 = a^2 - dCos^2 x2^2 - // Definizione di un sistema di riferimento ad hoc Vector3d vtV1, vtV2 ; @@ -3401,11 +3397,6 @@ VolZmap::CompCyl_ZMilling( int nGrid, const Point3d& ptS, const Point3d& ptE, co double dLenXY = vtMoveXY.LenXY() ; vtMove.Normalize() ; - // Parametri per determinare l'ellisse proiettata - double dCos = vtToolDir * vtMove ; - double dSemiAxMin = dRad * dCos ; // x1^2 = a^2 - (a / b)^2 x2^2 ; a = r dCos e b = r; - double dSqSemiAxMin = dSemiAxMin * dSemiAxMin ; // da cui si ottiene x1^2 = a^2 - dCos^2 x2^2 - double dSafeRad = dRad - EPS_SMALL ; // Definizione di un sistema di riferimento ad hoc @@ -3502,9 +3493,6 @@ VolZmap::CompConus_ZMilling( int nGrid, const Point3d& ptS, const Point3d& ptE, Point3d ptI = ( vtToolDir * ( ptE - ptS) > 0 ? ptS : ptE) ; Point3d ptF = ( vtToolDir * ( ptE - ptS) > 0 ? ptE : ptS) ; - Point3d ptIT = ptI - vtToolDir * dHei ; - Point3d ptFT = ptF - vtToolDir * dHei ; - Point3d ptIxy( ptI.x, ptI.y, 0) ; Point3d ptFxy( ptF.x, ptF.y, 0) ; @@ -4072,7 +4060,6 @@ VolZmap::CompCyl_Milling( int nGrid, const Point3d& ptS, const Point3d& ptE, Point3d ptI = ( vtToolDir * ( ptE - ptS) > 0 ? ptS : ptE) ; Point3d ptF = ( vtToolDir * ( ptE - ptS) > 0 ? ptE : ptS) ; Point3d ptITip = ptI - vtToolDir * dHei ; - Point3d ptFTip = ptF - vtToolDir * dHei ; // Definizione terne vettoriali e sistemi di riferimento intrinseci al movimento Vector3d vtMove = ptF - ptI ; @@ -4157,9 +4144,6 @@ VolZmap::CompConus_Milling( int nGrid, const Point3d& ptS, const Point3d& ptE, c Point3d ptI = ( vtToolDir * ( ptE - ptS) > 0 ? ptS : ptE) ; Point3d ptF = ( vtToolDir * ( ptE - ptS) > 0 ? ptE : ptS) ; - Point3d ptIT = ptI - vtToolDir * dHei ; - Point3d ptFT = ptF - vtToolDir * dHei ; - double dL = ( dMaxRad * dHei) / dDeltaR ; double dl = dL - dHei ;