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#include "../loadmodel.h"
45
46
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 m_options = aOptions;
104 m_status = aStatus;
105}
106
107
109{
110 return m_useInline;
111}
112
113
114SGNODE* WRL2BASE::GetInlineData( const std::string& aName )
115{
116 if( aName.empty() )
117 return nullptr;
118
119 std::map< std::string, SGNODE* >::iterator dp = m_inlineModels.find( aName );
120
121 if( dp != m_inlineModels.end() )
122 return dp->second;
123
124 wxString tname;
125
126 if( aName.compare( 0, 7, "file://" ) == 0 )
127 {
128 if( aName.length() <= 7 )
129 return nullptr;
130
131 tname = wxString::FromUTF8Unchecked( aName.substr( 7 ).c_str() );
132 }
133 else
134 {
135 tname = wxString::FromUTF8Unchecked( aName.c_str() );
136 }
137
138 wxFileName fn;
139 fn.Assign( tname );
140
141 if( fn.IsRelative() && !m_dir.empty() )
142 {
143 wxString fname = wxString::FromUTF8Unchecked( m_dir.c_str() );
144 fname.append( tname );
145 fn.Assign( fname );
146 }
147
148 if( !fn.Normalize( FN_NORMALIZE_FLAGS | wxPATH_NORM_ENV_VARS ) )
149 {
150 m_inlineModels.emplace( aName, nullptr );
151 return nullptr;
152 }
153
154 // Load the inline model with the same unit conversion setting as the parent.
155 // This ensures that submodels referenced via Inline{} nodes in PCBnew-exported VRML
156 // files (which have top-level scale and disabled unit conversion) are also loaded
157 // without unit conversion.
158 S3D::MODEL_IMPORT_OPTIONS inlineOptions = m_options;
160 inlineOptions.vrmlEnableInline = m_useInline;
161
162 SCENEGRAPH* sp = LoadVRML( fn.GetFullPath(), inlineOptions, m_status );
163
164 if( nullptr == sp )
165 {
166 m_incompleteInline = true;
167 m_inlineModels.emplace( aName, nullptr );
168 return nullptr;
169 }
170
171 m_inlineModels.emplace( aName, (SGNODE*) sp );
172
173 return (SGNODE*)sp;
174}
175
176
177std::string WRL2BASE::GetName( void )
178{
179 wxCHECK_MSG( false, std::string( "" ), wxT( "Attempt to extract name from base node." ) );
180}
181
182
183bool WRL2BASE::SetName( const std::string& aName )
184{
185 wxCHECK_MSG( false, false, wxT( "Attempt to set name of base node." ) );
186}
187
188
190{
191 wxCHECK_MSG( proc.GetVRMLType() == WRLVERSION::VRML_V2, false,
192 wxT( "No open file or file is not a VRML2 file." ) );
193
194 WRL2NODE* node = nullptr;
195 m_dir = proc.GetParentDir();
196
197 while( ReadNode( proc, this, &node ) && !proc.eof() );
198
199 if( proc.eof() )
200 return true;
201
202 return false;
203}
204
205
207{
208 // the base node is never dangling
209 return false;
210}
211
212
213bool WRL2BASE::implementUse( WRLPROC& proc, WRL2NODE* aParent, WRL2NODE** aNode )
214{
215 if( nullptr != aNode )
216 *aNode = nullptr;
217
218 wxCHECK_MSG( aParent, false, wxT( "Invalid parent." ) );
219
220 std::string glob;
221
222 if( !proc.ReadName( glob ) )
223 {
224 wxLogTrace( traceVrmlPlugin, wxT( "%s:%s:%d\n"
225 "%s" ),
226 __FILE__, __FUNCTION__, __LINE__ , proc.GetError() );
227
228 return false;
229 }
230
231 WRL2NODE* ref = aParent->FindNode( glob, nullptr );
232
233 // return 'true' - the file may be defective but it may still be somewhat OK
234 if( nullptr == ref )
235 {
236 wxLogTrace( traceVrmlPlugin, wxT( "%s:%s:%d\n"
237 " * [INFO] node '%s' not found." ),
238 __FILE__, __FUNCTION__, __LINE__, glob );
239
240 return true;
241 }
242
243 if( !aParent->AddRefNode( ref ) )
244 {
245 wxLogTrace( traceVrmlPlugin,
246 wxT( "%s:%s:%d\n"
247 " * [INFO] failed to add node '%s' (%d) to parent of type %d" ),
248 __FILE__, __FUNCTION__, __LINE__, glob, ref->GetNodeType(),
249 aParent->GetNodeType() );
250
251 return false;
252 }
253
254 if( nullptr != aNode )
255 *aNode = ref;
256
257 return true;
258}
259
260
261bool WRL2BASE::implementDef( WRLPROC& proc, WRL2NODE* aParent, WRL2NODE** aNode )
262{
263 if( nullptr != aNode )
264 *aNode = nullptr;
265
266 wxCHECK_MSG( aParent, false, wxT( "Invalid parent." ) );
267
268 std::string glob;
269 WRL2NODE* lnode = nullptr;
270
271 if( !proc.ReadName( glob ) )
272 {
273 wxLogTrace( traceVrmlPlugin, wxT( "%s:%s:%d\n"
274 "%s" ),
275 __FILE__, __FUNCTION__, __LINE__ , proc.GetError() );
276
277 return false;
278 }
279
280 if( ReadNode( proc, aParent, &lnode ) )
281 {
282 if( nullptr != aNode )
283 *aNode = lnode;
284
285 if( lnode && !lnode->SetName( glob ) )
286 {
287 wxLogTrace( traceVrmlPlugin,
288 wxT( "%s:%s:%d\n"
289 " * [INFO] bad formatting (invalid name) %s." ),
290 __FILE__, __FUNCTION__, __LINE__, proc.GetFilePosition() );
291
292 return false;
293 }
294
295 return true;
296 }
297
298 return false;
299}
300
301
302bool WRL2BASE::ReadNode( WRLPROC& proc, WRL2NODE* aParent, WRL2NODE** aNode )
303{
304 // This function reads a node and stores a pointer to it in aNode.
305 // A value 'true' is returned if a node is successfully read or,
306 // if the node is not supported, successfully discarded. Callers
307 // must always check the value of aNode when the function returns
308 // 'true' since it will be NULL if the node type is not supported.
309
310 if( nullptr != aNode )
311 *aNode = nullptr;
312
313 wxCHECK_MSG( aParent, false, wxT( "Invalid parent." ) );
314
315 std::string glob;
316 WRL2NODES ntype;
317
318 if( !proc.ReadName( glob ) )
319 {
320 wxLogTrace( traceVrmlPlugin, wxT( "%s:%s:%d\n"
321 "%s" ),
322 __FILE__, __FUNCTION__, __LINE__ , proc.GetError() );
323
324 return false;
325 }
326
327 // Process node name:
328 // the names encountered at this point should be one of the
329 // built-in node names or one of:
330 // DEF, USE
331 // PROTO, EXTERNPROTO
332 // ROUTE
333 // any PROTO or EXTERNPROTO defined name
334 // since we do not support PROTO or EXTERNPROTO, any unmatched names are
335 // assumed to be defined via PROTO/EXTERNPROTO and deleted according to
336 // a typical pattern.
337
338 if( !glob.compare( "USE" ) )
339 {
340 if( !implementUse( proc, aParent, aNode ) )
341 {
342 wxLogTrace( traceVrmlPlugin, wxT( "%s:%s:%d\n"
343 "%s" ),
344 __FILE__, __FUNCTION__, __LINE__ , proc.GetError() );
345
346 return false;
347 }
348
349 return true;
350 }
351
352 if( !glob.compare( "DEF" ) )
353 {
354 if( !implementDef( proc, aParent, aNode ) )
355 {
356 wxLogTrace( traceVrmlPlugin, wxT( "%s:%s:%d\n"
357 "%s" ),
358 __FILE__, __FUNCTION__, __LINE__ , proc.GetError() );
359
360 return false;
361 }
362
363 return true;
364 }
365
366 // pattern to skip: PROTO name list
367 if( !glob.compare( "PROTO" ) )
368 {
369 if( !proc.ReadName( glob ) || !proc.DiscardList() )
370 {
371 wxLogTrace( traceVrmlPlugin, wxT( "%s:%s:%d\n"
372 "%s" ),
373 __FILE__, __FUNCTION__, __LINE__ , proc.GetError() );
374
375 return false;
376 }
377
378 return true;
379 }
380
381 // pattern to skip: EXTERNPROTO name1 name2 list
382 if( !glob.compare( "EXTERNPROTO" ) )
383 {
384 if( !proc.ReadName( glob ) || !proc.ReadName( glob ) || !proc.DiscardList() )
385 {
386 wxLogTrace( traceVrmlPlugin, wxT( "%s:%s:%d\n"
387 "%s" ),
388 __FILE__, __FUNCTION__, __LINE__ , proc.GetError() );
389
390 return false;
391 }
392
393 return true;
394 }
395
396 // pattern to skip: ROUTE glob1 glob2 glob3
397 if( !glob.compare( "ROUTE" ) )
398 {
399 if( !proc.ReadGlob( glob ) || !proc.ReadGlob( glob ) || !proc.ReadGlob( glob ) )
400 {
401 wxLogTrace( traceVrmlPlugin, wxT( "%s:%s:%d\n"
402 "%s" ),
403 __FILE__, __FUNCTION__, __LINE__ , proc.GetError() );
404
405 return false;
406 }
407
408 return true;
409 }
410
411 ntype = getNodeTypeID( glob );
412
413 wxLogTrace( traceVrmlPlugin, wxT( " * [INFO] Processing node '%s' ID: %d" ), glob, ntype );
414
415 switch( ntype )
416 {
417 //
418 // items to be implemented:
419 //
421
422 if( !readAppearance( proc, aParent, aNode ) )
423 return false;
424
425 break;
426
428
429 if( !readBox( proc, aParent, aNode ) )
430 return false;
431
432 break;
433
435
436 if( !readColor( proc, aParent, aNode ) )
437 return false;
438
439 break;
440
442 // XXX - IMPLEMENT
443 if( !proc.DiscardNode() )
444 {
445 wxLogTrace( traceVrmlPlugin, wxT( " * [INFO] failed to discard %s node %s." ),
446 glob, proc.GetFilePosition() );
447
448 return false;
449 }
450 else
451 {
452 wxLogTrace( traceVrmlPlugin, wxT( " * [INFO] discarded %s node %s." ),
453 glob, proc.GetFilePosition() );
454 }
455
456 break;
457
459
460 if( !readCoords( proc, aParent, aNode ) )
461 return false;
462
463 break;
464
466 // XXX - IMPLEMENT
467 if( !proc.DiscardNode() )
468 {
469 wxLogTrace( traceVrmlPlugin, wxT( " * [INFO] failed to discard %s node %s." ),
470 glob, proc.GetFilePosition() );
471
472 return false;
473 }
474 else
475 {
476 wxLogTrace( traceVrmlPlugin, wxT( " * [INFO] discarded %s node %s." ),
477 glob, proc.GetFilePosition() );
478 }
479
480 break;
481
483 // XXX - IMPLEMENT
484 if( !proc.DiscardNode() )
485 {
486 wxLogTrace( traceVrmlPlugin, wxT( " * [INFO] failed to discard %s node %s." ),
487 glob, proc.GetFilePosition() );
488
489 return false;
490 }
491 else
492 {
493 wxLogTrace( traceVrmlPlugin, wxT( " * [INFO] discarded %s node %s." ),
494 glob, proc.GetFilePosition() );
495 }
496
497 break;
498
500 // XXX - IMPLEMENT
501 if( !proc.DiscardNode() )
502 {
503 wxLogTrace( traceVrmlPlugin, wxT( " * [INFO] failed to discard %s node %s." ),
504 glob, proc.GetFilePosition() );
505
506 return false;
507 }
508 else
509 {
510 wxLogTrace( traceVrmlPlugin, wxT( " * [INFO] discarded %s node %s." ),
511 glob, proc.GetFilePosition() );
512 }
513
514 break;
515
517
518 if( !readFaceSet( proc, aParent, aNode ) )
519 return false;
520
521 break;
522
524
525 if( !readLineSet( proc, aParent, aNode ) )
526 return false;
527
528 break;
529
531
532 if( !readPointSet( proc, aParent, aNode ) )
533 return false;
534
535 break;
536
538
539 if( !readMaterial( proc, aParent, aNode ) )
540 return false;
541
542 break;
543
545
546 if( !readNorms( proc, aParent, aNode ) )
547 return false;
548
549 break;
550
552
553 if( !readShape( proc, aParent, aNode ) )
554 return false;
555
556 break;
557
559 // XXX - IMPLEMENT
560 if( !proc.DiscardNode() )
561 {
562 wxLogTrace( traceVrmlPlugin, wxT( " * [INFO] failed to discard %s node %s." ),
563 glob, proc.GetFilePosition() );
564
565 return false;
566 }
567 else
568 {
569 wxLogTrace( traceVrmlPlugin, wxT( " * [INFO] discarded %s node %s." ),
570 glob, proc.GetFilePosition() );
571 }
572
573 break;
574
576
577 if( !readSwitch( proc, aParent, aNode ) )
578 return false;
579
580 break;
581
584
585 if( !readTransform( proc, aParent, aNode ) )
586 return false;
587
588 break;
589
591
592 if( !readInline( proc, aParent, aNode ) )
593 return false;
594
595 break;
596
597 //
598 // items not implemented or for optional future implementation:
599 //
636 default:
637
638 if( !proc.DiscardNode() )
639 {
640 wxLogTrace( traceVrmlPlugin, wxT( " * [INFO] failed to discard %s node %s." ),
641 glob, proc.GetFilePosition() );
642
643 return false;
644 }
645 else
646 {
647 wxLogTrace( traceVrmlPlugin, wxT( " * [INFO] discarded %s node %s." ),
648 glob, proc.GetFilePosition() );
649 }
650
651 break;
652 }
653
654 return true;
655}
656
657
658bool WRL2BASE::Read( WRLPROC& proc, WRL2BASE* aTopNode )
659{
660 wxCHECK_MSG( false, false, wxT( "This method must never be invoked on a WRL2BASE object." ) );
661}
662
663
664bool WRL2BASE::readTransform( WRLPROC& proc, WRL2NODE* aParent, WRL2NODE** aNode )
665{
666 if( nullptr != aNode )
667 *aNode = nullptr;
668
669 WRL2TRANSFORM* np = new WRL2TRANSFORM( aParent );
670
671 if( !np->Read( proc, this ) )
672 {
673 delete np;
674 return false;
675 }
676
677 if( nullptr != aNode )
678 *aNode = (WRL2NODE*) np;
679
680 return true;
681}
682
683
684bool WRL2BASE::readShape( WRLPROC& proc, WRL2NODE* aParent, WRL2NODE** aNode )
685{
686 if( nullptr != aNode )
687 *aNode = nullptr;
688
689 WRL2SHAPE* np = new WRL2SHAPE( aParent );
690
691 if( !np->Read( proc, this ) )
692 {
693 delete np;
694 return false;
695 }
696
697 if( nullptr != aNode )
698 *aNode = (WRL2NODE*) np;
699
700 return true;
701}
702
703
704bool WRL2BASE::readAppearance( WRLPROC& proc, WRL2NODE* aParent, WRL2NODE** aNode )
705{
706 if( nullptr != aNode )
707 *aNode = nullptr;
708
709 WRL2APPEARANCE* np = new WRL2APPEARANCE( aParent );
710
711 if( !np->Read( proc, this ) )
712 {
713 delete np;
714 return false;
715 }
716
717 if( nullptr != aNode )
718 *aNode = (WRL2NODE*) np;
719
720 return true;
721}
722
723
724bool WRL2BASE::readMaterial( WRLPROC& proc, WRL2NODE* aParent, WRL2NODE** aNode )
725{
726 if( nullptr != aNode )
727 *aNode = nullptr;
728
729 WRL2MATERIAL* np = new WRL2MATERIAL( aParent );
730
731 if( !np->Read( proc, this ) )
732 {
733 delete np;
734 return false;
735 }
736
737 if( nullptr != aNode )
738 *aNode = (WRL2NODE*) np;
739
740 return true;
741}
742
743
744bool WRL2BASE::readFaceSet( WRLPROC& proc, WRL2NODE* aParent, WRL2NODE** aNode )
745{
746 if( nullptr != aNode )
747 *aNode = nullptr;
748
749 WRL2FACESET* np = new WRL2FACESET( aParent );
750
751 if( !np->Read( proc, this ) )
752 {
753 delete np;
754 return false;
755 }
756
757 if( nullptr != aNode )
758 *aNode = (WRL2NODE*) np;
759
760 return true;
761}
762
763
764bool WRL2BASE::readLineSet( WRLPROC& proc, WRL2NODE* aParent, WRL2NODE** aNode )
765{
766 if( nullptr != aNode )
767 *aNode = nullptr;
768
769 WRL2LINESET* np = new WRL2LINESET( aParent );
770
771 if( !np->Read( proc, this ) )
772 {
773 delete np;
774 return false;
775 }
776
777 if( nullptr != aNode )
778 *aNode = (WRL2NODE*) np;
779
780 return true;
781}
782
783
784bool WRL2BASE::readPointSet( WRLPROC& proc, WRL2NODE* aParent, WRL2NODE** aNode )
785{
786 if( nullptr != aNode )
787 *aNode = nullptr;
788
789 WRL2POINTSET* np = new WRL2POINTSET( aParent );
790
791 if( !np->Read( proc, this ) )
792 {
793 delete np;
794 return false;
795 }
796
797 if( nullptr != aNode )
798 *aNode = (WRL2NODE*) np;
799
800 return true;
801}
802
803
804bool WRL2BASE::readCoords( WRLPROC& proc, WRL2NODE* aParent, WRL2NODE** aNode )
805{
806 if( nullptr != aNode )
807 *aNode = nullptr;
808
809 WRL2COORDS* np = new WRL2COORDS( aParent );
810
811 if( !np->Read( proc, this ) )
812 {
813 delete np;
814 return false;
815 }
816
817 if( nullptr != aNode )
818 *aNode = (WRL2NODE*) np;
819
820 return true;
821}
822
823
824bool WRL2BASE::readNorms( WRLPROC& proc, WRL2NODE* aParent, WRL2NODE** aNode )
825{
826 if( nullptr != aNode )
827 *aNode = nullptr;
828
829 WRL2NORMS* np = new WRL2NORMS( aParent );
830
831 if( !np->Read( proc, this ) )
832 {
833 delete np;
834 return false;
835 }
836
837 if( nullptr != aNode )
838 *aNode = (WRL2NODE*) np;
839
840 return true;
841}
842
843
844bool WRL2BASE::readColor( WRLPROC& proc, WRL2NODE* aParent, WRL2NODE** aNode )
845{
846 if( nullptr != aNode )
847 *aNode = nullptr;
848
849 WRL2COLOR* np = new WRL2COLOR( aParent );
850
851 if( !np->Read( proc, this ) )
852 {
853 delete np;
854 return false;
855 }
856
857 if( nullptr != aNode )
858 *aNode = (WRL2NODE*) np;
859
860 return true;
861}
862
863
864bool WRL2BASE::readBox( WRLPROC& proc, WRL2NODE* aParent, WRL2NODE** aNode )
865{
866 if( nullptr != aNode )
867 *aNode = nullptr;
868
869 WRL2BOX* np = new WRL2BOX( aParent );
870
871 if( !np->Read( proc, this ) )
872 {
873 delete np;
874 return false;
875 }
876
877 if( nullptr != aNode )
878 *aNode = (WRL2NODE*) np;
879
880 return true;
881}
882
883
884bool WRL2BASE::readSwitch( WRLPROC& proc, WRL2NODE* aParent, WRL2NODE** aNode )
885{
886 if( nullptr != aNode )
887 *aNode = nullptr;
888
889 WRL2SWITCH* np = new WRL2SWITCH( aParent );
890
891 if( !np->Read( proc, this ) )
892 {
893 delete np;
894 return false;
895 }
896
897 if( nullptr != aNode )
898 *aNode = (WRL2NODE*) np;
899
900 return true;
901}
902
903
904bool WRL2BASE::readInline( WRLPROC& proc, WRL2NODE* aParent, WRL2NODE** aNode )
905{
906 if( nullptr != aNode )
907 *aNode = nullptr;
908
909 if( !m_useInline )
910 {
911 m_incompleteInline = true;
912
913 if( !proc.DiscardNode() )
914 {
915 wxLogTrace( traceVrmlPlugin, wxT( " * [INFO] failed to discard in line node %s." ),
916 proc.GetFilePosition() );
917
918 return false;
919 }
920
921 return true;
922 }
923
924 WRL2INLINE* np = new WRL2INLINE( aParent );
925
926 if( !np->Read( proc, this ) )
927 {
928 delete np;
929 return false;
930 }
931
932 if( nullptr != aNode )
933 *aNode = (WRL2NODE*) np;
934
935 return true;
936}
937
938
940{
941 if( m_Children.empty() )
942 return nullptr;
943
944 if( m_sgNode )
945 {
946 if( nullptr != aParent )
947 {
948 if( nullptr == S3D::GetSGNodeParent( m_sgNode )
949 && !S3D::AddSGNodeChild( aParent, m_sgNode ) )
950 {
951 return nullptr;
952 }
953 else if( aParent != S3D::GetSGNodeParent( m_sgNode )
954 && !S3D::AddSGNodeRef( aParent, m_sgNode ) )
955 {
956 return nullptr;
957 }
958 }
959
960 return m_sgNode;
961 }
962
963 IFSG_TRANSFORM topNode( aParent );
964
965 std::list< WRL2NODE* >::iterator sC = m_Children.begin();
966 std::list< WRL2NODE* >::iterator eC = m_Children.end();
967 WRL2NODES type;
968
969 // Include only Shape and Transform nodes in the top node
970 bool test = false; // set to true if there are any subnodes for display
971
972 while( sC != eC )
973 {
974 type = (*sC)->GetNodeType();
975
976 switch( type )
977 {
979 // wrap the shape in a transform
980 do
981 {
982 IFSG_TRANSFORM wrapper( topNode.GetRawPtr() );
983 SGNODE* pshape = (*sC)->TranslateToSG( wrapper.GetRawPtr() );
984
985 if( nullptr != pshape )
986 test = true;
987 else
988 wrapper.Destroy();
989
990 } while( 0 );
991
992 break;
993
997
998 if( nullptr != (*sC)->TranslateToSG( topNode.GetRawPtr() ) )
999 test = true;
1000
1001 break;
1002
1003 default:
1004 break;
1005 }
1006
1007 ++ sC;
1008 }
1009
1010 if( false == test )
1011 {
1012 topNode.Destroy();
1013 return nullptr;
1014 }
1015
1016 m_sgNode = topNode.GetRawPtr();
1017
1018 return m_sgNode;
1019}
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)
MODEL_IMPORT_STATUS * m_status
Definition vrml2_base.h:118
std::map< std::string, SGNODE * > m_inlineModels
Definition vrml2_base.h:120
bool m_useInline
Definition vrml2_base.h:114
virtual bool SetName(const std::string &aName) override
void SetEnableInline(bool enable)
void SetImportOptions(const S3D::MODEL_IMPORT_OPTIONS &aOptions, MODEL_IMPORT_STATUS *aStatus)
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:115
S3D::MODEL_IMPORT_OPTIONS m_options
Definition vrml2_base.h:117
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 m_incompleteInline
Definition vrml2_base.h:116
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:119
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:175
WRL2NODES getNodeTypeID(const std::string &aNodeName)
std::list< WRL2NODE * > m_Children
Definition vrml2_node.h:171
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:167
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:493
bool ReadGlob(std::string &aGlob)
Definition wrlproc.cpp:247
WRLVERSION GetVRMLType(void)
Definition wrlproc.cpp:232
const char * GetParentDir(void)
Definition wrlproc.cpp:238
std::string GetError(void)
Definition wrlproc.cpp:1962
bool eof(void)
Definition wrlproc.cpp:1956
bool ReadName(std::string &aName)
Definition wrlproc.cpp:291
std::string GetFilePosition() const
Definition wrlproc.cpp:1984
bool DiscardNode(void)
Definition wrlproc.cpp:370
const wxChar *const traceVrmlPlugin
Flag to enable VRML plugin trace output.
Definition vrml.cpp:56
collects header files for all SG* wrappers and the API
SGLIB_API SGNODE * GetSGNodeParent(SGNODE *aNode)
Definition ifsg_api.cpp:518
SGLIB_API void DestroyNode(SGNODE *aNode) noexcept
Delete the given SG* class node.
Definition ifsg_api.cpp:169
SGLIB_API bool AddSGNodeChild(SGNODE *aParent, SGNODE *aChild)
Definition ifsg_api.cpp:536
SGLIB_API bool AddSGNodeRef(SGNODE *aParent, SGNODE *aChild)
Definition ifsg_api.cpp:527
SCENEGRAPH * LoadVRML(const wxString &aFileName, const S3D::MODEL_IMPORT_OPTIONS &aOptions, MODEL_IMPORT_STATUS *aStatus)
Definition vrml.cpp:72
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