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

49  :
52 {
53  wxLogTrace( m_logTrace, wxT( "CINFO3D_VISU::CINFO3D_VISU" ) );
54 
55  m_board = NULL;
56  m_3d_model_manager = NULL;
58  m_drawFlags.resize( FL_LAST, false );
59 
62 
63  m_boardPos = wxPoint();
64  m_boardSize = wxSize();
66 
69 
70  m_layers_container2D.clear();
71  m_layers_holes2D.clear();
74 
76  m_epoxyThickness3DU = 0.0f;
77  m_copperThickness3DU = 0.0f;
79  m_biuTo3Dunits = 1.0;
80 
82  m_stats_nr_vias = 0;
84  m_stats_nr_holes = 0;
87 
90 
91 
92  memset( m_layerZcoordTop, 0, sizeof( m_layerZcoordTop ) );
93  memset( m_layerZcoordBottom, 0, sizeof( m_layerZcoordBottom ) );
94 
97  SetFlag( FL_SHOW_BOARD_BODY, true );
102  SetFlag( FL_ZONE, true );
103  SetFlag( FL_SILKSCREEN, true );
104  SetFlag( FL_SOLDERMASK, true );
105 
106  m_BgColorBot = SFVEC3D( 0.4, 0.4, 0.5 );
107  m_BgColorTop = SFVEC3D( 0.8, 0.8, 0.9 );
108  m_BoardBodyColor = SFVEC3D( 0.4, 0.4, 0.5 );
109  m_SolderMaskColor = SFVEC3D( 0.1, 0.2, 0.1 );
110  m_SolderPasteColor = SFVEC3D( 0.4, 0.4, 0.4 );
111  m_SilkScreenColor = SFVEC3D( 0.9, 0.9, 0.9 );
112  m_CopperColor = SFVEC3D( 0.75, 0.61, 0.23 );
113 }
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 116 of file cinfo3d_visu.cpp.

References destroyLayers().

117 {
118  destroyLayers();
119 }

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::GraphicalItemsList(), EDA_TEXT::IsItalic(), EDA_TEXT::IsMirrored(), EDA_TEXT::IsVisible(), m_biuTo3Dunits, m_board2dBBox3DU, BOARD_ITEM::Next(), PCB_MODULE_EDGE_T, PCB_MODULE_TEXT_T, MODULE::Reference(), s_biuTo3Dunits, s_textWidth, and MODULE::Value().

Referenced by createLayers().

183 {
184  std::vector<TEXTE_MODULE *> texts; // List of TEXTE_MODULE to convert
185  EDGE_MODULE* outline;
186 
187  for( EDA_ITEM* item = aModule->GraphicalItemsList();
188  item != NULL;
189  item = item->Next() )
190  {
191  switch( item->Type() )
192  {
193  case PCB_MODULE_TEXT_T:
194  {
195  TEXTE_MODULE* text = static_cast<TEXTE_MODULE*>( item );
196 
197  if( text->GetLayer() == aLayerId && text->IsVisible() )
198  texts.push_back( text );
199  }
200  break;
201 
202 
203  case PCB_MODULE_EDGE_T:
204  {
205  outline = (EDGE_MODULE*) item;
206 
207  if( outline->GetLayer() != aLayerId )
208  break;
209 
211  aDstContainer,
212  aLayerId, 0 );
213  }
214  break;
215 
216  default:
217  break;
218  }
219  }
220 
221  // Convert texts sur modules
222  if( aModule->Reference().GetLayer() == aLayerId && aModule->Reference().IsVisible() )
223  texts.push_back( &aModule->Reference() );
224 
225  if( aModule->Value().GetLayer() == aLayerId && aModule->Value().IsVisible() )
226  texts.push_back( &aModule->Value() );
227 
228  s_boardItem = (const BOARD_ITEM *)&aModule->Value();
229  s_dstcontainer = aDstContainer;
232 
233  for( unsigned ii = 0; ii < texts.size(); ++ii )
234  {
235  TEXTE_MODULE *textmod = texts[ii];
236  s_textWidth = textmod->GetThickness() + ( 2 * aInflateValue );
237  wxSize size = textmod->GetTextSize();
238 
239  if( textmod->IsMirrored() )
240  size.x = -size.x;
241 
242  DrawGraphicText( NULL, NULL, textmod->GetTextPos(), BLACK,
243  textmod->GetShownText(), textmod->GetDrawRotation(), size,
244  textmod->GetHorizJustify(), textmod->GetVertJustify(),
245  textmod->GetThickness(), textmod->IsItalic(),
246  true, addTextSegmToContainer );
247  }
248 }
void AddShapeWithClearanceToContainer(const TEXTE_PCB *aTextPCB, CGENERICCONTAINER2D *aDstContainer, PCB_LAYER_ID aLayerId, int aClearanceValue)
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:483
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 PCB_LAYER_ID GetLayer() const
Function GetLayer returns the primary layer this item is on.
virtual wxString GetShownText() const override
Returns the string actually shown after processing of the base text.
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:94
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:482
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:93
EDA_TEXT_VJUSTIFY_T GetVertJustify() const
Definition: eda_text.h:191
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:178
static int s_textWidth
DLIST< BOARD_ITEM > & GraphicalItemsList()
Definition: class_module.h:157
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 616 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::PadsList().

