29 {0,
nullptr, 0,
nullptr,
nullptr},
38 N_(
"Alternate inside/outside based on crossing count")},
43 N_(
"Overlapping curves with the same winding direction are filled as a union")},
44 {0,
nullptr, 0,
nullptr,
nullptr},
52 "Curves to fill. All curves are treated as cyclic and projected to the XY plane");
54 .evaluated_geometry_field()
57 "An index used to group curves together. Filling is done separately for each group");
66 .description(
"Rule used to determine which regions are inside or outside");
73 node->storage = MEM_new<NodeGeometryCurveFill>(__func__);
80 for (const int i : range) {
81 array_utils::fill_index_range<int>(face_vert_indices.slice(offsets[i]), offsets[i].start());
94 for (const int i : range) {
95 positions_2d[i] = double2(positions[i].x, positions[i].y);
99 Array<int> face_vert_indices(positions.size());
100 fill_curve_vert_indices(points_by_curve, face_vert_indices);
103 input.
vert = positions_2d;
107 return delaunay_2d_calc(input, output_type);
119 points_by_curve,
mask, offsets_data);
123 [&](
const int src_curve,
const int dst_curve) {
124 const IndexRange src_points = points_by_curve[src_curve];
125 const IndexRange dst_points = points_by_curve_masked[dst_curve];
127 const int src = src_points[i];
128 const int dst = dst_points[i];
129 positions_2d[dst] =
double2(positions[src].
x, positions[src].
y);
138 input.
vert = positions_2d;
143 return delaunay_2d_calc(input, output_type);
153 data_evaluator.
add(group_index_field);
163 const int groups_num = group_masks.
size();
168 const int domain_size = curve_group_ids.
size();
169 const int avg_group_size = domain_size / groups_num;
170 const int grain_size = std::max(8192 / avg_group_size, 1);
172 for (
const int group_index : range) {
194 Array<int> vert_groups_data(results.size() + 1);
195 Array<int> edge_groups_data(results.size() + 1);
196 Array<int> face_groups_data(results.size() + 1);
197 Array<int> loop_groups_data(results.size() + 1);
199 for (const int i_result : results_range) {
200 const meshintersect::CDT_result<double> &result = results[i_result];
201 vert_groups_data[i_result] = result.vert.size();
202 edge_groups_data[i_result] = result.edge.size();
203 face_groups_data[i_result] = result.face.size();
205 for (const Vector<int> &face : result.face) {
206 loop_len += face.size();
208 loop_groups_data[i_result] = loop_len;
228 for (const int i_result : results_range) {
229 const meshintersect::CDT_result<double> &result = results[i_result];
230 const IndexRange verts_range = vert_groups[i_result];
231 const IndexRange edges_range = edge_groups[i_result];
232 const IndexRange faces_range = face_groups[i_result];
233 const IndexRange loops_range = loop_groups[i_result];
235 MutableSpan<float3> positions = all_positions.slice(verts_range);
236 for (const int i : result.vert.index_range()) {
237 positions[i] = float3(float(result.vert[i].x), float(result.vert[i].y), 0.0f);
240 MutableSpan<int2> edges = all_edges.slice(edges_range);
241 for (const int i : result.edge.index_range()) {
242 edges[i] = result.edge[i] + int(verts_range.start());
245 MutableSpan<int> face_offsets = all_face_offsets.slice(faces_range);
246 MutableSpan<int> corner_verts = all_corner_verts.slice(loops_range);
247 int i_face_corner = 0;
248 for (const int i_face : result.face.index_range()) {
249 face_offsets[i_face] = i_face_corner + loops_range.start();
250 for (const int i_corner : result.face[i_face].index_range()) {
251 corner_verts[i_face_corner] = result.face[i_face][i_corner] + verts_range.start();
263 mesh->tag_overlapping_none();
305 if (
curves.curves_num() > 0) {
307 curves, output_type, group_index);
318 for (
const int layer_index :
grease_pencil.layers().index_range()) {
320 if (drawing ==
nullptr) {
328 src_curves, output_type, group_index);
332 auto instances = std::make_unique<bke::Instances>(mesh_by_layer.
size());
370 params.
set_output(
"Mesh"_ustr, std::move(geometry_set));
379 "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.
#define NODE_STORAGE_FUNCS(StorageT)
#define NODE_CLASS_GEOMETRY
#define GEO_NODE_FILL_CURVE
#define NOD_REGISTER_NODE(REGISTER_FUNC)
static Vector< IndexMask, 4 > from_group_ids(const VArray< int > &group_ids, LinearAllocator<> &memory)
constexpr IndexRange index_range() const
constexpr void fill(const T &value) const
constexpr int64_t size() const
constexpr IndexRange index_range() const
IndexRange index_range() const
const bke::CurvesGeometry & strokes() const
int add(GField field, GVArray *varray_ptr)
const GVArray & get_evaluated(const int field_index) const
T extract_input(const UString identifier)
void set_output(const UString identifier, T &&value)
IndexRange index_range() const
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))
constexpr ParallelGrainSize grain_size(int grain_size)
bke::GeometrySet join_geometries(Span< bke::GeometrySet > geometries, const bke::AttributeFilter &attribute_filter, const std::optional< Span< bke::GeometryComponent::Type > > &component_types_to_join=std::nullopt, bool allow_merging_instance_references=true)
void foreach_real_geometry(bke::GeometrySet &geometry, FunctionRef< void(bke::GeometrySet &geometry_set)> fn)
static void node_init(bNodeTree *, bNode *node)
static void fill_curve_vert_indices(const OffsetIndices< int > offsets, MutableSpan< int > face_vert_indices)
static void node_register()
static void node_geo_exec(GeoNodeExecParams params)
static void node_declare(NodeDeclarationBuilder &b)
static const EnumPropertyItem mode_items[]
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 meshintersect::CDT_result< double > do_cdt_with_mask(const bke::CurvesGeometry &curves, const CDT_output_type output_type, const IndexMask &mask)
static void curve_fill_calculate(GeometrySet &geometry_set, const GeometryNodeCurveFillMode mode, const GeometryNodeCurveFillRule fill_rule, const Field< int > &group_index)
static Mesh * cdts_to_mesh(const Span< meshintersect::CDT_result< double > > results)
static const EnumPropertyItem fill_rule_items[]
static meshintersect::CDT_result< double > do_cdt(const bke::CurvesGeometry &curves, const CDT_output_type output_type)
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))
GeometryNodeCurveFillRule
@ GEO_NODE_CURVE_FILL_RULE_EVEN_ODD
@ GEO_NODE_CURVE_FILL_RULE_NON_ZERO
@ CDT_CONSTRAINTS_VALID_BMESH_WITH_HOLES_NONZERO
@ CDT_INSIDE_WITH_HOLES_NONZERO
@ CDT_CONSTRAINTS_VALID_BMESH_WITH_HOLES
VecBase< double, 2 > double2
GeometryNodeCurveFillMode
@ GEO_NODE_CURVE_FILL_MODE_TRIANGULATED
@ GEO_NODE_CURVE_FILL_MODE_NGONS
Mesh * BKE_mesh_new_nomain(int verts_num, int edges_num, int faces_num, int corners_num)
void node_copy_standard_storage(bNodeTree *, bNode *dest_node, const bNode *src_node)
void node_free_standard_storage(bNode *node)
void geo_node_type_base(bke::bNodeType *ntype, UString idname, const std::optional< int16_t > legacy_type)
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 replace_mesh(Mesh *mesh, GeometryOwnershipType ownership=GeometryOwnershipType::Owned)
void replace_grease_pencil(GreasePencil *grease_pencil, GeometryOwnershipType ownership=GeometryOwnershipType::Owned)
std::string ui_description
NodeGeometryExecFunction geometry_node_execute
void(*) initfunc(bNodeTree *ntree, bNode *node)
const char * enum_name_legacy
NodeDeclareFunction declare
static GeometrySet from_mesh(Mesh *mesh, GeometryOwnershipType ownership=GeometryOwnershipType::Owned)
static GeometrySet from_instances(std::unique_ptr< Instances > instances)