From 7b7fdcdcfead843e399644e0ca6f7e4bc649a51b Mon Sep 17 00:00:00 2001 From: Dario Sassi Date: Tue, 1 Apr 2014 07:38:24 +0000 Subject: [PATCH] Include : - aggiunti triangoli. --- EGkTriangle3d.h | 53 ++++++++++++++++++++++++++++++++++++++++++++++++ EgkSurfTriMesh.h | 10 +++++++-- 2 files changed, 61 insertions(+), 2 deletions(-) create mode 100644 EGkTriangle3d.h diff --git a/EGkTriangle3d.h b/EGkTriangle3d.h new file mode 100644 index 0000000..d570091 --- /dev/null +++ b/EGkTriangle3d.h @@ -0,0 +1,53 @@ +//---------------------------------------------------------------------------- +// EgalTech 2014-2014 +//---------------------------------------------------------------------------- +// File : EGkTria3d.h Data : 30.03.14 Versione : 1.5c9 +// Contenuto : Dichiarazione classe triangolo Triangle3d. +// +// +// +// Modifiche : 30.03.14 DS Creazione modulo. +// +// +//---------------------------------------------------------------------------- + +#pragma once + +#include "/EgtDev/Include/EGkPoint3d.h" + +//----------------------------------------------------------------------------- +class Triangle3d +{ + public : + Triangle3d( void) + {} + void Set( const Point3d& ptP0, const Point3d& ptP1, const Point3d& ptP2) + { ptP[0] = ptP0 ; ptP[1] = ptP1 ; ptP[2] = ptP2 ; vtN.Set( 0, 0, 0) ; } + void Set( const Point3d& ptP0, const Point3d& ptP1, const Point3d& ptP2, const Vector3d& vtV) + { ptP[0] = ptP0 ; ptP[1] = ptP1 ; ptP[2] = ptP2 ; vtN = vtV ; } + bool Validate( void) + { if ( AreSamePointNear( ptP[0], ptP[1]) || AreSamePointNear( ptP[0], ptP[2])) + return false ; + Vector3d vtV = ( ptP[1] - ptP[0]) ^ ( ptP[2] - ptP[0]) ; + vtV.Normalize() ; + if ( ! vtN.IsZero()) + return AreSameVectorNear( vtV, vtN) ; + vtN = vtV ; + return true ; + } + const Point3d& GetP( int nId) const + { if ( nId >= 0 && nId < 3) + return ptP[nId] ; + else if ( nId < 0) + return ptP[0] ; + else + return ptP[2] ; + } + const Vector3d& GetN( void) const + { return vtN ; } + + private : + Point3d ptP[3] ; + Vector3d vtN ; +} ; + diff --git a/EgkSurfTriMesh.h b/EgkSurfTriMesh.h index bc08e25..7757664 100644 --- a/EgkSurfTriMesh.h +++ b/EgkSurfTriMesh.h @@ -14,6 +14,7 @@ #pragma once #include "/EgtDev/Include/EGkSurf.h" +#include "/EgtDev/Include/EGkTriangle3d.h" //---------------------------------------------------------------------------- class __declspec( novtable) ISurfTriMesh : public ISurf @@ -23,8 +24,13 @@ class __declspec( novtable) ISurfTriMesh : public ISurf virtual bool Init( int nNumVert, int nNumTria) = 0 ; virtual int AddVertex( const Point3d& ptVert) = 0 ; virtual int AddTriangle( const int nIdVert[3]) = 0 ; - virtual int GetFirstTriangle( Point3d& ptP0, Point3d& ptP1, Point3d& ptP2) const = 0 ; - virtual int GetNextTriangle( int nId, Point3d& ptP0, Point3d& ptP1, Point3d& ptP2) const = 0 ; + virtual bool AdjustTopology( void) = 0 ; + virtual int GetVertexNum( void) const = 0 ; + virtual int GetTriangleNum( void) const = 0 ; + virtual int GetFirstVertex( Point3d& ptP) const = 0 ; + virtual int GetNextVertex( int nId, Point3d& ptP) const = 0 ; + virtual int GetFirstTriangle( Triangle3d& Tria) const = 0 ; + virtual int GetNextTriangle( int nId, Triangle3d& Tria) const = 0 ; } ; //-----------------------------------------------------------------------------