FSM_GetShapesOnShape,
/*! Use GetInPlaceByHistory method (can work only after Partition) */
- FSM_GetInPlaceByHistory
+ FSM_GetInPlaceByHistory,
+
+ /*! To be used only for multi-transformation result.
+ * Only this method can be used after multi-transformation.
+ */
+ FSM_MultiTransformed
};
/*!
* \param theCopy is a true or false parameter. true is to reverse direction, false is to move normal direction.
* \return New GEOM_Object, containing the displaced shape.
*/
-
GEOM_Object PositionAlongPath (in GEOM_Object theObject,
in GEOM_Object thePath,
in double theDistance,
in boolean theCopy,
in boolean theReverse);
+ /*!
+ * Transform the shape in the same way what was used for the sample shape creation.
+ * \param theObject The object to be transformed.
+ * \param theSample The object containing information about required transformation.
+ * \note Implementation of this method is limited by multi-transformations now.
+ * \note Internal method.
+ * \return New GEOM_Object, containing the transformed shape.
+ */
+ GEOM_Object TransformLikeOtherCopy (in GEOM_Object theObject,
+ in GEOM_Object theSample);
+
/*!
* Recompute the shape from its arguments.
* \param theObject The object to be recomputed.
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
-//
-//NOTE: This is an intreface to a function for the Rotate operation.
-//
+// NOTE: This is an interface to a function for the Rotate operation.
+
#include "GEOM_Function.hxx"
+#include <gp_XYZ.hxx>
+
#define ROTATE_ANGLE 1
#define ROTATE_AXIS 2
#define ROTATE_ORGN 3
#define ROTATE_STEP1 4
-#define ROTATE_NBITER1 5
-#define ROTATE_NBITER2 6
+#define ROTATE_NBITER1 5
+#define ROTATE_NBITER2 6
#define ROTATE_CENTRAL_POINT 7
#define ROTATE_POINT1 8
#define ROTATE_POINT2 9
+#define ROTATE_DIR2_X 10
+#define ROTATE_DIR2_Y 11
+#define ROTATE_DIR2_Z 12
class GEOMImpl_IRotate
{
Handle(GEOM_Function) GetOriginal() { return _func->GetReference(ROTATE_ORGN); }
- void SetStep(double theStep) { return _func->SetReal(ROTATE_STEP1, theStep); }
+ void SetStep(double theStep) { _func->SetReal(ROTATE_STEP1, theStep); }
double GetStep() { return _func->GetReal(ROTATE_STEP1); }
int GetNbIter2() { return _func->GetInteger(ROTATE_NBITER2); }
+ void SetDir2 (gp_XYZ theDir2)
+ {
+ _func->SetReal(ROTATE_DIR2_X, theDir2.X());
+ _func->SetReal(ROTATE_DIR2_Y, theDir2.Y());
+ _func->SetReal(ROTATE_DIR2_Z, theDir2.Z());
+ }
+
+ gp_XYZ GetDir2()
+ {
+ gp_XYZ aRes (0., 0., 0.);
+ aRes.SetX(_func->GetReal(ROTATE_DIR2_X));
+ aRes.SetY(_func->GetReal(ROTATE_DIR2_Y));
+ aRes.SetZ(_func->GetReal(ROTATE_DIR2_Z));
+ return aRes;
+ }
private:
*/
//================================================================================
- gp_Vec GetNormal(const TopoDS_Face& face, const BRepExtrema_DistShapeShape& extrema)
+ gp_Vec GetNormal (const TopoDS_Face& face, const BRepExtrema_DistShapeShape& extrema)
{
gp_Vec defaultNorm(1,0,0); // to have same normals on different faces
try {
}
return defaultNorm;
}
+
+ //================================================================================
+ /*!
+ * \brief Return type of shape for explode. In case of compound it will be a type of sub shape.
+ */
+ //================================================================================
+
+ TopAbs_ShapeEnum GetTypeOfSimplePart (const TopoDS_Shape& theShape)
+ {
+ TopAbs_ShapeEnum aType = theShape.ShapeType();
+ if (aType == TopAbs_VERTEX) return TopAbs_VERTEX;
+ else if (aType == TopAbs_EDGE || aType == TopAbs_WIRE) return TopAbs_EDGE;
+ else if (aType == TopAbs_FACE || aType == TopAbs_SHELL) return TopAbs_FACE;
+ else if (aType == TopAbs_SOLID || aType == TopAbs_COMPSOLID) return TopAbs_SOLID;
+ else if (aType == TopAbs_COMPOUND) {
+ // Only the iType of the first shape in the compound is taken into account
+ TopoDS_Iterator It (theShape, Standard_False, Standard_False);
+ if (It.More()) {
+ return GetTypeOfSimplePart(It.Value());
+ }
+ }
+ return TopAbs_SHAPE;
+ }
}
//=============================================================================
/*!
- case GetInPlace:
- default:
+ * case GetInPlace:
+ * default:
*/
//=============================================================================
Handle(GEOM_Object) GEOMImpl_IShapesOperations::GetInPlace (Handle(GEOM_Object) theShapeWhere,
Handle(GEOM_Object) aResult;
bool isFound = false;
- Standard_Integer iType = TopAbs_SOLID;
- Standard_Integer compType = TopAbs_SOLID;
+ TopAbs_ShapeEnum iType = TopAbs_SOLID;
//Standard_Real aWhat_Mass = 0., aWhere_Mass = 0.;
Standard_Real tab_aWhat[4], tab_aWhere[4];
Standard_Real dl_l = 1e-3;
GProp_GProps aProps;
// Find the iType of the aWhat shape
+ /*
if ( aWhat.ShapeType() == TopAbs_VERTEX ) iType = TopAbs_VERTEX;
else if ( aWhat.ShapeType() == TopAbs_EDGE || aWhat.ShapeType() == TopAbs_WIRE ) iType = TopAbs_EDGE;
else if ( aWhat.ShapeType() == TopAbs_FACE || aWhat.ShapeType() == TopAbs_SHELL ) iType = TopAbs_FACE;
SetErrorCode("Error: theShapeWhat is an empty COMPOUND.");
return NULL;
}
- compType = It.Value().ShapeType();
+ TopAbs_ShapeEnum compType = It.Value().ShapeType();
if ( compType == TopAbs_VERTEX ) iType = TopAbs_VERTEX;
else if ( compType == TopAbs_EDGE || compType == TopAbs_WIRE ) iType = TopAbs_EDGE;
else if ( compType == TopAbs_FACE || compType == TopAbs_SHELL) iType = TopAbs_FACE;
SetErrorCode("Error: An attempt to extract a shape of not supported type.");
return NULL;
}
+ */
+ iType = GetTypeOfSimplePart(aWhat);
+ if (iType == TopAbs_SHAPE) {
+ SetErrorCode("Error: An attempt to extract a shape of not supported type.");
+ return NULL;
+ }
- TopExp_Explorer Exp_aWhat( aWhat, TopAbs_ShapeEnum( iType ) );
- TopExp_Explorer Exp_aWhere( aWhere, TopAbs_ShapeEnum( iType ) );
- TopExp_Explorer Exp_Edge( aWhere, TopAbs_EDGE );
+ TopExp_Explorer Exp_aWhat ( aWhat, iType );
+ TopExp_Explorer Exp_aWhere ( aWhere, iType );
+ TopExp_Explorer Exp_Edge ( aWhere, TopAbs_EDGE );
// Find the shortest edge in theShapeWhere shape
BRepBndLib::Add(aWhere, BoundingBox);
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
-//
#include <Standard_Stream.hxx>
#include <OpUtil.hxx>
#include <Utils_ExceptHandlers.hxx>
-#include <TFunction_DriverTable.hxx>
-#include <TFunction_Driver.hxx>
-#include <TFunction_Logbook.hxx>
-#include <TDF_Tool.hxx>
-
#include <GEOM_Function.hxx>
#include <GEOM_PythonDump.hxx>
#include <GEOMImpl_Types.hxx>
+#include <TFunction_DriverTable.hxx>
+#include <TFunction_Driver.hxx>
+#include <TFunction_Logbook.hxx>
+#include <TDF_Tool.hxx>
+
+#include <BRep_Tool.hxx>
+#include <BRep_Builder.hxx>
+#include <TopExp.hxx>
+#include <TopoDS.hxx>
+#include <TopoDS_Edge.hxx>
+#include <TopoDS_Vertex.hxx>
+#include <TopoDS_Compound.hxx>
+#include <gp_Pnt.hxx>
+#include <gp_Vec.hxx>
+#include <gp_Trsf.hxx>
+
+#include <StdFail_NotDone.hxx>
#include <Standard_Failure.hxx>
#include <Standard_ErrorHandler.hxx> // CAREFUL ! position of this file is critic : see Lucien PIGNOLONI / OCC
//Check if the function is set correctly
if (aFunction->GetDriverGUID() != GEOMImpl_TranslateDriver::GetID()) return NULL;
- GEOMImpl_ITranslate aTI(aFunction);
+ GEOMImpl_ITranslate aTI (aFunction);
aTI.SetVector(theVector->GetLastFunction());
aTI.SetVector2(theVector2->GetLastFunction());
aTI.SetOriginal(aLastFunction);
return aCopy;
}
+//=============================================================================
+/*!
+ * TranslateShape1D
+ */
+//=============================================================================
+/*
+TopoDS_Shape GEOMImpl_ITransformOperations::TranslateShape1D (const TopoDS_Shape& theShape,
+ GEOMImpl_ITranslate* theTI)
+{
+ TopoDS_Shape aRes;
+
+ // Vector
+ Handle(GEOM_Function) aVector = theTI->GetVector();
+ if (aVector.IsNull()) {
+ StdFail_NotDone::Raise("Invalid object is given for vector argument");
+ }
+ TopoDS_Shape aV = aVector->GetValue();
+ if (aV.IsNull() || aV.ShapeType() != TopAbs_EDGE) {
+ StdFail_NotDone::Raise("Invalid object is given for vector argument");
+ }
+ TopoDS_Edge anEdge = TopoDS::Edge(aV);
+
+ gp_Pnt aP1 = BRep_Tool::Pnt(TopExp::FirstVertex(anEdge));
+ gp_Pnt aP2 = BRep_Tool::Pnt(TopExp::LastVertex(anEdge));
+ if (aP1.Distance(aP2) < gp::Resolution()) {
+ StdFail_NotDone::Raise("Invalid object is given for vector argument");
+ }
+
+ // Step and Nb.times
+ Standard_Real step = theTI->GetStep1();
+ Standard_Integer nbtimes = theTI->GetNbIter1();
+
+ // Make multi-translation
+ gp_Trsf aTrsf;
+ gp_Vec aVec;
+ TopoDS_Compound aCompound;
+ BRep_Builder B;
+ B.MakeCompound(aCompound);
+
+ gp_Vec Vec (aP1, aP2);
+ Vec.Normalize();
+
+ TopLoc_Location aLocOrig = theShape.Location();
+ gp_Trsf aTrsfOrig = aLocOrig.Transformation();
+
+ for (int i = 0; i < nbtimes; i++) {
+ aVec = Vec * (i * step);
+ aTrsf.SetTranslation(aVec);
+ //NPAL18620: performance problem: multiple locations are accumulated
+ // in shape and need a great time to process
+ //BRepBuilderAPI_Transform aTransformation(theShape, aTrsf, Standard_False);
+ //B.Add(aCompound, aTransformation.Shape());
+ TopLoc_Location aLocRes (aTrsf * aTrsfOrig);
+ B.Add(aCompound, theShape.Located(aLocRes));
+ }
+ aRes = aCompound;
+
+ return aRes;
+}
+*/
+
+//=============================================================================
+/*!
+ * TranslateShape2D
+ */
+//=============================================================================
+/*
+TopoDS_Shape GEOMImpl_ITransformOperations::TranslateShape2D (const TopoDS_Shape& theShape,
+ GEOMImpl_ITranslate* theTI)
+{
+ TopoDS_Shape aRes;
+
+ // Vectors
+ Handle(GEOM_Function) aVector1 = theTI->GetVector();
+ Handle(GEOM_Function) aVector2 = theTI->GetVector2();
+
+ if (aVector1.IsNull() || aVector2.IsNull()) {
+ StdFail_NotDone::Raise("Invalid object is given for vector argument");
+ }
+
+ TopoDS_Shape aV1 = aVector1->GetValue();
+ TopoDS_Shape aV2 = aVector2->GetValue();
+
+ if (aV1.IsNull() || aV1.ShapeType() != TopAbs_EDGE ||
+ aV2.IsNull() || aV2.ShapeType() != TopAbs_EDGE) {
+ StdFail_NotDone::Raise("Invalid object is given for vector argument");
+ }
+
+ TopoDS_Edge anEdge1 = TopoDS::Edge(aV1);
+ TopoDS_Edge anEdge2 = TopoDS::Edge(aV2);
+
+ gp_Pnt aP11 = BRep_Tool::Pnt(TopExp::FirstVertex(anEdge1));
+ gp_Pnt aP12 = BRep_Tool::Pnt(TopExp::LastVertex(anEdge1));
+ gp_Pnt aP21 = BRep_Tool::Pnt(TopExp::FirstVertex(anEdge2));
+ gp_Pnt aP22 = BRep_Tool::Pnt(TopExp::LastVertex(anEdge2));
+
+ if (aP11.Distance(aP12) < gp::Resolution() ||
+ aP21.Distance(aP22) < gp::Resolution()) {
+ StdFail_NotDone::Raise("Invalid object is given for vector argument");
+ }
+
+ gp_Vec Vec1 (aP11, aP12);
+ gp_Vec Vec2 (aP21, aP22);
+
+ Vec1.Normalize();
+ Vec2.Normalize();
+
+ // Step and Nb.times
+ Standard_Real step1 = theTI->GetStep1(), step2 = theTI->GetStep2();
+ Standard_Integer nbtimes1 = theTI->GetNbIter1(), nbtimes2 = theTI->GetNbIter2();
+
+ // Make multi-translation
+ gp_Trsf aTrsf;
+ gp_Vec aVec;
+ Standard_Real DX, DY, DZ;
+ TopoDS_Compound aCompound;
+ BRep_Builder B;
+ B.MakeCompound(aCompound);
+
+ TopLoc_Location aLocOrig = theShape.Location();
+ gp_Trsf aTrsfOrig = aLocOrig.Transformation();
+
+ for (int i = 0; i < nbtimes1; i++) {
+ for (int j = 0; j < nbtimes2; j++) {
+ DX = i * step1 * Vec1.X() + j * step2 * Vec2.X();
+ DY = i * step1 * Vec1.Y() + j * step2 * Vec2.Y();
+ DZ = i * step1 * Vec1.Z() + j * step2 * Vec2.Z();
+ aVec.SetCoord(DX, DY, DZ);
+ aTrsf.SetTranslation(aVec);
+ //NPAL18620: performance problem: multiple locations are accumulated
+ // in shape and need a great time to process
+ //BRepBuilderAPI_Transform aBRepTransformation(theShape, aTrsf, Standard_False);
+ //B.Add(aCompound, aBRepTransformation.Shape());
+ TopLoc_Location aLocRes (aTrsf * aTrsfOrig);
+ B.Add(aCompound, theShape.Located(aLocRes));
+ }
+ }
+ aRes = aCompound;
+
+ return aRes;
+}
+*/
//=============================================================================
/*!
aFunction = aCopy->AddFunction(GEOMImpl_RotateDriver::GetID(), ROTATE_1D);
if (aFunction.IsNull()) return NULL;
- //Check if the function is set correctly
+ //Check if the function is set correctly
if (aFunction->GetDriverGUID() != GEOMImpl_RotateDriver::GetID()) return NULL;
GEOMImpl_IRotate aRI(aFunction);
return aCopy;
}
+//=============================================================================
+/*!
+ * TransformLikeOtherCopy
+ */
+//=============================================================================
+Handle(GEOM_Object) GEOMImpl_ITransformOperations::TransformLikeOtherCopy
+ (Handle(GEOM_Object) theObject,
+ Handle(GEOM_Object) theSample)
+{
+ SetErrorCode(KO);
+
+ if (theObject.IsNull() || theSample.IsNull()) return NULL;
+
+ Handle(GEOM_Function) aLastFunction = theObject->GetLastFunction();
+ if (aLastFunction.IsNull()) return NULL; // There is no function which creates an object to be transformed
+
+ Handle(GEOM_Function) aSampleFunc = theSample->GetLastFunction();
+ if (aSampleFunc.IsNull()) return NULL; // There is no function which creates a sample object
+
+ // Add a new Copy object
+ Handle(GEOM_Object) aCopy = GetEngine()->AddObject(GetDocID(), theObject->GetType());
+
+ // Add a transform function (depends on theSample function)
+ Handle(GEOM_Function) aFunction =
+ aCopy->AddFunction(aSampleFunc->GetDriverGUID(), aSampleFunc->GetType());
+ if (aFunction.IsNull()) return NULL;
+
+ // Check if the function is set correctly
+ if (aFunction->GetDriverGUID() != aSampleFunc->GetDriverGUID()) return NULL;
+
+ if (aSampleFunc->GetDriverGUID() == GEOMImpl_TranslateDriver::GetID()) {
+ switch (aSampleFunc->GetType()) {
+ case TRANSLATE_1D:
+ {
+ GEOMImpl_ITranslate aRI_sample (aSampleFunc);
+ GEOMImpl_ITranslate aRI_target (aFunction);
+
+ aRI_target.SetVector(aRI_sample.GetVector());
+ aRI_target.SetStep1(aRI_sample.GetStep1());
+ aRI_target.SetNbIter1(aRI_sample.GetNbIter1());
+
+ aRI_target.SetOriginal(aLastFunction);
+ }
+ break;
+ case TRANSLATE_2D:
+ {
+ GEOMImpl_ITranslate aRI_sample (aSampleFunc);
+ GEOMImpl_ITranslate aRI_target (aFunction);
+
+ aRI_target.SetVector(aRI_sample.GetVector());
+ aRI_target.SetStep1(aRI_sample.GetStep1());
+ aRI_target.SetNbIter1(aRI_sample.GetNbIter1());
+
+ aRI_target.SetVector2(aRI_sample.GetVector2());
+ aRI_target.SetStep2(aRI_sample.GetStep2());
+ aRI_target.SetNbIter2(aRI_sample.GetNbIter2());
+
+ aRI_target.SetOriginal(aLastFunction);
+ }
+ break;
+ default:
+ {
+ SetErrorCode("Not implemented case of TransformLikeOtherCopy");
+ return NULL;
+ }
+ }
+ }
+ else if (aSampleFunc->GetDriverGUID() == GEOMImpl_RotateDriver::GetID()) {
+ switch (aSampleFunc->GetType()) {
+ case ROTATE_1D:
+ {
+ GEOMImpl_IRotate aRI_sample (aSampleFunc);
+ GEOMImpl_IRotate aRI_target (aFunction);
+
+ aRI_target.SetAxis(aRI_sample.GetAxis());
+ aRI_target.SetNbIter1(aRI_sample.GetNbIter1());
+
+ aRI_target.SetOriginal(aLastFunction);
+ }
+ break;
+ case ROTATE_2D:
+ {
+ GEOMImpl_IRotate aRI_sample (aSampleFunc);
+ GEOMImpl_IRotate aRI_target (aFunction);
+
+ aRI_target.SetAxis(aRI_sample.GetAxis());
+
+ aRI_target.SetNbIter1(aRI_sample.GetNbIter1());
+ aRI_target.SetNbIter2(aRI_sample.GetNbIter2());
+
+ aRI_target.SetAngle(aRI_sample.GetAngle());
+ aRI_target.SetStep(aRI_sample.GetStep());
+
+ aRI_target.SetDir2(aRI_sample.GetDir2());
+
+ aRI_target.SetOriginal(aLastFunction);
+ }
+ break;
+ case ROTATE_THREE_POINTS_COPY:
+ {
+ GEOMImpl_IRotate aRI_sample (aSampleFunc);
+ GEOMImpl_IRotate aRI_target (aFunction);
+
+ aRI_target.SetCentPoint(aRI_sample.GetCentPoint());
+ aRI_target.SetPoint1(aRI_sample.GetPoint1());
+ aRI_target.SetPoint2(aRI_sample.GetPoint2());
+
+ aRI_target.SetOriginal(aLastFunction);
+ }
+ break;
+ default:
+ {
+ SetErrorCode("Not implemented case of TransformLikeOtherCopy");
+ return NULL;
+ }
+ }
+ }
+ else {
+ SetErrorCode("Not implemented case of TransformLikeOtherCopy");
+ return NULL;
+ }
+
+ // Compute the transformation
+ try {
+#if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
+ OCC_CATCH_SIGNALS;
+#endif
+ if (!GetSolver()->ComputeFunction(aFunction)) {
+ SetErrorCode("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.TransformLikeOtherCopy("
+ // << theObject << ", " << theSample << ")";
+
+ SetErrorCode(OK);
+ return aCopy;
+}
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
-//
#ifndef _GEOMImpl_ITransformOperations_HXX_
#define _GEOMImpl_ITransformOperations_HXX_
#include "GEOM_IOperations.hxx"
#include "GEOM_Engine.hxx"
#include "GEOM_Object.hxx"
+
#include <TDocStd_Document.hxx>
+#include <TopoDS_Shape.hxx>
+
+class GEOMImpl_ITranslate;
+class GEOMImpl_IRotate;
class GEOMImpl_ITransformOperations : public GEOM_IOperations
{
double theStep2,
Standard_Integer theNbTimes2);
+ /*
+ Standard_EXPORT static TopoDS_Shape TranslateShape1D (const TopoDS_Shape& theShape,
+ GEOMImpl_ITranslate* theTI);
+
+ Standard_EXPORT static TopoDS_Shape TranslateShape2D (const TopoDS_Shape& theShape,
+ GEOMImpl_ITranslate* theTI);
+ */
+
Standard_EXPORT Handle(GEOM_Object) MirrorPlane (Handle(GEOM_Object) theObject,
Handle(GEOM_Object) thePlane);
Handle(GEOM_Object) thePoint1,
Handle(GEOM_Object) thePoint2);
+ Standard_EXPORT Handle(GEOM_Object) TransformLikeOtherCopy (Handle(GEOM_Object) theObject,
+ Handle(GEOM_Object) theSample);
+
};
#endif
gp_Ax1 AX1(aP1, D);
-
gp_Trsf aTrsf1;
gp_Trsf aTrsf2;
- gp_Pnt P1;
- GProp_GProps System;
- if (anOriginal.ShapeType() == TopAbs_VERTEX) {
- P1 = BRep_Tool::Pnt(TopoDS::Vertex( anOriginal ));
- }
- else if ( anOriginal.ShapeType() == TopAbs_EDGE || anOriginal.ShapeType() == TopAbs_WIRE ) {
- BRepGProp::LinearProperties(anOriginal, System);
- P1 = System.CentreOfMass();
- }
- else if ( anOriginal.ShapeType() == TopAbs_FACE || anOriginal.ShapeType() == TopAbs_SHELL ) {
- BRepGProp::SurfaceProperties(anOriginal, System);
- P1 = System.CentreOfMass();
- }
- else {
- BRepGProp::VolumeProperties(anOriginal, System);
- P1 = System.CentreOfMass();
- }
+ gp_XYZ aDir2 = RI.GetDir2(); // can be set by previous execution
+ if (aDir2.Modulus() < gp::Resolution()) {
+ // Calculate direction as vector from the axis to the shape's center
+ gp_Pnt P1;
+ GProp_GProps System;
+
+ if (anOriginal.ShapeType() == TopAbs_VERTEX) {
+ P1 = BRep_Tool::Pnt(TopoDS::Vertex( anOriginal ));
+ }
+ else if ( anOriginal.ShapeType() == TopAbs_EDGE || anOriginal.ShapeType() == TopAbs_WIRE ) {
+ BRepGProp::LinearProperties(anOriginal, System);
+ P1 = System.CentreOfMass();
+ }
+ else if ( anOriginal.ShapeType() == TopAbs_FACE || anOriginal.ShapeType() == TopAbs_SHELL ) {
+ BRepGProp::SurfaceProperties(anOriginal, System);
+ P1 = System.CentreOfMass();
+ }
+ else {
+ BRepGProp::VolumeProperties(anOriginal, System);
+ P1 = System.CentreOfMass();
+ }
- Handle(Geom_Line) Line = new Geom_Line(AX1);
- GeomAPI_ProjectPointOnCurve aPrjTool( P1, Line );
- gp_Pnt P2 = aPrjTool.NearestPoint();
+ Handle(Geom_Line) Line = new Geom_Line(AX1);
+ GeomAPI_ProjectPointOnCurve aPrjTool( P1, Line );
+ gp_Pnt P2 = aPrjTool.NearestPoint();
- if ( P1.IsEqual(P2, Precision::Confusion() ) ) return 0;
+ if ( P1.IsEqual(P2, Precision::Confusion() ) ) return 0;
+
+ aDir2 = gp_XYZ(P1.X()-P2.X(), P1.Y()-P2.Y(), P1.Z()-P2.Z());
+
+ // Attention: this abnormal action is done for good working of
+ // TransformLikeOther(), used by RestoreSubShapes functionality
+ RI.SetDir2(aDir2);
+ }
- gp_Vec Vec (P1.X()-P2.X(), P1.Y()-P2.Y(), P1.Z()-P2.Z());
+ gp_Vec Vec (aDir2);
Vec.Normalize();
Standard_Integer nbtimes2 = RI.GetNbIter2();
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
-//
#include <Standard_Stream.hxx>
#include <GEOMImpl_TranslateDriver.hxx>
#include <GEOMImpl_ITranslate.hxx>
+#include <GEOMImpl_ITransformOperations.hxx>
#include <GEOMImpl_Types.hxx>
#include <GEOM_Function.hxx>
if (aFunction.IsNull()) return 0;
- GEOMImpl_ITranslate TI(aFunction);
+ GEOMImpl_ITranslate TI (aFunction);
gp_Trsf aTrsf;
gp_Pnt aP1, aP2;
Standard_Integer aType = aFunction->GetType();
B.Add(aCompound, anOriginal.Located(aLocRes));
}
aShape = aCompound;
+ //aShape = GEOMImpl_ITransformOperations::TranslateShape1D(anOriginal, &TI);
}
else if (aType == TRANSLATE_2D) {
Standard_Integer nbtimes1 = TI.GetNbIter1(), nbtimes2 = TI.GetNbIter2();
B.Add(aCompound, anOriginal.Located(aLocRes));
}
}
- aShape = aCompound;
+ aShape = aCompound;
+ //aShape = GEOMImpl_ITransformOperations::TranslateShape2D(anOriginal, &TI);
}
else return 0;
}
else {
// Get interface, containing method, which we will use to reconstruct sub-shapes
- GEOM::GEOM_IShapesOperations_var aShapesOp = GetIShapesOperations(theStudy->StudyId());
- GEOM::GEOM_IGroupOperations_var aGroupOp = GetIGroupOperations(theStudy->StudyId());
+ GEOM::GEOM_IShapesOperations_var aShapesOp = GetIShapesOperations(theStudy->StudyId());
+ GEOM::GEOM_IGroupOperations_var aGroupOp = GetIGroupOperations(theStudy->StudyId());
+ GEOM::GEOM_ITransformOperations_var aTrsfOp = GetITransformOperations(theStudy->StudyId());
// Reconstruct arguments and tree of sub-shapes of the arguments
CORBA::String_var anIOR;
aSubO = aShapesOp->GetInPlace(theObject, anArgO);
}
break;
+ case GEOM::FSM_MultiTransformed:
+ {
+ // Only for Multi-transformations
+ GEOM::GEOM_Object_var anArgOTrsf = aTrsfOp->TransformLikeOtherCopy(anArgO, theObject);
+ if (!CORBA::is_nil(anArgOTrsf)) {
+ CORBA::String_var anArgOTrsfEntry = anArgOTrsf->GetEntry();
+ Handle(GEOM_Object) anArgOTrsfImpl = _impl->GetObject(anArgOTrsf->GetStudyID(), anArgOTrsfEntry);
+ Handle(GEOM_Function) anArgOTrsfFun = anArgOTrsfImpl->GetLastFunction();
+ anArgOTrsfFun->SetDescription("");
+ aSubO = aShapesOp->GetInPlace(theObject, anArgOTrsf);
+ }
+ /*
+ Handle(GEOM_Function) anOFun = theObject->GetLastFunction();
+ if (!anOFun.IsNull()) {
+ CORBA::String_var entryArg = anArgO->GetEntry();
+ Handle(GEOM_Object) anArgOImpl = _impl->GetObject(anArgO->GetStudyID(), entryArg);
+ if (!anArgOImpl.IsNull()) {
+ TopoDS_Shape anArgOShape = anArgOImpl->GetValue();
+ TopoDS_Shape aMultiArgShape;
+ //GEOM::GEOM_Object_var anArgOMulti; // ???
+ switch (anOFun->GetType()) {
+ case TRANSLATE_1D:
+ {
+ GEOMImpl_ITranslate aTI (anOFun);
+ aMultiArgShape = GEOMImpl_ITransformOperations::TranslateShape1D(anArgOShape, &aTI);
+ //anArgOMulti = aTrsfOp->Translate1D(anArgO, , , );
+ }
+ break;
+ case TRANSLATE_2D:
+ {
+ GEOMImpl_ITranslate aTI (anOFun);
+ aMultiArgShape = GEOMImpl_ITransformOperations::TranslateShape2D(anArgOShape, &aTI);
+ }
+ break;
+ case ROTATE_1D:
+ {
+ GEOMImpl_IRotate aTI (anOFun);
+ //aMultiArgShape = GEOMImpl_ITransformOperations::TranslateShape2D(anArgOShape, &aTI);
+ }
+ break;
+ case ROTATE_2D:
+ {
+ GEOMImpl_IRotate aTI (anOFun);
+ //aMultiArgShape = GEOMImpl_ITransformOperations::TranslateShape2D(anArgOShape, &aTI);
+ }
+ break;
+ default:
+ {}
+ }
+ GEOM::GEOM_Object_var anArgOMulti = (aMultiArgShape); // TODO
+ Handle(GEOM_Function) anArgOMultiFun = anArgOMulti->GetLastFunction();
+ anArgOMultiFun->SetDescription("");
+ aSubO = aShapesOp->GetInPlace(theObject, anArgOMulti);
+ }
+ }
+ */
+ }
+ break;
case GEOM::FSM_Transformed:
{
// transformation, cannot use GetInPlace, operate with indices
switch (theFindMethod) {
case GEOM::FSM_GetInPlace:
pd << "FSM_GetInPlace"; break;
+ case GEOM::FSM_MultiTransformed:
+ pd << "FSM_MultiTransformed"; break;
case GEOM::FSM_Transformed:
pd << "FSM_Transformed"; break;
case GEOM::FSM_GetSame:
SALOMEDS::StudyBuilder_var aStudyBuilder = theStudy->NewBuilder();
// Get interface, containing method, which we will use to reconstruct sub-shapes
- GEOM::GEOM_IShapesOperations_var aShapesOp = GetIShapesOperations(theStudy->StudyId());
- GEOM::GEOM_IGroupOperations_var aGroupOp = GetIGroupOperations(theStudy->StudyId());
+ GEOM::GEOM_IShapesOperations_var aShapesOp = GetIShapesOperations(theStudy->StudyId());
+ GEOM::GEOM_IGroupOperations_var aGroupOp = GetIGroupOperations(theStudy->StudyId());
+ GEOM::GEOM_ITransformOperations_var aTrsfOp = GetITransformOperations(theStudy->StudyId());
// Reconstruct published sub-shapes
SALOMEDS::ChildIterator_var it = theStudy->NewChildIterator(theOldSO);
aNewSubO = aShapesOp->GetInPlace(theNewO, anOldSubO);
}
break;
+ case GEOM::FSM_MultiTransformed:
+ {
+ // Only for Multi-transformations
+ GEOM::GEOM_Object_var anArgOTrsf = aTrsfOp->TransformLikeOtherCopy(anOldSubO, theNewO);
+ if (!CORBA::is_nil(anArgOTrsf)) {
+ CORBA::String_var anArgOTrsfEntry = anArgOTrsf->GetEntry();
+ Handle(GEOM_Object) anArgOTrsfImpl = _impl->GetObject(anArgOTrsf->GetStudyID(), anArgOTrsfEntry);
+ Handle(GEOM_Function) anArgOTrsfFun = anArgOTrsfImpl->GetLastFunction();
+ anArgOTrsfFun->SetDescription("");
+ aNewSubO = aShapesOp->GetInPlace(theNewO, anArgOTrsf);
+ }
+ }
+ break;
case GEOM::FSM_Transformed:
{
// transformation, cannot use GetInPlace, operate with indices
}
else {
// Get interface, containing method, which we will use to reconstruct sub-shapes
- GEOM::GEOM_IShapesOperations_var aShapesOp = GetIShapesOperations(theStudy->StudyId());
- GEOM::GEOM_IGroupOperations_var aGroupOp = GetIGroupOperations(theStudy->StudyId());
+ GEOM::GEOM_IShapesOperations_var aShapesOp = GetIShapesOperations(theStudy->StudyId());
+ GEOM::GEOM_IGroupOperations_var aGroupOp = GetIGroupOperations(theStudy->StudyId());
+ GEOM::GEOM_ITransformOperations_var aTrsfOp = GetITransformOperations(theStudy->StudyId());
// Reconstruct arguments and tree of sub-shapes of the arguments
CORBA::String_var anIOR;
aSubO = aShapesOp->GetInPlace(theObject, anArgO);
}
break;
+ case GEOM::FSM_MultiTransformed:
+ {
+ // Only for Multi-transformations
+ GEOM::GEOM_Object_var anArgOTrsf = aTrsfOp->TransformLikeOtherCopy(anArgO, theObject);
+ if (!CORBA::is_nil(anArgOTrsf)) {
+ CORBA::String_var anArgOTrsfEntry = anArgOTrsf->GetEntry();
+ Handle(GEOM_Object) anArgOTrsfImpl = _impl->GetObject(anArgOTrsf->GetStudyID(), anArgOTrsfEntry);
+ Handle(GEOM_Function) anArgOTrsfFun = anArgOTrsfImpl->GetLastFunction();
+ anArgOTrsfFun->SetDescription("");
+ aSubO = aShapesOp->GetInPlace(theObject, anArgOTrsf);
+ }
+ }
+ break;
case GEOM::FSM_Transformed:
{
// transformation, cannot use GetInPlace, operate with indices
switch (theFindMethod) {
case GEOM::FSM_GetInPlace:
pd << "FSM_GetInPlace"; break;
+ case GEOM::FSM_MultiTransformed:
+ pd << "FSM_MultiTransformed"; break;
case GEOM::FSM_Transformed:
pd << "FSM_Transformed"; break;
case GEOM::FSM_GetSame:
SALOMEDS::StudyBuilder_var aStudyBuilder = theStudy->NewBuilder();
// Get interface, containing method, which we will use to reconstruct sub-shapes
- GEOM::GEOM_IShapesOperations_var aShapesOp = GetIShapesOperations(theStudy->StudyId());
- GEOM::GEOM_IGroupOperations_var aGroupOp = GetIGroupOperations(theStudy->StudyId());
+ GEOM::GEOM_IShapesOperations_var aShapesOp = GetIShapesOperations(theStudy->StudyId());
+ GEOM::GEOM_IGroupOperations_var aGroupOp = GetIGroupOperations(theStudy->StudyId());
+ GEOM::GEOM_ITransformOperations_var aTrsfOp = GetITransformOperations(theStudy->StudyId());
// Reconstruct published sub-shapes
SALOMEDS::ChildIterator_var it = theStudy->NewChildIterator(theOldSO);
aNewSubO = aShapesOp->GetInPlace(theNewO, anOldSubO);
}
break;
+ case GEOM::FSM_MultiTransformed:
+ {
+ // Only for Multi-transformations
+ GEOM::GEOM_Object_var anArgOTrsf = aTrsfOp->TransformLikeOtherCopy(anOldSubO, theNewO);
+ if (!CORBA::is_nil(anArgOTrsf)) {
+ CORBA::String_var anArgOTrsfEntry = anArgOTrsf->GetEntry();
+ Handle(GEOM_Object) anArgOTrsfImpl = _impl->GetObject(anArgOTrsf->GetStudyID(), anArgOTrsfEntry);
+ Handle(GEOM_Function) anArgOTrsfFun = anArgOTrsfImpl->GetLastFunction();
+ anArgOTrsfFun->SetDescription("");
+ aNewSubO = aShapesOp->GetInPlace(theNewO, anArgOTrsf);
+ }
+ }
+ break;
case GEOM::FSM_Transformed:
{
// transformation, cannot use GetInPlace, operate with indices
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
-//
#include <Standard_Stream.hxx>
return GetObject(anObject);
}
+//=============================================================================
+/*!
+ * TransformLikeOtherCopy
+ */
+//=============================================================================
+GEOM::GEOM_Object_ptr GEOM_ITransformOperations_i::TransformLikeOtherCopy
+ (GEOM::GEOM_Object_ptr theObject,
+ GEOM::GEOM_Object_ptr theSample)
+{
+ GEOM::GEOM_Object_var aGEOMObject;
+
+ //Set a not done flag
+ GetOperations()->SetNotDone();
+
+ //Get the object itself
+ Handle(GEOM_Object) anObject = GetObjectImpl(theObject);
+ if (anObject.IsNull()) return aGEOMObject._retn();
+
+ //Get the sample object
+ Handle(GEOM_Object) aSample = GetObjectImpl(theSample);
+ if (aSample.IsNull()) return aGEOMObject._retn();
+
+ //Perform the transformation
+ Handle(GEOM_Object) aResObject =
+ GetOperations()->TransformLikeOtherCopy(anObject, aSample);
+ if (!GetOperations()->IsDone() || aResObject.IsNull())
+ return aGEOMObject._retn();
+
+ return GetObject(aResObject);
+}
+
//=============================================================================
/*!
* RecomputeObject
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
-//
#ifndef _GEOM_ITransformOperations_i_HeaderFile
#define _GEOM_ITransformOperations_i_HeaderFile
GEOM::GEOM_Object_ptr thePoint1,
GEOM::GEOM_Object_ptr thePoint2);
- GEOM::GEOM_Object_ptr TranslateDXDYDZ (GEOM::GEOM_Object_ptr theObject, CORBA::Double theDX, CORBA::Double theDY, CORBA::Double theDZ);
+ GEOM::GEOM_Object_ptr TranslateDXDYDZ (GEOM::GEOM_Object_ptr theObject,
+ CORBA::Double theDX, CORBA::Double theDY, CORBA::Double theDZ);
- GEOM::GEOM_Object_ptr TranslateDXDYDZCopy (GEOM::GEOM_Object_ptr theObject, CORBA::Double theDX, CORBA::Double theDY, CORBA::Double theDZ);
+ GEOM::GEOM_Object_ptr TranslateDXDYDZCopy (GEOM::GEOM_Object_ptr theObject,
+ CORBA::Double theDX, CORBA::Double theDY, CORBA::Double theDZ);
GEOM::GEOM_Object_ptr TranslateVector (GEOM::GEOM_Object_ptr theObject,
GEOM::GEOM_Object_ptr theVector);
CORBA::Double theDistance,
CORBA::Boolean theCopy);
- GEOM::GEOM_Object_ptr MultiTranslate1D (GEOM::GEOM_Object_ptr theObject, GEOM::GEOM_Object_ptr theVector, CORBA::Double theStep, CORBA::Long theNbTimes);
+ GEOM::GEOM_Object_ptr MultiTranslate1D (GEOM::GEOM_Object_ptr theObject,
+ GEOM::GEOM_Object_ptr theVector,
+ CORBA::Double theStep, CORBA::Long theNbTimes);
- GEOM::GEOM_Object_ptr MultiTranslate2D (GEOM::GEOM_Object_ptr theObject, GEOM::GEOM_Object_ptr theVector1, CORBA::Double theStep1, CORBA::Long theNbTimes1,
- GEOM::GEOM_Object_ptr theVector2, CORBA::Double theStep2, CORBA::Long theNbTimes2);
+ GEOM::GEOM_Object_ptr MultiTranslate2D (GEOM::GEOM_Object_ptr theObject,
+ GEOM::GEOM_Object_ptr theVector1,
+ CORBA::Double theStep1, CORBA::Long theNbTimes1,
+ GEOM::GEOM_Object_ptr theVector2,
+ CORBA::Double theStep2, CORBA::Long theNbTimes2);
GEOM::GEOM_Object_ptr Rotate (GEOM::GEOM_Object_ptr theObject,
GEOM::GEOM_Object_ptr theAxis,
GEOM::GEOM_Object_ptr thePoint1,
GEOM::GEOM_Object_ptr thePoint2);
+ GEOM::GEOM_Object_ptr TransformLikeOtherCopy (GEOM::GEOM_Object_ptr theObject,
+ GEOM::GEOM_Object_ptr theSample);
+
GEOM::GEOM_Object_ptr RecomputeObject (GEOM::GEOM_Object_ptr theObject);
anArgs->length(1);
anArgs[0] = myBase;
getGeomEngine()->RestoreSubShapesSO(theStudy, theSObject, anArgs,
- /*theFindMethod=*/GEOM::FSM_GetInPlace,
- /*theInheritFirstArg=*/false,
+ /*theFindMethod=*/GEOM::FSM_MultiTransformed,
+ /*theInheritFirstArg=*/true,
mainFrame()->CheckBoxAddPrefix->isChecked());
}
}
anArgs->length(1);
anArgs[0] = myBase;
getGeomEngine()->RestoreSubShapesSO(theStudy, theSObject, anArgs,
- /*theFindMethod=*/GEOM::FSM_GetInPlace,
- /*theInheritFirstArg=*/false,
+ /*theFindMethod=*/GEOM::FSM_MultiTransformed,
+ /*theInheritFirstArg=*/true,
mainFrame()->CheckBoxAddPrefix->isChecked());
}
}