KiCad PCB EDA Suite
CINFO3D_VISU Class Reference

Class CINFO3D_VISU Helper class to handle information needed to display 3D board. More...

#include <cinfo3d_visu.h>

Public Member Functions

 CINFO3D_VISU ()
 
 ~CINFO3D_VISU ()
 
void Set3DCacheManager (S3D_CACHE *aCachePointer)
 Set3DCacheManager - Update the Cache manager pointer. More...
 
S3D_CACHEGet3DCacheManager () const
 Get3DCacheManager - Return the 3d cache manager pointer. More...
 
bool GetFlag (DISPLAY3D_FLG aFlag) const
 GetFlag - get a configuration status of a flag. More...
 
void SetFlag (DISPLAY3D_FLG aFlag, bool aState)
 SetFlag - set the status of a flag. More...
 
bool Is3DLayerEnabled (PCB_LAYER_ID aLayer) const
 Is3DLayerEnabled - Check if a layer is enabled. More...
 
bool ShouldModuleBeDisplayed (MODULE_ATTR_T aModuleAttributs) const
 ShouldModuleBeDisplayed - Test if module should be displayed in relation to attributs and the flags. More...
 
void SetBoard (BOARD *aBoard)
 SetBoard - Set current board to be rendered. More...
 
const BOARDGetBoard () const
 GetBoard - Get current board to be rendered. More...
 
void InitSettings (REPORTER *aStatusTextReporter)
 InitSettings - Function to be called by the render when it need to reload the settings for the board. More...
 
double BiuTo3Dunits () const
 BiuTo3Dunits - Board integer units To 3D units. More...
 
const CBBOXGetBBox3DU () const
 GetBBox3DU - Get the bbox of the pcb board. More...
 
float GetEpoxyThickness3DU () const
 GetEpoxyThickness3DU - Get the current epoxy thickness. More...
 
float GetNonCopperLayerThickness3DU () const
 GetNonCopperLayerThickness3DU - Get the current non copper layers thickness. More...
 
float GetCopperThickness3DU () const
 GetCopperThickness3DU - Get the current copper layer thickness. More...
 
int GetCopperThicknessBIU () const
 GetCopperThicknessBIU - Get the current copper layer thickness. More...
 
wxSize GetBoardSizeBIU () const
 GetBoardSizeBIU - Get the board size. More...
 
wxPoint GetBoardPosBIU () const
 GetBoardPosBIU - Get the board size. More...
 
const SFVEC3FGetBoardCenter3DU () const
 GetBoardCenter - the board center position in 3d units. More...
 
float GetModulesZcoord3DIU (bool aIsFlipped) const
 GetModulesZcoord3DIU - Get the position of the module in 3d integer units considering if it is flipped or not. More...
 
void CameraSetType (CAMERA_TYPE aCameraType)
 CameraSetType - Set the camera type to use. More...
 
CCAMERACameraGet () const
 CameraGet - get current camera in use. More...
 
GRID3D_TYPE GridGet () const
 GridGet - get the current grid. More...
 
void GridSet (GRID3D_TYPE aGridType)
 GridSet - set the current grid. More...
 
void RenderEngineSet (RENDER_ENGINE aRenderEngine)
 RenderEngineSet. More...
 
RENDER_ENGINE RenderEngineGet () const
 RenderEngineGet. More...
 
void MaterialModeSet (MATERIAL_MODE aMaterialMode)
 MaterialModeSet. More...
 
MATERIAL_MODE MaterialModeGet () const
 MaterialModeGet. More...
 
const SHAPE_POLY_SETGetBoardPoly () const
 GetBoardPoly - Get the current polygon of the epoxy board. More...
 
SFVEC3F GetLayerColor (PCB_LAYER_ID aLayerId) const
 GetLayerColor - get the technical color of a layer. More...
 
SFVEC3F GetItemColor (int aItemId) const
 GetItemColor - get the technical color of a layer. More...
 
SFVEC3F GetColor (COLOR4D aColor) const
 GetColor. More...
 
float GetLayerTopZpos3DU (PCB_LAYER_ID aLayerId) const
 GetLayerTopZpos3DU - Get the top z position. More...
 
float GetLayerBottomZpos3DU (PCB_LAYER_ID aLayerId) const
 GetLayerBottomZpos3DU - Get the bottom z position. More...
 
const MAP_CONTAINER_2DGetMapLayers () const
 GetMapLayers - Get the map of container that have the objects per layer. More...
 
const MAP_CONTAINER_2DGetMapLayersHoles () const
 GetMapLayersHoles -Get the map of container that have the holes per layer. More...
 
const CBVHCONTAINER2DGetThroughHole_Outer () const
 GetThroughHole_Outer - Get the inflated ThroughHole container. More...
 
const SHAPE_POLY_SETGetThroughHole_Outer_poly () const
 GetThroughHole_Outer_poly -. More...
 
const SHAPE_POLY_SETGetThroughHole_Outer_poly_NPTH () const
 GetThroughHole_Outer_poly_NPTH -. More...
 
const CBVHCONTAINER2DGetThroughHole_Vias_Outer () const
 GetThroughHole_Vias_Outer -. More...
 
const CBVHCONTAINER2DGetThroughHole_Vias_Inner () const
 GetThroughHole_Vias_Inner -. More...
 
const SHAPE_POLY_SETGetThroughHole_Vias_Outer_poly () const
 GetThroughHole_Vias_Outer_poly -. More...
 
const SHAPE_POLY_SETGetThroughHole_Vias_Inner_poly () const
 GetThroughHole_Vias_Inner_poly -. More...
 
const CBVHCONTAINER2DGetThroughHole_Inner () const
 GetThroughHole_Inner - Get the ThroughHole container. More...
 
const SHAPE_POLY_SETGetThroughHole_Inner_poly () const
 GetThroughHole_Inner_poly -. More...
 
unsigned int GetStats_Nr_Vias () const
 GetStats_Nr_Vias - Get statistics of the nr of vias. More...
 
unsigned int GetStats_Nr_Holes () const
 GetStats_Nr_Holes - Get statistics of the nr of holes. More...
 
float GetStats_Med_Via_Hole_Diameter3DU () const
 GetStats_Med_Via_Hole_Diameter3DU - Average diameter of the via holes. More...
 
float GetStats_Med_Hole_Diameter3DU () const
 GetStats_Med_Hole_Diameter3DU - Average diameter of holes. More...
 
float GetStats_Med_Track_Width () const
 GetStats_Med_Track_Width - Average width of the tracks. More...
 
unsigned int GetNrSegmentsCircle (float aDiameter3DU) const
 GetNrSegmentsCircle. More...
 
unsigned int GetNrSegmentsCircle (int aDiameterBIU) const
 GetNrSegmentsCircle. More...
 
double GetCircleCorrectionFactor (int aNrSides) const
 GetCircleCorrectionFactor - computes a angle correction factor used when creating circles. More...
 
const MAP_POLYGetPolyMap () const
 GetPolyMap - Get maps of polygons's layers. More...
 
const MAP_POLYGetPolyMapHoles_Inner () const
 
const MAP_POLYGetPolyMapHoles_Outer () const
 

Public Attributes

SFVEC3D m_BgColorBot
 background bottom color More...
 
SFVEC3D m_BgColorTop
 background top color More...
 
SFVEC3D m_BoardBodyColor
 in realistic mode: FR4 board color More...
 
SFVEC3D m_SolderMaskColor
 in realistic mode: solder mask color More...
 
SFVEC3D m_SolderPasteColor
 in realistic mode: solder paste color More...
 
SFVEC3D m_SilkScreenColor
 in realistic mode: SilkScreen color More...
 
SFVEC3D m_CopperColor
 in realistic mode: copper color More...
 

Private Member Functions

void createBoardPolygon ()
 
void createLayers (REPORTER *aStatusTextReporter)
 
void destroyLayers ()
 
COBJECT2DcreateNewTrack (const TRACK *aTrack, int aClearanceValue) const
 
void createNewPad (const D_PAD *aPad, CGENERICCONTAINER2D *aDstContainer, wxSize aInflateValue) const
 
void createNewPadWithClearance (const D_PAD *aPad, CGENERICCONTAINER2D *aDstContainer, wxSize aClearanceValue) const
 
COBJECT2DcreateNewPadDrill (const D_PAD *aPad, int aInflateValue)
 
void AddPadsShapesWithClearanceToContainer (const MODULE *aModule, CGENERICCONTAINER2D *aDstContainer, PCB_LAYER_ID aLayerId, int aInflateValue, bool aSkipNPTHPadsWihNoCopper)
 
void AddGraphicsShapesWithClearanceToContainer (const MODULE *aModule, CGENERICCONTAINER2D *aDstContainer, PCB_LAYER_ID aLayerId, int aInflateValue)
 
void AddShapeWithClearanceToContainer (const TEXTE_PCB *aTextPCB, CGENERICCONTAINER2D *aDstContainer, PCB_LAYER_ID aLayerId, int aClearanceValue)
 
void AddShapeWithClearanceToContainer (const DRAWSEGMENT *aDrawSegment, CGENERICCONTAINER2D *aDstContainer, PCB_LAYER_ID aLayerId, int aClearanceValue)
 
void AddShapeWithClearanceToContainer (const DIMENSION *aDimension, CGENERICCONTAINER2D *aDstContainer, PCB_LAYER_ID aLayerId, int aClearanceValue)
 
void AddSolidAreasShapesToContainer (const ZONE_CONTAINER *aZoneContainer, CGENERICCONTAINER2D *aDstContainer, PCB_LAYER_ID aLayerId)
 
void TransformArcToSegments (const wxPoint &aCentre, const wxPoint &aStart, double aArcAngle, int aCircleToSegmentsCount, int aWidth, CGENERICCONTAINER2D *aDstContainer, const BOARD_ITEM &aBoardItem)
 
void buildPadShapeThickOutlineAsSegments (const D_PAD *aPad, CGENERICCONTAINER2D *aDstContainer, int aWidth)
 
void buildPadShapeThickOutlineAsPolygon (const D_PAD *aPad, SHAPE_POLY_SET &aCornerBuffer, int aWidth) const
 
void transformPadsShapesWithClearanceToPolygon (const DLIST< D_PAD > &aPads, PCB_LAYER_ID aLayer, SHAPE_POLY_SET &aCornerBuffer, int aInflateValue, bool aSkipNPTHPadsWihNoCopper) const
 
void transformGraphicModuleEdgeToPolygonSet (const MODULE *aModule, PCB_LAYER_ID aLayer, SHAPE_POLY_SET &aCornerBuffer) const
 
void buildPadShapePolygon (const D_PAD *aPad, SHAPE_POLY_SET &aCornerBuffer, wxSize aInflateValue, int aSegmentsPerCircle, double aCorrectionFactor) const
 

Private Attributes

BOARDm_board
 Current board. More...
 
S3D_CACHEm_3d_model_manager
 pointer to the 3d model manager More...
 
std::vector< bool > m_drawFlags
 options flags to render the board More...
 
GRID3D_TYPE m_3D_grid_type
 Stores the current grid type. More...
 
RENDER_ENGINE m_render_engine
 render engine currently on use More...
 
MATERIAL_MODE m_material_mode
 mode to render the 3d shape models material More...
 
wxPoint m_boardPos
 center board actual position in board units More...
 
wxSize m_boardSize
 board actual size in board units More...
 
SFVEC3F m_boardCenter
 3d center position of the pcb board in 3d units More...
 
CBBOX m_boardBoudingBox
 3d bouding box of the pcb board in 3d units More...
 
CBBOX2D m_board2dBBox3DU
 2d bouding box of the pcb board in 3d units More...
 
MAP_POLY m_layers_poly
 It contains polygon contours for each layer. More...
 
MAP_POLY m_layers_outer_holes_poly
 It contains polygon contours for holes of each layer (outer holes) More...
 
MAP_POLY m_layers_inner_holes_poly
 It contains polygon contours for holes of each layer (inner holes) More...
 
SHAPE_POLY_SET m_through_outer_holes_poly_NPTH
 It contains polygon contours for (just) non plated through holes (outer cylinder) More...
 
SHAPE_POLY_SET m_through_outer_holes_poly
 It contains polygon contours for through holes (outer cylinder) More...
 
SHAPE_POLY_SET m_through_inner_holes_poly
 It contains polygon contours for through holes (inner cylinder) More...
 
SHAPE_POLY_SET m_through_outer_holes_vias_poly
 It contains polygon contours for through holes vias (outer cylinder) More...
 
SHAPE_POLY_SET m_through_inner_holes_vias_poly
 It contains polygon contours for through holes vias (inner cylinder) More...
 
SHAPE_POLY_SET m_board_poly
 PCB board outline polygon. More...
 
MAP_CONTAINER_2D m_layers_container2D
 It contains the 2d elements of each layer. More...
 
MAP_CONTAINER_2D m_layers_holes2D
 It contains the holes per each layer. More...
 
CBVHCONTAINER2D m_through_holes_outer
 It contains the list of throughHoles of the board, the radius of the hole is inflated with the copper tickness. More...
 
CBVHCONTAINER2D m_through_holes_inner
 It contains the list of throughHoles of the board, the radius is the inner hole. More...
 
CBVHCONTAINER2D m_through_holes_vias_outer
 It contains the list of throughHoles vias of the board, the radius of the hole is inflated with the copper tickness. More...
 
CBVHCONTAINER2D m_through_holes_vias_inner
 It contains the list of throughHoles vias of the board, the radius of the hole. More...
 
unsigned int m_copperLayersCount
 Number of copper layers actually used by the board. More...
 
double m_biuTo3Dunits
 Normalization scale to convert board internal units to 3D units to normalize 3D units between -1.0 and +1.0. More...
 
float m_layerZcoordTop [PCB_LAYER_ID_COUNT]
 Top (End) Z position of each layer (normalized) More...
 
float m_layerZcoordBottom [PCB_LAYER_ID_COUNT]
 Bottom (Start) Z position of each layer (normalized) More...
 
float m_copperThickness3DU
 Copper thickness (normalized) More...
 
float m_epoxyThickness3DU
 Epoxy thickness (normalized) More...
 
float m_nonCopperLayerThickness3DU
 Non copper layers thickness. More...
 
CCAMERAm_currentCamera
 Holds a pointer to current camera in use. More...
 
CTRACK_BALL m_trackBallCamera
 
float m_calc_seg_min_factor3DU
 min factor used for cicle segment approximation calculation More...
 
float m_calc_seg_max_factor3DU
 max factor used for cicle segment approximation calculation More...
 
unsigned int m_stats_nr_tracks
 Number of tracks in the board. More...
 
float m_stats_track_med_width
 Track average width. More...
 
unsigned int m_stats_nr_vias
 Nr of vias. More...
 
float m_stats_via_med_hole_diameter
 Computed medium diameter of the via holes in 3D units. More...
 
unsigned int m_stats_nr_holes
 number of holes in the board More...
 
float m_stats_hole_med_diameter
 Computed medium diameter of the holes in 3D units. More...
 

Static Private Attributes

static const wxChar * m_logTrace = wxT( "KI_TRACE_EDA_CINFO3D_VISU" )
 Trace mask used to enable or disable the trace output of this class. More...
 

Detailed Description

Class CINFO3D_VISU Helper class to handle information needed to display 3D board.

Definition at line 70 of file cinfo3d_visu.h.

Constructor & Destructor Documentation

CINFO3D_VISU::CINFO3D_VISU ( )

Definition at line 50 of file cinfo3d_visu.cpp.

References CGENERICCONTAINER2D::Clear(), FL_LAST, FL_MODULE_ATTRIBUTES_NORMAL, FL_MODULE_ATTRIBUTES_NORMAL_INSERT, FL_MODULE_ATTRIBUTES_VIRTUAL, FL_RENDER_OPENGL_COPPER_THICKNESS, FL_SHOW_BOARD_BODY, FL_SILKSCREEN, FL_SOLDERMASK, FL_USE_REALISTIC_MODE, FL_ZONE, GRID3D_NONE, m_3D_grid_type, m_3d_model_manager, m_BgColorBot, m_BgColorTop, m_biuTo3Dunits, m_board, m_board2dBBox3DU, m_BoardBodyColor, m_boardBoudingBox, m_boardCenter, m_boardPos, m_boardSize, m_calc_seg_max_factor3DU, m_calc_seg_min_factor3DU, m_CopperColor, m_copperLayersCount, m_copperThickness3DU, m_drawFlags, m_epoxyThickness3DU, m_layers_container2D, m_layers_holes2D, m_layerZcoordBottom, m_layerZcoordTop, m_logTrace, m_material_mode, m_nonCopperLayerThickness3DU, m_render_engine, m_SilkScreenColor, m_SolderMaskColor, m_SolderPasteColor, m_stats_hole_med_diameter, m_stats_nr_holes, m_stats_nr_tracks, m_stats_nr_vias, m_stats_track_med_width, m_stats_via_med_hole_diameter, m_through_holes_inner, m_through_holes_outer, MATERIAL_MODE_NORMAL, RENDER_ENGINE_OPENGL_LEGACY, CBBOX2D::Reset(), CBBOX::Reset(), and SetFlag().

50  :
53 {
54  wxLogTrace( m_logTrace, wxT( "CINFO3D_VISU::CINFO3D_VISU" ) );
55 
56  m_board = NULL;
57  m_3d_model_manager = NULL;
59  m_drawFlags.resize( FL_LAST, false );
60 
63 
64  m_boardPos = wxPoint();
65  m_boardSize = wxSize();
66  m_boardCenter = SFVEC3F( 0.0f );
67 
70 
71  m_layers_container2D.clear();
72  m_layers_holes2D.clear();
75 
77  m_epoxyThickness3DU = 0.0f;
78  m_copperThickness3DU = 0.0f;
80  m_biuTo3Dunits = 1.0;
81 
83  m_stats_nr_vias = 0;
85  m_stats_nr_holes = 0;
88 
91 
92 
93  memset( m_layerZcoordTop, 0, sizeof( m_layerZcoordTop ) );
94  memset( m_layerZcoordBottom, 0, sizeof( m_layerZcoordBottom ) );
95 
98  SetFlag( FL_SHOW_BOARD_BODY, true );
103  SetFlag( FL_ZONE, true );
104  SetFlag( FL_SILKSCREEN, true );
105  SetFlag( FL_SOLDERMASK, true );
106 
107  m_BgColorBot = SFVEC3D( 0.4, 0.4, 0.5 );
108  m_BgColorTop = SFVEC3D( 0.8, 0.8, 0.9 );
109  m_BoardBodyColor = SFVEC3D( 0.4, 0.4, 0.5 );
110  m_SolderMaskColor = SFVEC3D( 0.1, 0.2, 0.1 );
111  m_SolderPasteColor = SFVEC3D( 0.4, 0.4, 0.4 );
112  m_SilkScreenColor = SFVEC3D( 0.9, 0.9, 0.9 );
113  m_CopperColor = SFVEC3D( 0.75, 0.61, 0.23 );
114 }
wxPoint m_boardPos
center board actual position in board units
Definition: cinfo3d_visu.h:539
CBBOX2D m_board2dBBox3DU
2d bouding box of the pcb board in 3d units
Definition: cinfo3d_visu.h:554
SFVEC3D m_CopperColor
in realistic mode: copper color
Definition: cinfo3d_visu.h:509
CBBOX m_boardBoudingBox
3d bouding box of the pcb board in 3d units
Definition: cinfo3d_visu.h:551
float m_calc_seg_min_factor3DU
min factor used for cicle segment approximation calculation
Definition: cinfo3d_visu.h:641
MATERIAL_MODE m_material_mode
mode to render the 3d shape models material
Definition: cinfo3d_visu.h:533
float m_calc_seg_max_factor3DU
max factor used for cicle segment approximation calculation
Definition: cinfo3d_visu.h:644
#define RANGE_SCALE_3D
This defines the range that all coord will have to be rendered.
Definition: cinfo3d_visu.h:63
BOARD * m_board
Current board.
Definition: cinfo3d_visu.h:515
unsigned int m_stats_nr_holes
number of holes in the board
Definition: cinfo3d_visu.h:662
SFVEC3D m_BgColorBot
background bottom color
Definition: cinfo3d_visu.h:503
float m_nonCopperLayerThickness3DU
Non copper layers thickness.
Definition: cinfo3d_visu.h:631
std::vector< bool > m_drawFlags
options flags to render the board
Definition: cinfo3d_visu.h:524
CBVHCONTAINER2D m_through_holes_inner
It contains the list of throughHoles of the board, the radius is the inner hole.
Definition: cinfo3d_visu.h:598
float m_stats_via_med_hole_diameter
Computed medium diameter of the via holes in 3D units.
Definition: cinfo3d_visu.h:659
SFVEC3D m_BgColorTop
background top color
Definition: cinfo3d_visu.h:504
MAP_CONTAINER_2D m_layers_container2D
It contains the 2d elements of each layer.
Definition: cinfo3d_visu.h:587
float m_epoxyThickness3DU
Epoxy thickness (normalized)
Definition: cinfo3d_visu.h:628
SFVEC3D m_BoardBodyColor
in realistic mode: FR4 board color
Definition: cinfo3d_visu.h:505
float m_stats_hole_med_diameter
Computed medium diameter of the holes in 3D units.
Definition: cinfo3d_visu.h:665
void Reset()
Function Reset reset the bounding box to zero and de-initialized it.
Definition: cbbox2d.cpp:88
unsigned int m_stats_nr_vias
Nr of vias.
Definition: cinfo3d_visu.h:656
SFVEC3F m_boardCenter
3d center position of the pcb board in 3d units
Definition: cinfo3d_visu.h:545
wxSize m_boardSize
board actual size in board units
Definition: cinfo3d_visu.h:542
double m_biuTo3Dunits
Normalization scale to convert board internal units to 3D units to normalize 3D units between -1...
Definition: cinfo3d_visu.h:616
glm::dvec3 SFVEC3D
Definition: xv3d_types.h:48
static const wxChar * m_logTrace
Trace mask used to enable or disable the trace output of this class.
Definition: cinfo3d_visu.h:673
SFVEC3D m_SolderPasteColor
in realistic mode: solder paste color
Definition: cinfo3d_visu.h:507
SFVEC3D m_SolderMaskColor
in realistic mode: solder mask color
Definition: cinfo3d_visu.h:506
CCAMERA & m_currentCamera
Holds a pointer to current camera in use.
Definition: cinfo3d_visu.h:637
Use all material properties from model file.
Definition: 3d_enums.h:92
S3D_CACHE * m_3d_model_manager
pointer to the 3d model manager
Definition: cinfo3d_visu.h:518
SFVEC3D m_SilkScreenColor
in realistic mode: SilkScreen color
Definition: cinfo3d_visu.h:508
glm::vec3 SFVEC3F
Definition: xv3d_types.h:47
float m_copperThickness3DU
Copper thickness (normalized)
Definition: cinfo3d_visu.h:625
float m_stats_track_med_width
Track average width.
Definition: cinfo3d_visu.h:653
unsigned int m_copperLayersCount
Number of copper layers actually used by the board.
Definition: cinfo3d_visu.h:612
MAP_CONTAINER_2D m_layers_holes2D
It contains the holes per each layer.
Definition: cinfo3d_visu.h:590
RENDER_ENGINE m_render_engine
render engine currently on use
Definition: cinfo3d_visu.h:530
float m_layerZcoordBottom[PCB_LAYER_ID_COUNT]
Bottom (Start) Z position of each layer (normalized)
Definition: cinfo3d_visu.h:622
CTRACK_BALL m_trackBallCamera
Definition: cinfo3d_visu.h:638
GRID3D_TYPE m_3D_grid_type
Stores the current grid type.
Definition: cinfo3d_visu.h:527
float m_layerZcoordTop[PCB_LAYER_ID_COUNT]
Top (End) Z position of each layer (normalized)
Definition: cinfo3d_visu.h:619
CBVHCONTAINER2D m_through_holes_outer
It contains the list of throughHoles of the board, the radius of the hole is inflated with the copper...
Definition: cinfo3d_visu.h:594
void SetFlag(DISPLAY3D_FLG aFlag, bool aState)
SetFlag - set the status of a flag.
void Reset()
Function Reset reset the bounding box to zero and de-initialized it.
Definition: cbbox.cpp:98
unsigned int m_stats_nr_tracks
Number of tracks in the board.
Definition: cinfo3d_visu.h:650
CINFO3D_VISU::~CINFO3D_VISU ( )

Definition at line 117 of file cinfo3d_visu.cpp.

References destroyLayers().

118 {
119  destroyLayers();
120 }

Member Function Documentation

void CINFO3D_VISU::AddGraphicsShapesWithClearanceToContainer ( const MODULE aModule,
CGENERICCONTAINER2D aDstContainer,
PCB_LAYER_ID  aLayerId,
int  aInflateValue 
)
private

Definition at line 179 of file create_3Dgraphic_brd_items.cpp.

References AddShapeWithClearanceToContainer(), addTextSegmToContainer(), BLACK, DrawGraphicText(), TEXTE_MODULE::GetDrawRotation(), EDA_TEXT::GetHorizJustify(), BOARD_ITEM::GetLayer(), TEXTE_MODULE::GetShownText(), EDA_TEXT::GetTextPos(), EDA_TEXT::GetTextSize(), EDA_TEXT::GetThickness(), EDA_TEXT::GetVertJustify(), MODULE::GraphicalItemsList(), EDA_TEXT::IsItalic(), EDA_TEXT::IsMirrored(), EDA_TEXT::IsVisible(), m_biuTo3Dunits, m_board2dBBox3DU, BOARD_ITEM::Next(), PCB_MODULE_EDGE_T, PCB_MODULE_TEXT_T, MODULE::Reference(), s_biuTo3Dunits, s_textWidth, and MODULE::Value().

Referenced by createLayers(), and GetPolyMapHoles_Outer().

