KiCad PCB EDA Suite
Loading...
Searching...
No Matches
model_import.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 *
4 * Copyright The KiCad Developers, see AUTHORS.txt for contributors.
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify 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 (at your option)
9 * 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, you may find one here:
18 * http://www.gnu.org/licenses/old-licenses/gpl-3.0.html
19 */
20
21#ifndef MODEL_IMPORT_H
22#define MODEL_IMPORT_H
23
24#include <cstddef>
25#include <cstdint>
26#include <string>
27#include <string_view>
28
31
32#ifndef KICAD_3D_IMPORT_API
33#if defined( COMPILE_3D_IMPORT )
34#define KICAD_3D_IMPORT_API APIEXPORT
35#else
36#define KICAD_3D_IMPORT_API APIIMPORT
37#endif
38#endif
39
40namespace S3D
41{
50
51
64
65
67{
69 double stepLinearDeflection = 0.14;
71 bool vrmlEnableInline = true;
73 std::uint64_t maxCompressedBytes = 64U * 1024U * 1024U;
74 std::uint64_t maxExpandedBytes = 512U * 1024U * 1024U;
75 std::uint64_t maxMeshBytes = 1024U * 1024U * 1024U;
76 bool ( *isCanceled )( void* aContext ) noexcept = nullptr;
77 void* cancellationContext = nullptr;
78
79 bool IsCanceled() const noexcept { return isCanceled && isCanceled( cancellationContext ); }
80};
81
82
84{
85public:
86 MODEL_IMPORT_RESULT( MODEL_IMPORT_RESULT&& aOther ) noexcept;
89
92
93 explicit operator bool() const noexcept;
94 const S3DMODEL* GetModel() const noexcept;
95 MODEL_IMPORT_ERROR GetError() const noexcept;
96 std::string_view GetDiagnostic() const noexcept;
97
98private:
99 MODEL_IMPORT_RESULT() noexcept = default;
100
101 S3DMODEL* m_model = nullptr;
104
105 friend KICAD_3D_IMPORT_API MODEL_IMPORT_RESULT ImportModel( const std::string& aFileName,
106 const MODEL_IMPORT_OPTIONS& aOptions ) noexcept;
107};
108
109
118{
119 MODEL_IMPORT_OPTIONS options;
120 options.vrmlEnableInline = false;
121 options.maxCompressedBytes = 32U * 1024U * 1024U;
122 options.maxExpandedBytes = 256U * 1024U * 1024U;
123 options.maxMeshBytes = 512U * 1024U * 1024U;
124
125 return options;
126}
127
128
139KICAD_3D_IMPORT_API MODEL_IMPORT_RESULT ImportModel( const std::string& aFileName,
140 const MODEL_IMPORT_OPTIONS& aOptions = {} ) noexcept;
141} // namespace S3D
142
143#endif // MODEL_IMPORT_H
define an internal structure to be used by the 3D renders
MODEL_IMPORT_ERROR m_error
const S3DMODEL * GetModel() const noexcept
MODEL_IMPORT_RESULT & operator=(const MODEL_IMPORT_RESULT &)=delete
MODEL_IMPORT_ERROR GetError() const noexcept
std::string_view GetDiagnostic() const noexcept
MODEL_IMPORT_RESULT(MODEL_IMPORT_RESULT &&aOther) noexcept
MODEL_IMPORT_RESULT & operator=(MODEL_IMPORT_RESULT &&aOther) noexcept
friend KICAD_3D_IMPORT_API MODEL_IMPORT_RESULT ImportModel(const std::string &aFileName, const MODEL_IMPORT_OPTIONS &aOptions) noexcept
Import and flatten one model without invoking GUI facilities.
MODEL_IMPORT_RESULT(const MODEL_IMPORT_RESULT &)=delete
#define KICAD_3D_IMPORT_API
MODEL_IMPORT_FORMAT
MODEL_IMPORT_ERROR
MODEL_IMPORT_OPTIONS PreviewImportOptions() noexcept
Options for previewing a file the user has not opened.
Definition x3d_ops.h:33
STL namespace.
Store the a model based on meshes and materials.
Definition c3dmodel.h:111
bool IsCanceled() const noexcept
MODEL_IMPORT_FORMAT format
std::uint64_t maxCompressedBytes
std::uint64_t maxExpandedBytes
bool(* isCanceled)(void *aContext) noexcept