Commit b119f711 authored by Christophe Geuzaine's avatar Christophe Geuzaine

point constrainsts for SurfaceFilling

parent e0abd072
Pipeline #1201 failed with stage
in 35 minutes and 29 seconds
......@@ -1398,7 +1398,10 @@ bool OCC_Internals::addPlaneSurface(int &tag, const std::vector<int> &wireTags)
return true;
}
bool OCC_Internals::addSurfaceFilling(int &tag, int wireTag)
bool OCC_Internals::addSurfaceFilling(int &tag, int wireTag,
const std::vector<int> &vertexTags,
const std::vector<int> &faceTags,
const std::vector<int> &faceContinuity)
{
if(tag >= 0 && _tagFace.IsBound(tag)){
Msg::Error("OpenCASCADE face with tag %d already exists", tag);
......@@ -1408,18 +1411,41 @@ bool OCC_Internals::addSurfaceFilling(int &tag, int wireTag)
TopoDS_Face result;
try{
BRepOffsetAPI_MakeFilling f;
// add edge constraints
// bounding edge constraints
if(!_tagWire.IsBound(wireTag)){
Msg::Error("Unknown OpenCASCADE line loop with tag %d", wireTag);
return false;
}
TopoDS_Wire wire = TopoDS::Wire(_tagWire.Find(wireTag));
TopExp_Explorer exp0;
int i = 0;
for(exp0.Init(wire, TopAbs_EDGE); exp0.More(); exp0.Next()){
TopoDS_Edge edge = TopoDS::Edge(exp0.Current());
f.Add(edge, GeomAbs_C0);
if(i < faceTags.size()){ // associated face constraint (does not seem to work...)
if(!_tagFace.IsBound(faceTags[i])){
Msg::Error("Unknown OpenCASCADE face with tag %d", faceTags[i]);
return false;
}
TopoDS_Face face = TopoDS::Face(_tagFace.Find(faceTags[i]));
if(i < faceContinuity.size() && faceContinuity[i] == 2)
f.Add(edge, face, GeomAbs_G2);
else
f.Add(edge, face, GeomAbs_G1);
}
else{
f.Add(edge, GeomAbs_C0);
}
i++;
}
// point constraints
for(unsigned int i = 0; i < vertexTags.size(); i++){
if(!_tagVertex.IsBound(vertexTags[i])){
Msg::Error("Unknown OpenCASCADE vertex with tag %d", vertexTags[i]);
return false;
}
TopoDS_Vertex vertex = TopoDS::Vertex(_tagVertex.Find(vertexTags[i]));
f.Add(BRep_Tool::Pnt(vertex));
}
// TODO: add optional point constraints using f.Add(gp_Pnt(x, y, z);
f.Build();
if(!f.IsDone()){
Msg::Error("Could not build surface filling");
......
......@@ -196,7 +196,10 @@ class OCC_Internals {
double dx, double dy, double roundedRadius = 0.);
bool addDisk(int &tag, double xc, double yc, double zc, double rx, double ry);
bool addPlaneSurface(int &tag, const std::vector<int> &wireTags);
bool addSurfaceFilling(int &tag, int wireTag);
bool addSurfaceFilling(int &tag, int wireTag,
const std::vector<int> &vertexTags = std::vector<int>(),
const std::vector<int> &faceTags = std::vector<int>(),
const std::vector<int> &faceContinuity = std::vector<int>());
bool addSurfaceLoop(int &tag, const std::vector<int> &faceTags);
bool addVolume(int &tag, const std::vector<int> &shellTags);
bool addSphere(int &tag, double xc, double yc, double zc, double radius,
......@@ -430,7 +433,10 @@ public:
{
return _error("add plane surface");
}
bool addSurfaceFilling(int &tag, int wireTag)
bool addSurfaceFilling(int &tag, int wireTag,
const std::vector<int> &vertexTags = std::vector<int>(),
const std::vector<int> &faceTags = std::vector<int>(),
const std::vector<int> &faceContinuity = std::vector<int>())
{
return _error("add surface filling");
}
......
......@@ -149,7 +149,6 @@ Call return tCall;
Catenary return tCatenary;
CatmullRom return tSpline;
Ceil return tCeil;
Chamfer return tChamfer;
Characteristic return tCharacteristic;
Circle return tCircle;
CodeName return tCodeName;
......
This diff is collapsed.
This diff is collapsed.
......@@ -196,7 +196,7 @@ struct doubleXstring{
%token tBox tCylinder tCone tTorus tEllipsoid tQuadric tShapeFromFile
%token tRectangle tDisk tWire tGeoEntity
%token tCharacteristic tLength tParametric tElliptic tRefineMesh tAdaptMesh
%token tRelocateMesh tSetFactory tThruSections tWedge tFillet tChamfer
%token tRelocateMesh tSetFactory tThruSections tWedge tFillet
%token tPlane tRuled tTransfinite tPhysical tCompound tPeriodic
%token tUsing tPlugin tDegenerated tRecursive
%token tRotate tTranslate tSymmetry tDilate tExtrude tLevelset tAffine
......@@ -221,13 +221,13 @@ struct doubleXstring{
%type <v> VExpr VExpr_Single CircleOptions TransfiniteType
%type <i> NumericAffectation NumericIncrement BooleanOperator BooleanOption
%type <i> PhysicalId_per_dim_entity GeoEntity GeoEntity123 GeoEntity12 GeoEntity02
%type <i> TransfiniteArrangement RecombineAngle InSphereCenter
%type <i> TransfiniteArrangement RecombineAngle
%type <i> Append AppendOrNot
%type <u> ColorExpr
%type <c> StringExpr StringExprVar SendToFile tSTRING_Member HomologyCommand
%type <c> LP RP GetForcedStr_Default
%type <c> StringIndex String__Index
%type <l> MultiStringExprVar
%type <l> MultiStringExprVar SurfaceConstraints
%type <l> RecursiveListOfStringExprVar Str_BracedRecursiveListOfStringExprVar
%type <l> BracedOrNotRecursiveListOfStringExprVar BracedRecursiveListOfStringExprVar
%type <l> FExpr_Multi ListOfDouble ListOfDoubleOrAll RecursiveListOfDouble
......@@ -1544,14 +1544,29 @@ PhysicalId_per_dim_entity :
}
;
InSphereCenter :
SurfaceConstraints :
// nothing
{
$$ = -1;
$$ = 0;
}
| tIn tSphere '{' FExpr '}'
{
$$ = (int)$4;
$$ = List_Create(1, 1, sizeof(double));
int p = (int)$4;
List_Add($$, &p);
}
| tUsing tPoint '{' RecursiveListOfDouble '}'
{
$$ = $4;
}
| tUsing tGeoEntity '{' RecursiveListOfDouble '}'
{
$$ = List_Create(10, 10, sizeof(double));
double flag = -1;
List_Add($$, &flag);
for(int i = 0; i < List_Nbr($4); i++)
List_Add($$, List_Pointer($4, i));
List_Delete($4);
}
;
......@@ -1813,7 +1828,7 @@ Shape :
$$.Type = MSH_SURF_PLAN;
$$.Num = num;
}
| tSurface '(' FExpr ')' tAFFECT ListOfDouble InSphereCenter tEND
| tSurface '(' FExpr ')' tAFFECT ListOfDouble SurfaceConstraints tEND
{
int num = (int)$3;
std::vector<int> wires; ListOfDouble2Vector($6, wires);
......@@ -1823,23 +1838,57 @@ Shape :
yymsg(0, "OpenCASCADE face filling requires a single line loop");
}
else{
r = GModel::current()->getOCCInternals()->addSurfaceFilling(num, wires[0]);
std::vector<int> constraints; ListOfDouble2Vector($7, constraints);
std::vector<int> points, surfaces, continuity;
if(constraints.size() >= 3 && constraints[0] < 0){
// {-1, type, ent, type, ent, ...}
for(unsigned int i = 2; i < constraints.size(); i+=2){
int type = constraints[i - 1];
if(type == 0){
points.push_back(constraints[i]);
}
else if(type == 1 || type == 2){
surfaces.push_back(constraints[i]);
continuity.push_back(type);
}
else
yymsg(0, "Unknown type of constraint for surface filling");
}
}
else if(constraints.size() > 0){
// {point, point, ...}
points = constraints;
}
r = GModel::current()->getOCCInternals()->addSurfaceFilling
(num, wires[0], points, surfaces, continuity);
}
}
else{
r = GModel::current()->getGEOInternals()->addSurfaceFilling(num, wires, $7);
int sphereCenter = 0;
if(List_Nbr($7) == 1){
double d; List_Read($7, 0, &d);
sphereCenter = (int)d;
}
r = GModel::current()->getGEOInternals()->addSurfaceFilling
(num, wires, sphereCenter);
}
if(!r) yymsg(0, "Could not add surface");
List_Delete($6);
$$.Type = MSH_SURF_REGL;
$$.Num = num;
}
| tRuled tSurface '(' FExpr ')' tAFFECT ListOfDouble InSphereCenter tEND
| tRuled tSurface '(' FExpr ')' tAFFECT ListOfDouble SurfaceConstraints tEND
{
yymsg(2, "'Ruled Surface' command is deprecated: use 'Surface' instead");
int num = (int)$4;
std::vector<int> wires; ListOfDouble2Vector($7, wires);
bool r = GModel::current()->getGEOInternals()->addSurfaceFilling(num, wires, $8);
int sphereCenter = 0;
if(List_Nbr($7) == 1){
double d; List_Read($7, 0, &d);
sphereCenter = (int)d;
}
bool r = GModel::current()->getGEOInternals()->addSurfaceFilling
(num, wires, sphereCenter);
if(!r) yymsg(0, "Could not add surface");
List_Delete($7);
$$.Type = MSH_SURF_REGL;
......
This source diff could not be displayed because it is too large. You can view the blob instead.
SetFactory("OpenCASCADE");
//Mesh.Algorithm = 6;
Mesh.CharacteristicLengthMin = 0.02;
Mesh.CharacteristicLengthMax = 0.02;
Point(1) = {-0.8, 0.1, -0.2, 1.0};
Point(2) = {-0.5, 0.1, -0.2, 1.0};
Point(3) = {-0.6, 0, -0.1, 1.0};
Point(4) = {-0.7, -0, -0.1, 1.0};
Point(5) = {-0.7, 0.2, -0.2, 1.0};
Point(6) = {-0.6, 0.1, -0.1, 1.0};
Spline(1) = {1, 5, 2};
Spline(2) = {2, 6, 3};
Spline(3) = {3, 4, 1};
Line Loop(1) = {1, 2, 3};
// bspline surface bounded by line loop 1
Surface(1) = {1};
Point(7) = {-0.7, 0.1, -0.2, 1.0};
Point(8) = {-0.67, 0.1, -0.2, 1.0};
// same as 1, but passing through points 7 and 8
Surface(2) = {1} Using Point {7,8};
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