spline 3 degree limit ? Bug ?

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
vroemm
Registered Member
Posts: 2
Joined: Sun Feb 07, 2016 5:23 pm

spline 3 degree limit ? Bug ?

Post by vroemm » Sun Feb 07, 2016 6:02 pm

Hi..

I hope this is the right place in the qcad forum to make this contribution.
If not, please point me to the right place.

I used a spline in qcad 3.12.6 with 7 points.
In the properties editor -> degree i could choose between 1 to 6 degree.
The drawing showed a difference between selecting 1, 2 .. 6 degree.
I choose 5.

Then i saved the drawing, closed the drawing, and opened the drawing again.

The something strange happened.
The DEGREE of the spline was changed from 5 to 3 .
The drawing showed the result of 3 degree.
The setting 5 degree was lost.

Then i downloaded the source code to see what happened.

I am a low level hobby programmer, with no experience in programming QCAD.
So it could be i did something stupid ;-))

In qcad-3.12.6.0/src/io/dxf/RDxfImporter.cpp

In:

void RDxfImporter::addSpline(const DL_SplineData& data) {

i changed the line :

if (data.degree<=1 || data.degree>3)

To :

if (data.degree<=1 || data.degree>= data.nControl )

Now it looks like qcad spline can remember the 5 degree.
It seems to work fine.
Is this a correct code change ?

I do not understand why spline first offered one less degree then then number of points.
Is this somehow needed ?
I toke data.nControl to limit the degrees, is this right or wrong ?

Does this solution break some international dxf definition or something ?
What do i know :-)

Vroemm.

User avatar
andrew
Site Admin
Posts: 9037
Joined: Fri Mar 30, 2007 6:07 am

Re: spline 3 degree limit ? Bug ?

Post by andrew » Mon Feb 08, 2016 10:36 am

Thanks. Yes, that check is obsolete. I think it's better not to check the degree at that point at all. The spline will simply fail to render at a later stage if it is invalid.

Commit:
https://github.com/qcad/qcad/commit/30e ... b0aa64322a
I do not understand why spline first offered one less degree then then number of points.
A spline by definition always needs at least degree+1 control points.

vroemm
Registered Member
Posts: 2
Joined: Sun Feb 07, 2016 5:23 pm

Re: spline 3 degree limit ? Bug ?

Post by vroemm » Tue Feb 09, 2016 3:32 pm

Thanks..

It feels good to contribute something to QCAD.
A smile on my face and a warm feeling.. :-)

Vroemm.

Post Reply

Return to “QCAD Programming, Script Programming and Contributing”