Loading 3d-viewer/3d_draw.cpp +8 −9 Original line number Original line Diff line number Diff line Loading @@ -91,8 +91,8 @@ static void BuildPadShapeThickOutlineAsPolygon( D_PAD* aPad, for( unsigned ii = 0, jj = corners.size() - 1; ii < corners.size(); jj = ii, ii++ ) for( unsigned ii = 0, jj = corners.size() - 1; ii < corners.size(); jj = ii, ii++ ) { { TransformRoundedEndsSegmentToPolygon( aCornerBuffer, TransformRoundedEndsSegmentToPolygon( aCornerBuffer, wxPoint( corners[jj].x, corners[jj].y ), corners.GetPos( jj ), wxPoint( corners[ii].x, corners[ii].y ), corners.GetPos( ii ), aCircleToSegmentsCount, aWidth ); aCircleToSegmentsCount, aWidth ); } } } } Loading Loading @@ -289,14 +289,13 @@ void EDA_3D_CANVAS::BuildBoard3DView() KI_POLYGON_SET polysetHoles; KI_POLYGON_SET polysetHoles; // Add polygons, without holes // Add polygons, without holes AddPolygonCornersToKiPolygonList( bufferPolys, currLayerPolyset ); bufferPolys.ExportTo( currLayerPolyset ); // Add holes in polygon list // Add holes in polygon list currLayerHoles.insert( currLayerHoles.begin(), currLayerHoles.Append( allLayerHoles ); allLayerHoles.begin(), allLayerHoles.end() ); if( currLayerHoles.size() > 0 ) if( currLayerHoles.size() > 0 ) AddPolygonCornersToKiPolygonList( currLayerHoles, polysetHoles ); currLayerHoles.ExportTo( polysetHoles ); // Merge polygons, remove holes // Merge polygons, remove holes currLayerPolyset -= polysetHoles; currLayerPolyset -= polysetHoles; Loading @@ -309,7 +308,7 @@ void EDA_3D_CANVAS::BuildBoard3DView() glNormal3f( 0.0, 0.0, Get3DLayer_Z_Orientation( layer ) ); glNormal3f( 0.0, 0.0, Get3DLayer_Z_Orientation( layer ) ); bufferPolys.clear(); bufferPolys.clear(); CopyPolygonsFromKiPolygonListToPolysList( currLayerPolyset, bufferPolys ); bufferPolys.ImportFrom( currLayerPolyset ); Draw3D_SolidHorizontalPolyPolygons( bufferPolys, zpos, Draw3D_SolidHorizontalPolyPolygons( bufferPolys, zpos, thickness, thickness, g_Parm_3D_Visu.m_BiuTo3Dunits ); g_Parm_3D_Visu.m_BiuTo3Dunits ); Loading Loading @@ -410,7 +409,7 @@ void EDA_3D_CANVAS::BuildBoard3DView() KI_POLYGON_SET currLayerPolyset; KI_POLYGON_SET currLayerPolyset; KI_POLYGON_SET polyset; KI_POLYGON_SET polyset; AddPolygonCornersToKiPolygonList( bufferPolys, polyset ); bufferPolys.ExportTo( polyset ); // merge polys: // merge polys: currLayerPolyset += polyset; currLayerPolyset += polyset; Loading @@ -430,7 +429,7 @@ void EDA_3D_CANVAS::BuildBoard3DView() glNormal3f( 0.0, 0.0, Get3DLayer_Z_Orientation( layer ) ); glNormal3f( 0.0, 0.0, Get3DLayer_Z_Orientation( layer ) ); bufferPolys.clear(); bufferPolys.clear(); CopyPolygonsFromKiPolygonListToPolysList( currLayerPolyset, bufferPolys ); bufferPolys.ImportFrom( currLayerPolyset ); Draw3D_SolidHorizontalPolyPolygons( bufferPolys, zpos, Draw3D_SolidHorizontalPolyPolygons( bufferPolys, zpos, thickness, g_Parm_3D_Visu.m_BiuTo3Dunits ); thickness, g_Parm_3D_Visu.m_BiuTo3Dunits ); } } Loading 3d-viewer/3d_draw_basic_functions.cpp +23 −26 Original line number Original line Diff line number Diff line Loading @@ -70,7 +70,7 @@ static inline void SetNormalZneg() * from Z position = aZpos to aZpos + aHeight * from Z position = aZpos to aZpos + aHeight * Used to create the vertical sides of 3D horizontal shapes with thickness. * Used to create the vertical sides of 3D horizontal shapes with thickness. */ */ static void Draw3D_VerticalPolygonalCylinder( const std::vector<CPolyPt>& aPolysList, static void Draw3D_VerticalPolygonalCylinder( const CPOLYGONS_LIST& aPolysList, int aHeight, int aZpos, int aHeight, int aZpos, bool aInside, double aBiuTo3DUnits ) bool aInside, double aBiuTo3DUnits ) { { Loading Loading @@ -100,19 +100,19 @@ static void Draw3D_VerticalPolygonalCylinder( const std::vector<CPolyPt>& aPolys { { unsigned jj = ii + 1; unsigned jj = ii + 1; if( aPolysList[ii].end_contour || jj >= aPolysList.size() ) if( aPolysList.IsEndContour( ii ) || jj >= aPolysList.size() ) { { jj = startContour; jj = startContour; startContour = ii + 1; startContour = ii + 1; } } // Build the 4 vertices of each GL_QUAD // Build the 4 vertices of each GL_QUAD coords[0].x = aPolysList[ii].x; coords[0].x = aPolysList.GetX( ii ); coords[0].y = -aPolysList[ii].y; coords[0].y = -aPolysList.GetY( ii ); coords[1].x = coords[0].x; coords[1].x = coords[0].x; coords[1].y = coords[0].y; // only z change coords[1].y = coords[0].y; // only z change coords[2].x = aPolysList[jj].x; coords[2].x = aPolysList.GetX( jj ); coords[2].y = -aPolysList[jj].y; coords[2].y = -aPolysList.GetY( jj ); coords[3].x = coords[2].x; coords[3].x = coords[2].x; coords[3].y = coords[2].y; // only z change coords[3].y = coords[2].y; // only z change Loading Loading @@ -142,7 +142,7 @@ void SetGLColor( EDA_COLOR_T color ) * The top side is located at aZpos + aThickness / 2 * The top side is located at aZpos + aThickness / 2 * The bottom side is located at aZpos - aThickness / 2 * The bottom side is located at aZpos - aThickness / 2 */ */ void Draw3D_SolidHorizontalPolyPolygons( const std::vector<CPolyPt>& aPolysList, void Draw3D_SolidHorizontalPolyPolygons( const CPOLYGONS_LIST& aPolysList, int aZpos, int aThickness, double aBiuTo3DUnits ) int aZpos, int aThickness, double aBiuTo3DUnits ) { { GLUtesselator* tess = gluNewTess(); GLUtesselator* tess = gluNewTess(); Loading @@ -164,7 +164,7 @@ void Draw3D_SolidHorizontalPolyPolygons( const std::vector<CPolyPt>& aPolysList, // gluTessProperty(tess, GLU_TESS_WINDING_RULE, GLU_TESS_WINDING_ODD); // gluTessProperty(tess, GLU_TESS_WINDING_RULE, GLU_TESS_WINDING_ODD); // Draw solid areas contained in this list // Draw solid areas contained in this list std::vector<CPolyPt> polylist = aPolysList; // temporary copy for gluTessVertex CPOLYGONS_LIST polylist = aPolysList; // temporary copy for gluTessVertex for( int side = 0; side < 2; side++ ) for( int side = 0; side < 2; side++ ) { { Loading @@ -179,15 +179,15 @@ void Draw3D_SolidHorizontalPolyPolygons( const std::vector<CPolyPt>& aPolysList, startContour = 0; startContour = 0; } } v_data[0] = polylist[ii].x * aBiuTo3DUnits; v_data[0] = polylist.GetX( ii ) * aBiuTo3DUnits; v_data[1] = -polylist[ii].y * aBiuTo3DUnits; v_data[1] = -polylist.GetY( ii ) * aBiuTo3DUnits; // gluTessVertex store pointers on data, not data, so do not store // gluTessVertex store pointers on data, not data, so do not store // different corners values in a temporary variable // different corners values in a temporary variable // but send pointer on each CPolyPt value in polylist // but send pointer on each CPolyPt value in polylist // before calling gluDeleteTess // before calling gluDeleteTess gluTessVertex( tess, v_data, &polylist[ii] ); gluTessVertex( tess, v_data, &polylist[ii] ); if( polylist[ii].end_contour == 1 ) if( polylist.IsEndContour( ii ) ) { { gluTessEndContour( tess ); gluTessEndContour( tess ); gluTessEndPolygon( tess ); gluTessEndPolygon( tess ); Loading Loading @@ -220,11 +220,11 @@ void Draw3D_SolidHorizontalPolyPolygons( const std::vector<CPolyPt>& aPolysList, * The first polygon is the main polygon, others are holes * The first polygon is the main polygon, others are holes * See Draw3D_SolidHorizontalPolyPolygons for more info * See Draw3D_SolidHorizontalPolyPolygons for more info */ */ void Draw3D_SolidHorizontalPolygonWithHoles( const std::vector<CPolyPt>& aPolysList, void Draw3D_SolidHorizontalPolygonWithHoles( const CPOLYGONS_LIST& aPolysList, int aZpos, int aThickness, int aZpos, int aThickness, double aBiuTo3DUnits ) double aBiuTo3DUnits ) { { std::vector<CPolyPt> polygon; CPOLYGONS_LIST polygon; ConvertPolysListWithHolesToOnePolygon( aPolysList, polygon ); ConvertPolysListWithHolesToOnePolygon( aPolysList, polygon ); Draw3D_SolidHorizontalPolyPolygons( polygon, aZpos, aThickness, aBiuTo3DUnits ); Draw3D_SolidHorizontalPolyPolygons( polygon, aZpos, aThickness, aBiuTo3DUnits ); Loading @@ -241,7 +241,7 @@ void Draw3D_ZaxisCylinder( wxPoint aCenterPos, int aRadius, int aZpos, double aBiuTo3DUnits ) int aZpos, double aBiuTo3DUnits ) { { const int slice = SEGM_PER_CIRCLE; const int slice = SEGM_PER_CIRCLE; std::vector <CPolyPt> outer_cornerBuffer; CPOLYGONS_LIST outer_cornerBuffer; TransformCircleToPolygon( outer_cornerBuffer, aCenterPos, TransformCircleToPolygon( outer_cornerBuffer, aCenterPos, aRadius + (aThickness / 2), slice ); aRadius + (aThickness / 2), slice ); Loading @@ -249,7 +249,7 @@ void Draw3D_ZaxisCylinder( wxPoint aCenterPos, int aRadius, std::vector<S3D_VERTEX> coords; std::vector<S3D_VERTEX> coords; coords.resize( 4 ); coords.resize( 4 ); std::vector <CPolyPt> inner_cornerBuffer; CPOLYGONS_LIST inner_cornerBuffer; if( aThickness ) // build the the vertical inner polygon (hole) if( aThickness ) // build the the vertical inner polygon (hole) TransformCircleToPolygon( inner_cornerBuffer, aCenterPos, TransformCircleToPolygon( inner_cornerBuffer, aCenterPos, aRadius - (aThickness / 2), slice ); aRadius - (aThickness / 2), slice ); Loading @@ -269,9 +269,8 @@ void Draw3D_ZaxisCylinder( wxPoint aCenterPos, int aRadius, { { // draw top (front) and bottom (back) horizontal sides (rings) // draw top (front) and bottom (back) horizontal sides (rings) SetNormalZpos(); SetNormalZpos(); outer_cornerBuffer.insert( outer_cornerBuffer.end(), outer_cornerBuffer.Append( inner_cornerBuffer ); inner_cornerBuffer.begin(), inner_cornerBuffer.end() ); CPOLYGONS_LIST polygon; std::vector<CPolyPt> polygon; ConvertPolysListWithHolesToOnePolygon( outer_cornerBuffer, polygon ); ConvertPolysListWithHolesToOnePolygon( outer_cornerBuffer, polygon ); // draw top (front) horizontal ring // draw top (front) horizontal ring Loading Loading @@ -303,7 +302,7 @@ void Draw3D_ZaxisOblongCylinder( wxPoint aAxis1Pos, wxPoint aAxis2Pos, const int slice = SEGM_PER_CIRCLE; const int slice = SEGM_PER_CIRCLE; // Build the points to approximate oblong cylinder by segments // Build the points to approximate oblong cylinder by segments std::vector <CPolyPt> outer_cornerBuffer; CPOLYGONS_LIST outer_cornerBuffer; int segm_width = (aRadius * 2) + aThickness; int segm_width = (aRadius * 2) + aThickness; TransformRoundedEndsSegmentToPolygon( outer_cornerBuffer, aAxis1Pos, TransformRoundedEndsSegmentToPolygon( outer_cornerBuffer, aAxis1Pos, Loading @@ -316,7 +315,7 @@ void Draw3D_ZaxisOblongCylinder( wxPoint aAxis1Pos, wxPoint aAxis2Pos, if( aThickness ) if( aThickness ) { { std::vector <CPolyPt> inner_cornerBuffer; CPOLYGONS_LIST inner_cornerBuffer; segm_width = aRadius * 2; segm_width = aRadius * 2; TransformRoundedEndsSegmentToPolygon( inner_cornerBuffer, aAxis1Pos, TransformRoundedEndsSegmentToPolygon( inner_cornerBuffer, aAxis1Pos, aAxis2Pos, slice, segm_width ); aAxis2Pos, slice, segm_width ); Loading @@ -328,11 +327,9 @@ void Draw3D_ZaxisOblongCylinder( wxPoint aAxis1Pos, wxPoint aAxis2Pos, // Build the horizontal full polygon shape // Build the horizontal full polygon shape // (outer polygon shape - inner polygon shape) // (outer polygon shape - inner polygon shape) outer_cornerBuffer.insert( outer_cornerBuffer.end(), outer_cornerBuffer.Append( inner_cornerBuffer ); inner_cornerBuffer.begin(), inner_cornerBuffer.end() ); std::vector<CPolyPt> polygon; CPOLYGONS_LIST polygon; ConvertPolysListWithHolesToOnePolygon( outer_cornerBuffer, polygon ); ConvertPolysListWithHolesToOnePolygon( outer_cornerBuffer, polygon ); // draw top (front) horizontal side (ring) // draw top (front) horizontal side (ring) Loading Loading @@ -360,7 +357,7 @@ void Draw3D_ZaxisOblongCylinder( wxPoint aAxis1Pos, wxPoint aAxis2Pos, void Draw3D_SolidSegment( const wxPoint& aStart, const wxPoint& aEnd, void Draw3D_SolidSegment( const wxPoint& aStart, const wxPoint& aEnd, int aWidth, int aThickness, int aZpos, double aBiuTo3DUnits ) int aWidth, int aThickness, int aZpos, double aBiuTo3DUnits ) { { std::vector <CPolyPt> cornerBuffer; CPOLYGONS_LIST cornerBuffer; const int slice = SEGM_PER_CIRCLE; const int slice = SEGM_PER_CIRCLE; TransformRoundedEndsSegmentToPolygon( cornerBuffer, aStart, aEnd, slice, aWidth ); TransformRoundedEndsSegmentToPolygon( cornerBuffer, aStart, aEnd, slice, aWidth ); Loading @@ -375,7 +372,7 @@ void Draw3D_ArcSegment( const wxPoint& aCenterPos, const wxPoint& aStartPoint, { { const int slice = SEGM_PER_CIRCLE; const int slice = SEGM_PER_CIRCLE; std::vector <CPolyPt> cornerBuffer; CPOLYGONS_LIST cornerBuffer; TransformArcToPolygon( cornerBuffer, aCenterPos, aStartPoint, aArcAngle, TransformArcToPolygon( cornerBuffer, aCenterPos, aStartPoint, aArcAngle, slice, aWidth ); slice, aWidth ); Loading common/convert_basic_shapes_to_polygon.cpp +0 −76 Original line number Original line Diff line number Diff line Loading @@ -32,82 +32,6 @@ #include <common.h> #include <common.h> #include <convert_basic_shapes_to_polygon.h> #include <convert_basic_shapes_to_polygon.h> /* Helper functions: * We are using a lots polygons in calculations. * and we are using 2 descriptions, * one easy to use with boost::polygon (KI_POLYGON_SET) * one easy to use in zones and in draw functions (CPOLYGONS_LIST) * Copy polygons from a KI_POLYGON_SET set of polygons to * a CPOLYGONS_LIST polygon list * Therefore we need conversion functions between these 2 descriptions */ void CopyPolygonsFromKiPolygonListToPolysList( KI_POLYGON_SET& aKiPolyList, CPOLYGONS_LIST& aPolysList ) { for( unsigned ii = 0; ii < aKiPolyList.size(); ii++ ) { KI_POLYGON& poly = aKiPolyList[ii]; CPolyPt corner( 0, 0, false ); for( unsigned jj = 0; jj < poly.size(); jj++ ) { KI_POLY_POINT point = *(poly.begin() + jj); corner.x = point.x(); corner.y = point.y(); corner.end_contour = false; aPolysList.push_back( corner ); } aPolysList.back().end_contour = true; } } /** * Helper function AddPolygonCornersToKiPolygonList * This function adds a KI_POLYGON_SET description to a * CPOLYGONS_LIST description * @param aCornersBuffer = source (set of polygons using CPolyPt corners descr) * @param aPolysList = destination (set of polygons) */ void AddPolygonCornersToKiPolygonList( CPOLYGONS_LIST& aCornersBuffer, KI_POLYGON_SET& aKiPolyList ) { std::vector<KI_POLY_POINT> cornerslist; unsigned corners_count = aCornersBuffer.size(); // Count the number of polygons in aCornersBuffer int polycount = 0; for( unsigned ii = 0; ii < corners_count; ii++ ) { if( aCornersBuffer[ii].end_contour ) polycount++; } aKiPolyList.reserve( polycount ); for( unsigned icnt = 0; icnt < corners_count; ) { KI_POLYGON poly; cornerslist.clear(); unsigned ii; for( ii = icnt; ii < aCornersBuffer.size(); ii++ ) { cornerslist.push_back( KI_POLY_POINT( aCornersBuffer[ii].x, aCornersBuffer[ii].y ) ); if( aCornersBuffer[ii].end_contour ) break; } bpl::set_points( poly, cornerslist.begin(), cornerslist.end() ); aKiPolyList.push_back( poly ); icnt = ii + 1; } } /** /** * Function TransformCircleToPolygon * Function TransformCircleToPolygon Loading include/convert_basic_shapes_to_polygon.h +0 −27 Original line number Original line Diff line number Diff line Loading @@ -35,33 +35,6 @@ #include <macros.h> #include <macros.h> #include <PolyLine.h> #include <PolyLine.h> /** * Helper function CopyPolygonsFromKiPolygonListToPolysList * We are using a lots polygons in calculations. * and we are using 2 descriptions, * one easy to use with boost::polygon (KI_POLYGON_SET) * one easy to use in zones and in draw functions (CPOLYGONS_LIST) * Copy polygons from a KI_POLYGON_SET set of polygons to * a CPOLYGONS_LIST corner polygon list * Therefore we need conversion functions between these 2 descriptions * This function converts a KI_POLYGON_SET description to a * CPOLYGONS_LIST description * @param aKiPolyList = source (set of polygons) * @param aPolysList = destination (set of polygons using CPolyPt corners descr) */ void CopyPolygonsFromKiPolygonListToPolysList( KI_POLYGON_SET& aKiPolyList, CPOLYGONS_LIST& aPolysList ); /** * Helper function AddPolygonCornersToKiPolygonList * This function adds a KI_POLYGON_SET description to a * CPOLYGONS_LIST description * @param aCornersBuffer = source (set of polygons using CPolyPt corners descr) * @param aPolysList = destination (set of polygons) */ void AddPolygonCornersToKiPolygonList( CPOLYGONS_LIST& aCornersBuffer, KI_POLYGON_SET& aKiPolyList ); /** /** * Function TransformCircleToPolygon * Function TransformCircleToPolygon * convert a circle to a polygon, using multiple straight lines * convert a circle to a polygon, using multiple straight lines Loading pcbnew/board_items_to_polygon_shape_transform.cpp +1 −2 Original line number Original line Diff line number Diff line Loading @@ -177,8 +177,7 @@ void ZONE_CONTAINER::TransformSolidAreasShapesToPolygonSet( return; return; // add filled areas polygons // add filled areas polygons aCornerBuffer.insert( aCornerBuffer.end(), m_FilledPolysList.begin(), aCornerBuffer.Append( m_FilledPolysList ); m_FilledPolysList.end() ); // add filled areas outlines, which are drawn with thich lines // add filled areas outlines, which are drawn with thich lines wxPoint seg_start, seg_end; wxPoint seg_start, seg_end; Loading Loading
3d-viewer/3d_draw.cpp +8 −9 Original line number Original line Diff line number Diff line Loading @@ -91,8 +91,8 @@ static void BuildPadShapeThickOutlineAsPolygon( D_PAD* aPad, for( unsigned ii = 0, jj = corners.size() - 1; ii < corners.size(); jj = ii, ii++ ) for( unsigned ii = 0, jj = corners.size() - 1; ii < corners.size(); jj = ii, ii++ ) { { TransformRoundedEndsSegmentToPolygon( aCornerBuffer, TransformRoundedEndsSegmentToPolygon( aCornerBuffer, wxPoint( corners[jj].x, corners[jj].y ), corners.GetPos( jj ), wxPoint( corners[ii].x, corners[ii].y ), corners.GetPos( ii ), aCircleToSegmentsCount, aWidth ); aCircleToSegmentsCount, aWidth ); } } } } Loading Loading @@ -289,14 +289,13 @@ void EDA_3D_CANVAS::BuildBoard3DView() KI_POLYGON_SET polysetHoles; KI_POLYGON_SET polysetHoles; // Add polygons, without holes // Add polygons, without holes AddPolygonCornersToKiPolygonList( bufferPolys, currLayerPolyset ); bufferPolys.ExportTo( currLayerPolyset ); // Add holes in polygon list // Add holes in polygon list currLayerHoles.insert( currLayerHoles.begin(), currLayerHoles.Append( allLayerHoles ); allLayerHoles.begin(), allLayerHoles.end() ); if( currLayerHoles.size() > 0 ) if( currLayerHoles.size() > 0 ) AddPolygonCornersToKiPolygonList( currLayerHoles, polysetHoles ); currLayerHoles.ExportTo( polysetHoles ); // Merge polygons, remove holes // Merge polygons, remove holes currLayerPolyset -= polysetHoles; currLayerPolyset -= polysetHoles; Loading @@ -309,7 +308,7 @@ void EDA_3D_CANVAS::BuildBoard3DView() glNormal3f( 0.0, 0.0, Get3DLayer_Z_Orientation( layer ) ); glNormal3f( 0.0, 0.0, Get3DLayer_Z_Orientation( layer ) ); bufferPolys.clear(); bufferPolys.clear(); CopyPolygonsFromKiPolygonListToPolysList( currLayerPolyset, bufferPolys ); bufferPolys.ImportFrom( currLayerPolyset ); Draw3D_SolidHorizontalPolyPolygons( bufferPolys, zpos, Draw3D_SolidHorizontalPolyPolygons( bufferPolys, zpos, thickness, thickness, g_Parm_3D_Visu.m_BiuTo3Dunits ); g_Parm_3D_Visu.m_BiuTo3Dunits ); Loading Loading @@ -410,7 +409,7 @@ void EDA_3D_CANVAS::BuildBoard3DView() KI_POLYGON_SET currLayerPolyset; KI_POLYGON_SET currLayerPolyset; KI_POLYGON_SET polyset; KI_POLYGON_SET polyset; AddPolygonCornersToKiPolygonList( bufferPolys, polyset ); bufferPolys.ExportTo( polyset ); // merge polys: // merge polys: currLayerPolyset += polyset; currLayerPolyset += polyset; Loading @@ -430,7 +429,7 @@ void EDA_3D_CANVAS::BuildBoard3DView() glNormal3f( 0.0, 0.0, Get3DLayer_Z_Orientation( layer ) ); glNormal3f( 0.0, 0.0, Get3DLayer_Z_Orientation( layer ) ); bufferPolys.clear(); bufferPolys.clear(); CopyPolygonsFromKiPolygonListToPolysList( currLayerPolyset, bufferPolys ); bufferPolys.ImportFrom( currLayerPolyset ); Draw3D_SolidHorizontalPolyPolygons( bufferPolys, zpos, Draw3D_SolidHorizontalPolyPolygons( bufferPolys, zpos, thickness, g_Parm_3D_Visu.m_BiuTo3Dunits ); thickness, g_Parm_3D_Visu.m_BiuTo3Dunits ); } } Loading
3d-viewer/3d_draw_basic_functions.cpp +23 −26 Original line number Original line Diff line number Diff line Loading @@ -70,7 +70,7 @@ static inline void SetNormalZneg() * from Z position = aZpos to aZpos + aHeight * from Z position = aZpos to aZpos + aHeight * Used to create the vertical sides of 3D horizontal shapes with thickness. * Used to create the vertical sides of 3D horizontal shapes with thickness. */ */ static void Draw3D_VerticalPolygonalCylinder( const std::vector<CPolyPt>& aPolysList, static void Draw3D_VerticalPolygonalCylinder( const CPOLYGONS_LIST& aPolysList, int aHeight, int aZpos, int aHeight, int aZpos, bool aInside, double aBiuTo3DUnits ) bool aInside, double aBiuTo3DUnits ) { { Loading Loading @@ -100,19 +100,19 @@ static void Draw3D_VerticalPolygonalCylinder( const std::vector<CPolyPt>& aPolys { { unsigned jj = ii + 1; unsigned jj = ii + 1; if( aPolysList[ii].end_contour || jj >= aPolysList.size() ) if( aPolysList.IsEndContour( ii ) || jj >= aPolysList.size() ) { { jj = startContour; jj = startContour; startContour = ii + 1; startContour = ii + 1; } } // Build the 4 vertices of each GL_QUAD // Build the 4 vertices of each GL_QUAD coords[0].x = aPolysList[ii].x; coords[0].x = aPolysList.GetX( ii ); coords[0].y = -aPolysList[ii].y; coords[0].y = -aPolysList.GetY( ii ); coords[1].x = coords[0].x; coords[1].x = coords[0].x; coords[1].y = coords[0].y; // only z change coords[1].y = coords[0].y; // only z change coords[2].x = aPolysList[jj].x; coords[2].x = aPolysList.GetX( jj ); coords[2].y = -aPolysList[jj].y; coords[2].y = -aPolysList.GetY( jj ); coords[3].x = coords[2].x; coords[3].x = coords[2].x; coords[3].y = coords[2].y; // only z change coords[3].y = coords[2].y; // only z change Loading Loading @@ -142,7 +142,7 @@ void SetGLColor( EDA_COLOR_T color ) * The top side is located at aZpos + aThickness / 2 * The top side is located at aZpos + aThickness / 2 * The bottom side is located at aZpos - aThickness / 2 * The bottom side is located at aZpos - aThickness / 2 */ */ void Draw3D_SolidHorizontalPolyPolygons( const std::vector<CPolyPt>& aPolysList, void Draw3D_SolidHorizontalPolyPolygons( const CPOLYGONS_LIST& aPolysList, int aZpos, int aThickness, double aBiuTo3DUnits ) int aZpos, int aThickness, double aBiuTo3DUnits ) { { GLUtesselator* tess = gluNewTess(); GLUtesselator* tess = gluNewTess(); Loading @@ -164,7 +164,7 @@ void Draw3D_SolidHorizontalPolyPolygons( const std::vector<CPolyPt>& aPolysList, // gluTessProperty(tess, GLU_TESS_WINDING_RULE, GLU_TESS_WINDING_ODD); // gluTessProperty(tess, GLU_TESS_WINDING_RULE, GLU_TESS_WINDING_ODD); // Draw solid areas contained in this list // Draw solid areas contained in this list std::vector<CPolyPt> polylist = aPolysList; // temporary copy for gluTessVertex CPOLYGONS_LIST polylist = aPolysList; // temporary copy for gluTessVertex for( int side = 0; side < 2; side++ ) for( int side = 0; side < 2; side++ ) { { Loading @@ -179,15 +179,15 @@ void Draw3D_SolidHorizontalPolyPolygons( const std::vector<CPolyPt>& aPolysList, startContour = 0; startContour = 0; } } v_data[0] = polylist[ii].x * aBiuTo3DUnits; v_data[0] = polylist.GetX( ii ) * aBiuTo3DUnits; v_data[1] = -polylist[ii].y * aBiuTo3DUnits; v_data[1] = -polylist.GetY( ii ) * aBiuTo3DUnits; // gluTessVertex store pointers on data, not data, so do not store // gluTessVertex store pointers on data, not data, so do not store // different corners values in a temporary variable // different corners values in a temporary variable // but send pointer on each CPolyPt value in polylist // but send pointer on each CPolyPt value in polylist // before calling gluDeleteTess // before calling gluDeleteTess gluTessVertex( tess, v_data, &polylist[ii] ); gluTessVertex( tess, v_data, &polylist[ii] ); if( polylist[ii].end_contour == 1 ) if( polylist.IsEndContour( ii ) ) { { gluTessEndContour( tess ); gluTessEndContour( tess ); gluTessEndPolygon( tess ); gluTessEndPolygon( tess ); Loading Loading @@ -220,11 +220,11 @@ void Draw3D_SolidHorizontalPolyPolygons( const std::vector<CPolyPt>& aPolysList, * The first polygon is the main polygon, others are holes * The first polygon is the main polygon, others are holes * See Draw3D_SolidHorizontalPolyPolygons for more info * See Draw3D_SolidHorizontalPolyPolygons for more info */ */ void Draw3D_SolidHorizontalPolygonWithHoles( const std::vector<CPolyPt>& aPolysList, void Draw3D_SolidHorizontalPolygonWithHoles( const CPOLYGONS_LIST& aPolysList, int aZpos, int aThickness, int aZpos, int aThickness, double aBiuTo3DUnits ) double aBiuTo3DUnits ) { { std::vector<CPolyPt> polygon; CPOLYGONS_LIST polygon; ConvertPolysListWithHolesToOnePolygon( aPolysList, polygon ); ConvertPolysListWithHolesToOnePolygon( aPolysList, polygon ); Draw3D_SolidHorizontalPolyPolygons( polygon, aZpos, aThickness, aBiuTo3DUnits ); Draw3D_SolidHorizontalPolyPolygons( polygon, aZpos, aThickness, aBiuTo3DUnits ); Loading @@ -241,7 +241,7 @@ void Draw3D_ZaxisCylinder( wxPoint aCenterPos, int aRadius, int aZpos, double aBiuTo3DUnits ) int aZpos, double aBiuTo3DUnits ) { { const int slice = SEGM_PER_CIRCLE; const int slice = SEGM_PER_CIRCLE; std::vector <CPolyPt> outer_cornerBuffer; CPOLYGONS_LIST outer_cornerBuffer; TransformCircleToPolygon( outer_cornerBuffer, aCenterPos, TransformCircleToPolygon( outer_cornerBuffer, aCenterPos, aRadius + (aThickness / 2), slice ); aRadius + (aThickness / 2), slice ); Loading @@ -249,7 +249,7 @@ void Draw3D_ZaxisCylinder( wxPoint aCenterPos, int aRadius, std::vector<S3D_VERTEX> coords; std::vector<S3D_VERTEX> coords; coords.resize( 4 ); coords.resize( 4 ); std::vector <CPolyPt> inner_cornerBuffer; CPOLYGONS_LIST inner_cornerBuffer; if( aThickness ) // build the the vertical inner polygon (hole) if( aThickness ) // build the the vertical inner polygon (hole) TransformCircleToPolygon( inner_cornerBuffer, aCenterPos, TransformCircleToPolygon( inner_cornerBuffer, aCenterPos, aRadius - (aThickness / 2), slice ); aRadius - (aThickness / 2), slice ); Loading @@ -269,9 +269,8 @@ void Draw3D_ZaxisCylinder( wxPoint aCenterPos, int aRadius, { { // draw top (front) and bottom (back) horizontal sides (rings) // draw top (front) and bottom (back) horizontal sides (rings) SetNormalZpos(); SetNormalZpos(); outer_cornerBuffer.insert( outer_cornerBuffer.end(), outer_cornerBuffer.Append( inner_cornerBuffer ); inner_cornerBuffer.begin(), inner_cornerBuffer.end() ); CPOLYGONS_LIST polygon; std::vector<CPolyPt> polygon; ConvertPolysListWithHolesToOnePolygon( outer_cornerBuffer, polygon ); ConvertPolysListWithHolesToOnePolygon( outer_cornerBuffer, polygon ); // draw top (front) horizontal ring // draw top (front) horizontal ring Loading Loading @@ -303,7 +302,7 @@ void Draw3D_ZaxisOblongCylinder( wxPoint aAxis1Pos, wxPoint aAxis2Pos, const int slice = SEGM_PER_CIRCLE; const int slice = SEGM_PER_CIRCLE; // Build the points to approximate oblong cylinder by segments // Build the points to approximate oblong cylinder by segments std::vector <CPolyPt> outer_cornerBuffer; CPOLYGONS_LIST outer_cornerBuffer; int segm_width = (aRadius * 2) + aThickness; int segm_width = (aRadius * 2) + aThickness; TransformRoundedEndsSegmentToPolygon( outer_cornerBuffer, aAxis1Pos, TransformRoundedEndsSegmentToPolygon( outer_cornerBuffer, aAxis1Pos, Loading @@ -316,7 +315,7 @@ void Draw3D_ZaxisOblongCylinder( wxPoint aAxis1Pos, wxPoint aAxis2Pos, if( aThickness ) if( aThickness ) { { std::vector <CPolyPt> inner_cornerBuffer; CPOLYGONS_LIST inner_cornerBuffer; segm_width = aRadius * 2; segm_width = aRadius * 2; TransformRoundedEndsSegmentToPolygon( inner_cornerBuffer, aAxis1Pos, TransformRoundedEndsSegmentToPolygon( inner_cornerBuffer, aAxis1Pos, aAxis2Pos, slice, segm_width ); aAxis2Pos, slice, segm_width ); Loading @@ -328,11 +327,9 @@ void Draw3D_ZaxisOblongCylinder( wxPoint aAxis1Pos, wxPoint aAxis2Pos, // Build the horizontal full polygon shape // Build the horizontal full polygon shape // (outer polygon shape - inner polygon shape) // (outer polygon shape - inner polygon shape) outer_cornerBuffer.insert( outer_cornerBuffer.end(), outer_cornerBuffer.Append( inner_cornerBuffer ); inner_cornerBuffer.begin(), inner_cornerBuffer.end() ); std::vector<CPolyPt> polygon; CPOLYGONS_LIST polygon; ConvertPolysListWithHolesToOnePolygon( outer_cornerBuffer, polygon ); ConvertPolysListWithHolesToOnePolygon( outer_cornerBuffer, polygon ); // draw top (front) horizontal side (ring) // draw top (front) horizontal side (ring) Loading Loading @@ -360,7 +357,7 @@ void Draw3D_ZaxisOblongCylinder( wxPoint aAxis1Pos, wxPoint aAxis2Pos, void Draw3D_SolidSegment( const wxPoint& aStart, const wxPoint& aEnd, void Draw3D_SolidSegment( const wxPoint& aStart, const wxPoint& aEnd, int aWidth, int aThickness, int aZpos, double aBiuTo3DUnits ) int aWidth, int aThickness, int aZpos, double aBiuTo3DUnits ) { { std::vector <CPolyPt> cornerBuffer; CPOLYGONS_LIST cornerBuffer; const int slice = SEGM_PER_CIRCLE; const int slice = SEGM_PER_CIRCLE; TransformRoundedEndsSegmentToPolygon( cornerBuffer, aStart, aEnd, slice, aWidth ); TransformRoundedEndsSegmentToPolygon( cornerBuffer, aStart, aEnd, slice, aWidth ); Loading @@ -375,7 +372,7 @@ void Draw3D_ArcSegment( const wxPoint& aCenterPos, const wxPoint& aStartPoint, { { const int slice = SEGM_PER_CIRCLE; const int slice = SEGM_PER_CIRCLE; std::vector <CPolyPt> cornerBuffer; CPOLYGONS_LIST cornerBuffer; TransformArcToPolygon( cornerBuffer, aCenterPos, aStartPoint, aArcAngle, TransformArcToPolygon( cornerBuffer, aCenterPos, aStartPoint, aArcAngle, slice, aWidth ); slice, aWidth ); Loading
common/convert_basic_shapes_to_polygon.cpp +0 −76 Original line number Original line Diff line number Diff line Loading @@ -32,82 +32,6 @@ #include <common.h> #include <common.h> #include <convert_basic_shapes_to_polygon.h> #include <convert_basic_shapes_to_polygon.h> /* Helper functions: * We are using a lots polygons in calculations. * and we are using 2 descriptions, * one easy to use with boost::polygon (KI_POLYGON_SET) * one easy to use in zones and in draw functions (CPOLYGONS_LIST) * Copy polygons from a KI_POLYGON_SET set of polygons to * a CPOLYGONS_LIST polygon list * Therefore we need conversion functions between these 2 descriptions */ void CopyPolygonsFromKiPolygonListToPolysList( KI_POLYGON_SET& aKiPolyList, CPOLYGONS_LIST& aPolysList ) { for( unsigned ii = 0; ii < aKiPolyList.size(); ii++ ) { KI_POLYGON& poly = aKiPolyList[ii]; CPolyPt corner( 0, 0, false ); for( unsigned jj = 0; jj < poly.size(); jj++ ) { KI_POLY_POINT point = *(poly.begin() + jj); corner.x = point.x(); corner.y = point.y(); corner.end_contour = false; aPolysList.push_back( corner ); } aPolysList.back().end_contour = true; } } /** * Helper function AddPolygonCornersToKiPolygonList * This function adds a KI_POLYGON_SET description to a * CPOLYGONS_LIST description * @param aCornersBuffer = source (set of polygons using CPolyPt corners descr) * @param aPolysList = destination (set of polygons) */ void AddPolygonCornersToKiPolygonList( CPOLYGONS_LIST& aCornersBuffer, KI_POLYGON_SET& aKiPolyList ) { std::vector<KI_POLY_POINT> cornerslist; unsigned corners_count = aCornersBuffer.size(); // Count the number of polygons in aCornersBuffer int polycount = 0; for( unsigned ii = 0; ii < corners_count; ii++ ) { if( aCornersBuffer[ii].end_contour ) polycount++; } aKiPolyList.reserve( polycount ); for( unsigned icnt = 0; icnt < corners_count; ) { KI_POLYGON poly; cornerslist.clear(); unsigned ii; for( ii = icnt; ii < aCornersBuffer.size(); ii++ ) { cornerslist.push_back( KI_POLY_POINT( aCornersBuffer[ii].x, aCornersBuffer[ii].y ) ); if( aCornersBuffer[ii].end_contour ) break; } bpl::set_points( poly, cornerslist.begin(), cornerslist.end() ); aKiPolyList.push_back( poly ); icnt = ii + 1; } } /** /** * Function TransformCircleToPolygon * Function TransformCircleToPolygon Loading
include/convert_basic_shapes_to_polygon.h +0 −27 Original line number Original line Diff line number Diff line Loading @@ -35,33 +35,6 @@ #include <macros.h> #include <macros.h> #include <PolyLine.h> #include <PolyLine.h> /** * Helper function CopyPolygonsFromKiPolygonListToPolysList * We are using a lots polygons in calculations. * and we are using 2 descriptions, * one easy to use with boost::polygon (KI_POLYGON_SET) * one easy to use in zones and in draw functions (CPOLYGONS_LIST) * Copy polygons from a KI_POLYGON_SET set of polygons to * a CPOLYGONS_LIST corner polygon list * Therefore we need conversion functions between these 2 descriptions * This function converts a KI_POLYGON_SET description to a * CPOLYGONS_LIST description * @param aKiPolyList = source (set of polygons) * @param aPolysList = destination (set of polygons using CPolyPt corners descr) */ void CopyPolygonsFromKiPolygonListToPolysList( KI_POLYGON_SET& aKiPolyList, CPOLYGONS_LIST& aPolysList ); /** * Helper function AddPolygonCornersToKiPolygonList * This function adds a KI_POLYGON_SET description to a * CPOLYGONS_LIST description * @param aCornersBuffer = source (set of polygons using CPolyPt corners descr) * @param aPolysList = destination (set of polygons) */ void AddPolygonCornersToKiPolygonList( CPOLYGONS_LIST& aCornersBuffer, KI_POLYGON_SET& aKiPolyList ); /** /** * Function TransformCircleToPolygon * Function TransformCircleToPolygon * convert a circle to a polygon, using multiple straight lines * convert a circle to a polygon, using multiple straight lines Loading
pcbnew/board_items_to_polygon_shape_transform.cpp +1 −2 Original line number Original line Diff line number Diff line Loading @@ -177,8 +177,7 @@ void ZONE_CONTAINER::TransformSolidAreasShapesToPolygonSet( return; return; // add filled areas polygons // add filled areas polygons aCornerBuffer.insert( aCornerBuffer.end(), m_FilledPolysList.begin(), aCornerBuffer.Append( m_FilledPolysList ); m_FilledPolysList.end() ); // add filled areas outlines, which are drawn with thich lines // add filled areas outlines, which are drawn with thich lines wxPoint seg_start, seg_end; wxPoint seg_start, seg_end; Loading