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, const wxSize &aInflateValue) const
 
void createNewPadWithClearance (const D_PAD *aPad, CGENERICCONTAINER2D *aDstContainer, int 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:502
double GetDrawRotation() const
const wxPoint & GetTextPos() const
Definition: eda_text.h:222
bool IsItalic() const
Definition: eda_text.h:168
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:188
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:152
static int s_textWidth
BOARD_ITEM * Next() const
static float s_biuTo3Dunits
TEXTE_MODULE & Value()
read/write accessors:
Definition: class_module.h:501
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:189
bool IsMirrored() const
Definition: eda_text.h:177
bool IsVisible() const
Definition: eda_text.h:174
Class EDA_ITEM is a base class for most all the KiCad significant classes, used in schematics and boa...
Definition: base_struct.h:162
void addTextSegmToContainer(int x0, int y0, int xf, int yf, void *aData)
DLIST< BOARD_ITEM > & GraphicalItemsList()
Definition: class_module.h:164
Definition: colors.h:45
const wxSize & GetTextSize() const
Definition: eda_text.h:213
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 616 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().

621 {
622  const D_PAD* pad = aModule->PadsList();
623 
624  wxSize margin;
625 
626  for( ; pad != NULL; pad = pad->Next() )
627  {
628  if( !pad->IsOnLayer( aLayerId ) )
629  continue;
630 
631  // NPTH pads are not drawn on layers if the
632  // shape size and pos is the same as their hole:
633  if( aSkipNPTHPadsWihNoCopper && (pad->GetAttribute() == PAD_ATTRIB_HOLE_NOT_PLATED) )
634  {
635  if( (pad->GetDrillSize() == pad->GetSize()) &&
636  (pad->GetOffset() == wxPoint( 0, 0 )) )
637  {
638  switch( pad->GetShape() )
639  {
640  case PAD_SHAPE_CIRCLE:
641  if( pad->GetDrillShape() == PAD_DRILL_SHAPE_CIRCLE )
642  continue;
643  break;
644 
645  case PAD_SHAPE_OVAL:
646  if( pad->GetDrillShape() != PAD_DRILL_SHAPE_CIRCLE )
647  continue;
648  break;
649 
650  default:
651  break;
652  }
653  }
654  }
655 
656  switch( aLayerId )
657  {
658  case F_Mask:
659  case B_Mask:
660  margin.x = margin.y = pad->GetSolderMaskMargin() + aInflateValue;
661  break;
662 
663  case F_Paste:
664  case B_Paste:
665  margin = pad->GetSolderPasteMargin();
666  margin.x += aInflateValue;
667  margin.y += aInflateValue;
668  break;
669 
670  default:
671  margin.x = margin.y = aInflateValue;
672  break;
673  }
674 
675  createNewPad( pad, aDstContainer, margin );
676  }
677 }
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:577
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:610
DLIST< D_PAD > & PadsList()
Definition: class_module.h:161
void createNewPad(const D_PAD *aPad, CGENERICCONTAINER2D *aDstContainer, const wxSize &aInflateValue) const
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:644
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)
Function wxStringSplit splits aString to a string list separated at aSplitter.
Definition: common.cpp:138
bool IsMultilineAllowed() const
Definition: eda_text.h:186
const wxPoint & GetTextPos() const
Definition: eda_text.h:222
bool IsItalic() const
Definition: eda_text.h:168
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:188
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:162
int GetThickness() const
Function GetThickness returns pen width.
Definition: eda_text.h:152
static int s_textWidth
virtual wxString GetShownText() const
Returns the string actually shown after processing of the base text.
Definition: eda_text.h:133
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:314
EDA_TEXT_VJUSTIFY_T GetVertJustify() const
Definition: eda_text.h:189
bool IsMirrored() const
Definition: eda_text.h:177
void addTextSegmToContainer(int x0, int y0, int xf, int yf, void *aData)
Definition: colors.h:45
const wxSize & GetTextSize() const
Definition: eda_text.h:213
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 758 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, SHAPE_POLY_SET::PM_STRICTLY_SIMPLE, S_ARC, S_CIRCLE, S_CURVE, S_POLYGON, S_SEGMENT, SHAPE_POLY_SET::Simplify(), TransformArcToSegments(), DRAWSEGMENT::TransformShapeWithClearanceToPolygon(), wxPoint::x, and wxPoint::y.

762 {
763  // The full width of the lines to create:
764  const int linewidth = aDrawSegment->GetWidth() + (2 * aClearanceValue);
765 
766  switch( aDrawSegment->GetShape() )
767  {
768  case S_CIRCLE:
769  {
770  const SFVEC2F center3DU( aDrawSegment->GetCenter().x * m_biuTo3Dunits,
771  -aDrawSegment->GetCenter().y * m_biuTo3Dunits );
772 
773  const float inner_radius = (aDrawSegment->GetRadius() - linewidth / 2) * m_biuTo3Dunits;
774  const float outter_radius = (aDrawSegment->GetRadius() + linewidth / 2) * m_biuTo3Dunits;
775 
776  aDstContainer->Add( new CRING2D( center3DU,
777  inner_radius,
778  outter_radius,
779  *aDrawSegment ) );
780  }
781  break;
782 
783  case S_ARC:
784  {
785  const unsigned int nr_segments =
786  GetNrSegmentsCircle( aDrawSegment->GetBoundingBox().GetSizeMax() );
787 
788  TransformArcToSegments( aDrawSegment->GetCenter(),
789  aDrawSegment->GetArcStart(),
790  aDrawSegment->GetAngle(),
791  nr_segments,
792  aDrawSegment->GetWidth(),
793  aDstContainer,
794  *aDrawSegment );
795  }
796  break;
797 
798  case S_SEGMENT:
799  {
800  const SFVEC2F start3DU( aDrawSegment->GetStart().x * m_biuTo3Dunits,
801  -aDrawSegment->GetStart().y * m_biuTo3Dunits );
802 
803  const SFVEC2F end3DU ( aDrawSegment->GetEnd().x * m_biuTo3Dunits,
804  -aDrawSegment->GetEnd().y * m_biuTo3Dunits );
805 
806  if( Is_segment_a_circle( start3DU, end3DU ) )
807  {
808  aDstContainer->Add( new CFILLEDCIRCLE2D( start3DU,
809  ( linewidth / 2 ) * m_biuTo3Dunits,
810  *aDrawSegment ) );
811  }
812  else
813  {
814  aDstContainer->Add( new CROUNDSEGMENT2D( start3DU,
815  end3DU,
816  linewidth * m_biuTo3Dunits,
817  *aDrawSegment ) );
818  }
819  }
820  break;
821 
822  case S_POLYGON:
823  {
824  const int segcountforcircle = 16;
825  const double correctionFactor = GetCircleCorrectionFactor( segcountforcircle );
826  SHAPE_POLY_SET polyList;
827 
828  aDrawSegment->TransformShapeWithClearanceToPolygon( polyList, aClearanceValue,
829  segcountforcircle, correctionFactor );
830  // This convert the poly in outline and holes
831  // Note: This two sequencial calls are need in order to get
832  // the triangulation function to work properly.
833  polyList.Simplify( SHAPE_POLY_SET::PM_FAST );
835 
836  if( polyList.IsEmpty() ) // Just for caution
837  break;
838 
839  Convert_shape_line_polygon_to_triangles( polyList, *aDstContainer,
840  m_biuTo3Dunits, *aDrawSegment );
841  }
842  break;
843 
844  case S_CURVE: // Bezier curve (not yet in use in KiCad)
845  break;
846 
847  default:
848  break;
849  }
850 }
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
void Convert_shape_line_polygon_to_triangles(const SHAPE_POLY_SET &aPolyList, CGENERICCONTAINER2D &aDstContainer, float aBiuTo3DunitsScale, const BOARD_ITEM &aBoardItem)
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 TransformShapeWithClearanceToPolygon(SHAPE_POLY_SET &aCornerBuffer, int aClearanceValue, int aCircleToSegmentsCount, double aCorrectionFactor) const override
Function TransformShapeWithClearanceToPolygon Convert the track shape to a closed polygon Used in fil...
void Add(COBJECT2D *aObject)
Definition: ccontainer2d.h:51
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.
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:51
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 856 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(), SHAPE_POLY_SET::IsEmpty(), m_biuTo3Dunits, SHAPE_POLY_SET::OutlineCount(), SHAPE_POLY_SET::PM_FAST, SHAPE_POLY_SET::PM_STRICTLY_SIMPLE, SHAPE_LINE_CHAIN::PointCount(), SHAPE_POLY_SET::Simplify(), VECTOR2< T >::x, and VECTOR2< T >::y.

Referenced by createLayers(), and GetPolyMapHoles_Outer().

