source: issm/trunk/src/c/Bamgx/objects/Triangle.h@ 3775

Last change on this file since 3775 was 3775, checked in by Eric.Larour, 15 years ago

Created include.h header file

File size: 5.2 KB
RevLine 
[3232]1#ifndef _TRIANGLE_H_
2#define _TRIANGLE_H_
3
4#include "../../objects/objects.h"
5#include "../../shared/shared.h"
[3775]6#include "../../include/include.h"
[3232]7#include "../../toolkits/toolkits.h"
8
[3775]9#include "../include/include.h"
10#include "../include/include.h"
[3407]11#include "MeshVertex.h"
[3232]12#include "TriangleAdjacent.h"
13
14namespace bamg {
15
16 //classes
17 class Triangles;
18
19 class Triangle {
20
21 friend class TriangleAdjacent;
22
23 private:
[3407]24 MeshVertex* TriaVertices[3]; // 3 vertices if t is triangle, t[i] allowed by access function, (*t)[i] if pointer
[3232]25 Triangle* TriaAdjTriangles[3]; // 3 pointers toward the adjacent triangles
[3242]26 short TriaAdjSharedEdge[3]; // number of the edges in the adjacent triangles the edge number 1 is the edge number TriaAdjSharedEdge[1] in the Adjacent triangle 1
[3232]27
28 public:
29 Icoor2 det; // determinant du triangle (2 fois l aire des vertices entieres)
30 union {
31 Triangle * link ;
[3243]32 long color;
[3232]33 };
34
35 //Constructors/Destructors
36 Triangle() {}
[3243]37 Triangle(Triangles *Th,long i,long j,long k);
[3407]38 Triangle(MeshVertex *v0,MeshVertex *v1,MeshVertex *v2);
[3232]39
40 //Operators
[3407]41 const MeshVertex & operator[](int i) const {return *TriaVertices[i];};
42 MeshVertex & operator[](int i) {return *TriaVertices[i];};
43 const MeshVertex * operator()(int i) const {return TriaVertices[i];};
44 MeshVertex * & operator()(int i) {return TriaVertices[i];};
[3232]45
46 //Methods
47 void Echo();
[3242]48 int swap(short a1,int=0);
[3243]49 long Optim(short a,int =0);
[3232]50 int Locked(int a)const { return TriaAdjSharedEdge[a]&4;}
51 int Hidden(int a)const { return TriaAdjSharedEdge[a]&16;}
52 int GetAllflag(int a){return TriaAdjSharedEdge[a] & 1020;}
53 void SetAllFlag(int a,int f){TriaAdjSharedEdge[a] = (TriaAdjSharedEdge[a] &3) + (1020 & f);}
54 double QualityQuad(int a,int option=1) const;
[3242]55 short NuEdgeTriangleAdj(int i) const {return TriaAdjSharedEdge[i&3]&3;} // Number of the adjacent edge in adj tria
[3232]56 TriangleAdjacent FindBoundaryEdge(int i) const;
57 TriangleAdjacent Adj(int i) const {return TriangleAdjacent(TriaAdjTriangles[i],TriaAdjSharedEdge[i]&3);};
58 Triangle* TriangleAdj(int i) const {return TriaAdjTriangles[i&3];}
[3407]59 Triangle* Quadrangle(MeshVertex * & v0,MeshVertex * & v1,MeshVertex * & v2,MeshVertex * & v3) const ;
[3243]60 void ReNumbering(Triangle *tb,Triangle *te, long *renu){
[3232]61 if (link >=tb && link <te) link = tb + renu[link -tb];
62 if (TriaAdjTriangles[0] >=tb && TriaAdjTriangles[0] <te) TriaAdjTriangles[0] = tb + renu[TriaAdjTriangles[0]-tb];
63 if (TriaAdjTriangles[1] >=tb && TriaAdjTriangles[1] <te) TriaAdjTriangles[1] = tb + renu[TriaAdjTriangles[1]-tb];
64 if (TriaAdjTriangles[2] >=tb && TriaAdjTriangles[2] <te) TriaAdjTriangles[2] = tb + renu[TriaAdjTriangles[2]-tb];
65 }
[3407]66 void ReNumbering(MeshVertex *vb,MeshVertex *ve, long *renu){
[3232]67 if (TriaVertices[0] >=vb && TriaVertices[0] <ve) TriaVertices[0] = vb + renu[TriaVertices[0]-vb];
68 if (TriaVertices[1] >=vb && TriaVertices[1] <ve) TriaVertices[1] = vb + renu[TriaVertices[1]-vb];
69 if (TriaVertices[2] >=vb && TriaVertices[2] <ve) TriaVertices[2] = vb + renu[TriaVertices[2]-vb];
70 }
[3242]71 void SetAdjAdj(short a){
[3232]72 a &= 3;
73 register Triangle *tt=TriaAdjTriangles[a];
74 TriaAdjSharedEdge [a] &= 55; // remove MarkUnSwap
[3242]75 register short aatt = TriaAdjSharedEdge[a] & 3;
[3232]76 if(tt){
77 tt->TriaAdjTriangles[aatt]=this;
78 tt->TriaAdjSharedEdge[aatt]=a + (TriaAdjSharedEdge[a] & 60 ) ;}// Copy all the mark
79 }
[3242]80 void SetAdj2(short a,Triangle *t,short aat){
[3272]81 TriaAdjTriangles[a]=t; //the adjacent triangle to the edge a is t
[3232]82 TriaAdjSharedEdge[a]=aat; //position of the edge in the adjacent triangle
83 if(t) { //if t!=NULL add adjacent triangle to t (this)
84 t->TriaAdjTriangles[aat]=this;
85 t->TriaAdjSharedEdge[aat]=a;
86 }
87 }
88 void SetTriangleContainingTheVertex() {
89 if (TriaVertices[0]) (TriaVertices[0]->t=this,TriaVertices[0]->vint=0);
90 if (TriaVertices[1]) (TriaVertices[1]->t=this,TriaVertices[1]->vint=1);
91 if (TriaVertices[2]) (TriaVertices[2]->t=this,TriaVertices[2]->vint=2);
92 }
93 void SetHidden(int a){
94 //Get Adjacent Triangle number a
95 register Triangle* t = TriaAdjTriangles[a];
96 //if it exist
97 //C|=D -> C=(C|D) bitwise inclusive OR
98 if(t) t->TriaAdjSharedEdge[TriaAdjSharedEdge[a] & 3] |=16;
99 TriaAdjSharedEdge[a] |= 16;
100 }
101
102 void SetLocked(int a){
103 //mark the edge as on Boundary
104 register Triangle * t = TriaAdjTriangles[a];
105 t->TriaAdjSharedEdge[TriaAdjSharedEdge[a] & 3] |=4;
106 TriaAdjSharedEdge[a] |= 4;
107 }
108 void SetMarkUnSwap(int a){
109 register Triangle * t = TriaAdjTriangles[a];
110 t->TriaAdjSharedEdge[TriaAdjSharedEdge[a] & 3] |=8;
111 TriaAdjSharedEdge[a] |=8 ;
112 }
113 void SetUnMarkUnSwap(int a){
114 register Triangle * t = TriaAdjTriangles[a];
115 t->TriaAdjSharedEdge[TriaAdjSharedEdge[a] & 3] &=55; // 23 + 32
116 TriaAdjSharedEdge[a] &=55 ;
117 }
118 void SetDet() {
119 if(TriaVertices[0] && TriaVertices[1] && TriaVertices[2]) det = bamg::det(*TriaVertices[0],*TriaVertices[1],*TriaVertices[2]);
120 else det = -1; }
121
122 //Inline methods
[3263]123 double qualite() ;
124 void Set(const Triangle &,const Triangles &,Triangles &);
[3407]125 int In(MeshVertex *v) const { return TriaVertices[0]==v || TriaVertices[1]==v || TriaVertices[2]==v ;}
[3232]126
127 };
128
129}
130#endif
Note: See TracBrowser for help on using the repository browser.