3 #include "GEOM_IBlocksOperations_i.hh"
7 #include "Utils_ExceptHandlers.hxx"
9 #include "GEOM_Engine.hxx"
10 #include "GEOM_Object.hxx"
12 #include <TColStd_HSequenceOfTransient.hxx>
13 #include <TColStd_HArray1OfInteger.hxx>
15 //=============================================================================
19 //=============================================================================
20 GEOM_IBlocksOperations_i::GEOM_IBlocksOperations_i (PortableServer::POA_ptr thePOA,
21 GEOM::GEOM_Gen_ptr theEngine,
22 ::GEOMImpl_IBlocksOperations* theImpl)
23 :GEOM_IOperations_i(thePOA, theEngine, theImpl)
25 MESSAGE("GEOM_IBlocksOperations_i::GEOM_IBlocksOperations_i");
28 //=============================================================================
32 //=============================================================================
33 GEOM_IBlocksOperations_i::~GEOM_IBlocksOperations_i()
35 MESSAGE("GEOM_IBlocksOperations_i::~GEOM_IBlocksOperations_i");
39 //=============================================================================
43 //=============================================================================
44 GEOM::GEOM_Object_ptr GEOM_IBlocksOperations_i::MakeQuad
45 (GEOM::GEOM_Object_ptr theEdge1, GEOM::GEOM_Object_ptr theEdge2,
46 GEOM::GEOM_Object_ptr theEdge3, GEOM::GEOM_Object_ptr theEdge4)
48 GEOM::GEOM_Object_var aGEOMObject;
51 GetOperations()->SetNotDone();
53 if (theEdge1 == NULL || theEdge2 == NULL ||
54 theEdge3 == NULL || theEdge4 == NULL) return aGEOMObject._retn();
56 //Get the reference edges
57 Handle(GEOM_Object) anEdge1 = GetOperations()->GetEngine()->GetObject
58 (theEdge1->GetStudyID(), theEdge1->GetEntry());
59 Handle(GEOM_Object) anEdge2 = GetOperations()->GetEngine()->GetObject
60 (theEdge2->GetStudyID(), theEdge2->GetEntry());
61 Handle(GEOM_Object) anEdge3 = GetOperations()->GetEngine()->GetObject
62 (theEdge3->GetStudyID(), theEdge3->GetEntry());
63 Handle(GEOM_Object) anEdge4 = GetOperations()->GetEngine()->GetObject
64 (theEdge4->GetStudyID(), theEdge4->GetEntry());
66 if (anEdge1.IsNull() || anEdge2.IsNull() ||
67 anEdge3.IsNull() || anEdge4.IsNull()) return aGEOMObject._retn();
70 Handle(GEOM_Object) anObject =
71 GetOperations()->MakeQuad(anEdge1, anEdge2, anEdge3, anEdge4);
72 if (!GetOperations()->IsDone() || anObject.IsNull())
73 return aGEOMObject._retn();
75 return GetObject(anObject);
78 //=============================================================================
82 //=============================================================================
83 GEOM::GEOM_Object_ptr GEOM_IBlocksOperations_i::MakeQuad2Edges
84 (GEOM::GEOM_Object_ptr theEdge1, GEOM::GEOM_Object_ptr theEdge2)
86 GEOM::GEOM_Object_var aGEOMObject;
89 GetOperations()->SetNotDone();
91 if (theEdge1 == NULL || theEdge2 == NULL) return aGEOMObject._retn();
93 //Get the reference edges
94 Handle(GEOM_Object) anEdge1 = GetOperations()->GetEngine()->GetObject
95 (theEdge1->GetStudyID(), theEdge1->GetEntry());
96 Handle(GEOM_Object) anEdge2 = GetOperations()->GetEngine()->GetObject
97 (theEdge2->GetStudyID(), theEdge2->GetEntry());
99 if (anEdge1.IsNull() || anEdge2.IsNull()) return aGEOMObject._retn();
102 Handle(GEOM_Object) anObject =
103 GetOperations()->MakeQuad2Edges(anEdge1, anEdge2);
104 if (!GetOperations()->IsDone() || anObject.IsNull())
105 return aGEOMObject._retn();
107 return GetObject(anObject);
110 //=============================================================================
114 //=============================================================================
115 GEOM::GEOM_Object_ptr GEOM_IBlocksOperations_i::MakeQuad4Vertices
116 (GEOM::GEOM_Object_ptr thePnt1, GEOM::GEOM_Object_ptr thePnt2,
117 GEOM::GEOM_Object_ptr thePnt3, GEOM::GEOM_Object_ptr thePnt4)
119 GEOM::GEOM_Object_var aGEOMObject;
121 //Set a not done flag
122 GetOperations()->SetNotDone();
124 if (thePnt1 == NULL || thePnt2 == NULL ||
125 thePnt3 == NULL || thePnt4 == NULL) return aGEOMObject._retn();
127 //Get the reference points
128 Handle(GEOM_Object) aPnt1 = GetOperations()->GetEngine()->GetObject
129 (thePnt1->GetStudyID(), thePnt1->GetEntry());
130 Handle(GEOM_Object) aPnt2 = GetOperations()->GetEngine()->GetObject
131 (thePnt2->GetStudyID(), thePnt2->GetEntry());
132 Handle(GEOM_Object) aPnt3 = GetOperations()->GetEngine()->GetObject
133 (thePnt3->GetStudyID(), thePnt3->GetEntry());
134 Handle(GEOM_Object) aPnt4 = GetOperations()->GetEngine()->GetObject
135 (thePnt4->GetStudyID(), thePnt4->GetEntry());
137 if (aPnt1.IsNull() || aPnt2.IsNull() ||
138 aPnt3.IsNull() || aPnt4.IsNull()) return aGEOMObject._retn();
141 Handle(GEOM_Object) anObject =
142 GetOperations()->MakeQuad4Vertices(aPnt1, aPnt2, aPnt3, aPnt4);
143 if (!GetOperations()->IsDone() || anObject.IsNull())
144 return aGEOMObject._retn();
146 return GetObject(anObject);
149 //=============================================================================
153 //=============================================================================
154 GEOM::GEOM_Object_ptr GEOM_IBlocksOperations_i::MakeHexa
155 (GEOM::GEOM_Object_ptr theFace1, GEOM::GEOM_Object_ptr theFace2,
156 GEOM::GEOM_Object_ptr theFace3, GEOM::GEOM_Object_ptr theFace4,
157 GEOM::GEOM_Object_ptr theFace5, GEOM::GEOM_Object_ptr theFace6)
159 GEOM::GEOM_Object_var aGEOMObject;
161 //Set a not done flag
162 GetOperations()->SetNotDone();
164 if (theFace1 == NULL || theFace2 == NULL ||
165 theFace3 == NULL || theFace4 == NULL ||
166 theFace5 == NULL || theFace6 == NULL) return aGEOMObject._retn();
168 //Get the reference Faces
169 Handle(GEOM_Object) anFace1 = GetOperations()->GetEngine()->GetObject
170 (theFace1->GetStudyID(), theFace1->GetEntry());
171 Handle(GEOM_Object) anFace2 = GetOperations()->GetEngine()->GetObject
172 (theFace2->GetStudyID(), theFace2->GetEntry());
173 Handle(GEOM_Object) anFace3 = GetOperations()->GetEngine()->GetObject
174 (theFace3->GetStudyID(), theFace3->GetEntry());
175 Handle(GEOM_Object) anFace4 = GetOperations()->GetEngine()->GetObject
176 (theFace4->GetStudyID(), theFace4->GetEntry());
177 Handle(GEOM_Object) anFace5 = GetOperations()->GetEngine()->GetObject
178 (theFace5->GetStudyID(), theFace5->GetEntry());
179 Handle(GEOM_Object) anFace6 = GetOperations()->GetEngine()->GetObject
180 (theFace6->GetStudyID(), theFace6->GetEntry());
182 if (anFace1.IsNull() || anFace2.IsNull() ||
183 anFace3.IsNull() || anFace4.IsNull() ||
184 anFace5.IsNull() || anFace6.IsNull()) return aGEOMObject._retn();
187 Handle(GEOM_Object) anObject = GetOperations()->MakeHexa
188 (anFace1, anFace2, anFace3, anFace4, anFace5, anFace6);
189 if (!GetOperations()->IsDone() || anObject.IsNull())
190 return aGEOMObject._retn();
192 return GetObject(anObject);
195 //=============================================================================
199 //=============================================================================
200 GEOM::GEOM_Object_ptr GEOM_IBlocksOperations_i::MakeHexa2Faces
201 (GEOM::GEOM_Object_ptr theFace1, GEOM::GEOM_Object_ptr theFace2)
203 GEOM::GEOM_Object_var aGEOMObject;
205 //Set a not done flag
206 GetOperations()->SetNotDone();
208 if (theFace1 == NULL || theFace2 == NULL) return aGEOMObject._retn();
210 //Get the reference Faces
211 Handle(GEOM_Object) anFace1 = GetOperations()->GetEngine()->GetObject
212 (theFace1->GetStudyID(), theFace1->GetEntry());
213 Handle(GEOM_Object) anFace2 = GetOperations()->GetEngine()->GetObject
214 (theFace2->GetStudyID(), theFace2->GetEntry());
216 if (anFace1.IsNull() || anFace2.IsNull()) return aGEOMObject._retn();
219 Handle(GEOM_Object) anObject =
220 GetOperations()->MakeHexa2Faces(anFace1, anFace2);
221 if (!GetOperations()->IsDone() || anObject.IsNull())
222 return aGEOMObject._retn();
224 return GetObject(anObject);
227 //=============================================================================
231 //=============================================================================
232 GEOM::GEOM_Object_ptr GEOM_IBlocksOperations_i::MakeBlockCompound
233 (GEOM::GEOM_Object_ptr theCompound)
235 GEOM::GEOM_Object_var aGEOMObject;
237 //Set a not done flag
238 GetOperations()->SetNotDone();
240 if (theCompound == NULL) return aGEOMObject._retn();
242 //Get the reference Compound
243 Handle(GEOM_Object) aCompound = GetOperations()->GetEngine()->GetObject
244 (theCompound->GetStudyID(), theCompound->GetEntry());
246 if (aCompound.IsNull()) return aGEOMObject._retn();
248 //Create the Blocks Compound
249 Handle(GEOM_Object) anObject =
250 GetOperations()->MakeBlockCompound(aCompound);
251 if (!GetOperations()->IsDone() || anObject.IsNull())
252 return aGEOMObject._retn();
254 return GetObject(anObject);
257 //=============================================================================
261 //=============================================================================
262 GEOM::GEOM_Object_ptr GEOM_IBlocksOperations_i::GetPoint (GEOM::GEOM_Object_ptr theShape,
263 const CORBA::Double theX,
264 const CORBA::Double theY,
265 const CORBA::Double theZ,
266 const CORBA::Double theEpsilon)
268 GEOM::GEOM_Object_var aGEOMObject;
270 //Set a not done flag
271 GetOperations()->SetNotDone();
273 if (theShape == NULL) return aGEOMObject._retn();
275 //Get the reference Objects
276 Handle(GEOM_Object) aShape = GetOperations()->GetEngine()->GetObject
277 (theShape->GetStudyID(), theShape->GetEntry());
279 if (aShape.IsNull()) return aGEOMObject._retn();
282 Handle(GEOM_Object) anObject =
283 GetOperations()->GetPoint(aShape, theX, theY, theZ, theEpsilon);
284 if (!GetOperations()->IsDone() || anObject.IsNull())
285 return aGEOMObject._retn();
287 return GetObject(anObject);
290 //=============================================================================
294 //=============================================================================
295 GEOM::GEOM_Object_ptr GEOM_IBlocksOperations_i::GetEdge (GEOM::GEOM_Object_ptr theShape,
296 GEOM::GEOM_Object_ptr thePoint1,
297 GEOM::GEOM_Object_ptr thePoint2)
299 GEOM::GEOM_Object_var aGEOMObject;
301 //Set a not done flag
302 GetOperations()->SetNotDone();
304 if (theShape == NULL ||
305 thePoint1 == NULL || thePoint2 == NULL) return aGEOMObject._retn();
307 //Get the reference Objects
308 Handle(GEOM_Object) aShape = GetOperations()->GetEngine()->GetObject
309 (theShape->GetStudyID(), theShape->GetEntry());
310 Handle(GEOM_Object) aPoint1 = GetOperations()->GetEngine()->GetObject
311 (thePoint1->GetStudyID(), thePoint1->GetEntry());
312 Handle(GEOM_Object) aPoint2 = GetOperations()->GetEngine()->GetObject
313 (thePoint2->GetStudyID(), thePoint2->GetEntry());
315 if (aShape.IsNull() ||
316 aPoint1.IsNull() || aPoint2.IsNull()) return aGEOMObject._retn();
319 Handle(GEOM_Object) anObject =
320 GetOperations()->GetEdge(aShape, aPoint1, aPoint2);
321 if (!GetOperations()->IsDone() || anObject.IsNull())
322 return aGEOMObject._retn();
324 return GetObject(anObject);
327 //=============================================================================
331 //=============================================================================
332 GEOM::GEOM_Object_ptr GEOM_IBlocksOperations_i::GetEdgeNearPoint (GEOM::GEOM_Object_ptr theShape,
333 GEOM::GEOM_Object_ptr thePoint)
335 GEOM::GEOM_Object_var aGEOMObject;
337 //Set a not done flag
338 GetOperations()->SetNotDone();
340 if (theShape == NULL || thePoint == NULL) return aGEOMObject._retn();
342 //Get the reference Objects
343 Handle(GEOM_Object) aShape = GetOperations()->GetEngine()->GetObject
344 (theShape->GetStudyID(), theShape->GetEntry());
345 Handle(GEOM_Object) aPoint = GetOperations()->GetEngine()->GetObject
346 (thePoint->GetStudyID(), thePoint->GetEntry());
348 if (aShape.IsNull() || aPoint.IsNull()) return aGEOMObject._retn();
351 Handle(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 if (theShape == NULL ||
377 thePoint1 == NULL || thePoint2 == NULL ||
378 thePoint3 == NULL || thePoint4 == NULL) return aGEOMObject._retn();
380 //Get the reference Objects
381 Handle(GEOM_Object) aShape = GetOperations()->GetEngine()->GetObject
382 (theShape->GetStudyID(), theShape->GetEntry());
383 Handle(GEOM_Object) aPoint1 = GetOperations()->GetEngine()->GetObject
384 (thePoint1->GetStudyID(), thePoint1->GetEntry());
385 Handle(GEOM_Object) aPoint2 = GetOperations()->GetEngine()->GetObject
386 (thePoint2->GetStudyID(), thePoint2->GetEntry());
387 Handle(GEOM_Object) aPoint3 = GetOperations()->GetEngine()->GetObject
388 (thePoint3->GetStudyID(), thePoint3->GetEntry());
389 Handle(GEOM_Object) aPoint4 = GetOperations()->GetEngine()->GetObject
390 (thePoint4->GetStudyID(), thePoint4->GetEntry());
392 if (aShape.IsNull() ||
393 aPoint1.IsNull() || aPoint2.IsNull() ||
394 aPoint3.IsNull() || aPoint4.IsNull()) return aGEOMObject._retn();
397 Handle(GEOM_Object) anObject =
398 GetOperations()->GetFaceByPoints(aShape, aPoint1, aPoint2, aPoint3, aPoint4);
399 if (!GetOperations()->IsDone() || anObject.IsNull())
400 return aGEOMObject._retn();
402 return GetObject(anObject);
405 //=============================================================================
409 //=============================================================================
410 GEOM::GEOM_Object_ptr GEOM_IBlocksOperations_i::GetFaceByEdges
411 (GEOM::GEOM_Object_ptr theShape,
412 GEOM::GEOM_Object_ptr theEdge1,
413 GEOM::GEOM_Object_ptr theEdge2)
415 GEOM::GEOM_Object_var aGEOMObject;
417 //Set a not done flag
418 GetOperations()->SetNotDone();
420 if (theShape == NULL ||
421 theEdge1 == NULL || theEdge2 == NULL) return aGEOMObject._retn();
423 //Get the reference Objects
424 Handle(GEOM_Object) aShape = GetOperations()->GetEngine()->GetObject
425 (theShape->GetStudyID(), theShape->GetEntry());
426 Handle(GEOM_Object) anEdge1 = GetOperations()->GetEngine()->GetObject
427 (theEdge1->GetStudyID(), theEdge1->GetEntry());
428 Handle(GEOM_Object) anEdge2 = GetOperations()->GetEngine()->GetObject
429 (theEdge2->GetStudyID(), theEdge2->GetEntry());
431 if (aShape.IsNull() ||
432 anEdge1.IsNull() || anEdge2.IsNull()) return aGEOMObject._retn();
435 Handle(GEOM_Object) anObject =
436 GetOperations()->GetFaceByEdges(aShape, anEdge1, anEdge2);
437 if (!GetOperations()->IsDone() || anObject.IsNull())
438 return aGEOMObject._retn();
440 return GetObject(anObject);
443 //=============================================================================
447 //=============================================================================
448 GEOM::GEOM_Object_ptr GEOM_IBlocksOperations_i::GetOppositeFace (GEOM::GEOM_Object_ptr theShape,
449 GEOM::GEOM_Object_ptr theFace)
451 GEOM::GEOM_Object_var aGEOMObject;
453 //Set a not done flag
454 GetOperations()->SetNotDone();
456 if (theShape == NULL || theFace == NULL) return aGEOMObject._retn();
458 //Get the reference Objects
459 Handle(GEOM_Object) aShape = GetOperations()->GetEngine()->GetObject
460 (theShape->GetStudyID(), theShape->GetEntry());
461 Handle(GEOM_Object) aFace = GetOperations()->GetEngine()->GetObject
462 (theFace->GetStudyID(), theFace->GetEntry());
464 if (aShape.IsNull() || aFace.IsNull()) return aGEOMObject._retn();
467 Handle(GEOM_Object) anObject =
468 GetOperations()->GetOppositeFace(aShape, aFace);
469 if (!GetOperations()->IsDone() || anObject.IsNull())
470 return aGEOMObject._retn();
472 return GetObject(anObject);
475 //=============================================================================
479 //=============================================================================
480 GEOM::GEOM_Object_ptr GEOM_IBlocksOperations_i::GetFaceNearPoint (GEOM::GEOM_Object_ptr theShape,
481 GEOM::GEOM_Object_ptr thePoint)
483 GEOM::GEOM_Object_var aGEOMObject;
485 //Set a not done flag
486 GetOperations()->SetNotDone();
488 if (theShape == NULL || thePoint == NULL) return aGEOMObject._retn();
490 //Get the reference Objects
491 Handle(GEOM_Object) aShape = GetOperations()->GetEngine()->GetObject
492 (theShape->GetStudyID(), theShape->GetEntry());
493 Handle(GEOM_Object) aPoint = GetOperations()->GetEngine()->GetObject
494 (thePoint->GetStudyID(), thePoint->GetEntry());
496 if (aShape.IsNull() || aPoint.IsNull()) return aGEOMObject._retn();
499 Handle(GEOM_Object) anObject =
500 GetOperations()->GetFaceNearPoint(aShape, aPoint);
501 if (!GetOperations()->IsDone() || anObject.IsNull())
502 return aGEOMObject._retn();
504 return GetObject(anObject);
507 //=============================================================================
511 //=============================================================================
512 GEOM::GEOM_Object_ptr GEOM_IBlocksOperations_i::GetFaceByNormale (GEOM::GEOM_Object_ptr theShape,
513 GEOM::GEOM_Object_ptr theVector)
515 GEOM::GEOM_Object_var aGEOMObject;
517 //Set a not done flag
518 GetOperations()->SetNotDone();
520 if (theShape == NULL || theVector == NULL) return aGEOMObject._retn();
522 //Get the reference Objects
523 Handle(GEOM_Object) aShape = GetOperations()->GetEngine()->GetObject
524 (theShape->GetStudyID(), theShape->GetEntry());
525 Handle(GEOM_Object) aVector = GetOperations()->GetEngine()->GetObject
526 (theVector->GetStudyID(), theVector->GetEntry());
528 if (aShape.IsNull() || aVector.IsNull()) return aGEOMObject._retn();
531 Handle(GEOM_Object) anObject =
532 GetOperations()->GetFaceByNormale(aShape, aVector);
533 if (!GetOperations()->IsDone() || anObject.IsNull())
534 return aGEOMObject._retn();
536 return GetObject(anObject);
539 //=============================================================================
541 * ExplodeCompoundOfBlocks
543 //=============================================================================
544 GEOM::ListOfGO* GEOM_IBlocksOperations_i::ExplodeCompoundOfBlocks
545 (GEOM::GEOM_Object_ptr theCompound,
546 const CORBA::Long theMinNbFaces,
547 const CORBA::Long theMaxNbFaces)
549 GEOM::ListOfGO_var aSeq = new GEOM::ListOfGO;
551 //Set a not done flag
552 GetOperations()->SetNotDone();
554 if (theCompound == NULL) return aSeq._retn();
556 //Get the reference Compound
557 Handle(GEOM_Object) aCompound = GetOperations()->GetEngine()->GetObject
558 (theCompound->GetStudyID(), theCompound->GetEntry());
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(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 if (theCompound == NULL) return isComp;
595 //Get the reference Compound
596 Handle(GEOM_Object) aCompound = GetOperations()->GetEngine()->GetObject
597 (theCompound->GetStudyID(), theCompound->GetEntry());
599 if (aCompound.IsNull()) return isComp;
602 Standard_Integer nbBlocks = 0;
603 isComp = GetOperations()->IsCompoundOfBlocks(aCompound,
607 if (!GetOperations()->IsDone())
610 theNbBlocks = nbBlocks;
614 //=============================================================================
616 * CheckCompoundOfBlocks
618 //=============================================================================
619 CORBA::Boolean GEOM_IBlocksOperations_i::CheckCompoundOfBlocks
620 (GEOM::GEOM_Object_ptr theCompound,
621 GEOM::GEOM_IBlocksOperations::BCErrors_out theErrors)
623 CORBA::Boolean isComp = false;
625 //Set a not done flag
626 GetOperations()->SetNotDone();
628 if (theCompound == NULL) return isComp;
630 //Get the reference Compound
631 Handle(GEOM_Object) aCompound = GetOperations()->GetEngine()->GetObject
632 (theCompound->GetStudyID(), theCompound->GetEntry());
634 if (aCompound.IsNull()) return isComp;
637 list<GEOMImpl_IBlocksOperations::BCError> errList;
638 isComp = GetOperations()->CheckCompoundOfBlocks(aCompound, errList);
639 if (!GetOperations()->IsDone())
642 const int nbErr = errList.size();
643 GEOM::GEOM_IBlocksOperations::BCErrors_var anErrArray =
644 new GEOM::GEOM_IBlocksOperations::BCErrors();
645 anErrArray->length(nbErr);
647 // fill the local CORBA array with values from lists
648 list<GEOMImpl_IBlocksOperations::BCError>::iterator errIt = errList.begin();
650 for (; errIt != errList.end(); i++, errIt++) {
651 GEOM::GEOM_IBlocksOperations::BCError_var anError =
652 new GEOM::GEOM_IBlocksOperations::BCError();
654 GEOMImpl_IBlocksOperations::BCError errStruct = *errIt;
656 switch (errStruct.error) {
657 case GEOMImpl_IBlocksOperations::NOT_BLOCK:
658 anError->error = GEOM::GEOM_IBlocksOperations::NOT_BLOCK;
660 case GEOMImpl_IBlocksOperations::EXTRA_EDGE:
661 anError->error = GEOM::GEOM_IBlocksOperations::EXTRA_EDGE;
663 case GEOMImpl_IBlocksOperations::INVALID_CONNECTION:
664 anError->error = GEOM::GEOM_IBlocksOperations::INVALID_CONNECTION;
666 case GEOMImpl_IBlocksOperations::NOT_CONNECTED:
667 anError->error = GEOM::GEOM_IBlocksOperations::NOT_CONNECTED;
669 case GEOMImpl_IBlocksOperations::NOT_GLUED:
670 anError->error = GEOM::GEOM_IBlocksOperations::NOT_GLUED;
676 list<int> sshList = errStruct.incriminated;
677 GEOM::ListOfLong_var anIncrims = new GEOM::ListOfLong();
678 anIncrims->length(sshList.size());
680 list<int>::iterator sshIt = sshList.begin();
682 for (; sshIt != sshList.end(); jj++, sshIt++) {
683 anIncrims[jj] = *sshIt;
686 anError->incriminated = anIncrims;
688 anErrArray[i] = anError;
691 // initialize out-parameter with local array
692 theErrors = anErrArray._retn();
697 //=============================================================================
701 //=============================================================================
702 char* GEOM_IBlocksOperations_i::PrintBCErrors
703 (GEOM::GEOM_Object_ptr theCompound,
704 const GEOM::GEOM_IBlocksOperations::BCErrors& theErrors)
706 //Get the reference Compound
707 if (theCompound == NULL) return NULL;
708 Handle(GEOM_Object) aCompound = GetOperations()->GetEngine()->GetObject
709 (theCompound->GetStudyID(), theCompound->GetEntry());
710 if (aCompound.IsNull()) return NULL;
712 // Convert the errors sequence
713 list<GEOMImpl_IBlocksOperations::BCError> anErrors;
714 int nbErr = theErrors.length();
716 for (; ie < nbErr; ie++) {
717 const GEOM::GEOM_IBlocksOperations::BCError err = theErrors[ie];
718 const GEOM::GEOM_IBlocksOperations::BCErrorType typ = err.error;
719 const GEOM::ListOfLong incrims = err.incriminated;
721 GEOMImpl_IBlocksOperations::BCError errStruct;
723 case GEOM::GEOM_IBlocksOperations::NOT_BLOCK:
724 errStruct.error = GEOMImpl_IBlocksOperations::NOT_BLOCK;
726 case GEOM::GEOM_IBlocksOperations::EXTRA_EDGE:
727 errStruct.error = GEOMImpl_IBlocksOperations::EXTRA_EDGE;
729 case GEOM::GEOM_IBlocksOperations::INVALID_CONNECTION:
730 errStruct.error = GEOMImpl_IBlocksOperations::INVALID_CONNECTION;
732 case GEOM::GEOM_IBlocksOperations::NOT_CONNECTED:
733 errStruct.error = GEOMImpl_IBlocksOperations::NOT_CONNECTED;
735 case GEOM::GEOM_IBlocksOperations::NOT_GLUED:
736 errStruct.error = GEOMImpl_IBlocksOperations::NOT_GLUED;
743 int aLen = incrims.length();
744 for (; ii < aLen; ii++) {
745 errStruct.incriminated.push_back(incrims[ii]);
748 anErrors.push_back(errStruct);
751 TCollection_AsciiString aDescr = GetOperations()->PrintBCErrors(aCompound, anErrors);
752 return CORBA::string_dup(aDescr.ToCString());
755 //=============================================================================
759 //=============================================================================
760 GEOM::GEOM_Object_ptr GEOM_IBlocksOperations_i::RemoveExtraEdges (GEOM::GEOM_Object_ptr theShape)
762 GEOM::GEOM_Object_var aGEOMObject;
764 //Set a not done flag
765 GetOperations()->SetNotDone();
767 if (theShape == NULL) return aGEOMObject._retn();
769 //Get the reference Objects
770 Handle(GEOM_Object) aShape = GetOperations()->GetEngine()->GetObject
771 (theShape->GetStudyID(), theShape->GetEntry());
773 if (aShape.IsNull()) return aGEOMObject._retn();
776 Handle(GEOM_Object) anObject =
777 GetOperations()->RemoveExtraEdges(aShape);
778 if (!GetOperations()->IsDone() || anObject.IsNull())
779 return aGEOMObject._retn();
781 return GetObject(anObject);
784 //=============================================================================
788 //=============================================================================
789 GEOM::GEOM_Object_ptr GEOM_IBlocksOperations_i::CheckAndImprove (GEOM::GEOM_Object_ptr theCompound)
791 GEOM::GEOM_Object_var aGEOMObject;
793 //Set a not done flag
794 GetOperations()->SetNotDone();
796 if (theCompound == NULL) return aGEOMObject._retn();
798 //Get the reference Objects
799 Handle(GEOM_Object) aCompound = GetOperations()->GetEngine()->GetObject
800 (theCompound->GetStudyID(), theCompound->GetEntry());
802 if (aCompound.IsNull()) return aGEOMObject._retn();
805 Handle(GEOM_Object) anObject =
806 GetOperations()->CheckAndImprove(aCompound);
807 if (!GetOperations()->IsDone() || anObject.IsNull())
808 return aGEOMObject._retn();
810 return GetObject(anObject);
813 //=============================================================================
817 //=============================================================================
818 GEOM::GEOM_Object_ptr GEOM_IBlocksOperations_i::GetBlockNearPoint (GEOM::GEOM_Object_ptr theCompound,
819 GEOM::GEOM_Object_ptr thePoint)
821 GEOM::GEOM_Object_var aGEOMObject;
823 //Set a not done flag
824 GetOperations()->SetNotDone();
826 if (theCompound == NULL || thePoint == NULL) return aGEOMObject._retn();
828 //Get the reference Objects
829 Handle(GEOM_Object) aCompound = GetOperations()->GetEngine()->GetObject
830 (theCompound->GetStudyID(), theCompound->GetEntry());
831 Handle(GEOM_Object) aPoint = GetOperations()->GetEngine()->GetObject
832 (thePoint->GetStudyID(), thePoint->GetEntry());
834 if (aCompound.IsNull() || aPoint.IsNull()) return aGEOMObject._retn();
837 Handle(GEOM_Object) anObject =
838 GetOperations()->GetBlockNearPoint(aCompound, aPoint);
839 if (!GetOperations()->IsDone() || anObject.IsNull())
840 return aGEOMObject._retn();
842 return GetObject(anObject);
845 //=============================================================================
849 //=============================================================================
850 GEOM::GEOM_Object_ptr GEOM_IBlocksOperations_i::GetBlockByParts (GEOM::GEOM_Object_ptr theCompound,
851 const GEOM::ListOfGO& theParts)
853 GEOM::GEOM_Object_var aGEOMObject;
855 //Set a not done flag
856 GetOperations()->SetNotDone();
858 if (theCompound == NULL) return aGEOMObject._retn();
860 //Get the reference Compound
861 Handle(GEOM_Object) aCompound = GetOperations()->GetEngine()->GetObject
862 (theCompound->GetStudyID(), theCompound->GetEntry());
864 if (aCompound.IsNull()) return aGEOMObject._retn();
868 Handle(TColStd_HSequenceOfTransient) aParts = new TColStd_HSequenceOfTransient;
870 aLen = theParts.length();
871 for (ind = 0; ind < aLen; ind++) {
872 if (theParts[ind] == NULL) return aGEOMObject._retn();
873 Handle(GEOM_Object) aSh = GetOperations()->GetEngine()->GetObject
874 (theParts[ind]->GetStudyID(), theParts[ind]->GetEntry());
875 if (aSh.IsNull()) return aGEOMObject._retn();
880 Handle(GEOM_Object) anObject =
881 GetOperations()->GetBlockByParts(aCompound, aParts);
882 if (!GetOperations()->IsDone() || anObject.IsNull())
883 return aGEOMObject._retn();
885 return GetObject(anObject);
888 //=============================================================================
892 //=============================================================================
893 GEOM::ListOfGO* GEOM_IBlocksOperations_i::GetBlocksByParts (GEOM::GEOM_Object_ptr theCompound,
894 const GEOM::ListOfGO& theParts)
896 GEOM::ListOfGO_var aSeq = new GEOM::ListOfGO;
898 //Set a not done flag
899 GetOperations()->SetNotDone();
901 if (theCompound == NULL) return aSeq._retn();
903 //Get the reference Compound
904 Handle(GEOM_Object) aCompound = GetOperations()->GetEngine()->GetObject
905 (theCompound->GetStudyID(), theCompound->GetEntry());
907 if (aCompound.IsNull()) return aSeq._retn();
911 Handle(TColStd_HSequenceOfTransient) aParts = new TColStd_HSequenceOfTransient;
913 aLen = theParts.length();
914 for (ind = 0; ind < aLen; ind++) {
915 if (theParts[ind] == NULL) return aSeq._retn();
916 Handle(GEOM_Object) aSh = GetOperations()->GetEngine()->GetObject
917 (theParts[ind]->GetStudyID(), theParts[ind]->GetEntry());
918 if (aSh.IsNull()) return aSeq._retn();
923 Handle(TColStd_HSequenceOfTransient) aHSeq =
924 GetOperations()->GetBlocksByParts(aCompound, aParts);
925 if (!GetOperations()->IsDone() || aHSeq.IsNull())
928 Standard_Integer aLength = aHSeq->Length();
929 aSeq->length(aLength);
930 for (Standard_Integer i = 1; i <= aLength; i++)
931 aSeq[i-1] = GetObject(Handle(GEOM_Object)::DownCast(aHSeq->Value(i)));
936 //=============================================================================
938 * MakeMultiTransformation1D
940 //=============================================================================
941 GEOM::GEOM_Object_ptr GEOM_IBlocksOperations_i::MakeMultiTransformation1D
942 (GEOM::GEOM_Object_ptr theBlock,
943 const CORBA::Long theDirFace1,
944 const CORBA::Long theDirFace2,
945 const CORBA::Long theNbTimes)
947 GEOM::GEOM_Object_var aGEOMObject;
949 //Set a not done flag
950 GetOperations()->SetNotDone();
952 if (theBlock == NULL) return aGEOMObject._retn();
954 //Get the object itself and the vector of translation
955 Handle(GEOM_Object) aBasicObject = GetOperations()->GetEngine()->GetObject
956 (theBlock->GetStudyID(), theBlock->GetEntry());
958 if (aBasicObject.IsNull()) return aGEOMObject._retn();
960 //Perform the transformation
961 Handle(GEOM_Object) anObject = GetOperations()->MakeMultiTransformation1D
962 (aBasicObject, theDirFace1, theDirFace2, theNbTimes);
963 if (!GetOperations()->IsDone() || anObject.IsNull()) return aGEOMObject._retn();
965 return GetObject(anObject);
968 //=============================================================================
970 * MakeMultiTransformation2D
972 //=============================================================================
973 GEOM::GEOM_Object_ptr GEOM_IBlocksOperations_i::MakeMultiTransformation2D
974 (GEOM::GEOM_Object_ptr theBlock,
975 const CORBA::Long theDirFace1U,
976 const CORBA::Long theDirFace2U,
977 const CORBA::Long theNbTimesU,
978 const CORBA::Long theDirFace1V,
979 const CORBA::Long theDirFace2V,
980 const CORBA::Long theNbTimesV)
982 GEOM::GEOM_Object_var aGEOMObject;
984 //Set a not done flag
985 GetOperations()->SetNotDone();
987 if (theBlock == NULL) return aGEOMObject._retn();
989 //Get the object itself
990 Handle(GEOM_Object) aBasicObject = GetOperations()->GetEngine()->GetObject
991 (theBlock->GetStudyID(), theBlock->GetEntry());
993 if (aBasicObject.IsNull()) return aGEOMObject._retn();
995 //Perform the transformation
996 Handle(GEOM_Object) anObject = GetOperations()->MakeMultiTransformation2D
998 theDirFace1U, theDirFace2U, theNbTimesU,
999 theDirFace1V, theDirFace2V, theNbTimesV);
1000 if (!GetOperations()->IsDone() || anObject.IsNull()) return aGEOMObject._retn();
1002 return GetObject(anObject);
1005 //=============================================================================
1009 //=============================================================================
1010 GEOM::ListOfGO* GEOM_IBlocksOperations_i::Propagate (GEOM::GEOM_Object_ptr theShape)
1012 GEOM::ListOfGO_var aSeq = new GEOM::ListOfGO;
1014 //Set a not done flag
1015 GetOperations()->SetNotDone();
1017 if (theShape == NULL) return aSeq._retn();
1019 //Get the reference Shape
1020 Handle(GEOM_Object) aShape = GetOperations()->GetEngine()->GetObject
1021 (theShape->GetStudyID(), theShape->GetEntry());
1023 if (aShape.IsNull()) return aSeq._retn();
1025 //Get the Propagation chains
1026 Handle(TColStd_HSequenceOfTransient) aHSeq =
1027 GetOperations()->Propagate(aShape);
1028 if (!GetOperations()->IsDone() || aHSeq.IsNull())
1029 return aSeq._retn();
1031 Standard_Integer aLength = aHSeq->Length();
1032 aSeq->length(aLength);
1033 for (Standard_Integer i = 1; i <= aLength; i++)
1034 aSeq[i-1] = GetObject(Handle(GEOM_Object)::DownCast(aHSeq->Value(i)));
1036 return aSeq._retn();