EgtGeomKernel :

- aggiunta delle intersezioni tra linee e SupBez.
This commit is contained in:
Daniele Bariletti
2024-02-08 09:28:49 +01:00
parent 6b5de066b7
commit b4058ad363
4 changed files with 111 additions and 2 deletions
+2
View File
@@ -309,6 +309,7 @@ copy $(TargetPath) \EgtProg\Dll64</Command>
<ClCompile Include="CurveByApprox.cpp" />
<ClCompile Include="CurveByInterp.cpp" />
<ClCompile Include="CurveCompositeOffset.cpp" />
<ClCompile Include="IntersLineSurfBez.cpp" />
<ClCompile Include="PolygonElevation.cpp" />
<ClCompile Include="Voronoi.cpp" />
<ClInclude Include="..\Include\EGkCDeClosedSurfTmClosedSurfTm.h" />
@@ -449,6 +450,7 @@ copy $(TargetPath) \EgtProg\Dll64</Command>
<ClCompile Include="VolZmapGraphics.cpp" />
<ClCompile Include="VolZmapVolume.cpp" />
<ClCompile Include="VolZmap.cpp" />
<ClInclude Include="IntersLineSurfBez.h" />
<ClInclude Include="Voronoi.h" />
</ItemGroup>
<ItemGroup>
+108
View File
@@ -0,0 +1,108 @@
//----------------------------------------------------------------------------
// EgalTech 2024
//----------------------------------------------------------------------------
// File : IntersLineSurfBez.cpp Data : 06.02.24 Versione : 2.6b1
// Contenuto : Implementazione della intersezione linea/superficie bezier.
//
//
//
// Modifiche : 06.02.24 DB Creazione modulo.
//
//
//----------------------------------------------------------------------------
//--------------------------- Include ----------------------------------------
#include "stdafx.h"
#include "IntersLineBox.h"
#include "/EgtDev/Include/EGkIntersLineTria.h"
#include "/EgtDev/Include/EGkIntersLineSurfTm.h"
#include "/EgtDev/Include/EGkIntersLineSurfBez.h"
#include "/EgtDev/Include/EGkSurfBezier.h"
using namespace std ;
//----------------------------------------------------------------------------
// Intersezione di una linea con una superficie TriMesh
//----------------------------------------------------------------------------
bool
IntersLineSurfBz( const Point3d& ptL, const Vector3d& vtL, double dLen, const ISurfBezier& SBz,
ILSBIVECTOR& vInfo, bool bFinite)
{
// verifico linea
Vector3d vtDir = vtL ;
if ( ! vtDir.Normalize( EPS_ZERO))
return false ;
// verifico superficie
if ( &SBz == nullptr)
return false ;
// verifico parametro di ritorno
if ( &vInfo == nullptr)
return false ;
vInfo.clear() ;
// trovo le intersezioni con la trimesh ausiliaria
const ISurfTriMesh* pSurfTm = SBz.GetAuxSurf() ;
ILSIVECTOR vInfoTm ;
if ( ! IntersLineSurfTm( ptL, vtL, dLen, *pSurfTm, vInfoTm, bFinite))
return false ;
// ricavo le intersezioni con la superficie di Bezier
for ( IntLinStmInfo InfoTm : vInfoTm ) {
int nIL, nTT ;
double dUU, dUU2, dCos ;
Point3d ptP, ptP2, ptSP, ptSP2 ;
IntLinSbzInfo InfoBz( InfoTm.nILTT, dUU, dUU2, nTT, dCos, ptP, ptP2, ptSP, ptSP2) ;
vInfo.emplace_back( InfoBz) ;
}
//////////////////////////////////////////////////////// interlineSurfTm
// limito la linea al box dei triangoli della superficie
BBox3d b3Stm = Stm.GetAllTriaBox() ;
if ( b3Stm.IsEmpty())
return false ;
// lo ingrandisco per non avere problemi con faccia piana su piani canonici
b3Stm.Expand( 10 * EPS_SMALL) ;
double dU1, dU2 ;
if ( ! IntersLineBox( ptL, vtL, b3Stm.GetMin() , b3Stm.GetMax(), dU1, dU2))
return true ;
if ( bFinite) {
dU1 = max( dU1, 0.) ;
dU2 = min( dU2, dLen) ;
if ( dU2 - dU1 < EPS_SMALL)
return true ;
}
Point3d ptStart = ptL + dU1 * vtL ;
double dLenEff = dU2 - dU1 ;
// cerco i triangoli intersecati dalla linea
const double BOX_STEP = 10 ;
int nStep = int( ceil( dLenEff / BOX_STEP)) ;
Vector3d vtStep = dLenEff / nStep * vtL ;
INTVECTOR vPrevT ;
for ( int i = 0 ; i < nStep ; ++ i) {
BBox3d b3Box( ptStart + i * vtStep, ptStart + ( i + 1) * vtStep) ;
INTVECTOR vT ;
if ( Stm.GetAllTriaOverlapBox( b3Box, vT)) {
for ( auto nT : vT) {
if ( find( vPrevT.begin(), vPrevT.end(), nT) == vPrevT.end()) {
vPrevT.emplace_back( nT) ;
Triangle3d Tria ;
Stm.GetTriangle( nT, Tria) ;
// aggiorno info con intersezione
UpdateInfoIntersLineSurfTm( ptL, vtDir, dLen, nT, Tria, vInfo, bFinite) ;
}
}
}
}
// ordino il vettore delle eventuali intersezioni secondo il senso crescente del parametro di linea
OrderInfoIntersLineSurfTm( vInfo) ;
return true ;
//////////////////////////////////////////////////////// interlineSurfTm
return true ;
}
+1
View File
@@ -0,0 +1 @@
#pragma once
-2
View File
@@ -257,9 +257,7 @@ class SurfTriMesh : public ISurfTriMesh, public IGeoObjRW
bool GetVertex( int nId, Point3d& ptP) const override ;
bool GetVertexParam( int nId, double& dU, double& dV) const override ;
int GetFirstVertex( Point3d& ptP) const override ;
int GetFirstVertexParam( int nId, double& dU, double& dV) const override ;
int GetNextVertex( int nId, Point3d& ptP) const override ;
int GetNextVertexParam( int nId, double& dU, double& dV) const override ;
bool GetTriangle( int nId, int nIdVert[3]) const override ;
int GetFirstTriangle( int nIdVert[3]) const override ;
int GetNextTriangle( int nId, int nIdVert[3]) const override ;