cf3676c4bf280c9dd406d378345e65573429673f
[occt.git] / src / QANewBRepNaming / QANewBRepNaming_Box.cxx
1 // Created on: 1999-09-24
2 // Created by: Sergey ZARITCHNY
3 // Copyright (c) 1999 Matra Datavision
4 // Copyright (c) 1999-2014 OPEN CASCADE SAS
5 //
6 // This file is part of Open CASCADE Technology software library.
7 //
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.
13 //
14 // Alternatively, this file may be used under the terms of Open CASCADE
15 // commercial license or contractual agreement.
16
17
18 #include <BRepPrimAPI_MakeBox.hxx>
19 #include <QANewBRepNaming_Box.hxx>
20 #include <QANewBRepNaming_Loader.hxx>
21 #include <Standard_NullObject.hxx>
22 #include <TDF_Label.hxx>
23 #include <TNaming_Builder.hxx>
24 #include <TopoDS_Solid.hxx>
25
26 //=======================================================================
27 //function : QANewBRepNaming_Box
28 //purpose  : 
29 //=======================================================================
30 QANewBRepNaming_Box::QANewBRepNaming_Box() {}
31
32 //=======================================================================
33 //function : QANewBRepNaming_Box
34 //purpose  : 
35 //=======================================================================
36
37 QANewBRepNaming_Box::QANewBRepNaming_Box(const TDF_Label& Label)
38      : QANewBRepNaming_TopNaming(Label) {}
39
40 //=======================================================================
41 //function : Init
42 //purpose  : 
43 //=======================================================================
44
45 void QANewBRepNaming_Box::Init(const TDF_Label& Label) {
46   if(Label.IsNull())
47     throw Standard_NullObject("QANewBRepNaming_Box::Init The Result label is Null ...");
48   myResultLabel = Label;
49 }  
50
51 //=======================================================================
52 //function : Load
53 //purpose  : 
54 //=======================================================================
55
56 void QANewBRepNaming_Box::Load (BRepPrimAPI_MakeBox& MS, const QANewBRepNaming_TypeOfPrimitive3D Type) const {
57   //Load the faces of the box :
58   TopoDS_Face BottomFace = MS.BottomFace ();
59   TNaming_Builder BottomFaceIns (Bottom ()); 
60   BottomFaceIns.Generated (BottomFace);
61  
62   TopoDS_Face TopFace = MS.TopFace ();
63   TNaming_Builder TopFaceIns (Top ()); 
64   TopFaceIns.Generated (TopFace); 
65
66   TopoDS_Face FrontFace = MS.FrontFace ();
67   TNaming_Builder FrontFaceIns (Front ()); 
68   FrontFaceIns.Generated (FrontFace); 
69
70   TopoDS_Face RightFace = MS.RightFace ();
71   TNaming_Builder RightFaceIns (Right ()); 
72   RightFaceIns.Generated (RightFace); 
73
74   TopoDS_Face BackFace = MS.BackFace ();
75   TNaming_Builder BackFaceIns (Back ()); 
76   BackFaceIns.Generated (BackFace); 
77
78   TopoDS_Face LeftFace = MS.LeftFace ();
79   TNaming_Builder LeftFaceIns (Left ()); 
80   LeftFaceIns.Generated (LeftFace); 
81
82   TNaming_Builder Builder (ResultLabel());
83   if (Type == QANewBRepNaming_SOLID) Builder.Generated (MS.Solid());
84   else if (Type == QANewBRepNaming_SHELL) Builder.Generated (MS.Shell());
85   else {
86 #ifdef OCCT_DEBUG
87     cout<<"QANewBRepNaming_Box::Load(): Unexpected type of result"<<endl;
88     Builder.Generated (MS.Shape());
89 #endif
90   }
91 }
92
93 //=======================================================================
94 //function : Back
95 //purpose  : 
96 //=======================================================================
97
98 TDF_Label QANewBRepNaming_Box::Back () const {
99   return ResultLabel().FindChild(1,Standard_True); 
100 }
101
102 //=======================================================================
103 //function : Front
104 //purpose  : 
105 //=======================================================================
106
107 TDF_Label QANewBRepNaming_Box::Front () const {
108   return ResultLabel().FindChild(2,Standard_True); 
109 }
110
111 //=======================================================================
112 //function : Left
113 //purpose  : 
114 //=======================================================================
115
116 TDF_Label QANewBRepNaming_Box::Left () const {
117   return ResultLabel().FindChild(3,Standard_True); 
118 }
119
120 //=======================================================================
121 //function : Right
122 //purpose  : 
123 //=======================================================================
124
125 TDF_Label QANewBRepNaming_Box::Right () const {
126   return ResultLabel().FindChild(4,Standard_True); 
127 }
128
129 //=======================================================================
130 //function : Bottom
131 //purpose  : 
132 //=======================================================================
133
134 TDF_Label QANewBRepNaming_Box::Bottom () const {
135   return ResultLabel().FindChild(5,Standard_True); 
136 }
137
138 //=======================================================================
139 //function : Top
140 //purpose  : 
141 //=======================================================================
142
143 TDF_Label QANewBRepNaming_Box::Top () const {
144   return ResultLabel().FindChild(6,Standard_True); 
145 }
146