Skip to content

Commit

Permalink
Handle Unstructured Points Case when points are unused (#19250) (#19282)
Browse files Browse the repository at this point in the history
  • Loading branch information
JustinPrivitera committed Feb 2, 2024
1 parent e2c849a commit 2b8d61a
Show file tree
Hide file tree
Showing 5 changed files with 94 additions and 25 deletions.
3 changes: 3 additions & 0 deletions data/blueprint_v0.8.7_unstructured_points.tar.xz
Git LFS file not shown
81 changes: 56 additions & 25 deletions src/avt/Blueprint/avtConduitBlueprintDataAdaptor.C
Original file line number Diff line number Diff line change
Expand Up @@ -659,8 +659,20 @@ ExplicitCoordsToVTKPoints(const Node &n_coords, const Node &n_topo)
}

points->SetDataTypeToDouble();
points->SetNumberOfPoints(npts);

int n_elems = npts;
if (n_topo["type"].as_string() == "unstructured" &&
n_topo.has_path("elements/shape") &&
n_topo["elements/shape"].as_string() == "point" &&
n_topo["elements/connectivity"].dtype().number_of_elements() != npts)
{
n_elems = n_topo["elements/connectivity"].dtype().number_of_elements();
points->SetNumberOfPoints(n_elems);
}
else
{
points->SetNumberOfPoints(npts);
}

if(ndstrided) // strided case
{
Expand All @@ -686,12 +698,28 @@ ExplicitCoordsToVTKPoints(const Node &n_coords, const Node &n_topo)
}
else // default, simplest case
{
for (vtkIdType i = 0; i < npts; i++)
// we need to look at the topo to decide what points to write
// we are in the unstructured case
if (npts != n_elems)
{
int_accessor conn = n_topo["elements/connectivity"].value();
for (vtkIdType i = 0; i < n_elems; i++)
{
double x = x_vals[conn[i]];
double y = have_y ? y_vals[conn[i]] : 0;
double z = have_z ? z_vals[conn[i]] : 0;
points->SetPoint(i, x, y, z);
}
}
else
{
double x = x_vals[i];
double y = have_y ? y_vals[i] : 0;
double z = have_z ? z_vals[i] : 0;
points->SetPoint(i, x, y, z);
for (vtkIdType i = 0; i < npts; i++)
{
double x = x_vals[i];
double y = have_y ? y_vals[i] : 0;
double z = have_z ? z_vals[i] : 0;
points->SetPoint(i, x, y, z);
}
}
}

Expand Down Expand Up @@ -722,34 +750,37 @@ ExplicitCoordsToVTKPoints(const Node &n_coords, const Node &n_topo)
//
// Justin Privitera, Mon Aug 22 17:15:06 PDT 2022
// Moved from blueprint plugin to conduit blueprint data adaptor.
//
// Justin Privitera, Thu Jan 18 14:53:32 PST 2024
// Added back in logic for unstructured points.
//
// ****************************************************************************

vtkCellArray *
HomogeneousShapeTopologyToVTKCellArray(const Node &n_topo,
int /* npts -- UNUSED */)
int npts)
{
vtkCellArray *ca = vtkCellArray::New();
vtkIdTypeArray *ida = vtkIdTypeArray::New();

// TODO, I don't think we need this logic any more
// // Handle empty and point topology
// if (!n_topo.has_path("elements/connectivity") ||
// (n_topo.has_path("elements/shape") &&
// n_topo["elements/shape"].as_string() == "point"))
// {
// // TODO, why is this 2 * npts?
// ida->SetNumberOfTuples(2*npts);
// for (int i = 0 ; i < npts; i++)
// {
// ida->SetComponent(2*i , 0, 1);
// ida->SetComponent(2*i+1, 0, i);
// }
// ca->SetCells(npts, ida);
// ida->Delete();
// }
// else
// {
// Handle empty and point topology
if (!n_topo.has_path("elements/connectivity") ||
(n_topo.has_path("elements/shape") &&
n_topo["elements/shape"].as_string() == "point"))
{
// TODO, why is this 2 * npts?
ida->SetNumberOfTuples(2*npts);
for (int i = 0 ; i < npts; i++)
{
ida->SetComponent(2*i , 0, 1);
ida->SetComponent(2*i+1, 0, i);
}
ca->SetCells(npts, ida);
ida->Delete();
}
else
{

int ctype = ElementShapeNameToVTKCellType(n_topo["elements/shape"].as_string());
int csize = VTKCellTypeSize(ctype);
Expand Down Expand Up @@ -779,7 +810,7 @@ HomogeneousShapeTopologyToVTKCellArray(const Node &n_topo,
}
ca->SetCells(ncells, ida);
ida->Delete();
// }
}
return ca;
}

