KiCad PCB EDA Suite
Loading...
Searching...
No Matches
exporter_step.cpp
Go to the documentation of this file.
1/*
2 * This program source code file is part of KiCad, a free EDA CAD application.
3 *
4 * Copyright (C) 2022 Mark Roszko <[email protected]>
5 * Copyright (C) 2016 Cirilo Bernardo <[email protected]>
6 * Copyright (C) 2016-2024 KiCad Developers, see AUTHORS.txt for contributors.
7 *
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License
10 * as published by the Free Software Foundation; either version 2
11 * of the License, or (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, you may find one here:
20 * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
21 * or you may search the http://www.gnu.org website for the version 2 license,
22 * or you may write to the Free Software Foundation, Inc.,
23 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
24 */
25
26#include "exporter_step.h"
27#include <advanced_config.h>
28#include <board.h>
30#include <footprint.h>
31#include <pcb_textbox.h>
32#include <pcb_track.h>
33#include <pcb_shape.h>
34#include <pad.h>
35#include <zone.h>
36#include <fp_lib_table.h>
37#include "step_pcb_model.h"
38
39#include <pgm_base.h>
40#include <base_units.h>
41#include <filename_resolver.h>
42#include <trace_helpers.h>
43#include <project_pcb.h>
45
46#include <Message.hxx> // OpenCascade messenger
47#include <Message_PrinterOStream.hxx> // OpenCascade output messenger
48#include <Standard_Failure.hxx> // In open cascade
49
50#include <Standard_Version.hxx>
51
52#include <wx/crt.h>
53#include <wx/log.h>
54#include <core/profile.h> // To use GetRunningMicroSecs or another profiling utility
55
56#define OCC_VERSION_MIN 0x070500
57
58#if OCC_VERSION_HEX < OCC_VERSION_MIN
59#include <Message_Messenger.hxx>
60#endif
61
62
63void ReportMessage( const wxString& aMessage )
64{
65 wxPrintf( aMessage );
66 fflush( stdout ); // Force immediate printing (needed on mingw)
67}
68
69class KiCadPrinter : public Message_Printer
70{
71public:
72 KiCadPrinter( EXPORTER_STEP* aConverter ) : m_converter( aConverter ) {}
73
74protected:
75#if OCC_VERSION_HEX < OCC_VERSION_MIN
76 virtual void Send( const TCollection_ExtendedString& theString,
77 const Message_Gravity theGravity,
78 const Standard_Boolean theToPutEol ) const override
79 {
80 Send( TCollection_AsciiString( theString ), theGravity, theToPutEol );
81 }
82
83 virtual void Send( const TCollection_AsciiString& theString,
84 const Message_Gravity theGravity,
85 const Standard_Boolean theToPutEol ) const override
86#else
87 virtual void send( const TCollection_AsciiString& theString,
88 const Message_Gravity theGravity ) const override
89#endif
90 {
91 if( theGravity >= Message_Warning
92 || ( wxLog::IsAllowedTraceMask( traceKiCad2Step ) && theGravity == Message_Info ) )
93 {
94 ReportMessage( theString.ToCString() );
95
96#if OCC_VERSION_HEX < OCC_VERSION_MIN
97 if( theToPutEol )
98 ReportMessage( wxT( "\n" ) );
99#else
100 ReportMessage( wxT( "\n" ) );
101#endif
102 }
103
104 if( theGravity == Message_Warning )
106
107 if( theGravity >= Message_Alarm )
109
110 if( theGravity == Message_Fail )
112 }
113
114private:
116};
117
118
120{
121 switch( m_format )
122 {
123 case EXPORTER_STEP_PARAMS::FORMAT::STEP: return wxS( "step" );
124 case EXPORTER_STEP_PARAMS::FORMAT::BREP: return wxS( "brep" );
125 case EXPORTER_STEP_PARAMS::FORMAT::XAO: return wxS( "xao" );
126 case EXPORTER_STEP_PARAMS::FORMAT::GLB: return wxS( "glb" );
127 default: return wxEmptyString; // shouldn't happen
128 }
129}
130
132{
133 switch( m_format )
134 {
135 // honestly these names shouldn't be translated since they are mostly industry standard acronyms
136 case EXPORTER_STEP_PARAMS::FORMAT::STEP: return wxS( "STEP" );
137 case EXPORTER_STEP_PARAMS::FORMAT::BREP: return wxS( "BREP" );
138 case EXPORTER_STEP_PARAMS::FORMAT::XAO: return wxS( "XAO" );
139 case EXPORTER_STEP_PARAMS::FORMAT::GLB: return wxS( "Binary GLTF" );
140 default: return wxEmptyString; // shouldn't happen
141 }
142}
143
144
146 m_params( aParams ),
147 m_error( false ),
148 m_fail( false ),
149 m_warn( false ),
150 m_board( aBoard ),
151 m_pcbModel( nullptr )
152{
153 m_copperColor = COLOR4D( 0.7, 0.61, 0.0, 1.0 );
154
156 m_padColor = COLOR4D( 0.50, 0.50, 0.50, 1.0 );
157 else
159
160 // TODO: make configurable
162
163 // Init m_pcbBaseName to the board short filename (no path, no ext)
164 // m_pcbName is used later to identify items in step file
165 wxFileName fn( aBoard->GetFileName() );
166 m_pcbBaseName = fn.GetName();
167
168 // Remove the autosave prefix
170
171 m_resolver = std::make_unique<FILENAME_RESOLVER>();
172 m_resolver->Set3DConfigDir( wxT( "" ) );
173 // needed to add the project to the search stack
174 m_resolver->SetProject( aBoard->GetProject() );
175 m_resolver->SetProgramBase( &Pgm() );
176}
177
178
180{
181}
182
183
185{
186 bool hasdata = false;
187 std::vector<PAD*> padsMatchingNetFilter;
188 int maxError = m_board->GetDesignSettings().m_MaxError;
189
190 // Dump the pad holes into the PCB
191 for( PAD* pad : aFootprint->Pads() )
192 {
193 std::shared_ptr<SHAPE_SEGMENT> holeShape = pad->GetEffectiveHoleShape();
194
195 SHAPE_POLY_SET holePoly;
196 holeShape->TransformToPolygon( holePoly, maxError, ERROR_INSIDE );
197
198 for( PCB_LAYER_ID pcblayer : pad->GetLayerSet().Seq() )
199 {
200 if( pad->IsOnLayer( pcblayer ) )
201 m_poly_holes[pcblayer].Append( holePoly );
202 }
203
204 if( pad->HasHole() )
205 {
206 int platingThickness = pad->GetAttribute() == PAD_ATTRIB::PTH ? m_platingThickness : 0;
207
208 if( m_pcbModel->AddHole( *holeShape, platingThickness, F_Cu, B_Cu, false, aOrigin ) )
209 hasdata = true;
210
212 //if( m_layersToExport.Contains( F_SilkS ) || m_layersToExport.Contains( B_SilkS ) )
213 //{
214 // m_poly_holes[F_SilkS].Append( holePoly );
215 // m_poly_holes[B_SilkS].Append( holePoly );
216 //}
217 }
218
219 if( !m_params.m_netFilter.IsEmpty() && !pad->GetNetname().Matches( m_params.m_netFilter ) )
220 continue;
221
223 {
224 if( m_pcbModel->AddPadShape( pad, aOrigin, false ) )
225 hasdata = true;
226
228 {
229 for( PCB_LAYER_ID pcblayer : pad->GetLayerSet().Seq() )
230 {
231 if( pcblayer != F_Mask && pcblayer != B_Mask )
232 continue;
233
234 SHAPE_POLY_SET poly;
235
236 pad->TransformShapeToPolygon( poly, pcblayer, pad->GetSolderMaskExpansion(),
237 maxError, ERROR_INSIDE );
238
239 m_poly_shapes[pcblayer].Append( poly );
240 }
241 }
242 }
243
244 padsMatchingNetFilter.push_back( pad );
245 }
246
247 // Build 3D shapes of the footprint graphic items:
248 for( PCB_LAYER_ID pcblayer : m_layersToExport.Seq() )
249 {
250 if( IsCopperLayer( pcblayer ) && !m_params.m_exportTracksVias )
251 continue;
252
253 SHAPE_POLY_SET buffer;
254
255 aFootprint->TransformFPShapesToPolySet( buffer, pcblayer, 0, maxError, ERROR_INSIDE,
256 true, /* include text */
257 true, /* include shapes */
258 false /* include private items */ );
259
260 if( m_params.m_netFilter.IsEmpty() || !IsCopperLayer( pcblayer ) )
261 {
262 m_poly_shapes[pcblayer].Append( buffer );
263 }
264 else
265 {
266 // Only add shapes colliding with any matching pads
267 for( const SHAPE_POLY_SET::POLYGON& poly : buffer.CPolygons() )
268 {
269 for( PAD* pad : padsMatchingNetFilter )
270 {
271 if( !pad->IsOnLayer( pcblayer ) )
272 continue;
273
274 std::shared_ptr<SHAPE_POLY_SET> padPoly = pad->GetEffectivePolygon();
275 SHAPE_POLY_SET gfxPoly( poly );
276
277 if( padPoly->Collide( &gfxPoly ) )
278 {
279 m_poly_shapes[pcblayer].Append( gfxPoly );
280 break;
281 }
282 }
283 }
284 }
285 }
286
287 if( ( !(aFootprint->GetAttributes() & (FP_THROUGH_HOLE|FP_SMD)) ) && !m_params.m_includeUnspecified )
288 {
289 return hasdata;
290 }
291
292 if( ( aFootprint->GetAttributes() & FP_DNP ) && !m_params.m_includeDNP )
293 {
294 return hasdata;
295 }
296
297 // Prefetch the library for this footprint
298 // In case we need to resolve relative footprint paths
299 wxString libraryName = aFootprint->GetFPID().GetLibNickname();
300 wxString footprintBasePath = wxEmptyString;
301
302 double posX = aFootprint->GetPosition().x - aOrigin.x;
303 double posY = (aFootprint->GetPosition().y) - aOrigin.y;
304
305 if( m_board->GetProject() )
306 {
307 try
308 {
309 // FindRow() can throw an exception
310 const FP_LIB_TABLE_ROW* fpRow =
311 PROJECT_PCB::PcbFootprintLibs( m_board->GetProject() )->FindRow( libraryName, false );
312
313 if( fpRow )
314 footprintBasePath = fpRow->GetFullURI( true );
315 }
316 catch( ... )
317 {
318 // Do nothing if the libraryName is not found in lib table
319 }
320 }
321
322 // Exit early if we don't want to include footprint models
324 {
325 return hasdata;
326 }
327
328 VECTOR2D newpos( pcbIUScale.IUTomm( posX ), pcbIUScale.IUTomm( posY ) );
329
330 for( const FP_3DMODEL& fp_model : aFootprint->Models() )
331 {
332 if( !fp_model.m_Show || fp_model.m_Filename.empty() )
333 continue;
334
335 std::vector<wxString> searchedPaths;
336 wxString mname = m_resolver->ResolvePath( fp_model.m_Filename, footprintBasePath, aFootprint );
337
338
339 if( mname.empty() || !wxFileName::FileExists( mname ) )
340 {
341 // the error path will return an empty name sometimes, at least report back the original filename
342 if( mname.empty() )
343 mname = fp_model.m_Filename;
344
345 ReportMessage( wxString::Format( wxT( "Could not add 3D model to %s.\n"
346 "File not found: %s\n" ),
347 aFootprint->GetReference(), mname ) );
348 continue;
349 }
350
351 std::string fname( mname.ToUTF8() );
352 std::string refName( aFootprint->GetReference().ToUTF8() );
353 try
354 {
355 bool bottomSide = aFootprint->GetLayer() == B_Cu;
356
357 // the rotation is stored in degrees but opencascade wants radians
358 VECTOR3D modelRot = fp_model.m_Rotation;
359 modelRot *= M_PI;
360 modelRot /= 180.0;
361
362 if( m_pcbModel->AddComponent( fname, refName, bottomSide,
363 newpos,
364 aFootprint->GetOrientation().AsRadians(),
365 fp_model.m_Offset, modelRot,
366 fp_model.m_Scale, m_params.m_substModels ) )
367 {
368 hasdata = true;
369 }
370 }
371 catch( const Standard_Failure& e )
372 {
373 ReportMessage( wxString::Format( wxT( "Could not add 3D model to %s.\n"
374 "OpenCASCADE error: %s\n" ),
375 aFootprint->GetReference(), e.GetMessageString() ) );
376 }
377
378 }
379
380 return hasdata;
381}
382
383
385{
386 if( !m_params.m_netFilter.IsEmpty() && !aTrack->GetNetname().Matches( m_params.m_netFilter ) )
387 return true;
388
389 int maxError = m_board->GetDesignSettings().m_MaxError;
390
391 if( aTrack->Type() == PCB_VIA_T )
392 {
393 PCB_VIA* via = static_cast<PCB_VIA*>( aTrack );
394
395 std::shared_ptr<SHAPE_SEGMENT> holeShape = via->GetEffectiveHoleShape();
396 SHAPE_POLY_SET holePoly;
397 holeShape->TransformToPolygon( holePoly, maxError, ERROR_INSIDE );
398
399 LSET layers( via->GetLayerSet() & m_layersToExport );
400
401 for( PCB_LAYER_ID pcblayer : layers.Seq() )
402 {
403 const std::shared_ptr<SHAPE>& shape = via->GetEffectiveShape( pcblayer );
404
405 SHAPE_POLY_SET poly;
406 shape->TransformToPolygon( poly, maxError, ERROR_INSIDE );
407 m_poly_shapes[pcblayer].Append( poly );
408 m_poly_holes[pcblayer].Append( holePoly );
409 }
410
412 //if( m_layersToExport.Contains( F_SilkS ) || m_layersToExport.Contains( B_SilkS ) )
413 //{
414 // m_poly_holes[F_SilkS].Append( holePoly );
415 // m_poly_holes[B_SilkS].Append( holePoly );
416 //}
417
418 PCB_LAYER_ID top_layer, bot_layer;
419 via->LayerPair( &top_layer, &bot_layer );
420
421 m_pcbModel->AddHole( *holeShape, m_platingThickness, top_layer, bot_layer, true, aOrigin );
422 m_pcbModel->AddBarrel( *holeShape, top_layer, bot_layer, true, aOrigin );
423
424 return true;
425 }
426
427 PCB_LAYER_ID pcblayer = aTrack->GetLayer();
428
429 if( !m_layersToExport.Contains( pcblayer ) )
430 return false;
431
432 aTrack->TransformShapeToPolygon( m_poly_shapes[pcblayer], pcblayer, 0, maxError, ERROR_INSIDE );
433
434 return true;
435}
436
437
439{
440 for( ZONE* zone : m_board->Zones() )
441 {
442 LSET layers = zone->GetLayerSet();
443
444 if( ( layers & LSET::AllCuMask() ).count() && !m_params.m_netFilter.IsEmpty()
445 && !zone->GetNetname().Matches( m_params.m_netFilter ) )
446 {
447 continue;
448 }
449
450 for( PCB_LAYER_ID layer : layers.Seq() )
451 {
452 SHAPE_POLY_SET fill_shape;
453 zone->TransformSolidAreasShapesToPolygon( layer, fill_shape );
455
456 fill_shape.SimplifyOutlines( ADVANCED_CFG::GetCfg().m_TriangulateSimplificationLevel );
457
458 m_poly_shapes[layer].Append( fill_shape );
459 }
460 }
461}
462
463
465{
466 PCB_LAYER_ID pcblayer = aItem->GetLayer();
467
468 if( !m_layersToExport.Contains( pcblayer ) )
469 return false;
470
471 int maxError = m_board->GetDesignSettings().m_MaxError;
472
473 switch( aItem->Type() )
474 {
475 case PCB_SHAPE_T:
476 {
477 PCB_SHAPE* graphic = static_cast<PCB_SHAPE*>( aItem );
478
479 if( IsCopperLayer( pcblayer ) && !m_params.m_netFilter.IsEmpty()
480 && !graphic->GetNetname().Matches( m_params.m_netFilter ) )
481 {
482 return true;
483 }
484
485 graphic->TransformShapeToPolygon( m_poly_shapes[pcblayer], pcblayer, 0, maxError,
486 ERROR_INSIDE );
487
488 break;
489 }
490
491 case PCB_TEXT_T:
492 {
493 PCB_TEXT* text = static_cast<PCB_TEXT*>( aItem );
494
495 text->TransformTextToPolySet( m_poly_shapes[pcblayer], 0, maxError, ERROR_INSIDE );
496 break;
497 }
498
499 case PCB_TEXTBOX_T:
500 {
501 PCB_TEXTBOX* textbox = static_cast<PCB_TEXTBOX*>( aItem );
502
503 textbox->TransformTextToPolySet( m_poly_shapes[pcblayer], 0, maxError, ERROR_INSIDE );
504 break;
505 }
506
507 case PCB_TABLE_T:
508 // JEY TODO: tables
509 break;
510
511 default: wxFAIL_MSG( "buildGraphic3DShape: unhandled item type" );
512 }
513
514 return true;
515}
516
517
519{
520 if( m_pcbModel )
521 return true;
522
523 SHAPE_POLY_SET pcbOutlines; // stores the board main outlines
524
525 if( !m_board->GetBoardPolygonOutlines( pcbOutlines,
526 /* error handler */ nullptr,
527 /* allows use arcs in outlines */ true ) )
528 {
529 wxLogWarning( _( "Board outline is malformed. Run DRC for a full analysis." ) );
530 }
531
532 VECTOR2D origin;
533
534 // Determine the coordinate system reference:
535 // Precedence of reference point is Drill Origin > Grid Origin > User Offset
538 else if( m_params.m_useGridOrigin )
540 else
541 origin = m_params.m_origin;
542
543 m_pcbModel = std::make_unique<STEP_PCB_MODEL>( m_pcbBaseName );
544
546 m_pcbModel->SetPadColor( m_padColor.r, m_padColor.g, m_padColor.b );
547
548 m_pcbModel->SetStackup( m_board->GetStackupOrDefault() );
549 m_pcbModel->SetEnabledLayers( m_layersToExport );
550 m_pcbModel->SetFuseShapes( m_params.m_fuseShapes );
551 m_pcbModel->SetNetFilter( m_params.m_netFilter );
552
553 // Note: m_params.m_BoardOutlinesChainingEpsilon is used only to build the board outlines,
554 // not to set OCC chaining epsilon (much smaller)
555 //
556 // Set the min distance between 2 points for OCC to see these 2 points as merged
557 // OCC_MAX_DISTANCE_TO_MERGE_POINTS is acceptable for OCC, otherwise there are issues
558 // to handle the shapes chaining on copper layers, because the Z dist is 0.035 mm and the
559 // min dist must be much smaller (we use 0.001 mm giving good results)
560 m_pcbModel->OCCSetMergeMaxDistance( OCC_MAX_DISTANCE_TO_MERGE_POINTS );
561
563
564 // For copper layers, only pads and tracks are added, because adding everything on copper
565 // generate unreasonable file sizes and take a unreasonable calculation time.
566 for( FOOTPRINT* fp : m_board->Footprints() )
567 buildFootprint3DShapes( fp, origin );
568
570 {
571 for( PCB_TRACK* track : m_board->Tracks() )
572 buildTrack3DShape( track, origin );
573 }
574
575 for( BOARD_ITEM* item : m_board->Drawings() )
576 buildGraphic3DShape( item, origin );
577
579 {
580 buildZones3DShape( origin );
581 }
582
583 SHAPE_POLY_SET pcbOutlinesNoArcs = pcbOutlines;
584 pcbOutlinesNoArcs.ClearArcs();
585
586 for( PCB_LAYER_ID pcblayer : m_layersToExport.Seq() )
587 {
588 SHAPE_POLY_SET poly = m_poly_shapes[pcblayer];
590
591 poly.SimplifyOutlines( pcbIUScale.mmToIU( 0.003 ) );
593
594 SHAPE_POLY_SET holes = m_poly_holes[pcblayer];
596
597 // Mask layer is negative
598 if( pcblayer == F_Mask || pcblayer == B_Mask )
599 {
600 SHAPE_POLY_SET mask = pcbOutlinesNoArcs;
601
604
605 poly = mask;
606 }
607 else
608 {
609 // Subtract holes
611
612 // Clip to board outline
614 }
615
616 m_pcbModel->AddPolygonShapes( &poly, pcblayer, origin );
617 }
618
619 ReportMessage( wxT( "Create PCB solid model\n" ) );
620
621 wxString msg;
622 msg.Printf( wxT( "Board outline: find %d initial points\n" ), pcbOutlines.FullPointCount() );
623 ReportMessage( msg );
624
625 if( !m_pcbModel->CreatePCB( pcbOutlines, origin, m_params.m_exportBoardBody ) )
626 {
627 ReportMessage( wxT( "could not create PCB solid model\n" ) );
628 return false;
629 }
630
631 return true;
632}
633
634
636{
637 // Display the export time, for statistics
638 int64_t stats_startExportTime = GetRunningMicroSecs();
639
640 // setup opencascade message log
641 Message::DefaultMessenger()->RemovePrinters( STANDARD_TYPE( Message_PrinterOStream ) );
642 Message::DefaultMessenger()->AddPrinter( new KiCadPrinter( this ) );
643
644 ReportMessage( _( "Determining PCB data\n" ) );
645
646 if( m_params.m_outputFile.IsEmpty() )
647 {
648 wxFileName fn = m_board->GetFileName();
649 fn.SetName( fn.GetName() );
650 fn.SetExt( m_params.GetDefaultExportExtension() );
651
652 m_params.m_outputFile = fn.GetFullName();
653 }
654
656
659
661 {
664 }
665
667 {
670 }
671
673
674 try
675 {
676 ReportMessage( wxString::Format( _( "Build %s data\n" ), m_params.GetFormatName() ) );
677
678 if( !buildBoard3DShapes() )
679 {
680 ReportMessage( _( "\n** Error building STEP board model. Export aborted. **\n" ) );
681 return false;
682 }
683
684 ReportMessage( wxString::Format( _( "Writing %s file\n" ), m_params.GetFormatName() ) );
685
686 bool success = true;
688 success = m_pcbModel->WriteSTEP( m_outputFile, m_params.m_optimizeStep );
690 success = m_pcbModel->WriteBREP( m_outputFile );
692 success = m_pcbModel->WriteXAO( m_outputFile );
694 success = m_pcbModel->WriteGLTF( m_outputFile );
695
696 if( !success )
697 {
698 ReportMessage( wxString::Format( _( "\n** Error writing %s file. **\n" ),
700 return false;
701 }
702 else
703 {
704 ReportMessage( wxString::Format( _( "%s file '%s' created.\n" ),
706 }
707 }
708 catch( const Standard_Failure& e )
709 {
710 ReportMessage( e.GetMessageString() );
711 ReportMessage( wxString::Format( _( "\n** Error exporting %s file. Export aborted. **\n" ),
713 return false;
714 }
715 catch( ... )
716 {
717 ReportMessage( wxString::Format( _( "\n** Error exporting %s file. Export aborted. **\n" ),
719 return false;
720 }
721
722 if( m_fail || m_error )
723 {
724 wxString msg;
725
726 if( m_fail )
727 {
728 msg = wxString::Format( _( "Unable to create %s file.\n"
729 "Check that the board has a valid outline and models." ),
731 }
732 else if( m_error || m_warn )
733 {
734 msg = wxString::Format( _( "%s file has been created, but there are warnings." ),
736 }
737
738 ReportMessage( msg );
739 }
740
741 // Display calculation time in seconds
742 double calculation_time = (double)( GetRunningMicroSecs() - stats_startExportTime) / 1e6;
743 ReportMessage( wxString::Format( _( "\nExport time %.3f s\n" ), calculation_time ) );
744
745 return true;
746}
constexpr EDA_IU_SCALE pcbIUScale
Definition: base_units.h:108
static const ADVANCED_CFG & GetCfg()
Get the singleton instance's config, which is shared by all consumers.
BASE_SET & set(size_t pos=std::numeric_limits< size_t >::max(), bool value=true)
Definition: base_set.h:61
const VECTOR2I & GetGridOrigin()
const VECTOR2I & GetAuxOrigin()
A base class for any item which can be embedded within the BOARD container class, and therefore insta...
Definition: board_item.h:79
virtual PCB_LAYER_ID GetLayer() const
Return the primary layer this item is on.
Definition: board_item.h:240
Information pertinent to a Pcbnew printed circuit board.
Definition: board.h:289
BOARD_STACKUP GetStackupOrDefault() const
Definition: board.cpp:2268
bool GetBoardPolygonOutlines(SHAPE_POLY_SET &aOutlines, OUTLINE_ERROR_HANDLER *aErrorHandler=nullptr, bool aAllowUseArcsInPolygons=false, bool aIncludeNPTHAsOutlines=false)
Extract the board outlines and build a closed polygon from lines, arcs and circle items on edge cut l...
Definition: board.cpp:2474
LSET GetEnabledLayers() const
A proxy function that calls the corresponding function in m_BoardSettings.
Definition: board.cpp:758
const ZONES & Zones() const
Definition: board.h:334
const FOOTPRINTS & Footprints() const
Definition: board.h:330
const TRACKS & Tracks() const
Definition: board.h:328
const wxString & GetFileName() const
Definition: board.h:326
PROJECT * GetProject() const
Definition: board.h:490
BOARD_DESIGN_SETTINGS & GetDesignSettings() const
Definition: board.cpp:875
const DRAWINGS & Drawings() const
Definition: board.h:332
double AsRadians() const
Definition: eda_angle.h:117
KICAD_T Type() const
Returns the type of object.
Definition: eda_item.h:101
wxString GetDefaultExportExtension()
void buildZones3DShape(VECTOR2D aOrigin)
std::map< PCB_LAYER_ID, SHAPE_POLY_SET > m_poly_holes
wxString m_outputFile
bool buildGraphic3DShape(BOARD_ITEM *aItem, VECTOR2D aOrigin)
EXPORTER_STEP_PARAMS m_params
EXPORTER_STEP(BOARD *aBoard, const EXPORTER_STEP_PARAMS &aParams)
wxString m_pcbBaseName
the name of the project (board short filename (no path, no ext) used to identify items in step file
bool buildFootprint3DShapes(FOOTPRINT *aFootprint, VECTOR2D aOrigin)
std::unique_ptr< FILENAME_RESOLVER > m_resolver
bool buildBoard3DShapes()
std::unique_ptr< STEP_PCB_MODEL > m_pcbModel
std::map< PCB_LAYER_ID, SHAPE_POLY_SET > m_poly_shapes
bool buildTrack3DShape(PCB_TRACK *aTrack, VECTOR2D aOrigin)
KIGFX::COLOR4D m_copperColor
KIGFX::COLOR4D m_padColor
EDA_ANGLE GetOrientation() const
Definition: footprint.h:226
std::deque< PAD * > & Pads()
Definition: footprint.h:205
int GetAttributes() const
Definition: footprint.h:289
PCB_LAYER_ID GetLayer() const override
Return the primary layer this item is on.
Definition: footprint.h:235
void TransformFPShapesToPolySet(SHAPE_POLY_SET &aBuffer, PCB_LAYER_ID aLayer, int aClearance, int aError, ERROR_LOC aErrorLoc, bool aIncludeText=true, bool aIncludeShapes=true, bool aIncludePrivateItems=false) const
Generate shapes of graphic items (outlines) on layer aLayer as polygons and adds these polygons to aB...
Definition: footprint.cpp:3662
const LIB_ID & GetFPID() const
Definition: footprint.h:247
std::vector< FP_3DMODEL > & Models()
Definition: footprint.h:219
const wxString & GetReference() const
Definition: footprint.h:601
VECTOR2I GetPosition() const override
Definition: footprint.h:223
Hold a record identifying a library accessed by the appropriate footprint library #PLUGIN object in t...
Definition: fp_lib_table.h:42
const FP_LIB_TABLE_ROW * FindRow(const wxString &aNickName, bool aCheckIfEnabled=false)
Return an FP_LIB_TABLE_ROW if aNickName is found in this table or in any chained fall back table frag...
A color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:104
double r
Red component.
Definition: color4d.h:392
double g
Green component.
Definition: color4d.h:393
double b
Blue component.
Definition: color4d.h:394
EXPORTER_STEP * m_converter
KiCadPrinter(EXPORTER_STEP *aConverter)
virtual void Send(const TCollection_ExtendedString &theString, const Message_Gravity theGravity, const Standard_Boolean theToPutEol) const override
virtual void Send(const TCollection_AsciiString &theString, const Message_Gravity theGravity, const Standard_Boolean theToPutEol) const override
const UTF8 & GetLibNickname() const
Return the logical library name portion of a LIB_ID.
Definition: lib_id.h:87
const wxString GetFullURI(bool aSubstituted=false) const
Return the full location specifying URI for the LIB, either in original UI form or in environment var...
LSET is a set of PCB_LAYER_IDs.
Definition: lset.h:35
static LSET ExternalCuMask()
Return a mask holding the Front and Bottom layers.
Definition: lset.cpp:761
LSEQ Seq(const PCB_LAYER_ID *aWishListSequence, unsigned aCount) const
Return an LSEQ from the union of this LSET and a desired sequence.
Definition: lset.cpp:393
bool Contains(PCB_LAYER_ID aLayer)
See if the layer set contains a PCB layer.
Definition: lset.h:79
static LSET InternalCuMask()
Return a complete set of internal copper layers which is all Cu layers except F_Cu and B_Cu.
Definition: lset.cpp:722
static LSET AllCuMask(int aCuLayerCount=MAX_CU_LAYERS)
Return a mask holding the requested number of Cu PCB_LAYER_IDs.
Definition: lset.cpp:733
Definition: pad.h:54
void TransformShapeToPolygon(SHAPE_POLY_SET &aBuffer, PCB_LAYER_ID aLayer, int aClearance, int aError, ERROR_LOC aErrorLoc, bool ignoreLineWidth=false) const override
Convert the shape to a closed polygon.
Definition: pcb_shape.cpp:821
void TransformTextToPolySet(SHAPE_POLY_SET &aBuffer, int aClearance, int aMaxError, ERROR_LOC aErrorLoc) const
Function TransformTextToPolySet Convert the text to a polygonSet describing the actual character stro...
void TransformShapeToPolygon(SHAPE_POLY_SET &aBuffer, PCB_LAYER_ID aLayer, int aClearance, int aError, ERROR_LOC aErrorLoc, bool ignoreLineWidth=false) const override
Convert the track shape to a closed polygon.
Definition: pcb_track.cpp:1683
static FP_LIB_TABLE * PcbFootprintLibs(PROJECT *aProject)
Return the table of footprint libraries without Kiway.
Definition: project_pcb.cpp:37
Represent a set of closed polygons.
void BooleanSubtract(const SHAPE_POLY_SET &b, POLYGON_MODE aFastMode)
Perform boolean polyset difference For aFastMode meaning, see function booleanOp.
void ClearArcs()
Removes all arc references from all the outlines and holes in the polyset.
int FullPointCount() const
Return the number of points in the shape poly set.
void BooleanIntersection(const SHAPE_POLY_SET &b, POLYGON_MODE aFastMode)
Perform boolean polyset intersection For aFastMode meaning, see function booleanOp.
std::vector< SHAPE_LINE_CHAIN > POLYGON
represents a single polygon outline with holes.
void Simplify(POLYGON_MODE aFastMode)
Simplify the polyset (merges overlapping polys, eliminates degeneracy/self-intersections) For aFastMo...
void Unfracture(POLYGON_MODE aFastMode)
Convert a single outline slitted ("fractured") polygon into a set ouf outlines with holes.
void SimplifyOutlines(int aMaxError=0)
Simplifies the lines in the polyset.
void TransformToPolygon(SHAPE_POLY_SET &aBuffer, int aError, ERROR_LOC aErrorLoc) const override
Fills a SHAPE_POLY_SET with a polygon representation of this shape.
const std::vector< POLYGON > & CPolygons() const
Handle a list of polygons defining a copper zone.
Definition: zone.h:73
#define _(s)
void ReportMessage(const wxString &aMessage)
@ FP_SMD
Definition: footprint.h:75
@ FP_DNP
Definition: footprint.h:82
@ FP_THROUGH_HOLE
Definition: footprint.h:74
@ ERROR_INSIDE
static const std::string AutoSaveFilePrefix
const wxChar *const traceKiCad2Step
Flag to enable KiCad2Step debug tracing.
bool IsCopperLayer(int aLayerId)
Tests whether a layer is a copper layer.
Definition: layer_ids.h:531
PCB_LAYER_ID
A quick note on layer IDs:
Definition: layer_ids.h:60
@ B_Mask
Definition: layer_ids.h:106
@ B_Cu
Definition: layer_ids.h:95
@ F_Mask
Definition: layer_ids.h:107
@ F_SilkS
Definition: layer_ids.h:104
@ B_SilkS
Definition: layer_ids.h:103
@ F_Cu
Definition: layer_ids.h:64
PGM_BASE & Pgm()
The global Program "get" accessor.
Definition: pgm_base.cpp:1059
see class PGM_BASE
int64_t GetRunningMicroSecs()
An alternate way to calculate an elapsed time (in microsecondes) to class PROF_COUNTER.
static constexpr double OCC_MAX_DISTANCE_TO_MERGE_POINTS
Default distance between points to treat them as separate ones (mm) 0.001 mm or less is a reasonable ...
constexpr double IUTomm(int iu) const
Definition: base_units.h:86
constexpr int mmToIU(double mm) const
Definition: base_units.h:88
wxLogTrace helper definitions.
@ PCB_SHAPE_T
class PCB_SHAPE, a segment not on copper layers
Definition: typeinfo.h:88
@ PCB_VIA_T
class PCB_VIA, a via (like a track segment on a copper layer)
Definition: typeinfo.h:97
@ PCB_TEXTBOX_T
class PCB_TEXTBOX, wrapped text on a layer
Definition: typeinfo.h:93
@ PCB_TEXT_T
class PCB_TEXT, text on a layer
Definition: typeinfo.h:92
@ PCB_TABLE_T
class PCB_TABLE, table of PCB_TABLECELLs
Definition: typeinfo.h:94
Definition of file extensions used in Kicad.