示例#1
0
void Box::parse(std::ifstream& fin){
  std::string tempString;
  fin >> tempString;
  
  if(tempString != "{"){
    std::cout << "Incorrect format, found: " << tempString << ", expected: {" << std::endl;
    exit(0);
  }
  
  setVector(fin, corner1);
  setVector(fin, corner2);
   
  fin >> tempString;

  glm::mat4 tempTransformationMatrix = glm::mat4(1.0f);
  while(tempString != "}"){
    if(tempString == "pigment"){
      setPigment(fin);
    }
    else if(tempString == "finish"){
      setFinish(fin);
    }
    else if(tempString == "translate"){
      glm::vec3 translation;
      setVector(fin, translation);
      tempTransformationMatrix = glm::translate(glm::mat4(1.0f), translation) * tempTransformationMatrix;
    }
    else if(tempString == "rotate"){
      glm::vec3 rotate;
      setVector(fin, rotate);
      
      if(rotate.x != 0.0f){
	tempTransformationMatrix = glm::rotate(glm::mat4(1.0f), rotate.x, glm::vec3(1.0f, 0.0f, 0.0f)) * tempTransformationMatrix;
      }
      else if(rotate.y != 0.0f){
	tempTransformationMatrix = glm::rotate(glm::mat4(1.0f), rotate.y, glm::vec3(0.0f, 1.0f, 0.0f)) * tempTransformationMatrix;
      }
      else{
	tempTransformationMatrix = glm::rotate(glm::mat4(1.0f), rotate.z, glm::vec3(0.0f, 0.0f, 1.0f)) * tempTransformationMatrix;
      }
    }
    else if(tempString == "scale"){
      glm::vec3 scale;
      setVector(fin, scale);
      tempTransformationMatrix = glm::scale(glm::mat4(1.0f), scale) * tempTransformationMatrix;
    }
    else{
      std::cout << "Unidentified keyword : " << tempString << std::endl;
      exit(0);
    }
    fin >> tempString;
  }
  setTransformationMatrix(tempTransformationMatrix);
  setITM(tempTransformationMatrix);
  setBoundingBox();
}
void
LOCA::PhaseTransition::ExtendedVector::setVec(
                    const NOX::Abstract::Vector& x1Vec,
                    const NOX::Abstract::Vector& x2vec,
                    double ptp)
{
  setVector(0, x1Vec);
  setVector(1, x2vec);
  setScalar(0, ptp);
}
void 
LOCA::TurningPoint::MooreSpence::ExtendedVector::setVec(
					const NOX::Abstract::Vector& xVec,
					const NOX::Abstract::Vector& nullVec,
					double bifPar)
{
  setVector(0, xVec);
  setVector(1, nullVec);
  setScalar(0, bifPar);
}
LOCA::PhaseTransition::ExtendedVector::ExtendedVector(
            const Teuchos::RCP<LOCA::GlobalData>& global_data,
            const NOX::Abstract::Vector& x1Vec,
            const NOX::Abstract::Vector& x2vec,
            double ptp) :
  LOCA::Extended::Vector(global_data,2,1)
{
  setVector(0, x1Vec);
  setVector(1, x2vec);
  setScalar(0, ptp);
}
LOCA::TurningPoint::MooreSpence::ExtendedVector::ExtendedVector(
		    const Teuchos::RCP<LOCA::GlobalData>& global_data,
		    const NOX::Abstract::Vector& xVec,
		    const NOX::Abstract::Vector& nullVec,
		    double bifParam) :
  LOCA::Extended::Vector(global_data,2,1)
{
  setVector(0, xVec);
  setVector(1, nullVec);
  setScalar(0, bifParam);
}
void 
LOCA::Pitchfork::MooreSpence::ExtendedVector::setVec(
					const NOX::Abstract::Vector& xVec,
					const NOX::Abstract::Vector& nullVec,
					double slack,
					double bifPar)
{
  setVector(0, xVec);
  setVector(1, nullVec);
  setScalar(0, slack);
  setScalar(1, bifPar);
}
LOCA::Pitchfork::MooreSpence::ExtendedVector::ExtendedVector(
		    const Teuchos::RCP<LOCA::GlobalData>& global_data,
		    const NOX::Abstract::Vector& xVec,
		    const NOX::Abstract::Vector& nullVec,
		    double slack,
		    double bifParam) :
  LOCA::Extended::Vector(global_data,2,2)
{
  setVector(0, xVec);
  setVector(1, nullVec);
  setScalar(0, slack);
  setScalar(1, bifParam);
}
void
LOCA::Hopf::MooreSpence::ExtendedVector::setVec(
                   const NOX::Abstract::Vector& xVec,
                   const NOX::Abstract::Vector& realEigenVec,
                   const NOX::Abstract::Vector& imagEigenVec,
                   double frequency,
                   double bifPar)
{
  setVector(0, xVec);
  setVector(1, realEigenVec);
  setVector(2, imagEigenVec);
  setScalar(0, frequency);
  setScalar(1, bifPar);
}
LOCA::Hopf::MooreSpence::ExtendedVector::ExtendedVector(
            const Teuchos::RCP<LOCA::GlobalData>& global_data,
            const NOX::Abstract::Vector& xVec,
            const NOX::Abstract::Vector& realEigenVec,
            const NOX::Abstract::Vector& imagEigenVec,
            double frequency,
            double bifParam) :
  LOCA::Extended::Vector(global_data,3,2)
{
  setVector(0, xVec);
  setVector(1, realEigenVec);
  setVector(2, imagEigenVec);
  setScalar(0, frequency);
  setScalar(1, bifParam);
}
示例#10
0
    void AIDA_Cloud1DIterator::fillData(const std::vector<iAIDA::AIDA_Function::AIDA_RangeSet * > & ranges) 
    { 
      int n = ranges.size();
      if (n != m_dim) {
	INFO_MSG(" AIDA_Cloud1DIterator::fillData  invalid dimension for rangeset - cannot feed data in FNL"); 
	return; 
      }
      if (!ranges[0]) { 
	INFO_MSG(" AIDA_Cloud1DIterator::fillData  invalid rangeset - cannot feed data in FNL"); 
	return; 
      }
	
      std::auto_ptr<fml::DataVector> vptr (new fml::DataVector());

      std::vector<double> x(m_dim);

      int nPoints = 0; 
      for(int i = 0; i<m_hist->entries(); ++i)
	{
	  x[0] = m_hist->value(i);
	  if (ranges[0]->isInRange(x[0]) ) { 
	    vptr->push_back(x, m_hist->weight(i), 0 );
	    //cout << " push in event " << x[0] << endl; 
	    nPoints++; 
	  }
	      
	}
      // set the range (size is number of events !) - needed by FML
      vptr->setRange(fml::DataRange(nPoints) );

      setVector(vptr);

    }
