Bug 2907

Summary: Proposed patch for Outdoor allocation
Product: ns-3 Reporter: Michele Polese <michele.polese>
Component: buildingsAssignee: Biljana Bojović <bbojovic>
Status: RESOLVED FIXED    
Severity: minor CC: michele.polese, ns-bugs, tomh
Priority: P3    
Version: ns-3-dev   
Hardware: All   
OS: All   
Attachments: Proposed patch
Proposed patch - V2
Proposed patch - V3

Description Michele Polese 2018-04-03 04:54:07 UTC
Created attachment 3089 [details]
Proposed patch

Currently, it possible to randomly allocate nodes inside buildings.
However, to the best of my knowledge, there is no class that inherits PositionAllocator and that allows a random allocation of nodes outside of buildings.
The proposed patch randomly allocates nodes in a specified box, outside of the buildings of the scenario. It extracts a position until an outdoor one is found.
Comment 1 Tom Henderson 2018-04-04 00:40:41 UTC
Michele, please address these comments:

1) the class Doxygen is not descriptive enough (describe the behavior about how it retries random positions corresponding to independent random variables on X, Y, and Z coordinates, for MaxNumAttempts before aborting)

2) the code doesn't conform to ns-3 coding style for indentation and spaces before parentheses (consider to run the check-style.py script in the utils directory, which calls uncrustify, to produce compliant style)

3) MaxNumAttempts could be better named to MaxAttempts (this would make the naming more consistent with the rest of ns-3)

4) avoid NS_ASSERT and use instead NS_ABORT_MSG_IF so that you can catch errors in non-debug builds
Comment 2 Michele Polese 2018-04-04 03:18:16 UTC
Created attachment 3090 [details]
Proposed patch - V2

Hi Tom,
thanks for your feedback.
I addressed the four comments, please let me know if the documentation is descriptive enough.
Uncrustify found some issues with spaces also in the other classes of the files I am patching, I hope it's fine to leave them in the patch.
Best,
Michele
Comment 3 Tom Henderson 2018-04-04 09:24:52 UTC
(In reply to Michele Polese from comment #2)
> Created attachment 3090 [details]
> Proposed patch - V2
> 
> Hi Tom,
> thanks for your feedback.
> I addressed the four comments, please let me know if the documentation is
> descriptive enough.

Yes, but please add also the '\ingroup buildings' and '\brief' components, such as here:

/**
 * \ingroup buildings
 * \brief mobility buildings information (to be used by mobility models)
 *
 * This model implements the managment of scenarios where users might be
 * either indoor (e.g., houses, offices, etc.) and outdoor.
 *
 */


> Uncrustify found some issues with spaces also in the other classes of the
> files I am patching, I hope it's fine to leave them in the patch.

Can you please split your patch from any other whitespace changes, either discarding the unrelated whitespace changes or putting them into a separate 'fix-whitespace.patch'?

We made a maintenance decision a while back to avoid continually tweaking the small whitespace issues (which do accumulate over time) because it tends to breaks out of tree patches, and because the output of uncrustify varies across its versions.  I tend to use 'check-style.py' for any new file that goes into the repository, and then I use it as a guide for any new patches made to existing files but I avoid making unrelated whitespace changes in other portions of the code that are bundled with a new feature patch.
Comment 4 Michele Polese 2018-04-04 09:56:11 UTC
Created attachment 3091 [details]
Proposed patch - V3

Hi Tom,
it makes sense.
This is a patch for the OutdoorPositionAllocator class only.
If you want I can prepare a patch with the \ingroup and \brief information for the other classes in building-position-allocator.h.
Best,
Michele
Comment 5 Tom Henderson 2018-04-11 01:07:48 UTC
(In reply to Michele Polese from comment #4)
> Created attachment 3091 [details]
> Proposed patch - V3
> 
> Hi Tom,
> it makes sense.
> This is a patch for the OutdoorPositionAllocator class only.

Thanks for making updates; I think it can be merged now.

> If you want I can prepare a patch with the \ingroup and \brief information
> for the other classes in building-position-allocator.h.

Sure, if you don't mind making other improvements in a separate patch, we'll take them.
Comment 6 Michele Polese 2018-04-12 10:51:17 UTC
(In reply to Tom Henderson from comment #5)
> (In reply to Michele Polese from comment #4)
> > Created attachment 3091 [details]
> > Proposed patch - V3
> > 
> > Hi Tom,
> > it makes sense.
> > This is a patch for the OutdoorPositionAllocator class only.
> 
> Thanks for making updates; I think it can be merged now.
Thanks, will you take care of this?
> 
> > If you want I can prepare a patch with the \ingroup and \brief information
> > for the other classes in building-position-allocator.h.
> 
> Sure, if you don't mind making other improvements in a separate patch, we'll
> take them.
I will prepare them in a few days.
Comment 7 Tom Henderson 2018-04-12 11:06:12 UTC
> Thanks, will you take care of this?

Yes, I plan to merge early next week if no other comments.
Comment 8 Tom Henderson 2018-04-19 11:52:07 UTC
pushed in 13493:d974ae28f427