Back to index

salome-geom  6.5.0
GEOM_ICurvesOperations_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_ICurvesOperations_i.hh"
00026 
00027 #include "utilities.h"
00028 #include "OpUtil.hxx"
00029 
00030 #include "GEOM_Engine.hxx"
00031 #include "GEOM_Object.hxx"
00032 
00033 //=============================================================================
00037 //=============================================================================
00038 GEOM_ICurvesOperations_i::GEOM_ICurvesOperations_i (PortableServer::POA_ptr thePOA,
00039                                                     GEOM::GEOM_Gen_ptr theEngine,
00040                                                     ::GEOMImpl_ICurvesOperations* theImpl)
00041 :GEOM_IOperations_i(thePOA, theEngine, theImpl)
00042 {
00043   MESSAGE("GEOM_ICurvesOperations_i::GEOM_ICurvesOperations_i");
00044 }
00045 
00046 //=============================================================================
00050 //=============================================================================
00051 GEOM_ICurvesOperations_i::~GEOM_ICurvesOperations_i()
00052 {
00053   MESSAGE("GEOM_ICurvesOperations_i::~GEOM_ICurvesOperations_i");
00054 }
00055 
00056 
00057 //=============================================================================
00061 //=============================================================================
00062 GEOM::GEOM_Object_ptr GEOM_ICurvesOperations_i::MakeCirclePntVecR
00063                       (GEOM::GEOM_Object_ptr thePnt, GEOM::GEOM_Object_ptr theVec,
00064                        CORBA::Double theR)
00065 {
00066   GEOM::GEOM_Object_var aGEOMObject;
00067 
00068   //Set a not done flag
00069   GetOperations()->SetNotDone();
00070 
00071   // Not set thePnt means origin of global CS,
00072   // Not set theVec means Z axis of global CS
00073   //if (thePnt == NULL || theVec == NULL) return aGEOMObject._retn();
00074 
00075   //Get the arguments
00076   Handle(GEOM_Object) aPnt, aVec;
00077   if (!CORBA::is_nil(thePnt)) {
00078     aPnt = GetObjectImpl(thePnt);
00079     if (aPnt.IsNull()) return aGEOMObject._retn();
00080   }
00081   if (!CORBA::is_nil(theVec)) {
00082     aVec = GetObjectImpl(theVec);
00083     if (aVec.IsNull()) return aGEOMObject._retn();
00084   }
00085 
00086   // Make Circle
00087   Handle(GEOM_Object) anObject =
00088     GetOperations()->MakeCirclePntVecR(aPnt, aVec, theR);
00089   if (!GetOperations()->IsDone() || anObject.IsNull())
00090     return aGEOMObject._retn();
00091 
00092   return GetObject(anObject);
00093 }
00094 
00095 //=============================================================================
00099 //=============================================================================
00100 GEOM::GEOM_Object_ptr GEOM_ICurvesOperations_i::MakeCircleThreePnt
00101                       (GEOM::GEOM_Object_ptr thePnt1, GEOM::GEOM_Object_ptr thePnt2,
00102                        GEOM::GEOM_Object_ptr thePnt3)
00103 {
00104   GEOM::GEOM_Object_var aGEOMObject;
00105 
00106   //Set a not done flag
00107   GetOperations()->SetNotDone();
00108 
00109   //Get the reference points
00110   Handle(GEOM_Object) aPnt1 = GetObjectImpl(thePnt1);
00111   Handle(GEOM_Object) aPnt2 = GetObjectImpl(thePnt2);
00112   Handle(GEOM_Object) aPnt3 = GetObjectImpl(thePnt3);
00113 
00114   if (aPnt1.IsNull() || aPnt2.IsNull() || aPnt3.IsNull()) return aGEOMObject._retn();
00115 
00116   // Make Circle
00117   Handle(GEOM_Object) anObject =
00118       GetOperations()->MakeCircleThreePnt(aPnt1, aPnt2, aPnt3);
00119   if (!GetOperations()->IsDone() || anObject.IsNull())
00120     return aGEOMObject._retn();
00121 
00122   return GetObject(anObject);
00123 }
00124 
00125 //=============================================================================
00129 //=============================================================================
00130 GEOM::GEOM_Object_ptr GEOM_ICurvesOperations_i::MakeCircleCenter2Pnt
00131                       (GEOM::GEOM_Object_ptr thePnt1, GEOM::GEOM_Object_ptr thePnt2,
00132                        GEOM::GEOM_Object_ptr thePnt3)
00133 {
00134   GEOM::GEOM_Object_var aGEOMObject;
00135 
00136   //Set a not done flag
00137   GetOperations()->SetNotDone();
00138 
00139   //Get the reference points
00140   Handle(GEOM_Object) aPnt1 = GetObjectImpl(thePnt1);
00141   Handle(GEOM_Object) aPnt2 = GetObjectImpl(thePnt2);
00142   Handle(GEOM_Object) aPnt3 = GetObjectImpl(thePnt3);
00143 
00144   if (aPnt1.IsNull() || aPnt2.IsNull() || aPnt3.IsNull()) return aGEOMObject._retn();
00145 
00146   // Make Circle
00147   Handle(GEOM_Object) anObject = GetOperations()->MakeCircleCenter2Pnt(aPnt1, aPnt2, aPnt3);
00148   if (!GetOperations()->IsDone() || anObject.IsNull())
00149     return aGEOMObject._retn();
00150 
00151   return GetObject(anObject);
00152 }
00153 
00154 //=============================================================================
00158 //=============================================================================
00159 GEOM::GEOM_Object_ptr GEOM_ICurvesOperations_i::MakeEllipse
00160                       (GEOM::GEOM_Object_ptr thePnt, GEOM::GEOM_Object_ptr theVec,
00161                        CORBA::Double theRMajor, double theRMinor)
00162 {
00163   GEOM::GEOM_Object_var aGEOMObject;
00164 
00165   //Set a not done flag
00166   GetOperations()->SetNotDone();
00167 
00168   // Not set thePnt means origin of global CS,
00169   // Not set theVec means Z axis of global CS
00170   //if (thePnt == NULL || theVec == NULL) return aGEOMObject._retn();
00171 
00172   //Get the arguments
00173   Handle(GEOM_Object) aPnt, aVec, aVecMaj;
00174   if (!CORBA::is_nil(thePnt)) {
00175     aPnt = GetObjectImpl(thePnt);
00176     if (aPnt.IsNull()) return aGEOMObject._retn();
00177   }
00178   if (!CORBA::is_nil(theVec)) {
00179     aVec = GetObjectImpl(theVec);
00180     if (aVec.IsNull()) return aGEOMObject._retn();
00181   }
00182 
00183   // Make Ellipse
00184   Handle(GEOM_Object) anObject =
00185     GetOperations()->MakeEllipse(aPnt, aVec, theRMajor, theRMinor, aVecMaj);
00186   if (!GetOperations()->IsDone() || anObject.IsNull())
00187     return aGEOMObject._retn();
00188 
00189   return GetObject(anObject);
00190 }
00191 
00192 //=============================================================================
00196 //=============================================================================
00197 GEOM::GEOM_Object_ptr GEOM_ICurvesOperations_i::MakeEllipseVec
00198                       (GEOM::GEOM_Object_ptr thePnt, GEOM::GEOM_Object_ptr theVec,
00199                        CORBA::Double theRMajor, double theRMinor,
00200                        GEOM::GEOM_Object_ptr theVecMaj)
00201 {
00202   GEOM::GEOM_Object_var aGEOMObject;
00203 
00204   //Set a not done flag
00205   GetOperations()->SetNotDone();
00206 
00207   // Not set thePnt means origin of global CS,
00208   // Not set theVec means Z axis of global CS
00209   // Not set theVecMaj means X axis of global CS
00210   //if (thePnt == NULL || theVec == NULL || theVecMaj == NULL) return aGEOMObject._retn();
00211 
00212   //Get the arguments
00213   Handle(GEOM_Object) aPnt, aVec, aVecMaj;
00214   if (!CORBA::is_nil(thePnt)) {
00215     aPnt = GetObjectImpl(thePnt);
00216     if (aPnt.IsNull()) return aGEOMObject._retn();
00217   }
00218   if (!CORBA::is_nil(theVec)) {
00219     aVec = GetObjectImpl(theVec);
00220     if (aVec.IsNull()) return aGEOMObject._retn();
00221   }
00222   if (!CORBA::is_nil(theVecMaj)) {
00223     aVecMaj = GetObjectImpl(theVecMaj);
00224     if (aVecMaj.IsNull()) return aGEOMObject._retn();
00225   }
00226 
00227   // Make Ellipse
00228   Handle(GEOM_Object) anObject =
00229     GetOperations()->MakeEllipse(aPnt, aVec, theRMajor, theRMinor, aVecMaj);
00230   if (!GetOperations()->IsDone() || anObject.IsNull())
00231     return aGEOMObject._retn();
00232 
00233   return GetObject(anObject);
00234 }
00235 
00236 //=============================================================================
00240 //=============================================================================
00241 GEOM::GEOM_Object_ptr GEOM_ICurvesOperations_i::MakeArc
00242                                                 (GEOM::GEOM_Object_ptr thePnt1,
00243                                                  GEOM::GEOM_Object_ptr thePnt2,
00244                                                  GEOM::GEOM_Object_ptr thePnt3)
00245 {
00246   GEOM::GEOM_Object_var aGEOMObject;
00247 
00248   //Set a not done flag
00249   GetOperations()->SetNotDone();
00250 
00251   //Get the reference points
00252   Handle(GEOM_Object) aPnt1 = GetObjectImpl(thePnt1);
00253   Handle(GEOM_Object) aPnt2 = GetObjectImpl(thePnt2);
00254   Handle(GEOM_Object) aPnt3 = GetObjectImpl(thePnt3);
00255 
00256   if (aPnt1.IsNull() || aPnt2.IsNull() || aPnt3.IsNull()) return aGEOMObject._retn();
00257 
00258   // Make Arc
00259   Handle(GEOM_Object) anObject =
00260     GetOperations()->MakeArc(aPnt1, aPnt2, aPnt3);
00261   if (!GetOperations()->IsDone() || anObject.IsNull())
00262     return aGEOMObject._retn();
00263 
00264   return GetObject(anObject);
00265 }
00266 
00267 
00268 //=============================================================================
00272 //=============================================================================
00273 GEOM::GEOM_Object_ptr GEOM_ICurvesOperations_i::MakeArcCenter
00274     (GEOM::GEOM_Object_ptr thePnt1,
00275      GEOM::GEOM_Object_ptr thePnt2,
00276      GEOM::GEOM_Object_ptr thePnt3,
00277      CORBA::Boolean theSense)
00278 
00279 {
00280   GEOM::GEOM_Object_var aGEOMObject;
00281   //Set a not done flag
00282   GetOperations()->SetNotDone();
00283 
00284   //Get the reference points
00285   Handle(GEOM_Object) aPnt1 = GetObjectImpl(thePnt1);
00286   Handle(GEOM_Object) aPnt2 = GetObjectImpl(thePnt2);
00287   Handle(GEOM_Object) aPnt3 = GetObjectImpl(thePnt3);
00288 
00289   if (aPnt1.IsNull() || aPnt2.IsNull() || aPnt3.IsNull()) return aGEOMObject._retn();
00290 
00291   // Make ArcCenter
00292   Handle(GEOM_Object) anObject =
00293       GetOperations()->MakeArcCenter(aPnt1, aPnt2, aPnt3,theSense);
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_ICurvesOperations_i::MakeArcOfEllipse
00306                                                 (GEOM::GEOM_Object_ptr thePnt1,
00307                                                  GEOM::GEOM_Object_ptr thePnt2,
00308                                                  GEOM::GEOM_Object_ptr thePnt3)
00309 {
00310   GEOM::GEOM_Object_var aGEOMObject;
00311 
00312   //Set a not done flag
00313   GetOperations()->SetNotDone();
00314 
00315   //Get the reference points
00316   Handle(GEOM_Object) aPnt1 = GetObjectImpl(thePnt1);
00317   Handle(GEOM_Object) aPnt2 = GetObjectImpl(thePnt2);
00318   Handle(GEOM_Object) aPnt3 = GetObjectImpl(thePnt3);
00319 
00320   if (aPnt1.IsNull() || aPnt2.IsNull() || aPnt3.IsNull()) return aGEOMObject._retn();
00321 
00322   // Make Arc
00323   Handle(GEOM_Object) anObject =
00324     GetOperations()->MakeArcOfEllipse(aPnt1, aPnt2, aPnt3);
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_ICurvesOperations_i::MakePolyline
00337                                     (const GEOM::ListOfGO& thePoints,
00338                                      CORBA::Boolean        theIsClosed)
00339 {
00340   GEOM::GEOM_Object_var aGEOMObject;
00341 
00342   //Set a not done flag
00343   GetOperations()->SetNotDone();
00344 
00345   //Get the reference point
00346   int ind = 0;
00347   int aLen = thePoints.length();
00348   std::list<Handle(GEOM_Object)> aPoints;
00349   for (; ind < aLen; ind++) {
00350     Handle(GEOM_Object) aPnt = GetObjectImpl(thePoints[ind]);
00351     if (aPnt.IsNull()) return aGEOMObject._retn();
00352     aPoints.push_back(aPnt);
00353   }
00354 
00355   // Make Polyline
00356   Handle(GEOM_Object) anObject =
00357     GetOperations()->MakePolyline(aPoints, theIsClosed);
00358   if (!GetOperations()->IsDone() || anObject.IsNull())
00359     return aGEOMObject._retn();
00360 
00361   return GetObject(anObject);
00362 }
00363 
00364 //=============================================================================
00368 //=============================================================================
00369 GEOM::GEOM_Object_ptr GEOM_ICurvesOperations_i::MakeSplineBezier
00370                                               (const GEOM::ListOfGO& thePoints,
00371                                                CORBA::Boolean        theIsClosed)
00372 {
00373   GEOM::GEOM_Object_var aGEOMObject;
00374 
00375   //Set a not done flag
00376   GetOperations()->SetNotDone();
00377 
00378   //Get the reference point
00379   int ind = 0;
00380   int aLen = thePoints.length();
00381   std::list<Handle(GEOM_Object)> aPoints;
00382   for (; ind < aLen; ind++) {
00383     Handle(GEOM_Object) aPnt = GetObjectImpl(thePoints[ind]);
00384     if (aPnt.IsNull()) return aGEOMObject._retn();
00385     aPoints.push_back(aPnt);
00386   }
00387 
00388   // Make Bezier curve
00389   Handle(GEOM_Object) anObject =
00390       GetOperations()->MakeSplineBezier(aPoints, theIsClosed);
00391   if (!GetOperations()->IsDone() || anObject.IsNull())
00392     return aGEOMObject._retn();
00393 
00394   return GetObject(anObject);
00395 }
00396 
00397 //=============================================================================
00401 //=============================================================================
00402 GEOM::GEOM_Object_ptr GEOM_ICurvesOperations_i::MakeSplineInterpolation
00403                                               (const GEOM::ListOfGO& thePoints,
00404                                                CORBA::Boolean        theIsClosed,
00405                                                CORBA::Boolean        theDoReordering)
00406 {
00407   GEOM::GEOM_Object_var aGEOMObject;
00408 
00409   //Set a not done flag
00410   GetOperations()->SetNotDone();
00411 
00412   //Get the reference point
00413   int ind = 0;
00414   int aLen = thePoints.length();
00415   std::list<Handle(GEOM_Object)> aPoints;
00416   for (; ind < aLen; ind++) {
00417     Handle(GEOM_Object) aPnt = GetObjectImpl(thePoints[ind]);
00418     if (aPnt.IsNull()) return aGEOMObject._retn();
00419     aPoints.push_back(aPnt);
00420   }
00421 
00422   // Make Polyline
00423   Handle(GEOM_Object) anObject =
00424     GetOperations()->MakeSplineInterpolation(aPoints, theIsClosed, theDoReordering);
00425   if (!GetOperations()->IsDone() || anObject.IsNull())
00426     return aGEOMObject._retn();
00427 
00428   return GetObject(anObject);
00429 }
00430 
00431 //=============================================================================
00435 //=============================================================================
00436 GEOM::GEOM_Object_ptr GEOM_ICurvesOperations_i::MakeCurveParametric(const char* thexExpr, const char* theyExpr, const char* thezExpr, 
00437                                                             double theParamMin, double theParamMax, double theParamStep, 
00438                                                             GEOM::curve_type theCurveType) {
00439   GEOM::GEOM_Object_var aGEOMObject;
00440   //Set a not done flag
00441   GetOperations()->SetNotDone();
00442   
00443   GEOMImpl_ICurvesOperations::CurveType aType;
00444   switch(theCurveType) {
00445   case GEOM::Polyline:
00446     aType = GEOMImpl_ICurvesOperations::Polyline;
00447     break;
00448   case GEOM::Bezier:
00449     aType = GEOMImpl_ICurvesOperations::Bezier;
00450     break;
00451   case GEOM::Interpolation:
00452     aType = GEOMImpl_ICurvesOperations::Interpolation;
00453     break;
00454   default:
00455     break;
00456   }  
00457   
00458 
00459   // Make Polyline
00460   Handle(GEOM_Object) anObject =
00461     GetOperations()->MakeCurveParametric(thexExpr, theyExpr, thezExpr, 
00462                                       theParamMin, theParamMax, 
00463                                       theParamStep, aType);
00464   
00465   if (!GetOperations()->IsDone() || anObject.IsNull())
00466     return aGEOMObject._retn();  
00467   
00468   return GetObject(anObject);
00469 }
00470 
00471 //=============================================================================
00475 //=============================================================================
00476 GEOM::GEOM_Object_ptr GEOM_ICurvesOperations_i::MakeCurveParametricNew(const char* thexExpr, const char* theyExpr, const char* thezExpr, 
00477                                     double theParamMin, double theParamMax, CORBA::Long theParamNbStep, 
00478                                     GEOM::curve_type theCurveType) {
00479   GEOM::GEOM_Object_var aGEOMObject;
00480   //Set a not done flag
00481   GetOperations()->SetNotDone();
00482   
00483   GEOMImpl_ICurvesOperations::CurveType aType;
00484   switch(theCurveType) {
00485   case GEOM::Polyline:
00486     aType = GEOMImpl_ICurvesOperations::Polyline;
00487     break;
00488   case GEOM::Bezier:
00489     aType = GEOMImpl_ICurvesOperations::Bezier;
00490     break;
00491   case GEOM::Interpolation:
00492     aType = GEOMImpl_ICurvesOperations::Interpolation;
00493     break;
00494   default:
00495     break;
00496   }  
00497   
00498 
00499   // Make Polyline
00500   Handle(GEOM_Object) anObject =
00501     GetOperations()->MakeCurveParametric(thexExpr, theyExpr, thezExpr, 
00502                        theParamMin, theParamMax, 
00503                        0.0, aType, theParamNbStep, true);
00504   
00505   if (!GetOperations()->IsDone() || anObject.IsNull())
00506     return aGEOMObject._retn();  
00507   
00508   return GetObject(anObject);
00509 }
00510 
00511 //=============================================================================
00515 //=============================================================================
00516 GEOM::GEOM_Object_ptr GEOM_ICurvesOperations_i::MakeSketcher
00517             (const char* theCommand, const GEOM::ListOfDouble& theWorkingPlane)
00518 {
00519   //Set a not done flag
00520   GetOperations()->SetNotDone();
00521 
00522   int ind = 0;
00523   int aLen = theWorkingPlane.length();
00524   std::list<double> aWorkingPlane;
00525   for (; ind < aLen; ind++)
00526     aWorkingPlane.push_back(theWorkingPlane[ind]);
00527 
00528   // Make Sketcher
00529   Handle(GEOM_Object) anObject =
00530     GetOperations()->MakeSketcher(theCommand, aWorkingPlane);
00531   if (!GetOperations()->IsDone() || anObject.IsNull())
00532     return GEOM::GEOM_Object::_nil();
00533 
00534   return GetObject(anObject);
00535 }
00536 
00537 //=============================================================================
00541 //=============================================================================
00542 GEOM::GEOM_Object_ptr GEOM_ICurvesOperations_i::Make3DSketcher
00543             (const GEOM::ListOfDouble& theCoordinates)
00544 {
00545   //Set a not done flag
00546   GetOperations()->SetNotDone();
00547 
00548   int ind = 0;
00549   int aLen = theCoordinates.length();
00550   std::list<double> aCoords;
00551   for (; ind < aLen; ind++)
00552     aCoords.push_back(theCoordinates[ind]);
00553 
00554   // Make Sketcher
00555   Handle(GEOM_Object) anObject =
00556     GetOperations()->Make3DSketcher(aCoords);
00557   if (!GetOperations()->IsDone() || anObject.IsNull())
00558     return GEOM::GEOM_Object::_nil();
00559 
00560   return GetObject(anObject);
00561 }
00562 
00563 //=============================================================================
00567 //=============================================================================
00568 GEOM::GEOM_Object_ptr GEOM_ICurvesOperations_i::MakeSketcherOnPlane
00569                 (const char* theCommand, GEOM::GEOM_Object_ptr theWorkingPlane)
00570 {
00571   //Set a not done flag
00572   GetOperations()->SetNotDone();
00573 
00574   Handle(GEOM_Object) aWorkingPlane = GetObjectImpl(theWorkingPlane);
00575 
00576   // Make Sketcher
00577   Handle(GEOM_Object) anObject =
00578       GetOperations()->MakeSketcherOnPlane(theCommand, aWorkingPlane);
00579   if (!GetOperations()->IsDone() || anObject.IsNull())
00580     return GEOM::GEOM_Object::_nil();
00581 
00582   return GetObject(anObject);
00583 }