Пример #1
0
bool parseCylinder(Cylinder &y, TiXmlElement *c)
{
  y.clear();

  y.type = Geometry::CYLINDER;
  if (!c->Attribute("length") ||
      !c->Attribute("radius"))
  {
    logError("Cylinder shape must have both length and radius attributes");
    return false;
  }

  if( !stringToDouble(c->Attribute("length"),y.length) )
  {
    std::stringstream stm;
    stm << "length [" << c->Attribute("length") << "] is not a valid float";
    logError(stm.str().c_str());
    return false;
  }

  if( !stringToDouble(c->Attribute("radius"),y.radius))
  {
    std::stringstream stm;
    stm << "radius [" << c->Attribute("radius") << "] is not a valid float";
    logError(stm.str().c_str());
    return false;
  }
  return true;
}
Пример #2
0
bool parseCylinder(Cylinder &y, TiXmlElement *c)
{
  y.clear();

  y.type = Geometry::CYLINDER;
  if (!c->Attribute("length") ||
      !c->Attribute("radius"))
  {
    logError("Cylinder shape must have both length and radius attributes");
    return false;
  }

  try
  {
    y.length = boost::lexical_cast<double>(c->Attribute("length"));
  }
  catch (boost::bad_lexical_cast &e)
  {
  //  std::stringstream stm;
   // stm << "length [" << c->Attribute("length") << "] is not a valid float";
    //logError(stm.str().c_str());
      logError("length");
      return false;
  }

  try
  {
    y.radius = boost::lexical_cast<double>(c->Attribute("radius"));
  }
  catch (boost::bad_lexical_cast &e)
  {
 //   std::stringstream stm;
   // stm << "radius [" << c->Attribute("radius") << "] is not a valid float";
    //logError(stm.str().c_str());
      logError("radius");
      return false;
  }
  return true;
}