summaryrefslogtreecommitdiff
path: root/src/mesh/assimp-master/code/AssetLib/X3D/X3DImporter_Rendering.cpp
blob: 66a30a916b7d3d37b23a54a4a2a9e9b0bb6508eb (plain)
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
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
/*
Open Asset Import Library (assimp)
----------------------------------------------------------------------

Copyright (c) 2006-2019, assimp team


All rights reserved.

Redistribution and use of this software in source and binary forms,
with or without modification, are permitted provided that the
following conditions are met:

* Redistributions of source code must retain the above
copyright notice, this list of conditions and the
following disclaimer.

* Redistributions in binary form must reproduce the above
copyright notice, this list of conditions and the
following disclaimer in the documentation and/or other
materials provided with the distribution.

* Neither the name of the assimp team, nor the names of its
contributors may be used to endorse or promote products
derived from this software without specific prior
written permission of the assimp team.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

----------------------------------------------------------------------
*/
/// \file   X3DImporter_Rendering.cpp
/// \brief  Parsing data from nodes of "Rendering" set of X3D.
/// \date   2015-2016
/// \author smal.root@gmail.com

#ifndef ASSIMP_BUILD_NO_X3D_IMPORTER

#include "X3DImporter.hpp"
#include "X3DImporter_Macro.hpp"
#include "X3DXmlHelper.h"

namespace Assimp {

// <Color
// DEF=""           ID
// USE=""           IDREF
// color="" MFColor [inputOutput]
// />
void X3DImporter::readColor(XmlNode &node) {
    std::string use, def;
    std::list<aiColor3D> color;
    X3DNodeElementBase *ne(nullptr);

    MACRO_ATTRREAD_CHECKUSEDEF_RET(node, def, use);
    X3DXmlHelper::getColor3DListAttribute(node, "color", color);

    // if "USE" defined then find already defined element.
    if (!use.empty()) {
        ne = MACRO_USE_CHECKANDAPPLY(node, def, use, ENET_Color, ne);
    } else {
        // create and if needed - define new geometry object.
        ne = new X3DNodeElementColor(mNodeElementCur);
        if (!def.empty()) ne->ID = def;

        ((X3DNodeElementColor *)ne)->Value = color;
        // check for X3DMetadataObject childs.
        if (!isNodeEmpty(node))
            childrenReadMetadata(node, ne, "Color");
        else
            mNodeElementCur->Children.push_back(ne); // add made object as child to current element

        NodeElement_List.push_back(ne); // add element to node element list because its a new object in graph
    } // if(!use.empty()) else
}

// <ColorRGBA
// DEF=""               ID
// USE=""               IDREF
// color="" MFColorRGBA [inputOutput]
// />
void X3DImporter::readColorRGBA(XmlNode &node) {
    std::string use, def;
    std::list<aiColor4D> color;
    X3DNodeElementBase *ne(nullptr);

    MACRO_ATTRREAD_CHECKUSEDEF_RET(node, def, use);
    X3DXmlHelper::getColor4DListAttribute(node, "color", color);

    // if "USE" defined then find already defined element.
    if (!use.empty()) {
        ne = MACRO_USE_CHECKANDAPPLY(node, def, use, ENET_ColorRGBA, ne);
    } else {
        // create and if needed - define new geometry object.
        ne = new X3DNodeElementColorRGBA(mNodeElementCur);
        if (!def.empty()) ne->ID = def;

        ((X3DNodeElementColorRGBA *)ne)->Value = color;
        // check for X3DMetadataObject childs.
        if (!isNodeEmpty(node))
            childrenReadMetadata(node, ne, "ColorRGBA");
        else
            mNodeElementCur->Children.push_back(ne); // add made object as child to current element

        NodeElement_List.push_back(ne); // add element to node element list because its a new object in graph
    } // if(!use.empty()) else
}

// <Coordinate
// DEF=""      ID
// USE=""      IDREF
// point=""    MFVec3f [inputOutput]
// />
void X3DImporter::readCoordinate(XmlNode &node) {
    std::string use, def;
    std::list<aiVector3D> point;
    X3DNodeElementBase *ne(nullptr);

    MACRO_ATTRREAD_CHECKUSEDEF_RET(node, def, use);
    X3DXmlHelper::getVector3DListAttribute(node, "point", point);

    // if "USE" defined then find already defined element.
    if (!use.empty()) {
        ne = MACRO_USE_CHECKANDAPPLY(node, def, use, ENET_Coordinate, ne);
    } else {
        // create and if needed - define new geometry object.
        ne = new X3DNodeElementCoordinate(mNodeElementCur);
        if (!def.empty()) ne->ID = def;

        ((X3DNodeElementCoordinate *)ne)->Value = point;
        // check for X3DMetadataObject childs.
        if (!isNodeEmpty(node))
            childrenReadMetadata(node, ne, "Coordinate");
        else
            mNodeElementCur->Children.push_back(ne); // add made object as child to current element

        NodeElement_List.push_back(ne); // add element to node element list because its a new object in graph
    } // if(!use.empty()) else
}

// <IndexedLineSet
// DEF=""                ID
// USE=""                IDREF
// colorIndex=""         MFInt32 [initializeOnly]
// colorPerVertex="true" SFBool  [initializeOnly]
// coordIndex=""         MFInt32 [initializeOnly]
// >
//    <!-- ColorCoordinateContentModel -->
// ColorCoordinateContentModel is the child-node content model corresponding to IndexedLineSet, LineSet and PointSet. ColorCoordinateContentModel can
// contain any-order Coordinate node with Color (or ColorRGBA) node. No more than one instance of any single node type is allowed.
// A ProtoInstance node (with the proper node type) can be substituted for any node in this content model.
// </IndexedLineSet>
void X3DImporter::readIndexedLineSet(XmlNode &node) {
    std::string use, def;
    std::vector<int32_t> colorIndex;
    bool colorPerVertex = true;
    std::vector<int32_t> coordIndex;
    X3DNodeElementBase *ne(nullptr);

    MACRO_ATTRREAD_CHECKUSEDEF_RET(node, def, use);
    X3DXmlHelper::getInt32ArrayAttribute(node, "colorIndex", colorIndex);
    XmlParser::getBoolAttribute(node, "colorPerVertex", colorPerVertex);
    X3DXmlHelper::getInt32ArrayAttribute(node, "coordIndex", coordIndex);

    // if "USE" defined then find already defined element.
    if (!use.empty()) {
        ne = MACRO_USE_CHECKANDAPPLY(node, def, use, ENET_IndexedLineSet, ne);
    } else {
        // check data
        if ((coordIndex.size() < 2) || ((coordIndex.back() == (-1)) && (coordIndex.size() < 3)))
            throw DeadlyImportError("IndexedLineSet must contain not empty \"coordIndex\" attribute.");

        // create and if needed - define new geometry object.
        ne = new X3DNodeElementIndexedSet(X3DElemType::ENET_IndexedLineSet, mNodeElementCur);
        if (!def.empty()) ne->ID = def;

        X3DNodeElementIndexedSet &ne_alias = *((X3DNodeElementIndexedSet *)ne);

        ne_alias.ColorIndex = colorIndex;
        ne_alias.ColorPerVertex = colorPerVertex;
        ne_alias.CoordIndex = coordIndex;
        // check for child nodes
        if (!isNodeEmpty(node)) {
            ParseHelper_Node_Enter(ne);
            for (auto currentChildNode : node.children()) {
                const std::string &currentChildName = currentChildNode.name();
                // check for Color and Coordinate nodes
                if (currentChildName == "Color")
                    readColor(currentChildNode);
                else if (currentChildName == "ColorRGBA")
                    readColorRGBA(currentChildNode);
                else if (currentChildName == "Coordinate")
                    readCoordinate(currentChildNode);
                // check for X3DMetadataObject
                else if (!checkForMetadataNode(currentChildNode))
                    skipUnsupportedNode("IndexedLineSet", currentChildNode);
            }
            ParseHelper_Node_Exit();
        } // if(!isNodeEmpty(node))
        else {
            mNodeElementCur->Children.push_back(ne); // add made object as child to current element
        }

        NodeElement_List.push_back(ne); // add element to node element list because its a new object in graph
    } // if(!use.empty()) else
}

// <IndexedTriangleFanSet
// DEF=""                 ID
// USE=""                 IDREF
// ccw="true"             SFBool  [initializeOnly]
// colorPerVertex="true"  SFBool  [initializeOnly]
// index=""               MFInt32 [initializeOnly]
// normalPerVertex="true" SFBool  [initializeOnly]
// solid="true"           SFBool  [initializeOnly]
// >
//    <!-- ComposedGeometryContentModel -->
// ComposedGeometryContentModel is the child-node content model corresponding to X3DComposedGeometryNodes. It can contain Color (or ColorRGBA), Coordinate,
// Normal and TextureCoordinate, in any order. No more than one instance of these nodes is allowed. Multiple VertexAttribute (FloatVertexAttribute,
// Matrix3VertexAttribute, Matrix4VertexAttribute) nodes can also be contained.
// A ProtoInstance node (with the proper node type) can be substituted for any node in this content model.
// </IndexedTriangleFanSet>
void X3DImporter::readIndexedTriangleFanSet(XmlNode &node) {
    std::string use, def;
    bool ccw = true;
    bool colorPerVertex = true;
    std::vector<int32_t> index;
    bool normalPerVertex = true;
    bool solid = true;
    X3DNodeElementBase *ne(nullptr);

    MACRO_ATTRREAD_CHECKUSEDEF_RET(node, def, use);
    XmlParser::getBoolAttribute(node, "ccw", ccw);
    XmlParser::getBoolAttribute(node, "colorPerVertex", colorPerVertex);
    X3DXmlHelper::getInt32ArrayAttribute(node, "index", index);
    XmlParser::getBoolAttribute(node, "normalPerVertex", normalPerVertex);
    XmlParser::getBoolAttribute(node, "solid", solid);

    // if "USE" defined then find already defined element.
    if (!use.empty()) {
        ne = MACRO_USE_CHECKANDAPPLY(node, def, use, ENET_IndexedTriangleFanSet, ne);
    } else {
        // check data
        if (index.size() == 0) throw DeadlyImportError("IndexedTriangleFanSet must contain not empty \"index\" attribute.");

        // create and if needed - define new geometry object.
        ne = new X3DNodeElementIndexedSet(X3DElemType::ENET_IndexedTriangleFanSet, mNodeElementCur);
        if (!def.empty()) ne->ID = def;

        X3DNodeElementIndexedSet &ne_alias = *((X3DNodeElementIndexedSet *)ne);

        ne_alias.CCW = ccw;
        ne_alias.ColorPerVertex = colorPerVertex;
        ne_alias.NormalPerVertex = normalPerVertex;
        ne_alias.Solid = solid;

        ne_alias.CoordIndex.clear();
        int counter = 0;
        int32_t idx[3];
        for (std::vector<int32_t>::const_iterator idx_it = index.begin(); idx_it != index.end(); ++idx_it) {
            idx[2] = *idx_it;
            if (idx[2] < 0) {
                counter = 0;
            } else {
                if (counter >= 2) {
                    if (ccw) {
                        ne_alias.CoordIndex.push_back(idx[0]);
                        ne_alias.CoordIndex.push_back(idx[1]);
                        ne_alias.CoordIndex.push_back(idx[2]);
                    } else {
                        ne_alias.CoordIndex.push_back(idx[0]);
                        ne_alias.CoordIndex.push_back(idx[2]);
                        ne_alias.CoordIndex.push_back(idx[1]);
                    }
                    ne_alias.CoordIndex.push_back(-1);
                    idx[1] = idx[2];
                } else {
                    idx[counter] = idx[2];
                }
                ++counter;
            }
        } // for(std::list<int32_t>::const_iterator idx_it = index.begin(); idx_it != ne_alias.index.end(); idx_it++)

        // check for child nodes
        if (!isNodeEmpty(node)) {
            ParseHelper_Node_Enter(ne);
            for (auto currentChildNode : node.children()) {
                const std::string &currentChildName = currentChildNode.name();
                // check for X3DComposedGeometryNodes
                if (currentChildName == "Color")
                    readColor(currentChildNode);
                else if (currentChildName == "ColorRGBA")
                    readColorRGBA(currentChildNode);
                else if (currentChildName == "Coordinate")
                    readCoordinate(currentChildNode);
                else if (currentChildName == "Normal")
                    readNormal(currentChildNode);
                else if (currentChildName == "TextureCoordinate")
                    readTextureCoordinate(currentChildNode);
                // check for X3DMetadataObject
                else if (!checkForMetadataNode(currentChildNode))
                    skipUnsupportedNode("IndexedTriangleFanSet", currentChildNode);
            }
            ParseHelper_Node_Exit();
        } // if(!isNodeEmpty(node))
        else {
            mNodeElementCur->Children.push_back(ne); // add made object as child to current element
        }

        NodeElement_List.push_back(ne); // add element to node element list because its a new object in graph
    } // if(!use.empty()) else
}

// <IndexedTriangleSet
// DEF=""                 ID
// USE=""                 IDREF
// ccw="true"             SFBool  [initializeOnly]
// colorPerVertex="true"  SFBool  [initializeOnly]
// index=""               MFInt32 [initializeOnly]
// normalPerVertex="true" SFBool  [initializeOnly]
// solid="true"           SFBool  [initializeOnly]
// >
//    <!-- ComposedGeometryContentModel -->
// ComposedGeometryContentModel is the child-node content model corresponding to X3DComposedGeometryNodes. It can contain Color (or ColorRGBA), Coordinate,
// Normal and TextureCoordinate, in any order. No more than one instance of these nodes is allowed. Multiple VertexAttribute (FloatVertexAttribute,
// Matrix3VertexAttribute, Matrix4VertexAttribute) nodes can also be contained.
// A ProtoInstance node (with the proper node type) can be substituted for any node in this content model.
// </IndexedTriangleSet>
void X3DImporter::readIndexedTriangleSet(XmlNode &node) {
    std::string use, def;
    bool ccw = true;
    bool colorPerVertex = true;
    std::vector<int32_t> index;
    bool normalPerVertex = true;
    bool solid = true;
    X3DNodeElementBase *ne(nullptr);

    MACRO_ATTRREAD_CHECKUSEDEF_RET(node, def, use);
    XmlParser::getBoolAttribute(node, "ccw", ccw);
    XmlParser::getBoolAttribute(node, "colorPerVertex", colorPerVertex);
    X3DXmlHelper::getInt32ArrayAttribute(node, "index", index);
    XmlParser::getBoolAttribute(node, "normalPerVertex", normalPerVertex);
    XmlParser::getBoolAttribute(node, "solid", solid);

    // if "USE" defined then find already defined element.
    if (!use.empty()) {
        ne = MACRO_USE_CHECKANDAPPLY(node, def, use, ENET_IndexedTriangleSet, ne);
    } else {
        // check data
        if (index.size() == 0) throw DeadlyImportError("IndexedTriangleSet must contain not empty \"index\" attribute.");

        // create and if needed - define new geometry object.
        ne = new X3DNodeElementIndexedSet(X3DElemType::ENET_IndexedTriangleSet, mNodeElementCur);
        if (!def.empty()) ne->ID = def;

        X3DNodeElementIndexedSet &ne_alias = *((X3DNodeElementIndexedSet *)ne);

        ne_alias.CCW = ccw;
        ne_alias.ColorPerVertex = colorPerVertex;
        ne_alias.NormalPerVertex = normalPerVertex;
        ne_alias.Solid = solid;

        ne_alias.CoordIndex.clear();
        int counter = 0;
        int32_t idx[3];
        for (std::vector<int32_t>::const_iterator idx_it = index.begin(); idx_it != index.end(); ++idx_it) {
            idx[counter++] = *idx_it;
            if (counter > 2) {
                counter = 0;
                if (ccw) {
                    ne_alias.CoordIndex.push_back(idx[0]);
                    ne_alias.CoordIndex.push_back(idx[1]);
                    ne_alias.CoordIndex.push_back(idx[2]);
                } else {
                    ne_alias.CoordIndex.push_back(idx[0]);
                    ne_alias.CoordIndex.push_back(idx[2]);
                    ne_alias.CoordIndex.push_back(idx[1]);
                }
                ne_alias.CoordIndex.push_back(-1);
            }
        } // for(std::list<int32_t>::const_iterator idx_it = index.begin(); idx_it != ne_alias.index.end(); idx_it++)

        // check for child nodes
        if (!isNodeEmpty(node)) {
            ParseHelper_Node_Enter(ne);
            for (auto currentChildNode : node.children()) {
                const std::string &currentChildName = currentChildNode.name();
                // check for X3DComposedGeometryNodes
                if (currentChildName == "Color")
                    readColor(currentChildNode);
                else if (currentChildName == "ColorRGBA")
                    readColorRGBA(currentChildNode);
                else if (currentChildName == "Coordinate")
                    readCoordinate(currentChildNode);
                else if (currentChildName == "Normal")
                    readNormal(currentChildNode);
                else if (currentChildName == "TextureCoordinate")
                    readTextureCoordinate(currentChildNode);
                // check for X3DMetadataObject
                else if (!checkForMetadataNode(currentChildNode))
                    skipUnsupportedNode("IndexedTriangleSet", currentChildNode);
            }
            ParseHelper_Node_Exit();
        } // if(!isNodeEmpty(node))
        else {
            mNodeElementCur->Children.push_back(ne); // add made object as child to current element
        }

        NodeElement_List.push_back(ne); // add element to node element list because its a new object in graph
    } // if(!use.empty()) else
}

// <IndexedTriangleStripSet
// DEF=""                 ID
// USE=""                 IDREF
// ccw="true"             SFBool  [initializeOnly]
// colorPerVertex="true"  SFBool  [initializeOnly]
// index=""               MFInt32 [initializeOnly]
// normalPerVertex="true" SFBool  [initializeOnly]
// solid="true"           SFBool  [initializeOnly]
// >
//    <!-- ComposedGeometryContentModel -->
// ComposedGeometryContentModel is the child-node content model corresponding to X3DComposedGeometryNodes. It can contain Color (or ColorRGBA), Coordinate,
// Normal and TextureCoordinate, in any order. No more than one instance of these nodes is allowed. Multiple VertexAttribute (FloatVertexAttribute,
// Matrix3VertexAttribute, Matrix4VertexAttribute) nodes can also be contained.
// A ProtoInstance node (with the proper node type) can be substituted for any node in this content model.
// </IndexedTriangleStripSet>
void X3DImporter::readIndexedTriangleStripSet(XmlNode &node) {
    std::string use, def;
    bool ccw = true;
    bool colorPerVertex = true;
    std::vector<int32_t> index;
    bool normalPerVertex = true;
    bool solid = true;
    X3DNodeElementBase *ne(nullptr);

    MACRO_ATTRREAD_CHECKUSEDEF_RET(node, def, use);
    XmlParser::getBoolAttribute(node, "ccw", ccw);
    XmlParser::getBoolAttribute(node, "colorPerVertex", colorPerVertex);
    X3DXmlHelper::getInt32ArrayAttribute(node, "index", index);
    XmlParser::getBoolAttribute(node, "normalPerVertex", normalPerVertex);
    XmlParser::getBoolAttribute(node, "solid", solid);

    // if "USE" defined then find already defined element.
    if (!use.empty()) {
        ne = MACRO_USE_CHECKANDAPPLY(node, def, use, ENET_IndexedTriangleStripSet, ne);
    } else {
        // check data
        if (index.empty()) {
            throw DeadlyImportError("IndexedTriangleStripSet must contain not empty \"index\" attribute.");
        }

        // create and if needed - define new geometry object.
        ne = new X3DNodeElementIndexedSet(X3DElemType::ENET_IndexedTriangleStripSet, mNodeElementCur);
        if (!def.empty()) ne->ID = def;

        X3DNodeElementIndexedSet &ne_alias = *((X3DNodeElementIndexedSet *)ne);

        ne_alias.CCW = ccw;
        ne_alias.ColorPerVertex = colorPerVertex;
        ne_alias.NormalPerVertex = normalPerVertex;
        ne_alias.Solid = solid;

        ne_alias.CoordIndex.clear();
        int counter = 0;
        int32_t idx[3];
        for (std::vector<int32_t>::const_iterator idx_it = index.begin(); idx_it != index.end(); ++idx_it) {
            idx[2] = *idx_it;
            if (idx[2] < 0) {
                counter = 0;
            } else {
                if (counter >= 2) {
                    if (ccw) {
                        ne_alias.CoordIndex.push_back(idx[0]);
                        ne_alias.CoordIndex.push_back(idx[1]);
                        ne_alias.CoordIndex.push_back(idx[2]);
                    } else {
                        ne_alias.CoordIndex.push_back(idx[0]);
                        ne_alias.CoordIndex.push_back(idx[2]);
                        ne_alias.CoordIndex.push_back(idx[1]);
                    }
                    ne_alias.CoordIndex.push_back(-1);
                }
                idx[counter & 1] = idx[2];
                ++counter;
            }
        } // for(std::list<int32_t>::const_iterator idx_it = index.begin(); idx_it != ne_alias.index.end(); idx_it++)

        // check for child nodes
        if (!isNodeEmpty(node)) {
            ParseHelper_Node_Enter(ne);
            for (auto currentChildNode : node.children()) {
                const std::string &currentChildName = currentChildNode.name();
                // check for X3DComposedGeometryNodes
                if (currentChildName == "Color")
                    readColor(currentChildNode);
                else if (currentChildName == "ColorRGBA")
                    readColorRGBA(currentChildNode);
                else if (currentChildName == "Coordinate")
                    readCoordinate(currentChildNode);
                else if (currentChildName == "Normal")
                    readNormal(currentChildNode);
                else if (currentChildName == "TextureCoordinate")
                    readTextureCoordinate(currentChildNode);
                // check for X3DMetadataObject
                else if (!checkForMetadataNode(currentChildNode))
                    skipUnsupportedNode("IndexedTriangleStripSet", currentChildNode);
            }
            ParseHelper_Node_Exit();
        } // if(!isNodeEmpty(node))
        else {
            mNodeElementCur->Children.push_back(ne); // add made object as child to current element
        }

        NodeElement_List.push_back(ne); // add element to node element list because its a new object in graph
    } // if(!use.empty()) else
}

// <LineSet
// DEF=""         ID
// USE=""         IDREF
// vertexCount="" MFInt32 [initializeOnly]
// >
//    <!-- ColorCoordinateContentModel -->
// ColorCoordinateContentModel is the child-node content model corresponding to IndexedLineSet, LineSet and PointSet. ColorCoordinateContentModel can
// contain any-order Coordinate node with Color (or ColorRGBA) node. No more than one instance of any single node type is allowed.
// A ProtoInstance node (with the proper node type) can be substituted for any node in this content model.
// </LineSet>
void X3DImporter::readLineSet(XmlNode &node) {
    std::string use, def;
    std::vector<int32_t> vertexCount;
    X3DNodeElementBase *ne(nullptr);

    MACRO_ATTRREAD_CHECKUSEDEF_RET(node, def, use);
    X3DXmlHelper::getInt32ArrayAttribute(node, "vertexCount", vertexCount);

    // if "USE" defined then find already defined element.
    if (!use.empty()) {
        ne = MACRO_USE_CHECKANDAPPLY(node, def, use, ENET_LineSet, ne);
    } else {
        // check data
        if (vertexCount.empty()) {
            throw DeadlyImportError("LineSet must contain not empty \"vertexCount\" attribute.");
        }

        // create and if needed - define new geometry object.
        ne = new X3DNodeElementSet(X3DElemType::ENET_LineSet, mNodeElementCur);
        if (!def.empty()) ne->ID = def;

        X3DNodeElementSet &ne_alias = *((X3DNodeElementSet *)ne);

        ne_alias.VertexCount = vertexCount;
        // create CoordIdx
        size_t coord_num = 0;

        ne_alias.CoordIndex.clear();
        for (std::vector<int32_t>::const_iterator vc_it = ne_alias.VertexCount.begin(); vc_it != ne_alias.VertexCount.end(); ++vc_it) {
            if (*vc_it < 2) throw DeadlyImportError("LineSet. vertexCount shall be greater than or equal to two.");

            for (int32_t i = 0; i < *vc_it; i++)
                ne_alias.CoordIndex.push_back(static_cast<int32_t>(coord_num++)); // add vertices indices

            ne_alias.CoordIndex.push_back(-1); // add face delimiter.
        }

        // check for child nodes
        if (!isNodeEmpty(node)) {
            ParseHelper_Node_Enter(ne);
            for (auto currentChildNode : node.children()) {
                const std::string &currentChildName = currentChildNode.name();
                // check for X3DComposedGeometryNodes
                if (currentChildName == "Color")
                    readColor(currentChildNode);
                else if (currentChildName == "ColorRGBA")
                    readColorRGBA(currentChildNode);
                else if (currentChildName == "Coordinate")
                    readCoordinate(currentChildNode);
                // check for X3DMetadataObject
                else if (!checkForMetadataNode(currentChildNode))
                    skipUnsupportedNode("LineSet", currentChildNode);
            }
            ParseHelper_Node_Exit();
        } // if(!isNodeEmpty(node))
        else {
            mNodeElementCur->Children.push_back(ne); // add made object as child to current element
        }

        NodeElement_List.push_back(ne); // add element to node element list because its a new object in graph
    } // if(!use.empty()) else
}

// <PointSet
// DEF="" ID
// USE="" IDREF
// >
//    <!-- ColorCoordinateContentModel -->
// ColorCoordinateContentModel is the child-node content model corresponding to IndexedLineSet, LineSet and PointSet. ColorCoordinateContentModel can
// contain any-order Coordinate node with Color (or ColorRGBA) node. No more than one instance of any single node type is allowed.
// A ProtoInstance node (with the proper node type) can be substituted for any node in this content model.
// </PointSet>
void X3DImporter::readPointSet(XmlNode &node) {
    std::string use, def;
    X3DNodeElementBase *ne(nullptr);

    MACRO_ATTRREAD_CHECKUSEDEF_RET(node, def, use);

    // if "USE" defined then find already defined element.
    if (!use.empty()) {
        ne = MACRO_USE_CHECKANDAPPLY(node, def, use, ENET_PointSet, ne);
    } else {
        // create and if needed - define new geometry object.
        ne = new X3DNodeElementIndexedSet(X3DElemType::ENET_PointSet, mNodeElementCur);
        if (!def.empty()) ne->ID = def;

        // check for child nodes
        if (!isNodeEmpty(node)) {
            ParseHelper_Node_Enter(ne);
            for (auto currentChildNode : node.children()) {
                const std::string &currentChildName = currentChildNode.name();
                // check for X3DComposedGeometryNodes
                if (currentChildName == "Color")
                    readColor(currentChildNode);
                else if (currentChildName == "ColorRGBA")
                    readColorRGBA(currentChildNode);
                else if (currentChildName == "Coordinate")
                    readCoordinate(currentChildNode);
                // check for X3DMetadataObject
                else if (!checkForMetadataNode(currentChildNode))
                    skipUnsupportedNode("PointSet", currentChildNode);
            }
            ParseHelper_Node_Exit();
        } // if(!isNodeEmpty(node))
        else {
            mNodeElementCur->Children.push_back(ne); // add made object as child to current element
        }

        NodeElement_List.push_back(ne); // add element to node element list because its a new object in graph
    } // if(!use.empty()) else
}

// <TriangleFanSet
// DEF=""                 ID
// USE=""                 IDREF
// ccw="true"             SFBool  [initializeOnly]
// colorPerVertex="true"  SFBool  [initializeOnly]
// fanCount=""            MFInt32 [inputOutput]
// normalPerVertex="true" SFBool  [initializeOnly]
// solid="true"           SFBool  [initializeOnly]
// >
//    <!-- ComposedGeometryContentModel -->
// ComposedGeometryContentModel is the child-node content model corresponding to X3DComposedGeometryNodes. It can contain Color (or ColorRGBA), Coordinate,
// Normal and TextureCoordinate, in any order. No more than one instance of these nodes is allowed. Multiple VertexAttribute (FloatVertexAttribute,
// Matrix3VertexAttribute, Matrix4VertexAttribute) nodes can also be contained.
// A ProtoInstance node (with the proper node type) can be substituted for any node in this content model.
// </TriangleFanSet>
void X3DImporter::readTriangleFanSet(XmlNode &node) {
    std::string use, def;
    bool ccw = true;
    bool colorPerVertex = true;
    std::vector<int32_t> fanCount;
    bool normalPerVertex = true;
    bool solid = true;
    X3DNodeElementBase *ne(nullptr);

    MACRO_ATTRREAD_CHECKUSEDEF_RET(node, def, use);
    XmlParser::getBoolAttribute(node, "ccw", ccw);
    XmlParser::getBoolAttribute(node, "colorPerVertex", colorPerVertex);
    X3DXmlHelper::getInt32ArrayAttribute(node, "fanCount", fanCount);
    XmlParser::getBoolAttribute(node, "normalPerVertex", normalPerVertex);
    XmlParser::getBoolAttribute(node, "solid", solid);

    // if "USE" defined then find already defined element.
    if (!use.empty()) {
        ne = MACRO_USE_CHECKANDAPPLY(node, def, use, ENET_TriangleFanSet, ne);
    } else {
        // check data
        if (fanCount.empty()) {
            throw DeadlyImportError("TriangleFanSet must contain not empty \"fanCount\" attribute.");
        }

        // create and if needed - define new geometry object.
        ne = new X3DNodeElementSet(X3DElemType::ENET_TriangleFanSet, mNodeElementCur);
        if (!def.empty()) ne->ID = def;

        X3DNodeElementSet &ne_alias = *((X3DNodeElementSet *)ne);

        ne_alias.CCW = ccw;
        ne_alias.ColorPerVertex = colorPerVertex;
        ne_alias.VertexCount = fanCount;
        ne_alias.NormalPerVertex = normalPerVertex;
        ne_alias.Solid = solid;
        // create CoordIdx
        size_t coord_num_first, coord_num_prev;

        ne_alias.CoordIndex.clear();
        // assign indices for first triangle
        coord_num_first = 0;
        coord_num_prev = 1;
        for (std::vector<int32_t>::const_iterator vc_it = ne_alias.VertexCount.begin(); vc_it != ne_alias.VertexCount.end(); ++vc_it) {
            if (*vc_it < 3) throw DeadlyImportError("TriangleFanSet. fanCount shall be greater than or equal to three.");

            for (int32_t vc = 2; vc < *vc_it; vc++) {
                if (ccw) {
                    // 2 1
                    //  0
                    ne_alias.CoordIndex.push_back(static_cast<int32_t>(coord_num_first)); // first vertex is a center and always is [0].
                    ne_alias.CoordIndex.push_back(static_cast<int32_t>(coord_num_prev++));
                    ne_alias.CoordIndex.push_back(static_cast<int32_t>(coord_num_prev));
                } else {
                    // 1 2
                    //  0
                    ne_alias.CoordIndex.push_back(static_cast<int32_t>(coord_num_first)); // first vertex is a center and always is [0].
                    ne_alias.CoordIndex.push_back(static_cast<int32_t>(coord_num_prev + 1));
                    ne_alias.CoordIndex.push_back(static_cast<int32_t>(coord_num_prev++));
                } // if(ccw) else

                ne_alias.CoordIndex.push_back(-1); // add face delimiter.
            } // for(int32_t vc = 2; vc < *vc_it; vc++)

            coord_num_prev++; // that index will be center of next fan
            coord_num_first = coord_num_prev++; // forward to next point - second point of fan
        } // for(std::list<int32_t>::const_iterator vc_it = ne_alias.VertexCount.begin(); vc_it != ne_alias.VertexCount.end(); vc_it++)
        // check for child nodes
        if (!isNodeEmpty(node)) {
            ParseHelper_Node_Enter(ne);
            for (auto currentChildNode : node.children()) {
                const std::string &currentChildName = currentChildNode.name();
                // check for X3DComposedGeometryNodes
                if (currentChildName == "Color")
                    readColor(currentChildNode);
                else if (currentChildName == "ColorRGBA")
                    readColorRGBA(currentChildNode);
                else if (currentChildName == "Coordinate")
                    readCoordinate(currentChildNode);
                else if (currentChildName == "Normal")
                    readNormal(currentChildNode);
                else if (currentChildName == "TextureCoordinate")
                    readTextureCoordinate(currentChildNode);
                // check for X3DMetadataObject
                else if (!checkForMetadataNode(currentChildNode))
                    skipUnsupportedNode("TriangleFanSet", currentChildNode);
            }
            ParseHelper_Node_Exit();
        } // if(!isNodeEmpty(node))
        else {
            mNodeElementCur->Children.push_back(ne); // add made object as child to current element
        }

        NodeElement_List.push_back(ne); // add element to node element list because its a new object in graph
    } // if(!use.empty()) else
}

// <TriangleSet
// DEF=""                 ID
// USE=""                 IDREF
// ccw="true"             SFBool  [initializeOnly]
// colorPerVertex="true"  SFBool  [initializeOnly]
// normalPerVertex="true" SFBool  [initializeOnly]
// solid="true"           SFBool  [initializeOnly]
// >
//    <!-- ComposedGeometryContentModel -->
// ComposedGeometryContentModel is the child-node content model corresponding to X3DComposedGeometryNodes. It can contain Color (or ColorRGBA), Coordinate,
// Normal and TextureCoordinate, in any order. No more than one instance of these nodes is allowed. Multiple VertexAttribute (FloatVertexAttribute,
// Matrix3VertexAttribute, Matrix4VertexAttribute) nodes can also be contained.
// A ProtoInstance node (with the proper node type) can be substituted for any node in this content model.
// </TriangleSet>
void X3DImporter::readTriangleSet(XmlNode &node) {
    std::string use, def;
    bool ccw = true;
    bool colorPerVertex = true;
    bool normalPerVertex = true;
    bool solid = true;
    X3DNodeElementBase *ne(nullptr);

    MACRO_ATTRREAD_CHECKUSEDEF_RET(node, def, use);
    XmlParser::getBoolAttribute(node, "ccw", ccw);
    XmlParser::getBoolAttribute(node, "colorPerVertex", colorPerVertex);
    XmlParser::getBoolAttribute(node, "normalPerVertex", normalPerVertex);
    XmlParser::getBoolAttribute(node, "solid", solid);

    // if "USE" defined then find already defined element.
    if (!use.empty()) {
        ne = MACRO_USE_CHECKANDAPPLY(node, def, use, ENET_TriangleSet, ne);
    } else {
        // create and if needed - define new geometry object.
        ne = new X3DNodeElementIndexedSet(X3DElemType::ENET_TriangleSet, mNodeElementCur);
        if (!def.empty()) ne->ID = def;

        X3DNodeElementSet &ne_alias = *((X3DNodeElementSet *)ne);

        ne_alias.CCW = ccw;
        ne_alias.ColorPerVertex = colorPerVertex;
        ne_alias.NormalPerVertex = normalPerVertex;
        ne_alias.Solid = solid;
        // check for child nodes
        if (!isNodeEmpty(node)) {
            ParseHelper_Node_Enter(ne);
            for (auto currentChildNode : node.children()) {
                const std::string &currentChildName = currentChildNode.name();
                // check for X3DComposedGeometryNodes
                if (currentChildName == "Color")
                    readColor(currentChildNode);
                else if (currentChildName == "ColorRGBA")
                    readColorRGBA(currentChildNode);
                else if (currentChildName == "Coordinate")
                    readCoordinate(currentChildNode);
                else if (currentChildName == "Normal")
                    readNormal(currentChildNode);
                else if (currentChildName == "TextureCoordinate")
                    readTextureCoordinate(currentChildNode);
                // check for X3DMetadataObject
                else if (!checkForMetadataNode(currentChildNode))
                    skipUnsupportedNode("TriangleSet", currentChildNode);
            }
            ParseHelper_Node_Exit();
        } // if(!isNodeEmpty(node))
        else {
            mNodeElementCur->Children.push_back(ne); // add made object as child to current element
        }

        NodeElement_List.push_back(ne); // add element to node element list because its a new object in graph
    } // if(!use.empty()) else
}

// <TriangleStripSet
// DEF=""                 ID
// USE=""                 IDREF
// ccw="true"             SFBool  [initializeOnly]
// colorPerVertex="true"  SFBool  [initializeOnly]
// normalPerVertex="true" SFBool  [initializeOnly]
// solid="true"           SFBool  [initializeOnly]
// stripCount=""          MFInt32 [inputOutput]
// >
//    <!-- ComposedGeometryContentModel -->
// ComposedGeometryContentModel is the child-node content model corresponding to X3DComposedGeometryNodes. It can contain Color (or ColorRGBA), Coordinate,
// Normal and TextureCoordinate, in any order. No more than one instance of these nodes is allowed. Multiple VertexAttribute (FloatVertexAttribute,
// Matrix3VertexAttribute, Matrix4VertexAttribute) nodes can also be contained.
// A ProtoInstance node (with the proper node type) can be substituted for any node in this content model.
// </TriangleStripSet>
void X3DImporter::readTriangleStripSet(XmlNode &node) {
    std::string use, def;
    bool ccw = true;
    bool colorPerVertex = true;
    std::vector<int32_t> stripCount;
    bool normalPerVertex = true;
    bool solid = true;
    X3DNodeElementBase *ne(nullptr);

    MACRO_ATTRREAD_CHECKUSEDEF_RET(node, def, use);
    XmlParser::getBoolAttribute(node, "ccw", ccw);
    XmlParser::getBoolAttribute(node, "colorPerVertex", colorPerVertex);
    X3DXmlHelper::getInt32ArrayAttribute(node, "stripCount", stripCount);
    XmlParser::getBoolAttribute(node, "normalPerVertex", normalPerVertex);
    XmlParser::getBoolAttribute(node, "solid", solid);

    // if "USE" defined then find already defined element.
    if (!use.empty()) {
        ne = MACRO_USE_CHECKANDAPPLY(node, def, use, ENET_TriangleStripSet, ne);
    } else {
        // check data
        if (stripCount.size() == 0) throw DeadlyImportError("TriangleStripSet must contain not empty \"stripCount\" attribute.");

        // create and if needed - define new geometry object.
        ne = new X3DNodeElementSet(X3DElemType::ENET_TriangleStripSet, mNodeElementCur);
        if (!def.empty()) ne->ID = def;

        X3DNodeElementSet &ne_alias = *((X3DNodeElementSet *)ne);

        ne_alias.CCW = ccw;
        ne_alias.ColorPerVertex = colorPerVertex;
        ne_alias.VertexCount = stripCount;
        ne_alias.NormalPerVertex = normalPerVertex;
        ne_alias.Solid = solid;
        // create CoordIdx
        size_t coord_num0, coord_num1, coord_num2; // indices of current triangle
        bool odd_tri; // sequence of current triangle
        size_t coord_num_sb; // index of first point of strip

        ne_alias.CoordIndex.clear();
        coord_num_sb = 0;
        for (std::vector<int32_t>::const_iterator vc_it = ne_alias.VertexCount.begin(); vc_it != ne_alias.VertexCount.end(); ++vc_it) {
            if (*vc_it < 3) throw DeadlyImportError("TriangleStripSet. stripCount shall be greater than or equal to three.");

            // set initial values for first triangle
            coord_num0 = coord_num_sb;
            coord_num1 = coord_num_sb + 1;
            coord_num2 = coord_num_sb + 2;
            odd_tri = true;

            for (int32_t vc = 2; vc < *vc_it; vc++) {
                if (ccw) {
                    // 0 2
                    //  1
                    ne_alias.CoordIndex.push_back(static_cast<int32_t>(coord_num0));
                    ne_alias.CoordIndex.push_back(static_cast<int32_t>(coord_num1));
                    ne_alias.CoordIndex.push_back(static_cast<int32_t>(coord_num2));
                } else {
                    // 0 1
                    //  2
                    ne_alias.CoordIndex.push_back(static_cast<int32_t>(coord_num0));
                    ne_alias.CoordIndex.push_back(static_cast<int32_t>(coord_num2));
                    ne_alias.CoordIndex.push_back(static_cast<int32_t>(coord_num1));
                } // if(ccw) else

                ne_alias.CoordIndex.push_back(-1); // add face delimiter.
                // prepare values for next triangle
                if (odd_tri) {
                    coord_num0 = coord_num2;
                    coord_num2++;
                } else {
                    coord_num1 = coord_num2;
                    coord_num2 = coord_num1 + 1;
                }

                odd_tri = !odd_tri;
                coord_num_sb = coord_num2; // that index will be start of next strip
            } // for(int32_t vc = 2; vc < *vc_it; vc++)
        } // for(std::list<int32_t>::const_iterator vc_it = ne_alias.VertexCount.begin(); vc_it != ne_alias.VertexCount.end(); vc_it++)
        // check for child nodes
        if (!isNodeEmpty(node)) {
            ParseHelper_Node_Enter(ne);
            for (auto currentChildNode : node.children()) {
                const std::string &currentChildName = currentChildNode.name();
                // check for X3DComposedGeometryNodes
                if (currentChildName == "Color")
                    readColor(currentChildNode);
                else if (currentChildName == "ColorRGBA")
                    readColorRGBA(currentChildNode);
                else if (currentChildName == "Coordinate")
                    readCoordinate(currentChildNode);
                else if (currentChildName == "Normal")
                    readNormal(currentChildNode);
                else if (currentChildName == "TextureCoordinate")
                    readTextureCoordinate(currentChildNode);
                // check for X3DMetadataObject
                else if (!checkForMetadataNode(currentChildNode))
                    skipUnsupportedNode("TriangleStripSet", currentChildNode);
            }
            ParseHelper_Node_Exit();
        } // if(!isNodeEmpty(node))
        else {
            mNodeElementCur->Children.push_back(ne); // add made object as child to current element
        }

        NodeElement_List.push_back(ne); // add element to node element list because its a new object in graph
    } // if(!use.empty()) else
}

// <Normal
// DEF=""      ID
// USE=""      IDREF
// vector=""   MFVec3f [inputOutput]
// />
void X3DImporter::readNormal(XmlNode &node) {
    std::string use, def;
    std::list<aiVector3D> vector;
    X3DNodeElementBase *ne=nullptr;

    MACRO_ATTRREAD_CHECKUSEDEF_RET(node, def, use);
    X3DXmlHelper::getVector3DListAttribute(node, "vector", vector);

    // if "USE" defined then find already defined element.
    if (!use.empty()) {
        ne = MACRO_USE_CHECKANDAPPLY(node, def, use, ENET_Normal, ne);
    } else {
        // create and if needed - define new geometry object.
        ne = new X3DNodeElementNormal(mNodeElementCur);
        if (!def.empty()) ne->ID = def;

        ((X3DNodeElementNormal *)ne)->Value = vector;
        // check for X3DMetadataObject childs.
        if (!isNodeEmpty(node))
            childrenReadMetadata(node, ne, "Normal");
        else
            mNodeElementCur->Children.push_back(ne); // add made object as child to current element

        NodeElement_List.push_back(ne); // add element to node element list because its a new object in graph
    } // if(!use.empty()) else
}

} // namespace Assimp

#endif // !ASSIMP_BUILD_NO_X3D_IMPORTER