LibrePCB Developers Documentation
occmodel.h
Go to the documentation of this file.
1/*
2 * LibrePCB - Professional EDA for everyone!
3 * Copyright (C) 2013 LibrePCB Developers, see AUTHORS.md for contributors.
4 * https://librepcb.org/
5 *
6 * This program is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation, either version 3 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program. If not, see <http://www.gnu.org/licenses/>.
18 */
19
20#ifndef LIBREPCB_CORE_OCCMODEL_H
21#define LIBREPCB_CORE_OCCMODEL_H
22
23/*******************************************************************************
24 * Includes
25 ******************************************************************************/
26#include "../types/angle.h"
27#include "../types/length.h"
28#include "../types/point.h"
29
30#include <QtCore>
31#include <QtGui>
32
33#include <memory>
34
35/*******************************************************************************
36 * Namespace / Forward Declarations
37 ******************************************************************************/
38namespace librepcb {
39
40class FilePath;
41class Path;
42class Transform;
43
44/*******************************************************************************
45 * Class OccModel
46 ******************************************************************************/
47
51class OccModel final {
52 Q_DECLARE_TR_FUNCTIONS(OccModel)
53
54 struct Data;
55
56public:
57 // Types
58 typedef std::tuple<qreal, qreal, qreal> Color;
59
60 // Constructors / Destructor
61 OccModel() noexcept = delete;
62 OccModel(const OccModel& other) = delete;
63 ~OccModel() noexcept;
64
65 // General Methods
66 void addToAssembly(const OccModel& model, const Point3D& pos,
67 const Angle3D& rot, const Transform& transform,
68 const QString& name);
69 void saveAsStep(const QString& name, const FilePath& fp) const;
70 QMap<Color, QVector<QVector3D>> tesselate() const;
71
72 // Static Methods
73 static bool isAvailable() noexcept;
74 static QString getOccVersionString() noexcept;
75 static void setVerboseOutput(bool verbose) noexcept;
76 static std::unique_ptr<OccModel> createAssembly(const QString& name);
77 static std::unique_ptr<OccModel> createBoard(const Path& outline,
78 const QVector<Path>& holes,
79 const PositiveLength& thickness,
80 const QColor& color);
81 static std::unique_ptr<OccModel> loadStep(const QByteArray content);
82 static QByteArray minifyStep(const QByteArray& content);
83
84 // Operator Overloadings
85 OccModel& operator=(const OccModel& rhs) = delete;
86
87private: // Methods
88 explicit OccModel(std::unique_ptr<Data> data);
89 static void initOpenCascade();
90 static QString cleanString(const QString& str);
91 static void throwNotAvailable();
92
93private: // Data
95
96 std::unique_ptr<Data> mImpl;
97};
98
99/*******************************************************************************
100 * End of File
101 ******************************************************************************/
102
103} // namespace librepcb
104
105#endif
This class represents absolute, well-formatted paths to files or directories.
Definition: filepath.h:129
3D model implemented with OpenCascade
Definition: occmodel.h:51
static std::unique_ptr< OccModel > createBoard(const Path &outline, const QVector< Path > &holes, const PositiveLength &thickness, const QColor &color)
Definition: occmodel.cpp:542
static bool sOutputVerbosityConfigured
Definition: occmodel.h:94
static QString cleanString(const QString &str)
Definition: occmodel.cpp:818
static void throwNotAvailable()
Definition: occmodel.cpp:824
static QByteArray minifyStep(const QByteArray &content)
Definition: occmodel.cpp:668
static std::unique_ptr< OccModel > loadStep(const QByteArray content)
Definition: occmodel.cpp:621
QMap< Color, QVector< QVector3D > > tesselate() const
Definition: occmodel.cpp:456
static bool isAvailable() noexcept
Definition: occmodel.cpp:485
static void setVerboseOutput(bool verbose) noexcept
Definition: occmodel.cpp:498
OccModel() noexcept=delete
void saveAsStep(const QString &name, const FilePath &fp) const
Definition: occmodel.cpp:424
static std::unique_ptr< OccModel > createAssembly(const QString &name)
Definition: occmodel.cpp:511
static QString getOccVersionString() noexcept
Definition: occmodel.cpp:489
std::unique_ptr< Data > mImpl
Definition: occmodel.h:96
std::tuple< qreal, qreal, qreal > Color
Definition: occmodel.h:58
void addToAssembly(const OccModel &model, const Point3D &pos, const Angle3D &rot, const Transform &transform, const QString &name)
Definition: occmodel.cpp:301
static void initOpenCascade()
Definition: occmodel.cpp:800
The Path class represents a list of vertices connected by straight lines or circular arc segments.
Definition: path.h:58
Helper class to perform coordinate transformation with various types.
Definition: transform.h:59
Definition: occmodel.cpp:77
type_safe::constrained_type< Length, PositiveLengthConstraint, PositiveLengthVerifier > PositiveLength
Definition: length.h:812
std::tuple< Length, Length, Length > Point3D
Definition: length.h:989
std::tuple< Angle, Angle, Angle > Angle3D
Definition: angle.h:461
Definition: occmodel.cpp:85