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 aDiameterBUI) 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();
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:93
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_layer_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::GraphicalItems(), 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().

183 {
184  std::vector<TEXTE_MODULE *> texts; // List of TEXTE_MODULE to convert
185  EDGE_MODULE* outline;
186 
187  for( EDA_ITEM* item = aModule->GraphicalItems();
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)
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), PLOTTER *aPlotter)
Function DrawGraphicText Draw a graphic text (like module texts)
Definition: drawtxt.cpp:122
static const CBBOX2D * s_boardBBox3DU
TEXTE_MODULE & Reference()
Definition: class_module.h:456
double GetDrawRotation() const
const wxPoint & GetTextPos() const
Definition: eda_text.h:224
bool IsItalic() const
Definition: eda_text.h:170
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 wxString GetShownText() const override
Returns the string actually shown after processing of the base text.
static const BOARD_ITEM * s_boardItem
EDA_TEXT_HJUSTIFY_T GetHorizJustify() const
Definition: eda_text.h:190
class EDGE_MODULE, a footprint edge
Definition: typeinfo.h:106
DLIST< BOARD_ITEM > & GraphicalItems()
Definition: class_module.h:137
int GetThickness() const
Function GetThickness returns pen width.
Definition: eda_text.h:154
void addTextSegmToContainer(int x0, int y0, int xf, int yf)
BOARD_ITEM * Next() const
static float s_biuTo3Dunits
TEXTE_MODULE & Value()
read/write accessors:
Definition: class_module.h:455
double m_biuTo3Dunits
Normalization scale to convert board internal units to 3D units to normalize 3D units between -1...
Definition: cinfo3d_visu.h:616
class TEXTE_MODULE, text in a footprint
Definition: typeinfo.h:105
EDA_TEXT_VJUSTIFY_T GetVertJustify() const
Definition: eda_text.h:191
PCB_LAYER_ID GetLayer() const
Function GetLayer returns the primary layer this item is on.
bool IsMirrored() const
Definition: eda_text.h:179
bool IsVisible() const
Definition: eda_text.h:176
Class EDA_ITEM is a base class for most all the KiCad significant classes, used in schematics and boa...
Definition: base_struct.h:151
static int s_textWidth
Definition: colors.h:45
const wxSize & GetTextSize() const
Definition: eda_text.h:215
static CGENERICCONTAINER2D * s_dstcontainer
void CINFO3D_VISU::AddPadsShapesWithClearanceToContainer ( const MODULE aModule,
CGENERICCONTAINER2D aDstContainer,
PCB_LAYER_ID  aLayerId,
int  aInflateValue,
bool  aSkipNPTHPadsWihNoCopper 
)
private

Definition at line 604 of file create_layer_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::Pads().

Referenced by createLayers().

609 {
610  const D_PAD* pad = aModule->Pads();
611 
612  wxSize margin;
613 
614  for( ; pad != NULL; pad = pad->Next() )
615  {
616  if( !pad->IsOnLayer( aLayerId ) )
617  continue;
618 
619  // NPTH pads are not drawn on layers if the
620  // shape size and pos is the same as their hole:
621  if( aSkipNPTHPadsWihNoCopper && (pad->GetAttribute() == PAD_ATTRIB_HOLE_NOT_PLATED) )
622  {
623  if( (pad->GetDrillSize() == pad->GetSize()) &&
624  (pad->GetOffset() == wxPoint( 0, 0 )) )
625  {
626  switch( pad->GetShape() )
627  {
628  case PAD_SHAPE_CIRCLE:
629  if( pad->GetDrillShape() == PAD_DRILL_SHAPE_CIRCLE )
630  continue;
631  break;
632 
633  case PAD_SHAPE_OVAL:
634  if( pad->GetDrillShape() != PAD_DRILL_SHAPE_CIRCLE )
635  continue;
636  break;
637 
638  default:
639  break;
640  }
641  }
642  }
643 
644  switch( aLayerId )
645  {
646  case F_Mask:
647  case B_Mask:
648  margin.x = margin.y = pad->GetSolderMaskMargin() + aInflateValue;
649  break;
650 
651  case F_Paste:
652  case B_Paste:
653  margin = pad->GetSolderPasteMargin();
654  margin.x += aInflateValue;
655  margin.y += aInflateValue;
656  break;
657 
658  default:
659  margin.x = margin.y = aInflateValue;
660  break;
661  }
662 
663  createNewPad( pad, aDstContainer, margin );
664  }
665 }
PAD_ATTR_T GetAttribute() const
Definition: class_pad.h:238
like PAD_STANDARD, but not plated mechanical use only, no connection allowed
Definition: pad_shapes.h:63
PAD_DRILL_SHAPE_T GetDrillShape() const
Definition: class_pad.h:221
const wxSize & GetDrillSize() const
Definition: class_pad.h:188
PAD_SHAPE_T GetShape() const
Function GetShape.
Definition: class_pad.h:166
int GetSolderMaskMargin() const
Function GetSolderMaskMargin.
Definition: class_pad.cpp:486
D_PAD * Next() const
Definition: class_pad.h:106
const wxSize & GetSize() const
Definition: class_pad.h:182
wxSize GetSolderPasteMargin() const
Function GetSolderPasteMargin.
Definition: class_pad.cpp:519
DLIST< D_PAD > & Pads()
Definition: class_module.h:134
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:479
const wxPoint & GetOffset() const
Definition: class_pad.h:191
void CINFO3D_VISU::AddShapeWithClearanceToContainer ( const TEXTE_PCB aTextPCB,
CGENERICCONTAINER2D aDstContainer,
PCB_LAYER_ID  aLayerId,
int  aClearanceValue 
)
private

Definition at line 92 of file create_layer_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(), and createLayers().

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:137
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), PLOTTER *aPlotter)
Function DrawGraphicText Draw a graphic text (like module texts)
Definition: drawtxt.cpp:122
static const CBBOX2D * s_boardBBox3DU
bool IsMultilineAllowed() const
Definition: eda_text.h:188
const wxPoint & GetTextPos() const
Definition: eda_text.h:224
bool IsItalic() const
Definition: eda_text.h:170
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
static const BOARD_ITEM * s_boardItem
EDA_TEXT_HJUSTIFY_T GetHorizJustify() const
Definition: eda_text.h:190
double GetTextAngle() const
Definition: eda_text.h:164
int GetThickness() const
Function GetThickness returns pen width.
Definition: eda_text.h:154
void addTextSegmToContainer(int x0, int y0, int xf, int yf)
virtual wxString GetShownText() const
Returns the string actually shown after processing of the base text.
Definition: eda_text.h:135
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
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:327
EDA_TEXT_VJUSTIFY_T GetVertJustify() const
Definition: eda_text.h:191
bool IsMirrored() const
Definition: eda_text.h:179
static int s_textWidth
Definition: colors.h:45
const wxSize & GetTextSize() const
Definition: eda_text.h:215
static CGENERICCONTAINER2D * s_dstcontainer
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 746 of file create_layer_items.cpp.

References CGENERICCONTAINER2D::Add(), SHAPE_POLY_SET::AddOutline(), SHAPE_LINE_CHAIN::Append(), Convert_shape_line_polygon_to_triangles(), DRAWSEGMENT::GetAngle(), DRAWSEGMENT::GetArcStart(), DRAWSEGMENT::GetBoundingBox(), DRAWSEGMENT::GetCenter(), DRAWSEGMENT::GetEnd(), GetNrSegmentsCircle(), MODULE::GetOrientation(), DRAWSEGMENT::GetParentModule(), DRAWSEGMENT::GetPolyPoints(), DRAWSEGMENT::GetPosition(), 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, RotatePoint(), S_ARC, S_CIRCLE, S_CURVE, S_POLYGON, S_SEGMENT, SHAPE_LINE_CHAIN::SetClosed(), SHAPE_POLY_SET::Simplify(), TransformArcToSegments(), wxPoint::x, and wxPoint::y.

750 {
751  // The full width of the lines to create:
752  const int linewidth = aDrawSegment->GetWidth() + (2 * aClearanceValue);
753 
754  switch( aDrawSegment->GetShape() )
755  {
756  case S_CIRCLE:
757  {
758  const SFVEC2F center3DU( aDrawSegment->GetCenter().x * m_biuTo3Dunits,
759  -aDrawSegment->GetCenter().y * m_biuTo3Dunits );
760 
761  const float inner_radius = (aDrawSegment->GetRadius() - linewidth / 2) * m_biuTo3Dunits;
762  const float outter_radius = (aDrawSegment->GetRadius() + linewidth / 2) * m_biuTo3Dunits;
763 
764  aDstContainer->Add( new CRING2D( center3DU,
765  inner_radius,
766  outter_radius,
767  *aDrawSegment ) );
768  }
769  break;
770 
771  case S_ARC:
772  {
773  const unsigned int nr_segments =
774  GetNrSegmentsCircle( aDrawSegment->GetBoundingBox().GetSizeMax() );
775 
776  TransformArcToSegments( aDrawSegment->GetCenter(),
777  aDrawSegment->GetArcStart(),
778  aDrawSegment->GetAngle(),
779  nr_segments,
780  aDrawSegment->GetWidth(),
781  aDstContainer,
782  *aDrawSegment );
783  }
784  break;
785 
786  case S_SEGMENT:
787  {
788  const SFVEC2F start3DU( aDrawSegment->GetStart().x * m_biuTo3Dunits,
789  -aDrawSegment->GetStart().y * m_biuTo3Dunits );
790 
791  const SFVEC2F end3DU ( aDrawSegment->GetEnd().x * m_biuTo3Dunits,
792  -aDrawSegment->GetEnd().y * m_biuTo3Dunits );
793 
794  if( Is_segment_a_circle( start3DU, end3DU ) )
795  {
796  aDstContainer->Add( new CFILLEDCIRCLE2D( start3DU,
797  ( linewidth / 2 ) * m_biuTo3Dunits,
798  *aDrawSegment ) );
799  }
800  else
801  {
802  aDstContainer->Add( new CROUNDSEGMENT2D( start3DU,
803  end3DU,
804  linewidth * m_biuTo3Dunits,
805  *aDrawSegment ) );
806  }
807  }
808  break;
809 
810  case S_POLYGON:
811  {
812  // Check for malformed polygon.
813  if( aDrawSegment->GetPolyPoints().size() > 2 )
814  {
815  // The polygon is expected to be a simple polygon
816  // not self intersecting, no hole.
817  MODULE* module = aDrawSegment->GetParentModule(); // NULL for items not in footprints
818  const double orientation = module ? module->GetOrientation() : 0.0;
819 
820  // Build the polygon with the actual position and orientation:
821  std::vector< wxPoint> poly;
822  poly = aDrawSegment->GetPolyPoints();
823 
824  for( unsigned ii = 0; ii < poly.size(); ++ii )
825  {
826  RotatePoint( &poly[ii], orientation );
827  poly[ii] += aDrawSegment->GetPosition();
828  }
829 
830  // Generate polygons for the outline + clearance
831 
832  if( linewidth ) // Add thick outlines
833  {
834  CPolyPt corner1( poly[poly.size()-1] );
835 
836  for( unsigned ii = 0; ii < poly.size(); ++ii )
837  {
838  CPolyPt corner2( poly[ii] );
839 
840  if( corner2 != corner1 )
841  {
842  const SFVEC2F start3DU( corner1.x * m_biuTo3Dunits,
843  -corner1.y * m_biuTo3Dunits );
844 
845  const SFVEC2F end3DU( corner2.x * m_biuTo3Dunits,
846  -corner2.y * m_biuTo3Dunits );
847 
848  if( Is_segment_a_circle( start3DU, end3DU ) )
849  {
850  aDstContainer->Add(
851  new CFILLEDCIRCLE2D( start3DU,
852  (linewidth / 2) * m_biuTo3Dunits,
853  *aDrawSegment ) );
854  }
855  else
856  {
857  aDstContainer->Add( new CROUNDSEGMENT2D( start3DU,
858  end3DU,
859  linewidth * m_biuTo3Dunits,
860  *aDrawSegment ) );
861  }
862  }
863 
864  corner1 = corner2;
865  }
866  }
867 
868  // Polygon for the inside
869  SHAPE_LINE_CHAIN path;
870 
871  for( unsigned ii = 0; ii < poly.size(); ++ii )
872  {
873  wxPoint corner = poly[ii];
874  path.Append( corner.x, corner.y );
875  }
876 
877  path.SetClosed( true );
878 
879  SHAPE_POLY_SET polyList;
880 
881  polyList.AddOutline( path );
882 
883  // This convert the poly in outline and holes
884  polyList.Simplify( SHAPE_POLY_SET::PM_FAST );
886 
887  if( polyList.IsEmpty() ) // Just for caution
888  break;
889 
891  *aDstContainer,
893  *aDrawSegment );
894  }
895  }
896  break;
897 
898  case S_CURVE: // Bezier curve (not yet in use in KiCad)
899  break;
900 
901  default:
902  break;
903  }
904 }
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 std::vector< wxPoint > & GetPolyPoints() const
void RotatePoint(int *pX, int *pY, double angle)
Definition: trigo.cpp:317
void Append(int aX, int aY, bool aAllowDuplication=false)
Function Append()
const wxPoint & GetArcStart() const
void SetClosed(bool aClosed)
Function SetClosed()
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
double GetOrientation() const
Definition: class_module.h:148
Class SHAPE_POLY_SET.
Arcs (with rounded ends)
int GetSizeMax() const
GetSizeMax.
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.
int AddOutline(const SHAPE_LINE_CHAIN &aOutline)
Adds a new outline to the set and returns its index
void Add(COBJECT2D *aObject)
Definition: ccontainer2d.h:51
double GetAngle() const
Class SHAPE_LINE_CHAIN.
int GetWidth() const
MODULE * GetParentModule() const
Function GetParentModule returns a pointer to the parent module, or NULL if DRAWSEGMENT does not belo...
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.
const wxPoint & GetPosition() const override
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_layer_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 910 of file create_layer_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(), 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().

