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

[GL] Introducing class LineSegment. #1139

Merged
merged 24 commits into from Apr 28, 2016
Merged

Conversation

TomFischer
Copy link
Member

PR improves the existing class LineSegment and establishs it at some places in the GeoLib. The changes should improve the readability.

Furthermore the PR introduces a SegmentIterator in class Polyline. The iterator class allows to use algorithms from the standard library and makes the code more readable at some places.

@ogsbot
Copy link
Member

ogsbot commented Apr 14, 2016

Jenkins: OGS-6/Gui/Win-PRs failed: https://svn.ufz.de:8443/job/OGS-6/job/Gui/job/Win-PRs/1439/

@ogsbot
Copy link
Member

ogsbot commented Apr 14, 2016

Jenkins: OGS-6/Win-PRs failed: https://svn.ufz.de:8443/job/OGS-6/job/Win-PRs/1462/

@TomFischer
Copy link
Member Author

Just let you know the status of the PR:

  • The testrunner is failing under Windows builds.
  • The testrunner is running fine under Mac and linux builds.
  • The Clang sanitizer under linux reports some mem leaks. These issues seems to be Qt related.
  • Valgrind kills the program because of an instruction valgrind does not understand. The place where this is reported is related to the test that is failing under Windows. A snippet of the valgrind message is below. Maybe someone has an idea to find the bug?

valgrind: Unrecognised instruction at address 0x136f6ad5.
at 0x136F6AD5: std::(anonymous namespace)::__x86_rdrand() (random.cc:69)
by 0x136F6C71: std::random_device::_M_getval() (random.cc:130)
by 0xD40864: std::random_device::operator()() (in /home/fischeth/w/OGS-6/BuildDebugWithCLangGui/bin/testrunner)
by 0xD40217: autocheck::rng() (generator.hpp:20)
by 0xE539F7: autocheck::generator<double, void>::operator()(unsigned long) (generator.hpp:162)
by 0xE53798: autocheck::RandomCirclePointGeneratorXY<autocheck::generator<double, void> >::operator()(unsigned long) (AutoCheckGenerators.h:38)
by 0xE53537: autocheck::SymmSegmentGeneratorXY<autocheck::RandomCirclePointGeneratorXY<autocheck::generator<double, void> > >::operator()(unsigned long) (AutoCheckGenerato rs.h:71)
by 0xE5341A: std::tuple<GeoLib::LineSegment, GeoLib::LineSegment> autocheck::generate<std::tuple<GeoLib::LineSegment, GeoLib::LineSegment>, autocheck::SymmSegmentGenerator XY<autocheck::RandomCirclePointGeneratorXY<autocheck::generator<double, void> > >, autocheck::SymmSegmentGeneratorXY<autocheck::RandomCirclePointGeneratorXY<autocheck::generator<double , void> > >, 0, 1>(std::tuple<autocheck::SymmSegmentGeneratorXY<autocheck::RandomCirclePointGeneratorXY<autocheck::generator<double, void> > >, autocheck::SymmSegmentGeneratorXY<autoch eck::RandomCirclePointGeneratorXY<autocheck::generator<double, void> > > >&, unsigned long, autocheck::range<0, 0, 1> const&) (generator.hpp:28)
by 0xE52E07: std::tuple<GeoLib::LineSegment, GeoLib::LineSegment> autocheck::generate<std::tuple<GeoLib::LineSegment, GeoLib::LineSegment>, autocheck::SymmSegmentGenerator XY<autocheck::RandomCirclePointGeneratorXY<autocheck::generator<double, void> > >, autocheck::SymmSegmentGeneratorXY<autocheck::RandomCirclePointGeneratorXY<autocheck::generator<double , void> > > >(std::tuple<autocheck::SymmSegmentGeneratorXY<autocheck::RandomCirclePointGeneratorXY<autocheck::generator<double, void> > >, autocheck::SymmSegmentGeneratorXY<autocheck:: RandomCirclePointGeneratorXY<autocheck::generator<double, void> > > >&, unsigned long) (in /home/fischeth/w/OGS-6/BuildDebugWithCLangGui/bin/testrunner)
by 0xE526A0: autocheck::arbitrary<autocheck::SymmSegmentGeneratorXY<autocheck::RandomCirclePointGeneratorXY<autocheck::generator<double, void> > >, autocheck::SymmSegmentG eneratorXY<autocheck::RandomCirclePointGeneratorXY<autocheck::generator<double, void> > > >::operator()(autocheck::value<std::tuple<GeoLib::LineSegment, GeoLib::LineSegment> >&) (arbit rary.hpp:50)
by 0xE4D2B1: void autocheck::check<GeoLib::LineSegment, GeoLib::LineSegment, LineSegmentIntersect2dTest_RandomSegmentOrientationIntersecting_Test::TestBody()::$_0, autoche ck::arbitrary<autocheck::SymmSegmentGeneratorXY<autocheck::RandomCirclePointGeneratorXY<autocheck::generator<double, void> > >, autocheck::SymmSegmentGeneratorXY<autocheck::RandomCircl ePointGeneratorXY<autocheck::generator<double, void> > > > >(LineSegmentIntersect2dTest_RandomSegmentOrientationIntersecting_Test::TestBody()::$_0, unsigned long, autocheck::arbitrary< autocheck::SymmSegmentGeneratorXY<autocheck::RandomCirclePointGeneratorXY<autocheck::generator<double, void> > >, autocheck::SymmSegmentGeneratorXY<autocheck::RandomCirclePointGenerato rXY<autocheck::generator<double, void> > > >, autocheck::reporter const&, autocheck::classifier<GeoLib::LineSegment, GeoLib::LineSegment>, bool) (check.hpp:39)
by 0xE4D1BA: LineSegmentIntersect2dTest_RandomSegmentOrientationIntersecting_Test::TestBody() (TestLineSegmentIntersect2d.cpp:78)
Your program just tried to execute an instruction that Valgrind did not recognise. There are two possible reasons for this.

  1. Your program has a bug and erroneously jumped to a non-code location. If you are running Memcheck and you just saw a warning about a bad jump, it's probably your program's fault.
  2. The instruction is legitimate but Valgrind doesn't handle it, i.e. it's Valgrind's fault. If you think this is the case or you are not sure, please let us know and we'll try to fix it.
    Either way, Valgrind will now raise a SIGILL signal which will
    probably kill your program.

