Salome HOME
NPAL16559: EDF507: Implementation of a more advanced system of measurement.
[modules/geom.git] / src / GEOM_I / GEOM_IMeasureOperations_i.cc
index 9b763dfaf53a0a967084d583a3742bddfc947236..7be30405664d6ece01d23a17357ef47f0f4e8596 100644 (file)
@@ -17,6 +17,7 @@
 //
 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
 //
+
 #include <Standard_Stream.hxx>
 
 #include "GEOM_IMeasureOperations_i.hh"
@@ -50,6 +51,52 @@ GEOM_IMeasureOperations_i::~GEOM_IMeasureOperations_i()
   MESSAGE("GEOM_IMeasureOperations_i::~GEOM_IMeasureOperations_i");
 }
 
+//=============================================================================
+/*!
+ *  KindOfShape
+ */
+//=============================================================================
+GEOM::GEOM_IKindOfShape::shape_kind GEOM_IMeasureOperations_i::KindOfShape
+                                   (GEOM::GEOM_Object_ptr  theShape,
+                                   GEOM::ListOfLong_out   theIntegers,
+                                   GEOM::ListOfDouble_out theDoubles)
+{
+  GEOMImpl_IMeasureOperations::ShapeKind aKind = GEOMImpl_IMeasureOperations::SK_NO_SHAPE;
+
+  // allocate the CORBA arrays
+  GEOM::ListOfLong_var anIntegersArray = new GEOM::ListOfLong();
+  GEOM::ListOfDouble_var aDoublesArray = new GEOM::ListOfDouble();
+
+  //Get the reference shape
+  Handle(GEOM_Object) aShape = GetOperations()->GetEngine()->GetObject
+    (theShape->GetStudyID(), theShape->GetEntry());
+
+  if (!aShape.IsNull()) {
+    Handle(TColStd_HSequenceOfInteger) anIntegers = new TColStd_HSequenceOfInteger;
+    Handle(TColStd_HSequenceOfReal)    aDoubles   = new TColStd_HSequenceOfReal;
+
+    // Detect kind of shape and parameters
+    aKind = GetOperations()->KindOfShape(aShape, anIntegers, aDoubles);
+
+    int nbInts = anIntegers->Length();
+    int nbDbls = aDoubles->Length();
+
+    anIntegersArray->length(nbInts);
+    aDoublesArray->length(nbDbls);
+
+    for (int ii = 0; ii < nbInts; ii++) {
+      anIntegersArray[ii] = anIntegers->Value(ii + 1);
+    }
+    for (int id = 0; id < nbDbls; id++) {
+      aDoublesArray[id] = aDoubles->Value(id + 1);
+    }
+  }
+
+  // initialize out-parameters with local arrays
+  theIntegers = anIntegersArray._retn();
+  theDoubles  = aDoublesArray._retn();
+  return (GEOM::GEOM_IKindOfShape::shape_kind)aKind;
+}
 
 //=============================================================================
 /*!
@@ -346,8 +393,8 @@ CORBA::Double GEOM_IMeasureOperations_i::GetMinDistance
  *  PointCoordinates
  */
 //=============================================================================
-void GEOM_IMeasureOperations_i::PointCoordinates(
-  GEOM::GEOM_Object_ptr theShape, CORBA::Double& X, CORBA::Double& Y, CORBA::Double& Z )
+void GEOM_IMeasureOperations_i::PointCoordinates (GEOM::GEOM_Object_ptr theShape,
+                                                 CORBA::Double& X, CORBA::Double& Y, CORBA::Double& Z)
 
 {
   //Set a not done flag
@@ -366,3 +413,28 @@ void GEOM_IMeasureOperations_i::PointCoordinates(
   // Get shape parameters
   GetOperations()->PointCoordinates( aShape, X, Y, Z );
 }
+
+//=============================================================================
+/*!
+ *  GetAngle
+ */
+//=============================================================================
+CORBA::Double GEOM_IMeasureOperations_i::GetAngle (GEOM::GEOM_Object_ptr theShape1,
+                                                  GEOM::GEOM_Object_ptr theShape2)
+{
+  //Set a not done flag
+  GetOperations()->SetNotDone();
+
+  if (theShape1 == NULL || theShape2 == NULL) return -1.0;
+
+  //Get the reference shapes
+  Handle(GEOM_Object) aShape1 = GetOperations()->GetEngine()->GetObject
+    (theShape1->GetStudyID(), theShape1->GetEntry());
+  Handle(GEOM_Object) aShape2 = GetOperations()->GetEngine()->GetObject
+    (theShape2->GetStudyID(), theShape2->GetEntry());
+
+  if (aShape1.IsNull() || aShape2.IsNull()) return -1.0;
+
+  // Get the angle
+  return GetOperations()->GetAngle(aShape1, aShape2);
+}