/usr/include/x86_64-linux-gnu/visp3/core/vpXmlParserHomogeneousMatrix.h is in libvisp-core-dev 3.0.0-4.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 | /****************************************************************************
*
* This file is part of the ViSP software.
* Copyright (C) 2005 - 2015 by Inria. All rights reserved.
*
* This software is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* ("GPL") version 2 as published by the Free Software Foundation.
* See the file LICENSE.txt at the root directory of this source
* distribution for additional information about the GNU GPL.
*
* For using ViSP with software that can not be combined with the GNU
* GPL, please contact Inria about acquiring a ViSP Professional
* Edition License.
*
* See http://visp.inria.fr for more information.
*
* This software was developed at:
* Inria Rennes - Bretagne Atlantique
* Campus Universitaire de Beaulieu
* 35042 Rennes Cedex
* France
*
* If you have questions regarding the use of this file, please contact
* Inria at visp@inria.fr
*
* This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
* WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*
* Description:
* XML parser to load and save Homogeneous Matrix in a XML file
*
* Authors:
* Giovanni Claudio
*
*****************************************************************************/
/*!
\file vpXmlParserHomogeneousMatrix.h
\brief Declaration of the vpXmlParserHomogeneousMatrix class.
Class vpXmlParserHomogeneousMatrix allowed to load and save Homogeneous Matrixes in a file XML
*/
#ifndef vpXMLPARSERHOMOGENEOUSMATRIX_H
#define vpXMLPARSERHOMOGENEOUSMATRIX_H
#include <visp3/core/vpConfig.h>
#ifdef VISP_HAVE_XML2
#include <string>
#include <visp3/core/vpXmlParser.h>
#include <visp3/core/vpHomogeneousMatrix.h>
#include <libxml/xmlmemory.h> /* Functions of libxml. */
/*!
\class vpXmlParserHomogeneousMatrix
\ingroup group_core_transformations
\brief XML parser to load and save an homogeneous matrix in a file.
To have a complete description of the homogeneous matrix implemented in ViSP, see
vpHomogeneousMatrix.
Example of an XML file "homogeneous_matrixes.xml" containing a Pose vector
that will be converted in an homogeneous matrix:
\code
<?xml version="1.0"?>
<root>
<homogeneous_transformation>
<!--Name of the homogeneous matrix-->
<name>eMc</name>
<values>
<!--Translation vector with values in meters -->
<tx>1.00</tx>
<ty>1.30</ty>
<tz>3.50</tz>
<!--Rotational vector expressed in angle axis representation with values in radians -->
<theta_ux>0.20</theta_ux>
<theta_uy>0.30</theta_uy>
<theta_uz>0.50</theta_uz>
</values>
</homogeneous_transformation>
</root>
\endcode
Example of loading an existing homogeneous matrix from an XML file.
\code
#include <iostream>
#include <string>
#include <visp3/core/vpXmlParserHomogeneousMatrix.h>
int main(int argc, char* argv[])
{
#ifdef VISP_HAVE_XML2
vpHomogeneousMatrix eMc;
// Create a XML parser
vpXmlParserHomogeneousMatrix p;
// Define the name of the matrix to load
std::string name = "eMc";
if (p.parse(eMc,"homogeneous_matrixes.xml", name) != vpXmlParserHomogeneousMatrix::SEQUENCE_OK) {
std::cout << "Cannot found the Homogeneous matrix named " << name << "." << std::endl;
}
else
std::cout << "Homogeneous matrix " << name <<": " << std::endl << eMc << std::endl;
#endif
return 0;
}
\endcode
Example of writing an homogenoeus matrix in a XML file.
\note Before writing an homogeneous matrix check if there
is already in the xml file a matrix with the same name.
If you are sure to overwrite it please delete it manually
from the file before.
\code
#include <iostream>
#include <string>
#include <visp3/core/vpXmlParserHomogeneousMatrix.h>
int main(int argc, char* argv[])
{
#ifdef VISP_HAVE_XML2
// Create Pose Vector and convert to homogeneous matrix
vpPoseVector r(1.0,1.3,3.5,0.2,0.3,0.5);
vpHomogeneousMatrix M(r);
// Create a XML parser
vpXmlParserHomogeneousMatrix p;
// Define the name of the matrix
std::string name_M = "eMe";
// Define name of the file xml to fill
char filename[FILENAME_MAX];
sprintf(filename, "%s", "homogeneous_matrixes.xml");
if (p.save(M, filename, name_M) != vpXmlParserHomogeneousMatrix::SEQUENCE_OK) {
std::cout << "Cannot save the Homogeneous matrix" << std::endl;
}
vpXmlParser::cleanup();
#endif
return 0;
}
\endcode
*/
class VISP_EXPORT vpXmlParserHomogeneousMatrix: public vpXmlParser
{
public:
/* --- XML Code------------------------------------------------------------ */
typedef enum
{
CODE_XML_BAD = -1,
CODE_XML_OTHER,
CODE_XML_M,
CODE_XML_M_NAME,
CODE_XML_VALUE,
CODE_XML_TX,
CODE_XML_TY,
CODE_XML_TZ,
CODE_XML_TUX,
CODE_XML_TUY,
CODE_XML_TUZ
} vpXmlCodeType;
typedef enum
{
SEQUENCE_OK,
SEQUENCE_ERROR
} vpXmlCodeSequenceType;
private :
vpHomogeneousMatrix m_M;
std::string m_name;
public:
vpXmlParserHomogeneousMatrix();
vpXmlParserHomogeneousMatrix(vpXmlParserHomogeneousMatrix& twinParser);
~vpXmlParserHomogeneousMatrix(){}
// get/set functions
vpHomogeneousMatrix getHomogeneousMatrix() const {return this->m_M;}
std::string getHomogeneousMatrixName() const {return this->m_name;}
vpXmlParserHomogeneousMatrix& operator =(const vpXmlParserHomogeneousMatrix& twinparser);
int parse(vpHomogeneousMatrix &M, const std::string &filename, const std::string &name);
int save(const vpHomogeneousMatrix &M, const std::string &filename, const std::string &name);
void setHomogeneousMatrixName(const std::string& name){
this->m_name = name;
}
private:
int read (xmlDocPtr doc, xmlNodePtr node,
const std::string& name);
int count (xmlDocPtr doc, xmlNodePtr node,
const std::string& name);
int read_matrix (xmlDocPtr doc, xmlNodePtr node,
const std::string& name);
vpXmlCodeSequenceType read_values (xmlDocPtr doc, xmlNodePtr node,
vpHomogeneousMatrix &M);
static vpXmlCodeSequenceType str2xmlcode (char * str, vpXmlCodeType & res);
void myXmlReadIntChild (xmlDocPtr doc,
xmlNodePtr node,
int &res,
vpXmlCodeSequenceType &code_error);
void myXmlReadDoubleChild (xmlDocPtr doc,
xmlNodePtr node,
double &res,
vpXmlCodeSequenceType &code_error);
void myXmlReadCharChild (xmlDocPtr doc,
xmlNodePtr node,
char **res);
int write (xmlNodePtr node, const std::string& name);
private:
/*!
\param 2doc : a pointer representing the document
\param node : the root node of the document
*/
virtual void readMainClass(xmlDocPtr , xmlNodePtr ){};
/*!
\param node2 : the root node of the document
*/
virtual void writeMainClass(xmlNodePtr ){};
};
#endif //VISP_HAVE_XML2
#endif
|