diff --git a/Common/Context.h b/Common/Context.h index 0ccf203e1fc1840a4861a5451692373af9ef530e..36f6da7ba8c22f952ffc367926f73c0058f7d27f 100644 --- a/Common/Context.h +++ b/Common/Context.h @@ -72,6 +72,7 @@ struct contextGeometryOptions { double tolerance, snap[3], transform[3][3], offset[3]; int occFixDegenerated, occFixSmallEdges, occFixSmallFaces; int occSewFaces, occConnectFaces; + double occScaling; int copyMeshingMethod, copyDisplayAttributes, exactExtrusion; int matchGeomAndMesh; int hideCompounds, orientedPhysicals; diff --git a/Common/DefaultOptions.h b/Common/DefaultOptions.h index 5cefb1581eb7c39f5c8c21e401b3cf09388a29c7..6b5396199efd0095cb1efa4b4afacc67b1673b5c 100644 --- a/Common/DefaultOptions.h +++ b/Common/DefaultOptions.h @@ -826,6 +826,8 @@ StringXNumber GeometryOptions_Number[] = { "Sew faces in STEP, IGES and BRep models" }, { F|O, "OCCConnectFaces" , opt_geometry_occ_connect_faces , 0. , "Cut and connect faces in STEP, IGES and BRep models (0=no, 1=internal, 2=Salome)" }, + { F|O, "OCCScaling" , opt_geometry_occ_scaling , -1. , + "Scale STEP, IGES and BRep model by given factor (if > 0)" }, { F, "OffsetX" , opt_geometry_offset0 , 0. , "Model display offset along X-axis (in model coordinates)" }, { F, "OffsetY" , opt_geometry_offset1 , 0. , diff --git a/Common/Options.cpp b/Common/Options.cpp index 709315b6e75f2021b6be13965ec7f4cfcdaacd3e..8b651cf73f2783ecf50c095974b72f8f541f077f 100644 --- a/Common/Options.cpp +++ b/Common/Options.cpp @@ -4603,6 +4603,19 @@ double opt_geometry_occ_connect_faces(OPT_ARGS_NUM) return CTX::instance()->geom.occConnectFaces; } +double opt_geometry_occ_scaling(OPT_ARGS_NUM) +{ + if(action & GMSH_SET) + CTX::instance()->geom.occScaling = val; +#if defined(HAVE_FLTK) + if(FlGui::available() && (action & GMSH_GUI)) { + FlGui::instance()->options->geo.value[20]->value + (CTX::instance()->geom.occScaling); + } +#endif + return CTX::instance()->geom.occScaling; +} + double opt_geometry_old_circle(OPT_ARGS_NUM) { if(action & GMSH_SET) diff --git a/Common/Options.h b/Common/Options.h index 3338b10d3f72e6d1b4c4cccc6a25fba16885c925..0725eac18441baeeda0055b9ce17dfa9f52583bc 100644 --- a/Common/Options.h +++ b/Common/Options.h @@ -366,6 +366,7 @@ double opt_geometry_occ_fix_small_edges(OPT_ARGS_NUM); double opt_geometry_occ_fix_small_faces(OPT_ARGS_NUM); double opt_geometry_occ_sew_faces(OPT_ARGS_NUM); double opt_geometry_occ_connect_faces(OPT_ARGS_NUM); +double opt_geometry_occ_scaling(OPT_ARGS_NUM); double opt_geometry_old_circle(OPT_ARGS_NUM); double opt_geometry_old_newreg(OPT_ARGS_NUM); double opt_geometry_old_ruled_surface(OPT_ARGS_NUM); diff --git a/Fltk/optionWindow.cpp b/Fltk/optionWindow.cpp index 6e9a2293d3070a5cd2e18ff9d367f34cc02744e0..f7b1d11d7d91737273fe7bd023d6dcf1ebbf49f3 100644 --- a/Fltk/optionWindow.cpp +++ b/Fltk/optionWindow.cpp @@ -430,6 +430,7 @@ static void geometry_options_ok_cb(Fl_Widget *w, void *data) opt_geometry_occ_fix_small_faces(0, GMSH_SET, o->geo.butt[12]->value()); opt_geometry_occ_sew_faces(0, GMSH_SET, o->geo.butt[13]->value()); opt_geometry_occ_connect_faces(0, GMSH_SET, o->geo.butt[15]->value()); + opt_geometry_occ_scaling(0, GMSH_SET, o->geo.value[20]->value()); opt_geometry_light_two_side(0, GMSH_SET, o->geo.butt[14]->value()); opt_geometry_hide_compounds(0, GMSH_SET, o->geo.butt[17]->value()); @@ -1957,6 +1958,11 @@ optionWindow::optionWindow(int deltaFontSize) geo.butt[15]->type(FL_TOGGLE_BUTTON); geo.butt[15]->callback(geometry_options_ok_cb); + geo.value[20] = new Fl_Value_Input + (L + 2 * WB, 2 * WB + 9 * BH, IW, BH, "Global model scaling"); + geo.value[20]->align(FL_ALIGN_RIGHT); + geo.value[20]->callback(geometry_options_ok_cb); + #if !defined(HAVE_OCC) b2->deactivate(); geo.butt[16]->deactivate(); @@ -1964,6 +1970,7 @@ optionWindow::optionWindow(int deltaFontSize) geo.butt[12]->deactivate(); geo.butt[13]->deactivate(); geo.butt[15]->deactivate(); + geo.value[20]->deactivate(); #endif o->end(); } diff --git a/Fltk/optionWindow.h b/Fltk/optionWindow.h index 9ea3a6d80dbfbbb39b91e275c16e1e07ac4c0c2f..e5c08ff8543a709077b60408d95a9accce0c1964 100644 --- a/Fltk/optionWindow.h +++ b/Fltk/optionWindow.h @@ -45,7 +45,7 @@ class optionWindow{ struct{ Fl_Group *group; Fl_Check_Button *butt[20]; - Fl_Value_Input *value[20]; + Fl_Value_Input *value[25]; Fl_Button *color[50]; Fl_Choice *choice[20]; } geo; diff --git a/Geo/GModelIO_OCC.cpp b/Geo/GModelIO_OCC.cpp index 083cc34661afc3fad806b68fc4350cf442fa876b..9be34fbfdb277c73a7e35fda583a082868ba0b9b 100644 --- a/Geo/GModelIO_OCC.cpp +++ b/Geo/GModelIO_OCC.cpp @@ -22,6 +22,8 @@ #include "Partition_Spliter.hxx" #endif +#include <BRepBuilderAPI_Transform.hxx> + void addSimpleShapes(TopoDS_Shape theShape, TopTools_ListOfShape &theList); void OCC_Internals::buildLists() @@ -35,7 +37,7 @@ void OCC_Internals::buildLists() addShapeToLists(shape); } -void OCC_Internals::buildShapeFromGModel(GModel* gm) +void OCC_Internals::buildShapeFromGModel(GModel* gm) { somap.Clear(); shmap.Clear(); @@ -46,13 +48,13 @@ void OCC_Internals::buildShapeFromGModel(GModel* gm) for (GModel::riter it = gm->firstRegion(); it != gm->lastRegion() ; ++it){ if ((*it)->getNativeType() == GEntity::OpenCascadeModel){ OCCRegion *occ = static_cast<OCCRegion*> (*it); - if (occ)addShapeToLists (occ->getTopoDS_Shape()); + if(occ) addShapeToLists(occ->getTopoDS_Shape()); } } for (GModel::fiter it = gm->firstFace(); it != gm->lastFace() ; ++it){ if ((*it)->getNativeType() == GEntity::OpenCascadeModel){ OCCFace *occ = static_cast<OCCFace*> (*it); - if(occ)addShapeToLists (occ->getTopoDS_Face ()); + if(occ) addShapeToLists(occ->getTopoDS_Face()); } } BRep_Builder B; @@ -241,8 +243,16 @@ void OCC_Internals::addShapeToLists(TopoDS_Shape _shape) void OCC_Internals::healGeometry(double tolerance, bool fixdegenerated, bool fixsmalledges, bool fixspotstripfaces, - bool sewfaces, bool makesolids, int connect) + bool sewfaces, bool makesolids, int connect, + double scaling) { + if(scaling > 0.){ + Msg::Info("Scaling geometry by factor %g", scaling); + gp_Trsf t; + t.SetScaleFactor(scaling); + BRepBuilderAPI_Transform trsf(shape, t); + shape = trsf.Shape(); + } if(!fixdegenerated && !fixsmalledges && !fixspotstripfaces && !sewfaces && !makesolids && !connect) return; @@ -594,7 +604,8 @@ void OCC_Internals::loadBREP(const char *fn) CTX::instance()->geom.occFixSmallFaces, CTX::instance()->geom.occSewFaces, false, - CTX::instance()->geom.occConnectFaces); + CTX::instance()->geom.occConnectFaces, + CTX::instance()->geom.occScaling); BRepTools::Clean(shape); buildLists(); } @@ -626,7 +637,8 @@ void OCC_Internals::loadSTEP(const char *fn) CTX::instance()->geom.occFixSmallFaces, CTX::instance()->geom.occSewFaces, false, - CTX::instance()->geom.occConnectFaces); + CTX::instance()->geom.occConnectFaces, + CTX::instance()->geom.occScaling); BRepTools::Clean(shape); buildLists(); } @@ -653,7 +665,8 @@ void OCC_Internals::loadIGES(const char *fn) CTX::instance()->geom.occFixSmallFaces, CTX::instance()->geom.occSewFaces, false, - CTX::instance()->geom.occConnectFaces); + CTX::instance()->geom.occConnectFaces, + CTX::instance()->geom.occScaling); BRepTools::Clean(shape); buildLists(); } diff --git a/Geo/GModelIO_OCC.h b/Geo/GModelIO_OCC.h index c69194c9558eece3237fc3197880b4ca0e9505df..fb00ac0ede19f94b0ae9fed8fd72a7372d905983 100644 --- a/Geo/GModelIO_OCC.h +++ b/Geo/GModelIO_OCC.h @@ -32,7 +32,7 @@ class OCC_Internals { void healGeometry(double tolerance, bool fixdegenerated, bool fixsmalledges, bool fixspotstripfaces, bool sewfaces, bool makesolids=false, - int connect=0); + int connect=0, double scaling=0.0); void loadBREP(const char *); void writeBREP(const char *); void loadSTEP(const char *);