35 #include "../3d_rendering/3d_render_raytracing/shapes2D/ring_2d.h" 36 #include "../3d_rendering/3d_render_raytracing/shapes2D/filled_circle_2d.h" 37 #include "../3d_rendering/3d_render_raytracing/shapes3D/cylinder_3d.h" 53 #ifdef PRINT_STATISTICS_3D_VIEWER 133 #ifdef PRINT_STATISTICS_3D_VIEWER 136 unsigned start_Time = stats_startCopperLayersTime;
150 std::vector< const TRACK *> trackList;
161 trackList.push_back( track );
165 const VIA *via = static_cast< const VIA*>( track );
184 std::vector< PCB_LAYER_ID > layer_id;
188 for(
unsigned i = 0; i <
arrayDim( cu_seq ); ++i )
198 layer_id.push_back( curr_layer_id );
221 if( aStatusReporter )
222 aStatusReporter->
Report(
_(
"Create tracks and vias" ) );
232 unsigned int nTracks = trackList.size();
234 for(
unsigned int trackIdx = 0; trackIdx < nTracks; ++trackIdx )
236 const TRACK *track = trackList[trackIdx];
243 const VIA *via = dyn_cast< const VIA*>( track );
257 unsigned int nTracks = trackList.size();
259 for(
unsigned int trackIdx = 0; trackIdx < nTracks; ++trackIdx )
261 const TRACK *track = trackList[trackIdx];
269 const VIA* via = static_cast<const VIA*>( track );
273 const float hole_inner_radius = ( holediameter / 2.0f );
300 hole_inner_radius + thickness,
303 else if( curr_layer_id == layer_id[0] )
307 hole_inner_radius + thickness,
310 hole_inner_radius + thickness,
332 const unsigned int nTracks = trackList.size();
334 for(
unsigned int trackIdx = 0; trackIdx < nTracks; ++trackIdx )
336 const TRACK *track = trackList[trackIdx];
344 const VIA *via = static_cast< const VIA*>( track );
389 else if( curr_layer_id == layer_id[0] )
393 const int hole_outer_ring_radius = via->
GetWidth() / 2.0f;
406 via->
GetStart(), hole_outer_ring_radius,
425 unsigned int nTracks = trackList.size();
427 for(
unsigned int trackIdx = 0; trackIdx < nTracks; ++trackIdx )
429 const TRACK *track = trackList[trackIdx];
435 const VIA *via = dyn_cast< const VIA*>( track );
450 for(
PAD* pad : footprint->Pads() )
452 const wxSize padHole = pad->GetDrillSize();
482 for(
PAD* pad : footprint->Pads() )
484 const wxSize padHole = pad->GetDrillSize();
534 true, renderPlatedPadsAsPlated,
false );
541 if( renderPlatedPadsAsPlated )
570 footprint->TransformPadsWithClearanceToPolygon( *layerPoly, curr_layer_id,
572 true, renderPlatedPadsAsPlated,
579 if( renderPlatedPadsAsPlated )
605 if( !item->IsOnLayer( curr_layer_id ) )
608 switch( item->Type() )
625 layerContainer, curr_layer_id, 0 );
629 wxLogTrace(
m_logTrace, wxT(
"createLayers: item type: %d not implemented" ),
649 if( !item->IsOnLayer( cur_layer_id ) )
652 switch( item->Type() )
655 item->TransformShapeWithClearanceToPolygon( *layerPoly, cur_layer_id, 0,
661 PCB_TEXT* text = static_cast<PCB_TEXT*>( item );
669 wxLogTrace(
m_logTrace, wxT(
"createLayers: item type: %d not implemented" ),
679 if( aStatusReporter )
680 aStatusReporter->
Report(
_(
"Create zones" ) );
682 std::vector<std::pair<const ZONE*, PCB_LAYER_ID>> zones;
687 zones.emplace_back( std::make_pair( zone, layer ) );
691 std::atomic<size_t> nextZone( 0 );
692 std::atomic<size_t> threadsFinished( 0 );
694 size_t parallelThreadCount = std::max<size_t>( std::thread::hardware_concurrency(), 2 );
696 for(
size_t ii = 0; ii < parallelThreadCount; ++ii )
698 std::thread t = std::thread( [&]()
700 for(
size_t areaId = nextZone.fetch_add( 1 );
701 areaId < zones.size();
702 areaId = nextZone.fetch_add( 1 ) )
704 const ZONE* zone = zones[areaId].first;
706 if( zone ==
nullptr )
711 auto layerContainer =
m_layerMap.find( layer );
723 while( threadsFinished < parallelThreadCount )
724 std::this_thread::sleep_for( std::chrono::milliseconds( 10 ) );
734 if( zone ==
nullptr )
742 zone->TransformSolidAreasShapesToPolygon( layer, *layerContainer->second );
749 if( aStatusReporter )
750 aStatusReporter->
Report(
_(
"Simplifying copper layers polygons" ) );
774 std::vector< PCB_LAYER_ID > &selected_layer_id = layer_id;
775 std::vector< PCB_LAYER_ID > layer_id_without_F_and_B;
779 layer_id_without_F_and_B.clear();
780 layer_id_without_F_and_B.reserve( layer_id.size() );
782 for(
size_t i = 0; i < layer_id.size(); ++i )
784 if( ( layer_id[i] !=
F_Cu ) && ( layer_id[i] !=
B_Cu ) )
785 layer_id_without_F_and_B.push_back( layer_id[i] );
788 selected_layer_id = layer_id_without_F_and_B;
791 if( selected_layer_id.size() > 0 )
793 std::atomic<size_t> nextItem( 0 );
794 std::atomic<size_t> threadsFinished( 0 );
796 size_t parallelThreadCount = std::min<size_t>(
797 std::max<size_t>( std::thread::hardware_concurrency(), 2 ),
798 selected_layer_id.size() );
800 for(
size_t ii = 0; ii < parallelThreadCount; ++ii )
802 std::thread t = std::thread(
803 [&nextItem, &threadsFinished, &selected_layer_id,
this]()
805 for(
size_t i = nextItem.fetch_add( 1 );
806 i < selected_layer_id.size();
807 i = nextItem.fetch_add( 1 ) )
822 while( threadsFinished < parallelThreadCount )
823 std::this_thread::sleep_for( std::chrono::milliseconds( 10 ) );
828 if( aStatusReporter )
829 aStatusReporter->
Report(
_(
"Simplify holes contours" ) );
857 if( aStatusReporter )
858 aStatusReporter->
Report(
_(
"Build Tech layers" ) );
899 if( !item->IsOnLayer( curr_layer_id ) )
902 switch( item->Type() )
930 if( !item->IsOnLayer( curr_layer_id ) )
933 switch( item->Type() )
936 item->TransformShapeWithClearanceToPolygon( *layerPoly, curr_layer_id, 0,
942 PCB_TEXT* text = static_cast<PCB_TEXT*>( item );
957 if( ( curr_layer_id ==
F_SilkS ) || ( curr_layer_id ==
B_SilkS ) )
961 for(
PAD* pad : footprint->Pads() )
963 if( !pad->IsOnLayer( curr_layer_id ) )
972 false,
false,
false );
982 if( ( curr_layer_id ==
F_SilkS ) || ( curr_layer_id ==
B_SilkS ) )
986 for(
PAD* pad : footprint->Pads() )
988 if( !pad->IsOnLayer( curr_layer_id ) )
996 footprint->TransformPadsWithClearanceToPolygon( *layerPoly, curr_layer_id, 0,
1001 footprint->TransformFPTextWithClearanceToPolygonSet( *layerPoly, curr_layer_id, 0,
1014 if( zone->IsOnLayer( curr_layer_id ) )
1020 if( zone->IsOnLayer( curr_layer_id ) )
1021 zone->TransformSolidAreasShapesToPolygon( curr_layer_id, *layerPoly );
1032 if( aStatusReporter )
1033 aStatusReporter->
Report(
_(
"Build BVH for holes and vias" ) );
1042 hole.second->BuildBVH();
static LSET AllCuMask(int aCuLayerCount=MAX_CU_LAYERS)
Return a mask holding the requested number of Cu PCB_LAYER_IDs.
BVH_CONTAINER_2D m_throughHoleViaOds
List of through hole via inner diameters.
bool GetFlag(DISPLAY3D_FLG aFlag) const
Get a configuration status of a flag.
BVH_CONTAINER_2D * m_platedPadsFront
void createTrack(const TRACK *aTrack, CONTAINER_2D_BASE *aDstContainer, int aClearanceValue)
class ALIGNED_DIMENSION, a linear dimension (graphic item)
class LEADER, a leader dimension (graphic item)
SHAPE_POLY_SET * m_backPlatedPadPolys
Polygon contours for hole outer diameters for each layer.
BVH_CONTAINER_2D m_throughHoleIds
List of through hole vias with the radius of the hole inflated with the copper thickness.
void buildPadOutlineAsSegments(const PAD *aPad, CONTAINER_2D_BASE *aDstContainer, int aWidth)
SHAPE_POLY_SET * m_frontPlatedPadPolys
A base class for any item which can be embedded within the BOARD container class, and therefore insta...
void TransformTextShapeWithClearanceToPolygon(SHAPE_POLY_SET &aCornerBuffer, PCB_LAYER_ID aLayer, int aClearanceValue, int aError, ERROR_LOC aErrorLoc) const
Function TransformTextShapeWithClearanceToPolygon Convert the text to a polygonSet describing the act...
OBJECT_2D * createPadWithDrill(const PAD *aPad, int aInflateValue)
const wxPoint & GetStart() const
float m_averageHoleDiameter
class CENTER_DIMENSION, a center point marking (graphic item)
SHAPE_POLY_SET m_throughHoleAnnularRingPolys
static LSET AllNonCuMask()
Return a mask holding all layer minus CU layers.
MAP_CONTAINER_2D_BASE m_layerMap
2D elements for each layer.
void transformFPShapesToPolygon(const FOOTPRINT *aFootprint, PCB_LAYER_ID aLayer, SHAPE_POLY_SET &aCornerBuffer) const
class PCB_TEXT, text on a layer
BVH_CONTAINER_2D m_throughHoleOds
List of plated through hole annular rings.
SHAPE_POLY_SET m_throughHoleViaOdPolys
Polygon contours for through hole via annular rings.
BOARD_DESIGN_SETTINGS & GetDesignSettings() const
float m_averageTrackWidth
Number of through hole vias in the board.
like PAD_PTH, but not plated mechanical use only, no connection allowed
A pure virtual class used to derive REPORTER objects from.
void addFootprintShapesWithClearance(const FOOTPRINT *aFootprint, CONTAINER_2D_BASE *aDstContainer, PCB_LAYER_ID aLayerId, int aInflateValue)
LSEQ Seq(const PCB_LAYER_ID *aWishListSequence, unsigned aCount) const
Return an LSEQ from the union of this LSET and a desired sequence.
MAP_POLY m_layerHoleIdPolys
Polygon contours for non plated through hole outer diameters.
virtual REPORTER & Report(const wxString &aText, SEVERITY aSeverity=RPT_SEVERITY_UNDEFINED)=0
Report a string with a given severity.
void TransformShapeWithClearanceToPolygon(SHAPE_POLY_SET &aCornerBuffer, PCB_LAYER_ID aLayer, int aClearanceValue, int aError, ERROR_LOC aErrorLoc, bool ignoreLineWidth=false) const override
Function TransformShapeWithClearanceToPolygon Convert the track shape to a closed polygon Used in fil...
void Add(OBJECT_2D *aObject)
bool Is3dLayerEnabled(PCB_LAYER_ID aLayer) const
Check if a layer is enabled.
PCB_LAYER_ID
A quick note on layer IDs:
void addShapeWithClearance(const PCB_TEXT *aText, CONTAINER_2D_BASE *aDstContainer, PCB_LAYER_ID aLayerId, int aClearanceValue)
LSET is a set of PCB_LAYER_IDs.
virtual bool IsOnLayer(PCB_LAYER_ID aLayer) const
Test to see if this object is on the given layer.
unsigned int m_trackCount
Track average width.
int GetDrillValue() const
Function GetDrillValue "calculates" the drill value for vias (m-Drill if > 0, or default drill value ...
BVH_CONTAINER_2D * m_platedPadsBack
The holes per each layer.
Represent a set of closed polygons.
bool FlashLayer(int aLayer) const
Checks to see whether the via should have a pad on the specific layer.
MAP_POLY m_layerHoleOdPolys
Polygon contours for hole inner diameters for each layer.
FOOTPRINTS & Footprints()
void buildPadOutlineAsPolygon(const PAD *aPad, SHAPE_POLY_SET &aCornerBuffer, int aWidth) const
MAP_CONTAINER_2D_BASE m_layerHoleMap
List of through holes with the radius of the hole inflated with the copper thickness.
void addSolidAreasShapes(const ZONE *aZoneContainer, CONTAINER_2D_BASE *aDstContainer, PCB_LAYER_ID aLayerId)
double BiuTo3dUnits() const noexcept
Board integer units To 3D units.
void addPadsWithClearance(const FOOTPRINT *aFootprint, CONTAINER_2D_BASE *aDstContainer, PCB_LAYER_ID aLayerId, int aInflateValue, bool aSkipNPTHPadsWihNoCopper, bool aSkipPlatedPads, bool aSkipNonPlatedPads)
double m_biuTo3Dunits
Top (End) Z position of each layer in 3D units.
constexpr std::size_t arrayDim(T const (&)[N]) noexcept
Returns # of elements in an array.
void Simplify(POLYGON_MODE aFastMode)
ZONE handles a list of polygons defining a copper zone.
BVH_CONTAINER_2D m_throughHoleAnnularRings
List of through hole inner diameters.
unsigned int m_viaCount
Computed average diameter of the via holes in 3D units.
int m_LineThickness[LAYER_CLASS_COUNT]
void createLayers(REPORTER *aStatusReporter)
LSEQ is a sequence (and therefore also a set) of PCB_LAYER_IDs.
RENDER_ENGINE m_renderEngine
static const wxChar * m_logTrace
Trace mask used to enable or disable the trace output of this class.
unsigned GetRunningMicroSecs()
An alternate way to calculate an elapset time (in microsecondes) to class PROF_COUNTER.
unsigned int m_copperLayersCount
Scale factor to convert board internal units to 3D units normalized between -1.0 and 1....
BVH_CONTAINER_2D m_throughHoleViaIds
Number of copper layers actually used by the board.
VIATYPE GetViaType() const
void TransformCircleToPolygon(SHAPE_LINE_CHAIN &aCornerBuffer, wxPoint aCenter, int aRadius, int aError, ERROR_LOC aErrorLoc)
Function TransformCircleToPolygon convert a circle to a polygon, using multiple straight lines.
bool IsCopperLayer(LAYER_NUM aLayerId)
Tests whether a layer is a copper layer.
float GetCopperThickness() const noexcept
Get the current copper layer thickness.
class ORTHOGONAL_DIMENSION, a linear dimension constrained to x/y
class VIA, a via (like a track segment on a copper layer)
void BooleanSubtract(const SHAPE_POLY_SET &b, POLYGON_MODE aFastMode)
Perform boolean polyset intersection For aFastMode meaning, see function booleanOp.
float m_averageViaHoleDiameter
Number of holes in the board.
SHAPE_POLY_SET m_throughHoleOdPolys
Polygon contours for through holes via outer diameters.
class PCB_SHAPE, a segment not on copper layers
PCB_LAYER_ID ToLAYER_ID(int aLayer)
SHAPE_POLY_SET m_nonPlatedThroughHoleOdPolys
Polygon contours for through hole outer diameters.
unsigned int m_holeCount
Computed average diameter of the holes in 3D units.
KICAD_T Type() const
Returns the type of object.
int GetHolePlatingThickness() const noexcept
Get the current copper layer thickness.