Fix formatting

This commit is contained in:
Oleg Klimov
2017-03-10 19:46:46 +03:00
parent 82495f3c84
commit 3a8199ec28
2 changed files with 34 additions and 9 deletions

View File

@@ -467,13 +467,26 @@ bool findExistingMeshFile(
b3Warning("%s: invalid mesh filename '%s'\n", error_message_prefix.c_str(), fn.c_str()); b3Warning("%s: invalid mesh filename '%s'\n", error_message_prefix.c_str(), fn.c_str());
return false; return false;
} }
std::string ext; std::string ext;
std::string ext_ = fn.substr(fn.size()-4); std::string ext_ = fn.substr(fn.size()-4);
for (std::string::iterator i=ext_.begin(); i!=ext_.end(); ++i) for (std::string::iterator i=ext_.begin(); i!=ext_.end(); ++i)
{
ext += char(tolower(*i)); ext += char(tolower(*i));
if (ext==".dae") *out_type = UrdfGeometry::FILE_COLLADA; }
else if (ext==".stl") *out_type = UrdfGeometry::FILE_STL;
else if (ext==".obj") *out_type = UrdfGeometry::FILE_OBJ; if (ext==".dae")
{
*out_type = UrdfGeometry::FILE_COLLADA;
}
else if (ext==".stl")
{
*out_type = UrdfGeometry::FILE_STL;
}
else if (ext==".obj")
{
*out_type = UrdfGeometry::FILE_OBJ;
}
else else
{ {
b3Warning("%s: invalid mesh filename extension '%s'\n", error_message_prefix.c_str(), ext.c_str()); b3Warning("%s: invalid mesh filename extension '%s'\n", error_message_prefix.c_str(), ext.c_str());
@@ -489,10 +502,13 @@ bool findExistingMeshFile(
shorter.push_back(".."); shorter.push_back("..");
shorter.push_back("."); shorter.push_back(".");
int cnt = urdf_path.size(); int cnt = urdf_path.size();
for (int i=0; i<cnt; ++i) { for (int i=0; i<cnt; ++i)
{
if (urdf_path[i]=='/' || urdf_path[i]=='\\') if (urdf_path[i]=='/' || urdf_path[i]=='\\')
{
shorter.push_back(urdf_path.substr(0, i)); shorter.push_back(urdf_path.substr(0, i));
} }
}
shorter.reverse(); shorter.reverse();
std::string existing_file; std::string existing_file;
@@ -500,7 +516,8 @@ bool findExistingMeshFile(
{ {
std::string attempt = *x + "/" + fn; std::string attempt = *x + "/" + fn;
FILE* f = fopen(attempt.c_str(), "rb"); FILE* f = fopen(attempt.c_str(), "rb");
if (!f) { if (!f)
{
//b3Printf("%s: tried '%s'", error_message_prefix.c_str(), attempt.c_str()); //b3Printf("%s: tried '%s'", error_message_prefix.c_str(), attempt.c_str());
continue; continue;
} }
@@ -514,7 +531,9 @@ bool findExistingMeshFile(
{ {
b3Warning("%s: cannot find '%s' in any directory in urdf path\n", error_message_prefix.c_str(), fn.c_str()); b3Warning("%s: cannot find '%s' in any directory in urdf path\n", error_message_prefix.c_str(), fn.c_str());
return false; return false;
} else { }
else
{
*out_found_filename = existing_file; *out_found_filename = existing_file;
return true; return true;
} }
@@ -590,7 +609,8 @@ btCollisionShape* convertURDFToCollisionShape(const UrdfCollision* collision, co
case URDF_GEOM_MESH: case URDF_GEOM_MESH:
{ {
GLInstanceGraphicsShape* glmesh = 0; GLInstanceGraphicsShape* glmesh = 0;
switch (collision->m_geometry.m_meshFileType) { switch (collision->m_geometry.m_meshFileType)
{
case FILE_OBJ: case FILE_OBJ:
if (collision->m_flags & URDF_FORCE_CONCAVE_TRIMESH) if (collision->m_flags & URDF_FORCE_CONCAVE_TRIMESH)
{ {

View File

@@ -439,7 +439,8 @@ bool UrdfParser::parseGeometry(UrdfGeometry& geom, TiXmlElement* g, ErrorLogger*
} }
else else
{ {
if (!shape->Attribute("filename")) { if (!shape->Attribute("filename"))
{
logger->reportError("Mesh must contain a filename attribute"); logger->reportError("Mesh must contain a filename attribute");
return false; return false;
} }
@@ -447,7 +448,11 @@ bool UrdfParser::parseGeometry(UrdfGeometry& geom, TiXmlElement* g, ErrorLogger*
bool success = findExistingMeshFile( bool success = findExistingMeshFile(
m_urdf2Model.m_sourceFile, shape->Attribute("filename"), sourceFileLocation(shape), m_urdf2Model.m_sourceFile, shape->Attribute("filename"), sourceFileLocation(shape),
&geom.m_meshFileName, &geom.m_meshFileType); &geom.m_meshFileName, &geom.m_meshFileType);
if (!success) return false; // warning printed if (!success)
{
// warning printed
return false;
}
geom.m_meshScale.setValue(1,1,1); geom.m_meshScale.setValue(1,1,1);
if (shape->Attribute("scale")) if (shape->Attribute("scale"))