MAGiC  V5.0
Mailleurs Automatiques de Géometries intégrés à la Cao
CAD4FE_FaceBoundaryPoint.cpp
Aller à la documentation de ce fichier.
1 //####//------------------------------------------------------------
2 //####//------------------------------------------------------------
3 //####// MAGiC
4 //####// Jean Christophe Cuilliere et Vincent FRANCOIS
5 //####// Departement de Genie Mecanique - UQTR
6 //####//------------------------------------------------------------
7 //####// MAGIC est un projet de recherche de l equipe ERICCA
8 //####// du departement de genie mecanique de l Universite du Quebec a Trois Rivieres
9 //####// http://www.uqtr.ca/ericca
10 //####// http://www.uqtr.ca/
11 //####//------------------------------------------------------------
12 //####//------------------------------------------------------------
13 //####//
14 //####// CAD4FE_FaceBoundaryPoint.cpp
15 //####//
16 //####//------------------------------------------------------------
17 //####//------------------------------------------------------------
18 //####// COPYRIGHT 2000-2024
19 //####// jeu 13 jun 2024 11:58:56 EDT
20 //####//------------------------------------------------------------
21 //####//------------------------------------------------------------
22 
23 
24 #pragma hdrstop
25 
26 #include "gestionversion.h"
27 
29 #include "mg_face.h"
30 #include <math.h>
31 #include "CAD4FE_MCNode.h"
32 #include "CAD4FE_Geometric_Tools.h"
33 
34 
35 #pragma package(smart_init)
36 
37 using namespace CAD4FE;
38 
40 : _face(__refFace), _node(__n)
41 {
42  if (__n->GetRefEdgeMapping().size() != 0)
43  Initialize();
44 }
45 
47 {
48  coedge1=__fbp.coedge1;
49  coedge1T=__fbp.coedge1T;
50  coedge2=__fbp.coedge2;
51  vecTpCoedge1Der[0]=__fbp.vecTpCoedge1Der[0];
52  vecTpCoedge1Der[1]=__fbp.vecTpCoedge1Der[1];
53  coedge2T=__fbp.coedge2T;
54  vecTpCoedge2Der[0]=__fbp.vecTpCoedge2Der[0];
55  vecTpCoedge2Der[1]=__fbp.vecTpCoedge2Der[1];
56  _face=__fbp._face;
57  _node=__n;
61 }
62 
64 {
65 }
66 
68 {
69  coedge1 = NULL;
70  coedge2 = NULL;
71  _mergedVertex = NULL;
72 
73  OT_VECTEUR_3D faceNormal;
74  _face->calcul_normale_unitaire(_node->UV(_face), faceNormal);
77 
78  int dimension = _node->get_lien_topologie_reference()->get_dimension();
79  for (MCNode::EMapIterator itEdge = _node->GetRefEdgeMapping().begin();
80  itEdge != _node->GetRefEdgeMapping().end();
81  itEdge++)
82  {
83  MG_ARETE * edge = itEdge->first;
84  unsigned nb_adjacent_face = edge->get_nb_mg_coarete();
85  for (unsigned i=0; i<nb_adjacent_face; i++)
86  {
87  MG_COARETE *coedge = edge->get_mg_coarete(i);
88  MG_FACE * adjacent_face = coedge->get_boucle()->get_mg_face();
89 
90  if (adjacent_face == _face)
91  {
92  if (dimension == 0)
93  {
94  MG_SOMMET *v1 = edge->get_cosommet1()->get_sommet();
95  MG_SOMMET *v2 = edge->get_cosommet2()->get_sommet();
96  if (coedge->get_orientation() == -1 ) std::swap(v1,v2);
99  {
100  if (_node->IsInVertex(v1))
101  {
102  coedge2 = coedge;
103  coedge2T = itEdge->second;
104  if (_node->GetRefVertexMapping().size()>1)
105  {
106  _mergedVertex = v1;
107  }
108  }
109  if (_node->IsInVertex(v2))
110  {coedge1 = coedge; coedge1T = itEdge->second; }
111  }
112  else
113  {
114  if (v==v1) {coedge2 = coedge; coedge2T = itEdge->second; }
115  if (v==v2) {coedge1 = coedge; coedge1T = itEdge->second; }
116  }
117  }
118  else
119  {
120  coedge1 = coedge; coedge1T = itEdge->second;
121  break;
122  }
123  }
124  }
125  }
126 
127  OT_VECTEUR_3D vecCoedge1Der, vecTpCoedge1DerTemp;
128  coedge1->get_arete()->deriver(coedge1T, vecCoedge1Der);
129  vecCoedge1Der *= coedge1->get_orientation();
130  vecTpCoedge1DerTemp = _tangentTransform*vecCoedge1Der;
131  vecTpCoedge1Der[0]=vecTpCoedge1DerTemp[0];
132  vecTpCoedge1Der[1]=vecTpCoedge1DerTemp[1];
133 
134  if (dimension == 0 && coedge2)
135  {
136  OT_VECTEUR_3D vecCoedge2Der, vecTpCoedge2DerTemp;
137  coedge2->get_arete()->deriver(coedge2T, vecCoedge2Der);
138  vecCoedge2Der *= coedge2->get_orientation();
139  vecTpCoedge2DerTemp = _tangentTransform*vecCoedge2Der;
140  vecTpCoedge2Der[0]=vecTpCoedge2DerTemp[0];
141  vecTpCoedge2Der[1]=vecTpCoedge2DerTemp[1];
142  }
143 }
144 
146 {
147  if (_node->GetRefEdgeMapping().size() == 0)
148  return 1;
149 
150  OT_VECTEUR_3D vecDir(__direction), vecTpDir;
151  vecTpDir = _tangentTransform*vecDir;
152  double angleMin, angleMax, angle;
153 
154  if (coedge2) // the point is on a vertex
156  else
157  angleMin = 0;
158 
159  angleMax = M_PI;
160 
161  angle = GeometricTools::AngleInPlane( vecTpCoedge1Der, vecTpDir );
162 
163  double angularTol = 1E-2;
164  if ( fabs(angle-angleMax) <= angularTol || fabs(angle-angleMin) <= angularTol )
165  return 0;
166  else if ( ( angle > angleMax) || (angle < angleMin) )
167  return -1;
168 
169  return +1;
170 }
171 
172 double FaceBoundaryPoint::GetInteriorDirectionAngle(double __direction[3])
173 {
174  if (_node->GetRefEdgeMapping().size() == 0)
175  return 1;
176 
177  OT_VECTEUR_3D vecDir(__direction), vecTpDir;
178  vecTpDir = _tangentTransform*vecDir;
179  double angleMin, angleMax, angle;
180 
181  if (coedge2) // the point is on a vertex
183  else
184  angleMin = 0;
185 
186  angleMax = M_PI;
187 
188  angle = GeometricTools::AngleInPlane( vecTpCoedge1Der, vecTpDir );
189  if (angle < 0 && fabs(angle+M_PI) < 1E-6*M_PI)
190  angle += 2*M_PI;
191 
192  if ( (angle == angleMax) || (angle == angleMin) )
193  return 0;
194  else if ( angle > angleMax)
195  return (angleMax-angle);
196  else if (angle < angleMin)
197  return (angle-angleMin);
198 
199  return angleMax - angle;
200 }
201 
203 {
204  return _mergedVertex;
205 }
206 
207 
209 {
210  return _node;
211 }
MG_ARETE::get_cosommet2
virtual class MG_COSOMMET * get_cosommet2(void)
Definition: mg_arete.cpp:85
CAD4FE::FaceBoundaryPoint::GetInteriorDirectionAngle
double GetInteriorDirectionAngle(double __direction[3])
Definition: CAD4FE_FaceBoundaryPoint.cpp:172
CAD4FE::FaceBoundaryPoint
Definition: CAD4FE_FaceBoundaryPoint.h:38
gestionversion.h
CAD4FE::FaceBoundaryPoint::vecTpCoedge2Der
double vecTpCoedge2Der[2]
Definition: CAD4FE_FaceBoundaryPoint.h:48
CAD4FE::GeometricTools::GetPlaneFrame
static OT_MATRICE_3D GetPlaneFrame(OT_VECTEUR_3D &__planeNormal)
Definition: CAD4FE_Geometric_Tools.cpp:412
CAD4FE::FaceBoundaryPoint::coedge2T
double coedge2T
Definition: CAD4FE_FaceBoundaryPoint.h:47
MG_COARETE
Definition: mg_coarete.h:31
CAD4FE::MCNode::IsInVertex
bool IsInVertex(MG_SOMMET *)
Definition: CAD4FE_MCNode.cpp:397
MG_COARETE::get_boucle
virtual MG_BOUCLE * get_boucle(void)
Definition: mg_coarete.cpp:53
MG_ELEMENT_TOPOLOGIQUE::get_dimension
virtual int get_dimension(void)=0
OT_MATRICE_3D::transpose
void transpose(OT_MATRICE_3D &res) const
Definition: ot_mathematique.cpp:750
swap
void swap(double2 &a, double2 &b)
Definition: ot_fonctions.cpp:106
CAD4FE::FaceBoundaryPoint::_node
MCNode * _node
Definition: CAD4FE_FaceBoundaryPoint.h:57
CAD4FE::FaceBoundaryPoint::coedge2
MG_COARETE * coedge2
Definition: CAD4FE_FaceBoundaryPoint.h:45
CAD4FE::FaceBoundaryPoint::~FaceBoundaryPoint
~FaceBoundaryPoint()
Definition: CAD4FE_FaceBoundaryPoint.cpp:63
CAD4FE::FaceBoundaryPoint::_mergedVertex
MG_SOMMET * _mergedVertex
Definition: CAD4FE_FaceBoundaryPoint.h:60
CAD4FE::FaceBoundaryPoint::GetNode
MCNode * GetNode()
Definition: CAD4FE_FaceBoundaryPoint.cpp:208
CAD4FE::MCNode::GetRefVertexMapping
VMap & GetRefVertexMapping()
Definition: CAD4FE_MCNode.cpp:136
MG_ARETE::get_nb_mg_coarete
virtual int get_nb_mg_coarete(void)
Definition: mg_arete.cpp:106
CAD4FE::FaceBoundaryPoint::coedge1T
double coedge1T
Definition: CAD4FE_FaceBoundaryPoint.h:44
CAD4FE::FaceBoundaryPoint::_face
MG_FACE * _face
Definition: CAD4FE_FaceBoundaryPoint.h:56
CAD4FE::FaceBoundaryPoint::vecTpCoedge1Der
double vecTpCoedge1Der[2]
Definition: CAD4FE_FaceBoundaryPoint.h:46
CAD4FE::GeometricTools::AngleInPlane
static double AngleInPlane(double *__axisX, double *__direction)
Definition: CAD4FE_Geometric_Tools.cpp:440
CAD4FE::MCNode::UV
OT_VECTEUR_3D & UV(MG_FACE *)
Definition: CAD4FE_MCNode.cpp:432
MG_BOUCLE::get_mg_face
virtual MG_FACE * get_mg_face(void)
Definition: mg_boucle.cpp:102
MG_COARETE::get_orientation
virtual int get_orientation(void)
Definition: mg_coarete.cpp:71
CAD4FE::GeometricTools::MG_FACE_Contains_MG_SOMMET
static bool MG_FACE_Contains_MG_SOMMET(MG_FACE *__face, MG_SOMMET *v)
Definition: CAD4FE_Geometric_Tools.cpp:455
CAD4FE_FaceBoundaryPoint.h
MG_COSOMMET::get_sommet
virtual MG_SOMMET * get_sommet(void)
Definition: mg_cosommet.cpp:83
CAD4FE::FaceBoundaryPoint::TestInteriorDirection
int TestInteriorDirection(double __direction[3])
Definition: CAD4FE_FaceBoundaryPoint.cpp:145
CAD4FE::FaceBoundaryPoint::GetMergedVertex
MG_SOMMET * GetMergedVertex()
Definition: CAD4FE_FaceBoundaryPoint.cpp:202
CAD4FE::FaceBoundaryPoint::_tangentFrame
OT_MATRICE_3D _tangentFrame
Definition: CAD4FE_FaceBoundaryPoint.h:58
OT_VECTEUR_3D
Definition: ot_mathematique.h:94
CAD4FE_MCNode.h
CAD4FE_Geometric_Tools.h
MG_FACE::calcul_normale_unitaire
virtual void calcul_normale_unitaire(double *uv, double *normale)
Definition: mg_face.cpp:248
CAD4FE
Definition: CAD4FE_ClosestPoint_Segment_MG_ARETE.h:34
CAD4FE::FaceBoundaryPoint::FaceBoundaryPoint
FaceBoundaryPoint(MCNode *__n, MG_FACE *__refFace)
Definition: CAD4FE_FaceBoundaryPoint.cpp:39
CAD4FE::MCNode::GetRefEdgeMapping
EMap & GetRefEdgeMapping()
Definition: CAD4FE_MCNode.cpp:135
CAD4FE::MCNode
Definition: CAD4FE_MCNode.h:47
CAD4FE::FaceBoundaryPoint::coedge1
MG_COARETE * coedge1
Definition: CAD4FE_FaceBoundaryPoint.h:43
CAD4FE::MCNode::get_lien_topologie_reference
MG_ELEMENT_TOPOLOGIQUE * get_lien_topologie_reference()
Definition: CAD4FE_MCNode.cpp:126
MG_ARETE::deriver
virtual void deriver(double t, double *xyz)
Definition: mg_arete.cpp:149
MG_ARETE
Definition: mg_arete.h:36
MG_FACE
Definition: mg_face.h:34
CAD4FE::FaceBoundaryPoint::_tangentTransform
OT_MATRICE_3D _tangentTransform
Definition: CAD4FE_FaceBoundaryPoint.h:59
MG_ARETE::get_cosommet1
virtual class MG_COSOMMET * get_cosommet1(void)
Definition: mg_arete.cpp:81
MG_SOMMET
Definition: mg_sommet.h:35
MG_COARETE::get_arete
virtual MG_ARETE * get_arete(void)
Definition: mg_coarete.cpp:58
CAD4FE::FaceBoundaryPoint::Initialize
void Initialize()
Definition: CAD4FE_FaceBoundaryPoint.cpp:67
mg_face.h
CAD4FE::MCNode::EMapIterator
EMap::iterator EMapIterator
Definition: CAD4FE_MCNode.h:53
MG_ARETE::get_mg_coarete
virtual MG_COARETE * get_mg_coarete(int num)
Definition: mg_arete.cpp:228