Salome HOME
Mantis issue 0021071: Regression in GetInPlace. A fix by PKV on Partition error.
[modules/geom.git] / src / GEOM_I / GEOM_IAdvancedOperations_i.cc
1 //  Copyright (C) 2007-2010  CEA/DEN, EDF R&D, OPEN CASCADE
2 //
3 //  This library is free software; you can redistribute it and/or
4 //  modify it under the terms of the GNU Lesser General Public
5 //  License as published by the Free Software Foundation; either
6 //  version 2.1 of the License.
7 //
8 //  This library is distributed in the hope that it will be useful,
9 //  but WITHOUT ANY WARRANTY; without even the implied warranty of
10 //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
11 //  Lesser General Public License for more details.
12 //
13 //  You should have received a copy of the GNU Lesser General Public
14 //  License along with this library; if not, write to the Free Software
15 //  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
16 //
17 //  See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
18 //
19
20 //  File   : GEOM_IAdvancedOperations.cc
21 //  Author : Vadim SANDLER, Open CASCADE S.A.S. (vadim.sandler@opencascade.com)
22 //
23 #include <Standard_Stream.hxx>
24
25 #include "GEOM_IAdvancedOperations_i.hh"
26
27 #include <utilities.h>
28 #include <OpUtil.hxx>
29 #include <Utils_ExceptHandlers.hxx>
30
31 #include "GEOM_Engine.hxx"
32 #include "GEOM_Object.hxx"
33
34 //=============================================================================
35 /*!
36  *   constructor:
37  */
38 //=============================================================================
39 GEOM_IAdvancedOperations_i::GEOM_IAdvancedOperations_i(PortableServer::POA_ptr thePOA, GEOM::GEOM_Gen_ptr theEngine, ::GEOMImpl_IAdvancedOperations* theImpl)
40 :GEOM_IOperations_i(thePOA, theEngine, theImpl)
41 {
42   MESSAGE("GEOM_IAdvancedOperations_i::GEOM_IAdvancedOperations_i");
43 }
44
45 //=============================================================================
46 /*!
47  *  destructor
48  */
49 //=============================================================================
50 GEOM_IAdvancedOperations_i::~GEOM_IAdvancedOperations_i()
51 {
52   MESSAGE("GEOM_IAdvancedOperations_i::~GEOM_IAdvancedOperations_i");
53 }
54
55 //=============================================================================
56 /*!
57  *  MakePipeTShape
58  *  Create a T-shape object with specified caracteristics for the main and
59  *  the incident pipes (radius, width, half-length).
60  *  Center of the shape is (0,0,0). The main plane of the T-shape is XOY.
61  *  \param theR1 Internal radius of main pipe
62  *  \param theW1 Width of main pipe
63  *  \param theL1 Half-length of main pipe
64  *  \param theR2 Internal radius of incident pipe (R2 < R1)
65  *  \param theW2 Width of incident pipe (R2+W2 < R1+W1)
66  *  \param theL2 Half-length of incident pipe
67  *  \param theHexMesh Boolean indicating if shape is prepared for hex mesh
68  *  \return List of GEOM_Objects, containing the created shape and propagation groups.
69  */
70 //=============================================================================
71 GEOM::ListOfGO* GEOM_IAdvancedOperations_i::MakePipeTShape (CORBA::Double theR1, CORBA::Double theW1, CORBA::Double theL1, 
72                                                               CORBA::Double theR2, CORBA::Double theW2, CORBA::Double theL2, CORBA::Boolean theHexMesh)
73 {
74   GEOM::ListOfGO_var aSeq = new GEOM::ListOfGO;
75
76   //Set a not done flag
77   GetOperations()->SetNotDone();
78
79   //Create the TShape
80   Handle(TColStd_HSequenceOfTransient) aHSeq = GetOperations()->MakePipeTShape(theR1, theW1, theL1, theR2, theW2, theL2, theHexMesh);
81   if (!GetOperations()->IsDone() || aHSeq.IsNull())
82     return aSeq._retn();
83   
84   Standard_Integer aLength = aHSeq->Length();
85   aSeq->length(aLength);
86   for (Standard_Integer i = 1; i <= aLength; i++)
87     aSeq[i-1] = GetObject(Handle(GEOM_Object)::DownCast(aHSeq->Value(i)));
88
89   return aSeq._retn();
90 }
91
92 //=============================================================================
93 /*!
94  *  MakePipeTShapeWithPosition
95  *  Create a T-shape object with specified caracteristics for the main and
96  *  the incident pipes (radius, width, half-length).
97  *  The extremities of the main pipe are located on junctions points P1 and P2.
98  *  The extremity of the incident pipe is located on junction point P3.
99  *  \param theR1 Internal radius of main pipe
100  *  \param theW1 Width of main pipe
101  *  \param theL1 Half-length of main pipe
102  *  \param theR2 Internal radius of incident pipe (R2 < R1)
103  *  \param theW2 Width of incident pipe (R2+W2 < R1+W1)
104  *  \param theL2 Half-length of incident pipe
105  *  \param theHexMesh Boolean indicating if shape is prepared for hex mesh
106  *  \param theP1 1st junction point of main pipe
107  *  \param theP2 2nd junction point of main pipe
108  *  \param theP3 Junction point of incident pipe
109  *  \return List of GEOM_Objects, containing the created shape and propagation groups.
110  */
111 //=============================================================================
112 GEOM::ListOfGO* GEOM_IAdvancedOperations_i::MakePipeTShapeWithPosition (CORBA::Double theR1, CORBA::Double theW1, CORBA::Double theL1, 
113                                                                               CORBA::Double theR2, CORBA::Double theW2, CORBA::Double theL2, CORBA::Boolean theHexMesh,
114                                                                               GEOM::GEOM_Object_ptr theP1, GEOM::GEOM_Object_ptr theP2, GEOM::GEOM_Object_ptr theP3)
115 {
116   GEOM::ListOfGO_var aSeq = new GEOM::ListOfGO;
117
118   //Set a not done flag
119   GetOperations()->SetNotDone();
120
121   //Get the reference vertices
122   Handle(GEOM_Object) aP1 = GetObjectImpl(theP1);
123   Handle(GEOM_Object) aP2 = GetObjectImpl(theP2);
124   Handle(GEOM_Object) aP3 = GetObjectImpl(theP3);
125   if (aP1.IsNull() || aP2.IsNull() || aP3.IsNull())return aSeq._retn();
126
127   //Create the TShape
128   Handle(TColStd_HSequenceOfTransient) aHSeq = GetOperations()->MakePipeTShapeWithPosition(theR1, theW1, theL1, theR2, theW2, theL2, theHexMesh, aP1, aP2, aP3);
129   if (!GetOperations()->IsDone() || aHSeq.IsNull())
130     return aSeq._retn();
131   
132   Standard_Integer aLength = aHSeq->Length();
133   aSeq->length(aLength);
134   for (Standard_Integer i = 1; i <= aLength; i++)
135     aSeq[i-1] = GetObject(Handle(GEOM_Object)::DownCast(aHSeq->Value(i)));
136
137   return aSeq._retn();
138 }
139
140 //=============================================================================
141 /*!
142  *  MakePipeTShapeChamfer
143  *  Create a T-shape object with specified caracteristics for the main and
144  *  the incident pipes (radius, width, half-length). A chamfer is created
145  *  on the junction of the pipes.
146  *  Center of the shape is (0,0,0). The main plane of the T-shape is XOY.
147  *  \param theR1 Internal radius of main pipe
148  *  \param theW1 Width of main pipe
149  *  \param theL1 Half-length of main pipe
150  *  \param theR2 Internal radius of incident pipe (R2 < R1)
151  *  \param theW2 Width of incident pipe (R2+W2 < R1+W1)
152  *  \param theL2 Half-length of incident pipe
153  *  \param theH Height of chamfer.
154  *  \param theW Width of chamfer.
155  *  \param theHexMesh Boolean indicating if shape is prepared for hex mesh
156  *  \return List of GEOM_Objects, containing the created shape and propagation groups.
157  */
158 //=============================================================================
159 GEOM::ListOfGO* GEOM_IAdvancedOperations_i::MakePipeTShapeChamfer(CORBA::Double theR1, CORBA::Double theW1, CORBA::Double theL1, 
160                                                                         CORBA::Double theR2, CORBA::Double theW2, CORBA::Double theL2, 
161                                                                         CORBA::Double theH, CORBA::Double theW, CORBA::Boolean theHexMesh)
162 {
163   GEOM::ListOfGO_var aSeq = new GEOM::ListOfGO;
164
165   //Set a not done flag
166   GetOperations()->SetNotDone();
167
168   //Create the TShape
169   Handle(TColStd_HSequenceOfTransient) aHSeq = GetOperations()->MakePipeTShapeChamfer(theR1, theW1, theL1, theR2, theW2, theL2, theH, theW, theHexMesh);
170   if (!GetOperations()->IsDone() || aHSeq.IsNull())
171     return aSeq._retn();
172   
173   Standard_Integer aLength = aHSeq->Length();
174   aSeq->length(aLength);
175   for (Standard_Integer i = 1; i <= aLength; i++)
176     aSeq[i-1] = GetObject(Handle(GEOM_Object)::DownCast(aHSeq->Value(i)));
177
178   return aSeq._retn();
179 }
180
181 //=============================================================================
182 /*!
183  *  MakePipeTShapeChamferWithPosition
184  *  Create a T-shape object with specified caracteristics for the main and
185  *  the incident pipes (radius, width, half-length). A chamfer is created
186  *  on the junction of the pipes.
187  *  The extremities of the main pipe are located on junctions points P1 and P2.
188  *  The extremity of the incident pipe is located on junction point P3.
189  *  \param theR1 Internal radius of main pipe
190  *  \param theW1 Width of main pipe
191  *  \param theL1 Half-length of main pipe
192  *  \param theR2 Internal radius of incident pipe (R2 < R1)
193  *  \param theW2 Width of incident pipe (R2+W2 < R1+W1)
194  *  \param theL2 Half-length of incident pipe
195  *  \param theH Height of the chamfer.
196  *  \param theW Width of the chamfer.
197  *  \param theHexMesh Boolean indicating if shape is prepared for hex mesh
198  *  \param theP1 1st junction point of main pipe
199  *  \param theP2 2nd junction point of main pipe
200  *  \param theP3 Junction point of incident pipe
201  *  \return List of GEOM_Objects, containing the created shape and propagation groups.
202  */
203 //=============================================================================
204 GEOM::ListOfGO* GEOM_IAdvancedOperations_i::MakePipeTShapeChamferWithPosition (CORBA::Double theR1, CORBA::Double theW1, CORBA::Double theL1, 
205                                                                                      CORBA::Double theR2, CORBA::Double theW2, CORBA::Double theL2, 
206                                                                                      CORBA::Double theH, CORBA::Double theW, CORBA::Boolean theHexMesh,
207                                                                                      GEOM::GEOM_Object_ptr theP1, GEOM::GEOM_Object_ptr theP2, GEOM::GEOM_Object_ptr theP3)
208 {
209   GEOM::ListOfGO_var aSeq = new GEOM::ListOfGO;
210
211   //Set a not done flag
212   GetOperations()->SetNotDone();
213
214   //Get the reference vertices
215   Handle(GEOM_Object) aP1 = GetObjectImpl(theP1);
216   Handle(GEOM_Object) aP2 = GetObjectImpl(theP2);
217   Handle(GEOM_Object) aP3 = GetObjectImpl(theP3);
218
219   //Create the TShape
220   Handle(TColStd_HSequenceOfTransient) aHSeq = GetOperations()->MakePipeTShapeChamferWithPosition(theR1, theW1, theL1, theR2, theW2, theL2, theH, theW,
221                                                                                     theHexMesh, aP1, aP2, aP3);
222   if (!GetOperations()->IsDone() || aHSeq.IsNull())
223     return aSeq._retn();
224   
225   Standard_Integer aLength = aHSeq->Length();
226   aSeq->length(aLength);
227   for (Standard_Integer i = 1; i <= aLength; i++)
228     aSeq[i-1] = GetObject(Handle(GEOM_Object)::DownCast(aHSeq->Value(i)));
229
230   return aSeq._retn();
231 }
232
233 //=============================================================================
234 /*!
235  *  MakePipeTShapeFillet
236  *  Create a T-shape object with specified caracteristics for the main and
237  *  the incident pipes (radius, width, half-length). A fillet is created
238  *  on the junction of the pipes.
239  *  Center of the shape is (0,0,0). The main plane of the T-shape is XOY.
240  *  \param theR1 Internal radius of main pipe
241  *  \param theW1 Width of main pipe
242  *  \param theL1 Half-length of main pipe
243  *  \param theR2 Internal radius of incident pipe (R2 < R1)
244  *  \param theW2 Width of incident pipe (R2+W2 < R1+W1)
245  *  \param theL2 Half-length of incident pipe
246  *  \param theRF Radius of curvature of fillet.
247  *  \param theHexMesh Boolean indicating if shape is prepared for hex mesh
248  *  \return List of GEOM_Objects, containing the created shape and propagation groups.
249  */
250 //=============================================================================
251 GEOM::ListOfGO* GEOM_IAdvancedOperations_i::MakePipeTShapeFillet (CORBA::Double theR1, CORBA::Double theW1, CORBA::Double theL1,
252                                                                         CORBA::Double theR2, CORBA::Double theW2, CORBA::Double theL2, 
253                                                                         CORBA::Double theRF, CORBA::Boolean theHexMesh)
254 {
255   GEOM::ListOfGO_var aSeq = new GEOM::ListOfGO;
256
257   //Set a not done flag
258   GetOperations()->SetNotDone();
259
260   //Create the TShape
261   Handle(TColStd_HSequenceOfTransient) aHSeq = GetOperations()->MakePipeTShapeFillet(theR1, theW1, theL1, theR2, theW2, theL2, theRF, theHexMesh);
262   if (!GetOperations()->IsDone() || aHSeq.IsNull())
263     return aSeq._retn();
264   
265   Standard_Integer aLength = aHSeq->Length();
266   aSeq->length(aLength);
267   for (Standard_Integer i = 1; i <= aLength; i++)
268     aSeq[i-1] = GetObject(Handle(GEOM_Object)::DownCast(aHSeq->Value(i)));
269
270   return aSeq._retn();
271 }
272
273 //=============================================================================
274 /*!
275  *  MakePipeTShapeFilletWithPosition
276  *  Create a T-shape object with specified caracteristics for the main and
277  *  the incident pipes (radius, width, half-length). A fillet is created
278  *  on the junction of the pipes.
279  *  The extremities of the main pipe are located on junctions points P1 and P2.
280  *  The extremity of the incident pipe is located on junction point P3.
281  *  \param theR1 Internal radius of main pipe
282  *  \param theW1 Width of main pipe
283  *  \param theL1 Half-length of main pipe
284  *  \param theR2 Internal radius of incident pipe (R2 < R1)
285  *  \param theW2 Width of incident pipe (R2+W2 < R1+W1)
286  *  \param theL2 Half-length of incident pipe
287  *  \param theRF Radius of curvature of fillet
288  *  \param theHexMesh Boolean indicating if shape is prepared for hex mesh
289  *  \param theP1 1st junction point of main pipe
290  *  \param theP2 2nd junction point of main pipe
291  *  \param theP3 Junction point of incident pipe
292  *  \return List of GEOM_Objects, containing the created shape and propagation groups.
293  */
294 //=============================================================================
295 GEOM::ListOfGO* GEOM_IAdvancedOperations_i::MakePipeTShapeFilletWithPosition (CORBA::Double theR1, CORBA::Double theW1, CORBA::Double theL1,
296                                                                                     CORBA::Double theR2, CORBA::Double theW2, CORBA::Double theL2, 
297                                                                                     CORBA::Double theRF, CORBA::Boolean theHexMesh,
298                                                                                     GEOM::GEOM_Object_ptr theP1, GEOM::GEOM_Object_ptr theP2, GEOM::GEOM_Object_ptr theP3)
299 {
300   GEOM::ListOfGO_var aSeq = new GEOM::ListOfGO;
301
302   //Set a not done flag
303   GetOperations()->SetNotDone();
304
305   //Get the reference vertices
306   Handle(GEOM_Object) aP1 = GetObjectImpl(theP1);
307   Handle(GEOM_Object) aP2 = GetObjectImpl(theP2);
308   Handle(GEOM_Object) aP3 = GetObjectImpl(theP3);
309
310   //Create the TShape
311   Handle(TColStd_HSequenceOfTransient) aHSeq = GetOperations()->MakePipeTShapeFilletWithPosition(theR1, theW1, theL1, theR2, theW2, theL2, theRF, 
312                                                                                    theHexMesh, aP1, aP2, aP3);
313   if (!GetOperations()->IsDone() || aHSeq.IsNull())
314     return aSeq._retn();
315   
316   Standard_Integer aLength = aHSeq->Length();
317   aSeq->length(aLength);
318   for (Standard_Integer i = 1; i <= aLength; i++)
319     aSeq[i-1] = GetObject(Handle(GEOM_Object)::DownCast(aHSeq->Value(i)));
320
321   return aSeq._retn();
322 }
323
324 /*@@ insert new functions before this line @@ do not remove this line @@*/