Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Part] Add scaleKnotsToBounds method to BSplineCurve #7385

Merged
merged 2 commits into from Aug 23, 2022

Conversation

tomate44
Copy link
Contributor

@tomate44 tomate44 commented Aug 21, 2022

and change the methods to use dedicated OCCT function

Thank you for creating a pull request to contribute to FreeCAD! To ease integration, we ask you to conform to the following items. Pull requests which don't satisfy all the items below might be rejected. If you are in doubt with any of the items below, don't hesitate to ask for help in the FreeCAD forum!

  • Your pull request is confined strictly to a single module. That is, all the files changed by your pull request are either in App, Base, Gui or one of the Mod subfolders. If you need to make changes in several locations, make several pull requests and wait for the first one to be merged before submitting the next ones
  • In case your pull request does more than just fixing small bugs, make sure you discussed your ideas with other developers on the FreeCAD forum
  • Your branch is rebased on latest master git pull --rebase upstream master
  • All FreeCAD unit tests are confirmed to pass by running ./bin/FreeCAD --run-test 0
  • All commit messages are well-written ex: Fixes typo in Draft Move command text
  • Your pull request is well written and has a good description, and its title starts with the module name, ex: Draft: Fixed typos
  • Commit messages include issue #<id> or fixes #<id> where <id> is the issue ID number from our Issues database in case a particular commit solves or is related to an existing issue. Ex: Draft: fix typos - fixes #4805

And please remember to update the Wiki with the features added or changed once this PR is merged.
Note: If you don't have wiki access, then please mention your contribution on the 0.20 Changelog Forum Thread.


@github-actions github-actions bot added the WB Part Related to the Part Workbench label Aug 21, 2022
@tomate44
Copy link
Contributor Author

While thinking back on this, I don't think setBounds is a good name choice.
It refers to the bounds() method, that returns parameters and is common to all surfaces.
While these methods are specific to BSplines, and deal with knots.
setKnotsRange(), setKnotsBounds() or setKnotsInterval() would be more accurate, IMHO.
Opinions ?

@AjinkyaDahale
Copy link
Contributor

I think setBounds is accurate given the signature. Only the first and last knots are given, and the ones in the middle appear to just be scaled to that range.

However, the topic is different if there already exists a "setBounds" function for other curves (I see that there is a setRange() in some cases) that actually keeps the same parametrization but changes start and end params (effectively changing the shape of the curve). AFAICT a function like this wouldn't make sense for a spline because of it's piecewise nature.

To further complicate the matter, there is a setKnots() function in OCCT that can specify a different sequence of knots. AFAIK that can change the shape of the spline.

So to summarize: setBounds isn't inaccurate, but if a function with the exact same name doing different things exists for other curves, it should be renamed; and, alternative names you suggested can add it's own kind of ambiguity.

If we have to rename I suggest something like "scaleKnotsToBounds()".

@berndhahnebach
Copy link
Contributor

pipeline status for feature branch PR_7385. Pipeline 618946924 was triggered at 4129865. All CI branches and pipelines.

@tomate44
Copy link
Contributor Author

scaleKnotsToBounds is both self-explaining and non-ambiguous.
Thanks a lot.

@berndhahnebach
Copy link
Contributor

pipeline status for feature branch PR_7385. Pipeline 619281056 was triggered at 8e955ec. All CI branches and pipelines.

@luzpaz luzpaz added the Feature FR for improvements or new features label Aug 22, 2022
@berndhahnebach
Copy link
Contributor

pipeline status for feature branch PR_7385. Pipeline 619888182 was triggered at e15ca32. All CI branches and pipelines.

@AjinkyaDahale
Copy link
Contributor

@tomate44 is there a reason you chose to make a merge commit rather than a rebase?

@tomate44
Copy link
Contributor Author

@AjinkyaDahale Are you talking about Merge branch 'master' into BSC_setBounds ?
On the PR window, Github was saying 'This branch is out-of-date with base branch' with a 'update branch' button next to it.
Was it a trap ?

@AjinkyaDahale
Copy link
Contributor

AjinkyaDahale commented Aug 23, 2022

@tomate44 not a trap by itself, but if this PR stays for longer there will be another "this branch is out of date", and then the update will add yet another such commit. At least in 2016-17 that was the case.

A cleaner solution is to rebase. This will then rearrange the commits such that it looks as if you made directly on the current master. It can be achieved by clicking the dropdown next to that "update" button and clicking "rebase and update".

and change BSplineSurface.setBounds() to use dedicated OCCT function
@tomate44 tomate44 changed the title [Part] Add setBounds method to BSplineCurve [Part] Add scaleKnotsToBounds method to BSplineCurve Aug 23, 2022
@tomate44
Copy link
Contributor Author

@AjinkyaDahale Thanks for the hint.
I don't know the github web interface very well.
I fixed the problem.

@AjinkyaDahale
Copy link
Contributor

@AjinkyaDahale Thanks for the hint. I don't know the github web interface very well. I fixed the problem.

Yeah I don't use github for this either. Just some tools I'm myself used to (magit within emacs).

@wwmayer wwmayer merged commit c86490e into FreeCAD:master Aug 23, 2022
@wwmayer
Copy link
Contributor

wwmayer commented Aug 23, 2022

Fixes the test failure: a783d5b

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Feature FR for improvements or new features WB Part Related to the Part Workbench
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants