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