Referenced by createLayers().

621 {
622  const D_PAD* pad = aModule->PadsList();
623 
624  wxSize margin;
625 
626  for( ; pad != NULL; pad = pad->Next() )
627  {
628  if( !pad->IsOnLayer( aLayerId ) )
629  continue;
630 
631  // NPTH pads are not drawn on layers if the
632  // shape size and pos is the same as their hole:
633  if( aSkipNPTHPadsWihNoCopper && (pad->GetAttribute() == PAD_ATTRIB_HOLE_NOT_PLATED) )
634  {
635  if( (pad->GetDrillSize() == pad->GetSize()) &&
636  (pad->GetOffset() == wxPoint( 0, 0 )) )
637  {
638  switch( pad->GetShape() )
639  {
640  case PAD_SHAPE_CIRCLE:
641  if( pad->GetDrillShape() == PAD_DRILL_SHAPE_CIRCLE )
642  continue;
643  break;
644 
645  case PAD_SHAPE_OVAL:
646  if( pad->GetDrillShape() != PAD_DRILL_SHAPE_CIRCLE )
647  continue;
648  break;
649 
650  default:
651  break;
652  }
653  }
654  }
655 
656  switch( aLayerId )
657  {
658  case F_Mask:
659  case B_Mask:
660  margin.x = margin.y = pad->GetSolderMaskMargin() + aInflateValue;
661  break;
662 
663  case F_Paste:
664  case B_Paste:
665  margin = pad->GetSolderPasteMargin();
666  margin.x += aInflateValue;
667  margin.y += aInflateValue;
668  break;
669 
670  default:
671  margin.x = margin.y = aInflateValue;
672  break;
673  }
674 
675  createNewPad( pad, aDstContainer, margin );
676  }
677 }
PAD_ATTR_T GetAttribute() const
Definition: class_pad.h:398
like PAD_STANDARD, but not plated mechanical use only, no connection allowed
Definition: pad_shapes.h:65
PAD_DRILL_SHAPE_T GetDrillShape() const
Definition: class_pad.h:381
const wxSize & GetDrillSize() const
Definition: class_pad.h:275
PAD_SHAPE_T GetShape() const
Function GetShape.
Definition: class_pad.h:216
int GetSolderMaskMargin() const
Function GetSolderMaskMargin.
Definition: class_pad.cpp:577
D_PAD * Next() const
Definition: class_pad.h:160
const wxSize & GetSize() const
Definition: class_pad.h:269
wxSize GetSolderPasteMargin() const
Function GetSolderPasteMargin.
Definition: class_pad.cpp:610
DLIST< D_PAD > & PadsList()
Definition: class_module.h:154
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:637
const wxPoint & GetOffset() const
Definition: class_pad.h:278
void CINFO3D_VISU::AddShapeWithClearanceToContainer ( const TEXTE_PCB aTextPCB,
CGENERICCONTAINER2D aDstContainer,
PCB_LAYER_ID  aLayerId,
int  aClearanceValue 
)
private

Definition at line 92 of file create_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:314
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 758 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.

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

925 {
926  // Copy the polys list because we have to simplify it
927  SHAPE_POLY_SET polyList = SHAPE_POLY_SET(aZoneContainer->GetFilledPolysList());
928 
929  // This convert the poly in outline and holes
930 
931  // Note: This two sequencial calls are need in order to get
932  // the triangulation function to work properly.
933  polyList.Simplify( SHAPE_POLY_SET::PM_FAST );
935 
936  if( polyList.IsEmpty() )
937  return;
938 
940  *aDstContainer,
942  *aZoneContainer );
943 
944 
945  // add filled areas outlines, which are drawn with thick lines segments
946  // /////////////////////////////////////////////////////////////////////////
947  for( int i = 0; i < polyList.OutlineCount(); ++i )
948  {
949  // Add outline
950  const SHAPE_LINE_CHAIN& pathOutline = polyList.COutline( i );
951 
952  for( int j = 0; j < pathOutline.PointCount(); ++j )
953  {
954  const VECTOR2I& a = pathOutline.CPoint( j );
955  const VECTOR2I& b = pathOutline.CPoint( j + 1 );
956 
957  SFVEC2F start3DU( a.x * m_biuTo3Dunits, -a.y * m_biuTo3Dunits );
958  SFVEC2F end3DU ( b.x * m_biuTo3Dunits, -b.y * m_biuTo3Dunits );
959 
960  if( Is_segment_a_circle( start3DU, end3DU ) )
961  {
962  aDstContainer->Add( new CFILLEDCIRCLE2D( start3DU,
963  (aZoneContainer->GetMinThickness() / 2) *
965  *aZoneContainer ) );
966  }
967  else
968  {
969  aDstContainer->Add( new CROUNDSEGMENT2D( start3DU, end3DU,
970  aZoneContainer->GetMinThickness() *
972  *aZoneContainer ) );
973  }
974  }
975 
976  // Add holes (of the poly, ie: the open parts) for this outline
977  for( int h = 0; h < polyList.HoleCount( i ); ++h )
978  {
979  const SHAPE_LINE_CHAIN& pathHole = polyList.CHole( i, h );
980 
981  for( int j = 0; j < pathHole.PointCount(); j++ )
982  {
983  const VECTOR2I& a = pathHole.CPoint( j );
984  const VECTOR2I& b = pathHole.CPoint( j + 1 );
985 
986  SFVEC2F start3DU( a.x * m_biuTo3Dunits, -a.y * m_biuTo3Dunits );
987  SFVEC2F end3DU ( b.x * m_biuTo3Dunits, -b.y * m_biuTo3Dunits );
988 
989  if( Is_segment_a_circle( start3DU, end3DU ) )
990  {
991  aDstContainer->Add(
992  new CFILLEDCIRCLE2D( start3DU,
993  (aZoneContainer->GetMinThickness() / 2) *
995  *aZoneContainer ) );
996  }
997  else
998  {
999  aDstContainer->Add(
1000  new CROUNDSEGMENT2D( start3DU, end3DU,
1001  aZoneContainer->GetMinThickness() *
1003  *aZoneContainer ) );
1004  }
1005  }
1006  }
1007  }
1008 }
int GetMinThickness() const
Definition: class_zone.h:198
int PointCount() const
Function PointCount()
int HoleCount(int aOutline) const
Returns the number of holes in a given outline
const SHAPE_LINE_CHAIN & CHole(int aOutline, int aHole) const
int OutlineCount() const
Returns the number of outlines in the set
bool Is_segment_a_circle(const SFVEC2F &aStart, const SFVEC2F &aEnd)
Segment_is_a_circle - check if segment start and end is very close to each other should used to check...
glm::vec2 SFVEC2F
Definition: xv3d_types.h:45
Class SHAPE_POLY_SET.
void Convert_shape_line_polygon_to_triangles(const SHAPE_POLY_SET &aPolyList, CGENERICCONTAINER2D &aDstContainer, float aBiuTo3DunitsScale, const BOARD_ITEM &aBoardItem)
double m_biuTo3Dunits
Normalization scale to convert board internal units to 3D units to normalize 3D units between -1...
Definition: cinfo3d_visu.h:616
const SHAPE_LINE_CHAIN & COutline(int aIndex) const
void Simplify(POLYGON_MODE aFastMode)
Simplifies the polyset (merges overlapping polys, eliminates degeneracy/self-intersections) For aFast...
const SHAPE_POLY_SET & GetFilledPolysList() const
Function GetFilledPolysList returns a reference to the list of filled polygons.
Definition: class_zone.h:534
void Add(COBJECT2D *aObject)
Definition: ccontainer2d.h:51
Class SHAPE_LINE_CHAIN.
bool IsEmpty() const
Returns true if the set is empty (no polygons at all)
const VECTOR2I & CPoint(int aIndex) const
Function CPoint()
double CINFO3D_VISU::BiuTo3Dunits ( ) const
inline

BiuTo3Dunits - Board integer units To 3D units.

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

Definition at line 141 of file cinfo3d_visu.h.

References m_biuTo3Dunits.

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

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

Definition at line 41 of file create_layer_poly.cpp.

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

Referenced by buildPadShapeThickOutlineAsPolygon(), and transformPadsShapesWithClearanceToPolygon().

