Salome HOME
Changes for modifying of GeomData objects by GeomAPI objects
authorazv <azv@opencascade.com>
Fri, 30 May 2014 11:57:32 +0000 (15:57 +0400)
committerazv <azv@opencascade.com>
Fri, 30 May 2014 11:57:32 +0000 (15:57 +0400)
18 files changed:
src/GeomAPI/CMakeLists.txt
src/GeomAPI/GeomAPI_Dir.cpp
src/GeomAPI/GeomAPI_Dir.h
src/GeomAPI/GeomAPI_Pnt2d.cpp
src/GeomAPI/GeomAPI_Pnt2d.h
src/GeomAPI/GeomAPI_XY.cpp [new file with mode: 0644]
src/GeomAPI/GeomAPI_XY.h [new file with mode: 0644]
src/GeomAPI/GeomAPI_XYZ.cpp
src/GeomAPI/GeomAPI_XYZ.h
src/GeomData/GeomData_Dir.cpp
src/GeomData/GeomData_Dir.h
src/GeomData/GeomData_Point.cpp
src/GeomData/GeomData_Point.h
src/GeomData/GeomData_Point2D.cpp
src/GeomData/GeomData_Point2D.h
src/GeomDataAPI/GeomDataAPI_Dir.h
src/GeomDataAPI/GeomDataAPI_Point.h
src/GeomDataAPI/GeomDataAPI_Point2D.h

