kicad-developers team mailing list archive
-
kicad-developers team
-
Mailing list archive
-
Message #26853
Re: CPolyLine refactor
Le 28/11/2016 à 15:37, Tomasz Wlostowski a écrit :
> On 23.11.2016 15:02, jp charras wrote:
>> Le 23/11/2016 à 13:32, Alejandro Garcia Montoro a écrit :
>>> Hi!
>>>
>>> Thanks for the tips :)
>>>
>>> I have some more doubts, one of them quite important: we have a class for storing a set of polygons
>>> with holes, SHAPE_POLY_SET, but there is no explicit class to store a single polygon with holes.
>>> There's a POLYGON typedef that could do the trick, but I think it would be a better design if we
>>> created a SHAPE_POLYGON class that contained the methods from SHAPE_POLY_SET (basically the
>>> iterator, the management of holes and vertices and the overrided from SHAPE) and SHAPE_POLY_SET
>>> would be just a wrapper over SHAPE_POLYGON, basically a vector of them with a couple of the methods
>>> that are now implemented (probably the ones from the Clipper library). Furthermore, the
>>> SHAPE_POLY_SET::ITERATOR class should be also refactored and completed, as for now it just iterates
>>> through the vertices of the outlines of the polygons, not through the vertices of its holes.
>>>
>>> I think I could send a patch soon with these changes, before going ahead with the work I'm doing for
>>> the CPolyLine refactor (which is somewhat deeper than I though on the first time), as I see a better
>>> correspondence between CPolyLine and SHAPE_POLYGON than between the former and SHAPE_POLY_SET.
>>>
>>> However, I still need a second opinion on this, I don't know if I'm misunderstanding something.
>>>
>>> Best,
>>> Alejandro
>>
>> I think extracting POLYGON class from SHAPE_POLY_SET to make it a full separate class is a good idea.
>> Perhaps you could call it SHAPE_POLYGON_WITH_HOLE, to be more explicit and avoid mistakes with a
>> simple usual polygon.
>>
>
> Hi JP & Alejandro,
>
> I'm hesitant to agree with this idea:
> - We risk proliferating more polygon classes this way. Pcbnew operates
> almost exclusively on polygon sets. I can't think of a single case where
> a special case for a single polygon with holes would be beneficial. For
> storing polygon outlines, a SHAPE_LINE_CHAIN should be sufficient.
In fact this class exists, more or less in SHAPE_POLY_SET.
A SHAPE_LINE_CHAIN is perfect as long we want to store a polygon without holes.
Because we are talking about CPolyLine refactoring, this is not an option.
It is good to handle DRAWSEGMENTs of polygon type (which are expected to be simple polygons).
> - It's not possible to predict the result of boolean polygon operations
> compile-time, they return one or more polygons, each of them
> with/without holes.
Yes, this is true.
Therefore, having specialized classes for each of
> these cases would make handling them unnecessarily complex (RTTI).
> - I would rather improve the iterators in the current SHAPE_POLY_SET
> class so that it's easy to access all vertices of each outline/hole.
This is also an option.
Because we need mainly a class to store a polygon with holes (to replace CPolyLine) improving
iterators and functions, especially to handle the first outline with holes can be an option.
>
> Cheers,
> Tom
>
--
Jean-Pierre CHARRAS
Follow ups
References