예제 #1
0
//-----------------------------------------------------------------
void elementVideo::element_videoPlay(int _speed)
{
    leftChannelPlayer.setSpeed(_speed);
    if (getElementType() == ELM_INPUT_STEREO_TWO_CHANNEL) rightChannelPlayer.setSpeed(_speed);
    leftChannelPlayer.play();
    if (getElementType() == ELM_INPUT_STEREO_TWO_CHANNEL) rightChannelPlayer.play();
}
예제 #2
0
//-----------------------------------------------------------------
void elementVideo::element_videoStop()
{
    leftChannelPlayer.play();
    if (getElementType() == ELM_INPUT_STEREO_TWO_CHANNEL) rightChannelPlayer.play();
    leftChannelPlayer.setFrame(0);
    if (getElementType() == ELM_INPUT_STEREO_TWO_CHANNEL) rightChannelPlayer.setFrame(0);
    leftChannelPlayer.stop();
    if (getElementType() == ELM_INPUT_STEREO_TWO_CHANNEL) rightChannelPlayer.stop();
}
예제 #3
0
//-----------------------------------------------------------------
void elementVideo::element_frameAvanti()
{
    leftChannelPlayer.play();
    if (getElementType() == ELM_INPUT_STEREO_TWO_CHANNEL) rightChannelPlayer.play();
    leftChannelPlayer.setFrame(leftChannelPlayer.getCurrentFrame()+1);
    if (getElementType() == ELM_INPUT_STEREO_TWO_CHANNEL) rightChannelPlayer.setFrame(leftChannelPlayer.getCurrentFrame());
    leftChannelPlayer.stop();
    if (getElementType() == ELM_INPUT_STEREO_TWO_CHANNEL) rightChannelPlayer.stop();    
}
예제 #4
0
grab::StrategyPtr SignalGrabStrategy::init(ViewerPtr viewer,
                                           grab_callback_t grabCallback,
                                           release_callback_t releaseCallback)
{
   mGrabCallback    = grabCallback;
   mReleaseCallback = releaseCallback;

   mGrabSignalData = viewer->getSceneObj()->getSceneData<GrabSignalData>();

   mConnections.push_back(
      mGrabSignalData->asyncRelease.connect(
         boost::bind(&SignalGrabStrategy::objectsReleased, this, _1)
      )
   );

   InterfaceTrader& if_trader = viewer->getUser()->getInterfaceTrader();
   mWandInterface = if_trader.getWandInterface();

   // Configure
   jccl::ConfigElementPtr cfg_elt =
      viewer->getConfiguration().getConfigElement(getElementType());

   if ( cfg_elt )
   {
      // Configure ourself.
      configure(cfg_elt);
   }

   return shared_from_this();
}
예제 #5
0
void SignalGrabStrategy::configure(jccl::ConfigElementPtr elt)
{
   vprASSERT(elt->getID() == getElementType());

   const unsigned int req_cfg_version(1);

   // Check for correct version of plugin configuration.
   if ( elt->getVersion() < req_cfg_version )
   {
      std::stringstream msg;
      msg << "Configuration of SignalGrabStrategy failed.  Required config "
          << "element version is " << req_cfg_version << ", but element '"
          << elt->getName() << "' is version " << elt->getVersion();
      throw PluginException(msg.str(), VRKIT_LOCATION);
   }

   const std::string choose_btn_prop("choose_button_nums");
   const std::string grab_btn_prop("grab_button_nums");
   const std::string release_btn_prop("release_button_nums");

   mChooseBtn.configure(elt->getProperty<std::string>(choose_btn_prop),
                        mWandInterface);
   mGrabBtn.configure(elt->getProperty<std::string>(grab_btn_prop),
                      mWandInterface);
   mReleaseBtn.configure(elt->getProperty<std::string>(release_btn_prop),
                         mWandInterface);

   // Determine if grab and release are activated using the same button
   // sequence. This indicates that the grab/release operation is a toggle
   // and must be handled differently than if the two operations are
   // separate.
   mGrabReleaseToggle = mGrabBtn == mReleaseBtn;
}
void MultiObjectGrabStrategy::configure(jccl::ConfigElementPtr elt)
{
   vprASSERT(elt->getID() == getElementType());

   const unsigned int req_cfg_version(1);

   // Check for correct version of plugin configuration.
   if ( elt->getVersion() < req_cfg_version )
   {
      std::stringstream msg;
      msg << "Configuration of MultiObjectGrabStrategy failed.  Required "
          << "config element version is " << req_cfg_version
          << ", but element '" << elt->getName() << "' is version "
          << elt->getVersion();
      throw PluginException(msg.str(), VRKIT_LOCATION);
   }

   const std::string choose_btn_prop("choose_button_nums");
   const std::string grab_btn_prop("grab_button_nums");
   const std::string release_btn_prop("release_button_nums");

   mChooseBtn.configure(elt->getProperty<std::string>(choose_btn_prop),
                        mWandInterface);
   mGrabBtn.configure(elt->getProperty<std::string>(grab_btn_prop),
                      mWandInterface);
   mReleaseBtn.configure(elt->getProperty<std::string>(release_btn_prop),
                         mWandInterface);
}
	virtual void init()
	{
		TiXmlDocument xml = xml::open( getSourceFile() );
		const TiXmlElement& root = *xml.RootElement();
		
		const std::string element = getElementType();

		const TiXmlNode * it = nullptr;
		while ( ( it = root.IterateChildren( element.c_str(), it ) ) )
		{
			const TiXmlElement& elem = static_cast< const TiXmlElement & >( *it );
			std::string id = xml::attribute( elem, "id" );

			try
			{
				std::unique_ptr< T > entry( new T() );
				load( elem, *entry );
				m_data.insert( std::make_pair( id, std::move( entry ) ) );
			}
			catch ( std::exception & err )
			{
				Console::singleton() << con::setcerr << "Error loading \"" << id << "\" to " << getDatabaseName() << ": " << err.what() << con::endl;
			}
		}
	}
예제 #8
0
파일: iraggr.cpp 프로젝트: klickverbot/ldc
llvm::Constant *
IrAggr::createInitializerConstant(const VarInitMap &explicitInitializers) {
  IF_LOG Logger::println("Creating initializer constant for %s",
                         aggrdecl->toChars());
  LOG_SCOPE;

  llvm::SmallVector<llvm::Constant *, 16> constants;

  unsigned offset = 0;
  if (type->ty == Tclass) {
    // add vtbl
    constants.push_back(getVtblSymbol());
    offset += Target::ptrsize;

    // add monitor (except for C++ classes)
    if (!aggrdecl->isClassDeclaration()->isCPPclass()) {
      constants.push_back(getNullValue(getVoidPtrType()));
      offset += Target::ptrsize;
    }
  }

  // Add the initializers for the member fields. While we are traversing the
  // class hierarchy, use the opportunity to populate interfacesWithVtbls if
  // we haven't done so previously (due to e.g. ClassReferenceExp, we can
  // have multiple initializer constants for a single class).
  addFieldInitializers(constants, explicitInitializers, aggrdecl, offset,
                       interfacesWithVtbls.empty());

  // tail padding?
  const size_t structsize = aggrdecl->size(Loc());
  if (offset < structsize)
    add_zeros(constants, offset, structsize);

  assert(!constants.empty());

  // get LL field types
  llvm::SmallVector<llvm::Type *, 16> types;
  types.reserve(constants.size());
  for (auto c : constants)
    types.push_back(c->getType());

  auto llStructType = getLLStructType();
  bool isCompatible = (types.size() == llStructType->getNumElements());
  if (isCompatible) {
    for (size_t i = 0; i < types.size(); i++) {
      if (types[i] != llStructType->getElementType(i)) {
        isCompatible = false;
        break;
      }
    }
  }

  // build constant
  LLStructType *llType =
      isCompatible ? llStructType
                   : LLStructType::get(gIR->context(), types, isPacked());
  llvm::Constant *c = LLConstantStruct::get(llType, constants);
  IF_LOG Logger::cout() << "final initializer: " << *c << std::endl;
  return c;
}
예제 #9
0
//-----------------------------------------------------------------
void elementVideo::update()
{
    
    if (isWarpable) warper.updateCoordinates();
    
	leftChannelPlayer.idleMovie();
    if (getElementType() == ELM_INPUT_STEREO_TWO_CHANNEL) rightChannelPlayer.idleMovie();
    
    if (mute) leftChannelPlayer.setVolume(0);
    else leftChannelPlayer.setVolume(volume);
    
}
예제 #10
0
void DataStmtEngine::CreateArrayElementExprInitializer(ArrayElementExpr *E,
                                                       Expr *Parent) {
  auto Target = dyn_cast<VarExpr>(E->getTarget());
  if(!Target)
    return VisitExpr(E);
  if(CheckVar(Target))
    return;

  auto VD = Target->getVarDecl();
  auto ATy = VD->getType()->asArrayType();
  auto ElementType = ATy->getElementType();

  uint64_t ArraySize;
  if(!ATy->EvaluateSize(ArraySize, Context))
    return VisitExpr(E);

  SmallVector<Expr*, 32> Items(ArraySize);
  if(VD->hasInit()) {
    assert(isa<ArrayConstructorExpr>(VD->getInit()));
    auto InsertPoint = cast<ArrayConstructorExpr>(VD->getInit())->getItems();
    for(uint64_t I = 0; I < ArraySize; ++I)
      Items[I] = InsertPoint[I];
  } else {
    for(uint64_t I = 0; I < ArraySize; ++I)
      Items[I] = nullptr;
  }

  uint64_t Offset;
  if(!E->EvaluateOffset(Context, Offset, &ImpliedDoEvaluator))
    return VisitExpr(E);

  ExprResult Val;
  if(Parent) {
    if(auto SE = dyn_cast<SubstringExpr>(Parent)) {
       Val = CreateSubstringExprInitializer(SE, ElementType);
    } else if(auto ME = dyn_cast<MemberExpr>(Parent)) {
      if(Offset < Items.size()) {
        const TypeConstructorExpr *Init = Items[Offset]? cast<TypeConstructorExpr>(Items[Offset]) : nullptr;
        Val = CreateMemberExprInitializer(ME, Init);
      }
    } else llvm_unreachable("invalid expression");
  } else Val = getAndCheckAnyValue(ElementType, E);

  if(Val.isUsable() && Offset < Items.size()) {
    Items[Offset] = Val.get();
    VD->setInit(ArrayConstructorExpr::Create(Context, Val.get()->getLocation(),
                                             Items, VD->getType()));
  }
}
예제 #11
0
bool Weapon::internalUseWeapon(Player* player, Item* item, Creature* target, int32_t damageModifier) const
{
	if (m_scripted) {
		LuaVariant var;
		var.type = VARIANT_NUMBER;
		var.number = target->getID();
		executeUseWeapon(player, var);
	} else {
		CombatDamage damage;
		damage.primary.type = params.combatType;
		damage.primary.value = (getWeaponDamage(player, target, item) * damageModifier) / 100;
		damage.secondary.type = getElementType();
		damage.secondary.value = getElementDamage(player, target, item);
		Combat::doCombatHealth(player, target, damage, params);
	}

	onUsedAmmo(player, item, target->getTile());
	onUsedWeapon(player, item, target->getTile());
	return true;
}
grab::StrategyPtr MultiObjectGrabStrategy::
init(ViewerPtr viewer, grab_callback_t grabCallback,
     release_callback_t releaseCallback)
{
   mEventData = viewer->getSceneObj()->getSceneData<EventData>();

   mGrabCallback    = grabCallback;
   mReleaseCallback = releaseCallback;

   // Connect the intersection signal to our slot.
   mIsectConnections.push_back(
      mEventData->objectIntersected.connect(
         0, boost::bind(&MultiObjectGrabStrategy::objectIntersected, this,
                        _1, _2)
      )
   );

   // Connect the de-intersection signal to our slot.
   mIsectConnections.push_back(
      mEventData->objectDeintersected.connect(
         0, boost::bind(&MultiObjectGrabStrategy::objectDeintersected,
                        this, _1)
      )
   );

   InterfaceTrader& if_trader = viewer->getUser()->getInterfaceTrader();
   mWandInterface = if_trader.getWandInterface();

   // Configure
   std::string elt_type_name = getElementType();
   jccl::ConfigElementPtr cfg_elt =
      viewer->getConfiguration().getConfigElement(elt_type_name);

   if ( cfg_elt )
   {
      // Configure ourself.
      configure(cfg_elt);
   }

   return shared_from_this();
}
예제 #13
0
move::StrategyPtr SlideMoveStrategy::init(ViewerPtr viewer)
{
   jccl::ConfigElementPtr cfg_elt =
      viewer->getConfiguration().getConfigElement(getElementType());

   if ( cfg_elt )
   {
      try
      {
         configure(cfg_elt);
      }
      catch (Exception& ex)
      {
         std::cerr << ex.what() << std::endl;
      }
   }

   vprASSERT((mForwardValue == 0.0f || mForwardValue == 1.0f) &&
             "Invalid setting for mForwardValue");

   return shared_from_this();
}
예제 #14
0
void WandInterface::init(ViewerPtr viewer)
{
   jccl::ConfigElementPtr cfg_elt =
      viewer->getConfiguration().getConfigElement(getElementType());

   if ( cfg_elt )
   {
      try
      {
         configure(cfg_elt);
      }
      catch (Exception& ex)
      {
         std::cerr << "Configuration of WandInterface failed:\n" << ex.what()
                   << "\nUsing default settings." << std::endl;
         configureDefault();
      }
   }
   else
   {
      configureDefault();
   }
}
예제 #15
0
void Weapon::internalUseWeapon(Player* player, Item* item, Creature* target, int32_t damageModifier) const
{
	if (m_scripted) {
		LuaVariant var;
		var.type = VARIANT_NUMBER;
		var.number = target->getID();
		executeUseWeapon(player, var);
	} else {
		CombatDamage damage;
		WeaponType_t weaponType = item->getWeaponType();
		if (weaponType == WEAPON_AMMO || weaponType == WEAPON_DISTANCE) {
			damage.origin = ORIGIN_RANGED;
		} else {
			damage.origin = ORIGIN_MELEE;
		}
		damage.primary.type = params.combatType;
		damage.primary.value = (getWeaponDamage(player, target, item) * damageModifier) / 100;
		damage.secondary.type = getElementType();
		damage.secondary.value = getElementDamage(player, target, item);
		Combat::doCombatHealth(player, target, damage, params);
	}

	onUsedWeapon(player, item, target->getTile());
}
예제 #16
0
viewer::PluginPtr ModeSwitchPlugin::init(ViewerPtr viewer)
{
   const std::string plugin_path_prop("plugin_path");
   const std::string plugins_prop("plugins");
   const std::string mode_names_prop("mode_names");
   const std::string swap_button_prop("swap_button_nums");
   const std::string mode_plugin_type("mode_plugin_def");
   const std::string active_modes_prop("active_modes");
   const std::string plugin_prop("plugin");

   const unsigned int req_cfg_version(2);

   InterfaceTrader& if_trader = viewer->getUser()->getInterfaceTrader();
   mWandInterface = if_trader.getWandInterface();

   // -- Configure -- //
   std::string elt_type_name = getElementType();
   jccl::ConfigElementPtr elt =
      viewer->getConfiguration().getConfigElement(elt_type_name);

   if ( ! elt )
   {
      throw PluginException("ModeSwitchPlugin not find its configuration.",
                            VRKIT_LOCATION);
   }

   vprASSERT(elt->getID() == getElementType());

   // Check for correct version of plug-in configuration.
   if ( elt->getVersion() < req_cfg_version )
   {
      std::ostringstream msg;
      msg << "ModeSwitchPlugin: Configuration failed. Required cfg version: "
          << req_cfg_version << " found:" << elt->getVersion();
      throw PluginException(msg.str(), VRKIT_LOCATION);
   }

   // ---- Process configuration --- //
   mMaxMode = 0;

   // -- Setup the plug-in search path -- //
   std::vector<std::string> search_path;
   const unsigned int num_paths(elt->getNum(plugin_path_prop));

   for ( unsigned int i = 0; i < num_paths; ++i )
   {
      search_path.push_back(
         elt->getProperty<std::string>(plugin_path_prop, i)
      );
   }

   const std::vector<vpr::LibraryPtr> modules =
      plugin::findModules(search_path);
   std::for_each(
      modules.begin(), modules.end(),
      boost::bind(&ModeSwitchPlugin::registerModule, this, _1, viewer)
   );

   // Get the button for swapping
   mSwitchButton.configure(elt->getProperty<std::string>(swap_button_prop),
                           mWandInterface);

   // Get mode names
   const unsigned int num_mode_names(elt->getNum(mode_names_prop));
   mMaxMode = num_mode_names - 1;
   for ( unsigned int i = 0; i < num_mode_names; ++i )
   {
      mModeNames.push_back(elt->getProperty<std::string>(mode_names_prop, i));
   }

   // --- Load the managed plug-ins --- //
   const unsigned int num_plugins(elt->getNum(plugins_prop));

   VRKIT_STATUS << "[Mode Switch Plug-in] Found " << num_plugins
                << " plug-ins to load." << std::endl;

   plugin::RegistryPtr plugin_registry = viewer->getPluginRegistry();

   // Attempt to load each plug-in
   // - Get creator and create plug-in
   // - Push onto plug-in list
   for ( unsigned int i = 0; i < num_plugins; ++i )
   {
      PluginData plugin_data;
      jccl::ConfigElementPtr plg_elt =
         elt->getProperty<jccl::ConfigElementPtr>(plugins_prop, i);
      plugin_data.mName = plg_elt->getProperty<std::string>(plugin_prop);

      try
      {
         std::cout << "   Loading plug-in: " << plugin_data.mName << " ... "
                   << std::flush;

         std::vector<AbstractPluginPtr> deps;
         AbstractPluginPtr p =
            plugin_registry->makeInstance(plugin_data.mName, deps);

         std::vector<PluginData> plugins;
         plugins.reserve(deps.size() + 1);

         typedef std::vector<AbstractPluginPtr>::iterator iter_type;
         for ( iter_type d = deps.begin(); d != deps.end(); ++d )
         {
            viewer::PluginPtr cur_dep =
               boost::dynamic_pointer_cast<viewer::Plugin>(*d);

            if ( cur_dep )
            {
               PluginData dep_data;
               dep_data.mName   = cur_dep->getInfo().getName();
               dep_data.mPlugin = cur_dep;
               plugins.push_back(dep_data);
            }
         }

         plugin_data.mPlugin = boost::dynamic_pointer_cast<Plugin>(p);

         if ( ! plugin_data.mPlugin )
         {
            std::ostringstream msg_stream;
            msg_stream << "Invalid plug-in type '"
                       << p->getInfo().getFullName()
                       << "' given as plug-in for the Mode Switch Plug-in!";
            throw PluginException(msg_stream.str(), VRKIT_LOCATION);
         }

         plugins.push_back(plugin_data);

         const unsigned int num_active_modes =
            plg_elt->getNum(active_modes_prop);
         for ( unsigned int m = 0; m < num_active_modes; ++m )
         {
            const unsigned int mode_num =
               plg_elt->getProperty<unsigned int>(active_modes_prop, m);

            if ( mode_num > mMaxMode )
            {
               mMaxMode = mode_num;
            }

            typedef std::vector<PluginData>::iterator piter_type;
            for ( piter_type p = plugins.begin(); p != plugins.end(); ++p )
            {
               (*p).mActiveModes.push_back(mode_num);
            }
         }

         mPlugins.insert(mPlugins.end(), plugins.begin(), plugins.end());
         std::cout << "[OK]" << std::endl;
      }
      catch (std::runtime_error& ex)
      {
         std::cerr << "[FAILED]\n"
                   << "WARNING: ModeSwitchPlugin failed to load plug-in '"
                   << plugin_data.mName << "': " << ex.what() << std::endl;
      }
   }

   // Make sure we have enough mode names to match up with the number of modes.
   if ( mMaxMode >= mModeNames.size() )
   {
      mModeNames.resize(mMaxMode + 1, std::string("Unknown Mode"));
   }

   switchToMode(0, viewer);

   return shared_from_this();
}
예제 #17
0
SkElementType SkAnimator::getElementType(const char* id) {
    const SkDisplayable* element = getElement(id);
    return getElementType(element);
}
예제 #18
0
void SlideMoveStrategy::configure(jccl::ConfigElementPtr cfgElt)
{
   vprASSERT(cfgElt->getID() == getElementType());

   const unsigned int req_cfg_version(2);

   if ( cfgElt->getVersion() < req_cfg_version )
   {
      std::stringstream msg;
      msg << "Configuration of SlideMoveStrategy failed.  Required config "
          << "element version is " << req_cfg_version << ", but element '"
          << cfgElt->getName() << "' is version " << cfgElt->getVersion();
      throw PluginException(msg.str(), VRKIT_LOCATION);
   }

   const std::string slide_target_prop("slide_target");
   const std::string analog_input_prop("analog_input");
   const std::string forward_value_prop("forward_slide_value");
   const std::string slide_epsilon_prop("slide_epsilon");

   const unsigned int slide_target =
      cfgElt->getProperty<unsigned int>(slide_target_prop);

   if ( slide_target == 0 || slide_target == 1 )
   {
      mSlideTarget = static_cast<SlideTarget>(slide_target);
   }
   else
   {
      VRKIT_STATUS << "ERROR: Invalid slide target identifier "
                   << slide_target << std::endl;
   }

   const int analog_num = cfgElt->getProperty<int>(analog_input_prop);

   // -1 disables sliding. Otherwise, the analog number must be in the range
   // 0 <= analog_num < 4.
   if ( analog_num == -1 || 0 <= analog_num && analog_num < 4 )
   {
      mAnalogNum = analog_num;
   }
   else
   {
      VRKIT_STATUS << "ERROR: Analog input index (" << analog_num
                   << ") given!\n"
                   << "This must be -1 (to disable) or in the range [0, 4)."
                   << std::endl;
   }

   const float fwd_val = cfgElt->getProperty<float>(forward_value_prop);

   if ( fwd_val == 0.0f || fwd_val == 1.0f )
   {
      mForwardValue = fwd_val;
   }
   else
   {
      VRKIT_STATUS << "ERROR: Invalid forward sliding value (" << fwd_val
                   << ") given!\n"
                   << "This must be either 0.0 or 1.0" << std::endl;
   }

   const float eps = cfgElt->getProperty<float>(slide_epsilon_prop);

   if ( eps >= 0.0f )
   {
      mSlideEpsilon = eps;
   }
   else
   {
      VRKIT_STATUS << "ERROR: Slide epsilon must be non-negative!"
                   << std::endl;
   }
}
예제 #19
0
//-----------------------------------------------------------------
void elementVideo::element_setLoop(ofLoopType _loop)
{
    leftChannelPlayer.setLoopState(_loop);
    if (getElementType() == ELM_INPUT_STEREO_TWO_CHANNEL) rightChannelPlayer.setLoopState(_loop);
}
예제 #20
0
int GridAdapter::readMeshFromFile(const std::string& filename)
{
	std::string line;
	std::list<std::string>::const_iterator it;

	std::ifstream in(filename.c_str());

	if (!in.is_open())
	{
		std::cout << "GridAdapter::readMeshFromFile() - Could not open file..."
		          << "\n";
		return 0;
	}

	// try to find the start of the nodes list
	while (getline(in, line))
	{
		trim(line);
		if (line.compare("$NODES") == 0)
			break;
	}

	// read number of nodes
	getline(in, line);
	trim(line);

	// read all nodes
	while (getline(in, line))
	{
		trim(line);
		if (line.compare("$ELEMENTS") == 0)
			break;

		std::list<std::string> fields = splitString(line, ' ');

		if (fields.size() >= 4)
		{
			it = fields.begin();

			if (atoi(it->c_str()) == (int)_nodes->size())
			{
				GEOLIB::Point* pnt = new GEOLIB::Point();

				(*pnt)[0] = strtod((++it)->c_str(), 0);
				(*pnt)[1] = strtod((++it)->c_str(), 0);
				(*pnt)[2] = strtod((++it)->c_str(), 0);

				_nodes->push_back(pnt);
			}
			else
				std::cout << "GridAdapter::readMeshFromFile() - Index error while reading nodes..."
				          << "\n";
		}
		else
			std::cout << "GridAdapter::readMeshFromFile() - Error reading node format..."
			          << "\n";
	}

	if (line.compare("$ELEMENTS") == 0)
	{
		Element* newElem;

		// read number of elements
		getline(in, line);
		trim(line);

		// read all elements
		while (getline(in, line))
		{
			trim(line);
			if (line.compare("$LAYER") == 0)
				break;

			std::list<std::string> fields = splitString(line, ' ');

			if (fields.size() >= 5)
			{
				it = fields.begin();
				if (atoi(it->c_str()) == (int)_elems->size())
				{
					newElem = new Element();

					if ((++it)->empty())
						it++;
					newElem->material = atoi(it->c_str()); // material group
					if ((++it)->empty())
						it++;
					newElem->type = getElementType(*it); // element type

					if (newElem->type != MshElemType::INVALID)
					{
						while ((++it) != fields.end())
						{
							if (it->empty())
								continue;
							newElem->nodes.push_back(atoi(it->c_str())); // next node id
						}

						_elems->push_back(newElem);
					}
					else
					{
						std::cout << "GridAdapter::readMeshFromFile() - Error recognising element type..."
						          << "\n";
						return 0;
					}
				}
				else
				{
					std::cout << "GridAdapter::readMeshFromFile() - Index error while reading element " << *it << "... "
					          << "\n";
					return 0;
				}
			}
			else
			{
				std::cout << "GridAdapter::readMeshFromFile() - Error reading element format..."
				          << "\n";
				return 0;
			}
		}
	}
	else
		std::cout << "GridAdapter::readMeshFromFile() - Index error after reading nodes..."
		          << "\n";

	in.close();

	return 1;
}
예제 #21
0
//-----------------------------------------------------------------
void elementVideo::element_videoPause()
{
    leftChannelPlayer.stop();
    if (getElementType() == ELM_INPUT_STEREO_TWO_CHANNEL) rightChannelPlayer.stop();   
}
예제 #22
0
void WandInterface::configure(jccl::ConfigElementPtr elt)
{
   vprASSERT(elt->getID() == getElementType());

   const unsigned int req_cfg_version(1);

   if ( elt->getVersion() < req_cfg_version )
   {
      std::ostringstream msg;
      msg << "Configuration of WandInterface failed.  Required config "
          << "element version is " << req_cfg_version << ", but element '"
          << elt->getName() << "' is version " << elt->getVersion();
      throw Exception(msg.str(), VRKIT_LOCATION);
   }

   const std::string pos_name_prop("position_name");
   const std::string digital_name_prop("digital_name");
   const std::string analog_name_prop("analog_name");

   const std::string wand_name = elt->getProperty<std::string>(pos_name_prop);

   if ( wand_name.empty() )
   {
      throw Exception("Empty wand name is not allowed", VRKIT_LOCATION);
   }

   mWandInterface.init(wand_name);

   const unsigned int num_digitals(elt->getNum(digital_name_prop));

   if ( num_digitals > 0 )
   {
      mButtonInterfaces.resize(num_digitals);

      for ( unsigned int d = 0; d < num_digitals; ++d )
      {
         const std::string digital_name =
            elt->getProperty<std::string>(digital_name_prop, d);

         if ( digital_name.empty() )
         {
            mButtonInterfaces.clear();

            std::ostringstream msg_stream;
            msg_stream << "Empty digital name (index " << d
                       << ") is not allowed";
            throw Exception(msg_stream.str(), VRKIT_LOCATION);
         }

         mButtonInterfaces[d].init(digital_name);
      }
   }

   const unsigned int num_analogs(elt->getNum(analog_name_prop));

   if ( num_analogs > 0 )
   {
      mAnalogInterfaces.resize(num_analogs);

      for ( unsigned int a = 0; a < num_analogs; ++a )
      {
         const std::string analog_name =
            elt->getProperty<std::string>(analog_name_prop, a);

         if ( analog_name.empty() )
         {
            mAnalogInterfaces.clear();

            std::ostringstream msg_stream;
            msg_stream << "Empty analog name (index " << a
                       << ") is not allowed";
            throw Exception(msg_stream.str(), VRKIT_LOCATION);
         }

         mAnalogInterfaces[a].init(analog_name);
      }
   }
}
예제 #23
0
void ModeHarnessPlugin::configure(jccl::ConfigElementPtr elt)
{
   vprASSERT(elt->getID() == getElementType());

   const unsigned int req_cfg_version(2);

   // Check for correct version of plugin configuration.
   if ( elt->getVersion() < req_cfg_version )
   {
      std::stringstream msg;
      msg << "Configuration of ModeHarnessPlugin failed.  Required config "
          << "element version is " << req_cfg_version << ", but element '"
          << elt->getName() << "' is version " << elt->getVersion();
      throw PluginException(msg.str(), VRKIT_LOCATION);
   }

   const std::string component_path_prop("component_path");
   const std::string default_component_prop("default_component");
   const std::string component_prop("component");
   const std::string plugin_prop("plugin");
   const std::string signal_prop("signal");
   const std::string active_component_prop("active_component");

   // Set up two default search paths:
   //    1. Relative path to './plugins/mode'
   //    2. VRKIT_BASE_DIR/lib/vrkit/plugins/mode
   //
   // In all of the above cases, the 'debug' subdirectory is searched first if
   // this is a debug build (i.e., when VRKIT_DEBUG is defined and _DEBUG is
   // not).
   std::vector<std::string> component_path =
      plugin::getDefaultSearchPath("mode");

   const unsigned int num_plugin_paths(elt->getNum(component_path_prop));
   for ( unsigned int i = 0; i < num_plugin_paths; ++i )
   {
      std::string dir = elt->getProperty<std::string>(component_path_prop, i);
      component_path.push_back(vpr::replaceEnvVars(dir));
   }

   mDefaultComponentName =
      elt->getProperty<std::string>(default_component_prop);

   const unsigned int num_comps(elt->getNum(component_prop));
   for ( unsigned int i = 0; i < num_comps; ++i )
   {
      jccl::ConfigElementPtr comp_elt =
         elt->getProperty<jccl::ConfigElementPtr>(component_prop, i);
      mComponentInfo.push_back(
         ComponentInfo(comp_elt->getName(),
                       comp_elt->getProperty<std::string>(plugin_prop))
      );
   }

   const unsigned int num_signals(elt->getNum(signal_prop));
   for ( unsigned int i = 0; i < num_signals; ++i )
   {
      jccl::ConfigElementPtr signal_elt =
         elt->getProperty<jccl::ConfigElementPtr>(signal_prop, i);
      mSignalDefs.push_back(
         SignalDef(signal_elt->getName(),
                   signal_elt->getProperty<std::string>(active_component_prop))
      );
   }

   std::vector<vpr::LibraryPtr> modules = plugin::findModules(component_path);
   std::for_each(modules.begin(), modules.end(),
                 boost::bind(&ModeHarnessPlugin::registerModule, this, _1));
}
예제 #24
0
	/*! \brief Renders the instanced object.
	 */
	inline void glRender()
	{
	  _primitiveVertices.attachToVertex();
	  _primitiveNormals.attachToNormal();
	  _primitiveIndices.drawInstancedElements(getElementType(), _N);
	}