183 {
184  std::vector<TEXTE_MODULE *> texts; // List of TEXTE_MODULE to convert
185  EDGE_MODULE* outline;
186 
187  for( EDA_ITEM* item = aModule->GraphicalItemsList();
188  item != NULL;
189  item = item->Next() )
190  {
191  switch( item->Type() )
192  {
193  case PCB_MODULE_TEXT_T:
194  {
195  TEXTE_MODULE* text = static_cast<TEXTE_MODULE*>( item );
196 
197  if( text->GetLayer() == aLayerId && text->IsVisible() )
198  texts.push_back( text );
199  }
200  break;
201 
202 
203  case PCB_MODULE_EDGE_T:
204  {
205  outline = (EDGE_MODULE*) item;
206 
207  if( outline->GetLayer() != aLayerId )
208  break;
209 
211  aDstContainer,
212  aLayerId, 0 );
213  }
214  break;
215 
216  default:
217  break;
218  }
219  }
220 
221  // Convert texts sur modules
222  if( aModule->Reference().GetLayer() == aLayerId && aModule->Reference().IsVisible() )
223  texts.push_back( &aModule->Reference() );
224 
225  if( aModule->Value().GetLayer() == aLayerId && aModule->Value().IsVisible() )
226  texts.push_back( &aModule->Value() );
227 
228  s_boardItem = (const BOARD_ITEM *)&aModule->Value();
229  s_dstcontainer = aDstContainer;
232 
233  for( unsigned ii = 0; ii < texts.size(); ++ii )
234  {
235  TEXTE_MODULE *textmod = texts[ii];
236  s_textWidth = textmod->GetThickness() + ( 2 * aInflateValue );
237  wxSize size = textmod->GetTextSize();
238 
239  if( textmod->IsMirrored() )
240  size.x = -size.x;
241 
242  DrawGraphicText( NULL, NULL, textmod->GetTextPos(), BLACK,
243  textmod->GetShownText(), textmod->GetDrawRotation(), size,
244  textmod->GetHorizJustify(), textmod->GetVertJustify(),
245  textmod->GetThickness(), textmod->IsItalic(),
246  true, addTextSegmToContainer );
247  }
248 }
void AddShapeWithClearanceToContainer(const TEXTE_PCB *aTextPCB, CGENERICCONTAINER2D *aDstContainer, PCB_LAYER_ID aLayerId, int aClearanceValue)
TEXTE_MODULE & Reference()
Definition: class_module.h:513
double GetDrawRotation() const
const wxPoint & GetTextPos() const
Definition: eda_text.h:237
bool IsItalic() const
Definition: eda_text.h:183
Class BOARD_ITEM is a base class for any item which can be embedded within the BOARD container class...
CBBOX2D m_board2dBBox3DU
2d bouding box of the pcb board in 3d units
Definition: cinfo3d_visu.h:554
virtual PCB_LAYER_ID GetLayer() const
Function GetLayer returns the primary layer this item is on.
virtual wxString GetShownText() const override
Returns the string actually shown after processing of the base text.
EDA_TEXT_HJUSTIFY_T GetHorizJustify() const
Definition: eda_text.h:203
class EDGE_MODULE, a footprint edge
Definition: typeinfo.h:94
void DrawGraphicText(EDA_RECT *aClipBox, wxDC *aDC, const wxPoint &aPos, COLOR4D aColor, const wxString &aText, double aOrient, const wxSize &aSize, enum EDA_TEXT_HJUSTIFY_T aH_justify, enum EDA_TEXT_VJUSTIFY_T aV_justify, int aWidth, bool aItalic, bool aBold, void(*aCallback)(int x0, int y0, int xf, int yf, void *aData), void *aCallbackData, PLOTTER *aPlotter)
Function DrawGraphicText Draw a graphic text (like module texts)
int GetThickness() const
Function GetThickness returns pen width.
Definition: eda_text.h:167
static int s_textWidth
BOARD_ITEM * Next() const
static float s_biuTo3Dunits
TEXTE_MODULE & Value()
read/write accessors:
Definition: class_module.h:512
double m_biuTo3Dunits
Normalization scale to convert board internal units to 3D units to normalize 3D units between -1...
Definition: cinfo3d_visu.h:616
static const CBBOX2D * s_boardBBox3DU
static CGENERICCONTAINER2D * s_dstcontainer
class TEXTE_MODULE, text in a footprint
Definition: typeinfo.h:93
EDA_TEXT_VJUSTIFY_T GetVertJustify() const
Definition: eda_text.h:204
bool IsMirrored() const
Definition: eda_text.h:192
bool IsVisible() const
Definition: eda_text.h:189
Class EDA_ITEM is a base class for most all the KiCad significant classes, used in schematics and boa...
Definition: base_struct.h:154
void addTextSegmToContainer(int x0, int y0, int xf, int yf, void *aData)
DLIST< BOARD_ITEM > & GraphicalItemsList()
Definition: class_module.h:166
Definition: colors.h:45
const wxSize & GetTextSize() const
Definition: eda_text.h:228
static const BOARD_ITEM * s_boardItem
void CINFO3D_VISU::AddPadsShapesWithClearanceToContainer ( const MODULE aModule,
CGENERICCONTAINER2D aDstContainer,
PCB_LAYER_ID  aLayerId,
int  aInflateValue,
bool  aSkipNPTHPadsWihNoCopper 
)
private

Definition at line 608 of file create_3Dgraphic_brd_items.cpp.

References B_Mask, B_Paste, createNewPad(), F_Mask, F_Paste, D_PAD::GetAttribute(), D_PAD::GetDrillShape(), D_PAD::GetDrillSize(), D_PAD::GetOffset(), D_PAD::GetShape(), D_PAD::GetSize(), D_PAD::GetSolderMaskMargin(), D_PAD::GetSolderPasteMargin(), D_PAD::IsOnLayer(), D_PAD::Next(), PAD_ATTRIB_HOLE_NOT_PLATED, PAD_DRILL_SHAPE_CIRCLE, PAD_SHAPE_CIRCLE, PAD_SHAPE_OVAL, and MODULE::PadsList().

Referenced by createLayers(), and GetPolyMapHoles_Outer().

613 {
614  const D_PAD* pad = aModule->PadsList();
615 
616  wxSize margin;
617 
618  for( ; pad != NULL; pad = pad->Next() )
619  {
620  if( !pad->IsOnLayer( aLayerId ) )
621  continue;
622 
623  // NPTH pads are not drawn on layers if the
624  // shape size and pos is the same as their hole:
625  if( aSkipNPTHPadsWihNoCopper && (pad->GetAttribute() == PAD_ATTRIB_HOLE_NOT_PLATED) )
626  {
627  if( (pad->GetDrillSize() == pad->GetSize()) &&
628  (pad->GetOffset() == wxPoint( 0, 0 )) )
629  {
630  switch( pad->GetShape() )
631  {
632  case PAD_SHAPE_CIRCLE:
633  if( pad->GetDrillShape() == PAD_DRILL_SHAPE_CIRCLE )
634  continue;
635  break;
636 
637  case PAD_SHAPE_OVAL:
638  if( pad->GetDrillShape() != PAD_DRILL_SHAPE_CIRCLE )
639  continue;
640  break;
641 
642  default:
643  break;
644  }
645  }
646  }
647 
648  switch( aLayerId )
649  {
650  case F_Mask:
651  case B_Mask:
652  margin.x = margin.y = pad->GetSolderMaskMargin() + aInflateValue;
653  break;
654 
655  case F_Paste:
656  case B_Paste:
657  margin = pad->GetSolderPasteMargin();
658  margin.x += aInflateValue;
659  margin.y += aInflateValue;
660  break;
661 
662  default:
663  margin.x = margin.y = aInflateValue;
664  break;
665  }
666 
667  createNewPad( pad, aDstContainer, margin );
668  }
669 }
PAD_ATTR_T GetAttribute() const
Definition: class_pad.h:405
like PAD_STANDARD, but not plated mechanical use only, no connection allowed
Definition: pad_shapes.h:65
PAD_DRILL_SHAPE_T GetDrillShape() const
Definition: class_pad.h:388
const wxSize & GetDrillSize() const
Definition: class_pad.h:275
void createNewPad(const D_PAD *aPad, CGENERICCONTAINER2D *aDstContainer, wxSize aInflateValue) const
PAD_SHAPE_T GetShape() const
Function GetShape.
Definition: class_pad.h:216
int GetSolderMaskMargin() const
Function GetSolderMaskMargin.
Definition: class_pad.cpp:594
D_PAD * Next() const
Definition: class_pad.h:160
const wxSize & GetSize() const
Definition: class_pad.h:269
wxSize GetSolderPasteMargin() const
Function GetSolderPasteMargin.
Definition: class_pad.cpp:637
DLIST< D_PAD > & PadsList()
Definition: class_module.h:163
bool IsOnLayer(PCB_LAYER_ID aLayer) const override
Function IsOnLayer tests to see if this object is on the given layer.
Definition: class_pad.h:663
const wxPoint & GetOffset() const
Definition: class_pad.h:278
void CINFO3D_VISU::AddShapeWithClearanceToContainer ( const TEXTE_PCB aTextPCB,
CGENERICCONTAINER2D aDstContainer,
PCB_LAYER_ID  aLayerId,
int  aClearanceValue 
)
private

Definition at line 92 of file create_3Dgraphic_brd_items.cpp.

References addTextSegmToContainer(), BLACK, DrawGraphicText(), EDA_TEXT::GetHorizJustify(), EDA_TEXT::GetPositionsOfLinesOfMultilineText(), EDA_TEXT::GetShownText(), EDA_TEXT::GetTextAngle(), EDA_TEXT::GetTextPos(), EDA_TEXT::GetTextSize(), EDA_TEXT::GetThickness(), EDA_TEXT::GetVertJustify(), EDA_TEXT::IsItalic(), EDA_TEXT::IsMirrored(), EDA_TEXT::IsMultilineAllowed(), m_biuTo3Dunits, m_board2dBBox3DU, s_biuTo3Dunits, s_textWidth, and wxStringSplit().

Referenced by AddGraphicsShapesWithClearanceToContainer(), AddShapeWithClearanceToContainer(), createLayers(), and GetPolyMapHoles_Outer().

96 {
97  wxSize size = aTextPCB->GetTextSize();
98 
99  if( aTextPCB->IsMirrored() )
100  size.x = -size.x;
101 
102  s_boardItem = (const BOARD_ITEM *)&aTextPCB;
103  s_dstcontainer = aDstContainer;
104  s_textWidth = aTextPCB->GetThickness() + ( 2 * aClearanceValue );
107 
108  // not actually used, but needed by DrawGraphicText
109  const COLOR4D dummy_color = COLOR4D::BLACK;
110 
111  if( aTextPCB->IsMultilineAllowed() )
112  {
113  wxArrayString strings_list;
114  wxStringSplit( aTextPCB->GetShownText(), strings_list, '\n' );
115  std::vector<wxPoint> positions;
116  positions.reserve( strings_list.Count() );
117  aTextPCB->GetPositionsOfLinesOfMultilineText( positions,
118  strings_list.Count() );
119 
120  for( unsigned ii = 0; ii < strings_list.Count(); ++ii )
121  {
122  wxString txt = strings_list.Item( ii );
123 
124  DrawGraphicText( NULL, NULL, positions[ii], dummy_color,
125  txt, aTextPCB->GetTextAngle(), size,
126  aTextPCB->GetHorizJustify(), aTextPCB->GetVertJustify(),
127  aTextPCB->GetThickness(), aTextPCB->IsItalic(),
128  true, addTextSegmToContainer );
129  }
130  }
131  else
132  {
133  DrawGraphicText( NULL, NULL, aTextPCB->GetTextPos(), dummy_color,
134  aTextPCB->GetShownText(), aTextPCB->GetTextAngle(), size,
135  aTextPCB->GetHorizJustify(), aTextPCB->GetVertJustify(),
136  aTextPCB->GetThickness(), aTextPCB->IsItalic(),
137  true, addTextSegmToContainer );
138  }
139 }
void wxStringSplit(const wxString &aText, wxArrayString &aStrings, wxChar aSplitter)
Split aString to a string list separated at aSplitter.
Definition: common.cpp:183
bool IsMultilineAllowed() const
Definition: eda_text.h:201
const wxPoint & GetTextPos() const
Definition: eda_text.h:237
bool IsItalic() const
Definition: eda_text.h:183
Class BOARD_ITEM is a base class for any item which can be embedded within the BOARD container class...
CBBOX2D m_board2dBBox3DU
2d bouding box of the pcb board in 3d units
Definition: cinfo3d_visu.h:554
EDA_TEXT_HJUSTIFY_T GetHorizJustify() const
Definition: eda_text.h:203
void DrawGraphicText(EDA_RECT *aClipBox, wxDC *aDC, const wxPoint &aPos, COLOR4D aColor, const wxString &aText, double aOrient, const wxSize &aSize, enum EDA_TEXT_HJUSTIFY_T aH_justify, enum EDA_TEXT_VJUSTIFY_T aV_justify, int aWidth, bool aItalic, bool aBold, void(*aCallback)(int x0, int y0, int xf, int yf, void *aData), void *aCallbackData, PLOTTER *aPlotter)
Function DrawGraphicText Draw a graphic text (like module texts)
double GetTextAngle() const
Definition: eda_text.h:177
int GetThickness() const
Function GetThickness returns pen width.
Definition: eda_text.h:167
static int s_textWidth
virtual wxString GetShownText() const
Returns the string actually shown after processing of the base text.
Definition: eda_text.h:148
static float s_biuTo3Dunits
double m_biuTo3Dunits
Normalization scale to convert board internal units to 3D units to normalize 3D units between -1...
Definition: cinfo3d_visu.h:616
static const CBBOX2D * s_boardBBox3DU
static CGENERICCONTAINER2D * s_dstcontainer
void GetPositionsOfLinesOfMultilineText(std::vector< wxPoint > &aPositions, int aLineCount) const
Function GetPositionsOfLinesOfMultilineText Populates aPositions with the position of each line of a ...
Definition: eda_text.cpp:315
EDA_TEXT_VJUSTIFY_T GetVertJustify() const
Definition: eda_text.h:204
bool IsMirrored() const
Definition: eda_text.h:192
void addTextSegmToContainer(int x0, int y0, int xf, int yf, void *aData)
Definition: colors.h:45
const wxSize & GetTextSize() const
Definition: eda_text.h:228
static const BOARD_ITEM * s_boardItem
Class COLOR4D is the color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:39
void CINFO3D_VISU::AddShapeWithClearanceToContainer ( const DRAWSEGMENT aDrawSegment,
CGENERICCONTAINER2D aDstContainer,
PCB_LAYER_ID  aLayerId,
int  aClearanceValue 
)
private

Definition at line 750 of file create_3Dgraphic_brd_items.cpp.

References CGENERICCONTAINER2D::Add(), Convert_shape_line_polygon_to_triangles(), DRAWSEGMENT::GetAngle(), DRAWSEGMENT::GetArcStart(), DRAWSEGMENT::GetBoundingBox(), DRAWSEGMENT::GetCenter(), GetCircleCorrectionFactor(), DRAWSEGMENT::GetEnd(), GetNrSegmentsCircle(), DRAWSEGMENT::GetRadius(), DRAWSEGMENT::GetShape(), EDA_RECT::GetSizeMax(), DRAWSEGMENT::GetStart(), DRAWSEGMENT::GetWidth(), Is_segment_a_circle(), SHAPE_POLY_SET::IsEmpty(), m_biuTo3Dunits, SHAPE_POLY_SET::PM_FAST, S_ARC, S_CIRCLE, S_CURVE, S_POLYGON, S_SEGMENT, SHAPE_POLY_SET::Simplify(), TransformArcToSegments(), DRAWSEGMENT::TransformShapeWithClearanceToPolygon(), wxPoint::x, and wxPoint::y.

754 {
755  // The full width of the lines to create
756  // The extra 1 protects the inner/outer radius values from degeneracy
757  const int linewidth = aDrawSegment->GetWidth() + (2 * aClearanceValue) + 1;
758 
759  switch( aDrawSegment->GetShape() )
760  {
761  case S_CIRCLE:
762  {
763  const SFVEC2F center3DU( aDrawSegment->GetCenter().x * m_biuTo3Dunits,
764  -aDrawSegment->GetCenter().y * m_biuTo3Dunits );
765 
766  const float inner_radius = (aDrawSegment->GetRadius() - linewidth / 2) * m_biuTo3Dunits;
767  const float outter_radius = (aDrawSegment->GetRadius() + linewidth / 2) * m_biuTo3Dunits;
768 
769  aDstContainer->Add( new CRING2D( center3DU,
770  inner_radius,
771  outter_radius,
772  *aDrawSegment ) );
773  }
774  break;
775 
776  case S_ARC:
777  {
778  const unsigned int nr_segments =
779  GetNrSegmentsCircle( aDrawSegment->GetBoundingBox().GetSizeMax() );
780 
781  TransformArcToSegments( aDrawSegment->GetCenter(),
782  aDrawSegment->GetArcStart(),
783  aDrawSegment->GetAngle(),
784  nr_segments,
785  aDrawSegment->GetWidth(),
786  aDstContainer,
787  *aDrawSegment );
788  }
789  break;
790 
791  case S_SEGMENT:
792  {
793  const SFVEC2F start3DU( aDrawSegment->GetStart().x * m_biuTo3Dunits,
794  -aDrawSegment->GetStart().y * m_biuTo3Dunits );
795 
796  const SFVEC2F end3DU ( aDrawSegment->GetEnd().x * m_biuTo3Dunits,
797  -aDrawSegment->GetEnd().y * m_biuTo3Dunits );
798 
799  if( Is_segment_a_circle( start3DU, end3DU ) )
800  {
801  aDstContainer->Add( new CFILLEDCIRCLE2D( start3DU,
802  ( linewidth / 2 ) * m_biuTo3Dunits,
803  *aDrawSegment ) );
804  }
805  else
806  {
807  aDstContainer->Add( new CROUNDSEGMENT2D( start3DU,
808  end3DU,
809  linewidth * m_biuTo3Dunits,
810  *aDrawSegment ) );
811  }
812  }
813  break;
814 
815  case S_CURVE:
816  case S_POLYGON:
817  {
818  const int segcountforcircle = 16;
819  const double correctionFactor = GetCircleCorrectionFactor( segcountforcircle );
820  SHAPE_POLY_SET polyList;
821 
822  aDrawSegment->TransformShapeWithClearanceToPolygon( polyList, aClearanceValue,
823  segcountforcircle, correctionFactor );
824 
825  polyList.Simplify( SHAPE_POLY_SET::PM_FAST );
826 
827  if( polyList.IsEmpty() ) // Just for caution
828  break;
829 
830  Convert_shape_line_polygon_to_triangles( polyList, *aDstContainer,
831  m_biuTo3Dunits, *aDrawSegment );
832  }
833  break;
834 
835  default:
836  break;
837  }
838 }
const wxPoint GetCenter() const override
Function GetCenter()
polygon (not yet used for tracks, but could be in microwave apps)
void TransformArcToSegments(const wxPoint &aCentre, const wxPoint &aStart, double aArcAngle, int aCircleToSegmentsCount, int aWidth, CGENERICCONTAINER2D *aDstContainer, const BOARD_ITEM &aBoardItem)
usual segment : line with rounded ends
const wxPoint & GetArcStart() const
STROKE_T GetShape() const
bool Is_segment_a_circle(const SFVEC2F &aStart, const SFVEC2F &aEnd)
Segment_is_a_circle - check if segment start and end is very close to each other should used to check...
const wxPoint & GetEnd() const
Function GetEnd returns the ending point of the graphic.
glm::vec2 SFVEC2F
Definition: xv3d_types.h:45
Class SHAPE_POLY_SET.
Arcs (with rounded ends)
int GetSizeMax() const
GetSizeMax.
Definition: eda_rect.h:107
double m_biuTo3Dunits
Normalization scale to convert board internal units to 3D units to normalize 3D units between -1...
Definition: cinfo3d_visu.h:616
void Simplify(POLYGON_MODE aFastMode)
Simplifies the polyset (merges overlapping polys, eliminates degeneracy/self-intersections) For aFast...
Bezier Curve.
unsigned int GetNrSegmentsCircle(float aDiameter3DU) const
GetNrSegmentsCircle.
void Add(COBJECT2D *aObject)
Definition: ccontainer2d.h:52
void TransformShapeWithClearanceToPolygon(SHAPE_POLY_SET &aCornerBuffer, int aClearanceValue, int aCircleToSegmentsCount, double aCorrectionFactor, bool ignoreLineWidth=false) const override
Function TransformShapeWithClearanceToPolygon Convert the draw segment to a closed polygon Used in fi...
double GetAngle() const
double GetCircleCorrectionFactor(int aNrSides) const
GetCircleCorrectionFactor - computes a angle correction factor used when creating circles...
int GetWidth() const
bool IsEmpty() const
Returns true if the set is empty (no polygons at all)
const wxPoint & GetStart() const
Function GetStart returns the starting point of the graphic.
int GetRadius() const
Function GetRadius returns the radius of this item Has meaning only for arc and circle.
void Convert_shape_line_polygon_to_triangles(SHAPE_POLY_SET &aPolyList, CGENERICCONTAINER2D &aDstContainer, float aBiuTo3DunitsScale, const BOARD_ITEM &aBoardItem)
virtual const EDA_RECT GetBoundingBox() const override
Function GetBoundingBox returns the orthogonal, bounding box of this object for display purposes...
void CINFO3D_VISU::AddShapeWithClearanceToContainer ( const DIMENSION aDimension,
CGENERICCONTAINER2D aDstContainer,
PCB_LAYER_ID  aLayerId,
int  aClearanceValue 
)
private

Definition at line 142 of file create_3Dgraphic_brd_items.cpp.

References CGENERICCONTAINER2D::Add(), AddShapeWithClearanceToContainer(), DIMENSION::GetWidth(), DIMENSION::m_arrowD1F, DIMENSION::m_arrowD2F, DIMENSION::m_arrowG1F, DIMENSION::m_arrowG2F, m_biuTo3Dunits, DIMENSION::m_crossBarF, DIMENSION::m_crossBarO, DIMENSION::m_featureLineDF, DIMENSION::m_featureLineDO, DIMENSION::m_featureLineGF, DIMENSION::m_featureLineGO, and DIMENSION::Text().

146 {
147  AddShapeWithClearanceToContainer(&aDimension->Text(), aDstContainer, aLayerId, aClearanceValue);
148 
149  const int linewidth = aDimension->GetWidth() + (2 * aClearanceValue);
150 
151  std::pair<wxPoint const *, wxPoint const *> segs[] = {
152  {&aDimension->m_crossBarO, &aDimension->m_crossBarF},
153  {&aDimension->m_featureLineGO, &aDimension->m_featureLineGF},
154  {&aDimension->m_featureLineDO, &aDimension->m_featureLineDF},
155  {&aDimension->m_crossBarF, &aDimension->m_arrowD1F},
156  {&aDimension->m_crossBarF, &aDimension->m_arrowD2F},
157  {&aDimension->m_crossBarO, &aDimension->m_arrowG1F},
158  {&aDimension->m_crossBarO, &aDimension->m_arrowG2F}};
159 
160  for( auto const & ii : segs )
161  {
162  const SFVEC2F start3DU( ii.first->x * m_biuTo3Dunits,
163  -ii.first->y * m_biuTo3Dunits );
164 
165  const SFVEC2F end3DU ( ii.second->x * m_biuTo3Dunits,
166  -ii.second->y * m_biuTo3Dunits );
167 
168  aDstContainer->Add( new CROUNDSEGMENT2D( start3DU,
169  end3DU,
170  linewidth * m_biuTo3Dunits,
171  *aDimension ) );
172  }
173 }
void AddShapeWithClearanceToContainer(const TEXTE_PCB *aTextPCB, CGENERICCONTAINER2D *aDstContainer, PCB_LAYER_ID aLayerId, int aClearanceValue)
wxPoint m_crossBarF
wxPoint m_arrowD1F
int GetWidth() const
wxPoint m_featureLineDF
wxPoint m_featureLineGO
glm::vec2 SFVEC2F
Definition: xv3d_types.h:45
wxPoint m_arrowG1F
wxPoint m_arrowD2F
wxPoint m_arrowG2F
double m_biuTo3Dunits
Normalization scale to convert board internal units to 3D units to normalize 3D units between -1...
Definition: cinfo3d_visu.h:616
void Add(COBJECT2D *aObject)
Definition: ccontainer2d.h:52
TEXTE_PCB & Text()
wxPoint m_crossBarO
wxPoint m_featureLineDO
wxPoint m_featureLineGF
void CINFO3D_VISU::AddSolidAreasShapesToContainer ( const ZONE_CONTAINER aZoneContainer,
CGENERICCONTAINER2D aDstContainer,
PCB_LAYER_ID  aLayerId 
)
private

Definition at line 844 of file create_3Dgraphic_brd_items.cpp.

References CGENERICCONTAINER2D::Add(), SHAPE_POLY_SET::CHole(), Convert_shape_line_polygon_to_triangles(), SHAPE_POLY_SET::COutline(), SHAPE_LINE_CHAIN::CPoint(), ZONE_CONTAINER::GetFilledPolysList(), ZONE_CONTAINER::GetMinThickness(), SHAPE_POLY_SET::HoleCount(), i, Is_segment_a_circle(), m_biuTo3Dunits, SHAPE_POLY_SET::OutlineCount(), SHAPE_LINE_CHAIN::PointCount(), VECTOR2< T >::x, and VECTOR2< T >::y.

Referenced by createLayers(), and GetPolyMapHoles_Outer().

847 {
848  // Copy the polys list because we have to simplify it
849  SHAPE_POLY_SET polyList = SHAPE_POLY_SET( aZoneContainer->GetFilledPolysList(), true );
850 
851  // This convert the poly in outline and holes
853  *aDstContainer,
855  *aZoneContainer );
856 
857  // add filled areas outlines, which are drawn with thick lines segments
858  // /////////////////////////////////////////////////////////////////////////
859  for( int i = 0; i < polyList.OutlineCount(); ++i )
860  {
861  // Add outline
862  const SHAPE_LINE_CHAIN& pathOutline = polyList.COutline( i );
863 
864  for( int j = 0; j < pathOutline.PointCount(); ++j )
865  {
866  const VECTOR2I& a = pathOutline.CPoint( j );
867  const VECTOR2I& b = pathOutline.CPoint( j + 1 );
868 
869  SFVEC2F start3DU( a.x * m_biuTo3Dunits, -a.y * m_biuTo3Dunits );
870  SFVEC2F end3DU ( b.x * m_biuTo3Dunits, -b.y * m_biuTo3Dunits );
871 
872  if( Is_segment_a_circle( start3DU, end3DU ) )
873  {
874  float radius = (aZoneContainer->GetMinThickness() / 2) * m_biuTo3Dunits;
875 
876  if( radius > 0.0 ) // degenerated circles crash 3D viewer
877  aDstContainer->Add( new CFILLEDCIRCLE2D( start3DU, radius ,
878  *aZoneContainer ) );
879  }
880  else
881  {
882  aDstContainer->Add( new CROUNDSEGMENT2D( start3DU, end3DU,
883  aZoneContainer->GetMinThickness() *
885  *aZoneContainer ) );
886  }
887  }
888 
889  // Add holes (of the poly, ie: the open parts) for this outline
890  for( int h = 0; h < polyList.HoleCount( i ); ++h )
891  {
892  const SHAPE_LINE_CHAIN& pathHole = polyList.CHole( i, h );
893 
894  for( int j = 0; j < pathHole.PointCount(); j++ )
895  {
896  const VECTOR2I& a = pathHole.CPoint( j );
897  const VECTOR2I& b = pathHole.CPoint( j + 1 );
898 
899  SFVEC2F start3DU( a.x * m_biuTo3Dunits, -a.y * m_biuTo3Dunits );
900  SFVEC2F end3DU ( b.x * m_biuTo3Dunits, -b.y * m_biuTo3Dunits );
901 
902  if( Is_segment_a_circle( start3DU, end3DU ) )
903  {
904  float radius = (aZoneContainer->GetMinThickness() / 2) * m_biuTo3Dunits;
905 
906  if( radius > 0.0 ) // degenerated circles crash 3D viewer
907  aDstContainer->Add(
908  new CFILLEDCIRCLE2D( start3DU, radius,
909  *aZoneContainer ) );
910  }
911  else
912  {
913  aDstContainer->Add(
914  new CROUNDSEGMENT2D( start3DU, end3DU,
915  aZoneContainer->GetMinThickness() *
917  *aZoneContainer ) );
918  }
919  }
920  }
921  }
922 }
int GetMinThickness() const
Definition: class_zone.h:204
int PointCount() const
Function PointCount()
int HoleCount(int aOutline) const
Returns the number of holes in a given outline
const SHAPE_LINE_CHAIN & CHole(int aOutline, int aHole) const
int OutlineCount() const
Returns the number of outlines in the set
bool Is_segment_a_circle(const SFVEC2F &aStart, const SFVEC2F &aEnd)
Segment_is_a_circle - check if segment start and end is very close to each other should used to check...
glm::vec2 SFVEC2F
Definition: xv3d_types.h:45
Class SHAPE_POLY_SET.
double m_biuTo3Dunits
Normalization scale to convert board internal units to 3D units to normalize 3D units between -1...
Definition: cinfo3d_visu.h:616
const SHAPE_LINE_CHAIN & COutline(int aIndex) const
const SHAPE_POLY_SET & GetFilledPolysList() const
Function GetFilledPolysList returns a reference to the list of filled polygons.
Definition: class_zone.h:555
void Add(COBJECT2D *aObject)
Definition: ccontainer2d.h:52
Class SHAPE_LINE_CHAIN.
size_t i
Definition: json11.cpp:597
const VECTOR2I & CPoint(int aIndex) const
Function CPoint()
void Convert_shape_line_polygon_to_triangles(SHAPE_POLY_SET &aPolyList, CGENERICCONTAINER2D &aDstContainer, float aBiuTo3DunitsScale, const BOARD_ITEM &aBoardItem)
double CINFO3D_VISU::BiuTo3Dunits ( ) const
inline

BiuTo3Dunits - Board integer units To 3D units.

Returns
the conversion factor to transform a position from the board to 3d units

Definition at line 141 of file cinfo3d_visu.h.

References m_biuTo3Dunits.

Referenced by createLayers(), C3D_RENDER_OGL_LEGACY::generate_3D_Vias_and_Pads(), C3D_RENDER_OGL_LEGACY::generate_holes_display_list(), C3D_RENDER_OGL_LEGACY::generate_new_3DGrid(), C3D_RENDER_RAYTRACING::insert3DPadHole(), C3D_RENDER_RAYTRACING::insert3DViaHole(), C3D_RENDER_RAYTRACING::load_3D_models(), C3D_RENDER_OGL_LEGACY::reload(), C3D_RENDER_RAYTRACING::reload(), C3D_RENDER_OGL_LEGACY::render_3D_module(), and C3D_RENDER_RAYTRACING::setupMaterials().

141 { return m_biuTo3Dunits; }
double m_biuTo3Dunits
Normalization scale to convert board internal units to 3D units to normalize 3D units between -1...
Definition: cinfo3d_visu.h:616
void CINFO3D_VISU::buildPadShapePolygon ( const D_PAD aPad,
SHAPE_POLY_SET aCornerBuffer,
wxSize  aInflateValue,
int  aSegmentsPerCircle,
double  aCorrectionFactor 
) const
private

Definition at line 41 of file create_layer_poly.cpp.

References SHAPE_POLY_SET::AddOutline(), SHAPE_LINE_CHAIN::Append(), SHAPE_POLY_SET::Append(), D_PAD::BuildPadPolygon(), D_PAD::CustomShapeAsPolygonToBoardPosition(), dummy(), D_PAD::GetCustomShapeAsPolygon(), D_PAD::GetOrientation(), D_PAD::GetShape(), D_PAD::GetSize(), PAD_SHAPE_CIRCLE, PAD_SHAPE_CUSTOM, PAD_SHAPE_OVAL, PAD_SHAPE_RECT, PAD_SHAPE_ROUNDRECT, PAD_SHAPE_TRAPEZOID, SHAPE_LINE_CHAIN::SetClosed(), D_PAD::SetSize(), D_PAD::ShapePos(), and D_PAD::TransformShapeWithClearanceToPolygon().

Referenced by buildPadShapeThickOutlineAsPolygon(), GetPolyMapHoles_Outer(), and transformPadsShapesWithClearanceToPolygon().

46 {
47  wxPoint corners[4];
48  wxPoint PadShapePos = aPad->ShapePos(); /* Note: for pad having a shape offset,
49  * the pad position is NOT the shape position */
50  switch( aPad->GetShape() )
51  {
52  case PAD_SHAPE_CIRCLE:
53  case PAD_SHAPE_OVAL:
55  {
56  // We are using TransformShapeWithClearanceToPolygon to build the shape.
57  // Currently, this method uses only the same inflate value for X and Y dirs.
58  // so because here this is not the case, we use a inflated dummy pad to build
59  // the polygonal shape
60  // TODO: remove this dummy pad when TransformShapeWithClearanceToPolygon will use
61  // a wxSize to inflate the pad size
62  D_PAD dummy( *aPad );
63  wxSize new_size = aPad->GetSize() + aInflateValue + aInflateValue;
64  dummy.SetSize( new_size );
65  dummy.TransformShapeWithClearanceToPolygon( aCornerBuffer, 0,
66  aSegmentsPerCircle, aCorrectionFactor );
67  }
68  break;
69 
71  case PAD_SHAPE_RECT:
72  {
73  SHAPE_LINE_CHAIN aLineChain;
74 
75  aPad->BuildPadPolygon( corners, aInflateValue, aPad->GetOrientation() );
76 
77  for( int ii = 0; ii < 4; ++ii )
78  {
79  corners[3-ii] += PadShapePos; // Shift origin to position
80  aLineChain.Append( corners[3-ii].x, corners[3-ii].y );
81  }
82 
83  aLineChain.SetClosed( true );
84 
85  aCornerBuffer.AddOutline( aLineChain );
86  }
87  break;
88 
89  case PAD_SHAPE_CUSTOM:
90  {
91  SHAPE_POLY_SET polyList; // Will contain the pad outlines in board coordinates
92  polyList.Append( aPad->GetCustomShapeAsPolygon() );
93  aPad->CustomShapeAsPolygonToBoardPosition( &polyList, aPad->ShapePos(), aPad->GetOrientation() );
94  aCornerBuffer.Append( polyList );
95  }
96  break;
97  }
98 }
const SHAPE_POLY_SET & GetCustomShapeAsPolygon() const
Accessor to the custom shape as one polygon.
Definition: class_pad.h:341
void BuildPadPolygon(wxPoint aCoord[4], wxSize aInflateValue, double aRotation) const
Function BuildPadPolygon Has meaning only for polygonal pads (trapezoid and rectangular) Build the Co...
PAD_SHAPE_T GetShape() const
Function GetShape.
Definition: class_pad.h:216
void Append(int aX, int aY, bool aAllowDuplication=false)
Function Append()
void SetClosed(bool aClosed)
Function SetClosed()
void CustomShapeAsPolygonToBoardPosition(SHAPE_POLY_SET *aMergedPolygon, wxPoint aPosition, double aRotation) const
When created, the corners coordinates are relative to the pad position, orientation 0...
Class SHAPE_POLY_SET.
const wxSize & GetSize() const
Definition: class_pad.h:269
int AddOutline(const SHAPE_LINE_CHAIN &aOutline)
Adds a new outline to the set and returns its index
static LIB_PART * dummy()
Used when a LIB_PART is not found in library to draw a dummy shape This component is a 400 mils squar...
Class SHAPE_LINE_CHAIN.
double GetOrientation() const
Function GetOrientation returns the rotation angle of the pad in tenths of degrees, but soon degrees.
Definition: class_pad.h:382
wxPoint ShapePos() const
Definition: class_pad.cpp:517
int Append(int x, int y, int aOutline=-1, int aHole=-1, bool aAllowDuplication=false)
Appends a vertex at the end of the given outline/hole (default: the last outline) ...
void CINFO3D_VISU::buildPadShapeThickOutlineAsPolygon ( const D_PAD aPad,
SHAPE_POLY_SET aCornerBuffer,
int  aWidth 
) const
private

Definition at line 101 of file create_layer_poly.cpp.

References buildPadShapePolygon(), SHAPE_POLY_SET::COutline(), SHAPE_LINE_CHAIN::CPoint(), GetCircleCorrectionFactor(), GetNrSegmentsCircle(), D_PAD::GetShape(), D_PAD::GetSize(), min, PAD_SHAPE_CIRCLE, SHAPE_LINE_CHAIN::PointCount(), D_PAD::ShapePos(), TransformRingToPolygon(), TransformRoundedEndsSegmentToPolygon(), VECTOR2< T >::x, and VECTOR2< T >::y.

Referenced by createLayers(), and GetPolyMapHoles_Outer().

104 {
105  if( aPad->GetShape() == PAD_SHAPE_CIRCLE ) // Draw a ring
106  {
107  unsigned int nr_sides_per_circle = GetNrSegmentsCircle( ( aPad->GetSize().x / 2 +
108  aWidth / 2 ) * 2 );
109 
110  TransformRingToPolygon( aCornerBuffer, aPad->ShapePos(),
111  aPad->GetSize().x / 2, nr_sides_per_circle, aWidth );
112  return;
113  }
114 
115 
116  // For other shapes, draw polygon outlines
117  SHAPE_POLY_SET corners;
118 
119  unsigned int nr_sides_per_circle = GetNrSegmentsCircle( glm::min( aPad->GetSize().x,
120  aPad->GetSize().y) );
121  buildPadShapePolygon( aPad, corners, wxSize( 0, 0 ),
122  nr_sides_per_circle,
123  GetCircleCorrectionFactor( nr_sides_per_circle ) );
124 
125  // Add outlines as thick segments in polygon buffer
126 
127  const SHAPE_LINE_CHAIN& path = corners.COutline( 0 );
128 
129  for( int ii = 0; ii < path.PointCount(); ++ii )
130  {
131  const VECTOR2I& a = path.CPoint( ii );
132  const VECTOR2I& b = path.CPoint( ii + 1 );
133 
135  wxPoint( a.x, a.y ),
136  wxPoint( b.x, b.y ),
137  nr_sides_per_circle,
138  aWidth );
139  }
140 }
void TransformRoundedEndsSegmentToPolygon(SHAPE_POLY_SET &aCornerBuffer, wxPoint aStart, wxPoint aEnd, int aCircleToSegmentsCount, int aWidth)
Function TransformRoundedEndsSegmentToPolygon convert a segment with rounded ends to a polygon Conver...
int PointCount() const
Function PointCount()
PAD_SHAPE_T GetShape() const
Function GetShape.
Definition: class_pad.h:216
Class SHAPE_POLY_SET.
const wxSize & GetSize() const
Definition: class_pad.h:269
const SHAPE_LINE_CHAIN & COutline(int aIndex) const
unsigned int GetNrSegmentsCircle(float aDiameter3DU) const
GetNrSegmentsCircle.
void TransformRingToPolygon(SHAPE_POLY_SET &aCornerBuffer, wxPoint aCentre, int aRadius, int aCircleToSegmentsCount, int aWidth)
Function TransformRingToPolygon Creates a polygon from a ring Convert arcs to multiple straight segme...
double GetCircleCorrectionFactor(int aNrSides) const
GetCircleCorrectionFactor - computes a angle correction factor used when creating circles...
Class SHAPE_LINE_CHAIN.
wxPoint ShapePos() const
Definition: class_pad.cpp:517
void buildPadShapePolygon(const D_PAD *aPad, SHAPE_POLY_SET &aCornerBuffer, wxSize aInflateValue, int aSegmentsPerCircle, double aCorrectionFactor) const
const VECTOR2I & CPoint(int aIndex) const
Function CPoint()
#define min(a, b)
Definition: auxiliary.h:85
void CINFO3D_VISU::buildPadShapeThickOutlineAsSegments ( const D_PAD aPad,
CGENERICCONTAINER2D aDstContainer,
int  aWidth 
)
private

Definition at line 926 of file create_3Dgraphic_brd_items.cpp.

References CGENERICCONTAINER2D::Add(), D_PAD::BuildPadShapePolygon(), SHAPE_POLY_SET::COutline(), SHAPE_LINE_CHAIN::CPoint(), GetCircleCorrectionFactor(), GetNrSegmentsCircle(), D_PAD::GetShape(), D_PAD::GetSize(), Is_segment_a_circle(), m_biuTo3Dunits, min, PAD_SHAPE_CIRCLE, SHAPE_LINE_CHAIN::PointCount(), D_PAD::ShapePos(), wxPoint::x, VECTOR2< T >::x, wxPoint::y, and VECTOR2< T >::y.

Referenced by createLayers(), and GetPolyMapHoles_Outer().

929 {
930  if( aPad->GetShape() == PAD_SHAPE_CIRCLE ) // Draw a ring
931  {
932  const SFVEC2F center3DU( aPad->ShapePos().x * m_biuTo3Dunits,
933  -aPad->ShapePos().y * m_biuTo3Dunits );
934 
935  const int radius = aPad->GetSize().x / 2;
936  const float inner_radius = (radius - aWidth / 2) * m_biuTo3Dunits;
937  const float outter_radius = (radius + aWidth / 2) * m_biuTo3Dunits;
938 
939  aDstContainer->Add( new CRING2D( center3DU,
940  inner_radius,
941  outter_radius,
942  *aPad ) );
943 
944  return;
945  }
946 
947  // For other shapes, draw polygon outlines
948  SHAPE_POLY_SET corners;
949 
950  const int segcountforcircle = GetNrSegmentsCircle( glm::min( aPad->GetSize().x,
951  aPad->GetSize().y) );
952 
953  const double correctionFactor = GetCircleCorrectionFactor( segcountforcircle );
954 
955  aPad->BuildPadShapePolygon( corners, wxSize( 0, 0 ),
956  // This two factors are only expected to be used if render an oval
957  segcountforcircle, correctionFactor );
958 
959 
960  // Add outlines as thick segments in polygon buffer
961 
962  const SHAPE_LINE_CHAIN& path = corners.COutline( 0 );
963 
964  for( int j = 0; j < path.PointCount(); j++ )
965  {
966  const VECTOR2I& a = path.CPoint( j );
967  const VECTOR2I& b = path.CPoint( j + 1 );
968 
969  SFVEC2F start3DU( a.x * m_biuTo3Dunits, -a.y * m_biuTo3Dunits );
970  SFVEC2F end3DU ( b.x * m_biuTo3Dunits, -b.y * m_biuTo3Dunits );
971 
972  if( Is_segment_a_circle( start3DU, end3DU ) )
973  {
974  aDstContainer->Add( new CFILLEDCIRCLE2D( start3DU,
975  (aWidth / 2) * m_biuTo3Dunits,
976  *aPad ) );
977  }
978  else
979  {
980  aDstContainer->Add( new CROUNDSEGMENT2D( start3DU, end3DU,
981  aWidth * m_biuTo3Dunits,
982  *aPad ) );
983  }
984  }
985 }
int PointCount() const
Function PointCount()
PAD_SHAPE_T GetShape() const
Function GetShape.
Definition: class_pad.h:216
bool Is_segment_a_circle(const SFVEC2F &aStart, const SFVEC2F &aEnd)
Segment_is_a_circle - check if segment start and end is very close to each other should used to check...
glm::vec2 SFVEC2F
Definition: xv3d_types.h:45
Class SHAPE_POLY_SET.
double m_biuTo3Dunits
Normalization scale to convert board internal units to 3D units to normalize 3D units between -1...
Definition: cinfo3d_visu.h:616
const wxSize & GetSize() const
Definition: class_pad.h:269
const SHAPE_LINE_CHAIN & COutline(int aIndex) const
unsigned int GetNrSegmentsCircle(float aDiameter3DU) const
GetNrSegmentsCircle.
void Add(COBJECT2D *aObject)
Definition: ccontainer2d.h:52
double GetCircleCorrectionFactor(int aNrSides) const
GetCircleCorrectionFactor - computes a angle correction factor used when creating circles...
Class SHAPE_LINE_CHAIN.
void BuildPadShapePolygon(SHAPE_POLY_SET &aCornerBuffer, wxSize aInflateValue, int aSegmentsPerCircle, double aCorrectionFactor) const
Function BuildPadShapePolygon Build the Corner list of the polygonal shape, depending on shape...
wxPoint ShapePos() const
Definition: class_pad.cpp:517
const VECTOR2I & CPoint(int aIndex) const
Function CPoint()
#define min(a, b)
Definition: auxiliary.h:85
void CINFO3D_VISU::CameraSetType ( CAMERA_TYPE  aCameraType)

CameraSetType - Set the camera type to use.

Parameters
aCameraTypecamera type to use in this canvas

Definition at line 492 of file cinfo3d_visu.cpp.

References CAMERA_TRACKBALL, m_currentCamera, and m_trackBallCamera.

Referenced by GetBoardCenter3DU().

493 {
494  switch( aCameraType )
495  {
496  case CAMERA_TRACKBALL:
498  break;
499 
500  default:
501  wxLogMessage( wxT( "CINFO3D_VISU::CameraSetType() error: unknown camera type %d" ),
502  (int)aCameraType );
503  break;
504  }
505 }
CCAMERA & m_currentCamera
Holds a pointer to current camera in use.
Definition: cinfo3d_visu.h:637
CTRACK_BALL m_trackBallCamera
Definition: cinfo3d_visu.h:638
void CINFO3D_VISU::createBoardPolygon ( )
private

Definition at line 453 of file cinfo3d_visu.cpp.

References BOARD::GetBoardPolygonOutlines(), m_biuTo3Dunits, m_board, m_board2dBBox3DU, m_board_poly, SHAPE_POLY_SET::PM_STRICTLY_SIMPLE, Polygon_Calc_BBox_3DU(), SHAPE_POLY_SET::RemoveAllContours(), and SHAPE_POLY_SET::Simplify().

Referenced by GetPolyMapHoles_Outer(), and InitSettings().

454 {
456 
457  wxString errmsg;
458 
459  if( !m_board->GetBoardPolygonOutlines( m_board_poly, /*allLayerHoles,*/ &errmsg ) )
460  {
461  errmsg.append( wxT( "\n\n" ) );
462  errmsg.append( _( "Cannot determine the board outline." ) );
463  wxLogMessage( errmsg );
464  }
465 
466  // Be sure the polygon is strictly simple to avoid issues.
468 
470 }
void Polygon_Calc_BBox_3DU(const SHAPE_POLY_SET &aPolysList, CBBOX2D &aOutBBox, float aBiuTo3DunitsScale)
Definition: cpolygon2d.cpp:714
bool GetBoardPolygonOutlines(SHAPE_POLY_SET &aOutlines, wxString *aErrorText=NULL)
Function GetBoardPolygonOutlines Extracts the board outlines and build a closed polygon from lines...
CBBOX2D m_board2dBBox3DU
2d bouding box of the pcb board in 3d units
Definition: cinfo3d_visu.h:554
BOARD * m_board
Current board.
Definition: cinfo3d_visu.h:515
double m_biuTo3Dunits
Normalization scale to convert board internal units to 3D units to normalize 3D units between -1...
Definition: cinfo3d_visu.h:616
void Simplify(POLYGON_MODE aFastMode)
Simplifies the polyset (merges overlapping polys, eliminates degeneracy/self-intersections) For aFast...
SHAPE_POLY_SET m_board_poly
PCB board outline polygon.
Definition: cinfo3d_visu.h:581
void RemoveAllContours()
Removes all outlines & holes (clears) the polygon set.
void CINFO3D_VISU::createLayers ( REPORTER aStatusTextReporter)
private

Definition at line 141 of file create_layer_items.cpp.

References CGENERICCONTAINER2D::Add(), AddGraphicsShapesWithClearanceToContainer(), AddPadsShapesWithClearanceToContainer(), AddShapeWithClearanceToContainer(), AddSolidAreasShapesToContainer(), LSET::AllCuMask(), LSET::AllNonCuMask(), B_Adhes, B_Cu, B_Mask, B_Paste, B_SilkS, BiuTo3Dunits(), CBVHCONTAINER2D::BuildBVH(), D_PAD::BuildPadDrillShapePolygon(), buildPadShapeThickOutlineAsPolygon(), buildPadShapeThickOutlineAsSegments(), Cmts_User, createNewPadDrill(), createNewTrack(), cu, destroyLayers(), DIM, BOARD::Drawings(), Dwgs_User, Eco1_User, Eco2_User, Edge_Cuts, F_Adhes, F_Mask, F_Paste, F_SilkS, FL_RENDER_OPENGL_COPPER_THICKNESS, FL_ZONE, g_DrawDefaultLineThickness, BOARD::GetArea(), BOARD::GetAreaCount(), D_PAD::GetAttribute(), GetCircleCorrectionFactor(), GetCopperThickness3DU(), GetCopperThicknessBIU(), DHEAD::GetCount(), D_PAD::GetDrillSize(), VIA::GetDrillValue(), GetFlag(), ZONE_CONTAINER::GetLayer(), GetNrSegmentsCircle(), GetRunningMicroSecs(), TRACK::GetStart(), VIA::GetViaType(), TRACK::GetWidth(), i, Is3DLayerEnabled(), BOARD_ITEM::IsOnLayer(), ZONE_CONTAINER::IsOnLayer(), D_PAD::IsOnLayer(), m_biuTo3Dunits, m_board, m_calc_seg_max_factor3DU, m_calc_seg_min_factor3DU, m_copperLayersCount, m_layers_container2D, m_layers_holes2D, m_layers_inner_holes_poly, m_layers_outer_holes_poly, m_layers_poly, m_logTrace, BOARD::m_Modules, m_render_engine, m_stats_hole_med_diameter, m_stats_nr_holes, m_stats_nr_tracks, m_stats_nr_vias, m_stats_track_med_width, m_stats_via_med_hole_diameter, m_through_holes_inner, m_through_holes_outer, m_through_holes_vias_outer, m_through_inner_holes_poly, m_through_outer_holes_poly, m_through_outer_holes_poly_NPTH, m_through_outer_holes_vias_poly, BOARD::m_Track, Margin, MAX_CU_LAYERS, min, TRACK::Next(), MODULE::Next(), D_PAD::Next(), PAD_ATTRIB_HOLE_NOT_PLATED, PCB_DIMENSION_T, PCB_LINE_T, PCB_TEXT_T, PCB_VIA_T, SHAPE_POLY_SET::PM_FAST, RENDER_ENGINE_OPENGL_LEGACY, REPORTER::Report(), LSET::Seq(), SHAPE_POLY_SET::Simplify(), ToLAYER_ID(), TransformCircleToPolygon(), transformGraphicModuleEdgeToPolygonSet(), transformPadsShapesWithClearanceToPolygon(), TRACK::TransformShapeWithClearanceToPolygon(), ZONE_CONTAINER::TransformSolidAreasShapesToPolygonSet(), EDA_ITEM::Type(), VIA_THROUGH, wxPoint::x, and wxPoint::y.

Referenced by GetPolyMapHoles_Outer(), and InitSettings().

