From eb8c1d2a9078a365baea327f712185681b697330 Mon Sep 17 00:00:00 2001
From: jean-pierre charras <jp.charras@wanadoo.fr>
Date: Thu, 24 Aug 2023 13:02:10 +0200
Subject: [PATCH] Fix compil issues (and probably a bug). Also display
 calculation time info.

---
 pcbnew/exporters/step/exporter_step.cpp  |  8 ++++++++
 pcbnew/exporters/step/step_pcb_model.cpp | 10 +++++-----
 2 files changed, 13 insertions(+), 5 deletions(-)

diff --git a/pcbnew/exporters/step/exporter_step.cpp b/pcbnew/exporters/step/exporter_step.cpp
index 3f68f451a6..2e04dd1b48 100644
--- a/pcbnew/exporters/step/exporter_step.cpp
+++ b/pcbnew/exporters/step/exporter_step.cpp
@@ -47,6 +47,7 @@
 
 #include <wx/crt.h>
 #include <wx/log.h>
+#include <profile.h>        // To use GetRunningMicroSecs or another profiling utility
 
 #define OCC_VERSION_MIN 0x070500
 
@@ -492,6 +493,9 @@ void EXPORTER_STEP::calculatePcbThickness()
 
 bool EXPORTER_STEP::Export()
 {
+    // Display the export time, for statistics
+    unsigned stats_startExportTime = GetRunningMicroSecs();
+
     // setup opencascade message log
     Message::DefaultMessenger()->RemovePrinters( STANDARD_TYPE( Message_PrinterOStream ) );
     Message::DefaultMessenger()->AddPrinter( new KiCadPrinter( this ) );
@@ -572,5 +576,9 @@ bool EXPORTER_STEP::Export()
         ReportMessage( msg );
     }
 
+    // Display calculation time in seconds
+    double calculation_time = (double)( GetRunningMicroSecs() - stats_startExportTime) / 1e6;
+    ReportMessage( wxString::Format( _( "\nExport time %.3f s\n" ), calculation_time ) );
+
     return true;
 }
diff --git a/pcbnew/exporters/step/step_pcb_model.cpp b/pcbnew/exporters/step/step_pcb_model.cpp
index cdd6ddae16..11f5a45b66 100644
--- a/pcbnew/exporters/step/step_pcb_model.cpp
+++ b/pcbnew/exporters/step/step_pcb_model.cpp
@@ -620,7 +620,7 @@ bool STEP_PCB_MODEL::MakeShapes( std::vector<TopoDS_Shape>& aShapes, const SHAPE
                     std::vector<gp_Pnt>   coords3D( coords.size() );
 
                     // Convert to 3D points
-                    for( int ii = 0; ii < coords.size(); ii++ )
+                    for( size_t ii = 0; ii < coords.size(); ii++ )
                     {
                         coords3D[ii] = gp_Pnt( pcbIUScale.IUTomm( coords[ii].x - aOrigin.x ),
                                                -pcbIUScale.IUTomm( coords[ii].y - aOrigin.y ),
@@ -635,7 +635,7 @@ bool STEP_PCB_MODEL::MakeShapes( std::vector<TopoDS_Shape>& aShapes, const SHAPE
 
                     aMkWire.Add( BRepBuilderAPI_MakeEdge( arcOfCircle ) );
 
-                    if( aMkWire.Error() != BRepBuilderAPI_WireDone )
+                    if( aMkWire.Error() != BRepLib_WireDone  )
                     {
                         ReportMessage( wxT( "failed to add curve\n" ) );
                         return false;
@@ -666,7 +666,7 @@ bool STEP_PCB_MODEL::MakeShapes( std::vector<TopoDS_Shape>& aShapes, const SHAPE
                     BRepBuilderAPI_MakeEdge mkEdge( start, end );
                     aMkWire.Add( mkEdge );
 
-                    if( aMkWire.Error() != BRepBuilderAPI_WireDone )
+                    if( aMkWire.Error() != BRepLib_WireDone  )
                     {
                         ReportMessage( wxT( "failed to add curve\n" ) );
                         return false;
@@ -687,7 +687,7 @@ bool STEP_PCB_MODEL::MakeShapes( std::vector<TopoDS_Shape>& aShapes, const SHAPE
 
         BRepBuilderAPI_MakeFace mkFace;
 
-        for( int contId = 0; contId < polygon.size(); contId++ )
+        for( size_t contId = 0; contId < polygon.size(); contId++ )
         {
             const SHAPE_LINE_CHAIN& contour = polygon[contId];
             BRepLib_MakeWire        mkWire;
@@ -775,7 +775,7 @@ bool STEP_PCB_MODEL::CreatePCB( SHAPE_POLY_SET& aOutline, VECTOR2D aOrigin )
 
         Handle( Bnd_HArray1OfBox ) holeBoxSet = new Bnd_HArray1OfBox( 0, m_cutouts.size() - 1 );
 
-        for( int i = 0; i < m_cutouts.size(); i++ )
+        for( size_t i = 0; i < m_cutouts.size(); i++ )
         {
             Bnd_Box bbox;
             BRepBndLib::Add( m_cutouts[i], bbox );