Files
test/source/blender/io/usd/tests/usd_imaging_test.cc
Campbell Barton e955c94ed3 License Headers: Set copyright to "Blender Authors", add AUTHORS
Listing the "Blender Foundation" as copyright holder implied the Blender
Foundation holds copyright to files which may include work from many
developers.

While keeping copyright on headers makes sense for isolated libraries,
Blender's own code may be refactored or moved between files in a way
that makes the per file copyright holders less meaningful.

Copyright references to the "Blender Foundation" have been replaced with
"Blender Authors", with the exception of `./extern/` since these this
contains libraries which are more isolated, any changed to license
headers there can be handled on a case-by-case basis.

Some directories in `./intern/` have also been excluded:

- `./intern/cycles/` it's own `AUTHORS` file is planned.
- `./intern/opensubdiv/`.

An "AUTHORS" file has been added, using the chromium projects authors
file as a template.

Design task: #110784

Ref !110783.
2023-08-16 00:20:26 +10:00

65 lines
2.0 KiB
C++

/* SPDX-FileCopyrightText: 2022 Blender Authors
*
* SPDX-License-Identifier: GPL-2.0-or-later */
#include "testing/testing.h"
#include <pxr/usd/usd/stage.h>
#include <pxr/usd/usdGeom/capsule.h>
#include <pxr/usdImaging/usdImaging/capsuleAdapter.h>
namespace blender::io::usd {
class USDImagingTest : public testing::Test {
};
TEST_F(USDImagingTest, CapsuleAdapterTest)
{
/* A simple test to exercise the UsdImagingGprimAdapter API to
* ensure the code compiles, links and returns reasonable results.
* We create a capsule shape on an in-memory stage and attempt
* to access the shape's points and topology. */
pxr::UsdStageRefPtr stage = pxr::UsdStage::CreateInMemory();
if (!stage) {
FAIL() << "Couldn't create in-memory stage.";
return;
}
pxr::UsdGeomCapsule capsule = pxr::UsdGeomCapsule::Define(stage, pxr::SdfPath("/Capsule"));
if (!capsule) {
FAIL() << "Couldn't create UsdGeomCapsule.";
return;
}
pxr::UsdImagingCapsuleAdapter capsule_adapter;
pxr::VtValue points_value = capsule_adapter.GetPoints(capsule.GetPrim(),
pxr::UsdTimeCode::Default());
if (!points_value.IsHolding<pxr::VtArray<pxr::GfVec3f>>()) {
FAIL() << "Mesh points value holding unexpected type.";
return;
}
pxr::VtArray<pxr::GfVec3f> points = points_value.Get<pxr::VtArray<pxr::GfVec3f>>();
EXPECT_FALSE(points.empty());
pxr::VtValue topology_value = capsule_adapter.GetTopology(
capsule.GetPrim(), pxr::SdfPath(), pxr::UsdTimeCode::Default());
if (!topology_value.IsHolding<pxr::HdMeshTopology>()) {
FAIL() << "Mesh topology value holding unexpected type.";
return;
}
pxr::HdMeshTopology topology = topology_value.Get<pxr::HdMeshTopology>();
pxr::VtArray<int> vertex_counts = topology.GetFaceVertexCounts();
EXPECT_FALSE(vertex_counts.empty());
pxr::VtArray<int> vertex_indices = topology.GetFaceVertexIndices();
EXPECT_FALSE(vertex_indices.empty());
}
} // namespace blender::io::usd