46 {
47  wxPoint corners[4];
48  wxPoint PadShapePos = aPad->ShapePos(); /* Note: for pad having a shape offset,
49  * the pad position is NOT the shape position */
50  switch( aPad->GetShape() )
51  {
52  case PAD_SHAPE_CIRCLE:
53  case PAD_SHAPE_OVAL:
55  aPad->TransformShapeWithClearanceToPolygon( aCornerBuffer, aInflateValue.x,
56  aSegmentsPerCircle, aCorrectionFactor );
57  break;
58 
60  case PAD_SHAPE_RECT:
61  {
62  SHAPE_LINE_CHAIN aLineChain;
63 
64  aPad->BuildPadPolygon( corners, aInflateValue, aPad->GetOrientation() );
65 
66  for( int ii = 0; ii < 4; ++ii )
67  {
68  corners[3-ii] += PadShapePos; // Shift origin to position
69  aLineChain.Append( corners[3-ii].x, corners[3-ii].y );
70  }
71 
72  aLineChain.SetClosed( true );
73 
74  aCornerBuffer.AddOutline( aLineChain );
75  }
76  break;
77 
78  case PAD_SHAPE_CUSTOM:
79  {
80  SHAPE_POLY_SET polyList; // Will contain the pad outlines in board coordinates
81  polyList.Append( aPad->GetCustomShapeAsPolygon() );
82  aPad->CustomShapeAsPolygonToBoardPosition( &polyList, aPad->ShapePos(), aPad->GetOrientation() );
83  aCornerBuffer.Append( polyList );
84  }
85  break;
86  }
87 }
const SHAPE_POLY_SET & GetCustomShapeAsPolygon() const
Accessor to the custom shape as one polygon.
Definition: class_pad.h:341
void BuildPadPolygon(wxPoint aCoord[4], wxSize aInflateValue, double aRotation) const
Function BuildPadPolygon Has meaning only for polygonal pads (trapezoid and rectangular) Build the Co...
PAD_SHAPE_T GetShape() const
Function GetShape.
Definition: class_pad.h:216
void Append(int aX, int aY, bool aAllowDuplication=false)
Function Append()
void SetClosed(bool aClosed)
Function SetClosed()
void CustomShapeAsPolygonToBoardPosition(SHAPE_POLY_SET *aMergedPolygon, wxPoint aPosition, double aRotation) const
When created, the corners coordinates are relative to the pad position, orientation 0...
Class SHAPE_POLY_SET.
void TransformShapeWithClearanceToPolygon(SHAPE_POLY_SET &aCornerBuffer, int aClearanceValue, int aCircleToSegmentsCount, double aCorrectionFactor) const override
Function TransformShapeWithClearanceToPolygon Convert the pad shape to a closed polygon Used in filli...
int AddOutline(const SHAPE_LINE_CHAIN &aOutline)
Adds a new outline to the set and returns its index
Class SHAPE_LINE_CHAIN.
double GetOrientation() const
Function GetOrientation returns the rotation angle of the pad in tenths of degrees, but soon degrees.
Definition: class_pad.h:375
wxPoint ShapePos() const
Definition: class_pad.cpp:500
int Append(int x, int y, int aOutline=-1, int aHole=-1, bool aAllowDuplication=false)
Appends a vertex at the end of the given outline/hole (default: the last outline) ...
void CINFO3D_VISU::buildPadShapeThickOutlineAsPolygon ( const D_PAD aPad,
SHAPE_POLY_SET aCornerBuffer,
int  aWidth 
) const
private

Definition at line 90 of file create_layer_poly.cpp.

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

Referenced by createLayers().

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

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

1015 {
1016  if( aPad->GetShape() == PAD_SHAPE_CIRCLE ) // Draw a ring
1017  {
1018  const SFVEC2F center3DU( aPad->ShapePos().x * m_biuTo3Dunits,
1019  -aPad->ShapePos().y * m_biuTo3Dunits );
1020 
1021  const int radius = aPad->GetSize().x / 2;
1022  const float inner_radius = (radius - aWidth / 2) * m_biuTo3Dunits;
1023  const float outter_radius = (radius + aWidth / 2) * m_biuTo3Dunits;
1024 
1025  aDstContainer->Add( new CRING2D( center3DU,
1026  inner_radius,
1027  outter_radius,
1028  *aPad ) );
1029 
1030  return;
1031  }
1032 
1033  // For other shapes, draw polygon outlines
1034  SHAPE_POLY_SET corners;
1035 
1036  const int segcountforcircle = GetNrSegmentsCircle( glm::min( aPad->GetSize().x,
1037  aPad->GetSize().y) );
1038 
1039  const double correctionFactor = GetCircleCorrectionFactor( segcountforcircle );
1040 
1041  aPad->BuildPadShapePolygon( corners, wxSize( 0, 0 ),
1042  // This two factors are only expected to be used if render an oval
1043  segcountforcircle, correctionFactor );
1044 
1045 
1046  // Add outlines as thick segments in polygon buffer
1047 
1048  const SHAPE_LINE_CHAIN& path = corners.COutline( 0 );
1049 
1050  for( int j = 0; j < path.PointCount(); j++ )
1051  {
1052  const VECTOR2I& a = path.CPoint( j );
1053  const VECTOR2I& b = path.CPoint( j + 1 );
1054 
1055  SFVEC2F start3DU( a.x * m_biuTo3Dunits, -a.y * m_biuTo3Dunits );
1056  SFVEC2F end3DU ( b.x * m_biuTo3Dunits, -b.y * m_biuTo3Dunits );
1057 
1058  if( Is_segment_a_circle( start3DU, end3DU ) )
1059  {
1060  aDstContainer->Add( new CFILLEDCIRCLE2D( start3DU,
1061  (aWidth / 2) * m_biuTo3Dunits,
1062  *aPad ) );
1063  }
1064  else
1065  {
1066  aDstContainer->Add( new CROUNDSEGMENT2D( start3DU, end3DU,
1067  aWidth * m_biuTo3Dunits,
1068  *aPad ) );
1069  }
1070  }
1071 }
int PointCount() const
Function PointCount()
PAD_SHAPE_T GetShape() const
Function GetShape.
Definition: class_pad.h:216
bool Is_segment_a_circle(const SFVEC2F &aStart, const SFVEC2F &aEnd)
Segment_is_a_circle - check if segment start and end is very close to each other should used to check...
glm::vec2 SFVEC2F
Definition: xv3d_types.h:45
Class SHAPE_POLY_SET.
double m_biuTo3Dunits
Normalization scale to convert board internal units to 3D units to normalize 3D units between -1...
Definition: cinfo3d_visu.h:616
const wxSize & GetSize() const
Definition: class_pad.h:269
const SHAPE_LINE_CHAIN & COutline(int aIndex) const
unsigned int GetNrSegmentsCircle(float aDiameter3DU) const
GetNrSegmentsCircle.
void Add(COBJECT2D *aObject)
Definition: ccontainer2d.h:51
double GetCircleCorrectionFactor(int aNrSides) const
GetCircleCorrectionFactor - computes a angle correction factor used when creating circles...
Class SHAPE_LINE_CHAIN.
void BuildPadShapePolygon(SHAPE_POLY_SET &aCornerBuffer, wxSize aInflateValue, int aSegmentsPerCircle, double aCorrectionFactor) const
Function BuildPadShapePolygon Build the Corner list of the polygonal shape, depending on shape...
wxPoint ShapePos() const
Definition: class_pad.cpp:500
const VECTOR2I & CPoint(int aIndex) const
Function CPoint()
#define min(a, b)
Definition: auxiliary.h:85
void CINFO3D_VISU::CameraSetType ( CAMERA_TYPE  aCameraType)

CameraSetType - Set the camera type to use.

Parameters
aCameraTypecamera type to use in this canvas

Definition at line 512 of file cinfo3d_visu.cpp.

References CAMERA_TRACKBALL, m_currentCamera, and m_trackBallCamera.

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

474 {
476 
477  wxString errmsg;
478 
479  if( !m_board->GetBoardPolygonOutlines( m_board_poly, /*allLayerHoles,*/ &errmsg ) )
480  {
481  errmsg.append( wxT( "\n\n" ) );
482  errmsg.append( _( "Cannot determine the board outline." ) );
483  wxLogMessage( errmsg );
484  }
485 
486  // Be sure the polygon is strictly simple to avoid issues.
488 
490 }
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 1154 of file create_layer_items.cpp.

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

Referenced by InitSettings().

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

Definition at line 577 of file create_layer_items.cpp.

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

Referenced by AddPadsShapesWithClearanceToContainer().

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

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