913 {
914  // Copy the polys list because we have to simplify it
915  SHAPE_POLY_SET polyList = SHAPE_POLY_SET(aZoneContainer->GetFilledPolysList());
916 
917  // This convert the poly in outline and holes
918 
919  // Note: This two sequencial calls are need in order to get
920  // the triangulation function to work properly.
921  polyList.Simplify( SHAPE_POLY_SET::PM_FAST );
923 
924  if( polyList.IsEmpty() )
925  return;
926 
928  *aDstContainer,
930  *aZoneContainer );
931 
932 
933  // add filled areas outlines, which are drawn with thick lines segments
934  // /////////////////////////////////////////////////////////////////////////
935  for( int i = 0; i < polyList.OutlineCount(); ++i )
936  {
937  // Add outline
938  const SHAPE_LINE_CHAIN& pathOutline = polyList.COutline( i );
939 
940  for( int j = 0; j < pathOutline.PointCount(); ++j )
941  {
942  const VECTOR2I& a = pathOutline.CPoint( j );
943  const VECTOR2I& b = pathOutline.CPoint( j + 1 );
944 
945  SFVEC2F start3DU( a.x * m_biuTo3Dunits, -a.y * m_biuTo3Dunits );
946  SFVEC2F end3DU ( b.x * m_biuTo3Dunits, -b.y * m_biuTo3Dunits );
947 
948  if( Is_segment_a_circle( start3DU, end3DU ) )
949  {
950  aDstContainer->Add( new CFILLEDCIRCLE2D( start3DU,
951  (aZoneContainer->GetMinThickness() / 2) *
953  *aZoneContainer ) );
954  }
955  else
956  {
957  aDstContainer->Add( new CROUNDSEGMENT2D( start3DU, end3DU,
958  aZoneContainer->GetMinThickness() *
960  *aZoneContainer ) );
961  }
962  }
963 
964  // Add holes (of the poly, ie: the open parts) for this outline
965  for( int h = 0; h < polyList.HoleCount( i ); ++h )
966  {
967  const SHAPE_LINE_CHAIN& pathHole = polyList.CHole( i, h );
968 
969  for( int j = 0; j < pathHole.PointCount(); j++ )
970  {
971  const VECTOR2I& a = pathHole.CPoint( j );
972  const VECTOR2I& b = pathHole.CPoint( j + 1 );
973 
974  SFVEC2F start3DU( a.x * m_biuTo3Dunits, -a.y * m_biuTo3Dunits );
975  SFVEC2F end3DU ( b.x * m_biuTo3Dunits, -b.y * m_biuTo3Dunits );
976 
977  if( Is_segment_a_circle( start3DU, end3DU ) )
978  {
979  aDstContainer->Add(
980  new CFILLEDCIRCLE2D( start3DU,
981  (aZoneContainer->GetMinThickness() / 2) *
983  *aZoneContainer ) );
984  }
985  else
986  {
987  aDstContainer->Add(
988  new CROUNDSEGMENT2D( start3DU, end3DU,
989  aZoneContainer->GetMinThickness() *
991  *aZoneContainer ) );
992  }
993  }
994  }
995  }
996 }
int GetMinThickness() const
Definition: class_zone.h:209
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:587
void Add(COBJECT2D *aObject)
Definition: ccontainer2d.h:51
Class SHAPE_LINE_CHAIN.
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(), D_PAD::BuildPadPolygon(), D_PAD::GetOrientation(), D_PAD::GetShape(), PAD_SHAPE_CIRCLE, 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(), 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  default:
79  wxFAIL_MSG( wxT( "CINFO3D_VISU::buildPadShapePolygon: found a not implemented pad shape (new shape?)" ) );
80  break;
81  }
82 }
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:166
void Append(int aX, int aY, bool aAllowDuplication=false)
Function Append()
void SetClosed(bool aClosed)
Function SetClosed()
void TransformShapeWithClearanceToPolygon(SHAPE_POLY_SET &aCornerBuffer, int aClearanceValue, int aCircleToSegmentsCount, double aCorrectionFactor) const
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:214
wxPoint ShapePos() const
Definition: class_pad.cpp:367
void CINFO3D_VISU::buildPadShapeThickOutlineAsPolygon ( const D_PAD aPad,
SHAPE_POLY_SET aCornerBuffer,
int  aWidth 
) const
private

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

88 {
89  if( aPad->GetShape() == PAD_SHAPE_CIRCLE ) // Draw a ring
90  {
91  unsigned int nr_sides_per_circle = GetNrSegmentsCircle( ( aPad->GetSize().x / 2 +
92  aWidth / 2 ) * 2 );
93 
94  TransformRingToPolygon( aCornerBuffer, aPad->ShapePos(),
95  aPad->GetSize().x / 2, nr_sides_per_circle, aWidth );
96  return;
97  }
98 
99  // For other shapes, draw polygon outlines
100  SHAPE_POLY_SET corners;
101 
102  unsigned int nr_sides_per_circle = GetNrSegmentsCircle( glm::min( aPad->GetSize().x,
103  aPad->GetSize().y) );
104 
105  buildPadShapePolygon( aPad, corners, wxSize( 0, 0 ),
106  nr_sides_per_circle, GetCircleCorrectionFactor( nr_sides_per_circle ) );
107 
108  // Add outlines as thick segments in polygon buffer
109 
110  const SHAPE_LINE_CHAIN& path = corners.COutline( 0 );
111 
112  for( int ii = 0; ii < path.PointCount(); ++ii )
113  {
114  const VECTOR2I& a = path.CPoint( ii );
115  const VECTOR2I& b = path.CPoint( ii + 1 );
116 
118  wxPoint( a.x, a.y ),
119  wxPoint( b.x, b.y ),
120  nr_sides_per_circle,
121  aWidth );
122  }
123 }
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:166
Class SHAPE_POLY_SET.
const wxSize & GetSize() const
Definition: class_pad.h:182
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:367
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 1000 of file create_layer_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().

1003 {
1004  if( aPad->GetShape() == PAD_SHAPE_CIRCLE ) // Draw a ring
1005  {
1006  const SFVEC2F center3DU( aPad->ShapePos().x * m_biuTo3Dunits,
1007  -aPad->ShapePos().y * m_biuTo3Dunits );
1008 
1009  const int radius = aPad->GetSize().x / 2;
1010  const float inner_radius = (radius - aWidth / 2) * m_biuTo3Dunits;
1011  const float outter_radius = (radius + aWidth / 2) * m_biuTo3Dunits;
1012 
1013  aDstContainer->Add( new CRING2D( center3DU,
1014  inner_radius,
1015  outter_radius,
1016  *aPad ) );
1017 
1018  return;
1019  }
1020 
1021  // For other shapes, draw polygon outlines
1022  SHAPE_POLY_SET corners;
1023 
1024  const int segcountforcircle = GetNrSegmentsCircle( glm::min( aPad->GetSize().x,
1025  aPad->GetSize().y) );
1026 
1027  const double correctionFactor = GetCircleCorrectionFactor( segcountforcircle );
1028 
1029  aPad->BuildPadShapePolygon( corners, wxSize( 0, 0 ),
1030  // This two factors are only expected to be used if render an oval
1031  segcountforcircle, correctionFactor );
1032 
1033 
1034  // Add outlines as thick segments in polygon buffer
1035 
1036  const SHAPE_LINE_CHAIN& path = corners.COutline( 0 );
1037 
1038  for( int j = 0; j < path.PointCount(); j++ )
1039  {
1040  const VECTOR2I& a = path.CPoint( j );
1041  const VECTOR2I& b = path.CPoint( j + 1 );
1042 
1043  SFVEC2F start3DU( a.x * m_biuTo3Dunits, -a.y * m_biuTo3Dunits );
1044  SFVEC2F end3DU ( b.x * m_biuTo3Dunits, -b.y * m_biuTo3Dunits );
1045 
1046  if( Is_segment_a_circle( start3DU, end3DU ) )
1047  {
1048  aDstContainer->Add( new CFILLEDCIRCLE2D( start3DU,
1049  (aWidth / 2) * m_biuTo3Dunits,
1050  *aPad ) );
1051  }
1052  else
1053  {
1054  aDstContainer->Add( new CROUNDSEGMENT2D( start3DU, end3DU,
1055  aWidth * m_biuTo3Dunits,
1056  *aPad ) );
1057  }
1058  }
1059 }
int PointCount() const
Function PointCount()
PAD_SHAPE_T GetShape() const
Function GetShape.
Definition: class_pad.h:166
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:182
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:367
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 513 of file cinfo3d_visu.cpp.

References CAMERA_TRACKBALL, m_currentCamera, and m_trackBallCamera.

514 {
515  switch( aCameraType )
516  {
517  case CAMERA_TRACKBALL:
519  break;
520 
521  default:
522  wxLogMessage( wxT( "CINFO3D_VISU::CameraSetType() error: unknown camera type %d" ),
523  (int)aCameraType );
524  break;
525  }
526 }
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 474 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 InitSettings().

475 {
477 
478  wxString errmsg;
479 
480  if( !m_board->GetBoardPolygonOutlines( m_board_poly, /*allLayerHoles,*/ &errmsg ) )
481  {
482  errmsg.append( wxT( "\n\n" ) );
483  errmsg.append( _( "Cannot determine the board outline." ) );
484  wxLogMessage( errmsg );
485  }
486 
487  // Be sure the polygon is strictly simple to avoid issues.
489 
491 }
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 1142 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, 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(), BOARD_ITEM::GetLayer(), GetNrSegmentsCircle(), GetRunningMicroSecs(), TRACK::GetStart(), VIA::GetViaType(), TRACK::GetWidth(), Is3DLayerEnabled(), BOARD_ITEM::IsOnLayer(), D_PAD::IsOnLayer(), m_biuTo3Dunits, m_board, m_calc_seg_max_factor3DU, m_calc_seg_min_factor3DU, m_copperLayersCount, BOARD::m_Drawings, 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(), BOARD_ITEM::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 InitSettings().

1143 {
1144  // Number of segments to draw a circle using segments (used on countour zones
1145  // and text copper elements )
1146  const int segcountforcircle = 12;
1147  const double correctionFactor = GetCircleCorrectionFactor( segcountforcircle );
1148 
1149  // segments to draw a circle to build texts. Is is used only to build
1150  // the shape of each segment of the stroke font, therefore no need to have
1151  // many segments per circle.
1152  const int segcountInStrokeFont = 12;
1153  const double correctionFactorStroke = GetCircleCorrectionFactor( segcountInStrokeFont );
1154 
1155  destroyLayers();
1156 
1157  // Build Copper layers
1158  // Based on: https://github.com/KiCad/kicad-source-mirror/blob/master/3d-viewer/3d_draw.cpp#L692
1159  // /////////////////////////////////////////////////////////////////////////
1160 
1161  #ifdef PRINT_STATISTICS_3D_VIEWER
1162  unsigned stats_startCopperLayersTime = GetRunningMicroSecs();
1163 
1164  unsigned start_Time = stats_startCopperLayersTime;
1165 #endif
1166 
1167  PCB_LAYER_ID cu_seq[MAX_CU_LAYERS];
1169 
1170  m_stats_nr_tracks = 0;
1172  m_stats_nr_vias = 0;
1174  m_stats_nr_holes = 0;
1176 
1177  // Prepare track list, convert in a vector. Calc statistic for the holes
1178  // /////////////////////////////////////////////////////////////////////////
1179  std::vector< const TRACK *> trackList;
1180  trackList.clear();
1181  trackList.reserve( m_board->m_Track.GetCount() );
1182 
1183  for( const TRACK* track = m_board->m_Track; track; track = track->Next() )
1184  {
1185  if( !Is3DLayerEnabled( track->GetLayer() ) ) // Skip non enabled layers
1186  continue;
1187 
1188  // Note: a TRACK holds normal segment tracks and
1189  // also vias circles (that have also drill values)
1190  trackList.push_back( track );
1191 
1192  if( track->Type() == PCB_VIA_T )
1193  {
1194  const VIA *via = static_cast< const VIA*>( track );
1195  m_stats_nr_vias++;
1197  }
1198  else
1199  {
1201  }
1202 
1203  m_stats_track_med_width += track->GetWidth() * m_biuTo3Dunits;
1204  }
1205 
1206  if( m_stats_nr_tracks )
1208 
1209  if( m_stats_nr_vias )
1211 
1212 #ifdef PRINT_STATISTICS_3D_VIEWER
1213  printf( "T01: %.3f ms\n", (float)( GetRunningMicroSecs() - start_Time ) / 1e3 );
1214  start_Time = GetRunningMicroSecs();
1215 #endif
1216 
1217  // Prepare copper layers index and containers
1218  // /////////////////////////////////////////////////////////////////////////
1219  std::vector< PCB_LAYER_ID > layer_id;
1220  layer_id.clear();
1221  layer_id.reserve( m_copperLayersCount );
1222 
1223  for( unsigned i = 0; i < DIM( cu_seq ); ++i )
1224  cu_seq[i] = ToLAYER_ID( B_Cu - i );
1225 
1226  for( LSEQ cu = cu_set.Seq( cu_seq, DIM( cu_seq ) ); cu; ++cu )
1227  {
1228  const PCB_LAYER_ID curr_layer_id = *cu;
1229 
1230  if( !Is3DLayerEnabled( curr_layer_id ) ) // Skip non enabled layers
1231  continue;
1232 
1233  layer_id.push_back( curr_layer_id );
1234 
1235  CBVHCONTAINER2D *layerContainer = new CBVHCONTAINER2D;
1236  m_layers_container2D[curr_layer_id] = layerContainer;
1237 
1240  {
1241  SHAPE_POLY_SET *layerPoly = new SHAPE_POLY_SET;
1242  m_layers_poly[curr_layer_id] = layerPoly;
1243  }
1244  }
1245 
1246 #ifdef PRINT_STATISTICS_3D_VIEWER
1247  printf( "T02: %.3f ms\n", (float)( GetRunningMicroSecs() - start_Time ) / 1e3 );
1248  start_Time = GetRunningMicroSecs();
1249 #endif
1250 
1251  if( aStatusTextReporter )
1252  aStatusTextReporter->Report( _( "Create tracks and vias" ) );
1253 
1254  // Create tracks as objects and add it to container
1255  // /////////////////////////////////////////////////////////////////////////
1256  for( unsigned int lIdx = 0; lIdx < layer_id.size(); ++lIdx )
1257  {
1258  const PCB_LAYER_ID curr_layer_id = layer_id[lIdx];
1259 
1260  wxASSERT( m_layers_container2D.find( curr_layer_id ) != m_layers_container2D.end() );
1261 
1262  CBVHCONTAINER2D *layerContainer = m_layers_container2D[curr_layer_id];
1263 
1264  // ADD TRACKS
1265  unsigned int nTracks = trackList.size();
1266 
1267  for( unsigned int trackIdx = 0; trackIdx < nTracks; ++trackIdx )
1268  {
1269  const TRACK *track = trackList[trackIdx];
1270 
1271  // NOTE: Vias can be on multiple layers
1272  if( !track->IsOnLayer( curr_layer_id ) )
1273  continue;
1274 
1275  // Add object item to layer container
1276  layerContainer->Add( createNewTrack( track, 0.0f ) );
1277  }
1278  }
1279 
1280 #ifdef PRINT_STATISTICS_3D_VIEWER
1281  printf( "T03: %.3f ms\n", (float)( GetRunningMicroSecs() - start_Time ) / 1e3 );
1282  start_Time = GetRunningMicroSecs();
1283 #endif
1284 
1285  // Create VIAS and THTs objects and add it to holes containers
1286  // /////////////////////////////////////////////////////////////////////////
1287  for( unsigned int lIdx = 0; lIdx < layer_id.size(); ++lIdx )
1288  {
1289  const PCB_LAYER_ID curr_layer_id = layer_id[lIdx];
1290 
1291  // ADD TRACKS
1292  unsigned int nTracks = trackList.size();
1293 
1294  for( unsigned int trackIdx = 0; trackIdx < nTracks; ++trackIdx )
1295  {
1296  const TRACK *track = trackList[trackIdx];
1297 
1298  if( !track->IsOnLayer( curr_layer_id ) )
1299  continue;
1300 
1301  // ADD VIAS and THT
1302  if( track->Type() == PCB_VIA_T )
1303  {
1304  const VIA *via = static_cast< const VIA*>( track );
1305  const VIATYPE_T viatype = via->GetViaType();
1306  const float holediameter = via->GetDrillValue() * BiuTo3Dunits();
1307  const float thickness = GetCopperThickness3DU();
1308  const float hole_inner_radius = ( holediameter / 2.0f );
1309 
1310  const SFVEC2F via_center( via->GetStart().x * m_biuTo3Dunits,
1311  -via->GetStart().y * m_biuTo3Dunits );
1312 
1313  if( viatype != VIA_THROUGH )
1314  {
1315 
1316  // Add hole objects
1317  // /////////////////////////////////////////////////////////
1318 
1319  CBVHCONTAINER2D *layerHoleContainer = NULL;
1320 
1321  // Check if the layer is already created
1322  if( m_layers_holes2D.find( curr_layer_id ) == m_layers_holes2D.end() )
1323  {
1324  // not found, create a new container
1325  layerHoleContainer = new CBVHCONTAINER2D;
1326  m_layers_holes2D[curr_layer_id] = layerHoleContainer;
1327  }
1328  else
1329  {
1330  // found
1331  layerHoleContainer = m_layers_holes2D[curr_layer_id];
1332  }
1333 
1334  // Add a hole for this layer
1335  layerHoleContainer->Add( new CFILLEDCIRCLE2D( via_center,
1336  hole_inner_radius + thickness,
1337  *track ) );
1338  }
1339  else if( lIdx == 0 ) // it only adds once the THT holes
1340  {
1341  // Add through hole object
1342  // /////////////////////////////////////////////////////////
1343  m_through_holes_outer.Add( new CFILLEDCIRCLE2D( via_center,
1344  hole_inner_radius + thickness,
1345  *track ) );
1346 
1348  new CFILLEDCIRCLE2D( via_center,
1349  hole_inner_radius + thickness,
1350  *track ) );
1351 
1352  m_through_holes_inner.Add( new CFILLEDCIRCLE2D( via_center,
1353  hole_inner_radius,
1354  *track ) );
1355 
1356  //m_through_holes_vias_inner.Add( new CFILLEDCIRCLE2D( via_center,
1357  // hole_inner_radius,
1358  // *track ) );
1359  }
1360  }
1361  }
1362  }
1363 
1364 #ifdef PRINT_STATISTICS_3D_VIEWER
1365  printf( "T04: %.3f ms\n", (float)( GetRunningMicroSecs() - start_Time ) / 1e3 );
1366  start_Time = GetRunningMicroSecs();
1367 #endif
1368 
1369  // Create VIAS and THTs objects and add it to holes containers
1370  // /////////////////////////////////////////////////////////////////////////
1371  for( unsigned int lIdx = 0; lIdx < layer_id.size(); ++lIdx )
1372  {
1373  const PCB_LAYER_ID curr_layer_id = layer_id[lIdx];
1374 
1375  // ADD TRACKS
1376  const unsigned int nTracks = trackList.size();
1377 
1378  for( unsigned int trackIdx = 0; trackIdx < nTracks; ++trackIdx )
1379  {
1380  const TRACK *track = trackList[trackIdx];
1381 
1382  if( !track->IsOnLayer( curr_layer_id ) )
1383  continue;
1384 
1385  // ADD VIAS and THT
1386  if( track->Type() == PCB_VIA_T )
1387  {
1388  const VIA *via = static_cast< const VIA*>( track );
1389  const VIATYPE_T viatype = via->GetViaType();
1390 
1391  if( viatype != VIA_THROUGH )
1392  {
1393 
1394  // Add VIA hole contourns
1395  // /////////////////////////////////////////////////////////
1396 
1397  // Add outter holes of VIAs
1398  SHAPE_POLY_SET *layerOuterHolesPoly = NULL;
1399  SHAPE_POLY_SET *layerInnerHolesPoly = NULL;
1400 
1401  // Check if the layer is already created
1402  if( m_layers_outer_holes_poly.find( curr_layer_id ) ==
1404  {
1405  // not found, create a new container
1406  layerOuterHolesPoly = new SHAPE_POLY_SET;
1407  m_layers_outer_holes_poly[curr_layer_id] = layerOuterHolesPoly;
1408 
1409  wxASSERT( m_layers_inner_holes_poly.find( curr_layer_id ) ==
1410  m_layers_inner_holes_poly.end() );
1411 
1412  layerInnerHolesPoly = new SHAPE_POLY_SET;
1413  m_layers_inner_holes_poly[curr_layer_id] = layerInnerHolesPoly;
1414  }
1415  else
1416  {
1417  // found
1418  layerOuterHolesPoly = m_layers_outer_holes_poly[curr_layer_id];
1419 
1420  wxASSERT( m_layers_inner_holes_poly.find( curr_layer_id ) !=
1421  m_layers_inner_holes_poly.end() );
1422 
1423  layerInnerHolesPoly = m_layers_inner_holes_poly[curr_layer_id];
1424  }
1425 
1426  const int holediameter = via->GetDrillValue();
1427  const int hole_outer_radius = (holediameter / 2) + GetCopperThicknessBIU();
1428 
1429  TransformCircleToPolygon( *layerOuterHolesPoly,
1430  via->GetStart(),
1431  hole_outer_radius,
1432  GetNrSegmentsCircle( hole_outer_radius * 2 ) );
1433 
1434  TransformCircleToPolygon( *layerInnerHolesPoly,
1435  via->GetStart(),
1436  holediameter / 2,
1437  GetNrSegmentsCircle( holediameter ) );
1438  }
1439  else if( lIdx == 0 ) // it only adds once the THT holes
1440  {
1441  const int holediameter = via->GetDrillValue();
1442  const int hole_outer_radius = (holediameter / 2)+ GetCopperThicknessBIU();
1443 
1444  // Add through hole contourns
1445  // /////////////////////////////////////////////////////////
1447  via->GetStart(),
1448  hole_outer_radius,
1449  GetNrSegmentsCircle( hole_outer_radius * 2 ) );
1450 
1452  via->GetStart(),
1453  holediameter / 2,
1454  GetNrSegmentsCircle( holediameter ) );
1455 
1456  // Add samething for vias only
1457 
1459  via->GetStart(),
1460  hole_outer_radius,
1461  GetNrSegmentsCircle( hole_outer_radius * 2 ) );
1462 
1463  //TransformCircleToPolygon( m_through_inner_holes_vias_poly,
1464  // via->GetStart(),
1465  // holediameter / 2,
1466  // GetNrSegmentsCircle( holediameter ) );
1467  }
1468  }
1469  }
1470  }
1471 
1472 #ifdef PRINT_STATISTICS_3D_VIEWER
1473  printf( "T05: %.3f ms\n", (float)( GetRunningMicroSecs() - start_Time ) / 1e3 );
1474  start_Time = GetRunningMicroSecs();
1475 #endif
1476 
1477  // Creates outline contours of the tracks and add it to the poly of the layer
1478  // /////////////////////////////////////////////////////////////////////////
1481  {
1482  for( unsigned int lIdx = 0; lIdx < layer_id.size(); ++lIdx )
1483  {
1484  const PCB_LAYER_ID curr_layer_id = layer_id[lIdx];
1485 
1486  wxASSERT( m_layers_poly.find( curr_layer_id ) != m_layers_poly.end() );
1487 
1488  SHAPE_POLY_SET *layerPoly = m_layers_poly[curr_layer_id];
1489 
1490  // ADD TRACKS
1491  unsigned int nTracks = trackList.size();
1492 
1493  for( unsigned int trackIdx = 0; trackIdx < nTracks; ++trackIdx )
1494  {
1495  const TRACK *track = trackList[trackIdx];
1496 
1497  if( !track->IsOnLayer( curr_layer_id ) )
1498  continue;
1499 
1500  // Add the track contour
1501  int nrSegments = GetNrSegmentsCircle( track->GetWidth() );
1502 
1504  *layerPoly,
1505  0,
1506  nrSegments,
1507  GetCircleCorrectionFactor( nrSegments ) );
1508  }
1509  }
1510  }
1511 
1512 #ifdef PRINT_STATISTICS_3D_VIEWER
1513  printf( "T06: %.3f ms\n", (float)( GetRunningMicroSecs() - start_Time ) / 1e3 );
1514  start_Time = GetRunningMicroSecs();
1515 #endif
1516 
1517  // Add holes of modules
1518  // /////////////////////////////////////////////////////////////////////////
1519  for( const MODULE* module = m_board->m_Modules; module; module = module->Next() )
1520  {
1521  const D_PAD* pad = module->Pads();
1522 
1523  for( ; pad; pad = pad->Next() )
1524  {
1525  const wxSize padHole = pad->GetDrillSize();
1526 
1527  if( !padHole.x ) // Not drilled pad like SMD pad
1528  continue;
1529 
1530  // The hole in the body is inflated by copper thickness,
1531  // if not plated, no copper
1532  const int inflate = (pad->GetAttribute () != PAD_ATTRIB_HOLE_NOT_PLATED) ?
1533  GetCopperThicknessBIU() : 0;
1534 
1535  m_stats_nr_holes++;
1536  m_stats_hole_med_diameter += ( ( pad->GetDrillSize().x +
1537  pad->GetDrillSize().y ) / 2.0f ) * m_biuTo3Dunits;
1538 
1539  m_through_holes_outer.Add( createNewPadDrill( pad, inflate ) );
1541  }
1542  }
1543  if( m_stats_nr_holes )
1545 
1546 #ifdef PRINT_STATISTICS_3D_VIEWER
1547  printf( "T07: %.3f ms\n", (float)( GetRunningMicroSecs() - start_Time ) / 1e3 );
1548  start_Time = GetRunningMicroSecs();
1549 #endif
1550 
1551  // Add contours of the pad holes (pads can be Circle or Segment holes)
1552  // /////////////////////////////////////////////////////////////////////////
1553  for( const MODULE* module = m_board->m_Modules; module; module = module->Next() )
1554  {
1555  const D_PAD* pad = module->Pads();
1556 
1557  for( ; pad; pad = pad->Next() )
1558  {
1559  const wxSize padHole = pad->GetDrillSize();
1560 
1561  if( !padHole.x ) // Not drilled pad like SMD pad
1562  continue;
1563 
1564  // The hole in the body is inflated by copper thickness.
1565  const int inflate = GetCopperThicknessBIU();
1566 
1567  // we use the hole diameter to calculate the seg count.
1568  // for round holes, padHole.x == padHole.y
1569  // for oblong holes, the diameter is the smaller of (padHole.x, padHole.y)
1570  const int diam = std::min( padHole.x, padHole.y );
1571 
1572 
1573  if( pad->GetAttribute () != PAD_ATTRIB_HOLE_NOT_PLATED )
1574  {
1576  inflate,
1577  GetNrSegmentsCircle( diam ) );
1578 
1580  0,
1581  GetNrSegmentsCircle( diam ) );
1582  }
1583  else
1584  {
1585  // If not plated, no copper.
1587  inflate,
1588  GetNrSegmentsCircle( diam ) );
1589  }
1590  }
1591  }
1592 
1593 #ifdef PRINT_STATISTICS_3D_VIEWER
1594  printf( "T08: %.3f ms\n", (float)( GetRunningMicroSecs() - start_Time ) / 1e3 );
1595  start_Time = GetRunningMicroSecs();
1596 #endif
1597 
1598  // Add modules PADs objects to containers
1599  // /////////////////////////////////////////////////////////////////////////
1600  for( unsigned int lIdx = 0; lIdx < layer_id.size(); ++lIdx )
1601  {
1602  const PCB_LAYER_ID curr_layer_id = layer_id[lIdx];
1603 
1604  wxASSERT( m_layers_container2D.find( curr_layer_id ) != m_layers_container2D.end() );
1605 
1606  CBVHCONTAINER2D *layerContainer = m_layers_container2D[curr_layer_id];
1607 
1608  // ADD PADS
1609  for( const MODULE* module = m_board->m_Modules; module; module = module->Next() )
1610  {
1611  // Note: NPTH pads are not drawn on copper layers when the pad
1612  // has same shape as its hole
1614  layerContainer,
1615  curr_layer_id,
1616  0,
1617  true );
1618 
1619  // Micro-wave modules may have items on copper layers
1621  layerContainer,
1622  curr_layer_id,
1623  0 );
1624  }
1625  }
1626 
1627 #ifdef PRINT_STATISTICS_3D_VIEWER
1628  printf( "T09: %.3f ms\n", (float)( GetRunningMicroSecs() - start_Time ) / 1e3 );
1629  start_Time = GetRunningMicroSecs();
1630 #endif
1631 
1632  // Add modules PADs poly contourns
1633  // /////////////////////////////////////////////////////////////////////////
1636  {
1637  for( unsigned int lIdx = 0; lIdx < layer_id.size(); ++lIdx )
1638  {
1639  const PCB_LAYER_ID curr_layer_id = layer_id[lIdx];
1640 
1641  wxASSERT( m_layers_poly.find( curr_layer_id ) != m_layers_poly.end() );
1642 
1643  SHAPE_POLY_SET *layerPoly = m_layers_poly[curr_layer_id];
1644 
1645  // ADD PADS
1646  for( const MODULE* module = m_board->m_Modules;
1647  module;
1648  module = module->Next() )
1649  {
1650  // Construct polys
1651  // /////////////////////////////////////////////////////////////
1652 
1653  // Note: NPTH pads are not drawn on copper layers when the pad
1654  // has same shape as its hole
1656  curr_layer_id,
1657  *layerPoly,
1658  0,
1659  true );
1660 
1661  // Micro-wave modules may have items on copper layers
1662  module->TransformGraphicTextWithClearanceToPolygonSet( curr_layer_id,
1663  *layerPoly,
1664  0,
1665  segcountforcircle,
1666  correctionFactor );
1667 
1668  transformGraphicModuleEdgeToPolygonSet( module, curr_layer_id, *layerPoly );
1669  }
1670  }
1671  }
1672 
1673 #ifdef PRINT_STATISTICS_3D_VIEWER
1674  printf( "T10: %.3f ms\n", (float)( GetRunningMicroSecs() - start_Time ) / 1e3 );
1675  start_Time = GetRunningMicroSecs();
1676 #endif
1677 
1678  // Add graphic item on copper layers to object containers
1679  // /////////////////////////////////////////////////////////////////////////
1680  for( unsigned int lIdx = 0; lIdx < layer_id.size(); ++lIdx )
1681  {
1682  const PCB_LAYER_ID curr_layer_id = layer_id[lIdx];
1683 
1684  wxASSERT( m_layers_container2D.find( curr_layer_id ) != m_layers_container2D.end() );
1685 
1686  CBVHCONTAINER2D *layerContainer = m_layers_container2D[curr_layer_id];
1687 
1688  // ADD GRAPHIC ITEMS ON COPPER LAYERS (texts)
1689  for( const BOARD_ITEM* item = m_board->m_Drawings;
1690  item;
1691  item = item->Next() )
1692  {
1693  if( !item->IsOnLayer( curr_layer_id ) )
1694  continue;
1695 
1696  switch( item->Type() )
1697  {
1698  case PCB_LINE_T: // should not exist on copper layers
1699  {
1701  layerContainer,
1702  curr_layer_id,
1703  0 );
1704  }
1705  break;
1706 
1707  case PCB_TEXT_T:
1709  layerContainer,
1710  curr_layer_id,
1711  0 );
1712  break;
1713 
1714  case PCB_DIMENSION_T:
1716  layerContainer,
1717  curr_layer_id,
1718  0 );
1719  break;
1720 
1721  default:
1722  wxLogTrace( m_logTrace,
1723  wxT( "createLayers: item type: %d not implemented" ),
1724  item->Type() );
1725  break;
1726  }
1727  }
1728  }
1729 
1730 #ifdef PRINT_STATISTICS_3D_VIEWER
1731  printf( "T11: %.3f ms\n", (float)( GetRunningMicroSecs() - start_Time ) / 1e3 );
1732  start_Time = GetRunningMicroSecs();
1733 #endif
1734 
1735  // Add graphic item on copper layers to poly contourns
1736  // /////////////////////////////////////////////////////////////////////////
1739  {
1740  for( unsigned int lIdx = 0; lIdx < layer_id.size(); ++lIdx )
1741  {
1742  const PCB_LAYER_ID curr_layer_id = layer_id[lIdx];
1743 
1744  wxASSERT( m_layers_poly.find( curr_layer_id ) != m_layers_poly.end() );
1745 
1746  SHAPE_POLY_SET *layerPoly = m_layers_poly[curr_layer_id];
1747 
1748  // ADD GRAPHIC ITEMS ON COPPER LAYERS (texts)
1749  for( const BOARD_ITEM* item = m_board->m_Drawings;
1750  item;
1751  item = item->Next() )
1752  {
1753  if( !item->IsOnLayer( curr_layer_id ) )
1754  continue;
1755 
1756  switch( item->Type() )
1757  {
1758  case PCB_LINE_T: // should not exist on copper layers
1759  {
1760  const int nrSegments =
1761  GetNrSegmentsCircle( item->GetBoundingBox().GetSizeMax() );
1762 
1763  ( (DRAWSEGMENT*) item )->TransformShapeWithClearanceToPolygon(
1764  *layerPoly,
1765  0,
1766  nrSegments,
1767  GetCircleCorrectionFactor( nrSegments ) );
1768  }
1769  break;
1770 
1771  case PCB_TEXT_T:
1772  ( (TEXTE_PCB*) item )->TransformShapeWithClearanceToPolygonSet(
1773  *layerPoly,
1774  0,
1775  segcountforcircle,
1776  correctionFactor );
1777  break;
1778 
1779  default:
1780  wxLogTrace( m_logTrace,
1781  wxT( "createLayers: item type: %d not implemented" ),
1782  item->Type() );
1783  break;
1784  }
1785  }
1786  }
1787  }
1788 
1789 #ifdef PRINT_STATISTICS_3D_VIEWER
1790  printf( "T12: %.3f ms\n", (float)( GetRunningMicroSecs() - start_Time ) / 1e3 );
1791  start_Time = GetRunningMicroSecs();
1792 #endif
1793 
1794  if( GetFlag( FL_ZONE ) )
1795  {
1796  if( aStatusTextReporter )
1797  aStatusTextReporter->Report( _( "Create zones" ) );
1798 
1799  // Add zones objects
1800  // /////////////////////////////////////////////////////////////////////
1801  for( unsigned int lIdx = 0; lIdx < layer_id.size(); ++lIdx )
1802  {
1803  const PCB_LAYER_ID curr_layer_id = layer_id[lIdx];
1804 
1805  if( aStatusTextReporter )
1806  aStatusTextReporter->Report( wxString::Format( _( "Create zones of layer %s" ),
1807  LSET::Name( curr_layer_id ) ) );
1808 
1809  wxASSERT( m_layers_container2D.find( curr_layer_id ) != m_layers_container2D.end() );
1810 
1811  CBVHCONTAINER2D *layerContainer = m_layers_container2D[curr_layer_id];
1812 
1813  // ADD COPPER ZONES
1814  for( int ii = 0; ii < m_board->GetAreaCount(); ++ii )
1815  {
1816  const ZONE_CONTAINER* zone = m_board->GetArea( ii );
1817  const PCB_LAYER_ID zonelayer = zone->GetLayer();
1818 
1819  if( zonelayer == curr_layer_id )
1820  {
1822  layerContainer,
1823  curr_layer_id );
1824  }
1825  }
1826  }
1827  }
1828 
1829 #ifdef PRINT_STATISTICS_3D_VIEWER
1830  printf( "T13: %.3f ms\n", (float)( GetRunningMicroSecs() - start_Time ) / 1e3 );
1831  start_Time = GetRunningMicroSecs();
1832 #endif
1833 
1834  if( GetFlag( FL_ZONE ) &&
1837  {
1838  // Add zones poly contourns
1839  // /////////////////////////////////////////////////////////////////////
1840  for( unsigned int lIdx = 0; lIdx < layer_id.size(); ++lIdx )
1841  {
1842  const PCB_LAYER_ID curr_layer_id = layer_id[lIdx];
1843 
1844  wxASSERT( m_layers_poly.find( curr_layer_id ) != m_layers_poly.end() );
1845 
1846  SHAPE_POLY_SET *layerPoly = m_layers_poly[curr_layer_id];
1847 
1848  // ADD COPPER ZONES
1849  for( int ii = 0; ii < m_board->GetAreaCount(); ++ii )
1850  {
1851  const ZONE_CONTAINER* zone = m_board->GetArea( ii );
1852  const LAYER_NUM zonelayer = zone->GetLayer();
1853 
1854  if( zonelayer == curr_layer_id )
1855  {
1856  zone->TransformSolidAreasShapesToPolygonSet( *layerPoly,
1857  segcountforcircle,
1858  correctionFactor );
1859  }
1860  }
1861  }
1862  }
1863 
1864 #ifdef PRINT_STATISTICS_3D_VIEWER
1865  printf( "T14: %.3f ms\n", (float)( GetRunningMicroSecs() - start_Time ) / 1e3 );
1866  start_Time = GetRunningMicroSecs();
1867 #endif
1868 
1869  // Simplify layer polygons
1870  // /////////////////////////////////////////////////////////////////////////
1871 
1872  if( aStatusTextReporter )
1873  aStatusTextReporter->Report( _( "Simplifying polygons" ) );
1874 
1877  {
1878  const int nLayers = layer_id.size();
1879 
1880  #pragma omp parallel for
1881  for( signed int lIdx = 0; lIdx < nLayers; ++lIdx )
1882  {
1883  const PCB_LAYER_ID curr_layer_id = layer_id[lIdx];
1884 
1885  wxASSERT( m_layers_poly.find( curr_layer_id ) != m_layers_poly.end() );
1886 
1887  SHAPE_POLY_SET *layerPoly = m_layers_poly[curr_layer_id];
1888 
1889  wxASSERT( layerPoly != NULL );
1890 
1891  // This will make a union of all added contourns
1892  layerPoly->Simplify( SHAPE_POLY_SET::PM_FAST );
1893  }
1894  }
1895 
1896 #ifdef PRINT_STATISTICS_3D_VIEWER
1897  printf( "T15: %.3f ms\n", (float)( GetRunningMicroSecs() - start_Time ) / 1e3 );
1898  start_Time = GetRunningMicroSecs();
1899 #endif
1900 
1901  // Simplify holes polygon contours
1902  // /////////////////////////////////////////////////////////////////////////
1903  if( aStatusTextReporter )
1904  aStatusTextReporter->Report( _( "Simplify holes contours" ) );
1905 
1906  for( unsigned int lIdx = 0; lIdx < layer_id.size(); ++lIdx )
1907  {
1908  const PCB_LAYER_ID curr_layer_id = layer_id[lIdx];
1909 
1910  if( m_layers_outer_holes_poly.find( curr_layer_id ) !=
1912  {
1913  // found
1914  SHAPE_POLY_SET *polyLayer = m_layers_outer_holes_poly[curr_layer_id];
1915  polyLayer->Simplify( SHAPE_POLY_SET::PM_FAST );
1916 
1917  wxASSERT( m_layers_inner_holes_poly.find( curr_layer_id ) !=
1918  m_layers_inner_holes_poly.end() );
1919 
1920  polyLayer = m_layers_inner_holes_poly[curr_layer_id];
1921  polyLayer->Simplify( SHAPE_POLY_SET::PM_FAST );
1922  }
1923  }
1924 
1925 #ifdef PRINT_STATISTICS_3D_VIEWER
1926  printf( "T16: %.3f ms\n", (float)( GetRunningMicroSecs() - start_Time ) / 1e3 );
1927 #endif
1928  // End Build Copper layers
1929 
1930 
1931  // This will make a union of all added contourns
1936  //m_through_inner_holes_vias_poly.Simplify( SHAPE_POLY_SET::PM_FAST ); // Not in use
1937 
1938 #ifdef PRINT_STATISTICS_3D_VIEWER
1939  unsigned stats_endCopperLayersTime = GetRunningMicroSecs();
1940 #endif
1941 
1942 
1943  // Build Tech layers
1944  // Based on: https://github.com/KiCad/kicad-source-mirror/blob/master/3d-viewer/3d_draw.cpp#L1059
1945  // /////////////////////////////////////////////////////////////////////////
1946 #ifdef PRINT_STATISTICS_3D_VIEWER
1947  unsigned stats_startTechLayersTime = GetRunningMicroSecs();
1948 #endif
1949 
1950  if( aStatusTextReporter )
1951  aStatusTextReporter->Report( _( "Build Tech layers" ) );
1952 
1953  // draw graphic items, on technical layers
1954  static const PCB_LAYER_ID teckLayerList[] = {
1955  B_Adhes,
1956  F_Adhes,
1957  B_Paste,
1958  F_Paste,
1959  B_SilkS,
1960  F_SilkS,
1961  B_Mask,
1962  F_Mask,
1963 
1964  // Aux Layers
1965  Dwgs_User,
1966  Cmts_User,
1967  Eco1_User,
1968  Eco2_User,
1969  Edge_Cuts,
1970  Margin
1971  };
1972 
1973  // User layers are not drawn here, only technical layers
1974  for( LSEQ seq = LSET::AllNonCuMask().Seq( teckLayerList, DIM( teckLayerList ) );
1975  seq;
1976  ++seq )
1977  {
1978  const PCB_LAYER_ID curr_layer_id = *seq;
1979 
1980  if( !Is3DLayerEnabled( curr_layer_id ) )
1981  continue;
1982 
1983  CBVHCONTAINER2D *layerContainer = new CBVHCONTAINER2D;
1984  m_layers_container2D[curr_layer_id] = layerContainer;
1985 
1986  SHAPE_POLY_SET *layerPoly = new SHAPE_POLY_SET;
1987  m_layers_poly[curr_layer_id] = layerPoly;
1988 
1989  // Add drawing objects
1990  // /////////////////////////////////////////////////////////////////////
1991  for( BOARD_ITEM* item = m_board->m_Drawings; item; item = item->Next() )
1992  {
1993  if( !item->IsOnLayer( curr_layer_id ) )
1994  continue;
1995 
1996  switch( item->Type() )
1997  {
1998  case PCB_LINE_T:
2000  layerContainer,
2001  curr_layer_id,
2002  0 );
2003  break;
2004 
2005  case PCB_TEXT_T:
2007  layerContainer,
2008  curr_layer_id,
2009  0 );
2010  break;
2011 
2012  case PCB_DIMENSION_T:
2014  layerContainer,
2015  curr_layer_id,
2016  0 );
2017  break;
2018 
2019  default:
2020  break;
2021  }
2022  }
2023 
2024 
2025  // Add drawing contours
2026  // /////////////////////////////////////////////////////////////////////
2027  for( BOARD_ITEM* item = m_board->m_Drawings; item; item = item->Next() )
2028  {
2029  if( !item->IsOnLayer( curr_layer_id ) )
2030  continue;
2031 
2032  switch( item->Type() )
2033  {
2034  case PCB_LINE_T:
2035  {
2036  const unsigned int nr_segments =
2037  GetNrSegmentsCircle( item->GetBoundingBox().GetSizeMax() );
2038 
2039  ((DRAWSEGMENT*) item)->TransformShapeWithClearanceToPolygon( *layerPoly,
2040  0,
2041  nr_segments,
2042  0.0 );
2043  }
2044  break;
2045 
2046  case PCB_TEXT_T:
2047  ((TEXTE_PCB*) item)->TransformShapeWithClearanceToPolygonSet( *layerPoly,
2048  0,
2049  segcountInStrokeFont,
2050  1.0 );
2051  break;
2052 
2053  default:
2054  break;
2055  }
2056  }
2057 
2058 
2059  // Add modules tech layers - objects
2060  // /////////////////////////////////////////////////////////////////////
2061  for( MODULE* module = m_board->m_Modules; module; module = module->Next() )
2062  {
2063  if( (curr_layer_id == F_SilkS) || (curr_layer_id == B_SilkS) )
2064  {
2065  D_PAD* pad = module->Pads();
2066  int linewidth = g_DrawDefaultLineThickness;
2067 
2068  for( ; pad; pad = pad->Next() )
2069  {
2070  if( !pad->IsOnLayer( curr_layer_id ) )
2071  continue;
2072 
2074  layerContainer,
2075  linewidth );
2076  }
2077  }
2078  else
2079  {
2081  layerContainer,
2082  curr_layer_id,
2083  0,
2084  false );
2085  }
2086 
2088  layerContainer,
2089  curr_layer_id,
2090  0 );
2091  }
2092 
2093 
2094  // Add modules tech layers - contours
2095  // /////////////////////////////////////////////////////////////////////
2096  for( MODULE* module = m_board->m_Modules; module; module = module->Next() )
2097  {
2098  if( (curr_layer_id == F_SilkS) || (curr_layer_id == B_SilkS) )
2099  {
2100  D_PAD* pad = module->Pads();
2101  const int linewidth = g_DrawDefaultLineThickness;
2102 
2103  for( ; pad; pad = pad->Next() )
2104  {
2105  if( !pad->IsOnLayer( curr_layer_id ) )
2106  continue;
2107 
2108  buildPadShapeThickOutlineAsPolygon( pad, *layerPoly, linewidth );
2109  }
2110  }
2111  else
2112  {
2114  curr_layer_id,
2115  *layerPoly,
2116  0,
2117  false );
2118  }
2119 
2120  // On tech layers, use a poor circle approximation, only for texts (stroke font)
2121  module->TransformGraphicTextWithClearanceToPolygonSet( curr_layer_id,
2122  *layerPoly,
2123  0,
2124  segcountInStrokeFont,
2125  correctionFactorStroke,
2126  segcountInStrokeFont );
2127 
2128  // Add the remaining things with dynamic seg count for circles
2129  transformGraphicModuleEdgeToPolygonSet( module, curr_layer_id, *layerPoly );
2130  }
2131 
2132 
2133  // Draw non copper zones
2134  // /////////////////////////////////////////////////////////////////////
2135  if( GetFlag( FL_ZONE ) )
2136  {
2137  for( int ii = 0; ii < m_board->GetAreaCount(); ++ii )
2138  {
2139  ZONE_CONTAINER* zone = m_board->GetArea( ii );
2140 
2141  if( !zone->IsOnLayer( curr_layer_id ) )
2142  continue;
2143 
2145  layerContainer,
2146  curr_layer_id );
2147  }
2148 
2149  for( int ii = 0; ii < m_board->GetAreaCount(); ++ii )
2150  {
2151  ZONE_CONTAINER* zone = m_board->GetArea( ii );
2152 
2153  if( !zone->IsOnLayer( curr_layer_id ) )
2154  continue;
2155 
2156  zone->TransformSolidAreasShapesToPolygonSet( *layerPoly,
2157  // Use the same segcount as stroke font
2158  segcountInStrokeFont,
2159  correctionFactorStroke );
2160  }
2161  }
2162 
2163  // This will make a union of all added contourns
2164  layerPoly->Simplify( SHAPE_POLY_SET::PM_FAST );
2165  }
2166  // End Build Tech layers
2167 
2168 #ifdef PRINT_STATISTICS_3D_VIEWER
2169  unsigned stats_endTechLayersTime = GetRunningMicroSecs();
2170 #endif
2171 
2172 
2173  // Build BVH for holes and vias
2174  // /////////////////////////////////////////////////////////////////////////
2175 
2176 #ifdef PRINT_STATISTICS_3D_VIEWER
2177  unsigned stats_startHolesBVHTime = GetRunningMicroSecs();
2178 #endif
2179 
2182 
2183  if( !m_layers_holes2D.empty() )
2184  {
2185  for( MAP_CONTAINER_2D::iterator ii = m_layers_holes2D.begin();
2186  ii != m_layers_holes2D.end();
2187  ++ii )
2188  {
2189  ((CBVHCONTAINER2D *)(ii->second))->BuildBVH();
2190  }
2191  }
2192 
2193  // We only need the Solder mask to initialize the BVH
2194  // because..?
2196  ((CBVHCONTAINER2D *)m_layers_container2D[B_Mask])->BuildBVH();
2197 
2199  ((CBVHCONTAINER2D *)m_layers_container2D[F_Mask])->BuildBVH();
2200 
2201 #ifdef PRINT_STATISTICS_3D_VIEWER
2202  unsigned stats_endHolesBVHTime = GetRunningMicroSecs();
2203 
2204  printf( "CINFO3D_VISU::createLayers times\n" );
2205  printf( " Copper Layers: %.3f ms\n",
2206  (float)( stats_endCopperLayersTime - stats_startCopperLayersTime ) / 1e3 );
2207  printf( " Holes BVH creation: %.3f ms\n",
2208  (float)( stats_endHolesBVHTime - stats_startHolesBVHTime ) / 1e3 );
2209  printf( " Tech Layers: %.3f ms\n",
2210  (float)( stats_endTechLayersTime - stats_startTechLayersTime ) / 1e3 );
2211  printf( "Statistics:\n" );
2212  printf( " m_stats_nr_tracks %u\n", m_stats_nr_tracks );
2213  printf( " m_stats_nr_vias %u\n", m_stats_nr_vias );
2214  printf( " m_stats_nr_holes %u\n", m_stats_nr_holes );
2215  printf( " m_stats_via_med_hole_diameter (3DU) %f\n", m_stats_via_med_hole_diameter );
2216  printf( " m_stats_hole_med_diameter (3DU) %f\n", m_stats_hole_med_diameter );
2217  printf( " m_calc_seg_min_factor3DU (3DU) %f\n", m_calc_seg_min_factor3DU );
2218  printf( " m_calc_seg_max_factor3DU (3DU) %f\n", m_calc_seg_max_factor3DU );
2219 #endif
2220 }
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:639
void AddShapeWithClearanceToContainer(const TEXTE_PCB *aTextPCB, CGENERICCONTAINER2D *aDstContainer, PCB_LAYER_ID aLayerId, int aClearanceValue)
KICAD_T Type() const
Function Type()
Definition: base_struct.h:198
#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:78
COBJECT2D * createNewTrack(const TRACK *aTrack, int aClearanceValue) const
PAD_ATTR_T GetAttribute() const
Definition: class_pad.h:238
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:63
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.
Class BOARD_ITEM is a base class for any item which can be embedded within the BOARD container class...
void TransformCircleToPolygon(SHAPE_POLY_SET &aCornerBuffer, wxPoint aCenter, int aRadius, int aCircleToSegmentsCount)
Function TransformCircleToPolygon convert a circle to a polygon, using multiple straight lines...
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:662
MODULE * Next() const
Definition: class_module.h:100
MAP_POLY m_layers_inner_holes_poly
It contains polygon contours for holes of each layer (inner holes)
Definition: cinfo3d_visu.h:563
class TEXTE_PCB, text on a layer
Definition: typeinfo.h:104
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:188
VIATYPE_T
Definition: class_track.h:49
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:337
BOARD_ITEM * Next() const
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:446
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:121
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:106
DLIST< BOARD_ITEM > m_Drawings
Definition: class_board.h:242
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:1051
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:112
void TransformShapeWithClearanceToPolygon(SHAPE_POLY_SET &aCornerBuffer, int aClearanceValue, int aCircleToSegmentsCount, double aCorrectionFactor) const
Function TransformShapeWithClearanceToPolygon Convert the track shape to a closed polygon Used in fil...
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.
PCB_LAYER_ID GetLayer() const
Function GetLayer returns the primary layer this item is on.
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:98
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:1022
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:243
unsigned GetRunningMicroSecs()
Function GetRunningMicroSecs An alternate way to calculate an elapset time (in microsecondes) to clas...
int GetWidth() const
Definition: class_track.h:115
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:108
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:244
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:479
class DRAWSEGMENT, a segment not on copper layers
Definition: typeinfo.h:103
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:767
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)
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 562 of file create_layer_items.cpp.

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

Referenced by AddPadsShapesWithClearanceToContainer().

565 {
566  switch( aPad->GetShape() )
567  {
568  default:
569  wxFAIL_MSG( wxT( "CINFO3D_VISU::createNewPad: found a not implemented pad shape (new shape?)" ) );
570  break;
571 
572  case PAD_SHAPE_CIRCLE:
573  case PAD_SHAPE_OVAL:
574  case PAD_SHAPE_ROUNDRECT:
575  createNewPadWithClearance( aPad, aDstContainer, aInflateValue.x );
576  break;
577 
578  case PAD_SHAPE_TRAPEZOID:
579  case PAD_SHAPE_RECT:
580  wxPoint corners[4];
581  aPad->BuildPadPolygon( corners, aInflateValue, aPad->GetOrientation() );
582 
583  // Note: for pad having a shape offset,
584  // the pad position is NOT the shape position
585  for( unsigned int ii = 0; ii < 4; ++ii )
586  corners[ii] += aPad->ShapePos(); // Shift origin to position
587 
588  aDstContainer->Add( new CPOLYGON4PTS2D(
589  SFVEC2F( corners[0].x * m_biuTo3Dunits,
590  -corners[0].y * m_biuTo3Dunits ),
591  SFVEC2F( corners[1].x * m_biuTo3Dunits,
592  -corners[1].y * m_biuTo3Dunits ),
593  SFVEC2F( corners[2].x * m_biuTo3Dunits,
594  -corners[2].y * m_biuTo3Dunits ),
595  SFVEC2F( corners[3].x * m_biuTo3Dunits,
596  -corners[3].y * m_biuTo3Dunits ),
597  *aPad ) );
598 
599  break;
600  }
601 }
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:166
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:214
wxPoint ShapePos() const
Definition: class_pad.cpp:367
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 508 of file create_layer_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().

509 {
510  wxSize drillSize = aPad->GetDrillSize();
511 
512  if( !drillSize.x || !drillSize.y )
513  {
514  wxLogTrace( m_logTrace, wxT( "CINFO3D_VISU::createNewPadDrill - found an invalid pad" ) );
515  return NULL;
516  }
517 
518  if( drillSize.x == drillSize.y ) // usual round hole
519  {
520  const int radius = (drillSize.x / 2) + aInflateValue;
521 
522  const SFVEC2F center( aPad->GetPosition().x * m_biuTo3Dunits,
523  -aPad->GetPosition().y * m_biuTo3Dunits );
524 
525  return new CFILLEDCIRCLE2D( center, radius * m_biuTo3Dunits, *aPad );
526 
527  }
528  else // Oblong hole
529  {
530  wxPoint start, end;
531  int width;
532 
533  aPad->GetOblongDrillGeometry( start, end, width );
534 
535  width += aInflateValue * 2;
536  start += aPad->GetPosition();
537  end += aPad->GetPosition();
538 
539  SFVEC2F start3DU( start.x * m_biuTo3Dunits,
540  -start.y * m_biuTo3Dunits );
541 
542  SFVEC2F end3DU ( end.x * m_biuTo3Dunits,
543  -end.y * m_biuTo3Dunits );
544 
545  if( Is_segment_a_circle( start3DU, end3DU ) )
546  {
547  return new CFILLEDCIRCLE2D( start3DU, (width / 2) * m_biuTo3Dunits, *aPad );
548  }
549  else
550  {
551  return new CROUNDSEGMENT2D( start3DU, end3DU, width * m_biuTo3Dunits, *aPad );
552  }
553  }
554 
555  return NULL;
556 }
const wxSize & GetDrillSize() const
Definition: class_pad.h:188
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 & GetPosition() const override
Definition: class_pad.h:170
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:667
void CINFO3D_VISU::createNewPadWithClearance ( const D_PAD aPad,
CGENERICCONTAINER2D aDstContainer,
int  aClearanceValue 
) const
private

Definition at line 298 of file create_layer_items.cpp.

References abs, CGENERICCONTAINER2D::Add(), D_PAD::BuildPadPolygon(), D_PAD::GetOrientation(), GetRoundRectCornerCenters(), D_PAD::GetRoundRectCornerRadius(), D_PAD::GetShape(), D_PAD::GetSize(), Is_segment_a_circle(), m_biuTo3Dunits, m_logTrace, PAD_SHAPE_CIRCLE, PAD_SHAPE_OVAL, PAD_SHAPE_RECT, PAD_SHAPE_ROUNDRECT, PAD_SHAPE_TRAPEZOID, RotatePoint(), D_PAD::ShapePos(), wxPoint::x, and wxPoint::y.

Referenced by createNewPad().

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  default:
499  wxFAIL_MSG( "CINFO3D_VISU::createNewPadWithClearance - a pad shape type is not implemented" );
500  break;
501  }
502 }
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:351
void RotatePoint(int *pX, int *pY, double angle)
Definition: trigo.cpp:317
PAD_SHAPE_T GetShape() const
Function GetShape.
Definition: class_pad.h:166
#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...
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
const wxSize & GetSize() const
Definition: class_pad.h:182
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:214
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:367
COBJECT2D * CINFO3D_VISU::createNewTrack ( const TRACK aTrack,
int  aClearanceValue 
) const
private

Definition at line 251 of file create_layer_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().

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:198
const wxPoint & GetEnd() const
Definition: class_track.h:118
class TRACK, a track segment (segment on a copper layer)
Definition: typeinfo.h:107
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:121
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:115
class VIA, a via (like a track segment on a copper layer)
Definition: typeinfo.h:108
void CINFO3D_VISU::destroyLayers ( )
private

Definition at line 1062 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(), and ~CINFO3D_VISU().

1063 {
1064  if( !m_layers_poly.empty() )
1065  {
1066  for( MAP_POLY::iterator ii = m_layers_poly.begin();
1067  ii != m_layers_poly.end();
1068  ++ii )
1069  {
1070  delete ii->second;
1071  ii->second = NULL;
1072  }
1073 
1074  m_layers_poly.clear();
1075  }
1076 
1077  if( !m_layers_inner_holes_poly.empty() )
1078  {
1079  for( MAP_POLY::iterator ii = m_layers_inner_holes_poly.begin();
1080  ii != m_layers_inner_holes_poly.end();
1081  ++ii )
1082  {
1083  delete ii->second;
1084  ii->second = NULL;
1085  }
1086 
1087  m_layers_inner_holes_poly.clear();
1088  }
1089 
1090  if( !m_layers_outer_holes_poly.empty() )
1091  {
1092  for( MAP_POLY::iterator ii = m_layers_outer_holes_poly.begin();
1093  ii != m_layers_outer_holes_poly.end();
1094  ++ii )
1095  {
1096  delete ii->second;
1097  ii->second = NULL;
1098  }
1099 
1100  m_layers_outer_holes_poly.clear();
1101  }
1102 
1103  if( !m_layers_container2D.empty() )
1104  {
1105  for( MAP_CONTAINER_2D::iterator ii = m_layers_container2D.begin();
1106  ii != m_layers_container2D.end();
1107  ++ii )
1108  {
1109  delete ii->second;
1110  ii->second = NULL;
1111  }
1112 
1113  m_layers_container2D.clear();
1114  }
1115 
1116  if( !m_layers_holes2D.empty() )
1117  {
1118  for( MAP_CONTAINER_2D::iterator ii = m_layers_holes2D.begin();
1119  ii != m_layers_holes2D.end();
1120  ++ii )
1121  {
1122  delete ii->second;
1123  ii->second = NULL;
1124  }
1125 
1126  m_layers_holes2D.clear();
1127  }
1128 
1135  //m_through_inner_holes_poly.RemoveAllContours();
1136 
1139 }
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 m_3d_model_manager.

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 BOARD* CINFO3D_VISU::GetBoard ( ) const
inline
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 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 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 281 of file cinfo3d_visu.cpp.

Referenced by buildPadShapeThickOutlineAsPolygon(), buildPadShapeThickOutlineAsSegments(), createLayers(), transformGraphicModuleEdgeToPolygonSet(), and transformPadsShapesWithClearanceToPolygon().

282 {
283  wxASSERT( aNrSides >= 3 );
284 
285  return 1.0 / cos( M_PI / ( (double)aNrSides * 2.0 ) );
286 }
SFVEC3F CINFO3D_VISU::GetColor ( COLOR4D  aColor) const

GetColor.

Parameters
aColorthe color mapped
Returns
the color in SFVEC3F format

Definition at line 545 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(), and GetItemColor().

546 {
547  return SFVEC3F( aColor.r, aColor.g, aColor.b );
548 }
double g
Green component.
Definition: color4d.h:282
double b
Blue component.
Definition: color4d.h:283
glm::vec3 SFVEC3F
Definition: xv3d_types.h:47
double r
Red component.
Definition: color4d.h:281
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 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(), 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
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 539 of file cinfo3d_visu.cpp.

References g_ColorsSettings, GetColor(), and COLORS_DESIGN_SETTINGS::GetItemColor().

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

540 {
541  return GetColor( g_ColorsSettings.GetItemColor( aItemId ) );
542 }
COLOR4D GetItemColor(int aItemIdx) const
Function GetItemColor.
COLORS_DESIGN_SETTINGS g_ColorsSettings
Definition: pcbnew.cpp:68
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 529 of file cinfo3d_visu.cpp.

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

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

530 {
531  wxASSERT( aLayerId < PCB_LAYER_ID_COUNT );
532 
533  const COLOR4D color = g_ColorsSettings.GetLayerColor( aLayerId );
534 
535  return SFVEC3F( color.r, color.g, color.b );
536 }
double g
Green component.
Definition: color4d.h:282
double b
Blue component.
Definition: color4d.h:283
COLORS_DESIGN_SETTINGS g_ColorsSettings
Definition: pcbnew.cpp:68
glm::vec3 SFVEC3F
Definition: xv3d_types.h:47
COLOR4D GetLayerColor(LAYER_NUM aLayer) const
Function GetLayerColor.
double r
Red component.
Definition: color4d.h:281
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 494 of file cinfo3d_visu.cpp.

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

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

495 {
496  if( aIsFlipped )
497  {
498  if( GetFlag( FL_SOLDERPASTE ) )
500  else
502  }
503  else
504  {
505  if( GetFlag( FL_SOLDERPASTE ) )
506  return m_layerZcoordTop[F_SilkS];
507  else
508  return m_layerZcoordTop[F_Paste];
509  }
510 }
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
aDiameterdiameter in 3DU
Returns
number of sides that should be used in that circle

Definition at line 255 of file cinfo3d_visu.cpp.

References m_calc_seg_max_factor3DU, m_calc_seg_min_factor3DU, mapf(), MAX_SEG_PER_CIRCLE, and MIN_SEG_PER_CIRCLE.

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

256 {
257  wxASSERT( aDiameter3DU > 0.0f );
258 
259  unsigned int result = mapf( aDiameter3DU,
261  (float)MIN_SEG_PER_CIRCLE, (float)MAX_SEG_PER_CIRCLE );
262  wxASSERT( result > 1 );
263 
264  return result;
265 }
float m_calc_seg_min_factor3DU
min factor used for cicle segment approximation calculation
Definition: cinfo3d_visu.h:641
float mapf(float x, float in_min, float in_max, float out_min, float out_max)
Definition: 3d_math.h:136
float m_calc_seg_max_factor3DU
max factor used for cicle segment approximation calculation
Definition: cinfo3d_visu.h:644
#define MIN_SEG_PER_CIRCLE
#define MAX_SEG_PER_CIRCLE
unsigned int CINFO3D_VISU::GetNrSegmentsCircle ( int  aDiameterBUI) const

GetNrSegmentsCircle.

Parameters
aDiameterBUIdiameter in board unities
Returns
number of sides that should be used in that circle

Definition at line 268 of file cinfo3d_visu.cpp.

References mapf(), MAX_SEG_PER_CIRCLE, MIN_SEG_PER_CIRCLE, SEG_MAX_FACTOR_BIU, and SEG_MIN_FACTOR_BIU.

269 {
270  wxASSERT( aDiameterBUI > 0 );
271 
272  unsigned int result = mapf( (float)aDiameterBUI,
273  (float)SEG_MIN_FACTOR_BIU, (float)SEG_MAX_FACTOR_BIU,
274  (float)MIN_SEG_PER_CIRCLE, (float)MAX_SEG_PER_CIRCLE );
275  wxASSERT( result > 1 );
276 
277  return result;
278 }
#define SEG_MIN_FACTOR_BIU
float mapf(float x, float in_min, float in_max, float out_min, float out_max)
Definition: 3d_math.h:136
#define MIN_SEG_PER_CIRCLE
#define SEG_MAX_FACTOR_BIU
#define MAX_SEG_PER_CIRCLE
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
const MAP_POLY& CINFO3D_VISU::GetPolyMapHoles_Outer ( ) const
inline

Definition at line 418 of file cinfo3d_visu.h.

References m_layers_outer_holes_poly.

Referenced by C3D_RENDER_OGL_LEGACY::reload().

418 { return m_layers_outer_holes_poly; }
MAP_POLY m_layers_outer_holes_poly
It contains polygon contours for holes of each layer (outer holes)
Definition: cinfo3d_visu.h:560
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 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 289 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_calc_seg_max_factor3DU, m_calc_seg_min_factor3DU, 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(), SEG_MAX_FACTOR_BIU, SEG_MIN_FACTOR_BIU, TECH_LAYER_THICKNESS, wxPoint::x, and wxPoint::y.

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