142 {
143  // Number of segments to draw a circle using segments (used on countour zones
144  // and text copper elements )
145  const int segcountforcircle = 12;
146  const double correctionFactor = GetCircleCorrectionFactor( segcountforcircle );
147 
148  // segments to draw a circle to build texts. Is is used only to build
149  // the shape of each segment of the stroke font, therefore no need to have
150  // many segments per circle.
151  const int segcountInStrokeFont = 12;
152  const double correctionFactorStroke = GetCircleCorrectionFactor( segcountInStrokeFont );
153 
154  destroyLayers();
155 
156  // Build Copper layers
157  // Based on: https://github.com/KiCad/kicad-source-mirror/blob/master/3d-viewer/3d_draw.cpp#L692
158  // /////////////////////////////////////////////////////////////////////////
159 
160  #ifdef PRINT_STATISTICS_3D_VIEWER
161  unsigned stats_startCopperLayersTime = GetRunningMicroSecs();
162 
163  unsigned start_Time = stats_startCopperLayersTime;
164 #endif
165 
166  PCB_LAYER_ID cu_seq[MAX_CU_LAYERS];
168 
169  m_stats_nr_tracks = 0;
171  m_stats_nr_vias = 0;
173  m_stats_nr_holes = 0;
175 
176  // Prepare track list, convert in a vector. Calc statistic for the holes
177  // /////////////////////////////////////////////////////////////////////////
178  std::vector< const TRACK *> trackList;
179  trackList.clear();
180  trackList.reserve( m_board->m_Track.GetCount() );
181 
182  for( const TRACK* track = m_board->m_Track; track; track = track->Next() )
183  {
184  if( !Is3DLayerEnabled( track->GetLayer() ) ) // Skip non enabled layers
185  continue;
186 
187  // Note: a TRACK holds normal segment tracks and
188  // also vias circles (that have also drill values)
189  trackList.push_back( track );
190 
191  if( track->Type() == PCB_VIA_T )
192  {
193  const VIA *via = static_cast< const VIA*>( track );
194  m_stats_nr_vias++;
196  }
197  else
198  {
200  }
201 
202  m_stats_track_med_width += track->GetWidth() * m_biuTo3Dunits;
203  }
204 
205  if( m_stats_nr_tracks )
207 
208  if( m_stats_nr_vias )
210 
211 #ifdef PRINT_STATISTICS_3D_VIEWER
212  printf( "T01: %.3f ms\n", (float)( GetRunningMicroSecs() - start_Time ) / 1e3 );
213  start_Time = GetRunningMicroSecs();
214 #endif
215 
216  // Prepare copper layers index and containers
217  // /////////////////////////////////////////////////////////////////////////
218  std::vector< PCB_LAYER_ID > layer_id;
219  layer_id.clear();
220  layer_id.reserve( m_copperLayersCount );
221 
222  for( unsigned i = 0; i < DIM( cu_seq ); ++i )
223  cu_seq[i] = ToLAYER_ID( B_Cu - i );
224 
225  for( LSEQ cu = cu_set.Seq( cu_seq, DIM( cu_seq ) ); cu; ++cu )
226  {
227  const PCB_LAYER_ID curr_layer_id = *cu;
228 
229  if( !Is3DLayerEnabled( curr_layer_id ) ) // Skip non enabled layers
230  continue;
231 
232  layer_id.push_back( curr_layer_id );
233 
234  CBVHCONTAINER2D *layerContainer = new CBVHCONTAINER2D;
235  m_layers_container2D[curr_layer_id] = layerContainer;
236 
239  {
240  SHAPE_POLY_SET *layerPoly = new SHAPE_POLY_SET;
241  m_layers_poly[curr_layer_id] = layerPoly;
242  }
243  }
244 
245 #ifdef PRINT_STATISTICS_3D_VIEWER
246  printf( "T02: %.3f ms\n", (float)( GetRunningMicroSecs() - start_Time ) / 1e3 );
247  start_Time = GetRunningMicroSecs();
248 #endif
249 
250  if( aStatusTextReporter )
251  aStatusTextReporter->Report( _( "Create tracks and vias" ) );
252 
253  // Create tracks as objects and add it to container
254  // /////////////////////////////////////////////////////////////////////////
255  for( unsigned int lIdx = 0; lIdx < layer_id.size(); ++lIdx )
256  {
257  const PCB_LAYER_ID curr_layer_id = layer_id[lIdx];
258 
259  wxASSERT( m_layers_container2D.find( curr_layer_id ) != m_layers_container2D.end() );
260 
261  CBVHCONTAINER2D *layerContainer = m_layers_container2D[curr_layer_id];
262 
263  // ADD TRACKS
264  unsigned int nTracks = trackList.size();
265 
266  for( unsigned int trackIdx = 0; trackIdx < nTracks; ++trackIdx )
267  {
268  const TRACK *track = trackList[trackIdx];
269 
270  // NOTE: Vias can be on multiple layers
271  if( !track->IsOnLayer( curr_layer_id ) )
272  continue;
273 
274  // Add object item to layer container
275  layerContainer->Add( createNewTrack( track, 0.0f ) );
276  }
277  }
278 
279 #ifdef PRINT_STATISTICS_3D_VIEWER
280  printf( "T03: %.3f ms\n", (float)( GetRunningMicroSecs() - start_Time ) / 1e3 );
281  start_Time = GetRunningMicroSecs();
282 #endif
283 
284  // Create VIAS and THTs objects and add it to holes containers
285  // /////////////////////////////////////////////////////////////////////////
286  for( unsigned int lIdx = 0; lIdx < layer_id.size(); ++lIdx )
287  {
288  const PCB_LAYER_ID curr_layer_id = layer_id[lIdx];
289 
290  // ADD TRACKS
291  unsigned int nTracks = trackList.size();
292 
293  for( unsigned int trackIdx = 0; trackIdx < nTracks; ++trackIdx )
294  {
295  const TRACK *track = trackList[trackIdx];
296 
297  if( !track->IsOnLayer( curr_layer_id ) )
298  continue;
299 
300  // ADD VIAS and THT
301  if( track->Type() == PCB_VIA_T )
302  {
303  const VIA *via = static_cast< const VIA*>( track );
304  const VIATYPE_T viatype = via->GetViaType();
305  const float holediameter = via->GetDrillValue() * BiuTo3Dunits();
306  const float thickness = GetCopperThickness3DU();
307  const float hole_inner_radius = ( holediameter / 2.0f );
308 
309  const SFVEC2F via_center( via->GetStart().x * m_biuTo3Dunits,
310  -via->GetStart().y * m_biuTo3Dunits );
311 
312  if( viatype != VIA_THROUGH )
313  {
314 
315  // Add hole objects
316  // /////////////////////////////////////////////////////////
317 
318  CBVHCONTAINER2D *layerHoleContainer = NULL;
319 
320  // Check if the layer is already created
321  if( m_layers_holes2D.find( curr_layer_id ) == m_layers_holes2D.end() )
322  {
323  // not found, create a new container
324  layerHoleContainer = new CBVHCONTAINER2D;
325  m_layers_holes2D[curr_layer_id] = layerHoleContainer;
326  }
327  else
328  {
329  // found
330  layerHoleContainer = m_layers_holes2D[curr_layer_id];
331  }
332 
333  // Add a hole for this layer
334  layerHoleContainer->Add( new CFILLEDCIRCLE2D( via_center,
335  hole_inner_radius + thickness,
336  *track ) );
337  }
338  else if( lIdx == 0 ) // it only adds once the THT holes
339  {
340  // Add through hole object
341  // /////////////////////////////////////////////////////////
342  m_through_holes_outer.Add( new CFILLEDCIRCLE2D( via_center,
343  hole_inner_radius + thickness,
344  *track ) );
345 
347  new CFILLEDCIRCLE2D( via_center,
348  hole_inner_radius + thickness,
349  *track ) );
350 
351  m_through_holes_inner.Add( new CFILLEDCIRCLE2D( via_center,
352  hole_inner_radius,
353  *track ) );
354 
355  //m_through_holes_vias_inner.Add( new CFILLEDCIRCLE2D( via_center,
356  // hole_inner_radius,
357  // *track ) );
358  }
359  }
360  }
361  }
362 
363 #ifdef PRINT_STATISTICS_3D_VIEWER
364  printf( "T04: %.3f ms\n", (float)( GetRunningMicroSecs() - start_Time ) / 1e3 );
365  start_Time = GetRunningMicroSecs();
366 #endif
367 
368  // Create VIAS and THTs objects and add it to holes containers
369  // /////////////////////////////////////////////////////////////////////////
370  for( unsigned int lIdx = 0; lIdx < layer_id.size(); ++lIdx )
371  {
372  const PCB_LAYER_ID curr_layer_id = layer_id[lIdx];
373 
374  // ADD TRACKS
375  const unsigned int nTracks = trackList.size();
376 
377  for( unsigned int trackIdx = 0; trackIdx < nTracks; ++trackIdx )
378  {
379  const TRACK *track = trackList[trackIdx];
380 
381  if( !track->IsOnLayer( curr_layer_id ) )
382  continue;
383 
384  // ADD VIAS and THT
385  if( track->Type() == PCB_VIA_T )
386  {
387  const VIA *via = static_cast< const VIA*>( track );
388  const VIATYPE_T viatype = via->GetViaType();
389 
390  if( viatype != VIA_THROUGH )
391  {
392 
393  // Add VIA hole contourns
394  // /////////////////////////////////////////////////////////
395 
396  // Add outter holes of VIAs
397  SHAPE_POLY_SET *layerOuterHolesPoly = NULL;
398  SHAPE_POLY_SET *layerInnerHolesPoly = NULL;
399 
400  // Check if the layer is already created
401  if( m_layers_outer_holes_poly.find( curr_layer_id ) ==
403  {
404  // not found, create a new container
405  layerOuterHolesPoly = new SHAPE_POLY_SET;
406  m_layers_outer_holes_poly[curr_layer_id] = layerOuterHolesPoly;
407 
408  wxASSERT( m_layers_inner_holes_poly.find( curr_layer_id ) ==
410 
411  layerInnerHolesPoly = new SHAPE_POLY_SET;
412  m_layers_inner_holes_poly[curr_layer_id] = layerInnerHolesPoly;
413  }
414  else
415  {
416  // found
417  layerOuterHolesPoly = m_layers_outer_holes_poly[curr_layer_id];
418 
419  wxASSERT( m_layers_inner_holes_poly.find( curr_layer_id ) !=
421 
422  layerInnerHolesPoly = m_layers_inner_holes_poly[curr_layer_id];
423  }
424 
425  const int holediameter = via->GetDrillValue();
426  const int hole_outer_radius = (holediameter / 2) + GetCopperThicknessBIU();
427 
428  TransformCircleToPolygon( *layerOuterHolesPoly,
429  via->GetStart(),
430  hole_outer_radius,
431  GetNrSegmentsCircle( hole_outer_radius * 2 ) );
432 
433  TransformCircleToPolygon( *layerInnerHolesPoly,
434  via->GetStart(),
435  holediameter / 2,
436  GetNrSegmentsCircle( holediameter ) );
437  }
438  else if( lIdx == 0 ) // it only adds once the THT holes
439  {
440  const int holediameter = via->GetDrillValue();
441  const int hole_outer_radius = (holediameter / 2)+ GetCopperThicknessBIU();
442 
443  // Add through hole contourns
444  // /////////////////////////////////////////////////////////
446  via->GetStart(),
447  hole_outer_radius,
448  GetNrSegmentsCircle( hole_outer_radius * 2 ) );
449 
451  via->GetStart(),
452  holediameter / 2,
453  GetNrSegmentsCircle( holediameter ) );
454 
455  // Add samething for vias only
456 
458  via->GetStart(),
459  hole_outer_radius,
460  GetNrSegmentsCircle( hole_outer_radius * 2 ) );
461 
462  //TransformCircleToPolygon( m_through_inner_holes_vias_poly,
463  // via->GetStart(),
464  // holediameter / 2,
465  // GetNrSegmentsCircle( holediameter ) );
466  }
467  }
468  }
469  }
470 
471 #ifdef PRINT_STATISTICS_3D_VIEWER
472  printf( "T05: %.3f ms\n", (float)( GetRunningMicroSecs() - start_Time ) / 1e3 );
473  start_Time = GetRunningMicroSecs();
474 #endif
475 
476  // Creates outline contours of the tracks and add it to the poly of the layer
477  // /////////////////////////////////////////////////////////////////////////
480  {
481  for( unsigned int lIdx = 0; lIdx < layer_id.size(); ++lIdx )
482  {
483  const PCB_LAYER_ID curr_layer_id = layer_id[lIdx];
484 
485  wxASSERT( m_layers_poly.find( curr_layer_id ) != m_layers_poly.end() );
486 
487  SHAPE_POLY_SET *layerPoly = m_layers_poly[curr_layer_id];
488 
489  // ADD TRACKS
490  unsigned int nTracks = trackList.size();
491 
492  for( unsigned int trackIdx = 0; trackIdx < nTracks; ++trackIdx )
493  {
494  const TRACK *track = trackList[trackIdx];
495 
496  if( !track->IsOnLayer( curr_layer_id ) )
497  continue;
498 
499  // Add the track contour
500  int nrSegments = GetNrSegmentsCircle( track->GetWidth() );
501 
503  *layerPoly,
504  0,
505  nrSegments,
506  GetCircleCorrectionFactor( nrSegments ) );
507  }
508  }
509  }
510 
511 #ifdef PRINT_STATISTICS_3D_VIEWER
512  printf( "T06: %.3f ms\n", (float)( GetRunningMicroSecs() - start_Time ) / 1e3 );
513  start_Time = GetRunningMicroSecs();
514 #endif
515 
516  // Add holes of modules
517  // /////////////////////////////////////////////////////////////////////////
518  for( const MODULE* module = m_board->m_Modules; module; module = module->Next() )
519  {
520  const D_PAD* pad = module->PadsList();
521 
522  for( ; pad; pad = pad->Next() )
523  {
524  const wxSize padHole = pad->GetDrillSize();
525 
526  if( !padHole.x ) // Not drilled pad like SMD pad
527  continue;
528 
529  // The hole in the body is inflated by copper thickness,
530  // if not plated, no copper
531  const int inflate = (pad->GetAttribute () != PAD_ATTRIB_HOLE_NOT_PLATED) ?
532  GetCopperThicknessBIU() : 0;
533 
535  m_stats_hole_med_diameter += ( ( pad->GetDrillSize().x +
536  pad->GetDrillSize().y ) / 2.0f ) * m_biuTo3Dunits;
537 
538  m_through_holes_outer.Add( createNewPadDrill( pad, inflate ) );
540  }
541  }
542  if( m_stats_nr_holes )
544 
545 #ifdef PRINT_STATISTICS_3D_VIEWER
546  printf( "T07: %.3f ms\n", (float)( GetRunningMicroSecs() - start_Time ) / 1e3 );
547  start_Time = GetRunningMicroSecs();
548 #endif
549 
550  // Add contours of the pad holes (pads can be Circle or Segment holes)
551  // /////////////////////////////////////////////////////////////////////////
552  for( const MODULE* module = m_board->m_Modules; module; module = module->Next() )
553  {
554  const D_PAD* pad = module->PadsList();
555 
556  for( ; pad; pad = pad->Next() )
557  {
558  const wxSize padHole = pad->GetDrillSize();
559 
560  if( !padHole.x ) // Not drilled pad like SMD pad
561  continue;
562 
563  // The hole in the body is inflated by copper thickness.
564  const int inflate = GetCopperThicknessBIU();
565 
566  // we use the hole diameter to calculate the seg count.
567  // for round holes, padHole.x == padHole.y
568  // for oblong holes, the diameter is the smaller of (padHole.x, padHole.y)
569  const int diam = std::min( padHole.x, padHole.y );
570 
571 
573  {
575  inflate,
576  GetNrSegmentsCircle( diam ) );
577 
579  0,
580  GetNrSegmentsCircle( diam ) );
581  }
582  else
583  {
584  // If not plated, no copper.
586  inflate,
587  GetNrSegmentsCircle( diam ) );
588  }
589  }
590  }
591 
592 #ifdef PRINT_STATISTICS_3D_VIEWER
593  printf( "T08: %.3f ms\n", (float)( GetRunningMicroSecs() - start_Time ) / 1e3 );
594  start_Time = GetRunningMicroSecs();
595 #endif
596 
597  // Add modules PADs objects to containers
598  // /////////////////////////////////////////////////////////////////////////
599  for( unsigned int lIdx = 0; lIdx < layer_id.size(); ++lIdx )
600  {
601  const PCB_LAYER_ID curr_layer_id = layer_id[lIdx];
602 
603  wxASSERT( m_layers_container2D.find( curr_layer_id ) != m_layers_container2D.end() );
604 
605  CBVHCONTAINER2D *layerContainer = m_layers_container2D[curr_layer_id];
606 
607  // ADD PADS
608  for( const MODULE* module = m_board->m_Modules; module; module = module->Next() )
609  {
610  // Note: NPTH pads are not drawn on copper layers when the pad
611  // has same shape as its hole
613  layerContainer,
614  curr_layer_id,
615  0,
616  true );
617 
618  // Micro-wave modules may have items on copper layers
620  layerContainer,
621  curr_layer_id,
622  0 );
623  }
624  }
625 
626 #ifdef PRINT_STATISTICS_3D_VIEWER
627  printf( "T09: %.3f ms\n", (float)( GetRunningMicroSecs() - start_Time ) / 1e3 );
628  start_Time = GetRunningMicroSecs();
629 #endif
630 
631  // Add modules PADs poly contourns
632  // /////////////////////////////////////////////////////////////////////////
635  {
636  for( unsigned int lIdx = 0; lIdx < layer_id.size(); ++lIdx )
637  {
638  const PCB_LAYER_ID curr_layer_id = layer_id[lIdx];
639 
640  wxASSERT( m_layers_poly.find( curr_layer_id ) != m_layers_poly.end() );
641 
642  SHAPE_POLY_SET *layerPoly = m_layers_poly[curr_layer_id];
643 
644  // ADD PADS
645  for( const MODULE* module = m_board->m_Modules; module; module = module->Next() )
646  {
647  // Construct polys
648  // /////////////////////////////////////////////////////////////
649 
650  // Note: NPTH pads are not drawn on copper layers when the pad
651  // has same shape as its hole
652  transformPadsShapesWithClearanceToPolygon( module->PadsList(),
653  curr_layer_id,
654  *layerPoly,
655  0,
656  true );
657 
658  // Micro-wave modules may have items on copper layers
659  module->TransformGraphicTextWithClearanceToPolygonSet( curr_layer_id,
660  *layerPoly,
661  0,
662  segcountforcircle,
663  correctionFactor );
664 
665  transformGraphicModuleEdgeToPolygonSet( module, curr_layer_id, *layerPoly );
666  }
667  }
668  }
669 
670 #ifdef PRINT_STATISTICS_3D_VIEWER
671  printf( "T10: %.3f ms\n", (float)( GetRunningMicroSecs() - start_Time ) / 1e3 );
672  start_Time = GetRunningMicroSecs();
673 #endif
674 
675  // Add graphic item on copper layers to object containers
676  // /////////////////////////////////////////////////////////////////////////
677  for( unsigned int lIdx = 0; lIdx < layer_id.size(); ++lIdx )
678  {
679  const PCB_LAYER_ID curr_layer_id = layer_id[lIdx];
680 
681  wxASSERT( m_layers_container2D.find( curr_layer_id ) != m_layers_container2D.end() );
682 
683  CBVHCONTAINER2D *layerContainer = m_layers_container2D[curr_layer_id];
684 
685  // ADD GRAPHIC ITEMS ON COPPER LAYERS (texts)
686  for( auto item : m_board->Drawings() )
687  {
688  if( !item->IsOnLayer( curr_layer_id ) )
689  continue;
690 
691  switch( item->Type() )
692  {
693  case PCB_LINE_T: // should not exist on copper layers
694  {
696  layerContainer,
697  curr_layer_id,
698  0 );
699  }
700  break;
701 
702  case PCB_TEXT_T:
704  layerContainer,
705  curr_layer_id,
706  0 );
707  break;
708 
709  case PCB_DIMENSION_T:
711  layerContainer,
712  curr_layer_id,
713  0 );
714  break;
715 
716  default:
717  wxLogTrace( m_logTrace,
718  wxT( "createLayers: item type: %d not implemented" ),
719  item->Type() );
720  break;
721  }
722  }
723  }
724 
725 #ifdef PRINT_STATISTICS_3D_VIEWER
726  printf( "T11: %.3f ms\n", (float)( GetRunningMicroSecs() - start_Time ) / 1e3 );
727  start_Time = GetRunningMicroSecs();
728 #endif
729 
730  // Add graphic item on copper layers to poly contourns
731  // /////////////////////////////////////////////////////////////////////////
734  {
735  for( unsigned int lIdx = 0; lIdx < layer_id.size(); ++lIdx )
736  {
737  const PCB_LAYER_ID curr_layer_id = layer_id[lIdx];
738 
739  wxASSERT( m_layers_poly.find( curr_layer_id ) != m_layers_poly.end() );
740 
741  SHAPE_POLY_SET *layerPoly = m_layers_poly[curr_layer_id];
742 
743  // ADD GRAPHIC ITEMS ON COPPER LAYERS (texts)
744  for( auto item : m_board->Drawings() )
745  {
746  if( !item->IsOnLayer( curr_layer_id ) )
747  continue;
748 
749  switch( item->Type() )
750  {
751  case PCB_LINE_T:
752  {
753  const int nrSegments =
754  GetNrSegmentsCircle( item->GetBoundingBox().GetSizeMax() );
755 
756  ( (DRAWSEGMENT*) item )->TransformShapeWithClearanceToPolygon(
757  *layerPoly,
758  0,
759  nrSegments,
760  GetCircleCorrectionFactor( nrSegments ) );
761  }
762  break;
763 
764  case PCB_TEXT_T:
765  ( (TEXTE_PCB*) item )->TransformShapeWithClearanceToPolygonSet(
766  *layerPoly,
767  0,
768  segcountforcircle,
769  correctionFactor );
770  break;
771 
772  default:
773  wxLogTrace( m_logTrace,
774  wxT( "createLayers: item type: %d not implemented" ),
775  item->Type() );
776  break;
777  }
778  }
779  }
780  }
781 
782 #ifdef PRINT_STATISTICS_3D_VIEWER
783  printf( "T12: %.3f ms\n", (float)( GetRunningMicroSecs() - start_Time ) / 1e3 );
784  start_Time = GetRunningMicroSecs();
785 #endif
786 
787  if( GetFlag( FL_ZONE ) )
788  {
789  if( aStatusTextReporter )
790  aStatusTextReporter->Report( _( "Create zones" ) );
791 
792  // Add zones objects
793  // /////////////////////////////////////////////////////////////////////
794  std::atomic<size_t> nextZone( 0 );
795  std::atomic<size_t> threadsFinished( 0 );
796 
797  size_t parallelThreadCount = std::max<size_t>( std::thread::hardware_concurrency(), 2 );
798  for( size_t ii = 0; ii < parallelThreadCount; ++ii )
799  {
800  std::thread t = std::thread( [&]()
801  {
802  for( size_t areaId = nextZone.fetch_add( 1 );
803  areaId < static_cast<size_t>( m_board->GetAreaCount() );
804  areaId = nextZone.fetch_add( 1 ) )
805  {
806  const ZONE_CONTAINER* zone = m_board->GetArea( areaId );
807 
808  if( zone == nullptr )
809  break;
810 
811  auto layerContainer = m_layers_container2D.find( zone->GetLayer() );
812 
813  if( layerContainer != m_layers_container2D.end() )
814  AddSolidAreasShapesToContainer( zone, layerContainer->second,
815  zone->GetLayer() );
816  }
817 
818  threadsFinished++;
819  } );
820 
821  t.detach();
822  }
823 
824  while( threadsFinished < parallelThreadCount )
825  std::this_thread::sleep_for( std::chrono::milliseconds( 10 ) );
826 
827  }
828 
829 #ifdef PRINT_STATISTICS_3D_VIEWER
830  printf( "fill zones T13: %.3f ms\n", (float)( GetRunningMicroSecs() - start_Time ) / 1e3 );
831  start_Time = GetRunningMicroSecs();
832 #endif
833 
834  if( GetFlag( FL_ZONE ) &&
837  {
838  // ADD COPPER ZONES
839  for( int ii = 0; ii < m_board->GetAreaCount(); ++ii )
840  {
841  const ZONE_CONTAINER* zone = m_board->GetArea( ii );
842 
843  if( zone == nullptr )
844  break;
845 
846  auto layerContainer = m_layers_poly.find( zone->GetLayer() );
847 
848  if( layerContainer != m_layers_poly.end() )
849  zone->TransformSolidAreasShapesToPolygonSet( *layerContainer->second, segcountforcircle, correctionFactor );
850  }
851  }
852 
853 #ifdef PRINT_STATISTICS_3D_VIEWER
854  printf( "T14: %.3f ms\n", (float)( GetRunningMicroSecs() - start_Time ) / 1e3 );
855  start_Time = GetRunningMicroSecs();
856 #endif
857 
858  // Simplify layer polygons
859  // /////////////////////////////////////////////////////////////////////////
860 
861  if( aStatusTextReporter )
862  aStatusTextReporter->Report( _( "Simplifying copper layers polygons" ) );
863 
866  {
867  std::atomic<size_t> nextItem( 0 );
868  std::atomic<size_t> threadsFinished( 0 );
869 
870  size_t parallelThreadCount = std::min<size_t>(
871  std::max<size_t>( std::thread::hardware_concurrency(), 2 ),
872  layer_id.size() );
873  for( size_t ii = 0; ii < parallelThreadCount; ++ii )
874  {
875  std::thread t = std::thread( [&nextItem, &threadsFinished, &layer_id, this]()
876  {
877  for( size_t i = nextItem.fetch_add( 1 );
878  i < layer_id.size();
879  i = nextItem.fetch_add( 1 ) )
880  {
881  auto layerPoly = m_layers_poly.find( layer_id[i] );
882 
883  if( layerPoly != m_layers_poly.end() )
884  // This will make a union of all added contours
885  layerPoly->second->Simplify( SHAPE_POLY_SET::PM_FAST );
886  }
887 
888  threadsFinished++;
889  } );
890 
891  t.detach();
892  }
893 
894  while( threadsFinished < parallelThreadCount )
895  std::this_thread::sleep_for( std::chrono::milliseconds( 10 ) );
896  }
897 
898 #ifdef PRINT_STATISTICS_3D_VIEWER
899  printf( "T15: %.3f ms\n", (float)( GetRunningMicroSecs() - start_Time ) / 1e3 );
900  start_Time = GetRunningMicroSecs();
901 #endif
902 
903  // Simplify holes polygon contours
904  // /////////////////////////////////////////////////////////////////////////
905  if( aStatusTextReporter )
906  aStatusTextReporter->Report( _( "Simplify holes contours" ) );
907 
908  for( unsigned int lIdx = 0; lIdx < layer_id.size(); ++lIdx )
909  {
910  const PCB_LAYER_ID curr_layer_id = layer_id[lIdx];
911 
912  if( m_layers_outer_holes_poly.find( curr_layer_id ) !=
914  {
915  // found
916  SHAPE_POLY_SET *polyLayer = m_layers_outer_holes_poly[curr_layer_id];
917  polyLayer->Simplify( SHAPE_POLY_SET::PM_FAST );
918 
919  wxASSERT( m_layers_inner_holes_poly.find( curr_layer_id ) !=
921 
922  polyLayer = m_layers_inner_holes_poly[curr_layer_id];
923  polyLayer->Simplify( SHAPE_POLY_SET::PM_FAST );
924  }
925  }
926 
927 #ifdef PRINT_STATISTICS_3D_VIEWER
928  printf( "T16: %.3f ms\n", (float)( GetRunningMicroSecs() - start_Time ) / 1e3 );
929 #endif
930  // End Build Copper layers
931 
932 
933  // This will make a union of all added contourns
938  //m_through_inner_holes_vias_poly.Simplify( SHAPE_POLY_SET::PM_FAST ); // Not in use
939 
940 #ifdef PRINT_STATISTICS_3D_VIEWER
941  unsigned stats_endCopperLayersTime = GetRunningMicroSecs();
942 #endif
943 
944  // Build Tech layers
945  // Based on: https://github.com/KiCad/kicad-source-mirror/blob/master/3d-viewer/3d_draw.cpp#L1059
946  // /////////////////////////////////////////////////////////////////////////
947 #ifdef PRINT_STATISTICS_3D_VIEWER
948  unsigned stats_startTechLayersTime = GetRunningMicroSecs();
949 #endif
950 
951  if( aStatusTextReporter )
952  aStatusTextReporter->Report( _( "Build Tech layers" ) );
953 
954  // draw graphic items, on technical layers
955  static const PCB_LAYER_ID teckLayerList[] = {
956  B_Adhes,
957  F_Adhes,
958  B_Paste,
959  F_Paste,
960  B_SilkS,
961  F_SilkS,
962  B_Mask,
963  F_Mask,
964 
965  // Aux Layers
966  Dwgs_User,
967  Cmts_User,
968  Eco1_User,
969  Eco2_User,
970  Edge_Cuts,
971  Margin
972  };
973 
974  // User layers are not drawn here, only technical layers
975 
976  for( LSEQ seq = LSET::AllNonCuMask().Seq( teckLayerList, DIM( teckLayerList ) );
977  seq;
978  ++seq )
979  {
980  const PCB_LAYER_ID curr_layer_id = *seq;
981 
982  if( !Is3DLayerEnabled( curr_layer_id ) )
983  continue;
984 
985  CBVHCONTAINER2D *layerContainer = new CBVHCONTAINER2D;
986  m_layers_container2D[curr_layer_id] = layerContainer;
987 
988  SHAPE_POLY_SET *layerPoly = new SHAPE_POLY_SET;
989  m_layers_poly[curr_layer_id] = layerPoly;
990 
991  // Add drawing objects
992  // /////////////////////////////////////////////////////////////////////
993  for( auto item : m_board->Drawings() )
994  {
995  if( !item->IsOnLayer( curr_layer_id ) )
996  continue;
997 
998  switch( item->Type() )
999  {
1000  case PCB_LINE_T:
1002  layerContainer,
1003  curr_layer_id,
1004  0 );
1005  break;
1006 
1007  case PCB_TEXT_T:
1009  layerContainer,
1010  curr_layer_id,
1011  0 );
1012  break;
1013 
1014  case PCB_DIMENSION_T:
1016  layerContainer,
1017  curr_layer_id,
1018  0 );
1019  break;
1020 
1021  default:
1022  break;
1023  }
1024  }
1025 
1026 
1027  // Add drawing contours
1028  // /////////////////////////////////////////////////////////////////////
1029  for( auto item : m_board->Drawings() )
1030  {
1031  if( !item->IsOnLayer( curr_layer_id ) )
1032  continue;
1033 
1034  switch( item->Type() )
1035  {
1036  case PCB_LINE_T:
1037  {
1038  const unsigned int nr_segments =
1039  GetNrSegmentsCircle( item->GetBoundingBox().GetSizeMax() );
1040 
1041  ((DRAWSEGMENT*) item)->TransformShapeWithClearanceToPolygon( *layerPoly,
1042  0,
1043  nr_segments,
1044  0.0 );
1045  }
1046  break;
1047 
1048  case PCB_TEXT_T:
1049  ((TEXTE_PCB*) item)->TransformShapeWithClearanceToPolygonSet( *layerPoly,
1050  0,
1051  segcountInStrokeFont,
1052  1.0 );
1053  break;
1054 
1055  default:
1056  break;
1057  }
1058  }
1059 
1060 
1061  // Add modules tech layers - objects
1062  // /////////////////////////////////////////////////////////////////////
1063  for( MODULE* module = m_board->m_Modules; module; module = module->Next() )
1064  {
1065  if( (curr_layer_id == F_SilkS) || (curr_layer_id == B_SilkS) )
1066  {
1067  D_PAD* pad = module->PadsList();
1068  int linewidth = g_DrawDefaultLineThickness;
1069 
1070  for( ; pad; pad = pad->Next() )
1071  {
1072  if( !pad->IsOnLayer( curr_layer_id ) )
1073  continue;
1074 
1076  layerContainer,
1077  linewidth );
1078  }
1079  }
1080  else
1081  {
1083  layerContainer,
1084  curr_layer_id,
1085  0,
1086  false );
1087  }
1088 
1090  layerContainer,
1091  curr_layer_id,
1092  0 );
1093  }
1094 
1095 
1096  // Add modules tech layers - contours
1097  // /////////////////////////////////////////////////////////////////////
1098  for( MODULE* module = m_board->m_Modules; module; module = module->Next() )
1099  {
1100  if( (curr_layer_id == F_SilkS) || (curr_layer_id == B_SilkS) )
1101  {
1102  D_PAD* pad = module->PadsList();
1103  const int linewidth = g_DrawDefaultLineThickness;
1104 
1105  for( ; pad; pad = pad->Next() )
1106  {
1107  if( !pad->IsOnLayer( curr_layer_id ) )
1108  continue;
1109 
1110  buildPadShapeThickOutlineAsPolygon( pad, *layerPoly, linewidth );
1111  }
1112  }
1113  else
1114  {
1115  transformPadsShapesWithClearanceToPolygon( module->PadsList(),
1116  curr_layer_id,
1117  *layerPoly,
1118  0,
1119  false );
1120  }
1121 
1122  // On tech layers, use a poor circle approximation, only for texts (stroke font)
1123  module->TransformGraphicTextWithClearanceToPolygonSet( curr_layer_id,
1124  *layerPoly,
1125  0,
1126  segcountInStrokeFont,
1127  correctionFactorStroke,
1128  segcountInStrokeFont );
1129 
1130  // Add the remaining things with dynamic seg count for circles
1131  transformGraphicModuleEdgeToPolygonSet( module, curr_layer_id, *layerPoly );
1132  }
1133 
1134 
1135  // Draw non copper zones
1136  // /////////////////////////////////////////////////////////////////////
1137  if( GetFlag( FL_ZONE ) )
1138  {
1139  for( int ii = 0; ii < m_board->GetAreaCount(); ++ii )
1140  {
1141  ZONE_CONTAINER* zone = m_board->GetArea( ii );
1142 
1143  if( !zone->IsOnLayer( curr_layer_id ) )
1144  continue;
1145 
1147  layerContainer,
1148  curr_layer_id );
1149  }
1150 
1151  for( int ii = 0; ii < m_board->GetAreaCount(); ++ii )
1152  {
1153  ZONE_CONTAINER* zone = m_board->GetArea( ii );
1154 
1155  if( !zone->IsOnLayer( curr_layer_id ) )
1156  continue;
1157 
1158  zone->TransformSolidAreasShapesToPolygonSet( *layerPoly,
1159  // Use the same segcount as stroke font
1160  segcountInStrokeFont,
1161  correctionFactorStroke );
1162  }
1163  }
1164 
1165  // This will make a union of all added contours
1166  layerPoly->Simplify( SHAPE_POLY_SET::PM_FAST );
1167  }
1168  // End Build Tech layers
1169 
1170 #ifdef PRINT_STATISTICS_3D_VIEWER
1171  unsigned stats_endTechLayersTime = GetRunningMicroSecs();
1172 #endif
1173 
1174 
1175  // Build BVH for holes and vias
1176  // /////////////////////////////////////////////////////////////////////////
1177 
1178 #ifdef PRINT_STATISTICS_3D_VIEWER
1179  unsigned stats_startHolesBVHTime = GetRunningMicroSecs();
1180 #endif
1181  if( aStatusTextReporter )
1182  aStatusTextReporter->Report( _( "Build BVH for holes and vias" ) );
1183 
1186 
1187  if( !m_layers_holes2D.empty() )
1188  {
1189  for( MAP_CONTAINER_2D::iterator ii = m_layers_holes2D.begin();
1190  ii != m_layers_holes2D.end();
1191  ++ii )
1192  {
1193  ((CBVHCONTAINER2D *)(ii->second))->BuildBVH();
1194  }
1195  }
1196 
1197  // We only need the Solder mask to initialize the BVH
1198  // because..?
1200  ((CBVHCONTAINER2D *)m_layers_container2D[B_Mask])->BuildBVH();
1201 
1203  ((CBVHCONTAINER2D *)m_layers_container2D[F_Mask])->BuildBVH();
1204 
1205 #ifdef PRINT_STATISTICS_3D_VIEWER
1206  unsigned stats_endHolesBVHTime = GetRunningMicroSecs();
1207 
1208  printf( "CINFO3D_VISU::createLayers times\n" );
1209  printf( " Copper Layers: %.3f ms\n",
1210  (float)( stats_endCopperLayersTime - stats_startCopperLayersTime ) / 1e3 );
1211  printf( " Holes BVH creation: %.3f ms\n",
1212  (float)( stats_endHolesBVHTime - stats_startHolesBVHTime ) / 1e3 );
1213  printf( " Tech Layers: %.3f ms\n",
1214  (float)( stats_endTechLayersTime - stats_startTechLayersTime ) / 1e3 );
1215  printf( "Statistics:\n" );
1216  printf( " m_stats_nr_tracks %u\n", m_stats_nr_tracks );
1217  printf( " m_stats_nr_vias %u\n", m_stats_nr_vias );
1218  printf( " m_stats_nr_holes %u\n", m_stats_nr_holes );
1219  printf( " m_stats_via_med_hole_diameter (3DU) %f\n", m_stats_via_med_hole_diameter );
1220  printf( " m_stats_hole_med_diameter (3DU) %f\n", m_stats_hole_med_diameter );
1221  printf( " m_calc_seg_min_factor3DU (3DU) %f\n", m_calc_seg_min_factor3DU );
1222  printf( " m_calc_seg_max_factor3DU (3DU) %f\n", m_calc_seg_max_factor3DU );
1223 #endif
1224 }
static LSET AllCuMask(int aCuLayerCount=MAX_CU_LAYERS)
Function AllCuMask returns a mask holding the requested number of Cu PCB_LAYER_IDs.
Definition: lset.cpp:673
void AddShapeWithClearanceToContainer(const TEXTE_PCB *aTextPCB, CGENERICCONTAINER2D *aDstContainer, PCB_LAYER_ID aLayerId, int aClearanceValue)
KICAD_T Type() const
Function Type()
Definition: base_struct.h:201
#define DIM(x)
of elements in an array
Definition: macros.h:98
Class ZONE_CONTAINER handles a list of polygons defining a copper zone.
Definition: class_zone.h:60
COBJECT2D * createNewTrack(const TRACK *aTrack, int aClearanceValue) const
PAD_ATTR_T GetAttribute() const
Definition: class_pad.h:405
float GetCopperThickness3DU() const
GetCopperThickness3DU - Get the current copper layer thickness.
Definition: cinfo3d_visu.h:165
like PAD_STANDARD, but not plated mechanical use only, no connection allowed
Definition: pad_shapes.h:65
CBVHCONTAINER2D m_through_holes_vias_outer
It contains the list of throughHoles vias of the board, the radius of the hole is inflated with the c...
Definition: cinfo3d_visu.h:602
void TransformShapeWithClearanceToPolygon(SHAPE_POLY_SET &aCornerBuffer, int aClearanceValue, int aCircleToSegmentsCount, double aCorrectionFactor, bool ignoreLineWidth=false) const override
Function TransformShapeWithClearanceToPolygon Convert the track shape to a closed polygon Used in fil...
virtual bool IsOnLayer(PCB_LAYER_ID aLayer) const
Function IsOnLayer tests to see if this object is on the given layer.
void TransformCircleToPolygon(SHAPE_POLY_SET &aCornerBuffer, wxPoint aCenter, int aRadius, int aCircleToSegmentsCount)
Function TransformCircleToPolygon convert a circle to a polygon, using multiple straight lines...
virtual bool IsOnLayer(PCB_LAYER_ID) const override
Function IsOnLayer tests to see if this object is on the given layer.
Definition: class_zone.cpp:265
float m_calc_seg_min_factor3DU
min factor used for cicle segment approximation calculation
Definition: cinfo3d_visu.h:641
SHAPE_POLY_SET m_through_inner_holes_poly
It contains polygon contours for through holes (inner cylinder)
Definition: cinfo3d_visu.h:572
static LSET AllNonCuMask()
Function AllNonCuMask returns a mask holding all layer minus CU layers.
Definition: lset.cpp:696
MODULE * Next() const
Definition: class_module.h:123
MAP_POLY m_layers_inner_holes_poly
It contains polygon contours for holes of each layer (inner holes)
Definition: cinfo3d_visu.h:563
virtual PCB_LAYER_ID GetLayer() const override
Function GetLayer returns the primary layer this item is on.
Definition: class_zone.cpp:175
class TEXTE_PCB, text on a layer
Definition: typeinfo.h:92
float m_calc_seg_max_factor3DU
max factor used for cicle segment approximation calculation
Definition: cinfo3d_visu.h:644
int GetCopperThicknessBIU() const
GetCopperThicknessBIU - Get the current copper layer thickness.
BOARD * m_board
Current board.
Definition: cinfo3d_visu.h:515
unsigned int m_stats_nr_holes
number of holes in the board
Definition: cinfo3d_visu.h:662
const wxSize & GetDrillSize() const
Definition: class_pad.h:275
VIATYPE_T
Definition: class_track.h:50
CBVHCONTAINER2D m_through_holes_inner
It contains the list of throughHoles of the board, the radius is the inner hole.
Definition: cinfo3d_visu.h:598
float m_stats_via_med_hole_diameter
Computed medium diameter of the via holes in 3D units.
Definition: cinfo3d_visu.h:659
#define cu(a)
Definition: auxiliary.h:88
MAP_CONTAINER_2D m_layers_container2D
It contains the 2d elements of each layer.
Definition: cinfo3d_visu.h:587
float m_stats_hole_med_diameter
Computed medium diameter of the holes in 3D units.
Definition: cinfo3d_visu.h:665
void TransformSolidAreasShapesToPolygonSet(SHAPE_POLY_SET &aCornerBuffer, int aCircleToSegmentsCount, double aCorrectionFactor) const
Function TransformSolidAreasShapesToPolygonSet Convert solid areas full shapes to polygon set (the fu...
LSEQ Seq(const PCB_LAYER_ID *aWishListSequence, unsigned aCount) const
Function Seq returns an LSEQ from the union of this LSET and a desired sequence.
Definition: lset.cpp:364
PCB_LAYER_ID
A quick note on layer IDs:
MAP_POLY m_layers_poly
It contains polygon contours for each layer.
Definition: cinfo3d_visu.h:557
Class LSET is a set of PCB_LAYER_IDs.
glm::vec2 SFVEC2F
Definition: xv3d_types.h:45
VIATYPE_T GetViaType() const
Definition: class_track.h:457
unsigned int m_stats_nr_vias
Nr of vias.
Definition: cinfo3d_visu.h:656
Class SHAPE_POLY_SET.
const wxPoint & GetStart() const
Definition: class_track.h:122
int g_DrawDefaultLineThickness
Default line thickness in internal units used to draw or plot items using a default thickness line va...
double m_biuTo3Dunits
Normalization scale to convert board internal units to 3D units to normalize 3D units between -1...
Definition: cinfo3d_visu.h:616
D_PAD * Next() const
Definition: class_pad.h:160
SHAPE_POLY_SET m_through_outer_holes_poly_NPTH
It contains polygon contours for (just) non plated through holes (outer cylinder) ...
Definition: cinfo3d_visu.h:566
MAP_POLY m_layers_outer_holes_poly
It contains polygon contours for holes of each layer (outer holes)
Definition: cinfo3d_visu.h:560
void Simplify(POLYGON_MODE aFastMode)
Simplifies the polyset (merges overlapping polys, eliminates degeneracy/self-intersections) For aFast...
int GetAreaCount() const
Function GetAreaCount.
Definition: class_board.h:1020
void AddSolidAreasShapesToContainer(const ZONE_CONTAINER *aZoneContainer, CGENERICCONTAINER2D *aDstContainer, PCB_LAYER_ID aLayerId)
static const wxChar * m_logTrace
Trace mask used to enable or disable the trace output of this class.
Definition: cinfo3d_visu.h:673
class DIMENSION, a dimension (graphic item)
Definition: typeinfo.h:100
bool Is3DLayerEnabled(PCB_LAYER_ID aLayer) const
Is3DLayerEnabled - Check if a layer is enabled.
Class LSEQ is a sequence (and therefore also a set) of PCB_LAYER_IDs.
unsigned int GetNrSegmentsCircle(float aDiameter3DU) const
GetNrSegmentsCircle.
void Add(COBJECT2D *aObject)
Definition: ccontainer2d.h:52
bool GetFlag(DISPLAY3D_FLG aFlag) const
GetFlag - get a configuration status of a flag.
SHAPE_POLY_SET m_through_outer_holes_poly
It contains polygon contours for through holes (outer cylinder)
Definition: cinfo3d_visu.h:569
void transformPadsShapesWithClearanceToPolygon(const DLIST< D_PAD > &aPads, PCB_LAYER_ID aLayer, SHAPE_POLY_SET &aCornerBuffer, int aInflateValue, bool aSkipNPTHPadsWihNoCopper) const
TRACK * Next() const
Definition: class_track.h:99
double GetCircleCorrectionFactor(int aNrSides) const
GetCircleCorrectionFactor - computes a angle correction factor used when creating circles...
ZONE_CONTAINER * GetArea(int index) const
Function GetArea returns the Area (Zone Container) at a given index.
Definition: class_board.h:991
int GetDrillValue() const
Function GetDrillValue "calculates" the drill value for vias (m-Drill if > 0, or default drill value ...
DLIST< MODULE > m_Modules
Definition: class_board.h:248
unsigned GetRunningMicroSecs()
Function GetRunningMicroSecs An alternate way to calculate an elapset time (in microsecondes) to clas...
int GetWidth() const
Definition: class_track.h:116
size_t i
Definition: json11.cpp:597
float m_stats_track_med_width
Track average width.
Definition: cinfo3d_visu.h:653
unsigned int m_copperLayersCount
Number of copper layers actually used by the board.
Definition: cinfo3d_visu.h:612
MAP_CONTAINER_2D m_layers_holes2D
It contains the holes per each layer.
Definition: cinfo3d_visu.h:590
RENDER_ENGINE m_render_engine
render engine currently on use
Definition: cinfo3d_visu.h:530
virtual REPORTER & Report(const wxString &aText, SEVERITY aSeverity=RPT_UNDEFINED)=0
Function Report is a pure virtual function to override in the derived object.
unsigned GetCount() const
Function GetCount returns the number of elements in the list.
Definition: dlist.h:126
class VIA, a via (like a track segment on a copper layer)
Definition: typeinfo.h:96
SHAPE_POLY_SET m_through_outer_holes_vias_poly
It contains polygon contours for through holes vias (outer cylinder)
Definition: cinfo3d_visu.h:575
DLIST< TRACK > m_Track
Definition: class_board.h:249
CBVHCONTAINER2D m_through_holes_outer
It contains the list of throughHoles of the board, the radius of the hole is inflated with the copper...
Definition: cinfo3d_visu.h:594
bool IsOnLayer(PCB_LAYER_ID aLayer) const override
Function IsOnLayer tests to see if this object is on the given layer.
Definition: class_pad.h:663
class DRAWSEGMENT, a segment not on copper layers
Definition: typeinfo.h:91
void buildPadShapeThickOutlineAsSegments(const D_PAD *aPad, CGENERICCONTAINER2D *aDstContainer, int aWidth)
COBJECT2D * createNewPadDrill(const D_PAD *aPad, int aInflateValue)
bool BuildPadDrillShapePolygon(SHAPE_POLY_SET &aCornerBuffer, int aInflateValue, int aSegmentsPerCircle) const
Function BuildPadDrillShapePolygon Build the Corner list of the polygonal drill shape, depending on shape pad hole and orientation.
PCB_LAYER_ID ToLAYER_ID(int aLayer)
Definition: lset.cpp:810
Class DIMENSION.
unsigned int m_stats_nr_tracks
Number of tracks in the board.
Definition: cinfo3d_visu.h:650
void transformGraphicModuleEdgeToPolygonSet(const MODULE *aModule, PCB_LAYER_ID aLayer, SHAPE_POLY_SET &aCornerBuffer) const
void AddGraphicsShapesWithClearanceToContainer(const MODULE *aModule, CGENERICCONTAINER2D *aDstContainer, PCB_LAYER_ID aLayerId, int aInflateValue)
DLIST_ITERATOR_WRAPPER< BOARD_ITEM > Drawings()
Definition: class_board.h:255
void buildPadShapeThickOutlineAsPolygon(const D_PAD *aPad, SHAPE_POLY_SET &aCornerBuffer, int aWidth) const
double BiuTo3Dunits() const
BiuTo3Dunits - Board integer units To 3D units.
Definition: cinfo3d_visu.h:141
#define min(a, b)
Definition: auxiliary.h:85
void AddPadsShapesWithClearanceToContainer(const MODULE *aModule, CGENERICCONTAINER2D *aDstContainer, PCB_LAYER_ID aLayerId, int aInflateValue, bool aSkipNPTHPadsWihNoCopper)
void CINFO3D_VISU::createNewPad ( const D_PAD aPad,
CGENERICCONTAINER2D aDstContainer,
wxSize  aInflateValue 
) const
private

Definition at line 569 of file create_3Dgraphic_brd_items.cpp.

References CGENERICCONTAINER2D::Add(), D_PAD::BuildPadPolygon(), createNewPadWithClearance(), D_PAD::GetOrientation(), D_PAD::GetShape(), m_biuTo3Dunits, PAD_SHAPE_CIRCLE, PAD_SHAPE_CUSTOM, PAD_SHAPE_OVAL, PAD_SHAPE_RECT, PAD_SHAPE_ROUNDRECT, PAD_SHAPE_TRAPEZOID, and D_PAD::ShapePos().

Referenced by AddPadsShapesWithClearanceToContainer(), and GetPolyMapHoles_Outer().

572 {
573  switch( aPad->GetShape() )
574  {
575  case PAD_SHAPE_CIRCLE:
576  case PAD_SHAPE_OVAL:
577  case PAD_SHAPE_ROUNDRECT:
578  case PAD_SHAPE_CUSTOM:
579  createNewPadWithClearance( aPad, aDstContainer, aInflateValue );
580  break;
581 
582  case PAD_SHAPE_TRAPEZOID:
583  case PAD_SHAPE_RECT:
584  wxPoint corners[4];
585  aPad->BuildPadPolygon( corners, aInflateValue, aPad->GetOrientation() );
586 
587  // Note: for pad having a shape offset,
588  // the pad position is NOT the shape position
589  for( unsigned int ii = 0; ii < 4; ++ii )
590  corners[ii] += aPad->ShapePos(); // Shift origin to position
591 
592  aDstContainer->Add( new CPOLYGON4PTS2D(
593  SFVEC2F( corners[0].x * m_biuTo3Dunits,
594  -corners[0].y * m_biuTo3Dunits ),
595  SFVEC2F( corners[1].x * m_biuTo3Dunits,
596  -corners[1].y * m_biuTo3Dunits ),
597  SFVEC2F( corners[2].x * m_biuTo3Dunits,
598  -corners[2].y * m_biuTo3Dunits ),
599  SFVEC2F( corners[3].x * m_biuTo3Dunits,
600  -corners[3].y * m_biuTo3Dunits ),
601  *aPad ) );
602 
603  break;
604  }
605 }
void BuildPadPolygon(wxPoint aCoord[4], wxSize aInflateValue, double aRotation) const
Function BuildPadPolygon Has meaning only for polygonal pads (trapezoid and rectangular) Build the Co...
PAD_SHAPE_T GetShape() const
Function GetShape.
Definition: class_pad.h:216
glm::vec2 SFVEC2F
Definition: xv3d_types.h:45
double m_biuTo3Dunits
Normalization scale to convert board internal units to 3D units to normalize 3D units between -1...
Definition: cinfo3d_visu.h:616
void Add(COBJECT2D *aObject)
Definition: ccontainer2d.h:52
This handles simple polygons with 4 points.
double GetOrientation() const
Function GetOrientation returns the rotation angle of the pad in tenths of degrees, but soon degrees.
Definition: class_pad.h:382
wxPoint ShapePos() const
Definition: class_pad.cpp:517
void createNewPadWithClearance(const D_PAD *aPad, CGENERICCONTAINER2D *aDstContainer, wxSize aClearanceValue) const
COBJECT2D * CINFO3D_VISU::createNewPadDrill ( const D_PAD aPad,
int  aInflateValue 
)
private

Definition at line 515 of file create_3Dgraphic_brd_items.cpp.

References D_PAD::GetDrillSize(), D_PAD::GetOblongDrillGeometry(), D_PAD::GetPosition(), Is_segment_a_circle(), m_biuTo3Dunits, m_logTrace, wxPoint::x, and wxPoint::y.

Referenced by createLayers(), and GetPolyMapHoles_Outer().

516 {
517  wxSize drillSize = aPad->GetDrillSize();
518 
519  if( !drillSize.x || !drillSize.y )
520  {
521  wxLogTrace( m_logTrace, wxT( "CINFO3D_VISU::createNewPadDrill - found an invalid pad" ) );
522  return NULL;
523  }
524 
525  if( drillSize.x == drillSize.y ) // usual round hole
526  {
527  const int radius = (drillSize.x / 2) + aInflateValue;
528 
529  const SFVEC2F center( aPad->GetPosition().x * m_biuTo3Dunits,
530  -aPad->GetPosition().y * m_biuTo3Dunits );
531 
532  return new CFILLEDCIRCLE2D( center, radius * m_biuTo3Dunits, *aPad );
533 
534  }
535  else // Oblong hole
536  {
537  wxPoint start, end;
538  int width;
539 
540  aPad->GetOblongDrillGeometry( start, end, width );
541 
542  width += aInflateValue * 2;
543  start += aPad->GetPosition();
544  end += aPad->GetPosition();
545 
546  SFVEC2F start3DU( start.x * m_biuTo3Dunits,
547  -start.y * m_biuTo3Dunits );
548 
549  SFVEC2F end3DU ( end.x * m_biuTo3Dunits,
550  -end.y * m_biuTo3Dunits );
551 
552  if( Is_segment_a_circle( start3DU, end3DU ) )
553  {
554  return new CFILLEDCIRCLE2D( start3DU, (width / 2) * m_biuTo3Dunits, *aPad );
555  }
556  else
557  {
558  return new CROUNDSEGMENT2D( start3DU, end3DU, width * m_biuTo3Dunits, *aPad );
559  }
560  }
561 
562  return NULL;
563 }
const wxSize & GetDrillSize() const
Definition: class_pad.h:275
bool Is_segment_a_circle(const SFVEC2F &aStart, const SFVEC2F &aEnd)
Segment_is_a_circle - check if segment start and end is very close to each other should used to check...
glm::vec2 SFVEC2F
Definition: xv3d_types.h:45
double m_biuTo3Dunits
Normalization scale to convert board internal units to 3D units to normalize 3D units between -1...
Definition: cinfo3d_visu.h:616
static const wxChar * m_logTrace
Trace mask used to enable or disable the trace output of this class.
Definition: cinfo3d_visu.h:673
void GetOblongDrillGeometry(wxPoint &aStartPoint, wxPoint &aEndPoint, int &aWidth) const
Function GetOblongDrillGeometry calculates the start point, end point and width of an equivalent segm...
Definition: class_pad.cpp:787
const wxPoint GetPosition() const override
Definition: class_pad.h:220
void CINFO3D_VISU::createNewPadWithClearance ( const D_PAD aPad,
CGENERICCONTAINER2D aDstContainer,
wxSize  aClearanceValue 
) const
private

Definition at line 298 of file create_3Dgraphic_brd_items.cpp.

References CGENERICCONTAINER2D::Add(), SHAPE_POLY_SET::Append(), D_PAD::BuildPadPolygon(), Convert_shape_line_polygon_to_triangles(), D_PAD::CustomShapeAsPolygonToBoardPosition(), D_PAD::GetCustomShapeAsPolygon(), D_PAD::GetOrientation(), GetRoundRectCornerCenters(), D_PAD::GetRoundRectCornerRadius(), D_PAD::GetShape(), D_PAD::GetSize(), i, SHAPE_POLY_SET::Inflate(), Is_segment_a_circle(), m_biuTo3Dunits, m_logTrace, PAD_SHAPE_CIRCLE, PAD_SHAPE_CUSTOM, PAD_SHAPE_OVAL, PAD_SHAPE_RECT, PAD_SHAPE_ROUNDRECT, PAD_SHAPE_TRAPEZOID, RotatePoint(), D_PAD::ShapePos(), wxPoint::x, and wxPoint::y.

Referenced by createNewPad(), and GetPolyMapHoles_Outer().

301 {
302  // note: for most of shapes, aClearanceValue.x = aClearanceValue.y
303  // only rectangular and oval shapes can have different values
304  // when drawn on the solder paste layer, because we can have a margin that is a
305  // percent of pad size
306  const int dx = (aPad->GetSize().x / 2) + aClearanceValue.x;
307  const int dy = (aPad->GetSize().y / 2) + aClearanceValue.y;
308 
309  if( !dx || !dy )
310  {
311  wxLogTrace( m_logTrace,
312  wxT( "CINFO3D_VISU::createNewPadWithClearance - found an invalid pad" ) );
313 
314  return;
315  }
316 
317  wxPoint PadShapePos = aPad->ShapePos(); // Note: for pad having a shape offset,
318  // the pad position is NOT the shape position
319 
320  switch( aPad->GetShape() )
321  {
322  case PAD_SHAPE_CIRCLE:
323  {
324  const float radius = dx * m_biuTo3Dunits;
325 
326  const SFVEC2F center( PadShapePos.x * m_biuTo3Dunits,
327  -PadShapePos.y * m_biuTo3Dunits );
328 
329  aDstContainer->Add( new CFILLEDCIRCLE2D( center, radius, *aPad ) );
330  }
331  break;
332 
333  case PAD_SHAPE_OVAL:
334  {
335  if( dx == dy )
336  {
337  // The segment object cannot store start and end the same position,
338  // so add a circle instead
339  const float radius = dx * m_biuTo3Dunits;
340 
341  const SFVEC2F center( PadShapePos.x * m_biuTo3Dunits,
342  -PadShapePos.y * m_biuTo3Dunits );
343 
344  aDstContainer->Add( new CFILLEDCIRCLE2D( center, radius, *aPad ) );
345  }
346  else
347  {
348  // An oval pad has the same shape as a segment with rounded ends
349 
350  int iwidth;
351  wxPoint shape_offset = wxPoint( 0, 0 );
352 
353  if( dy > dx ) // Oval pad X/Y ratio for choosing translation axis
354  {
355  shape_offset.y = dy - dx;
356  iwidth = dx * 2;
357  }
358  else //if( dy < dx )
359  {
360  shape_offset.x = dy - dx;
361  iwidth = dy * 2;
362  }
363 
364  RotatePoint( &shape_offset, aPad->GetOrientation() );
365 
366  const wxPoint start = PadShapePos - shape_offset;
367  const wxPoint end = PadShapePos + shape_offset;
368 
369  const SFVEC2F start3DU( start.x * m_biuTo3Dunits, -start.y * m_biuTo3Dunits );
370  const SFVEC2F end3DU ( end.x * m_biuTo3Dunits, -end.y * m_biuTo3Dunits );
371 
372  // Cannot add segments that have the same start and end point
373  if( Is_segment_a_circle( start3DU, end3DU ) )
374  {
375  aDstContainer->Add( new CFILLEDCIRCLE2D( start3DU,
376  (iwidth / 2) * m_biuTo3Dunits,
377  *aPad ) );
378  }
379  else
380  {
381  aDstContainer->Add( new CROUNDSEGMENT2D( start3DU, end3DU,
382  iwidth * m_biuTo3Dunits,
383  *aPad ) );
384  }
385  }
386  }
387  break;
388 
389  case PAD_SHAPE_TRAPEZOID:
390  case PAD_SHAPE_RECT:
391  {
392  // see pcbnew/board_items_to_polygon_shape_transform.cpp
393 
394  wxPoint corners[4];
395  aPad->BuildPadPolygon( corners, wxSize( 0, 0), aPad->GetOrientation() );
396 
397  SFVEC2F corners3DU[4];
398 
399  // Note: for pad having a shape offset,
400  // the pad position is NOT the shape position
401  for( unsigned int ii = 0; ii < 4; ++ii )
402  {
403  corners[ii] += aPad->ShapePos(); // Shift origin to position
404 
405  corners3DU[ii] = SFVEC2F( corners[ii].x * m_biuTo3Dunits,
406  -corners[ii].y * m_biuTo3Dunits );
407  }
408 
409 
410  // Learn more at:
411  // https://lists.launchpad.net/kicad-developers/msg18729.html
412 
413  // Add the PAD polygon
414  aDstContainer->Add( new CPOLYGON4PTS2D( corners3DU[0],
415  corners3DU[1],
416  corners3DU[2],
417  corners3DU[3],
418  *aPad ) );
419 
420  // Add the PAD contours
421  // Round segments cannot have 0-length elements, so we approximate them
422  // as a small circle
423  for( int i = 1; i <= 4; i++ )
424  {
425  if( Is_segment_a_circle( corners3DU[i - 1], corners3DU[i & 3] ) )
426  {
427  aDstContainer->Add( new CFILLEDCIRCLE2D( corners3DU[i - 1],
428  aClearanceValue.x * m_biuTo3Dunits,
429  *aPad ) );
430  }
431  else
432  {
433  aDstContainer->Add( new CROUNDSEGMENT2D( corners3DU[i - 1],
434  corners3DU[i & 3],
435  aClearanceValue.x * 2.0f * m_biuTo3Dunits,
436  *aPad ) );
437  }
438  }
439  }
440  break;
441 
442  case PAD_SHAPE_ROUNDRECT:
443  {
444  wxSize shapesize( aPad->GetSize() );
445  shapesize.x += aClearanceValue.x * 2;
446  shapesize.y += aClearanceValue.y * 2;
447 
448  int rounding_radius = aPad->GetRoundRectCornerRadius( shapesize );
449 
450  wxPoint corners[4];
451 
452  GetRoundRectCornerCenters( corners,
453  rounding_radius,
454  PadShapePos,
455  shapesize,
456  aPad->GetOrientation() );
457 
458  SFVEC2F corners3DU[4];
459 
460  for( unsigned int ii = 0; ii < 4; ++ii )
461  corners3DU[ii] = SFVEC2F( corners[ii].x * m_biuTo3Dunits,
462  -corners[ii].y * m_biuTo3Dunits );
463 
464  // Add the PAD polygon (For some reason the corners need
465  // to be inverted to display with the correctly orientation)
466  aDstContainer->Add( new CPOLYGON4PTS2D( corners3DU[0],
467  corners3DU[3],
468  corners3DU[2],
469  corners3DU[1],
470  *aPad ) );
471 
472  // Add the PAD contours
473  // Round segments cannot have 0-length elements, so we approximate them
474  // as a small circle
475  for( int i = 1; i <= 4; i++ )
476  {
477  if( Is_segment_a_circle( corners3DU[i - 1], corners3DU[i & 3] ) )
478  {
479  aDstContainer->Add( new CFILLEDCIRCLE2D( corners3DU[i - 1],
480  rounding_radius * m_biuTo3Dunits,
481  *aPad ) );
482  }
483  else
484  {
485  aDstContainer->Add( new CROUNDSEGMENT2D( corners3DU[i - 1],
486  corners3DU[i & 3],
487  rounding_radius * 2.0f * m_biuTo3Dunits,
488  *aPad ) );
489  }
490  }
491  }
492  break;
493 
494  case PAD_SHAPE_CUSTOM:
495  {
496  SHAPE_POLY_SET polyList; // Will contain the pad outlines in board coordinates
497  polyList.Append( aPad->GetCustomShapeAsPolygon() );
498  aPad->CustomShapeAsPolygonToBoardPosition( &polyList, aPad->ShapePos(), aPad->GetOrientation() );
499 
500  if( aClearanceValue.x )
501  polyList.Inflate( aClearanceValue.x, 32 );
502 
503  // Add the PAD polygon
504  Convert_shape_line_polygon_to_triangles( polyList, *aDstContainer, m_biuTo3Dunits, *aPad );
505 
506  }
507  break;
508  }
509 }
const SHAPE_POLY_SET & GetCustomShapeAsPolygon() const
Accessor to the custom shape as one polygon.
Definition: class_pad.h:341
void BuildPadPolygon(wxPoint aCoord[4], wxSize aInflateValue, double aRotation) const
Function BuildPadPolygon Has meaning only for polygonal pads (trapezoid and rectangular) Build the Co...
int GetRoundRectCornerRadius() const
Function GetRoundRectCornerRadius Has meaning only for rounded rect pads.
Definition: class_pad.h:531
void RotatePoint(int *pX, int *pY, double angle)
Definition: trigo.cpp:216
PAD_SHAPE_T GetShape() const
Function GetShape.
Definition: class_pad.h:216
bool Is_segment_a_circle(const SFVEC2F &aStart, const SFVEC2F &aEnd)
Segment_is_a_circle - check if segment start and end is very close to each other should used to check...
void CustomShapeAsPolygonToBoardPosition(SHAPE_POLY_SET *aMergedPolygon, wxPoint aPosition, double aRotation) const
When created, the corners coordinates are relative to the pad position, orientation 0...
void Inflate(int aFactor, int aCircleSegmentsCount)
Performs outline inflation/deflation, using round corners.
glm::vec2 SFVEC2F
Definition: xv3d_types.h:45
Class SHAPE_POLY_SET.
double m_biuTo3Dunits
Normalization scale to convert board internal units to 3D units to normalize 3D units between -1...
Definition: cinfo3d_visu.h:616
const wxSize & GetSize() const
Definition: class_pad.h:269
static const wxChar * m_logTrace
Trace mask used to enable or disable the trace output of this class.
Definition: cinfo3d_visu.h:673
void Add(COBJECT2D *aObject)
Definition: ccontainer2d.h:52
This handles simple polygons with 4 points.
size_t i
Definition: json11.cpp:597
double GetOrientation() const
Function GetOrientation returns the rotation angle of the pad in tenths of degrees, but soon degrees.
Definition: class_pad.h:382
void GetRoundRectCornerCenters(wxPoint aCenters[4], int aRadius, const wxPoint &aPosition, const wxSize &aSize, double aRotation)
Helper function GetRoundRectCornerCenters Has meaning only for rounded rect Returns the centers of th...
wxPoint ShapePos() const
Definition: class_pad.cpp:517
void Convert_shape_line_polygon_to_triangles(SHAPE_POLY_SET &aPolyList, CGENERICCONTAINER2D &aDstContainer, float aBiuTo3DunitsScale, const BOARD_ITEM &aBoardItem)
int Append(int x, int y, int aOutline=-1, int aHole=-1, bool aAllowDuplication=false)
Appends a vertex at the end of the given outline/hole (default: the last outline) ...
COBJECT2D * CINFO3D_VISU::createNewTrack ( const TRACK aTrack,
int  aClearanceValue 
) const
private

Definition at line 251 of file create_3Dgraphic_brd_items.cpp.

References TRACK::GetEnd(), TRACK::GetStart(), TRACK::GetWidth(), Is_segment_a_circle(), m_biuTo3Dunits, PCB_TRACE_T, PCB_VIA_T, EDA_ITEM::Type(), wxPoint::x, and wxPoint::y.

Referenced by createLayers(), and GetPolyMapHoles_Outer().

253 {
254  SFVEC2F start3DU( aTrack->GetStart().x * m_biuTo3Dunits,
255  -aTrack->GetStart().y * m_biuTo3Dunits ); // y coord is inverted
256 
257  switch( aTrack->Type() )
258  {
259  case PCB_VIA_T:
260  {
261  const float radius = ( ( aTrack->GetWidth() / 2 ) + aClearanceValue ) * m_biuTo3Dunits;
262 
263  return new CFILLEDCIRCLE2D( start3DU, radius, *aTrack );
264  }
265  break;
266 
267  default:
268  {
269  wxASSERT( aTrack->Type() == PCB_TRACE_T );
270 
271  SFVEC2F end3DU ( aTrack->GetEnd().x * m_biuTo3Dunits,
272  -aTrack->GetEnd().y * m_biuTo3Dunits );
273 
274  // Cannot add segments that have the same start and end point
275  if( Is_segment_a_circle( start3DU, end3DU ) )
276  {
277  const float radius = ((aTrack->GetWidth() / 2) + aClearanceValue) * m_biuTo3Dunits;
278 
279  return new CFILLEDCIRCLE2D( start3DU, radius, *aTrack );
280  }
281  else
282  {
283  const float width = (aTrack->GetWidth() + 2 * aClearanceValue ) * m_biuTo3Dunits;
284 
285  return new CROUNDSEGMENT2D( start3DU, end3DU, width, *aTrack );
286  }
287  }
288  break;
289  }
290 
291  return NULL;
292 }
KICAD_T Type() const
Function Type()
Definition: base_struct.h:201
const wxPoint & GetEnd() const
Definition: class_track.h:119
class TRACK, a track segment (segment on a copper layer)
Definition: typeinfo.h:95
bool Is_segment_a_circle(const SFVEC2F &aStart, const SFVEC2F &aEnd)
Segment_is_a_circle - check if segment start and end is very close to each other should used to check...
glm::vec2 SFVEC2F
Definition: xv3d_types.h:45
const wxPoint & GetStart() const
Definition: class_track.h:122
double m_biuTo3Dunits
Normalization scale to convert board internal units to 3D units to normalize 3D units between -1...
Definition: cinfo3d_visu.h:616
int GetWidth() const
Definition: class_track.h:116
class VIA, a via (like a track segment on a copper layer)
Definition: typeinfo.h:96
void CINFO3D_VISU::destroyLayers ( )
private

Definition at line 61 of file create_layer_items.cpp.

References CGENERICCONTAINER2D::Clear(), m_layers_container2D, m_layers_holes2D, m_layers_inner_holes_poly, m_layers_outer_holes_poly, m_layers_poly, m_through_holes_inner, m_through_holes_outer, m_through_holes_vias_inner, m_through_holes_vias_outer, m_through_inner_holes_vias_poly, m_through_outer_holes_poly, m_through_outer_holes_poly_NPTH, m_through_outer_holes_vias_poly, and SHAPE_POLY_SET::RemoveAllContours().

Referenced by createLayers(), GetPolyMapHoles_Outer(), and ~CINFO3D_VISU().

62 {
63  if( !m_layers_poly.empty() )
64  {
65  for( MAP_POLY::iterator ii = m_layers_poly.begin();
66  ii != m_layers_poly.end();
67  ++ii )
68  {
69  delete ii->second;
70  ii->second = NULL;
71  }
72 
73  m_layers_poly.clear();
74  }
75 
76  if( !m_layers_inner_holes_poly.empty() )
77  {
78  for( MAP_POLY::iterator ii = m_layers_inner_holes_poly.begin();
79  ii != m_layers_inner_holes_poly.end();
80  ++ii )
81  {
82  delete ii->second;
83  ii->second = NULL;
84  }
85 
87  }
88 
89  if( !m_layers_outer_holes_poly.empty() )
90  {
91  for( MAP_POLY::iterator ii = m_layers_outer_holes_poly.begin();
92  ii != m_layers_outer_holes_poly.end();
93  ++ii )
94  {
95  delete ii->second;
96  ii->second = NULL;
97  }
98 
100  }
101 
102  if( !m_layers_container2D.empty() )
103  {
104  for( MAP_CONTAINER_2D::iterator ii = m_layers_container2D.begin();
105  ii != m_layers_container2D.end();
106  ++ii )
107  {
108  delete ii->second;
109  ii->second = NULL;
110  }
111 
112  m_layers_container2D.clear();
113  }
114 
115  if( !m_layers_holes2D.empty() )
116  {
117  for( MAP_CONTAINER_2D::iterator ii = m_layers_holes2D.begin();
118  ii != m_layers_holes2D.end();
119  ++ii )
120  {
121  delete ii->second;
122  ii->second = NULL;
123  }
124 
125  m_layers_holes2D.clear();
126  }
127 
134  //m_through_inner_holes_poly.RemoveAllContours();
135 
138 }
CBVHCONTAINER2D m_through_holes_vias_outer
It contains the list of throughHoles vias of the board, the radius of the hole is inflated with the c...
Definition: cinfo3d_visu.h:602
MAP_POLY m_layers_inner_holes_poly
It contains polygon contours for holes of each layer (inner holes)
Definition: cinfo3d_visu.h:563
CBVHCONTAINER2D m_through_holes_inner
It contains the list of throughHoles of the board, the radius is the inner hole.
Definition: cinfo3d_visu.h:598
MAP_CONTAINER_2D m_layers_container2D
It contains the 2d elements of each layer.
Definition: cinfo3d_visu.h:587
MAP_POLY m_layers_poly
It contains polygon contours for each layer.
Definition: cinfo3d_visu.h:557
SHAPE_POLY_SET m_through_inner_holes_vias_poly
It contains polygon contours for through holes vias (inner cylinder)
Definition: cinfo3d_visu.h:578
SHAPE_POLY_SET m_through_outer_holes_poly_NPTH
It contains polygon contours for (just) non plated through holes (outer cylinder) ...
Definition: cinfo3d_visu.h:566
MAP_POLY m_layers_outer_holes_poly
It contains polygon contours for holes of each layer (outer holes)
Definition: cinfo3d_visu.h:560
SHAPE_POLY_SET m_through_outer_holes_poly
It contains polygon contours for through holes (outer cylinder)
Definition: cinfo3d_visu.h:569
void RemoveAllContours()
Removes all outlines & holes (clears) the polygon set.
MAP_CONTAINER_2D m_layers_holes2D
It contains the holes per each layer.
Definition: cinfo3d_visu.h:590
CBVHCONTAINER2D m_through_holes_vias_inner
It contains the list of throughHoles vias of the board, the radius of the hole.
Definition: cinfo3d_visu.h:606
SHAPE_POLY_SET m_through_outer_holes_vias_poly
It contains polygon contours for through holes vias (outer cylinder)
Definition: cinfo3d_visu.h:575
CBVHCONTAINER2D m_through_holes_outer
It contains the list of throughHoles of the board, the radius of the hole is inflated with the copper...
Definition: cinfo3d_visu.h:594
S3D_CACHE* CINFO3D_VISU::Get3DCacheManager ( ) const
inline

Get3DCacheManager - Return the 3d cache manager pointer.

Returns

Definition at line 88 of file cinfo3d_visu.h.

References GetFlag(), Is3DLayerEnabled(), m_3d_model_manager, SetFlag(), and ShouldModuleBeDisplayed().

Referenced by C3D_RENDER_OGL_LEGACY::load_3D_models(), and C3D_RENDER_RAYTRACING::load_3D_models().

88 { return m_3d_model_manager; }
S3D_CACHE * m_3d_model_manager
pointer to the 3d model manager
Definition: cinfo3d_visu.h:518
const CBBOX& CINFO3D_VISU::GetBBox3DU ( ) const
inline

GetBBox3DU - Get the bbox of the pcb board.

Returns
the board bbox in 3d units

Definition at line 147 of file cinfo3d_visu.h.

References m_boardBoudingBox.

Referenced by EDA_3D_CANVAS::move_pivot_based_on_cur_mouse_position(), and C3D_RENDER_RAYTRACING::reload().

147 { return m_boardBoudingBox; }
CBBOX m_boardBoudingBox
3d bouding box of the pcb board in 3d units
Definition: cinfo3d_visu.h:551
const SFVEC3F& CINFO3D_VISU::GetBoardCenter3DU ( ) const
inline

GetBoardCenter - the board center position in 3d units.

Returns
board center vector position in 3d units

Definition at line 189 of file cinfo3d_visu.h.

References CameraSetType(), GetModulesZcoord3DIU(), and m_boardCenter.

Referenced by C3D_RENDER_OGL_LEGACY::reload(), and C3D_RENDER_RAYTRACING::reload().

189 { return m_boardCenter; }
SFVEC3F m_boardCenter
3d center position of the pcb board in 3d units
Definition: cinfo3d_visu.h:545
const SHAPE_POLY_SET& CINFO3D_VISU::GetBoardPoly ( ) const
inline

GetBoardPoly - Get the current polygon of the epoxy board.

Returns
the shape polygon

Definition at line 252 of file cinfo3d_visu.h.

References GetColor(), GetItemColor(), GetLayerColor(), and m_board_poly.

Referenced by C3D_RENDER_OGL_LEGACY::reload(), and C3D_RENDER_RAYTRACING::reload().

252 { return m_board_poly; }
SHAPE_POLY_SET m_board_poly
PCB board outline polygon.
Definition: cinfo3d_visu.h:581
wxPoint CINFO3D_VISU::GetBoardPosBIU ( ) const
inline

GetBoardPosBIU - Get the board size.

Returns
size in BIU unities

Definition at line 183 of file cinfo3d_visu.h.

References m_boardPos.

Referenced by C3D_RENDER_OGL_LEGACY::generate_new_3DGrid().

183 { return m_boardPos; }
wxPoint m_boardPos
center board actual position in board units
Definition: cinfo3d_visu.h:539
wxSize CINFO3D_VISU::GetBoardSizeBIU ( ) const
inline

GetBoardSizeBIU - Get the board size.

Returns
size in BIU unities

Definition at line 177 of file cinfo3d_visu.h.

References m_boardSize.

Referenced by C3D_RENDER_OGL_LEGACY::generate_new_3DGrid().

177 { return m_boardSize; }
wxSize m_boardSize
board actual size in board units
Definition: cinfo3d_visu.h:542
double CINFO3D_VISU::GetCircleCorrectionFactor ( int  aNrSides) const

GetCircleCorrectionFactor - computes a angle correction factor used when creating circles.

Parameters
aNrSidesthe number of segments sides of the circle
Returns
a factor to apply to contour creation

Definition at line 264 of file cinfo3d_visu.cpp.

References GetCircletoPolyCorrectionFactor().

Referenced by AddShapeWithClearanceToContainer(), buildPadShapeThickOutlineAsPolygon(), buildPadShapeThickOutlineAsSegments(), createLayers(), C3D_RENDER_OGL_LEGACY::generate_3D_Vias_and_Pads(), GetStats_Med_Track_Width(), transformGraphicModuleEdgeToPolygonSet(), and transformPadsShapesWithClearanceToPolygon().

265 {
266  wxASSERT( aNrSides >= 3 );
267 
268  return GetCircletoPolyCorrectionFactor( aNrSides );
269 }
double GetCircletoPolyCorrectionFactor(int aSegCountforCircle)
SFVEC3F CINFO3D_VISU::GetColor ( COLOR4D  aColor) const

GetColor.

Parameters
aColorthe color mapped
Returns
the color in SFVEC3F format

Definition at line 524 of file cinfo3d_visu.cpp.

References KIGFX::COLOR4D::b, KIGFX::COLOR4D::g, and KIGFX::COLOR4D::r.

Referenced by C3D_RENDER_OGL_LEGACY::generate_new_3DGrid(), GetBoardPoly(), and GetItemColor().

525 {
526  return SFVEC3F( aColor.r, aColor.g, aColor.b );
527 }
double g
Green component.
Definition: color4d.h:288
double b
Blue component.
Definition: color4d.h:289
glm::vec3 SFVEC3F
Definition: xv3d_types.h:47
double r
Red component.
Definition: color4d.h:287
float CINFO3D_VISU::GetCopperThickness3DU ( ) const
inline

GetCopperThickness3DU - Get the current copper layer thickness.

Returns
thickness in 3d unities of copperlayers

Definition at line 165 of file cinfo3d_visu.h.

References GetCopperThicknessBIU(), and m_copperThickness3DU.

Referenced by createLayers(), C3D_RENDER_OGL_LEGACY::generate_3D_Vias_and_Pads(), C3D_RENDER_RAYTRACING::insert3DPadHole(), and C3D_RENDER_RAYTRACING::insert3DViaHole().

165 { return m_copperThickness3DU; }
float m_copperThickness3DU
Copper thickness (normalized)
Definition: cinfo3d_visu.h:625
int CINFO3D_VISU::GetCopperThicknessBIU ( ) const

GetCopperThicknessBIU - Get the current copper layer thickness.

Returns
thickness in board unities

Definition at line 242 of file cinfo3d_visu.cpp.

References COPPER_THICKNESS.

Referenced by createLayers(), C3D_RENDER_OGL_LEGACY::generate_3D_Vias_and_Pads(), GetCopperThickness3DU(), C3D_RENDER_RAYTRACING::insert3DPadHole(), and C3D_RENDER_RAYTRACING::insert3DViaHole().

243 {
244  return COPPER_THICKNESS;
245 }
#define COPPER_THICKNESS
float CINFO3D_VISU::GetEpoxyThickness3DU ( ) const
inline

GetEpoxyThickness3DU - Get the current epoxy thickness.

Returns
thickness in 3d unities

Definition at line 153 of file cinfo3d_visu.h.

References m_epoxyThickness3DU.

Referenced by C3D_RENDER_OGL_LEGACY::Redraw().

153 { return m_epoxyThickness3DU; }
float m_epoxyThickness3DU
Epoxy thickness (normalized)
Definition: cinfo3d_visu.h:628
bool CINFO3D_VISU::GetFlag ( DISPLAY3D_FLG  aFlag) const
SFVEC3F CINFO3D_VISU::GetItemColor ( int  aItemId) const

GetItemColor - get the technical color of a layer.

Parameters
aItemIdthe item id to get the color information
Returns
the color in SFVEC3F format

Definition at line 518 of file cinfo3d_visu.cpp.

References BOARD::Colors(), GetColor(), COLORS_DESIGN_SETTINGS::GetItemColor(), and m_board.

Referenced by GetBoardPoly(), C3D_RENDER_RAYTRACING::insert3DPadHole(), and C3D_RENDER_RAYTRACING::insert3DViaHole().

519 {
520  return GetColor( m_board->Colors().GetItemColor( aItemId ) );
521 }
BOARD * m_board
Current board.
Definition: cinfo3d_visu.h:515
COLOR4D GetItemColor(int aItemIdx) const
Function GetItemColor.
const COLORS_DESIGN_SETTINGS & Colors() const
Function GetColorSettings.
Definition: class_board.h:569
SFVEC3F GetColor(COLOR4D aColor) const
GetColor.
float CINFO3D_VISU::GetLayerBottomZpos3DU ( PCB_LAYER_ID  aLayerId) const
inline

GetLayerBottomZpos3DU - Get the bottom z position.

Parameters
aLayerIdlayer id
Returns
position in 3D unities

Definition at line 287 of file cinfo3d_visu.h.

References m_layerZcoordBottom.

Referenced by C3D_RENDER_OGL_LEGACY::get_layer_z_pos(), C3D_RENDER_RAYTRACING::insert3DPadHole(), C3D_RENDER_RAYTRACING::insert3DViaHole(), C3D_RENDER_OGL_LEGACY::Redraw(), and C3D_RENDER_RAYTRACING::reload().

287 { return m_layerZcoordBottom[aLayerId]; }
float m_layerZcoordBottom[PCB_LAYER_ID_COUNT]
Bottom (Start) Z position of each layer (normalized)
Definition: cinfo3d_visu.h:622
SFVEC3F CINFO3D_VISU::GetLayerColor ( PCB_LAYER_ID  aLayerId) const

GetLayerColor - get the technical color of a layer.

Parameters
aLayerIdthe layer to get the color information
Returns
the color in SFVEC3F format

Definition at line 508 of file cinfo3d_visu.cpp.

References KIGFX::COLOR4D::b, color, BOARD::Colors(), KIGFX::COLOR4D::g, COLORS_DESIGN_SETTINGS::GetLayerColor(), m_board, PCB_LAYER_ID_COUNT, and KIGFX::COLOR4D::r.

Referenced by C3D_RENDER_OGL_LEGACY::get_layer_color(), GetBoardPoly(), and C3D_RENDER_RAYTRACING::reload().

509 {
510  wxASSERT( aLayerId < PCB_LAYER_ID_COUNT );
511 
512  const COLOR4D color = m_board->Colors().GetLayerColor( aLayerId );
513 
514  return SFVEC3F( color.r, color.g, color.b );
515 }
int color
Definition: DXF_plotter.cpp:62
double g
Green component.
Definition: color4d.h:288
BOARD * m_board
Current board.
Definition: cinfo3d_visu.h:515
double b
Blue component.
Definition: color4d.h:289
const COLORS_DESIGN_SETTINGS & Colors() const
Function GetColorSettings.
Definition: class_board.h:569
glm::vec3 SFVEC3F
Definition: xv3d_types.h:47
COLOR4D GetLayerColor(LAYER_NUM aLayer) const
Function GetLayerColor.
double r
Red component.
Definition: color4d.h:287
Class COLOR4D is the color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:39
float CINFO3D_VISU::GetLayerTopZpos3DU ( PCB_LAYER_ID  aLayerId) const
inline

GetLayerTopZpos3DU - Get the top z position.

Parameters
aLayerIdlayer id
Returns
position in 3D unities

Definition at line 280 of file cinfo3d_visu.h.

References m_layerZcoordTop.

Referenced by C3D_RENDER_OGL_LEGACY::get_layer_z_pos(), C3D_RENDER_OGL_LEGACY::Redraw(), and C3D_RENDER_RAYTRACING::reload().

280 { return m_layerZcoordTop[aLayerId]; }
float m_layerZcoordTop[PCB_LAYER_ID_COUNT]
Top (End) Z position of each layer (normalized)
Definition: cinfo3d_visu.h:619
const MAP_CONTAINER_2D& CINFO3D_VISU::GetMapLayers ( ) const
inline

GetMapLayers - Get the map of container that have the objects per layer.

Returns
the map containers of this board

Definition at line 293 of file cinfo3d_visu.h.

References m_layers_container2D.

Referenced by C3D_RENDER_OGL_LEGACY::reload(), and C3D_RENDER_RAYTRACING::reload().

293 { return m_layers_container2D; }
MAP_CONTAINER_2D m_layers_container2D
It contains the 2d elements of each layer.
Definition: cinfo3d_visu.h:587
const MAP_CONTAINER_2D& CINFO3D_VISU::GetMapLayersHoles ( ) const
inline

GetMapLayersHoles -Get the map of container that have the holes per layer.

Returns
the map containers of holes from this board

Definition at line 299 of file cinfo3d_visu.h.

References m_layers_holes2D.

Referenced by C3D_RENDER_OGL_LEGACY::reload(), and C3D_RENDER_RAYTRACING::reload().

299 { return m_layers_holes2D; }
MAP_CONTAINER_2D m_layers_holes2D
It contains the holes per each layer.
Definition: cinfo3d_visu.h:590
float CINFO3D_VISU::GetModulesZcoord3DIU ( bool  aIsFlipped) const

GetModulesZcoord3DIU - Get the position of the module in 3d integer units considering if it is flipped or not.

Parameters
aIsFlippedtrue for use in modules on Front (top) layer, false if module is on back (bottom) layer
Returns
the Z position of 3D shapes, in 3D integer units

Definition at line 473 of file cinfo3d_visu.cpp.

References B_Paste, B_SilkS, F_Paste, F_SilkS, FL_SOLDERPASTE, GetFlag(), m_layerZcoordBottom, and m_layerZcoordTop.

Referenced by GetBoardCenter3DU(), C3D_RENDER_RAYTRACING::load_3D_models(), and C3D_RENDER_OGL_LEGACY::render_3D_module().

474 {
475  if( aIsFlipped )
476  {
477  if( GetFlag( FL_SOLDERPASTE ) )
479  else
481  }
482  else
483  {
484  if( GetFlag( FL_SOLDERPASTE ) )
485  return m_layerZcoordTop[F_SilkS];
486  else
487  return m_layerZcoordTop[F_Paste];
488  }
489 }
bool GetFlag(DISPLAY3D_FLG aFlag) const
GetFlag - get a configuration status of a flag.
float m_layerZcoordBottom[PCB_LAYER_ID_COUNT]
Bottom (Start) Z position of each layer (normalized)
Definition: cinfo3d_visu.h:622
float m_layerZcoordTop[PCB_LAYER_ID_COUNT]
Top (End) Z position of each layer (normalized)
Definition: cinfo3d_visu.h:619
float CINFO3D_VISU::GetNonCopperLayerThickness3DU ( ) const
inline

GetNonCopperLayerThickness3DU - Get the current non copper layers thickness.

Returns
thickness in 3d unities of non copperlayers

Definition at line 159 of file cinfo3d_visu.h.

References m_nonCopperLayerThickness3DU.

Referenced by C3D_RENDER_OGL_LEGACY::render_solder_mask_layer(), and C3D_RENDER_RAYTRACING::shadeHit().

float m_nonCopperLayerThickness3DU
Non copper layers thickness.
Definition: cinfo3d_visu.h:631
unsigned int CINFO3D_VISU::GetNrSegmentsCircle ( float  aDiameter3DU) const

GetNrSegmentsCircle.

Parameters
aDiameter3DUdiameter in 3DU
Returns
number of sides that should be used in that circle

Definition at line 247 of file cinfo3d_visu.cpp.

References m_biuTo3Dunits.

Referenced by C3D_RENDER_OGL_LEGACY::add_object_to_triangle_layer(), AddShapeWithClearanceToContainer(), buildPadShapeThickOutlineAsPolygon(), buildPadShapeThickOutlineAsSegments(), createLayers(), C3D_RENDER_OGL_LEGACY::generate_3D_Vias_and_Pads(), GetStats_Med_Track_Width(), transformGraphicModuleEdgeToPolygonSet(), and transformPadsShapesWithClearanceToPolygon().

248 {
249  wxASSERT( aDiameter3DU > 0.0f );
250 
251  return GetNrSegmentsCircle( (int)( aDiameter3DU / m_biuTo3Dunits ) );
252 }
double m_biuTo3Dunits
Normalization scale to convert board internal units to 3D units to normalize 3D units between -1...
Definition: cinfo3d_visu.h:616
unsigned int GetNrSegmentsCircle(float aDiameter3DU) const
GetNrSegmentsCircle.
unsigned int CINFO3D_VISU::GetNrSegmentsCircle ( int  aDiameterBIU) const

GetNrSegmentsCircle.

Parameters
aDiameterBIUdiameter in board internal units
Returns
number of sides that should be used in that circle

Definition at line 255 of file cinfo3d_visu.cpp.

References GetArcToSegmentCount(), and max.

256 {
257  wxASSERT( aDiameterBIU > 0 );
258 
259  // Require at least 3 segments for a circle
260  return std::max( GetArcToSegmentCount( aDiameterBIU / 2, ARC_HIGH_DEF, 360.0 ), 3 );
261 }
int GetArcToSegmentCount(int aRadius, int aErrorMax, double aArcAngleDegree)
#define max(a, b)
Definition: auxiliary.h:86
const MAP_POLY& CINFO3D_VISU::GetPolyMap ( ) const
inline

GetPolyMap - Get maps of polygons's layers.

Returns
the map with polygons's layers

Definition at line 414 of file cinfo3d_visu.h.

References m_layers_poly.

Referenced by C3D_RENDER_OGL_LEGACY::reload().

414 { return m_layers_poly; }
MAP_POLY m_layers_poly
It contains polygon contours for each layer.
Definition: cinfo3d_visu.h:557
const MAP_POLY& CINFO3D_VISU::GetPolyMapHoles_Inner ( ) const
inline

Definition at line 416 of file cinfo3d_visu.h.

References m_layers_inner_holes_poly.

Referenced by C3D_RENDER_OGL_LEGACY::reload().

416 { return m_layers_inner_holes_poly; }
MAP_POLY m_layers_inner_holes_poly
It contains polygon contours for holes of each layer (inner holes)
Definition: cinfo3d_visu.h:563
float CINFO3D_VISU::GetStats_Med_Hole_Diameter3DU ( ) const
inline

GetStats_Med_Hole_Diameter3DU - Average diameter of holes.

Returns
dimension in 3D units

Definition at line 380 of file cinfo3d_visu.h.

References m_stats_hole_med_diameter.

Referenced by C3D_RENDER_RAYTRACING::reload().

380 { return m_stats_hole_med_diameter; }
float m_stats_hole_med_diameter
Computed medium diameter of the holes in 3D units.
Definition: cinfo3d_visu.h:665
float CINFO3D_VISU::GetStats_Med_Track_Width ( ) const
inline

GetStats_Med_Track_Width - Average width of the tracks.

Returns
dimensions in 3D units

Definition at line 386 of file cinfo3d_visu.h.

References GetCircleCorrectionFactor(), GetNrSegmentsCircle(), and m_stats_track_med_width.

386 { return m_stats_track_med_width; }
float m_stats_track_med_width
Track average width.
Definition: cinfo3d_visu.h:653
float CINFO3D_VISU::GetStats_Med_Via_Hole_Diameter3DU ( ) const
inline

GetStats_Med_Via_Hole_Diameter3DU - Average diameter of the via holes.

Returns
dimension in 3D units

Definition at line 374 of file cinfo3d_visu.h.

References m_stats_via_med_hole_diameter.

Referenced by C3D_RENDER_OGL_LEGACY::generate_3D_Vias_and_Pads(), and C3D_RENDER_RAYTRACING::reload().

float m_stats_via_med_hole_diameter
Computed medium diameter of the via holes in 3D units.
Definition: cinfo3d_visu.h:659
unsigned int CINFO3D_VISU::GetStats_Nr_Holes ( ) const
inline

GetStats_Nr_Holes - Get statistics of the nr of holes.

Returns
number of holes

Definition at line 368 of file cinfo3d_visu.h.

References m_stats_nr_holes.

Referenced by C3D_RENDER_OGL_LEGACY::generate_3D_Vias_and_Pads(), and C3D_RENDER_RAYTRACING::reload().

368 { return m_stats_nr_holes; }
unsigned int m_stats_nr_holes
number of holes in the board
Definition: cinfo3d_visu.h:662
unsigned int CINFO3D_VISU::GetStats_Nr_Vias ( ) const
inline

GetStats_Nr_Vias - Get statistics of the nr of vias.

Returns
number of vias

Definition at line 362 of file cinfo3d_visu.h.

References m_stats_nr_vias.

Referenced by C3D_RENDER_OGL_LEGACY::generate_3D_Vias_and_Pads(), and C3D_RENDER_RAYTRACING::reload().

362 { return m_stats_nr_vias; }
unsigned int m_stats_nr_vias
Nr of vias.
Definition: cinfo3d_visu.h:656
const CBVHCONTAINER2D& CINFO3D_VISU::GetThroughHole_Inner ( ) const
inline

GetThroughHole_Inner - Get the ThroughHole container.

Returns
a container with holes

Definition at line 350 of file cinfo3d_visu.h.

References m_through_holes_inner.

Referenced by C3D_RENDER_RAYTRACING::insert3DPadHole(), and C3D_RENDER_OGL_LEGACY::reload().

350 { return m_through_holes_inner; }
CBVHCONTAINER2D m_through_holes_inner
It contains the list of throughHoles of the board, the radius is the inner hole.
Definition: cinfo3d_visu.h:598
const SHAPE_POLY_SET& CINFO3D_VISU::GetThroughHole_Inner_poly ( ) const
inline

GetThroughHole_Inner_poly -.

Returns

Definition at line 356 of file cinfo3d_visu.h.

References m_through_inner_holes_poly.

Referenced by C3D_RENDER_OGL_LEGACY::reload().

356 { return m_through_inner_holes_poly; }
SHAPE_POLY_SET m_through_inner_holes_poly
It contains polygon contours for through holes (inner cylinder)
Definition: cinfo3d_visu.h:572
const CBVHCONTAINER2D& CINFO3D_VISU::GetThroughHole_Outer ( ) const
inline

GetThroughHole_Outer - Get the inflated ThroughHole container.

Returns
a container with holes

Definition at line 305 of file cinfo3d_visu.h.

References m_through_holes_outer.

Referenced by C3D_RENDER_OGL_LEGACY::reload(), and C3D_RENDER_RAYTRACING::reload().

305 { return m_through_holes_outer; }
CBVHCONTAINER2D m_through_holes_outer
It contains the list of throughHoles of the board, the radius of the hole is inflated with the copper...
Definition: cinfo3d_visu.h:594
const SHAPE_POLY_SET& CINFO3D_VISU::GetThroughHole_Outer_poly ( ) const
inline

GetThroughHole_Outer_poly -.

Returns

Definition at line 311 of file cinfo3d_visu.h.

References m_through_outer_holes_poly.

Referenced by C3D_RENDER_OGL_LEGACY::reload().

311 { return m_through_outer_holes_poly; }
SHAPE_POLY_SET m_through_outer_holes_poly
It contains polygon contours for through holes (outer cylinder)
Definition: cinfo3d_visu.h:569
const SHAPE_POLY_SET& CINFO3D_VISU::GetThroughHole_Outer_poly_NPTH ( ) const
inline

GetThroughHole_Outer_poly_NPTH -.

Returns

Definition at line 317 of file cinfo3d_visu.h.

References m_through_outer_holes_poly_NPTH.

Referenced by C3D_RENDER_OGL_LEGACY::reload().

317  {
SHAPE_POLY_SET m_through_outer_holes_poly_NPTH
It contains polygon contours for (just) non plated through holes (outer cylinder) ...
Definition: cinfo3d_visu.h:566
const CBVHCONTAINER2D& CINFO3D_VISU::GetThroughHole_Vias_Inner ( ) const
inline

GetThroughHole_Vias_Inner -.

Returns
a container with via THT holes only

Definition at line 330 of file cinfo3d_visu.h.

References m_through_holes_vias_inner.

330 { return m_through_holes_vias_inner; }
CBVHCONTAINER2D m_through_holes_vias_inner
It contains the list of throughHoles vias of the board, the radius of the hole.
Definition: cinfo3d_visu.h:606
const SHAPE_POLY_SET& CINFO3D_VISU::GetThroughHole_Vias_Inner_poly ( ) const
inline

GetThroughHole_Vias_Inner_poly -.

Returns

Definition at line 343 of file cinfo3d_visu.h.

References m_through_inner_holes_vias_poly.

343  {
SHAPE_POLY_SET m_through_inner_holes_vias_poly
It contains polygon contours for through holes vias (inner cylinder)
Definition: cinfo3d_visu.h:578
const CBVHCONTAINER2D& CINFO3D_VISU::GetThroughHole_Vias_Outer ( ) const
inline

GetThroughHole_Vias_Outer -.

Returns
a container with via THT holes only

Definition at line 324 of file cinfo3d_visu.h.

References m_through_holes_vias_outer.

Referenced by C3D_RENDER_OGL_LEGACY::reload().

324 { return m_through_holes_vias_outer; }
CBVHCONTAINER2D m_through_holes_vias_outer
It contains the list of throughHoles vias of the board, the radius of the hole is inflated with the c...
Definition: cinfo3d_visu.h:602
const SHAPE_POLY_SET& CINFO3D_VISU::GetThroughHole_Vias_Outer_poly ( ) const
inline

GetThroughHole_Vias_Outer_poly -.

Returns

Definition at line 336 of file cinfo3d_visu.h.

References m_through_outer_holes_vias_poly.

Referenced by C3D_RENDER_OGL_LEGACY::reload().

336  {
SHAPE_POLY_SET m_through_outer_holes_vias_poly
It contains polygon contours for through holes vias (outer cylinder)
Definition: cinfo3d_visu.h:575
GRID3D_TYPE CINFO3D_VISU::GridGet ( ) const
inline

GridGet - get the current grid.

Returns
space type of the grid

Definition at line 216 of file cinfo3d_visu.h.

References m_3D_grid_type.

Referenced by EDA_3D_VIEWER::CreateMenuBar(), C3D_RENDER_OGL_LEGACY::Redraw(), and EDA_3D_VIEWER::SaveSettings().

216 { return m_3D_grid_type; }
GRID3D_TYPE m_3D_grid_type
Stores the current grid type.
Definition: cinfo3d_visu.h:527
void CINFO3D_VISU::GridSet ( GRID3D_TYPE  aGridType)
inline

GridSet - set the current grid.

Parameters
aGridType= the type space of the grid

Definition at line 222 of file cinfo3d_visu.h.

References m_3D_grid_type.

Referenced by EDA_3D_VIEWER::LoadSettings(), and EDA_3D_VIEWER::On3DGridSelection().

222 { m_3D_grid_type = aGridType; }
GRID3D_TYPE m_3D_grid_type
Stores the current grid type.
Definition: cinfo3d_visu.h:527
void CINFO3D_VISU::InitSettings ( REPORTER aStatusTextReporter)

InitSettings - Function to be called by the render when it need to reload the settings for the board.

Parameters
aStatusTextReporterthe pointer for the status reporter

Definition at line 272 of file cinfo3d_visu.cpp.

References B_Adhes, B_Cu, B_Mask, B_Paste, B_SilkS, EDA_RECT::Centre(), BOARD::ComputeBoundingBox(), COPPER_THICKNESS, createBoardPolygon(), createLayers(), F_Adhes, F_Cu, F_Mask, F_Paste, F_SilkS, BOARD_DESIGN_SETTINGS::GetBoardThickness(), BOARD::GetCopperLayerCount(), BOARD::GetDesignSettings(), EDA_RECT::GetHeight(), GetRunningMicroSecs(), EDA_RECT::GetSize(), EDA_RECT::GetWidth(), EDA_RECT::Inflate(), layerThicknessMargin, m_biuTo3Dunits, m_board, m_boardBoudingBox, m_boardCenter, m_boardPos, m_boardSize, m_copperLayersCount, m_copperThickness3DU, m_epoxyThickness3DU, m_layerZcoordBottom, m_layerZcoordTop, m_logTrace, m_nonCopperLayerThickness3DU, max, MAX_CU_LAYERS, PCB_LAYER_ID_COUNT, RANGE_SCALE_3D, REPORTER::Report(), TECH_LAYER_THICKNESS, wxPoint::x, and wxPoint::y.

Referenced by GetBoard(), C3D_RENDER_OGL_LEGACY::reload(), and C3D_RENDER_RAYTRACING::reload().

273 {
274  wxLogTrace( m_logTrace, wxT( "CINFO3D_VISU::InitSettings" ) );
275 
276  // Calculates the board bounding box
277  // First, use only the board outlines
278  EDA_RECT bbbox = m_board->ComputeBoundingBox( true );
279 
280  // If no outlines, use the board with items
281  if( ( bbbox.GetWidth() == 0 ) && ( bbbox.GetHeight() == 0 ) )
282  bbbox = m_board->ComputeBoundingBox( false );
283 
284  // Gives a non null size to avoid issues in zoom / scale calculations
285  if( ( bbbox.GetWidth() == 0 ) && ( bbbox.GetHeight() == 0 ) )
286  bbbox.Inflate( Millimeter2iu( 10 ) );
287 
288  m_boardSize = bbbox.GetSize();
289  m_boardPos = bbbox.Centre();
290 
291  wxASSERT( (m_boardSize.x > 0) && (m_boardSize.y > 0) );
292 
293  m_boardPos.y = -m_boardPos.y; // The y coord is inverted in 3D viewer
294 
296 
297  // Ensure the board has 2 sides for 3D views, because it is hard to find
298  // a *really* single side board in the true life...
299  if( m_copperLayersCount < 2 )
301 
302  // Calculate the convertion to apply to all positions.
304 
307 
308  // !TODO: use value defined by user (currently use default values by ctor
311 
312  // Init Z position of each layer
313  // calculate z position for each copper layer
314  // Zstart = -m_epoxyThickness / 2.0 is the z position of the back (bottom layer) (layer id = 31)
315  // Zstart = +m_epoxyThickness / 2.0 is the z position of the front (top layer) (layer id = 0)
316  // all unused copper layer z position are set to 0
317 
318  // ____==__________==________==______ <- Bottom = +m_epoxyThickness / 2.0,
319  // | | Top = Bottom + m_copperThickness
320  // |__________________________________|
321  // == == == == <- Bottom = -m_epoxyThickness / 2.0,
322  // Top = Bottom - m_copperThickness
323 
324  unsigned int layer;
325 
326  for( layer = 0; layer < m_copperLayersCount; ++layer )
327  {
328  m_layerZcoordBottom[layer] = m_epoxyThickness3DU / 2.0f -
329  (m_epoxyThickness3DU * layer / (m_copperLayersCount - 1) );
330 
331  if( layer < (m_copperLayersCount / 2) )
333  else
335  }
336 
337  #define layerThicknessMargin 1.1
338  const float zpos_offset = m_nonCopperLayerThickness3DU * layerThicknessMargin;
339 
340  // Fill remaining unused copper layers and back layer zpos
341  // with -m_epoxyThickness / 2.0
342  for( ; layer < MAX_CU_LAYERS; layer++ )
343  {
344  m_layerZcoordBottom[layer] = -(m_epoxyThickness3DU / 2.0f);
346  }
347 
348  // This is the top of the copper layer thickness.
349  const float zpos_copperTop_back = m_layerZcoordTop[B_Cu];
350  const float zpos_copperTop_front = m_layerZcoordTop[F_Cu];
351 
352  // calculate z position for each non copper layer
353  // Solder mask and Solder paste have the same Z position
354  for( int layer_id = MAX_CU_LAYERS; layer_id < PCB_LAYER_ID_COUNT; ++layer_id )
355  {
356  float zposTop;
357  float zposBottom;
358 
359  switch( layer_id )
360  {
361  case B_Adhes:
362  zposBottom = zpos_copperTop_back - 2.0f * zpos_offset;
363  zposTop = zposBottom - m_nonCopperLayerThickness3DU;
364  break;
365 
366  case F_Adhes:
367  zposBottom = zpos_copperTop_front + 2.0f * zpos_offset;
368  zposTop = zposBottom + m_nonCopperLayerThickness3DU;
369  break;
370 
371  case B_Mask:
372  case B_Paste:
373  zposBottom = zpos_copperTop_back;
374  zposTop = zpos_copperTop_back - m_nonCopperLayerThickness3DU;
375  break;
376 
377  case F_Mask:
378  case F_Paste:
379  zposTop = zpos_copperTop_front + m_nonCopperLayerThickness3DU;
380  zposBottom = zpos_copperTop_front;
381  break;
382 
383  case B_SilkS:
384  zposBottom = zpos_copperTop_back - 1.0f * zpos_offset;
385  zposTop = zposBottom - m_nonCopperLayerThickness3DU;
386  break;
387 
388  case F_SilkS:
389  zposBottom = zpos_copperTop_front + 1.0f * zpos_offset;
390  zposTop = zposBottom + m_nonCopperLayerThickness3DU;
391  break;
392 
393  // !TODO: review
394  default:
395  zposTop = zpos_copperTop_front + (layer_id - MAX_CU_LAYERS + 3.0f) * zpos_offset;
396  zposBottom = zposTop - m_nonCopperLayerThickness3DU;
397  break;
398  }
399 
400  m_layerZcoordTop[layer_id] = zposTop;
401  m_layerZcoordBottom[layer_id] = zposBottom;
402  }
403 
404  m_boardCenter = SFVEC3F( m_boardPos.x * m_biuTo3Dunits,
405  m_boardPos.y * m_biuTo3Dunits,
406  0.0f );
407 
408  SFVEC3F boardSize = SFVEC3F( m_boardSize.x * m_biuTo3Dunits,
409  m_boardSize.y * m_biuTo3Dunits,
410  0.0f );
411  boardSize /= 2.0f;
412 
413  SFVEC3F boardMin = (m_boardCenter - boardSize);
414  SFVEC3F boardMax = (m_boardCenter + boardSize);
415 
416  boardMin.z = m_layerZcoordTop[B_Adhes];
417  boardMax.z = m_layerZcoordTop[F_Adhes];
418 
419  m_boardBoudingBox = CBBOX( boardMin, boardMax );
420 
421 #ifdef PRINT_STATISTICS_3D_VIEWER
422  unsigned stats_startCreateBoardPolyTime = GetRunningMicroSecs();
423 #endif
424 
425  if( aStatusTextReporter )
426  aStatusTextReporter->Report( _( "Build board body" ) );
427 
429 
430 #ifdef PRINT_STATISTICS_3D_VIEWER
431  unsigned stats_stopCreateBoardPolyTime = GetRunningMicroSecs();
432  unsigned stats_startCreateLayersTime = stats_stopCreateBoardPolyTime;
433 #endif
434 
435  if( aStatusTextReporter )
436  aStatusTextReporter->Report( _( "Create layers" ) );
437 
438  createLayers( aStatusTextReporter );
439 
440 #ifdef PRINT_STATISTICS_3D_VIEWER
441  unsigned stats_stopCreateLayersTime = GetRunningMicroSecs();
442 
443  printf( "CINFO3D_VISU::InitSettings times\n" );
444  printf( " CreateBoardPoly: %.3f ms\n",
445  (float)( stats_stopCreateBoardPolyTime - stats_startCreateBoardPolyTime ) / 1e3 );
446  printf( " CreateLayers and holes: %.3f ms\n",
447  (float)( stats_stopCreateLayersTime - stats_startCreateLayersTime ) / 1e3 );
448  printf( "\n" );
449 #endif
450 }
wxPoint m_boardPos
center board actual position in board units
Definition: cinfo3d_visu.h:539
const wxSize GetSize() const
Definition: eda_rect.h:101
EDA_RECT ComputeBoundingBox(bool aBoardEdgesOnly=false) const
Function ComputeBoundingBox calculates the bounding box containing all board items (or board edge seg...
CBBOX m_boardBoudingBox
3d bouding box of the pcb board in 3d units
Definition: cinfo3d_visu.h:551
int GetCopperLayerCount() const
Function GetCopperLayerCount.
int GetHeight() const
Definition: eda_rect.h:118
#define RANGE_SCALE_3D
This defines the range that all coord will have to be rendered.
Definition: cinfo3d_visu.h:63
BOARD * m_board
Current board.
Definition: cinfo3d_visu.h:515
float m_nonCopperLayerThickness3DU
Non copper layers thickness.
Definition: cinfo3d_visu.h:631
#define COPPER_THICKNESS
float m_epoxyThickness3DU
Epoxy thickness (normalized)
Definition: cinfo3d_visu.h:628
void createBoardPolygon()
#define layerThicknessMargin
void createLayers(REPORTER *aStatusTextReporter)
SFVEC3F m_boardCenter
3d center position of the pcb board in 3d units
Definition: cinfo3d_visu.h:545
wxSize m_boardSize
board actual size in board units
Definition: cinfo3d_visu.h:542
double m_biuTo3Dunits
Normalization scale to convert board internal units to 3D units to normalize 3D units between -1...
Definition: cinfo3d_visu.h:616
BOARD_DESIGN_SETTINGS & GetDesignSettings() const
Function GetDesignSettings.
Definition: class_board.h:538
wxPoint Centre() const
Definition: eda_rect.h:60
static const wxChar * m_logTrace
Trace mask used to enable or disable the trace output of this class.
Definition: cinfo3d_visu.h:673
#define max(a, b)
Definition: auxiliary.h:86
#define TECH_LAYER_THICKNESS
unsigned GetRunningMicroSecs()
Function GetRunningMicroSecs An alternate way to calculate an elapset time (in microsecondes) to clas...
glm::vec3 SFVEC3F
Definition: xv3d_types.h:47
float m_copperThickness3DU
Copper thickness (normalized)
Definition: cinfo3d_visu.h:625
Class EDA_RECT handles the component boundary box.
Definition: eda_rect.h:44
unsigned int m_copperLayersCount
Number of copper layers actually used by the board.
Definition: cinfo3d_visu.h:612
int GetWidth() const
Definition: eda_rect.h:117
float m_layerZcoordBottom[PCB_LAYER_ID_COUNT]
Bottom (Start) Z position of each layer (normalized)
Definition: cinfo3d_visu.h:622
virtual REPORTER & Report(const wxString &aText, SEVERITY aSeverity=RPT_UNDEFINED)=0
Function Report is a pure virtual function to override in the derived object.
float m_layerZcoordTop[PCB_LAYER_ID_COUNT]
Top (End) Z position of each layer (normalized)
Definition: cinfo3d_visu.h:619
Class CBBOX manages a bounding box defined by two SFVEC3F min max points.
Definition: cbbox.h:40
EDA_RECT & Inflate(wxCoord dx, wxCoord dy)
Function Inflate inflates the rectangle horizontally by dx and vertically by dy.
bool CINFO3D_VISU::Is3DLayerEnabled ( PCB_LAYER_ID  aLayer) const

Is3DLayerEnabled - Check if a layer is enabled.

Parameters
aLayerlayer ID to get status
Returns
true if layer should be displayed, false if not

Definition at line 123 of file cinfo3d_visu.cpp.

References B_Adhes, B_Cu, B_Mask, B_Paste, B_SilkS, Cmts_User, Dwgs_User, Eco1_User, Eco2_User, Edge_Cuts, F_Adhes, F_Cu, F_Mask, F_Paste, F_SilkS, FL_ADHESIVE, FL_COMMENTS, FL_ECO, FL_SHOW_BOARD_BODY, FL_SILKSCREEN, FL_SOLDERMASK, FL_SOLDERPASTE, FL_USE_REALISTIC_MODE, BOARD::GetDesignSettings(), GetFlag(), BOARD_DESIGN_SETTINGS::IsLayerVisible(), m_board, m_render_engine, Margin, PCB_LAYER_ID_COUNT, and RENDER_ENGINE_OPENGL_LEGACY.

Referenced by createLayers(), Get3DCacheManager(), and C3D_RENDER_OGL_LEGACY::reload().

124 {
125  wxASSERT( aLayer < PCB_LAYER_ID_COUNT );
126 
127  DISPLAY3D_FLG flg;
128 
129  // see if layer needs to be shown
130  // check the flags
131  switch( aLayer )
132  {
133  case B_Adhes:
134  case F_Adhes:
135  flg = FL_ADHESIVE;
136  break;
137 
138  case B_Paste:
139  case F_Paste:
140  flg = FL_SOLDERPASTE;
141  break;
142 
143  case B_SilkS:
144  case F_SilkS:
145  flg = FL_SILKSCREEN;
146  break;
147 
148  case B_Mask:
149  case F_Mask:
150  flg = FL_SOLDERMASK;
151  break;
152 
153  case Dwgs_User:
154  case Cmts_User:
156  return false;
157 
158  flg = FL_COMMENTS;
159  break;
160 
161  case Eco1_User:
162  case Eco2_User:
164  return false;
165 
166  flg = FL_ECO;
167  break;
168 
169  case Edge_Cuts:
171  return false;
172 
173  return true;
174  break;
175 
176  case Margin:
178  return false;
179 
180  return true;
181  break;
182 
183  case B_Cu:
184  case F_Cu:
185  return m_board->GetDesignSettings().IsLayerVisible( aLayer ) ||
187  break;
188 
189  default:
190  // the layer is an internal copper layer, used the visibility
191  if( GetFlag( FL_SHOW_BOARD_BODY ) &&
193  {
194  // Do not render internal layers if it is overlap with the board
195  // (on OpenGL render)
196  return false;
197  }
198 
199  return m_board->GetDesignSettings().IsLayerVisible( aLayer );
200  }
201 
202  // The layer has a flag, return the flag
203  return GetFlag( flg );
204 }
BOARD * m_board
Current board.
Definition: cinfo3d_visu.h:515
bool IsLayerVisible(PCB_LAYER_ID aLayerId) const
Function IsLayerVisible tests whether a given layer is visible.
BOARD_DESIGN_SETTINGS & GetDesignSettings() const
Function GetDesignSettings.
Definition: class_board.h:538
DISPLAY3D_FLG
Flags used in rendering options.
Definition: 3d_enums.h:34
bool GetFlag(DISPLAY3D_FLG aFlag) const
GetFlag - get a configuration status of a flag.
RENDER_ENGINE m_render_engine
render engine currently on use
Definition: cinfo3d_visu.h:530
MATERIAL_MODE CINFO3D_VISU::MaterialModeGet ( ) const
inline

MaterialModeGet.

Returns
material rendering mode

Definition at line 246 of file cinfo3d_visu.h.

References m_material_mode.

Referenced by C3D_RENDER_RAYTRACING::add_3D_models(), C3D_RENDER_OGL_LEGACY::load_3D_models(), EDA_3D_VIEWER::SaveSettings(), and EDA_3D_VIEWER::SetMenuBarOptionsState().

246 { return m_material_mode; }
MATERIAL_MODE m_material_mode
mode to render the 3d shape models material
Definition: cinfo3d_visu.h:533
void CINFO3D_VISU::MaterialModeSet ( MATERIAL_MODE  aMaterialMode)
inline

MaterialModeSet.

Parameters
aMaterialMode= the render material mode

Definition at line 240 of file cinfo3d_visu.h.

References m_material_mode.

Referenced by EDA_3D_VIEWER::LoadSettings(), and EDA_3D_VIEWER::Process_Special_Functions().

240 { m_material_mode = aMaterialMode; }
MATERIAL_MODE m_material_mode
mode to render the 3d shape models material
Definition: cinfo3d_visu.h:533
void CINFO3D_VISU::RenderEngineSet ( RENDER_ENGINE  aRenderEngine)
inline

RenderEngineSet.

Parameters
aRenderEngine= the render engine mode selected

Definition at line 228 of file cinfo3d_visu.h.

References m_render_engine.

Referenced by EDA_3D_VIEWER::LoadSettings(), and EDA_3D_VIEWER::OnRenderEngineSelection().

228 { m_render_engine = aRenderEngine; }
RENDER_ENGINE m_render_engine
render engine currently on use
Definition: cinfo3d_visu.h:530
void CINFO3D_VISU::Set3DCacheManager ( S3D_CACHE aCachePointer)
inline

Set3DCacheManager - Update the Cache manager pointer.

Parameters
aCachePointerthe pointer to the 3d cache manager

Definition at line 82 of file cinfo3d_visu.h.

References m_3d_model_manager.

Referenced by EDA_3D_CANVAS::ReloadRequest().

82 { m_3d_model_manager = aCachePointer; }
S3D_CACHE * m_3d_model_manager
pointer to the 3d model manager
Definition: cinfo3d_visu.h:518
void CINFO3D_VISU::SetBoard ( BOARD aBoard)
inline

SetBoard - Set current board to be rendered.

Parameters
aBoardboard to process

Definition at line 122 of file cinfo3d_visu.h.

References m_board.

Referenced by EDA_3D_CANVAS::ReloadRequest().

122 { m_board = aBoard; }
BOARD * m_board
Current board.
Definition: cinfo3d_visu.h:515
void CINFO3D_VISU::SetFlag ( DISPLAY3D_FLG  aFlag,
bool  aState 
)

SetFlag - set the status of a flag.

Parameters
aFlagthe flag to get the status
aStatestatus to set

Definition at line 215 of file cinfo3d_visu.cpp.

References FL_LAST, and m_drawFlags.

Referenced by CINFO3D_VISU(), PCB_BASE_FRAME::CommonSettingsChanged(), Get3DCacheManager(), EDA_3D_VIEWER::LoadSettings(), PANEL_PREV_3D::PANEL_PREV_3D(), EDA_3D_VIEWER::Process_Special_Functions(), EDA_3D_CANVAS::SetView3D(), and DIALOG_3D_VIEW_OPTIONS::TransferDataFromWindow().

216 {
217  wxASSERT( aFlag < FL_LAST );
218 
219  m_drawFlags[aFlag] = aState;
220 }
std::vector< bool > m_drawFlags
options flags to render the board
Definition: cinfo3d_visu.h:524
bool CINFO3D_VISU::ShouldModuleBeDisplayed ( MODULE_ATTR_T  aModuleAttributs) const

ShouldModuleBeDisplayed - Test if module should be displayed in relation to attributs and the flags.

Returns
true if module should be displayed, false if not

Definition at line 222 of file cinfo3d_visu.cpp.

References FL_MODULE_ATTRIBUTES_NORMAL, FL_MODULE_ATTRIBUTES_NORMAL_INSERT, FL_MODULE_ATTRIBUTES_VIRTUAL, GetFlag(), MOD_CMS, MOD_DEFAULT, and MOD_VIRTUAL.

Referenced by Get3DCacheManager(), C3D_RENDER_RAYTRACING::load_3D_models(), and C3D_RENDER_OGL_LEGACY::render_3D_models().

223 {
224  if( ( ( aModuleAttributs == MOD_DEFAULT ) &&
226  ( ( ( aModuleAttributs & MOD_CMS) == MOD_CMS ) &&
228  ( ( ( aModuleAttributs & MOD_VIRTUAL) == MOD_VIRTUAL ) &&
230  {
231  return true;
232  }
233 
234  return false;
235 }
Set for modules listed in the automatic insertion list (usually SMD footprints)
Definition: class_module.h:77
default
Definition: class_module.h:76
bool GetFlag(DISPLAY3D_FLG aFlag) const
GetFlag - get a configuration status of a flag.
Virtual component: when created by copper shapes on board (Like edge card connectors, mounting hole...)
Definition: class_module.h:79
void CINFO3D_VISU::TransformArcToSegments ( const wxPoint aCentre,
const wxPoint aStart,
double  aArcAngle,
int  aCircleToSegmentsCount,
int  aWidth,
CGENERICCONTAINER2D aDstContainer,
const BOARD_ITEM aBoardItem 
)
private

Definition at line 673 of file create_3Dgraphic_brd_items.cpp.

References CGENERICCONTAINER2D::Add(), delta, Is_segment_a_circle(), m_biuTo3Dunits, RotatePoint(), wxPoint::x, and wxPoint::y.

Referenced by AddShapeWithClearanceToContainer(), and GetPolyMapHoles_Outer().

680 {
681  wxPoint arc_start, arc_end;
682  int delta = 3600 / aCircleToSegmentsCount; // rotate angle in 0.1 degree
683 
684  arc_end = arc_start = aStart;
685 
686  if( aArcAngle != 3600 )
687  {
688  RotatePoint( &arc_end, aCentre, -aArcAngle );
689  }
690 
691  if( aArcAngle < 0 )
692  {
693  std::swap( arc_start, arc_end );
694  aArcAngle = -aArcAngle;
695  }
696 
697  // Compute the ends of segments and creates poly
698  wxPoint curr_end = arc_start;
699  wxPoint curr_start = arc_start;
700 
701  for( int ii = delta; ii < aArcAngle; ii += delta )
702  {
703  curr_end = arc_start;
704  RotatePoint( &curr_end, aCentre, -ii );
705 
706  const SFVEC2F start3DU( curr_start.x * m_biuTo3Dunits, -curr_start.y * m_biuTo3Dunits );
707  const SFVEC2F end3DU ( curr_end.x * m_biuTo3Dunits, -curr_end.y * m_biuTo3Dunits );
708 
709  if( Is_segment_a_circle( start3DU, end3DU ) )
710  {
711  aDstContainer->Add( new CFILLEDCIRCLE2D( start3DU,
712  ( aWidth / 2 ) * m_biuTo3Dunits,
713  aBoardItem ) );
714  }
715  else
716  {
717  aDstContainer->Add( new CROUNDSEGMENT2D( start3DU,
718  end3DU,
719  aWidth * m_biuTo3Dunits,
720  aBoardItem ) );
721  }
722 
723  curr_start = curr_end;
724  }
725 
726  if( curr_end != arc_end )
727  {
728  const SFVEC2F start3DU( curr_end.x * m_biuTo3Dunits, -curr_end.y * m_biuTo3Dunits );
729  const SFVEC2F end3DU ( arc_end.x * m_biuTo3Dunits, -arc_end.y * m_biuTo3Dunits );
730 
731  if( Is_segment_a_circle( start3DU, end3DU ) )
732  {
733  aDstContainer->Add( new CFILLEDCIRCLE2D( start3DU,
734  ( aWidth / 2 ) * m_biuTo3Dunits,
735  aBoardItem ) );
736  }
737  else
738  {
739  aDstContainer->Add( new CROUNDSEGMENT2D( start3DU,
740  end3DU,
741  aWidth * m_biuTo3Dunits,
742  aBoardItem ) );
743  }
744  }
745 }
void RotatePoint(int *pX, int *pY, double angle)
Definition: trigo.cpp:216
static const int delta[8][2]
Definition: solve.cpp:112
bool Is_segment_a_circle(const SFVEC2F &aStart, const SFVEC2F &aEnd)
Segment_is_a_circle - check if segment start and end is very close to each other should used to check...
glm::vec2 SFVEC2F
Definition: xv3d_types.h:45
double m_biuTo3Dunits
Normalization scale to convert board internal units to 3D units to normalize 3D units between -1...
Definition: cinfo3d_visu.h:616
void Add(COBJECT2D *aObject)
Definition: ccontainer2d.h:52
void CINFO3D_VISU::transformGraphicModuleEdgeToPolygonSet ( const MODULE aModule,
PCB_LAYER_ID  aLayer,
SHAPE_POLY_SET aCornerBuffer 
) const
private

Definition at line 210 of file create_layer_poly.cpp.

References DRAWSEGMENT::GetBoundingBox(), GetCircleCorrectionFactor(), BOARD_ITEM::GetLayer(), GetNrSegmentsCircle(), EDA_RECT::GetSizeMax(), MODULE::GraphicalItemsList(), BOARD_ITEM::Next(), PCB_MODULE_EDGE_T, and DRAWSEGMENT::TransformShapeWithClearanceToPolygon().

Referenced by createLayers(), and GetPolyMapHoles_Outer().

213 {
214  for( const EDA_ITEM* item = aModule->GraphicalItemsList();
215  item != NULL;
216  item = item->Next() )
217  {
218  switch( item->Type() )
219  {
220  case PCB_MODULE_EDGE_T:
221  {
222  EDGE_MODULE*outline = (EDGE_MODULE*) item;
223 
224  if( outline->GetLayer() != aLayer )
225  break;
226 
227  unsigned int aCircleToSegmentsCount =
229 
230  double aCorrectionFactor = GetCircleCorrectionFactor( aCircleToSegmentsCount );
231 
232  outline->TransformShapeWithClearanceToPolygon( aCornerBuffer,
233  0,
234  aCircleToSegmentsCount,
235  aCorrectionFactor );
236  }
237  break;
238 
239  default:
240  break;
241  }
242  }
243 }
virtual PCB_LAYER_ID GetLayer() const
Function GetLayer returns the primary layer this item is on.
class EDGE_MODULE, a footprint edge
Definition: typeinfo.h:94
BOARD_ITEM * Next() const
int GetSizeMax() const
GetSizeMax.
Definition: eda_rect.h:107
unsigned int GetNrSegmentsCircle(float aDiameter3DU) const
GetNrSegmentsCircle.
void TransformShapeWithClearanceToPolygon(SHAPE_POLY_SET &aCornerBuffer, int aClearanceValue, int aCircleToSegmentsCount, double aCorrectionFactor, bool ignoreLineWidth=false) const override
Function TransformShapeWithClearanceToPolygon Convert the draw segment to a closed polygon Used in fi...
double GetCircleCorrectionFactor(int aNrSides) const
GetCircleCorrectionFactor - computes a angle correction factor used when creating circles...
Class EDA_ITEM is a base class for most all the KiCad significant classes, used in schematics and boa...
Definition: base_struct.h:154
DLIST< BOARD_ITEM > & GraphicalItemsList()
Definition: class_module.h:166
virtual const EDA_RECT GetBoundingBox() const override
Function GetBoundingBox returns the orthogonal, bounding box of this object for display purposes...
void CINFO3D_VISU::transformPadsShapesWithClearanceToPolygon ( const DLIST< D_PAD > &  aPads,
PCB_LAYER_ID  aLayer,
SHAPE_POLY_SET aCornerBuffer,
int  aInflateValue,
bool  aSkipNPTHPadsWihNoCopper 
) const
private

Definition at line 145 of file create_layer_poly.cpp.

References B_Mask, B_Paste, buildPadShapePolygon(), F_Mask, F_Paste, D_PAD::GetAttribute(), GetCircleCorrectionFactor(), D_PAD::GetDrillShape(), D_PAD::GetDrillSize(), GetNrSegmentsCircle(), D_PAD::GetOffset(), D_PAD::GetShape(), D_PAD::GetSize(), D_PAD::GetSolderMaskMargin(), D_PAD::GetSolderPasteMargin(), D_PAD::IsOnLayer(), D_PAD::Next(), PAD_ATTRIB_HOLE_NOT_PLATED, PAD_DRILL_SHAPE_CIRCLE, PAD_SHAPE_CIRCLE, and PAD_SHAPE_OVAL.

Referenced by createLayers(), and GetPolyMapHoles_Outer().

149 {
150  const D_PAD* pad = aPads;
151 
152  wxSize margin;
153  for( ; pad != NULL; pad = pad->Next() )
154  {
155  if( !pad->IsOnLayer(aLayer) )
156  continue;
157 
158  // NPTH pads are not drawn on layers if the shape size and pos is the same
159  // as their hole:
160  if( aSkipNPTHPadsWihNoCopper && (pad->GetAttribute() == PAD_ATTRIB_HOLE_NOT_PLATED) )
161  {
162  if( (pad->GetDrillSize() == pad->GetSize()) &&
163  (pad->GetOffset() == wxPoint( 0, 0 )) )
164  {
165  switch( pad->GetShape() )
166  {
167  case PAD_SHAPE_CIRCLE:
168  if( pad->GetDrillShape() == PAD_DRILL_SHAPE_CIRCLE )
169  continue;
170  break;
171 
172  case PAD_SHAPE_OVAL:
173  if( pad->GetDrillShape() != PAD_DRILL_SHAPE_CIRCLE )
174  continue;
175  break;
176 
177  default:
178  break;
179  }
180  }
181  }
182 
183  switch( aLayer )
184  {
185  case F_Mask:
186  case B_Mask:
187  margin.x = margin.y = pad->GetSolderMaskMargin() + aInflateValue;
188  break;
189 
190  case F_Paste:
191  case B_Paste:
192  margin = pad->GetSolderPasteMargin();
193  margin.x += aInflateValue;
194  margin.y += aInflateValue;
195  break;
196 
197  default:
198  margin.x = margin.y = aInflateValue;
199  break;
200  }
201 
202  unsigned int aCircleToSegmentsCount = GetNrSegmentsCircle( pad->GetSize().x );
203  double aCorrectionFactor = GetCircleCorrectionFactor( aCircleToSegmentsCount );
204 
205  buildPadShapePolygon( pad, aCornerBuffer, margin,
206  aCircleToSegmentsCount, aCorrectionFactor );
207  }
208 }
PAD_ATTR_T GetAttribute() const
Definition: class_pad.h:405
like PAD_STANDARD, but not plated mechanical use only, no connection allowed
Definition: pad_shapes.h:65
PAD_DRILL_SHAPE_T GetDrillShape() const
Definition: class_pad.h:388
const wxSize & GetDrillSize() const
Definition: class_pad.h:275
PAD_SHAPE_T GetShape() const
Function GetShape.
Definition: class_pad.h:216
int GetSolderMaskMargin() const
Function GetSolderMaskMargin.
Definition: class_pad.cpp:594
D_PAD * Next() const
Definition: class_pad.h:160
const wxSize & GetSize() const
Definition: class_pad.h:269
unsigned int GetNrSegmentsCircle(float aDiameter3DU) const
GetNrSegmentsCircle.
double GetCircleCorrectionFactor(int aNrSides) const
GetCircleCorrectionFactor - computes a angle correction factor used when creating circles...
wxSize GetSolderPasteMargin() const
Function GetSolderPasteMargin.
Definition: class_pad.cpp:637
bool IsOnLayer(PCB_LAYER_ID aLayer) const override
Function IsOnLayer tests to see if this object is on the given layer.
Definition: class_pad.h:663
void buildPadShapePolygon(const D_PAD *aPad, SHAPE_POLY_SET &aCornerBuffer, wxSize aInflateValue, int aSegmentsPerCircle, double aCorrectionFactor) const
const wxPoint & GetOffset() const
Definition: class_pad.h:278

Member Data Documentation

GRID3D_TYPE CINFO3D_VISU::m_3D_grid_type
private

Stores the current grid type.

Definition at line 527 of file cinfo3d_visu.h.

Referenced by CINFO3D_VISU(), GridGet(), and GridSet().

S3D_CACHE* CINFO3D_VISU::m_3d_model_manager
private

pointer to the 3d model manager

Definition at line 518 of file cinfo3d_visu.h.

Referenced by CINFO3D_VISU(), Get3DCacheManager(), and Set3DCacheManager().

BOARD* CINFO3D_VISU::m_board
private
CBBOX2D CINFO3D_VISU::m_board2dBBox3DU
private

2d bouding box of the pcb board in 3d units

Definition at line 554 of file cinfo3d_visu.h.

Referenced by AddGraphicsShapesWithClearanceToContainer(), AddShapeWithClearanceToContainer(), CINFO3D_VISU(), and createBoardPolygon().

SHAPE_POLY_SET CINFO3D_VISU::m_board_poly
private

PCB board outline polygon.

Definition at line 581 of file cinfo3d_visu.h.

Referenced by createBoardPolygon(), and GetBoardPoly().

CBBOX CINFO3D_VISU::m_boardBoudingBox
private

3d bouding box of the pcb board in 3d units

Definition at line 551 of file cinfo3d_visu.h.

Referenced by CINFO3D_VISU(), GetBBox3DU(), and InitSettings().

SFVEC3F CINFO3D_VISU::m_boardCenter
private

3d center position of the pcb board in 3d units

Definition at line 545 of file cinfo3d_visu.h.

Referenced by CINFO3D_VISU(), GetBoardCenter3DU(), and InitSettings().

wxPoint CINFO3D_VISU::m_boardPos
private

center board actual position in board units

Definition at lin