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

catch OCC exception in addShape

parent c4f25e5d
No related branches found
No related tags found
No related merge requests found
......@@ -499,55 +499,60 @@ void GModel::addShape(std::string name, std::vector<double> &p,
else if(op == "Fuse" || op == "Union") o = OCC_Internals::Fuse;
else if(op == "Intersection") o = OCC_Internals::Intersection;
if (name == "Sphere"){
if (p.size() != 4){
Msg::Error("4 parameters have to be defined for a sphere");
return;
}
_occ_internals->Sphere(SPoint3(p[0],p[1],p[2]),p[3],o);
}
else if (name == "Cylinder"){
if (p.size() != 8){
Msg::Error("8 parameters have to be defined for a Cylinder");
return;
try{
if (name == "Sphere"){
if (p.size() != 4){
Msg::Error("4 parameters have to be defined for a sphere");
return;
}
_occ_internals->Sphere(SPoint3(p[0],p[1],p[2]),p[3],o);
}
_occ_internals->Cylinder(SPoint3(p[0],p[1],p[2]),
SVector3(p[3],p[4],p[5]),p[6],p[7],o);
}
else if (name == "Torus"){
if (p.size() == 8){
_occ_internals->Torus(SPoint3(p[0],p[1],p[2]),
SVector3(p[3],p[4],p[5]),p[6],p[7],o);
else if (name == "Cylinder"){
if (p.size() != 8){
Msg::Error("8 parameters have to be defined for a Cylinder");
return;
}
_occ_internals->Cylinder(SPoint3(p[0],p[1],p[2]),
SVector3(p[3],p[4],p[5]),p[6],p[7],o);
}
else if (p.size() == 9){
_occ_internals->Torus(SPoint3(p[0],p[1],p[2]),
SVector3(p[3],p[4],p[5]),p[6],p[7],p[8],o);
else if (name == "Torus"){
if (p.size() == 8){
_occ_internals->Torus(SPoint3(p[0],p[1],p[2]),
SVector3(p[3],p[4],p[5]),p[6],p[7],o);
}
else if (p.size() == 9){
_occ_internals->Torus(SPoint3(p[0],p[1],p[2]),
SVector3(p[3],p[4],p[5]),p[6],p[7],p[8],o);
}
else{
Msg::Error("Wrong number of parameters for a Torus (8 or 9 is OK)");
return;
}
}
else{
Msg::Error("Wrong number of parameters for a Torus (8 or 9 is OK)");
return;
else if (name == "Cone"){
if (p.size() != 9){
Msg::Error("9 parameters have to be defined for a Cone");
return;
}
_occ_internals->Cone(SPoint3(p[0],p[1],p[2]),
SVector3(p[3],p[4],p[5]),p[6],p[7],p[8],o);
}
}
else if (name == "Cone"){
if (p.size() != 9){
Msg::Error("9 parameters have to be defined for a Cone");
return;
else if (name == "Box"){
if (p.size() != 6){
Msg::Error("6 parameters have to be defined for a Box");
return;
}
_occ_internals->Box(SPoint3(p[0],p[1],p[2]),
SPoint3(p[3],p[4],p[5]),o);
}
_occ_internals->Cone(SPoint3(p[0],p[1],p[2]),
SVector3(p[3],p[4],p[5]),p[6],p[7],p[8],o);
}
else if (name == "Box"){
if (p.size() != 6){
Msg::Error("6 parameters have to be defined for a Box");
return;
else{
// we should that at the end, a test now !!
_occ_internals->buildLists();
_occ_internals->buildGModel(this);
}
_occ_internals->Box(SPoint3(p[0],p[1],p[2]),
SPoint3(p[3],p[4],p[5]),o);
}
else{
// we should that at the end, a test now !!
_occ_internals->buildLists();
_occ_internals->buildGModel(this);
catch(Standard_Failure &err){
Msg::Error("%s", err.GetMessageString());
}
}
......@@ -848,7 +853,7 @@ void OCC_Internals::Cone(const SPoint3 &p, const SVector3 &d, double R1,
gp_Pnt aP(p.x(), p.y(), p.z());
gp_Vec aV(d.x(), d.y(), d.z());
gp_Ax2 anAxes(aP, aV);
BRepPrimAPI_MakeCone MC(anAxes, R1, R2,H);
BRepPrimAPI_MakeCone MC(anAxes, R1, R2, H);
MC.Build();
if (!MC.IsDone()) {
Msg::Error("Cone can't be computed from the given parameters");
......
......@@ -48,7 +48,6 @@ class OCC_Internals {
void buildLists();
void removeAllDuplicates(const double &tolerance);
void Cone(const SPoint3 &p1, const SPoint3 &p2, const BooleanOperator &op);
void Box(const SPoint3 &p1, const SPoint3 &p2, const BooleanOperator &op);
void Sphere(const SPoint3 &center, const double &radius, const BooleanOperator &op);
void Cylinder(const SPoint3 &bottom_center, const SVector3 &dir, double R, double H,
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment