Print function names and surface/volume evaluation

This commit is contained in:
Matthias Hochsteger 2021-01-13 10:58:13 +01:00
parent e5d339ed99
commit 36aa8658b7
2 changed files with 73 additions and 15 deletions

View File

@ -3156,10 +3156,14 @@ namespace netgen
lock = NULL; lock = NULL;
} }
if(pz>=1.0)
return false;
// cout << "x, y = " << px << ", " << hy << endl; // cout << "x, y = " << px << ", " << hy << endl;
glReadPixels (px, hy, 1, 1, GL_DEPTH_COMPONENT, GL_FLOAT, &pz); glReadPixels (px, hy, 1, 1, GL_DEPTH_COMPONENT, GL_FLOAT, &pz);
if(pz>=1.0)
return false;
if(pz<=0.0)
return false;
// cout << "pz = " << pz << endl; // cout << "pz = " << pz << endl;
gluUnProject(px, hy, pz, transformationmat, projection, viewport, gluUnProject(px, hy, pz, transformationmat, projection, viewport,
&result[0], &result[1], &result[2]); &result[0], &result[1], &result[2]);

View File

@ -4759,24 +4759,78 @@ namespace netgen
if(!found_point) if(!found_point)
return; return;
auto mesh = GetMesh();
auto dim = mesh->GetDimension();
if(selelement>0) // found a surface element (possibliy behind clipping plane), check if drawn point really is in this element auto printScalValue = [](SolData & sol, int comp, double value)
{ {
double lami[3]; if(sol.components>1)
lami[0] = lami[1] = lami[2] = 0.0;
// Check if unprojected Point is close to surface element (eps of 1e-3 due to z-Buffer accuracy)
if(GetMesh()->PointContainedIn2DElement(p, lami, selelement, false) && fabs(lami[2])<1e-3)
{ {
double val; if(comp==0)
GetSurfValue(soldata[scalfunction], selelement-1, -1, 1.0-lami[0]-lami[1], lami[0], scalcomp, val); cout << "func(" << sol.name << ")";
cout << "surface function value: " << val << endl; else
cout << sol.name << "["+ToString(comp)+"]";
} }
// otherwise assume that the unprojected point is on the clipping plane -> find 3d element containing it else
else if(auto el3d = GetMesh()->GetElementOfPoint( p, lami )) cout << sol.name;
cout << " = " << value << endl;
};
if(selelement>0) // found a drawn point (clipping plane or surface element)
{
double lami[3] = {0.0, 0.0, 0.0};
// Check if unprojected Point is close to surface element (eps of 1e-3 due to z-Buffer accuracy)
bool found_2del = false;
if(mesh->PointContainedIn2DElement(p, lami, selelement, false && fabs(lami[2])<1e-3))
{ {
double val; // Found it, use coordinates of point projected to surface element
GetValue(soldata[scalfunction], el3d-1, lami[0], lami[1], lami[2], scalcomp, val); mesh->GetCurvedElements().CalcSurfaceTransformation({1.0-lami[0]-lami[1], lami[0]}, selelement-1, p);
cout << "clipping plane value: " << val << endl; found_2del = true;
}
cout << "Selected point " << p << " " << endl;
bool have_surf_scal_func = scalfunction!=-1 && soldata[scalfunction]->draw_surface && found_2del;
bool have_surf_vec_func = vecfunction!=-1 && soldata[vecfunction]->draw_surface && found_2del;
if(have_surf_scal_func || have_surf_vec_func)
{
cout << "Surface values:" << endl;
if(have_surf_scal_func)
{
auto & sol = *soldata[scalfunction];
double val;
GetSurfValue(&sol, selelement-1, -1, 1.0-lami[0]-lami[1], lami[0], scalcomp, val);
printScalValue(sol, scalcomp, val);
}
if(have_surf_vec_func)
{
auto & sol = *soldata[vecfunction];
ArrayMem<double, 10> values(sol.components);
GetSurfValues(&sol, selelement-1, -1, 1.0-lami[0]-lami[1], lami[0], &values[0]);
cout << sol.name << " = " << values;
}
}
bool have_vol_scal_func = scalfunction!=-1 && soldata[scalfunction]->draw_volume && !have_surf_scal_func;
bool have_vol_vec_func = vecfunction!=-1 && soldata[vecfunction]->draw_volume && !have_surf_vec_func;
// otherwise assume that the unprojected point is on the clipping plane -> find 3d element containing it
if(dim==3 && (have_vol_scal_func || have_vol_vec_func))
if(auto el3d = mesh->GetElementOfPoint( p, lami ))
{
cout << "Volume values:" << endl;
if(have_vol_scal_func)
{
auto & sol = *soldata[scalfunction];
double val;
GetValue(&sol, el3d-1, lami[0], lami[1], lami[2], scalcomp, val);
printScalValue(sol, scalcomp, val);
}
if(have_vol_vec_func)
{
auto & sol = *soldata[vecfunction];
ArrayMem<double, 10> values(sol.components);
GetValues(&sol, el3d-1, lami[0], lami[1], lami[2], &values[0]);
cout << sol.name << " = " << values;
}
} }
} }