-
Notifications
You must be signed in to change notification settings - Fork 59
Add direct cutting-plane control to GLVis scripts #374
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
base: master
Are you sure you want to change the base?
Changes from all commits
3dc9c7d
d757215
1c42190
4a22f38
cc8b16a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -20,6 +20,8 @@ | |||||
| #include <array> | ||||||
| #include <algorithm> | ||||||
| #include <thread> | ||||||
| #include <cmath> | ||||||
| #include <cctype> | ||||||
|
|
||||||
| using namespace std; | ||||||
| using namespace mfem; | ||||||
|
|
@@ -63,6 +65,7 @@ enum class Command | |||||
| PlotCaption, | ||||||
| PointLine, | ||||||
| Headless, | ||||||
| CuttingPlane, | ||||||
| //---------- | ||||||
| Max | ||||||
| }; | ||||||
|
|
@@ -128,6 +131,7 @@ ScriptCommands::ScriptCommands() | |||||
| (*this)[Command::PlotCaption] = {"plot_caption", "'<caption>'", "Set the plot caption."}; | ||||||
| (*this)[Command::PointLine] = {"pointline", "<num_points> <x y z>...", "Set point line overlay coordinates."}; | ||||||
| (*this)[Command::Headless] = {"headless", "", "Change the session to headless."}; | ||||||
| (*this)[Command::CuttingPlane] = {"cutting_plane", "<phi> <theta> <translation> <kind:optional, default 1> <alg:optional>", "Set the cutting plane orientation (degrees), translation, kind, and algorithm."}; | ||||||
| } | ||||||
|
|
||||||
| int ScriptController::ScriptReadSolution(istream &scr, DataState &state) | ||||||
|
|
@@ -859,6 +863,49 @@ bool ScriptController::ExecuteScriptCommand() | |||||
| case Command::Headless: | ||||||
| cout << "The session cannot become headless after initialization" << endl; | ||||||
| break; | ||||||
| case Command::CuttingPlane: | ||||||
| { | ||||||
| double phi_deg, theta_deg, translation; | ||||||
| scr >> phi_deg >> theta_deg >> translation; | ||||||
|
|
||||||
| int kind = 1, algo = -1; | ||||||
| scr >> ws; | ||||||
| int ch = scr.peek(); | ||||||
| if (isdigit(ch) || ch == '-') | ||||||
| { | ||||||
| scr >> kind; | ||||||
| scr >> ws; | ||||||
| ch = scr.peek(); | ||||||
| if (isdigit(ch) || ch == '-') | ||||||
| { | ||||||
| scr >> algo; | ||||||
| } | ||||||
| } | ||||||
|
|
||||||
| if (kind < -1 || kind > 2) | ||||||
| { | ||||||
| cerr << "Script: cutting_plane: invalid kind " << kind | ||||||
| << " (expected -1..2)" << endl; | ||||||
| kind = 1; | ||||||
| } | ||||||
| if (algo != -1 && (algo < 0 || algo > 1)) | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
| { | ||||||
| cerr << "Script: cutting_plane: invalid alg " << algo | ||||||
| << " (expected 0 or 1)" << endl; | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fix this message please to include -1. |
||||||
| algo = -1; | ||||||
| } | ||||||
|
|
||||||
| cout << "Script: cutting_plane: " << phi_deg << ' ' << theta_deg | ||||||
| << ' ' << translation << ' ' << kind; | ||||||
| if (algo != -1) { cout << ' ' << algo; } | ||||||
| cout << endl; | ||||||
|
|
||||||
| win.vs->SetCuttingPlane(phi_deg * M_PI / 180.0, | ||||||
| theta_deg * M_PI / 180.0, | ||||||
| translation, kind, algo); | ||||||
| MyExpose(); | ||||||
| } | ||||||
| break; | ||||||
| case Command::Max: //dummy | ||||||
| break; | ||||||
| } | ||||||
|
|
||||||
| Original file line number | Diff line number | Diff line change | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -23,6 +23,7 @@ class Plane | |||||||||
| double eqn[4]; | ||||||||||
| double phi, theta, rho; | ||||||||||
| double x0,y0,z0; | ||||||||||
| double cx, cy, cz; // fixed mesh bounding-box center | ||||||||||
| void CartesianToSpherical(); | ||||||||||
| void SphericalToCartesian(); | ||||||||||
|
|
||||||||||
|
|
@@ -44,6 +45,7 @@ class Plane | |||||||||
| void DecreaseTheta(); | ||||||||||
| void IncreaseDistance(); | ||||||||||
| void DecreaseDistance(); | ||||||||||
| void SetPlane(double phi_, double theta_, double translation); | ||||||||||
| }; | ||||||||||
|
|
||||||||||
|
|
||||||||||
|
|
@@ -263,6 +265,12 @@ class VisualizationSceneScalarData : public VisualizationScene | |||||||||
| virtual void AutoRefine() = 0; | ||||||||||
| virtual void ToggleAttributes(mfem::Array<int> &attr_list) = 0; | ||||||||||
|
|
||||||||||
| // Set the cutting-plane orientation (radians), translation, kind, and | ||||||||||
| // algorithm in one shot. No-op by default; only meaningful for 3D scenes. | ||||||||||
| // kind == -1 / algo == -1 mean "leave unchanged". | ||||||||||
|
Comment on lines
+268
to
+270
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please use doxygen style. We do not publish it anymore on the webpage, but you can still build it locally. |
||||||||||
| virtual void SetCuttingPlane(double phi, double theta, double translation, | ||||||||||
| int kind, int algo) { } | ||||||||||
|
Comment on lines
+271
to
+272
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||
|
|
||||||||||
| virtual void PrintState(); | ||||||||||
|
|
||||||||||
| mfem::Mesh *GetMesh() { return mesh; } | ||||||||||
|
|
||||||||||
| Original file line number | Diff line number | Diff line change | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -218,6 +218,8 @@ class VisualizationSceneSolution3d : public VisualizationSceneScalarData | |||||||||
| void ToggleCPDrawElems(); | ||||||||||
| void ToggleCPDrawMesh(); | ||||||||||
| void ToggleCPAlgorithm(); | ||||||||||
| void SetCuttingPlane(double phi, double theta, double translation, | ||||||||||
| int kind, int algo) override; | ||||||||||
|
Comment on lines
+221
to
+222
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||
| void MoveLevelSurf(int); | ||||||||||
| void NumberOfLevelSurf(int); | ||||||||||
| void EventUpdateColors() override; | ||||||||||
|
|
||||||||||
Uh oh!
There was an error while loading. Please reload this page.
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.