1 // Copyright (C) 2007-2016 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, or (at your option) any later version.
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
23 #include <Standard_Stream.hxx>
25 #include "GEOM_IBlocksOperations_i.hh"
27 #include "utilities.h"
29 #include "Utils_ExceptHandlers.hxx"
31 #include "GEOM_Engine.hxx"
32 #include "GEOM_Object.hxx"
34 #include <TColStd_HSequenceOfTransient.hxx>
35 #include <TColStd_HArray1OfInteger.hxx>
37 //=============================================================================
41 //=============================================================================
42 GEOM_IBlocksOperations_i::GEOM_IBlocksOperations_i (PortableServer::POA_ptr thePOA,
43 GEOM::GEOM_Gen_ptr theEngine,
44 ::GEOMImpl_IBlocksOperations* theImpl)
45 :GEOM_IOperations_i(thePOA, theEngine, theImpl)
47 MESSAGE("GEOM_IBlocksOperations_i::GEOM_IBlocksOperations_i");
50 //=============================================================================
54 //=============================================================================
55 GEOM_IBlocksOperations_i::~GEOM_IBlocksOperations_i()
57 MESSAGE("GEOM_IBlocksOperations_i::~GEOM_IBlocksOperations_i");
61 //=============================================================================
65 //=============================================================================
66 GEOM::GEOM_Object_ptr GEOM_IBlocksOperations_i::MakeQuad
67 (GEOM::GEOM_Object_ptr theEdge1, GEOM::GEOM_Object_ptr theEdge2,
68 GEOM::GEOM_Object_ptr theEdge3, GEOM::GEOM_Object_ptr theEdge4)
70 GEOM::GEOM_Object_var aGEOMObject;
73 GetOperations()->SetNotDone();
75 //Get the reference edges
76 HANDLE_NAMESPACE(GEOM_Object) anEdge1 = GetObjectImpl(theEdge1);
77 HANDLE_NAMESPACE(GEOM_Object) anEdge2 = GetObjectImpl(theEdge2);
78 HANDLE_NAMESPACE(GEOM_Object) anEdge3 = GetObjectImpl(theEdge3);
79 HANDLE_NAMESPACE(GEOM_Object) anEdge4 = GetObjectImpl(theEdge4);
81 if (anEdge1.IsNull() || anEdge2.IsNull() ||
82 anEdge3.IsNull() || anEdge4.IsNull()) return aGEOMObject._retn();
85 HANDLE_NAMESPACE(GEOM_Object) anObject =
86 GetOperations()->MakeQuad(anEdge1, anEdge2, anEdge3, anEdge4);
87 if (!GetOperations()->IsDone() || anObject.IsNull())
88 return aGEOMObject._retn();
90 return GetObject(anObject);
93 //=============================================================================
97 //=============================================================================
98 GEOM::GEOM_Object_ptr GEOM_IBlocksOperations_i::MakeQuad2Edges
99 (GEOM::GEOM_Object_ptr theEdge1, GEOM::GEOM_Object_ptr theEdge2)
101 GEOM::GEOM_Object_var aGEOMObject;
103 //Set a not done flag
104 GetOperations()->SetNotDone();
106 //Get the reference edges
107 HANDLE_NAMESPACE(GEOM_Object) anEdge1 = GetObjectImpl(theEdge1);
108 HANDLE_NAMESPACE(GEOM_Object) anEdge2 = GetObjectImpl(theEdge2);
110 if (anEdge1.IsNull() || anEdge2.IsNull()) return aGEOMObject._retn();
113 HANDLE_NAMESPACE(GEOM_Object) anObject =
114 GetOperations()->MakeQuad2Edges(anEdge1, anEdge2);
115 if (!GetOperations()->IsDone() || anObject.IsNull())
116 return aGEOMObject._retn();
118 return GetObject(anObject);
121 //=============================================================================
125 //=============================================================================
126 GEOM::GEOM_Object_ptr GEOM_IBlocksOperations_i::MakeQuad4Vertices
127 (GEOM::GEOM_Object_ptr thePnt1, GEOM::GEOM_Object_ptr thePnt2,
128 GEOM::GEOM_Object_ptr thePnt3, GEOM::GEOM_Object_ptr thePnt4)
130 GEOM::GEOM_Object_var aGEOMObject;
132 //Set a not done flag
133 GetOperations()->SetNotDone();
135 //Get the reference points
136 HANDLE_NAMESPACE(GEOM_Object) aPnt1 = GetObjectImpl(thePnt1);
137 HANDLE_NAMESPACE(GEOM_Object) aPnt2 = GetObjectImpl(thePnt2);
138 HANDLE_NAMESPACE(GEOM_Object) aPnt3 = GetObjectImpl(thePnt3);
139 HANDLE_NAMESPACE(GEOM_Object) aPnt4 = GetObjectImpl(thePnt4);
141 if (aPnt1.IsNull() || aPnt2.IsNull() ||
142 aPnt3.IsNull() || aPnt4.IsNull()) return aGEOMObject._retn();
145 HANDLE_NAMESPACE(GEOM_Object) anObject =
146 GetOperations()->MakeQuad4Vertices(aPnt1, aPnt2, aPnt3, aPnt4);
147 if (!GetOperations()->IsDone() || anObject.IsNull())
148 return aGEOMObject._retn();
150 return GetObject(anObject);
153 //=============================================================================
157 //=============================================================================
158 GEOM::GEOM_Object_ptr GEOM_IBlocksOperations_i::MakeHexa
159 (GEOM::GEOM_Object_ptr theFace1, GEOM::GEOM_Object_ptr theFace2,
160 GEOM::GEOM_Object_ptr theFace3, GEOM::GEOM_Object_ptr theFace4,
161 GEOM::GEOM_Object_ptr theFace5, GEOM::GEOM_Object_ptr theFace6)
163 GEOM::GEOM_Object_var aGEOMObject;
165 //Set a not done flag
166 GetOperations()->SetNotDone();
168 //Get the reference Faces
169 HANDLE_NAMESPACE(GEOM_Object) anFace1 = GetObjectImpl(theFace1);
170 HANDLE_NAMESPACE(GEOM_Object) anFace2 = GetObjectImpl(theFace2);
171 HANDLE_NAMESPACE(GEOM_Object) anFace3 = GetObjectImpl(theFace3);
172 HANDLE_NAMESPACE(GEOM_Object) anFace4 = GetObjectImpl(theFace4);
173 HANDLE_NAMESPACE(GEOM_Object) anFace5 = GetObjectImpl(theFace5);
174 HANDLE_NAMESPACE(GEOM_Object) anFace6 = GetObjectImpl(theFace6);
176 if (anFace1.IsNull() || anFace2.IsNull() ||
177 anFace3.IsNull() || anFace4.IsNull() ||
178 anFace5.IsNull() || anFace6.IsNull()) return aGEOMObject._retn();
181 HANDLE_NAMESPACE(GEOM_Object) anObject = GetOperations()->MakeHexa
182 (anFace1, anFace2, anFace3, anFace4, anFace5, anFace6);
183 if (!GetOperations()->IsDone() || anObject.IsNull())
184 return aGEOMObject._retn();
186 return GetObject(anObject);
189 //=============================================================================
193 //=============================================================================
194 GEOM::GEOM_Object_ptr GEOM_IBlocksOperations_i::MakeHexa2Faces
195 (GEOM::GEOM_Object_ptr theFace1, GEOM::GEOM_Object_ptr theFace2)
197 GEOM::GEOM_Object_var aGEOMObject;
199 //Set a not done flag
200 GetOperations()->SetNotDone();
202 //Get the reference Faces
203 HANDLE_NAMESPACE(GEOM_Object) anFace1 = GetObjectImpl(theFace1);
204 HANDLE_NAMESPACE(GEOM_Object) anFace2 = GetObjectImpl(theFace2);
206 if (anFace1.IsNull() || anFace2.IsNull()) return aGEOMObject._retn();
209 HANDLE_NAMESPACE(GEOM_Object) anObject =
210 GetOperations()->MakeHexa2Faces(anFace1, anFace2);
211 if (!GetOperations()->IsDone() || anObject.IsNull())
212 return aGEOMObject._retn();
214 return GetObject(anObject);
217 //=============================================================================
221 //=============================================================================
222 GEOM::GEOM_Object_ptr GEOM_IBlocksOperations_i::MakeBlockCompound
223 (GEOM::GEOM_Object_ptr theCompound)
225 GEOM::GEOM_Object_var aGEOMObject;
227 //Set a not done flag
228 GetOperations()->SetNotDone();
230 //Get the reference Compound
231 HANDLE_NAMESPACE(GEOM_Object) aCompound = GetObjectImpl(theCompound);
232 if (aCompound.IsNull()) return aGEOMObject._retn();
234 //Create the Blocks Compound
235 HANDLE_NAMESPACE(GEOM_Object) anObject =
236 GetOperations()->MakeBlockCompound(aCompound);
237 if (!GetOperations()->IsDone() || anObject.IsNull())
238 return aGEOMObject._retn();
240 return GetObject(anObject);
243 //=============================================================================
247 //=============================================================================
248 GEOM::GEOM_Object_ptr GEOM_IBlocksOperations_i::GetPoint (GEOM::GEOM_Object_ptr theShape,
249 const CORBA::Double theX,
250 const CORBA::Double theY,
251 const CORBA::Double theZ,
252 const CORBA::Double theEpsilon)
254 GEOM::GEOM_Object_var aGEOMObject;
256 //Set a not done flag
257 GetOperations()->SetNotDone();
259 //Get the reference Objects
260 HANDLE_NAMESPACE(GEOM_Object) aShape = GetObjectImpl(theShape);
261 if (aShape.IsNull()) return aGEOMObject._retn();
264 HANDLE_NAMESPACE(GEOM_Object) anObject =
265 GetOperations()->GetPoint(aShape, theX, theY, theZ, theEpsilon);
266 if (!GetOperations()->IsDone() || anObject.IsNull())
267 return aGEOMObject._retn();
269 return GetObject(anObject);
272 //=============================================================================
276 //=============================================================================
277 GEOM::GEOM_Object_ptr GEOM_IBlocksOperations_i::GetVertexNearPoint
278 (GEOM::GEOM_Object_ptr theShape,
279 GEOM::GEOM_Object_ptr thePoint)
281 GEOM::GEOM_Object_var aGEOMObject;
283 // Set a not done flag
284 GetOperations()->SetNotDone();
286 // Get the reference Objects
287 HANDLE_NAMESPACE(GEOM_Object) aShape = GetObjectImpl(theShape);
288 HANDLE_NAMESPACE(GEOM_Object) aPoint = GetObjectImpl(thePoint);
289 if (aShape.IsNull() || aPoint.IsNull()) return aGEOMObject._retn();
292 HANDLE_NAMESPACE(GEOM_Object) anObject =
293 GetOperations()->GetVertexNearPoint(aShape, aPoint);
294 if (!GetOperations()->IsDone() || anObject.IsNull())
295 return aGEOMObject._retn();
297 return GetObject(anObject);
300 //=============================================================================
304 //=============================================================================
305 GEOM::GEOM_Object_ptr GEOM_IBlocksOperations_i::GetEdge (GEOM::GEOM_Object_ptr theShape,
306 GEOM::GEOM_Object_ptr thePoint1,
307 GEOM::GEOM_Object_ptr thePoint2)
309 GEOM::GEOM_Object_var aGEOMObject;
311 //Set a not done flag
312 GetOperations()->SetNotDone();
314 //Get the reference Objects
315 HANDLE_NAMESPACE(GEOM_Object) aShape = GetObjectImpl(theShape);
316 HANDLE_NAMESPACE(GEOM_Object) aPoint1 = GetObjectImpl(thePoint1);
317 HANDLE_NAMESPACE(GEOM_Object) aPoint2 = GetObjectImpl(thePoint2);
319 if (aShape.IsNull() ||
320 aPoint1.IsNull() || aPoint2.IsNull()) return aGEOMObject._retn();
323 HANDLE_NAMESPACE(GEOM_Object) anObject =
324 GetOperations()->GetEdge(aShape, aPoint1, aPoint2);
325 if (!GetOperations()->IsDone() || anObject.IsNull())
326 return aGEOMObject._retn();
328 return GetObject(anObject);
331 //=============================================================================
335 //=============================================================================
336 GEOM::GEOM_Object_ptr GEOM_IBlocksOperations_i::GetEdgeNearPoint (GEOM::GEOM_Object_ptr theShape,
337 GEOM::GEOM_Object_ptr thePoint)
339 GEOM::GEOM_Object_var aGEOMObject;
341 //Set a not done flag
342 GetOperations()->SetNotDone();
344 //Get the reference Objects
345 HANDLE_NAMESPACE(GEOM_Object) aShape = GetObjectImpl(theShape);
346 HANDLE_NAMESPACE(GEOM_Object) aPoint = GetObjectImpl(thePoint);
348 if (aShape.IsNull() || aPoint.IsNull()) return aGEOMObject._retn();
351 HANDLE_NAMESPACE(GEOM_Object) anObject =
352 GetOperations()->GetEdgeNearPoint(aShape, aPoint);
353 if (!GetOperations()->IsDone() || anObject.IsNull())
354 return aGEOMObject._retn();
356 return GetObject(anObject);
359 //=============================================================================
363 //=============================================================================
364 GEOM::GEOM_Object_ptr GEOM_IBlocksOperations_i::GetFaceByPoints
365 (GEOM::GEOM_Object_ptr theShape,
366 GEOM::GEOM_Object_ptr thePoint1,
367 GEOM::GEOM_Object_ptr thePoint2,
368 GEOM::GEOM_Object_ptr thePoint3,
369 GEOM::GEOM_Object_ptr thePoint4)
371 GEOM::GEOM_Object_var aGEOMObject;
373 //Set a not done flag
374 GetOperations()->SetNotDone();
376 //Get the reference Objects
377 HANDLE_NAMESPACE(GEOM_Object) aShape = GetObjectImpl(theShape);
378 HANDLE_NAMESPACE(GEOM_Object) aPoint1 = GetObjectImpl(thePoint1);
379 HANDLE_NAMESPACE(GEOM_Object) aPoint2 = GetObjectImpl(thePoint2);
380 HANDLE_NAMESPACE(GEOM_Object) aPoint3 = GetObjectImpl(thePoint3);
381 HANDLE_NAMESPACE(GEOM_Object) aPoint4 = GetObjectImpl(thePoint4);
383 if (aShape.IsNull() ||
384 aPoint1.IsNull() || aPoint2.IsNull() ||
385 aPoint3.IsNull() || aPoint4.IsNull()) return aGEOMObject._retn();
388 HANDLE_NAMESPACE(GEOM_Object) anObject =
389 GetOperations()->GetFaceByPoints(aShape, aPoint1, aPoint2, aPoint3, aPoint4);
390 if (!GetOperations()->IsDone() || anObject.IsNull())
391 return aGEOMObject._retn();
393 return GetObject(anObject);
396 //=============================================================================
400 //=============================================================================
401 GEOM::GEOM_Object_ptr GEOM_IBlocksOperations_i::GetFaceByEdges
402 (GEOM::GEOM_Object_ptr theShape,
403 GEOM::GEOM_Object_ptr theEdge1,
404 GEOM::GEOM_Object_ptr theEdge2)
406 GEOM::GEOM_Object_var aGEOMObject;
408 //Set a not done flag
409 GetOperations()->SetNotDone();
411 //Get the reference Objects
412 HANDLE_NAMESPACE(GEOM_Object) aShape = GetObjectImpl(theShape);
413 HANDLE_NAMESPACE(GEOM_Object) anEdge1 = GetObjectImpl(theEdge1);
414 HANDLE_NAMESPACE(GEOM_Object) anEdge2 = GetObjectImpl(theEdge2);
416 if (aShape.IsNull() ||
417 anEdge1.IsNull() || anEdge2.IsNull()) return aGEOMObject._retn();
420 HANDLE_NAMESPACE(GEOM_Object) anObject =
421 GetOperations()->GetFaceByEdges(aShape, anEdge1, anEdge2);
422 if (!GetOperations()->IsDone() || anObject.IsNull())
423 return aGEOMObject._retn();
425 return GetObject(anObject);
428 //=============================================================================
432 //=============================================================================
433 GEOM::GEOM_Object_ptr GEOM_IBlocksOperations_i::GetOppositeFace (GEOM::GEOM_Object_ptr theShape,
434 GEOM::GEOM_Object_ptr theFace)
436 GEOM::GEOM_Object_var aGEOMObject;
438 //Set a not done flag
439 GetOperations()->SetNotDone();
441 //Get the reference Objects
442 HANDLE_NAMESPACE(GEOM_Object) aShape = GetObjectImpl(theShape);
443 HANDLE_NAMESPACE(GEOM_Object) aFace = GetObjectImpl(theFace);
445 if (aShape.IsNull() || aFace.IsNull()) return aGEOMObject._retn();
448 HANDLE_NAMESPACE(GEOM_Object) anObject =
449 GetOperations()->GetOppositeFace(aShape, aFace);
450 if (!GetOperations()->IsDone() || anObject.IsNull())
451 return aGEOMObject._retn();
453 return GetObject(anObject);
456 //=============================================================================
460 //=============================================================================
461 GEOM::GEOM_Object_ptr GEOM_IBlocksOperations_i::GetFaceNearPoint (GEOM::GEOM_Object_ptr theShape,
462 GEOM::GEOM_Object_ptr thePoint)
464 GEOM::GEOM_Object_var aGEOMObject;
466 //Set a not done flag
467 GetOperations()->SetNotDone();
469 //Get the reference Objects
470 HANDLE_NAMESPACE(GEOM_Object) aShape = GetObjectImpl(theShape);
471 HANDLE_NAMESPACE(GEOM_Object) aPoint = GetObjectImpl(thePoint);
473 if (aShape.IsNull() || aPoint.IsNull()) return aGEOMObject._retn();
476 HANDLE_NAMESPACE(GEOM_Object) anObject =
477 GetOperations()->GetFaceNearPoint(aShape, aPoint);
478 if (!GetOperations()->IsDone() || anObject.IsNull())
479 return aGEOMObject._retn();
481 return GetObject(anObject);
484 //=============================================================================
488 //=============================================================================
489 GEOM::GEOM_Object_ptr GEOM_IBlocksOperations_i::GetFaceByNormale (GEOM::GEOM_Object_ptr theShape,
490 GEOM::GEOM_Object_ptr theVector)
492 GEOM::GEOM_Object_var aGEOMObject;
494 //Set a not done flag
495 GetOperations()->SetNotDone();
497 //Get the reference Objects
498 HANDLE_NAMESPACE(GEOM_Object) aShape = GetObjectImpl(theShape);
499 HANDLE_NAMESPACE(GEOM_Object) aVector = GetObjectImpl(theVector);
501 if (aShape.IsNull() || aVector.IsNull()) return aGEOMObject._retn();
504 HANDLE_NAMESPACE(GEOM_Object) anObject =
505 GetOperations()->GetFaceByNormale(aShape, aVector);
506 if (!GetOperations()->IsDone() || anObject.IsNull())
507 return aGEOMObject._retn();
509 return GetObject(anObject);
512 //=============================================================================
516 //=============================================================================
517 GEOM::GEOM_Object_ptr GEOM_IBlocksOperations_i::GetShapesNearPoint
518 (GEOM::GEOM_Object_ptr theShape,
519 GEOM::GEOM_Object_ptr thePoint,
520 CORBA::Long theShapeType,
521 CORBA::Double theTolerance)
523 GEOM::GEOM_Object_var aGEOMObject;
525 // Set a not done flag
526 GetOperations()->SetNotDone();
528 // Get the reference Objects
529 HANDLE_NAMESPACE(GEOM_Object) aShape = GetObjectImpl(theShape);
530 HANDLE_NAMESPACE(GEOM_Object) aPoint = GetObjectImpl(thePoint);
532 if (aShape.IsNull() || aPoint.IsNull()) return aGEOMObject._retn();
535 HANDLE_NAMESPACE(GEOM_Object) anObject =
536 GetOperations()->GetShapesNearPoint(aShape, aPoint, theShapeType, theTolerance);
537 if (!GetOperations()->IsDone() || anObject.IsNull())
538 return aGEOMObject._retn();
540 return GetObject(anObject);
543 //=============================================================================
545 * ExplodeCompoundOfBlocks
547 //=============================================================================
548 GEOM::ListOfGO* GEOM_IBlocksOperations_i::ExplodeCompoundOfBlocks
549 (GEOM::GEOM_Object_ptr theCompound,
550 const CORBA::Long theMinNbFaces,
551 const CORBA::Long theMaxNbFaces)
553 GEOM::ListOfGO_var aSeq = new GEOM::ListOfGO;
555 //Set a not done flag
556 GetOperations()->SetNotDone();
558 //Get the reference Compound
559 HANDLE_NAMESPACE(GEOM_Object) aCompound = GetObjectImpl(theCompound);
560 if (aCompound.IsNull()) return aSeq._retn();
563 Handle(TColStd_HSequenceOfTransient) aHSeq =
564 GetOperations()->ExplodeCompoundOfBlocks(aCompound, theMinNbFaces, theMaxNbFaces);
565 if (!GetOperations()->IsDone() || aHSeq.IsNull())
568 Standard_Integer aLength = aHSeq->Length();
569 aSeq->length(aLength);
570 for (Standard_Integer i = 1; i <= aLength; i++)
571 aSeq[i-1] = GetObject(HANDLE_NAMESPACE(GEOM_Object)::DownCast(aHSeq->Value(i)));
576 //=============================================================================
580 //=============================================================================
581 CORBA::Boolean GEOM_IBlocksOperations_i::IsCompoundOfBlocks
582 (GEOM::GEOM_Object_ptr theCompound,
583 const CORBA::Long theMinNbFaces,
584 const CORBA::Long theMaxNbFaces,
585 CORBA::Long& theNbBlocks)
588 CORBA::Boolean isComp = false;
590 //Set a not done flag
591 GetOperations()->SetNotDone();
593 //Get the reference Compound
594 HANDLE_NAMESPACE(GEOM_Object) aCompound = GetObjectImpl(theCompound);
595 if (aCompound.IsNull()) return isComp;
598 Standard_Integer nbBlocks = 0;
599 isComp = GetOperations()->IsCompoundOfBlocks(aCompound,
603 if (!GetOperations()->IsDone())
606 theNbBlocks = nbBlocks;
610 //=============================================================================
612 * CheckCompoundOfBlocks
614 //=============================================================================
615 CORBA::Boolean GEOM_IBlocksOperations_i::CheckCompoundOfBlocks
616 (GEOM::GEOM_Object_ptr theCompound,
617 const CORBA::Double theToleranceC1,
618 GEOM::GEOM_IBlocksOperations::BCErrors_out theErrors)
620 CORBA::Boolean isComp = false;
622 //Set a not done flag
623 GetOperations()->SetNotDone();
625 //Get the reference Compound
626 HANDLE_NAMESPACE(GEOM_Object) aCompound = GetObjectImpl(theCompound);
627 if (aCompound.IsNull()) return isComp;
630 std::list<GEOMImpl_IBlocksOperations::BCError> errList;
631 isComp = GetOperations()->CheckCompoundOfBlocks
632 (aCompound, theToleranceC1, errList);
633 if (!GetOperations()->IsDone())
636 const int nbErr = errList.size();
637 GEOM::GEOM_IBlocksOperations::BCErrors_var anErrArray =
638 new GEOM::GEOM_IBlocksOperations::BCErrors();
639 anErrArray->length(nbErr);
641 // fill the local CORBA array with values from lists
642 std::list<GEOMImpl_IBlocksOperations::BCError>::iterator errIt = errList.begin();
644 for (; errIt != errList.end(); i++, errIt++) {
645 GEOM::GEOM_IBlocksOperations::BCError_var anError =
646 new GEOM::GEOM_IBlocksOperations::BCError();
648 GEOMImpl_IBlocksOperations::BCError errStruct = *errIt;
650 switch (errStruct.error) {
651 case GEOMImpl_IBlocksOperations::NOT_BLOCK:
652 anError->error = GEOM::GEOM_IBlocksOperations::NOT_BLOCK;
654 case GEOMImpl_IBlocksOperations::EXTRA_EDGE:
655 anError->error = GEOM::GEOM_IBlocksOperations::EXTRA_EDGE;
657 case GEOMImpl_IBlocksOperations::INVALID_CONNECTION:
658 anError->error = GEOM::GEOM_IBlocksOperations::INVALID_CONNECTION;
660 case GEOMImpl_IBlocksOperations::NOT_CONNECTED:
661 anError->error = GEOM::GEOM_IBlocksOperations::NOT_CONNECTED;
663 case GEOMImpl_IBlocksOperations::NOT_GLUED:
664 anError->error = GEOM::GEOM_IBlocksOperations::NOT_GLUED;
670 std::list<int> sshList = errStruct.incriminated;
671 GEOM::ListOfLong_var anIncrims = new GEOM::ListOfLong();
672 anIncrims->length(sshList.size());
674 std::list<int>::iterator sshIt = sshList.begin();
676 for (; sshIt != sshList.end(); jj++, sshIt++) {
677 anIncrims[jj] = *sshIt;
680 anError->incriminated = anIncrims;
682 anErrArray[i] = anError;
685 // initialize out-parameter with local array
686 theErrors = anErrArray._retn();
691 //=============================================================================
695 //=============================================================================
696 char* GEOM_IBlocksOperations_i::PrintBCErrors
697 (GEOM::GEOM_Object_ptr theCompound,
698 const GEOM::GEOM_IBlocksOperations::BCErrors& theErrors)
700 //Get the reference Compound
701 HANDLE_NAMESPACE(GEOM_Object) aCompound = GetObjectImpl(theCompound);
702 if (aCompound.IsNull()) return NULL;
704 // Convert the errors sequence
705 std::list<GEOMImpl_IBlocksOperations::BCError> anErrors;
706 int nbErr = theErrors.length();
708 for (; ie < nbErr; ie++) {
709 const GEOM::GEOM_IBlocksOperations::BCError err = theErrors[ie];
710 const GEOM::GEOM_IBlocksOperations::BCErrorType typ = err.error;
711 const GEOM::ListOfLong incrims = err.incriminated;
713 GEOMImpl_IBlocksOperations::BCError errStruct;
715 case GEOM::GEOM_IBlocksOperations::NOT_BLOCK:
716 errStruct.error = GEOMImpl_IBlocksOperations::NOT_BLOCK;
718 case GEOM::GEOM_IBlocksOperations::EXTRA_EDGE:
719 errStruct.error = GEOMImpl_IBlocksOperations::EXTRA_EDGE;
721 case GEOM::GEOM_IBlocksOperations::INVALID_CONNECTION:
722 errStruct.error = GEOMImpl_IBlocksOperations::INVALID_CONNECTION;
724 case GEOM::GEOM_IBlocksOperations::NOT_CONNECTED:
725 errStruct.error = GEOMImpl_IBlocksOperations::NOT_CONNECTED;
727 case GEOM::GEOM_IBlocksOperations::NOT_GLUED:
728 errStruct.error = GEOMImpl_IBlocksOperations::NOT_GLUED;
735 int aLen = incrims.length();
736 for (; ii < aLen; ii++) {
737 errStruct.incriminated.push_back(incrims[ii]);
740 anErrors.push_back(errStruct);
743 TCollection_AsciiString aDescr = GetOperations()->PrintBCErrors(aCompound, anErrors);
744 return CORBA::string_dup(aDescr.ToCString());
747 //=============================================================================
751 //=============================================================================
752 GEOM::GEOM_Object_ptr GEOM_IBlocksOperations_i::GetNonBlocks
753 (GEOM::GEOM_Object_ptr theShape,
754 const CORBA::Double theToleranceC1,
755 GEOM::GEOM_Object_out theNonQuads)
757 GEOM::GEOM_Object_var aGEOMObject;
758 GEOM::GEOM_Object_var aNonQuads;
760 theNonQuads = aNonQuads._retn();
762 //Set a not done flag
763 GetOperations()->SetNotDone();
765 //Get the reference Objects
766 HANDLE_NAMESPACE(GEOM_Object) aShape = GetObjectImpl(theShape);
767 if (aShape.IsNull()) return aGEOMObject._retn();
770 HANDLE_NAMESPACE(GEOM_Object) aFaces;
771 HANDLE_NAMESPACE(GEOM_Object) anObject =
772 GetOperations()->GetNonBlocks(aShape, theToleranceC1, aFaces);
773 if (!GetOperations()->IsDone())
774 return aGEOMObject._retn();
776 if (!aFaces.IsNull())
777 theNonQuads = GetObject(aFaces);
779 if (anObject.IsNull())
780 return aGEOMObject._retn();
782 return GetObject(anObject);
785 //=============================================================================
789 //=============================================================================
790 GEOM::GEOM_Object_ptr GEOM_IBlocksOperations_i::RemoveExtraEdges
791 (GEOM::GEOM_Object_ptr theShape,
792 CORBA::Long theOptimumNbFaces)
794 GEOM::GEOM_Object_var aGEOMObject;
796 //Set a not done flag
797 GetOperations()->SetNotDone();
799 //Get the reference Objects
800 HANDLE_NAMESPACE(GEOM_Object) aShape = GetObjectImpl(theShape);
801 if (aShape.IsNull()) return aGEOMObject._retn();
804 HANDLE_NAMESPACE(GEOM_Object) anObject = GetOperations()->RemoveExtraEdges(aShape, theOptimumNbFaces);
805 if (!GetOperations()->IsDone() || anObject.IsNull())
806 return aGEOMObject._retn();
808 return GetObject(anObject);
811 //=============================================================================
815 //=============================================================================
816 GEOM::GEOM_Object_ptr GEOM_IBlocksOperations_i::UnionFaces
817 (GEOM::GEOM_Object_ptr theShape)
819 GEOM::GEOM_Object_var aGEOMObject;
821 //Set a not done flag
822 GetOperations()->SetNotDone();
824 //Get the reference Objects
825 HANDLE_NAMESPACE(GEOM_Object) aShape = GetObjectImpl(theShape);
826 if (aShape.IsNull()) return aGEOMObject._retn();
829 HANDLE_NAMESPACE(GEOM_Object) anObject = GetOperations()->UnionFaces(aShape);
830 if (!GetOperations()->IsDone() || anObject.IsNull())
831 return aGEOMObject._retn();
833 return GetObject(anObject);
836 //=============================================================================
840 //=============================================================================
841 GEOM::GEOM_Object_ptr GEOM_IBlocksOperations_i::CheckAndImprove (GEOM::GEOM_Object_ptr theCompound)
843 GEOM::GEOM_Object_var aGEOMObject;
845 //Set a not done flag
846 GetOperations()->SetNotDone();
848 //Get the reference Objects
849 HANDLE_NAMESPACE(GEOM_Object) aCompound = GetObjectImpl(theCompound);
850 if (aCompound.IsNull()) return aGEOMObject._retn();
853 HANDLE_NAMESPACE(GEOM_Object) anObject =
854 GetOperations()->CheckAndImprove(aCompound);
855 if (!GetOperations()->IsDone() || anObject.IsNull())
856 return aGEOMObject._retn();
858 return GetObject(anObject);
861 //=============================================================================
865 //=============================================================================
866 GEOM::GEOM_Object_ptr GEOM_IBlocksOperations_i::GetBlockNearPoint (GEOM::GEOM_Object_ptr theCompound,
867 GEOM::GEOM_Object_ptr thePoint)
869 GEOM::GEOM_Object_var aGEOMObject;
871 //Set a not done flag
872 GetOperations()->SetNotDone();
874 //Get the reference Objects
875 HANDLE_NAMESPACE(GEOM_Object) aCompound = GetObjectImpl(theCompound);
876 HANDLE_NAMESPACE(GEOM_Object) aPoint = GetObjectImpl(thePoint);
878 if (aCompound.IsNull() || aPoint.IsNull()) return aGEOMObject._retn();
881 HANDLE_NAMESPACE(GEOM_Object) anObject =
882 GetOperations()->GetBlockNearPoint(aCompound, aPoint);
883 if (!GetOperations()->IsDone() || anObject.IsNull())
884 return aGEOMObject._retn();
886 return GetObject(anObject);
889 //=============================================================================
893 //=============================================================================
894 GEOM::GEOM_Object_ptr GEOM_IBlocksOperations_i::GetBlockByParts (GEOM::GEOM_Object_ptr theCompound,
895 const GEOM::ListOfGO& theParts)
897 GEOM::GEOM_Object_var aGEOMObject;
899 //Set a not done flag
900 GetOperations()->SetNotDone();
902 //Get the reference Compound
903 HANDLE_NAMESPACE(GEOM_Object) aCompound = GetObjectImpl(theCompound);
904 if (aCompound.IsNull()) return aGEOMObject._retn();
908 Handle(TColStd_HSequenceOfTransient) aParts = new TColStd_HSequenceOfTransient;
910 aLen = theParts.length();
911 for (ind = 0; ind < aLen; ind++) {
912 HANDLE_NAMESPACE(GEOM_Object) aSh = GetObjectImpl(theParts[ind]);
913 if (aSh.IsNull()) return aGEOMObject._retn();
918 HANDLE_NAMESPACE(GEOM_Object) anObject =
919 GetOperations()->GetBlockByParts(aCompound, aParts);
920 if (!GetOperations()->IsDone() || anObject.IsNull())
921 return aGEOMObject._retn();
923 return GetObject(anObject);
926 //=============================================================================
930 //=============================================================================
931 GEOM::ListOfGO* GEOM_IBlocksOperations_i::GetBlocksByParts (GEOM::GEOM_Object_ptr theCompound,
932 const GEOM::ListOfGO& theParts)
934 GEOM::ListOfGO_var aSeq = new GEOM::ListOfGO;
936 //Set a not done flag
937 GetOperations()->SetNotDone();
939 //Get the reference Compound
940 HANDLE_NAMESPACE(GEOM_Object) aCompound = GetObjectImpl(theCompound);
941 if (aCompound.IsNull()) return aSeq._retn();
945 Handle(TColStd_HSequenceOfTransient) aParts = new TColStd_HSequenceOfTransient;
947 aLen = theParts.length();
948 for (ind = 0; ind < aLen; ind++) {
949 HANDLE_NAMESPACE(GEOM_Object) aSh = GetObjectImpl(theParts[ind]);
950 if (aSh.IsNull()) return aSeq._retn();
955 Handle(TColStd_HSequenceOfTransient) aHSeq =
956 GetOperations()->GetBlocksByParts(aCompound, aParts);
957 if (!GetOperations()->IsDone() || aHSeq.IsNull())
960 Standard_Integer aLength = aHSeq->Length();
961 aSeq->length(aLength);
962 for (Standard_Integer i = 1; i <= aLength; i++)
963 aSeq[i-1] = GetObject(HANDLE_NAMESPACE(GEOM_Object)::DownCast(aHSeq->Value(i)));
968 //=============================================================================
970 * MakeMultiTransformation1D
972 //=============================================================================
973 GEOM::GEOM_Object_ptr GEOM_IBlocksOperations_i::MakeMultiTransformation1D
974 (GEOM::GEOM_Object_ptr theBlock,
975 const CORBA::Long theDirFace1,
976 const CORBA::Long theDirFace2,
977 const CORBA::Long theNbTimes)
979 GEOM::GEOM_Object_var aGEOMObject;
981 //Set a not done flag
982 GetOperations()->SetNotDone();
984 //Get the object itself and the vector of translation
985 HANDLE_NAMESPACE(GEOM_Object) aBasicObject = GetObjectImpl(theBlock);
986 if (aBasicObject.IsNull()) return aGEOMObject._retn();
988 //Perform the transformation
989 HANDLE_NAMESPACE(GEOM_Object) anObject = GetOperations()->MakeMultiTransformation1D
990 (aBasicObject, theDirFace1, theDirFace2, theNbTimes);
991 if (!GetOperations()->IsDone() || anObject.IsNull()) return aGEOMObject._retn();
993 return GetObject(anObject);
996 //=============================================================================
998 * MakeMultiTransformation2D
1000 //=============================================================================
1001 GEOM::GEOM_Object_ptr GEOM_IBlocksOperations_i::MakeMultiTransformation2D
1002 (GEOM::GEOM_Object_ptr theBlock,
1003 const CORBA::Long theDirFace1U,
1004 const CORBA::Long theDirFace2U,
1005 const CORBA::Long theNbTimesU,
1006 const CORBA::Long theDirFace1V,
1007 const CORBA::Long theDirFace2V,
1008 const CORBA::Long theNbTimesV)
1010 GEOM::GEOM_Object_var aGEOMObject;
1012 //Set a not done flag
1013 GetOperations()->SetNotDone();
1015 //Get the object itself
1016 HANDLE_NAMESPACE(GEOM_Object) aBasicObject = GetObjectImpl(theBlock);
1017 if (aBasicObject.IsNull()) return aGEOMObject._retn();
1019 //Perform the transformation
1020 HANDLE_NAMESPACE(GEOM_Object) anObject = GetOperations()->MakeMultiTransformation2D
1022 theDirFace1U, theDirFace2U, theNbTimesU,
1023 theDirFace1V, theDirFace2V, theNbTimesV);
1024 if (!GetOperations()->IsDone() || anObject.IsNull()) return aGEOMObject._retn();
1026 return GetObject(anObject);
1029 //=============================================================================
1033 //=============================================================================
1034 GEOM::ListOfGO* GEOM_IBlocksOperations_i::Propagate (GEOM::GEOM_Object_ptr theShape)
1036 GEOM::ListOfGO_var aSeq = new GEOM::ListOfGO;
1038 //Set a not done flag
1039 GetOperations()->SetNotDone();
1041 //Get the reference Shape
1042 HANDLE_NAMESPACE(GEOM_Object) aShape = GetObjectImpl(theShape);
1043 if (aShape.IsNull()) return aSeq._retn();
1045 //Get the Propagation chains
1046 Handle(TColStd_HSequenceOfTransient) aHSeq =
1047 GetOperations()->Propagate(aShape);
1048 if (!GetOperations()->IsDone() || aHSeq.IsNull())
1049 return aSeq._retn();
1051 Standard_Integer aLength = aHSeq->Length();
1052 aSeq->length(aLength);
1053 for (Standard_Integer i = 1; i <= aLength; i++)
1054 aSeq[i-1] = GetObject(HANDLE_NAMESPACE(GEOM_Object)::DownCast(aHSeq->Value(i)));
1056 return aSeq._retn();