9cfc7917a82d641d2568894f18a93a248c6a9ec4
[occt.git] / src / XSDRAWSTLVRML / XSDRAWSTLVRML.cxx
1 // Created on: 2000-05-30
2 // Created by: Sergey MOZOKHIN
3 // Copyright (c) 2000-2014 OPEN CASCADE SAS
4 //
5 // This file is part of Open CASCADE Technology software library.
6 //
7 // This library is free software; you can redistribute it and/or modify it under
8 // the terms of the GNU Lesser General Public License version 2.1 as published
9 // by the Free Software Foundation, with special exception defined in the file
10 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
11 // distribution for complete text of the license and disclaimer of any warranty.
12 //
13 // Alternatively, this file may be used under the terms of Open CASCADE
14 // commercial license or contractual agreement.
15
16
17 #include <AIS_InteractiveContext.hxx>
18 #include <Aspect_TypeOfMarker.hxx>
19 #include <Bnd_Box.hxx>
20 #include <DBRep.hxx>
21 #include <Draw.hxx>
22 #include <Draw_Interpretor.hxx>
23 #include <Draw_PluginMacro.hxx>
24 #include <Draw_ProgressIndicator.hxx>
25 #include <Graphic3d_MaterialAspect.hxx>
26 #include <MeshVS_DataMapOfIntegerAsciiString.hxx>
27 #include <MeshVS_DeformedDataSource.hxx>
28 #include <MeshVS_Drawer.hxx>
29 #include <MeshVS_DrawerAttribute.hxx>
30 #include <MeshVS_ElementalColorPrsBuilder.hxx>
31 #include <MeshVS_Mesh.hxx>
32 #include <MeshVS_MeshEntityOwner.hxx>
33 #include <MeshVS_MeshPrsBuilder.hxx>
34 #include <MeshVS_NodalColorPrsBuilder.hxx>
35 #include <MeshVS_PrsBuilder.hxx>
36 #include <MeshVS_TextPrsBuilder.hxx>
37 #include <MeshVS_VectorPrsBuilder.hxx>
38 #include <OSD_Path.hxx>
39 #include <Quantity_Color.hxx>
40 #include <Quantity_HArray1OfColor.hxx>
41 #include <Quantity_NameOfColor.hxx>
42 #include <RWStl.hxx>
43 #include <SelectMgr_SelectionManager.hxx>
44 #include <Standard_ErrorHandler.hxx>
45 #include <StdSelect_ViewerSelector3d.hxx>
46 #include <StlAPI.hxx>
47 #include <StlAPI_Writer.hxx>
48 #include <StlMesh_Mesh.hxx>
49 #include <StlMesh_SequenceOfMeshTriangle.hxx>
50 #include <TColgp_SequenceOfXYZ.hxx>
51 #include <TCollection_AsciiString.hxx>
52 #include <TColStd_Array1OfReal.hxx>
53 #include <TColStd_HPackedMapOfInteger.hxx>
54 #include <TColStd_MapIteratorOfPackedMapOfInteger.hxx>
55 #include <TopoDS_Shape.hxx>
56 #include <V3d_View.hxx>
57 #include <ViewerTest.hxx>
58 #include <VrmlAPI.hxx>
59 #include <VrmlAPI_Writer.hxx>
60 #include <VrmlData_DataMapOfShapeAppearance.hxx>
61 #include <VrmlData_Scene.hxx>
62 #include <VrmlData_ShapeConvert.hxx>
63 #include <XSDRAW.hxx>
64 #include <XSDRAWIGES.hxx>
65 #include <XSDRAWSTEP.hxx>
66 #include <XSDRAWSTLVRML.hxx>
67 #include <XSDRAWSTLVRML_DataSource.hxx>
68 #include <XSDRAWSTLVRML_DataSource3D.hxx>
69 #include <XSDRAWSTLVRML_DrawableMesh.hxx>
70
71 #ifndef _STDIO_H
72 #include <stdio.h>
73 #endif
74
75 extern Standard_Boolean VDisplayAISObject (const TCollection_AsciiString& theName,
76                                            const Handle(AIS_InteractiveObject)& theAISObj,
77                                            Standard_Boolean theReplaceIfExists = Standard_True);
78
79 static Standard_Integer writestl
80 (Draw_Interpretor& di, Standard_Integer argc, const char** argv)
81 {
82   if (argc < 3 || argc > 4) {
83     di << "Use: " << argv[0]
84     << " shape file [ascii/binary (0/1) : 1 by default]\n";
85   } else {
86     TopoDS_Shape aShape = DBRep::Get(argv[1]);
87     Standard_Boolean isASCIIMode = Standard_False;
88     if (argc == 4) {
89       isASCIIMode = (Draw::Atoi(argv[3]) == 0);
90     }
91     StlAPI_Writer aWriter;
92     aWriter.ASCIIMode() = isASCIIMode;
93     StlAPI_ErrorStatus aStatus = aWriter.Write (aShape, argv[2]);
94
95     switch (aStatus)
96     {
97     case StlAPI_MeshIsEmpty: di << "** Error **: Mesh is empty. Please, compute triangulation before."; break;
98     case StlAPI_CannotOpenFile: di << "** Error **: Cannot create/open a file with the passed name."; break;
99     case StlAPI_StatusOK: default: break;
100     }
101   }
102   return 0;
103 }
104
105 static Standard_Integer readstl
106 (Draw_Interpretor& di, Standard_Integer argc, const char** argv)
107 {
108   if (argc<3) di << "wrong number of parameters"    << "\n";
109   else {
110     TopoDS_Shape aShape ;
111     StlAPI::Read(aShape,argv[2]);
112     DBRep::Set(argv[1],aShape);
113   }
114   return 0;
115 }
116
117 static Standard_Integer writevrml
118 (Draw_Interpretor& di, Standard_Integer argc, const char** argv)
119 {
120   if (argc < 3 || argc > 5) 
121   {
122     di << "wrong number of parameters\n";
123     return 0;
124   }
125
126   TopoDS_Shape aShape = DBRep::Get(argv[1]);
127
128   // Get the optional parameters
129   Standard_Integer aVersion = 2;
130   Standard_Integer aType = 1;
131   if (argc >= 4)
132   {
133     aVersion = Draw::Atoi(argv[3]);
134     if (argc == 5)
135       aType = Draw::Atoi(argv[4]);
136   }
137
138   // Bound parameters
139   aVersion = Max(1, aVersion);
140   aVersion = Min(2, aVersion);
141   aType = Max(0, aType);
142   aType = Min(2, aType);
143
144   VrmlAPI_Writer writer;
145
146   switch (aType)
147   {
148   case 0: writer.SetRepresentation(VrmlAPI_ShadedRepresentation); break;
149   case 1: writer.SetRepresentation(VrmlAPI_WireFrameRepresentation); break;
150   case 2: writer.SetRepresentation(VrmlAPI_BothRepresentation); break;
151   }
152
153   writer.Write(aShape, argv[2], aVersion);
154
155   return 0;
156 }
157
158 //=======================================================================
159 //function : loadvrml
160 //purpose  :
161 //=======================================================================
162
163 static Standard_Integer loadvrml
164 (Draw_Interpretor& di, Standard_Integer argc, const char** argv)
165 {
166   if (argc<3) di << "wrong number of parameters"    << "\n";
167   else {
168     TopoDS_Shape aShape ;
169     VrmlData_DataMapOfShapeAppearance aShapeAppMap;
170
171     //-----------------------------------------------------------
172     filebuf aFic;
173     istream aStream (&aFic);
174
175     if (aFic.open(argv[2], ios::in)) {
176
177       // Get path of the VRML file.
178       OSD_Path aPath(argv[2]);
179       TCollection_AsciiString aVrmlDir(".");
180       TCollection_AsciiString aDisk = aPath.Disk();
181       TCollection_AsciiString aTrek = aPath.Trek();
182       if (!aTrek.IsEmpty())
183       {
184         if (!aDisk.IsEmpty())
185           aVrmlDir = aDisk;
186         else
187           aVrmlDir.Clear();
188         aTrek.ChangeAll('|', '/');
189         aVrmlDir += aTrek;
190       }
191
192       VrmlData_Scene aScene;
193
194       aScene.SetVrmlDir (aVrmlDir);
195       aScene << aStream;
196       const char * aStr = 0L;
197       switch (aScene.Status()) {
198
199       case VrmlData_StatusOK:
200         {
201           aShape = aScene.GetShape(aShapeAppMap);
202           break;
203         }
204       case VrmlData_EmptyData:            aStr = "EmptyData"; break;
205       case VrmlData_UnrecoverableError:   aStr = "UnrecoverableError"; break;
206       case VrmlData_GeneralError:         aStr = "GeneralError"; break;
207       case VrmlData_EndOfFile:            aStr = "EndOfFile"; break;
208       case VrmlData_NotVrmlFile:          aStr = "NotVrmlFile"; break;
209       case VrmlData_CannotOpenFile:       aStr = "CannotOpenFile"; break;
210       case VrmlData_VrmlFormatError:      aStr = "VrmlFormatError"; break;
211       case VrmlData_NumericInputError:    aStr = "NumericInputError"; break;
212       case VrmlData_IrrelevantNumber:     aStr = "IrrelevantNumber"; break;
213       case VrmlData_BooleanInputError:    aStr = "BooleanInputError"; break;
214       case VrmlData_StringInputError:     aStr = "StringInputError"; break;
215       case VrmlData_NodeNameUnknown:      aStr = "NodeNameUnknown"; break;
216       case VrmlData_NonPositiveSize:      aStr = "NonPositiveSize"; break;
217       case VrmlData_ReadUnknownNode:      aStr = "ReadUnknownNode"; break;
218       case VrmlData_NonSupportedFeature:  aStr = "NonSupportedFeature"; break;
219       case VrmlData_OutputStreamUndefined:aStr = "OutputStreamUndefined"; break;
220       case VrmlData_NotImplemented:       aStr = "NotImplemented"; break;
221       default:
222         break;
223       }
224       if (aStr) {
225         di << " ++ VRML Error: " << aStr << " in line "
226           << aScene.GetLineError() << "\n";
227       }
228       else {
229         DBRep::Set(argv[1],aShape);
230       }
231     }
232     else {
233       di << "cannot open file\n";
234     }
235
236
237     //-----------------------------------------------------------
238   }
239   return 0;
240 }
241
242 //-----------------------------------------------------------------------------
243 static Standard_Integer createmesh
244 (Draw_Interpretor& di, Standard_Integer argc, const char** argv )
245 {
246   if (argc<3)
247   {
248     di << "Wrong number of parameters\n";
249     di << "Use: " << argv[0] << " <mesh name> <stl file>\n";
250     return 0;
251   }
252
253   Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext();
254   if (aContext.IsNull())
255   {
256     di << "No active view. Please call 'vinit' first\n";
257     return 0;
258   }
259
260   // Progress indicator
261   OSD_Path aFile( argv[2] );
262   Handle(Draw_ProgressIndicator) aProgress = new Draw_ProgressIndicator (di, 1);
263   Handle(StlMesh_Mesh) aSTLMesh = RWStl::ReadFile (aFile, aProgress);
264
265   di << "Reading OK...\n";
266   Handle( XSDRAWSTLVRML_DataSource ) aDS = new XSDRAWSTLVRML_DataSource( aSTLMesh );
267   di << "Data source is created successful\n";
268   Handle( MeshVS_Mesh ) aMesh = new MeshVS_Mesh();
269   di << "MeshVS_Mesh is created successful\n";
270
271   aMesh->SetDataSource( aDS );
272   aMesh->AddBuilder( new MeshVS_MeshPrsBuilder( aMesh.operator->() ), Standard_True );
273
274   aMesh->GetDrawer()->SetColor( MeshVS_DA_EdgeColor, Quantity_NOC_YELLOW );
275
276   // Hide all nodes by default
277   Handle(TColStd_HPackedMapOfInteger) aNodes = new TColStd_HPackedMapOfInteger();
278   Standard_Integer aLen = aSTLMesh->Vertices().Length();
279   for ( Standard_Integer anIndex = 1; anIndex <= aLen; anIndex++ )
280     aNodes->ChangeMap().Add( anIndex );
281   aMesh->SetHiddenNodes( aNodes );
282   aMesh->SetSelectableNodes ( aNodes );
283
284   VDisplayAISObject(argv[1], aMesh);
285   aContext->Deactivate( aMesh );
286
287   Draw::Set( argv[1], new XSDRAWSTLVRML_DrawableMesh( aMesh ) );
288   Handle( V3d_View ) aView = ViewerTest::CurrentView();
289   if ( !aView.IsNull() )
290     aView->FitAll();
291
292   return 0;
293 }
294 //-----------------------------------------------------------------------------
295
296 static Standard_Integer create3d
297 (Draw_Interpretor& di, Standard_Integer argc, const char** argv )
298 {
299   if (argc<2)
300   {
301     di << "Wrong number of parameters\n";
302     di << "Use: " << argv[0] << " <mesh name>\n";
303     return 0;
304   }
305
306   Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext();
307   if (aContext.IsNull())
308   {
309     di << "No active view. Please call 'vinit' first\n";
310     return 0;
311   }
312
313   Handle( XSDRAWSTLVRML_DataSource3D ) aDS = new XSDRAWSTLVRML_DataSource3D();
314   di << "Data source is created successful\n";
315   Handle( MeshVS_Mesh ) aMesh = new MeshVS_Mesh();
316   di << "MeshVS_Mesh is created successful\n";
317
318   aMesh->SetDataSource( aDS );
319   aMesh->AddBuilder( new MeshVS_MeshPrsBuilder( aMesh.operator->() ), Standard_True );
320
321   aMesh->GetDrawer()->SetColor( MeshVS_DA_EdgeColor, Quantity_NOC_YELLOW );
322
323   // Hide all nodes by default
324   Handle(TColStd_HPackedMapOfInteger) aNodes = new TColStd_HPackedMapOfInteger();
325   Standard_Integer aLen = aDS->GetAllNodes().Extent();
326   for ( Standard_Integer anIndex = 1; anIndex <= aLen; anIndex++ )
327     aNodes->ChangeMap().Add( anIndex );
328   aMesh->SetHiddenNodes( aNodes );
329   aMesh->SetSelectableNodes ( aNodes );
330
331   VDisplayAISObject(argv[1], aMesh);
332   aContext->Deactivate( aMesh );
333
334   Draw::Set( argv[1], new XSDRAWSTLVRML_DrawableMesh( aMesh ) );
335   Handle( V3d_View ) aView = ViewerTest::CurrentView();
336   if ( !aView.IsNull() )
337     aView->FitAll();
338
339   return 0;
340 }
341
342 Handle( MeshVS_Mesh ) getMesh( const char* theName, Draw_Interpretor& di)
343 {
344   Handle( XSDRAWSTLVRML_DrawableMesh ) aDrawMesh =
345     Handle( XSDRAWSTLVRML_DrawableMesh )::DownCast( Draw::Get( theName ) );
346
347   if( aDrawMesh.IsNull() )
348   {
349     di << "There is no such object\n";
350     return NULL;
351   }
352   else
353   {
354     Handle( MeshVS_Mesh ) aMesh = aDrawMesh->GetMesh();
355     if( aMesh.IsNull() )
356     {
357       di << "There is invalid mesh\n";
358       return NULL;
359     }
360     else
361       return aMesh;
362   }
363 }
364
365 //-----------------------------------------------------------------------------
366 static Standard_Integer setcolor
367 (Draw_Interpretor& di, Standard_Integer argc, const char** argv, Standard_Integer theParam )
368 {
369   if (argc<5)
370     di << "Wrong number of parameters\n";
371   else
372   {
373     Handle( MeshVS_Mesh ) aMesh = getMesh( argv[1], di );
374     if( !aMesh.IsNull() )
375     {
376       Standard_Real aRed = Draw::Atof (argv[2]);
377       Standard_Real aGreen = Draw::Atof (argv[3]);
378       Standard_Real aBlue = Draw::Atof (argv[4]);
379       aMesh->GetDrawer()->SetColor( (MeshVS_DrawerAttribute)theParam,
380                                     Quantity_Color( aRed, aGreen, aBlue, Quantity_TOC_RGB ) );
381
382       Handle( AIS_InteractiveContext ) aContext = ViewerTest::GetAISContext();
383
384       if( aContext.IsNull() )
385         di << "The context is null\n";
386       else
387         aContext->Redisplay (aMesh, Standard_True);
388     }
389   }
390   return 0;
391 }
392 //-----------------------------------------------------------------------------
393 static Standard_Integer meshcolor
394 (Draw_Interpretor& theInterp, Standard_Integer argc, const char** argv )
395 {
396   return setcolor( theInterp, argc, argv, MeshVS_DA_InteriorColor );
397 }
398 //-----------------------------------------------------------------------------
399 static Standard_Integer linecolor
400 (Draw_Interpretor& theInterp, Standard_Integer argc, const char** argv )
401 {
402   return setcolor( theInterp, argc, argv, MeshVS_DA_EdgeColor );
403 }
404 //-----------------------------------------------------------------------------
405 static Standard_Integer meshmat
406 (Draw_Interpretor& di, Standard_Integer argc, const char** argv )
407 {
408   if (argc<3)
409     di << "Wrong number of parameters\n";
410   else
411   {
412     Handle( MeshVS_Mesh ) aMesh = getMesh( argv[1], di );
413     if( !aMesh.IsNull() )
414     {
415       Standard_Integer aMaterial = Draw::Atoi (argv[2]);
416
417       Graphic3d_MaterialAspect aMatAsp =
418         (Graphic3d_MaterialAspect)(Graphic3d_NameOfMaterial)aMaterial;
419
420       if (argc == 4)
421       {
422         Standard_Real aTransparency = Draw::Atof(argv[3]);
423         aMatAsp.SetTransparency (Standard_ShortReal (aTransparency));
424       }
425       aMesh->GetDrawer()->SetMaterial( MeshVS_DA_FrontMaterial, aMatAsp );
426       aMesh->GetDrawer()->SetMaterial( MeshVS_DA_BackMaterial, aMatAsp );
427
428       Handle( AIS_InteractiveContext ) aContext = ViewerTest::GetAISContext();
429
430       if( aContext.IsNull() )
431         di << "The context is null\n";
432       else
433         aContext->Redisplay (aMesh, Standard_True);
434     }
435   }
436   return 0;
437 }
438 //-----------------------------------------------------------------------------
439 static Standard_Integer shrink
440 (Draw_Interpretor& di, Standard_Integer argc, const char** argv )
441 {
442   if (argc<3)
443     di << "Wrong number of parameters\n";
444   else
445   {
446     Handle( MeshVS_Mesh ) aMesh = getMesh( argv[1], di );
447     if( !aMesh.IsNull() )
448     {
449       Standard_Real aShrinkCoeff = Draw::Atof (argv[2]);
450       aMesh->GetDrawer()->SetDouble( MeshVS_DA_ShrinkCoeff, aShrinkCoeff );
451
452       Handle( AIS_InteractiveContext ) aContext = ViewerTest::GetAISContext();
453
454       if( aContext.IsNull() )
455         di << "The context is null\n";
456       else
457         aContext->Redisplay (aMesh, Standard_True);
458     }
459   }
460   return 0;
461 }
462
463 //-----------------------------------------------------------------------------
464 static Standard_Integer closed (Draw_Interpretor& theDI, Standard_Integer theArgc, const char** theArgv)
465 {
466   if (theArgc < 3)
467   {
468     theDI << "Wrong number of parameters.\n";
469   }
470   else
471   {
472     Handle(MeshVS_Mesh) aMesh = getMesh (theArgv[1], theDI);
473     if (!aMesh.IsNull())
474     {
475       Standard_Boolean aFlag = Draw::Atoi (theArgv[2]) != 0;
476       aMesh->GetDrawer()->SetBoolean (MeshVS_DA_SupressBackFaces, aFlag);
477
478       Handle( AIS_InteractiveContext ) aContext = ViewerTest::GetAISContext();
479       if (aContext.IsNull())
480       {
481         theDI << "The context is null\n";
482       }
483       else
484       {
485         aContext->Redisplay (aMesh, Standard_True);
486       }
487     }
488   }
489   return 0;
490 }
491
492 //-----------------------------------------------------------------------------
493
494 static Standard_Integer mdisplay
495 (Draw_Interpretor& di, Standard_Integer argc, const char** argv )
496 {
497   if (argc<2)
498     di << "Wrong number of parameters\n";
499   else
500   {
501     Handle( MeshVS_Mesh ) aMesh = getMesh( argv[1], di );
502     if( !aMesh.IsNull() )
503     {
504       Handle( AIS_InteractiveContext ) aContext = ViewerTest::GetAISContext();
505
506       if( aContext.IsNull() )
507         di << "The context is null\n";
508       else
509       {
510         Standard_DISABLE_DEPRECATION_WARNINGS
511         if (aContext->HasOpenedContext())
512         {
513           aContext->CloseLocalContext();
514         }
515         Standard_ENABLE_DEPRECATION_WARNINGS
516
517         aContext->Display (aMesh, Standard_True);
518       }
519     }
520   }
521   return 0;
522 }
523 //-----------------------------------------------------------------------------
524 static Standard_Integer merase
525 (Draw_Interpretor& di, Standard_Integer argc, const char** argv )
526 {
527   if (argc<2)
528     di << "Wrong number of parameters\n";
529   else
530   {
531     Handle( MeshVS_Mesh ) aMesh = getMesh( argv[1], di );
532     if( !aMesh.IsNull() )
533     {
534       Handle( AIS_InteractiveContext ) aContext = ViewerTest::GetAISContext();
535
536       if( aContext.IsNull() )
537         di << "The context is null\n";
538       else
539       {
540         Standard_DISABLE_DEPRECATION_WARNINGS
541         if (aContext->HasOpenedContext())
542         {
543           aContext->CloseLocalContext();
544         }
545         Standard_ENABLE_DEPRECATION_WARNINGS
546
547         aContext->Erase (aMesh, Standard_True);
548       }
549     }
550     else
551       di << "Mesh is null\n";
552   }
553   return 0;
554 }
555 //-----------------------------------------------------------------------------
556 static Standard_Integer hidesel
557 (Draw_Interpretor& di, Standard_Integer argc, const char** argv )
558 {
559   if (argc<2)
560   {
561     di << "Wrong number of parameters\n";
562     di << "Use: " << argv[0] << " <mesh name>\n";
563     return 0;
564   }
565
566   Handle( AIS_InteractiveContext ) aContext = ViewerTest::GetAISContext();
567   Handle( MeshVS_Mesh ) aMesh = getMesh( argv[1], di );
568   if( aMesh.IsNull() )
569   {
570     di << "The mesh is invalid\n";
571     return 0;
572   }
573
574   if( aContext.IsNull() )
575     di << "The context is null\n";
576   else
577   {
578     Handle(TColStd_HPackedMapOfInteger) aHiddenNodes = aMesh->GetHiddenNodes();
579     if (aHiddenNodes.IsNull())
580     {
581       aHiddenNodes = new TColStd_HPackedMapOfInteger();
582     }
583     Handle(TColStd_HPackedMapOfInteger) aHiddenElements = aMesh->GetHiddenElems();
584     if (aHiddenElements.IsNull())
585     {
586       aHiddenElements = new TColStd_HPackedMapOfInteger();
587     }
588     for( aContext->InitSelected(); aContext->MoreSelected(); aContext->NextSelected() )
589     {
590       Handle( MeshVS_MeshEntityOwner ) anOwner =
591         Handle( MeshVS_MeshEntityOwner )::DownCast( aContext->SelectedOwner() );
592       if( !anOwner.IsNull() )
593       {
594         if( anOwner->Type()==MeshVS_ET_Node )
595         {
596           aHiddenNodes->ChangeMap().Add( anOwner->ID() );
597         }
598         else
599         {
600           aHiddenElements->ChangeMap().Add( anOwner->ID() );
601         }
602       }
603     }
604     aContext->ClearSelected (Standard_False);
605     aMesh->SetHiddenNodes( aHiddenNodes );
606     aMesh->SetHiddenElems( aHiddenElements );
607     aContext->Redisplay (aMesh, Standard_True);
608   }
609
610   return 0;
611 }
612 //-----------------------------------------------------------------------------
613 static Standard_Integer showonly
614 (Draw_Interpretor& di, Standard_Integer argc, const char** argv )
615 {
616   if (argc<2)
617   {
618     di << "Wrong number of parameters\n";
619     di << "Use: " << argv[0] << " <mesh name>\n";
620     return 0;
621   }
622
623
624   Handle( AIS_InteractiveContext ) aContext = ViewerTest::GetAISContext();
625   Handle( MeshVS_Mesh ) aMesh = getMesh( argv[1], di );
626   if( aMesh.IsNull() )
627   {
628     di << "The mesh is invalid\n";
629     return 0;
630   }
631
632   if( aContext.IsNull() )
633     di << "The context is null\n";
634   else
635   {
636     Handle(TColStd_HPackedMapOfInteger) aHiddenNodes =
637       new TColStd_HPackedMapOfInteger(aMesh->GetDataSource()->GetAllNodes());
638     Handle(TColStd_HPackedMapOfInteger) aHiddenElements =
639       new TColStd_HPackedMapOfInteger(aMesh->GetDataSource()->GetAllElements());
640     for( aContext->InitSelected(); aContext->MoreSelected(); aContext->NextSelected() )
641     {
642       Handle( MeshVS_MeshEntityOwner ) anOwner =
643         Handle( MeshVS_MeshEntityOwner )::DownCast( aContext->SelectedOwner() );
644       if( !anOwner.IsNull() )
645       {
646         if( anOwner->Type() == MeshVS_ET_Node )
647         {
648           aHiddenNodes->ChangeMap().Remove( anOwner->ID() );
649         }
650         else
651         {
652           aHiddenElements->ChangeMap().Remove( anOwner->ID() );
653         }
654       }
655     }
656     aMesh->SetHiddenNodes( aHiddenNodes );
657     aMesh->SetHiddenElems( aHiddenElements );
658     aContext->Redisplay (aMesh, Standard_True);
659   }
660
661   return 0;
662 }
663 //-----------------------------------------------------------------------------
664 static Standard_Integer showall
665 (Draw_Interpretor& di, Standard_Integer argc, const char** argv )
666 {
667   if (argc<2)
668   {
669     di << "Wrong number of parameters\n";
670     di << "Use: " << argv[0] << " <mesh name>\n";
671     return 0;
672   }
673
674   Handle( AIS_InteractiveContext ) aContext = ViewerTest::GetAISContext();
675   Handle( MeshVS_Mesh ) aMesh = getMesh( argv[1], di );
676   if( aMesh.IsNull() )
677   {
678     di << "The mesh is invalid\n";
679     return 0;
680   }
681
682   if( aContext.IsNull() )
683     di << "The context is null\n";
684   else
685   {
686     aMesh->SetHiddenNodes( new TColStd_HPackedMapOfInteger() );
687     aMesh->SetHiddenElems( new TColStd_HPackedMapOfInteger() );
688     aContext->Redisplay (aMesh, Standard_True);
689   }
690
691   return 0;
692 }
693
694 //-----------------------------------------------------------------------------
695 static Standard_Integer meshcolors( Draw_Interpretor& di,
696                                     Standard_Integer argc,
697                                     const char** argv )
698 {
699   try
700   {
701     OCC_CATCH_SIGNALS
702       if ( argc < 4 )
703       {
704         di << "Wrong number of parameters\n";
705         di << "Use : meshcolors <mesh name> <mode> <isreflect>\n";
706         di << "mode : {elem1|elem2|nodal|nodaltex|none}\n";
707         di << "       elem1 - different color for each element\n";
708         di << "       elem2 - one color for one side\n";
709         di << "       nodal - different color for each node\n";
710         di << "       nodaltex - different color for each node with texture interpolation\n";
711         di << "       none  - clear\n";
712         di << "isreflect : {0|1} \n";
713
714         return 0;
715       }
716
717       Handle( MeshVS_Mesh ) aMesh = getMesh( argv[ 1 ], di );
718
719       if ( aMesh.IsNull() )
720       {
721         di << "Mesh not found\n";
722         return 0;
723       }
724       Handle(AIS_InteractiveContext) anIC = ViewerTest::GetAISContext();
725       if ( anIC.IsNull() )
726       {
727         di << "The context is null\n";
728         return 0;
729       }
730       if( !aMesh.IsNull() )
731       {
732         TCollection_AsciiString aMode = TCollection_AsciiString (argv[2]);
733         Quantity_Color aColor1(Quantity_NOC_BLUE1);
734         Quantity_Color aColor2(Quantity_NOC_RED1);
735         if( aMode.IsEqual("elem1") || aMode.IsEqual("elem2") || aMode.IsEqual("nodal") || aMode.IsEqual("nodaltex") || aMode.IsEqual("none") )
736         {
737           Handle(MeshVS_PrsBuilder) aTempBuilder;
738           Standard_Integer aReflection = Draw::Atoi(argv[3]);
739
740           for (Standard_Integer aCount = 0 ; aCount < aMesh->GetBuildersCount(); aCount++ ){
741             aTempBuilder = aMesh->FindBuilder("MeshVS_ElementalColorPrsBuilder");
742             if( !aTempBuilder.IsNull())
743               aMesh->RemoveBuilderById(aTempBuilder->GetId());
744
745             aTempBuilder = aMesh->FindBuilder("MeshVS_NodalColorPrsBuilder");
746             if( !aTempBuilder.IsNull())
747               aMesh->RemoveBuilderById(aTempBuilder->GetId());
748           }
749
750           if( aMode.IsEqual("elem1") || aMode.IsEqual("elem2") )
751           {
752             Handle(MeshVS_ElementalColorPrsBuilder) aBuilder = new MeshVS_ElementalColorPrsBuilder(
753                 aMesh, MeshVS_DMF_ElementalColorDataPrs | MeshVS_DMF_OCCMask );
754               // Color
755             const TColStd_PackedMapOfInteger& anAllElements = aMesh->GetDataSource()->GetAllElements();
756             TColStd_MapIteratorOfPackedMapOfInteger anIter( anAllElements );
757
758             if( aMode.IsEqual("elem1") )
759               for ( ; anIter.More(); anIter.Next() )
760               {
761                 Quantity_Color aColor( (Quantity_NameOfColor)( anIter.Key() % Quantity_NOC_WHITE ) );
762                 aBuilder->SetColor1( anIter.Key(), aColor );
763               }
764             else
765               for ( ; anIter.More(); anIter.Next() )
766                 aBuilder->SetColor2( anIter.Key(), aColor1, aColor2 );
767
768             aMesh->AddBuilder( aBuilder, Standard_True );
769           }
770
771
772           if( aMode.IsEqual("nodal") )
773           {
774             Handle(MeshVS_NodalColorPrsBuilder) aBuilder = new MeshVS_NodalColorPrsBuilder(
775                 aMesh, MeshVS_DMF_NodalColorDataPrs | MeshVS_DMF_OCCMask );
776             aMesh->AddBuilder( aBuilder, Standard_True );
777
778             // Color
779             const TColStd_PackedMapOfInteger& anAllNodes =
780               aMesh->GetDataSource()->GetAllNodes();
781             TColStd_MapIteratorOfPackedMapOfInteger anIter( anAllNodes );
782             for ( ; anIter.More(); anIter.Next() )
783             {
784               Quantity_Color aColor( (Quantity_NameOfColor)(
785                 anIter.Key() % Quantity_NOC_WHITE ) );
786               aBuilder->SetColor( anIter.Key(), aColor );
787             }
788             aMesh->AddBuilder( aBuilder, Standard_True );
789           }
790
791           if(aMode.IsEqual("nodaltex"))
792           {
793             // assign nodal builder to the mesh
794             Handle(MeshVS_NodalColorPrsBuilder) aBuilder = new MeshVS_NodalColorPrsBuilder(
795                    aMesh, MeshVS_DMF_NodalColorDataPrs | MeshVS_DMF_OCCMask);
796             aMesh->AddBuilder(aBuilder, Standard_True);
797             aBuilder->UseTexture(Standard_True);
798
799             // prepare color map for texture
800             Aspect_SequenceOfColor aColorMap;
801             aColorMap.Append((Quantity_NameOfColor) Quantity_NOC_RED);
802             aColorMap.Append((Quantity_NameOfColor) Quantity_NOC_YELLOW);
803             aColorMap.Append((Quantity_NameOfColor) Quantity_NOC_BLUE1);
804
805             // prepare scale map for mesh - it will be assigned to mesh as texture coordinates
806             // make mesh color interpolated from minimum X coord to maximum X coord
807             Handle(MeshVS_DataSource) aDataSource = aMesh->GetDataSource();
808             Standard_Real aMinX, aMinY, aMinZ, aMaxX, aMaxY, aMaxZ;
809
810             // get bounding box for calculations
811             aDataSource->GetBoundingBox().Get(aMinX, aMinY, aMinZ, aMaxX, aMaxY, aMaxZ);
812             Standard_Real aDelta = aMaxX - aMinX;
813
814             // assign color scale map values (0..1) to nodes
815             TColStd_DataMapOfIntegerReal aScaleMap;
816             TColStd_Array1OfReal aCoords(1, 3);
817             Standard_Integer     aNbNodes;
818             MeshVS_EntityType    aType;
819
820             // iterate nodes
821             const TColStd_PackedMapOfInteger& anAllNodes =
822                   aMesh->GetDataSource()->GetAllNodes();
823             TColStd_MapIteratorOfPackedMapOfInteger anIter(anAllNodes);
824             for (; anIter.More(); anIter.Next())
825             {
826               //get node coordinates to aCoord variable
827               aDataSource->GetGeom(anIter.Key(), Standard_False, aCoords, aNbNodes, aType);
828
829               Standard_Real aScaleValue;
830               try {
831                 OCC_CATCH_SIGNALS
832                 aScaleValue = (aCoords.Value(1) - (Standard_Real) aMinX) / aDelta;
833               } catch(Standard_Failure) {
834                 aScaleValue = 0;
835               }
836
837               aScaleMap.Bind(anIter.Key(), aScaleValue);
838             }
839
840             //set color map for builder and a color for invalid scale value
841             aBuilder->SetColorMap(aColorMap);
842             aBuilder->SetInvalidColor(Quantity_NOC_BLACK);
843             aBuilder->SetTextureCoords(aScaleMap);
844             aMesh->AddBuilder(aBuilder, Standard_True);
845           }
846
847           aMesh->GetDrawer()->SetBoolean (MeshVS_DA_ColorReflection, aReflection != 0);
848
849           anIC->Redisplay (aMesh, Standard_True);
850         }
851         else
852         {
853           di << "Wrong mode name\n";
854           return 0;
855         }
856       }
857   }
858   catch ( Standard_Failure )
859   {
860     di << "Error\n";
861   }
862
863   return 0;
864 }
865 //-----------------------------------------------------------------------------
866 static Standard_Integer meshvectors( Draw_Interpretor& di,
867                                      Standard_Integer argc,
868                                      const char** argv )
869 {
870   if ( argc < 3 )
871   {
872     di << "Wrong number of parameters\n";
873     di << "Use : meshvectors <mesh name> < -mode {elem|nodal|none} > [-maxlen len] [-color name] [-arrowpart ratio] [-issimple {1|0}]\n";
874     di << "Supported mode values:\n";
875     di << "       elem  - vector per element\n";
876     di << "       nodal - vector per node\n";
877     di << "       none  - clear\n";
878
879     return 0;
880   }
881
882   Handle( MeshVS_Mesh ) aMesh = getMesh( argv[ 1 ], di );
883
884   if ( aMesh.IsNull() )
885   {
886     di << "Mesh not found\n";
887     return 0;
888   }
889   Handle(AIS_InteractiveContext) anIC = ViewerTest::GetAISContext();
890   if ( anIC.IsNull() )
891   {
892     di << "The context is null\n";
893     return 0;
894   }
895
896   TCollection_AsciiString aParam;
897   TCollection_AsciiString aMode("none");
898   Standard_Real           aMaxlen(1.0);
899   Quantity_Color          aColor(Quantity_NOC_ORANGE);
900   Standard_Real           anArrowPart(0.1);
901   Standard_Boolean        isSimplePrs(Standard_False);
902
903   for (Standard_Integer anIdx = 2; anIdx < argc; anIdx++)
904   {
905     if (!aParam.IsEmpty())
906     {
907       if (aParam == "-mode")
908       {
909         aMode       = argv[anIdx];
910       }
911       else if (aParam == "-maxlen")
912       {
913         aMaxlen     = Draw::Atof(argv[anIdx]);
914       }
915       else if (aParam == "-color")
916       {
917         aColor      = ViewerTest::GetColorFromName(argv[anIdx]);
918       }
919       else if (aParam == "-arrowpart")
920       {
921         anArrowPart = Draw::Atof(argv[anIdx]);
922       }
923       else if (aParam == "-issimple")
924       {
925         isSimplePrs = Draw::Atoi(argv[anIdx]) != 0;
926       }
927       aParam.Clear();
928     }
929     else if (argv[anIdx][0] == '-')
930     {
931       aParam = argv[anIdx];
932     }
933   }
934
935   if( !aMode.IsEqual("elem") && !aMode.IsEqual("nodal") && !aMode.IsEqual("none") )
936   {
937     di << "Wrong mode name\n";
938     return 0;
939   }
940
941   Handle(MeshVS_PrsBuilder) aTempBuilder;
942
943   aTempBuilder = aMesh->FindBuilder("MeshVS_VectorPrsBuilder");
944   if( !aTempBuilder.IsNull())
945     aMesh->RemoveBuilderById(aTempBuilder->GetId());
946
947   if( !aMode.IsEqual("none") )
948   {
949     Handle(MeshVS_VectorPrsBuilder) aBuilder = new MeshVS_VectorPrsBuilder( aMesh.operator->(), 
950                                                                             aMaxlen,
951                                                                             aColor,
952                                                                             MeshVS_DMF_VectorDataPrs,
953                                                                             0,
954                                                                             -1,
955                                                                             MeshVS_BP_Vector,
956                                                                             isSimplePrs);
957
958     Standard_Boolean anIsElement = aMode.IsEqual("elem");
959     const TColStd_PackedMapOfInteger& anAllIDs = anIsElement ? aMesh->GetDataSource()->GetAllElements() :
960                                                                aMesh->GetDataSource()->GetAllNodes();
961
962     Standard_Integer aNbNodes;
963     MeshVS_EntityType aEntType;
964
965     TColStd_Array1OfReal aCoords(1, 3);
966     aCoords.Init (0.);
967     TColStd_MapIteratorOfPackedMapOfInteger anIter( anAllIDs );
968     for ( ; anIter.More(); anIter.Next() )
969     {
970       Standard_Boolean IsValidData = Standard_False; 
971       if (anIsElement) {
972         aMesh->GetDataSource()->GetGeomType(anIter.Key(), anIsElement, aEntType);
973         if (aEntType == MeshVS_ET_Face)
974           IsValidData = aMesh->GetDataSource()->GetNormal(anIter.Key(), 3, aCoords.ChangeValue(1), aCoords.ChangeValue(2), aCoords.ChangeValue(3));
975       } else
976         IsValidData = aMesh->GetDataSource()->GetGeom(anIter.Key(), Standard_False, aCoords, aNbNodes, aEntType);
977
978       gp_Vec aNorm;
979       if(IsValidData)
980       { 
981         aNorm = gp_Vec(aCoords.Value(1), aCoords.Value(2), aCoords.Value(3));
982         if(aNorm.Magnitude() < gp::Resolution())
983         {
984           aNorm = gp_Vec(0,0,1); //method GetGeom(...) returns coordinates of nodes
985         }
986       }
987       else
988       {
989         aNorm = gp_Vec(0,0,1);
990       }
991       aBuilder->SetVector(anIsElement, anIter.Key(), aNorm.Normalized());
992     }
993
994     aMesh->AddBuilder( aBuilder, Standard_False );
995     aMesh->GetDrawer()->SetDouble ( MeshVS_DA_VectorArrowPart, anArrowPart );
996   }
997
998   anIC->Redisplay (aMesh, Standard_True);
999
1000   return 0;
1001 }
1002 //-----------------------------------------------------------------------------
1003
1004 static Standard_Integer meshtext( Draw_Interpretor& di,
1005                                   Standard_Integer argc,
1006                                   const char** argv )
1007 {
1008   if ( argc < 2 )
1009   {
1010     di << "Wrong number of parameters\n";
1011     di << "Use : meshtext <mesh name>\n";
1012     return 0;
1013   }
1014
1015   Handle( MeshVS_Mesh ) aMesh = getMesh( argv[ 1 ], di );
1016
1017   if ( aMesh.IsNull() )
1018   {
1019     di << "Mesh not found\n";
1020     return 0;
1021   }
1022
1023   Handle(AIS_InteractiveContext) anIC = ViewerTest::GetAISContext();
1024   if ( anIC.IsNull() )
1025   {
1026     di << "The context is null\n";
1027     return 0;
1028   }
1029
1030   // Prepare triangle labels
1031   MeshVS_DataMapOfIntegerAsciiString aLabels;
1032   Standard_Integer aLen = aMesh->GetDataSource()->GetAllElements().Extent();
1033   for ( Standard_Integer anIndex = 1; anIndex <= aLen; anIndex++ ){
1034     aLabels.Bind( anIndex, TCollection_AsciiString( anIndex ) );
1035   }
1036
1037   Handle(MeshVS_TextPrsBuilder) aTextBuilder = new MeshVS_TextPrsBuilder( aMesh.operator->(), 20., Quantity_NOC_YELLOW );
1038   aTextBuilder->SetTexts( Standard_True, aLabels );
1039   aMesh->AddBuilder( aTextBuilder );
1040
1041   return 0;
1042 }
1043
1044 static Standard_Integer meshdeform( Draw_Interpretor& di,
1045                                     Standard_Integer argc,
1046                                     const char** argv )
1047 {
1048   if ( argc < 3 )
1049   {
1050     di << "Wrong number of parameters\n";
1051     di << "Use : meshdeform <mesh name> < -mode {on|off} > [-scale scalefactor]\n";
1052     return 0;
1053   }
1054
1055   Handle( MeshVS_Mesh ) aMesh = getMesh( argv[ 1 ], di );
1056
1057   if ( aMesh.IsNull() )
1058   {
1059     di << "Mesh not found\n";
1060     return 0;
1061   }
1062   Handle(AIS_InteractiveContext) anIC = ViewerTest::GetAISContext();
1063   if ( anIC.IsNull() )
1064   {
1065     di << "The context is null\n";
1066     return 0;
1067   }
1068
1069   TCollection_AsciiString aParam;
1070   TCollection_AsciiString aMode("off");
1071   Standard_Real           aScale(1.0);
1072
1073   for (Standard_Integer anIdx = 2; anIdx < argc; anIdx++)
1074   {
1075     if (!aParam.IsEmpty())
1076     {
1077       if (aParam == "-mode")
1078       {
1079         aMode = argv[anIdx];
1080       }
1081       else if (aParam == "-scale")
1082       {
1083         aScale = Draw::Atof(argv[anIdx]);
1084       }
1085       aParam.Clear();
1086     }
1087     else if (argv[anIdx][0] == '-')
1088     {
1089       aParam = argv[anIdx];
1090     }
1091   }
1092
1093   if(!aMode.IsEqual("on") && !aMode.IsEqual("off"))
1094   {
1095     di << "Wrong mode name\n";
1096     return 0;
1097   }
1098
1099   Handle ( MeshVS_DeformedDataSource ) aDefDS =
1100     new MeshVS_DeformedDataSource( aMesh->GetDataSource() , aScale );
1101
1102   const TColStd_PackedMapOfInteger& anAllIDs = aMesh->GetDataSource()->GetAllNodes();
1103
1104   Standard_Integer aNbNodes;
1105   MeshVS_EntityType aEntType;
1106
1107   TColStd_MapIteratorOfPackedMapOfInteger anIter( anAllIDs );
1108   for ( ; anIter.More(); anIter.Next() )
1109   {
1110     TColStd_Array1OfReal aCoords(1, 3);
1111     aMesh->GetDataSource()->GetGeom(anIter.Key(), Standard_False, aCoords, aNbNodes, aEntType);
1112
1113     gp_Vec aNorm = gp_Vec(aCoords.Value(1), aCoords.Value(2), aCoords.Value(3));
1114     if( !aNorm.Magnitude() )
1115       aNorm = gp_Vec(0,0,1);
1116     aDefDS->SetVector(anIter.Key(), aNorm.Normalized());
1117   }
1118
1119   aMesh->SetDataSource(aDefDS);
1120
1121   anIC->Redisplay (aMesh, Standard_False);
1122
1123   Handle( V3d_View ) aView = ViewerTest::CurrentView();
1124   if ( !aView.IsNull() )
1125     aView->FitAll();
1126
1127   return 0;
1128 }
1129
1130 static Standard_Integer mesh_edge_width( Draw_Interpretor& di,
1131                                         Standard_Integer argc,
1132                                         const char** argv )
1133 {
1134   try
1135   {
1136     OCC_CATCH_SIGNALS
1137       if ( argc < 3 )
1138       {
1139         di << "Wrong number of parameters\n";
1140         di << "Use : mesh_edge_width <mesh name> <width>\n";
1141         return 0;
1142       }
1143
1144       Handle(MeshVS_Mesh) aMesh = getMesh( argv[ 1 ], di );
1145       if ( aMesh.IsNull() )
1146       {
1147         di << "Mesh not found\n";
1148         return 0;
1149       }
1150
1151       const char* aWidthStr = argv[ 2 ];
1152       if ( aWidthStr == 0 || Draw::Atof( aWidthStr ) <= 0 )
1153       {
1154         di << "Width must be real value more than zero\n";
1155         return 0;
1156       }
1157
1158       double aWidth = Draw::Atof( aWidthStr );
1159
1160       Handle(AIS_InteractiveContext) anIC = ViewerTest::GetAISContext();
1161       if ( anIC.IsNull() )
1162       {
1163         di << "The context is null\n";
1164         return 0;
1165       }
1166
1167       Handle(MeshVS_Drawer) aDrawer = aMesh->GetDrawer();
1168       if ( aDrawer.IsNull() )
1169       {
1170         di << "The drawer is null\n";
1171         return 0;
1172       }
1173
1174       aDrawer->SetDouble( MeshVS_DA_EdgeWidth, aWidth );
1175       anIC->Redisplay (aMesh, Standard_True);
1176   }
1177   catch ( Standard_Failure )
1178   {
1179     di << "Error\n";
1180   }
1181
1182   return 0;
1183 }
1184
1185 //-----------------------------------------------------------------------------
1186
1187 static Standard_Integer meshinfo(Draw_Interpretor& di,
1188                                  Standard_Integer argc,
1189                                  const char** argv)
1190 {
1191   if ( argc != 2 )
1192   {
1193     di << "Wrong number of parameters. Use : meshinfo mesh\n";
1194     return 0;
1195   }
1196
1197   Handle(MeshVS_Mesh) aMesh = getMesh(argv[ 1 ], di);
1198   if ( aMesh.IsNull() )
1199   {
1200     di << "Mesh not found\n";
1201     return 0;
1202   }
1203
1204   Handle(XSDRAWSTLVRML_DataSource) stlMeshSource = Handle(XSDRAWSTLVRML_DataSource)::DownCast(aMesh->GetDataSource());
1205   if (!stlMeshSource.IsNull())
1206   {
1207     const TColStd_PackedMapOfInteger& nodes = stlMeshSource->GetAllNodes();
1208     const TColStd_PackedMapOfInteger& tris  = stlMeshSource->GetAllElements();
1209
1210     di << "Nb nodes = " << nodes.Extent() << "\n";
1211     di << "Nb triangles = " << tris.Extent() << "\n";
1212   }
1213
1214   return 0;
1215 }
1216
1217 //-----------------------------------------------------------------------------
1218
1219 void  XSDRAWSTLVRML::InitCommands (Draw_Interpretor& theCommands)
1220 {
1221   const char* g = "XSTEP-STL/VRML";  // Step transfer file commands
1222   //XSDRAW::LoadDraw(theCommands);
1223
1224   theCommands.Add ("writevrml", "shape file [version VRML#1.0/VRML#2.0 (1/2): 2 by default] [representation shaded/wireframe/both (0/1/2): 1 by default]",__FILE__,writevrml,g);
1225   theCommands.Add ("writestl",  "shape file [ascii/binary (0/1) : 1 by default] [InParallel (0/1) : 0 by default]",__FILE__,writestl,g);
1226   theCommands.Add ("readstl",   "shape file",__FILE__,readstl,g);
1227   theCommands.Add ("loadvrml" , "shape file",__FILE__,loadvrml,g);
1228
1229   theCommands.Add ("meshfromstl",     "creates MeshVS_Mesh from STL file",            __FILE__, createmesh,      g );
1230   theCommands.Add ("mesh3delem",      "creates 3d element mesh to test",              __FILE__, create3d,        g );
1231   theCommands.Add ("meshshadcolor",   "change MeshVS_Mesh shading color",             __FILE__, meshcolor,       g );
1232   theCommands.Add ("meshlinkcolor",   "change MeshVS_Mesh line color",                __FILE__, linecolor,       g );
1233   theCommands.Add ("meshmat",         "change MeshVS_Mesh material and transparency", __FILE__, meshmat,         g );
1234   theCommands.Add ("meshshrcoef",     "change MeshVS_Mesh shrink coeff",              __FILE__, shrink,          g );
1235   theCommands.Add ("meshclosed",      "meshclosed meshname (0/1) \nChange MeshVS_Mesh drawing mode. 0 - not closed object, 1 - closed object", __FILE__, closed, g);
1236   theCommands.Add ("meshshow",        "display MeshVS_Mesh object",                   __FILE__, mdisplay,        g );
1237   theCommands.Add ("meshhide",        "erase MeshVS_Mesh object",                     __FILE__, merase,          g );
1238   theCommands.Add ("meshhidesel",     "hide selected entities",                       __FILE__, hidesel,         g );
1239   theCommands.Add ("meshshowsel",     "show only selected entities",                  __FILE__, showonly,        g );
1240   theCommands.Add ("meshshowall",     "show all entities",                            __FILE__, showall,         g );
1241   theCommands.Add ("meshcolors",      "display color presentation",                   __FILE__, meshcolors,      g );
1242   theCommands.Add ("meshvectors",     "display sample vectors",                       __FILE__, meshvectors,     g );
1243   theCommands.Add ("meshtext",        "display text labels",                          __FILE__, meshtext,        g );
1244   theCommands.Add ("meshdeform",      "display deformed mesh",                        __FILE__, meshdeform,      g );
1245   theCommands.Add ("mesh_edge_width", "set width of edges",                           __FILE__, mesh_edge_width, g );
1246   theCommands.Add ("meshinfo",        "displays the number of nodes and triangles",   __FILE__, meshinfo,        g );
1247 }
1248
1249 //==============================================================================
1250 // XSDRAWSTLVRML::Factory
1251 //==============================================================================
1252 void XSDRAWSTLVRML::Factory(Draw_Interpretor& theDI)
1253 {
1254   XSDRAWIGES::InitSelect();
1255   XSDRAWIGES::InitToBRep(theDI);
1256   XSDRAWIGES::InitFromBRep(theDI);
1257   XSDRAWSTEP::InitCommands(theDI);
1258   XSDRAWSTLVRML::InitCommands(theDI);
1259   XSDRAW::LoadDraw(theDI);
1260 #ifdef OCCT_DEBUG
1261   theDI << "Draw Plugin : All TKXSDRAW commands are loaded\n";
1262 #endif
1263 }
1264
1265 // Declare entry point PLUGINFACTORY
1266 DPLUGIN(XSDRAWSTLVRML)
1267