1 // Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE
3 // Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License.
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 // Lesser General Public License for more details.
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
22 #include <Standard_Stream.hxx>
24 #include "GEOM_IBlocksOperations_i.hh"
26 #include "utilities.h"
28 #include "Utils_ExceptHandlers.hxx"
30 #include "GEOM_Engine.hxx"
31 #include "GEOM_Object.hxx"
33 #include <TColStd_HSequenceOfTransient.hxx>
34 #include <TColStd_HArray1OfInteger.hxx>
36 //=============================================================================
40 //=============================================================================
41 GEOM_IBlocksOperations_i::GEOM_IBlocksOperations_i (PortableServer::POA_ptr thePOA,
42 GEOM::GEOM_Gen_ptr theEngine,
43 ::GEOMImpl_IBlocksOperations* theImpl)
44 :GEOM_IOperations_i(thePOA, theEngine, theImpl)
46 MESSAGE("GEOM_IBlocksOperations_i::GEOM_IBlocksOperations_i");
49 //=============================================================================
53 //=============================================================================
54 GEOM_IBlocksOperations_i::~GEOM_IBlocksOperations_i()
56 MESSAGE("GEOM_IBlocksOperations_i::~GEOM_IBlocksOperations_i");
60 //=============================================================================
64 //=============================================================================
65 GEOM::GEOM_Object_ptr GEOM_IBlocksOperations_i::MakeQuad
66 (GEOM::GEOM_Object_ptr theEdge1, GEOM::GEOM_Object_ptr theEdge2,
67 GEOM::GEOM_Object_ptr theEdge3, GEOM::GEOM_Object_ptr theEdge4)
69 GEOM::GEOM_Object_var aGEOMObject;
72 GetOperations()->SetNotDone();
74 //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::GetEdge (GEOM::GEOM_Object_ptr theShape,
277 GEOM::GEOM_Object_ptr thePoint1,
278 GEOM::GEOM_Object_ptr thePoint2)
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) aPoint1 = GetObjectImpl(thePoint1);
288 Handle(GEOM_Object) aPoint2 = GetObjectImpl(thePoint2);
290 if (aShape.IsNull() ||
291 aPoint1.IsNull() || aPoint2.IsNull()) return aGEOMObject._retn();
294 Handle(GEOM_Object) anObject =
295 GetOperations()->GetEdge(aShape, aPoint1, aPoint2);
296 if (!GetOperations()->IsDone() || anObject.IsNull())
297 return aGEOMObject._retn();
299 return GetObject(anObject);
302 //=============================================================================
306 //=============================================================================
307 GEOM::GEOM_Object_ptr GEOM_IBlocksOperations_i::GetEdgeNearPoint (GEOM::GEOM_Object_ptr theShape,
308 GEOM::GEOM_Object_ptr thePoint)
310 GEOM::GEOM_Object_var aGEOMObject;
312 //Set a not done flag
313 GetOperations()->SetNotDone();
315 //Get the reference Objects
316 Handle(GEOM_Object) aShape = GetObjectImpl(theShape);
317 Handle(GEOM_Object) aPoint = GetObjectImpl(thePoint);
319 if (aShape.IsNull() || aPoint.IsNull()) return aGEOMObject._retn();
322 Handle(GEOM_Object) anObject =
323 GetOperations()->GetEdgeNearPoint(aShape, aPoint);
324 if (!GetOperations()->IsDone() || anObject.IsNull())
325 return aGEOMObject._retn();
327 return GetObject(anObject);
330 //=============================================================================
334 //=============================================================================
335 GEOM::GEOM_Object_ptr GEOM_IBlocksOperations_i::GetFaceByPoints
336 (GEOM::GEOM_Object_ptr theShape,
337 GEOM::GEOM_Object_ptr thePoint1,
338 GEOM::GEOM_Object_ptr thePoint2,
339 GEOM::GEOM_Object_ptr thePoint3,
340 GEOM::GEOM_Object_ptr thePoint4)
342 GEOM::GEOM_Object_var aGEOMObject;
344 //Set a not done flag
345 GetOperations()->SetNotDone();
347 //Get the reference Objects
348 Handle(GEOM_Object) aShape = GetObjectImpl(theShape);
349 Handle(GEOM_Object) aPoint1 = GetObjectImpl(thePoint1);
350 Handle(GEOM_Object) aPoint2 = GetObjectImpl(thePoint2);
351 Handle(GEOM_Object) aPoint3 = GetObjectImpl(thePoint3);
352 Handle(GEOM_Object) aPoint4 = GetObjectImpl(thePoint4);
354 if (aShape.IsNull() ||
355 aPoint1.IsNull() || aPoint2.IsNull() ||
356 aPoint3.IsNull() || aPoint4.IsNull()) return aGEOMObject._retn();
359 Handle(GEOM_Object) anObject =
360 GetOperations()->GetFaceByPoints(aShape, aPoint1, aPoint2, aPoint3, aPoint4);
361 if (!GetOperations()->IsDone() || anObject.IsNull())
362 return aGEOMObject._retn();
364 return GetObject(anObject);
367 //=============================================================================
371 //=============================================================================
372 GEOM::GEOM_Object_ptr GEOM_IBlocksOperations_i::GetFaceByEdges
373 (GEOM::GEOM_Object_ptr theShape,
374 GEOM::GEOM_Object_ptr theEdge1,
375 GEOM::GEOM_Object_ptr theEdge2)
377 GEOM::GEOM_Object_var aGEOMObject;
379 //Set a not done flag
380 GetOperations()->SetNotDone();
382 //Get the reference Objects
383 Handle(GEOM_Object) aShape = GetObjectImpl(theShape);
384 Handle(GEOM_Object) anEdge1 = GetObjectImpl(theEdge1);
385 Handle(GEOM_Object) anEdge2 = GetObjectImpl(theEdge2);
387 if (aShape.IsNull() ||
388 anEdge1.IsNull() || anEdge2.IsNull()) return aGEOMObject._retn();
391 Handle(GEOM_Object) anObject =
392 GetOperations()->GetFaceByEdges(aShape, anEdge1, anEdge2);
393 if (!GetOperations()->IsDone() || anObject.IsNull())
394 return aGEOMObject._retn();
396 return GetObject(anObject);
399 //=============================================================================
403 //=============================================================================
404 GEOM::GEOM_Object_ptr GEOM_IBlocksOperations_i::GetOppositeFace (GEOM::GEOM_Object_ptr theShape,
405 GEOM::GEOM_Object_ptr theFace)
407 GEOM::GEOM_Object_var aGEOMObject;
409 //Set a not done flag
410 GetOperations()->SetNotDone();
412 //Get the reference Objects
413 Handle(GEOM_Object) aShape = GetObjectImpl(theShape);
414 Handle(GEOM_Object) aFace = GetObjectImpl(theFace);
416 if (aShape.IsNull() || aFace.IsNull()) return aGEOMObject._retn();
419 Handle(GEOM_Object) anObject =
420 GetOperations()->GetOppositeFace(aShape, aFace);
421 if (!GetOperations()->IsDone() || anObject.IsNull())
422 return aGEOMObject._retn();
424 return GetObject(anObject);
427 //=============================================================================
431 //=============================================================================
432 GEOM::GEOM_Object_ptr GEOM_IBlocksOperations_i::GetFaceNearPoint (GEOM::GEOM_Object_ptr theShape,
433 GEOM::GEOM_Object_ptr thePoint)
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) aPoint = GetObjectImpl(thePoint);
444 if (aShape.IsNull() || aPoint.IsNull()) return aGEOMObject._retn();
447 Handle(GEOM_Object) anObject =
448 GetOperations()->GetFaceNearPoint(aShape, aPoint);
449 if (!GetOperations()->IsDone() || anObject.IsNull())
450 return aGEOMObject._retn();
452 return GetObject(anObject);
455 //=============================================================================
459 //=============================================================================
460 GEOM::GEOM_Object_ptr GEOM_IBlocksOperations_i::GetFaceByNormale (GEOM::GEOM_Object_ptr theShape,
461 GEOM::GEOM_Object_ptr theVector)
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) aVector = GetObjectImpl(theVector);
472 if (aShape.IsNull() || aVector.IsNull()) return aGEOMObject._retn();
475 Handle(GEOM_Object) anObject =
476 GetOperations()->GetFaceByNormale(aShape, aVector);
477 if (!GetOperations()->IsDone() || anObject.IsNull())
478 return aGEOMObject._retn();
480 return GetObject(anObject);
483 //=============================================================================
485 * ExplodeCompoundOfBlocks
487 //=============================================================================
488 GEOM::ListOfGO* GEOM_IBlocksOperations_i::ExplodeCompoundOfBlocks
489 (GEOM::GEOM_Object_ptr theCompound,
490 const CORBA::Long theMinNbFaces,
491 const CORBA::Long theMaxNbFaces)
493 GEOM::ListOfGO_var aSeq = new GEOM::ListOfGO;
495 //Set a not done flag
496 GetOperations()->SetNotDone();
498 //Get the reference Compound
499 Handle(GEOM_Object) aCompound = GetObjectImpl(theCompound);
500 if (aCompound.IsNull()) return aSeq._retn();
503 Handle(TColStd_HSequenceOfTransient) aHSeq =
504 GetOperations()->ExplodeCompoundOfBlocks(aCompound, theMinNbFaces, theMaxNbFaces);
505 if (!GetOperations()->IsDone() || aHSeq.IsNull())
508 Standard_Integer aLength = aHSeq->Length();
509 aSeq->length(aLength);
510 for (Standard_Integer i = 1; i <= aLength; i++)
511 aSeq[i-1] = GetObject(Handle(GEOM_Object)::DownCast(aHSeq->Value(i)));
516 //=============================================================================
520 //=============================================================================
521 CORBA::Boolean GEOM_IBlocksOperations_i::IsCompoundOfBlocks
522 (GEOM::GEOM_Object_ptr theCompound,
523 const CORBA::Long theMinNbFaces,
524 const CORBA::Long theMaxNbFaces,
525 CORBA::Long& theNbBlocks)
528 CORBA::Boolean isComp = false;
530 //Set a not done flag
531 GetOperations()->SetNotDone();
533 //Get the reference Compound
534 Handle(GEOM_Object) aCompound = GetObjectImpl(theCompound);
535 if (aCompound.IsNull()) return isComp;
538 Standard_Integer nbBlocks = 0;
539 isComp = GetOperations()->IsCompoundOfBlocks(aCompound,
543 if (!GetOperations()->IsDone())
546 theNbBlocks = nbBlocks;
550 //=============================================================================
552 * CheckCompoundOfBlocks
554 //=============================================================================
555 CORBA::Boolean GEOM_IBlocksOperations_i::CheckCompoundOfBlocks
556 (GEOM::GEOM_Object_ptr theCompound,
557 GEOM::GEOM_IBlocksOperations::BCErrors_out theErrors)
559 CORBA::Boolean isComp = false;
561 //Set a not done flag
562 GetOperations()->SetNotDone();
564 //Get the reference Compound
565 Handle(GEOM_Object) aCompound = GetObjectImpl(theCompound);
566 if (aCompound.IsNull()) return isComp;
569 std::list<GEOMImpl_IBlocksOperations::BCError> errList;
570 isComp = GetOperations()->CheckCompoundOfBlocks(aCompound, errList);
571 if (!GetOperations()->IsDone())
574 const int nbErr = errList.size();
575 GEOM::GEOM_IBlocksOperations::BCErrors_var anErrArray =
576 new GEOM::GEOM_IBlocksOperations::BCErrors();
577 anErrArray->length(nbErr);
579 // fill the local CORBA array with values from lists
580 std::list<GEOMImpl_IBlocksOperations::BCError>::iterator errIt = errList.begin();
582 for (; errIt != errList.end(); i++, errIt++) {
583 GEOM::GEOM_IBlocksOperations::BCError_var anError =
584 new GEOM::GEOM_IBlocksOperations::BCError();
586 GEOMImpl_IBlocksOperations::BCError errStruct = *errIt;
588 switch (errStruct.error) {
589 case GEOMImpl_IBlocksOperations::NOT_BLOCK:
590 anError->error = GEOM::GEOM_IBlocksOperations::NOT_BLOCK;
592 case GEOMImpl_IBlocksOperations::EXTRA_EDGE:
593 anError->error = GEOM::GEOM_IBlocksOperations::EXTRA_EDGE;
595 case GEOMImpl_IBlocksOperations::INVALID_CONNECTION:
596 anError->error = GEOM::GEOM_IBlocksOperations::INVALID_CONNECTION;
598 case GEOMImpl_IBlocksOperations::NOT_CONNECTED:
599 anError->error = GEOM::GEOM_IBlocksOperations::NOT_CONNECTED;
601 case GEOMImpl_IBlocksOperations::NOT_GLUED:
602 anError->error = GEOM::GEOM_IBlocksOperations::NOT_GLUED;
608 std::list<int> sshList = errStruct.incriminated;
609 GEOM::ListOfLong_var anIncrims = new GEOM::ListOfLong();
610 anIncrims->length(sshList.size());
612 std::list<int>::iterator sshIt = sshList.begin();
614 for (; sshIt != sshList.end(); jj++, sshIt++) {
615 anIncrims[jj] = *sshIt;
618 anError->incriminated = anIncrims;
620 anErrArray[i] = anError;
623 // initialize out-parameter with local array
624 theErrors = anErrArray._retn();
629 //=============================================================================
633 //=============================================================================
634 char* GEOM_IBlocksOperations_i::PrintBCErrors
635 (GEOM::GEOM_Object_ptr theCompound,
636 const GEOM::GEOM_IBlocksOperations::BCErrors& theErrors)
638 //Get the reference Compound
639 Handle(GEOM_Object) aCompound = GetObjectImpl(theCompound);
640 if (aCompound.IsNull()) return NULL;
642 // Convert the errors sequence
643 std::list<GEOMImpl_IBlocksOperations::BCError> anErrors;
644 int nbErr = theErrors.length();
646 for (; ie < nbErr; ie++) {
647 const GEOM::GEOM_IBlocksOperations::BCError err = theErrors[ie];
648 const GEOM::GEOM_IBlocksOperations::BCErrorType typ = err.error;
649 const GEOM::ListOfLong incrims = err.incriminated;
651 GEOMImpl_IBlocksOperations::BCError errStruct;
653 case GEOM::GEOM_IBlocksOperations::NOT_BLOCK:
654 errStruct.error = GEOMImpl_IBlocksOperations::NOT_BLOCK;
656 case GEOM::GEOM_IBlocksOperations::EXTRA_EDGE:
657 errStruct.error = GEOMImpl_IBlocksOperations::EXTRA_EDGE;
659 case GEOM::GEOM_IBlocksOperations::INVALID_CONNECTION:
660 errStruct.error = GEOMImpl_IBlocksOperations::INVALID_CONNECTION;
662 case GEOM::GEOM_IBlocksOperations::NOT_CONNECTED:
663 errStruct.error = GEOMImpl_IBlocksOperations::NOT_CONNECTED;
665 case GEOM::GEOM_IBlocksOperations::NOT_GLUED:
666 errStruct.error = GEOMImpl_IBlocksOperations::NOT_GLUED;
673 int aLen = incrims.length();
674 for (; ii < aLen; ii++) {
675 errStruct.incriminated.push_back(incrims[ii]);
678 anErrors.push_back(errStruct);
681 TCollection_AsciiString aDescr = GetOperations()->PrintBCErrors(aCompound, anErrors);
682 return CORBA::string_dup(aDescr.ToCString());
685 //=============================================================================
689 //=============================================================================
690 GEOM::GEOM_Object_ptr GEOM_IBlocksOperations_i::RemoveExtraEdges
691 (GEOM::GEOM_Object_ptr theShape,
692 CORBA::Long theOptimumNbFaces)
694 GEOM::GEOM_Object_var aGEOMObject;
696 //Set a not done flag
697 GetOperations()->SetNotDone();
699 //Get the reference Objects
700 Handle(GEOM_Object) aShape = GetObjectImpl(theShape);
701 if (aShape.IsNull()) return aGEOMObject._retn();
704 Handle(GEOM_Object) anObject = GetOperations()->RemoveExtraEdges(aShape, theOptimumNbFaces);
705 if (!GetOperations()->IsDone() || anObject.IsNull())
706 return aGEOMObject._retn();
708 return GetObject(anObject);
711 //=============================================================================
715 //=============================================================================
716 GEOM::GEOM_Object_ptr GEOM_IBlocksOperations_i::CheckAndImprove (GEOM::GEOM_Object_ptr theCompound)
718 GEOM::GEOM_Object_var aGEOMObject;
720 //Set a not done flag
721 GetOperations()->SetNotDone();
723 //Get the reference Objects
724 Handle(GEOM_Object) aCompound = GetObjectImpl(theCompound);
725 if (aCompound.IsNull()) return aGEOMObject._retn();
728 Handle(GEOM_Object) anObject =
729 GetOperations()->CheckAndImprove(aCompound);
730 if (!GetOperations()->IsDone() || anObject.IsNull())
731 return aGEOMObject._retn();
733 return GetObject(anObject);
736 //=============================================================================
740 //=============================================================================
741 GEOM::GEOM_Object_ptr GEOM_IBlocksOperations_i::GetBlockNearPoint (GEOM::GEOM_Object_ptr theCompound,
742 GEOM::GEOM_Object_ptr thePoint)
744 GEOM::GEOM_Object_var aGEOMObject;
746 //Set a not done flag
747 GetOperations()->SetNotDone();
749 //Get the reference Objects
750 Handle(GEOM_Object) aCompound = GetObjectImpl(theCompound);
751 Handle(GEOM_Object) aPoint = GetObjectImpl(thePoint);
753 if (aCompound.IsNull() || aPoint.IsNull()) return aGEOMObject._retn();
756 Handle(GEOM_Object) anObject =
757 GetOperations()->GetBlockNearPoint(aCompound, aPoint);
758 if (!GetOperations()->IsDone() || anObject.IsNull())
759 return aGEOMObject._retn();
761 return GetObject(anObject);
764 //=============================================================================
768 //=============================================================================
769 GEOM::GEOM_Object_ptr GEOM_IBlocksOperations_i::GetBlockByParts (GEOM::GEOM_Object_ptr theCompound,
770 const GEOM::ListOfGO& theParts)
772 GEOM::GEOM_Object_var aGEOMObject;
774 //Set a not done flag
775 GetOperations()->SetNotDone();
777 //Get the reference Compound
778 Handle(GEOM_Object) aCompound = GetObjectImpl(theCompound);
779 if (aCompound.IsNull()) return aGEOMObject._retn();
783 Handle(TColStd_HSequenceOfTransient) aParts = new TColStd_HSequenceOfTransient;
785 aLen = theParts.length();
786 for (ind = 0; ind < aLen; ind++) {
787 Handle(GEOM_Object) aSh = GetObjectImpl(theParts[ind]);
788 if (aSh.IsNull()) return aGEOMObject._retn();
793 Handle(GEOM_Object) anObject =
794 GetOperations()->GetBlockByParts(aCompound, aParts);
795 if (!GetOperations()->IsDone() || anObject.IsNull())
796 return aGEOMObject._retn();
798 return GetObject(anObject);
801 //=============================================================================
805 //=============================================================================
806 GEOM::ListOfGO* GEOM_IBlocksOperations_i::GetBlocksByParts (GEOM::GEOM_Object_ptr theCompound,
807 const GEOM::ListOfGO& theParts)
809 GEOM::ListOfGO_var aSeq = new GEOM::ListOfGO;
811 //Set a not done flag
812 GetOperations()->SetNotDone();
814 //Get the reference Compound
815 Handle(GEOM_Object) aCompound = GetObjectImpl(theCompound);
816 if (aCompound.IsNull()) return aSeq._retn();
820 Handle(TColStd_HSequenceOfTransient) aParts = new TColStd_HSequenceOfTransient;
822 aLen = theParts.length();
823 for (ind = 0; ind < aLen; ind++) {
824 Handle(GEOM_Object) aSh = GetObjectImpl(theParts[ind]);
825 if (aSh.IsNull()) return aSeq._retn();
830 Handle(TColStd_HSequenceOfTransient) aHSeq =
831 GetOperations()->GetBlocksByParts(aCompound, aParts);
832 if (!GetOperations()->IsDone() || aHSeq.IsNull())
835 Standard_Integer aLength = aHSeq->Length();
836 aSeq->length(aLength);
837 for (Standard_Integer i = 1; i <= aLength; i++)
838 aSeq[i-1] = GetObject(Handle(GEOM_Object)::DownCast(aHSeq->Value(i)));
843 //=============================================================================
845 * MakeMultiTransformation1D
847 //=============================================================================
848 GEOM::GEOM_Object_ptr GEOM_IBlocksOperations_i::MakeMultiTransformation1D
849 (GEOM::GEOM_Object_ptr theBlock,
850 const CORBA::Long theDirFace1,
851 const CORBA::Long theDirFace2,
852 const CORBA::Long theNbTimes)
854 GEOM::GEOM_Object_var aGEOMObject;
856 //Set a not done flag
857 GetOperations()->SetNotDone();
859 //Get the object itself and the vector of translation
860 Handle(GEOM_Object) aBasicObject = GetObjectImpl(theBlock);
861 if (aBasicObject.IsNull()) return aGEOMObject._retn();
863 //Perform the transformation
864 Handle(GEOM_Object) anObject = GetOperations()->MakeMultiTransformation1D
865 (aBasicObject, theDirFace1, theDirFace2, theNbTimes);
866 if (!GetOperations()->IsDone() || anObject.IsNull()) return aGEOMObject._retn();
868 return GetObject(anObject);
871 //=============================================================================
873 * MakeMultiTransformation2D
875 //=============================================================================
876 GEOM::GEOM_Object_ptr GEOM_IBlocksOperations_i::MakeMultiTransformation2D
877 (GEOM::GEOM_Object_ptr theBlock,
878 const CORBA::Long theDirFace1U,
879 const CORBA::Long theDirFace2U,
880 const CORBA::Long theNbTimesU,
881 const CORBA::Long theDirFace1V,
882 const CORBA::Long theDirFace2V,
883 const CORBA::Long theNbTimesV)
885 GEOM::GEOM_Object_var aGEOMObject;
887 //Set a not done flag
888 GetOperations()->SetNotDone();
890 //Get the object itself
891 Handle(GEOM_Object) aBasicObject = GetObjectImpl(theBlock);
892 if (aBasicObject.IsNull()) return aGEOMObject._retn();
894 //Perform the transformation
895 Handle(GEOM_Object) anObject = GetOperations()->MakeMultiTransformation2D
897 theDirFace1U, theDirFace2U, theNbTimesU,
898 theDirFace1V, theDirFace2V, theNbTimesV);
899 if (!GetOperations()->IsDone() || anObject.IsNull()) return aGEOMObject._retn();
901 return GetObject(anObject);
904 //=============================================================================
908 //=============================================================================
909 GEOM::ListOfGO* GEOM_IBlocksOperations_i::Propagate (GEOM::GEOM_Object_ptr theShape)
911 GEOM::ListOfGO_var aSeq = new GEOM::ListOfGO;
913 //Set a not done flag
914 GetOperations()->SetNotDone();
916 //Get the reference Shape
917 Handle(GEOM_Object) aShape = GetObjectImpl(theShape);
918 if (aShape.IsNull()) return aSeq._retn();
920 //Get the Propagation chains
921 Handle(TColStd_HSequenceOfTransient) aHSeq =
922 GetOperations()->Propagate(aShape);
923 if (!GetOperations()->IsDone() || aHSeq.IsNull())
926 Standard_Integer aLength = aHSeq->Length();
927 aSeq->length(aLength);
928 for (Standard_Integer i = 1; i <= aLength; i++)
929 aSeq[i-1] = GetObject(Handle(GEOM_Object)::DownCast(aHSeq->Value(i)));