1 // Copyright (C) 2005 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
2 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
4 // This library is free software; you can redistribute it and/or
5 // modify it under the terms of the GNU Lesser General Public
6 // License as published by the Free Software Foundation; either
7 // version 2.1 of the License.
9 // This library is distributed in the hope that it will be useful
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 // Lesser General Public License for more details.
14 // You should have received a copy of the GNU Lesser General Public
15 // License along with this library; if not, write to the Free Software
16 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
20 #include <Standard_Stream.hxx>
22 #include "GEOM_IBlocksOperations_i.hh"
24 #include "utilities.h"
26 #include "Utils_ExceptHandlers.hxx"
28 #include "GEOM_Engine.hxx"
29 #include "GEOM_Object.hxx"
31 #include <TColStd_HSequenceOfTransient.hxx>
32 #include <TColStd_HArray1OfInteger.hxx>
34 //=============================================================================
38 //=============================================================================
39 GEOM_IBlocksOperations_i::GEOM_IBlocksOperations_i (PortableServer::POA_ptr thePOA,
40 GEOM::GEOM_Gen_ptr theEngine,
41 ::GEOMImpl_IBlocksOperations* theImpl)
42 :GEOM_IOperations_i(thePOA, theEngine, theImpl)
44 MESSAGE("GEOM_IBlocksOperations_i::GEOM_IBlocksOperations_i");
47 //=============================================================================
51 //=============================================================================
52 GEOM_IBlocksOperations_i::~GEOM_IBlocksOperations_i()
54 MESSAGE("GEOM_IBlocksOperations_i::~GEOM_IBlocksOperations_i");
58 //=============================================================================
62 //=============================================================================
63 GEOM::GEOM_Object_ptr GEOM_IBlocksOperations_i::MakeQuad
64 (GEOM::GEOM_Object_ptr theEdge1, GEOM::GEOM_Object_ptr theEdge2,
65 GEOM::GEOM_Object_ptr theEdge3, GEOM::GEOM_Object_ptr theEdge4)
67 GEOM::GEOM_Object_var aGEOMObject;
70 GetOperations()->SetNotDone();
72 if (theEdge1 == NULL || theEdge2 == NULL ||
73 theEdge3 == NULL || theEdge4 == NULL) return aGEOMObject._retn();
75 //Get the reference edges
76 Handle(GEOM_Object) anEdge1 = GetOperations()->GetEngine()->GetObject
77 (theEdge1->GetStudyID(), theEdge1->GetEntry());
78 Handle(GEOM_Object) anEdge2 = GetOperations()->GetEngine()->GetObject
79 (theEdge2->GetStudyID(), theEdge2->GetEntry());
80 Handle(GEOM_Object) anEdge3 = GetOperations()->GetEngine()->GetObject
81 (theEdge3->GetStudyID(), theEdge3->GetEntry());
82 Handle(GEOM_Object) anEdge4 = GetOperations()->GetEngine()->GetObject
83 (theEdge4->GetStudyID(), theEdge4->GetEntry());
85 if (anEdge1.IsNull() || anEdge2.IsNull() ||
86 anEdge3.IsNull() || anEdge4.IsNull()) return aGEOMObject._retn();
89 Handle(GEOM_Object) anObject =
90 GetOperations()->MakeQuad(anEdge1, anEdge2, anEdge3, anEdge4);
91 if (!GetOperations()->IsDone() || anObject.IsNull())
92 return aGEOMObject._retn();
94 return GetObject(anObject);
97 //=============================================================================
101 //=============================================================================
102 GEOM::GEOM_Object_ptr GEOM_IBlocksOperations_i::MakeQuad2Edges
103 (GEOM::GEOM_Object_ptr theEdge1, GEOM::GEOM_Object_ptr theEdge2)
105 GEOM::GEOM_Object_var aGEOMObject;
107 //Set a not done flag
108 GetOperations()->SetNotDone();
110 if (theEdge1 == NULL || theEdge2 == NULL) return aGEOMObject._retn();
112 //Get the reference edges
113 Handle(GEOM_Object) anEdge1 = GetOperations()->GetEngine()->GetObject
114 (theEdge1->GetStudyID(), theEdge1->GetEntry());
115 Handle(GEOM_Object) anEdge2 = GetOperations()->GetEngine()->GetObject
116 (theEdge2->GetStudyID(), theEdge2->GetEntry());
118 if (anEdge1.IsNull() || anEdge2.IsNull()) return aGEOMObject._retn();
121 Handle(GEOM_Object) anObject =
122 GetOperations()->MakeQuad2Edges(anEdge1, anEdge2);
123 if (!GetOperations()->IsDone() || anObject.IsNull())
124 return aGEOMObject._retn();
126 return GetObject(anObject);
129 //=============================================================================
133 //=============================================================================
134 GEOM::GEOM_Object_ptr GEOM_IBlocksOperations_i::MakeQuad4Vertices
135 (GEOM::GEOM_Object_ptr thePnt1, GEOM::GEOM_Object_ptr thePnt2,
136 GEOM::GEOM_Object_ptr thePnt3, GEOM::GEOM_Object_ptr thePnt4)
138 GEOM::GEOM_Object_var aGEOMObject;
140 //Set a not done flag
141 GetOperations()->SetNotDone();
143 if (thePnt1 == NULL || thePnt2 == NULL ||
144 thePnt3 == NULL || thePnt4 == NULL) return aGEOMObject._retn();
146 //Get the reference points
147 Handle(GEOM_Object) aPnt1 = GetOperations()->GetEngine()->GetObject
148 (thePnt1->GetStudyID(), thePnt1->GetEntry());
149 Handle(GEOM_Object) aPnt2 = GetOperations()->GetEngine()->GetObject
150 (thePnt2->GetStudyID(), thePnt2->GetEntry());
151 Handle(GEOM_Object) aPnt3 = GetOperations()->GetEngine()->GetObject
152 (thePnt3->GetStudyID(), thePnt3->GetEntry());
153 Handle(GEOM_Object) aPnt4 = GetOperations()->GetEngine()->GetObject
154 (thePnt4->GetStudyID(), thePnt4->GetEntry());
156 if (aPnt1.IsNull() || aPnt2.IsNull() ||
157 aPnt3.IsNull() || aPnt4.IsNull()) return aGEOMObject._retn();
160 Handle(GEOM_Object) anObject =
161 GetOperations()->MakeQuad4Vertices(aPnt1, aPnt2, aPnt3, aPnt4);
162 if (!GetOperations()->IsDone() || anObject.IsNull())
163 return aGEOMObject._retn();
165 return GetObject(anObject);
168 //=============================================================================
172 //=============================================================================
173 GEOM::GEOM_Object_ptr GEOM_IBlocksOperations_i::MakeHexa
174 (GEOM::GEOM_Object_ptr theFace1, GEOM::GEOM_Object_ptr theFace2,
175 GEOM::GEOM_Object_ptr theFace3, GEOM::GEOM_Object_ptr theFace4,
176 GEOM::GEOM_Object_ptr theFace5, GEOM::GEOM_Object_ptr theFace6)
178 GEOM::GEOM_Object_var aGEOMObject;
180 //Set a not done flag
181 GetOperations()->SetNotDone();
183 if (theFace1 == NULL || theFace2 == NULL ||
184 theFace3 == NULL || theFace4 == NULL ||
185 theFace5 == NULL || theFace6 == NULL) return aGEOMObject._retn();
187 //Get the reference Faces
188 Handle(GEOM_Object) anFace1 = GetOperations()->GetEngine()->GetObject
189 (theFace1->GetStudyID(), theFace1->GetEntry());
190 Handle(GEOM_Object) anFace2 = GetOperations()->GetEngine()->GetObject
191 (theFace2->GetStudyID(), theFace2->GetEntry());
192 Handle(GEOM_Object) anFace3 = GetOperations()->GetEngine()->GetObject
193 (theFace3->GetStudyID(), theFace3->GetEntry());
194 Handle(GEOM_Object) anFace4 = GetOperations()->GetEngine()->GetObject
195 (theFace4->GetStudyID(), theFace4->GetEntry());
196 Handle(GEOM_Object) anFace5 = GetOperations()->GetEngine()->GetObject
197 (theFace5->GetStudyID(), theFace5->GetEntry());
198 Handle(GEOM_Object) anFace6 = GetOperations()->GetEngine()->GetObject
199 (theFace6->GetStudyID(), theFace6->GetEntry());
201 if (anFace1.IsNull() || anFace2.IsNull() ||
202 anFace3.IsNull() || anFace4.IsNull() ||
203 anFace5.IsNull() || anFace6.IsNull()) return aGEOMObject._retn();
206 Handle(GEOM_Object) anObject = GetOperations()->MakeHexa
207 (anFace1, anFace2, anFace3, anFace4, anFace5, anFace6);
208 if (!GetOperations()->IsDone() || anObject.IsNull())
209 return aGEOMObject._retn();
211 return GetObject(anObject);
214 //=============================================================================
218 //=============================================================================
219 GEOM::GEOM_Object_ptr GEOM_IBlocksOperations_i::MakeHexa2Faces
220 (GEOM::GEOM_Object_ptr theFace1, GEOM::GEOM_Object_ptr theFace2)
222 GEOM::GEOM_Object_var aGEOMObject;
224 //Set a not done flag
225 GetOperations()->SetNotDone();
227 if (theFace1 == NULL || theFace2 == NULL) return aGEOMObject._retn();
229 //Get the reference Faces
230 Handle(GEOM_Object) anFace1 = GetOperations()->GetEngine()->GetObject
231 (theFace1->GetStudyID(), theFace1->GetEntry());
232 Handle(GEOM_Object) anFace2 = GetOperations()->GetEngine()->GetObject
233 (theFace2->GetStudyID(), theFace2->GetEntry());
235 if (anFace1.IsNull() || anFace2.IsNull()) return aGEOMObject._retn();
238 Handle(GEOM_Object) anObject =
239 GetOperations()->MakeHexa2Faces(anFace1, anFace2);
240 if (!GetOperations()->IsDone() || anObject.IsNull())
241 return aGEOMObject._retn();
243 return GetObject(anObject);
246 //=============================================================================
250 //=============================================================================
251 GEOM::GEOM_Object_ptr GEOM_IBlocksOperations_i::MakeBlockCompound
252 (GEOM::GEOM_Object_ptr theCompound)
254 GEOM::GEOM_Object_var aGEOMObject;
256 //Set a not done flag
257 GetOperations()->SetNotDone();
259 if (theCompound == NULL) return aGEOMObject._retn();
261 //Get the reference Compound
262 Handle(GEOM_Object) aCompound = GetOperations()->GetEngine()->GetObject
263 (theCompound->GetStudyID(), theCompound->GetEntry());
265 if (aCompound.IsNull()) return aGEOMObject._retn();
267 //Create the Blocks Compound
268 Handle(GEOM_Object) anObject =
269 GetOperations()->MakeBlockCompound(aCompound);
270 if (!GetOperations()->IsDone() || anObject.IsNull())
271 return aGEOMObject._retn();
273 return GetObject(anObject);
276 //=============================================================================
280 //=============================================================================
281 GEOM::GEOM_Object_ptr GEOM_IBlocksOperations_i::GetPoint (GEOM::GEOM_Object_ptr theShape,
282 const CORBA::Double theX,
283 const CORBA::Double theY,
284 const CORBA::Double theZ,
285 const CORBA::Double theEpsilon)
287 GEOM::GEOM_Object_var aGEOMObject;
289 //Set a not done flag
290 GetOperations()->SetNotDone();
292 if (theShape == NULL) return aGEOMObject._retn();
294 //Get the reference Objects
295 Handle(GEOM_Object) aShape = GetOperations()->GetEngine()->GetObject
296 (theShape->GetStudyID(), theShape->GetEntry());
298 if (aShape.IsNull()) return aGEOMObject._retn();
301 Handle(GEOM_Object) anObject =
302 GetOperations()->GetPoint(aShape, theX, theY, theZ, theEpsilon);
303 if (!GetOperations()->IsDone() || anObject.IsNull())
304 return aGEOMObject._retn();
306 return GetObject(anObject);
309 //=============================================================================
313 //=============================================================================
314 GEOM::GEOM_Object_ptr GEOM_IBlocksOperations_i::GetEdge (GEOM::GEOM_Object_ptr theShape,
315 GEOM::GEOM_Object_ptr thePoint1,
316 GEOM::GEOM_Object_ptr thePoint2)
318 GEOM::GEOM_Object_var aGEOMObject;
320 //Set a not done flag
321 GetOperations()->SetNotDone();
323 if (theShape == NULL ||
324 thePoint1 == NULL || thePoint2 == NULL) return aGEOMObject._retn();
326 //Get the reference Objects
327 Handle(GEOM_Object) aShape = GetOperations()->GetEngine()->GetObject
328 (theShape->GetStudyID(), theShape->GetEntry());
329 Handle(GEOM_Object) aPoint1 = GetOperations()->GetEngine()->GetObject
330 (thePoint1->GetStudyID(), thePoint1->GetEntry());
331 Handle(GEOM_Object) aPoint2 = GetOperations()->GetEngine()->GetObject
332 (thePoint2->GetStudyID(), thePoint2->GetEntry());
334 if (aShape.IsNull() ||
335 aPoint1.IsNull() || aPoint2.IsNull()) return aGEOMObject._retn();
338 Handle(GEOM_Object) anObject =
339 GetOperations()->GetEdge(aShape, aPoint1, aPoint2);
340 if (!GetOperations()->IsDone() || anObject.IsNull())
341 return aGEOMObject._retn();
343 return GetObject(anObject);
346 //=============================================================================
350 //=============================================================================
351 GEOM::GEOM_Object_ptr GEOM_IBlocksOperations_i::GetEdgeNearPoint (GEOM::GEOM_Object_ptr theShape,
352 GEOM::GEOM_Object_ptr thePoint)
354 GEOM::GEOM_Object_var aGEOMObject;
356 //Set a not done flag
357 GetOperations()->SetNotDone();
359 if (theShape == NULL || thePoint == NULL) return aGEOMObject._retn();
361 //Get the reference Objects
362 Handle(GEOM_Object) aShape = GetOperations()->GetEngine()->GetObject
363 (theShape->GetStudyID(), theShape->GetEntry());
364 Handle(GEOM_Object) aPoint = GetOperations()->GetEngine()->GetObject
365 (thePoint->GetStudyID(), thePoint->GetEntry());
367 if (aShape.IsNull() || aPoint.IsNull()) return aGEOMObject._retn();
370 Handle(GEOM_Object) anObject =
371 GetOperations()->GetEdgeNearPoint(aShape, aPoint);
372 if (!GetOperations()->IsDone() || anObject.IsNull())
373 return aGEOMObject._retn();
375 return GetObject(anObject);
378 //=============================================================================
382 //=============================================================================
383 GEOM::GEOM_Object_ptr GEOM_IBlocksOperations_i::GetFaceByPoints
384 (GEOM::GEOM_Object_ptr theShape,
385 GEOM::GEOM_Object_ptr thePoint1,
386 GEOM::GEOM_Object_ptr thePoint2,
387 GEOM::GEOM_Object_ptr thePoint3,
388 GEOM::GEOM_Object_ptr thePoint4)
390 GEOM::GEOM_Object_var aGEOMObject;
392 //Set a not done flag
393 GetOperations()->SetNotDone();
395 if (theShape == NULL ||
396 thePoint1 == NULL || thePoint2 == NULL ||
397 thePoint3 == NULL || thePoint4 == NULL) return aGEOMObject._retn();
399 //Get the reference Objects
400 Handle(GEOM_Object) aShape = GetOperations()->GetEngine()->GetObject
401 (theShape->GetStudyID(), theShape->GetEntry());
402 Handle(GEOM_Object) aPoint1 = GetOperations()->GetEngine()->GetObject
403 (thePoint1->GetStudyID(), thePoint1->GetEntry());
404 Handle(GEOM_Object) aPoint2 = GetOperations()->GetEngine()->GetObject
405 (thePoint2->GetStudyID(), thePoint2->GetEntry());
406 Handle(GEOM_Object) aPoint3 = GetOperations()->GetEngine()->GetObject
407 (thePoint3->GetStudyID(), thePoint3->GetEntry());
408 Handle(GEOM_Object) aPoint4 = GetOperations()->GetEngine()->GetObject
409 (thePoint4->GetStudyID(), thePoint4->GetEntry());
411 if (aShape.IsNull() ||
412 aPoint1.IsNull() || aPoint2.IsNull() ||
413 aPoint3.IsNull() || aPoint4.IsNull()) return aGEOMObject._retn();
416 Handle(GEOM_Object) anObject =
417 GetOperations()->GetFaceByPoints(aShape, aPoint1, aPoint2, aPoint3, aPoint4);
418 if (!GetOperations()->IsDone() || anObject.IsNull())
419 return aGEOMObject._retn();
421 return GetObject(anObject);
424 //=============================================================================
428 //=============================================================================
429 GEOM::GEOM_Object_ptr GEOM_IBlocksOperations_i::GetFaceByEdges
430 (GEOM::GEOM_Object_ptr theShape,
431 GEOM::GEOM_Object_ptr theEdge1,
432 GEOM::GEOM_Object_ptr theEdge2)
434 GEOM::GEOM_Object_var aGEOMObject;
436 //Set a not done flag
437 GetOperations()->SetNotDone();
439 if (theShape == NULL ||
440 theEdge1 == NULL || theEdge2 == NULL) return aGEOMObject._retn();
442 //Get the reference Objects
443 Handle(GEOM_Object) aShape = GetOperations()->GetEngine()->GetObject
444 (theShape->GetStudyID(), theShape->GetEntry());
445 Handle(GEOM_Object) anEdge1 = GetOperations()->GetEngine()->GetObject
446 (theEdge1->GetStudyID(), theEdge1->GetEntry());
447 Handle(GEOM_Object) anEdge2 = GetOperations()->GetEngine()->GetObject
448 (theEdge2->GetStudyID(), theEdge2->GetEntry());
450 if (aShape.IsNull() ||
451 anEdge1.IsNull() || anEdge2.IsNull()) return aGEOMObject._retn();
454 Handle(GEOM_Object) anObject =
455 GetOperations()->GetFaceByEdges(aShape, anEdge1, anEdge2);
456 if (!GetOperations()->IsDone() || anObject.IsNull())
457 return aGEOMObject._retn();
459 return GetObject(anObject);
462 //=============================================================================
466 //=============================================================================
467 GEOM::GEOM_Object_ptr GEOM_IBlocksOperations_i::GetOppositeFace (GEOM::GEOM_Object_ptr theShape,
468 GEOM::GEOM_Object_ptr theFace)
470 GEOM::GEOM_Object_var aGEOMObject;
472 //Set a not done flag
473 GetOperations()->SetNotDone();
475 if (theShape == NULL || theFace == NULL) return aGEOMObject._retn();
477 //Get the reference Objects
478 Handle(GEOM_Object) aShape = GetOperations()->GetEngine()->GetObject
479 (theShape->GetStudyID(), theShape->GetEntry());
480 Handle(GEOM_Object) aFace = GetOperations()->GetEngine()->GetObject
481 (theFace->GetStudyID(), theFace->GetEntry());
483 if (aShape.IsNull() || aFace.IsNull()) return aGEOMObject._retn();
486 Handle(GEOM_Object) anObject =
487 GetOperations()->GetOppositeFace(aShape, aFace);
488 if (!GetOperations()->IsDone() || anObject.IsNull())
489 return aGEOMObject._retn();
491 return GetObject(anObject);
494 //=============================================================================
498 //=============================================================================
499 GEOM::GEOM_Object_ptr GEOM_IBlocksOperations_i::GetFaceNearPoint (GEOM::GEOM_Object_ptr theShape,
500 GEOM::GEOM_Object_ptr thePoint)
502 GEOM::GEOM_Object_var aGEOMObject;
504 //Set a not done flag
505 GetOperations()->SetNotDone();
507 if (theShape == NULL || thePoint == NULL) return aGEOMObject._retn();
509 //Get the reference Objects
510 Handle(GEOM_Object) aShape = GetOperations()->GetEngine()->GetObject
511 (theShape->GetStudyID(), theShape->GetEntry());
512 Handle(GEOM_Object) aPoint = GetOperations()->GetEngine()->GetObject
513 (thePoint->GetStudyID(), thePoint->GetEntry());
515 if (aShape.IsNull() || aPoint.IsNull()) return aGEOMObject._retn();
518 Handle(GEOM_Object) anObject =
519 GetOperations()->GetFaceNearPoint(aShape, aPoint);
520 if (!GetOperations()->IsDone() || anObject.IsNull())
521 return aGEOMObject._retn();
523 return GetObject(anObject);
526 //=============================================================================
530 //=============================================================================
531 GEOM::GEOM_Object_ptr GEOM_IBlocksOperations_i::GetFaceByNormale (GEOM::GEOM_Object_ptr theShape,
532 GEOM::GEOM_Object_ptr theVector)
534 GEOM::GEOM_Object_var aGEOMObject;
536 //Set a not done flag
537 GetOperations()->SetNotDone();
539 if (theShape == NULL || theVector == NULL) return aGEOMObject._retn();
541 //Get the reference Objects
542 Handle(GEOM_Object) aShape = GetOperations()->GetEngine()->GetObject
543 (theShape->GetStudyID(), theShape->GetEntry());
544 Handle(GEOM_Object) aVector = GetOperations()->GetEngine()->GetObject
545 (theVector->GetStudyID(), theVector->GetEntry());
547 if (aShape.IsNull() || aVector.IsNull()) return aGEOMObject._retn();
550 Handle(GEOM_Object) anObject =
551 GetOperations()->GetFaceByNormale(aShape, aVector);
552 if (!GetOperations()->IsDone() || anObject.IsNull())
553 return aGEOMObject._retn();
555 return GetObject(anObject);
558 //=============================================================================
560 * ExplodeCompoundOfBlocks
562 //=============================================================================
563 GEOM::ListOfGO* GEOM_IBlocksOperations_i::ExplodeCompoundOfBlocks
564 (GEOM::GEOM_Object_ptr theCompound,
565 const CORBA::Long theMinNbFaces,
566 const CORBA::Long theMaxNbFaces)
568 GEOM::ListOfGO_var aSeq = new GEOM::ListOfGO;
570 //Set a not done flag
571 GetOperations()->SetNotDone();
573 if (theCompound == NULL) return aSeq._retn();
575 //Get the reference Compound
576 Handle(GEOM_Object) aCompound = GetOperations()->GetEngine()->GetObject
577 (theCompound->GetStudyID(), theCompound->GetEntry());
579 if (aCompound.IsNull()) return aSeq._retn();
582 Handle(TColStd_HSequenceOfTransient) aHSeq =
583 GetOperations()->ExplodeCompoundOfBlocks(aCompound, theMinNbFaces, theMaxNbFaces);
584 if (!GetOperations()->IsDone() || aHSeq.IsNull())
587 Standard_Integer aLength = aHSeq->Length();
588 aSeq->length(aLength);
589 for (Standard_Integer i = 1; i <= aLength; i++)
590 aSeq[i-1] = GetObject(Handle(GEOM_Object)::DownCast(aHSeq->Value(i)));
595 //=============================================================================
599 //=============================================================================
600 CORBA::Boolean GEOM_IBlocksOperations_i::IsCompoundOfBlocks
601 (GEOM::GEOM_Object_ptr theCompound,
602 const CORBA::Long theMinNbFaces,
603 const CORBA::Long theMaxNbFaces,
604 CORBA::Long& theNbBlocks)
607 CORBA::Boolean isComp = false;
609 //Set a not done flag
610 GetOperations()->SetNotDone();
612 if (theCompound == NULL) return isComp;
614 //Get the reference Compound
615 Handle(GEOM_Object) aCompound = GetOperations()->GetEngine()->GetObject
616 (theCompound->GetStudyID(), theCompound->GetEntry());
618 if (aCompound.IsNull()) return isComp;
621 Standard_Integer nbBlocks = 0;
622 isComp = GetOperations()->IsCompoundOfBlocks(aCompound,
626 if (!GetOperations()->IsDone())
629 theNbBlocks = nbBlocks;
633 //=============================================================================
635 * CheckCompoundOfBlocks
637 //=============================================================================
638 CORBA::Boolean GEOM_IBlocksOperations_i::CheckCompoundOfBlocks
639 (GEOM::GEOM_Object_ptr theCompound,
640 GEOM::GEOM_IBlocksOperations::BCErrors_out theErrors)
642 CORBA::Boolean isComp = false;
644 //Set a not done flag
645 GetOperations()->SetNotDone();
647 if (theCompound == NULL) return isComp;
649 //Get the reference Compound
650 Handle(GEOM_Object) aCompound = GetOperations()->GetEngine()->GetObject
651 (theCompound->GetStudyID(), theCompound->GetEntry());
653 if (aCompound.IsNull()) return isComp;
656 list<GEOMImpl_IBlocksOperations::BCError> errList;
657 isComp = GetOperations()->CheckCompoundOfBlocks(aCompound, errList);
658 if (!GetOperations()->IsDone())
661 const int nbErr = errList.size();
662 GEOM::GEOM_IBlocksOperations::BCErrors_var anErrArray =
663 new GEOM::GEOM_IBlocksOperations::BCErrors();
664 anErrArray->length(nbErr);
666 // fill the local CORBA array with values from lists
667 list<GEOMImpl_IBlocksOperations::BCError>::iterator errIt = errList.begin();
669 for (; errIt != errList.end(); i++, errIt++) {
670 GEOM::GEOM_IBlocksOperations::BCError_var anError =
671 new GEOM::GEOM_IBlocksOperations::BCError();
673 GEOMImpl_IBlocksOperations::BCError errStruct = *errIt;
675 switch (errStruct.error) {
676 case GEOMImpl_IBlocksOperations::NOT_BLOCK:
677 anError->error = GEOM::GEOM_IBlocksOperations::NOT_BLOCK;
679 case GEOMImpl_IBlocksOperations::EXTRA_EDGE:
680 anError->error = GEOM::GEOM_IBlocksOperations::EXTRA_EDGE;
682 case GEOMImpl_IBlocksOperations::INVALID_CONNECTION:
683 anError->error = GEOM::GEOM_IBlocksOperations::INVALID_CONNECTION;
685 case GEOMImpl_IBlocksOperations::NOT_CONNECTED:
686 anError->error = GEOM::GEOM_IBlocksOperations::NOT_CONNECTED;
688 case GEOMImpl_IBlocksOperations::NOT_GLUED:
689 anError->error = GEOM::GEOM_IBlocksOperations::NOT_GLUED;
695 list<int> sshList = errStruct.incriminated;
696 GEOM::ListOfLong_var anIncrims = new GEOM::ListOfLong();
697 anIncrims->length(sshList.size());
699 list<int>::iterator sshIt = sshList.begin();
701 for (; sshIt != sshList.end(); jj++, sshIt++) {
702 anIncrims[jj] = *sshIt;
705 anError->incriminated = anIncrims;
707 anErrArray[i] = anError;
710 // initialize out-parameter with local array
711 theErrors = anErrArray._retn();
716 //=============================================================================
720 //=============================================================================
721 char* GEOM_IBlocksOperations_i::PrintBCErrors
722 (GEOM::GEOM_Object_ptr theCompound,
723 const GEOM::GEOM_IBlocksOperations::BCErrors& theErrors)
725 //Get the reference Compound
726 if (theCompound == NULL) return NULL;
727 Handle(GEOM_Object) aCompound = GetOperations()->GetEngine()->GetObject
728 (theCompound->GetStudyID(), theCompound->GetEntry());
729 if (aCompound.IsNull()) return NULL;
731 // Convert the errors sequence
732 list<GEOMImpl_IBlocksOperations::BCError> anErrors;
733 int nbErr = theErrors.length();
735 for (; ie < nbErr; ie++) {
736 const GEOM::GEOM_IBlocksOperations::BCError err = theErrors[ie];
737 const GEOM::GEOM_IBlocksOperations::BCErrorType typ = err.error;
738 const GEOM::ListOfLong incrims = err.incriminated;
740 GEOMImpl_IBlocksOperations::BCError errStruct;
742 case GEOM::GEOM_IBlocksOperations::NOT_BLOCK:
743 errStruct.error = GEOMImpl_IBlocksOperations::NOT_BLOCK;
745 case GEOM::GEOM_IBlocksOperations::EXTRA_EDGE:
746 errStruct.error = GEOMImpl_IBlocksOperations::EXTRA_EDGE;
748 case GEOM::GEOM_IBlocksOperations::INVALID_CONNECTION:
749 errStruct.error = GEOMImpl_IBlocksOperations::INVALID_CONNECTION;
751 case GEOM::GEOM_IBlocksOperations::NOT_CONNECTED:
752 errStruct.error = GEOMImpl_IBlocksOperations::NOT_CONNECTED;
754 case GEOM::GEOM_IBlocksOperations::NOT_GLUED:
755 errStruct.error = GEOMImpl_IBlocksOperations::NOT_GLUED;
762 int aLen = incrims.length();
763 for (; ii < aLen; ii++) {
764 errStruct.incriminated.push_back(incrims[ii]);
767 anErrors.push_back(errStruct);
770 TCollection_AsciiString aDescr = GetOperations()->PrintBCErrors(aCompound, anErrors);
771 return CORBA::string_dup(aDescr.ToCString());
774 //=============================================================================
778 //=============================================================================
779 GEOM::GEOM_Object_ptr GEOM_IBlocksOperations_i::RemoveExtraEdges (GEOM::GEOM_Object_ptr theShape)
781 GEOM::GEOM_Object_var aGEOMObject;
783 //Set a not done flag
784 GetOperations()->SetNotDone();
786 if (theShape == NULL) return aGEOMObject._retn();
788 //Get the reference Objects
789 Handle(GEOM_Object) aShape = GetOperations()->GetEngine()->GetObject
790 (theShape->GetStudyID(), theShape->GetEntry());
792 if (aShape.IsNull()) return aGEOMObject._retn();
795 Handle(GEOM_Object) anObject =
796 GetOperations()->RemoveExtraEdges(aShape);
797 if (!GetOperations()->IsDone() || anObject.IsNull())
798 return aGEOMObject._retn();
800 return GetObject(anObject);
803 //=============================================================================
807 //=============================================================================
808 GEOM::GEOM_Object_ptr GEOM_IBlocksOperations_i::CheckAndImprove (GEOM::GEOM_Object_ptr theCompound)
810 GEOM::GEOM_Object_var aGEOMObject;
812 //Set a not done flag
813 GetOperations()->SetNotDone();
815 if (theCompound == NULL) return aGEOMObject._retn();
817 //Get the reference Objects
818 Handle(GEOM_Object) aCompound = GetOperations()->GetEngine()->GetObject
819 (theCompound->GetStudyID(), theCompound->GetEntry());
821 if (aCompound.IsNull()) return aGEOMObject._retn();
824 Handle(GEOM_Object) anObject =
825 GetOperations()->CheckAndImprove(aCompound);
826 if (!GetOperations()->IsDone() || anObject.IsNull())
827 return aGEOMObject._retn();
829 return GetObject(anObject);
832 //=============================================================================
836 //=============================================================================
837 GEOM::GEOM_Object_ptr GEOM_IBlocksOperations_i::GetBlockNearPoint (GEOM::GEOM_Object_ptr theCompound,
838 GEOM::GEOM_Object_ptr thePoint)
840 GEOM::GEOM_Object_var aGEOMObject;
842 //Set a not done flag
843 GetOperations()->SetNotDone();
845 if (theCompound == NULL || thePoint == NULL) return aGEOMObject._retn();
847 //Get the reference Objects
848 Handle(GEOM_Object) aCompound = GetOperations()->GetEngine()->GetObject
849 (theCompound->GetStudyID(), theCompound->GetEntry());
850 Handle(GEOM_Object) aPoint = GetOperations()->GetEngine()->GetObject
851 (thePoint->GetStudyID(), thePoint->GetEntry());
853 if (aCompound.IsNull() || aPoint.IsNull()) return aGEOMObject._retn();
856 Handle(GEOM_Object) anObject =
857 GetOperations()->GetBlockNearPoint(aCompound, aPoint);
858 if (!GetOperations()->IsDone() || anObject.IsNull())
859 return aGEOMObject._retn();
861 return GetObject(anObject);
864 //=============================================================================
868 //=============================================================================
869 GEOM::GEOM_Object_ptr GEOM_IBlocksOperations_i::GetBlockByParts (GEOM::GEOM_Object_ptr theCompound,
870 const GEOM::ListOfGO& theParts)
872 GEOM::GEOM_Object_var aGEOMObject;
874 //Set a not done flag
875 GetOperations()->SetNotDone();
877 if (theCompound == NULL) return aGEOMObject._retn();
879 //Get the reference Compound
880 Handle(GEOM_Object) aCompound = GetOperations()->GetEngine()->GetObject
881 (theCompound->GetStudyID(), theCompound->GetEntry());
883 if (aCompound.IsNull()) return aGEOMObject._retn();
887 Handle(TColStd_HSequenceOfTransient) aParts = new TColStd_HSequenceOfTransient;
889 aLen = theParts.length();
890 for (ind = 0; ind < aLen; ind++) {
891 if (theParts[ind] == NULL) return aGEOMObject._retn();
892 Handle(GEOM_Object) aSh = GetOperations()->GetEngine()->GetObject
893 (theParts[ind]->GetStudyID(), theParts[ind]->GetEntry());
894 if (aSh.IsNull()) return aGEOMObject._retn();
899 Handle(GEOM_Object) anObject =
900 GetOperations()->GetBlockByParts(aCompound, aParts);
901 if (!GetOperations()->IsDone() || anObject.IsNull())
902 return aGEOMObject._retn();
904 return GetObject(anObject);
907 //=============================================================================
911 //=============================================================================
912 GEOM::ListOfGO* GEOM_IBlocksOperations_i::GetBlocksByParts (GEOM::GEOM_Object_ptr theCompound,
913 const GEOM::ListOfGO& theParts)
915 GEOM::ListOfGO_var aSeq = new GEOM::ListOfGO;
917 //Set a not done flag
918 GetOperations()->SetNotDone();
920 if (theCompound == NULL) return aSeq._retn();
922 //Get the reference Compound
923 Handle(GEOM_Object) aCompound = GetOperations()->GetEngine()->GetObject
924 (theCompound->GetStudyID(), theCompound->GetEntry());
926 if (aCompound.IsNull()) return aSeq._retn();
930 Handle(TColStd_HSequenceOfTransient) aParts = new TColStd_HSequenceOfTransient;
932 aLen = theParts.length();
933 for (ind = 0; ind < aLen; ind++) {
934 if (theParts[ind] == NULL) return aSeq._retn();
935 Handle(GEOM_Object) aSh = GetOperations()->GetEngine()->GetObject
936 (theParts[ind]->GetStudyID(), theParts[ind]->GetEntry());
937 if (aSh.IsNull()) return aSeq._retn();
942 Handle(TColStd_HSequenceOfTransient) aHSeq =
943 GetOperations()->GetBlocksByParts(aCompound, aParts);
944 if (!GetOperations()->IsDone() || aHSeq.IsNull())
947 Standard_Integer aLength = aHSeq->Length();
948 aSeq->length(aLength);
949 for (Standard_Integer i = 1; i <= aLength; i++)
950 aSeq[i-1] = GetObject(Handle(GEOM_Object)::DownCast(aHSeq->Value(i)));
955 //=============================================================================
957 * MakeMultiTransformation1D
959 //=============================================================================
960 GEOM::GEOM_Object_ptr GEOM_IBlocksOperations_i::MakeMultiTransformation1D
961 (GEOM::GEOM_Object_ptr theBlock,
962 const CORBA::Long theDirFace1,
963 const CORBA::Long theDirFace2,
964 const CORBA::Long theNbTimes)
966 GEOM::GEOM_Object_var aGEOMObject;
968 //Set a not done flag
969 GetOperations()->SetNotDone();
971 if (theBlock == NULL) return aGEOMObject._retn();
973 //Get the object itself and the vector of translation
974 Handle(GEOM_Object) aBasicObject = GetOperations()->GetEngine()->GetObject
975 (theBlock->GetStudyID(), theBlock->GetEntry());
977 if (aBasicObject.IsNull()) return aGEOMObject._retn();
979 //Perform the transformation
980 Handle(GEOM_Object) anObject = GetOperations()->MakeMultiTransformation1D
981 (aBasicObject, theDirFace1, theDirFace2, theNbTimes);
982 if (!GetOperations()->IsDone() || anObject.IsNull()) return aGEOMObject._retn();
984 return GetObject(anObject);
987 //=============================================================================
989 * MakeMultiTransformation2D
991 //=============================================================================
992 GEOM::GEOM_Object_ptr GEOM_IBlocksOperations_i::MakeMultiTransformation2D
993 (GEOM::GEOM_Object_ptr theBlock,
994 const CORBA::Long theDirFace1U,
995 const CORBA::Long theDirFace2U,
996 const CORBA::Long theNbTimesU,
997 const CORBA::Long theDirFace1V,
998 const CORBA::Long theDirFace2V,
999 const CORBA::Long theNbTimesV)
1001 GEOM::GEOM_Object_var aGEOMObject;
1003 //Set a not done flag
1004 GetOperations()->SetNotDone();
1006 if (theBlock == NULL) return aGEOMObject._retn();
1008 //Get the object itself
1009 Handle(GEOM_Object) aBasicObject = GetOperations()->GetEngine()->GetObject
1010 (theBlock->GetStudyID(), theBlock->GetEntry());
1012 if (aBasicObject.IsNull()) return aGEOMObject._retn();
1014 //Perform the transformation
1015 Handle(GEOM_Object) anObject = GetOperations()->MakeMultiTransformation2D
1017 theDirFace1U, theDirFace2U, theNbTimesU,
1018 theDirFace1V, theDirFace2V, theNbTimesV);
1019 if (!GetOperations()->IsDone() || anObject.IsNull()) return aGEOMObject._retn();
1021 return GetObject(anObject);
1024 //=============================================================================
1028 //=============================================================================
1029 GEOM::ListOfGO* GEOM_IBlocksOperations_i::Propagate (GEOM::GEOM_Object_ptr theShape)
1031 GEOM::ListOfGO_var aSeq = new GEOM::ListOfGO;
1033 //Set a not done flag
1034 GetOperations()->SetNotDone();
1036 if (theShape == NULL) return aSeq._retn();
1038 //Get the reference Shape
1039 Handle(GEOM_Object) aShape = GetOperations()->GetEngine()->GetObject
1040 (theShape->GetStudyID(), theShape->GetEntry());
1042 if (aShape.IsNull()) return aSeq._retn();
1044 //Get the Propagation chains
1045 Handle(TColStd_HSequenceOfTransient) aHSeq =
1046 GetOperations()->Propagate(aShape);
1047 if (!GetOperations()->IsDone() || aHSeq.IsNull())
1048 return aSeq._retn();
1050 Standard_Integer aLength = aHSeq->Length();
1051 aSeq->length(aLength);
1052 for (Standard_Integer i = 1; i <= aLength; i++)
1053 aSeq[i-1] = GetObject(Handle(GEOM_Object)::DownCast(aHSeq->Value(i)));
1055 return aSeq._retn();