From b11d52eda1c007efc9cd98c95d2297c9c01f47e9 Mon Sep 17 00:00:00 2001 From: Mark Roszko Date: Mon, 30 Dec 2019 13:01:06 +0000 Subject: [PATCH] Scope 3d viewer enums Also fix one rogue character in a gerbview file that wasn't proper UTF8. --- 3d-viewer/3d_canvas/cinfo3d_visu.cpp | 15 ++- 3d-viewer/3d_canvas/create_layer_items.cpp | 27 +++-- 3d-viewer/3d_canvas/eda_3d_canvas.cpp | 41 ++++--- 3d-viewer/3d_enums.h | 30 ++--- .../3d_model_viewer/c3d_model_viewer.cpp | 2 +- .../c3d_render_createscene_ogl_legacy.cpp | 39 ++++--- .../c3d_render_ogl_legacy.cpp | 18 +-- .../3d_render_ogl_legacy/c_ogl_3dmodel.cpp | 16 +-- .../accelerators/cbvh_pbrt.cpp | 26 +++-- .../accelerators/cbvh_pbrt.h | 16 ++- .../accelerators/ccontainer2d.cpp | 6 +- .../c3d_render_createscene.cpp | 107 ++++++++---------- .../c3d_render_raytracing.cpp | 2 +- .../3d_rendering/3d_render_raytracing/ray.cpp | 52 ++++----- .../3d_rendering/3d_render_raytracing/ray.h | 30 ++++- .../shapes2D/cfilledcircle2d.cpp | 15 ++- .../shapes2D/citemlayercsg2d.cpp | 19 ++-- .../shapes2D/cobject2d.cpp | 32 +++--- .../3d_render_raytracing/shapes2D/cobject2d.h | 46 ++++---- .../shapes2D/cpolygon2d.cpp | 22 ++-- .../shapes2D/cpolygon4pts2d.cpp | 11 +- .../3d_render_raytracing/shapes2D/cring2d.cpp | 13 ++- .../shapes2D/croundsegment2d.cpp | 17 ++- .../shapes2D/ctriangle2d.cpp | 13 +-- .../shapes3D/cbbox_ray.cpp | 104 ++++++++--------- .../shapes3D/ccylinder.cpp | 6 +- .../shapes3D/cdummyblock.cpp | 2 +- .../shapes3D/clayeritem.cpp | 5 +- .../3d_render_raytracing/shapes3D/cobject.cpp | 27 +++-- .../3d_render_raytracing/shapes3D/cobject.h | 36 +++--- .../3d_render_raytracing/shapes3D/cplane.cpp | 7 +- .../shapes3D/croundseg.cpp | 6 +- .../shapes3D/ctriangle.cpp | 21 ++-- 3d-viewer/3d_rendering/ccamera.cpp | 22 ++-- 3d-viewer/3d_rendering/ccamera.h | 15 ++- 3d-viewer/3d_rendering/cimage.cpp | 76 +++++++------ 3d-viewer/3d_rendering/cimage.h | 87 +++++++------- 3d-viewer/3d_rendering/ctrack_ball.cpp | 10 +- 3d-viewer/3d_viewer/3d_menubar.cpp | 96 +++++++++++----- 3d-viewer/3d_viewer/eda_3d_viewer.cpp | 85 ++++++++------ include/gbr_netlist_metadata.h | 2 +- 41 files changed, 648 insertions(+), 574 deletions(-) diff --git a/3d-viewer/3d_canvas/cinfo3d_visu.cpp b/3d-viewer/3d_canvas/cinfo3d_visu.cpp index 7051626aec..d3996f7651 100644 --- a/3d-viewer/3d_canvas/cinfo3d_visu.cpp +++ b/3d-viewer/3d_canvas/cinfo3d_visu.cpp @@ -53,13 +53,13 @@ CINFO3D_VISU::CINFO3D_VISU() : { wxLogTrace( m_logTrace, wxT( "CINFO3D_VISU::CINFO3D_VISU" ) ); - m_board = NULL; + m_board = NULL; m_3d_model_manager = NULL; - m_3D_grid_type = GRID3D_NONE; + m_3D_grid_type = GRID3D_TYPE::NONE; m_drawFlags.resize( FL_LAST, false ); - m_render_engine = RENDER_ENGINE_OPENGL_LEGACY; - m_material_mode = MATERIAL_MODE_NORMAL; + m_render_engine = RENDER_ENGINE::OPENGL_LEGACY; + m_material_mode = MATERIAL_MODE::NORMAL; m_boardPos = wxPoint(); m_boardSize = wxSize(); @@ -187,8 +187,7 @@ bool CINFO3D_VISU::Is3DLayerEnabled( PCB_LAYER_ID aLayer ) const default: // the layer is an internal copper layer, used the visibility - if( GetFlag( FL_SHOW_BOARD_BODY ) && - (m_render_engine == RENDER_ENGINE_OPENGL_LEGACY) ) + if( GetFlag( FL_SHOW_BOARD_BODY ) && ( m_render_engine == RENDER_ENGINE::OPENGL_LEGACY ) ) { // Do not render internal layers if it is overlap with the board // (on OpenGL render) @@ -487,9 +486,9 @@ void CINFO3D_VISU::CameraSetType( CAMERA_TYPE aCameraType ) { switch( aCameraType ) { - case CAMERA_TRACKBALL: + case CAMERA_TYPE::TRACKBALL: m_currentCamera = m_trackBallCamera; - break; + break; default: wxLogMessage( wxT( "CINFO3D_VISU::CameraSetType() error: unknown camera type %d" ), diff --git a/3d-viewer/3d_canvas/create_layer_items.cpp b/3d-viewer/3d_canvas/create_layer_items.cpp index ac98a6f9d2..4ed2cd6442 100644 --- a/3d-viewer/3d_canvas/create_layer_items.cpp +++ b/3d-viewer/3d_canvas/create_layer_items.cpp @@ -223,10 +223,10 @@ void CINFO3D_VISU::createLayers( REPORTER *aStatusTextReporter ) CBVHCONTAINER2D *layerContainer = new CBVHCONTAINER2D; m_layers_container2D[curr_layer_id] = layerContainer; - if( GetFlag( FL_RENDER_OPENGL_COPPER_THICKNESS ) && - (m_render_engine == RENDER_ENGINE_OPENGL_LEGACY) ) + if( GetFlag( FL_RENDER_OPENGL_COPPER_THICKNESS ) + && ( m_render_engine == RENDER_ENGINE::OPENGL_LEGACY ) ) { - SHAPE_POLY_SET *layerPoly = new SHAPE_POLY_SET; + SHAPE_POLY_SET* layerPoly = new SHAPE_POLY_SET; m_layers_poly[curr_layer_id] = layerPoly; } } @@ -454,8 +454,8 @@ void CINFO3D_VISU::createLayers( REPORTER *aStatusTextReporter ) // Creates outline contours of the tracks and add it to the poly of the layer // ///////////////////////////////////////////////////////////////////////// - if( GetFlag( FL_RENDER_OPENGL_COPPER_THICKNESS ) && - (m_render_engine == RENDER_ENGINE_OPENGL_LEGACY) ) + if( GetFlag( FL_RENDER_OPENGL_COPPER_THICKNESS ) + && ( m_render_engine == RENDER_ENGINE::OPENGL_LEGACY ) ) { for( unsigned int lIdx = 0; lIdx < layer_id.size(); ++lIdx ) { @@ -587,8 +587,8 @@ void CINFO3D_VISU::createLayers( REPORTER *aStatusTextReporter ) // Add modules PADs poly contourns // ///////////////////////////////////////////////////////////////////////// - if( GetFlag( FL_RENDER_OPENGL_COPPER_THICKNESS ) && - (m_render_engine == RENDER_ENGINE_OPENGL_LEGACY) ) + if( GetFlag( FL_RENDER_OPENGL_COPPER_THICKNESS ) + && ( m_render_engine == RENDER_ENGINE::OPENGL_LEGACY ) ) { for( unsigned int lIdx = 0; lIdx < layer_id.size(); ++lIdx ) { @@ -683,8 +683,8 @@ void CINFO3D_VISU::createLayers( REPORTER *aStatusTextReporter ) // Add graphic item on copper layers to poly contourns // ///////////////////////////////////////////////////////////////////////// - if( GetFlag( FL_RENDER_OPENGL_COPPER_THICKNESS ) && - (m_render_engine == RENDER_ENGINE_OPENGL_LEGACY) ) + if( GetFlag( FL_RENDER_OPENGL_COPPER_THICKNESS ) + && ( m_render_engine == RENDER_ENGINE::OPENGL_LEGACY ) ) { for( unsigned int lIdx = 0; lIdx < layer_id.size(); ++lIdx ) { @@ -771,9 +771,8 @@ void CINFO3D_VISU::createLayers( REPORTER *aStatusTextReporter ) start_Time = GetRunningMicroSecs(); #endif - if( GetFlag( FL_ZONE ) && - GetFlag( FL_RENDER_OPENGL_COPPER_THICKNESS ) && - (m_render_engine == RENDER_ENGINE_OPENGL_LEGACY) ) + if( GetFlag( FL_ZONE ) && GetFlag( FL_RENDER_OPENGL_COPPER_THICKNESS ) + && ( m_render_engine == RENDER_ENGINE::OPENGL_LEGACY ) ) { // ADD COPPER ZONES for( int ii = 0; ii < m_board->GetAreaCount(); ++ii ) @@ -801,8 +800,8 @@ void CINFO3D_VISU::createLayers( REPORTER *aStatusTextReporter ) if( aStatusTextReporter ) aStatusTextReporter->Report( _( "Simplifying copper layers polygons" ) ); - if( GetFlag( FL_RENDER_OPENGL_COPPER_THICKNESS ) && - (m_render_engine == RENDER_ENGINE_OPENGL_LEGACY) ) + if( GetFlag( FL_RENDER_OPENGL_COPPER_THICKNESS ) + && ( m_render_engine == RENDER_ENGINE::OPENGL_LEGACY ) ) { std::atomic nextItem( 0 ); std::atomic threadsFinished( 0 ); diff --git a/3d-viewer/3d_canvas/eda_3d_canvas.cpp b/3d-viewer/3d_canvas/eda_3d_canvas.cpp index c4de0e67c9..153f957f2d 100644 --- a/3d-viewer/3d_canvas/eda_3d_canvas.cpp +++ b/3d-viewer/3d_canvas/eda_3d_canvas.cpp @@ -387,11 +387,11 @@ void EDA_3D_CANVAS::OnPaint( wxPaintEvent &event ) { m_3d_render = m_3d_render_ogl_legacy; m_render_raytracing_was_requested = false; - m_settings.RenderEngineSet( RENDER_ENGINE_OPENGL_LEGACY ); + m_settings.RenderEngineSet( RENDER_ENGINE::OPENGL_LEGACY ); } // Check if a raytacing was requested and need to switch to raytracing mode - if( m_settings.RenderEngineGet() == RENDER_ENGINE_OPENGL_LEGACY ) + if( m_settings.RenderEngineGet() == RENDER_ENGINE::OPENGL_LEGACY ) { const bool was_camera_changed = m_settings.CameraGet().ParametersChanged(); @@ -899,7 +899,7 @@ void EDA_3D_CANVAS::move_pivot_based_on_cur_mouse_position() // Test it with the board bounding box if( m_settings.GetBBox3DU().Intersect( mouseRay, &hit_t ) ) { - m_settings.CameraGet().SetInterpolateMode( INTERPOLATION_BEZIER ); + m_settings.CameraGet().SetInterpolateMode( CAMERA_INTERPOLATION::BEZIER ); m_settings.CameraGet().SetT0_and_T1_current_T(); m_settings.CameraGet().SetLookAtPos_T1( mouseRay.at( hit_t ) ); m_settings.CameraGet().ResetXYpos_T1(); @@ -925,35 +925,35 @@ bool EDA_3D_CANVAS::SetView3D( int aKeycode ) return true; case WXK_LEFT: - m_settings.CameraGet().SetInterpolateMode( INTERPOLATION_LINEAR ); + m_settings.CameraGet().SetInterpolateMode( CAMERA_INTERPOLATION::LINEAR ); m_settings.CameraGet().SetT0_and_T1_current_T(); m_settings.CameraGet().Pan_T1( SFVEC3F( -delta_move, 0.0f, 0.0f ) ); request_start_moving_camera( arrow_moving_time_speed, false ); return true; case WXK_RIGHT: - m_settings.CameraGet().SetInterpolateMode( INTERPOLATION_LINEAR ); + m_settings.CameraGet().SetInterpolateMode( CAMERA_INTERPOLATION::LINEAR ); m_settings.CameraGet().SetT0_and_T1_current_T(); m_settings.CameraGet().Pan_T1( SFVEC3F( +delta_move, 0.0f, 0.0f ) ); request_start_moving_camera( arrow_moving_time_speed, false ); return true; case WXK_UP: - m_settings.CameraGet().SetInterpolateMode( INTERPOLATION_LINEAR ); + m_settings.CameraGet().SetInterpolateMode( CAMERA_INTERPOLATION::LINEAR ); m_settings.CameraGet().SetT0_and_T1_current_T(); m_settings.CameraGet().Pan_T1( SFVEC3F( 0.0f, +delta_move, 0.0f ) ); request_start_moving_camera( arrow_moving_time_speed, false ); return true; case WXK_DOWN: - m_settings.CameraGet().SetInterpolateMode( INTERPOLATION_LINEAR ); + m_settings.CameraGet().SetInterpolateMode( CAMERA_INTERPOLATION::LINEAR ); m_settings.CameraGet().SetT0_and_T1_current_T(); m_settings.CameraGet().Pan_T1( SFVEC3F( 0.0f, -delta_move, 0.0f ) ); request_start_moving_camera( arrow_moving_time_speed, false ); return true; case WXK_HOME: - m_settings.CameraGet().SetInterpolateMode( INTERPOLATION_BEZIER ); + m_settings.CameraGet().SetInterpolateMode( CAMERA_INTERPOLATION::BEZIER ); m_settings.CameraGet().SetT0_and_T1_current_T(); m_settings.CameraGet().Reset_T1(); request_start_moving_camera( glm::min( glm::max( m_settings.CameraGet().ZoomGet(), 1/1.26f ), 1.26f ) ); @@ -963,7 +963,7 @@ bool EDA_3D_CANVAS::SetView3D( int aKeycode ) break; case WXK_TAB: - m_settings.CameraGet().SetInterpolateMode( INTERPOLATION_EASING_IN_OUT ); + m_settings.CameraGet().SetInterpolateMode( CAMERA_INTERPOLATION::EASING_IN_OUT ); m_settings.CameraGet().SetT0_and_T1_current_T(); m_settings.CameraGet().RotateZ_T1( glm::radians( 45.0f ) ); request_start_moving_camera(); @@ -971,7 +971,7 @@ bool EDA_3D_CANVAS::SetView3D( int aKeycode ) break; case WXK_F1: - m_settings.CameraGet().SetInterpolateMode( INTERPOLATION_BEZIER ); + m_settings.CameraGet().SetInterpolateMode( CAMERA_INTERPOLATION::BEZIER ); m_settings.CameraGet().SetT0_and_T1_current_T(); if( m_settings.CameraGet().Zoom_T1( 1.26f ) ) // 3 steps per doubling @@ -980,7 +980,7 @@ bool EDA_3D_CANVAS::SetView3D( int aKeycode ) return true; case WXK_F2: - m_settings.CameraGet().SetInterpolateMode( INTERPOLATION_BEZIER ); + m_settings.CameraGet().SetInterpolateMode( CAMERA_INTERPOLATION::BEZIER ); m_settings.CameraGet().SetT0_and_T1_current_T(); if( m_settings.CameraGet().Zoom_T1( 1/1.26f ) ) // 3 steps per halving @@ -1018,14 +1018,14 @@ bool EDA_3D_CANVAS::SetView3D( int aKeycode ) case 'r': case 'R': - m_settings.CameraGet().SetInterpolateMode( INTERPOLATION_BEZIER ); + m_settings.CameraGet().SetInterpolateMode( CAMERA_INTERPOLATION::BEZIER ); m_settings.CameraGet().SetT0_and_T1_current_T(); m_settings.CameraGet().Reset_T1(); request_start_moving_camera( glm::min( glm::max( m_settings.CameraGet().ZoomGet(), 0.5f ), 1.125f ) ); return true; case 'X': - m_settings.CameraGet().SetInterpolateMode( INTERPOLATION_BEZIER ); + m_settings.CameraGet().SetInterpolateMode( CAMERA_INTERPOLATION::BEZIER ); m_settings.CameraGet().SetT0_and_T1_current_T(); m_settings.CameraGet().Reset_T1(); m_settings.CameraGet().RotateZ_T1( glm::radians( -90.0f ) ); @@ -1034,7 +1034,7 @@ bool EDA_3D_CANVAS::SetView3D( int aKeycode ) return true; case GR_KB_SHIFT + 'X': - m_settings.CameraGet().SetInterpolateMode( INTERPOLATION_BEZIER ); + m_settings.CameraGet().SetInterpolateMode( CAMERA_INTERPOLATION::BEZIER ); m_settings.CameraGet().SetT0_and_T1_current_T(); m_settings.CameraGet().Reset_T1(); m_settings.CameraGet().RotateZ_T1( glm::radians( 90.0f ) ); @@ -1043,7 +1043,7 @@ bool EDA_3D_CANVAS::SetView3D( int aKeycode ) return true; case 'Y': - m_settings.CameraGet().SetInterpolateMode( INTERPOLATION_BEZIER ); + m_settings.CameraGet().SetInterpolateMode( CAMERA_INTERPOLATION::BEZIER ); m_settings.CameraGet().SetT0_and_T1_current_T(); m_settings.CameraGet().Reset_T1(); m_settings.CameraGet().RotateX_T1( glm::radians( -90.0f ) ); @@ -1051,7 +1051,7 @@ bool EDA_3D_CANVAS::SetView3D( int aKeycode ) return true; case GR_KB_SHIFT + 'Y': - m_settings.CameraGet().SetInterpolateMode( INTERPOLATION_BEZIER ); + m_settings.CameraGet().SetInterpolateMode( CAMERA_INTERPOLATION::BEZIER ); m_settings.CameraGet().SetT0_and_T1_current_T(); m_settings.CameraGet().Reset_T1(); m_settings.CameraGet().RotateX_T1( glm::radians( -90.0f ) ); @@ -1060,7 +1060,7 @@ bool EDA_3D_CANVAS::SetView3D( int aKeycode ) return true; case 'Z': - m_settings.CameraGet().SetInterpolateMode( INTERPOLATION_BEZIER ); + m_settings.CameraGet().SetInterpolateMode( CAMERA_INTERPOLATION::BEZIER ); m_settings.CameraGet().SetT0_and_T1_current_T(); m_settings.CameraGet().Reset_T1(); request_start_moving_camera( @@ -1068,7 +1068,7 @@ bool EDA_3D_CANVAS::SetView3D( int aKeycode ) return true; case GR_KB_SHIFT + 'Z': - m_settings.CameraGet().SetInterpolateMode( INTERPOLATION_BEZIER ); + m_settings.CameraGet().SetInterpolateMode( CAMERA_INTERPOLATION::BEZIER ); m_settings.CameraGet().SetT0_and_T1_current_T(); m_settings.CameraGet().Reset_T1(); m_settings.CameraGet().RotateY_T1( glm::radians( 180.0f ) ); @@ -1093,14 +1093,13 @@ bool EDA_3D_CANVAS::SetView3D( int aKeycode ) void EDA_3D_CANVAS::RenderEngineChanged() { - switch( m_settings.RenderEngineGet() ) { - case RENDER_ENGINE_OPENGL_LEGACY: + case RENDER_ENGINE::OPENGL_LEGACY: m_3d_render = m_3d_render_ogl_legacy; break; - case RENDER_ENGINE_RAYTRACING: + case RENDER_ENGINE::RAYTRACING: m_3d_render = m_3d_render_raytracing; break; diff --git a/3d-viewer/3d_enums.h b/3d-viewer/3d_enums.h index 7ff5d1403c..4e1b874e1b 100644 --- a/3d-viewer/3d_enums.h +++ b/3d-viewer/3d_enums.h @@ -61,37 +61,37 @@ enum DISPLAY3D_FLG { /// Camera types -enum CAMERA_TYPE +enum class CAMERA_TYPE { - CAMERA_TRACKBALL + TRACKBALL }; /// Grid types -enum GRID3D_TYPE +enum class GRID3D_TYPE { - GRID3D_NONE, - GRID3D_1MM, - GRID3D_2P5MM, - GRID3D_5MM, - GRID3D_10MM + NONE, + GRID_1MM, + GRID_2P5MM, + GRID_5MM, + GRID_10MM }; /// Render engine mode -enum RENDER_ENGINE +enum class RENDER_ENGINE { - RENDER_ENGINE_OPENGL_LEGACY, - RENDER_ENGINE_RAYTRACING, + OPENGL_LEGACY, + RAYTRACING, }; /// Render 3d model shape materials mode -enum MATERIAL_MODE +enum class MATERIAL_MODE { - MATERIAL_MODE_NORMAL, ///< Use all material properties from model file - MATERIAL_MODE_DIFFUSE_ONLY, ///< Use only diffuse material properties - MATERIAL_MODE_CAD_MODE ///< Use a gray shading based on diffuse material + NORMAL, ///< Use all material properties from model file + DIFFUSE_ONLY, ///< Use only diffuse material properties + CAD_MODE ///< Use a gray shading based on diffuse material }; #endif // _3D_ENUMS_H_ diff --git a/3d-viewer/3d_model_viewer/c3d_model_viewer.cpp b/3d-viewer/3d_model_viewer/c3d_model_viewer.cpp index e00a772f73..d577b84b6f 100644 --- a/3d-viewer/3d_model_viewer/c3d_model_viewer.cpp +++ b/3d-viewer/3d_model_viewer/c3d_model_viewer.cpp @@ -264,7 +264,7 @@ void C3D_MODEL_VIEWER::OnPaint( wxPaintEvent &event ) wxLogTrace( m_logTrace, wxT( "C3D_MODEL_VIEWER::OnPaint m_reload_is_needed" ) ); m_reload_is_needed = false; - m_ogl_3dmodel = new C_OGL_3DMODEL( *m_3d_model, MATERIAL_MODE_NORMAL ); + m_ogl_3dmodel = new C_OGL_3DMODEL( *m_3d_model, MATERIAL_MODE::NORMAL ); // It convert a model as it was a board, so get the max size dimension of the board // and compute the conversion scale diff --git a/3d-viewer/3d_rendering/3d_render_ogl_legacy/c3d_render_createscene_ogl_legacy.cpp b/3d-viewer/3d_rendering/3d_render_ogl_legacy/c3d_render_createscene_ogl_legacy.cpp index 6f3fdb764f..6df3a2b399 100644 --- a/3d-viewer/3d_rendering/3d_render_ogl_legacy/c3d_render_createscene_ogl_legacy.cpp +++ b/3d-viewer/3d_rendering/3d_render_ogl_legacy/c3d_render_createscene_ogl_legacy.cpp @@ -285,27 +285,26 @@ CLAYERS_OGL_DISP_LISTS *C3D_RENDER_OGL_LEGACY::generate_holes_display_list( itemOnLayer != aListHolesObject2d.end(); ++itemOnLayer ) { - const COBJECT2D *object2d_A = static_cast(*itemOnLayer); + const COBJECT2D* object2d_A = static_cast( *itemOnLayer ); - wxASSERT( (object2d_A->GetObjectType() == OBJ2D_FILLED_CIRCLE) || - (object2d_A->GetObjectType() == OBJ2D_ROUNDSEG) ); + wxASSERT( ( object2d_A->GetObjectType() == OBJECT2D_TYPE::FILLED_CIRCLE ) + || ( object2d_A->GetObjectType() == OBJECT2D_TYPE::ROUNDSEG ) ); switch( object2d_A->GetObjectType() ) { - case OBJ2D_FILLED_CIRCLE: - add_object_to_triangle_layer( (const CFILLEDCIRCLE2D *)object2d_A, - layerTriangles, - aZtop, aZbot ); + case OBJECT2D_TYPE::FILLED_CIRCLE: + add_object_to_triangle_layer( static_cast( object2d_A ), + layerTriangles, aZtop, aZbot ); break; - case OBJ2D_ROUNDSEG: - add_object_to_triangle_layer( (const CROUNDSEGMENT2D *) object2d_A, - layerTriangles, - aZtop, aZbot ); + case OBJECT2D_TYPE::ROUNDSEG: + add_object_to_triangle_layer( static_cast( object2d_A ), + layerTriangles, aZtop, aZbot ); break; - default: - wxFAIL_MSG("C3D_RENDER_OGL_LEGACY::generate_holes_display_list: Object type is not implemented"); + default: + wxFAIL_MSG( + "C3D_RENDER_OGL_LEGACY::generate_holes_display_list: Object type is not implemented" ); break; } } @@ -394,7 +393,7 @@ void C3D_RENDER_OGL_LEGACY::reload( REPORTER *aStatusTextReporter ) { const COBJECT2D *object2d_A = static_cast(*itemOnLayer); - wxASSERT( object2d_A->GetObjectType() == OBJ2D_TRIANGLE ); + wxASSERT( object2d_A->GetObjectType() == OBJECT2D_TYPE::TRIANGLE ); const CTRIANGLE2D *tri = (const CTRIANGLE2D *)object2d_A; @@ -563,27 +562,27 @@ void C3D_RENDER_OGL_LEGACY::reload( REPORTER *aStatusTextReporter ) switch( object2d_A->GetObjectType() ) { - case OBJ2D_FILLED_CIRCLE: + case OBJECT2D_TYPE::FILLED_CIRCLE: add_object_to_triangle_layer( (const CFILLEDCIRCLE2D *)object2d_A, layerTriangles, layer_z_top, layer_z_bot ); break; - case OBJ2D_POLYGON4PT: + case OBJECT2D_TYPE::POLYGON4PT: add_object_to_triangle_layer( (const CPOLYGON4PTS2D *)object2d_A, layerTriangles, layer_z_top, layer_z_bot ); break; - case OBJ2D_RING: + case OBJECT2D_TYPE::RING: add_object_to_triangle_layer( (const CRING2D *)object2d_A, layerTriangles, layer_z_top, layer_z_bot ); break; - case OBJ2D_TRIANGLE: + case OBJECT2D_TYPE::TRIANGLE: add_object_to_triangle_layer( (const CTRIANGLE2D *)object2d_A, layerTriangles, layer_z_top, layer_z_bot ); break; - case OBJ2D_ROUNDSEG: + case OBJECT2D_TYPE::ROUNDSEG: add_object_to_triangle_layer( (const CROUNDSEGMENT2D *) object2d_A, layerTriangles, layer_z_top, layer_z_bot ); break; @@ -856,7 +855,7 @@ void C3D_RENDER_OGL_LEGACY::generate_3D_Vias_and_Pads() { const COBJECT2D *object2d_A = static_cast(*itemOnLayer); - wxASSERT( object2d_A->GetObjectType() == OBJ2D_TRIANGLE ); + wxASSERT( object2d_A->GetObjectType() == OBJECT2D_TYPE::TRIANGLE ); const CTRIANGLE2D *tri = (const CTRIANGLE2D *)object2d_A; diff --git a/3d-viewer/3d_rendering/3d_render_ogl_legacy/c3d_render_ogl_legacy.cpp b/3d-viewer/3d_rendering/3d_render_ogl_legacy/c3d_render_ogl_legacy.cpp index 7d60da45af..fba9f634fe 100644 --- a/3d-viewer/3d_rendering/3d_render_ogl_legacy/c3d_render_ogl_legacy.cpp +++ b/3d-viewer/3d_rendering/3d_render_ogl_legacy/c3d_render_ogl_legacy.cpp @@ -65,7 +65,7 @@ C3D_RENDER_OGL_LEGACY::C3D_RENDER_OGL_LEGACY( CINFO3D_VISU &aSettings ) : m_ogl_circle_texture = 0; m_ogl_disp_list_grid = 0; - m_last_grid_type = GRID3D_NONE; + m_last_grid_type = GRID3D_TYPE::NONE; m_3dmodel_map.clear(); } @@ -752,7 +752,7 @@ bool C3D_RENDER_OGL_LEGACY::Redraw( bool aIsMoving, // Render Grid // ///////////////////////////////////////////////////////////////////////// - if( m_settings.GridGet() != GRID3D_NONE ) + if( m_settings.GridGet() != GRID3D_TYPE::NONE ) { glDisable( GL_LIGHTING ); @@ -802,7 +802,7 @@ bool C3D_RENDER_OGL_LEGACY::initializeOpenGL() CIMAGE *circleImage_Copy = new CIMAGE( *circleImage ); - circleImage->EfxFilter( circleImage_Copy, FILTER_BLUR_3X3 ); + circleImage->EfxFilter( circleImage_Copy, IMAGE_FILTER::BLUR_3X3 ); m_ogl_circle_texture = OGL_LoadTexture( *circleImage ); @@ -1108,7 +1108,7 @@ void C3D_RENDER_OGL_LEGACY::generate_new_3DGrid( GRID3D_TYPE aGridType ) m_ogl_disp_list_grid = 0; - if( aGridType == GRID3D_NONE ) + if( aGridType == GRID3D_TYPE::NONE ) return; m_ogl_disp_list_grid = glGenLists( 1 ); @@ -1136,18 +1136,18 @@ void C3D_RENDER_OGL_LEGACY::generate_new_3DGrid( GRID3D_TYPE aGridType ) switch( aGridType ) { default: - case GRID3D_NONE: + case GRID3D_TYPE::NONE: return; - case GRID3D_1MM: + case GRID3D_TYPE::GRID_1MM: griSizeMM = 1.0; break; - case GRID3D_2P5MM: + case GRID3D_TYPE::GRID_2P5MM: griSizeMM = 2.5; break; - case GRID3D_5MM: + case GRID3D_TYPE::GRID_5MM: griSizeMM = 5.0; break; - case GRID3D_10MM: + case GRID3D_TYPE::GRID_10MM: griSizeMM = 10.0; break; } diff --git a/3d-viewer/3d_rendering/3d_render_ogl_legacy/c_ogl_3dmodel.cpp b/3d-viewer/3d_rendering/3d_render_ogl_legacy/c_ogl_3dmodel.cpp index 66a07b55d7..5eb2f9f07c 100644 --- a/3d-viewer/3d_rendering/3d_render_ogl_legacy/c_ogl_3dmodel.cpp +++ b/3d-viewer/3d_rendering/3d_render_ogl_legacy/c_ogl_3dmodel.cpp @@ -113,8 +113,8 @@ C_OGL_3DMODEL::C_OGL_3DMODEL( const S3DMODEL &a3DModel, if( mesh.m_MaterialIdx < a3DModel.m_MaterialsSize ) transparency = a3DModel.m_Materials[mesh.m_MaterialIdx].m_Transparency; - if( (transparency > FLT_EPSILON) && - (aMaterialMode == MATERIAL_MODE_NORMAL) ) + if( ( transparency > FLT_EPSILON ) + && ( aMaterialMode == MATERIAL_MODE::NORMAL ) ) { // Create a new array of RGBA colors pColorRGBA = new SFVEC4F[mesh.m_VertexSize]; @@ -131,12 +131,12 @@ C_OGL_3DMODEL::C_OGL_3DMODEL( const S3DMODEL &a3DModel, { switch( aMaterialMode ) { - case MATERIAL_MODE_NORMAL: - case MATERIAL_MODE_DIFFUSE_ONLY: + case MATERIAL_MODE::NORMAL: + case MATERIAL_MODE::DIFFUSE_ONLY: // load the original RGB color array glColorPointer( 3, GL_FLOAT, 0, mesh.m_Color ); break; - case MATERIAL_MODE_CAD_MODE: + case MATERIAL_MODE::CAD_MODE: // Create a new array of RGBA colors pColorRGBA = new SFVEC4F[mesh.m_VertexSize]; @@ -185,14 +185,14 @@ C_OGL_3DMODEL::C_OGL_3DMODEL( const S3DMODEL &a3DModel, { switch( aMaterialMode ) { - case MATERIAL_MODE_NORMAL: + case MATERIAL_MODE::NORMAL: OGL_SetMaterial( a3DModel.m_Materials[mesh.m_MaterialIdx] ); break; - case MATERIAL_MODE_DIFFUSE_ONLY: + case MATERIAL_MODE::DIFFUSE_ONLY: OGL_SetDiffuseOnlyMaterial( a3DModel.m_Materials[mesh.m_MaterialIdx].m_Diffuse ); break; - case MATERIAL_MODE_CAD_MODE: + case MATERIAL_MODE::CAD_MODE: OGL_SetDiffuseOnlyMaterial( MaterialDiffuseToColorCAD( a3DModel.m_Materials[mesh.m_MaterialIdx].m_Diffuse ) ); diff --git a/3d-viewer/3d_rendering/3d_render_raytracing/accelerators/cbvh_pbrt.cpp b/3d-viewer/3d_rendering/3d_render_raytracing/accelerators/cbvh_pbrt.cpp index 7c821be31a..319689bf3a 100644 --- a/3d-viewer/3d_rendering/3d_render_raytracing/accelerators/cbvh_pbrt.cpp +++ b/3d-viewer/3d_rendering/3d_render_raytracing/accelerators/cbvh_pbrt.cpp @@ -275,7 +275,7 @@ CBVH_PBRT::CBVH_PBRT( const CGENERICCONTAINER &aObjectContainer, BVHBuildNode *root; - if( m_splitMethod == SPLIT_HLBVH ) + if( m_splitMethod == SPLITMETHOD::HLBVH ) root = HLBVHBuild( primitiveInfo, &totalNodes, orderedPrims); else root = recursiveBuild( primitiveInfo, 0, m_primitives.size(), @@ -314,10 +314,18 @@ CBVH_PBRT::CBVH_PBRT( const CGENERICCONTAINER &aObjectContainer, switch( m_splitMethod ) { - case SPLIT_MIDDLE: printf( "using SPLIT_MIDDLE\n" ); break; - case SPLIT_EQUALCOUNTS: printf( "using SPLIT_EQUALCOUNTS\n" ); break; - case SPLIT_SAH: printf( "using SPLIT_SAH\n" ); break; - case SPLIT_HLBVH: printf( "using SPLIT_HLBVH\n" ); break; + case SPLITMETHOD::MIDDLE: + printf( "using SPLITMETHOD::MIDDLE\n" ); + break; + case SPLITMETHOD::EQUALCOUNTS: + printf( "using SPLITMETHOD::EQUALCOUNTS\n" ); + break; + case SPLITMETHOD::SAH: + printf( "using SPLITMETHOD::SAH\n" ); + break; + case SPLITMETHOD::HLBVH: + printf( "using SPLITMETHOD::HLBVH\n" ); + break; } printf( " BVH created with %d nodes (%.2f MB)\n", @@ -533,7 +541,7 @@ BVHBuildNode *CBVH_PBRT::recursiveBuild ( std::vector &primiti // Partition primitives based on _splitMethod_ switch( m_splitMethod ) { - case SPLIT_MIDDLE: + case SPLITMETHOD::MIDDLE: { // Partition primitives through node's midpoint float pmid = centroidBounds.GetCenter( dim ); @@ -549,11 +557,11 @@ BVHBuildNode *CBVH_PBRT::recursiveBuild ( std::vector &primiti if( (mid != start) && (mid != end) ) // for lots of prims with large overlapping bounding boxes, this // may fail to partition; in that case don't break and fall through - // to SPLIT_EQUAL_COUNTS + // to SPLITMETHOD::EQUAL_COUNTS break; } - case SPLIT_EQUALCOUNTS: + case SPLITMETHOD::EQUALCOUNTS: { // Partition primitives into equally-sized subsets mid = (start + end) / 2; @@ -566,7 +574,7 @@ BVHBuildNode *CBVH_PBRT::recursiveBuild ( std::vector &primiti break; } - case SPLIT_SAH: + case SPLITMETHOD::SAH: default: { // Partition primitives using approximate SAH diff --git a/3d-viewer/3d_rendering/3d_render_raytracing/accelerators/cbvh_pbrt.h b/3d-viewer/3d_rendering/3d_render_raytracing/accelerators/cbvh_pbrt.h index dc739189d1..e0d40c389b 100644 --- a/3d-viewer/3d_rendering/3d_render_raytracing/accelerators/cbvh_pbrt.h +++ b/3d-viewer/3d_rendering/3d_render_raytracing/accelerators/cbvh_pbrt.h @@ -98,22 +98,20 @@ struct LinearBVHNode }; -enum SPLITMETHOD +enum class SPLITMETHOD { - SPLIT_MIDDLE, - SPLIT_EQUALCOUNTS, - SPLIT_SAH, - SPLIT_HLBVH + MIDDLE, + EQUALCOUNTS, + SAH, + HLBVH }; class CBVH_PBRT : public CGENERICACCELERATOR { - public: - CBVH_PBRT( const CGENERICCONTAINER &aObjectContainer, - int aMaxPrimsInNode = 4, - SPLITMETHOD aSplitMethod = SPLIT_SAH ); + CBVH_PBRT( const CGENERICCONTAINER& aObjectContainer, int aMaxPrimsInNode = 4, + SPLITMETHOD aSplitMethod = SPLITMETHOD::SAH ); ~CBVH_PBRT(); diff --git a/3d-viewer/3d_rendering/3d_render_raytracing/accelerators/ccontainer2d.cpp b/3d-viewer/3d_rendering/3d_render_raytracing/accelerators/ccontainer2d.cpp index eef660b802..fbd253aed6 100644 --- a/3d-viewer/3d_rendering/3d_render_raytracing/accelerators/ccontainer2d.cpp +++ b/3d-viewer/3d_rendering/3d_render_raytracing/accelerators/ccontainer2d.cpp @@ -74,7 +74,7 @@ CGENERICCONTAINER2D::~CGENERICCONTAINER2D() // CCONTAINER2D // ///////////////////////////////////////////////////////////////////////////// -CCONTAINER2D::CCONTAINER2D() : CGENERICCONTAINER2D( OBJ2D_CONTAINER ) +CCONTAINER2D::CCONTAINER2D() : CGENERICCONTAINER2D( OBJECT2D_TYPE::CONTAINER ) { } @@ -123,7 +123,7 @@ bool CCONTAINER2D::Intersect( const RAYSEG2D &aSegRay, float *aOutT, SFVEC2F *aN INTERSECTION_RESULT CCONTAINER2D::IsBBoxInside( const CBBOX2D &aBBox ) const { - return INTR_MISSES; + return INTERSECTION_RESULT::MISSES; } @@ -160,7 +160,7 @@ void CCONTAINER2D::GetListObjectsIntersects( const CBBOX2D & aBBox, // CBVHCONTAINER2D // ///////////////////////////////////////////////////////////////////////////// -CBVHCONTAINER2D::CBVHCONTAINER2D() : CGENERICCONTAINER2D( OBJ2D_BVHCONTAINER ) +CBVHCONTAINER2D::CBVHCONTAINER2D() : CGENERICCONTAINER2D( OBJECT2D_TYPE::BVHCONTAINER ) { m_isInitialized = false; m_bbox.Reset(); diff --git a/3d-viewer/3d_rendering/3d_render_raytracing/c3d_render_createscene.cpp b/3d-viewer/3d_rendering/3d_render_raytracing/c3d_render_createscene.cpp index 97ab97ab91..e3c75c7d42 100644 --- a/3d-viewer/3d_rendering/3d_render_raytracing/c3d_render_createscene.cpp +++ b/3d-viewer/3d_rendering/3d_render_raytracing/c3d_render_createscene.cpp @@ -176,72 +176,61 @@ void C3D_RENDER_RAYTRACING::setupMaterials() * @param aZMin * @param aZMax */ -void C3D_RENDER_RAYTRACING::create_3d_object_from( CCONTAINER &aDstContainer, - const COBJECT2D *aObject2D, - float aZMin, float aZMax, - const CMATERIAL *aMaterial, - const SFVEC3F &aObjColor ) +void C3D_RENDER_RAYTRACING::create_3d_object_from( CCONTAINER& aDstContainer, + const COBJECT2D* aObject2D, float aZMin, float aZMax, const CMATERIAL* aMaterial, + const SFVEC3F& aObjColor ) { switch( aObject2D->GetObjectType() ) { - case OBJ2D_DUMMYBLOCK: - { - m_stats_converted_dummy_to_plane++; + case OBJECT2D_TYPE::DUMMYBLOCK: + { + m_stats_converted_dummy_to_plane++; #if 1 - CXYPLANE *objPtr; - objPtr = new CXYPLANE( CBBOX ( SFVEC3F( aObject2D->GetBBox().Min().x, - aObject2D->GetBBox().Min().y, - aZMin ), - SFVEC3F( aObject2D->GetBBox().Max().x, - aObject2D->GetBBox().Max().y, - aZMin ) ) ); - objPtr->SetMaterial( aMaterial ); - objPtr->SetColor( ConvertSRGBToLinear( aObjColor ) ); - aDstContainer.Add( objPtr ); + CXYPLANE* objPtr; + objPtr = new CXYPLANE( CBBOX( + SFVEC3F( aObject2D->GetBBox().Min().x, aObject2D->GetBBox().Min().y, aZMin ), + SFVEC3F( aObject2D->GetBBox().Max().x, aObject2D->GetBBox().Max().y, aZMin ) ) ); + objPtr->SetMaterial( aMaterial ); + objPtr->SetColor( ConvertSRGBToLinear( aObjColor ) ); + aDstContainer.Add( objPtr ); - objPtr = new CXYPLANE( CBBOX ( SFVEC3F( aObject2D->GetBBox().Min().x, - aObject2D->GetBBox().Min().y, - aZMax ), - SFVEC3F( aObject2D->GetBBox().Max().x, - aObject2D->GetBBox().Max().y, - aZMax ) ) ); - objPtr->SetMaterial( aMaterial ); - objPtr->SetColor( ConvertSRGBToLinear( aObjColor ) ); - aDstContainer.Add( objPtr ); + objPtr = new CXYPLANE( CBBOX( + SFVEC3F( aObject2D->GetBBox().Min().x, aObject2D->GetBBox().Min().y, aZMax ), + SFVEC3F( aObject2D->GetBBox().Max().x, aObject2D->GetBBox().Max().y, aZMax ) ) ); + objPtr->SetMaterial( aMaterial ); + objPtr->SetColor( ConvertSRGBToLinear( aObjColor ) ); + aDstContainer.Add( objPtr ); #else - objPtr = new CDUMMYBLOCK( CBBOX ( SFVEC3F( aObject2D->GetBBox().Min().x, - aObject2D->GetBBox().Min().y, - aZMin ), - SFVEC3F( aObject2D->GetBBox().Max().x, - aObject2D->GetBBox().Max().y, - aZMax ) ) ); - objPtr->SetMaterial( aMaterial ); - aDstContainer.Add( objPtr ); + objPtr = new CDUMMYBLOCK( CBBOX( + SFVEC3F( aObject2D->GetBBox().Min().x, aObject2D->GetBBox().Min().y, aZMin ), + SFVEC3F( aObject2D->GetBBox().Max().x, aObject2D->GetBBox().Max().y, aZMax ) ) ); + objPtr->SetMaterial( aMaterial ); + aDstContainer.Add( objPtr ); #endif - } - break; + } + break; - case OBJ2D_ROUNDSEG: - { - m_stats_converted_roundsegment2d_to_roundsegment++; + case OBJECT2D_TYPE::ROUNDSEG: + { + m_stats_converted_roundsegment2d_to_roundsegment++; - const CROUNDSEGMENT2D *aRoundSeg2D = static_cast( aObject2D ); - CROUNDSEG *objPtr = new CROUNDSEG( *aRoundSeg2D, aZMin, aZMax ); - objPtr->SetMaterial( aMaterial ); - objPtr->SetColor( ConvertSRGBToLinear( aObjColor ) ); - aDstContainer.Add( objPtr ); - } - break; + const CROUNDSEGMENT2D* aRoundSeg2D = static_cast( aObject2D ); + CROUNDSEG* objPtr = new CROUNDSEG( *aRoundSeg2D, aZMin, aZMax ); + objPtr->SetMaterial( aMaterial ); + objPtr->SetColor( ConvertSRGBToLinear( aObjColor ) ); + aDstContainer.Add( objPtr ); + } + break; - default: - { - CLAYERITEM *objPtr = new CLAYERITEM( aObject2D, aZMin, aZMax ); - objPtr->SetMaterial( aMaterial ); - objPtr->SetColor( ConvertSRGBToLinear( aObjColor ) ); - aDstContainer.Add( objPtr ); - } - break; + default: + { + CLAYERITEM* objPtr = new CLAYERITEM( aObject2D, aZMin, aZMax ); + objPtr->SetMaterial( aMaterial ); + objPtr->SetColor( ConvertSRGBToLinear( aObjColor ) ); + aDstContainer.Add( objPtr ); + } + break; } } @@ -405,7 +394,7 @@ void C3D_RENDER_RAYTRACING::reload( REPORTER *aStatusTextReporter ) switch( hole2d->GetObjectType() ) { - case OBJ2D_FILLED_CIRCLE: + case OBJECT2D_TYPE::FILLED_CIRCLE: { const float radius = hole2d->GetBBox().GetExtent().x * 0.5f * 0.999f; @@ -1332,7 +1321,7 @@ void C3D_RENDER_RAYTRACING::add_3D_models( const S3DMODEL *a3DModel, imat < a3DModel->m_MaterialsSize; ++imat ) { - if( m_settings.MaterialModeGet() == MATERIAL_MODE_NORMAL ) + if( m_settings.MaterialModeGet() == MATERIAL_MODE::NORMAL ) { const SMATERIAL &material = a3DModel->m_Materials[imat]; @@ -1511,14 +1500,14 @@ void C3D_RENDER_RAYTRACING::add_3D_models( const S3DMODEL *a3DModel, const SFVEC3F diffuseColor = a3DModel->m_Materials[mesh.m_MaterialIdx].m_Diffuse; - if( m_settings.MaterialModeGet() == MATERIAL_MODE_CAD_MODE ) + if( m_settings.MaterialModeGet() == MATERIAL_MODE::CAD_MODE ) newTriangle->SetColor( ConvertSRGBToLinear( MaterialDiffuseToColorCAD( diffuseColor ) ) ); else newTriangle->SetColor( ConvertSRGBToLinear( diffuseColor ) ); } else { - if( m_settings.MaterialModeGet() == MATERIAL_MODE_CAD_MODE ) + if( m_settings.MaterialModeGet() == MATERIAL_MODE::CAD_MODE ) newTriangle->SetColor( ConvertSRGBToLinear( MaterialDiffuseToColorCAD( mesh.m_Color[idx0] ) ), ConvertSRGBToLinear( MaterialDiffuseToColorCAD( mesh.m_Color[idx1] ) ), ConvertSRGBToLinear( MaterialDiffuseToColorCAD( mesh.m_Color[idx2] ) ) ); diff --git a/3d-viewer/3d_rendering/3d_render_raytracing/c3d_render_raytracing.cpp b/3d-viewer/3d_rendering/3d_render_raytracing/c3d_render_raytracing.cpp index ecdda56466..e2d362f60a 100644 --- a/3d-viewer/3d_rendering/3d_render_raytracing/c3d_render_raytracing.cpp +++ b/3d-viewer/3d_rendering/3d_render_raytracing/c3d_render_raytracing.cpp @@ -308,7 +308,7 @@ void C3D_RENDER_RAYTRACING::render( GLubyte *ptrPBO , REPORTER *aStatusTextRepor if( m_camera_light ) m_camera_light->SetDirection( -m_settings.CameraGet().GetDir() ); - if( m_settings.RenderEngineGet() == RENDER_ENGINE_OPENGL_LEGACY ) + if( m_settings.RenderEngineGet() == RENDER_ENGINE::OPENGL_LEGACY ) { // Set all pixels of PBO transparent (Alpha to 0) // This way it will draw the full buffer but only shows the updated ( diff --git a/3d-viewer/3d_rendering/3d_render_raytracing/ray.cpp b/3d-viewer/3d_rendering/3d_render_raytracing/ray.cpp index 554a73f923..60f8cf1689 100644 --- a/3d-viewer/3d_rendering/3d_render_raytracing/ray.cpp +++ b/3d-viewer/3d_rendering/3d_render_raytracing/ray.cpp @@ -86,34 +86,34 @@ void RAY::Init( const SFVEC3F& o, const SFVEC3F& d ) { if( m_Dir.z < 0 ) { - m_Classification = MMM; + m_Classification = RAY_CLASSIFICATION::MMM; } else if( m_Dir.z > 0 ){ - m_Classification = MMP; + m_Classification = RAY_CLASSIFICATION::MMP; } else//( m_Dir.z >= 0 ) { - m_Classification = MMO; + m_Classification = RAY_CLASSIFICATION::MMO; } } else//( m_Dir.y >= 0 ) { if( m_Dir.z < 0 ) { - m_Classification = MPM; + m_Classification = RAY_CLASSIFICATION::MPM; if( m_Dir.y == 0 ) - m_Classification = MOM; + m_Classification = RAY_CLASSIFICATION::MOM; } else//( m_Dir.z >= 0 ) { if( ( m_Dir.y == 0 ) && ( m_Dir.z == 0 ) ) - m_Classification = MOO; + m_Classification = RAY_CLASSIFICATION::MOO; else if( m_Dir.z == 0 ) - m_Classification = MPO; + m_Classification = RAY_CLASSIFICATION::MPO; else if( m_Dir.y == 0 ) - m_Classification = MOP; + m_Classification = RAY_CLASSIFICATION::MOP; else - m_Classification = MPP; + m_Classification = RAY_CLASSIFICATION::MPP; } } } @@ -123,20 +123,20 @@ void RAY::Init( const SFVEC3F& o, const SFVEC3F& d ) { if( m_Dir.z < 0 ) { - m_Classification = PMM; + m_Classification = RAY_CLASSIFICATION::PMM; if( m_Dir.x == 0 ) - m_Classification = OMM; + m_Classification = RAY_CLASSIFICATION::OMM; } else//( m_Dir.z >= 0 ) { if( ( m_Dir.x == 0 ) && ( m_Dir.z == 0 ) ) - m_Classification = OMO; + m_Classification = RAY_CLASSIFICATION::OMO; else if( m_Dir.z == 0 ) - m_Classification = PMO; + m_Classification = RAY_CLASSIFICATION::PMO; else if( m_Dir.x == 0 ) - m_Classification = OMP; + m_Classification = RAY_CLASSIFICATION::OMP; else - m_Classification = PMP; + m_Classification = RAY_CLASSIFICATION::PMP; } } else//( m_Dir.y >= 0 ) @@ -144,35 +144,35 @@ void RAY::Init( const SFVEC3F& o, const SFVEC3F& d ) if( m_Dir.z < 0 ) { if( ( m_Dir.x == 0 ) && ( m_Dir.y == 0 ) ) - m_Classification = OOM; + m_Classification = RAY_CLASSIFICATION::OOM; else if( m_Dir.x == 0 ) - m_Classification = OPM; + m_Classification = RAY_CLASSIFICATION::OPM; else if( m_Dir.y == 0 ) - m_Classification = POM; + m_Classification = RAY_CLASSIFICATION::POM; else - m_Classification = PPM; + m_Classification = RAY_CLASSIFICATION::PPM; } else//( m_Dir.z > 0 ) { if( m_Dir.x == 0 ) { if( m_Dir.y == 0 ) - m_Classification = OOP; + m_Classification = RAY_CLASSIFICATION::OOP; else if( m_Dir.z == 0 ) - m_Classification = OPO; + m_Classification = RAY_CLASSIFICATION::OPO; else - m_Classification = OPP; + m_Classification = RAY_CLASSIFICATION::OPP; } else { if( ( m_Dir.y == 0 ) && ( m_Dir.z == 0 ) ) - m_Classification = POO; + m_Classification = RAY_CLASSIFICATION::POO; else if( m_Dir.y == 0 ) - m_Classification = POP; + m_Classification = RAY_CLASSIFICATION::POP; else if( m_Dir.z == 0 ) - m_Classification = PPO; + m_Classification = RAY_CLASSIFICATION::PPO; else - m_Classification = PPP; + m_Classification = RAY_CLASSIFICATION::PPP; } } } diff --git a/3d-viewer/3d_rendering/3d_render_raytracing/ray.h b/3d-viewer/3d_rendering/3d_render_raytracing/ray.h index d20685e0bd..1f319e015c 100644 --- a/3d-viewer/3d_rendering/3d_render_raytracing/ray.h +++ b/3d-viewer/3d_rendering/3d_render_raytracing/ray.h @@ -33,10 +33,34 @@ #include -enum RAY_CLASSIFICATION +enum class RAY_CLASSIFICATION { - MMM, MMP, MPM, MPP, PMM, PMP, PPM, PPP, POO, MOO, OPO, OMO, OOP, OOM, OMM, - OMP,OPM,OPP,MOM,MOP,POM,POP,MMO,MPO,PMO,PPO + MMM, + MMP, + MPM, + MPP, + PMM, + PMP, + PPM, + PPP, + POO, + MOO, + OPO, + OMO, + OOP, + OOM, + OMM, + OMP, + OPM, + OPP, + MOM, + MOP, + POM, + POP, + MMO, + MPO, + PMO, + PPO }; diff --git a/3d-viewer/3d_rendering/3d_render_raytracing/shapes2D/cfilledcircle2d.cpp b/3d-viewer/3d_rendering/3d_render_raytracing/shapes2D/cfilledcircle2d.cpp index f5adbb4b80..d88ea72b6a 100644 --- a/3d-viewer/3d_rendering/3d_render_raytracing/shapes2D/cfilledcircle2d.cpp +++ b/3d-viewer/3d_rendering/3d_render_raytracing/shapes2D/cfilledcircle2d.cpp @@ -31,10 +31,9 @@ #include -CFILLEDCIRCLE2D::CFILLEDCIRCLE2D( const SFVEC2F &aCenter, - float aRadius, - const BOARD_ITEM &aBoardItem ) : - COBJECT2D( OBJ2D_FILLED_CIRCLE, aBoardItem ) +CFILLEDCIRCLE2D::CFILLEDCIRCLE2D( + const SFVEC2F& aCenter, float aRadius, const BOARD_ITEM& aBoardItem ) + : COBJECT2D( OBJECT2D_TYPE::FILLED_CIRCLE, aBoardItem ) { wxASSERT( aRadius > 0.0f ); // If that happens, it should be handled before create this circle @@ -125,7 +124,7 @@ bool CFILLEDCIRCLE2D::Intersect( const RAYSEG2D &aSegRay, INTERSECTION_RESULT CFILLEDCIRCLE2D::IsBBoxInside( const CBBOX2D &aBBox ) const { if( !m_bbox.Intersects( aBBox ) ) - return INTR_MISSES; + return INTERSECTION_RESULT::MISSES; SFVEC2F v[4]; @@ -153,16 +152,16 @@ INTERSECTION_RESULT CFILLEDCIRCLE2D::IsBBoxInside( const CBBOX2D &aBBox ) const isInside[1] && isInside[2] && isInside[3] ) - return INTR_FULL_INSIDE; + return INTERSECTION_RESULT::FULL_INSIDE; // Check if any point is inside the circle if( isInside[0] || isInside[1] || isInside[2] || isInside[3] ) - return INTR_INTERSECTS; + return INTERSECTION_RESULT::INTERSECTS; - return INTR_MISSES; + return INTERSECTION_RESULT::MISSES; } diff --git a/3d-viewer/3d_rendering/3d_render_raytracing/shapes2D/citemlayercsg2d.cpp b/3d-viewer/3d_rendering/3d_render_raytracing/shapes2D/citemlayercsg2d.cpp index b419c6e0cc..1f78886b6a 100644 --- a/3d-viewer/3d_rendering/3d_render_raytracing/shapes2D/citemlayercsg2d.cpp +++ b/3d-viewer/3d_rendering/3d_render_raytracing/shapes2D/citemlayercsg2d.cpp @@ -31,14 +31,13 @@ #include "3d_fastmath.h" #include -CITEMLAYERCSG2D::CITEMLAYERCSG2D( const COBJECT2D *aObjectA, - std::vector *aObjectB, - const COBJECT2D *aObjectC, - const BOARD_ITEM &aBoardItem ): - COBJECT2D( OBJ2D_CSG, aBoardItem ), - m_objectA(aObjectA), - m_objectB(aObjectB), - m_objectC(aObjectC) +CITEMLAYERCSG2D::CITEMLAYERCSG2D( const COBJECT2D* aObjectA, + std::vector* aObjectB, const COBJECT2D* aObjectC, + const BOARD_ITEM& aBoardItem ) + : COBJECT2D( OBJECT2D_TYPE::CSG, aBoardItem ), + m_objectA( aObjectA ), + m_objectB( aObjectB ), + m_objectC( aObjectC ) { wxASSERT( aObjectA ); @@ -85,7 +84,7 @@ bool CITEMLAYERCSG2D::Intersect( const RAYSEG2D &aSegRay, wxASSERT( aOutT ); wxASSERT( aNormalOut ); - if( m_objectA->GetObjectType() == OBJ2D_DUMMYBLOCK ) + if( m_objectA->GetObjectType() == OBJECT2D_TYPE::DUMMYBLOCK ) return false; float currentRayDist; @@ -187,7 +186,7 @@ INTERSECTION_RESULT CITEMLAYERCSG2D::IsBBoxInside( const CBBOX2D &aBBox ) const // !TODO: - return INTR_MISSES; + return INTERSECTION_RESULT::MISSES; } diff --git a/3d-viewer/3d_rendering/3d_render_raytracing/shapes2D/cobject2d.cpp b/3d-viewer/3d_rendering/3d_render_raytracing/shapes2D/cobject2d.cpp index 391a02e9ee..65a8ccfe86 100644 --- a/3d-viewer/3d_rendering/3d_render_raytracing/shapes2D/cobject2d.cpp +++ b/3d-viewer/3d_rendering/3d_render_raytracing/shapes2D/cobject2d.cpp @@ -42,27 +42,33 @@ COBJECT2D::COBJECT2D( OBJECT2D_TYPE aObjType, const BOARD_ITEM &aBoardItem ) } -static const char *OBJECT2D_STR[OBJ2D_MAX] = +/* + * Lookup table for OBJECT2D_TYPE printed names + */ +// clang-format off +const std::map objectTypeNames { - "OBJ2D_FILLED_CIRCLE", - "OBJ2D_CSG", - "OBJ2D_POLYGON", - "OBJ2D_DUMMYBLOCK", - "OBJ2D_POLYGON4PT", - "OBJ2D_RING", - "OBJ2D_ROUNDSEG", - "OBJ2D_TRIANGLE", - "OBJ2D_CONTAINER", - "OBJ2D_BVHCONTAINER" + { OBJECT2D_TYPE::FILLED_CIRCLE, "OBJECT2D_TYPE::FILLED_CIRCLE" }, + { OBJECT2D_TYPE::CSG, "OBJECT2D_TYPE::CSG" }, + { OBJECT2D_TYPE::POLYGON, "OBJECT2D_TYPE::POLYGON" }, + { OBJECT2D_TYPE::DUMMYBLOCK, "OBJECT2D_TYPE::DUMMYBLOCK" }, + { OBJECT2D_TYPE::POLYGON4PT, "OBJECT2D_TYPE::POLYGON4PT" }, + { OBJECT2D_TYPE::RING, "OBJECT2D_TYPE::RING" }, + { OBJECT2D_TYPE::ROUNDSEG, "OBJECT2D_TYPE::ROUNDSEG" }, + { OBJECT2D_TYPE::TRIANGLE, "OBJECT2D_TYPE::TRIANGLE" }, + { OBJECT2D_TYPE::CONTAINER, "OBJECT2D_TYPE::CONTAINER" }, + { OBJECT2D_TYPE::BVHCONTAINER, "OBJECT2D_TYPE::BVHCONTAINER" }, }; +// clang-format on void COBJECT2D_STATS::PrintStats() { printf( "OBJ2D Statistics:\n" ); - for( unsigned int i = 0; i < OBJ2D_MAX; ++i ) + for( auto& objectType : objectTypeNames ) { - printf( " %20s %u\n", OBJECT2D_STR[i], m_counter[i] ); + printf( " %20s %u\n", objectType.second, + m_counter[static_cast( objectType.first )] ); } } diff --git a/3d-viewer/3d_rendering/3d_render_raytracing/shapes2D/cobject2d.h b/3d-viewer/3d_rendering/3d_render_raytracing/shapes2D/cobject2d.h index a33762d621..d823eaf4a2 100644 --- a/3d-viewer/3d_rendering/3d_render_raytracing/shapes2D/cobject2d.h +++ b/3d-viewer/3d_rendering/3d_render_raytracing/shapes2D/cobject2d.h @@ -35,27 +35,27 @@ #include -enum INTERSECTION_RESULT +enum class INTERSECTION_RESULT { - INTR_MISSES, - INTR_INTERSECTS, - INTR_FULL_INSIDE + MISSES, + INTERSECTS, + FULL_INSIDE }; -enum OBJECT2D_TYPE +enum class OBJECT2D_TYPE { - OBJ2D_FILLED_CIRCLE, - OBJ2D_CSG, - OBJ2D_POLYGON, - OBJ2D_DUMMYBLOCK, - OBJ2D_POLYGON4PT, - OBJ2D_RING, - OBJ2D_ROUNDSEG, - OBJ2D_TRIANGLE, - OBJ2D_CONTAINER, - OBJ2D_BVHCONTAINER, - OBJ2D_MAX + FILLED_CIRCLE, + CSG, + POLYGON, + DUMMYBLOCK, + POLYGON4PT, + RING, + ROUNDSEG, + TRIANGLE, + CONTAINER, + BVHCONTAINER, + MAX }; @@ -132,14 +132,20 @@ public: class COBJECT2D_STATS { public: - void ResetStats() { memset( m_counter, 0, sizeof( unsigned int ) * OBJ2D_MAX ); } + void ResetStats() + { + memset( m_counter, 0, sizeof( unsigned int ) * static_cast( OBJECT2D_TYPE::MAX ) ); + } unsigned int GetCountOf( OBJECT2D_TYPE aObjType ) const { - return m_counter[aObjType]; + return m_counter[static_cast( aObjType )]; } - void AddOne( OBJECT2D_TYPE aObjType ) { m_counter[aObjType]++; } + void AddOne( OBJECT2D_TYPE aObjType ) + { + m_counter[static_cast( aObjType )]++; + } void PrintStats(); @@ -158,7 +164,7 @@ private: ~COBJECT2D_STATS(){} private: - unsigned int m_counter[OBJ2D_MAX]; + unsigned int m_counter[static_cast( OBJECT2D_TYPE::MAX )]; static COBJECT2D_STATS *s_instance; }; diff --git a/3d-viewer/3d_rendering/3d_render_raytracing/shapes2D/cpolygon2d.cpp b/3d-viewer/3d_rendering/3d_render_raytracing/shapes2D/cpolygon2d.cpp index 62b6d8f599..e8eb797b87 100644 --- a/3d-viewer/3d_rendering/3d_render_raytracing/shapes2D/cpolygon2d.cpp +++ b/3d-viewer/3d_rendering/3d_render_raytracing/shapes2D/cpolygon2d.cpp @@ -70,10 +70,9 @@ static bool polygon_IsPointInside( const SEGMENTS &aSegments, const SFVEC2F &aPo } -CPOLYGONBLOCK2D::CPOLYGONBLOCK2D( const SEGMENTS_WIDTH_NORMALS &aOpenSegmentList, - const OUTERS_AND_HOLES &aOuter_and_holes, - const BOARD_ITEM &aBoardItem ) : - COBJECT2D( OBJ2D_POLYGON, aBoardItem ) +CPOLYGONBLOCK2D::CPOLYGONBLOCK2D( const SEGMENTS_WIDTH_NORMALS& aOpenSegmentList, + const OUTERS_AND_HOLES& aOuter_and_holes, const BOARD_ITEM& aBoardItem ) + : COBJECT2D( OBJECT2D_TYPE::POLYGON, aBoardItem ) { m_open_segments.resize( aOpenSegmentList.size() ); @@ -190,7 +189,7 @@ bool CPOLYGONBLOCK2D::Intersect( const RAYSEG2D &aSegRay, INTERSECTION_RESULT CPOLYGONBLOCK2D::IsBBoxInside( const CBBOX2D &aBBox ) const { - return INTR_MISSES; + return INTERSECTION_RESULT::MISSES; } @@ -221,9 +220,9 @@ bool CPOLYGONBLOCK2D::IsPointInside( const SFVEC2F &aPoint ) const // CDUMMYBLOCK2D // ///////////////////////////////////////////////////////////////////////////// -CDUMMYBLOCK2D::CDUMMYBLOCK2D( const SFVEC2F &aPbMin, const SFVEC2F &aPbMax, - const BOARD_ITEM &aBoardItem ) : - COBJECT2D( OBJ2D_DUMMYBLOCK, aBoardItem ) +CDUMMYBLOCK2D::CDUMMYBLOCK2D( + const SFVEC2F& aPbMin, const SFVEC2F& aPbMax, const BOARD_ITEM& aBoardItem ) + : COBJECT2D( OBJECT2D_TYPE::DUMMYBLOCK, aBoardItem ) { m_bbox.Set( aPbMin, aPbMax ); m_bbox.ScaleNextUp(); @@ -231,9 +230,8 @@ CDUMMYBLOCK2D::CDUMMYBLOCK2D( const SFVEC2F &aPbMin, const SFVEC2F &aPbMax, } -CDUMMYBLOCK2D::CDUMMYBLOCK2D( const CBBOX2D &aBBox, - const BOARD_ITEM &aBoardItem ) : - COBJECT2D( OBJ2D_DUMMYBLOCK, aBoardItem ) +CDUMMYBLOCK2D::CDUMMYBLOCK2D( const CBBOX2D& aBBox, const BOARD_ITEM& aBoardItem ) + : COBJECT2D( OBJECT2D_TYPE::DUMMYBLOCK, aBoardItem ) { m_bbox.Set( aBBox ); m_bbox.ScaleNextUp(); @@ -267,7 +265,7 @@ bool CDUMMYBLOCK2D::Intersect( const RAYSEG2D &aSegRay, INTERSECTION_RESULT CDUMMYBLOCK2D::IsBBoxInside( const CBBOX2D &aBBox ) const { //!TODO: - return INTR_MISSES; + return INTERSECTION_RESULT::MISSES; } diff --git a/3d-viewer/3d_rendering/3d_render_raytracing/shapes2D/cpolygon4pts2d.cpp b/3d-viewer/3d_rendering/3d_render_raytracing/shapes2D/cpolygon4pts2d.cpp index 65885f059e..e4565ff044 100644 --- a/3d-viewer/3d_rendering/3d_render_raytracing/shapes2D/cpolygon4pts2d.cpp +++ b/3d-viewer/3d_rendering/3d_render_raytracing/shapes2D/cpolygon4pts2d.cpp @@ -31,12 +31,9 @@ #include -CPOLYGON4PTS2D::CPOLYGON4PTS2D( const SFVEC2F &v1, - const SFVEC2F &v2, - const SFVEC2F &v3, - const SFVEC2F &v4, - const BOARD_ITEM &aBoardItem ) : - COBJECT2D( OBJ2D_POLYGON4PT, aBoardItem ) +CPOLYGON4PTS2D::CPOLYGON4PTS2D( const SFVEC2F& v1, const SFVEC2F& v2, const SFVEC2F& v3, + const SFVEC2F& v4, const BOARD_ITEM& aBoardItem ) + : COBJECT2D( OBJECT2D_TYPE::POLYGON4PT, aBoardItem ) {/* if( (v1.x > v2.x) || (v1.y < v2.y) ) { @@ -177,7 +174,7 @@ INTERSECTION_RESULT CPOLYGON4PTS2D::IsBBoxInside( const CBBOX2D &aBBox ) const { // !TODO: - return INTR_MISSES; + return INTERSECTION_RESULT::MISSES; } diff --git a/3d-viewer/3d_rendering/3d_render_raytracing/shapes2D/cring2d.cpp b/3d-viewer/3d_rendering/3d_render_raytracing/shapes2D/cring2d.cpp index eab040e7c1..49de4d3694 100644 --- a/3d-viewer/3d_rendering/3d_render_raytracing/shapes2D/cring2d.cpp +++ b/3d-viewer/3d_rendering/3d_render_raytracing/shapes2D/cring2d.cpp @@ -32,8 +32,9 @@ #include -CRING2D::CRING2D( const SFVEC2F &aCenter, float aInnerRadius, float aOuterRadius, - const BOARD_ITEM &aBoardItem ) : COBJECT2D( OBJ2D_RING, aBoardItem ) +CRING2D::CRING2D( const SFVEC2F& aCenter, float aInnerRadius, float aOuterRadius, + const BOARD_ITEM& aBoardItem ) + : COBJECT2D( OBJECT2D_TYPE::RING, aBoardItem ) { wxASSERT( aInnerRadius < aOuterRadius ); @@ -141,7 +142,7 @@ INTERSECTION_RESULT CRING2D::IsBBoxInside( const CBBOX2D &aBBox ) const { /* if( !m_bbox.Overlaps( aBBox ) ) - return INTR_MISSES; + return INTERSECTION_RESULT::MISSES; SFVEC2F v[4]; @@ -169,16 +170,16 @@ INTERSECTION_RESULT CRING2D::IsBBoxInside( const CBBOX2D &aBBox ) const isInside[1] && isInside[2] && isInside[3] ) - return INTR_FULL_INSIDE; + return INTERSECTION_RESULT::FULL_INSIDE; // Check if any point is inside the circle if( isInside[0] || isInside[1] || isInside[2] || isInside[3] ) - return INTR_INTERSECTS; + return INTERSECTION_RESULT::INTERSECTS; */ - return INTR_MISSES; + return INTERSECTION_RESULT::MISSES; } diff --git a/3d-viewer/3d_rendering/3d_render_raytracing/shapes2D/croundsegment2d.cpp b/3d-viewer/3d_rendering/3d_render_raytracing/shapes2D/croundsegment2d.cpp index bb1de266c7..54fc45e7a5 100644 --- a/3d-viewer/3d_rendering/3d_render_raytracing/shapes2D/croundsegment2d.cpp +++ b/3d-viewer/3d_rendering/3d_render_raytracing/shapes2D/croundsegment2d.cpp @@ -31,12 +31,9 @@ #include -CROUNDSEGMENT2D::CROUNDSEGMENT2D( const SFVEC2F &aStart, - const SFVEC2F &aEnd, - float aWidth, - const BOARD_ITEM &aBoardItem ) : - COBJECT2D( OBJ2D_ROUNDSEG, aBoardItem ), - m_segment( aStart, aEnd ) +CROUNDSEGMENT2D::CROUNDSEGMENT2D( + const SFVEC2F& aStart, const SFVEC2F& aEnd, float aWidth, const BOARD_ITEM& aBoardItem ) + : COBJECT2D( OBJECT2D_TYPE::ROUNDSEG, aBoardItem ), m_segment( aStart, aEnd ) { wxASSERT( aStart != aEnd ); @@ -297,7 +294,7 @@ bool CROUNDSEGMENT2D::Intersect( const RAYSEG2D &aSegRay, INTERSECTION_RESULT CROUNDSEGMENT2D::IsBBoxInside( const CBBOX2D &aBBox ) const { if( !m_bbox.Intersects( aBBox ) ) - return INTR_MISSES; + return INTERSECTION_RESULT::MISSES; SFVEC2F v[4]; @@ -318,16 +315,16 @@ INTERSECTION_RESULT CROUNDSEGMENT2D::IsBBoxInside( const CBBOX2D &aBBox ) const isInside[1] && isInside[2] && isInside[3] ) - return INTR_FULL_INSIDE; + return INTERSECTION_RESULT::FULL_INSIDE; // Check if any point is inside the circle if( isInside[0] || isInside[1] || isInside[2] || isInside[3] ) - return INTR_INTERSECTS; + return INTERSECTION_RESULT::INTERSECTS; - return INTR_MISSES; + return INTERSECTION_RESULT::MISSES; } diff --git a/3d-viewer/3d_rendering/3d_render_raytracing/shapes2D/ctriangle2d.cpp b/3d-viewer/3d_rendering/3d_render_raytracing/shapes2D/ctriangle2d.cpp index eafc02881d..b744cad33b 100644 --- a/3d-viewer/3d_rendering/3d_render_raytracing/shapes2D/ctriangle2d.cpp +++ b/3d-viewer/3d_rendering/3d_render_raytracing/shapes2D/ctriangle2d.cpp @@ -39,12 +39,9 @@ #include "../../../3d_fastmath.h" - -CTRIANGLE2D::CTRIANGLE2D ( const SFVEC2F &aV1, - const SFVEC2F &aV2, - const SFVEC2F &aV3, - const BOARD_ITEM &aBoardItem ) : COBJECT2D( OBJ2D_TRIANGLE, - aBoardItem ) +CTRIANGLE2D::CTRIANGLE2D( + const SFVEC2F& aV1, const SFVEC2F& aV2, const SFVEC2F& aV3, const BOARD_ITEM& aBoardItem ) + : COBJECT2D( OBJECT2D_TYPE::TRIANGLE, aBoardItem ) { p1 = aV1; p2 = aV2; @@ -98,9 +95,9 @@ bool CTRIANGLE2D::Intersect( const RAYSEG2D &aSegRay, INTERSECTION_RESULT CTRIANGLE2D::IsBBoxInside( const CBBOX2D &aBBox ) const { if( !m_bbox.Intersects( aBBox ) ) - return INTR_MISSES; + return INTERSECTION_RESULT::MISSES; // !TODO: - return INTR_MISSES; + return INTERSECTION_RESULT::MISSES; } diff --git a/3d-viewer/3d_rendering/3d_render_raytracing/shapes3D/cbbox_ray.cpp b/3d-viewer/3d_rendering/3d_render_raytracing/shapes3D/cbbox_ray.cpp index 759a7cc8bb..ab9d2d077e 100644 --- a/3d-viewer/3d_rendering/3d_render_raytracing/shapes3D/cbbox_ray.cpp +++ b/3d-viewer/3d_rendering/3d_render_raytracing/shapes3D/cbbox_ray.cpp @@ -47,7 +47,7 @@ bool CBBOX::Intersect( const RAY& aRay, float* t ) const { switch( aRay.m_Classification ) { - case MMM: + case RAY_CLASSIFICATION::MMM: { if( ( aRay.m_Origin.x < m_min.x ) || ( aRay.m_Origin.y < m_min.y ) @@ -79,7 +79,7 @@ bool CBBOX::Intersect( const RAY& aRay, float* t ) const } - case MMP: + case RAY_CLASSIFICATION::MMP: { if( ( aRay.m_Origin.x < m_min.x ) || ( aRay.m_Origin.y < m_min.y ) @@ -108,7 +108,7 @@ bool CBBOX::Intersect( const RAY& aRay, float* t ) const return true; } - case MPM: + case RAY_CLASSIFICATION::MPM: { if( ( aRay.m_Origin.x < m_min.x ) || ( aRay.m_Origin.y > m_max.y ) @@ -137,7 +137,7 @@ bool CBBOX::Intersect( const RAY& aRay, float* t ) const return true; } - case MPP: + case RAY_CLASSIFICATION::MPP: { if( ( aRay.m_Origin.x < m_min.x ) || ( aRay.m_Origin.y > m_max.y ) @@ -166,7 +166,7 @@ bool CBBOX::Intersect( const RAY& aRay, float* t ) const return true; } - case PMM: + case RAY_CLASSIFICATION::PMM: { if( ( aRay.m_Origin.x > m_max.x ) || ( aRay.m_Origin.y < m_min.y ) @@ -196,7 +196,7 @@ bool CBBOX::Intersect( const RAY& aRay, float* t ) const } - case PMP: + case RAY_CLASSIFICATION::PMP: { if( ( aRay.m_Origin.x > m_max.x ) || ( aRay.m_Origin.y < m_min.y ) @@ -225,7 +225,7 @@ bool CBBOX::Intersect( const RAY& aRay, float* t ) const return true; } - case PPM: + case RAY_CLASSIFICATION::PPM: { if( ( aRay.m_Origin.x > m_max.x ) || ( aRay.m_Origin.y > m_max.y ) @@ -254,7 +254,7 @@ bool CBBOX::Intersect( const RAY& aRay, float* t ) const return true; } - case PPP: + case RAY_CLASSIFICATION::PPP: { if( ( aRay.m_Origin.x > m_max.x ) || ( aRay.m_Origin.y > m_max.y ) @@ -283,7 +283,7 @@ bool CBBOX::Intersect( const RAY& aRay, float* t ) const return true; } - case OMM: + case RAY_CLASSIFICATION::OMM: { if( ( aRay.m_Origin.x < m_min.x ) || ( aRay.m_Origin.x > m_max.x ) @@ -303,7 +303,7 @@ bool CBBOX::Intersect( const RAY& aRay, float* t ) const return true; } - case OMP: + case RAY_CLASSIFICATION::OMP: { if( ( aRay.m_Origin.x < m_min.x ) || ( aRay.m_Origin.x > m_max.x ) @@ -323,7 +323,7 @@ bool CBBOX::Intersect( const RAY& aRay, float* t ) const return true; } - case OPM: + case RAY_CLASSIFICATION::OPM: { if( ( aRay.m_Origin.x < m_min.x) || ( aRay.m_Origin.x > m_max.x) || ( aRay.m_Origin.y > m_max.y) || ( aRay.m_Origin.z < m_min.z) @@ -342,7 +342,7 @@ bool CBBOX::Intersect( const RAY& aRay, float* t ) const return true; } - case OPP: + case RAY_CLASSIFICATION::OPP: { if( ( aRay.m_Origin.x < m_min.x) || ( aRay.m_Origin.x > m_max.x) || ( aRay.m_Origin.y > m_max.y) || ( aRay.m_Origin.z > m_max.z) @@ -362,7 +362,7 @@ bool CBBOX::Intersect( const RAY& aRay, float* t ) const } - case MOM: + case RAY_CLASSIFICATION::MOM: { if( ( aRay.m_Origin.y < m_min.y) || ( aRay.m_Origin.y > m_max.y) || ( aRay.m_Origin.x < m_min.x) || ( aRay.m_Origin.z < m_min.z) @@ -382,7 +382,7 @@ bool CBBOX::Intersect( const RAY& aRay, float* t ) const } - case MOP: + case RAY_CLASSIFICATION::MOP: { if( ( aRay.m_Origin.y < m_min.y) || ( aRay.m_Origin.y > m_max.y) || ( aRay.m_Origin.x < m_min.x) || ( aRay.m_Origin.z > m_max.z) @@ -401,7 +401,7 @@ bool CBBOX::Intersect( const RAY& aRay, float* t ) const return true; } - case POM: + case RAY_CLASSIFICATION::POM: { if( ( aRay.m_Origin.y < m_min.y) || ( aRay.m_Origin.y > m_max.y) || ( aRay.m_Origin.x > m_max.x) || ( aRay.m_Origin.z < m_min.z) @@ -421,7 +421,7 @@ bool CBBOX::Intersect( const RAY& aRay, float* t ) const } - case POP: + case RAY_CLASSIFICATION::POP: { if( ( aRay.m_Origin.y < m_min.y) || ( aRay.m_Origin.y > m_max.y) || ( aRay.m_Origin.x > m_max.x) || ( aRay.m_Origin.z > m_max.z) @@ -440,7 +440,7 @@ bool CBBOX::Intersect( const RAY& aRay, float* t ) const return true; } - case MMO: + case RAY_CLASSIFICATION::MMO: { if( ( aRay.m_Origin.z < m_min.z) || ( aRay.m_Origin.z > m_max.z) || ( aRay.m_Origin.x < m_min.x) || ( aRay.m_Origin.y < m_min.y) @@ -459,7 +459,7 @@ bool CBBOX::Intersect( const RAY& aRay, float* t ) const return true; } - case MPO: + case RAY_CLASSIFICATION::MPO: { if( ( aRay.m_Origin.z < m_min.z) || ( aRay.m_Origin.z > m_max.z) || ( aRay.m_Origin.x < m_min.x) || ( aRay.m_Origin.y > m_max.y) @@ -479,7 +479,7 @@ bool CBBOX::Intersect( const RAY& aRay, float* t ) const } - case PMO: + case RAY_CLASSIFICATION::PMO: { if( ( aRay.m_Origin.z < m_min.z) || ( aRay.m_Origin.z > m_max.z) || ( aRay.m_Origin.x > m_max.x) || ( aRay.m_Origin.y < m_min.y) @@ -498,7 +498,7 @@ bool CBBOX::Intersect( const RAY& aRay, float* t ) const return true; } - case PPO: + case RAY_CLASSIFICATION::PPO: { if( ( aRay.m_Origin.z < m_min.z) || ( aRay.m_Origin.z > m_max.z) || ( aRay.m_Origin.x > m_max.x) || ( aRay.m_Origin.y > m_max.y) @@ -518,7 +518,7 @@ bool CBBOX::Intersect( const RAY& aRay, float* t ) const } - case MOO: + case RAY_CLASSIFICATION::MOO: { if( ( aRay.m_Origin.x < m_min.x) || ( aRay.m_Origin.y < m_min.y) || ( aRay.m_Origin.y > m_max.y) @@ -531,7 +531,7 @@ bool CBBOX::Intersect( const RAY& aRay, float* t ) const return true; } - case POO: + case RAY_CLASSIFICATION::POO: { if( ( aRay.m_Origin.x > m_max.x) || ( aRay.m_Origin.y < m_min.y) || ( aRay.m_Origin.y > m_max.y) @@ -544,7 +544,7 @@ bool CBBOX::Intersect( const RAY& aRay, float* t ) const return true; } - case OMO: + case RAY_CLASSIFICATION::OMO: { if( ( aRay.m_Origin.y < m_min.y) || ( aRay.m_Origin.x < m_min.x) || ( aRay.m_Origin.x > m_max.x) @@ -557,7 +557,7 @@ bool CBBOX::Intersect( const RAY& aRay, float* t ) const return true; } - case OPO: + case RAY_CLASSIFICATION::OPO: { if( ( aRay.m_Origin.y > m_max.y) || ( aRay.m_Origin.x < m_min.x) || ( aRay.m_Origin.x > m_max.x) @@ -571,7 +571,7 @@ bool CBBOX::Intersect( const RAY& aRay, float* t ) const } - case OOM: + case RAY_CLASSIFICATION::OOM: { if( ( aRay.m_Origin.z < m_min.z) || ( aRay.m_Origin.x < m_min.x) || ( aRay.m_Origin.x > m_max.x) @@ -584,7 +584,7 @@ bool CBBOX::Intersect( const RAY& aRay, float* t ) const return true; } - case OOP: + case RAY_CLASSIFICATION::OOP: { if( ( aRay.m_Origin.z > m_max.z) || ( aRay.m_Origin.x < m_min.x) || ( aRay.m_Origin.x > m_max.x) @@ -606,7 +606,7 @@ bool CBBOX::Intersect( const RAY& aRay ) const { switch( aRay.m_Classification ) { - case MMM: + case RAY_CLASSIFICATION::MMM: { if( ( aRay.m_Origin.x < m_min.x ) || ( aRay.m_Origin.y < m_min.y ) @@ -624,7 +624,7 @@ bool CBBOX::Intersect( const RAY& aRay ) const } - case MMP: + case RAY_CLASSIFICATION::MMP: { if( ( aRay.m_Origin.x < m_min.x ) || ( aRay.m_Origin.y < m_min.y ) @@ -641,7 +641,7 @@ bool CBBOX::Intersect( const RAY& aRay ) const return true; } - case MPM: + case RAY_CLASSIFICATION::MPM: { if( ( aRay.m_Origin.x < m_min.x ) || ( aRay.m_Origin.y > m_max.y ) @@ -658,7 +658,7 @@ bool CBBOX::Intersect( const RAY& aRay ) const return true; } - case MPP: + case RAY_CLASSIFICATION::MPP: { if( ( aRay.m_Origin.x < m_min.x ) || ( aRay.m_Origin.y > m_max.y ) @@ -675,7 +675,7 @@ bool CBBOX::Intersect( const RAY& aRay ) const return true; } - case PMM: + case RAY_CLASSIFICATION::PMM: { if( ( aRay.m_Origin.x > m_max.x ) || ( aRay.m_Origin.y < m_min.y ) @@ -693,7 +693,7 @@ bool CBBOX::Intersect( const RAY& aRay ) const } - case PMP: + case RAY_CLASSIFICATION::PMP: { if( ( aRay.m_Origin.x > m_max.x ) || ( aRay.m_Origin.y < m_min.y ) @@ -710,7 +710,7 @@ bool CBBOX::Intersect( const RAY& aRay ) const return true; } - case PPM: + case RAY_CLASSIFICATION::PPM: { if( ( aRay.m_Origin.x > m_max.x ) || ( aRay.m_Origin.y > m_max.y ) @@ -727,7 +727,7 @@ bool CBBOX::Intersect( const RAY& aRay ) const return true; } - case PPP: + case RAY_CLASSIFICATION::PPP: { if( ( aRay.m_Origin.x > m_max.x ) || ( aRay.m_Origin.y > m_max.y ) @@ -744,7 +744,7 @@ bool CBBOX::Intersect( const RAY& aRay ) const return true; } - case OMM: + case RAY_CLASSIFICATION::OMM: { if( ( aRay.m_Origin.x < m_min.x ) || ( aRay.m_Origin.x > m_max.x ) @@ -756,7 +756,7 @@ bool CBBOX::Intersect( const RAY& aRay ) const return true; } - case OMP: + case RAY_CLASSIFICATION::OMP: { if( ( aRay.m_Origin.x < m_min.x ) || ( aRay.m_Origin.x > m_max.x ) @@ -769,7 +769,7 @@ bool CBBOX::Intersect( const RAY& aRay ) const return true; } - case OPM: + case RAY_CLASSIFICATION::OPM: { if( ( aRay.m_Origin.x < m_min.x ) || ( aRay.m_Origin.x > m_max.x ) @@ -782,7 +782,7 @@ bool CBBOX::Intersect( const RAY& aRay ) const return true; } - case OPP: + case RAY_CLASSIFICATION::OPP: { if( ( aRay.m_Origin.x < m_min.x ) || ( aRay.m_Origin.x > m_max.x ) @@ -796,7 +796,7 @@ bool CBBOX::Intersect( const RAY& aRay ) const } - case MOM: + case RAY_CLASSIFICATION::MOM: { if( ( aRay.m_Origin.y < m_min.y) || ( aRay.m_Origin.y > m_max.y) || ( aRay.m_Origin.x < m_min.x) || ( aRay.m_Origin.z < m_min.z) @@ -809,7 +809,7 @@ bool CBBOX::Intersect( const RAY& aRay ) const } - case MOP: + case RAY_CLASSIFICATION::MOP: { if( ( aRay.m_Origin.y < m_min.y) || ( aRay.m_Origin.y > m_max.y) || ( aRay.m_Origin.x < m_min.x) || ( aRay.m_Origin.z > m_max.z) @@ -821,7 +821,7 @@ bool CBBOX::Intersect( const RAY& aRay ) const return true; } - case POM: + case RAY_CLASSIFICATION::POM: { if( ( aRay.m_Origin.y < m_min.y) || ( aRay.m_Origin.y > m_max.y) || ( aRay.m_Origin.x > m_max.x) || ( aRay.m_Origin.z < m_min.z) @@ -834,7 +834,7 @@ bool CBBOX::Intersect( const RAY& aRay ) const } - case POP: + case RAY_CLASSIFICATION::POP: { if( ( aRay.m_Origin.y < m_min.y) || ( aRay.m_Origin.y > m_max.y) || ( aRay.m_Origin.x > m_max.x) || ( aRay.m_Origin.z > m_max.z) @@ -846,7 +846,7 @@ bool CBBOX::Intersect( const RAY& aRay ) const return true; } - case MMO: + case RAY_CLASSIFICATION::MMO: { if( ( aRay.m_Origin.z < m_min.z) || ( aRay.m_Origin.z > m_max.z) || ( aRay.m_Origin.x < m_min.x) || ( aRay.m_Origin.y < m_min.y) @@ -858,7 +858,7 @@ bool CBBOX::Intersect( const RAY& aRay ) const return true; } - case MPO: + case RAY_CLASSIFICATION::MPO: { if( ( aRay.m_Origin.z < m_min.z) || ( aRay.m_Origin.z > m_max.z) || ( aRay.m_Origin.x < m_min.x) || ( aRay.m_Origin.y > m_max.y) @@ -871,7 +871,7 @@ bool CBBOX::Intersect( const RAY& aRay ) const } - case PMO: + case RAY_CLASSIFICATION::PMO: { if( ( aRay.m_Origin.z < m_min.z) || ( aRay.m_Origin.z > m_max.z) || ( aRay.m_Origin.x > m_max.x) || ( aRay.m_Origin.y < m_min.y) @@ -883,7 +883,7 @@ bool CBBOX::Intersect( const RAY& aRay ) const return true; } - case PPO: + case RAY_CLASSIFICATION::PPO: { if( ( aRay.m_Origin.z < m_min.z) || ( aRay.m_Origin.z > m_max.z) || ( aRay.m_Origin.x > m_max.x) || ( aRay.m_Origin.y > m_max.y) @@ -896,7 +896,7 @@ bool CBBOX::Intersect( const RAY& aRay ) const } - case MOO: + case RAY_CLASSIFICATION::MOO: { if( ( aRay.m_Origin.x < m_min.x) || ( aRay.m_Origin.y < m_min.y) || ( aRay.m_Origin.y > m_max.y) @@ -907,7 +907,7 @@ bool CBBOX::Intersect( const RAY& aRay ) const return true; } - case POO: + case RAY_CLASSIFICATION::POO: { if( ( aRay.m_Origin.x > m_max.x) || ( aRay.m_Origin.y < m_min.y) || ( aRay.m_Origin.y > m_max.y) @@ -918,7 +918,7 @@ bool CBBOX::Intersect( const RAY& aRay ) const return true; } - case OMO: + case RAY_CLASSIFICATION::OMO: { if( ( aRay.m_Origin.y < m_min.y) || ( aRay.m_Origin.x < m_min.x) || ( aRay.m_Origin.x > m_max.x) @@ -929,7 +929,7 @@ bool CBBOX::Intersect( const RAY& aRay ) const return true; } - case OPO: + case RAY_CLASSIFICATION::OPO: { if( ( aRay.m_Origin.y > m_max.y) || ( aRay.m_Origin.x < m_min.x) || ( aRay.m_Origin.x > m_max.x) @@ -941,7 +941,7 @@ bool CBBOX::Intersect( const RAY& aRay ) const } - case OOM: + case RAY_CLASSIFICATION::OOM: { if( ( aRay.m_Origin.z < m_min.z) || ( aRay.m_Origin.x < m_min.x) || ( aRay.m_Origin.x > m_max.x) @@ -952,7 +952,7 @@ bool CBBOX::Intersect( const RAY& aRay ) const return true; } - case OOP: + case RAY_CLASSIFICATION::OOP: { if( ( aRay.m_Origin.z > m_max.z) || ( aRay.m_Origin.x < m_min.x) || ( aRay.m_Origin.x > m_max.x) diff --git a/3d-viewer/3d_rendering/3d_render_raytracing/shapes3D/ccylinder.cpp b/3d-viewer/3d_rendering/3d_render_raytracing/shapes3D/ccylinder.cpp index 8150231548..71c47b2e3e 100644 --- a/3d-viewer/3d_rendering/3d_render_raytracing/shapes3D/ccylinder.cpp +++ b/3d-viewer/3d_rendering/3d_render_raytracing/shapes3D/ccylinder.cpp @@ -31,10 +31,8 @@ #include "ccylinder.h" -CVCYLINDER::CVCYLINDER( SFVEC2F aCenterPoint, - float aZmin, - float aZmax, - float aRadius ) : COBJECT( OBJ3D_CYLINDER ) +CVCYLINDER::CVCYLINDER( SFVEC2F aCenterPoint, float aZmin, float aZmax, float aRadius ) + : COBJECT( OBJECT3D_TYPE::CYLINDER ) { m_center = aCenterPoint; m_radius_squared = aRadius * aRadius; diff --git a/3d-viewer/3d_rendering/3d_render_raytracing/shapes3D/cdummyblock.cpp b/3d-viewer/3d_rendering/3d_render_raytracing/shapes3D/cdummyblock.cpp index c44a97edf1..54971ede48 100644 --- a/3d-viewer/3d_rendering/3d_render_raytracing/shapes3D/cdummyblock.cpp +++ b/3d-viewer/3d_rendering/3d_render_raytracing/shapes3D/cdummyblock.cpp @@ -30,7 +30,7 @@ #include "cdummyblock.h" -CDUMMYBLOCK::CDUMMYBLOCK( const CBBOX &aBBox ) : COBJECT( OBJ3D_DUMMYBLOCK ) +CDUMMYBLOCK::CDUMMYBLOCK( const CBBOX& aBBox ) : COBJECT( OBJECT3D_TYPE::DUMMYBLOCK ) { m_centroid = aBBox.GetCenter(); m_bbox.Reset(); diff --git a/3d-viewer/3d_rendering/3d_render_raytracing/shapes3D/clayeritem.cpp b/3d-viewer/3d_rendering/3d_render_raytracing/shapes3D/clayeritem.cpp index ee51d44483..c5498e09bd 100644 --- a/3d-viewer/3d_rendering/3d_render_raytracing/shapes3D/clayeritem.cpp +++ b/3d-viewer/3d_rendering/3d_render_raytracing/shapes3D/clayeritem.cpp @@ -32,9 +32,8 @@ #include -CLAYERITEM::CLAYERITEM( const COBJECT2D *aObject2D, float aZMin, float aZMax ) : - COBJECT( OBJ3D_LAYERITEM ), - m_object2d(aObject2D) +CLAYERITEM::CLAYERITEM( const COBJECT2D* aObject2D, float aZMin, float aZMax ) + : COBJECT( OBJECT3D_TYPE::LAYERITEM ), m_object2d( aObject2D ) { wxASSERT( aObject2D ); diff --git a/3d-viewer/3d_rendering/3d_render_raytracing/shapes3D/cobject.cpp b/3d-viewer/3d_rendering/3d_render_raytracing/shapes3D/cobject.cpp index e3a4adbb2f..7e3248268b 100644 --- a/3d-viewer/3d_rendering/3d_render_raytracing/shapes3D/cobject.cpp +++ b/3d-viewer/3d_rendering/3d_render_raytracing/shapes3D/cobject.cpp @@ -29,6 +29,7 @@ #include "cobject.h" #include +#include COBJECT3D_STATS *COBJECT3D_STATS::s_instance = 0; @@ -43,23 +44,29 @@ COBJECT::COBJECT( OBJECT3D_TYPE aObjType ) } -static const char *OBJECT3D_STR[OBJ3D_MAX] = -{ - "OBJ3D_CYLINDER", - "OBJ3D_DUMMYBLOCK", - "OBJ3D_LAYERITEM", - "OBJ3D_XYPLANE", - "OBJ3D_ROUNDSEG", - "OBJ3D_TRIANGLE" +/* + * Lookup table for OBJECT2D_TYPE printed names + */ +// clang-format off +const std::map objectTypeNames +{ + { OBJECT3D_TYPE::CYLINDER, "OBJECT3D_TYPE::CYLINDER" }, + { OBJECT3D_TYPE::DUMMYBLOCK, "OBJECT2D_TYPE::DUMMYBLOCK" }, + { OBJECT3D_TYPE::LAYERITEM, "OBJECT2D_TYPE::LAYERITEM" }, + { OBJECT3D_TYPE::XYPLANE, "OBJECT2D_TYPE::XYPLANE" }, + { OBJECT3D_TYPE::ROUNDSEG, "OBJECT2D_TYPE::ROUNDSEG" }, + { OBJECT3D_TYPE::TRIANGLE, "OBJECT2D_TYPE::TRIANGLE" } }; +// clang-format on void COBJECT3D_STATS::PrintStats() { printf( "OBJ3D Statistics:\n" ); - for( unsigned int i = 0; i < OBJ3D_MAX; ++i ) + for( auto& objectType : objectTypeNames ) { - printf( " %20s %u\n", OBJECT3D_STR[i], m_counter[i] ); + printf( " %20s %u\n", objectType.second, + m_counter[static_cast( objectType.first )] ); } } diff --git a/3d-viewer/3d_rendering/3d_render_raytracing/shapes3D/cobject.h b/3d-viewer/3d_rendering/3d_render_raytracing/shapes3D/cobject.h index 9f9d3f69ae..a22bcca7a5 100644 --- a/3d-viewer/3d_rendering/3d_render_raytracing/shapes3D/cobject.h +++ b/3d-viewer/3d_rendering/3d_render_raytracing/shapes3D/cobject.h @@ -35,15 +35,15 @@ #include "../cmaterial.h" -enum OBJECT3D_TYPE +enum class OBJECT3D_TYPE { - OBJ3D_CYLINDER, - OBJ3D_DUMMYBLOCK, - OBJ3D_LAYERITEM, - OBJ3D_XYPLANE, - OBJ3D_ROUNDSEG, - OBJ3D_TRIANGLE, - OBJ3D_MAX + CYLINDER, + DUMMYBLOCK, + LAYERITEM, + XYPLANE, + ROUNDSEG, + TRIANGLE, + MAX }; @@ -102,14 +102,20 @@ public: class COBJECT3D_STATS { public: + void ResetStats() + { + memset( m_counter, 0, sizeof( unsigned int ) * static_cast( OBJECT3D_TYPE::MAX ) ); + } - void ResetStats() { memset( m_counter, - 0, - sizeof( unsigned int ) * OBJ3D_MAX ); } + unsigned int GetCountOf( OBJECT3D_TYPE aObjType ) const + { + return m_counter[static_cast( aObjType )]; + } - unsigned int GetCountOf( OBJECT3D_TYPE aObjType ) const { return m_counter[aObjType]; } - - void AddOne( OBJECT3D_TYPE aObjType ) { m_counter[aObjType]++; } + void AddOne( OBJECT3D_TYPE aObjType ) + { + m_counter[static_cast( aObjType )]++; + } void PrintStats(); @@ -128,7 +134,7 @@ private: ~COBJECT3D_STATS(){} private: - unsigned int m_counter[OBJ3D_MAX]; + unsigned int m_counter[static_cast( OBJECT3D_TYPE::MAX )]; static COBJECT3D_STATS *s_instance; }; diff --git a/3d-viewer/3d_rendering/3d_render_raytracing/shapes3D/cplane.cpp b/3d-viewer/3d_rendering/3d_render_raytracing/shapes3D/cplane.cpp index 1fe767f377..c3d7b568f3 100644 --- a/3d-viewer/3d_rendering/3d_render_raytracing/shapes3D/cplane.cpp +++ b/3d-viewer/3d_rendering/3d_render_raytracing/shapes3D/cplane.cpp @@ -30,7 +30,7 @@ #include "cplane.h" -CXYPLANE::CXYPLANE( const CBBOX &aBBox ) : COBJECT( OBJ3D_XYPLANE ) +CXYPLANE::CXYPLANE( const CBBOX& aBBox ) : COBJECT( OBJECT3D_TYPE::XYPLANE ) { m_centerPoint = aBBox.GetCenter(); m_centroid = m_centerPoint; @@ -44,9 +44,8 @@ CXYPLANE::CXYPLANE( const CBBOX &aBBox ) : COBJECT( OBJ3D_XYPLANE ) } -CXYPLANE::CXYPLANE( SFVEC3F aCenterPoint, - float aXSize, - float aYSize ) : COBJECT( OBJ3D_XYPLANE ) +CXYPLANE::CXYPLANE( SFVEC3F aCenterPoint, float aXSize, float aYSize ) + : COBJECT( OBJECT3D_TYPE::XYPLANE ) { m_centerPoint = aCenterPoint; m_xsize = aXSize; diff --git a/3d-viewer/3d_rendering/3d_render_raytracing/shapes3D/croundseg.cpp b/3d-viewer/3d_rendering/3d_render_raytracing/shapes3D/croundseg.cpp index 4630f90399..ba89476127 100644 --- a/3d-viewer/3d_rendering/3d_render_raytracing/shapes3D/croundseg.cpp +++ b/3d-viewer/3d_rendering/3d_render_raytracing/shapes3D/croundseg.cpp @@ -29,10 +29,8 @@ #include "croundseg.h" -CROUNDSEG::CROUNDSEG( const CROUNDSEGMENT2D &aSeg2D, - float aZmin, - float aZmax ) : COBJECT( OBJ3D_ROUNDSEG ), - m_segment( aSeg2D.m_segment ) +CROUNDSEG::CROUNDSEG( const CROUNDSEGMENT2D& aSeg2D, float aZmin, float aZmax ) + : COBJECT( OBJECT3D_TYPE::ROUNDSEG ), m_segment( aSeg2D.m_segment ) { m_radius = aSeg2D.GetRadius(); m_radius_squared = m_radius * m_radius; diff --git a/3d-viewer/3d_rendering/3d_render_raytracing/shapes3D/ctriangle.cpp b/3d-viewer/3d_rendering/3d_render_raytracing/shapes3D/ctriangle.cpp index 9964839b07..f5dcad0942 100644 --- a/3d-viewer/3d_rendering/3d_render_raytracing/shapes3D/ctriangle.cpp +++ b/3d-viewer/3d_rendering/3d_render_raytracing/shapes3D/ctriangle.cpp @@ -98,9 +98,8 @@ void CTRIANGLE::pre_calc_const() } -CTRIANGLE::CTRIANGLE( const SFVEC3F &aV1, - const SFVEC3F &aV2, - const SFVEC3F &aV3 ) : COBJECT( OBJ3D_TRIANGLE ) +CTRIANGLE::CTRIANGLE( const SFVEC3F& aV1, const SFVEC3F& aV2, const SFVEC3F& aV3 ) + : COBJECT( OBJECT3D_TYPE::TRIANGLE ) { m_vertex[0] = aV1; m_vertex[1] = aV2; @@ -114,10 +113,9 @@ CTRIANGLE::CTRIANGLE( const SFVEC3F &aV1, } -CTRIANGLE::CTRIANGLE( const SFVEC3F &aV1, - const SFVEC3F &aV2, - const SFVEC3F &aV3, - const SFVEC3F &aFaceNormal ) : COBJECT( OBJ3D_TRIANGLE ) +CTRIANGLE::CTRIANGLE( + const SFVEC3F& aV1, const SFVEC3F& aV2, const SFVEC3F& aV3, const SFVEC3F& aFaceNormal ) + : COBJECT( OBJECT3D_TYPE::TRIANGLE ) { m_vertex[0] = aV1; m_vertex[1] = aV2; @@ -135,12 +133,9 @@ CTRIANGLE::CTRIANGLE( const SFVEC3F &aV1, } -CTRIANGLE::CTRIANGLE( const SFVEC3F &aV1, - const SFVEC3F &aV2, - const SFVEC3F &aV3, - const SFVEC3F &aN1, - const SFVEC3F &aN2, - const SFVEC3F &aN3 ) : COBJECT( OBJ3D_TRIANGLE ) +CTRIANGLE::CTRIANGLE( const SFVEC3F& aV1, const SFVEC3F& aV2, const SFVEC3F& aV3, + const SFVEC3F& aN1, const SFVEC3F& aN2, const SFVEC3F& aN3 ) + : COBJECT( OBJECT3D_TYPE::TRIANGLE ) { m_vertex[0] = aV1; m_vertex[1] = aV2; diff --git a/3d-viewer/3d_rendering/ccamera.cpp b/3d-viewer/3d_rendering/ccamera.cpp index 8db4ea9468..17e8f5dff8 100644 --- a/3d-viewer/3d_rendering/ccamera.cpp +++ b/3d-viewer/3d_rendering/ccamera.cpp @@ -50,8 +50,8 @@ CCAMERA::CCAMERA( float aRangeScale ) m_camera_pos_init = SFVEC3F( 0.0f, 0.0f, -(aRangeScale * 2.0f ) ); m_board_lookat_pos_init = SFVEC3F( 0.0f ); m_windowSize = SFVEC2I( 0, 0 ); - m_projectionType = PROJECTION_PERSPECTIVE; - m_interpolation_mode = INTERPOLATION_BEZIER; + m_projectionType = PROJECTION_TYPE::PERSPECTIVE; + m_interpolation_mode = CAMERA_INTERPOLATION::BEZIER; Reset(); } @@ -148,7 +148,7 @@ void CCAMERA::rebuildProjection() switch( m_projectionType ) { default: - case PROJECTION_PERSPECTIVE: + case PROJECTION_TYPE::PERSPECTIVE: m_frustum.nearD = 0.10f; @@ -174,7 +174,7 @@ void CCAMERA::rebuildProjection() m_frustum.fw = m_frustum.fh * m_frustum.ratio; break; - case PROJECTION_ORTHO: + case PROJECTION_TYPE::ORTHO: m_frustum.nearD = -m_frustum.farD; // Use a symmetrical clip plane for ortho projection @@ -303,12 +303,12 @@ void CCAMERA::MakeRay( const SFVEC2I &aWindowPos, switch( m_projectionType ) { default: - case PROJECTION_PERSPECTIVE: + case PROJECTION_TYPE::PERSPECTIVE: aOutOrigin = up_plus_right + m_frustum.nc; aOutDirection = glm::normalize( aOutOrigin - m_pos ); break; - case PROJECTION_ORTHO: + case PROJECTION_TYPE::ORTHO: aOutOrigin = up_plus_right * 0.5f + m_frustum.nc; aOutDirection = -m_dir + SFVEC3F( FLT_EPSILON ); break; @@ -334,12 +334,12 @@ void CCAMERA::MakeRay( const SFVEC2F &aWindowPos, SFVEC3F &aOutOrigin, SFVEC3F & switch( m_projectionType ) { default: - case PROJECTION_PERSPECTIVE: + case PROJECTION_TYPE::PERSPECTIVE: aOutOrigin = up_plus_right + m_frustum.nc; aOutDirection = glm::normalize( aOutOrigin - m_pos ); break; - case PROJECTION_ORTHO: + case PROJECTION_TYPE::ORTHO: aOutOrigin = up_plus_right * 0.5f + m_frustum.nc; aOutDirection = -m_dir + SFVEC3F( FLT_EPSILON ); break; @@ -416,10 +416,10 @@ void CCAMERA::SetProjection( PROJECTION_TYPE aProjectionType ) void CCAMERA::ToggleProjection() { - if( m_projectionType == PROJECTION_ORTHO ) - m_projectionType = PROJECTION_PERSPECTIVE; + if( m_projectionType == PROJECTION_TYPE::ORTHO ) + m_projectionType = PROJECTION_TYPE::PERSPECTIVE; else - m_projectionType = PROJECTION_ORTHO; + m_projectionType = PROJECTION_TYPE::ORTHO; rebuildProjection(); } diff --git a/3d-viewer/3d_rendering/ccamera.h b/3d-viewer/3d_rendering/ccamera.h index 3531ad171a..713222e7b3 100644 --- a/3d-viewer/3d_rendering/ccamera.h +++ b/3d-viewer/3d_rendering/ccamera.h @@ -34,10 +34,10 @@ #include // for wxSize #include -enum PROJECTION_TYPE +enum class PROJECTION_TYPE { - PROJECTION_ORTHO, - PROJECTION_PERSPECTIVE + ORTHO, + PERSPECTIVE }; /** @@ -62,12 +62,11 @@ struct FRUSTUM }; -enum CAMERA_INTERPOLATION +enum class CAMERA_INTERPOLATION { - INTERPOLATION_LINEAR, - INTERPOLATION_EASING_IN_OUT, // Quadratic - INTERPOLATION_BEZIER, - + LINEAR, + EASING_IN_OUT, // Quadratic + BEZIER, }; diff --git a/3d-viewer/3d_rendering/cimage.cpp b/3d-viewer/3d_rendering/cimage.cpp index 8dbe8dc45c..67dbf4afa1 100644 --- a/3d-viewer/3d_rendering/cimage.cpp +++ b/3d-viewer/3d_rendering/cimage.cpp @@ -42,29 +42,29 @@ CIMAGE::CIMAGE( unsigned int aXsize, unsigned int aYsize ) { - m_wxh = aXsize * aYsize; - m_pixels = (unsigned char*)malloc( m_wxh ); + m_wxh = aXsize * aYsize; + m_pixels = new unsigned char[m_wxh]; memset( m_pixels, 0, m_wxh ); m_width = aXsize; m_height = aYsize; - m_wraping = (E_WRAP)WRAP_CLAMP; + m_wraping = IMAGE_WRAP::CLAMP; } CIMAGE::CIMAGE( const CIMAGE &aSrcImage ) { - m_wxh = aSrcImage.GetWidth() * aSrcImage.GetHeight(); - m_pixels = (unsigned char*)malloc( m_wxh ); + m_wxh = aSrcImage.GetWidth() * aSrcImage.GetHeight(); + m_pixels = new unsigned char[m_wxh]; memcpy( m_pixels, aSrcImage.GetBuffer(), m_wxh ); m_width = aSrcImage.GetWidth(); m_height = aSrcImage.GetHeight(); - m_wraping = (E_WRAP)WRAP_CLAMP; + m_wraping = IMAGE_WRAP::CLAMP; } CIMAGE::~CIMAGE() { - free( m_pixels ); + delete[] m_pixels; } @@ -81,14 +81,14 @@ bool CIMAGE::wrapCoords( int *aXo, int *aYo ) const switch(m_wraping) { - case WRAP_CLAMP: + case IMAGE_WRAP::CLAMP: x = (x < 0 )?0:x; x = (x >= (int)(m_width - 1))?(m_width - 1):x; y = (y < 0)?0:y; y = (y >= (int)(m_height - 1))?(m_height - 1):y; break; - case WRAP_WRAP: + case IMAGE_WRAP::WRAP: x = (x < 0)?((m_width - 1)+x):x; x = (x >= (int)(m_width - 1))?(x - m_width):x; y = (y < 0)?((m_height - 1)+y):y; @@ -201,11 +201,11 @@ void CIMAGE::Invert() } -void CIMAGE::CopyFull( const CIMAGE *aImgA, const CIMAGE *aImgB, E_IMAGE_OP aOperation ) +void CIMAGE::CopyFull( const CIMAGE* aImgA, const CIMAGE* aImgB, IMAGE_OP aOperation ) { int aV, bV; - if( aOperation == COPY_RAW ) + if( aOperation == IMAGE_OP::RAW ) { if( aImgA == NULL ) return; @@ -218,11 +218,11 @@ void CIMAGE::CopyFull( const CIMAGE *aImgA, const CIMAGE *aImgB, E_IMAGE_OP aOpe switch(aOperation) { - case COPY_RAW: + case IMAGE_OP::RAW: memcpy( m_pixels, aImgA->m_pixels, m_wxh ); break; - case COPY_ADD: + case IMAGE_OP::ADD: for( unsigned int it = 0;it < m_wxh; it++ ) { aV = aImgA->m_pixels[it]; @@ -235,7 +235,7 @@ void CIMAGE::CopyFull( const CIMAGE *aImgA, const CIMAGE *aImgB, E_IMAGE_OP aOpe } break; - case COPY_SUB: + case IMAGE_OP::SUB: for( unsigned int it = 0;it < m_wxh; it++ ) { aV = aImgA->m_pixels[it]; @@ -248,7 +248,7 @@ void CIMAGE::CopyFull( const CIMAGE *aImgA, const CIMAGE *aImgB, E_IMAGE_OP aOpe } break; - case COPY_DIF: + case IMAGE_OP::DIF: for( unsigned int it = 0;it < m_wxh; it++ ) { aV = aImgA->m_pixels[it]; @@ -258,7 +258,7 @@ void CIMAGE::CopyFull( const CIMAGE *aImgA, const CIMAGE *aImgB, E_IMAGE_OP aOpe } break; - case COPY_MUL: + case IMAGE_OP::MUL: for( unsigned int it = 0;it < m_wxh; it++ ) { aV = aImgA->m_pixels[it]; @@ -268,28 +268,28 @@ void CIMAGE::CopyFull( const CIMAGE *aImgA, const CIMAGE *aImgB, E_IMAGE_OP aOpe } break; - case COPY_AND: + case IMAGE_OP::AND: for( unsigned int it = 0;it < m_wxh; it++ ) { m_pixels[it] = aImgA->m_pixels[it] & aImgB->m_pixels[it]; } break; - case COPY_OR: + case IMAGE_OP::OR: for( unsigned int it = 0;it < m_wxh; it++ ) { m_pixels[it] = aImgA->m_pixels[it] | aImgB->m_pixels[it]; } break; - case COPY_XOR: + case IMAGE_OP::XOR: for( unsigned int it = 0;it < m_wxh; it++ ) { m_pixels[it] = aImgA->m_pixels[it] ^ aImgB->m_pixels[it]; } break; - case COPY_BLEND50: + case IMAGE_OP::BLEND50: for( unsigned int it = 0;it < m_wxh; it++ ) { aV = aImgA->m_pixels[it]; @@ -299,7 +299,7 @@ void CIMAGE::CopyFull( const CIMAGE *aImgA, const CIMAGE *aImgB, E_IMAGE_OP aOpe } break; - case COPY_MIN: + case IMAGE_OP::MIN: for( unsigned int it = 0;it < m_wxh; it++ ) { aV = aImgA->m_pixels[it]; @@ -309,7 +309,7 @@ void CIMAGE::CopyFull( const CIMAGE *aImgA, const CIMAGE *aImgB, E_IMAGE_OP aOpe } break; - case COPY_MAX: + case IMAGE_OP::MAX: for( unsigned int it = 0;it < m_wxh; it++ ) { aV = aImgA->m_pixels[it]; @@ -327,8 +327,9 @@ void CIMAGE::CopyFull( const CIMAGE *aImgA, const CIMAGE *aImgB, E_IMAGE_OP aOpe // TIP: If you want create or test filters you can use GIMP // with a generic convolution matrix and get the values from there. // http://docs.gimp.org/nl/plug-in-convmatrix.html +// clang-format off static const S_FILTER FILTERS[] = { - // FILTER_HIPASS + // IMAGE_FILTER::HIPASS { { { 0, -1, -1, -1, 0}, {-1, 2, -4, 2, -1}, @@ -340,7 +341,7 @@ static const S_FILTER FILTERS[] = { 255 }, - // FILTER_GAUSSIAN_BLUR + // IMAGE_FILTER::GAUSSIAN_BLUR { { { 3, 5, 7, 5, 3}, { 5, 9, 12, 9, 5}, @@ -352,7 +353,7 @@ static const S_FILTER FILTERS[] = { 0 }, - // FILTER_GAUSSIAN_BLUR2 + // IMAGE_FILTER::GAUSSIAN_BLUR2 { { { 1, 4, 7, 4, 1}, { 4, 16, 26, 16, 4}, @@ -364,7 +365,7 @@ static const S_FILTER FILTERS[] = { 0 }, - // FILTER_INVERT_BLUR + // IMAGE_FILTER::INVERT_BLUR { { { 0, 0, 0, 0, 0}, { 0, 0, -1, 0, 0}, @@ -376,7 +377,7 @@ static const S_FILTER FILTERS[] = { 255 }, - // FILTER_CARTOON + // IMAGE_FILTER::CARTOON { { {-1, -1, -1, -1, 0}, {-1, 0, 0, 0, 0}, @@ -388,7 +389,7 @@ static const S_FILTER FILTERS[] = { 0 }, - // FILTER_EMBOSS + // IMAGE_FILTER::EMBOSS { { {-1, -1, -1, -1, 0}, {-1, -1, -1, 0, 1}, @@ -400,7 +401,7 @@ static const S_FILTER FILTERS[] = { 128 }, - // FILTER_SHARPEN + // IMAGE_FILTER::SHARPEN { { {-1, -1, -1, -1, -1}, {-1, 2, 2, 2, -1}, @@ -412,7 +413,7 @@ static const S_FILTER FILTERS[] = { 0 }, - // FILTER_MELT + // IMAGE_FILTER::MELT { { { 4, 2, 6, 8, 1}, { 1, 2, 5, 4, 2}, @@ -424,7 +425,7 @@ static const S_FILTER FILTERS[] = { 0 }, - // FILTER_SOBEL_GX + // IMAGE_FILTER::SOBEL_GX { { { 0, 0, 0, 0, 0}, { 0, -1, 0, 1, 0}, @@ -436,7 +437,7 @@ static const S_FILTER FILTERS[] = { 0 }, - // FILTER_SOBEL_GY + // IMAGE_FILTER::SOBEL_GY { { { 1, 2, 4, 2, 1}, {-1, -1, 0, 1, 1}, @@ -448,7 +449,7 @@ static const S_FILTER FILTERS[] = { 0 }, - // FILTER_BLUR_3X3 + // IMAGE_FILTER::BLUR_3X3 { { { 0, 0, 0, 0, 0}, { 0, 1, 2, 1, 0}, @@ -460,18 +461,19 @@ static const S_FILTER FILTERS[] = { 0 } };// Filters +// clang-format on // !TODO: This functions can be optimized slipting it between the edges and // do it without use the getpixel function. // Optimization can be done to m_pixels[ix + iy * m_width] // but keep in mind the parallel process of the algorithm -void CIMAGE::EfxFilter( CIMAGE *aInImg, E_FILTER aFilterType ) +void CIMAGE::EfxFilter( CIMAGE* aInImg, IMAGE_FILTER aFilterType ) { - S_FILTER filter = FILTERS[aFilterType]; + S_FILTER filter = FILTERS[static_cast( aFilterType )]; - aInImg->m_wraping = WRAP_CLAMP; - m_wraping = WRAP_CLAMP; + aInImg->m_wraping = IMAGE_WRAP::CLAMP; + m_wraping = IMAGE_WRAP::CLAMP; std::atomic nextRow( 0 ); std::atomic threadsFinished( 0 ); diff --git a/3d-viewer/3d_rendering/cimage.h b/3d-viewer/3d_rendering/cimage.h index 1cf079268e..4429460870 100644 --- a/3d-viewer/3d_rendering/cimage.h +++ b/3d-viewer/3d_rendering/cimage.h @@ -33,42 +33,45 @@ #include /// Image operation type -enum E_IMAGE_OP { - COPY_RAW, - COPY_ADD, - COPY_SUB, - COPY_DIF, - COPY_MUL, - COPY_AND, - COPY_OR, - COPY_XOR, - COPY_BLEND50, - COPY_MIN, - COPY_MAX +enum class IMAGE_OP +{ + RAW, + ADD, + SUB, + DIF, + MUL, + AND, + OR, + XOR, + BLEND50, + MIN, + MAX }; /// Image wrap type enumeration -enum E_WRAP { - WRAP_ZERO, ///< Coords that wraps are not evaluated - WRAP_CLAMP, ///< Coords are clamped to image size - WRAP_WRAP ///< Coords are wrapped arround +enum class IMAGE_WRAP +{ + ZERO, ///< Coords that wraps are not evaluated + CLAMP, ///< Coords are clamped to image size + WRAP ///< Coords are wrapped arround }; /// Filter type enumeration -enum E_FILTER { - FILTER_HIPASS, - FILTER_GAUSSIAN_BLUR, - FILTER_GAUSSIAN_BLUR2, - FILTER_INVERT_BLUR, - FILTER_CARTOON, - FILTER_EMBOSS, - FILTER_SHARPEN, - FILTER_MELT, - FILTER_SOBEL_GX, - FILTER_SOBEL_GY, - FILTER_BLUR_3X3, +enum class IMAGE_FILTER +{ + HIPASS, + GAUSSIAN_BLUR, + GAUSSIAN_BLUR2, + INVERT_BLUR, + CARTOON, + EMBOSS, + SHARPEN, + MELT, + SOBEL_GX, + SOBEL_GY, + BLUR_3X3, }; /// 5x5 Filter struct parameters @@ -151,19 +154,19 @@ public: * @param aImgA an image input * @param aImgB an image input * @param aOperation operation to perform - * COPY_RAW this <- aImgA - * COPY_ADD this <- CLAMP(aImgA + aImgB) - * COPY_SUB this <- CLAMP(aImgA - aImgB) - * COPY_DIF this <- abs(aImgA - aImgB) - * COPY_MUL this <- aImgA * aImgB - * COPY_AND this <- aImgA & aImgB - * COPY_OR this <- aImgA | aImgB - * COPY_XOR this <- aImgA ^ aImgB - * COPY_BLEND50 this <- (aImgA + aImgB) / 2 - * COPY_MIN this <- (aImgA < aImgB)?aImgA:aImgB - * COPY_MAX this <- (aImgA > aImgB)?aImgA:aImgB + * IMAGE_OP::RAW this <- aImgA + * IMAGE_OP::ADD this <- CLAMP(aImgA + aImgB) + * IMAGE_OP::SUB this <- CLAMP(aImgA - aImgB) + * IMAGE_OP::DIF this <- abs(aImgA - aImgB) + * IMAGE_OP::MUL this <- aImgA * aImgB + * IMAGE_OP::AND this <- aImgA & aImgB + * IMAGE_OP::OR this <- aImgA | aImgB + * IMAGE_OP::XOR this <- aImgA ^ aImgB + * IMAGE_OP::BLEND50 this <- (aImgA + aImgB) / 2 + * IMAGE_OP::MIN this <- (aImgA < aImgB)?aImgA:aImgB + * IMAGE_OP::MAX this <- (aImgA > aImgB)?aImgA:aImgB */ - void CopyFull( const CIMAGE *aImgA, const CIMAGE *aImgB, E_IMAGE_OP aOperation ); + void CopyFull( const CIMAGE* aImgA, const CIMAGE* aImgB, IMAGE_OP aOperation ); /** * Function Invert @@ -178,7 +181,7 @@ public: * @param aInImg input image * @param aFilterType filter type to apply */ - void EfxFilter( CIMAGE *aInImg, E_FILTER aFilterType ); + void EfxFilter( CIMAGE* aInImg, IMAGE_FILTER aFilterType ); /** * Function SaveAsPNG @@ -223,7 +226,7 @@ private: unsigned int m_width; ///< width of the image unsigned int m_height; ///< height of the image unsigned int m_wxh; ///< width * height precalc value - E_WRAP m_wraping; ///< current wrapping type + IMAGE_WRAP m_wraping; ///< current wrapping type }; #endif // CIMAGE_H diff --git a/3d-viewer/3d_rendering/ctrack_ball.cpp b/3d-viewer/3d_rendering/ctrack_ball.cpp index f908c806bb..ebc39d8984 100644 --- a/3d-viewer/3d_rendering/ctrack_ball.cpp +++ b/3d-viewer/3d_rendering/ctrack_ball.cpp @@ -96,14 +96,14 @@ void CTRACK_BALL::Pan( const wxPoint &aNewMousePosition ) { m_parametersChanged = true; - if( m_projectionType == PROJECTION_ORTHO ) + if( m_projectionType == PROJECTION_TYPE::ORTHO ) { // With the ortographic projection, there is just a zoom factor const float panFactor = m_zoom / 37.5f; // Magic number from CCAMERA::rebuildProjection m_camera_pos.x -= panFactor * ( m_lastPosition.x - aNewMousePosition.x ); m_camera_pos.y -= panFactor * ( aNewMousePosition.y - m_lastPosition.y ); } - else // PROJECTION_PERSPECTIVE + else // PROJECTION_TYPE::PERSPECTIVE { // Unproject the coordinates using the precomputed frustum tangent (zoom level dependent) const float panFactor = -m_camera_pos.z * m_frustum.tang * 2; @@ -169,15 +169,15 @@ void CTRACK_BALL::Interpolate( float t ) switch( m_interpolation_mode ) { - case INTERPOLATION_BEZIER: + case CAMERA_INTERPOLATION::BEZIER: t = BezierBlend( t ); break; - case INTERPOLATION_EASING_IN_OUT: + case CAMERA_INTERPOLATION::EASING_IN_OUT: t = QuadricEasingInOut( t ); break; - case INTERPOLATION_LINEAR: + case CAMERA_INTERPOLATION::LINEAR: default: break; } diff --git a/3d-viewer/3d_viewer/3d_menubar.cpp b/3d-viewer/3d_viewer/3d_menubar.cpp index 0054a58ab1..07221e24b7 100644 --- a/3d-viewer/3d_viewer/3d_menubar.cpp +++ b/3d-viewer/3d_viewer/3d_menubar.cpp @@ -124,48 +124,77 @@ void EDA_3D_VIEWER::CreateMenuBar() // CONDITIONAL_MENU* prefsMenu = new CONDITIONAL_MENU( false, tool ); - auto raytracingCondition = [ this ] ( const SELECTION& aSel ) { - return m_settings.RenderEngineGet() != RENDER_ENGINE_OPENGL_LEGACY; + //clang-format off + auto raytracingCondition = [this]( const SELECTION& aSel ) + { + return m_settings.RenderEngineGet() != RENDER_ENGINE::OPENGL_LEGACY; }; - auto NormalModeCondition = [ this ] ( const SELECTION& aSel ) { - return m_settings.MaterialModeGet() == MATERIAL_MODE_NORMAL; + + auto NormalModeCondition = [this]( const SELECTION& aSel ) + { + return m_settings.MaterialModeGet() == MATERIAL_MODE::NORMAL; }; - auto DiffuseModeCondition = [ this ] ( const SELECTION& aSel ) { - return m_settings.MaterialModeGet() == MATERIAL_MODE_DIFFUSE_ONLY; + + auto DiffuseModeCondition = [this]( const SELECTION& aSel ) + { + return m_settings.MaterialModeGet() == MATERIAL_MODE::DIFFUSE_ONLY; }; - auto CADModeCondition = [ this ] ( const SELECTION& aSel ) { - return m_settings.MaterialModeGet() == MATERIAL_MODE_CAD_MODE; + + auto CADModeCondition = [this]( const SELECTION& aSel ) + { + return m_settings.MaterialModeGet() == MATERIAL_MODE::CAD_MODE; }; - auto copperThicknessCondition = [ this ] ( const SELECTION& aSel ) { + + auto copperThicknessCondition = [this]( const SELECTION& aSel ) + { return m_settings.GetFlag( FL_RENDER_OPENGL_COPPER_THICKNESS ); }; - auto boundingBoxesCondition = [ this ] ( const SELECTION& aSel ) { + + auto boundingBoxesCondition = [this]( const SELECTION& aSel ) + { return m_settings.GetFlag( FL_RENDER_OPENGL_SHOW_MODEL_BBOX ); }; - auto renderShadowsCondition = [ this ] ( const SELECTION& aSel ) { + + auto renderShadowsCondition = [this]( const SELECTION& aSel ) + { return m_settings.GetFlag( FL_RENDER_RAYTRACING_SHADOWS ); }; - auto proceduralTexturesCondition = [ this ] ( const SELECTION& aSel ) { + + auto proceduralTexturesCondition = [this]( const SELECTION& aSel ) + { return m_settings.GetFlag( FL_RENDER_RAYTRACING_PROCEDURAL_TEXTURES ); }; - auto showFloorCondition = [ this ] ( const SELECTION& aSel ) { + + auto showFloorCondition = [this]( const SELECTION& aSel ) + { return m_settings.GetFlag( FL_RENDER_RAYTRACING_BACKFLOOR ); }; - auto useRefractionsCondition = [ this ] ( const SELECTION& aSel ) { + + auto useRefractionsCondition = [this]( const SELECTION& aSel ) + { return m_settings.GetFlag( FL_RENDER_RAYTRACING_REFRACTIONS ); }; - auto useReflectionsCondition = [ this ] ( const SELECTION& aSel ) { + + auto useReflectionsCondition = [this]( const SELECTION& aSel ) + { return m_settings.GetFlag( FL_RENDER_RAYTRACING_REFLECTIONS ); }; - auto antiAliasingCondition = [ this ] ( const SELECTION& aSel ) { + + auto antiAliasingCondition = [this]( const SELECTION& aSel ) + { return m_settings.GetFlag( FL_RENDER_RAYTRACING_ANTI_ALIASING ); }; - auto postProcessCondition = [ this ] ( const SELECTION& aSel ) { + + auto postProcessCondition = [this]( const SELECTION& aSel ) + { return m_settings.GetFlag( FL_RENDER_RAYTRACING_POST_PROCESSING ); }; - auto showAxesCondition = [ this ] ( const SELECTION& aSel ) { + + auto showAxesCondition = [this]( const SELECTION& aSel ) + { return m_settings.GetFlag( FL_AXIS ); }; + //clang-format on prefsMenu->AddItem( ID_TOOL_SET_VISIBLE_ITEMS, _( "Display Options" ), "", read_setup_xpm, SELECTION_CONDITIONS::ShowAlways ); @@ -289,21 +318,32 @@ void EDA_3D_VIEWER::CreateMenuBar() gridSubmenu->SetTitle( _( "3D Grid" ) ); gridSubmenu->SetIcon( grid_xpm ); - auto noGridCondition = [ this ] ( const SELECTION& aSel ) { - return m_settings.GridGet() == GRID3D_NONE; + //clang-format off + auto noGridCondition = [this]( const SELECTION& aSel ) + { + return m_settings.GridGet() == GRID3D_TYPE::NONE; }; - auto grid10mmCondition = [ this ] ( const SELECTION& aSel ) { - return m_settings.GridGet() == GRID3D_10MM; + + auto grid10mmCondition = [this]( const SELECTION& aSel ) + { + return m_settings.GridGet() == GRID3D_TYPE::GRID_10MM; }; - auto grid5mmCondition = [ this ] ( const SELECTION& aSel ) { - return m_settings.GridGet() == GRID3D_5MM; + + auto grid5mmCondition = [this]( const SELECTION& aSel ) + { + return m_settings.GridGet() == GRID3D_TYPE::GRID_5MM; }; - auto grid2p5mmCondition = [ this ] ( const SELECTION& aSel ) { - return m_settings.GridGet() == GRID3D_2P5MM; + + auto grid2p5mmCondition = [this]( const SELECTION& aSel ) + { + return m_settings.GridGet() == GRID3D_TYPE::GRID_2P5MM; }; - auto grid_1mmCondition = [ this ] ( const SELECTION& aSel ) { - return m_settings.GridGet() == GRID3D_1MM; + + auto grid_1mmCondition = [this]( const SELECTION& aSel ) + { + return m_settings.GridGet() == GRID3D_TYPE::GRID_1MM; }; + //clang-format on gridSubmenu->AddCheckItem( ID_MENU3D_GRID_NOGRID, _( "No 3D Grid" ), "", nullptr, noGridCondition ); diff --git a/3d-viewer/3d_viewer/eda_3d_viewer.cpp b/3d-viewer/3d_viewer/eda_3d_viewer.cpp index bdbd917a39..a7cf491092 100644 --- a/3d-viewer/3d_viewer/eda_3d_viewer.cpp +++ b/3d-viewer/3d_viewer/eda_3d_viewer.cpp @@ -285,7 +285,7 @@ void EDA_3D_VIEWER::Process_Special_Functions( wxCommandEvent &event ) case ID_ROTATE3D_X_POS: m_settings.CameraGet().RotateX( glm::radians(ROT_ANGLE) ); - if( m_settings.RenderEngineGet() == RENDER_ENGINE_OPENGL_LEGACY ) + if( m_settings.RenderEngineGet() == RENDER_ENGINE::OPENGL_LEGACY ) m_canvas->Request_refresh(); else m_canvas->RenderRaytracingRequest(); @@ -295,7 +295,7 @@ void EDA_3D_VIEWER::Process_Special_Functions( wxCommandEvent &event ) case ID_ROTATE3D_X_NEG: m_settings.CameraGet().RotateX( -glm::radians(ROT_ANGLE) ); - if( m_settings.RenderEngineGet() == RENDER_ENGINE_OPENGL_LEGACY ) + if( m_settings.RenderEngineGet() == RENDER_ENGINE::OPENGL_LEGACY ) m_canvas->Request_refresh(); else m_canvas->RenderRaytracingRequest(); @@ -305,7 +305,7 @@ void EDA_3D_VIEWER::Process_Special_Functions( wxCommandEvent &event ) case ID_ROTATE3D_Y_POS: m_settings.CameraGet().RotateY( glm::radians(ROT_ANGLE) ); - if( m_settings.RenderEngineGet() == RENDER_ENGINE_OPENGL_LEGACY ) + if( m_settings.RenderEngineGet() == RENDER_ENGINE::OPENGL_LEGACY ) m_canvas->Request_refresh(); else m_canvas->RenderRaytracingRequest(); @@ -315,7 +315,7 @@ void EDA_3D_VIEWER::Process_Special_Functions( wxCommandEvent &event ) case ID_ROTATE3D_Y_NEG: m_settings.CameraGet().RotateY( -glm::radians(ROT_ANGLE) ); - if( m_settings.RenderEngineGet() == RENDER_ENGINE_OPENGL_LEGACY ) + if( m_settings.RenderEngineGet() == RENDER_ENGINE::OPENGL_LEGACY ) m_canvas->Request_refresh(); else m_canvas->RenderRaytracingRequest(); @@ -325,7 +325,7 @@ void EDA_3D_VIEWER::Process_Special_Functions( wxCommandEvent &event ) case ID_ROTATE3D_Z_POS: m_settings.CameraGet().RotateZ( glm::radians(ROT_ANGLE) ); - if( m_settings.RenderEngineGet() == RENDER_ENGINE_OPENGL_LEGACY ) + if( m_settings.RenderEngineGet() == RENDER_ENGINE::OPENGL_LEGACY ) m_canvas->Request_refresh(); else m_canvas->RenderRaytracingRequest(); @@ -335,7 +335,7 @@ void EDA_3D_VIEWER::Process_Special_Functions( wxCommandEvent &event ) case ID_ROTATE3D_Z_NEG: m_settings.CameraGet().RotateZ( -glm::radians(ROT_ANGLE) ); - if( m_settings.RenderEngineGet() == RENDER_ENGINE_OPENGL_LEGACY ) + if( m_settings.RenderEngineGet() == RENDER_ENGINE::OPENGL_LEGACY ) m_canvas->Request_refresh(); else m_canvas->RenderRaytracingRequest(); @@ -373,7 +373,7 @@ void EDA_3D_VIEWER::Process_Special_Functions( wxCommandEvent &event ) if( Set3DColorFromUser( m_settings.m_BgColorBot, _( "Background Color, Bottom" ), nullptr ) ) { - if( m_settings.RenderEngineGet() == RENDER_ENGINE_OPENGL_LEGACY ) + if( m_settings.RenderEngineGet() == RENDER_ENGINE::OPENGL_LEGACY ) m_canvas->Request_refresh(); else NewDisplay( true ); @@ -383,7 +383,7 @@ void EDA_3D_VIEWER::Process_Special_Functions( wxCommandEvent &event ) case ID_MENU3D_BGCOLOR_TOP: if( Set3DColorFromUser( m_settings.m_BgColorTop, _( "Background Color, Top" ), nullptr ) ) { - if( m_settings.RenderEngineGet() == RENDER_ENGINE_OPENGL_LEGACY ) + if( m_settings.RenderEngineGet() == RENDER_ENGINE::OPENGL_LEGACY ) m_canvas->Request_refresh(); else NewDisplay( true ); @@ -416,17 +416,17 @@ void EDA_3D_VIEWER::Process_Special_Functions( wxCommandEvent &event ) return; case ID_MENU3D_FL_RENDER_MATERIAL_MODE_NORMAL: - m_settings.MaterialModeSet( MATERIAL_MODE_NORMAL ); + m_settings.MaterialModeSet( MATERIAL_MODE::NORMAL ); NewDisplay( true ); return; case ID_MENU3D_FL_RENDER_MATERIAL_MODE_DIFFUSE_ONLY: - m_settings.MaterialModeSet( MATERIAL_MODE_DIFFUSE_ONLY ); + m_settings.MaterialModeSet( MATERIAL_MODE::DIFFUSE_ONLY ); NewDisplay( true ); return; case ID_MENU3D_FL_RENDER_MATERIAL_MODE_CAD_MODE: - m_settings.MaterialModeSet( MATERIAL_MODE_CAD_MODE ); + m_settings.MaterialModeSet( MATERIAL_MODE::CAD_MODE ); NewDisplay( true ); return; @@ -567,13 +567,24 @@ void EDA_3D_VIEWER::On3DGridSelection( wxCommandEvent &event ) switch( id ) { - case ID_MENU3D_GRID_NOGRID: m_settings.GridSet( GRID3D_NONE ); break; - case ID_MENU3D_GRID_10_MM: m_settings.GridSet( GRID3D_10MM ); break; - case ID_MENU3D_GRID_5_MM: m_settings.GridSet( GRID3D_5MM ); break; - case ID_MENU3D_GRID_2P5_MM: m_settings.GridSet( GRID3D_2P5MM ); break; - case ID_MENU3D_GRID_1_MM: m_settings.GridSet( GRID3D_1MM ); break; + case ID_MENU3D_GRID_NOGRID: + m_settings.GridSet( GRID3D_TYPE::NONE ); + break; + case ID_MENU3D_GRID_10_MM: + m_settings.GridSet( GRID3D_TYPE::GRID_10MM ); + break; + case ID_MENU3D_GRID_5_MM: + m_settings.GridSet( GRID3D_TYPE::GRID_5MM ); + break; + case ID_MENU3D_GRID_2P5_MM: + m_settings.GridSet( GRID3D_TYPE::GRID_2P5MM ); + break; + case ID_MENU3D_GRID_1_MM: + m_settings.GridSet( GRID3D_TYPE::GRID_1MM ); + break; - default: wxFAIL_MSG( "Invalid event in EDA_3D_VIEWER::On3DGridSelection()" ); + default: + wxFAIL_MSG( "Invalid event in EDA_3D_VIEWER::On3DGridSelection()" ); } int menu_ids[] @@ -600,14 +611,14 @@ void EDA_3D_VIEWER::OnRenderEngineSelection( wxCommandEvent &event ) { const RENDER_ENGINE old_engine = m_settings.RenderEngineGet(); - if( old_engine == RENDER_ENGINE_OPENGL_LEGACY ) - m_settings.RenderEngineSet( RENDER_ENGINE_RAYTRACING ); + if( old_engine == RENDER_ENGINE::OPENGL_LEGACY ) + m_settings.RenderEngineSet( RENDER_ENGINE::RAYTRACING ); else - m_settings.RenderEngineSet( RENDER_ENGINE_OPENGL_LEGACY ); + m_settings.RenderEngineSet( RENDER_ENGINE::OPENGL_LEGACY ); wxLogTrace( m_logTrace, "EDA_3D_VIEWER::OnRenderEngineSelection type %s ", - ( m_settings.RenderEngineGet() == RENDER_ENGINE_RAYTRACING ) ? - "Ray Trace" : "OpenGL Legacy" ); + ( m_settings.RenderEngineGet() == RENDER_ENGINE::RAYTRACING ) ? "Ray Trace" : + "OpenGL Legacy" ); if( old_engine != m_settings.RenderEngineGet() ) { @@ -643,7 +654,7 @@ void EDA_3D_VIEWER::OnDisableRayTracing( wxCommandEvent& aEvent ) wxLogTrace( m_logTrace, "EDA_3D_VIEWER::%s disabling ray tracing.", __WXFUNCTION__ ); m_disable_ray_tracing = true; - m_settings.RenderEngineSet( RENDER_ENGINE_OPENGL_LEGACY ); + m_settings.RenderEngineSet( RENDER_ENGINE::OPENGL_LEGACY ); } @@ -786,16 +797,17 @@ void EDA_3D_VIEWER::LoadSettings( wxConfigBase *aCfg ) m_settings.SetFlag( FL_SHOW_BOARD_BODY, tmp ); int tmpi; - aCfg->Read( keyShowGrid, &tmpi, (int)GRID3D_NONE ); - m_settings.GridSet( (GRID3D_TYPE)tmpi ); + aCfg->Read( keyShowGrid, &tmpi, static_cast( GRID3D_TYPE::NONE ) ); + m_settings.GridSet( static_cast( tmpi ) ); - aCfg->Read( keyRenderEngine, &tmpi, (int)RENDER_ENGINE_OPENGL_LEGACY ); + aCfg->Read( keyRenderEngine, &tmpi, static_cast( RENDER_ENGINE::OPENGL_LEGACY ) ); wxLogTrace( m_logTrace, "EDA_3D_VIEWER::LoadSettings render setting %s", - ( (RENDER_ENGINE)tmpi == RENDER_ENGINE_RAYTRACING ) ? "Ray Trace" : "OpenGL" ); - m_settings.RenderEngineSet( (RENDER_ENGINE)tmpi ); + ( static_cast( tmpi ) == RENDER_ENGINE::RAYTRACING ) ? "Ray Trace" : + "OpenGL" ); + m_settings.RenderEngineSet( static_cast( tmpi ) ); - aCfg->Read( keyRenderMaterial, &tmpi, (int)MATERIAL_MODE_NORMAL ); - m_settings.MaterialModeSet( (MATERIAL_MODE)tmpi ); + aCfg->Read( keyRenderMaterial, &tmpi, static_cast( MATERIAL_MODE::NORMAL ) ); + m_settings.MaterialModeSet( static_cast( tmpi ) ); } @@ -835,9 +847,10 @@ void EDA_3D_VIEWER::SaveSettings( wxConfigBase *aCfg ) aCfg->Write( keyShowRealisticMode, m_settings.GetFlag( FL_USE_REALISTIC_MODE ) ); - aCfg->Write( keyRenderEngine, (int)m_settings.RenderEngineGet() ); + aCfg->Write( keyRenderEngine, static_cast( m_settings.RenderEngineGet() ) ); wxLogTrace( m_logTrace, "EDA_3D_VIEWER::SaveSettings render setting %s", - ( m_settings.RenderEngineGet() == RENDER_ENGINE_RAYTRACING ) ? "Ray Trace" : "OpenGL" ); + ( m_settings.RenderEngineGet() == RENDER_ENGINE::RAYTRACING ) ? "Ray Trace" : + "OpenGL" ); aCfg->Write( keyRenderMaterial, (int)m_settings.MaterialModeGet() ); @@ -1121,7 +1134,7 @@ bool EDA_3D_VIEWER::Set3DSolderPasteColorFromUser() void EDA_3D_VIEWER::OnUpdateUIEngine( wxUpdateUIEvent& aEvent ) { - aEvent.Check( m_settings.RenderEngineGet() != RENDER_ENGINE_OPENGL_LEGACY ); + aEvent.Check( m_settings.RenderEngineGet() != RENDER_ENGINE::OPENGL_LEGACY ); } @@ -1131,15 +1144,15 @@ void EDA_3D_VIEWER::OnUpdateUIMaterial( wxUpdateUIEvent& aEvent ) switch( aEvent.GetId() ) { case ID_MENU3D_FL_RENDER_MATERIAL_MODE_NORMAL: - aEvent.Check( m_settings.MaterialModeGet() == MATERIAL_MODE_NORMAL ); + aEvent.Check( m_settings.MaterialModeGet() == MATERIAL_MODE::NORMAL ); break; case ID_MENU3D_FL_RENDER_MATERIAL_MODE_DIFFUSE_ONLY: - aEvent.Check( m_settings.MaterialModeGet() == MATERIAL_MODE_DIFFUSE_ONLY ); + aEvent.Check( m_settings.MaterialModeGet() == MATERIAL_MODE::DIFFUSE_ONLY ); break; case ID_MENU3D_FL_RENDER_MATERIAL_MODE_CAD_MODE: - aEvent.Check( m_settings.MaterialModeGet() == MATERIAL_MODE_CAD_MODE ); + aEvent.Check( m_settings.MaterialModeGet() == MATERIAL_MODE::CAD_MODE ); break; default: diff --git a/include/gbr_netlist_metadata.h b/include/gbr_netlist_metadata.h index 7709c67fdb..82b6edf48f 100644 --- a/include/gbr_netlist_metadata.h +++ b/include/gbr_netlist_metadata.h @@ -33,7 +33,7 @@ * The rotation angle is consistent with the one for graphics objects. * Positive rotation is counter- clockwise as viewed from the top side, even if * the component is on the board side. - * The base orientation of component – no rotation - on the top side is as in IPC-7351. + * The base orientation of component - no rotation - on the top side is as in IPC-7351. * Components on the bottom side are of course mirrored. * The base orientation on the bottom side is the one on the top side * mirrored around the X axis.