diff --git a/src/meshlabplugins/io_x3d/import_x3d.h b/src/meshlabplugins/io_x3d/import_x3d.h index 15bc13480..b3c10a6bf 100644 --- a/src/meshlabplugins/io_x3d/import_x3d.h +++ b/src/meshlabplugins/io_x3d/import_x3d.h @@ -767,6 +767,9 @@ namespace io { textureFile.push_back(url); } } + QDomElement materialNode = appearance.firstChildElement("Material"); + if (!materialNode.attribute("diffuseColor", "").isEmpty()) + bHasPerVertexColor = true; } QDomElement geometry = shape.firstChildElement(); while(!geometry.isNull()) @@ -775,7 +778,7 @@ namespace io { QString coorTag[] = {"Coordinate", "CoordinateDouble"}; QDomElement coordinate = findNode(coorTag, 2, geometry); //If geometry node is supported, get info on color, normal and texture coordinate (per vertex, per color, or per wedge) - if ((!coordinate.isNull() && (coordinate.attribute("point")!= "")) || (tagName == "ElevationGrid")) + if ((!coordinate.isNull() && ((coordinate.attribute("point")!= "") || coordinate.attribute("USE", "") != "")) || (tagName == "ElevationGrid")) { bool copyTextureFile = true; QStringList colorList, normalList, textureList; @@ -796,12 +799,12 @@ namespace io { findAndParseAttribute(coordIndex, geometry, "index", ""); if (!coordIndex.isEmpty()) { - if (!color.isNull() && !colorList.isEmpty()) bHasPerVertexColor = true; - if (!textureCoor.isNull() && (textureGenSup || !textureList.isEmpty()) && textureFile.size()>0) + if (!color.isNull() && (!colorList.isEmpty() || color.attribute("USE", "") != "")) bHasPerVertexColor = true; + if (!textureCoor.isNull() && (textureGenSup || !textureList.isEmpty() || textureCoor.attribute("USE", "") != "") && textureFile.size()>0) bHasPerVertexText = true; else copyTextureFile = false; - if (!normal.isNull() && !normalList.isEmpty()) + if (!normal.isNull() && (!normalList.isEmpty() || normal.attribute("USE", "") != "")) { if (normalPerVertex == "true") bHasPerVertexNormal = true; @@ -812,12 +815,12 @@ namespace io { } else if (tagName == "TriangleFanSet" || tagName == "TriangleSet" || tagName == "TriangleStripSet" || tagName == "QuadSet") { - if (!color.isNull() && !colorList.isEmpty()) bHasPerWedgeColor = true; - if (!textureCoor.isNull() && (textureGenSup || !textureList.isEmpty()) && textureFile.size()>0) + if (!color.isNull() && (!colorList.isEmpty() || color.attribute("USE", "") != "")) bHasPerWedgeColor = true; + if (!textureCoor.isNull() && (textureGenSup || !textureList.isEmpty() || textureCoor.attribute("USE", "") != "") && textureFile.size()>0) bHasPerWedgeTexCoord = true; else copyTextureFile = false; - if (!normal.isNull() && !normalList.isEmpty()) + if (!normal.isNull() && (!normalList.isEmpty() || normal.attribute("USE", "") != "")) { if (normalPerVertex == "true") bHasPerWedgeNormal = true; @@ -834,7 +837,7 @@ namespace io { findAndParseAttribute(coordIndex, geometry, "coordIndex", ""); if (!coordIndex.isEmpty()) { - if (!textureCoor.isNull() && (textureGenSup || !textureList.isEmpty()) && textureFile.size()>0) + if (!textureCoor.isNull() && (textureGenSup || !textureList.isEmpty() || textureCoor.attribute("USE", "") != "") && textureFile.size()>0) { if (!texCoordIndex.isEmpty()) bHasPerWedgeTexCoord = true; @@ -843,7 +846,7 @@ namespace io { } else copyTextureFile = false; - if (!color.isNull() && !colorList.isEmpty()) + if (!color.isNull() && (!colorList.isEmpty() || color.attribute("USE", "") != "")) { if (colorPerVertex == "true" && !colorIndex.isEmpty()) bHasPerWedgeColor = true; @@ -852,7 +855,7 @@ namespace io { else bHasPerFaceColor = true; } - if (!normal.isNull() && !normalList.isEmpty()) + if (!normal.isNull() && (!normalList.isEmpty() || normal.attribute("USE", "") != "")) { if (normalPerVertex == "true" && !normalIndex.isEmpty()) bHasPerWedgeNormal = true; @@ -869,18 +872,18 @@ namespace io { int zDimension = geometry.attribute("zDimension", "0").toInt(); if (xDimension != 0 && zDimension!=0) { - if (!textureCoor.isNull() && (textureGenSup || !textureList.isEmpty()) && textureFile.size()>0) + if (!textureCoor.isNull() && (textureGenSup || !textureList.isEmpty() || textureCoor.attribute("USE", "") != "") && textureFile.size()>0) bHasPerVertexText = true; else copyTextureFile = false; - if (!color.isNull() && !colorList.isEmpty()) + if (!color.isNull() && (!colorList.isEmpty() || color.attribute("USE", "") != "")) { if (colorPerVertex == "true") bHasPerVertexColor = true; else bHasPerFaceColor = true; } - if (!normal.isNull() && !normalList.isEmpty()) + if (!normal.isNull() && (!normalList.isEmpty() || normal.attribute("USE", "") != "")) { if (normalPerVertex == "true") bHasPerVertexNormal = true; @@ -889,7 +892,7 @@ namespace io { } } } - else if (tagName == "PointSet" && !color.isNull() && !colorList.isEmpty()) + else if (tagName == "PointSet" && !color.isNull() && (!colorList.isEmpty() || color.attribute("USE", "") != "")) { bHasPerVertexColor = true; copyTextureFile = false; @@ -1005,6 +1008,8 @@ namespace io { vcg::Point4f tmp = tMatrix * vertexSet.at(vv); m.vert[offset + vv].P() = vcg::Point3f(tmp.X(),tmp.Y(),tmp.Z()); loadDefaultValuePerVertex(&(m.vert[offset + vv]), m, info->mask); + if (m.HasPerVertexColor() && (info->mask & vcg::tri::io::Mask::IOM_VERTCOLOR) && info->meshColor) + m.vert[offset + vv].C() = info->color; } //Load faces in the mesh int offsetFace = m.face.size(); @@ -1027,7 +1032,7 @@ namespace io { getNormal(normalList, (tt + ff*3)*3, m.face[faceIndex].WN(vertIndexPerFace), tMatrix); //Load color per wedge if (HasPerWedgeColor(m) && (info->mask & vcg::tri::io::Mask::IOM_WEDGCOLOR)) - getColor(colorList, colorComponent, (tt + ff*3)*colorComponent, m.face[faceIndex].WC(vertIndexPerFace)); + getColor(colorList, colorComponent, (tt + ff*3)*colorComponent, m.face[faceIndex].WC(vertIndexPerFace), vcg::Color4b(Color4b::White)); //Load textureCoordinate per wedge if (HasPerWedgeTexCoord(m) && (info->mask & vcg::tri::io::Mask::IOM_WEDGTEXCOORD)) getTextureCoord(texture, (tt + ff*3)*2, m.vert[vertexFaceIndex.at(tt + ff*3) + offset].cP(), m.face[faceIndex].WT(vertIndexPerFace), tMatrix); @@ -1085,8 +1090,8 @@ namespace io { getNormal(normalList, index*3 + 3, secondNormal, tMatrix); } vcg::Color4b firstColor, secondColor; - getColor(colorList, colorComponent, index*colorComponent, firstColor); - getColor(colorList, colorComponent, index*colorComponent + colorComponent, secondColor); + getColor(colorList, colorComponent, index*colorComponent, firstColor, vcg::Color4b(Color4b::White)); + getColor(colorList, colorComponent, index*colorComponent + colorComponent, secondColor, vcg::Color4b(Color4b::White)); vcg::TexCoord2 firstTextCoord, secondTextCoord; getTextureCoord(texture, index*2, m.vert[vertexFaceIndex.at(index) + offset].cP(), firstTextCoord, tMatrix); getTextureCoord(texture, index*2, m.vert[vertexFaceIndex.at(index + 1) + offset].cP(), secondTextCoord, tMatrix); @@ -1121,7 +1126,7 @@ namespace io { if ((info->mask & vcg::tri::io::Mask::IOM_FACENORMAL) && normalPerVertex == "false" && HasPerFaceNormal(m)) getNormal(normalList, ff*3, m.face[faceIndex].N(), tMatrix); if ((info->mask & vcg::tri::io::Mask::IOM_WEDGCOLOR) && HasPerWedgeColor(m)) - getColor(colorList, colorComponent, (index + vi)*colorComponent, m.face[faceIndex].WC(2 - vertIndexPerFace)); + getColor(colorList, colorComponent, (index + vi)*colorComponent, m.face[faceIndex].WC(2 - vertIndexPerFace), vcg::Color4b(Color4b::White)); if (HasPerWedgeTexCoord(m) && (info->mask & vcg::tri::io::Mask::IOM_WEDGTEXCOORD)) getTextureCoord(texture, (index + vi)*2, m.vert[vertexFaceIndex.at(index + vi) + offset].cP(), m.face[faceIndex].WT(2 - vertIndexPerFace), tMatrix); @@ -1184,7 +1189,7 @@ namespace io { getNormal(normalList, indexVertex*3, m.face[faceIndex].WN(vertIndexPerFace), tMatrix); //Load color per wedge if (HasPerWedgeColor(m) && (info->mask & vcg::tri::io::Mask::IOM_WEDGCOLOR)) - getColor(colorList, colorComponent, indexVertex*colorComponent, m.face[faceIndex].WC(vertIndexPerFace)); + getColor(colorList, colorComponent, indexVertex*colorComponent, m.face[faceIndex].WC(vertIndexPerFace), vcg::Color4b(Color4b::White)); //Load texture coordinate per wedge if (HasPerWedgeTexCoord(m) && (info->mask & vcg::tri::io::Mask::IOM_WEDGTEXCOORD)) getTextureCoord(texture, indexVertex*2, m.vert[vertexFaceIndex.at(indexVertex) + offset].cP(), m.face[faceIndex].WT(vertIndexPerFace), tMatrix); @@ -1226,6 +1231,11 @@ namespace io { int offset = m.vert.size(); int nVertex = coordList.size()/3; vcg::tri::Allocator::AddVertices(m, nVertex); + vcg::Color4b defValue; + if (info->meshColor) + defValue = info->color; + else + defValue = vcg::Color4b(Color4b::White); for (int vv = 0; vv < nVertex; vv++) { vcg::Point4f tmp = tMatrix * vcg::Point4f(coordList.at(vv*3).toFloat(), coordList.at(vv*3 + 1).toFloat(), coordList.at(vv*3 + 2).toFloat(), 1.0); @@ -1235,7 +1245,7 @@ namespace io { getNormal(normalList, vv*3, m.vert[offset + vv].N(), tMatrix); //Load color per vertex if (m.HasPerVertexColor() && (info->mask & vcg::tri::io::Mask::IOM_VERTCOLOR)) - getColor(colorList, colorComponent, vv*3, m.vert[offset + vv].C()); + getColor(colorList, colorComponent, vv*3, m.vert[offset + vv].C(), defValue); //Load texture coordinate per vertex if (m.HasPerVertexTexCoord() && (info->mask & vcg::tri::io::Mask::IOM_VERTCOORD)) getTextureCoord(texture, vv*2, m.vert[offset + vv].cP(), m.vert[offset + vv].T(), tMatrix); @@ -1465,6 +1475,11 @@ namespace io { vcg::tri::Allocator::AddFaces(m, (xDimension - 1)*(zDimension - 1)*2); //Load vertex in the mesh int index = 0; + vcg::Color4b defValue; + if (info->meshColor) + defValue = info->color; + else + defValue = vcg::Color4b(Color4b::White); for (int i=0; i < zDimension; i++) { for (int j=0; j < xDimension; j++) @@ -1478,9 +1493,9 @@ namespace io { if (m.HasPerVertexColor() && (info->mask & vcg::tri::io::Mask::IOM_VERTCOLOR)) { if (colorPerVertex == "true") - getColor(colorList, colorComponent, index * colorComponent, m.vert[index + offsetVertex].C()); + getColor(colorList, colorComponent, index * colorComponent, m.vert[index + offsetVertex].C(), defValue); else - m.vert[index + offsetVertex].C() = vcg::Color4b(vcg::Color4b::White); + m.vert[index + offsetVertex].C() = defValue; } //Load normal per vertex if (m.HasPerVertexNormal() && normalPerVertex == "true" && (info->mask & vcg::tri::io::Mask::IOM_VERTNORMAL)) @@ -1522,7 +1537,7 @@ namespace io { if (HasPerFaceColor(m) && (info->mask & vcg::tri::io::Mask::IOM_FACECOLOR)) { if (colorPerVertex == "false") - getColor(colorList, colorComponent, (index + ff) * colorComponent, m.face[index + offsetFace].C()); + getColor(colorList, colorComponent, (index + ff) * colorComponent, m.face[index + offsetFace].C(), vcg::Color4b(Color4b::White)); else m.face[index + offsetFace].C() = vcg::Color4b(vcg::Color4b::White); } @@ -1567,6 +1582,11 @@ namespace io { int nVertex = coordList.size()/3; //Load vertex in the mesh vcg::tri::Allocator::AddVertices(m, nVertex); + vcg::Color4b defValue; + if (info->meshColor) + defValue = info->color; + else + defValue = vcg::Color4b(Color4b::White); for (int vv = 0; vv < nVertex; vv++) { vcg::Point4f tmp = tMatrix * vcg::Point4f(coordList.at(vv*3).toFloat(), coordList.at(vv*3 + 1).toFloat(), coordList.at(vv*3 + 2).toFloat(), 1.0); @@ -1575,9 +1595,9 @@ namespace io { if (m.HasPerVertexColor() && (info->mask & vcg::tri::io::Mask::IOM_VERTCOLOR)) { if (colorPerVertex == "true") - getColor(colorList, colorComponent, vv*colorComponent, m.vert[offset + vv].C()); + getColor(colorList, colorComponent, vv*colorComponent, m.vert[offset + vv].C(), defValue); else - m.vert[offset + vv].C() = vcg::Color4b(vcg::Color4b::White); + m.vert[offset + vv].C() = defValue; } //Load normal per vertex if (m.HasPerVertexNormal() && normalPerVertex == "true" && (info->mask & vcg::tri::io::Mask::IOM_VERTNORMAL)) @@ -1653,7 +1673,7 @@ namespace io { if (HasPerWedgeColor(m) && (info->mask & vcg::tri::io::Mask::IOM_WEDGCOLOR)) { if (index < colorIndex.size() && colorPerVertex == "true") - getColor(colorList, colorComponent, colorIndex.at(indexVect.at(tt + ff*3) + initPolygon).toInt() * colorComponent, m.face[ff + offsetFace].WC(vertIndexPerFace)); + getColor(colorList, colorComponent, colorIndex.at(indexVect.at(tt + ff*3) + initPolygon).toInt() * colorComponent, m.face[ff + offsetFace].WC(vertIndexPerFace), vcg::Color4b(Color4b::White)); else m.face[ff + offsetFace].WC(vertIndexPerFace) = vcg::Color4b(vcg::Color4b::White); } @@ -1689,9 +1709,9 @@ namespace io { if (colorPerVertex == "false") { if (!colorIndex.isEmpty() && ff < colorIndex.size() && colorIndex.at(ff).toInt() > -1) - getColor(colorList, colorComponent, colorIndex.at(j).toInt() * colorComponent, m.face[ff + offsetFace].C()); + getColor(colorList, colorComponent, colorIndex.at(j).toInt() * colorComponent, m.face[ff + offsetFace].C(), vcg::Color4b(Color4b::White)); else - getColor(colorList, colorComponent, j*colorComponent, m.face[ff + offsetFace].C()); + getColor(colorList, colorComponent, j*colorComponent, m.face[ff + offsetFace].C(), vcg::Color4b(Color4b::White)); } else m.face[ff + offsetFace].C() = vcg::Color4b(vcg::Color4b::White); @@ -1722,6 +1742,11 @@ namespace io { int offset = m.vert.size(); int nVertex = coordList.size()/3; vcg::tri::Allocator::AddVertices(m, nVertex); + vcg::Color4b defValue; + if (info->meshColor) + defValue = info->color; + else + defValue = vcg::Color4b(Color4b::White); for (int vv = 0; vv < nVertex; vv++) { vcg::Point4f tmp(coordList.at(vv*3).toFloat(), coordList.at(vv*3 + 1).toFloat(), coordList.at(vv*3 + 2).toFloat(), 1.0); @@ -1729,7 +1754,7 @@ namespace io { m.vert[vv + offset].P() = vcg::Point3f(tmp.X(), tmp.Y(), tmp.Z()); //Load color per vertex if (m.HasPerVertexColor() && (info->mask & vcg::tri::io::Mask::IOM_VERTCOLOR)) - getColor(colorList, colorComponent, vv*colorComponent, m.vert[vv + offset].C()); + getColor(colorList, colorComponent, vv*colorComponent, m.vert[vv + offset].C(), defValue); if (m.HasPerVertexTexCoord() && (info->mask & vcg::tri::io::Mask::IOM_VERTCOORD)) { m.vert[vv + offset].T() = vcg::TexCoord2<>(); @@ -1914,6 +1939,19 @@ namespace io { } } textTransfList = appearance.elementsByTagName("TextureTransform"); + QDomElement materialNode = appearance.firstChildElement("Material"); + QStringList list; + findAndParseAttribute(list, materialNode, "diffuseColor", ""); + if (list.size() >= 3) + { + vcg::Color4f color(list.at(0).toFloat(), list.at( 1).toFloat(), list.at(2).toFloat(), 1); + vcg::Color4b colorB; + colorB.Import(color); + info->color = colorB; + } + else + info->meshColor = false; + } return E_NOERROR; } @@ -2224,7 +2262,7 @@ namespace io { //If the index is valid, return the color of index 'index' - inline static void getColor(const QStringList& list, int component, int index, vcg::Color4b& dest) + inline static void getColor(const QStringList& list, int component, int index, vcg::Color4b& dest, vcg::Color4b& defValue) { if(!list.isEmpty() && (index + component - 1) < list.size()) { @@ -2238,7 +2276,7 @@ namespace io { dest = colorB; } else - dest = vcg::Color4b(vcg::Color4b::White); + dest = defValue; } @@ -2376,6 +2414,8 @@ namespace io { if (result != E_NOERROR) return result; QStringList colorList; findAndParseAttribute(colorList, color, "color", ""); + if (!colorList.isEmpty()) + info->meshColor = false; //GetNormal QDomElement normal = geometry.firstChildElement("Normal"); result = solveDefUse(normal, defMap, normal, info); diff --git a/src/meshlabplugins/io_x3d/util_x3d.h b/src/meshlabplugins/io_x3d/util_x3d.h index b264485a3..129e43ddf 100644 --- a/src/meshlabplugins/io_x3d/util_x3d.h +++ b/src/meshlabplugins/io_x3d/util_x3d.h @@ -75,6 +75,9 @@ namespace io { int lineNumberError; std::vector filenameStack; + + bool meshColor; + vcg::Color4b color; AdditionalInfoX3D() :AdditionalInfo() diff --git a/src/meshlabplugins/io_x3d/vrml/Parser.cpp b/src/meshlabplugins/io_x3d/vrml/Parser.cpp index 247b342b9..6fe253db0 100644 --- a/src/meshlabplugins/io_x3d/vrml/Parser.cpp +++ b/src/meshlabplugins/io_x3d/vrml/Parser.cpp @@ -812,9 +812,9 @@ void Parser::SingleValue(QDomElement& parent, QString fieldName, bool flag) { } else if (la->kind == 2 || la->kind == 3) { if (la->kind == 2) { Get(); - } else if (la->kind == 3) { + } else { Get(); - } else SynErr(102); + } value.append(coco_string_create_char(t->val)); if (la->kind == 37) { Get(); @@ -857,7 +857,7 @@ void Parser::SingleValue(QDomElement& parent, QString fieldName, bool flag) { } else parent.appendChild(tmpParent.firstChildElement()); - } else SynErr(103); + } else SynErr(102); } void Parser::MultiValue(QDomElement& parent, QString fieldName, bool flag) { @@ -905,7 +905,7 @@ void Parser::MultiValue(QDomElement& parent, QString fieldName, bool flag) { if (flag) parent.appendChild(field); - } else SynErr(104); + } else SynErr(103); Expect(23); } @@ -914,7 +914,7 @@ void Parser::MultiNumber(QString& value) { Get(); } else if (la->kind == 3) { Get(); - } else SynErr(105); + } else SynErr(104); value.append(coco_string_create_char(t->val)); if (la->kind == 37) { Get(); @@ -952,7 +952,7 @@ void Parser::MultiBool(QString& value) { Get(); } else if (la->kind == 84) { Get(); - } else SynErr(106); + } else SynErr(105); value.append(coco_string_create_char(t->val)); if (la->kind == 37) { Get(); @@ -1137,10 +1137,9 @@ void Errors::SynErr(int line, int col, int n) { case 100: s = coco_string_create(L"invalid ScriptBodyElement"); break; case 101: s = coco_string_create(L"invalid ScriptBodyElement"); break; case 102: s = coco_string_create(L"invalid SingleValue"); break; - case 103: s = coco_string_create(L"invalid SingleValue"); break; - case 104: s = coco_string_create(L"invalid MultiValue"); break; - case 105: s = coco_string_create(L"invalid MultiNumber"); break; - case 106: s = coco_string_create(L"invalid MultiBool"); break; + case 103: s = coco_string_create(L"invalid MultiValue"); break; + case 104: s = coco_string_create(L"invalid MultiNumber"); break; + case 105: s = coco_string_create(L"invalid MultiBool"); break; default: { @@ -1178,6 +1177,6 @@ void Errors::Exception(const wchar_t* s) { exit(1); } */ -}; // namespace +} // namespace diff --git a/src/meshlabplugins/io_x3d/vrml/Parser.h b/src/meshlabplugins/io_x3d/vrml/Parser.h index c663d0695..b266953b0 100644 --- a/src/meshlabplugins/io_x3d/vrml/Parser.h +++ b/src/meshlabplugins/io_x3d/vrml/Parser.h @@ -128,7 +128,7 @@ QDomDocument *doc; x3dNode.insert("Layer"); x3dNode.insert("LayerSet"); x3dNode.insert("Layout"); x3dNode.insert("LayoutGroup"); x3dNode.insert("LayoutLayer"); x3dNode.insert("LinePicker"); x3dNode.insert("LineProperties"); x3dNode.insert("LineSet"); x3dNode.insert("LoadSensor"); - x3dNode.insert("LocalFog"); x3dNode.insert("Matrix3VertexAttribute"); + x3dNode.insert("LocalFog"); x3dNode.insert("Material"); x3dNode.insert("Matrix3VertexAttribute"); x3dNode.insert("Matrix4VertexAttribute"); x3dNode.insert("MetadataDouble"); x3dNode.insert("MetadataFloat"); x3dNode.insert("MetadataInteger"); x3dNode.insert("MetadataSet"); x3dNode.insert("MetadataString"); x3dNode.insert("MotorJoint"); x3dNode.insert("MultiTexture"); @@ -225,7 +225,7 @@ QDomDocument *doc; }; // end Parser -}; // namespace +} // namespace #endif // !defined(VRML_PARSER_H__) diff --git a/src/meshlabplugins/io_x3d/vrml/Scanner.cpp b/src/meshlabplugins/io_x3d/vrml/Scanner.cpp index bbfa3112d..674d3e7be 100644 --- a/src/meshlabplugins/io_x3d/vrml/Scanner.cpp +++ b/src/meshlabplugins/io_x3d/vrml/Scanner.cpp @@ -597,7 +597,7 @@ void Scanner::AddCh() { delete [] tval; tval = newBuf; } - tval[tlen++] = ch; + tval[tlen++] = ch; NextCh(); } @@ -664,9 +664,9 @@ void Scanner::AppendVal(Token *t) { Token* Scanner::NextToken() { while (ch == ' ' || - ch >= 9 && ch <= 10 || ch == 13 + (ch >= 9 && ch <= 10) || ch == 13 ) NextCh(); - if (ch == L'#' && Comment0()) return NextToken(); + if ((ch == L'#' && Comment0())) return NextToken(); t = CreateToken(); t->pos = pos; t->col = col; t->line = line; int state = start.state(ch); @@ -677,133 +677,133 @@ Token* Scanner::NextToken() { case 0: { t->kind = noSym; break; } // NextCh already done case 1: case_1: - if (ch == L'!' || ch >= L'$' && ch <= L'&' || ch >= L'(' && ch <= L'+' || ch == L'-' || ch >= L'/' && ch <= L'Z' || ch >= L'^' && ch <= L'z' || ch == L'|' || ch == L'~' || ch >= 128 && ch <= 65535) {AddCh(); goto case_1;} + if (ch == L'!' || (ch >= L'$' && ch <= L'&') || (ch >= L'(' && ch <= L'+') || ch == L'-' || (ch >= L'/' && ch <= L'Z') || (ch >= L'^' && ch <= L'z') || ch == L'|' || ch == L'~' || (ch >= 128 && ch <= 65535)) {AddCh(); goto case_1;} else {t->kind = 1; wchar_t *literal = coco_string_create(tval, 0, tlen); t->kind = keywords.get(literal, t->kind); coco_string_delete(literal); break;} case 2: case_2: - if (ch >= L'0' && ch <= L'9' || ch >= L'A' && ch <= L'F' || ch >= L'a' && ch <= L'f') {AddCh(); goto case_3;} + if ((ch >= L'0' && ch <= L'9') || (ch >= L'A' && ch <= L'F') || (ch >= L'a' && ch <= L'f')) {AddCh(); goto case_3;} else {t->kind = noSym; break;} case 3: case_3: - if (ch >= L'0' && ch <= L'9' || ch >= L'A' && ch <= L'F' || ch >= L'a' && ch <= L'f') {AddCh(); goto case_3;} + if ((ch >= L'0' && ch <= L'9') || (ch >= L'A' && ch <= L'F') || (ch >= L'a' && ch <= L'f')) {AddCh(); goto case_3;} else {t->kind = 2; break;} case 4: case_4: - if (ch >= L'0' && ch <= L'9') {AddCh(); goto case_5;} + if ((ch >= L'0' && ch <= L'9')) {AddCh(); goto case_5;} else {t->kind = noSym; break;} case 5: case_5: - if (ch >= L'0' && ch <= L'9') {AddCh(); goto case_5;} + if ((ch >= L'0' && ch <= L'9')) {AddCh(); goto case_5;} else if (ch == L'E' || ch == L'e') {AddCh(); goto case_6;} else {t->kind = 3; break;} case 6: case_6: - if (ch >= L'0' && ch <= L'9') {AddCh(); goto case_8;} + if ((ch >= L'0' && ch <= L'9')) {AddCh(); goto case_8;} else if (ch == L'+' || ch == L'-') {AddCh(); goto case_7;} else {t->kind = noSym; break;} case 7: case_7: - if (ch >= L'0' && ch <= L'9') {AddCh(); goto case_8;} + if ((ch >= L'0' && ch <= L'9')) {AddCh(); goto case_8;} else {t->kind = noSym; break;} case 8: case_8: - if (ch >= L'0' && ch <= L'9') {AddCh(); goto case_8;} + if ((ch >= L'0' && ch <= L'9')) {AddCh(); goto case_8;} else {t->kind = 3; break;} case 9: case_9: - if (ch >= L'0' && ch <= L'9') {AddCh(); goto case_9;} + if ((ch >= L'0' && ch <= L'9')) {AddCh(); goto case_9;} else if (ch == L'E' || ch == L'e') {AddCh(); goto case_10;} else {t->kind = 3; break;} case 10: case_10: - if (ch >= L'0' && ch <= L'9') {AddCh(); goto case_12;} + if ((ch >= L'0' && ch <= L'9')) {AddCh(); goto case_12;} else if (ch == L'+' || ch == L'-') {AddCh(); goto case_11;} else {t->kind = noSym; break;} case 11: case_11: - if (ch >= L'0' && ch <= L'9') {AddCh(); goto case_12;} + if ((ch >= L'0' && ch <= L'9')) {AddCh(); goto case_12;} else {t->kind = noSym; break;} case 12: case_12: - if (ch >= L'0' && ch <= L'9') {AddCh(); goto case_12;} + if ((ch >= L'0' && ch <= L'9')) {AddCh(); goto case_12;} else {t->kind = 3; break;} case 13: case_13: - if (ch >= L'0' && ch <= L'9') {AddCh(); goto case_15;} + if ((ch >= L'0' && ch <= L'9')) {AddCh(); goto case_15;} else if (ch == L'+' || ch == L'-') {AddCh(); goto case_14;} else {t->kind = noSym; break;} case 14: case_14: - if (ch >= L'0' && ch <= L'9') {AddCh(); goto case_15;} + if ((ch >= L'0' && ch <= L'9')) {AddCh(); goto case_15;} else {t->kind = noSym; break;} case 15: case_15: - if (ch >= L'0' && ch <= L'9') {AddCh(); goto case_15;} + if ((ch >= L'0' && ch <= L'9')) {AddCh(); goto case_15;} else {t->kind = 3; break;} case 16: case_16: - if (ch <= L'!' || ch >= L'#' && ch <= L'[' || ch >= L']' && ch <= 65535) {AddCh(); goto case_16;} + if (ch <= L'!' || (ch >= L'#' && ch <= L'[') || (ch >= L']' && ch <= 65535)) {AddCh(); goto case_16;} else if (ch == L'"') {AddCh(); goto case_31;} else if (ch == 92) {AddCh(); goto case_39;} else {t->kind = noSym; break;} case 17: case_17: - if (ch >= L'0' && ch <= L'9' || ch >= L'A' && ch <= L'F' || ch >= L'a' && ch <= L'f') {AddCh(); goto case_18;} + if ((ch >= L'0' && ch <= L'9') || (ch >= L'A' && ch <= L'F') || (ch >= L'a' && ch <= L'f')) {AddCh(); goto case_18;} else {t->kind = noSym; break;} case 18: case_18: - if (ch <= L'!' || ch >= L'#' && ch <= L'/' || ch >= L':' && ch <= L'@' || ch >= L'G' && ch <= L'[' || ch >= L']' && ch <= L'`' || ch >= L'g' && ch <= 65535) {AddCh(); goto case_16;} - else if (ch >= L'0' && ch <= L'9' || ch >= L'A' && ch <= L'F' || ch >= L'a' && ch <= L'f') {AddCh(); goto case_40;} + if (ch <= L'!' || (ch >= L'#' && ch <= L'/') || (ch >= L':' && ch <= L'@') || (ch >= L'G' && ch <= L'[') || (ch >= L']' && ch <= L'`') || (ch >= L'g' && ch <= 65535)) {AddCh(); goto case_16;} + else if ((ch >= L'0' && ch <= L'9') || (ch >= L'A' && ch <= L'F') || (ch >= L'a' && ch <= L'f')) {AddCh(); goto case_40;} else if (ch == L'"') {AddCh(); goto case_31;} else if (ch == 92) {AddCh(); goto case_39;} else {t->kind = noSym; break;} case 19: case_19: - if (ch >= L'0' && ch <= L'9' || ch >= L'A' && ch <= L'F' || ch >= L'a' && ch <= L'f') {AddCh(); goto case_20;} + if ((ch >= L'0' && ch <= L'9') || (ch >= L'A' && ch <= L'F') || (ch >= L'a' && ch <= L'f')) {AddCh(); goto case_20;} else {t->kind = noSym; break;} case 20: case_20: - if (ch >= L'0' && ch <= L'9' || ch >= L'A' && ch <= L'F' || ch >= L'a' && ch <= L'f') {AddCh(); goto case_21;} + if ((ch >= L'0' && ch <= L'9') || (ch >= L'A' && ch <= L'F') || (ch >= L'a' && ch <= L'f')) {AddCh(); goto case_21;} else {t->kind = noSym; break;} case 21: case_21: - if (ch >= L'0' && ch <= L'9' || ch >= L'A' && ch <= L'F' || ch >= L'a' && ch <= L'f') {AddCh(); goto case_22;} + if ((ch >= L'0' && ch <= L'9') || (ch >= L'A' && ch <= L'F') || (ch >= L'a' && ch <= L'f')) {AddCh(); goto case_22;} else {t->kind = noSym; break;} case 22: case_22: - if (ch >= L'0' && ch <= L'9' || ch >= L'A' && ch <= L'F' || ch >= L'a' && ch <= L'f') {AddCh(); goto case_16;} + if ((ch >= L'0' && ch <= L'9') || (ch >= L'A' && ch <= L'F') || (ch >= L'a' && ch <= L'f')) {AddCh(); goto case_16;} else {t->kind = noSym; break;} case 23: case_23: - if (ch >= L'0' && ch <= L'9' || ch >= L'A' && ch <= L'F' || ch >= L'a' && ch <= L'f') {AddCh(); goto case_24;} + if ((ch >= L'0' && ch <= L'9') || (ch >= L'A' && ch <= L'F') || (ch >= L'a' && ch <= L'f')) {AddCh(); goto case_24;} else {t->kind = noSym; break;} case 24: case_24: - if (ch >= L'0' && ch <= L'9' || ch >= L'A' && ch <= L'F' || ch >= L'a' && ch <= L'f') {AddCh(); goto case_25;} + if ((ch >= L'0' && ch <= L'9') || (ch >= L'A' && ch <= L'F') || (ch >= L'a' && ch <= L'f')) {AddCh(); goto case_25;} else {t->kind = noSym; break;} case 25: case_25: - if (ch >= L'0' && ch <= L'9' || ch >= L'A' && ch <= L'F' || ch >= L'a' && ch <= L'f') {AddCh(); goto case_26;} + if ((ch >= L'0' && ch <= L'9') || (ch >= L'A' && ch <= L'F') || (ch >= L'a' && ch <= L'f')) {AddCh(); goto case_26;} else {t->kind = noSym; break;} case 26: case_26: - if (ch >= L'0' && ch <= L'9' || ch >= L'A' && ch <= L'F' || ch >= L'a' && ch <= L'f') {AddCh(); goto case_27;} + if ((ch >= L'0' && ch <= L'9') || (ch >= L'A' && ch <= L'F') || (ch >= L'a' && ch <= L'f')) {AddCh(); goto case_27;} else {t->kind = noSym; break;} case 27: case_27: - if (ch >= L'0' && ch <= L'9' || ch >= L'A' && ch <= L'F' || ch >= L'a' && ch <= L'f') {AddCh(); goto case_28;} + if ((ch >= L'0' && ch <= L'9') || (ch >= L'A' && ch <= L'F') || (ch >= L'a' && ch <= L'f')) {AddCh(); goto case_28;} else {t->kind = noSym; break;} case 28: case_28: - if (ch >= L'0' && ch <= L'9' || ch >= L'A' && ch <= L'F' || ch >= L'a' && ch <= L'f') {AddCh(); goto case_29;} + if ((ch >= L'0' && ch <= L'9') || (ch >= L'A' && ch <= L'F') || (ch >= L'a' && ch <= L'f')) {AddCh(); goto case_29;} else {t->kind = noSym; break;} case 29: case_29: - if (ch >= L'0' && ch <= L'9' || ch >= L'A' && ch <= L'F' || ch >= L'a' && ch <= L'f') {AddCh(); goto case_30;} + if ((ch >= L'0' && ch <= L'9') || (ch >= L'A' && ch <= L'F') || (ch >= L'a' && ch <= L'f')) {AddCh(); goto case_30;} else {t->kind = noSym; break;} case 30: case_30: - if (ch >= L'0' && ch <= L'9' || ch >= L'A' && ch <= L'F' || ch >= L'a' && ch <= L'f') {AddCh(); goto case_16;} + if ((ch >= L'0' && ch <= L'9') || (ch >= L'A' && ch <= L'F') || (ch >= L'a' && ch <= L'f')) {AddCh(); goto case_16;} else {t->kind = noSym; break;} case 31: case_31: @@ -820,60 +820,60 @@ Token* Scanner::NextToken() { {t->kind = 6; break;} case 35: case_35: - if (ch >= L'0' && ch <= L'9') {AddCh(); goto case_35;} + if ((ch >= L'0' && ch <= L'9')) {AddCh(); goto case_35;} else if (ch == L'.') {AddCh(); goto case_9;} else if (ch == L'E' || ch == L'e') {AddCh(); goto case_13;} else {t->kind = 2; break;} case 36: case_36: - if (ch >= L'0' && ch <= L'9') {AddCh(); goto case_35;} + if ((ch >= L'0' && ch <= L'9')) {AddCh(); goto case_35;} else if (ch == L'X' || ch == L'x') {AddCh(); goto case_2;} else if (ch == L'.') {AddCh(); goto case_9;} else if (ch == L'E' || ch == L'e') {AddCh(); goto case_13;} else {t->kind = 2; break;} case 37: - if (ch >= L'1' && ch <= L'9') {AddCh(); goto case_35;} + if ((ch >= L'1' && ch <= L'9')) {AddCh(); goto case_35;} else if (ch == L'0') {AddCh(); goto case_36;} else if (ch == L'.') {AddCh(); goto case_4;} else {t->kind = noSym; break;} case 38: - if (ch == L'!' || ch >= L'$' && ch <= L'&' || ch >= L'(' && ch <= L'+' || ch == L'-' || ch >= L'/' && ch <= L'1' || ch >= L'4' && ch <= L'Z' || ch >= L'^' && ch <= L'z' || ch == L'|' || ch == L'~' || ch >= 128 && ch <= 65535) {AddCh(); goto case_1;} + if (ch == L'!' || (ch >= L'$' && ch <= L'&') || (ch >= L'(' && ch <= L'+') || ch == L'-' || (ch >= L'/' && ch <= L'1') || (ch >= L'4' && ch <= L'Z') || (ch >= L'^' && ch <= L'z') || ch == L'|' || ch == L'~' || (ch >= 128 && ch <= 65535)) {AddCh(); goto case_1;} else if (ch == L'3') {AddCh(); goto case_42;} else if (ch == L'2') {AddCh(); goto case_43;} else {t->kind = 1; wchar_t *literal = coco_string_create(tval, 0, tlen); t->kind = keywords.get(literal, t->kind); coco_string_delete(literal); break;} case 39: case_39: - if (ch == L'"' || ch == 39 || ch == L'0' || ch == 92 || ch >= L'a' && ch <= L'b' || ch == L'f' || ch == L'n' || ch == L'r' || ch == L't' || ch == L'v') {AddCh(); goto case_16;} + if (ch == L'"' || ch == 39 || ch == L'0' || ch == 92 || (ch >= L'a' && ch <= L'b') || ch == L'f' || ch == L'n' || ch == L'r' || ch == L't' || ch == L'v') {AddCh(); goto case_16;} else if (ch == L'x') {AddCh(); goto case_17;} else if (ch == L'u') {AddCh(); goto case_19;} else if (ch == L'U') {AddCh(); goto case_23;} else {t->kind = noSym; break;} case 40: case_40: - if (ch >= L'0' && ch <= L'9' || ch >= L'A' && ch <= L'F' || ch >= L'a' && ch <= L'f') {AddCh(); goto case_41;} - else if (ch <= L'!' || ch >= L'#' && ch <= L'/' || ch >= L':' && ch <= L'@' || ch >= L'G' && ch <= L'[' || ch >= L']' && ch <= L'`' || ch >= L'g' && ch <= 65535) {AddCh(); goto case_16;} + if ((ch >= L'0' && ch <= L'9') || (ch >= L'A' && ch <= L'F') || (ch >= L'a' && ch <= L'f')) {AddCh(); goto case_41;} + else if (ch <= L'!' || (ch >= L'#' && ch <= L'/') || (ch >= L':' && ch <= L'@') || (ch >= L'G' && ch <= L'[') || (ch >= L']' && ch <= L'`') || (ch >= L'g' && ch <= 65535)) {AddCh(); goto case_16;} else if (ch == L'"') {AddCh(); goto case_31;} else if (ch == 92) {AddCh(); goto case_39;} else {t->kind = noSym; break;} case 41: case_41: - if (ch <= L'!' || ch >= L'#' && ch <= L'[' || ch >= L']' && ch <= 65535) {AddCh(); goto case_16;} + if (ch <= L'!' || (ch >= L'#' && ch <= L'[') || (ch >= L']' && ch <= 65535)) {AddCh(); goto case_16;} else if (ch == L'"') {AddCh(); goto case_31;} else if (ch == 92) {AddCh(); goto case_39;} else {t->kind = noSym; break;} case 42: case_42: - if (ch == L'!' || ch >= L'$' && ch <= L'&' || ch >= L'(' && ch <= L'+' || ch == L'-' || ch >= L'/' && ch <= L'Z' || ch >= L'^' && ch <= L'z' || ch == L'|' || ch == L'~' || ch >= 128 && ch <= 65535) {AddCh(); goto case_1;} + if (ch == L'!' || (ch >= L'$' && ch <= L'&') || (ch >= L'(' && ch <= L'+') || ch == L'-' || (ch >= L'/' && ch <= L'Z') || (ch >= L'^' && ch <= L'z') || ch == L'|' || ch == L'~' || (ch >= 128 && ch <= 65535)) {AddCh(); goto case_1;} else if (ch == L'.') {AddCh(); goto case_44;} else {t->kind = 1; wchar_t *literal = coco_string_create(tval, 0, tlen); t->kind = keywords.get(literal, t->kind); coco_string_delete(literal); break;} case 43: case_43: - if (ch == L'!' || ch >= L'$' && ch <= L'&' || ch >= L'(' && ch <= L'+' || ch == L'-' || ch >= L'/' && ch <= L'Z' || ch >= L'^' && ch <= L'z' || ch == L'|' || ch == L'~' || ch >= 128 && ch <= 65535) {AddCh(); goto case_1;} + if (ch == L'!' || (ch >= L'$' && ch <= L'&') || (ch >= L'(' && ch <= L'+') || ch == L'-' || (ch >= L'/' && ch <= L'Z') || (ch >= L'^' && ch <= L'z') || ch == L'|' || ch == L'~' || (ch >= 128 && ch <= 65535)) {AddCh(); goto case_1;} else if (ch == L'.') {AddCh(); goto case_33;} else {t->kind = 1; wchar_t *literal = coco_string_create(tval, 0, tlen); t->kind = keywords.get(literal, t->kind); coco_string_delete(literal); break;} case 44: case_44: - if (ch >= L'0' && ch <= L'2') {AddCh(); goto case_32;} + if ((ch >= L'0' && ch <= L'2')) {AddCh(); goto case_32;} else {t->kind = noSym; break;} case 45: {t->kind = 7; break;} @@ -888,7 +888,7 @@ Token* Scanner::NextToken() { case 50: {t->kind = 37; break;} case 51: - if (ch >= L'0' && ch <= L'9') {AddCh(); goto case_5;} + if ((ch >= L'0' && ch <= L'9')) {AddCh(); goto case_5;} else {t->kind = 17; break;} } @@ -925,6 +925,6 @@ void Scanner::ResetPeek() { pt = tokens; } -}; // namespace +} // namespace diff --git a/src/meshlabplugins/io_x3d/vrml/Scanner.h b/src/meshlabplugins/io_x3d/vrml/Scanner.h index 98c1624e1..387728e9c 100644 --- a/src/meshlabplugins/io_x3d/vrml/Scanner.h +++ b/src/meshlabplugins/io_x3d/vrml/Scanner.h @@ -299,7 +299,7 @@ public: }; // end Scanner -}; // namespace +} // namespace #endif // !defined(VRML_SCANNER_H__) diff --git a/src/meshlabplugins/io_x3d/vrml/VrmlTranslator.atg b/src/meshlabplugins/io_x3d/vrml/VrmlTranslator.atg index 729744a9d..1ff4be70e 100644 --- a/src/meshlabplugins/io_x3d/vrml/VrmlTranslator.atg +++ b/src/meshlabplugins/io_x3d/vrml/VrmlTranslator.atg @@ -41,7 +41,7 @@ COMPILER VrmlTranslator x3dNode.insert("Layer"); x3dNode.insert("LayerSet"); x3dNode.insert("Layout"); x3dNode.insert("LayoutGroup"); x3dNode.insert("LayoutLayer"); x3dNode.insert("LinePicker"); x3dNode.insert("LineProperties"); x3dNode.insert("LineSet"); x3dNode.insert("LoadSensor"); - x3dNode.insert("LocalFog"); x3dNode.insert("Matrix3VertexAttribute"); + x3dNode.insert("LocalFog"); x3dNode.insert("Material"); x3dNode.insert("Matrix3VertexAttribute"); x3dNode.insert("Matrix4VertexAttribute"); x3dNode.insert("MetadataDouble"); x3dNode.insert("MetadataFloat"); x3dNode.insert("MetadataInteger"); x3dNode.insert("MetadataSet"); x3dNode.insert("MetadataString"); x3dNode.insert("MotorJoint"); x3dNode.insert("MultiTexture");