index cf21d319f0efbac8e85a7886ae2655c29c50daa2..ad741d302d83c67fe65adae20fc93ff949e96e45 100644 (file)
@@ -7,6 +7,7 @@ INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR})
 SET(PROJECT_HEADERS
     GeomAPI.h
     GeomAPI_Interface.h
+    GeomAPI_XY.h
     GeomAPI_XYZ.h
     GeomAPI_Pnt.h
     GeomAPI_Pnt2d.h
@@ -19,6 +20,7 @@ SET(PROJECT_HEADERS
 
 SET(PROJECT_SOURCES
     GeomAPI_Interface.cpp
+    GeomAPI_XY.cpp
     GeomAPI_XYZ.cpp
     GeomAPI_Pnt.cpp
     GeomAPI_Pnt2d.cpp
index c3ad12fb97a2421cee00f8ce53f44045cfbd1146..abe357b2bfc17e033ddd4af1644aa204ed3b3c5c 100644 (file)
@@ -36,3 +36,8 @@ const boost::shared_ptr<GeomAPI_XYZ> GeomAPI_Dir::xyz()
 {
   return boost::shared_ptr<GeomAPI_XYZ>(new GeomAPI_XYZ(MY_DIR->X(), MY_DIR->Y(), MY_DIR->Z()));
 }
+
+double GeomAPI_Dir::dot(const boost::shared_ptr<GeomAPI_Dir>& theArg) const
+{
+  return MY_DIR->Dot(theArg->impl<gp_Dir>());
+}
index a8b4022cea38af190a50f745a09adce9ca972432..6ab0f1dd2baced7076eff6b372d6d477e4f1ca49 100644 (file)
@@ -32,6 +32,9 @@ public:
 
   /// returns coordinates of the direction
   const boost::shared_ptr<GeomAPI_XYZ> xyz();
+
+  /// result is a scalar product of directions
+  double dot(const boost::shared_ptr<GeomAPI_Dir>& theArg) const;
 };
 
 #endif
index f1cbb8e22d4d7c7b8a36f78a5822831dc8973496..1b4ee554bfb82bde1c9bdc1338b246635bbe2489 100644 (file)
@@ -3,7 +3,7 @@
 // Author:      Artem ZHIDKOV
 
 #include<GeomAPI_Pnt2d.h>
-#include<GeomAPI_XYZ.h>
+#include<GeomAPI_XY.h>
 
 #include<gp_Pnt2d.hxx>
 
@@ -13,6 +13,10 @@ GeomAPI_Pnt2d::GeomAPI_Pnt2d(const double theX, const double theY)
   : GeomAPI_Interface(new gp_Pnt2d(theX, theY))
 {}
 
+GeomAPI_Pnt2d::GeomAPI_Pnt2d(const boost::shared_ptr<GeomAPI_XY>& theCoords)
+  : GeomAPI_Interface(new gp_Pnt2d(theCoords->x(), theCoords->y()))
+{}
+
 double GeomAPI_Pnt2d::x() const
 {
   return MY_PNT2D->X();
@@ -33,6 +37,11 @@ void GeomAPI_Pnt2d::setY(const double theY)
   return MY_PNT2D->SetY(theY);
 }
 
+const boost::shared_ptr<GeomAPI_XY> GeomAPI_Pnt2d::xy()
+{
+  return boost::shared_ptr<GeomAPI_XY>(new GeomAPI_XY(MY_PNT2D->X(), MY_PNT2D->Y()));
+}
+
 double GeomAPI_Pnt2d::distance(const boost::shared_ptr<GeomAPI_Pnt2d>& theOther) const
 {
   return MY_PNT2D->Distance(theOther->impl<gp_Pnt2d>());
index 097e8786ea144dc232309a3eae42fa769e2f18d6..a1faf626c561b1e5df015cb502575af70cbab1c4 100644 (file)
@@ -8,7 +8,7 @@
 #include <GeomAPI_Interface.h>
 #include <boost/shared_ptr.hpp>
 
-class GeomAPI_XYZ;
+class GeomAPI_XY;
 
 /**\class GeomAPI_Pnt2d
  * \ingroup DataModel
@@ -20,6 +20,8 @@ class GEOMAPI_EXPORT GeomAPI_Pnt2d: public GeomAPI_Interface
 public:
   /// Creation of point by coordinates
   GeomAPI_Pnt2d(const double theX, const double theY);
+  /// Creation of point by coordinates
+  GeomAPI_Pnt2d(const boost::shared_ptr<GeomAPI_XY>& theCoords);
 
   /// returns X coordinate
   double x() const;
@@ -31,6 +33,9 @@ public:
   /// sets Y coordinate
   void setY(const double theY);
 
+  /// returns coordinates of the point
+  const boost::shared_ptr<GeomAPI_XY> xy();
+
   /// Distance between two points
   double distance(const boost::shared_ptr<GeomAPI_Pnt2d>& theOther) const;
 };
diff --git a/src/GeomAPI/GeomAPI_XY.cpp b/src/GeomAPI/GeomAPI_XY.cpp
new file mode 100644 (file)
index 0000000..94341c3
--- /dev/null
@@ -0,0 +1,65 @@
+// File:        GeomAPI_XY.cpp
+// Created:     30 May 2014
+// Author:      Artem ZHIDKOV
+
+#include<GeomAPI_XY.h>
+
+#include<gp_XY.hxx>
+
+#define MY_XY static_cast<gp_XY*>(myImpl)
+
+GeomAPI_XY::GeomAPI_XY(const double theX, const double theY)
+  : GeomAPI_Interface(new gp_XY(theX, theY))
+{}
+
+double GeomAPI_XY::x() const
+{
+  return MY_XY->X();
+}
+
+double GeomAPI_XY::y() const
+{
+  return MY_XY->Y();
+}
+
+void GeomAPI_XY::setX(const double theX)
+{
+  return MY_XY->SetX(theX);
+}
+
+void GeomAPI_XY::setY(const double theY)
+{
+  return MY_XY->SetY(theY);
+}
+
+const boost::shared_ptr<GeomAPI_XY> GeomAPI_XY::added(
+  const boost::shared_ptr<GeomAPI_XY>& theArg)
+{
+  boost::shared_ptr<GeomAPI_XY> aResult(
+    new GeomAPI_XY(MY_XY->X() + theArg->x(), MY_XY->Y() + theArg->y()));
+  return aResult;
+}
+
+const boost::shared_ptr<GeomAPI_XY> GeomAPI_XY::multiplied(const double theArg)
+{
+  boost::shared_ptr<GeomAPI_XY> aResult(
+    new GeomAPI_XY(MY_XY->X() * theArg, MY_XY->Y() * theArg));
+  return aResult;
+}
+
+double GeomAPI_XY::dot(const boost::shared_ptr<GeomAPI_XY>& theArg) const
+{
+  return MY_XY->Dot(theArg->impl<gp_XY>());
+}
+
+double GeomAPI_XY::cross(const boost::shared_ptr<GeomAPI_XY>& theArg) const
+{
+  return MY_XY->Crossed(theArg->impl<gp_XY>());
+}
+
+double GeomAPI_XY::distance(const boost::shared_ptr<GeomAPI_XY>& theOther) const
+{
+  gp_XY aResult(theOther->x() - x(), theOther->y() - y());
+  return aResult.Modulus();
+}
+
diff --git a/src/GeomAPI/GeomAPI_XY.h b/src/GeomAPI/GeomAPI_XY.h
new file mode 100644 (file)
index 0000000..0f0187a
--- /dev/null
@@ -0,0 +1,47 @@
+// File:        GeomAPI_XY.hxx
+// Created:     30 May 2014
+// Author:      Artem ZHIDKOV
+
+#ifndef GeomAPI_XY_HeaderFile
+#define GeomAPI_XY_HeaderFile
+
+#include <GeomAPI_Interface.h>
+#include <boost/shared_ptr.hpp>
+
+/**\class GeomAPI_XY
+ * \ingroup DataModel
+ * \brief 2 coordinates: they may represent vector or point or something else
+ */
+
+class GEOMAPI_EXPORT GeomAPI_XY: public GeomAPI_Interface
+{
+public:
+  /// Creation by coordinates
+  GeomAPI_XY(const double theX, const double theY);
+
+  /// returns X coordinate
+  double x() const;
+  /// returns Y coordinate
+  double y() const;
+
+  /// sets X coordinate
+  void setX(const double theX);
+  /// sets Y coordinate
+  void setY(const double theY);
+
+  /// result is sum of coordinates of this and the given argument
+  const boost::shared_ptr<GeomAPI_XY> added(const boost::shared_ptr<GeomAPI_XY>& theArg);
+  /// result is coordinates multiplied by the argument
+  const boost::shared_ptr<GeomAPI_XY> multiplied(const double theArg);
+
+  /// result is a scalar product of two triplets
+  double dot(const boost::shared_ptr<GeomAPI_XY>& theArg) const;
+  /// result is a cross product of two triplets
+  double cross(const boost::shared_ptr<GeomAPI_XY>& theArg) const;
+
+  /// Distance between two pairs
+  double distance(const boost::shared_ptr<GeomAPI_XY>& theOther) const;
+};
+
+#endif
+
index 3cc18eeb166de29e93f99f67f330ef3928eaf620..f413005fd0aebc80ab6744fef5787a82920b4a85 100644 (file)
@@ -50,6 +50,14 @@ const boost::shared_ptr<GeomAPI_XYZ> GeomAPI_XYZ::added(
   return aResult;
 }
 
+const boost::shared_ptr<GeomAPI_XYZ> GeomAPI_XYZ::decreased(
+  const boost::shared_ptr<GeomAPI_XYZ>& theArg)
+{
+  boost::shared_ptr<GeomAPI_XYZ> aResult(new GeomAPI_XYZ(MY_XYZ->X() - theArg->x(),
+    MY_XYZ->Y() - theArg->y(), MY_XYZ->Z() - theArg->z()));
+  return aResult;
+}
+
 const boost::shared_ptr<GeomAPI_XYZ> GeomAPI_XYZ::multiplied(const double theArg)
 {
   boost::shared_ptr<GeomAPI_XYZ> aResult(new GeomAPI_XYZ(MY_XYZ->X() * theArg,
index 85c60779ef8cb7fa3cbd9168973e1d81c7394cde..ffcaa9d8675e97f9c0cab0502a45ff46b44b0ecb 100644 (file)
@@ -35,6 +35,8 @@ public:
 
   /// result is sum of coordinates of this and the given argument
   const boost::shared_ptr<GeomAPI_XYZ> added(const boost::shared_ptr<GeomAPI_XYZ>& theArg);
+  /// result is difference between coordinates of this and the given argument
+  const boost::shared_ptr<GeomAPI_XYZ> decreased(const boost::shared_ptr<GeomAPI_XYZ>& theArg);
   /// result is coordinates multiplied by the argument
   const boost::shared_ptr<GeomAPI_XYZ> multiplied(const double theArg);
 
index 070e94562ff56705f0276b3baf85fec704454e78..44f04fe307900b6867a4bba70a6d7bd480b7c984 100644 (file)
@@ -22,6 +22,11 @@ void GeomData_Dir::setValue(const double theX, const double theY, const double t
   }
 }
 
+void GeomData_Dir::setValue(const boost::shared_ptr<GeomAPI_Dir>& theDir)
+{
+  setValue(theDir->x(), theDir->y(), theDir->z());
+}
+
 double GeomData_Dir::x() const
 {
   return myCoords->Value(0);
index a7c1a2497363120d9a90bbba4820f844910f60ea..1b6dd6c64bf9090060cc596fcd69533c6bc204df 100644 (file)
@@ -23,6 +23,8 @@ class GeomData_Dir : public GeomDataAPI_Dir
 public:
   /// Defines the double value
   GEOMDATA_EXPORT virtual void setValue(const double theX, const double theY, const double theZ);
+  /// Defines the direction
+  GEOMDATA_EXPORT virtual void setValue(const boost::shared_ptr<GeomAPI_Dir>& theDir);
 
   /// Returns the X double value
   GEOMDATA_EXPORT virtual double x() const;
index 6ad2ac56479b99942b5c4c2ac55be0947aedb3a9..da6299703174b694c2d95b179b905a738c2dfc23 100644 (file)
@@ -21,6 +21,11 @@ void GeomData_Point::setValue(const double theX, const double theY, const double
   }
 }
 
+void GeomData_Point::setValue(const boost::shared_ptr<GeomAPI_Pnt>& thePoint)
+{
+  setValue(thePoint->x(), thePoint->y(), thePoint->z());
+}
+
 double GeomData_Point::x() const
 {
   return myCoords->Value(0);
index ee319e89e53ad505005fac78e7eed5cd396af140..116039cf196daad35fe7e6e5aa6cfe3130bc79a5 100644 (file)
@@ -21,6 +21,8 @@ class GeomData_Point : public GeomDataAPI_Point
 public:
   /// Defines the double value
   GEOMDATA_EXPORT virtual void setValue(const double theX, const double theY, const double theZ);
+  /// Defines the point
+  GEOMDATA_EXPORT virtual void setValue(const boost::shared_ptr<GeomAPI_Pnt>& thePoint);
 
   /// Returns the X double value
   GEOMDATA_EXPORT virtual double x() const;
index 8af702953a020f407e2360e2b054f1ec87f60820..334d2070a320b1c19d0f9cf73450d143eca4f868 100644 (file)
@@ -5,6 +5,7 @@
 #include "GeomData_Point2D.h"
 #include "Model_Events.h"
 #include <Events_Loop.h>
+#include <GeomAPI_Pnt2d.h>
 
 using namespace std;
 
@@ -19,6 +20,11 @@ void GeomData_Point2D::setValue(const double theX, const double theY)
   }
 }
 
+void GeomData_Point2D::setValue(const boost::shared_ptr<GeomAPI_Pnt2d>& thePoint)
+{
+  setValue(thePoint->x(), thePoint->y());
+}
+
 double GeomData_Point2D::x() const
 {
   return myCoords->Value(0);
@@ -29,6 +35,13 @@ double GeomData_Point2D::y() const
   return myCoords->Value(1);
 }
 
+boost::shared_ptr<GeomAPI_Pnt2d> GeomData_Point2D::pnt()
+{
+  boost::shared_ptr<GeomAPI_Pnt2d> aResult(
+    new GeomAPI_Pnt2d(myCoords->Value(0), myCoords->Value(1)));
+  return aResult;
+}
+
 GeomData_Point2D::GeomData_Point2D(TDF_Label& theLabel)
 {
   // check the attribute could be already presented in this doc (after load document)
index 4b3d4671c43dcf0c85d70f82669a25aa3e153da1..8e3c124b3d45515ee57177707277c7035bf38d25 100644 (file)
@@ -21,11 +21,15 @@ class GeomData_Point2D : public GeomDataAPI_Point2D
 public:
   /// Defines the double value
   GEOMDATA_EXPORT virtual void setValue(const double theX, const double theY);
+  /// Defines the point
+  GEOMDATA_EXPORT virtual void setValue(const boost::shared_ptr<GeomAPI_Pnt2d>& thePoint);
 
   /// Returns the X double value
   GEOMDATA_EXPORT virtual double x() const;
   /// Returns the Y double value
   GEOMDATA_EXPORT virtual double y() const;
+  /// Returns the 2D point
+  GEOMDATA_EXPORT virtual boost::shared_ptr<GeomAPI_Pnt2d> pnt();
 
 protected:
   /// Initializes attributes
index dbe8ef5e26f0a2c5d6f3d1e4d1648e1c0c4d2c96..a25c9faaf976137abbf605eda322fe2c7379576a 100644 (file)
@@ -20,6 +20,8 @@ class GeomDataAPI_Dir : public ModelAPI_Attribute
 public:
   /// Defines the double value
   virtual void setValue(const double theX, const double theY, const double theZ) = 0;
+  /// Defines the direction
+  virtual void setValue(const boost::shared_ptr<GeomAPI_Dir>& theDir) = 0;
 
   /// Returns the X double value
   virtual double x() const = 0;
index c9581b2bea7fd6ff38aecada82a7cf5cbeff58a8..5f08bde0264495703c61458ffacf5002b7aff05f 100644 (file)
@@ -20,6 +20,8 @@ class GeomDataAPI_Point : public ModelAPI_Attribute
 public:
   /// Defines the double value
   virtual void setValue(const double theX, const double theY, const double theZ) = 0;
+  /// Defines the point
+  virtual void setValue(const boost::shared_ptr<GeomAPI_Pnt>& thePoint) = 0;
 
   /// Returns the X double value
   virtual double x() const = 0;
index bfc8094c2c121a7ca803ab869edc0b04373448b0..f5eb429382bffd9528137114adb9ed7b70938345 100644 (file)
@@ -8,6 +8,8 @@
 #include "GeomDataAPI.h"
 #include <ModelAPI_Attribute.h>
 
+class GeomAPI_Pnt2d;
+
 /**\class GeomDataAPI_Point2D
  * \ingroup DataModel
  * \brief Attribute that contains 2D point coordinates.
@@ -18,11 +20,15 @@ class GeomDataAPI_Point2D : public ModelAPI_Attribute
 public:
   /// Defines the double value
   virtual void setValue(const double theX, const double theY) = 0;
+  /// Defines the point
+  virtual void setValue(const boost::shared_ptr<GeomAPI_Pnt2d>& thePoint) = 0;
 
   /// Returns the X double value
   virtual double x() const = 0;
   /// Returns the Y double value
   virtual double y() const = 0;
+  /// Returns the 2D point
+  virtual boost::shared_ptr<GeomAPI_Pnt2d> pnt() = 0;
 
   /// Returns the type of this class of attributes
   static inline std::string type() {return std::string("Point2D");}