Include :

- aggiornamenti vari.
This commit is contained in:
Dario Sassi
2015-03-11 09:08:10 +00:00
parent 1d2ad0b47f
commit 07072b370f
8 changed files with 230 additions and 23 deletions
+44
View File
@@ -0,0 +1,44 @@
//----------------------------------------------------------------------------
// EgalTech 2015-2015
//----------------------------------------------------------------------------
// File : EGkIntersLineSurfTm.h Data : 18.02.15 Versione : 1.6b7
// Contenuto : Dichiarazione della classe intersezione linea/piano.
//
//
//
// Modifiche : 18.02.15 DS Creazione modulo.
//
//
//----------------------------------------------------------------------------
#pragma once
#include "/EgtDev/Include/EGkTriangle3d.h"
//----------------------- Macro per import/export ----------------------------
#undef EGK_EXPORT
#if defined( I_AM_EGK) // da definirsi solo nella DLL
#define EGK_EXPORT __declspec( dllexport)
#else
#define EGK_EXPORT __declspec( dllimport)
#endif
//-----------------------------------------------------------------------------
//! dati di intersezione linea - superficie trimesh
struct IntLinStmInfo {
double dU ; //!< parametro sulla linea
int nT ; //!< indice del triangolo della superficie trimesh
Point3d ptI ; //!< punto di intersezione
// costruttori
IntLinStmInfo( void) : dU( 0), nT(0), ptI() {}
IntLinStmInfo( double dUU, int nTT, const Point3d& ptP) : dU( dUU), nT( nTT), ptI( ptP) {}
} ;
//! vettore di IntLinStmInfo
typedef std::vector<IntLinStmInfo> ILSIVECTOR ;
//-----------------------------------------------------------------------------
// Per ora si considerano solo intersezioni semplici, ovvero che attraversano la superficie.
//EGK_EXPORT int IntersLineSurfTm( const Point3d& ptL1, const Point3d& ptL2, const Triangle3d& trTria,
// Point3d& ptInt) ;
EGK_EXPORT bool IntersLineSurfTm( const Point3d& ptL, const Vector3d& vtL, double dLen, const ISurfTriMesh& Stm,
ILSIVECTOR& vInfo) ;
+4 -4
View File
@@ -1,8 +1,8 @@
//----------------------------------------------------------------------------
// EgalTech 2015-2015
//----------------------------------------------------------------------------
// File : EGkIntersLinePlane.h Data : 18.02.15 Versione : 1.6b7
// Contenuto : Dichiarazione della classe intersezione linea/piano.
// File : EGkIntersLineTria.h Data : 18.02.15 Versione : 1.6b7
// Contenuto : Dichiarazione della classe intersezione linea/triangolo.
//
//
//
@@ -25,9 +25,9 @@
//-----------------------------------------------------------------------------
EGK_EXPORT int IntersLineTria( const Point3d& ptL1, const Point3d& ptL2, const Triangle3d& trTria,
Point3d& ptInt) ;
Point3d& ptInt, Point3d& ptInt2) ;
EGK_EXPORT int IntersLineTria( const Point3d& ptL, const Vector3d& vtL, double dLen, const Triangle3d& trTria,
Point3d& ptInt) ;
Point3d& ptInt, Point3d& ptInt2) ;
//-----------------------------------------------------------------------------
// Tipo di intersezione linea-triangolo
+28 -3
View File
@@ -1,13 +1,13 @@
//----------------------------------------------------------------------------
// EgalTech 2014-2014
// EgalTech 2014-2015
//----------------------------------------------------------------------------
// File : EGkPlane3d.h Data : 08.04.14 Versione : 1.5d2
// File : EGkPlane3d.h Data : 25.02.15 Versione : 1.6b7
// Contenuto : Dichiarazione classe piano Plane3d.
//
//
//
// Modifiche : 08.04.14 DS Creazione modulo.
//
// 25.02.15 DS Agg. PointInPlane*.
//
//----------------------------------------------------------------------------
@@ -22,3 +22,28 @@ class Plane3d
Vector3d vtN ;
double dDist ;
} ;
//-----------------------------------------------------------------------------
inline bool
SetPlane( const Point3d& ptP, const Vector3d& vtN, Plane3d& plPlane)
{
if ( vtN.IsSmall())
return false ;
plPlane.vtN = vtN ;
plPlane.dDist = ( ptP - ORIG) * plPlane.vtN ;
return true ;
}
//-----------------------------------------------------------------------------
inline bool
PointInPlaneApprox( const Point3d& ptP, const Plane3d& plPlane)
{
return ( fabs( (( ptP - ORIG) * plPlane.vtN) - plPlane.dDist) < EPS_SMALL) ;
}
//-----------------------------------------------------------------------------
inline bool
PointInPlaneExact( const Point3d& ptP, const Plane3d& plPlane)
{
return ( fabs( (( ptP - ORIG) * plPlane.vtN) - plPlane.dDist) < EPS_ZERO) ;
}
+113
View File
@@ -60,6 +60,8 @@ class Triangle3d
}
const Vector3d& GetN( void) const
{ return vtN ; }
Point3d GetCentroid( void) const
{ return ( ptP[0] + ptP[1] + ptP[2]) / 3 ; }
double GetArea( void) const
{ return (( ptP[1] - ptP[0]) ^ ( ptP[2] - ptP[0])).Len() / 2 ; }
double GetAspectRatio( void) const
@@ -93,3 +95,114 @@ class TriNormals3d
public :
Vector3d vtN[3] ;
} ;
//-----------------------------------------------------------------------------
enum PlaneType { PL_NULL = 0,
PL_XY = 1,
PL_YZ = 2,
PL_ZX = 3} ;
//----------------------------------------------------------------------------
// Piano canonico di miglior proiezione (perpendicolare alla componente maggiore della normale)
inline bool
CalcProjPlane( const Vector3d& vtN, int& nPlane, bool& bCCW)
{
// verifico che la normale non sia nulla
if ( vtN.IsZero())
return false ;
// proiezione sul piano XY (Nz con valore maggiore)
if ( fabs( vtN.z) > fabs( vtN.x) &&
fabs( vtN.z) > fabs( vtN.y)) {
nPlane = PL_XY ;
bCCW = ( vtN.z > 0) ;
}
// proiezione sul piano YZ (Nx con valore maggiore)
else if ( fabs( vtN.x) > fabs( vtN.y)) {
nPlane = PL_YZ ;
bCCW = ( vtN.x > 0) ;
}
// proiezione sul piano ZX (Ny con valore maggiore)
else {
nPlane = PL_ZX ;
bCCW = ( vtN.y > 0) ;
}
return true ;
}
//----------------------------------------------------------------------------
// Prodotto vettoriale nel piano di proiezione ( positivo se i 3 punti in ordine CCW)
inline double
TwoAreaInPlane( int nPlane, const Point3d& ptA, const Point3d& ptB, const Point3d& ptC)
{
switch ( nPlane) {
default : // PL_XY
return ( ptB.x - ptA.x) * ( ptC.y - ptB.y) - ( ptB.y - ptA.y) * ( ptC.x - ptB.x) ;
case PL_YZ :
return ( ptB.y - ptA.y) * ( ptC.z - ptB.z) - ( ptB.z - ptA.z) * ( ptC.y - ptB.y) ;
case PL_ZX :
return ( ptB.z - ptA.z) * ( ptC.x - ptB.x) - ( ptB.x - ptA.x) * ( ptC.z - ptB.z) ;
}
}
//----------------------------------------------------------------------------
// Prodotto scalare nel piano di proiezione
inline double
ProScaInPlane( int nPlane, const Point3d& ptP, const Point3d& ptA, const Point3d& ptB)
{
switch ( nPlane) {
default : // PL_XY
return ( ptP.x - ptA.x) * ( ptB.x - ptA.x) + ( ptP.y - ptA.y) * ( ptB.y - ptA.y) ;
case PL_YZ :
return ( ptP.y - ptA.y) * ( ptB.y - ptA.y) + ( ptP.z - ptA.z) * ( ptB.z - ptA.z) ;
case PL_ZX :
return ( ptP.z - ptA.z) * ( ptB.z - ptA.z) + ( ptP.x - ptA.x) * ( ptB.x - ptA.x) ;
}
}
//----------------------------------------------------------------------------
// Coordinate baricentriche di un punto giacente nel piano del triangolo
inline bool
BarycentricCoord( const Point3d& ptP, const Triangle3d& Tria,
double& dU, double& dV, double& dW)
{
// calcolo del piano ottimale di proiezione
int nPlane ;
bool bCCW ;
if ( ! CalcProjPlane( Tria.GetN(), nPlane, bCCW))
return false ;
// verifico che l'area (doppia) non sia nulla
double d2Area = TwoAreaInPlane( nPlane, Tria.GetP( 0), Tria.GetP( 1), Tria.GetP( 2)) ;
if ( fabs( d2Area) < EPS_SMALL * EPS_SMALL)
return false ;
// calcolo delle coordinate baricentriche
double dDenom = 1 / d2Area ;
dU = TwoAreaInPlane( nPlane, ptP, Tria.GetP( 1), Tria.GetP( 2)) * dDenom ;
dV = TwoAreaInPlane( nPlane, Tria.GetP( 0), ptP, Tria.GetP( 2)) * dDenom ;
dW = TwoAreaInPlane( nPlane, Tria.GetP( 0), Tria.GetP( 1), ptP) * dDenom ;
// devono dare somma unitaria
double dSumm = dU + dV + dW ;
if ( fabs( dSumm) < EPS_ZERO)
return false ;
if ( fabs( dSumm - 1) > EPS_ZERO) {
double dDenom = 1 / dSumm ;
dU *= dDenom ;
dV *= dDenom ;
dW *= dDenom ;
}
return true ;
}
//----------------------------------------------------------------------------
// Normale in un punto del triangolo, come media baricentrica delle normali nei vertici
inline bool
CalcNormal( const Point3d& ptP, const Triangle3d& Tria, const TriNormals3d& Tnorms, Vector3d& vtNorm)
{
// calcolo le coordinate baricentriche del punto
double dU, dV, dW ;
if ( ! BarycentricCoord( ptP, Tria, dU, dV, dW))
return false ;
// calcolo la media
vtNorm = dU * Tnorms.vtN[0] + dV * Tnorms.vtN[1] + dW * Tnorms.vtN[2] ;
// la normalizzo
return vtNorm.Normalize() ;
}
+1 -1
View File
@@ -60,7 +60,7 @@ class IEGrScene
virtual int GetNextSelectedObj( void) = 0 ;
virtual double GetSelectedObjWinZ( int nSel = - 1) = 0 ;
virtual double GetSelectedObjMinWinZ( int nSel = - 1) = 0 ;
virtual bool GetPointFromSelect( int nSelId, const Point3d& ptView, Point3d& ptSel) = 0 ;
virtual bool GetPointFromSelect( int nSelId, const Point3d& ptView, Point3d& ptSel, int& nAux) = 0 ;
virtual bool Project( const Point3d& ptWorld, Point3d& ptView) = 0 ;
virtual bool UnProject( const Point3d& ptView, Point3d& ptWorld) = 0 ;
virtual void Destroy( void) = 0 ;
+27 -14
View File
@@ -147,19 +147,21 @@ EIN_EXPORT int __stdcall EgtCreatePolygonFromSide( int nParentId, int nNumSides
const double ptFin[3], const double vtN[3], int nRefType) ;
// GeomDB Create Surf
EIN_EXPORT int __stdcall EgtCreateSurfTriMeshByFlatContour( int nParentId, int nCrvId, double dLinTol) ;
EIN_EXPORT int __stdcall EgtCreateSurfTriMeshByRegion( int nParentId, int nNumId, const int nCrvIds[], double dLinTol) ;
EIN_EXPORT int __stdcall EgtCreateSurfTriMeshByExtrusion( int nParentId, int nNumId, const int nCrvIds[],
const double vtExtr[3], double dLinTol, int nRefType) ;
EIN_EXPORT int __stdcall EgtCreateSurfTriMeshByRegionExtrusion( int nParentId, int nNumId, const int nCrvIds[],
const double vtExtr[3], double dLinTol, int nRefType) ;
EIN_EXPORT int __stdcall EgtCreateSurfTriMeshByRevolve( int nParentId, int nCrvId,
const double ptAx[3], const double vtAx[3],
BOOL bCapEnds, double dLinTol, int nRefType) ;
EIN_EXPORT int __stdcall EgtCreateSurfTriMeshByScrewing( int nParentId, int nCrvId,
EIN_EXPORT int __stdcall EgtCreateSurfTmByFlatContour( int nParentId, int nCrvId, double dLinTol) ;
EIN_EXPORT int __stdcall EgtCreateSurfTmByRegion( int nParentId, int nNumId, const int nCrvIds[], double dLinTol) ;
EIN_EXPORT int __stdcall EgtCreateSurfTmByExtrusion( int nParentId, int nNumId, const int nCrvIds[],
const double vtExtr[3], double dLinTol, int nRefType) ;
EIN_EXPORT int __stdcall EgtCreateSurfTmByRegionExtrusion( int nParentId, int nNumId, const int nCrvIds[],
const double vtExtr[3], double dLinTol, int nRefType) ;
EIN_EXPORT int __stdcall EgtCreateSurfTmByRevolve( int nParentId, int nCrvId,
const double ptAx[3], const double vtAx[3],
BOOL bCapEnds, double dLinTol, int nRefType) ;
EIN_EXPORT int __stdcall EgtCreateSurfTmByScrewing( int nParentId, int nCrvId,
const double ptAx[3], const double vtAx[3],
double dAngRotDeg, double dMove, double dLinTol, int nRefType) ;
EIN_EXPORT int __stdcall EgtCreateSurfTriMeshRuled( int nParentId, int nCrvId1, int nCrvId2, double dLinTol) ;
EIN_EXPORT int __stdcall EgtCreateSurfTmRuled( int nParentId, int nCrvId1, int nCrvId2, double dLinTol) ;
EIN_EXPORT BOOL __stdcall EgtCreateSurfTmByTriangles( int nParentId, int nNumId, const int nIds[], BOOL bErase) ;
EIN_EXPORT int __stdcall EgtCreateSurfTmBySewing( int nParentId, int nNumId, const int nIds[], BOOL bErase) ;
// GeomDB PartLayer
EIN_EXPORT int __stdcall EgtGetCurrPart( void) ;
@@ -254,7 +256,6 @@ EIN_EXPORT int __stdcall EgtGetPrevSelectedObj( void) ;
EIN_EXPORT BOOL __stdcall EgtChangeGroupFrame( int nId, double ptOrig[3],
double vtX[3], double vtY[3], double vtZ[3], int nRefType) ;
EIN_EXPORT BOOL __stdcall EgtChangeVectorBase( int nId, const double ptB[3], int nRefType) ;
EIN_EXPORT BOOL __stdcall EgtInvertSurface( int nId) ;
EIN_EXPORT BOOL __stdcall EgtModifyText( int nId, const wchar_t* wsNewText) ;
EIN_EXPORT BOOL __stdcall EgtChangeTextFont( int nId, const wchar_t* wsNewFont) ;
EIN_EXPORT BOOL __stdcall EgtFlipText( int nId) ;
@@ -262,7 +263,7 @@ EIN_EXPORT BOOL __stdcall EgtMirrorText( int nId, BOOL bOnL) ;
EIN_EXPORT BOOL __stdcall EgtExplodeText( int nId) ;
EIN_EXPORT BOOL __stdcall EgtSplitText( int nId) ;
// GeomDb CurveModif
// GeomDb Curve Modify
EIN_EXPORT BOOL __stdcall EgtInvertCurve( int nId) ;
EIN_EXPORT BOOL __stdcall EgtModifyCurveStartPoint( int nId, const double ptP[3], int nRefType) ;
EIN_EXPORT BOOL __stdcall EgtModifyCurveEndPoint( int nId, const double ptP[3], int nRefType) ;
@@ -286,6 +287,10 @@ EIN_EXPORT BOOL __stdcall EgtModifyCurveArc3P( int nId, const double ptMid[3], i
EIN_EXPORT BOOL __stdcall EgtExplodeCurveCompo( int nId) ;
EIN_EXPORT BOOL __stdcall EgtExplodeCurveBezier( int nId, BOOL bArcsVsLines, double dLinTol) ;
// GeomDb Surf Modify
EIN_EXPORT BOOL __stdcall EgtInvertSurface( int nId) ;
EIN_EXPORT int __stdcall EgtExtractSurfTmFacetLoops( int nId, int nFacet, int nDestGrpId) ;
// Geo Snap Vector/Point/Frame
EIN_EXPORT BOOL __stdcall EgtStartPoint( int nId, int nRefId, double ptP[3]) ;
EIN_EXPORT BOOL __stdcall EgtEndPoint( int nId, int nRefId, double ptP[3]) ;
@@ -311,6 +316,14 @@ EIN_EXPORT BOOL __stdcall EgtGetMinDistPntSidePointCurve( const double ptP[3], i
EIN_EXPORT BOOL __stdcall EgtCurveArcRadius( int nId, double* pdRad) ;
EIN_EXPORT BOOL __stdcall EgtCurveArcNormVersor( int nId, int nRefId, double vtNorm[3]) ;
EIN_EXPORT BOOL __stdcall EgtCurveCompoCenter( int nId, int nSimpCrv, int nRefId, double ptCen[3]) ;
EIN_EXPORT int __stdcall EgtSurfTmFacetNbr( int nId) ;
EIN_EXPORT int __stdcall EgtSurfTmFacetFromTria( int nId, int nT) ;
EIN_EXPORT BOOL __stdcall EgtSurfTmFacetNearestEndPoint( int nId, int nFacet, const double ptNear[3], int nRefId,
double ptEnd[3], double vtNorm[3]) ;
EIN_EXPORT BOOL __stdcall EgtSurfTmFacetNearestMidPoint( int nId, int nFacet, const double ptNear[3], int nRefId,
double ptMid[3], double vtNorm[3]) ;
EIN_EXPORT BOOL __stdcall EgtSurfTmFacetCenter( int nId, int nFacet, int nRefId, double ptCen[3], double vtNorm[3]) ;
EIN_EXPORT BOOL __stdcall EgtSurfTmFacetNormVersor( int nId, int nFacet, int nRefId, double vtNorm[3]) ;
EIN_EXPORT BOOL __stdcall EgtExtTextNormVersor( int nId, int nRefId, double vtNorm[3]) ;
EIN_EXPORT BOOL __stdcall EgtPointToIdGlob( double ptP[3], int nId) ;
EIN_EXPORT BOOL __stdcall EgtPointToIdLoc( double ptP[3], int nId) ;
@@ -356,7 +369,7 @@ EIN_EXPORT int __stdcall EgtGetNextObjInSelWin( void) ;
EIN_EXPORT BOOL __stdcall EgtUnselectableAdd( int nId) ;
EIN_EXPORT BOOL __stdcall EgtUnselectableRemove( int nId) ;
EIN_EXPORT BOOL __stdcall EgtUnselectableClearAll( void) ;
EIN_EXPORT BOOL __stdcall EgtGetPointFromSelect( int nSelId, int nWinX, int nWinY, double ptSel[3]) ;
EIN_EXPORT BOOL __stdcall EgtGetPointFromSelect( int nSelId, int nWinX, int nWinY, double ptSel[3], int* pnAux) ;
EIN_EXPORT BOOL __stdcall EgtGetGraphicSnapPoint( int nSnap, int nWinX, int nWinY, int nSelW, int nSelH, double ptP[3]) ;
EIN_EXPORT BOOL __stdcall EgtGetGridSnapPointZ( BOOL bSketch, int nWinX, int nWinY, const double ptGrid[3], double ptP[3]) ;
EIN_EXPORT int __stdcall EgtGetLastSnapId( void) ;
+3
View File
@@ -21,6 +21,9 @@ class __declspec( novtable) ISurf : public IGeoObj
public :
virtual bool IsSimple( void) const = 0 ;
virtual bool IsClosed( void) const = 0 ;
virtual bool GetArea( double& dArea) const = 0 ;
virtual bool GetVolume( double& dVolume) const = 0 ;
virtual bool GetCentroid( Point3d& ptCen) const = 0 ;
virtual bool Invert( void) = 0 ;
} ;
+10 -1
View File
@@ -26,7 +26,7 @@ class __declspec( novtable) ISurfTriMesh : public ISurf
{
public :
virtual bool CopyFrom( const IGeoObj* pGObjSrc) = 0 ;
virtual bool Init( int nNumVert, int nNumTria) = 0 ;
virtual bool Init( int nNumVert, int nNumTria, int nNumFacet = 0) = 0 ;
virtual void SetLinearTolerance( double dLinTol) = 0 ;
virtual void SetBoundaryAngle( double dBoundaryAngDeg) = 0 ;
virtual void SetSmoothAngle( double dSmoothAngDeg) = 0 ;
@@ -62,6 +62,15 @@ class __declspec( novtable) ISurfTriMesh : public ISurf
virtual bool GetVertexSmoothNormal( int nV, int nT, Vector3d& vtN) const = 0 ;
virtual bool GetTriangleBoundaryEdges( int nId, TriFlags3d& TFlags) const = 0 ;
virtual bool GetTriangleSmoothNormals( int nId, TriNormals3d& TNrms) const = 0 ;
virtual int GetFacetNum( void) const = 0 ;
virtual int GetFacetSize( void) const = 0 ;
virtual int GetFacetFromTria( int nT) const = 0 ;
virtual bool GetAllTriaInFacet( int nF, INTVECTOR& vT) const = 0 ;
virtual bool GetFacetLoops( int nF, POLYLINEVECTOR& vPL) const = 0 ;
virtual bool GetFacetNearestEndPoint( int nF, const Point3d& ptNear, Point3d& ptEnd, Vector3d& vtN) const = 0 ;
virtual bool GetFacetNearestMidPoint( int nF, const Point3d& ptNear, Point3d& ptMid, Vector3d& vtN) const = 0 ;
virtual bool GetFacetCenter( int nF, Point3d& ptCen, Vector3d& vtN) const = 0 ;
virtual bool GetFacetNormal( int nF, Vector3d& vtN) const = 0 ;
} ;
//-----------------------------------------------------------------------------