Exemple #1
0
bool ReadVectorTerm(ParameterScalar PS[3], TiXmlElement &elem, const char* attr, double val, const char delimiter)
{
	//initialize with default value
	for (int n=0;n<3;++n)
		PS[n].SetValue(val);

	const char* values = elem.Attribute(attr);
	if (values==NULL)
		return false;
	std::vector<string> val_list = SplitString2Vector(values, delimiter);
	if (val_list.size()>3)
		return false;

	for (int n=0;n<3;++n)
		PS[n].SetValue(val);
	for (int n=0;n<(int)val_list.size();++n)
	{
		string sHelp=val_list.at(n);
		size_t tHelp=sHelp.find("term:",0);
		if (tHelp!=0)
			PS[n].SetValue(atof(sHelp.c_str()));
		else
			PS[n].SetValue(sHelp.erase(0,5).c_str());
	}
	return true;
}
Exemple #2
0
bool CSTransform::Translate(std::string translate, bool concatenate)
{
	double matrix[16];

	std::vector<std::string> tl_vec = SplitString2Vector(translate, ',');
	ParameterScalar ps_translate[3];
	double tl_double_vec[3];
	if (tl_vec.size()>3)
		std::cerr << "CSTransform::Translate: Warning: Number of arguments for operation: \"Translate\" with arguments: \"" << translate << "\" is larger than expected, skipping unneeded! " << std::endl;
	else if (tl_vec.size()<3)
	{
		std::cerr << "CSTransform::Translate: Error: Number of arguments for operation: \"Translate\" with arguments: \"" << translate << "\" is invalid! Skipping" << std::endl;
		return false;
	}

	for (int n=0;n<3;++n)
	{
		ps_translate[n].SetParameterSet(m_ParaSet);
		ps_translate[n].SetValue(tl_vec.at(n));
		int EC = ps_translate[n].Evaluate();
		if (EC!=0)
			return false;
		tl_double_vec[n]=ps_translate[n].GetValue();
	}

	if (TranslateMatrix(matrix, tl_double_vec)==false)
		return false;

	ApplyMatrix(matrix,concatenate);
	AppendList(TRANSLATE,ps_translate,3);
	return true;
}
Exemple #3
0
bool CSTransform::RotateOrigin(std::string XYZ_A, bool concatenate)
{
	double matrix[16];

	std::vector<std::string> rot_vec = SplitString2Vector(XYZ_A, ',');
	ParameterScalar ps_rotate[4];
	double rot_double_vec[4];
	if (rot_vec.size()>4)
		std::cerr << "CSTransform::RotateOrigin: Warning: Number of arguments for operation: \"RotateOrigin\" with arguments: \"" << XYZ_A << "\" is larger than expected, skipping unneeded! " << std::endl;
	else if (rot_vec.size()<4)
	{
		std::cerr << "CSTransform::RotateOrigin: Error: Number of arguments for operation: \"RotateOrigin\" with arguments: \"" << XYZ_A << "\" is invalid! Skipping" << std::endl;
		return false;
	}

	for (int n=0;n<4;++n)
	{
		ps_rotate[n].SetParameterSet(m_ParaSet);
		ps_rotate[n].SetValue(rot_vec.at(n));
		int EC = ps_rotate[n].Evaluate();
		if (EC!=0)
			return false;
		rot_double_vec[n]=ps_rotate[n].GetValue();
	}

	if (RotateOriginMatrix(matrix, rot_double_vec)==false)
		return false;

	ApplyMatrix(matrix,concatenate);
	AppendList(ROTATE_ORIGIN,ps_rotate,4);
	return true;
}
Exemple #4
0
bool CSTransform::SetMatrix(std::string matrix, bool concatenate)
{
	std::vector<std::string> mat_vec = SplitString2Vector(matrix, ',');
	ParameterScalar ps_matrix[16];

	double d_matrix[16];
	if (mat_vec.size()>16)
		std::cerr << "CSTransform::SetMatrix: Warning: Number of arguments for operation: \"Matrix\" with arguments: \"" << matrix << "\" is larger than expected, skipping unneeded! " << std::endl;
	else if (mat_vec.size()<16)
	{
		std::cerr << "CSTransform::SetMatrix: Error: Number of arguments for operation: \"Matrix\" with arguments: \"" << matrix << "\" is invalid! Skipping" << std::endl;
		return false;
	}

	for (int n=0;n<16;++n)
	{
		ps_matrix[n].SetParameterSet(m_ParaSet);
		ps_matrix[n].SetValue(mat_vec.at(n));
		int EC = ps_matrix[n].Evaluate();
		if (EC!=0)
			return false;
		d_matrix[n]=ps_matrix[n].GetValue();
	}

	ApplyMatrix(d_matrix,concatenate);
	AppendList(MATRIX,ps_matrix,16);
	return true;
}
Exemple #5
0
bool CSTransform::Scale(std::string scale, bool concatenate)
{
	double matrix[16];

	std::vector<std::string> scale_vec = SplitString2Vector(scale, ',');

	if ((scale_vec.size()>1) && (scale_vec.size()!=3))
		std::cerr << "CSTransform::Scale: Warning: Number of arguments for operation: \"Scale\" with arguments: \"" << scale << "\" is larger than expected, skipping unneeded! " << std::endl;
	else if (scale_vec.size()<1)
	{
		std::cerr << "CSTransform::Scale: Error: Number of arguments for operation: \"Scale\" with arguments: \"" << scale << "\" is invalid! Skipping" << std::endl;
		return false;
	}

	if (scale_vec.size()>=3)
	{
		ParameterScalar ps_scale[3];
		double scale_double_vec[3];
		for (int n=0;n<3;++n)
		{
			ps_scale[n].SetParameterSet(m_ParaSet);
			ps_scale[n].SetValue(scale_vec.at(n));
			int EC = ps_scale[n].Evaluate();
			if (EC!=0)
				return false;
			scale_double_vec[n]=ps_scale[n].GetValue();
		}

		if (ScaleMatrix(matrix, scale_double_vec)==false)
			return false;

		ApplyMatrix(matrix,concatenate);
		AppendList(SCALE3,ps_scale,3);
		return true;
	}

	if(scale_vec.size()>=1)
	{
		ParameterScalar ps_scale(m_ParaSet, scale);
		int EC = ps_scale.Evaluate();
		if (EC!=0)
			return false;

		if (ScaleMatrix(matrix, ps_scale.GetValue())==false)
			return false;

		ApplyMatrix(matrix,concatenate);
		AppendList(SCALE,&ps_scale,1);
		return true;
	}

	std::cerr << "CSTransform::Scale: Error: Number of arguments for operation: \"Scale\" with arguments: \"" << scale << "\" is invalid! Skipping" << std::endl;
	return false;
}