1 // Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE
3 // Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License.
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 // Lesser General Public License for more details.
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
22 #include <Standard_Stream.hxx>
24 #include "GEOM_IBlocksOperations_i.hh"
26 #include "utilities.h"
28 #include "Utils_ExceptHandlers.hxx"
30 #include "GEOM_Engine.hxx"
31 #include "GEOM_Object.hxx"
33 #include <TColStd_HSequenceOfTransient.hxx>
34 #include <TColStd_HArray1OfInteger.hxx>
36 //=============================================================================
40 //=============================================================================
41 GEOM_IBlocksOperations_i::GEOM_IBlocksOperations_i (PortableServer::POA_ptr thePOA,
42 GEOM::GEOM_Gen_ptr theEngine,
43 ::GEOMImpl_IBlocksOperations* theImpl)
44 :GEOM_IOperations_i(thePOA, theEngine, theImpl)
46 MESSAGE("GEOM_IBlocksOperations_i::GEOM_IBlocksOperations_i");
49 //=============================================================================
53 //=============================================================================
54 GEOM_IBlocksOperations_i::~GEOM_IBlocksOperations_i()
56 MESSAGE("GEOM_IBlocksOperations_i::~GEOM_IBlocksOperations_i");
60 //=============================================================================
64 //=============================================================================
65 GEOM::GEOM_Object_ptr GEOM_IBlocksOperations_i::MakeQuad
66 (GEOM::GEOM_Object_ptr theEdge1, GEOM::GEOM_Object_ptr theEdge2,
67 GEOM::GEOM_Object_ptr theEdge3, GEOM::GEOM_Object_ptr theEdge4)
69 GEOM::GEOM_Object_var aGEOMObject;
72 GetOperations()->SetNotDone();
74 if (theEdge1 == NULL || theEdge2 == NULL ||
75 theEdge3 == NULL || theEdge4 == NULL) return aGEOMObject._retn();
77 //Get the reference edges
78 Handle(GEOM_Object) anEdge1 = GetOperations()->GetEngine()->GetObject
79 (theEdge1->GetStudyID(), theEdge1->GetEntry());
80 Handle(GEOM_Object) anEdge2 = GetOperations()->GetEngine()->GetObject
81 (theEdge2->GetStudyID(), theEdge2->GetEntry());
82 Handle(GEOM_Object) anEdge3 = GetOperations()->GetEngine()->GetObject
83 (theEdge3->GetStudyID(), theEdge3->GetEntry());
84 Handle(GEOM_Object) anEdge4 = GetOperations()->GetEngine()->GetObject
85 (theEdge4->GetStudyID(), theEdge4->GetEntry());
87 if (anEdge1.IsNull() || anEdge2.IsNull() ||
88 anEdge3.IsNull() || anEdge4.IsNull()) return aGEOMObject._retn();
91 Handle(GEOM_Object) anObject =
92 GetOperations()->MakeQuad(anEdge1, anEdge2, anEdge3, anEdge4);
93 if (!GetOperations()->IsDone() || anObject.IsNull())
94 return aGEOMObject._retn();
96 return GetObject(anObject);
99 //=============================================================================
103 //=============================================================================
104 GEOM::GEOM_Object_ptr GEOM_IBlocksOperations_i::MakeQuad2Edges
105 (GEOM::GEOM_Object_ptr theEdge1, GEOM::GEOM_Object_ptr theEdge2)
107 GEOM::GEOM_Object_var aGEOMObject;
109 //Set a not done flag
110 GetOperations()->SetNotDone();
112 if (theEdge1 == NULL || theEdge2 == NULL) return aGEOMObject._retn();
114 //Get the reference edges
115 Handle(GEOM_Object) anEdge1 = GetOperations()->GetEngine()->GetObject
116 (theEdge1->GetStudyID(), theEdge1->GetEntry());
117 Handle(GEOM_Object) anEdge2 = GetOperations()->GetEngine()->GetObject
118 (theEdge2->GetStudyID(), theEdge2->GetEntry());
120 if (anEdge1.IsNull() || anEdge2.IsNull()) return aGEOMObject._retn();
123 Handle(GEOM_Object) anObject =
124 GetOperations()->MakeQuad2Edges(anEdge1, anEdge2);
125 if (!GetOperations()->IsDone() || anObject.IsNull())
126 return aGEOMObject._retn();
128 return GetObject(anObject);
131 //=============================================================================
135 //=============================================================================
136 GEOM::GEOM_Object_ptr GEOM_IBlocksOperations_i::MakeQuad4Vertices
137 (GEOM::GEOM_Object_ptr thePnt1, GEOM::GEOM_Object_ptr thePnt2,
138 GEOM::GEOM_Object_ptr thePnt3, GEOM::GEOM_Object_ptr thePnt4)
140 GEOM::GEOM_Object_var aGEOMObject;
142 //Set a not done flag
143 GetOperations()->SetNotDone();
145 if (thePnt1 == NULL || thePnt2 == NULL ||
146 thePnt3 == NULL || thePnt4 == NULL) return aGEOMObject._retn();
148 //Get the reference points
149 Handle(GEOM_Object) aPnt1 = GetOperations()->GetEngine()->GetObject
150 (thePnt1->GetStudyID(), thePnt1->GetEntry());
151 Handle(GEOM_Object) aPnt2 = GetOperations()->GetEngine()->GetObject
152 (thePnt2->GetStudyID(), thePnt2->GetEntry());
153 Handle(GEOM_Object) aPnt3 = GetOperations()->GetEngine()->GetObject
154 (thePnt3->GetStudyID(), thePnt3->GetEntry());
155 Handle(GEOM_Object) aPnt4 = GetOperations()->GetEngine()->GetObject
156 (thePnt4->GetStudyID(), thePnt4->GetEntry());
158 if (aPnt1.IsNull() || aPnt2.IsNull() ||
159 aPnt3.IsNull() || aPnt4.IsNull()) return aGEOMObject._retn();
162 Handle(GEOM_Object) anObject =
163 GetOperations()->MakeQuad4Vertices(aPnt1, aPnt2, aPnt3, aPnt4);
164 if (!GetOperations()->IsDone() || anObject.IsNull())
165 return aGEOMObject._retn();
167 return GetObject(anObject);
170 //=============================================================================
174 //=============================================================================
175 GEOM::GEOM_Object_ptr GEOM_IBlocksOperations_i::MakeHexa
176 (GEOM::GEOM_Object_ptr theFace1, GEOM::GEOM_Object_ptr theFace2,
177 GEOM::GEOM_Object_ptr theFace3, GEOM::GEOM_Object_ptr theFace4,
178 GEOM::GEOM_Object_ptr theFace5, GEOM::GEOM_Object_ptr theFace6)
180 GEOM::GEOM_Object_var aGEOMObject;
182 //Set a not done flag
183 GetOperations()->SetNotDone();
185 if (theFace1 == NULL || theFace2 == NULL ||
186 theFace3 == NULL || theFace4 == NULL ||
187 theFace5 == NULL || theFace6 == NULL) return aGEOMObject._retn();
189 //Get the reference Faces
190 Handle(GEOM_Object) anFace1 = GetOperations()->GetEngine()->GetObject
191 (theFace1->GetStudyID(), theFace1->GetEntry());
192 Handle(GEOM_Object) anFace2 = GetOperations()->GetEngine()->GetObject
193 (theFace2->GetStudyID(), theFace2->GetEntry());
194 Handle(GEOM_Object) anFace3 = GetOperations()->GetEngine()->GetObject
195 (theFace3->GetStudyID(), theFace3->GetEntry());
196 Handle(GEOM_Object) anFace4 = GetOperations()->GetEngine()->GetObject
197 (theFace4->GetStudyID(), theFace4->GetEntry());
198 Handle(GEOM_Object) anFace5 = GetOperations()->GetEngine()->GetObject
199 (theFace5->GetStudyID(), theFace5->GetEntry());
200 Handle(GEOM_Object) anFace6 = GetOperations()->GetEngine()->GetObject
201 (theFace6->GetStudyID(), theFace6->GetEntry());
203 if (anFace1.IsNull() || anFace2.IsNull() ||
204 anFace3.IsNull() || anFace4.IsNull() ||
205 anFace5.IsNull() || anFace6.IsNull()) return aGEOMObject._retn();
208 Handle(GEOM_Object) anObject = GetOperations()->MakeHexa
209 (anFace1, anFace2, anFace3, anFace4, anFace5, anFace6);
210 if (!GetOperations()->IsDone() || anObject.IsNull())
211 return aGEOMObject._retn();
213 return GetObject(anObject);
216 //=============================================================================
220 //=============================================================================
221 GEOM::GEOM_Object_ptr GEOM_IBlocksOperations_i::MakeHexa2Faces
222 (GEOM::GEOM_Object_ptr theFace1, GEOM::GEOM_Object_ptr theFace2)
224 GEOM::GEOM_Object_var aGEOMObject;
226 //Set a not done flag
227 GetOperations()->SetNotDone();
229 if (theFace1 == NULL || theFace2 == NULL) return aGEOMObject._retn();
231 //Get the reference Faces
232 Handle(GEOM_Object) anFace1 = GetOperations()->GetEngine()->GetObject
233 (theFace1->GetStudyID(), theFace1->GetEntry());
234 Handle(GEOM_Object) anFace2 = GetOperations()->GetEngine()->GetObject
235 (theFace2->GetStudyID(), theFace2->GetEntry());
237 if (anFace1.IsNull() || anFace2.IsNull()) return aGEOMObject._retn();
240 Handle(GEOM_Object) anObject =
241 GetOperations()->MakeHexa2Faces(anFace1, anFace2);
242 if (!GetOperations()->IsDone() || anObject.IsNull())
243 return aGEOMObject._retn();
245 return GetObject(anObject);
248 //=============================================================================
252 //=============================================================================
253 GEOM::GEOM_Object_ptr GEOM_IBlocksOperations_i::MakeBlockCompound
254 (GEOM::GEOM_Object_ptr theCompound)
256 GEOM::GEOM_Object_var aGEOMObject;
258 //Set a not done flag
259 GetOperations()->SetNotDone();
261 if (theCompound == NULL) return aGEOMObject._retn();
263 //Get the reference Compound
264 Handle(GEOM_Object) aCompound = GetOperations()->GetEngine()->GetObject
265 (theCompound->GetStudyID(), theCompound->GetEntry());
267 if (aCompound.IsNull()) return aGEOMObject._retn();
269 //Create the Blocks Compound
270 Handle(GEOM_Object) anObject =
271 GetOperations()->MakeBlockCompound(aCompound);
272 if (!GetOperations()->IsDone() || anObject.IsNull())
273 return aGEOMObject._retn();
275 return GetObject(anObject);
278 //=============================================================================
282 //=============================================================================
283 GEOM::GEOM_Object_ptr GEOM_IBlocksOperations_i::GetPoint (GEOM::GEOM_Object_ptr theShape,
284 const CORBA::Double theX,
285 const CORBA::Double theY,
286 const CORBA::Double theZ,
287 const CORBA::Double theEpsilon)
289 GEOM::GEOM_Object_var aGEOMObject;
291 //Set a not done flag
292 GetOperations()->SetNotDone();
294 if (theShape == NULL) return aGEOMObject._retn();
296 //Get the reference Objects
297 Handle(GEOM_Object) aShape = GetOperations()->GetEngine()->GetObject
298 (theShape->GetStudyID(), theShape->GetEntry());
300 if (aShape.IsNull()) return aGEOMObject._retn();
303 Handle(GEOM_Object) anObject =
304 GetOperations()->GetPoint(aShape, theX, theY, theZ, theEpsilon);
305 if (!GetOperations()->IsDone() || anObject.IsNull())
306 return aGEOMObject._retn();
308 return GetObject(anObject);
311 //=============================================================================
315 //=============================================================================
316 GEOM::GEOM_Object_ptr GEOM_IBlocksOperations_i::GetEdge (GEOM::GEOM_Object_ptr theShape,
317 GEOM::GEOM_Object_ptr thePoint1,
318 GEOM::GEOM_Object_ptr thePoint2)
320 GEOM::GEOM_Object_var aGEOMObject;
322 //Set a not done flag
323 GetOperations()->SetNotDone();
325 if (theShape == NULL ||
326 thePoint1 == NULL || thePoint2 == NULL) return aGEOMObject._retn();
328 //Get the reference Objects
329 Handle(GEOM_Object) aShape = GetOperations()->GetEngine()->GetObject
330 (theShape->GetStudyID(), theShape->GetEntry());
331 Handle(GEOM_Object) aPoint1 = GetOperations()->GetEngine()->GetObject
332 (thePoint1->GetStudyID(), thePoint1->GetEntry());
333 Handle(GEOM_Object) aPoint2 = GetOperations()->GetEngine()->GetObject
334 (thePoint2->GetStudyID(), thePoint2->GetEntry());
336 if (aShape.IsNull() ||
337 aPoint1.IsNull() || aPoint2.IsNull()) return aGEOMObject._retn();
340 Handle(GEOM_Object) anObject =
341 GetOperations()->GetEdge(aShape, aPoint1, aPoint2);
342 if (!GetOperations()->IsDone() || anObject.IsNull())
343 return aGEOMObject._retn();
345 return GetObject(anObject);
348 //=============================================================================
352 //=============================================================================
353 GEOM::GEOM_Object_ptr GEOM_IBlocksOperations_i::GetEdgeNearPoint (GEOM::GEOM_Object_ptr theShape,
354 GEOM::GEOM_Object_ptr thePoint)
356 GEOM::GEOM_Object_var aGEOMObject;
358 //Set a not done flag
359 GetOperations()->SetNotDone();
361 if (theShape == NULL || thePoint == NULL) return aGEOMObject._retn();
363 //Get the reference Objects
364 Handle(GEOM_Object) aShape = GetOperations()->GetEngine()->GetObject
365 (theShape->GetStudyID(), theShape->GetEntry());
366 Handle(GEOM_Object) aPoint = GetOperations()->GetEngine()->GetObject
367 (thePoint->GetStudyID(), thePoint->GetEntry());
369 if (aShape.IsNull() || aPoint.IsNull()) return aGEOMObject._retn();
372 Handle(GEOM_Object) anObject =
373 GetOperations()->GetEdgeNearPoint(aShape, aPoint);
374 if (!GetOperations()->IsDone() || anObject.IsNull())
375 return aGEOMObject._retn();
377 return GetObject(anObject);
380 //=============================================================================
384 //=============================================================================
385 GEOM::GEOM_Object_ptr GEOM_IBlocksOperations_i::GetFaceByPoints
386 (GEOM::GEOM_Object_ptr theShape,
387 GEOM::GEOM_Object_ptr thePoint1,
388 GEOM::GEOM_Object_ptr thePoint2,
389 GEOM::GEOM_Object_ptr thePoint3,
390 GEOM::GEOM_Object_ptr thePoint4)
392 GEOM::GEOM_Object_var aGEOMObject;
394 //Set a not done flag
395 GetOperations()->SetNotDone();
397 if (theShape == NULL ||
398 thePoint1 == NULL || thePoint2 == NULL ||
399 thePoint3 == NULL || thePoint4 == NULL) return aGEOMObject._retn();
401 //Get the reference Objects
402 Handle(GEOM_Object) aShape = GetOperations()->GetEngine()->GetObject
403 (theShape->GetStudyID(), theShape->GetEntry());
404 Handle(GEOM_Object) aPoint1 = GetOperations()->GetEngine()->GetObject
405 (thePoint1->GetStudyID(), thePoint1->GetEntry());
406 Handle(GEOM_Object) aPoint2 = GetOperations()->GetEngine()->GetObject
407 (thePoint2->GetStudyID(), thePoint2->GetEntry());
408 Handle(GEOM_Object) aPoint3 = GetOperations()->GetEngine()->GetObject
409 (thePoint3->GetStudyID(), thePoint3->GetEntry());
410 Handle(GEOM_Object) aPoint4 = GetOperations()->GetEngine()->GetObject
411 (thePoint4->GetStudyID(), thePoint4->GetEntry());
413 if (aShape.IsNull() ||
414 aPoint1.IsNull() || aPoint2.IsNull() ||
415 aPoint3.IsNull() || aPoint4.IsNull()) return aGEOMObject._retn();
418 Handle(GEOM_Object) anObject =
419 GetOperations()->GetFaceByPoints(aShape, aPoint1, aPoint2, aPoint3, aPoint4);
420 if (!GetOperations()->IsDone() || anObject.IsNull())
421 return aGEOMObject._retn();
423 return GetObject(anObject);
426 //=============================================================================
430 //=============================================================================
431 GEOM::GEOM_Object_ptr GEOM_IBlocksOperations_i::GetFaceByEdges
432 (GEOM::GEOM_Object_ptr theShape,
433 GEOM::GEOM_Object_ptr theEdge1,
434 GEOM::GEOM_Object_ptr theEdge2)
436 GEOM::GEOM_Object_var aGEOMObject;
438 //Set a not done flag
439 GetOperations()->SetNotDone();
441 if (theShape == NULL ||
442 theEdge1 == NULL || theEdge2 == NULL) return aGEOMObject._retn();
444 //Get the reference Objects
445 Handle(GEOM_Object) aShape = GetOperations()->GetEngine()->GetObject
446 (theShape->GetStudyID(), theShape->GetEntry());
447 Handle(GEOM_Object) anEdge1 = GetOperations()->GetEngine()->GetObject
448 (theEdge1->GetStudyID(), theEdge1->GetEntry());
449 Handle(GEOM_Object) anEdge2 = GetOperations()->GetEngine()->GetObject
450 (theEdge2->GetStudyID(), theEdge2->GetEntry());
452 if (aShape.IsNull() ||
453 anEdge1.IsNull() || anEdge2.IsNull()) return aGEOMObject._retn();
456 Handle(GEOM_Object) anObject =
457 GetOperations()->GetFaceByEdges(aShape, anEdge1, anEdge2);
458 if (!GetOperations()->IsDone() || anObject.IsNull())
459 return aGEOMObject._retn();
461 return GetObject(anObject);
464 //=============================================================================
468 //=============================================================================
469 GEOM::GEOM_Object_ptr GEOM_IBlocksOperations_i::GetOppositeFace (GEOM::GEOM_Object_ptr theShape,
470 GEOM::GEOM_Object_ptr theFace)
472 GEOM::GEOM_Object_var aGEOMObject;
474 //Set a not done flag
475 GetOperations()->SetNotDone();
477 if (theShape == NULL || theFace == NULL) return aGEOMObject._retn();
479 //Get the reference Objects
480 Handle(GEOM_Object) aShape = GetOperations()->GetEngine()->GetObject
481 (theShape->GetStudyID(), theShape->GetEntry());
482 Handle(GEOM_Object) aFace = GetOperations()->GetEngine()->GetObject
483 (theFace->GetStudyID(), theFace->GetEntry());
485 if (aShape.IsNull() || aFace.IsNull()) return aGEOMObject._retn();
488 Handle(GEOM_Object) anObject =
489 GetOperations()->GetOppositeFace(aShape, aFace);
490 if (!GetOperations()->IsDone() || anObject.IsNull())
491 return aGEOMObject._retn();
493 return GetObject(anObject);
496 //=============================================================================
500 //=============================================================================
501 GEOM::GEOM_Object_ptr GEOM_IBlocksOperations_i::GetFaceNearPoint (GEOM::GEOM_Object_ptr theShape,
502 GEOM::GEOM_Object_ptr thePoint)
504 GEOM::GEOM_Object_var aGEOMObject;
506 //Set a not done flag
507 GetOperations()->SetNotDone();
509 if (theShape == NULL || thePoint == NULL) return aGEOMObject._retn();
511 //Get the reference Objects
512 Handle(GEOM_Object) aShape = GetOperations()->GetEngine()->GetObject
513 (theShape->GetStudyID(), theShape->GetEntry());
514 Handle(GEOM_Object) aPoint = GetOperations()->GetEngine()->GetObject
515 (thePoint->GetStudyID(), thePoint->GetEntry());
517 if (aShape.IsNull() || aPoint.IsNull()) return aGEOMObject._retn();
520 Handle(GEOM_Object) anObject =
521 GetOperations()->GetFaceNearPoint(aShape, aPoint);
522 if (!GetOperations()->IsDone() || anObject.IsNull())
523 return aGEOMObject._retn();
525 return GetObject(anObject);
528 //=============================================================================
532 //=============================================================================
533 GEOM::GEOM_Object_ptr GEOM_IBlocksOperations_i::GetFaceByNormale (GEOM::GEOM_Object_ptr theShape,
534 GEOM::GEOM_Object_ptr theVector)
536 GEOM::GEOM_Object_var aGEOMObject;
538 //Set a not done flag
539 GetOperations()->SetNotDone();
541 if (theShape == NULL || theVector == NULL) return aGEOMObject._retn();
543 //Get the reference Objects
544 Handle(GEOM_Object) aShape = GetOperations()->GetEngine()->GetObject
545 (theShape->GetStudyID(), theShape->GetEntry());
546 Handle(GEOM_Object) aVector = GetOperations()->GetEngine()->GetObject
547 (theVector->GetStudyID(), theVector->GetEntry());
549 if (aShape.IsNull() || aVector.IsNull()) return aGEOMObject._retn();
552 Handle(GEOM_Object) anObject =
553 GetOperations()->GetFaceByNormale(aShape, aVector);
554 if (!GetOperations()->IsDone() || anObject.IsNull())
555 return aGEOMObject._retn();
557 return GetObject(anObject);
560 //=============================================================================
562 * ExplodeCompoundOfBlocks
564 //=============================================================================
565 GEOM::ListOfGO* GEOM_IBlocksOperations_i::ExplodeCompoundOfBlocks
566 (GEOM::GEOM_Object_ptr theCompound,
567 const CORBA::Long theMinNbFaces,
568 const CORBA::Long theMaxNbFaces)
570 GEOM::ListOfGO_var aSeq = new GEOM::ListOfGO;
572 //Set a not done flag
573 GetOperations()->SetNotDone();
575 if (theCompound == NULL) return aSeq._retn();
577 //Get the reference Compound
578 Handle(GEOM_Object) aCompound = GetOperations()->GetEngine()->GetObject
579 (theCompound->GetStudyID(), theCompound->GetEntry());
581 if (aCompound.IsNull()) return aSeq._retn();
584 Handle(TColStd_HSequenceOfTransient) aHSeq =
585 GetOperations()->ExplodeCompoundOfBlocks(aCompound, theMinNbFaces, theMaxNbFaces);
586 if (!GetOperations()->IsDone() || aHSeq.IsNull())
589 Standard_Integer aLength = aHSeq->Length();
590 aSeq->length(aLength);
591 for (Standard_Integer i = 1; i <= aLength; i++)
592 aSeq[i-1] = GetObject(Handle(GEOM_Object)::DownCast(aHSeq->Value(i)));
597 //=============================================================================
601 //=============================================================================
602 CORBA::Boolean GEOM_IBlocksOperations_i::IsCompoundOfBlocks
603 (GEOM::GEOM_Object_ptr theCompound,
604 const CORBA::Long theMinNbFaces,
605 const CORBA::Long theMaxNbFaces,
606 CORBA::Long& theNbBlocks)
609 CORBA::Boolean isComp = false;
611 //Set a not done flag
612 GetOperations()->SetNotDone();
614 if (theCompound == NULL) return isComp;
616 //Get the reference Compound
617 Handle(GEOM_Object) aCompound = GetOperations()->GetEngine()->GetObject
618 (theCompound->GetStudyID(), theCompound->GetEntry());
620 if (aCompound.IsNull()) return isComp;
623 Standard_Integer nbBlocks = 0;
624 isComp = GetOperations()->IsCompoundOfBlocks(aCompound,
628 if (!GetOperations()->IsDone())
631 theNbBlocks = nbBlocks;
635 //=============================================================================
637 * CheckCompoundOfBlocks
639 //=============================================================================
640 CORBA::Boolean GEOM_IBlocksOperations_i::CheckCompoundOfBlocks
641 (GEOM::GEOM_Object_ptr theCompound,
642 GEOM::GEOM_IBlocksOperations::BCErrors_out theErrors)
644 CORBA::Boolean isComp = false;
646 //Set a not done flag
647 GetOperations()->SetNotDone();
649 if (theCompound == NULL) return isComp;
651 //Get the reference Compound
652 Handle(GEOM_Object) aCompound = GetOperations()->GetEngine()->GetObject
653 (theCompound->GetStudyID(), theCompound->GetEntry());
655 if (aCompound.IsNull()) return isComp;
658 list<GEOMImpl_IBlocksOperations::BCError> errList;
659 isComp = GetOperations()->CheckCompoundOfBlocks(aCompound, errList);
660 if (!GetOperations()->IsDone())
663 const int nbErr = errList.size();
664 GEOM::GEOM_IBlocksOperations::BCErrors_var anErrArray =
665 new GEOM::GEOM_IBlocksOperations::BCErrors();
666 anErrArray->length(nbErr);
668 // fill the local CORBA array with values from lists
669 list<GEOMImpl_IBlocksOperations::BCError>::iterator errIt = errList.begin();
671 for (; errIt != errList.end(); i++, errIt++) {
672 GEOM::GEOM_IBlocksOperations::BCError_var anError =
673 new GEOM::GEOM_IBlocksOperations::BCError();
675 GEOMImpl_IBlocksOperations::BCError errStruct = *errIt;
677 switch (errStruct.error) {
678 case GEOMImpl_IBlocksOperations::NOT_BLOCK:
679 anError->error = GEOM::GEOM_IBlocksOperations::NOT_BLOCK;
681 case GEOMImpl_IBlocksOperations::EXTRA_EDGE:
682 anError->error = GEOM::GEOM_IBlocksOperations::EXTRA_EDGE;
684 case GEOMImpl_IBlocksOperations::INVALID_CONNECTION:
685 anError->error = GEOM::GEOM_IBlocksOperations::INVALID_CONNECTION;
687 case GEOMImpl_IBlocksOperations::NOT_CONNECTED:
688 anError->error = GEOM::GEOM_IBlocksOperations::NOT_CONNECTED;
690 case GEOMImpl_IBlocksOperations::NOT_GLUED:
691 anError->error = GEOM::GEOM_IBlocksOperations::NOT_GLUED;
697 list<int> sshList = errStruct.incriminated;
698 GEOM::ListOfLong_var anIncrims = new GEOM::ListOfLong();
699 anIncrims->length(sshList.size());
701 list<int>::iterator sshIt = sshList.begin();
703 for (; sshIt != sshList.end(); jj++, sshIt++) {
704 anIncrims[jj] = *sshIt;
707 anError->incriminated = anIncrims;
709 anErrArray[i] = anError;
712 // initialize out-parameter with local array
713 theErrors = anErrArray._retn();
718 //=============================================================================
722 //=============================================================================
723 char* GEOM_IBlocksOperations_i::PrintBCErrors
724 (GEOM::GEOM_Object_ptr theCompound,
725 const GEOM::GEOM_IBlocksOperations::BCErrors& theErrors)
727 //Get the reference Compound
728 if (theCompound == NULL) return NULL;
729 Handle(GEOM_Object) aCompound = GetOperations()->GetEngine()->GetObject
730 (theCompound->GetStudyID(), theCompound->GetEntry());
731 if (aCompound.IsNull()) return NULL;
733 // Convert the errors sequence
734 list<GEOMImpl_IBlocksOperations::BCError> anErrors;
735 int nbErr = theErrors.length();
737 for (; ie < nbErr; ie++) {
738 const GEOM::GEOM_IBlocksOperations::BCError err = theErrors[ie];
739 const GEOM::GEOM_IBlocksOperations::BCErrorType typ = err.error;
740 const GEOM::ListOfLong incrims = err.incriminated;
742 GEOMImpl_IBlocksOperations::BCError errStruct;
744 case GEOM::GEOM_IBlocksOperations::NOT_BLOCK:
745 errStruct.error = GEOMImpl_IBlocksOperations::NOT_BLOCK;
747 case GEOM::GEOM_IBlocksOperations::EXTRA_EDGE:
748 errStruct.error = GEOMImpl_IBlocksOperations::EXTRA_EDGE;
750 case GEOM::GEOM_IBlocksOperations::INVALID_CONNECTION:
751 errStruct.error = GEOMImpl_IBlocksOperations::INVALID_CONNECTION;
753 case GEOM::GEOM_IBlocksOperations::NOT_CONNECTED:
754 errStruct.error = GEOMImpl_IBlocksOperations::NOT_CONNECTED;
756 case GEOM::GEOM_IBlocksOperations::NOT_GLUED:
757 errStruct.error = GEOMImpl_IBlocksOperations::NOT_GLUED;
764 int aLen = incrims.length();
765 for (; ii < aLen; ii++) {
766 errStruct.incriminated.push_back(incrims[ii]);
769 anErrors.push_back(errStruct);
772 TCollection_AsciiString aDescr = GetOperations()->PrintBCErrors(aCompound, anErrors);
773 return CORBA::string_dup(aDescr.ToCString());
776 //=============================================================================
780 //=============================================================================
781 GEOM::GEOM_Object_ptr GEOM_IBlocksOperations_i::RemoveExtraEdges (GEOM::GEOM_Object_ptr theShape)
783 GEOM::GEOM_Object_var aGEOMObject;
785 //Set a not done flag
786 GetOperations()->SetNotDone();
788 if (theShape == NULL) return aGEOMObject._retn();
790 //Get the reference Objects
791 Handle(GEOM_Object) aShape = GetOperations()->GetEngine()->GetObject
792 (theShape->GetStudyID(), theShape->GetEntry());
794 if (aShape.IsNull()) return aGEOMObject._retn();
797 Handle(GEOM_Object) anObject =
798 GetOperations()->RemoveExtraEdges(aShape);
799 if (!GetOperations()->IsDone() || anObject.IsNull())
800 return aGEOMObject._retn();
802 return GetObject(anObject);
805 //=============================================================================
809 //=============================================================================
810 GEOM::GEOM_Object_ptr GEOM_IBlocksOperations_i::CheckAndImprove (GEOM::GEOM_Object_ptr theCompound)
812 GEOM::GEOM_Object_var aGEOMObject;
814 //Set a not done flag
815 GetOperations()->SetNotDone();
817 if (theCompound == NULL) return aGEOMObject._retn();
819 //Get the reference Objects
820 Handle(GEOM_Object) aCompound = GetOperations()->GetEngine()->GetObject
821 (theCompound->GetStudyID(), theCompound->GetEntry());
823 if (aCompound.IsNull()) return aGEOMObject._retn();
826 Handle(GEOM_Object) anObject =
827 GetOperations()->CheckAndImprove(aCompound);
828 if (!GetOperations()->IsDone() || anObject.IsNull())
829 return aGEOMObject._retn();
831 return GetObject(anObject);
834 //=============================================================================
838 //=============================================================================
839 GEOM::GEOM_Object_ptr GEOM_IBlocksOperations_i::GetBlockNearPoint (GEOM::GEOM_Object_ptr theCompound,
840 GEOM::GEOM_Object_ptr thePoint)
842 GEOM::GEOM_Object_var aGEOMObject;
844 //Set a not done flag
845 GetOperations()->SetNotDone();
847 if (theCompound == NULL || thePoint == NULL) return aGEOMObject._retn();
849 //Get the reference Objects
850 Handle(GEOM_Object) aCompound = GetOperations()->GetEngine()->GetObject
851 (theCompound->GetStudyID(), theCompound->GetEntry());
852 Handle(GEOM_Object) aPoint = GetOperations()->GetEngine()->GetObject
853 (thePoint->GetStudyID(), thePoint->GetEntry());
855 if (aCompound.IsNull() || aPoint.IsNull()) return aGEOMObject._retn();
858 Handle(GEOM_Object) anObject =
859 GetOperations()->GetBlockNearPoint(aCompound, aPoint);
860 if (!GetOperations()->IsDone() || anObject.IsNull())
861 return aGEOMObject._retn();
863 return GetObject(anObject);
866 //=============================================================================
870 //=============================================================================
871 GEOM::GEOM_Object_ptr GEOM_IBlocksOperations_i::GetBlockByParts (GEOM::GEOM_Object_ptr theCompound,
872 const GEOM::ListOfGO& theParts)
874 GEOM::GEOM_Object_var aGEOMObject;
876 //Set a not done flag
877 GetOperations()->SetNotDone();
879 if (theCompound == NULL) return aGEOMObject._retn();
881 //Get the reference Compound
882 Handle(GEOM_Object) aCompound = GetOperations()->GetEngine()->GetObject
883 (theCompound->GetStudyID(), theCompound->GetEntry());
885 if (aCompound.IsNull()) return aGEOMObject._retn();
889 Handle(TColStd_HSequenceOfTransient) aParts = new TColStd_HSequenceOfTransient;
891 aLen = theParts.length();
892 for (ind = 0; ind < aLen; ind++) {
893 if (theParts[ind] == NULL) return aGEOMObject._retn();
894 Handle(GEOM_Object) aSh = GetOperations()->GetEngine()->GetObject
895 (theParts[ind]->GetStudyID(), theParts[ind]->GetEntry());
896 if (aSh.IsNull()) return aGEOMObject._retn();
901 Handle(GEOM_Object) anObject =
902 GetOperations()->GetBlockByParts(aCompound, aParts);
903 if (!GetOperations()->IsDone() || anObject.IsNull())
904 return aGEOMObject._retn();
906 return GetObject(anObject);
909 //=============================================================================
913 //=============================================================================
914 GEOM::ListOfGO* GEOM_IBlocksOperations_i::GetBlocksByParts (GEOM::GEOM_Object_ptr theCompound,
915 const GEOM::ListOfGO& theParts)
917 GEOM::ListOfGO_var aSeq = new GEOM::ListOfGO;
919 //Set a not done flag
920 GetOperations()->SetNotDone();
922 if (theCompound == NULL) return aSeq._retn();
924 //Get the reference Compound
925 Handle(GEOM_Object) aCompound = GetOperations()->GetEngine()->GetObject
926 (theCompound->GetStudyID(), theCompound->GetEntry());
928 if (aCompound.IsNull()) return aSeq._retn();
932 Handle(TColStd_HSequenceOfTransient) aParts = new TColStd_HSequenceOfTransient;
934 aLen = theParts.length();
935 for (ind = 0; ind < aLen; ind++) {
936 if (theParts[ind] == NULL) return aSeq._retn();
937 Handle(GEOM_Object) aSh = GetOperations()->GetEngine()->GetObject
938 (theParts[ind]->GetStudyID(), theParts[ind]->GetEntry());
939 if (aSh.IsNull()) return aSeq._retn();
944 Handle(TColStd_HSequenceOfTransient) aHSeq =
945 GetOperations()->GetBlocksByParts(aCompound, aParts);
946 if (!GetOperations()->IsDone() || aHSeq.IsNull())
949 Standard_Integer aLength = aHSeq->Length();
950 aSeq->length(aLength);
951 for (Standard_Integer i = 1; i <= aLength; i++)
952 aSeq[i-1] = GetObject(Handle(GEOM_Object)::DownCast(aHSeq->Value(i)));
957 //=============================================================================
959 * MakeMultiTransformation1D
961 //=============================================================================
962 GEOM::GEOM_Object_ptr GEOM_IBlocksOperations_i::MakeMultiTransformation1D
963 (GEOM::GEOM_Object_ptr theBlock,
964 const CORBA::Long theDirFace1,
965 const CORBA::Long theDirFace2,
966 const CORBA::Long theNbTimes)
968 GEOM::GEOM_Object_var aGEOMObject;
970 //Set a not done flag
971 GetOperations()->SetNotDone();
973 if (theBlock == NULL) return aGEOMObject._retn();
975 //Get the object itself and the vector of translation
976 Handle(GEOM_Object) aBasicObject = GetOperations()->GetEngine()->GetObject
977 (theBlock->GetStudyID(), theBlock->GetEntry());
979 if (aBasicObject.IsNull()) return aGEOMObject._retn();
981 //Perform the transformation
982 Handle(GEOM_Object) anObject = GetOperations()->MakeMultiTransformation1D
983 (aBasicObject, theDirFace1, theDirFace2, theNbTimes);
984 if (!GetOperations()->IsDone() || anObject.IsNull()) return aGEOMObject._retn();
986 return GetObject(anObject);
989 //=============================================================================
991 * MakeMultiTransformation2D
993 //=============================================================================
994 GEOM::GEOM_Object_ptr GEOM_IBlocksOperations_i::MakeMultiTransformation2D
995 (GEOM::GEOM_Object_ptr theBlock,
996 const CORBA::Long theDirFace1U,
997 const CORBA::Long theDirFace2U,
998 const CORBA::Long theNbTimesU,
999 const CORBA::Long theDirFace1V,
1000 const CORBA::Long theDirFace2V,
1001 const CORBA::Long theNbTimesV)
1003 GEOM::GEOM_Object_var aGEOMObject;
1005 //Set a not done flag
1006 GetOperations()->SetNotDone();
1008 if (theBlock == NULL) return aGEOMObject._retn();
1010 //Get the object itself
1011 Handle(GEOM_Object) aBasicObject = GetOperations()->GetEngine()->GetObject
1012 (theBlock->GetStudyID(), theBlock->GetEntry());
1014 if (aBasicObject.IsNull()) return aGEOMObject._retn();
1016 //Perform the transformation
1017 Handle(GEOM_Object) anObject = GetOperations()->MakeMultiTransformation2D
1019 theDirFace1U, theDirFace2U, theNbTimesU,
1020 theDirFace1V, theDirFace2V, theNbTimesV);
1021 if (!GetOperations()->IsDone() || anObject.IsNull()) return aGEOMObject._retn();
1023 return GetObject(anObject);
1026 //=============================================================================
1030 //=============================================================================
1031 GEOM::ListOfGO* GEOM_IBlocksOperations_i::Propagate (GEOM::GEOM_Object_ptr theShape)
1033 GEOM::ListOfGO_var aSeq = new GEOM::ListOfGO;
1035 //Set a not done flag
1036 GetOperations()->SetNotDone();
1038 if (theShape == NULL) return aSeq._retn();
1040 //Get the reference Shape
1041 Handle(GEOM_Object) aShape = GetOperations()->GetEngine()->GetObject
1042 (theShape->GetStudyID(), theShape->GetEntry());
1044 if (aShape.IsNull()) return aSeq._retn();
1046 //Get the Propagation chains
1047 Handle(TColStd_HSequenceOfTransient) aHSeq =
1048 GetOperations()->Propagate(aShape);
1049 if (!GetOperations()->IsDone() || aHSeq.IsNull())
1050 return aSeq._retn();
1052 Standard_Integer aLength = aHSeq->Length();
1053 aSeq->length(aLength);
1054 for (Standard_Integer i = 1; i <= aLength; i++)
1055 aSeq[i-1] = GetObject(Handle(GEOM_Object)::DownCast(aHSeq->Value(i)));
1057 return aSeq._retn();