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