]> SALOME platform Git repositories - modules/geom.git/commitdiff
Salome HOME
PAL 11107 - Make a rotation given an object and 3 points
authorepa <epa@opencascade.com>
Fri, 27 Oct 2006 08:39:40 +0000 (08:39 +0000)
committerepa <epa@opencascade.com>
Fri, 27 Oct 2006 08:39:40 +0000 (08:39 +0000)
16 files changed:
src/GEOMContext/GEOM_icons.po
src/GEOMGUI/GEOM_images.po
src/GEOMImpl/GEOMImpl_IRotate.hxx
src/GEOMImpl/GEOMImpl_ITransformOperations.cxx
src/GEOMImpl/GEOMImpl_ITransformOperations.hxx
src/GEOMImpl/GEOMImpl_RotateDriver.cxx
src/GEOMImpl/GEOMImpl_Types.hxx
src/GEOM_I/GEOM_ITransformOperations_i.cc
src/GEOM_I/GEOM_ITransformOperations_i.hh
src/GEOM_I_Superv/GEOM_Superv_i.cc
src/GEOM_I_Superv/GEOM_Superv_i.hh
src/GEOM_SWIG/GEOM_TestAll.py
src/GEOM_SWIG/batchmode_geompy.py
src/GEOM_SWIG/geompy.py
src/TransformationGUI/TransformationGUI_RotationDlg.cxx
src/TransformationGUI/TransformationGUI_RotationDlg.h

index 996122d66220d42e948f72ed3afc45310afc2c6c..82eaeadd299769c11b8721f5f598c8a7a2ca39ac 100644 (file)
@@ -257,6 +257,10 @@ msgstr "translation.png"
 msgid "ICON_DLG_ROTATION"
 msgstr "rotate.png"
 
+#RotationDlg
+msgid "ICON_DLG_ROTATION_THREE_POINTS"
+msgstr "rotatepnt.png"
+
 #ScaleDlg
 msgid "ICON_DLG_SCALE"
 msgstr "scale.png"
index e8132904a24960db31ec80034607aa42f9e8c99e..130b32162cad34b4939195085f7ba9d941777ff8 100644 (file)
@@ -291,6 +291,10 @@ msgstr "translationVector.png"
 msgid "ICON_DLG_ROTATION"
 msgstr "rotate.png"
 
+#RotationDlg
+msgid "ICON_DLG_ROTATION_THREE_POINTS"
+msgstr "rotatepnt.png"
+
 #ScaleDlg
 msgid "ICON_DLG_SCALE"
 msgstr "scale.png"
index 9d09aa48705da5c133fb9a1a9054e17429e650c1..2cdad4d5a31b7535cb7b3cfa8e20ffb7041eec7b 100644 (file)
@@ -28,6 +28,9 @@
 #define ROTATE_STEP1      4
 #define ROTATE_NBITER1   5
 #define ROTATE_NBITER2   6
