| 17 | {} |
| 18 | |
| 19 | bool CommandCrossSection::process(ccCommandLineInterface &cmd) |
| 20 | { |
| 21 | cmd.print("[CROSS SECTION]"); |
| 22 | |
| 23 | static QString s_xmlCloudCompare = "CloudCompare"; |
| 24 | static QString s_xmlBoxThickness = "BoxThickness"; |
| 25 | static QString s_xmlBoxCenter = "BoxCenter"; |
| 26 | static QString s_xmlRepeatDim = "RepeatDim"; |
| 27 | static QString s_xmlRepeatGap = "RepeatGap"; |
| 28 | static QString s_xmlFilePath = "FilePath"; |
| 29 | static QString s_outputXmlFilePath = "OutputFilePath"; |
| 30 | |
| 31 | //expected argument: XML file |
| 32 | if (cmd.arguments().empty()) |
| 33 | return cmd.error(QString("Missing parameter: XML parameters file after \"-%1\"").arg(COMMAND_CROSS_SECTION)); |
| 34 | QString xmlFilename = cmd.arguments().takeFirst(); |
| 35 | |
| 36 | //read the XML file |
| 37 | CCVector3 boxCenter(0, 0, 0); |
| 38 | CCVector3 boxThickness(0, 0, 0); |
| 39 | bool repeatDim[3] = { false, false, false }; |
| 40 | double repeatGap = 0.0; |
| 41 | bool inside = true; |
| 42 | bool autoCenter = true; |
| 43 | QString inputFilePath; |
| 44 | QString outputFilePath; |
| 45 | { |
| 46 | QFile file(xmlFilename); |
| 47 | if (!file.open(QFile::ReadOnly | QFile::Text)) |
| 48 | { |
| 49 | return cmd.error(QString("Couldn't open XML file '%1'").arg(xmlFilename)); |
| 50 | } |
| 51 | |
| 52 | //read file content |
| 53 | QXmlStreamReader stream(&file); |
| 54 | |
| 55 | //expected: CloudCompare |
| 56 | if (!stream.readNextStartElement() |
| 57 | || stream.name() != s_xmlCloudCompare) |
| 58 | { |
| 59 | return cmd.error(QString("Invalid XML file (should start by '<%1>')").arg(s_xmlCloudCompare)); |
| 60 | } |
| 61 | |
| 62 | unsigned mandatoryCount = 0; |
| 63 | while (stream.readNextStartElement()) //loop over the elements |
| 64 | { |
| 65 | if (stream.name() == s_xmlBoxThickness) |
| 66 | { |
| 67 | QXmlStreamAttributes attributes = stream.attributes(); |
| 68 | if (!readVector(attributes, boxThickness, s_xmlBoxThickness, cmd)) |
| 69 | return false; |
| 70 | stream.skipCurrentElement(); |
| 71 | ++mandatoryCount; |
| 72 | } |
| 73 | else if (stream.name() == s_xmlBoxCenter) |
| 74 | { |
| 75 | QXmlStreamAttributes attributes = stream.attributes(); |
| 76 | if (!readVector(attributes, boxCenter, s_xmlBoxCenter, cmd)) |
nothing calls this directly
no test coverage detected