Salome HOME
0016757: EDF 546 GEOM : Add Face and Disc in geom primitives
[modules/geom.git] / src / GEOM_I_Superv / GEOM_Superv_i.cc
index 666ec08611870b4bc0b114ff8ac91c81daa2e4e7..3a37d31026946348592a9ab6ec89bea1aeb2cb11 100644 (file)
@@ -70,6 +70,12 @@ GEOM_Superv_i::GEOM_Superv_i(CORBA::ORB_ptr orb,
 GEOM_Superv_i::~GEOM_Superv_i()
 {
   MESSAGE("GEOM_Superv_i::~GEOM_Superv_i");
+  if (!CORBA::is_nil(myBasicOp))
+    myBasicOp->Destroy();
+  if (!CORBA::is_nil(myBoolOp))
+    myBoolOp->Destroy();
+  if (!CORBA::is_nil(my3DPrimOp))
+    my3DPrimOp->Destroy();
   delete name_service;
 }
 
@@ -79,8 +85,8 @@ GEOM_Superv_i::~GEOM_Superv_i()
 //============================================================================
 void GEOM_Superv_i::register_name(char * name)
 {
-  GEOM::GEOM_Superv_ptr g = GEOM::GEOM_Superv::_narrow(POA_GEOM::GEOM_Superv::_this());
-  name_service->Register(g, strdup(name)); 
+  GEOM::GEOM_Superv_var g = _this();
+  name_service->Register(g, name); 
 }
 
 //=============================================================================
@@ -88,9 +94,17 @@ void GEOM_Superv_i::register_name(char * name)
 //=============================================================================
 void GEOM_Superv_i::setGeomEngine()
 {
+  if ( !CORBA::is_nil(myGeomEngine) ) 
+    return;
+
   // get GEOM_Gen engine
+  Engines::Container_var cont=GetContainerRef();
+  CORBA::String_var container_name=cont->name();
+  std::string shortName=container_name.in();
+  shortName=shortName.substr(12); // substract "/Containers/"
   SALOME_LifeCycleCORBA* lcc = new SALOME_LifeCycleCORBA( name_service );
-  Engines::Component_var comp = lcc->FindOrLoad_Component( "FactoryServer", "GEOM" );
+  Engines::Component_var comp = lcc->FindOrLoad_Component( shortName.c_str(), "GEOM" );
+  delete lcc;
 
   myGeomEngine = GEOM::GEOM_Gen::_narrow(comp);
 }
@@ -757,6 +771,65 @@ GEOM::GEOM_Object_ptr GEOM_Superv_i::MakeBoxTwoPnt (GEOM::GEOM_Object_ptr thePnt
   return anObj;
 }
 
+//=============================================================================
+//  MakeFaceHW:
+//=============================================================================
+GEOM::GEOM_Object_ptr GEOM_Superv_i::MakeFaceHW (CORBA::Double theH,
+                                                CORBA::Double theW)
+{
+  beginService( " GEOM_Superv_i::MakeFaceHW" );
+  MESSAGE("GEOM_Superv_i::MakeFaceHW");
+  get3DPrimOp();
+  GEOM::GEOM_Object_ptr anObj = my3DPrimOp->MakeFaceHW(theH, theW);
+  endService( " GEOM_Superv_i::MakeFaceHW" );
+  return anObj;
+}
+
+//=============================================================================
+//  MakeFaceTwoPlaneHW:
+//=============================================================================
+GEOM::GEOM_Object_ptr GEOM_Superv_i::MakeFacePlaneHW (GEOM::GEOM_Object_ptr theFace, 
+                                                     CORBA::Double theH,
+                                                     CORBA::Double theW)
+{
+  beginService( " GEOM_Superv_i::MakeFacePlaneHW" );
+  MESSAGE("GEOM_Superv_i::MakeFacePlaneHW");
+  get3DPrimOp();
+  GEOM::GEOM_Object_ptr anObj = my3DPrimOp->MakeFacePlaneHW(theFace, theH, theW);
+  endService( " GEOM_Superv_i::MakeFacePlaneHW" );
+  return anObj;
+}
+
+//=============================================================================
+//  MakeDiskPntVecR:
+//=============================================================================
+GEOM::GEOM_Object_ptr GEOM_Superv_i::MakeDiskPntVecR (GEOM::GEOM_Object_ptr theCenter,
+                                                     GEOM::GEOM_Object_ptr theVector,
+                                                     CORBA::Double theR)
+{
+  beginService( " GEOM_Superv_i::MakeDiskPntVecR" );
+  MESSAGE("GEOM_Superv_i::MakeDiskPntVecR");
+  get3DPrimOp();
+  GEOM::GEOM_Object_ptr anObj = my3DPrimOp->MakeDiskPntVecR(theCenter, theVector, theR);
+  endService( " GEOM_Superv_i::MakeDiskPntVecR" );
+  return anObj;
+}
+
+//=============================================================================
+//  MakeDiskThreePnt:
+//=============================================================================
+GEOM::GEOM_Object_ptr GEOM_Superv_i::MakeDiskThreePnt (GEOM::GEOM_Object_ptr thePnt1,
+                                                      GEOM::GEOM_Object_ptr thePnt2,
+                                                      GEOM::GEOM_Object_ptr thePnt3)
+{
+  beginService( " GEOM_Superv_i::MakeDiskThreePnt" );
+  MESSAGE("GEOM_Superv_i::MakeDiskThreePnt");
+  get3DPrimOp();
+  GEOM::GEOM_Object_ptr anObj = my3DPrimOp->MakeDiskThreePnt(thePnt1, thePnt2, thePnt3);
+  endService( " GEOM_Superv_i::MakeDiskThreePnt" );
+  return anObj;
+}
+
 //=============================================================================
 //  MakeCylinderPntVecRH:
 //=============================================================================
@@ -953,6 +1026,34 @@ GEOM::GEOM_Object_ptr GEOM_Superv_i::MakePrismTwoPnt2Ways (GEOM::GEOM_Object_ptr
   return anObj;
 }
 
+//=============================================================================
+//  MakePrismDXDYDZ:
+//=============================================================================
+GEOM::GEOM_Object_ptr GEOM_Superv_i::MakePrismDXDYDZ (GEOM::GEOM_Object_ptr theBase,
+                     CORBA::Double theDX, CORBA::Double theDY, CORBA::Double theDZ)
+{
+  beginService( " GEOM_Superv_i::MakePrismDXDYDZ" );
+  MESSAGE("GEOM_Superv_i::MakePrismDXDYDZ");
+  get3DPrimOp();
+  GEOM::GEOM_Object_ptr anObj = my3DPrimOp->MakePrismDXDYDZ(theBase, theDX, theDY, theDZ);
+  endService( " GEOM_Superv_i::MakePrismDXDYDZ" );
+  return anObj;
+}
+
+//=============================================================================
+//  MakePrismDXDYDZ:
+//=============================================================================
+GEOM::GEOM_Object_ptr GEOM_Superv_i::MakePrismDXDYDZ2Ways (GEOM::GEOM_Object_ptr theBase,
+                     CORBA::Double theDX, CORBA::Double theDY, CORBA::Double theDZ)
+{
+  beginService( " GEOM_Superv_i::MakePrismDXDYDZ2Ways" );
+  MESSAGE("GEOM_Superv_i::MakePrismDXDYDZ2Ways");
+  get3DPrimOp();
+  GEOM::GEOM_Object_ptr anObj = my3DPrimOp->MakePrismDXDYDZ2Ways(theBase, theDX, theDY, theDZ);
+  endService( " GEOM_Superv_i::MakePrismDXDYDZ2Ways" );
+  return anObj;
+}
+
 //=============================================================================
 //  MakePipe:
 //=============================================================================
@@ -1003,12 +1104,12 @@ GEOM::GEOM_Object_ptr GEOM_Superv_i::MakeRevolutionAxisAngle2Ways (GEOM::GEOM_Ob
 GEOM::GEOM_Object_ptr GEOM_Superv_i::MakeFilling (GEOM::GEOM_Object_ptr theShape,
                                                  CORBA::Long theMinDeg, CORBA::Long theMaxDeg,
                                                  CORBA::Double theTol2D, CORBA::Double theTol3D,
-                                                 CORBA::Long theNbIter)
+                                                 CORBA::Long theNbIter, CORBA::Boolean theApprox)
 {
   beginService( " GEOM_Superv_i::MakeFilling" );
   MESSAGE("GEOM_Superv_i::MakeFilling");
   get3DPrimOp();
-  GEOM::GEOM_Object_ptr anObj = my3DPrimOp->MakeFilling(theShape, theMinDeg, theMaxDeg, theTol2D, theTol3D, theNbIter);
+  GEOM::GEOM_Object_ptr anObj = my3DPrimOp->MakeFilling(theShape, theMinDeg, theMaxDeg, theTol2D, theTol3D, theNbIter, theApprox);
   endService( " GEOM_Superv_i::MakeFilling" );
   return anObj;
 }
@@ -1331,6 +1432,23 @@ GEOM::GEOM_Object_ptr GEOM_Superv_i::TranslateVectorCopy (GEOM::GEOM_Object_ptr
   return anObj;
 }
 
+//=============================================================================
+//  TranslateVectorDistance:
+//=============================================================================
+GEOM::GEOM_Object_ptr GEOM_Superv_i::TranslateVectorDistance (GEOM::GEOM_Object_ptr theObject,
+                                                             GEOM::GEOM_Object_ptr theVector,
+                                                             CORBA::Double theDistance,
+                                                             CORBA::Boolean theCopy)
+{
+  beginService( " GEOM_Superv_i::TranslateVectorDistance" );
+  MESSAGE("GEOM_Superv_i::TranslateVectorDistance");
+  getTransfOp();
+  GEOM::GEOM_Object_ptr anObj = myTransfOp->TranslateVectorDistance(theObject, 
+                                                                   theVector, theDistance, theCopy);
+  endService( " GEOM_Superv_i::TranslateVectorDistance" );
+  return anObj;
+}
+
 //=============================================================================
 //  MultiTranslate1D:
 //=============================================================================
@@ -1603,6 +1721,42 @@ GEOM::GEOM_Object_ptr GEOM_Superv_i::ScaleShapeCopy (GEOM::GEOM_Object_ptr theOb
   return anObj;
 }
 
+//=============================================================================
+//  ScaleShapeAlongAxes:
+//=============================================================================
+GEOM::GEOM_Object_ptr GEOM_Superv_i::ScaleShapeAlongAxes (GEOM::GEOM_Object_ptr theObject,
+                                                         GEOM::GEOM_Object_ptr thePoint,
+                                                         CORBA::Double theFactorX,
+                                                         CORBA::Double theFactorY,
+                                                         CORBA::Double theFactorZ)
+{
+  beginService( " GEOM_Superv_i::ScaleShapeAlongAxes" );
+  MESSAGE("GEOM_Superv_i::ScaleShapeAlongAxes");
+  getTransfOp();
+  GEOM::GEOM_Object_ptr anObj = myTransfOp->ScaleShapeAlongAxes
+    (theObject, thePoint, theFactorX, theFactorY, theFactorZ);
+  endService( " GEOM_Superv_i::ScaleShapeAlongAxes" );
+  return anObj;
+}
+
+//=============================================================================
+//  ScaleShapeAlongAxesCopy:
+//=============================================================================
+GEOM::GEOM_Object_ptr GEOM_Superv_i::ScaleShapeAlongAxesCopy (GEOM::GEOM_Object_ptr theObject,
+                                                             GEOM::GEOM_Object_ptr thePoint,
+                                                             CORBA::Double theFactorX,
+                                                             CORBA::Double theFactorY,
+                                                             CORBA::Double theFactorZ)
+{
+  beginService( " GEOM_Superv_i::ScaleShapeAlongAxesCopy" );
+  MESSAGE("GEOM_Superv_i::ScaleShapeAlongAxesCopy");
+  getTransfOp();
+  GEOM::GEOM_Object_ptr anObj = myTransfOp->ScaleShapeAlongAxesCopy
+    (theObject, thePoint, theFactorX, theFactorY, theFactorZ);
+  endService( " GEOM_Superv_i::ScaleShapeAlongAxesCopy" );
+  return anObj;
+}
+
 //=============================================================================
 //  PositionShape:
 //=============================================================================
@@ -1859,6 +2013,7 @@ CORBA::Long GEOM_Superv_i::NumberOfEdges (GEOM::GEOM_Object_ptr theShape)
   return aRes;
 }
 
