EgtGeomKernel 1.5g2 :

- aggiunte intersezioni tra linee ed archi
- aggiunte intersezioni tra archi e archi
- aggiunte funzioni di utilità per angoli.
This commit is contained in:
Dario Sassi
2014-07-16 09:08:32 +00:00
parent 19fda49699
commit 56d6307a1c
19 changed files with 1357 additions and 99 deletions
+26 -5
View File
@@ -327,7 +327,7 @@ PolyLine::GetNextULine( double* pdIni, Point3d* pptIni, double* pdFin, Point3d*
//----------------------------------------------------------------------------
bool
PolyLine::NewellPlane( Plane3d& plPlane) const
PolyLine::NewellPlane( Plane3d& plPlane, double& dArea) const
{
// Compute normal as being proportional to projected areas of polygon onto the yz,
// xz, and xy planes. Also compute centroid as representative point on the plane
@@ -356,21 +356,25 @@ PolyLine::NewellPlane( Plane3d& plPlane) const
if ( nNumSide < 3)
return false ;
// Normal must be normalizable (the length of the normal is the double of the area of the polygon)
if ( ! vtN.Normalize())
double dLenN = vtN.Len() ;
if ( dLenN < EPS_SMALL)
return false ;
// Normalize normal and fill in the plane equation fields
vtN /= dLenN ;
// Fill in the plane equation fields
plPlane.vtN = vtN ;
plPlane.dDist = ( ( ptCen - ORIG) * plPlane.vtN) / nNumSide ; // “centroid / n” is the true centroid point
// Set area
dArea = 0.5 * dLenN ;
return true ;
}
//----------------------------------------------------------------------------
bool
PolyLine::IsPlanar( Plane3d& plPlane, double dToler) const
PolyLine::IsPlanar( Plane3d& plPlane, double& dArea, double dToler) const
{
// Compute a representative plane for the polygon
if ( ! NewellPlane( plPlane))
if ( ! NewellPlane( plPlane, dArea))
return false ;
// Test each vertex to see if it is farther from plane than allowed max distance
Point3d ptP ;
@@ -383,6 +387,23 @@ PolyLine::IsPlanar( Plane3d& plPlane, double dToler) const
return true ;
}
//----------------------------------------------------------------------------
bool
PolyLine::GetAreaXY( double& dArea) const
{
// verifico sia chiusa
if ( ! IsClosed())
return false ;
// calcolo l'area considerando solo XY (è la Z di Newell)
dArea = 0 ;
Point3d ptIni, ptFin ;
for ( bool bFound = GetFirstLine( ptIni, ptFin) ; bFound ; bFound = GetNextLine( ptIni, ptFin)) {
dArea += ( ptIni.x - ptFin.x) * ( ptIni.y + ptFin.y) ; // projection on xy
}
dArea = 0.5 * dArea ;
return true ;
}
//----------------------------------------------------------------------------
bool
PolyLine::GetMaxDistanceFromLine( double& dMaxDist, const Point3d& ptAx,