Commit d2f49ddb by Christophe Geuzaine

Merge branch 'master' of https://gitlab.onelab.info/gmsh/gmsh

parents 8cb932b8 190b4ff3
......@@ -80,14 +80,14 @@ void GFace::setMeshingAlgo(int algo)
CTX::instance()->mesh.algo2dPerFace[tag()] = algo;
}
void GFace::delFreeEdge(GEdge *e)
void GFace::delFreeEdge(GEdge *edge)
{
// delete the edge from the edge list and the orientation list
std::list<GEdge*>::iterator ite = l_edges.begin();
std::list<int>::iterator itd = l_dirs.begin();
std::vector<int>::iterator itd = l_dirs.begin();
while(ite != l_edges.end()){
if(e == *ite){
Msg::Debug("Erasing edge %d from edge list in face %d", e->tag(), tag());
if(edge == *ite){
Msg::Debug("Erasing edge %d from edge list in face %d", edge->tag(), tag());
l_edges.erase(ite);
if(itd != l_dirs.end()) l_dirs.erase(itd);
break;
......@@ -100,8 +100,8 @@ void GFace::delFreeEdge(GEdge *e)
for(std::list<GEdgeLoop>::iterator it = edgeLoops.begin();
it != edgeLoops.end(); it++){
for(GEdgeLoop::iter it2 = it->begin(); it2 != it->end(); it2++){
if(e == it2->ge){
Msg::Debug("Erasing edge %d from edge loop in face %d", e->tag(), tag());
if(edge == it2->ge){
Msg::Debug("Erasing edge %d from edge loop in face %d", edge->tag(), tag());
it->erase(it2);
break;
}
......@@ -119,9 +119,8 @@ int GFace::delEdge(GEdge* edge)
}
l_edges.erase(it);
std::list<int>::iterator itOri;
int posOri = 0;
int orientation = 0;
std::vector<int>::iterator itOri;
int posOri = 0, orientation = 0;
for(itOri = l_dirs.begin(); itOri != l_dirs.end(); ++itOri){
if(posOri == pos){
orientation = *itOri;
......@@ -418,12 +417,12 @@ void GFace::writeGEO(FILE *fp)
if(geomType() == DiscreteSurface) return;
std::list<GEdge*> edg = edges();
std::list<int> dir = orientations();
std::vector<int> const& dir = orientations();
if(edg.size() && dir.size() == edg.size()){
std::vector<int> num, ori;
for(std::list<GEdge*>::iterator it = edg.begin(); it != edg.end(); it++)
num.push_back((*it)->tag());
for(std::list<int>::iterator it = dir.begin(); it != dir.end(); it++)
for(std::vector<int>::const_iterator it = dir.begin(); it != dir.end(); it++)
ori.push_back((*it) > 0 ? 1 : -1);
fprintf(fp, "Line Loop(%d) = ", tag());
for(unsigned int i = 0; i < num.size(); i++){
......@@ -1530,8 +1529,11 @@ void GFace::replaceEdges(std::list<GEdge*> &new_edges)
{
std::list<GEdge*>::iterator it = l_edges.begin();
std::list<GEdge*>::iterator it2 = new_edges.begin();
std::list<int>::iterator it3 = l_dirs.begin();
std::list<int> newdirs;
std::vector<int>::iterator it3 = l_dirs.begin();
std::vector<int> newdirs;
newdirs.reserve(l_edges.size());
for ( ; it != l_edges.end(); ++it, ++it2, ++it3){
(*it)->delFace(this);
(*it2)->addFace(this);
......@@ -1746,9 +1748,9 @@ void GFace::setMeshMaster(GFace* master, const std::vector<double>& tfo)
inline double myAngle(const SVector3 &a, const SVector3 &b, const SVector3 &d)
{
double cosTheta = dot(a, b);
double sinTheta = dot(crossprod(a, b), d);
return atan2(sinTheta, cosTheta);
double const cosTheta = dot(a, b);
double const sinTheta = dot(crossprod(a, b), d);
return std::atan2(sinTheta, cosTheta);
}
struct myPlane {
......
......@@ -33,7 +33,7 @@ class GFace : public GEntity {
// edge loops might replace what follows (list of all the edges of
// the face + directions)
std::list<GEdge *> l_edges;
std::list<int> l_dirs;
std::vector<int> l_dirs;
GRegion *r1, *r2;
mean_plane meanPlane;
std::list<GEdge *> embedded_edges;
......@@ -94,20 +94,22 @@ class GFace : public GEntity {
void delFreeEdge(GEdge *e);
// edge orientations
virtual std::list<int> orientations() const { return l_dirs; }
virtual std::vector<int> const& orientations() const { return l_dirs; }
// edges that bound the face
int delEdge(GEdge* edge);
virtual std::list<GEdge*> edges() const { return l_edges; }
inline void set(const std::list<GEdge*> f) { l_edges = f; }
inline void setOrientations(const std::list<int> f) { l_dirs = f; }
void set(const std::list<GEdge*> f) { l_edges = f; }
void setOrientations(std::vector<int> f) { l_dirs = f; }
void setEdge(GEdge* f, int orientation)
{
l_edges.push_back(f);
l_dirs.push_back(orientation);
}
virtual std::list<int> edgeOrientations() const { return l_dirs; }
inline bool containsEdge (int iEdge) const
virtual std::vector<int> const& edgeOrientations() const { return l_dirs; }
bool containsEdge (int iEdge) const
{
for (std::list<GEdge*>::const_iterator it = l_edges.begin(); it !=l_edges.end(); ++it)
if ((*it)->tag() == iEdge) return true;
......
......@@ -561,8 +561,8 @@ bool GModel::getBoundaryTags(const std::vector<std::pair<int, int> > &inDimTags,
}
else{
std::list<GEdge*> edges(gf->edges());
std::list<int> orientations(gf->edgeOrientations());
std::list<int>::iterator ito = orientations.begin();
std::vector<int> orientations(gf->edgeOrientations());
std::vector<int>::iterator ito = orientations.begin();
for(std::list<GEdge*>::iterator it = edges.begin(); it != edges.end(); it++){
int t = (*it)->tag();
if(oriented && ito != orientations.end()){
......
......@@ -501,13 +501,14 @@ void writeMSHEntities(FILE *fp, GModel *gm) // also used in MSH2
}
for (GModel::fiter it = gm->firstFace(); it != gm->lastFace(); ++it) {
std::list<GEdge*> edges = (*it)->edges();
std::list<int> ori = (*it)->edgeOrientations();
std::vector<int> const& ori = (*it)->edgeOrientations();
fprintf(fp, "%d %d ", (*it)->tag(), (int)edges.size());
std::vector<int> tags, signs;
std::vector<int> tags;
for(std::list<GEdge*>::iterator ite = edges.begin(); ite != edges.end(); ite++)
tags.push_back((*ite)->tag());
for(std::list<int>::iterator ite = ori.begin(); ite != ori.end(); ite++)
signs.push_back(*ite);
std::vector<int> signs(ori.begin(), ori.end());
if(tags.size() == signs.size()){
for(unsigned int i = 0; i < tags.size(); i++)
tags[i] *= (signs[i] > 0 ? 1 : -1);
......
......@@ -1537,7 +1537,7 @@ static void writeMSH4Entities(GModel *const model, FILE *fp, bool partition,
for(GModel::fiter it = faces.begin(); it != faces.end(); ++it){
std::list<GEdge*> edges = (*it)->edges();
std::list<int> ori = (*it)->edgeOrientations();
std::vector<int> const& ori = (*it)->edgeOrientations();
unsigned long edgesSize = edges.size();
int entityTag = (*it)->tag();
fwrite(&entityTag, sizeof(int), 1, fp);
......@@ -1560,8 +1560,9 @@ static void writeMSH4Entities(GModel *const model, FILE *fp, bool partition,
std::vector<int> tags, signs;
for(std::list<GEdge*>::iterator ite = edges.begin(); ite != edges.end(); ite++)
tags.push_back((*ite)->tag());
for(std::list<int>::iterator ite = ori.begin(); ite != ori.end(); ite++)
signs.push_back(*ite);
signs.insert(signs.end(), ori.begin(), ori.end());
if(tags.size() == signs.size()){
for(unsigned int i = 0; i < tags.size(); i++)
tags[i] *= (signs[i] > 0 ? 1 : -1);
......@@ -1574,7 +1575,7 @@ static void writeMSH4Entities(GModel *const model, FILE *fp, bool partition,
for(GModel::riter it = regions.begin(); it != regions.end(); ++it){
std::vector<GFace*> faces = (*it)->faces();
std::list<int> ori = (*it)->faceOrientations();
std::list<int> const& ori = (*it)->faceOrientations();
unsigned long facesSize = faces.size();
int entityTag = (*it)->tag();
fwrite(&entityTag, sizeof(int), 1, fp);
......@@ -1597,7 +1598,7 @@ static void writeMSH4Entities(GModel *const model, FILE *fp, bool partition,
std::vector<int> tags, signs;
for(std::vector<GFace*>::iterator itf = faces.begin(); itf != faces.end(); itf++)
tags.push_back((*itf)->tag());
for(std::list<int>::iterator itf = ori.begin(); itf != ori.end(); itf++)
for(std::list<int>::const_iterator itf = ori.begin(); itf != ori.end(); itf++)
signs.push_back(*itf);
if(tags.size() == signs.size()){
for(unsigned int i = 0; i < tags.size(); i++)
......@@ -1707,7 +1708,7 @@ static void writeMSH4Entities(GModel *const model, FILE *fp, bool partition,
for(GModel::fiter it = faces.begin(); it != faces.end(); ++it){
std::list<GEdge*> edges = (*it)->edges();
std::list<int> ori = (*it)->edgeOrientations();
std::vector<int> const& ori = (*it)->edgeOrientations();
fprintf(fp, "%d ", (*it)->tag());
if(partition){
partitionFace *pf = static_cast<partitionFace*>(*it);
......@@ -1728,7 +1729,7 @@ static void writeMSH4Entities(GModel *const model, FILE *fp, bool partition,
std::vector<int> tags, signs;
for(std::list<GEdge*>::iterator ite = edges.begin(); ite != edges.end(); ite++)
tags.push_back((*ite)->tag());
for(std::list<int>::iterator ite = ori.begin(); ite != ori.end(); ite++)
for(std::vector<int>::const_iterator ite = ori.begin(); ite != ori.end(); ite++)
signs.push_back(*ite);
if(tags.size() == signs.size()){
for(unsigned int i = 0; i < tags.size(); i++)
......@@ -1759,11 +1760,12 @@ static void writeMSH4Entities(GModel *const model, FILE *fp, bool partition,
writeMSH4BoundingBox((*it)->bounds(), fp, scalingFactor, binary);
writeMSH4Physicals(fp, *it, binary);
fprintf(fp, "%lu ", faces.size());
std::vector<int> tags, signs;
std::vector<int> tags;
for(std::vector<GFace*>::iterator itf = faces.begin(); itf != faces.end(); itf++)
tags.push_back((*itf)->tag());
for(std::list<int>::iterator itf = ori.begin(); itf != ori.end(); itf++)
signs.push_back(*itf);
std::vector<int> signs(ori.begin(), ori.end());
if(tags.size() == signs.size()){
for(unsigned int i = 0; i < tags.size(); i++)
tags[i] *= (signs[i] > 0 ? 1 : -1);
......
......@@ -367,7 +367,7 @@ bool OCCFace::containsPoint(const SPoint3 &pt) const
double angle = 0.;
double v[3] = {pt.x(), pt.y(), pt.z()};
std::list<int>::const_iterator ito = l_dirs.begin();
std::vector<int>::const_iterator ito = l_dirs.begin();
for(std::list<GEdge*>::const_iterator it = l_edges.begin(); it != l_edges.end(); it++){
GEdge *c = *it;
int ori = 1;
......@@ -392,9 +392,7 @@ bool OCCFace::containsPoint(const SPoint3 &pt) const
}
}
// we're inside if angle equals 2 * pi
if(fabs(angle) > 2 * M_PI - 0.5 && fabs(angle) < 2 * M_PI + 0.5)
return true;
return false;
return std::abs(angle) > 2 * M_PI - 0.5 && std::abs(angle) < 2 * M_PI + 0.5;
}
else
Msg::Error("Not Done Yet ...");
......
......@@ -84,9 +84,9 @@ static void computeEdgeLoops(const GFace *gf, std::vector<MVertex*> &all_mvertic
std::vector<int> &indices)
{
std::list<GEdge*> edges = gf->edges();
std::list<int> ori = gf->orientations();
std::vector<int> ori = gf->orientations();
std::list<GEdge*>::iterator it = edges.begin();
std::list<int>::iterator ito = ori.begin();
std::vector<int>::iterator ito = ori.begin();
indices.push_back(0);
GVertex *start = ((*ito) == 1) ? (*it)->getBeginVertex() : (*it)->getEndVertex();
......
......@@ -2518,7 +2518,7 @@ int UnpartitionMesh(GModel *const model)
pface->quadrangles.clear();
pface->mesh_vertices.clear();
pface->set(std::list<GEdge*>());
pface->setOrientations(std::list<int>());
pface->setOrientations(std::vector<int>());
model->remove(pface);
delete pface;
......
......@@ -527,8 +527,8 @@ void voroMetal3D::correspondance(double e, double xMax, double yMax, double zMax
std::list<GVertex*> vertices;
std::list<GEdge*> edges1;
std::list<GEdge*> edges2;
std::list<int> orientations1;
std::list<int> orientations2;
std::vector<int> orientations1;
std::vector<int> orientations2;
std::map<GFace*,SPoint3> centers;
std::map<GFace*,bool> markings;
std::list<GVertex*>::iterator it2;
......@@ -538,8 +538,8 @@ void voroMetal3D::correspondance(double e, double xMax, double yMax, double zMax
std::map<GFace*,bool>::iterator it6;
std::list<GEdge*>::iterator it7;
std::list<GEdge*>::iterator it8;
std::list<int>::iterator it9;
std::list<int>::iterator it10;
std::vector<int>::iterator it9;
std::vector<int>::iterator it10;
std::list<GEdge*>::iterator mem;
faces.clear();
......
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