mirror of
https://git.salome-platform.org/gitpub/modules/geom.git
synced 2025-04-25 06:22:04 +05:00
PAL 11107 - Make a rotation given an object and 3 points
This commit is contained in:
parent
40b79d4e26
commit
5c6ce3deb5
@ -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"
|
||||
|
@ -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"
|
||||
|
@ -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); }
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
@ -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
|
||||
|
@ -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();
|
||||
|
@ -119,6 +119,8 @@
|
||||
#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
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
|
@ -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(); }
|
||||
};
|
||||
|
||||
|
@ -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:
|
||||
|
@ -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);
|
||||
|
@ -159,6 +159,7 @@ def TestAll (geompy, math):
|
||||
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) #
|
||||
@ -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")
|
||||
|
@ -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:
|
||||
|
@ -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.
|
||||
|
@ -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,9 +101,12 @@ 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)
|
||||
{
|
||||
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,7 +289,18 @@ 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();
|
||||
@ -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() );
|
||||
}
|
||||
|
||||
|
||||
@ -294,8 +374,21 @@ GEOM::GEOM_IOperations_ptr TransformationGUI_RotationDlg::createOperation()
|
||||
// purpose :
|
||||
//=================================================================================
|
||||
bool TransformationGUI_RotationDlg::isValid( QString& msg )
|
||||
{
|
||||
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,10 +399,15 @@ 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())
|
||||
switch ( getConstructorId() )
|
||||
{
|
||||
case 0 :
|
||||
{
|
||||
if (toCreateCopy)
|
||||
for (int i = 0; i < myObjects.length(); i++)
|
||||
{
|
||||
anObj = GEOM::GEOM_ITransformOperations::_narrow( getOperation() )->RotateCopy( myObjects[i], myAxis, GetAngle() * PI180 );
|
||||
@ -324,6 +422,28 @@ bool TransformationGUI_RotationDlg::execute( ObjectList& objects )
|
||||
objects.push_back( anObj._retn() );
|
||||
}
|
||||
res = true;
|
||||
break;
|
||||
}
|
||||
case 1 :
|
||||
{
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
@ -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();
|
||||
};
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user