859 {
860  // Copy the polys list because we have to simplify it
861  SHAPE_POLY_SET polyList = SHAPE_POLY_SET(aZoneContainer->GetFilledPolysList());
862 
863  // This convert the poly in outline and holes
864 
865  // Note: This two sequencial calls are need in order to get
866  // the triangulation function to work properly.
867  polyList.Simplify( SHAPE_POLY_SET::PM_FAST );
869 
870  if( polyList.IsEmpty() )
871  return;
872 
874  *aDstContainer,
876  *aZoneContainer );
877 
878 
879  // add filled areas outlines, which are drawn with thick lines segments
880  // /////////////////////////////////////////////////////////////////////////
881  for( int i = 0; i < polyList.OutlineCount(); ++i )
882  {
883  // Add outline
884  const SHAPE_LINE_CHAIN& pathOutline = polyList.COutline( i );
885 
886  for( int j = 0; j < pathOutline.PointCount(); ++j )
887  {
888  const VECTOR2I& a = pathOutline.CPoint( j );
889  const VECTOR2I& b = pathOutline.CPoint( j + 1 );
890 
891  SFVEC2F start3DU( a.x * m_biuTo3Dunits, -a.y * m_biuTo3Dunits );
892  SFVEC2F end3DU ( b.x * m_biuTo3Dunits, -b.y * m_biuTo3Dunits );
893 
894  if( Is_segment_a_circle( start3DU, end3DU ) )
895  {
896  aDstContainer->Add( new CFILLEDCIRCLE2D( start3DU,
897  (aZoneContainer->GetMinThickness() / 2) *
899  *aZoneContainer ) );
900  }
901  else
902  {
903  aDstContainer->Add( new CROUNDSEGMENT2D( start3DU, end3DU,
904  aZoneContainer->GetMinThickness() *
906  *aZoneContainer ) );
907  }
908  }
909 
910  // Add holes (of the poly, ie: the open parts) for this outline
911  for( int h = 0; h < polyList.HoleCount( i ); ++h )
912  {
913  const SHAPE_LINE_CHAIN& pathHole = polyList.CHole( i, h );
914 
915  for( int j = 0; j < pathHole.PointCount(); j++ )
916  {
917  const VECTOR2I& a = pathHole.CPoint( j );
918  const VECTOR2I& b = pathHole.CPoint( j + 1 );
919 
920  SFVEC2F start3DU( a.x * m_biuTo3Dunits, -a.y * m_biuTo3Dunits );
921  SFVEC2F end3DU ( b.x * m_biuTo3Dunits, -b.y * m_biuTo3Dunits );
922 
923  if( Is_segment_a_circle( start3DU, end3DU ) )
924  {
925  aDstContainer->Add(
926  new CFILLEDCIRCLE2D( start3DU,
927  (aZoneContainer->GetMinThickness() / 2) *
929  *aZoneContainer ) );
930  }
931  else
932  {
933  aDstContainer->Add(
934  new CROUNDSEGMENT2D( start3DU, end3DU,
935  aZoneContainer->GetMinThickness() *
937  *aZoneContainer ) );
938  }
939  }
940  }
941  }
942 }
int GetMinThickness() const
Definition: class_zone.h:198
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.
void Convert_shape_line_polygon_to_triangles(const SHAPE_POLY_SET &aPolyList, CGENERICCONTAINER2D &aDstContainer, float aBiuTo3DunitsScale, const BOARD_ITEM &aBoardItem)
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
void Simplify(POLYGON_MODE aFastMode)
Simplifies the polyset (merges overlapping polys, eliminates degeneracy/self-intersections) For aFast...
const SHAPE_POLY_SET & GetFilledPolysList() const
Function GetFilledPolysList returns a reference to the list of filled polygons.
Definition: class_zone.h:534
void Add(COBJECT2D *aObject)
Definition: ccontainer2d.h:51
Class SHAPE_LINE_CHAIN.
size_t i
Definition: json11.cpp:597
bool IsEmpty() const
Returns true if the set is empty (no polygons at all)
const VECTOR2I & CPoint(int aIndex) const
Function CPoint()
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(), D_PAD::GetCustomShapeAsPolygon(), D_PAD::GetOrientation(), D_PAD::GetShape(), PAD_SHAPE_CIRCLE, PAD_SHAPE_CUSTOM, PAD_SHAPE_OVAL, PAD_SHAPE_RECT, PAD_SHAPE_ROUNDRECT, PAD_SHAPE_TRAPEZOID, SHAPE_LINE_CHAIN::SetClosed(), 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  aPad->TransformShapeWithClearanceToPolygon( aCornerBuffer, aInflateValue.x,
56  aSegmentsPerCircle, aCorrectionFactor );
57  break;
58 
60  case PAD_SHAPE_RECT:
61  {
62  SHAPE_LINE_CHAIN aLineChain;
63 
64  aPad->BuildPadPolygon( corners, aInflateValue, aPad->GetOrientation() );
65 
66  for( int ii = 0; ii < 4; ++ii )
67  {
68  corners[3-ii] += PadShapePos; // Shift origin to position
69  aLineChain.Append( corners[3-ii].x, corners[3-ii].y );
70  }
71 
72  aLineChain.SetClosed( true );
73 
74  aCornerBuffer.AddOutline( aLineChain );
75  }
76  break;
77 
78  case PAD_SHAPE_CUSTOM:
79  {
80  SHAPE_POLY_SET polyList; // Will contain the pad outlines in board coordinates
81  polyList.Append( aPad->GetCustomShapeAsPolygon() );
82  aPad->CustomShapeAsPolygonToBoardPosition( &polyList, aPad->ShapePos(), aPad->GetOrientation() );
83  aCornerBuffer.Append( polyList );
84  }
85  break;
86  }
87 }
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.
void TransformShapeWithClearanceToPolygon(SHAPE_POLY_SET &aCornerBuffer, int aClearanceValue, int aCircleToSegmentsCount, double aCorrectionFactor) const override
Function TransformShapeWithClearanceToPolygon Convert the pad shape to a closed polygon Used in filli...
int AddOutline(const SHAPE_LINE_CHAIN &aOutline)
Adds a new outline to the set and returns its index
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:500
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 90 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().

93 {
94  if( aPad->GetShape() == PAD_SHAPE_CIRCLE ) // Draw a ring
95  {
96  unsigned int nr_sides_per_circle = GetNrSegmentsCircle( ( aPad->GetSize().x / 2 +
97  aWidth / 2 ) * 2 );
98 
99  TransformRingToPolygon( aCornerBuffer, aPad->ShapePos(),
100  aPad->GetSize().x / 2, nr_sides_per_circle, aWidth );
101  return;
102  }
103 
104 
105  // For other shapes, draw polygon outlines
106  SHAPE_POLY_SET corners;
107 
108  unsigned int nr_sides_per_circle = GetNrSegmentsCircle( glm::min( aPad->GetSize().x,
109  aPad->GetSize().y) );
110  buildPadShapePolygon( aPad, corners, wxSize( 0, 0 ),
111  nr_sides_per_circle,
112  GetCircleCorrectionFactor( nr_sides_per_circle ) );
113 
114  // Add outlines as thick segments in polygon buffer
115 
116  const SHAPE_LINE_CHAIN& path = corners.COutline( 0 );
117 
118  for( int ii = 0; ii < path.PointCount(); ++ii )
119  {
120  const VECTOR2I& a = path.CPoint( ii );
121  const VECTOR2I& b = path.CPoint( ii + 1 );
122 
124  wxPoint( a.x, a.y ),
125  wxPoint( b.x, b.y ),
126  nr_sides_per_circle,
127  aWidth );
128  }
129 }
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:500
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 946 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().

949 {
950  if( aPad->GetShape() == PAD_SHAPE_CIRCLE ) // Draw a ring
951  {
952  const SFVEC2F center3DU( aPad->ShapePos().x * m_biuTo3Dunits,
953  -aPad->ShapePos().y * m_biuTo3Dunits );
954 
955  const int radius = aPad->GetSize().x / 2;
956  const float inner_radius = (radius - aWidth / 2) * m_biuTo3Dunits;
957  const float outter_radius = (radius + aWidth / 2) * m_biuTo3Dunits;
958 
959  aDstContainer->Add( new CRING2D( center3DU,
960  inner_radius,
961  outter_radius,
962  *aPad ) );
963 
964  return;
965  }
966 
967  // For other shapes, draw polygon outlines
968  SHAPE_POLY_SET corners;
969 
970  const int segcountforcircle = GetNrSegmentsCircle( glm::min( aPad->GetSize().x,
971  aPad->GetSize().y) );
972 
973  const double correctionFactor = GetCircleCorrectionFactor( segcountforcircle );
974 
975  aPad->BuildPadShapePolygon( corners, wxSize( 0, 0 ),
976  // This two factors are only expected to be used if render an oval
977  segcountforcircle, correctionFactor );
978 
979 
980  // Add outlines as thick segments in polygon buffer
981 
982  const SHAPE_LINE_CHAIN& path = corners.COutline( 0 );
983 
984  for( int j = 0; j < path.PointCount(); j++ )
985  {
986  const VECTOR2I& a = path.CPoint( j );
987  const VECTOR2I& b = path.CPoint( j + 1 );
988 
989  SFVEC2F start3DU( a.x * m_biuTo3Dunits, -a.y * m_biuTo3Dunits );
990  SFVEC2F end3DU ( b.x * m_biuTo3Dunits, -b.y * m_biuTo3Dunits );
991 
992  if( Is_segment_a_circle( start3DU, end3DU ) )
993  {
994  aDstContainer->Add( new CFILLEDCIRCLE2D( start3DU,
995  (aWidth / 2) * m_biuTo3Dunits,
996  *aPad ) );
997  }
998  else
999  {
1000  aDstContainer->Add( new CROUNDSEGMENT2D( start3DU, end3DU,
1001  aWidth * m_biuTo3Dunits,
1002  *aPad ) );
1003  }
1004  }
1005 }
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:51
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:500
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 491 of file cinfo3d_visu.cpp.

References CAMERA_TRACKBALL, m_currentCamera, and m_trackBallCamera.

Referenced by GetBoardCenter3DU().

492 {
493  switch( aCameraType )
494  {
495  case CAMERA_TRACKBALL:
497  break;
498 
499  default:
500  wxLogMessage( wxT( "CINFO3D_VISU::CameraSetType() error: unknown camera type %d" ),
501  (int)aCameraType );
502  break;
503  }
504 }
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 452 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().

453 {
455 
456  wxString errmsg;
457 
458  if( !m_board->GetBoardPolygonOutlines( m_board_poly, /*allLayerHoles,*/ &errmsg ) )
459  {
460  errmsg.append( wxT( "\n\n" ) );
461  errmsg.append( _( "Cannot determine the board outline." ) );
462  wxLogMessage( errmsg );
463  }
464 
465  // Be sure the polygon is strictly simple to avoid issues.
467 
469 }
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 138 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, Format(), 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(), ZONE_CONTAINER::IsOnLayer(), BOARD_ITEM::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, LSET::Name(), 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().

