KiCad PCB EDA Suite
Loading...
Searching...
No Matches
3d_model_align.h
Go to the documentation of this file.
1/*
2 * This program source code file is part of KiCad, a free EDA CAD application.
3 * Copyright The KiCad Developers, see AUTHORS.txt for contributors.
4 * SPDX-License-Identifier: GPL-2.0-or-later
5 */
6
7#ifndef KICAD_3D_MODEL_ALIGN_H
8#define KICAD_3D_MODEL_ALIGN_H
9
10#include <glm/glm.hpp>
11#include <array>
12#include <string>
13#include <vector>
14
15struct S3DMODEL;
16
17namespace MODEL_ALIGN
18{
19struct REGION
20{
21 std::vector<std::array<unsigned int, 2>> sourceTriangles;
22 std::vector<glm::dvec3> vertices;
23 std::vector<std::array<unsigned int, 3>> triangles;
24 unsigned int material = 0;
25 double area = 0;
26 glm::dvec3 centroid{ 0.0 };
27 glm::dvec3 normal{ 0.0 };
28 glm::dvec3 extents{ 0.0 };
29 double normalMagnitude = 0;
30 bool planar = false;
31 bool twoSided = false;
32};
33
40
41struct PAD
42{
43 std::string number;
45 glm::dvec2 position{ 0.0 };
46 glm::dvec2 size{ 0.0 };
47 glm::dvec2 drill{ 0.0 };
48 double rotation = 0;
49};
50
58
60{
61 glm::dvec3 rotation{ 0.0 };
62 glm::dvec3 offset{ 0.0 };
63 unsigned int matched = 0;
64 unsigned int total = 0;
66};
67
68std::vector<REGION> BuildRegions( const S3DMODEL& aModel, const glm::dvec3& aScale );
69
71std::vector<PAD> BuildPadGroup( const std::vector<PAD>& aPads, size_t aClickedPad );
72
74std::vector<ALIGN_SOLUTION> SolveAlignment( const std::vector<REGION>& aRegions, size_t aSeed,
75 const std::vector<PAD>& aPadGroup, const std::vector<PAD>& aAllPads,
76 const glm::dvec3& aCurrentRotation );
77} // namespace MODEL_ALIGN
78
79#endif
std::vector< REGION > BuildRegions(const S3DMODEL &aModel, const glm::dvec3 &aScale)
std::vector< PAD > BuildPadGroup(const std::vector< PAD > &aPads, size_t aClickedPad)
Return the clicked pad first, followed by its congruent, deduplicated peers.
std::vector< ALIGN_SOLUTION > SolveAlignment(const std::vector< REGION > &aRegions, size_t aSeed, const std::vector< PAD > &aPadGroup, const std::vector< PAD > &aAllPads, const glm::dvec3 &aCurrentRotation)
The first element of aPadGroup must be the clicked pad; all coordinates are millimetres,...
glm::dvec3 rotation
GUI degrees of Rz * Ry * Rx; negate when storing in FP_3DMODEL.
glm::dvec3 offset
Footprint-local millimetres, Y up.
std::string number
PAD_ATTRIBUTE attribute
glm::dvec2 position
Footprint-local millimetres, Y up.
double rotation
Degrees in the Y-up frame.
unsigned int material
std::vector< std::array< unsigned int, 3 > > triangles
glm::dvec3 extents
Sorted PCA extents, largest first.
std::vector< std::array< unsigned int, 2 > > sourceTriangles
Mesh/triangle pairs, including reversed duplicates.
std::vector< glm::dvec3 > vertices
Scaled model coordinates, millimetres.
Store the a model based on meshes and materials.
Definition c3dmodel.h:111