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


C++ Universe::getId方法代码示例

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


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

示例1: clone

/**
 * @brief Clones this Universe and all of the Cells within it and returns it
 * @return a pointer to the Universe clone
 */
Universe* Universe::clone() {

  log_printf(DEBUG, "Cloning Universe %d", _id);

  /* Instantiate new Universe clone */
  Universe* clone = new Universe(universe_id());

  /* Loop over Cells in Universe and clone each one */
  std::map<int, Cell*>::iterator iter1;
  for (iter1 = _cells.begin(); iter1 != _cells.end(); ++iter1) {

    /* If the Cell is filled with a Material, clone it */
    if ((*iter1).second->getType() == MATERIAL) {

      /* Clone the Cell */
      CellBasic* parent = static_cast<CellBasic*>((*iter1).second);
      CellBasic* cell_clone = parent->clone();

      /* Add Cell clone to the list */
      clone->addCell(cell_clone);
      cell_clone->setUniverse(clone->getId());
    }

    /* Throw error message if Cell is FILL type */
    else {
      log_printf(ERROR, "Unable to clone Universe %d since it contains Cell %d"
                 "which is filled with a Universe rather than a Material");
    }
  }

  return clone;
}
开发者ID:AlexYou,项目名称:OpenMOC,代码行数:36,代码来源:Universe.cpp

示例2: query_venue_describe

// ----------------------------------------------------------------------------
//
void HttpRestServices::query_venue_describe( Venue* venue, DMXHttpSession* session, CString& response, LPCSTR data ) {
    JsonBuilder json( response );

    json.startObject();
    json.add( "name", venue->getName() );
    json.add( "description", venue->getDescription() );
    json.add( "auto_blackout", venue->getAutoBlackoutMS() );
    json.add( "audio_capture_device", venue->getAudioCaptureDevice() );
    json.add( "audio_sample_size", venue->getAudioSampleSize() );
    json.add( "audio_boost", venue->getAudioBoost() );
    json.add( "audio_boost_floor", venue->getAudioBoostFloor() );
    json.add( "track_fixtures", venue->isTrackFixtures() );

    json.startArray( "ports" );
    for ( int i=1; i <= 12; i++ ) {
        CString com_port;
        com_port.Format( "com%d", i );
        json.add( com_port );
    }
    json.endArray( "ports" );

    json.startArray("driver_types");
    json.add( "Enttec USB Pro");
    json.add( "Open DMX");
    json.add( "Philips Hue");
    json.endArray("driver_types");

    json.startArray( "universes" );
    UniversePtrArray universes = venue->getUniverses();
    for ( UniversePtrArray::iterator it=universes.begin(); it != universes.end(); ++it ) {
        Universe* universe = (*it);

        json.startObject( );
        json.add( "id", universe->getId() );
        json.add( "type", universe->getType() );
        json.add( "dmx_config", universe->getDmxConfig() );
        json.add( "packet_delay_ms", universe->getDmxPacketDelayMS() );
        json.add( "minimum_delay_ms", universe->getDmxMinimumDelayMS() );
        json.endObject( );
    }
    json.endArray( "universes" );

    json.startArray( "capture_devices" );
    for ( AudioCaptureDeviceArray::iterator it=AudioInputStream::audioCaptureDevices.begin();
            it != AudioInputStream::audioCaptureDevices.end(); ++it )
        json.add( (*it).m_friendly_name );

    json.endArray( "capture_devices" );

    json.endObject();
}
开发者ID:desantir,项目名称:DMXStudio,代码行数:53,代码来源:HttpRestVenue.cpp

示例3: findNextLatticeCell


//.........这里部分代码省略.........
      /* Check if distance to test Point is current minimum */
      if (d < distance) {
        distance = d;
        x_new = x_curr;
        y_new = y_curr;
      }
    }
  }

  /* Right Lattice cell */
  if (lattice_x <= _num_x-1 && (angle <= M_PI/2 || angle >= 3*M_PI/2)) {
    x_curr = (lattice_x - _num_x/2.0 + 1) * _width_x;
    y_curr = y0 + m * (x_curr - x0);
    test.setCoords(x_curr, y_curr);

    /* Check if the test Point is within the bounds of the Lattice */
    if (withinBounds(&test)) {
      d = test.distanceToPoint(coords->getPoint());

      /* Check if distance to test Point is current minimum */
      if (d < distance) {
        distance = d;
        x_new = x_curr;
        y_new = y_curr;
      }
    }
  }

  /* If no Point was found on the Lattice cell, then the LocalCoords was
   * already on the boundary of the Lattice */
  if (distance == INFINITY)
    return NULL;

  /* Otherwise a Point was found inside a new Lattice cell */
  else {
    /* Update the Localcoords location to the Point on the new Lattice cell
     * plus a small bit to ensure that its coordinates are inside cell */
    double delta_x = (x_new - coords->getX()) + cos(angle) * TINY_MOVE;
    double delta_y = (y_new - coords->getY()) + sin(angle) * TINY_MOVE;
    coords->adjustCoords(delta_x, delta_y);

    /* Compute the x and y indices for the new Lattice cell */
    new_lattice_x = (int)floor((coords->getX() - _origin.getX())/_width_x);
    new_lattice_y = (int)floor((coords->getY() - _origin.getY())/_width_y);

    /* Check if the LocalCoord is on the lattice boundaries and if so adjust
     * x or y Lattice cell indices i */
    if (fabs(fabs(coords->getX()) - _num_x*_width_x*0.5) <
        ON_LATTICE_CELL_THRESH) {

      if (coords->getX() > 0)
        new_lattice_x = _num_x - 1;
      else
        new_lattice_x = 0;
    }
    if (fabs(fabs(coords->getY()) - _num_y*_width_y*0.5) <
        ON_LATTICE_CELL_THRESH) {

      if (coords->getY() > 0)
        new_lattice_y = _num_y - 1;
      else
        new_lattice_y = 0;
    }

    /* Check if new Lattice cell indices are within the bounds, if not,
     * new LocalCoords is now on the boundary of the Lattice */
    if (new_lattice_x >= _num_x || new_lattice_x < 0)
      return NULL;
    else if (new_lattice_y >= _num_y || new_lattice_y < 0)
      return NULL;

    /* New LocalCoords is still within the interior of the Lattice */
    else {
      /* Update the LocalCoords Lattice cell indices */
      coords->setLatticeX(new_lattice_x);
      coords->setLatticeY(new_lattice_y);

      /* Move to next lowest level Universe */
      coords->prune();
      Universe* univ = _universes.at(new_lattice_y).at(new_lattice_x).second;
      LocalCoords* next_coords;

      /* Compute local position of Point in next level Universe */
      double nextX = coords->getX() - (_origin.getX()
                     + (new_lattice_x + 0.5) * _width_x);
      double nextY = coords->getY() - (_origin.getY()
                     + (new_lattice_y + 0.5) * _width_y);

      /* Set the coordinates at the next level LocalCoord */
      next_coords = new LocalCoords(nextX, nextY);
      next_coords->setPrev(coords);
      coords->setNext(next_coords);

      next_coords->setUniverse(univ->getId());

      /* Search lower level Universe */
      return findCell(coords, universes);
    }
  }
}
开发者ID:AlexYou,项目名称:OpenMOC,代码行数:101,代码来源:Universe.cpp


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