コード例 #1
0
int main(int argc, char **argv)
{
  vtkMultiProcessController *controller=Initialize(&argc,&argv);
  int worldRank=controller->GetLocalProcessId();
  int worldSize=controller->GetNumberOfProcesses();

  // configure
  std::string dataRoot;
  std::string tempDir;
  std::string baseline;
  BroadcastConfiguration(controller,argc,argv,dataRoot,tempDir,baseline);

  std::string inputFileName;
  inputFileName=dataRoot+"/Data/SciberQuestToolKit/MagneticIslands/MagneticIslands.bov";

  std::string logFileName;
  logFileName=NativePath(tempDir+"/SciberQuestToolKit-TestFieldTracer.log");
  vtkSQLog::GetGlobalInstance()->SetFileName(logFileName.c_str());
  vtkSQLog::GetGlobalInstance()->SetGlobalLevel(1);

  // pipeline 1
  // ooc reader
  vtkSQBOVMetaReader *mr=vtkSQBOVMetaReader::New();
  mr->SetFileName(inputFileName.c_str());
  mr->SetPointArrayStatus("b",1);
  mr->SetNumberOfGhostCells(2);
  mr->SetXHasPeriodicBC(1);
  mr->SetYHasPeriodicBC(1);
  mr->SetZHasPeriodicBC(1);
  mr->SetBlockSize(8,8,8);
  mr->SetBlockCacheSize(1);

  // seed points
  vtkSQLineSource *p1=vtkSQLineSource::New();
  p1->SetPoint1(-0.125,-0.125,0.0);
  p1->SetPoint2(-0.5,-0.5,0.0);
  p1->SetResolution(3);

  // field tracer
  vtkSQFieldTracer *ft=vtkSQFieldTracer::New();
  ft->SetMode(vtkSQFieldTracer::MODE_STREAM);
  ft->SetIntegratorType(vtkSQFieldTracer::INTEGRATOR_RK4);
  ft->SetMaxStep(0.01);
  ft->SetMaxLineLength(300);
  //ft->SetMinSegmentLength(0.2); TODO --- this feature has a bug.
  ft->SetNullThreshold(0.001);
  ft->SetForwardOnly(0);
  ft->SetUseDynamicScheduler(0);
  ft->AddInputConnection(0,mr->GetOutputPort(0));
  ft->AddInputConnection(1,p1->GetOutputPort(0));
  ft->SetInputArrayToProcess(0,0,0,vtkDataObject::FIELD_ASSOCIATION_POINTS,"b");
  mr->Delete();
  p1->Delete();

  // pids
  vtkProcessIdScalars *pid=vtkProcessIdScalars::New();
  pid->SetInputConnection(0,ft->GetOutputPort(0));
  ft->Delete();

  // tubes
  vtkSQTubeFilter *tf=vtkSQTubeFilter::New();
  tf->SetRadius(0.025);
  tf->SetNumberOfSides(16);
  tf->SetInputConnection(pid->GetOutputPort(0));
  pid->Delete();

  // execute
  GetParallelExec(worldRank,worldSize,tf,0.0);
  tf->Update();

  int testStatus = SerialRender(
        controller,
        (vtkPolyData*)tf->GetOutput(),
        true,
        tempDir,
        baseline,
        "SciberQuestToolKit-TestFieldTracer",
        600,600,
        13,13,13,
        0,0,0,
        0,0,1,
        1.1,
        30.0);

  tf->Delete();

  return Finalize(controller,testStatus==vtkTesting::PASSED?0:1);
}
コード例 #2
0
int TestPlaneSource(int argc, char *argv[])
{
  vtkMultiProcessController *controller=Initialize(&argc,&argv);
  int worldRank=controller->GetLocalProcessId();
  int worldSize=controller->GetNumberOfProcesses();

  // configure
  std::string dataRoot;
  std::string tempDir;
  std::string baseline;
  BroadcastConfiguration(controller,argc,argv,dataRoot,tempDir,baseline);

  std::string logFileName;
  logFileName=NativePath(tempDir+"/SciberQuestToolKit-TestPlaneSource.log");
  vtkSQLog::GetGlobalInstance()->SetFileName(logFileName.c_str());
  vtkSQLog::GetGlobalInstance()->SetGlobalLevel(1);

  // plane
  const int nResolutions=4;
  int resolution[nResolutions][2]={
        {1,1,},
        {537,1,},
        {1,537,},
        {127,67},
        };

  const int nDecomps=2;
  int decomp[nDecomps]={
        vtkSQPlaneSource::DECOMP_TYPE_STRIPS,
        vtkSQPlaneSource::DECOMP_TYPE_PATCHES
        };

  const char *decompName[nDecomps]={
        "Strips",
        "Patches"};

  int ext[6]={-1,1,-1,1,0,0};

  int aTestFailed=0;
  for (int i=0; i<nResolutions; ++i)
    {
    for (int j=0; j<nDecomps; ++j)
      {
      int *res=resolution[i];

      vtkSQPlaneSource *p=vtkSQPlaneSource::New();
      p->SetOrigin(ext[0],ext[2],ext[4]);
      p->SetPoint1(ext[1],ext[2],ext[4]);
      p->SetPoint2(ext[0],ext[3],ext[4]);
      p->SetXResolution(res[0]);
      p->SetYResolution(res[1]);
      p->SetDecompType(decomp[j]);

      // process id
      vtkProcessIdScalars *pid=vtkProcessIdScalars::New();
      pid->SetInputConnection(0,p->GetOutputPort(0));
      p->Delete();

      // execute
      GetParallelExec(worldRank, worldSize, pid, 0.0);
      pid->Update();

      vtkPolyData *output=dynamic_cast<vtkPolyData*>(pid->GetOutput());

      // rename resolution dependent arrays
      std::ostringstream oss;
      oss << "Decomp-" << decompName[j] << "-" << res[0] << "x" << res[1];
      vtkDataArray *ids=output->GetPointData()->GetArray("ProcessId");
      if (ids)
        {
        ids->SetName(oss.str().c_str());
        }
      oss.str("");
      oss << "TCoords-"  << decompName[j] << "-" << res[0] << "x" << res[1];
      vtkDataArray *tcoord=output->GetPointData()->GetTCoords();
      if (tcoord)
        {
        tcoord->SetName(oss.str().c_str());
        }

      int testStatus = SerialRender(
            controller,
            output,
            false,
            tempDir,
            baseline,
            "SciberQuestToolKit-TestPlaneSource",
            300,300,
            63,63,128,
            0,0,0,
            0,1,0,
            1.25);
      if (testStatus==vtkTesting::FAILED)
        {
        aTestFailed=1;
        }

      pid->Delete();
      }
    }

  return Finalize(controller,aTestFailed);
}