Skip to content

OctreeIterators special member revision - #2108

Merged
taketwo merged 2 commits into
PointCloudLibrary:masterfrom
SergioRAgostinho:oct-it-cpy-ctor
Dec 9, 2017
Merged

OctreeIterators special member revision#2108
taketwo merged 2 commits into
PointCloudLibrary:masterfrom
SergioRAgostinho:oct-it-cpy-ctor

Conversation

@SergioRAgostinho

@SergioRAgostinho SergioRAgostinho commented Dec 1, 2017

Copy link
Copy Markdown
Member

Revised the implementations of the following operators

  • Copy constructors
  • Copy assignment
  • Destructors
  • Equality
  • Inequality

Added unit tests to validate all changes.

#1983 is meant to be applied after this one.

Edit: Fixes #2064

@SergioRAgostinho SergioRAgostinho added the changelog: API break Meta-information for changelog generation label Dec 1, 2017

@taketwo taketwo left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Did you try PCL.Octree_Test on your machine? Seems to segfault on Travis.

: OctreeIteratorBase<OctreeT> (other)
, stack_ (other.stack_)
{
this->current_state_ = stack_.size()? &stack_.back() : NULL;

@taketwo taketwo Dec 1, 2017

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Style

Also, can you please explain why we don't inherit the state from other, i.e. this->current_state_ = other.current_state_?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I'm gonna redirect you to the explanation I gave @frozar when I had a first look at the copy constructor fix he did. Let me know in case you need further clarification. Here's the link #1983 (comment)

The important point to remember is that current_state_ points to an address, which is normally the back element of the stack or the front of the FIFO vector (depending on the type of iterator) and when you perform the copy, this pointer needs to be updated the equivalent element of the stack/fifo container your object has. Also notice that current_state_ is not a direct pointer to an octree node. Hence it can't be simply copied.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks, makes sense.

: OctreeIteratorBase<OctreeT> (other)
, FIFO_ (other.FIFO_)
{
this->current_state_ = FIFO_.size()? &FIFO_.front () : NULL;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Style

@SergioRAgostinho

Copy link
Copy Markdown
Member Author

Did you try PCL.Octree_Test on your machine? Seems to segfault on Travis.

No. It was 4 am already when I pushed this. I just decided to let Travis do it's job over the night :)

@frozar

frozar commented Dec 1, 2017

Copy link
Copy Markdown
Contributor

If it may help, I use this line to compile octree test on my machine (it's quick enough to get the binary):

cmake -DPCL_ONLY_CORE_POINT_TYPES=ON -DPCL_NO_PRECOMPILE=ON -DBUILD_tools=OFF -DBUILD_examples=OFF -DBUILD_apps=OFF -DBUILD_2d=OFF -DBUILD_features=OFF -DBUILD_filters=OFF -DBUILD_geometry=OFF -DBUILD_io=OFF -DBUILD_kdtree=OFF -DBUILD_keypoints=OFF -DBUILD_ml=OFF -DBUILD_octree=ON -DBUILD_outofcore=OFF -DBUILD_people=OFF -DBUILD_recognition=OFF -DBUILD_registration=OFF -DBUILD_sample_consensus=OFFF -DBUILD_search=OFF -DBUILD_segmentation=OFF -DBUILD_simulation=OFF -DBUILD_stereo=OFF -DBUILD_surface=OFF -DBUILD_tracking=OFF -DBUILD_visualization=OFF -DBUILD_global_tests=ON -DBUILD_tests_2d=OFF -DBUILD_tests_common=OFF -DBUILD_tests_features=OFF -DBUILD_tests_filters=OFF -DBUILD_tests_geometry=OFF -DBUILD_tests_io=OFF -DBUILD_tests_kdtree=OFF -DBUILD_tests_keypoints=OFF -DBUILD_tests_octree=ON -DBUILD_tests_outofcore=OFF -DBUILD_tests_people=OFF -DBUILD_tests_recognition=OFF -DBUILD_tests_registration=OFF -DBUILD_tests_sample_consensus=OFF -DBUILD_tests_search=OFF -DBUILD_tests_segmentation=OFF -DBUILD_tests_surface=OFF -DBUILD_tests_visualization=OFF -DGTEST_INCLUDE_DIR=/home/frozar/soft/googletest/googletest/include -DGTEST_SRC_DIR=/home/frozar/soft/googletest/googletest -DCMAKE_BUILD_TYPE=Debug .. && make -j8 test_octree test_octree_iterator

@taketwo is right, test_octree segfaults.

: OctreeIteratorBase<OctreeT> (other)
, stack_ (other.stack_)
{
this->current_state_ = stack_.size()? &stack_.back() : NULL;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks, makes sense.

( max_octree_depth_ == other.max_octree_depth_) );
return (this == &other) ||
((octree_ == other.octree_) &&
(current_state_ == other.current_state_) &&

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Then here we should dereference, right? Otherwise this is never true.
(Plus protection from dereferencing null pointer).

@SergioRAgostinho

SergioRAgostinho commented Dec 3, 2017

Copy link
Copy Markdown
Member Author

The end iterators we're being constructed in a defective manner. The moment, we wrote a "proper" iterator equivalence/inequality they started failing of course.

These latest changes fix #2064 as well. The PR now lacks tests for checking the newly defined begin/end operators. To be added later.

@taketwo

taketwo commented Dec 3, 2017

Copy link
Copy Markdown
Member

The PR now lacks tests for checking the newly defined begin/end operators. To be added later.

In a separate PR? Should I merge this?

@SergioRAgostinho

SergioRAgostinho commented Dec 3, 2017 via email

Copy link
Copy Markdown
Member Author

@SergioRAgostinho SergioRAgostinho added needs: more work Specify why not closed/merged yet needs: code review Specify why not closed/merged yet and removed needs: more work Specify why not closed/merged yet labels Dec 3, 2017
@taketwo taketwo removed the needs: code review Specify why not closed/merged yet label Dec 8, 2017
@taketwo

taketwo commented Dec 8, 2017

Copy link
Copy Markdown
Member

Can I just squash, or do you want to rearrange commits in some certain way?

@SergioRAgostinho

Copy link
Copy Markdown
Member Author

I think I will squash 60c3272 into 44ffdd6 and then I think it would leave it like that.

@SergioRAgostinho
SergioRAgostinho force-pushed the oct-it-cpy-ctor branch 2 times, most recently from e4ec8f8 to 2e0a4e7 Compare December 8, 2017 15:02
@SergioRAgostinho

Copy link
Copy Markdown
Member Author

Squashed and rebased on top of master for that additional appveyor checkup.

@SergioRAgostinho

Copy link
Copy Markdown
Member Author

Ok, scratch that. I think I will just make two commits:

  • Copy ctor, assignment and other methods revision, plus test
  • Begin/end iterator revision plus tests

* Revised the implementations of the following operators
  - Copy constructors
  - Copy assignment
  - Destructors
  - Equality
  - Inequality
* Added unit tests
- Added full parameter constructor for the octree iterators.
- Modified Octree end iterators construction
- Added unit tests for octree begin/end iterators
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

changelog: API break Meta-information for changelog generation module: octree

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants