From eed7ede376fea7310a10f5c2264df11b1e9be314 Mon Sep 17 00:00:00 2001 From: Marek Roszko Date: Tue, 14 Feb 2023 19:43:31 -0500 Subject: [PATCH] Fix step colors some more Fixes https://gitlab.com/kicad/code/kicad/-/issues/13611 I need to refactor the overall structure and know what to do, but ugh lazy (cherry picked from commit c6540575b5a30ac968b01dd4ea1b15e7b5d7df56) --- plugins/3d/oce/loadmodel.cpp | 58 +++++++++++++++++++----------------- plugins/3d/oce/oce.cpp | 2 +- 2 files changed, 31 insertions(+), 29 deletions(-) diff --git a/plugins/3d/oce/loadmodel.cpp b/plugins/3d/oce/loadmodel.cpp index b121f07815..e75e4cb076 100644 --- a/plugins/3d/oce/loadmodel.cpp +++ b/plugins/3d/oce/loadmodel.cpp @@ -800,7 +800,7 @@ bool processShell( const TopoDS_Shape& shape, DATA& data, SGNODE* parent, } -bool processSolid( const TopoDS_Shape& shape, DATA& data, SGNODE* parent, +bool processSolidOrShell( const TopoDS_Shape& shape, DATA& data, SGNODE* parent, std::vector< SGNODE* >* items ) { TDF_Label label; @@ -887,21 +887,31 @@ bool processSolid( const TopoDS_Shape& shape, DATA& data, SGNODE* parent, items->push_back( pptr ); } - // instantiate the solid - std::vector< SGNODE* > itemList; + // instantiate resulting object + std::vector itemList; - for( it.Initialize( shape, false, false ); it.More(); it.Next() ) + TopAbs_ShapeEnum stype = shape.ShapeType(); + if( stype == TopAbs_SHELL ) + { + if( processShell( shape, data, pptr, &itemList, lcolor ) ) + ret = true; + } + else { - const TopoDS_Shape& subShape = it.Value(); - if( subShape.ShapeType() == TopAbs_SHELL ) + for( it.Initialize( shape, false, false ); it.More(); it.Next() ) { - if( processShell( subShape, data, pptr, &itemList, lcolor ) ) - ret = true; - } - else - { - wxLogTrace( MASK_OCE, wxT( "Unsupported subshape in solid" ) ); + const TopoDS_Shape& subShape = it.Value(); + + if( subShape.ShapeType() == TopAbs_SHELL ) + { + if( processShell( subShape, data, pptr, &itemList, lcolor ) ) + ret = true; + } + else + { + wxLogTrace( MASK_OCE, wxT( "Unsupported subshape in solid" ) ); + } } } @@ -996,14 +1006,14 @@ bool processLabel( const TDF_Label& aLabel, DATA& aData, SGNODE* aParent, for( xp.Init( shape, TopAbs_SOLID ); xp.More(); xp.Next() ) { - processSolid( xp.Current(), aData, pptr, aItems ); + processSolidOrShell( xp.Current(), aData, pptr, aItems ); ret = true; } // Get all shells, avoid those that may be attached to solids for( xp.Init( shape, TopAbs_SHELL, TopAbs_SOLID ); xp.More(); xp.Next() ) { - processShell( xp.Current(), aData, pptr, aItems, nullptr ); + processSolidOrShell( xp.Current(), aData, pptr, aItems ); ret = true; } @@ -1019,13 +1029,13 @@ bool processLabel( const TDF_Label& aLabel, DATA& aData, SGNODE* aParent, break; case TopAbs_SOLID: - if( processSolid( shape, aData, pptr, aItems ) ) + if( processSolidOrShell( shape, aData, pptr, aItems ) ) ret = true; break; case TopAbs_SHELL: - if( processShell( shape, aData, pptr, aItems, nullptr ) ) + if( processSolidOrShell( shape, aData, pptr, aItems ) ) ret = true; break; @@ -1130,18 +1140,10 @@ bool processFace( const TopoDS_Face& face, DATA& data, SGNODE* parent, std::vect Quantity_ColorRGBA lcolor; // check for a face color; this has precedence over SOLID colors - do - { - TDF_Label L; - - if( data.m_color->ShapeTool()->Search( face, L ) ) - { - if( data.m_color->GetColor( L, XCAFDoc_ColorGen, lcolor ) - || data.m_color->GetColor( L, XCAFDoc_ColorCurv, lcolor ) - || data.m_color->GetColor( L, XCAFDoc_ColorSurf, lcolor ) ) - color = &lcolor; - } - } while( 0 ); + if( data.m_color->GetColor( face, XCAFDoc_ColorGen, lcolor ) + || data.m_color->GetColor( face, XCAFDoc_ColorCurv, lcolor ) + || data.m_color->GetColor( face, XCAFDoc_ColorSurf, lcolor ) ) + color = &lcolor; SGNODE* ocolor = data.GetColor( color ); diff --git a/plugins/3d/oce/oce.cpp b/plugins/3d/oce/oce.cpp index fcbcd9f628..833df5515a 100644 --- a/plugins/3d/oce/oce.cpp +++ b/plugins/3d/oce/oce.cpp @@ -37,7 +37,7 @@ SCENEGRAPH* LoadModel( char const* filename ); #define PLUGIN_OCE_MAJOR 1 #define PLUGIN_OCE_MINOR 4 -#define PLUGIN_OCE_PATCH 1 +#define PLUGIN_OCE_PATCH 2 #define PLUGIN_OCE_REVNO 0