50 float scene_unit_scale,
53 std::unique_ptr<FileWriter> writer;
60 catch (
const std::runtime_error &ex) {
64 "STL Export: Cannot open file '%s'",
88 char object_name[
sizeof(
object->id.name) - 2];
101 if (basename !=
nullptr &&
BLI_strcasecmp(basename,
".stl") == 0) {
102 *
const_cast<char *
>(basename) =
'\0';
112 writer = std::make_unique<FileWriter>(filepath, export_params.
ascii_format);
114 catch (
const std::runtime_error &ex) {
117 export_params.
reports,
RPT_ERROR,
"STL Export: Cannot open file '%s'", filepath);
132 float global_scale = export_params.
global_scale * scene_unit_scale;
133 float axes_transform[3][3];
139 mul_m4_m3m4(xform, axes_transform, obj_eval->object_to_world().ptr());
141 mul_v3_m3v3(xform[3], axes_transform, obj_eval->object_to_world().location());
142 xform[3][3] = obj_eval->object_to_world()[3][3];
149 for (
const int3 &tri :
mesh->corner_tris()) {
151 for (
int i = 0; i < 3; i++) {
153 int idx = mirrored ? 2 - i : i;
154 float3 pos = positions[corner_verts[tri[idx]]];
157 data.vertices[i] = pos;
160 writer->write_triangle(
data);
182 "STL Export: Unable to find collection '%s'",
196 float scene_unit_scale = 1.0f;
201 export_frame(depsgraph, scene_unit_scale, export_params);
#define CLOG_ERROR(clg_ref,...)
#define DEG_OBJECT_ITER_BEGIN(settings_, instance_)
#define DEG_OBJECT_ITER_END
Object is a sort of wrapper for general info.
void export_frame(Depsgraph *depsgraph, float scene_unit_scale, const STLExportParams &export_params)
void exporter_main(const bContext *C, const STLExportParams &export_params)
const Mesh * mesh_coerce_for_export_setup(MeshCoerceForExport &coerce, Depsgraph *depsgraph, Object *obj_eval, const bool apply_modifiers)
VecBase< T, 3 > normal_tri(const VecBase< T, 3 > &v1, const VecBase< T, 3 > &v2, const VecBase< T, 3 > &v3)
int char char int BLI_strcasecmp(const char *s1, const char *s2) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1
char * STRNCPY(char(&dst)[N], const char *src)
ID * BKE_libblock_find_name(Main *bmain, short type, const char *name, const std::optional< Library * > lib=std::nullopt) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL()
bool ED_editors_flush_edits(Main *bmain)
void DEG_graph_build_from_view_layer(Depsgraph *graph)
void DEG_graph_build_from_collection(Depsgraph *graph, Collection *collection)
void DEG_graph_free(Depsgraph *graph)
void BLI_string_replace_char(char *str, char src, char dst) ATTR_NONNULL(1)
bool bool BLI_path_suffix(char *path, size_t path_maxncpy, const char *suffix, const char *sep) ATTR_NONNULL(1
Depsgraph * DEG_graph_new(Main *bmain, Scene *scene, ViewLayer *view_layer, eEvaluationMode mode)
void BKE_mesh_wrapper_ensure_mdata(Mesh *mesh)
bool is_negative_m4(const float mat[4][4])
ViewLayer * CTX_data_view_layer(const bContext *C)
void mul_m4_v3(const float M[4][4], float r[3])
void void void const char * BLI_path_basename(const char *path) ATTR_NONNULL(1) ATTR_WARN_UNUSED_RESULT
bool BLI_path_extension_ensure(char *path, size_t path_maxncpy, const char *ext) ATTR_NONNULL(1
VecBase< int32_t, 3 > int3
BMesh const char void * data
T * DEG_get_evaluated(const Depsgraph *depsgraph, T *id)
@ DEG_ITER_OBJECT_FLAG_LINKED_VIA_SET
@ DEG_ITER_OBJECT_FLAG_VISIBLE
@ DEG_ITER_OBJECT_FLAG_LINKED_DIRECTLY
@ DEG_ITER_OBJECT_FLAG_DUPLI
void BKE_scene_graph_update_tagged(Depsgraph *depsgraph, Main *bmain)
bool mat3_from_axis_conversion(int src_forward, int src_up, int dst_forward, int dst_up, float r_mat[3][3])
void BKE_reportf(ReportList *reports, eReportType type, const char *format,...) ATTR_PRINTF_FORMAT(3
Main * CTX_data_main(const bContext *C)
void unit_m3(float m[3][3])
bool BLI_path_extension_check(const char *path, const char *ext) ATTR_NONNULL(1
Scene * CTX_data_scene(const bContext *C)
bool BLI_path_make_safe_filename(char *filename) ATTR_NONNULL(1)
VecBase< float, 3 > float3
void mul_v3_m3v3(float r[3], const float M[3][3], const float a[3])
void mul_m4_m3m4(float R[4][4], const float A[3][3], const float B[4][4])
eEvaluationMode evaluation_mode
bool export_selected_objects
char collection[MAX_ID_NAME - 2]