Commit c670a555 authored by Amaury Johnen's avatar Amaury Johnen

Merge branch 'master' into guiRotCenter

parents 019f7781 cec23971
Pipeline #2074 passed with stage
in 16 minutes 8 seconds
......@@ -1478,7 +1478,8 @@ int GModel::indexMeshVertices(bool all, int singlePartition, bool renumber)
// not to be saved (because we save a single partition and they are not used
// in that partition)
for(unsigned int i = 0; i < entities.size(); i++){
if(all || entities[i]->physicals.size()){
if(all || entities[i]->physicals.size() ||
(entities[i]->getParentEntity() && entities[i]->getParentEntity()->physicals.size())){
for(std::size_t j = 0; j < entities[i]->getNumMeshElements(); j++){
MElement *e = entities[i]->getMeshElement(j);
for(std::size_t k = 0; k < e->getNumVertices(); k++){
......
This diff is collapsed.
......@@ -49,7 +49,7 @@ class Vertex {
}
void norme()
{
double d = sqrt(Pos.X * Pos.X + Pos.Y * Pos.Y + Pos.Z * Pos.Z);
double const d = std::sqrt(Pos.X * Pos.X + Pos.Y * Pos.Y + Pos.Z * Pos.Z);
if(d == 0.0) return;
Pos.X /= d;
Pos.Y /= d;
......
......@@ -414,7 +414,7 @@ static Vertex InterpolateNurbs(Curve *Curve, double u, int derivee)
return p;
}
Vertex InterpolateCurve(Curve *c, double u, int derivee)
Vertex InterpolateCurve(Curve *c, double u, int const derivee)
{
if(c->Num < 0) {
Curve *C0 = FindCurve(-c->Num);
......@@ -539,11 +539,11 @@ Vertex InterpolateCurve(Curve *c, double u, int derivee)
theta = c->Circle.t1 - (c->Circle.t1 - c->Circle.t2) * u;
theta -= c->Circle.incl; // for ellipses
V.Pos.X =
c->Circle.f1 * cos(theta) * cos(c->Circle.incl) -
c->Circle.f2 * sin(theta) * sin(c->Circle.incl);
c->Circle.f1 * std::cos(theta) * std::cos(c->Circle.incl) -
c->Circle.f2 * std::sin(theta) * std::sin(c->Circle.incl);
V.Pos.Y =
c->Circle.f1 * cos(theta) * sin(c->Circle.incl) +
c->Circle.f2 * sin(theta) * cos(c->Circle.incl);
c->Circle.f1 * std::cos(theta) * std::sin(c->Circle.incl) +
c->Circle.f2 * std::sin(theta) * std::cos(c->Circle.incl);
V.Pos.Z = 0.0;
Projette(&V, c->Circle.invmat);
List_Read(c->Control_Points, 1, &v[0]);
......
This diff is collapsed.
......@@ -196,9 +196,11 @@ public:
bool operator()(const MVertex *v1, const MVertex *v2) const;
};
class MVertexLessThanNum {
public:
bool operator()(const MVertex *v1, const MVertex *v2) const;
struct MVertexLessThanNum {
bool operator()(const MVertex *v1, const MVertex *v2) const
{
return v1->getNum() < v2->getNum();
}
};
bool reparamMeshEdgeOnFace(MVertex *v1, MVertex *v2, GFace *gf, SPoint2 &param1,
......
......@@ -6,7 +6,7 @@
#ifndef _SPOINT3_H_
#define _SPOINT3_H_
#include <math.h>
#include <cmath>
// A point in 3-space
class SPoint3 {
protected:
......@@ -104,7 +104,7 @@ inline double SPoint3::operator[](int i) const
inline double SPoint3::distance(const SPoint3 &p)const
{
double x = P[0] - p.P[0], y = P[1] - p.P[1], z = P[2] - p.P[2];
return sqrt(x * x + y * y + z * z);
return std::sqrt(x * x + y * y + z * z);
}
#endif
......@@ -10,7 +10,6 @@
#include <string>
#include <stdio.h>
#include "GmshMessage.h"
#include <iostream>
// concrete class for vector of size 3
class SVector3 {
......@@ -26,11 +25,11 @@ class SVector3 {
SVector3(double v) : P(v, v, v) {}
SVector3(const double *array) : P(array) {}
SVector3(const SVector3& v) : P(v.P) {}
inline double x(void) const { return P.x(); }
inline double y(void) const { return P.y(); }
inline double z(void) const { return P.z(); }
inline double norm() const { return sqrt(P[0] * P[0] + P[1] * P[1] + P[2] * P[2]); }
inline double normSq() const{ return (P[0] * P[0] + P[1] * P[1] + P[2] * P[2]); }
double x(void) const { return P.x(); }
double y(void) const { return P.y(); }
double z(void) const { return P.z(); }
double norm() const { return std::sqrt(this->normSq()); }
double normSq() const{ return P[0] * P[0] + P[1] * P[1] + P[2] * P[2]; }
// Beware that " w = v.normalize() " produces the vector
// w = (v.norm(), v.norm(), v.norm()), which is NOT a unit vector!
// Use " w = v.unit() " to affect to "w" the unit vector parallel to "v".
......
This diff is collapsed.
......@@ -18,86 +18,80 @@ class GVertex;
class MVertex;
class edge_angle {
public :
public:
MVertex *v1, *v2;
double angle;
edge_angle(MVertex *_v1, MVertex *_v2, MElement *t1, MElement *t2);
bool operator < (const edge_angle &other) const
{
return other.angle < angle;
}
bool operator<(const edge_angle &other) const { return other.angle < angle; }
};
typedef std::map<MVertex*, std::vector<MElement*>, MVertexLessThanNum > v2t_cont;
typedef std::map<MEdge, std::pair<MElement*, MElement*>, Less_Edge> e2t_cont;
template <class T> void buildVertexToElement(std::vector<T*> &eles, v2t_cont &adj){
for(unsigned int i = 0; i < eles.size(); i++){
T *t = eles[i];
for(std::size_t j = 0; j < t->getNumVertices(); j++){
MVertex *v = t->getVertex(j);
v2t_cont :: iterator it = adj.find(v);
if(it == adj.end()){
std::vector<MElement*> one;
one.push_back(t);
adj[v] = one;
}
else{
it->second.push_back(t);
}
typedef std::map<MVertex *, std::vector<MElement *>, MVertexLessThanNum>
v2t_cont;
typedef std::map<MEdge, std::pair<MElement *, MElement *>, Less_Edge> e2t_cont;
template <class T>
void buildVertexToElement(std::vector<T *> const &elements, v2t_cont &adj)
{
for(std::size_t i = 0, elements_size = elements.size(); i < elements_size;
i++) {
T *const t = elements[i];
for(std::size_t j = 0, vertices_size = t->getNumVertices();
j < vertices_size; j++) {
adj[t->getVertex(j)].push_back(t);
}
}
}
template <class T> void buildEdgeToElement(std::vector<T*> &eles, e2t_cont &adj);
template <class T>
void buildEdgeToElement(std::vector<T *> &eles, e2t_cont &adj);
void buildVertexToTriangle(std::vector<MTriangle*> &, v2t_cont &adj);
void buildEdgeToTriangle(std::vector<MTriangle*> &, e2t_cont &adj);
void buildVertexToTriangle(std::vector<MTriangle *> &, v2t_cont &adj);
void buildEdgeToTriangle(std::vector<MTriangle *> &, e2t_cont &adj);
void buildListOfEdgeAngle(e2t_cont adj, std::vector<edge_angle> &edges_detected,
std::vector<edge_angle> &edges_lonly);
void buildEdgeToElements(std::vector<MElement*> &tris, e2t_cont &adj);
void buildEdgeToElements(std::vector<MElement *> &tris, e2t_cont &adj);
void laplaceSmoothing(GFace *gf, int niter=1, bool infinity_norm = false);
void laplaceSmoothing(GFace *gf, int niter = 1, bool infinity_norm = false);
void _relocateVertex(GFace *gf, MVertex *ver,
const std::vector<MElement*> &lt);
const std::vector<MElement *> &lt);
enum swapCriterion {SWCR_DEL, SWCR_QUAL, SWCR_SPH};
enum splitCriterion {SPCR_CLOSE, SPCR_QUAL, SPCR_ALLWAYS};
enum swapCriterion { SWCR_DEL, SWCR_QUAL, SWCR_SPH };
enum splitCriterion { SPCR_CLOSE, SPCR_QUAL, SPCR_ALLWAYS };
int edgeSwapPass(GFace *gf,
std::set<MTri3*, compareTri3Ptr> &allTris,
int edgeSwapPass(GFace *gf, std::set<MTri3 *, compareTri3Ptr> &allTris,
const swapCriterion &cr, bidimMeshData &DATA);
void removeThreeTrianglesNodes(GFace *gf);
void buildMeshGenerationDataStructures(GFace *gf,
std::set<MTri3*, compareTri3Ptr> &AllTris,
bidimMeshData & data);
void transferDataStructure(GFace *gf, std::set<MTri3*, compareTri3Ptr> &AllTris,bidimMeshData &DATA);
void computeEquivalences(GFace *gf,bidimMeshData &DATA);
void recombineIntoQuads(GFace *gf,
bool topologicalOpti = true,
bool nodeRepositioning = true,
double minqual = 0.1,
bool verbose = true);
//used for meshGFaceRecombine development
void buildMeshGenerationDataStructures(
GFace *gf, std::set<MTri3 *, compareTri3Ptr> &AllTris, bidimMeshData &data);
void transferDataStructure(GFace *gf,
std::set<MTri3 *, compareTri3Ptr> &AllTris,
bidimMeshData &DATA);
void computeEquivalences(GFace *gf, bidimMeshData &DATA);
void recombineIntoQuads(GFace *gf, bool topologicalOpti = true,
bool nodeRepositioning = true, double minqual = 0.1,
bool verbose = true);
// used for meshGFaceRecombine development
void quadsToTriangles(GFace *gf, double minqual);
void splitElementsInBoundaryLayerIfNeeded(GFace *gf);
struct swapquad{
struct swapquad {
int v[4];
bool operator < (const swapquad &o) const
bool operator<(const swapquad &o) const
{
if (v[0] < o.v[0]) return true;
if (v[0] > o.v[0]) return false;
if (v[1] < o.v[1]) return true;
if (v[1] > o.v[1]) return false;
if (v[2] < o.v[2]) return true;
if (v[2] > o.v[2]) return false;
if (v[3] < o.v[3]) return true;
if(v[0] < o.v[0]) return true;
if(v[0] > o.v[0]) return false;
if(v[1] < o.v[1]) return true;
if(v[1] > o.v[1]) return false;
if(v[2] < o.v[2]) return true;
if(v[2] > o.v[2]) return false;
if(v[3] < o.v[3]) return true;
return false;
}
swapquad(MVertex *v1, MVertex *v2, MVertex *v3, MVertex *v4)
{
v[0] = v1->getNum();
......@@ -106,7 +100,8 @@ struct swapquad{
v[3] = v4->getNum();
std::sort(v, v + 4);
}
swapquad(int v1, int v2, int v3, int v4)
swapquad(int const v1, int const v2, int const v3, int const v4)
{
v[0] = v1;
v[1] = v2;
......@@ -116,44 +111,52 @@ struct swapquad{
}
};
struct RecombineTriangle
{
struct RecombineTriangle {
MElement *t1, *t2;
double angle;
double quality;
MVertex *n1, *n2, *n3, *n4;
RecombineTriangle(const MEdge &me, MElement *_t1, MElement *_t2)
: t1(_t1), t2(_t2)
: t1(_t1)
, t2(_t2)
{
n1 = me.getVertex(0);
n2 = me.getVertex(1);
n3 = 0;
n4 = 0;
if(t1->getVertex(0) != n1 && t1->getVertex(0) != n2) n3 = t1->getVertex(0);
else if(t1->getVertex(1) != n1 && t1->getVertex(1) != n2) n3 = t1->getVertex(1);
else if(t1->getVertex(2) != n1 && t1->getVertex(2) != n2) n3 = t1->getVertex(2);
if(t2->getVertex(0) != n1 && t2->getVertex(0) != n2) n4 = t2->getVertex(0);
else if(t2->getVertex(1) != n1 && t2->getVertex(1) != n2) n4 = t2->getVertex(1);
else if(t2->getVertex(2) != n1 && t2->getVertex(2) != n2) n4 = t2->getVertex(2);
MQuadrangle q (n1,n3,n2,n4);
if(t1->getVertex(0) != n1 && t1->getVertex(0) != n2)
n3 = t1->getVertex(0);
else if(t1->getVertex(1) != n1 && t1->getVertex(1) != n2)
n3 = t1->getVertex(1);
else if(t1->getVertex(2) != n1 && t1->getVertex(2) != n2)
n3 = t1->getVertex(2);
if(t2->getVertex(0) != n1 && t2->getVertex(0) != n2)
n4 = t2->getVertex(0);
else if(t2->getVertex(1) != n1 && t2->getVertex(1) != n2)
n4 = t2->getVertex(1);
else if(t2->getVertex(2) != n1 && t2->getVertex(2) != n2)
n4 = t2->getVertex(2);
MQuadrangle q(n1, n3, n2, n4);
angle = q.etaShapeMeasure();
double a1 = 180 * angle3Vertices(n1, n4, n2) / M_PI;
double a2 = 180 * angle3Vertices(n4, n2, n3) / M_PI;
double a3 = 180 * angle3Vertices(n2, n3, n1) / M_PI;
double a4 = 180 * angle3Vertices(n3, n1, n4) / M_PI;
quality = fabs(90. - a1);
quality = std::max(fabs(90. - a2),quality);
quality = std::max(fabs(90. - a3),quality);
quality = std::max(fabs(90. - a4),quality);
double const a1 = 180 * angle3Vertices(n1, n4, n2) / M_PI;
double const a2 = 180 * angle3Vertices(n4, n2, n3) / M_PI;
double const a3 = 180 * angle3Vertices(n2, n3, n1) / M_PI;
double const a4 = 180 * angle3Vertices(n3, n1, n4) / M_PI;
quality = std::abs(90. - a1);
quality = std::max(std::abs(90. - a2), quality);
quality = std::max(std::abs(90. - a3), quality);
quality = std::max(std::abs(90. - a4), quality);
}
bool operator < (const RecombineTriangle &other) const
bool operator<(const RecombineTriangle &other) const
{
return quality < other.quality;
}
};
#endif
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment