X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FGEOMImpl%2FGEOMImpl_ITransformOperations.cxx;h=012d9982d1d816a748d65db1391ea584d972a3ab;hb=33eddb946d773271e86d77267212c204fd32af4a;hp=89c1d2b9c83cd6e0edcc0372a842c4489befc6dc;hpb=7d880c6a8262b6d670ed70ee2b9ec25c199a46d4;p=modules%2Fgeom.git diff --git a/src/GEOMImpl/GEOMImpl_ITransformOperations.cxx b/src/GEOMImpl/GEOMImpl_ITransformOperations.cxx index 89c1d2b9c..012d9982d 100644 --- a/src/GEOMImpl/GEOMImpl_ITransformOperations.cxx +++ b/src/GEOMImpl/GEOMImpl_ITransformOperations.cxx @@ -129,9 +129,7 @@ Handle(GEOM_Object) GEOMImpl_ITransformOperations::TranslateTwoPoints //Compute the translation try { -#if OCC_VERSION_LARGE > 0x06010000 OCC_CATCH_SIGNALS; -#endif if (!GetSolver()->ComputeFunction(aFunction)) { SetErrorCode("Translation driver failed"); return NULL; @@ -182,9 +180,7 @@ Handle(GEOM_Object) GEOMImpl_ITransformOperations::TranslateDXDYDZ //Compute the translation try { -#if OCC_VERSION_LARGE > 0x06010000 OCC_CATCH_SIGNALS; -#endif if (!GetSolver()->ComputeFunction(aFunction)) { SetErrorCode("Translation driver failed"); return NULL; @@ -238,9 +234,7 @@ Handle(GEOM_Object) GEOMImpl_ITransformOperations::TranslateTwoPointsCopy //Compute the translation try { -#if OCC_VERSION_LARGE > 0x06010000 OCC_CATCH_SIGNALS; -#endif if (!GetSolver()->ComputeFunction(aFunction)) { SetErrorCode("Translation driver failed"); return NULL; @@ -293,9 +287,7 @@ Handle(GEOM_Object) GEOMImpl_ITransformOperations::TranslateDXDYDZCopy //Compute the translation try { -#if OCC_VERSION_LARGE > 0x06010000 OCC_CATCH_SIGNALS; -#endif if (!GetSolver()->ComputeFunction(aFunction)) { SetErrorCode("Translation driver failed"); return NULL; @@ -348,9 +340,7 @@ Handle(GEOM_Object) GEOMImpl_ITransformOperations::TranslateVector //Compute the translation try { -#if OCC_VERSION_LARGE > 0x06010000 OCC_CATCH_SIGNALS; -#endif if (!GetSolver()->ComputeFunction(aFunction)) { SetErrorCode("Translation driver failed"); return NULL; @@ -401,9 +391,7 @@ Handle(GEOM_Object) GEOMImpl_ITransformOperations::TranslateVectorCopy //Compute the translation try { -#if OCC_VERSION_LARGE > 0x06010000 OCC_CATCH_SIGNALS; -#endif if (!GetSolver()->ComputeFunction(aFunction)) { SetErrorCode("Translation driver failed"); return NULL; @@ -462,9 +450,7 @@ Handle(GEOM_Object) GEOMImpl_ITransformOperations::TranslateVectorDistance //Compute the translation try { -#if OCC_VERSION_LARGE > 0x06010000 OCC_CATCH_SIGNALS; -#endif if (!GetSolver()->ComputeFunction(aFunction)) { SetErrorCode("Translation driver failed"); return NULL; @@ -525,9 +511,7 @@ Handle(GEOM_Object) GEOMImpl_ITransformOperations::Translate1D //Compute the translation try { -#if OCC_VERSION_LARGE > 0x06010000 OCC_CATCH_SIGNALS; -#endif if (!GetSolver()->ComputeFunction(aFunction)) { SetErrorCode("Translation driver failed"); return NULL; @@ -590,9 +574,7 @@ Handle(GEOM_Object) GEOMImpl_ITransformOperations::Translate2D (Handle(GEOM_Obje //Compute the translation try { -#if OCC_VERSION_LARGE > 0x06010000 OCC_CATCH_SIGNALS; -#endif if (!GetSolver()->ComputeFunction(aFunction)) { SetErrorCode("Translation driver failed"); return NULL; @@ -788,9 +770,7 @@ Handle(GEOM_Object) GEOMImpl_ITransformOperations::MirrorPlane //Compute the mirror try { -#if OCC_VERSION_LARGE > 0x06010000 OCC_CATCH_SIGNALS; -#endif if (!GetSolver()->ComputeFunction(aFunction)) { SetErrorCode("Mirror driver failed"); return NULL; @@ -841,9 +821,7 @@ Handle(GEOM_Object) GEOMImpl_ITransformOperations::MirrorPlaneCopy //Compute the mirror try { -#if OCC_VERSION_LARGE > 0x06010000 OCC_CATCH_SIGNALS; -#endif if (!GetSolver()->ComputeFunction(aFunction)) { SetErrorCode("Mirror driver failed"); return NULL; @@ -895,9 +873,7 @@ Handle(GEOM_Object) GEOMImpl_ITransformOperations::MirrorPoint //Compute the mirror try { -#if OCC_VERSION_LARGE > 0x06010000 OCC_CATCH_SIGNALS; -#endif if (!GetSolver()->ComputeFunction(aFunction)) { SetErrorCode("Mirror driver failed"); return NULL; @@ -948,9 +924,7 @@ Handle(GEOM_Object) GEOMImpl_ITransformOperations::MirrorPointCopy //Compute the mirror try { -#if OCC_VERSION_LARGE > 0x06010000 OCC_CATCH_SIGNALS; -#endif if (!GetSolver()->ComputeFunction(aFunction)) { SetErrorCode("Mirror driver failed"); return NULL; @@ -1002,9 +976,7 @@ Handle(GEOM_Object) GEOMImpl_ITransformOperations::MirrorAxis //Compute the mirror try { -#if OCC_VERSION_LARGE > 0x06010000 OCC_CATCH_SIGNALS; -#endif if (!GetSolver()->ComputeFunction(aFunction)) { SetErrorCode("Mirror driver failed"); return NULL; @@ -1055,9 +1027,7 @@ Handle(GEOM_Object) GEOMImpl_ITransformOperations::MirrorAxisCopy //Compute the mirror try { -#if OCC_VERSION_LARGE > 0x06010000 OCC_CATCH_SIGNALS; -#endif if (!GetSolver()->ComputeFunction(aFunction)) { SetErrorCode("Mirror driver failed"); return NULL; @@ -1107,9 +1077,7 @@ Handle(GEOM_Object) GEOMImpl_ITransformOperations::OffsetShape //Compute the offset try { -#if OCC_VERSION_LARGE > 0x06010000 OCC_CATCH_SIGNALS; -#endif if (!GetSolver()->ComputeFunction(aFunction)) { SetErrorCode("Offset driver failed"); return NULL; @@ -1161,9 +1129,7 @@ Handle(GEOM_Object) GEOMImpl_ITransformOperations::OffsetShapeCopy //Compute the offset try { -#if OCC_VERSION_LARGE > 0x06010000 OCC_CATCH_SIGNALS; -#endif if (!GetSolver()->ComputeFunction(aFunction)) { SetErrorCode("Offset driver failed"); return NULL; @@ -1189,8 +1155,9 @@ Handle(GEOM_Object) GEOMImpl_ITransformOperations::OffsetShapeCopy * ProjectShapeCopy */ //============================================================================= -Handle(GEOM_Object) GEOMImpl_ITransformOperations::ProjectShapeCopy - (Handle(GEOM_Object) theSource, Handle(GEOM_Object) theTarget) +Handle(GEOM_Object) +GEOMImpl_ITransformOperations::ProjectShapeCopy (Handle(GEOM_Object) theSource, + Handle(GEOM_Object) theTarget) { SetErrorCode(KO); @@ -1199,37 +1166,54 @@ Handle(GEOM_Object) GEOMImpl_ITransformOperations::ProjectShapeCopy Handle(GEOM_Function) aLastFunction = theSource->GetLastFunction(); if (aLastFunction.IsNull()) return NULL; //There is no function which creates an object to be projected - //Add a new Projection object - Handle(GEOM_Object) aCopy = GetEngine()->AddObject(GetDocID(), GEOM_PROJECTION); + Handle(GEOM_Object) aCopy; - //Add a Projection function - Handle(GEOM_Function) aFunction = - aCopy->AddFunction(GEOMImpl_ProjectionDriver::GetID(), PROJECTION_COPY); + TopoDS_Shape aTarget = theTarget->GetValue(); + if ( aTarget.IsNull() ) return NULL; + if ( aTarget.ShapeType() == TopAbs_EDGE || + aTarget.ShapeType() == TopAbs_WIRE ) + { + // a TPythonDump prevents dumping ProjectPointOnWire(), + // dump of MakeProjection() is done at the end of this function + GEOM::TPythonDump preventDump(aLastFunction, /*append=*/true); + Standard_Integer dummy; + ProjectPointOnWire( theSource, theTarget, aCopy, dummy ); + if ( aCopy.IsNull() || !IsDone() ) + return NULL; + } + else + { + //Add a new Projection object + aCopy = GetEngine()->AddObject(GetDocID(), GEOM_PROJECTION); - //Check if the function is set correctly - if (aFunction->GetDriverGUID() != GEOMImpl_ProjectionDriver::GetID()) return NULL; + //Add a Projection function + Handle(GEOM_Function) aFunction = + aCopy->AddFunction(GEOMImpl_ProjectionDriver::GetID(), PROJECTION_COPY); - GEOMImpl_IMirror aTI (aFunction); - aTI.SetPlane(theTarget->GetLastFunction()); - aTI.SetOriginal(aLastFunction); + //Check if the function is set correctly + if (aFunction->GetDriverGUID() != GEOMImpl_ProjectionDriver::GetID()) return NULL; - //Compute the Projection - try { -#if OCC_VERSION_LARGE > 0x06010000 - OCC_CATCH_SIGNALS; -#endif - if (!GetSolver()->ComputeFunction(aFunction)) { - SetErrorCode("Projection driver failed"); + GEOMImpl_IMirror aTI (aFunction); + aTI.SetPlane(theTarget->GetLastFunction()); + aTI.SetOriginal(aLastFunction); + + //Compute the Projection + try { + OCC_CATCH_SIGNALS; + if (!GetSolver()->ComputeFunction(aFunction)) { + SetErrorCode("Projection driver failed"); + return NULL; + } + } + catch (Standard_Failure) { + Handle(Standard_Failure) aFail = Standard_Failure::Caught(); + SetErrorCode(aFail->GetMessageString()); return NULL; } } - catch (Standard_Failure) { - Handle(Standard_Failure) aFail = Standard_Failure::Caught(); - SetErrorCode(aFail->GetMessageString()); - return NULL; - } //Make a Python command + Handle(GEOM_Function) aFunction = aCopy->GetLastFunction(); GEOM::TPythonDump(aFunction) << aCopy << " = geompy.MakeProjection(" << theSource << ", " << theTarget << ")"; @@ -1281,9 +1265,7 @@ Standard_Real GEOMImpl_ITransformOperations::ProjectPointOnWire //Compute the Projection try { -#if OCC_VERSION_LARGE > 0x06010000 OCC_CATCH_SIGNALS; -#endif if (!GetSolver()->ComputeFunction(aFunction)) { SetErrorCode("Projection driver failed"); return aResult; @@ -1345,9 +1327,7 @@ Handle(GEOM_Object) GEOMImpl_ITransformOperations::ScaleShape //Compute the scale try { -#if OCC_VERSION_LARGE > 0x06010000 OCC_CATCH_SIGNALS; -#endif if (!GetSolver()->ComputeFunction(aFunction)) { SetErrorCode("Scale driver failed"); return NULL; @@ -1406,9 +1386,7 @@ Handle(GEOM_Object) GEOMImpl_ITransformOperations::ScaleShapeCopy //Compute the scale try { -#if OCC_VERSION_LARGE > 0x06010000 OCC_CATCH_SIGNALS; -#endif if (!GetSolver()->ComputeFunction(aFunction)) { SetErrorCode("Scale driver failed"); return NULL; @@ -1477,9 +1455,7 @@ Handle(GEOM_Object) GEOMImpl_ITransformOperations::ScaleShapeAlongAxes (Handle(G //Compute the scale try { -#if OCC_VERSION_LARGE > 0x06010000 OCC_CATCH_SIGNALS; -#endif if (!GetSolver()->ComputeFunction(aFunction)) { SetErrorCode("Scale driver failed"); return NULL; @@ -1542,9 +1518,7 @@ Handle(GEOM_Object) GEOMImpl_ITransformOperations::PositionShape //Compute the Position try { -#if OCC_VERSION_LARGE > 0x06010000 OCC_CATCH_SIGNALS; -#endif if (!GetSolver()->ComputeFunction(aFunction)) { SetErrorCode("Position driver failed"); return NULL; @@ -1601,9 +1575,7 @@ Handle(GEOM_Object) GEOMImpl_ITransformOperations::PositionShapeCopy //Compute the position try { -#if OCC_VERSION_LARGE > 0x06010000 OCC_CATCH_SIGNALS; -#endif if (!GetSolver()->ComputeFunction(aFunction)) { SetErrorCode("Position driver failed"); return NULL; @@ -1663,9 +1635,7 @@ Handle(GEOM_Object) GEOMImpl_ITransformOperations::PositionAlongPath //Compute the position try { -#if OCC_VERSION_LARGE > 0x06010000 OCC_CATCH_SIGNALS; -#endif if (!GetSolver()->ComputeFunction(aFunction)) { SetErrorCode("Position driver failed"); return NULL; @@ -1726,9 +1696,7 @@ Handle(GEOM_Object) GEOMImpl_ITransformOperations::Rotate (Handle(GEOM_Object) t //Compute the translation try { -#if OCC_VERSION_LARGE > 0x06010000 OCC_CATCH_SIGNALS; -#endif if (!GetSolver()->ComputeFunction(aFunction)) { SetErrorCode("Rotate driver failed"); return NULL; @@ -1781,9 +1749,7 @@ Handle(GEOM_Object) GEOMImpl_ITransformOperations::RotateCopy (Handle(GEOM_Objec //Compute the translation try { -#if OCC_VERSION_LARGE > 0x06010000 OCC_CATCH_SIGNALS; -#endif if (!GetSolver()->ComputeFunction(aFunction)) { SetErrorCode("Rotate driver failed"); return NULL; @@ -1837,9 +1803,7 @@ Handle(GEOM_Object) GEOMImpl_ITransformOperations::Rotate1D (Handle(GEOM_Object) //Compute the translation try { -#if OCC_VERSION_LARGE > 0x06010000 OCC_CATCH_SIGNALS; -#endif if (!GetSolver()->ComputeFunction(aFunction)) { SetErrorCode("Rotate driver failed"); return NULL; @@ -1898,9 +1862,7 @@ Handle(GEOM_Object) GEOMImpl_ITransformOperations::Rotate1D (Handle(GEOM_Object) //Compute the translation try { -#if OCC_VERSION_LARGE > 0x06010000 OCC_CATCH_SIGNALS; -#endif if (!GetSolver()->ComputeFunction(aFunction)) { SetErrorCode("Rotate driver failed"); return NULL; @@ -1962,9 +1924,7 @@ Handle(GEOM_Object) GEOMImpl_ITransformOperations::Rotate2D (Handle(GEOM_Object) //Compute the translation try { -#if OCC_VERSION_LARGE > 0x06010000 OCC_CATCH_SIGNALS; -#endif if (!GetSolver()->ComputeFunction(aFunction)) { SetErrorCode("Rotate driver failed"); return NULL; @@ -2028,9 +1988,7 @@ Handle(GEOM_Object) GEOMImpl_ITransformOperations::Rotate2D (Handle(GEOM_Object) //Compute the translation try { -#if OCC_VERSION_LARGE > 0x06010000 OCC_CATCH_SIGNALS; -#endif if (!GetSolver()->ComputeFunction(aFunction)) { SetErrorCode("Rotate driver failed"); return NULL; @@ -2091,9 +2049,7 @@ Handle(GEOM_Object) GEOMImpl_ITransformOperations::RotateThreePoints (Handle(GEO //Compute the translation try { -#if OCC_VERSION_LARGE > 0x06010000 OCC_CATCH_SIGNALS; -#endif if (!GetSolver()->ComputeFunction(aFunction)) { SetErrorCode("Rotate driver failed"); return NULL; @@ -2148,9 +2104,7 @@ Handle(GEOM_Object) GEOMImpl_ITransformOperations::RotateThreePointsCopy (Handle //Compute the translation try { -#if OCC_VERSION_LARGE > 0x06010000 OCC_CATCH_SIGNALS; -#endif if (!GetSolver()->ComputeFunction(aFunction)) { SetErrorCode("Rotate driver failed"); return NULL; @@ -2294,9 +2248,7 @@ Handle(GEOM_Object) GEOMImpl_ITransformOperations::TransformLikeOtherCopy // Compute the transformation try { -#if OCC_VERSION_LARGE > 0x06010000 OCC_CATCH_SIGNALS; -#endif if (!GetSolver()->ComputeFunction(aFunction)) { SetErrorCode("Driver failed"); return NULL;