KiCad PCB EDA Suite
Loading...
Searching...
No Matches
vrml2_base.cpp
Go to the documentation of this file.
1/*
2 * This program source code file is part of KiCad, a free EDA CAD application.
3 *
4 * Copyright (C) 2015-2016 Cirilo Bernardo <[email protected]>
5 * Copyright The KiCad Developers, see AUTHORS.txt for contributors.
6 *
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation; either version 2
10 * of the License, or (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program. If not, see <https://www.gnu.org/licenses/>.
19 */
20
21#include <iostream>
22#include <sstream>
23#include <utility>
24#include <wx/string.h>
25#include <wx/log.h>
26
27#include <wx_filename.h>
28
29#include "vrml2_base.h"
30#include "vrml2_transform.h"
31#include "vrml2_shape.h"
32#include "vrml2_appearance.h"
33#include "vrml2_material.h"
34#include "vrml2_faceset.h"
35#include "vrml2_lineset.h"
36#include "vrml2_pointset.h"
37#include "vrml2_coords.h"
38#include "vrml2_norms.h"
39#include "vrml2_color.h"
40#include "vrml2_box.h"
41#include "vrml2_switch.h"
42#include "vrml2_inline.h"
44
45
46SCENEGRAPH* LoadVRML( const wxString& aFileName, bool useInline, bool applyUnitConversion );
47
48
50{
51 m_useInline = false;
52 m_applyUnitConversion = true; // default to legacy behavior
54}
55
56
58{
59 std::map< std::string, SGNODE* >::iterator iS = m_inlineModels.begin();
60 std::map< std::string, SGNODE* >::iterator eS = m_inlineModels.end();
61
62 while( iS != eS )
63 {
64 SGNODE* np = iS->second;
65
66 // destroy any orphaned Inline{} node data
67 if( np && nullptr == S3D::GetSGNodeParent( np ) )
68 S3D::DestroyNode( np );
69
70 ++iS;
71 }
72
73 m_inlineModels.clear();
74}
75
76
77bool WRL2BASE::SetParent( WRL2NODE* aParent, bool /* doUnlink */ )
78{
79 wxCHECK_MSG( false, false, wxT( "Attempt to set parent on WRL2BASE node." ) );
80}
81
82
83void WRL2BASE::SetEnableInline( bool enable )
84{
85 m_useInline = enable;
86}
87
88
90{
92}
93
94
96{
98}
99
100
102{
103 return m_useInline;
104}
105
106
107SGNODE* WRL2BASE::GetInlineData( const std::string& aName )
108{
109 if( aName.empty() )
110 return nullptr;
111
112 std::map< std::string, SGNODE* >::iterator dp = m_inlineModels.find( aName );
113
114 if( dp != m_inlineModels.end() )
115 return dp->second;
116
117 wxString tname;
118
119 if( aName.compare( 0, 7, "file://" ) == 0 )
120 {
121 if( aName.length() <= 7 )
122 return nullptr;
123
124 tname = wxString::FromUTF8Unchecked( aName.substr( 7 ).c_str() );
125 }
126 else
127 {
128 tname = wxString::FromUTF8Unchecked( aName.c_str() );
129 }
130
131 wxFileName fn;
132 fn.Assign( tname );
133
134 if( fn.IsRelative() && !m_dir.empty() )
135 {
136 wxString fname = wxString::FromUTF8Unchecked( m_dir.c_str() );
137 fname.append( tname );
138 fn.Assign( fname );
139 }
140
141 if( !fn.Normalize( FN_NORMALIZE_FLAGS | wxPATH_NORM_ENV_VARS ) )
142 {
143 m_inlineModels.emplace( aName, nullptr );
144 return nullptr;
145 }
146
147 // Load the inline model with the same unit conversion setting as the parent.
148 // This ensures that submodels referenced via Inline{} nodes in PCBnew-exported VRML
149 // files (which have top-level scale and disabled unit conversion) are also loaded
150 // without unit conversion.
151 SCENEGRAPH* sp = LoadVRML( fn.GetFullPath(), false, m_applyUnitConversion );
152
153 if( nullptr == sp )
154 {
155 m_inlineModels.emplace( aName, nullptr );
156 return nullptr;
157 }
158
159 m_inlineModels.emplace( aName, (SGNODE*) sp );
160
161 return (SGNODE*)sp;
162}
163
164
165std::string WRL2BASE::GetName( void )
166{
167 wxCHECK_MSG( false, std::string( "" ), wxT( "Attempt to extract name from base node." ) );
168}
169
170
171bool WRL2BASE::SetName( const std::string& aName )
172{
173 wxCHECK_MSG( false, false, wxT( "Attempt to set name of base node." ) );
174}
175
176
178{
179 wxCHECK_MSG( proc.GetVRMLType() == WRLVERSION::VRML_V2, false,
180 wxT( "No open file or file is not a VRML2 file." ) );
181
182 WRL2NODE* node = nullptr;
183 m_dir = proc.GetParentDir();
184
185 while( ReadNode( proc, this, &node ) && !proc.eof() );
186
187 if( proc.eof() )
188 return true;
189
190 return false;
191}
192
193
195{
196 // the base node is never dangling
197 return false;
198}
199
200
201bool WRL2BASE::implementUse( WRLPROC& proc, WRL2NODE* aParent, WRL2NODE** aNode )
202{
203 if( nullptr != aNode )
204 *aNode = nullptr;
205
206 wxCHECK_MSG( aParent, false, wxT( "Invalid parent." ) );
207
208 std::string glob;
209
210 if( !proc.ReadName( glob ) )
211 {
212 wxLogTrace( traceVrmlPlugin, wxT( "%s:%s:%d\n"
213 "%s" ),
214 __FILE__, __FUNCTION__, __LINE__ , proc.GetError() );
215
216 return false;
217 }
218
219 WRL2NODE* ref = aParent->FindNode( glob, nullptr );
220
221 // return 'true' - the file may be defective but it may still be somewhat OK
222 if( nullptr == ref )
223 {
224 wxLogTrace( traceVrmlPlugin, wxT( "%s:%s:%d\n"
225 " * [INFO] node '%s' not found." ),
226 __FILE__, __FUNCTION__, __LINE__, glob );
227
228 return true;
229 }
230
231 if( !aParent->AddRefNode( ref ) )
232 {
233 wxLogTrace( traceVrmlPlugin,
234 wxT( "%s:%s:%d\n"
235 " * [INFO] failed to add node '%s' (%d) to parent of type %d" ),
236 __FILE__, __FUNCTION__, __LINE__, glob, ref->GetNodeType(),
237 aParent->GetNodeType() );
238
239 return false;
240 }
241
242 if( nullptr != aNode )
243 *aNode = ref;
244
245 return true;
246}
247
248
249bool WRL2BASE::implementDef( WRLPROC& proc, WRL2NODE* aParent, WRL2NODE** aNode )
250{
251 if( nullptr != aNode )
252 *aNode = nullptr;
253
254 wxCHECK_MSG( aParent, false, wxT( "Invalid parent." ) );
255
256 std::string glob;
257 WRL2NODE* lnode = nullptr;
258
259 if( !proc.ReadName( glob ) )
260 {
261 wxLogTrace( traceVrmlPlugin, wxT( "%s:%s:%d\n"
262 "%s" ),
263 __FILE__, __FUNCTION__, __LINE__ , proc.GetError() );
264
265 return false;
266 }
267
268 if( ReadNode( proc, aParent, &lnode ) )
269 {
270 if( nullptr != aNode )
271 *aNode = lnode;
272
273 if( lnode && !lnode->SetName( glob ) )
274 {
275 wxLogTrace( traceVrmlPlugin,
276 wxT( "%s:%s:%d\n"
277 " * [INFO] bad formatting (invalid name) %s." ),
278 __FILE__, __FUNCTION__, __LINE__, proc.GetFilePosition() );
279
280 return false;
281 }
282
283 return true;
284 }
285
286 return false;
287}
288
289
290bool WRL2BASE::ReadNode( WRLPROC& proc, WRL2NODE* aParent, WRL2NODE** aNode )
291{
292 // This function reads a node and stores a pointer to it in aNode.
293 // A value 'true' is returned if a node is successfully read or,
294 // if the node is not supported, successfully discarded. Callers
295 // must always check the value of aNode when the function returns
296 // 'true' since it will be NULL if the node type is not supported.
297
298 if( nullptr != aNode )
299 *aNode = nullptr;
300
301 wxCHECK_MSG( aParent, false, wxT( "Invalid parent." ) );
302
303 std::string glob;
304 WRL2NODES ntype;
305
306 if( !proc.ReadName( glob ) )
307 {
308 wxLogTrace( traceVrmlPlugin, wxT( "%s:%s:%d\n"
309 "%s" ),
310 __FILE__, __FUNCTION__, __LINE__ , proc.GetError() );
311
312 return false;
313 }
314
315 // Process node name:
316 // the names encountered at this point should be one of the
317 // built-in node names or one of:
318 // DEF, USE
319 // PROTO, EXTERNPROTO
320 // ROUTE
321 // any PROTO or EXTERNPROTO defined name
322 // since we do not support PROTO or EXTERNPROTO, any unmatched names are
323 // assumed to be defined via PROTO/EXTERNPROTO and deleted according to
324 // a typical pattern.
325
326 if( !glob.compare( "USE" ) )
327 {
328 if( !implementUse( proc, aParent, aNode ) )
329 {
330 wxLogTrace( traceVrmlPlugin, wxT( "%s:%s:%d\n"
331 "%s" ),
332 __FILE__, __FUNCTION__, __LINE__ , proc.GetError() );
333
334 return false;
335 }
336
337 return true;
338 }
339
340 if( !glob.compare( "DEF" ) )
341 {
342 if( !implementDef( proc, aParent, aNode ) )
343 {
344 wxLogTrace( traceVrmlPlugin, wxT( "%s:%s:%d\n"
345 "%s" ),
346 __FILE__, __FUNCTION__, __LINE__ , proc.GetError() );
347
348 return false;
349 }
350
351 return true;
352 }
353
354 // pattern to skip: PROTO name list
355 if( !glob.compare( "PROTO" ) )
356 {
357 if( !proc.ReadName( glob ) || !proc.DiscardList() )
358 {
359 wxLogTrace( traceVrmlPlugin, wxT( "%s:%s:%d\n"
360 "%s" ),
361 __FILE__, __FUNCTION__, __LINE__ , proc.GetError() );
362
363 return false;
364 }
365
366 return true;
367 }
368
369 // pattern to skip: EXTERNPROTO name1 name2 list
370 if( !glob.compare( "EXTERNPROTO" ) )
371 {
372 if( !proc.ReadName( glob ) || !proc.ReadName( glob ) || !proc.DiscardList() )
373 {
374 wxLogTrace( traceVrmlPlugin, wxT( "%s:%s:%d\n"
375 "%s" ),
376 __FILE__, __FUNCTION__, __LINE__ , proc.GetError() );
377
378 return false;
379 }
380
381 return true;
382 }
383
384 // pattern to skip: ROUTE glob1 glob2 glob3
385 if( !glob.compare( "ROUTE" ) )
386 {
387 if( !proc.ReadGlob( glob ) || !proc.ReadGlob( glob ) || !proc.ReadGlob( glob ) )
388 {
389 wxLogTrace( traceVrmlPlugin, wxT( "%s:%s:%d\n"
390 "%s" ),
391 __FILE__, __FUNCTION__, __LINE__ , proc.GetError() );
392
393 return false;
394 }
395
396 return true;
397 }
398
399 ntype = getNodeTypeID( glob );
400
401 wxLogTrace( traceVrmlPlugin, wxT( " * [INFO] Processing node '%s' ID: %d" ), glob, ntype );
402
403 switch( ntype )
404 {
405 //
406 // items to be implemented:
407 //
409
410 if( !readAppearance( proc, aParent, aNode ) )
411 return false;
412
413 break;
414
416
417 if( !readBox( proc, aParent, aNode ) )
418 return false;
419
420 break;
421
423
424 if( !readColor( proc, aParent, aNode ) )
425 return false;
426
427 break;
428
430 // XXX - IMPLEMENT
431 if( !proc.DiscardNode() )
432 {
433 wxLogTrace( traceVrmlPlugin, wxT( " * [INFO] failed to discard %s node %s." ),
434 glob, proc.GetFilePosition() );
435
436 return false;
437 }
438 else
439 {
440 wxLogTrace( traceVrmlPlugin, wxT( " * [INFO] discarded %s node %s." ),
441 glob, proc.GetFilePosition() );
442 }
443
444 break;
445
447
448 if( !readCoords( proc, aParent, aNode ) )
449 return false;
450
451 break;
452
454 // XXX - IMPLEMENT
455 if( !proc.DiscardNode() )
456 {
457 wxLogTrace( traceVrmlPlugin, wxT( " * [INFO] failed to discard %s node %s." ),
458 glob, proc.GetFilePosition() );
459
460 return false;
461 }
462 else
463 {
464 wxLogTrace( traceVrmlPlugin, wxT( " * [INFO] discarded %s node %s." ),
465 glob, proc.GetFilePosition() );
466 }
467
468 break;
469
471 // XXX - IMPLEMENT
472 if( !proc.DiscardNode() )
473 {
474 wxLogTrace( traceVrmlPlugin, wxT( " * [INFO] failed to discard %s node %s." ),
475 glob, proc.GetFilePosition() );
476
477 return false;
478 }
479 else
480 {
481 wxLogTrace( traceVrmlPlugin, wxT( " * [INFO] discarded %s node %s." ),
482 glob, proc.GetFilePosition() );
483 }
484
485 break;
486
488 // XXX - IMPLEMENT
489 if( !proc.DiscardNode() )
490 {
491 wxLogTrace( traceVrmlPlugin, wxT( " * [INFO] failed to discard %s node %s." ),
492 glob, proc.GetFilePosition() );
493
494 return false;
495 }
496 else
497 {
498 wxLogTrace( traceVrmlPlugin, wxT( " * [INFO] discarded %s node %s." ),
499 glob, proc.GetFilePosition() );
500 }
501
502 break;
503
505
506 if( !readFaceSet( proc, aParent, aNode ) )
507 return false;
508
509 break;
510
512
513 if( !readLineSet( proc, aParent, aNode ) )
514 return false;
515
516 break;
517
519
520 if( !readPointSet( proc, aParent, aNode ) )
521 return false;
522
523 break;
524
526
527 if( !readMaterial( proc, aParent, aNode ) )
528 return false;
529
530 break;
531
533
534 if( !readNorms( proc, aParent, aNode ) )
535 return false;
536
537 break;
538
540
541 if( !readShape( proc, aParent, aNode ) )
542 return false;
543
544 break;
545
547 // XXX - IMPLEMENT
548 if( !proc.DiscardNode() )
549 {
550 wxLogTrace( traceVrmlPlugin, wxT( " * [INFO] failed to discard %s node %s." ),
551 glob, proc.GetFilePosition() );
552
553 return false;
554 }
555 else
556 {
557 wxLogTrace( traceVrmlPlugin, wxT( " * [INFO] discarded %s node %s." ),
558 glob, proc.GetFilePosition() );
559 }
560
561 break;
562
564
565 if( !readSwitch( proc, aParent, aNode ) )
566 return false;
567
568 break;
569
572
573 if( !readTransform( proc, aParent, aNode ) )
574 return false;
575
576 break;
577
579
580 if( !readInline( proc, aParent, aNode ) )
581 return false;
582
583 break;
584
585 //
586 // items not implemented or for optional future implementation:
587 //
624 default:
625
626 if( !proc.DiscardNode() )
627 {
628 wxLogTrace( traceVrmlPlugin, wxT( " * [INFO] failed to discard %s node %s." ),
629 glob, proc.GetFilePosition() );
630
631 return false;
632 }
633 else
634 {
635 wxLogTrace( traceVrmlPlugin, wxT( " * [INFO] discarded %s node %s." ),
636 glob, proc.GetFilePosition() );
637 }
638
639 break;
640 }
641
642 return true;
643}
644
645
646bool WRL2BASE::Read( WRLPROC& proc, WRL2BASE* aTopNode )
647{
648 wxCHECK_MSG( false, false, wxT( "This method must never be invoked on a WRL2BASE object." ) );
649}
650
651
652bool WRL2BASE::readTransform( WRLPROC& proc, WRL2NODE* aParent, WRL2NODE** aNode )
653{
654 if( nullptr != aNode )
655 *aNode = nullptr;
656
657 WRL2TRANSFORM* np = new WRL2TRANSFORM( aParent );
658
659 if( !np->Read( proc, this ) )
660 {
661 delete np;
662 return false;
663 }
664
665 if( nullptr != aNode )
666 *aNode = (WRL2NODE*) np;
667
668 return true;
669}
670
671
672bool WRL2BASE::readShape( WRLPROC& proc, WRL2NODE* aParent, WRL2NODE** aNode )
673{
674 if( nullptr != aNode )
675 *aNode = nullptr;
676
677 WRL2SHAPE* np = new WRL2SHAPE( aParent );
678
679 if( !np->Read( proc, this ) )
680 {
681 delete np;
682 return false;
683 }
684
685 if( nullptr != aNode )
686 *aNode = (WRL2NODE*) np;
687
688 return true;
689}
690
691
692bool WRL2BASE::readAppearance( WRLPROC& proc, WRL2NODE* aParent, WRL2NODE** aNode )
693{
694 if( nullptr != aNode )
695 *aNode = nullptr;
696
697 WRL2APPEARANCE* np = new WRL2APPEARANCE( aParent );
698
699 if( !np->Read( proc, this ) )
700 {
701 delete np;
702 return false;
703 }
704
705 if( nullptr != aNode )
706 *aNode = (WRL2NODE*) np;
707
708 return true;
709}
710
711
712bool WRL2BASE::readMaterial( WRLPROC& proc, WRL2NODE* aParent, WRL2NODE** aNode )
713{
714 if( nullptr != aNode )
715 *aNode = nullptr;
716
717 WRL2MATERIAL* np = new WRL2MATERIAL( aParent );
718
719 if( !np->Read( proc, this ) )
720 {
721 delete np;
722 return false;
723 }
724
725 if( nullptr != aNode )
726 *aNode = (WRL2NODE*) np;
727
728 return true;
729}
730
731
732bool WRL2BASE::readFaceSet( WRLPROC& proc, WRL2NODE* aParent, WRL2NODE** aNode )
733{
734 if( nullptr != aNode )
735 *aNode = nullptr;
736
737 WRL2FACESET* np = new WRL2FACESET( aParent );
738
739 if( !np->Read( proc, this ) )
740 {
741 delete np;
742 return false;
743 }
744
745 if( nullptr != aNode )
746 *aNode = (WRL2NODE*) np;
747
748 return true;
749}
750
751
752bool WRL2BASE::readLineSet( WRLPROC& proc, WRL2NODE* aParent, WRL2NODE** aNode )
753{
754 if( nullptr != aNode )
755 *aNode = nullptr;
756
757 WRL2LINESET* np = new WRL2LINESET( aParent );
758
759 if( !np->Read( proc, this ) )
760 {
761 delete np;
762 return false;
763 }
764
765 if( nullptr != aNode )
766 *aNode = (WRL2NODE*) np;
767
768 return true;
769}
770
771
772bool WRL2BASE::readPointSet( WRLPROC& proc, WRL2NODE* aParent, WRL2NODE** aNode )
773{
774 if( nullptr != aNode )
775 *aNode = nullptr;
776
777 WRL2POINTSET* np = new WRL2POINTSET( aParent );
778
779 if( !np->Read( proc, this ) )
780 {
781 delete np;
782 return false;
783 }
784
785 if( nullptr != aNode )
786 *aNode = (WRL2NODE*) np;
787
788 return true;
789}
790
791
792bool WRL2BASE::readCoords( WRLPROC& proc, WRL2NODE* aParent, WRL2NODE** aNode )
793{
794 if( nullptr != aNode )
795 *aNode = nullptr;
796
797 WRL2COORDS* np = new WRL2COORDS( aParent );
798
799 if( !np->Read( proc, this ) )
800 {
801 delete np;
802 return false;
803 }
804
805 if( nullptr != aNode )
806 *aNode = (WRL2NODE*) np;
807
808 return true;
809}
810
811
812bool WRL2BASE::readNorms( WRLPROC& proc, WRL2NODE* aParent, WRL2NODE** aNode )
813{
814 if( nullptr != aNode )
815 *aNode = nullptr;
816
817 WRL2NORMS* np = new WRL2NORMS( aParent );
818
819 if( !np->Read( proc, this ) )
820 {
821 delete np;
822 return false;
823 }
824
825 if( nullptr != aNode )
826 *aNode = (WRL2NODE*) np;
827
828 return true;
829}
830
831
832bool WRL2BASE::readColor( WRLPROC& proc, WRL2NODE* aParent, WRL2NODE** aNode )
833{
834 if( nullptr != aNode )
835 *aNode = nullptr;
836
837 WRL2COLOR* np = new WRL2COLOR( aParent );
838
839 if( !np->Read( proc, this ) )
840 {
841 delete np;
842 return false;
843 }
844
845 if( nullptr != aNode )
846 *aNode = (WRL2NODE*) np;
847
848 return true;
849}
850
851
852bool WRL2BASE::readBox( WRLPROC& proc, WRL2NODE* aParent, WRL2NODE** aNode )
853{
854 if( nullptr != aNode )
855 *aNode = nullptr;
856
857 WRL2BOX* np = new WRL2BOX( aParent );
858
859 if( !np->Read( proc, this ) )
860 {
861 delete np;
862 return false;
863 }
864
865 if( nullptr != aNode )
866 *aNode = (WRL2NODE*) np;
867
868 return true;
869}
870
871
872bool WRL2BASE::readSwitch( WRLPROC& proc, WRL2NODE* aParent, WRL2NODE** aNode )
873{
874 if( nullptr != aNode )
875 *aNode = nullptr;
876
877 WRL2SWITCH* np = new WRL2SWITCH( aParent );
878
879 if( !np->Read( proc, this ) )
880 {
881 delete np;
882 return false;
883 }
884
885 if( nullptr != aNode )
886 *aNode = (WRL2NODE*) np;
887
888 return true;
889}
890
891
892bool WRL2BASE::readInline( WRLPROC& proc, WRL2NODE* aParent, WRL2NODE** aNode )
893{
894 if( nullptr != aNode )
895 *aNode = nullptr;
896
897 if( !m_useInline )
898 {
899 if( !proc.DiscardNode() )
900 {
901 wxLogTrace( traceVrmlPlugin, wxT( " * [INFO] failed to discard in line node %s." ),
902 proc.GetFilePosition() );
903
904 return false;
905 }
906
907 return true;
908 }
909
910 WRL2INLINE* np = new WRL2INLINE( aParent );
911
912 if( !np->Read( proc, this ) )
913 {
914 delete np;
915 return false;
916 }
917
918 if( nullptr != aNode )
919 *aNode = (WRL2NODE*) np;
920
921 return true;
922}
923
924
926{
927 if( m_Children.empty() )
928 return nullptr;
929
930 if( m_sgNode )
931 {
932 if( nullptr != aParent )
933 {
934 if( nullptr == S3D::GetSGNodeParent( m_sgNode )
935 && !S3D::AddSGNodeChild( aParent, m_sgNode ) )
936 {
937 return nullptr;
938 }
939 else if( aParent != S3D::GetSGNodeParent( m_sgNode )
940 && !S3D::AddSGNodeRef( aParent, m_sgNode ) )
941 {
942 return nullptr;
943 }
944 }
945
946 return m_sgNode;
947 }
948
949 IFSG_TRANSFORM topNode( aParent );
950
951 std::list< WRL2NODE* >::iterator sC = m_Children.begin();
952 std::list< WRL2NODE* >::iterator eC = m_Children.end();
953 WRL2NODES type;
954
955 // Include only Shape and Transform nodes in the top node
956 bool test = false; // set to true if there are any subnodes for display
957
958 while( sC != eC )
959 {
960 type = (*sC)->GetNodeType();
961
962 switch( type )
963 {
965 // wrap the shape in a transform
966 do
967 {
968 IFSG_TRANSFORM wrapper( topNode.GetRawPtr() );
969 SGNODE* pshape = (*sC)->TranslateToSG( wrapper.GetRawPtr() );
970
971 if( nullptr != pshape )
972 test = true;
973 else
974 wrapper.Destroy();
975
976 } while( 0 );
977
978 break;
979
983
984 if( nullptr != (*sC)->TranslateToSG( topNode.GetRawPtr() ) )
985 test = true;
986
987 break;
988
989 default:
990 break;
991 }
992
993 ++ sC;
994 }
995
996 if( false == test )
997 {
998 topNode.Destroy();
999 return nullptr;
1000 }
1001
1002 m_sgNode = topNode.GetRawPtr();
1003
1004 return m_sgNode;
1005}
SGNODE * GetRawPtr(void) noexcept
Return the raw internal SGNODE pointer.
Definition ifsg_node.cpp:61
void Destroy(void)
Delete the object held by this wrapper.
Definition ifsg_node.cpp:51
The wrapper for the VRML compatible TRANSFORM block class SCENEGRAPH.
Define the basic data set required to represent a 3D model.
Definition scenegraph.h:41
The base class of all Scene Graph nodes.
Definition sg_node.h:71
bool Read(WRLPROC &proc, WRL2BASE *aTopNode) override
bool readMaterial(WRLPROC &proc, WRL2NODE *aParent, WRL2NODE **aNode)
std::map< std::string, SGNODE * > m_inlineModels
Definition vrml2_base.h:111
bool m_useInline
Definition vrml2_base.h:108
virtual bool SetName(const std::string &aName) override
void SetEnableInline(bool enable)
bool readTransform(WRLPROC &proc, WRL2NODE *aParent, WRL2NODE **aNode)
bool GetEnableInline(void)
bool readLineSet(WRLPROC &proc, WRL2NODE *aParent, WRL2NODE **aNode)
bool readShape(WRLPROC &proc, WRL2NODE *aParent, WRL2NODE **aNode)
bool implementDef(WRLPROC &proc, WRL2NODE *aParent, WRL2NODE **aNode)
bool readPointSet(WRLPROC &proc, WRL2NODE *aParent, WRL2NODE **aNode)
bool readInline(WRLPROC &proc, WRL2NODE *aParent, WRL2NODE **aNode)
SGNODE * GetInlineData(const std::string &aName)
bool ReadNode(WRLPROC &proc, WRL2NODE *aParent, WRL2NODE **aNode)
bool m_applyUnitConversion
Definition vrml2_base.h:109
bool implementUse(WRLPROC &proc, WRL2NODE *aParent, WRL2NODE **aNode)
bool readColor(WRLPROC &proc, WRL2NODE *aParent, WRL2NODE **aNode)
bool SetParent(WRL2NODE *aParent, bool doUnlink=true) override
Set the parent WRL2NODE of this object.
virtual std::string GetName(void) override
virtual ~WRL2BASE()
void SetApplyUnitConversion(bool apply)
bool readBox(WRLPROC &proc, WRL2NODE *aParent, WRL2NODE **aNode)
bool readAppearance(WRLPROC &proc, WRL2NODE *aParent, WRL2NODE **aNode)
bool GetApplyUnitConversion(void) const
bool readNorms(WRLPROC &proc, WRL2NODE *aParent, WRL2NODE **aNode)
bool readSwitch(WRLPROC &proc, WRL2NODE *aParent, WRL2NODE **aNode)
bool readCoords(WRLPROC &proc, WRL2NODE *aParent, WRL2NODE **aNode)
bool Read(WRLPROC &proc)
SGNODE * TranslateToSG(SGNODE *aParent) override
Produce a representation of the data using the intermediate scenegraph structures of the kicad_3dsg l...
bool isDangling(void) override
Determine whether an object should be moved to a different parent during the VRML to SG* translation.
std::string m_dir
Definition vrml2_base.h:110
bool readFaceSet(WRLPROC &proc, WRL2NODE *aParent, WRL2NODE **aNode)
bool Read(WRLPROC &proc, WRL2BASE *aTopNode) override
Definition vrml2_box.cpp:70
bool Read(WRLPROC &proc, WRL2BASE *aTopNode) override
bool Read(WRLPROC &proc, WRL2BASE *aTopNode) override
bool Read(WRLPROC &proc, WRL2BASE *aTopNode) override
bool Read(WRLPROC &proc, WRL2BASE *aTopNode) override
bool Read(WRLPROC &proc, WRL2BASE *aTopNode) override
bool Read(WRLPROC &proc, WRL2BASE *aTopNode) override
virtual bool SetName(const std::string &aName)
SGNODE * m_sgNode
Definition vrml2_node.h:174
WRL2NODES getNodeTypeID(const std::string &aNodeName)
std::list< WRL2NODE * > m_Children
Definition vrml2_node.h:170
virtual WRL2NODE * FindNode(const std::string &aNodeName, const WRL2NODE *aCaller)
Search the tree of linked nodes and returns a reference to the first node found with the given name.
WRL2NODES m_Type
Definition vrml2_node.h:166
virtual bool AddRefNode(WRL2NODE *aNode)
WRL2NODES GetNodeType(void) const
bool Read(WRLPROC &proc, WRL2BASE *aTopNode) override
bool Read(WRLPROC &proc, WRL2BASE *aTopNode) override
bool Read(WRLPROC &proc, WRL2BASE *aTopNode) override
bool Read(WRLPROC &proc, WRL2BASE *aTopNode) override
bool Read(WRLPROC &proc, WRL2BASE *aTopNode) override
bool DiscardList(void)
Definition wrlproc.cpp:487
bool ReadGlob(std::string &aGlob)
Definition wrlproc.cpp:241
WRLVERSION GetVRMLType(void)
Definition wrlproc.cpp:226
const char * GetParentDir(void)
Definition wrlproc.cpp:232
std::string GetError(void)
Definition wrlproc.cpp:1956
bool eof(void)
Definition wrlproc.cpp:1950
bool ReadName(std::string &aName)
Definition wrlproc.cpp:285
std::string GetFilePosition() const
Definition wrlproc.cpp:1978
bool DiscardNode(void)
Definition wrlproc.cpp:364
const wxChar *const traceVrmlPlugin
Flag to enable VRML plugin trace output.
Definition vrml.cpp:59
collects header files for all SG* wrappers and the API
SGLIB_API SGNODE * GetSGNodeParent(SGNODE *aNode)
Definition ifsg_api.cpp:490
SGLIB_API void DestroyNode(SGNODE *aNode) noexcept
Delete the given SG* class node.
Definition ifsg_api.cpp:145
SGLIB_API bool AddSGNodeChild(SGNODE *aParent, SGNODE *aChild)
Definition ifsg_api.cpp:508
SGLIB_API bool AddSGNodeRef(SGNODE *aParent, SGNODE *aChild)
Definition ifsg_api.cpp:499
SCENEGRAPH * LoadVRML(const wxString &aFileName, bool useInline, bool applyUnitConversion)
Definition vrml.cpp:166
WRL2NODES
Definition wrltypes.h:121
@ WRL2_CYLINDERSENSOR
Definition wrltypes.h:137
@ WRL2_TRANSFORM
Definition wrltypes.h:174
@ WRL2_POSITIONINTERPOLATOR
Definition wrltypes.h:159
@ WRL2_SPOTLIGHT
Definition wrltypes.h:167
@ WRL2_SCALARINTERPOLATOR
Definition wrltypes.h:161
@ WRL2_ORIENTATIONINTERPOLATOR
Definition wrltypes.h:154
@ WRL2_COLLISION
Definition wrltypes.h:130
@ WRL2_SPHERESENSOR
Definition wrltypes.h:166
@ WRL2_NAVIGATIONINFO
Definition wrltypes.h:151
@ WRL2_INDEXEDFACESET
Definition wrltypes.h:145
@ WRL2_INDEXEDLINESET
Definition wrltypes.h:146
@ WRL2_PLANESENSOR
Definition wrltypes.h:156
@ WRL2_INLINE
Definition wrltypes.h:147
@ WRL2_TOUCHSENSOR
Definition wrltypes.h:173
@ WRL2_MOVIETEXTURE
Definition wrltypes.h:150
@ WRL2_TIMESENSOR
Definition wrltypes.h:172
@ WRL2_DIRECTIONALLIGHT
Definition wrltypes.h:138
@ WRL2_BACKGROUND
Definition wrltypes.h:127
@ WRL2_COLORINTERPOLATOR
Definition wrltypes.h:132
@ WRL2_POINTLIGHT
Definition wrltypes.h:157
@ WRL2_PROXIMITYSENSOR
Definition wrltypes.h:160
@ WRL2_ELEVATIONGRID
Definition wrltypes.h:139
@ WRL2_TEXTURETRANSFORM
Definition wrltypes.h:171
@ WRL2_AUDIOCLIP
Definition wrltypes.h:126
@ WRL2_PIXELTEXTURE
Definition wrltypes.h:155
@ WRL2_BILLBOARD
Definition wrltypes.h:128
@ WRL2_COORDINATE
Definition wrltypes.h:134
@ WRL2_WORLDINFO
Definition wrltypes.h:177
@ WRL2_NORMALINTERPOLATOR
Definition wrltypes.h:153
@ WRL2_MATERIAL
Definition wrltypes.h:149
@ WRL2_NORMAL
Definition wrltypes.h:152
@ WRL2_COORDINATEINTERPOLATOR
Definition wrltypes.h:135
@ WRL2_FONTSTYLE
Definition wrltypes.h:142
@ WRL2_SWITCH
Definition wrltypes.h:168
@ WRL2_VIEWPOINT
Definition wrltypes.h:175
@ WRL2_IMAGETEXTURE
Definition wrltypes.h:144
@ WRL2_CYLINDER
Definition wrltypes.h:136
@ WRL2_SCRIPT
Definition wrltypes.h:162
@ WRL2_EXTRUSION
Definition wrltypes.h:140
@ WRL2_VISIBILITYSENSOR
Definition wrltypes.h:176
@ WRL2_INVALID
Definition wrltypes.h:178
@ WRL2_POINTSET
Definition wrltypes.h:158
@ WRL2_SPHERE
Definition wrltypes.h:165
@ WRL2_ANCHOR
Definition wrltypes.h:124
@ WRL2_APPEARANCE
Definition wrltypes.h:125
@ WRL2_TEXTURECOORDINATE
Definition wrltypes.h:170
#define FN_NORMALIZE_FLAGS
Default flags to pass to wxFileName::Normalize().
Definition wx_filename.h:35