Skip to content
Snippets Groups Projects
Commit 358436b1 authored by Christophe Geuzaine's avatar Christophe Geuzaine
Browse files

occ mesh size constraint on points

parent 05662e5c
No related branches found
No related tags found
No related merge requests found
...@@ -243,7 +243,8 @@ int OCC_Internals::getMaxTag(int dim) const ...@@ -243,7 +243,8 @@ int OCC_Internals::getMaxTag(int dim) const
return ret; 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)){ if(tag > 0 && _tagVertex.IsBound(tag)){
Msg::Error("OpenCASCADE vertex with tag %d already exists", 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) ...@@ -266,6 +267,8 @@ void OCC_Internals::addVertex(int tag, double x, double y, double z)
} }
if(tag <= 0) tag = getMaxTag(0) + 1; if(tag <= 0) tag = getMaxTag(0) + 1;
bind(result, tag); bind(result, tag);
if(meshSize > 0 && meshSize < MAX_LC)
meshAttributes[0][tag].size = meshSize;
} }
void OCC_Internals::addLine(int tag, int startTag, int endTag) void OCC_Internals::addLine(int tag, int startTag, int endTag)
...@@ -1788,7 +1791,10 @@ void OCC_Internals::synchronize(GModel *model) ...@@ -1788,7 +1791,10 @@ void OCC_Internals::synchronize(GModel *model)
tag = vTagMax + 1; tag = vTagMax + 1;
vTagMax++; 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));
} }
} }
......
...@@ -37,13 +37,13 @@ class OCC_Internals { ...@@ -37,13 +37,13 @@ class OCC_Internals {
TopTools_DataMapOfIntegerShape _tagWire, _tagShell; TopTools_DataMapOfIntegerShape _tagWire, _tagShell;
// internal mesh attributes, linked to tags // internal mesh attributes, linked to tags
class meshAttributes { class meshAttribute {
public: public:
meshAttributes() : size(0.), extrude(0) {} meshAttribute() : size(MAX_LC), extrude(0) {}
double size; double size;
ExtrudeParams *extrude; 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 // add a shape and all its subshapes to _vmap, _emap, ..., _somap
void _addShapeToMaps(TopoDS_Shape shape); void _addShapeToMaps(TopoDS_Shape shape);
...@@ -75,7 +75,7 @@ class OCC_Internals { ...@@ -75,7 +75,7 @@ class OCC_Internals {
void reset() void reset()
{ {
for(int i = 0; i < 6; i++) _maxTagConstraints[i] = 0; 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(); _somap.Clear(); _shmap.Clear(); _fmap.Clear(); _wmap.Clear(); _emap.Clear();
_vmap.Clear(); _vmap.Clear();
_vertexTag.Clear(); _edgeTag.Clear(); _faceTag.Clear(); _solidTag.Clear(); _vertexTag.Clear(); _edgeTag.Clear(); _faceTag.Clear(); _solidTag.Clear();
...@@ -120,7 +120,7 @@ class OCC_Internals { ...@@ -120,7 +120,7 @@ class OCC_Internals {
int getMaxTag(int dim) const; int getMaxTag(int dim) const;
// add shapes // 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 addLine(int tag, int startTag, int endTag);
void addCircleArc(int tag, int startTag, int centerTag, 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, void addCircle(int tag, double x, double y, double z, double r, double angle1,
...@@ -254,7 +254,7 @@ public: ...@@ -254,7 +254,7 @@ public:
void reset(){} void reset(){}
void setTagConstraints(int dim, int val){} void setTagConstraints(int dim, int val){}
int getMaxTag(int dim) const { return 0; } 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 addLine(int tag, int startTag, int endTag){}
void addCircleArc(int tag, int startTag, int centerTag, 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, void addCircle(int tag, double x, double y, double z, double r, double angle1,
......
...@@ -15,20 +15,20 @@ ...@@ -15,20 +15,20 @@
#include "GModelIO_OCC.h" #include "GModelIO_OCC.h"
OCCVertex::OCCVertex(GModel *m, int num, TopoDS_Vertex _v) OCCVertex::OCCVertex(GModel *m, int num, TopoDS_Vertex v, double lc)
: GVertex(m, num), v(_v) : GVertex(m, num, lc), _v(v)
{ {
max_curvature = -1; max_curvature = -1;
gp_Pnt pnt = BRep_Tool::Pnt(v); gp_Pnt pnt = BRep_Tool::Pnt(_v);
_x = pnt.X(); _x = pnt.X();
_y = pnt.Y(); _y = pnt.Y();
_z = pnt.Z(); _z = pnt.Z();
model()->getOCCInternals()->bind(v, num); model()->getOCCInternals()->bind(_v, num);
} }
OCCVertex::~OCCVertex() OCCVertex::~OCCVertex()
{ {
model()->getOCCInternals()->unbind(v, tag()); model()->getOCCInternals()->unbind(_v, tag());
} }
void OCCVertex::setPosition(GPoint &p) void OCCVertex::setPosition(GPoint &p)
......
...@@ -15,12 +15,12 @@ ...@@ -15,12 +15,12 @@
class OCCVertex : public GVertex { class OCCVertex : public GVertex {
protected: protected:
TopoDS_Vertex v; TopoDS_Vertex _v;
double _x, _y, _z; double _x, _y, _z;
mutable double max_curvature; mutable double max_curvature;
double max_curvature_of_surfaces() const; double max_curvature_of_surfaces() const;
public: public:
OCCVertex(GModel *m, int num, TopoDS_Vertex _v); OCCVertex(GModel *m, int num, TopoDS_Vertex v, double lc=MAX_LC);
virtual ~OCCVertex(); virtual ~OCCVertex();
virtual GPoint point() const { return GPoint(x(), y(), z()); } virtual GPoint point() const { return GPoint(x(), y(), z()); }
virtual double x() const { return _x; } virtual double x() const { return _x; }
...@@ -28,9 +28,9 @@ class OCCVertex : public GVertex { ...@@ -28,9 +28,9 @@ class OCCVertex : public GVertex {
virtual double z() const { return _z; } virtual double z() const { return _z; }
virtual void setPosition(GPoint &p); virtual void setPosition(GPoint &p);
ModelType getNativeType() const { return OpenCascadeModel; } 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; virtual SPoint2 reparamOnFace(const GFace *gf, int) const;
TopoDS_Vertex getShape() { return v; } TopoDS_Vertex getShape() { return _v; }
}; };
#endif #endif
......
...@@ -8063,11 +8063,11 @@ yyreduce: ...@@ -8063,11 +8063,11 @@ yyreduce:
double x = CTX::instance()->geom.scalingFactor * (yyvsp[(6) - (7)].v)[0]; double x = CTX::instance()->geom.scalingFactor * (yyvsp[(6) - (7)].v)[0];
double y = CTX::instance()->geom.scalingFactor * (yyvsp[(6) - (7)].v)[1]; double y = CTX::instance()->geom.scalingFactor * (yyvsp[(6) - (7)].v)[1];
double z = CTX::instance()->geom.scalingFactor * (yyvsp[(6) - (7)].v)[2]; 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()){ if(factory == "OpenCASCADE" && GModel::current()->getOCCInternals()){
GModel::current()->getOCCInternals()->addVertex(num, x, y, z); GModel::current()->getOCCInternals()->addVertex(num, x, y, z, lc);
} }
else{ 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 if(lc == 0.) lc = MAX_LC; // no mesh size given at the point
Vertex *v; Vertex *v;
if(!myGmshSurface) if(!myGmshSurface)
......
...@@ -1735,11 +1735,11 @@ Shape : ...@@ -1735,11 +1735,11 @@ Shape :
double x = CTX::instance()->geom.scalingFactor * $6[0]; double x = CTX::instance()->geom.scalingFactor * $6[0];
double y = CTX::instance()->geom.scalingFactor * $6[1]; double y = CTX::instance()->geom.scalingFactor * $6[1];
double z = CTX::instance()->geom.scalingFactor * $6[2]; double z = CTX::instance()->geom.scalingFactor * $6[2];
double lc = CTX::instance()->geom.scalingFactor * $6[3];
if(factory == "OpenCASCADE" && GModel::current()->getOCCInternals()){ if(factory == "OpenCASCADE" && GModel::current()->getOCCInternals()){
GModel::current()->getOCCInternals()->addVertex(num, x, y, z); GModel::current()->getOCCInternals()->addVertex(num, x, y, z, lc);
} }
else{ else{
double lc = CTX::instance()->geom.scalingFactor * $6[3];
if(lc == 0.) lc = MAX_LC; // no mesh size given at the point if(lc == 0.) lc = MAX_LC; // no mesh size given at the point
Vertex *v; Vertex *v;
if(!myGmshSurface) if(!myGmshSurface)
......
SetFactory("OpenCASCADE"); SetFactory("OpenCASCADE");
Mesh.Algorithm = 6; lc = 0.1;
Mesh.CharacteristicLengthMin = 0.1; Point(1) = {0,0,0, lc};
Mesh.CharacteristicLengthMax = 0.1; Point(2) = {1,0,0, lc};
Point(3) = {1,1,0, lc};
Point(1) = {0,0,0}; Point(4) = {0,1,0, lc/10};
Point(2) = {1,0,0};
Point(3) = {1,1,0};
Point(4) = {0,1,0};
Line(1) = {1,2}; Line(1) = {1,2};
Line(2) = {2,3}; Line(2) = {2,3};
Line(3) = {3,4}; Line(3) = {3,4};
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment