0031642: Visualization - crash in Graphic3d_Structure::SetVisual() on redisplaying...
[occt.git] / src / DDataStd / DDataStd_NamedShapeCommands.cxx
CommitLineData
b311480e 1// Created on: 1997-07-30
2// Created by: Denis PASCAL
3// Copyright (c) 1997-1999 Matra Datavision
973c2be1 4// Copyright (c) 1999-2014 OPEN CASCADE SAS
b311480e 5//
973c2be1 6// This file is part of Open CASCADE Technology software library.
b311480e 7//
d5f74e42 8// This library is free software; you can redistribute it and/or modify it under
9// the terms of the GNU Lesser General Public License version 2.1 as published
973c2be1 10// by the Free Software Foundation, with special exception defined in the file
11// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
12// distribution for complete text of the license and disclaimer of any warranty.
b311480e 13//
973c2be1 14// Alternatively, this file may be used under the terms of Open CASCADE
15// commercial license or contractual agreement.
7fd59977 16
17#include <DDataStd.hxx>
18#include <DDataStd_DrawPresentation.hxx>
19#include <DDF.hxx>
20#include <Draw_Interpretor.hxx>
21#include <Draw_Appli.hxx>
22
23#include <TDF_Data.hxx>
24#include <TDF_Label.hxx>
25
26#include <DBRep.hxx>
27#include <TopAbs.hxx>
28#include <TopoDS.hxx>
29
30
31// LES ATTRIBUTES
32
33#include <TNaming_NamedShape.hxx>
34#include <TNaming_Builder.hxx>
35#include <TNaming_Tool.hxx>
36
37
38//=======================================================================
39//function : DDataStd_SetShape
40//purpose : SetShape (DF, entry, drawshape)
41//=======================================================================
42
43static Standard_Integer DDataStd_SetShape (Draw_Interpretor& di,
44 Standard_Integer nb,
45 const char** arg)
46{
47 if (nb == 4) {
48 Handle(TDF_Data) DF;
49 if (!DDF::GetDF(arg[1],DF)) return 1;
50 TopoDS_Shape s = DBRep::Get(arg[3]);
586db386 51 if (s.IsNull()) { di <<"shape not found\n"; return 1;}
7fd59977 52 TDF_Label L;
53 DDF::AddLabel(DF, arg[2], L);
54 TNaming_Builder SI (L);
55 SI.Generated(s);
56 return 0;
57 }
586db386 58 di << "DDataStd_SetShape : Error\n";
7fd59977 59 return 1;
60}
61
62
63//=======================================================================
64//function : NamedShapeCommands
65//purpose :
66//=======================================================================
67
68void DDataStd::NamedShapeCommands (Draw_Interpretor& theCommands)
69{
70
71 static Standard_Boolean done = Standard_False;
72 if (done) return;
73 done = Standard_True;
74 const char* g = "DData : Standard Attribute Commands";
75
76
77 theCommands.Add ("SetShape",
78 "SetShape (DF, entry, drawname)",
79 __FILE__, DDataStd_SetShape, g);
80
81}