524 {
525  wxSize drillSize = aPad->GetDrillSize();
526 
527  if( !drillSize.x || !drillSize.y )
528  {
529  wxLogTrace( m_logTrace, wxT( "CINFO3D_VISU::createNewPadDrill - found an invalid pad" ) );
530  return NULL;
531  }
532 
533  if( drillSize.x == drillSize.y ) // usual round hole
534  {
535  const int radius = (drillSize.x / 2) + aInflateValue;
536 
537  const SFVEC2F center( aPad->GetPosition().x * m_biuTo3Dunits,
538  -aPad->GetPosition().y * m_biuTo3Dunits );
539 
540  return new CFILLEDCIRCLE2D( center, radius * m_biuTo3Dunits, *aPad );
541 
542  }
543  else // Oblong hole
544  {
545  wxPoint start, end;
546  int width;
547 
548  aPad->GetOblongDrillGeometry( start, end, width );
549 
550  width += aInflateValue * 2;
551  start += aPad->GetPosition();
552  end += aPad->GetPosition();
553 
554  SFVEC2F start3DU( start.x * m_biuTo3Dunits,
555  -start.y * m_biuTo3Dunits );
556 
557  SFVEC2F end3DU ( end.x * m_biuTo3Dunits,
558  -end.y * m_biuTo3Dunits );
559 
560  if( Is_segment_a_circle( start3DU, end3DU ) )
561  {
562  return new CFILLEDCIRCLE2D( start3DU, (width / 2) * m_biuTo3Dunits, *aPad );
563  }
564  else
565  {
566  return new CROUNDSEGMENT2D( start3DU, end3DU, width * m_biuTo3Dunits, *aPad );
567  }
568  }
569 
570  return NULL;
571 }
const wxSize & GetDrillSize() const
Definition: class_pad.h:275
bool Is_segment_a_circle(const SFVEC2F &aStart, const SFVEC2F &aEnd)
Segment_is_a_circle - check if segment start and end is very close to each other should used to check...
glm::vec2 SFVEC2F
Definition: xv3d_types.h:45
const wxPoint & GetPosition() const override
Definition: class_pad.h:220
double m_biuTo3Dunits
Normalization scale to convert board internal units to 3D units to normalize 3D units between -1...
Definition: cinfo3d_visu.h:616
static const wxChar * m_logTrace
Trace mask used to enable or disable the trace output of this class.
Definition: cinfo3d_visu.h:673
void GetOblongDrillGeometry(wxPoint &aStartPoint, wxPoint &aEndPoint, int &aWidth) const
Function GetOblongDrillGeometry calculates the start point, end point and width of an equivalent segm...
Definition: class_pad.cpp:749
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(), SHAPE_POLY_SET::Append(), D_PAD::BuildPadPolygon(), Convert_shape_line_polygon_to_triangles(), D_PAD::CustomShapeAsPolygonToBoardPosition(), D_PAD::GetCustomShapeAsPolygon(), D_PAD::GetOrientation(), GetRoundRectCornerCenters(), D_PAD::GetRoundRectCornerRadius(), D_PAD::GetShape(), D_PAD::GetSize(), SHAPE_POLY_SET::Inflate(), Is_segment_a_circle(), m_biuTo3Dunits, m_logTrace, PAD_SHAPE_CIRCLE, PAD_SHAPE_CUSTOM, PAD_SHAPE_OVAL, PAD_SHAPE_RECT, PAD_SHAPE_ROUNDRECT, PAD_SHAPE_TRAPEZOID, SHAPE_POLY_SET::PM_FAST, SHAPE_POLY_SET::PM_STRICTLY_SIMPLE, RotatePoint(), D_PAD::ShapePos(), SHAPE_POLY_SET::Simplify(), wxPoint::x, and wxPoint::y.

Referenced by createNewPad().

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

Definition at line 251 of file create_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:225
const wxPoint & GetEnd() const
Definition: class_track.h:120
class TRACK, a track segment (segment on a copper layer)
Definition: typeinfo.h:95
bool Is_segment_a_circle(const SFVEC2F &aStart, const SFVEC2F &aEnd)
Segment_is_a_circle - check if segment start and end is very close to each other should used to check...
glm::vec2 SFVEC2F
Definition: xv3d_types.h:45
const wxPoint & GetStart() const
Definition: class_track.h:123
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:117
class VIA, a via (like a track segment on a copper layer)
Definition: typeinfo.h:96
void CINFO3D_VISU::destroyLayers ( )
private

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

1075 {
1076  if( !m_layers_poly.empty() )
1077  {
1078  for( MAP_POLY::iterator ii = m_layers_poly.begin();
1079  ii != m_layers_poly.end();
1080  ++ii )
1081  {
1082  delete ii->second;
1083  ii->second = NULL;
1084  }
1085 
1086  m_layers_poly.clear();
1087  }
1088 
1089  if( !m_layers_inner_holes_poly.empty() )
1090  {
1091  for( MAP_POLY::iterator ii = m_layers_inner_holes_poly.begin();
1092  ii != m_layers_inner_holes_poly.end();
1093  ++ii )
1094  {
1095  delete ii->second;
1096  ii->second = NULL;
1097  }
1098 
1099  m_layers_inner_holes_poly.clear();
1100  }
1101 
1102  if( !m_layers_outer_holes_poly.empty() )
1103  {
1104  for( MAP_POLY::iterator ii = m_layers_outer_holes_poly.begin();
1105  ii != m_layers_outer_holes_poly.end();
1106  ++ii )
1107  {
1108  delete ii->second;
1109  ii->second = NULL;
1110  }
1111 
1112  m_layers_outer_holes_poly.clear();
1113  }
1114 
1115  if( !m_layers_container2D.empty() )
1116  {
1117  for( MAP_CONTAINER_2D::iterator ii = m_layers_container2D.begin();
1118  ii != m_layers_container2D.end();
1119  ++ii )
1120  {
1121  delete ii->second;
1122  ii->second = NULL;
1123  }
1124 
1125  m_layers_container2D.clear();
1126  }
1127 
1128  if( !m_layers_holes2D.empty() )
1129  {
1130  for( MAP_CONTAINER_2D::iterator ii = m_layers_holes2D.begin();
1131  ii != m_layers_holes2D.end();
1132  ++ii )
1133  {
1134  delete ii->second;
1135  ii->second = NULL;
1136  }
1137 
1138  m_layers_holes2D.clear();
1139  }
1140 
1147  //m_through_inner_holes_poly.RemoveAllContours();
1148 
1151 }
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 280 of file cinfo3d_visu.cpp.

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

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

