diff --git a/Common/Context.h b/Common/Context.h index c119ae7339f01069505b34ee80cee01fe1466b8f..da389c2f504194be195f04c21eb9cedc57574471 100644 --- a/Common/Context.h +++ b/Common/Context.h @@ -72,7 +72,7 @@ struct contextGeometryOptions { int extrudeSplinePoints, extrudeReturnLateral; double normals, tangents, scalingFactor; int autoCoherence, highlightOrphans, clip, useTransform; - double tolerance, snap[3], transform[3][3], offset[3]; + double tolerance, toleranceBoolean, snap[3], transform[3][3], offset[3]; int occFixDegenerated, occFixSmallEdges, occFixSmallFaces; int occSewFaces, occConnectFaces, occParallel; double occScaling; diff --git a/Common/DefaultOptions.h b/Common/DefaultOptions.h index ba954a5cc035678418d21e076481a0b056470bcb..8a416b2b20c875a9b1add060a3ace7af27955dac 100644 --- a/Common/DefaultOptions.h +++ b/Common/DefaultOptions.h @@ -919,6 +919,8 @@ StringXNumber GeometryOptions_Number[] = { "Display size of tangent vectors (in pixels)" }, { F|O, "Tolerance" , opt_geometry_tolerance, 1.e-8 , "Geometrical tolerance" }, + { F|O, "ToleranceBoolean" , opt_geometry_tolerance_boolean, 0. , + "Geometrical tolerance for boolean operations" }, { F, "Transform" , opt_geometry_transform , 0. , "Transform model display coordinates (0=no, 1=scale)" }, { F, "TransformXX" , opt_geometry_transform00 , 1. , diff --git a/Common/Options.cpp b/Common/Options.cpp index 80d56719f6771b483b02ac8b62ed005fca741411..183ba74564a050c38ef4ebe6066ce851ab464a1e 100644 --- a/Common/Options.cpp +++ b/Common/Options.cpp @@ -4406,6 +4406,13 @@ double opt_geometry_tolerance(OPT_ARGS_NUM) return CTX::instance()->geom.tolerance; } +double opt_geometry_tolerance_boolean(OPT_ARGS_NUM) +{ + if(action & GMSH_SET) + CTX::instance()->geom.toleranceBoolean = val; + return CTX::instance()->geom.toleranceBoolean; +} + double opt_geometry_normals(OPT_ARGS_NUM) { if(action & GMSH_SET) diff --git a/Common/Options.h b/Common/Options.h index 86a7f0dec7ed376361517180b57c84074d613c33..e193ba597da7b637d226501c3398e252bfa16e89 100644 --- a/Common/Options.h +++ b/Common/Options.h @@ -359,6 +359,7 @@ double opt_geometry_hide_compounds(OPT_ARGS_NUM); double opt_geometry_oriented_physicals(OPT_ARGS_NUM); double opt_geometry_highlight_orphans(OPT_ARGS_NUM); double opt_geometry_tolerance(OPT_ARGS_NUM); +double opt_geometry_tolerance_boolean(OPT_ARGS_NUM); double opt_geometry_normals(OPT_ARGS_NUM); double opt_geometry_tangents(OPT_ARGS_NUM); double opt_geometry_points(OPT_ARGS_NUM); diff --git a/Geo/GModelIO_OCC.cpp b/Geo/GModelIO_OCC.cpp index a658659758491d6afa8a512f9ebdd65211933149..b454fd56eda96f47a6069cc278217e0da0fe625b 100644 --- a/Geo/GModelIO_OCC.cpp +++ b/Geo/GModelIO_OCC.cpp @@ -328,8 +328,10 @@ void OCC_Internals::importShape(const std::string &fileName, else if(split[2] == ".step" || split[2] == ".stp" || split[2] == ".STEP" || split[2] == ".STP"){ STEPControl_Reader reader; - reader.ReadFile(fileName.c_str()); - reader.NbRootsForTransfer(); + if(reader.ReadFile(fileName.c_str()) != IFSelect_RetDone){ + Msg::Error("Could not read file '%s'", fileName.c_str()); + return; + } reader.TransferRoots(); result = reader.OneShape(); } @@ -337,7 +339,6 @@ void OCC_Internals::importShape(const std::string &fileName, Msg::Error("Unknown file type '%s'", fileName.c_str()); return; } - BRepTools::Clean(result); // FIXME: apply healing routine on result? } catch(Standard_Failure &err){ @@ -354,13 +355,28 @@ void OCC_Internals::importShape(const std::string &fileName, // FIXME: if no solids, return faces, etc. } +/* +void OCC_Internals::export(const std::string &fileName) +{ + BRep_Builder b; + TopoDS_Compound c; + b.MakeCompound(c); + for(int i = 1; i <= _vmap.Extent(); i++) b.Add(c, _vmap(i)); + for(int i = 1; i <= _emap.Extent(); i++) b.Add(c, _emap(i)); + for(int i = 1; i <= _wmap.Extent(); i++) b.Add(c, _wmap(i)); + for(int i = 1; i <= _fmap.Extent(); i++) b.Add(c, _fmap(i)); + for(int i = 1; i <= _shmap.Extent(); i++) b.Add(c, _shmap(i)); + for(int i = 1; i <= _somap.Extent(); i++) b.Add(c, _somap(i)); +} +*/ + void OCC_Internals::applyBooleanOperator(int tag, BooleanOperator op, std::vector<int> objectTags[4], std::vector<int> toolTags[4], std::vector<int> outTags[4], bool removeObject, bool removeTool) { - double tolerance = 0.0; // FIXME make this a parameter + double tolerance = CTX::instance()->geom.toleranceBoolean; bool parallel = CTX::instance()->geom.occParallel; if(tag > 0 && _tagSolid.IsBound(tag)){