Skip to content
Snippets Groups Projects
Commit 55ffbb77 authored by Christophe Geuzaine's avatar Christophe Geuzaine
Browse files

fix rec ori

parent a869aef8
No related branches found
No related tags found
No related merge requests found
// $Id: BDS.cpp,v 1.98 2008-02-16 20:42:40 geuzaine Exp $
// $Id: BDS.cpp,v 1.99 2008-02-16 21:25:45 geuzaine Exp $
//
// Copyright (C) 1997-2007 C. Geuzaine, J.-F. Remacle
//
......@@ -597,7 +597,6 @@ bool BDS_Mesh::split_edge(BDS_Edge * e, BDS_Point *mid)
orientation = 1;
else
orientation = -1;
break;
}
}
......@@ -937,7 +936,6 @@ bool BDS_Mesh::recombine_edge(BDS_Edge * e)
*/
// we test if the edge is deleted
// return false;
if(e->deleted)
return false;
if(e->numfaces() != 2 || e->numTriangles() != 2)
......@@ -945,17 +943,14 @@ bool BDS_Mesh::recombine_edge(BDS_Edge * e)
if(e->g && e->g->classif_degree == 1)
return false;
BDS_Point *op[2];
BDS_Point *p1 = e->p1;
BDS_Point *p2 = e->p2;
BDS_Point *op[2];
e->oppositeof(op);
BDS_Point *pts1[4];
e->faces(0)->getNodes(pts1);
// FIXME !!!!!!!!!!!!!!!!!
// should ensure that orientation is unchanged
BDS_Edge *p1_op1 = find_edge(p1, op[0], e->faces(0));
BDS_Edge *op1_p2 = find_edge(op[0], p2, e->faces(0));
BDS_Edge *p1_op2 = find_edge(p1, op[1], e->faces(1));
......@@ -972,7 +967,22 @@ bool BDS_Mesh::recombine_edge(BDS_Edge * e)
}
del_edge(e);
BDS_Face *f = add_quadrangle (p1_op1, op1_p2, op2_p2, p1_op2);
int orientation = 0;
for(int i = 0; i < 3; i++) {
if(pts1[i] == p1) {
if(pts1[(i + 1) % 3] == p2)
orientation = 1;
else
orientation = -1;
break;
}
}
BDS_Face *f;
if(orientation < 0)
f = add_quadrangle(p1_op1, op1_p2, op2_p2, p1_op2);
else
f = add_quadrangle(p1_op1, p1_op2, op2_p2, op1_p2);
f->g = g;
p1->config_modified = true;
......@@ -1127,11 +1137,8 @@ bool test_move_point_parametric_triangle(BDS_Point *p, double u, double v, BDS_F
return ori_init*ori_final > 0;
}
/**
d^2_i = (x^2_i - x)^T M (x_i - x)
= M11 (x_i - x)^2 + 2 M21 (x_i-x)(y_i-y) + M22 (y_i-y)^2
~:-)
*/
// d^2_i = (x^2_i - x)^T M (x_i - x)
// = M11 (x_i - x)^2 + 2 M21 (x_i-x)(y_i-y) + M22 (y_i-y)^2
struct smoothVertexData{
BDS_Point *p;
......@@ -1305,7 +1312,8 @@ bool BDS_Mesh::smooth_point_centroid(BDS_Point *p, GFace *gf, bool test_quality)
p->Z = oldZ;
normal_triangle(n[0], n[1], n[2], norm2);
oldWorst = std::min(oldWorst, qmTriangle(*it, QMTRI_RHO));
double ps; prosca (norm1, norm2, &ps);
double ps;
prosca(norm1, norm2, &ps);
if(ps < .5) return false;
}
++it;
......
......@@ -173,8 +173,8 @@ class BDS_Point
// and is propagated
double _lcBGM, _lcPTS;
public:
double X,Y,Z; // Real COORDINATES
double u,v; // Parametric COORDINATES
double X, Y, Z;
double u, v;
bool config_modified;
int iD;
BDS_GeomEntity *g;
......@@ -202,7 +202,8 @@ public:
}
void getTriangles(std::list<BDS_Face *> &t) const;
BDS_Point(int id, double x=0, double y=0, double z=0)
: _lcBGM(1.e22),_lcPTS(1.e22),X(x),Y(y),Z(z),u(0),v(0),config_modified(true),iD(id),g(0)
: _lcBGM(1.e22), _lcPTS(1.e22), X(x), Y(y), Z(z), u(0), v(0),
config_modified(true), iD(id), g(0)
{
}
};
......@@ -260,7 +261,8 @@ public:
}
inline void del(BDS_Face *t)
{
_faces.erase(std::remove_if(_faces.begin(),_faces.end() , std::bind2nd(std::equal_to<BDS_Face*>(), t)) ,
_faces.erase(std::remove_if(_faces.begin(),_faces.end(),
std::bind2nd(std::equal_to<BDS_Face*>(), t)),
_faces.end());
}
......@@ -268,7 +270,9 @@ public:
void update()
{
_length = sqrt((p1->X-p2->X)*(p1->X-p2->X)+(p1->Y-p2->Y)*(p1->Y-p2->Y)+(p1->Z-p2->Z)*(p1->Z-p2->Z));
_length = sqrt((p1->X - p2->X) * (p1->X - p2->X) +
(p1->Y - p2->Y) * (p1->Y - p2->Y) +
(p1->Z - p2->Z) * (p1->Z - p2->Z));
}
BDS_Edge(BDS_Point *A, BDS_Point *B)
......@@ -288,7 +292,6 @@ public:
}
};
class BDS_Face
{
public:
......@@ -298,15 +301,13 @@ public:
inline int numEdges () const { return e4 ? 4 : 3; }
inline void getNodes(BDS_Point *n[4]) const
{
if (!e4)
{
if (!e4){
n[0] = e1->commonvertex(e3);
n[1] = e1->commonvertex(e2);
n[2] = e2->commonvertex(e3);
n[3] = 0;
}
else
{
else{
n[0] = e1->commonvertex(e4);
n[1] = e1->commonvertex(e2);
n[2] = e2->commonvertex(e3);
......@@ -324,7 +325,6 @@ public:
}
};
class GeomLessThan
{
public:
......@@ -367,7 +367,6 @@ public:
}
};
class BDS_SwapEdgeTest
{
public:
......@@ -400,13 +399,11 @@ struct EdgeToRecover
GEdge *ge;
EdgeToRecover(int _p1, int _p2, GEdge *_ge) : ge(_ge)
{
if (_p1 < _p2 )
{
if(_p1 < _p2 ){
p1 = _p1;
p2 = _p2;
}
else
{
else{
p2 = _p1;
p1 = _p2;
}
......@@ -460,7 +457,8 @@ public:
void add_geom(int degree, int tag);
BDS_GeomEntity *get_geom(int p1, int p2);
// 2D operators
BDS_Edge *recover_edge(int p1, int p2, std::set<EdgeToRecover> *e2r=0, std::set<EdgeToRecover> *not_recovered = 0);
BDS_Edge *recover_edge(int p1, int p2, std::set<EdgeToRecover> *e2r=0,
std::set<EdgeToRecover> *not_recovered=0);
bool swap_edge(BDS_Edge*, const BDS_SwapEdgeTest &theTest);
bool collapse_edge_parametric(BDS_Edge*, BDS_Point*);
void snap_point(BDS_Point*, BDS_Mesh *geom = 0);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment