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

Last change on this file since 3784 was 3784, checked in by Mathieu Morlighem, 15 years ago

removed double ../../include/include.h

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