+#define ROTATE_CENTRAL_POINT    7  
+#define ROTATE_POINT1           8
+#define ROTATE_POINT2           9
 
 class GEOMImpl_IRotate
 {
@@ -35,6 +38,18 @@ class GEOMImpl_IRotate
   
   GEOMImpl_IRotate(Handle(GEOM_Function) theFunction): _func(theFunction) {}
   
+  void SetCentPoint(Handle(GEOM_Function) theCentPoint) { _func->SetReference(ROTATE_CENTRAL_POINT, theCentPoint); }
+  
+  Handle(GEOM_Function) GetCentPoint() { return _func->GetReference(ROTATE_CENTRAL_POINT); }
+
+  void SetPoint1(Handle(GEOM_Function) thePoint1) { _func->SetReference(ROTATE_POINT1, thePoint1); }
+  
+  Handle(GEOM_Function) GetPoint1() { return _func->GetReference(ROTATE_POINT1); }
+  
+  void SetPoint2(Handle(GEOM_Function) thePoint2) { _func->SetReference(ROTATE_POINT2, thePoint2); }
+  
+  Handle(GEOM_Function) GetPoint2() { return _func->GetReference(ROTATE_POINT2); }
+  
   void SetAngle(Standard_Real theAngle) { _func->SetReal(ROTATE_ANGLE, theAngle); }
   
   Standard_Real GetAngle() { return _func->GetReal(ROTATE_ANGLE); }
index 27ba4cb29d7bdd5bb11892caa6269f7d01bced53..9bf0da1bfd9e0194c80496d62ed93db602f76151 100644 (file)
@@ -1405,3 +1405,122 @@ Handle(GEOM_Object) GEOMImpl_ITransformOperations::Rotate2D (Handle(GEOM_Object)
   SetErrorCode(OK);
   return aCopy;
 }
+
+//=============================================================================
+/*!
+ *  RotateThreePoints
+ */
+//=============================================================================
+Handle(GEOM_Object) GEOMImpl_ITransformOperations::RotateThreePoints (Handle(GEOM_Object) theObject,
+                                                                     Handle(GEOM_Object) theCentPoint, 
+                                                                     Handle(GEOM_Object) thePoint1,
+                                                                     Handle(GEOM_Object) thePoint2)
+{
+  SetErrorCode(KO);
+
+  if (theObject.IsNull() || theCentPoint.IsNull() || thePoint1.IsNull() || thePoint2.IsNull()) return NULL;
+
+  Handle(GEOM_Function) aFunction, aLastFunction = theObject->GetLastFunction();
+  if (aLastFunction.IsNull()) return NULL;  //There is no function which creates an object to be rotated
+
+  // Get last functions of the arguments
+  Handle(GEOM_Function) aCPF = theCentPoint->GetLastFunction();
+  Handle(GEOM_Function) aP1F = thePoint1->GetLastFunction();
+  Handle(GEOM_Function) aP2F = thePoint2->GetLastFunction();
+
+
+  //Add a rotate function
+  aFunction = theObject->AddFunction(GEOMImpl_RotateDriver::GetID(), ROTATE_THREE_POINTS);
+
+  if (aFunction.IsNull()) return NULL;
+
+  //Check if the function is set correctly
+  if (aFunction->GetDriverGUID() != GEOMImpl_RotateDriver::GetID()) return NULL;
+
+  GEOMImpl_IRotate aRI(aFunction);
+  aRI.SetCentPoint(aCPF);
+  aRI.SetPoint1(aP1F);
+  aRI.SetPoint2(aP2F);
+  aRI.SetOriginal(aLastFunction);
+
+  //Compute the translation
+  try {
+#if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
+    OCC_CATCH_SIGNALS;
+#endif
+    if (!GetSolver()->ComputeFunction(aFunction)) {
+      SetErrorCode("Rotate driver failed");
+      return NULL;
+    }
+  }
+  catch (Standard_Failure) {
+    Handle(Standard_Failure) aFail = Standard_Failure::Caught();
+    SetErrorCode(aFail->GetMessageString());
+    return NULL;
+  }
+
+  //Make a Python command
+  GEOM::TPythonDump(aFunction) << "geompy.TrsfOp.RotateThreePoints(" << theObject
+                              << ", " << theCentPoint << ", "<<thePoint1 << ", " << thePoint2 << ")";
+
+  SetErrorCode(OK);
+  return theObject;
+}
+
+//=============================================================================
+/*!
+ *  RotateThreePointsCopy
+ */
+//=============================================================================
+Handle(GEOM_Object) GEOMImpl_ITransformOperations::RotateThreePointsCopy (Handle(GEOM_Object) theObject, 
+                                                        Handle(GEOM_Object) theCentPoint, 
+                                                        Handle(GEOM_Object) thePoint1,
+                                                        Handle(GEOM_Object) thePoint2)
+{
+  SetErrorCode(KO);
+
+  if (theObject.IsNull() || theCentPoint.IsNull() || thePoint1.IsNull() || thePoint2.IsNull()) return NULL;
+
+  Handle(GEOM_Function) aFunction, aLastFunction = theObject->GetLastFunction();
+  if (aLastFunction.IsNull()) return NULL;  //There is no function which creates an object to be rotated
+
+  //Add a new Copy object
+  Handle(GEOM_Object) aCopy = GetEngine()->AddObject(GetDocID(), theObject->GetType());
+
+  //Add a rotate function
+  aFunction = aCopy->AddFunction(GEOMImpl_RotateDriver::GetID(), ROTATE_THREE_POINTS_COPY);
+  if (aFunction.IsNull()) return NULL;
+
+    //Check if the function is set correctly
+  if (aFunction->GetDriverGUID() != GEOMImpl_RotateDriver::GetID()) return NULL;
+
+  GEOMImpl_IRotate aRI(aFunction);
+  aRI.SetCentPoint(theCentPoint->GetLastFunction());
+  aRI.SetPoint1(thePoint1->GetLastFunction());
+  aRI.SetPoint2(thePoint2->GetLastFunction());
+  aRI.SetOriginal(aLastFunction);
+
+  //Compute the translation
+  try {
+#if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
+    OCC_CATCH_SIGNALS;
+#endif
+    if (!GetSolver()->ComputeFunction(aFunction)) {
+      SetErrorCode("Rotate driver failed");
+      return NULL;
+    }
+  }
+  catch (Standard_Failure) {
+    Handle(Standard_Failure) aFail = Standard_Failure::Caught();
+    SetErrorCode(aFail->GetMessageString());
+    return NULL;
+  }
+
+  //Make a Python command
+  GEOM::TPythonDump(aFunction) << aCopy << " = geompy.MakeRotationThreePoints(" << theObject
+                              << ", " << theCentPoint << ", "<<thePoint1 << ", " << thePoint2 << ")";
+
+  SetErrorCode(OK);
+  return aCopy;
+}
+
index e5ba8fddfabccc35531ac3ceea020dc5c2687dbf..843c8a12a4ff118e1b33ae114ac87f2ab99df394 100644 (file)
@@ -107,6 +107,17 @@ class GEOMImpl_ITransformOperations : public GEOM_IOperations {
                                Standard_Integer theNbTimes1,
                                double theStep, 
                                Standard_Integer theNbTimes2);
+
+  Standard_EXPORT Handle(GEOM_Object) RotateThreePoints (Handle(GEOM_Object) theObject,
+                                                        Handle(GEOM_Object) theCentPoint, 
+                                                        Handle(GEOM_Object) thePoint1,
+                                                        Handle(GEOM_Object) thePoint2);
+
+  Standard_EXPORT Handle(GEOM_Object) RotateThreePointsCopy (Handle(GEOM_Object) theObject, 
+                                                        Handle(GEOM_Object) theCentPoint, 
+                                                        Handle(GEOM_Object) thePoint1,
+                                                        Handle(GEOM_Object) thePoint2);
+
 };
 
 #endif
index f252716aa7556cba65c818998f389cc91d54ac4f..94f949129b83f1541cf4dc62483659c29db199e8 100644 (file)
@@ -79,6 +79,7 @@ Standard_Integer GEOMImpl_RotateDriver::Execute(TFunction_Logbook& log) const
 
   GEOMImpl_IRotate RI(aFunction);
   gp_Trsf aTrsf;
+  gp_Pnt aCP, aP1, aP2;
   Standard_Integer aType = aFunction->GetType();
   Handle(GEOM_Function) anOriginalFunction = RI.GetOriginal();
   if(anOriginalFunction.IsNull()) return 0;
@@ -102,6 +103,31 @@ Standard_Integer GEOMImpl_RotateDriver::Execute(TFunction_Logbook& log) const
     BRepBuilderAPI_Transform aTransformation(anOriginal, aTrsf, Standard_False);
     aShape = aTransformation.Shape();
   }
+  else if(aType ==  ROTATE_THREE_POINTS || aType == ROTATE_THREE_POINTS_COPY) {
+    Handle(GEOM_Function) aCentPoint = RI.GetCentPoint();
+    Handle(GEOM_Function) aPoint1 = RI.GetPoint1();
+    Handle(GEOM_Function) aPoint2 = RI.GetPoint2();
+    if(aCentPoint.IsNull() || aPoint1.IsNull() || aPoint2.IsNull()) return 0;
+    TopoDS_Shape aCV = aCentPoint->GetValue();
+    TopoDS_Shape aV1 = aPoint1->GetValue();
+    TopoDS_Shape aV2 = aPoint2->GetValue();
+    if(aCV.IsNull() || aCV.ShapeType() != TopAbs_VERTEX) return 0;
+    if(aV1.IsNull() || aV1.ShapeType() != TopAbs_VERTEX) return 0;
+    if(aV2.IsNull() || aV2.ShapeType() != TopAbs_VERTEX) return 0;
+
+    aCP = BRep_Tool::Pnt(TopoDS::Vertex(aCV));
+    aP1 = BRep_Tool::Pnt(TopoDS::Vertex(aV1));
+    aP2 = BRep_Tool::Pnt(TopoDS::Vertex(aV2));
+
+    gp_Vec aVec1(aCP, aP1);
+    gp_Vec aVec2(aCP, aP2);
+    gp_Dir aDir(aVec1 ^ aVec2);
+    gp_Ax1 anAx1(aCP, aDir);
+    Standard_Real anAngle = aVec1.Angle(aVec2);
+    aTrsf.SetRotation(anAx1, anAngle);
+    BRepBuilderAPI_Transform aTransformation(anOriginal, aTrsf, Standard_False);
+    aShape = aTransformation.Shape();
+  }
   else if(aType == ROTATE_1D) {
     //Get direction
     Handle(GEOM_Function) anAxis = RI.GetAxis();
index cc0ebb563936dee8a5bee7f4463c0cafa0296668..4c436de297ec4bcb95f8c58cac0214d7cd97bda1 100755 (executable)
 #define TRANSLATE_XYZ             7
 #define TRANSLATE_XYZ_COPY        8
 
-#define ROTATE      1
-#define ROTATE_COPY 2
-#define ROTATE_1D   3
-#define ROTATE_2D   4
+#define ROTATE                    1
+#define ROTATE_COPY               2
+#define ROTATE_1D                 3
+#define ROTATE_2D                 4
+#define ROTATE_THREE_POINTS       5
+#define ROTATE_THREE_POINTS_COPY  6
 
 #define MIRROR_PLANE      1
 #define MIRROR_PLANE_COPY 2
index e19197e805f5fdf3d5084fcc7103d4219c5d9918..e914733f6a59fe7df80e0da32d985b4dc208c5c5 100644 (file)
@@ -952,3 +952,102 @@ GEOM::GEOM_Object_ptr GEOM_ITransformOperations_i::MultiRotate2D (GEOM::GEOM_Obj
 
   return GetObject(anObject);
 }
+
+//=============================================================================
+/*!
+ *  RotateThreePoints
+ */
+//=============================================================================
+GEOM::GEOM_Object_ptr GEOM_ITransformOperations_i::RotateThreePoints
+                                             (GEOM::GEOM_Object_ptr theObject,
+                                             GEOM::GEOM_Object_ptr theCentPoint,
+                                             GEOM::GEOM_Object_ptr thePoint1,
+                                             GEOM::GEOM_Object_ptr thePoint2)
+{
+  //Set a not done flag
+  GetOperations()->SetNotDone();
+  GEOM::GEOM_Object_var aGEOMObject;
+
+  if (theCentPoint == NULL || thePoint1 == NULL || thePoint2 == NULL || theObject == NULL) return aGEOMObject._retn();
+
+  //check if the object is a subshape
+  if(!theObject->IsMainShape()) {
+    GetOperations()->SetErrorCode(SUBSHAPE_ERROR);
+    return aGEOMObject._retn();
+  }
+
+  aGEOMObject = GEOM::GEOM_Object::_duplicate(theObject);
+
+  //Get the object itself
+  Handle(GEOM_Object) anObject =
+    GetOperations()->GetEngine()->GetObject(theObject->GetStudyID(), theObject->GetEntry());
+  if (anObject.IsNull()) return aGEOMObject._retn();
+
+  //Get the central point of rotation
+  Handle(GEOM_Object) aCentPoint =
+    GetOperations()->GetEngine()->GetObject(theCentPoint->GetStudyID(), theCentPoint->GetEntry());
+  if (aCentPoint.IsNull()) return aGEOMObject._retn();
+
+  //Get the first point
+  Handle(GEOM_Object) aPoint1 =
+    GetOperations()->GetEngine()->GetObject(thePoint1->GetStudyID(), thePoint1->GetEntry());
+  if (aPoint1.IsNull()) return aGEOMObject._retn();
+
+  //Get the second point
+  Handle(GEOM_Object) aPoint2 =
+    GetOperations()->GetEngine()->GetObject(thePoint2->GetStudyID(), thePoint2->GetEntry());
+  if (aPoint2.IsNull()) return aGEOMObject._retn();
+
+  //Perform the translation
+  GetOperations()->RotateThreePoints(anObject, aCentPoint, aPoint1, aPoint2);
+
+  return aGEOMObject._retn();
+}
+
+//=============================================================================
+/*!
+ *  RotateThreePointsCopy
+ */
+//=============================================================================
+GEOM::GEOM_Object_ptr GEOM_ITransformOperations_i::RotateThreePointsCopy
+                                             (GEOM::GEOM_Object_ptr theObject,
+                                             GEOM::GEOM_Object_ptr theCentPoint,
+                                             GEOM::GEOM_Object_ptr thePoint1,
+                                             GEOM::GEOM_Object_ptr thePoint2)
+{
+  GEOM::GEOM_Object_var aGEOMObject;
+
+  //Set a not done flag
+  GetOperations()->SetNotDone();
+
+  if (theCentPoint == NULL || thePoint1 == NULL || thePoint2 == NULL || theObject == NULL) return aGEOMObject._retn();
+
+  //Get the object itself
+  Handle(GEOM_Object) aBasicObject =
+    GetOperations()->GetEngine()->GetObject(theObject->GetStudyID(), theObject->GetEntry());
+  if (aBasicObject.IsNull()) return aGEOMObject._retn();
+
+  //Get the central point of rotation
+  Handle(GEOM_Object) aCentPoint =
+    GetOperations()->GetEngine()->GetObject(theCentPoint->GetStudyID(), theCentPoint->GetEntry());
+  if (aCentPoint.IsNull()) return aGEOMObject._retn();
+
+  //Get the first point
+  Handle(GEOM_Object) aPoint1 =
+    GetOperations()->GetEngine()->GetObject(thePoint1->GetStudyID(), thePoint1->GetEntry());
+  if (aPoint1.IsNull()) return aGEOMObject._retn();
+
+  //Get the second point
+  Handle(GEOM_Object) aPoint2 =
+    GetOperations()->GetEngine()->GetObject(thePoint2->GetStudyID(), thePoint2->GetEntry());
+  if (aPoint2.IsNull()) return aGEOMObject._retn();
+
+  //Perform the rotation
+  Handle(GEOM_Object) anObject =
+    GetOperations()->RotateThreePointsCopy(aBasicObject, aCentPoint, aPoint1, aPoint2);
+  if (!GetOperations()->IsDone() || anObject.IsNull())
+    return aGEOMObject._retn();
+
+  return GetObject(anObject);
+}
+
index 188642963c458c6cc7d90423a6a7dcee5df78689..7c3fb3f4008f7dfff5f4a43cf63acfc5f6f8ae0d 100644 (file)
@@ -124,6 +124,17 @@ class GEOM_ITransformOperations_i :
                                           GEOM::GEOM_Object_ptr theStartLCS,
                                           GEOM::GEOM_Object_ptr theEndLCS);
 
+  GEOM::GEOM_Object_ptr RotateThreePoints (GEOM::GEOM_Object_ptr theObject,
+                                          GEOM::GEOM_Object_ptr theCentPoint,
+                                          GEOM::GEOM_Object_ptr thePoint1,
+                                          GEOM::GEOM_Object_ptr thePoint2);
+
+  GEOM::GEOM_Object_ptr RotateThreePointsCopy (GEOM::GEOM_Object_ptr theObject,
+                                              GEOM::GEOM_Object_ptr theCentPoint,
+                                              GEOM::GEOM_Object_ptr thePoint1,
+                                              GEOM::GEOM_Object_ptr thePoint2);
+
+
   ::GEOMImpl_ITransformOperations* GetOperations() { return (::GEOMImpl_ITransformOperations*)GetImpl(); }
 };
 
index 894e4f358745fdf0fb37262ab1234aa1b82db8a1..6d289ff684e0f5f9dae0322148ca218f629b9443 100644 (file)
@@ -1278,6 +1278,37 @@ GEOM::GEOM_Object_ptr GEOM_Superv_i::RotateCopy (GEOM::GEOM_Object_ptr theObject
   endService( " GEOM_Superv_i::RotateCopy" );
   return anObj;
 }
+//=============================================================================
+//  RotateThreePoints:
+//=============================================================================
+GEOM::GEOM_Object_ptr GEOM_Superv_i::RotateThreePoints (GEOM::GEOM_Object_ptr theObject,
+                                                       GEOM::GEOM_Object_ptr theCentPoint,
+                                                       GEOM::GEOM_Object_ptr thePoint1,
+                                                       GEOM::GEOM_Object_ptr thePoint2)
+{
+  beginService( " GEOM_Superv_i::RotateThreePoints" );
+  MESSAGE("GEOM_Superv_i::RotateThreePoints");
+  getTransfOp();
+  GEOM::GEOM_Object_ptr anObj = myTransfOp->RotateThreePoints(theObject, theCentPoint, thePoint1, thePoint2);
+  endService( " GEOM_Superv_i::RotateThreePoints" );
+  return anObj;
+}
+
+//=============================================================================
+//  RotateThreePointsCopy:
+//=============================================================================
+GEOM::GEOM_Object_ptr GEOM_Superv_i::RotateThreePointsCopy (GEOM::GEOM_Object_ptr theObject,
+                                                           GEOM::GEOM_Object_ptr theCentPoint,
+                                                           GEOM::GEOM_Object_ptr thePoint1,
+                                                           GEOM::GEOM_Object_ptr thePoint2)
+{
+  beginService( " GEOM_Superv_i::RotateThreePointsCopy" );
+  MESSAGE("GEOM_Superv_i::RotateThreePointsCopy");
+  getTransfOp();
+  GEOM::GEOM_Object_ptr anObj = myTransfOp->RotateThreePointsCopy(theObject, theCentPoint, thePoint1, thePoint2);
+  endService( " GEOM_Superv_i::RotateThreePointsCopy" );
+  return anObj;
+}
 
 //=============================================================================
 //  MultiRotate1D:
index 87422e14d13a55bc70035bc00b47ce1b04f5b923..4dce89ebb6a98c24f4f1daf0a9397ae72e58abb4 100644 (file)
@@ -307,6 +307,17 @@ public:
   GEOM::GEOM_Object_ptr RotateCopy (GEOM::GEOM_Object_ptr theObject,
                                    GEOM::GEOM_Object_ptr theAxis,
                                    CORBA::Double theAngle);
+
+  GEOM::GEOM_Object_ptr RotateThreePoints (GEOM::GEOM_Object_ptr theObject,
+                                          GEOM::GEOM_Object_ptr theCentPoint,
+                                          GEOM::GEOM_Object_ptr thePoint1,
+                                          GEOM::GEOM_Object_ptr thePoint2);
+
+  GEOM::GEOM_Object_ptr RotateThreePointsCopy (GEOM::GEOM_Object_ptr theObject,
+                                              GEOM::GEOM_Object_ptr theCentPoint,
+                                              GEOM::GEOM_Object_ptr thePoint1,
+                                              GEOM::GEOM_Object_ptr thePoint2);
+
   GEOM::GEOM_Object_ptr MultiRotate1D (GEOM::GEOM_Object_ptr theObject,
                                       GEOM::GEOM_Object_ptr theAxis,
                                       CORBA::Long theNbTimes);
index 236e187b39af885599b706cb590449864d53e739..ec06701863af3e9c873725b8bf564da5cca2944e 100644 (file)
@@ -156,15 +156,16 @@ def TestAll (geompy, math):
   Sewing     = geompy.MakeSewing([Face, S], precision)   #(List Of GEOM_Object_ptr, Double)->GEOM_Object_ptr
 
   #Transform objects
-  Translation = geompy.MakeTranslationTwoPoints(Box, px, pz)  #(3 GEOM_Object_ptr)->GEOM_Object_ptr
-  TranslVect  = geompy.MakeTranslationVector(Box, vxyz)       #(2 GEOM_Object_ptr)->GEOM_Object_ptr
-  Rotation    = geompy.MakeRotation(Box, vz, angle1)          #(2 GEOM_Object_ptr, Double)->GEOM_Object_ptr
-  Scale       = geompy.MakeScaleTransform(Box, p0, factor)    #
-  Mirror      = geompy.MakeMirrorByPlane(Box, Plane)          #(2 GEOM_Object_ptr)->GEOM_Object_ptr
-  MirrorAxis  = geompy.MakeMirrorByAxis(Box, Line1)           #
-  MirrorPnt   = geompy.MakeMirrorByPoint(Box, p200)           #
-  Position    = geompy.MakePosition(Box, cs1, cs2)            #(3 GEOM_Object_ptr)->GEOM_Object_ptr
-  Offset      = geompy.MakeOffset(Box, 10.)                   #(GEOM_Object_ptr, Double)->GEOM_Object_ptr
+  Translation = geompy.MakeTranslationTwoPoints(Box, px, pz)    #(3 GEOM_Object_ptr)->GEOM_Object_ptr
+  TranslVect  = geompy.MakeTranslationVector(Box, vxyz)         #(2 GEOM_Object_ptr)->GEOM_Object_ptr
+  Rotation    = geompy.MakeRotation(Box, vz, angle1)            #(2 GEOM_Object_ptr, Double)->GEOM_Object_ptr
+  RotatPnt    = geompy.MakeRotationThreePoints(Box, px, py, pz) #(4 GEOM_Object_ptr)->GEOM_Object_ptr
+  Scale       = geompy.MakeScaleTransform(Box, p0, factor)      #
+  Mirror      = geompy.MakeMirrorByPlane(Box, Plane)            #(2 GEOM_Object_ptr)->GEOM_Object_ptr
+  MirrorAxis  = geompy.MakeMirrorByAxis(Box, Line1)             #
+  MirrorPnt   = geompy.MakeMirrorByPoint(Box, p200)             #
+  Position    = geompy.MakePosition(Box, cs1, cs2)              #(3 GEOM_Object_ptr)->GEOM_Object_ptr
+  Offset      = geompy.MakeOffset(Box, 10.)                     #(GEOM_Object_ptr, Double)->GEOM_Object_ptr
   Orientation = geompy.ChangeOrientation(Box)
 
   #IDList for Fillet/Chamfer
@@ -292,6 +293,7 @@ def TestAll (geompy, math):
   id_Translation = geompy.addToStudy(Translation, "Translation")
   id_TranslVect  = geompy.addToStudy(TranslVect , "Translation along vector")
   id_Rotation    = geompy.addToStudy(Rotation,    "Rotation")
+  id_RotatPnt    = geompy.addToStudy(RotatPnt,    "Rotation by three points")
   id_Scale       = geompy.addToStudy(Scale,       "Scale")
   id_Mirror      = geompy.addToStudy(Mirror,      "Mirror by Plane")
   id_MirrorAxis  = geompy.addToStudy(MirrorAxis,  "Mirror by Axis")