示例#11
0
// ベクトル単品にマトリクスをかける
int
CKLBLuaLibMatrix::luaMulMatVector(lua_State * L)
{
	CLuaState lua(L);
	MATRIX * mat = getMatPointer(lua, 1);
	if(!mat) {
		lua.retNil();
		return 1;
	}
	VECTOR vec;
	VECTOR ret;

	// vector を取得
	lua.retValue(2);
	getVector(lua, &vec);
	lua.pop(1);

	// vectorにmatrixをかけて、その結果を受け取る
	mulMatVector(&ret, &vec, mat);

	// 結果のvectorをLuaテーブルに変換しスタックに積む
	setVector(lua, &ret);

	return 1;
}
示例#12
0
CBotGAValues :: CBotGAValues( vector<float> values )
{
	clear();	
	setFitness(0);

	setVector(values);
}
示例#13
0
template <typename T> CoinDenseVector<T> &
CoinDenseVector<T>::operator=(const CoinDenseVector<T> & rhs)
{
   if (this != &rhs) {
     setVector(rhs.getNumElements(), rhs.getElements());
   }
   return *this;
}
void VectorProperty::load( const YAML::Node& yaml_node )
{
  float x, y, z;
  yaml_node[ "X" ] >> x;
  yaml_node[ "Y" ] >> y;
  yaml_node[ "Z" ] >> z;
  setVector( Ogre::Vector3( x, y, z ));
}
示例#15
0
void RenderingEngine::blurShandowMap(int shandowMapIndex, float blurAmount, Shader* blurFilter){
	setVector("blurScale", Vector3(blurAmount / (shandowMaps.at(shandowMapIndex)->getWidth()), 0.f, 0.f));
	applyFilter(blurFilter, shandowMaps.at(shandowMapIndex), shandowMapTempTargets.at(shandowMapIndex));

	setVector("blurScale", Vector3(0.0f, blurAmount / (shandowMaps.at(shandowMapIndex)->getWidth()), 0.f));
	applyFilter(blurFilter, shandowMapTempTargets.at(shandowMapIndex), shandowMaps.at(shandowMapIndex));

	setVector("blurScale", Vector3(blurAmount / (transparencyShandowMaps.at(shandowMapIndex)->getWidth()), 0.f, 0.f));
	applyFilter(blurFilter, transparencyShandowMaps.at(shandowMapIndex), shandowMapTempTargets.at(shandowMapIndex));

	setVector("blurScale", Vector3(0.0f, blurAmount / (transparencyShandowMaps.at(shandowMapIndex)->getWidth()), 0.f));
	applyFilter(blurFilter, shandowMapTempTargets.at(shandowMapIndex), transparencyShandowMaps.at(shandowMapIndex));




}
示例#16
0
returnValue VariablesGrid::setAllVectors(	const Vector& _values
											)
{
	for( uint i = 0; i < getNumPoints(); i++ )
		ACADO_TRY( setVector( i,_values ) );

	return SUCCESSFUL_RETURN;
}
void MyObj::deleteData()
{
   setColorTable(nullptr);
   setTextColor(nullptr);
   setBackColor(nullptr);
   setVector(nullptr);
   setMessage(nullptr);
}
bool MyObj::setSlotVector(const oe::base::List* const x)
{
   bool ok = false;
   if (x != nullptr) {
      ok = setVector(x);
   }
   return ok;
}
示例#19
0
void NoseDetector::Detect(){


	std::vector<Rect> v_nose;

	nose_classifier->detectMultiScale( frame_ROI, v_nose, 1.1, 2, 0 |CV_HAAR_FIND_BIGGEST_OBJECT, Size(3*18, 3*15) ); //18x15

	setVector(v_nose);
}
示例#20
0
文件: pthread.c 项目: luki00765/MPI
// now main program, as usual, with some options parsing, etc.
int main(int argc, char** argv){

	int i;
	pTimer T = newTimer(); startTimer(T); // let's measure execution time of the whole program.
	// options parsing, configuration and reporting variables
	parseOptions(argc,argv);
	printf("[i] vector size is:    %li\n",SIZE);
	printf("[i] threads requested: %i\n", PTHR);
	printf("[i] total mem for data: %1.2f MB\n",SIZE*sizeof(Data)/1024.0/1024.0);
	if(PTHR<=0){printf("Too few threads, exiting...\n");exit(0);}
	printf("\n");

	// preparing data for calculations
	pVector V = newVector(SIZE); setVector(V,1.0);

	// preparing barrier for all threads involved in calculations
	if(pthread_barrier_init( &barrier, NULL, PTHR)){
		fprintf(stderr,"[E] could not create barrier!\n");
		exit(-1);
	}

	// preparing threads for calculations
	Info threads[PTHR];
	for(i=0;i<PTHR;i++){
		threads[i].nr = i;
		threads[i].V = V;
		threads[i].sum = 0.0;
		threads[i].start = (i  )*SIZE/PTHR;
		threads[i].end   = (i+1)*SIZE/PTHR;
		int rc = pthread_create(&threads[i].id,NULL,reduceVector,(void*) &threads[i]);
		if(rc){
			fprintf(stderr,"[E] thread creation error, code returned: %i\n",rc);
			exit(-1);
		}
		else{
			if(LOUD) printf("[i] thread %i: start=%i, end=%i\n",i,threads[i].start,threads[i].end);
		}
	}

	for(i=0;i<PTHR;i++){
		if(pthread_join(threads[i].id,NULL)){
			fprintf(stderr,"[e] Can't join thread id=%li, nr=%i\n",threads[i].id,threads[i].nr);
			return -1;
		}
	}
	// at the end we have to collect all data from threads
	double sum = 0.0;
	double time = 0.0;
	for(i=0;i<PTHR;i++){
		sum += threads[i].sum;
		time+= threads[i].time;
	}
	stopTimer(T);
	printf("Main sum is %1.2f, avg thread time: %-1.12f s, TOTAL time: %1.12f\n",sum,time/PTHR,getTime(T));
	freeTimer(T);
}
示例#21
0
VGradientEx::VGradientEx( VGradientEx::Type type ) : m_type( type )
{
	// set up dummy gradient
	addStop( ScColor(255,0,0) , 0.0, 0.5, 1.0 );
	addStop( ScColor(255,255,0) , 1.0, 0.5, 1.0 );

	setOrigin( FPoint( 0, 0 ) );
	setVector( FPoint( 0, 50 ) );
	setRepeatMethod( VGradientEx::reflect );
}
示例#22
0
static double getAngle (double s, Geometry *g, Point a, Vector ap)
{
  Point  c;
  Vector ac;

  c  = setPoint (splint(g->npts, s, g->arclen, g->x, g->sx),
                 splint(g->npts, s, g->arclen, g->y, g->sy));
  ac = setVector(a, c);

  return 1. - ((ap.x * ac.x + ap.y * ac.y) / (ap.length * ac.length));
}
示例#23
0
void EyeDetector::Detect(){


	std::vector<Rect> v_eye;


	eye_classifier->detectMultiScale( frame_ROI, v_eye, 1.1, 2, 0 |CV_HAAR_FIND_BIGGEST_OBJECT, Size(18, 12) );//18x12


	setVector(v_eye);
}
示例#24
0
    void
    perm_homogeneous(double k) {
        setVector(0.0, perm_);

        const ::std::size_t d2 = dim_ * dim_;

        for (::std::size_t c = 0, nc = poro_.size(); c < nc; ++c) {
            for (::std::size_t i = 0; i < dim_; ++i) {
                perm_[c*d2 + i*(dim_ + 1)] = k;
            }
        }
    }
示例#25
0
	void cWaterUberShader::setMaterialParam(cMaterial const* mtl)
	{
		setTechnique(m_handle[H_TUBER]);

		if (m_handle[H_DIFFUSE_TEXTURE])
		{
			cTexture* tex = _getTextureMgr()->getTexture(mtl->m_mapBuid[cMaterial::DIFFUSE]);
			setTexture(m_handle[H_DIFFUSE_TEXTURE], tex);
		}
		if (m_handle[H_NORMAL_TEXTURE])
		{
			cTexture* tex = _getTextureMgr()->getTexture(m_normalTexBuid);
			setTexture(m_handle[H_NORMAL_TEXTURE], tex);
		}
		if (m_handle[H_ENVIRONMENT_TEXTURE])
		{
			cTexture* tex = _getTextureMgr()->getTexture(m_environmentTexBuid);
			setTexture(m_handle[H_ENVIRONMENT_TEXTURE], tex);
		}

		if (m_handle[H_TIMER])
		{
			setFloat(m_handle[H_TIMER], m_time);
		}

		setVector(_T("textureScale"),  &m_textureScale);
		setFloat(_T("waveFreq"), m_waveFreq);
		setFloat(_T("waveAmp"), m_waveAmp);
		setFloat(_T("bumpScale"), m_bumpScale);
		setVector(_T("bumpSpeed"), &m_bumpSpeed);
		setVector(_T("deepColor"), &m_deepColor);
		setVector(_T("shallowColor"), &m_shallowColor);
		setFloat(_T("waterAmount"), m_waterAmount);
		setVector(_T("reflectionColor"), &m_reflectionColor);
		setFloat(_T("reflectionAmount"), m_reflectionAmount);
		setFloat(_T("reflectionBlur"), m_reflectionBlur);
		setFloat(_T("fresnelPower"), m_fresnelPower);
		setFloat(_T("fresnelBias"), m_fresnelBias);
		setFloat(_T("hdrMultiplier"), m_hdrMultiplier);
	}
