diff --git a/EGkCAvSilhouetteSurfTm.h b/EGkCAvSilhouetteSurfTm.h new file mode 100644 index 0000000..48381ee --- /dev/null +++ b/EGkCAvSilhouetteSurfTm.h @@ -0,0 +1,39 @@ +//---------------------------------------------------------------------------- +// EgalTech 2024-2024 +//---------------------------------------------------------------------------- +// File : EGkCAvSilhouetteSurfTm.h Data : 08.06.24 Versione : 2.6f2 +// Contenuto : Dichiarazione della funzione calcolo silhouette. +// +// +// +// Modifiche : 08.06.24 DS Creazione modulo. +// +// +//---------------------------------------------------------------------------- + +#pragma once + +#include "/EgtDev/Include/EGkSurfTriMesh.h" + +//----------------------- 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 + +//----------------------------------------------------------------------------- +EGK_EXPORT bool CAvSilhouetteSurfTm( const ISurfTriMesh& Stm, const Plane3d& plPlane, double dTol, POLYLINEVECTOR& vPL) ; + +//----------------------------------------------------------------------------- +class __declspec( novtable) ICAvParSilhouettesSurfTm +{ + public : + virtual ~ICAvParSilhouettesSurfTm( void) {} + virtual bool SetData( const CISURFTMPVECTOR& vpStm, const Frame3d& frPlanes, double dTol) = 0 ; + virtual bool GetSilhouette( double dLevel, POLYLINEVECTOR& vPL) = 0 ; +} ; + +//----------------------------------------------------------------------------- +EGK_EXPORT ICAvParSilhouettesSurfTm* CreateCAvParSilhouettesSurfTm( void) ; diff --git a/EGkCAvToolSurfTm.h b/EGkCAvToolSurfTm.h index d782334..176ea05 100644 --- a/EGkCAvToolSurfTm.h +++ b/EGkCAvToolSurfTm.h @@ -23,6 +23,8 @@ #define EGK_EXPORT __declspec( dllimport) #endif +class ICurveComposite ; + //----------------------------------------------------------------------------- class __declspec( novtable) ICAvToolSurfTm { public : @@ -37,6 +39,7 @@ class __declspec( novtable) ICAvToolSurfTm { virtual double GetToolHeight( void) const = 0 ; virtual const ICurveComposite& GetToolOutline( bool bApprox = false) const = 0 ; virtual bool TestPosition( const Point3d& ptT, const Vector3d& vtDir, const Vector3d& vtMove, double& dTotDist) = 0 ; + virtual bool TestSeries( PNTUVECTOR& vPntM, const Vector3d& vtDir, const Vector3d& vtMove, double dProgCoeff = 1) = 0 ; virtual bool TestPath( PNTULIST& lPntM, const Vector3d& vtDir, const Vector3d& vtMove, double dLinTol, double dProgCoeff = 1) = 0 ; } ; diff --git a/EGkFrame3d.h b/EGkFrame3d.h index 5fb7f16..05ee1f8 100644 --- a/EGkFrame3d.h +++ b/EGkFrame3d.h @@ -116,11 +116,22 @@ operator/( const Frame3d& frRef, const Frame3d& frDest) return frNew ; } +//---------------------------------------------------------------------------- +//! Restituisce il frame inverso di quello passato +//---------------------------------------------------------------------------- +inline const Frame3d +GetInvert( const Frame3d& frRef) +{ + Frame3d frNew = GLOB_FRM ; + frNew.ToLoc( frRef) ; + return frNew ; +} + //---------------------------------------------------------------------------- //! Restituisce una copia in locale del frame passato //---------------------------------------------------------------------------- inline const Frame3d -GetToLoc ( const Frame3d& frRef, const Frame3d& frDest) +GetToLoc( const Frame3d& frRef, const Frame3d& frDest) { Frame3d frNew = frRef ; frNew.ToLoc( frDest) ; diff --git a/EGkGeoObjSave.h b/EGkGeoObjSave.h index 7f2b170..c6ca6fd 100644 --- a/EGkGeoObjSave.h +++ b/EGkGeoObjSave.h @@ -21,7 +21,7 @@ bool SaveGeoObj( IGeoObj* pGObj, const std::string& sFile, int nFlag = GDB_SV_BIN) { - // verifico validità oggetto + // verifico validità oggetto if ( pGObj == nullptr || ! pGObj->IsValid()) return false ; // creo GeomDB temporaneo @@ -47,7 +47,7 @@ bool SaveGeoObj( std::vector vpGObj, const std::string& sFile, int nFlag = GDB_SV_BIN) { for ( int i = 0 ; i < int( vpGObj.size()); ++i) { - // verifico validità oggetto + // verifico validità oggetto if ( vpGObj[i] == nullptr || ! vpGObj[i]->IsValid() ) return false ; } @@ -75,4 +75,106 @@ SaveGeoObj( std::vector vpGObj, const std::string& sFile, int nFlag = bOk = ( pGeomDB->RemoveGeoObjAndErase( vIds[i]) != nullptr ) && bOk ; return bOk ; +} + +//---------------------------------------------------------------------------- +bool +SaveGeoObj( std::vector> vvpGObj, std::vector vCol, + const std::string& sFile, int nFlag = GDB_SV_BIN) +{ + // verifico validità oggetti + for ( int i = 0 ; i < int( vvpGObj.size()) ; ++ i) { + for ( int j = 0 ; j < int( vvpGObj[i].size()) ; ++ j) { + if ( vvpGObj[i][j] == nullptr || ! vvpGObj[i][j]->IsValid()) + return false ; + } + } + if ( int( vCol.size()) <= int( vvpGObj.size())) { + for ( int i = int( vCol.size()) ; i < int( vvpGObj.size()) ; ++ i) + vCol.push_back( BLACK) ; + } + else + return false ; + + // creo GeomDB temporaneo + PtrOwner pGeomDB( CreateGeomDB()) ; + if ( IsNull( pGeomDB)) + return false ; + INTVECTOR vIds ; + int nLayId = 0 ; + + // creo il part + int nPartId = pGeomDB->AddGroup( GDB_ID_NULL, GDB_ID_ROOT, Frame3d()) ; + + // per ogni elemento i-esimo, creo un layer + for ( int i = 0 ; i < int( vvpGObj.size()) ; ++i) { + // creo il layer + nLayId = pGeomDB->AddGroup( GDB_ID_NULL, nPartId, Frame3d()) ; + pGeomDB->SetMaterial( nLayId, vCol[i]) ; + + for ( int j = 0 ; j < int( vvpGObj.size()) ; ++ j) { + // inserisco gli oggetti corrispondenti + int nId = pGeomDB->AddGeoObj( GDB_ID_NULL, nLayId, vvpGObj[i][j]) ; + vIds.push_back( nId) ; + if ( nId == GDB_ID_NULL) + return false ; + } + } + + // eseguo il salvataggio + bool bOk = pGeomDB->Save( vIds, sFile, nFlag) ; + // rimuovo l'oggetto dal GeomDB + for ( int i = 0 ; i < int( vIds.size()) ; ++i) + bOk = ( pGeomDB->RemoveGeoObjAndErase( vIds[i]) != nullptr) && bOk ; + + return bOk ; +} + +//---------------------------------------------------------------------------- +bool +SaveCurveCompo( ICRVCOMPOPOVECTOR& vCompo, bool bUniform, const std::string& sFile, int nFlag = GDB_SV_BIN) +{ + // controllo validità delle curve + std::vector vpGObj ; + for ( int i = 0 ; i < int( vCompo.size()) ; ++ i) { + if ( vCompo[i] == nullptr || ! vCompo[i]->IsValid()) + return false ; + vpGObj.emplace_back( static_cast( vCompo[i]->Clone())) ; + } + // creo GeomDB temporaneo + PtrOwner pGeomDB( CreateGeomDB()) ; + if ( IsNull( pGeomDB)) + return false ; + INTVECTOR vIds ; + + // se curve con colore uniforme + if ( bUniform) + return SaveGeoObj( vpGObj, sFile, nFlag) ; + + // altrimenti scorro le sottocurve e le coloro in base alle temp prop + int nPartId = pGeomDB->AddGroup( GDB_ID_NULL, GDB_ID_ROOT, Frame3d()) ; + int nLayId = 0 ; + for ( int i = 0 ; i < int( vCompo.size()) ; ++i) { + // inserisco l'oggetto nel GeomDB (sotto pezzo/layer) + nLayId = pGeomDB->AddGroup( GDB_ID_NULL, nPartId, Frame3d()) ; + for ( int u = 0 ; u < vCompo[i]->GetCurveCount() ; ++ u) { + const ICurve* pCrv = vCompo[i]->GetCurve( u) ; + if ( pCrv == nullptr) + return false ; + int nId = pGeomDB->AddGeoObj( GDB_ID_NULL, nLayId, pCrv->Clone()) ; + pGeomDB->SetMaterial( nId, ( pCrv->GetTempProp( 0) == 1 ? RED : + ( pCrv->GetTempProp( 0)) == 0 ? BLUE : WHITE)) ; + vIds.push_back( nId) ; + if ( nId == GDB_ID_NULL) + return false ; + } + } + // eseguo il salvataggio + bool bOk = pGeomDB->Save( vIds, sFile, nFlag) ; + // rimuovo l'oggetto dal GeomDB + for ( int i = 0 ; i < int( vIds.size()); ++i) + bOk = ( pGeomDB->RemoveGeoObjAndErase( vIds[i]) != nullptr) && bOk ; + + return bOk ; + } \ No newline at end of file diff --git a/EGkHashGrids1d.h b/EGkHashGrids1d.h index cbdfb49..991517c 100644 --- a/EGkHashGrids1d.h +++ b/EGkHashGrids1d.h @@ -56,11 +56,11 @@ private : typedef std::list ObjList ; typedef std::vector PtrObjVector ; typedef std::unordered_map IntPObjUmap ; + typedef std::list GridList ; private : - typedef std::list GridList ; // Tipo per lista di hash grid - -private : + HashGrids1d( const HashGrids1d&) = delete ; + HashGrids1d& operator=( const HashGrids1d&) = delete ; void addGrid( ObjData& obj) ; void addList( ObjData& obj) ; diff --git a/EGkHashGrids2d.h b/EGkHashGrids2d.h index 2f18b3e..7de1f1a 100644 --- a/EGkHashGrids2d.h +++ b/EGkHashGrids2d.h @@ -56,11 +56,11 @@ class HashGrids2d typedef std::list ObjList ; typedef std::vector PtrObjVector ; typedef std::unordered_map IntPObjUmap ; + typedef std::list GridList ; private : - typedef std::list GridList ; // Tipo per lista di hash grid - - private : + HashGrids2d( const HashGrids2d&) = delete ; + HashGrids2d& operator=( const HashGrids2d&) = delete ; void addGrid( ObjData& obj) ; void addList( ObjData& obj) ; diff --git a/EGkHashGrids3d.h b/EGkHashGrids3d.h index 6195abd..8795ae1 100644 --- a/EGkHashGrids3d.h +++ b/EGkHashGrids3d.h @@ -56,11 +56,11 @@ class HashGrids3d typedef std::list ObjList ; typedef std::vector PtrObjVector ; typedef std::unordered_map IntPObjUmap ; + typedef std::list GridList ; private : - typedef std::list GridList ; // Tipo per lista di hash grid - - private : + HashGrids3d( const HashGrids3d&) = delete ; + HashGrids3d& operator=( const HashGrids3d&) = delete ; void addGrid( ObjData& obj) ; void addList( ObjData& obj) ; diff --git a/EGkSurfFlatRegion.h b/EGkSurfFlatRegion.h index b076359..eee5e43 100644 --- a/EGkSurfFlatRegion.h +++ b/EGkSurfFlatRegion.h @@ -52,6 +52,10 @@ class __declspec( novtable) ISurfFlatRegion : public ISurf virtual bool CalcVoronoiDiagram( ICURVEPOVECTOR& vCrvs, int nBound = 3) const = 0 ; virtual bool CalcMedialAxis( ICURVEPOVECTOR& vCrvs, int nSide = 1) const = 0 ; virtual void ResetVoronoiObject( void) const = 0 ; + virtual bool SetCurveTempProp( int nChunk, int nLoop, int nCrv, int nProp, int nPropInd = 0) = 0 ; + virtual bool GetCurveTempProp( int nChunk, int nLoop, int nCrv, int& nProp, int nPropInd = 0) const = 0 ; + virtual bool SetCurveTempParam( int nChunk, int nLoop, int nCrv, double dParam, int nParamInd = 0) = 0 ; + virtual bool GetCurveTempParam( int nChunk, int nLoop, int nCrv, double& dParam, int nParamInd = 0) const = 0 ; } ; //----------------------------------------------------------------------------- diff --git a/EXeExecutor.h b/EXeExecutor.h index 3b4180b..f5118c2 100644 --- a/EXeExecutor.h +++ b/EXeExecutor.h @@ -756,6 +756,7 @@ EXE_EXPORT int ExeSurfTmFacetCount( int nId) ; EXE_EXPORT int ExeSurfTmPartCount( int nId) ; EXE_EXPORT bool ExeSurfTmGetVertex( int nId, int nVert, int nRefId, Point3d& ptVert) ; EXE_EXPORT bool ExeSurfTmGetNearestVertex( int nId, const Point3d& ptNear, int nRefId, int& nVert, Point3d& ptVert) ; +EXE_EXPORT bool ExeSurfTmTriangleNormVersor( int nId, int nTria, int nRefId, Vector3d& vtNorm) ; EXE_EXPORT int ExeSurfTmFacetFromTria( int nId, int nT) ; EXE_EXPORT bool ExeSurfTmFacetAdjacencies( int nId, int nFacet, INTMATRIX& vAdj) ; EXE_EXPORT bool ExeSurfTmFacetNearestEndPoint( int nId, int nFacet, const Point3d& ptNear, int nRefId, @@ -774,8 +775,8 @@ EXE_EXPORT bool ExeSurfTmFacetOppositeSideEx( int nId, int nFacet, const Vector3 EXE_EXPORT bool ExeSurfTmFacetsContact( int nId, int nF1, int nF2, int nRefId, bool& bAdjac, Point3d& ptP1, Point3d& ptP2, double& dAng) ; EXE_EXPORT int ExeExtractSurfTmLoops( int nId, int nDestGrpId, int* pnCount) ; EXE_EXPORT int ExeGetSurfTmSilhouette( int nId, const Vector3d& vtDir, double dToler, int nDestGrpId, int nRefType, int* pnCount, bool bAllTria = false) ; -EXE_EXPORT int ExeGetSurfTmSilhouetteEx( int nId, const Point3d& ptOn, const Vector3d& vtN, double dToler, int nDestGrpId, int nRefType, - int* pnCount, bool bAllTria) ; +EXE_EXPORT int ExeGetSurfTmParSilhouettes( const INTVECTOR& vIds, const Point3d& ptOn, const Vector3d& vtN, const DBLVECTOR& vdDist, + double dToler, int nDestGrpId, int nRefType, int* pnCount) ; EXE_EXPORT int ExeExtractSurfTmFacetLoops( int nId, int nFacet, int nDestGrpId, int* pnCount) ; EXE_EXPORT int ExeCopySurfTmFacet( int nId, int nFacet, int nDestGrpId) ; EXE_EXPORT bool ExeSurfTmGetAllVertInFacet( int nId, int nFacet, INTVECTOR& vVert) ;