Commit c25ed52f authored by Christophe Geuzaine's avatar Christophe Geuzaine

setMeshSize now removes a pre-existing constraint if it exists - fixes #459

parent 6d2cc41b
......@@ -3177,8 +3177,10 @@ void OCC_Internals::setMeshSize(int dim, int tag, double size)
{
if(dim != 0) return;
if(_tagVertex.IsBound(tag)) {
_meshAttributes->insert(
new OCCMeshAttributes(0, _tagVertex.Find(tag), size));
OCCMeshAttributes *a = new OCCMeshAttributes(0, _tagVertex.Find(tag), size);
// first remove any other constraint
_meshAttributes->remove(a);
_meshAttributes->insert(a);
}
}
......
......@@ -119,8 +119,7 @@ public:
try {
BRepBndLib::Add(v->getShape(), box);
if(box.IsVoid()) {
Msg::Debug(
"Inserting (null or degenerate) shape with void bounding box");
Msg::Debug("Inserting (null or degenerate) shape with void bounding box");
// BRepTools::Dump(v->getShape(), std::cout);
return;
}
......@@ -137,6 +136,30 @@ public:
double bmax[3] = {x + _tol, y + _tol, z + _tol};
_rtree[v->getDim()]->Insert(bmin, bmax, v);
}
void remove(OCCMeshAttributes *v)
{
if(v->getDim() < 0 || v->getDim() > 3) return;
Bnd_Box box;
try {
BRepBndLib::Add(v->getShape(), box);
if(box.IsVoid()) {
Msg::Debug("Removing (null or degenerate) shape with void bounding box");
// BRepTools::Dump(v->getShape(), std::cout);
return;
}
} catch(Standard_Failure &err) {
Msg::Error("OpenCASCADE exception %s", err.GetMessageString());
return;
}
double xmin, ymin, zmin, xmax, ymax, zmax;
box.Get(xmin, ymin, zmin, xmax, ymax, zmax);
double x = 0.5 * (xmin + xmax);
double y = 0.5 * (ymin + ymax);
double z = 0.5 * (zmin + zmax);
double bmin[3] = {x - _tol, y - _tol, z - _tol};
double bmax[3] = {x + _tol, y + _tol, z + _tol};
_rtree[v->getDim()]->Remove(bmin, bmax, v);
}
void find(int dim, const TopoDS_Shape &shape,
std::vector<OCCMeshAttributes *> &attr, bool requireMeshSize,
bool requireExtrudeParams, bool excludeSame)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment