31 {GeometryComponent::Type::Curve, GeometryComponent::Type::GreasePencil});
36 "An index used to group curves together. Filling is done separately for each group");
37 b.add_output<
decl::Geometry>(
"Mesh").propagate_all_instance_attributes();
57 for (const int i : range) {
58 faces[i].resize(offsets[i].size());
59 array_utils::fill_index_range<int>(faces[i], offsets[i].start());
72 for (const int i : range) {
73 positions_2d[i] = double2(positions[i].x, positions[i].y);
78 fill_curve_vert_indices(points_by_curve,
faces);
81 input.need_ids =
false;
82 input.vert = std::move(positions_2d);
85 return delaunay_2d_calc(
input, output_type);
97 points_by_curve,
mask, offsets_data);
100 mask.foreach_index(
GrainSize(1024), [&](
const int src_curve,
const int dst_curve) {
101 const IndexRange src_points = points_by_curve[src_curve];
102 const IndexRange dst_points = points_by_curve_masked[dst_curve];
104 const int src = src_points[
i];
105 const int dst = dst_points[
i];
106 positions_2d[dst] =
double2(positions[src].
x, positions[src].
y);
114 input.need_ids =
false;
115 input.vert = std::move(positions_2d);
118 return delaunay_2d_calc(
input, output_type);
128 data_evaluator.
add(group_index_field);
133 return {
do_cdt(curves, output_type)};
139 curve_group_ids, mask_memory, group_indexing);
140 const int groups_num = group_masks.
size();
145 const int domain_size = curve_group_ids.
size();
146 const int avg_group_size = domain_size / groups_num;
147 const int grain_size = std::max(8192 / avg_group_size, 1);
149 for (
const int group_index : range) {
171 Array<int> vert_groups_data(results.size() + 1);
172 Array<int> edge_groups_data(results.size() + 1);
173 Array<int> face_groups_data(results.size() + 1);
174 Array<int> loop_groups_data(results.size() + 1);
176 for (const int i_result : results_range) {
177 const meshintersect::CDT_result<double> &result = results[i_result];
178 vert_groups_data[i_result] = result.vert.size();
179 edge_groups_data[i_result] = result.edge.size();
180 face_groups_data[i_result] = result.face.size();
182 for (const Vector<int> &face : result.face) {
183 loop_len += face.size();
185 loop_groups_data[i_result] = loop_len;
205 for (const int i_result : results_range) {
206 const meshintersect::CDT_result<double> &result = results[i_result];
207 const IndexRange verts_range = vert_groups[i_result];
208 const IndexRange edges_range = edge_groups[i_result];
209 const IndexRange faces_range = face_groups[i_result];
210 const IndexRange loops_range = loop_groups[i_result];
212 MutableSpan<float3> positions = all_positions.slice(verts_range);
213 for (const int i : result.vert.index_range()) {
214 positions[i] = float3(float(result.vert[i].x), float(result.vert[i].y), 0.0f);
217 MutableSpan<int2> edges = all_edges.slice(edges_range);
218 for (const int i : result.edge.index_range()) {
219 edges[i] = int2(result.edge[i].first + verts_range.start(),
220 result.edge[i].second + verts_range.start());
223 MutableSpan<int> face_offsets = all_face_offsets.slice(faces_range);
224 MutableSpan<int> corner_verts = all_corner_verts.slice(loops_range);
225 int i_face_corner = 0;
226 for (const int i_face : result.face.index_range()) {
227 face_offsets[i_face] = i_face_corner + loops_range.start();
228 for (const int i_corner : result.face[i_face].index_range()) {
229 corner_verts[i_face_corner] = result.face[i_face][i_corner] + verts_range.start();
241 mesh->tag_overlapping_none();
258 curves, output_type, group_index);
268 Vector<Mesh *> mesh_by_layer(grease_pencil.layers().size(),
nullptr);
269 for (
const int layer_index : grease_pencil.layers().index_range()) {
270 const Drawing *drawing = grease_pencil.get_eval_drawing(grease_pencil.layer(layer_index));
271 if (drawing ==
nullptr) {
279 src_curves, output_type, group_index);
286 if (instances ==
nullptr) {
288 instances_component.
replace(instances);
319 params.set_output(
"Mesh", std::move(geometry_set));
327 {0,
nullptr, 0,
nullptr,
nullptr},
345 "Generate a mesh on the XY plane with faces on the inside of input curves";
Low-level operations for curves.
Low-level operations for grease pencil.
Mesh * BKE_mesh_new_nomain(int verts_num, int edges_num, int faces_num, int corners_num)
#define NODE_STORAGE_FUNCS(StorageT)
#define NODE_CLASS_GEOMETRY
#define GEO_NODE_FILL_CURVE
@ CDT_CONSTRAINTS_VALID_BMESH_WITH_HOLES
GeometryNodeCurveFillMode
@ GEO_NODE_CURVE_FILL_MODE_TRIANGULATED
@ GEO_NODE_CURVE_FILL_MODE_NGONS
#define NOD_REGISTER_NODE(REGISTER_FUNC)
#define NOD_storage_enum_accessors(member)
BMesh const char void * data
static Vector< IndexMask, 4 > from_group_ids(const VArray< int > &group_ids, IndexMaskMemory &memory, VectorSet< int > &r_index_by_group_id)
constexpr IndexRange index_range() const
constexpr int64_t size() const
constexpr IndexRange index_range() const
OffsetIndices< int > evaluated_points_by_curve() const
Span< float3 > evaluated_positions() const
Instances * get_for_write()
void replace(Instances *instances, GeometryOwnershipType ownership=GeometryOwnershipType::Owned)
const bke::CurvesGeometry & strokes() const
int add(GField field, GVArray *varray_ptr)
const GVArray & get_evaluated(const int field_index) const
void * MEM_callocN(size_t len, const char *str)
ccl_device_inline float2 mask(const MaskType mask, const float2 a)
void node_register_type(bNodeType &ntype)
void mesh_smooth_set(Mesh &mesh, bool use_smooth, bool keep_sharp_edges=false)
void mesh_calc_edges(Mesh &mesh, bool keep_existing_edges, bool select_new_edges)
void node_type_storage(bNodeType &ntype, std::optional< StringRefNull > storagename, void(*freefunc)(bNode *node), void(*copyfunc)(bNodeTree *dest_ntree, bNode *dest_node, const bNode *src_node))
static void node_init(bNodeTree *, bNode *node)
static void node_register()
static void node_geo_exec(GeoNodeExecParams params)
static void node_rna(StructRNA *srna)
static void node_declare(NodeDeclarationBuilder &b)
static Array< meshintersect::CDT_result< double > > do_group_aware_cdt(const bke::CurvesGeometry &curves, const CDT_output_type output_type, const Field< int > &group_index_field)
static void curve_fill_calculate(GeometrySet &geometry_set, const GeometryNodeCurveFillMode mode, const Field< int > &group_index)
static void fill_curve_vert_indices(const OffsetIndices< int > offsets, MutableSpan< Vector< int > > faces)
static meshintersect::CDT_result< double > do_cdt_with_mask(const bke::CurvesGeometry &curves, const CDT_output_type output_type, const IndexMask &mask)
static Mesh * cdts_to_mesh(const Span< meshintersect::CDT_result< double > > results)
static void node_layout(uiLayout *layout, bContext *, PointerRNA *ptr)
static meshintersect::CDT_result< double > do_cdt(const bke::CurvesGeometry &curves, const CDT_output_type output_type)
PropertyRNA * RNA_def_node_enum(StructRNA *srna, const char *identifier, const char *ui_name, const char *ui_description, const EnumPropertyItem *static_items, const EnumRNAAccessors accessors, std::optional< int > default_value, const EnumPropertyItemFunc item_func, const bool allow_animation)
OffsetIndices< int > accumulate_counts_to_offsets(MutableSpan< int > counts_to_offsets, int start_offset=0)
OffsetIndices< int > gather_selected_offsets(OffsetIndices< int > src_offsets, const IndexMask &selection, int start_offset, MutableSpan< int > dst_offsets)
void parallel_for(const IndexRange range, const int64_t grain_size, const Function &function, const TaskSizeHints &size_hints=detail::TaskSizeHints_Static(1))
VecBase< double, 2 > double2
void geo_node_type_base(blender::bke::bNodeType *ntype, std::string idname, const std::optional< int16_t > legacy_type)
void node_free_standard_storage(bNode *node)
void node_copy_standard_storage(bNodeTree *, bNode *dest_node, const bNode *src_node)
static GeometrySet from_mesh(Mesh *mesh, GeometryOwnershipType ownership=GeometryOwnershipType::Owned)
static MatBase identity()
GeometryComponent & get_component_for_write(GeometryComponent::Type component_type)
const GreasePencil * get_grease_pencil() const
const Curves * get_curves() const
bool has_grease_pencil() const
void replace_curves(Curves *curves, GeometryOwnershipType ownership=GeometryOwnershipType::Owned)
void modify_geometry_sets(ForeachSubGeometryCallback callback)
void replace_mesh(Mesh *mesh, GeometryOwnershipType ownership=GeometryOwnershipType::Owned)
void replace_grease_pencil(GreasePencil *grease_pencil, GeometryOwnershipType ownership=GeometryOwnershipType::Owned)
std::string ui_description
void(* initfunc)(bNodeTree *ntree, bNode *node)
NodeGeometryExecFunction geometry_node_execute
const char * enum_name_legacy
void(* draw_buttons)(uiLayout *, bContext *C, PointerRNA *ptr)
NodeDeclareFunction declare
void prop(PointerRNA *ptr, PropertyRNA *prop, int index, int value, eUI_Item_Flag flag, std::optional< blender::StringRef > name_opt, int icon, std::optional< blender::StringRef > placeholder=std::nullopt)