@norihiro-w
Copy link
Collaborator

norihiro-w commented Apr 15, 2016

It seems valgrind failed because the test uses RDRAND instruction (__x86_rdrand()) which is on-chip hardware random number generator (see https://en.wikipedia.org/wiki/RdRand). As this is hardware dependent, valgrind may not suppose it in some hardware. see, e.g., https://bugs.launchpad.net/ubuntu/+source/valgrind/+bug/852795

I'm not sure how we can fix it. you may need to change some code in auto check where it specifies how to generate random numbers, i.e. change it to use some software random number generator. Alternatively, as a temporal solution, you may try valgrind on other computers.

@TomFischer TomFischer force-pushed the LineSegment branch 2 times, most recently from 663848a to 8dc858d Compare April 20, 2016 09:55
@ogsbot
Copy link
Member

ogsbot commented Apr 20, 2016

Jenkins: OGS-6/Win-PRs failed: https://svn.ufz.de:8443/job/OGS-6/job/Win-PRs/1516/

@ogsbot
Copy link
Member

ogsbot commented Apr 20, 2016

Jenkins: OGS-6/Gui/Win-PRs failed: https://svn.ufz.de:8443/job/OGS-6/job/Gui/job/Win-PRs/1494/

@ogsbot
Copy link
Member

ogsbot commented Apr 20, 2016

Jenkins: OGS-6/Win-PRs failed: https://svn.ufz.de:8443/job/OGS-6/job/Win-PRs/1518/

@ogsbot
Copy link
Member

ogsbot commented Apr 20, 2016

Jenkins: OGS-6/Gui/Win-PRs failed: https://svn.ufz.de:8443/job/OGS-6/job/Gui/job/Win-PRs/1496/

@chleh
Copy link
Collaborator

chleh commented Apr 21, 2016

Currently I don't feel like I want to contemplate about your changes all by myself. I think this PR is a good candidate for a personal introduction by yourself to the reviewers (less thinking required on my side, and maybe it's faster). Of course, if others volunteered for reviewing without prior presentation, that would be fine, too.

@TomFischer
Copy link
Member Author

@chleh The main points of the PR are the changes to class LineSegment and the introduction of the class Polyline::SegmentIterator. All other changes are related to this.

Are you available tomorrow morning for an explanation?

line_segment._point_mem_management_by_line_segment = false;
}

LineSegment::LineSegment()
Copy link
Member

@endJunction endJunction Apr 21, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is no longer needed... ✅

@ogsbot
Copy link
Member

ogsbot commented Apr 21, 2016

Jenkins: OGS-6/Linux-PRs failed: https://svn.ufz.de:8443/job/OGS-6/job/Linux-PRs/1657/

@ogsbot
Copy link
Member

ogsbot commented Apr 21, 2016

Jenkins: OGS-6/Win-PRs failed: https://svn.ufz.de:8443/job/OGS-6/job/Win-PRs/1535/

@TomFischer
Copy link
Member Author

Commit 2c86725 and d25f04e results of a discussion with @chleh.

  • first commit documents/explains the default value of the third argument
  • second commit is simply using modern C++

@ogsbot
Copy link
Member

ogsbot commented Apr 22, 2016

Jenkins: OGS-6/Gui/Win-PRs failed: https://svn.ufz.de:8443/job/OGS-6/job/Gui/job/Win-PRs/1524/

@TomFischer
Copy link
Member Author

Jenkins, test this please.

GeoLib::Point* intersection_pnt,
std::size_t& seg_num) const;

bool getNextIntersectionPointPolygonLine(GeoLib::LineSegment const& seg,
Copy link
Collaborator

@chleh chleh Apr 23, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you please document the meaning of the Boolean return value, too. ✅

@TomFischer TomFischer merged commit 11f8953 into ufz:master Apr 28, 2016
@TomFischer TomFischer deleted the LineSegment branch April 28, 2016 12:56
@ogsbot
Copy link
Member

ogsbot commented Jun 19, 2020

OpenGeoSys development has been moved to GitLab.

See this pull request on GitLab.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
6 participants