EgtGeomKernel 1.8j2 :

- aggiunte a Zmap GetVolume, GetPartVolume e RemovePart.
This commit is contained in:
Dario Sassi
2017-10-06 07:51:53 +00:00
parent 23af6833ba
commit fc74341862
5 changed files with 120 additions and 40 deletions
+61 -31
View File
@@ -12,7 +12,6 @@
//----------------------------------------------------------------------------
//--------------------------- Include ----------------------------------------
#include "stdafx.h"
#include "CurveLine.h"
#include "VolZmap.h"
@@ -20,7 +19,6 @@
#include "IntersLineSurfTm.h"
#include "/EgtDev/Include/EgtNumUtils.h"
using namespace std ;
//----------------------------------------------------------------------------
@@ -957,12 +955,9 @@ VolZmap::IntersLineEllipticalCylinder( const Vector3d& vtLineDir, const Point3d&
//----------------------------------------------------------------------------
bool
VolZmap::IntersLineMyPolyhedron( const Point3d& ptLineSt, const Vector3d& vtLineDir,
const Frame3d& PolyFrame, double dLenX, double dLenY, double dLenZ, double dDeltaX,
Point3d& ptInt1, Point3d& ptInt2, Vector3d& vtN1, Vector3d& vtN2)
const Frame3d& PolyFrame, double dLenX, double dLenY, double dLenZ, double dDeltaX,
Point3d& ptInt1, Point3d& ptInt2, Vector3d& vtN1, Vector3d& vtN2)
{
double SqIndet = EPS_SMALL * EPS_SMALL ;
Point3d ptP = ptLineSt ;
Vector3d vtV = vtLineDir ;
@@ -1026,15 +1021,12 @@ VolZmap::IntersLineMyPolyhedron( const Point3d& ptLineSt, const Vector3d& vtLine
// Intersezione con la seconda faccia
if ( ptI2.y >= 0 && ptI2.y <= dLenY &&
ptI2.x * dLenY >= dDeltaX * ptI2.y && ( ptI2.x - dLenX) * dLenY <= dDeltaX * ptI2.y) {
if ( nIntNum == 0) {
ptInt1 = ptI2 ;
vtN1 = Z_AX ;
++ nIntNum ;
}
else if ( ( ptInt1 - ptI2).SqLen() > SqIndet) {
else if ( ( ptInt1 - ptI2).SqLen() > SQ_EPS_SMALL) {
ptInt2 = ptI2 ;
vtN2 = Z_AX ;
++ nIntNum ;
@@ -1045,15 +1037,12 @@ VolZmap::IntersLineMyPolyhedron( const Point3d& ptLineSt, const Vector3d& vtLine
if ( nIntNum < 2 &&
ptI3.x >= 0 && ptI3.x <= dLenX &&
ptI3.z >= - ptFacet135.z && ptI3.z <= ptFacet135.z) {
if ( nIntNum == 0) {
ptInt1 = ptI3 ;
vtN1 = Y_AX ;
++ nIntNum ;
}
else if ( ( ptInt1 - ptI3).SqLen() > SqIndet) {
else if ( ( ptInt1 - ptI3).SqLen() > SQ_EPS_SMALL) {
ptInt2 = ptI3 ;
vtN2 = Y_AX ;
++ nIntNum ;
@@ -1064,15 +1053,12 @@ VolZmap::IntersLineMyPolyhedron( const Point3d& ptLineSt, const Vector3d& vtLine
if ( nIntNum < 2 &&
ptI4.x >= dDeltaX && ptI4.x <= dLenX + dDeltaX &&
ptI4.z >= - ptFacet135.z && ptI4.z <= ptFacet135.z) {
if ( nIntNum == 0) {
ptInt1 = ptI4 ;
vtN1 = - Y_AX ;
++ nIntNum ;
}
else if ( ( ptInt1 - ptI4).SqLen() > SqIndet) {
else if ( ( ptInt1 - ptI4).SqLen() > SQ_EPS_SMALL) {
ptInt2 = ptI4 ;
vtN2 = - Y_AX ;
++ nIntNum ;
@@ -1083,15 +1069,12 @@ VolZmap::IntersLineMyPolyhedron( const Point3d& ptLineSt, const Vector3d& vtLine
if ( nIntNum < 2 &&
ptI5.y >= 0 && ptI5.y <= dLenY &&
ptI5.z >= - ptFacet135.z && ptI5.z <= ptFacet135.z) {
if ( nIntNum == 0) {
ptInt1 = ptI5 ;
vtN1 = vtOb ;
++ nIntNum ;
}
else if ( ( ptInt1 - ptI5).SqLen() > SqIndet) {
else if ( ( ptInt1 - ptI5).SqLen() > SQ_EPS_SMALL) {
ptInt2 = ptI5 ;
vtN2 = vtOb ;
++ nIntNum ;
@@ -1102,32 +1085,79 @@ VolZmap::IntersLineMyPolyhedron( const Point3d& ptLineSt, const Vector3d& vtLine
if ( nIntNum < 2 &&
ptI6.y >= 0 && ptI6.y <= dLenY &&
ptI6.z >= - ptFacet135.z && ptI6.z <= ptFacet135.z) {
if ( nIntNum == 0) {
ptInt1 = ptI6;
vtN1 = - vtOb ;
++ nIntNum ;
}
else if ( ( ptInt1 - ptI6).SqLen() > SqIndet) {
else if ( ( ptInt1 - ptI6).SqLen() > SQ_EPS_SMALL) {
ptInt2 = ptI6;
vtN2 = - vtOb ;
++ nIntNum ;
}
}
if ( nIntNum == 2) {
ptInt1.ToGlob( PolyFrame) ;
ptInt2.ToGlob( PolyFrame) ;
vtN1.ToGlob( PolyFrame) ;
vtN2.ToGlob( PolyFrame) ;
return true ;
}
else
return false ;
}
//----------------------------------------------------------------------------
bool
VolZmap::GetVolume( double& dVol) const
{
// verifico lo stato
if ( m_nStatus != OK)
return false ;
// Eseguo il calcolo della lunghezza totale degli spilloni
double dLen = 0 ;
for ( int nMap = 0 ; nMap < int( m_nMapNum) ; ++ nMap) {
for ( int nDex = 0 ; nDex < int( m_Values[nMap].size()) ; ++ nDex) {
for ( int nInt = 0 ; nInt < int( m_Values[nMap][nDex].size()) ; ++ nInt) {
dLen += m_Values[nMap][nDex][nInt].dMax - m_Values[nMap][nDex][nInt].dMin ;
}
}
}
// Il volume si trova moltiplicando per l'area di ogni spillone e dividendo per il numero di mappe
dVol = dLen * ( m_dStep * m_dStep) / m_nMapNum ;
return true ;
}
//----------------------------------------------------------------------------
bool
VolZmap::GetPartVolume( int nPart, double& dVol) const
{
// verifico lo stato
if ( m_nStatus != OK)
return false ;
// Se una sola mappa o il numero di componenti è indefinito, errore
if ( m_nMapNum == 1 || m_nConnectedCompoCount == -1)
return false ;
// Se la componente richiesta non esiste, errore
if ( nPart < 0 || nPart > m_nConnectedCompoCount - 1)
return false ;
// Eseguo il calcolo della lunghezza totale degli spilloni
double dLen = 0 ;
for ( int nMap = 0 ; nMap < int( m_nMapNum) ; ++ nMap) {
for ( int nDex = 0 ; nDex < int( m_Values[nMap].size()) ; ++ nDex) {
for ( int nInt = 0 ; nInt < int( m_Values[nMap][nDex].size()) ; ++ nInt) {
// se il pezzo di spillone appartiene alla parte, ne aggiungo la lunghezza
if ( m_Values[nMap][nDex][nInt].nCompo == nPart + 1) {
dLen += m_Values[nMap][nDex][nInt].dMax - m_Values[nMap][nDex][nInt].dMin ;
}
}
}
}
// Il volume si trova moltiplicando per l'area di ogni spillone e dividendo per il numero di mappe
dVol = dLen * ( m_dStep * m_dStep) / 3 ;
return true ;
}