Ejemplo n.º 1
0
int LoadPolygonModel (char *filename, int n_textures, grs_bitmap ***textures)
#endif
{
#ifdef DRIVE
#define r NULL
#endif

    Assert (gameData.models.nPolyModels < MAX_POLYGON_MODELS);
    Assert (n_textures < MAX_POLYOBJ_TEXTURES);

    //	MK was real tired of those useless, slow mprintfs...
#if TRACE
    if (gameData.models.nPolyModels > MAX_POLYGON_MODELS - 10)
        con_printf (CON_VERBOSE, "Used %d/%d polygon model slots\n", gameData.models.nPolyModels+1, MAX_POLYGON_MODELS);
#endif
    Assert (strlen (filename) <= 12);
    strcpy (Pof_names [gameData.models.nPolyModels], filename);
    ReadModelFile (gameData.models.polyModels+gameData.models.nPolyModels, filename, r);
    polyobj_find_min_max (gameData.models.polyModels+gameData.models.nPolyModels);
    G3InitPolyModel (gameData.models.polyModels [gameData.models.nPolyModels].model_data);
    if (nHighestTexture + 1 != n_textures)
        Error ("Model <%s> references %d textures but specifies %d.", filename, nHighestTexture+1, n_textures);
    gameData.models.polyModels [gameData.models.nPolyModels].n_textures = n_textures;
    gameData.models.polyModels [gameData.models.nPolyModels].first_texture = first_texture;
    gameData.models.polyModels [gameData.models.nPolyModels].simpler_model = 0;
//	Assert (polygon_models [gameData.models.nPolyModels]!=NULL);
    gameData.models.nPolyModels++;
    return gameData.models.nPolyModels-1;
}
Ejemplo n.º 2
0
void DepthSensor::Update()
{
    // Initialize must be called prior to creating timer events.
    mDrawDepth->interactor->Initialize();
    // Sign up to receive TimerEvent
    vtkTimerCallback* timer = new vtkTimerCallback(this);
    mDrawDepth->interactor->AddObserver(vtkCommand::TimerEvent, timer);
    int timerId = mDrawDepth->interactor->CreateRepeatingTimer(100);

    vtkSmartPointer<vtkLambdaCommand> keypressCallback = vtkSmartPointer<vtkLambdaCommand>::New();
    
    keypressCallback->SetCallback(
        [&](vtkObject* caller, long unsigned int eventId, void* clientData)
        {
            // Get the keypress
            vtkRenderWindowInteractor *iren = static_cast<vtkRenderWindowInteractor*>(caller);
            std::string key = iren->GetKeySym();
            // Output the key that was pressed
            std::cout << "Pressed " << key << std::endl;
            // Handle an arrow key
            if (key == "s")
            {
                if (this->SaveMesh())
                {
                    std::cout << "Saving Mesh successed." << std::endl;
                }
                //After save the mesh ,reset Recconstruction
                ResetReconstruction();
            }

            if (key == "r")
            {
                ResetReconstruction();
            }

            //press t and read STL File just have created
            if (key == "t")
            {
                if (m_saveMeshFormat == Stl || m_saveMeshFormat == Obj)
                {
                    cout << "Reading the mesh , waiting...... " << endl;
                    ReadModelFile((char*)filename.c_str(), m_saveMeshFormat);
                }
                else
                {
                    cout << "Read model file failed" << endl;
                }
            }
        }
    );
    mDrawDepth->interactor->AddObserver(vtkCommand::KeyPressEvent, keypressCallback);
    mDrawDepth->interactor->Start();

    
}
Ejemplo n.º 3
0
void readfile(const string &nm)
{
  if (nm.empty())
    return;
  string name = nm;
  switch (from)
  {
    case model:
    {
      name += ".mod";
      ifstream in(name.c_str(), ios::in);
      if (!in)
      {
        in.open(nm.c_str(), ios::in);
        if (!in)
        {
          cout << "no file - " << name << " - skipped" << endl;
          return;
        }
      }
      ReadModelFile(in, name, vec);
      return;
    }
    case values:
    {
      name += ".par";
      ifstream in(name.c_str(), ios::in);
      if (!in)
      {
        in.open(nm.c_str(), ios::in);
        if (!in)
        {
          cout << "no file - " << name << " - skipped" << endl;
          return;
        }
      }
      coef::InitialValues(in, name);
      return;
    }
    case data:
    {
      name += ".dat";
      ifstream in(name.c_str(), ios::in);
      if (!in)
      {
        in.open(nm.c_str(), ios::in);
        if (!in)
        {
          cout << "no file - " << name << " - skipped" << endl;
          return;
        }
      }
      read_series(in, name);
      return;
    }
    case hypotheses:
    {
      if (!hide_series)
      {
        hide_series = true;
        for (iser = ser.begin(); iser != ser.end(); ++iser)
          (*iser).hide = true;
      }
      name += ".set";
      ifstream in(name.c_str(), ios::in);
      if (!in)
      {
        in.open(nm.c_str(), ios::in);
        if (!in)
        {
          cout << "no file - " << name << " - skipped" << endl;
          return;
        }
      }
      read_setfile(in);
      return;
    }
  }
}