index 52ccbdfff6afc2b063b51e1d9d196b182c55e529..0f91c8c9dcf4b9e4210e32176a133cf95ea46771 100644 (file)
@@ -748,6 +748,12 @@ def MakeRotation(aShape,axis,angle):
       print "RotateCopy : ", TrsfOp.GetErrorCode()
     return anObj
 
+def MakeRotationThreePoints(aShape, centpoint, point1, point2):
+    anObj = TrsfOp.RotateThreePointsCopy(aShape, centpoint, point1, point2)
+    if TrsfOp.IsDone() == 0:
+      print "RotateThreePointsCopy : ", TrsfOp.GetErrorCode()
+    return anObj
+
 def MakeScaleTransform(aShape,theCenterofScale,factor):
     anObj = TrsfOp.ScaleShapeCopy(aShape,theCenterofScale,factor)
     if TrsfOp.IsDone() == 0:
index 2247928c1974fdf066f39fd6ae1d51a8ce2fca64..55f3659af80da99a746e774586a48cea9db4ef53 100644 (file)
@@ -1446,6 +1446,21 @@ def MakeRotation(theObject, theAxis, theAngle):
       print "RotateCopy : ", TrsfOp.GetErrorCode()
     return anObj
 
+## Rotate given object around vector perpendicular to plane
+#  containing three points, creating its copy before the rotatation.
+#  @param theObject The object to be rotated.
+#  @param theCentPoint central point - the axis is the vector perpendicular to the plane
+#  containing the three points.
+#  @param thePoint1 and thePoint2 - in a perpendicular plan of the axis.
+#  @return New GEOM_Object, containing the rotated object.
+#
+#  Example: see GEOM_TestAll.py
+def MakeRotationThreePoints(theObject, theCentPoint, thePoint1, thePoint2):
+    anObj = TrsfOp.RotateThreePointsCopy(theObject, theCentPoint, thePoint1, thePoint2)
+    if TrsfOp.IsDone() == 0:
+      print "RotateThreePointsCopy : ", TrsfOp.GetErrorCode()
+    return anObj
+
 ## Scale the given object by the factor, creating its copy before the scaling.
 #  @param theObject The object to be scaled.
 #  @param thePoint Center point for scaling.
index c22db8006a0503b61ecc64ce572fd65f59d10cdd..f7ef55d8987f58ed2980f13e36e5c3c84ef41387 100644 (file)
@@ -54,26 +54,35 @@ TransformationGUI_RotationDlg::TransformationGUI_RotationDlg
   :GEOMBase_Skeleton(theGeometryGUI, parent, name, modal, WStyle_Customize |
                      WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu)
 {
-  QPixmap image0(SUIT_Session::session()->resourceMgr()->loadPixmap("GEOM",tr("ICON_DLG_ROTATION")));
-  QPixmap image1(SUIT_Session::session()->resourceMgr()->loadPixmap("GEOM",tr("ICON_SELECT")));
+  SUIT_ResourceMgr* aResMgr = myGeomGUI->getApp()->resourceMgr();
+  QPixmap image0 (aResMgr->loadPixmap("GEOM",tr("ICON_DLG_ROTATION")));
+  QPixmap image1 (aResMgr->loadPixmap("GEOM",tr("ICON_SELECT")));
+  QPixmap image2 (aResMgr->loadPixmap("GEOM",tr("ICON_DLG_ROTATION_THREE_POINTS")));
 
   setCaption(tr("GEOM_ROTATION_TITLE"));
 
   /***************************************************************/
   GroupConstructors->setTitle(tr("GEOM_ROTATION"));
   RadioButton1->setPixmap(image0);
-  RadioButton2->close(TRUE);
+  RadioButton2->setPixmap(image2);
   RadioButton3->close(TRUE);
 
-  GroupPoints = new DlgRef_2Sel1Spin2Check(this, "GroupPoints");
+  GroupPoints = new DlgRef_4Sel1Spin2Check(this, "GroupPoints");
   GroupPoints->GroupBox1->setTitle(tr("GEOM_ARGUMENTS"));
   GroupPoints->TextLabel1->setText(tr("GEOM_OBJECTS"));
   GroupPoints->TextLabel2->setText(tr("GEOM_AXIS"));
   GroupPoints->TextLabel3->setText(tr("GEOM_ANGLE"));
+  GroupPoints->TextLabel4->setText(tr("GEOM_POINT_I").arg("1"));
+  GroupPoints->TextLabel5->setText(tr("GEOM_POINT_I").arg("2"));
+
   GroupPoints->LineEdit1->setReadOnly(true);
   GroupPoints->LineEdit2->setReadOnly(true);
+  GroupPoints->LineEdit4->setReadOnly(true);
+  GroupPoints->LineEdit5->setReadOnly(true);
   GroupPoints->PushButton1->setPixmap(image1);
   GroupPoints->PushButton2->setPixmap(image1);
+  GroupPoints->PushButton4->setPixmap(image1);
+  GroupPoints->PushButton5->setPixmap(image1);
   GroupPoints->CheckButton1->setText(tr("GEOM_CREATE_COPY"));
   GroupPoints->CheckButton2->setText(tr("GEOM_REVERSE"));
 
@@ -92,10 +101,13 @@ TransformationGUI_RotationDlg::TransformationGUI_RotationDlg
   /* signals and slots connections */
   connect(buttonOk, SIGNAL(clicked()), this, SLOT(ClickOnOk()));
   connect(buttonApply, SIGNAL(clicked()), this, SLOT(ClickOnApply()));
-  
+  connect(GroupConstructors, SIGNAL(clicked(int)), SLOT(ConstructorsClicked(int)));
+
   connect(GroupPoints->PushButton1, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument()));
   connect(GroupPoints->PushButton2, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument()));
