From 883baf4189ad2ac4ac5e8643332606324fc46590 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stefan=20Br=C3=BCns?= Date: Mon, 8 Mar 2021 02:33:00 +0100 Subject: [PATCH 1/4] Remove occconstruction.cpp from list of library sources Since commit 0c3c3f32d173b3f7edcb40f9f6447fae60f02c05 ("occ build visualization mesh") occgeometry.cpp does not contain any compiled code, and it has not been used at least for 12 years. As the file includes quite some header files removing it from the sources should save some compile time. --- libsrc/occ/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libsrc/occ/CMakeLists.txt b/libsrc/occ/CMakeLists.txt index 9db6271b..ea5a756e 100644 --- a/libsrc/occ/CMakeLists.txt +++ b/libsrc/occ/CMakeLists.txt @@ -2,7 +2,7 @@ add_definitions(-DNGINTERFACE_EXPORTS) add_library(occ ${NG_LIB_TYPE} Partition_Inter2d.cxx Partition_Inter3d.cxx Partition_Loop.cxx Partition_Loop2d.cxx Partition_Loop3d.cxx Partition_Spliter.cxx - occconstruction.cpp occgenmesh.cpp occgeom.cpp occmeshsurf.cpp python_occ.cpp + occgenmesh.cpp occgeom.cpp occmeshsurf.cpp python_occ.cpp ) if(USE_GUI) add_library(occvis ${NG_LIB_TYPE} vsocc.cpp) From 2767672286fa6ece29417eab4f399deb3ec62b3d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stefan=20Br=C3=BCns?= Date: Wed, 10 Mar 2021 00:45:56 +0100 Subject: [PATCH 2/4] Cleanup use of M_PI/PI defines gprim/geom2d.cpp includes mystdlib.h, which already has a fallback define for M_PI. As geomfuncs.cpp also includes mystdlib.h, use M_PI instead of a truncated value. occ/Partition_Loop2d.cxx already gets M_PI from the opencascade headers (~everything includes Standard_Real.hxx, which includes Standard_math.hxx, which sets _USE_MATH_DEFINES for Windows and includes math.h). --- libsrc/gprim/geom2d.cpp | 4 ---- libsrc/gprim/geomfuncs.cpp | 2 +- libsrc/occ/Partition_Loop2d.cxx | 2 -- 3 files changed, 1 insertion(+), 7 deletions(-) diff --git a/libsrc/gprim/geom2d.cpp b/libsrc/gprim/geom2d.cpp index 7d051359..f50131aa 100644 --- a/libsrc/gprim/geom2d.cpp +++ b/libsrc/gprim/geom2d.cpp @@ -3,10 +3,6 @@ #include #include -#ifndef M_PI -#define M_PI 3.14159265358979323846 -#endif - namespace netgen { diff --git a/libsrc/gprim/geomfuncs.cpp b/libsrc/gprim/geomfuncs.cpp index b2ac8382..6608c072 100644 --- a/libsrc/gprim/geomfuncs.cpp +++ b/libsrc/gprim/geomfuncs.cpp @@ -83,7 +83,7 @@ double Det (const Mat<3,3> & m) void EigenValues (const Mat<3,3> & m, Vec<3> & ev) { - const double pi = 3.141592; + const double pi = M_PI; double a, b, c, d; double p, q; double arg; diff --git a/libsrc/occ/Partition_Loop2d.cxx b/libsrc/occ/Partition_Loop2d.cxx index 22740a58..1c3d7957 100644 --- a/libsrc/occ/Partition_Loop2d.cxx +++ b/libsrc/occ/Partition_Loop2d.cxx @@ -52,8 +52,6 @@ #include #include -#define PI 3.14159265358979323846 - //======================================================================= //function : Partition_Loop2d //purpose : From 8abd52a47b6da9d53f25a8171091124ba8cb7d5a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stefan=20Br=C3=BCns?= Date: Wed, 10 Mar 2021 01:06:11 +0100 Subject: [PATCH 3/4] Remove two unused variables --- libsrc/occ/occgenmesh.cpp | 6 ------ 1 file changed, 6 deletions(-) diff --git a/libsrc/occ/occgenmesh.cpp b/libsrc/occ/occgenmesh.cpp index 314d405a..783ba96b 100644 --- a/libsrc/occ/occgenmesh.cpp +++ b/libsrc/occ/occgenmesh.cpp @@ -244,9 +244,6 @@ namespace netgen hvalue[0] = 0; pnt = c->Value(s0); - double olddist = 0; - double dist = 0; - int tmpVal = (int)(DIVIDEEDGESECTIONS); for (int i = 1; i <= tmpVal; i++) @@ -259,9 +256,6 @@ namespace netgen //(*testout) << "mesh.GetH(Point3d(pnt.X(), pnt.Y(), pnt.Z())) " << mesh.GetH(Point3d(pnt.X(), pnt.Y(), pnt.Z())) // << " pnt.Distance(oldpnt) " << pnt.Distance(oldpnt) << endl; - - olddist = dist; - dist = pnt.Distance(oldpnt); } // nsubedges = int(ceil(hvalue[DIVIDEEDGESECTIONS])); From cf4d9eff33486817f001a361f5346b1d11728672 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stefan=20Br=C3=BCns?= Date: Wed, 10 Mar 2021 01:57:16 +0100 Subject: [PATCH 4/4] Modernize code, replace Handle_ with Handle(X) Same like c35297a8fb158be47772cb5fc9cee76ca88ff871 --- libsrc/occ/occgeom.cpp | 36 ++++++++++++++++++------------------ libsrc/occ/occgeom.hpp | 2 +- 2 files changed, 19 insertions(+), 19 deletions(-) diff --git a/libsrc/occ/occgeom.cpp b/libsrc/occ/occgeom.cpp index a3e8ddd3..cc5b9f65 100644 --- a/libsrc/occ/occgeom.cpp +++ b/libsrc/occ/occgeom.cpp @@ -282,7 +282,7 @@ namespace netgen double surfacecont = 0; { - Handle_ShapeBuild_ReShape rebuild = new ShapeBuild_ReShape; + Handle(ShapeBuild_ReShape) rebuild = new ShapeBuild_ReShape; rebuild->Apply(shape); for (exp1.Init (shape, TopAbs_EDGE); exp1.More(); exp1.Next()) { @@ -313,7 +313,7 @@ namespace netgen cout << endl << "- repairing faces" << endl; Handle(ShapeFix_Face) sff; - Handle_ShapeBuild_ReShape rebuild = new ShapeBuild_ReShape; + Handle(ShapeBuild_ReShape) rebuild = new ShapeBuild_ReShape; rebuild->Apply(shape); @@ -370,7 +370,7 @@ namespace netgen { - Handle_ShapeBuild_ReShape rebuild = new ShapeBuild_ReShape; + Handle(ShapeBuild_ReShape) rebuild = new ShapeBuild_ReShape; rebuild->Apply(shape); for (exp1.Init (shape, TopAbs_EDGE); exp1.More(); exp1.Next()) { @@ -387,7 +387,7 @@ namespace netgen cout << endl << "- fixing small edges" << endl; Handle(ShapeFix_Wire) sfw; - Handle_ShapeBuild_ReShape rebuild = new ShapeBuild_ReShape; + Handle(ShapeBuild_ReShape) rebuild = new ShapeBuild_ReShape; rebuild->Apply(shape); @@ -454,7 +454,7 @@ namespace netgen { BuildFMap(); - Handle_ShapeBuild_ReShape rebuild = new ShapeBuild_ReShape; + Handle(ShapeBuild_ReShape) rebuild = new ShapeBuild_ReShape; rebuild->Apply(shape); for (exp1.Init (shape, TopAbs_EDGE); exp1.More(); exp1.Next()) @@ -482,7 +482,7 @@ namespace netgen { - Handle_ShapeBuild_ReShape rebuild = new ShapeBuild_ReShape; + Handle(ShapeBuild_ReShape) rebuild = new ShapeBuild_ReShape; rebuild->Apply(shape); for (exp1.Init (shape, TopAbs_EDGE); exp1.More(); exp1.Next()) { @@ -608,7 +608,7 @@ namespace netgen { - Handle_ShapeBuild_ReShape rebuild = new ShapeBuild_ReShape; + Handle(ShapeBuild_ReShape) rebuild = new ShapeBuild_ReShape; rebuild->Apply(shape); for (exp1.Init (shape, TopAbs_EDGE); exp1.More(); exp1.Next()) { @@ -653,7 +653,7 @@ namespace netgen TopoDS_Solid solid = TopoDS::Solid(exp0.Current()); TopoDS_Solid newsolid = solid; BRepLib::OrientClosedSolid (newsolid); - Handle_ShapeBuild_ReShape rebuild = new ShapeBuild_ReShape; + Handle(ShapeBuild_ReShape) rebuild = new ShapeBuild_ReShape; // rebuild->Apply(shape); rebuild->Replace(solid, newsolid); TopoDS_Shape newshape = rebuild->Apply(shape, TopAbs_COMPSOLID);//, 1); @@ -1076,7 +1076,7 @@ namespace netgen TopoDS_Solid solid = TopoDS::Solid(exp0.Current()); TopoDS_Solid newsolid = solid; BRepLib::OrientClosedSolid (newsolid); - Handle_ShapeBuild_ReShape rebuild = new ShapeBuild_ReShape; + Handle(ShapeBuild_ReShape) rebuild = new ShapeBuild_ReShape; rebuild->Replace(solid, newsolid); TopoDS_Shape newshape = rebuild->Apply(shape, TopAbs_SHAPE, 1); @@ -1408,10 +1408,10 @@ namespace netgen static Timer timer_getnames("LoadOCC-get names"); // Initiate a dummy XCAF Application to handle the STEP XCAF Document - static Handle_XCAFApp_Application dummy_app = XCAFApp_Application::GetApplication(); + static Handle(XCAFApp_Application) dummy_app = XCAFApp_Application::GetApplication(); // Create an XCAF Document to contain the STEP file itself - Handle_TDocStd_Document step_doc; + Handle(TDocStd_Document) step_doc; // Check if a STEP File is already open under this handle, if so, close it to prevent // Segmentation Faults when trying to create a new document @@ -1441,8 +1441,8 @@ namespace netgen timer_transfer.Stop(); // Read in the shape(s) and the colours present in the STEP File - Handle_XCAFDoc_ShapeTool step_shape_contents = XCAFDoc_DocumentTool::ShapeTool(step_doc->Main()); - Handle_XCAFDoc_ColorTool step_colour_contents = XCAFDoc_DocumentTool::ColorTool(step_doc->Main()); + Handle(XCAFDoc_ShapeTool) step_shape_contents = XCAFDoc_DocumentTool::ShapeTool(step_doc->Main()); + Handle(XCAFDoc_ColorTool) step_colour_contents = XCAFDoc_DocumentTool::ColorTool(step_doc->Main()); TDF_LabelSequence step_shapes; step_shape_contents->GetShapes(step_shapes); @@ -1567,10 +1567,10 @@ namespace netgen OCCGeometry *occgeo; occgeo = new OCCGeometry; // Initiate a dummy XCAF Application to handle the IGES XCAF Document - static Handle_XCAFApp_Application dummy_app = XCAFApp_Application::GetApplication(); + static Handle(XCAFApp_Application) dummy_app = XCAFApp_Application::GetApplication(); // Create an XCAF Document to contain the IGES file itself - Handle_TDocStd_Document iges_doc; + Handle(TDocStd_Document) iges_doc; // Check if a IGES File is already open under this handle, if so, close it to prevent // Segmentation Faults when trying to create a new document @@ -1596,8 +1596,8 @@ namespace netgen reader.Transfer(iges_doc); // Read in the shape(s) and the colours present in the IGES File - Handle_XCAFDoc_ShapeTool iges_shape_contents = XCAFDoc_DocumentTool::ShapeTool(iges_doc->Main()); - Handle_XCAFDoc_ColorTool iges_colour_contents = XCAFDoc_DocumentTool::ColorTool(iges_doc->Main()); + Handle(XCAFDoc_ShapeTool) iges_shape_contents = XCAFDoc_DocumentTool::ShapeTool(iges_doc->Main()); + Handle(XCAFDoc_ColorTool) iges_colour_contents = XCAFDoc_DocumentTool::ColorTool(iges_doc->Main()); TDF_LabelSequence iges_shapes; iges_shape_contents->GetShapes(iges_shapes); @@ -1667,7 +1667,7 @@ namespace netgen // Fixed a bug in the OpenCascade XDE Colour handling when // opening BREP Files, since BREP Files have no colour data. // Hence, the face_colours Handle needs to be created as a NULL handle. - occgeo->face_colours = Handle_XCAFDoc_ColorTool(); + occgeo->face_colours = Handle(XCAFDoc_ColorTool)(); occgeo->face_colours.Nullify(); occgeo->changed = 1; occgeo->BuildFMap(); diff --git a/libsrc/occ/occgeom.hpp b/libsrc/occ/occgeom.hpp index a491952f..95853e94 100644 --- a/libsrc/occ/occgeom.hpp +++ b/libsrc/occ/occgeom.hpp @@ -221,7 +221,7 @@ namespace netgen // OpenCascade XDE Support // XCAF Handle to make the face colours available to the rest of // the system - Handle_XCAFDoc_ColorTool face_colours; + Handle(XCAFDoc_ColorTool) face_colours; mutable int changed; mutable NgArray facemeshstatus;