Salome HOME
Implemented [bos #35094] [EDF] (2023-T1) X,Y,Z to U,V.
[modules/geom.git] / src / GEOM_I / GEOM_IMeasureOperations_i.cc
index e829aceabec2103f9a95aacade55111c6424349b..a740731b4b648c22badcb4e0f6115774649c1274 100644 (file)
@@ -21,6 +21,7 @@
 //
 
 #include <Standard_Stream.hxx>
+#include <TColStd_HArray1OfReal.hxx>
 
 #include "GEOM_IMeasureOperations_i.hh"
 
@@ -1244,6 +1245,92 @@ GEOM::GEOM_Object_ptr GEOM_IMeasureOperations_i::SurfaceCurvatureByPointAndDirec
   return GetObject(anObject);
 }
 
+//=============================================================================
+/*!
+ *  XYZtoUV
+ */
+//=============================================================================
+GEOM::ListOfDouble* GEOM_IMeasureOperations_i::XYZtoUV
+                                        (GEOM::GEOM_Object_ptr     theSurf,
+                                         const GEOM::ListOfDouble& theXYZlist,
+                                         CORBA::Boolean            theIsNormalized)
+{
+  GEOM::ListOfDouble_var resUV = new GEOM::ListOfDouble;
+
+  //Set a not done flag
+  GetOperations()->SetNotDone();
+
+  //Get the reference shape
+  Handle(::GEOM_Object) aShape = GetObjectImpl(theSurf);
+  if (aShape.IsNull()) return resUV._retn();
+
+  //Get input XYZ list
+  Handle(TColStd_HArray1OfReal) aXYZlist =
+    new TColStd_HArray1OfReal (0, theXYZlist.length() - 1);
+  {
+    size_t nb = theXYZlist.length(); 
+    for (size_t i = 0; i < nb; ++i)
+      aXYZlist->SetValue(i, theXYZlist[i]);
+  }
+
+  //Call implementation
+  Handle(TColStd_HArray1OfReal) aUVlist =
+    GetOperations()->XYZtoUV(aShape, aXYZlist, theIsNormalized);
+
+  if (GetOperations()->IsDone()) {
+    resUV->length(aUVlist->Length());
+    int i0 = aUVlist->Lower();
+    int nb = aUVlist->Upper(); 
+    for (int i = i0; i <= nb; ++i)
+      resUV[ i-i0 ] = aUVlist->Value(i);
+  }
+
+  return resUV._retn();
+}
+
+//=============================================================================
+/*!
+ *  UVtoXYZ
+ */
+//=============================================================================
+GEOM::ListOfDouble* GEOM_IMeasureOperations_i::UVtoXYZ
+                                        (GEOM::GEOM_Object_ptr     theSurf,
+                                         const GEOM::ListOfDouble& theUVlist,
+                                         CORBA::Boolean            theIsNormalized)
+{
+  GEOM::ListOfDouble_var resXYZ = new GEOM::ListOfDouble;
+
+  //Set a not done flag
+  GetOperations()->SetNotDone();
+
+  //Get the reference shape
+  Handle(::GEOM_Object) aShape = GetObjectImpl(theSurf);
+  if (aShape.IsNull()) return resXYZ._retn();
+
+  //Get input UV list
+  Handle(TColStd_HArray1OfReal) aUVlist =
+    new TColStd_HArray1OfReal (0, theUVlist.length() - 1);
+  {
+    size_t nb = theUVlist.length(); 
+    for (size_t i = 0; i < nb; ++i)
+      aUVlist->SetValue(i, theUVlist[i]);
+  }
+
+  //Call implementation
+  Handle(TColStd_HArray1OfReal) aXYZlist =
+    GetOperations()->UVtoXYZ(aShape, aUVlist, theIsNormalized);
+
+  if (GetOperations()->IsDone()) {
+    resXYZ->length(aXYZlist->Length());
+    int i0 = aXYZlist->Lower();
+    int nb = aXYZlist->Upper(); 
+    for (int i = i0; i <= nb; ++i)
+      resXYZ[ i-i0 ] = aXYZlist->Value(i);
+  }
+
+  return resXYZ._retn();
+}
+
 //=============================================================================
 /*!
  *  SelfIntersected2D