KiCad PCB EDA Suite
step_pcb_model.cpp File Reference
#include <algorithm>
#include <cmath>
#include <sstream>
#include <string>
#include <utility>
#include <wx/filename.h>
#include <wx/filefn.h>
#include <wx/stdpaths.h>
#include <wx/wfstream.h>
#include <wx/zipstrm.h>
#include <decompress.hpp>
#include <footprint.h>
#include <pad.h>
#include "step_pcb_model.h"
#include "streamwrapper.h"
#include <IGESCAFControl_Reader.hxx>
#include <IGESCAFControl_Writer.hxx>
#include <IGESControl_Controller.hxx>
#include <IGESData_GlobalSection.hxx>
#include <IGESData_IGESModel.hxx>
#include <Interface_Static.hxx>
#include <Quantity_Color.hxx>
#include <STEPCAFControl_Reader.hxx>
#include <STEPCAFControl_Writer.hxx>
#include <APIHeaderSection_MakeHeader.hxx>
#include <Standard_Version.hxx>
#include <TCollection_ExtendedString.hxx>
#include <TDataStd_Name.hxx>
#include <TDataStd_TreeNode.hxx>
#include <TDF_LabelSequence.hxx>
#include <TDF_ChildIterator.hxx>
#include <TopExp_Explorer.hxx>
#include <XCAFDoc.hxx>
#include <XCAFDoc_DocumentTool.hxx>
#include <XCAFDoc_ColorTool.hxx>
#include <BRep_Tool.hxx>
#include <BRepMesh_IncrementalMesh.hxx>
#include <BRepBuilderAPI.hxx>
#include <BRepBuilderAPI_MakeEdge.hxx>
#include <BRepBuilderAPI_Transform.hxx>
#include <BRepBuilderAPI_GTransform.hxx>
#include <BRepBuilderAPI_MakeFace.hxx>
#include <BRepPrimAPI_MakePrism.hxx>
#include <BRepPrimAPI_MakeCylinder.hxx>
#include <BRepAlgoAPI_Cut.hxx>
#include <TopoDS.hxx>
#include <TopoDS_Wire.hxx>
#include <TopoDS_Face.hxx>
#include <TopoDS_Compound.hxx>
#include <TopoDS_Builder.hxx>
#include <Standard_Failure.hxx>
#include <gp_Ax2.hxx>
#include <gp_Circ.hxx>
#include <gp_Dir.hxx>
#include <gp_Pnt.hxx>
#include <Geom_BezierCurve.hxx>
#include <macros.h>

Go to the source code of this file.

Enumerations

enum  FormatType {
  FMT_NONE , FMT_STEP , FMT_STEPZ , FMT_IGES ,
  FMT_EMN , FMT_IDF , FMT_WRL , FMT_WRZ ,
  FMT_NONE = 0 , FMT_STEP , FMT_STPZ , FMT_IGES
}
 

Functions

FormatType fileType (const char *aFileName)
 

Variables

static constexpr double USER_PREC = 1e-4
 
static constexpr double USER_ANGLE_PREC = 1e-6
 
static constexpr double THICKNESS_MIN = 0.002
 
static constexpr double THICKNESS_DEFAULT = 1.6
 
static constexpr double BOARD_OFFSET = 0.05
 
static constexpr double MIN_LENGTH2 = STEPEXPORT_MIN_DISTANCE * STEPEXPORT_MIN_DISTANCE
 

Enumeration Type Documentation

◆ FormatType

enum FormatType
Enumerator
FMT_NONE 
FMT_STEP 
FMT_STEPZ 
FMT_IGES 
FMT_EMN 
FMT_IDF 
FMT_WRL 
FMT_WRZ 
FMT_NONE 
FMT_STEP 
FMT_STPZ 
FMT_IGES 

Definition at line 110 of file step_pcb_model.cpp.

111{
112 FMT_NONE,
113 FMT_STEP,
114 FMT_STEPZ,
115 FMT_IGES,
116 FMT_EMN,
117 FMT_IDF,
118 FMT_WRL,
119 FMT_WRZ
120};
@ FMT_STEP
@ FMT_IGES
@ FMT_IDF
@ FMT_WRZ
@ FMT_STEPZ
@ FMT_NONE
@ FMT_WRL
@ FMT_EMN

Function Documentation

◆ fileType()

FormatType fileType ( const char *  aFileName)

Definition at line 123 of file step_pcb_model.cpp.

124{
125 wxFileName lfile( wxString::FromUTF8Unchecked( aFileName ) );
126
127 if( !lfile.FileExists() )
128 {
129 wxString msg;
130 msg.Printf( wxT( " * fileType(): no such file: %s\n" ),
131 wxString::FromUTF8Unchecked( aFileName ) );
132
133 ReportMessage( msg );
134 return FMT_NONE;
135 }
136
137 wxString ext = lfile.GetExt().Lower();
138
139 if( ext == wxT( "wrl" ) )
140 return FMT_WRL;
141
142 if( ext == wxT( "wrz" ) )
143 return FMT_WRZ;
144
145 if( ext == wxT( "idf" ) )
146 return FMT_IDF; // component outline
147
148 if( ext == wxT( "emn" ) )
149 return FMT_EMN; // PCB assembly
150
151 if( ext == wxT( "stpz" ) || ext == wxT( "gz" ) )
152 return FMT_STEPZ;
153
154 OPEN_ISTREAM( ifile, aFileName );
155
156 if( ifile.fail() )
157 return FMT_NONE;
158
159 char iline[82];
160 memset( iline, 0, 82 );
161 ifile.getline( iline, 82 );
162 CLOSE_STREAM( ifile );
163 iline[81] = 0; // ensure NULL termination when string is too long
164
165 // check for STEP in Part 21 format
166 // (this can give false positives since Part 21 is not exclusively STEP)
167 if( !strncmp( iline, "ISO-10303-21;", 13 ) )
168 return FMT_STEP;
169
170 std::string fstr = iline;
171
172 // check for STEP in XML format
173 // (this can give both false positive and false negatives)
174 if( fstr.find( "urn:oid:1.0.10303." ) != std::string::npos )
175 return FMT_STEP;
176
177 // Note: this is a very simple test which can yield false positives; the only
178 // sure method for determining if a file *not* an IGES model is to attempt
179 // to load it.
180 if( iline[72] == 'S' && ( iline[80] == 0 || iline[80] == 13 || iline[80] == 10 ) )
181 return FMT_IGES;
182
183 return FMT_NONE;
184}
void ReportMessage(const wxString &aMessage)
#define CLOSE_STREAM(var)
#define OPEN_ISTREAM(var, name)

References CLOSE_STREAM, FMT_EMN, FMT_IDF, FMT_IGES, FMT_NONE, FMT_STEP, FMT_STEPZ, FMT_WRL, FMT_WRZ, OPEN_ISTREAM, and ReportMessage().

Referenced by PANEL_FP_LIB_TABLE::browseLibrariesHandler(), STEP_PCB_MODEL::getModelLabel(), GRAPHICS_IMPORT_MGR::GetPluginByExt(), SCH_EDIT_FRAME::importFile(), FOOTPRINT_EDIT_FRAME::ImportFootprint(), PANEL_FP_LIB_TABLE::PANEL_FP_LIB_TABLE(), GERBVIEW_CONTROL::ReloadAllLayers(), and SYMBOL_EDIT_FRAME::saveLibrary().

Variable Documentation

◆ BOARD_OFFSET

constexpr double BOARD_OFFSET = 0.05
staticconstexpr

Definition at line 103 of file step_pcb_model.cpp.

Referenced by STEP_PCB_MODEL::getModelLocation().

◆ MIN_LENGTH2

constexpr double MIN_LENGTH2 = STEPEXPORT_MIN_DISTANCE * STEPEXPORT_MIN_DISTANCE
staticconstexpr

Definition at line 106 of file step_pcb_model.cpp.

Referenced by STEP_PCB_MODEL::STEP_PCB_MODEL().

◆ THICKNESS_DEFAULT

constexpr double THICKNESS_DEFAULT = 1.6
staticconstexpr

◆ THICKNESS_MIN

constexpr double THICKNESS_MIN = 0.002
staticconstexpr

Definition at line 97 of file step_pcb_model.cpp.

Referenced by STEP_PCB_MODEL::SetPCBThickness().

◆ USER_ANGLE_PREC

constexpr double USER_ANGLE_PREC = 1e-6
staticconstexpr

Definition at line 94 of file step_pcb_model.cpp.

Referenced by STEP_PCB_MODEL::STEP_PCB_MODEL().

◆ USER_PREC

constexpr double USER_PREC = 1e-4
staticconstexpr