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