1 // Copyright (C) 2007-2012 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 //Get the reference edges
75 Handle(GEOM_Object) anEdge1 = GetObjectImpl(theEdge1);
76 Handle(GEOM_Object) anEdge2 = GetObjectImpl(theEdge2);
77 Handle(GEOM_Object) anEdge3 = GetObjectImpl(theEdge3);
78 Handle(GEOM_Object) anEdge4 = GetObjectImpl(theEdge4);
80 if (anEdge1.IsNull() || anEdge2.IsNull() ||
81 anEdge3.IsNull() || anEdge4.IsNull()) return aGEOMObject._retn();
84 Handle(GEOM_Object) anObject =
85 GetOperations()->MakeQuad(anEdge1, anEdge2, anEdge3, anEdge4);
86 if (!GetOperations()->IsDone() || anObject.IsNull())
87 return aGEOMObject._retn();
89 return GetObject(anObject);
92 //=============================================================================
96 //=============================================================================
97 GEOM::GEOM_Object_ptr GEOM_IBlocksOperations_i::MakeQuad2Edges
98 (GEOM::GEOM_Object_ptr theEdge1, GEOM::GEOM_Object_ptr theEdge2)
100 GEOM::GEOM_Object_var aGEOMObject;
102 //Set a not done flag
103 GetOperations()->SetNotDone();
105 //Get the reference edges
106 Handle(GEOM_Object) anEdge1 = GetObjectImpl(theEdge1);
107 Handle(GEOM_Object) anEdge2 = GetObjectImpl(theEdge2);
109 if (anEdge1.IsNull() || anEdge2.IsNull()) return aGEOMObject._retn();
112 Handle(GEOM_Object) anObject =
113 GetOperations()->MakeQuad2Edges(anEdge1, anEdge2);
114 if (!GetOperations()->IsDone() || anObject.IsNull())
115 return aGEOMObject._retn();
117 return GetObject(anObject);
120 //=============================================================================
124 //=============================================================================
125 GEOM::GEOM_Object_ptr GEOM_IBlocksOperations_i::MakeQuad4Vertices
126 (GEOM::GEOM_Object_ptr thePnt1, GEOM::GEOM_Object_ptr thePnt2,
127 GEOM::GEOM_Object_ptr thePnt3, GEOM::GEOM_Object_ptr thePnt4)
129 GEOM::GEOM_Object_var aGEOMObject;
131 //Set a not done flag
132 GetOperations()->SetNotDone();
134 //Get the reference points
135 Handle(GEOM_Object) aPnt1 = GetObjectImpl(thePnt1);
136 Handle(GEOM_Object) aPnt2 = GetObjectImpl(thePnt2);
137 Handle(GEOM_Object) aPnt3 = GetObjectImpl(thePnt3);
138 Handle(GEOM_Object) aPnt4 = GetObjectImpl(thePnt4);
140 if (aPnt1.IsNull() || aPnt2.IsNull() ||
141 aPnt3.IsNull() || aPnt4.IsNull()) return aGEOMObject._retn();
144 Handle(GEOM_Object) anObject =
145 GetOperations()->MakeQuad4Vertices(aPnt1, aPnt2, aPnt3, aPnt4);
146 if (!GetOperations()->IsDone() || anObject.IsNull())
147 return aGEOMObject._retn();
149 return GetObject(anObject);
152 //=============================================================================
156 //=============================================================================
157 GEOM::GEOM_Object_ptr GEOM_IBlocksOperations_i::MakeHexa
158 (GEOM::GEOM_Object_ptr theFace1, GEOM::GEOM_Object_ptr theFace2,
159 GEOM::GEOM_Object_ptr theFace3, GEOM::GEOM_Object_ptr theFace4,
160 GEOM::GEOM_Object_ptr theFace5, GEOM::GEOM_Object_ptr theFace6)
162 GEOM::GEOM_Object_var aGEOMObject;
164 //Set a not done flag
165 GetOperations()->SetNotDone();
167 //Get the reference Faces
168 Handle(GEOM_Object) anFace1 = GetObjectImpl(theFace1);
169 Handle(GEOM_Object) anFace2 = GetObjectImpl(theFace2);
170 Handle(GEOM_Object) anFace3 = GetObjectImpl(theFace3);
171 Handle(GEOM_Object) anFace4 = GetObjectImpl(theFace4);
172 Handle(GEOM_Object) anFace5 = GetObjectImpl(theFace5);
173 Handle(GEOM_Object) anFace6 = GetObjectImpl(theFace6);
175 if (anFace1.IsNull() || anFace2.IsNull() ||
176 anFace3.IsNull() || anFace4.IsNull() ||
177 anFace5.IsNull() || anFace6.IsNull()) return aGEOMObject._retn();
180 Handle(GEOM_Object) anObject = GetOperations()->MakeHexa
181 (anFace1, anFace2, anFace3, anFace4, anFace5, anFace6);
182 if (!GetOperations()->IsDone() || anObject.IsNull())
183 return aGEOMObject._retn();
185 return GetObject(anObject);
188 //=============================================================================
192 //=============================================================================
193 GEOM::GEOM_Object_ptr GEOM_IBlocksOperations_i::MakeHexa2Faces
194 (GEOM::GEOM_Object_ptr theFace1, GEOM::GEOM_Object_ptr theFace2)
196 GEOM::GEOM_Object_var aGEOMObject;
198 //Set a not done flag
199 GetOperations()->SetNotDone();
201 //Get the reference Faces
202 Handle(GEOM_Object) anFace1 = GetObjectImpl(theFace1);
203 Handle(GEOM_Object) anFace2 = GetObjectImpl(theFace2);
205 if (anFace1.IsNull() || anFace2.IsNull()) return aGEOMObject._retn();
208 Handle(GEOM_Object) anObject =
209 GetOperations()->MakeHexa2Faces(anFace1, anFace2);
210 if (!GetOperations()->IsDone() || anObject.IsNull())
211 return aGEOMObject._retn();
213 return GetObject(anObject);
216 //=============================================================================
220 //=============================================================================
221 GEOM::GEOM_Object_ptr GEOM_IBlocksOperations_i::MakeBlockCompound
222 (GEOM::GEOM_Object_ptr theCompound)
224 GEOM::GEOM_Object_var aGEOMObject;
226 //Set a not done flag
227 GetOperations()->SetNotDone();
229 //Get the reference Compound
230 Handle(GEOM_Object) aCompound = GetObjectImpl(theCompound);
231 if (aCompound.IsNull()) return aGEOMObject._retn();
233 //Create the Blocks Compound
234 Handle(GEOM_Object) anObject =
235 GetOperations()->MakeBlockCompound(aCompound);
236 if (!GetOperations()->IsDone() || anObject.IsNull())
237 return aGEOMObject._retn();
239 return GetObject(anObject);
242 //=============================================================================
246 //=============================================================================
247 GEOM::GEOM_Object_ptr GEOM_IBlocksOperations_i::GetPoint (GEOM::GEOM_Object_ptr theShape,
248 const CORBA::Double theX,
249 const CORBA::Double theY,
250 const CORBA::Double theZ,
251 const CORBA::Double theEpsilon)
253 GEOM::GEOM_Object_var aGEOMObject;
255 //Set a not done flag
256 GetOperations()->SetNotDone();
258 //Get the reference Objects
259 Handle(GEOM_Object) aShape = GetObjectImpl(theShape);
260 if (aShape.IsNull()) return aGEOMObject._retn();
263 Handle(GEOM_Object) anObject =
264 GetOperations()->GetPoint(aShape, theX, theY, theZ, theEpsilon);
265 if (!GetOperations()->IsDone() || anObject.IsNull())
266 return aGEOMObject._retn();
268 return GetObject(anObject);
271 //=============================================================================
275 //=============================================================================
276 GEOM::GEOM_Object_ptr GEOM_IBlocksOperations_i::GetVertexNearPoint
277 (GEOM::GEOM_Object_ptr theShape,
278 GEOM::GEOM_Object_ptr thePoint)
280 GEOM::GEOM_Object_var aGEOMObject;
282 // Set a not done flag
283 GetOperations()->SetNotDone();
285 // Get the reference Objects
286 Handle(GEOM_Object) aShape = GetObjectImpl(theShape);
287 Handle(GEOM_Object) aPoint = GetObjectImpl(thePoint);
288 if (aShape.IsNull() || aPoint.IsNull()) return aGEOMObject._retn();
291 Handle(GEOM_Object) anObject =
292 GetOperations()->GetVertexNearPoint(aShape, aPoint);
293 if (!GetOperations()->IsDone() || anObject.IsNull())
294 return aGEOMObject._retn();
296 return GetObject(anObject);
299 //=============================================================================
303 //=============================================================================
304 GEOM::GEOM_Object_ptr GEOM_IBlocksOperations_i::GetEdge (GEOM::GEOM_Object_ptr theShape,
305 GEOM::GEOM_Object_ptr thePoint1,
306 GEOM::GEOM_Object_ptr thePoint2)
308 GEOM::GEOM_Object_var aGEOMObject;
310 //Set a not done flag
311 GetOperations()->SetNotDone();
313 //Get the reference Objects
314 Handle(GEOM_Object) aShape = GetObjectImpl(theShape);
315 Handle(GEOM_Object) aPoint1 = GetObjectImpl(thePoint1);
316 Handle(GEOM_Object) aPoint2 = GetObjectImpl(thePoint2);
318 if (aShape.IsNull() ||
319 aPoint1.IsNull() || aPoint2.IsNull()) return aGEOMObject._retn();
322 Handle(GEOM_Object) anObject =
323 GetOperations()->GetEdge(aShape, aPoint1, aPoint2);
324 if (!GetOperations()->IsDone() || anObject.IsNull())
325 return aGEOMObject._retn();
327 return GetObject(anObject);
330 //=============================================================================
334 //=============================================================================
335 GEOM::GEOM_Object_ptr GEOM_IBlocksOperations_i::GetEdgeNearPoint (GEOM::GEOM_Object_ptr theShape,
336 GEOM::GEOM_Object_ptr thePoint)
338 GEOM::GEOM_Object_var aGEOMObject;
340 //Set a not done flag
341 GetOperations()->SetNotDone();
343 //Get the reference Objects
344 Handle(GEOM_Object) aShape = GetObjectImpl(theShape);
345 Handle(GEOM_Object) aPoint = GetObjectImpl(thePoint);
347 if (aShape.IsNull() || aPoint.IsNull()) return aGEOMObject._retn();
350 Handle(GEOM_Object) anObject =
351 GetOperations()->GetEdgeNearPoint(aShape, aPoint);
352 if (!GetOperations()->IsDone() || anObject.IsNull())
353 return aGEOMObject._retn();
355 return GetObject(anObject);
358 //=============================================================================
362 //=============================================================================
363 GEOM::GEOM_Object_ptr GEOM_IBlocksOperations_i::GetFaceByPoints
364 (GEOM::GEOM_Object_ptr theShape,
365 GEOM::GEOM_Object_ptr thePoint1,
366 GEOM::GEOM_Object_ptr thePoint2,
367 GEOM::GEOM_Object_ptr thePoint3,
368 GEOM::GEOM_Object_ptr thePoint4)
370 GEOM::GEOM_Object_var aGEOMObject;
372 //Set a not done flag
373 GetOperations()->SetNotDone();
375 //Get the reference Objects
376 Handle(GEOM_Object) aShape = GetObjectImpl(theShape);
377 Handle(GEOM_Object) aPoint1 = GetObjectImpl(thePoint1);
378 Handle(GEOM_Object) aPoint2 = GetObjectImpl(thePoint2);
379 Handle(GEOM_Object) aPoint3 = GetObjectImpl(thePoint3);
380 Handle(GEOM_Object) aPoint4 = GetObjectImpl(thePoint4);
382 if (aShape.IsNull() ||
383 aPoint1.IsNull() || aPoint2.IsNull() ||
384 aPoint3.IsNull() || aPoint4.IsNull()) return aGEOMObject._retn();
387 Handle(GEOM_Object) anObject =
388 GetOperations()->GetFaceByPoints(aShape, aPoint1, aPoint2, aPoint3, aPoint4);
389 if (!GetOperations()->IsDone() || anObject.IsNull())
390 return aGEOMObject._retn();
392 return GetObject(anObject);
395 //=============================================================================
399 //=============================================================================
400 GEOM::GEOM_Object_ptr GEOM_IBlocksOperations_i::GetFaceByEdges
401 (GEOM::GEOM_Object_ptr theShape,
402 GEOM::GEOM_Object_ptr theEdge1,
403 GEOM::GEOM_Object_ptr theEdge2)
405 GEOM::GEOM_Object_var aGEOMObject;
407 //Set a not done flag
408 GetOperations()->SetNotDone();
410 //Get the reference Objects
411 Handle(GEOM_Object) aShape = GetObjectImpl(theShape);
412 Handle(GEOM_Object) anEdge1 = GetObjectImpl(theEdge1);
413 Handle(GEOM_Object) anEdge2 = GetObjectImpl(theEdge2);
415 if (aShape.IsNull() ||
416 anEdge1.IsNull() || anEdge2.IsNull()) return aGEOMObject._retn();
419 Handle(GEOM_Object) anObject =
420 GetOperations()->GetFaceByEdges(aShape, anEdge1, anEdge2);
421 if (!GetOperations()->IsDone() || anObject.IsNull())
422 return aGEOMObject._retn();
424 return GetObject(anObject);
427 //=============================================================================
431 //=============================================================================
432 GEOM::GEOM_Object_ptr GEOM_IBlocksOperations_i::GetOppositeFace (GEOM::GEOM_Object_ptr theShape,
433 GEOM::GEOM_Object_ptr theFace)
435 GEOM::GEOM_Object_var aGEOMObject;
437 //Set a not done flag
438 GetOperations()->SetNotDone();
440 //Get the reference Objects
441 Handle(GEOM_Object) aShape = GetObjectImpl(theShape);
442 Handle(GEOM_Object) aFace = GetObjectImpl(theFace);
444 if (aShape.IsNull() || aFace.IsNull()) return aGEOMObject._retn();
447 Handle(GEOM_Object) anObject =
448 GetOperations()->GetOppositeFace(aShape, aFace);
449 if (!GetOperations()->IsDone() || anObject.IsNull())
450 return aGEOMObject._retn();
452 return GetObject(anObject);
455 //=============================================================================
459 //=============================================================================
460 GEOM::GEOM_Object_ptr GEOM_IBlocksOperations_i::GetFaceNearPoint (GEOM::GEOM_Object_ptr theShape,
461 GEOM::GEOM_Object_ptr thePoint)
463 GEOM::GEOM_Object_var aGEOMObject;
465 //Set a not done flag
466 GetOperations()->SetNotDone();
468 //Get the reference Objects
469 Handle(GEOM_Object) aShape = GetObjectImpl(theShape);
470 Handle(GEOM_Object) aPoint = GetObjectImpl(thePoint);
472 if (aShape.IsNull() || aPoint.IsNull()) return aGEOMObject._retn();
475 Handle(GEOM_Object) anObject =
476 GetOperations()->GetFaceNearPoint(aShape, aPoint);
477 if (!GetOperations()->IsDone() || anObject.IsNull())
478 return aGEOMObject._retn();
480 return GetObject(anObject);
483 //=============================================================================
487 //=============================================================================
488 GEOM::GEOM_Object_ptr GEOM_IBlocksOperations_i::GetFaceByNormale (GEOM::GEOM_Object_ptr theShape,
489 GEOM::GEOM_Object_ptr theVector)
491 GEOM::GEOM_Object_var aGEOMObject;
493 //Set a not done flag
494 GetOperations()->SetNotDone();
496 //Get the reference Objects
497 Handle(GEOM_Object) aShape = GetObjectImpl(theShape);
498 Handle(GEOM_Object) aVector = GetObjectImpl(theVector);
500 if (aShape.IsNull() || aVector.IsNull()) return aGEOMObject._retn();
503 Handle(GEOM_Object) anObject =
504 GetOperations()->GetFaceByNormale(aShape, aVector);
505 if (!GetOperations()->IsDone() || anObject.IsNull())
506 return aGEOMObject._retn();
508 return GetObject(anObject);
511 //=============================================================================
515 //=============================================================================
516 GEOM::GEOM_Object_ptr GEOM_IBlocksOperations_i::GetShapesNearPoint
517 (GEOM::GEOM_Object_ptr theShape,
518 GEOM::GEOM_Object_ptr thePoint,
519 CORBA::Long theShapeType,
520 CORBA::Double theTolerance)
522 GEOM::GEOM_Object_var aGEOMObject;
524 // Set a not done flag
525 GetOperations()->SetNotDone();
527 // Get the reference Objects
528 Handle(GEOM_Object) aShape = GetObjectImpl(theShape);
529 Handle(GEOM_Object) aPoint = GetObjectImpl(thePoint);
531 if (aShape.IsNull() || aPoint.IsNull()) return aGEOMObject._retn();
534 Handle(GEOM_Object) anObject =
535 GetOperations()->GetShapesNearPoint(aShape, aPoint, theShapeType, theTolerance);
536 if (!GetOperations()->IsDone() || anObject.IsNull())
537 return aGEOMObject._retn();
539 return GetObject(anObject);
542 //=============================================================================
544 * ExplodeCompoundOfBlocks
546 //=============================================================================
547 GEOM::ListOfGO* GEOM_IBlocksOperations_i::ExplodeCompoundOfBlocks
548 (GEOM::GEOM_Object_ptr theCompound,
549 const CORBA::Long theMinNbFaces,
550 const CORBA::Long theMaxNbFaces)
552 GEOM::ListOfGO_var aSeq = new GEOM::ListOfGO;
554 //Set a not done flag
555 GetOperations()->SetNotDone();
557 //Get the reference Compound
558 Handle(GEOM_Object) aCompound = GetObjectImpl(theCompound);
559 if (aCompound.IsNull()) return aSeq._retn();
562 Handle(TColStd_HSequenceOfTransient) aHSeq =
563 GetOperations()->ExplodeCompoundOfBlocks(aCompound, theMinNbFaces, theMaxNbFaces);
564 if (!GetOperations()->IsDone() || aHSeq.IsNull())
567 Standard_Integer aLength = aHSeq->Length();
568 aSeq->length(aLength);
569 for (Standard_Integer i = 1; i <= aLength; i++)
570 aSeq[i-1] = GetObject(Handle(GEOM_Object)::DownCast(aHSeq->Value(i)));
575 //=============================================================================
579 //=============================================================================
580 CORBA::Boolean GEOM_IBlocksOperations_i::IsCompoundOfBlocks
581 (GEOM::GEOM_Object_ptr theCompound,
582 const CORBA::Long theMinNbFaces,
583 const CORBA::Long theMaxNbFaces,
584 CORBA::Long& theNbBlocks)
587 CORBA::Boolean isComp = false;
589 //Set a not done flag
590 GetOperations()->SetNotDone();
592 //Get the reference Compound
593 Handle(GEOM_Object) aCompound = GetObjectImpl(theCompound);
594 if (aCompound.IsNull()) return isComp;
597 Standard_Integer nbBlocks = 0;
598 isComp = GetOperations()->IsCompoundOfBlocks(aCompound,
602 if (!GetOperations()->IsDone())
605 theNbBlocks = nbBlocks;
609 //=============================================================================
611 * CheckCompoundOfBlocks
613 //=============================================================================
614 CORBA::Boolean GEOM_IBlocksOperations_i::CheckCompoundOfBlocks
615 (GEOM::GEOM_Object_ptr theCompound,
616 GEOM::GEOM_IBlocksOperations::BCErrors_out theErrors)
618 CORBA::Boolean isComp = false;
620 //Set a not done flag
621 GetOperations()->SetNotDone();
623 //Get the reference Compound
624 Handle(GEOM_Object) aCompound = GetObjectImpl(theCompound);
625 if (aCompound.IsNull()) return isComp;
628 std::list<GEOMImpl_IBlocksOperations::BCError> errList;
629 isComp = GetOperations()->CheckCompoundOfBlocks(aCompound, errList);
630 if (!GetOperations()->IsDone())
633 const int nbErr = errList.size();
634 GEOM::GEOM_IBlocksOperations::BCErrors_var anErrArray =
635 new GEOM::GEOM_IBlocksOperations::BCErrors();
636 anErrArray->length(nbErr);
638 // fill the local CORBA array with values from lists
639 std::list<GEOMImpl_IBlocksOperations::BCError>::iterator errIt = errList.begin();
641 for (; errIt != errList.end(); i++, errIt++) {
642 GEOM::GEOM_IBlocksOperations::BCError_var anError =
643 new GEOM::GEOM_IBlocksOperations::BCError();
645 GEOMImpl_IBlocksOperations::BCError errStruct = *errIt;
647 switch (errStruct.error) {
648 case GEOMImpl_IBlocksOperations::NOT_BLOCK:
649 anError->error = GEOM::GEOM_IBlocksOperations::NOT_BLOCK;
651 case GEOMImpl_IBlocksOperations::EXTRA_EDGE:
652 anError->error = GEOM::GEOM_IBlocksOperations::EXTRA_EDGE;
654 case GEOMImpl_IBlocksOperations::INVALID_CONNECTION:
655 anError->error = GEOM::GEOM_IBlocksOperations::INVALID_CONNECTION;
657 case GEOMImpl_IBlocksOperations::NOT_CONNECTED:
658 anError->error = GEOM::GEOM_IBlocksOperations::NOT_CONNECTED;
660 case GEOMImpl_IBlocksOperations::NOT_GLUED:
661 anError->error = GEOM::GEOM_IBlocksOperations::NOT_GLUED;
667 std::list<int> sshList = errStruct.incriminated;
668 GEOM::ListOfLong_var anIncrims = new GEOM::ListOfLong();
669 anIncrims->length(sshList.size());
671 std::list<int>::iterator sshIt = sshList.begin();
673 for (; sshIt != sshList.end(); jj++, sshIt++) {
674 anIncrims[jj] = *sshIt;
677 anError->incriminated = anIncrims;
679 anErrArray[i] = anError;
682 // initialize out-parameter with local array
683 theErrors = anErrArray._retn();
688 //=============================================================================
692 //=============================================================================
693 char* GEOM_IBlocksOperations_i::PrintBCErrors
694 (GEOM::GEOM_Object_ptr theCompound,
695 const GEOM::GEOM_IBlocksOperations::BCErrors& theErrors)
697 //Get the reference Compound
698 Handle(GEOM_Object) aCompound = GetObjectImpl(theCompound);
699 if (aCompound.IsNull()) return NULL;
701 // Convert the errors sequence
702 std::list<GEOMImpl_IBlocksOperations::BCError> anErrors;
703 int nbErr = theErrors.length();
705 for (; ie < nbErr; ie++) {
706 const GEOM::GEOM_IBlocksOperations::BCError err = theErrors[ie];
707 const GEOM::GEOM_IBlocksOperations::BCErrorType typ = err.error;
708 const GEOM::ListOfLong incrims = err.incriminated;
710 GEOMImpl_IBlocksOperations::BCError errStruct;
712 case GEOM::GEOM_IBlocksOperations::NOT_BLOCK:
713 errStruct.error = GEOMImpl_IBlocksOperations::NOT_BLOCK;
715 case GEOM::GEOM_IBlocksOperations::EXTRA_EDGE:
716 errStruct.error = GEOMImpl_IBlocksOperations::EXTRA_EDGE;
718 case GEOM::GEOM_IBlocksOperations::INVALID_CONNECTION:
719 errStruct.error = GEOMImpl_IBlocksOperations::INVALID_CONNECTION;
721 case GEOM::GEOM_IBlocksOperations::NOT_CONNECTED:
722 errStruct.error = GEOMImpl_IBlocksOperations::NOT_CONNECTED;
724 case GEOM::GEOM_IBlocksOperations::NOT_GLUED:
725 errStruct.error = GEOMImpl_IBlocksOperations::NOT_GLUED;
732 int aLen = incrims.length();
733 for (; ii < aLen; ii++) {
734 errStruct.incriminated.push_back(incrims[ii]);
737 anErrors.push_back(errStruct);
740 TCollection_AsciiString aDescr = GetOperations()->PrintBCErrors(aCompound, anErrors);
741 return CORBA::string_dup(aDescr.ToCString());
744 //=============================================================================
748 //=============================================================================
749 GEOM::GEOM_Object_ptr GEOM_IBlocksOperations_i::GetNonBlocks
750 (GEOM::GEOM_Object_ptr theShape,
751 GEOM::GEOM_Object_out theNonQuads)
753 GEOM::GEOM_Object_var aGEOMObject;
754 GEOM::GEOM_Object_var aNonQuads;
756 theNonQuads = aNonQuads._retn();
758 //Set a not done flag
759 GetOperations()->SetNotDone();
761 //Get the reference Objects
762 Handle(GEOM_Object) aShape = GetObjectImpl(theShape);
763 if (aShape.IsNull()) return aGEOMObject._retn();
766 Handle(GEOM_Object) aFaces;
767 Handle(GEOM_Object) anObject = GetOperations()->GetNonBlocks(aShape, aFaces);
768 if (!GetOperations()->IsDone() || anObject.IsNull())
769 return aGEOMObject._retn();
771 if (!aFaces.IsNull())
772 theNonQuads = GetObject(aFaces);
774 return GetObject(anObject);
777 //=============================================================================
781 //=============================================================================
782 GEOM::GEOM_Object_ptr GEOM_IBlocksOperations_i::RemoveExtraEdges
783 (GEOM::GEOM_Object_ptr theShape,
784 CORBA::Long theOptimumNbFaces)
786 GEOM::GEOM_Object_var aGEOMObject;
788 //Set a not done flag
789 GetOperations()->SetNotDone();
791 //Get the reference Objects
792 Handle(GEOM_Object) aShape = GetObjectImpl(theShape);
793 if (aShape.IsNull()) return aGEOMObject._retn();
796 Handle(GEOM_Object) anObject = GetOperations()->RemoveExtraEdges(aShape, theOptimumNbFaces);
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 //Get the reference Objects
816 Handle(GEOM_Object) aCompound = GetObjectImpl(theCompound);
817 if (aCompound.IsNull()) return aGEOMObject._retn();
820 Handle(GEOM_Object) anObject =
821 GetOperations()->CheckAndImprove(aCompound);
822 if (!GetOperations()->IsDone() || anObject.IsNull())
823 return aGEOMObject._retn();
825 return GetObject(anObject);
828 //=============================================================================
832 //=============================================================================
833 GEOM::GEOM_Object_ptr GEOM_IBlocksOperations_i::GetBlockNearPoint (GEOM::GEOM_Object_ptr theCompound,
834 GEOM::GEOM_Object_ptr thePoint)
836 GEOM::GEOM_Object_var aGEOMObject;
838 //Set a not done flag
839 GetOperations()->SetNotDone();
841 //Get the reference Objects
842 Handle(GEOM_Object) aCompound = GetObjectImpl(theCompound);
843 Handle(GEOM_Object) aPoint = GetObjectImpl(thePoint);
845 if (aCompound.IsNull() || aPoint.IsNull()) return aGEOMObject._retn();
848 Handle(GEOM_Object) anObject =
849 GetOperations()->GetBlockNearPoint(aCompound, aPoint);
850 if (!GetOperations()->IsDone() || anObject.IsNull())
851 return aGEOMObject._retn();
853 return GetObject(anObject);
856 //=============================================================================
860 //=============================================================================
861 GEOM::GEOM_Object_ptr GEOM_IBlocksOperations_i::GetBlockByParts (GEOM::GEOM_Object_ptr theCompound,
862 const GEOM::ListOfGO& theParts)
864 GEOM::GEOM_Object_var aGEOMObject;
866 //Set a not done flag
867 GetOperations()->SetNotDone();
869 //Get the reference Compound
870 Handle(GEOM_Object) aCompound = GetObjectImpl(theCompound);
871 if (aCompound.IsNull()) return aGEOMObject._retn();
875 Handle(TColStd_HSequenceOfTransient) aParts = new TColStd_HSequenceOfTransient;
877 aLen = theParts.length();
878 for (ind = 0; ind < aLen; ind++) {
879 Handle(GEOM_Object) aSh = GetObjectImpl(theParts[ind]);
880 if (aSh.IsNull()) return aGEOMObject._retn();
885 Handle(GEOM_Object) anObject =
886 GetOperations()->GetBlockByParts(aCompound, aParts);
887 if (!GetOperations()->IsDone() || anObject.IsNull())
888 return aGEOMObject._retn();
890 return GetObject(anObject);
893 //=============================================================================
897 //=============================================================================
898 GEOM::ListOfGO* GEOM_IBlocksOperations_i::GetBlocksByParts (GEOM::GEOM_Object_ptr theCompound,
899 const GEOM::ListOfGO& theParts)
901 GEOM::ListOfGO_var aSeq = new GEOM::ListOfGO;
903 //Set a not done flag
904 GetOperations()->SetNotDone();
906 //Get the reference Compound
907 Handle(GEOM_Object) aCompound = GetObjectImpl(theCompound);
908 if (aCompound.IsNull()) return aSeq._retn();
912 Handle(TColStd_HSequenceOfTransient) aParts = new TColStd_HSequenceOfTransient;
914 aLen = theParts.length();
915 for (ind = 0; ind < aLen; ind++) {
916 Handle(GEOM_Object) aSh = GetObjectImpl(theParts[ind]);
917 if (aSh.IsNull()) return aSeq._retn();
922 Handle(TColStd_HSequenceOfTransient) aHSeq =
923 GetOperations()->GetBlocksByParts(aCompound, aParts);
924 if (!GetOperations()->IsDone() || aHSeq.IsNull())
927 Standard_Integer aLength = aHSeq->Length();
928 aSeq->length(aLength);
929 for (Standard_Integer i = 1; i <= aLength; i++)
930 aSeq[i-1] = GetObject(Handle(GEOM_Object)::DownCast(aHSeq->Value(i)));
935 //=============================================================================
937 * MakeMultiTransformation1D
939 //=============================================================================
940 GEOM::GEOM_Object_ptr GEOM_IBlocksOperations_i::MakeMultiTransformation1D
941 (GEOM::GEOM_Object_ptr theBlock,
942 const CORBA::Long theDirFace1,
943 const CORBA::Long theDirFace2,
944 const CORBA::Long theNbTimes)
946 GEOM::GEOM_Object_var aGEOMObject;
948 //Set a not done flag
949 GetOperations()->SetNotDone();
951 //Get the object itself and the vector of translation
952 Handle(GEOM_Object) aBasicObject = GetObjectImpl(theBlock);
953 if (aBasicObject.IsNull()) return aGEOMObject._retn();
955 //Perform the transformation
956 Handle(GEOM_Object) anObject = GetOperations()->MakeMultiTransformation1D
957 (aBasicObject, theDirFace1, theDirFace2, theNbTimes);
958 if (!GetOperations()->IsDone() || anObject.IsNull()) return aGEOMObject._retn();
960 return GetObject(anObject);
963 //=============================================================================
965 * MakeMultiTransformation2D
967 //=============================================================================
968 GEOM::GEOM_Object_ptr GEOM_IBlocksOperations_i::MakeMultiTransformation2D
969 (GEOM::GEOM_Object_ptr theBlock,
970 const CORBA::Long theDirFace1U,
971 const CORBA::Long theDirFace2U,
972 const CORBA::Long theNbTimesU,
973 const CORBA::Long theDirFace1V,
974 const CORBA::Long theDirFace2V,
975 const CORBA::Long theNbTimesV)
977 GEOM::GEOM_Object_var aGEOMObject;
979 //Set a not done flag
980 GetOperations()->SetNotDone();
982 //Get the object itself
983 Handle(GEOM_Object) aBasicObject = GetObjectImpl(theBlock);
984 if (aBasicObject.IsNull()) return aGEOMObject._retn();
986 //Perform the transformation
987 Handle(GEOM_Object) anObject = GetOperations()->MakeMultiTransformation2D
989 theDirFace1U, theDirFace2U, theNbTimesU,
990 theDirFace1V, theDirFace2V, theNbTimesV);
991 if (!GetOperations()->IsDone() || anObject.IsNull()) return aGEOMObject._retn();
993 return GetObject(anObject);
996 //=============================================================================
1000 //=============================================================================
1001 GEOM::ListOfGO* GEOM_IBlocksOperations_i::Propagate (GEOM::GEOM_Object_ptr theShape)
1003 GEOM::ListOfGO_var aSeq = new GEOM::ListOfGO;
1005 //Set a not done flag
1006 GetOperations()->SetNotDone();
1008 //Get the reference Shape
1009 Handle(GEOM_Object) aShape = GetObjectImpl(theShape);
1010 if (aShape.IsNull()) return aSeq._retn();
1012 //Get the Propagation chains
1013 Handle(TColStd_HSequenceOfTransient) aHSeq =
1014 GetOperations()->Propagate(aShape);
1015 if (!GetOperations()->IsDone() || aHSeq.IsNull())
1016 return aSeq._retn();
1018 Standard_Integer aLength = aHSeq->Length();
1019 aSeq->length(aLength);
1020 for (Standard_Integer i = 1; i <= aLength; i++)
1021 aSeq[i-1] = GetObject(Handle(GEOM_Object)::DownCast(aHSeq->Value(i)));
1023 return aSeq._retn();