139 {
140  // Number of segments to draw a circle using segments (used on countour zones
141  // and text copper elements )
142  const int segcountforcircle = 12;
143  const double correctionFactor = GetCircleCorrectionFactor( segcountforcircle );
144 
145  // segments to draw a circle to build texts. Is is used only to build
146  // the shape of each segment of the stroke font, therefore no need to have
147  // many segments per circle.
148  const int segcountInStrokeFont = 12;
149  const double correctionFactorStroke = GetCircleCorrectionFactor( segcountInStrokeFont );
150 
151  destroyLayers();
152 
153  // Build Copper layers
154  // Based on: https://github.com/KiCad/kicad-source-mirror/blob/master/3d-viewer/3d_draw.cpp#L692
155  // /////////////////////////////////////////////////////////////////////////
156 
157  #ifdef PRINT_STATISTICS_3D_VIEWER
158  unsigned stats_startCopperLayersTime = GetRunningMicroSecs();
159 
160  unsigned start_Time = stats_startCopperLayersTime;
161 #endif
162 
163  PCB_LAYER_ID cu_seq[MAX_CU_LAYERS];
165 
166  m_stats_nr_tracks = 0;
168  m_stats_nr_vias = 0;
170  m_stats_nr_holes = 0;
172 
173  // Prepare track list, convert in a vector. Calc statistic for the holes
174  // /////////////////////////////////////////////////////////////////////////
175  std::vector< const TRACK *> trackList;
176  trackList.clear();
177  trackList.reserve( m_board->m_Track.GetCount() );
178 
179  for( const TRACK* track = m_board->m_Track; track; track = track->Next() )
180  {
181  if( !Is3DLayerEnabled( track->GetLayer() ) ) // Skip non enabled layers
182  continue;
183 
184  // Note: a TRACK holds normal segment tracks and
185  // also vias circles (that have also drill values)
186  trackList.push_back( track );
187 
188  if( track->Type() == PCB_VIA_T )
189  {
190  const VIA *via = static_cast< const VIA*>( track );
191  m_stats_nr_vias++;
193  }
194  else
195  {
197  }
198 
199  m_stats_track_med_width += track->GetWidth() * m_biuTo3Dunits;
200  }
201 
202  if( m_stats_nr_tracks )
204 
205  if( m_stats_nr_vias )
207 
208 #ifdef PRINT_STATISTICS_3D_VIEWER
209  printf( "T01: %.3f ms\n", (float)( GetRunningMicroSecs() - start_Time ) / 1e3 );
210  start_Time = GetRunningMicroSecs();
211 #endif
212 
213  // Prepare copper layers index and containers
214  // /////////////////////////////////////////////////////////////////////////
215  std::vector< PCB_LAYER_ID > layer_id;
216  layer_id.clear();
217  layer_id.reserve( m_copperLayersCount );
218 
219  for( unsigned i = 0; i < DIM( cu_seq ); ++i )
220  cu_seq[i] = ToLAYER_ID( B_Cu - i );
221 
222  for( LSEQ cu = cu_set.Seq( cu_seq, DIM( cu_seq ) ); cu; ++cu )
223  {
224  const PCB_LAYER_ID curr_layer_id = *cu;
225 
226  if( !Is3DLayerEnabled( curr_layer_id ) ) // Skip non enabled layers
227  continue;
228 
229  layer_id.push_back( curr_layer_id );
230 
231  CBVHCONTAINER2D *layerContainer = new CBVHCONTAINER2D;
232  m_layers_container2D[curr_layer_id] = layerContainer;
233 
236  {
237  SHAPE_POLY_SET *layerPoly = new SHAPE_POLY_SET;
238  m_layers_poly[curr_layer_id] = layerPoly;
239  }
240  }
241 
242 #ifdef PRINT_STATISTICS_3D_VIEWER
243  printf( "T02: %.3f ms\n", (float)( GetRunningMicroSecs() - start_Time ) / 1e3 );
244  start_Time = GetRunningMicroSecs();
245 #endif
246 
247  if( aStatusTextReporter )
248  aStatusTextReporter->Report( _( "Create tracks and vias" ) );
249 
250  // Create tracks as objects and add it to container
251  // /////////////////////////////////////////////////////////////////////////
252  for( unsigned int lIdx = 0; lIdx < layer_id.size(); ++lIdx )
253  {
254  const PCB_LAYER_ID curr_layer_id = layer_id[lIdx];
255 
256  wxASSERT( m_layers_container2D.find( curr_layer_id ) != m_layers_container2D.end() );
257 
258  CBVHCONTAINER2D *layerContainer = m_layers_container2D[curr_layer_id];
259 
260  // ADD TRACKS
261  unsigned int nTracks = trackList.size();
262 
263  for( unsigned int trackIdx = 0; trackIdx < nTracks; ++trackIdx )
264  {
265  const TRACK *track = trackList[trackIdx];
266 
267  // NOTE: Vias can be on multiple layers
268  if( !track->IsOnLayer( curr_layer_id ) )
269  continue;
270 
271  // Add object item to layer container
272  layerContainer->Add( createNewTrack( track, 0.0f ) );
273  }
274  }
275 
276 #ifdef PRINT_STATISTICS_3D_VIEWER
277  printf( "T03: %.3f ms\n", (float)( GetRunningMicroSecs() - start_Time ) / 1e3 );
278  start_Time = GetRunningMicroSecs();
279 #endif
280 
281  // Create VIAS and THTs objects and add it to holes containers
282  // /////////////////////////////////////////////////////////////////////////
283  for( unsigned int lIdx = 0; lIdx < layer_id.size(); ++lIdx )
284  {
285  const PCB_LAYER_ID curr_layer_id = layer_id[lIdx];
286 
287  // ADD TRACKS
288  unsigned int nTracks = trackList.size();
289 
290  for( unsigned int trackIdx = 0; trackIdx < nTracks; ++trackIdx )
291  {
292  const TRACK *track = trackList[trackIdx];
293 
294  if( !track->IsOnLayer( curr_layer_id ) )
295  continue;
296 
297  // ADD VIAS and THT
298  if( track->Type() == PCB_VIA_T )
299  {
300  const VIA *via = static_cast< const VIA*>( track );
301  const VIATYPE_T viatype = via->GetViaType();
302  const float holediameter = via->GetDrillValue() * BiuTo3Dunits();
303  const float thickness = GetCopperThickness3DU();
304  const float hole_inner_radius = ( holediameter / 2.0f );
305 
306  const SFVEC2F via_center( via->GetStart().x * m_biuTo3Dunits,
307  -via->GetStart().y * m_biuTo3Dunits );
308 
309  if( viatype != VIA_THROUGH )
310  {
311 
312  // Add hole objects
313  // /////////////////////////////////////////////////////////
314 
315  CBVHCONTAINER2D *layerHoleContainer = NULL;
316 
317  // Check if the layer is already created
318  if( m_layers_holes2D.find( curr_layer_id ) == m_layers_holes2D.end() )
319  {
320  // not found, create a new container
321  layerHoleContainer = new CBVHCONTAINER2D;
322  m_layers_holes2D[curr_layer_id] = layerHoleContainer;
323  }
324  else
325  {
326  // found
327  layerHoleContainer = m_layers_holes2D[curr_layer_id];
328  }
329 
330  // Add a hole for this layer
331  layerHoleContainer->Add( new CFILLEDCIRCLE2D( via_center,
332  hole_inner_radius + thickness,
333  *track ) );
334  }
335  else if( lIdx == 0 ) // it only adds once the THT holes
336  {
337  // Add through hole object
338  // /////////////////////////////////////////////////////////
339  m_through_holes_outer.Add( new CFILLEDCIRCLE2D( via_center,
340  hole_inner_radius + thickness,
341  *track ) );
342 
344  new CFILLEDCIRCLE2D( via_center,
345  hole_inner_radius + thickness,
346  *track ) );
347 
348  m_through_holes_inner.Add( new CFILLEDCIRCLE2D( via_center,
349  hole_inner_radius,
350  *track ) );
351 
352  //m_through_holes_vias_inner.Add( new CFILLEDCIRCLE2D( via_center,
353  // hole_inner_radius,
354  // *track ) );
355  }
356  }
357  }
358  }
359 
360 #ifdef PRINT_STATISTICS_3D_VIEWER
361  printf( "T04: %.3f ms\n", (float)( GetRunningMicroSecs() - start_Time ) / 1e3 );
362  start_Time = GetRunningMicroSecs();
363 #endif
364 
365  // Create VIAS and THTs objects and add it to holes containers
366  // /////////////////////////////////////////////////////////////////////////
367  for( unsigned int lIdx = 0; lIdx < layer_id.size(); ++lIdx )
368  {
369  const PCB_LAYER_ID curr_layer_id = layer_id[lIdx];
370 
371  // ADD TRACKS
372  const unsigned int nTracks = trackList.size();
373 
374  for( unsigned int trackIdx = 0; trackIdx < nTracks; ++trackIdx )
375  {
376  const TRACK *track = trackList[trackIdx];
377 
378  if( !track->IsOnLayer( curr_layer_id ) )
379  continue;
380 
381  // ADD VIAS and THT
382  if( track->Type() == PCB_VIA_T )
383  {
384  const VIA *via = static_cast< const VIA*>( track );
385  const VIATYPE_T viatype = via->GetViaType();
386 
387  if( viatype != VIA_THROUGH )
388  {
389 
390  // Add VIA hole contourns
391  // /////////////////////////////////////////////////////////
392 
393  // Add outter holes of VIAs
394  SHAPE_POLY_SET *layerOuterHolesPoly = NULL;
395  SHAPE_POLY_SET *layerInnerHolesPoly = NULL;
396 
397  // Check if the layer is already created
398  if( m_layers_outer_holes_poly.find( curr_layer_id ) ==
400  {
401  // not found, create a new container
402  layerOuterHolesPoly = new SHAPE_POLY_SET;
403  m_layers_outer_holes_poly[curr_layer_id] = layerOuterHolesPoly;
404 
405  wxASSERT( m_layers_inner_holes_poly.find( curr_layer_id ) ==
407 
408  layerInnerHolesPoly = new SHAPE_POLY_SET;
409  m_layers_inner_holes_poly[curr_layer_id] = layerInnerHolesPoly;
410  }
411  else
412  {
413  // found
414  layerOuterHolesPoly = m_layers_outer_holes_poly[curr_layer_id];
415 
416  wxASSERT( m_layers_inner_holes_poly.find( curr_layer_id ) !=
418 
419  layerInnerHolesPoly = m_layers_inner_holes_poly[curr_layer_id];
420  }
421 
422  const int holediameter = via->GetDrillValue();
423  const int hole_outer_radius = (holediameter / 2) + GetCopperThicknessBIU();
424 
425  TransformCircleToPolygon( *layerOuterHolesPoly,
426  via->GetStart(),
427  hole_outer_radius,
428  GetNrSegmentsCircle( hole_outer_radius * 2 ) );
429 
430  TransformCircleToPolygon( *layerInnerHolesPoly,
431  via->GetStart(),
432  holediameter / 2,
433  GetNrSegmentsCircle( holediameter ) );
434  }
435  else if( lIdx == 0 ) // it only adds once the THT holes
436  {
437  const int holediameter = via->GetDrillValue();
438  const int hole_outer_radius = (holediameter / 2)+ GetCopperThicknessBIU();
439 
440  // Add through hole contourns
441  // /////////////////////////////////////////////////////////
443  via->GetStart(),
444  hole_outer_radius,
445  GetNrSegmentsCircle( hole_outer_radius * 2 ) );
446 
448  via->GetStart(),
449  holediameter / 2,
450  GetNrSegmentsCircle( holediameter ) );
451 
452  // Add samething for vias only
453 
455  via->GetStart(),
456  hole_outer_radius,
457  GetNrSegmentsCircle( hole_outer_radius * 2 ) );
458 
459  //TransformCircleToPolygon( m_through_inner_holes_vias_poly,
460  // via->GetStart(),
461  // holediameter / 2,
462  // GetNrSegmentsCircle( holediameter ) );
463  }
464  }
465  }
466  }
467 
468 #ifdef PRINT_STATISTICS_3D_VIEWER
469  printf( "T05: %.3f ms\n", (float)( GetRunningMicroSecs() - start_Time ) / 1e3 );
470  start_Time = GetRunningMicroSecs();
471 #endif
472 
473  // Creates outline contours of the tracks and add it to the poly of the layer
474  // /////////////////////////////////////////////////////////////////////////
477  {
478  for( unsigned int lIdx = 0; lIdx < layer_id.size(); ++lIdx )
479  {
480  const PCB_LAYER_ID curr_layer_id = layer_id[lIdx];
481 
482  wxASSERT( m_layers_poly.find( curr_layer_id ) != m_layers_poly.end() );
483 
484  SHAPE_POLY_SET *layerPoly = m_layers_poly[curr_layer_id];
485 
486  // ADD TRACKS
487  unsigned int nTracks = trackList.size();
488 
489  for( unsigned int trackIdx = 0; trackIdx < nTracks; ++trackIdx )
490  {
491  const TRACK *track = trackList[trackIdx];
492 
493  if( !track->IsOnLayer( curr_layer_id ) )
494  continue;
495 
496  // Add the track contour
497  int nrSegments = GetNrSegmentsCircle( track->GetWidth() );
498 
500  *layerPoly,
501  0,
502  nrSegments,
503  GetCircleCorrectionFactor( nrSegments ) );
504  }
505  }
506  }
507 
508 #ifdef PRINT_STATISTICS_3D_VIEWER
509  printf( "T06: %.3f ms\n", (float)( GetRunningMicroSecs() - start_Time ) / 1e3 );
510  start_Time = GetRunningMicroSecs();
511 #endif
512 
513  // Add holes of modules
514  // /////////////////////////////////////////////////////////////////////////
515  for( const MODULE* module = m_board->m_Modules; module; module = module->Next() )
516  {
517  const D_PAD* pad = module->PadsList();
518 
519  for( ; pad; pad = pad->Next() )
520  {
521  const wxSize padHole = pad->GetDrillSize();
522 
523  if( !padHole.x ) // Not drilled pad like SMD pad
524  continue;
525 
526  // The hole in the body is inflated by copper thickness,
527  // if not plated, no copper
528  const int inflate = (pad->GetAttribute () != PAD_ATTRIB_HOLE_NOT_PLATED) ?
529  GetCopperThicknessBIU() : 0;
530 
532  m_stats_hole_med_diameter += ( ( pad->GetDrillSize().x +
533  pad->GetDrillSize().y ) / 2.0f ) * m_biuTo3Dunits;
534 
535  m_through_holes_outer.Add( createNewPadDrill( pad, inflate ) );
537  }
538  }
539  if( m_stats_nr_holes )
541 
542 #ifdef PRINT_STATISTICS_3D_VIEWER
543  printf( "T07: %.3f ms\n", (float)( GetRunningMicroSecs() - start_Time ) / 1e3 );
544  start_Time = GetRunningMicroSecs();
545 #endif
546 
547  // Add contours of the pad holes (pads can be Circle or Segment holes)
548  // /////////////////////////////////////////////////////////////////////////
549  for( const MODULE* module = m_board->m_Modules; module; module = module->Next() )
550  {
551  const D_PAD* pad = module->PadsList();
552 
553  for( ; pad; pad = pad->Next() )
554  {
555  const wxSize padHole = pad->GetDrillSize();
556 
557  if( !padHole.x ) // Not drilled pad like SMD pad
558  continue;
559 
560  // The hole in the body is inflated by copper thickness.
561  const int inflate = GetCopperThicknessBIU();
562 
563  // we use the hole diameter to calculate the seg count.
564  // for round holes, padHole.x == padHole.y
565  // for oblong holes, the diameter is the smaller of (padHole.x, padHole.y)
566  const int diam = std::min( padHole.x, padHole.y );
567 
568 
570  {
572  inflate,
573  GetNrSegmentsCircle( diam ) );
574 
576  0,
577  GetNrSegmentsCircle( diam ) );
578  }
579  else
580  {
581  // If not plated, no copper.
583  inflate,
584  GetNrSegmentsCircle( diam ) );
585  }
586  }
587  }
588 
589 #ifdef PRINT_STATISTICS_3D_VIEWER
590  printf( "T08: %.3f ms\n", (float)( GetRunningMicroSecs() - start_Time ) / 1e3 );
591  start_Time = GetRunningMicroSecs();
592 #endif
593 
594  // Add modules PADs objects to containers
595  // /////////////////////////////////////////////////////////////////////////
596  for( unsigned int lIdx = 0; lIdx < layer_id.size(); ++lIdx )
597  {
598  const PCB_LAYER_ID curr_layer_id = layer_id[lIdx];
599 
600  wxASSERT( m_layers_container2D.find( curr_layer_id ) != m_layers_container2D.end() );
601 
602  CBVHCONTAINER2D *layerContainer = m_layers_container2D[curr_layer_id];
603 
604  // ADD PADS
605  for( const MODULE* module = m_board->m_Modules; module; module = module->Next() )
606  {
607  // Note: NPTH pads are not drawn on copper layers when the pad
608  // has same shape as its hole
610  layerContainer,
611  curr_layer_id,
612  0,
613  true );
614 
615  // Micro-wave modules may have items on copper layers
617  layerContainer,
618  curr_layer_id,
619  0 );
620  }
621  }
622 
623 #ifdef PRINT_STATISTICS_3D_VIEWER
624  printf( "T09: %.3f ms\n", (float)( GetRunningMicroSecs() - start_Time ) / 1e3 );
625  start_Time = GetRunningMicroSecs();
626 #endif
627 
628  // Add modules PADs poly contourns
629  // /////////////////////////////////////////////////////////////////////////
632  {
633  for( unsigned int lIdx = 0; lIdx < layer_id.size(); ++lIdx )
634  {
635  const PCB_LAYER_ID curr_layer_id = layer_id[lIdx];
636 
637  wxASSERT( m_layers_poly.find( curr_layer_id ) != m_layers_poly.end() );
638 
639  SHAPE_POLY_SET *layerPoly = m_layers_poly[curr_layer_id];
640 
641  // ADD PADS
642  for( const MODULE* module = m_board->m_Modules; module; module = module->Next() )
643  {
644  // Construct polys
645  // /////////////////////////////////////////////////////////////
646 
647  // Note: NPTH pads are not drawn on copper layers when the pad
648  // has same shape as its hole
649  transformPadsShapesWithClearanceToPolygon( module->PadsList(),
650  curr_layer_id,
651  *layerPoly,
652  0,
653  true );
654 
655  // Micro-wave modules may have items on copper layers
656  module->TransformGraphicTextWithClearanceToPolygonSet( curr_layer_id,
657  *layerPoly,
658  0,
659  segcountforcircle,
660  correctionFactor );
661 
662  transformGraphicModuleEdgeToPolygonSet( module, curr_layer_id, *layerPoly );
663  }
664  }
665  }
666 
667 #ifdef PRINT_STATISTICS_3D_VIEWER
668  printf( "T10: %.3f ms\n", (float)( GetRunningMicroSecs() - start_Time ) / 1e3 );
669  start_Time = GetRunningMicroSecs();
670 #endif
671 
672  // Add graphic item on copper layers to object containers
673  // /////////////////////////////////////////////////////////////////////////
674  for( unsigned int lIdx = 0; lIdx < layer_id.size(); ++lIdx )
675  {
676  const PCB_LAYER_ID curr_layer_id = layer_id[lIdx];
677 
678  wxASSERT( m_layers_container2D.find( curr_layer_id ) != m_layers_container2D.end() );
679 
680  CBVHCONTAINER2D *layerContainer = m_layers_container2D[curr_layer_id];
681 
682  // ADD GRAPHIC ITEMS ON COPPER LAYERS (texts)
683  for( auto item : m_board->Drawings() )
684  {
685  if( !item->IsOnLayer( curr_layer_id ) )
686  continue;
687 
688  switch( item->Type() )
689  {
690  case PCB_LINE_T: // should not exist on copper layers
691  {
693  layerContainer,
694  curr_layer_id,
695  0 );
696  }
697  break;
698 
699  case PCB_TEXT_T:
701  layerContainer,
702  curr_layer_id,
703  0 );
704  break;
705 
706  case PCB_DIMENSION_T:
708  layerContainer,
709  curr_layer_id,
710  0 );
711  break;
712 
713  default:
714  wxLogTrace( m_logTrace,
715  wxT( "createLayers: item type: %d not implemented" ),
716  item->Type() );
717  break;
718  }
719  }
720  }
721 
722 #ifdef PRINT_STATISTICS_3D_VIEWER
723  printf( "T11: %.3f ms\n", (float)( GetRunningMicroSecs() - start_Time ) / 1e3 );
724  start_Time = GetRunningMicroSecs();
725 #endif
726 
727  // Add graphic item on copper layers to poly contourns
728  // /////////////////////////////////////////////////////////////////////////
731  {
732  for( unsigned int lIdx = 0; lIdx < layer_id.size(); ++lIdx )
733  {
734  const PCB_LAYER_ID curr_layer_id = layer_id[lIdx];
735 
736  wxASSERT( m_layers_poly.find( curr_layer_id ) != m_layers_poly.end() );
737 
738  SHAPE_POLY_SET *layerPoly = m_layers_poly[curr_layer_id];
739 
740  // ADD GRAPHIC ITEMS ON COPPER LAYERS (texts)
741  for( auto item : m_board->Drawings() )
742  {
743  if( !item->IsOnLayer( curr_layer_id ) )
744  continue;
745 
746  switch( item->Type() )
747  {
748  case PCB_LINE_T: // should not exist on copper layers
749  {
750  const int nrSegments =
751  GetNrSegmentsCircle( item->GetBoundingBox().GetSizeMax() );
752 
753  ( (DRAWSEGMENT*) item )->TransformShapeWithClearanceToPolygon(
754  *layerPoly,
755  0,
756  nrSegments,
757  GetCircleCorrectionFactor( nrSegments ) );
758  }
759  break;
760 
761  case PCB_TEXT_T:
762  ( (TEXTE_PCB*) item )->TransformShapeWithClearanceToPolygonSet(
763  *layerPoly,
764  0,
765  segcountforcircle,
766  correctionFactor );
767  break;
768 
769  default:
770  wxLogTrace( m_logTrace,
771  wxT( "createLayers: item type: %d not implemented" ),
772  item->Type() );
773  break;
774  }
775  }
776  }
777  }
778 
779 #ifdef PRINT_STATISTICS_3D_VIEWER
780  printf( "T12: %.3f ms\n", (float)( GetRunningMicroSecs() - start_Time ) / 1e3 );
781  start_Time = GetRunningMicroSecs();
782 #endif
783 
784  if( GetFlag( FL_ZONE ) )
785  {
786  if( aStatusTextReporter )
787  aStatusTextReporter->Report( _( "Create zones" ) );
788 
789  // Add zones objects
790  // /////////////////////////////////////////////////////////////////////
791  for( unsigned int lIdx = 0; lIdx < layer_id.size(); ++lIdx )
792  {
793  const PCB_LAYER_ID curr_layer_id = layer_id[lIdx];
794 
795  if( aStatusTextReporter )
796  aStatusTextReporter->Report( wxString::Format( _( "Create zones of layer %s" ),
797  LSET::Name( curr_layer_id ) ) );
798 
799  wxASSERT( m_layers_container2D.find( curr_layer_id ) != m_layers_container2D.end() );
800 
801  CBVHCONTAINER2D *layerContainer = m_layers_container2D[curr_layer_id];
802 
803  // ADD COPPER ZONES
804  for( int ii = 0; ii < m_board->GetAreaCount(); ++ii )
805  {
806  const ZONE_CONTAINER* zone = m_board->GetArea( ii );
807  const PCB_LAYER_ID zonelayer = zone->GetLayer();
808 
809  if( zonelayer == curr_layer_id )
810  {
812  layerContainer,
813  curr_layer_id );
814  }
815  }
816  }
817  }
818 
819 #ifdef PRINT_STATISTICS_3D_VIEWER
820  printf( "T13: %.3f ms\n", (float)( GetRunningMicroSecs() - start_Time ) / 1e3 );
821  start_Time = GetRunningMicroSecs();
822 #endif
823 
824  if( GetFlag( FL_ZONE ) &&
827  {
828  // Add zones poly contourns
829  // /////////////////////////////////////////////////////////////////////
830  for( unsigned int lIdx = 0; lIdx < layer_id.size(); ++lIdx )
831  {
832  const PCB_LAYER_ID curr_layer_id = layer_id[lIdx];
833 
834  wxASSERT( m_layers_poly.find( curr_layer_id ) != m_layers_poly.end() );
835 
836  SHAPE_POLY_SET *layerPoly = m_layers_poly[curr_layer_id];
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  const LAYER_NUM zonelayer = zone->GetLayer();
843 
844  if( zonelayer == curr_layer_id )
845  {
846  zone->TransformSolidAreasShapesToPolygonSet( *layerPoly,
847  segcountforcircle,
848  correctionFactor );
849  }
850  }
851  }
852  }
853 
854 #ifdef PRINT_STATISTICS_3D_VIEWER
855  printf( "T14: %.3f ms\n", (float)( GetRunningMicroSecs() - start_Time ) / 1e3 );
856  start_Time = GetRunningMicroSecs();
857 #endif
858 
859  // Simplify layer polygons
860  // /////////////////////////////////////////////////////////////////////////
861 
862  if( aStatusTextReporter )
863  aStatusTextReporter->Report( _( "Simplifying copper layers polygons" ) );
864 
867  {
868  const int nLayers = layer_id.size();
869 
870  #pragma omp parallel for
871  for( signed int lIdx = 0; lIdx < nLayers; ++lIdx )
872  {
873  const PCB_LAYER_ID curr_layer_id = layer_id[lIdx];
874 
875  wxASSERT( m_layers_poly.find( curr_layer_id ) != m_layers_poly.end() );
876 
877  SHAPE_POLY_SET *layerPoly = m_layers_poly[curr_layer_id];
878 
879  wxASSERT( layerPoly != NULL );
880 
881  // This will make a union of all added contourns
882  layerPoly->Simplify( SHAPE_POLY_SET::PM_FAST );
883  }
884  }
885 
886 #ifdef PRINT_STATISTICS_3D_VIEWER
887  printf( "T15: %.3f ms\n", (float)( GetRunningMicroSecs() - start_Time ) / 1e3 );
888  start_Time = GetRunningMicroSecs();
889 #endif
890 
891  // Simplify holes polygon contours
892  // /////////////////////////////////////////////////////////////////////////
893  if( aStatusTextReporter )
894  aStatusTextReporter->Report( _( "Simplify holes contours" ) );
895 
896  for( unsigned int lIdx = 0; lIdx < layer_id.size(); ++lIdx )
897  {
898  const PCB_LAYER_ID curr_layer_id = layer_id[lIdx];
899 
900  if( m_layers_outer_holes_poly.find( curr_layer_id ) !=
902  {
903  // found
904  SHAPE_POLY_SET *polyLayer = m_layers_outer_holes_poly[curr_layer_id];
905  polyLayer->Simplify( SHAPE_POLY_SET::PM_FAST );
906 
907  wxASSERT( m_layers_inner_holes_poly.find( curr_layer_id ) !=
909 
910  polyLayer = m_layers_inner_holes_poly[curr_layer_id];
911  polyLayer->Simplify( SHAPE_POLY_SET::PM_FAST );
912  }
913  }
914 
915 #ifdef PRINT_STATISTICS_3D_VIEWER
916  printf( "T16: %.3f ms\n", (float)( GetRunningMicroSecs() - start_Time ) / 1e3 );
917 #endif
918  // End Build Copper layers
919 
920 
921  // This will make a union of all added contourns
926  //m_through_inner_holes_vias_poly.Simplify( SHAPE_POLY_SET::PM_FAST ); // Not in use
927 
928 #ifdef PRINT_STATISTICS_3D_VIEWER
929  unsigned stats_endCopperLayersTime = GetRunningMicroSecs();
930 #endif
931 
932  // Build Tech layers
933  // Based on: https://github.com/KiCad/kicad-source-mirror/blob/master/3d-viewer/3d_draw.cpp#L1059
934  // /////////////////////////////////////////////////////////////////////////
935 #ifdef PRINT_STATISTICS_3D_VIEWER
936  unsigned stats_startTechLayersTime = GetRunningMicroSecs();
937 #endif
938 
939  if( aStatusTextReporter )
940  aStatusTextReporter->Report( _( "Build Tech layers" ) );
941 
942  // draw graphic items, on technical layers
943  static const PCB_LAYER_ID teckLayerList[] = {
944  B_Adhes,
945  F_Adhes,
946  B_Paste,
947  F_Paste,
948  B_SilkS,
949  F_SilkS,
950  B_Mask,
951  F_Mask,
952 
953  // Aux Layers
954  Dwgs_User,
955  Cmts_User,
956  Eco1_User,
957  Eco2_User,
958  Edge_Cuts,
959  Margin
960  };
961 
962  // User layers are not drawn here, only technical layers
963 
964  for( LSEQ seq = LSET::AllNonCuMask().Seq( teckLayerList, DIM( teckLayerList ) );
965  seq;
966  ++seq )
967  {
968  const PCB_LAYER_ID curr_layer_id = *seq;
969 
970  if( !Is3DLayerEnabled( curr_layer_id ) )
971  continue;
972 
973  CBVHCONTAINER2D *layerContainer = new CBVHCONTAINER2D;
974  m_layers_container2D[curr_layer_id] = layerContainer;
975 
976  SHAPE_POLY_SET *layerPoly = new SHAPE_POLY_SET;
977  m_layers_poly[curr_layer_id] = layerPoly;
978 
979  // Add drawing objects
980  // /////////////////////////////////////////////////////////////////////
981  for( auto item : m_board->Drawings() )
982  {
983  if( !item->IsOnLayer( curr_layer_id ) )
984  continue;
985 
986  switch( item->Type() )
987  {
988  case PCB_LINE_T:
990  layerContainer,
991  curr_layer_id,
992  0 );
993  break;
994 
995  case PCB_TEXT_T:
997  layerContainer,
998  curr_layer_id,
999  0 );
1000  break;
1001 
1002  case PCB_DIMENSION_T:
1004  layerContainer,
1005  curr_layer_id,
1006  0 );
1007  break;
1008 
1009  default:
1010  break;
1011  }
1012  }
1013 
1014 
1015  // Add drawing contours
1016  // /////////////////////////////////////////////////////////////////////
1017  for( auto item : m_board->Drawings() )
1018  {
1019  if( !item->IsOnLayer( curr_layer_id ) )
1020  continue;
1021 
1022  switch( item->Type() )
1023  {
1024  case PCB_LINE_T:
1025  {
1026  const unsigned int nr_segments =
1027  GetNrSegmentsCircle( item->GetBoundingBox().GetSizeMax() );
1028 
1029  ((DRAWSEGMENT*) item)->TransformShapeWithClearanceToPolygon( *layerPoly,
1030  0,
1031  nr_segments,
1032  0.0 );
1033  }
1034  break;
1035 
1036  case PCB_TEXT_T:
1037  ((TEXTE_PCB*) item)->TransformShapeWithClearanceToPolygonSet( *layerPoly,
1038  0,
1039  segcountInStrokeFont,
1040  1.0 );
1041  break;
1042 
1043  default:
1044  break;
1045  }
1046  }
1047 
1048 
1049  // Add modules tech layers - objects
1050  // /////////////////////////////////////////////////////////////////////
1051  for( MODULE* module = m_board->m_Modules; module; module = module->Next() )
1052  {
1053  if( (curr_layer_id == F_SilkS) || (curr_layer_id == B_SilkS) )
1054  {
1055  D_PAD* pad = module->PadsList();
1056  int linewidth = g_DrawDefaultLineThickness;
1057 
1058  for( ; pad; pad = pad->Next() )
1059  {
1060  if( !pad->IsOnLayer( curr_layer_id ) )
1061  continue;
1062 
1064  layerContainer,
1065  linewidth );
1066  }
1067  }
1068  else
1069  {
1071  layerContainer,
1072  curr_layer_id,
1073  0,
1074  false );
1075  }
1076 
1078  layerContainer,
1079  curr_layer_id,
1080  0 );
1081  }
1082 
1083 
1084  // Add modules tech layers - contours
1085  // /////////////////////////////////////////////////////////////////////
1086  for( MODULE* module = m_board->m_Modules; module; module = module->Next() )
1087  {
1088  if( (curr_layer_id == F_SilkS) || (curr_layer_id == B_SilkS) )
1089  {
1090  D_PAD* pad = module->PadsList();
1091  const int linewidth = g_DrawDefaultLineThickness;
1092 
1093  for( ; pad; pad = pad->Next() )
1094  {
1095  if( !pad->IsOnLayer( curr_layer_id ) )
1096  continue;
1097 
1098  buildPadShapeThickOutlineAsPolygon( pad, *layerPoly, linewidth );
1099  }
1100  }
1101  else
1102  {
1103  transformPadsShapesWithClearanceToPolygon( module->PadsList(),
1104  curr_layer_id,
1105  *layerPoly,
1106  0,
1107  false );
1108  }
1109 
1110  // On tech layers, use a poor circle approximation, only for texts (stroke font)
1111  module->TransformGraphicTextWithClearanceToPolygonSet( curr_layer_id,
1112  *layerPoly,
1113  0,
1114  segcountInStrokeFont,
1115  correctionFactorStroke,
1116  segcountInStrokeFont );
1117 
1118  // Add the remaining things with dynamic seg count for circles
1119  transformGraphicModuleEdgeToPolygonSet( module, curr_layer_id, *layerPoly );
1120  }
1121 
1122 
1123  // Draw non copper zones
1124  // /////////////////////////////////////////////////////////////////////
1125  if( GetFlag( FL_ZONE ) )
1126  {
1127  for( int ii = 0; ii < m_board->GetAreaCount(); ++ii )
1128  {
1129  ZONE_CONTAINER* zone = m_board->GetArea( ii );
1130 
1131  if( !zone->IsOnLayer( curr_layer_id ) )
1132  continue;
1133 
1135  layerContainer,
1136  curr_layer_id );
1137  }
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 
1146  zone->TransformSolidAreasShapesToPolygonSet( *layerPoly,
1147  // Use the same segcount as stroke font
1148  segcountInStrokeFont,
1149  correctionFactorStroke );
1150  }
1151  }
1152 
1153  // This will make a union of all added contours
1154  layerPoly->Simplify( SHAPE_POLY_SET::PM_FAST );
1155  }
1156  // End Build Tech layers
1157 
1158 #ifdef PRINT_STATISTICS_3D_VIEWER
1159  unsigned stats_endTechLayersTime = GetRunningMicroSecs();
1160 #endif
1161 
1162 
1163  // Build BVH for holes and vias
1164  // /////////////////////////////////////////////////////////////////////////
1165 
1166 #ifdef PRINT_STATISTICS_3D_VIEWER
1167  unsigned stats_startHolesBVHTime = GetRunningMicroSecs();
1168 #endif
1169  if( aStatusTextReporter )
1170  aStatusTextReporter->Report( _( "Build BVH for holes and vias" ) );
1171 
1174 
1175  if( !m_layers_holes2D.empty() )
1176  {
1177  for( MAP_CONTAINER_2D::iterator ii = m_layers_holes2D.begin();
1178  ii != m_layers_holes2D.end();
1179  ++ii )
1180  {
1181  ((CBVHCONTAINER2D *)(ii->second))->BuildBVH();
1182  }
1183  }
1184 
1185  // We only need the Solder mask to initialize the BVH
1186  // because..?
1188  ((CBVHCONTAINER2D *)m_layers_container2D[B_Mask])->BuildBVH();
1189 
1191  ((CBVHCONTAINER2D *)m_layers_container2D[F_Mask])->BuildBVH();
1192 
1193 #ifdef PRINT_STATISTICS_3D_VIEWER
1194  unsigned stats_endHolesBVHTime = GetRunningMicroSecs();
1195 
1196  printf( "CINFO3D_VISU::createLayers times\n" );
1197  printf( " Copper Layers: %.3f ms\n",
1198  (float)( stats_endCopperLayersTime - stats_startCopperLayersTime ) / 1e3 );
1199  printf( " Holes BVH creation: %.3f ms\n",
1200  (float)( stats_endHolesBVHTime - stats_startHolesBVHTime ) / 1e3 );
1201  printf( " Tech Layers: %.3f ms\n",
1202  (float)( stats_endTechLayersTime - stats_startTechLayersTime ) / 1e3 );
1203  printf( "Statistics:\n" );
1204  printf( " m_stats_nr_tracks %u\n", m_stats_nr_tracks );
1205  printf( " m_stats_nr_vias %u\n", m_stats_nr_vias );
1206  printf( " m_stats_nr_holes %u\n", m_stats_nr_holes );
1207  printf( " m_stats_via_med_hole_diameter (3DU) %f\n", m_stats_via_med_hole_diameter );
1208  printf( " m_stats_hole_med_diameter (3DU) %f\n", m_stats_hole_med_diameter );
1209  printf( " m_calc_seg_min_factor3DU (3DU) %f\n", m_calc_seg_min_factor3DU );
1210  printf( " m_calc_seg_max_factor3DU (3DU) %f\n", m_calc_seg_max_factor3DU );
1211 #endif
1212 }
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:209
#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
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:121
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:455
unsigned int m_stats_nr_vias
Nr of vias.
Definition: cinfo3d_visu.h:656
static const wxChar * Name(PCB_LAYER_ID aLayerId)
Function Name returns the fixed name association with aLayerId.
Definition: lset.cpp:73
Class SHAPE_POLY_SET.
const wxPoint & GetStart() const
Definition: class_track.h:122
void TransformShapeWithClearanceToPolygon(SHAPE_POLY_SET &aCornerBuffer, int aClearanceValue, int aCircleToSegmentsCount, double aCorrectionFactor) const override
Function TransformShapeWithClearanceToPolygon Convert the track shape to a closed polygon Used in fil...
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:1011
int g_DrawDefaultLineThickness
Default line thickness in internal units used to draw or plot items using a default thickness line va...
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.
int LAYER_NUM
Type LAYER_NUM can be replaced with int and removed.
unsigned int GetNrSegmentsCircle(float aDiameter3DU) const
GetNrSegmentsCircle.
void Add(COBJECT2D *aObject)
Definition: ccontainer2d.h:51
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:982
void Format(OUTPUTFORMATTER *out, int aNestLevel, int aCtl, CPTREE &aTree)
Function Format outputs a PTREE into s-expression format via an OUTPUTFORMATTER derivative.
Definition: ptree.cpp:205
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:245
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:246
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:644
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:796
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:251
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,
const wxSize &  aInflateValue 
) const
private

