diff --git a/3d-viewer/3d_rendering/opengl/create_scene.cpp b/3d-viewer/3d_rendering/opengl/create_scene.cpp index b19b6cfd13..f087934d96 100644 --- a/3d-viewer/3d_rendering/opengl/create_scene.cpp +++ b/3d-viewer/3d_rendering/opengl/create_scene.cpp @@ -150,8 +150,7 @@ void RENDER_3D_OPENGL::addObjectTriangles( const RING_2D* aRing, TRIANGLE_DISPLA } -void RENDER_3D_OPENGL::addObjectTriangles( const TRIANGLE_2D* aTri, - TRIANGLE_DISPLAY_LIST* aDstLayer, +void RENDER_3D_OPENGL::addObjectTriangles( const TRIANGLE_2D* aTri, TRIANGLE_DISPLAY_LIST* aDstLayer, float aZtop, float aZbot ) { const SFVEC2F& v1 = aTri->GetP1(); @@ -248,64 +247,52 @@ void RENDER_3D_OPENGL::addObjectTriangles( const ROUND_SEGMENT_2D* aSeg, OPENGL_RENDER_LIST* RENDER_3D_OPENGL::generateHoles( const LIST_OBJECT2D& aListHolesObject2d, - const SHAPE_POLY_SET& aPoly, float aZtop, - float aZbot, bool aInvertFaces, - const BVH_CONTAINER_2D* aThroughHoles ) + const SHAPE_POLY_SET& aPoly, float aZtop, float aZbot, + bool aInvertFaces, const BVH_CONTAINER_2D* aThroughHoles ) { - OPENGL_RENDER_LIST* ret = nullptr; + if( aListHolesObject2d.size() == 0 ) + return nullptr; - if( aListHolesObject2d.size() > 0 ) + OPENGL_RENDER_LIST* ret = nullptr; + TRIANGLE_DISPLAY_LIST* layerTriangles = new TRIANGLE_DISPLAY_LIST( aListHolesObject2d.size() * 2 ); + + // Convert the list of objects(filled circles) to triangle layer structure + for( const OBJECT_2D* object2d : aListHolesObject2d ) { - TRIANGLE_DISPLAY_LIST* layerTriangles = - new TRIANGLE_DISPLAY_LIST( aListHolesObject2d.size() * 2 ); - - // Convert the list of objects(filled circles) to triangle layer structure - for( const OBJECT_2D* itemOnLayer : aListHolesObject2d ) + switch( object2d->GetObjectType() ) { - const OBJECT_2D* object2d_A = itemOnLayer; + case OBJECT_2D_TYPE::FILLED_CIRCLE: + addObjectTriangles( static_cast( object2d ), layerTriangles, aZtop, aZbot ); + break; - wxASSERT( ( object2d_A->GetObjectType() == OBJECT_2D_TYPE::FILLED_CIRCLE ) - || ( object2d_A->GetObjectType() == OBJECT_2D_TYPE::ROUNDSEG ) ); + case OBJECT_2D_TYPE::ROUNDSEG: + addObjectTriangles( static_cast( object2d ), layerTriangles, aZtop, aZbot ); + break; - switch( object2d_A->GetObjectType() ) - { - case OBJECT_2D_TYPE::FILLED_CIRCLE: - addObjectTriangles( static_cast( object2d_A ), - layerTriangles, aZtop, aZbot ); - break; - - case OBJECT_2D_TYPE::ROUNDSEG: - addObjectTriangles( static_cast( object2d_A ), - layerTriangles, aZtop, aZbot ); - break; - - default: - wxFAIL_MSG( wxT( "RENDER_3D_OPENGL::generateHoles: Object type not implemented" ) ); - break; - } + default: + wxFAIL_MSG( wxT( "RENDER_3D_OPENGL::generateHoles: Object type not implemented" ) ); + break; } - - // Note: he can have a aListHolesObject2d with holes but without contours - // eg: when there are only NPTH on the list and the contours were not added - if( aPoly.OutlineCount() > 0 ) - { - layerTriangles->AddToMiddleContourns( aPoly, aZbot, aZtop, - m_boardAdapter.BiuTo3dUnits(), - aInvertFaces, aThroughHoles ); - } - - ret = new OPENGL_RENDER_LIST( *layerTriangles, m_circleTexture, aZbot, aZtop ); - - delete layerTriangles; } + // Note: he can have a aListHolesObject2d with holes but without contours + // eg: when there are only NPTH on the list and the contours were not added + if( aPoly.OutlineCount() > 0 ) + { + layerTriangles->AddToMiddleContours( aPoly, aZbot, aZtop, m_boardAdapter.BiuTo3dUnits(), aInvertFaces, + aThroughHoles ); + } + + ret = new OPENGL_RENDER_LIST( *layerTriangles, m_circleTexture, aZbot, aZtop ); + + delete layerTriangles; + return ret; } OPENGL_RENDER_LIST* RENDER_3D_OPENGL::generateLayerList( const BVH_CONTAINER_2D* aContainer, - const SHAPE_POLY_SET* aPolyList, - PCB_LAYER_ID aLayer, + const SHAPE_POLY_SET* aPolyList, PCB_LAYER_ID aLayer, const BVH_CONTAINER_2D* aThroughHoles ) { if( aContainer == nullptr ) @@ -316,10 +303,10 @@ OPENGL_RENDER_LIST* RENDER_3D_OPENGL::generateLayerList( const BVH_CONTAINER_2D* if( listObject2d.size() == 0 ) return nullptr; - float layer_z_bot = 0.0f; - float layer_z_top = 0.0f; + float zBot = 0.0f; + float zTop = 0.0f; - getLayerZPos( aLayer, layer_z_top, layer_z_bot ); + getLayerZPos( aLayer, zTop, zBot ); // Calculate an estimation for the nr of triangles based on the nr of objects unsigned int nrTrianglesEstimation = listObject2d.size() * 8; @@ -330,35 +317,28 @@ OPENGL_RENDER_LIST* RENDER_3D_OPENGL::generateLayerList( const BVH_CONTAINER_2D* m_triangles.push_back( layerTriangles ); // Load the 2D (X,Y axis) component of shapes - for( const OBJECT_2D* itemOnLayer : listObject2d ) + for( const OBJECT_2D* object2d : listObject2d ) { - const OBJECT_2D* object2d_A = itemOnLayer; - - switch( object2d_A->GetObjectType() ) + switch( object2d->GetObjectType() ) { case OBJECT_2D_TYPE::FILLED_CIRCLE: - addObjectTriangles( static_cast( object2d_A ), - layerTriangles, layer_z_top, layer_z_bot ); + addObjectTriangles( static_cast( object2d ), layerTriangles, zTop, zBot ); break; case OBJECT_2D_TYPE::POLYGON4PT: - addObjectTriangles( static_cast( object2d_A ), - layerTriangles, layer_z_top, layer_z_bot ); + addObjectTriangles( static_cast( object2d ), layerTriangles, zTop, zBot ); break; case OBJECT_2D_TYPE::RING: - addObjectTriangles( static_cast( object2d_A ), - layerTriangles, layer_z_top, layer_z_bot ); + addObjectTriangles( static_cast( object2d ), layerTriangles, zTop, zBot ); break; case OBJECT_2D_TYPE::TRIANGLE: - addObjectTriangles( static_cast( object2d_A ), - layerTriangles, layer_z_top, layer_z_bot ); + addObjectTriangles( static_cast( object2d ), layerTriangles, zTop, zBot ); break; case OBJECT_2D_TYPE::ROUNDSEG: - addObjectTriangles( static_cast( object2d_A ), - layerTriangles, layer_z_top, layer_z_bot ); + addObjectTriangles( static_cast( object2d ), layerTriangles, zTop, zBot ); break; default: @@ -369,12 +349,12 @@ OPENGL_RENDER_LIST* RENDER_3D_OPENGL::generateLayerList( const BVH_CONTAINER_2D* if( aPolyList && aPolyList->OutlineCount() > 0 ) { - layerTriangles->AddToMiddleContourns( *aPolyList, layer_z_bot, layer_z_top, - m_boardAdapter.BiuTo3dUnits(), false, aThroughHoles ); + layerTriangles->AddToMiddleContours( *aPolyList, zBot, zTop, m_boardAdapter.BiuTo3dUnits(), false, + aThroughHoles ); } // Create display list - return new OPENGL_RENDER_LIST( *layerTriangles, m_circleTexture, layer_z_bot, layer_z_top ); + return new OPENGL_RENDER_LIST( *layerTriangles, m_circleTexture, zBot, zTop ); } @@ -433,9 +413,9 @@ OPENGL_RENDER_LIST* RENDER_3D_OPENGL::createBoard( const SHAPE_POLY_SET& aBoardP if( aBoardPoly.OutlineCount() > 0 ) { - layerTriangles->AddToMiddleContourns( aBoardPoly, layer_z_bot, layer_z_top, - m_boardAdapter.BiuTo3dUnits(), false, - aThroughHoles ); + layerTriangles->AddToMiddleContours( aBoardPoly, layer_z_bot, layer_z_top, + m_boardAdapter.BiuTo3dUnits(), false, + aThroughHoles ); dispLists = new OPENGL_RENDER_LIST( *layerTriangles, m_circleTexture, layer_z_top, layer_z_top ); @@ -722,8 +702,8 @@ void RENDER_3D_OPENGL::generateCylinder( const SFVEC2F& aCenter, float aInnerRad SFVEC3F( vi0.x, vi0.y, aZbot ) ); } - aDstLayer->AddToMiddleContourns( outerContour, aZbot, aZtop, true ); - aDstLayer->AddToMiddleContourns( innerContour, aZbot, aZtop, false ); + aDstLayer->AddToMiddleContours( outerContour, aZbot, aZtop, true ); + aDstLayer->AddToMiddleContours( innerContour, aZbot, aZtop, false ); } @@ -920,9 +900,9 @@ void RENDER_3D_OPENGL::generateViasAndPads() if( tht_outer_holes_poly.OutlineCount() > 0 ) { - layerTriangles->AddToMiddleContourns( tht_outer_holes_poly, - layer_z_bot, layer_z_top, - m_boardAdapter.BiuTo3dUnits(), false ); + layerTriangles->AddToMiddleContours( tht_outer_holes_poly, + layer_z_bot, layer_z_top, + m_boardAdapter.BiuTo3dUnits(), false ); m_padHoles = new OPENGL_RENDER_LIST( *layerTriangles, m_circleTexture, layer_z_top, layer_z_top ); diff --git a/3d-viewer/3d_rendering/opengl/layer_triangles.cpp b/3d-viewer/3d_rendering/opengl/layer_triangles.cpp index b3ec749c2c..a9c190cdf4 100644 --- a/3d-viewer/3d_rendering/opengl/layer_triangles.cpp +++ b/3d-viewer/3d_rendering/opengl/layer_triangles.cpp @@ -93,11 +93,11 @@ void TRIANGLE_LIST::AddNormal( const SFVEC3F& aN1, const SFVEC3F& aN2, const SFV TRIANGLE_DISPLAY_LIST::TRIANGLE_DISPLAY_LIST( unsigned int aNrReservedTriangles ) { - m_layer_top_segment_ends = new TRIANGLE_LIST( aNrReservedTriangles, false ); - m_layer_top_triangles = new TRIANGLE_LIST( aNrReservedTriangles, false ); - m_layer_middle_contourns_quads = new TRIANGLE_LIST( aNrReservedTriangles, true ); - m_layer_bot_triangles = new TRIANGLE_LIST( aNrReservedTriangles, false ); - m_layer_bot_segment_ends = new TRIANGLE_LIST( aNrReservedTriangles, false ); + m_layer_top_segment_ends = new TRIANGLE_LIST( aNrReservedTriangles, false ); + m_layer_top_triangles = new TRIANGLE_LIST( aNrReservedTriangles, false ); + m_layer_middle_contours_quads = new TRIANGLE_LIST( aNrReservedTriangles, true ); + m_layer_bot_triangles = new TRIANGLE_LIST( aNrReservedTriangles, false ); + m_layer_bot_segment_ends = new TRIANGLE_LIST( aNrReservedTriangles, false ); } @@ -109,8 +109,8 @@ TRIANGLE_DISPLAY_LIST::~TRIANGLE_DISPLAY_LIST() delete m_layer_top_triangles; m_layer_top_triangles = nullptr; - delete m_layer_middle_contourns_quads; - m_layer_middle_contourns_quads = nullptr; + delete m_layer_middle_contours_quads; + m_layer_middle_contours_quads = nullptr; delete m_layer_bot_triangles; m_layer_bot_triangles = nullptr; @@ -120,38 +120,38 @@ TRIANGLE_DISPLAY_LIST::~TRIANGLE_DISPLAY_LIST() } -void TRIANGLE_DISPLAY_LIST::AddToMiddleContourns( const std::vector< SFVEC2F >& aContournPoints, - float zBot, float zTop, bool aInvertFaceDirection, - const BVH_CONTAINER_2D* aThroughHoles ) +void TRIANGLE_DISPLAY_LIST::AddToMiddleContours( const std::vector& aContourPoints, + float zBot, float zTop, bool aInvertFaceDirection, + const BVH_CONTAINER_2D* aThroughHoles ) { - if( aContournPoints.size() >= 4 ) + if( aContourPoints.size() >= 4 ) { // Calculate normals of each segment of the contour - std::vector< SFVEC2F > contournNormals; + std::vector< SFVEC2F > contourNormals; - contournNormals.clear(); - contournNormals.resize( aContournPoints.size() - 1 ); + contourNormals.clear(); + contourNormals.resize( aContourPoints.size() - 1 ); if( aInvertFaceDirection ) { - for( unsigned int i = 0; i < ( aContournPoints.size() - 1 ); ++i ) + for( unsigned int i = 0; i < ( aContourPoints.size() - 1 ); ++i ) { - const SFVEC2F& v0 = aContournPoints[i + 0]; - const SFVEC2F& v1 = aContournPoints[i + 1]; + const SFVEC2F& v0 = aContourPoints[i + 0]; + const SFVEC2F& v1 = aContourPoints[i + 1]; const SFVEC2F n = glm::normalize( v1 - v0 ); - contournNormals[i] = SFVEC2F( n.y,-n.x ); + contourNormals[i] = SFVEC2F( n.y, -n.x ); } } else { - for( unsigned int i = 0; i < ( aContournPoints.size() - 1 ); ++i ) + for( unsigned int i = 0; i < ( aContourPoints.size() - 1 ); ++i ) { - const SFVEC2F& v0 = aContournPoints[i + 0]; - const SFVEC2F& v1 = aContournPoints[i + 1]; + const SFVEC2F& v0 = aContourPoints[i + 0]; + const SFVEC2F& v1 = aContourPoints[i + 1]; const SFVEC2F n = glm::normalize( v1 - v0 ); - contournNormals[i] = SFVEC2F( -n.y, n.x ); + contourNormals[i] = SFVEC2F( -n.y, n.x ); } } @@ -159,18 +159,18 @@ void TRIANGLE_DISPLAY_LIST::AddToMiddleContourns( const std::vector< SFVEC2F >& if( aInvertFaceDirection ) std::swap( zBot, zTop ); - const unsigned int nContournsToProcess = ( aContournPoints.size() - 1 ); + const unsigned int nContoursToProcess = ( aContourPoints.size() - 1 ); - for( unsigned int i = 0; i < nContournsToProcess; ++i ) + for( unsigned int i = 0; i < nContoursToProcess; ++i ) { SFVEC2F lastNormal; if( i > 0 ) - lastNormal = contournNormals[i - 1]; + lastNormal = contourNormals[i - 1]; else - lastNormal = contournNormals[nContournsToProcess - 1]; + lastNormal = contourNormals[nContoursToProcess - 1]; - SFVEC2F n0 = contournNormals[i]; + SFVEC2F n0 = contourNormals[i]; // Only interpolate the normal if the angle is closer if( glm::dot( n0, lastNormal ) > 0.5f ) @@ -178,12 +178,12 @@ void TRIANGLE_DISPLAY_LIST::AddToMiddleContourns( const std::vector< SFVEC2F >& SFVEC2F nextNormal; - if( i < (nContournsToProcess - 1) ) - nextNormal = contournNormals[i + 1]; + if( i < ( nContoursToProcess - 1) ) + nextNormal = contourNormals[i + 1]; else - nextNormal = contournNormals[0]; + nextNormal = contourNormals[0]; - SFVEC2F n1 = contournNormals[i]; + SFVEC2F n1 = contourNormals[i]; if( glm::dot( n1, nextNormal ) > 0.5f ) n1 = glm::normalize( n1 + nextNormal ); @@ -191,8 +191,8 @@ void TRIANGLE_DISPLAY_LIST::AddToMiddleContourns( const std::vector< SFVEC2F >& const SFVEC3F n3d0 = SFVEC3F( n0.x, n0.y, 0.0f ); const SFVEC3F n3d1 = SFVEC3F( n1.x, n1.y, 0.0f ); - const SFVEC2F& v0 = aContournPoints[i + 0]; - const SFVEC2F& v1 = aContournPoints[i + 1]; + const SFVEC2F& v0 = aContourPoints[i + 0]; + const SFVEC2F& v1 = aContourPoints[i + 1]; if( aThroughHoles && aThroughHoles->IntersectAny( RAYSEG2D( v0, v1 ) ) ) { @@ -201,33 +201,32 @@ void TRIANGLE_DISPLAY_LIST::AddToMiddleContourns( const std::vector< SFVEC2F >& else { std::lock_guard lock( m_middle_layer_lock ); - m_layer_middle_contourns_quads->AddQuad( SFVEC3F( v0.x, v0.y, zTop ), - SFVEC3F( v1.x, v1.y, zTop ), - SFVEC3F( v1.x, v1.y, zBot ), - SFVEC3F( v0.x, v0.y, zBot ) ); + m_layer_middle_contours_quads->AddQuad( SFVEC3F( v0.x, v0.y, zTop ), + SFVEC3F( v1.x, v1.y, zTop ), + SFVEC3F( v1.x, v1.y, zBot ), + SFVEC3F( v0.x, v0.y, zBot ) ); - m_layer_middle_contourns_quads->AddNormal( n3d0, n3d1, n3d1, n3d0 ); + m_layer_middle_contours_quads->AddNormal( n3d0, n3d1, n3d1, n3d0 ); } } } } -void TRIANGLE_DISPLAY_LIST::AddToMiddleContourns( const SHAPE_LINE_CHAIN& outlinePath, float zBot, - float zTop, double aBiuTo3Du, - bool aInvertFaceDirection, - const BVH_CONTAINER_2D* aThroughHoles ) +void TRIANGLE_DISPLAY_LIST::AddToMiddleContours( const SHAPE_LINE_CHAIN& outlinePath, float zBot, float zTop, + double aBiuTo3Du, bool aInvertFaceDirection, + const BVH_CONTAINER_2D* aThroughHoles ) { - std::vector< SFVEC2F >contournPoints; + std::vector contourPoints; - contournPoints.clear(); - contournPoints.reserve( outlinePath.PointCount() + 2 ); + contourPoints.clear(); + contourPoints.reserve( outlinePath.PointCount() + 2 ); const VECTOR2I& firstV = outlinePath.CPoint( 0 ); SFVEC2F lastV = SFVEC2F( firstV.x * aBiuTo3Du, -firstV.y * aBiuTo3Du ); - contournPoints.push_back( lastV ); + contourPoints.push_back( lastV ); for( unsigned int i = 1; i < (unsigned int)outlinePath.PointCount(); ++i ) { @@ -238,77 +237,73 @@ void TRIANGLE_DISPLAY_LIST::AddToMiddleContourns( const SHAPE_LINE_CHAIN& outlin if( vf != lastV ) // Do not add repeated points { lastV = vf; - contournPoints.push_back( vf ); + contourPoints.push_back( vf ); } } // Add first position of the list to close the path. - if( lastV != contournPoints[0] ) - contournPoints.push_back( contournPoints[0] ); + if( lastV != contourPoints[0] ) + contourPoints.push_back( contourPoints[0] ); - AddToMiddleContourns( contournPoints, zBot, zTop, aInvertFaceDirection, aThroughHoles ); + AddToMiddleContours( contourPoints, zBot, zTop, aInvertFaceDirection, aThroughHoles ); } -void TRIANGLE_DISPLAY_LIST::AddToMiddleContourns( const SHAPE_POLY_SET& aPolySet, float zBot, - float zTop, double aBiuTo3Du, - bool aInvertFaceDirection, - const BVH_CONTAINER_2D* aThroughHoles ) +void TRIANGLE_DISPLAY_LIST::AddToMiddleContours( const SHAPE_POLY_SET& aPolySet, float zBot, float zTop, + double aBiuTo3Du, bool aInvertFaceDirection, + const BVH_CONTAINER_2D* aThroughHoles ) { if( aPolySet.OutlineCount() == 0 ) return; // Calculate an estimation of points to reserve - unsigned int nrContournPointsToReserve = 0; + unsigned int nrContourPointsToReserve = 0; for( int i = 0; i < aPolySet.OutlineCount(); ++i ) { const SHAPE_LINE_CHAIN& pathOutline = aPolySet.COutline( i ); - nrContournPointsToReserve += pathOutline.PointCount(); + nrContourPointsToReserve += pathOutline.PointCount(); for( int h = 0; h < aPolySet.HoleCount( i ); ++h ) { const SHAPE_LINE_CHAIN& hole = aPolySet.CHole( i, h ); - nrContournPointsToReserve += hole.PointCount(); + nrContourPointsToReserve += hole.PointCount(); } } // Request to reserve more space - m_layer_middle_contourns_quads->Reserve_More( nrContournPointsToReserve * 2, true ); + m_layer_middle_contours_quads->Reserve_More( nrContourPointsToReserve * 2, true ); for( int i = 0; i < aPolySet.OutlineCount(); i++ ) { // Add outline const SHAPE_LINE_CHAIN& pathOutline = aPolySet.COutline( i ); - AddToMiddleContourns( pathOutline, zBot, zTop, aBiuTo3Du, aInvertFaceDirection, - aThroughHoles ); + AddToMiddleContours( pathOutline, zBot, zTop, aBiuTo3Du, aInvertFaceDirection, aThroughHoles ); // Add holes for this outline for( int h = 0; h < aPolySet.HoleCount( i ); ++h ) { const SHAPE_LINE_CHAIN& hole = aPolySet.CHole( i, h ); - AddToMiddleContourns( hole, zBot, zTop, aBiuTo3Du, aInvertFaceDirection, - aThroughHoles ); + AddToMiddleContours( hole, zBot, zTop, aBiuTo3Du, aInvertFaceDirection, aThroughHoles ); } } } OPENGL_RENDER_LIST::OPENGL_RENDER_LIST( const TRIANGLE_DISPLAY_LIST& aLayerTriangles, - GLuint aTextureIndexForSegEnds, - float aZBot, float aZTop ) + GLuint aTextureIndexForSegEnds, float aZBot, float aZTop ) { m_zBot = aZBot; m_zTop = aZTop; - m_layer_top_segment_ends = 0; - m_layer_top_triangles = 0; - m_layer_middle_contourns_quads = 0; - m_layer_bot_triangles = 0; - m_layer_bot_segment_ends = 0; + m_layer_top_segment_ends = 0; + m_layer_top_triangles = 0; + m_layer_middle_contours_quads = 0; + m_layer_bot_triangles = 0; + m_layer_bot_segment_ends = 0; if( aTextureIndexForSegEnds ) { @@ -316,28 +311,21 @@ OPENGL_RENDER_LIST::OPENGL_RENDER_LIST( const TRIANGLE_DISPLAY_LIST& aLayerTrian if( glIsTexture( aTextureIndexForSegEnds ) ) { - m_layer_top_segment_ends = - generate_top_or_bot_seg_ends( aLayerTriangles.m_layer_top_segment_ends, - true, aTextureIndexForSegEnds ); + m_layer_top_segment_ends = generate_top_or_bot_seg_ends( aLayerTriangles.m_layer_top_segment_ends, + true, aTextureIndexForSegEnds ); - m_layer_bot_segment_ends = - generate_top_or_bot_seg_ends( aLayerTriangles.m_layer_bot_segment_ends, - false, aTextureIndexForSegEnds ); + m_layer_bot_segment_ends = generate_top_or_bot_seg_ends( aLayerTriangles.m_layer_bot_segment_ends, + false, aTextureIndexForSegEnds ); } } - m_layer_top_triangles = generate_top_or_bot_triangles( aLayerTriangles.m_layer_top_triangles, - true ); + m_layer_top_triangles = generate_top_or_bot_triangles( aLayerTriangles.m_layer_top_triangles, true ); - m_layer_bot_triangles = generate_top_or_bot_triangles( aLayerTriangles.m_layer_bot_triangles, - false ); + m_layer_bot_triangles = generate_top_or_bot_triangles( aLayerTriangles.m_layer_bot_triangles, false ); - if( aLayerTriangles.m_layer_middle_contourns_quads->GetVertexSize() > 0 ) - { - m_layer_middle_contourns_quads = - generate_middle_triangles( aLayerTriangles.m_layer_middle_contourns_quads ); - } + if( aLayerTriangles.m_layer_middle_contours_quads->GetVertexSize() > 0 ) + m_layer_middle_contours_quads = generate_middle_triangles( aLayerTriangles.m_layer_middle_contours_quads ); m_draw_it_transparent = false; m_haveTransformation = false; @@ -354,8 +342,8 @@ OPENGL_RENDER_LIST::~OPENGL_RENDER_LIST() if( glIsList( m_layer_top_triangles ) ) glDeleteLists( m_layer_top_triangles, 1 ); - if( glIsList( m_layer_middle_contourns_quads ) ) - glDeleteLists( m_layer_middle_contourns_quads, 1 ); + if( glIsList( m_layer_middle_contours_quads ) ) + glDeleteLists( m_layer_middle_contours_quads, 1 ); if( glIsList( m_layer_bot_triangles ) ) glDeleteLists( m_layer_bot_triangles, 1 ); @@ -365,7 +353,7 @@ OPENGL_RENDER_LIST::~OPENGL_RENDER_LIST() m_layer_top_segment_ends = 0; m_layer_top_triangles = 0; - m_layer_middle_contourns_quads = 0; + m_layer_middle_contours_quads = 0; m_layer_bot_triangles = 0; m_layer_bot_segment_ends = 0; } @@ -375,8 +363,8 @@ void OPENGL_RENDER_LIST::DrawTopAndMiddle() const { beginTransformation(); - if( glIsList( m_layer_middle_contourns_quads ) ) - glCallList( m_layer_middle_contourns_quads ); + if( glIsList( m_layer_middle_contours_quads ) ) + glCallList( m_layer_middle_contours_quads ); if( glIsList( m_layer_top_triangles ) ) glCallList( m_layer_top_triangles ); @@ -392,8 +380,8 @@ void OPENGL_RENDER_LIST::DrawBotAndMiddle() const { beginTransformation(); - if( glIsList( m_layer_middle_contourns_quads ) ) - glCallList( m_layer_middle_contourns_quads ); + if( glIsList( m_layer_middle_contours_quads ) ) + glCallList( m_layer_middle_contours_quads ); if( glIsList( m_layer_bot_triangles ) ) glCallList( m_layer_bot_triangles ); @@ -437,8 +425,8 @@ void OPENGL_RENDER_LIST::DrawMiddle() const { beginTransformation(); - if( glIsList( m_layer_middle_contourns_quads ) ) - glCallList( m_layer_middle_contourns_quads ); + if( glIsList( m_layer_middle_contours_quads ) ) + glCallList( m_layer_middle_contours_quads ); endTransformation(); } @@ -449,8 +437,8 @@ void OPENGL_RENDER_LIST::DrawAll( bool aDrawMiddle ) const beginTransformation(); if( aDrawMiddle ) - if( glIsList( m_layer_middle_contourns_quads ) ) - glCallList( m_layer_middle_contourns_quads ); + if( glIsList( m_layer_middle_contours_quads ) ) + glCallList( m_layer_middle_contours_quads ); if( glIsList( m_layer_top_triangles ) ) glCallList( m_layer_top_triangles ); diff --git a/3d-viewer/3d_rendering/opengl/layer_triangles.h b/3d-viewer/3d_rendering/opengl/layer_triangles.h index 8586cc6962..493a49e7b2 100644 --- a/3d-viewer/3d_rendering/opengl/layer_triangles.h +++ b/3d-viewer/3d_rendering/opengl/layer_triangles.h @@ -111,23 +111,23 @@ public: bool IsLayersSizeValid(); - void AddToMiddleContourns( const SHAPE_LINE_CHAIN& outlinePath, float zBot, float zTop, - double aBiuTo3Du, bool aInvertFaceDirection, - const BVH_CONTAINER_2D* aThroughHoles = nullptr ); + void AddToMiddleContours( const SHAPE_LINE_CHAIN& outlinePath, float zBot, float zTop, + double aBiuTo3Du, bool aInvertFaceDirection, + const BVH_CONTAINER_2D* aThroughHoles = nullptr ); - void AddToMiddleContourns( const SHAPE_POLY_SET& aPolySet, float zBot, float zTop, - double aBiuTo3Du, bool aInvertFaceDirection, - const BVH_CONTAINER_2D* aThroughHoles = nullptr ); + void AddToMiddleContours( const SHAPE_POLY_SET& aPolySet, float zBot, float zTop, + double aBiuTo3Du, bool aInvertFaceDirection, + const BVH_CONTAINER_2D* aThroughHoles = nullptr ); - void AddToMiddleContourns( const std::vector< SFVEC2F >& aContournPoints, float zBot, - float zTop, bool aInvertFaceDirection, - const BVH_CONTAINER_2D* aThroughHoles = nullptr ); + void AddToMiddleContours( const std::vector< SFVEC2F >& aContourPoints, float zBot, + float zTop, bool aInvertFaceDirection, + const BVH_CONTAINER_2D* aThroughHoles = nullptr ); std::mutex m_middle_layer_lock; TRIANGLE_LIST* m_layer_top_segment_ends; TRIANGLE_LIST* m_layer_top_triangles; - TRIANGLE_LIST* m_layer_middle_contourns_quads; + TRIANGLE_LIST* m_layer_middle_contours_quads; TRIANGLE_LIST* m_layer_bot_triangles; TRIANGLE_LIST* m_layer_bot_segment_ends; }; @@ -229,7 +229,7 @@ private: float m_zTop; GLuint m_layer_top_segment_ends; GLuint m_layer_top_triangles; - GLuint m_layer_middle_contourns_quads; + GLuint m_layer_middle_contours_quads; GLuint m_layer_bot_triangles; GLuint m_layer_bot_segment_ends; diff --git a/pcbnew/board.cpp b/pcbnew/board.cpp index 44a857aea7..10e3890a8d 100644 --- a/pcbnew/board.cpp +++ b/pcbnew/board.cpp @@ -2784,17 +2784,14 @@ ZONE* BOARD::AddArea( PICKED_ITEMS_LIST* aNewZonesList, int aNetcode, PCB_LAYER_ } -bool BOARD::GetBoardPolygonOutlines( SHAPE_POLY_SET& aOutlines, - OUTLINE_ERROR_HANDLER* aErrorHandler, - bool aAllowUseArcsInPolygons, - bool aIncludeNPTHAsOutlines ) +bool BOARD::GetBoardPolygonOutlines( SHAPE_POLY_SET& aOutlines, OUTLINE_ERROR_HANDLER* aErrorHandler, + bool aAllowUseArcsInPolygons, bool aIncludeNPTHAsOutlines ) { // max dist from one endPt to next startPt: use the current value int chainingEpsilon = GetOutlinesChainingEpsilon(); bool success = BuildBoardPolygonOutlines( this, aOutlines, GetDesignSettings().m_MaxError, - chainingEpsilon, aErrorHandler, - aAllowUseArcsInPolygons ); + chainingEpsilon, aErrorHandler, aAllowUseArcsInPolygons ); // Now add NPTH oval holes as holes in outlines if required if( aIncludeNPTHAsOutlines ) diff --git a/pcbnew/convert_shape_list_to_polygon.cpp b/pcbnew/convert_shape_list_to_polygon.cpp index d15b1db232..3570dbd8dc 100644 --- a/pcbnew/convert_shape_list_to_polygon.cpp +++ b/pcbnew/convert_shape_list_to_polygon.cpp @@ -197,6 +197,7 @@ static void processClosedShape( PCB_SHAPE* aShape, SHAPE_LINE_CHAIN& aContour, prevPt = pt; } + aContour.SetClosed( true ); break; } @@ -212,13 +213,11 @@ static void processClosedShape( PCB_SHAPE* aShape, SHAPE_LINE_CHAIN& aContour, aContour.SetClosed( true ); for( int ii = 1; ii < aContour.PointCount(); ++ii ) - { - aShapeOwners[ std::make_pair( aContour.CPoint( ii-1 ), - aContour.CPoint( ii ) ) ] = aShape; - } + aShapeOwners[ std::make_pair( aContour.CPoint( ii-1 ), aContour.CPoint( ii ) ) ] = aShape; if( !aAllowUseArcsInPolygons ) aContour.ClearArcs(); + break; } case SHAPE_T::RECTANGLE: @@ -232,10 +231,7 @@ static void processClosedShape( PCB_SHAPE* aShape, SHAPE_LINE_CHAIN& aContour, aContour.Append( poly.Outline( 0 ) ); for( int ii = 1; ii < aContour.PointCount(); ++ii ) - { - aShapeOwners[ std::make_pair( aContour.CPoint( ii - 1 ), - aContour.CPoint( ii ) ) ] = aShape; - } + aShapeOwners[ std::make_pair( aContour.CPoint( ii - 1 ), aContour.CPoint( ii ) ) ] = aShape; if( !aAllowUseArcsInPolygons ) aContour.ClearArcs();