MCPcopy Create free account
hub / github.com/CloudCompare/CloudCompare / readVector

Method readVector

qCC/ccCommandCrossSection.cpp:371–417  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

369}
370
371bool CommandCrossSection::readVector(const QXmlStreamAttributes &attributes, CCVector3 &P, QString element, const ccCommandLineInterface &cmd)
372{
373 if (attributes.size() < 3)
374 {
375 return cmd.error(QString("Invalid XML file (3 attributes expected for element '<%1>')").arg(element));
376 }
377
378 int count = 0;
379 for (int i = 0; i < attributes.size(); ++i)
380 {
381 QString name = attributes[i].name().toString().toUpper();
382 QString value = attributes[i].value().toString();
383
384 bool ok = false;
385 if (name == "X")
386 {
387 P.x = value.toDouble(&ok);
388 ++count;
389 }
390 else if (name == "Y")
391 {
392 P.y = value.toDouble(&ok);
393 ++count;
394 }
395 else if (name == "Z")
396 {
397 P.z = value.toDouble(&ok);
398 ++count;
399 }
400 else
401 {
402 ok = true;
403 }
404
405 if (!ok)
406 {
407 return cmd.error(QString("Invalid XML file (numerical attribute expected for attribute '%1' of element '<%2>')").arg(name, element));
408 }
409 }
410
411 if (count < 3)
412 {
413 return cmd.error(QString("Invalid XML file (attributes 'X','Y' and 'Z' are mandatory for element '<%1>')").arg(element));
414 }
415
416 return true;
417}

Callers

nothing calls this directly

Calls 6

errorMethod · 0.80
QStringClass · 0.70
sizeMethod · 0.45
toStringMethod · 0.45
nameMethod · 0.45
valueMethod · 0.45

Tested by

no test coverage detected