Definition at line 577 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().

580 {
581  switch( aPad->GetShape() )
582  {
583  case PAD_SHAPE_CIRCLE:
584  case PAD_SHAPE_OVAL:
585  case PAD_SHAPE_ROUNDRECT:
586  case PAD_SHAPE_CUSTOM:
587  createNewPadWithClearance( aPad, aDstContainer, aInflateValue.x );
588  break;
589 
590  case PAD_SHAPE_TRAPEZOID:
591  case PAD_SHAPE_RECT:
592  wxPoint corners[4];
593  aPad->BuildPadPolygon( corners, aInflateValue, aPad->GetOrientation() );
594 
595  // Note: for pad having a shape offset,
596  // the pad position is NOT the shape position
597  for( unsigned int ii = 0; ii < 4; ++ii )
598  corners[ii] += aPad->ShapePos(); // Shift origin to position
599 
600  aDstContainer->Add( new CPOLYGON4PTS2D(
601  SFVEC2F( corners[0].x * m_biuTo3Dunits,
602  -corners[0].y * m_biuTo3Dunits ),
603  SFVEC2F( corners[1].x * m_biuTo3Dunits,
604  -corners[1].y * m_biuTo3Dunits ),
605  SFVEC2F( corners[2].x * m_biuTo3Dunits,
606  -corners[2].y * m_biuTo3Dunits ),
607  SFVEC2F( corners[3].x * m_biuTo3Dunits,
608  -corners[3].y * m_biuTo3Dunits ),
609  *aPad ) );
610 
611  break;
612  }
613 }
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:51
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:500
void createNewPadWithClearance(const D_PAD *aPad, CGENERICCONTAINER2D *aDstContainer, int aClearanceValue) const
COBJECT2D * CINFO3D_VISU::createNewPadDrill ( const D_PAD aPad,
int  aInflateValue 
)
private

Definition at line 523 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().

524 {
525  wxSize drillSize = aPad->GetDrillSize();
526 
527  if( !drillSize.x || !drillSize.y )
528  {
529  wxLogTrace( m_logTrace, wxT( "CINFO3D_VISU::createNewPadDrill - found an invalid pad" ) );
530  return NULL;
531  }
532 
533  if( drillSize.x == drillSize.y ) // usual round hole
534  {
535  const int radius = (drillSize.x / 2) + aInflateValue;
536 
537  const SFVEC2F center( aPad->GetPosition().x * m_biuTo3Dunits,
538  -aPad->GetPosition().y * m_biuTo3Dunits );
539 
540  return new CFILLEDCIRCLE2D( center, radius * m_biuTo3Dunits, *aPad );
541 
542  }
543  else // Oblong hole
544  {
545  wxPoint start, end;
546  int width;
547 
548  aPad->GetOblongDrillGeometry( start, end, width );
549 
550  width += aInflateValue * 2;
551  start += aPad->GetPosition();
552  end += aPad->GetPosition();
553 
554  SFVEC2F start3DU( start.x * m_biuTo3Dunits,
555  -start.y * m_biuTo3Dunits );
556 
557  SFVEC2F end3DU ( end.x * m_biuTo3Dunits,
558  -end.y * m_biuTo3Dunits );
559 
560  if( Is_segment_a_circle( start3DU, end3DU ) )
561  {
562  return new CFILLEDCIRCLE2D( start3DU, (width / 2) * m_biuTo3Dunits, *aPad );
563  }
564  else
565  {
566  return new CROUNDSEGMENT2D( start3DU, end3DU, width * m_biuTo3Dunits, *aPad );
567  }
568  }
569 
570  return NULL;
571 }
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:749
const wxPoint GetPosition() const override
Definition: class_pad.h:220
void CINFO3D_VISU::createNewPadWithClearance ( const D_PAD aPad,
CGENERICCONTAINER2D aDstContainer,
int  aClearanceValue 
) const
private

Definition at line 298 of file create_3Dgraphic_brd_items.cpp.

References abs, 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(), 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, SHAPE_POLY_SET::PM_FAST, SHAPE_POLY_SET::PM_STRICTLY_SIMPLE, RotatePoint(), D_PAD::ShapePos(), SHAPE_POLY_SET::Simplify(), wxPoint::x, and wxPoint::y.

Referenced by createNewPad(), and GetPolyMapHoles_Outer().

301 {
302  const int dx = (aPad->GetSize().x / 2) + aClearanceValue;
303  const int dy = (aPad->GetSize().y / 2) + aClearanceValue;
304 
305  if( !dx || !dy )
306  {
307  wxLogTrace( m_logTrace,
308  wxT( "CINFO3D_VISU::createNewPadWithClearance - found an invalid pad" ) );
309 
310  return;
311  }
312 
313  wxPoint PadShapePos = aPad->ShapePos(); // Note: for pad having a shape offset,
314  // the pad position is NOT the shape position
315 
316  switch( aPad->GetShape() )
317  {
318  case PAD_SHAPE_CIRCLE:
319  {
320  const float radius = dx * m_biuTo3Dunits;
321 
322  const SFVEC2F center( PadShapePos.x * m_biuTo3Dunits,
323  -PadShapePos.y * m_biuTo3Dunits );
324 
325  aDstContainer->Add( new CFILLEDCIRCLE2D( center, radius, *aPad ) );
326  }
327  break;
328 
329  case PAD_SHAPE_OVAL:
330  {
331  if( abs( dx - dy ) == 0 )
332  {
333  // The segment object cannot store start and end the same position,
334  // so add a circle instead
335  const float radius = dx * m_biuTo3Dunits;
336 
337  const SFVEC2F center( PadShapePos.x * m_biuTo3Dunits,
338  -PadShapePos.y * m_biuTo3Dunits );
339 
340  aDstContainer->Add( new CFILLEDCIRCLE2D( center, radius, *aPad ) );
341  }
342  else
343  {
344  // An oval pad has the same shape as a segment with rounded ends
345 
346  int iwidth;
347  wxPoint shape_offset = wxPoint( 0, 0 );
348 
349  if( dy > dx ) // Oval pad X/Y ratio for choosing translation axis
350  {
351  shape_offset.y = dy - dx;
352  iwidth = dx * 2;
353  }
354  else //if( dy <= dx )
355  {
356  shape_offset.x = dy - dx;
357  iwidth = dy * 2;
358  }
359 
360  RotatePoint( &shape_offset, aPad->GetOrientation() );
361 
362  const wxPoint start = PadShapePos - shape_offset;
363  const wxPoint end = PadShapePos + shape_offset;
364 
365  const SFVEC2F start3DU( start.x * m_biuTo3Dunits, -start.y * m_biuTo3Dunits );
366  const SFVEC2F end3DU ( end.x * m_biuTo3Dunits, -end.y * m_biuTo3Dunits );
367 
368  // Cannot add segments that have the same start and end point
369  if( Is_segment_a_circle( start3DU, end3DU ) )
370  {
371  aDstContainer->Add( new CFILLEDCIRCLE2D( start3DU,
372  (iwidth / 2) * m_biuTo3Dunits,
373  *aPad ) );
374  }
375  else
376  {
377  aDstContainer->Add( new CROUNDSEGMENT2D( start3DU,
378  end3DU,
379  iwidth * m_biuTo3Dunits,
380  *aPad ) );
381  }
382  }
383  }
384  break;
385 
386  case PAD_SHAPE_TRAPEZOID:
387  case PAD_SHAPE_RECT:
388  {
389  // https://github.com/KiCad/kicad-source-mirror/blob/0cab3e47ad8097db7b898b3cef2cf9b235318ca3/pcbnew/board_items_to_polygon_shape_transform.cpp#L613
390 
391  wxPoint corners[4];
392  aPad->BuildPadPolygon( corners, wxSize( 0, 0), aPad->GetOrientation() );
393 
394  SFVEC2F corners3DU[4];
395 
396  // Note: for pad having a shape offset,
397  // the pad position is NOT the shape position
398  for( unsigned int ii = 0; ii < 4; ++ii )
399  {
400  corners[ii] += aPad->ShapePos(); // Shift origin to position
401 
402  corners3DU[ii] = SFVEC2F( corners[ii].x * m_biuTo3Dunits,
403  -corners[ii].y * m_biuTo3Dunits );
404  }
405 
406 
407  // Learn more at:
408  // https://lists.launchpad.net/kicad-developers/msg18729.html
409 
410  // Add the PAD polygon
411  aDstContainer->Add( new CPOLYGON4PTS2D( corners3DU[0],
412  corners3DU[1],
413  corners3DU[2],
414  corners3DU[3],
415  *aPad ) );
416 
417  // Add the PAD contours
418  // !TODO: check the corners because it cannot add
419  // roundsegments that are in the same start and end position
420  aDstContainer->Add( new CROUNDSEGMENT2D( corners3DU[0],
421  corners3DU[1],
422  aClearanceValue * 2.0f * m_biuTo3Dunits,
423  *aPad ) );
424 
425  aDstContainer->Add( new CROUNDSEGMENT2D( corners3DU[1],
426  corners3DU[2],
427  aClearanceValue * 2.0f * m_biuTo3Dunits,
428  *aPad ) );
429 
430  aDstContainer->Add( new CROUNDSEGMENT2D( corners3DU[2],
431  corners3DU[3],
432  aClearanceValue * 2.0f * m_biuTo3Dunits,
433  *aPad ) );
434 
435  aDstContainer->Add( new CROUNDSEGMENT2D( corners3DU[3],
436  corners3DU[0],
437  aClearanceValue * 2.0f * m_biuTo3Dunits,
438  *aPad ) );
439  }
440  break;
441 
442  case PAD_SHAPE_ROUNDRECT:
443  {
444  const int pad_radius = aPad->GetRoundRectCornerRadius();
445  const int rounding_radius = pad_radius + aClearanceValue;
446 
447  wxSize shapesize( aPad->GetSize() );
448  shapesize.x += aClearanceValue * 2;
449  shapesize.y += aClearanceValue * 2;
450 
451  wxPoint corners[4];
452 
453  GetRoundRectCornerCenters( corners,
454  rounding_radius,
455  PadShapePos,
456  shapesize,
457  aPad->GetOrientation() );
458 
459  SFVEC2F corners3DU[4];
460 
461  for( unsigned int ii = 0; ii < 4; ++ii )
462  corners3DU[ii] = SFVEC2F( corners[ii].x * m_biuTo3Dunits,
463  -corners[ii].y * m_biuTo3Dunits );
464 
465  // Add the PAD polygon (For some reason the corners need
466  // to be inverted to display with the correctly orientation)
467  aDstContainer->Add( new CPOLYGON4PTS2D( corners3DU[0],
468  corners3DU[3],
469  corners3DU[2],
470  corners3DU[1],
471  *aPad ) );
472 
473  // Add the PAD contours
474  // !TODO: check the corners because it cannot add
475  // roundsegments that are in the same start and end position
476  aDstContainer->Add( new CROUNDSEGMENT2D( corners3DU[0],
477  corners3DU[1],
478  rounding_radius * 2.0f * m_biuTo3Dunits,
479  *aPad ) );
480 
481  aDstContainer->Add( new CROUNDSEGMENT2D( corners3DU[1],
482  corners3DU[2],
483  rounding_radius * 2.0f * m_biuTo3Dunits,
484  *aPad ) );
485 
486  aDstContainer->Add( new CROUNDSEGMENT2D( corners3DU[2],
487  corners3DU[3],
488  rounding_radius * 2.0f * m_biuTo3Dunits,
489  *aPad ) );
490 
491  aDstContainer->Add( new CROUNDSEGMENT2D( corners3DU[3],
492  corners3DU[0],
493  rounding_radius * 2.0f * m_biuTo3Dunits,
494  *aPad ) );
495  }
496  break;
497 
498  case PAD_SHAPE_CUSTOM:
499  {
500  SHAPE_POLY_SET polyList; // Will contain the pad outlines in board coordinates
501  polyList.Append( aPad->GetCustomShapeAsPolygon() );
502  aPad->CustomShapeAsPolygonToBoardPosition( &polyList, aPad->ShapePos(), aPad->GetOrientation() );
503 
504  if( aClearanceValue )
505  polyList.Inflate( aClearanceValue, 32 );
506 
507  // This convert the poly in outline and holes
508  polyList.Simplify( SHAPE_POLY_SET::PM_FAST );
510 
511  // Add the PAD polygon
512  Convert_shape_line_polygon_to_triangles( polyList, *aDstContainer, m_biuTo3Dunits, *aPad );
513 
514  }
515  break;
516  }
517 }
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:518
void RotatePoint(int *pX, int *pY, double angle)
Definition: trigo.cpp:216
PAD_SHAPE_T GetShape() const
Function GetShape.
Definition: class_pad.h:216
#define abs(a)
Definition: auxiliary.h:84
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.
void Convert_shape_line_polygon_to_triangles(const SHAPE_POLY_SET &aPolyList, CGENERICCONTAINER2D &aDstContainer, float aBiuTo3DunitsScale, const BOARD_ITEM &aBoardItem)
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
void Simplify(POLYGON_MODE aFastMode)
Simplifies the polyset (merges overlapping polys, eliminates degeneracy/self-intersections) For aFast...
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:51
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
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:500
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:209
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 58 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().

