diff --git a/libsrc/visualization/mvdraw.hpp b/libsrc/visualization/mvdraw.hpp index eb2958a7..e750edb1 100644 --- a/libsrc/visualization/mvdraw.hpp +++ b/libsrc/visualization/mvdraw.hpp @@ -222,6 +222,7 @@ namespace netgen { return selpoint; } void BuildFilledList (bool select); void BuildColorTexture(); + void SelectCenter(int zoomall); // private: void BuildLineList(); void BuildEdgeList(); diff --git a/libsrc/visualization/vsmesh.cpp b/libsrc/visualization/vsmesh.cpp index f5e1668e..1e3583a4 100644 --- a/libsrc/visualization/vsmesh.cpp +++ b/libsrc/visualization/vsmesh.cpp @@ -253,6 +253,47 @@ namespace netgen } + void VisualSceneMesh :: SelectCenter (int zoomall) + { + shared_ptr mesh = GetMesh(); + Point3d pmin, pmax; + mesh->GetBox (pmin, pmax, -1); + + // works in NGSolve, mesh view + if (mesh->GetDimension() == 2) + mesh->GetBox (pmin, pmax); + else // otherwise strange zooms during mesh generation + mesh->GetBox (pmin, pmax, SURFACEPOINT); + + if (vispar.use_center_coords && zoomall==2) + { + center.X() = vispar.centerx; + center.Y() = vispar.centery; + center.Z() = vispar.centerz; + } + else if (selpoint >= 1 && zoomall==2) + center = mesh->Point (selpoint); + else if (marker && zoomall==2) + center = *marker; + else if (vispar.centerpoint >= 1 && zoomall==2) + center = mesh->Point (vispar.centerpoint); + else + center = Center (pmin, pmax); + + double oldrad = rad; + rad = 0.5 * Dist (pmin, pmax); + if(rad == 0) rad = 1e-6; + + if (rad > 1.2 * oldrad || + mesh->GetMajorTimeStamp() > vstimestamp || + zoomall) + { + CalcTransformationMatrices(); + } + + glEnable (GL_NORMALIZE); + + } void VisualSceneMesh :: BuildScene (int zoomall) { @@ -277,48 +318,11 @@ namespace netgen - Point3d pmin, pmax; - static double oldrad = 0; - NgArray faces; int meshtimestamp = mesh->GetTimeStamp(); if (meshtimestamp > vstimestamp || zoomall) - { - if (mesh->GetDimension() == 2) - { - // works in NGSolve, mesh view - mesh->GetBox (pmin, pmax); - } - else - { - // otherwise strange zooms douring mesh generation - mesh->GetBox (pmin, pmax, SURFACEPOINT); - } - - if (vispar.use_center_coords && zoomall == 2) - { - center.X() = vispar.centerx; center.Y() = vispar.centery; center.Z() = vispar.centerz; - } - else if (selpoint >= 1 && zoomall == 2) - center = mesh->Point (selpoint); - else if (vispar.centerpoint >= 1 && zoomall == 2) - center = mesh->Point (vispar.centerpoint); - else - center = Center (pmin, pmax); - rad = 0.5 * Dist (pmin, pmax); - if(rad == 0) rad = 1e-6; - - if (rad > 1.2 * oldrad || - mesh->GetMajorTimeStamp() > vstimestamp || - zoomall) - { - CalcTransformationMatrices(); - oldrad = rad; - } - } - - glEnable (GL_NORMALIZE); + SelectCenter(zoomall); if (pointnumberlist) { diff --git a/libsrc/visualization/vssolution.cpp b/libsrc/visualization/vssolution.cpp index ef2645b6..baaaf448 100644 --- a/libsrc/visualization/vssolution.cpp +++ b/libsrc/visualization/vssolution.cpp @@ -791,35 +791,7 @@ namespace netgen if (mesh->GetTimeStamp() > surfeltimestamp || zoomall) { // mesh has changed - - Point3d pmin, pmax; - static double oldrad = 0; - - mesh->GetBox (pmin, pmax, -1); - if(vispar.use_center_coords && zoomall == 2) - { - center.X() = vispar.centerx; - center.Y() = vispar.centery; - center.Z() = vispar.centerz; - } - else if(selpoint >= 1 && zoomall == 2) - center = mesh->Point(selpoint); - else if(vispar.centerpoint >= 1 && zoomall == 2) - center = mesh->Point(vispar.centerpoint); - else - center = Center (pmin, pmax); - rad = 0.5 * Dist (pmin, pmax); - if(rad == 0) rad = 1e-6; - - glEnable (GL_NORMALIZE); - - if (rad > 1.2 * oldrad || - mesh->GetMajorTimeStamp() > surfeltimestamp || - zoomall) - { - CalcTransformationMatrices(); - oldrad = rad; - } + vsmesh.SelectCenter(zoomall); } DrawSurfaceElements(); @@ -4775,6 +4747,7 @@ namespace netgen auto printScalValue = [&formatComplex] (SolData & sol, int comp, double value, double imag=0., bool iscomplex=false) { + cout << '\t'; if(sol.components>1) { if(comp==0)