From f254b3fe38adabab46676f680d2b9f9df6df9883 Mon Sep 17 00:00:00 2001 From: Martin Kroeker Date: Thu, 11 Oct 2018 21:54:22 +0200 Subject: [PATCH 1/2] Add support for the node Sphere --- src/meshlabplugins/io_x3d/vrml/Parser.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/meshlabplugins/io_x3d/vrml/Parser.h b/src/meshlabplugins/io_x3d/vrml/Parser.h index 68d3e8e6a..e50cc2093 100644 --- a/src/meshlabplugins/io_x3d/vrml/Parser.h +++ b/src/meshlabplugins/io_x3d/vrml/Parser.h @@ -160,7 +160,7 @@ QDomDocument *doc; x3dNode.insert("TriangleFanSet"); x3dNode.insert("TriangleSet"); x3dNode.insert("TriangleSet2D"); x3dNode.insert("TriangleStripSet"); x3dNode.insert("TwoSidedMaterial"); x3dNode.insert("UniversalJoint"); x3dNode.insert(" Viewpoint"); x3dNode.insert("ViewpointGroup"); x3dNode.insert("VolumeEmitter"); - x3dNode.insert("VolumePicker"); x3dNode.insert("WindPhysicsModel"); x3dNode.insert("Cylinder"); + x3dNode.insert("VolumePicker"); x3dNode.insert("WindPhysicsModel"); x3dNode.insert("Cylinder"); x3dNode.insert("Sphere"); } From 90d2a1defdeda56382fd7c08b13318bef5ea7e1f Mon Sep 17 00:00:00 2001 From: Martin Kroeker Date: Thu, 11 Oct 2018 22:03:06 +0200 Subject: [PATCH 2/2] Add support for the node "Sphere" --- src/meshlabplugins/io_x3d/import_x3d.h | 32 ++++++++++++++++++++++++-- 1 file changed, 30 insertions(+), 2 deletions(-) diff --git a/src/meshlabplugins/io_x3d/import_x3d.h b/src/meshlabplugins/io_x3d/import_x3d.h index c445471b0..7b8b0d684 100644 --- a/src/meshlabplugins/io_x3d/import_x3d.h +++ b/src/meshlabplugins/io_x3d/import_x3d.h @@ -783,7 +783,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")!= "") || coordinate.attribute("USE", "") != "")) || (tagName == "ElevationGrid") || (tagName == "Cylinder")) + if ((!coordinate.isNull() && ((coordinate.attribute("point")!= "") || coordinate.attribute("USE", "") != "")) || (tagName == "ElevationGrid") || (tagName == "Cylinder") || (tagName == "Sphere")) { bool copyTextureFile = true; QStringList colorList, normalList, textureList; @@ -1891,6 +1891,32 @@ namespace io { return E_NOERROR; } + static int LoadSphere(QDomElement geometry, + OpenMeshType& m, + const vcg::Matrix44& tMatrix, + AdditionalInfoX3D* info, + CallBackPos *cb) + { + vcg::Matrix44 t, tmp; + t.SetIdentity(); + + QStringList radiusList; + findAndParseAttribute(radiusList, geometry, "radius", "1"); + float radius = radiusList[0].toFloat(); + tmp.SetScale(radius,radius,radius); + t *= tmp; + tmp = tMatrix * t; + OpenMeshType newSphere; + vcg::tri::Sphere(newSphere, 3); + if (info->meshColor) + vcg::tri::UpdateColor::PerVertexConstant(newSphere, info->color, false); +// vcg::tri::UpdatePosition::Matrix(newSphere, tMatrix, false); + vcg::tri::UpdatePosition::Matrix(newSphere, tmp, false); + vcg::tri::Append::Mesh(m, newSphere); + info->numvert++; + if (cb !=NULL) (*cb)(10 + 80*info->numvert/info->numface, "Loading X3D Object..."); + return E_NOERROR; + } //Load texture info from Appearance node. @@ -2486,7 +2512,7 @@ namespace io { QDomElement coordinate = findNode(coordTag, 2, geometry); result = solveDefUse(coordinate, defMap, coordinate, info); if (result != E_NOERROR) return result; - if ((!coordinate.isNull() && (coordinate.attribute("point") != "")) || (geometry.tagName() == "ElevationGrid") || (geometry.tagName() == "Cylinder")) + if ((!coordinate.isNull() && (coordinate.attribute("point") != "")) || (geometry.tagName() == "ElevationGrid") || (geometry.tagName() == "Cylinder") || (geometry.tagName() == "Sphere")) { //Get coordinate QStringList coordList; @@ -2602,6 +2628,8 @@ namespace io { return LoadPointSet(geometry, m, tMatrix, coordList, colorList, colorComponent, info, cb); else if (geometry.tagName() == "Cylinder") return LoadCylinder(geometry, m, tMatrix, info, cb); + else if (geometry.tagName() == "Sphere") + return LoadSphere(geometry, m, tMatrix, info, cb); } else if (geometry.tagName() == "Polypoint2D") return LoadPolypoint2D(geometry, m, tMatrix, info, cb);