Expand Down
1 change: 1 addition & 0 deletions src/resources/help/en_US/relnotes3.4.1.html
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
<li>Fixed a bug with the Expression window that caused the 'Python' editor to be the default tab when the window was first opened.</li>
<li>Fixed a bug with the Cartographic Projection operator where the projections were a no-op.</li>
<li>Removed custom logic forcing the opacity slider to snap to zero if the mouse dragged the slider outside the widget it belongs to.</li>
<li>Fixed a bug in the Blueprint reader causing unstructured point topologies to display incorrectly if they did not use all of the provided coordinates.</li>
</ul>

<a name="Enhancements"></a>
Expand Down
31 changes: 31 additions & 0 deletions src/test/tests/databases/blueprint.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@
#
# Justin Privitera, Wed Oct 25 17:29:07 PDT 2023
# Added a test for a polygonal mesh with no offsets.
#
# Justin Privitera, Thu Jan 18 14:53:32 PST 2024
# Added test for unstructured points.
#
# ----------------------------------------------------------------------------
RequiredDatabasePlugin("Blueprint")
Expand All @@ -59,6 +62,7 @@
bp_1d_curve_test_dir = "blueprint_v0.8.6_1d_curve_examples"
bp_venn_modded_matnos_dir = "blueprint_v0.8.7_venn_modded_matnos_example"
bp_poly_no_offsets_dir = "blueprint_v0.8.7_polytopal_mesh_no_offsets"
bp_unstructured_points_dir = "blueprint_v0.8.7_unstructured_points"

braid_2d_hdf5_root = data_path(pjoin(bp_test_dir,"braid_2d_examples.blueprint_root_hdf5"))
braid_3d_hdf5_root = data_path(pjoin(bp_test_dir,"braid_3d_examples.blueprint_root_hdf5"))
Expand All @@ -81,6 +85,8 @@

uniform_root = data_path(pjoin(bp_test_dir,"uniform.cycle_001038.root"))

unstructured_points = data_path(pjoin(bp_unstructured_points_dir,"unstructured_points.cycle_000100.root"))

#
# venn test data (multi material)
#
Expand Down Expand Up @@ -757,4 +763,29 @@ def test_paren_vars():
DeleteAllPlots()
ResetView()

TestSection("Blueprint Unstructured Points not using the entire coordset, 0.8.7")
OpenDatabase(unstructured_points)
AddPlot("Pseudocolor", "mesh_mesh/braid", 1, 1)
SetActivePlots(0)
PseudocolorAtts = PseudocolorAttributes()
PseudocolorAtts.pointSizePixels = 20
SetPlotOptions(PseudocolorAtts)
AddPlot("Label", "mesh_mesh/braid", 1, 1)
DrawPlots()
View3DAtts = View3DAttributes()
View3DAtts.viewNormal = (-0.64536, -0.104723, 0.756666)
View3DAtts.focus = (10, 0, 0)
View3DAtts.viewUp = (-0.0863273, 0.994211, 0.0639709)
View3DAtts.viewAngle = 30
View3DAtts.parallelScale = 14.1421
View3DAtts.nearPlane = -28.2843
View3DAtts.farPlane = 28.2843
View3DAtts.centerOfRotationSet = 0
View3DAtts.centerOfRotation = (10, 0, 0)
SetView3D(View3DAtts)
DrawPlots()
Test("Unstructured_points_not_using_entire_coordset")
DeleteAllPlots()
ResetView()

Exit()
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 2b8d61a

Please sign in to comment.