diff --git a/BtlGeom.cpp b/BtlGeom.cpp index 44ce42f..49578cf 100644 --- a/BtlGeom.cpp +++ b/BtlGeom.cpp @@ -18,7 +18,7 @@ #include "/EgtDev/Include/EGkCurveLine.h" #include "/EgtDev/Include/EGkCurveArc.h" #include "/EgtDev/Include/EGkCurveComposite.h" -#include "/EgtDev/Include/EGkSurfFlatRegion.h" +#include "/EgtDev/Include/EGkSfrCreate.h" #include "/EgtDev/Include/EGkStmStandard.h" #include "/EgtDev/Include/EGkStmFromCurves.h" #include "/EgtDev/Include/EGkExtText.h" @@ -47,14 +47,15 @@ BtlGeom::BtlGeom( void) //---------------------------------------------------------------------------- bool -BtlGeom::Init( IGeomDB* pGDB, bool bFlatPos) +BtlGeom::Init( IGeomDB* pGDB, bool bFlatPos, bool bSpecialTrim) { // salvo puntatore a DB geometrico m_pGDB = pGDB ; if ( m_pGDB == nullptr) return false ; - // salvo flag + // salvo i flag m_bFlatPos = bFlatPos ; + m_bSpecialTrim = bSpecialTrim ; // se non esiste, creo gruppo per assemblaggio m_nAsseId = m_pGDB->GetFirstNameInGroup( GDB_ID_ROOT, ASSEMBLY_GROUP_NAME) ; if ( m_nAsseId == GDB_ID_NULL) @@ -213,14 +214,20 @@ BtlGeom::AddPartBox( double dLength, double dHeight, double dWidth) string sName ; if ( ! m_pGDB->GetName( m_nPartId, sName) || sName.empty()) return true ; + // aggiungo dimensioni + double dDim1 = dLength ; + double dDim2 = max( dWidth, dHeight) ; + double dDim3 = min( dWidth, dHeight) ; + sName += "
(" + ToString( dDim1, 0) + "x" + ToString( dDim2, 0) + "x" + ToString( dDim3, 0) +")" ; PtrOwner pText( CreateExtText()) ; if ( IsNull( pText)) return false ; - int nSide = (( m_vtDim.z > m_vtDim.y + EPS_SMALL) ? 1 : 4) ; + int nSide = (( m_vtDim.z > m_vtDim.y + EPS_SMALL) ? BTL_SIDE_FRONT : BTL_SIDE_TOP) ; double dSideLen = GetSideLength( nSide) ; double dSideWidth = GetSideWidth( nSide) ; + double dTextHeight = 0.1 * min( dSideLen, dSideWidth) ; Point3d ptCen( 0.5 * dSideLen, 0.5 * dSideWidth, 0) ; - if ( ! pText->Set( ptCen, Z_AX, X_AX, sName, "", 100, false, 0.1 * dSideWidth, 1, 0, ETXT_IPMC)) + if ( ! pText->Set( ptCen, Z_AX, X_AX, sName, "", 100, false, dTextHeight, 1, 0, ETXT_IPMC)) return false ; // porto il testo nel piano della faccia Frame3d frRef = GetSideFrame( nSide) ; @@ -272,143 +279,7 @@ BtlGeom::AddPartTransformation( int nUID, const Frame3d& frRef) //---------------------------------------------------------------------------- bool -BtlGeom::AddPartOutline( int nSide, const FCEDEQUE& dqFce) -{ - // verifico esistenza pezzo - if ( m_nBoxId == GDB_ID_NULL) - return false ; - // verifico validità faccia - if ( ! IsSideValid( nSide)) - return false ; - // verifico siano definiti almeno 4 punti (triangolo) - if ( dqFce.size() < 4) - return false ; - // verifico che primo e ultimo punto coincidano - if ( ! AreSamePointApprox( dqFce.front().ptP, dqFce.back().ptP)) - return false ; - // verifico che sia un percorso semplice - if ( dqFce.front().nFlag != FreeContourEnt::START) - return false ; - // verifico non ci sia angolo di sbandamento - for ( auto& Fce : dqFce) { - if ( fabs( Fce.dAng) > EPS_ANG_SMALL) - return false ; - } - // costruisco il percorso di contorno - PtrOwner pCrvCompo( CurveFromFces( dqFce)) ; - if ( IsNull( pCrvCompo)) - return false ; - // aggiusto orientamento affinché sia antiorario - double dArea ; - pCrvCompo->GetAreaXY( dArea) ; - if ( dArea < 0) - pCrvCompo->Invert() ; - // Porto il percorso sul piano corretto - Frame3d frRef = GetSideFrame( nSide) ; - pCrvCompo->ToGlob( frRef) ; - // Estrudo il contorno - Vector3d vtExtr = - frRef.VersZ() * GetSideHeight( nSide) ; - PtrOwner pStm( GetSurfTriMeshByExtrusion( Get( pCrvCompo), vtExtr, false, EPS_SMALL)) ; - if ( IsNull( pStm)) - return false ; - pStm->Invert() ; - // Inserisco la superficie nel layer Outline - int nId = m_pGDB->AddGeoObj( GDB_ID_NULL, m_nOutsId, Release( pStm)) ; - if ( nId == GDB_ID_NULL) - return false ; - m_pGDB->SetName( nId, GetOutlineOutName( nSide)) ; - // Creo le regioni sopra e sotto - PtrOwner pSfr1( CreateSurfFlatRegion()) ; - if ( IsNull( pSfr1) || ! pSfr1->AddExtLoop( Release( pCrvCompo))) - return false ; - PtrOwner pSfr2( GetSurfFlatRegion( pSfr1->Clone())) ; - if ( IsNull( pSfr2)) - return false ; - pSfr2->Invert() ; - pSfr2->Translate( vtExtr) ; - // Inserisco le regioni nel layer Outline - int nId1 = m_pGDB->AddGeoObj( GDB_ID_NULL, m_nOutsId, Release( pSfr1)) ; - if ( nId1 == GDB_ID_NULL) - return false ; - m_pGDB->SetName( nId1, GetOutlineTopName( nSide)) ; - int nId2 = m_pGDB->AddGeoObj( GDB_ID_NULL, m_nOutsId, Release( pSfr2)) ; - if ( nId2 == GDB_ID_NULL) - return false ; - m_pGDB->SetName( nId2, GetOutlineBottomName( nSide)) ; - // nascondo il box - m_pGDB->SetStatus( m_nBoxId, GDB_ST_OFF) ; - - return true ; -} - -//---------------------------------------------------------------------------- -bool -BtlGeom::AddPartAperture( int nSide, const FCEDEQUE& dqFce) -{ - // verifico validità faccia - if ( ! IsSideValid( nSide)) - return false ; - // verifico siano definiti almeno 4 punti (triangolo) - if ( dqFce.size() < 4) - return false ; - // verifico che primo e ultimo punto coincidano - if ( ! AreSamePointApprox( dqFce.front().ptP, dqFce.back().ptP)) - return false ; - // verifico che sia un percorso semplice - if ( dqFce.front().nFlag != FreeContourEnt::START) - return false ; - // verifico non ci sia angolo di sbandamento - for ( auto& Fce : dqFce) { - if ( fabs( Fce.dAng) > EPS_ANG_SMALL) - return false ; - } - // costruisco il percorso di contorno - PtrOwner pCrvCompo( CurveFromFces( dqFce)) ; - if ( IsNull( pCrvCompo)) - return false ; - // aggiusto orientamento affinché sia antiorario - double dArea ; - pCrvCompo->GetAreaXY( dArea) ; - if ( dArea < 0) - pCrvCompo->Invert() ; - // Porto il percorso sul piano corretto - Frame3d frRef = GetSideFrame( nSide) ; - pCrvCompo->ToGlob( frRef) ; - // Estrudo il contorno - Vector3d vtExtr = - frRef.VersZ() * GetSideHeight( nSide) ; - PtrOwner pStm( GetSurfTriMeshByExtrusion( Get( pCrvCompo), vtExtr, false, EPS_SMALL)) ; - if ( IsNull( pStm)) - return false ; - // Inserisco la superficie nel layer Outline - int nId = m_pGDB->AddGeoObj( GDB_ID_NULL, m_nOutsId, Release( pStm)) ; - if ( nId == GDB_ID_NULL) - return false ; - m_pGDB->SetName( nId, GetOutlineApertureName( nSide)) ; - // Creo le regioni sopra e sotto - PtrOwner pSfr1( CreateSurfFlatRegion()) ; - if ( IsNull( pSfr1) || ! pSfr1->AddExtLoop( Release( pCrvCompo))) - return false ; - PtrOwner pSfr2( GetSurfFlatRegion( pSfr1->Clone())) ; - if ( IsNull( pSfr2)) - return false ; - pSfr2->Invert() ; - pSfr2->Translate( vtExtr) ; - // Sottraggo le regioni da quelle già presenti nell'outline - ISurfFlatRegion* pSfrTop = GetSurfFlatRegion( m_pGDB->GetGeoObj( m_pGDB->GetFirstNameInGroup( m_nOutsId, GetOutlineTopName( nSide)))) ; - if ( pSfrTop == nullptr) - return false ; - pSfrTop->Subtract( *pSfr1) ; - ISurfFlatRegion* pSfrBot = GetSurfFlatRegion( m_pGDB->GetGeoObj( m_pGDB->GetFirstNameInGroup( m_nOutsId, GetOutlineBottomName( nSide)))) ; - if ( pSfrBot == nullptr) - return false ; - pSfrBot->Subtract( *pSfr2) ; - - return true ; -} - -//---------------------------------------------------------------------------- -bool -BtlGeom::IsSideValid( int nSide) +BtlGeom::IsTrueSide( int nSide) const { return ( nSide >= BTL_SIDE_FRONT && nSide <= BTL_SIDE_TOP) ; } @@ -463,49 +334,58 @@ BtlGeom::CurveFromFces( const FCEDEQUE& dqFce) //---------------------------------------------------------------------------- string -BtlGeom::GetOutlineOutName( int nSide) +BtlGeom::GetOutlineOutName( int nSide) const { return ( ToString( nSide) + "-" + OL_OUTSTM_NAME) ; } //---------------------------------------------------------------------------- string -BtlGeom::GetOutlineApertureName( int nSide) +BtlGeom::GetOutlineApertureName( int nSide) const { return ( ToString( nSide) + "-" + OL_APERTURESTM_NAME) ; } //---------------------------------------------------------------------------- string -BtlGeom::GetOutlineTopName( int nSide) +BtlGeom::GetOutlineTopName( int nSide) const { return ( ToString( nSide) + "-" + OL_TOPREGION_NAME) ; } //---------------------------------------------------------------------------- string -BtlGeom::GetOutlineBottomName( int nSide) +BtlGeom::GetOutlineBottomName( int nSide) const { return ( ToString( nSide) + "-" + OL_BOTTOMREGION_NAME) ; } //---------------------------------------------------------------------------- double -BtlGeom::GetSideLength( int nSide) -{ - if ( nSide < BTL_SIDE_FRONT || nSide > BTL_SIDE_TOP) - return 0 ; - else - return m_vtDim.x ; -} - -//---------------------------------------------------------------------------- -double -BtlGeom::GetSideWidth( int nSide) +BtlGeom::GetSideLength( int nSide) const { switch ( nSide) { case BTL_SIDE_FRONT : case BTL_SIDE_BACK : + case BTL_SIDE_TOP : + case BTL_SIDE_BOTTOM : + return m_vtDim.x ; + case BTL_SIDE_RIGHT : + case BTL_SIDE_LEFT : + return m_vtDim.y ; + } + return 0 ; +} + +//---------------------------------------------------------------------------- +double +BtlGeom::GetSideWidth( int nSide) const +{ + switch ( nSide) { + case BTL_SIDE_FRONT : + case BTL_SIDE_BACK : + case BTL_SIDE_RIGHT : + case BTL_SIDE_LEFT : return m_vtDim.z ; case BTL_SIDE_TOP : case BTL_SIDE_BOTTOM : @@ -516,7 +396,7 @@ BtlGeom::GetSideWidth( int nSide) //---------------------------------------------------------------------------- double -BtlGeom::GetSideHeight( int nSide) +BtlGeom::GetSideHeight( int nSide) const { switch ( nSide) { case BTL_SIDE_FRONT : @@ -525,13 +405,16 @@ BtlGeom::GetSideHeight( int nSide) case BTL_SIDE_TOP : case BTL_SIDE_BOTTOM : return m_vtDim.z ; + case BTL_SIDE_RIGHT : + case BTL_SIDE_LEFT : + return m_vtDim.x ; } return 0 ; } //---------------------------------------------------------------------------- Frame3d -BtlGeom::GetSideFrame( int nSide) +BtlGeom::GetSideFrame( int nSide) const { Frame3d frRef ; switch ( nSide) { @@ -547,6 +430,71 @@ BtlGeom::GetSideFrame( int nSide) case BTL_SIDE_TOP : frRef.Set( Point3d( 0, 0, m_vtDim.z), X_AX, Y_AX, Z_AX) ; break ; + case BTL_SIDE_RIGHT : + frRef.Set( Point3d( m_vtDim.x, 0, 0), Y_AX, Z_AX, X_AX) ; + break ; + case BTL_SIDE_LEFT : + frRef.Set( Point3d( 0, m_vtDim.y, 0), - Y_AX, Z_AX, - X_AX) ; + break ; } return frRef ; } + +//---------------------------------------------------------------------------- +Plane3d +BtlGeom::GetSidePlane( int nSide) const +{ + Plane3d plPlane ; + switch ( nSide) { + case BTL_SIDE_FRONT : + plPlane.dDist = 0 ; + plPlane.vtN = - Y_AX ; + break ; + case BTL_SIDE_BOTTOM : + plPlane.dDist = 0 ; + plPlane.vtN = - Z_AX ; + break ; + case BTL_SIDE_BACK : + plPlane.dDist = m_vtDim.y ; + plPlane.vtN = Y_AX ; + break ; + case BTL_SIDE_TOP : + plPlane.dDist = m_vtDim.z ; + plPlane.vtN = Z_AX ; + break ; + case BTL_SIDE_RIGHT : + plPlane.dDist = m_vtDim.x ; + plPlane.vtN = X_AX ; + break ; + case BTL_SIDE_LEFT : + plPlane.dDist = 0 ; + plPlane.vtN = - X_AX ; + break ; + default : + plPlane.dDist = 0 ; + plPlane.vtN = V_NULL ; + break ; + } + return plPlane ; +} + +//---------------------------------------------------------------------------- +int +BtlGeom::GetOppositeSide( int nSide) const +{ + switch ( nSide) { + case BTL_SIDE_FRONT : + return BTL_SIDE_BACK ; + case BTL_SIDE_TOP : + return BTL_SIDE_BOTTOM ; + case BTL_SIDE_BACK : + return BTL_SIDE_FRONT ; + case BTL_SIDE_BOTTOM : + return BTL_SIDE_TOP ; + case BTL_SIDE_RIGHT : + return BTL_SIDE_LEFT ; + case BTL_SIDE_LEFT : + return BTL_SIDE_RIGHT ; + } + return BTL_SIDE_NONE ; +} diff --git a/BtlGeom.h b/BtlGeom.h index d916724..f0f3719 100644 --- a/BtlGeom.h +++ b/BtlGeom.h @@ -15,6 +15,7 @@ #include "BtlGeomCoStru.h" #include "/EgtDev/Include/EgkGeomDB.h" +#include "/EgtDev/Include/EgkCurve.h" class Polygon3d ; class ICurveComposite ; @@ -27,7 +28,7 @@ class BtlGeom BtlGeom( void) ; public : - bool Init( IGeomDB* pGDB, bool bFlatPos) ; + bool Init( IGeomDB* pGDB, bool bFlatPos, bool bSpecialTrim) ; bool CreatePart( void) ; bool ErasePart( void) ; bool SetPartProdNbr( int nProdNbr) ; @@ -35,30 +36,45 @@ class BtlGeom bool SetPartCount( int nCount) ; bool AddPartBox( double dLength, double dHeight, double dWidth) ; bool AddPartTransformation( int nUID, const Frame3d& frRef) ; - bool AddPartOutline( int nSide, const FCEDEQUE& dqFce) ; - bool AddPartAperture( int nSide, const FCEDEQUE& dqFce) ; bool AdjustPartFlatPos( int nPartId) ; - public : + public : // Outline + bool AddPartOutline( int nSide, const FCEDEQUE& dqFce) ; + bool AddPartAperture( int nSide, const FCEDEQUE& dqFce) ; + bool AddPartStdOutline( void) ; + + public : // Proc bool GetProcessParamInfos( int nGroup, int nProc, int nSide, - INTVECTOR& vnDPar, int& nSPar, DBLVECTOR& vdPar, std::string& sPar) ; + INTVECTOR& vnDPar, int& nSPar, DBLVECTOR& vdPar, std::string& sPar) const ; bool AddProcess( int nGroup, int nProc, int nSide, const std::string& sDes, int nProcId, const DBLVECTOR& vdPar, const std::string& sPar) ; private : bool CreateAssemblyGroup( void) ; - bool IsSideValid( int nSide) ; + bool IsTrueSide( int nSide) const ; // esclude gli estremi (RIGHT e LEFT) ICurveComposite* CurveFromFces( const FCEDEQUE& dqFce) ; - std::string GetOutlineOutName( int nSide) ; - std::string GetOutlineApertureName( int nSide) ; - std::string GetOutlineTopName( int nSide) ; - std::string GetOutlineBottomName( int nSide) ; - double GetSideLength( int nSide) ; - double GetSideWidth( int nSide) ; - double GetSideHeight( int nSide) ; - Frame3d GetSideFrame( int nSide) ; + std::string GetOutlineOutName( int nSide) const ; + std::string GetOutlineApertureName( int nSide) const ; + std::string GetOutlineTopName( int nSide) const ; + std::string GetOutlineBottomName( int nSide) const ; + double GetSideLength( int nSide) const ; + double GetSideWidth( int nSide) const ; + double GetSideHeight( int nSide) const ; + Frame3d GetSideFrame( int nSide) const ; + Plane3d GetSidePlane( int nSide) const ; + int GetOppositeSide( int nSide) const ; - private : + private : // Outline + bool UseProcessToTrimOutline( int nProcId) ; + bool TrimOutline( int nProcSurfId) ; + bool GetLineInFace( const Point3d& ptP1, const Point3d& ptP2, int& nFace) const ; + bool IsLineOnFace( const Point3d& ptP1, const Point3d& ptP2, int nFace) const ; + bool RemoveDanglingFace( const ICURVEPVECTOR vCrvP[], ISurfTriMesh* pStm) ; + bool AdjustOneOutlineFace( int nSide, ICURVEPVECTOR& vCrvP) ; + int GetFaceRegion( int nSide) ; + ICurveComposite* GetFaceContour( int nSide) ; + + private : // Proc bool AddCut( int nGroup, int nProc, int nSide, const std::string& sDes, int nProcId, const DBLVECTOR& vdPar) ; bool AddLongitCut( int nGroup, int nProc, int nSide, const std::string& sDes, int nProcId, @@ -82,6 +98,7 @@ class BtlGeom private : IGeomDB* m_pGDB ; bool m_bFlatPos ; // flag per posizionamento pezzi di piatto + bool m_bSpecialTrim ; // flag per trim speciale regioni per pareti (solo con feature passanti) Color m_BoxCol ; // colore per box pezzi Color m_OutsCol ; // colore per outline pezzi Color m_ProcsCol ; // colore per lavorazioni pezzi diff --git a/BtlGeomCoStru.h b/BtlGeomCoStru.h index e39ff8a..676b980 100644 --- a/BtlGeomCoStru.h +++ b/BtlGeomCoStru.h @@ -18,37 +18,42 @@ //---------------------------------------------------------------------------- // nome gruppo di sistema per riferimenti di definizione assemblaggio -static std::string ASSEMBLY_GROUP_NAME = "AsseBase" ; +static const std::string ASSEMBLY_GROUP_NAME = "AsseBase" ; // nomi layer standard dei pezzi -static std::string AUX_LAYER_NAME = "Part" ; -static std::string BOX_LAYER_NAME = "Box" ; -static std::string OUTLINE_LAYER_NAME = "Outline" ; -static std::string PROCESSINGS_LAYER_NAME = "Processings" ; +static const std::string AUX_LAYER_NAME = "Part" ; +static const std::string BOX_LAYER_NAME = "Box" ; +static const std::string OUTLINE_LAYER_NAME = "Outline" ; +static const std::string PROCESSINGS_LAYER_NAME = "Processings" ; // nomi entità standard dei pezzi -static std::string AUX_PART_NAME = "Name" ; -static std::string BOX_BOX_NAME = "Box" ; -static std::string OL_OUTSTM_NAME = "Out" ; -static std::string OL_APERTURESTM_NAME = "Ape" ; -static std::string OL_TOPREGION_NAME = "Top" ; -static std::string OL_BOTTOMREGION_NAME = "Bot" ; +static const std::string AUX_PART_NAME = "Name" ; +static const std::string BOX_BOX_NAME = "Box" ; +static const std::string OL_OUTSTM_NAME = "Out" ; +static const std::string OL_APERTURESTM_NAME = "Ape" ; +static const std::string OL_TOPREGION_NAME = "Top" ; +static const std::string OL_BOTTOMREGION_NAME = "Bot" ; // chiavi di informazioni associate ai pezzi -static std::string IKEY_PROD_NBR = "PDN" ; -static std::string IKEY_NAME = "NAM" ; -static std::string IKEY_COUNT = "CNT" ; -static std::string IKEY_LENGTH = "L" ; -static std::string IKEY_WIDTH = "W" ; -static std::string IKEY_HEIGHT = "H" ; +static const std::string IKEY_PROD_NBR = "PDN" ; +static const std::string IKEY_NAME = "NAM" ; +static const std::string IKEY_COUNT = "CNT" ; +static const std::string IKEY_LENGTH = "L" ; +static const std::string IKEY_WIDTH = "W" ; +static const std::string IKEY_HEIGHT = "H" ; +// chiavi di informazioni associate alle geometrie di outline +static const std::string IKEY_OTL_SIDE = "SIDE" ; // chiavi di informazioni associate alle geometrie di lavorazione -static std::string IKEY_GROUP = "GRP" ; -static std::string IKEY_PROC = "PRC" ; -static std::string IKEY_SIDE = "SID" ; +static const std::string IKEY_GROUP = "GRP" ; +static const std::string IKEY_PROC = "PRC" ; +static const std::string IKEY_SIDE = "SIDE" ; //---------------------------------------------------------------------------- enum BtlSide { BTL_SIDE_NONE = 0, BTL_SIDE_FRONT = 1, BTL_SIDE_BOTTOM = 2, BTL_SIDE_BACK = 3, - BTL_SIDE_TOP = 4} ; + BTL_SIDE_TOP = 4, + BTL_SIDE_RIGHT = 5, + BTL_SIDE_LEFT = 6} ; +static const int SIDE_NBR = 6 ; //---------------------------------------------------------------------------- struct FreeContourEnt { diff --git a/BtlGeomOutline.cpp b/BtlGeomOutline.cpp new file mode 100644 index 0000000..1939e80 --- /dev/null +++ b/BtlGeomOutline.cpp @@ -0,0 +1,523 @@ +//---------------------------------------------------------------------------- +// EgalTech 2015-2015 +//---------------------------------------------------------------------------- +// File : BtlGeomOutline.cpp Data : 06.11.15 Versione : 1.6k2 +// Contenuto : Implementazione delle funzioni su outline per BtlGeom. +// +// +// +// Modifiche : 06.11.15 DS Creazione modulo. +// +// +//---------------------------------------------------------------------------- + +//--------------------------- Include ---------------------------------------- +#include "stdafx.h" +#include "BtlGeom.h" +#include "DllMain.h" +#include "/EgtDev/Include/EGkCurveLine.h" +#include "/EgtDev/Include/EGkCurveArc.h" +#include "/EgtDev/Include/EGkCurveComposite.h" +#include "/EgtDev/Include/EgkChainCurves.h" +#include "/EgtDev/Include/EGkSfrCreate.h" +#include "/EgtDev/Include/EGkStmStandard.h" +#include "/EgtDev/Include/EGkStmFromCurves.h" +#include "/EgtDev/Include/EGkExtText.h" +#include "/EgtDev/Include/EGnStringUtils.h" +#include "/EgtDev/Include/EgtPointerOwner.h" + +using namespace std ; + + +//---------------------------------------------------------------------------- +bool +BtlGeom::AddPartOutline( int nSide, const FCEDEQUE& dqFce) +{ + // verifico esistenza pezzo + if ( m_nBoxId == GDB_ID_NULL) + return false ; + // verifico validità faccia + if ( ! IsTrueSide( nSide)) + return false ; + // verifico siano definiti almeno 4 punti (triangolo) + if ( dqFce.size() < 4) + return false ; + // verifico che primo e ultimo punto coincidano + if ( ! AreSamePointApprox( dqFce.front().ptP, dqFce.back().ptP)) + return false ; + // verifico che sia un percorso semplice + if ( dqFce.front().nFlag != FreeContourEnt::START) + return false ; + // verifico non ci sia angolo di sbandamento + for ( auto& Fce : dqFce) { + if ( fabs( Fce.dAng) > EPS_ANG_SMALL) + return false ; + } + // costruisco il percorso di contorno + PtrOwner pCrvCompo( CurveFromFces( dqFce)) ; + if ( IsNull( pCrvCompo)) + return false ; + // aggiusto orientamento affinché sia antiorario + double dArea ; + pCrvCompo->GetAreaXY( dArea) ; + if ( dArea < 0) + pCrvCompo->Invert() ; + // Porto il percorso sul piano corretto + Frame3d frRef = GetSideFrame( nSide) ; + pCrvCompo->ToGlob( frRef) ; + // Estrudo il contorno + Vector3d vtExtr = - frRef.VersZ() * GetSideHeight( nSide) ; + PtrOwner pStm( GetSurfTriMeshByExtrusion( Get( pCrvCompo), vtExtr, false, EPS_SMALL)) ; + if ( IsNull( pStm)) + return false ; + pStm->Invert() ; + // Inserisco la superficie nel layer Outline + int nId = m_pGDB->AddGeoObj( GDB_ID_NULL, m_nOutsId, Release( pStm)) ; + if ( nId == GDB_ID_NULL) + return false ; + m_pGDB->SetName( nId, GetOutlineOutName( nSide)) ; + // Creo le regioni sopra e sotto + PtrOwner pSfr1( CreateSurfFlatRegion()) ; + if ( IsNull( pSfr1) || ! pSfr1->AddExtLoop( Release( pCrvCompo))) + return false ; + PtrOwner pSfr2( GetSurfFlatRegion( pSfr1->Clone())) ; + if ( IsNull( pSfr2)) + return false ; + pSfr2->Invert() ; + pSfr2->Translate( vtExtr) ; + // Inserisco le regioni nel layer Outline + int nId1 = m_pGDB->AddGeoObj( GDB_ID_NULL, m_nOutsId, Release( pSfr1)) ; + if ( nId1 == GDB_ID_NULL) + return false ; + m_pGDB->SetName( nId1, GetOutlineTopName( nSide)) ; + m_pGDB->SetInfo( nId1, IKEY_OTL_SIDE, nSide) ; + int nId2 = m_pGDB->AddGeoObj( GDB_ID_NULL, m_nOutsId, Release( pSfr2)) ; + if ( nId2 == GDB_ID_NULL) + return false ; + m_pGDB->SetName( nId2, GetOutlineBottomName( nSide)) ; + m_pGDB->SetInfo( nId2, IKEY_OTL_SIDE, GetOppositeSide( nSide)) ; + // nascondo il box + m_pGDB->SetStatus( m_nBoxId, GDB_ST_OFF) ; + + return true ; +} + +//---------------------------------------------------------------------------- +bool +BtlGeom::AddPartAperture( int nSide, const FCEDEQUE& dqFce) +{ + // verifico esistenza pezzo + if ( m_nBoxId == GDB_ID_NULL) + return false ; + // verifico validità faccia + if ( ! IsTrueSide( nSide)) + return false ; + // verifico siano definiti almeno 4 punti (triangolo) + if ( dqFce.size() < 4) + return false ; + // verifico che primo e ultimo punto coincidano + if ( ! AreSamePointApprox( dqFce.front().ptP, dqFce.back().ptP)) + return false ; + // verifico che sia un percorso semplice + if ( dqFce.front().nFlag != FreeContourEnt::START) + return false ; + // verifico non ci sia angolo di sbandamento + for ( auto& Fce : dqFce) { + if ( fabs( Fce.dAng) > EPS_ANG_SMALL) + return false ; + } + // costruisco il percorso di contorno + PtrOwner pCrvCompo( CurveFromFces( dqFce)) ; + if ( IsNull( pCrvCompo)) + return false ; + // aggiusto orientamento affinché sia antiorario + double dArea ; + pCrvCompo->GetAreaXY( dArea) ; + if ( dArea < 0) + pCrvCompo->Invert() ; + // Porto il percorso sul piano corretto + Frame3d frRef = GetSideFrame( nSide) ; + pCrvCompo->ToGlob( frRef) ; + // Estrudo il contorno + Vector3d vtExtr = - frRef.VersZ() * GetSideHeight( nSide) ; + PtrOwner pStm( GetSurfTriMeshByExtrusion( Get( pCrvCompo), vtExtr, false, EPS_SMALL)) ; + if ( IsNull( pStm)) + return false ; + // Inserisco la superficie nel layer Outline + int nId = m_pGDB->AddGeoObj( GDB_ID_NULL, m_nOutsId, Release( pStm)) ; + if ( nId == GDB_ID_NULL) + return false ; + m_pGDB->SetName( nId, GetOutlineApertureName( nSide)) ; + // Creo le regioni sopra e sotto + PtrOwner pSfr1( CreateSurfFlatRegion()) ; + if ( IsNull( pSfr1) || ! pSfr1->AddExtLoop( Release( pCrvCompo))) + return false ; + PtrOwner pSfr2( GetSurfFlatRegion( pSfr1->Clone())) ; + if ( IsNull( pSfr2)) + return false ; + pSfr2->Invert() ; + pSfr2->Translate( vtExtr) ; + // Sottraggo le regioni da quelle già presenti nell'outline + ISurfFlatRegion* pSfrTop = GetSurfFlatRegion( m_pGDB->GetGeoObj( m_pGDB->GetFirstNameInGroup( m_nOutsId, GetOutlineTopName( nSide)))) ; + if ( pSfrTop == nullptr) + return false ; + pSfrTop->Subtract( *pSfr1) ; + ISurfFlatRegion* pSfrBot = GetSurfFlatRegion( m_pGDB->GetGeoObj( m_pGDB->GetFirstNameInGroup( m_nOutsId, GetOutlineBottomName( nSide)))) ; + if ( pSfrBot == nullptr) + return false ; + pSfrBot->Subtract( *pSfr2) ; + + return true ; +} + +//---------------------------------------------------------------------------- +bool +BtlGeom::AddPartStdOutline( void) +{ + // verifico esistenza pezzo + if ( m_nBoxId == GDB_ID_NULL) + return false ; + // aggiungo le regioni delle faccie + for ( int nSide = BTL_SIDE_FRONT ; nSide <= BTL_SIDE_LEFT ; ++ nSide) { + PtrOwner pSfr( GetSurfFlatRegionRectangle( GetSideLength( nSide),GetSideWidth( nSide))) ; + if ( IsNull( pSfr)) + return false ; + pSfr->ToGlob( GetSideFrame( nSide)) ; + // Inserisco la regione nel layer Outline + int nId = m_pGDB->AddGeoObj( GDB_ID_NULL, m_nOutsId, Release( pSfr)) ; + if ( nId == GDB_ID_NULL) + return false ; + m_pGDB->SetName( nId, GetOutlineTopName( nSide)) ; + m_pGDB->SetInfo( nId, IKEY_OTL_SIDE, nSide) ; + } + // nascondo il box + m_pGDB->SetStatus( m_nBoxId, GDB_ST_OFF) ; + return true ; +} + +//---------------------------------------------------------------------------- +bool +BtlGeom::UseProcessToTrimOutline( int nProcId) +{ + // se non trim speciale per pareti... + if ( ! m_bSpecialTrim) + return true ; + // recupero il box della superficie + BBox3d b3Proc ; + Point3d ptMin, ptMax ; + if ( ! m_pGDB->GetLocalBBox( nProcId, b3Proc) || ! b3Proc.GetMinMax( ptMin, ptMax)) + return true ; + // verifico rispetto allo spessore perpendicolare alla faccia maggiore + if ( m_vtDim.y > m_vtDim.z) + return ( ( ptMax.z - ptMin.z) > m_vtDim.z - 100 * EPS_SMALL) ; + else + return ( ( ptMax.y - ptMin.y) > m_vtDim.y - 100 * EPS_SMALL) ; +} + +//---------------------------------------------------------------------------- +bool +BtlGeom::TrimOutline( int nProcSurfId) +{ + // Recupero la superficie del processo di lavorazione + ISurfTriMesh* pStm = GetSurfTriMesh( m_pGDB->GetGeoObj( nProcSurfId)) ; + if ( pStm == nullptr) + return false ; + // Ne recupero le curve di contorno + POLYLINEVECTOR vPL ; + if ( ! pStm->GetLoops( vPL)) + return false ; + // Divido le curve sulle varie facce del box del pezzo + bool bOk = true ; + bool bSomeInFace = false ; + ICURVEPVECTOR vCrvP[SIDE_NBR] ; + for ( auto& PL : vPL) { + // ciclo sulle linee della polilinea + Point3d ptP1, ptP2 ; + for ( bool bFound = PL.GetFirstLine( ptP1, ptP2) ; + bFound ; + bFound = PL.GetNextLine( ptP1, ptP2)) { + // verifico la faccia di appartenenza + int nFace ; + if ( GetLineInFace( ptP1, ptP2, nFace)) { + // creo la linea + PtrOwner pLine( CreateCurveLine()) ; + if ( ! IsNull( pLine) && pLine->Set( ptP1, ptP2)) { + vCrvP[ nFace - 1].emplace_back( Release( pLine)) ; + bSomeInFace = true ; + } + else + bOk = false ; + } + } + } + // Se trovate curve che stanno completamente in una faccia + if ( bSomeInFace) { + // elimino eventuale faccia che rimarrebbe penzolante + if ( ! RemoveDanglingFace( vCrvP, pStm)) + bOk = false ; + // per ogni faccia + for ( int i = BTL_SIDE_FRONT ; i <= BTL_SIDE_LEFT ; ++ i) { + if ( ! AdjustOneOutlineFace( i, vCrvP[i-1])) + bOk = false ; + } + } + // Altrimenti, verifico se la superficie di lavorazione coincide con una faccia + else { + Point3d ptCen ; + Vector3d vtN ; + // se la superficie è formata da una sola faccetta + if ( pStm->GetFacetCount() == 1 && pStm->GetFacetCenter( 0, ptCen, vtN)) { + // per ogni faccia + for ( int i = BTL_SIDE_FRONT ; i <= BTL_SIDE_LEFT ; ++ i) { + // piano della faccia + Plane3d plFace = GetSidePlane( i) ; + // verifico se la faccetta coincide con la faccia + if ( PointInPlaneApprox( ptCen, plFace) && AreSameVectorApprox( vtN, plFace.vtN)) { + // cancello la regione della faccia + int nRegId = GetFaceRegion( i) ; + m_pGDB->Erase( nRegId) ; + break ; + } + } + } + } + // Pulisco il vettore delle curve + for ( int i = BTL_SIDE_FRONT ; i <= BTL_SIDE_LEFT ; ++ i) { + for ( auto& pCrv : vCrvP[i-1]) { + if ( pCrv != nullptr) + delete pCrv ; + pCrv = nullptr ; + } + } + + return bOk ; +} + +//---------------------------------------------------------------------------- +bool +BtlGeom::GetLineInFace( const Point3d& ptP1, const Point3d& ptP2, int& nFace) const +{ + // ciclo di verifica con le diverse facce + nFace = BTL_SIDE_NONE ; + for ( int i = BTL_SIDE_FRONT ; i <= BTL_SIDE_LEFT ; ++ i) { + // se sta sulla faccia + if ( IsLineOnFace( ptP1, ptP2, i)) { + // se appartiene anche ad altra faccia, è sul bordo comune e quindi non interna + if ( nFace != BTL_SIDE_NONE) + return false ; + // assegno la faccia + else + nFace = i ; + } + } + + return true ; +} + +//---------------------------------------------------------------------------- +bool +BtlGeom::IsLineOnFace( const Point3d& ptP1, const Point3d& ptP2, int nFace) const +{ + // piano della faccia + Plane3d plFace = GetSidePlane( nFace) ; + // sulla faccia se i due punti appartengono alla faccia + return ( PointInPlaneApprox( ptP1, plFace) && PointInPlaneApprox( ptP2, plFace)) ; +} + +//---------------------------------------------------------------------------- +bool +BtlGeom::RemoveDanglingFace( const ICURVEPVECTOR vCrvP[], ISurfTriMesh* pStm) +{ + // vettore con flag di interessamento faccia + bool bInFace[SIDE_NBR] ; + for ( int i = BTL_SIDE_FRONT ; i <= BTL_SIDE_LEFT ; ++ i) + bInFace[i-1] = ( vCrvP[i-1].size() > 0) ; + // prima normale alla faccia + Vector3d vtN ; + if ( ! pStm->GetFacetNormal( 0, vtN)) + return false ; + // verifico facce 5 e 6 + if ( ( bInFace[1-1] && bInFace[2-1]) || ( bInFace[1-1] && bInFace[3-1]) || + ( bInFace[1-1] && bInFace[4-1]) || ( bInFace[2-1] && bInFace[3-1]) || + ( bInFace[2-1] && bInFace[4-1]) || ( bInFace[3-1] && bInFace[4-1])) { + if ( ! bInFace[5-1] && vtN.x > 0) { + // cancello la regione della faccia + int nRegId = GetFaceRegion( 5) ; + m_pGDB->Erase( nRegId) ; + } + else if ( ! bInFace[6-1] && vtN.x < 0) { + // cancello la regione della faccia + int nRegId = GetFaceRegion( 6) ; + m_pGDB->Erase( nRegId) ; + } + } + // verifico facce 1 e 3 + if ( ( bInFace[2-1] && bInFace[4-1]) || ( bInFace[2-1] && bInFace[5-1]) || + ( bInFace[2-1] && bInFace[6-1]) || ( bInFace[4-1] && bInFace[5-1]) || + ( bInFace[4-1] && bInFace[6-1]) || ( bInFace[5-1] && bInFace[6-1])) { + if ( ! bInFace[1-1] && vtN.y < 0) { + // cancello la regione della faccia + int nRegId = GetFaceRegion( 1) ; + m_pGDB->Erase( nRegId) ; + } + else if ( ! bInFace[3-1] && vtN.y > 0) { + // cancello la regione della faccia + int nRegId = GetFaceRegion( 3) ; + m_pGDB->Erase( nRegId) ; + } + } + // verifico facce 2 e 4 + if ( ( bInFace[1-1] && bInFace[3-1]) || ( bInFace[1-1] && bInFace[5-1]) || + ( bInFace[1-1] && bInFace[6-1]) || ( bInFace[3-1] && bInFace[5-1]) || + ( bInFace[3-1] && bInFace[6-1]) || ( bInFace[5-1] && bInFace[6-1])) { + if ( ! bInFace[2-1] && vtN.z < 0) { + // cancello la regione della faccia + int nRegId = GetFaceRegion( 2) ; + m_pGDB->Erase( nRegId) ; + } + else if ( ! bInFace[4-1] && vtN.z > 0) { + // cancello la regione della faccia + int nRegId = GetFaceRegion( 4) ; + m_pGDB->Erase( nRegId) ; + } + } + + return true ; +} + +//---------------------------------------------------------------------------- +bool +BtlGeom::AdjustOneOutlineFace( int nSide, ICURVEPVECTOR& vCrvP) +{ + // verifico ci siano delle curve di taglio + if ( vCrvP.size() == 0) + return true ; + // recupero la regione associata alla faccia + int nRegId = GetFaceRegion( nSide) ; + ISurfFlatRegion* pFaceReg = GetSurfFlatRegion( m_pGDB->GetGeoObj( nRegId)) ; + if ( pFaceReg == nullptr) + return true ; + // preparo la regione da sottrarre + PtrOwner pSubReg ; + // recupero il riferimento della faccia + Frame3d frFace = GetSideFrame( nSide) ; + // recupero il contorno della faccia nel suo proprio riferimento + PtrOwner pFaceCnt( GetFaceContour( nSide)) ; + if ( IsNull( pFaceCnt)) + return false ; + // porto le linee nel riferimento della faccia + for ( auto& pCrv : vCrvP) + pCrv->ToLoc( frFace) ; + // concateno le linee senza invertirle + double dToler = 10 * EPS_SMALL ; + ChainCurves chainC ; + chainC.Init( false, dToler, int( vCrvP.size())) ; + for ( size_t i = 0 ; i < vCrvP.size() ; ++ i) { + Point3d ptStart, ptEnd ; + Vector3d vtStart, vtEnd ; + if ( ! vCrvP[i]->GetStartPoint( ptStart) || ! vCrvP[i]->GetStartDir( vtStart) || + ! vCrvP[i]->GetEndPoint( ptEnd) || !vCrvP[i]->GetEndDir( vtEnd)) + return false ; + if ( ! chainC.AddCurve( int( i+1), ptStart, vtStart, ptEnd, vtEnd)) + return false ; + } + Point3d ptNearL = ORIG ; + INTVECTOR vId2s ; + while ( chainC.GetChainFromNear( ptNearL, false, vId2s)) { + // creo una curva composita + PtrOwner pCrvCompo( CreateCurveComposite()) ; + if ( IsNull( pCrvCompo)) + return false ; + // recupero le curve semplici e le inserisco nella curva composita + for ( size_t i = 0 ; i < vId2s.size() ; ++ i) { + // indice della curva + int j = vId2s[i] - 1 ; + // la aggiungo alla curva composta + bool bOk = pCrvCompo->AddCurve( vCrvP[j], true, dToler) ; + vCrvP[j] = nullptr ; + if ( ! bOk) + return false ; + } + // se curva aperta, la completo con il contorno della faccia + if ( ! pCrvCompo->IsClosed()) { + // intersezione della curva col contorno + IntersCurveCurve intCC( *pCrvCompo, *pFaceCnt) ; + int nIntCount = intCC.GetIntersCount() ; + if ( nIntCount < 2) + continue ; + IntCrvCrvInfo iccInfo ; + intCC.GetIntCrvCrvInfo( 0, iccInfo) ; + double dParEnd = iccInfo.IciB[0].dU ; + intCC.GetIntCrvCrvInfo( nIntCount - 1, iccInfo) ; + double dParStart = iccInfo.IciB[0].dU ; + // recupero parte del contorno tra intersezione fine e intersezione inizio + PtrOwner pTmpCrv( pFaceCnt->CopyParamRange( dParStart, dParEnd)) ; + if ( IsNull( pTmpCrv) || ! pCrvCompo->AddCurve( Release( pTmpCrv))) + continue ; + // se ora non è chiusa, salto alla prossima concatenazione + if ( ! pCrvCompo->IsClosed()) + continue ; + } + // porto la curva nel riferimento del pezzo + pCrvCompo->ToGlob( frFace) ; + // creo una regione a partire dalla curva + SurfFlatRegionByContours SfrCntr ; + SfrCntr.AddCurve( Release( pCrvCompo)) ; + // se la regione sottrazione totale è nulla, la assegno + if ( IsNull( pSubReg)) + pSubReg.Set( SfrCntr.GetSurf()) ; + // altrimenti la interseco + else { + PtrOwner pSfrReg(SfrCntr.GetSurf()) ; + if ( IsNull( pSfrReg)) + continue ; + pSubReg->Intersect( *Get( pSfrReg)) ; + } + } + // se esiste regione sottrazione, la tolgo dalla regione della faccia + if ( ! IsNull( pSubReg)) { + // sottraggo + pFaceReg->Subtract( *Get( pSubReg)) ; + // se vuota, la elimino + if ( ! pFaceReg->IsValid()) + m_pGDB->Erase( nRegId) ; + } + return true ; +} + +//---------------------------------------------------------------------------- +int +BtlGeom::GetFaceRegion( int nSide) +{ + int nId = m_pGDB->GetFirstInGroup( m_nOutsId) ; + while ( nId != GDB_ID_NULL) { + int nS ; + if ( m_pGDB->GetGeoType( nId) == SRF_FLATRGN && + m_pGDB->GetInfo( nId, IKEY_OTL_SIDE, nS) && nS == nSide) + return nId ; + nId = m_pGDB->GetNext( nId) ; + } + return GDB_ID_NULL ; +} + +//---------------------------------------------------------------------------- +ICurveComposite* +BtlGeom::GetFaceContour( int nSide) +{ + // verifico validità indice di faccia + if ( nSide < BTL_SIDE_FRONT || nSide > BTL_SIDE_LEFT) + return nullptr ; + // creo il contorno antiorario + PolyLine PL ; + PL.AddUPoint( 0, ORIG) ; + PL.AddUPoint( 1, Point3d( GetSideLength( nSide), 0, 0)) ; + PL.AddUPoint( 2, Point3d( GetSideLength( nSide), GetSideWidth( nSide), 0)) ; + PL.AddUPoint( 3, Point3d( 0, GetSideWidth( nSide), 0)) ; + PL.AddUPoint( 4, ORIG) ; + // creo la curva composita + PtrOwner pCrvCompo( CreateCurveComposite()) ; + if ( IsNull( pCrvCompo) || ! pCrvCompo->FromPolyLine( PL)) + return nullptr ; + else + return Release( pCrvCompo) ; +} \ No newline at end of file diff --git a/BtlGeomProc.cpp b/BtlGeomProc.cpp index 2b8b867..4e38a27 100644 --- a/BtlGeomProc.cpp +++ b/BtlGeomProc.cpp @@ -43,7 +43,7 @@ Clip( double dVal, double dMin, double dMax) //---------------------------------------------------------------------------- bool BtlGeom::GetProcessParamInfos( int nGroup, int nProc, int nSide, - INTVECTOR& vnDPar, int& nSPar, DBLVECTOR& vdPar, string& sPar) + INTVECTOR& vnDPar, int& nSPar, DBLVECTOR& vdPar, string& sPar) const { // se taglio if ( IS_CUT( nGroup, nProc)) { @@ -220,6 +220,9 @@ BtlGeom::AddCut( int nGroup, int nProc, int nSide, const string& sDes, int nProc return false ; // nome e info con tipo SetNameAndInfo( nId, nGroup, nProc, nSide, sDes, nProcId) ; + // aggiusto l'outline + if ( UseProcessToTrimOutline( nId)) + TrimOutline( nId) ; return true ; } @@ -286,6 +289,9 @@ BtlGeom::AddLongitCut( int nGroup, int nProc, int nSide, const string& sDes, int return false ; // nome e info con tipo SetNameAndInfo( nId, nGroup, nProc, nSide, sDes, nProcId) ; + // aggiusto l'outline + if ( UseProcessToTrimOutline( nId)) + TrimOutline( nId) ; return true ; } @@ -336,6 +342,9 @@ BtlGeom::AddDoubleCut( int nGroup, int nProc, int nSide, const string& sDes, int return false ; // nome e info con tipo SetNameAndInfo( nId, nGroup, nProc, nSide, sDes, nProcId) ; + // aggiusto l'outline + if ( UseProcessToTrimOutline( nId)) + TrimOutline( nId) ; return true ; } @@ -448,6 +457,9 @@ BtlGeom::AddRidgeValleyCut( int nGroup, int nProc, int nSide, const string& sDes return false ; // nome e info con tipo SetNameAndInfo( nId, nGroup, nProc, nSide, sDes, nProcId) ; + // aggiusto l'outline + if ( UseProcessToTrimOutline( nId)) + TrimOutline( nId) ; return true ; } @@ -569,6 +581,9 @@ BtlGeom::AddLapJoint( int nGroup, int nProc, int nSide, const string& sDes, int return false ; // nome e info con tipo SetNameAndInfo( nId, nGroup, nProc, nSide, sDes, nProcId) ; + // aggiusto l'outline + if ( UseProcessToTrimOutline( nId)) + TrimOutline( nId) ; return true ; } @@ -643,6 +658,9 @@ BtlGeom::AddNotch( int nGroup, int nProc, int nSide, const string& sDes, int nPr return false ; // nome e info con tipo SetNameAndInfo( nId, nGroup, nProc, nSide, sDes, nProcId) ; + // aggiusto l'outline + if ( UseProcessToTrimOutline( nId)) + TrimOutline( nId) ; return true ; } @@ -693,6 +711,9 @@ BtlGeom::AddSeathingCut( int nGroup, int nProc, int nSide, const string& sDes, i return false ; // nome e info con tipo SetNameAndInfo( nId, nGroup, nProc, nSide, sDes, nProcId) ; + // aggiusto l'outline + if ( UseProcessToTrimOutline( nId)) + TrimOutline( nId) ; return true ; } diff --git a/EgtExchange.rc b/EgtExchange.rc index 328f5a1..9b28ec1 100644 Binary files a/EgtExchange.rc and b/EgtExchange.rc differ diff --git a/EgtExchange.vcxproj b/EgtExchange.vcxproj index 342f4ab..b2bf8fa 100644 --- a/EgtExchange.vcxproj +++ b/EgtExchange.vcxproj @@ -226,6 +226,7 @@ copy $(TargetPath) \EgtProg\Dll64 + false diff --git a/EgtExchange.vcxproj.filters b/EgtExchange.vcxproj.filters index 74e1bac..1806fc8 100644 --- a/EgtExchange.vcxproj.filters +++ b/EgtExchange.vcxproj.filters @@ -149,6 +149,9 @@ File di origine + + File di origine + diff --git a/ImportBtl.cpp b/ImportBtl.cpp index 4cd01e7..dc0b580 100644 --- a/ImportBtl.cpp +++ b/ImportBtl.cpp @@ -78,7 +78,7 @@ ImportBtl::ImportBtl( void) //---------------------------------------------------------------------------- bool -ImportBtl::Import( const string& sFile, IGeomDB* pGDB, bool bFlatPos) +ImportBtl::Import( const string& sFile, IGeomDB* pGDB, bool bFlatPos, bool bSpecialTrim) { // log di informazioni LOG_INFO( GetEExLogger(), ( "ImportBtl : " + sFile).c_str()) @@ -90,7 +90,7 @@ ImportBtl::Import( const string& sFile, IGeomDB* pGDB, bool bFlatPos) } // inizializzo il gestore geometria pezzi Btl - if ( ! m_BtlGeom.Init( pGDB, bFlatPos)) { + if ( ! m_BtlGeom.Init( pGDB, bFlatPos, bSpecialTrim)) { LOG_ERROR( GetEExLogger(), " Error on BtlGeom.Init") return false ; } @@ -258,6 +258,7 @@ ImportBtl::ReadPart( bool& bEnd) // ciclo sulle linee con i dati generali del pezzo double dLength = 0, dHeight = 0, dWidth = 0 ; bool bLength = false, bHeight = false, bWidth = false, bBox = false ; + bool bOutline = false ; int nUID = 0 ; while ( m_theScanner.GetLine( sLine)) { // se cambio sezione @@ -341,6 +342,7 @@ ImportBtl::ReadPart( bool& bEnd) bEnd = false ; return false ; } + bOutline = true ; } // apertura else if ( sKey == KEY_APERTURE) { @@ -370,6 +372,17 @@ ImportBtl::ReadPart( bool& bEnd) bEnd = false ; return false ; } + // se non trovato l'outline lo aggiungo + if ( ! bOutline) { + if ( ! m_BtlGeom.AddPartStdOutline()) { + string sOut = " Error (AddPartStdOutline) on line " + ToString( m_theScanner.GetCurrLineNbr()) ; + LOG_ERROR( GetEExLogger(), sOut.c_str()) + SkipCurrSection() ; + m_BtlGeom.ErasePart() ; + bEnd = false ; + return false ; + } + } // interpreto le lavorazioni (processing) bool bOk = true ; diff --git a/ImportBtl.h b/ImportBtl.h index c6ee37e..1aff7b8 100644 --- a/ImportBtl.h +++ b/ImportBtl.h @@ -21,7 +21,8 @@ class ImportBtl : public IImportBtl { public : - virtual bool Import( const std::string& sFile, IGeomDB* pGDB, bool bFlatPos = false) ; + virtual bool Import( const std::string& sFile, IGeomDB* pGDB, + bool bFlatPos = false, bool bSpecialTrim = false) ; public : ImportBtl( void) ;