59 {
60  if( !m_layers_poly.empty() )
61  {
62  for( MAP_POLY::iterator ii = m_layers_poly.begin();
63  ii != m_layers_poly.end();
64  ++ii )
65  {
66  delete ii->second;
67  ii->second = NULL;
68  }
69 
70  m_layers_poly.clear();
71  }
72 
73  if( !m_layers_inner_holes_poly.empty() )
74  {
75  for( MAP_POLY::iterator ii = m_layers_inner_holes_poly.begin();
76  ii != m_layers_inner_holes_poly.end();
77  ++ii )
78  {
79  delete ii->second;
80  ii->second = NULL;
81  }
82 
84  }
85 
86  if( !m_layers_outer_holes_poly.empty() )
87  {
88  for( MAP_POLY::iterator ii = m_layers_outer_holes_poly.begin();
89  ii != m_layers_outer_holes_poly.end();
90  ++ii )
91  {
92  delete ii->second;
93  ii->second = NULL;
94  }
95 
97  }
98 
99  if( !m_layers_container2D.empty() )
100  {
101  for( MAP_CONTAINER_2D::iterator ii = m_layers_container2D.begin();
102  ii != m_layers_container2D.end();
103  ++ii )
104  {
105  delete ii->second;
106  ii->second = NULL;
107  }
108 
109  m_layers_container2D.clear();
110  }
111 
112  if( !m_layers_holes2D.empty() )
113  {
114  for( MAP_CONTAINER_2D::iterator ii = m_layers_holes2D.begin();
115  ii != m_layers_holes2D.end();
116  ++ii )
117  {
118  delete ii->second;
119  ii->second = NULL;
120  }
121 
122  m_layers_holes2D.clear();
123  }
124 
131  //m_through_inner_holes_poly.RemoveAllContours();
132 
135 }
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 263 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().

264 {
265  wxASSERT( aNrSides >= 3 );
266 
267  return GetCircletoPolyCorrectionFactor( aNrSides );
268 }
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 523 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().

524 {
525  return SFVEC3F( aColor.r, aColor.g, aColor.b );
526 }
double g
Green component.
Definition: color4d.h:292
double b
Blue component.
Definition: color4d.h:293
glm::vec3 SFVEC3F
Definition: xv3d_types.h:47
double r
Red component.
Definition: color4d.h:291
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 517 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().

518 {
519  return GetColor( m_board->Colors().GetItemColor( aItemId ) );
520 }
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:563
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 507 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().

508 {
509  wxASSERT( aLayerId < PCB_LAYER_ID_COUNT );
510 
511  const COLOR4D color = m_board->Colors().GetLayerColor( aLayerId );
512 
513  return SFVEC3F( color.r, color.g, color.b );
514 }
int color
Definition: DXF_plotter.cpp:62
double g
Green component.
Definition: color4d.h:292
BOARD * m_board
Current board.
Definition: cinfo3d_visu.h:515
double b
Blue component.
Definition: color4d.h:293
const COLORS_DESIGN_SETTINGS & Colors() const
Function GetColorSettings.
Definition: class_board.h:563
glm::vec3 SFVEC3F
Definition: xv3d_types.h:47
COLOR4D GetLayerColor(LAYER_NUM aLayer) const
Function GetLayerColor.
double r
Red component.
Definition: color4d.h:291
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 472 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().

473 {
474  if( aIsFlipped )
475  {
476  if( GetFlag( FL_SOLDERPASTE ) )
478  else
480  }
481  else
482  {
483  if( GetFlag( FL_SOLDERPASTE ) )
484  return m_layerZcoordTop[F_SilkS];
485  else
486  return m_layerZcoordTop[F_Paste];
487  }
488 }
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().

256 {
257  wxASSERT( aDiameterBIU > 0 );
258 
259  return GetArcToSegmentCount( aDiameterBIU / 2, ARC_HIGH_DEF, 360.0 );
260 }
int GetArcToSegmentCount(int aRadius, int aErrorMax, double aArcAngleDegree)
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 271 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().

