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

more work on boolean numbering

parent 26df45f9
Branches
Tags
No related merge requests found
...@@ -2214,12 +2214,9 @@ bool OCC_Internals::booleanOperator(int tag, BooleanOperator op, ...@@ -2214,12 +2214,9 @@ bool OCC_Internals::booleanOperator(int tag, BooleanOperator op,
return false; return false;
} }
// don't try to preserve numbering if we specify the tag explicitly, or if // if we specify the tag explicitly, just go ahead and bind the resulting
// there is a problem // shape (and sub-shapes)
bool bug1 = (objectDimTags.size() + toolDimTags.size() != mapModified.size()); if(tag >= 0){
bool bug2 = (op == OCC_Internals::Union); // strange fuse behavior in OCC 7.1
if(tag >= 0 || bug1 || bug2){
if(bug1) Msg::Error("Wrong shape count in boolean operation");
if(removeObject){ if(removeObject){
for(unsigned int i = 0; i < objectDimTags.size(); i++){ for(unsigned int i = 0; i < objectDimTags.size(); i++){
int d = objectDimTags[i].first; int d = objectDimTags[i].first;
...@@ -2239,26 +2236,22 @@ bool OCC_Internals::booleanOperator(int tag, BooleanOperator op, ...@@ -2239,26 +2236,22 @@ bool OCC_Internals::booleanOperator(int tag, BooleanOperator op,
return true; return true;
} }
// otherwise, try to preserve the numbering // otherwise, preserve the numbering of the input shapes that did not change,
// or that were replaced by a single shape
for(unsigned int i = 0; i < objectDimTags.size(); i++){ for(unsigned int i = 0; i < objectDimTags.size(); i++){
int dim = objectDimTags[i].first; int dim = objectDimTags[i].first;
int tag = objectDimTags[i].second; int tag = objectDimTags[i].second;
if(mapDeleted[i] && !mapGenerated[i].Extent()){ if(mapDeleted[i]){ // object deleted
// the shape has been deleted if(removeObject) unbind(mapOriginal[i], dim, tag, true);
if(removeObject && _isBound(dim, mapOriginal[i])){
unbind(mapOriginal[i], dim, tag, true);
}
} }
else if(mapModified[i].Extent() == 0){ else if(mapModified[i].Extent() == 0){ // object not modified
// the shape has not been modified
outDimTags.push_back(std::pair<int, int>(dim, tag)); outDimTags.push_back(std::pair<int, int>(dim, tag));
unbind(mapOriginal[i], dim, tag, false); // not recursive!
bind(mapOriginal[i], dim, tag, false); // not recursive!
} }
else if(mapModified[i].Extent() == 1){ else if(mapModified[i].Extent() == 1){ // object replaced by single one
if(removeObject){ if(removeObject){
// the shape has been replaced by a single shape, keep the same tag
if(_isBound(dim, mapOriginal[i])){
unbind(mapOriginal[i], dim, tag, true); unbind(mapOriginal[i], dim, tag, true);
}
bind(mapModified[i].First(), dim, tag, false); // not recursive! bind(mapModified[i].First(), dim, tag, false); // not recursive!
int t = _find(dim, mapModified[i].First()); int t = _find(dim, mapModified[i].First());
if(tag != t) if(tag != t)
...@@ -2267,32 +2260,24 @@ bool OCC_Internals::booleanOperator(int tag, BooleanOperator op, ...@@ -2267,32 +2260,24 @@ bool OCC_Internals::booleanOperator(int tag, BooleanOperator op,
} }
} }
else{ else{
if(removeObject && _isBound(dim, mapOriginal[i])){ if(removeObject) unbind(mapOriginal[i], dim, tag, true);
unbind(mapOriginal[i], dim, tag, true);
}
} }
} }
for(unsigned int i = 0; i < toolDimTags.size(); i++){ for(unsigned int i = 0; i < toolDimTags.size(); i++){
int k = objectDimTags.size() + i; int k = objectDimTags.size() + i;
int dim = toolDimTags[i].first; int dim = toolDimTags[i].first;
int tag = toolDimTags[i].second; int tag = toolDimTags[i].second;
if(mapDeleted[k] && !mapGenerated[k].Extent()){ if(mapDeleted[k]){ // tool deleted
// the shape has been deleted if(removeTool) unbind(mapOriginal[k], dim, tag, true);
if(removeTool && _isBound(dim, mapOriginal[k])){
unbind(mapOriginal[k], dim, tag, true);
}
} }
else if(mapModified[k].Extent() == 0){ else if(mapModified[k].Extent() == 0){ // tool not modified
// the shape has not been modified
outDimTags.push_back(std::pair<int, int>(dim, tag)); outDimTags.push_back(std::pair<int, int>(dim, tag));
unbind(mapOriginal[k], dim, tag, false); // not recursive!
bind(mapOriginal[k], dim, tag, false); // not recursive!
} }
else if(mapModified[k].Extent() == 1){ else if(mapModified[k].Extent() == 1){
if(removeTool){ if(removeTool){ // tool replaced by single one
// the shape has been replaced by a single shape, keep the same tag
if(_isBound(dim, mapOriginal[k])){
unbind(mapOriginal[k], dim, tag, true); unbind(mapOriginal[k], dim, tag, true);
}
bind(mapModified[k].First(), dim, tag, false); // not recursive! bind(mapModified[k].First(), dim, tag, false); // not recursive!
int t = _find(dim, mapModified[k].First()); int t = _find(dim, mapModified[k].First());
if(tag != t) if(tag != t)
...@@ -2301,14 +2286,12 @@ bool OCC_Internals::booleanOperator(int tag, BooleanOperator op, ...@@ -2301,14 +2286,12 @@ bool OCC_Internals::booleanOperator(int tag, BooleanOperator op,
} }
} }
else{ else{
if(removeTool && _isBound(dim, mapOriginal[k])){ if(removeTool) unbind(mapOriginal[k], dim, tag, true);
unbind(mapOriginal[k], dim, tag, true);
}
} }
} }
// bind all remaining entities and add (only) new one to the returned list // bind all remaining entities and add the new ones to the returned list
_multiBind(result, tag, outDimTags, false, true, true); _multiBind(result, -1, outDimTags, false, true, true);
_filterTags(outDimTags, minDim); _filterTags(outDimTags, minDim);
return true; return true;
...@@ -2383,6 +2366,8 @@ bool OCC_Internals::_transform(const std::vector<std::pair<int, int> > &inDimTag ...@@ -2383,6 +2366,8 @@ bool OCC_Internals::_transform(const std::vector<std::pair<int, int> > &inDimTag
} }
result = gtfo->Shape(); result = gtfo->Shape();
} }
// FIXME we should implement rebind(object, result, dim) which would
// unbind/bind all subshapes to the same tags
unbind(object, dim, tag, true); unbind(object, dim, tag, true);
bind(result, dim, tag, true); bind(result, dim, tag, true);
} }
......
lv = .1; lv = .15;
lc = .1; lc = .12;
Point(1) = {0.0,0.0,0.0,lv}; Point(1) = {0.0,0.0,0.0,lv};
Point(2) = {1,0.0,0.0,lv}; Point(2) = {1,0.0,0.0,lv};
Point(3) = {1,1,0.0,lv}; Point(3) = {1,1,0.0,lv};
......
SetFactory("OpenCASCADE"); SetFactory("OpenCASCADE");
Block(1) = {-0, 0, 0, 1, 1, 1}; Block(1) = {-0, 0, 0, 1, 1, 1};
p() = PointsOf{ Volume{1}; };
Characteristic Length{p()} = 0.2;
// intersecting:
Rectangle(7) = {0.4, 0.7, 0.2, 0.3, 0.3, 0}; Rectangle(7) = {0.4, 0.7, 0.2, 0.3, 0.3, 0};
Rectangle(8) = {-0.2, 0.3, 0.5, 0.3, 0.3, 0}; Rectangle(8) = {-0.2, 0.3, 0.5, 0.3, 0.3, 0};
Rectangle(9) = {0.8, -0.2, 0.5, 0.3, 0.3, 0}; Rectangle(9) = {0.8, -0.2, 0.5, 0.3, 0.3, 0};
...@@ -11,6 +11,5 @@ Rectangle(10) = {0.3, 0.3, 0.5, 0.3, 0.3, 0}; ...@@ -11,6 +11,5 @@ Rectangle(10) = {0.3, 0.3, 0.5, 0.3, 0.3, 0};
a() = BooleanFragments{ Volume{1}; Delete; }{ Surface{7:10}; Delete; }; a() = BooleanFragments{ Volume{1}; Delete; }{ Surface{7:10}; Delete; };
Printf("a = ", a()); Printf("a = ", a());
//Characteristic Length{Point "*"} = 0.1; p() = PointsOf{ Surface{a({1:6})}; };
//p() = PointsOf{ Surface{a({1:#a()-1})}; }; Characteristic Length{p()} = 0.04;
//Characteristic Length{p()} = 0.01;
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment