diff --git a/Geo/GModelIO_OCC.cpp b/Geo/GModelIO_OCC.cpp index a18d52b7570f88777f4d58aedfe3398c47bd0ea3..a266a0af7d06890a191b213082ce50a9f174fe6f 100644 --- a/Geo/GModelIO_OCC.cpp +++ b/Geo/GModelIO_OCC.cpp @@ -243,7 +243,8 @@ int OCC_Internals::getMaxTag(int dim) const return ret; } -void OCC_Internals::addVertex(int tag, double x, double y, double z) +void OCC_Internals::addVertex(int tag, double x, double y, double z, + double meshSize) { if(tag > 0 && _tagVertex.IsBound(tag)){ Msg::Error("OpenCASCADE vertex with tag %d already exists", tag); @@ -266,6 +267,8 @@ void OCC_Internals::addVertex(int tag, double x, double y, double z) } if(tag <= 0) tag = getMaxTag(0) + 1; bind(result, tag); + if(meshSize > 0 && meshSize < MAX_LC) + meshAttributes[0][tag].size = meshSize; } void OCC_Internals::addLine(int tag, int startTag, int endTag) @@ -1788,7 +1791,10 @@ void OCC_Internals::synchronize(GModel *model) tag = vTagMax + 1; vTagMax++; } - model->add(new OCCVertex(model, tag, vertex)); + std::map<int, meshAttribute>::iterator it = + meshAttributes[0].find(tag); + double lc = (it == meshAttributes[0].end()) ? MAX_LC : it->second.size; + model->add(new OCCVertex(model, tag, vertex, lc)); } } diff --git a/Geo/GModelIO_OCC.h b/Geo/GModelIO_OCC.h index b77c1388d18c07ce676942797c8fc79d16711b77..cf5dc52a78925ee389dba732296eb8ae48cb2b53 100644 --- a/Geo/GModelIO_OCC.h +++ b/Geo/GModelIO_OCC.h @@ -37,13 +37,13 @@ class OCC_Internals { TopTools_DataMapOfIntegerShape _tagWire, _tagShell; // internal mesh attributes, linked to tags - class meshAttributes { + class meshAttribute { public: - meshAttributes() : size(0.), extrude(0) {} + meshAttribute() : size(MAX_LC), extrude(0) {} double size; ExtrudeParams *extrude; }; - std::map<int, meshAttributes> meshAttibutes[4]; + std::map<int, meshAttribute> meshAttributes[4]; // add a shape and all its subshapes to _vmap, _emap, ..., _somap void _addShapeToMaps(TopoDS_Shape shape); @@ -75,7 +75,7 @@ class OCC_Internals { void reset() { for(int i = 0; i < 6; i++) _maxTagConstraints[i] = 0; - for(int i = 0; i < 4; i++) meshAttibutes[i].clear(); + for(int i = 0; i < 4; i++) meshAttributes[i].clear(); _somap.Clear(); _shmap.Clear(); _fmap.Clear(); _wmap.Clear(); _emap.Clear(); _vmap.Clear(); _vertexTag.Clear(); _edgeTag.Clear(); _faceTag.Clear(); _solidTag.Clear(); @@ -120,7 +120,7 @@ class OCC_Internals { int getMaxTag(int dim) const; // add shapes - void addVertex(int tag, double x, double y, double z); + void addVertex(int tag, double x, double y, double z, double meshSize=MAX_LC); void addLine(int tag, int startTag, int endTag); void addCircleArc(int tag, int startTag, int centerTag, int endTag); void addCircle(int tag, double x, double y, double z, double r, double angle1, @@ -254,7 +254,7 @@ public: void reset(){} void setTagConstraints(int dim, int val){} int getMaxTag(int dim) const { return 0; } - void addVertex(int tag, double x, double y, double z){} + void addVertex(int tag, double x, double y, double z, double meshSize=MAX_LC){} void addLine(int tag, int startTag, int endTag){} void addCircleArc(int tag, int startTag, int centerTag, int endTag){} void addCircle(int tag, double x, double y, double z, double r, double angle1, diff --git a/Geo/OCCVertex.cpp b/Geo/OCCVertex.cpp index 131f3f68722eff7c1d1a4eafd4fed2ffc34c0a0e..dcc24fe45358c6d1adfec250f0c1cba62fc59f8d 100644 --- a/Geo/OCCVertex.cpp +++ b/Geo/OCCVertex.cpp @@ -15,20 +15,20 @@ #include "GModelIO_OCC.h" -OCCVertex::OCCVertex(GModel *m, int num, TopoDS_Vertex _v) - : GVertex(m, num), v(_v) +OCCVertex::OCCVertex(GModel *m, int num, TopoDS_Vertex v, double lc) + : GVertex(m, num, lc), _v(v) { max_curvature = -1; - gp_Pnt pnt = BRep_Tool::Pnt(v); + gp_Pnt pnt = BRep_Tool::Pnt(_v); _x = pnt.X(); _y = pnt.Y(); _z = pnt.Z(); - model()->getOCCInternals()->bind(v, num); + model()->getOCCInternals()->bind(_v, num); } OCCVertex::~OCCVertex() { - model()->getOCCInternals()->unbind(v, tag()); + model()->getOCCInternals()->unbind(_v, tag()); } void OCCVertex::setPosition(GPoint &p) diff --git a/Geo/OCCVertex.h b/Geo/OCCVertex.h index ac4fd21d1528d6c4823ec5cb1c819101f2c16249..2e49204046b81f8a53986658933be1741021b5cf 100644 --- a/Geo/OCCVertex.h +++ b/Geo/OCCVertex.h @@ -15,12 +15,12 @@ class OCCVertex : public GVertex { protected: - TopoDS_Vertex v; + TopoDS_Vertex _v; double _x, _y, _z; mutable double max_curvature; double max_curvature_of_surfaces() const; public: - OCCVertex(GModel *m, int num, TopoDS_Vertex _v); + OCCVertex(GModel *m, int num, TopoDS_Vertex v, double lc=MAX_LC); virtual ~OCCVertex(); virtual GPoint point() const { return GPoint(x(), y(), z()); } virtual double x() const { return _x; } @@ -28,9 +28,9 @@ class OCCVertex : public GVertex { virtual double z() const { return _z; } virtual void setPosition(GPoint &p); ModelType getNativeType() const { return OpenCascadeModel; } - void * getNativePtr() const { return (void*)&v; } + void *getNativePtr() const { return (void*)&_v; } virtual SPoint2 reparamOnFace(const GFace *gf, int) const; - TopoDS_Vertex getShape() { return v; } + TopoDS_Vertex getShape() { return _v; } }; #endif diff --git a/Parser/Gmsh.tab.cpp b/Parser/Gmsh.tab.cpp index 88338ea08df475781c8ecbacd758c21d65fa81ea..1277e9954a127a6d4ff5d0a7037d38c4c3fff58b 100644 --- a/Parser/Gmsh.tab.cpp +++ b/Parser/Gmsh.tab.cpp @@ -8063,11 +8063,11 @@ yyreduce: double x = CTX::instance()->geom.scalingFactor * (yyvsp[(6) - (7)].v)[0]; double y = CTX::instance()->geom.scalingFactor * (yyvsp[(6) - (7)].v)[1]; double z = CTX::instance()->geom.scalingFactor * (yyvsp[(6) - (7)].v)[2]; + double lc = CTX::instance()->geom.scalingFactor * (yyvsp[(6) - (7)].v)[3]; if(factory == "OpenCASCADE" && GModel::current()->getOCCInternals()){ - GModel::current()->getOCCInternals()->addVertex(num, x, y, z); + GModel::current()->getOCCInternals()->addVertex(num, x, y, z, lc); } else{ - double lc = CTX::instance()->geom.scalingFactor * (yyvsp[(6) - (7)].v)[3]; if(lc == 0.) lc = MAX_LC; // no mesh size given at the point Vertex *v; if(!myGmshSurface) diff --git a/Parser/Gmsh.y b/Parser/Gmsh.y index 35aeb9341653f0b3536e13759afeb0a61d8f360a..83f1952052e8b810ef54045f0b88eaa8e4a30d02 100644 --- a/Parser/Gmsh.y +++ b/Parser/Gmsh.y @@ -1735,11 +1735,11 @@ Shape : double x = CTX::instance()->geom.scalingFactor * $6[0]; double y = CTX::instance()->geom.scalingFactor * $6[1]; double z = CTX::instance()->geom.scalingFactor * $6[2]; + double lc = CTX::instance()->geom.scalingFactor * $6[3]; if(factory == "OpenCASCADE" && GModel::current()->getOCCInternals()){ - GModel::current()->getOCCInternals()->addVertex(num, x, y, z); + GModel::current()->getOCCInternals()->addVertex(num, x, y, z, lc); } else{ - double lc = CTX::instance()->geom.scalingFactor * $6[3]; if(lc == 0.) lc = MAX_LC; // no mesh size given at the point Vertex *v; if(!myGmshSurface) diff --git a/demos/boolean/simple.geo b/demos/boolean/simple.geo index 27e757daf5ec7822da9302e2026102bb4e3203ea..c49e9a9d576cb2a4ca3c490fc95adcf81fba7410 100644 --- a/demos/boolean/simple.geo +++ b/demos/boolean/simple.geo @@ -1,13 +1,10 @@ SetFactory("OpenCASCADE"); -Mesh.Algorithm = 6; -Mesh.CharacteristicLengthMin = 0.1; -Mesh.CharacteristicLengthMax = 0.1; - -Point(1) = {0,0,0}; -Point(2) = {1,0,0}; -Point(3) = {1,1,0}; -Point(4) = {0,1,0}; +lc = 0.1; +Point(1) = {0,0,0, lc}; +Point(2) = {1,0,0, lc}; +Point(3) = {1,1,0, lc}; +Point(4) = {0,1,0, lc/10}; Line(1) = {1,2}; Line(2) = {2,3}; Line(3) = {3,4};