From 90df6d3a7a1435347deeb45babb276099ec8448c Mon Sep 17 00:00:00 2001 From: Dario Sassi Date: Mon, 13 May 2019 06:36:58 +0000 Subject: [PATCH] EgtGeomKernel 2.1e3 : - modifiche a Zmap per intersezioni con linee e piani. --- EgtGeomKernel.rc | Bin 11710 -> 11710 bytes EgtGeomKernel.vcxproj | 27 +- EgtGeomKernel.vcxproj.filters | 81 ++- GdbExecutor.cpp | 284 +++++------ VolZmap.h | 22 +- VolZmapCalculus.cpp | 908 ++++++++++++++-------------------- VolZmapGraphics.cpp | 204 ++++++-- 7 files changed, 758 insertions(+), 768 deletions(-) diff --git a/EgtGeomKernel.rc b/EgtGeomKernel.rc index 74d7bb5ca9fe3f86e07962dfc32bc30e64e5854d..c57e3bf6cdd3eed68040a7f9705fd70d9ac554f1 100644 GIT binary patch delta 94 zcmdlNy)SyhFE&Qw&A-_cnHh~ID{|{@_Trkr0u;H;XNwSVW8B;$>;>dw2zN+>g;Df- LFmBFL4&ed-W11TR delta 94 zcmdlNy)SyhFE&P_&A-_cnHh~HD{|{@_Trkr0u;H;XNwSVW8B;$>;>dw2zN+>g;Df- LFmBFL4&ed-Vf-5U diff --git a/EgtGeomKernel.vcxproj b/EgtGeomKernel.vcxproj index cabd15e..1678055 100644 --- a/EgtGeomKernel.vcxproj +++ b/EgtGeomKernel.vcxproj @@ -411,6 +411,7 @@ copy $(TargetPath) \EgtProg\Dll64 + @@ -429,6 +430,8 @@ copy $(TargetPath) \EgtProg\Dll64 + + @@ -448,7 +451,7 @@ copy $(TargetPath) \EgtProg\Dll64 - + @@ -465,24 +468,40 @@ copy $(TargetPath) \EgtProg\Dll64 - + - - + + + + + + + + + + + + + + + + + + diff --git a/EgtGeomKernel.vcxproj.filters b/EgtGeomKernel.vcxproj.filters index d182915..f693099 100644 --- a/EgtGeomKernel.vcxproj.filters +++ b/EgtGeomKernel.vcxproj.filters @@ -644,9 +644,6 @@ File di intestazione\Include - - File di intestazione\Include - File di intestazione\Include @@ -665,18 +662,12 @@ File di intestazione\Include - - File di intestazione\Include - File di intestazione\Include File di intestazione\Include - - File di intestazione\Include - File di intestazione\Include @@ -722,9 +713,6 @@ File di intestazione - - File di intestazione\Include - File di intestazione\Include @@ -890,6 +878,75 @@ File di intestazione\Include + + File di intestazione\Include + + + File di intestazione\Include + + + File di intestazione\Include + + + File di intestazione\Include + + + File di intestazione\Include + + + File di intestazione\Include + + + File di intestazione\Include + + + File di intestazione\Include + + + File di intestazione\Include + + + File di intestazione\Include + + + File di intestazione\Include + + + File di intestazione\Include + + + File di intestazione\Include + + + File di intestazione\Include + + + File di intestazione\Include + + + File di intestazione\Include + + + File di intestazione\Include + + + File di intestazione\Include + + + File di intestazione\Include + + + File di intestazione\Include + + + File di intestazione\Include + + + File di intestazione\Include + + + File di intestazione\Include + diff --git a/GdbExecutor.cpp b/GdbExecutor.cpp index 523c73c..549bb5f 100644 --- a/GdbExecutor.cpp +++ b/GdbExecutor.cpp @@ -19,6 +19,8 @@ #include "GeoConst.h" #include "GeomDB.h" #include "DllMain.h" +#include "CurveLine.h" +#include "SurfTriMesh.h" #include "VolZmap.h" #include "IntersLineSurfStd.h" #include "CAvToolTriangle.h" @@ -27,7 +29,6 @@ #include "/EgtDev/Include/EGkGeoPoint3d.h" #include "/EgtDev/Include/EGkGeoVector3d.h" #include "/EgtDev/Include/EGkGeoFrame3d.h" -#include "/EgtDev/Include/EGkCurveLine.h" #include "/EgtDev/Include/EGkCurveAux.h" #include "/EgtDev/Include/EGkLinePntTgCurve.h" #include "/EgtDev/Include/EGkLineTgTwoCurves.h" @@ -44,7 +45,6 @@ #include "/EgtDev/Include/EGkChainCurves.h" #include "/EgtDev/Include/EGkBiArcs.h" #include "/EgtDev/Include/EGkCurveByInterp.h" -#include "/EgtDev/Include/EGkSurfTriMesh.h" #include "/EgtDev/Include/EGkExtText.h" #include "/EgtDev/Include/EGkStmFromCurves.h" #include "/EgtDev/Include/EGkStmFromTriangleSoup.h" @@ -3142,25 +3142,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( nothrow) CurveLine) ; + PtrOwner pLine( CreateBasicCurveLine()) ; 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( nothrow) CurveLine) ; + PtrOwner pLine( CreateBasicCurveLine()) ; 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( nothrow) CurveLine) ; + PtrOwner pLine( CreateBasicCurveLine()) ; 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( nothrow) CurveLine) ; + PtrOwner pLine( CreateBasicCurveLine()) ; pLine->Set( ptPS, ptPE) ; // inserisco nel DB return AddGeoObj( vsParams[0], vsParams[1], Release( pLine)) ; @@ -3212,25 +3212,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( nothrow) CurveLine) ; + PtrOwner pLine( CreateBasicCurveLine()) ; 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( nothrow) CurveLine) ; + PtrOwner pLine( CreateBasicCurveLine()) ; 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( nothrow) CurveLine) ; + PtrOwner pLine( CreateBasicCurveLine()) ; 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( nothrow) CurveLine) ; + PtrOwner pLine( CreateBasicCurveLine()) ; pLine->Set( ptPS, ptPE) ; // inserisco nel DB return AddGeoObj( vsParams[0], vsParams[1], Release( pLine)) ; @@ -3286,25 +3286,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( nothrow) CurveLine) ; + PtrOwner pLine( CreateBasicCurveLine()) ; 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( nothrow) CurveLine) ; + PtrOwner pLine( CreateBasicCurveLine()) ; 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( nothrow) CurveLine) ; + PtrOwner pLine( CreateBasicCurveLine()) ; 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( nothrow) CurveLine) ; + PtrOwner pLine( CreateBasicCurveLine()) ; pLine->Set( ptPS, ptPE) ; // inserisco nel DB return AddGeoObj( vsParams[0], vsParams[1], Release( pLine)) ; @@ -3351,13 +3351,13 @@ GdbExecutor::LineSphereInters( const STRVECTOR& vsParams) if ( nIntType == S_NO_INTERS) int nSol = 0 ; if ( nIntType == S_TWO_INT) { - PtrOwner pLine( new( nothrow) CurveLine) ; + PtrOwner pLine( CreateBasicCurveLine()) ; pLine->Set( ptPS, ptPE) ; // inserisco nel DB return AddGeoObj (vsParams[0], vsParams[1], Release( pLine)) ; } if ( nIntType == S_ONE_INT_TAN) { - PtrOwner pLine( new( nothrow) CurveLine) ; + PtrOwner pLine( CreateBasicCurveLine()) ; pLine->Set( ptPS - vtV, ptPS + vtV) ; // inserisco nel DB return AddGeoObj( vsParams[0], vsParams[1], Release( pLine)) ; @@ -3404,19 +3404,19 @@ GdbExecutor::RaySphereInters( const STRVECTOR& vsParams) if ( nIntType == S_NO_INTERS) int nSol = 0 ; if ( nIntType == S_TWO_INT) { - PtrOwner pLine( new( nothrow) CurveLine) ; + PtrOwner pLine( CreateBasicCurveLine()) ; pLine->Set( ptPS, ptPE) ; // inserisco nel DB return AddGeoObj (vsParams[0], vsParams[1], Release( pLine)) ; } if ( nIntType == S_ONE_INT_TAN) { - PtrOwner pLine( new( nothrow) CurveLine) ; + PtrOwner pLine( CreateBasicCurveLine()) ; 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( nothrow) CurveLine) ; + PtrOwner pLine( CreateBasicCurveLine()) ; pLine->Set( ptPS - 3 * vtV, ptPS + 3 * vtV) ; // inserisco nel DB return AddGeoObj( vsParams[0], vsParams[1], Release( pLine)) ; @@ -3468,21 +3468,21 @@ GdbExecutor::SegmentSphereInters( const STRVECTOR& vsParams) if ( nIntType == S_TWO_INT) { Point3d ptPS = ptP + dU1 * vtV ; Point3d ptPE = ptP + dU2 * vtV ; - PtrOwner pLine( new( nothrow) CurveLine) ; + PtrOwner pLine( CreateBasicCurveLine()) ; 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( nothrow) CurveLine) ; + PtrOwner pLine( CreateBasicCurveLine()) ; 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( nothrow) CurveLine) ; + PtrOwner pLine( CreateBasicCurveLine()) ; pLine->Set( ptPS - 3 * vtV, ptPS + 3 * vtV) ; // inserisco nel DB return AddGeoObj( vsParams[0], vsParams[1], Release( pLine)) ; @@ -3535,13 +3535,13 @@ GdbExecutor::LineSemiSphereInters( const STRVECTOR& vsParams) if ( nIntType == S_NO_INTERS) int nSol = 0 ; if ( nIntType == S_TWO_INT) { - PtrOwner pLine( new( nothrow) CurveLine) ; + PtrOwner pLine( CreateBasicCurveLine()) ; pLine->Set( ptPS, ptPE) ; // inserisco nel DB return AddGeoObj (vsParams[0], vsParams[1], Release( pLine)) ; } if ( nIntType == S_ONE_INT_TAN) { - PtrOwner pLine( new( nothrow) CurveLine) ; + PtrOwner pLine( CreateBasicCurveLine()) ; pLine->Set( ptPS - vtV, ptPS + vtV) ; // inserisco nel DB return AddGeoObj( vsParams[0], vsParams[1], Release( pLine)) ; @@ -3594,19 +3594,19 @@ GdbExecutor::RaySemiSphereInters( const STRVECTOR& vsParams) if ( nIntType == S_NO_INTERS) int nSol = 0 ; if ( nIntType == S_TWO_INT) { - PtrOwner pLine( new( nothrow) CurveLine) ; + PtrOwner pLine( CreateBasicCurveLine()) ; pLine->Set( ptPS, ptPE) ; // inserisco nel DB return AddGeoObj (vsParams[0], vsParams[1], Release( pLine)) ; } if ( nIntType == S_ONE_INT_SEC) { - PtrOwner pLine( new( nothrow) CurveLine) ; + PtrOwner pLine( CreateBasicCurveLine()) ; 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( nothrow) CurveLine) ; + PtrOwner pLine( CreateBasicCurveLine()) ; pLine->Set( ptPS - vtV, ptPS + vtV) ; // inserisco nel DB return AddGeoObj( vsParams[0], vsParams[1], Release( pLine)) ; @@ -3663,21 +3663,21 @@ GdbExecutor::SegmentSemiSphereInters( const STRVECTOR& vsParams) if ( nIntType == S_TWO_INT) { Point3d ptPS = ptP + dU1 * vtV ; Point3d ptPE = ptP + dU2 * vtV ; - PtrOwner pLine( new( nothrow) CurveLine) ; + PtrOwner pLine( CreateBasicCurveLine()) ; 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( nothrow) CurveLine) ; + PtrOwner pLine( CreateBasicCurveLine()) ; 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( nothrow) CurveLine) ; + PtrOwner pLine( CreateBasicCurveLine()) ; pLine->Set( ptPS - 3 * vtV, ptPS + 3 * vtV) ; // inserisco nel DB return AddGeoObj( vsParams[0], vsParams[1], Release( pLine)) ; @@ -3736,21 +3736,21 @@ GdbExecutor::LinCompSemiSphereInters( const STRVECTOR& vsParams) if ( nIntType == S_TWO_INT) { Point3d ptPS = ptP + dU1 * vtV ; Point3d ptPE = ptP + dU2 * vtV ; - PtrOwner pLine( new( nothrow) CurveLine) ; + PtrOwner pLine( CreateBasicCurveLine()) ; 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( nothrow) CurveLine) ; + PtrOwner pLine( CreateBasicCurveLine()) ; 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( nothrow) CurveLine) ; + PtrOwner pLine( CreateBasicCurveLine()) ; pLine->Set( ptPS - 3 * vtV, ptPS + 3 * vtV) ; // inserisco nel DB return AddGeoObj( vsParams[0], vsParams[1], Release( pLine)) ; @@ -3803,25 +3803,25 @@ GdbExecutor::LineInfiniteCylinderInters( const STRVECTOR& vsParams) if ( nTypeInt == CC_NO_INTERS) int nSol = 0 ; if ( nTypeInt == CC_ONE_INT_SEC) { - PtrOwner pLine( new( nothrow) CurveLine) ; + PtrOwner pLine( CreateBasicCurveLine()) ; 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( nothrow) CurveLine) ; + PtrOwner pLine( CreateBasicCurveLine()) ; 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( nothrow) CurveLine) ; + PtrOwner pLine( CreateBasicCurveLine()) ; pLine->Set( ptPS, ptPE) ; // inserisco nel DB return AddGeoObj( vsParams[0], vsParams[1], Release( pLine)) ; } if ( nTypeInt == CC_INF_INT) { - PtrOwner pLine( new( nothrow) CurveLine) ; + PtrOwner pLine( CreateBasicCurveLine()) ; pLine->Set( ptPS, ptPE) ; // inserisco nel DB return AddGeoObj( vsParams[0], vsParams[1], Release( pLine)) ; @@ -3874,25 +3874,25 @@ GdbExecutor::RayInfiniteCylinderInters( const STRVECTOR& vsParams) if ( nTypeInt == CC_NO_INTERS) int nSol = 0 ; if ( nTypeInt == CC_ONE_INT_SEC) { - PtrOwner pLine( new( nothrow) CurveLine) ; + PtrOwner pLine( CreateBasicCurveLine()) ; 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( nothrow) CurveLine) ; + PtrOwner pLine( CreateBasicCurveLine()) ; 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( nothrow) CurveLine) ; + PtrOwner pLine( CreateBasicCurveLine()) ; pLine->Set( ptPS, ptPE) ; // inserisco nel DB return AddGeoObj( vsParams[0], vsParams[1], Release( pLine)) ; } if ( nTypeInt == CC_INF_INT) { - PtrOwner pLine( new( nothrow) CurveLine) ; + PtrOwner pLine( CreateBasicCurveLine()) ; pLine->Set( ptPS, ptPE) ; // inserisco nel DB return AddGeoObj( vsParams[0], vsParams[1], Release( pLine)) ; @@ -3948,25 +3948,25 @@ GdbExecutor::SegmentInfiniteCylinderInters( const STRVECTOR& vsParams) if ( nTypeInt == CC_NO_INTERS) int nSol = 0 ; if ( nTypeInt == CC_ONE_INT_SEC) { - PtrOwner pLine( new( nothrow) CurveLine) ; + PtrOwner pLine( CreateBasicCurveLine()) ; 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( nothrow) CurveLine) ; + PtrOwner pLine( CreateBasicCurveLine()) ; 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( nothrow) CurveLine) ; + PtrOwner pLine( CreateBasicCurveLine()) ; pLine->Set( ptPS, ptPE) ; // inserisco nel DB return AddGeoObj( vsParams[0], vsParams[1], Release( pLine)) ; } if ( nTypeInt == CC_INF_INT) { - PtrOwner pLine( new( nothrow) CurveLine) ; + PtrOwner pLine( CreateBasicCurveLine()) ; pLine->Set( ptPS, ptPE) ; // inserisco nel DB return AddGeoObj( vsParams[0], vsParams[1], Release( pLine)) ; @@ -4026,25 +4026,25 @@ GdbExecutor::SegmentCylinderInters( const STRVECTOR& vsParams) if ( nTypeInt == CC_NO_INTERS) int nSol = 0 ; if ( nTypeInt == CC_ONE_INT_SEC) { - PtrOwner pLine( new( nothrow) CurveLine) ; + PtrOwner pLine( CreateBasicCurveLine()) ; 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( nothrow) CurveLine) ; + PtrOwner pLine( CreateBasicCurveLine()) ; 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( nothrow) CurveLine) ; + PtrOwner pLine( CreateBasicCurveLine()) ; pLine->Set( ptPS, ptPE) ; // inserisco nel DB return AddGeoObj( vsParams[0], vsParams[1], Release( pLine)) ; } if ( nTypeInt == CC_INF_INT) { - PtrOwner pLine( new( nothrow) CurveLine) ; + PtrOwner pLine( CreateBasicCurveLine()) ; pLine->Set( ptPS, ptPE) ; // inserisco nel DB return AddGeoObj( vsParams[0], vsParams[1], Release( pLine)) ; @@ -4104,31 +4104,31 @@ GdbExecutor::SegmentConeInters( const STRVECTOR& vsParams) if ( nTypeInt == CC_NO_INTERS) int nSol = 0 ; if ( nTypeInt == CC_ONE_INT_SEC) { - PtrOwner pLine( new( nothrow) CurveLine) ; + PtrOwner pLine( CreateBasicCurveLine()) ; 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( nothrow) CurveLine) ; + PtrOwner pLine( CreateBasicCurveLine()) ; 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( nothrow) CurveLine) ; + PtrOwner pLine( CreateBasicCurveLine()) ; pLine->Set( ptPS, ptPE) ; // inserisco nel DB return AddGeoObj( vsParams[0], vsParams[1], Release( pLine)) ; } if ( nTypeInt == CC_INF_INT) { - PtrOwner pLine( new( nothrow) CurveLine) ; + PtrOwner pLine( CreateBasicCurveLine()) ; pLine->Set( ptPS, ptPE) ; // inserisco nel DB return AddGeoObj( vsParams[0], vsParams[1], Release( pLine)) ; } if ( nTypeInt == CC_ON_VERT) { - PtrOwner pLine( new( nothrow) CurveLine) ; + PtrOwner pLine( CreateBasicCurveLine()) ; pLine->Set( ptPS - 6 * vtLine, ptPS + 6 * vtLine) ; // inserisco nel DB return AddGeoObj( vsParams[0], vsParams[1], Release( pLine)) ; @@ -4187,31 +4187,31 @@ GdbExecutor::LineTruncateConeInters( const STRVECTOR& vsParams) if ( nTypeInt == CC_NO_INTERS) int nSol = 0 ; if ( nTypeInt == CC_ONE_INT_SEC) { - PtrOwner pLine( new( nothrow) CurveLine) ; + PtrOwner pLine( CreateBasicCurveLine()) ; 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( nothrow) CurveLine) ; + PtrOwner pLine( CreateBasicCurveLine()) ; 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( nothrow) CurveLine) ; + PtrOwner pLine( CreateBasicCurveLine()) ; pLine->Set( ptPS, ptPE) ; // inserisco nel DB return AddGeoObj( vsParams[0], vsParams[1], Release( pLine)) ; } if ( nTypeInt == CC_INF_INT) { - PtrOwner pLine( new( nothrow) CurveLine) ; + PtrOwner pLine( CreateBasicCurveLine()) ; pLine->Set( ptPS, ptPE) ; // inserisco nel DB return AddGeoObj( vsParams[0], vsParams[1], Release( pLine)) ; } if ( nTypeInt == CC_ON_VERT) { - PtrOwner pLine( new( nothrow) CurveLine) ; + PtrOwner pLine( CreateBasicCurveLine()) ; pLine->Set( ptPS - 6 * vtLine, ptPS + 6 * vtLine) ; // inserisco nel DB return AddGeoObj( vsParams[0], vsParams[1], Release( pLine)) ; @@ -4271,31 +4271,31 @@ GdbExecutor::RayTruncateConeInters( const STRVECTOR& vsParams) if ( nTypeInt == CC_NO_INTERS) int nSol = 0 ; if ( nTypeInt == CC_ONE_INT_SEC) { - PtrOwner pLine( new( nothrow) CurveLine) ; + PtrOwner pLine( CreateBasicCurveLine()) ; 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( nothrow) CurveLine) ; + PtrOwner pLine( CreateBasicCurveLine()) ; 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( nothrow) CurveLine) ; + PtrOwner pLine( CreateBasicCurveLine()) ; pLine->Set( ptPS, ptPE) ; // inserisco nel DB return AddGeoObj( vsParams[0], vsParams[1], Release( pLine)) ; } if ( nTypeInt == CC_INF_INT) { - PtrOwner pLine( new( nothrow) CurveLine) ; + PtrOwner pLine( CreateBasicCurveLine()) ; pLine->Set( ptPS, ptPE) ; // inserisco nel DB return AddGeoObj( vsParams[0], vsParams[1], Release( pLine)) ; } if ( nTypeInt == CC_ON_VERT) { - PtrOwner pLine( new( nothrow) CurveLine) ; + PtrOwner pLine( CreateBasicCurveLine()) ; pLine->Set( ptPS - 6 * vtLine, ptPS + 6 * vtLine) ; // inserisco nel DB return AddGeoObj( vsParams[0], vsParams[1], Release( pLine)) ; @@ -4358,31 +4358,31 @@ GdbExecutor::SegmentTruncateConeInters( const STRVECTOR& vsParams) if ( nTypeInt == CC_NO_INTERS) int nSol = 0 ; if ( nTypeInt == CC_ONE_INT_SEC) { - PtrOwner pLine( new( nothrow) CurveLine) ; + PtrOwner pLine( CreateBasicCurveLine()) ; 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( nothrow) CurveLine) ; + PtrOwner pLine( CreateBasicCurveLine()) ; 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( nothrow) CurveLine) ; + PtrOwner pLine( CreateBasicCurveLine()) ; pLine->Set( ptPS, ptPE) ; // inserisco nel DB return AddGeoObj( vsParams[0], vsParams[1], Release( pLine)) ; } if ( nTypeInt == CC_INF_INT) { - PtrOwner pLine( new( nothrow) CurveLine) ; + PtrOwner pLine( CreateBasicCurveLine()) ; pLine->Set( ptPS, ptPE) ; // inserisco nel DB return AddGeoObj( vsParams[0], vsParams[1], Release( pLine)) ; } if ( nTypeInt == CC_ON_VERT) { - PtrOwner pLine( new( nothrow) CurveLine) ; + PtrOwner pLine( CreateBasicCurveLine()) ; pLine->Set( ptPS - 6 * vtLine, ptPS + 6 * vtLine) ; // inserisco nel DB return AddGeoObj( vsParams[0], vsParams[1], Release( pLine)) ; @@ -4437,7 +4437,7 @@ GdbExecutor::LineTorusInters( const STRVECTOR& vsParams) int nSol = 0 ; if ( nTypeInt == T_ONE_TAN) { Point3d ptInt = ptLine + vdP[0] * vtLine ; - PtrOwner pLine( new( nothrow) CurveLine) ; + PtrOwner pLine( CreateBasicCurveLine()) ; pLine->Set( ptInt - vtLine, ptInt + vtLine) ; // inserisco nel DB return AddGeoObj( vsParams[0], vsParams[1], Release( pLine)) ; @@ -4445,8 +4445,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( nothrow) CurveLine) ; - PtrOwner pLine1( new( nothrow) CurveLine) ; + PtrOwner pLine0( CreateBasicCurveLine()) ; + PtrOwner pLine1( CreateBasicCurveLine()) ; pLine0->Set( ptInt0 - vtLine, ptInt0 + vtLine) ; pLine1->Set( ptInt1 - vtLine, ptInt1 + vtLine) ; // inserisco nel DB @@ -4456,7 +4456,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( nothrow) CurveLine) ; + PtrOwner pLine( CreateBasicCurveLine()) ; pLine->Set( ptInt0, ptInt1) ; // inserisco nel DB return AddGeoObj( vsParams[0], vsParams[1], Release( pLine)) ; @@ -4466,24 +4466,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( nothrow) CurveLine) ; + PtrOwner pLine0( CreateBasicCurveLine()) ; pLine0->Set( ptInt0, ptInt1) ; - PtrOwner pLine1( new( nothrow) CurveLine) ; + PtrOwner pLine1( CreateBasicCurveLine()) ; 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( nothrow) CurveLine) ; + PtrOwner pLine( CreateBasicCurveLine()) ; 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( nothrow) CurveLine) ; + PtrOwner pLine0( CreateBasicCurveLine()) ; pLine0->Set( ptInt0 - vtLine, ptInt0 + vtLine) ; - PtrOwner pLine1( new( nothrow) CurveLine) ; + PtrOwner pLine1( CreateBasicCurveLine()) ; pLine1->Set( ptInt1, ptInt2) ; // inserisco nel DB return ( AddGeoObj( vsParams[0], vsParams[1], Release( pLine0)) && @@ -4495,9 +4495,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( nothrow) CurveLine) ; + PtrOwner pLine0( CreateBasicCurveLine()) ; pLine0->Set( ptInt0, ptInt1) ; - PtrOwner pLine1( new( nothrow) CurveLine) ; + PtrOwner pLine1( CreateBasicCurveLine()) ; pLine1->Set( ptInt2, ptInt3) ; // inserisco nel DB return ( AddGeoObj( vsParams[0], vsParams[1], Release( pLine0)) && @@ -4554,14 +4554,14 @@ GdbExecutor::RayTorusInters( const STRVECTOR& vsParams) int nSol = 0 ; if ( nTypeInt == T_ONE_TAN) { Point3d ptInt = ptLine + vdP[0] * vtLine ; - PtrOwner pLine( new( nothrow) CurveLine) ; + PtrOwner pLine( CreateBasicCurveLine()) ; 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( nothrow) CurveLine) ; + PtrOwner pLine( CreateBasicCurveLine()) ; pLine->Set( ptInt - 4 * vtLine, ptInt + 4 * vtLine) ; // inserisco nel DB return AddGeoObj( vsParams[0], vsParams[1], Release( pLine)) ; @@ -4569,8 +4569,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( nothrow) CurveLine) ; - PtrOwner pLine1( new( nothrow) CurveLine) ; + PtrOwner pLine0( CreateBasicCurveLine()) ; + PtrOwner pLine1( CreateBasicCurveLine()) ; pLine0->Set( ptInt0 - vtLine, ptInt0 + vtLine) ; pLine1->Set( ptInt1 - vtLine, ptInt1 + vtLine) ; // inserisco nel DB @@ -4580,7 +4580,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( nothrow) CurveLine) ; + PtrOwner pLine( CreateBasicCurveLine()) ; pLine->Set( ptInt0, ptInt1) ; // inserisco nel DB return AddGeoObj( vsParams[0], vsParams[1], Release( pLine)) ; @@ -4590,9 +4590,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( nothrow) CurveLine) ; + PtrOwner pLine0( CreateBasicCurveLine()) ; pLine0->Set( ptInt0 - dDil0 * vtLine, ptInt0 + dDil0 * vtLine) ; - PtrOwner pLine1( new( nothrow) CurveLine) ; + PtrOwner pLine1( CreateBasicCurveLine()) ; pLine1->Set( ptInt1 - dDil1 * vtLine, ptInt1 + dDil1 * vtLine) ; // inserisco nel DB return ( AddGeoObj( vsParams[0], vsParams[1], Release( pLine0)) && @@ -4602,11 +4602,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( nothrow) CurveLine) ; + PtrOwner pLine0( CreateBasicCurveLine()) ; pLine0->Set( ptInt0 - 4 * vtLine, ptInt0 + 4 * vtLine) ; - PtrOwner pLine1( new( nothrow) CurveLine) ; + PtrOwner pLine1( CreateBasicCurveLine()) ; pLine1->Set( ptInt1 - 4 * vtLine, ptInt1 + 4 * vtLine) ; - PtrOwner pLine2( new( nothrow) CurveLine) ; + PtrOwner pLine2( CreateBasicCurveLine()) ; pLine2->Set( ptInt2 - 4 * vtLine, ptInt2 + 4 * vtLine) ; // inserisco nel DB return ( AddGeoObj( vsParams[0], vsParams[1], Release( pLine0)) && @@ -4618,24 +4618,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( nothrow) CurveLine) ; + PtrOwner pLine0( CreateBasicCurveLine()) ; pLine0->Set( ptInt0, ptInt1) ; - PtrOwner pLine1( new( nothrow) CurveLine) ; + PtrOwner pLine1( CreateBasicCurveLine()) ; 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( nothrow) CurveLine) ; + PtrOwner pLine( CreateBasicCurveLine()) ; 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( nothrow) CurveLine) ; + PtrOwner pLine0( CreateBasicCurveLine()) ; pLine0->Set( ptInt0 - vtLine, ptInt0 + vtLine) ; - PtrOwner pLine1( new( nothrow) CurveLine) ; + PtrOwner pLine1( CreateBasicCurveLine()) ; pLine1->Set( ptInt1, ptInt2) ; // inserisco nel DB return ( AddGeoObj( vsParams[0], vsParams[1], Release( pLine0)) && @@ -4647,9 +4647,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( nothrow) CurveLine) ; + PtrOwner pLine0( CreateBasicCurveLine()) ; pLine0->Set( ptInt0, ptInt1) ; - PtrOwner pLine1( new( nothrow) CurveLine) ; + PtrOwner pLine1( CreateBasicCurveLine()) ; pLine1->Set( ptInt2, ptInt3) ; // inserisco nel DB return ( AddGeoObj( vsParams[0], vsParams[1], Release( pLine0)) && @@ -4710,14 +4710,14 @@ GdbExecutor::SegmentTorusInters( const STRVECTOR& vsParams) int nSol = 0 ; if ( nTypeInt == T_ONE_TAN) { Point3d ptInt = ptLine + vdP[0] * vtLine ; - PtrOwner pLine( new( nothrow) CurveLine) ; + PtrOwner pLine( CreateBasicCurveLine()) ; 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( nothrow) CurveLine) ; + PtrOwner pLine( CreateBasicCurveLine()) ; pLine->Set( ptInt - 4 * vtLine, ptInt + 4 * vtLine) ; // inserisco nel DB return AddGeoObj( vsParams[0], vsParams[1], Release( pLine)) ; @@ -4725,8 +4725,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( nothrow) CurveLine) ; - PtrOwner pLine1( new( nothrow) CurveLine) ; + PtrOwner pLine0( CreateBasicCurveLine()) ; + PtrOwner pLine1( CreateBasicCurveLine()) ; pLine0->Set( ptInt0 - vtLine, ptInt0 + vtLine) ; pLine1->Set( ptInt1 - vtLine, ptInt1 + vtLine) ; // inserisco nel DB @@ -4736,8 +4736,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( nothrow) CurveLine) ; - PtrOwner pLine1( new( nothrow) CurveLine) ; + PtrOwner pLine0( CreateBasicCurveLine()) ; + PtrOwner pLine1( CreateBasicCurveLine()) ; pLine0->Set( ptInt0 - 4 * vtLine, ptInt0 + 4 * vtLine) ; pLine1->Set( ptInt1 - 4 * vtLine, ptInt1 + 4 * vtLine) ; // inserisco nel DB @@ -4749,9 +4749,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( nothrow) CurveLine) ; + PtrOwner pLine0( CreateBasicCurveLine()) ; pLine0->Set( ptInt0 - dDil0 * vtLine, ptInt0 + dDil0 * vtLine) ; - PtrOwner pLine1( new( nothrow) CurveLine) ; + PtrOwner pLine1( CreateBasicCurveLine()) ; pLine1->Set( ptInt1 - dDil1 * vtLine, ptInt1 + dDil1 * vtLine) ; // inserisco nel DB return ( AddGeoObj( vsParams[0], vsParams[1], Release( pLine0)) && @@ -4761,11 +4761,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( nothrow) CurveLine) ; + PtrOwner pLine0( CreateBasicCurveLine()) ; pLine0->Set( ptInt0 - 4 * vtLine, ptInt0 + 4 * vtLine) ; - PtrOwner pLine1( new( nothrow) CurveLine) ; + PtrOwner pLine1( CreateBasicCurveLine()) ; pLine1->Set( ptInt1 - 4 * vtLine, ptInt1 + 4 * vtLine) ; - PtrOwner pLine2( new( nothrow) CurveLine) ; + PtrOwner pLine2( CreateBasicCurveLine()) ; pLine2->Set( ptInt2 - 4 * vtLine, ptInt2 + 4 * vtLine) ; // inserisco nel DB return ( AddGeoObj( vsParams[0], vsParams[1], Release( pLine0)) && @@ -4777,11 +4777,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( nothrow) CurveLine) ; + PtrOwner pLine0( CreateBasicCurveLine()) ; pLine0->Set( ptInt0 - 4 * vtLine, ptInt0 + 4 * vtLine) ; - PtrOwner pLine1( new( nothrow) CurveLine) ; + PtrOwner pLine1( CreateBasicCurveLine()) ; pLine1->Set( ptInt1 - 4 * vtLine, ptInt1 + 4 * vtLine) ; - PtrOwner pLine2( new( nothrow) CurveLine) ; + PtrOwner pLine2( CreateBasicCurveLine()) ; pLine2->Set( ptInt2 - vtLine, ptInt2 + vtLine) ; // inserisco nel DB return ( AddGeoObj( vsParams[0], vsParams[1], Release( pLine0)) && @@ -4789,11 +4789,11 @@ GdbExecutor::SegmentTorusInters( const STRVECTOR& vsParams) AddGeoObj( "$NN", vsParams[1], Release( pLine2))) ; } else if ( vbT[0] && ( ! vbT[1]) && vbT[2]) { - PtrOwner pLine0( new( nothrow) CurveLine) ; + PtrOwner pLine0( CreateBasicCurveLine()) ; pLine0->Set( ptInt0 - 4 * vtLine, ptInt0 + 4 * vtLine) ; - PtrOwner pLine1( new( nothrow) CurveLine) ; + PtrOwner pLine1( CreateBasicCurveLine()) ; pLine1->Set( ptInt1 - vtLine, ptInt1 + vtLine) ; - PtrOwner pLine2( new( nothrow) CurveLine) ; + PtrOwner pLine2( CreateBasicCurveLine()) ; pLine2->Set( ptInt2 - 4 * vtLine, ptInt2 + 4 * vtLine) ; // inserisco nel DB return ( AddGeoObj( vsParams[0], vsParams[1], Release( pLine0)) && @@ -4801,11 +4801,11 @@ GdbExecutor::SegmentTorusInters( const STRVECTOR& vsParams) AddGeoObj( "$NN", vsParams[1], Release( pLine2))) ; } else if ( ( ! vbT[0]) && vbT[1] && vbT[2]) { - PtrOwner pLine0( new( nothrow) CurveLine) ; + PtrOwner pLine0( CreateBasicCurveLine()) ; pLine0->Set( ptInt0 - vtLine, ptInt0 + vtLine) ; - PtrOwner pLine1( new( nothrow) CurveLine) ; + PtrOwner pLine1( CreateBasicCurveLine()) ; pLine1->Set( ptInt1 - 4 * vtLine, ptInt1 + 4 * vtLine) ; - PtrOwner pLine2( new( nothrow) CurveLine) ; + PtrOwner pLine2( CreateBasicCurveLine()) ; pLine2->Set( ptInt2 - 4 * vtLine, ptInt2 + 4 * vtLine) ; // inserisco nel DB return ( AddGeoObj( vsParams[0], vsParams[1], Release( pLine0)) && @@ -4818,9 +4818,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( nothrow) CurveLine) ; + PtrOwner pLine0( CreateBasicCurveLine()) ; pLine0->Set( ptInt0, ptInt1) ; - PtrOwner pLine1( new( nothrow) CurveLine) ; + PtrOwner pLine1( CreateBasicCurveLine()) ; pLine1->Set( ptInt2, ptInt3) ; // inserisco nel DB return ( AddGeoObj( vsParams[0], vsParams[1], Release( pLine0)) && @@ -4884,14 +4884,14 @@ GdbExecutor::LinCompTorusPartInters( const STRVECTOR& vsParams) int nSol = 0 ; if ( nTypeInt == T_ONE_TAN) { Point3d ptInt = ptLine + vdP[0] * vtLine ; - PtrOwner pLine( new( nothrow) CurveLine) ; + PtrOwner pLine( CreateBasicCurveLine()) ; 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( nothrow) CurveLine) ; + PtrOwner pLine( CreateBasicCurveLine()) ; pLine->Set( ptInt - 4 * vtLine, ptInt + 4 * vtLine) ; // inserisco nel DB return AddGeoObj( vsParams[0], vsParams[1], Release( pLine)) ; @@ -4899,8 +4899,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( nothrow) CurveLine) ; - PtrOwner pLine1( new( nothrow) CurveLine) ; + PtrOwner pLine0( CreateBasicCurveLine()) ; + PtrOwner pLine1( CreateBasicCurveLine()) ; pLine0->Set( ptInt0 - vtLine, ptInt0 + vtLine) ; pLine1->Set( ptInt1 - vtLine, ptInt1 + vtLine) ; // inserisco nel DB @@ -4910,8 +4910,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( nothrow) CurveLine) ; - PtrOwner pLine1( new( nothrow) CurveLine) ; + PtrOwner pLine0( CreateBasicCurveLine()) ; + PtrOwner pLine1( CreateBasicCurveLine()) ; pLine0->Set( ptInt0 - 4 * vtLine, ptInt0 + 4 * vtLine) ; pLine1->Set( ptInt1 - 4 * vtLine, ptInt1 + 4 * vtLine) ; // inserisco nel DB @@ -4923,9 +4923,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( nothrow) CurveLine) ; + PtrOwner pLine0( CreateBasicCurveLine()) ; pLine0->Set( ptInt0 - dDil0 * vtLine, ptInt0 + dDil0 * vtLine) ; - PtrOwner pLine1( new( nothrow) CurveLine) ; + PtrOwner pLine1( CreateBasicCurveLine()) ; pLine1->Set( ptInt1 - dDil1 * vtLine, ptInt1 + dDil1 * vtLine) ; // inserisco nel DB return ( AddGeoObj( vsParams[0], vsParams[1], Release( pLine0)) && @@ -4935,11 +4935,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( nothrow) CurveLine) ; + PtrOwner pLine0( CreateBasicCurveLine()) ; pLine0->Set( ptInt0 - 4 * vtLine, ptInt0 + 4 * vtLine) ; - PtrOwner pLine1( new( nothrow) CurveLine) ; + PtrOwner pLine1( CreateBasicCurveLine()) ; pLine1->Set( ptInt1 - 4 * vtLine, ptInt1 + 4 * vtLine) ; - PtrOwner pLine2( new( nothrow) CurveLine) ; + PtrOwner pLine2( CreateBasicCurveLine()) ; pLine2->Set( ptInt2 - 4 * vtLine, ptInt2 + 4 * vtLine) ; // inserisco nel DB return ( AddGeoObj( vsParams[0], vsParams[1], Release( pLine0)) && @@ -4951,11 +4951,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( nothrow) CurveLine) ; + PtrOwner pLine0( CreateBasicCurveLine()) ; pLine0->Set( ptInt0 - 4 * vtLine, ptInt0 + 4 * vtLine) ; - PtrOwner pLine1( new( nothrow) CurveLine) ; + PtrOwner pLine1( CreateBasicCurveLine()) ; pLine1->Set( ptInt1 - 4 * vtLine, ptInt1 + 4 * vtLine) ; - PtrOwner pLine2( new( nothrow) CurveLine) ; + PtrOwner pLine2( CreateBasicCurveLine()) ; pLine2->Set( ptInt2 - vtLine, ptInt2 + vtLine) ; // inserisco nel DB return ( AddGeoObj( vsParams[0], vsParams[1], Release( pLine0)) && @@ -4963,11 +4963,11 @@ GdbExecutor::LinCompTorusPartInters( const STRVECTOR& vsParams) AddGeoObj( "$NN", vsParams[1], Release( pLine2))) ; } else if ( vbT[0] && ( ! vbT[1]) && vbT[2]) { - PtrOwner pLine0( new( nothrow) CurveLine) ; + PtrOwner pLine0( CreateBasicCurveLine()) ; pLine0->Set( ptInt0 - 4 * vtLine, ptInt0 + 4 * vtLine) ; - PtrOwner pLine1( new( nothrow) CurveLine) ; + PtrOwner pLine1( CreateBasicCurveLine()) ; pLine1->Set( ptInt1 - vtLine, ptInt1 + vtLine) ; - PtrOwner pLine2( new( nothrow) CurveLine) ; + PtrOwner pLine2( CreateBasicCurveLine()) ; pLine2->Set( ptInt2 - 4 * vtLine, ptInt2 + 4 * vtLine) ; // inserisco nel DB return ( AddGeoObj( vsParams[0], vsParams[1], Release( pLine0)) && @@ -4975,11 +4975,11 @@ GdbExecutor::LinCompTorusPartInters( const STRVECTOR& vsParams) AddGeoObj( "$NN", vsParams[1], Release( pLine2))) ; } else if ( ( ! vbT[0]) && vbT[1] && vbT[2]) { - PtrOwner pLine0( new( nothrow) CurveLine) ; + PtrOwner pLine0( CreateBasicCurveLine()) ; pLine0->Set( ptInt0 - vtLine, ptInt0 + vtLine) ; - PtrOwner pLine1( new( nothrow) CurveLine) ; + PtrOwner pLine1( CreateBasicCurveLine()) ; pLine1->Set( ptInt1 - 4 * vtLine, ptInt1 + 4 * vtLine) ; - PtrOwner pLine2( new( nothrow) CurveLine) ; + PtrOwner pLine2( CreateBasicCurveLine()) ; pLine2->Set( ptInt2 - 4 * vtLine, ptInt2 + 4 * vtLine) ; // inserisco nel DB return ( AddGeoObj( vsParams[0], vsParams[1], Release( pLine0)) && @@ -4992,9 +4992,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( nothrow) CurveLine) ; + PtrOwner pLine0( CreateBasicCurveLine()) ; pLine0->Set( ptInt0, ptInt1) ; - PtrOwner pLine1( new( nothrow) CurveLine) ; + PtrOwner pLine1( CreateBasicCurveLine()) ; pLine1->Set( ptInt2, ptInt3) ; // inserisco nel DB return ( AddGeoObj( vsParams[0], vsParams[1], Release( pLine0)) && @@ -5084,7 +5084,7 @@ GdbExecutor::ExecuteDistPointTrimesh( const std::string& sCmd2, const STRVECTOR& if ( DistPointSurf.GetMinDistPoint( ptMinDistPoint) ) { - PtrOwner pLine( new( nothrow) CurveLine) ; + PtrOwner pLine( CreateBasicCurveLine()) ; pLine->Set( ptP, ptMinDistPoint) ; Vector3d vtDir = ptP - ptMinDistPoint ; diff --git a/VolZmap.h b/VolZmap.h index ae51260..ae5c7cf 100644 --- a/VolZmap.h +++ b/VolZmap.h @@ -1,7 +1,7 @@ //---------------------------------------------------------------------------- // EgalTech 2015-2019 //---------------------------------------------------------------------------- -// File : VolZmap.h Data : 07.03.19 Versione : 2.1c2 +// File : VolZmap.h Data : 12.05.19 Versione : 2.1e3 // Contenuto : Dichiarazione della classe Volume Zmap. // // @@ -15,15 +15,8 @@ #include "ObjGraphicsMgr.h" #include "GeoObjRW.h" -#include "CurveComposite.h" -#include "SurfFlatRegion.h" -#include "CurveLine.h" #include "Tool.h" #include "/EgtDev/Include/EGkVolZmap.h" -#include "/EgtDev/Include/EGkPoint3d.h" -#include "/EgtDev/Include/EGkVector3d.h" -#include "/EgtDev/Include/ENkPolynomialRoots.h" -#include "/EgtDev/Include/EgkIntersLinesurfTm.h" #include #include @@ -97,8 +90,7 @@ class VolZmap : public IVolZmap, public IGeoObjRW bool MillingStep( const Point3d& ptPs, const Vector3d& vtDs, const Vector3d& vtAs, const Point3d& ptPe, const Vector3d& vtDe, const Vector3d& vtAe) override ; bool GetDepth( const Point3d& ptP, const Vector3d& vtD, double& dInLength, double& dOutLength, bool bExact) const override ; - bool GetDepthWithDexel( const Point3d& ptP, const Vector3d& vtDir, double& dInLength, double& dOutLength) const ; - bool GetDepthWithVoxel( const Point3d& ptP, const Vector3d& vtDir, double& dInLength, double& dOutLength, bool bEnh) const ; + bool GetLineIntersection( const Point3d& ptP, const Vector3d& vtD, ILZIVECTOR& vIntersInfo) const override ; bool GetPlaneIntersection( const Plane3d& plPlane, ICURVEPOVECTOR& vpLoop) const override ; bool AvoidBox( const Frame3d& frBox, const Vector3d& vtDiag, double dSafeDist) const override ; bool AvoidSphere( const Point3d& ptCenter, double dRad, double dSafeDist) const override ; @@ -108,7 +100,6 @@ class VolZmap : public IVolZmap, public IGeoObjRW bool Cut( const Plane3d& plPlane) override ; bool Compact( void) override ; - public : // IGeoObjRW int GetNgeId( void) const override ; bool Save( NgeWriter& ngeOut) const override ; @@ -188,7 +179,6 @@ class VolZmap : public IVolZmap, public IGeoObjRW bool CalcDexelPrisms( int nPos1, int nPos2, int nBlock) const ; bool AddDexelSideFace( int nPos, int nPosAdj, const Point3d& ptP, const Point3d& ptQ, const Vector3d& vtZ, const Vector3d& vtNorm, int nBlock) const ; - bool ProcessCell( int nGrid, int nCellI, int nCellJ, const Plane3d& plPlane, std::vector& vLine) const ; bool UpdateSingleMapGraphics( void) const ; bool UpdateTripleMapGraphics( void) const ; bool ExtMarchingCubes( int nBlock, VoxelContainer& vVox) const ; @@ -198,13 +188,10 @@ class VolZmap : public IVolZmap, public IGeoObjRW bool FlipEdgesII( int nBlock) const ; bool FlipEdgesBB() const ; bool IsThereMat( int nI, int nJ, int nK) const ; - bool InOut( const Plane3d& plPlane, int nGrid, int nI, int nJ) const ; int CalcIndex( int nI, int nJ, int nK) const ; - int CalcIndexForPlaneCells( const Plane3d& plPlane, int nGrid, int nCellI, int nCellJ) const ; bool IntersPos( int nVec1[], int nVec2[], bool bFirstCorner, AppliedVector& vfField) const ; bool IsPointInsideVoxelApprox( int nI, int nJ, int nK, const Point3d& ptP, double dPrec = EPS_SMALL) const ; bool GetPointVoxel( const Point3d& ptP, int& nVoxI, int& nVoxJ, int& nVoxK) const ; - bool IsZInsideInterval( int nGrid, int nDex, double dZ) const ; // Per regolarizzazione della catena di feature bool FindAdjComp( const std::vector& vVecVox, int nCurBlock, int nCurVox, int nCurComp, INTVECTOR& vAdjBlockVoxComp, INTVECTOR& vAdjBordBlockVoxComp) const ; @@ -299,6 +286,8 @@ class VolZmap : public IVolZmap, public IGeoObjRW double& dU1, double& dU2) const ; bool IntersRayDexel( const Point3d& ptP, const Vector3d& vtV, int nGrid, int nI, int nJ, double& dU1, double& dU2) const ; + bool GetDepthWithDexel( const Point3d& ptP, const Vector3d& vtDir, double& dInLength, double& dOutLength) const ; + bool GetDepthWithVoxel( const Point3d& ptP, const Vector3d& vtDir, double& dInLength, double& dOutLength) const ; bool IntersLineCylinder( const Point3d& ptLineSt, const Vector3d& vtLineDir, const Frame3d& CylFrame, double dH, double dRad, bool bTapLow, bool bTapUp, Point3d& ptInt1, Vector3d& vtN1, Point3d& ptInt2, Vector3d& vtN2) const ; @@ -318,11 +307,14 @@ class VolZmap : public IVolZmap, public IGeoObjRW bool IsValidVoxel( int nI, int nJ, int nK) const ; bool GetVoxIJKFromN( int nN, int& nI, int& nJ, int& nK) const ; bool GetVoxNFromIJK( int nI, int nJ, int nK, int& nN) const ; + bool GetVoxelBox( int nI, int nJ, int nK, BBox3d& b3VoxBox) const ; // Funzioni di gestione dei blocchi bool GetBlockIJKFromN( int nBlock, int nIJK[]) const ; bool GetBlockNFromIJK( int nIJK[], int& nBlock) const ; bool GetBlockLimitsIJK( const int nIJK[], int nLimits[]) const ; + bool GetBlockBox( const int nIJK[], BBox3d& b3VoxBox) const ; bool GetVoxelBlockIJK( const int nVoxIJK[], int nBlockIJK[]) const ; + bool GetVoxelBlockN( int nVox, int& nBlock) const ; bool SetToModifyDexelBlocks( int nGrid, int nDex, int nInt) ; bool GetAdjBlockToBlock( int nBlockN, int nDeltaI, int nDeltaJ, int nDeltaK, int& nAdjBlockN) const ; bool IsAVoxelOnBoundary( const int nLimits[], const int nIJK[], bool bType) const ; diff --git a/VolZmapCalculus.cpp b/VolZmapCalculus.cpp index 56ecf1f..bb66301 100644 --- a/VolZmapCalculus.cpp +++ b/VolZmapCalculus.cpp @@ -19,11 +19,47 @@ #include "/EgtDev/Include/EGkIntersLineTria.h" #include "/EgtDev/Include/EGkIntersLinePlane.h" #include "/EgtDev/Include/EGkIntersLineSphere.h" +#include "/EgtDev/Include/EGkIntersPlaneTria.h" #include "/EgtDev/Include/EGkChainCurves.h" +#include "/EgtDev/Include/ENkPolynomialRoots.h" #include "/EgtDev/Include/EgtNumUtils.h" using namespace std ; +//---------------------------------------------------------------------------- +// Box e piano devono essere nello stesso riferimento. Il box deve essere axis aligned. +static bool +TestIntersPlaneBox( const BBox3d& b3Box, const Plane3d& plPlane) +{ + // Calcolo le distanze con segno dei punti dal piano + Point3d ptE0 = b3Box.GetMin() ; + double dDist0 = DistPointPlane( ptE0, plPlane) ; + Point3d ptE1( b3Box.GetMax().x, b3Box.GetMin().y, b3Box.GetMin().z) ; + double dDist1 = DistPointPlane( ptE1, plPlane) ; + Point3d ptE2( b3Box.GetMax().x, b3Box.GetMax().y, b3Box.GetMin().z) ; + double dDist2 = DistPointPlane( ptE2, plPlane) ; + Point3d ptE3( b3Box.GetMin().x, b3Box.GetMax().y, b3Box.GetMin().z) ; + double dDist3 = DistPointPlane( ptE3, plPlane) ; + Point3d ptE4( b3Box.GetMin().x, b3Box.GetMin().y, b3Box.GetMax().z) ; + double dDist4 = DistPointPlane( ptE4, plPlane) ; + Point3d ptE5( b3Box.GetMax().x, b3Box.GetMin().y, b3Box.GetMax().z) ; + double dDist5 = DistPointPlane( ptE5, plPlane) ; + Point3d ptE6 = b3Box.GetMax() ; + double dDist6 = DistPointPlane( ptE6, plPlane) ; + Point3d ptE7( b3Box.GetMin().x, b3Box.GetMax().y, b3Box.GetMax().z) ; + double dDist7 = DistPointPlane( ptE7, plPlane) ; + // Distanze tutte positive + if ( dDist0 > EPS_SMALL && dDist1 > EPS_SMALL && dDist2 > EPS_SMALL && dDist3 > EPS_SMALL && + dDist4 > EPS_SMALL && dDist5 > EPS_SMALL && dDist6 > EPS_SMALL && dDist7 > EPS_SMALL) + return false ; + // Distanze tutte negative + if ( dDist0 < - EPS_SMALL && dDist1 < - EPS_SMALL && dDist2 < - EPS_SMALL && dDist3 < - EPS_SMALL && + dDist4 < - EPS_SMALL && dDist5 < - EPS_SMALL && dDist6 < - EPS_SMALL && dDist7 < - EPS_SMALL) + return false ; + // Il piano interseca il box + return true ; +} + //---------------------------------------------------------------------------- // Punti e vettore devono esse espressi nel medesimo sistema di riferimento. // Il box è allineato con gli assi di tale sistema di riferimento. @@ -31,7 +67,6 @@ using namespace std ; bool VolZmap::IntersLineBox( const Point3d& ptP, const Vector3d& vtV, const Point3d& ptMin, const Point3d& ptMax) const { - // Il box è allineato agli assi double dU1, dU2 ; return IntersLineBox( ptP, vtV, ptMin, ptMax, dU1, dU2) ; } @@ -219,7 +254,7 @@ VolZmap::GetDepth( const Point3d& ptPLoc, const Vector3d& vtDLoc, double& dInLen vtD.ToLoc( m_MapFrame) ; if ( bExact && m_nMapNum == 3) - return GetDepthWithVoxel( ptP, vtD, dInLength, dOutLength, true) ; + return GetDepthWithVoxel( ptP, vtD, dInLength, dOutLength) ; else return GetDepthWithDexel( ptP, vtD, dInLength, dOutLength) ; } @@ -385,286 +420,73 @@ VolZmap::GetDepthWithDexel( const Point3d& ptP, const Vector3d& vtV, double& dIn //---------------------------------------------------------------------------- // Calcola la profondità del materiale usando i triangoli della rappresentazione grafica. // Punto e versore devono essere espressi nel sistema di riferimento Zmap. -// Se si vuole che vengano utilizzati i triangoli con sharp-featue bEnh deve valere true, false altrimenti. // InLength = distanza di ingresso (se -1 il punto è interno, se -2 il punto è esterno e il raggio non interseca lo Zmap) // OutLength = distanza di uscita. bool -VolZmap::GetDepthWithVoxel( const Point3d& ptP, const Vector3d& vtD, double& dInLength, double& dOutLength, bool bEnh) const +VolZmap::GetDepthWithVoxel( const Point3d& ptP, const Vector3d& vtD, double& dInLength, double& dOutLength) const { - // Serve che punto e vettore siano espressi sia nel sistema intrinseco dello Zmap (m_MapFrame) sia in quello - // in cui esso è immerso; questo perché i dexel sono espressi in quello intrinseco e i triangoli in quello - // in cui esso è immerso. - Point3d ptOutP = ptP ; - Vector3d vtOutD = vtD ; - ptOutP.ToGlob( m_MapFrame) ; - vtOutD.ToGlob( m_MapFrame) ; - // Intersezione fra semiretta e BBox dello Zmap - double dU1, dU2 ; - bool bLineBBoxInters = IntersLineZMapBBox( ptP, vtD, dU1, dU2) && ( dU1 > 0 || dU2 > 0) ; + ILZIVECTOR vIntersInfo ; + if ( ! GetLineIntersection( ptP, vtD, vIntersInfo)) + return false ; - // Semiretta esterna al box dello Zmap quindi esterna anche allo Zmap - if ( ! bLineBBoxInters) { - dInLength = - 2 ; - dOutLength = - 2 ; + if ( vIntersInfo.empty()) { + dInLength = - 2. ; + dOutLength = - 2. ; return true ; } - // Lancio eventuale aggiornamento pendente della grafica - if ( m_nMapNum == 1) - UpdateSingleMapGraphics() ; - else - UpdateTripleMapGraphics() ; - - // Determino il voxel di partenza - int nVoxI, nVoxJ, nVoxK ; - if ( ! GetPointVoxel( ptP, nVoxI, nVoxJ, nVoxK)) { - if ( ! GetPointVoxel( ptP + dU1 * vtD, nVoxI, nVoxJ, nVoxK)) - return false ; - } - - // Incrementi degli indici per seguire la retta - int nDeltaI = ( vtD.x > 0 ? 1 : ( vtD.x < 0 ? - 1 : 0)) ; - int nDeltaJ = ( vtD.y > 0 ? 1 : ( vtD.y < 0 ? - 1 : 0)) ; - int nDeltaK = ( vtD.z > 0 ? 1 : ( vtD.z < 0 ? - 1 : 0)) ; - // Scelgo i piani del voxel con cui intersecare la retta, per determinare il voxel successivo - int nPlaneI = ( vtD.x >= 0 ? 1 : 0) ; - int nPlaneJ = ( vtD.y >= 0 ? 1 : 0) ; - int nPlaneK = ( vtD.z >= 0 ? 1 : 0) ; - - // Ciclo sui voxel - vector vVox ; - while ( IsValidVoxel( nVoxI, nVoxJ, nVoxK)) { - // Estremi della diagonale del voxel corrente - Point3d ptMin( ( nVoxI * N_DEXVOXRATIO + 0.5) * m_dStep, - ( nVoxJ * N_DEXVOXRATIO + 0.5) * m_dStep, - ( nVoxK * N_DEXVOXRATIO + 0.5) * m_dStep) ; - Point3d ptMax( ( ( nVoxI + 1) * N_DEXVOXRATIO + 0.5) * m_dStep, - ( ( nVoxJ + 1) * N_DEXVOXRATIO + 0.5) * m_dStep, - ( ( nVoxK + 1) * N_DEXVOXRATIO + 0.5) * m_dStep) ; - // Studio il voxel corrente - if ( IntersLineBox( ptP, vtD, ptMin, ptMax)) { - int nCurVoxIndex = CalcIndex( nVoxI, nVoxJ, nVoxK) ; - if ( nCurVoxIndex != 0 && nCurVoxIndex != 255) { - VoxelIndexes NewVox ; - NewVox.nI = nVoxI ; - NewVox.nJ = nVoxJ ; - NewVox.nK = nVoxK ; - vVox.emplace_back( NewVox) ; - } - } - // Interseco la retta con i piani frontiera del voxel - double dMaxTX = ( abs( vtD.x) > EPS_ZERO ? - abs( ( ( ( nVoxI + nPlaneI) * N_DEXVOXRATIO + 0.5) * m_dStep - ptP.x) / vtD.x) : INFINITO) ; - double dMaxTY = ( abs( vtD.y) > EPS_ZERO ? - abs( ( ( ( nVoxJ + nPlaneJ) * N_DEXVOXRATIO + 0.5) * m_dStep - ptP.y) / vtD.y) : INFINITO) ; - double dMaxTZ = ( abs( vtD.z) > EPS_ZERO ? - abs( ( ( ( nVoxK + nPlaneK) * N_DEXVOXRATIO + 0.5) * m_dStep - ptP.z) / vtD.z) : INFINITO) ; - // Determino gli incrementi - if ( dMaxTX < dMaxTY) { - if ( dMaxTX < dMaxTZ) - nVoxI += nDeltaI ; - else - nVoxK += nDeltaK ; - } - else { - if ( dMaxTY < dMaxTZ) - nVoxJ += nDeltaJ ; - else - nVoxK += nDeltaK ; - } - } - - // Dati dell'intersezione - struct LineTriaInt { - int nNum ; - double dPar1 ; - double dPar2 ; - double dDot ; - LineTriaInt( void) : nNum( 0) {} - LineTriaInt( double dP, double dD) : nNum( 1), dPar1( dP), dDot( dD) {} - LineTriaInt( double dP1, double dP2, double dD) - : nNum( 2), dPar1( dP1), dPar2( dP2), dDot( dD) {} - } ; - vector vInt ; - int nPrevBlockN = - 1 ; - // Ciclo sui voxel - for ( int nVx = 0 ; nVx < int( vVox.size()) ; ++ nVx) { - int nCurVoxIJK[3] = { vVox[nVx].nI, vVox[nVx].nJ, vVox[nVx].nK} ; - int nCurBlockIJK[3] ; - if ( GetVoxelBlockIJK( nCurVoxIJK, nCurBlockIJK)) { - int nCurBlockN ; - GetBlockNFromIJK( nCurBlockIJK, nCurBlockN) ; - // Triangoli sharp fra blocchi - for ( int nBlVx = 0 ; nBlVx < int( m_InterBlockSharpTria[nCurBlockN].size()) ; ++ nBlVx) { - if ( m_InterBlockSharpTria[nCurBlockN][nBlVx].i == nCurVoxIJK[0] && - m_InterBlockSharpTria[nCurBlockN][nBlVx].j == nCurVoxIJK[1] && - m_InterBlockSharpTria[nCurBlockN][nBlVx].k == nCurVoxIJK[2]) { - for ( int nBlCm = 0 ; nBlCm < int( m_InterBlockSharpTria[nCurBlockN][nBlVx].vCompoTria.size()) ; ++ nBlCm) { - for ( int nBlTr = 0 ; nBlTr < int( m_InterBlockSharpTria[nCurBlockN][nBlVx].vCompoTria[nBlCm].size()) ; ++ nBlTr) { - Triangle3d CurrTria = m_InterBlockSharpTria[nCurBlockN][nBlVx].vCompoTria[nBlCm][nBlTr] ; - Point3d ptLineTria1, ptLineTria2 ; - // Studio dell'intersezione della retta con il triangolo corrente - int nIntType = IntersLineTria( ptOutP, vtOutD, 1.5 * dU2, CurrTria, ptLineTria1, ptLineTria2) ; - // Se non ci sono intersezioni passo al prossimo triangolo - if ( nIntType == ILTT_NO) - continue ; - // se altrimenti c'è una sola intersezione - else if ( nIntType == ILTT_VERT || - nIntType == ILTT_EDGE || - nIntType == ILTT_IN) { - vInt.emplace_back( ( ptLineTria1 - ptOutP) * vtOutD, vtOutD * CurrTria.GetN()) ; - } - // altrimenti ci sono due intersezioni - else { - double dP1 = ( ptLineTria1 - ptOutP) * vtOutD ; - double dP2 = ( ptLineTria2 - ptOutP) * vtOutD ; - double dD = vtOutD * CurrTria.GetN() ; - vInt.emplace_back( ( dP1 < dP2 ? dP1 : dP2), ( dP1 < dP2 ? dP2 : dP1), dD) ; - } - } - } - } - } - // Triangoli sharp interni - for ( int nBlVx = 0 ; nBlVx < int( m_BlockSharpTria[nCurBlockN].size()) ; ++ nBlVx) { - if ( m_BlockSharpTria[nCurBlockN][nBlVx].i == nCurVoxIJK[0] && - m_BlockSharpTria[nCurBlockN][nBlVx].j == nCurVoxIJK[1] && - m_BlockSharpTria[nCurBlockN][nBlVx].k == nCurVoxIJK[2]) { - for ( int nBlCm = 0 ; nBlCm < int( m_BlockSharpTria[nCurBlockN][nBlVx].vCompoTria.size()) ; ++ nBlCm) { - for ( int nBlTr = 0 ; nBlTr < int( m_BlockSharpTria[nCurBlockN][nBlVx].vCompoTria[nBlCm].size()) ; ++ nBlTr) { - Triangle3d CurrTria = m_BlockSharpTria[nCurBlockN][nBlVx].vCompoTria[nBlCm][nBlTr] ; - Point3d ptLineTria1, ptLineTria2 ; - // Studio dell'intersezione della retta con il triangolo corrente - int nIntType = IntersLineTria( ptOutP, vtOutD, 1.5 * dU2, CurrTria, ptLineTria1, ptLineTria2) ; - // Se non ci sono intersezioni passo al prossimo triangolo - if ( nIntType == ILTT_NO) - continue ; - // se altrimenti c'è una sola intersezione - else if ( nIntType == ILTT_VERT || - nIntType == ILTT_EDGE || - nIntType == ILTT_IN) { - vInt.emplace_back( ( ptLineTria1 - ptOutP) * vtOutD, vtOutD * CurrTria.GetN()) ; - } - // altrimenti ci sono due intersezioni - else { - double dP1 = ( ptLineTria1 - ptOutP) * vtOutD ; - double dP2 = ( ptLineTria2 - ptOutP) * vtOutD ; - double dD = vtOutD * CurrTria.GetN() ; - vInt.emplace_back( ( dP1 < dP2 ? dP1 : dP2), ( dP1 < dP2 ? dP2 : dP1), dD) ; - } - } - } - } - } - // Triangoli smooth - for ( int nBlVx = 0 ; nBlVx < int( m_BlockSmoothTria[nCurBlockN].size()) ; ++ nBlVx) { - if ( m_BlockSmoothTria[nCurBlockN][nBlVx].i == nCurVoxIJK[0] && - m_BlockSmoothTria[nCurBlockN][nBlVx].j == nCurVoxIJK[1] && - m_BlockSmoothTria[nCurBlockN][nBlVx].k == nCurVoxIJK[2]) { - for ( int nBlTr = 0 ; nBlTr < int( m_BlockSmoothTria[nCurBlockN][nBlVx].vTria.size()) ; ++ nBlTr) { - Triangle3d CurrTria = m_BlockSmoothTria[nCurBlockN][nBlVx].vTria[nBlTr] ; - Point3d ptLineTria1, ptLineTria2 ; - // Studio dell'intersezione della retta con il triangolo corrente - int nIntType = IntersLineTria( ptOutP, vtOutD, 1.5 * dU2, CurrTria, ptLineTria1, ptLineTria2) ; - // Se non ci sono intersezioni passo al prossimo triangolo - if ( nIntType == ILTT_NO) - continue ; - // se altrimenti c'è una sola intersezione - else if ( nIntType == ILTT_VERT || - nIntType == ILTT_EDGE || - nIntType == ILTT_IN) { - vInt.emplace_back( ( ptLineTria1 - ptOutP) * vtOutD, vtOutD * CurrTria.GetN()) ; - } - // altrimenti ci sono due intersezioni - else { - double dP1 = ( ptLineTria1 - ptOutP) * vtOutD ; - double dP2 = ( ptLineTria2 - ptOutP) * vtOutD ; - double dD = vtOutD * CurrTria.GetN() ; - vInt.emplace_back( ( dP1 < dP2 ? dP1 : dP2), ( dP1 < dP2 ? dP2 : dP1), dD) ; - } - } - } - } - // Triangoli grandi - if ( nCurBlockN != nPrevBlockN) { - for ( int nBlTr = 0 ; nBlTr < int( m_BlockBigTria[nCurBlockN].size()) ; ++ nBlTr) { - Triangle3d CurrTria = m_BlockBigTria[nCurBlockN][nBlTr] ; - Point3d ptLineTria1, ptLineTria2 ; - // Studio dell'intersezione della retta con il triangolo corrente - int nIntType = IntersLineTria( ptOutP, vtOutD, 1.5 * dU2, CurrTria, ptLineTria1, ptLineTria2) ; - // Se non ci sono intersezioni passo al prossimo triangolo - if ( nIntType == ILTT_NO) - continue ; - // se altrimenti c'è una sola intersezione - else if ( nIntType == ILTT_VERT || - nIntType == ILTT_EDGE || - nIntType == ILTT_IN) { - vInt.emplace_back( ( ptLineTria1 - ptOutP) * vtOutD, vtOutD * CurrTria.GetN()) ; - } - // altrimenti ci sono due intersezioni - else { - double dP1 = ( ptLineTria1 - ptOutP) * vtOutD ; - double dP2 = ( ptLineTria2 - ptOutP) * vtOutD ; - double dD = vtOutD * CurrTria.GetN() ; - vInt.emplace_back( ( dP1 < dP2 ? dP1 : dP2), ( dP1 < dP2 ? dP2 : dP1), dD) ; - } - } - nPrevBlockN = nCurBlockN ; - } - } - } - - // Ordino le intersezioni in base al parametro distanza con segno da ptP - sort( vInt.begin(), vInt.end(), - []( const LineTriaInt& a, const LineTriaInt& b) - { double dFP = ( a.nNum == 2 ? 0.5 * ( a.dPar1 + a.dPar2) : a.dPar1) ; - double dLP = ( b.nNum == 2 ? 0.5 * ( b.dPar1 + b.dPar2) : b.dPar1) ; - return ( dLP > dFP) ; }) ; - - // Inizializzo le distanze di ingresso e uscita: - // dInLength diminuisce, dOutLength aumenta. - dInLength = INFINITO ; - dOutLength = - INFINITO ; + // Porto nel riferimento intrinseco dello Zmap + Vector3d vtOutD = vtD ; + vtOutD.ToGlob( m_MapFrame) ; + + // Inizializzo le distanze di ingresso e uscita: + // dInLength diminuisce, dOutLength aumenta. + dInLength = INFINITO ; + dOutLength = -INFINITO ; int nFirstPosN ; int nN = 0 ; - for ( ; nN < int( vInt.size()) ; ++ nN) { - if ( vInt[nN].dPar1 > - EPS_SMALL) { + for ( ; nN < int( vIntersInfo.size()) ; ++ nN) { + if ( vIntersInfo[nN].dU > - EPS_SMALL) { nFirstPosN = nN ; - break ; + break ; } } - if ( nN == int( vInt.size())) { + if ( nN == int( vIntersInfo.size())) { dInLength = - 2 ; dOutLength = - 2 ; return true ; } - if ( nFirstPosN > 0) { - if ( vInt[nFirstPosN - 1].dDot < EPS_ZERO) - dInLength = -1 ; + int nVoxIJK[3] ; + GetBlockIJKFromN( vIntersInfo[0].nVox, nVoxIJK) ; + + if ( nFirstPosN > 0) { + if ( vIntersInfo[nFirstPosN - 1].trTria.GetN() * vtOutD < EPS_ZERO) + dInLength = - 1 ; } else if ( nFirstPosN == 0) { - if ( vInt[nFirstPosN].dDot > EPS_ZERO) - dInLength = -1 ; - else if ( GetPointVoxel( ptP, nVoxI, nVoxJ, nVoxK)) { - int nCubeType = CalcIndex( nVoxI, nVoxJ, nVoxK) ; + if ( vIntersInfo[nFirstPosN].trTria.GetN() * vtOutD > EPS_ZERO) + dInLength = - 1 ; + else if ( GetPointVoxel( ptP, nVoxIJK[0], nVoxIJK[1], nVoxIJK[2])) { + int nCubeType = CalcIndex( nVoxIJK[0], nVoxIJK[1], nVoxIJK[2]) ; if ( nCubeType == 255) - dInLength = -1 ; + dInLength = - 1 ; } } - for ( int nN = nFirstPosN ; nN < int( vInt.size()) ; ++ nN) { - if ( vInt[nN].dDot > - EPS_ZERO) { - if ( vInt[nN].nNum == 2 && dOutLength < vInt[nN].dPar2) - dOutLength = vInt[nN].dPar2 ; - else if ( dOutLength < vInt[nN].dPar1) - dOutLength = vInt[nN].dPar1 ; - } - if ( vInt[nN].dDot < EPS_ZERO && - dInLength > vInt[nN].dPar1) - dInLength = vInt[nN].dPar1 ; + for ( int nN = nFirstPosN ; nN < int( vIntersInfo.size()) ; ++ nN) { + if ( vIntersInfo[nN].trTria.GetN() * vtOutD > - EPS_ZERO) { + if ( ( vIntersInfo[nN].nILTT == ILTT_SEGM || vIntersInfo[nN].nILTT == ILTT_SEGM_ON_EDGE) && + dOutLength < vIntersInfo[nN].dU2) + dOutLength = vIntersInfo[nN].dU2 ; + else if ( dOutLength < vIntersInfo[nN].dU) + dOutLength = vIntersInfo[nN].dU ; + } + if ( vIntersInfo[nN].trTria.GetN() * vtOutD < EPS_ZERO && + dInLength > vIntersInfo[nN].dU) + dInLength = vIntersInfo[nN].dU ; } return true ; @@ -1502,6 +1324,193 @@ VolZmap::GetPartVolume( int nPart, double& dVol) const return true ; } +//---------------------------------------------------------------------------- +// La retta deve essere espressa nel sistema Zmap. +// Per riferimento viene restituito un vettore di intersezioni della retta con i triangoli della superficie del solido. +// Si restituisce false in caso di errore, true altrimenti. +bool +VolZmap::GetLineIntersection( const Point3d& ptP, const Vector3d& vtD, ILZIVECTOR& vIntersInfo) const +{ + // Calcolo punto e vettore espressi nel riferimento intrinseco dello Zmap + Point3d ptLocP = ptP ; + Vector3d vtLocD = vtD ; + ptLocP.ToLoc( m_MapFrame) ; + vtLocD.ToLoc( m_MapFrame) ; + + // Intersezione fra semiretta e BBox dello Zmap + double dU1, dU2 ; + bool bLineBBoxInters = IntersLineZMapBBox( ptLocP, vtLocD, dU1, dU2) && ( dU1 > 0 || dU2 > 0) ; + + // Semiretta esterna al box dello Zmap quindi esterna anche allo Zmap + if ( ! bLineBBoxInters) + return true ; + + // Lancio eventuale aggiornamento pendente della grafica + if ( m_nMapNum == 1) + UpdateSingleMapGraphics() ; + else + UpdateTripleMapGraphics() ; + + // Ciclo sui blocchi + for ( int nB = 0 ; nB < m_nNumBlock ; ++ nB) { + // Determino indici IJK del blocco; se non trovo il blocco, errore + int nBlockIJK[3] ; + if ( ! GetBlockIJKFromN( nB, nBlockIJK)) + return false ; + // Costruisco il bounding-box del blocco; se non è possibile, errore + BBox3d b3BlockBox ; + if ( ! GetBlockBox( nBlockIJK, b3BlockBox)) + return false ; + // Se c'è intersezione valuto tutti i voxel interni + if ( IntersLineBox( ptLocP, vtLocD, b3BlockBox.GetMin(), b3BlockBox.GetMax())) { + // Ciclo sui voxel del blocco. + // Triangoli smooth + for ( int nV = 0 ; nV < int( m_BlockSmoothTria[nB].size()) ; ++ nV) { + // Box del voxel + BBox3d b3Vox ; + int nCurVoxIJK[3] = { m_BlockSmoothTria[nB][nV].i, + m_BlockSmoothTria[nB][nV].j, + m_BlockSmoothTria[nB][nV].k } ; + GetVoxelBox( nCurVoxIJK[0], nCurVoxIJK[1], nCurVoxIJK[2], b3Vox) ; + // Se non c'è intersezione col voxel, passo al successivo. + if ( ! IntersLineBox( ptLocP, vtLocD, b3Vox.GetMin(), b3Vox.GetMax())) + continue ; + for ( int nT = 0 ; nT < int( m_BlockSmoothTria[nB][nV].vTria.size()) ; ++ nT) { + Triangle3d trTria = m_BlockSmoothTria[nB][nV].vTria[nT] ; + if ( ! trTria.Validate( true)) + continue ; + Point3d ptLineTria1, ptLineTria2 ; + // Studio dell'intersezione della retta con il triangolo corrente + int nIntType = IntersLineTria( ptP, vtD, 1.5 * dU2, trTria, ptLineTria1, ptLineTria2) ; + // Se non ci sono intersezioni passo al prossimo triangolo + if ( nIntType == ILTT_NO) + continue ; + // se altrimenti c'è una sola intersezione + else if ( nIntType == ILTT_VERT || nIntType == ILTT_EDGE || nIntType == ILTT_IN) { + int nNumVox ; + GetVoxNFromIJK( nCurVoxIJK[0], nCurVoxIJK[1], nCurVoxIJK[2], nNumVox) ; + vIntersInfo.emplace_back( nIntType, ( ptLineTria1 - ptP) * vtD, + nNumVox, nB, ptLineTria1, trTria) ; + } + // altrimenti ci sono due intersezioni + else { + int nNumVox ; + GetVoxNFromIJK( nCurVoxIJK[0], nCurVoxIJK[1], nCurVoxIJK[2], nNumVox) ; + double dP1 = ( ptLineTria1 - ptP) * vtD ; + double dP2 = ( ptLineTria2 - ptP) * vtD ; + vIntersInfo.emplace_back( nIntType, ( dP1 < dP2 ? dP1 : dP2), ( dP1 < dP2 ? dP2 : dP1), + nNumVox, nB, ptLineTria1, ptLineTria2, trTria) ; + } + } + } + // Triangoli sharp interni al blocco + for ( int nV = 0 ; nV < int( m_BlockSharpTria[nB].size()) ; ++ nV) { + int nCurVoxIJK[3] = { m_BlockSharpTria[nB][nV].i, + m_BlockSharpTria[nB][nV].j, + m_BlockSharpTria[nB][nV].k } ; + + // Ciclo sulle componenti connesse + for ( int nC = 0 ; nC < int( m_BlockSharpTria[nB][nV].vCompoTria.size()) ; ++ nC) { + for ( int nT = 0 ; nT < int( m_BlockSharpTria[nB][nV].vCompoTria[nC].size()) ; ++ nT) { + Triangle3d trTria = m_BlockSharpTria[nB][nV].vCompoTria[nC][nT] ; + if ( ! trTria.Validate( true)) + continue ; + Point3d ptLineTria1, ptLineTria2 ; + // Studio dell'intersezione della retta con il triangolo corrente + int nIntType = IntersLineTria( ptP, vtD, 1.5 * dU2, trTria, ptLineTria1, ptLineTria2) ; + // Se non ci sono intersezioni passo al prossimo triangolo + if ( nIntType == ILTT_NO) + continue ; + // se altrimenti c'è una sola intersezione + else if ( nIntType == ILTT_VERT || nIntType == ILTT_EDGE || nIntType == ILTT_IN) { + int nNumVox ; + GetVoxNFromIJK( nCurVoxIJK[0], nCurVoxIJK[1], nCurVoxIJK[2], nNumVox) ; + vIntersInfo.emplace_back( nIntType, ( ptLineTria1 - ptP) * vtD, + nNumVox, nB, ptLineTria1, trTria) ; + } + // altrimenti ci sono due intersezioni + else { + int nNumVox ; + GetVoxNFromIJK( nCurVoxIJK[0], nCurVoxIJK[1], nCurVoxIJK[2], nNumVox) ; + double dP1 = ( ptLineTria1 - ptP) * vtD ; + double dP2 = ( ptLineTria2 - ptP) * vtD ; + vIntersInfo.emplace_back( nIntType, ( dP1 < dP2 ? dP1 : dP2), ( dP1 < dP2 ? dP2 : dP1), + nNumVox, nB, ptLineTria1, ptLineTria2, trTria) ; + } + } + } + } + // Triangoli grandi del blocco + for ( int nT = 0 ; nT < int( m_BlockBigTria[nB].size()) ; ++ nT) { + Triangle3d trTria = m_BlockBigTria[nB][nT] ; + Point3d ptLineTria1, ptLineTria2 ; + // Studio dell'intersezione della retta con il triangolo corrente + int nIntType = IntersLineTria( ptP, vtD, 1.5 * dU2, trTria, ptLineTria1, ptLineTria2) ; + // Se non ci sono intersezioni passo al prossimo triangolo + if ( nIntType == ILTT_NO) + continue ; + // se altrimenti c'è una sola intersezione + else if ( nIntType == ILTT_VERT || nIntType == ILTT_EDGE || nIntType == ILTT_IN) { + vIntersInfo.emplace_back( nIntType, ( ptLineTria1 - ptP) * vtD, + -1, nB, ptLineTria1, trTria) ; + } + // altrimenti ci sono due intersezioni + else { + double dP1 = ( ptLineTria1 - ptP) * vtD ; + double dP2 = ( ptLineTria2 - ptP) * vtD ; + vIntersInfo.emplace_back( nIntType, ( dP1 < dP2 ? dP1 : dP2), ( dP1 < dP2 ? dP2 : dP1), + -1, nB, ptLineTria1, ptLineTria2, trTria) ; + } + } + } + // In ogni caso valuto i triangoli sharp fra blocchi + for ( int nV = 0 ; nV < int( m_InterBlockSharpTria[nB].size()) ; ++ nV) { + int nCurVoxIJK[3] = { m_InterBlockSharpTria[nB][nV].i, + m_InterBlockSharpTria[nB][nV].j, + m_InterBlockSharpTria[nB][nV].k } ; + // Ciclo sulle componenti connesse + for ( int nC = 0 ; nC < int( m_InterBlockSharpTria[nB][nV].vCompoTria.size()) ; ++ nC) { + for ( int nT = 0 ; nT < int( m_InterBlockSharpTria[nB][nV].vCompoTria[nC].size()) ; ++ nT) { + Triangle3d trTria = m_InterBlockSharpTria[nB][nV].vCompoTria[nC][nT] ; + if ( ! trTria.Validate( true)) + continue ; + Point3d ptLineTria1, ptLineTria2 ; + // Studio dell'intersezione della retta con il triangolo corrente + int nIntType = IntersLineTria( ptP, vtD, 1.5 * dU2, trTria, ptLineTria1, ptLineTria2) ; + // Se non ci sono intersezioni passo al prossimo triangolo + if ( nIntType == ILTT_NO) + continue ; + // se altrimenti c'è una sola intersezione + else if ( nIntType == ILTT_VERT || nIntType == ILTT_EDGE || nIntType == ILTT_IN) { + int nNumVox ; + GetVoxNFromIJK( nCurVoxIJK[0], nCurVoxIJK[1], nCurVoxIJK[2], nNumVox) ; + vIntersInfo.emplace_back( nIntType, ( ptLineTria1 - ptP) * vtD, + nNumVox, nB, ptLineTria1, trTria) ; + } + // altrimenti ci sono due intersezioni + else { + int nNumVox ; + GetVoxNFromIJK( nCurVoxIJK[0], nCurVoxIJK[1], nCurVoxIJK[2], nNumVox) ; + double dP1 = ( ptLineTria1 - ptP) * vtD ; + double dP2 = ( ptLineTria2 - ptP) * vtD ; + vIntersInfo.emplace_back( nIntType, ( dP1 < dP2 ? dP1 : dP2), ( dP1 < dP2 ? dP2 : dP1), + nNumVox, nB, ptLineTria1, ptLineTria2, trTria) ; + } + } + } + } + } + + // Ordino le intersezioni in base al parametro distanza con segno da ptP + sort( vIntersInfo.begin(), vIntersInfo.end(), + []( const IntLineZmapInfo& a, const IntLineZmapInfo& b) + { double dFP = (( a.nILTT == ILTT_SEGM || a.nILTT == ILTT_SEGM_ON_EDGE) ? 0.5 * ( a.dU + a.dU2) : a.dU) ; + double dLP = (( b.nILTT == ILTT_SEGM || b.nILTT == ILTT_SEGM_ON_EDGE) ? 0.5 * ( b.dU + b.dU2) : b.dU) ; + return ( dLP > dFP) ; }) ; + + return true ; +} + //---------------------------------------------------------------------------- // Il piano è espresso nel sistema locale, la funzione lo esprime nel sistema Zmap. // I loop della flat region ottenuta dall'intersezione vengono salvati nello @@ -1513,45 +1522,115 @@ VolZmap::GetPlaneIntersection( const Plane3d& plPlane, ICURVEPOVECTOR& vpLoop) c // Verifico validità parametri if ( ! plPlane.IsValid()) return false ; + // Porto il piano nel sistema Zmap - Plane3d plPlaneL = plPlane ; - plPlaneL.ToLoc( m_MapFrame) ; - // Vettore del piano - Vector3d vtNL = plPlaneL.GetVersN() ; + Plane3d plPlaneLoc = plPlane ; + plPlaneLoc.ToLoc( m_MapFrame) ; - // Se il piano non interseca il bounding box del solido, abbiamo finito - if ( ! TestIntersPlaneZmapBBox( plPlaneL)) + // Se non c'è intersezione fra piano e bounding-box del solido, ho finito. + if ( ! TestIntersPlaneZmapBBox( plPlaneLoc)) return true ; - - // Cerco la mappa con i dexel più perpendicolari al piano e valuto - // se il versore del piano è equiverso o controverso ai dexel. - int nGrid = 0 ; - int nSign = ( vtNL.z > 0 ? 1 : - 1) ; - if ( abs( vtNL.x) > abs( vtNL.y) && abs( vtNL.x) > abs( vtNL.z)) { - nGrid = 1 ; - nSign = ( vtNL.x > 0 ? 1 : - 1) ; - } - else if ( abs( vtNL.y) > abs( vtNL.x) && abs( vtNL.y) > abs( vtNL.z)) { - nGrid = 2 ; - nSign = ( vtNL.y > 0 ? 1 : - 1) ; - } - - // Ciclo sulle celle + // Lancio eventuale aggiornamento pendente della grafica + if ( m_nMapNum == 1) + UpdateSingleMapGraphics() ; + else + UpdateTripleMapGraphics() ; + // Vettore di segmenti vector vLine ; - for ( int ni = - 1 ; ni < int( m_nNx[nGrid]) ; ++ ni) { - for ( int nj = - 1 ; nj < int( m_nNy[nGrid]) ; ++ nj) { - ProcessCell( nGrid, ni, nj, plPlaneL, vLine) ; + // Ciclo sui blocchi + for ( int nB = 0 ; nB < m_nNumBlock ; ++ nB) { + // Determino indici IJK del blocco; Se non trovo il blocco, errore + int nBlockIJK[3] ; + if ( ! GetBlockIJKFromN( nB, nBlockIJK)) + return false ; + // Costruisco il bounding-bx del blocco; se non è possiblie, errore + BBox3d b3BlockBox ; + if ( ! GetBlockBox( nBlockIJK, b3BlockBox)) + return false ; + // Se c'è intersezione valuto tutti i voxel interni + if ( TestIntersPlaneBox( b3BlockBox, plPlaneLoc)) { + // Ciclo sui voxel del blocco. + // Triangoli smooth + for ( int nV = 0 ; nV < int( m_BlockSmoothTria[nB].size()) ; ++ nV) { + // Box del voxel + BBox3d b3Vox ; + GetVoxelBox( m_BlockSmoothTria[nB][nV].i, m_BlockSmoothTria[nB][nV].j, m_BlockSmoothTria[nB][nV].k, b3Vox) ; + // Se non c'è intersezione col voxel, passo al successivo. + if ( ! TestIntersPlaneBox(b3Vox, plPlaneLoc)) + continue ; + for ( int nT = 0 ; nT < int( m_BlockSmoothTria[nB][nV].vTria.size()) ; ++ nT) { + Triangle3d trTria = m_BlockSmoothTria[nB][nV].vTria[nT] ; + Point3d ptSt, ptEn ; + int nIntersType = IntersPlaneTria( plPlane, trTria, ptSt, ptEn) ; + if ( nIntersType == IPTT_EDGE || nIntersType == IPTT_YES) { + // Costruisco il tratto di curva + CurveLine cvLine ; + if ( cvLine.Set( ptSt, ptEn)) + vLine.emplace_back( cvLine) ; + } + } + } + // Triangoli sharp interni al blocco + for ( int nV = 0 ; nV < int( m_BlockSharpTria[nB].size()) ; ++ nV) { + // Box del voxel + BBox3d b3Vox ; + GetVoxelBox( m_BlockSharpTria[nB][nV].i, m_BlockSharpTria[nB][nV].j, m_BlockSharpTria[nB][nV].k, b3Vox) ; + // Se non c'è intersezione col voxel, passo al successivo. + // Ciclo sulle componenti connesse + for ( int nC = 0 ; nC < int( m_BlockSharpTria[nB][nV].vCompoTria.size()) ; ++ nC) { + for ( int nT = 0 ; nT < int( m_BlockSharpTria[nB][nV].vCompoTria[nC].size()) ; ++ nT) { + Triangle3d trTria = m_BlockSharpTria[nB][nV].vCompoTria[nC][nT] ; + Point3d ptSt, ptEn ; + int nIntersType = IntersPlaneTria(plPlane, trTria, ptSt, ptEn) ; + if (nIntersType == IPTT_EDGE || nIntersType == IPTT_YES) { + // Costruisco il tratto di curva + CurveLine cvLine ; + if ( cvLine.Set(ptSt, ptEn)) + vLine.emplace_back( cvLine) ; + } + } + } + } + // Triangoli grandi del blocco + for ( int nT = 0 ; nT < int( m_BlockBigTria[nB].size()) ; ++ nT) { + Triangle3d trTria = m_BlockBigTria[nB][nT] ; + Point3d ptSt, ptEn ; + int nIntersType = IntersPlaneTria(plPlane, trTria, ptSt, ptEn) ; + if ( nIntersType == IPTT_EDGE || nIntersType == IPTT_YES) { + // Costruisco il tratto di curva + CurveLine cvLine ; + if ( cvLine.Set(ptSt, ptEn)) + vLine.emplace_back( cvLine) ; + } + } } + // In ogni caso valuto i triangoli sharp fra blocchi + for ( int nV = 0 ; nV < int( m_InterBlockSharpTria[nB].size()) ; ++ nV) { + // Ciclo sulle componenti connesse + for ( int nC = 0 ; nC < int( m_InterBlockSharpTria[nB][nV].vCompoTria.size()) ; ++ nC) { + for ( int nT = 0 ; nT < int( m_InterBlockSharpTria[nB][nV].vCompoTria[nC].size()) ; ++ nT) { + Triangle3d trTria = m_InterBlockSharpTria[nB][nV].vCompoTria[nC][nT] ; + Point3d ptSt, ptEn ; + int nIntersType = IntersPlaneTria( plPlane, trTria, ptSt, ptEn) ; + if ( nIntersType == IPTT_EDGE || nIntersType == IPTT_YES) { + // Costruisco il tratto di curva + CurveLine cvLine ; + if ( cvLine.Set(ptSt, ptEn)) + vLine.emplace_back( cvLine) ; + } + } + } + } } - + // Creo i loop ChainCurves LoopCreator ; LoopCreator.Init( false, EPS_SMALL, int( vLine.size())) ; - // Carico le curve per concatenarle + // Carico le curve per concatenarle for ( int nCv = 0 ; nCv < int( vLine.size()) ; ++ nCv) { Point3d ptSt = vLine[nCv].GetStart() ; - Point3d ptEn = vLine[nCv].GetEnd() ; - Vector3d vtDir ; vLine[nCv].GetStartDir( vtDir) ; + Point3d ptEn = vLine[nCv].GetEnd() ; + Vector3d vtDir; vLine[nCv].GetStartDir(vtDir) ; LoopCreator.AddCurve( nCv + 1, ptSt, vtDir, ptEn, vtDir) ; } // Recupero i concatenamenti @@ -1563,266 +1642,15 @@ VolZmap::GetPlaneIntersection( const Plane3d& plPlane, ICURVEPOVECTOR& vpLoop) c return false ; for ( auto i : vIds) { // Aggiungo la linea alla curva composta. - if ( ! pLoop->AddCurve( vLine[i-1], true, EPS_SMALL)) + if ( ! pLoop->AddCurve( vLine[i - 1], true, 10 * EPS_SMALL)) return false ; - } - pLoop->SetExtrusion( vtNL) ; - pLoop->ToGlob( m_MapFrame) ; - // Se normali controverse, devo invertire il verso del loop. - if ( nSign < 0) - pLoop->Invert() ; - // eseguo approssimazione - PolyLine PL ; - if ( ! pLoop->ApproxWithLines( m_dStep, ANG_TOL_STD_DEG, ICurve::APL_RIGHT, PL) || - ! pLoop->Clear() || ! pLoop->FromPolyLine( PL)) - return false ; - pLoop->MergeCurves( m_dStep, ANG_TOL_STD_DEG) ; - // Inserisco la curva composita nella raccolta da ritornare - vpLoop.emplace_back( Release( pLoop)) ; - } - - return true ; -} - -//---------------------------------------------------------------------------- -// Data una cella, identificata dal numero della sua griglia e dai suoi indici i,j -// all'interno della griglia, genera gli eventuali segmenti che costituiscono la curva -// corrispondente alla frontiera della regione di piano interna la solido. -// Se la griglia o la cella non è valida, la funzione restituisce false, -// altrimenti valuta la tipologia della cella e crea gli eventuali segmenti. -// Se il processo va a buon fine la funzione restituisce true. -bool -VolZmap::ProcessCell( int nGrid, int nCellI, int nCellJ, const Plane3d& plPlane, vector& vLine) const -{ - // Se la griglia non esiste vi è un errore - if ( nGrid < 0 || nGrid > 2) - return false ; - // Se la cella non esiste vi è un errore - if ( nCellI < - 1 || nCellI >= int( m_nNx[nGrid]) || - nCellJ < - 1 || nCellJ >= int( m_nNy[nGrid])) - return false ; - - // Determino la configurazione della cella - int nIndex = CalcIndexForPlaneCells( plPlane, nGrid, nCellI, nCellJ) ; - - // Tabella segmenti - static int nLineTable[16][5] = { - { -1, -1, -1, -1, -1}, - { 0, 3, -1, -1, -1}, - { 1, 0, -1, -1, -1}, - { 1, 3, -1, -1, -1}, - { 2, 1, -1, -1, -1}, - { 0, 1, 2, 3, -1}, - { 2, 0, -1, -1, -1}, - { 2, 3, -1, -1, -1}, - { 3, 2, -1, -1, -1}, - { 0, 2, -1, -1, -1}, - { 1, 2, 3, 0, -1}, - { 1, 2, -1, -1, -1}, - { 3, 1, -1, -1, -1}, - { 0, 1, -1, -1, -1}, - { 3, 0, -1, -1, -1}, - { -1, -1, -1, -1, -1} - } ; - // Tabella dei punti medi dei segmenti: le righe rappresentano - // il numero di segmento (0, 1, 2, 3) le colonne rappresentano - // i e j. - static double dDeltaIJ[4][2] = { - { 0.5, 0}, - { 1, 0.5}, - { 0.5, 1}, - { 0, 0.5} - } ; - // Se la cella è di frontiera costruisco i segmenti della curva - if ( nIndex != 0 && nIndex != 15) { - // Ciclo su tutti gli spigoli della cella che vengono attraversati dalla curva. - for ( int nEdge = 0 ; nLineTable[nIndex][nEdge] != -1 ; nEdge += 2) { - - int nStEdge = nLineTable[nIndex][nEdge] ; - int nEnEdge = nLineTable[nIndex][nEdge + 1] ; - double nStDeltaI = dDeltaIJ[nStEdge][0] ; - double nStDeltaJ = dDeltaIJ[nStEdge][1] ; - double nEnDeltaI = dDeltaIJ[nEnEdge][0] ; - double nEnDeltaJ = dDeltaIJ[nEnEdge][1] ; - - if ( nGrid == 0) { - // Punti sulla griglia - Point3d ptGrSt( ( nCellI + nStDeltaI + 0.5) * m_dStep, ( nCellJ + nStDeltaJ + 0.5) * m_dStep, 0) ; - Point3d ptGrEn( ( nCellI + nEnDeltaI + 0.5) * m_dStep, ( nCellJ + nEnDeltaJ + 0.5) * m_dStep, 0) ; - // Corrispondenti punti sul piano - Point3d ptSt, ptEn ; - if ( IntersLinePlane( ptGrSt, Z_AX, 10, plPlane, ptSt, false) && - IntersLinePlane( ptGrEn, Z_AX, 10, plPlane, ptEn, false)) { - // Costruisco il tratto di curva - CurveLine cvLine ; - cvLine.Set( ptSt, ptEn) ; - vLine.emplace_back( cvLine) ; - } - } - - else if ( nGrid == 1) { - // Punti sulla griglia - Point3d ptGrSt( 0, ( nCellI + nStDeltaI + 0.5) * m_dStep, ( nCellJ + nStDeltaJ + 0.5) * m_dStep) ; - Point3d ptGrEn( 0, ( nCellI + nEnDeltaI + 0.5) * m_dStep, ( nCellJ + nEnDeltaJ + 0.5) * m_dStep) ; - // Corrispondenti punti sul piano - Point3d ptSt, ptEn ; - if ( IntersLinePlane( ptGrSt, X_AX, 10, plPlane, ptSt, false) && - IntersLinePlane( ptGrEn, X_AX, 10, plPlane, ptEn, false)) { - // Costruisco il tratto di curva - CurveLine cvLine ; - cvLine.Set( ptSt, ptEn) ; - vLine.emplace_back( cvLine) ; - } - } - - else { - // Punti sulla griglia - Point3d ptGrSt( ( nCellJ + nStDeltaJ + 0.5) * m_dStep, 0, ( nCellI + nStDeltaI + 0.5) * m_dStep) ; - Point3d ptGrEn( ( nCellJ + nEnDeltaJ + 0.5) * m_dStep, 0, ( nCellI + nEnDeltaI + 0.5) * m_dStep) ; - // Corrispondenti punti sul piano - Point3d ptSt, ptEn ; - if ( IntersLinePlane( ptGrSt, Y_AX, 10, plPlane, ptSt, false) && - IntersLinePlane( ptGrEn, Y_AX, 10, plPlane, ptEn, false)) { - // Costruisco il tratto di curva - CurveLine cvLine ; - cvLine.Set( ptSt, ptEn) ; - vLine.emplace_back( cvLine) ; - } - } } + pLoop->SetExtrusion( plPlane.GetVersN()) ; + pLoop->MergeCurves( 10 * EPS_SMALL, ANG_TOL_STD_DEG) ; + // Inserisco la curva composita nella raccolta da ritornare + vpLoop.emplace_back( Release( pLoop)) ; } - - return true ; -} - -//---------------------------------------------------------------------------- -// Dato un dexel, identificato dal numero della sua griglia e dai suoi indici, -// determina se un suo intervallo attraversa il piano dato. -// Il numero di griglia e gli indici del dexel devono essere validi, se -// non lo sono, la funzione restituisce false, altrimenti cerca un -// tratto di dexel che intersechi il piano, se lo trova restituisce true, -// false altrimenti. -bool -VolZmap::InOut( const Plane3d& plPlane, int nGrid, int nI, int nJ) const -{ - // Se la griglia non esiste, vi è un errore. - if ( nGrid < 0 || nGrid > 2) - return false ; - // Se gli indici sono di frontiera per lo - // Zmap o non esistono, non sono interni. - if ( nI <= - 1 || nI >= int( m_nNx[nGrid]) || - nJ <= - 1 || nJ >= int( m_nNy[nGrid])) - return false ; - // Numero del dexel - int nDex = nJ * m_nNx[nGrid] + nI ; - - // Ciclo sui segmenti del dexel - bool bNotFound = true ; - for ( int nK = 0 ; nK < int( m_Values[nGrid][nDex].size()) ; ++ nK) { - if ( nGrid == 0) { - // Punti estremi del segmento - Point3d ptSt( ( nI + 0.5) * m_dStep, ( nJ + 0.5) * m_dStep, m_Values[nGrid][nDex][nK].dMin) ; - Point3d ptEn( ( nI + 0.5) * m_dStep, ( nJ + 0.5) * m_dStep, m_Values[nGrid][nDex][nK].dMax) ; - // Se il segmento interseca il piano abbiamo finito - Point3d ptInt ; - if ( IntersLinePlane( ptSt, ptEn, plPlane, ptInt)) - return true ; - } - else if ( nGrid == 1) { - // Punti estremi del segmento - Point3d ptSt( m_Values[nGrid][nDex][nK].dMin, ( nI + 0.5) * m_dStep, ( nJ + 0.5) * m_dStep) ; - Point3d ptEn( m_Values[nGrid][nDex][nK].dMax, ( nI + 0.5) * m_dStep, ( nJ + 0.5) * m_dStep) ; - // Se il segmento interseca il piano abbiamo finito - Point3d ptInt ; - if ( IntersLinePlane( ptSt, ptEn, plPlane, ptInt)) - return true ; - } - else { - // Punti estremi del segmento - Point3d ptSt( ( nJ + 0.5) * m_dStep, m_Values[nGrid][nDex][nK].dMin, ( nI + 0.5) * m_dStep) ; - Point3d ptEn( ( nJ + 0.5) * m_dStep, m_Values[nGrid][nDex][nK].dMax, ( nI + 0.5) * m_dStep) ; - // Se il segmento interseca il piano abbiamo finito - Point3d ptInt ; - if ( IntersLinePlane( ptSt, ptEn, plPlane, ptInt)) - return true ; - } - } - return false ; -} - -//---------------------------------------------------------------------------- -int -VolZmap::CalcIndexForPlaneCells( const Plane3d& plPlane, int nGrid, int nCellI, int nCellJ) const -{ - int nIndex = 0 ; - - if ( InOut( plPlane, nGrid, nCellI, nCellJ)) - nIndex |= ( 1 << 0) ; - if ( InOut( plPlane, nGrid, nCellI + 1, nCellJ)) - nIndex |= ( 1 << 1) ; - if ( InOut( plPlane, nGrid, nCellI + 1, nCellJ + 1)) - nIndex |= ( 1 << 2) ; - if ( InOut( plPlane, nGrid, nCellI, nCellJ + 1)) - nIndex |= ( 1 << 3) ; - return nIndex ; -} - -//---------------------------------------------------------------------------- -// dZ è una quota relativa alla mappa nGrid, se il dexel nDex esiste e -// dZ è interna a un suo intervallo restituisce true, false altrimenti. -bool -VolZmap::IsZInsideInterval( int nGrid, int nDex, double dZ) const -{ - // Se la griglia non esiste vi è un errore. - if ( nGrid < 0 || nGrid > 2) - return false ; - // Se il dexel non esiste vi è un errore. - if ( nDex < 0 && nDex > int( m_Values[nGrid].size() - 1)) - return false ; - // Valuto se dZ è interna a un intervallo. - for ( int nk = 0 ; nk < int( m_Values[nGrid][nDex].size()) ; ++ nk) { - double dZ1 = m_Values[nGrid][nDex][nk].dMin ; - double dZ2 = m_Values[nGrid][nDex][nk].dMax ; - // Se troviamo dZ in un intervallo abbiamo finito. - if ( dZ > dZ1 && dZ < dZ2) - return true ; - } - // dZ non sta in un intervallo. - return false ; -} - -//---------------------------------------------------------------------------- -// Box e piano devono essere nello stesso riferimento. Il box deve essere axis aligned. -bool -TestIntersPlaneBox( const BBox3d& b3Box, const Plane3d& plPlane) -{ - // Calcolo le distanze con segno dei punti dal piano - Point3d ptE0 = b3Box.GetMin() ; - double dDist0 = DistPointPlane( ptE0, plPlane) ; - Point3d ptE1( b3Box.GetMax().x, b3Box.GetMin().y, b3Box.GetMin().z) ; - double dDist1 = DistPointPlane( ptE1, plPlane) ; - Point3d ptE2( b3Box.GetMax().x, b3Box.GetMax().y, b3Box.GetMin().z) ; - double dDist2 = DistPointPlane( ptE2, plPlane) ; - Point3d ptE3( b3Box.GetMin().x, b3Box.GetMax().y, b3Box.GetMin().z) ; - double dDist3 = DistPointPlane( ptE3, plPlane) ; - Point3d ptE4( b3Box.GetMin().x, b3Box.GetMin().y, b3Box.GetMax().z) ; - double dDist4 = DistPointPlane( ptE4, plPlane) ; - Point3d ptE5( b3Box.GetMax().x, b3Box.GetMin().y, b3Box.GetMax().z) ; - double dDist5 = DistPointPlane( ptE5, plPlane) ; - Point3d ptE6 = b3Box.GetMax() ; - double dDist6 = DistPointPlane( ptE6, plPlane) ; - Point3d ptE7( b3Box.GetMin().x, b3Box.GetMax().y, b3Box.GetMax().z) ; - double dDist7 = DistPointPlane( ptE7, plPlane) ; - // Distanze tutte positive - if ( dDist0 > EPS_SMALL && dDist1 > EPS_SMALL && dDist2 > EPS_SMALL && dDist3 > EPS_SMALL && - dDist4 > EPS_SMALL && dDist5 > EPS_SMALL && dDist6 > EPS_SMALL && dDist7 > EPS_SMALL) - return false ; - // Distanze tutte negative - if ( dDist0 < - EPS_SMALL && dDist1 < - EPS_SMALL && dDist2 < - EPS_SMALL && dDist3 < - EPS_SMALL && - dDist4 < - EPS_SMALL && dDist5 < - EPS_SMALL && dDist6 < - EPS_SMALL && dDist7 < - EPS_SMALL) - return false ; - // Il piano interseca il box return true ; } diff --git a/VolZmapGraphics.cpp b/VolZmapGraphics.cpp index 2aad28a..e65235a 100644 --- a/VolZmapGraphics.cpp +++ b/VolZmapGraphics.cpp @@ -1971,7 +1971,7 @@ VolZmap::ExtMarchingCubes( int nBlock, VoxelContainer& vVox) const Vector3d vtNlm = ( CompoVert[nComp][l].ptPApp - ptSol) ^ ( CompoVert[nComp][m].ptPApp - ptSol) ; vtNlm.Normalize() ; double dDotl = vtNlm * CompoVert[nComp][l].vtVec ; - double dDotm = vtNlm * CompoVert[nComp][m].vtVec; + double dDotm = vtNlm * CompoVert[nComp][m].vtVec ; if ( dDotl < - 0.85 || dDotm < - 0.85) { bOverTurning = true ; break ; @@ -2000,6 +2000,44 @@ VolZmap::ExtMarchingCubes( int nBlock, VoxelContainer& vVox) const } } + // Gestione casi speciali: tutti i vettori quasi equiversi tranne uno + if ( bExtConfirmed && ( nVertComp[nComp] == 4 || nVertComp[nComp] == 5)) { + int nParNum = 0 ; + for ( int m = 0 ; m < nVertComp[nComp] - 1 ; ++ m) { + for ( int l = m + 1 ; l < nVertComp[nComp] ; ++ l) { + if ( CompoVert[nComp][m].vtVec * CompoVert[nComp][l].vtVec > 0.9) { + ++ nParNum ; + } + } + } + if ( nParNum == ( nVertComp[nComp] - 1) * ( nVertComp[nComp] - 2) / 2) { + int nNotParIndex = - 1 ; + for ( int m = 0 ; m < nVertComp[nComp] ; ++ m) { + int nNumDiff = 0 ; + for ( int l = 0 ; l < nVertComp[nComp] ; ++ l) { + if ( CompoVert[nComp][m].vtVec * CompoVert[nComp][l].vtVec <= 0.9) { + ++ nNumDiff ; + } + } + if ( nNumDiff == nVertComp[nComp] - 1) { + nNotParIndex = m ; + break ; + } + } + int nPrevL = nNotParIndex > 0 ? nNotParIndex - 1 : nVertComp[nComp] - 1 ; + int nNextL = nNotParIndex < nVertComp[nComp] - 1 ? nNotParIndex + 1 : 0 ; + Vector3d vtPrevN = ( CompoVert[nComp][nNotParIndex].ptPApp - ptSol) ^ ( CompoVert[nComp][nPrevL].ptPApp - ptSol) ; + Vector3d vtNextN = ( CompoVert[nComp][nNextL].ptPApp - ptSol) ^ ( CompoVert[nComp][nNotParIndex].ptPApp - ptSol) ; + vtPrevN.Normalize() ; + vtNextN.Normalize() ; + if ( nNotParIndex >= 0 && + CompoVert[nComp][nNotParIndex].vtVec * vtPrevN < - EPS_SMALL && + CompoVert[nComp][nNotParIndex].vtVec * vtNextN < - EPS_SMALL) { + bExtConfirmed = false ; + } + } + } + // ExtMC confermato if ( bExtConfirmed) { int tOldCompo = VoxConf.nNumComp ; @@ -3450,9 +3488,9 @@ VolZmap::IsValidVoxel( int nI, int nJ, int nK) const int nVoxNumY = int( m_nNy[0] / N_DEXVOXRATIO + ( m_nNy[0] % N_DEXVOXRATIO == 0 ? 1 : 2)) ; int nVoxNumZ = int( m_nNy[1] / N_DEXVOXRATIO + ( m_nNy[1] % N_DEXVOXRATIO == 0 ? 1 : 2)) ; // Verifico la validità del voxel - return ( nI >= - 1 && nI < nVoxNumX - 1 && - nJ >= - 1 && nJ < nVoxNumY - 1 && - nK >= - 1 && nK < nVoxNumZ - 1 ) ; + return ( nI >= -1 && nI <= nVoxNumX - 2 && + nJ >= -1 && nJ <= nVoxNumY - 2 && + nK >= -1 && nK <= nVoxNumZ - 2) ; } //---------------------------------------------------------------------------- @@ -3474,9 +3512,9 @@ VolZmap::GetVoxIJKFromN( int nN, int& nI, int& nJ, int& nK) const nK = ( nN / ( nVoxNumX * nVoxNumY)) - 1 ; // Controllo la sensatezza del risultato ottenuto - return ( nI >= - 1 && nI < nVoxNumX - 1 && - nJ >= - 1 && nJ < nVoxNumY - 1 && - nK >= - 1 && nK < nVoxNumZ - 1 ) ; + return ( nI >= -1 && nI <= nVoxNumX - 2 && + nJ >= -1 && nJ <= nVoxNumY - 2 && + nK >= -1 && nK <= nVoxNumZ - 2) ; } //---------------------------------------------------------------------------- @@ -3489,9 +3527,9 @@ VolZmap::GetVoxNFromIJK( int nI, int nJ, int nK, int& nN) const int nVoxNumZ = int( m_nNy[1] / N_DEXVOXRATIO + ( m_nNy[1] % N_DEXVOXRATIO == 0 ? 1 : 2)) ; // Controllo la validità del voxel - if ( nI <= - 2 || nI >= nVoxNumX - 1 || - nJ <= - 2 || nJ >= nVoxNumY - 1 || - nK <= - 2 || nK >= nVoxNumZ - 1 ) + if ( nI < -1 || nI > nVoxNumX - 2 || + nJ < -1 || nJ > nVoxNumY - 2 || + nK < -1 || nK > nVoxNumZ - 2) return false ; // Calcolo il numero di Voxel @@ -3501,6 +3539,32 @@ VolZmap::GetVoxNFromIJK( int nI, int nJ, int nK, int& nN) const return ( nN >= 0 && nN < nVoxNumX * nVoxNumY * nVoxNumZ) ; } +//---------------------------------------------------------------------------- +bool +VolZmap::GetVoxelBox( int nI, int nJ, int nK, BBox3d& b3VoxBox) const +{ + // Calcolo il numero di voxel lungo X,Y e Z + int nVoxNumX = int( m_nNx[0] / N_DEXVOXRATIO + ( m_nNx[0] % N_DEXVOXRATIO == 0 ? 1 : 2)) ; + int nVoxNumY = int( m_nNy[0] / N_DEXVOXRATIO + ( m_nNy[0] % N_DEXVOXRATIO == 0 ? 1 : 2)) ; + int nVoxNumZ = int( m_nNy[1] / N_DEXVOXRATIO + ( m_nNy[1] % N_DEXVOXRATIO == 0 ? 1 : 2)) ; + + // Controllo la validità del voxel + if ( nI < -1 || nI > nVoxNumX - 2 || + nJ < -1 || nJ > nVoxNumY - 2 || + nK < -1 || nK > nVoxNumZ - 2) + return false ; + + // Punti della diagonale del voxel + Point3d ptCubeInf( ( nI * N_DEXVOXRATIO + 0.5) * m_dStep, + ( nJ * N_DEXVOXRATIO + 0.5) * m_dStep, + ( nK * N_DEXVOXRATIO + 0.5) * m_dStep) ; + Point3d ptCubeSup( ( ( nI + 1) * N_DEXVOXRATIO + 0.5) * m_dStep, + ( ( nJ + 1) * N_DEXVOXRATIO + 0.5) * m_dStep, + ( ( nK + 1) * N_DEXVOXRATIO + 0.5) * m_dStep) ; + b3VoxBox.Set( ptCubeInf, ptCubeSup) ; + return true ; +} + //---------------------------------------------------------------------------- bool VolZmap::GetBlockIJKFromN( int nBlock, int nIJK[]) const @@ -3538,9 +3602,9 @@ bool VolZmap::GetBlockLimitsIJK( const int nIJK[], int nLimits[]) const { // Controllo sulla validità degli indici i, j, k del blocco - if ( nIJK[0] < 0 || nIJK[0] >= int( m_nFracLin[0]) || - nIJK[1] < 0 || nIJK[1] >= int( m_nFracLin[1]) || - nIJK[2] < 0 || nIJK[2] >= int( m_nFracLin[2])) + if ( nIJK[0] < 0 || nIJK[0] >= m_nFracLin[0] || + nIJK[1] < 0 || nIJK[1] >= m_nFracLin[1] || + nIJK[2] < 0 || nIJK[2] >= m_nFracLin[2]) return false ; // Calcolo il numero di voxel lungo X,Y e Z @@ -3549,23 +3613,42 @@ VolZmap::GetBlockLimitsIJK( const int nIJK[], int nLimits[]) const int nVoxNumZ = int( m_nNy[1] / N_DEXVOXRATIO + ( m_nNy[1] % N_DEXVOXRATIO == 0 ? 1 : 2)) ; // Calcolo limiti per l'indice i - nLimits[0] = ( nIJK[0] == 0 ? - 1 : nIJK[0] * int( m_nVoxNumPerBlock)) ; - nLimits[1] = ( nIJK[0] + 1 == int( m_nFracLin[0]) ? - nVoxNumX - 1 : ( nIJK[0] + 1) * int( m_nVoxNumPerBlock)) ; + nLimits[0] = ( nIJK[0] == 0 ? - 1 : nIJK[0] * m_nVoxNumPerBlock) ; + nLimits[1] = ( nIJK[0] + 1 == m_nFracLin[0] ? + nVoxNumX - 1 : ( nIJK[0] + 1) * m_nVoxNumPerBlock) ; // Calcolo limiti per l'indice j - nLimits[2] = ( nIJK[1] == 0 ? - 1 : nIJK[1] * int( m_nVoxNumPerBlock)) ; - nLimits[3] = ( nIJK[1] + 1 == int( m_nFracLin[1]) ? - nVoxNumY - 1 : ( nIJK[1] + 1) * int( m_nVoxNumPerBlock)) ; + nLimits[2] = ( nIJK[1] == 0 ? - 1 : nIJK[1] * m_nVoxNumPerBlock) ; + nLimits[3] = ( nIJK[1] + 1 == m_nFracLin[1] ? + nVoxNumY - 1 : ( nIJK[1] + 1) * m_nVoxNumPerBlock) ; // Calcolo limiti per l'indice k - nLimits[4] = ( nIJK[2] == 0 ? - 1 : nIJK[2] * int( m_nVoxNumPerBlock)) ; - nLimits[5] = ( nIJK[2] + 1 == int( m_nFracLin[2]) ? - nVoxNumZ - 1 : ( nIJK[2] + 1) * int( m_nVoxNumPerBlock)) ; + nLimits[4] = ( nIJK[2] == 0 ? - 1 : nIJK[2] * m_nVoxNumPerBlock) ; + nLimits[5] = ( nIJK[2] + 1 == m_nFracLin[2] ? + nVoxNumZ - 1 : ( nIJK[2] + 1) * m_nVoxNumPerBlock) ; return true ; } +//---------------------------------------------------------------------------- +bool +VolZmap::GetBlockBox( const int nIJK[], BBox3d& b3VoxBox) const +{ + // Calcolo limiti sugli indici del blocco; se il blocco non è valido, errore + int nLimits[6] ; + if ( ! GetBlockLimitsIJK( nIJK, nLimits)) + return false ; + // Costruisco il bounding-bx del blocco + Point3d ptMinDiag( ( nLimits[0] * N_DEXVOXRATIO + 0.5) * m_dStep, + ( nLimits[2] * N_DEXVOXRATIO + 0.5) * m_dStep, + ( nLimits[4] * N_DEXVOXRATIO + 0.5) * m_dStep) ; + Point3d ptMaxDiag( ( nLimits[1] * N_DEXVOXRATIO + 0.5) * m_dStep, + ( nLimits[3] * N_DEXVOXRATIO + 0.5) * m_dStep, + ( nLimits[5] * N_DEXVOXRATIO + 0.5) * m_dStep) ; + b3VoxBox.Set( ptMinDiag, ptMaxDiag) ; + return true ; +} + //---------------------------------------------------------------------------- bool VolZmap::IsPointInsideVoxelApprox( int nI, int nJ, int nK, const Point3d& ptP, double dPrec) const @@ -3575,9 +3658,9 @@ VolZmap::IsPointInsideVoxelApprox( int nI, int nJ, int nK, const Point3d& ptP, d int nVoxNumY = int( m_nNy[0] / N_DEXVOXRATIO + ( m_nNy[0] % N_DEXVOXRATIO == 0 ? 1 : 2)) ; int nVoxNumZ = int( m_nNy[1] / N_DEXVOXRATIO + ( m_nNy[1] % N_DEXVOXRATIO == 0 ? 1 : 2)) ; // Controllo sulla validità del voxel - if ( nI <= - 2 || nI >= nVoxNumX - 1 || - nJ <= - 2 || nJ >= nVoxNumY - 1 || - nK <= - 2 || nK >= nVoxNumZ - 1 ) + if ( nI < -1 || nI > nVoxNumX - 2 || + nJ < -1 || nJ > nVoxNumY - 2 || + nK < -1 || nK > nVoxNumZ - 2) return false ; // Se la tolleranza è minore di EPS_SMALL, la considero nulla if ( dPrec < EPS_ZERO) @@ -3606,9 +3689,9 @@ VolZmap::GetPointVoxel( const Point3d& ptP, int& nVoxI, int& nVoxJ, int& nVoxK) nVoxJ = int( floor( ( ptP.y - 0.5 * m_dStep) / ( m_dStep * N_DEXVOXRATIO))) ; nVoxK = int( floor( ( ptP.z - 0.5 * m_dStep) / ( m_dStep * N_DEXVOXRATIO))) ; // Controllo la validità del voxel - return ( nVoxI >= - 1 && nVoxI < nVoxNumX - 1) && - ( nVoxJ >= - 1 && nVoxJ < nVoxNumY - 1) && - ( nVoxK >= - 1 && nVoxK < nVoxNumZ - 1) ; + return ( nVoxI >= - 1 && nVoxI <= nVoxNumX - 2 && + nVoxJ >= - 1 && nVoxJ <= nVoxNumY - 2 && + nVoxK >= - 1 && nVoxK <= nVoxNumZ - 2) ; } //---------------------------------------------------------------------------- @@ -3620,9 +3703,9 @@ VolZmap::GetVoxelBlockIJK( const int nVoxIJK[], int nBlockIJK[]) const int nVoxNumY = int( m_nNy[0] / N_DEXVOXRATIO + ( m_nNy[0] % N_DEXVOXRATIO == 0 ? 1 : 2)) ; int nVoxNumZ = int( m_nNy[1] / N_DEXVOXRATIO + ( m_nNy[1] % N_DEXVOXRATIO == 0 ? 1 : 2)) ; // Controllo sull'ammissibilità del voxel - if ( nVoxIJK[0] <= - 2 || nVoxIJK[0] >= nVoxNumX - 1 || - nVoxIJK[1] <= - 2 || nVoxIJK[1] >= nVoxNumY - 1 || - nVoxIJK[2] <= - 2 || nVoxIJK[2] >= nVoxNumZ - 1 ) + if ( nVoxIJK[0] < -1 || nVoxIJK[0] > nVoxNumX - 2 || + nVoxIJK[1] < -1 || nVoxIJK[1] > nVoxNumY - 2 || + nVoxIJK[2] < -1 || nVoxIJK[2] > nVoxNumZ - 2) return false ; // Divisioni intere int nIntRatio0 = nVoxIJK[0] / m_nVoxNumPerBlock ; @@ -3636,14 +3719,25 @@ VolZmap::GetVoxelBlockIJK( const int nVoxIJK[], int nBlockIJK[]) const return true ; } +//---------------------------------------------------------------------------- +bool +VolZmap::GetVoxelBlockN( int nVox, int& nBlock) const +{ + int nVoxIJK[3] ; + int nBlockIJK[3] ; + return ( GetVoxIJKFromN( nVox, nVoxIJK[0], nVoxIJK[1], nVoxIJK[2]) && + GetVoxelBlockIJK( nVoxIJK, nBlockIJK) && + GetBlockNFromIJK( nBlockIJK, nBlock)) ; +} + //---------------------------------------------------------------------------- bool VolZmap::GetAdjBlockToBlock( int nBlockN, int nDeltaI, int nDeltaJ, int nDeltaK, int& nAdjBlockN) const { // Test sulla validità degli incrementi su i,j,k - if ( nDeltaI < - 1 || nDeltaI > 1 || - nDeltaJ < - 1 || nDeltaJ > 1 || - nDeltaK < - 1 || nDeltaK > 1) + if ( nDeltaI < -1 || nDeltaI > 1 || + nDeltaJ < -1 || nDeltaJ > 1 || + nDeltaK < -1 || nDeltaK > 1) return false ; // Determino blocco adiacente @@ -3666,18 +3760,18 @@ VolZmap::IsAVoxelOnBoundary( const int nLimits[], const int nIJK[], bool bType) int nVoxNumZ = int( m_nNy[1] / N_DEXVOXRATIO + ( m_nNy[1] % N_DEXVOXRATIO == 0 ? 1 : 2)) ; // Test sulla validità dei limiti - if ( nLimits[0] < - 1 || nLimits[0] > nVoxNumX - 1 || - nLimits[1] < - 1 || nLimits[1] > nVoxNumX - 1 || - nLimits[2] < - 1 || nLimits[2] > nVoxNumY - 1 || - nLimits[3] < - 1 || nLimits[3] > nVoxNumY - 1 || - nLimits[4] < - 1 || nLimits[4] > nVoxNumZ - 1 || - nLimits[5] < - 1 || nLimits[5] > nVoxNumZ - 1 ) + if ( nLimits[0] < -1 || nLimits[0] > nVoxNumX - 1 || + nLimits[1] < -1 || nLimits[1] > nVoxNumX - 1 || + nLimits[2] < -1 || nLimits[2] > nVoxNumY - 1 || + nLimits[3] < -1 || nLimits[3] > nVoxNumY - 1 || + nLimits[4] < -1 || nLimits[4] > nVoxNumZ - 1 || + nLimits[5] < -1 || nLimits[5] > nVoxNumZ - 1 ) return false ; // Controllo sull'ammissibilità del voxel - if ( nIJK[0] <= -2 || nIJK[0] > nVoxNumX - 2 || - nIJK[1] <= -2 || nIJK[1] > nVoxNumY - 2 || - nIJK[2] <= -2 || nIJK[2] > nVoxNumZ - 2) + if ( nIJK[0] < -1 || nIJK[0] > nVoxNumX - 2 || + nIJK[1] < -1 || nIJK[1] > nVoxNumY - 2 || + nIJK[2] < -1 || nIJK[2] > nVoxNumZ - 2) return false ; // Se cerchiamo i voxel che sono sulla frontiera del blocco @@ -3707,9 +3801,9 @@ VolZmap::IsAVoxelOnBoundary( const int nLimits[], const int nIJK[], bool bType) // Determino (se esiste) il blocco in cui cade il voxel adiacente. int nAdjBlockIJK[3] ; if ( GetVoxelBlockIJK( nAdjIJK, nAdjBlockIJK)) { - if ( nAdjBlockIJK[0] > -1 && nAdjBlockIJK[0] < int( m_nFracLin[0]) && - nAdjBlockIJK[1] > -1 && nAdjBlockIJK[1] < int( m_nFracLin[1]) && - nAdjBlockIJK[2] > -1 && nAdjBlockIJK[2] < int( m_nFracLin[2]) && + if ( nAdjBlockIJK[0] > -1 && nAdjBlockIJK[0] < m_nFracLin[0] && + nAdjBlockIJK[1] > -1 && nAdjBlockIJK[1] < m_nFracLin[1] && + nAdjBlockIJK[2] > -1 && nAdjBlockIJK[2] < m_nFracLin[2] && ( nCurrentBlockIJK[0] != nAdjBlockIJK[0] || nCurrentBlockIJK[1] != nAdjBlockIJK[1] || nCurrentBlockIJK[2] != nAdjBlockIJK[2])) { @@ -3732,17 +3826,17 @@ VolZmap::IsAVoxelOnBoundary( const int nLimits[], const int nIJK[], int nDeltaIn int nVoxNumY = int( m_nNy[0] / N_DEXVOXRATIO + ( m_nNy[0] % N_DEXVOXRATIO == 0 ? 1 : 2)) ; int nVoxNumZ = int( m_nNy[1] / N_DEXVOXRATIO + ( m_nNy[1] % N_DEXVOXRATIO == 0 ? 1 : 2)) ; // Test sulla validità dei limiti - if ( nLimits[0] < - 1 || nLimits[0] > nVoxNumX - 1 || - nLimits[1] < - 1 || nLimits[1] > nVoxNumX - 1 || - nLimits[2] < - 1 || nLimits[2] > nVoxNumY - 1 || - nLimits[3] < - 1 || nLimits[3] > nVoxNumY - 1 || - nLimits[4] < - 1 || nLimits[4] > nVoxNumZ - 1 || - nLimits[5] < - 1 || nLimits[5] > nVoxNumZ - 1 ) + if ( nLimits[0] < -1 || nLimits[0] > nVoxNumX - 1 || + nLimits[1] < -1 || nLimits[1] > nVoxNumX - 1 || + nLimits[2] < -1 || nLimits[2] > nVoxNumY - 1 || + nLimits[3] < -1 || nLimits[3] > nVoxNumY - 1 || + nLimits[4] < -1 || nLimits[4] > nVoxNumZ - 1 || + nLimits[5] < -1 || nLimits[5] > nVoxNumZ - 1 ) return false ; // Controllo sull'ammissibilità del voxel - if ( nIJK[0] <= -2 || nIJK[0] > nVoxNumX - 2 || - nIJK[1] <= -2 || nIJK[1] > nVoxNumY - 2 || - nIJK[2] <= -2 || nIJK[2] > nVoxNumZ - 2) + if ( nIJK[0] < -1 || nIJK[0] > nVoxNumX - 2 || + nIJK[1] < -1 || nIJK[1] > nVoxNumY - 2 || + nIJK[2] < -1 || nIJK[2] > nVoxNumZ - 2) return false ; nDeltaIndex[0] = 0 ; nDeltaIndex[1] = 0 ;