diff --git a/Geo/CMakeLists.txt b/Geo/CMakeLists.txt index e8d73035adf0db89d78b9648e7a62cee26ddba3c..2dff8ae7b53c33b1854a6afcbc1985e42f738224 100644 --- a/Geo/CMakeLists.txt +++ b/Geo/CMakeLists.txt @@ -23,7 +23,6 @@ set(SRC GModel.cpp GModelCreateTopologyFromMesh.cpp GModelVertexArrays.cpp - GModelFactory.cpp GModelIO_GEO.cpp GModelIO_ACIS.cpp GModelIO_OCC.cpp GModelIO_TOCHNOG.cpp GModelIO_Fourier.cpp GModelIO_MSH.cpp GModelIO_MSH2.cpp GModelIO_VTK.cpp GModelIO_POS.cpp diff --git a/Geo/GFaceCompound.cpp b/Geo/GFaceCompound.cpp index f579999b49107e8e8915eec947b3d27d7372ef37..46170ba73490387b30e98d6d97da57701dfdbae2 100644 --- a/Geo/GFaceCompound.cpp +++ b/Geo/GFaceCompound.cpp @@ -464,7 +464,8 @@ void GFaceCompound::printFillTris() const void GFaceCompound::fillNeumannBCS_Plane() const { -#if defined(HAVE_MESH) +#if 0 +//#if defined(HAVE_MESH) Msg::Debug("Meshing %d interior holes with planes ", _interior_loops.size()-1); @@ -893,8 +894,8 @@ bool GFaceCompound::parametrize() const } } - fillNeumannBCS_Plane(); - //fillNeumannBCS(); + //fillNeumannBCS_Plane(); + fillNeumannBCS(); // Convex parametrization if (_mapping == CONVEX){ diff --git a/Geo/GModel.cpp b/Geo/GModel.cpp index 297271c8ee4482fc959dab0e45680c9cacdcbda9..eaf83e780824c6d8935ff8f99897e3fcfb398cab 100644 --- a/Geo/GModel.cpp +++ b/Geo/GModel.cpp @@ -12,7 +12,6 @@ #include "GModel.h" #include "GModelIO_GEO.h" #include "GModelIO_OCC.h" -#include "GModelFactory.h" #include "GFaceCompound.h" #include "GEdgeCompound.h" #include "MPoint.h" @@ -70,7 +69,7 @@ GModel::GModel(std::string name) _checkPointedMaxVertexNum(0), _checkPointedMaxElementNum(0), _name(name), _visible(1), _octree(0), _geo_internals(0), _occ_internals(0), _acis_internals(0), _fm_internals(0), - _factory(0), _fields(0), _currentMeshEntity(0), + _fields(0), _currentMeshEntity(0), normals(0) { partitionSize[0] = 0; partitionSize[1] = 0; @@ -86,10 +85,6 @@ GModel::GModel(std::string name) // on-demand _createGEOInternals(); - // FIXME: GModelFactory is deprecated and will be removed in Gmsh 3.1. You - // should use GEO_Internals or OCC_Internals instead. - setFactory("Gmsh"); - #if defined(HAVE_MESH) _fields = new FieldManager(); #endif @@ -116,8 +111,6 @@ GModel::~GModel() #if defined(HAVE_MESH) delete _fields; #endif - if(_factory) - delete _factory; } void GModel::setFileName(std::string fileName) @@ -155,22 +148,6 @@ int GModel::setCurrent(GModel *m) return _current; } -void GModel::setFactory(std::string name) -{ - if(_factory) delete _factory; - if(name == "OpenCASCADE"){ -#if defined(HAVE_OCC) - _factory = new OCCFactory(); -#else - Msg::Error("Missing OpenCASCADE support: using Gmsh GEO factory instead"); - _factory = new GeoFactory(); -#endif - } - else{ - _factory = new GeoFactory(); - } -} - GModel *GModel::findByName(const std::string &name, const std::string &fileName) { // return last mesh with given name @@ -3275,281 +3252,6 @@ GFace* GModel::addCompoundFace(std::vector<GFace*> faces, int param, int split, #endif } -// FIXME: what follows will be removed in Gmsh 3.1 -static void factoryWarning() -{ - static bool warn = true; - if(warn){ - Msg::Warning("GModelFactory is deprecated and will be removed in Gmsh 3.1"); - warn = false; - } -} - -GVertex *GModel::addVertex(double x, double y, double z, double lc) -{ - factoryWarning(); - if(_factory) return _factory->addVertex(this, x, y, z, lc); - return 0; -} - -GEdge *GModel::addLine(GVertex *v1, GVertex *v2) -{ - factoryWarning(); - if(_factory) return _factory->addLine(this, v1, v2); - return 0; -} - -GEdge *GModel::addCircleArcCenter(double x, double y, double z, GVertex *start, - GVertex *end) -{ - factoryWarning(); - if(_factory) - return _factory->addCircleArc(this, GModelFactory::CENTER_START_END, - start, end, SPoint3(x, y, z)); - return 0; -} - -GEdge *GModel::addCircleArcCenter(GVertex *start, GVertex *center, GVertex *end) -{ - factoryWarning(); - if(_factory) - return _factory->addCircleArc(this, start, center, end); - return 0; -} - -GEdge *GModel::addCircleArc3Points(double x, double y, double z, GVertex *start, - GVertex *end) -{ - factoryWarning(); - if(_factory) - return _factory->addCircleArc(this, GModelFactory::THREE_POINTS, - start, end, SPoint3(x, y, z)); - return 0; -} - -GEdge *GModel::addBezier(GVertex *start, GVertex *end, - std::vector<std::vector<double> > points) -{ - factoryWarning(); - if(_factory) - return _factory->addSpline(this, GModelFactory::BEZIER, start, end, - points); - return 0; -} - -GEdge *GModel::addBSpline(GVertex *start, GVertex *end, - std::vector<std::vector<double> > points) -{ - factoryWarning(); - if(_factory) - return _factory->addSpline(this, GModelFactory::BSPLINE, start, end, - points); - return 0; -} - -GEdge *GModel::addNURBS(GVertex *start, GVertex *end, - std::vector<std::vector<double> > points, - std::vector<double> knots, - std::vector<double> weights, - std::vector<int> mult) -{ - factoryWarning(); - if(_factory) - return _factory->addNURBS(this, start,end,points,knots,weights, mult); - return 0; -} - -std::vector<GFace *> GModel::addRuledFaces (std::vector<std::vector<GEdge *> > edges) -{ - factoryWarning(); - std::vector<GFace *> faces; - if(_factory) - faces = _factory->addRuledFaces(this, edges); - return faces; -} - -GFace* GModel::addFace (std::vector<GEdge *> edges, - std::vector< std::vector<double > > points) -{ - factoryWarning(); - if(_factory) - return _factory->addFace(this, edges, points); - return 0; -} - -GFace* GModel::addPlanarFace (std::vector<std::vector<GEdge *> > edges) -{ - factoryWarning(); - if(_factory) - return _factory->addPlanarFace(this, edges); - return 0; -} - -GFace* GModel::addPlanarFace (std::vector<std::vector<GEdgeSigned> > edges) -{ - factoryWarning(); - if(_factory) - return _factory->addPlanarFace(this, edges); - return 0; -} - -GRegion* GModel::addVolume (std::vector<std::vector<GFace *> > faces) -{ - factoryWarning(); - if(_factory) - return _factory->addVolume(this, faces); - return 0; -} - -GFace *GModel::add2Drect(double x0, double y0, double dx, double dy) -{ - factoryWarning(); - if(_factory) - return _factory->add2Drect(this, x0, y0, dx, dy); - return 0; -} - -GFace *GModel::add2Dellips(double xc, double yc, double rx, double ry) -{ - factoryWarning(); - if(_factory) - return _factory->add2Dellips(this, xc, yc, rx, ry); - return 0; -} - -GEntity *GModel::revolve(GEntity *e, std::vector<double> p1, std::vector<double> p2, - double angle) -{ - factoryWarning(); - if(_factory) - return _factory->revolve(this, e, p1, p2, angle); - return 0; -} - -GEntity *GModel::extrude(GEntity *e, std::vector<double> p1, std::vector<double> p2) -{ - factoryWarning(); - if(_factory) - return _factory->extrude(this, e, p1, p2); - return 0; -} - -std::vector<GEntity*> GModel::extrudeBoundaryLayer(GEntity *e, int nbLayers, - double hLayers, int dir, int view) -{ - factoryWarning(); - if(_factory) - return _factory->extrudeBoundaryLayer(this, e, nbLayers,hLayers, dir, view); - std::vector<GEntity*> empty; - return empty; -} - -GEntity *GModel::addPipe(GEntity *e, std::vector<GEdge *> edges) -{ - factoryWarning(); - if(_factory) - return _factory->addPipe(this,e,edges); - return 0; -} - -GEntity *GModel::addThruSections(std::vector<std::vector<GEdge *> > edges) -{ - factoryWarning(); - if(_factory) - return _factory->addThruSections(this,edges); - return 0; -} - -GEntity *GModel::addSphere(double cx, double cy, double cz, double radius) -{ - factoryWarning(); - if(_factory) return _factory->addSphere(this, cx, cy, cz, radius); - return 0; -} - -GEntity *GModel::addCylinder(std::vector<double> p1, std::vector<double> p2, - double radius) -{ - factoryWarning(); - if(_factory) return _factory->addCylinder(this, p1, p2, radius); - return 0; -} - -GEntity *GModel::addTorus(std::vector<double> p1, std::vector<double> p2, - double radius1, double radius2) -{ - factoryWarning(); - if(_factory) return _factory->addTorus(this, p1, p2, radius1, radius2); - return 0; -} - -GEntity *GModel::addBlock(std::vector<double> p1, std::vector<double> p2) -{ - factoryWarning(); - if(_factory) return _factory->addBlock(this, p1, p2); - return 0; -} - -GEntity *GModel::add3DBlock(std::vector<double> p1, double dx, double dy, double dz ) -{ - factoryWarning(); - if(_factory) return _factory->add3DBlock(this, p1, dx, dy, dz); - return 0; -} - -GEntity *GModel::addCone(std::vector<double> p1, std::vector<double> p2, - double radius1, double radius2) -{ - factoryWarning(); - if(_factory) return _factory->addCone(this, p1, p2,radius1, radius2); - return 0; -} - -void GModel::healGeometry(double tolerance) -{ - factoryWarning(); - if(_factory) _factory->healGeometry(this, tolerance); -} - -GModel *GModel::computeBooleanUnion(GModel *tool, int createNewModel) -{ - factoryWarning(); - if(_factory) - return _factory->computeBooleanUnion(this, tool, createNewModel); - return 0; -} - -GModel *GModel::computeBooleanIntersection(GModel *tool, int createNewModel) -{ - factoryWarning(); - if(_factory) - return _factory->computeBooleanIntersection(this, tool, createNewModel); - return 0; -} - -GModel *GModel::computeBooleanDifference(GModel *tool, int createNewModel) -{ - factoryWarning(); - if(_factory) - return _factory->computeBooleanDifference(this, tool, createNewModel); - return 0; -} - -void GModel::setPeriodicAllFaces(std::vector<double> FaceTranslationVector) -{ - factoryWarning(); - if(_factory) _factory->setPeriodicAllFaces(this, FaceTranslationVector); -} - -void GModel::setPeriodicPairOfFaces(int numFaceMaster, std::vector<int> EdgeListMaster, - int numFaceSlave, std::vector<int> EdgeListSlave) -{ - factoryWarning(); - if(_factory) - _factory->setPeriodicPairOfFaces(this, numFaceMaster, EdgeListMaster, - numFaceSlave, EdgeListSlave); -} - void GModel::setPhysicalNumToEntitiesInBox(int EntityDimension, int PhysicalNumber, SBoundingBox3d box) { diff --git a/Geo/GModel.h b/Geo/GModel.h index b8992c582a0e43872ef711b425eb5dc86318f36b..d14b5ea8fab51a9afd6aa67f8925bece978fc693 100644 --- a/Geo/GModel.h +++ b/Geo/GModel.h @@ -31,12 +31,10 @@ class gLevelset; class discreteFace; class discreteRegion; class MElementOctree; -class GModelFactory; // A geometric model. The model is a "not yet" non-manifold B-Rep. class GModel { private: - friend class OCCFactory; std::multimap<std::pair<std::vector<int>, std::vector<int> >, std::pair<std::string, std::vector<int> > > _homologyRequests; std::set<GRegion*, GEntityLessThan> _chainRegions; @@ -102,9 +100,6 @@ class GModel { void _createFMInternals(); void _deleteFMInternals(); - // CAD creation factory - GModelFactory *_factory; - // characteristic length (mesh size) fields FieldManager *_fields; @@ -284,6 +279,9 @@ class GModel { void remove(int dim, int tag, bool recursive=false); void remove(const std::vector<std::pair<int, int> > &dimTags, bool recursive=false); + GEdge *addCompoundEdge(std::vector<GEdge*> edges, int num=-1); + GFace *addCompoundFace(std::vector<GFace*> faces, int type, int split, int num=-1); + // snap vertices on model edges by using geometry tolerance void snapVertices(); @@ -501,69 +499,6 @@ class GModel { // classify a mesh for all faces on the current model void classifyAllFaces(); - // glue entities in the model (assume a tolerance eps and merge - // vertices that are too close, then merge edges, faces and - // regions). Warning: the gluer changes the geometric model, so that - // some pointers could become invalid. - // void glue(double eps); - - // change the entity creation factory - void setFactory(std::string name); - - // create brep geometry entities using the factory - GVertex *addVertex(double x, double y, double z, double lc); - GEdge *addLine(GVertex *v1, GVertex *v2); - GEdge *addCircleArcCenter(double x, double y, double z, GVertex *start, GVertex *end); - GEdge *addCircleArcCenter(GVertex *start, GVertex *center, GVertex *end); - GEdge *addCircleArc3Points(double x, double y, double z, GVertex *start, GVertex *end); - GEdge *addBezier(GVertex *start, GVertex *end, std::vector<std::vector<double> > points); - GEdge *addBSpline(GVertex *start, GVertex *end, std::vector<std::vector<double> > points); - GEdge *addNURBS(GVertex *start, GVertex *end, - std::vector<std::vector<double> > points, - std::vector<double> knots, - std::vector<double> weights, - std::vector<int> mult); - GEntity *revolve(GEntity *e, std::vector<double> p1, std::vector<double> p2, - double angle); - GEntity *extrude(GEntity *e, std::vector<double> p1, std::vector<double> p2); - std::vector<GEntity*> extrudeBoundaryLayer(GEntity *e, int nbLayers, double hLayers, - int dir=1, int view=-1); - GEntity *addPipe(GEntity *e, std::vector<GEdge *> edges); - GEntity *addThruSections(std::vector<std::vector<GEdge *> > edges); - - std::vector<GFace *> addRuledFaces(std::vector<std::vector<GEdge *> > edges); - GFace *addFace(std::vector<GEdge *> edges, std::vector< std::vector<double > > points); - GFace *addPlanarFace(std::vector<std::vector<GEdge *> > edges); - GFace *addPlanarFace (std::vector<std::vector<GEdgeSigned> > edges); - GFace *add2Drect(double x0, double y0, double dx, double dy); - GFace *add2Dellips(double xc, double yc, double rx, double ry); - - GEdge *addCompoundEdge(std::vector<GEdge*> edges, int num=-1); - GFace *addCompoundFace(std::vector<GFace*> faces, int type, int split, int num=-1); - GRegion *addVolume(std::vector<std::vector<GFace*> > faces); - - // create solid geometry primitives using the factory - GEntity *addSphere(double cx, double cy, double cz, double radius); - GEntity *addCylinder(std::vector<double> p1, std::vector<double> p2, double radius); - GEntity *addTorus(std::vector<double> p1, std::vector<double> p2, double radius1, - double radius2); - GEntity *addBlock(std::vector<double> p1, std::vector<double> p2); - GEntity *add3DBlock(std::vector<double> p1, double dx, double dy , double dz); - GEntity *addCone(std::vector<double> p1, std::vector<double> p2, double radius1, - double radius2); - - // heal geometry using the factory - void healGeometry(double tolerance = -1); - - // boolean operators acting on 2 models - GModel *computeBooleanUnion(GModel *tool, int createNewModel=0); - GModel *computeBooleanIntersection(GModel *tool, int createNewModel=0); - GModel *computeBooleanDifference(GModel *tool, int createNewModel=0); - - void setPeriodicAllFaces(std::vector<double> FaceTranslationVector); - void setPeriodicPairOfFaces(int numFaceMaster, std::vector<int> EdgeListMaster, - int numFaceSlave, std::vector<int> EdgeListSlave); - // build a new GModel by cutting the elements crossed by the levelset ls // if cutElem is set to false, split the model without cutting the elements GModel *buildCutGModel(gLevelset *ls, bool cutElem=true, bool saveTri=false); diff --git a/Geo/GModelFactory.cpp b/Geo/GModelFactory.cpp deleted file mode 100644 index b275f7d03fb32a616adcd51fe1e59ade31d0bd05..0000000000000000000000000000000000000000 --- a/Geo/GModelFactory.cpp +++ /dev/null @@ -1,1546 +0,0 @@ -// Gmsh - Copyright (C) 1997-2017 C. Geuzaine, J.-F. Remacle -// -// See the LICENSE.txt file for license information. Please report all -// bugs and problems to the public mailing list <gmsh@onelab.info>. - -#include <stdlib.h> -#include "GModelFactory.h" -#include "ListUtils.h" -#include "Context.h" -#include "GVertex.h" -#include "gmshVertex.h" -#include "gmshEdge.h" -#include "gmshFace.h" -#include "gmshRegion.h" -#include "GEdgeCompound.h" -#include "MLine.h" -#include "GModel.h" -#include "Numeric.h" -#include "ExtrudeParams.h" -#include "GModelIO_GEO.h" -#include "Geo.h" -#include "Parser.h" -#include "GmshDefines.h" - -GVertex *GeoFactory::addVertex(GModel *gm, double x, double y, double z, double lc) -{ - int num = gm->getMaxElementaryNumber(0) + 1; - - x *= CTX::instance()->geom.scalingFactor; - y *= CTX::instance()->geom.scalingFactor; - z *= CTX::instance()->geom.scalingFactor; - lc *= CTX::instance()->geom.scalingFactor; - if(lc == 0.) lc = MAX_LC; // no mesh size given at the point - Vertex *p; - p = CreateVertex(num, x, y, z, lc, 1.0); - Tree_Add(gm->getGEOInternals()->Points, &p); - p->Typ = MSH_POINT; - p->Num = num; - - GVertex *v = new gmshVertex(gm, p); - gm->add(v); - - return v; -} - -GEdge *GeoFactory::addLine(GModel *gm, GVertex *start, GVertex *end) -{ - int num = gm->getMaxElementaryNumber(1) + 1; - List_T *iList = List_Create(2, 2, sizeof(int)); - int tagBeg = start->tag(); - int tagEnd = end->tag(); - List_Add(iList, &tagBeg); - List_Add(iList, &tagEnd); - - Curve *c = CreateCurve(num, MSH_SEGM_LINE, 1, iList, NULL, - -1, -1, 0., 1.); - Tree_Add(gm->getGEOInternals()->Curves, &c); - CreateReversedCurve(c); - List_Delete(iList); - c->Typ = MSH_SEGM_LINE; - c->Num = num; - - GEdge *e = new gmshEdge(gm, c, start, end); - gm->add(e); - - return e; -} - -GFace *GeoFactory::addPlanarFace(GModel *gm, std::vector< std::vector<GEdge *> > edges) -{ - std::vector<std::vector<GEdgeSigned> > orientedEdges; - orientedEdges.reserve(edges.size()); - for (size_t i=0; i< edges.size(); i++){ - std::vector<GEdge *> loop = edges[i]; - orientedEdges.push_back(std::vector<GEdgeSigned>()); - std::vector<GEdgeSigned> &orientedLoop = orientedEdges.back(); - orientedLoop.reserve(loop.size()); - for (size_t j=0; j< loop.size(); j++){ - GEdge *edge = loop[j]; - orientedLoop.push_back(GEdgeSigned(1, edge)); - } - } - - return _addPlanarFace(gm, orientedEdges, true); -} - -GFace *GeoFactory::addPlanarFace(GModel *gm, const std::vector<std::vector<GEdgeSigned> > &edges) -{ - return _addPlanarFace(gm, edges, false); -} - -GRegion* GeoFactory::addVolume (GModel *gm, std::vector<std::vector<GFace *> > faces) -{ - //create surface loop - int nLoops = faces.size(); - std::vector<SurfaceLoop *> vecLoops; - for (int i=0; i< nLoops; i++){ - int nl=(int)faces[i].size(); - List_T *temp = List_Create(nl, nl, sizeof(int)); - for(int j = 0; j < nl; j++){ - int numFace = faces[i][j]->tag(); - List_Add(temp, &numFace); - } - int numfl = gm->getMaxElementaryNumber(2) + 1; - while (FindSurfaceLoop(numfl)){ - numfl++; - if (!FindSurfaceLoop(numfl)) break; - } - SurfaceLoop *l = CreateSurfaceLoop(numfl, temp); - vecLoops.push_back(l); - Tree_Add(gm->getGEOInternals()->SurfaceLoops, &l); - List_Delete(temp); - } - - //create volume - int numv = gm->getMaxElementaryNumber(3) + 1; - Volume *v = CreateVolume(numv, MSH_VOLUME); - List_T *temp = List_Create(nLoops, nLoops, sizeof(int)); - for (unsigned int i = 0; i < vecLoops.size(); i++){ - int numl = vecLoops[i]->Num; - List_Add(temp, &numl); - } - SetVolumeSurfaces(v, temp); - List_Delete(temp); - Tree_Add(gm->getGEOInternals()->Volumes, &v); - v->Typ = MSH_VOLUME; - v->Num = numv; - v->Recombine3D = 0; - - //gmsh volume - GRegion *gr = new gmshRegion(gm,v); - gm->add(gr); - - return gr; -} - -GEdge* GeoFactory::addCircleArc(GModel *gm,GVertex *begin, GVertex *center, GVertex *end) -{ - int num = gm->getMaxElementaryNumber(1) + 1; - List_T *iList = List_Create(2, 2, sizeof(int)); - int tagBeg = begin->tag(); - int tagMiddle = center->tag(); - int tagEnd = end->tag(); - List_Add(iList, &tagBeg); - List_Add(iList, &tagMiddle); - List_Add(iList, &tagEnd); - - Curve *c = CreateCurve(num, MSH_SEGM_CIRC, 1, iList, NULL, - -1, -1, 0., 1.); - Tree_Add(gm->getGEOInternals()->Curves, &c); - CreateReversedCurve(c); - List_Delete(iList); - c->Typ = MSH_SEGM_CIRC; - c->Num = num; - - GEdge *e = new gmshEdge(gm, c, begin, end); - gm->add(e); - - return e; -} - -std::vector<GFace *> GeoFactory::addRuledFaces(GModel *gm, - std::vector<std::vector<GEdge *> > edges) -{ - //create line loops - std::vector<EdgeLoop *> vecLoops; - int nLoops = edges.size(); - for (int i=0; i< nLoops; i++){ - int numl = gm->getMaxElementaryNumber(1) + i; - while (FindEdgeLoop(numl)){ - numl++; - if (!FindEdgeLoop(numl)) break; - } - int nl=(int)edges[i].size(); - List_T *temp = List_Create(nl, nl, sizeof(int)); - for(int j = 0; j < nl; j++){ - int numEdge = edges[i][j]->tag(); - List_Add(temp, &numEdge); - } - SortEdgesInLoop(numl, temp); - EdgeLoop *l = CreateEdgeLoop(numl, temp); - vecLoops.push_back(l); - Tree_Add(gm->getGEOInternals()->EdgeLoops, &l); - l->Num = numl; - List_Delete(temp); - } - - //create plane surfaces - int numf = gm->getMaxElementaryNumber(2) + 1; - Surface *s = CreateSurface(numf, MSH_SURF_TRIC); - List_T *iList = List_Create(nLoops, nLoops, sizeof(int)); - for (unsigned int i=0; i< vecLoops.size(); i++){ - int numl = vecLoops[i]->Num; - List_Add(iList, &numl); - } - SetSurfaceGeneratrices(s, iList); - EndSurface(s); - Tree_Add(gm->getGEOInternals()->Surfaces, &s); - s->Typ= MSH_SURF_TRIC; - s->Num = numf; - List_Delete(iList); - - //gmsh surface - GFace *gf = new gmshFace(gm,s); - gm->add(gf); - - std::vector<GFace*> faces; - faces.push_back(gf); - - return faces; -} - -std::vector<GEntity*> GeoFactory::extrudeBoundaryLayer(GModel *gm, GEntity *e, - int nbLayers, double hLayer, - int dir, int view) -{ - - ExtrudeParams *ep = new ExtrudeParams; - ep->mesh.BoundaryLayerIndex = dir; - ep->mesh.ViewIndex = view; //view -5 for centerline based extrude - ep->mesh.NbLayer = 1; //this may be more general for defining different layers - ep->mesh.hLayer.clear(); - ep->mesh.hLayer.push_back(hLayer); - ep->mesh.NbElmLayer.clear(); - ep->mesh.NbElmLayer.push_back(nbLayers); - ep->mesh.ExtrudeMesh = true; - if (CTX::instance()->mesh.recombineAll){ - ep->mesh.Recombine = true; - //ep->mesh.QuadToTri = QUADTRI_DBL_1 ; //QUADTRI_SNGL_1_RECOMB; //QUADTRI_SNGL_1; - } - else ep->mesh.Recombine = false; - ep->geo.Source = e->tag(); - - int type = BOUNDARY_LAYER; - double T0=0., T1=0., T2=0.; - double A0=0., A1=0., A2=0.; - double X0=0., X1=0., X2=0.,alpha=0.; - - std::vector<GEntity*> extrudedEntities; - - //extrude shape dans geo.cpp - Shape shape; - if(e->dim() == 0){ - Vertex *v = FindPoint(e->tag()); - if(!v) printf("vertex %d not found \n", e->tag()); - shape.Num = v->Num; - shape.Type = v->Typ; - } - else if (e->dim() == 1){ - ((GEdge*)e)->meshAttributes.extrude = ep; - Curve *c = FindCurve(e->tag()); - if(!c) printf("curve %d not found \n", e->tag()); - shape.Num = c->Num; - shape.Type = c->Typ; - } - else if (e->dim() == 2){ - ((GFace*)e)->meshAttributes.extrude = ep; - Surface *s = FindSurface(e->tag()); - if(!s) { - Msg::Error("Surface %d not found", e->tag()); - return extrudedEntities; - } - shape.Num = s->Num; - shape.Type = s->Typ; - } - - //extrude shape - List_T *list_out= List_Create(2, 1, sizeof(Shape)); - List_T *tmp = List_Create(1, 1, sizeof(Shape)); - List_Add(tmp, &shape); - ExtrudeShapes(type, tmp, - T0, T1, T2, - A0, A1, A2, - X0, X1, X2, alpha, - ep, - list_out); - - //create GEntities - gm->getGEOInternals()->synchronize(gm); - - //return the new created entity - int nbout = List_Nbr(list_out); - if(e->dim()==1){ - Shape e; - Shape s; - List_Read(list_out, 0, &e); - List_Read(list_out, 1, &s); - GEdge *ge = gm->getEdgeByTag(e.Num); - GFace *gf = gm->getFaceByTag(s.Num); - extrudedEntities.push_back((GEntity*)ge); - extrudedEntities.push_back((GEntity*)gf); - for (int j=2; j<nbout; j++){ - Shape el; - List_Read(list_out, j, &el); - GEdge *gel = gm->getEdgeByTag(el.Num); - extrudedEntities.push_back((GEntity*)gel); - } - } - else if(e->dim()==2){ - Shape s; - Shape v; - List_Read(list_out, 0, &s); - List_Read(list_out, 1, &v); - GFace *gf = gm->getFaceByTag(s.Num); - GRegion *gr = gm->getRegionByTag(v.Num); - extrudedEntities.push_back((GEntity*)gf); - extrudedEntities.push_back((GEntity*)gr); - for (int j=2; j<nbout; j++){ - Shape sl; - List_Read(list_out, j, &sl); - GFace *gfl = gm->getFaceByTag(sl.Num); - extrudedEntities.push_back((GEntity*)gfl); - } - } - - List_Delete(list_out); - List_Delete(tmp); - - return extrudedEntities; - - // //return the new created entity - // GEntity *newEnt=0; - // if (e->dim() == 1){ - // for(GModel::eiter it = gm->firstEdge(); it != gm->lastEdge(); it++){ - // GEdge *ge = *it; - // if(ge->getNativeType() == GEntity::GmshModel && - // ge->geomType() == GEntity::BoundaryLayerCurve){ - // ExtrudeParams *ep = ge->meshAttributes.extrude; - // if(ep && ep->mesh.ExtrudeMesh && ep->geo.Mode == COPIED_ENTITY && - // std::abs(ep->geo.Source) ==e->tag() ) - // newEnt = ge; - // } - // } - // } - // else if (e->dim() ==2){ - // for(GModel::fiter it = gm->firstFace(); it != gm->lastFace(); it++){ - // GFace *gf = *it; - // if(gf->getNativeType() == GEntity::GmshModel && - // gf->geomType() == GEntity::BoundaryLayerSurface){ - // ExtrudeParams *ep = gf->meshAttributes.extrude; - // if(ep && ep->mesh.ExtrudeMesh && ep->geo.Mode == COPIED_ENTITY - // && std::abs(ep->geo.Source) == e->tag()) - // newEnt = gf; - // } - // } - // } - - // return newEnt; - -}; - -void GeoFactory::healGeometry(GModel *gm, double tolerance) -{ - GModel *current = GModel::current(); - GModel::setCurrent(gm); - ReplaceAllDuplicatesNew(tolerance); - gm->destroy(); - gm->getGEOInternals()->synchronize(gm); - GModel::setCurrent(current); -} - -GFace *GeoFactory::_addPlanarFace(GModel *gm, const std::vector<std::vector<GEdgeSigned> > &edges, bool orientEdges) -{ - - //create line loops - int nLoops = edges.size(); - std::vector<EdgeLoop *> vecLoops; - for (int i=0; i< nLoops; i++){ - int ne=(int)edges[i].size(); - List_T *temp = List_Create(ne, ne, sizeof(int)); - for(int j = 0; j < ne; j++){ - const GEdgeSigned &signedEdge = edges[i][j]; - GEdge *ge = signedEdge.ge; - int numEdge = ge->tag(); - //create curve if it does not exist - Curve *c = FindCurve(numEdge); - if(!c){ - GVertex *gvb = ge->getBeginVertex(); - GVertex *gve = ge->getEndVertex(); - Vertex *vertb = FindPoint(abs(gvb->tag())); - Vertex *verte = FindPoint(abs(gve->tag())); - if (!vertb){ - vertb = CreateVertex(gvb->tag(), gvb->x(), gvb->y(), gvb->z(), - gvb->prescribedMeshSizeAtVertex(), 1.0); - Tree_Add(gm->getGEOInternals()->Points, &vertb); - vertb->Typ = MSH_POINT; - vertb->Num = gvb->tag(); - } - if (!verte){ - verte = CreateVertex(gve->tag(), gve->x(), gve->y(), gve->z(), - gve->prescribedMeshSizeAtVertex(), 1.0); - Tree_Add(gm->getGEOInternals()->Points, &verte); - verte->Typ = MSH_POINT; - verte->Num = gve->tag(); - } - - if (ge->geomType() == GEntity::Line){ - c = CreateCurve(numEdge, MSH_SEGM_LINE, 1, NULL, NULL, -1, -1, 0., 1.); - } - else if (ge->geomType() == GEntity::DiscreteCurve){ - c = CreateCurve(numEdge, MSH_SEGM_DISCRETE, 1, NULL, NULL, -1, -1, 0., 1.); - } - else if(ge->geomType() == GEntity::CompoundCurve){ - c = CreateCurve(numEdge, MSH_SEGM_COMPOUND, 1, NULL, NULL, -1, -1, 0., 1.); - std::vector<GEdge*> gec = ((GEdgeCompound*)ge)->getCompounds(); - for(unsigned int i = 0; i < gec.size(); i++) - c->compound.push_back(gec[i]->tag()); - } - else{ - c = CreateCurve(numEdge, MSH_SEGM_DISCRETE, 1, NULL, NULL, -1, -1, 0., 1.); - } - - c->Control_Points = List_Create(2, 1, sizeof(Vertex *)); - List_Add(c->Control_Points, &vertb); - List_Add(c->Control_Points, &verte); - c->beg = vertb; - c->end = verte; - EndCurve(c); - - Tree_Add(gm->getGEOInternals()->Curves, &c); - CreateReversedCurve(c); - } - int signedNumEdge = numEdge*signedEdge.getSign(); - List_Add(temp, &signedNumEdge); - } - - int numl = gm->getMaxElementaryNumber(1) + i; - while (FindEdgeLoop(numl)){ - numl++; - if (!FindEdgeLoop(numl)) break; - } - SortEdgesInLoop(numl, temp, orientEdges); - EdgeLoop *l = CreateEdgeLoop(numl, temp); - vecLoops.push_back(l); - Tree_Add(gm->getGEOInternals()->EdgeLoops, &l); - l->Num = numl; - List_Delete(temp); - } - - //create surface - int numf = gm->getMaxElementaryNumber(2)+1; - Surface *s = CreateSurface(numf, MSH_SURF_PLAN); - List_T *temp = List_Create(nLoops, nLoops, sizeof(int)); - for (int i = 0; i < nLoops; i++){ - int numl = vecLoops[i]->Num; - List_Add(temp, &numl); - } - - SetSurfaceGeneratrices(s, temp); - List_Delete(temp); - EndSurface(s); - Tree_Add(gm->getGEOInternals()->Surfaces, &s); - - //gmsh surface - GFace *gf = new gmshFace(gm,s); - gm->add(gf); - - return gf; -} - -#if defined(HAVE_OCC) -#include "GModelIO_OCC.h" -#include "OCCVertex.h" -#include "OCCEdge.h" -#include "OCCFace.h" -#include "OCCRegion.h" - -#include <BRepAdaptor_Curve.hxx> -#include <BRepAdaptor_Surface.hxx> -#include <BRepAlgoAPI_Common.hxx> -#include <BRepAlgoAPI_Cut.hxx> -#include <BRepAlgoAPI_Fuse.hxx> -#include <BRepAlgoAPI_Section.hxx> -#include <BRepBndLib.hxx> -#include <BRepBuilderAPI_MakeEdge.hxx> -#include <BRepBuilderAPI_MakeFace.hxx> -#include <BRepBuilderAPI_MakeShell.hxx> -#include <BRepBuilderAPI_MakeSolid.hxx> -#include <BRepBuilderAPI_MakeVertex.hxx> -#include <BRepBuilderAPI_MakeWire.hxx> -#include <BRepBuilderAPI_Transform.hxx> -#include <BRepBuilderAPI_GTransform.hxx> -#include <BRepCheck_Analyzer.hxx> -#include <BRepFilletAPI_MakeFillet.hxx> -#include <BRepGProp.hxx> -#include <BRepLProp_SLProps.hxx> -#include <BRepLib.hxx> -#include <BRepMesh.hxx> -#include <BRepMesh_IncrementalMesh.hxx> -#include <BRepOffsetAPI_MakeFilling.hxx> -#include <BRepOffsetAPI_MakePipe.hxx> -#include <BRepOffsetAPI_Sewing.hxx> -#include <BRepOffsetAPI_ThruSections.hxx> -#include <BRepPrimAPI_MakeBox.hxx> -#include <BRepPrimAPI_MakeCone.hxx> -#include <BRepPrimAPI_MakeCylinder.hxx> -#include <BRepPrimAPI_MakePrism.hxx> -#include <BRepPrimAPI_MakeRevol.hxx> -#include <BRepPrimAPI_MakeSphere.hxx> -#include <BRepPrimAPI_MakeTorus.hxx> -#include <BRepTools.hxx> -#include <BRepTools_WireExplorer.hxx> -#include <BRep_Builder.hxx> -#include <BRep_Tool.hxx> -#include <Bnd_Box.hxx> -#include <ElCLib.hxx> -#include <GC_MakeArcOfCircle.hxx> -#include <GProp_GProps.hxx> -#include <Geom2d_Curve.hxx> -#include <GeomAPI_ExtremaCurveCurve.hxx> -#include <GeomAPI_PointsToBSpline.hxx> -#include <GeomAPI_ProjectPointOnCurve.hxx> -#include <GeomAPI_ProjectPointOnSurf.hxx> -#include <GeomLProp_SLProps.hxx> -#include <Geom_BSplineCurve.hxx> -#include <Geom_BezierCurve.hxx> -#include <Geom_Circle.hxx> -#include <Geom_Curve.hxx> -#include <Geom_Surface.hxx> -#include <Geom_TrimmedCurve.hxx> -#include <IGESControl_Reader.hxx> -#include <IGESControl_Writer.hxx> -#include <IGESToBRep_Reader.hxx> -#include <Interface_Static.hxx> -#include <Poly_Array1OfTriangle.hxx> -#include <Poly_Triangle.hxx> -#include <Poly_Triangulation.hxx> -#include <Precision.hxx> -#include <STEPControl_Reader.hxx> -#include <STEPControl_StepModelType.hxx> -#include <STEPControl_Writer.hxx> -#include <ShapeAnalysis.hxx> -#include <ShapeAnalysis_CheckSmallFace.hxx> -#include <ShapeAnalysis_DataMapOfShapeListOfReal.hxx> -#include <ShapeAnalysis_ShapeContents.hxx> -#include <ShapeAnalysis_ShapeTolerance.hxx> -#include <ShapeBuild_ReShape.hxx> -#include <ShapeFix.hxx> -#include <ShapeFix_FixSmallFace.hxx> -#include <ShapeFix_Shape.hxx> -#include <ShapeFix_Wireframe.hxx> -#include <ShapeUpgrade_ShellSewing.hxx> -#include <Standard_ErrorHandler.hxx> -#include <Standard_Failure.hxx> -#include <Standard_Version.hxx> -#include <StlAPI_Writer.hxx> -#include <TColStd_HArray1OfInteger.hxx> -#include <TColStd_HArray1OfReal.hxx> -#include <TColgp_Array1OfPnt2d.hxx> -#include <TColgp_HArray1OfPnt.hxx> -#include <TopExp.hxx> -#include <TopExp_Explorer.hxx> -#include <TopTools_DataMapOfIntegerShape.hxx> -#include <TopTools_DataMapOfShapeInteger.hxx> -#include <TopTools_IndexedMapOfShape.hxx> -#include <TopTools_ListIteratorOfListOfShape.hxx> -#include <TopTools_ListOfShape.hxx> -#include <TopoDS.hxx> -#include <TopoDS_Compound.hxx> -#include <TopoDS_Edge.hxx> -#include <TopoDS_Face.hxx> -#include <TopoDS_Iterator.hxx> -#include <TopoDS_Shape.hxx> -#include <TopoDS_Solid.hxx> -#include <TopoDS_Wire.hxx> -#include <gce_MakeCirc.hxx> -#include <gce_MakePln.hxx> -#include <gp.hxx> -#include <gp_Ax1.hxx> -#include <gp_Ax2.hxx> -#include <gp_Ax2d.hxx> -#include <gp_Dir.hxx> -#include <gp_Dir2d.hxx> -#include <gp_Pnt.hxx> -#include <gp_Pnt2d.hxx> -#include <gp_Trsf.hxx> -#include <gp_GTrsf.hxx> -#include <gp_Vec.hxx> - -GVertex *OCCFactory::addVertex(GModel *gm, double x, double y, double z, double lc) -{ - if (!gm->_occ_internals) - gm->_occ_internals = new OCC_Internals; - - gp_Pnt aPnt; - aPnt = gp_Pnt(x, y, z); - BRepBuilderAPI_MakeVertex mkVertex(aPnt); - TopoDS_Vertex occv = mkVertex.Vertex(); - - GVertex *vertex = gm->_occ_internals->addVertexToModel(gm, occv); - - lc *= CTX::instance()->geom.scalingFactor; - if(lc == 0.) lc = MAX_LC; // no mesh size given at the point - vertex->setPrescribedMeshSizeAtVertex(lc); - - return vertex; -} - -GEdge *OCCFactory::addLine(GModel *gm, GVertex *start, GVertex *end) -{ - if (!gm->_occ_internals) - gm->_occ_internals = new OCC_Internals; - - OCCVertex *occv1 = dynamic_cast<OCCVertex*>(start); - OCCVertex *occv2 = dynamic_cast<OCCVertex*>(end); - TopoDS_Edge occEdge; - if (occv1 && occv2){ - occEdge = BRepBuilderAPI_MakeEdge(occv1->getShape(), - occv2->getShape()).Edge(); - } - else{ - gp_Pnt p1(start->x(),start->y(),start->z()); - gp_Pnt p2(end->x(),end->y(),end->z()); - occEdge = BRepBuilderAPI_MakeEdge(p1, p2).Edge(); - } - return gm->_occ_internals->addEdgeToModel(gm,occEdge); -} - -GEdge *OCCFactory::addCircleArc(GModel *gm, const arcCreationMethod &method, - GVertex *start, GVertex *end, - const SPoint3 &aPoint) -{ - if (!gm->_occ_internals) - gm->_occ_internals = new OCC_Internals; - - gp_Pnt aP1(start->x(), start->y(), start->z()); - gp_Pnt aP2(aPoint.x(), aPoint.y(), aPoint.z()); - gp_Pnt aP3(end->x(), end->y(), end->z()); - TopoDS_Edge occEdge; - - OCCVertex *occv1 = dynamic_cast<OCCVertex*>(start); - OCCVertex *occv2 = dynamic_cast<OCCVertex*>(end); - - if (method == GModelFactory::THREE_POINTS){ - GC_MakeArcOfCircle arc(aP1, aP2, aP3); - if (occv1 && occv2) - occEdge = BRepBuilderAPI_MakeEdge(arc.Value(),occv1->getShape(), - occv2->getShape()).Edge(); - else - occEdge = BRepBuilderAPI_MakeEdge(arc.Value()).Edge(); - } - else if (method == GModelFactory::CENTER_START_END){ - Standard_Real Radius = aP1.Distance(aP2); - gce_MakeCirc MC(aP2,gce_MakePln(aP1, aP2, aP3).Value(), Radius); - const gp_Circ& Circ = MC.Value(); - Standard_Real Alpha1 = ElCLib::Parameter(Circ, aP1); - Standard_Real Alpha2 = ElCLib::Parameter(Circ, aP3); - Handle(Geom_Circle) C = new Geom_Circle(Circ); - Handle(Geom_TrimmedCurve) arc = new Geom_TrimmedCurve(C, Alpha1, Alpha2, false); - if (occv1 && occv2) - occEdge = BRepBuilderAPI_MakeEdge(arc, occv1->getShape(), - occv2->getShape()).Edge(); - else - occEdge = BRepBuilderAPI_MakeEdge(arc).Edge(); - } - return gm->_occ_internals->addEdgeToModel(gm,occEdge); -} - -GEdge *OCCFactory::addSpline(GModel *gm, const splineType &type, - GVertex *start, GVertex *end, - std::vector<std::vector<double> > points) -{ - if (!gm->_occ_internals) - gm->_occ_internals = new OCC_Internals; - - TopoDS_Edge occEdge; - - OCCVertex *occv1 = dynamic_cast<OCCVertex*>(start); - OCCVertex *occv2 = dynamic_cast<OCCVertex*>(end); - - int nbControlPoints = points.size(); - TColgp_Array1OfPnt ctrlPoints(1, nbControlPoints + 2); - int index = 1; - ctrlPoints.SetValue(index++, gp_Pnt(start->x(), start->y(), start->z())); - - // printf("%d %d %d %d\n",points.size(),points[0].size(),points[1].size(),points[2].size()); - for (int i = 0; i < nbControlPoints; i++) { - // printf("%g %g %g\n",points[i][0],points[i][1],points[i][2]); - gp_Pnt aP(points[i][0],points[i][1],points[i][2]); - ctrlPoints.SetValue(index++, aP); - } - ctrlPoints.SetValue(index++, gp_Pnt(end->x(), end->y(), end->z())); - if (type == BEZIER) { - if (nbControlPoints >= 20)Msg::Fatal("OCC Bezier Curves have a maximum degree of 20"); - Handle(Geom_BezierCurve) Bez = new Geom_BezierCurve(ctrlPoints); - if (occv1 && occv2) - occEdge = BRepBuilderAPI_MakeEdge(Bez,occv1->getShape(),occv2->getShape()).Edge(); - else - occEdge = BRepBuilderAPI_MakeEdge(Bez).Edge(); - } - else if (type == BSPLINE) { - - Handle(Geom_BSplineCurve) Bez = GeomAPI_PointsToBSpline(ctrlPoints).Curve(); - - if (occv1 && occv2) - occEdge = BRepBuilderAPI_MakeEdge(Bez,occv1->getShape(),occv2->getShape()).Edge(); - else - occEdge = BRepBuilderAPI_MakeEdge(Bez).Edge(); - } - - - return gm->_occ_internals->addEdgeToModel(gm, occEdge); -} - - -GEdge *OCCFactory::addNURBS(GModel *gm, GVertex *start, GVertex *end, - std::vector<std::vector<double> > points, - std::vector<double> knots, - std::vector<double> weights, - std::vector<int> mult) -{ - try{ - if (!gm->_occ_internals) - gm->_occ_internals = new OCC_Internals; - - OCCVertex *occv1 = dynamic_cast<OCCVertex*>(start); - OCCVertex *occv2 = dynamic_cast<OCCVertex*>(end); - - int nbControlPoints = points.size() + 2; - TColgp_Array1OfPnt ctrlPoints(1, nbControlPoints); - - TColStd_Array1OfReal _knots(1, knots.size()); - TColStd_Array1OfReal _weights(1, weights.size()); - TColStd_Array1OfInteger _mult(1, mult.size()); - - for (unsigned i = 0; i < knots.size(); i++) { - _knots.SetValue(i+1, knots[i]); - } - for (unsigned i = 0; i < weights.size(); i++) { - _weights.SetValue(i+1, weights[i]); - } - int totKnots = 0; - for (unsigned i = 0; i < mult.size(); i++) { - _mult.SetValue(i+1, mult[i]); - totKnots += mult[i]; - } - - const int degree = totKnots - nbControlPoints - 1; - Msg::Debug("creation of a nurbs of degree %d with %d control points", - degree,nbControlPoints); - - int index = 1; - ctrlPoints.SetValue(index++, gp_Pnt(start->x(), start->y(), start->z())); - for (unsigned i = 0; i < points.size(); i++) { - gp_Pnt aP(points[i][0],points[i][1],points[i][2]); - ctrlPoints.SetValue(index++, aP); - } - ctrlPoints.SetValue(index++, gp_Pnt(end->x(), end->y(), end->z())); - Handle(Geom_BSplineCurve) NURBS = new Geom_BSplineCurve - (ctrlPoints, _weights, _knots, _mult, degree, false); - TopoDS_Edge occEdge; - if (occv1 && occv2) - occEdge = BRepBuilderAPI_MakeEdge(NURBS, occv1->getShape(), - occv2->getShape()).Edge(); - else - occEdge = BRepBuilderAPI_MakeEdge(NURBS).Edge(); - return gm->_occ_internals->addEdgeToModel(gm, occEdge); - } - catch(Standard_Failure &err){ - Msg::Error("%s", err.GetMessageString()); - } - return 0; -} - -/* add2Drect: rectangluar face, given lower left point and width/height (in X-Y plane)*/ -GFace *OCCFactory::add2Drect(GModel *gm,double x0, double y0, double dx, double dy) -{ - Msg::Info("Default working plane is XY in add2D* functions..."); - - if (!gm->_occ_internals) - gm->_occ_internals = new OCC_Internals; - - TopoDS_Vertex occv1 = BRepBuilderAPI_MakeVertex( gp_Pnt(x0 , y0 , 0.) ); - TopoDS_Vertex occv2 = BRepBuilderAPI_MakeVertex( gp_Pnt(x0+dx, y0 , 0.) ); - TopoDS_Vertex occv3 = BRepBuilderAPI_MakeVertex( gp_Pnt(x0+dx, y0+dy, 0.) ); - TopoDS_Vertex occv4 = BRepBuilderAPI_MakeVertex( gp_Pnt(x0 , y0+dy, 0.) ); - - TopoDS_Edge occEdge1 = BRepBuilderAPI_MakeEdge(occv1,occv2); - TopoDS_Edge occEdge2 = BRepBuilderAPI_MakeEdge(occv2,occv3); - TopoDS_Edge occEdge3 = BRepBuilderAPI_MakeEdge(occv3,occv4); - TopoDS_Edge occEdge4 = BRepBuilderAPI_MakeEdge(occv4,occv1); - - TopoDS_Wire rectWire = BRepBuilderAPI_MakeWire(occEdge1 , occEdge2 , occEdge3, occEdge4); - TopoDS_Face rectFace = BRepBuilderAPI_MakeFace(rectWire); - - return gm->_occ_internals->addFaceToModel(gm, TopoDS::Face(rectFace)); -} - -/* add2Dellips: ellips face, given lower left point and width/height (in X-Y plane)*/ -GFace *OCCFactory::add2Dellips(GModel *gm, double xc, double yc, double rx, double ry) -{ - Msg::Info("Default working plane is XY in add2D* functions..."); - - if (!gm->_occ_internals) - gm->_occ_internals = new OCC_Internals; - - gp_Dir N_dir(0., 0., 1.); - gp_Dir x_dir(1., 0., 0.); - gp_Pnt center(xc, yc, 0.); - gp_Ax2 axis(center, N_dir, x_dir); - gp_Elips ellipse = gp_Elips(axis, rx, ry); - // gp_Ax2(gp_Pnt(xc,yc;0),gp_Dir(0.,0.,1.)),rx,ry - TopoDS_Edge ellipsEdge = BRepBuilderAPI_MakeEdge(ellipse); - TopoDS_Wire ellipsWire = BRepBuilderAPI_MakeWire(ellipsEdge); - TopoDS_Face ellipsFace = BRepBuilderAPI_MakeFace(ellipsWire); - // TopoDS_Edge ellipsEdge = BRepBuilderAPI_MakeEdge( gp_Elips2d(gp_Ax22d(gp_Pnt2d(xc,yc), - // gp_Dir2d(1.,0.), gp_Dir2d(0.,1.)),rx,ry) ); - - return gm->_occ_internals->addFaceToModel(gm, TopoDS::Face(ellipsFace)); -} - -GEntity *OCCFactory::revolve(GModel *gm, GEntity* base, - std::vector<double> p1, - std::vector<double> p2, double angle) -{ - if (!gm->_occ_internals) - gm->_occ_internals = new OCC_Internals; - - const double x1 = p1[0]; - const double y1 = p1[1]; - const double z1 = p1[2]; - const double x2 = p2[0]; - const double y2 = p2[1]; - const double z2 = p2[2]; - - gp_Dir direction(x2 - x1, y2 - y1, z2 - z1); - gp_Ax1 axisOfRevolution(gp_Pnt(x1, y1, z1), direction); - BRepPrimAPI_MakeRevol MR(*(TopoDS_Shape*)base->getNativePtr(), - axisOfRevolution, angle, Standard_False); - GEntity *ret = 0; - if (base->cast2Vertex()){ - TopoDS_Edge result = TopoDS::Edge(MR.Shape()); - ret = gm->_occ_internals->addEdgeToModel(gm, result); - } - if (base->cast2Edge()){ - TopoDS_Face result = TopoDS::Face(MR.Shape()); - ret = gm->_occ_internals->addFaceToModel(gm, result); - } - if (base->cast2Face()){ - TopoDS_Solid result = TopoDS::Solid(MR.Shape()); - ret = gm->_occ_internals->addRegionToModel(gm, result); - } - return ret; -} - -GEntity *OCCFactory::extrude(GModel *gm, GEntity* base, - std::vector<double> p1, std::vector<double> p2) -{ - if (!gm->_occ_internals) - gm->_occ_internals = new OCC_Internals; - - const double x1 = p1[0]; - const double y1 = p1[1]; - const double z1 = p1[2]; - const double x2 = p2[0]; - const double y2 = p2[1]; - const double z2 = p2[2]; - - gp_Vec direction(gp_Pnt(x1, y1, z1), gp_Pnt(x2, y2, z2)); - BRepPrimAPI_MakePrism MP(*(TopoDS_Shape*)base->getNativePtr(), direction, - Standard_False); - GEntity *ret = 0; - if (base->cast2Vertex()){ - TopoDS_Edge result = TopoDS::Edge(MP.Shape()); - ret = gm->_occ_internals->addEdgeToModel(gm, result); - } - if (base->cast2Edge()){ - TopoDS_Face result = TopoDS::Face(MP.Shape()); - ret = gm->_occ_internals->addFaceToModel(gm, result); - } - if (base->cast2Face()){ - TopoDS_Solid result = TopoDS::Solid(MP.Shape()); - ret = gm->_occ_internals->addRegionToModel(gm, result); - } - return ret; -} - -GEntity *OCCFactory::addSphere(GModel *gm, double xc, double yc, double zc, double radius) -{ - if (!gm->_occ_internals) - gm->_occ_internals = new OCC_Internals; - - gp_Pnt aP(xc, yc, zc); - TopoDS_Shape shape = BRepPrimAPI_MakeSphere(aP, radius).Shape(); - gm->_occ_internals->buildShapeFromLists(shape); - gm->destroy(); - gm->_occ_internals->buildLists(); - gm->_occ_internals->buildGModel(gm); - return gm->_occ_internals->getRegionForOCCShape(gm, TopoDS::Solid(shape)); -} - -GRegion* OCCFactory::addVolume (GModel *gm, std::vector<std::vector<GFace *> > faces) -{ - Msg::Error("add Volume not implemented yet for OCCFactory"); - return 0; -} - -GEntity *OCCFactory::addCylinder(GModel *gm, std::vector<double> p1, - std::vector<double> p2, double radius) -{ - if (!gm->_occ_internals) - gm->_occ_internals = new OCC_Internals; - - const double x1 = p1[0]; - const double y1 = p1[1]; - const double z1 = p1[2]; - const double x2 = p2[0]; - const double y2 = p2[1]; - const double z2 = p2[2]; - - gp_Pnt aP(x1, y1, z1); - const double H = sqrt((x2 - x1) * (x2 - x1) + (y2 - y1) * (y2 - y1) + - (z2 - z1) * (z2 - z1)); - gp_Vec aV((x2 - x1) / H, (y2 - y1) / H, (z2 - z1) / H); - gp_Ax2 anAxes(aP, aV); - BRepPrimAPI_MakeCylinder MC(anAxes, radius, H); - MC.Build(); - if (!MC.IsDone()) { - Msg::Error("Cylinder can't be computed from the given parameters"); - return 0; - } - TopoDS_Shape shape = MC.Shape(); - gm->_occ_internals->buildShapeFromLists(shape); - gm->destroy(); - gm->_occ_internals->buildLists(); - gm->_occ_internals->buildGModel(gm); - return gm->_occ_internals->getRegionForOCCShape(gm, TopoDS::Solid(shape)); -} - -GEntity *OCCFactory::addTorus(GModel *gm, std::vector<double> p1, - std::vector<double> p2, double radius1, - double radius2) -{ - if (!gm->_occ_internals) - gm->_occ_internals = new OCC_Internals; - - const double x1 = p1[0]; - const double y1 = p1[1]; - const double z1 = p1[2]; - const double x2 = p2[0]; - const double y2 = p2[1]; - const double z2 = p2[2]; - gp_Pnt aP(x1, y1, z1); - const double H = sqrt((x2 - x1) * (x2 - x1) + (y2 - y1) * (y2 - y1) + - (z2 - z1) * (z2 - z1)); - gp_Vec aV((x2 - x1) / H, (y2 - y1) / H, (z2 - z1) / H); - gp_Ax2 anAxes(aP, aV); - BRepPrimAPI_MakeTorus MC(anAxes, radius1, radius2); - MC.Build(); - if (!MC.IsDone()) { - Msg::Error("Cylinder can't be computed from the given parameters"); - return 0; - } - TopoDS_Shape shape = MC.Shape(); - gm->_occ_internals->buildShapeFromLists(shape); - gm->destroy(); - gm->_occ_internals->buildLists(); - gm->_occ_internals->buildGModel(gm); - return gm->_occ_internals->getRegionForOCCShape(gm, TopoDS::Solid(shape)); -} - -GEntity *OCCFactory::addCone(GModel *gm, std::vector<double> p1, - std::vector<double> p2, double radius1, - double radius2) -{ - if (!gm->_occ_internals) - gm->_occ_internals = new OCC_Internals; - - const double x1 = p1[0]; - const double y1 = p1[1]; - const double z1 = p1[2]; - const double x2 = p2[0]; - const double y2 = p2[1]; - const double z2 = p2[2]; - - gp_Pnt aP(x1, y1, z1); - const double H = sqrt((x2 - x1) * (x2 - x1) + (y2 - y1) * (y2 - y1) + - (z2 - z1) * (z2 - z1)); - gp_Vec aV((x2 - x1) / H, (y2 - y1) / H, (z2 - z1) / H); - gp_Ax2 anAxes(aP, aV); - BRepPrimAPI_MakeCone MC(anAxes, radius1, radius2, H); - MC.Build(); - if (!MC.IsDone()) { - Msg::Error("Cylinder can't be computed from the given parameters"); - return 0; - } - TopoDS_Shape shape = MC.Shape(); - gm->_occ_internals->buildShapeFromLists(shape); - gm->destroy(); - gm->_occ_internals->buildLists(); - gm->_occ_internals->buildGModel(gm); - return gm->_occ_internals->getRegionForOCCShape(gm,TopoDS::Solid(shape)); -} - -GEntity *OCCFactory::addBlock(GModel *gm, std::vector<double> p1, - std::vector<double> p2) -{ - if (!gm->_occ_internals) - gm->_occ_internals = new OCC_Internals; - - gp_Pnt P1(p1[0], p1[1], p1[2]); - gp_Pnt P2(p2[0], p2[1], p2[2]); - BRepPrimAPI_MakeBox MB(P1, P2); - MB.Build(); - if (!MB.IsDone()) { - Msg::Error("Box can not be computed from the given point"); - return 0; - } - TopoDS_Shape shape = MB.Shape(); - gm->_occ_internals->buildShapeFromLists(shape); - gm->destroy(); - gm->_occ_internals->buildLists(); - gm->_occ_internals->buildGModel(gm); - return gm->_occ_internals->getRegionForOCCShape(gm, TopoDS::Solid(shape)); -} - -GEntity *OCCFactory::add3DBlock(GModel *gm,std::vector<double> p1, - double dx, double dy, double dz) -{ - if (!gm->_occ_internals) - gm->_occ_internals = new OCC_Internals; - - gp_Pnt P1(p1[0], p1[1], p1[2]); - BRepPrimAPI_MakeBox MB(P1, dx, dy, dz); - MB.Build(); - if (!MB.IsDone()) { - Msg::Error("Box can not be computed from the given point"); - return 0; - } - TopoDS_Shape shape = MB.Shape(); - gm->_occ_internals->buildShapeFromLists(shape); - gm->destroy(); - gm->_occ_internals->buildLists(); - gm->_occ_internals->buildGModel(gm); - return gm->_occ_internals->getRegionForOCCShape(gm, TopoDS::Solid(shape)); -} - -GModel *OCCFactory::computeBooleanUnion(GModel* obj, GModel* tool, - int createNewModel) -{ - try{ - OCC_Internals *occ_obj = obj->getOCCInternals(); - OCC_Internals *occ_tool = tool->getOCCInternals(); - - if (!occ_obj || !occ_tool) return NULL; - - if (createNewModel){ - GModel *temp = new GModel; - temp->_occ_internals = new OCC_Internals; - temp->_occ_internals->_addShapeToLists(occ_obj->getShape()); - obj = temp; - } - obj->_occ_internals->applyBooleanOperator(occ_tool->getShape(), - OCC_Internals::Union); - obj->destroy(); - obj->_occ_internals->buildLists(); - obj->_occ_internals->buildGModel(obj); - } - catch(Standard_Failure &err){ - Msg::Error("%s", err.GetMessageString()); - } - - return obj; -} - -GModel *OCCFactory::computeBooleanDifference(GModel* obj, GModel* tool, - int createNewModel) -{ - try{ - OCC_Internals *occ_obj = obj->getOCCInternals(); - OCC_Internals *occ_tool = tool->getOCCInternals(); - - if (!occ_obj || !occ_tool) return NULL; - - if (createNewModel){ - GModel *temp = new GModel; - temp->_occ_internals = new OCC_Internals; - temp->_occ_internals->_addShapeToLists(occ_obj->getShape()); - obj = temp; - } - obj->getOCCInternals()->applyBooleanOperator(occ_tool->getShape(), - OCC_Internals::Difference); - obj->destroy(); - obj->_occ_internals->buildLists(); - obj->_occ_internals->buildGModel(obj); - } - catch(Standard_Failure &err){ - Msg::Error("%s", err.GetMessageString()); - } - return obj; -} - -GModel *OCCFactory::computeBooleanIntersection(GModel* obj, GModel* tool, - int createNewModel) -{ - try{ - OCC_Internals *occ_obj = obj->getOCCInternals(); - OCC_Internals *occ_tool = tool->getOCCInternals(); - - if (!occ_obj || !occ_tool) return NULL; - - if (createNewModel){ - GModel *temp = new GModel; - temp->_occ_internals = new OCC_Internals; - temp->_occ_internals->_addShapeToLists(occ_obj->getShape()); - obj = temp; - } - obj->getOCCInternals()->applyBooleanOperator(occ_tool->getShape(), - OCC_Internals::Intersection); - obj->destroy(); - obj->_occ_internals->buildLists(); - obj->_occ_internals->buildGModel(obj); - } - catch(Standard_Failure &err){ - Msg::Error("%s", err.GetMessageString()); - } - return obj; -} - -/* IsEqualG : a tolerance function for setPeriodicAllFaces */ -bool IsEqualG(double x, double y) -{ - const double epsilon = 0.00000000001; - return fabs(x - y) <= epsilon * (std::max(fabs(x),fabs(y))); -} - -/* setPeriodicAllFaces: detects T-periodic pair of faces and uses - setPeriodicPairOfFaces to make them all periodic */ -void OCCFactory::setPeriodicAllFaces(GModel *gm, std::vector<double> FaceTranslationVector) -{ - if (!gm->_occ_internals) - gm->_occ_internals = new OCC_Internals; - - Msg::Info("Experimental: search for 'translated' faces and calls setPeriodicPairOfFaces automatically"); - TopoDS_Shape shape = gm->_occ_internals->getShape(); - gp_Trsf theTransformation; - gp_Vec theVectorOfTranslation(FaceTranslationVector[0], - FaceTranslationVector[1], - FaceTranslationVector[2]); - int numFaceMaster , numFaceSlave; - std::list<GEdge*> ListOfEdgeMaster, ListOfEdgeSlave; - for(TopExp_Explorer aFaceExplorer(shape, TopAbs_FACE); aFaceExplorer.More(); aFaceExplorer.Next()){ - TopoDS_Face aFace1 = TopoDS::Face(aFaceExplorer.Current()); - for(TopExp_Explorer aFaceExplorer2(shape, TopAbs_FACE); aFaceExplorer2.More(); aFaceExplorer2.Next()){ - TopoDS_Face aFace2 = TopoDS::Face(aFaceExplorer2.Current()); - // Get number of Edges - int NumberOfEdgesInFace1=0; - int NumberOfEdgesInFace2=0; - for (TopExp_Explorer aEdgeExplorer1(aFace1,TopAbs_EDGE); aEdgeExplorer1.More(); - aEdgeExplorer1.Next()) {NumberOfEdgesInFace1++;} - for (TopExp_Explorer aEdgeExplorer2(aFace2,TopAbs_EDGE); aEdgeExplorer2.More(); - aEdgeExplorer2.Next()) {NumberOfEdgesInFace2++;} - // Get Surfaces of Faces (occtopo=>occgeom) - Handle(Geom_Surface) Surf1=BRep_Tool::Surface(aFace1); - Handle(Geom_Surface) Surf2=BRep_Tool::Surface(aFace2); - // Get barycenter and area - GProp_GProps FaceProps1; - GProp_GProps FaceProps2; - BRepGProp::SurfaceProperties(aFace1,FaceProps1); - BRepGProp::SurfaceProperties(aFace2,FaceProps2); - gp_Pnt BarycenterFace1 = FaceProps1.CentreOfMass (); - gp_Pnt BarycenterFace2 = FaceProps2.CentreOfMass (); - Standard_Real Area1 = FaceProps1.Mass(); - Standard_Real Area2 = FaceProps2.Mass(); - // Get surface normal - //Standard_Real umin, vmin;//umax,vmax - //GeomLProp_SLProps props1(Surf1, umin, vmin, 1, 0.01); - //GeomLProp_SLProps props2(Surf2, umin, vmin, 1, 0.01); - //gp_Dir norm1=props1.Normal(); - //gp_Dir norm2=props2.Normal(); - - if(NumberOfEdgesInFace1==NumberOfEdgesInFace2 - && IsEqualG(Area1,Area2) - && IsEqualG(BarycenterFace1.X()+FaceTranslationVector[0],BarycenterFace2.X()) - && IsEqualG(BarycenterFace1.Y()+FaceTranslationVector[1],BarycenterFace2.Y()) - && IsEqualG(BarycenterFace1.Z()+FaceTranslationVector[2],BarycenterFace2.Z())){ - numFaceMaster = gm->getOCCInternals()->getFaceForOCCShape(gm,aFace1)->tag(); - numFaceSlave = gm->getOCCInternals()->getFaceForOCCShape(gm,aFace2)->tag(); - //Msg::Info("Face %d (slave) is most likely Face %d (master) translated by (%.2e,%.2e,%.2e)!", - // numFaceSlave,numFaceMaster,FaceTranslationVector[0],FaceTranslationVector[1], - // FaceTranslationVector[2]); - - std::vector<int> EdgeListMaster(NumberOfEdgesInFace1); - std::vector<int> EdgeListSlave(NumberOfEdgesInFace2); - int i1=0;//,i2=0; - - // ici il faut imbriquer la seconde boucle pour fournir des edges qui match slave/master - for (TopExp_Explorer aEdgeExplorer1(aFace1,TopAbs_EDGE); aEdgeExplorer1.More(); - aEdgeExplorer1.Next()) { - TopoDS_Edge aEdge1 = TopoDS::Edge(aEdgeExplorer1.Current()); - int numEdgeMaster = gm->getOCCInternals()->getEdgeForOCCShape(gm,aEdge1)->tag(); - EdgeListMaster[i1] = numEdgeMaster; - //i2=0; - for (TopExp_Explorer aEdgeExplorer2(aFace2,TopAbs_EDGE); aEdgeExplorer2.More(); - aEdgeExplorer2.Next()) { - TopoDS_Edge aEdge2 = TopoDS::Edge(aEdgeExplorer2.Current()); - GProp_GProps EdgeProps1; - GProp_GProps EdgeProps2; - BRepGProp::LinearProperties(aEdge1, EdgeProps1); - BRepGProp::LinearProperties(aEdge2, EdgeProps2); - gp_Pnt BarycenterEdge1 = EdgeProps1.CentreOfMass (); - gp_Pnt BarycenterEdge2 = EdgeProps2.CentreOfMass (); - Standard_Real Length1 = EdgeProps1.Mass(); - Standard_Real Length2 = EdgeProps2.Mass(); - if(IsEqualG(Length1,Length2) - && IsEqualG(BarycenterEdge1.X()+FaceTranslationVector[0],BarycenterEdge2.X()) - && IsEqualG(BarycenterEdge1.Y()+FaceTranslationVector[1],BarycenterEdge2.Y()) - && IsEqualG(BarycenterEdge1.Z()+FaceTranslationVector[2],BarycenterEdge2.Z())){ - int numEdgeSlave = gm->getOCCInternals()->getEdgeForOCCShape(gm,aEdge2)->tag(); - EdgeListSlave[i1] = numEdgeSlave; - } - } - i1++; - } - if(NumberOfEdgesInFace1==4) - Msg::Info("Setting Periodic : Face %d {%d,%d,%d,%d} (slave) and Face %d " - "{%d,%d,%d,%d} (master)", - numFaceSlave ,EdgeListSlave[0] ,EdgeListSlave[1] ,EdgeListSlave[2], - EdgeListSlave[3], numFaceMaster,EdgeListMaster[0],EdgeListMaster[1], - EdgeListMaster[2],EdgeListMaster[3]); - setPeriodicPairOfFaces(gm, numFaceMaster, EdgeListMaster, numFaceSlave, EdgeListSlave); - } - else ; - } - } -} - -/* setPeriodicPairOfFaces: set periodic given a Slave/Master pair of - numFace-Edgelist */ -void OCCFactory::setPeriodicPairOfFaces(GModel *gm, int numFaceMaster, - std::vector<int> EdgeListMaster, - int numFaceSlave, - std::vector<int> EdgeListSlave) -{ - if (!gm->_occ_internals) - gm->_occ_internals = new OCC_Internals; - - if (EdgeListMaster.size() != EdgeListSlave.size()){ - Msg::Error("Slave/Master faces don't have the same number of edges!"); - } - else { - - std::map<int,int> edgeCounterparts; - std::vector<int>::iterator siter = EdgeListSlave.begin(); - std::vector<int>::iterator miter = EdgeListMaster.begin(); - - for (;siter!=EdgeListSlave.end();++siter,++miter) { - edgeCounterparts[*siter] = *miter; - } - - GFace *gf = GModel::current()->getFaceByTag(abs(numFaceSlave)); - if (gf) { - GFace *master = GModel::current()->getFaceByTag(abs(numFaceMaster)); - gf->setMeshMaster(master,edgeCounterparts); - } - else Msg::Error("Slave surface %d not found", numFaceSlave); - } -} - -void OCCFactory::fillet(GModel *gm, std::vector<int> edges, double radius) -{ - if (!gm->_occ_internals) - gm->_occ_internals = new OCC_Internals; - - try{ - std::vector<TopoDS_Edge> edgesToFillet; - for (unsigned i = 0; i < edges.size(); i++){ - GEdge *ed = gm->getEdgeByTag(edges[i]); - if (ed){ - OCCEdge *occed = dynamic_cast<OCCEdge*>(ed); - if (occed)edgesToFillet.push_back(occed->getTopoDS_Edge()); - } - } - gm->_occ_internals->fillet(edgesToFillet, radius); - gm->destroy(); - gm->_occ_internals->buildLists(); - gm->_occ_internals->buildGModel(gm); - } - catch(Standard_Failure &err){ - Msg::Error("%s", err.GetMessageString()); - } -} - -void OCCFactory::translate(GModel *gm, std::vector<double> dx, int addToTheModel) -{ - if (!gm->_occ_internals) - gm->_occ_internals = new OCC_Internals; - - gp_Trsf transformation; - transformation.SetTranslation(gp_Pnt (0,0,0),gp_Pnt (dx[0],dx[1],dx[2])); - BRepBuilderAPI_Transform aTransformation(gm->_occ_internals->getShape(), - transformation, Standard_False); - TopoDS_Shape temp = aTransformation.Shape(); - if (!addToTheModel) gm->_occ_internals->loadShape(& temp); - else gm->_occ_internals->buildShapeFromLists(temp); - gm->destroy(); - gm->_occ_internals->buildLists(); - gm->_occ_internals->buildGModel(gm); -} - -void OCCFactory::rotate(GModel *gm, std::vector<double> p1, std::vector<double> p2, - double angle, int addToTheModel) -{ - if (!gm->_occ_internals) - gm->_occ_internals = new OCC_Internals; - - const double x1 = p1[0]; - const double y1 = p1[1]; - const double z1 = p1[2]; - const double x2 = p2[0]; - const double y2 = p2[1]; - const double z2 = p2[2]; - - gp_Trsf transformation; - - gp_Vec direction(gp_Pnt(x1, y1, z1), gp_Pnt(x2, y2, z2)); - gp_Ax1 axisOfRevolution(gp_Pnt(x1, y1, z1), direction); - transformation.SetRotation(axisOfRevolution, angle); - BRepBuilderAPI_Transform aTransformation(gm->_occ_internals->getShape(), - transformation, Standard_False); - TopoDS_Shape temp = aTransformation.Shape(); - if (!addToTheModel) gm->_occ_internals->loadShape(&temp); - else gm->_occ_internals->buildShapeFromLists(temp); - gm->destroy(); - gm->_occ_internals->buildLists(); - gm->_occ_internals->buildGModel(gm); -} - -void OCCFactory::dilate(GModel *gm, std::vector<double> p, std::vector<double> s, - int addToTheModel) -{ - if (!gm->_occ_internals) - gm->_occ_internals = new OCC_Internals; - - const double x = p[0]; - const double y = p[1]; - const double z = p[2]; - - const double a = s[0]; - const double b = s[1]; - const double c = s[2]; - - gp_GTrsf transformation; - transformation.SetVectorialPart(gp_Mat(a, 0, 0, 0, b, 0, 0, 0, c)); - transformation.SetTranslationPart(gp_XYZ(x,y,z)); - BRepBuilderAPI_GTransform aTransformation(gm->_occ_internals->getShape(), - transformation, Standard_False); - TopoDS_Shape temp = aTransformation.Shape(); - if (!addToTheModel) gm->_occ_internals->loadShape(&temp); - else gm->_occ_internals->buildShapeFromLists(temp); - gm->destroy(); - gm->_occ_internals->buildLists(); - gm->_occ_internals->buildGModel(gm); -} - -std::vector<GFace *> OCCFactory::addRuledFaces(GModel *gm, - std::vector< std::vector<GEdge *> > wires) -{ - if (!gm->_occ_internals) - gm->_occ_internals = new OCC_Internals; - - std::vector<GFace*> faces; - Standard_Boolean anIsSolid = Standard_False; - Standard_Boolean anIsRuled = Standard_True; - BRepOffsetAPI_ThruSections aGenerator (anIsSolid,anIsRuled); - - for (unsigned i=0;i<wires.size();i++) { - BRepBuilderAPI_MakeWire wire_maker; - for (unsigned j=0;j<wires[i].size();j++) { - GEdge *ge = wires[i][j]; - OCCEdge *occe = dynamic_cast<OCCEdge*>(ge); - if (occe){ - wire_maker.Add(occe->getTopoDS_Edge()); - } - } - aGenerator.AddWire (wire_maker.Wire()); - } - - aGenerator.CheckCompatibility (Standard_False); - - aGenerator.Build(); - - TopoDS_Shape aResult = aGenerator.Shape(); - - TopExp_Explorer exp2; - for(exp2.Init(TopoDS::Shell(aResult), TopAbs_FACE); exp2.More(); exp2.Next()){ - TopoDS_Face face = TopoDS::Face(exp2.Current()); - GFace *ret = gm->_occ_internals->addFaceToModel(gm, face); - faces.push_back(ret); - } - return faces; -} - -GFace *OCCFactory::addFace(GModel *gm, std::vector<GEdge *> edges, - std::vector< std::vector<double > > points) -{ - if (!gm->_occ_internals) - gm->_occ_internals = new OCC_Internals; - - BRepOffsetAPI_MakeFilling aGenerator; - - for (unsigned i = 0; i < edges.size(); i++) { - GEdge *ge = edges[i]; - OCCEdge *occe = dynamic_cast<OCCEdge*>(ge); - if (occe){ - aGenerator.Add(occe->getTopoDS_Edge(), GeomAbs_C0); - } - } - for (unsigned i = 0; i < points.size(); i++) { - gp_Pnt aPnt(points[i][0], points[i][1], points[i][2]); - aGenerator.Add(aPnt); - } - - aGenerator.Build(); - - TopoDS_Shape aResult = aGenerator.Shape(); - return gm->_occ_internals->addFaceToModel(gm, TopoDS::Face(aResult)); -} - -GFace *OCCFactory::addPlanarFace(GModel *gm, std::vector< std::vector<GEdge *> > wires) -{ - if (!gm->_occ_internals) - gm->_occ_internals = new OCC_Internals; - - std::set<GVertex*> verts; - for (unsigned i = 0; i < wires.size(); i++) { - for (unsigned j = 0; j < wires[i].size(); j++) { - GEdge *ge = wires[i][j]; - verts.insert(ge->getBeginVertex()); - verts.insert(ge->getEndVertex()); - } - } - std::vector<SPoint3> points; - std::set<GVertex*>::iterator it = verts.begin(); - for ( ; it != verts.end(); ++it){ - points.push_back(SPoint3((*it)->x(), (*it)->y(), (*it)->z())); - } - - mean_plane meanPlane; - computeMeanPlaneSimple(points, meanPlane); - - gp_Pln aPlane (meanPlane.a, meanPlane.b, meanPlane.c, -meanPlane.d); - BRepBuilderAPI_MakeFace aGenerator (aPlane); - - for (unsigned i = 0; i < wires.size() ;i++) { - BRepBuilderAPI_MakeWire wire_maker; - for (unsigned j = 0; j < wires[i].size(); j++) { - GEdge *ge = wires[i][j]; - OCCEdge *occe = dynamic_cast<OCCEdge*>(ge); - if (occe){ - wire_maker.Add(occe->getTopoDS_Edge()); - } - } - TopoDS_Wire myWire = wire_maker.Wire(); - //if (i)myWire.Reverse(); - aGenerator.Add (myWire); - } - - aGenerator.Build(); - TopoDS_Shape aResult = aGenerator.Shape(); - - return gm->_occ_internals->addFaceToModel(gm, TopoDS::Face(aResult)); -} - -GFace *OCCFactory::addPlanarFace(GModel *gm, const std::vector<std::vector<GEdgeSigned> > &edges) -{ - Msg::Error("addPlanarFace with oriented edges not implemented yet for OCCFactory"); - return 0; -} - -GEntity *OCCFactory::addPipe(GModel *gm, GEntity *base, std::vector<GEdge *> wire) -{ - if (!gm->_occ_internals) - gm->_occ_internals = new OCC_Internals; - - BRepBuilderAPI_MakeWire wire_maker; - for (unsigned j = 0; j < wire.size(); j++) { - GEdge *ge = wire[j]; - OCCEdge *occe = dynamic_cast<OCCEdge*>(ge); - if (occe){ - wire_maker.Add(occe->getTopoDS_Edge()); - } - } - TopoDS_Wire myWire = wire_maker.Wire(); - - GEntity *ret = 0; - if (base->cast2Vertex()){ - OCCVertex *occv = dynamic_cast<OCCVertex*>(base); - BRepOffsetAPI_MakePipe myNiceLittlePipe (myWire, occv->getShape()); - TopoDS_Edge result = TopoDS::Edge(myNiceLittlePipe.Shape()); - ret = gm->_occ_internals->addEdgeToModel(gm, result); - } - if (base->cast2Edge()){ - OCCEdge *occe = dynamic_cast<OCCEdge*>(base); - BRepOffsetAPI_MakePipe myNiceLittlePipe (myWire, occe->getTopoDS_Edge()); - TopoDS_Face result = TopoDS::Face(myNiceLittlePipe.Shape()); - ret = gm->_occ_internals->addFaceToModel(gm, result); - } - if (base->cast2Face()){ - OCCFace *occf = dynamic_cast<OCCFace*>(base); - BRepOffsetAPI_MakePipe myNiceLittlePipe (myWire, occf->getTopoDS_Face()); - TopoDS_Solid result = TopoDS::Solid(myNiceLittlePipe.Shape()); - ret = gm->_occ_internals->addRegionToModel(gm, result); - } - return ret; -} - -GEntity *OCCFactory::addThruSections(GModel *gm, std::vector<std::vector<GEdge *> > wire) -{ - if (!gm->_occ_internals) - gm->_occ_internals = new OCC_Internals; - - BRepOffsetAPI_ThruSections aGenerator(Standard_True); // create solid - for (unsigned i = 0; i < wire.size(); i++) { - BRepBuilderAPI_MakeWire wire_maker; - for (unsigned j = 0; j < wire[i].size(); j++) { - GEdge *ge = wire[i][j]; - OCCEdge *occe = dynamic_cast<OCCEdge*>(ge); - if (occe){ - wire_maker.Add(occe->getTopoDS_Edge()); - } - } - aGenerator.AddWire(wire_maker.Wire()); - } - aGenerator.CheckCompatibility(Standard_False); - aGenerator.Build(); - TopoDS_Solid result = TopoDS::Solid(aGenerator.Shape()); - GEntity *ret = gm->_occ_internals->addRegionToModel(gm, result); - return ret; -} - -void OCCFactory::healGeometry(GModel *gm, double tolerance) -{ - if (!gm->_occ_internals) - gm->_occ_internals = new OCC_Internals; - - if (tolerance < 0.) - tolerance = CTX::instance()->geom.tolerance; - if (!gm || !gm->_occ_internals) - return; - gm->_occ_internals->_healGeometry(tolerance, true, true, true, true, true, true); - gm->_occ_internals->buildLists(); - gm->_occ_internals->buildGModel(gm); -} - -#endif diff --git a/Geo/GModelFactory.h b/Geo/GModelFactory.h deleted file mode 100644 index a8e08221b53c9d9d6505f0af8c4cc81487e95cf0..0000000000000000000000000000000000000000 --- a/Geo/GModelFactory.h +++ /dev/null @@ -1,295 +0,0 @@ -// Gmsh - Copyright (C) 1997-2017 C. Geuzaine, J.-F. Remacle -// -// See the LICENSE.txt file for license information. Please report all -// bugs and problems to the public mailing list <gmsh@onelab.info>. - -#ifndef _GMODEL_FACTORY_H_ -#define _GMODEL_FACTORY_H_ - -#include <vector> -#include "GmshConfig.h" -#include "GmshMessage.h" - -class GEntity; -class GVertex; -class GEdge; -class GEdgeSigned; -class GFace; -class GRegion; -class GModel; -class SPoint3; - -// Abstract CAD creation factory. -class GModelFactory { - public: - GModelFactory(){} - virtual ~GModelFactory(){} - virtual std::string getName(){ return ""; } - // brep primitives - enum arcCreationMethod {THREE_POINTS=1, CENTER_START_END=2}; - enum splineType {BEZIER=1, BSPLINE=2}; - virtual GVertex *addVertex(GModel *gm, double x, double y, double z, double lc) = 0; - virtual GEdge *addLine(GModel *, GVertex *v1, GVertex *v2) = 0; - virtual GFace *addPlanarFace(GModel *gm, std::vector<std::vector<GEdge *> > edges) = 0; - virtual GFace *addPlanarFace(GModel *gm, const std::vector<std::vector<GEdgeSigned> > &edges) = 0; - virtual GRegion*addVolume(GModel *gm, std::vector<std::vector<GFace *> > faces) = 0; - virtual GEdge *addCircleArc(GModel *gm, GVertex *start, GVertex *center, GVertex *end) - { - Msg::Error("addCircleArc not implemented yet"); - return 0; - } - virtual GEdge *addCircleArc(GModel *gm, const arcCreationMethod &method, - GVertex *start, GVertex *end, - 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) - { - 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) - { - 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) - { - 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) - { - Msg::Error("addFace not implemented yet"); - return 0; - } - virtual GFace *add2Drect(GModel *gm,double x0, double y0, double dx, double dy) - { - Msg::Error("add2Drect not implemented yet"); - return 0; - } - virtual GFace *add2Dellips(GModel *gm,double xc, double yc, double rx, double ry) - { - Msg::Error("add2Dellips not implemented yet"); - return 0; - } - - // sweep stuff - virtual GEntity *revolve(GModel *gm, GEntity*, std::vector<double> p1, - 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) - { - Msg::Error("extrude not implemented yet"); - return 0; - } - virtual std::vector<GEntity*> extrudeBoundaryLayer(GModel *gm, GEntity *e, - int nbLayers, double hLayers, - int dir, int view) - { - Msg::Error("extrude normals not implemented yet"); - std::vector<GEntity*> empty; - return empty; - } - virtual GEntity *addPipe(GModel *gm, GEntity *base, std::vector<GEdge *> wire) - { - Msg::Error("addPipe not implemented yet"); - return 0; - } - virtual GEntity *addThruSections(GModel *gm, std::vector<std::vector<GEdge *> > wire) - { - Msg::Error("addThruSections not implemented yet"); - return 0; - } - - // solid primitives - virtual GEntity *addSphere(GModel *gm, double cx, double cy, double cz, - 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) - { - 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) - { - Msg::Error("addTorus not implemented yet"); - return 0; - } - virtual GEntity *addBlock(GModel *gm, std::vector<double> p1, - std::vector<double> p2) - { - Msg::Error("addBlock not implemented yet"); - return 0; - } - virtual GEntity *add3DBlock(GModel *gm, std::vector<double> p1, - double dx, double dy, double dz) - { - Msg::Error("add3DBlock not implemented yet"); - return 0; - } - virtual GEntity *addCone(GModel *gm, std::vector<double> p1, - std::vector<double> p2, double radius1, - 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) - { - Msg::Error("fillet not implemented yet"); - } - - // rigid body motions - 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) - { - Msg::Error("rotate not implemented yet"); - } - - // boolean operators acting on 2 GModels - 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) - { - Msg::Error("computeBooleanIntersection not implemented yet"); - return 0; - } - virtual GModel *computeBooleanDifference(GModel *obj, GModel*tool, - int createNewModel) - { - Msg::Error("computeBooleanDifference not implemented yet"); - return 0; - } - - virtual void setPeriodicAllFaces(GModel *gm, std::vector<double> FaceTranslationVector) - { - Msg::Error("findperiodic not implemented yet"); - } - virtual void setPeriodicPairOfFaces(GModel *gm, int numFaceMaster, - std::vector<int> EdgeListMaster, - int numFaceSlave, std::vector<int> EdgeListSlave) - { - Msg::Error("setPeriodicPairOfFaces not implemented yet"); - } - ; - virtual void healGeometry(GModel *gm, double tolerance = -1.) = 0; -}; - -class GeoFactory : public GModelFactory { - public: - GeoFactory(){} - std::string getName(){ return "GEO"; } - GVertex *addVertex(GModel *gm,double x, double y, double z, double lc); - GEdge *addLine(GModel *gm,GVertex *v1, GVertex *v2); - GFace *addPlanarFace(GModel *gm, std::vector<std::vector<GEdge *> > edges); - GFace *addPlanarFace(GModel *gm, const std::vector<std::vector<GEdgeSigned> > &edges); - GRegion *addVolume(GModel *gm, std::vector<std::vector<GFace *> > faces); - using GModelFactory::addCircleArc; - GEdge *addCircleArc(GModel *gm,GVertex *begin, GVertex *center, GVertex *end); - std::vector<GFace *> addRuledFaces(GModel *gm, std::vector<std::vector<GEdge *> > edges); - std::vector<GEntity*> extrudeBoundaryLayer(GModel *gm, GEntity *e, int nbLayers, - double hLayers, int dir, int view); - void healGeometry(GModel *gm, double tolerance = -1.); - -private: - GFace *_addPlanarFace(GModel *gm, const std::vector<std::vector<GEdgeSigned> > &edges, bool orientEdges); -}; - -#if defined(HAVE_OCC) - -class OCCFactory : public GModelFactory { - public: - OCCFactory(){} - std::string getName(){ return "OpenCASCADE"; } - GVertex *addVertex(GModel *gm,double x, double y, double z, double lc); - GEdge *addLine(GModel *gm,GVertex *v1, GVertex *v2); - 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 *addThruSections(GModel *gm, std::vector<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); - GFace *addPlanarFace(GModel *gm, std::vector<std::vector<GEdge *> > edges); - GFace *addPlanarFace(GModel *gm, const std::vector<std::vector<GEdgeSigned> > &edges); - GFace *add2Drect(GModel *gm,double x0, double y0, double dx, double dy); - GFace *add2Dellips(GModel *gm,double xc, double yc, double rx, double ry); - 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); - GEntity *addBlock(GModel *gm,std::vector<double> p1, std::vector<double> p2); - GEntity *add3DBlock(GModel *gm,std::vector<double> p1, double dx, double dy, double dz); - 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); - void dilate(GModel *gm, std::vector<double> p, std::vector<double> s, - 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 setPeriodicAllFaces(GModel *gm, std::vector<double> FaceTranslationVector); - void setPeriodicPairOfFaces(GModel *gm, int numFaceMaster, std::vector<int> EdgeListMaster, - int numFaceSlave, std::vector<int> EdgeListSlave); - void fillet(GModel *gm, std::vector<int> edges, double radius); - void healGeometry(GModel *gm, double tolerance = -1.); -}; - -#endif - -#endif diff --git a/Geo/GModelIO_OCC.cpp b/Geo/GModelIO_OCC.cpp index 16f5e4bf3c40089d17ec5e1dd5e5a9ff02d1b979..d4e5b41e72aa49caac18d6ecd6979120e11311e1 100644 --- a/Geo/GModelIO_OCC.cpp +++ b/Geo/GModelIO_OCC.cpp @@ -3636,461 +3636,6 @@ bool OCC_Internals::makeTorusSTL(double x, double y, double z, double r1, double return false; return true; } -/* -void dumpStepLabels(STEPControl_Reader reader) -{ - const Handle(XSControl_WorkSession) &theSession = reader.WS(); - const Handle(Interface_InterfaceModel) &theModel = theSession->Model(); - Standard_Integer nb = theModel->NbEntities(); - for(Standard_Integer i=1; i < ....) { - Handle(StepRepr_Representation) entity = - Handle(StepRepr_Representation)::DownCast(theModel->Value(i)); - if(entity.IsNull()){ - continue; - } - if(entity->Name().IsNull()){ - continue; - } - cout << Name()->ToCString(); - } -} - -void dumpIgesLabels(IGESControl_Reader reader) -{ - const Handle(XSControl_WorkSession) & theSession = reader.WS(); - const Handle(Interface_InterfaceModel) & theModel = theSession->Model(); - Standard_Integer nb = theModel->NbEntities(); - for(Standard_Integer i=1; i<...; i++){ - Handle(IGESData_IGESEntity) entity = - Handle(IGESData_IGESEntity)::DownCast(theModel->Value(i)); - if(entity.IsNull()){ - continue; - } - if(entity->HasName()){ - cout << NameValue()->String().ToCString(); - } - } -} -*/ - -// FIXME ***************** BEGIN WILL BE REMOVED ************************ - -void addSimpleShapes(TopoDS_Shape theShape, TopTools_ListOfShape &theList) -{ - if(theShape.ShapeType() != TopAbs_COMPOUND && - theShape.ShapeType() != TopAbs_COMPSOLID) { - theList.Append(theShape); - return; - } - - TopTools_MapOfShape mapShape; - TopoDS_Iterator It(theShape, Standard_True, Standard_True); - - for(; It.More(); It.Next()) { - TopoDS_Shape aShape_i = It.Value(); - if(mapShape.Add(aShape_i)) { - if(aShape_i.ShapeType() == TopAbs_COMPOUND || - aShape_i.ShapeType() == TopAbs_COMPSOLID) { - addSimpleShapes(aShape_i, theList); - } - else { - theList.Append(aShape_i); - } - } - } -} - -void OCC_Internals::buildLists() -{ - _somap.Clear(); - _shmap.Clear(); - _fmap.Clear(); - _wmap.Clear(); - _emap.Clear(); - _vmap.Clear(); - _addShapeToMaps(_shape); -} - -void OCC_Internals::buildShapeFromGModel(GModel* gm) -{ - _somap.Clear(); - _shmap.Clear(); - _fmap.Clear(); - _wmap.Clear(); - _emap.Clear(); - _vmap.Clear(); - for (GModel::riter it = gm->firstRegion(); it != gm->lastRegion() ; ++it){ - if ((*it)->getNativeType() == GEntity::OpenCascadeModel){ - OCCRegion *occ = static_cast<OCCRegion*> (*it); - if(occ) _addShapeToMaps(occ->getTopoDS_Shape()); - } - } - for (GModel::fiter it = gm->firstFace(); it != gm->lastFace() ; ++it){ - if ((*it)->getNativeType() == GEntity::OpenCascadeModel){ - OCCFace *occ = static_cast<OCCFace*> (*it); - if(occ) _addShapeToMaps(occ->getTopoDS_Face()); - } - } - BRep_Builder B; - TopoDS_Compound C; - B.MakeCompound(C); - for(int i = 1; i <= _vmap.Extent(); i++) B.Add(C, _vmap(i)); - for(int i = 1; i <= _emap.Extent(); i++) B.Add(C, _emap(i)); - for(int i = 1; i <= _wmap.Extent(); i++) B.Add(C, _wmap(i)); - for(int i = 1; i <= _fmap.Extent(); i++) B.Add(C, _fmap(i)); - for(int i = 1; i <= _shmap.Extent(); i++) B.Add(C, _shmap(i)); - for(int i = 1; i <= _somap.Extent(); i++) B.Add(C, _somap(i)); - _shape = C; -} - -void OCC_Internals::buildShapeFromLists(TopoDS_Shape shape) -{ - BRep_Builder B; - TopoDS_Compound C; - B.MakeCompound(C); - - TopTools_ListOfShape theList; - addSimpleShapes(shape, theList); - TopTools_ListIteratorOfListOfShape itSub1(theList); - for (; itSub1.More(); itSub1.Next()) B.Add(C, itSub1.Value()); - - for(int i = 1; i <= _vmap.Extent(); i++) B.Add(C, _vmap(i)); - for(int i = 1; i <= _emap.Extent(); i++) B.Add(C, _emap(i)); - for(int i = 1; i <= _wmap.Extent(); i++) B.Add(C, _wmap(i)); - for(int i = 1; i <= _fmap.Extent(); i++) B.Add(C, _fmap(i)); - for(int i = 1; i <= _shmap.Extent(); i++) B.Add(C, _shmap(i)); - for(int i = 1; i <= _somap.Extent(); i++) B.Add(C, _somap(i)); - _shape = C; -} - -GVertex *OCC_Internals::addVertexToModel(GModel *model, TopoDS_Vertex vertex) -{ - GVertex *gv = getVertexForOCCShape(model, vertex); - if(gv) return gv; - _addShapeToMaps(vertex); - buildShapeFromLists(vertex); - buildGModel(model); - return getVertexForOCCShape(model, vertex); -} - -GEdge *OCC_Internals::addEdgeToModel(GModel *model, TopoDS_Edge edge) -{ - GEdge *ge = getEdgeForOCCShape(model, edge); - if(ge) return ge; - _addShapeToMaps(edge); - buildShapeFromLists(edge); - buildGModel(model); - return getEdgeForOCCShape(model, edge); -} - -GFace* OCC_Internals::addFaceToModel(GModel *model, TopoDS_Face face) -{ - GFace *gf = getFaceForOCCShape(model, face); - if(gf) return gf; - _addShapeToMaps(face); - buildShapeFromLists(face); - buildGModel(model); - return getFaceForOCCShape(model, face); -} - -GRegion* OCC_Internals::addRegionToModel(GModel *model, TopoDS_Solid region) -{ - GRegion *gr = getRegionForOCCShape(model, region); - if(gr) return gr; - - // FIXME THE PREVIOUS IMPLEMENTATION WAS BETTER FOR SOME USERS :-) - buildShapeFromLists(region); - model->destroy(); - buildLists(); - buildGModel(model); - return getRegionForOCCShape(model, region); - // _addShapeToMaps(region); - // buildShapeFromLists(region); - // buildGModel(model); - // return getRegionForOCCShape(model, region); -} - -void OCC_Internals::buildGModel(GModel *model) -{ - // building geom vertices - int numv = model->getMaxElementaryNumber(0) + 1; - for(int i = 1; i <= _vmap.Extent(); i++){ - TopoDS_Vertex vertex = TopoDS::Vertex(_vmap(i)); - if(!getVertexForOCCShape(model, vertex)){ - model->add(new OCCVertex(model, numv, vertex)); - numv++; - } - } - - // building geom edges - int nume = model->getMaxElementaryNumber(1) + 1; - for(int i = 1; i <= _emap.Extent(); i++){ - int i1 = _vmap.FindIndex(TopExp::FirstVertex(TopoDS::Edge(_emap(i)))); - int i2 = _vmap.FindIndex(TopExp::LastVertex(TopoDS::Edge(_emap(i)))); - if(!getEdgeForOCCShape(model, TopoDS::Edge(_emap(i)))){ - GVertex *v1 = getVertexForOCCShape(model, TopoDS::Vertex(_vmap(i1))); - GVertex *v2 = getVertexForOCCShape(model, TopoDS::Vertex(_vmap(i2))); - model->add(new OCCEdge(model, TopoDS::Edge(_emap(i)), nume, v1, v2)); - nume++; - } - } - - // building geom faces - int numf = model->getMaxElementaryNumber(2) + 1; - for(int i = 1; i <= _fmap.Extent(); i++){ - if(!getFaceForOCCShape(model, TopoDS::Face(_fmap(i)))){ - model->add(new OCCFace(model, TopoDS::Face(_fmap(i)), numf)); - numf++; - } - } - - // building geom regions - int numr = model->getMaxElementaryNumber(3) + 1; - for(int i = 1; i <= _somap.Extent(); i++){ - if(!getRegionForOCCShape(model, TopoDS::Solid(_somap(i)))){ - model->add(new OCCRegion(model, TopoDS::Solid(_somap(i)), numr)); - numr++; - } - } -} - -void OCC_Internals::applyBooleanOperator(TopoDS_Shape tool, const BooleanOperator &op) -{ - if(tool.IsNull()) return; - if(_shape.IsNull()){ - _shape = tool; - return; - } - - switch(op){ - case OCC_Internals::Intersection : - { - TopoDS_Shape theNewShape; - BRep_Builder B; - TopoDS_Compound C; - B.MakeCompound(C); - TopTools_ListOfShape listShape1, listShape2; - addSimpleShapes(_shape, listShape1); - addSimpleShapes(tool, listShape2); - Standard_Boolean isCompound = - (listShape1.Extent() > 1 || listShape2.Extent() > 1); - - TopTools_ListIteratorOfListOfShape itSub1(listShape1); - for(; itSub1.More(); itSub1.Next()) { - TopoDS_Shape aValue1 = itSub1.Value(); - TopTools_ListIteratorOfListOfShape itSub2(listShape2); - for(; itSub2.More(); itSub2.Next()) { - TopoDS_Shape aValue2 = itSub2.Value(); - BRepAlgoAPI_Common BO(aValue1, aValue2); - if(!BO.IsDone()) { - Msg::Error("Boolean Intersection Operator can not be performed"); - } - if(isCompound) { - TopoDS_Shape aStepResult = BO.Shape(); - if(aStepResult.ShapeType() == TopAbs_COMPOUND) { - TopoDS_Iterator aCompIter(aStepResult); - for(; aCompIter.More(); aCompIter.Next()) { - B.Add(C, aCompIter.Value()); - } - } - else { - B.Add(C, aStepResult); - } - } - else - theNewShape = BO.Shape(); - } - } - if(isCompound) { - TopTools_ListOfShape listShapeC; - addSimpleShapes(C, listShapeC); - TopTools_ListIteratorOfListOfShape itSubC(listShapeC); - //bool isOnlySolids = true; - for(; itSubC.More(); itSubC.Next()) { - TopoDS_Shape aValueC = itSubC.Value(); - //if(aValueC.ShapeType() != TopAbs_SOLID) isOnlySolids = false; - } - // if(isOnlySolids) - // theNewShape = GlueFaces(C, Precision::Confusion()); - // else - theNewShape = C; - } - _shape = theNewShape; - } - break; - case OCC_Internals::Difference : - { - TopoDS_Shape theNewShape; - BRep_Builder B; - TopoDS_Compound C; - B.MakeCompound(C); - - TopTools_ListOfShape listShapes, listTools; - addSimpleShapes(_shape, listShapes); - addSimpleShapes(tool, listTools); - - Standard_Boolean isCompound = (listShapes.Extent() > 1); - - TopTools_ListIteratorOfListOfShape itSub1(listShapes); - for(; itSub1.More(); itSub1.Next()) { - TopoDS_Shape aCut = itSub1.Value(); - // tools - TopTools_ListIteratorOfListOfShape itSub2(listTools); - for(; itSub2.More(); itSub2.Next()) { - TopoDS_Shape aTool = itSub2.Value(); - BRepAlgoAPI_Cut BO(aCut, aTool); - if(!BO.IsDone()) { - Msg::Error("Cut operation can not be performed on the given shapes"); - return; - } - aCut = BO.Shape(); - } - if(isCompound) { - if(aCut.ShapeType() == TopAbs_COMPOUND) { - TopoDS_Iterator aCompIter(aCut); - for(; aCompIter.More(); aCompIter.Next()) { - B.Add(C, aCompIter.Value()); - } - } - else { - B.Add(C, aCut); - } - } - else - theNewShape = aCut; - } - - if(isCompound) { - TopTools_ListOfShape listShapeC; - addSimpleShapes(C, listShapeC); - TopTools_ListIteratorOfListOfShape itSubC(listShapeC); - //bool isOnlySolids = true; - for(; itSubC.More(); itSubC.Next()) { - TopoDS_Shape aValueC = itSubC.Value(); - //if(aValueC.ShapeType() != TopAbs_SOLID) isOnlySolids = false; - } - // if(isOnlySolids) - // theNewShape = GlueFaces(C, Precision::Confusion()); - // else - theNewShape = C; - } - _shape = theNewShape; - } - break; - case OCC_Internals::Union : - { - TopoDS_Solid solid1, solid2; - int hack = 0; - if(_shape.ShapeType() != TopAbs_SOLID && tool.ShapeType() != TopAbs_SOLID){ - TopExp_Explorer exp0; - for(exp0.Init(_shape, TopAbs_SOLID); exp0.More(); exp0.Next()){ - solid1 = TopoDS::Solid(exp0.Current()); - hack++; - break; - } - for(exp0.Init(tool, TopAbs_SOLID); exp0.More(); exp0.Next()){ - solid2 = TopoDS::Solid(exp0.Current()); - hack++; - break; - } - } - if(hack == 2){ // FIXME: just a temp hack! - Msg::Info("Temporary hack in Fuse :-)"); - BRepAlgoAPI_Fuse BO(solid1, solid2); - if(!BO.IsDone()) { - Msg::Error("Fuse operation can not be performed on the given shapes"); - } - _shape = BO.Shape(); - } - else{ - BRepAlgoAPI_Fuse BO(tool, _shape); - if(!BO.IsDone()) { - Msg::Error("Fuse operation can not be performed on the given shapes"); - } - _shape = BO.Shape(); - } - } - break; - case OCC_Internals::Section : - { - TopoDS_Shape theNewShape; - BRep_Builder B; - TopoDS_Compound C; - B.MakeCompound(C); - - TopTools_ListOfShape listShapes, listTools; - addSimpleShapes(_shape, listShapes); - addSimpleShapes(tool, listTools); - - Standard_Boolean isCompound = (listShapes.Extent() > 1); - TopTools_ListIteratorOfListOfShape itSub1(listShapes); - for(; itSub1.More(); itSub1.Next()) { - TopoDS_Shape aValue1 = itSub1.Value(); - TopTools_ListIteratorOfListOfShape itSub2(listTools); - for(; itSub2.More(); itSub2.Next()) { - TopoDS_Shape aValue2 = itSub2.Value(); - BRepAlgoAPI_Section BO(aValue1, aValue2, Standard_False); - BO.Approximation(Standard_True); - BO.Build(); - if(!BO.IsDone()) { - Msg::Error("Section operation can not be performed on the given shapes"); - return; - } - if(isCompound) { - TopoDS_Shape aStepResult = BO.Shape(); - if(aStepResult.ShapeType() == TopAbs_COMPOUND) { - TopoDS_Iterator aCompIter(aStepResult); - for(; aCompIter.More(); aCompIter.Next()) { - B.Add(C, aCompIter.Value()); - } - } - else { - B.Add(C, aStepResult); - } - } - else - theNewShape = BO.Shape(); - } - } - if(isCompound) - theNewShape = C; - _shape = theNewShape; - } - break; - default : - Msg::Error("Requested boolean operation not implemented"); - break; - } -} - -void OCC_Internals::fillet(std::vector<TopoDS_Edge> &edgesToFillet, - double Radius) -{ - // create a tool for fillet - BRepFilletAPI_MakeFillet fill(_shape); - for(unsigned int i = 0; i < edgesToFillet.size(); ++i){ - fill.Add(edgesToFillet[i]); - } - for(int i = 1; i <= fill.NbContours(); i++){ - fill.SetRadius(Radius, i, 1); - } - fill.Build(); - if(!fill.IsDone()) { - Msg::Error("Fillet can't be computed on the given shape with the given radius"); - return; - } - _shape = fill.Shape(); - - if(_shape.IsNull()) return; - - // Check shape validity - BRepCheck_Analyzer ana(_shape, false); - if(!ana.IsValid()) { - Msg::Error("Fillet algorithm have produced an invalid shape result"); - } -} - -// FIXME ***************** END OF WILL BE REMOVED ************************ #endif diff --git a/Geo/GModelIO_OCC.h b/Geo/GModelIO_OCC.h index 3cd210082c06fa33359f022a9af9dc77496f99ff..ced922d2515ae4b9d70d2638808f0208c07bd9d0 100644 --- a/Geo/GModelIO_OCC.h +++ b/Geo/GModelIO_OCC.h @@ -365,36 +365,6 @@ class OCC_Internals { bool makeTorusSTL(double x, double y, double z, double r1, double r2, double angle, std::vector<SPoint3> &vertices, std::vector<SVector3> &normals, std::vector<int> &triangles); - - // *** FIXME what follows will be removed *** - private: - TopoDS_Shape _shape; - public: - void _addShapeToLists(TopoDS_Shape shape){ _addShapeToMaps(shape); } - void _healGeometry(double tolerance, bool fixdegenerated, - bool fixsmalledges, bool fixspotstripfaces, bool sewfaces, - bool makesolids=false, double scaling=0.0) - { - _healShape(_shape, tolerance, fixdegenerated, fixsmalledges, - fixspotstripfaces, sewfaces, makesolids, scaling); - } - void applyBooleanOperator(TopoDS_Shape tool, const BooleanOperator &op); - TopoDS_Shape getShape () { return _shape; } - void buildLists(); - void buildShapeFromLists(TopoDS_Shape shape); - void fillet(std::vector<TopoDS_Edge> &shapes, double radius); - void buildShapeFromGModel(GModel*); - void buildGModel(GModel *gm); - void loadShape(const TopoDS_Shape *s) - { - std::vector<std::pair<int, int> > outDimTags; - importShapes(s, false, outDimTags); - } - GVertex *addVertexToModel(GModel *model, TopoDS_Vertex v); - GEdge *addEdgeToModel(GModel *model, TopoDS_Edge e); - GFace *addFaceToModel(GModel *model, TopoDS_Face f); - GRegion *addRegionToModel(GModel *model, TopoDS_Solid r); - // *** FIXME end of stuff that will be removed *** }; #else diff --git a/Parser/Gmsh.tab.cpp b/Parser/Gmsh.tab.cpp index 27a6c52f61f6181431ebf71ecb63846d551e187e..9b03c85bc7e617f39fd853b01eb7e7bfdf55ebca 100644 --- a/Parser/Gmsh.tab.cpp +++ b/Parser/Gmsh.tab.cpp @@ -1438,45 +1438,45 @@ static const yytype_uint16 yyrline[] = 2067, 2093, 2110, 2126, 2144, 2162, 2192, 2222, 2221, 2251, 2253, 2255, 2257, 2259, 2267, 2269, 2271, 2273, 2281, 2283, 2285, 2293, 2295, 2297, 2299, 2309, 2325, 2341, 2357, 2373, - 2389, 2426, 2448, 2472, 2473, 2478, 2481, 2485, 2506, 2525, - 2546, 2561, 2577, 2595, 2646, 2667, 2689, 2712, 2817, 2833, - 2868, 2890, 2912, 2918, 2933, 2961, 2973, 2982, 2989, 3001, - 3020, 3026, 3032, 3039, 3046, 3053, 3065, 3138, 3156, 3173, - 3188, 3221, 3233, 3257, 3261, 3266, 3273, 3278, 3288, 3293, - 3299, 3307, 3311, 3315, 3324, 3388, 3404, 3421, 3438, 3460, - 3482, 3517, 3525, 3533, 3539, 3546, 3553, 3573, 3599, 3611, - 3622, 3640, 3658, 3677, 3676, 3701, 3700, 3727, 3726, 3751, - 3750, 3773, 3789, 3806, 3823, 3846, 3849, 3855, 3867, 3887, - 3891, 3895, 3899, 3903, 3907, 3911, 3915, 3924, 3937, 3938, - 3939, 3940, 3941, 3945, 3946, 3947, 3948, 3949, 3952, 3976, - 3995, 4018, 4021, 4037, 4040, 4057, 4060, 4066, 4069, 4076, - 4079, 4086, 4103, 4144, 4188, 4227, 4252, 4261, 4291, 4317, - 4343, 4375, 4402, 4428, 4454, 4480, 4506, 4528, 4539, 4587, - 4636, 4648, 4659, 4666, 4681, 4695, 4696, 4697, 4701, 4707, - 4719, 4737, 4765, 4766, 4767, 4768, 4769, 4770, 4771, 4772, - 4773, 4780, 4781, 4782, 4783, 4784, 4785, 4786, 4787, 4788, - 4789, 4790, 4791, 4792, 4793, 4794, 4795, 4796, 4797, 4798, - 4799, 4800, 4801, 4802, 4803, 4804, 4805, 4806, 4807, 4808, - 4809, 4810, 4811, 4812, 4813, 4814, 4815, 4816, 4817, 4826, - 4827, 4828, 4829, 4830, 4831, 4832, 4833, 4834, 4835, 4836, - 4841, 4840, 4848, 4850, 4855, 4860, 4864, 4869, 4874, 4878, - 4882, 4886, 4890, 4894, 4898, 4904, 4920, 4925, 4931, 4937, - 4956, 4977, 5010, 5014, 5019, 5023, 5027, 5031, 5036, 5041, - 5051, 5061, 5066, 5077, 5086, 5091, 5096, 5124, 5125, 5131, - 5132, 5138, 5137, 5160, 5162, 5167, 5176, 5178, 5184, 5185, - 5190, 5194, 5198, 5202, 5206, 5213, 5217, 5221, 5225, 5232, - 5237, 5244, 5249, 5253, 5258, 5262, 5270, 5281, 5285, 5297, - 5305, 5313, 5320, 5330, 5353, 5359, 5370, 5376, 5381, 5391, - 5401, 5411, 5423, 5427, 5432, 5444, 5448, 5452, 5456, 5474, - 5482, 5490, 5519, 5529, 5545, 5556, 5561, 5565, 5569, 5581, - 5585, 5597, 5614, 5624, 5628, 5643, 5648, 5655, 5659, 5664, - 5678, 5694, 5698, 5702, 5706, 5710, 5718, 5724, 5730, 5736, - 5745, 5749, 5753, 5761, 5767, 5773, 5777, 5785, 5793, 5800, - 5809, 5813, 5817, 5832, 5846, 5860, 5872, 5888, 5897, 5906, - 5916, 5927, 5935, 5943, 5947, 5966, 5973, 5979, 5986, 5994, - 5993, 6003, 6027, 6029, 6035, 6040, 6042, 6047, 6052, 6057, - 6059, 6063, 6075, 6089, 6093, 6100, 6108, 6116, 6127, 6129, - 6132 + 2389, 2439, 2461, 2485, 2486, 2491, 2494, 2498, 2519, 2538, + 2559, 2574, 2590, 2608, 2659, 2680, 2702, 2725, 2830, 2846, + 2881, 2903, 2925, 2931, 2946, 2974, 2986, 2995, 3002, 3014, + 3033, 3039, 3045, 3052, 3059, 3066, 3078, 3151, 3169, 3186, + 3201, 3234, 3246, 3270, 3274, 3279, 3286, 3291, 3301, 3306, + 3312, 3320, 3324, 3328, 3337, 3401, 3417, 3434, 3451, 3473, + 3495, 3530, 3538, 3546, 3552, 3559, 3566, 3586, 3612, 3624, + 3635, 3653, 3671, 3690, 3689, 3714, 3713, 3740, 3739, 3764, + 3763, 3786, 3802, 3819, 3836, 3859, 3862, 3868, 3880, 3900, + 3904, 3908, 3912, 3916, 3920, 3924, 3928, 3937, 3950, 3951, + 3952, 3953, 3954, 3958, 3959, 3960, 3961, 3962, 3965, 3989, + 4008, 4031, 4034, 4050, 4053, 4070, 4073, 4079, 4082, 4089, + 4092, 4099, 4116, 4157, 4201, 4240, 4265, 4274, 4304, 4330, + 4356, 4388, 4415, 4441, 4467, 4493, 4519, 4541, 4552, 4600, + 4649, 4661, 4672, 4679, 4694, 4708, 4709, 4710, 4714, 4720, + 4732, 4750, 4778, 4779, 4780, 4781, 4782, 4783, 4784, 4785, + 4786, 4793, 4794, 4795, 4796, 4797, 4798, 4799, 4800, 4801, + 4802, 4803, 4804, 4805, 4806, 4807, 4808, 4809, 4810, 4811, + 4812, 4813, 4814, 4815, 4816, 4817, 4818, 4819, 4820, 4821, + 4822, 4823, 4824, 4825, 4826, 4827, 4828, 4829, 4830, 4839, + 4840, 4841, 4842, 4843, 4844, 4845, 4846, 4847, 4848, 4849, + 4854, 4853, 4861, 4863, 4868, 4873, 4877, 4882, 4887, 4891, + 4895, 4899, 4903, 4907, 4911, 4917, 4933, 4938, 4944, 4950, + 4969, 4990, 5023, 5027, 5032, 5036, 5040, 5044, 5049, 5054, + 5064, 5074, 5079, 5090, 5099, 5104, 5109, 5137, 5138, 5144, + 5145, 5151, 5150, 5173, 5175, 5180, 5189, 5191, 5197, 5198, + 5203, 5207, 5211, 5215, 5219, 5226, 5230, 5234, 5238, 5245, + 5250, 5257, 5262, 5266, 5271, 5275, 5283, 5294, 5298, 5310, + 5318, 5326, 5333, 5343, 5366, 5372, 5383, 5389, 5394, 5404, + 5414, 5424, 5436, 5440, 5445, 5457, 5461, 5465, 5469, 5487, + 5495, 5503, 5532, 5542, 5558, 5569, 5574, 5578, 5582, 5594, + 5598, 5610, 5627, 5637, 5641, 5656, 5661, 5668, 5672, 5677, + 5691, 5707, 5711, 5715, 5719, 5723, 5731, 5737, 5743, 5749, + 5758, 5762, 5766, 5774, 5780, 5786, 5790, 5798, 5806, 5813, + 5822, 5826, 5830, 5845, 5859, 5873, 5885, 5901, 5910, 5919, + 5929, 5940, 5948, 5956, 5960, 5979, 5986, 5992, 5999, 6007, + 6006, 6016, 6040, 6042, 6048, 6053, 6055, 6060, 6065, 6070, + 6072, 6076, 6088, 6102, 6106, 6113, 6121, 6129, 6140, 6142, + 6145 }; #endif @@ -8769,6 +8769,19 @@ yyreduce: (inDimTags, outDimTags, action == "CombinedBoundary", true, action == "PointsOf"); } + else if(action == "DontSaveMesh"){ + // boundary operations are performed directly on GModel, which enables + // to compute the boundary of hybrid CAD models; this also automatically + // binds all boundary entities for OCC models + if(GModel::current()->getOCCInternals() && + GModel::current()->getOCCInternals()->getChanged()) + GModel::current()->getOCCInternals()->synchronize(GModel::current()); + if(GModel::current()->getGEOInternals()->getChanged()) + GModel::current()->getGEOInternals()->synchronize(GModel::current()); + r = GModel::current()->getBoundaryTags + (inDimTags, outDimTags, action == "CombinedBoundary", true, + action == "PointsOf"); + } else{ yymsg(0, "Unknown action on multiple shapes '%s'", (yyvsp[(1) - (4)].c)); } @@ -8779,7 +8792,7 @@ yyreduce: break; case 211: -#line 2427 "Gmsh.y" +#line 2440 "Gmsh.y" { (yyval.l) = List_Create(2, 1, sizeof(Shape)); bool r = true; @@ -8803,7 +8816,7 @@ yyreduce: break; case 212: -#line 2449 "Gmsh.y" +#line 2462 "Gmsh.y" { (yyval.l) = List_Create(2, 1, sizeof(Shape)); bool r = true; @@ -8827,31 +8840,31 @@ yyreduce: break; case 213: -#line 2472 "Gmsh.y" +#line 2485 "Gmsh.y" { (yyval.l) = (yyvsp[(1) - (1)].l); ;} break; case 214: -#line 2473 "Gmsh.y" +#line 2486 "Gmsh.y" { (yyval.l) = (yyvsp[(1) - (1)].l); ;} break; case 215: -#line 2478 "Gmsh.y" +#line 2491 "Gmsh.y" { (yyval.l) = List_Create(3, 3, sizeof(Shape)); ;} break; case 216: -#line 2482 "Gmsh.y" +#line 2495 "Gmsh.y" { List_Add((yyval.l), &(yyvsp[(2) - (2)].s)); ;} break; case 217: -#line 2486 "Gmsh.y" +#line 2499 "Gmsh.y" { for(int i = 0; i < List_Nbr((yyvsp[(4) - (6)].l)); i++){ double d; @@ -8870,7 +8883,7 @@ yyreduce: break; case 218: -#line 2507 "Gmsh.y" +#line 2520 "Gmsh.y" { if(List_Nbr((yyvsp[(7) - (8)].l)) == 4){ int t = (int)(yyvsp[(4) - (8)].d); @@ -8892,7 +8905,7 @@ yyreduce: break; case 219: -#line 2526 "Gmsh.y" +#line 2539 "Gmsh.y" { int t = (int)(yyvsp[(4) - (10)].d); if(gLevelset::find(t)){ @@ -8916,7 +8929,7 @@ yyreduce: break; case 220: -#line 2548 "Gmsh.y" +#line 2561 "Gmsh.y" { int t = (int)(yyvsp[(4) - (14)].d); if(gLevelset::find(t)){ @@ -8933,7 +8946,7 @@ yyreduce: break; case 221: -#line 2563 "Gmsh.y" +#line 2576 "Gmsh.y" { int t = (int)(yyvsp[(4) - (16)].d); if(gLevelset::find(t)){ @@ -8951,7 +8964,7 @@ yyreduce: break; case 222: -#line 2578 "Gmsh.y" +#line 2591 "Gmsh.y" { if(List_Nbr((yyvsp[(10) - (12)].l)) == 1){ int t = (int)(yyvsp[(4) - (12)].d); @@ -8972,7 +8985,7 @@ yyreduce: break; case 223: -#line 2597 "Gmsh.y" +#line 2610 "Gmsh.y" { if(List_Nbr((yyvsp[(12) - (14)].l)) == 1){ int t = (int)(yyvsp[(4) - (14)].d); @@ -9025,7 +9038,7 @@ yyreduce: break; case 224: -#line 2648 "Gmsh.y" +#line 2661 "Gmsh.y" { if(List_Nbr((yyvsp[(12) - (14)].l)) == 1){ int t = (int)(yyvsp[(4) - (14)].d); @@ -9048,7 +9061,7 @@ yyreduce: break; case 225: -#line 2669 "Gmsh.y" +#line 2682 "Gmsh.y" { if(List_Nbr((yyvsp[(12) - (14)].l)) == 3){ int t = (int)(yyvsp[(4) - (14)].d); @@ -9072,7 +9085,7 @@ yyreduce: break; case 226: -#line 2691 "Gmsh.y" +#line 2704 "Gmsh.y" { if(List_Nbr((yyvsp[(12) - (14)].l)) == 5){ int t = (int)(yyvsp[(4) - (14)].d); @@ -9097,7 +9110,7 @@ yyreduce: break; case 227: -#line 2713 "Gmsh.y" +#line 2726 "Gmsh.y" { if(!strcmp((yyvsp[(2) - (8)].c), "Union")){ int t = (int)(yyvsp[(4) - (8)].d); @@ -9205,7 +9218,7 @@ yyreduce: break; case 228: -#line 2818 "Gmsh.y" +#line 2831 "Gmsh.y" { if(!strcmp((yyvsp[(2) - (8)].c), "MathEval")){ int t = (int)(yyvsp[(4) - (8)].d); @@ -9224,7 +9237,7 @@ yyreduce: break; case 229: -#line 2834 "Gmsh.y" +#line 2847 "Gmsh.y" { if(!strcmp((yyvsp[(2) - (6)].c), "CutMesh")){ int t = (int)(yyvsp[(4) - (6)].d); @@ -9257,7 +9270,7 @@ yyreduce: break; case 230: -#line 2869 "Gmsh.y" +#line 2882 "Gmsh.y" { std::vector<std::pair<int, int> > dimTags; ListOfShapes2VectorOfPairs((yyvsp[(3) - (4)].l), dimTags); @@ -9282,7 +9295,7 @@ yyreduce: break; case 231: -#line 2891 "Gmsh.y" +#line 2904 "Gmsh.y" { std::vector<std::pair<int, int> > dimTags; ListOfShapes2VectorOfPairs((yyvsp[(4) - (5)].l), dimTags); @@ -9307,7 +9320,7 @@ yyreduce: break; case 232: -#line 2913 "Gmsh.y" +#line 2926 "Gmsh.y" { #if defined(HAVE_MESH) GModel::current()->getFields()->deleteField((int)(yyvsp[(4) - (6)].d)); @@ -9316,7 +9329,7 @@ yyreduce: break; case 233: -#line 2919 "Gmsh.y" +#line 2932 "Gmsh.y" { #if defined(HAVE_POST) if(!strcmp((yyvsp[(2) - (6)].c), "View")){ @@ -9334,7 +9347,7 @@ yyreduce: break; case 234: -#line 2934 "Gmsh.y" +#line 2947 "Gmsh.y" { if(!strcmp((yyvsp[(2) - (3)].c), "Meshes") || !strcmp((yyvsp[(2) - (3)].c), "All")){ ClearProject(); @@ -9365,7 +9378,7 @@ yyreduce: break; case 235: -#line 2962 "Gmsh.y" +#line 2975 "Gmsh.y" { #if defined(HAVE_POST) if(!strcmp((yyvsp[(2) - (4)].c), "Empty") && !strcmp((yyvsp[(3) - (4)].c), "Views")){ @@ -9380,14 +9393,14 @@ yyreduce: break; case 236: -#line 2974 "Gmsh.y" +#line 2987 "Gmsh.y" { gmsh_yynamespaces.clear(); ;} break; case 237: -#line 2983 "Gmsh.y" +#line 2996 "Gmsh.y" { std::vector<std::pair<int, int> > dimTags; ListOfShapes2VectorOfPairs((yyvsp[(4) - (5)].l), dimTags); @@ -9397,7 +9410,7 @@ yyreduce: break; case 238: -#line 2990 "Gmsh.y" +#line 3003 "Gmsh.y" { std::vector<std::pair<int, int> > dimTags; ListOfShapes2VectorOfPairs((yyvsp[(5) - (6)].l), dimTags); @@ -9407,7 +9420,7 @@ yyreduce: break; case 239: -#line 3002 "Gmsh.y" +#line 3015 "Gmsh.y" { std::vector<std::pair<int, int> > dimTags; ListOfShapes2VectorOfPairs((yyvsp[(4) - (5)].l), dimTags); @@ -9424,7 +9437,7 @@ yyreduce: break; case 240: -#line 3021 "Gmsh.y" +#line 3034 "Gmsh.y" { std::string what = (yyvsp[(2) - (3)].c); setVisibility(-1, 1, false); @@ -9433,7 +9446,7 @@ yyreduce: break; case 241: -#line 3027 "Gmsh.y" +#line 3040 "Gmsh.y" { std::string what = (yyvsp[(2) - (3)].c); setVisibility(-1, 0, false); @@ -9442,7 +9455,7 @@ yyreduce: break; case 242: -#line 3033 "Gmsh.y" +#line 3046 "Gmsh.y" { std::vector<std::pair<int, int> > dimTags; ListOfShapes2VectorOfPairs((yyvsp[(3) - (4)].l), dimTags); @@ -9452,7 +9465,7 @@ yyreduce: break; case 243: -#line 3040 "Gmsh.y" +#line 3053 "Gmsh.y" { std::vector<std::pair<int, int> > dimTags; ListOfShapes2VectorOfPairs((yyvsp[(4) - (5)].l), dimTags); @@ -9462,7 +9475,7 @@ yyreduce: break; case 244: -#line 3047 "Gmsh.y" +#line 3060 "Gmsh.y" { std::vector<std::pair<int, int> > dimTags; ListOfShapes2VectorOfPairs((yyvsp[(3) - (4)].l), dimTags); @@ -9472,7 +9485,7 @@ yyreduce: break; case 245: -#line 3054 "Gmsh.y" +#line 3067 "Gmsh.y" { std::vector<std::pair<int, int> > dimTags; ListOfShapes2VectorOfPairs((yyvsp[(4) - (5)].l), dimTags); @@ -9482,7 +9495,7 @@ yyreduce: break; case 246: -#line 3066 "Gmsh.y" +#line 3079 "Gmsh.y" { if(!strcmp((yyvsp[(1) - (3)].c), "Include")){ std::string tmp = FixRelativePath(gmsh_yyname, (yyvsp[(2) - (3)].c)); @@ -9558,7 +9571,7 @@ yyreduce: break; case 247: -#line 3139 "Gmsh.y" +#line 3152 "Gmsh.y" { int n = List_Nbr((yyvsp[(3) - (5)].l)); if(n == 1){ @@ -9579,7 +9592,7 @@ yyreduce: break; case 248: -#line 3157 "Gmsh.y" +#line 3170 "Gmsh.y" { #if defined(HAVE_POST) if(!strcmp((yyvsp[(1) - (7)].c), "Save") && !strcmp((yyvsp[(2) - (7)].c), "View")){ @@ -9599,7 +9612,7 @@ yyreduce: break; case 249: -#line 3174 "Gmsh.y" +#line 3187 "Gmsh.y" { #if defined(HAVE_POST) && defined(HAVE_MESH) if(!strcmp((yyvsp[(1) - (7)].c), "Background") && !strcmp((yyvsp[(2) - (7)].c), "Mesh") && !strcmp((yyvsp[(3) - (7)].c), "View")){ @@ -9617,7 +9630,7 @@ yyreduce: break; case 250: -#line 3189 "Gmsh.y" +#line 3202 "Gmsh.y" { if(!strcmp((yyvsp[(1) - (3)].c), "Sleep")){ SleepInSeconds((yyvsp[(2) - (3)].d)); @@ -9653,7 +9666,7 @@ yyreduce: break; case 251: -#line 3222 "Gmsh.y" +#line 3235 "Gmsh.y" { #if defined(HAVE_PLUGINS) try { @@ -9668,7 +9681,7 @@ yyreduce: break; case 252: -#line 3234 "Gmsh.y" +#line 3247 "Gmsh.y" { #if defined(HAVE_POST) if(!strcmp((yyvsp[(2) - (3)].c), "ElementsFromAllViews")) @@ -9695,14 +9708,14 @@ yyreduce: break; case 253: -#line 3258 "Gmsh.y" +#line 3271 "Gmsh.y" { Msg::Exit(0); ;} break; case 254: -#line 3262 "Gmsh.y" +#line 3275 "Gmsh.y" { gmsh_yyerrorstate = 999; // this will be checked when yyparse returns YYABORT; @@ -9710,7 +9723,7 @@ yyreduce: break; case 255: -#line 3267 "Gmsh.y" +#line 3280 "Gmsh.y" { // force sync if(GModel::current()->getOCCInternals()) @@ -9720,7 +9733,7 @@ yyreduce: break; case 256: -#line 3274 "Gmsh.y" +#line 3287 "Gmsh.y" { new GModel(); GModel::current(GModel::list.size() - 1); @@ -9728,7 +9741,7 @@ yyreduce: break; case 257: -#line 3279 "Gmsh.y" +#line 3292 "Gmsh.y" { CTX::instance()->forcedBBox = 0; if(GModel::current()->getOCCInternals() && @@ -9741,7 +9754,7 @@ yyreduce: break; case 258: -#line 3289 "Gmsh.y" +#line 3302 "Gmsh.y" { CTX::instance()->forcedBBox = 1; SetBoundingBox((yyvsp[(3) - (15)].d), (yyvsp[(5) - (15)].d), (yyvsp[(7) - (15)].d), (yyvsp[(9) - (15)].d), (yyvsp[(11) - (15)].d), (yyvsp[(13) - (15)].d)); @@ -9749,7 +9762,7 @@ yyreduce: break; case 259: -#line 3294 "Gmsh.y" +#line 3307 "Gmsh.y" { #if defined(HAVE_OPENGL) drawContext::global()->draw(); @@ -9758,7 +9771,7 @@ yyreduce: break; case 260: -#line 3300 "Gmsh.y" +#line 3313 "Gmsh.y" { #if defined(HAVE_OPENGL) CTX::instance()->mesh.changed = ENT_ALL; @@ -9769,21 +9782,21 @@ yyreduce: break; case 261: -#line 3308 "Gmsh.y" +#line 3321 "Gmsh.y" { GModel::current()->createTopologyFromMesh(); ;} break; case 262: -#line 3312 "Gmsh.y" +#line 3325 "Gmsh.y" { GModel::current()->createTopologyFromMesh(1); ;} break; case 263: -#line 3316 "Gmsh.y" +#line 3329 "Gmsh.y" { if(GModel::current()->getOCCInternals() && GModel::current()->getOCCInternals()->getChanged()) @@ -9795,7 +9808,7 @@ yyreduce: break; case 264: -#line 3326 "Gmsh.y" +#line 3339 "Gmsh.y" { int lock = CTX::instance()->lock; CTX::instance()->lock = 0; @@ -9856,7 +9869,7 @@ yyreduce: break; case 265: -#line 3389 "Gmsh.y" +#line 3402 "Gmsh.y" { #if defined(HAVE_POPPLER) std::vector<int> is; @@ -9871,7 +9884,7 @@ yyreduce: break; case 266: -#line 3405 "Gmsh.y" +#line 3418 "Gmsh.y" { LoopControlVariablesTab[ImbricatedLoop][0] = (yyvsp[(3) - (6)].d); LoopControlVariablesTab[ImbricatedLoop][1] = (yyvsp[(5) - (6)].d); @@ -9891,7 +9904,7 @@ yyreduce: break; case 267: -#line 3422 "Gmsh.y" +#line 3435 "Gmsh.y" { LoopControlVariablesTab[ImbricatedLoop][0] = (yyvsp[(3) - (8)].d); LoopControlVariablesTab[ImbricatedLoop][1] = (yyvsp[(5) - (8)].d); @@ -9911,7 +9924,7 @@ yyreduce: break; case 268: -#line 3439 "Gmsh.y" +#line 3452 "Gmsh.y" { LoopControlVariablesTab[ImbricatedLoop][0] = (yyvsp[(5) - (8)].d); LoopControlVariablesTab[ImbricatedLoop][1] = (yyvsp[(7) - (8)].d); @@ -9936,7 +9949,7 @@ yyreduce: break; case 269: -#line 3461 "Gmsh.y" +#line 3474 "Gmsh.y" { LoopControlVariablesTab[ImbricatedLoop][0] = (yyvsp[(5) - (10)].d); LoopControlVariablesTab[ImbricatedLoop][1] = (yyvsp[(7) - (10)].d); @@ -9961,7 +9974,7 @@ yyreduce: break; case 270: -#line 3483 "Gmsh.y" +#line 3496 "Gmsh.y" { if(ImbricatedLoop <= 0){ yymsg(0, "Invalid For/EndFor loop"); @@ -9999,7 +10012,7 @@ yyreduce: break; case 271: -#line 3518 "Gmsh.y" +#line 3531 "Gmsh.y" { if(!FunctionManager::Instance()->createFunction (std::string((yyvsp[(2) - (2)].c)), gmsh_yyin, gmsh_yyname, gmsh_yylineno)) @@ -10010,7 +10023,7 @@ yyreduce: break; case 272: -#line 3526 "Gmsh.y" +#line 3539 "Gmsh.y" { if(!FunctionManager::Instance()->createFunction (std::string((yyvsp[(2) - (2)].c)), gmsh_yyin, gmsh_yyname, gmsh_yylineno)) @@ -10021,7 +10034,7 @@ yyreduce: break; case 273: -#line 3534 "Gmsh.y" +#line 3547 "Gmsh.y" { if(!FunctionManager::Instance()->leaveFunction (&gmsh_yyin, gmsh_yyname, gmsh_yylineno)) @@ -10030,7 +10043,7 @@ yyreduce: break; case 274: -#line 3540 "Gmsh.y" +#line 3553 "Gmsh.y" { if(!FunctionManager::Instance()->enterFunction (std::string((yyvsp[(2) - (3)].c)), &gmsh_yyin, gmsh_yyname, gmsh_yylineno)) @@ -10040,7 +10053,7 @@ yyreduce: break; case 275: -#line 3547 "Gmsh.y" +#line 3560 "Gmsh.y" { if(!FunctionManager::Instance()->enterFunction (std::string((yyvsp[(2) - (3)].c)), &gmsh_yyin, gmsh_yyname, gmsh_yylineno)) @@ -10050,7 +10063,7 @@ yyreduce: break; case 276: -#line 3554 "Gmsh.y" +#line 3567 "Gmsh.y" { ImbricatedTest++; if(ImbricatedTest > MAX_RECUR_TESTS-1){ @@ -10073,7 +10086,7 @@ yyreduce: break; case 277: -#line 3574 "Gmsh.y" +#line 3587 "Gmsh.y" { if(ImbricatedTest > 0){ if (statusImbricatedTests[ImbricatedTest]){ @@ -10102,7 +10115,7 @@ yyreduce: break; case 278: -#line 3600 "Gmsh.y" +#line 3613 "Gmsh.y" { if(ImbricatedTest > 0){ if(statusImbricatedTests[ImbricatedTest]){ @@ -10117,7 +10130,7 @@ yyreduce: break; case 279: -#line 3612 "Gmsh.y" +#line 3625 "Gmsh.y" { ImbricatedTest--; if(ImbricatedTest < 0) @@ -10126,7 +10139,7 @@ yyreduce: break; case 280: -#line 3623 "Gmsh.y" +#line 3636 "Gmsh.y" { std::vector<std::pair<int, int> > inDimTags, outDimTags; ListOfShapes2VectorOfPairs((yyvsp[(4) - (5)].l), inDimTags); @@ -10147,7 +10160,7 @@ yyreduce: break; case 281: -#line 3641 "Gmsh.y" +#line 3654 "Gmsh.y" { std::vector<std::pair<int, int> > inDimTags, outDimTags; ListOfShapes2VectorOfPairs((yyvsp[(10) - (11)].l), inDimTags); @@ -10168,7 +10181,7 @@ yyreduce: break; case 282: -#line 3659 "Gmsh.y" +#line 3672 "Gmsh.y" { std::vector<std::pair<int, int> > inDimTags, outDimTags; ListOfShapes2VectorOfPairs((yyvsp[(12) - (13)].l), inDimTags); @@ -10189,7 +10202,7 @@ yyreduce: break; case 283: -#line 3677 "Gmsh.y" +#line 3690 "Gmsh.y" { extr.mesh.ExtrudeMesh = extr.mesh.Recombine = false; extr.mesh.QuadToTri = NO_QUADTRI; @@ -10198,7 +10211,7 @@ yyreduce: break; case 284: -#line 3683 "Gmsh.y" +#line 3696 "Gmsh.y" { std::vector<std::pair<int, int> > inDimTags, outDimTags; ListOfShapes2VectorOfPairs((yyvsp[(4) - (7)].l), inDimTags); @@ -10219,7 +10232,7 @@ yyreduce: break; case 285: -#line 3701 "Gmsh.y" +#line 3714 "Gmsh.y" { extr.mesh.ExtrudeMesh = extr.mesh.Recombine = false; extr.mesh.QuadToTri = NO_QUADTRI; @@ -10228,7 +10241,7 @@ yyreduce: break; case 286: -#line 3707 "Gmsh.y" +#line 3720 "Gmsh.y" { std::vector<std::pair<int, int> > inDimTags, outDimTags; ListOfShapes2VectorOfPairs((yyvsp[(10) - (13)].l), inDimTags); @@ -10251,7 +10264,7 @@ yyreduce: break; case 287: -#line 3727 "Gmsh.y" +#line 3740 "Gmsh.y" { extr.mesh.ExtrudeMesh = extr.mesh.Recombine = false; extr.mesh.QuadToTri = NO_QUADTRI; @@ -10260,7 +10273,7 @@ yyreduce: break; case 288: -#line 3733 "Gmsh.y" +#line 3746 "Gmsh.y" { std::vector<std::pair<int, int> > inDimTags, outDimTags; ListOfShapes2VectorOfPairs((yyvsp[(12) - (15)].l), inDimTags); @@ -10281,7 +10294,7 @@ yyreduce: break; case 289: -#line 3751 "Gmsh.y" +#line 3764 "Gmsh.y" { extr.mesh.ExtrudeMesh = extr.mesh.Recombine = false; extr.mesh.QuadToTri = NO_QUADTRI; @@ -10290,7 +10303,7 @@ yyreduce: break; case 290: -#line 3757 "Gmsh.y" +#line 3770 "Gmsh.y" { std::vector<std::pair<int, int> > inDimTags, outDimTags; ListOfShapes2VectorOfPairs((yyvsp[(3) - (6)].l), inDimTags); @@ -10310,7 +10323,7 @@ yyreduce: break; case 291: -#line 3774 "Gmsh.y" +#line 3787 "Gmsh.y" { std::vector<std::pair<int, int> > inDimTags, outDimTags; ListOfShapes2VectorOfPairs((yyvsp[(3) - (9)].l), inDimTags); @@ -10329,7 +10342,7 @@ yyreduce: break; case 292: -#line 3790 "Gmsh.y" +#line 3803 "Gmsh.y" { (yyval.l) = List_Create(2, 1, sizeof(Shape)); bool r = true; @@ -10349,7 +10362,7 @@ yyreduce: break; case 293: -#line 3807 "Gmsh.y" +#line 3820 "Gmsh.y" { (yyval.l) = List_Create(2, 1, sizeof(Shape)); bool r = true; @@ -10369,7 +10382,7 @@ yyreduce: break; case 294: -#line 3824 "Gmsh.y" +#line 3837 "Gmsh.y" { (yyval.l) = List_Create(2, 1, sizeof(Shape)); bool r = true; @@ -10392,19 +10405,19 @@ yyreduce: break; case 295: -#line 3847 "Gmsh.y" +#line 3860 "Gmsh.y" { ;} break; case 296: -#line 3850 "Gmsh.y" +#line 3863 "Gmsh.y" { ;} break; case 297: -#line 3856 "Gmsh.y" +#line 3869 "Gmsh.y" { int n = (int)fabs((yyvsp[(3) - (5)].d)); if(n){ // we accept n==0 to easily disable layers @@ -10419,7 +10432,7 @@ yyreduce: break; case 298: -#line 3868 "Gmsh.y" +#line 3881 "Gmsh.y" { extr.mesh.ExtrudeMesh = true; extr.mesh.NbLayer = List_Nbr((yyvsp[(3) - (7)].l)); @@ -10442,56 +10455,56 @@ yyreduce: break; case 299: -#line 3888 "Gmsh.y" +#line 3901 "Gmsh.y" { extr.mesh.ScaleLast = true; ;} break; case 300: -#line 3892 "Gmsh.y" +#line 3905 "Gmsh.y" { extr.mesh.Recombine = true; ;} break; case 301: -#line 3896 "Gmsh.y" +#line 3909 "Gmsh.y" { extr.mesh.Recombine = (yyvsp[(2) - (3)].d) ? true : false; ;} break; case 302: -#line 3900 "Gmsh.y" +#line 3913 "Gmsh.y" { extr.mesh.QuadToTri = QUADTRI_ADDVERTS_1; ;} break; case 303: -#line 3904 "Gmsh.y" +#line 3917 "Gmsh.y" { extr.mesh.QuadToTri = QUADTRI_ADDVERTS_1_RECOMB; ;} break; case 304: -#line 3908 "Gmsh.y" +#line 3921 "Gmsh.y" { extr.mesh.QuadToTri = QUADTRI_NOVERTS_1; ;} break; case 305: -#line 3912 "Gmsh.y" +#line 3925 "Gmsh.y" { extr.mesh.QuadToTri = QUADTRI_NOVERTS_1_RECOMB; ;} break; case 306: -#line 3916 "Gmsh.y" +#line 3929 "Gmsh.y" { std::vector<int> tags; ListOfDouble2Vector((yyvsp[(6) - (9)].l), tags); int num = (int)(yyvsp[(3) - (9)].d); @@ -10503,7 +10516,7 @@ yyreduce: break; case 307: -#line 3925 "Gmsh.y" +#line 3938 "Gmsh.y" { if(!strcmp((yyvsp[(2) - (6)].c), "Index")) extr.mesh.BoundaryLayerIndex = (yyvsp[(4) - (6)].d); @@ -10514,57 +10527,57 @@ yyreduce: break; case 308: -#line 3937 "Gmsh.y" +#line 3950 "Gmsh.y" { (yyval.i) = OCC_Internals::Union; ;} break; case 309: -#line 3938 "Gmsh.y" +#line 3951 "Gmsh.y" { (yyval.i) = OCC_Internals::Intersection; ;} break; case 310: -#line 3939 "Gmsh.y" +#line 3952 "Gmsh.y" { (yyval.i) = OCC_Internals::Difference; ;} break; case 311: -#line 3940 "Gmsh.y" +#line 3953 "Gmsh.y" { (yyval.i) = OCC_Internals::Section; ;} break; case 312: -#line 3941 "Gmsh.y" +#line 3954 "Gmsh.y" { (yyval.i) = OCC_Internals::Fragments; ;} break; case 313: -#line 3945 "Gmsh.y" +#line 3958 "Gmsh.y" { (yyval.i) = 0; ;} break; case 314: -#line 3946 "Gmsh.y" +#line 3959 "Gmsh.y" { (yyval.i) = 1; ;} break; case 315: -#line 3947 "Gmsh.y" +#line 3960 "Gmsh.y" { (yyval.i) = 2; ;} break; case 316: -#line 3948 "Gmsh.y" +#line 3961 "Gmsh.y" { (yyval.i) = (yyvsp[(2) - (3)].d) ? 1 : 0; ;} break; case 317: -#line 3949 "Gmsh.y" +#line 3962 "Gmsh.y" { (yyval.i) = (yyvsp[(3) - (4)].d) ? 2 : 0; ;} break; case 318: -#line 3954 "Gmsh.y" +#line 3967 "Gmsh.y" { (yyval.l) = List_Create(2, 1, sizeof(Shape)); bool r = true; @@ -10590,7 +10603,7 @@ yyreduce: break; case 319: -#line 3977 "Gmsh.y" +#line 3990 "Gmsh.y" { (yyval.l) = List_Create(2, 1, sizeof(Shape)); bool r = true; @@ -10609,7 +10622,7 @@ yyreduce: break; case 320: -#line 3997 "Gmsh.y" +#line 4010 "Gmsh.y" { bool r = true; if(gmsh_yyfactory == "OpenCASCADE" && GModel::current()->getOCCInternals()){ @@ -10630,14 +10643,14 @@ yyreduce: break; case 321: -#line 4018 "Gmsh.y" +#line 4031 "Gmsh.y" { (yyval.v)[0] = (yyval.v)[1] = 1.; ;} break; case 322: -#line 4022 "Gmsh.y" +#line 4035 "Gmsh.y" { if(!strcmp((yyvsp[(2) - (3)].c), "Progression") || !strcmp((yyvsp[(2) - (3)].c), "Power")) (yyval.v)[0] = 1.; @@ -10653,14 +10666,14 @@ yyreduce: break; case 323: -#line 4037 "Gmsh.y" +#line 4050 "Gmsh.y" { (yyval.i) = -1; // left ;} break; case 324: -#line 4041 "Gmsh.y" +#line 4054 "Gmsh.y" { if(!strcmp((yyvsp[(1) - (1)].c), "Right")) (yyval.i) = 1; @@ -10677,49 +10690,49 @@ yyreduce: break; case 325: -#line 4057 "Gmsh.y" +#line 4070 "Gmsh.y" { (yyval.l) = List_Create(1, 1, sizeof(double)); ;} break; case 326: -#line 4061 "Gmsh.y" +#line 4074 "Gmsh.y" { (yyval.l) = (yyvsp[(2) - (2)].l); ;} break; case 327: -#line 4066 "Gmsh.y" +#line 4079 "Gmsh.y" { (yyval.i) = 45; ;} break; case 328: -#line 4070 "Gmsh.y" +#line 4083 "Gmsh.y" { (yyval.i) = (int)(yyvsp[(2) - (2)].d); ;} break; case 329: -#line 4076 "Gmsh.y" +#line 4089 "Gmsh.y" { (yyval.l) = List_Create(1, 1, sizeof(double)); ;} break; case 330: -#line 4080 "Gmsh.y" +#line 4093 "Gmsh.y" { (yyval.l) = (yyvsp[(2) - (2)].l); ;} break; case 331: -#line 4087 "Gmsh.y" +#line 4100 "Gmsh.y" { // mesh sizes at vertices are stored in internal CAD data, as they can be // specified during vertex creation and copied around during CAD @@ -10739,7 +10752,7 @@ yyreduce: break; case 332: -#line 4104 "Gmsh.y" +#line 4117 "Gmsh.y" { // transfinite constraints are stored in GEO internals in addition to // GModel, as they can be copied around during GEO operations @@ -10783,7 +10796,7 @@ yyreduce: break; case 333: -#line 4145 "Gmsh.y" +#line 4158 "Gmsh.y" { // transfinite constraints are stored in GEO internals in addition to // GModel, as they can be copied around during GEO operations @@ -10830,7 +10843,7 @@ yyreduce: break; case 334: -#line 4189 "Gmsh.y" +#line 4202 "Gmsh.y" { // transfinite constraints are stored in GEO internals in addition to // GModel, as they can be copied around during GEO operations @@ -10872,7 +10885,7 @@ yyreduce: break; case 335: -#line 4228 "Gmsh.y" +#line 4241 "Gmsh.y" { // transfinite constraints are stored in GEO internals in addition to // GModel, as they can be copied around during GEO operations @@ -10900,7 +10913,7 @@ yyreduce: break; case 336: -#line 4253 "Gmsh.y" +#line 4266 "Gmsh.y" { for(int i = 0; i < List_Nbr((yyvsp[(4) - (8)].l)); i++){ double d; @@ -10912,7 +10925,7 @@ yyreduce: break; case 337: -#line 4262 "Gmsh.y" +#line 4275 "Gmsh.y" { // recombine constraints are stored in GEO internals in addition to // GModel, as they can be copied around during GEO operations @@ -10945,7 +10958,7 @@ yyreduce: break; case 338: -#line 4292 "Gmsh.y" +#line 4305 "Gmsh.y" { // recombine constraints are stored in GEO internals in addition to // GModel, as they can be copied around during GEO operations @@ -10974,7 +10987,7 @@ yyreduce: break; case 339: -#line 4318 "Gmsh.y" +#line 4331 "Gmsh.y" { // smoothing constraints are stored in GEO internals in addition to // GModel, as they can be copied around during GEO operations @@ -11003,7 +11016,7 @@ yyreduce: break; case 340: -#line 4345 "Gmsh.y" +#line 4358 "Gmsh.y" { if (List_Nbr((yyvsp[(4) - (11)].l)) != List_Nbr((yyvsp[(8) - (11)].l))){ yymsg(0, "Number of master lines (%d) different from number of " @@ -11037,7 +11050,7 @@ yyreduce: break; case 341: -#line 4377 "Gmsh.y" +#line 4390 "Gmsh.y" { if (List_Nbr((yyvsp[(4) - (11)].l)) != List_Nbr((yyvsp[(8) - (11)].l))){ yymsg(0, "Number of master faces (%d) different from number of " @@ -11066,7 +11079,7 @@ yyreduce: break; case 342: -#line 4404 "Gmsh.y" +#line 4417 "Gmsh.y" { if (List_Nbr((yyvsp[(4) - (18)].l)) != List_Nbr((yyvsp[(8) - (18)].l))){ yymsg(0, "Number of master edges (%d) different from number of " @@ -11094,7 +11107,7 @@ yyreduce: break; case 343: -#line 4430 "Gmsh.y" +#line 4443 "Gmsh.y" { if (List_Nbr((yyvsp[(4) - (18)].l)) != List_Nbr((yyvsp[(8) - (18)].l))){ yymsg(0, "Number of master faces (%d) different from number of " @@ -11122,7 +11135,7 @@ yyreduce: break; case 344: -#line 4456 "Gmsh.y" +#line 4469 "Gmsh.y" { if (List_Nbr((yyvsp[(4) - (12)].l)) != List_Nbr((yyvsp[(8) - (12)].l))){ yymsg(0, "Number of master edges (%d) different from number of " @@ -11150,7 +11163,7 @@ yyreduce: break; case 345: -#line 4482 "Gmsh.y" +#line 4495 "Gmsh.y" { if (List_Nbr((yyvsp[(4) - (12)].l)) != List_Nbr((yyvsp[(8) - (12)].l))){ yymsg(0, "Number of master faces (%d) different from number of " @@ -11178,7 +11191,7 @@ yyreduce: break; case 346: -#line 4508 "Gmsh.y" +#line 4521 "Gmsh.y" { if (List_Nbr((yyvsp[(5) - (12)].l)) != List_Nbr((yyvsp[(10) - (12)].l))){ yymsg(0, "Number of master surface edges (%d) different from number of " @@ -11202,7 +11215,7 @@ yyreduce: break; case 347: -#line 4529 "Gmsh.y" +#line 4542 "Gmsh.y" { if (((yyvsp[(6) - (10)].i)==2 || (yyvsp[(6) - (10)].i)==3) && (yyvsp[(1) - (10)].i)<(yyvsp[(6) - (10)].i) ) { std::vector<int> tags; ListOfDouble2Vector((yyvsp[(3) - (10)].l), tags); @@ -11216,7 +11229,7 @@ yyreduce: break; case 348: -#line 4540 "Gmsh.y" +#line 4553 "Gmsh.y" { // reverse mesh constraints are stored in GEO internals in addition to // GModel, as they can be copied around during GEO operations @@ -11267,7 +11280,7 @@ yyreduce: break; case 349: -#line 4588 "Gmsh.y" +#line 4601 "Gmsh.y" { if(!(yyvsp[(3) - (4)].l)){ switch ((yyvsp[(2) - (4)].i)) { @@ -11319,7 +11332,7 @@ yyreduce: break; case 350: -#line 4637 "Gmsh.y" +#line 4650 "Gmsh.y" { for(int i = 0; i < List_Nbr((yyvsp[(3) - (4)].l)); i++){ double dnum; @@ -11334,7 +11347,7 @@ yyreduce: break; case 351: -#line 4649 "Gmsh.y" +#line 4662 "Gmsh.y" { std::vector<int> tags; ListOfDouble2Vector((yyvsp[(3) - (4)].l), tags); GModel::current()->getGEOInternals()->setCompoundMesh((yyvsp[(2) - (4)].i), tags); @@ -11343,7 +11356,7 @@ yyreduce: break; case 352: -#line 4660 "Gmsh.y" +#line 4673 "Gmsh.y" { if(gmsh_yyfactory == "OpenCASCADE" && GModel::current()->getOCCInternals()) GModel::current()->getOCCInternals()->removeAllDuplicates(); @@ -11353,7 +11366,7 @@ yyreduce: break; case 353: -#line 4667 "Gmsh.y" +#line 4680 "Gmsh.y" { if(!strcmp((yyvsp[(2) - (3)].c), "Geometry")){ if(gmsh_yyfactory == "OpenCASCADE" && GModel::current()->getOCCInternals()) @@ -11371,7 +11384,7 @@ yyreduce: break; case 354: -#line 4682 "Gmsh.y" +#line 4695 "Gmsh.y" { std::vector<int> tags; ListOfDouble2Vector((yyvsp[(4) - (6)].l), tags); if(gmsh_yyfactory == "OpenCASCADE" && GModel::current()->getOCCInternals()) @@ -11383,22 +11396,22 @@ yyreduce: break; case 355: -#line 4695 "Gmsh.y" +#line 4708 "Gmsh.y" { (yyval.c) = (char*)"Homology"; ;} break; case 356: -#line 4696 "Gmsh.y" +#line 4709 "Gmsh.y" { (yyval.c) = (char*)"Cohomology"; ;} break; case 357: -#line 4697 "Gmsh.y" +#line 4710 "Gmsh.y" { (yyval.c) = (char*)"Betti"; ;} break; case 358: -#line 4702 "Gmsh.y" +#line 4715 "Gmsh.y" { std::vector<int> domain, subdomain, dim; for(int i = 0; i < 4; i++) dim.push_back(i); @@ -11407,7 +11420,7 @@ yyreduce: break; case 359: -#line 4708 "Gmsh.y" +#line 4721 "Gmsh.y" { std::vector<int> domain, subdomain, dim; for(int i = 0; i < List_Nbr((yyvsp[(3) - (5)].l)); i++){ @@ -11422,7 +11435,7 @@ yyreduce: break; case 360: -#line 4720 "Gmsh.y" +#line 4733 "Gmsh.y" { std::vector<int> domain, subdomain, dim; for(int i = 0; i < List_Nbr((yyvsp[(3) - (7)].l)); i++){ @@ -11443,7 +11456,7 @@ yyreduce: break; case 361: -#line 4738 "Gmsh.y" +#line 4751 "Gmsh.y" { std::vector<int> domain, subdomain, dim; for(int i = 0; i < List_Nbr((yyvsp[(6) - (10)].l)); i++){ @@ -11469,47 +11482,47 @@ yyreduce: break; case 362: -#line 4765 "Gmsh.y" +#line 4778 "Gmsh.y" { (yyval.d) = (yyvsp[(1) - (1)].d); ;} break; case 363: -#line 4766 "Gmsh.y" +#line 4779 "Gmsh.y" { (yyval.d) = (yyvsp[(2) - (3)].d); ;} break; case 364: -#line 4767 "Gmsh.y" +#line 4780 "Gmsh.y" { (yyval.d) = -(yyvsp[(2) - (2)].d); ;} break; case 365: -#line 4768 "Gmsh.y" +#line 4781 "Gmsh.y" { (yyval.d) = (yyvsp[(2) - (2)].d); ;} break; case 366: -#line 4769 "Gmsh.y" +#line 4782 "Gmsh.y" { (yyval.d) = !(yyvsp[(2) - (2)].d); ;} break; case 367: -#line 4770 "Gmsh.y" +#line 4783 "Gmsh.y" { (yyval.d) = (yyvsp[(1) - (3)].d) - (yyvsp[(3) - (3)].d); ;} break; case 368: -#line 4771 "Gmsh.y" +#line 4784 "Gmsh.y" { (yyval.d) = (yyvsp[(1) - (3)].d) + (yyvsp[(3) - (3)].d); ;} break; case 369: -#line 4772 "Gmsh.y" +#line 4785 "Gmsh.y" { (yyval.d) = (yyvsp[(1) - (3)].d) * (yyvsp[(3) - (3)].d); ;} break; case 370: -#line 4774 "Gmsh.y" +#line 4787 "Gmsh.y" { if(!(yyvsp[(3) - (3)].d)) yymsg(0, "Division by zero in '%g / %g'", (yyvsp[(1) - (3)].d), (yyvsp[(3) - (3)].d)); @@ -11519,257 +11532,257 @@ yyreduce: break; case 371: -#line 4780 "Gmsh.y" +#line 4793 "Gmsh.y" { (yyval.d) = (int)(yyvsp[(1) - (3)].d) | (int)(yyvsp[(3) - (3)].d); ;} break; case 372: -#line 4781 "Gmsh.y" +#line 4794 "Gmsh.y" { (yyval.d) = (int)(yyvsp[(1) - (3)].d) & (int)(yyvsp[(3) - (3)].d); ;} break; case 373: -#line 4782 "Gmsh.y" +#line 4795 "Gmsh.y" { (yyval.d) = (int)(yyvsp[(1) - (3)].d) % (int)(yyvsp[(3) - (3)].d); ;} break; case 374: -#line 4783 "Gmsh.y" +#line 4796 "Gmsh.y" { (yyval.d) = pow((yyvsp[(1) - (3)].d), (yyvsp[(3) - (3)].d)); ;} break; case 375: -#line 4784 "Gmsh.y" +#line 4797 "Gmsh.y" { (yyval.d) = (yyvsp[(1) - (3)].d) < (yyvsp[(3) - (3)].d); ;} break; case 376: -#line 4785 "Gmsh.y" +#line 4798 "Gmsh.y" { (yyval.d) = (yyvsp[(1) - (3)].d) > (yyvsp[(3) - (3)].d); ;} break; case 377: -#line 4786 "Gmsh.y" +#line 4799 "Gmsh.y" { (yyval.d) = (yyvsp[(1) - (3)].d) <= (yyvsp[(3) - (3)].d); ;} break; case 378: -#line 4787 "Gmsh.y" +#line 4800 "Gmsh.y" { (yyval.d) = (yyvsp[(1) - (3)].d) >= (yyvsp[(3) - (3)].d); ;} break; case 379: -#line 4788 "Gmsh.y" +#line 4801 "Gmsh.y" { (yyval.d) = (yyvsp[(1) - (3)].d) == (yyvsp[(3) - (3)].d); ;} break; case 380: -#line 4789 "Gmsh.y" +#line 4802 "Gmsh.y" { (yyval.d) = (yyvsp[(1) - (3)].d) != (yyvsp[(3) - (3)].d); ;} break; case 381: -#line 4790 "Gmsh.y" +#line 4803 "Gmsh.y" { (yyval.d) = (yyvsp[(1) - (3)].d) && (yyvsp[(3) - (3)].d); ;} break; case 382: -#line 4791 "Gmsh.y" +#line 4804 "Gmsh.y" { (yyval.d) = (yyvsp[(1) - (3)].d) || (yyvsp[(3) - (3)].d); ;} break; case 383: -#line 4792 "Gmsh.y" +#line 4805 "Gmsh.y" { (yyval.d) = ((int)(yyvsp[(1) - (3)].d) >> (int)(yyvsp[(3) - (3)].d)); ;} break; case 384: -#line 4793 "Gmsh.y" +#line 4806 "Gmsh.y" { (yyval.d) = ((int)(yyvsp[(1) - (3)].d) << (int)(yyvsp[(3) - (3)].d)); ;} break; case 385: -#line 4794 "Gmsh.y" +#line 4807 "Gmsh.y" { (yyval.d) = (yyvsp[(1) - (5)].d) ? (yyvsp[(3) - (5)].d) : (yyvsp[(5) - (5)].d); ;} break; case 386: -#line 4795 "Gmsh.y" +#line 4808 "Gmsh.y" { (yyval.d) = exp((yyvsp[(3) - (4)].d)); ;} break; case 387: -#line 4796 "Gmsh.y" +#line 4809 "Gmsh.y" { (yyval.d) = log((yyvsp[(3) - (4)].d)); ;} break; case 388: -#line 4797 "Gmsh.y" +#line 4810 "Gmsh.y" { (yyval.d) = log10((yyvsp[(3) - (4)].d)); ;} break; case 389: -#line 4798 "Gmsh.y" +#line 4811 "Gmsh.y" { (yyval.d) = sqrt((yyvsp[(3) - (4)].d)); ;} break; case 390: -#line 4799 "Gmsh.y" +#line 4812 "Gmsh.y" { (yyval.d) = sin((yyvsp[(3) - (4)].d)); ;} break; case 391: -#line 4800 "Gmsh.y" +#line 4813 "Gmsh.y" { (yyval.d) = asin((yyvsp[(3) - (4)].d)); ;} break; case 392: -#line 4801 "Gmsh.y" +#line 4814 "Gmsh.y" { (yyval.d) = cos((yyvsp[(3) - (4)].d)); ;} break; case 393: -#line 4802 "Gmsh.y" +#line 4815 "Gmsh.y" { (yyval.d) = acos((yyvsp[(3) - (4)].d)); ;} break; case 394: -#line 4803 "Gmsh.y" +#line 4816 "Gmsh.y" { (yyval.d) = tan((yyvsp[(3) - (4)].d)); ;} break; case 395: -#line 4804 "Gmsh.y" +#line 4817 "Gmsh.y" { (yyval.d) = atan((yyvsp[(3) - (4)].d)); ;} break; case 396: -#line 4805 "Gmsh.y" +#line 4818 "Gmsh.y" { (yyval.d) = atan2((yyvsp[(3) - (6)].d), (yyvsp[(5) - (6)].d));;} break; case 397: -#line 4806 "Gmsh.y" +#line 4819 "Gmsh.y" { (yyval.d) = sinh((yyvsp[(3) - (4)].d)); ;} break; case 398: -#line 4807 "Gmsh.y" +#line 4820 "Gmsh.y" { (yyval.d) = cosh((yyvsp[(3) - (4)].d)); ;} break; case 399: -#line 4808 "Gmsh.y" +#line 4821 "Gmsh.y" { (yyval.d) = tanh((yyvsp[(3) - (4)].d)); ;} break; case 400: -#line 4809 "Gmsh.y" +#line 4822 "Gmsh.y" { (yyval.d) = fabs((yyvsp[(3) - (4)].d)); ;} break; case 401: -#line 4810 "Gmsh.y" +#line 4823 "Gmsh.y" { (yyval.d) = std::abs((yyvsp[(3) - (4)].d)); ;} break; case 402: -#line 4811 "Gmsh.y" +#line 4824 "Gmsh.y" { (yyval.d) = floor((yyvsp[(3) - (4)].d)); ;} break; case 403: -#line 4812 "Gmsh.y" +#line 4825 "Gmsh.y" { (yyval.d) = ceil((yyvsp[(3) - (4)].d)); ;} break; case 404: -#line 4813 "Gmsh.y" +#line 4826 "Gmsh.y" { (yyval.d) = floor((yyvsp[(3) - (4)].d) + 0.5); ;} break; case 405: -#line 4814 "Gmsh.y" +#line 4827 "Gmsh.y" { (yyval.d) = fmod((yyvsp[(3) - (6)].d), (yyvsp[(5) - (6)].d)); ;} break; case 406: -#line 4815 "Gmsh.y" +#line 4828 "Gmsh.y" { (yyval.d) = fmod((yyvsp[(3) - (6)].d), (yyvsp[(5) - (6)].d)); ;} break; case 407: -#line 4816 "Gmsh.y" +#line 4829 "Gmsh.y" { (yyval.d) = sqrt((yyvsp[(3) - (6)].d) * (yyvsp[(3) - (6)].d) + (yyvsp[(5) - (6)].d) * (yyvsp[(5) - (6)].d)); ;} break; case 408: -#line 4817 "Gmsh.y" +#line 4830 "Gmsh.y" { (yyval.d) = (yyvsp[(3) - (4)].d) * (double)rand() / (double)RAND_MAX; ;} break; case 409: -#line 4826 "Gmsh.y" +#line 4839 "Gmsh.y" { (yyval.d) = (yyvsp[(1) - (1)].d); ;} break; case 410: -#line 4827 "Gmsh.y" +#line 4840 "Gmsh.y" { (yyval.d) = 3.141592653589793; ;} break; case 411: -#line 4828 "Gmsh.y" +#line 4841 "Gmsh.y" { (yyval.d) = (double)ImbricatedTest; ;} break; case 412: -#line 4829 "Gmsh.y" +#line 4842 "Gmsh.y" { (yyval.d) = Msg::GetCommRank(); ;} break; case 413: -#line 4830 "Gmsh.y" +#line 4843 "Gmsh.y" { (yyval.d) = Msg::GetCommSize(); ;} break; case 414: -#line 4831 "Gmsh.y" +#line 4844 "Gmsh.y" { (yyval.d) = GetGmshMajorVersion(); ;} break; case 415: -#line 4832 "Gmsh.y" +#line 4845 "Gmsh.y" { (yyval.d) = GetGmshMinorVersion(); ;} break; case 416: -#line 4833 "Gmsh.y" +#line 4846 "Gmsh.y" { (yyval.d) = GetGmshPatchVersion(); ;} break; case 417: -#line 4834 "Gmsh.y" +#line 4847 "Gmsh.y" { (yyval.d) = Cpu(); ;} break; case 418: -#line 4835 "Gmsh.y" +#line 4848 "Gmsh.y" { (yyval.d) = GetMemoryUsage()/1024./1024.; ;} break; case 419: -#line 4836 "Gmsh.y" +#line 4849 "Gmsh.y" { (yyval.d) = TotalRam(); ;} break; case 420: -#line 4841 "Gmsh.y" +#line 4854 "Gmsh.y" { init_options(); ;} break; case 421: -#line 4843 "Gmsh.y" +#line 4856 "Gmsh.y" { std::vector<double> val(1, (yyvsp[(3) - (6)].d)); Msg::ExchangeOnelabParameter("", val, floatOptions, charOptions); @@ -11778,12 +11791,12 @@ yyreduce: break; case 422: -#line 4849 "Gmsh.y" +#line 4862 "Gmsh.y" { (yyval.d) = (yyvsp[(1) - (1)].d); ;} break; case 423: -#line 4851 "Gmsh.y" +#line 4864 "Gmsh.y" { (yyval.d) = Msg::GetOnelabNumber((yyvsp[(3) - (4)].c)); Free((yyvsp[(3) - (4)].c)); @@ -11791,7 +11804,7 @@ yyreduce: break; case 424: -#line 4856 "Gmsh.y" +#line 4869 "Gmsh.y" { (yyval.d) = Msg::GetOnelabNumber((yyvsp[(3) - (6)].c), (yyvsp[(5) - (6)].d)); Free((yyvsp[(3) - (6)].c)); @@ -11799,70 +11812,70 @@ yyreduce: break; case 425: -#line 4861 "Gmsh.y" +#line 4874 "Gmsh.y" { (yyval.d) = treat_Struct_FullName_Float((yyvsp[(1) - (1)].c2).char1, (yyvsp[(1) - (1)].c2).char2); ;} break; case 426: -#line 4866 "Gmsh.y" +#line 4879 "Gmsh.y" { (yyval.d) = treat_Struct_FullName_Float(NULL, (yyvsp[(1) - (4)].c), 2, (int)(yyvsp[(3) - (4)].d)); ;} break; case 427: -#line 4871 "Gmsh.y" +#line 4884 "Gmsh.y" { (yyval.d) = treat_Struct_FullName_Float(NULL, (yyvsp[(1) - (4)].c), 2, (int)(yyvsp[(3) - (4)].d)); ;} break; case 428: -#line 4875 "Gmsh.y" +#line 4888 "Gmsh.y" { (yyval.d) = treat_Struct_FullName_Float((yyvsp[(3) - (4)].c2).char1, (yyvsp[(3) - (4)].c2).char2, 1, 0, 0., 1); ;} break; case 429: -#line 4879 "Gmsh.y" +#line 4892 "Gmsh.y" { (yyval.d) = treat_Struct_FullName_dot_tSTRING_Float((yyvsp[(3) - (6)].c2).char1, (yyvsp[(3) - (6)].c2).char2, (yyvsp[(5) - (6)].c), 0, 0., 1); ;} break; case 430: -#line 4883 "Gmsh.y" +#line 4896 "Gmsh.y" { (yyval.d) = treat_Struct_FullName_Float((yyvsp[(3) - (5)].c2).char1, (yyvsp[(3) - (5)].c2).char2, 1, 0, (yyvsp[(4) - (5)].d), 2); ;} break; case 431: -#line 4887 "Gmsh.y" +#line 4900 "Gmsh.y" { (yyval.d) = treat_Struct_FullName_dot_tSTRING_Float((yyvsp[(3) - (7)].c2).char1, (yyvsp[(3) - (7)].c2).char2, (yyvsp[(5) - (7)].c), 0, (yyvsp[(6) - (7)].d), 2); ;} break; case 432: -#line 4891 "Gmsh.y" +#line 4904 "Gmsh.y" { (yyval.d) = treat_Struct_FullName_Float((yyvsp[(3) - (8)].c2).char1, (yyvsp[(3) - (8)].c2).char2, 2, (int)(yyvsp[(5) - (8)].d), (yyvsp[(7) - (8)].d), 2); ;} break; case 433: -#line 4895 "Gmsh.y" +#line 4908 "Gmsh.y" { (yyval.d) = treat_Struct_FullName_dot_tSTRING_Float((yyvsp[(3) - (10)].c2).char1, (yyvsp[(3) - (10)].c2).char2, (yyvsp[(5) - (10)].c), (int)(yyvsp[(7) - (10)].d), (yyvsp[(9) - (10)].d), 2); ;} break; case 434: -#line 4899 "Gmsh.y" +#line 4912 "Gmsh.y" { std::string tmp = FixRelativePath(gmsh_yyname, (yyvsp[(3) - (4)].c)); (yyval.d) = !StatFile(tmp); @@ -11871,7 +11884,7 @@ yyreduce: break; case 435: -#line 4905 "Gmsh.y" +#line 4918 "Gmsh.y" { if(gmsh_yysymbols.count((yyvsp[(2) - (4)].c))){ gmsh_yysymbol &s(gmsh_yysymbols[(yyvsp[(2) - (4)].c)]); @@ -11889,14 +11902,14 @@ yyreduce: break; case 436: -#line 4921 "Gmsh.y" +#line 4934 "Gmsh.y" { (yyval.d) = treat_Struct_FullName_dot_tSTRING_Float_getDim((yyvsp[(2) - (6)].c2).char1, (yyvsp[(2) - (6)].c2).char2, (yyvsp[(4) - (6)].c)); ;} break; case 437: -#line 4926 "Gmsh.y" +#line 4939 "Gmsh.y" { std::string struct_namespace((yyvsp[(3) - (4)].c)); (yyval.d) = (double)gmsh_yynamespaces[struct_namespace].size(); @@ -11905,7 +11918,7 @@ yyreduce: break; case 438: -#line 4932 "Gmsh.y" +#line 4945 "Gmsh.y" { std::string struct_namespace(std::string("")); (yyval.d) = (double)gmsh_yynamespaces[struct_namespace].size(); @@ -11913,7 +11926,7 @@ yyreduce: break; case 439: -#line 4938 "Gmsh.y" +#line 4951 "Gmsh.y" { if(!gmsh_yysymbols.count((yyvsp[(1) - (2)].c))){ yymsg(0, "Unknown variable '%s'", (yyvsp[(1) - (2)].c)); @@ -11935,7 +11948,7 @@ yyreduce: break; case 440: -#line 4957 "Gmsh.y" +#line 4970 "Gmsh.y" { int index = (int)(yyvsp[(3) - (5)].d); if(!gmsh_yysymbols.count((yyvsp[(1) - (5)].c))){ @@ -11958,7 +11971,7 @@ yyreduce: break; case 441: -#line 4978 "Gmsh.y" +#line 4991 "Gmsh.y" { int index = (int)(yyvsp[(3) - (5)].d); if(!gmsh_yysymbols.count((yyvsp[(1) - (5)].c))){ @@ -11981,49 +11994,49 @@ yyreduce: break; case 442: -#line 5011 "Gmsh.y" +#line 5024 "Gmsh.y" { (yyval.d) = treat_Struct_FullName_dot_tSTRING_Float(NULL, (yyvsp[(1) - (3)].c), (yyvsp[(3) - (3)].c)); ;} break; case 443: -#line 5015 "Gmsh.y" +#line 5028 "Gmsh.y" { (yyval.d) = treat_Struct_FullName_dot_tSTRING_Float((yyvsp[(1) - (5)].c), (yyvsp[(3) - (5)].c), (yyvsp[(5) - (5)].c)); ;} break; case 444: -#line 5020 "Gmsh.y" +#line 5033 "Gmsh.y" { (yyval.d) = treat_Struct_FullName_dot_tSTRING_Float(NULL, (yyvsp[(1) - (6)].c), (yyvsp[(3) - (6)].c), (int)(yyvsp[(5) - (6)].d)); ;} break; case 445: -#line 5024 "Gmsh.y" +#line 5037 "Gmsh.y" { (yyval.d) = treat_Struct_FullName_dot_tSTRING_Float((yyvsp[(1) - (8)].c), (yyvsp[(3) - (8)].c), (yyvsp[(5) - (8)].c), (int)(yyvsp[(7) - (8)].d)); ;} break; case 446: -#line 5028 "Gmsh.y" +#line 5041 "Gmsh.y" { (yyval.d) = treat_Struct_FullName_dot_tSTRING_Float(NULL, (yyvsp[(1) - (6)].c), (yyvsp[(3) - (6)].c), (int)(yyvsp[(5) - (6)].d)); ;} break; case 447: -#line 5032 "Gmsh.y" +#line 5045 "Gmsh.y" { (yyval.d) = treat_Struct_FullName_dot_tSTRING_Float((yyvsp[(1) - (8)].c), (yyvsp[(3) - (8)].c), (yyvsp[(5) - (8)].c), (int)(yyvsp[(7) - (8)].d)); ;} break; case 448: -#line 5037 "Gmsh.y" +#line 5050 "Gmsh.y" { NumberOption(GMSH_GET, (yyvsp[(1) - (6)].c), (int)(yyvsp[(3) - (6)].d), (yyvsp[(6) - (6)].c), (yyval.d)); Free((yyvsp[(1) - (6)].c)); Free((yyvsp[(6) - (6)].c)); @@ -12031,7 +12044,7 @@ yyreduce: break; case 449: -#line 5042 "Gmsh.y" +#line 5055 "Gmsh.y" { double d = 0.; if(NumberOption(GMSH_GET, (yyvsp[(1) - (4)].c), 0, (yyvsp[(3) - (4)].c), d)){ @@ -12044,7 +12057,7 @@ yyreduce: break; case 450: -#line 5052 "Gmsh.y" +#line 5065 "Gmsh.y" { double d = 0.; if(NumberOption(GMSH_GET, (yyvsp[(1) - (7)].c), (int)(yyvsp[(3) - (7)].d), (yyvsp[(6) - (7)].c), d)){ @@ -12057,7 +12070,7 @@ yyreduce: break; case 451: -#line 5062 "Gmsh.y" +#line 5075 "Gmsh.y" { (yyval.d) = Msg::GetValue((yyvsp[(3) - (6)].c), (yyvsp[(5) - (6)].d)); Free((yyvsp[(3) - (6)].c)); @@ -12065,7 +12078,7 @@ yyreduce: break; case 452: -#line 5067 "Gmsh.y" +#line 5080 "Gmsh.y" { int matches = 0; for(int i = 0; i < List_Nbr((yyvsp[(3) - (6)].l)); i++){ @@ -12079,7 +12092,7 @@ yyreduce: break; case 453: -#line 5078 "Gmsh.y" +#line 5091 "Gmsh.y" { std::string s((yyvsp[(3) - (6)].c)), substr((yyvsp[(5) - (6)].c)); if(s.find(substr) != std::string::npos) @@ -12091,7 +12104,7 @@ yyreduce: break; case 454: -#line 5087 "Gmsh.y" +#line 5100 "Gmsh.y" { (yyval.d) = strlen((yyvsp[(3) - (4)].c)); Free((yyvsp[(3) - (4)].c)); @@ -12099,7 +12112,7 @@ yyreduce: break; case 455: -#line 5092 "Gmsh.y" +#line 5105 "Gmsh.y" { (yyval.d) = strcmp((yyvsp[(3) - (6)].c), (yyvsp[(5) - (6)].c)); Free((yyvsp[(3) - (6)].c)); Free((yyvsp[(5) - (6)].c)); @@ -12107,7 +12120,7 @@ yyreduce: break; case 456: -#line 5097 "Gmsh.y" +#line 5110 "Gmsh.y" { int align = 0, font = 0, fontsize = CTX::instance()->glFontSize; if(List_Nbr((yyvsp[(3) - (4)].l)) % 2){ @@ -12134,27 +12147,27 @@ yyreduce: break; case 457: -#line 5124 "Gmsh.y" +#line 5137 "Gmsh.y" { (yyval.d) = 0.; ;} break; case 458: -#line 5126 "Gmsh.y" +#line 5139 "Gmsh.y" { (yyval.d) = (yyvsp[(2) - (2)].d);;} break; case 459: -#line 5131 "Gmsh.y" +#line 5144 "Gmsh.y" { (yyval.c) = NULL; ;} break; case 460: -#line 5133 "Gmsh.y" +#line 5146 "Gmsh.y" { (yyval.c) = (yyvsp[(2) - (2)].c);;} break; case 461: -#line 5138 "Gmsh.y" +#line 5151 "Gmsh.y" { std::string struct_namespace((yyvsp[(2) - (3)].c2).char1? (yyvsp[(2) - (3)].c2).char1 : std::string("")), struct_name((yyvsp[(2) - (3)].c2).char2); @@ -12164,7 +12177,7 @@ yyreduce: break; case 462: -#line 5145 "Gmsh.y" +#line 5158 "Gmsh.y" { std::string struct_namespace((yyvsp[(2) - (7)].c2).char1? (yyvsp[(2) - (7)].c2).char1 : std::string("")), struct_name((yyvsp[(2) - (7)].c2).char2); @@ -12180,105 +12193,105 @@ yyreduce: break; case 463: -#line 5161 "Gmsh.y" +#line 5174 "Gmsh.y" { (yyval.c2).char1 = NULL; (yyval.c2).char2 = (yyvsp[(1) - (1)].c); ;} break; case 464: -#line 5163 "Gmsh.y" +#line 5176 "Gmsh.y" { (yyval.c2).char1 = (yyvsp[(1) - (3)].c); (yyval.c2).char2 = (yyvsp[(3) - (3)].c); ;} break; case 465: -#line 5168 "Gmsh.y" +#line 5181 "Gmsh.y" { (yyval.c) = (yyvsp[(1) - (1)].c); flag_tSTRING_alloc = 1; ;} break; case 466: -#line 5177 "Gmsh.y" +#line 5190 "Gmsh.y" { (yyval.i) = 99; ;} break; case 467: -#line 5179 "Gmsh.y" +#line 5192 "Gmsh.y" { (yyval.i) = (int)(yyvsp[(2) - (2)].d); ;} break; case 468: -#line 5184 "Gmsh.y" +#line 5197 "Gmsh.y" { (yyval.i) = 0; ;} break; case 469: -#line 5186 "Gmsh.y" +#line 5199 "Gmsh.y" { (yyval.i) = (yyvsp[(2) - (3)].i); ;} break; case 470: -#line 5191 "Gmsh.y" +#line 5204 "Gmsh.y" { memcpy((yyval.v), (yyvsp[(1) - (1)].v), 5*sizeof(double)); ;} break; case 471: -#line 5195 "Gmsh.y" +#line 5208 "Gmsh.y" { for(int i = 0; i < 5; i++) (yyval.v)[i] = -(yyvsp[(2) - (2)].v)[i]; ;} break; case 472: -#line 5199 "Gmsh.y" +#line 5212 "Gmsh.y" { for(int i = 0; i < 5; i++) (yyval.v)[i] = (yyvsp[(2) - (2)].v)[i]; ;} break; case 473: -#line 5203 "Gmsh.y" +#line 5216 "Gmsh.y" { for(int i = 0; i < 5; i++) (yyval.v)[i] = (yyvsp[(1) - (3)].v)[i] - (yyvsp[(3) - (3)].v)[i]; ;} break; case 474: -#line 5207 "Gmsh.y" +#line 5220 "Gmsh.y" { for(int i = 0; i < 5; i++) (yyval.v)[i] = (yyvsp[(1) - (3)].v)[i] + (yyvsp[(3) - (3)].v)[i]; ;} break; case 475: -#line 5214 "Gmsh.y" +#line 5227 "Gmsh.y" { (yyval.v)[0] = (yyvsp[(2) - (11)].d); (yyval.v)[1] = (yyvsp[(4) - (11)].d); (yyval.v)[2] = (yyvsp[(6) - (11)].d); (yyval.v)[3] = (yyvsp[(8) - (11)].d); (yyval.v)[4] = (yyvsp[(10) - (11)].d); ;} break; case 476: -#line 5218 "Gmsh.y" +#line 5231 "Gmsh.y" { (yyval.v)[0] = (yyvsp[(2) - (9)].d); (yyval.v)[1] = (yyvsp[(4) - (9)].d); (yyval.v)[2] = (yyvsp[(6) - (9)].d); (yyval.v)[3] = (yyvsp[(8) - (9)].d); (yyval.v)[4] = 1.0; ;} break; case 477: -#line 5222 "Gmsh.y" +#line 5235 "Gmsh.y" { (yyval.v)[0] = (yyvsp[(2) - (7)].d); (yyval.v)[1] = (yyvsp[(4) - (7)].d); (yyval.v)[2] = (yyvsp[(6) - (7)].d); (yyval.v)[3] = 0.0; (yyval.v)[4] = 1.0; ;} break; case 478: -#line 5226 "Gmsh.y" +#line 5239 "Gmsh.y" { (yyval.v)[0] = (yyvsp[(2) - (7)].d); (yyval.v)[1] = (yyvsp[(4) - (7)].d); (yyval.v)[2] = (yyvsp[(6) - (7)].d); (yyval.v)[3] = 0.0; (yyval.v)[4] = 1.0; ;} break; case 479: -#line 5233 "Gmsh.y" +#line 5246 "Gmsh.y" { (yyval.l) = List_Create(2, 1, sizeof(List_T*)); List_Add((yyval.l), &((yyvsp[(1) - (1)].l))); @@ -12286,14 +12299,14 @@ yyreduce: break; case 480: -#line 5238 "Gmsh.y" +#line 5251 "Gmsh.y" { List_Add((yyval.l), &((yyvsp[(3) - (3)].l))); ;} break; case 481: -#line 5245 "Gmsh.y" +#line 5258 "Gmsh.y" { (yyval.l) = List_Create(2, 1, sizeof(double)); List_Add((yyval.l), &((yyvsp[(1) - (1)].d))); @@ -12301,14 +12314,14 @@ yyreduce: break; case 482: -#line 5250 "Gmsh.y" +#line 5263 "Gmsh.y" { (yyval.l) = (yyvsp[(1) - (1)].l); ;} break; case 483: -#line 5254 "Gmsh.y" +#line 5267 "Gmsh.y" { // creates an empty list (yyval.l) = List_Create(2, 1, sizeof(double)); @@ -12316,14 +12329,14 @@ yyreduce: break; case 484: -#line 5259 "Gmsh.y" +#line 5272 "Gmsh.y" { (yyval.l) = (yyvsp[(2) - (3)].l); ;} break; case 485: -#line 5263 "Gmsh.y" +#line 5276 "Gmsh.y" { (yyval.l) = (yyvsp[(3) - (4)].l); for(int i = 0; i < List_Nbr((yyval.l)); i++){ @@ -12334,7 +12347,7 @@ yyreduce: break; case 486: -#line 5271 "Gmsh.y" +#line 5284 "Gmsh.y" { (yyval.l) = (yyvsp[(4) - (5)].l); for(int i = 0; i < List_Nbr((yyval.l)); i++){ @@ -12345,14 +12358,14 @@ yyreduce: break; case 487: -#line 5282 "Gmsh.y" +#line 5295 "Gmsh.y" { (yyval.l) = (yyvsp[(1) - (1)].l); ;} break; case 488: -#line 5286 "Gmsh.y" +#line 5299 "Gmsh.y" { if(!strcmp((yyvsp[(1) - (1)].c), "*") || !strcmp((yyvsp[(1) - (1)].c), "all")) (yyval.l) = 0; @@ -12364,7 +12377,7 @@ yyreduce: break; case 489: -#line 5298 "Gmsh.y" +#line 5311 "Gmsh.y" { (yyval.l) = (yyvsp[(2) - (2)].l); for(int i = 0; i < List_Nbr((yyval.l)); i++){ @@ -12375,7 +12388,7 @@ yyreduce: break; case 490: -#line 5306 "Gmsh.y" +#line 5319 "Gmsh.y" { (yyval.l) = (yyvsp[(3) - (3)].l); for(int i = 0; i < List_Nbr((yyval.l)); i++){ @@ -12386,7 +12399,7 @@ yyreduce: break; case 491: -#line 5314 "Gmsh.y" +#line 5327 "Gmsh.y" { (yyval.l) = List_Create(2, 1, sizeof(double)); for(double d = (yyvsp[(1) - (3)].d); ((yyvsp[(1) - (3)].d) < (yyvsp[(3) - (3)].d)) ? (d <= (yyvsp[(3) - (3)].d)) : (d >= (yyvsp[(3) - (3)].d)); @@ -12396,7 +12409,7 @@ yyreduce: break; case 492: -#line 5321 "Gmsh.y" +#line 5334 "Gmsh.y" { (yyval.l) = List_Create(2, 1, sizeof(double)); if(!(yyvsp[(5) - (5)].d)){ //|| ($1 < $3 && $5 < 0) || ($1 > $3 && $5 > 0) @@ -12409,7 +12422,7 @@ yyreduce: break; case 493: -#line 5331 "Gmsh.y" +#line 5344 "Gmsh.y" { (yyval.l) = List_Create(3, 1, sizeof(double)); int tag = (int)(yyvsp[(3) - (4)].d); @@ -12435,7 +12448,7 @@ yyreduce: break; case 494: -#line 5354 "Gmsh.y" +#line 5367 "Gmsh.y" { (yyval.l) = List_Create(10, 10, sizeof(double)); getAllElementaryTags((yyvsp[(1) - (2)].i), (yyval.l)); @@ -12444,7 +12457,7 @@ yyreduce: break; case 495: -#line 5360 "Gmsh.y" +#line 5373 "Gmsh.y" { (yyval.l) = List_Create(10, 10, sizeof(double)); if(!(yyvsp[(3) - (3)].l)){ @@ -12458,7 +12471,7 @@ yyreduce: break; case 496: -#line 5372 "Gmsh.y" +#line 5385 "Gmsh.y" { (yyval.l) = List_Create(10, 10, sizeof(double)); getElementaryTagsInBoundingBox((yyvsp[(1) - (16)].i), (yyvsp[(5) - (16)].d), (yyvsp[(7) - (16)].d), (yyvsp[(9) - (16)].d), (yyvsp[(11) - (16)].d), (yyvsp[(13) - (16)].d), (yyvsp[(15) - (16)].d), (yyval.l)); @@ -12466,7 +12479,7 @@ yyreduce: break; case 497: -#line 5377 "Gmsh.y" +#line 5390 "Gmsh.y" { (yyval.l) = List_Create(10, 10, sizeof(double)); getBoundingBox((yyvsp[(2) - (5)].i), (int)(yyvsp[(4) - (5)].d), (yyval.l)); @@ -12474,7 +12487,7 @@ yyreduce: break; case 498: -#line 5382 "Gmsh.y" +#line 5395 "Gmsh.y" { (yyval.l) = List_Create(List_Nbr((yyvsp[(1) - (1)].l)), 1, sizeof(double)); for(int i = 0; i < List_Nbr((yyvsp[(1) - (1)].l)); i++){ @@ -12487,7 +12500,7 @@ yyreduce: break; case 499: -#line 5392 "Gmsh.y" +#line 5405 "Gmsh.y" { (yyval.l) = List_Create(List_Nbr((yyvsp[(1) - (1)].l)), 1, sizeof(double)); for(int i = 0; i < List_Nbr((yyvsp[(1) - (1)].l)); i++){ @@ -12500,7 +12513,7 @@ yyreduce: break; case 500: -#line 5402 "Gmsh.y" +#line 5415 "Gmsh.y" { (yyval.l) = List_Create(List_Nbr((yyvsp[(1) - (1)].l)), 1, sizeof(double)); for(int i = 0; i < List_Nbr((yyvsp[(1) - (1)].l)); i++){ @@ -12513,7 +12526,7 @@ yyreduce: break; case 501: -#line 5412 "Gmsh.y" +#line 5425 "Gmsh.y" { (yyval.l) = List_Create(20, 20, sizeof(double)); if(!gmsh_yysymbols.count((yyvsp[(1) - (3)].c))) @@ -12528,21 +12541,21 @@ yyreduce: break; case 502: -#line 5424 "Gmsh.y" +#line 5437 "Gmsh.y" { (yyval.l) = treat_Struct_FullName_dot_tSTRING_ListOfFloat(NULL, (yyvsp[(1) - (5)].c), (yyvsp[(3) - (5)].c)); ;} break; case 503: -#line 5428 "Gmsh.y" +#line 5441 "Gmsh.y" { (yyval.l) = treat_Struct_FullName_dot_tSTRING_ListOfFloat((yyvsp[(1) - (7)].c), (yyvsp[(3) - (7)].c), (yyvsp[(5) - (7)].c)); ;} break; case 504: -#line 5433 "Gmsh.y" +#line 5446 "Gmsh.y" { (yyval.l) = List_Create(2, 1, sizeof(double)); if(!gmsh_yysymbols.count((yyvsp[(3) - (4)].c))) @@ -12557,28 +12570,28 @@ yyreduce: break; case 505: -#line 5445 "Gmsh.y" +#line 5458 "Gmsh.y" { (yyval.l) = (yyvsp[(3) - (4)].l); ;} break; case 506: -#line 5449 "Gmsh.y" +#line 5462 "Gmsh.y" { (yyval.l) = (yyvsp[(3) - (4)].l); ;} break; case 507: -#line 5453 "Gmsh.y" +#line 5466 "Gmsh.y" { (yyval.l) = (yyvsp[(4) - (6)].l); ;} break; case 508: -#line 5457 "Gmsh.y" +#line 5470 "Gmsh.y" { (yyval.l) = List_Create(2, 1, sizeof(double)); if(!gmsh_yysymbols.count((yyvsp[(1) - (6)].c))) @@ -12599,7 +12612,7 @@ yyreduce: break; case 509: -#line 5475 "Gmsh.y" +#line 5488 "Gmsh.y" { (yyval.l) = List_Create(20,20,sizeof(double)); for(int i = 0; i < (int)(yyvsp[(7) - (8)].d); i++) { @@ -12610,7 +12623,7 @@ yyreduce: break; case 510: -#line 5483 "Gmsh.y" +#line 5496 "Gmsh.y" { (yyval.l) = List_Create(20,20,sizeof(double)); for(int i = 0; i < (int)(yyvsp[(7) - (8)].d); i++) { @@ -12621,7 +12634,7 @@ yyreduce: break; case 511: -#line 5491 "Gmsh.y" +#line 5504 "Gmsh.y" { Msg::Barrier(); FILE *File; @@ -12653,7 +12666,7 @@ yyreduce: break; case 512: -#line 5520 "Gmsh.y" +#line 5533 "Gmsh.y" { double x0 = (yyvsp[(3) - (14)].d), x1 = (yyvsp[(5) - (14)].d), y0 = (yyvsp[(7) - (14)].d), y1 = (yyvsp[(9) - (14)].d), ys = (yyvsp[(11) - (14)].d); int N = (int)(yyvsp[(13) - (14)].d); @@ -12666,7 +12679,7 @@ yyreduce: break; case 513: -#line 5530 "Gmsh.y" +#line 5543 "Gmsh.y" { std::vector<double> tmp; for(int i = 0; i < List_Nbr((yyvsp[(3) - (4)].l)); i++){ @@ -12685,7 +12698,7 @@ yyreduce: break; case 514: -#line 5546 "Gmsh.y" +#line 5559 "Gmsh.y" { for(int i = 0; i < List_Nbr((yyvsp[(3) - (4)].l)); i++){ double *d = (double*)List_Pointer((yyvsp[(3) - (4)].l), i); @@ -12696,7 +12709,7 @@ yyreduce: break; case 515: -#line 5557 "Gmsh.y" +#line 5570 "Gmsh.y" { (yyval.l) = List_Create(2, 1, sizeof(double)); List_Add((yyval.l), &((yyvsp[(1) - (1)].d))); @@ -12704,21 +12717,21 @@ yyreduce: break; case 516: -#line 5562 "Gmsh.y" +#line 5575 "Gmsh.y" { (yyval.l) = (yyvsp[(1) - (1)].l); ;} break; case 517: -#line 5566 "Gmsh.y" +#line 5579 "Gmsh.y" { List_Add((yyval.l), &((yyvsp[(3) - (3)].d))); ;} break; case 518: -#line 5570 "Gmsh.y" +#line 5583 "Gmsh.y" { for(int i = 0; i < List_Nbr((yyvsp[(3) - (3)].l)); i++){ double d; @@ -12730,21 +12743,21 @@ yyreduce: break; case 519: -#line 5582 "Gmsh.y" +#line 5595 "Gmsh.y" { (yyval.u) = CTX::instance()->packColor((int)(yyvsp[(2) - (9)].d), (int)(yyvsp[(4) - (9)].d), (int)(yyvsp[(6) - (9)].d), (int)(yyvsp[(8) - (9)].d)); ;} break; case 520: -#line 5586 "Gmsh.y" +#line 5599 "Gmsh.y" { (yyval.u) = CTX::instance()->packColor((int)(yyvsp[(2) - (7)].d), (int)(yyvsp[(4) - (7)].d), (int)(yyvsp[(6) - (7)].d), 255); ;} break; case 521: -#line 5598 "Gmsh.y" +#line 5611 "Gmsh.y" { int flag = 0; if(gmsh_yystringsymbols.count((yyvsp[(1) - (1)].c))){ @@ -12764,7 +12777,7 @@ yyreduce: break; case 522: -#line 5615 "Gmsh.y" +#line 5628 "Gmsh.y" { unsigned int val = 0; ColorOption(GMSH_GET, (yyvsp[(1) - (5)].c), 0, (yyvsp[(5) - (5)].c), val); @@ -12774,14 +12787,14 @@ yyreduce: break; case 523: -#line 5625 "Gmsh.y" +#line 5638 "Gmsh.y" { (yyval.l) = (yyvsp[(2) - (3)].l); ;} break; case 524: -#line 5629 "Gmsh.y" +#line 5642 "Gmsh.y" { (yyval.l) = List_Create(256, 10, sizeof(unsigned int)); GmshColorTable *ct = GetColorTable((int)(yyvsp[(3) - (6)].d)); @@ -12796,7 +12809,7 @@ yyreduce: break; case 525: -#line 5644 "Gmsh.y" +#line 5657 "Gmsh.y" { (yyval.l) = List_Create(256, 10, sizeof(unsigned int)); List_Add((yyval.l), &((yyvsp[(1) - (1)].u))); @@ -12804,21 +12817,21 @@ yyreduce: break; case 526: -#line 5649 "Gmsh.y" +#line 5662 "Gmsh.y" { List_Add((yyval.l), &((yyvsp[(3) - (3)].u))); ;} break; case 527: -#line 5656 "Gmsh.y" +#line 5669 "Gmsh.y" { (yyval.c) = (yyvsp[(1) - (1)].c); ;} break; case 528: -#line 5660 "Gmsh.y" +#line 5673 "Gmsh.y" { // No need to extend to Struct_FullName (a Tag is not a String) (yyval.c) = treat_Struct_FullName_String(NULL, (yyvsp[(1) - (1)].c)); @@ -12826,7 +12839,7 @@ yyreduce: break; case 529: -#line 5665 "Gmsh.y" +#line 5678 "Gmsh.y" { std::string val; int j = (int)(yyvsp[(3) - (4)].d); @@ -12843,7 +12856,7 @@ yyreduce: break; case 530: -#line 5679 "Gmsh.y" +#line 5692 "Gmsh.y" { std::string val; int j = (int)(yyvsp[(3) - (4)].d); @@ -12860,35 +12873,35 @@ yyreduce: break; case 531: -#line 5695 "Gmsh.y" +#line 5708 "Gmsh.y" { (yyval.c) = treat_Struct_FullName_dot_tSTRING_String(NULL, (yyvsp[(1) - (3)].c), (yyvsp[(3) - (3)].c)); ;} break; case 532: -#line 5699 "Gmsh.y" +#line 5712 "Gmsh.y" { (yyval.c) = treat_Struct_FullName_dot_tSTRING_String((yyvsp[(1) - (5)].c), (yyvsp[(3) - (5)].c), (yyvsp[(5) - (5)].c)); ;} break; case 533: -#line 5703 "Gmsh.y" +#line 5716 "Gmsh.y" { (yyval.c) = treat_Struct_FullName_dot_tSTRING_String(NULL, (yyvsp[(1) - (6)].c), (yyvsp[(3) - (6)].c), (int)(yyvsp[(5) - (6)].d)); ;} break; case 534: -#line 5707 "Gmsh.y" +#line 5720 "Gmsh.y" { (yyval.c) = treat_Struct_FullName_dot_tSTRING_String((yyvsp[(1) - (8)].c), (yyvsp[(3) - (8)].c), (yyvsp[(5) - (8)].c), (int)(yyvsp[(7) - (8)].d)); ;} break; case 535: -#line 5711 "Gmsh.y" +#line 5724 "Gmsh.y" { std::string out; StringOption(GMSH_GET, (yyvsp[(1) - (6)].c), (int)(yyvsp[(3) - (6)].d), (yyvsp[(6) - (6)].c), out); @@ -12899,7 +12912,7 @@ yyreduce: break; case 536: -#line 5719 "Gmsh.y" +#line 5732 "Gmsh.y" { std::string name = GModel::current()->getPhysicalName(0, (int)(yyvsp[(4) - (5)].d)); (yyval.c) = (char*)Malloc((name.size() + 1) * sizeof(char)); @@ -12908,7 +12921,7 @@ yyreduce: break; case 537: -#line 5725 "Gmsh.y" +#line 5738 "Gmsh.y" { std::string name = GModel::current()->getPhysicalName(1, (int)(yyvsp[(4) - (5)].d)); (yyval.c) = (char*)Malloc((name.size() + 1) * sizeof(char)); @@ -12917,7 +12930,7 @@ yyreduce: break; case 538: -#line 5731 "Gmsh.y" +#line 5744 "Gmsh.y" { std::string name = GModel::current()->getPhysicalName(2, (int)(yyvsp[(4) - (5)].d)); (yyval.c) = (char*)Malloc((name.size() + 1) * sizeof(char)); @@ -12926,7 +12939,7 @@ yyreduce: break; case 539: -#line 5737 "Gmsh.y" +#line 5750 "Gmsh.y" { std::string name = GModel::current()->getPhysicalName(3, (int)(yyvsp[(4) - (5)].d)); (yyval.c) = (char*)Malloc((name.size() + 1) * sizeof(char)); @@ -12935,21 +12948,21 @@ yyreduce: break; case 540: -#line 5746 "Gmsh.y" +#line 5759 "Gmsh.y" { (yyval.c) = (yyvsp[(1) - (1)].c); ;} break; case 541: -#line 5750 "Gmsh.y" +#line 5763 "Gmsh.y" { (yyval.c) = (yyvsp[(3) - (4)].c); ;} break; case 542: -#line 5754 "Gmsh.y" +#line 5767 "Gmsh.y" { (yyval.c) = (char *)Malloc(32 * sizeof(char)); time_t now; @@ -12960,7 +12973,7 @@ yyreduce: break; case 543: -#line 5762 "Gmsh.y" +#line 5775 "Gmsh.y" { std::string exe = Msg::GetExecutableName(); (yyval.c) = (char *)Malloc(exe.size() + 1); @@ -12969,7 +12982,7 @@ yyreduce: break; case 544: -#line 5768 "Gmsh.y" +#line 5781 "Gmsh.y" { std::string action = Msg::GetOnelabAction(); (yyval.c) = (char *)Malloc(action.size() + 1); @@ -12978,14 +12991,14 @@ yyreduce: break; case 545: -#line 5774 "Gmsh.y" +#line 5787 "Gmsh.y" { (yyval.c) = strsave((char*)"Gmsh"); ;} break; case 546: -#line 5778 "Gmsh.y" +#line 5791 "Gmsh.y" { const char *env = GetEnvironmentVar((yyvsp[(3) - (4)].c)); if(!env) env = ""; @@ -12996,7 +13009,7 @@ yyreduce: break; case 547: -#line 5786 "Gmsh.y" +#line 5799 "Gmsh.y" { std::string s = Msg::GetString((yyvsp[(3) - (6)].c), (yyvsp[(5) - (6)].c)); (yyval.c) = (char *)Malloc((s.size() + 1) * sizeof(char)); @@ -13007,7 +13020,7 @@ yyreduce: break; case 548: -#line 5794 "Gmsh.y" +#line 5807 "Gmsh.y" { std::string s = Msg::GetOnelabString((yyvsp[(3) - (4)].c)); (yyval.c) = (char *)Malloc((s.size() + 1) * sizeof(char)); @@ -13017,7 +13030,7 @@ yyreduce: break; case 549: -#line 5801 "Gmsh.y" +#line 5814 "Gmsh.y" { std::string s = Msg::GetOnelabString((yyvsp[(3) - (6)].c), (yyvsp[(5) - (6)].c)); (yyval.c) = (char *)Malloc((s.size() + 1) * sizeof(char)); @@ -13028,21 +13041,21 @@ yyreduce: break; case 550: -#line 5810 "Gmsh.y" +#line 5823 "Gmsh.y" { (yyval.c) = treat_Struct_FullName_String(NULL, (yyvsp[(3) - (5)].c2).char2, 1, 0, (yyvsp[(4) - (5)].c), 2); ;} break; case 551: -#line 5814 "Gmsh.y" +#line 5827 "Gmsh.y" { (yyval.c) = treat_Struct_FullName_dot_tSTRING_String((yyvsp[(3) - (7)].c2).char1, (yyvsp[(3) - (7)].c2).char2, (yyvsp[(5) - (7)].c), 0, (yyvsp[(6) - (7)].c), 2); ;} break; case 552: -#line 5818 "Gmsh.y" +#line 5831 "Gmsh.y" { int size = 1; for(int i = 0; i < List_Nbr((yyvsp[(3) - (4)].l)); i++) @@ -13060,7 +13073,7 @@ yyreduce: break; case 553: -#line 5833 "Gmsh.y" +#line 5846 "Gmsh.y" { (yyval.c) = (char *)Malloc((strlen((yyvsp[(3) - (4)].c)) + 1) * sizeof(char)); int i; @@ -13077,7 +13090,7 @@ yyreduce: break; case 554: -#line 5847 "Gmsh.y" +#line 5860 "Gmsh.y" { (yyval.c) = (char *)Malloc((strlen((yyvsp[(3) - (4)].c)) + 1) * sizeof(char)); int i; @@ -13094,7 +13107,7 @@ yyreduce: break; case 555: -#line 5861 "Gmsh.y" +#line 5874 "Gmsh.y" { std::string input = (yyvsp[(3) - (8)].c); std::string substr_old = (yyvsp[(5) - (8)].c); @@ -13109,7 +13122,7 @@ yyreduce: break; case 556: -#line 5873 "Gmsh.y" +#line 5886 "Gmsh.y" { int size = 1; for(int i = 0; i < List_Nbr((yyvsp[(3) - (4)].l)); i++) @@ -13128,7 +13141,7 @@ yyreduce: break; case 557: -#line 5889 "Gmsh.y" +#line 5902 "Gmsh.y" { int i = 0; while ((yyvsp[(3) - (4)].c)[i]) { @@ -13140,7 +13153,7 @@ yyreduce: break; case 558: -#line 5898 "Gmsh.y" +#line 5911 "Gmsh.y" { int i = 0; while ((yyvsp[(3) - (4)].c)[i]) { @@ -13152,7 +13165,7 @@ yyreduce: break; case 559: -#line 5907 "Gmsh.y" +#line 5920 "Gmsh.y" { int i = 0; while ((yyvsp[(3) - (4)].c)[i]) { @@ -13165,7 +13178,7 @@ yyreduce: break; case 560: -#line 5917 "Gmsh.y" +#line 5930 "Gmsh.y" { if((yyvsp[(3) - (8)].d)){ (yyval.c) = (yyvsp[(5) - (8)].c); @@ -13179,7 +13192,7 @@ yyreduce: break; case 561: -#line 5928 "Gmsh.y" +#line 5941 "Gmsh.y" { std::string in = (yyvsp[(3) - (8)].c); std::string out = in.substr((int)(yyvsp[(5) - (8)].d), (int)(yyvsp[(7) - (8)].d)); @@ -13190,7 +13203,7 @@ yyreduce: break; case 562: -#line 5936 "Gmsh.y" +#line 5949 "Gmsh.y" { std::string in = (yyvsp[(3) - (6)].c); std::string out = in.substr((int)(yyvsp[(5) - (6)].d), std::string::npos); @@ -13201,14 +13214,14 @@ yyreduce: break; case 563: -#line 5944 "Gmsh.y" +#line 5957 "Gmsh.y" { (yyval.c) = (yyvsp[(3) - (4)].c); ;} break; case 564: -#line 5948 "Gmsh.y" +#line 5961 "Gmsh.y" { char tmpstring[5000]; int i = printListOfDouble((yyvsp[(3) - (6)].c), (yyvsp[(5) - (6)].l), tmpstring); @@ -13230,7 +13243,7 @@ yyreduce: break; case 565: -#line 5967 "Gmsh.y" +#line 5980 "Gmsh.y" { std::string tmp = FixRelativePath(gmsh_yyname, (yyvsp[(3) - (4)].c)); (yyval.c) = (char*)Malloc((tmp.size() + 1) * sizeof(char)); @@ -13240,7 +13253,7 @@ yyreduce: break; case 566: -#line 5974 "Gmsh.y" +#line 5987 "Gmsh.y" { std::string tmp = SplitFileName(GetAbsolutePath(gmsh_yyname))[0]; (yyval.c) = (char*)Malloc((tmp.size() + 1) * sizeof(char)); @@ -13249,7 +13262,7 @@ yyreduce: break; case 567: -#line 5980 "Gmsh.y" +#line 5993 "Gmsh.y" { std::string tmp = SplitFileName((yyvsp[(3) - (4)].c))[0]; (yyval.c) = (char*)Malloc((tmp.size() + 1) * sizeof(char)); @@ -13259,7 +13272,7 @@ yyreduce: break; case 568: -#line 5987 "Gmsh.y" +#line 6000 "Gmsh.y" { std::string tmp = GetAbsolutePath((yyvsp[(3) - (4)].c)); (yyval.c) = (char*)Malloc((tmp.size() + 1) * sizeof(char)); @@ -13269,12 +13282,12 @@ yyreduce: break; case 569: -#line 5994 "Gmsh.y" +#line 6007 "Gmsh.y" { init_options(); ;} break; case 570: -#line 5996 "Gmsh.y" +#line 6009 "Gmsh.y" { std::string val((yyvsp[(3) - (6)].c)); Msg::ExchangeOnelabParameter("", val, floatOptions, charOptions); @@ -13285,7 +13298,7 @@ yyreduce: break; case 571: -#line 6004 "Gmsh.y" +#line 6017 "Gmsh.y" { std::string out; const std::string * key_struct = NULL; @@ -13309,37 +13322,37 @@ yyreduce: break; case 572: -#line 6028 "Gmsh.y" +#line 6041 "Gmsh.y" { struct_namespace = std::string(""); (yyval.d) = (yyvsp[(2) - (2)].d); ;} break; case 573: -#line 6030 "Gmsh.y" +#line 6043 "Gmsh.y" { struct_namespace = (yyvsp[(1) - (4)].c); Free((yyvsp[(1) - (4)].c)); (yyval.d) = (yyvsp[(4) - (4)].d); ;} break; case 574: -#line 6036 "Gmsh.y" +#line 6049 "Gmsh.y" { (yyval.l) = (yyvsp[(3) - (4)].l); ;} break; case 575: -#line 6041 "Gmsh.y" +#line 6054 "Gmsh.y" { (yyval.l) = (yyvsp[(1) - (1)].l); ;} break; case 576: -#line 6043 "Gmsh.y" +#line 6056 "Gmsh.y" { (yyval.l) = (yyvsp[(1) - (1)].l); ;} break; case 577: -#line 6048 "Gmsh.y" +#line 6061 "Gmsh.y" { (yyval.l) = (yyvsp[(2) - (3)].l); ;} break; case 578: -#line 6053 "Gmsh.y" +#line 6066 "Gmsh.y" { (yyval.l) = List_Create(20,20,sizeof(char*)); List_Add((yyval.l), &((yyvsp[(1) - (1)].c))); @@ -13347,19 +13360,19 @@ yyreduce: break; case 579: -#line 6058 "Gmsh.y" +#line 6071 "Gmsh.y" { (yyval.l) = (yyvsp[(1) - (1)].l); ;} break; case 580: -#line 6060 "Gmsh.y" +#line 6073 "Gmsh.y" { List_Add((yyval.l), &((yyvsp[(3) - (3)].c))); ;} break; case 581: -#line 6064 "Gmsh.y" +#line 6077 "Gmsh.y" { for(int i = 0; i < List_Nbr((yyvsp[(3) - (3)].l)); i++){ char* c; @@ -13371,7 +13384,7 @@ yyreduce: break; case 582: -#line 6076 "Gmsh.y" +#line 6089 "Gmsh.y" { (yyval.l) = List_Create(20, 20, sizeof(char *)); if(!gmsh_yystringsymbols.count((yyvsp[(1) - (3)].c))) @@ -13388,21 +13401,21 @@ yyreduce: break; case 583: -#line 6090 "Gmsh.y" +#line 6103 "Gmsh.y" { (yyval.l) = treat_Struct_FullName_dot_tSTRING_ListOfString(NULL, (yyvsp[(1) - (5)].c), (yyvsp[(3) - (5)].c)); ;} break; case 584: -#line 6094 "Gmsh.y" +#line 6107 "Gmsh.y" { (yyval.l) = treat_Struct_FullName_dot_tSTRING_ListOfString((yyvsp[(1) - (7)].c), (yyvsp[(3) - (7)].c), (yyvsp[(5) - (7)].c)); ;} break; case 585: -#line 6101 "Gmsh.y" +#line 6114 "Gmsh.y" { char tmpstr[256]; sprintf(tmpstr, "_%d", (int)(yyvsp[(4) - (5)].d)); @@ -13413,7 +13426,7 @@ yyreduce: break; case 586: -#line 6109 "Gmsh.y" +#line 6122 "Gmsh.y" { char tmpstr[256]; sprintf(tmpstr, "_%d", (int)(yyvsp[(4) - (5)].d)); @@ -13424,7 +13437,7 @@ yyreduce: break; case 587: -#line 6117 "Gmsh.y" +#line 6130 "Gmsh.y" { char tmpstr[256]; sprintf(tmpstr, "_%d", (int)(yyvsp[(7) - (8)].d)); @@ -13435,23 +13448,23 @@ yyreduce: break; case 588: -#line 6128 "Gmsh.y" +#line 6141 "Gmsh.y" { (yyval.c) = (yyvsp[(1) - (1)].c); ;} break; case 589: -#line 6130 "Gmsh.y" +#line 6143 "Gmsh.y" { (yyval.c) = (yyvsp[(1) - (1)].c); ;} break; case 590: -#line 6133 "Gmsh.y" +#line 6146 "Gmsh.y" { (yyval.c) = (yyvsp[(3) - (4)].c); ;} break; /* Line 1267 of yacc.c. */ -#line 13455 "Gmsh.tab.cpp" +#line 13468 "Gmsh.tab.cpp" default: break; } YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc); @@ -13665,7 +13678,7 @@ yyreturn: } -#line 6136 "Gmsh.y" +#line 6149 "Gmsh.y" void assignVariable(const std::string &name, int index, int assignType, diff --git a/Parser/Gmsh.y b/Parser/Gmsh.y index 0e39b28650e3109ce9a9c5414d2fffac5023d7be..d84a1ad091fb799e74bcd4043a1e6acb1a7348ba 100644 --- a/Parser/Gmsh.y +++ b/Parser/Gmsh.y @@ -2416,6 +2416,19 @@ Transform : (inDimTags, outDimTags, action == "CombinedBoundary", true, action == "PointsOf"); } + else if(action == "DontSaveMesh"){ + // boundary operations are performed directly on GModel, which enables + // to compute the boundary of hybrid CAD models; this also automatically + // binds all boundary entities for OCC models + if(GModel::current()->getOCCInternals() && + GModel::current()->getOCCInternals()->getChanged()) + GModel::current()->getOCCInternals()->synchronize(GModel::current()); + if(GModel::current()->getGEOInternals()->getChanged()) + GModel::current()->getGEOInternals()->synchronize(GModel::current()); + r = GModel::current()->getBoundaryTags + (inDimTags, outDimTags, action == "CombinedBoundary", true, + action == "PointsOf"); + } else{ yymsg(0, "Unknown action on multiple shapes '%s'", $1); } diff --git a/Plugin/CMakeLists.txt b/Plugin/CMakeLists.txt index 5f37603afc7d6190cd15c071f95f51cc69265ba3..b2bc58942aaebae59971ce3af89ef5c57e5efc09 100644 --- a/Plugin/CMakeLists.txt +++ b/Plugin/CMakeLists.txt @@ -32,7 +32,7 @@ set(SRC Scal2Tens.cpp Scal2Vec.cpp CutMesh.cpp NewView.cpp - SimplePartition.cpp Crack.cpp DuplicateBoundaries.cpp ThinLayerFixMesh.cpp + SimplePartition.cpp Crack.cpp ThinLayerFixMesh.cpp FaultZone.cpp MeshSubEntities.cpp CVTRemesh.cpp diff --git a/Plugin/DuplicateBoundaries.cpp b/Plugin/DuplicateBoundaries.cpp deleted file mode 100644 index 92a91a763ca78522682b040f68284b34c5a236a3..0000000000000000000000000000000000000000 --- a/Plugin/DuplicateBoundaries.cpp +++ /dev/null @@ -1,3905 +0,0 @@ -// Gmsh - Copyright (C) 1997-2013 C. Geuzaine, J.-F. Remacle -// -// See the LICENSE.txt file for license information. Please report all -// bugs and problems to the public mailing list <gmsh@onelab.info>. - -#include "DuplicateBoundaries.h" -#include "GModel.h" -#include "discreteEdge.h" -#include "discreteFace.h" -#include "MElement.h" -#include "MLine.h" -#include "MTriangle.h" -#include "MQuadrangle.h" -#include "MPrism.h" -#include "MEdge.h" -#include <fstream> -#include <sstream> -#include "Context.h" - -StringXNumber DuplicateBoundariesOptions_Number[] = { - {GMSH_FULLRC, "Dummy", NULL, 1.}, -}; - -extern "C" -{ - GMSH_Plugin *GMSH_RegisterDuplicateBoundariesPlugin() - { - return new GMSH_DuplicateBoundariesPlugin(); - } -} - -std::string GMSH_DuplicateBoundariesPlugin::getHelp() const -{ - return "Plugin(DuplicateBoundaries) is not documented yet."; -} - -int GMSH_DuplicateBoundariesPlugin::getNbOptions() const -{ - return sizeof(DuplicateBoundariesOptions_Number) / sizeof(StringXNumber); -} - -StringXNumber *GMSH_DuplicateBoundariesPlugin::getOption(int iopt) -{ - return &DuplicateBoundariesOptions_Number[iopt]; -} - -class EdgeData{ -public: - EdgeData(MEdge e) : edge(e) {} - MEdge edge; - std::vector<MVertex*> data; -}; - -struct Less_EdgeData : public std::binary_function<EdgeData, EdgeData, bool> { - bool operator()(const EdgeData &e1, const EdgeData &e2) const - { - if(e1.edge.getMinVertex() < e2.edge.getMinVertex()) return true; - if(e1.edge.getMinVertex() > e2.edge.getMinVertex()) return false; - if(e1.edge.getMaxVertex() < e2.edge.getMaxVertex()) return true; - return false; - } -}; - -//OLF VERSION ONLY DUPLICATING NODES - -//PView *GMSH_DuplicateBoundariesPlugin::execute(PView *view) -//{ -// std::cout<<"starting DuplicateBoundaries"<<std::endl; -// GModel *m = GModel::current(); -// std::map<std::pair<MVertex*,GRegion*>,MVertex* > VertexAssociation; -// for (GModel::viter itv = m->firstVertex();itv != m->lastVertex();itv++){ -//// std::cout<<"entering first for"<<std::endl; -// GVertex* vTmp = (*itv); -// std::list<GRegion*> r = vTmp->regions(); -// std::cout<<"size of mesh_vertices: "<<vTmp->mesh_vertices.size()<<std::endl; -// MVertex *vMesh = vTmp->mesh_vertices[0]; -// std::cout<<"size of r: "<<r.size()<<std::endl; -// // for all regions, create association -//// for (int i = 0; i < vTmp->getNumMeshVertices();i++){ -//// std::cout<<"entering second for"<<std::endl; -//// MVertex* vMesh = vTmp->getMeshVertex(i); -//// for (GModel::riter itr = vTmp->regions().begin();itr != vTmp->regions().end();itr++){ -// for (std::list<GRegion*>::iterator itr = r.begin();itr != r.end();itr++){ -// std::cout<<"entering third for"<<std::endl; -// GRegion* vReg = (*itr); -// // std::cout<<"we have the region "<<vReg-> -// MVertex *newv = new MVertex(vMesh->x(), vMesh->y(), vMesh->z(), (GEntity*)vReg); -// vReg->mesh_vertices.push_back(newv); -// VertexAssociation[std::make_pair(vMesh,vReg)] = newv; -// std::cout<<"end third for"<<std::endl; -// } -//// std::cout<<"end second for"<<std::endl; -//// } -//// std::cout<<"end first for"<<std::endl; -// } -// std::cout<<"Phase 1 done for DuplicateBoundaries"<<std::endl; -// for (GModel::eiter ite = m->firstEdge();ite != m->lastEdge();ite++){ -// GEdge* eTmp = (*ite); -// for (int i = 0; i < eTmp->mesh_vertices.size();i++){ -// MVertex* vMesh = eTmp->mesh_vertices[i]; -// std::list<GRegion*> r = eTmp->regions(); -// for (std::list<GRegion*>::iterator itr = r.begin();itr != r.end();itr++){ -// GRegion* vReg = (*itr); -// MVertex *newv = new MVertex(vMesh->x(), vMesh->y(), vMesh->z(), (GEntity*)vReg); -// vReg->mesh_vertices.push_back(newv); -// VertexAssociation[std::make_pair(vMesh,vReg)] = newv; -// } -// } -// } -// std::cout<<"Phase 2 done for DuplicateBoundaries"<<std::endl; -// for (GModel::fiter itf = m->firstFace();itf != m->lastFace();itf++){ -// GFace* fTmp = (*itf); -// for (int i = 0; i < fTmp->mesh_vertices.size();i++){ -// MVertex* vMesh = fTmp->mesh_vertices[i]; -// std::list<GRegion*> r = fTmp->regions(); -// for (std::list<GRegion*>::iterator itr = r.begin();itr != r.end();itr++){ -// GRegion* vReg = (*itr); -// MVertex *newv = new MVertex(vMesh->x(), vMesh->y(), vMesh->z(), (GEntity*)vReg); -// vReg->mesh_vertices.push_back(newv); -// VertexAssociation[std::make_pair(vMesh,vReg)] = newv; -// } -// } -// } -// std::cout<<"Phase 3 done for DuplicateBoundaries"<<std::endl; -// for (GModel::riter itr = m->firstRegion();itr != m->lastRegion();itr++){ -// GRegion* rTmp = (*itr); -// for (int i = 0; i < rTmp->getNumMeshElements();i++){ -// MElement* elem = rTmp->getMeshElement(i); -// for (int j = 0;j < elem->getNumVertices();j++){ -// MVertex* vert = elem->getVertex(j); -// std::map<std::pair<MVertex*,GRegion*>,MVertex* >::iterator itMap = VertexAssociation.find(std::make_pair(vert,rTmp)); -// if (itMap != VertexAssociation.end()){ -// elem->setVertex(j,itMap->second); -// } -// } -// } -// } -// std::cout<<"End of DuplicateBoundaries"<<std::endl; -// return view; -//} - -double GMSH_DuplicateBoundariesPlugin::abs(double x){ - if (x < 0.0){ - return (-x); - } - else{ - return x; - } -} - -PView *GMSH_DuplicateBoundariesPlugin::executeBis(PView *view) -{ - std::cout<<"starting DuplicateBoundaries"<<std::endl; - GModel *m = GModel::current(); - m->setFactory("geo"); - std::set<GFace*> ToDuplicateList; - ToDuplicateList.clear(); - std::set<GFace*> ToDuplicateListBoundary; - ToDuplicateListBoundary.clear(); - std::vector<GFace*> facesBound; - facesBound.clear(); - std::map<GFace*,SPoint3> centers; - std::vector<std::pair<GFace*,GFace*> > pairs; - // int PhysicalSeeds = m->setPhysicalName("Seeds",3); - // - // //std::cout<<"number for seeds: "<<PhysicalSeeds<<" and for interface: "<<PhysicalInterface<<std::endl; - // - // for (GModel::riter itf= m->firstRegion();itf != m->lastRegion();itf++){ - // GRegion* fTmp = (*itf); - // fTmp->addPhysicalEntity(PhysicalSeeds); - // } - int PhysicalInterface = m->setPhysicalName("Interface",3); - std::cout<<"DEBUT INIT"<<std::endl; - for (GModel::fiter itf= m->firstFace();itf != m->lastFace();itf++){ - GFace* fTmp = (*itf); - - //for (unsigned int i = 0; i < fTmp->getNumMeshElements();i++){ - // MElement* elem = fTmp->getMeshElement(i); - //} - - if (fTmp->numRegions() == 2){ - ToDuplicateList.insert(fTmp); - } - else{ - facesBound.push_back(fTmp); - } - } - - for(unsigned int i=0;i<facesBound.size();i++){ - double x = 0.0; - double y = 0.0; - double z = 0.0; - - std::list<GVertex*> vertices; - - vertices = facesBound[i]->vertices(); - - for(std::list<GVertex*>::iterator it2=vertices.begin();it2!=vertices.end();it2++){ - x = x + (*it2)->x(); - y = y + (*it2)->y(); - z = z + (*it2)->z(); - } - - x = x/vertices.size(); - y = y/vertices.size(); - z = z/vertices.size(); - - centers.insert(std::pair<GFace*,SPoint3>(facesBound[i],SPoint3(x,y,z))); - } - - for(unsigned int i=0;i<facesBound.size();i++){ - for(unsigned int j=0;j<facesBound.size();j++){ - std::map<GFace*,SPoint3>::iterator it3 = centers.find(facesBound[i]); - std::map<GFace*,SPoint3>::iterator it4 = centers.find(facesBound[j]); - - SPoint3 p1 = it3->second; - SPoint3 p2 = it4->second; - - - // categories.push_back(val); - - // print_segment(p1,p2,file); - - if (abs((p2.x()-p1.x()-1.0))<0.0001){ - if (abs((p2.y()-p1.y()))<0.0001){ - if (abs((p2.z()-p1.z()))<0.0001){ - pairs.push_back(std::pair<GFace*,GFace*>(facesBound[i],facesBound[j])); - ToDuplicateListBoundary.insert(facesBound[i]); - }else if(abs((p2.z()-p1.z()-1.0))<0.0001){ - pairs.push_back(std::pair<GFace*,GFace*>(facesBound[i],facesBound[j])); - ToDuplicateListBoundary.insert(facesBound[i]); - }else if (abs((p1.z()-p2.z()-1.0))<0.0001){ - pairs.push_back(std::pair<GFace*,GFace*>(facesBound[i],facesBound[j])); - ToDuplicateListBoundary.insert(facesBound[i]); - } - }else if (abs((p2.y()-p1.y()-1.0))<0.0001){ - if (abs((p2.z()-p1.z()))<0.0001){ - pairs.push_back(std::pair<GFace*,GFace*>(facesBound[i],facesBound[j])); - ToDuplicateListBoundary.insert(facesBound[i]); - }else if (abs((p2.z()-p1.z()-1.0))<0.0001){ - pairs.push_back(std::pair<GFace*,GFace*>(facesBound[i],facesBound[j])); - ToDuplicateListBoundary.insert(facesBound[i]); - }else if (abs((p1.z()-p2.z()-1.0))<0.0001){ - pairs.push_back(std::pair<GFace*,GFace*>(facesBound[i],facesBound[j])); - ToDuplicateListBoundary.insert(facesBound[i]); - } - }else if (abs((p1.y()-p2.y()-1.0))<0.0001){ - if (abs((p2.z()-p1.z()))<0.0001){ - pairs.push_back(std::pair<GFace*,GFace*>(facesBound[i],facesBound[j])); - ToDuplicateListBoundary.insert(facesBound[i]); - }else if (abs((p2.z()-p1.z()-1.0))<0.0001){ - pairs.push_back(std::pair<GFace*,GFace*>(facesBound[i],facesBound[j])); - ToDuplicateListBoundary.insert(facesBound[i]); - }else if (abs((p1.z()-p2.z()-1.0))<0.0001){ - pairs.push_back(std::pair<GFace*,GFace*>(facesBound[i],facesBound[j])); - ToDuplicateListBoundary.insert(facesBound[i]); - } - } - }else if (abs((p1.x()-p2.x()-1.0))<0.0001){ - if (abs((p2.y()-p1.y()))<0.0001){ - if (abs((p2.z()-p1.z()))<0.0001){ - //NOTHING - }else if(abs((p2.z()-p1.z()-1.0))<0.0001){ - //NOTHING - }else if (abs((p1.z()-p2.z()-1.0))<0.0001){ - //NOTHING - } - }else if (abs((p2.y()-p1.y()-1.0))<0.0001){ - if (abs((p2.z()-p1.z()))<0.0001){ - //NOTHING - }else if (abs((p2.z()-p1.z()-1.0))<0.0001){ - //NOTHING - }else if (abs((p1.z()-p2.z()-1.0))<0.0001){ - //NOTHING - } - }else if (abs((p1.y()-p2.y()-1.0))<0.0001){ - if (abs((p2.z()-p1.z()))<0.0001){ - //NOTHING - }else if (abs((p2.z()-p1.z()-1.0))<0.0001){ - //NOTHING - }else if (abs((p1.z()-p2.z()-1.0))<0.0001){ - //NOTHING - } - } - }else if (abs((p1.x()-p2.x()))<0.0001){ - if (abs((p2.y()-p1.y()-1.0))<0.0001){ - if (abs((p2.z()-p1.z()))<0.0001){ - pairs.push_back(std::pair<GFace*,GFace*>(facesBound[i],facesBound[j])); - ToDuplicateListBoundary.insert(facesBound[i]); - }else if (abs((p2.z()-p1.z()-1.0))<0.0001){ - pairs.push_back(std::pair<GFace*,GFace*>(facesBound[i],facesBound[j])); - ToDuplicateListBoundary.insert(facesBound[i]); - }else if (abs((p1.z()-p2.z()-1.0))<0.0001){ - pairs.push_back(std::pair<GFace*,GFace*>(facesBound[i],facesBound[j])); - ToDuplicateListBoundary.insert(facesBound[i]); - } - }else if (abs((p1.y()-p2.y()-1.0))<0.0001){ - if (abs((p2.z()-p1.z()))<0.0001){ - //NOTHING - }else if (abs((p2.z()-p1.z()-1.0))<0.0001){ - //NOTHING - }else if (abs((p1.z()-p2.z()-1.0))<0.0001){ - //NOTHING - } - }else if (abs((p1.y()-p2.y()))<0.0001){ - if (abs((p2.z()-p1.z()-1.0))<0.0001){ - pairs.push_back(std::pair<GFace*,GFace*>(facesBound[i],facesBound[j])); - ToDuplicateListBoundary.insert(facesBound[i]); - }else if (abs((p1.z()-p2.z()-1.0))<0.0001){ - //NOTHING - } - } - } - } - } - - int counterNbDone = 10000; - //int tagEdges = 10000; - for (std::set<GFace*>::iterator itr = ToDuplicateList.begin();itr != ToDuplicateList.end();itr++){ - counterNbDone++; - GFace* fTmp = (*itr); - //on doit dupliquer la face, les noeuds, les aretes, puis creer une region entre les deux - std::map<MVertex*,MVertex* > VertexAssociation; - std::map<GVertex*,GVertex* > GVertexAssociation; - std::map<GEdge*,GEdge* > GEdgeAssociation; - std::list<GVertex*> vlist = fTmp->vertices(); - std::map<GVertex*,GEdge* > SurroudingEdges; - GRegion *rTmp = fTmp->getRegion(1); - std::list<GFace*> facesReg; - facesReg = rTmp->faces(); - //for (std::list<GFace*>::iterator it2=facesReg.begin();it2!=facesReg.end();it2++){ - // GFace* fTemp = (*it2); - //} - double xCenterReg = 0.0; - double yCenterReg = 0.0; - double zCenterReg = 0.0; - - int counterPts = 0; - for(std::list<GFace*>::iterator it2=facesReg.begin();it2!=facesReg.end();it2++){ - GFace* fTemp = (*it2); - std::list<GVertex*> verticesFace = fTemp->vertices(); - for (std::list<GVertex*>::iterator it3=verticesFace.begin();it3!=verticesFace.end();it3++){ - xCenterReg = xCenterReg + (*it3)->x(); - yCenterReg = yCenterReg + (*it3)->y(); - zCenterReg = zCenterReg + (*it3)->z(); - counterPts++; - } - } - - xCenterReg = xCenterReg/counterPts; - yCenterReg = yCenterReg/counterPts; - zCenterReg = zCenterReg/counterPts; - - for (std::list<GVertex*>::iterator itv = vlist.begin();itv != vlist.end();itv++){ - //duplication Gvertex - GVertex* vTmp = (*itv); - double ponderatedX = 0.99999999999 * vTmp->x() + 0.00000000001 * xCenterReg; - double ponderatedY = 0.99999999999 * vTmp->y() + 0.00000000001 * yCenterReg; - double ponderatedZ = 0.99999999999 * vTmp->z() + 0.00000000001 * zCenterReg; - // double ponderatedX = 1.0 * vTmp->x() + 0.0 * xCenterReg; - // double ponderatedY = 1.0 * vTmp->y() + 0.0 * yCenterReg; - // double ponderatedZ = 1.0 * vTmp->z() + 0.0 * zCenterReg; - //GVertex* newv = new gmshVertex(m,vTmp->prescribedMeshSizeAtVertex()); - GVertex* newv = m->addVertex(ponderatedX,ponderatedY,ponderatedZ,vTmp->prescribedMeshSizeAtVertex()); - GVertexAssociation[vTmp] = newv; - //creation des Gedge correspondantes - //GEdge* newE = new GEdge(m,tagEdges,vTmp,newv); - //tagEdges++; - //m->add(newE); - GEdge* newE = m->addLine(vTmp,newv); - SurroudingEdges[vTmp] = newE; - //maintenant traitement mesh - MVertex *vMesh = vTmp->mesh_vertices[0]; - MVertex *newMv = new MVertex(vMesh->x(), vMesh->y(), vMesh->z(), (GEntity*)newv); - VertexAssociation[vMesh] = newMv; - newv->addMeshVertex(newMv); - } - std::list<GEdge*> elist = fTmp->edges(); - std::vector<GEdge*> newEdgesVector; - std::vector<GFace*> SurroundingsFaces; - for (std::list<GEdge*>::iterator ite = elist.begin();ite != elist.end();ite++){ - //duplication Gedge - GEdge* eTmp = (*ite); - GEdge* newE = m->addLine(GVertexAssociation[eTmp->getEndVertex()],GVertexAssociation[eTmp->getBeginVertex()]); - GEdgeAssociation[eTmp] = newE; - newEdgesVector.push_back(newE); - //creation des GFace correspondantes - GEdge* firstE = SurroudingEdges.find(eTmp->getEndVertex())->second; - GEdge* lastE = SurroudingEdges.find(eTmp->getBeginVertex())->second; - std::vector<GEdge*> VecEdgesTmp; - VecEdgesTmp.push_back(eTmp); - VecEdgesTmp.push_back(firstE); - VecEdgesTmp.push_back(newE); - VecEdgesTmp.push_back(lastE); - std::vector<std::vector<GEdge*> > VecOfVecTmp; - VecOfVecTmp.push_back(VecEdgesTmp); - GFace* newFaceTmp = m->addPlanarFace(VecOfVecTmp); - SurroundingsFaces.push_back(newFaceTmp); - //maintenant traitement mesh - for (unsigned int i = 0; i < eTmp->mesh_vertices.size();i++){ - MVertex *vMesh = eTmp->mesh_vertices[i]; - MVertex *newMv = new MVertex(vMesh->x(), vMesh->y(), vMesh->z(), (GEntity*)newE); - VertexAssociation[vMesh] = newMv; - newE->addMeshVertex(newMv); - } - for (unsigned int i = 0; i < eTmp->getNumMeshElements();i++){ - MElement* elem = eTmp->getMeshElement(i); - MVertex *firstETmp = VertexAssociation.find(elem->getVertex(0))->second; - MVertex *lastETmp = VertexAssociation.find(elem->getVertex(1))->second; - MLine *newLine = new MLine(firstETmp,lastETmp); - newE->addLine(newLine); - } - } - std::vector<std::vector<GEdge*> > VecOfVec; - VecOfVec.push_back(newEdgesVector); - //creation de la nouvelle face - GFace* GFaceAssociation = m->addPlanarFace(VecOfVec); - //maintenant traitement mesh - for (unsigned int i = 0; i < fTmp->mesh_vertices.size();i++){ - MVertex *vMesh = fTmp->mesh_vertices[i]; - MVertex *newMv = new MVertex(vMesh->x(), vMesh->y(), vMesh->z(), (GEntity*)GFaceAssociation); - VertexAssociation[vMesh] = newMv; - GFaceAssociation->addMeshVertex(newMv); - } - for (unsigned int i = 0; i < fTmp->getNumMeshElements();i++){ - MElement* elem = fTmp->getMeshElement(i); - MVertex *firstE = VertexAssociation.find(elem->getVertex(0))->second; - MVertex *secondE = VertexAssociation.find(elem->getVertex(1))->second; - MVertex *thirdE = VertexAssociation.find(elem->getVertex(2))->second; - MTriangle *newTri = new MTriangle(firstE,secondE,thirdE); - GFaceAssociation->addTriangle(newTri); - - - - } - std::vector<GFace*> VectorFaces; - std::list<GFace*> listFaces; - VectorFaces.push_back(fTmp); - listFaces.push_back(fTmp); - for (unsigned int i = 0;i < SurroundingsFaces.size();i++){ - VectorFaces.push_back(SurroundingsFaces[i]); - listFaces.push_back(SurroundingsFaces[i]); - } - VectorFaces.push_back(GFaceAssociation); - listFaces.push_back(GFaceAssociation); - std::vector<std::vector<GFace*> > VecOfVecGFace; - VecOfVecGFace.push_back(VectorFaces); - //creation de la nouvelle region - - GRegion* createdRegion = new GRegion(m,counterNbDone); - createdRegion->addPhysicalEntity(PhysicalInterface); - createdRegion->set(listFaces); - m->add(createdRegion); - std::list<GFace*> RegFaces = rTmp->faces(); - std::list<GFace*>::iterator it = std::find(RegFaces.begin(), RegFaces.end(), fTmp); - std::cout<<(*it)->tag()<<std::endl; - if(it != RegFaces.end()) RegFaces.erase(it); - RegFaces.push_back(GFaceAssociation); - rTmp->set(RegFaces); - std::list<GFace*> NewFacesReg; - NewFacesReg = rTmp->faces(); - for (std::list<GFace*>::iterator it2=NewFacesReg.begin();it2!=NewFacesReg.end();it2++){ - GFace* fTemp = (*it2); - for (std::list<GEdge*>::iterator ite = elist.begin();ite != elist.end();ite++){ - GEdge* eTmp = (*ite); - GEdge* newE = GEdgeAssociation[eTmp]; - fTemp->replaceEdge(eTmp,newE); - } - } - for (unsigned int i = 0; i < fTmp->getNumMeshElements();i++){ - MElement* elem = fTmp->getMeshElement(i); - - - - MVertex *firstE = VertexAssociation.find(elem->getVertex(0))->second; - MVertex *secondE = VertexAssociation.find(elem->getVertex(1))->second; - MVertex *thirdE = VertexAssociation.find(elem->getVertex(2))->second; - - - - MPrism *newPri = new MPrism(elem->getVertex(0),elem->getVertex(1),elem->getVertex(2),firstE,secondE,thirdE); - - createdRegion->addPrism(newPri); - } - for (unsigned int i = 0; i < rTmp->getNumMeshElements();i++){ - MElement* elem = rTmp->getMeshElement(i); - for (int j = 0;j < elem->getNumVertices();j++){ - MVertex* vert = elem->getVertex(j); - std::map<MVertex*,MVertex* >::iterator itMap = VertexAssociation.find(vert); - if (itMap != VertexAssociation.end()){ - elem->setVertex(j,itMap->second); - } - } - } - int countTmp = 0; - //maitenant refonte points dans faces - for (std::list<GFace*>::iterator itTmp = NewFacesReg.begin();itTmp != NewFacesReg.end();itTmp++){ - GFace* GFaceTmp = (*itTmp); - countTmp++; - for (unsigned int i = 0; i < GFaceTmp->getNumMeshElements();i++){ - MElement* elem = GFaceTmp->getMeshElement(i); - for (int j = 0;j < elem->getNumVertices();j++){ - MVertex* vert = elem->getVertex(j); - std::map<MVertex*,MVertex* >::iterator itMap = VertexAssociation.find(vert); - if (itMap != VertexAssociation.end()){ - elem->setVertex(j,itMap->second); - - - - std::vector<MVertex*> FaceVerti = GFaceTmp->mesh_vertices; - std::vector<MVertex*>::iterator itHere = std::find(FaceVerti.begin(), FaceVerti.end(), vert); - if(itHere != FaceVerti.end()) { - FaceVerti.erase(itHere); - FaceVerti.push_back(itMap->second); - GFaceTmp->mesh_vertices = FaceVerti; - } - - - } - } - } - } - } - - //maintenant on attaque les faces au bord - for (std::set<GFace*>::iterator itr = ToDuplicateListBoundary.begin();itr != ToDuplicateListBoundary.end();itr++){ - counterNbDone++; - GFace* fTmp = (*itr); - //on doit dupliquer la face, les noeuds, les aretes, puis creer une region entre les deux - std::map<MVertex*,MVertex* > VertexAssociation; - std::map<GVertex*,GVertex* > GVertexAssociation; - std::map<GEdge*,GEdge* > GEdgeAssociation; - std::list<GVertex*> vlist = fTmp->vertices(); - std::map<GVertex*,GEdge* > SurroudingEdges; - GRegion *rTmp = fTmp->getRegion(0); - double xCenterReg = 0.0; - double yCenterReg = 0.0; - double zCenterReg = 0.0; - - std::list<GFace*> facesReg; - - facesReg = rTmp->faces(); - - int counterPts = 0; - for(std::list<GFace*>::iterator it2=facesReg.begin();it2!=facesReg.end();it2++){ - GFace* fTemp = (*it2); - std::list<GVertex*> verticesFace = fTemp->vertices(); - for (std::list<GVertex*>::iterator it3=verticesFace.begin();it3!=verticesFace.end();it3++){ - xCenterReg = xCenterReg + (*it3)->x(); - yCenterReg = yCenterReg + (*it3)->y(); - zCenterReg = zCenterReg + (*it3)->z(); - counterPts++; - } - } - - xCenterReg = xCenterReg/counterPts; - yCenterReg = yCenterReg/counterPts; - zCenterReg = zCenterReg/counterPts; - - for (std::list<GVertex*>::iterator itv = vlist.begin();itv != vlist.end();itv++){ - //duplication Gvertex - GVertex* vTmp = (*itv); - double ponderatedX = 0.99999999999 * vTmp->x() + 0.00000000001 * xCenterReg; - double ponderatedY = 0.99999999999 * vTmp->y() + 0.00000000001 * yCenterReg; - double ponderatedZ = 0.99999999999 * vTmp->z() + 0.00000000001 * zCenterReg; - GVertex* newv = m->addVertex(ponderatedX,ponderatedY,ponderatedZ,vTmp->prescribedMeshSizeAtVertex()); - GVertexAssociation[vTmp] = newv; - //creation des Gedge correspondantes - GEdge* newE = m->addLine(vTmp,newv); - SurroudingEdges[vTmp] = newE; - //maintenant traitement mesh - MVertex *vMesh = vTmp->mesh_vertices[0]; - MVertex *newMv = new MVertex(vMesh->x(), vMesh->y(), vMesh->z(), (GEntity*)newv); - VertexAssociation[vMesh] = newMv; - newv->addMeshVertex(newMv); - } - std::list<GEdge*> elist = fTmp->edges(); - std::vector<GEdge*> newEdgesVector; - std::vector<GFace*> SurroundingsFaces; - for (std::list<GEdge*>::iterator ite = elist.begin();ite != elist.end();ite++){ - //duplication Gedge - GEdge* eTmp = (*ite); - GEdge* newE = m->addLine(GVertexAssociation[eTmp->getEndVertex()],GVertexAssociation[eTmp->getBeginVertex()]); - GEdgeAssociation[eTmp] = newE; - newEdgesVector.push_back(newE); - //creation des GFace correspondantes - GEdge* firstE = SurroudingEdges.find(eTmp->getEndVertex())->second; - GEdge* lastE = SurroudingEdges.find(eTmp->getBeginVertex())->second; - std::vector<GEdge*> VecEdgesTmp; - VecEdgesTmp.push_back(eTmp); - VecEdgesTmp.push_back(firstE); - VecEdgesTmp.push_back(newE); - VecEdgesTmp.push_back(lastE); - std::vector<std::vector<GEdge*> > VecOfVecTmp; - VecOfVecTmp.push_back(VecEdgesTmp); - GFace* newFaceTmp = m->addPlanarFace(VecOfVecTmp); - SurroundingsFaces.push_back(newFaceTmp); - //maintenant traitement mesh - for (unsigned int i = 0; i < eTmp->mesh_vertices.size();i++){ - MVertex *vMesh = eTmp->mesh_vertices[i]; - MVertex *newMv = new MVertex(vMesh->x(), vMesh->y(), vMesh->z(), (GEntity*)newE); - VertexAssociation[vMesh] = newMv; - newE->addMeshVertex(newMv); - } - for (unsigned int i = 0; i < eTmp->getNumMeshElements();i++){ - MElement* elem = eTmp->getMeshElement(i); - MVertex *firstETmp = VertexAssociation.find(elem->getVertex(0))->second; - MVertex *lastETmp = VertexAssociation.find(elem->getVertex(1))->second; - MLine *newLine = new MLine(firstETmp,lastETmp); - newE->addLine(newLine); - } - } - std::vector<std::vector<GEdge*> > VecOfVec; - VecOfVec.push_back(newEdgesVector); - //creation de la nouvelle face - GFace* GFaceAssociation = m->addPlanarFace(VecOfVec); - //maintenant traitement mesh - for (unsigned int i = 0; i < fTmp->mesh_vertices.size();i++){ - MVertex *vMesh = fTmp->mesh_vertices[i]; - MVertex *newMv = new MVertex(vMesh->x(), vMesh->y(), vMesh->z(), (GEntity*)GFaceAssociation); - VertexAssociation[vMesh] = newMv; - GFaceAssociation->addMeshVertex(newMv); - } - for (unsigned int i = 0; i < fTmp->getNumMeshElements();i++){ - MElement* elem = fTmp->getMeshElement(i); - MVertex *firstE = VertexAssociation.find(elem->getVertex(0))->second; - MVertex *secondE = VertexAssociation.find(elem->getVertex(1))->second; - MVertex *thirdE = VertexAssociation.find(elem->getVertex(2))->second; - MTriangle *newTri = new MTriangle(firstE,secondE,thirdE); - GFaceAssociation->addTriangle(newTri); - } - std::vector<GFace*> VectorFaces; - std::list<GFace*> listFaces; - VectorFaces.push_back(fTmp); - listFaces.push_back(fTmp); - for (unsigned int i = 0;i < SurroundingsFaces.size();i++){ - VectorFaces.push_back(SurroundingsFaces[i]); - listFaces.push_back(SurroundingsFaces[i]); - } - VectorFaces.push_back(GFaceAssociation); - listFaces.push_back(GFaceAssociation); - std::vector<std::vector<GFace*> > VecOfVecGFace; - VecOfVecGFace.push_back(VectorFaces); - //creation de la nouvelle region - - GRegion* createdRegion = new GRegion(m,counterNbDone); - createdRegion->set(listFaces); - createdRegion->addPhysicalEntity(PhysicalInterface); - m->add(createdRegion); - - - std::list<GFace*> RegFaces = rTmp->faces(); - std::list<GFace*>::iterator it = std::find(RegFaces.begin(), RegFaces.end(), fTmp); - std::cout<<(*it)->tag()<<std::endl; - if(it != RegFaces.end()) RegFaces.erase(it); - RegFaces.push_back(GFaceAssociation); - rTmp->set(RegFaces); - std::list<GFace*> NewFacesReg; - NewFacesReg = rTmp->faces(); - for (std::list<GFace*>::iterator it2=NewFacesReg.begin();it2!=NewFacesReg.end();it2++){ - GFace* fTemp = (*it2); - for (std::list<GEdge*>::iterator ite = elist.begin();ite != elist.end();ite++){ - GEdge* eTmp = (*ite); - GEdge* newE = GEdgeAssociation[eTmp]; - fTemp->replaceEdge(eTmp,newE); - } - } - - - for (unsigned int i = 0; i < fTmp->getNumMeshElements();i++){ - MElement* elem = fTmp->getMeshElement(i); - MVertex *firstE = VertexAssociation.find(elem->getVertex(0))->second; - MVertex *secondE = VertexAssociation.find(elem->getVertex(1))->second; - MVertex *thirdE = VertexAssociation.find(elem->getVertex(2))->second; - MPrism *newPri = new MPrism(elem->getVertex(0),elem->getVertex(1),elem->getVertex(2),firstE,secondE,thirdE); - - createdRegion->addPrism(newPri); - } - for (unsigned int i = 0; i < rTmp->getNumMeshElements();i++){ - MElement* elem = rTmp->getMeshElement(i); - for (int j = 0;j < elem->getNumVertices();j++){ - MVertex* vert = elem->getVertex(j); - std::map<MVertex*,MVertex* >::iterator itMap = VertexAssociation.find(vert); - if (itMap != VertexAssociation.end()){ - elem->setVertex(j,itMap->second); - } - } - } - - - int countTmp = 0; - //maitenant refonte points dans faces - for (std::list<GFace*>::iterator itTmp = NewFacesReg.begin();itTmp != NewFacesReg.end();itTmp++){ - GFace* GFaceTmp = (*itTmp); - countTmp++; - for (unsigned int i = 0; i < GFaceTmp->getNumMeshElements();i++){ - MElement* elem = GFaceTmp->getMeshElement(i); - for (int j = 0;j < elem->getNumVertices();j++){ - MVertex* vert = elem->getVertex(j); - std::map<MVertex*,MVertex* >::iterator itMap = VertexAssociation.find(vert); - if (itMap != VertexAssociation.end()){ - elem->setVertex(j,itMap->second); - std::vector<MVertex*> FaceVerti = GFaceTmp->mesh_vertices; - std::vector<MVertex*>::iterator itHere = std::find(FaceVerti.begin(), FaceVerti.end(), vert); - if(itHere != FaceVerti.end()) { - FaceVerti.erase(itHere); - FaceVerti.push_back(itMap->second); - GFaceTmp->mesh_vertices = FaceVerti; - } - } - } - } - } - - - } - - /* - //now we put all info into a file - //to being with we put all boundary vertices into a unique set - std::vector<MEdge*> ListBoundaryVectors; - for (GModel::fiter itf= m->firstFace();itf != m->lastFace();itf++){ - GFace* fTmp = (*itf); - if (fTmp->regions().size() == 1){ - //for each node we are going to test the displacement - std::list<GEdge*> elist = fTmp->edges(); - for (std::list<GEdge*>::iterator ite = elist.begin();ite != elist.end();ite++){ - - } - } - } - std::ofstream file2("PeriodicMatches.txt"); - file2 << "PeriodicalNodes\n\n"; - file2 << "Displacement 1.0 0.0 0.0\n\n"; - file2 << "Displacement 0.0 1.0 0.0\n\n"; - file2 << "Displacement 0.0 0.0 1.0\n\n"; - */ - - - - - - - - return view; -} - -PView *GMSH_DuplicateBoundariesPlugin::executeFourth(PView *view) -{ - GModel *m = GModel::current(); - m->setFactory("geo"); - std::set<GFace*> ToDuplicateList; - ToDuplicateList.clear(); - std::set<GFace*> ToDuplicateListBoundary; - ToDuplicateListBoundary.clear(); - std::vector<GFace*> facesBound; - facesBound.clear(); - std::map<GFace*,SPoint3> centers; - std::vector<std::pair<GFace*,GFace*> > pairs; - std::vector<std::pair<GFace*,GFace*> > newPairs; - int PhysicalInterface = m->setPhysicalName("Interface",3); - for (GModel::fiter itf= m->firstFace();itf != m->lastFace();itf++){ - GFace* fTmp = (*itf); - if (fTmp->numRegions() == 2){ - ToDuplicateList.insert(fTmp); - } - else{ - ToDuplicateListBoundary.insert(fTmp); - facesBound.push_back(fTmp); - } - } - - - - - - - - - for(unsigned int i=0;i<facesBound.size();i++){ - double x = 0.0; - double y = 0.0; - double z = 0.0; - - std::list<GVertex*> vertices; - - vertices = facesBound[i]->vertices(); - - for(std::list<GVertex*>::iterator it2=vertices.begin();it2!=vertices.end();it2++){ - x = x + (*it2)->x(); - y = y + (*it2)->y(); - z = z + (*it2)->z(); - } - - x = x/vertices.size(); - y = y/vertices.size(); - z = z/vertices.size(); - - centers.insert(std::pair<GFace*,SPoint3>(facesBound[i],SPoint3(x,y,z))); - } - - for(unsigned int i=0;i<facesBound.size();i++){ - for(unsigned int j=0;j<facesBound.size();j++){ - std::map<GFace*,SPoint3>::iterator it3 = centers.find(facesBound[i]); - std::map<GFace*,SPoint3>::iterator it4 = centers.find(facesBound[j]); - - SPoint3 p1 = it3->second; - SPoint3 p2 = it4->second; - - - // categories.push_back(val); - - // print_segment(p1,p2,file); - - if (abs((p2.x()-p1.x()-1.0))<0.0001){ - if (abs((p2.y()-p1.y()))<0.0001){ - if (abs((p2.z()-p1.z()))<0.0001){ - pairs.push_back(std::pair<GFace*,GFace*>(facesBound[i],facesBound[j])); - ToDuplicateListBoundary.insert(facesBound[i]); - }else if(abs((p2.z()-p1.z()-1.0))<0.0001){ - pairs.push_back(std::pair<GFace*,GFace*>(facesBound[i],facesBound[j])); - ToDuplicateListBoundary.insert(facesBound[i]); - }else if (abs((p1.z()-p2.z()-1.0))<0.0001){ - pairs.push_back(std::pair<GFace*,GFace*>(facesBound[i],facesBound[j])); - ToDuplicateListBoundary.insert(facesBound[i]); - } - }else if (abs((p2.y()-p1.y()-1.0))<0.0001){ - if (abs((p2.z()-p1.z()))<0.0001){ - pairs.push_back(std::pair<GFace*,GFace*>(facesBound[i],facesBound[j])); - ToDuplicateListBoundary.insert(facesBound[i]); - }else if (abs((p2.z()-p1.z()-1.0))<0.0001){ - pairs.push_back(std::pair<GFace*,GFace*>(facesBound[i],facesBound[j])); - ToDuplicateListBoundary.insert(facesBound[i]); - }else if (abs((p1.z()-p2.z()-1.0))<0.0001){ - pairs.push_back(std::pair<GFace*,GFace*>(facesBound[i],facesBound[j])); - ToDuplicateListBoundary.insert(facesBound[i]); - } - }else if (abs((p1.y()-p2.y()-1.0))<0.0001){ - if (abs((p2.z()-p1.z()))<0.0001){ - pairs.push_back(std::pair<GFace*,GFace*>(facesBound[i],facesBound[j])); - ToDuplicateListBoundary.insert(facesBound[i]); - }else if (abs((p2.z()-p1.z()-1.0))<0.0001){ - pairs.push_back(std::pair<GFace*,GFace*>(facesBound[i],facesBound[j])); - ToDuplicateListBoundary.insert(facesBound[i]); - }else if (abs((p1.z()-p2.z()-1.0))<0.0001){ - pairs.push_back(std::pair<GFace*,GFace*>(facesBound[i],facesBound[j])); - ToDuplicateListBoundary.insert(facesBound[i]); - } - } - }else if (abs((p1.x()-p2.x()-1.0))<0.0001){ - if (abs((p2.y()-p1.y()))<0.0001){ - if (abs((p2.z()-p1.z()))<0.0001){ - //NOTHING - }else if(abs((p2.z()-p1.z()-1.0))<0.0001){ - //NOTHING - }else if (abs((p1.z()-p2.z()-1.0))<0.0001){ - //NOTHING - } - }else if (abs((p2.y()-p1.y()-1.0))<0.0001){ - if (abs((p2.z()-p1.z()))<0.0001){ - //NOTHING - }else if (abs((p2.z()-p1.z()-1.0))<0.0001){ - //NOTHING - }else if (abs((p1.z()-p2.z()-1.0))<0.0001){ - //NOTHING - } - }else if (abs((p1.y()-p2.y()-1.0))<0.0001){ - if (abs((p2.z()-p1.z()))<0.0001){ - //NOTHING - }else if (abs((p2.z()-p1.z()-1.0))<0.0001){ - //NOTHING - }else if (abs((p1.z()-p2.z()-1.0))<0.0001){ - //NOTHING - } - } - }else if (abs((p1.x()-p2.x()))<0.0001){ - if (abs((p2.y()-p1.y()-1.0))<0.0001){ - if (abs((p2.z()-p1.z()))<0.0001){ - pairs.push_back(std::pair<GFace*,GFace*>(facesBound[i],facesBound[j])); - ToDuplicateListBoundary.insert(facesBound[i]); - }else if (abs((p2.z()-p1.z()-1.0))<0.0001){ - pairs.push_back(std::pair<GFace*,GFace*>(facesBound[i],facesBound[j])); - ToDuplicateListBoundary.insert(facesBound[i]); - }else if (abs((p1.z()-p2.z()-1.0))<0.0001){ - pairs.push_back(std::pair<GFace*,GFace*>(facesBound[i],facesBound[j])); - ToDuplicateListBoundary.insert(facesBound[i]); - } - }else if (abs((p1.y()-p2.y()-1.0))<0.0001){ - if (abs((p2.z()-p1.z()))<0.0001){ - //NOTHING - }else if (abs((p2.z()-p1.z()-1.0))<0.0001){ - //NOTHING - }else if (abs((p1.z()-p2.z()-1.0))<0.0001){ - //NOTHING - } - }else if (abs((p1.y()-p2.y()))<0.0001){ - if (abs((p2.z()-p1.z()-1.0))<0.0001){ - pairs.push_back(std::pair<GFace*,GFace*>(facesBound[i],facesBound[j])); - ToDuplicateListBoundary.insert(facesBound[i]); - }else if (abs((p1.z()-p2.z()-1.0))<0.0001){ - //NOTHING - } - } - } - } - } - - - - - - - - - - - std::map<std::pair<MVertex*,GRegion*>,MVertex* > VertexGlobalAssociation; - std::map<std::pair<GVertex*,GRegion*>,GVertex* > GVertexGlobalAssociation; - std::map<std::pair<GEdge*,GRegion*>,GEdge* > GEdgeGlobalAssociation; - std::map<std::pair<GFace*,GRegion*>,GFace* > GFaceGlobalAssociation; - - for (GModel::riter itr= m->firstRegion();itr != m->lastRegion();itr++){ - GRegion* rTmp = (*itr); - std::list<GFace*> RegFaces = rTmp->faces(); - std::map<MVertex*,MVertex* > VertexAssociation; - std::map<GVertex*,GVertex* > GVertexAssociation; - std::map<GEdge*,GEdge* > GEdgeAssociation; - //int counterNbDone = 10000; - double xCenterReg = 0.0; - double yCenterReg = 0.0; - double zCenterReg = 0.0; - int counterPts = 0; - for(std::list<GFace*>::iterator it2=RegFaces.begin();it2!=RegFaces.end();it2++){ - GFace* fTemp = (*it2); - std::list<GVertex*> verticesFace = fTemp->vertices(); - for (std::list<GVertex*>::iterator it3=verticesFace.begin();it3!=verticesFace.end();it3++){ - xCenterReg = xCenterReg + (*it3)->x(); - yCenterReg = yCenterReg + (*it3)->y(); - zCenterReg = zCenterReg + (*it3)->z(); - counterPts++; - } - } - xCenterReg = xCenterReg/counterPts; - yCenterReg = yCenterReg/counterPts; - zCenterReg = zCenterReg/counterPts; - //duplication noeud et aretes au niveau de la region directement - std::list<GVertex*> vlist; - - - std::list<GFace*> listFacesTmp = rTmp->faces(); - for (std::list<GFace*>::iterator itTp = listFacesTmp.begin();itTp != listFacesTmp.end();itTp++){ - std::list<GVertex*> vlist2; - vlist2 = (*itTp)->vertices(); - for (std::list<GVertex*>::iterator itTp2 = vlist2.begin();itTp2 != vlist2.end();itTp2++){ - if(std::find(vlist.begin(), vlist.end(), *itTp2) == vlist.end()) - vlist.push_back(*itTp2); - } - } - - - for (std::list<GVertex*>::iterator itv = vlist.begin();itv != vlist.end();itv++){ - //duplication Gvertex - GVertex* vTmp = (*itv); - double ponderatedX = 0.99999999999 * vTmp->x() + 0.00000000001 * xCenterReg; - double ponderatedY = 0.99999999999 * vTmp->y() + 0.00000000001 * yCenterReg; - double ponderatedZ = 0.99999999999 * vTmp->z() + 0.00000000001 * zCenterReg; - GVertex* newv = m->addVertex(ponderatedX,ponderatedY,ponderatedZ,vTmp->prescribedMeshSizeAtVertex()); - GVertexAssociation[vTmp] = newv; - GVertexGlobalAssociation[std::make_pair(vTmp,rTmp)] = newv; - //creation des Gedge correspondantes - // GEdge* newE = m->addLine(vTmp,newv); - // SurroudingEdges[vTmp] = newE; - //maintenant traitement mesh - MVertex *vMesh = vTmp->mesh_vertices[0]; - MVertex *newMv = new MVertex(vMesh->x(), vMesh->y(), vMesh->z(), (GEntity*)newv); - VertexAssociation[vMesh] = newMv; - VertexGlobalAssociation[std::make_pair(vMesh,rTmp)] = newMv; - newv->addMeshVertex(newMv); - } - //maintenant on soccupe de duppliquer les edges de la region - std::list<GEdge*> elist = rTmp->edges(); - - std::vector<GFace*> SurroundingsFaces; - for (std::list<GEdge*>::iterator ite = elist.begin();ite != elist.end();ite++){ - //duplication Gedge - GEdge* eTmp = (*ite); - GEdge* newE = m->addLine(GVertexAssociation[eTmp->getEndVertex()],GVertexAssociation[eTmp->getBeginVertex()]); - GEdgeAssociation[eTmp] = newE; - GEdgeGlobalAssociation[std::make_pair(eTmp,rTmp)] = newE; - //creation des GFace correspondantes - // GEdge* firstE = SurroudingEdges.find(eTmp->getEndVertex())->second; - // GEdge* lastE = SurroudingEdges.find(eTmp->getBeginVertex())->second; - // std::vector<GEdge*> VecEdgesTmp; - // VecEdgesTmp.push_back(eTmp); - // VecEdgesTmp.push_back(firstE); - // VecEdgesTmp.push_back(newE); - // VecEdgesTmp.push_back(lastE); - // std::vector<std::vector<GEdge*> > VecOfVecTmp; - // VecOfVecTmp.push_back(VecEdgesTmp); - // GFace* newFaceTmp = m->addPlanarFace(VecOfVecTmp); - // SurroundingsFaces.push_back(newFaceTmp); - //maintenant traitement mesh - for (unsigned int i = 0; i < eTmp->mesh_vertices.size();i++){ - MVertex *vMesh = eTmp->mesh_vertices[i]; - MVertex *newMv = new MVertex(vMesh->x(), vMesh->y(), vMesh->z(), (GEntity*)newE); - VertexAssociation[vMesh] = newMv; - VertexGlobalAssociation[std::make_pair(vMesh,rTmp)] = newMv; - newE->addMeshVertex(newMv); - } - for (unsigned int i = 0; i < eTmp->getNumMeshElements();i++){ - MElement* elem = eTmp->getMeshElement(i); - MVertex *firstETmp = VertexAssociation.find(elem->getVertex(0))->second; - MVertex *lastETmp = VertexAssociation.find(elem->getVertex(1))->second; - MLine *newLine = new MLine(firstETmp,lastETmp); - newE->addLine(newLine); - } - } - for (std::list<GFace*>::iterator itf = RegFaces.begin();itf != RegFaces.end();itf++){ - GFace* fTmp = (*itf); - std::vector<GEdge*> newEdgesVector; - std::list<GEdge*> elistFace = fTmp->edges(); - for (std::list<GEdge*>::iterator ite = elistFace.begin();ite != elistFace.end();ite++){ - GEdge* eTmp = (*ite); - GEdge* eToFind = GEdgeAssociation[eTmp]; - newEdgesVector.push_back(eToFind); - } - std::vector<std::vector<GEdge*> > VecOfVec; - VecOfVec.push_back(newEdgesVector); - //creation de la nouvelle face - GFace* GFaceAssociation = m->addPlanarFace(VecOfVec); - //maintenant traitement mesh - for (unsigned int i = 0; i < fTmp->mesh_vertices.size();i++){ - MVertex *vMesh = fTmp->mesh_vertices[i]; - MVertex *newMv = new MVertex(vMesh->x(), vMesh->y(), vMesh->z(), (GEntity*)GFaceAssociation); - VertexAssociation[vMesh] = newMv; - VertexGlobalAssociation[std::make_pair(vMesh,rTmp)] = newMv; - GFaceAssociation->addMeshVertex(newMv); - } - for (unsigned int i = 0; i < fTmp->getNumMeshElements();i++){ - MElement* elem = fTmp->getMeshElement(i); - MVertex *firstE = VertexAssociation.find(elem->getVertex(0))->second; - MVertex *secondE = VertexAssociation.find(elem->getVertex(1))->second; - MVertex *thirdE = VertexAssociation.find(elem->getVertex(2))->second; - MTriangle *newTri = new MTriangle(firstE,secondE,thirdE); - GFaceAssociation->addTriangle(newTri); - } - GFaceGlobalAssociation[std::make_pair(fTmp,rTmp)] = GFaceAssociation; - } - } - int counterNbDone = 10000; - //maintenant on va traiter les faces initiales - for (std::set<GFace*>::iterator itf = ToDuplicateList.begin();itf != ToDuplicateList.end();itf++){ - counterNbDone++; - GFace* fTmp = (*itf); - GRegion* reg1 = fTmp->getRegion(0); - GRegion* reg2 = fTmp->getRegion(1); - //pour commencer on cree des aretes entre les vertex - std::list<GVertex*> vlist = fTmp->vertices(); - std::map<GVertex*,GEdge* > SurroudingEdges; - for (std::list<GVertex*>::iterator itv = vlist.begin();itv != vlist.end();itv++){ - GVertex* vTmp = (*itv); - GVertex* v1=0; - GVertex* v2=0; - std::map<std::pair<GVertex*,GRegion*>,GVertex* >::iterator itMap = GVertexGlobalAssociation.find(std::make_pair(vTmp,reg1)); - if (itMap != GVertexGlobalAssociation.end()){ - v1 = itMap->second; - } - itMap = GVertexGlobalAssociation.find(std::make_pair(vTmp,reg2)); - if (itMap != GVertexGlobalAssociation.end()){ - v2 = itMap->second; - } - GEdge* newE = m->addLine(v1,v2); - SurroudingEdges[vTmp] = newE; - } - //ici tous les vertex sont traites - //on va traiter les edges - std::list<GEdge*> elist = fTmp->edges(); - std::vector<GEdge*> newEdgesVector; - std::vector<GFace*> SurroundingsFaces; - for (std::list<GEdge*>::iterator ite = elist.begin();ite != elist.end();ite++){ - //duplication Gedge - GEdge* eTmp = (*ite); - GEdge* e1=0; - GEdge* e2=0; - std::map<std::pair<GEdge*,GRegion*>,GEdge* >::iterator itMap = GEdgeGlobalAssociation.find(std::make_pair(eTmp,reg1)); - if (itMap != GEdgeGlobalAssociation.end()){ - e1 = itMap->second; - } - itMap = GEdgeGlobalAssociation.find(std::make_pair(eTmp,reg2)); - if (itMap != GEdgeGlobalAssociation.end()){ - e2 = itMap->second; - } - //creation des GFace correspondantes - GEdge* firstE = SurroudingEdges.find(eTmp->getBeginVertex())->second; - GEdge* lastE = SurroudingEdges.find(eTmp->getEndVertex())->second; - if (firstE->getBeginVertex() != e1->getEndVertex()){ - firstE->reverse(); - } - if (firstE->getBeginVertex() != e1->getEndVertex()){ - e1->reverse(); - } - if (firstE->getBeginVertex() != e1->getEndVertex()){ - firstE->reverse(); - } - if (e2->getBeginVertex() != firstE->getEndVertex()){ - e2->reverse(); - } - if (lastE->getBeginVertex() != e2->getEndVertex()){ - lastE->reverse(); - } - std::vector<GEdge*> VecEdgesTmp; - VecEdgesTmp.push_back(e1); - VecEdgesTmp.push_back(firstE); - VecEdgesTmp.push_back(e2); - VecEdgesTmp.push_back(lastE); - std::vector<std::vector<GEdge*> > VecOfVecTmp; - VecOfVecTmp.push_back(VecEdgesTmp); - GFace* newFaceTmp = m->addPlanarFace(VecOfVecTmp); - SurroundingsFaces.push_back(newFaceTmp); - } - std::vector<GFace*> VectorFaces; - std::list<GFace*> listFaces; - GFace* f1; - GFace* f2; - std::map<std::pair<GFace*,GRegion*>,GFace* >::iterator itMap = GFaceGlobalAssociation.find(std::make_pair(fTmp,reg1)); - if (itMap != GFaceGlobalAssociation.end()){ - f1 = itMap->second; - } - itMap = GFaceGlobalAssociation.find(std::make_pair(fTmp,reg2)); - if (itMap != GFaceGlobalAssociation.end()){ - f2 = itMap->second; - } - VectorFaces.push_back(f1); - listFaces.push_back(f1); - for (unsigned int i = 0;i < SurroundingsFaces.size();i++){ - VectorFaces.push_back(SurroundingsFaces[i]); - listFaces.push_back(SurroundingsFaces[i]); - } - VectorFaces.push_back(f2); - listFaces.push_back(f2); - std::vector<std::vector<GFace*> > VecOfVecGFace; - VecOfVecGFace.push_back(VectorFaces); - //creation de la nouvelle region - GRegion* createdRegion = new GRegion(m,counterNbDone); - createdRegion->addPhysicalEntity(PhysicalInterface); - createdRegion->set(listFaces); - m->add(createdRegion); - for (unsigned int i = 0; i < fTmp->getNumMeshElements();i++){ - MElement* elem = fTmp->getMeshElement(i); - MVertex* v1=0; - MVertex* v2=0; - MVertex* v3=0; - MVertex* v4=0; - MVertex* v5=0; - MVertex* v6=0; - std::map<std::pair<MVertex*,GRegion*>,MVertex* >::iterator itMap = VertexGlobalAssociation.find(std::make_pair(elem->getVertex(0),reg1)); - if (itMap != VertexGlobalAssociation.end()){ - v1 = itMap->second; - } - itMap = VertexGlobalAssociation.find(std::make_pair(elem->getVertex(1),reg1)); - if (itMap != VertexGlobalAssociation.end()){ - v2 = itMap->second; - } - itMap = VertexGlobalAssociation.find(std::make_pair(elem->getVertex(2),reg1)); - if (itMap != VertexGlobalAssociation.end()){ - v3 = itMap->second; - } - itMap = VertexGlobalAssociation.find(std::make_pair(elem->getVertex(0),reg2)); - if (itMap != VertexGlobalAssociation.end()){ - v4 = itMap->second; - } - itMap = VertexGlobalAssociation.find(std::make_pair(elem->getVertex(1),reg2)); - if (itMap != VertexGlobalAssociation.end()){ - v5 = itMap->second; - } - itMap = VertexGlobalAssociation.find(std::make_pair(elem->getVertex(2),reg2)); - if (itMap != VertexGlobalAssociation.end()){ - v6 = itMap->second; - } - MPrism *newPri = new MPrism(v1,v2,v3,v4,v5,v6); - - createdRegion->addPrism(newPri); - } - for (unsigned int i = 0; i < reg1->getNumMeshElements();i++){ - MElement* elem = reg1->getMeshElement(i); - for (int j = 0;j < elem->getNumVertices();j++){ - MVertex* vert = elem->getVertex(j); - std::map<std::pair<MVertex*,GRegion*>,MVertex* >::iterator itMap = VertexGlobalAssociation.find(std::make_pair(vert,reg1)); - if (itMap != VertexGlobalAssociation.end()){ - elem->setVertex(j,itMap->second); - } - } - } - for (unsigned int i = 0; i < reg2->getNumMeshElements();i++){ - MElement* elem = reg2->getMeshElement(i); - for (int j = 0;j < elem->getNumVertices();j++){ - MVertex* vert = elem->getVertex(j); - std::map<std::pair<MVertex*,GRegion*>,MVertex* >::iterator itMap = VertexGlobalAssociation.find(std::make_pair(vert,reg2)); - if (itMap != VertexGlobalAssociation.end()){ - elem->setVertex(j,itMap->second); - } - } - } - } - //maintenant on va traiter les faces du bord - for (std::set<GFace*>::iterator itf = ToDuplicateListBoundary.begin();itf != ToDuplicateListBoundary.end();itf++){ - counterNbDone++; - GFace* fTmp = (*itf); - GRegion* reg1 = fTmp->getRegion(0); - //pour commencer on cree des aretes entre les vertex - std::list<GVertex*> vlist = fTmp->vertices(); - std::map<GVertex*,GEdge* > SurroudingEdges; - for (std::list<GVertex*>::iterator itv = vlist.begin();itv != vlist.end();itv++){ - GVertex* vTmp = (*itv); - GVertex* v1=0; - std::map<std::pair<GVertex*,GRegion*>,GVertex* >::iterator itMap = GVertexGlobalAssociation.find(std::make_pair(vTmp,reg1)); - if (itMap != GVertexGlobalAssociation.end()){ - v1 = itMap->second; - } - GEdge* newE = m->addLine(v1,vTmp); - SurroudingEdges[vTmp] = newE; - } - //ici tous les vertex sont traites - //on va traiter les edges - std::list<GEdge*> elist = fTmp->edges(); - std::vector<GEdge*> newEdgesVector; - std::vector<GFace*> SurroundingsFaces; - for (std::list<GEdge*>::iterator ite = elist.begin();ite != elist.end();ite++){ - //duplication Gedge - GEdge* eTmp = (*ite); - GEdge* e1=0; - std::map<std::pair<GEdge*,GRegion*>,GEdge* >::iterator itMap = GEdgeGlobalAssociation.find(std::make_pair(eTmp,reg1)); - if (itMap != GEdgeGlobalAssociation.end()){ - e1 = itMap->second; - } - //creation des GFace correspondantes - GEdge* firstE = SurroudingEdges.find(eTmp->getBeginVertex())->second; - GEdge* lastE = SurroudingEdges.find(eTmp->getEndVertex())->second; - if (firstE->getBeginVertex() != e1->getEndVertex()){ - firstE->reverse(); - } - if (firstE->getBeginVertex() != e1->getEndVertex()){ - e1->reverse(); - } - if (firstE->getBeginVertex() != e1->getEndVertex()){ - firstE->reverse(); - } - if (eTmp->getBeginVertex() != firstE->getEndVertex()){ - eTmp->reverse(); - } - if (lastE->getBeginVertex() != eTmp->getEndVertex()){ - lastE->reverse(); - } - std::vector<GEdge*> VecEdgesTmp; - VecEdgesTmp.push_back(e1); - VecEdgesTmp.push_back(firstE); - VecEdgesTmp.push_back(eTmp); - VecEdgesTmp.push_back(lastE); - std::vector<std::vector<GEdge*> > VecOfVecTmp; - VecOfVecTmp.push_back(VecEdgesTmp); - GFace* newFaceTmp = m->addPlanarFace(VecOfVecTmp); - SurroundingsFaces.push_back(newFaceTmp); - } - std::vector<GFace*> VectorFaces; - std::list<GFace*> listFaces; - GFace* f1; - std::map<std::pair<GFace*,GRegion*>,GFace* >::iterator itMap = GFaceGlobalAssociation.find(std::make_pair(fTmp,reg1)); - if (itMap != GFaceGlobalAssociation.end()){ - f1 = itMap->second; - } - VectorFaces.push_back(f1); - listFaces.push_back(f1); - for (unsigned int i = 0;i < SurroundingsFaces.size();i++){ - VectorFaces.push_back(SurroundingsFaces[i]); - listFaces.push_back(SurroundingsFaces[i]); - } - VectorFaces.push_back(fTmp); - listFaces.push_back(fTmp); - std::vector<std::vector<GFace*> > VecOfVecGFace; - VecOfVecGFace.push_back(VectorFaces); - //creation de la nouvelle region - GRegion* createdRegion = new GRegion(m,counterNbDone); - createdRegion->addPhysicalEntity(PhysicalInterface); - createdRegion->set(listFaces); - m->add(createdRegion); - for (unsigned int i = 0; i < fTmp->getNumMeshElements();i++){ - MElement* elem = fTmp->getMeshElement(i); - MVertex* v1=0; - MVertex* v2=0; - MVertex* v3=0; - std::map<std::pair<MVertex*,GRegion*>,MVertex* >::iterator itMap = VertexGlobalAssociation.find(std::make_pair(elem->getVertex(0),reg1)); - if (itMap != VertexGlobalAssociation.end()){ - v1 = itMap->second; - } - itMap = VertexGlobalAssociation.find(std::make_pair(elem->getVertex(1),reg1)); - if (itMap != VertexGlobalAssociation.end()){ - v2 = itMap->second; - } - itMap = VertexGlobalAssociation.find(std::make_pair(elem->getVertex(2),reg1)); - if (itMap != VertexGlobalAssociation.end()){ - v3 = itMap->second; - } - MPrism *newPri = new MPrism(v1,v2,v3,elem->getVertex(0),elem->getVertex(1),elem->getVertex(2)); - - createdRegion->addPrism(newPri); - } - for (unsigned int i = 0; i < reg1->getNumMeshElements();i++){ - MElement* elem = reg1->getMeshElement(i); - for (int j = 0;j < elem->getNumVertices();j++){ - MVertex* vert = elem->getVertex(j); - std::map<std::pair<MVertex*,GRegion*>,MVertex* >::iterator itMap = VertexGlobalAssociation.find(std::make_pair(vert,reg1)); - if (itMap != VertexGlobalAssociation.end()){ - elem->setVertex(j,itMap->second); - } - } - } - } - std::ofstream file("MicrostructurePolycrystal3D.pos"); - file << "View \"test\" {\n"; - - std::ofstream file2("PERIODIC.map"); - for (std::vector<std::pair<GFace*,GFace*> >::iterator itP = pairs.begin();itP != pairs.end();itP++){ - std::pair<GFace*,GFace*> pairTmp = (*itP); - GFace* ToReplaceFace = pairTmp.second; - GRegion* rTmp = ToReplaceFace->getRegion(0); - std::map<std::pair<GFace*,GRegion*>,GFace* >::iterator itMap = GFaceGlobalAssociation.find(std::make_pair(ToReplaceFace,rTmp)); - if (itMap != GFaceGlobalAssociation.end()){ - GFace* associatedFace = (*itMap).second; - - - - - - - std::map<GFace*,SPoint3>::iterator it3 = centers.find(pairTmp.first); - std::map<GFace*,SPoint3>::iterator it4 = centers.find(ToReplaceFace); - - SPoint3 p1 = it3->second; - SPoint3 p2 = it4->second; - - //double delta_x = fabs(p2.x()-p1.x()); - //double delta_y = fabs(p2.y()-p1.y()); - //double delta_z = fabs(p2.z()-p1.z()); - - - file << "SL (" - << p1.x() << ", " << p1.y() << ", " << p1.z() << ", " - << p2.x() << ", " << p2.y() << ", " << p2.z() - << "){10, 20};\n"; - - //file2 << "PERIODIC\tSURFACE"<<faces[i]->tag() << "\tSURFACE" << faces[j]->tag() << "\t" << p2.x()-p1.x() << "\t" << p2.y()-p1.y() << "\t" << p2.z()-p1.z() << "\n"; - if (abs((p2.x()-p1.x()-1.0))<0.0001){ - if (abs((p2.y()-p1.y()))<0.0001){ - if (abs((p2.z()-p1.z()))<0.0001){ - file2 << "NSET\tFRONT = FRONT + SURFACE"<<ToReplaceFace->tag()<<"\n"; - file2 << "NSET\tBACK = BACK + SURFACE"<<pairTmp.first->tag()<<"\n"; - }else if(abs((p2.z()-p1.z()-1.0))<0.0001){ - file2 << "NSET\tFRONTTOP = FRONTTOP + SURFACE"<<ToReplaceFace->tag()<<"\n"; - file2 << "NSET\tBACKBOTTOM = BACKBOTTOM + SURFACE"<<pairTmp.first->tag()<<"\n"; - }else if (abs((p1.z()-p2.z()-1.0))<0.0001){ - file2 << "NSET\tFRONTBOTTOM = FRONTBOTTOM + SURFACE"<<ToReplaceFace->tag()<<"\n"; - file2 << "NSET\tBACKTOP = BACKTOP + SURFACE"<<pairTmp.first->tag()<<"\n"; - } - }else if (abs((p2.y()-p1.y()-1.0))<0.0001){ - if (abs((p2.z()-p1.z()))<0.0001){ - file2 << "NSET\tFRONTRIGHT = FRONTRIGHT + SURFACE"<<ToReplaceFace->tag()<<"\n"; - file2 << "NSET\tBACKLEFT = BACKLEFT + SURFACE"<<pairTmp.first->tag()<<"\n"; - }else if (abs((p2.z()-p1.z()-1.0))<0.0001){ - file2 << "NSET\tFRONTRIGHTTOP = FRONTRIGHTTOP + SURFACE"<<ToReplaceFace->tag()<<"\n"; - file2 << "NSET\tBACKLEFTBOTTOM = BACKLEFTBOTTOM + SURFACE"<<pairTmp.first->tag()<<"\n"; - }else if (abs((p1.z()-p2.z()-1.0))<0.0001){ - file2 << "NSET\tFRONTRIGHTBOTTOM = FRONTRIGHTBOTTOM + SURFACE"<<ToReplaceFace->tag()<<"\n"; - file2 << "NSET\tBACKLEFTTOP = BACKLEFTTOP + SURFACE"<<pairTmp.first->tag()<<"\n"; - } - }else if (abs((p1.y()-p2.y()-1.0))<0.0001){ - if (abs((p2.z()-p1.z()))<0.0001){ - file2 << "NSET\tFRONTLEFT = FRONTLEFT + SURFACE"<<ToReplaceFace->tag()<<"\n"; - file2 << "NSET\tBACKRIGHT = BACKRIGHT + SURFACE"<<pairTmp.first->tag()<<"\n"; - }else if (abs((p2.z()-p1.z()-1.0))<0.0001){ - file2 << "NSET\tFRONTLEFTTOP = FRONTLEFTTOP + SURFACE"<<ToReplaceFace->tag()<<"\n"; - file2 << "NSET\tBACKRIGHTBOTTOM = BACKRIGHTBOTTOM + SURFACE"<<pairTmp.first->tag()<<"\n"; - }else if (abs((p1.z()-p2.z()-1.0))<0.0001){ - file2 << "NSET\tFRONTLEFTBOTTOM = FRONTLEFTBOTTOM + SURFACE"<<ToReplaceFace->tag()<<"\n"; - file2 << "NSET\tBACKRIGHTTOP = BACKRIGHTTOP + SURFACE"<<pairTmp.first->tag()<<"\n"; - } - } - }else if (abs((p1.x()-p2.x()-1.0))<0.0001){ - if (abs((p2.y()-p1.y()))<0.0001){ - if (abs((p2.z()-p1.z()))<0.0001){ - file2 << "NSET\tFRONT = FRONT + SURFACE"<<pairTmp.first->tag()<<"\n"; - file2 << "NSET\tBACK = BACK + SURFACE"<<ToReplaceFace->tag()<<"\n"; - }else if(abs((p2.z()-p1.z()-1.0))<0.0001){ - file2 << "NSET\tFRONTBOTTOM = FRONTBOTTOM + SURFACE"<<pairTmp.first->tag()<<"\n"; - file2 << "NSET\tBACKTOP = BACKTOP + SURFACE"<<ToReplaceFace->tag()<<"\n"; - }else if (abs((p1.z()-p2.z()-1.0))<0.0001){ - file2 << "NSET\tFRONTTOP = FRONTTOP + SURFACE"<<pairTmp.first->tag()<<"\n"; - file2 << "NSET\tBACKBOTTOM = BACKBOTTOM + SURFACE"<<ToReplaceFace->tag()<<"\n"; - } - }else if (abs((p2.y()-p1.y()-1.0))<0.0001){ - if (abs((p2.z()-p1.z()))<0.0001){ - file2 << "NSET\tFRONTLEFT = FRONTLEFT + SURFACE"<<pairTmp.first->tag()<<"\n"; - file2 << "NSET\tBACKRIGHT = BACKRIGHT + SURFACE"<<ToReplaceFace->tag()<<"\n"; - }else if (abs((p2.z()-p1.z()-1.0))<0.0001){ - file2 << "NSET\tFRONTLEFTBOTTOM = FRONTLEFTBOTTOM + SURFACE"<<pairTmp.first->tag()<<"\n"; - file2 << "NSET\tBACKRIGHTTOP = BACKRIGHTTOP + SURFACE"<<ToReplaceFace->tag()<<"\n"; - }else if (abs((p1.z()-p2.z()-1.0))<0.0001){ - file2 << "NSET\tFRONTLEFTTOP = FRONTLEFTTOP + SURFACE"<<pairTmp.first->tag()<<"\n"; - file2 << "NSET\tBACKRIGHTBOTTOM = BACKRIGHTBOTTOM + SURFACE"<<ToReplaceFace->tag()<<"\n"; - } - }else if (abs((p1.y()-p2.y()-1.0))<0.0001){ - if (abs((p2.z()-p1.z()))<0.0001){ - file2 << "NSET\tFRONTRIGHT = FRONTRIGHT + SURFACE"<<pairTmp.first->tag()<<"\n"; - file2 << "NSET\tBACKLEFT = BACKLEFT + SURFACE"<<ToReplaceFace->tag()<<"\n"; - }else if (abs((p2.z()-p1.z()-1.0))<0.0001){ - file2 << "NSET\tFRONTRIGHTBOTTOM = FRONTRIGHTBOTTOM + SURFACE"<<pairTmp.first->tag()<<"\n"; - file2 << "NSET\tBACKLEFTTOP = BACKLEFTTOP + SURFACE"<<ToReplaceFace->tag()<<"\n"; - }else if (abs((p1.z()-p2.z()-1.0))<0.0001){ - file2 << "NSET\tFRONTRIGHTTOP = FRONTRIGHTTOP + SURFACE"<<pairTmp.first->tag()<<"\n"; - file2 << "NSET\tBACKLEFTBOTTOM = BACKLEFTBOTTOM + SURFACE"<<ToReplaceFace->tag()<<"\n"; - } - } - }else if (abs((p1.x()-p2.x()))<0.0001){ - if (abs((p2.y()-p1.y()-1.0))<0.0001){ - if (abs((p2.z()-p1.z()))<0.0001){ - file2 << "NSET\tRIGHT = RIGHT + SURFACE"<<ToReplaceFace->tag()<<"\n"; - file2 << "NSET\tLEFT = LEFT + SURFACE"<<pairTmp.first->tag()<<"\n"; - }else if (abs((p2.z()-p1.z()-1.0))<0.0001){ - file2 << "NSET\tRIGHTTOP = RIGHTTOP + SURFACE"<<ToReplaceFace->tag()<<"\n"; - file2 << "NSET\tLEFTBOTTOM = LEFTBOTTOM + SURFACE"<<pairTmp.first->tag()<<"\n"; - }else if (abs((p1.z()-p2.z()-1.0))<0.0001){ - file2 << "NSET\tRIGHTBOTTOM = RIGHTBOTTOM + SURFACE"<<ToReplaceFace->tag()<<"\n"; - file2 << "NSET\tLEFTTOP = LEFTTOP + SURFACE"<<pairTmp.first->tag()<<"\n"; - } - }else if (abs((p1.y()-p2.y()-1.0))<0.0001){ - if (abs((p2.z()-p1.z()))<0.0001){ - file2 << "NSET\tRIGHT = RIGHT + SURFACE"<<pairTmp.first->tag()<<"\n"; - file2 << "NSET\tLEFT = LEFT + SURFACE"<<ToReplaceFace->tag()<<"\n"; - }else if (abs((p2.z()-p1.z()-1.0))<0.0001){ - file2 << "NSET\tRIGHTBOTTOM = RIGHTBOTTOM + SURFACE"<<pairTmp.first->tag()<<"\n"; - file2 << "NSET\tLEFTTOP = LEFTTOP + SURFACE"<<ToReplaceFace->tag()<<"\n"; - }else if (abs((p1.z()-p2.z()-1.0))<0.0001){ - file2 << "NSET\tRIGHTTOP = RIGHTTOP + SURFACE"<<pairTmp.first->tag()<<"\n"; - file2 << "NSET\tLEFTBOTTOM = LEFTBOTTOM + SURFACE"<<ToReplaceFace->tag()<<"\n"; - } - }else if (abs((p1.y()-p2.y()))<0.0001){ - if (abs((p2.z()-p1.z()-1.0))<0.0001){ - file2 << "NSET\tTOP = TOP + SURFACE"<<ToReplaceFace->tag()<<"\n"; - file2 << "NSET\tBOTTOM = BOTTOM + SURFACE"<<pairTmp.first->tag()<<"\n"; - }else if (abs((p1.z()-p2.z()-1.0))<0.0001){ - file2 << "NSET\tTOP = TOP + SURFACE"<<pairTmp.first->tag()<<"\n"; - file2 << "NSET\tBOTTOM = BOTTOM + SURFACE"<<ToReplaceFace->tag()<<"\n"; - } - } - } - // count++; - - - - - - - - newPairs.push_back(std::make_pair(pairTmp.first,associatedFace)); - } - } - // for (std::vector<std::pair<GFace*,GFace*> >::iterator itP = newPairs.begin();itP != newPairs.end();itP++){ - // std::pair<GFace*,GFace*> pairTmp = (*itP); - // } - - std::cout<<"End of DuplicateBoundaries"<<std::endl; - return view; -} - - - - - -PView *GMSH_DuplicateBoundariesPlugin::execute(PView *view) -{ - GModel *m = GModel::current(); - if (m->getDim() == 3){ - view = GMSH_DuplicateBoundariesPlugin::executeDuplicate(view); - } - else if (m->getDim() == 2){ - view = GMSH_DuplicateBoundariesPlugin::execute2DWithBound(view); - } - //view = GMSH_DuplicateBoundariesPlugin::ComputeBestSeeds(view); - //view = GMSH_DuplicateBoundariesPlugin::execute2D(view); - //view = GMSH_DuplicateBoundariesPlugin::execute2DWithBound(view); - return view; -} - - - -PView *GMSH_DuplicateBoundariesPlugin::executeDuplicate(PView *view) -{ - std::cout<<"starting DuplicateBoundaries"<<std::endl; - GModel *m = GModel::current(); - m->setFactory("geo"); - std::set<GFace*> ToDuplicateList; - ToDuplicateList.clear(); - std::set<GFace*> ToDuplicateListBoundary; - ToDuplicateListBoundary.clear(); - std::vector<GFace*> facesBound; - facesBound.clear(); - std::map<GFace*,SPoint3> centers; - std::vector<std::pair<GFace*,GFace*> > pairs; - std::vector<std::pair<GFace*,GFace*> > newPairs; - int PhysicalInterface = m->setPhysicalName("Interface",3); - for (GModel::fiter itf= m->firstFace();itf != m->lastFace();itf++){ - GFace* fTmp = (*itf); - if (fTmp->numRegions() == 2){ - ToDuplicateList.insert(fTmp); - } - else{ - // ToDuplicateListBoundary.insert(fTmp); - facesBound.push_back(fTmp); - } - } - - - - - - - - - for(unsigned int i=0;i<facesBound.size();i++){ - double x = 0.0; - double y = 0.0; - double z = 0.0; - - std::list<GVertex*> vertices; - - vertices = facesBound[i]->vertices(); - - for(std::list<GVertex*>::iterator it2=vertices.begin();it2!=vertices.end();it2++){ - x = x + (*it2)->x(); - y = y + (*it2)->y(); - z = z + (*it2)->z(); - } - - x = x/vertices.size(); - y = y/vertices.size(); - z = z/vertices.size(); - - centers.insert(std::pair<GFace*,SPoint3>(facesBound[i],SPoint3(x,y,z))); - } - - for(unsigned int i=0;i<facesBound.size();i++){ - for(unsigned int j=0;j<facesBound.size();j++){ - std::map<GFace*,SPoint3>::iterator it3 = centers.find(facesBound[i]); - std::map<GFace*,SPoint3>::iterator it4 = centers.find(facesBound[j]); - - SPoint3 p1 = it3->second; - SPoint3 p2 = it4->second; - - - // categories.push_back(val); - - // print_segment(p1,p2,file); - - if (abs((p2.x()-p1.x()-1.0))<0.0001){ - if (abs((p2.y()-p1.y()))<0.0001){ - if (abs((p2.z()-p1.z()))<0.0001){ - pairs.push_back(std::pair<GFace*,GFace*>(facesBound[i],facesBound[j])); - ToDuplicateListBoundary.insert(facesBound[i]); - }else if(abs((p2.z()-p1.z()-1.0))<0.0001){ - pairs.push_back(std::pair<GFace*,GFace*>(facesBound[i],facesBound[j])); - ToDuplicateListBoundary.insert(facesBound[i]); - }else if (abs((p1.z()-p2.z()-1.0))<0.0001){ - pairs.push_back(std::pair<GFace*,GFace*>(facesBound[i],facesBound[j])); - ToDuplicateListBoundary.insert(facesBound[i]); - } - }else if (abs((p2.y()-p1.y()-1.0))<0.0001){ - if (abs((p2.z()-p1.z()))<0.0001){ - pairs.push_back(std::pair<GFace*,GFace*>(facesBound[i],facesBound[j])); - ToDuplicateListBoundary.insert(facesBound[i]); - }else if (abs((p2.z()-p1.z()-1.0))<0.0001){ - pairs.push_back(std::pair<GFace*,GFace*>(facesBound[i],facesBound[j])); - ToDuplicateListBoundary.insert(facesBound[i]); - }else if (abs((p1.z()-p2.z()-1.0))<0.0001){ - pairs.push_back(std::pair<GFace*,GFace*>(facesBound[i],facesBound[j])); - ToDuplicateListBoundary.insert(facesBound[i]); - } - }else if (abs((p1.y()-p2.y()-1.0))<0.0001){ - if (abs((p2.z()-p1.z()))<0.0001){ - pairs.push_back(std::pair<GFace*,GFace*>(facesBound[i],facesBound[j])); - ToDuplicateListBoundary.insert(facesBound[i]); - }else if (abs((p2.z()-p1.z()-1.0))<0.0001){ - pairs.push_back(std::pair<GFace*,GFace*>(facesBound[i],facesBound[j])); - ToDuplicateListBoundary.insert(facesBound[i]); - }else if (abs((p1.z()-p2.z()-1.0))<0.0001){ - pairs.push_back(std::pair<GFace*,GFace*>(facesBound[i],facesBound[j])); - ToDuplicateListBoundary.insert(facesBound[i]); - } - } - }else if (abs((p1.x()-p2.x()-1.0))<0.0001){ - if (abs((p2.y()-p1.y()))<0.0001){ - if (abs((p2.z()-p1.z()))<0.0001){ - //NOTHING - }else if(abs((p2.z()-p1.z()-1.0))<0.0001){ - //NOTHING - }else if (abs((p1.z()-p2.z()-1.0))<0.0001){ - //NOTHING - } - }else if (abs((p2.y()-p1.y()-1.0))<0.0001){ - if (abs((p2.z()-p1.z()))<0.0001){ - //NOTHING - }else if (abs((p2.z()-p1.z()-1.0))<0.0001){ - //NOTHING - }else if (abs((p1.z()-p2.z()-1.0))<0.0001){ - //NOTHING - } - }else if (abs((p1.y()-p2.y()-1.0))<0.0001){ - if (abs((p2.z()-p1.z()))<0.0001){ - //NOTHING - }else if (abs((p2.z()-p1.z()-1.0))<0.0001){ - //NOTHING - }else if (abs((p1.z()-p2.z()-1.0))<0.0001){ - //NOTHING - } - } - }else if (abs((p1.x()-p2.x()))<0.0001){ - if (abs((p2.y()-p1.y()-1.0))<0.0001){ - if (abs((p2.z()-p1.z()))<0.0001){ - pairs.push_back(std::pair<GFace*,GFace*>(facesBound[i],facesBound[j])); - ToDuplicateListBoundary.insert(facesBound[i]); - }else if (abs((p2.z()-p1.z()-1.0))<0.0001){ - pairs.push_back(std::pair<GFace*,GFace*>(facesBound[i],facesBound[j])); - ToDuplicateListBoundary.insert(facesBound[i]); - }else if (abs((p1.z()-p2.z()-1.0))<0.0001){ - pairs.push_back(std::pair<GFace*,GFace*>(facesBound[i],facesBound[j])); - ToDuplicateListBoundary.insert(facesBound[i]); - } - }else if (abs((p1.y()-p2.y()-1.0))<0.0001){ - if (abs((p2.z()-p1.z()))<0.0001){ - //NOTHING - }else if (abs((p2.z()-p1.z()-1.0))<0.0001){ - //NOTHING - }else if (abs((p1.z()-p2.z()-1.0))<0.0001){ - //NOTHING - } - }else if (abs((p1.y()-p2.y()))<0.0001){ - if (abs((p2.z()-p1.z()-1.0))<0.0001){ - pairs.push_back(std::pair<GFace*,GFace*>(facesBound[i],facesBound[j])); - ToDuplicateListBoundary.insert(facesBound[i]); - }else if (abs((p1.z()-p2.z()-1.0))<0.0001){ - //NOTHING - } - } - } - } - } - - - - - - - - - - - std::map<std::pair<MVertex*,GRegion*>,MVertex* > VertexGlobalAssociation; - std::map<std::pair<GVertex*,GRegion*>,GVertex* > GVertexGlobalAssociation; - std::map<std::pair<GEdge*,GRegion*>,GEdge* > GEdgeGlobalAssociation; - std::map<std::pair<GFace*,GRegion*>,GFace* > GFaceGlobalAssociation; - // for (GModel::viter itv= m->firstVertex();itv != m->lastVertex();itv++){ - // GVertex* vTmp = (*itv); - // std::vector<GVertex* > vecTmp; - // vecTmp.clear(); - // GVertexGlobalAssociation[vTmp] = vecTmp; - // for (int i = 0; i < vTmp->mesh_vertices.size();i++){ - // MVertex *vMesh = vTmp->mesh_vertices[i]; - // std::vector<MVertex* > vecTmpBis; - // vecTmpBis.clear(); - // VertexGlobalAssociation[vMesh] = vecTmpBis; - // } - // } - // for (GModel::eiter ite= m->firstEdge();ite != m->lastEdge();ite++){ - // GEdge* eTmp = (*ite); - // std::vector<GEdge* > vecTmp; - // vecTmp.clear(); - // GEdgeGlobalAssociation[eTmp] = vecTmp; - // for (int i = 0; i < eTmp->mesh_vertices.size();i++){ - // MVertex *vMesh = eTmp->mesh_vertices[i]; - // std::vector<MVertex* > vecTmpBis; - // vecTmpBis.clear(); - // VertexGlobalAssociation[vMesh] = vecTmpBis; - // } - // } - // for (GModel::fiter itf= m->firstFace();itf != m->lastFace();itf++){ - // GFace* fTmp = (*itf); - // for (int i = 0; i < fTmp->mesh_vertices.size();i++){ - // MVertex *vMesh = fTmp->mesh_vertices[i]; - // std::vector<MVertex* > vecTmpBis; - // vecTmpBis.clear(); - // VertexGlobalAssociation[vMesh] = vecTmpBis; - // } - // } - // for (GModel::riter itr= m->firstRegion();itr != m->lastRegion();itr++){ - // GRegion* rTmp = (*itr); - // for (int i = 0; i < rTmp->mesh_vertices.size();i++){ - // MVertex *vMesh = rTmp->mesh_vertices[i]; - // std::vector<MVertex* > vecTmpBis; - // vecTmpBis.clear(); - // VertexGlobalAssociation[vMesh] = vecTmpBis; - // } - // } - for (GModel::riter itr= m->firstRegion();itr != m->lastRegion();itr++){ - GRegion* rTmp = (*itr); - std::list<GFace*> RegFaces = rTmp->faces(); - std::map<MVertex*,MVertex* > VertexAssociation; - std::map<GVertex*,GVertex* > GVertexAssociation; - std::map<GEdge*,GEdge* > GEdgeAssociation; - //int counterNbDone = 10000; - double xCenterReg = 0.0; - double yCenterReg = 0.0; - double zCenterReg = 0.0; - int counterPts = 0; - for(std::list<GFace*>::iterator it2=RegFaces.begin();it2!=RegFaces.end();it2++){ - GFace* fTemp = (*it2); - std::list<GVertex*> verticesFace = fTemp->vertices(); - for (std::list<GVertex*>::iterator it3=verticesFace.begin();it3!=verticesFace.end();it3++){ - xCenterReg = xCenterReg + (*it3)->x(); - yCenterReg = yCenterReg + (*it3)->y(); - zCenterReg = zCenterReg + (*it3)->z(); - counterPts++; - } - } - xCenterReg = xCenterReg/counterPts; - yCenterReg = yCenterReg/counterPts; - zCenterReg = zCenterReg/counterPts; - //duplication noeud et aretes au niveau de la region directement - std::list<GVertex*> vlist; - - - std::list<GFace*> listFacesTmp = rTmp->faces(); - for (std::list<GFace*>::iterator itTp = listFacesTmp.begin();itTp != listFacesTmp.end();itTp++){ - std::list<GVertex*> vlist2; - vlist2 = (*itTp)->vertices(); - for (std::list<GVertex*>::iterator itTp2 = vlist2.begin();itTp2 != vlist2.end();itTp2++){ - if(std::find(vlist.begin(), vlist.end(), *itTp2) == vlist.end()) - vlist.push_back(*itTp2); - } - } - - - for (std::list<GVertex*>::iterator itv = vlist.begin();itv != vlist.end();itv++){ - //duplication Gvertex - GVertex* vTmp = (*itv); - double ponderatedX = 0.99999999999 * vTmp->x() + 0.00000000001 * xCenterReg; - double ponderatedY = 0.99999999999 * vTmp->y() + 0.00000000001 * yCenterReg; - double ponderatedZ = 0.99999999999 * vTmp->z() + 0.00000000001 * zCenterReg; - GVertex* newv = m->addVertex(ponderatedX,ponderatedY,ponderatedZ,vTmp->prescribedMeshSizeAtVertex()); - GVertexAssociation[vTmp] = newv; - GVertexGlobalAssociation[std::make_pair(vTmp,rTmp)] = newv; - //creation des Gedge correspondantes - // GEdge* newE = m->addLine(vTmp,newv); - // SurroudingEdges[vTmp] = newE; - //maintenant traitement mesh - MVertex *vMesh = vTmp->mesh_vertices[0]; - MVertex *newMv = new MVertex(vMesh->x(), vMesh->y(), vMesh->z(), (GEntity*)newv); - VertexAssociation[vMesh] = newMv; - VertexGlobalAssociation[std::make_pair(vMesh,rTmp)] = newMv; - newv->addMeshVertex(newMv); - } - //maintenant on soccupe de duppliquer les edges de la region - std::list<GEdge*> elist = rTmp->edges(); - - std::vector<GFace*> SurroundingsFaces; - for (std::list<GEdge*>::iterator ite = elist.begin();ite != elist.end();ite++){ - //duplication Gedge - GEdge* eTmp = (*ite); - GEdge* newE = m->addLine(GVertexAssociation[eTmp->getEndVertex()],GVertexAssociation[eTmp->getBeginVertex()]); - GEdgeAssociation[eTmp] = newE; - GEdgeGlobalAssociation[std::make_pair(eTmp,rTmp)] = newE; - //creation des GFace correspondantes - // GEdge* firstE = SurroudingEdges.find(eTmp->getEndVertex())->second; - // GEdge* lastE = SurroudingEdges.find(eTmp->getBeginVertex())->second; - // std::vector<GEdge*> VecEdgesTmp; - // VecEdgesTmp.push_back(eTmp); - // VecEdgesTmp.push_back(firstE); - // VecEdgesTmp.push_back(newE); - // VecEdgesTmp.push_back(lastE); - // std::vector<std::vector<GEdge*> > VecOfVecTmp; - // VecOfVecTmp.push_back(VecEdgesTmp); - // GFace* newFaceTmp = m->addPlanarFace(VecOfVecTmp); - // SurroundingsFaces.push_back(newFaceTmp); - //maintenant traitement mesh - for (unsigned int i = 0; i < eTmp->mesh_vertices.size();i++){ - MVertex *vMesh = eTmp->mesh_vertices[i]; - MVertex *newMv = new MVertex(vMesh->x(), vMesh->y(), vMesh->z(), (GEntity*)newE); - VertexAssociation[vMesh] = newMv; - VertexGlobalAssociation[std::make_pair(vMesh,rTmp)] = newMv; - newE->addMeshVertex(newMv); - } - for (unsigned int i = 0; i < eTmp->getNumMeshElements();i++){ - MElement* elem = eTmp->getMeshElement(i); - MVertex *firstETmp = VertexAssociation.find(elem->getVertex(0))->second; - MVertex *lastETmp = VertexAssociation.find(elem->getVertex(1))->second; - MVertex *midETmp = VertexAssociation.find(elem->getVertex(2))->second; - MLine3 *newLine = new MLine3(firstETmp,lastETmp,midETmp); - newE->addLine(newLine); - } - } - for (std::list<GFace*>::iterator itf = RegFaces.begin();itf != RegFaces.end();itf++){ - GFace* fTmp = (*itf); - std::vector<GEdge*> newEdgesVector; - std::list<GEdge*> elistFace = fTmp->edges(); - for (std::list<GEdge*>::iterator ite = elistFace.begin();ite != elistFace.end();ite++){ - GEdge* eTmp = (*ite); - GEdge* eToFind = GEdgeAssociation[eTmp]; - newEdgesVector.push_back(eToFind); - } - std::vector<std::vector<GEdge*> > VecOfVec; - VecOfVec.push_back(newEdgesVector); - //creation de la nouvelle face - GFace* GFaceAssociation = m->addPlanarFace(VecOfVec); - // int tagTmp = GFaceAssociation->tag(); - // std::ostringstream ss; - // ss << tagTmp; - //// char *intStr = itoa(tagTmp); - // std::string nameSurf = "SURFACE"; - //// nameSurf += std::string(intStr); - // nameSurf += ss.str(); - // int PhysicalSurfaceTmp = m->setPhysicalName(nameSurf,2); - // GFaceAssociation->addPhysicalEntity(PhysicalSurfaceTmp); - //maintenant traitement mesh - for (unsigned int i = 0; i < fTmp->mesh_vertices.size();i++){ - MVertex *vMesh = fTmp->mesh_vertices[i]; - MVertex *newMv = new MVertex(vMesh->x(), vMesh->y(), vMesh->z(), (GEntity*)GFaceAssociation); - VertexAssociation[vMesh] = newMv; - VertexGlobalAssociation[std::make_pair(vMesh,rTmp)] = newMv; - GFaceAssociation->addMeshVertex(newMv); - } - for (unsigned int i = 0; i < fTmp->getNumMeshElements();i++){ - MElement* elem = fTmp->getMeshElement(i); - MVertex *firstE = VertexAssociation.find(elem->getVertex(0))->second; - MVertex *secondE = VertexAssociation.find(elem->getVertex(1))->second; - MVertex *thirdE = VertexAssociation.find(elem->getVertex(2))->second; - MVertex *fourthE = VertexAssociation.find(elem->getVertex(3))->second; - MVertex *fifthE = VertexAssociation.find(elem->getVertex(4))->second; - MVertex *sisthE = VertexAssociation.find(elem->getVertex(5))->second; - MTriangle6 *newTri = new MTriangle6(firstE,secondE,thirdE,fourthE,fifthE,sisthE); - GFaceAssociation->addTriangle(newTri); - } - GFaceGlobalAssociation[std::make_pair(fTmp,rTmp)] = GFaceAssociation; - } - } - int counterNbDone = 10000; - //maintenant on va traiter les faces initiales - for (std::set<GFace*>::iterator itf = ToDuplicateList.begin();itf != ToDuplicateList.end();itf++){ - counterNbDone++; - GFace* fTmp = (*itf); - GRegion* reg1 = fTmp->getRegion(0); - GRegion* reg2 = fTmp->getRegion(1); - //pour commencer on cree des aretes entre les vertex - std::list<GVertex*> vlist = fTmp->vertices(); - std::map<GVertex*,GEdge* > SurroudingEdges; - for (std::list<GVertex*>::iterator itv = vlist.begin();itv != vlist.end();itv++){ - GVertex* vTmp = (*itv); - GVertex* v1=0; - GVertex* v2=0; - std::map<std::pair<GVertex*,GRegion*>,GVertex* >::iterator itMap = GVertexGlobalAssociation.find(std::make_pair(vTmp,reg1)); - if (itMap != GVertexGlobalAssociation.end()){ - v1 = itMap->second; - } - itMap = GVertexGlobalAssociation.find(std::make_pair(vTmp,reg2)); - if (itMap != GVertexGlobalAssociation.end()){ - v2 = itMap->second; - } - GEdge* newE = m->addLine(v1,v2); - SurroudingEdges[vTmp] = newE; - } - //ici tous les vertex sont traites - //on va traiter les edges - std::list<GEdge*> elist = fTmp->edges(); - std::vector<GEdge*> newEdgesVector; - std::vector<GFace*> SurroundingsFaces; - for (std::list<GEdge*>::iterator ite = elist.begin();ite != elist.end();ite++){ - //duplication Gedge - GEdge* eTmp = (*ite); - GEdge* e1=0; - GEdge* e2=0; - std::map<std::pair<GEdge*,GRegion*>,GEdge* >::iterator itMap = GEdgeGlobalAssociation.find(std::make_pair(eTmp,reg1)); - if (itMap != GEdgeGlobalAssociation.end()){ - e1 = itMap->second; - } - itMap = GEdgeGlobalAssociation.find(std::make_pair(eTmp,reg2)); - if (itMap != GEdgeGlobalAssociation.end()){ - e2 = itMap->second; - } - //creation des GFace correspondantes - GEdge* firstE = SurroudingEdges.find(eTmp->getBeginVertex())->second; - GEdge* lastE = SurroudingEdges.find(eTmp->getEndVertex())->second; - if (firstE->getBeginVertex() != e1->getEndVertex()){ - firstE->reverse(); - } - if (firstE->getBeginVertex() != e1->getEndVertex()){ - e1->reverse(); - } - if (firstE->getBeginVertex() != e1->getEndVertex()){ - firstE->reverse(); - } - if (e2->getBeginVertex() != firstE->getEndVertex()){ - e2->reverse(); - } - if (lastE->getBeginVertex() != e2->getEndVertex()){ - lastE->reverse(); - } - std::vector<GEdge*> VecEdgesTmp; - VecEdgesTmp.push_back(e1); - VecEdgesTmp.push_back(firstE); - VecEdgesTmp.push_back(e2); - VecEdgesTmp.push_back(lastE); - std::vector<std::vector<GEdge*> > VecOfVecTmp; - VecOfVecTmp.push_back(VecEdgesTmp); - GFace* newFaceTmp = m->addPlanarFace(VecOfVecTmp); - SurroundingsFaces.push_back(newFaceTmp); - } - std::vector<GFace*> VectorFaces; - std::list<GFace*> listFaces; - GFace* f1; - GFace* f2; - std::map<std::pair<GFace*,GRegion*>,GFace* >::iterator itMap = GFaceGlobalAssociation.find(std::make_pair(fTmp,reg1)); - if (itMap != GFaceGlobalAssociation.end()){ - f1 = itMap->second; - } - itMap = GFaceGlobalAssociation.find(std::make_pair(fTmp,reg2)); - if (itMap != GFaceGlobalAssociation.end()){ - f2 = itMap->second; - } - VectorFaces.push_back(f1); - listFaces.push_back(f1); - for (unsigned int i = 0;i < SurroundingsFaces.size();i++){ - VectorFaces.push_back(SurroundingsFaces[i]); - listFaces.push_back(SurroundingsFaces[i]); - } - VectorFaces.push_back(f2); - listFaces.push_back(f2); - std::vector<std::vector<GFace*> > VecOfVecGFace; - VecOfVecGFace.push_back(VectorFaces); - //creation de la nouvelle region - GRegion* createdRegion = new GRegion(m,counterNbDone); - createdRegion->addPhysicalEntity(PhysicalInterface); - createdRegion->set(listFaces); - m->add(createdRegion); - for (unsigned int i = 0; i < fTmp->getNumMeshElements();i++){ - MElement* elem = fTmp->getMeshElement(i); - MVertex* v1=0; - MVertex* v2=0; - MVertex* v3=0; - MVertex* v4=0; - MVertex* v5=0; - MVertex* v6=0; - std::map<std::pair<MVertex*,GRegion*>,MVertex* >::iterator itMap = VertexGlobalAssociation.find(std::make_pair(elem->getVertex(0),reg1)); - if (itMap != VertexGlobalAssociation.end()){ - v1 = itMap->second; - } - itMap = VertexGlobalAssociation.find(std::make_pair(elem->getVertex(3),reg1)); - if (itMap != VertexGlobalAssociation.end()){ - v2 = itMap->second; - } - itMap = VertexGlobalAssociation.find(std::make_pair(elem->getVertex(5),reg1)); - if (itMap != VertexGlobalAssociation.end()){ - v3 = itMap->second; - } - itMap = VertexGlobalAssociation.find(std::make_pair(elem->getVertex(0),reg2)); - if (itMap != VertexGlobalAssociation.end()){ - v4 = itMap->second; - } - itMap = VertexGlobalAssociation.find(std::make_pair(elem->getVertex(3),reg2)); - if (itMap != VertexGlobalAssociation.end()){ - v5 = itMap->second; - } - itMap = VertexGlobalAssociation.find(std::make_pair(elem->getVertex(5),reg2)); - if (itMap != VertexGlobalAssociation.end()){ - v6 = itMap->second; - } - MPrism *newPri = new MPrism(v1,v3,v2,v4,v6,v5); - - createdRegion->addPrism(newPri); - - //second - itMap = VertexGlobalAssociation.find(std::make_pair(elem->getVertex(1),reg1)); - if (itMap != VertexGlobalAssociation.end()){ - v1 = itMap->second; - } - itMap = VertexGlobalAssociation.find(std::make_pair(elem->getVertex(4),reg1)); - if (itMap != VertexGlobalAssociation.end()){ - v2 = itMap->second; - } - itMap = VertexGlobalAssociation.find(std::make_pair(elem->getVertex(3),reg1)); - if (itMap != VertexGlobalAssociation.end()){ - v3 = itMap->second; - } - itMap = VertexGlobalAssociation.find(std::make_pair(elem->getVertex(1),reg2)); - if (itMap != VertexGlobalAssociation.end()){ - v4 = itMap->second; - } - itMap = VertexGlobalAssociation.find(std::make_pair(elem->getVertex(4),reg2)); - if (itMap != VertexGlobalAssociation.end()){ - v5 = itMap->second; - } - itMap = VertexGlobalAssociation.find(std::make_pair(elem->getVertex(3),reg2)); - if (itMap != VertexGlobalAssociation.end()){ - v6 = itMap->second; - } - MPrism *newPri2 = new MPrism(v1,v3,v2,v4,v6,v5); - - createdRegion->addPrism(newPri2); - //third - itMap = VertexGlobalAssociation.find(std::make_pair(elem->getVertex(2),reg1)); - if (itMap != VertexGlobalAssociation.end()){ - v1 = itMap->second; - } - itMap = VertexGlobalAssociation.find(std::make_pair(elem->getVertex(5),reg1)); - if (itMap != VertexGlobalAssociation.end()){ - v2 = itMap->second; - } - itMap = VertexGlobalAssociation.find(std::make_pair(elem->getVertex(4),reg1)); - if (itMap != VertexGlobalAssociation.end()){ - v3 = itMap->second; - } - itMap = VertexGlobalAssociation.find(std::make_pair(elem->getVertex(2),reg2)); - if (itMap != VertexGlobalAssociation.end()){ - v4 = itMap->second; - } - itMap = VertexGlobalAssociation.find(std::make_pair(elem->getVertex(5),reg2)); - if (itMap != VertexGlobalAssociation.end()){ - v5 = itMap->second; - } - itMap = VertexGlobalAssociation.find(std::make_pair(elem->getVertex(4),reg2)); - if (itMap != VertexGlobalAssociation.end()){ - v6 = itMap->second; - } - MPrism *newPri3 = new MPrism(v1,v3,v2,v4,v6,v5); - - createdRegion->addPrism(newPri3); - //fourth - itMap = VertexGlobalAssociation.find(std::make_pair(elem->getVertex(3),reg1)); - if (itMap != VertexGlobalAssociation.end()){ - v1 = itMap->second; - } - itMap = VertexGlobalAssociation.find(std::make_pair(elem->getVertex(4),reg1)); - if (itMap != VertexGlobalAssociation.end()){ - v2 = itMap->second; - } - itMap = VertexGlobalAssociation.find(std::make_pair(elem->getVertex(5),reg1)); - if (itMap != VertexGlobalAssociation.end()){ - v3 = itMap->second; - } - itMap = VertexGlobalAssociation.find(std::make_pair(elem->getVertex(3),reg2)); - if (itMap != VertexGlobalAssociation.end()){ - v4 = itMap->second; - } - itMap = VertexGlobalAssociation.find(std::make_pair(elem->getVertex(4),reg2)); - if (itMap != VertexGlobalAssociation.end()){ - v5 = itMap->second; - } - itMap = VertexGlobalAssociation.find(std::make_pair(elem->getVertex(5),reg2)); - if (itMap != VertexGlobalAssociation.end()){ - v6 = itMap->second; - } - MPrism *newPri4 = new MPrism(v1,v3,v2,v4,v6,v5); - - createdRegion->addPrism(newPri4); - } - for (unsigned int i = 0; i < reg1->getNumMeshElements();i++){ - MElement* elem = reg1->getMeshElement(i); - for (int j = 0;j < elem->getNumVertices();j++){ - MVertex* vert = elem->getVertex(j); - std::map<std::pair<MVertex*,GRegion*>,MVertex* >::iterator itMap = VertexGlobalAssociation.find(std::make_pair(vert,reg1)); - if (itMap != VertexGlobalAssociation.end()){ - elem->setVertex(j,itMap->second); - } - } - } - for (unsigned int i = 0; i < reg2->getNumMeshElements();i++){ - MElement* elem = reg2->getMeshElement(i); - for (int j = 0;j < elem->getNumVertices();j++){ - MVertex* vert = elem->getVertex(j); - std::map<std::pair<MVertex*,GRegion*>,MVertex* >::iterator itMap = VertexGlobalAssociation.find(std::make_pair(vert,reg2)); - if (itMap != VertexGlobalAssociation.end()){ - elem->setVertex(j,itMap->second); - } - } - } - } - //maintenant on va traiter les faces du bord - for (std::set<GFace*>::iterator itf = ToDuplicateListBoundary.begin();itf != ToDuplicateListBoundary.end();itf++){ - counterNbDone++; - GFace* fTmp = (*itf); - GRegion* reg1 = fTmp->getRegion(0); - //pour commencer on cree des aretes entre les vertex - std::list<GVertex*> vlist = fTmp->vertices(); - std::map<GVertex*,GEdge* > SurroudingEdges; - for (std::list<GVertex*>::iterator itv = vlist.begin();itv != vlist.end();itv++){ - GVertex* vTmp = (*itv); - GVertex* v1=0; - std::map<std::pair<GVertex*,GRegion*>,GVertex* >::iterator itMap = GVertexGlobalAssociation.find(std::make_pair(vTmp,reg1)); - if (itMap != GVertexGlobalAssociation.end()){ - v1 = itMap->second; - } - GEdge* newE = m->addLine(v1,vTmp); - SurroudingEdges[vTmp] = newE; - } - //ici tous les vertex sont traites - //on va traiter les edges - std::list<GEdge*> elist = fTmp->edges(); - std::vector<GEdge*> newEdgesVector; - std::vector<GFace*> SurroundingsFaces; - for (std::list<GEdge*>::iterator ite = elist.begin();ite != elist.end();ite++){ - //duplication Gedge - GEdge* eTmp = (*ite); - GEdge* e1=0; - std::map<std::pair<GEdge*,GRegion*>,GEdge* >::iterator itMap = GEdgeGlobalAssociation.find(std::make_pair(eTmp,reg1)); - if (itMap != GEdgeGlobalAssociation.end()){ - e1 = itMap->second; - } - //creation des GFace correspondantes - GEdge* firstE = SurroudingEdges.find(eTmp->getBeginVertex())->second; - GEdge* lastE = SurroudingEdges.find(eTmp->getEndVertex())->second; - if (firstE->getBeginVertex() != e1->getEndVertex()){ - firstE->reverse(); - } - if (firstE->getBeginVertex() != e1->getEndVertex()){ - e1->reverse(); - } - if (firstE->getBeginVertex() != e1->getEndVertex()){ - firstE->reverse(); - } - if (eTmp->getBeginVertex() != firstE->getEndVertex()){ - eTmp->reverse(); - } - if (lastE->getBeginVertex() != eTmp->getEndVertex()){ - lastE->reverse(); - } - std::vector<GEdge*> VecEdgesTmp; - VecEdgesTmp.push_back(e1); - VecEdgesTmp.push_back(firstE); - VecEdgesTmp.push_back(eTmp); - VecEdgesTmp.push_back(lastE); - std::vector<std::vector<GEdge*> > VecOfVecTmp; - VecOfVecTmp.push_back(VecEdgesTmp); - GFace* newFaceTmp = m->addPlanarFace(VecOfVecTmp); - SurroundingsFaces.push_back(newFaceTmp); - } - std::vector<GFace*> VectorFaces; - std::list<GFace*> listFaces; - GFace* f1; - std::map<std::pair<GFace*,GRegion*>,GFace* >::iterator itMap = GFaceGlobalAssociation.find(std::make_pair(fTmp,reg1)); - if (itMap != GFaceGlobalAssociation.end()){ - f1 = itMap->second; - } - VectorFaces.push_back(f1); - listFaces.push_back(f1); - for (unsigned int i = 0;i < SurroundingsFaces.size();i++){ - VectorFaces.push_back(SurroundingsFaces[i]); - listFaces.push_back(SurroundingsFaces[i]); - } - VectorFaces.push_back(fTmp); - listFaces.push_back(fTmp); - std::vector<std::vector<GFace*> > VecOfVecGFace; - VecOfVecGFace.push_back(VectorFaces); - //creation de la nouvelle region - GRegion* createdRegion = new GRegion(m,counterNbDone); - createdRegion->addPhysicalEntity(PhysicalInterface); - createdRegion->set(listFaces); - m->add(createdRegion); - for (unsigned int i = 0; i < fTmp->getNumMeshElements();i++){ - MElement* elem = fTmp->getMeshElement(i); - MVertex* v1=0; - MVertex* v2=0; - MVertex* v3=0; - std::map<std::pair<MVertex*,GRegion*>,MVertex* >::iterator itMap = VertexGlobalAssociation.find(std::make_pair(elem->getVertex(0),reg1)); - if (itMap != VertexGlobalAssociation.end()){ - v1 = itMap->second; - } - itMap = VertexGlobalAssociation.find(std::make_pair(elem->getVertex(3),reg1)); - if (itMap != VertexGlobalAssociation.end()){ - v2 = itMap->second; - } - itMap = VertexGlobalAssociation.find(std::make_pair(elem->getVertex(5),reg1)); - if (itMap != VertexGlobalAssociation.end()){ - v3 = itMap->second; - } - MPrism *newPri = new MPrism(v1,v3,v2,elem->getVertex(0),elem->getVertex(5),elem->getVertex(3)); - - createdRegion->addPrism(newPri); - //second - itMap = VertexGlobalAssociation.find(std::make_pair(elem->getVertex(1),reg1)); - if (itMap != VertexGlobalAssociation.end()){ - v1 = itMap->second; - } - itMap = VertexGlobalAssociation.find(std::make_pair(elem->getVertex(4),reg1)); - if (itMap != VertexGlobalAssociation.end()){ - v2 = itMap->second; - } - itMap = VertexGlobalAssociation.find(std::make_pair(elem->getVertex(3),reg1)); - if (itMap != VertexGlobalAssociation.end()){ - v3 = itMap->second; - } - MPrism *newPri2 = new MPrism(v1,v3,v2,elem->getVertex(1),elem->getVertex(3),elem->getVertex(4)); - - createdRegion->addPrism(newPri2); - //third - itMap = VertexGlobalAssociation.find(std::make_pair(elem->getVertex(2),reg1)); - if (itMap != VertexGlobalAssociation.end()){ - v1 = itMap->second; - } - itMap = VertexGlobalAssociation.find(std::make_pair(elem->getVertex(5),reg1)); - if (itMap != VertexGlobalAssociation.end()){ - v2 = itMap->second; - } - itMap = VertexGlobalAssociation.find(std::make_pair(elem->getVertex(4),reg1)); - if (itMap != VertexGlobalAssociation.end()){ - v3 = itMap->second; - } - MPrism *newPri3 = new MPrism(v1,v3,v2,elem->getVertex(2),elem->getVertex(4),elem->getVertex(5)); - - createdRegion->addPrism(newPri3); - //fourth - itMap = VertexGlobalAssociation.find(std::make_pair(elem->getVertex(3),reg1)); - if (itMap != VertexGlobalAssociation.end()){ - v1 = itMap->second; - } - itMap = VertexGlobalAssociation.find(std::make_pair(elem->getVertex(4),reg1)); - if (itMap != VertexGlobalAssociation.end()){ - v2 = itMap->second; - } - itMap = VertexGlobalAssociation.find(std::make_pair(elem->getVertex(5),reg1)); - if (itMap != VertexGlobalAssociation.end()){ - v3 = itMap->second; - } - MPrism *newPri4 = new MPrism(v1,v3,v2,elem->getVertex(3),elem->getVertex(5),elem->getVertex(4)); - - createdRegion->addPrism(newPri4); - } - for (unsigned int i = 0; i < reg1->getNumMeshElements();i++){ - MElement* elem = reg1->getMeshElement(i); - for (int j = 0;j < elem->getNumVertices();j++){ - MVertex* vert = elem->getVertex(j); - std::map<std::pair<MVertex*,GRegion*>,MVertex* >::iterator itMap = VertexGlobalAssociation.find(std::make_pair(vert,reg1)); - if (itMap != VertexGlobalAssociation.end()){ - elem->setVertex(j,itMap->second); - } - } - } - } - std::ofstream file("MicrostructurePolycrystal3D.pos"); - file << "View \"test\" {\n"; - - std::ofstream file2("PERIODIC.map"); - std::ofstream file3("SetAdd.map"); - for (std::vector<std::pair<GFace*,GFace*> >::iterator itP = pairs.begin();itP != pairs.end();itP++){ - std::pair<GFace*,GFace*> pairTmp = (*itP); - GFace* ToReplaceFace = pairTmp.second; - GRegion* rTmp = ToReplaceFace->getRegion(0); - std::map<std::pair<GFace*,GRegion*>,GFace* >::iterator itMap = GFaceGlobalAssociation.find(std::make_pair(ToReplaceFace,rTmp)); - if (itMap != GFaceGlobalAssociation.end()){ - GFace* associatedFace = (*itMap).second; - - - - - - file3 <<associatedFace->tag()<<"\tSURFACE"<<associatedFace->tag()<<"\tNSET "<<"\n"; - - int tagTmp = associatedFace->tag(); - std::ostringstream ss; - ss << tagTmp; - // char *intStr = itoa(tagTmp); - std::string nameSurf = "SURFACE"; - // nameSurf += std::string(intStr); - nameSurf += ss.str(); - int PhysicalSurfaceTmp = m->setPhysicalName(nameSurf,2); - associatedFace->addPhysicalEntity(PhysicalSurfaceTmp); - - std::map<GFace*,SPoint3>::iterator it3 = centers.find(pairTmp.first); - std::map<GFace*,SPoint3>::iterator it4 = centers.find(ToReplaceFace); - - SPoint3 p1 = it3->second; - SPoint3 p2 = it4->second; - - //double delta_x = fabs(p2.x()-p1.x()); - //double delta_y = fabs(p2.y()-p1.y()); - //double delta_z = fabs(p2.z()-p1.z()); - - - file << "SL (" - << p1.x() << ", " << p1.y() << ", " << p1.z() << ", " - << p2.x() << ", " << p2.y() << ", " << p2.z() - << "){10, 20};\n"; - - //file2 << "PERIODIC\tSURFACE"<<faces[i]->tag() << "\tSURFACE" << faces[j]->tag() << "\t" << p2.x()-p1.x() << "\t" << p2.y()-p1.y() << "\t" << p2.z()-p1.z() << "\n"; - if (abs((p2.x()-p1.x()-1.0))<0.0001){ - if (abs((p2.y()-p1.y()))<0.0001){ - if (abs((p2.z()-p1.z()))<0.0001){ - file2 << "NSET\tFRONT = FRONT + SURFACE"<<associatedFace->tag()<<"\n"; - file2 << "NSET\tBACK = BACK + SURFACE"<<pairTmp.first->tag()<<"\n"; - }else if(abs((p2.z()-p1.z()-1.0))<0.0001){ - file2 << "NSET\tFRONTTOP = FRONTTOP + SURFACE"<<associatedFace->tag()<<"\n"; - file2 << "NSET\tBACKBOTTOM = BACKBOTTOM + SURFACE"<<pairTmp.first->tag()<<"\n"; - }else if (abs((p1.z()-p2.z()-1.0))<0.0001){ - file2 << "NSET\tFRONTBOTTOM = FRONTBOTTOM + SURFACE"<<associatedFace->tag()<<"\n"; - file2 << "NSET\tBACKTOP = BACKTOP + SURFACE"<<pairTmp.first->tag()<<"\n"; - } - }else if (abs((p2.y()-p1.y()-1.0))<0.0001){ - if (abs((p2.z()-p1.z()))<0.0001){ - file2 << "NSET\tFRONTRIGHT = FRONTRIGHT + SURFACE"<<associatedFace->tag()<<"\n"; - file2 << "NSET\tBACKLEFT = BACKLEFT + SURFACE"<<pairTmp.first->tag()<<"\n"; - }else if (abs((p2.z()-p1.z()-1.0))<0.0001){ - file2 << "NSET\tFRONTRIGHTTOP = FRONTRIGHTTOP + SURFACE"<<associatedFace->tag()<<"\n"; - file2 << "NSET\tBACKLEFTBOTTOM = BACKLEFTBOTTOM + SURFACE"<<pairTmp.first->tag()<<"\n"; - }else if (abs((p1.z()-p2.z()-1.0))<0.0001){ - file2 << "NSET\tFRONTRIGHTBOTTOM = FRONTRIGHTBOTTOM + SURFACE"<<associatedFace->tag()<<"\n"; - file2 << "NSET\tBACKLEFTTOP = BACKLEFTTOP + SURFACE"<<pairTmp.first->tag()<<"\n"; - } - }else if (abs((p1.y()-p2.y()-1.0))<0.0001){ - if (abs((p2.z()-p1.z()))<0.0001){ - file2 << "NSET\tFRONTLEFT = FRONTLEFT + SURFACE"<<associatedFace->tag()<<"\n"; - file2 << "NSET\tBACKRIGHT = BACKRIGHT + SURFACE"<<pairTmp.first->tag()<<"\n"; - }else if (abs((p2.z()-p1.z()-1.0))<0.0001){ - file2 << "NSET\tFRONTLEFTTOP = FRONTLEFTTOP + SURFACE"<<associatedFace->tag()<<"\n"; - file2 << "NSET\tBACKRIGHTBOTTOM = BACKRIGHTBOTTOM + SURFACE"<<pairTmp.first->tag()<<"\n"; - }else if (abs((p1.z()-p2.z()-1.0))<0.0001){ - file2 << "NSET\tFRONTLEFTBOTTOM = FRONTLEFTBOTTOM + SURFACE"<<associatedFace->tag()<<"\n"; - file2 << "NSET\tBACKRIGHTTOP = BACKRIGHTTOP + SURFACE"<<pairTmp.first->tag()<<"\n"; - } - } - }else if (abs((p1.x()-p2.x()-1.0))<0.0001){ - if (abs((p2.y()-p1.y()))<0.0001){ - if (abs((p2.z()-p1.z()))<0.0001){ - file2 << "NSET\tFRONT = FRONT + SURFACE"<<pairTmp.first->tag()<<"\n"; - file2 << "NSET\tBACK = BACK + SURFACE"<<associatedFace->tag()<<"\n"; - }else if(abs((p2.z()-p1.z()-1.0))<0.0001){ - file2 << "NSET\tFRONTBOTTOM = FRONTBOTTOM + SURFACE"<<pairTmp.first->tag()<<"\n"; - file2 << "NSET\tBACKTOP = BACKTOP + SURFACE"<<associatedFace->tag()<<"\n"; - }else if (abs((p1.z()-p2.z()-1.0))<0.0001){ - file2 << "NSET\tFRONTTOP = FRONTTOP + SURFACE"<<pairTmp.first->tag()<<"\n"; - file2 << "NSET\tBACKBOTTOM = BACKBOTTOM + SURFACE"<<associatedFace->tag()<<"\n"; - } - }else if (abs((p2.y()-p1.y()-1.0))<0.0001){ - if (abs((p2.z()-p1.z()))<0.0001){ - file2 << "NSET\tFRONTLEFT = FRONTLEFT + SURFACE"<<pairTmp.first->tag()<<"\n"; - file2 << "NSET\tBACKRIGHT = BACKRIGHT + SURFACE"<<associatedFace->tag()<<"\n"; - }else if (abs((p2.z()-p1.z()-1.0))<0.0001){ - file2 << "NSET\tFRONTLEFTBOTTOM = FRONTLEFTBOTTOM + SURFACE"<<pairTmp.first->tag()<<"\n"; - file2 << "NSET\tBACKRIGHTTOP = BACKRIGHTTOP + SURFACE"<<associatedFace->tag()<<"\n"; - }else if (abs((p1.z()-p2.z()-1.0))<0.0001){ - file2 << "NSET\tFRONTLEFTTOP = FRONTLEFTTOP + SURFACE"<<pairTmp.first->tag()<<"\n"; - file2 << "NSET\tBACKRIGHTBOTTOM = BACKRIGHTBOTTOM + SURFACE"<<associatedFace->tag()<<"\n"; - } - }else if (abs((p1.y()-p2.y()-1.0))<0.0001){ - if (abs((p2.z()-p1.z()))<0.0001){ - file2 << "NSET\tFRONTRIGHT = FRONTRIGHT + SURFACE"<<pairTmp.first->tag()<<"\n"; - file2 << "NSET\tBACKLEFT = BACKLEFT + SURFACE"<<associatedFace->tag()<<"\n"; - }else if (abs((p2.z()-p1.z()-1.0))<0.0001){ - file2 << "NSET\tFRONTRIGHTBOTTOM = FRONTRIGHTBOTTOM + SURFACE"<<pairTmp.first->tag()<<"\n"; - file2 << "NSET\tBACKLEFTTOP = BACKLEFTTOP + SURFACE"<<associatedFace->tag()<<"\n"; - }else if (abs((p1.z()-p2.z()-1.0))<0.0001){ - file2 << "NSET\tFRONTRIGHTTOP = FRONTRIGHTTOP + SURFACE"<<pairTmp.first->tag()<<"\n"; - file2 << "NSET\tBACKLEFTBOTTOM = BACKLEFTBOTTOM + SURFACE"<<associatedFace->tag()<<"\n"; - } - } - }else if (abs((p1.x()-p2.x()))<0.0001){ - if (abs((p2.y()-p1.y()-1.0))<0.0001){ - if (abs((p2.z()-p1.z()))<0.0001){ - file2 << "NSET\tRIGHT = RIGHT + SURFACE"<<associatedFace->tag()<<"\n"; - file2 << "NSET\tLEFT = LEFT + SURFACE"<<pairTmp.first->tag()<<"\n"; - }else if (abs((p2.z()-p1.z()-1.0))<0.0001){ - file2 << "NSET\tRIGHTTOP = RIGHTTOP + SURFACE"<<associatedFace->tag()<<"\n"; - file2 << "NSET\tLEFTBOTTOM = LEFTBOTTOM + SURFACE"<<pairTmp.first->tag()<<"\n"; - }else if (abs((p1.z()-p2.z()-1.0))<0.0001){ - file2 << "NSET\tRIGHTBOTTOM = RIGHTBOTTOM + SURFACE"<<associatedFace->tag()<<"\n"; - file2 << "NSET\tLEFTTOP = LEFTTOP + SURFACE"<<pairTmp.first->tag()<<"\n"; - } - }else if (abs((p1.y()-p2.y()-1.0))<0.0001){ - if (abs((p2.z()-p1.z()))<0.0001){ - file2 << "NSET\tRIGHT = RIGHT + SURFACE"<<pairTmp.first->tag()<<"\n"; - file2 << "NSET\tLEFT = LEFT + SURFACE"<<associatedFace->tag()<<"\n"; - }else if (abs((p2.z()-p1.z()-1.0))<0.0001){ - file2 << "NSET\tRIGHTBOTTOM = RIGHTBOTTOM + SURFACE"<<pairTmp.first->tag()<<"\n"; - file2 << "NSET\tLEFTTOP = LEFTTOP + SURFACE"<<associatedFace->tag()<<"\n"; - }else if (abs((p1.z()-p2.z()-1.0))<0.0001){ - file2 << "NSET\tRIGHTTOP = RIGHTTOP + SURFACE"<<pairTmp.first->tag()<<"\n"; - file2 << "NSET\tLEFTBOTTOM = LEFTBOTTOM + SURFACE"<<associatedFace->tag()<<"\n"; - } - }else if (abs((p1.y()-p2.y()))<0.0001){ - if (abs((p2.z()-p1.z()-1.0))<0.0001){ - file2 << "NSET\tTOP = TOP + SURFACE"<<associatedFace->tag()<<"\n"; - file2 << "NSET\tBOTTOM = BOTTOM + SURFACE"<<pairTmp.first->tag()<<"\n"; - }else if (abs((p1.z()-p2.z()-1.0))<0.0001){ - file2 << "NSET\tTOP = TOP + SURFACE"<<pairTmp.first->tag()<<"\n"; - file2 << "NSET\tBOTTOM = BOTTOM + SURFACE"<<associatedFace->tag()<<"\n"; - } - } - } - // count++; - - - - - - - - newPairs.push_back(std::make_pair(pairTmp.first,associatedFace)); - } - } - // for (std::vector<std::pair<GFace*,GFace*> >::iterator itP = newPairs.begin();itP != newPairs.end();itP++){ - // std::pair<GFace*,GFace*> pairTmp = (*itP); - // } - - std::cout<<"End of DuplicateBoundaries"<<std::endl; - return view; -} - - - - - - - - - - - -PView *GMSH_DuplicateBoundariesPlugin::execute2D(PView *view) -{ - std::cout<<"starting DuplicateBoundaries"<<std::endl; - GModel *m = GModel::current(); - m->setFactory("geo"); - std::set<GEdge*> ToDuplicateList; - ToDuplicateList.clear(); - std::set<GFace*> ToDuplicateListBoundary; - ToDuplicateListBoundary.clear(); - std::vector<GFace*> facesBound; - facesBound.clear(); - std::map<GFace*,SPoint3> centers; - std::vector<std::pair<GFace*,GFace*> > pairs; - std::vector<std::pair<GFace*,GFace*> > newPairs; - int PhysicalInterface = m->setPhysicalName("Interface",2); - for (GModel::eiter ite= m->firstEdge();ite != m->lastEdge();ite++){ - GEdge* eTmp = (*ite); - if (eTmp->faces().size() == 2){ - ToDuplicateList.insert(eTmp); - } - } - - - - - - - - - - - std::map<std::pair<MVertex*,GFace*>,MVertex* > VertexGlobalAssociation; - std::map<std::pair<GVertex*,GFace*>,GVertex* > GVertexGlobalAssociation; - std::map<std::pair<GEdge*,GFace*>,GEdge* > GEdgeGlobalAssociation; - std::map<std::pair<GFace*,GRegion*>,GFace* > GFaceGlobalAssociation; - for (GModel::fiter itr= m->firstFace();itr != m->lastFace();itr++){ - GFace* rTmp = (*itr); - std::list<GEdge*> RegEdges = rTmp->edges(); - std::map<MVertex*,MVertex* > VertexAssociation; - std::map<GVertex*,GVertex* > GVertexAssociation; - std::map<GEdge*,GEdge* > GEdgeAssociation; - //int counterNbDone = 10000; - double xCenterReg = 0.0; - double yCenterReg = 0.0; - double zCenterReg = 0.0; - int counterPts = 0; - for(std::list<GEdge*>::iterator it2=RegEdges.begin();it2!=RegEdges.end();it2++){ - GEdge* fTemp = (*it2); - std::list<GVertex*> verticesFace = fTemp->vertices(); - for (std::list<GVertex*>::iterator it3=verticesFace.begin();it3!=verticesFace.end();it3++){ - xCenterReg = xCenterReg + (*it3)->x(); - yCenterReg = yCenterReg + (*it3)->y(); - zCenterReg = zCenterReg + (*it3)->z(); - counterPts++; - } - } - xCenterReg = xCenterReg/counterPts; - yCenterReg = yCenterReg/counterPts; - zCenterReg = zCenterReg/counterPts; - //duplication noeud et aretes au niveau de la region directement - std::list<GVertex*> vlist; - - - std::list<GEdge*> listedgesTmp = rTmp->edges(); - std::cout<<"listeEdge size "<<listedgesTmp.size()<<std::endl; - for (std::list<GEdge*>::iterator itTp = listedgesTmp.begin();itTp != listedgesTmp.end();itTp++){ - std::list<GVertex*> vlist2; - if(std::find(vlist.begin(), vlist.end(),(*itTp)->getBeginVertex()) == vlist.end()) - vlist.push_back((*itTp)->getBeginVertex()); - if(std::find(vlist.begin(), vlist.end(),(*itTp)->getEndVertex()) == vlist.end()) - vlist.push_back((*itTp)->getEndVertex()); - } - - - for (std::list<GVertex*>::iterator itv = vlist.begin();itv != vlist.end();itv++){ - //duplication Gvertex - GVertex* vTmp = (*itv); - double ponderatedX = 0.99999999999 * vTmp->x() + 0.00000000001 * xCenterReg; - double ponderatedY = 0.99999999999 * vTmp->y() + 0.00000000001 * yCenterReg; - double ponderatedZ = 0.99999999999 * vTmp->z() + 0.00000000001 * zCenterReg; - GVertex* newv = m->addVertex(ponderatedX,ponderatedY,ponderatedZ,vTmp->prescribedMeshSizeAtVertex()); - GVertexAssociation[vTmp] = newv; - GVertexGlobalAssociation[std::make_pair(vTmp,rTmp)] = newv; - //creation des Gedge correspondantes - // GEdge* newE = m->addLine(vTmp,newv); - // SurroudingEdges[vTmp] = newE; - //maintenant traitement mesh - MVertex *vMesh = vTmp->mesh_vertices[0]; - MVertex *newMv = new MVertex(vMesh->x(), vMesh->y(), vMesh->z(), (GEntity*)newv); - VertexAssociation[vMesh] = newMv; - VertexGlobalAssociation[std::make_pair(vMesh,rTmp)] = newMv; - newv->addMeshVertex(newMv); - } - //maintenant on soccupe de duppliquer les edges de la region - std::list<GEdge*> elist = rTmp->edges(); - - std::vector<GFace*> SurroundingsFaces; - for (std::list<GEdge*>::iterator itf = RegEdges.begin();itf != RegEdges.end();itf++){ - GEdge* eTmp = (*itf); - //creation de la nouvelle face - GEdge* newE = m->addLine(GVertexAssociation[eTmp->getBeginVertex()],GVertexAssociation[eTmp->getEndVertex()]); - for (unsigned int i = 0; i < eTmp->mesh_vertices.size();i++){ - MVertex *vMesh = eTmp->mesh_vertices[i]; - MVertex *newMv = new MVertex(vMesh->x(), vMesh->y(), vMesh->z(), (GEntity*)newE); - VertexAssociation[vMesh] = newMv; - VertexGlobalAssociation[std::make_pair(vMesh,rTmp)] = newMv; - newE->addMeshVertex(newMv); - } - for (unsigned int i = 0; i < eTmp->getNumMeshElements();i++){ - MElement* elem = eTmp->getMeshElement(i); - MVertex *firstETmp = VertexAssociation.find(elem->getVertex(0))->second; - MVertex *lastETmp = VertexAssociation.find(elem->getVertex(1))->second; - MVertex *midETmp = VertexAssociation.find(elem->getVertex(2))->second; - MLine3 *newLine = new MLine3(firstETmp,lastETmp,midETmp); - newE->addLine(newLine); - } - GEdgeGlobalAssociation[std::make_pair(eTmp,rTmp)] = newE; - } - } - int counterNbDone = 10000; - //maintenant on va traiter les faces initiales - for (std::set<GEdge*>::iterator itf = ToDuplicateList.begin();itf != ToDuplicateList.end();itf++){ - counterNbDone++; - GEdge* eTmp = (*itf); - std::list<GFace*> listFacesTmpT = eTmp->faces(); - std::list<GFace*>::iterator itTmpFace = listFacesTmpT.begin(); - GFace* fac1 = (*itTmpFace); - itTmpFace++; - GFace* fac2 = (*itTmpFace); - //pour commencer on cree des aretes entre les vertex - // std::list<GVertex*> vlist = eTmp->vertices(); - std::list<GVertex*> vlist; - vlist.push_back(eTmp->getBeginVertex()); - vlist.push_back(eTmp->getEndVertex()); - std::map<GVertex*,GEdge* > SurroudingEdges; - for (std::list<GVertex*>::iterator itv = vlist.begin();itv != vlist.end();itv++){ - GVertex* vTmp = (*itv); - GVertex* v1=0; - GVertex* v2=0; - std::map<std::pair<GVertex*,GFace*>,GVertex* >::iterator itMap = GVertexGlobalAssociation.find(std::make_pair(vTmp,fac1)); - if (itMap != GVertexGlobalAssociation.end()){ - v1 = itMap->second; - } - itMap = GVertexGlobalAssociation.find(std::make_pair(vTmp,fac2)); - if (itMap != GVertexGlobalAssociation.end()){ - v2 = itMap->second; - } - GEdge* newE = m->addLine(v1,v2); - SurroudingEdges[vTmp] = newE; - } - //ici tous les vertex sont traites - //on va traiter les edges - // std::list<GEdge*> elist = fTmp->edges(); - std::vector<GEdge*> newEdgesVector; - std::vector<GFace*> SurroundingsFaces; - //duplication Gedge - // GEdge* eTmp = (*ite); - GEdge* e1=0; - GEdge* e2=0; - std::map<std::pair<GEdge*,GFace*>,GEdge* >::iterator itMap = GEdgeGlobalAssociation.find(std::make_pair(eTmp,fac1)); - if (itMap != GEdgeGlobalAssociation.end()){ - e1 = itMap->second; - } - itMap = GEdgeGlobalAssociation.find(std::make_pair(eTmp,fac2)); - if (itMap != GEdgeGlobalAssociation.end()){ - e2 = itMap->second; - } - //creation des GFace correspondantes - GEdge* firstE = SurroudingEdges.find(eTmp->getBeginVertex())->second; - GEdge* lastE = SurroudingEdges.find(eTmp->getEndVertex())->second; - if (firstE->getBeginVertex() != e1->getEndVertex()){ - firstE->reverse(); - } - if (firstE->getBeginVertex() != e1->getEndVertex()){ - e1->reverse(); - } - if (firstE->getBeginVertex() != e1->getEndVertex()){ - firstE->reverse(); - } - if (e2->getBeginVertex() != firstE->getEndVertex()){ - e2->reverse(); - } - if (lastE->getBeginVertex() != e2->getEndVertex()){ - lastE->reverse(); - } - std::vector<GEdge*> VecEdgesTmp; - VecEdgesTmp.push_back(e1); - VecEdgesTmp.push_back(firstE); - VecEdgesTmp.push_back(e2); - VecEdgesTmp.push_back(lastE); - std::vector<std::vector<GEdge*> > VecOfVecTmp; - VecOfVecTmp.push_back(VecEdgesTmp); - GFace* newFaceTmp = m->addPlanarFace(VecOfVecTmp); - // SurroundingsFaces.push_back(newFaceTmp); - - //creation de la nouvelle region - // GRegion* createdRegion = new GRegion(m,counterNbDone); - newFaceTmp->addPhysicalEntity(PhysicalInterface); - // createdRegion->set(listFaces); - // m->add(createdRegion); - for (unsigned int i = 0; i < eTmp->getNumMeshElements();i++){ - MElement* elem = eTmp->getMeshElement(i); - MVertex* v1=0; - MVertex* v2=0; - MVertex* v3=0; - MVertex* v4=0; - //MVertex* v5; - //MVertex* v6; - std::map<std::pair<MVertex*,GFace*>,MVertex* >::iterator itMap = VertexGlobalAssociation.find(std::make_pair(elem->getVertex(0),fac1)); - if (itMap != VertexGlobalAssociation.end()){ - v1 = itMap->second; - } - itMap = VertexGlobalAssociation.find(std::make_pair(elem->getVertex(2),fac1)); - if (itMap != VertexGlobalAssociation.end()){ - v2 = itMap->second; - } - itMap = VertexGlobalAssociation.find(std::make_pair(elem->getVertex(2),fac2)); - if (itMap != VertexGlobalAssociation.end()){ - v3 = itMap->second; - } - itMap = VertexGlobalAssociation.find(std::make_pair(elem->getVertex(0),fac2)); - if (itMap != VertexGlobalAssociation.end()){ - v4 = itMap->second; - } - // itMap = VertexGlobalAssociation.find(std::make_pair(elem->getVertex(3),fac2)); - // if (itMap != VertexGlobalAssociation.end()){ - // v5 = itMap->second; - // } - // itMap = VertexGlobalAssociation.find(std::make_pair(elem->getVertex(5),fac2)); - // if (itMap != VertexGlobalAssociation.end()){ - // v6 = itMap->second; - // } - MQuadrangle *newQua = new MQuadrangle(v1,v2,v3,v4); - - newFaceTmp->addQuadrangle(newQua); - - //second - itMap = VertexGlobalAssociation.find(std::make_pair(elem->getVertex(2),fac1)); - if (itMap != VertexGlobalAssociation.end()){ - v1 = itMap->second; - } - itMap = VertexGlobalAssociation.find(std::make_pair(elem->getVertex(1),fac1)); - if (itMap != VertexGlobalAssociation.end()){ - v2 = itMap->second; - } - itMap = VertexGlobalAssociation.find(std::make_pair(elem->getVertex(1),fac2)); - if (itMap != VertexGlobalAssociation.end()){ - v3 = itMap->second; - } - itMap = VertexGlobalAssociation.find(std::make_pair(elem->getVertex(2),fac2)); - if (itMap != VertexGlobalAssociation.end()){ - v4 = itMap->second; - } - // itMap = VertexGlobalAssociation.find(std::make_pair(elem->getVertex(3),fac2)); - // if (itMap != VertexGlobalAssociation.end()){ - // v5 = itMap->second; - // } - // itMap = VertexGlobalAssociation.find(std::make_pair(elem->getVertex(5),fac2)); - // if (itMap != VertexGlobalAssociation.end()){ - // v6 = itMap->second; - // } - MQuadrangle *newQua2 = new MQuadrangle(v1,v2,v3,v4); - - newFaceTmp->addQuadrangle(newQua2); - - - - - } - for (unsigned int i = 0; i < fac1->getNumMeshElements();i++){ - MElement* elem = fac1->getMeshElement(i); - for (int j = 0;j < elem->getNumVertices();j++){ - MVertex* vert = elem->getVertex(j); - std::map<std::pair<MVertex*,GFace*>,MVertex* >::iterator itMap = VertexGlobalAssociation.find(std::make_pair(vert,fac1)); - if (itMap != VertexGlobalAssociation.end()){ - elem->setVertex(j,itMap->second); - } - } - } - for (unsigned int i = 0; i < fac2->getNumMeshElements();i++){ - MElement* elem = fac2->getMeshElement(i); - for (int j = 0;j < elem->getNumVertices();j++){ - MVertex* vert = elem->getVertex(j); - std::map<std::pair<MVertex*,GFace*>,MVertex* >::iterator itMap = VertexGlobalAssociation.find(std::make_pair(vert,fac2)); - if (itMap != VertexGlobalAssociation.end()){ - elem->setVertex(j,itMap->second); - } - } - } - } - //maintenant on va traiter les faces du bord - // std::ofstream file("MicrostructurePolycrystal3D.pos"); - // file << "View \"test\" {\n"; - // - // std::ofstream file2("PERIODIC.map"); - // std::ofstream file3("SetAdd.map"); - // for (std::vector<std::pair<GFace*,GFace*> >::iterator itP = pairs.begin();itP != pairs.end();itP++){ - // std::pair<GFace*,GFace*> pairTmp = (*itP); - // GFace* ToReplaceFace = pairTmp.second; - // GRegion* rTmp = ToReplaceFace->getRegion(0); - // std::map<std::pair<GFace*,GRegion*>,GFace* >::iterator itMap = GFaceGlobalAssociation.find(std::make_pair(ToReplaceFace,rTmp)); - // if (itMap != GFaceGlobalAssociation.end()){ - // GFace* associatedFace = (*itMap).second; - // - // - // - // - // - // file3 <<associatedFace->tag()<<"\tSURFACE"<<associatedFace->tag()<<"\tNSET "<<"\n"; - // - // int tagTmp = associatedFace->tag(); - // std::ostringstream ss; - // ss << tagTmp; - //// char *intStr = itoa(tagTmp); - // std::string nameSurf = "SURFACE"; - //// nameSurf += std::string(intStr); - // nameSurf += ss.str(); - // int PhysicalSurfaceTmp = m->setPhysicalName(nameSurf,2); - // associatedFace->addPhysicalEntity(PhysicalSurfaceTmp); - // - // std::map<GFace*,SPoint3>::iterator it3 = centers.find(pairTmp.first); - // std::map<GFace*,SPoint3>::iterator it4 = centers.find(ToReplaceFace); - // - // SPoint3 p1 = it3->second; - // SPoint3 p2 = it4->second; - // - // double delta_x = fabs(p2.x()-p1.x()); - // double delta_y = fabs(p2.y()-p1.y()); - // double delta_z = fabs(p2.z()-p1.z()); - // - // - // file << "SL (" - // << p1.x() << ", " << p1.y() << ", " << p1.z() << ", " - // << p2.x() << ", " << p2.y() << ", " << p2.z() - // << "){10, 20};\n"; - // - // //file2 << "PERIODIC\tSURFACE"<<faces[i]->tag() << "\tSURFACE" << faces[j]->tag() << "\t" << p2.x()-p1.x() << "\t" << p2.y()-p1.y() << "\t" << p2.z()-p1.z() << "\n"; - // if (abs((p2.x()-p1.x()-1.0))<0.0001){ - // if (abs((p2.y()-p1.y()))<0.0001){ - // if (abs((p2.z()-p1.z()))<0.0001){ - // file2 << "NSET\tFRONT = FRONT + SURFACE"<<associatedFace->tag()<<"\n"; - // file2 << "NSET\tBACK = BACK + SURFACE"<<pairTmp.first->tag()<<"\n"; - // }else if(abs((p2.z()-p1.z()-1.0))<0.0001){ - // file2 << "NSET\tFRONTTOP = FRONTTOP + SURFACE"<<associatedFace->tag()<<"\n"; - // file2 << "NSET\tBACKBOTTOM = BACKBOTTOM + SURFACE"<<pairTmp.first->tag()<<"\n"; - // }else if (abs((p1.z()-p2.z()-1.0))<0.0001){ - // file2 << "NSET\tFRONTBOTTOM = FRONTBOTTOM + SURFACE"<<associatedFace->tag()<<"\n"; - // file2 << "NSET\tBACKTOP = BACKTOP + SURFACE"<<pairTmp.first->tag()<<"\n"; - // } - // }else if (abs((p2.y()-p1.y()-1.0))<0.0001){ - // if (abs((p2.z()-p1.z()))<0.0001){ - // file2 << "NSET\tFRONTRIGHT = FRONTRIGHT + SURFACE"<<associatedFace->tag()<<"\n"; - // file2 << "NSET\tBACKLEFT = BACKLEFT + SURFACE"<<pairTmp.first->tag()<<"\n"; - // }else if (abs((p2.z()-p1.z()-1.0))<0.0001){ - // file2 << "NSET\tFRONTRIGHTTOP = FRONTRIGHTTOP + SURFACE"<<associatedFace->tag()<<"\n"; - // file2 << "NSET\tBACKLEFTBOTTOM = BACKLEFTBOTTOM + SURFACE"<<pairTmp.first->tag()<<"\n"; - // }else if (abs((p1.z()-p2.z()-1.0))<0.0001){ - // file2 << "NSET\tFRONTRIGHTBOTTOM = FRONTRIGHTBOTTOM + SURFACE"<<associatedFace->tag()<<"\n"; - // file2 << "NSET\tBACKLEFTTOP = BACKLEFTTOP + SURFACE"<<pairTmp.first->tag()<<"\n"; - // } - // }else if (abs((p1.y()-p2.y()-1.0))<0.0001){ - // if (abs((p2.z()-p1.z()))<0.0001){ - // file2 << "NSET\tFRONTLEFT = FRONTLEFT + SURFACE"<<associatedFace->tag()<<"\n"; - // file2 << "NSET\tBACKRIGHT = BACKRIGHT + SURFACE"<<pairTmp.first->tag()<<"\n"; - // }else if (abs((p2.z()-p1.z()-1.0))<0.0001){ - // file2 << "NSET\tFRONTLEFTTOP = FRONTLEFTTOP + SURFACE"<<associatedFace->tag()<<"\n"; - // file2 << "NSET\tBACKRIGHTBOTTOM = BACKRIGHTBOTTOM + SURFACE"<<pairTmp.first->tag()<<"\n"; - // }else if (abs((p1.z()-p2.z()-1.0))<0.0001){ - // file2 << "NSET\tFRONTLEFTBOTTOM = FRONTLEFTBOTTOM + SURFACE"<<associatedFace->tag()<<"\n"; - // file2 << "NSET\tBACKRIGHTTOP = BACKRIGHTTOP + SURFACE"<<pairTmp.first->tag()<<"\n"; - // } - // } - // }else if (abs((p1.x()-p2.x()-1.0))<0.0001){ - // if (abs((p2.y()-p1.y()))<0.0001){ - // if (abs((p2.z()-p1.z()))<0.0001){ - // file2 << "NSET\tFRONT = FRONT + SURFACE"<<pairTmp.first->tag()<<"\n"; - // file2 << "NSET\tBACK = BACK + SURFACE"<<associatedFace->tag()<<"\n"; - // }else if(abs((p2.z()-p1.z()-1.0))<0.0001){ - // file2 << "NSET\tFRONTBOTTOM = FRONTBOTTOM + SURFACE"<<pairTmp.first->tag()<<"\n"; - // file2 << "NSET\tBACKTOP = BACKTOP + SURFACE"<<associatedFace->tag()<<"\n"; - // }else if (abs((p1.z()-p2.z()-1.0))<0.0001){ - // file2 << "NSET\tFRONTTOP = FRONTTOP + SURFACE"<<pairTmp.first->tag()<<"\n"; - // file2 << "NSET\tBACKBOTTOM = BACKBOTTOM + SURFACE"<<associatedFace->tag()<<"\n"; - // } - // }else if (abs((p2.y()-p1.y()-1.0))<0.0001){ - // if (abs((p2.z()-p1.z()))<0.0001){ - // file2 << "NSET\tFRONTLEFT = FRONTLEFT + SURFACE"<<pairTmp.first->tag()<<"\n"; - // file2 << "NSET\tBACKRIGHT = BACKRIGHT + SURFACE"<<associatedFace->tag()<<"\n"; - // }else if (abs((p2.z()-p1.z()-1.0))<0.0001){ - // file2 << "NSET\tFRONTLEFTBOTTOM = FRONTLEFTBOTTOM + SURFACE"<<pairTmp.first->tag()<<"\n"; - // file2 << "NSET\tBACKRIGHTTOP = BACKRIGHTTOP + SURFACE"<<associatedFace->tag()<<"\n"; - // }else if (abs((p1.z()-p2.z()-1.0))<0.0001){ - // file2 << "NSET\tFRONTLEFTTOP = FRONTLEFTTOP + SURFACE"<<pairTmp.first->tag()<<"\n"; - // file2 << "NSET\tBACKRIGHTBOTTOM = BACKRIGHTBOTTOM + SURFACE"<<associatedFace->tag()<<"\n"; - // } - // }else if (abs((p1.y()-p2.y()-1.0))<0.0001){ - // if (abs((p2.z()-p1.z()))<0.0001){ - // file2 << "NSET\tFRONTRIGHT = FRONTRIGHT + SURFACE"<<pairTmp.first->tag()<<"\n"; - // file2 << "NSET\tBACKLEFT = BACKLEFT + SURFACE"<<associatedFace->tag()<<"\n"; - // }else if (abs((p2.z()-p1.z()-1.0))<0.0001){ - // file2 << "NSET\tFRONTRIGHTBOTTOM = FRONTRIGHTBOTTOM + SURFACE"<<pairTmp.first->tag()<<"\n"; - // file2 << "NSET\tBACKLEFTTOP = BACKLEFTTOP + SURFACE"<<associatedFace->tag()<<"\n"; - // }else if (abs((p1.z()-p2.z()-1.0))<0.0001){ - // file2 << "NSET\tFRONTRIGHTTOP = FRONTRIGHTTOP + SURFACE"<<pairTmp.first->tag()<<"\n"; - // file2 << "NSET\tBACKLEFTBOTTOM = BACKLEFTBOTTOM + SURFACE"<<associatedFace->tag()<<"\n"; - // } - // } - // }else if (abs((p1.x()-p2.x()))<0.0001){ - // if (abs((p2.y()-p1.y()-1.0))<0.0001){ - // if (abs((p2.z()-p1.z()))<0.0001){ - // file2 << "NSET\tRIGHT = RIGHT + SURFACE"<<associatedFace->tag()<<"\n"; - // file2 << "NSET\tLEFT = LEFT + SURFACE"<<pairTmp.first->tag()<<"\n"; - // }else if (abs((p2.z()-p1.z()-1.0))<0.0001){ - // file2 << "NSET\tRIGHTTOP = RIGHTTOP + SURFACE"<<associatedFace->tag()<<"\n"; - // file2 << "NSET\tLEFTBOTTOM = LEFTBOTTOM + SURFACE"<<pairTmp.first->tag()<<"\n"; - // }else if (abs((p1.z()-p2.z()-1.0))<0.0001){ - // file2 << "NSET\tRIGHTBOTTOM = RIGHTBOTTOM + SURFACE"<<associatedFace->tag()<<"\n"; - // file2 << "NSET\tLEFTTOP = LEFTTOP + SURFACE"<<pairTmp.first->tag()<<"\n"; - // } - // }else if (abs((p1.y()-p2.y()-1.0))<0.0001){ - // if (abs((p2.z()-p1.z()))<0.0001){ - // file2 << "NSET\tRIGHT = RIGHT + SURFACE"<<pairTmp.first->tag()<<"\n"; - // file2 << "NSET\tLEFT = LEFT + SURFACE"<<associatedFace->tag()<<"\n"; - // }else if (abs((p2.z()-p1.z()-1.0))<0.0001){ - // file2 << "NSET\tRIGHTBOTTOM = RIGHTBOTTOM + SURFACE"<<pairTmp.first->tag()<<"\n"; - // file2 << "NSET\tLEFTTOP = LEFTTOP + SURFACE"<<associatedFace->tag()<<"\n"; - // }else if (abs((p1.z()-p2.z()-1.0))<0.0001){ - // file2 << "NSET\tRIGHTTOP = RIGHTTOP + SURFACE"<<pairTmp.first->tag()<<"\n"; - // file2 << "NSET\tLEFTBOTTOM = LEFTBOTTOM + SURFACE"<<associatedFace->tag()<<"\n"; - // } - // }else if (abs((p1.y()-p2.y()))<0.0001){ - // if (abs((p2.z()-p1.z()-1.0))<0.0001){ - // file2 << "NSET\tTOP = TOP + SURFACE"<<associatedFace->tag()<<"\n"; - // file2 << "NSET\tBOTTOM = BOTTOM + SURFACE"<<pairTmp.first->tag()<<"\n"; - // }else if (abs((p1.z()-p2.z()-1.0))<0.0001){ - // file2 << "NSET\tTOP = TOP + SURFACE"<<pairTmp.first->tag()<<"\n"; - // file2 << "NSET\tBOTTOM = BOTTOM + SURFACE"<<associatedFace->tag()<<"\n"; - // } - // } - // } - //// count++; - // - // - // - // - // - // - // - // newPairs.push_back(std::make_pair(pairTmp.first,associatedFace)); - // } - // } - // for (std::vector<std::pair<GFace*,GFace*> >::iterator itP = newPairs.begin();itP != newPairs.end();itP++){ - // std::pair<GFace*,GFace*> pairTmp = (*itP); - // } - - std::cout<<"End of DuplicateBoundaries"<<std::endl; - return view; -} - - - - - - - - - - - - - - - - - - - - - - - - - -PView *GMSH_DuplicateBoundariesPlugin::execute2DWithBound(PView *view) -{ - std::cout<<"starting DuplicateBoundaries"<<std::endl; - GModel *m = GModel::current(); - m->setFactory("geo"); - std::set<GEdge*> ToDuplicateList; - ToDuplicateList.clear(); - std::set<GEdge*> ToDuplicateListBoundary; - ToDuplicateListBoundary.clear(); - std::vector<GFace*> facesBound; - facesBound.clear(); - std::map<GFace*,SPoint3> centers; - std::vector<std::pair<GFace*,GFace*> > pairs; - std::vector<std::pair<GFace*,GFace*> > newPairs; - int PhysicalInterface = m->setPhysicalName("Interface",2); - - for (GModel::eiter ite= m->firstEdge();ite != m->lastEdge();ite++){ - GEdge* eTmp = (*ite); - if (eTmp->faces().size() == 2){ - ToDuplicateList.insert(eTmp); - } - else{ - ToDuplicateListBoundary.insert(eTmp); - } - } - - - - - - - - - - - std::map<std::pair<MVertex*,GFace*>,MVertex* > VertexGlobalAssociation; - std::map<std::pair<GVertex*,GFace*>,GVertex* > GVertexGlobalAssociation; - std::map<std::pair<GEdge*,GFace*>,GEdge* > GEdgeGlobalAssociation; - std::map<std::pair<GFace*,GRegion*>,GFace* > GFaceGlobalAssociation; - for (GModel::fiter itr= m->firstFace();itr != m->lastFace();itr++){ - GFace* rTmp = (*itr); - std::list<GEdge*> RegEdges = rTmp->edges(); - std::map<MVertex*,MVertex* > VertexAssociation; - std::map<GVertex*,GVertex* > GVertexAssociation; - std::map<GEdge*,GEdge* > GEdgeAssociation; - //int counterNbDone = 10000; - double xCenterReg = 0.0; - double yCenterReg = 0.0; - double zCenterReg = 0.0; - int counterPts = 0; - for(std::list<GEdge*>::iterator it2=RegEdges.begin();it2!=RegEdges.end();it2++){ - GEdge* fTemp = (*it2); - std::list<GVertex*> verticesFace = fTemp->vertices(); - for (std::list<GVertex*>::iterator it3=verticesFace.begin();it3!=verticesFace.end();it3++){ - xCenterReg = xCenterReg + (*it3)->x(); - yCenterReg = yCenterReg + (*it3)->y(); - zCenterReg = zCenterReg + (*it3)->z(); - counterPts++; - } - } - xCenterReg = xCenterReg/counterPts; - yCenterReg = yCenterReg/counterPts; - zCenterReg = zCenterReg/counterPts; - //duplication noeud et aretes au niveau de la region directement - std::list<GVertex*> vlist; - - - std::list<GEdge*> listedgesTmp = rTmp->edges(); - for (std::list<GEdge*>::iterator itTp = listedgesTmp.begin();itTp != listedgesTmp.end();itTp++){ - std::list<GVertex*> vlist2; - if(std::find(vlist.begin(), vlist.end(),(*itTp)->getBeginVertex()) == vlist.end()) - vlist.push_back((*itTp)->getBeginVertex()); - if(std::find(vlist.begin(), vlist.end(),(*itTp)->getEndVertex()) == vlist.end()) - vlist.push_back((*itTp)->getEndVertex()); - } - - - for (std::list<GVertex*>::iterator itv = vlist.begin();itv != vlist.end();itv++){ - //duplication Gvertex - GVertex* vTmp = (*itv); - double ponderatedX = 0.99999999999 * vTmp->x() + 0.00000000001 * xCenterReg; - double ponderatedY = 0.99999999999 * vTmp->y() + 0.00000000001 * yCenterReg; - double ponderatedZ = 0.99999999999 * vTmp->z() + 0.00000000001 * zCenterReg; - GVertex* newv = m->addVertex(ponderatedX,ponderatedY,ponderatedZ,vTmp->prescribedMeshSizeAtVertex()); - GVertexAssociation[vTmp] = newv; - GVertexGlobalAssociation[std::make_pair(vTmp,rTmp)] = newv; - //creation des Gedge correspondantes - // GEdge* newE = m->addLine(vTmp,newv); - // SurroudingEdges[vTmp] = newE; - //maintenant traitement mesh - MVertex *vMesh = vTmp->mesh_vertices[0]; - MVertex *newMv = new MVertex(vMesh->x(), vMesh->y(), vMesh->z(), (GEntity*)newv); - VertexAssociation[vMesh] = newMv; - VertexGlobalAssociation[std::make_pair(vMesh,rTmp)] = newMv; - newv->addMeshVertex(newMv); - } - //maintenant on soccupe de duppliquer les edges de la region - std::list<GEdge*> elist = rTmp->edges(); - - std::vector<GFace*> SurroundingsFaces; - for (std::list<GEdge*>::iterator itf = RegEdges.begin();itf != RegEdges.end();itf++){ - GEdge* eTmp = (*itf); - GEdge* newE = m->addLine(GVertexAssociation[eTmp->getBeginVertex()],GVertexAssociation[eTmp->getEndVertex()]); - for (unsigned int i = 0; i < eTmp->mesh_vertices.size();i++){ - MVertex *vMesh = eTmp->mesh_vertices[i]; - MVertex *newMv = new MVertex(vMesh->x(), vMesh->y(), vMesh->z(), (GEntity*)newE); - VertexAssociation[vMesh] = newMv; - VertexGlobalAssociation[std::make_pair(vMesh,rTmp)] = newMv; - newE->addMeshVertex(newMv); - } - for (unsigned int i = 0; i < eTmp->getNumMeshElements();i++){ - MElement* elem = eTmp->getMeshElement(i); - MVertex *firstETmp = VertexAssociation.find(elem->getVertex(0))->second; - MVertex *lastETmp = VertexAssociation.find(elem->getVertex(1))->second; - MVertex *midETmp = VertexAssociation.find(elem->getVertex(2))->second; - MLine3 *newLine = new MLine3(firstETmp,lastETmp,midETmp); - newE->addLine(newLine); - } - GEdgeGlobalAssociation[std::make_pair(eTmp,rTmp)] = newE; - } - } - int counterNbDone = 10000; - //maintenant on va traiter les faces initiales - for (std::set<GEdge*>::iterator itf = ToDuplicateList.begin();itf != ToDuplicateList.end();itf++){ - counterNbDone++; - GEdge* eTmp = (*itf); - std::list<GFace*> listFacesTmpT = eTmp->faces(); - std::list<GFace*>::iterator itTmpFace = listFacesTmpT.begin(); - GFace* fac1 = (*itTmpFace); - itTmpFace++; - GFace* fac2 = (*itTmpFace); - //pour commencer on cree des aretes entre les vertex - // std::list<GVertex*> vlist = eTmp->vertices(); - std::list<GVertex*> vlist; - vlist.push_back(eTmp->getBeginVertex()); - vlist.push_back(eTmp->getEndVertex()); - std::map<GVertex*,GEdge* > SurroudingEdges; - for (std::list<GVertex*>::iterator itv = vlist.begin();itv != vlist.end();itv++){ - GVertex* vTmp = (*itv); - GVertex* v1=0; - GVertex* v2=0; - std::map<std::pair<GVertex*,GFace*>,GVertex* >::iterator itMap = GVertexGlobalAssociation.find(std::make_pair(vTmp,fac1)); - if (itMap != GVertexGlobalAssociation.end()){ - v1 = itMap->second; - } - itMap = GVertexGlobalAssociation.find(std::make_pair(vTmp,fac2)); - if (itMap != GVertexGlobalAssociation.end()){ - v2 = itMap->second; - } - GEdge* newE = m->addLine(v1,v2); - SurroudingEdges[vTmp] = newE; - } - //ici tous les vertex sont traites - //on va traiter les edges - std::vector<GEdge*> newEdgesVector; - std::vector<GFace*> SurroundingsFaces; - //duplication Gedge - // GEdge* eTmp = (*ite); - GEdge* e1=0; - GEdge* e2=0; - std::map<std::pair<GEdge*,GFace*>,GEdge* >::iterator itMap = GEdgeGlobalAssociation.find(std::make_pair(eTmp,fac1)); - if (itMap != GEdgeGlobalAssociation.end()){ - e1 = itMap->second; - } - itMap = GEdgeGlobalAssociation.find(std::make_pair(eTmp,fac2)); - if (itMap != GEdgeGlobalAssociation.end()){ - e2 = itMap->second; - } - //creation des GFace correspondantes - GEdge* firstE = SurroudingEdges.find(eTmp->getBeginVertex())->second; - GEdge* lastE = SurroudingEdges.find(eTmp->getEndVertex())->second; - if (firstE->getBeginVertex() != e1->getEndVertex()){ - firstE->reverse(); - } - if (firstE->getBeginVertex() != e1->getEndVertex()){ - e1->reverse(); - } - if (firstE->getBeginVertex() != e1->getEndVertex()){ - firstE->reverse(); - } - if (e2->getBeginVertex() != firstE->getEndVertex()){ - e2->reverse(); - } - if (lastE->getBeginVertex() != e2->getEndVertex()){ - lastE->reverse(); - } - std::vector<GEdge*> VecEdgesTmp; - VecEdgesTmp.push_back(e1); - VecEdgesTmp.push_back(firstE); - VecEdgesTmp.push_back(e2); - VecEdgesTmp.push_back(lastE); - std::vector<std::vector<GEdge*> > VecOfVecTmp; - VecOfVecTmp.push_back(VecEdgesTmp); - GFace* newFaceTmp = m->addPlanarFace(VecOfVecTmp); - // SurroundingsFaces.push_back(newFaceTmp); - - //creation de la nouvelle region - // GRegion* createdRegion = new GRegion(m,counterNbDone); - newFaceTmp->addPhysicalEntity(PhysicalInterface); - // createdRegion->set(listFaces); - // m->add(createdRegion); - for (unsigned int i = 0; i < eTmp->getNumMeshElements();i++){ - MElement* elem = eTmp->getMeshElement(i); - MVertex* v1=0; - MVertex* v2=0; - MVertex* v3=0; - MVertex* v4=0; - //MVertex* v5; - //MVertex* v6; - std::map<std::pair<MVertex*,GFace*>,MVertex* >::iterator itMap = VertexGlobalAssociation.find(std::make_pair(elem->getVertex(0),fac1)); - if (itMap != VertexGlobalAssociation.end()){ - v1 = itMap->second; - } - itMap = VertexGlobalAssociation.find(std::make_pair(elem->getVertex(2),fac1)); - if (itMap != VertexGlobalAssociation.end()){ - v2 = itMap->second; - } - itMap = VertexGlobalAssociation.find(std::make_pair(elem->getVertex(2),fac2)); - if (itMap != VertexGlobalAssociation.end()){ - v3 = itMap->second; - } - itMap = VertexGlobalAssociation.find(std::make_pair(elem->getVertex(0),fac2)); - if (itMap != VertexGlobalAssociation.end()){ - v4 = itMap->second; - } - // itMap = VertexGlobalAssociation.find(std::make_pair(elem->getVertex(3),fac2)); - // if (itMap != VertexGlobalAssociation.end()){ - // v5 = itMap->second; - // } - // itMap = VertexGlobalAssociation.find(std::make_pair(elem->getVertex(5),fac2)); - // if (itMap != VertexGlobalAssociation.end()){ - // v6 = itMap->second; - // } - MQuadrangle *newQua = new MQuadrangle(v1,v2,v3,v4); - - newFaceTmp->addQuadrangle(newQua); - - //second - itMap = VertexGlobalAssociation.find(std::make_pair(elem->getVertex(2),fac1)); - if (itMap != VertexGlobalAssociation.end()){ - v1 = itMap->second; - } - itMap = VertexGlobalAssociation.find(std::make_pair(elem->getVertex(1),fac1)); - if (itMap != VertexGlobalAssociation.end()){ - v2 = itMap->second; - } - itMap = VertexGlobalAssociation.find(std::make_pair(elem->getVertex(1),fac2)); - if (itMap != VertexGlobalAssociation.end()){ - v3 = itMap->second; - } - itMap = VertexGlobalAssociation.find(std::make_pair(elem->getVertex(2),fac2)); - if (itMap != VertexGlobalAssociation.end()){ - v4 = itMap->second; - } - // itMap = VertexGlobalAssociation.find(std::make_pair(elem->getVertex(3),fac2)); - // if (itMap != VertexGlobalAssociation.end()){ - // v5 = itMap->second; - // } - // itMap = VertexGlobalAssociation.find(std::make_pair(elem->getVertex(5),fac2)); - // if (itMap != VertexGlobalAssociation.end()){ - // v6 = itMap->second; - // } - MQuadrangle *newQua2 = new MQuadrangle(v1,v2,v3,v4); - - newFaceTmp->addQuadrangle(newQua2); - - - - - } - for (unsigned int i = 0; i < fac1->getNumMeshElements();i++){ - MElement* elem = fac1->getMeshElement(i); - for (int j = 0;j < elem->getNumVertices();j++){ - MVertex* vert = elem->getVertex(j); - std::map<std::pair<MVertex*,GFace*>,MVertex* >::iterator itMap = VertexGlobalAssociation.find(std::make_pair(vert,fac1)); - if (itMap != VertexGlobalAssociation.end()){ - elem->setVertex(j,itMap->second); - } - } - } - for (unsigned int i = 0; i < fac2->getNumMeshElements();i++){ - MElement* elem = fac2->getMeshElement(i); - for (int j = 0;j < elem->getNumVertices();j++){ - MVertex* vert = elem->getVertex(j); - std::map<std::pair<MVertex*,GFace*>,MVertex* >::iterator itMap = VertexGlobalAssociation.find(std::make_pair(vert,fac2)); - if (itMap != VertexGlobalAssociation.end()){ - elem->setVertex(j,itMap->second); - } - } - } - } - - - - - - - - - //maintenant on va traiter les faces du bord - for (std::set<GEdge*>::iterator itf = ToDuplicateListBoundary.begin();itf != ToDuplicateListBoundary.end();itf++){ - counterNbDone++; - GEdge* eTmp = (*itf); - std::list<GFace*> listFacesTmpT = eTmp->faces(); - std::list<GFace*>::iterator itTmpFace = listFacesTmpT.begin(); - GFace* fac1 = (*itTmpFace); - // GFace* reg1 = fTmp->getRegion(0); - //pour commencer on cree des aretes entre les vertex - std::list<GVertex*> vlist; - vlist.push_back(eTmp->getBeginVertex()); - vlist.push_back(eTmp->getEndVertex()); - std::map<GVertex*,GEdge* > SurroudingEdges; - for (std::list<GVertex*>::iterator itv = vlist.begin();itv != vlist.end();itv++){ - GVertex* vTmp = (*itv); - GVertex* v1=0; - std::map<std::pair<GVertex*,GFace*>,GVertex* >::iterator itMap = GVertexGlobalAssociation.find(std::make_pair(vTmp,fac1)); - if (itMap != GVertexGlobalAssociation.end()){ - v1 = itMap->second; - } - GEdge* newE = m->addLine(v1,vTmp); - SurroudingEdges[vTmp] = newE; - } - //ici tous les vertex sont traites - //on va traiter les edges - // std::list<GEdge*> elist = fTmp->edges(); - std::vector<GEdge*> newEdgesVector; - std::vector<GFace*> SurroundingsFaces; - // for (std::list<GEdge*>::iterator ite = elist.begin();ite != elist.end();ite++){ - //duplication Gedge - // GEdge* eTmp = (*ite); - GEdge* e1=0; - std::map<std::pair<GEdge*,GFace*>,GEdge* >::iterator itMap = GEdgeGlobalAssociation.find(std::make_pair(eTmp,fac1)); - if (itMap != GEdgeGlobalAssociation.end()){ - e1 = itMap->second; - } - //creation des GFace correspondantes - GEdge* firstE = SurroudingEdges.find(eTmp->getBeginVertex())->second; - GEdge* lastE = SurroudingEdges.find(eTmp->getEndVertex())->second; - if (firstE->getBeginVertex() != e1->getEndVertex()){ - firstE->reverse(); - } - if (firstE->getBeginVertex() != e1->getEndVertex()){ - e1->reverse(); - } - if (firstE->getBeginVertex() != e1->getEndVertex()){ - firstE->reverse(); - } - if (eTmp->getBeginVertex() != firstE->getEndVertex()){ - eTmp->reverse(); - } - if (lastE->getBeginVertex() != eTmp->getEndVertex()){ - lastE->reverse(); - } - std::vector<GEdge*> VecEdgesTmp; - VecEdgesTmp.push_back(e1); - VecEdgesTmp.push_back(firstE); - VecEdgesTmp.push_back(eTmp); - VecEdgesTmp.push_back(lastE); - std::vector<std::vector<GEdge*> > VecOfVecTmp; - VecOfVecTmp.push_back(VecEdgesTmp); - GFace* newFaceTmp = m->addPlanarFace(VecOfVecTmp); - // SurroundingsFaces.push_back(newFaceTmp); - // } - std::vector<GFace*> VectorFaces; - std::list<GFace*> listFaces; - // GFace* f1; - // std::map<std::pair<GFace*,GRegion*>,GFace* >::iterator itMap = GFaceGlobalAssociation.find(std::make_pair(fTmp,reg1)); - // if (itMap != GFaceGlobalAssociation.end()){ - // f1 = itMap->second; - // } - // VectorFaces.push_back(f1); - // listFaces.push_back(f1); - // for (unsigned int i = 0;i < SurroundingsFaces.size();i++){ - // VectorFaces.push_back(SurroundingsFaces[i]); - // listFaces.push_back(SurroundingsFaces[i]); - // } - // VectorFaces.push_back(fTmp); - // listFaces.push_back(fTmp); - // std::vector<std::vector<GFace*> > VecOfVecGFace; - // VecOfVecGFace.push_back(VectorFaces); - // //creation de la nouvelle region - // GRegion* createdRegion = new GRegion(m,counterNbDone); - newFaceTmp->addPhysicalEntity(PhysicalInterface); - // createdRegion->set(listFaces); - // m->add(createdRegion); - for (unsigned int i = 0; i < eTmp->getNumMeshElements();i++){ - MElement* elem = eTmp->getMeshElement(i); - MVertex* v1=0; - MVertex* v2=0; - //MVertex* v3; - std::map<std::pair<MVertex*,GFace*>,MVertex* >::iterator itMap = VertexGlobalAssociation.find(std::make_pair(elem->getVertex(0),fac1)); - if (itMap != VertexGlobalAssociation.end()){ - v1 = itMap->second; - } - itMap = VertexGlobalAssociation.find(std::make_pair(elem->getVertex(2),fac1)); - if (itMap != VertexGlobalAssociation.end()){ - v2 = itMap->second; - } - MQuadrangle *newQua = new MQuadrangle(v1,v2,elem->getVertex(2),elem->getVertex(0)); - newFaceTmp->addQuadrangle(newQua); - //second - itMap = VertexGlobalAssociation.find(std::make_pair(elem->getVertex(2),fac1)); - if (itMap != VertexGlobalAssociation.end()){ - v1 = itMap->second; - } - itMap = VertexGlobalAssociation.find(std::make_pair(elem->getVertex(1),fac1)); - if (itMap != VertexGlobalAssociation.end()){ - v2 = itMap->second; - } - MQuadrangle *newQua2 = new MQuadrangle(v1,v2,elem->getVertex(1),elem->getVertex(2)); - newFaceTmp->addQuadrangle(newQua2); - } - for (unsigned int i = 0; i < fac1->getNumMeshElements();i++){ - MElement* elem = fac1->getMeshElement(i); - for (int j = 0;j < elem->getNumVertices();j++){ - MVertex* vert = elem->getVertex(j); - std::map<std::pair<MVertex*,GFace*>,MVertex* >::iterator itMap = VertexGlobalAssociation.find(std::make_pair(vert,fac1)); - if (itMap != VertexGlobalAssociation.end()){ - elem->setVertex(j,itMap->second); - } - } - } - } - - - - - - - - - - - - - - - - - - - // std::ofstream file("MicrostructurePolycrystal3D.pos"); - // file << "View \"test\" {\n"; - // - // std::ofstream file2("PERIODIC.map"); - // std::ofstream file3("SetAdd.map"); - // for (std::vector<std::pair<GFace*,GFace*> >::iterator itP = pairs.begin();itP != pairs.end();itP++){ - // std::pair<GFace*,GFace*> pairTmp = (*itP); - // GFace* ToReplaceFace = pairTmp.second; - // GRegion* rTmp = ToReplaceFace->getRegion(0); - // std::map<std::pair<GFace*,GRegion*>,GFace* >::iterator itMap = GFaceGlobalAssociation.find(std::make_pair(ToReplaceFace,rTmp)); - // if (itMap != GFaceGlobalAssociation.end()){ - // GFace* associatedFace = (*itMap).second; - // - // - // - // - // - // file3 <<associatedFace->tag()<<"\tSURFACE"<<associatedFace->tag()<<"\tNSET "<<"\n"; - // - // int tagTmp = associatedFace->tag(); - // std::ostringstream ss; - // ss << tagTmp; - //// char *intStr = itoa(tagTmp); - // std::string nameSurf = "SURFACE"; - //// nameSurf += std::string(intStr); - // nameSurf += ss.str(); - // int PhysicalSurfaceTmp = m->setPhysicalName(nameSurf,2); - // associatedFace->addPhysicalEntity(PhysicalSurfaceTmp); - // - // std::map<GFace*,SPoint3>::iterator it3 = centers.find(pairTmp.first); - // std::map<GFace*,SPoint3>::iterator it4 = centers.find(ToReplaceFace); - // - // SPoint3 p1 = it3->second; - // SPoint3 p2 = it4->second; - // - // double delta_x = fabs(p2.x()-p1.x()); - // double delta_y = fabs(p2.y()-p1.y()); - // double delta_z = fabs(p2.z()-p1.z()); - // - // - // file << "SL (" - // << p1.x() << ", " << p1.y() << ", " << p1.z() << ", " - // << p2.x() << ", " << p2.y() << ", " << p2.z() - // << "){10, 20};\n"; - // - // //file2 << "PERIODIC\tSURFACE"<<faces[i]->tag() << "\tSURFACE" << faces[j]->tag() << "\t" << p2.x()-p1.x() << "\t" << p2.y()-p1.y() << "\t" << p2.z()-p1.z() << "\n"; - // if (abs((p2.x()-p1.x()-1.0))<0.0001){ - // if (abs((p2.y()-p1.y()))<0.0001){ - // if (abs((p2.z()-p1.z()))<0.0001){ - // file2 << "NSET\tFRONT = FRONT + SURFACE"<<associatedFace->tag()<<"\n"; - // file2 << "NSET\tBACK = BACK + SURFACE"<<pairTmp.first->tag()<<"\n"; - // }else if(abs((p2.z()-p1.z()-1.0))<0.0001){ - // file2 << "NSET\tFRONTTOP = FRONTTOP + SURFACE"<<associatedFace->tag()<<"\n"; - // file2 << "NSET\tBACKBOTTOM = BACKBOTTOM + SURFACE"<<pairTmp.first->tag()<<"\n"; - // }else if (abs((p1.z()-p2.z()-1.0))<0.0001){ - // file2 << "NSET\tFRONTBOTTOM = FRONTBOTTOM + SURFACE"<<associatedFace->tag()<<"\n"; - // file2 << "NSET\tBACKTOP = BACKTOP + SURFACE"<<pairTmp.first->tag()<<"\n"; - // } - // }else if (abs((p2.y()-p1.y()-1.0))<0.0001){ - // if (abs((p2.z()-p1.z()))<0.0001){ - // file2 << "NSET\tFRONTRIGHT = FRONTRIGHT + SURFACE"<<associatedFace->tag()<<"\n"; - // file2 << "NSET\tBACKLEFT = BACKLEFT + SURFACE"<<pairTmp.first->tag()<<"\n"; - // }else if (abs((p2.z()-p1.z()-1.0))<0.0001){ - // file2 << "NSET\tFRONTRIGHTTOP = FRONTRIGHTTOP + SURFACE"<<associatedFace->tag()<<"\n"; - // file2 << "NSET\tBACKLEFTBOTTOM = BACKLEFTBOTTOM + SURFACE"<<pairTmp.first->tag()<<"\n"; - // }else if (abs((p1.z()-p2.z()-1.0))<0.0001){ - // file2 << "NSET\tFRONTRIGHTBOTTOM = FRONTRIGHTBOTTOM + SURFACE"<<associatedFace->tag()<<"\n"; - // file2 << "NSET\tBACKLEFTTOP = BACKLEFTTOP + SURFACE"<<pairTmp.first->tag()<<"\n"; - // } - // }else if (abs((p1.y()-p2.y()-1.0))<0.0001){ - // if (abs((p2.z()-p1.z()))<0.0001){ - // file2 << "NSET\tFRONTLEFT = FRONTLEFT + SURFACE"<<associatedFace->tag()<<"\n"; - // file2 << "NSET\tBACKRIGHT = BACKRIGHT + SURFACE"<<pairTmp.first->tag()<<"\n"; - // }else if (abs((p2.z()-p1.z()-1.0))<0.0001){ - // file2 << "NSET\tFRONTLEFTTOP = FRONTLEFTTOP + SURFACE"<<associatedFace->tag()<<"\n"; - // file2 << "NSET\tBACKRIGHTBOTTOM = BACKRIGHTBOTTOM + SURFACE"<<pairTmp.first->tag()<<"\n"; - // }else if (abs((p1.z()-p2.z()-1.0))<0.0001){ - // file2 << "NSET\tFRONTLEFTBOTTOM = FRONTLEFTBOTTOM + SURFACE"<<associatedFace->tag()<<"\n"; - // file2 << "NSET\tBACKRIGHTTOP = BACKRIGHTTOP + SURFACE"<<pairTmp.first->tag()<<"\n"; - // } - // } - // }else if (abs((p1.x()-p2.x()-1.0))<0.0001){ - // if (abs((p2.y()-p1.y()))<0.0001){ - // if (abs((p2.z()-p1.z()))<0.0001){ - // file2 << "NSET\tFRONT = FRONT + SURFACE"<<pairTmp.first->tag()<<"\n"; - // file2 << "NSET\tBACK = BACK + SURFACE"<<associatedFace->tag()<<"\n"; - // }else if(abs((p2.z()-p1.z()-1.0))<0.0001){ - // file2 << "NSET\tFRONTBOTTOM = FRONTBOTTOM + SURFACE"<<pairTmp.first->tag()<<"\n"; - // file2 << "NSET\tBACKTOP = BACKTOP + SURFACE"<<associatedFace->tag()<<"\n"; - // }else if (abs((p1.z()-p2.z()-1.0))<0.0001){ - // file2 << "NSET\tFRONTTOP = FRONTTOP + SURFACE"<<pairTmp.first->tag()<<"\n"; - // file2 << "NSET\tBACKBOTTOM = BACKBOTTOM + SURFACE"<<associatedFace->tag()<<"\n"; - // } - // }else if (abs((p2.y()-p1.y()-1.0))<0.0001){ - // if (abs((p2.z()-p1.z()))<0.0001){ - // file2 << "NSET\tFRONTLEFT = FRONTLEFT + SURFACE"<<pairTmp.first->tag()<<"\n"; - // file2 << "NSET\tBACKRIGHT = BACKRIGHT + SURFACE"<<associatedFace->tag()<<"\n"; - // }else if (abs((p2.z()-p1.z()-1.0))<0.0001){ - // file2 << "NSET\tFRONTLEFTBOTTOM = FRONTLEFTBOTTOM + SURFACE"<<pairTmp.first->tag()<<"\n"; - // file2 << "NSET\tBACKRIGHTTOP = BACKRIGHTTOP + SURFACE"<<associatedFace->tag()<<"\n"; - // }else if (abs((p1.z()-p2.z()-1.0))<0.0001){ - // file2 << "NSET\tFRONTLEFTTOP = FRONTLEFTTOP + SURFACE"<<pairTmp.first->tag()<<"\n"; - // file2 << "NSET\tBACKRIGHTBOTTOM = BACKRIGHTBOTTOM + SURFACE"<<associatedFace->tag()<<"\n"; - // } - // }else if (abs((p1.y()-p2.y()-1.0))<0.0001){ - // if (abs((p2.z()-p1.z()))<0.0001){ - // file2 << "NSET\tFRONTRIGHT = FRONTRIGHT + SURFACE"<<pairTmp.first->tag()<<"\n"; - // file2 << "NSET\tBACKLEFT = BACKLEFT + SURFACE"<<associatedFace->tag()<<"\n"; - // }else if (abs((p2.z()-p1.z()-1.0))<0.0001){ - // file2 << "NSET\tFRONTRIGHTBOTTOM = FRONTRIGHTBOTTOM + SURFACE"<<pairTmp.first->tag()<<"\n"; - // file2 << "NSET\tBACKLEFTTOP = BACKLEFTTOP + SURFACE"<<associatedFace->tag()<<"\n"; - // }else if (abs((p1.z()-p2.z()-1.0))<0.0001){ - // file2 << "NSET\tFRONTRIGHTTOP = FRONTRIGHTTOP + SURFACE"<<pairTmp.first->tag()<<"\n"; - // file2 << "NSET\tBACKLEFTBOTTOM = BACKLEFTBOTTOM + SURFACE"<<associatedFace->tag()<<"\n"; - // } - // } - // }else if (abs((p1.x()-p2.x()))<0.0001){ - // if (abs((p2.y()-p1.y()-1.0))<0.0001){ - // if (abs((p2.z()-p1.z()))<0.0001){ - // file2 << "NSET\tRIGHT = RIGHT + SURFACE"<<associatedFace->tag()<<"\n"; - // file2 << "NSET\tLEFT = LEFT + SURFACE"<<pairTmp.first->tag()<<"\n"; - // }else if (abs((p2.z()-p1.z()-1.0))<0.0001){ - // file2 << "NSET\tRIGHTTOP = RIGHTTOP + SURFACE"<<associatedFace->tag()<<"\n"; - // file2 << "NSET\tLEFTBOTTOM = LEFTBOTTOM + SURFACE"<<pairTmp.first->tag()<<"\n"; - // }else if (abs((p1.z()-p2.z()-1.0))<0.0001){ - // file2 << "NSET\tRIGHTBOTTOM = RIGHTBOTTOM + SURFACE"<<associatedFace->tag()<<"\n"; - // file2 << "NSET\tLEFTTOP = LEFTTOP + SURFACE"<<pairTmp.first->tag()<<"\n"; - // } - // }else if (abs((p1.y()-p2.y()-1.0))<0.0001){ - // if (abs((p2.z()-p1.z()))<0.0001){ - // file2 << "NSET\tRIGHT = RIGHT + SURFACE"<<pairTmp.first->tag()<<"\n"; - // file2 << "NSET\tLEFT = LEFT + SURFACE"<<associatedFace->tag()<<"\n"; - // }else if (abs((p2.z()-p1.z()-1.0))<0.0001){ - // file2 << "NSET\tRIGHTBOTTOM = RIGHTBOTTOM + SURFACE"<<pairTmp.first->tag()<<"\n"; - // file2 << "NSET\tLEFTTOP = LEFTTOP + SURFACE"<<associatedFace->tag()<<"\n"; - // }else if (abs((p1.z()-p2.z()-1.0))<0.0001){ - // file2 << "NSET\tRIGHTTOP = RIGHTTOP + SURFACE"<<pairTmp.first->tag()<<"\n"; - // file2 << "NSET\tLEFTBOTTOM = LEFTBOTTOM + SURFACE"<<associatedFace->tag()<<"\n"; - // } - // }else if (abs((p1.y()-p2.y()))<0.0001){ - // if (abs((p2.z()-p1.z()-1.0))<0.0001){ - // file2 << "NSET\tTOP = TOP + SURFACE"<<associatedFace->tag()<<"\n"; - // file2 << "NSET\tBOTTOM = BOTTOM + SURFACE"<<pairTmp.first->tag()<<"\n"; - // }else if (abs((p1.z()-p2.z()-1.0))<0.0001){ - // file2 << "NSET\tTOP = TOP + SURFACE"<<pairTmp.first->tag()<<"\n"; - // file2 << "NSET\tBOTTOM = BOTTOM + SURFACE"<<associatedFace->tag()<<"\n"; - // } - // } - // } - //// count++; - // - // - // - // - // - // - // - // newPairs.push_back(std::make_pair(pairTmp.first,associatedFace)); - // } - // } - // for (std::vector<std::pair<GFace*,GFace*> >::iterator itP = newPairs.begin();itP != newPairs.end();itP++){ - // std::pair<GFace*,GFace*> pairTmp = (*itP); - // } - - std::cout<<"End of DuplicateBoundaries"<<std::endl; - return view; -} - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -PView *GMSH_DuplicateBoundariesPlugin::executeTer(PView *view) -{ - std::cout<<"starting DuplicateBoundaries"<<std::endl; - GModel *m = GModel::current(); - m->setFactory("geo"); - std::set<GFace*> ToDuplicateList; - ToDuplicateList.clear(); - std::set<GFace*> ToDuplicateListBoundary; - ToDuplicateListBoundary.clear(); - std::vector<GFace*> facesBound; - facesBound.clear(); - std::map<GFace*,SPoint3> centers; - std::vector<std::pair<GFace*,GFace*> > pairs; - std::vector<std::pair<GFace*,GFace*> > newPairs; - int PhysicalInterface = m->setPhysicalName("Interface",3); - int PhysicalBoundary = m->setPhysicalName("Boundary",2); - for (GModel::fiter itf= m->firstFace();itf != m->lastFace();itf++){ - GFace* fTmp = (*itf); - if (fTmp->numRegions() == 2){ - ToDuplicateList.insert(fTmp); - } - else{ - ToDuplicateListBoundary.insert(fTmp); - facesBound.push_back(fTmp); - } - } - - - - - - - - std::map<std::pair<MVertex*,GRegion*>,MVertex* > VertexGlobalAssociation; - std::map<std::pair<GVertex*,GRegion*>,GVertex* > GVertexGlobalAssociation; - std::map<std::pair<GEdge*,GRegion*>,GEdge* > GEdgeGlobalAssociation; - std::map<std::pair<GFace*,GRegion*>,GFace* > GFaceGlobalAssociation; - - for (GModel::riter itr= m->firstRegion();itr != m->lastRegion();itr++){ - GRegion* rTmp = (*itr); - std::list<GFace*> RegFaces = rTmp->faces(); - std::map<MVertex*,MVertex* > VertexAssociation; - std::map<GVertex*,GVertex* > GVertexAssociation; - std::map<GEdge*,GEdge* > GEdgeAssociation; - //int counterNbDone = 10000; - double xCenterReg = 0.0; - double yCenterReg = 0.0; - double zCenterReg = 0.0; - int counterPts = 0; - for(std::list<GFace*>::iterator it2=RegFaces.begin();it2!=RegFaces.end();it2++){ - GFace* fTemp = (*it2); - std::list<GVertex*> verticesFace = fTemp->vertices(); - for (std::list<GVertex*>::iterator it3=verticesFace.begin();it3!=verticesFace.end();it3++){ - xCenterReg = xCenterReg + (*it3)->x(); - yCenterReg = yCenterReg + (*it3)->y(); - zCenterReg = zCenterReg + (*it3)->z(); - counterPts++; - } - } - xCenterReg = xCenterReg/counterPts; - yCenterReg = yCenterReg/counterPts; - zCenterReg = zCenterReg/counterPts; - //duplication noeud et aretes au niveau de la region directement - std::list<GVertex*> vlist; - - - std::list<GFace*> listFacesTmp = rTmp->faces(); - for (std::list<GFace*>::iterator itTp = listFacesTmp.begin();itTp != listFacesTmp.end();itTp++){ - std::list<GVertex*> vlist2; - vlist2 = (*itTp)->vertices(); - for (std::list<GVertex*>::iterator itTp2 = vlist2.begin();itTp2 != vlist2.end();itTp2++){ - if(std::find(vlist.begin(), vlist.end(), *itTp2) == vlist.end()) - vlist.push_back(*itTp2); - } - } - - - for (std::list<GVertex*>::iterator itv = vlist.begin();itv != vlist.end();itv++){ - //duplication Gvertex - GVertex* vTmp = (*itv); - double ponderatedX = 0.99999999999 * vTmp->x() + 0.00000000001 * xCenterReg; - double ponderatedY = 0.99999999999 * vTmp->y() + 0.00000000001 * yCenterReg; - double ponderatedZ = 0.99999999999 * vTmp->z() + 0.00000000001 * zCenterReg; - GVertex* newv = m->addVertex(ponderatedX,ponderatedY,ponderatedZ,vTmp->prescribedMeshSizeAtVertex()); - GVertexAssociation[vTmp] = newv; - GVertexGlobalAssociation[std::make_pair(vTmp,rTmp)] = newv; - //creation des Gedge correspondantes - // GEdge* newE = m->addLine(vTmp,newv); - // SurroudingEdges[vTmp] = newE; - //maintenant traitement mesh - MVertex *vMesh = vTmp->mesh_vertices[0]; - MVertex *newMv = new MVertex(vMesh->x(), vMesh->y(), vMesh->z(), (GEntity*)newv); - VertexAssociation[vMesh] = newMv; - VertexGlobalAssociation[std::make_pair(vMesh,rTmp)] = newMv; - newv->addMeshVertex(newMv); - } - //maintenant on soccupe de duppliquer les edges de la region - std::list<GEdge*> elist = rTmp->edges(); - - std::vector<GFace*> SurroundingsFaces; - for (std::list<GEdge*>::iterator ite = elist.begin();ite != elist.end();ite++){ - //duplication Gedge - GEdge* eTmp = (*ite); - GEdge* newE = m->addLine(GVertexAssociation[eTmp->getEndVertex()],GVertexAssociation[eTmp->getBeginVertex()]); - GEdgeAssociation[eTmp] = newE; - GEdgeGlobalAssociation[std::make_pair(eTmp,rTmp)] = newE; - //creation des GFace correspondantes - // GEdge* firstE = SurroudingEdges.find(eTmp->getEndVertex())->second; - // GEdge* lastE = SurroudingEdges.find(eTmp->getBeginVertex())->second; - // std::vector<GEdge*> VecEdgesTmp; - // VecEdgesTmp.push_back(eTmp); - // VecEdgesTmp.push_back(firstE); - // VecEdgesTmp.push_back(newE); - // VecEdgesTmp.push_back(lastE); - // std::vector<std::vector<GEdge*> > VecOfVecTmp; - // VecOfVecTmp.push_back(VecEdgesTmp); - // GFace* newFaceTmp = m->addPlanarFace(VecOfVecTmp); - // SurroundingsFaces.push_back(newFaceTmp); - //maintenant traitement mesh - for (unsigned int i = 0; i < eTmp->mesh_vertices.size();i++){ - MVertex *vMesh = eTmp->mesh_vertices[i]; - MVertex *newMv = new MVertex(vMesh->x(), vMesh->y(), vMesh->z(), (GEntity*)newE); - VertexAssociation[vMesh] = newMv; - VertexGlobalAssociation[std::make_pair(vMesh,rTmp)] = newMv; - newE->addMeshVertex(newMv); - } - for (unsigned int i = 0; i < eTmp->getNumMeshElements();i++){ - MElement* elem = eTmp->getMeshElement(i); - MVertex *firstETmp = VertexAssociation.find(elem->getVertex(0))->second; - MVertex *lastETmp = VertexAssociation.find(elem->getVertex(1))->second; - MLine *newLine = new MLine(firstETmp,lastETmp); - newE->addLine(newLine); - } - } - for (std::list<GFace*>::iterator itf = RegFaces.begin();itf != RegFaces.end();itf++){ - GFace* fTmp = (*itf); - std::vector<GEdge*> newEdgesVector; - std::list<GEdge*> elistFace = fTmp->edges(); - for (std::list<GEdge*>::iterator ite = elistFace.begin();ite != elistFace.end();ite++){ - GEdge* eTmp = (*ite); - GEdge* eToFind = GEdgeAssociation[eTmp]; - newEdgesVector.push_back(eToFind); - } - std::vector<std::vector<GEdge*> > VecOfVec; - VecOfVec.push_back(newEdgesVector); - //creation de la nouvelle face - GFace* GFaceAssociation = m->addPlanarFace(VecOfVec); - //maintenant traitement mesh - for (unsigned int i = 0; i < fTmp->mesh_vertices.size();i++){ - MVertex *vMesh = fTmp->mesh_vertices[i]; - MVertex *newMv = new MVertex(vMesh->x(), vMesh->y(), vMesh->z(), (GEntity*)GFaceAssociation); - VertexAssociation[vMesh] = newMv; - VertexGlobalAssociation[std::make_pair(vMesh,rTmp)] = newMv; - GFaceAssociation->addMeshVertex(newMv); - } - for (unsigned int i = 0; i < fTmp->getNumMeshElements();i++){ - MElement* elem = fTmp->getMeshElement(i); - MVertex *firstE = VertexAssociation.find(elem->getVertex(0))->second; - MVertex *secondE = VertexAssociation.find(elem->getVertex(1))->second; - MVertex *thirdE = VertexAssociation.find(elem->getVertex(2))->second; - MTriangle *newTri = new MTriangle(firstE,secondE,thirdE); - GFaceAssociation->addTriangle(newTri); - } - GFaceGlobalAssociation[std::make_pair(fTmp,rTmp)] = GFaceAssociation; - } - } - int counterNbDone = 10000; - //maintenant on va traiter les faces initiales - for (std::set<GFace*>::iterator itf = ToDuplicateList.begin();itf != ToDuplicateList.end();itf++){ - counterNbDone++; - GFace* fTmp = (*itf); - GRegion* reg1 = fTmp->getRegion(0); - GRegion* reg2 = fTmp->getRegion(1); - //pour commencer on cree des aretes entre les vertex - std::list<GVertex*> vlist = fTmp->vertices(); - std::map<GVertex*,GEdge* > SurroudingEdges; - for (std::list<GVertex*>::iterator itv = vlist.begin();itv != vlist.end();itv++){ - GVertex* vTmp = (*itv); - GVertex* v1=0; - GVertex* v2=0; - std::map<std::pair<GVertex*,GRegion*>,GVertex* >::iterator itMap = GVertexGlobalAssociation.find(std::make_pair(vTmp,reg1)); - if (itMap != GVertexGlobalAssociation.end()){ - v1 = itMap->second; - } - itMap = GVertexGlobalAssociation.find(std::make_pair(vTmp,reg2)); - if (itMap != GVertexGlobalAssociation.end()){ - v2 = itMap->second; - } - GEdge* newE = m->addLine(v1,v2); - SurroudingEdges[vTmp] = newE; - } - //ici tous les vertex sont traites - //on va traiter les edges - std::list<GEdge*> elist = fTmp->edges(); - std::vector<GEdge*> newEdgesVector; - std::vector<GFace*> SurroundingsFaces; - for (std::list<GEdge*>::iterator ite = elist.begin();ite != elist.end();ite++){ - //duplication Gedge - GEdge* eTmp = (*ite); - GEdge* e1=0; - GEdge* e2=0; - std::map<std::pair<GEdge*,GRegion*>,GEdge* >::iterator itMap = GEdgeGlobalAssociation.find(std::make_pair(eTmp,reg1)); - if (itMap != GEdgeGlobalAssociation.end()){ - e1 = itMap->second; - } - itMap = GEdgeGlobalAssociation.find(std::make_pair(eTmp,reg2)); - if (itMap != GEdgeGlobalAssociation.end()){ - e2 = itMap->second; - } - //creation des GFace correspondantes - GEdge* firstE = SurroudingEdges.find(eTmp->getBeginVertex())->second; - GEdge* lastE = SurroudingEdges.find(eTmp->getEndVertex())->second; - if (firstE->getBeginVertex() != e1->getEndVertex()){ - firstE->reverse(); - } - if (firstE->getBeginVertex() != e1->getEndVertex()){ - e1->reverse(); - } - if (firstE->getBeginVertex() != e1->getEndVertex()){ - firstE->reverse(); - } - if (e2->getBeginVertex() != firstE->getEndVertex()){ - e2->reverse(); - } - if (lastE->getBeginVertex() != e2->getEndVertex()){ - lastE->reverse(); - } - std::vector<GEdge*> VecEdgesTmp; - VecEdgesTmp.push_back(e1); - VecEdgesTmp.push_back(firstE); - VecEdgesTmp.push_back(e2); - VecEdgesTmp.push_back(lastE); - std::vector<std::vector<GEdge*> > VecOfVecTmp; - VecOfVecTmp.push_back(VecEdgesTmp); - GFace* newFaceTmp = m->addPlanarFace(VecOfVecTmp); - SurroundingsFaces.push_back(newFaceTmp); - } - std::vector<GFace*> VectorFaces; - std::list<GFace*> listFaces; - GFace* f1; - GFace* f2; - std::map<std::pair<GFace*,GRegion*>,GFace* >::iterator itMap = GFaceGlobalAssociation.find(std::make_pair(fTmp,reg1)); - if (itMap != GFaceGlobalAssociation.end()){ - f1 = itMap->second; - } - itMap = GFaceGlobalAssociation.find(std::make_pair(fTmp,reg2)); - if (itMap != GFaceGlobalAssociation.end()){ - f2 = itMap->second; - } - VectorFaces.push_back(f1); - listFaces.push_back(f1); - for (unsigned int i = 0;i < SurroundingsFaces.size();i++){ - VectorFaces.push_back(SurroundingsFaces[i]); - listFaces.push_back(SurroundingsFaces[i]); - } - VectorFaces.push_back(f2); - listFaces.push_back(f2); - std::vector<std::vector<GFace*> > VecOfVecGFace; - VecOfVecGFace.push_back(VectorFaces); - //creation de la nouvelle region - GRegion* createdRegion = new GRegion(m,counterNbDone); - createdRegion->addPhysicalEntity(PhysicalInterface); - createdRegion->set(listFaces); - m->add(createdRegion); - for (unsigned int i = 0; i < fTmp->getNumMeshElements();i++){ - MElement* elem = fTmp->getMeshElement(i); - MVertex* v1=0; - MVertex* v2=0; - MVertex* v3=0; - MVertex* v4=0; - MVertex* v5=0; - MVertex* v6=0; - std::map<std::pair<MVertex*,GRegion*>,MVertex* >::iterator itMap = VertexGlobalAssociation.find(std::make_pair(elem->getVertex(0),reg1)); - if (itMap != VertexGlobalAssociation.end()){ - v1 = itMap->second; - } - itMap = VertexGlobalAssociation.find(std::make_pair(elem->getVertex(1),reg1)); - if (itMap != VertexGlobalAssociation.end()){ - v2 = itMap->second; - } - itMap = VertexGlobalAssociation.find(std::make_pair(elem->getVertex(2),reg1)); - if (itMap != VertexGlobalAssociation.end()){ - v3 = itMap->second; - } - itMap = VertexGlobalAssociation.find(std::make_pair(elem->getVertex(0),reg2)); - if (itMap != VertexGlobalAssociation.end()){ - v4 = itMap->second; - } - itMap = VertexGlobalAssociation.find(std::make_pair(elem->getVertex(1),reg2)); - if (itMap != VertexGlobalAssociation.end()){ - v5 = itMap->second; - } - itMap = VertexGlobalAssociation.find(std::make_pair(elem->getVertex(2),reg2)); - if (itMap != VertexGlobalAssociation.end()){ - v6 = itMap->second; - } - MPrism *newPri = new MPrism(v1,v2,v3,v4,v5,v6); - - createdRegion->addPrism(newPri); - } - for (unsigned int i = 0; i < reg1->getNumMeshElements();i++){ - MElement* elem = reg1->getMeshElement(i); - for (int j = 0;j < elem->getNumVertices();j++){ - MVertex* vert = elem->getVertex(j); - std::map<std::pair<MVertex*,GRegion*>,MVertex* >::iterator itMap = VertexGlobalAssociation.find(std::make_pair(vert,reg1)); - if (itMap != VertexGlobalAssociation.end()){ - elem->setVertex(j,itMap->second); - } - } - } - for (unsigned int i = 0; i < reg2->getNumMeshElements();i++){ - MElement* elem = reg2->getMeshElement(i); - for (int j = 0;j < elem->getNumVertices();j++){ - MVertex* vert = elem->getVertex(j); - std::map<std::pair<MVertex*,GRegion*>,MVertex* >::iterator itMap = VertexGlobalAssociation.find(std::make_pair(vert,reg2)); - if (itMap != VertexGlobalAssociation.end()){ - elem->setVertex(j,itMap->second); - } - } - } - } - - for (std::set<GFace*>::iterator itf = ToDuplicateListBoundary.begin();itf != ToDuplicateListBoundary.end();itf++){ - GFace* fTmp = (*itf); - GRegion* reg1 = fTmp->getRegion(0); - std::map<std::pair<GFace*,GRegion*>,GFace* >::iterator itMap = GFaceGlobalAssociation.find(std::make_pair(fTmp,reg1)); - GFace* f1 = itMap->second; - f1->addPhysicalEntity(PhysicalBoundary); - } - - - std::cout<<"End of DuplicateBoundaries"<<std::endl; - return view; -} - -PView *GMSH_DuplicateBoundariesPlugin::ComputeBestSeeds(PView *view) -{ - std::cout<<"starting DuplicateBoundaries"<<std::endl; - GModel *m = GModel::current(); - m->setFactory("geo"); - return view; -} diff --git a/Plugin/PluginManager.cpp b/Plugin/PluginManager.cpp index bfdd58b0def96e5d3853114bcad62f28765a8053..a9256cc6b2f17ef4fee11ad4da8445d58d2a7f32 100644 --- a/Plugin/PluginManager.cpp +++ b/Plugin/PluginManager.cpp @@ -25,7 +25,6 @@ #include "ExtractElements.h" #include "SimplePartition.h" #include "Crack.h" -#include "DuplicateBoundaries.h" #include "ThinLayerFixMesh.h" #include "HarmonicToTime.h" #include "ModulusPhase.h" @@ -260,8 +259,6 @@ void PluginManager::registerDefaultPlugins() ("Crack", GMSH_RegisterCrackPlugin())); allPlugins.insert(std::pair<std::string, GMSH_Plugin*> ("FaultZone", GMSH_RegisterFaultZonePlugin())); - allPlugins.insert(std::pair<std::string, GMSH_Plugin*> - ("DuplicateBoundaries", GMSH_RegisterDuplicateBoundariesPlugin())); allPlugins.insert(std::pair<std::string, GMSH_Plugin*> ("ThinLayerFixMesh", GMSH_RegisterThinLayerFixMeshPlugin())); allPlugins.insert(std::pair<std::string, GMSH_Plugin*>