diff --git a/EGkHashGrids1d.h b/EGkHashGrids1d.h new file mode 100644 index 0000000..cbdfb49 --- /dev/null +++ b/EGkHashGrids1d.h @@ -0,0 +1,76 @@ +//---------------------------------------------------------------------------- +// EgalTech 2015-2018 +//---------------------------------------------------------------------------- +// File : EGkHashGrids1d.h Data : 02.05.21 Versione : 2.4e1 +// Contenuto : Dichiarazione della classe HashGrids1d. +// +// +// +// Modifiche : 04.07.15 DS Creazione modulo. +// +// +//---------------------------------------------------------------------------- + +#pragma once + +#include "EgtDev/Include/EGkBBox3d.h" +#include "EgtDev/Include/EgtNumCollection.h" +#include + +//----------------------- Macro per import/export ---------------------------- +#undef EGK_EXPORT +#if defined( I_AM_EGK) // da definirsi solo nella DLL +#define EGK_EXPORT __declspec( dllexport) +#else +#define EGK_EXPORT __declspec( dllimport) +#endif + +//---------------------------------------------------------------------------- +class HashGrids1d +{ +public : + EGK_EXPORT HashGrids1d( void) ; + EGK_EXPORT ~HashGrids1d( void) ; + EGK_EXPORT void SetActivationGrid( bool bActivate) ; + EGK_EXPORT bool Add( int nObjId, const BBox3d& box) ; + EGK_EXPORT bool Modify( int nObjId, const BBox3d& box) ; + EGK_EXPORT bool Remove( int nObjId) ; + EGK_EXPORT bool Update( void) ; + EGK_EXPORT bool Find( const BBox3d& b3Test, INTVECTOR& vnIds) const ; + EGK_EXPORT void Clear( void) ; + + friend class HashGrid1d ; + +private : + struct ObjData { + int nId ; + BBox3d box ; + HashGrid1d* pHGrid ; + size_t nHash ; + size_t nCellId ; + ObjData( void) + : nId( -1), box(), pHGrid( nullptr), nHash( 0), nCellId( 0) {} + ObjData( int nI, const BBox3d& bb, HashGrid1d* pHG, size_t nH, size_t nCI) + : nId( nI), box( bb), pHGrid( pHG), nHash( nH), nCellId( nCI) {} + } ; + typedef std::list ObjList ; + typedef std::vector PtrObjVector ; + typedef std::unordered_map IntPObjUmap ; + +private : + typedef std::list GridList ; // Tipo per lista di hash grid + +private : + void addGrid( ObjData& obj) ; + void addList( ObjData& obj) ; + +private : + ObjList m_ObjsList ; // Lista degli oggetti + IntPObjUmap m_ObjsMap ; // Map da Id a PtrObj + PtrObjVector m_objsToAdd ; // Vettore di puntatori agli oggetti da inserire + PtrObjVector m_nonGridObjs ; // Vettore di puntatori agli oggetti non assegnati alle griglie (per dimensioni o perchè pochi) + GridList m_GridList ; // Lista delle griglie di dimensione fissa ( in ordine crescente di dimensione di cella) + bool m_bActivate ; // Flag che abilita l'attivazione delle griglie + bool m_bGridActive ; // Flag di attivazione delle griglie + BBox3d m_b3Objs ; // Box totale di tutti gli oggetti inseriti +} ; diff --git a/EGkIntersPlaneSurfTm.h b/EGkIntersPlaneSurfTm.h index 12fcbdf..a06e2f2 100644 --- a/EGkIntersPlaneSurfTm.h +++ b/EGkIntersPlaneSurfTm.h @@ -14,6 +14,7 @@ #pragma once #include "/EgtDev/Include/EGkSurfTriMesh.h" +#include "/EgtDev/Include/EGkHashGrids1d.h" //----------------------- Macro per import/export ---------------------------- #undef EGK_EXPORT @@ -26,3 +27,18 @@ //----------------------------------------------------------------------------- EGK_EXPORT bool IntersPlaneSurfTm( const Plane3d& plPlane, const ISurfTriMesh& Stm, PNTVECTOR& vPnt, BIPNTVECTOR& vBpt, TRIA3DVECTOR& vTria) ; + + +//----------------------------------------------------------------------------- +class IntersParPlanesSurfTm +{ +public : + EGK_EXPORT IntersParPlanesSurfTm( const Frame3d& frPlanes, const ISurfTriMesh& Stm) ; + EGK_EXPORT bool GetInters( const Point3d& ptPl, PNTVECTOR& vPnt, BIPNTVECTOR& vBpt, TRIA3DVECTOR& vTria) const ; + +private : + bool m_bOk ; + const Frame3d m_frPlanes ; + const ISurfTriMesh* m_pSTm ; + HashGrids1d m_HGrids ; +} ; \ No newline at end of file diff --git a/EXeExecutor.h b/EXeExecutor.h index 5428d62..76a3545 100644 --- a/EXeExecutor.h +++ b/EXeExecutor.h @@ -737,6 +737,8 @@ EXE_EXPORT int ExePlaneBoxInters( const Point3d& ptOn, const Vector3d& vtN, con EXE_EXPORT bool ExeLineSurfTmInters( const Point3d& ptP, const Vector3d& vtDir, int nId, int nRefType, INTDBLVECTOR& vInters) ; EXE_EXPORT int ExePlaneSurfTmInters( const Point3d& ptOn, const Vector3d& vtN, int nId, int nDestGrpId, int nRefType, double dToler, int* pnPntCount, int* pnCrvCount, int* pnSrfCount) ; +EXE_EXPORT int ExeParPlanesSurfTmInters( const Vector3d& vtN, const PNTVECTOR& vPntPlanes, int nId, int nDestGrpId, int nRefType, double dToler, + int* pnGrpCount) ; EXE_EXPORT int ExeSurfTmSurfTmInters( int nId1, int nId2, int nDestGrpId, double dToler, int* pnPntCount, int* pnCrvCount, int* pnSrfCount) ; EXE_EXPORT bool ExeLineVolZmapInters( const Point3d& ptP, const Vector3d& vtDir, int nId, int nRefType, INTDBLVECTOR& vInters) ;