POV-Ray : Newsgroups : povray.general : fillets and rounded corners : Re: fillets and rounded corners Server Time
15 May 2024 10:24:33 EDT (-0400)
  Re: fillets and rounded corners  
From: lelama
Date: 8 Sep 2016 12:10:01
Message: <web.57d1851dc06f3de321263ef70@news.povray.org>
scott <sco### [at] scottcom> wrote:
>
>
> You'll need much more than the "impact curve" in order to build the
> mesh. [...]
>
> Also what happens when the sharp edge / impact curve that is needed to
> create the round is not visible in the image (because it's obscured by
> another part of the shape or just pointing away from the camera)?
> Attached example.




If some part is not visible, we don't care: The proposed algorithm starts from
the 2D image.

Let me give with some details the algorithm which computes the mesh of the
rounded corner for clarity.


Let us represent the pixels on the 2D image as squares on a chess board. Let us
call segment the piece of line which is at the interface of two adjacent squares
on the board. For each square s on the board, by the hypothesis, we have the
following parametrized data: an impact point p(s) in the 3D space, an object
o(s) which contains the impact point p(s), the normal n(s) at the impact point.
(Recall that I supposed that for each pixel in the rendering,  the impact
surface and the corresponding normal was accessible).


An sharpEdge is a segment such that the two adajacent squares s1,s2 on each side
verify:
- there are on two different surfaces o(s1)!=o(s2) and the user asked to smooth
the intersection of these two surfaces
- the distance between the two corresponding points p(s1) p(s2) in the 3d space
is small enough ( small depends on the user input parameters).

2 sharpEdges are called connected if
- they are connected on the chess board, ie they have in common the corner of a
square
- the two segments have the same objects on each side

( If unclear, The last condition may be described precisely as follows
- if the two edges form a right angle, the three squares s1,s2,s3 on the
exterior of the curve have the same object o(s1)=o(s2)=o(s3)
- it the two edges are along a line, and if s1 s2 are two squares adjacent to
the edges and on the same side of the edges, then o(s1)=o(s2)

If we put a set of connected edges together, we get a connected component of
sharpEdges. This is a ray that we see on the 2D image where we want to smooth.
After a moment of thouhgt, we see that a connected component is a set of
sharpEdges which is not a general tree, but a simple branch.  For instance, in
the example you propose, there are 3 connected components of straight edges :
one component for each pair of surface.

Thus now, we have a well defined branch, with 2 sides, which I call left and
right for simplicity, and we want to produce a mesh around this branch.
There is an object o(l) on the left of the branch and an object o(r) on the
right. By construction, all the squares adjacent to the left side
parametrize ray whose impact is in o(l) and same thing for the right.


Now, we delimit the zone around the branch that we shall smooth out. We
construct a set S(l) containing squares on the left side. The squares s in S(l):
- are connected to the left side of the branch
- are  sufficiently closed to the curve: ie there is s' adjacent to the curve
with p(s)-p(s') small enough
- have impact in the required surface ie o(s)=o(l)

The boundary of S(l) is a union of segments which is closed curve: this is a
deformed circles. More
precisely, it is a union of 2 pieces: the sharp edges that we are
trying to smooth out, and a residual piece which I call the left boundary
B(l).

Similarly, there is a right boundary B(r). THe union of B(l) and B(r) is a
closed curve around the connected component that I call the total boundary B.

The boundary B is a union of segments, and it is a deformed circle. We want to
smooth the zone corresponding to the squares inside B,

If a square s is in the circonference of the deformed circle, ie if it
adjacent to some segment in B, we keep unchanged the
information p(s),n(s),o(s) we started from.

For the other squares, which are inside the circle but not on the
circumferentce, we use an algorithm to interpolate the values
p(s),n(s),o(s) (basically by averaging while keeping the circumference
unchanged)

Once we have computed the values p(s),n(s),o(s) for s in B, this is easy to
produce the mesh.

Laurent.


Post a reply to this message

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.