EgtGeomKernel 2.2d1 :
- alla classe Polygon3d aggiunto metodo Add - nella classe SurfFlatRegion corretto possesso curva in AddExtLoop e AddIntLoop - gli attributi delle entità vengono assegnati se non vuoti, altrimenti vengono rimossi.
This commit is contained in:
Binary file not shown.
+13
-5
@@ -822,11 +822,19 @@ GdbObj::RemoveName( void)
|
||||
bool
|
||||
GdbObj::SetInfo( const string& sKey, const string& sInfo)
|
||||
{
|
||||
// verifico esistenza (con eventuale creazione) degli attributi
|
||||
if ( GetSafeAttribs() == nullptr)
|
||||
return false ;
|
||||
// assegno l'Info
|
||||
return m_pAttribs->SetInfo( sKey, sInfo) ;
|
||||
// se Info non vuota
|
||||
if ( ! IsEmptyOrSpaces( sInfo)) {
|
||||
// verifico esistenza (con eventuale creazione) degli attributi
|
||||
if ( GetSafeAttribs() == nullptr)
|
||||
return false ;
|
||||
// eseguo assegnazione
|
||||
return m_pAttribs->SetInfo( sKey, sInfo) ;
|
||||
}
|
||||
// altrimenti
|
||||
else {
|
||||
// se esiste, la rimuovo
|
||||
return ( m_pAttribs == nullptr || m_pAttribs->RemoveInfo( sKey)) ;
|
||||
}
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
+48
-8
@@ -1,7 +1,7 @@
|
||||
//----------------------------------------------------------------------------
|
||||
// EgalTech 2015-2017
|
||||
// EgalTech 2015-2020
|
||||
//----------------------------------------------------------------------------
|
||||
// File : Polygon3d.cpp Data : 15.10.17 Versione : 1.8j3
|
||||
// File : Polygon3d.cpp Data : 03.04.20 Versione : 2.2d1
|
||||
// Contenuto : Implementazione della classe Polygon3d.
|
||||
//
|
||||
//
|
||||
@@ -14,6 +14,9 @@
|
||||
//--------------------------- Include ----------------------------------------
|
||||
#include "stdafx.h"
|
||||
#include "PolygonPlane.h"
|
||||
#include "CurveComposite.h"
|
||||
#include "SurfFlatRegion.h"
|
||||
#include "GeoConst.h"
|
||||
#include "/EgtDev/Include/EgkPolygon3d.h"
|
||||
|
||||
using namespace std ;
|
||||
@@ -39,6 +42,8 @@ Polygon3d::ClearSides( void)
|
||||
bool
|
||||
Polygon3d::FromRectangle( double dDimX, double dDimY)
|
||||
{
|
||||
// pulisco tutto
|
||||
Clear() ;
|
||||
// verifico i dati
|
||||
if ( dDimX < EPS_SMALL || dDimY < EPS_SMALL)
|
||||
return false ;
|
||||
@@ -57,8 +62,8 @@ Polygon3d::FromRectangle( double dDimX, double dDimY)
|
||||
bool
|
||||
Polygon3d::FromTriangle( const Triangle3d& trTria)
|
||||
{
|
||||
// annullo il piano del poligono
|
||||
m_Plane.Reset() ;
|
||||
// pulisco tutto
|
||||
Clear() ;
|
||||
// verifico che il triangolo sia valido
|
||||
if ( ! trTria.IsValid())
|
||||
return false ;
|
||||
@@ -76,8 +81,8 @@ Polygon3d::FromTriangle( const Triangle3d& trTria)
|
||||
bool
|
||||
Polygon3d::FromPolyLine( const PolyLine& PL)
|
||||
{
|
||||
// annullo il piano del poligono
|
||||
m_Plane.Reset() ;
|
||||
// pulisco tutto
|
||||
Clear() ;
|
||||
// verifico sia chiusa e piana
|
||||
Plane3d plPlane ;
|
||||
double dArea ;
|
||||
@@ -101,6 +106,8 @@ Polygon3d::FromPolyLine( const PolyLine& PL)
|
||||
bool
|
||||
Polygon3d::FromPlaneTrimmedWithBox( const Plane3d& plPlane, const Point3d& ptMin, const Point3d& ptMax)
|
||||
{
|
||||
// pulisco tutto
|
||||
Clear() ;
|
||||
// il piano e il box devono essere validi
|
||||
if ( plPlane.GetVersN().IsSmall() || AreSamePointApprox( ptMin, ptMax))
|
||||
return false ;
|
||||
@@ -140,8 +147,7 @@ bool
|
||||
Polygon3d::FromPlaneTrimmedWithBox( const Point3d& ptOn, const Vector3d& vtN, const Point3d& ptMin, const Point3d& ptMax)
|
||||
{
|
||||
Plane3d plPlane ;
|
||||
if ( plPlane.Set( ptOn, vtN))
|
||||
return false ;
|
||||
plPlane.Set( ptOn, vtN) ;
|
||||
return FromPlaneTrimmedWithBox( plPlane, ptMin, ptMax) ;
|
||||
}
|
||||
|
||||
@@ -236,6 +242,40 @@ Polygon3d::Trim( const Polygon3d& plyOther, bool bInVsOut, bool bOnEq)
|
||||
return Trim( plyOther.m_Plane, bInVsOut, bOnEq) ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
Polygon3d::Add( const Polygon3d& plyOther)
|
||||
{
|
||||
// verifico non siano vuoti
|
||||
if ( GetSideCount() == 0 || ! plyOther.IsValid())
|
||||
return true ;
|
||||
// verifico siano complanari
|
||||
if ( ! AreSameVectorApprox( GetVersN(), plyOther.GetVersN()) &&
|
||||
abs( GetPlaneDist() - plyOther.GetPlaneDist()) > EPS_SMALL)
|
||||
return false ;
|
||||
// creo la regione del poligono
|
||||
CurveComposite crvThis ;
|
||||
crvThis.FromPolyLine( GetPolyLine()) ;
|
||||
SurfFlatRegion frThis ;
|
||||
if ( ! frThis.AddExtLoop( crvThis))
|
||||
return false ;
|
||||
// creo la regione dell'altro poligono
|
||||
CurveComposite crvOther ;
|
||||
crvOther.FromPolyLine( plyOther.GetPolyLine()) ;
|
||||
SurfFlatRegion frOther ;
|
||||
if ( ! frOther.AddExtLoop( crvOther))
|
||||
return false ;
|
||||
// unisco le due regioni e verifico che il risultato sia un solo pezzo
|
||||
if ( ! frThis.Add( frOther) && frThis.GetChunkCount() != 1)
|
||||
return false ;
|
||||
// recupero il contorno della regione
|
||||
PolyLine PL ;
|
||||
if ( ! frThis.ApproxLoopWithLines( 0, 0, EPS_SMALL, ANG_TOL_MIN_DEG, ICurve::APL_STD, PL))
|
||||
return false ;
|
||||
// lo impongo come nuovo poligono
|
||||
return FromPolyLine( PL) ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
PolyLine
|
||||
Polygon3d::GetPolyLine( void) const
|
||||
|
||||
+28
-14
@@ -84,22 +84,29 @@ SurfFlatRegion::AddExtLoop( const ICurve& cCrv)
|
||||
bool
|
||||
SurfFlatRegion::AddExtLoop( ICurve* pCrv)
|
||||
{
|
||||
// acquisisco la curva
|
||||
PtrOwner<ICurve> pMyCrv( pCrv) ;
|
||||
if ( IsNull( pMyCrv))
|
||||
return false ;
|
||||
// verifico sia chiusa
|
||||
if ( ! pMyCrv->IsClosed())
|
||||
return false ;
|
||||
// verifico sia piana e imposto estrusione come normale al piano
|
||||
double dArea ;
|
||||
Plane3d plPlane ;
|
||||
if ( ! pCrv->GetArea( plPlane, dArea))
|
||||
if ( ! pMyCrv->GetArea( plPlane, dArea))
|
||||
return false ;
|
||||
pCrv->SetExtrusion( plPlane.GetVersN()) ;
|
||||
pCrv->SetThickness( 0) ;
|
||||
pMyCrv->SetExtrusion( plPlane.GetVersN()) ;
|
||||
pMyCrv->SetThickness( 0) ;
|
||||
// rimuovo eventuali sovrapposizioni (calcolate nel suo piano)
|
||||
ICURVEPLIST CrvLst ;
|
||||
if ( ! RemoveCurveOverlaps( pCrv, true, true, CrvLst))
|
||||
if ( ! RemoveCurveOverlaps( Release( pMyCrv), true, true, CrvLst))
|
||||
return false ;
|
||||
// aggiungo le singole curve
|
||||
bool bOk = true ;
|
||||
for ( auto& pCrv : CrvLst) {
|
||||
for ( auto& pSingCrv : CrvLst) {
|
||||
// se curva composita
|
||||
CurveComposite* pCrvCo = GetBasicCurveComposite( pCrv) ;
|
||||
CurveComposite* pCrvCo = GetBasicCurveComposite( pSingCrv) ;
|
||||
if ( pCrvCo != nullptr) {
|
||||
// unisco eventuali tratti allineati
|
||||
pCrvCo->MergeCurves( LIN_TOL_MIN, ANG_TOL_STD_DEG) ;
|
||||
@@ -107,7 +114,7 @@ SurfFlatRegion::AddExtLoop( ICurve* pCrv)
|
||||
RemoveCurveSpikes( pCrvCo) ;
|
||||
}
|
||||
// aggiungo il loop
|
||||
if ( ! AddSimpleExtLoop( pCrv))
|
||||
if ( ! AddSimpleExtLoop( pSingCrv))
|
||||
bOk = false ;
|
||||
}
|
||||
return bOk ;
|
||||
@@ -230,22 +237,29 @@ SurfFlatRegion::AddIntLoop( const ICurve& cCrv)
|
||||
bool
|
||||
SurfFlatRegion::AddIntLoop( ICurve* pCrv)
|
||||
{
|
||||
// acquisisco la curva
|
||||
PtrOwner<ICurve> pMyCrv( pCrv) ;
|
||||
if ( IsNull( pMyCrv))
|
||||
return false ;
|
||||
// verifico sia chiusa
|
||||
if ( ! pMyCrv->IsClosed())
|
||||
return false ;
|
||||
// verifico sia piana e imposto estrusione come normale al piano
|
||||
double dArea ;
|
||||
Plane3d plPlane ;
|
||||
if ( ! pCrv->GetArea( plPlane, dArea))
|
||||
if ( ! pMyCrv->GetArea( plPlane, dArea))
|
||||
return false ;
|
||||
pCrv->SetExtrusion( plPlane.GetVersN()) ;
|
||||
pCrv->SetThickness( 0) ;
|
||||
pMyCrv->SetExtrusion( plPlane.GetVersN()) ;
|
||||
pMyCrv->SetThickness( 0) ;
|
||||
// rimuovo eventuali sovrapposizioni (calcolate nel suo piano)
|
||||
ICURVEPLIST CrvLst ;
|
||||
if ( ! RemoveCurveOverlaps( pCrv, true, true, CrvLst))
|
||||
if ( ! RemoveCurveOverlaps( Release( pMyCrv), true, true, CrvLst))
|
||||
return false ;
|
||||
// aggiungo le singole curve
|
||||
bool bOk = true ;
|
||||
for ( auto& pCrv : CrvLst) {
|
||||
for ( auto& pSingCrv : CrvLst) {
|
||||
// se curva composita
|
||||
CurveComposite* pCrvCo = GetBasicCurveComposite( pCrv) ;
|
||||
CurveComposite* pCrvCo = GetBasicCurveComposite( pSingCrv) ;
|
||||
if ( pCrvCo != nullptr) {
|
||||
// unisco eventuali tratti allineati
|
||||
pCrvCo->MergeCurves( LIN_TOL_MIN, ANG_TOL_STD_DEG) ;
|
||||
@@ -253,7 +267,7 @@ SurfFlatRegion::AddIntLoop( ICurve* pCrv)
|
||||
RemoveCurveSpikes( pCrvCo) ;
|
||||
}
|
||||
// aggiungo il loop
|
||||
if ( ! AddSimpleIntLoop( pCrv))
|
||||
if ( ! AddSimpleIntLoop( pSingCrv))
|
||||
bOk = false ;
|
||||
}
|
||||
return bOk ;
|
||||
|
||||
+3
-3
@@ -156,13 +156,13 @@ class SurfTriMesh : public ISurfTriMesh, public IGeoObjRW
|
||||
bool CopyFrom( const IGeoObj* pGObjSrc) override ;
|
||||
bool Init( int nNumVert, int nNumTria, int nNumFacet = 0) override ;
|
||||
void SetLinearTolerance( double dLinTol) override
|
||||
{ m_dLinTol = (std::max)( dLinTol, EPS_SMALL) ; }
|
||||
{ m_dLinTol = std::max( dLinTol, EPS_SMALL) ; }
|
||||
void SetBoundaryAngle( double dBoundaryAngDeg) override
|
||||
{ m_dBoundaryAng = (std::max)( dBoundaryAngDeg, EPS_ANG_SMALL) ;
|
||||
{ m_dBoundaryAng = std::max( dBoundaryAngDeg, EPS_ANG_SMALL) ;
|
||||
m_dCosBndAng = cos( m_dBoundaryAng * DEGTORAD) ;
|
||||
m_OGrMgr.Reset() ; }
|
||||
void SetSmoothAngle( double dSmoothAngDeg) override
|
||||
{ m_dSmoothAng = (std::max)( dSmoothAngDeg, EPS_ANG_SMALL) ;
|
||||
{ m_dSmoothAng = std::max( dSmoothAngDeg, EPS_ANG_SMALL) ;
|
||||
m_dCosSmAng = cos( m_dSmoothAng * DEGTORAD) ;
|
||||
m_OGrMgr.Reset() ; }
|
||||
int AddVertex( const Point3d& ptVert) override ;
|
||||
|
||||
Reference in New Issue
Block a user