当前位置: 首页>>代码示例>>C++>>正文


C++ Array1::constAccessor方法代码示例

本文整理汇总了C++中Array1::constAccessor方法的典型用法代码示例。如果您正苦于以下问题:C++ Array1::constAccessor方法的具体用法?C++ Array1::constAccessor怎么用?C++ Array1::constAccessor使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Array1的用法示例。


在下文中一共展示了Array1::constAccessor方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: frame

JET_BEGIN_TEST_F(PhysicsAnimation, SimpleMassSpringAnimation)
{
    Array1<double> x;
    Array1<double> y;

    SimpleMassSpringAnimation anim;
    anim.makeChain(10);
    anim.wind = std::make_shared<ConstantVectorField3>(Vector3D(30.0, 0.0, 0.0));
    anim.constraints.push_back(SimpleMassSpringAnimation::Constraint{0, Vector3D(), Vector3D()});
    anim.exportStates(x, y);

    char filename[256];
    snprintf(filename, sizeof(filename), "data.#line2,0000,x.npy");
    saveData(x.constAccessor(), filename);
    snprintf(filename, sizeof(filename), "data.#line2,0000,y.npy");
    saveData(y.constAccessor(), filename);

    Frame frame(1, 1.0 / 60.0);
    for ( ; frame.index < 360; frame.advance())
    {
        anim.update(frame);
        anim.exportStates(x, y);

        snprintf(filename, sizeof(filename), "data.#line2,%04d,x.npy", frame.index);
        saveData(x.constAccessor(), filename);
        snprintf(filename, sizeof(filename), "data.#line2,%04d,y.npy", frame.index);
        saveData(y.constAccessor(), filename);
    }
}
开发者ID:sumitneup,项目名称:fluid-engine-dev,代码行数:29,代码来源:physics_animation_tests.cpp

示例2: grid

JET_BEGIN_TEST_F(ZhuBridsonPointsToImplicit3, ConvertTwo) {
    Array1<Vector3D> points;

    std::mt19937 rng{0};
    std::uniform_real_distribution<> dist(0.2, 0.8);
    for (size_t i = 0; i < 2; ++i) {
        points.append({dist(rng), dist(rng), dist(rng)});
    }

    VertexCenteredScalarGrid3 grid(128, 128, 128, 1.0 / 128, 1.0 / 128,
                                   1.0 / 128);

    ZhuBridsonPointsToImplicit3 converter(0.6, 0.25);
    converter.convert(points.constAccessor(), &grid);

    TriangleMesh3 triMesh;
    marchingCubes(grid.constDataAccessor(), grid.gridSpacing(),
                  grid.dataOrigin(), &triMesh, 0, kDirectionAll);

    saveTriangleMeshData(triMesh,
                         "zhu_bridson_points_to_implicit3_convert_two.obj");
}
开发者ID:doyubkim,项目名称:fluid-engine-dev,代码行数:22,代码来源:zhu_bridson_points_to_implicit3_tests.cpp

示例3:

TEST(SphSystemData3, Particles) {
    SphSystemData3 data;

    data.setTargetSpacing(1.0);
    data.setRelativeKernelRadius(1.0);

    data.addParticle(Vector3D(0, 0, 0));
    data.addParticle(Vector3D(1, 0, 0));

    data.buildNeighborSearcher();
    data.updateDensities();

    // See if we get symmetric density profile
    auto den = data.densities();
    EXPECT_LT(0.0, den[0]);
    EXPECT_EQ(den[0], den[1]);

    Array1<double> values = {1.0, 1.0};
    double midVal = data.interpolate(
        Vector3D(0.5, 0, 0), values.constAccessor());
    EXPECT_LT(0.0, midVal);
    EXPECT_GT(1.0, midVal);
}
开发者ID:doyubkim,项目名称:fluid-engine-dev,代码行数:23,代码来源:sph_system_data3_tests.cpp


注:本文中的Array1::constAccessor方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。