290 {
291  wxLogTrace( m_logTrace, wxT( "CINFO3D_VISU::InitSettings" ) );
292 
293  // Calculates the board bounding box
294  // First, use only the board outlines
295  EDA_RECT bbbox = m_board->ComputeBoundingBox( true );
296 
297  // If no outlines, use the board with items
298  if( ( bbbox.GetWidth() == 0 ) && ( bbbox.GetHeight() == 0 ) )
299  bbbox = m_board->ComputeBoundingBox( false );
300 
301  // Gives a non null size to avoid issues in zoom / scale calculations
302  if( ( bbbox.GetWidth() == 0 ) && ( bbbox.GetHeight() == 0 ) )
303  bbbox.Inflate( Millimeter2iu( 10 ) );
304 
305  m_boardSize = bbbox.GetSize();
306  m_boardPos = bbbox.Centre();
307 
308  wxASSERT( (m_boardSize.x > 0) && (m_boardSize.y > 0) );
309 
310  m_boardPos.y = -m_boardPos.y; // The y coord is inverted in 3D viewer
311 
313 
314  // Ensure the board has 2 sides for 3D views, because it is hard to find
315  // a *really* single side board in the true life...
316  if( m_copperLayersCount < 2 )
318 
319  // Calculate the convertion to apply to all positions.
321 
322  // Calculate factors for cicle segment approximation
324  m_calc_seg_max_factor3DU = (float)( SEG_MAX_FACTOR_BIU * m_biuTo3Dunits );
325 
328 
329  // !TODO: use value defined by user (currently use default values by ctor
332 
333  // Init Z position of each layer
334  // calculate z position for each copper layer
335  // Zstart = -m_epoxyThickness / 2.0 is the z position of the back (bottom layer) (layer id = 31)
336  // Zstart = +m_epoxyThickness / 2.0 is the z position of the front (top layer) (layer id = 0)
337  // all unused copper layer z position are set to 0
338 
339  // ____==__________==________==______ <- Bottom = +m_epoxyThickness / 2.0,
340  // | | Top = Bottom + m_copperThickness
341  // |__________________________________|
342  // == == == == <- Bottom = -m_epoxyThickness / 2.0,
343  // Top = Bottom - m_copperThickness
344 
345  unsigned int layer;
346 
347  for( layer = 0; layer < m_copperLayersCount; ++layer )
348  {
349  m_layerZcoordBottom[layer] = m_epoxyThickness3DU / 2.0f -
350  (m_epoxyThickness3DU * layer / (m_copperLayersCount - 1) );
351 
352  if( layer < (m_copperLayersCount / 2) )
354  else
356  }
357 
358  #define layerThicknessMargin 1.1
359  const float zpos_offset = m_nonCopperLayerThickness3DU * layerThicknessMargin;
360 
361  // Fill remaining unused copper layers and back layer zpos
362  // with -m_epoxyThickness / 2.0
363  for( ; layer < MAX_CU_LAYERS; layer++ )
364  {
365  m_layerZcoordBottom[layer] = -(m_epoxyThickness3DU / 2.0f);
367  }
368 
369  // This is the top of the copper layer thickness.
370  const float zpos_copperTop_back = m_layerZcoordTop[B_Cu];
371  const float zpos_copperTop_front = m_layerZcoordTop[F_Cu];
372 
373  // calculate z position for each non copper layer
374  // Solder mask and Solder paste have the same Z position
375  for( int layer_id = MAX_CU_LAYERS; layer_id < PCB_LAYER_ID_COUNT; ++layer_id )
376  {
377  float zposTop;
378  float zposBottom;
379 
380  switch( layer_id )
381  {
382  case B_Adhes:
383  zposBottom = zpos_copperTop_back - 2.0f * zpos_offset;
384  zposTop = zposBottom - m_nonCopperLayerThickness3DU;
385  break;
386 
387  case F_Adhes:
388  zposBottom = zpos_copperTop_front + 2.0f * zpos_offset;
389  zposTop = zposBottom + m_nonCopperLayerThickness3DU;
390  break;
391 
392  case B_Mask:
393  case B_Paste:
394  zposBottom = zpos_copperTop_back;
395  zposTop = zpos_copperTop_back - m_nonCopperLayerThickness3DU;
396  break;
397 
398  case F_Mask:
399  case F_Paste:
400  zposTop = zpos_copperTop_front + m_nonCopperLayerThickness3DU;
401  zposBottom = zpos_copperTop_front;
402  break;
403 
404  case B_SilkS:
405  zposBottom = zpos_copperTop_back - 1.0f * zpos_offset;
406  zposTop = zposBottom - m_nonCopperLayerThickness3DU;
407  break;
408 
409  case F_SilkS:
410  zposBottom = zpos_copperTop_front + 1.0f * zpos_offset;
411  zposTop = zposBottom + m_nonCopperLayerThickness3DU;
412  break;
413 
414  // !TODO: review
415  default:
416  zposTop = zpos_copperTop_front + (layer_id - MAX_CU_LAYERS + 3.0f) * zpos_offset;
417  zposBottom = zposTop - m_nonCopperLayerThickness3DU;
418  break;
419  }
420 
421  m_layerZcoordTop[layer_id] = zposTop;
422  m_layerZcoordBottom[layer_id] = zposBottom;
423  }
424 
425  m_boardCenter = SFVEC3F( m_boardPos.x * m_biuTo3Dunits,
426  m_boardPos.y * m_biuTo3Dunits,
427  0.0f );
428 
429  SFVEC3F boardSize = SFVEC3F( m_boardSize.x * m_biuTo3Dunits,
430  m_boardSize.y * m_biuTo3Dunits,
431  0.0f );
432  boardSize /= 2.0f;
433 
434  SFVEC3F boardMin = (m_boardCenter - boardSize);
435  SFVEC3F boardMax = (m_boardCenter + boardSize);
436 
437  boardMin.z = m_layerZcoordTop[B_Adhes];
438  boardMax.z = m_layerZcoordTop[F_Adhes];
439 
440  m_boardBoudingBox = CBBOX( boardMin, boardMax );
441 
442 #ifdef PRINT_STATISTICS_3D_VIEWER
443  unsigned stats_startCreateBoardPolyTime = GetRunningMicroSecs();
444 #endif
445 
446  if( aStatusTextReporter )
447  aStatusTextReporter->Report( _( "Build board body" ) );
448 
450 
451 #ifdef PRINT_STATISTICS_3D_VIEWER
452  unsigned stats_stopCreateBoardPolyTime = GetRunningMicroSecs();
453  unsigned stats_startCreateLayersTime = stats_stopCreateBoardPolyTime;
454 #endif
455 
456  if( aStatusTextReporter )
457  aStatusTextReporter->Report( _( "Create layers" ) );
458 
459  createLayers( aStatusTextReporter );
460 
461 #ifdef PRINT_STATISTICS_3D_VIEWER
462  unsigned stats_stopCreateLayersTime = GetRunningMicroSecs();
463 
464  printf( "CINFO3D_VISU::InitSettings times\n" );
465  printf( " CreateBoardPoly: %.3f ms\n",
466  (float)( stats_stopCreateBoardPolyTime - stats_startCreateBoardPolyTime ) / 1e3 );
467  printf( " CreateLayers and holes: %.3f ms\n",
468  (float)( stats_stopCreateLayersTime - stats_startCreateLayersTime ) / 1e3 );
469  printf( "\n" );
470 #endif
471 }
#define SEG_MIN_FACTOR_BIU
wxPoint m_boardPos
center board actual position in board units
Definition: cinfo3d_visu.h:539
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
float m_calc_seg_min_factor3DU
min factor used for cicle segment approximation calculation
Definition: cinfo3d_visu.h:641
int GetCopperLayerCount() const
Function GetCopperLayerCount.
int GetHeight() const
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
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:530
wxPoint Centre() const
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
#define SEG_MAX_FACTOR_BIU
float m_copperThickness3DU
Copper thickness (normalized)
Definition: cinfo3d_visu.h:625
Class EDA_RECT handles the component boundary box.
unsigned int m_copperLayersCount
Number of copper layers actually used by the board.
Definition: cinfo3d_visu.h:612
int GetWidth() const
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
const wxSize & GetSize() const
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(), 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:530
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(), EDA_3D_VIEWER::LoadSettings(), DIALOG_3D_VIEW_OPTIONS::OnOKClick(), EDA_3D_VIEWER::Process_Special_Functions(), and EDA_3D_CANVAS::SetView3D().

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 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 669 of file create_layer_items.cpp.

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

Referenced by AddShapeWithClearanceToContainer().

676 {
677  wxPoint arc_start, arc_end;
678  int delta = 3600 / aCircleToSegmentsCount; // rotate angle in 0.1 degree
679 
680  arc_end = arc_start = aStart;
681 
682  if( aArcAngle != 3600 )
683  {
684  RotatePoint( &arc_end, aCentre, -aArcAngle );
685  }
686 
687  if( aArcAngle < 0 )
688  {
689  std::swap( arc_start, arc_end );
690  aArcAngle = -aArcAngle;
691  }
692 
693  // Compute the ends of segments and creates poly
694  wxPoint curr_end = arc_start;
695  wxPoint curr_start = arc_start;
696 
697  for( int ii = delta; ii < aArcAngle; ii += delta )
698  {
699  curr_end = arc_start;
700  RotatePoint( &curr_end, aCentre, -ii );
701 
702  const SFVEC2F start3DU( curr_start.x * m_biuTo3Dunits, -curr_start.y * m_biuTo3Dunits );
703  const SFVEC2F end3DU ( curr_end.x * m_biuTo3Dunits, -curr_end.y * m_biuTo3Dunits );
704 
705  if( Is_segment_a_circle( start3DU, end3DU ) )
706  {
707  aDstContainer->Add( new CFILLEDCIRCLE2D( start3DU,
708  ( aWidth / 2 ) * m_biuTo3Dunits,
709  aBoardItem ) );
710  }
711  else
712  {
713  aDstContainer->Add( new CROUNDSEGMENT2D( start3DU,
714  end3DU,
715  aWidth * m_biuTo3Dunits,
716  aBoardItem ) );
717  }
718 
719  curr_start = curr_end;
720  }
721 
722  if( curr_end != arc_end )
723  {
724  const SFVEC2F start3DU( curr_end.x * m_biuTo3Dunits, -curr_end.y * m_biuTo3Dunits );
725  const SFVEC2F end3DU ( arc_end.x * m_biuTo3Dunits, -arc_end.y * m_biuTo3Dunits );
726 
727  if( Is_segment_a_circle( start3DU, end3DU ) )
728  {
729  aDstContainer->Add( new CFILLEDCIRCLE2D( start3DU,
730  ( aWidth / 2 ) * m_biuTo3Dunits,
731  aBoardItem ) );
732  }
733  else
734  {
735  aDstContainer->Add( new CROUNDSEGMENT2D( start3DU,
736  end3DU,
737  aWidth * m_biuTo3Dunits,
738  aBoardItem ) );
739  }
740  }
741 }
void RotatePoint(int *pX, int *pY, double angle)
Definition: trigo.cpp:317
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 193 of file create_layer_poly.cpp.

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

Referenced by createLayers().

196 {
197  for( const EDA_ITEM* item = aModule->GraphicalItems();
198  item != NULL;
199  item = item->Next() )
200  {
201  switch( item->Type() )
202  {
203  case PCB_MODULE_EDGE_T:
204  {
205  EDGE_MODULE*outline = (EDGE_MODULE*) item;
206 
207  if( outline->GetLayer() != aLayer )
208  break;
209 
210  unsigned int aCircleToSegmentsCount =
212 
213  double aCorrectionFactor = GetCircleCorrectionFactor( aCircleToSegmentsCount );
214 
215  outline->TransformShapeWithClearanceToPolygon( aCornerBuffer,
216  0,
217  aCircleToSegmentsCount,
218  aCorrectionFactor );
219  }
220  break;
221 
222  default:
223  break;
224  }
225  }
226 }
class EDGE_MODULE, a footprint edge
Definition: typeinfo.h:106
DLIST< BOARD_ITEM > & GraphicalItems()
Definition: class_module.h:137
BOARD_ITEM * Next() const
int GetSizeMax() const
GetSizeMax.
void TransformShapeWithClearanceToPolygon(SHAPE_POLY_SET &aCornerBuffer, int aClearanceValue, int aCircleToSegmentsCount, double aCorrectionFactor) const
Function TransformShapeWithClearanceToPolygon Convert the track shape to a closed polygon Used in fil...
unsigned int GetNrSegmentsCircle(float aDiameter3DU) const
GetNrSegmentsCircle.
PCB_LAYER_ID GetLayer() const
Function GetLayer returns the primary layer this item is on.
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:151
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 128 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().

132 {
133  const D_PAD* pad = aPads;
134 
135  wxSize margin;
136  for( ; pad != NULL; pad = pad->Next() )
137  {
138  if( !pad->IsOnLayer(aLayer) )
139  continue;
140 
141  // NPTH pads are not drawn on layers if the shape size and pos is the same
142  // as their hole:
143  if( aSkipNPTHPadsWihNoCopper && (pad->GetAttribute() == PAD_ATTRIB_HOLE_NOT_PLATED) )
144  {
145  if( (pad->GetDrillSize() == pad->GetSize()) &&
146  (pad->GetOffset() == wxPoint( 0, 0 )) )
147  {
148  switch( pad->GetShape() )
149  {
150  case PAD_SHAPE_CIRCLE:
151  if( pad->GetDrillShape() == PAD_DRILL_SHAPE_CIRCLE )
152  continue;
153  break;
154 
155  case PAD_SHAPE_OVAL:
156  if( pad->GetDrillShape() != PAD_DRILL_SHAPE_CIRCLE )
157  continue;
158  break;
159 
160  default:
161  break;
162  }
163  }
164  }
165 
166  switch( aLayer )
167  {
168  case F_Mask:
169  case B_Mask:
170  margin.x = margin.y = pad->GetSolderMaskMargin() + aInflateValue;
171  break;
172 
173  case F_Paste:
174  case B_Paste:
175  margin = pad->GetSolderPasteMargin();
176  margin.x += aInflateValue;
177  margin.y += aInflateValue;
178  break;
179 
180  default:
181  margin.x = margin.y = aInflateValue;
182  break;
183  }
184 
185  unsigned int aCircleToSegmentsCount = GetNrSegmentsCircle( pad->GetSize().x );
186  double aCorrectionFactor = GetCircleCorrectionFactor( aCircleToSegmentsCount );
187 
188  buildPadShapePolygon( pad, aCornerBuffer, margin,
189  aCircleToSegmentsCount, aCorrectionFactor );
190  }
191 }
PAD_ATTR_T GetAttribute() const
Definition: class_pad.h:238
like PAD_STANDARD, but not plated mechanical use only, no connection allowed
Definition: pad_shapes.h:63
PAD_DRILL_SHAPE_T GetDrillShape() const
Definition: class_pad.h:221
const wxSize & GetDrillSize() const
Definition: class_pad.h:188
PAD_SHAPE_T GetShape() const
Function GetShape.
Definition: class_pad.h:166
int GetSolderMaskMargin() const
Function GetSolderMaskMargin.
Definition: class_pad.cpp:486
D_PAD * Next() const
Definition: class_pad.h:106
const wxSize & GetSize() const
Definition: class_pad.h:182
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:519
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:479
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:191

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().