-
Notifications
You must be signed in to change notification settings - Fork 328
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
Add no visualization option #2522
base: main
Are you sure you want to change the base?
Conversation
…e convenience methods to set it and query it. Use it in Mesh::extendFinalizeFromProperties to avoid file search for mesh files
@@ -66,6 +69,7 @@ class OSIMSIMULATION_API ModelVisualPreferences : public Object { | |||
private: | |||
void constructProperties() { | |||
constructProperty_ModelDisplayHints(ModelDisplayHints()); | |||
constructProperty_no_visualization(false); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should avoid the possibility for double negatives. I would prefer this setting to be named "visualize" or something like that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't disagree.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I made sure the user facing convenience method name is clear, I definitely welcome better names for the property that will appear in xml and will flip the logic accordingly. I don't particularly like visualize as it is close to "visualizer" so rather overused, but I welcome other opinions.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The description is "Flag to indicate whether or not to show geometry from mesh files, default to false." so I assume analytic geometry would still visualize. If that's the case, then perhaps put "Mesh" in the name of the property, like loadMeshFiles
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@tkuchida I would have called it show_meshes but I wanted to get feedback on (item 3) whether we want to use this more widely to avoid calling generateDecorations altogether which would affect all geometry but may be more efficient.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seems somewhat confusing to me particularly in context of existing Model::get/setUseVisualizer()
. I realize that this is for the API visualizer and not the GUI visualizer. If you are not using the API visualizer (and you are not in the GUI) you would expect zero overhead/errors related to visualization. If you are in the GUI or have the visualizer on, then visualize should be true. You shouldn't have to turn two flags on.
I like the idea of bypassing generateDecorations()
altogether if there is no visualization.
Can we simplify the interface and only have one internal visualize
flag without exposing any properties? If getUseVisualizer
is true then it is true. The GUI turns it to true but otherwise it is false.
@@ -66,6 +69,7 @@ class OSIMSIMULATION_API ModelVisualPreferences : public Object { | |||
private: | |||
void constructProperties() { | |||
constructProperty_ModelDisplayHints(ModelDisplayHints()); | |||
constructProperty_no_visualization(false); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seems somewhat confusing to me particularly in context of existing Model::get/setUseVisualizer()
. I realize that this is for the API visualizer and not the GUI visualizer. If you are not using the API visualizer (and you are not in the GUI) you would expect zero overhead/errors related to visualization. If you are in the GUI or have the visualizer on, then visualize should be true. You shouldn't have to turn two flags on.
I like the idea of bypassing generateDecorations()
altogether if there is no visualization.
Can we simplify the interface and only have one internal visualize
flag without exposing any properties? If getUseVisualizer
is true then it is true. The GUI turns it to true but otherwise it is false.
@aseth1 my preference would have been not to use the properties altogether as well, however due to the fact that mesh file loading is performed in extendFinalizeFromProperties which is invoked in the constructor, there's no clear way to pass a flag around to relevant components. The two options were the Properties or to pass a flag to the constructor that's kept around which seemed less friendly to API users. (item 1 in looking for feedback on above). |
…ity, flip logic and rename methods to reflect feedback on PR.
I changed the property to 'load_mesh_files' per the feedback so far and flipped the -ve logic. Now pending the discussion of scope. It would be good to run a simulation and place a breakpoint in generateDecorations to see if the method is actually called or only assumed. I can do that myself if no body else did it already. |
IMHO a flag to control visualization is better than having to make users aware of loading meshes from files (even though mesh loading is the current issue). It seems like a one line fix to interrupt the delegation to each component in the Model in model's generateDecorations(). |
Other options are:
|
Some experiments to take into consideration:
|
Some more comments:
I understand having the property and a call to visualize could possibly be confusing so I'm hoping the current name would help clarify the scope. |
…se it before loading mesh files and test it in testVisualization .
Thanks for the proposal @aseth1 I went ahead and implemented it as you suggested (you can check the branch/PR to make sure we're in sync. documentation may need more work). The good news is that it worked and the issue with working directory didn't cause a problem at all :+1 Test cases passed except for testActuators which was tripped by the side effect of calling finalizeFromProperties within setUseVisualizer). This however highlights the major drawback that finalizeFromProperties is a massive hammer that wipes out the system, connections and state and recreates them from scratch (rather unnecessarily in this case) just for the side effect of calling extendFinalizeFromProperties on meshes. The GUI will need to be changed to handle that at a dozen places or so where it loads models as well. Another side effect is that innocent looking calls that used to be sprinkled rather liberally in our code and users code to setUseVisualizer now could have major side-effects (as in testActuators.cpp). Having the API visualizer as a debugging tool that can be used without worry about side-effects is likely very important for developers. My recommendation at this point would be to stay with the more "proportionate" change that controls meshes only but I'd like to hear your thoughts/feedback and to hear from others @chrisdembia, @tkuchida, @jimmyDunne and @jenhicks Cheers. |
Not a side effect. Calling
This is the designed behavior--
Then the GUI has been using the API incorrectly, which is unlikely given the series of Exceptions throws to thwart this kind of thing. Meshes should not be loaded on a model with a live System. As properties, this would be equivalent to editing joint locations or spring constants on a model as it is running. Please verify this is not in fact the case.
Again, the "side-effect" i.e. the failure should happen if the Model is edited. The correct use of
You can hear from others, but your description above is distorted. One misuse in a test case does not invalidate the process we have built to ensure that our simulations are valid. I believe the fix works as expected and the test case can be repaired by deleting two lines of code (which were incorrect usage in the first place). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
-
For testActuators to pass, remove the two instances where
model.setUserVisualizer(false)
is called aftermodel.initSystem()
. This is effectively a property change. -
To mitigate unnecessary invocations of
finalizeFromProperties
do not invoke if the visualization flag is unchanged from its present value.
void enableVisualization(bool enable) { | ||
// Propagate flag so that meshes are loaded (or not) | ||
upd_ModelVisualPreferences().setVisualize(enable); | ||
finalizeFromProperties(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you want this to be a bit more efficient, you could check that the enable status is changing. If not, no reason to do anything.
Fixes issue #2375
Brief summary of changes
Introduce a Property in ModelVisualPreferences to turn off loading mesh files.
Testing I've completed
Modified a test case that loads a model and produce missing vtp files warning, then set flag to no_visualization, printed the model. Got no warning on reading model back.
Looking for feedback on...
CHANGELOG.md (choose one)
The Doxygen for this PR can be viewed at http://myosin.sourceforge.net/?C=N;O=D; click the folder whose name is this PR's number.
This change is![Reviewable](https://camo.githubusercontent.com/1541c4039185914e83657d3683ec25920c672c6c5c7ab4240ee7bff601adec0b/68747470733a2f2f72657669657761626c652e696f2f7265766965775f627574746f6e2e737667)