Click here to Skip to main content
15,902,492 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I know this is really not the place for this but since this site has been “good”
to me in the past I thought I’d start here. I’m looking for a “common line removal”
algorithm. I have objects similar to a puzzle where each piece is a different color
and possibly shares an edge segment(s) with the surrounding pieces.

What I would like to do is where the edges share a common boundary segment
(within a tolerance) make each piece’s bounding segment the same. I’ve searched
but I have not found anything worthwhile. Any ideas?

TIA
Posted

Is this "invisible line removal"? I always though this problem is artificial and should not be solved in most cases. The problem can be difficult, not always solvable (for example, due to the problems of the shared line segment and its affect of pixel-size vicinity of the shared area); at the same time, the benefits of the solution can be miserable when compared with the effort.

(Also, remember, there are no lines in real life, they are all imaginary. In photo-realistic quality of rendering there no lines, too. So, if you show lines in your simplified picture, they are symbolic reflection of ideal mathematical object, not the realistic rendering model, so you may want not too take likes too seriously. You merely need a clear recognizable picture.)

Here is the idea. If the line is invisible, this is because it is masked by the object which is closer to the spectator. In 2D case, you need to keep Z-order to draw objects closer to the spectator on top of the others. In 3D case it's a bit more complex, but essentially, this is the same is Z-order; you need to order objects according to the position of the "camera". I did it in 3D and had no problems with performance, by the way. In other words: you have to draw all or some of the "invisible" lines; the objects placed on top of those line will cover them.

The only problem is performance, but it is not significant in most cases; you may loose more CPU time by trying to find a more complex solution. Anyway, even if you want to prevent excessive rendering (yes, my solution is based on excessive rendering), you should consider the problem of "invisible lines" as optimization one, not rendering.

To prevent flicker you need to use double-buffering; to improve performance, you need partial invalidation (with Windows GDI, InvalidateRect or InvalidateRgn).

—SA
 
Share this answer
 
v3
You can create polygon buffer zones for all the segments in one polyline. Then traverse the segments in the other polyline, and see if they are inside the buffers. This is a common problem in geographical information systems, and there is probably open source code for this somwhere.

Good luck
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900