GetColor.

Parameters
aColorthe color mapped
Returns
the color in SFVEC3F format

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

545 {
546  return SFVEC3F( aColor.r, aColor.g, aColor.b );
547 }
double g
Green component.
Definition: color4d.h:292
double b
Blue component.
Definition: color4d.h:293
glm::vec3 SFVEC3F
Definition: xv3d_types.h:47
double r
Red component.
Definition: color4d.h:291
float CINFO3D_VISU::GetCopperThickness3DU ( ) const
inline

GetCopperThickness3DU - Get the current copper layer thickness.

Returns
thickness in 3d unities of copperlayers

Definition at line 165 of file cinfo3d_visu.h.

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

242 {
243  return COPPER_THICKNESS;
244 }
#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 538 of file cinfo3d_visu.cpp.

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

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

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

GetLayerBottomZpos3DU - Get the bottom z position.

Parameters
aLayerIdlayer id
Returns
position in 3D unities

Definition at line 287 of file cinfo3d_visu.h.

References m_layerZcoordBottom.

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

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

GetLayerColor - get the technical color of a layer.

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

Definition at line 528 of file cinfo3d_visu.cpp.

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

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

529 {
530  wxASSERT( aLayerId < PCB_LAYER_ID_COUNT );
531 
532  const COLOR4D color = m_board->Colors().GetLayerColor( aLayerId );
533 
534  return SFVEC3F( color.r, color.g, color.b );
535 }
double g
Green component.
Definition: color4d.h:292
BOARD * m_board
Current board.
Definition: cinfo3d_visu.h:515
double b
Blue component.
Definition: color4d.h:293
const COLORS_DESIGN_SETTINGS & Colors() const
Function GetColorSettings.
Definition: class_board.h:563
glm::vec3 SFVEC3F
Definition: xv3d_types.h:47
COLOR4D GetLayerColor(LAYER_NUM aLayer) const
Function GetLayerColor.
double r
Red component.
Definition: color4d.h:291
Class COLOR4D is the color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:39
float CINFO3D_VISU::GetLayerTopZpos3DU ( PCB_LAYER_ID  aLayerId) const
inline

GetLayerTopZpos3DU - Get the top z position.

Parameters
aLayerIdlayer id
Returns
position in 3D unities

Definition at line 280 of file cinfo3d_visu.h.

References m_layerZcoordTop.

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

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

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

Returns
the map containers of this board

Definition at line 293 of file cinfo3d_visu.h.

References m_layers_container2D.

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

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

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

Returns
the map containers of holes from this board

Definition at line 299 of file cinfo3d_visu.h.

References m_layers_holes2D.

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

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

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

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

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

494 {
495  if( aIsFlipped )
496  {
497  if( GetFlag( FL_SOLDERPASTE ) )
499  else
501  }
502  else
503  {
504  if( GetFlag( FL_SOLDERPASTE ) )
505  return m_layerZcoordTop[F_SilkS];
506  else
507  return m_layerZcoordTop[F_Paste];
508  }
509 }
bool GetFlag(DISPLAY3D_FLG aFlag) const
GetFlag - get a configuration status of a flag.
float m_layerZcoordBottom[PCB_LAYER_ID_COUNT]
Bottom (Start) Z position of each layer (normalized)
Definition: cinfo3d_visu.h:622
float m_layerZcoordTop[PCB_LAYER_ID_COUNT]
Top (End) Z position of each layer (normalized)
Definition: cinfo3d_visu.h:619
float CINFO3D_VISU::GetNonCopperLayerThickness3DU ( ) const
inline

GetNonCopperLayerThickness3DU - Get the current non copper layers thickness.

Returns
thickness in 3d unities of non copperlayers

Definition at line 159 of file cinfo3d_visu.h.

References m_nonCopperLayerThickness3DU.

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

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

GetNrSegmentsCircle.

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

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

255 {
256  wxASSERT( aDiameter3DU > 0.0f );
257 
258  unsigned int result = mapf( aDiameter3DU,
260  (float)MIN_SEG_PER_CIRCLE, (float)MAX_SEG_PER_CIRCLE );
261  wxASSERT( result > 1 );
262 
263  return result;
264 }
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 267 of file cinfo3d_visu.cpp.

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

268 {
269  wxASSERT( aDiameterBUI > 0 );
270 
271  unsigned int result = mapf( (float)aDiameterBUI,
272  (float)SEG_MIN_FACTOR_BIU, (float)SEG_MAX_FACTOR_BIU,
273  (float)MIN_SEG_PER_CIRCLE, (float)MAX_SEG_PER_CIRCLE );
274  wxASSERT( result > 1 );
275 
276  return result;
277 }
#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 288 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().

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

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

MaterialModeGet.

Returns
material rendering mode

Definition at line 246 of file cinfo3d_visu.h.

References m_material_mode.

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

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

MaterialModeSet.

Parameters
aMaterialMode= the render material mode

Definition at line 240 of file cinfo3d_visu.h.

References m_material_mode.

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

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

RenderEngineSet.

Parameters
aRenderEngine= the render engine mode selected

Definition at line 228 of file cinfo3d_visu.h.

References m_render_engine.

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

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

Set3DCacheManager - Update the Cache manager pointer.

Parameters
aCachePointerthe pointer to the 3d cache manager

Definition at line 82 of file cinfo3d_visu.h.

References m_3d_model_manager.

Referenced by EDA_3D_CANVAS::ReloadRequest().

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

SetBoard - Set current board to be rendered.

Parameters
aBoardboard to process

Definition at line 122 of file cinfo3d_visu.h.

References m_board.

Referenced by EDA_3D_CANVAS::ReloadRequest().

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

SetFlag - set the status of a flag.

Parameters
aFlagthe flag to get the status
aStatestatus to set

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

215 {
216  wxASSERT( aFlag < FL_LAST );
217 
218  m_drawFlags[aFlag] = aState;
219 }
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 221 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().

222 {
223  if( ( ( aModuleAttributs == MOD_DEFAULT ) &&
225  ( ( ( aModuleAttributs & MOD_CMS) == MOD_CMS ) &&
227  ( ( ( aModuleAttributs & MOD_VIRTUAL) == MOD_VIRTUAL ) &&
229  {
230  return true;
231  }
232 
233  return false;
234 }
Set for modules listed in the automatic insertion list (usually SMD footprints)
Definition: class_module.h:76
default
Definition: class_module.h:75
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:78
void CINFO3D_VISU::TransformArcToSegments ( const wxPoint aCentre,
const wxPoint aStart,
double  aArcAngle,
int  aCircleToSegmentsCount,
int  aWidth,
CGENERICCONTAINER2D aDstContainer,
const BOARD_ITEM aBoardItem 
)
private

Definition at line 681 of file create_layer_items.cpp.

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

Referenced by AddShapeWithClearanceToContainer().

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

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

Referenced by createLayers().

202 {
203  for( const EDA_ITEM* item = aModule->GraphicalItemsList();
204  item != NULL;
205  item = item->Next() )
206  {
207  switch( item->Type() )
208  {
209  case PCB_MODULE_EDGE_T:
210  {
211  EDGE_MODULE*outline = (EDGE_MODULE*) item;
212 
213  if( outline->GetLayer() != aLayer )
214  break;
215 
216  unsigned int aCircleToSegmentsCount =
218 
219  double aCorrectionFactor = GetCircleCorrectionFactor( aCircleToSegmentsCount );
220 
221  outline->TransformShapeWithClearanceToPolygon( aCornerBuffer,
222  0,
223  aCircleToSegmentsCount,
224  aCorrectionFactor );
225  }
226  break;
227 
228  default:
229  break;
230  }
231  }
232 }
virtual PCB_LAYER_ID GetLayer() const
Function GetLayer returns the primary layer this item is on.
class EDGE_MODULE, a footprint edge
Definition: typeinfo.h:94
BOARD_ITEM * Next() const
int GetSizeMax() const
GetSizeMax.
unsigned int GetNrSegmentsCircle(float aDiameter3DU) const
GetNrSegmentsCircle.
void TransformShapeWithClearanceToPolygon(SHAPE_POLY_SET &aCornerBuffer, int aClearanceValue, int aCircleToSegmentsCount, double aCorrectionFactor) const override
Function TransformShapeWithClearanceToPolygon Convert the track shape to a closed polygon Used in fil...
double GetCircleCorrectionFactor(int aNrSides) const
GetCircleCorrectionFactor - computes a angle correction factor used when creating circles...
Class EDA_ITEM is a base class for most all the KiCad significant classes, used in schematics and boa...
Definition: base_struct.h:178
DLIST< BOARD_ITEM > & GraphicalItemsList()
Definition: class_module.h:157
virtual const EDA_RECT GetBoundingBox() const override
Function GetBoundingBox returns the orthogonal, bounding box of this object for display purposes...
void CINFO3D_VISU::transformPadsShapesWithClearanceToPolygon ( const DLIST< D_PAD > &  aPads,
PCB_LAYER_ID  aLayer,
SHAPE_POLY_SET aCornerBuffer,
int  aInflateValue,
bool  aSkipNPTHPadsWihNoCopper 
) const
private

Definition at line 134 of file create_layer_poly.cpp.

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

Referenced by createLayers().

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