-  
+  connect(GroupPoints->PushButton4, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument()));
+  connect(GroupPoints->PushButton5, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument()));
   connect(GroupPoints->LineEdit1, SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed()));
   connect(GroupPoints->LineEdit2, SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed()));
 
@@ -132,11 +144,53 @@ void TransformationGUI_RotationDlg::Init()
   myEditCurrentArgument = GroupPoints->LineEdit1;
   GroupPoints->LineEdit2->clear();
   
-  myAxis = GEOM::GEOM_Object::_nil();
+  myAxis = myCentPoint = myPoint1 = myPoint2 = GEOM::GEOM_Object::_nil();
   
   initName( tr( "GEOM_ROTATION" ) );
+  ConstructorsClicked( 0 );
 }
 
+//=================================================================================
+// function : ConstructorsClicked()
+// purpose  : Radio button management
+//=================================================================================
+void TransformationGUI_RotationDlg::ConstructorsClicked(int constructorId)
+{
+  disconnect(myGeomGUI->getApp()->selectionMgr(), 0, this, 0);
+  
+  myEditCurrentArgument = GroupPoints->LineEdit1;
+  globalSelection();
+
+  switch (constructorId)
+    {
+    case 0: /* rotation an object angle and axis */
+      {         
+       GroupPoints->ShowRows(2,3,false);
+       resize(0,0);
+       GroupPoints->TextLabel2->setText(tr("GEOM_AXIS"));
+       GroupPoints->LineEdit2->clear();
+       GroupPoints->ShowRows(4,4,true);
+       myAxis = GEOM::GEOM_Object::_nil();
+       break;
+      }
+    case 1: /* rotation an object by 3 points */
+      {
+       GroupPoints->ShowRows(4,4,false);
+       resize(0,0);
+       GroupPoints->ShowRows(2,3,true);
+       GroupPoints->TextLabel2->setText(tr("GEOM_CENTRAL_POINT"));
+       GroupPoints->TextLabel4->setText(tr("GEOM_POINT_I").arg("1"));
+       GroupPoints->TextLabel5->setText(tr("GEOM_POINT_I").arg("2"));
+       GroupPoints->LineEdit2->clear();
+       myCentPoint = myPoint1 = myPoint2 = GEOM::GEOM_Object::_nil();
+       break;
+      } 
+    }
+  
+  myEditCurrentArgument->setFocus();
+  connect(myGeomGUI->getApp()->selectionMgr(), 
+         SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument()));
+}
 
 //=================================================================================
 // function : ClickOnOk()
@@ -184,18 +238,36 @@ void TransformationGUI_RotationDlg::SelectionIntoArgument()
       if (!myObjects.length())
        return;
     }
-  else if(myEditCurrentArgument == GroupPoints->LineEdit2)
+  else 
     {
       if(IObjectCount() != 1)
        {
-         myAxis = GEOM::GEOM_Object::_nil();
+         if(myEditCurrentArgument == GroupPoints->LineEdit2 && getConstructorId() == 0)
+           myAxis = GEOM::GEOM_Object::_nil();
+         else if(myEditCurrentArgument == GroupPoints->LineEdit2 && getConstructorId() == 1)
+           myCentPoint  = GEOM::GEOM_Object::_nil();
+          else if(myEditCurrentArgument == GroupPoints->LineEdit4)
+           myPoint1 = GEOM::GEOM_Object::_nil();
+         else if(myEditCurrentArgument == GroupPoints->LineEdit5)
+           myPoint2 = GEOM::GEOM_Object::_nil();
          return;
        }
+
       Standard_Boolean testResult = Standard_False;
-      myAxis = GEOMBase::ConvertIOinGEOMObject(firstIObject(), testResult );
-      if(!testResult || CORBA::is_nil( myAxis ))
+      GEOM::GEOM_Object_var aSelectedObject = GEOMBase::ConvertIOinGEOMObject(firstIObject(), testResult );
+      if(!testResult || CORBA::is_nil( aSelectedObject ))
        return;
-      aName = GEOMBase::GetName( myAxis );
+
+      if(myEditCurrentArgument == GroupPoints->LineEdit2 && getConstructorId() == 0)
+       myAxis = aSelectedObject;
+      else if(myEditCurrentArgument == GroupPoints->LineEdit2 && getConstructorId() == 1)
+       myCentPoint = aSelectedObject;
+      else if(myEditCurrentArgument == GroupPoints->LineEdit4)
+       myPoint1 = aSelectedObject;
+      else if(myEditCurrentArgument == GroupPoints->LineEdit5)
+       myPoint2 = aSelectedObject;
+
+      aName = GEOMBase::GetName( aSelectedObject );
     }
   myEditCurrentArgument->setText( aName );
   
@@ -217,9 +289,20 @@ void TransformationGUI_RotationDlg::SetEditCurrentArgument()
   }
   else if(send == GroupPoints->PushButton2) {
     myEditCurrentArgument = GroupPoints->LineEdit2;
-    globalSelection( GEOM_LINE );
+    getConstructorId() == 0 ? globalSelection( GEOM_LINE ) :
+                              globalSelection( GEOM_POINT  );
   }
-  
+  else if (send == GroupPoints->PushButton4)
+    {
+      myEditCurrentArgument = GroupPoints->LineEdit4;
+      globalSelection( GEOM_POINT );
+    }
+  else if (send == GroupPoints->PushButton5)
+    {
+      myEditCurrentArgument = GroupPoints->LineEdit5;
+      globalSelection( GEOM_POINT );
+    }
+
   myEditCurrentArgument->setFocus();
   SelectionIntoArgument();
 }
