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

no need for addOCCFillet in GModel

parent 9b7d3fe7
No related branches found
No related tags found
No related merge requests found
...@@ -331,7 +331,6 @@ class GModel ...@@ -331,7 +331,6 @@ class GModel
int writeOCCBREP(const std::string &name); int writeOCCBREP(const std::string &name);
int importOCCShape(const void *shape); int importOCCShape(const void *shape);
int applyOCCMeshConstraints(const void *constraints); int applyOCCMeshConstraints(const void *constraints);
void addOCCFillet(std::vector<int> & , double &);
void addShape(std::string name, std::vector<double> &p, std::string op); void addShape(std::string name, std::vector<double> &p, std::string op);
// Gmsh mesh file format // Gmsh mesh file format
......
...@@ -546,9 +546,18 @@ void GModel::addShape(std::string name, std::vector<double> &p, ...@@ -546,9 +546,18 @@ void GModel::addShape(std::string name, std::vector<double> &p,
SPoint3(p[3],p[4],p[5]),o); SPoint3(p[3],p[4],p[5]),o);
} }
else if (name == "Fillet"){ else if (name == "Fillet"){
std::vector<int> edges; if (p.size() < 2){
for (int i=0;i<p.size()-1;i++)edges.push_back((int)p[i]); Msg::Error("At least 2 parameters have to be defined for a Fillet");
addOCCFillet(edges,p[p.size()-1]); return;
}
std::vector<TopoDS_Edge> edges;
for (int i = 0; i < p.size() - 1; i++){
GEdge *ge = getEdgeByTag((int)p[i]);
if (ge && ge->getNativeType() == GEntity::OpenCascadeModel){
edges.push_back(*(TopoDS_Edge*)ge->getNativePtr());
}
}
_occ_internals->Fillet(edges, p[p.size() - 1]);
} }
else{ else{
return; return;
...@@ -560,8 +569,6 @@ void GModel::addShape(std::string name, std::vector<double> &p, ...@@ -560,8 +569,6 @@ void GModel::addShape(std::string name, std::vector<double> &p,
catch(Standard_Failure &err){ catch(Standard_Failure &err){
Msg::Error("%s", err.GetMessageString()); Msg::Error("%s", err.GetMessageString());
} }
} }
TopoDS_Shape GlueFaces(const TopoDS_Shape &theShape, TopoDS_Shape GlueFaces(const TopoDS_Shape &theShape,
...@@ -612,51 +619,6 @@ TopoDS_Shape GlueFaces (const TopoDS_Shape& theShape, ...@@ -612,51 +619,6 @@ TopoDS_Shape GlueFaces (const TopoDS_Shape& theShape,
// return aRes; // return aRes;
} }
void OCC_Internals::Fillet(std::vector<TopoDS_Edge> & edgesToFillet,
double Radius){
// create a tool for fillet
BRepFilletAPI_MakeFillet fill (shape);
for (int i=0;i<edgesToFillet.size();++i){
fill.Add(edgesToFillet[i]);
}
for (int i = 1; i <= fill.NbContours(); i++) {
fill.SetRadius(Radius, i, 1);
}
fill.Build();
if (!fill.IsDone()) {
Msg::Error("Fillet can't be computed on the given shape with the given radius");
return;
}
shape = fill.Shape();
if (shape.IsNull()) return;
// Check shape validity
BRepCheck_Analyzer ana (shape, false);
if (!ana.IsValid()) {
Msg::Error("Fillet algorithm have produced an invalid shape result");
}
}
void GModel::addOCCFillet(std::vector<int> & edgesToFillet,
double &Radius)
{
std::vector<TopoDS_Edge> toto;
for (int i=0;i<edgesToFillet.size();++i){
GEdge *ge = getEdgeByTag(edgesToFillet[i]);
if (ge && ge->getNativeType() == GEntity::OpenCascadeModel){
toto.push_back(*(TopoDS_Edge*)ge->getNativePtr());
}
}
_occ_internals->Fillet(toto,Radius);
}
void OCC_Internals::applyBooleanOperator(TopoDS_Shape tool, const BooleanOperator &op) void OCC_Internals::applyBooleanOperator(TopoDS_Shape tool, const BooleanOperator &op)
{ {
if (tool.IsNull()) return; if (tool.IsNull()) return;
...@@ -932,6 +894,33 @@ void OCC_Internals::Box(const SPoint3 &p1, const SPoint3 &p2, ...@@ -932,6 +894,33 @@ void OCC_Internals::Box(const SPoint3 &p1, const SPoint3 &p2,
applyBooleanOperator(aShape, op); applyBooleanOperator(aShape, op);
} }
void OCC_Internals::Fillet(std::vector<TopoDS_Edge> &edgesToFillet,
double Radius){
// create a tool for fillet
BRepFilletAPI_MakeFillet fill(shape);
for (int i = 0; i < edgesToFillet.size(); ++i){
fill.Add(edgesToFillet[i]);
}
for (int i = 1; i <= fill.NbContours(); i++){
fill.SetRadius(Radius, i, 1);
}
fill.Build();
if (!fill.IsDone()) {
Msg::Error("Fillet can't be computed on the given shape with the given radius");
return;
}
shape = fill.Shape();
if (shape.IsNull()) return;
// Check shape validity
BRepCheck_Analyzer ana (shape, false);
if (!ana.IsValid()) {
Msg::Error("Fillet algorithm have produced an invalid shape result");
}
}
void GModel::_deleteOCCInternals() void GModel::_deleteOCCInternals()
{ {
if(_occ_internals) delete _occ_internals; if(_occ_internals) delete _occ_internals;
...@@ -1198,9 +1187,4 @@ void GModel::addShape(std::string name, std::vector<double> &p, ...@@ -1198,9 +1187,4 @@ void GModel::addShape(std::string name, std::vector<double> &p,
"Boolean Operators On Solids"); "Boolean Operators On Solids");
} }
void GModel:: addOCCFillet(std::vector<int> & , double &){
Msg::Error("Gmsh must be compiled with OpenCascade support to apply "
"the Fillet operator");
}
#endif #endif
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment