Changeset 2985
- Timestamp:
- 02/08/10 14:09:11 (15 years ago)
- Location:
- issm/trunk/src/c/Bamgx
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
issm/trunk/src/c/Bamgx/Mesh2.h
r2984 r2985 14 14 #include <stdlib.h> 15 15 #include <math.h> 16 #include <limits.h>17 #include <time.h>18 16 19 17 #include "meshtype.h" 20 #include " R2.h"18 #include "Metric.h" 21 19 22 20 using namespace std; 21 23 22 namespace bamg { 24 25 //Some parameters26 const double Pi =3.141592653589793238462643383279502884197169399375105820974944592308;27 const float fPi=3.141592653589793238462643383279502884197169399375105820974944592308;28 const int IsVertexOnGeom = 8;29 const int IsVertexOnVertex = 16;30 const int IsVertexOnEdge = 32;31 32 //some functions33 inline int BinaryRand(){34 #ifdef RAND_MAX35 const long HalfRandMax = RAND_MAX/2;36 return rand() < HalfRandMax;37 #else38 return rand() & 16384; //2^14 (for sun because RAND_MAX is not def in stdlib.h)39 #endif40 }41 42 //typedef43 typedef P2<Icoor1,Icoor2> I2;44 typedef P2xP2<Int2,Int4> I2xI2;45 typedef P2<Real8,Real8> R2;46 typedef P2<Real4,Real8> R2xR2;47 48 }49 #include "Metric.h"50 51 namespace bamg {52 53 inline float OppositeAngle(float a){return a<0 ? fPi+a:a-fPi;}54 inline double OppositeAngle(double a){return a<0 ? Pi+a:a- Pi;}55 56 Icoor2 inline det(const I2 &a,const I2 & b,const I2 &c){57 register Icoor2 bax = b.x - a.x ,bay = b.y - a.y;58 register Icoor2 cax = c.x - a.x ,cay = c.y - a.y;59 return bax*cay - bay*cax;60 }61 62 //Intermediary63 Int4 AGoodNumberPrimeWith(Int4 n);64 65 //triangle numbering definitions66 static const Int2 VerticesOfTriangularEdge[3][2] = {{1,2},{2,0},{0,1}};67 static const Int2 EdgesVertexTriangle[3][2] = {{1,2},{2,0},{0,1}};68 static const Int2 OppositeVertex[3] = {0,1,2};69 static const Int2 OppositeEdge[3] = {0,1,2};70 static const Int2 NextEdge[3] = {1,2,0};71 static const Int2 PreviousEdge[3] = {2,0,1};72 static const Int2 NextVertex[3] = {1,2,0};73 static const Int2 PreviousVertex[3] = {2,0,1};74 23 75 24 //classes -
issm/trunk/src/c/Bamgx/meshtype.h
r2984 r2985 1 1 #ifndef MESHTYPE_H 2 2 #define MESHTYPE_H 3 #include <limits.h> 3 4 #include "R2.h" 5 4 6 namespace bamg { 7 8 //typedefs 9 typedef float Real4; 10 typedef double Real8; 11 typedef short Int1; 12 typedef short Int2; 13 typedef long Int4; 14 typedef int Icoor1; 15 #if LONG_BIT > 63 //64 bits or more 16 typedef long Icoor2; 17 #else //32 bits 18 typedef double Icoor2; 19 #endif 20 typedef P2<Icoor1,Icoor2> I2; 21 typedef P2xP2<Int2,Int4> I2xI2; 22 typedef P2<Real8,Real8> R2; 23 typedef P2<Real4,Real8> R2xR2; 24 25 //Some parameters 26 const double Pi =3.141592653589793238462643383279502884197169399375105820974944592308; 27 const float fPi=3.141592653589793238462643383279502884197169399375105820974944592308; 28 const int IsVertexOnGeom = 8; 29 const int IsVertexOnVertex = 16; 30 const int IsVertexOnEdge = 32; 31 static const Int2 VerticesOfTriangularEdge[3][2] = {{1,2},{2,0},{0,1}}; 32 static const Int2 EdgesVertexTriangle[3][2] = {{1,2},{2,0},{0,1}}; 33 static const Int2 OppositeVertex[3] = {0,1,2}; 34 static const Int2 OppositeEdge[3] = {0,1,2}; 35 static const Int2 NextEdge[3] = {1,2,0}; 36 static const Int2 PreviousEdge[3] = {2,0,1}; 37 static const Int2 NextVertex[3] = {1,2,0}; 38 static const Int2 PreviousVertex[3] = {2,0,1}; 39 #if LONG_BIT > 63 40 const Icoor1 MaxICoor = 1073741823; // 2^30-1 41 #else 42 const Icoor1 MaxICoor = 8388608; // 2^23 43 #endif 44 const Icoor2 MaxICoor22 = Icoor2(2)*Icoor2(MaxICoor) * Icoor2(MaxICoor) ; 5 45 6 46 //template functions … … 11 51 template<class T> inline double Norme (const T &a){return sqrt(a*a);} 12 52 template<class T> inline void Exchange (T& a,T& b) {T c=a;a=b;b=c;} 13 14 // for pb on microsoft compiler15 53 template<class T> inline T Max3 (const T &a,const T & b,const T & c){return Max(Max(a,b),c);} 16 54 template<class T> inline T Min3 (const T &a,const T & b,const T & c){return Min(Min(a,b),c);} 17 55 18 typedef float Real4; 19 typedef double Real8; 20 typedef short Int1; 21 typedef short Int2; 22 typedef long Int4; 56 //some functions 57 Int4 AGoodNumberPrimeWith(Int4 n); 23 58 24 #if LONG_BIT > 63 25 // for alpha and silicon 26 typedef int Icoor1; 27 typedef long Icoor2; 28 const Icoor1 MaxICoor = 1073741823; // 2^30-1 29 const Icoor2 MaxICoor22 = Icoor2(2)*Icoor2(MaxICoor) * Icoor2(MaxICoor) ; 59 //Inline functions 60 inline int BinaryRand(){ 61 #ifdef RAND_MAX 62 const long HalfRandMax = RAND_MAX/2; 63 return rand() < HalfRandMax; 30 64 #else 31 typedef int Icoor1; 32 typedef double Icoor2; 33 const Icoor1 MaxICoor = 8388608; // 2^23 34 const Icoor2 MaxICoor22 = Icoor2(2)*Icoor2(MaxICoor) * Icoor2(MaxICoor) ; 65 return rand() & 16384; //2^14 (for sun because RAND_MAX is not def in stdlib.h) 35 66 #endif 36 class Triangles; 67 } 68 inline float OppositeAngle(float a){return a<0 ? fPi+a:a-fPi;} 69 inline double OppositeAngle(double a){return a<0 ? Pi+a:a- Pi;} 70 71 Icoor2 inline det(const I2 &a,const I2 & b,const I2 &c){ 72 register Icoor2 bax = b.x - a.x ,bay = b.y - a.y; 73 register Icoor2 cax = c.x - a.x ,cay = c.y - a.y; 74 return bax*cay - bay*cax; 75 } 76 77 37 78 } 38 79 #endif
Note:
See TracChangeset
for help on using the changeset viewer.