58 for(
unsigned int meshIndex = 0; meshIndex < aModel.
m_MeshesSize; ++meshIndex )
62 for(
unsigned int vertexIndex = 0; vertexIndex < mesh.
m_VertexSize; ++vertexIndex )
65 double z = ( transform * glm::vec4( vertex.x, vertex.y, vertex.z, 1.0f ) ).z;
67 if( std::isfinite( z ) )
68 height = std::max( height, z );
78 return std::any_of( aFp->
Models().begin(), aFp->
Models().end(),
81 return model.m_Show && !model.m_Filename.IsEmpty();
88double componentModelHeight(
const FOOTPRINT* aFp )
98 static std::mutex cacheMutex;
99 std::lock_guard<std::mutex> lock( cacheMutex );
116 if( !placement.m_Show || placement.m_Filename.IsEmpty() )
119 std::vector<const EMBEDDED_FILES*> embeddedFiles = { aFp->
GetEmbeddedFiles(),
150 comp.m_mirror = wxT(
"M" );
160 if(
comp.m_part_name.IsEmpty() )
168 double heightMm = componentModelHeight( aFp );
170 if( heightMm <= 0.0 )
172 wxString value = row.
Field( wxS(
"Height" ) );
174 if( !value.IsEmpty() )
181 if( std::isfinite( heightMm ) && heightMm > 0.0 )
183 double outputHeight = format.
m_unitsStr ==
"INCH" ? heightMm / 25.4 : heightMm;
187 if(
comp.m_comp_name.IsEmpty() )
190 comp.m_comp_name = wxString::Format(
"UNNAMED%zu",
m_compList.size() );
194 if(
comp.m_comp_name != originalRef )
198 m_plugin->Report( wxString::Format(
_(
"Component '%s' has non-ASCII characters in its "
199 "designator; converted to '%s' for ODB++ export." ),
206 wxString base_comp_name =
comp.m_comp_name;
215 candidate = wxString::Format(
"%s_%zu", base_comp_name, suffix++ );
220 m_plugin->Report( wxString::Format(
_(
"Component '%s' has an ambiguous designator after "
221 "conversion; renamed to '%s' for ODB++ export." ),
227 comp.m_comp_name = candidate;
235 wxString key = field->GetName();
239 wxString value = row.
Field( field->GetName() );
240 value.Replace( wxS(
"\r" ), wxEmptyString );
241 value.Replace( wxS(
"\n" ), wxS(
" " ) );
243 comp.m_prp[key] = wxString::Format(
"'%s'", value );
252 &&
m_plugin->GetFormat().m_variantNames.m_listsFit )
254 std::vector<wxString> included;
259 included.push_back( variant );
263 m_plugin->GetFormat().m_variantNames.Join( included ).ToStdString() } );
289 ost <<
"UNITS=" <<
m_plugin->GetFormat().m_unitsStr << std::endl;
302 ost <<
"# CMP " <<
m_index << std::endl;
310 for(
const auto& [key, value] :
m_prp )
312 ost <<
"PRP " << key.utf8_string() <<
" " << value.utf8_string() << std::endl;
320 ost <<
"#" << std::endl;
glm::mat4 CalcModelMatrix(const SFVEC3F &aOffset, const SFVEC3F &aRotation, const SFVEC3F &aScale)
Build the model-to-footprint transform used by rendering and picking.
Defines math related functions.
constexpr EDA_IU_SCALE pcbIUScale
define an internal structure to be used by the 3D renders
void WriteAttributes(std::ostream &ost, const std::string &prefix="") const
void AddSystemAttribute(Tr &r, Ta v)
void WriteAttributes(std::ostream &ost) const
virtual const BOARD * GetBoard() const
Return the BOARD in which this BOARD_ITEM resides, or NULL if none.
Information pertinent to a Pcbnew printed circuit board.
EMBEDDED_FILES * GetEmbeddedFiles() override
const std::vector< wxString > & GetVariantNames() const
PROJECT * GetProject() const
PCB_IO_ODBPP * m_plugin
Plugin the export runs under, used for formatting and designator reports.
std::list< ODB_COMPONENT > m_compList
ODB_COMPONENT & AddComponent(const FOOTPRINT *aFp, const EDA_DATA::PACKAGE &aPkg)
void Write(std::ostream &ost) const
std::set< wxString > m_usedCompNames
VECTOR3D m_Offset
3D model offset (mm)
VECTOR3D m_Rotation
3D model rotation (degrees)
VECTOR3D m_Scale
3D model scaling factor (dimensionless)
std::optional< wxString > GetFullURI(LIBRARY_TABLE_TYPE aType, const wxString &aNickname, bool aSubstituted=false)
Return the full location specifying URI for the LIB, either in original UI form or in environment var...
const UTF8 & GetLibItemName() const
const UTF8 & GetLibNickname() const
Return the logical library name portion of a LIB_ID.
const wxString GetFullLibraryName() const
const size_t m_index
! CMP index number on board to be used in SNT(TOP), 0~n-1
std::list< TOEPRINT > m_toeprints
std::pair< wxString, wxString > m_center
size_t m_pkg_ref
! package ref number from PKG in eda/data file, 0~n-1
wxString m_part_name
! Part identification is a single string of ASCII characters without spaces
void Write(std::ostream &ost) const
wxString m_comp_name
! Unique reference designator (component name)
std::map< wxString, wxString > m_prp
static S3D_CACHE * Get3DCacheManager(PROJECT *aProject, bool updateProjDir=false)
Return a pointer to an instance of the 3D cache manager.
static FOOTPRINT_LIBRARY_ADAPTER * FootprintLibAdapter(PROJECT *aProject)
Container for project specific data.
Cache for storing the 3D shapes.
S3DMODEL * GetModel(const wxString &aModelFileName, const wxString &aBasePath, std::vector< const EMBEDDED_FILES * > aEmbeddedFilesStack)
Attempt to load the scene data for a model and to translate it into an S3D_MODEL structure for displa...
static constexpr EDA_ANGLE ANGLE_0
static constexpr EDA_ANGLE ANGLE_360
FAB_COMPONENT_ROW MakeFabComponentRow(const FOOTPRINT &aFootprint, const wxString &aVariant)
Hashing functions for EDA_ITEMs.
KICOMMON_API double DoubleValueFromString(const EDA_IU_SCALE &aIuScale, EDA_UNITS aUnits, const wxString &aTextValue, EDA_DATA_TYPE aType=EDA_DATA_TYPE::DISTANCE)
Convert aTextValue to a double.
wxString GenLegalComponentName(const wxString &aStr)
std::pair< wxString, wxString > AddXY(const ODB_FORMAT &aFormat, const VECTOR2I &aVec)
void RemoveWhitespace(wxString &aStr)
double ModelHeightAboveBoard(const S3DMODEL &aModel, const FP_3DMODEL &aPlacement)
bool HasShownModel(const FOOTPRINT *aFp)
wxString Double2String(const ODB_FORMAT &aFormat, double aVal)
Footprint facts resolved for one assembly variant.
wxString Field(const wxString &aName) const
Variant-resolved shown text, empty when the field is missing.
size_t m_subnet_num
! Number of subnet (SNT record TOP) in the referenced net
std::pair< wxString, wxString > m_center
! Board location of the pin.
void Write(std::ostream &ost) const
size_t m_net_num
! Number of NET record in the eda/data file.
wxString m_mirror
! equal to CMP m_mirror.
const size_t m_pin_num
! index of PIN record in the eda/data file, 0~n-1.
wxString m_toeprint_name
! Name of the pad in PIN record
Store the a model based on meshes and materials.
unsigned int m_MeshesSize
Number of meshes in the array.
SMESH * m_Meshes
The meshes list of this model.
Per-vertex normal/color/texcoors structure.
unsigned int m_VertexSize
Number of vertex in the arrays.
SFVEC3F * m_Positions
Vertex position array.
@ REFERENCE
Field Reference of part, i.e. "IC21".
wxLogTrace helper definitions.