Subscribe to this thread
Home - General / All posts - InsertGeom
rotten_apple21 post(s)
#16-Jan-17 04:08

Good Day!

I'm trying to insert a new area from selected areas in a drawing . In the attached script, I add all the points of the selected areas to the "newPointSet" variable and create a new Geom. The current output is far from the desired output. What do I need to do?

Attachments:
Current output.png
Desired output.png
input.png
InsertGeom.txt

tjhb

7,387 post(s)
#17-Jan-17 01:39

Add the branches and the points in index order.

For Each doesn't ensure any particular order, so use an indexed For for these cases.

Dim newGeom, newPointSet

Dim geom, branch, point

Dim i, j

...

For Each geom in geomSet

    For i = 0 To geom.BranchSet.Count - 1

        Set branch = geom.BranchSet.Item(i)

        For j = 0 To branch.PointSet.Count - 1

            Set point = branch.PointSet.Item(j)

            newPointSet.Add(point)

        Next ' j

    Next ' i

Next ' geom

...

It's fine to use For Each for the geoms, since there order doesn't matter (unless it does!).

rotten_apple21 post(s)
#18-Jan-17 05:09

Many thanks. I tried the code above but I'm getting the same result

mechalas

839 post(s)
#19-Jan-17 02:05

I think you are expecting too much of Manifold here. You are taking the points from each branch and combining them into one branch, but you are expecting Manifold to understand that what you intend is to generate a perimeter from these points by joining the shapes. Manifold is doing exactly what you ask: it is creating an area with one branch of points. It creates the first set of 5 points, then it crosses over to the other area and creates the next set of points, and then it crosses back to close the geometry.

Your algorithm will only work (i.e., do what you intend) on very simple geometries where your points also happen to be arranged in order around the perimeter of the new area to be formed. In the more common, general case it will not work. For complex geometries, it will never work.

What is it that you are trying to do? Fill in the empty space between two areas? I am not even sure how you would describe this problem algorithmically.

Sloots

408 post(s)
#19-Jan-17 12:27

How about select the two elements, and then use the transform toolbar to create a convex hull.

Don't know if that works for all your shapes of course...


http://www.mppng.nl/manifold/pointlabeler

rotten_apple21 post(s)
#06-Feb-17 05:22

sorry for the late reply. convex hull works works for me.

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