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

occ thicksolid (does not seem to work on complex solids)

parent fd75453c
No related branches found
No related tags found
No related merge requests found
...@@ -35,6 +35,7 @@ ...@@ -35,6 +35,7 @@
#include <BRepOffsetAPI_MakeFilling.hxx> #include <BRepOffsetAPI_MakeFilling.hxx>
#include <BRepOffsetAPI_MakePipe.hxx> #include <BRepOffsetAPI_MakePipe.hxx>
#include <BRepOffsetAPI_ThruSections.hxx> #include <BRepOffsetAPI_ThruSections.hxx>
#include <BRepOffsetAPI_MakeThickSolid.hxx>
#include <gce_MakeCirc.hxx> #include <gce_MakeCirc.hxx>
#include <gce_MakePln.hxx> #include <gce_MakePln.hxx>
#include <ElCLib.hxx> #include <ElCLib.hxx>
...@@ -443,7 +444,7 @@ void OCC_Internals::addLineLoop(int tag, std::vector<int> edgeTags) ...@@ -443,7 +444,7 @@ void OCC_Internals::addLineLoop(int tag, std::vector<int> edgeTags)
void OCC_Internals::addRectangle(int tag, double x1, double y1, double z1, void OCC_Internals::addRectangle(int tag, double x1, double y1, double z1,
double x2, double y2, double z2) double x2, double y2, double z2)
{ {
if(_tagFace.IsBound(tag)){ if(tag > 0 && _tagFace.IsBound(tag)){
Msg::Error("OpenCASCADE face with tag %d already exists", tag); Msg::Error("OpenCASCADE face with tag %d already exists", tag);
return; return;
} }
...@@ -469,13 +470,14 @@ void OCC_Internals::addRectangle(int tag, double x1, double y1, double z1, ...@@ -469,13 +470,14 @@ void OCC_Internals::addRectangle(int tag, double x1, double y1, double z1,
Msg::Error("OpenCASCADE exception %s", err.GetMessageString()); Msg::Error("OpenCASCADE exception %s", err.GetMessageString());
return; return;
} }
if(tag <= 0) tag = getMaxTag(2) + 1;
bind(result, tag); bind(result, tag);
} }
void OCC_Internals::addDisk(int tag, double xc, double yc, double zc, void OCC_Internals::addDisk(int tag, double xc, double yc, double zc,
double rx, double ry) double rx, double ry)
{ {
if(_tagFace.IsBound(tag)){ if(tag > 0 && _tagFace.IsBound(tag)){
Msg::Error("OpenCASCADE face with tag %d already exists", tag); Msg::Error("OpenCASCADE face with tag %d already exists", tag);
return; return;
} }
...@@ -495,6 +497,7 @@ void OCC_Internals::addDisk(int tag, double xc, double yc, double zc, ...@@ -495,6 +497,7 @@ void OCC_Internals::addDisk(int tag, double xc, double yc, double zc,
Msg::Error("OpenCASCADE exception %s", err.GetMessageString()); Msg::Error("OpenCASCADE exception %s", err.GetMessageString());
return; return;
} }
if(tag <= 0) tag = getMaxTag(2) + 1;
bind(result, tag); bind(result, tag);
} }
...@@ -1033,6 +1036,47 @@ void OCC_Internals::addPipe(int tag, std::vector<int> inTags[4], ...@@ -1033,6 +1036,47 @@ void OCC_Internals::addPipe(int tag, std::vector<int> inTags[4],
_extrude(tag, 2, inTags, 0, 0, 0, 0, 0, 0, 0, edgeTags, outTags); _extrude(tag, 2, inTags, 0, 0, 0, 0, 0, 0, 0, edgeTags, outTags);
} }
void OCC_Internals::addThickSolid(int tag, int solidTag,
std::vector<int> excludeFaceTags, double offset)
{
if(tag > 0 && isBound(3, tag)){
Msg::Error("OpenCASCADE region with tag %d already exists", tag);
return;
}
if(!isBound(3, solidTag)){
Msg::Error("Unknown OpenCASCADE region with tag %d", solidTag);
return;
}
TopoDS_Shape result;
try{
TopoDS_Shape shape = find(3, solidTag);
TopTools_ListOfShape exclude;
for(unsigned int i = 0; i < excludeFaceTags.size(); i++){
if(!_tagFace.IsBound(excludeFaceTags[i])){
Msg::Error("Unknown OpenCASCADE face with tag %d", excludeFaceTags[i]);
return;
}
exclude.Append(_tagFace.Find(excludeFaceTags[i]));
}
BRepOffsetAPI_MakeThickSolid ts(shape, exclude, offset,
CTX::instance()->geom.tolerance);
ts.Build();
if(!ts.IsDone()){
Msg::Error("Could not build thick solid");
return;
}
result = ts.Shape();
}
catch(Standard_Failure &err){
Msg::Error("OpenCASCADE exception %s", err.GetMessageString());
return;
}
std::vector<int> out[4];
bind(result, true, tag, out);
}
void OCC_Internals::applyBooleanOperator(int tag, BooleanOperator op, void OCC_Internals::applyBooleanOperator(int tag, BooleanOperator op,
std::vector<int> objectTags[4], std::vector<int> objectTags[4],
std::vector<int> toolTags[4], std::vector<int> toolTags[4],
......
...@@ -123,6 +123,8 @@ class OCC_Internals { ...@@ -123,6 +123,8 @@ class OCC_Internals {
void addThruSections(int tag, std::vector<int> wireTags, void addThruSections(int tag, std::vector<int> wireTags,
std::vector<int> outTags[4], std::vector<int> outTags[4],
bool makeSolid, bool makeRuled); bool makeSolid, bool makeRuled);
void addThickSolid(int tag, int solidTag, std::vector<int> excludeFaceTags,
double offset);
// extrude and revolve // extrude and revolve
void extrude(int tag, std::vector<int> inTags[4], void extrude(int tag, std::vector<int> inTags[4],
...@@ -245,6 +247,8 @@ public: ...@@ -245,6 +247,8 @@ public:
void addThruSections(int tag, std::vector<int> wireTags, void addThruSections(int tag, std::vector<int> wireTags,
std::vector<int> outTags[4], std::vector<int> outTags[4],
bool makeSolid, bool makeRuled){} bool makeSolid, bool makeRuled){}
void addThickSolid(int tag, int solidTag, std::vector<int> excludeFaceTags,
double offset){}
void extrude(int tag, std::vector<int> inTags[4], void extrude(int tag, std::vector<int> inTags[4],
double dx, double dy, double dz, double dx, double dy, double dz,
std::vector<int> outTags[4]){} std::vector<int> outTags[4]){}
......
...@@ -310,6 +310,7 @@ Tan return tTan; ...@@ -310,6 +310,7 @@ Tan return tTan;
Tanh return tTanh; Tanh return tTanh;
TestLevel return tTestLevel; TestLevel return tTestLevel;
TextAttributes return tTextAttributes; TextAttributes return tTextAttributes;
ThickSolid return tThickSolid;
ThruSections return tThruSections; ThruSections return tThruSections;
Today return tToday; Today return tToday;
Torus return tTorus; Torus return tTorus;
......
This diff is collapsed.
...@@ -172,84 +172,85 @@ ...@@ -172,84 +172,85 @@
tBooleanDifference = 388, tBooleanDifference = 388,
tBooleanSection = 389, tBooleanSection = 389,
tBooleanFragments = 390, tBooleanFragments = 390,
tRecombine = 391, tThickSolid = 391,
tSmoother = 392, tRecombine = 392,
tSplit = 393, tSmoother = 393,
tDelete = 394, tSplit = 394,
tCoherence = 395, tDelete = 395,
tIntersect = 396, tCoherence = 396,
tMeshAlgorithm = 397, tIntersect = 397,
tReverse = 398, tMeshAlgorithm = 398,
tLayers = 399, tReverse = 399,
tScaleLast = 400, tLayers = 400,
tHole = 401, tScaleLast = 401,
tAlias = 402, tHole = 402,
tAliasWithOptions = 403, tAlias = 403,
tCopyOptions = 404, tAliasWithOptions = 404,
tQuadTriAddVerts = 405, tCopyOptions = 405,
tQuadTriNoNewVerts = 406, tQuadTriAddVerts = 406,
tQuadTriSngl = 407, tQuadTriNoNewVerts = 407,
tQuadTriDbl = 408, tQuadTriSngl = 408,
tRecombLaterals = 409, tQuadTriDbl = 409,
tTransfQuadTri = 410, tRecombLaterals = 410,
tText2D = 411, tTransfQuadTri = 411,
tText3D = 412, tText2D = 412,
tInterpolationScheme = 413, tText3D = 413,
tTime = 414, tInterpolationScheme = 414,
tCombine = 415, tTime = 415,
tBSpline = 416, tCombine = 416,
tBezier = 417, tBSpline = 417,
tNurbs = 418, tBezier = 418,
tNurbsOrder = 419, tNurbs = 419,
tNurbsKnots = 420, tNurbsOrder = 420,
tColor = 421, tNurbsKnots = 421,
tColorTable = 422, tColor = 422,
tFor = 423, tColorTable = 423,
tIn = 424, tFor = 424,
tEndFor = 425, tIn = 425,
tIf = 426, tEndFor = 426,
tElseIf = 427, tIf = 427,
tElse = 428, tElseIf = 428,
tEndIf = 429, tElse = 429,
tExit = 430, tEndIf = 430,
tAbort = 431, tExit = 431,
tField = 432, tAbort = 432,
tReturn = 433, tField = 433,
tCall = 434, tReturn = 434,
tSlide = 435, tCall = 435,
tMacro = 436, tSlide = 436,
tShow = 437, tMacro = 437,
tHide = 438, tShow = 438,
tGetValue = 439, tHide = 439,
tGetStringValue = 440, tGetValue = 440,
tGetEnv = 441, tGetStringValue = 441,
tGetString = 442, tGetEnv = 442,
tGetNumber = 443, tGetString = 443,
tHomology = 444, tGetNumber = 444,
tCohomology = 445, tHomology = 445,
tBetti = 446, tCohomology = 446,
tExists = 447, tBetti = 447,
tFileExists = 448, tExists = 448,
tGMSH_MAJOR_VERSION = 449, tFileExists = 449,
tGMSH_MINOR_VERSION = 450, tGMSH_MAJOR_VERSION = 450,
tGMSH_PATCH_VERSION = 451, tGMSH_MINOR_VERSION = 451,
tGmshExecutableName = 452, tGMSH_PATCH_VERSION = 452,
tSetPartition = 453, tGmshExecutableName = 453,
tNameToString = 454, tSetPartition = 454,
tStringToName = 455, tNameToString = 455,
tAFFECTDIVIDE = 456, tStringToName = 456,
tAFFECTTIMES = 457, tAFFECTDIVIDE = 457,
tAFFECTMINUS = 458, tAFFECTTIMES = 458,
tAFFECTPLUS = 459, tAFFECTMINUS = 459,
tOR = 460, tAFFECTPLUS = 460,
tAND = 461, tOR = 461,
tNOTEQUAL = 462, tAND = 462,
tEQUAL = 463, tNOTEQUAL = 463,
tGREATEROREQUAL = 464, tEQUAL = 464,
tLESSOREQUAL = 465, tGREATEROREQUAL = 465,
UNARYPREC = 466, tLESSOREQUAL = 466,
tMINUSMINUS = 467, UNARYPREC = 467,
tPLUSPLUS = 468 tMINUSMINUS = 468,
tPLUSPLUS = 469
}; };
#endif #endif
/* Tokens. */ /* Tokens. */
...@@ -386,84 +387,85 @@ ...@@ -386,84 +387,85 @@
#define tBooleanDifference 388 #define tBooleanDifference 388
#define tBooleanSection 389 #define tBooleanSection 389
#define tBooleanFragments 390 #define tBooleanFragments 390
#define tRecombine 391 #define tThickSolid 391
#define tSmoother 392 #define tRecombine 392
#define tSplit 393 #define tSmoother 393
#define tDelete 394 #define tSplit 394
#define tCoherence 395 #define tDelete 395
#define tIntersect 396 #define tCoherence 396
#define tMeshAlgorithm 397 #define tIntersect 397
#define tReverse 398 #define tMeshAlgorithm 398
#define tLayers 399 #define tReverse 399
#define tScaleLast 400 #define tLayers 400
#define tHole 401 #define tScaleLast 401
#define tAlias 402 #define tHole 402
#define tAliasWithOptions 403 #define tAlias 403
#define tCopyOptions 404 #define tAliasWithOptions 404
#define tQuadTriAddVerts 405 #define tCopyOptions 405
#define tQuadTriNoNewVerts 406 #define tQuadTriAddVerts 406
#define tQuadTriSngl 407 #define tQuadTriNoNewVerts 407
#define tQuadTriDbl 408 #define tQuadTriSngl 408
#define tRecombLaterals 409 #define tQuadTriDbl 409
#define tTransfQuadTri 410 #define tRecombLaterals 410
#define tText2D 411 #define tTransfQuadTri 411
#define tText3D 412 #define tText2D 412
#define tInterpolationScheme 413 #define tText3D 413
#define tTime 414 #define tInterpolationScheme 414
#define tCombine 415 #define tTime 415
#define tBSpline 416 #define tCombine 416
#define tBezier 417 #define tBSpline 417
#define tNurbs 418 #define tBezier 418
#define tNurbsOrder 419 #define tNurbs 419
#define tNurbsKnots 420 #define tNurbsOrder 420
#define tColor 421 #define tNurbsKnots 421
#define tColorTable 422 #define tColor 422
#define tFor 423 #define tColorTable 423
#define tIn 424 #define tFor 424
#define tEndFor 425 #define tIn 425
#define tIf 426 #define tEndFor 426
#define tElseIf 427 #define tIf 427
#define tElse 428 #define tElseIf 428
#define tEndIf 429 #define tElse 429
#define tExit 430 #define tEndIf 430
#define tAbort 431 #define tExit 431
#define tField 432 #define tAbort 432
#define tReturn 433 #define tField 433
#define tCall 434 #define tReturn 434
#define tSlide 435 #define tCall 435
#define tMacro 436 #define tSlide 436
#define tShow 437 #define tMacro 437
#define tHide 438 #define tShow 438
#define tGetValue 439 #define tHide 439
#define tGetStringValue 440 #define tGetValue 440
#define tGetEnv 441 #define tGetStringValue 441
#define tGetString 442 #define tGetEnv 442
#define tGetNumber 443 #define tGetString 443
#define tHomology 444 #define tGetNumber 444
#define tCohomology 445 #define tHomology 445
#define tBetti 446 #define tCohomology 446
#define tExists 447 #define tBetti 447
#define tFileExists 448 #define tExists 448
#define tGMSH_MAJOR_VERSION 449 #define tFileExists 449
#define tGMSH_MINOR_VERSION 450 #define tGMSH_MAJOR_VERSION 450
#define tGMSH_PATCH_VERSION 451 #define tGMSH_MINOR_VERSION 451
#define tGmshExecutableName 452 #define tGMSH_PATCH_VERSION 452
#define tSetPartition 453 #define tGmshExecutableName 453
#define tNameToString 454 #define tSetPartition 454
#define tStringToName 455 #define tNameToString 455
#define tAFFECTDIVIDE 456 #define tStringToName 456
#define tAFFECTTIMES 457 #define tAFFECTDIVIDE 457
#define tAFFECTMINUS 458 #define tAFFECTTIMES 458
#define tAFFECTPLUS 459 #define tAFFECTMINUS 459
#define tOR 460 #define tAFFECTPLUS 460
#define tAND 461 #define tOR 461
#define tNOTEQUAL 462 #define tAND 462
#define tEQUAL 463 #define tNOTEQUAL 463
#define tGREATEROREQUAL 464 #define tEQUAL 464
#define tLESSOREQUAL 465 #define tGREATEROREQUAL 465
#define UNARYPREC 466 #define tLESSOREQUAL 466
#define tMINUSMINUS 467 #define UNARYPREC 467
#define tPLUSPLUS 468 #define tMINUSMINUS 468
#define tPLUSPLUS 469
...@@ -481,7 +483,7 @@ typedef union YYSTYPE ...@@ -481,7 +483,7 @@ typedef union YYSTYPE
List_T *l; List_T *l;
} }
/* Line 1529 of yacc.c. */ /* Line 1529 of yacc.c. */
#line 485 "Gmsh.tab.hpp" #line 487 "Gmsh.tab.hpp"
YYSTYPE; YYSTYPE;
# define yystype YYSTYPE /* obsolescent; will be withdrawn */ # define yystype YYSTYPE /* obsolescent; will be withdrawn */
# define YYSTYPE_IS_DECLARED 1 # define YYSTYPE_IS_DECLARED 1
......
...@@ -151,7 +151,7 @@ struct doubleXstring{ ...@@ -151,7 +151,7 @@ struct doubleXstring{
%token tUsing tNotUsing tPlugin tDegenerated tRecursive %token tUsing tNotUsing tPlugin tDegenerated tRecursive
%token tRotate tTranslate tSymmetry tDilate tExtrude tLevelset tAffine %token tRotate tTranslate tSymmetry tDilate tExtrude tLevelset tAffine
%token tBooleanUnion tBooleanIntersection tBooleanDifference tBooleanSection %token tBooleanUnion tBooleanIntersection tBooleanDifference tBooleanSection
%token tBooleanFragments %token tBooleanFragments tThickSolid
%token tRecombine tSmoother tSplit tDelete tCoherence %token tRecombine tSmoother tSplit tDelete tCoherence
%token tIntersect tMeshAlgorithm tReverse %token tIntersect tMeshAlgorithm tReverse
%token tLayers tScaleLast tHole tAlias tAliasWithOptions tCopyOptions %token tLayers tScaleLast tHole tAlias tAliasWithOptions tCopyOptions
...@@ -2477,6 +2477,29 @@ Shape : ...@@ -2477,6 +2477,29 @@ Shape :
$$.Type = MSH_VOLUME; $$.Type = MSH_VOLUME;
$$.Num = num; $$.Num = num;
} }
| tThickSolid '(' FExpr ')' tAFFECT ListOfDouble tEND
{
int num = (int)$3;
if(factory == "OpenCASCADE" && GModel::current()->getOCCInternals()){
if(List_Nbr($6) >= 2){
double in; List_Read($6, 0, &in);
double offset; List_Read($6, 1, &offset);
std::vector<int> exclude;
for(int i = 2; i < List_Nbr($6); i++){
double d; List_Read($6, i, &d); exclude.push_back((int)d);
}
GModel::current()->getOCCInternals()->addThickSolid(num, (int)in, exclude,
offset);
}
else{
yymsg(0, "ThickSolid requires at least 2 arguments");
}
}
else{
yymsg(0, "ThickSolid only available with OpenCASCADE factory");
}
List_Delete($6);
}
| tSurface tSTRING '(' FExpr ')' tAFFECT ListOfDouble tEND | tSurface tSTRING '(' FExpr ')' tAFFECT ListOfDouble tEND
{ {
int num = (int)$4; int num = (int)$4;
...@@ -4334,11 +4357,6 @@ Extrude : ...@@ -4334,11 +4357,6 @@ Extrude :
List_Delete($3); List_Delete($3);
List_Delete($8); List_Delete($8);
} }
| tExtrude '{' FExpr '}' '{' ListOfShapes '}'
{
$$ = List_Create(2, 1, sizeof(Shape));
List_Delete($6);
}
| tExtrude '{' FExpr '}' '{' ListOfShapes '}' tNotUsing tSurface '{' ListOfDouble '}' | tExtrude '{' FExpr '}' '{' ListOfShapes '}' tNotUsing tSurface '{' ListOfDouble '}'
{ {
$$ = List_Create(2, 1, sizeof(Shape)); $$ = List_Create(2, 1, sizeof(Shape));
......
This diff is collapsed.
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment