Is there a way to find child, parent closed polylines?

Discussion forum for C++ and script developers who are using the QCAD development platform or who are looking to contribute to QCAD (translations, documentation, etc).

Moderator: andrew

Forum rules

Always indicate your operating system and QCAD version.

Attach drawing files, scripts and screenshots.

Post one question per topic.

Post Reply
ilyasozkurt
Newbie Member
Posts: 9
Joined: Sat Nov 19, 2022 3:20 pm

Is there a way to find child, parent closed polylines?

Post by ilyasozkurt » Sat Nov 19, 2022 11:57 pm

Hello there,

The question is at the title. Is there a way you guys know?

Thank you so much.

CVH
Premier Member
Posts: 3416
Joined: Wed Sep 27, 2017 4:17 pm

Re: Is there a way to find child, parent closed polylines?

Post by CVH » Sun Nov 20, 2022 9:12 am

ilyasozkurt wrote:
Sat Nov 19, 2022 11:57 pm
Is there a way to find child, parent closed polylines?
There is no such thing as parent or child Polylines or any other relation between entities.

I think that you mean a closed Polyline that is fully inside another closed Polyline.
Or better, the enclosed area of one is fully inside the other enclosed area.

That is surely a tough one because a Polyline is merely some line art.
QCAD is all about line art and doesn't work with surfaces.

The solution may sit in the purpose.
Let's assume that you need the area of the larger minus the areas of the smaller ones.
In that case the differential hatched area of a Hatch may be a solution.

There are two ways to do that.
The Centroid resource .getHatchedAreaCentroid(entity)
https://github.com/qcad/qcad/blob/maste ... entroid.js
Or
The recent added Hatch property resource RHatchData.getArea()
https://github.com/qcad/qcad/blob/ca30e ... chData.cpp

First you need to create an RHatchData with the boundaries shapes in question.
https://qcad.org/doc/qcad/3.0/developer ... _data.html

Some words of caution:
- Boundaries or resulting Polylines should not intersect.
This is not checked.
- A Boundary / Polyline should not self-intersect.
There is no good resource to check this. Included for Centroids based on no false positives.
- Boundaries / Polylines should be perfectly closed at every node.
- Boundaries / Polylines must have an unambiguous orientation.
All seems easy enough but created from arc segments things can become tricky.


If the differential hatched area is not what you are looking for ...
... then the mentioned resources may still give you some insight on how they find shapes inside shapes.
I know, these are not perfectly conclusive methods but they return correct values for all/most common cases.

Regards,
CVH

ilyasozkurt
Newbie Member
Posts: 9
Joined: Sat Nov 19, 2022 3:20 pm

Re: Is there a way to find child, parent closed polylines?

Post by ilyasozkurt » Sun Nov 20, 2022 2:23 pm

Thank you for your suggestions. I'll try to find a proper way.

CVH
Premier Member
Posts: 3416
Joined: Wed Sep 27, 2017 4:17 pm

Re: Is there a way to find child, parent closed polylines?

Post by CVH » Sat Nov 26, 2022 7:07 am

ilyasozkurt wrote:
Sun Nov 20, 2022 2:23 pm
I'll try to find a proper way.
Me, we are very curious about some good methods to deal with surfaces in a simpler way.

If you would like to share your code with us, we could assist and figure it out together. :wink:

Regards,
CVH

Post Reply

Return to “QCAD Programming, Script Programming and Contributing”