+
 //=============================================================================
 //  ChangeOrientation:
 //=============================================================================
@@ -1873,6 +2028,46 @@ GEOM::GEOM_Object_ptr GEOM_Superv_i::ChangeOrientation (GEOM::GEOM_Object_ptr th
 }
 
 
+//=============================================================================
+//  GetShapesOnShape:
+//=============================================================================
+GEOM::GEOM_List_ptr GEOM_Superv_i::GetShapesOnShape
+                                          (GEOM::GEOM_Object_ptr theCheckShape,
+                                          GEOM::GEOM_Object_ptr theShape,
+                                          CORBA::Short theShapeType,
+                                          GEOM::shape_state theState)
+{
+  beginService( " GEOM_Superv_i::GetShapesOnShape" );
+  MESSAGE("GEOM_Superv_i::GetShapesOnShape");
+  getShapesOp();
+  GEOM::ListOfGO* aList =
+    myShapesOp->GetShapesOnShape(theCheckShape, theShape, theShapeType, theState);
+  GEOM_List_i<GEOM::ListOfGO>* aListPtr = new GEOM_List_i<GEOM::ListOfGO>(*(aList));
+  MESSAGE(" List of "<<aListPtr->GetList().length()<<" element(s)");
+  endService( " GEOM_Superv_i::GetShapesOnShape" );
+  return aListPtr->_this();
+}
+
+
+//=============================================================================
+//  GetShapesOnShapeAsCompound:
+//=============================================================================
+GEOM::GEOM_Object_ptr GEOM_Superv_i::GetShapesOnShapeAsCompound
+                                          (GEOM::GEOM_Object_ptr theCheckShape,
+                                          GEOM::GEOM_Object_ptr theShape,
+                                          CORBA::Short theShapeType,
+                                          GEOM::shape_state theState)
+{
+  beginService( " GEOM_Superv_i::GetShapesOnShapeAsCompound" );
+  MESSAGE("GEOM_Superv_i::GetShapesOnShapeAsCompound");
+  getShapesOp();
+  GEOM::GEOM_Object_ptr anObj = 
+    myShapesOp->GetShapesOnShapeAsCompound(theCheckShape, theShape, theShapeType, theState);
+  endService( " GEOM_Superv_i::GetShapesOnShapeAsCompound" );
+  return anObj;
+}
+
+
 //=============================== BlocksOperations ============================
 //=============================================================================
 //  MakeQuad4Vertices:
@@ -2737,7 +2932,8 @@ extern "C"
                                                      const char * interfaceName)
   {
     GEOM_Superv_i * myGEOM_Superv_i = new GEOM_Superv_i(orb, poa, contId, instanceName, interfaceName);
-    myGEOM_Superv_i->register_name("/myGEOM_Superv");
+    //Don't understand the reason why this component is registered ???
+//    myGEOM_Superv_i->register_name("/myGEOM_Superv");
     return myGEOM_Superv_i->getId() ;
   }
 }