Subscribe to this thread
Home - General / All posts - Bending lines
rk
335 post(s)
#29-Sep-19 20:19

Here is a little Manifold 9 addin dll that provides 2 functions.

GeomUpdateCoord(@geom GEOM, @index INT32, @newCoord FLOAT64x2) for changing 1 coord

and

GeomAdjustCoord(@geom GEOM, @index INT32, @newCoord FLOAT64x2) for changing 1 coord and its neighbours - "bending" geoms.

I used the latter for merging two datasets.

Unzip and place under ~\Shared\ folder.

Running it from Tools -> Addins creates a sample query.

Attachments:
after.png
before.png
DisplaceGeom.zip

adamw


8,696 post(s)
online
#02-Oct-19 12:52

This is beautiful!

A couple of notes:

If I am reading the code correctly, GeomAdjustCoord does not adjust the first or last coordinate of the line. If so, this only handles lines with a single branch - to handle lines with multiple branches, the check has to be extended.

Creating an example query in Main to show how the functions are used is great! I think it could be made even better though by (a) moving the text into the TXT file near the add-in, and (b) rewriting Main to just figure out the path to that TXT file and run it (which will launch Notepad by default). This will separate the documentation from the code and avoid creating extra components.

You can get the path to the addin DLL using reflection: new System.Uri( System.Reflection.Assembly.GetExecutingAssembly().CodeBase ).LocalPath should do it. Then change the extension from DLL to TXT and you are done. To run the TXT file, use System.Diagnostic.Process.Start().

On our side, maybe it would make sense to extend the query engine with an easy way to get all functions declared in a DLL / source file using something like FUNCTION LIBRARY 'DisplaceGeom.dll'. We can figure out the arguments automatically using reflection.

rk
335 post(s)
#03-Oct-19 20:35

Thanks!

Good suggestions.

GeomAdjustCoord preserves branches and adjusts all coords "near enough" to the target coord. It doesn't adjust the first coord of first branch and the last coord of last branch (unless they happen to be the target) of *lines* only. Sometimes we may want to adjust only certain branch and not affect other(s), yes.

Manifold User Community Use Agreement Copyright (C) 2007-2017 Manifold Software Limited. All rights reserved.