1 // Copyright (C) 2007-2010 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
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(GEOM_Object) anEdge1 = GetObjectImpl(theEdge1);
77 Handle(GEOM_Object) anEdge2 = GetObjectImpl(theEdge2);
78 Handle(GEOM_Object) anEdge3 = GetObjectImpl(theEdge3);
79 Handle(GEOM_Object) anEdge4 = GetObjectImpl(theEdge4);
81 if (anEdge1.IsNull() || anEdge2.IsNull() ||
82 anEdge3.IsNull() || anEdge4.IsNull()) return aGEOMObject._retn();
85 Handle(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(GEOM_Object) anEdge1 = GetObjectImpl(theEdge1);
108 Handle(GEOM_Object) anEdge2 = GetObjectImpl(theEdge2);
110 if (anEdge1.IsNull() || anEdge2.IsNull()) return aGEOMObject._retn();
113 Handle(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(GEOM_Object) aPnt1 = GetObjectImpl(thePnt1);
137 Handle(GEOM_Object) aPnt2 = GetObjectImpl(thePnt2);
138 Handle(GEOM_Object) aPnt3 = GetObjectImpl(thePnt3);
139 Handle(GEOM_Object) aPnt4 = GetObjectImpl(thePnt4);
141 if (aPnt1.IsNull() || aPnt2.IsNull() ||
142 aPnt3.IsNull() || aPnt4.IsNull()) return aGEOMObject._retn();
145 Handle(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(GEOM_Object) anFace1 = GetObjectImpl(theFace1);
170 Handle(GEOM_Object) anFace2 = GetObjectImpl(theFace2);
171 Handle(GEOM_Object) anFace3 = GetObjectImpl(theFace3);
172 Handle(GEOM_Object) anFace4 = GetObjectImpl(theFace4);
173 Handle(GEOM_Object) anFace5 = GetObjectImpl(theFace5);
174 Handle(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(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(GEOM_Object) anFace1 = GetObjectImpl(theFace1);
204 Handle(GEOM_Object) anFace2 = GetObjectImpl(theFace2);
206 if (anFace1.IsNull() || anFace2.IsNull()) return aGEOMObject._retn();
209 Handle(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(GEOM_Object) aCompound = GetObjectImpl(theCompound);
232 if (aCompound.IsNull()) return aGEOMObject._retn();
234 //Create the Blocks Compound
235 Handle(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(GEOM_Object) aShape = GetObjectImpl(theShape);
261 if (aShape.IsNull()) return aGEOMObject._retn();
264 Handle(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::GetEdge (GEOM::GEOM_Object_ptr theShape,
278 GEOM::GEOM_Object_ptr thePoint1,
279 GEOM::GEOM_Object_ptr thePoint2)
281 GEOM::GEOM_Object_var aGEOMObject;
283 //Set a not done flag
284 GetOperations()->SetNotDone();
286 //Get the reference Objects
287 Handle(GEOM_Object) aShape = GetObjectImpl(theShape);
288 Handle(GEOM_Object) aPoint1 = GetObjectImpl(thePoint1);
289 Handle(GEOM_Object) aPoint2 = GetObjectImpl(thePoint2);
291 if (aShape.IsNull() ||
292 aPoint1.IsNull() || aPoint2.IsNull()) return aGEOMObject._retn();
295 Handle(GEOM_Object) anObject =
296 GetOperations()->GetEdge(aShape, aPoint1, aPoint2);
297 if (!GetOperations()->IsDone() || anObject.IsNull())
298 return aGEOMObject._retn();
300 return GetObject(anObject);
303 //=============================================================================
307 //=============================================================================
308 GEOM::GEOM_Object_ptr GEOM_IBlocksOperations_i::GetEdgeNearPoint (GEOM::GEOM_Object_ptr theShape,
309 GEOM::GEOM_Object_ptr thePoint)
311 GEOM::GEOM_Object_var aGEOMObject;
313 //Set a not done flag
314 GetOperations()->SetNotDone();
316 //Get the reference Objects
317 Handle(GEOM_Object) aShape = GetObjectImpl(theShape);
318 Handle(GEOM_Object) aPoint = GetObjectImpl(thePoint);
320 if (aShape.IsNull() || aPoint.IsNull()) return aGEOMObject._retn();
323 Handle(GEOM_Object) anObject =
324 GetOperations()->GetEdgeNearPoint(aShape, aPoint);
325 if (!GetOperations()->IsDone() || anObject.IsNull())
326 return aGEOMObject._retn();
328 return GetObject(anObject);
331 //=============================================================================
335 //=============================================================================
336 GEOM::GEOM_Object_ptr GEOM_IBlocksOperations_i::GetFaceByPoints
337 (GEOM::GEOM_Object_ptr theShape,
338 GEOM::GEOM_Object_ptr thePoint1,
339 GEOM::GEOM_Object_ptr thePoint2,
340 GEOM::GEOM_Object_ptr thePoint3,
341 GEOM::GEOM_Object_ptr thePoint4)
343 GEOM::GEOM_Object_var aGEOMObject;
345 //Set a not done flag
346 GetOperations()->SetNotDone();
348 //Get the reference Objects
349 Handle(GEOM_Object) aShape = GetObjectImpl(theShape);
350 Handle(GEOM_Object) aPoint1 = GetObjectImpl(thePoint1);
351 Handle(GEOM_Object) aPoint2 = GetObjectImpl(thePoint2);
352 Handle(GEOM_Object) aPoint3 = GetObjectImpl(thePoint3);
353 Handle(GEOM_Object) aPoint4 = GetObjectImpl(thePoint4);
355 if (aShape.IsNull() ||
356 aPoint1.IsNull() || aPoint2.IsNull() ||
357 aPoint3.IsNull() || aPoint4.IsNull()) return aGEOMObject._retn();
360 Handle(GEOM_Object) anObject =
361 GetOperations()->GetFaceByPoints(aShape, aPoint1, aPoint2, aPoint3, aPoint4);
362 if (!GetOperations()->IsDone() || anObject.IsNull())
363 return aGEOMObject._retn();
365 return GetObject(anObject);
368 //=============================================================================
372 //=============================================================================
373 GEOM::GEOM_Object_ptr GEOM_IBlocksOperations_i::GetFaceByEdges
374 (GEOM::GEOM_Object_ptr theShape,
375 GEOM::GEOM_Object_ptr theEdge1,
376 GEOM::GEOM_Object_ptr theEdge2)
378 GEOM::GEOM_Object_var aGEOMObject;
380 //Set a not done flag
381 GetOperations()->SetNotDone();
383 //Get the reference Objects
384 Handle(GEOM_Object) aShape = GetObjectImpl(theShape);
385 Handle(GEOM_Object) anEdge1 = GetObjectImpl(theEdge1);
386 Handle(GEOM_Object) anEdge2 = GetObjectImpl(theEdge2);
388 if (aShape.IsNull() ||
389 anEdge1.IsNull() || anEdge2.IsNull()) return aGEOMObject._retn();
392 Handle(GEOM_Object) anObject =
393 GetOperations()->GetFaceByEdges(aShape, anEdge1, anEdge2);
394 if (!GetOperations()->IsDone() || anObject.IsNull())
395 return aGEOMObject._retn();
397 return GetObject(anObject);
400 //=============================================================================
404 //=============================================================================
405 GEOM::GEOM_Object_ptr GEOM_IBlocksOperations_i::GetOppositeFace (GEOM::GEOM_Object_ptr theShape,
406 GEOM::GEOM_Object_ptr theFace)
408 GEOM::GEOM_Object_var aGEOMObject;
410 //Set a not done flag
411 GetOperations()->SetNotDone();
413 //Get the reference Objects
414 Handle(GEOM_Object) aShape = GetObjectImpl(theShape);
415 Handle(GEOM_Object) aFace = GetObjectImpl(theFace);
417 if (aShape.IsNull() || aFace.IsNull()) return aGEOMObject._retn();
420 Handle(GEOM_Object) anObject =
421 GetOperations()->GetOppositeFace(aShape, aFace);
422 if (!GetOperations()->IsDone() || anObject.IsNull())
423 return aGEOMObject._retn();
425 return GetObject(anObject);
428 //=============================================================================
432 //=============================================================================
433 GEOM::GEOM_Object_ptr GEOM_IBlocksOperations_i::GetFaceNearPoint (GEOM::GEOM_Object_ptr theShape,
434 GEOM::GEOM_Object_ptr thePoint)
436 GEOM::GEOM_Object_var aGEOMObject;
438 //Set a not done flag
439 GetOperations()->SetNotDone();
441 //Get the reference Objects
442 Handle(GEOM_Object) aShape = GetObjectImpl(theShape);
443 Handle(GEOM_Object) aPoint = GetObjectImpl(thePoint);
445 if (aShape.IsNull() || aPoint.IsNull()) return aGEOMObject._retn();
448 Handle(GEOM_Object) anObject =
449 GetOperations()->GetFaceNearPoint(aShape, aPoint);
450 if (!GetOperations()->IsDone() || anObject.IsNull())
451 return aGEOMObject._retn();
453 return GetObject(anObject);
456 //=============================================================================
460 //=============================================================================
461 GEOM::GEOM_Object_ptr GEOM_IBlocksOperations_i::GetFaceByNormale (GEOM::GEOM_Object_ptr theShape,
462 GEOM::GEOM_Object_ptr theVector)
464 GEOM::GEOM_Object_var aGEOMObject;
466 //Set a not done flag
467 GetOperations()->SetNotDone();
469 //Get the reference Objects
470 Handle(GEOM_Object) aShape = GetObjectImpl(theShape);
471 Handle(GEOM_Object) aVector = GetObjectImpl(theVector);
473 if (aShape.IsNull() || aVector.IsNull()) return aGEOMObject._retn();
476 Handle(GEOM_Object) anObject =
477 GetOperations()->GetFaceByNormale(aShape, aVector);
478 if (!GetOperations()->IsDone() || anObject.IsNull())
479 return aGEOMObject._retn();
481 return GetObject(anObject);
484 //=============================================================================
486 * ExplodeCompoundOfBlocks
488 //=============================================================================
489 GEOM::ListOfGO* GEOM_IBlocksOperations_i::ExplodeCompoundOfBlocks
490 (GEOM::GEOM_Object_ptr theCompound,
491 const CORBA::Long theMinNbFaces,
492 const CORBA::Long theMaxNbFaces)
494 GEOM::ListOfGO_var aSeq = new GEOM::ListOfGO;
496 //Set a not done flag
497 GetOperations()->SetNotDone();
499 //Get the reference Compound
500 Handle(GEOM_Object) aCompound = GetObjectImpl(theCompound);
501 if (aCompound.IsNull()) return aSeq._retn();
504 Handle(TColStd_HSequenceOfTransient) aHSeq =
505 GetOperations()->ExplodeCompoundOfBlocks(aCompound, theMinNbFaces, theMaxNbFaces);
506 if (!GetOperations()->IsDone() || aHSeq.IsNull())
509 Standard_Integer aLength = aHSeq->Length();
510 aSeq->length(aLength);
511 for (Standard_Integer i = 1; i <= aLength; i++)
512 aSeq[i-1] = GetObject(Handle(GEOM_Object)::DownCast(aHSeq->Value(i)));
517 //=============================================================================
521 //=============================================================================
522 CORBA::Boolean GEOM_IBlocksOperations_i::IsCompoundOfBlocks
523 (GEOM::GEOM_Object_ptr theCompound,
524 const CORBA::Long theMinNbFaces,
525 const CORBA::Long theMaxNbFaces,
526 CORBA::Long& theNbBlocks)
529 CORBA::Boolean isComp = false;
531 //Set a not done flag
532 GetOperations()->SetNotDone();
534 //Get the reference Compound
535 Handle(GEOM_Object) aCompound = GetObjectImpl(theCompound);
536 if (aCompound.IsNull()) return isComp;
539 Standard_Integer nbBlocks = 0;
540 isComp = GetOperations()->IsCompoundOfBlocks(aCompound,
544 if (!GetOperations()->IsDone())
547 theNbBlocks = nbBlocks;
551 //=============================================================================
553 * CheckCompoundOfBlocks
555 //=============================================================================
556 CORBA::Boolean GEOM_IBlocksOperations_i::CheckCompoundOfBlocks
557 (GEOM::GEOM_Object_ptr theCompound,
558 GEOM::GEOM_IBlocksOperations::BCErrors_out theErrors)
560 CORBA::Boolean isComp = false;
562 //Set a not done flag
563 GetOperations()->SetNotDone();
565 //Get the reference Compound
566 Handle(GEOM_Object) aCompound = GetObjectImpl(theCompound);
567 if (aCompound.IsNull()) return isComp;
570 std::list<GEOMImpl_IBlocksOperations::BCError> errList;
571 isComp = GetOperations()->CheckCompoundOfBlocks(aCompound, errList);
572 if (!GetOperations()->IsDone())
575 const int nbErr = errList.size();
576 GEOM::GEOM_IBlocksOperations::BCErrors_var anErrArray =
577 new GEOM::GEOM_IBlocksOperations::BCErrors();
578 anErrArray->length(nbErr);
580 // fill the local CORBA array with values from lists
581 std::list<GEOMImpl_IBlocksOperations::BCError>::iterator errIt = errList.begin();
583 for (; errIt != errList.end(); i++, errIt++) {
584 GEOM::GEOM_IBlocksOperations::BCError_var anError =
585 new GEOM::GEOM_IBlocksOperations::BCError();
587 GEOMImpl_IBlocksOperations::BCError errStruct = *errIt;
589 switch (errStruct.error) {
590 case GEOMImpl_IBlocksOperations::NOT_BLOCK:
591 anError->error = GEOM::GEOM_IBlocksOperations::NOT_BLOCK;
593 case GEOMImpl_IBlocksOperations::EXTRA_EDGE:
594 anError->error = GEOM::GEOM_IBlocksOperations::EXTRA_EDGE;
596 case GEOMImpl_IBlocksOperations::INVALID_CONNECTION:
597 anError->error = GEOM::GEOM_IBlocksOperations::INVALID_CONNECTION;
599 case GEOMImpl_IBlocksOperations::NOT_CONNECTED:
600 anError->error = GEOM::GEOM_IBlocksOperations::NOT_CONNECTED;
602 case GEOMImpl_IBlocksOperations::NOT_GLUED:
603 anError->error = GEOM::GEOM_IBlocksOperations::NOT_GLUED;
609 std::list<int> sshList = errStruct.incriminated;
610 GEOM::ListOfLong_var anIncrims = new GEOM::ListOfLong();
611 anIncrims->length(sshList.size());
613 std::list<int>::iterator sshIt = sshList.begin();
615 for (; sshIt != sshList.end(); jj++, sshIt++) {
616 anIncrims[jj] = *sshIt;
619 anError->incriminated = anIncrims;
621 anErrArray[i] = anError;
624 // initialize out-parameter with local array
625 theErrors = anErrArray._retn();
630 //=============================================================================
634 //=============================================================================
635 char* GEOM_IBlocksOperations_i::PrintBCErrors
636 (GEOM::GEOM_Object_ptr theCompound,
637 const GEOM::GEOM_IBlocksOperations::BCErrors& theErrors)
639 //Get the reference Compound
640 Handle(GEOM_Object) aCompound = GetObjectImpl(theCompound);
641 if (aCompound.IsNull()) return NULL;
643 // Convert the errors sequence
644 std::list<GEOMImpl_IBlocksOperations::BCError> anErrors;
645 int nbErr = theErrors.length();
647 for (; ie < nbErr; ie++) {
648 const GEOM::GEOM_IBlocksOperations::BCError err = theErrors[ie];
649 const GEOM::GEOM_IBlocksOperations::BCErrorType typ = err.error;
650 const GEOM::ListOfLong incrims = err.incriminated;
652 GEOMImpl_IBlocksOperations::BCError errStruct;
654 case GEOM::GEOM_IBlocksOperations::NOT_BLOCK:
655 errStruct.error = GEOMImpl_IBlocksOperations::NOT_BLOCK;
657 case GEOM::GEOM_IBlocksOperations::EXTRA_EDGE:
658 errStruct.error = GEOMImpl_IBlocksOperations::EXTRA_EDGE;
660 case GEOM::GEOM_IBlocksOperations::INVALID_CONNECTION:
661 errStruct.error = GEOMImpl_IBlocksOperations::INVALID_CONNECTION;
663 case GEOM::GEOM_IBlocksOperations::NOT_CONNECTED:
664 errStruct.error = GEOMImpl_IBlocksOperations::NOT_CONNECTED;
666 case GEOM::GEOM_IBlocksOperations::NOT_GLUED:
667 errStruct.error = GEOMImpl_IBlocksOperations::NOT_GLUED;
674 int aLen = incrims.length();
675 for (; ii < aLen; ii++) {
676 errStruct.incriminated.push_back(incrims[ii]);
679 anErrors.push_back(errStruct);
682 TCollection_AsciiString aDescr = GetOperations()->PrintBCErrors(aCompound, anErrors);
683 return CORBA::string_dup(aDescr.ToCString());
686 //=============================================================================
690 //=============================================================================
691 GEOM::GEOM_Object_ptr GEOM_IBlocksOperations_i::RemoveExtraEdges
692 (GEOM::GEOM_Object_ptr theShape,
693 CORBA::Long theOptimumNbFaces)
695 GEOM::GEOM_Object_var aGEOMObject;
697 //Set a not done flag
698 GetOperations()->SetNotDone();
700 //Get the reference Objects
701 Handle(GEOM_Object) aShape = GetObjectImpl(theShape);
702 if (aShape.IsNull()) return aGEOMObject._retn();
705 Handle(GEOM_Object) anObject = GetOperations()->RemoveExtraEdges(aShape, theOptimumNbFaces);
706 if (!GetOperations()->IsDone() || anObject.IsNull())
707 return aGEOMObject._retn();
709 return GetObject(anObject);
712 //=============================================================================
716 //=============================================================================
717 GEOM::GEOM_Object_ptr GEOM_IBlocksOperations_i::CheckAndImprove (GEOM::GEOM_Object_ptr theCompound)
719 GEOM::GEOM_Object_var aGEOMObject;
721 //Set a not done flag
722 GetOperations()->SetNotDone();
724 //Get the reference Objects
725 Handle(GEOM_Object) aCompound = GetObjectImpl(theCompound);
726 if (aCompound.IsNull()) return aGEOMObject._retn();
729 Handle(GEOM_Object) anObject =
730 GetOperations()->CheckAndImprove(aCompound);
731 if (!GetOperations()->IsDone() || anObject.IsNull())
732 return aGEOMObject._retn();
734 return GetObject(anObject);
737 //=============================================================================
741 //=============================================================================
742 GEOM::GEOM_Object_ptr GEOM_IBlocksOperations_i::GetBlockNearPoint (GEOM::GEOM_Object_ptr theCompound,
743 GEOM::GEOM_Object_ptr thePoint)
745 GEOM::GEOM_Object_var aGEOMObject;
747 //Set a not done flag
748 GetOperations()->SetNotDone();
750 //Get the reference Objects
751 Handle(GEOM_Object) aCompound = GetObjectImpl(theCompound);
752 Handle(GEOM_Object) aPoint = GetObjectImpl(thePoint);
754 if (aCompound.IsNull() || aPoint.IsNull()) return aGEOMObject._retn();
757 Handle(GEOM_Object) anObject =
758 GetOperations()->GetBlockNearPoint(aCompound, aPoint);
759 if (!GetOperations()->IsDone() || anObject.IsNull())
760 return aGEOMObject._retn();
762 return GetObject(anObject);
765 //=============================================================================
769 //=============================================================================
770 GEOM::GEOM_Object_ptr GEOM_IBlocksOperations_i::GetBlockByParts (GEOM::GEOM_Object_ptr theCompound,
771 const GEOM::ListOfGO& theParts)
773 GEOM::GEOM_Object_var aGEOMObject;
775 //Set a not done flag
776 GetOperations()->SetNotDone();
778 //Get the reference Compound
779 Handle(GEOM_Object) aCompound = GetObjectImpl(theCompound);
780 if (aCompound.IsNull()) return aGEOMObject._retn();
784 Handle(TColStd_HSequenceOfTransient) aParts = new TColStd_HSequenceOfTransient;
786 aLen = theParts.length();
787 for (ind = 0; ind < aLen; ind++) {
788 Handle(GEOM_Object) aSh = GetObjectImpl(theParts[ind]);
789 if (aSh.IsNull()) return aGEOMObject._retn();
794 Handle(GEOM_Object) anObject =
795 GetOperations()->GetBlockByParts(aCompound, aParts);
796 if (!GetOperations()->IsDone() || anObject.IsNull())
797 return aGEOMObject._retn();
799 return GetObject(anObject);
802 //=============================================================================
806 //=============================================================================
807 GEOM::ListOfGO* GEOM_IBlocksOperations_i::GetBlocksByParts (GEOM::GEOM_Object_ptr theCompound,
808 const GEOM::ListOfGO& theParts)
810 GEOM::ListOfGO_var aSeq = new GEOM::ListOfGO;
812 //Set a not done flag
813 GetOperations()->SetNotDone();
815 //Get the reference Compound
816 Handle(GEOM_Object) aCompound = GetObjectImpl(theCompound);
817 if (aCompound.IsNull()) return aSeq._retn();
821 Handle(TColStd_HSequenceOfTransient) aParts = new TColStd_HSequenceOfTransient;
823 aLen = theParts.length();
824 for (ind = 0; ind < aLen; ind++) {
825 Handle(GEOM_Object) aSh = GetObjectImpl(theParts[ind]);
826 if (aSh.IsNull()) return aSeq._retn();
831 Handle(TColStd_HSequenceOfTransient) aHSeq =
832 GetOperations()->GetBlocksByParts(aCompound, aParts);
833 if (!GetOperations()->IsDone() || aHSeq.IsNull())
836 Standard_Integer aLength = aHSeq->Length();
837 aSeq->length(aLength);
838 for (Standard_Integer i = 1; i <= aLength; i++)
839 aSeq[i-1] = GetObject(Handle(GEOM_Object)::DownCast(aHSeq->Value(i)));
844 //=============================================================================
846 * MakeMultiTransformation1D
848 //=============================================================================
849 GEOM::GEOM_Object_ptr GEOM_IBlocksOperations_i::MakeMultiTransformation1D
850 (GEOM::GEOM_Object_ptr theBlock,
851 const CORBA::Long theDirFace1,
852 const CORBA::Long theDirFace2,
853 const CORBA::Long theNbTimes)
855 GEOM::GEOM_Object_var aGEOMObject;
857 //Set a not done flag
858 GetOperations()->SetNotDone();
860 //Get the object itself and the vector of translation
861 Handle(GEOM_Object) aBasicObject = GetObjectImpl(theBlock);
862 if (aBasicObject.IsNull()) return aGEOMObject._retn();
864 //Perform the transformation
865 Handle(GEOM_Object) anObject = GetOperations()->MakeMultiTransformation1D
866 (aBasicObject, theDirFace1, theDirFace2, theNbTimes);
867 if (!GetOperations()->IsDone() || anObject.IsNull()) return aGEOMObject._retn();
869 return GetObject(anObject);
872 //=============================================================================
874 * MakeMultiTransformation2D
876 //=============================================================================
877 GEOM::GEOM_Object_ptr GEOM_IBlocksOperations_i::MakeMultiTransformation2D
878 (GEOM::GEOM_Object_ptr theBlock,
879 const CORBA::Long theDirFace1U,
880 const CORBA::Long theDirFace2U,
881 const CORBA::Long theNbTimesU,
882 const CORBA::Long theDirFace1V,
883 const CORBA::Long theDirFace2V,
884 const CORBA::Long theNbTimesV)
886 GEOM::GEOM_Object_var aGEOMObject;
888 //Set a not done flag
889 GetOperations()->SetNotDone();
891 //Get the object itself
892 Handle(GEOM_Object) aBasicObject = GetObjectImpl(theBlock);
893 if (aBasicObject.IsNull()) return aGEOMObject._retn();
895 //Perform the transformation
896 Handle(GEOM_Object) anObject = GetOperations()->MakeMultiTransformation2D
898 theDirFace1U, theDirFace2U, theNbTimesU,
899 theDirFace1V, theDirFace2V, theNbTimesV);
900 if (!GetOperations()->IsDone() || anObject.IsNull()) return aGEOMObject._retn();
902 return GetObject(anObject);
905 //=============================================================================
909 //=============================================================================
910 GEOM::ListOfGO* GEOM_IBlocksOperations_i::Propagate (GEOM::GEOM_Object_ptr theShape)
912 GEOM::ListOfGO_var aSeq = new GEOM::ListOfGO;
914 //Set a not done flag
915 GetOperations()->SetNotDone();
917 //Get the reference Shape
918 Handle(GEOM_Object) aShape = GetObjectImpl(theShape);
919 if (aShape.IsNull()) return aSeq._retn();
921 //Get the Propagation chains
922 Handle(TColStd_HSequenceOfTransient) aHSeq =
923 GetOperations()->Propagate(aShape);
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)));