From ee262f99d91447c4bf711486a1f4ad3eee6f72a3 Mon Sep 17 00:00:00 2001 From: Christophe Geuzaine <cgeuzaine@ulg.ac.be> Date: Fri, 15 Oct 2010 11:27:56 +0000 Subject: [PATCH] fix compile --- Geo/GModelFactory.h | 172 ++++++++++++++++++++++--------------- Geo/GRegion.cpp | 2 +- Mesh/meshGFaceOptimize.cpp | 71 ++++++++------- 3 files changed, 142 insertions(+), 103 deletions(-) diff --git a/Geo/GModelFactory.h b/Geo/GModelFactory.h index f080f01a98..f79a680f59 100644 --- a/Geo/GModelFactory.h +++ b/Geo/GModelFactory.h @@ -8,6 +8,7 @@ #include <vector> #include "GmshConfig.h" +#include "GmshMessage.h" class GEntity; class GVertex; @@ -26,116 +27,149 @@ class GModelFactory { // brep primitives enum arcCreationMethod {THREE_POINTS=1, CENTER_START_END=2}; enum splineType {BEZIER=1, BSPLINE=2}; - // vertex primitive virtual GVertex *addVertex(GModel *gm, double x, double y, double z, double lc) = 0; - // edge primitives virtual GEdge *addLine(GModel *, GVertex *v1, GVertex *v2) = 0; + virtual GFace *addPlanarFace(GModel *gm, std::vector<std::vector<GEdge *> > edges) = 0; + virtual GRegion*addVolume(GModel *gm, std::vector<std::vector<GFace *> > faces) = 0; virtual GEdge *addCircleArc(GModel *gm, const arcCreationMethod &method, GVertex *start, GVertex *end, - const SPoint3 &aPoint) = 0; + const SPoint3 &aPoint) + { + Msg::Error("addCircleArc not implemented yet"); + return 0; + } virtual GEdge *addSpline(GModel *gm,const splineType &type, GVertex *start, GVertex *end, - std::vector<std::vector<double> > controlPoints) = 0; + std::vector<std::vector<double> > controlPoints) + { + Msg::Error("addSpline not implemented yet"); + return 0; + } virtual GEdge *addNURBS(GModel *gm, GVertex *start, GVertex *end, std::vector<std::vector<double> > controlPoints, std::vector<double> knots, std::vector<double> weights, - std::vector<int> multiplicity) = 0; - // faces primitives - // this one tries to build a model face with one single list - // of faces. If boundaries are co-planar, then it's a plane, - // otherwise, we tru ruled, sweep or other kind of surfaces + std::vector<int> multiplicity) + { + Msg::Error("addNURBS not implemented yet"); + return 0; + } + // this one tries to build a model face with one single list of + // faces. If boundaries are co-planar, then it's a plane, otherwise, + // we tru ruled, sweep or other kind of surfaces virtual std::vector<GFace *> addRuledFaces(GModel *gm, - std::vector<std::vector<GEdge *> > edges) = 0; + std::vector<std::vector<GEdge *> > edges) + { + Msg::Error("addRuledFaces not implemented yet"); + return std::vector<GFace*>(); + } virtual GFace *addFace(GModel *gm, std::vector<GEdge *> edges, - std::vector< std::vector<double > > points) = 0; - virtual GFace *addPlanarFace(GModel *gm, std::vector<std::vector<GEdge *> > edges) = 0; + std::vector< std::vector<double > > points) + { + Msg::Error("addFace not implemented yet"); + return 0; + } + // sweep stuff virtual GEntity *revolve(GModel *gm, GEntity*, std::vector<double> p1, - std::vector<double> p2, double angle) = 0; + std::vector<double> p2, double angle) + { + Msg::Error("revolve not implemented yet"); + return 0; + } virtual GEntity *extrude(GModel *gm, GEntity*, std::vector<double> p1, - std::vector<double> p2) = 0; - virtual GEntity *addPipe(GModel *gm, GEntity *base, std::vector<GEdge *> wire) = 0; + std::vector<double> p2) + { + Msg::Error("extrude not implemented yet"); + return 0; + } + virtual GEntity *addPipe(GModel *gm, GEntity *base, std::vector<GEdge *> wire) + { + Msg::Error("addPipe not implemented yet"); + return 0; + } // solid primitives virtual GEntity *addSphere(GModel *gm, double cx, double cy, double cz, - double radius) = 0; + double radius) + { + Msg::Error("addSphere not implemented yet"); + return 0; + } virtual GEntity *addCylinder(GModel *gm, std::vector<double> p1, - std::vector<double> p2, double radius) = 0; + std::vector<double> p2, double radius) + { + Msg::Error("addCylinder not implemented yet"); + return 0; + } virtual GEntity *addTorus(GModel *gm, std::vector<double> p1, std::vector<double> p2, double radius1, - double radius2) = 0; + double radius2) + { + Msg::Error("addTorus not implemented yet"); + return 0; + } virtual GEntity *addBlock(GModel *gm, std::vector<double> p1, - std::vector<double> p2) = 0; + std::vector<double> p2) + { + Msg::Error("addBlock not implemented yet"); + return 0; + } virtual GEntity *addCone(GModel *gm, std::vector<double> p1, std::vector<double> p2, double radius1, - double radius2) = 0; + double radius2) + { + Msg::Error("addCone not implemented yet"); + return 0; + } // here, we should give a list of GEdges. Yet, I still can't figure out how // to get those automatically ... wait and see - virtual void fillet(GModel *gm, std::vector<int> edges, double radius) = 0; + virtual void fillet(GModel *gm, std::vector<int> edges, double radius) + { + Msg::Error("fillet not implemented yet"); + } // rigid body motions - virtual void translate(GModel *gm, std::vector<double> dx, int addToTheModel) = 0; + virtual void translate(GModel *gm, std::vector<double> dx, int addToTheModel) + { + Msg::Error("translate not implemented yet"); + } virtual void rotate(GModel *gm, std::vector<double> p1,std::vector<double> p2, - double angle, int addToTheModel) = 0; + double angle, int addToTheModel) + { + Msg::Error("rotate not implemented yet"); + } // boolean operators acting on 2 GModels - virtual GModel *computeBooleanUnion(GModel *obj, GModel*tool, int createNewModel) = 0; + virtual GModel *computeBooleanUnion(GModel *obj, GModel*tool, int createNewModel) + { + Msg::Error("computeBooleanUnion not implemented yet"); + return 0; + } virtual GModel *computeBooleanIntersection(GModel *obj, GModel*tool, - int createNewModel) = 0; + int createNewModel) + { + Msg::Error("computeBooleanIntersection not implemented yet"); + return 0; + } virtual GModel *computeBooleanDifference(GModel *obj, GModel*tool, - int createNewModel) = 0; - virtual GRegion* addVolume (GModel *gm, std::vector<std::vector<GFace *> > faces) = 0; + int createNewModel) + { + Msg::Error("computeBooleanDifference not implemented yet"); + return 0; + } }; class GeoFactory : public GModelFactory { public: GeoFactory(){} GVertex *addVertex(GModel *gm,double x, double y, double z, double lc); - virtual GEdge *addLine(GModel *gm,GVertex *v1, GVertex *v2); + GEdge *addLine(GModel *gm,GVertex *v1, GVertex *v2); GFace *addPlanarFace(GModel *gm, std::vector<std::vector<GEdge *> > edges); - GRegion* addVolume (GModel *gm, std::vector<std::vector<GFace *> > faces); - - //not implemented yet - GEdge *addCircleArc(GModel *gm,const arcCreationMethod &method, - GVertex *start, GVertex *end, - const SPoint3 &aPoint){}; - GEdge *addSpline(GModel *gm,const splineType &type, - GVertex *start, GVertex *end, - std::vector<std::vector<double> > controlPoints){}; - GEdge *addNURBS(GModel *gm, - GVertex *start, GVertex *end, - std::vector<std::vector<double> > controlPoints, - std::vector<double> knots, - std::vector<double> weights, - std::vector<int> multiplicity){}; - GEntity *revolve(GModel *gm, GEntity*,std::vector<double> p1, - std::vector<double> p2, double angle){}; - GEntity *extrude(GModel *gm, GEntity*,std::vector<double> p1, - std::vector<double> p2){}; - GEntity *addPipe(GModel *gm, GEntity *base, std::vector<GEdge *> wire){}; - GEntity *addSphere(GModel *gm,double cx, double cy, double cz, double radius){}; - GEntity *addCylinder(GModel *gm,std::vector<double> p1, std::vector<double> p2, - double radius){}; - std::vector<GFace *> addRuledFaces(GModel *gm, std::vector<std::vector<GEdge *> > edges){}; - GFace *addFace(GModel *gm, std::vector<GEdge *> edges, - std::vector< std::vector<double > > points){}; - GEntity *addTorus(GModel *gm,std::vector<double> p1, std::vector<double> p2, - double radius1, double radius2){}; - GEntity *addBlock(GModel *gm,std::vector<double> p1, std::vector<double> p2){}; - GEntity *addCone(GModel *gm,std::vector<double> p1, std::vector<double> p2, - double radius1, double radius2){}; - void translate(GModel *gm, std::vector<double> dx, int addToTheModel){}; - void rotate(GModel *gm, std::vector<double> p1,std::vector<double> p2, - double angle, int addToTheModel){}; - GModel *computeBooleanUnion(GModel *obj, GModel *tool, int createNewModel){}; - GModel *computeBooleanIntersection(GModel *obj, GModel *tool, int createNewModel){}; - GModel *computeBooleanDifference(GModel *obj, GModel *tool, int createNewModel){}; - void fillet(GModel *gm, std::vector<int> edges, double radius){}; - + GRegion *addVolume(GModel *gm, std::vector<std::vector<GFace *> > faces); }; @@ -170,8 +204,9 @@ class OCCFactory : public GModelFactory { GFace *addFace(GModel *gm, std::vector<GEdge *> edges, std::vector< std::vector<double > > points); GFace *addPlanarFace(GModel *gm, std::vector<std::vector<GEdge *> > edges); + GRegion *addVolume(GModel *gm, std::vector<std::vector<GFace *> > faces); GEntity *addTorus(GModel *gm,std::vector<double> p1, std::vector<double> p2, - double radius1, double radius2); + double radius1, double radius2); GEntity *addBlock(GModel *gm,std::vector<double> p1, std::vector<double> p2); GEntity *addCone(GModel *gm,std::vector<double> p1, std::vector<double> p2, double radius1, double radius2); @@ -182,7 +217,6 @@ class OCCFactory : public GModelFactory { GModel *computeBooleanIntersection(GModel *obj, GModel *tool, int createNewModel); GModel *computeBooleanDifference(GModel *obj, GModel *tool, int createNewModel); void fillet(GModel *gm, std::vector<int> edges, double radius); - GRegion* addVolume (GModel *gm, std::vector<std::vector<GFace *> > faces); }; #endif diff --git a/Geo/GRegion.cpp b/Geo/GRegion.cpp index bbf51bd3c9..b9dcc9f497 100644 --- a/Geo/GRegion.cpp +++ b/Geo/GRegion.cpp @@ -310,7 +310,7 @@ double GRegion::computeSolidProperties (std::vector<double> cg, double surface = 0; cg[0] = cg[1] = cg[2] = 0.0; for ( ; it != l_faces.end(); ++it,++itdir){ - printf("face %d dir %d %d elements\n",(*it)->tag(),*itdir,(*it)->triangles.size()); + printf("face %d dir %d %d elements\n",(*it)->tag(),*itdir,(int)(*it)->triangles.size()); for (int i=0;i<(*it)->triangles.size();++i){ MTriangle *e = (*it)->triangles[i]; // MElement *e = (*it)->getMeshElement(i); diff --git a/Mesh/meshGFaceOptimize.cpp b/Mesh/meshGFaceOptimize.cpp index da9373666e..828e5c4dcb 100644 --- a/Mesh/meshGFaceOptimize.cpp +++ b/Mesh/meshGFaceOptimize.cpp @@ -308,34 +308,32 @@ double surfaceTriangleUV(MVertex *v1, MVertex *v2, MVertex *v3, int _removeFourTrianglesNodes(GFace *gf,bool replace_by_quads) { - v2t_cont adj; buildVertexToElement(gf->triangles,adj); v2t_cont :: iterator it = adj.begin(); int n=0; std::set<MElement*> touched; while (it != adj.end()) { - bool skip=false; - double surfaceRef=0; - if(it->second.size()==4) { + bool skip = false; + double surfaceRef = 0; + if(it->second.size() == 4) { const std::vector<MElement*> < = it->second; MVertex* edges[4][2]; - for(int i=0;i<4;i++) { + for(int i = 0; i < 4; i++) { if(touched.find(lt[i])!=touched.end() || lt[i]->getNumVertices()!=3){ skip=true; break; } int j; - - surfaceRef+=surfaceFaceUV(lt[i],gf); - for(j=0;j<3;j++) { - if(lt[i]->getVertex(j)==it->first) { + surfaceRef += surfaceFaceUV(lt[i], gf); + for(j = 0; j < 3; j++) { + if(lt[i]->getVertex(j) == it->first) { edges[i][0] = lt[i]->getVertex((j+1)%3); edges[i][1] = lt[i]->getVertex((j+2)%3); break; } } - if(j==3) + if(j == 3) throw; } if(skip){ @@ -343,9 +341,9 @@ int _removeFourTrianglesNodes(GFace *gf,bool replace_by_quads) continue; } - for(int i=1;i<3;i++) { - for(int j=i+1;j<4;j++) { - if(edges[j][0]==edges[i-1][1]){ + for(int i = 1; i < 3; i++) { + for(int j = i + 1; j < 4; j++) { + if(edges[j][0] == edges[i-1][1]){ MVertex *buf[2]={edges[i][0],edges[i][1]}; edges[i][0]=edges[j][0]; edges[i][1]=edges[j][1]; @@ -355,30 +353,37 @@ int _removeFourTrianglesNodes(GFace *gf,bool replace_by_quads) } } } - if(edges[0][1]==edges[1][0] && edges[1][1]==edges[2][0] && edges[2][1] == edges[3][0] && edges[3][1]==edges[0][0]) { + if(edges[0][1] == edges[1][0] && edges[1][1] == edges[2][0] && + edges[2][1] == edges[3][0] && edges[3][1] == edges[0][0]) { if(replace_by_quads){ - gf->quadrangles.push_back(new MQuadrangle(edges[0][0],edges[1][0],edges[2][0],edges[3][0])); - }else{ + gf->quadrangles.push_back(new MQuadrangle(edges[0][0], edges[1][0], + edges[2][0], edges[3][0])); + } + else{ MTriangle *newt[4]; double surf[4],qual[4]; for(int i=0;i<4;i++){ newt[i] = new MTriangle(edges[i][0],edges[(i+1)%4][0],edges[(i+2)%4][0]); - surf[i]=surfaceFaceUV(newt[i],gf); - qual[i]=qmTriangle(newt[i],QMTRI_RHO); + surf[i] = surfaceFaceUV(newt[i],gf); + qual[i] = qmTriangle(newt[i],QMTRI_RHO); } - double q02=(fabs((surf[0]+surf[2]-surfaceRef)/surfaceRef)<1e-8) ? std::min(qual[0],qual[2]) : -1; - double q13=(fabs((surf[1]+surf[3]-surfaceRef)/surfaceRef)<1e-8) ? std::min(qual[1],qual[3]) : -1; + double q02=(fabs((surf[0]+surf[2]-surfaceRef)/surfaceRef)<1e-8) ? + std::min(qual[0],qual[2]) : -1; + double q13=(fabs((surf[1]+surf[3]-surfaceRef)/surfaceRef)<1e-8) ? + std::min(qual[1],qual[3]) : -1; if(q02>q13 && q02 >0) { delete newt[1]; delete newt[3]; gf->triangles.push_back(newt[0]); gf->triangles.push_back(newt[2]); - } else if (q13 >0) { + } + else if (q13 >0) { delete newt[0]; delete newt[2]; gf->triangles.push_back(newt[1]); gf->triangles.push_back(newt[3]); - } else { + } + else { it++; continue; } @@ -531,7 +536,7 @@ static bool _isItAGoodIdeaToCollapseThatVertex (GFace *gf, // v->setParameter(0,p.x()); // v->setParameter(1,p.y()); - for (int j=0;j<e1.size();++j){ + for (unsigned int j=0;j<e1.size();++j){ surface_old += surfaceFaceUV(e1[j],gf); // worst_quality_old = std::min(worst_quality_old,e1[j]-> etaShapeMeasure()); for (int k=0;k<e1[j]->getNumVertices();k++){ @@ -546,7 +551,7 @@ static bool _isItAGoodIdeaToCollapseThatVertex (GFace *gf, } } - for (int j=0;j<e2.size();++j){ + for (unsigned int j=0;j<e2.size();++j){ surface_old += surfaceFaceUV(e2[j],gf); // worst_quality_old = std::min(worst_quality_old,e2[j]-> etaShapeMeasure()); for (int k=0;k<e2[j]->getNumVertices();k++){ @@ -583,13 +588,13 @@ static bool _isItAGoodIdeaToMoveThatVertex (GFace *gf, double surface_old = 0; double surface_new = 0; - for (int j=0;j<e1.size();++j) + for (unsigned int j=0;j<e1.size();++j) surface_old += surfaceFaceUV(e1[j],gf); v1->setParameter(0,after.x()); v1->setParameter(1,after.y()); - for (int j=0;j<e1.size();++j) + for (unsigned int j=0;j<e1.size();++j) surface_new += surfaceFaceUV(e1[j],gf); v1->setParameter(0,before.x()); @@ -648,7 +653,7 @@ static int _quadWithOneVertexOnBoundary (GFace *gf, */ // if (line.size() == 2)printf("caca\n"); // else printf("hohcozbucof\n"); - for (int j=0;j<e2.size();++j){ + for (unsigned int j=0;j<e2.size();++j){ for (int k=0;k<e2[j]->getNumVertices();k++){ if (e2[j]->getVertex(k) == v2 && e2[j] != q) e2[j]->setVertex(k,v4); @@ -663,8 +668,8 @@ static int _quadWithOneVertexOnBoundary (GFace *gf, static int _countCommon(std::vector<MElement*> &a, std::vector<MElement*> &b) { int count = 0; - for (int i=0;i<a.size();i++){ - for (int j=0;j<b.size();j++){ + for (unsigned int i=0;i<a.size();i++){ + for (unsigned int j=0;j<b.size();j++){ if (a[i]==b[j])count++; } } @@ -718,7 +723,7 @@ static int _removeDiamonds(GFace *gf) touched.insert(v2); touched.insert(v3); touched.insert(v4); - for (int j=0;j<it1->second.size();++j){ + for (unsigned int j=0;j<it1->second.size();++j){ for (int k=0;k<it1->second[j]->getNumVertices();k++){ if (it1->second[j]->getVertex(k) == v1 && it1->second[j] != q) it1->second[j]->setVertex(k,v3); @@ -738,7 +743,7 @@ static int _removeDiamonds(GFace *gf) touched.insert(v2); touched.insert(v3); touched.insert(v4); - for (int j=0;j<it2->second.size();++j){ + for (unsigned int j=0;j<it2->second.size();++j){ for (int k=0;k<it2->second[j]->getNumVertices();k++){ if (it2->second[j]->getVertex(k) == v2 && it2->second[j] != q) it2->second[j]->setVertex(k,v4); @@ -1376,7 +1381,7 @@ static int _recombineIntoQuads(GFace *gf, int recur_level, bool cubicGraph = 1) Msg::Debug("Perfect Match Starts %d edges %d nodes",ecount,ncount); std::map<MElement*,int> t2n; std::map<int,MElement*> n2t; - for (int i=0;i<gf->triangles.size();++i){ + for (unsigned int i=0;i<gf->triangles.size();++i){ t2n[gf->triangles[i]] = i; n2t[i] = gf->triangles[i]; } @@ -1437,7 +1442,7 @@ static int _recombineIntoQuads(GFace *gf, int recur_level, bool cubicGraph = 1) Msg::Warning("Perfect Match Failed in Quadrangulation, Applying Graph Splits"); std::set<MElement*> removed; std::vector<MTriangle*> triangles2; - for (int i=0;i<pairs.size();++i){ + for (unsigned int i=0;i<pairs.size();++i){ RecombineTriangle &rt = pairs[i]; if ((rt.n1->onWhat()->dim() < 2 && rt.n2->onWhat()->dim() < 2) || -- GitLab