示例#26
0
	/************************************************
	 * Interface to change globally the vector type *
	 ************************************************/
	ALGEB lbSetVector (MKernelVector kv, ALGEB *argv){
		M_INT argc = MapleNumArgs(kv, (ALGEB) argv);
		if (argc != 1){
			MapleRaiseError(kv, "wrong number of arguments");
			return ToMapleNULL(kv);
		}
		if (!IsMapleString(kv, argv[1])){
			MapleRaiseError(kv, "String expected as 1st argument");
			return ToMapleNULL(kv);
		}
		setVector(MapleToString(kv, argv[1]));
		return ToMapleNULL(kv);
	}
示例#27
0
void LayerGradientTest::onTouchesMoved(const std::vector<Touch*>& touches, Event *event)
{
    auto s = Director::getInstance()->getWinSize();

    auto touch = touches[0];
    auto start = touch->getLocation();    

    auto diff =  Vec2(s.width/2,s.height/2) - start;
    diff = diff.getNormalized();

    auto gradient = static_cast<LayerGradient*>( getChildByTag(1) );
    gradient->setVector(diff);
}
示例#28
0
void GuiCreateHexIbMesh::before()
{
  vec3_t x_centre(0,0,0);
  double A = 0;
  for (vtkIdType id_cell = 0; id_cell < m_Grid->GetNumberOfCells(); ++id_cell) {
    if (isSurface(id_cell, m_Grid)) {
      double A_cell = GeometryTools::cellVA(m_Grid, id_cell);
      x_centre += A_cell*cellCentre(m_Grid, id_cell);
      A += A_cell;
    }
  }
  x_centre *= 1.0/A;
  setVector(x_centre, m_Ui.m_LineEditCentre);
}
示例#29
0
VGradient::VGradient( VGradientType type ) : m_type( type )
{
	// set up dummy gradient
	QColor color;

	color = QColor(255,0,0);
	addStop( color, 0.0, 0.5, 1.0 );

	color = QColor(255,255,0);
	addStop( color, 1.0, 0.5, 1.0 );

	setOrigin( FPoint( 0, 0 ) );
	setVector( FPoint( 0, 50 ) );
	setRepeatMethod( VGradient::pad );
}
示例#30
0
returnValue VariablesGrid::appendTimes(	const VariablesGrid& arg,
										MergeMethod _mergeMethod
										)
{
	// nothing to do for empty grids
	if ( arg.getNumPoints( ) == 0 )
		return SUCCESSFUL_RETURN;

	if ( getNumPoints( ) == 0 )
	{
		*this = arg;
		return SUCCESSFUL_RETURN;
	}

	// consistency check
	if ( acadoIsGreater( arg.getFirstTime( ),getLastTime( ) ) == BT_FALSE )
		return ACADOERROR( RET_INVALID_ARGUMENTS );

	if ( acadoIsEqual( getLastTime( ),arg.getFirstTime( ) ) == BT_FALSE )
	{
		// simply append
		for( uint i=0; i<arg.getNumPoints( ); ++i )
			addMatrix( *(arg.values[i]),arg.getTime( i ) );
	}
	else
	{
		// if last and first time point coincide, merge as specified
		switch ( _mergeMethod )
		{
			case MM_KEEP:
				break;

			case MM_REPLACE:
				setVector( getLastIndex(),arg.getFirstVector( ) );
				break;

			case MM_DUPLICATE:
				addMatrix( *(arg.values[0]),arg.getTime( 0 ) );
				break;
		}

		// simply append all remaining points
		for( uint i=1; i<arg.getNumPoints( ); ++i )
			addMatrix( *(arg.values[i]),arg.getTime( i ) );
	}

	return SUCCESSFUL_RETURN;
}