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


C++ Grid3D::getNz方法代码示例

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


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

示例1: writeShape

void MeshFileManager::writeShape(const Grid3D &grid, const QString &path)
{
    QFile file(getRootPath() + path);
    if (!file.open(QIODevice::WriteOnly)) {
        return;
    }

    QTextStream stream(&file);
    stream  << "MeshVersionFormatted 1" << endl
            << "Dimension" << endl
            << "3" << endl;

    stream  << "Vertices" << endl
            <<  grid.getNx() * grid.getNy() * grid.getNz() << endl;

    for (int z = 0; z < grid.getNz(); ++z) {
        for (int y = 0; y < grid.getNy(); ++y) {
            for (int x = 0; x < grid.getNx(); ++x) {
                Point3D currentPoint(grid.getOrigin().getX() + x,
                                     grid.getOrigin().getY() + y,
                                     grid.getOrigin().getZ() + z);

                if (grid.getProperty(currentPoint.getX(), currentPoint.getY(), currentPoint.getZ()) < 0) {
                    stream << currentPoint.format()
                           << endl;
                }
            }
        }
    }

    stream << "End" << endl;
}
开发者ID:Beny13,项目名称:mod-3d-mesh,代码行数:32,代码来源:meshfilemanager.cpp

示例2: writeGeometry

void MeshFileManager::writeGeometry(const Grid3D &grid, const QString &path)
{
    QFile file(getRootPath() + path);
    if (!file.open(QIODevice::WriteOnly)) {
        return;
    }

    QTextStream stream(&file);
    stream  << "MeshVersionFormatted 1" << endl
            << "Dimension" << endl
            << "3" << endl;

    int nx = grid.getNx();
    int ny = grid.getNy();
    int nz = grid.getNz();
    Point3D origin = grid.getOrigin();

    stream  << "Vertices" << endl
            <<  nx * ny * nz << endl;
    QVector<Hexaedra> hexs;

    int xD = 1;
    int yD = nx;
    int zD = nx * ny;
    for (int z = 0; z < nz; ++z) {
        for (int y = 0; y < ny; ++y) {
            for (int x = 0; x < nx; ++x) {
                stream << Point3D(origin.getX() + x, origin.getY() + y, origin.getZ() + z).format()
                       << endl;

                if (!(x == nx - 1 || y == ny - 1 || z == nz - 1)) {
                    hexs.push_back(Hexaedra(
                        xD * (x + 0) + yD * (y + 0) + zD * (z + 0),
                        xD * (x + 1) + yD * (y + 0) + zD * (z + 0),
                        xD * (x + 1) + yD * (y + 1) + zD * (z + 0),
                        xD * (x + 0) + yD * (y + 1) + zD * (z + 0),
                        xD * (x + 0) + yD * (y + 0) + zD * (z + 1),
                        xD * (x + 1) + yD * (y + 0) + zD * (z + 1),
                        xD * (x + 1) + yD * (y + 1) + zD * (z + 1),
                        xD * (x + 0) + yD * (y + 1) + zD * (z + 1)
                    ));
                }
            }
        }
    }

    stream  << "Hexahedra" << endl
            << hexs.size() << endl;

    for (int i = 0; i < hexs.size(); ++i) {
        stream << hexs.at(i).format() << endl;
    }

    stream << "End" << endl;
}
开发者ID:Beny13,项目名称:mod-3d-mesh,代码行数:55,代码来源:meshfilemanager.cpp


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