1 // Created on: 1999-06-24
2 // Created by: Sergey ZARITCHNY
3 // Copyright (c) 1999-1999 Matra Datavision
4 // Copyright (c) 1999-2014 OPEN CASCADE SAS
6 // This file is part of Open CASCADE Technology software library.
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
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.
14 // Alternatively, this file may be used under the terms of Open CASCADE
15 // commercial license or contractual agreement.
19 #include <Draw_Interpretor.hxx>
20 #include <QADNaming.hxx>
21 #include <BRepTools.hxx>
22 #include <TopoDS_Face.hxx>
23 #include <TopLoc_Location.hxx>
24 #include <BRep_Builder.hxx>
26 #include <gp_Trsf.hxx>
27 #include <BRepTools.hxx>
28 #include <TCollection_AsciiString.hxx>
29 #include <TNaming_Translator.hxx>
30 #include <TopTools_DataMapIteratorOfDataMapOfShapeShape.hxx>
31 #include <DNaming_DataMapOfShapeOfName.hxx>
32 #include <DNaming_DataMapIteratorOfDataMapOfShapeOfName.hxx>
33 #include <TCollection_AsciiString.hxx>
35 #include <TopExp_Explorer.hxx>
36 #include <TopTools_MapOfShape.hxx>
37 #include <TopTools_MapIteratorOfMapOfShape.hxx>
41 //=======================================================================
42 //function : QADNaming_CheckHasSame
43 //purpose : CheckIsSame Shape1 Shape2
44 // - for test ShapeCopy mechanism
45 //=======================================================================
47 static Standard_Integer QADNaming_CheckHasSame (Draw_Interpretor& di,
52 TopoDS_Shape S1 = DBRep::Get(arg[1]);
54 BRep_Builder aBuilder;
55 BRepTools::Read( S1, arg[1], aBuilder);
58 TopoDS_Shape S2 = DBRep::Get(arg[2]);
60 BRep_Builder aBuilder;
61 BRepTools::Read( S2, arg[2], aBuilder);
66 TopAbs_ShapeEnum mod = TopAbs_FACE;
67 if(M[0] == 'F' || M[0] == 'f')
69 else if(M[0] == 'E' || M[0] == 'e')
71 else if(M[0] == 'V' || M[0] == 'v')
76 TopExp_Explorer Exp1, Exp2;
78 TopTools_MapOfShape M1, M2;
79 for(Exp1.Init(S1, mod);Exp1.More();Exp1.Next()) {
80 M1.Add(Exp1.Current());
82 for(Exp2.Init(S2, mod);Exp2.More();Exp2.Next()) {
83 M2.Add(Exp2.Current());
86 TopTools_MapIteratorOfMapOfShape itr1(M1);
87 TopTools_MapIteratorOfMapOfShape itr2;
88 for(;itr1.More();itr1.Next()) {
89 const TopoDS_Shape& s1 = itr1.Key();
91 for(itr2.Initialize(M2);itr2.More();itr2.Next()) {
92 const TopoDS_Shape& s2 = itr2.Key();
94 di << "Shapes " << arg[1]<< " and "<< arg[2]<< " have SAME subshapes\n";
100 //=======================================================================
101 //function : QADNaming_TCopyShape
102 //purpose : CopyShape Shape1 [Shape2 ...]
103 // - for test ShapeCopy mechanism
104 //=======================================================================
106 static Standard_Integer QADNaming_TCopyShape (Draw_Interpretor& di,
110 TNaming_Translator TR;
111 if(nb < 2) return (1);
113 DNaming_DataMapOfShapeOfName aDMapOfShapeOfName;
114 for(Standard_Integer i= 1;i < nb; i++) {
115 TopoDS_Shape S = DBRep::Get(arg[i]);
116 TCollection_AsciiString name(arg[i]);
117 name.AssignCat("_c");
119 BRep_Builder aBuilder;
120 BRepTools::Read( S, arg[i], aBuilder);
124 if(S.IsNull()) return(1);
126 aDMapOfShapeOfName.Bind(S, name);
135 // cout << "QADNaming_CopyShape:: Copy is Done " << endl;
137 DNaming_DataMapIteratorOfDataMapOfShapeOfName itrn(aDMapOfShapeOfName);
138 for(;itrn.More();itrn.Next()) {
139 TCollection_AsciiString name = itrn.Value();
140 const TopoDS_Shape& Result = TR.Copied(itrn.Key());
141 DBRep::Set(name.ToCString(), Result);
142 di.AppendElement(name.ToCString());
146 di << "QADNaming_CopyShape : Error\n";
150 //=======================================================================
151 //function : ToolsCommands
153 //=======================================================================
155 void QADNaming::ToolsCommands (Draw_Interpretor& theCommands)
158 static Standard_Boolean done = Standard_False;
160 done = Standard_True;
161 const char* g = "Naming data commands" ;
163 theCommands.Add ("CopyShape",
164 "CopyShape (Shape1 [Shape2] ...)",
165 __FILE__, QADNaming_TCopyShape, g);
167 theCommands.Add ("CheckSame",
168 "CheckSame (Shape1 Shape2 ExploMode{F|E|V]",
169 __FILE__, QADNaming_CheckHasSame, g);