3D Viewer: member variable and method naming improvements.

A few build improvements thrown in for a good measure.
This commit is contained in:
Wayne Stambaugh 2021-01-05 17:19:00 -05:00
parent 81aa91ce2a
commit 1c7a5c46e5
43 changed files with 1031 additions and 1104 deletions

View File

@ -58,15 +58,15 @@ BOARD_ADAPTER::BOARD_ADAPTER() :
{
wxLogTrace( m_logTrace, wxT( "BOARD_ADAPTER::BOARD_ADAPTER" ) );
m_3D_grid_type = GRID3D_TYPE::NONE;
m_antialiasing_mode = ANTIALIASING_MODE::AA_8X;
m_gridType = GRID3D_TYPE::NONE;
m_antiAliasingMode = ANTIALIASING_MODE::AA_8X;
m_drawFlags.resize( FL_LAST, false );
if( PgmOrNull() )
m_colors = Pgm().GetSettingsManager().GetColorSettings();
m_render_engine = RENDER_ENGINE::OPENGL_LEGACY;
m_material_mode = MATERIAL_MODE::NORMAL;
m_renderEngine = RENDER_ENGINE::OPENGL_LEGACY;
m_materialMode = MATERIAL_MODE::NORMAL;
m_boardPos = wxPoint();
m_boardSize = wxSize();
@ -74,9 +74,9 @@ BOARD_ADAPTER::BOARD_ADAPTER() :
m_boardBoundingBox.Reset();
m_through_holes_inner.Clear();
m_through_holes_outer.Clear();
m_through_holes_outer_ring.Clear();
m_throughHoleIds.Clear();
m_throughHoleOds.Clear();
m_throughHoleAnnularRings.Clear();
m_copperLayersCount = -1;
m_epoxyThickness3DU = 0.0f;
@ -84,12 +84,12 @@ BOARD_ADAPTER::BOARD_ADAPTER() :
m_nonCopperLayerThickness3DU = 0.0f;
m_biuTo3Dunits = 1.0;
m_stats_nr_tracks = 0;
m_stats_nr_vias = 0;
m_stats_via_med_hole_diameter = 0.0f;
m_stats_nr_holes = 0;
m_stats_hole_med_diameter = 0.0f;
m_stats_track_med_width = 0.0f;
m_trackCount = 0;
m_viaCount = 0;
m_averageViaHoleDiameter = 0.0f;
m_holeCount = 0;
m_averageHoleDiameter = 0.0f;
m_averageTrackWidth = 0.0f;
m_calc_seg_min_factor3DU = 0.0f;
m_calc_seg_max_factor3DU = 0.0f;
@ -124,11 +124,11 @@ BOARD_ADAPTER::BOARD_ADAPTER() :
m_SilkScreenColorBot = SFVEC4F( 0.9, 0.9, 0.9, 1.0 );
m_CopperColor = SFVEC4F( 0.75, 0.61, 0.23, 1.0 );
m_platedpads_container2D_F_Cu = nullptr;
m_platedpads_container2D_B_Cu = nullptr;
m_platedPadsFront = nullptr;
m_platedPadsBack = nullptr;
m_F_Cu_PlatedPads_poly = nullptr;
m_B_Cu_PlatedPads_poly = nullptr;
m_frontPlatedPadPolys = nullptr;
m_backPlatedPadPolys = nullptr;
// Avoid raytracing options not initialized:
m_raytrace_nrsamples_shadows = 0;
@ -150,7 +150,7 @@ BOARD_ADAPTER::~BOARD_ADAPTER()
}
bool BOARD_ADAPTER::Is3DLayerEnabled( PCB_LAYER_ID aLayer ) const
bool BOARD_ADAPTER::Is3dLayerEnabled( PCB_LAYER_ID aLayer ) const
{
wxASSERT( aLayer < PCB_LAYER_ID_COUNT );
@ -241,7 +241,7 @@ void BOARD_ADAPTER::SetFlag( DISPLAY3D_FLG aFlag, bool aState )
}
bool BOARD_ADAPTER::ShouldFPBeDisplayed( FOOTPRINT_ATTR_T aFPAttributes ) const
bool BOARD_ADAPTER::IsFootprintShown( FOOTPRINT_ATTR_T aFPAttributes ) const
{
if( aFPAttributes & FP_SMD )
return GetFlag( FL_FP_ATTRIBUTES_NORMAL_INSERT );
@ -257,21 +257,21 @@ bool BOARD_ADAPTER::ShouldFPBeDisplayed( FOOTPRINT_ATTR_T aFPAttributes ) const
#define TECH_LAYER_THICKNESS KiROUND( 0.04 * IU_PER_MM )
int BOARD_ADAPTER::GetHolePlatingThicknessBIU() const noexcept
int BOARD_ADAPTER::GetHolePlatingThickness() const noexcept
{
return m_board->GetDesignSettings().GetHolePlatingThickness();
}
unsigned int BOARD_ADAPTER::GetNrSegmentsCircle( float aDiameter3DU ) const
unsigned int BOARD_ADAPTER::GetCircleSegmentCount( float aDiameter3DU ) const
{
wxASSERT( aDiameter3DU > 0.0f );
return GetNrSegmentsCircle( (int)( aDiameter3DU / m_biuTo3Dunits ) );
return GetCircleSegmentCount( (int)( aDiameter3DU / m_biuTo3Dunits ) );
}
unsigned int BOARD_ADAPTER::GetNrSegmentsCircle( int aDiameterBIU ) const
unsigned int BOARD_ADAPTER::GetCircleSegmentCount( int aDiameterBIU ) const
{
wxASSERT( aDiameterBIU > 0 );
@ -500,7 +500,7 @@ bool BOARD_ADAPTER::createBoardPolygon( wxString* aErrorMsg )
}
float BOARD_ADAPTER::GetModulesZcoord3DIU( bool aIsFlipped ) const
float BOARD_ADAPTER::GetFootprintZPos( bool aIsFlipped ) const
{
if( aIsFlipped )
{

View File

@ -76,7 +76,7 @@ public:
*
* @param aCachePointer: the pointer to the 3D cache manager.
*/
void Set3DCacheManager( S3D_CACHE* aCachePointer ) noexcept
void Set3dCacheManager( S3D_CACHE* aCachePointer ) noexcept
{
m_3d_model_manager = aCachePointer;
}
@ -84,7 +84,7 @@ public:
/**
* Return the 3D cache manager pointer.
*/
S3D_CACHE *Get3DCacheManager( ) const noexcept
S3D_CACHE* Get3dCacheManager() const noexcept
{
return m_3d_model_manager;
}
@ -110,12 +110,12 @@ public:
*
* @param aLayer layer ID to get status.
*/
bool Is3DLayerEnabled( PCB_LAYER_ID aLayer ) const;
bool Is3dLayerEnabled( PCB_LAYER_ID aLayer ) const;
/**
* Test if footprint should be displayed in relation to attributes and the flags.
*/
bool ShouldFPBeDisplayed( FOOTPRINT_ATTR_T aFPAttributes ) const;
bool IsFootprintShown( FOOTPRINT_ATTR_T aFPAttributes ) const;
/**
* Set current board to be rendered.
@ -155,17 +155,17 @@ public:
*
* @return the conversion factor to transform a position from the board to 3D units.
*/
double BiuTo3Dunits() const noexcept
double BiuTo3dUnits() const noexcept
{
return m_biuTo3Dunits;
}
/**
* Get the bbox of the pcb board.
* Get the board outling bounding box.
*
* @return the board bbox in 3D units.
* @return the board bounding box in 3D units.
*/
const BBOX_3D& GetBBox3DU() const noexcept
const BBOX_3D& GetBBox() const noexcept
{
return m_boardBoundingBox;
}
@ -173,9 +173,9 @@ public:
/**
* Get the current epoxy thickness.
*
* @return thickness in 3D units.
* @return epoxy thickness in 3D units.
*/
float GetEpoxyThickness3DU() const noexcept
float GetEpoxyThickness() const noexcept
{
return m_epoxyThickness3DU;
}
@ -183,9 +183,9 @@ public:
/**
* Get the current non copper layers thickness.
*
* @return thickness in 3D units of non copperlayers.
* @return thickness in 3D units of non copper layers.
*/
float GetNonCopperLayerThickness3DU() const noexcept
float GetNonCopperLayerThickness() const noexcept
{
return m_nonCopperLayerThickness3DU;
}
@ -193,9 +193,9 @@ public:
/**
* Get the current copper layer thickness.
*
* @return thickness in 3D units of copperlayers.
* @return thickness in 3D units of copper layers.
*/
float GetCopperThickness3DU() const noexcept
float GetCopperThickness() const noexcept
{
return m_copperThickness3DU;
}
@ -205,14 +205,14 @@ public:
*
* @return thickness in board units.
*/
int GetHolePlatingThicknessBIU() const noexcept;
int GetHolePlatingThickness() const noexcept;
/**
* Get the board size.
*
* @return size in BIU units.
*/
wxSize GetBoardSizeBIU() const noexcept
wxSize GetBoardSize() const noexcept
{
return m_boardSize;
}
@ -222,7 +222,7 @@ public:
*
* @return position in BIU units.
*/
wxPoint GetBoardPosBIU() const noexcept
wxPoint GetBoardPos() const noexcept
{
return m_boardPos;
}
@ -232,7 +232,7 @@ public:
*
* @return board center vector position in 3D units.
*/
const SFVEC3F& GetBoardCenter3DU() const noexcept
const SFVEC3F& GetBoardCenter() const noexcept
{
return m_boardCenter;
}
@ -244,16 +244,16 @@ public:
* if footprint is on back (bottom) layer.
* @return the Z position of 3D shapes, in 3D integer units.
*/
float GetModulesZcoord3DIU( bool aIsFlipped ) const ;
float GetFootprintZPos( bool aIsFlipped ) const ;
/**
* Get the current grid.
*
* @return space type of the grid.
*/
GRID3D_TYPE GridGet() const noexcept
GRID3D_TYPE GetGridType() const noexcept
{
return m_3D_grid_type;
return m_gridType;
}
/**
@ -261,9 +261,9 @@ public:
*
* @param aGridType the type space of the grid.
*/
void GridSet( GRID3D_TYPE aGridType ) noexcept
void SetGridType( GRID3D_TYPE aGridType ) noexcept
{
m_3D_grid_type = aGridType;
m_gridType = aGridType;
}
/**
@ -271,45 +271,45 @@ public:
*
* @return antialiasing mode value
*/
ANTIALIASING_MODE AntiAliasingGet() const { return m_antialiasing_mode; }
ANTIALIASING_MODE GetAntiAliasingMode() const { return m_antiAliasingMode; }
/**
* Set the current antialiasing mode value.
*
* @param aAAmode antialiasing mode value.
*/
void AntiAliasingSet( ANTIALIASING_MODE aAAmode ) { m_antialiasing_mode = aAAmode; }
void SetAntiAliasingMode( ANTIALIASING_MODE aAAmode ) { m_antiAliasingMode = aAAmode; }
/**
* @param aRenderEngine the render engine mode selected.
*/
void RenderEngineSet( RENDER_ENGINE aRenderEngine ) noexcept
void SetRenderEngine( RENDER_ENGINE aRenderEngine ) noexcept
{
m_render_engine = aRenderEngine;
m_renderEngine = aRenderEngine;
}
/**
* @return render engine on use.
*/
RENDER_ENGINE RenderEngineGet() const noexcept
RENDER_ENGINE GetRenderEngine() const noexcept
{
return m_render_engine;
return m_renderEngine;
}
/**
* @param aMaterialMode the render material mode.
*/
void MaterialModeSet( MATERIAL_MODE aMaterialMode ) noexcept
void SetMaterialMode( MATERIAL_MODE aMaterialMode ) noexcept
{
m_material_mode = aMaterialMode;
m_materialMode = aMaterialMode;
}
/**
* @return material rendering mode.
*/
MATERIAL_MODE MaterialModeGet() const noexcept
MATERIAL_MODE GetMaterialMode() const noexcept
{
return m_material_mode;
return m_materialMode;
}
/**
@ -350,7 +350,7 @@ public:
* @param aLayerId layer id.
* @return position in 3D units.
*/
float GetLayerTopZpos3DU( PCB_LAYER_ID aLayerId ) const noexcept
float GetLayerTopZPos( PCB_LAYER_ID aLayerId ) const noexcept
{
return m_layerZcoordTop[aLayerId];
}
@ -361,29 +361,29 @@ public:
* @param aLayerId layer id.
* @return position in 3D units.
*/
float GetLayerBottomZpos3DU( PCB_LAYER_ID aLayerId ) const noexcept
float GetLayerBottomZPos( PCB_LAYER_ID aLayerId ) const noexcept
{
return m_layerZcoordBottom[aLayerId];
}
/**
* Get the map of container that have the objects per layer.
* Get the map of containers that have the objects per layer.
*
* @return the map containers of this board
* @return the map containers of this board.
*/
const MAP_CONTAINER_2D_BASE& GetMapLayers() const noexcept
const MAP_CONTAINER_2D_BASE& GetLayerMap() const noexcept
{
return m_layers_container2D;
return m_layerMap;
}
const BVH_CONTAINER_2D* GetPlatedPads_Front() const noexcept
const BVH_CONTAINER_2D* GetPlatedPadsFront() const noexcept
{
return m_platedpads_container2D_F_Cu;
return m_platedPadsFront;
}
const BVH_CONTAINER_2D* GetPlatedPads_Back() const noexcept
const BVH_CONTAINER_2D* GetPlatedPadsBack() const noexcept
{
return m_platedpads_container2D_B_Cu;
return m_platedPadsBack;
}
/**
@ -391,133 +391,140 @@ public:
*
* @return the map containers of holes from this board.
*/
const MAP_CONTAINER_2D_BASE& GetMapLayersHoles() const noexcept
const MAP_CONTAINER_2D_BASE& GetLayerHoleMap() const noexcept
{
return m_layers_holes2D;
return m_layerHoleMap;
}
/**
* Get the inflated ThroughHole container.
* Get the inflated through hole outside diameters container.
*
* @return a container with holes.
*/
const BVH_CONTAINER_2D& GetThroughHole_Outer() const noexcept
const BVH_CONTAINER_2D& GetThroughHoleOds() const noexcept
{
return m_through_holes_outer;
return m_throughHoleOds;
}
/**
* Get the ThroughHole container that include the width of the annular ring.
* Get the through hole annular rings container.
*
* @return a container with holes.
* @return a container with through hole annular rings.
*/
const BVH_CONTAINER_2D& GetThroughHole_Outer_Ring() const noexcept
const BVH_CONTAINER_2D& GetThroughHoleAnnularRings() const noexcept
{
return m_through_holes_outer_ring;
}
const SHAPE_POLY_SET& GetThroughHole_Outer_poly() const noexcept
{
return m_through_outer_holes_poly;
}
const SHAPE_POLY_SET& GetThroughHole_Outer_Ring_poly() const noexcept
{
return m_through_outer_ring_holes_poly;
}
const SHAPE_POLY_SET& GetThroughHole_Outer_poly_NPTH() const noexcept
{
return m_through_outer_holes_poly_NPTH;
return m_throughHoleAnnularRings;
}
/**
* @return a container with via THT holes only.
*/
const BVH_CONTAINER_2D& GetThroughHole_Vias_Outer() const noexcept
{
return m_through_holes_vias_outer;
}
const SHAPE_POLY_SET& GetThroughHole_Vias_Outer_poly() const noexcept
{
return m_through_outer_holes_vias_poly;
}
/**
* Get the ThroughHole container.
* Get through hole outside diameter 2D polygons.
*
* @return a container with holes.
* The outside diameter 2D polygon is the hole diameter plus the plating thickness.
*
* @return a container with through hold outside diameter 2D polygons.
*/
const BVH_CONTAINER_2D& GetThroughHole_Inner() const noexcept
const SHAPE_POLY_SET& GetThroughHoleOdPolys() const noexcept
{
return m_through_holes_inner;
return m_throughHoleOdPolys;
}
const SHAPE_POLY_SET& GetThroughHoleAnnularRingPolys() const noexcept
{
return m_throughHoleAnnularRingPolys;
}
const SHAPE_POLY_SET& GetOuterNonPlatedThroughHolePoly() const noexcept
{
return m_nonPlatedThroughHoleOdPolys;
}
/**
* Get statistics of the nr of vias.
* @return a container with through hole via hole outside diameters.
*/
const BVH_CONTAINER_2D& GetThroughHoleViaOds() const noexcept
{
return m_throughHoleViaOds;
}
const SHAPE_POLY_SET& GetThroughHoleViaOdPolys() const noexcept
{
return m_throughHoleViaOdPolys;
}
/**
* Get the through hole inner diameter container.
*
* @return a container with holes inner diameters.
*/
const BVH_CONTAINER_2D& GetThroughHoleIds() const noexcept
{
return m_throughHoleIds;
}
/**
* Get number of vias in this board.
*
* @return number of vias.
*/
unsigned int GetStats_Nr_Vias() const noexcept
unsigned int GetViaCount() const noexcept
{
return m_stats_nr_vias;
return m_viaCount;
}
/**
* Get statistics of the nr of holes.
* Get number of holes in this board.
*
* @return number of holes.
*/
unsigned int GetStats_Nr_Holes() const noexcept
unsigned int GetHoleCount() const noexcept
{
return m_stats_nr_holes;
return m_holeCount;
}
/**
* Average diameter of the via holes.
* Thee average diameter of the via holes.
*
* @return dimension in 3D units.
* @return via hole average diameter dimension in 3D units.
*/
float GetStats_Med_Via_Hole_Diameter3DU() const noexcept
float GetAverageViaHoleDiameter() const noexcept
{
return m_stats_via_med_hole_diameter;
return m_averageViaHoleDiameter;
}
/**
* average diameter of holes.
* Average diameter of through holes.
*
* @return dimension in 3D units.
* @return the average diameter of through holes in 3D units.
*/
float GetStats_Med_Hole_Diameter3DU() const noexcept
float GetAverageHoleDiameter() const noexcept
{
return m_stats_hole_med_diameter;
return m_averageHoleDiameter;
}
/**
* Average width of the tracks.
*
* @return dimensions in 3D units.
* @return average track width in 3D units.
*/
float GetStats_Med_Track_Width() const noexcept
float GetAverageTrackWidth() const noexcept
{
return m_stats_track_med_width;
return m_averageTrackWidth;
}
/**
* @param aDiameter3DU diameter in 3DU.
* @return number of sides that should be used in that circle.
* @return number of sides that should be used in a circle with \a aDiameter3DU.
*/
unsigned int GetNrSegmentsCircle( float aDiameter3DU ) const;
unsigned int GetCircleSegmentCount( float aDiameter3DU ) const;
/**
* @param aDiameterBIU diameter in board internal units.
* @return number of sides that should be used in that circle.
* @return number of sides that should be used in circle with \a aDiameterBIU.
*/
unsigned int GetNrSegmentsCircle( int aDiameterBIU ) const;
unsigned int GetCircleSegmentCount( int aDiameterBIU ) const;
/**
* Get maps of polygon's layers.
* Get map of polygon's layers.
*
* @return the map with polygon's layers.
*/
@ -526,27 +533,27 @@ public:
return m_layers_poly;
}
const SHAPE_POLY_SET *GetPolyPlatedPads_Front()
const SHAPE_POLY_SET* GetFrontPlatedPadPolys()
{
return m_F_Cu_PlatedPads_poly;
return m_frontPlatedPadPolys;
}
const SHAPE_POLY_SET *GetPolyPlatedPads_Back()
const SHAPE_POLY_SET* GetBackPlatedPadPolys()
{
return m_B_Cu_PlatedPads_poly;
return m_backPlatedPadPolys;
}
const MAP_POLY& GetPolyMapHoles_Inner() const noexcept
const MAP_POLY& GetHoleIdPolysMap() const noexcept
{
return m_layers_inner_holes_poly;
return m_layerHoleIdPolys;
}
const MAP_POLY& GetPolyMapHoles_Outer() const noexcept
const MAP_POLY& GetHoleOdPolysMap() const noexcept
{
return m_layers_outer_holes_poly;
return m_layerHoleOdPolys;
}
private:
private:
/**
* Create the board outline polygon.
*
@ -557,47 +564,43 @@ public:
void destroyLayers();
// Helper functions to create the board
void createNewTrack( const TRACK* aTrack, CONTAINER_2D_BASE* aDstContainer,
int aClearanceValue );
void createTrack( const TRACK* aTrack, CONTAINER_2D_BASE* aDstContainer, int aClearanceValue );
void createNewPadWithClearance( const PAD *aPad, CONTAINER_2D_BASE* aDstContainer,
PCB_LAYER_ID aLayer, wxSize aClearanceValue ) const;
void createPadWithClearance( const PAD *aPad, CONTAINER_2D_BASE* aDstContainer,
PCB_LAYER_ID aLayer, wxSize aClearanceValue ) const;
OBJECT_2D *createNewPadDrill( const PAD* aPad, int aInflateValue );
OBJECT_2D* createPadWithDrill( const PAD* aPad, int aInflateValue );
void AddPadsWithClearanceToContainer( const FOOTPRINT* aFootprint,
void addPadsWithClearance( const FOOTPRINT* aFootprint, CONTAINER_2D_BASE* aDstContainer,
PCB_LAYER_ID aLayerId, int aInflateValue,
bool aSkipNPTHPadsWihNoCopper, bool aSkipPlatedPads,
bool aSkipNonPlatedPads );
void addFootprintShapesWithClearance( const FOOTPRINT* aFootprint,
CONTAINER_2D_BASE* aDstContainer,
PCB_LAYER_ID aLayerId, int aInflateValue,
bool aSkipNPTHPadsWihNoCopper, bool aSkipPlatedPads,
bool aSkipNonPlatedPads );
PCB_LAYER_ID aLayerId, int aInflateValue );
void AddFPShapesWithClearanceToContainer( const FOOTPRINT* aFootprint,
CONTAINER_2D_BASE* aDstContainer,
PCB_LAYER_ID aLayerId, int aInflateValue );
void addShapeWithClearance( const PCB_TEXT* aText, CONTAINER_2D_BASE* aDstContainer,
PCB_LAYER_ID aLayerId, int aClearanceValue );
void AddShapeWithClearanceToContainer( const PCB_TEXT* aText, CONTAINER_2D_BASE* aDstContainer,
PCB_LAYER_ID aLayerId, int aClearanceValue );
void addShapeWithClearance( const PCB_SHAPE* aShape, CONTAINER_2D_BASE* aDstContainer,
PCB_LAYER_ID aLayerId, int aClearanceValue );
void AddShapeWithClearanceToContainer( const PCB_SHAPE* aShape, CONTAINER_2D_BASE* aDstContainer,
PCB_LAYER_ID aLayerId, int aClearanceValue );
void addShapeWithClearance( const DIMENSION_BASE* aDimension, CONTAINER_2D_BASE* aDstContainer,
PCB_LAYER_ID aLayerId, int aClearanceValue );
void AddShapeWithClearanceToContainer( const DIMENSION_BASE* aDimension,
CONTAINER_2D_BASE* aDstContainer,
PCB_LAYER_ID aLayerId, int aClearanceValue );
void addSolidAreasShapes( const ZONE* aZoneContainer, CONTAINER_2D_BASE* aDstContainer,
PCB_LAYER_ID aLayerId );
void AddSolidAreasShapesToContainer( const ZONE* aZoneContainer, CONTAINER_2D_BASE* aDstContainer,
PCB_LAYER_ID aLayerId );
void TransformArcToSegments( const wxPoint& aCentre, const wxPoint& aStart, double aArcAngle,
void transformArcToSegments( const wxPoint& aCentre, const wxPoint& aStart, double aArcAngle,
int aCircleToSegmentsCount, int aWidth,
CONTAINER_2D_BASE* aDstContainer, const BOARD_ITEM& aBoardItem );
void buildPadShapeThickOutlineAsSegments( const PAD* aPad, CONTAINER_2D_BASE* aDstContainer,
int aWidth );
void buildPadOutlineAsSegments( const PAD* aPad, CONTAINER_2D_BASE* aDstContainer, int aWidth );
// Helper functions to create poly contours
void buildPadShapeThickOutlineAsPolygon( const PAD* aPad, SHAPE_POLY_SET& aCornerBuffer,
int aWidth) const;
void buildPadOutlineAsPolygon( const PAD* aPad, SHAPE_POLY_SET& aCornerBuffer,
int aWidth) const;
void transformFPShapesToPolygon( const FOOTPRINT* aFootprint, PCB_LAYER_ID aLayer,
SHAPE_POLY_SET& aCornerBuffer ) const;
@ -641,93 +644,73 @@ private:
S3D_CACHE* m_3d_model_manager;
COLOR_SETTINGS* m_colors;
// Render options
std::vector< bool > m_drawFlags;
GRID3D_TYPE m_3D_grid_type;
RENDER_ENGINE m_render_engine;
MATERIAL_MODE m_material_mode;
ANTIALIASING_MODE m_antialiasing_mode;
GRID3D_TYPE m_gridType;
RENDER_ENGINE m_renderEngine;
MATERIAL_MODE m_materialMode;
ANTIALIASING_MODE m_antiAliasingMode;
// Pcb board position
/// center board actual position in board units
wxPoint m_boardPos;
/// board actual size in board units
wxSize m_boardSize;
/// 3d center position of the pcb board in 3d units
SFVEC3F m_boardCenter;
wxPoint m_boardPos; ///< Board center position in board internal units.
wxSize m_boardSize; ///< Board size in board internal units.
SFVEC3F m_boardCenter; ///< 3D center position of the board in 3D units.
BBOX_3D m_boardBoundingBox; ///< 3D bounding box of the board in 3D units.
// Pcb board bounding boxes
/// 3d bounding box of the pcb board in 3d units
BBOX_3D m_boardBoundingBox;
/// It contains polygon contours for each layer
///< Polygon contours for each layer.
MAP_POLY m_layers_poly;
SHAPE_POLY_SET* m_F_Cu_PlatedPads_poly;
SHAPE_POLY_SET* m_B_Cu_PlatedPads_poly;
SHAPE_POLY_SET* m_frontPlatedPadPolys;
SHAPE_POLY_SET* m_backPlatedPadPolys;
/// It contains polygon contours for holes of each layer (outer holes)
MAP_POLY m_layers_outer_holes_poly;
///< Polygon contours for hole outer diameters for each layer.
MAP_POLY m_layerHoleOdPolys;
/// It contains polygon contours for holes of each layer (inner holes)
MAP_POLY m_layers_inner_holes_poly;
///< Polygon contours for hole inner diameters for each layer.
MAP_POLY m_layerHoleIdPolys;
/// It contains polygon contours for (just) non plated through holes (outer cylinder)
SHAPE_POLY_SET m_through_outer_holes_poly_NPTH;
///< Polygon contours for non plated through hole outer diameters.
SHAPE_POLY_SET m_nonPlatedThroughHoleOdPolys;
/// It contains polygon contours for through holes (outer cylinder)
SHAPE_POLY_SET m_through_outer_holes_poly;
///< Polygon contours for through hole outer diameters.
SHAPE_POLY_SET m_throughHoleOdPolys;
/// It contains polygon contours for through holes vias (outer cylinder)
SHAPE_POLY_SET m_through_outer_holes_vias_poly;
///< Polygon contours for through holes via outer diameters.
SHAPE_POLY_SET m_throughHoleViaOdPolys;
/// It contains polygon contours for through holes vias (outer annular ring)
SHAPE_POLY_SET m_through_outer_ring_holes_poly;
///< Polygon contours for through hole via annular rings.
SHAPE_POLY_SET m_throughHoleAnnularRingPolys;
/// PCB board outline polygon
SHAPE_POLY_SET m_board_poly;
SHAPE_POLY_SET m_board_poly; ///< Board outline polygon.
MAP_CONTAINER_2D_BASE m_layerMap; ///< 2D elements for each layer.
// 2D element containers
BVH_CONTAINER_2D* m_platedPadsFront;
BVH_CONTAINER_2D* m_platedPadsBack;
/// It contains the 2d elements of each layer
MAP_CONTAINER_2D_BASE m_layers_container2D;
BVH_CONTAINER_2D* m_platedpads_container2D_F_Cu;
BVH_CONTAINER_2D* m_platedpads_container2D_B_Cu;
/// It contains the holes per each layer
MAP_CONTAINER_2D_BASE m_layers_holes2D;
///< The holes per each layer.
MAP_CONTAINER_2D_BASE m_layerHoleMap;
/// It contains the list of throughHoles of the board,
/// the radius of the hole is inflated with the copper thickness
BVH_CONTAINER_2D m_through_holes_outer;
BVH_CONTAINER_2D m_throughHoleOds;
/// It contains the list of throughHoles of the board,
/// the radius of the hole is inflated with the annular ring size
BVH_CONTAINER_2D m_through_holes_outer_ring;
BVH_CONTAINER_2D m_throughHoleAnnularRings;
/// It contains the list of throughHoles of the board,
/// the radius is the inner hole
BVH_CONTAINER_2D m_through_holes_inner;
BVH_CONTAINER_2D m_throughHoleIds;
/// It contains the list of throughHoles vias of the board,
/// the radius of the hole is inflated with the copper thickness
BVH_CONTAINER_2D m_through_holes_vias_outer;
BVH_CONTAINER_2D m_throughHoleViaOds;
/// It contains the list of throughHoles vias of the board,
/// the radius of the hole
BVH_CONTAINER_2D m_through_holes_vias_inner;
// Layers information
BVH_CONTAINER_2D m_throughHoleViaIds;
/// Number of copper layers actually used by the board
unsigned int m_copperLayersCount;
@ -757,26 +740,23 @@ private:
/// max factor used for circle segment approximation calculation
float m_calc_seg_max_factor3DU;
// Statistics
/// Number of tracks in the board
unsigned int m_stats_nr_tracks;
///< Number of tracks in the board.
unsigned int m_trackCount;
/// Track average width
float m_stats_track_med_width;
float m_averageTrackWidth;
/// Nr of vias
unsigned int m_stats_nr_vias;
///< Number of through hole vias in the board.
unsigned int m_viaCount;
/// Computed medium diameter of the via holes in 3D units
float m_stats_via_med_hole_diameter;
///< Computed average diameter of the via holes in 3D units.
float m_averageViaHoleDiameter;
/// number of holes in the board
unsigned int m_stats_nr_holes;
///< Number of holes in the board.
unsigned int m_holeCount;
/// Computed medium diameter of the holes in 3D units
float m_stats_hole_med_diameter;
/// Computed average diameter of the holes in 3D units.
float m_averageHoleDiameter;
/**
* Trace mask used to enable or disable the trace output of this class.

View File

@ -82,9 +82,8 @@ void addTextSegmToContainer( int x0, int y0, int xf, int yf, void* aData )
// Based on
// void PCB_TEXT::TransformTextShapeWithClearanceToPolygon
// board_items_to_polygon_shape_transform.cpp
void BOARD_ADAPTER::AddShapeWithClearanceToContainer( const PCB_TEXT* aText,
CONTAINER_2D_BASE* aDstContainer,
PCB_LAYER_ID aLayerId, int aClearanceValue )
void BOARD_ADAPTER::addShapeWithClearance( const PCB_TEXT* aText, CONTAINER_2D_BASE* aDstContainer,
PCB_LAYER_ID aLayerId, int aClearanceValue )
{
wxSize size = aText->GetTextSize();
@ -127,12 +126,11 @@ void BOARD_ADAPTER::AddShapeWithClearanceToContainer( const PCB_TEXT* aText,
}
void BOARD_ADAPTER::AddShapeWithClearanceToContainer( const DIMENSION_BASE* aDimension,
CONTAINER_2D_BASE* aDstContainer,
PCB_LAYER_ID aLayerId, int aClearanceValue )
void BOARD_ADAPTER::addShapeWithClearance( const DIMENSION_BASE* aDimension,
CONTAINER_2D_BASE* aDstContainer,
PCB_LAYER_ID aLayerId, int aClearanceValue )
{
AddShapeWithClearanceToContainer( &aDimension->Text(), aDstContainer, aLayerId,
aClearanceValue );
addShapeWithClearance( &aDimension->Text(), aDstContainer, aLayerId, aClearanceValue );
const int linewidth = aDimension->GetLineThickness() + ( 2 * aClearanceValue );
@ -179,10 +177,9 @@ void BOARD_ADAPTER::AddShapeWithClearanceToContainer( const DIMENSION_BASE* aDim
// Based on
// void FOOTPRINT::TransformFPShapesWithClearanceToPolygonSet
// board_items_to_polygon_shape_transform.cpp#L204
void BOARD_ADAPTER::AddFPShapesWithClearanceToContainer( const FOOTPRINT* aFootprint,
CONTAINER_2D_BASE* aDstContainer,
PCB_LAYER_ID aLayerId,
int aInflateValue )
void BOARD_ADAPTER::addFootprintShapesWithClearance( const FOOTPRINT* aFootprint,
CONTAINER_2D_BASE* aDstContainer,
PCB_LAYER_ID aLayerId, int aInflateValue )
{
std::vector<FP_TEXT*> texts; // List of FP_TEXT to convert
FP_SHAPE* outline;
@ -208,8 +205,7 @@ void BOARD_ADAPTER::AddFPShapesWithClearanceToContainer( const FOOTPRINT* aFootp
if( outline->GetLayer() != aLayerId )
break;
AddShapeWithClearanceToContainer( (const PCB_SHAPE*) outline, aDstContainer,
aLayerId, 0 );
addShapeWithClearance( (const PCB_SHAPE*) outline, aDstContainer, aLayerId, 0 );
}
break;
@ -246,8 +242,8 @@ void BOARD_ADAPTER::AddFPShapesWithClearanceToContainer( const FOOTPRINT* aFootp
}
void BOARD_ADAPTER::createNewTrack( const TRACK* aTrack, CONTAINER_2D_BASE* aDstContainer,
int aClearanceValue )
void BOARD_ADAPTER::createTrack( const TRACK* aTrack, CONTAINER_2D_BASE* aDstContainer,
int aClearanceValue )
{
SFVEC2F start3DU( aTrack->GetStart().x * m_biuTo3Dunits,
-aTrack->GetStart().y * m_biuTo3Dunits ); // y coord is inverted
@ -292,7 +288,7 @@ void BOARD_ADAPTER::createNewTrack( const TRACK* aTrack, CONTAINER_2D_BASE* aDst
}
}
TransformArcToSegments( wxPoint( center.x, center.y ), arc->GetStart(),
transformArcToSegments( wxPoint( center.x, center.y ), arc->GetStart(),
arc_angle, circlesegcount,
arc->GetWidth() + 2 * aClearanceValue, aDstContainer, *arc );
break;
@ -325,7 +321,7 @@ void BOARD_ADAPTER::createNewTrack( const TRACK* aTrack, CONTAINER_2D_BASE* aDst
}
void BOARD_ADAPTER::createNewPadWithClearance( const PAD* aPad, CONTAINER_2D_BASE* aDstContainer,
void BOARD_ADAPTER::createPadWithClearance( const PAD* aPad, CONTAINER_2D_BASE* aDstContainer,
PCB_LAYER_ID aLayer, wxSize aClearanceValue ) const
{
SHAPE_POLY_SET poly;
@ -411,7 +407,7 @@ void BOARD_ADAPTER::createNewPadWithClearance( const PAD* aPad, CONTAINER_2D_BAS
break;
default:
wxFAIL_MSG( "BOARD_ADAPTER::createNewPadWithClearance no implementation for "
wxFAIL_MSG( "BOARD_ADAPTER::createPadWithClearance no implementation for "
+ SHAPE_TYPE_asString( shape->Type() ) );
break;
}
@ -424,18 +420,18 @@ void BOARD_ADAPTER::createNewPadWithClearance( const PAD* aPad, CONTAINER_2D_BAS
poly.Inflate( aClearanceValue.x, 32 );
// Add the PAD polygon
Convert_shape_line_polygon_to_triangles( poly, *aDstContainer, m_biuTo3Dunits, *aPad );
ConvertPolygonToTriangles( poly, *aDstContainer, m_biuTo3Dunits, *aPad );
}
}
OBJECT_2D* BOARD_ADAPTER::createNewPadDrill( const PAD* aPad, int aInflateValue )
OBJECT_2D* BOARD_ADAPTER::createPadWithDrill( const PAD* aPad, int aInflateValue )
{
wxSize drillSize = aPad->GetDrillSize();
if( !drillSize.x || !drillSize.y )
{
wxLogTrace( m_logTrace, wxT( "BOARD_ADAPTER::createNewPadDrill - found an invalid pad" ) );
wxLogTrace( m_logTrace, wxT( "BOARD_ADAPTER::createPadWithDrill - found an invalid pad" ) );
return nullptr;
}
@ -467,13 +463,11 @@ OBJECT_2D* BOARD_ADAPTER::createNewPadDrill( const PAD* aPad, int aInflateValue
}
void BOARD_ADAPTER::AddPadsWithClearanceToContainer( const FOOTPRINT* aFootprint,
CONTAINER_2D_BASE* aDstContainer,
PCB_LAYER_ID aLayerId,
int aInflateValue,
bool aSkipNPTHPadsWihNoCopper,
bool aSkipPlatedPads,
bool aSkipNonPlatedPads )
void BOARD_ADAPTER::addPadsWithClearance( const FOOTPRINT* aFootprint,
CONTAINER_2D_BASE* aDstContainer,
PCB_LAYER_ID aLayerId, int aInflateValue,
bool aSkipNPTHPadsWihNoCopper, bool aSkipPlatedPads,
bool aSkipNonPlatedPads )
{
for( PAD* pad : aFootprint->Pads() )
{
@ -536,14 +530,14 @@ void BOARD_ADAPTER::AddPadsWithClearanceToContainer( const FOOTPRINT* aFootprint
break;
}
createNewPadWithClearance( pad, aDstContainer, aLayerId, margin );
createPadWithClearance( pad, aDstContainer, aLayerId, margin );
}
}
// based on TransformArcToPolygon function from
// common/convert_basic_shapes_to_polygon.cpp
void BOARD_ADAPTER::TransformArcToSegments( const wxPoint& aCentre, const wxPoint& aStart,
void BOARD_ADAPTER::transformArcToSegments( const wxPoint& aCentre, const wxPoint& aStart,
double aArcAngle, int aCircleToSegmentsCount,
int aWidth, CONTAINER_2D_BASE* aDstContainer,
const BOARD_ITEM& aBoardItem )
@ -612,10 +606,9 @@ void BOARD_ADAPTER::TransformArcToSegments( const wxPoint& aCentre, const wxPoin
// Based on
// TransformShapeWithClearanceToPolygon
// board_items_to_polygon_shape_transform.cpp#L431
void BOARD_ADAPTER::AddShapeWithClearanceToContainer( const PCB_SHAPE* aShape,
CONTAINER_2D_BASE* aDstContainer,
PCB_LAYER_ID aLayerId,
int aClearanceValue )
void BOARD_ADAPTER::addShapeWithClearance( const PCB_SHAPE* aShape,
CONTAINER_2D_BASE* aDstContainer, PCB_LAYER_ID aLayerId,
int aClearanceValue )
{
// The full width of the lines to create
// The extra 1 protects the inner/outer radius values from degeneracy
@ -651,8 +644,7 @@ void BOARD_ADAPTER::AddShapeWithClearanceToContainer( const PCB_SHAPE* aShape,
polyList.Simplify( SHAPE_POLY_SET::PM_FAST );
Convert_shape_line_polygon_to_triangles( polyList, *aDstContainer, m_biuTo3Dunits,
*aShape );
ConvertPolygonToTriangles( polyList, *aDstContainer, m_biuTo3Dunits, *aShape );
}
else
{
@ -676,9 +668,9 @@ void BOARD_ADAPTER::AddShapeWithClearanceToContainer( const PCB_SHAPE* aShape,
case S_ARC:
{
unsigned int segCount = GetNrSegmentsCircle( aShape->GetBoundingBox().GetSizeMax() );
unsigned int segCount = GetCircleSegmentCount( aShape->GetBoundingBox().GetSizeMax() );
TransformArcToSegments( aShape->GetCenter(), aShape->GetArcStart(), aShape->GetAngle(),
transformArcToSegments( aShape->GetCenter(), aShape->GetArcStart(), aShape->GetAngle(),
segCount, linewidth, aDstContainer, *aShape );
}
break;
@ -717,13 +709,12 @@ void BOARD_ADAPTER::AddShapeWithClearanceToContainer( const PCB_SHAPE* aShape,
if( polyList.IsEmpty() ) // Just for caution
break;
Convert_shape_line_polygon_to_triangles( polyList, *aDstContainer, m_biuTo3Dunits,
*aShape );
ConvertPolygonToTriangles( polyList, *aDstContainer, m_biuTo3Dunits, *aShape );
}
break;
default:
wxFAIL_MSG( "BOARD_ADAPTER::AddShapeWithClearanceToContainer no implementation for "
wxFAIL_MSG( "BOARD_ADAPTER::addShapeWithClearance no implementation for "
+ PCB_SHAPE_TYPE_T_asString( aShape->GetShape() ) );
break;
}
@ -733,16 +724,14 @@ void BOARD_ADAPTER::AddShapeWithClearanceToContainer( const PCB_SHAPE* aShape,
// Based on
// TransformSolidAreasShapesToPolygonSet
// board_items_to_polygon_shape_transform.cpp
void BOARD_ADAPTER::AddSolidAreasShapesToContainer( const ZONE* aZoneContainer,
CONTAINER_2D_BASE* aDstContainer,
PCB_LAYER_ID aLayerId )
void BOARD_ADAPTER::addSolidAreasShapes( const ZONE* aZoneContainer,
CONTAINER_2D_BASE* aDstContainer, PCB_LAYER_ID aLayerId )
{
// Copy the polys list because we have to simplify it
SHAPE_POLY_SET polyList = SHAPE_POLY_SET( aZoneContainer->GetFilledPolysList( aLayerId ) );
// This convert the poly in outline and holes
Convert_shape_line_polygon_to_triangles( polyList, *aDstContainer, m_biuTo3Dunits,
*aZoneContainer );
ConvertPolygonToTriangles( polyList, *aDstContainer, m_biuTo3Dunits, *aZoneContainer );
// add filled areas outlines, which are drawn with thick lines segments
// but only if filled polygons outlines have thickness
@ -810,9 +799,8 @@ void BOARD_ADAPTER::AddSolidAreasShapesToContainer( const ZONE* aZoneContainer,
}
void BOARD_ADAPTER::buildPadShapeThickOutlineAsSegments( const PAD* aPad,
CONTAINER_2D_BASE* aDstContainer,
int aWidth )
void BOARD_ADAPTER::buildPadOutlineAsSegments( const PAD* aPad, CONTAINER_2D_BASE* aDstContainer,
int aWidth )
{
if( aPad->GetShape() == PAD_SHAPE_CIRCLE ) // Draw a ring
{

View File

@ -65,60 +65,60 @@ void BOARD_ADAPTER::destroyLayers()
m_layers_poly.clear();
}
delete m_F_Cu_PlatedPads_poly;
m_F_Cu_PlatedPads_poly = nullptr;
delete m_frontPlatedPadPolys;
m_frontPlatedPadPolys = nullptr;
delete m_B_Cu_PlatedPads_poly;
m_B_Cu_PlatedPads_poly = nullptr;
delete m_backPlatedPadPolys;
m_backPlatedPadPolys = nullptr;
if( !m_layers_inner_holes_poly.empty() )
if( !m_layerHoleIdPolys.empty() )
{
for( auto& poly : m_layers_inner_holes_poly )
for( auto& poly : m_layerHoleIdPolys )
delete poly.second;
m_layers_inner_holes_poly.clear();
m_layerHoleIdPolys.clear();
}
if( !m_layers_outer_holes_poly.empty() )
if( !m_layerHoleOdPolys.empty() )
{
for( auto& poly : m_layers_outer_holes_poly )
for( auto& poly : m_layerHoleOdPolys )
delete poly.second;
m_layers_outer_holes_poly.clear();
m_layerHoleOdPolys.clear();
}
if( !m_layers_container2D.empty() )
if( !m_layerMap.empty() )
{
for( auto& poly : m_layers_container2D )
for( auto& poly : m_layerMap )
delete poly.second;
m_layers_container2D.clear();
m_layerMap.clear();
}
delete m_platedpads_container2D_F_Cu;
m_platedpads_container2D_F_Cu = nullptr;
delete m_platedPadsFront;
m_platedPadsFront = nullptr;
delete m_platedpads_container2D_B_Cu;
m_platedpads_container2D_B_Cu = nullptr;
delete m_platedPadsBack;
m_platedPadsBack = nullptr;
if( !m_layers_holes2D.empty() )
if( !m_layerHoleMap.empty() )
{
for( auto& poly : m_layers_holes2D )
for( auto& poly : m_layerHoleMap )
delete poly.second;
m_layers_holes2D.clear();
m_layerHoleMap.clear();
}
m_through_holes_inner.Clear();
m_through_holes_outer.Clear();
m_through_holes_outer_ring.Clear();
m_through_holes_vias_outer.Clear();
m_through_holes_vias_inner.Clear();
m_through_outer_holes_poly_NPTH.RemoveAllContours();
m_through_outer_holes_poly.RemoveAllContours();
m_throughHoleIds.Clear();
m_throughHoleOds.Clear();
m_throughHoleAnnularRings.Clear();
m_throughHoleViaOds.Clear();
m_throughHoleViaIds.Clear();
m_nonPlatedThroughHoleOdPolys.RemoveAllContours();
m_throughHoleOdPolys.RemoveAllContours();
m_through_outer_holes_vias_poly.RemoveAllContours();
m_through_outer_ring_holes_poly.RemoveAllContours();
m_throughHoleViaOdPolys.RemoveAllContours();
m_throughHoleAnnularRingPolys.RemoveAllContours();
}
@ -139,12 +139,12 @@ void BOARD_ADAPTER::createLayers( REPORTER* aStatusReporter )
PCB_LAYER_ID cu_seq[MAX_CU_LAYERS];
LSET cu_set = LSET::AllCuMask( m_copperLayersCount );
m_stats_nr_tracks = 0;
m_stats_track_med_width = 0;
m_stats_nr_vias = 0;
m_stats_via_med_hole_diameter = 0;
m_stats_nr_holes = 0;
m_stats_hole_med_diameter = 0;
m_trackCount = 0;
m_averageTrackWidth = 0;
m_viaCount = 0;
m_averageViaHoleDiameter = 0;
m_holeCount = 0;
m_averageHoleDiameter = 0;
// Prepare track list, convert in a vector. Calc statistic for the holes
std::vector< const TRACK *> trackList;
@ -153,7 +153,7 @@ void BOARD_ADAPTER::createLayers( REPORTER* aStatusReporter )
for( TRACK* track : m_board->Tracks() )
{
if( !Is3DLayerEnabled( track->GetLayer() ) ) // Skip non enabled layers
if( !Is3dLayerEnabled( track->GetLayer() ) ) // Skip non enabled layers
continue;
// Note: a TRACK holds normal segment tracks and
@ -163,22 +163,22 @@ void BOARD_ADAPTER::createLayers( REPORTER* aStatusReporter )
if( track->Type() == PCB_VIA_T )
{
const VIA *via = static_cast< const VIA*>( track );
m_stats_nr_vias++;
m_stats_via_med_hole_diameter += via->GetDrillValue() * m_biuTo3Dunits;
m_viaCount++;
m_averageViaHoleDiameter += via->GetDrillValue() * m_biuTo3Dunits;
}
else
{
m_stats_nr_tracks++;
m_trackCount++;
}
m_stats_track_med_width += track->GetWidth() * m_biuTo3Dunits;
m_averageTrackWidth += track->GetWidth() * m_biuTo3Dunits;
}
if( m_stats_nr_tracks )
m_stats_track_med_width /= (float)m_stats_nr_tracks;
if( m_trackCount )
m_averageTrackWidth /= (float)m_trackCount;
if( m_stats_nr_vias )
m_stats_via_med_hole_diameter /= (float)m_stats_nr_vias;
if( m_viaCount )
m_averageViaHoleDiameter /= (float)m_viaCount;
// Prepare copper layers index and containers
std::vector< PCB_LAYER_ID > layer_id;
@ -192,16 +192,16 @@ void BOARD_ADAPTER::createLayers( REPORTER* aStatusReporter )
{
const PCB_LAYER_ID curr_layer_id = *cu;
if( !Is3DLayerEnabled( curr_layer_id ) ) // Skip non enabled layers
if( !Is3dLayerEnabled( curr_layer_id ) ) // Skip non enabled layers
continue;
layer_id.push_back( curr_layer_id );
BVH_CONTAINER_2D *layerContainer = new BVH_CONTAINER_2D;
m_layers_container2D[curr_layer_id] = layerContainer;
m_layerMap[curr_layer_id] = layerContainer;
if( GetFlag( FL_RENDER_OPENGL_COPPER_THICKNESS )
&& ( m_render_engine == RENDER_ENGINE::OPENGL_LEGACY ) )
&& ( m_renderEngine == RENDER_ENGINE::OPENGL_LEGACY ) )
{
SHAPE_POLY_SET* layerPoly = new SHAPE_POLY_SET;
m_layers_poly[curr_layer_id] = layerPoly;
@ -210,11 +210,11 @@ void BOARD_ADAPTER::createLayers( REPORTER* aStatusReporter )
if( GetFlag( FL_RENDER_PLATED_PADS_AS_PLATED ) && GetFlag( FL_USE_REALISTIC_MODE ) )
{
m_F_Cu_PlatedPads_poly = new SHAPE_POLY_SET;
m_B_Cu_PlatedPads_poly = new SHAPE_POLY_SET;
m_frontPlatedPadPolys = new SHAPE_POLY_SET;
m_backPlatedPadPolys = new SHAPE_POLY_SET;
m_platedpads_container2D_F_Cu = new BVH_CONTAINER_2D;
m_platedpads_container2D_B_Cu = new BVH_CONTAINER_2D;
m_platedPadsFront = new BVH_CONTAINER_2D;
m_platedPadsBack = new BVH_CONTAINER_2D;
}
@ -224,9 +224,9 @@ void BOARD_ADAPTER::createLayers( REPORTER* aStatusReporter )
// Create tracks as objects and add it to container
for( PCB_LAYER_ID curr_layer_id : layer_id )
{
wxASSERT( m_layers_container2D.find( curr_layer_id ) != m_layers_container2D.end() );
wxASSERT( m_layerMap.find( curr_layer_id ) != m_layerMap.end() );
BVH_CONTAINER_2D *layerContainer = m_layers_container2D[curr_layer_id];
BVH_CONTAINER_2D *layerContainer = m_layerMap[curr_layer_id];
// Add track segments shapes and via annulus shapes
unsigned int nTracks = trackList.size();
@ -246,7 +246,7 @@ void BOARD_ADAPTER::createLayers( REPORTER* aStatusReporter )
continue;
// Add object item to layer container
createNewTrack( track, layerContainer, 0.0f );
createTrack( track, layerContainer, 0.0f );
}
}
@ -268,10 +268,10 @@ void BOARD_ADAPTER::createLayers( REPORTER* aStatusReporter )
{
const VIA* via = static_cast<const VIA*>( track );
const VIATYPE viatype = via->GetViaType();
const float holediameter = via->GetDrillValue() * BiuTo3Dunits();
const float thickness = GetCopperThickness3DU();
const float holediameter = via->GetDrillValue() * BiuTo3dUnits();
const float thickness = GetCopperThickness();
const float hole_inner_radius = ( holediameter / 2.0f );
const float ring_radius = via->GetWidth() * BiuTo3Dunits() / 2.0f;
const float ring_radius = via->GetWidth() * BiuTo3dUnits() / 2.0f;
const SFVEC2F via_center( via->GetStart().x * m_biuTo3Dunits,
-via->GetStart().y * m_biuTo3Dunits );
@ -283,16 +283,16 @@ void BOARD_ADAPTER::createLayers( REPORTER* aStatusReporter )
BVH_CONTAINER_2D *layerHoleContainer = nullptr;
// Check if the layer is already created
if( m_layers_holes2D.find( curr_layer_id ) == m_layers_holes2D.end() )
if( m_layerHoleMap.find( curr_layer_id ) == m_layerHoleMap.end() )
{
// not found, create a new container
layerHoleContainer = new BVH_CONTAINER_2D;
m_layers_holes2D[curr_layer_id] = layerHoleContainer;
m_layerHoleMap[curr_layer_id] = layerHoleContainer;
}
else
{
// found
layerHoleContainer = m_layers_holes2D[curr_layer_id];
layerHoleContainer = m_layerHoleMap[curr_layer_id];
}
// Add a hole for this layer
@ -303,22 +303,22 @@ void BOARD_ADAPTER::createLayers( REPORTER* aStatusReporter )
else if( curr_layer_id == layer_id[0] ) // it only adds once the THT holes
{
// Add through hole object
m_through_holes_outer.Add( new FILLED_CIRCLE_2D( via_center,
m_throughHoleOds.Add( new FILLED_CIRCLE_2D( via_center,
hole_inner_radius + thickness,
*track ) );
m_through_holes_vias_outer.Add(
new FILLED_CIRCLE_2D( via_center, hole_inner_radius + thickness,
*track ) );
m_throughHoleViaOds.Add( new FILLED_CIRCLE_2D( via_center,
hole_inner_radius + thickness,
*track ) );
if( GetFlag( FL_CLIP_SILK_ON_VIA_ANNULUS ) &&
GetFlag( FL_USE_REALISTIC_MODE ) )
{
m_through_holes_outer_ring.Add( new FILLED_CIRCLE_2D( via_center,
m_throughHoleAnnularRings.Add( new FILLED_CIRCLE_2D( via_center,
ring_radius,
*track ) );
}
m_through_holes_inner.Add( new FILLED_CIRCLE_2D( via_center, hole_inner_radius,
m_throughHoleIds.Add( new FILLED_CIRCLE_2D( via_center, hole_inner_radius,
*track ) );
}
}
@ -353,32 +353,32 @@ void BOARD_ADAPTER::createLayers( REPORTER* aStatusReporter )
SHAPE_POLY_SET *layerInnerHolesPoly = nullptr;
// Check if the layer is already created
if( m_layers_outer_holes_poly.find( curr_layer_id ) ==
m_layers_outer_holes_poly.end() )
if( m_layerHoleOdPolys.find( curr_layer_id ) ==
m_layerHoleOdPolys.end() )
{
// not found, create a new container
layerOuterHolesPoly = new SHAPE_POLY_SET;
m_layers_outer_holes_poly[curr_layer_id] = layerOuterHolesPoly;
m_layerHoleOdPolys[curr_layer_id] = layerOuterHolesPoly;
wxASSERT( m_layers_inner_holes_poly.find( curr_layer_id ) ==
m_layers_inner_holes_poly.end() );
wxASSERT( m_layerHoleIdPolys.find( curr_layer_id ) ==
m_layerHoleIdPolys.end() );
layerInnerHolesPoly = new SHAPE_POLY_SET;
m_layers_inner_holes_poly[curr_layer_id] = layerInnerHolesPoly;
m_layerHoleIdPolys[curr_layer_id] = layerInnerHolesPoly;
}
else
{
// found
layerOuterHolesPoly = m_layers_outer_holes_poly[curr_layer_id];
layerOuterHolesPoly = m_layerHoleOdPolys[curr_layer_id];
wxASSERT( m_layers_inner_holes_poly.find( curr_layer_id ) !=
m_layers_inner_holes_poly.end() );
wxASSERT( m_layerHoleIdPolys.find( curr_layer_id ) !=
m_layerHoleIdPolys.end() );
layerInnerHolesPoly = m_layers_inner_holes_poly[curr_layer_id];
layerInnerHolesPoly = m_layerHoleIdPolys[curr_layer_id];
}
const int holediameter = via->GetDrillValue();
const int hole_outer_radius = (holediameter / 2) + GetHolePlatingThicknessBIU();
const int hole_outer_radius = (holediameter / 2) + GetHolePlatingThickness();
TransformCircleToPolygon( *layerOuterHolesPoly, via->GetStart(),
hole_outer_radius, ARC_HIGH_DEF, ERROR_INSIDE );
@ -389,20 +389,20 @@ void BOARD_ADAPTER::createLayers( REPORTER* aStatusReporter )
else if( curr_layer_id == layer_id[0] ) // it only adds once the THT holes
{
const int holediameter = via->GetDrillValue();
const int hole_outer_radius = (holediameter / 2) + GetHolePlatingThicknessBIU();
const int hole_outer_radius = (holediameter / 2) + GetHolePlatingThickness();
const int hole_outer_ring_radius = via->GetWidth() / 2.0f;
// Add through hole contours
TransformCircleToPolygon( m_through_outer_holes_poly, via->GetStart(),
TransformCircleToPolygon( m_throughHoleOdPolys, via->GetStart(),
hole_outer_radius, ARC_HIGH_DEF, ERROR_INSIDE );
// Add same thing for vias only
TransformCircleToPolygon( m_through_outer_holes_vias_poly, via->GetStart(),
TransformCircleToPolygon( m_throughHoleViaOdPolys, via->GetStart(),
hole_outer_radius, ARC_HIGH_DEF, ERROR_INSIDE );
if( GetFlag( FL_CLIP_SILK_ON_VIA_ANNULUS ) && GetFlag( FL_USE_REALISTIC_MODE ) )
{
TransformCircleToPolygon( m_through_outer_ring_holes_poly,
TransformCircleToPolygon( m_throughHoleAnnularRingPolys,
via->GetStart(), hole_outer_ring_radius,
ARC_HIGH_DEF, ERROR_INSIDE );
}
@ -413,7 +413,7 @@ void BOARD_ADAPTER::createLayers( REPORTER* aStatusReporter )
// Creates vertical 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 ) )
&& ( m_renderEngine == RENDER_ENGINE::OPENGL_LEGACY ) )
{
for( PCB_LAYER_ID curr_layer_id : layer_id )
{
@ -456,25 +456,25 @@ void BOARD_ADAPTER::createLayers( REPORTER* aStatusReporter )
// The hole in the body is inflated by copper thickness, if not plated, no copper
const int inflate = ( pad->GetAttribute () != PAD_ATTRIB_NPTH ) ?
GetHolePlatingThicknessBIU() : 0;
GetHolePlatingThickness() : 0;
m_stats_nr_holes++;
m_stats_hole_med_diameter += ( ( pad->GetDrillSize().x +
m_holeCount++;
m_averageHoleDiameter += ( ( pad->GetDrillSize().x +
pad->GetDrillSize().y ) / 2.0f ) * m_biuTo3Dunits;
m_through_holes_outer.Add( createNewPadDrill( pad, inflate ) );
m_throughHoleOds.Add( createPadWithDrill( pad, inflate ) );
if( GetFlag( FL_CLIP_SILK_ON_VIA_ANNULUS ) && GetFlag( FL_USE_REALISTIC_MODE ) )
{
m_through_holes_outer_ring.Add( createNewPadDrill( pad, inflate ) );
m_throughHoleAnnularRings.Add( createPadWithDrill( pad, inflate ) );
}
m_through_holes_inner.Add( createNewPadDrill( pad, 0 ) );
m_throughHoleIds.Add( createPadWithDrill( pad, 0 ) );
}
}
if( m_stats_nr_holes )
m_stats_hole_med_diameter /= (float)m_stats_nr_holes;
if( m_holeCount )
m_averageHoleDiameter /= (float)m_holeCount;
// Add contours of the pad holes (pads can be Circle or Segment holes)
for( FOOTPRINT* footprint : m_board->Footprints() )
@ -487,17 +487,17 @@ void BOARD_ADAPTER::createLayers( REPORTER* aStatusReporter )
continue;
// The hole in the body is inflated by copper thickness.
const int inflate = GetHolePlatingThicknessBIU();
const int inflate = GetHolePlatingThickness();
if( pad->GetAttribute () != PAD_ATTRIB_NPTH )
{
if( GetFlag( FL_CLIP_SILK_ON_VIA_ANNULUS ) && GetFlag( FL_USE_REALISTIC_MODE ) )
{
pad->TransformHoleWithClearanceToPolygon( m_through_outer_ring_holes_poly,
pad->TransformHoleWithClearanceToPolygon( m_throughHoleAnnularRingPolys,
inflate, ARC_HIGH_DEF, ERROR_INSIDE );
}
pad->TransformHoleWithClearanceToPolygon( m_through_outer_holes_poly, inflate,
pad->TransformHoleWithClearanceToPolygon( m_throughHoleOdPolys, inflate,
ARC_HIGH_DEF, ERROR_INSIDE );
}
else
@ -505,11 +505,11 @@ void BOARD_ADAPTER::createLayers( REPORTER* aStatusReporter )
// If not plated, no copper.
if( GetFlag( FL_CLIP_SILK_ON_VIA_ANNULUS ) && GetFlag( FL_USE_REALISTIC_MODE ) )
{
pad->TransformHoleWithClearanceToPolygon( m_through_outer_ring_holes_poly, 0,
pad->TransformHoleWithClearanceToPolygon( m_throughHoleAnnularRingPolys, 0,
ARC_HIGH_DEF, ERROR_INSIDE );
}
pad->TransformHoleWithClearanceToPolygon( m_through_outer_holes_poly_NPTH, 0,
pad->TransformHoleWithClearanceToPolygon( m_nonPlatedThroughHoleOdPolys, 0,
ARC_HIGH_DEF, ERROR_INSIDE );
}
}
@ -521,20 +521,20 @@ void BOARD_ADAPTER::createLayers( REPORTER* aStatusReporter )
// Add footprints PADs objects to containers
for( PCB_LAYER_ID curr_layer_id : layer_id )
{
wxASSERT( m_layers_container2D.find( curr_layer_id ) != m_layers_container2D.end() );
wxASSERT( m_layerMap.find( curr_layer_id ) != m_layerMap.end() );
BVH_CONTAINER_2D *layerContainer = m_layers_container2D[curr_layer_id];
BVH_CONTAINER_2D *layerContainer = m_layerMap[curr_layer_id];
// ADD PADS
for( FOOTPRINT* footprint : m_board->Footprints() )
{
// Note: NPTH pads are not drawn on copper layers when the pad
// has same shape as its hole
AddPadsWithClearanceToContainer( footprint, layerContainer, curr_layer_id, 0,
true, renderPlatedPadsAsPlated, false );
addPadsWithClearance( footprint, layerContainer, curr_layer_id, 0,
true, renderPlatedPadsAsPlated, false );
// Micro-wave footprints may have items on copper layers
AddFPShapesWithClearanceToContainer( footprint, layerContainer, curr_layer_id, 0 );
addFootprintShapesWithClearance( footprint, layerContainer, curr_layer_id, 0 );
}
}
@ -543,20 +543,18 @@ void BOARD_ADAPTER::createLayers( REPORTER* aStatusReporter )
// ADD PLATED PADS
for( FOOTPRINT* footprint : m_board->Footprints() )
{
AddPadsWithClearanceToContainer( footprint, m_platedpads_container2D_F_Cu, F_Cu,
0, true, false, true );
addPadsWithClearance( footprint, m_platedPadsFront, F_Cu, 0, true, false, true );
AddPadsWithClearanceToContainer( footprint, m_platedpads_container2D_B_Cu, B_Cu,
0, true, false, true );
addPadsWithClearance( footprint, m_platedPadsBack, B_Cu, 0, true, false, true );
}
m_platedpads_container2D_F_Cu->BuildBVH();
m_platedpads_container2D_B_Cu->BuildBVH();
m_platedPadsFront->BuildBVH();
m_platedPadsBack->BuildBVH();
}
// Add footprints PADs poly contours (vertical outlines)
if( GetFlag( FL_RENDER_OPENGL_COPPER_THICKNESS )
&& ( m_render_engine == RENDER_ENGINE::OPENGL_LEGACY ) )
&& ( m_renderEngine == RENDER_ENGINE::OPENGL_LEGACY ) )
{
for( PCB_LAYER_ID curr_layer_id : layer_id )
{
@ -583,17 +581,13 @@ void BOARD_ADAPTER::createLayers( REPORTER* aStatusReporter )
// ADD PLATED PADS contours
for( FOOTPRINT* footprint : m_board->Footprints() )
{
footprint->TransformPadsWithClearanceToPolygon( *m_F_Cu_PlatedPads_poly, F_Cu,
footprint->TransformPadsWithClearanceToPolygon( *m_frontPlatedPadPolys, F_Cu,
0, ARC_HIGH_DEF, ERROR_INSIDE,
true, false, true );
//transformFPShapesToPolygon( footprint, F_Cu, *m_F_Cu_PlatedPads_poly );
footprint->TransformPadsWithClearanceToPolygon( *m_B_Cu_PlatedPads_poly, B_Cu,
footprint->TransformPadsWithClearanceToPolygon( *m_backPlatedPadPolys, B_Cu,
0, ARC_HIGH_DEF, ERROR_INSIDE,
true, false, true );
//transformFPShapesToPolygon( footprint, B_Cu, *m_B_Cu_PlatedPads_poly );
}
}
}
@ -601,9 +595,9 @@ void BOARD_ADAPTER::createLayers( REPORTER* aStatusReporter )
// Add graphic item on copper layers to object containers
for( PCB_LAYER_ID curr_layer_id : layer_id )
{
wxASSERT( m_layers_container2D.find( curr_layer_id ) != m_layers_container2D.end() );
wxASSERT( m_layerMap.find( curr_layer_id ) != m_layerMap.end() );
BVH_CONTAINER_2D *layerContainer = m_layers_container2D[curr_layer_id];
BVH_CONTAINER_2D *layerContainer = m_layerMap[curr_layer_id];
// Add graphic items on copper layers (texts and other graphics)
for( BOARD_ITEM* item : m_board->Drawings() )
@ -614,21 +608,21 @@ void BOARD_ADAPTER::createLayers( REPORTER* aStatusReporter )
switch( item->Type() )
{
case PCB_SHAPE_T:
AddShapeWithClearanceToContainer( static_cast<PCB_SHAPE*>( item ), layerContainer,
curr_layer_id, 0 );
addShapeWithClearance( static_cast<PCB_SHAPE*>( item ), layerContainer,
curr_layer_id, 0 );
break;
case PCB_TEXT_T:
AddShapeWithClearanceToContainer( static_cast<PCB_TEXT*>( item ), layerContainer,
curr_layer_id, 0 );
addShapeWithClearance( static_cast<PCB_TEXT*>( item ), layerContainer,
curr_layer_id, 0 );
break;
case PCB_DIM_ALIGNED_T:
case PCB_DIM_CENTER_T:
case PCB_DIM_ORTHOGONAL_T:
case PCB_DIM_LEADER_T:
AddShapeWithClearanceToContainer( static_cast<DIMENSION_BASE*>( item ),
layerContainer, curr_layer_id, 0 );
addShapeWithClearance( static_cast<DIMENSION_BASE*>( item ),
layerContainer, curr_layer_id, 0 );
break;
default:
@ -641,7 +635,7 @@ void BOARD_ADAPTER::createLayers( REPORTER* aStatusReporter )
// Add graphic item on copper layers to poly contours (vertical outlines)
if( GetFlag( FL_RENDER_OPENGL_COPPER_THICKNESS )
&& ( m_render_engine == RENDER_ENGINE::OPENGL_LEGACY ) )
&& ( m_renderEngine == RENDER_ENGINE::OPENGL_LEGACY ) )
{
for( PCB_LAYER_ID cur_layer_id : layer_id )
{
@ -714,10 +708,10 @@ void BOARD_ADAPTER::createLayers( REPORTER* aStatusReporter )
PCB_LAYER_ID layer = zones[areaId].second;
auto layerContainer = m_layers_container2D.find( layer );
auto layerContainer = m_layerMap.find( layer );
if( layerContainer != m_layers_container2D.end() )
AddSolidAreasShapesToContainer( zone, layerContainer->second, layer );
if( layerContainer != m_layerMap.end() )
addSolidAreasShapes( zone, layerContainer->second, layer );
}
threadsFinished++;
@ -732,7 +726,7 @@ void BOARD_ADAPTER::createLayers( REPORTER* aStatusReporter )
}
if( GetFlag( FL_ZONE ) && GetFlag( FL_RENDER_OPENGL_COPPER_THICKNESS )
&& ( m_render_engine == RENDER_ENGINE::OPENGL_LEGACY ) )
&& ( m_renderEngine == RENDER_ENGINE::OPENGL_LEGACY ) )
{
// Add copper zones
for( ZONE* zone : m_board->Zones() )
@ -756,24 +750,24 @@ void BOARD_ADAPTER::createLayers( REPORTER* aStatusReporter )
aStatusReporter->Report( _( "Simplifying copper layers polygons" ) );
if( GetFlag( FL_RENDER_OPENGL_COPPER_THICKNESS )
&& ( m_render_engine == RENDER_ENGINE::OPENGL_LEGACY ) )
&& ( m_renderEngine == RENDER_ENGINE::OPENGL_LEGACY ) )
{
if( GetFlag( FL_RENDER_PLATED_PADS_AS_PLATED ) && GetFlag( FL_USE_REALISTIC_MODE ) )
{
if( m_F_Cu_PlatedPads_poly && ( m_layers_poly.find( F_Cu ) != m_layers_poly.end() ) )
if( m_frontPlatedPadPolys && ( m_layers_poly.find( F_Cu ) != m_layers_poly.end() ) )
{
SHAPE_POLY_SET *layerPoly_F_Cu = m_layers_poly[F_Cu];
layerPoly_F_Cu->BooleanSubtract( *m_F_Cu_PlatedPads_poly, SHAPE_POLY_SET::PM_FAST );
layerPoly_F_Cu->BooleanSubtract( *m_frontPlatedPadPolys, SHAPE_POLY_SET::PM_FAST );
m_F_Cu_PlatedPads_poly->Simplify( SHAPE_POLY_SET::PM_FAST );
m_frontPlatedPadPolys->Simplify( SHAPE_POLY_SET::PM_FAST );
}
if( m_B_Cu_PlatedPads_poly && ( m_layers_poly.find( B_Cu ) != m_layers_poly.end() ) )
if( m_backPlatedPadPolys && ( m_layers_poly.find( B_Cu ) != m_layers_poly.end() ) )
{
SHAPE_POLY_SET *layerPoly_B_Cu = m_layers_poly[B_Cu];
layerPoly_B_Cu->BooleanSubtract( *m_B_Cu_PlatedPads_poly, SHAPE_POLY_SET::PM_FAST );
layerPoly_B_Cu->BooleanSubtract( *m_backPlatedPadPolys, SHAPE_POLY_SET::PM_FAST );
m_B_Cu_PlatedPads_poly->Simplify( SHAPE_POLY_SET::PM_FAST );
m_backPlatedPadPolys->Simplify( SHAPE_POLY_SET::PM_FAST );
}
}
@ -836,15 +830,15 @@ void BOARD_ADAPTER::createLayers( REPORTER* aStatusReporter )
for( PCB_LAYER_ID layer : layer_id )
{
if( m_layers_outer_holes_poly.find( layer ) != m_layers_outer_holes_poly.end() )
if( m_layerHoleOdPolys.find( layer ) != m_layerHoleOdPolys.end() )
{
// found
SHAPE_POLY_SET *polyLayer = m_layers_outer_holes_poly[layer];
SHAPE_POLY_SET *polyLayer = m_layerHoleOdPolys[layer];
polyLayer->Simplify( SHAPE_POLY_SET::PM_FAST );
wxASSERT( m_layers_inner_holes_poly.find( layer ) != m_layers_inner_holes_poly.end() );
wxASSERT( m_layerHoleIdPolys.find( layer ) != m_layerHoleIdPolys.end() );
polyLayer = m_layers_inner_holes_poly[layer];
polyLayer = m_layerHoleIdPolys[layer];
polyLayer->Simplify( SHAPE_POLY_SET::PM_FAST );
}
}
@ -852,10 +846,10 @@ void BOARD_ADAPTER::createLayers( REPORTER* aStatusReporter )
// End Build Copper layers
// This will make a union of all added contours
m_through_outer_holes_poly.Simplify( SHAPE_POLY_SET::PM_FAST );
m_through_outer_holes_poly_NPTH.Simplify( SHAPE_POLY_SET::PM_FAST );
m_through_outer_holes_vias_poly.Simplify( SHAPE_POLY_SET::PM_FAST );
m_through_outer_ring_holes_poly.Simplify( SHAPE_POLY_SET::PM_FAST );
m_throughHoleOdPolys.Simplify( SHAPE_POLY_SET::PM_FAST );
m_nonPlatedThroughHoleOdPolys.Simplify( SHAPE_POLY_SET::PM_FAST );
m_throughHoleViaOdPolys.Simplify( SHAPE_POLY_SET::PM_FAST );
m_throughHoleAnnularRingPolys.Simplify( SHAPE_POLY_SET::PM_FAST );
// Build Tech layers
// Based on:
@ -890,11 +884,11 @@ void BOARD_ADAPTER::createLayers( REPORTER* aStatusReporter )
{
const PCB_LAYER_ID curr_layer_id = *seq;
if( !Is3DLayerEnabled( curr_layer_id ) )
if( !Is3dLayerEnabled( curr_layer_id ) )
continue;
BVH_CONTAINER_2D *layerContainer = new BVH_CONTAINER_2D;
m_layers_container2D[curr_layer_id] = layerContainer;
m_layerMap[curr_layer_id] = layerContainer;
SHAPE_POLY_SET *layerPoly = new SHAPE_POLY_SET;
m_layers_poly[curr_layer_id] = layerPoly;
@ -908,21 +902,21 @@ void BOARD_ADAPTER::createLayers( REPORTER* aStatusReporter )
switch( item->Type() )
{
case PCB_SHAPE_T:
AddShapeWithClearanceToContainer( static_cast<PCB_SHAPE*>( item ), layerContainer,
curr_layer_id, 0 );
addShapeWithClearance( static_cast<PCB_SHAPE*>( item ), layerContainer,
curr_layer_id, 0 );
break;
case PCB_TEXT_T:
AddShapeWithClearanceToContainer( static_cast<PCB_TEXT*>( item ), layerContainer,
curr_layer_id, 0 );
addShapeWithClearance( static_cast<PCB_TEXT*>( item ), layerContainer,
curr_layer_id, 0 );
break;
case PCB_DIM_ALIGNED_T:
case PCB_DIM_CENTER_T:
case PCB_DIM_ORTHOGONAL_T:
case PCB_DIM_LEADER_T:
AddShapeWithClearanceToContainer( static_cast<DIMENSION_BASE*>( item ),
layerContainer, curr_layer_id, 0 );
addShapeWithClearance( static_cast<DIMENSION_BASE*>( item ), layerContainer,
curr_layer_id, 0 );
break;
default:
@ -969,16 +963,16 @@ void BOARD_ADAPTER::createLayers( REPORTER* aStatusReporter )
if( !pad->IsOnLayer( curr_layer_id ) )
continue;
buildPadShapeThickOutlineAsSegments( pad, layerContainer, linewidth );
buildPadOutlineAsSegments( pad, layerContainer, linewidth );
}
}
else
{
AddPadsWithClearanceToContainer( footprint, layerContainer, curr_layer_id, 0,
false, false, false );
addPadsWithClearance( footprint, layerContainer, curr_layer_id, 0,
false, false, false );
}
AddFPShapesWithClearanceToContainer( footprint, layerContainer, curr_layer_id, 0 );
addFootprintShapesWithClearance( footprint, layerContainer, curr_layer_id, 0 );
}
@ -994,7 +988,7 @@ void BOARD_ADAPTER::createLayers( REPORTER* aStatusReporter )
if( !pad->IsOnLayer( curr_layer_id ) )
continue;
buildPadShapeThickOutlineAsPolygon( pad, *layerPoly, linewidth );
buildPadOutlineAsPolygon( pad, *layerPoly, linewidth );
}
}
else
@ -1018,7 +1012,7 @@ void BOARD_ADAPTER::createLayers( REPORTER* aStatusReporter )
for( ZONE* zone : m_board->Zones() )
{
if( zone->IsOnLayer( curr_layer_id ) )
AddSolidAreasShapesToContainer( zone, layerContainer, curr_layer_id );
addSolidAreasShapes( zone, layerContainer, curr_layer_id );
}
for( ZONE* zone : m_board->Zones() )
@ -1038,21 +1032,21 @@ void BOARD_ADAPTER::createLayers( REPORTER* aStatusReporter )
if( aStatusReporter )
aStatusReporter->Report( _( "Build BVH for holes and vias" ) );
m_through_holes_inner.BuildBVH();
m_through_holes_outer.BuildBVH();
m_through_holes_outer_ring.BuildBVH();
m_throughHoleIds.BuildBVH();
m_throughHoleOds.BuildBVH();
m_throughHoleAnnularRings.BuildBVH();
if( !m_layers_holes2D.empty() )
if( !m_layerHoleMap.empty() )
{
for( auto& hole : m_layers_holes2D )
for( auto& hole : m_layerHoleMap )
hole.second->BuildBVH();
}
// We only need the Solder mask to initialize the BVH
// because..?
if( m_layers_container2D[B_Mask] )
m_layers_container2D[B_Mask]->BuildBVH();
if( m_layerMap[B_Mask] )
m_layerMap[B_Mask]->BuildBVH();
if( m_layers_container2D[F_Mask] )
m_layers_container2D[F_Mask]->BuildBVH();
if( m_layerMap[F_Mask] )
m_layerMap[F_Mask]->BuildBVH();
}

View File

@ -34,9 +34,8 @@
#include <footprint.h>
void BOARD_ADAPTER::buildPadShapeThickOutlineAsPolygon( const PAD* aPad,
SHAPE_POLY_SET& aCornerBuffer,
int aWidth ) const
void BOARD_ADAPTER::buildPadOutlineAsPolygon( const PAD* aPad, SHAPE_POLY_SET& aCornerBuffer,
int aWidth ) const
{
if( aPad->GetShape() == PAD_SHAPE_CIRCLE ) // Draw a ring
{

View File

@ -144,7 +144,7 @@ EDA_3D_CANVAS::EDA_3D_CANVAS( wxWindow* aParent, const int* aAttribList, BOARD*
m_boardAdapter.SetColorSettings( Pgm().GetSettingsManager().GetColorSettings() );
wxASSERT( a3DCachePointer != nullptr );
m_boardAdapter.Set3DCacheManager( a3DCachePointer );
m_boardAdapter.Set3dCacheManager( a3DCachePointer );
const wxEventType events[] =
{
@ -298,7 +298,7 @@ void EDA_3D_CANVAS::GetScreenshot( wxImage& aDstImage )
void EDA_3D_CANVAS::ReloadRequest( BOARD* aBoard , S3D_CACHE* aCachePointer )
{
if( aCachePointer != nullptr )
m_boardAdapter.Set3DCacheManager( aCachePointer );
m_boardAdapter.Set3dCacheManager( aCachePointer );
if( aBoard != nullptr )
m_boardAdapter.SetBoard( aBoard );
@ -439,11 +439,11 @@ void EDA_3D_CANVAS::DoRePaint()
{
m_3d_render = m_3d_render_ogl_legacy;
m_render_raytracing_was_requested = false;
m_boardAdapter.RenderEngineSet( RENDER_ENGINE::OPENGL_LEGACY );
m_boardAdapter.SetRenderEngine( RENDER_ENGINE::OPENGL_LEGACY );
}
// Check if a raytacing was requested and need to switch to raytracing mode
if( m_boardAdapter.RenderEngineGet() == RENDER_ENGINE::OPENGL_LEGACY )
if( m_boardAdapter.GetRenderEngine() == RENDER_ENGINE::OPENGL_LEGACY )
{
const bool was_camera_changed = m_camera.ParametersChanged();
@ -492,7 +492,7 @@ void EDA_3D_CANVAS::DoRePaint()
bool reloadRaytracingForIntersectionCalculations = false;
if( ( m_boardAdapter.RenderEngineGet() == RENDER_ENGINE::OPENGL_LEGACY )
if( ( m_boardAdapter.GetRenderEngine() == RENDER_ENGINE::OPENGL_LEGACY )
&& m_3d_render_ogl_legacy->IsReloadRequestPending() )
{
reloadRaytracingForIntersectionCalculations = true;
@ -712,7 +712,7 @@ void EDA_3D_CANVAS::OnMouseMove( wxMouseEvent& event )
m_camera.SetCurMousePosition( eventPosition );
if( !event.Dragging() &&
( m_boardAdapter.RenderEngineGet() == RENDER_ENGINE::OPENGL_LEGACY ) )
( m_boardAdapter.GetRenderEngine() == RENDER_ENGINE::OPENGL_LEGACY ) )
{
STATUSBAR_REPORTER reporter( m_parentStatusBar,
static_cast<int>( EDA_3D_VIEWER_STATUSBAR::STATUS_TEXT ) );
@ -791,7 +791,7 @@ void EDA_3D_CANVAS::OnMouseMove( wxMouseEvent& event )
else
{
if( ( m_currentIntersectedBoardItem != nullptr ) &&
( m_boardAdapter.RenderEngineGet() == RENDER_ENGINE::OPENGL_LEGACY ) )
( m_boardAdapter.GetRenderEngine() == RENDER_ENGINE::OPENGL_LEGACY ) )
{
m_3d_render_ogl_legacy->SetCurrentIntersectedBoardItem( nullptr );
Request_refresh();
@ -951,7 +951,7 @@ void EDA_3D_CANVAS::move_pivot_based_on_cur_mouse_position()
float hit_t;
// Test it with the board bounding box
if( m_boardAdapter.GetBBox3DU().Intersect( mouseRay, &hit_t ) )
if( m_boardAdapter.GetBBox().Intersect( mouseRay, &hit_t ) )
{
m_camera.SetInterpolateMode( CAMERA_INTERPOLATION::BEZIER );
m_camera.SetT0_and_T1_current_T();
@ -1126,7 +1126,7 @@ bool EDA_3D_CANVAS::SetView3D( int aKeycode )
void EDA_3D_CANVAS::RenderEngineChanged()
{
switch( m_boardAdapter.RenderEngineGet() )
switch( m_boardAdapter.GetRenderEngine() )
{
case RENDER_ENGINE::OPENGL_LEGACY: m_3d_render = m_3d_render_ogl_legacy; break;
case RENDER_ENGINE::RAYTRACING: m_3d_render = m_3d_render_raytracing; break;

View File

@ -94,7 +94,7 @@ C3D_MODEL_VIEWER::C3D_MODEL_VIEWER( wxWindow* aParent, const int* aAttribList,
m_reload_is_needed = false;
m_ogl_3dmodel = nullptr;
m_3d_model = nullptr;
m_BiuTo3Dunits = 1.0;
m_BiuTo3dUnits = 1.0;
m_glRC = nullptr;
}
@ -260,7 +260,7 @@ void C3D_MODEL_VIEWER::OnPaint( wxPaintEvent& event )
// It convert a model as it was a board, so get the max size dimension of the board
// and compute the conversion scale
m_BiuTo3Dunits =
m_BiuTo3dUnits =
(double) RANGE_SCALE_3D
/ ( (double) m_ogl_3dmodel->GetBBox().GetMaxDimension() * UNITS3D_TO_UNITSPCB );
}
@ -288,7 +288,7 @@ void C3D_MODEL_VIEWER::OnPaint( wxPaintEvent& event )
{
glPushMatrix();
double modelunit_to_3d_units_factor = m_BiuTo3Dunits * UNITS3D_TO_UNITSPCB;
double modelunit_to_3d_units_factor = m_BiuTo3dUnits * UNITS3D_TO_UNITSPCB;
glScaled( modelunit_to_3d_units_factor, modelunit_to_3d_units_factor,
modelunit_to_3d_units_factor );
@ -300,8 +300,8 @@ void C3D_MODEL_VIEWER::OnPaint( wxPaintEvent& event )
m_ogl_3dmodel->BeginDrawMulti( true );
m_ogl_3dmodel->Draw_opaque( false );
m_ogl_3dmodel->Draw_transparent( 1.0f, false );
m_ogl_3dmodel->DrawOpaque( false );
m_ogl_3dmodel->DrawTransparent( 1.0f, false );
m_ogl_3dmodel->EndDrawMulti();

View File

@ -124,7 +124,7 @@ private:
/// factor to convert the model or any other items to keep it in relation to
/// the +/-RANGE_SCALE_3D
/// (it is named same as the board render for better understanding proposes)
double m_BiuTo3Dunits;
double m_BiuTo3dUnits;
/// Optional cache manager
S3D_CACHE* m_cacheManager;

View File

@ -27,8 +27,7 @@
*/
#include "container_2d.h"
#include <vector>
#include <mutex>
#include "../ray.h"
#include <boost/range/algorithm/partition.hpp>
#include <boost/range/algorithm/nth_element.hpp>
#include <wx/debug.h>

View File

@ -33,6 +33,8 @@
#include <list>
#include <mutex>
class RAYSEG2D;
typedef std::list<OBJECT_2D*> LIST_OBJECT2D;
typedef std::list<const OBJECT_2D*> CONST_LIST_OBJECT2D;

View File

@ -37,6 +37,7 @@
#include "shapes2D/ring_2d.h"
#include "shapes2D/polygon_2d.h"
#include "shapes2D/filled_circle_2d.h"
#include "shapes2D/round_segment_2d.h"
#include "accelerators/bvh_pbrt.h"
#include "3d_fastmath.h"
#include "3d_math.h"
@ -80,7 +81,7 @@ void RENDER_3D_RAYTRACE::setupMaterials()
MATERIAL::SetDefaultRefractionsLevel( m_boardAdapter.m_raytrace_recursivelevel_refractions );
MATERIAL::SetDefaultReflectionsLevel( m_boardAdapter.m_raytrace_recursivelevel_reflections );
double mmTo3Dunits = IU_PER_MM * m_boardAdapter.BiuTo3Dunits();
double mmTo3Dunits = IU_PER_MM * m_boardAdapter.BiuTo3dUnits();
if( m_boardAdapter.GetFlag( FL_RENDER_RAYTRACING_PROCEDURAL_TEXTURES ) )
{
@ -274,7 +275,7 @@ void RENDER_3D_RAYTRACE::createItemsFromContainer( const BVH_CONTAINER_2D* aCont
{
// Check if there are any layerhole that intersects this object
// Eg: a segment is cut by a via hole or THT hole.
const MAP_CONTAINER_2D_BASE& layerHolesMap = m_boardAdapter.GetMapLayersHoles();
const MAP_CONTAINER_2D_BASE& layerHolesMap = m_boardAdapter.GetLayerHoleMap();
if( layerHolesMap.find( aLayer_id ) != layerHolesMap.end() )
{
@ -309,8 +310,8 @@ void RENDER_3D_RAYTRACE::createItemsFromContainer( const BVH_CONTAINER_2D* aCont
( m_boardAdapter.GetFlag( FL_CLIP_SILK_ON_VIA_ANNULUS )
&& m_boardAdapter.GetFlag( FL_USE_REALISTIC_MODE )
&& ( ( aLayer_id == B_SilkS ) || ( aLayer_id == F_SilkS ) ) ) ?
m_boardAdapter.GetThroughHole_Outer_Ring() :
m_boardAdapter.GetThroughHole_Outer();
m_boardAdapter.GetThroughHoleAnnularRings() :
m_boardAdapter.GetThroughHoleOds();
if( !throughHoleOuter.GetList().empty() )
{
@ -350,7 +351,7 @@ void RENDER_3D_RAYTRACE::createItemsFromContainer( const BVH_CONTAINER_2D* aCont
}
}
const MAP_CONTAINER_2D_BASE& mapLayers = m_boardAdapter.GetMapLayers();
const MAP_CONTAINER_2D_BASE& mapLayers = m_boardAdapter.GetLayerMap();
if( m_boardAdapter.GetFlag( FL_SUBTRACT_MASK_FROM_SILK )
&& m_boardAdapter.GetFlag( FL_USE_REALISTIC_MODE )
@ -390,8 +391,8 @@ void RENDER_3D_RAYTRACE::createItemsFromContainer( const BVH_CONTAINER_2D* aCont
if( ( object2d_B == CSGITEM_EMPTY ) && ( object2d_C == CSGITEM_FULL ) )
{
LAYER_ITEM* objPtr = new LAYER_ITEM( object2d_A,
m_boardAdapter.GetLayerBottomZpos3DU( aLayer_id ) - aLayerZOffset,
m_boardAdapter.GetLayerTopZpos3DU( aLayer_id ) + aLayerZOffset );
m_boardAdapter.GetLayerBottomZPos( aLayer_id ) - aLayerZOffset,
m_boardAdapter.GetLayerTopZPos( aLayer_id ) + aLayerZOffset );
objPtr->SetMaterial( aMaterialLayer );
objPtr->SetColor( ConvertSRGBToLinear( aLayerColor ) );
m_object_container.Add( objPtr );
@ -403,8 +404,8 @@ void RENDER_3D_RAYTRACE::createItemsFromContainer( const BVH_CONTAINER_2D* aCont
m_containerWithObjectsToDelete.Add( itemCSG2d );
LAYER_ITEM* objPtr = new LAYER_ITEM( itemCSG2d,
m_boardAdapter.GetLayerBottomZpos3DU( aLayer_id ) - aLayerZOffset,
m_boardAdapter.GetLayerTopZpos3DU( aLayer_id ) + aLayerZOffset );
m_boardAdapter.GetLayerBottomZPos( aLayer_id ) - aLayerZOffset,
m_boardAdapter.GetLayerTopZPos( aLayer_id ) + aLayerZOffset );
objPtr->SetMaterial( aMaterialLayer );
objPtr->SetColor( ConvertSRGBToLinear( aLayerColor ) );
@ -434,7 +435,7 @@ void RENDER_3D_RAYTRACE::Reload( REPORTER* aStatusReporter, REPORTER* aWarningRe
{
m_boardAdapter.InitSettings( aStatusReporter, aWarningReporter );
SFVEC3F camera_pos = m_boardAdapter.GetBoardCenter3DU();
SFVEC3F camera_pos = m_boardAdapter.GetBoardCenter();
m_camera.SetBoardLookAtPos( camera_pos );
}
@ -461,10 +462,10 @@ void RENDER_3D_RAYTRACE::Reload( REPORTER* aStatusReporter, REPORTER* aWarningRe
{
float divFactor = 0.0f;
if( m_boardAdapter.GetStats_Nr_Vias() )
divFactor = m_boardAdapter.GetStats_Med_Via_Hole_Diameter3DU() * 18.0f;
else if( m_boardAdapter.GetStats_Nr_Holes() )
divFactor = m_boardAdapter.GetStats_Med_Hole_Diameter3DU() * 8.0f;
if( m_boardAdapter.GetViaCount() )
divFactor = m_boardAdapter.GetAverageViaHoleDiameter() * 18.0f;
else if( m_boardAdapter.GetHoleCount() )
divFactor = m_boardAdapter.GetAverageHoleDiameter() * 8.0f;
SHAPE_POLY_SET boardPolyCopy = m_boardAdapter.GetBoardPoly();
@ -479,8 +480,8 @@ void RENDER_3D_RAYTRACE::Reload( REPORTER* aStatusReporter, REPORTER* aWarningRe
for( int iOutlinePolyIdx = 0; iOutlinePolyIdx < antiboardPoly.OutlineCount();
iOutlinePolyIdx++ )
{
Convert_path_polygon_to_polygon_blocks_and_dummy_blocks( antiboardPoly,
*m_antioutlineBoard2dObjects, m_boardAdapter.BiuTo3Dunits(), -1.0f,
CovertPolygonToBlocks( antiboardPoly,
*m_antioutlineBoard2dObjects, m_boardAdapter.BiuTo3dUnits(), -1.0f,
*dynamic_cast<const BOARD_ITEM*>( m_boardAdapter.GetBoard() ),
iOutlinePolyIdx );
}
@ -491,10 +492,10 @@ void RENDER_3D_RAYTRACE::Reload( REPORTER* aStatusReporter, REPORTER* aWarningRe
for( int iOutlinePolyIdx = 0; iOutlinePolyIdx < outlineCount; iOutlinePolyIdx++ )
{
Convert_path_polygon_to_polygon_blocks_and_dummy_blocks( boardPolyCopy,
*m_outlineBoard2dObjects, m_boardAdapter.BiuTo3Dunits(), divFactor,
*dynamic_cast<const BOARD_ITEM*>( m_boardAdapter.GetBoard() ),
iOutlinePolyIdx );
CovertPolygonToBlocks( boardPolyCopy, *m_outlineBoard2dObjects,
m_boardAdapter.BiuTo3dUnits(), divFactor,
*dynamic_cast<const BOARD_ITEM*>( m_boardAdapter.GetBoard() ),
iOutlinePolyIdx );
}
if( m_boardAdapter.GetFlag( FL_SHOW_BOARD_BODY ) )
@ -510,10 +511,10 @@ void RENDER_3D_RAYTRACE::Reload( REPORTER* aStatusReporter, REPORTER* aWarningRe
std::vector<const OBJECT_2D*>* object2d_B = new std::vector<const OBJECT_2D*>();
// Check if there are any THT that intersects this outline object part
if( !m_boardAdapter.GetThroughHole_Outer().GetList().empty() )
if( !m_boardAdapter.GetThroughHoleOds().GetList().empty() )
{
CONST_LIST_OBJECT2D intersectionList;
m_boardAdapter.GetThroughHole_Outer().GetListObjectsIntersects(
m_boardAdapter.GetThroughHoleOds().GetListObjectsIntersects(
object2d_A->GetBBox(), intersectionList );
if( !intersectionList.empty() )
@ -556,8 +557,8 @@ void RENDER_3D_RAYTRACE::Reload( REPORTER* aStatusReporter, REPORTER* aWarningRe
if( object2d_B == CSGITEM_EMPTY )
{
LAYER_ITEM* objPtr = new LAYER_ITEM( object2d_A,
m_boardAdapter.GetLayerBottomZpos3DU( F_Cu ),
m_boardAdapter.GetLayerBottomZpos3DU( B_Cu ) );
m_boardAdapter.GetLayerBottomZPos( F_Cu ),
m_boardAdapter.GetLayerBottomZPos( B_Cu ) );
objPtr->SetMaterial( &m_materials.m_EpoxyBoard );
objPtr->SetColor(
@ -574,8 +575,8 @@ void RENDER_3D_RAYTRACE::Reload( REPORTER* aStatusReporter, REPORTER* aWarningRe
m_containerWithObjectsToDelete.Add( itemCSG2d );
LAYER_ITEM* objPtr = new LAYER_ITEM( itemCSG2d,
m_boardAdapter.GetLayerBottomZpos3DU( F_Cu ),
m_boardAdapter.GetLayerBottomZpos3DU( B_Cu ) );
m_boardAdapter.GetLayerBottomZPos( F_Cu ),
m_boardAdapter.GetLayerBottomZPos( B_Cu ) );
objPtr->SetMaterial( &m_materials.m_EpoxyBoard );
objPtr->SetColor(
@ -590,9 +591,9 @@ void RENDER_3D_RAYTRACE::Reload( REPORTER* aStatusReporter, REPORTER* aWarningRe
// a polygon or dummy block) it will cut also the render of the hole.
// So this will add a full hole.
// In fact, that is not need if the hole have copper.
if( !m_boardAdapter.GetThroughHole_Outer().GetList().empty() )
if( !m_boardAdapter.GetThroughHoleOds().GetList().empty() )
{
const LIST_OBJECT2D& holeList = m_boardAdapter.GetThroughHole_Outer().GetList();
const LIST_OBJECT2D& holeList = m_boardAdapter.GetThroughHoleOds().GetList();
for( LIST_OBJECT2D::const_iterator hole = holeList.begin();
hole != holeList.end(); ++hole )
@ -621,8 +622,8 @@ void RENDER_3D_RAYTRACE::Reload( REPORTER* aStatusReporter, REPORTER* aWarningRe
const float radius = hole2d->GetBBox().GetExtent().x * 0.5f * 0.999f;
CYLINDER* objPtr = new CYLINDER( hole2d->GetCentroid(),
NextFloatDown( m_boardAdapter.GetLayerBottomZpos3DU( F_Cu ) ),
NextFloatUp( m_boardAdapter.GetLayerBottomZpos3DU( B_Cu ) ),
NextFloatDown( m_boardAdapter.GetLayerBottomZPos( F_Cu ) ),
NextFloatUp( m_boardAdapter.GetLayerBottomZPos( B_Cu ) ),
radius );
objPtr->SetMaterial( &m_materials.m_EpoxyBoard );
@ -646,8 +647,8 @@ void RENDER_3D_RAYTRACE::Reload( REPORTER* aStatusReporter, REPORTER* aWarningRe
aStatusReporter->Report( _( "Load Raytracing: layers" ) );
// Add layers maps (except B_Mask and F_Mask)
for( MAP_CONTAINER_2D_BASE::const_iterator ii = m_boardAdapter.GetMapLayers().begin();
ii != m_boardAdapter.GetMapLayers().end(); ++ii )
for( MAP_CONTAINER_2D_BASE::const_iterator ii = m_boardAdapter.GetLayerMap().begin();
ii != m_boardAdapter.GetLayerMap().end(); ++ii )
{
PCB_LAYER_ID layer_id = static_cast<PCB_LAYER_ID>( ii->first );
@ -734,11 +735,13 @@ void RENDER_3D_RAYTRACE::Reload( REPORTER* aStatusReporter, REPORTER* aWarningRe
if( m_boardAdapter.GetFlag( FL_RENDER_PLATED_PADS_AS_PLATED )
&& m_boardAdapter.GetFlag( FL_USE_REALISTIC_MODE ) )
{
createItemsFromContainer( m_boardAdapter.GetPlatedPads_Front(), F_Cu, &m_materials.m_Copper,
m_boardAdapter.m_CopperColor, +m_boardAdapter.GetCopperThickness3DU() * 0.1f );
createItemsFromContainer( m_boardAdapter.GetPlatedPadsFront(), F_Cu, &m_materials.m_Copper,
m_boardAdapter.m_CopperColor,
m_boardAdapter.GetCopperThickness() * 0.1f );
createItemsFromContainer( m_boardAdapter.GetPlatedPads_Back(), B_Cu, &m_materials.m_Copper,
m_boardAdapter.m_CopperColor, -m_boardAdapter.GetCopperThickness3DU() * 0.1f );
createItemsFromContainer( m_boardAdapter.GetPlatedPadsBack(), B_Cu, &m_materials.m_Copper,
m_boardAdapter.m_CopperColor,
-m_boardAdapter.GetCopperThickness() * 0.1f );
}
if( !aOnlyLoadCopperAndShapes )
@ -749,12 +752,12 @@ void RENDER_3D_RAYTRACE::Reload( REPORTER* aStatusReporter, REPORTER* aWarningRe
// We will check for all objects in the outline if it intersects any object
// in the layer container and also any hole.
if( m_boardAdapter.GetFlag( FL_SOLDERMASK )
&& ( m_outlineBoard2dObjects->GetList().size() >= 1 ) )
&& ( m_outlineBoard2dObjects->GetList().size() >= 1 ) )
{
const MATERIAL* materialLayer = &m_materials.m_SolderMask;
for( MAP_CONTAINER_2D_BASE::const_iterator ii = m_boardAdapter.GetMapLayers().begin();
ii != m_boardAdapter.GetMapLayers().end(); ++ii )
for( MAP_CONTAINER_2D_BASE::const_iterator ii = m_boardAdapter.GetLayerMap().begin();
ii != m_boardAdapter.GetLayerMap().end(); ++ii )
{
PCB_LAYER_ID layer_id = static_cast<PCB_LAYER_ID>( ii->first );
@ -779,8 +782,8 @@ void RENDER_3D_RAYTRACE::Reload( REPORTER* aStatusReporter, REPORTER* aWarningRe
layerColor = m_boardAdapter.GetLayerColor( layer_id );
}
const float zLayerMin = m_boardAdapter.GetLayerBottomZpos3DU( layer_id );
const float zLayerMax = m_boardAdapter.GetLayerTopZpos3DU( layer_id );
const float zLayerMin = m_boardAdapter.GetLayerBottomZPos( layer_id );
const float zLayerMax = m_boardAdapter.GetLayerTopZPos( layer_id );
// Get the outline board objects
const LIST_OBJECT2D& listObjects = m_outlineBoard2dObjects->GetList();
@ -794,12 +797,12 @@ void RENDER_3D_RAYTRACE::Reload( REPORTER* aStatusReporter, REPORTER* aWarningRe
std::vector<const OBJECT_2D*>* object2d_B = new std::vector<const OBJECT_2D*>();
// Check if there are any THT that intersects this outline object part
if( !m_boardAdapter.GetThroughHole_Outer().GetList().empty() )
if( !m_boardAdapter.GetThroughHoleOds().GetList().empty() )
{
CONST_LIST_OBJECT2D intersectionList;
m_boardAdapter.GetThroughHole_Outer().GetListObjectsIntersects(
m_boardAdapter.GetThroughHoleOds().GetListObjectsIntersects(
object2d_A->GetBBox(), intersectionList );
if( !intersectionList.empty() )
@ -897,7 +900,7 @@ void RENDER_3D_RAYTRACE::Reload( REPORTER* aStatusReporter, REPORTER* aWarningRe
// Add floor
if( m_boardAdapter.GetFlag( FL_RENDER_RAYTRACING_BACKFLOOR ) )
{
BBOX_3D boardBBox = m_boardAdapter.GetBBox3DU();
BBOX_3D boardBBox = m_boardAdapter.GetBBox();
if( boardBBox.IsInitialized() )
{
@ -980,7 +983,7 @@ void RENDER_3D_RAYTRACE::Reload( REPORTER* aStatusReporter, REPORTER* aWarningRe
if( !IsColorZero( m_boardAdapter.m_raytrace_lightColorCamera ) )
m_lights.Add( m_camera_light );
const SFVEC3F& boardCenter = m_boardAdapter.GetBBox3DU().GetCenter();
const SFVEC3F& boardCenter = m_boardAdapter.GetBBox().GetCenter();
if( !IsColorZero( m_boardAdapter.m_raytrace_lightColorTop ) )
m_lights.Add( new POINT_LIGHT( SFVEC3F( boardCenter.x, boardCenter.y,
@ -1036,18 +1039,18 @@ void RENDER_3D_RAYTRACE::insert3DViaHole( const VIA* aVia )
aVia->LayerPair( &top_layer, &bottom_layer );
float topZ = m_boardAdapter.GetLayerBottomZpos3DU( top_layer )
+ m_boardAdapter.GetCopperThickness3DU();
float topZ = m_boardAdapter.GetLayerBottomZPos( top_layer )
+ m_boardAdapter.GetCopperThickness();
float botZ = m_boardAdapter.GetLayerBottomZpos3DU( bottom_layer )
- m_boardAdapter.GetCopperThickness3DU();
float botZ = m_boardAdapter.GetLayerBottomZPos( bottom_layer )
- m_boardAdapter.GetCopperThickness();
const SFVEC2F center = SFVEC2F( aVia->GetStart().x * m_boardAdapter.BiuTo3Dunits(),
-aVia->GetStart().y * m_boardAdapter.BiuTo3Dunits() );
const SFVEC2F center = SFVEC2F( aVia->GetStart().x * m_boardAdapter.BiuTo3dUnits(),
-aVia->GetStart().y * m_boardAdapter.BiuTo3dUnits() );
RING_2D* ring = new RING_2D( center, radiusBUI * m_boardAdapter.BiuTo3Dunits(),
( radiusBUI + m_boardAdapter.GetHolePlatingThicknessBIU() )
* m_boardAdapter.BiuTo3Dunits(), *aVia );
RING_2D* ring = new RING_2D( center, radiusBUI * m_boardAdapter.BiuTo3dUnits(),
( radiusBUI + m_boardAdapter.GetHolePlatingThickness() )
* m_boardAdapter.BiuTo3dUnits(), *aVia );
m_containerWithObjectsToDelete.Add( ring );
@ -1084,22 +1087,22 @@ void RENDER_3D_RAYTRACE::insert3DPadHole( const PAD* aPad )
CONST_LIST_OBJECT2D antiOutlineIntersectionList;
const float topZ = m_boardAdapter.GetLayerBottomZpos3DU( F_Cu )
+ m_boardAdapter.GetCopperThickness3DU() * 0.99f;
const float topZ = m_boardAdapter.GetLayerBottomZPos( F_Cu )
+ m_boardAdapter.GetCopperThickness() * 0.99f;
const float botZ = m_boardAdapter.GetLayerBottomZpos3DU( B_Cu )
- m_boardAdapter.GetCopperThickness3DU() * 0.99f;
const float botZ = m_boardAdapter.GetLayerBottomZPos( B_Cu )
- m_boardAdapter.GetCopperThickness() * 0.99f;
if( drillsize.x == drillsize.y ) // usual round hole
{
SFVEC2F center = SFVEC2F( aPad->GetPosition().x * m_boardAdapter.BiuTo3Dunits(),
-aPad->GetPosition().y * m_boardAdapter.BiuTo3Dunits() );
SFVEC2F center = SFVEC2F( aPad->GetPosition().x * m_boardAdapter.BiuTo3dUnits(),
-aPad->GetPosition().y * m_boardAdapter.BiuTo3dUnits() );
int innerRadius = drillsize.x / 2;
int outerRadius = innerRadius + m_boardAdapter.GetHolePlatingThicknessBIU();
int outerRadius = innerRadius + m_boardAdapter.GetHolePlatingThickness();
RING_2D* ring = new RING_2D( center, innerRadius * m_boardAdapter.BiuTo3Dunits(),
outerRadius * m_boardAdapter.BiuTo3Dunits(), *aPad );
RING_2D* ring = new RING_2D( center, innerRadius * m_boardAdapter.BiuTo3dUnits(),
outerRadius * m_boardAdapter.BiuTo3dUnits(), *aPad );
m_containerWithObjectsToDelete.Add( ring );
@ -1116,10 +1119,10 @@ void RENDER_3D_RAYTRACE::insert3DPadHole( const PAD* aPad )
if( !antiOutlineIntersectionList.empty() )
{
FILLED_CIRCLE_2D* innerCircle = new FILLED_CIRCLE_2D(
center, innerRadius * m_boardAdapter.BiuTo3Dunits(), *aPad );
center, innerRadius * m_boardAdapter.BiuTo3dUnits(), *aPad );
FILLED_CIRCLE_2D* outterCircle = new FILLED_CIRCLE_2D(
center, outerRadius * m_boardAdapter.BiuTo3Dunits(), *aPad );
center, outerRadius * m_boardAdapter.BiuTo3dUnits(), *aPad );
std::vector<const OBJECT_2D*>* object2d_B = new std::vector<const OBJECT_2D*>();
object2d_B->push_back( innerCircle );
@ -1155,20 +1158,19 @@ void RENDER_3D_RAYTRACE::insert3DPadHole( const PAD* aPad )
wxPoint end = aPad->GetPosition() - ends_offset;
ROUND_SEGMENT_2D* innerSeg =
new ROUND_SEGMENT_2D( SFVEC2F( start.x * m_boardAdapter.BiuTo3Dunits(),
-start.y * m_boardAdapter.BiuTo3Dunits() ),
SFVEC2F( end.x * m_boardAdapter.BiuTo3Dunits(),
-end.y * m_boardAdapter.BiuTo3Dunits() ),
width * m_boardAdapter.BiuTo3Dunits(), *aPad );
new ROUND_SEGMENT_2D( SFVEC2F( start.x * m_boardAdapter.BiuTo3dUnits(),
-start.y * m_boardAdapter.BiuTo3dUnits() ),
SFVEC2F( end.x * m_boardAdapter.BiuTo3dUnits(),
-end.y * m_boardAdapter.BiuTo3dUnits() ),
width * m_boardAdapter.BiuTo3dUnits(), *aPad );
ROUND_SEGMENT_2D* outerSeg =
new ROUND_SEGMENT_2D( SFVEC2F( start.x * m_boardAdapter.BiuTo3Dunits(),
-start.y * m_boardAdapter.BiuTo3Dunits() ),
SFVEC2F( end.x * m_boardAdapter.BiuTo3Dunits(),
-end.y * m_boardAdapter.BiuTo3Dunits() ),
( width + m_boardAdapter.GetHolePlatingThicknessBIU() * 2 )
* m_boardAdapter.BiuTo3Dunits(),
*aPad );
new ROUND_SEGMENT_2D( SFVEC2F( start.x * m_boardAdapter.BiuTo3dUnits(),
-start.y * m_boardAdapter.BiuTo3dUnits() ),
SFVEC2F( end.x * m_boardAdapter.BiuTo3dUnits(),
-end.y * m_boardAdapter.BiuTo3dUnits() ),
( width + m_boardAdapter.GetHolePlatingThickness() * 2 )
* m_boardAdapter.BiuTo3dUnits(), *aPad );
// NOTE: the round segment width is the "diameter", so we double the thickness
std::vector<const OBJECT_2D*>* object2d_B = new std::vector<const OBJECT_2D*>();
@ -1197,10 +1199,10 @@ void RENDER_3D_RAYTRACE::insert3DPadHole( const PAD* aPad )
// Check if there are any other THT that intersects this hole
// It will use the non inflated holes
if( !m_boardAdapter.GetThroughHole_Inner().GetList().empty() )
if( !m_boardAdapter.GetThroughHoleIds().GetList().empty() )
{
CONST_LIST_OBJECT2D intersectionList;
m_boardAdapter.GetThroughHole_Inner().GetListObjectsIntersects(
m_boardAdapter.GetThroughHoleIds().GetListObjectsIntersects(
object2d_A->GetBBox(), intersectionList );
if( !intersectionList.empty() )
@ -1211,7 +1213,6 @@ void RENDER_3D_RAYTRACE::insert3DPadHole( const PAD* aPad )
const OBJECT_2D* hole2d = static_cast<const OBJECT_2D*>( *hole );
if( object2d_A->Intersects( hole2d->GetBBox() ) )
//if( object2d_A->GetBBox().Intersects( hole2d->GetBBox() ) )
object2d_B->push_back( hole2d );
}
}
@ -1292,17 +1293,17 @@ void RENDER_3D_RAYTRACE::load_3D_models( CONTAINER_3D& aDstContainer,
for( FOOTPRINT* fp : m_boardAdapter.GetBoard()->Footprints() )
{
if( !fp->Models().empty()
&& m_boardAdapter.ShouldFPBeDisplayed( (FOOTPRINT_ATTR_T) fp->GetAttributes() ) )
&& m_boardAdapter.IsFootprintShown( (FOOTPRINT_ATTR_T) fp->GetAttributes() ) )
{
double zpos = m_boardAdapter.GetModulesZcoord3DIU( fp->IsFlipped() );
double zpos = m_boardAdapter.GetFootprintZPos( fp->IsFlipped() );
wxPoint pos = fp->GetPosition();
glm::mat4 fpMatrix = glm::mat4( 1.0f );
fpMatrix = glm::translate( fpMatrix,
SFVEC3F( pos.x * m_boardAdapter.BiuTo3Dunits(),
-pos.y * m_boardAdapter.BiuTo3Dunits(),
SFVEC3F( pos.x * m_boardAdapter.BiuTo3dUnits(),
-pos.y * m_boardAdapter.BiuTo3dUnits(),
zpos ) );
if( fp->GetOrientation() )
@ -1320,7 +1321,7 @@ void RENDER_3D_RAYTRACE::load_3D_models( CONTAINER_3D& aDstContainer,
}
const double modelunit_to_3d_units_factor =
m_boardAdapter.BiuTo3Dunits() * UNITS3D_TO_UNITSPCB;
m_boardAdapter.BiuTo3dUnits() * UNITS3D_TO_UNITSPCB;
fpMatrix = glm::scale(
fpMatrix, SFVEC3F( modelunit_to_3d_units_factor, modelunit_to_3d_units_factor,
@ -1329,7 +1330,7 @@ void RENDER_3D_RAYTRACE::load_3D_models( CONTAINER_3D& aDstContainer,
BOARD_ITEM* boardItem = dynamic_cast<BOARD_ITEM*>( fp );
// Get the list of model files for this model
S3D_CACHE* cacheMgr = m_boardAdapter.Get3DCacheManager();
S3D_CACHE* cacheMgr = m_boardAdapter.Get3dCacheManager();
auto sM = fp->Models().begin();
auto eM = fp->Models().end();
@ -1398,7 +1399,7 @@ MODEL_MATERIALS* RENDER_3D_RAYTRACE::get_3D_model_material( const S3DMODEL* a3DM
for( unsigned int imat = 0; imat < a3DModel->m_MaterialsSize; ++imat )
{
if( m_boardAdapter.MaterialModeGet() == MATERIAL_MODE::NORMAL )
if( m_boardAdapter.GetMaterialMode() == MATERIAL_MODE::NORMAL )
{
const SMATERIAL& material = a3DModel->m_Materials[imat];
@ -1590,7 +1591,7 @@ void RENDER_3D_RAYTRACE::add_3D_models( CONTAINER_3D& aDstContainer, const S3DMO
const SFVEC3F diffuseColor =
a3DModel->m_Materials[mesh.m_MaterialIdx].m_Diffuse;
if( m_boardAdapter.MaterialModeGet() == MATERIAL_MODE::CAD_MODE )
if( m_boardAdapter.GetMaterialMode() == MATERIAL_MODE::CAD_MODE )
newTriangle->SetColor( ConvertSRGBToLinear(
MaterialDiffuseToColorCAD( diffuseColor ) ) );
else
@ -1598,7 +1599,7 @@ void RENDER_3D_RAYTRACE::add_3D_models( CONTAINER_3D& aDstContainer, const S3DMO
}
else
{
if( m_boardAdapter.MaterialModeGet() == MATERIAL_MODE::CAD_MODE )
if( m_boardAdapter.GetMaterialMode() == MATERIAL_MODE::CAD_MODE )
newTriangle->SetColor(
ConvertSRGBToLinear( MaterialDiffuseToColorCAD(
mesh.m_Color[idx0] ) ),

View File

@ -301,7 +301,7 @@ void RENDER_3D_RAYTRACE::render( GLubyte* ptrPBO, REPORTER* aStatusReporter )
if( m_camera_light )
m_camera_light->SetDirection( -m_camera.GetDir() );
if( m_boardAdapter.RenderEngineGet() == RENDER_ENGINE::OPENGL_LEGACY )
if( m_boardAdapter.GetRenderEngine() == 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 (
@ -1571,7 +1571,7 @@ SFVEC3F RENDER_3D_RAYTRACE::shadeHit( const SFVEC3F& aBgColor, const RAY& aRay,
SFVEC3F hitPoint = aHitInfo.m_HitPoint;
hitPoint += aHitInfo.m_HitNormal * m_boardAdapter.GetNonCopperLayerThickness3DU() * 0.6f;
hitPoint += aHitInfo.m_HitNormal * m_boardAdapter.GetNonCopperLayerThickness() * 0.6f;
const SFVEC3F diffuseColorObj = aHitInfo.pHitObject->GetDiffuseColor( aHitInfo );
@ -1766,7 +1766,7 @@ SFVEC3F RENDER_3D_RAYTRACE::shadeHit( const SFVEC3F& aBgColor, const RAY& aRay,
// This increase the start point by a "fixed" factor so it will work the
// same for all distances
const SFVEC3F startPoint =
aRay.at( aHitInfo.m_tHit + m_boardAdapter.GetNonCopperLayerThickness3DU() *
aRay.at( aHitInfo.m_tHit + m_boardAdapter.GetNonCopperLayerThickness() *
0.25f );
const unsigned int refractions_number_of_samples =

View File

@ -28,6 +28,7 @@
#include "4pt_polygon_2d.h"
#include <wx/debug.h>
#include "../ray.h"
POLYGON_4PT_2D::POLYGON_4PT_2D( const SFVEC2F& v1, const SFVEC2F& v2, const SFVEC2F& v3,

View File

@ -30,6 +30,7 @@
#include "3d_fastmath.h"
#include "bbox_2d.h"
#include "../ray.h"
#include <wx/debug.h>
@ -117,7 +118,7 @@ void BBOX_2D::Union( const BBOX_2D& aBBox )
SFVEC2F BBOX_2D::GetCenter() const
{
return (m_max + m_min) * 0.5f;
return ( m_max + m_min ) * 0.5f;
}
@ -153,8 +154,8 @@ void BBOX_2D::Scale( float aScale )
const SFVEC2F scaleV( aScale, aScale );
const SFVEC2F centerV = GetCenter();
m_min = (m_min - centerV) * scaleV + centerV;
m_max = (m_max - centerV) * scaleV + centerV;
m_min = ( m_min - centerV ) * scaleV + centerV;
m_max = ( m_max - centerV ) * scaleV + centerV;
}
@ -240,14 +241,14 @@ bool BBOX_2D::Intersect( const RAY2D& aRay, float* t ) const
{
wxASSERT( t );
const float tx1 = (m_min.x - aRay.m_Origin.x) * aRay.m_InvDir.x;
const float tx2 = (m_max.x - aRay.m_Origin.x) * aRay.m_InvDir.x;
const float tx1 = ( m_min.x - aRay.m_Origin.x ) * aRay.m_InvDir.x;
const float tx2 = ( m_max.x - aRay.m_Origin.x ) * aRay.m_InvDir.x;
float tmin = glm::min( tx1, tx2 );
float tmax = glm::max( tx1, tx2 );
const float ty1 = (m_min.y - aRay.m_Origin.y) * aRay.m_InvDir.y;
const float ty2 = (m_max.y - aRay.m_Origin.y) * aRay.m_InvDir.y;
const float ty1 = ( m_min.y - aRay.m_Origin.y ) * aRay.m_InvDir.y;
const float ty2 = ( m_max.y - aRay.m_Origin.y ) * aRay.m_InvDir.y;
tmin = glm::max( tmin, glm::min( ty1, ty2 ) );
tmax = glm::min( tmax, glm::max( ty1, ty2 ) );
@ -306,5 +307,5 @@ bool BBOX_2D::Intersect( const RAY2D& aRay, float* aOutHitT0, float* aOutHitT1 )
*aOutHitT0 = (tmin > 0.0f)?tmin:0.0f;
*aOutHitT1 = tmax;
return (tmax >= 0.0f) && (tmax >= tmin);
return ( tmax >= 0.0f ) && ( tmax >= tmin );
}

View File

@ -30,8 +30,10 @@
#ifndef _BBOX_2D_H_
#define _BBOX_2D_H_
#include "../ray.h"
#include <plugins/3dapi/xv3d_types.h> // SFVEC2F
class RAY2D;
class RAYSEG2D;
/**
* Manage a bounding box defined by two SFVEC2F min max points.

View File

@ -28,6 +28,7 @@
*/
#include "filled_circle_2d.h"
#include "../ray.h"
#include <wx/debug.h>

View File

@ -24,10 +24,10 @@
/**
* @file layer_item_2d.cpp
* @brief
*/
#include "layer_item_2d.h"
#include "../ray.h"
#include "3d_fastmath.h"
#include <wx/debug.h>

View File

@ -33,6 +33,7 @@
#include "object_2d.h"
#include <vector>
class RAYSEG2D;
#define CSGITEM_EMPTY 0
#define CSGITEM_FULL (OBJECT_2D*) ( ( size_t )( -1 ) )

View File

@ -27,13 +27,13 @@
*/
#include "object_2d.h"
#include <cstdio>
#include <wx/log.h>
#include <map>
OBJECT_2D_STATS *OBJECT_2D_STATS::s_instance = 0;
OBJECT_2D::OBJECT_2D( OBJECT_2D_TYPE aObjType, const BOARD_ITEM &aBoardItem )
OBJECT_2D::OBJECT_2D( OBJECT_2D_TYPE aObjType, const BOARD_ITEM& aBoardItem )
: m_boardItem(aBoardItem)
{
m_obj_type = aObjType;

View File

@ -30,9 +30,8 @@
#define _OBJECT_2D_H_
#include "bbox_2d.h"
#include <cstring>
#include <board_item.h>
class BOARD_ITEM;
enum class INTERSECTION_RESULT
{

View File

@ -27,12 +27,9 @@
*/
#include "polygon_2d.h"
#include "../ray.h"
#include <wx/debug.h>
#ifdef PRINT_STATISTICS_3D_VIEWER
#include <stdio.h>
#endif
static bool polygon_IsPointInside( const SEGMENTS& aSegments, const SFVEC2F& aPoint )
{
@ -352,7 +349,7 @@ static void extractPathsFrom( const SEGMENTS_WIDTH_NORMALS& aSegList, const BBOX
static void polygon_Convert( const SHAPE_LINE_CHAIN& aPath, SEGMENTS& aOutSegment,
float aBiuTo3DunitsScale )
float aBiuTo3dUnitsScale )
{
aOutSegment.resize( aPath.PointCount() );
@ -360,8 +357,8 @@ static void polygon_Convert( const SHAPE_LINE_CHAIN& aPath, SEGMENTS& aOutSegmen
{
const VECTOR2I& a = aPath.CPoint( j );
aOutSegment[j].m_Start = SFVEC2F( (float) a.x * aBiuTo3DunitsScale,
(float) -a.y * aBiuTo3DunitsScale );
aOutSegment[j].m_Start = SFVEC2F( (float) a.x * aBiuTo3dUnitsScale,
(float) -a.y * aBiuTo3dUnitsScale );
}
unsigned int i;
@ -378,9 +375,9 @@ static void polygon_Convert( const SHAPE_LINE_CHAIN& aPath, SEGMENTS& aOutSegmen
}
void Convert_path_polygon_to_polygon_blocks_and_dummy_blocks( const SHAPE_POLY_SET& aMainPath,
CONTAINER_2D_BASE& aDstContainer, float aBiuTo3DunitsScale, float aDivFactor,
const BOARD_ITEM& aBoardItem, int aPolyIndex )
void CovertPolygonToBlocks( const SHAPE_POLY_SET& aMainPath, CONTAINER_2D_BASE& aDstContainer,
float aBiuTo3dUnitsScale, float aDivFactor,
const BOARD_ITEM& aBoardItem, int aPolyIndex )
{
// Get the path
wxASSERT( aPolyIndex < aMainPath.OutlineCount() );
@ -408,8 +405,8 @@ void Convert_path_polygon_to_polygon_blocks_and_dummy_blocks( const SHAPE_POLY_S
{
const VECTOR2I& a = path.CPoint( i );
const SFVEC2F point( (float) ( a.x ) * aBiuTo3DunitsScale,
(float) ( -a.y ) * aBiuTo3DunitsScale );
const SFVEC2F point( (float) ( a.x ) * aBiuTo3dUnitsScale,
(float) ( -a.y ) * aBiuTo3dUnitsScale );
// Only add points that are not coincident
if( ( i == 0 ) || ( fabs( prevPoint.x - point.x ) > FLT_EPSILON )
@ -631,7 +628,7 @@ void Convert_path_polygon_to_polygon_blocks_and_dummy_blocks( const SHAPE_POLY_S
SEGMENTS solutionSegment;
polygon_Convert( outline, solutionSegment, aBiuTo3DunitsScale );
polygon_Convert( outline, solutionSegment, aBiuTo3dUnitsScale );
outersAndHoles.m_Outers.push_back( solutionSegment );
stats_sum_size_of_polygons += solutionSegment.size();
@ -640,7 +637,7 @@ void Convert_path_polygon_to_polygon_blocks_and_dummy_blocks( const SHAPE_POLY_S
{
const SHAPE_LINE_CHAIN& hole = solution.Hole( idx, holeIdx );
polygon_Convert( hole, solutionSegment, aBiuTo3DunitsScale );
polygon_Convert( hole, solutionSegment, aBiuTo3dUnitsScale );
outersAndHoles.m_Holes.push_back( solutionSegment );
stats_sum_size_of_polygons += solutionSegment.size();
}
@ -666,14 +663,14 @@ void Convert_path_polygon_to_polygon_blocks_and_dummy_blocks( const SHAPE_POLY_S
#ifdef DEBUG
static void polygon_Convert( const ClipperLib::Path& aPath, SEGMENTS& aOutSegment,
float aBiuTo3DunitsScale )
float aBiuTo3dUnitsScale )
{
aOutSegment.resize( aPath.size() );
for( unsigned i = 0; i < aPath.size(); i++ )
{
aOutSegment[i].m_Start = SFVEC2F(
(float) aPath[i].X * aBiuTo3DunitsScale, (float) -aPath[i].Y * aBiuTo3DunitsScale );
(float) aPath[i].X * aBiuTo3dUnitsScale, (float) -aPath[i].Y * aBiuTo3dUnitsScale );
}
unsigned int i;

View File

@ -145,17 +145,13 @@ public:
*
* @param aMainPath the polygon are that was converted from the pcb board
* @param aDstContainer the destination container to put the created sub blocks
* @param aBiuTo3DunitsScale the rendering target 3d scale
* @param aBiuTo3dUnitsScale the rendering target 3d scale
* @param aDivFactor a division factor (in 3Dunits) to divide the polygon plane,
* 0.0f will use the internal polygon segm statistics
*/
void Convert_path_polygon_to_polygon_blocks_and_dummy_blocks(
const SHAPE_POLY_SET& aMainPath,
CONTAINER_2D_BASE& aDstContainer,
float aBiuTo3DunitsScale,
float aDivFactor,
const BOARD_ITEM& aBoardItem,
int aPolyIndex );
void CovertPolygonToBlocks( const SHAPE_POLY_SET& aMainPath, CONTAINER_2D_BASE& aDstContainer,
float aBiuTo3dUnitsScale, float aDivFactor,
const BOARD_ITEM& aBoardItem, int aPolyIndex );
void Polygon2d_TestModule();

View File

@ -28,6 +28,7 @@
#include "ring_2d.h"
#include "../../../3d_fastmath.h"
#include "../ray.h"
#include <wx/debug.h>

View File

@ -30,6 +30,10 @@
#define _ROUND_SEGMENT_2D_H_
#include "object_2d.h"
#include "../ray.h"
#include <plugins/3dapi/xv3d_types.h> // SFVEC2F
class BOARD_ITEM;
class ROUND_SEGMENT_2D : public OBJECT_2D
{
@ -95,10 +99,9 @@ inline bool Is_segment_a_circle( const SFVEC2F& aStart, const SFVEC2F& aEnd )
{
const SFVEC2F vec = aEnd - aStart;
return (aStart == aEnd) ||
// This is the same as calc the length squared (without the sqrt)
// and compare with a small value
( glm::dot( vec, vec ) <= s_min_dot );
// This is the same as calc the length squared (without the sqrt)
// and compare with a small value.
return (aStart == aEnd) || ( glm::dot( vec, vec ) <= s_min_dot );
}
#endif // _ROUND_SEGMENT_2D_H_

View File

@ -27,13 +27,8 @@
*/
#include "triangle_2d.h"
#include <map>
#include <boost/smart_ptr/shared_ptr.hpp>
#include <boost/smart_ptr/shared_array.hpp>
#include "../ray.h"
#include <wx/debug.h>
#include <wx/glcanvas.h> // CALLBACK definition, needed on Windows
// also needed on OSX to define __DARWIN__
#include <geometry/polygon_triangulation.h>
#include "../../../3d_fastmath.h"
@ -123,17 +118,15 @@ bool TRIANGLE_2D::IsPointInside( const SFVEC2F& aPoint ) const
}
void Convert_shape_line_polygon_to_triangles( SHAPE_POLY_SET& aPolyList,
CONTAINER_2D_BASE& aDstContainer,
float aBiuTo3DunitsScale ,
const BOARD_ITEM& aBoardItem )
void ConvertPolygonToTriangles( SHAPE_POLY_SET& aPolyList, CONTAINER_2D_BASE& aDstContainer,
float aBiuTo3dUnitsScale, const BOARD_ITEM& aBoardItem )
{
VECTOR2I a;
VECTOR2I b;
VECTOR2I c;
aPolyList.CacheTriangulation( false );
const double conver_d = (double)aBiuTo3DunitsScale;
const double conver_d = (double)aBiuTo3dUnitsScale;
for( unsigned int j = 0; j < aPolyList.TriangulatedPolyCount(); j++ )
{

View File

@ -64,8 +64,6 @@ private:
};
void Convert_shape_line_polygon_to_triangles( SHAPE_POLY_SET& aPolyList,
CONTAINER_2D_BASE& aDstContainer,
float aBiuTo3DunitsScale,
const BOARD_ITEM& aBoardItem );
void ConvertPolygonToTriangles( SHAPE_POLY_SET& aPolyList, CONTAINER_2D_BASE& aDstContainer,
float aBiuTo3dUnitsScale, const BOARD_ITEM& aBoardItem );
#endif // _TRIANGLE_2D_H_

View File

@ -29,7 +29,7 @@
#include "3d_fastmath.h"
#include "bbox_3d.h"
#include <cstdio>
#include "../ray.h"
#include <wx/log.h>
#include <wx/debug.h> // For the wxASSERT

View File

@ -30,7 +30,10 @@
#ifndef _BBOX_3D_H_
#define _BBOX_3D_H_
#include "../ray.h"
#include <plugins/3dapi/xv3d_types.h> // SFVEC2F
class RAY;
/**
* Manage a bounding box defined by two SFVEC3F min max points.

View File

@ -28,6 +28,7 @@
*/
#include "bbox_3d.h"
#include "../ray.h"
#include <wx/debug.h>
// This BBOX Ray intersection test have the following credits:

View File

@ -28,7 +28,8 @@
*/
#include "object_3d.h"
#include <cstdio>
#include <board_item.h>
#include "../hitinfo.h"
#include <map>

View File

@ -30,10 +30,10 @@
#define _OBJECT_3D_H_
#include "bbox_3d.h"
#include "../hitinfo.h"
#include "../material.h"
#include <board_item.h>
class BOARD_ITEM;
class HITINFOR;
enum class OBJECT_3D_TYPE
{
@ -61,7 +61,7 @@ public:
m_modelTransparency = aMaterial->GetTransparency(); // Default transparency is from material
}
const MATERIAL *GetMaterial() const { return m_material; }
const MATERIAL* GetMaterial() const { return m_material; }
float GetModelTransparency() const { return m_modelTransparency; }
void SetModelTransparency( float aModelTransparency )
{

View File

@ -27,6 +27,7 @@
*/
#include "round_segment_3d.h"
#include "../shapes2D/round_segment_2d.h"
ROUND_SEGMENT::ROUND_SEGMENT( const ROUND_SEGMENT_2D& aSeg2D, float aZmin, float aZmax ) :
@ -229,7 +230,7 @@ bool ROUND_SEGMENT::Intersect( const RAY& aRay, HITINFO& aHitInfo ) const
if( delta_End > FLT_EPSILON )
{
const float sdelta = sqrtf( delta_End );
const float t = (-b_End - sdelta) / a;
const float t = ( -b_End - sdelta ) / a;
const float z = aRay.m_Origin.z + t * aRay.m_Dir.z;
if( ( z >= m_bbox.Min().z ) && ( z <= m_bbox.Max().z ) )
@ -239,8 +240,7 @@ bool ROUND_SEGMENT::Intersect( const RAY& aRay, HITINFO& aHitInfo ) const
aHitInfo.m_tHit = t;
aHitInfo.m_HitPoint = aRay.at( t );
const SFVEC2F hitPoint2D = SFVEC2F( aHitInfo.m_HitPoint.x,
aHitInfo.m_HitPoint.y );
const SFVEC2F hitPoint2D = SFVEC2F( aHitInfo.m_HitPoint.x, aHitInfo.m_HitPoint.y );
aHitInfo.m_HitNormal = SFVEC3F(
(hitPoint2D.x - m_segment.m_End.x) * m_inv_radius,

View File

@ -30,7 +30,8 @@
#define _ROUND_SEGMENT_H_
#include "object_3d.h"
#include "../shapes2D/round_segment_2d.h"
class ROUND_SEGMENT_2D;
class ROUND_SEGMENT : public OBJECT_3D
{

View File

@ -36,6 +36,7 @@
#include "../3d_math.h"
#include <wx/debug.h>
#include <chrono>
#include <memory>
/*
@ -99,7 +100,7 @@ MODEL_3D::MODEL_3D( const S3DMODEL& a3DModel, MATERIAL_MODE aMaterialMode )
wxASSERT( a3DModel.m_MaterialsSize > 0 );
wxASSERT( a3DModel.m_MeshesSize > 0 );
m_material_mode = aMaterialMode;
m_materialMode = aMaterialMode;
if( a3DModel.m_Materials == nullptr || a3DModel.m_Meshes == nullptr
|| a3DModel.m_MaterialsSize == 0 || a3DModel.m_MeshesSize == 0 )
@ -399,7 +400,7 @@ void MODEL_3D::EndDrawMulti()
void MODEL_3D::Draw( bool aTransparent, float aOpacity, bool aUseSelectedMaterial,
SFVEC3F aSelectionColor ) const
SFVEC3F& aSelectionColor ) const
{
if( aOpacity <= FLT_EPSILON )
return;
@ -418,7 +419,7 @@ void MODEL_3D::Draw( bool aTransparent, float aOpacity, bool aUseSelectedMateria
glColorPointer( 4, GL_UNSIGNED_BYTE, sizeof( VERTEX ),
reinterpret_cast<const void*>(
m_material_mode == MATERIAL_MODE::CAD_MODE
m_materialMode == MATERIAL_MODE::CAD_MODE
? offsetof( VERTEX, m_cad_color )
: offsetof( VERTEX, m_color ) ) );
@ -435,7 +436,7 @@ void MODEL_3D::Draw( bool aTransparent, float aOpacity, bool aUseSelectedMateria
if( ( mat.IsTransparent() != aTransparent ) && ( aOpacity >= 1.0f ) )
continue;
switch( m_material_mode )
switch( m_materialMode )
{
case MATERIAL_MODE::NORMAL:
OGL_SetMaterial( mat, aOpacity, aUseSelectedMaterial, aSelectionColor );
@ -471,7 +472,7 @@ MODEL_3D::~MODEL_3D()
}
void MODEL_3D::Draw_bbox() const
void MODEL_3D::DrawBbox() const
{
if( !glBindBuffer )
throw std::runtime_error( "The OpenGL context no longer exists: unable to draw bbox" );
@ -490,7 +491,7 @@ void MODEL_3D::Draw_bbox() const
}
void MODEL_3D::Draw_bboxes() const
void MODEL_3D::DrawBboxes() const
{
if( !glBindBuffer )
throw std::runtime_error( "The OpenGL context no longer exists: unable to draw bboxes" );

View File

@ -55,7 +55,7 @@ public:
/**
* Render the model into the current context.
*/
void Draw_opaque( bool aUseSelectedMaterial, SFVEC3F aSelectionColor = SFVEC3F( 0.0f ) ) const
void DrawOpaque( bool aUseSelectedMaterial, SFVEC3F aSelectionColor = SFVEC3F( 0.0f ) ) const
{
Draw( false, 1.0f, aUseSelectedMaterial, aSelectionColor );
}
@ -63,8 +63,8 @@ public:
/**
* Render the model into the current context.
*/
void Draw_transparent( float aOpacity, bool aUseSelectedMaterial,
SFVEC3F aSelectionColor = SFVEC3F( 0.0f ) ) const
void DrawTransparent( float aOpacity, bool aUseSelectedMaterial,
SFVEC3F aSelectionColor = SFVEC3F( 0.0f ) ) const
{
Draw( true, aOpacity, aUseSelectedMaterial, aSelectionColor );
}
@ -72,22 +72,22 @@ public:
/**
* Return true if have opaque meshes to render.
*/
bool Have_opaque() const { return m_have_opaque_meshes; }
bool HasOpaqueMeshes() const { return m_have_opaque_meshes; }
/**
* Return true if have transparent mesh's to render.
*/
bool Have_transparent() const { return m_have_transparent_meshes; }
bool HasTransparentMeshes() const { return m_have_transparent_meshes; }
/**
* Draw main bounding box of the model.
*/
void Draw_bbox() const;
void DrawBbox() const;
/**
* Draw individual bounding boxes of each mesh.
*/
void Draw_bboxes() const;
void DrawBboxes() const;
/**
* Get the main bounding box.
@ -111,7 +111,7 @@ private:
// the material mode that was used to generate the rendering data.
// FIXME: this can be selected at run-time and does not require re-creation
// of the whole model objects.
MATERIAL_MODE m_material_mode;
MATERIAL_MODE m_materialMode;
BBOX_3D m_model_bbox; ///< global bounding box for this model
std::vector<BBOX_3D> m_meshes_bbox; ///< individual bbox for each mesh
@ -164,7 +164,7 @@ private:
GLuint* aIdxOut, const glm::vec4& aColor );
void Draw( bool aTransparent, float aOpacity, bool aUseSelectedMaterial,
SFVEC3F aSelectionColor ) const;
SFVEC3F& aSelectionColor ) const;
};
#endif // _MODEL_3D_H_

View File

@ -32,17 +32,16 @@
#include <profile.h> // To use GetRunningMicroSecs or another profiling utility
void RENDER_3D_LEGACY::add_object_to_triangle_layer( const FILLED_CIRCLE_2D* aFilledCircle,
TRIANGLE_DISPLAY_LIST* aDstLayer,
float aZtop, float aZbot )
void RENDER_3D_LEGACY::addObjectTriangles( const FILLED_CIRCLE_2D* aFilledCircle,
TRIANGLE_DISPLAY_LIST* aDstLayer,
float aZtop, float aZbot )
{
const SFVEC2F& center = aFilledCircle->GetCenter();
const float radius = aFilledCircle->GetRadius() *
2.0f; // Double because the render triangle
const float radius = aFilledCircle->GetRadius() * 2.0f; // Double because the render triangle
// This is a small adjustment to the circle texture
const float texture_factor = (8.0f / (float)SIZE_OF_CIRCLE_TEXTURE) + 1.0f;
const float f = (sqrtf(2.0f) / 2.0f) * radius * texture_factor;
const float texture_factor = ( 8.0f / (float) SIZE_OF_CIRCLE_TEXTURE ) + 1.0f;
const float f = ( sqrtf( 2.0f ) / 2.0f ) * radius * texture_factor;
// Top and Bot segments ends are just triangle semi-circles, so need to add it in duplicated.
aDstLayer->m_layer_top_segment_ends->AddTriangle( SFVEC3F( center.x + f, center.y, aZtop ),
@ -63,25 +62,25 @@ void RENDER_3D_LEGACY::add_object_to_triangle_layer( const FILLED_CIRCLE_2D* aFi
}
void RENDER_3D_LEGACY::add_object_to_triangle_layer( const POLYGON_4PT_2D* aPoly,
TRIANGLE_DISPLAY_LIST* aDstLayer,
float aZtop, float aZbot )
void RENDER_3D_LEGACY::addObjectTriangles( const POLYGON_4PT_2D* aPoly,
TRIANGLE_DISPLAY_LIST* aDstLayer,
float aZtop, float aZbot )
{
const SFVEC2F& v0 = aPoly->GetV0();
const SFVEC2F& v1 = aPoly->GetV1();
const SFVEC2F& v2 = aPoly->GetV2();
const SFVEC2F& v3 = aPoly->GetV3();
add_triangle_top_bot( aDstLayer, v0, v2, v1, aZtop, aZbot );
add_triangle_top_bot( aDstLayer, v2, v0, v3, aZtop, aZbot );
addTopAndBottomTriangles( aDstLayer, v0, v2, v1, aZtop, aZbot );
addTopAndBottomTriangles( aDstLayer, v2, v0, v3, aZtop, aZbot );
}
void RENDER_3D_LEGACY::generate_ring_contour( const SFVEC2F& aCenter, float aInnerRadius,
float aOuterRadius, unsigned int aNr_sides_per_circle,
std::vector< SFVEC2F >& aInnerContourResult,
std::vector< SFVEC2F >& aOuterContourResult,
bool aInvertOrder )
void RENDER_3D_LEGACY::generateRing( const SFVEC2F& aCenter, float aInnerRadius,
float aOuterRadius, unsigned int aNr_sides_per_circle,
std::vector< SFVEC2F >& aInnerContourResult,
std::vector< SFVEC2F >& aOuterContourResult,
bool aInvertOrder )
{
aInnerContourResult.clear();
aInnerContourResult.reserve( aNr_sides_per_circle + 2 );
@ -111,7 +110,7 @@ void RENDER_3D_LEGACY::generate_ring_contour( const SFVEC2F& aCenter, float aInn
}
void RENDER_3D_LEGACY::add_object_to_triangle_layer( const RING_2D* aRing,
void RENDER_3D_LEGACY::addObjectTriangles( const RING_2D* aRing,
TRIANGLE_DISPLAY_LIST* aDstLayer,
float aZtop, float aZbot )
{
@ -122,8 +121,8 @@ void RENDER_3D_LEGACY::add_object_to_triangle_layer( const RING_2D* aRing,
std::vector< SFVEC2F > innerContour;
std::vector< SFVEC2F > outerContour;
generate_ring_contour( center, inner, outer, m_boardAdapter.GetNrSegmentsCircle( outer * 2.0f ),
innerContour, outerContour, false );
generateRing( center, inner, outer, m_boardAdapter.GetCircleSegmentCount( outer * 2.0f ),
innerContour, outerContour, false );
// This will add the top and bot quads that will form the approximated ring
for( unsigned int i = 0; i < ( innerContour.size() - 1 ); ++i )
@ -146,21 +145,21 @@ void RENDER_3D_LEGACY::add_object_to_triangle_layer( const RING_2D* aRing,
}
void RENDER_3D_LEGACY::add_object_to_triangle_layer( const TRIANGLE_2D* aTri,
TRIANGLE_DISPLAY_LIST* aDstLayer,
float aZtop, float aZbot )
void RENDER_3D_LEGACY::addObjectTriangles( const TRIANGLE_2D* aTri,
TRIANGLE_DISPLAY_LIST* aDstLayer,
float aZtop, float aZbot )
{
const SFVEC2F& v1 = aTri->GetP1();
const SFVEC2F& v2 = aTri->GetP2();
const SFVEC2F& v3 = aTri->GetP3();
add_triangle_top_bot( aDstLayer, v1, v2, v3, aZtop, aZbot );
addTopAndBottomTriangles( aDstLayer, v1, v2, v3, aZtop, aZbot );
}
void RENDER_3D_LEGACY::add_object_to_triangle_layer( const ROUND_SEGMENT_2D* aSeg,
TRIANGLE_DISPLAY_LIST* aDstLayer,
float aZtop, float aZbot )
void RENDER_3D_LEGACY::addObjectTriangles( const ROUND_SEGMENT_2D* aSeg,
TRIANGLE_DISPLAY_LIST* aDstLayer,
float aZtop, float aZbot )
{
const SFVEC2F& leftStart = aSeg->GetLeftStar();
const SFVEC2F& leftEnd = aSeg->GetLeftEnd();
@ -243,9 +242,10 @@ void RENDER_3D_LEGACY::add_object_to_triangle_layer( const ROUND_SEGMENT_2D* aSe
}
OPENGL_RENDER_LIST* RENDER_3D_LEGACY::generate_holes_display_list(
const LIST_OBJECT2D& aListHolesObject2d, const SHAPE_POLY_SET& aPoly,
float aZtop, float aZbot, bool aInvertFaces, const BVH_CONTAINER_2D* aThroughHoles )
OPENGL_RENDER_LIST* RENDER_3D_LEGACY::generateHoles( const LIST_OBJECT2D& aListHolesObject2d,
const SHAPE_POLY_SET& aPoly, float aZtop,
float aZbot, bool aInvertFaces,
const BVH_CONTAINER_2D* aThroughHoles )
{
OPENGL_RENDER_LIST* ret = nullptr;
@ -267,18 +267,17 @@ OPENGL_RENDER_LIST* RENDER_3D_LEGACY::generate_holes_display_list(
switch( object2d_A->GetObjectType() )
{
case OBJECT_2D_TYPE::FILLED_CIRCLE:
add_object_to_triangle_layer( static_cast<const FILLED_CIRCLE_2D*>( object2d_A ),
layerTriangles, aZtop, aZbot );
addObjectTriangles( static_cast<const FILLED_CIRCLE_2D*>( object2d_A ),
layerTriangles, aZtop, aZbot );
break;
case OBJECT_2D_TYPE::ROUNDSEG:
add_object_to_triangle_layer( static_cast<const ROUND_SEGMENT_2D*>( object2d_A ),
layerTriangles, aZtop, aZbot );
addObjectTriangles( static_cast<const ROUND_SEGMENT_2D*>( object2d_A ),
layerTriangles, aZtop, aZbot );
break;
default:
wxFAIL_MSG( "RENDER_3D_LEGACY::generate_holes_display_list: "
"Object type is not implemented" );
wxFAIL_MSG( "RENDER_3D_LEGACY::generateHoles: Object type is not implemented" );
break;
}
}
@ -288,11 +287,11 @@ OPENGL_RENDER_LIST* RENDER_3D_LEGACY::generate_holes_display_list(
if( aPoly.OutlineCount() > 0 )
{
layerTriangles->AddToMiddleContourns( aPoly, aZbot, aZtop,
m_boardAdapter.BiuTo3Dunits(),
m_boardAdapter.BiuTo3dUnits(),
aInvertFaces, aThroughHoles );
}
ret = new OPENGL_RENDER_LIST( *layerTriangles, m_ogl_circle_texture, aZbot, aZtop );
ret = new OPENGL_RENDER_LIST( *layerTriangles, m_circleTexture, aZbot, aZtop );
delete layerTriangles;
}
@ -301,11 +300,10 @@ OPENGL_RENDER_LIST* RENDER_3D_LEGACY::generate_holes_display_list(
}
OPENGL_RENDER_LIST*
RENDER_3D_LEGACY::generateLayerListFromContainer( const BVH_CONTAINER_2D* aContainer,
const SHAPE_POLY_SET* aPolyList,
PCB_LAYER_ID aLayerId,
const BVH_CONTAINER_2D* aThroughHoles )
OPENGL_RENDER_LIST* RENDER_3D_LEGACY::generateLayerList( const BVH_CONTAINER_2D* aContainer,
const SHAPE_POLY_SET* aPolyList,
PCB_LAYER_ID aLayerId,
const BVH_CONTAINER_2D* aThroughHoles )
{
if( aContainer == nullptr )
return nullptr;
@ -318,7 +316,7 @@ RENDER_3D_LEGACY::generateLayerListFromContainer( const BVH_CONTAINER_2D* aConta
float layer_z_bot = 0.0f;
float layer_z_top = 0.0f;
get_layer_z_pos( aLayerId, layer_z_top, layer_z_bot );
getLayerZPos( aLayerId, layer_z_top, layer_z_bot );
// Calculate an estimation for the nr of triangles based on the nr of objects
unsigned int nrTrianglesEstimation = listObject2d.size() * 8;
@ -338,28 +336,28 @@ RENDER_3D_LEGACY::generateLayerListFromContainer( const BVH_CONTAINER_2D* aConta
switch( object2d_A->GetObjectType() )
{
case OBJECT_2D_TYPE::FILLED_CIRCLE:
add_object_to_triangle_layer( (const FILLED_CIRCLE_2D *)object2d_A,
layerTriangles, layer_z_top, layer_z_bot );
addObjectTriangles( (const FILLED_CIRCLE_2D *)object2d_A, layerTriangles,
layer_z_top, layer_z_bot );
break;
case OBJECT_2D_TYPE::POLYGON4PT:
add_object_to_triangle_layer( (const POLYGON_4PT_2D*)object2d_A,
layerTriangles, layer_z_top, layer_z_bot );
addObjectTriangles( (const POLYGON_4PT_2D*)object2d_A, layerTriangles,
layer_z_top, layer_z_bot );
break;
case OBJECT_2D_TYPE::RING:
add_object_to_triangle_layer( (const RING_2D*)object2d_A,
layerTriangles, layer_z_top, layer_z_bot );
addObjectTriangles( (const RING_2D*)object2d_A, layerTriangles, layer_z_top,
layer_z_bot );
break;
case OBJECT_2D_TYPE::TRIANGLE:
add_object_to_triangle_layer( (const TRIANGLE_2D*)object2d_A,
layerTriangles, layer_z_top, layer_z_bot );
addObjectTriangles( (const TRIANGLE_2D*)object2d_A, layerTriangles, layer_z_top,
layer_z_bot );
break;
case OBJECT_2D_TYPE::ROUNDSEG:
add_object_to_triangle_layer( (const ROUND_SEGMENT_2D*) object2d_A,
layerTriangles, layer_z_top, layer_z_bot );
addObjectTriangles( (const ROUND_SEGMENT_2D*) object2d_A, layerTriangles,
layer_z_top, layer_z_bot );
break;
default:
@ -371,12 +369,11 @@ RENDER_3D_LEGACY::generateLayerListFromContainer( const BVH_CONTAINER_2D* aConta
if( aPolyList &&aPolyList->OutlineCount() > 0 )
{
layerTriangles->AddToMiddleContourns( *aPolyList, layer_z_bot, layer_z_top,
m_boardAdapter.BiuTo3Dunits(), false, aThroughHoles );
m_boardAdapter.BiuTo3dUnits(), false, aThroughHoles );
}
// Create display list
return new OPENGL_RENDER_LIST( *layerTriangles, m_ogl_circle_texture, layer_z_bot,
layer_z_top );
return new OPENGL_RENDER_LIST( *layerTriangles, m_circleTexture, layer_z_bot, layer_z_top );
}
@ -387,9 +384,8 @@ OPENGL_RENDER_LIST* RENDER_3D_LEGACY::createBoard( const SHAPE_POLY_SET& aBoardP
CONTAINER_2D boardContainer;
SHAPE_POLY_SET brd_outlines = aBoardPoly;
Convert_shape_line_polygon_to_triangles( brd_outlines, boardContainer,
m_boardAdapter.BiuTo3Dunits(),
(const BOARD_ITEM &)*m_boardAdapter.GetBoard() );
ConvertPolygonToTriangles( brd_outlines, boardContainer, m_boardAdapter.BiuTo3dUnits(),
(const BOARD_ITEM &)*m_boardAdapter.GetBoard() );
const LIST_OBJECT2D& listBoardObject2d = boardContainer.GetList();
@ -419,17 +415,17 @@ OPENGL_RENDER_LIST* RENDER_3D_LEGACY::createBoard( const SHAPE_POLY_SET& aBoardP
const SFVEC2F& v2 = tri->GetP2();
const SFVEC2F& v3 = tri->GetP3();
add_triangle_top_bot( layerTriangles, v1, v2, v3, layer_z_top, layer_z_bot );
addTopAndBottomTriangles( layerTriangles, v1, v2, v3, layer_z_top, layer_z_bot );
}
if( aBoardPoly.OutlineCount() > 0 )
{
layerTriangles->AddToMiddleContourns( aBoardPoly, layer_z_bot, layer_z_top,
m_boardAdapter.BiuTo3Dunits(), false,
m_boardAdapter.BiuTo3dUnits(), false,
aThroughHoles );
dispLists = new OPENGL_RENDER_LIST( *layerTriangles, m_ogl_circle_texture,
layer_z_top, layer_z_top );
dispLists = new OPENGL_RENDER_LIST( *layerTriangles, m_circleTexture,
layer_z_top, layer_z_top );
}
delete layerTriangles;
@ -443,7 +439,7 @@ void RENDER_3D_LEGACY::reload( REPORTER* aStatusReporter, REPORTER* aWarningRepo
{
m_reloadRequested = false;
ogl_free_all_display_lists();
freeAllLists();
OBJECT_2D_STATS::Instance().ResetStats();
@ -451,89 +447,73 @@ void RENDER_3D_LEGACY::reload( REPORTER* aStatusReporter, REPORTER* aWarningRepo
m_boardAdapter.InitSettings( aStatusReporter, aWarningReporter );
SFVEC3F camera_pos = m_boardAdapter.GetBoardCenter3DU();
SFVEC3F camera_pos = m_boardAdapter.GetBoardCenter();
m_camera.SetBoardLookAtPos( camera_pos );
if( aStatusReporter )
aStatusReporter->Report( _( "Load OpenGL: board" ) );
// Create Board
m_board = createBoard( m_boardAdapter.GetBoardPoly(), &m_boardAdapter.GetThroughHole_Inner() );
m_board = createBoard( m_boardAdapter.GetBoardPoly(), &m_boardAdapter.GetThroughHoleIds() );
if( m_boardAdapter.GetFlag( FL_USE_REALISTIC_MODE ) )
{
m_anti_board_poly.RemoveAllContours();
m_anti_board_poly.NewOutline();
m_anti_board_poly.Append( VECTOR2I( -INT_MAX/2, -INT_MAX/2 ) );
m_anti_board_poly.Append( VECTOR2I( INT_MAX/2, -INT_MAX/2 ) );
m_anti_board_poly.Append( VECTOR2I( INT_MAX/2, INT_MAX/2 ) );
m_anti_board_poly.Append( VECTOR2I( -INT_MAX/2, INT_MAX/2 ) );
m_anti_board_poly.Outline( 0 ).SetClosed( true );
m_antiBoardPolys.RemoveAllContours();
m_antiBoardPolys.NewOutline();
m_antiBoardPolys.Append( VECTOR2I( -INT_MAX/2, -INT_MAX/2 ) );
m_antiBoardPolys.Append( VECTOR2I( INT_MAX/2, -INT_MAX/2 ) );
m_antiBoardPolys.Append( VECTOR2I( INT_MAX/2, INT_MAX/2 ) );
m_antiBoardPolys.Append( VECTOR2I( -INT_MAX/2, INT_MAX/2 ) );
m_antiBoardPolys.Outline( 0 ).SetClosed( true );
m_anti_board_poly.BooleanSubtract( m_boardAdapter.GetBoardPoly(),
SHAPE_POLY_SET::PM_STRICTLY_SIMPLE );
m_anti_board = createBoard( m_anti_board_poly );
m_antiBoardPolys.BooleanSubtract( m_boardAdapter.GetBoardPoly(),
SHAPE_POLY_SET::PM_STRICTLY_SIMPLE );
m_antiBoard = createBoard( m_antiBoardPolys );
}
SHAPE_POLY_SET board_poly_with_holes = m_boardAdapter.GetBoardPoly();
board_poly_with_holes.BooleanSubtract( m_boardAdapter.GetThroughHole_Outer_poly(),
board_poly_with_holes.BooleanSubtract( m_boardAdapter.GetThroughHoleOdPolys(),
SHAPE_POLY_SET::PM_FAST );
board_poly_with_holes.BooleanSubtract( m_boardAdapter.GetThroughHole_Outer_poly_NPTH(),
board_poly_with_holes.BooleanSubtract( m_boardAdapter.GetOuterNonPlatedThroughHolePoly(),
SHAPE_POLY_SET::PM_FAST );
m_board_with_holes = createBoard( board_poly_with_holes );
m_boardWithHoles = createBoard( board_poly_with_holes );
if( m_anti_board )
m_anti_board->SetItIsTransparent( true );
if( m_antiBoard )
m_antiBoard->SetItIsTransparent( true );
// Create Through Holes and vias
if( aStatusReporter )
aStatusReporter->Report( _( "Load OpenGL: holes and vias" ) );
SHAPE_POLY_SET outerPolyTHT = m_boardAdapter.GetThroughHole_Outer_poly();
SHAPE_POLY_SET outerPolyTHT = m_boardAdapter.GetThroughHoleOdPolys();
if( m_boardAdapter.GetFlag( FL_USE_REALISTIC_MODE ) )
outerPolyTHT.BooleanIntersection( m_boardAdapter.GetBoardPoly(),
SHAPE_POLY_SET::PM_STRICTLY_SIMPLE );
m_through_holes_outer = generate_holes_display_list(
m_boardAdapter.GetThroughHole_Outer().GetList(),
outerPolyTHT,
1.0f,
0.0f,
false,
&m_boardAdapter.GetThroughHole_Inner() );
m_outerThroughHoles = generateHoles( m_boardAdapter.GetThroughHoleOds().GetList(),
outerPolyTHT, 1.0f, 0.0f, false,
&m_boardAdapter.GetThroughHoleIds() );
m_through_holes_vias_outer = generate_holes_display_list(
m_boardAdapter.GetThroughHole_Vias_Outer().GetList(),
m_boardAdapter.GetThroughHole_Vias_Outer_poly(),
1.0f,
0.0f,
false );
m_outerViaThroughHoles = generateHoles(
m_boardAdapter.GetThroughHoleViaOds().GetList(),
m_boardAdapter.GetThroughHoleViaOdPolys(), 1.0f, 0.0f, false );
if( m_boardAdapter.GetFlag( FL_CLIP_SILK_ON_VIA_ANNULUS ) &&
m_boardAdapter.GetFlag( FL_USE_REALISTIC_MODE ) )
{
m_through_holes_outer_ring = generate_holes_display_list(
m_boardAdapter.GetThroughHole_Outer_Ring().GetList(),
m_boardAdapter.GetThroughHole_Outer_Ring_poly(),
1.0f,
0.0f,
false );
m_outerThroughHoleRings = generateHoles(
m_boardAdapter.GetThroughHoleAnnularRings().GetList(),
m_boardAdapter.GetThroughHoleAnnularRingPolys(), 1.0f, 0.0f, false );
}
/// @todo Determine what to do with this commented out code.
//m_ogl_disp_list_through_holes_vias_inner = generate_holes_display_list(
// m_boardAdapter.GetThroughHole_Vias_Inner().GetList(),
// m_boardAdapter.GetThroughHole_Vias_Inner_poly(),
// 1.0f, 0.0f,
// false );
const MAP_POLY& innerMapHoles = m_boardAdapter.GetPolyMapHoles_Inner();
const MAP_POLY& outerMapHoles = m_boardAdapter.GetPolyMapHoles_Outer();
const MAP_POLY& innerMapHoles = m_boardAdapter.GetHoleIdPolysMap();
const MAP_POLY& outerMapHoles = m_boardAdapter.GetHoleOdPolysMap();
wxASSERT( innerMapHoles.size() == outerMapHoles.size() );
const MAP_CONTAINER_2D_BASE& map_holes = m_boardAdapter.GetMapLayersHoles();
const MAP_CONTAINER_2D_BASE& map_holes = m_boardAdapter.GetLayerHoleMap();
if( outerMapHoles.size() > 0 )
{
@ -546,11 +526,10 @@ void RENDER_3D_LEGACY::reload( REPORTER* aStatusReporter, REPORTER* aWarningRepo
const SHAPE_POLY_SET* poly = static_cast<const SHAPE_POLY_SET*>( ii->second );
const BVH_CONTAINER_2D* container = map_holes.at( layer_id );
get_layer_z_pos( layer_id, layer_z_top, layer_z_bot );
getLayerZPos( layer_id, layer_z_top, layer_z_bot );
m_layers_holes_outer[layer_id] = generate_holes_display_list( container->GetList(),
*poly, layer_z_top,
layer_z_bot, false );
m_outerLayerHoles[layer_id] = generateHoles( container->GetList(), *poly,
layer_z_top, layer_z_bot, false );
}
for( MAP_POLY::const_iterator ii = innerMapHoles.begin(); ii != innerMapHoles.end(); ++ii )
@ -559,16 +538,15 @@ void RENDER_3D_LEGACY::reload( REPORTER* aStatusReporter, REPORTER* aWarningRepo
const SHAPE_POLY_SET* poly = static_cast<const SHAPE_POLY_SET*>( ii->second );
const BVH_CONTAINER_2D* container = map_holes.at( layer_id );
get_layer_z_pos( layer_id, layer_z_top, layer_z_bot );
getLayerZPos( layer_id, layer_z_top, layer_z_bot );
m_layers_holes_inner[layer_id] = generate_holes_display_list( container->GetList(),
*poly, layer_z_top,
layer_z_bot, false );
m_innerLayerHoles[layer_id] = generateHoles( container->GetList(), *poly,
layer_z_top, layer_z_bot, false );
}
}
// Generate vertical cylinders of vias and pads (copper)
generate_3D_Vias_and_Pads();
generateViasAndPads();
// Add layers maps
if( aStatusReporter )
@ -576,13 +554,13 @@ void RENDER_3D_LEGACY::reload( REPORTER* aStatusReporter, REPORTER* aWarningRepo
const MAP_POLY& map_poly = m_boardAdapter.GetPolyMap();
for( MAP_CONTAINER_2D_BASE::const_iterator ii = m_boardAdapter.GetMapLayers().begin();
ii != m_boardAdapter.GetMapLayers().end();
for( MAP_CONTAINER_2D_BASE::const_iterator ii = m_boardAdapter.GetLayerMap().begin();
ii != m_boardAdapter.GetLayerMap().end();
++ii )
{
PCB_LAYER_ID layer_id = static_cast<PCB_LAYER_ID>( ii->first );
if( !m_boardAdapter.Is3DLayerEnabled( layer_id ) )
if( !m_boardAdapter.Is3dLayerEnabled( layer_id ) )
continue;
const BVH_CONTAINER_2D* container2d = static_cast<const BVH_CONTAINER_2D*>( ii->second );
@ -604,10 +582,10 @@ void RENDER_3D_LEGACY::reload( REPORTER* aStatusReporter, REPORTER* aWarningRepo
if( ( layer_id != B_Mask ) && ( layer_id != F_Mask ) )
{
polyListSubtracted.BooleanSubtract( m_boardAdapter.GetThroughHole_Outer_poly(),
polyListSubtracted.BooleanSubtract( m_boardAdapter.GetThroughHoleOdPolys(),
SHAPE_POLY_SET::PM_FAST );
polyListSubtracted.BooleanSubtract(
m_boardAdapter.GetThroughHole_Outer_poly_NPTH(),
m_boardAdapter.GetOuterNonPlatedThroughHolePoly(),
SHAPE_POLY_SET::PM_FAST );
}
@ -630,10 +608,8 @@ void RENDER_3D_LEGACY::reload( REPORTER* aStatusReporter, REPORTER* aWarningRepo
aPolyList = &polyListSubtracted;
}
OPENGL_RENDER_LIST* oglList = generateLayerListFromContainer(
container2d, aPolyList,
layer_id,
&m_boardAdapter.GetThroughHole_Inner() );
OPENGL_RENDER_LIST* oglList = generateLayerList( container2d, aPolyList, layer_id,
&m_boardAdapter.GetThroughHoleIds() );
if( oglList != nullptr )
m_layers[layer_id] = oglList;
@ -643,33 +619,32 @@ void RENDER_3D_LEGACY::reload( REPORTER* aStatusReporter, REPORTER* aWarningRepo
if( m_boardAdapter.GetFlag( FL_RENDER_PLATED_PADS_AS_PLATED ) &&
m_boardAdapter.GetFlag( FL_USE_REALISTIC_MODE ) )
{
if( m_boardAdapter.GetPolyPlatedPads_Front() )
if( m_boardAdapter.GetFrontPlatedPadPolys() )
{
SHAPE_POLY_SET polySubtracted = *m_boardAdapter.GetPolyPlatedPads_Front();
SHAPE_POLY_SET polySubtracted = *m_boardAdapter.GetFrontPlatedPadPolys();
polySubtracted.BooleanIntersection( m_boardAdapter.GetBoardPoly(),
SHAPE_POLY_SET::PM_FAST );
polySubtracted.BooleanSubtract( m_boardAdapter.GetThroughHole_Outer_poly(),
polySubtracted.BooleanSubtract( m_boardAdapter.GetThroughHoleOdPolys(),
SHAPE_POLY_SET::PM_FAST );
polySubtracted.BooleanSubtract( m_boardAdapter.GetThroughHole_Outer_poly_NPTH(),
polySubtracted.BooleanSubtract( m_boardAdapter.GetOuterNonPlatedThroughHolePoly(),
SHAPE_POLY_SET::PM_FAST );
m_platedPads_F_Cu = generateLayerListFromContainer(
m_boardAdapter.GetPlatedPads_Front(),
&polySubtracted, F_Cu );
m_platedPadsFront = generateLayerList( m_boardAdapter.GetPlatedPadsFront(),
&polySubtracted, F_Cu );
}
if( m_boardAdapter.GetPolyPlatedPads_Back() )
if( m_boardAdapter.GetBackPlatedPadPolys() )
{
SHAPE_POLY_SET polySubtracted = *m_boardAdapter.GetPolyPlatedPads_Back();
SHAPE_POLY_SET polySubtracted = *m_boardAdapter.GetBackPlatedPadPolys();
polySubtracted.BooleanIntersection( m_boardAdapter.GetBoardPoly(),
SHAPE_POLY_SET::PM_FAST );
polySubtracted.BooleanSubtract( m_boardAdapter.GetThroughHole_Outer_poly(),
polySubtracted.BooleanSubtract( m_boardAdapter.GetThroughHoleOdPolys(),
SHAPE_POLY_SET::PM_FAST );
polySubtracted.BooleanSubtract( m_boardAdapter.GetThroughHole_Outer_poly_NPTH(),
polySubtracted.BooleanSubtract( m_boardAdapter.GetOuterNonPlatedThroughHolePoly(),
SHAPE_POLY_SET::PM_FAST );
m_platedPads_B_Cu = generateLayerListFromContainer( m_boardAdapter.GetPlatedPads_Back(),
&polySubtracted, B_Cu );
m_platedPadsBack = generateLayerList( m_boardAdapter.GetPlatedPadsBack(),
&polySubtracted, B_Cu );
}
}
@ -677,7 +652,7 @@ void RENDER_3D_LEGACY::reload( REPORTER* aStatusReporter, REPORTER* aWarningRepo
if( aStatusReporter )
aStatusReporter->Report( _( "Loading 3D models" ) );
load_3D_models( aStatusReporter );
load3dModels( aStatusReporter );
if( aStatusReporter )
{
@ -690,9 +665,9 @@ void RENDER_3D_LEGACY::reload( REPORTER* aStatusReporter, REPORTER* aWarningRepo
}
void RENDER_3D_LEGACY::add_triangle_top_bot( TRIANGLE_DISPLAY_LIST* aDst, const SFVEC2F& v0,
const SFVEC2F& v1, const SFVEC2F& v2,
float top, float bot )
void RENDER_3D_LEGACY::addTopAndBottomTriangles( TRIANGLE_DISPLAY_LIST* aDst, const SFVEC2F& v0,
const SFVEC2F& v1, const SFVEC2F& v2,
float top, float bot )
{
aDst->m_layer_bot_triangles->AddTriangle( SFVEC3F( v0.x, v0.y, bot ),
SFVEC3F( v1.x, v1.y, bot ),
@ -704,11 +679,11 @@ void RENDER_3D_LEGACY::add_triangle_top_bot( TRIANGLE_DISPLAY_LIST* aDst, const
}
void RENDER_3D_LEGACY::get_layer_z_pos ( PCB_LAYER_ID aLayerID, float& aOutZtop,
float& aOutZbot ) const
void RENDER_3D_LEGACY::getLayerZPos( PCB_LAYER_ID aLayerID, float& aOutZtop,
float& aOutZbot ) const
{
aOutZbot = m_boardAdapter.GetLayerBottomZpos3DU( aLayerID );
aOutZtop = m_boardAdapter.GetLayerTopZpos3DU( aLayerID );
aOutZbot = m_boardAdapter.GetLayerBottomZPos( aLayerID );
aOutZtop = m_boardAdapter.GetLayerTopZPos( aLayerID );
if( aOutZtop < aOutZbot )
{
@ -719,16 +694,16 @@ void RENDER_3D_LEGACY::get_layer_z_pos ( PCB_LAYER_ID aLayerID, float& aOutZtop,
}
void RENDER_3D_LEGACY::generate_cylinder( const SFVEC2F& aCenter, float aInnerRadius,
float aOuterRadius, float aZtop, float aZbot,
unsigned int aNr_sides_per_circle,
TRIANGLE_DISPLAY_LIST* aDstLayer )
void RENDER_3D_LEGACY::generateCylinder( const SFVEC2F& aCenter, float aInnerRadius,
float aOuterRadius, float aZtop, float aZbot,
unsigned int aNr_sides_per_circle,
TRIANGLE_DISPLAY_LIST* aDstLayer )
{
std::vector< SFVEC2F > innerContour;
std::vector< SFVEC2F > outerContour;
generate_ring_contour( aCenter, aInnerRadius, aOuterRadius, aNr_sides_per_circle,
innerContour, outerContour, false );
generateRing( aCenter, aInnerRadius, aOuterRadius, aNr_sides_per_circle, innerContour,
outerContour, false );
for( unsigned int i = 0; i < ( innerContour.size() - 1 ); ++i )
{
@ -753,14 +728,14 @@ void RENDER_3D_LEGACY::generate_cylinder( const SFVEC2F& aCenter, float aInnerRa
}
void RENDER_3D_LEGACY::generate_3D_Vias_and_Pads()
void RENDER_3D_LEGACY::generateViasAndPads()
{
if( m_boardAdapter.GetStats_Nr_Vias() )
if( m_boardAdapter.GetViaCount() )
{
const unsigned int reserve_nr_triangles_estimation =
m_boardAdapter.GetNrSegmentsCircle(
m_boardAdapter.GetStats_Med_Via_Hole_Diameter3DU() ) * 8 *
m_boardAdapter.GetStats_Nr_Vias();
m_boardAdapter.GetCircleSegmentCount(
m_boardAdapter.GetAverageViaHoleDiameter() ) * 8 *
m_boardAdapter.GetViaCount();
TRIANGLE_DISPLAY_LIST* layerTriangleVIA =
new TRIANGLE_DISPLAY_LIST( reserve_nr_triangles_estimation );
@ -774,26 +749,26 @@ void RENDER_3D_LEGACY::generate_3D_Vias_and_Pads()
{
const VIA* via = static_cast<const VIA*>(track);
const float holediameter = via->GetDrillValue() * m_boardAdapter.BiuTo3Dunits();
const float thickness = m_boardAdapter.GetCopperThickness3DU();
const int nrSegments = m_boardAdapter.GetNrSegmentsCircle( via->GetDrillValue() );
const float holediameter = via->GetDrillValue() * m_boardAdapter.BiuTo3dUnits();
const float thickness = m_boardAdapter.GetCopperThickness();
const int nrSegments = m_boardAdapter.GetCircleSegmentCount( via->GetDrillValue() );
const float hole_inner_radius = holediameter / 2.0f;
const SFVEC2F via_center( via->GetStart().x * m_boardAdapter.BiuTo3Dunits(),
-via->GetStart().y * m_boardAdapter.BiuTo3Dunits() );
const SFVEC2F via_center( via->GetStart().x * m_boardAdapter.BiuTo3dUnits(),
-via->GetStart().y * m_boardAdapter.BiuTo3dUnits() );
PCB_LAYER_ID top_layer, bottom_layer;
via->LayerPair( &top_layer, &bottom_layer );
float ztop, zbot, dummy;
get_layer_z_pos( top_layer, ztop, dummy );
get_layer_z_pos( bottom_layer, dummy, zbot );
getLayerZPos( top_layer, ztop, dummy );
getLayerZPos( bottom_layer, dummy, zbot );
wxASSERT( zbot < ztop );
generate_cylinder( via_center, hole_inner_radius, hole_inner_radius + thickness,
ztop, zbot, nrSegments, layerTriangleVIA );
generateCylinder( via_center, hole_inner_radius, hole_inner_radius + thickness,
ztop, zbot, nrSegments, layerTriangleVIA );
}
}
@ -803,7 +778,7 @@ void RENDER_3D_LEGACY::generate_3D_Vias_and_Pads()
}
if( m_boardAdapter.GetStats_Nr_Holes() > 0 )
if( m_boardAdapter.GetHoleCount() > 0 )
{
SHAPE_POLY_SET tht_outer_holes_poly; // Stores the outer poly of the copper holes (the pad)
SHAPE_POLY_SET tht_inner_holes_poly; // Stores the inner poly of the copper holes (the hole)
@ -824,7 +799,7 @@ void RENDER_3D_LEGACY::generate_3D_Vias_and_Pads()
if( !hasHole )
continue;
const int copperThickness = m_boardAdapter.GetHolePlatingThicknessBIU();
const int copperThickness = m_boardAdapter.GetHolePlatingThickness();
pad->TransformHoleWithClearanceToPolygon( tht_outer_holes_poly,
copperThickness,
@ -839,13 +814,13 @@ void RENDER_3D_LEGACY::generate_3D_Vias_and_Pads()
tht_outer_holes_poly.BooleanSubtract( tht_inner_holes_poly, SHAPE_POLY_SET::PM_FAST );
if( m_boardAdapter.GetFlag( FL_USE_REALISTIC_MODE ) )
tht_outer_holes_poly.BooleanSubtract( m_anti_board_poly, SHAPE_POLY_SET::PM_FAST );
tht_outer_holes_poly.BooleanSubtract( m_antiBoardPolys, SHAPE_POLY_SET::PM_FAST );
CONTAINER_2D holesContainer;
Convert_shape_line_polygon_to_triangles( tht_outer_holes_poly, holesContainer,
m_boardAdapter.BiuTo3Dunits(),
(const BOARD_ITEM &)*m_boardAdapter.GetBoard() );
ConvertPolygonToTriangles( tht_outer_holes_poly, holesContainer,
m_boardAdapter.BiuTo3dUnits(),
(const BOARD_ITEM &)*m_boardAdapter.GetBoard() );
const LIST_OBJECT2D& listHolesObject2d = holesContainer.GetList();
@ -853,8 +828,8 @@ void RENDER_3D_LEGACY::generate_3D_Vias_and_Pads()
{
float layer_z_top, layer_z_bot, dummy;
get_layer_z_pos( F_Cu, layer_z_top, dummy );
get_layer_z_pos( B_Cu, dummy, layer_z_bot );
getLayerZPos( F_Cu, layer_z_top, dummy );
getLayerZPos( B_Cu, dummy, layer_z_bot );
TRIANGLE_DISPLAY_LIST* layerTriangles =
new TRIANGLE_DISPLAY_LIST( listHolesObject2d.size() );
@ -874,7 +849,7 @@ void RENDER_3D_LEGACY::generate_3D_Vias_and_Pads()
const SFVEC2F& v2 = tri->GetP2();
const SFVEC2F& v3 = tri->GetP3();
add_triangle_top_bot( layerTriangles, v1, v2, v3, layer_z_top, layer_z_bot );
addTopAndBottomTriangles( layerTriangles, v1, v2, v3, layer_z_top, layer_z_bot );
}
wxASSERT( tht_outer_holes_poly.OutlineCount() > 0 );
@ -883,11 +858,10 @@ void RENDER_3D_LEGACY::generate_3D_Vias_and_Pads()
{
layerTriangles->AddToMiddleContourns( tht_outer_holes_poly,
layer_z_bot, layer_z_top,
m_boardAdapter.BiuTo3Dunits(), false );
m_boardAdapter.BiuTo3dUnits(), false );
m_pad_holes = new OPENGL_RENDER_LIST( *layerTriangles,
m_ogl_circle_texture, // not need
layer_z_top, layer_z_top );
m_padHoles = new OPENGL_RENDER_LIST( *layerTriangles, m_circleTexture,
layer_z_top, layer_z_top );
}
delete layerTriangles;
@ -896,7 +870,7 @@ void RENDER_3D_LEGACY::generate_3D_Vias_and_Pads()
}
void RENDER_3D_LEGACY::load_3D_models( REPORTER* aStatusReporter )
void RENDER_3D_LEGACY::load3dModels( REPORTER* aStatusReporter )
{
if( !m_boardAdapter.GetFlag( FL_FP_ATTRIBUTES_NORMAL )
&& !m_boardAdapter.GetFlag( FL_FP_ATTRIBUTES_NORMAL_INSERT )
@ -924,20 +898,20 @@ void RENDER_3D_LEGACY::load_3D_models( REPORTER* aStatusReporter )
// Check if the model is not present in our cache map
// (Not already loaded in memory)
if( m_3dmodel_map.find( model.m_Filename ) == m_3dmodel_map.end() )
if( m_3dModelMap.find( model.m_Filename ) == m_3dModelMap.end() )
{
// It is not present, try get it from cache
const S3DMODEL* modelPtr =
m_boardAdapter.Get3DCacheManager()->GetModel( model.m_Filename );
m_boardAdapter.Get3dCacheManager()->GetModel( model.m_Filename );
// only add it if the return is not NULL
if( modelPtr )
{
MATERIAL_MODE materialMode = m_boardAdapter.MaterialModeGet();
MATERIAL_MODE materialMode = m_boardAdapter.GetMaterialMode();
MODEL_3D* ogl_model = new MODEL_3D( *modelPtr, materialMode );
if( ogl_model )
m_3dmodel_map[ model.m_Filename ] = ogl_model;
m_3dModelMap[ model.m_Filename ] = ogl_model;
}
}
}

View File

@ -28,10 +28,9 @@
#include "layer_triangles.h"
#include "../3d_render_raytracing/ray.h"
#include <wx/debug.h> // For the wxASSERT
#include <mutex>
#include <thread>
#include <atomic>
TRIANGLE_LIST::TRIANGLE_LIST( unsigned int aNrReservedTriangles, bool aReserveNormals )
@ -307,8 +306,8 @@ void TRIANGLE_DISPLAY_LIST::AddToMiddleContourns( const SHAPE_POLY_SET& aPolySet
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;
@ -613,7 +612,7 @@ GLuint OPENGL_RENDER_LIST::generate_top_or_bot_seg_ends(
{
wxASSERT( aTriangleContainer != nullptr );
wxASSERT( (aTriangleContainer->GetVertexSize() % 3) == 0 );
wxASSERT( ( aTriangleContainer->GetVertexSize() % 3 ) == 0 );
// Top and Bot dont have normals array stored in container
wxASSERT( aTriangleContainer->GetNormalsSize() == 0 );
@ -676,8 +675,8 @@ GLuint OPENGL_RENDER_LIST::generate_top_or_bot_seg_ends(
}
GLuint OPENGL_RENDER_LIST::generate_top_or_bot_triangles(
const TRIANGLE_LIST* aTriangleContainer, bool aIsNormalUp ) const
GLuint OPENGL_RENDER_LIST::generate_top_or_bot_triangles( const TRIANGLE_LIST* aTriangleContainer,
bool aIsNormalUp ) const
{
wxASSERT( aTriangleContainer != nullptr );

View File

@ -44,29 +44,29 @@ RENDER_3D_LEGACY::RENDER_3D_LEGACY( BOARD_ADAPTER& aAdapter, CAMERA& aCamera ) :
wxLogTrace( m_logTrace, wxT( "RENDER_3D_LEGACY::RENDER_3D_LEGACY" ) );
m_layers.clear();
m_layers_holes_outer.clear();
m_layers_holes_inner.clear();
m_outerLayerHoles.clear();
m_innerLayerHoles.clear();
m_triangles.clear();
m_board = nullptr;
m_anti_board = nullptr;
m_antiBoard = nullptr;
m_platedPads_F_Cu = nullptr;
m_platedPads_B_Cu = nullptr;
m_platedPadsFront = nullptr;
m_platedPadsBack = nullptr;
m_through_holes_outer = nullptr;
m_through_holes_outer_ring = nullptr;
m_through_holes_vias_outer = nullptr;
m_outerThroughHoles = nullptr;
m_outerThroughHoleRings = nullptr;
m_outerViaThroughHoles = nullptr;
m_vias = nullptr;
m_pad_holes = nullptr;
m_padHoles = nullptr;
m_vias_and_pad_holes_outer_contourn_and_caps = nullptr;
m_ogl_circle_texture = 0;
m_circleTexture = 0;
m_grid = 0;
m_last_grid_type = GRID3D_TYPE::NONE;
m_lastGridType = GRID3D_TYPE::NONE;
m_currentIntersectedBoardItem = nullptr;
m_board_with_holes = nullptr;
m_boardWithHoles = nullptr;
m_3dmodel_map.clear();
m_3dModelMap.clear();
}
@ -74,9 +74,9 @@ RENDER_3D_LEGACY::~RENDER_3D_LEGACY()
{
wxLogTrace( m_logTrace, wxT( "RENDER_3D_LEGACY::~RENDER_3D_LEGACY" ) );
ogl_free_all_display_lists();
freeAllLists();
glDeleteTextures( 1, &m_ogl_circle_texture );
glDeleteTextures( 1, &m_circleTexture );
}
@ -98,7 +98,7 @@ void RENDER_3D_LEGACY::SetCurWindowSize( const wxSize& aSize )
}
void RENDER_3D_LEGACY::setLight_Front( bool enabled )
void RENDER_3D_LEGACY::setLightFront( bool enabled )
{
if( enabled )
glEnable( GL_LIGHT0 );
@ -107,7 +107,7 @@ void RENDER_3D_LEGACY::setLight_Front( bool enabled )
}
void RENDER_3D_LEGACY::setLight_Top( bool enabled )
void RENDER_3D_LEGACY::setLightTop( bool enabled )
{
if( enabled )
glEnable( GL_LIGHT1 );
@ -116,7 +116,7 @@ void RENDER_3D_LEGACY::setLight_Top( bool enabled )
}
void RENDER_3D_LEGACY::setLight_Bottom( bool enabled )
void RENDER_3D_LEGACY::setLightBottom( bool enabled )
{
if( enabled )
glEnable( GL_LIGHT2 );
@ -125,7 +125,7 @@ void RENDER_3D_LEGACY::setLight_Bottom( bool enabled )
}
void RENDER_3D_LEGACY::render_3D_arrows()
void RENDER_3D_LEGACY::render3dArrows()
{
const float arrow_size = RANGE_SCALE_3D * 0.30f;
@ -150,7 +150,7 @@ void RENDER_3D_LEGACY::render_3D_arrows()
glLoadMatrixf( glm::value_ptr( ViewMatrix ) );
ogl_set_arrow_material();
setArrowMaterial();
glColor3f( 0.9f, 0.0f, 0.0f );
DrawRoundArrow( SFVEC3F( 0.0f, 0.0f, 0.0f ), SFVEC3F( arrow_size, 0.0f, 0.0f ), 0.275f );
@ -314,14 +314,14 @@ void RENDER_3D_LEGACY::setupMaterials()
}
void RENDER_3D_LEGACY::set_layer_material( PCB_LAYER_ID aLayerID )
void RENDER_3D_LEGACY::setLayerMaterial( PCB_LAYER_ID aLayerID )
{
switch( aLayerID )
{
case F_Mask:
case B_Mask:
{
const SFVEC4F layerColor = get_layer_color( aLayerID );
const SFVEC4F layerColor = getLayerColor( aLayerID );
m_materials.m_SolderMask.m_Diffuse = layerColor;
@ -342,17 +342,17 @@ void RENDER_3D_LEGACY::set_layer_material( PCB_LAYER_ID aLayerID )
case B_Paste:
case F_Paste:
m_materials.m_Paste.m_Diffuse = get_layer_color( aLayerID );
m_materials.m_Paste.m_Diffuse = getLayerColor( aLayerID );
OGL_SetMaterial( m_materials.m_Paste, 1.0f );
break;
case B_SilkS:
m_materials.m_SilkSBot.m_Diffuse = get_layer_color( aLayerID );
m_materials.m_SilkSBot.m_Diffuse = getLayerColor( aLayerID );
OGL_SetMaterial( m_materials.m_SilkSBot, 1.0f );
break;
case F_SilkS:
m_materials.m_SilkSTop.m_Diffuse = get_layer_color( aLayerID );
m_materials.m_SilkSTop.m_Diffuse = getLayerColor( aLayerID );
OGL_SetMaterial( m_materials.m_SilkSTop, 1.0f );
break;
@ -368,7 +368,7 @@ void RENDER_3D_LEGACY::set_layer_material( PCB_LAYER_ID aLayerID )
case F_CrtYd:
case B_Fab:
case F_Fab:
m_materials.m_Plastic.m_Diffuse = get_layer_color( aLayerID );
m_materials.m_Plastic.m_Diffuse = getLayerColor( aLayerID );
m_materials.m_Plastic.m_Ambient = SFVEC3F( m_materials.m_Plastic.m_Diffuse.r * 0.05f,
m_materials.m_Plastic.m_Diffuse.g * 0.05f,
@ -384,14 +384,14 @@ void RENDER_3D_LEGACY::set_layer_material( PCB_LAYER_ID aLayerID )
break;
default:
m_materials.m_Copper.m_Diffuse = get_layer_color( aLayerID );
m_materials.m_Copper.m_Diffuse = getLayerColor( aLayerID );
OGL_SetMaterial( m_materials.m_Copper, 1.0f );
break;
}
}
SFVEC4F RENDER_3D_LEGACY::get_layer_color( PCB_LAYER_ID aLayerID )
SFVEC4F RENDER_3D_LEGACY::getLayerColor( PCB_LAYER_ID aLayerID )
{
SFVEC4F layerColor = m_boardAdapter.GetLayerColor( aLayerID );
@ -505,7 +505,7 @@ void RENDER_3D_LEGACY::setPlatedCopperAndDepthOffset( PCB_LAYER_ID aLayer_id )
{
glEnable( GL_POLYGON_OFFSET_FILL );
glPolygonOffset(-0.1f, -2.0f );
set_layer_material( aLayer_id );
setLayerMaterial( aLayer_id );
}
@ -515,7 +515,7 @@ void RENDER_3D_LEGACY::unsetDepthOffset()
}
void RENDER_3D_LEGACY::render_board_body( bool aSkipRenderHoles )
void RENDER_3D_LEGACY::renderBoardBody( bool aSkipRenderHoles )
{
m_materials.m_EpoxyBoard.m_Diffuse = m_boardAdapter.m_BoardBodyColor;
@ -529,12 +529,12 @@ void RENDER_3D_LEGACY::render_board_body( bool aSkipRenderHoles )
if( aSkipRenderHoles )
ogl_disp_list = m_board;
else
ogl_disp_list = m_board_with_holes;
ogl_disp_list = m_boardWithHoles;
if( ogl_disp_list )
{
ogl_disp_list->ApplyScalePosition( -m_boardAdapter.GetEpoxyThickness3DU() / 2.0f,
m_boardAdapter.GetEpoxyThickness3DU() );
ogl_disp_list->ApplyScalePosition( -m_boardAdapter.GetEpoxyThickness() / 2.0f,
m_boardAdapter.GetEpoxyThickness() );
ogl_disp_list->SetItIsTransparent( true );
@ -563,17 +563,17 @@ bool RENDER_3D_LEGACY::Redraw( bool aIsMoving, REPORTER* aStatusReporter,
reload( aStatusReporter, aWarningReporter );
// generate a new 3D grid as the size of the board may had changed
m_last_grid_type = m_boardAdapter.GridGet();
generate_new_3DGrid( m_last_grid_type );
m_lastGridType = m_boardAdapter.GetGridType();
generate3dGrid( m_lastGridType );
}
else
{
// Check if grid was changed
if( m_boardAdapter.GridGet() != m_last_grid_type )
if( m_boardAdapter.GetGridType() != m_lastGridType )
{
// and generate a new one
m_last_grid_type = m_boardAdapter.GridGet();
generate_new_3DGrid( m_last_grid_type );
m_lastGridType = m_boardAdapter.GetGridType();
generate3dGrid( m_lastGridType );
}
}
@ -613,9 +613,9 @@ bool RENDER_3D_LEGACY::Redraw( bool aIsMoving, REPORTER* aStatusReporter,
glLoadMatrixf( glm::value_ptr( m_camera.GetViewMatrix() ) );
// Position the headlight
setLight_Front( true );
setLight_Top( true );
setLight_Bottom( true );
setLightFront( true );
setLightTop( true );
setLightBottom( true );
glEnable( GL_LIGHTING );
@ -653,7 +653,7 @@ bool RENDER_3D_LEGACY::Redraw( bool aIsMoving, REPORTER* aStatusReporter,
if( m_boardAdapter.GetFlag( FL_USE_REALISTIC_MODE ) )
{
// Draw vias and pad holes with copper material
set_layer_material( B_Cu );
setLayerMaterial( B_Cu );
}
else
{
@ -663,8 +663,8 @@ bool RENDER_3D_LEGACY::Redraw( bool aIsMoving, REPORTER* aStatusReporter,
if( !( skipRenderVias || skipRenderHoles ) && m_vias )
m_vias->DrawAll();
if( !skipRenderHoles && m_pad_holes )
m_pad_holes->DrawAll();
if( !skipRenderHoles && m_padHoles )
m_padHoles->DrawAll();
// Display copper and tech layers
for( MAP_OGL_DISP_LISTS::const_iterator ii = m_layers.begin(); ii != m_layers.end(); ++ii )
@ -692,7 +692,7 @@ bool RENDER_3D_LEGACY::Redraw( bool aIsMoving, REPORTER* aStatusReporter,
if( !m_boardAdapter.GetFlag( FL_USE_REALISTIC_MODE ) ||
!( m_boardAdapter.GetFlag( FL_RENDER_PLATED_PADS_AS_PLATED ) &&
m_boardAdapter.GetFlag( FL_USE_REALISTIC_MODE ) ) )
set_layer_material( layer_id );
setLayerMaterial( layer_id );
else
setCopperMaterial();
@ -702,75 +702,74 @@ bool RENDER_3D_LEGACY::Redraw( bool aIsMoving, REPORTER* aStatusReporter,
// Draw copper plated pads
if( ( ( layer_id == F_Cu ) || ( layer_id == B_Cu ) ) &&
( m_platedPads_F_Cu || m_platedPads_B_Cu ) )
( m_platedPadsFront || m_platedPadsBack ) )
setPlatedCopperAndDepthOffset( layer_id );
if( layer_id == F_Cu && m_platedPads_F_Cu )
if( layer_id == F_Cu && m_platedPadsFront )
{
m_platedPads_F_Cu->DrawAllCameraCulled( m_camera.GetPos().z,
m_platedPadsFront->DrawAllCameraCulled( m_camera.GetPos().z,
drawMiddleSegments );
}
else if( layer_id == B_Cu && m_platedPads_B_Cu )
else if( layer_id == B_Cu && m_platedPadsBack )
{
m_platedPads_B_Cu->DrawAllCameraCulled( m_camera.GetPos().z,
drawMiddleSegments );
m_platedPadsBack->DrawAllCameraCulled( m_camera.GetPos().z,
drawMiddleSegments );
}
unsetDepthOffset();
}
else
{
if( m_through_holes_outer )
if( m_outerThroughHoles )
{
m_through_holes_outer->ApplyScalePosition( pLayerDispList->GetZBot(),
pLayerDispList->GetZTop()
- pLayerDispList->GetZBot() );
m_outerThroughHoles->ApplyScalePosition( pLayerDispList->GetZBot(),
pLayerDispList->GetZTop()
- pLayerDispList->GetZBot() );
}
if( m_anti_board )
if( m_antiBoard )
{
m_anti_board->ApplyScalePosition( pLayerDispList->GetZBot(),
pLayerDispList->GetZTop()
- pLayerDispList->GetZBot() );
m_antiBoard->ApplyScalePosition( pLayerDispList->GetZBot(),
pLayerDispList->GetZTop()
- pLayerDispList->GetZBot() );
}
if( m_layers_holes_outer.find( layer_id ) != m_layers_holes_outer.end() )
if( m_outerLayerHoles.find( layer_id ) != m_outerLayerHoles.end() )
{
const OPENGL_RENDER_LIST* viasHolesLayer =
m_layers_holes_outer.at( layer_id );
const OPENGL_RENDER_LIST* viasHolesLayer = m_outerLayerHoles.at( layer_id );
wxASSERT( viasHolesLayer != nullptr );
if( viasHolesLayer != nullptr )
{
pLayerDispList->DrawAllCameraCulledSubtractLayer( drawMiddleSegments,
m_through_holes_outer,
m_outerThroughHoles,
viasHolesLayer,
m_anti_board );
m_antiBoard );
// Draw copper plated pads
if( ( ( layer_id == F_Cu ) || ( layer_id == B_Cu ) ) &&
( m_platedPads_F_Cu || m_platedPads_B_Cu ) )
( m_platedPadsFront || m_platedPadsBack ) )
{
setPlatedCopperAndDepthOffset( layer_id );
}
if( layer_id == F_Cu && m_platedPads_F_Cu )
if( layer_id == F_Cu && m_platedPadsFront )
{
m_platedPads_F_Cu->DrawAllCameraCulledSubtractLayer(
m_platedPadsFront->DrawAllCameraCulledSubtractLayer(
drawMiddleSegments,
m_through_holes_outer,
m_outerThroughHoles,
viasHolesLayer,
m_anti_board );
m_antiBoard );
}
else if( layer_id == B_Cu && m_platedPads_B_Cu )
else if( layer_id == B_Cu && m_platedPadsBack )
{
m_platedPads_B_Cu->DrawAllCameraCulledSubtractLayer(
m_platedPadsBack->DrawAllCameraCulledSubtractLayer(
drawMiddleSegments,
m_through_holes_outer,
m_outerThroughHoles,
viasHolesLayer,
m_anti_board );
m_antiBoard );
}
unsetDepthOffset();
@ -779,27 +778,27 @@ bool RENDER_3D_LEGACY::Redraw( bool aIsMoving, REPORTER* aStatusReporter,
else
{
pLayerDispList->DrawAllCameraCulledSubtractLayer( drawMiddleSegments,
m_through_holes_outer,
m_anti_board );
m_outerThroughHoles,
m_antiBoard );
// Draw copper plated pads
if( ( ( layer_id == F_Cu ) || ( layer_id == B_Cu ) ) &&
( m_platedPads_F_Cu || m_platedPads_B_Cu ) )
( m_platedPadsFront || m_platedPadsBack ) )
{
setPlatedCopperAndDepthOffset( layer_id );
}
if( layer_id == F_Cu && m_platedPads_F_Cu )
if( layer_id == F_Cu && m_platedPadsFront )
{
m_platedPads_F_Cu->DrawAllCameraCulledSubtractLayer( drawMiddleSegments,
m_through_holes_outer,
m_anti_board );
m_platedPadsFront->DrawAllCameraCulledSubtractLayer( drawMiddleSegments,
m_outerThroughHoles,
m_antiBoard );
}
else if( layer_id == B_Cu && m_platedPads_B_Cu )
else if( layer_id == B_Cu && m_platedPadsBack )
{
m_platedPads_B_Cu->DrawAllCameraCulledSubtractLayer( drawMiddleSegments,
m_through_holes_outer,
m_anti_board );
m_platedPadsBack->DrawAllCameraCulledSubtractLayer( drawMiddleSegments,
m_outerThroughHoles,
m_antiBoard );
}
unsetDepthOffset();
@ -808,14 +807,14 @@ bool RENDER_3D_LEGACY::Redraw( bool aIsMoving, REPORTER* aStatusReporter,
}
else
{
set_layer_material( layer_id );
setLayerMaterial( layer_id );
OPENGL_RENDER_LIST* throughHolesOuter =
m_boardAdapter.GetFlag( FL_CLIP_SILK_ON_VIA_ANNULUS )
&& m_boardAdapter.GetFlag( FL_USE_REALISTIC_MODE )
&& ( layer_id == B_SilkS || layer_id == F_SilkS )
? m_through_holes_outer_ring
: m_through_holes_outer;
? m_outerThroughHoleRings
: m_outerThroughHoles;
if( throughHolesOuter )
{
@ -824,7 +823,7 @@ bool RENDER_3D_LEGACY::Redraw( bool aIsMoving, REPORTER* aStatusReporter,
pLayerDispList->GetZTop() - pLayerDispList->GetZBot() );
}
OPENGL_RENDER_LIST* anti_board = m_anti_board;
OPENGL_RENDER_LIST* anti_board = m_antiBoard;
if( ( layer_id == B_Paste ) || ( layer_id == F_Paste ) )
anti_board = nullptr;
@ -877,21 +876,18 @@ bool RENDER_3D_LEGACY::Redraw( bool aIsMoving, REPORTER* aStatusReporter,
}
// Render 3D Models (Non-transparent)
render_3D_models( false, false );
render_3D_models( true, false );
render3dModels( false, false );
render3dModels( true, false );
// Display board body
if( m_boardAdapter.GetFlag( FL_SHOW_BOARD_BODY ) )
{
render_board_body( skipRenderHoles );
renderBoardBody( skipRenderHoles );
}
// Display transparent mask layers
if( m_boardAdapter.GetFlag( FL_SOLDERMASK ) )
{
//setLight_Top( true );
//setLight_Bottom( true );
// add a depth buffer offset, it will help to hide some artifacts
// on silkscreen where the SolderMask is removed
glEnable( GL_POLYGON_OFFSET_FILL );
@ -899,26 +895,25 @@ bool RENDER_3D_LEGACY::Redraw( bool aIsMoving, REPORTER* aStatusReporter,
if( m_camera.GetPos().z > 0 )
{
render_solder_mask_layer( B_Mask, m_boardAdapter.GetLayerTopZpos3DU( B_Mask ),
drawMiddleSegments, skipRenderHoles );
renderSolderMaskLayer( B_Mask, m_boardAdapter.GetLayerTopZPos( B_Mask ),
drawMiddleSegments, skipRenderHoles );
render_solder_mask_layer( F_Mask, m_boardAdapter.GetLayerBottomZpos3DU( F_Mask ),
drawMiddleSegments, skipRenderHoles );
renderSolderMaskLayer( F_Mask, m_boardAdapter.GetLayerBottomZPos( F_Mask ),
drawMiddleSegments, skipRenderHoles );
}
else
{
render_solder_mask_layer( F_Mask, m_boardAdapter.GetLayerBottomZpos3DU( F_Mask ),
drawMiddleSegments, skipRenderHoles );
renderSolderMaskLayer( F_Mask, m_boardAdapter.GetLayerBottomZPos( F_Mask ),
drawMiddleSegments, skipRenderHoles );
render_solder_mask_layer( B_Mask, m_boardAdapter.GetLayerTopZpos3DU( B_Mask ),
drawMiddleSegments, skipRenderHoles );
renderSolderMaskLayer( B_Mask, m_boardAdapter.GetLayerTopZPos( B_Mask ),
drawMiddleSegments, skipRenderHoles );
}
glDisable( GL_POLYGON_OFFSET_FILL );
glPolygonOffset( 0.0f, 0.0f );
}
// Render 3D Models (Transparent)
// !TODO: this can be optimized. If there are no transparent models (or no opacity),
// then there is no need to make this function call.
@ -945,8 +940,8 @@ bool RENDER_3D_LEGACY::Redraw( bool aIsMoving, REPORTER* aStatusReporter,
glTexEnvi( GL_TEXTURE_ENV, GL_SRC1_ALPHA, GL_CONSTANT );
glTexEnvi( GL_TEXTURE_ENV, GL_OPERAND1_ALPHA, GL_CONSTANT );
render_3D_models( false, true );
render_3D_models( true, true );
render3dModels( false, true );
render3dModels( true, true );
glDisable( GL_BLEND );
OGL_ResetTextureStateDefaults();
@ -954,7 +949,7 @@ bool RENDER_3D_LEGACY::Redraw( bool aIsMoving, REPORTER* aStatusReporter,
glDepthMask( GL_TRUE );
// Render Grid
if( m_boardAdapter.GridGet() != GRID3D_TYPE::NONE )
if( m_boardAdapter.GetGridType() != GRID3D_TYPE::NONE )
{
glDisable( GL_LIGHTING );
@ -966,7 +961,7 @@ bool RENDER_3D_LEGACY::Redraw( bool aIsMoving, REPORTER* aStatusReporter,
// Render 3D arrows
if( m_boardAdapter.GetFlag( FL_AXIS ) )
render_3D_arrows();
render3dArrows();
// Return back to the original viewport (this is important if we want
// to take a screenshot after the render)
@ -999,7 +994,7 @@ bool RENDER_3D_LEGACY::initializeOpenGL()
circleImage->EfxFilter( circleImage_Copy, IMAGE_FILTER::BLUR_3X3 );
m_ogl_circle_texture = OGL_LoadTexture( *circleImage );
m_circleTexture = OGL_LoadTexture( *circleImage );
//circleImage_Copy->SaveAsPNG("circleImage.png");
delete circleImage_Copy;
@ -1019,7 +1014,7 @@ bool RENDER_3D_LEGACY::initializeOpenGL()
}
void RENDER_3D_LEGACY::ogl_set_arrow_material()
void RENDER_3D_LEGACY::setArrowMaterial()
{
glEnable( GL_COLOR_MATERIAL );
glColorMaterial( GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE );
@ -1038,7 +1033,7 @@ void RENDER_3D_LEGACY::ogl_set_arrow_material()
}
void RENDER_3D_LEGACY::ogl_free_all_display_lists()
void RENDER_3D_LEGACY::freeAllLists()
{
if( glIsList( m_grid ) )
glDeleteLists( m_grid, 1 );
@ -1053,31 +1048,31 @@ void RENDER_3D_LEGACY::ogl_free_all_display_lists()
m_layers.clear();
delete m_platedPads_F_Cu;
m_platedPads_F_Cu = nullptr;
delete m_platedPadsFront;
m_platedPadsFront = nullptr;
delete m_platedPads_B_Cu;
m_platedPads_B_Cu = nullptr;
delete m_platedPadsBack;
m_platedPadsBack = nullptr;
for( MAP_OGL_DISP_LISTS::const_iterator ii = m_layers_holes_outer.begin();
ii != m_layers_holes_outer.end();
for( MAP_OGL_DISP_LISTS::const_iterator ii = m_outerLayerHoles.begin();
ii != m_outerLayerHoles.end();
++ii )
{
OPENGL_RENDER_LIST* pLayerDispList = static_cast<OPENGL_RENDER_LIST*>( ii->second );
delete pLayerDispList;
}
m_layers_holes_outer.clear();
m_outerLayerHoles.clear();
for( MAP_OGL_DISP_LISTS::const_iterator ii = m_layers_holes_inner.begin();
ii != m_layers_holes_inner.end();
for( MAP_OGL_DISP_LISTS::const_iterator ii = m_innerLayerHoles.begin();
ii != m_innerLayerHoles.end();
++ii )
{
OPENGL_RENDER_LIST* pLayerDispList = static_cast<OPENGL_RENDER_LIST*>( ii->second );
delete pLayerDispList;
}
m_layers_holes_inner.clear();
m_innerLayerHoles.clear();
for( LIST_TRIANGLES::const_iterator ii = m_triangles.begin(); ii != m_triangles.end(); ++ii )
{
@ -1086,49 +1081,49 @@ void RENDER_3D_LEGACY::ogl_free_all_display_lists()
m_triangles.clear();
for( MAP_3DMODEL::const_iterator ii = m_3dmodel_map.begin(); ii != m_3dmodel_map.end(); ++ii )
for( MAP_3DMODEL::const_iterator ii = m_3dModelMap.begin(); ii != m_3dModelMap.end(); ++ii )
{
MODEL_3D* pointer = static_cast<MODEL_3D*>(ii->second);
delete pointer;
}
m_3dmodel_map.clear();
m_3dModelMap.clear();
delete m_board;
m_board = nullptr;
delete m_board_with_holes;
m_board_with_holes = nullptr;
delete m_boardWithHoles;
m_boardWithHoles = nullptr;
delete m_anti_board;
m_anti_board = nullptr;
delete m_antiBoard;
m_antiBoard = nullptr;
delete m_through_holes_outer;
m_through_holes_outer = nullptr;
delete m_outerThroughHoles;
m_outerThroughHoles = nullptr;
delete m_through_holes_vias_outer;
m_through_holes_vias_outer = nullptr;
delete m_outerViaThroughHoles;
m_outerViaThroughHoles = nullptr;
delete m_through_holes_outer_ring;
m_through_holes_outer_ring = nullptr;
delete m_outerThroughHoleRings;
m_outerThroughHoleRings = nullptr;
delete m_vias;
m_vias = nullptr;
delete m_pad_holes;
m_pad_holes = nullptr;
delete m_padHoles;
m_padHoles = nullptr;
delete m_vias_and_pad_holes_outer_contourn_and_caps;
m_vias_and_pad_holes_outer_contourn_and_caps = nullptr;
}
void RENDER_3D_LEGACY::render_solder_mask_layer( PCB_LAYER_ID aLayerID, float aZPosition,
bool aDrawMiddleSegments, bool aSkipRenderHoles )
void RENDER_3D_LEGACY::renderSolderMaskLayer( PCB_LAYER_ID aLayerID, float aZPosition,
bool aDrawMiddleSegments, bool aSkipRenderHoles )
{
wxASSERT( (aLayerID == B_Mask) || (aLayerID == F_Mask) );
float nonCopperThickness = m_boardAdapter.GetNonCopperLayerThickness3DU();
float nonCopperThickness = m_boardAdapter.GetNonCopperLayerThickness();
if( m_board )
{
@ -1136,12 +1131,12 @@ void RENDER_3D_LEGACY::render_solder_mask_layer( PCB_LAYER_ID aLayerID, float aZ
{
OPENGL_RENDER_LIST* pLayerDispListMask = m_layers.at( aLayerID );
if( m_through_holes_vias_outer )
m_through_holes_vias_outer->ApplyScalePosition( aZPosition, nonCopperThickness );
if( m_outerViaThroughHoles )
m_outerViaThroughHoles->ApplyScalePosition( aZPosition, nonCopperThickness );
m_board->ApplyScalePosition( aZPosition, nonCopperThickness );
set_layer_material( aLayerID );
setLayerMaterial( aLayerID );
m_board->SetItIsTransparent( true );
@ -1152,19 +1147,19 @@ void RENDER_3D_LEGACY::render_solder_mask_layer( PCB_LAYER_ID aLayerID, float aZ
else
{
m_board->DrawAllCameraCulledSubtractLayer( aDrawMiddleSegments, pLayerDispListMask,
m_through_holes_vias_outer );
m_outerViaThroughHoles );
}
}
else
{
// This case there is no layer with mask, so we will render the full board as mask
if( m_through_holes_vias_outer )
m_through_holes_vias_outer->ApplyScalePosition( aZPosition, nonCopperThickness );
if( m_outerViaThroughHoles )
m_outerViaThroughHoles->ApplyScalePosition( aZPosition, nonCopperThickness );
m_board->ApplyScalePosition( aZPosition, nonCopperThickness );
set_layer_material( aLayerID );
setLayerMaterial( aLayerID );
m_board->SetItIsTransparent( true );
@ -1175,15 +1170,15 @@ void RENDER_3D_LEGACY::render_solder_mask_layer( PCB_LAYER_ID aLayerID, float aZ
else
{
m_board->DrawAllCameraCulledSubtractLayer( aDrawMiddleSegments,
m_through_holes_vias_outer );
m_outerViaThroughHoles );
}
}
}
}
void RENDER_3D_LEGACY::render_3D_models_selected( bool aRenderTopOrBot, bool aRenderTransparentOnly,
bool aRenderSelectedOnly )
void RENDER_3D_LEGACY::render3dModelsSelected( bool aRenderTopOrBot, bool aRenderTransparentOnly,
bool aRenderSelectedOnly )
{
MODEL_3D::BeginDrawMulti( !aRenderSelectedOnly );
@ -1210,12 +1205,12 @@ void RENDER_3D_LEGACY::render_3D_models_selected( bool aRenderTopOrBot, bool aRe
if( !fp->Models().empty() )
{
if( m_boardAdapter.ShouldFPBeDisplayed( (FOOTPRINT_ATTR_T) fp->GetAttributes() ) )
if( m_boardAdapter.IsFootprintShown( (FOOTPRINT_ATTR_T) fp->GetAttributes() ) )
{
if( ( aRenderTopOrBot && !fp->IsFlipped() )
|| ( !aRenderTopOrBot && fp->IsFlipped() ) )
{
render_3D_footprint( fp, aRenderTransparentOnly, isIntersected );
renderFootprint( fp, aRenderTransparentOnly, isIntersected );
}
}
}
@ -1232,28 +1227,27 @@ void RENDER_3D_LEGACY::render_3D_models_selected( bool aRenderTopOrBot, bool aRe
}
void RENDER_3D_LEGACY::render_3D_models( bool aRenderTopOrBot, bool aRenderTransparentOnly )
void RENDER_3D_LEGACY::render3dModels( bool aRenderTopOrBot, bool aRenderTransparentOnly )
{
if( m_boardAdapter.GetFlag( FL_USE_SELECTION ) )
render_3D_models_selected( aRenderTopOrBot, aRenderTransparentOnly, true );
render3dModelsSelected( aRenderTopOrBot, aRenderTransparentOnly, true );
render_3D_models_selected( aRenderTopOrBot, aRenderTransparentOnly, false );
render3dModelsSelected( aRenderTopOrBot, aRenderTransparentOnly, false );
}
void RENDER_3D_LEGACY::render_3D_footprint( const FOOTPRINT* aFootprint,
bool aRenderTransparentOnly, bool aIsSelected )
void RENDER_3D_LEGACY::renderFootprint( const FOOTPRINT* aFootprint, bool aRenderTransparentOnly,
bool aIsSelected )
{
if( !aFootprint->Models().empty() )
{
const double zpos = m_boardAdapter.GetModulesZcoord3DIU( aFootprint->IsFlipped() );
const double zpos = m_boardAdapter.GetFootprintZPos( aFootprint->IsFlipped() );
glPushMatrix();
wxPoint pos = aFootprint->GetPosition();
glTranslatef( pos.x * m_boardAdapter.BiuTo3Dunits(),
-pos.y * m_boardAdapter.BiuTo3Dunits(),
glTranslatef( pos.x * m_boardAdapter.BiuTo3dUnits(), -pos.y * m_boardAdapter.BiuTo3dUnits(),
zpos );
if( aFootprint->GetOrientation() )
@ -1265,7 +1259,7 @@ void RENDER_3D_LEGACY::render_3D_footprint( const FOOTPRINT* aFootprint,
glRotatef( 180.0f, 0.0f, 0.0f, 1.0f );
}
double modelunit_to_3d_units_factor = m_boardAdapter.BiuTo3Dunits() * UNITS3D_TO_UNITSPCB;
double modelunit_to_3d_units_factor = m_boardAdapter.BiuTo3dUnits() * UNITS3D_TO_UNITSPCB;
glScaled( modelunit_to_3d_units_factor, modelunit_to_3d_units_factor,
modelunit_to_3d_units_factor );
@ -1277,17 +1271,17 @@ void RENDER_3D_LEGACY::render_3D_footprint( const FOOTPRINT* aFootprint,
continue;
// Check if the model is present in our cache map
auto cache_i = m_3dmodel_map.find( sM.m_Filename );
auto cache_i = m_3dModelMap.find( sM.m_Filename );
if( cache_i == m_3dmodel_map.end() )
if( cache_i == m_3dModelMap.end() )
continue;
if( const MODEL_3D* modelPtr = cache_i->second )
{
bool opaque = sM.m_Opacity >= 1.0;
if( ( !aRenderTransparentOnly && modelPtr->Have_opaque() && opaque ) ||
( aRenderTransparentOnly && ( modelPtr->Have_transparent() || !opaque ) ) )
if( ( !aRenderTransparentOnly && modelPtr->HasOpaqueMeshes() && opaque ) ||
( aRenderTransparentOnly && ( modelPtr->HasTransparentMeshes() || !opaque ) ) )
{
glPushMatrix();
@ -1306,14 +1300,14 @@ void RENDER_3D_LEGACY::render_3D_footprint( const FOOTPRINT* aFootprint,
if( aRenderTransparentOnly )
{
modelPtr->Draw_transparent( sM.m_Opacity,
aFootprint->IsSelected() || aIsSelected,
m_boardAdapter.m_opengl_selectionColor );
modelPtr->DrawTransparent( sM.m_Opacity,
aFootprint->IsSelected() || aIsSelected,
m_boardAdapter.m_opengl_selectionColor );
}
else
{
modelPtr->Draw_opaque( aFootprint->IsSelected() || aIsSelected,
m_boardAdapter.m_opengl_selectionColor );
modelPtr->DrawOpaque( aFootprint->IsSelected() || aIsSelected,
m_boardAdapter.m_opengl_selectionColor );
}
if( m_boardAdapter.GetFlag( FL_RENDER_OPENGL_SHOW_MODEL_BBOX ) )
@ -1324,10 +1318,10 @@ void RENDER_3D_LEGACY::render_3D_footprint( const FOOTPRINT* aFootprint,
glDisable( GL_LIGHTING );
glLineWidth( 1 );
modelPtr->Draw_bboxes();
modelPtr->DrawBboxes();
glLineWidth( 4 );
modelPtr->Draw_bbox();
modelPtr->DrawBbox();
glEnable( GL_LIGHTING );
glDisable( GL_BLEND );
@ -1343,7 +1337,7 @@ void RENDER_3D_LEGACY::render_3D_footprint( const FOOTPRINT* aFootprint,
}
void RENDER_3D_LEGACY::generate_new_3DGrid( GRID3D_TYPE aGridType )
void RENDER_3D_LEGACY::generate3dGrid( GRID3D_TYPE aGridType )
{
if( glIsList( m_grid ) )
glDeleteLists( m_grid, 1 );
@ -1370,7 +1364,7 @@ void RENDER_3D_LEGACY::generate_new_3DGrid( GRID3D_TYPE aGridType )
// Color of grid lines every 5 lines
const SFVEC3F gridColor_marker = m_boardAdapter.GetColor( LIGHTGRAY );
const double scale = m_boardAdapter.BiuTo3Dunits();
const double scale = m_boardAdapter.BiuTo3dUnits();
const GLfloat transparency = 0.35f;
double griSizeMM = 0.0;
@ -1396,8 +1390,8 @@ void RENDER_3D_LEGACY::generate_new_3DGrid( GRID3D_TYPE aGridType )
glNormal3f( 0.0, 0.0, 1.0 );
const wxSize brd_size = m_boardAdapter.GetBoardSizeBIU();
wxPoint brd_center_pos = m_boardAdapter.GetBoardPosBIU();
const wxSize brd_size = m_boardAdapter.GetBoardSize();
wxPoint brd_center_pos = m_boardAdapter.GetBoardPos();
brd_center_pos.y = -brd_center_pos.y;
@ -1498,7 +1492,7 @@ void RENDER_3D_LEGACY::generate_new_3DGrid( GRID3D_TYPE aGridType )
// Draw horizontal grid lines on Z axis (parallel to X axis)
for( int ii = 0; ; ii++ )
{
if( (ii % 5) )
if( ii % 5 )
glColor4f( gridColor.r, gridColor.g, gridColor.b, transparency );
else
glColor4f( gridColor_marker.r, gridColor_marker.g, gridColor_marker.b,

View File

@ -73,54 +73,51 @@ public:
}
private:
OPENGL_RENDER_LIST* generate_holes_display_list( const LIST_OBJECT2D& aListHolesObject2d,
const SHAPE_POLY_SET& aPoly,
float aZtop,
float aZbot,
bool aInvertFaces,
const BVH_CONTAINER_2D* aThroughHoles = nullptr );
OPENGL_RENDER_LIST* generateHoles( const LIST_OBJECT2D& aListHolesObject2d,
const SHAPE_POLY_SET& aPoly, float aZtop,
float aZbot, bool aInvertFaces,
const BVH_CONTAINER_2D* aThroughHoles = nullptr );
OPENGL_RENDER_LIST* generateLayerListFromContainer( const BVH_CONTAINER_2D* aContainer,
const SHAPE_POLY_SET* aPolyList,
PCB_LAYER_ID aLayerId,
const BVH_CONTAINER_2D* aThroughHoles = nullptr );
OPENGL_RENDER_LIST* generateLayerList( const BVH_CONTAINER_2D* aContainer,
const SHAPE_POLY_SET* aPolyList,
PCB_LAYER_ID aLayerId,
const BVH_CONTAINER_2D* aThroughHoles = nullptr );
void add_triangle_top_bot( TRIANGLE_DISPLAY_LIST* aDst, const SFVEC2F& v0, const SFVEC2F& v1,
const SFVEC2F& v2, float top, float bot );
void addTopAndBottomTriangles( TRIANGLE_DISPLAY_LIST* aDst, const SFVEC2F& v0,
const SFVEC2F& v1, const SFVEC2F& v2, float top, float bot );
void add_object_to_triangle_layer( const RING_2D* aRing, TRIANGLE_DISPLAY_LIST* aDstLayer,
float aZtop, float aZbot );
void addObjectTriangles( const RING_2D* aRing, TRIANGLE_DISPLAY_LIST* aDstLayer,
float aZtop, float aZbot );
void add_object_to_triangle_layer( const POLYGON_4PT_2D* aPoly,
TRIANGLE_DISPLAY_LIST* aDstLayer, float aZtop, float aZbot );
void addObjectTriangles( const POLYGON_4PT_2D* aPoly, TRIANGLE_DISPLAY_LIST* aDstLayer,
float aZtop, float aZbot );
void add_object_to_triangle_layer( const FILLED_CIRCLE_2D* aFilledCircle,
TRIANGLE_DISPLAY_LIST* aDstLayer, float aZtop, float aZbot );
void addObjectTriangles( const FILLED_CIRCLE_2D* aFilledCircle,
TRIANGLE_DISPLAY_LIST* aDstLayer, float aZtop, float aZbot );
void add_object_to_triangle_layer( const TRIANGLE_2D* aTri, TRIANGLE_DISPLAY_LIST* aDstLayer,
float aZtop, float aZbot );
void addObjectTriangles( const TRIANGLE_2D* aTri, TRIANGLE_DISPLAY_LIST* aDstLayer,
float aZtop, float aZbot );
void add_object_to_triangle_layer( const ROUND_SEGMENT_2D* aSeg,
TRIANGLE_DISPLAY_LIST* aDstLayer, float aZtop, float aZbot );
void addObjectTriangles( const ROUND_SEGMENT_2D* aSeg,
TRIANGLE_DISPLAY_LIST* aDstLayer, float aZtop, float aZbot );
void render_solder_mask_layer( PCB_LAYER_ID aLayerID, float aZPosition,
bool aDrawMiddleSegments, bool aSkipRenderHoles );
void renderSolderMaskLayer( PCB_LAYER_ID aLayerID, float aZPosition,
bool aDrawMiddleSegments, bool aSkipRenderHoles );
void render_board_body( bool aSkipRenderHoles );
void renderBoardBody( bool aSkipRenderHoles );
void get_layer_z_pos( PCB_LAYER_ID aLayerID, float& aOutZtop, float& aOutZbot ) const;
void getLayerZPos( PCB_LAYER_ID aLayerID, float& aOutZtop, float& aOutZbot ) const;
void generate_ring_contour( const SFVEC2F& aCenter, float aInnerRadius,
float aOuterRadius, unsigned int aNr_sides_per_circle,
std::vector< SFVEC2F >& aInnerContourResult,
std::vector< SFVEC2F >& aOuterContourResult,
bool aInvertOrder );
void generateRing( const SFVEC2F& aCenter, float aInnerRadius, float aOuterRadius,
unsigned int aNr_sides_per_circle,
std::vector< SFVEC2F >& aInnerContourResult,
std::vector< SFVEC2F >& aOuterContourResult, bool aInvertOrder );
void generate_cylinder( const SFVEC2F& aCenter, float aInnerRadius, float aOuterRadius,
float aZtop, float aZbot, unsigned int aNr_sides_per_circle,
TRIANGLE_DISPLAY_LIST* aDstLayer );
void generateCylinder( const SFVEC2F& aCenter, float aInnerRadius, float aOuterRadius,
float aZtop, float aZbot, unsigned int aNr_sides_per_circle,
TRIANGLE_DISPLAY_LIST* aDstLayer );
void generate_3D_Vias_and_Pads();
void generateViasAndPads();
/**
* Load footprint models from the cache and load it to openGL lists in the form of
@ -129,33 +126,33 @@ private:
* This map of models will work as a local cache for this render. (cache based on
* MODEL_3D with associated openGL lists in GPU memory)
*/
void load_3D_models( REPORTER* aStatusReporter );
void load3dModels( REPORTER* aStatusReporter );
/**
* @param aRenderTopOrBot true will render Top, false will render bottom
* @param aRenderTransparentOnly true will render only the transparent objects, false will
* render opaque
*/
void render_3D_models( bool aRenderTopOrBot, bool aRenderTransparentOnly );
void render3dModels( bool aRenderTopOrBot, bool aRenderTransparentOnly );
void render_3D_models_selected( bool aRenderTopOrBot, bool aRenderTransparentOnly,
bool aRenderSelectedOnly );
void render3dModelsSelected( bool aRenderTopOrBot, bool aRenderTransparentOnly,
bool aRenderSelectedOnly );
void render_3D_footprint( const FOOTPRINT* aFootprint, bool aRenderTransparentOnly,
bool aIsSelected );
void renderFootprint( const FOOTPRINT* aFootprint, bool aRenderTransparentOnly,
bool aIsSelected );
void setLight_Front( bool enabled );
void setLight_Top( bool enabled );
void setLight_Bottom( bool enabled );
void setLightFront( bool enabled );
void setLightTop( bool enabled );
void setLightBottom( bool enabled );
void render_3D_arrows();
void render3dArrows();
/**
* Create a 3D grid to an OpenGL display list.
*
* A horizontal grid (XY plane and Z = 0, and a vertical grid (XZ plane and Y = 0).
*/
void generate_new_3DGrid( GRID3D_TYPE aGridType );
void generate3dGrid( GRID3D_TYPE aGridType );
// Materials
void setupMaterials();
@ -164,17 +161,17 @@ private:
void setPlatedCopperAndDepthOffset( PCB_LAYER_ID aLayer_id );
void unsetDepthOffset();
void set_layer_material( PCB_LAYER_ID aLayerID );
SFVEC4F get_layer_color( PCB_LAYER_ID aLayerID );
void setLayerMaterial( PCB_LAYER_ID aLayerID );
SFVEC4F getLayerColor( PCB_LAYER_ID aLayerID );
bool initializeOpenGL();
OPENGL_RENDER_LIST* createBoard( const SHAPE_POLY_SET& aBoardPoly,
const BVH_CONTAINER_2D* aThroughHoles = nullptr );
void reload( REPORTER* aStatusReporter, REPORTER* aWarningReporter );
void ogl_set_arrow_material();
void setArrowMaterial();
void ogl_free_all_display_lists();
void freeAllLists();
struct
{
@ -190,32 +187,32 @@ private:
} m_materials;
MAP_OGL_DISP_LISTS m_layers;
OPENGL_RENDER_LIST* m_platedPads_F_Cu;
OPENGL_RENDER_LIST* m_platedPads_B_Cu;
MAP_OGL_DISP_LISTS m_layers_holes_outer;
MAP_OGL_DISP_LISTS m_layers_holes_inner;
OPENGL_RENDER_LIST* m_platedPadsFront;
OPENGL_RENDER_LIST* m_platedPadsBack;
MAP_OGL_DISP_LISTS m_outerLayerHoles;
MAP_OGL_DISP_LISTS m_innerLayerHoles;
OPENGL_RENDER_LIST* m_board;
OPENGL_RENDER_LIST* m_board_with_holes;
OPENGL_RENDER_LIST* m_anti_board;
OPENGL_RENDER_LIST* m_through_holes_outer;
OPENGL_RENDER_LIST* m_through_holes_vias_outer;
OPENGL_RENDER_LIST* m_through_holes_outer_ring;
OPENGL_RENDER_LIST* m_boardWithHoles;
OPENGL_RENDER_LIST* m_antiBoard;
OPENGL_RENDER_LIST* m_outerThroughHoles;
OPENGL_RENDER_LIST* m_outerViaThroughHoles;
OPENGL_RENDER_LIST* m_outerThroughHoleRings;
OPENGL_RENDER_LIST* m_vias_and_pad_holes_outer_contourn_and_caps;
LIST_TRIANGLES m_triangles; ///< store pointers so can be deleted latter
GLuint m_ogl_circle_texture;
GLuint m_circleTexture;
GLuint m_grid; ///< oGL list that stores current grid
GRID3D_TYPE m_last_grid_type; ///< Stores the last grid computed
GRID3D_TYPE m_lastGridType; ///< Stores the last grid type.
OPENGL_RENDER_LIST* m_vias;
OPENGL_RENDER_LIST* m_pad_holes;
OPENGL_RENDER_LIST* m_padHoles;
MAP_3DMODEL m_3dmodel_map;
MAP_3DMODEL m_3dModelMap;
BOARD_ITEM* m_currentIntersectedBoardItem;
SHAPE_POLY_SET m_anti_board_poly; ///< negative polygon representation of the board outline
SHAPE_POLY_SET m_antiBoardPolys; ///< The negative polygon representation of the board outline.
};
#endif // RENDER_3D_LEGACY_H_

View File

@ -232,7 +232,7 @@ bool DIALOG_3D_VIEW_OPTIONS::TransferDataToWindow()
m_settings.GetFlag( FL_RENDER_OPENGL_VIAS_DISABLE_ON_MOVE ) );
m_checkBoxDisableMoveHoles->SetValue(
m_settings.GetFlag( FL_RENDER_OPENGL_HOLES_DISABLE_ON_MOVE ) );
m_choiceAntiAliasing->SetSelection( static_cast<int>( m_settings.AntiAliasingGet() ) );
m_choiceAntiAliasing->SetSelection( static_cast<int>( m_settings.GetAntiAliasingMode() ) );
// Raytracing options
m_checkBoxRaytracing_renderShadows->SetValue(
@ -316,7 +316,7 @@ bool DIALOG_3D_VIEW_OPTIONS::TransferDataFromWindow()
m_checkBoxDisableMoveVias->GetValue() );
m_settings.SetFlag( FL_RENDER_OPENGL_HOLES_DISABLE_ON_MOVE,
m_checkBoxDisableMoveHoles->GetValue() );
m_settings.AntiAliasingSet(
m_settings.SetAntiAliasingMode(
static_cast<ANTIALIASING_MODE>( m_choiceAntiAliasing->GetSelection() ) );
// Raytracing options

View File

@ -107,7 +107,7 @@ EDA_3D_VIEWER::EDA_3D_VIEWER( KIWAY *aKiway, PCB_BASE_FRAME *aParent, const wxSt
SetStatusWidths( arrayDim( status_dims ), status_dims );
m_canvas = new EDA_3D_CANVAS( this,
OGL_ATT_LIST::GetAttributesList( m_boardAdapter.AntiAliasingGet() ),
OGL_ATT_LIST::GetAttributesList( m_boardAdapter.GetAntiAliasingMode() ),
aParent->GetBoard(), m_boardAdapter, m_currentCamera,
Prj().Get3DCacheManager() );
@ -193,7 +193,7 @@ void EDA_3D_VIEWER::setupUIConditions()
auto raytracingCondition = [this]( const SELECTION& aSel )
{
return m_boardAdapter.RenderEngineGet() != RENDER_ENGINE::OPENGL_LEGACY;
return m_boardAdapter.GetRenderEngine() != RENDER_ENGINE::OPENGL_LEGACY;
};
RegisterUIUpdateHandler( ID_RENDER_CURRENT_VIEW,
@ -268,14 +268,14 @@ void EDA_3D_VIEWER::NewDisplay( bool aForceImmediateRedraw )
void EDA_3D_VIEWER::Redraw()
{
// Only update in OpenGL for an interactive interaction
if( m_boardAdapter.RenderEngineGet() == RENDER_ENGINE::OPENGL_LEGACY )
if( m_boardAdapter.GetRenderEngine() == RENDER_ENGINE::OPENGL_LEGACY )
m_canvas->Request_refresh( true );
}
void EDA_3D_VIEWER::refreshRender()
{
if( m_boardAdapter.RenderEngineGet() == RENDER_ENGINE::OPENGL_LEGACY )
if( m_boardAdapter.GetRenderEngine() == RENDER_ENGINE::OPENGL_LEGACY )
m_canvas->Request_refresh();
else
NewDisplay( true );
@ -388,18 +388,18 @@ void EDA_3D_VIEWER::Process_Special_Functions( wxCommandEvent &event )
void EDA_3D_VIEWER::OnRenderEngineSelection( wxCommandEvent &event )
{
const RENDER_ENGINE old_engine = m_boardAdapter.RenderEngineGet();
const RENDER_ENGINE old_engine = m_boardAdapter.GetRenderEngine();
if( old_engine == RENDER_ENGINE::OPENGL_LEGACY )
m_boardAdapter.RenderEngineSet( RENDER_ENGINE::RAYTRACING );
m_boardAdapter.SetRenderEngine( RENDER_ENGINE::RAYTRACING );
else
m_boardAdapter.RenderEngineSet( RENDER_ENGINE::OPENGL_LEGACY );
m_boardAdapter.SetRenderEngine( RENDER_ENGINE::OPENGL_LEGACY );
wxLogTrace( m_logTrace, "EDA_3D_VIEWER::OnRenderEngineSelection type %s ",
( m_boardAdapter.RenderEngineGet() == RENDER_ENGINE::RAYTRACING ) ? "Ray Trace" :
( m_boardAdapter.GetRenderEngine() == RENDER_ENGINE::RAYTRACING ) ? "Ray Trace" :
"OpenGL Legacy" );
if( old_engine != m_boardAdapter.RenderEngineGet() )
if( old_engine != m_boardAdapter.GetRenderEngine() )
RenderEngineChanged();
}
@ -409,7 +409,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_boardAdapter.RenderEngineSet( RENDER_ENGINE::OPENGL_LEGACY );
m_boardAdapter.SetRenderEngine( RENDER_ENGINE::OPENGL_LEGACY );
}
@ -539,8 +539,8 @@ void EDA_3D_VIEWER::LoadSettings( APP_SETTINGS_BASE *aCfg )
TRANSFER_SETTING( FL_CLIP_SILK_ON_VIA_ANNULUS, clip_silk_on_via_annulus );
TRANSFER_SETTING( FL_RENDER_PLATED_PADS_AS_PLATED, renderPlatedPadsAsPlated );
m_boardAdapter.GridSet( static_cast<GRID3D_TYPE>( cfg->m_Render.grid_type ) );
m_boardAdapter.AntiAliasingSet(
m_boardAdapter.SetGridType( static_cast<GRID3D_TYPE>( cfg->m_Render.grid_type ) );
m_boardAdapter.SetAntiAliasingMode(
static_cast<ANTIALIASING_MODE>( cfg->m_Render.opengl_AA_mode ) );
m_boardAdapter.m_opengl_selectionColor =
@ -570,10 +570,10 @@ void EDA_3D_VIEWER::LoadSettings( APP_SETTINGS_BASE *aCfg )
"EDA_3D_VIEWER::LoadSettings render setting Ray Trace" :
"EDA_3D_VIEWER::LoadSettings render setting OpenGL" );
#else
m_boardAdapter.RenderEngineSet( RENDER_ENGINE::OPENGL_LEGACY );
m_boardAdapter.SetRenderEngine( RENDER_ENGINE::OPENGL_LEGACY );
#endif
m_boardAdapter.MaterialModeSet( static_cast<MATERIAL_MODE>( cfg->m_Render.material_mode ) );
m_boardAdapter.SetMaterialMode( static_cast<MATERIAL_MODE>( cfg->m_Render.material_mode ) );
m_canvas->AnimationEnabledSet( cfg->m_Camera.animation_enabled );
m_canvas->MovingSpeedMultiplierSet( cfg->m_Camera.moving_speed_multiplier );
@ -625,7 +625,7 @@ void EDA_3D_VIEWER::SaveSettings( APP_SETTINGS_BASE *aCfg )
Pgm().GetSettingsManager().SaveColorSettings( colors, "3d_viewer" );
wxLogTrace( m_logTrace, m_boardAdapter.RenderEngineGet() == RENDER_ENGINE::RAYTRACING ?
wxLogTrace( m_logTrace, m_boardAdapter.GetRenderEngine() == RENDER_ENGINE::RAYTRACING ?
"EDA_3D_VIEWER::SaveSettings render setting Ray Trace" :
"EDA_3D_VIEWER::SaveSettings render setting OpenGL" );
@ -674,10 +674,10 @@ void EDA_3D_VIEWER::SaveSettings( APP_SETTINGS_BASE *aCfg )
#define TRANSFER_SETTING( field, flag ) cfg->m_Render.field = m_boardAdapter.GetFlag( flag )
cfg->m_Render.engine = static_cast<int>( m_boardAdapter.RenderEngineGet() );
cfg->m_Render.grid_type = static_cast<int>( m_boardAdapter.GridGet() );
cfg->m_Render.material_mode = static_cast<int>( m_boardAdapter.MaterialModeGet() );
cfg->m_Render.opengl_AA_mode = static_cast<int>( m_boardAdapter.AntiAliasingGet() );
cfg->m_Render.engine = static_cast<int>( m_boardAdapter.GetRenderEngine() );
cfg->m_Render.grid_type = static_cast<int>( m_boardAdapter.GetGridType() );
cfg->m_Render.material_mode = static_cast<int>( m_boardAdapter.GetMaterialMode() );
cfg->m_Render.opengl_AA_mode = static_cast<int>( m_boardAdapter.GetAntiAliasingMode() );
save_color( m_boardAdapter.m_opengl_selectionColor, cfg->m_Render.opengl_selection_color );

View File

@ -52,7 +52,7 @@ bool EDA_3D_CONDITIONS::materialModeFunction( const SELECTION& aSelection,
BOARD_ADAPTER* aAdapter,
MATERIAL_MODE aMaterial )
{
return aAdapter->MaterialModeGet() == aMaterial;
return aAdapter->GetMaterialMode() == aMaterial;
}
@ -68,5 +68,5 @@ bool EDA_3D_CONDITIONS::gridSizeFunction( const SELECTION& aSelection,
BOARD_ADAPTER* aAdapter,
GRID3D_TYPE aGridSize )
{
return aAdapter->GridGet() == aGridSize;
return aAdapter->GetGridType() == aGridSize;
}

View File

@ -162,7 +162,7 @@ int EDA_3D_CONTROLLER::RotateView( const TOOL_EVENT& aEvent )
default: wxFAIL; break;
}
if( m_boardAdapter->RenderEngineGet() == RENDER_ENGINE::OPENGL_LEGACY )
if( m_boardAdapter->GetRenderEngine() == RENDER_ENGINE::OPENGL_LEGACY )
m_canvas->Request_refresh();
else
m_canvas->RenderRaytracingRequest();
@ -175,7 +175,7 @@ int EDA_3D_CONTROLLER::SetMaterial( const TOOL_EVENT& aEvent )
{
MATERIAL_MODE mode = aEvent.Parameter<MATERIAL_MODE>();
m_boardAdapter->MaterialModeSet( mode );
m_boardAdapter->SetMaterialMode( mode );
if( EDA_3D_VIEWER* viewer = dynamic_cast<EDA_3D_VIEWER*>( m_toolMgr->GetToolHolder() ) )
viewer->NewDisplay( true );
@ -190,7 +190,7 @@ int EDA_3D_CONTROLLER::ToggleOrtho( const TOOL_EVENT& aEvent )
{
m_camera->ToggleProjection();
if( m_boardAdapter->RenderEngineGet() == RENDER_ENGINE::OPENGL_LEGACY )
if( m_boardAdapter->GetRenderEngine() == RENDER_ENGINE::OPENGL_LEGACY )
m_canvas->Request_refresh();
else
m_canvas->RenderRaytracingRequest();
@ -235,7 +235,7 @@ int EDA_3D_CONTROLLER::ToggleVisibility( const TOOL_EVENT& aEvent )
int EDA_3D_CONTROLLER::On3DGridSelection( const TOOL_EVENT& aEvent )
{
GRID3D_TYPE grid = aEvent.Parameter<GRID3D_TYPE>();
m_boardAdapter->GridSet( grid );
m_boardAdapter->SetGridType( grid );
if( m_canvas )
m_canvas->Request_refresh();