272 {
273  wxLogTrace( m_logTrace, wxT( "CINFO3D_VISU::InitSettings" ) );
274 
275  // Calculates the board bounding box
276  // First, use only the board outlines
277  EDA_RECT bbbox = m_board->ComputeBoundingBox( true );
278 
279  // If no outlines, use the board with items
280  if( ( bbbox.GetWidth() == 0 ) && ( bbbox.GetHeight() == 0 ) )
281  bbbox = m_board->ComputeBoundingBox( false );
282 
283  // Gives a non null size to avoid issues in zoom / scale calculations
284  if( ( bbbox.GetWidth() == 0 ) && ( bbbox.GetHeight() == 0 ) )
285  bbbox.Inflate( Millimeter2iu( 10 ) );
286 
287  m_boardSize = bbbox.GetSize();
288  m_boardPos = bbbox.Centre();
289 
290  wxASSERT( (m_boardSize.x > 0) && (m_boardSize.y > 0) );
291 
292  m_boardPos.y = -m_boardPos.y; // The y coord is inverted in 3D viewer
293 
295 
296  // Ensure the board has 2 sides for 3D views, because it is hard to find
297  // a *really* single side board in the true life...
298  if( m_copperLayersCount < 2 )
300 
301  // Calculate the convertion to apply to all positions.
303 
306 
307  // !TODO: use value defined by user (currently use default values by ctor
310 
311  // Init Z position of each layer
312  // calculate z position for each copper layer
313  // Zstart = -m_epoxyThickness / 2.0 is the z position of the back (bottom layer) (layer id = 31)
314  // Zstart = +m_epoxyThickness / 2.0 is the z position of the front (top layer) (layer id = 0)
315  // all unused copper layer z position are set to 0
316 
317  // ____==__________==________==______ <- Bottom = +m_epoxyThickness / 2.0,
318  // | | Top = Bottom + m_copperThickness
319  // |__________________________________|
320  // == == == == <- Bottom = -m_epoxyThickness / 2.0,
321  // Top = Bottom - m_copperThickness
322 
323  unsigned int layer;
324 
325  for( layer = 0; layer < m_copperLayersCount; ++layer )
326  {
327  m_layerZcoordBottom[layer] = m_epoxyThickness3DU / 2.0f -
328  (m_epoxyThickness3DU * layer / (m_copperLayersCount - 1) );
329 
330  if( layer < (m_copperLayersCount / 2) )
332  else
334  }
335 
336  #define layerThicknessMargin 1.1
337  const float zpos_offset = m_nonCopperLayerThickness3DU * layerThicknessMargin;
338 
339  // Fill remaining unused copper layers and back layer zpos
340  // with -m_epoxyThickness / 2.0
341  for( ; layer < MAX_CU_LAYERS; layer++ )
342  {
343  m_layerZcoordBottom[layer] = -(m_epoxyThickness3DU / 2.0f);
345  }
346 
347  // This is the top of the copper layer thickness.
348  const float zpos_copperTop_back = m_layerZcoordTop[B_Cu];
349  const float zpos_copperTop_front = m_layerZcoordTop[F_Cu];
350 
351  // calculate z position for each non copper layer
352  // Solder mask and Solder paste have the same Z position
353  for( int layer_id = MAX_CU_LAYERS; layer_id < PCB_LAYER_ID_COUNT; ++layer_id )
354  {
355  float zposTop;
356  float zposBottom;
357 
358  switch( layer_id )
359  {
360  case B_Adhes:
361  zposBottom = zpos_copperTop_back - 2.0f * zpos_offset;
362  zposTop = zposBottom - m_nonCopperLayerThickness3DU;
363  break;
364 
365  case F_Adhes:
366  zposBottom = zpos_copperTop_front + 2.0f * zpos_offset;
367  zposTop = zposBottom + m_nonCopperLayerThickness3DU;
368  break;
369 
370  case B_Mask:
371  case B_Paste:
372  zposBottom = zpos_copperTop_back;
373  zposTop = zpos_copperTop_back - m_nonCopperLayerThickness3DU;
374  break;
375 
376  case F_Mask:
377  case F_Paste:
378  zposTop = zpos_copperTop_front + m_nonCopperLayerThickness3DU;
379  zposBottom = zpos_copperTop_front;
380  break;
381 
382  case B_SilkS:
383  zposBottom = zpos_copperTop_back - 1.0f * zpos_offset;
384  zposTop = zposBottom - m_nonCopperLayerThickness3DU;
385  break;
386 
387  case F_SilkS:
388  zposBottom = zpos_copperTop_front + 1.0f * zpos_offset;
389  zposTop = zposBottom + m_nonCopperLayerThickness3DU;
390  break;
391 
392  // !TODO: review
393  default:
394  zposTop = zpos_copperTop_front + (layer_id - MAX_CU_LAYERS + 3.0f) * zpos_offset;
395  zposBottom = zposTop - m_nonCopperLayerThickness3DU;
396  break;
397  }
398 
399  m_layerZcoordTop[layer_id] = zposTop;
400  m_layerZcoordBottom[layer_id] = zposBottom;
401  }
402 
403  m_boardCenter = SFVEC3F( m_boardPos.x * m_biuTo3Dunits,
404  m_boardPos.y * m_biuTo3Dunits,
405  0.0f );
406 
407  SFVEC3F boardSize = SFVEC3F( m_boardSize.x * m_biuTo3Dunits,
408  m_boardSize.y * m_biuTo3Dunits,
409  0.0f );
410  boardSize /= 2.0f;
411 
412  SFVEC3F boardMin = (m_boardCenter - boardSize);
413  SFVEC3F boardMax = (m_boardCenter + boardSize);
414 
415  boardMin.z = m_layerZcoordTop[B_Adhes];
416  boardMax.z = m_layerZcoordTop[F_Adhes];
417 
418  m_boardBoudingBox = CBBOX( boardMin, boardMax );
419 
420 #ifdef PRINT_STATISTICS_3D_VIEWER
421  unsigned stats_startCreateBoardPolyTime = GetRunningMicroSecs();
422 #endif
423 
424  if( aStatusTextReporter )
425  aStatusTextReporter->Report( _( "Build board body" ) );
426 
428 
429 #ifdef PRINT_STATISTICS_3D_VIEWER
430  unsigned stats_stopCreateBoardPolyTime = GetRunningMicroSecs();
431  unsigned stats_startCreateLayersTime = stats_stopCreateBoardPolyTime;
432 #endif
433 
434  if( aStatusTextReporter )
435  aStatusTextReporter->Report( _( "Create layers" ) );
436 
437  createLayers( aStatusTextReporter );
438 
439 #ifdef PRINT_STATISTICS_3D_VIEWER
440  unsigned stats_stopCreateLayersTime = GetRunningMicroSecs();
441 
442  printf( "CINFO3D_VISU::InitSettings times\n" );
443  printf( " CreateBoardPoly: %.3f ms\n",
444  (float)( stats_stopCreateBoardPolyTime - stats_startCreateBoardPolyTime ) / 1e3 );
445  printf( " CreateLayers and holes: %.3f ms\n",
446  (float)( stats_stopCreateLayersTime - stats_startCreateLayersTime ) / 1e3 );
447  printf( "\n" );
448 #endif
449 }
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:532
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:532
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(), Get3DCacheManager(), EDA_3D_VIEWER::LoadSettings(), 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 681 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().

688 {
689  wxPoint arc_start, arc_end;
690  int delta = 3600 / aCircleToSegmentsCount; // rotate angle in 0.1 degree
691 
692  arc_end = arc_start = aStart;
693 
694  if( aArcAngle != 3600 )
695  {
696  RotatePoint( &arc_end, aCentre, -aArcAngle );
697  }
698 
699  if( aArcAngle < 0 )
700  {
701  std::swap( arc_start, arc_end );
702  aArcAngle = -aArcAngle;
703  }
704 
705  // Compute the ends of segments and creates poly
706  wxPoint curr_end = arc_start;
707  wxPoint curr_start = arc_start;
708 
709  for( int ii = delta; ii < aArcAngle; ii += delta )
710  {
711  curr_end = arc_start;
712  RotatePoint( &curr_end, aCentre, -ii );
713 
714  const SFVEC2F start3DU( curr_start.x * m_biuTo3Dunits, -curr_start.y * m_biuTo3Dunits );
715  const SFVEC2F end3DU ( curr_end.x * m_biuTo3Dunits, -curr_end.y * m_biuTo3Dunits );
716 
717  if( Is_segment_a_circle( start3DU, end3DU ) )
718  {
719  aDstContainer->Add( new CFILLEDCIRCLE2D( start3DU,
720  ( aWidth / 2 ) * m_biuTo3Dunits,
721  aBoardItem ) );
722  }
723  else
724  {
725  aDstContainer->Add( new CROUNDSEGMENT2D( start3DU,
726  end3DU,
727  aWidth * m_biuTo3Dunits,
728  aBoardItem ) );
729  }
730 
731  curr_start = curr_end;
732  }
733 
734  if( curr_end != arc_end )
735  {
736  const SFVEC2F start3DU( curr_end.x * m_biuTo3Dunits, -curr_end.y * m_biuTo3Dunits );
737  const SFVEC2F end3DU ( arc_end.x * m_biuTo3Dunits, -arc_end.y * m_biuTo3Dunits );
738 
739  if( Is_segment_a_circle( start3DU, end3DU ) )
740  {
741  aDstContainer->Add( new CFILLEDCIRCLE2D( start3DU,
742  ( aWidth / 2 ) * m_biuTo3Dunits,
743  aBoardItem ) );
744  }
745  else
746  {
747  aDstContainer->Add( new CROUNDSEGMENT2D( start3DU,
748  end3DU,
749  aWidth * m_biuTo3Dunits,
750  aBoardItem ) );
751  }
752  }
753 }
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:51
void CINFO3D_VISU::transformGraphicModuleEdgeToPolygonSet ( const MODULE aModule,
PCB_LAYER_ID  aLayer,
SHAPE_POLY_SET aCornerBuffer 
) const
private

Definition at line 199 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().

202 {
203  for( const EDA_ITEM* item = aModule->GraphicalItemsList();
204  item != NULL;
205  item = item->Next() )
206  {
207  switch( item->Type() )
208  {
209  case PCB_MODULE_EDGE_T:
210  {
211  EDGE_MODULE*outline = (EDGE_MODULE*) item;
212 
213  if( outline->GetLayer() != aLayer )
214  break;
215 
216  unsigned int aCircleToSegmentsCount =
218 
219  double aCorrectionFactor = GetCircleCorrectionFactor( aCircleToSegmentsCount );
220 
221  outline->TransformShapeWithClearanceToPolygon( aCornerBuffer,
222  0,
223  aCircleToSegmentsCount,
224  aCorrectionFactor );
225  }
226  break;
227 
228  default:
229  break;
230  }
231  }
232 }
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) const override
Function TransformShapeWithClearanceToPolygon Convert the track shape to a closed polygon Used in fil...
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:162
DLIST< BOARD_ITEM > & GraphicalItemsList()
Definition: class_module.h:164
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 134 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().

138 {
139  const D_PAD* pad = aPads;
140 
141  wxSize margin;
142  for( ; pad != NULL; pad = pad->Next() )
143  {
144  if( !pad->IsOnLayer(aLayer) )
145  continue;
146 
147  // NPTH pads are not drawn on layers if the shape size and pos is the same
148  // as their hole:
149  if( aSkipNPTHPadsWihNoCopper && (pad->GetAttribute() == PAD_ATTRIB_HOLE_NOT_PLATED) )
150  {
151  if( (pad->GetDrillSize() == pad->GetSize()) &&
152  (pad->GetOffset() == wxPoint( 0, 0 )) )
153  {
154  switch( pad->GetShape() )
155  {
156  case PAD_SHAPE_CIRCLE:
157  if( pad->GetDrillShape() == PAD_DRILL_SHAPE_CIRCLE )
158  continue;
159  break;
160 
161  case PAD_SHAPE_OVAL:
162  if( pad->GetDrillShape() != PAD_DRILL_SHAPE_CIRCLE )
163  continue;
164  break;
165 
166  default:
167  break;
168  }
169  }
170  }
171 
172  switch( aLayer )
173  {
174  case F_Mask:
175  case B_Mask:
176  margin.x = margin.y = pad->GetSolderMaskMargin() + aInflateValue;
177  break;
178 
179  case F_Paste:
180  case B_Paste:
181  margin = pad->GetSolderPasteMargin();
182  margin.x += aInflateValue;
183  margin.y += aInflateValue;
184  break;
185 
186  default:
187  margin.x = margin.y = aInflateValue;
188  break;
189  }
190 
191  unsigned int aCircleToSegmentsCount = GetNrSegmentsCircle( pad->GetSize().x );
192  double aCorrectionFactor = GetCircleCorrectionFactor( aCircleToSegmentsCount );
193 
194  buildPadShapePolygon( pad, aCornerBuffer, margin,
195  aCircleToSegmentsCount, aCorrectionFactor );
196  }
197 }
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:577
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:610
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:644
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

Current board.

Definition at line 515 of file cinfo3d_visu.h.

Referenced by CINFO3D_VISU(), createBoardPolygon(),