MeshLink
Computational geometry access
MeshLinkParser_xerces.h
Go to the documentation of this file.
1 /****************************************************************************
2  *
3  * Copyright (c) 2019-2020 Pointwise, Inc.
4  * All rights reserved.
5  *
6  * This sample Pointwise source code is not supported by Pointwise, Inc.
7  * It is provided freely for demonstration purposes only.
8  * SEE THE WARRANTY DISCLAIMER AT THE BOTTOM OF THIS FILE.
9  *
10  ***************************************************************************/
11 
12 #ifndef MESH_LINK_PARSER_XERCES
13 #define MESH_LINK_PARSER_XERCES
14 
15 #include "Types.h"
16 #include "MeshLinkParser.h"
17 
18 #include <map>
19 #include <string>
20 #include <vector>
21 
22 
23 namespace xercesc_3_2 {
24  class DOMNode;
25  class DOMElement;
26 }
27 
28 class MeshLinkWriterXerces;
29 class MeshAssociativity;
30 class MeshModel;
31 class MeshTopo;
32 class ParamVertex;
33 
34 class XMLMeshEdge;
35 class XMLMeshFace;
36 class MeshLinkParser;
37 
38 
39 /****************************************************************************
40  * MeshLinkParserXerces class
41  ***************************************************************************/
51 
52 // Function pointer typedef for MeshTopo parser, e.g. parseMeshEdge
54  MeshTopo* meshTopo,
55  xercesc_3_2::DOMElement *domElement);
56 
57 // Map MeshTopo element name to parser function
58 typedef std::map<const char *, pParseMeshObj> ParseMeshObjMap;
59 
61 public:
64  meshAssociativity_(NULL),
66  {}
69 
76  bool validate(const std::string &fileName, const std::string &schemaName) override;
77 
86  bool parseMeshLinkFile(std::string fname, MeshAssociativity *meshAssociativity) override;
87 
94  bool getMeshLinkAttributes(std::string &xmlns, std::string &xmlns_xsi,
95  std::string &schemaLocation) override
96  {
97  if (xmlns_.empty()) {
98  return false;
99  }
100  xmlns = xmlns_;
101  xmlns_xsi = xmlns_xsi_;
102  schemaLocation = schemaLocation_;
103  return true;
104  }
105 
109  MeshLinkWriterXerces *getXMLWriter();
110 
114  void setVerboseLevel(int level) {
115  verbose_level_ = level;
116  }
117 private:
119  bool parseAttributes(xercesc_3_2::DOMElement *root);
120 
122  bool parsePeriodicInfo(xercesc_3_2::DOMElement *root);
123 
125  bool parseGeometryRefs(xercesc_3_2::DOMElement *root);
126 
128  bool parseMeshFile(xercesc_3_2::DOMElement *element);
130  bool parseMeshRefModel(MeshFile &meshFile, xercesc_3_2::DOMElement *modelRef);
132  bool parseMeshSheet(MeshModel *model, xercesc_3_2::DOMElement *meshSheetNode);
134  bool parseMeshSheetReference(MeshModel *model, xercesc_3_2::DOMElement *meshSheetNode);
136  bool parseMeshString(MeshModel *model, xercesc_3_2::DOMElement *meshStringNode);
138  bool parseMeshStringReference(MeshModel *model, xercesc_3_2::DOMElement *meshStringNode);
140  bool parseParamVertex(MeshTopo *meshTopo, xercesc_3_2::DOMElement *element);
142  bool parseMeshPoint(MeshModel *model, xercesc_3_2::DOMElement *meshPoint);
145  xercesc_3_2::DOMElement *meshPoint);
148  bool parseMeshPointReference(MeshModel *model, MeshTopo* parentMeshTopo,
149  xercesc_3_2::DOMElement *meshPoint);
150 
153  bool parseMeshEdge(MeshModel *model,
154  MeshTopo * meshTopo, xercesc_3_2::DOMElement *element);
157  bool parseMeshEdgeReference(MeshModel *model,
158  MeshTopo * meshTopo, xercesc_3_2::DOMElement *element);
161  bool parseMeshFace(MeshModel *model,
162  MeshTopo * meshTopo, xercesc_3_2::DOMElement *element);
165  bool parseMeshFaceReference(MeshModel *model,
166  MeshTopo * meshTopo, xercesc_3_2::DOMElement *element);
167 
171  bool parseMeshObject(MeshModel *model,
172  MeshTopo* meshTopo,
173  xercesc_3_2::DOMElement *xmlObj,
174  const char *objName,
175  ParseMeshObjMap &parseMeshObjMap, bool &mapID);
176 
179 
181 
182  // Parsed Xml 'header' attributes cached for use when writing out
183  // Xml file based on parsed/modified Meshassociativity. Supports
184  // 'round tripping' of MeshLink files
185 
187  std::string xmlVersion_;
189  std::string xmlns_;
191  std::string xmlns_xsi_;
193  std::string schemaLocation_;
194 };
195 
196 #endif
197 
198 /****************************************************************************
199  *
200  * DISCLAIMER:
201  * TO THE MAXIMUM EXTENT PERMITTED BY APPLICABLE LAW, POINTWISE DISCLAIMS
202  * ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING, BUT NOT LIMITED
203  * TO, IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
204  * PURPOSE, WITH REGARD TO THIS SCRIPT. TO THE MAXIMUM EXTENT PERMITTED
205  * BY APPLICABLE LAW, IN NO EVENT SHALL POINTWISE BE LIABLE TO ANY PARTY
206  * FOR ANY SPECIAL, INCIDENTAL, INDIRECT, OR CONSEQUENTIAL DAMAGES
207  * WHATSOEVER (INCLUDING, WITHOUT LIMITATION, DAMAGES FOR LOSS OF
208  * BUSINESS INFORMATION, OR ANY OTHER PECUNIARY LOSS) ARISING OUT OF THE
209  * USE OF OR INABILITY TO USE THIS SCRIPT EVEN IF POINTWISE HAS BEEN
210  * ADVISED OF THE POSSIBILITY OF SUCH DAMAGES AND REGARDLESS OF THE
211  * FAULT OR NEGLIGENCE OF POINTWISE.
212  *
213  ***************************************************************************/
Storage for mesh topology and geometry associativity data.
3D (volume) mesh topology
Definition: MeshModel.h:38
Storage for MeshLink schema MeshFile data.
Base class for mesh topology entities.
Definition: MeshTopo.h:132
Parametric geometry data.
Definition: MeshTopo.h:69