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:
+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
|
||||
|
||||
Reference in New Issue
Block a user