Here’s a start point on that matter. Your approach for dividing is completely abandoned for obvious reasons. A mesh approach is used instead where the color part is not yet implemented (that’s rather easy) since 90% of this C# stuff attached was already on hand and I haven’t found time to add the final cut of the mustard.
If we forget the Elapsed time required for the curves VS the boundary part … the big issue here is to use a Method that yields the min possible Elapsed time with regard the mesh creation (coloring is real-time so forget that part). So … patch is out of question (and Ball Pivot is internal): meaning a flat (filtered in boundary) Delauney is used and then another Method does the final elevated mesh (see comments on that below).
Terrain_Slope_V1.3dm (490.7 KB)
Terrain_Slope_V1A.gh (18.2 MB)
That said storing your data (18Mb) in the GH file is VERY RISKY and I would strongly recommend to reference them (Curves) from some R file and used some Excel (Elevations).
That said 280 milliseconds for the mesh (on a slow I5 that is always used for testing performance matters) is not that fast … but 95% of the time is consumed for mapping MTV vertices back to the division points (using a Point3dList) and thus to Z values. Using a proper I9 or a Ryzen time drops to 100 milliseconds max. This is the guilty line:
Division points are proportional to the min length curve (use skip and watch the sorted lengths values to have an idea of what you are doing/using).
Testing random parcels … rises the need for some intelligence with regard the min curve length (a best pick ability, that is) and/or a better point selection policy for the Delauney by interpolating points to the ones derived from the curve divisions (I’ll add all that in the next update):
More (the final slope/color part) soon: clustering the mesh faces in predefined intervals according the mesh faces normal angle to the global Z.
Update:
Found some minutes for the clustering thing (it’s very simple in fact: you define Intervals according a min/max angle and a partition var [the resolution] and after 10-20 milliseconds the old I5 does the job):
Terrain_Slope_V1B.gh (18.2 MB)
Note: If some faces are not sampled it means that their normal, Z angle is > than the maxAngle. The normal is checked (DotProduct) against the Z so no worries about the mesh orientation.
Note: no elaborated checks are included with regard the data: avoid feeding the thing with bananas.
Note: Filtering Delauney faces inside the boundary is a bit primitive (testing for inclusion of the face center). Done that way for speed. Some times results like this captured occur … but the other way (ccx on topo edges) is quite expensive (but why bother? that’s the 1M question).