Back to index

salome-geom  6.5.0
GEOM_IBlocksOperations_i.cc
Go to the documentation of this file.
00001 // Copyright (C) 2007-2012  CEA/DEN, EDF R&D, OPEN CASCADE
00002 //
00003 // Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
00004 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
00005 //
00006 // This library is free software; you can redistribute it and/or
00007 // modify it under the terms of the GNU Lesser General Public
00008 // License as published by the Free Software Foundation; either
00009 // version 2.1 of the License.
00010 //
00011 // This library is distributed in the hope that it will be useful,
00012 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00013 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00014 // Lesser General Public License for more details.
00015 //
00016 // You should have received a copy of the GNU Lesser General Public
00017 // License along with this library; if not, write to the Free Software
00018 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
00019 //
00020 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
00021 //
00022 
00023 #include <Standard_Stream.hxx>
00024 
00025 #include "GEOM_IBlocksOperations_i.hh"
00026 
00027 #include "utilities.h"
00028 #include "OpUtil.hxx"
00029 #include "Utils_ExceptHandlers.hxx"
00030 
00031 #include "GEOM_Engine.hxx"
00032 #include "GEOM_Object.hxx"
00033 
00034 #include <TColStd_HSequenceOfTransient.hxx>
00035 #include <TColStd_HArray1OfInteger.hxx>
00036 
00037 //=============================================================================
00041 //=============================================================================
00042 GEOM_IBlocksOperations_i::GEOM_IBlocksOperations_i (PortableServer::POA_ptr thePOA,
00043                                                     GEOM::GEOM_Gen_ptr theEngine,
00044                                                     ::GEOMImpl_IBlocksOperations* theImpl)
00045 :GEOM_IOperations_i(thePOA, theEngine, theImpl)
00046 {
00047   MESSAGE("GEOM_IBlocksOperations_i::GEOM_IBlocksOperations_i");
00048 }
00049 
00050 //=============================================================================
00054 //=============================================================================
00055 GEOM_IBlocksOperations_i::~GEOM_IBlocksOperations_i()
00056 {
00057   MESSAGE("GEOM_IBlocksOperations_i::~GEOM_IBlocksOperations_i");
00058 }
00059 
00060 
00061 //=============================================================================
00065 //=============================================================================
00066 GEOM::GEOM_Object_ptr GEOM_IBlocksOperations_i::MakeQuad
00067                (GEOM::GEOM_Object_ptr theEdge1, GEOM::GEOM_Object_ptr theEdge2,
00068                 GEOM::GEOM_Object_ptr theEdge3, GEOM::GEOM_Object_ptr theEdge4)
00069 {
00070   GEOM::GEOM_Object_var aGEOMObject;
00071 
00072   //Set a not done flag
00073   GetOperations()->SetNotDone();
00074 
00075   //Get the reference edges
00076   Handle(GEOM_Object) anEdge1 = GetObjectImpl(theEdge1);
00077   Handle(GEOM_Object) anEdge2 = GetObjectImpl(theEdge2);
00078   Handle(GEOM_Object) anEdge3 = GetObjectImpl(theEdge3);
00079   Handle(GEOM_Object) anEdge4 = GetObjectImpl(theEdge4);
00080 
00081   if (anEdge1.IsNull() || anEdge2.IsNull() ||
00082       anEdge3.IsNull() || anEdge4.IsNull()) return aGEOMObject._retn();
00083 
00084   //Create the Face
00085   Handle(GEOM_Object) anObject =
00086     GetOperations()->MakeQuad(anEdge1, anEdge2, anEdge3, anEdge4);
00087   if (!GetOperations()->IsDone() || anObject.IsNull())
00088     return aGEOMObject._retn();
00089 
00090   return GetObject(anObject);
00091 }
00092 
00093 //=============================================================================
00097 //=============================================================================
00098 GEOM::GEOM_Object_ptr GEOM_IBlocksOperations_i::MakeQuad2Edges
00099                (GEOM::GEOM_Object_ptr theEdge1, GEOM::GEOM_Object_ptr theEdge2)
00100 {
00101   GEOM::GEOM_Object_var aGEOMObject;
00102 
00103   //Set a not done flag
00104   GetOperations()->SetNotDone();
00105 
00106   //Get the reference edges
00107   Handle(GEOM_Object) anEdge1 = GetObjectImpl(theEdge1);
00108   Handle(GEOM_Object) anEdge2 = GetObjectImpl(theEdge2);
00109 
00110   if (anEdge1.IsNull() || anEdge2.IsNull()) return aGEOMObject._retn();
00111 
00112   //Create the Face
00113   Handle(GEOM_Object) anObject =
00114     GetOperations()->MakeQuad2Edges(anEdge1, anEdge2);
00115   if (!GetOperations()->IsDone() || anObject.IsNull())
00116     return aGEOMObject._retn();
00117 
00118   return GetObject(anObject);
00119 }
00120 
00121 //=============================================================================
00125 //=============================================================================
00126 GEOM::GEOM_Object_ptr GEOM_IBlocksOperations_i::MakeQuad4Vertices
00127                       (GEOM::GEOM_Object_ptr thePnt1, GEOM::GEOM_Object_ptr thePnt2,
00128                        GEOM::GEOM_Object_ptr thePnt3, GEOM::GEOM_Object_ptr thePnt4)
00129 {
00130   GEOM::GEOM_Object_var aGEOMObject;
00131 
00132   //Set a not done flag
00133   GetOperations()->SetNotDone();
00134 
00135   //Get the reference points
00136   Handle(GEOM_Object) aPnt1 = GetObjectImpl(thePnt1);
00137   Handle(GEOM_Object) aPnt2 = GetObjectImpl(thePnt2);
00138   Handle(GEOM_Object) aPnt3 = GetObjectImpl(thePnt3);
00139   Handle(GEOM_Object) aPnt4 = GetObjectImpl(thePnt4);
00140 
00141   if (aPnt1.IsNull() || aPnt2.IsNull() ||
00142       aPnt3.IsNull() || aPnt4.IsNull()) return aGEOMObject._retn();
00143 
00144   //Create the Face
00145   Handle(GEOM_Object) anObject =
00146     GetOperations()->MakeQuad4Vertices(aPnt1, aPnt2, aPnt3, aPnt4);
00147   if (!GetOperations()->IsDone() || anObject.IsNull())
00148     return aGEOMObject._retn();
00149 
00150   return GetObject(anObject);
00151 }
00152 
00153 //=============================================================================
00157 //=============================================================================
00158 GEOM::GEOM_Object_ptr GEOM_IBlocksOperations_i::MakeHexa
00159                (GEOM::GEOM_Object_ptr theFace1, GEOM::GEOM_Object_ptr theFace2,
00160                 GEOM::GEOM_Object_ptr theFace3, GEOM::GEOM_Object_ptr theFace4,
00161                 GEOM::GEOM_Object_ptr theFace5, GEOM::GEOM_Object_ptr theFace6)
00162 {
00163   GEOM::GEOM_Object_var aGEOMObject;
00164 
00165   //Set a not done flag
00166   GetOperations()->SetNotDone();
00167 
00168   //Get the reference Faces
00169   Handle(GEOM_Object) anFace1 = GetObjectImpl(theFace1);
00170   Handle(GEOM_Object) anFace2 = GetObjectImpl(theFace2);
00171   Handle(GEOM_Object) anFace3 = GetObjectImpl(theFace3);
00172   Handle(GEOM_Object) anFace4 = GetObjectImpl(theFace4);
00173   Handle(GEOM_Object) anFace5 = GetObjectImpl(theFace5);
00174   Handle(GEOM_Object) anFace6 = GetObjectImpl(theFace6);
00175 
00176   if (anFace1.IsNull() || anFace2.IsNull() ||
00177       anFace3.IsNull() || anFace4.IsNull() ||
00178       anFace5.IsNull() || anFace6.IsNull()) return aGEOMObject._retn();
00179 
00180   //Create the Face
00181   Handle(GEOM_Object) anObject = GetOperations()->MakeHexa
00182     (anFace1, anFace2, anFace3, anFace4, anFace5, anFace6);
00183   if (!GetOperations()->IsDone() || anObject.IsNull())
00184     return aGEOMObject._retn();
00185 
00186   return GetObject(anObject);
00187 }
00188 
00189 //=============================================================================
00193 //=============================================================================
00194 GEOM::GEOM_Object_ptr GEOM_IBlocksOperations_i::MakeHexa2Faces
00195                (GEOM::GEOM_Object_ptr theFace1, GEOM::GEOM_Object_ptr theFace2)
00196 {
00197   GEOM::GEOM_Object_var aGEOMObject;
00198 
00199   //Set a not done flag
00200   GetOperations()->SetNotDone();
00201 
00202   //Get the reference Faces
00203   Handle(GEOM_Object) anFace1 = GetObjectImpl(theFace1);
00204   Handle(GEOM_Object) anFace2 = GetObjectImpl(theFace2);
00205 
00206   if (anFace1.IsNull() || anFace2.IsNull()) return aGEOMObject._retn();
00207 
00208   //Create the Face
00209   Handle(GEOM_Object) anObject =
00210     GetOperations()->MakeHexa2Faces(anFace1, anFace2);
00211   if (!GetOperations()->IsDone() || anObject.IsNull())
00212     return aGEOMObject._retn();
00213 
00214   return GetObject(anObject);
00215 }
00216 
00217 //=============================================================================
00221 //=============================================================================
00222 GEOM::GEOM_Object_ptr GEOM_IBlocksOperations_i::MakeBlockCompound
00223                                             (GEOM::GEOM_Object_ptr theCompound)
00224 {
00225   GEOM::GEOM_Object_var aGEOMObject;
00226 
00227   //Set a not done flag
00228   GetOperations()->SetNotDone();
00229 
00230   //Get the reference Compound
00231   Handle(GEOM_Object) aCompound = GetObjectImpl(theCompound);
00232   if (aCompound.IsNull()) return aGEOMObject._retn();
00233 
00234   //Create the Blocks Compound
00235   Handle(GEOM_Object) anObject =
00236     GetOperations()->MakeBlockCompound(aCompound);
00237   if (!GetOperations()->IsDone() || anObject.IsNull())
00238     return aGEOMObject._retn();
00239 
00240   return GetObject(anObject);
00241 }
00242 
00243 //=============================================================================
00247 //=============================================================================
00248 GEOM::GEOM_Object_ptr GEOM_IBlocksOperations_i::GetPoint (GEOM::GEOM_Object_ptr theShape,
00249                                                           const CORBA::Double   theX,
00250                                                           const CORBA::Double   theY,
00251                                                           const CORBA::Double   theZ,
00252                                                           const CORBA::Double   theEpsilon)
00253 {
00254   GEOM::GEOM_Object_var aGEOMObject;
00255 
00256   //Set a not done flag
00257   GetOperations()->SetNotDone();
00258 
00259   //Get the reference Objects
00260   Handle(GEOM_Object) aShape = GetObjectImpl(theShape);
00261   if (aShape.IsNull()) return aGEOMObject._retn();
00262 
00263   //Create the Point
00264   Handle(GEOM_Object) anObject =
00265     GetOperations()->GetPoint(aShape, theX, theY, theZ, theEpsilon);
00266   if (!GetOperations()->IsDone() || anObject.IsNull())
00267     return aGEOMObject._retn();
00268 
00269   return GetObject(anObject);
00270 }
00271 
00272 //=============================================================================
00276 //=============================================================================
00277 GEOM::GEOM_Object_ptr GEOM_IBlocksOperations_i::GetVertexNearPoint
00278                                                 (GEOM::GEOM_Object_ptr theShape,
00279                                                  GEOM::GEOM_Object_ptr thePoint)
00280 {
00281   GEOM::GEOM_Object_var aGEOMObject;
00282 
00283   // Set a not done flag
00284   GetOperations()->SetNotDone();
00285 
00286   // Get the reference Objects
00287   Handle(GEOM_Object) aShape = GetObjectImpl(theShape);
00288   Handle(GEOM_Object) aPoint = GetObjectImpl(thePoint);
00289   if (aShape.IsNull() || aPoint.IsNull()) return aGEOMObject._retn();
00290 
00291   // Create the Point
00292   Handle(GEOM_Object) anObject =
00293     GetOperations()->GetVertexNearPoint(aShape, aPoint);
00294   if (!GetOperations()->IsDone() || anObject.IsNull())
00295     return aGEOMObject._retn();
00296 
00297   return GetObject(anObject);
00298 }
00299 
00300 //=============================================================================
00304 //=============================================================================
00305 GEOM::GEOM_Object_ptr GEOM_IBlocksOperations_i::GetEdge (GEOM::GEOM_Object_ptr theShape,
00306                                                          GEOM::GEOM_Object_ptr thePoint1,
00307                                                          GEOM::GEOM_Object_ptr thePoint2)
00308 {
00309   GEOM::GEOM_Object_var aGEOMObject;
00310 
00311   //Set a not done flag
00312   GetOperations()->SetNotDone();
00313 
00314   //Get the reference Objects
00315   Handle(GEOM_Object) aShape = GetObjectImpl(theShape);
00316   Handle(GEOM_Object) aPoint1 = GetObjectImpl(thePoint1);
00317   Handle(GEOM_Object) aPoint2 = GetObjectImpl(thePoint2);
00318 
00319   if (aShape.IsNull() ||
00320       aPoint1.IsNull() || aPoint2.IsNull()) return aGEOMObject._retn();
00321 
00322   //Create the Point
00323   Handle(GEOM_Object) anObject =
00324     GetOperations()->GetEdge(aShape, aPoint1, aPoint2);
00325   if (!GetOperations()->IsDone() || anObject.IsNull())
00326     return aGEOMObject._retn();
00327 
00328   return GetObject(anObject);
00329 }
00330 
00331 //=============================================================================
00335 //=============================================================================
00336 GEOM::GEOM_Object_ptr GEOM_IBlocksOperations_i::GetEdgeNearPoint (GEOM::GEOM_Object_ptr theShape,
00337                                                                   GEOM::GEOM_Object_ptr thePoint)
00338 {
00339   GEOM::GEOM_Object_var aGEOMObject;
00340 
00341   //Set a not done flag
00342   GetOperations()->SetNotDone();
00343 
00344   //Get the reference Objects
00345   Handle(GEOM_Object) aShape = GetObjectImpl(theShape);
00346   Handle(GEOM_Object) aPoint = GetObjectImpl(thePoint);
00347 
00348   if (aShape.IsNull() || aPoint.IsNull()) return aGEOMObject._retn();
00349 
00350   //Create the Edge
00351   Handle(GEOM_Object) anObject =
00352     GetOperations()->GetEdgeNearPoint(aShape, aPoint);
00353   if (!GetOperations()->IsDone() || anObject.IsNull())
00354     return aGEOMObject._retn();
00355 
00356   return GetObject(anObject);
00357 }
00358 
00359 //=============================================================================
00363 //=============================================================================
00364 GEOM::GEOM_Object_ptr GEOM_IBlocksOperations_i::GetFaceByPoints
00365                                               (GEOM::GEOM_Object_ptr theShape,
00366                                                GEOM::GEOM_Object_ptr thePoint1,
00367                                                GEOM::GEOM_Object_ptr thePoint2,
00368                                                GEOM::GEOM_Object_ptr thePoint3,
00369                                                GEOM::GEOM_Object_ptr thePoint4)
00370 {
00371   GEOM::GEOM_Object_var aGEOMObject;
00372 
00373   //Set a not done flag
00374   GetOperations()->SetNotDone();
00375 
00376   //Get the reference Objects
00377   Handle(GEOM_Object) aShape = GetObjectImpl(theShape);
00378   Handle(GEOM_Object) aPoint1 = GetObjectImpl(thePoint1);
00379   Handle(GEOM_Object) aPoint2 = GetObjectImpl(thePoint2);
00380   Handle(GEOM_Object) aPoint3 = GetObjectImpl(thePoint3);
00381   Handle(GEOM_Object) aPoint4 = GetObjectImpl(thePoint4);
00382 
00383   if (aShape.IsNull() ||
00384       aPoint1.IsNull() || aPoint2.IsNull() ||
00385       aPoint3.IsNull() || aPoint4.IsNull()) return aGEOMObject._retn();
00386 
00387   //Create the Face
00388   Handle(GEOM_Object) anObject =
00389     GetOperations()->GetFaceByPoints(aShape, aPoint1, aPoint2, aPoint3, aPoint4);
00390   if (!GetOperations()->IsDone() || anObject.IsNull())
00391     return aGEOMObject._retn();
00392 
00393   return GetObject(anObject);
00394 }
00395 
00396 //=============================================================================
00400 //=============================================================================
00401 GEOM::GEOM_Object_ptr GEOM_IBlocksOperations_i::GetFaceByEdges
00402                                                (GEOM::GEOM_Object_ptr theShape,
00403                                                 GEOM::GEOM_Object_ptr theEdge1,
00404                                                 GEOM::GEOM_Object_ptr theEdge2)
00405 {
00406   GEOM::GEOM_Object_var aGEOMObject;
00407 
00408   //Set a not done flag
00409   GetOperations()->SetNotDone();
00410 
00411   //Get the reference Objects
00412   Handle(GEOM_Object) aShape = GetObjectImpl(theShape);
00413   Handle(GEOM_Object) anEdge1 = GetObjectImpl(theEdge1);
00414   Handle(GEOM_Object) anEdge2 = GetObjectImpl(theEdge2);
00415 
00416   if (aShape.IsNull() ||
00417       anEdge1.IsNull() || anEdge2.IsNull()) return aGEOMObject._retn();
00418 
00419   //Create the Face
00420   Handle(GEOM_Object) anObject =
00421     GetOperations()->GetFaceByEdges(aShape, anEdge1, anEdge2);
00422   if (!GetOperations()->IsDone() || anObject.IsNull())
00423     return aGEOMObject._retn();
00424 
00425   return GetObject(anObject);
00426 }
00427 
00428 //=============================================================================
00432 //=============================================================================
00433 GEOM::GEOM_Object_ptr GEOM_IBlocksOperations_i::GetOppositeFace (GEOM::GEOM_Object_ptr theShape,
00434                                                                  GEOM::GEOM_Object_ptr theFace)
00435 {
00436   GEOM::GEOM_Object_var aGEOMObject;
00437 
00438   //Set a not done flag
00439   GetOperations()->SetNotDone();
00440 
00441   //Get the reference Objects
00442   Handle(GEOM_Object) aShape = GetObjectImpl(theShape);
00443   Handle(GEOM_Object) aFace = GetObjectImpl(theFace);
00444 
00445   if (aShape.IsNull() || aFace.IsNull()) return aGEOMObject._retn();
00446 
00447   //Create the Face
00448   Handle(GEOM_Object) anObject =
00449     GetOperations()->GetOppositeFace(aShape, aFace);
00450   if (!GetOperations()->IsDone() || anObject.IsNull())
00451     return aGEOMObject._retn();
00452 
00453   return GetObject(anObject);
00454 }
00455 
00456 //=============================================================================
00460 //=============================================================================
00461 GEOM::GEOM_Object_ptr GEOM_IBlocksOperations_i::GetFaceNearPoint (GEOM::GEOM_Object_ptr theShape,
00462                                                                   GEOM::GEOM_Object_ptr thePoint)
00463 {
00464   GEOM::GEOM_Object_var aGEOMObject;
00465 
00466   //Set a not done flag
00467   GetOperations()->SetNotDone();
00468 
00469   //Get the reference Objects
00470   Handle(GEOM_Object) aShape = GetObjectImpl(theShape);
00471   Handle(GEOM_Object) aPoint = GetObjectImpl(thePoint);
00472 
00473   if (aShape.IsNull() || aPoint.IsNull()) return aGEOMObject._retn();
00474 
00475   //Create the Face
00476   Handle(GEOM_Object) anObject =
00477     GetOperations()->GetFaceNearPoint(aShape, aPoint);
00478   if (!GetOperations()->IsDone() || anObject.IsNull())
00479     return aGEOMObject._retn();
00480 
00481   return GetObject(anObject);
00482 }
00483 
00484 //=============================================================================
00488 //=============================================================================
00489 GEOM::GEOM_Object_ptr GEOM_IBlocksOperations_i::GetFaceByNormale (GEOM::GEOM_Object_ptr theShape,
00490                                                                   GEOM::GEOM_Object_ptr theVector)
00491 {
00492   GEOM::GEOM_Object_var aGEOMObject;
00493 
00494   //Set a not done flag
00495   GetOperations()->SetNotDone();
00496 
00497   //Get the reference Objects
00498   Handle(GEOM_Object) aShape = GetObjectImpl(theShape);
00499   Handle(GEOM_Object) aVector = GetObjectImpl(theVector);
00500 
00501   if (aShape.IsNull() || aVector.IsNull()) return aGEOMObject._retn();
00502 
00503   //Create the Face
00504   Handle(GEOM_Object) anObject =
00505     GetOperations()->GetFaceByNormale(aShape, aVector);
00506   if (!GetOperations()->IsDone() || anObject.IsNull())
00507     return aGEOMObject._retn();
00508 
00509   return GetObject(anObject);
00510 }
00511 
00512 //=============================================================================
00516 //=============================================================================
00517 GEOM::GEOM_Object_ptr GEOM_IBlocksOperations_i::GetShapesNearPoint
00518                       (GEOM::GEOM_Object_ptr theShape,
00519                        GEOM::GEOM_Object_ptr thePoint,
00520                        CORBA::Long           theShapeType,
00521                        CORBA::Double         theTolerance)
00522 {
00523   GEOM::GEOM_Object_var aGEOMObject;
00524 
00525   // Set a not done flag
00526   GetOperations()->SetNotDone();
00527 
00528   // Get the reference Objects
00529   Handle(GEOM_Object) aShape = GetObjectImpl(theShape);
00530   Handle(GEOM_Object) aPoint = GetObjectImpl(thePoint);
00531 
00532   if (aShape.IsNull() || aPoint.IsNull()) return aGEOMObject._retn();
00533 
00534   // Create the Shape
00535   Handle(GEOM_Object) anObject =
00536     GetOperations()->GetShapesNearPoint(aShape, aPoint, theShapeType, theTolerance);
00537   if (!GetOperations()->IsDone() || anObject.IsNull())
00538     return aGEOMObject._retn();
00539 
00540   return GetObject(anObject);
00541 }
00542 
00543 //=============================================================================
00547 //=============================================================================
00548 GEOM::ListOfGO* GEOM_IBlocksOperations_i::ExplodeCompoundOfBlocks
00549                                           (GEOM::GEOM_Object_ptr theCompound,
00550                                            const CORBA::Long     theMinNbFaces,
00551                                            const CORBA::Long     theMaxNbFaces)
00552 {
00553   GEOM::ListOfGO_var aSeq = new GEOM::ListOfGO;
00554 
00555   //Set a not done flag
00556   GetOperations()->SetNotDone();
00557 
00558   //Get the reference Compound
00559   Handle(GEOM_Object) aCompound = GetObjectImpl(theCompound);
00560   if (aCompound.IsNull()) return aSeq._retn();
00561 
00562   //Explode
00563   Handle(TColStd_HSequenceOfTransient) aHSeq =
00564     GetOperations()->ExplodeCompoundOfBlocks(aCompound, theMinNbFaces, theMaxNbFaces);
00565   if (!GetOperations()->IsDone() || aHSeq.IsNull())
00566     return aSeq._retn();
00567 
00568   Standard_Integer aLength = aHSeq->Length();
00569   aSeq->length(aLength);
00570   for (Standard_Integer i = 1; i <= aLength; i++)
00571     aSeq[i-1] = GetObject(Handle(GEOM_Object)::DownCast(aHSeq->Value(i)));
00572 
00573   return aSeq._retn();
00574 }
00575 
00576 //=============================================================================
00580 //=============================================================================
00581 CORBA::Boolean GEOM_IBlocksOperations_i::IsCompoundOfBlocks
00582                                           (GEOM::GEOM_Object_ptr theCompound,
00583                                            const CORBA::Long     theMinNbFaces,
00584                                            const CORBA::Long     theMaxNbFaces,
00585                                            CORBA::Long&          theNbBlocks)
00586 {
00587   theNbBlocks = 0;
00588   CORBA::Boolean isComp = false;
00589 
00590   //Set a not done flag
00591   GetOperations()->SetNotDone();
00592 
00593   //Get the reference Compound
00594   Handle(GEOM_Object) aCompound = GetObjectImpl(theCompound);
00595   if (aCompound.IsNull()) return isComp;
00596 
00597   //Check
00598   Standard_Integer nbBlocks = 0;
00599   isComp = GetOperations()->IsCompoundOfBlocks(aCompound,
00600                                                theMinNbFaces,
00601                                                theMaxNbFaces,
00602                                                nbBlocks);
00603   if (!GetOperations()->IsDone())
00604     return isComp;
00605 
00606   theNbBlocks = nbBlocks;
00607   return isComp;
00608 }
00609 
00610 //=============================================================================
00614 //=============================================================================
00615 CORBA::Boolean GEOM_IBlocksOperations_i::CheckCompoundOfBlocks
00616                                           (GEOM::GEOM_Object_ptr theCompound,
00617                                            GEOM::GEOM_IBlocksOperations::BCErrors_out theErrors)
00618 {
00619   CORBA::Boolean isComp = false;
00620 
00621   //Set a not done flag
00622   GetOperations()->SetNotDone();
00623 
00624   //Get the reference Compound
00625   Handle(GEOM_Object) aCompound = GetObjectImpl(theCompound);
00626   if (aCompound.IsNull()) return isComp;
00627 
00628   //Check
00629   std::list<GEOMImpl_IBlocksOperations::BCError> errList;
00630   isComp = GetOperations()->CheckCompoundOfBlocks(aCompound, errList);
00631   if (!GetOperations()->IsDone())
00632     return isComp;
00633 
00634   const int nbErr = errList.size();
00635   GEOM::GEOM_IBlocksOperations::BCErrors_var anErrArray =
00636     new GEOM::GEOM_IBlocksOperations::BCErrors();
00637   anErrArray->length(nbErr);
00638 
00639   // fill the local CORBA array with values from lists
00640   std::list<GEOMImpl_IBlocksOperations::BCError>::iterator errIt = errList.begin();
00641   int i = 0;
00642   for (; errIt != errList.end(); i++, errIt++) {
00643     GEOM::GEOM_IBlocksOperations::BCError_var anError =
00644       new GEOM::GEOM_IBlocksOperations::BCError();
00645 
00646     GEOMImpl_IBlocksOperations::BCError errStruct = *errIt;
00647 
00648     switch (errStruct.error) {
00649     case GEOMImpl_IBlocksOperations::NOT_BLOCK:
00650       anError->error = GEOM::GEOM_IBlocksOperations::NOT_BLOCK;
00651       break;
00652     case GEOMImpl_IBlocksOperations::EXTRA_EDGE:
00653       anError->error = GEOM::GEOM_IBlocksOperations::EXTRA_EDGE;
00654       break;
00655     case GEOMImpl_IBlocksOperations::INVALID_CONNECTION:
00656       anError->error = GEOM::GEOM_IBlocksOperations::INVALID_CONNECTION;
00657       break;
00658     case GEOMImpl_IBlocksOperations::NOT_CONNECTED:
00659       anError->error = GEOM::GEOM_IBlocksOperations::NOT_CONNECTED;
00660       break;
00661     case GEOMImpl_IBlocksOperations::NOT_GLUED:
00662       anError->error = GEOM::GEOM_IBlocksOperations::NOT_GLUED;
00663       break;
00664     default:
00665       break;
00666     }
00667 
00668     std::list<int> sshList = errStruct.incriminated;
00669     GEOM::ListOfLong_var anIncrims = new GEOM::ListOfLong();
00670     anIncrims->length(sshList.size());
00671 
00672     std::list<int>::iterator sshIt = sshList.begin();
00673     int jj = 0;
00674     for (; sshIt != sshList.end(); jj++, sshIt++) {
00675       anIncrims[jj] = *sshIt;
00676     }
00677 
00678     anError->incriminated = anIncrims;
00679 
00680     anErrArray[i] = anError;
00681   }
00682 
00683   // initialize out-parameter with local array
00684   theErrors = anErrArray._retn();
00685 
00686   return isComp;
00687 }
00688 
00689 //=============================================================================
00693 //=============================================================================
00694 char* GEOM_IBlocksOperations_i::PrintBCErrors
00695                       (GEOM::GEOM_Object_ptr theCompound,
00696                        const GEOM::GEOM_IBlocksOperations::BCErrors& theErrors)
00697 {
00698   //Get the reference Compound
00699   Handle(GEOM_Object) aCompound = GetObjectImpl(theCompound);
00700   if (aCompound.IsNull()) return NULL;
00701 
00702   // Convert the errors sequence
00703   std::list<GEOMImpl_IBlocksOperations::BCError> anErrors;
00704   int nbErr = theErrors.length();
00705   int ie = 0;
00706   for (; ie < nbErr; ie++) {
00707     const GEOM::GEOM_IBlocksOperations::BCError err = theErrors[ie];
00708     const GEOM::GEOM_IBlocksOperations::BCErrorType typ = err.error;
00709     const GEOM::ListOfLong incrims = err.incriminated;
00710 
00711     GEOMImpl_IBlocksOperations::BCError errStruct;
00712     switch (typ) {
00713     case GEOM::GEOM_IBlocksOperations::NOT_BLOCK:
00714       errStruct.error = GEOMImpl_IBlocksOperations::NOT_BLOCK;
00715       break;
00716     case GEOM::GEOM_IBlocksOperations::EXTRA_EDGE:
00717       errStruct.error = GEOMImpl_IBlocksOperations::EXTRA_EDGE;
00718       break;
00719     case GEOM::GEOM_IBlocksOperations::INVALID_CONNECTION:
00720       errStruct.error = GEOMImpl_IBlocksOperations::INVALID_CONNECTION;
00721       break;
00722     case GEOM::GEOM_IBlocksOperations::NOT_CONNECTED:
00723       errStruct.error = GEOMImpl_IBlocksOperations::NOT_CONNECTED;
00724       break;
00725     case GEOM::GEOM_IBlocksOperations::NOT_GLUED:
00726       errStruct.error = GEOMImpl_IBlocksOperations::NOT_GLUED;
00727       break;
00728     default:
00729       break;
00730     }
00731 
00732     int ii = 0;
00733     int aLen = incrims.length();
00734     for (; ii < aLen; ii++) {
00735       errStruct.incriminated.push_back(incrims[ii]);
00736     }
00737 
00738     anErrors.push_back(errStruct);
00739   }
00740 
00741   TCollection_AsciiString aDescr = GetOperations()->PrintBCErrors(aCompound, anErrors);
00742   return CORBA::string_dup(aDescr.ToCString());
00743 }
00744 
00745 //=============================================================================
00749 //=============================================================================
00750 GEOM::GEOM_Object_ptr GEOM_IBlocksOperations_i::RemoveExtraEdges
00751                                       (GEOM::GEOM_Object_ptr theShape,
00752                                        CORBA::Long           theOptimumNbFaces)
00753 {
00754   GEOM::GEOM_Object_var aGEOMObject;
00755 
00756   //Set a not done flag
00757   GetOperations()->SetNotDone();
00758 
00759   //Get the reference Objects
00760   Handle(GEOM_Object) aShape = GetObjectImpl(theShape);
00761   if (aShape.IsNull()) return aGEOMObject._retn();
00762 
00763   //Get the result
00764   Handle(GEOM_Object) anObject = GetOperations()->RemoveExtraEdges(aShape, theOptimumNbFaces);
00765   if (!GetOperations()->IsDone() || anObject.IsNull())
00766     return aGEOMObject._retn();
00767 
00768   return GetObject(anObject);
00769 }
00770 
00771 //=============================================================================
00775 //=============================================================================
00776 GEOM::GEOM_Object_ptr GEOM_IBlocksOperations_i::CheckAndImprove (GEOM::GEOM_Object_ptr theCompound)
00777 {
00778   GEOM::GEOM_Object_var aGEOMObject;
00779 
00780   //Set a not done flag
00781   GetOperations()->SetNotDone();
00782 
00783   //Get the reference Objects
00784   Handle(GEOM_Object) aCompound = GetObjectImpl(theCompound);
00785   if (aCompound.IsNull()) return aGEOMObject._retn();
00786 
00787   //Get the result
00788   Handle(GEOM_Object) anObject =
00789     GetOperations()->CheckAndImprove(aCompound);
00790   if (!GetOperations()->IsDone() || anObject.IsNull())
00791     return aGEOMObject._retn();
00792 
00793   return GetObject(anObject);
00794 }
00795 
00796 //=============================================================================
00800 //=============================================================================
00801 GEOM::GEOM_Object_ptr GEOM_IBlocksOperations_i::GetBlockNearPoint (GEOM::GEOM_Object_ptr theCompound,
00802                                                                    GEOM::GEOM_Object_ptr thePoint)
00803 {
00804   GEOM::GEOM_Object_var aGEOMObject;
00805 
00806   //Set a not done flag
00807   GetOperations()->SetNotDone();
00808 
00809   //Get the reference Objects
00810   Handle(GEOM_Object) aCompound = GetObjectImpl(theCompound);
00811   Handle(GEOM_Object) aPoint = GetObjectImpl(thePoint);
00812 
00813   if (aCompound.IsNull() || aPoint.IsNull()) return aGEOMObject._retn();
00814 
00815   //Get the block
00816   Handle(GEOM_Object) anObject =
00817     GetOperations()->GetBlockNearPoint(aCompound, aPoint);
00818   if (!GetOperations()->IsDone() || anObject.IsNull())
00819     return aGEOMObject._retn();
00820 
00821   return GetObject(anObject);
00822 }
00823 
00824 //=============================================================================
00828 //=============================================================================
00829 GEOM::GEOM_Object_ptr GEOM_IBlocksOperations_i::GetBlockByParts (GEOM::GEOM_Object_ptr theCompound,
00830                                                                  const GEOM::ListOfGO& theParts)
00831 {
00832   GEOM::GEOM_Object_var aGEOMObject;
00833 
00834   //Set a not done flag
00835   GetOperations()->SetNotDone();
00836 
00837   //Get the reference Compound
00838   Handle(GEOM_Object) aCompound = GetObjectImpl(theCompound);
00839   if (aCompound.IsNull()) return aGEOMObject._retn();
00840 
00841   //Get the parts
00842   int ind, aLen;
00843   Handle(TColStd_HSequenceOfTransient) aParts = new TColStd_HSequenceOfTransient;
00844 
00845   aLen = theParts.length();
00846   for (ind = 0; ind < aLen; ind++) {
00847     Handle(GEOM_Object) aSh = GetObjectImpl(theParts[ind]);
00848     if (aSh.IsNull()) return aGEOMObject._retn();
00849     aParts->Append(aSh);
00850   }
00851 
00852   //Get the Block
00853   Handle(GEOM_Object) anObject =
00854     GetOperations()->GetBlockByParts(aCompound, aParts);
00855   if (!GetOperations()->IsDone() || anObject.IsNull())
00856     return aGEOMObject._retn();
00857 
00858   return GetObject(anObject);
00859 }
00860 
00861 //=============================================================================
00865 //=============================================================================
00866 GEOM::ListOfGO* GEOM_IBlocksOperations_i::GetBlocksByParts (GEOM::GEOM_Object_ptr theCompound,
00867                                                             const GEOM::ListOfGO& theParts)
00868 {
00869   GEOM::ListOfGO_var aSeq = new GEOM::ListOfGO;
00870 
00871   //Set a not done flag
00872   GetOperations()->SetNotDone();
00873 
00874   //Get the reference Compound
00875   Handle(GEOM_Object) aCompound = GetObjectImpl(theCompound);
00876   if (aCompound.IsNull()) return aSeq._retn();
00877 
00878   //Get the parts
00879   int ind, aLen;
00880   Handle(TColStd_HSequenceOfTransient) aParts = new TColStd_HSequenceOfTransient;
00881 
00882   aLen = theParts.length();
00883   for (ind = 0; ind < aLen; ind++) {
00884     Handle(GEOM_Object) aSh = GetObjectImpl(theParts[ind]);
00885     if (aSh.IsNull()) return aSeq._retn();
00886     aParts->Append(aSh);
00887   }
00888 
00889   //Get the Block
00890   Handle(TColStd_HSequenceOfTransient) aHSeq =
00891     GetOperations()->GetBlocksByParts(aCompound, aParts);
00892   if (!GetOperations()->IsDone() || aHSeq.IsNull())
00893     return aSeq._retn();
00894 
00895   Standard_Integer aLength = aHSeq->Length();
00896   aSeq->length(aLength);
00897   for (Standard_Integer i = 1; i <= aLength; i++)
00898     aSeq[i-1] = GetObject(Handle(GEOM_Object)::DownCast(aHSeq->Value(i)));
00899 
00900   return aSeq._retn();
00901 }
00902 
00903 //=============================================================================
00907 //=============================================================================
00908 GEOM::GEOM_Object_ptr GEOM_IBlocksOperations_i::MakeMultiTransformation1D
00909                                               (GEOM::GEOM_Object_ptr theBlock,
00910                                                const CORBA::Long     theDirFace1,
00911                                                const CORBA::Long     theDirFace2,
00912                                                const CORBA::Long     theNbTimes)
00913 {
00914   GEOM::GEOM_Object_var aGEOMObject;
00915 
00916   //Set a not done flag
00917   GetOperations()->SetNotDone();
00918 
00919   //Get the object itself and the vector of translation
00920   Handle(GEOM_Object) aBasicObject = GetObjectImpl(theBlock);
00921   if (aBasicObject.IsNull()) return aGEOMObject._retn();
00922 
00923   //Perform the transformation
00924   Handle(GEOM_Object) anObject = GetOperations()->MakeMultiTransformation1D
00925     (aBasicObject, theDirFace1, theDirFace2, theNbTimes);
00926   if (!GetOperations()->IsDone() || anObject.IsNull())  return aGEOMObject._retn();
00927 
00928   return GetObject(anObject);
00929 }
00930 
00931 //=============================================================================
00935 //=============================================================================
00936 GEOM::GEOM_Object_ptr GEOM_IBlocksOperations_i::MakeMultiTransformation2D
00937                                            (GEOM::GEOM_Object_ptr theBlock,
00938                                             const CORBA::Long     theDirFace1U,
00939                                             const CORBA::Long     theDirFace2U,
00940                                             const CORBA::Long     theNbTimesU,
00941                                             const CORBA::Long     theDirFace1V,
00942                                             const CORBA::Long     theDirFace2V,
00943                                             const CORBA::Long     theNbTimesV)
00944 {
00945   GEOM::GEOM_Object_var aGEOMObject;
00946 
00947   //Set a not done flag
00948   GetOperations()->SetNotDone();
00949 
00950   //Get the object itself
00951   Handle(GEOM_Object) aBasicObject = GetObjectImpl(theBlock);
00952   if (aBasicObject.IsNull()) return aGEOMObject._retn();
00953 
00954   //Perform the transformation
00955   Handle(GEOM_Object) anObject = GetOperations()->MakeMultiTransformation2D
00956     (aBasicObject,
00957      theDirFace1U, theDirFace2U, theNbTimesU,
00958      theDirFace1V, theDirFace2V, theNbTimesV);
00959   if (!GetOperations()->IsDone() || anObject.IsNull()) return aGEOMObject._retn();
00960 
00961   return GetObject(anObject);
00962 }
00963 
00964 //=============================================================================
00968 //=============================================================================
00969 GEOM::ListOfGO* GEOM_IBlocksOperations_i::Propagate (GEOM::GEOM_Object_ptr theShape)
00970 {
00971   GEOM::ListOfGO_var aSeq = new GEOM::ListOfGO;
00972 
00973   //Set a not done flag
00974   GetOperations()->SetNotDone();
00975 
00976   //Get the reference Shape
00977   Handle(GEOM_Object) aShape = GetObjectImpl(theShape);
00978   if (aShape.IsNull()) return aSeq._retn();
00979 
00980   //Get the Propagation chains
00981   Handle(TColStd_HSequenceOfTransient) aHSeq =
00982     GetOperations()->Propagate(aShape);
00983   if (!GetOperations()->IsDone() || aHSeq.IsNull())
00984     return aSeq._retn();
00985 
00986   Standard_Integer aLength = aHSeq->Length();
00987   aSeq->length(aLength);
00988   for (Standard_Integer i = 1; i <= aLength; i++)
00989     aSeq[i-1] = GetObject(Handle(GEOM_Object)::DownCast(aHSeq->Value(i)));
00990 
00991   return aSeq._retn();
00992 }