Author Topic: Pedit algorithm  (Read 1492 times)

0 Members and 1 Guest are viewing this topic.

hellios8502

  • Guest
Pedit algorithm
« on: October 08, 2011, 06:33:02 PM »
Hi
I am trying to develop a routine that creates countour lines from triangles. So far i had no problems creating the contours, but my algorithm produces only polylines with 2 vertecies(from the intersection of each triangle with the corresponding plane). Now that I have all  the polylines from the intersections I want to programmatically connect them in a single polyline but this has came to be not so easy task :lol:

So I am wondering if someone has an idea how the pedit command works.

Any help would be greatly appreciated.

zoltan

  • Guest
Re: Pedit algorithm
« Reply #1 on: October 09, 2011, 10:51:49 AM »
I guess it would just be a tedious loop.

1. Put all of the segments in a list.
2. Take one segment out of the list and put in into a new polyline.
3. Compare the end points of every segment in the list to the ends of the polyline.
4. If you have a match, add the segment to the polyline and take it out of the list. Go to step 3.
5. If you cannot find a match, go to step 2.
6. Do this until the list is empty.

This is assuming that all of the end points of the segments connect to either zero or one other end point.  Since you are making contours, I guess this would be the case.   I'm sure there are smarter and faster ways of doing this so you don't have to iterate through the list so many times.  There might even be something sneaky you can do with Linq to group all of the segments that share end points.

hellios8502

  • Guest
Re: Pedit algorithm
« Reply #2 on: October 09, 2011, 02:34:16 PM »
I was considering the same aproach but the number of polyline segments can easely reach 150 000-200 000, which will lead to considerable amount of time for processing. I think i'll give it a try and see the result :-).

gile

  • Gator
  • Posts: 2520
  • Marseille, France
Re: Pedit algorithm
« Reply #3 on: October 09, 2011, 04:30:15 PM »
Hi,

Look at the PolylineSegemntCollection.Join() method in the GeometryExtensions assembly
Speaking English as a French Frog

hellios8502

  • Guest
Re: Pedit algorithm
« Reply #4 on: October 10, 2011, 11:02:28 AM »
Thanks gile. This routine worked excelent in my case, you are a live saver :-).
 Thanks again.