diff --git a/Geo/GModelIO_OCC.cpp b/Geo/GModelIO_OCC.cpp index 4998acda4116d5c23cafc4b3e1d81d523a01e3ce..9dd1c6c901b05c275c7ff4ffa7946f9929bf5733 100644 --- a/Geo/GModelIO_OCC.cpp +++ b/Geo/GModelIO_OCC.cpp @@ -1877,12 +1877,11 @@ bool OCC_Internals::fillet(const std::vector<int> ®ionTags, return true; } -bool OCC_Internals::applyBooleanOperator - (int tag, BooleanOperator op, - const std::vector<std::pair<int, int> > &objectDimTags, - const std::vector<std::pair<int, int> > &toolDimTags, - std::vector<std::pair<int, int> > &outDimTags, - bool removeObject, bool removeTool) +bool OCC_Internals::booleanOperator(int tag, BooleanOperator op, + const std::vector<std::pair<int, int> > &objectDimTags, + const std::vector<std::pair<int, int> > &toolDimTags, + std::vector<std::pair<int, int> > &outDimTags, + bool removeObject, bool removeTool) { double tolerance = CTX::instance()->geom.toleranceBoolean; bool parallel = CTX::instance()->geom.occParallel; @@ -2158,6 +2157,46 @@ bool OCC_Internals::applyBooleanOperator return true; } +bool OCC_Internals::booleanUnion(int tag, + const std::vector<std::pair<int, int> > &objectDimTags, + const std::vector<std::pair<int, int> > &toolDimTags, + std::vector<std::pair<int, int> > &outDimTags, + bool removeObject, bool removeTool) +{ + return booleanOperator(tag, OCC_Internals::Union, objectDimTags, toolDimTags, + outDimTags, removeObject, removeTool); +} + +bool OCC_Internals::booleanIntersection(int tag, + const std::vector<std::pair<int, int> > &objectDimTags, + const std::vector<std::pair<int, int> > &toolDimTags, + std::vector<std::pair<int, int> > &outDimTags, + bool removeObject, bool removeTool) +{ + return booleanOperator(tag, OCC_Internals::Intersection, objectDimTags, toolDimTags, + outDimTags, removeObject, removeTool); +} + +bool OCC_Internals::booleanDifference(int tag, + const std::vector<std::pair<int, int> > &objectDimTags, + const std::vector<std::pair<int, int> > &toolDimTags, + std::vector<std::pair<int, int> > &outDimTags, + bool removeObject, bool removeTool) +{ + return booleanOperator(tag, OCC_Internals::Difference, objectDimTags, toolDimTags, + outDimTags, removeObject, removeTool); +} + +bool OCC_Internals::booleanFragments(int tag, + const std::vector<std::pair<int, int> > &objectDimTags, + const std::vector<std::pair<int, int> > &toolDimTags, + std::vector<std::pair<int, int> > &outDimTags, + bool removeObject, bool removeTool) +{ + return booleanOperator(tag, OCC_Internals::Fragments, objectDimTags, toolDimTags, + outDimTags, removeObject, removeTool); +} + bool OCC_Internals::_transform(const std::vector<std::pair<int, int> > &inDimTags, BRepBuilderAPI_Transform *tfo, BRepBuilderAPI_GTransform *gtfo) diff --git a/Geo/GModelIO_OCC.h b/Geo/GModelIO_OCC.h index 04d6c72bd92ab870f17ab33ec913c0e4501dcf30..66938494012aef51523204dd4e128afc7b92cada 100644 --- a/Geo/GModelIO_OCC.h +++ b/Geo/GModelIO_OCC.h @@ -239,11 +239,31 @@ class OCC_Internals { bool removeRegion); // apply boolean operator - bool applyBooleanOperator(int tag, BooleanOperator op, - const std::vector<std::pair<int, int> > &objectDimTags, - const std::vector<std::pair<int, int> > &toolDimTags, - std::vector<std::pair<int, int> > &outDimTags, - bool removeObject, bool removeTool); + bool booleanOperator(int tag, BooleanOperator op, + const std::vector<std::pair<int, int> > &objectDimTags, + const std::vector<std::pair<int, int> > &toolDimTags, + std::vector<std::pair<int, int> > &outDimTags, + bool removeObject, bool removeTool); + bool booleanUnion(int tag, + const std::vector<std::pair<int, int> > &objectDimTags, + const std::vector<std::pair<int, int> > &toolDimTags, + std::vector<std::pair<int, int> > &outDimTags, + bool removeObject, bool removeTool); + bool booleanIntersection(int tag, + const std::vector<std::pair<int, int> > &objectDimTags, + const std::vector<std::pair<int, int> > &toolDimTags, + std::vector<std::pair<int, int> > &outDimTags, + bool removeObject, bool removeTool); + bool booleanDifference(int tag, + const std::vector<std::pair<int, int> > &objectDimTags, + const std::vector<std::pair<int, int> > &toolDimTags, + std::vector<std::pair<int, int> > &outDimTags, + bool removeObject, bool removeTool); + bool booleanFragments(int tag, + const std::vector<std::pair<int, int> > &objectDimTags, + const std::vector<std::pair<int, int> > &toolDimTags, + std::vector<std::pair<int, int> > &outDimTags, + bool removeObject, bool removeTool); // apply transformations bool translate(const std::vector<std::pair<int, int> > &inDimTags, @@ -508,14 +528,46 @@ public: { return _error("create fillet"); } - bool applyBooleanOperator(int tag, BooleanOperator op, - const std::vector<std::pair<int, int> > &objectDimTags, - const std::vector<std::pair<int, int> > &toolDimTags, - std::vector<std::pair<int, int> > &outDimTags, - bool removeObject, bool removeTool) + bool booleanOperator(int tag, BooleanOperator op, + const std::vector<std::pair<int, int> > &objectDimTags, + const std::vector<std::pair<int, int> > &toolDimTags, + std::vector<std::pair<int, int> > &outDimTags, + bool removeObject, bool removeTool) { return _error("apply boolean operator"); } + bool booleanUnion(int tag, + const std::vector<std::pair<int, int> > &objectDimTags, + const std::vector<std::pair<int, int> > &toolDimTags, + std::vector<std::pair<int, int> > &outDimTags, + bool removeObject, bool removeTool) + { + return _error("apply boolean union"); + } + bool booleanIntersection(int tag, + const std::vector<std::pair<int, int> > &objectDimTags, + const std::vector<std::pair<int, int> > &toolDimTags, + std::vector<std::pair<int, int> > &outDimTags, + bool removeObject, bool removeTool) + { + return _error("apply boolean intersection"); + } + bool booleanDifference(int tag, + const std::vector<std::pair<int, int> > &objectDimTags, + const std::vector<std::pair<int, int> > &toolDimTags, + std::vector<std::pair<int, int> > &outDimTags, + bool removeObject, bool removeTool) + { + return _error("apply boolean difference"); + } + bool booleanFragments(int tag, + const std::vector<std::pair<int, int> > &objectDimTags, + const std::vector<std::pair<int, int> > &toolDimTags, + std::vector<std::pair<int, int> > &outDimTags, + bool removeObject, bool removeTool) + { + return _error("apply boolean fragments"); + } bool translate(const std::vector<std::pair<int, int> > &inDimTags, double dx, double dy, double dz) { diff --git a/Parser/Gmsh.tab.cpp b/Parser/Gmsh.tab.cpp index 204c713bb4e3b54dcba59b960e2e577b4d1b8c8f..7d299d99d5fbc2c2ea4366a09ce4f56670fde7fc 100644 --- a/Parser/Gmsh.tab.cpp +++ b/Parser/Gmsh.tab.cpp @@ -10490,7 +10490,7 @@ yyreduce: // currently we don't distinguish between Delete and Recursive Delete: // we always delete recursively. Let us know if you have examples where // having the choice would be interesting - r = GModel::current()->getOCCInternals()->applyBooleanOperator + r = GModel::current()->getOCCInternals()->booleanOperator (-1, (OCC_Internals::BooleanOperator)(yyvsp[(1) - (9)].i), object, tool, out, (yyvsp[(4) - (9)].i), (yyvsp[(8) - (9)].i)); VectorOfPairs2ListOfShapes(out, (yyval.l)); } @@ -10533,7 +10533,7 @@ yyreduce: // currently we don't distinguish between Delete and Recursive Delete: // we always delete recursively. Let us know if you have examples where // having the choice would be interesting - r = GModel::current()->getOCCInternals()->applyBooleanOperator + r = GModel::current()->getOCCInternals()->booleanOperator ((int)(yyvsp[(3) - (14)].d), (OCC_Internals::BooleanOperator)(yyvsp[(1) - (14)].i), object, tool, out, (yyvsp[(8) - (14)].i), (yyvsp[(12) - (14)].i)); } if(!r) yymsg(0, "Could not apply boolean operator"); diff --git a/Parser/Gmsh.y b/Parser/Gmsh.y index 3de33fdf53e76b6d42e6ad387e18931c7c5f12e1..4c3b037c86327f9e0096924b99122a9ba088155c 100644 --- a/Parser/Gmsh.y +++ b/Parser/Gmsh.y @@ -3922,7 +3922,7 @@ Boolean : // currently we don't distinguish between Delete and Recursive Delete: // we always delete recursively. Let us know if you have examples where // having the choice would be interesting - r = GModel::current()->getOCCInternals()->applyBooleanOperator + r = GModel::current()->getOCCInternals()->booleanOperator (-1, (OCC_Internals::BooleanOperator)$1, object, tool, out, $4, $8); VectorOfPairs2ListOfShapes(out, $$); } @@ -3963,7 +3963,7 @@ BooleanShape : // currently we don't distinguish between Delete and Recursive Delete: // we always delete recursively. Let us know if you have examples where // having the choice would be interesting - r = GModel::current()->getOCCInternals()->applyBooleanOperator + r = GModel::current()->getOCCInternals()->booleanOperator ((int)$3, (OCC_Internals::BooleanOperator)$1, object, tool, out, $8, $12); } if(!r) yymsg(0, "Could not apply boolean operator");