]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Remove DirY from Sketch attributes
authorazv <azv@opencascade.com>
Tue, 24 Mar 2015 11:26:30 +0000 (14:26 +0300)
committerazv <azv@opencascade.com>
Tue, 24 Mar 2015 11:26:30 +0000 (14:26 +0300)
13 files changed:
src/GeomAPI/GeomAPI_Ax3.cpp
src/GeomAPI/GeomAPI_Ax3.h
src/GeomAPI/GeomAPI_PlanarEdges.cpp
src/GeomAPI/GeomAPI_PlanarEdges.h
src/GeomData/GeomData_Dir.cpp
src/GeomData/GeomData_Dir.h
src/GeomDataAPI/GeomDataAPI_Dir.h
src/PartSet/PartSet_Tools.cpp
src/PartSet/PartSet_WidgetSketchLabel.cpp
src/SketchPlugin/SketchPlugin_Sketch.cpp
src/SketchPlugin/SketchPlugin_Sketch.h
src/SketchSolver/SketchSolver_ConstraintGroup.cpp
src/SketchSolver/SketchSolver_ConstraintGroup.h

index d7950b585126717c0e96d409e92ceb1a7d877d5c..892869a4c9a7f4593af69285648478443bb49e07 100644 (file)
@@ -25,13 +25,11 @@ GeomAPI_Ax3::GeomAPI_Ax3()
 
 GeomAPI_Ax3::GeomAPI_Ax3(std::shared_ptr<GeomAPI_Pnt> theOrigin,
                          std::shared_ptr<GeomAPI_Dir> theDirX,
-                         std::shared_ptr<GeomAPI_Dir> theDirY,
                          std::shared_ptr<GeomAPI_Dir> theNorm)
 : GeomAPI_Interface(new gp_Ax3(theOrigin->impl<gp_Pnt>(), 
                                theNorm->impl<gp_Dir>(), 
                                theDirX->impl<gp_Dir>()))
  {
-   MY_AX3->SetYDirection(theDirY->impl<gp_Dir>());
  }
 
 void GeomAPI_Ax3::setOrigin(const std::shared_ptr<GeomAPI_Pnt>& theOrigin)
index 67bde43efd50a2b1e331ffe33202901c295e5df9..6a554e2b393b3f2516cd7ed9a368fccb92524bf5 100644 (file)
@@ -29,7 +29,6 @@ public:
   /// \param theNorm direction of normal vector
   GeomAPI_Ax3(std::shared_ptr<GeomAPI_Pnt> theOrigin,
               std::shared_ptr<GeomAPI_Dir> theDirX,
-              std::shared_ptr<GeomAPI_Dir> theDirY,
               std::shared_ptr<GeomAPI_Dir> theNorm);
 
   /// Sets origin point
index f7757cf7e94b7b32a3ad5f0a23067ece92cd4381..619716256d1b81865122b9a0122b880216a5c1b8 100644 (file)
@@ -93,8 +93,7 @@ std::shared_ptr<GeomAPI_Dir> GeomAPI_PlanarEdges::norm() const
 
 void GeomAPI_PlanarEdges::setPlane(const std::shared_ptr<GeomAPI_Pnt>& theOrigin,
                                    const std::shared_ptr<GeomAPI_Dir>& theDirX,
-                                   const std::shared_ptr<GeomAPI_Dir>& theDirY,
                                    const std::shared_ptr<GeomAPI_Dir>& theNorm)
 {
-  myPlane = std::shared_ptr<GeomAPI_Ax3>(new GeomAPI_Ax3(theOrigin, theDirX, theDirY, theNorm));
+  myPlane = std::shared_ptr<GeomAPI_Ax3>(new GeomAPI_Ax3(theOrigin, theDirX, theNorm));
 }
\ No newline at end of file
index 1eddd16c899ca9bb59c39d39eb34a33eafe47820..c26ad2505e180e386ff739d3852b85012581ab52 100644 (file)
@@ -61,7 +61,6 @@ class GeomAPI_PlanarEdges : public GeomAPI_Shape
   /// \param theNorm normal direction of the plane axis
   GEOMAPI_EXPORT void setPlane(const std::shared_ptr<GeomAPI_Pnt>& theOrigin,
                                const std::shared_ptr<GeomAPI_Dir>& theDirX,
-                               const std::shared_ptr<GeomAPI_Dir>& theDirY,
                                const std::shared_ptr<GeomAPI_Dir>& theNorm);
 
 private:
