Commit 050b91d1 authored by cyrush's avatar cyrush

add centroid option to spherical and elliptical compactness queries

git-svn-id: http://visit.ilight.com/svn/visit/trunk/src@23796 18c085ea-50e0-402c-830e-de6fd14e8384
parent 5172c68f
......@@ -109,6 +109,36 @@ avtEllipticalCompactnessFactorQuery::~avtEllipticalCompactnessFactorQuery()
delete rev_volume;
}
// ****************************************************************************
// Method: avtEllipticalCompactnessFactorQuery::SetInputParams
//
// Purpose:
// Set the input parameters.
//
// Programmer: Cyrus Harrison
// Creation: Wed Jul 16 15:58:54 PDT 2014
//
// Modifications:
//
// ****************************************************************************
void
avtEllipticalCompactnessFactorQuery::SetInputParams(const MapNode &params)
{
if(params.HasNumericVectorEntry("centroid"))
{
overrideCentroid = true;
doubleVector cvals;
params.GetEntry("centroid")->ToDoubleVector(cvals);
centroid[0] = cvals[0];
centroid[1] = cvals[1];
centroid[2] = cvals[2];
}else
{
overrideCentroid = false;
}
}
// ****************************************************************************
// Method: avtEllipticalCompactnessFactorQuery::PreExecute
......@@ -126,6 +156,9 @@ avtEllipticalCompactnessFactorQuery::~avtEllipticalCompactnessFactorQuery()
// Kathleen Biagas, Tue Apr 22 07:51:19 MST 2014
// Use double instead of float.
//
// Cyrus Harrison, Wed Jul 16 15:52:57 PDT 2014
// Added support for user selected center.
//
// ****************************************************************************
void
......@@ -133,8 +166,12 @@ avtEllipticalCompactnessFactorQuery::PreExecute(void)
{
avtTwoPassDatasetQuery::PreExecute();
for (int i = 0 ; i < 3 ; i++)
centroid[i] = 0.;
if(!overrideCentroid)
{
centroid[0] = 0.;
centroid[1] = 0.;
centroid[2] = 0.;
}
total_volume = 0.;
bounds[0] = +DBL_MAX;
......@@ -163,23 +200,30 @@ avtEllipticalCompactnessFactorQuery::PreExecute(void)
// Kathleen Biagas, Tue Apr 22 07:51:19 MST 2014
// Use double instead of float.
//
// Cyrus Harrison, Wed Jul 16 15:52:57 PDT 2014
// Added support for user selected center.
//
// ****************************************************************************
void
avtEllipticalCompactnessFactorQuery::MidExecute(void)
{
SumDoubleAcrossAllProcessors(total_volume);
double C_tmp[3] = { 0, 0, 0 };
SumDoubleArrayAcrossAllProcessors(centroid, C_tmp, 3);
if (total_volume != 0.)
if(!overrideCentroid)
{
C_tmp[0] /= total_volume;
C_tmp[1] /= total_volume;
C_tmp[2] /= total_volume;
double C_tmp[3] = { 0, 0, 0 };
SumDoubleArrayAcrossAllProcessors(centroid, C_tmp, 3);
if (total_volume != 0.)
{
C_tmp[0] /= total_volume;
C_tmp[1] /= total_volume;
C_tmp[2] /= total_volume;
}
centroid[0] = C_tmp[0];
centroid[1] = C_tmp[1];
centroid[2] = C_tmp[2];
}
centroid[0] = C_tmp[0];
centroid[1] = C_tmp[1];
centroid[2] = C_tmp[2];
// we need to unify the bounds across all processors.
UnifyMinMax(bounds,6);
......@@ -269,6 +313,9 @@ avtEllipticalCompactnessFactorQuery::MidExecute(void)
// Kathleen Biagas, Tue Feb 25 16:12:44 PST 2014
// Add Xml results.
//
// Cyrus Harrison, Wed Jul 16 15:52:57 PDT 2014
// Added support for user selected center.
//
// ****************************************************************************
void
......@@ -316,6 +363,8 @@ avtEllipticalCompactnessFactorQuery::PostExecute(void)
ec[0] = ellipse_center[0];
ec[1] = ellipse_center[1];
ec[2] = ellipse_center[2];
result_node["override_centroid"] = overrideCentroid;
result_node["centroid"] = ec;
result_node["elliptical_compactness_factor"] = biggestVal / total_volume;
SetXmlResult(result_node.ToXML());
......@@ -336,6 +385,9 @@ avtEllipticalCompactnessFactorQuery::PostExecute(void)
// Kathleen Biagas, Tue Apr 22 07:51:19 MST 2014
// Use double instead of float for volume.
//
// Cyrus Harrison, Wed Jul 16 15:52:57 PDT 2014
// Added support for user selected center.
//
// ****************************************************************************
void
......@@ -357,9 +409,14 @@ avtEllipticalCompactnessFactorQuery::Execute1(vtkDataSet *ds, const int dom)
vtkVisItUtility::GetCellCenter(cell, center);
double volume = var->GetTuple1(i);
volume = (volume < 0 ? -volume : volume);
centroid[0] += volume*center[0];
centroid[1] += volume*center[1];
centroid[2] += volume*center[2];
if(!overrideCentroid)
{
centroid[0] += volume*center[0];
centroid[1] += volume*center[1];
centroid[2] += volume*center[2];
}
bounds[0] = (center[0] < bounds[0] ? center[0] : bounds[0]);
bounds[1] = (center[0] > bounds[1] ? center[0] : bounds[1]);
bounds[2] = (center[1] < bounds[2] ? center[1] : bounds[2]);
......
......@@ -68,6 +68,10 @@ class avtRevolvedVolume;
// Programmer: Hank Childs
// Creation: May 16, 2006
//
// Modifications:
// Cyrus Harrison, Wed Jul 16 15:52:57 PDT 2014
// Added support for user selected center.
//
// ****************************************************************************
class QUERY_API avtEllipticalCompactnessFactorQuery
......@@ -82,7 +86,13 @@ class QUERY_API avtEllipticalCompactnessFactorQuery
virtual const char *GetDescription(void)
{return "Calculating Elliptical Compactness Factor";};
virtual void SetInputParams(const MapNode &);
protected:
bool overrideCentroid;
double centroid[3];
double ellipse_center[3];
// NOTE: numGuesses should have an integer sqrt.
......
......@@ -110,6 +110,38 @@ avtSphericalCompactnessFactorQuery::~avtSphericalCompactnessFactorQuery()
}
// ****************************************************************************
// Method: avtSphericalCompactnessFactorQuery::SetInputParams
//
// Purpose:
// Set the input parameters.
//
// Programmer: Cyrus Harrison
// Creation: Wed Jul 16 15:58:54 PDT 2014
//
// Modifications:
//
// ****************************************************************************
void
avtSphericalCompactnessFactorQuery::SetInputParams(const MapNode &params)
{
if(params.HasNumericVectorEntry("centroid"))
{
overrideCentroid = true;
doubleVector cvals;
params.GetEntry("centroid")->ToDoubleVector(cvals);
centroid[0] = cvals[0];
centroid[1] = cvals[1];
centroid[2] = cvals[2];
}else
{
overrideCentroid = false;
}
}
// ****************************************************************************
// Method: avtSphericalCompactnessFactorQuery::PreExecute
//
......@@ -123,6 +155,9 @@ avtSphericalCompactnessFactorQuery::~avtSphericalCompactnessFactorQuery()
// Jeremy Meredith, Thu Feb 15 11:55:03 EST 2007
// Call inherited PreExecute before everything else.
//
// Cyrus Harrison, Wed Jul 16 15:52:57 PDT 2014
// Added support for user selected center.
//
// ****************************************************************************
void
......@@ -130,8 +165,13 @@ avtSphericalCompactnessFactorQuery::PreExecute(void)
{
avtTwoPassDatasetQuery::PreExecute();
for (int i = 0 ; i < 3 ; i++)
centroid[i] = 0.;
if(!overrideCentroid)
{
centroid[0] = 0.;
centroid[1] = 0.;
centroid[2] = 0.;
}
total_volume = 0.;
}
......@@ -145,23 +185,30 @@ avtSphericalCompactnessFactorQuery::PreExecute(void)
// Programmer: Hank Childs
// Creation: July 14, 2005
//
// Modifications:
// Cyrus Harrison, Wed Jul 16 15:52:57 PDT 2014
// Added support for user selected center.
//
// ****************************************************************************
void
avtSphericalCompactnessFactorQuery::MidExecute(void)
{
SumDoubleAcrossAllProcessors(total_volume);
double C_tmp[3] = { 0, 0, 0 };
SumDoubleArrayAcrossAllProcessors(centroid, C_tmp, 3);
if (total_volume != 0.)
if(!overrideCentroid)
{
C_tmp[0] /= total_volume;
C_tmp[1] /= total_volume;
C_tmp[2] /= total_volume;
double C_tmp[3] = { 0, 0, 0 };
SumDoubleArrayAcrossAllProcessors(centroid, C_tmp, 3);
if (total_volume != 0.)
{
C_tmp[0] /= total_volume;
C_tmp[1] /= total_volume;
C_tmp[2] /= total_volume;
}
centroid[0] = C_tmp[0];
centroid[1] = C_tmp[1];
centroid[2] = C_tmp[2];
}
centroid[0] = C_tmp[0];
centroid[1] = C_tmp[1];
centroid[2] = C_tmp[2];
volume_inside = 0.;
radius = pow(total_volume*0.75/M_PI, 0.3333333);
......@@ -197,6 +244,9 @@ avtSphericalCompactnessFactorQuery::MidExecute(void)
// Kathleen Biagas, Tue Feb 25 16:16:13 PST 2014
// Add Xml results.
//
// Cyrus Harrison, Wed Jul 16 15:52:57 PDT 2014
// Added support for user selected center.
//
// ****************************************************************************
void
......@@ -229,10 +279,13 @@ avtSphericalCompactnessFactorQuery::PostExecute(void)
SetResultValue(volume_inside / total_volume);
MapNode result_node;
result_node["radius"] = radius;
doubleVector sc(3);
sc[0] = sphere_center[0];
sc[1] = sphere_center[1];
sc[2] = sphere_center[2];
result_node["override_centroid"] = overrideCentroid;
result_node["centroid"] = sc;
result_node["spherical_compactness_factor"] = volume_inside / total_volume;
SetXmlResult(result_node.ToXML());
......@@ -274,9 +327,14 @@ avtSphericalCompactnessFactorQuery::Execute1(vtkDataSet *ds, const int dom)
vtkVisItUtility::GetCellCenter(cell, center);
double volume = var->GetTuple1(i);
volume = (volume < 0 ? -volume : volume);
centroid[0] += volume*center[0];
centroid[1] += volume*center[1];
centroid[2] += volume*center[2];
if(!overrideCentroid)
{
centroid[0] += volume*center[0];
centroid[1] += volume*center[1];
centroid[2] += volume*center[2];
}
total_volume += volume;
}
}
......
......@@ -69,6 +69,10 @@ class avtRevolvedVolume;
// Programmer: Hank Childs
// Creation: July 14, 2005
//
// Modifications:
// Cyrus Harrison, Wed Jul 16 15:52:57 PDT 2014
// Added support for user selected center.
//
// ****************************************************************************
class QUERY_API avtSphericalCompactnessFactorQuery
......@@ -83,7 +87,12 @@ class QUERY_API avtSphericalCompactnessFactorQuery
virtual const char *GetDescription(void)
{return "Calculating Spherical Compactness Factor";};
virtual void SetInputParams(const MapNode &);
protected:
bool overrideCentroid;
double centroid[3];
double sphere_center[3];
double radius;
......
......@@ -87,20 +87,20 @@ static const char *WindowType_strings[] = {
"ActualDataVars", "LineDistribution", "HohlraumFlux",
"ConnCompSummary", "ShapeletsDecomp", "XRayImage",
"LineSamplerInfo", "StreamlineInfo", "Pick",
"Lineout"};
"Lineout", "Compactness"};
std::string
QueryList::WindowType_ToString(QueryList::WindowType t)
{
int index = int(t);
if(index < 0 || index >= 16) index = 0;
if(index < 0 || index >= 17) index = 0;
return WindowType_strings[index];
}
std::string
QueryList::WindowType_ToString(int t)
{
int index = (t < 0 || t >= 16) ? 0 : t;
int index = (t < 0 || t >= 17) ? 0 : t;
return WindowType_strings[index];
}
......@@ -108,7 +108,7 @@ bool
QueryList::WindowType_FromString(const std::string &s, QueryList::WindowType &val)
{
val = QueryList::Basic;
for(int i = 0; i < 16; ++i)
for(int i = 0; i < 17; ++i)
{
if(s == WindowType_strings[i])
{
......
......@@ -85,7 +85,8 @@ public:
LineSamplerInfo,
StreamlineInfo,
Pick,
Lineout
Lineout,
Compactness
};
enum Groups
{
......
......@@ -22,6 +22,7 @@
StreamlineInfo
Pick
Lineout
Compactness
</Enum>
<Enum name="Groups">
CurveRelated
......
......@@ -945,6 +945,9 @@ QvisQueryWindow::UpdateResults(bool)
// Kathleen Biagas, Fri Jun 10 08:59:32 PDT 2011
// Added pickQueryWidget.
//
// Cyrus Harrison, Thu Jul 17 09:16:39 PDT 2014
// Added GUI case for Compactness queries.
//
// ****************************************************************************
void
......@@ -1126,6 +1129,12 @@ QvisQueryWindow::UpdateArgumentPanel(const QString &qname)
showDumpCoordinates = true;
showDumpValues = true;
}
else if (winT == QueryList::Compactness)
{
labels[0]->setText(tr("Centroid"));
textFields[0]->setText("default");
showWidgets[0] = true;
}
// hide and show the right text widgets.
for(int i = 0; i < 6; ++i)
......@@ -1579,6 +1588,25 @@ QvisQueryWindow::ExecuteStandardQuery()
if (!pickQueryWidget->GetQueryParameters(queryParams))
noErrors = false;
}
else if(winT == QueryList::Compactness)
{
string cen_txt = textFields[0]->text().simplified().toStdString();
if(cen_txt != "default")
{
doubleVector vals(3,0.0);
int vlen = sscanf(cen_txt.c_str(), "%lg %lg %lg",
&vals[0], &vals[1], &vals[2]);
if(vlen > 0)
{
queryParams["centroid"] = vals;
}
else
{
noErrors = false;
}
}
}
if(!timeQueryOptions->isCheckable() || timeQueryOptions->isChecked())
{
......
......@@ -81,6 +81,7 @@ public class QueryList extends AttributeSubject
public final static int WINDOWTYPE_STREAMLINEINFO = 13;
public final static int WINDOWTYPE_PICK = 14;
public final static int WINDOWTYPE_LINEOUT = 15;
public final static int WINDOWTYPE_COMPACTNESS = 16;
public final static int GROUPS_CURVERELATED = 0;
public final static int GROUPS_MESHRELATED = 1;
......
......@@ -4121,8 +4121,9 @@ ViewerQueryManager::InitializeQueryList()
QueryList::WindowType xri = QueryList::XRayImage;
QueryList::WindowType sli = QueryList::StreamlineInfo;
QueryList::WindowType lsi = QueryList::LineSamplerInfo;
QueryList::WindowType pick = QueryList::Pick;
QueryList::WindowType line = QueryList::Lineout;
QueryList::WindowType pick = QueryList::Pick;
QueryList::WindowType line = QueryList::Lineout;
QueryList::WindowType compact = QueryList::Compactness;
QueryList::QueryMode qo = QueryList::QueryOnly;
QueryList::QueryMode qt = QueryList::QueryAndTime;
......@@ -4164,8 +4165,8 @@ ViewerQueryManager::InitializeQueryList()
queryTypes->AddQuery("Moment of Inertia", dq, mr, basic, 1, 0, qo);
queryTypes->AddQuery("Centroid", dq, mr, basic, 1, 0, qo);
queryTypes->AddQuery("Localized Compactness Factor", dq, sr, basic, 1, 0, qt);
queryTypes->AddQuery("Elliptical Compactness Factor", dq, sr, basic, 1, 0, qt);
queryTypes->AddQuery("Spherical Compactness Factor", dq, sr, basic, 1, 0, qt);
queryTypes->AddQuery("Elliptical Compactness Factor", dq, sr, compact, 1, 0, qt);
queryTypes->AddQuery("Spherical Compactness Factor", dq, sr, compact, 1, 0, qt);
queryTypes->AddQuery("Average Mean Curvature", dq, mr, basic, 1, 0, qt);
queryTypes->AddQuery("Average Value", dq, vr, basic, 1, 0, qt);
queryTypes->AddQuery("Variable Sum", dq, vr, basic, 1, 0, qt);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment