57 std::optional<float> width,
58 std::optional<float> miter_limit_angle);
73 const int frame_number = scene.
r.
cfra;
89 const int orig_frame = scene.
r.
cfra;
90 for (
int frame_number = scene.
r.
sfra; frame_number <= scene.
r.
efra; frame_number++) {
101 scene.
r.
cfra = frame_number;
112 scene.
r.
cfra = orig_frame;
131 const Object *ob = info.object;
136 const GreasePencil *grease_pencil_eval = id_cast<const GreasePencil *>(ob_eval->
data);
139 if (!
layer->is_visible()) {
142 const Drawing *drawing = grease_pencil_eval->get_drawing_at(*
layer, frame_number);
143 if (drawing ==
nullptr) {
148 if (
curves.has_curve_with_type(
149 {CURVE_TYPE_CATMULL_ROM, CURVE_TYPE_BEZIER, CURVE_TYPE_NURBS}))
153 .complement(
curves.curves_range(), memory);
173 const float4x4 layer_to_world =
layer.to_world_space(
object);
176 const std::optional<Span<float3>> ,
177 const std::optional<Span<float3>> ,
184 const std::optional<float> width,
185 const std::optional<float> miter_limit_angle,
205 auto hpdf_error_handler = [](HPDF_STATUS error_no, HPDF_STATUS detail_no,
void * ) {
206 printf(
"ERROR: error_no=%04X, detail_no=%u\n", (HPDF_UINT)error_no, (HPDF_UINT)detail_no);
209 pdf_ = HPDF_New(hpdf_error_handler,
nullptr);
211 std::cout <<
"error: cannot create PdfDoc object\n";
224 std::cout <<
"error: cannot create PdfPage\n";
236 HPDF_Page_Concat(
page_, scale_factor.x, 0.0f, 0.0f, scale_factor.y, 0.0f, 0.0f);
258 std::optional<float> width,
259 std::optional<float> miter_limit_angle)
261 if (miter_limit_angle) {
263 HPDF_Page_SetLineJoin(
page_, HPDF_ROUND_JOIN);
266 HPDF_Page_SetLineJoin(
page_, HPDF_BEVEL_JOIN);
270 const float miter_limit = 1.0f /
math::sin(*miter_limit_angle / 2.0f);
272 HPDF_Page_SetLineJoin(
page_, HPDF_MITER_JOIN);
273 HPDF_Page_SetMiterLimit(
page_, miter_limit);
278 HPDF_Page_SetLineWidth(
page_, std::max(*width, 1.0f));
281 const float total_opacity =
color.a * opacity;
283 HPDF_Page_GSave(
page_);
284 HPDF_ExtGState gstate = (total_opacity < 1.0f) ? HPDF_CreateExtGState(
pdf_) :
nullptr;
289 HPDF_Page_SetRGBFill(
page_, srgb.
r, srgb.
g, srgb.
b);
290 HPDF_Page_SetRGBStroke(
page_, srgb.
r, srgb.
g, srgb.
b);
292 HPDF_ExtGState_SetAlphaFill(gstate, std::clamp(total_opacity, 0.0f, 1.0f));
293 HPDF_ExtGState_SetAlphaStroke(gstate, std::clamp(total_opacity, 0.0f, 1.0f));
297 HPDF_Page_SetRGBFill(
page_, srgb.
r, srgb.
g, srgb.
b);
299 HPDF_ExtGState_SetAlphaFill(gstate, std::clamp(total_opacity, 0.0f, 1.0f));
303 HPDF_Page_SetExtGState(
page_, gstate);
306 for (
const int curve_i : shape) {
307 const IndexRange points = points_by_curve[curve_i];
313 HPDF_Page_MoveTo(
page_, screen_co.x, screen_co.y);
316 HPDF_Page_LineTo(
page_, screen_co.x, screen_co.y);
319 if (cyclic[curve_i]) {
320 HPDF_Page_ClosePath(
page_);
325 HPDF_Page_Stroke(
page_);
328 HPDF_Page_Fill(
page_);
331 HPDF_Page_GRestore(
page_);
342 std::wstring wstr(filepath_16);
Low-level operations for curves.
Low-level operations for grease pencil.
#define GP_STROKE_MITER_ANGLE_BEVEL
#define GP_STROKE_MITER_ANGLE_ROUND
constexpr Span slice(int64_t start, int64_t size) const
constexpr IndexRange index_range() const
constexpr const char * c_str() const
bke::CurvesGeometry & strokes_for_write()
const bke::CurvesGeometry & strokes() const
void tag_topology_changed()
GreasePencilExporter(const IOContext &context, const ExportParams ¶ms)
void foreach_shape_in_layer(const Object &object, const bke::greasepencil::Layer &layer, const bke::greasepencil::Drawing &drawing, WriteShapeFn shape_fn)
Bounds< float2 > camera_rect_
std::optional< float4x4 > camera_persmat_
const ExportParams params_
void prepare_render_params(Scene &scene, int frame_number)
Vector< ObjectInfo > retrieve_objects() const
bool is_selected_frame(const GreasePencil &grease_pencil, int frame_number) const
Bounds< float2 > screen_rect_
float2 project_to_screen(const float4x4 &transform, const float3 &position) const
GreasePencilExporter(const IOContext &context, const ExportParams ¶ms)
bool add_page(Scene &scene)
void export_grease_pencil_objects(int frame_number)
void write_path(const float4x4 &transform, Span< float3 > positions, const OffsetIndices< int > points_by_curve, const Span< int > shape, const VArray< bool > &cyclic, const VArray< int8_t > &types, const ColorGeometry4f &color, const float opacity, std::optional< float > width, std::optional< float > miter_limit_angle)
void export_grease_pencil_layer(const Object &object, const bke::greasepencil::Layer &layer, const bke::greasepencil::Drawing &drawing)
bool export_scene(Scene &scene, StringRefNull filepath)
bool write_to_file(StringRefNull filepath)
void free(Subdiv *subdiv)
CurvesGeometry resample_to_evaluated(const CurvesGeometry &src_curves, const IndexMask &selection, const ResampleCurvesOutputAttributeIDs &output_ids={})
constexpr double default_pdf_ppi
bool export_pdf(const IOContext &context, const ExportParams ¶ms, Scene &scene, StringRefNull filepath)
constexpr double meter_to_inches_factor
T sin(const AngleRadianBase< T > &a)
BLI_assert(slot->slot_subtype.map==BMO_OP_SLOT_SUBTYPE_MAP_FLT)
void BKE_scene_graph_update_for_newframe(Depsgraph *depsgraph)
void linearrgb_to_srgb_v3_v3(float srgb[3], const float linear[3])
VecBase< double, 2 > double2
MatBase< float, 4, 4 > float4x4
void BKE_scene_ppm_get(const RenderData *rd, double r_ppm[2])
VecBase< float, 2 > float2
T * DEG_get_evaluated(const Depsgraph *depsgraph, T *id)
bool BKE_scene_camera_switch_update(Scene *scene)
ColorSceneLinear4f< eAlpha::Premultiplied > ColorGeometry4f
wchar_t * alloc_utf16_from_8(const char *in8, size_t add)