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


C++ VRTransformPtr::push_back方法代码示例

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


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

示例1: loadVtk

void loadVtk(string path, VRTransformPtr res) {
    cout << "load VTK file " << path << endl;
    VRGeoData geo;

    vtkDataSetReader* reader = vtkDataSetReader::New();
    reader->SetFileName(path.c_str());
    reader->ReadAllScalarsOn();
    reader->ReadAllVectorsOn();
    reader->ReadAllNormalsOn();
    reader->ReadAllTensorsOn();
    reader->ReadAllTCoordsOn();
    reader->ReadAllFieldsOn();
    reader->ReadAllColorScalarsOn();
    reader->Update();

    vtkDataSet* dataset = reader->GetOutput();

    int npoints = dataset->GetNumberOfPoints();
    int ncells = dataset->GetNumberOfCells();
    int nscalars = reader->GetNumberOfScalarsInFile();
    int nvectors = reader->GetNumberOfVectorsInFile();
    int ntensors = reader->GetNumberOfTensorsInFile();
    cout << "dataset sizes: " << npoints << " " << ncells << " " << nscalars << " " << nvectors << " " << ntensors << endl;

    for (int i=0; i<npoints; i++) {
        auto p = dataset->GetPoint(i);
        Vec3d v(p[0], p[1], p[2]);
        geo.pushVert(v);
        cout << "point " << v << endl;
    }

    auto getCellPIDs = [](vtkCell* c) {
        vector<int> res;
        auto ids = c->GetPointIds();
        for (int k=0; k<ids->GetNumberOfIds(); k++) {
            res.push_back( ids->GetId(k) );
        }
        return res;
    };

    for (int i=0; i<ncells; i++) {
        vtkCell* c = dataset->GetCell(i);
        //int d = c->GetCellDimension();
        //int t = c->GetCellType();

        string type = c->GetClassName();
        cout << "cell type " << type << endl;
        if (type == "vtkQuad") {
            auto j = getCellPIDs(c);
            geo.pushQuad(j[0], j[1], j[2], j[3]);
        }
    }

    //vtkCellData* cells = dataset->GetCellData();
    vtkPointData* points = dataset->GetPointData();

    cout << "POINT_DATA:\n";
    if (points) {
        std::cout << " contains point data with " << points->GetNumberOfArrays() << " arrays." << std::endl;
        for (int i = 0; i < points->GetNumberOfArrays(); i++) {
            std::cout << "\tArray " << i << " is named " << (points->GetArrayName(i) ? points->GetArrayName(i) : "NULL") << std::endl;
        }

        for(int i=0; vtkDataArray* a = points->GetArray(i); i++ ) {
            int size = a->GetNumberOfTuples();
            int comp = a->GetNumberOfComponents();
            cout << " data array " << size << " " << comp << endl;

            for (int j=0; j<size; j++) {
                cout << "pnt:";
                for (int k=0; k<comp; k++) cout << " " << a->GetComponent(j, k);
                cout << endl;
            }
        }
    }


    cout << "FIELD_DATA:\n";
     if (dataset->GetFieldData()) {
       std::cout << " contains field data with "
            << dataset->GetFieldData()->GetNumberOfArrays()
             << " arrays." << std::endl;
        for (int i = 0; i < dataset->GetFieldData()->GetNumberOfArrays(); i++)
          {
          std::cout << "\tArray " << i
               << " is named " << dataset->GetFieldData()->GetArray(i)->GetName()
               << std::endl;
          }
        }


    cout << "CELL_DATA:\n";

     vtkCellData *cd = dataset->GetCellData();
      if (cd)
        {
        std::cout << " contains cell data with "
             << cd->GetNumberOfArrays()
             << " arrays." << std::endl;
        for (int i = 0; i < cd->GetNumberOfArrays(); i++)
//.........这里部分代码省略.........
开发者ID:Victor-Haefner,项目名称:polyvr,代码行数:101,代码来源:VRVTK.cpp


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