diff --git a/Geo/GModelIO_OCC.cpp b/Geo/GModelIO_OCC.cpp index 22063715fe6fed1d8bb43ae3a9664c84a8c12b4c..c67cf69e0003a48385efbd24556afd3efc4ecd0f 100644 --- a/Geo/GModelIO_OCC.cpp +++ b/Geo/GModelIO_OCC.cpp @@ -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"); diff --git a/Geo/GModelIO_OCC.h b/Geo/GModelIO_OCC.h index 3a4470ca86b4e478ea6e4af80a006ee3b5903c5d..c66c7863441d8e06ba13ce8583fdf1b0b6adb08a 100644 --- a/Geo/GModelIO_OCC.h +++ b/Geo/GModelIO_OCC.h @@ -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 ¢er, const double &radius, const BooleanOperator &op); void Cylinder(const SPoint3 &bottom_center, const SVector3 &dir, double R, double H,