@@ -250,11 +333,8 @@ void TransformationGUI_RotationDlg::ActivateThisDialog()
   GEOMBase_Skeleton::ActivateThisDialog();
   connect(myGeomGUI->getApp()->selectionMgr(), 
          SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument()));
-  globalSelection();
-  GroupPoints->LineEdit1->setFocus();
-  myEditCurrentArgument = GroupPoints->LineEdit1;
-  GroupPoints->LineEdit2->clear();
-  myAxis = GEOM::GEOM_Object::_nil();
+
+  ConstructorsClicked( getConstructorId() );
 }
 
 
@@ -295,7 +375,20 @@ GEOM::GEOM_IOperations_ptr TransformationGUI_RotationDlg::createOperation()
 //=================================================================================
 bool TransformationGUI_RotationDlg::isValid( QString& msg )
 {
-  return !(myObjects.length() == 0 || myAxis->_is_nil());
+  switch (getConstructorId())
+    {
+    case 0: 
+      {
+       return !(myObjects.length() == 0 || myAxis->_is_nil());
+       break;
+      }
+    case 1: 
+      {
+       return !(myObjects.length() == 0 || myCentPoint->_is_nil() || myPoint1->_is_nil() || myPoint2->_is_nil() );
+       break;
+      }
+    default: return false;
+    }
 }
 
 
@@ -306,24 +399,51 @@ bool TransformationGUI_RotationDlg::isValid( QString& msg )
 bool TransformationGUI_RotationDlg::execute( ObjectList& objects )
 {
   bool res = false;
-  
+  bool toCreateCopy = IsPreview() || GroupPoints->CheckButton1->isChecked();
+
   GEOM::GEOM_Object_var anObj;
   
-  if (GroupPoints->CheckButton1->isChecked() || IsPreview())
-    for (int i = 0; i < myObjects.length(); i++)
+  switch ( getConstructorId() ) 
+    {
+    case 0 :
       {
-       anObj = GEOM::GEOM_ITransformOperations::_narrow( getOperation() )->RotateCopy( myObjects[i], myAxis, GetAngle() * PI180 );
-       if ( !anObj->_is_nil() )
-         objects.push_back( anObj._retn() );
+       if (toCreateCopy)
+         for (int i = 0; i < myObjects.length(); i++)
+           {
+             anObj = GEOM::GEOM_ITransformOperations::_narrow( getOperation() )->RotateCopy( myObjects[i], myAxis, GetAngle() * PI180 );
+             if ( !anObj->_is_nil() )
+               objects.push_back( anObj._retn() );
+           }
+       else
+         for (int i = 0; i < myObjects.length(); i++)
+           {
+             anObj = GEOM::GEOM_ITransformOperations::_narrow( getOperation() )->Rotate( myObjects[i], myAxis, GetAngle() * PI180 );
+             if ( !anObj->_is_nil() )
+               objects.push_back( anObj._retn() );
+           }
+       res = true;
+       break;
       }
-  else
-    for (int i = 0; i < myObjects.length(); i++)
+    case 1 :
       {
-       anObj = GEOM::GEOM_ITransformOperations::_narrow( getOperation() )->Rotate( myObjects[i], myAxis, GetAngle() * PI180 );
-       if ( !anObj->_is_nil() )
-         objects.push_back( anObj._retn() );
+       if (toCreateCopy)
+         for (int i = 0; i < myObjects.length(); i++)
+           {
+             anObj = GEOM::GEOM_ITransformOperations::_narrow( getOperation() )->RotateThreePointsCopy( myObjects[i], myCentPoint, myPoint1, myPoint2 );
+             if ( !anObj->_is_nil() )
+               objects.push_back( anObj._retn() );
+           }
+       else
+         for (int i = 0; i < myObjects.length(); i++)
+           {
+             anObj = GEOM::GEOM_ITransformOperations::_narrow( getOperation() )->RotateThreePoints( myObjects[i], myCentPoint, myPoint1, myPoint2 );   
+             if ( !anObj->_is_nil() )
+               objects.push_back( anObj._retn() );
+           }
+       res = true;
+       break;
       }
-  res = true;
+    }
   
   return res;
 }
index 4824444501d5a96378b14c0aa02e7692b18b4897..4a18bbc1d44b16c52a7d69c64c9a957ca2e4ae7f 100644 (file)
@@ -29,7 +29,7 @@
 #define DIALOGBOX_ROTATION_H
 
 #include "GEOMBase_Skeleton.h"
-#include "DlgRef_2Sel1Spin2Check.h"
+#include "DlgRef_4Sel1Spin2Check.h"
   
 //=================================================================================
 // class    : TransformationGUI_RotationDlg
@@ -58,9 +58,9 @@ private:
     double GetAngle() const;
     
     GEOM::ListOfGO myObjects;
-    GEOM::GEOM_Object_var myAxis;
+    GEOM::GEOM_Object_var myAxis, myCentPoint, myPoint1, myPoint2;
     
-    DlgRef_2Sel1Spin2Check* GroupPoints;
+    DlgRef_4Sel1Spin2Check* GroupPoints;
 
 private slots:
     void ClickOnOk();
@@ -71,6 +71,7 @@ private slots:
     void SetEditCurrentArgument();
     void ValueChangedInSpinBox();
     void CreateCopyModeChanged(bool isCreateCopy);
+    void ConstructorsClicked(int constructorId);
     void onReverse();
 };