index d36e8a8f5c84685b7b3d6fbc879ee6aa03ca2fa2..d5272dda21f432786c2ca04ff8e983b99a7a5108 100644 (file)
@@ -5,7 +5,8 @@
 // Author:      Mikhail PONIKAROV
 
 #include "GeomData_Dir.h"
-#include "GeomAPI_Dir.h"
+#include <GeomAPI_Dir.h>
+#include <GeomAPI_XYZ.h>
 #include <gp_Dir.hxx>
 #include <ModelAPI_Feature.h>
 #include <ModelAPI_Data.h>
@@ -49,6 +50,12 @@ std::shared_ptr<GeomAPI_Dir> GeomData_Dir::dir()
       new GeomAPI_Dir(myCoords->Value(0), myCoords->Value(1), myCoords->Value(2)));
 }
 
+std::shared_ptr<GeomAPI_XYZ> GeomData_Dir::xyz()
+{
+  return std::shared_ptr<GeomAPI_XYZ>(
+      new GeomAPI_XYZ(myCoords->Value(0), myCoords->Value(1), myCoords->Value(2)));
+}
+
 GeomData_Dir::GeomData_Dir(TDF_Label& theLabel)
 {
   myIsInitialized = theLabel.FindAttribute(TDataStd_RealArray::GetID(), myCoords) == Standard_True;
index 0080ffbc6df16c357a0c95ff11475b592b34b861..debd400552702b68455955f17d775b3f6f97d8ae 100644 (file)
@@ -14,6 +14,7 @@
 #include <memory>
 
 class GeomAPI_Dir;
+class GeomAPI_XYZ;
 
 /**\class GeomData_Dir
  * \ingroup DataModel
@@ -36,6 +37,8 @@ class GeomData_Dir : public GeomDataAPI_Dir
   GEOMDATA_EXPORT virtual double z() const;
   /// Returns the direction of this attribute
   GEOMDATA_EXPORT virtual std::shared_ptr<GeomAPI_Dir> dir();
+  /// Returns the coordinates of this attribute
+  GEOMDATA_EXPORT virtual std::shared_ptr<GeomAPI_XYZ> xyz();
 
  protected:
   /// Initializes attributes
index 968edb2325670112dc8e008c5afb2bb9c383ea1e..85d4b3a8c433706c41f92d0fb9580b719664c364 100644 (file)
@@ -11,6 +11,7 @@
 #include <ModelAPI_Attribute.h>
 
 class GeomAPI_Dir;
+class GeomAPI_XYZ;
 
 /**\class GeomDataAPI_Dir
  * \ingroup DataModel
@@ -33,6 +34,8 @@ class GeomDataAPI_Dir : public ModelAPI_Attribute
   virtual double z() const = 0;
   /// Returns the direction of this attribute
   virtual std::shared_ptr<GeomAPI_Dir> dir() = 0;
+  /// Returns the coordinates of this attribute
+  virtual std::shared_ptr<GeomAPI_XYZ> xyz() = 0;
 
   /// Returns the type of this class of attributes
   static inline std::string type()
index 56f1ac3fc83708bdb32db18c07286b58c225aa4b..f7c4ab57f0c6fde0261324b1410766d0acf8a20b 100644 (file)
@@ -99,8 +99,9 @@ Handle(V3d_View) theView,
 
   std::shared_ptr<GeomDataAPI_Dir> aX = std::dynamic_pointer_cast<GeomDataAPI_Dir>(
       aData->attribute(SketchPlugin_Sketch::DIRX_ID()));
-  std::shared_ptr<GeomDataAPI_Dir> anY = std::dynamic_pointer_cast<GeomDataAPI_Dir>(
-      aData->attribute(SketchPlugin_Sketch::DIRY_ID()));
+  std::shared_ptr<GeomDataAPI_Dir> aNorm = std::dynamic_pointer_cast<GeomDataAPI_Dir>(
+      aData->attribute(SketchPlugin_Sketch::NORM_ID()));
+  std::shared_ptr<GeomAPI_XYZ> anY = aNorm->xyz()->cross(aX->xyz());
 
   gp_Pnt anOriginPnt(anOrigin->x(), anOrigin->y(), anOrigin->z());
   gp_Vec aVec(anOriginPnt, thePoint);
@@ -138,13 +139,14 @@ std::shared_ptr<GeomAPI_Pnt> PartSet_Tools::convertTo3D(const double theX, const
       aData->attribute(SketchPlugin_Sketch::ORIGIN_ID()));
   std::shared_ptr<GeomDataAPI_Dir> aX = std::dynamic_pointer_cast<GeomDataAPI_Dir>(
       aData->attribute(SketchPlugin_Sketch::DIRX_ID()));
-  std::shared_ptr<GeomDataAPI_Dir> aY = std::dynamic_pointer_cast<GeomDataAPI_Dir>(
-      aData->attribute(SketchPlugin_Sketch::DIRY_ID()));
+  std::shared_ptr<GeomDataAPI_Dir> aNorm = std::dynamic_pointer_cast<GeomDataAPI_Dir>(
+      aData->attribute(SketchPlugin_Sketch::NORM_ID()));
+  std::shared_ptr<GeomAPI_Dir> aY(new GeomAPI_Dir(aNorm->dir()->cross(aX->dir())));
 
   std::shared_ptr<GeomAPI_Pnt2d> aPnt2d = 
     std::shared_ptr<GeomAPI_Pnt2d>(new GeomAPI_Pnt2d(theX, theY));
 
-  return aPnt2d->to3D(aC->pnt(), aX->dir(), aY->dir());
+  return aPnt2d->to3D(aC->pnt(), aX->dir(), aY);
 }
 
 ObjectPtr PartSet_Tools::nearestFeature(QPoint thePoint, Handle_V3d_View theView,
@@ -417,14 +419,16 @@ std::shared_ptr<GeomAPI_Pnt> PartSet_Tools::point3D(std::shared_ptr<GeomAPI_Pnt2
   if (!theSketch || !thePoint2D)
     return aPoint;
 
+  DataPtr aData = theSketch->data();
   std::shared_ptr<GeomDataAPI_Point> aC = std::dynamic_pointer_cast<GeomDataAPI_Point>(
-      theSketch->data()->attribute(SketchPlugin_Sketch::ORIGIN_ID()));
+      aData->attribute(SketchPlugin_Sketch::ORIGIN_ID()));
   std::shared_ptr<GeomDataAPI_Dir> aX = std::dynamic_pointer_cast<GeomDataAPI_Dir>(
-      theSketch->data()->attribute(SketchPlugin_Sketch::DIRX_ID()));
-  std::shared_ptr<GeomDataAPI_Dir> aY = std::dynamic_pointer_cast<GeomDataAPI_Dir>(
-      theSketch->data()->attribute(SketchPlugin_Sketch::DIRY_ID()));
+      aData->attribute(SketchPlugin_Sketch::DIRX_ID()));
+  std::shared_ptr<GeomDataAPI_Dir> aNorm = std::dynamic_pointer_cast<GeomDataAPI_Dir>(
+      aData->attribute(SketchPlugin_Sketch::NORM_ID()));
+  std::shared_ptr<GeomAPI_Dir> aY(new GeomAPI_Dir(aNorm->dir()->cross(aX->dir())));
 
-  return thePoint2D->to3D(aC->pnt(), aX->dir(), aY->dir());
+  return thePoint2D->to3D(aC->pnt(), aX->dir(), aY);
 }
 
 ResultPtr PartSet_Tools::createFixedObjectByExternal(const TopoDS_Shape& theShape, 
index 96435f627a95826200c5ed20017793ba04989e46..d47fadecdcdc159462422c6fffc9261e4f09d327 100644 (file)
@@ -287,9 +287,6 @@ std::shared_ptr<GeomAPI_Dir> PartSet_WidgetSketchLabel::setSketchPlane(const Top
   std::shared_ptr<GeomDataAPI_Dir> aDirX = std::dynamic_pointer_cast<GeomDataAPI_Dir>(
       aData->attribute(SketchPlugin_Sketch::DIRX_ID()));
   aDirX->setValue(aXDir);
-  std::shared_ptr<GeomDataAPI_Dir> aDirY = std::dynamic_pointer_cast<GeomDataAPI_Dir>(
-      aData->attribute(SketchPlugin_Sketch::DIRY_ID()));
-  aDirY->setValue(aYDir);
   std::shared_ptr<GeomAPI_Dir> aDir = aPlane->direction();
   return aDir;
 }
index 466024127b2af00ea9d0a95bf4ad70db9b187f26..365db4ca69b59d5d4aca8311afa65980b1aca50a 100644 (file)
@@ -46,7 +46,6 @@ void SketchPlugin_Sketch::initAttributes()
 {
   data()->addAttribute(SketchPlugin_Sketch::ORIGIN_ID(), GeomDataAPI_Point::type());
   data()->addAttribute(SketchPlugin_Sketch::DIRX_ID(), GeomDataAPI_Dir::type());
-  data()->addAttribute(SketchPlugin_Sketch::DIRY_ID(), GeomDataAPI_Dir::type());
   data()->addAttribute(SketchPlugin_Sketch::NORM_ID(), GeomDataAPI_Dir::type());
   data()->addAttribute(SketchPlugin_Sketch::FEATURES_ID(), ModelAPI_AttributeRefList::type());
   // the selected face, base for the sketcher plane, not obligatory
@@ -66,8 +65,6 @@ void SketchPlugin_Sketch::execute()
       data()->attribute(SketchPlugin_Sketch::ORIGIN_ID()));
   std::shared_ptr<GeomDataAPI_Dir> aDirX = std::dynamic_pointer_cast<GeomDataAPI_Dir>(
       data()->attribute(SketchPlugin_Sketch::DIRX_ID()));
-  std::shared_ptr<GeomDataAPI_Dir> aDirY = std::dynamic_pointer_cast<GeomDataAPI_Dir>(
-      data()->attribute(SketchPlugin_Sketch::DIRY_ID()));
   std::shared_ptr<GeomDataAPI_Dir> aNorm = std::dynamic_pointer_cast<GeomDataAPI_Dir>(
       data()->attribute(SketchPlugin_Sketch::NORM_ID()));
 
@@ -117,7 +114,7 @@ void SketchPlugin_Sketch::execute()
   for (; aShapeIt != aFeaturesPreview.end(); ++aShapeIt) {
     aBigWire->addEdge(*aShapeIt);
   }
-  aBigWire->setPlane(anOrigin->pnt(), aDirX->dir(), aDirY->dir(), aNorm->dir());
+  aBigWire->setPlane(anOrigin->pnt(), aDirX->dir(), aNorm->dir());
 
 //  GeomAlgoAPI_SketchBuilder::createFaces(anOrigin->pnt(), aDirX->dir(), aDirY->dir(), aNorm->dir(),
 //                                         aFeaturesPreview, aLoops, aWires);
@@ -198,13 +195,14 @@ std::shared_ptr<GeomAPI_Pnt> SketchPlugin_Sketch::to3D(const double theX, const
 {
   std::shared_ptr<GeomDataAPI_Point> aC = std::dynamic_pointer_cast<GeomDataAPI_Point>(
       data()->attribute(SketchPlugin_Sketch::ORIGIN_ID()));
+  std::shared_ptr<GeomDataAPI_Dir> aNorm = std::dynamic_pointer_cast<GeomDataAPI_Dir>(
+      data()->attribute(SketchPlugin_Sketch::NORM_ID()));
   std::shared_ptr<GeomDataAPI_Dir> aX = std::dynamic_pointer_cast<GeomDataAPI_Dir>(
       data()->attribute(SketchPlugin_Sketch::DIRX_ID()));
-  std::shared_ptr<GeomDataAPI_Dir> aY = std::dynamic_pointer_cast<GeomDataAPI_Dir>(
-      data()->attribute(SketchPlugin_Sketch::DIRY_ID()));
+  std::shared_ptr<GeomAPI_Dir> aY(new GeomAPI_Dir(aNorm->dir()->cross(aX->dir())));
 
   std::shared_ptr<GeomAPI_XYZ> aSum = aC->pnt()->xyz()->added(aX->dir()->xyz()->multiplied(theX))
-      ->added(aY->dir()->xyz()->multiplied(theY));
+      ->added(aY->xyz()->multiplied(theY));
 
   return std::shared_ptr<GeomAPI_Pnt>(new GeomAPI_Pnt(aSum));
 }
@@ -214,11 +212,12 @@ std::shared_ptr<GeomAPI_Pnt2d> SketchPlugin_Sketch::to2D(
 {
   std::shared_ptr<GeomDataAPI_Point> aC = std::dynamic_pointer_cast<GeomDataAPI_Point>(
       data()->attribute(SketchPlugin_Sketch::ORIGIN_ID()));
+  std::shared_ptr<GeomDataAPI_Dir> aNorm = std::dynamic_pointer_cast<GeomDataAPI_Dir>(
+      data()->attribute(SketchPlugin_Sketch::NORM_ID()));
   std::shared_ptr<GeomDataAPI_Dir> aX = std::dynamic_pointer_cast<GeomDataAPI_Dir>(
       data()->attribute(SketchPlugin_Sketch::DIRX_ID()));
-  std::shared_ptr<GeomDataAPI_Dir> aY = std::dynamic_pointer_cast<GeomDataAPI_Dir>(
-      data()->attribute(SketchPlugin_Sketch::DIRY_ID()));
-  return thePnt->to2D(aC->pnt(), aX->dir(), aY->dir());
+  std::shared_ptr<GeomAPI_Dir> aY(new GeomAPI_Dir(aNorm->dir()->cross(aX->dir())));
+  return thePnt->to2D(aC->pnt(), aX->dir(), aY);
 }
 
 
@@ -250,12 +249,10 @@ std::shared_ptr<GeomAPI_Ax3> SketchPlugin_Sketch::coordinatePlane() const
     aData->attribute(SketchPlugin_Sketch::ORIGIN_ID()));
   std::shared_ptr<GeomDataAPI_Dir> aX = std::dynamic_pointer_cast<GeomDataAPI_Dir>(
     aData->attribute(SketchPlugin_Sketch::DIRX_ID()));
-  std::shared_ptr<GeomDataAPI_Dir> aY = std::dynamic_pointer_cast<GeomDataAPI_Dir>(
-    aData->attribute(SketchPlugin_Sketch::DIRY_ID()));
   std::shared_ptr<GeomDataAPI_Dir> aNorm = std::dynamic_pointer_cast<GeomDataAPI_Dir>(
     aData->attribute(SketchPlugin_Sketch::NORM_ID()));
 
-  return std::shared_ptr<GeomAPI_Ax3>(new GeomAPI_Ax3(aC->pnt(), aX->dir(), aY->dir(), aNorm->dir()));
+  return std::shared_ptr<GeomAPI_Ax3>(new GeomAPI_Ax3(aC->pnt(), aX->dir(), aNorm->dir()));
 }
 
 void SketchPlugin_Sketch::erase()
@@ -309,9 +306,6 @@ void SketchPlugin_Sketch::attributeChanged(const std::string& theID) {
         std::shared_ptr<GeomDataAPI_Dir> aDirX = std::dynamic_pointer_cast<GeomDataAPI_Dir>(
           data()->attribute(SketchPlugin_Sketch::DIRX_ID()));
         aDirX->setValue(aXDir);
-        std::shared_ptr<GeomDataAPI_Dir> aDirY = std::dynamic_pointer_cast<GeomDataAPI_Dir>(
-          data()->attribute(SketchPlugin_Sketch::DIRY_ID()));
-        aDirY->setValue(aYDir);
         std::shared_ptr<GeomAPI_Dir> aDir = aPlane->direction();
       }
     }
index 43a6e370792dc38e1d020ee6808fe739d6b5e04f..0c88f0d8f097c59f2dff814f9344ac942f343de9 100644 (file)
@@ -44,12 +44,6 @@ class SketchPlugin_Sketch : public ModelAPI_CompositeFeature//, public GeomAPI_I
     static const std::string MY_DIRX_ID("DirX");
     return MY_DIRX_ID;
   }
-  /// Vector Y inside of the sketch plane
-  inline static const std::string& DIRY_ID()
-  {
-    static const std::string MY_DIRY_ID("DirY");
-    return MY_DIRY_ID;
-  }
   /// Vector Z, normal to the sketch plane
   inline static const std::string& NORM_ID()
   {
index c1f07f72be58b70d0ab6f1a543c578e2083b4d75..b650cbdabee544b8d56a85a3242adaf72f912dda 100644 (file)
@@ -1299,14 +1299,15 @@ Slvs_hEntity SketchSolver_ConstraintGroup::changeEntityFeature(FeaturePtr theEnt
 //  Purpose:  create/update the normal of workplane
 // ============================================================================
 Slvs_hEntity SketchSolver_ConstraintGroup::changeNormal(
-    std::shared_ptr<ModelAPI_Attribute> theDirX, std::shared_ptr<ModelAPI_Attribute> theDirY,
+    std::shared_ptr<ModelAPI_Attribute> theDirX,
     std::shared_ptr<ModelAPI_Attribute> theNorm)
 {
+  std::shared_ptr<GeomDataAPI_Dir> aNorm = std::dynamic_pointer_cast<GeomDataAPI_Dir>(theNorm);
   std::shared_ptr<GeomDataAPI_Dir> aDirX = std::dynamic_pointer_cast<GeomDataAPI_Dir>(theDirX);
-  std::shared_ptr<GeomDataAPI_Dir> aDirY = std::dynamic_pointer_cast<GeomDataAPI_Dir>(theDirY);
-  if (!aDirX || !aDirY || (fabs(aDirX->x()) + fabs(aDirX->y()) + fabs(aDirX->z()) < tolerance)
-      || (fabs(aDirY->x()) + fabs(aDirY->y()) + fabs(aDirY->z()) < tolerance))
+  if (!aDirX || (fabs(aDirX->x()) + fabs(aDirX->y()) + fabs(aDirX->z()) < tolerance))
     return SLVS_E_UNKNOWN;
+  // calculate Y direction
+  std::shared_ptr<GeomAPI_Dir> aDirY(new GeomAPI_Dir(aNorm->dir()->cross(aDirX->dir())));
 
   // quaternion parameters of normal vector
   double qw, qx, qy, qz;
@@ -1370,14 +1371,12 @@ bool SketchSolver_ConstraintGroup::updateWorkplane()
   // Get parameters of workplane
   std::shared_ptr<ModelAPI_Attribute> aDirX = mySketch->data()->attribute(
       SketchPlugin_Sketch::DIRX_ID());
-  std::shared_ptr<ModelAPI_Attribute> aDirY = mySketch->data()->attribute(
-      SketchPlugin_Sketch::DIRY_ID());
   std::shared_ptr<ModelAPI_Attribute> aNorm = mySketch->data()->attribute(
       SketchPlugin_Sketch::NORM_ID());
   std::shared_ptr<ModelAPI_Attribute> anOrigin = mySketch->data()->attribute(
       SketchPlugin_Sketch::ORIGIN_ID());
   // Transform them into SolveSpace format
-  Slvs_hEntity aNormalWP = changeNormal(aDirX, aDirY, aNorm);
+  Slvs_hEntity aNormalWP = changeNormal(aDirX, aNorm);
   if (!aNormalWP)
     return false;
   Slvs_hEntity anOriginWP = changeEntity(anOrigin);
index 5c6f965e33b54d4344ddb5acff661dac4a11463f..e24d93a7d2bf0e6814e89de8e5cbebe7e24a4e28 100644 (file)
@@ -156,12 +156,10 @@ protected:
    *  on the plane transversed to created normal.
    *
    *  \param[in] theDirX first coordinate axis of the plane
-   *  \param[in] theDirY second coordinate axis of the plane
    *  \param[in] theNorm attribute for the normal (used to identify newly created entity)
    *  \return identifier of created or updated normal
    */
   Slvs_hEntity changeNormal(std::shared_ptr<ModelAPI_Attribute> theDirX,
-                            std::shared_ptr<ModelAPI_Attribute> theDirY,
                             std::shared_ptr<ModelAPI_Attribute> theNorm);
 
   /** \brief Adds or updates a parameter in the group