From 7fca694b7eba76daf1e2708601b23d04d3b6d63b Mon Sep 17 00:00:00 2001 From: Emilie Marchandise <emilie.marchandise@uclouvain.be> Date: Wed, 21 Mar 2012 10:39:47 +0000 Subject: [PATCH] fixed bug in add planar face --- Geo/GFace.cpp | 1 - Geo/GFaceCompound.cpp | 53 ++++++++++++++++++++++--------------------- Geo/GModelFactory.cpp | 13 ++++++----- 3 files changed, 34 insertions(+), 33 deletions(-) diff --git a/Geo/GFace.cpp b/Geo/GFace.cpp index ec3482601b..d7fc8dd414 100644 --- a/Geo/GFace.cpp +++ b/Geo/GFace.cpp @@ -51,7 +51,6 @@ GFace::GFace(GModel *model, int tag) GFace::~GFace() { std::list<GEdge*>::iterator it = l_edges.begin(); - while (it != l_edges.end()){ (*it)->delFace(this); ++it; diff --git a/Geo/GFaceCompound.cpp b/Geo/GFaceCompound.cpp index 201134c404..ec56ef6b80 100644 --- a/Geo/GFaceCompound.cpp +++ b/Geo/GFaceCompound.cpp @@ -476,33 +476,34 @@ void GFaceCompound::orientFillTris(std::list<MTriangle*> loopfillTris) const{ it != loopfillTris.end(); it++ ) (*it)->revert(); } - + fillTris.insert(fillTris.begin(),loopfillTris.begin(),loopfillTris.end()); } void GFaceCompound::printFillTris() const{ - if(CTX::instance()->mesh.saveAll){ - if (fillTris.size() > 0){ - char name[256]; - std::list<GFace*>::const_iterator itf = _compound.begin(); - sprintf(name, "fillTris-%d.pos", tag()); - FILE * ftri = fopen(name,"w"); - fprintf(ftri,"View \"\"{\n"); - for (std::list<MTriangle*>::iterator it2 = fillTris.begin(); - it2 !=fillTris.end(); it2++ ){ - MTriangle *t = (*it2); - fprintf(ftri,"ST(%g,%g,%g,%g,%g,%g,%g,%g,%g){%g,%g,%g};\n", - t->getVertex(0)->x(), t->getVertex(0)->y(), t->getVertex(0)->z(), - t->getVertex(1)->x(), t->getVertex(1)->y(), t->getVertex(1)->z(), - t->getVertex(2)->x(), t->getVertex(2)->y(), t->getVertex(2)->z(), - 1., 1., 1.); - } - fprintf(ftri,"};\n"); - fclose(ftri); - } + if(!CTX::instance()->mesh.saveAll) return; + + if (fillTris.size() > 0){ + char name[256]; + std::list<GFace*>::const_iterator itf = _compound.begin(); + sprintf(name, "fillTris-%d.pos", tag()); + FILE * ftri = fopen(name,"w"); + fprintf(ftri,"View \"\"{\n"); + for (std::list<MTriangle*>::iterator it2 = fillTris.begin(); + it2 !=fillTris.end(); it2++ ){ + MTriangle *t = (*it2); + fprintf(ftri,"ST(%g,%g,%g,%g,%g,%g,%g,%g,%g){%g,%g,%g};\n", + t->getVertex(0)->x(), t->getVertex(0)->y(), t->getVertex(0)->z(), + t->getVertex(1)->x(), t->getVertex(1)->y(), t->getVertex(1)->z(), + t->getVertex(2)->x(), t->getVertex(2)->y(), t->getVertex(2)->z(), + 1., 1., 1.); + } + fprintf(ftri,"};\n"); + fclose(ftri); } + } void GFaceCompound::fillNeumannBCS_Plane() const @@ -525,8 +526,11 @@ void GFaceCompound::fillNeumannBCS_Plane() const if (loop != _U0 ){ std::vector<std::vector<GEdge *> > myEdgeLoops; std::vector<GEdge*> myEdges; - for (std::list<GEdge*>::iterator itl = loop.begin(); itl != loop.end(); itl++) + myEdgeLoops.clear(); + myEdges.clear(); + for (std::list<GEdge*>::iterator itl = loop.begin(); itl != loop.end(); itl++){ myEdges.push_back(*itl); + } myEdgeLoops.push_back(myEdges); GFace *newFace = GModel::current()->addPlanarFace(myEdgeLoops); fillFaces.push_back(newFace); @@ -541,9 +545,8 @@ void GFaceCompound::fillNeumannBCS_Plane() const fillNodes.insert(newFace->triangles[i]->getVertex(1)); fillNodes.insert(newFace->triangles[i]->getVertex(2)); } - //mod->remove(newFace); + orientFillTris(loopfillTris); } - orientFillTris(loopfillTris); } printFillTris(); @@ -984,7 +987,7 @@ bool GFaceCompound::parametrize() const parametrize_conformal(0, NULL, NULL); } printStuff(55); - oriented = checkOrientation(0); + oriented = false; //checkOrientation(0); printStuff(66); if (!oriented) oriented = checkOrientation(0, true); printStuff(77); @@ -1250,8 +1253,6 @@ GFaceCompound::GFaceCompound(GModel *m, int tag, std::list<GFace*> &compound, _type = FE; } - - nbSplit = 0; fillTris.clear(); } diff --git a/Geo/GModelFactory.cpp b/Geo/GModelFactory.cpp index d173108491..1781c10bb3 100644 --- a/Geo/GModelFactory.cpp +++ b/Geo/GModelFactory.cpp @@ -122,15 +122,16 @@ GFace *GeoFactory::addPlanarFace(GModel *gm, std::vector< std::vector<GEdge *> > List_Add(temp, &numEdge); } - int num = gm->getMaxElementaryNumber(2) + 1+i; - while (FindSurfaceLoop(num)){ - num++; - if (!FindSurfaceLoop(num)) break; + int numl = gm->getMaxElementaryNumber(1) + i; + while (FindEdgeLoop(numl)){ + numl++; + if (!FindEdgeLoop(numl)) break; } - sortEdgesInLoop(num, temp); - EdgeLoop *l = Create_EdgeLoop(num, temp); + sortEdgesInLoop(numl, temp); + EdgeLoop *l = Create_EdgeLoop(numl, temp); vecLoops.push_back(l); Tree_Add(gm->getGEOInternals()->EdgeLoops, &l); + l->Num = numl; List_Delete(temp); } -- GitLab