3D-viewer: raytracing, implement multiple shape board.

Fixes #1879 (lp:1820099)
Fixes #2126 (lp:1764039)
This commit is contained in:
Mario Luzeiro 2020-01-04 20:50:37 +00:00 committed by Ian McInerney
parent 772835e3e3
commit 37c3e34486
3 changed files with 21 additions and 15 deletions

View File

@ -275,7 +275,9 @@ void C3D_RENDER_RAYTRACING::reload( REPORTER *aStatusTextReporter )
m_outlineBoard2dObjects = new CCONTAINER2D;
if( ((const SHAPE_POLY_SET &)m_settings.GetBoardPoly()).OutlineCount() == 1 )
const int outlineCount = m_settings.GetBoardPoly().OutlineCount();
if( outlineCount > 0 )
{
float divFactor = 0.0f;
@ -288,12 +290,16 @@ void C3D_RENDER_RAYTRACING::reload( REPORTER *aStatusTextReporter )
SHAPE_POLY_SET boardPolyCopy = m_settings.GetBoardPoly();
boardPolyCopy.Fracture( SHAPE_POLY_SET::PM_FAST );
Convert_path_polygon_to_polygon_blocks_and_dummy_blocks(
boardPolyCopy,
*m_outlineBoard2dObjects,
m_settings.BiuTo3Dunits(),
divFactor,
(const BOARD_ITEM &)*m_settings.GetBoard() );
for( int iOutlinePolyIdx = 0; iOutlinePolyIdx < outlineCount; iOutlinePolyIdx++ )
{
Convert_path_polygon_to_polygon_blocks_and_dummy_blocks(
boardPolyCopy,
*m_outlineBoard2dObjects,
m_settings.BiuTo3Dunits(),
divFactor,
*dynamic_cast<const BOARD_ITEM*>( m_settings.GetBoard() ),
iOutlinePolyIdx );
}
if( m_settings.GetFlag( FL_SHOW_BOARD_BODY ) )
{

View File

@ -406,17 +406,16 @@ void Convert_path_polygon_to_polygon_blocks_and_dummy_blocks(
CGENERICCONTAINER2D &aDstContainer,
float aBiuTo3DunitsScale,
float aDivFactor,
const BOARD_ITEM &aBoardItem )
const BOARD_ITEM &aBoardItem,
int aPolyIndex )
{
BOX2I pathBounds = aMainPath.BBox();
// Get the path
wxASSERT( aMainPath.OutlineCount() == 1 );
const SHAPE_POLY_SET::POLYGON& curr_polywithholes = aMainPath.CPolygon( 0 );
wxASSERT( aPolyIndex < aMainPath.OutlineCount() );
wxASSERT( curr_polywithholes.size() == 1 );
const SHAPE_LINE_CHAIN& path = curr_polywithholes[0]; // a simple polygon
const SHAPE_LINE_CHAIN& path = aMainPath.COutline( aPolyIndex );
BOX2I pathBounds = path.BBox();
// Convert the points to segments class
CBBOX2D bbox;

View File

@ -148,7 +148,8 @@ void Convert_path_polygon_to_polygon_blocks_and_dummy_blocks(
CGENERICCONTAINER2D &aDstContainer,
float aBiuTo3DunitsScale,
float aDivFactor,
const BOARD_ITEM &aBoardItem );
const BOARD_ITEM &aBoardItem,
int aPolyIndex );
void Polygon2d_TestModule();