X3DImporter_Geometry2D.cpp 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467
  1. /*
  2. Open Asset Import Library (assimp)
  3. ----------------------------------------------------------------------
  4. Copyright (c) 2006-2019, assimp team
  5. All rights reserved.
  6. Redistribution and use of this software in source and binary forms,
  7. with or without modification, are permitted provided that the
  8. following conditions are met:
  9. * Redistributions of source code must retain the above
  10. copyright notice, this list of conditions and the
  11. following disclaimer.
  12. * Redistributions in binary form must reproduce the above
  13. copyright notice, this list of conditions and the
  14. following disclaimer in the documentation and/or other
  15. materials provided with the distribution.
  16. * Neither the name of the assimp team, nor the names of its
  17. contributors may be used to endorse or promote products
  18. derived from this software without specific prior
  19. written permission of the assimp team.
  20. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  21. "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  22. LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
  23. A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
  24. OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  25. SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  26. LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  27. DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  28. THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  29. (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  30. OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  31. ----------------------------------------------------------------------
  32. */
  33. /// \file X3DImporter_Geometry2D.cpp
  34. /// \brief Parsing data from nodes of "Geometry2D" set of X3D.
  35. /// date 2015-2016
  36. /// author [email protected]
  37. #ifndef ASSIMP_BUILD_NO_X3D_IMPORTER
  38. #include "X3DImporter.hpp"
  39. #include "X3DImporter_Macro.hpp"
  40. #include "X3DXmlHelper.h"
  41. #include "X3DGeoHelper.h"
  42. namespace Assimp {
  43. // <Arc2D
  44. // DEF="" ID
  45. // USE="" IDREF
  46. // endAngle="1.570796" SFFloat [initializeOnly]
  47. // radius="1" SFFloat [initializeOnly]
  48. // startAngle="0" SFFloat [initializeOnly]
  49. // />
  50. // The Arc2D node specifies a linear circular arc whose center is at (0,0) and whose angles are measured starting at the positive x-axis and sweeping
  51. // towards the positive y-axis. The radius field specifies the radius of the circle of which the arc is a portion. The arc extends from the startAngle
  52. // counterclockwise to the endAngle. The values of startAngle and endAngle shall be in the range [-2pi, 2pi] radians (or the equivalent if a different
  53. // angle base unit has been specified). If startAngle and endAngle have the same value, a circle is specified.
  54. void X3DImporter::readArc2D(XmlNode &node) {
  55. std::string def, use;
  56. float endAngle = AI_MATH_HALF_PI_F;
  57. float radius = 1;
  58. float startAngle = 0;
  59. X3DNodeElementBase *ne(nullptr);
  60. MACRO_ATTRREAD_CHECKUSEDEF_RET(node, def, use);
  61. XmlParser::getFloatAttribute(node, "endAngle", endAngle);
  62. XmlParser::getFloatAttribute(node, "radius", radius);
  63. XmlParser::getFloatAttribute(node, "startAngle", startAngle);
  64. // if "USE" defined then find already defined element.
  65. if (!use.empty()) {
  66. ne = MACRO_USE_CHECKANDAPPLY(node, def, use, ENET_Arc2D, ne);
  67. } else {
  68. // create and if needed - define new geometry object.
  69. ne = new X3DNodeElementGeometry2D(X3DElemType::ENET_Arc2D, mNodeElementCur);
  70. if (!def.empty()) ne->ID = def;
  71. // create point list of geometry object and convert it to line set.
  72. std::list<aiVector3D> tlist;
  73. X3DGeoHelper::make_arc2D(startAngle, endAngle, radius, 10, tlist); ///TODO: IME - AI_CONFIG for NumSeg
  74. X3DGeoHelper::extend_point_to_line(tlist, ((X3DNodeElementGeometry2D *)ne)->Vertices);
  75. ((X3DNodeElementGeometry2D *)ne)->NumIndices = 2;
  76. // check for X3DMetadataObject childs.
  77. if (!isNodeEmpty(node))
  78. childrenReadMetadata(node, ne, "Arc2D");
  79. else
  80. mNodeElementCur->Children.push_back(ne); // add made object as child to current element
  81. NodeElement_List.push_back(ne); // add element to node element list because its a new object in graph
  82. } // if(!use.empty()) else
  83. }
  84. // <ArcClose2D
  85. // DEF="" ID
  86. // USE="" IDREF
  87. // closureType="PIE" SFString [initializeOnly], {"PIE", "CHORD"}
  88. // endAngle="1.570796" SFFloat [initializeOnly]
  89. // radius="1" SFFloat [initializeOnly]
  90. // solid="false" SFBool [initializeOnly]
  91. // startAngle="0" SFFloat [initializeOnly]
  92. // />
  93. // The ArcClose node specifies a portion of a circle whose center is at (0,0) and whose angles are measured starting at the positive x-axis and sweeping
  94. // towards the positive y-axis. The end points of the arc specified are connected as defined by the closureType field. The radius field specifies the radius
  95. // of the circle of which the arc is a portion. The arc extends from the startAngle counterclockwise to the endAngle. The value of radius shall be greater
  96. // than zero. The values of startAngle and endAngle shall be in the range [-2pi, 2pi] radians (or the equivalent if a different default angle base unit has
  97. // been specified). If startAngle and endAngle have the same value, a circle is specified and closureType is ignored. If the absolute difference between
  98. // startAngle and endAngle is greater than or equal to 2pi, a complete circle is produced with no chord or radial line(s) drawn from the center.
  99. // A closureType of "PIE" connects the end point to the start point by defining two straight line segments first from the end point to the center and then
  100. // the center to the start point. A closureType of "CHORD" connects the end point to the start point by defining a straight line segment from the end point
  101. // to the start point. Textures are applied individually to each face of the ArcClose2D. On the front (+Z) and back (-Z) faces of the ArcClose2D, when
  102. // viewed from the +Z-axis, the texture is mapped onto each face with the same orientation as if the image were displayed normally in 2D.
  103. void X3DImporter::readArcClose2D(XmlNode &node) {
  104. std::string def, use;
  105. std::string closureType("PIE");
  106. float endAngle = AI_MATH_HALF_PI_F;
  107. float radius = 1;
  108. bool solid = false;
  109. float startAngle = 0;
  110. X3DNodeElementBase *ne(nullptr);
  111. MACRO_ATTRREAD_CHECKUSEDEF_RET(node, def, use);
  112. XmlParser::getStdStrAttribute(node, "closureType", closureType);
  113. XmlParser::getFloatAttribute(node, "endAngle", endAngle);
  114. XmlParser::getFloatAttribute(node, "endAngle", endAngle);
  115. XmlParser::getFloatAttribute(node, "radius", radius);
  116. XmlParser::getBoolAttribute(node, "solid", solid);
  117. XmlParser::getFloatAttribute(node, "startAngle", startAngle);
  118. // if "USE" defined then find already defined element.
  119. if (!use.empty()) {
  120. ne = MACRO_USE_CHECKANDAPPLY(node, def, use, ENET_ArcClose2D, ne);
  121. } else {
  122. // create and if needed - define new geometry object.
  123. ne = new X3DNodeElementGeometry2D(X3DElemType::ENET_ArcClose2D, mNodeElementCur);
  124. if (!def.empty()) ne->ID = def;
  125. ((X3DNodeElementGeometry2D *)ne)->Solid = solid;
  126. // create point list of geometry object.
  127. X3DGeoHelper::make_arc2D(startAngle, endAngle, radius, 10, ((X3DNodeElementGeometry2D *)ne)->Vertices); ///TODO: IME - AI_CONFIG for NumSeg
  128. // add chord or two radiuses only if not a circle was defined
  129. if (!((std::fabs(endAngle - startAngle) >= AI_MATH_TWO_PI_F) || (endAngle == startAngle))) {
  130. std::list<aiVector3D> &vlist = ((X3DNodeElementGeometry2D *)ne)->Vertices; // just short alias.
  131. if ((closureType == "PIE") || (closureType == "\"PIE\""))
  132. vlist.push_back(aiVector3D(0, 0, 0)); // center point - first radial line
  133. else if ((closureType != "CHORD") && (closureType != "\"CHORD\""))
  134. Throw_IncorrectAttrValue("ArcClose2D", "closureType");
  135. vlist.push_back(*vlist.begin()); // arc first point - chord from first to last point of arc(if CHORD) or second radial line(if PIE).
  136. }
  137. ((X3DNodeElementGeometry2D *)ne)->NumIndices = ((X3DNodeElementGeometry2D *)ne)->Vertices.size();
  138. // check for X3DMetadataObject childs.
  139. if (!isNodeEmpty(node))
  140. childrenReadMetadata(node, ne, "ArcClose2D");
  141. else
  142. mNodeElementCur->Children.push_back(ne); // add made object as child to current element
  143. NodeElement_List.push_back(ne); // add element to node element list because its a new object in graph
  144. } // if(!use.empty()) else
  145. }
  146. // <Circle2D
  147. // DEF="" ID
  148. // USE="" IDREF
  149. // radius="1" SFFloat [initializeOnly]
  150. // />
  151. void X3DImporter::readCircle2D(XmlNode &node) {
  152. std::string def, use;
  153. float radius = 1;
  154. X3DNodeElementBase *ne(nullptr);
  155. MACRO_ATTRREAD_CHECKUSEDEF_RET(node, def, use);
  156. XmlParser::getFloatAttribute(node, "radius", radius);
  157. // if "USE" defined then find already defined element.
  158. if (!use.empty()) {
  159. ne = MACRO_USE_CHECKANDAPPLY(node, def, use, ENET_Circle2D, ne);
  160. } else {
  161. // create and if needed - define new geometry object.
  162. ne = new X3DNodeElementGeometry2D(X3DElemType::ENET_Circle2D, mNodeElementCur);
  163. if (!def.empty()) ne->ID = def;
  164. // create point list of geometry object and convert it to line set.
  165. std::list<aiVector3D> tlist;
  166. X3DGeoHelper::make_arc2D(0, 0, radius, 10, tlist); ///TODO: IME - AI_CONFIG for NumSeg
  167. X3DGeoHelper::extend_point_to_line(tlist, ((X3DNodeElementGeometry2D *)ne)->Vertices);
  168. ((X3DNodeElementGeometry2D *)ne)->NumIndices = 2;
  169. // check for X3DMetadataObject childs.
  170. if (!isNodeEmpty(node))
  171. childrenReadMetadata(node, ne, "Circle2D");
  172. else
  173. mNodeElementCur->Children.push_back(ne); // add made object as child to current element
  174. NodeElement_List.push_back(ne); // add element to node element list because its a new object in graph
  175. } // if(!use.empty()) else
  176. }
  177. // <Disk2D
  178. // DEF="" ID
  179. // USE="" IDREF
  180. // innerRadius="0" SFFloat [initializeOnly]
  181. // outerRadius="1" SFFloat [initializeOnly]
  182. // solid="false" SFBool [initializeOnly]
  183. // />
  184. // The Disk2D node specifies a circular disk which is centred at (0, 0) in the local coordinate system. The outerRadius field specifies the radius of the
  185. // outer dimension of the Disk2D. The innerRadius field specifies the inner dimension of the Disk2D. The value of outerRadius shall be greater than zero.
  186. // The value of innerRadius shall be greater than or equal to zero and less than or equal to outerRadius. If innerRadius is zero, the Disk2D is completely
  187. // filled. Otherwise, the area within the innerRadius forms a hole in the Disk2D. If innerRadius is equal to outerRadius, a solid circular line shall
  188. // be drawn using the current line properties. Textures are applied individually to each face of the Disk2D. On the front (+Z) and back (-Z) faces of
  189. // the Disk2D, when viewed from the +Z-axis, the texture is mapped onto each face with the same orientation as if the image were displayed normally in 2D.
  190. void X3DImporter::readDisk2D(XmlNode &node) {
  191. std::string def, use;
  192. float innerRadius = 0;
  193. float outerRadius = 1;
  194. bool solid = false;
  195. X3DNodeElementBase *ne(nullptr);
  196. MACRO_ATTRREAD_CHECKUSEDEF_RET(node, def, use);
  197. XmlParser::getFloatAttribute(node, "innerRadius", innerRadius);
  198. XmlParser::getFloatAttribute(node, "outerRadius", outerRadius);
  199. XmlParser::getBoolAttribute(node, "solid", solid);
  200. // if "USE" defined then find already defined element.
  201. if (!use.empty()) {
  202. ne = MACRO_USE_CHECKANDAPPLY(node, def, use, ENET_Disk2D, ne);
  203. } else {
  204. std::list<aiVector3D> tlist_o, tlist_i;
  205. if (innerRadius > outerRadius) Throw_IncorrectAttrValue("Disk2D", "innerRadius");
  206. // create and if needed - define new geometry object.
  207. ne = new X3DNodeElementGeometry2D(X3DElemType::ENET_Disk2D, mNodeElementCur);
  208. if (!def.empty()) ne->ID = def;
  209. // create point list of geometry object.
  210. ///TODO: IME - AI_CONFIG for NumSeg
  211. X3DGeoHelper::make_arc2D(0, 0, outerRadius, 10, tlist_o); // outer circle
  212. if (innerRadius == 0.0f) { // make filled disk
  213. // in tlist_o we already have points of circle. just copy it and sign as polygon.
  214. ((X3DNodeElementGeometry2D *)ne)->Vertices = tlist_o;
  215. ((X3DNodeElementGeometry2D *)ne)->NumIndices = tlist_o.size();
  216. } else if (innerRadius == outerRadius) { // make circle
  217. // in tlist_o we already have points of circle. convert it to line set.
  218. X3DGeoHelper::extend_point_to_line(tlist_o, ((X3DNodeElementGeometry2D *)ne)->Vertices);
  219. ((X3DNodeElementGeometry2D *)ne)->NumIndices = 2;
  220. } else { // make disk
  221. std::list<aiVector3D> &vlist = ((X3DNodeElementGeometry2D *)ne)->Vertices; // just short alias.
  222. X3DGeoHelper::make_arc2D(0, 0, innerRadius, 10, tlist_i); // inner circle
  223. //
  224. // create quad list from two point lists
  225. //
  226. if (tlist_i.size() < 2) throw DeadlyImportError("Disk2D. Not enough points for creating quad list."); // tlist_i and tlist_o has equal size.
  227. // add all quads except last
  228. for (std::list<aiVector3D>::iterator it_i = tlist_i.begin(), it_o = tlist_o.begin(); it_i != tlist_i.end();) {
  229. // do not forget - CCW direction
  230. vlist.push_back(*it_i++); // 1st point
  231. vlist.push_back(*it_o++); // 2nd point
  232. vlist.push_back(*it_o); // 3rd point
  233. vlist.push_back(*it_i); // 4th point
  234. }
  235. // add last quad
  236. vlist.push_back(*tlist_i.end()); // 1st point
  237. vlist.push_back(*tlist_o.end()); // 2nd point
  238. vlist.push_back(*tlist_o.begin()); // 3rd point
  239. vlist.push_back(*tlist_o.begin()); // 4th point
  240. ((X3DNodeElementGeometry2D *)ne)->NumIndices = 4;
  241. }
  242. ((X3DNodeElementGeometry2D *)ne)->Solid = solid;
  243. // check for X3DMetadataObject childs.
  244. if (!isNodeEmpty(node))
  245. childrenReadMetadata(node, ne, "Disk2D");
  246. else
  247. mNodeElementCur->Children.push_back(ne); // add made object as child to current element
  248. NodeElement_List.push_back(ne); // add element to node element list because its a new object in graph
  249. } // if(!use.empty()) else
  250. }
  251. // <Polyline2D
  252. // DEF="" ID
  253. // USE="" IDREF
  254. // lineSegments="" MFVec2F [intializeOnly]
  255. // />
  256. void X3DImporter::readPolyline2D(XmlNode &node) {
  257. std::string def, use;
  258. std::list<aiVector2D> lineSegments;
  259. X3DNodeElementBase *ne(nullptr);
  260. MACRO_ATTRREAD_CHECKUSEDEF_RET(node, def, use);
  261. X3DXmlHelper::getVector2DListAttribute(node, "lineSegments", lineSegments);
  262. // if "USE" defined then find already defined element.
  263. if (!use.empty()) {
  264. ne = MACRO_USE_CHECKANDAPPLY(node, def, use, ENET_Polyline2D, ne);
  265. } else {
  266. // create and if needed - define new geometry object.
  267. ne = new X3DNodeElementGeometry2D(X3DElemType::ENET_Polyline2D, mNodeElementCur);
  268. if (!def.empty()) ne->ID = def;
  269. //
  270. // convert read point list of geometry object to line set.
  271. //
  272. std::list<aiVector3D> tlist;
  273. // convert vec2 to vec3
  274. for (std::list<aiVector2D>::iterator it2 = lineSegments.begin(); it2 != lineSegments.end(); ++it2)
  275. tlist.push_back(aiVector3D(it2->x, it2->y, 0));
  276. // convert point set to line set
  277. X3DGeoHelper::extend_point_to_line(tlist, ((X3DNodeElementGeometry2D *)ne)->Vertices);
  278. ((X3DNodeElementGeometry2D *)ne)->NumIndices = 2;
  279. // check for X3DMetadataObject childs.
  280. if (!isNodeEmpty(node))
  281. childrenReadMetadata(node, ne, "Polyline2D");
  282. else
  283. mNodeElementCur->Children.push_back(ne); // add made object as child to current element
  284. NodeElement_List.push_back(ne); // add element to node element list because its a new object in graph
  285. } // if(!use.empty()) else
  286. }
  287. // <Polypoint2D
  288. // DEF="" ID
  289. // USE="" IDREF
  290. // point="" MFVec2F [inputOutput]
  291. // />
  292. void X3DImporter::readPolypoint2D(XmlNode &node) {
  293. std::string def, use;
  294. std::list<aiVector2D> point;
  295. X3DNodeElementBase *ne(nullptr);
  296. MACRO_ATTRREAD_CHECKUSEDEF_RET(node, def, use);
  297. X3DXmlHelper::getVector2DListAttribute(node, "point", point);
  298. // if "USE" defined then find already defined element.
  299. if (!use.empty()) {
  300. ne = MACRO_USE_CHECKANDAPPLY(node, def, use, ENET_Polypoint2D, ne);
  301. } else {
  302. // create and if needed - define new geometry object.
  303. ne = new X3DNodeElementGeometry2D(X3DElemType::ENET_Polypoint2D, mNodeElementCur);
  304. if (!def.empty()) ne->ID = def;
  305. // convert vec2 to vec3
  306. for (std::list<aiVector2D>::iterator it2 = point.begin(); it2 != point.end(); ++it2) {
  307. ((X3DNodeElementGeometry2D *)ne)->Vertices.push_back(aiVector3D(it2->x, it2->y, 0));
  308. }
  309. ((X3DNodeElementGeometry2D *)ne)->NumIndices = 1;
  310. // check for X3DMetadataObject childs.
  311. if (!isNodeEmpty(node))
  312. childrenReadMetadata(node, ne, "Polypoint2D");
  313. else
  314. mNodeElementCur->Children.push_back(ne); // add made object as child to current element
  315. NodeElement_List.push_back(ne); // add element to node element list because its a new object in graph
  316. } // if(!use.empty()) else
  317. }
  318. // <Rectangle2D
  319. // DEF="" ID
  320. // USE="" IDREF
  321. // size="2 2" SFVec2f [initializeOnly]
  322. // solid="false" SFBool [initializeOnly]
  323. // />
  324. void X3DImporter::readRectangle2D(XmlNode &node) {
  325. std::string def, use;
  326. aiVector2D size(2, 2);
  327. bool solid = false;
  328. X3DNodeElementBase *ne(nullptr);
  329. MACRO_ATTRREAD_CHECKUSEDEF_RET(node, def, use);
  330. X3DXmlHelper::getVector2DAttribute(node, "size", size);
  331. XmlParser::getBoolAttribute(node, "solid", solid);
  332. // if "USE" defined then find already defined element.
  333. if (!use.empty()) {
  334. ne = MACRO_USE_CHECKANDAPPLY(node, def, use, ENET_Rectangle2D, ne);
  335. } else {
  336. // create and if needed - define new geometry object.
  337. ne = new X3DNodeElementGeometry2D(X3DElemType::ENET_Rectangle2D, mNodeElementCur);
  338. if (!def.empty()) ne->ID = def;
  339. float x1 = -size.x / 2.0f;
  340. float x2 = size.x / 2.0f;
  341. float y1 = -size.y / 2.0f;
  342. float y2 = size.y / 2.0f;
  343. std::list<aiVector3D> &vlist = ((X3DNodeElementGeometry2D *)ne)->Vertices; // just short alias.
  344. vlist.push_back(aiVector3D(x2, y1, 0)); // 1st point
  345. vlist.push_back(aiVector3D(x2, y2, 0)); // 2nd point
  346. vlist.push_back(aiVector3D(x1, y2, 0)); // 3rd point
  347. vlist.push_back(aiVector3D(x1, y1, 0)); // 4th point
  348. ((X3DNodeElementGeometry2D *)ne)->Solid = solid;
  349. ((X3DNodeElementGeometry2D *)ne)->NumIndices = 4;
  350. // check for X3DMetadataObject childs.
  351. if (!isNodeEmpty(node))
  352. childrenReadMetadata(node, ne, "Rectangle2D");
  353. else
  354. mNodeElementCur->Children.push_back(ne); // add made object as child to current element
  355. NodeElement_List.push_back(ne); // add element to node element list because its a new object in graph
  356. } // if(!use.empty()) else
  357. }
  358. // <TriangleSet2D
  359. // DEF="" ID
  360. // USE="" IDREF
  361. // solid="false" SFBool [initializeOnly]
  362. // vertices="" MFVec2F [inputOutput]
  363. // />
  364. void X3DImporter::readTriangleSet2D(XmlNode &node) {
  365. std::string def, use;
  366. bool solid = false;
  367. std::list<aiVector2D> vertices;
  368. X3DNodeElementBase *ne(nullptr);
  369. MACRO_ATTRREAD_CHECKUSEDEF_RET(node, def, use);
  370. X3DXmlHelper::getVector2DListAttribute(node, "vertices", vertices);
  371. XmlParser::getBoolAttribute(node, "solid", solid);
  372. // if "USE" defined then find already defined element.
  373. if (!use.empty()) {
  374. ne = MACRO_USE_CHECKANDAPPLY(node, def, use, ENET_TriangleSet2D, ne);
  375. } else {
  376. if (vertices.size() % 3) throw DeadlyImportError("TriangleSet2D. Not enough points for defining triangle.");
  377. // create and if needed - define new geometry object.
  378. ne = new X3DNodeElementGeometry2D(X3DElemType::ENET_TriangleSet2D, mNodeElementCur);
  379. if (!def.empty()) ne->ID = def;
  380. // convert vec2 to vec3
  381. for (std::list<aiVector2D>::iterator it2 = vertices.begin(); it2 != vertices.end(); ++it2) {
  382. ((X3DNodeElementGeometry2D *)ne)->Vertices.push_back(aiVector3D(it2->x, it2->y, 0));
  383. }
  384. ((X3DNodeElementGeometry2D *)ne)->Solid = solid;
  385. ((X3DNodeElementGeometry2D *)ne)->NumIndices = 3;
  386. // check for X3DMetadataObject childs.
  387. if (!isNodeEmpty(node))
  388. childrenReadMetadata(node, ne, "TriangleSet2D");
  389. else
  390. mNodeElementCur->Children.push_back(ne); // add made object as child to current element
  391. NodeElement_List.push_back(ne); // add element to node element list because its a new object in graph
  392. } // if(!use.empty()) else
  393. }
  394. } // namespace Assimp
  395. #endif // !ASSIMP_BUILD_NO_X3D_IMPORTER