Use marker as center, cleanup code

This commit is contained in:
Matthias Hochsteger 2023-03-31 15:46:45 +02:00
parent 5d0c61b10f
commit aae0521057
3 changed files with 45 additions and 67 deletions

View File

@ -222,6 +222,7 @@ namespace netgen
{ return selpoint; }
void BuildFilledList (bool select);
void BuildColorTexture();
void SelectCenter(int zoomall);
// private:
void BuildLineList();
void BuildEdgeList();

View File

@ -253,6 +253,47 @@ namespace netgen
}
void VisualSceneMesh :: SelectCenter (int zoomall)
{
shared_ptr<Mesh> 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<Element2d> 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)
{

View File

@ -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)