Reimplementing constraint solver

Discussion about the development of the Assembly workbench.
User avatar
DeepSOIC
Posts: 7292
Joined: Fri Aug 29, 2014 12:45 am
Location: Saint-Petersburg, Russia

Re: Reimplementing constraint solver

Post by DeepSOIC » Tue Dec 17, 2019 3:11 pm

A small update. The development slowed to a crawl. The main reason is I had trouble with establishing structures for placed geometry support.

I think I've come up with a reasonable solution, it's 2D version is being finished now.

I've opened issue tracker on the repo, to gather some things I postpone.

New year holidays are coming. I plan traveling. There will be little to no development in the coming three weeks.
User avatar
Kunda1
Posts: 6440
Joined: Thu Jan 05, 2017 9:03 pm

Re: Reimplementing constraint solver

Post by Kunda1 » Tue Dec 17, 2019 6:56 pm

Thanks for the update and heads-up. !
Want to contribute back to FC? Checkout:
#lowhangingfruit | Use the Source, Luke. | How to Help FreeCAD | How to report FC bugs and features
triplus
Posts: 9136
Joined: Mon Dec 12, 2011 4:45 pm

Re: Call for team! Reimplementing constraint solver

Post by triplus » Wed Jan 15, 2020 5:40 pm

Trying to compile the branch i get the following error:

Code: Select all

src/Mod/ConstraintSolver/App/SubSystem.cpp:221:58: error: no matching function for call to ‘FCS::Subconstraint::Subconstraint(<brace-enclosed initializer list>)’
             _subconstraints.push_back(Subconstraint{c, ie});
In addition would it be possible to provide an example code snippet to test:
DeepSOIC wrote:
Mon Nov 25, 2019 12:51 pm
Base classes for geometry and constraints are up, with just one concrete geometric thing and one constraint implemented (point and distance). This should be enough for initial experiments on solver.
Thanks.
wmayer
Site Admin
Posts: 15279
Joined: Thu Feb 19, 2009 10:32 am

Re: Reimplementing constraint solver

Post by wmayer » Wed Jan 15, 2020 6:40 pm

Looks like you need to use C++14

Example 1:

Code: Select all

#include <vector>

struct test {
  int a;
  int b;
};

int main()
{
  std::vector<test> vec;
  vec.push_back(test{1,2});
}
gcc init.cpp -std=c++11 -lstdc++ => works


Example 2:

Code: Select all

#include <vector>

struct test {
  int a;
  int b = -1; // a member is already initialized in the class declaration
};

int main()
{
  std::vector<test> vec;
  vec.push_back(test{1,2});
}
gcc init.cpp -std=c++11 -lstdc++ =>
init.cpp: In function ‘int main()’:
init.cpp:11:25: error: no matching function for call to ‘test::test(<brace-enclosed initializer list>)’
vec.push_back(test{1,2});
^
init.cpp:3:8: note: candidate: test::test()
struct test {
^~~~
init.cpp:3:8: note: candidate expects 0 arguments, 2 provided
init.cpp:3:8: note: candidate: constexpr test::test(const test&)
init.cpp:3:8: note: candidate expects 1 argument, 2 provided
init.cpp:3:8: note: candidate: constexpr test::test(test&&)
init.cpp:3:8: note: candidate expects 1 argument, 2 provided
gcc init.cpp -std=c++14 -lstdc++ => works
triplus
Posts: 9136
Joined: Mon Dec 12, 2011 4:45 pm

Re: Reimplementing constraint solver

Post by triplus » Wed Jan 15, 2020 9:04 pm

wmayer wrote:
Wed Jan 15, 2020 6:40 pm
Looks like you need to use C++14
Thanks for the info.

P.S. Will wait a bit to see if @DeepSOIC will still be prepared to support C++11 (Ubuntu 16.04). For me personally this is not a huge problem, could update the toolchain or migrate to Ubuntu 20.04. But generally speaking maybe supporting C++11 still makes some sense? That is talking from the next FreeCAD version (that will come after the FreeCAD 0.19 release) point of view.
User avatar
DeepSOIC
Posts: 7292
Joined: Fri Aug 29, 2014 12:45 am
Location: Saint-Petersburg, Russia

Re: Reimplementing constraint solver

Post by DeepSOIC » Thu Jan 16, 2020 10:06 am

triplus wrote:
Wed Jan 15, 2020 5:40 pm
In addition would it be possible to provide an example code snippet to test:
see src/Mod/ConstraintSolver/examples for a starting point. Though they might not work right now...
User avatar
DeepSOIC
Posts: 7292
Joined: Fri Aug 29, 2014 12:45 am
Location: Saint-Petersburg, Russia

Re: Reimplementing constraint solver

Post by DeepSOIC » Thu Jan 16, 2020 10:09 am

triplus wrote:
Wed Jan 15, 2020 9:04 pm
wmayer wrote:
Wed Jan 15, 2020 6:40 pm
Looks like you need to use C++14
... But generally speaking maybe supporting C++11 still makes some sense?
I didn't know I am using c++14 features. I aimed for c++11. I guess my toolchain supports c++14, which made me use some c++14 features by accident.
wmayer
Site Admin
Posts: 15279
Joined: Thu Feb 19, 2009 10:32 am

Re: Reimplementing constraint solver

Post by wmayer » Thu Jan 16, 2020 1:07 pm

DeepSOIC wrote:
Thu Jan 16, 2020 10:09 am
I didn't know I am using c++14 features. I aimed for c++11. I guess my toolchain supports c++14, which made me use some c++14 features by accident.
git commit 0b2b1e3a536 now prints which C++ standard is being used. When configuring with CMake you should see it in the output window.

With the CMake macro https://github.com/FreeCAD/FreeCAD/blob ... tups.cmake we can choose the C++ standard from a combo box but obviously the value is only set for the clang or gcc compiler and is ignored for MSVC.

But am not sure if by forcing it to C++11 the compiler will abort for C++14 (or later) code because often compiler extensions are used automatically.
triplus
Posts: 9136
Joined: Mon Dec 12, 2011 4:45 pm

Re: Reimplementing constraint solver

Post by triplus » Thu Jan 16, 2020 6:17 pm

Good to see all the progress and to hear supporting C++11 is still on the plan. No hurry, but will wait for the C++11 fix to land. After i will try to compile again and test the examples.
User avatar
DeepSOIC
Posts: 7292
Joined: Fri Aug 29, 2014 12:45 am
Location: Saint-Petersburg, Russia

Re: Reimplementing constraint solver

Post by DeepSOIC » Wed Jan 22, 2020 11:30 pm

I am now seriously considering shifting the focus to 3d sketching.
Post Reply

Who is online

Users browsing this forum: No registered users and 2 guests