diff --git a/src/GEOMImpl/GEOMImpl_IHealingOperations.cxx b/src/GEOMImpl/GEOMImpl_IHealingOperations.cxx index 0cbce375b..265a35f6c 100644 --- a/src/GEOMImpl/GEOMImpl_IHealingOperations.cxx +++ b/src/GEOMImpl/GEOMImpl_IHealingOperations.cxx @@ -33,6 +33,8 @@ #include #include #include +#include +#include #include #include @@ -819,18 +821,30 @@ Handle(GEOM_Object) GEOMImpl_IHealingOperations::ChangeOrientation (Handle(GEOM_ if (aLastFunction.IsNull()) return NULL; //There is no function which creates an object to be processed - //Add the function - aFunction = theObject->AddFunction(GEOMImpl_HealingDriver::GetID(), CHANGE_ORIENTATION); + if (theObject->GetType() == GEOM_VECTOR) { // Mantis issue 21066 + //Add the function + aFunction = theObject->AddFunction(GEOMImpl_VectorDriver::GetID(), VECTOR_REVERSE); - if (aFunction.IsNull()) - return NULL; + //Check if the function is set correctly + if (aFunction.IsNull()) return NULL; + if (aFunction->GetDriverGUID() != GEOMImpl_VectorDriver::GetID()) return NULL; - //Check if the function is set correctly - if (aFunction->GetDriverGUID() != GEOMImpl_HealingDriver::GetID()) return NULL; + // prepare "data container" class IVector + GEOMImpl_IVector aVI (aFunction); + aVI.SetCurve(aLastFunction); + } + else { + //Add the function + aFunction = theObject->AddFunction(GEOMImpl_HealingDriver::GetID(), CHANGE_ORIENTATION); - // prepare "data container" class IHealing - GEOMImpl_IHealing HI(aFunction); - HI.SetOriginal( aLastFunction ); + //Check if the function is set correctly + if (aFunction.IsNull()) return NULL; + if (aFunction->GetDriverGUID() != GEOMImpl_HealingDriver::GetID()) return NULL; + + // prepare "data container" class IHealing + GEOMImpl_IHealing HI (aFunction); + HI.SetOriginal(aLastFunction); + } //Compute the translation try { @@ -874,22 +888,34 @@ Handle(GEOM_Object) GEOMImpl_IHealingOperations::ChangeOrientationCopy (Handle(G return NULL; //There is no function which creates an object to be processed // Add a new object - Handle(GEOM_Object) aNewObject = GetEngine()->AddObject( GetDocID(), theObject->GetType() ); + Handle(GEOM_Object) aNewObject = GetEngine()->AddObject(GetDocID(), theObject->GetType()); - //Add the function - aFunction = aNewObject->AddFunction(GEOMImpl_HealingDriver::GetID(), CHANGE_ORIENTATION); + if (theObject->GetType() == GEOM_VECTOR) { // Mantis issue 21066 + //Add the function + aFunction = aNewObject->AddFunction(GEOMImpl_VectorDriver::GetID(), VECTOR_REVERSE); - if (aFunction.IsNull()) - return NULL; + //Check if the function is set correctly + if (aFunction.IsNull()) return NULL; + if (aFunction->GetDriverGUID() != GEOMImpl_VectorDriver::GetID()) return NULL; - //Check if the function is set correctly - if (aFunction->GetDriverGUID() != GEOMImpl_HealingDriver::GetID()) return NULL; + // prepare "data container" class IVector + GEOMImpl_IVector aVI (aFunction); + aVI.SetCurve(aLastFunction); + } + else { + //Add the function + aFunction = aNewObject->AddFunction(GEOMImpl_HealingDriver::GetID(), CHANGE_ORIENTATION); - // prepare "data container" class IHealing - GEOMImpl_IHealing HI(aFunction); - HI.SetOriginal( aLastFunction ); + //Check if the function is set correctly + if (aFunction.IsNull()) return NULL; + if (aFunction->GetDriverGUID() != GEOMImpl_HealingDriver::GetID()) return NULL; - //Compute the translation + // prepare "data container" class IHealing + GEOMImpl_IHealing aHI (aFunction); + aHI.SetOriginal(aLastFunction); + } + + // Compute the result try { #if OCC_VERSION_LARGE > 0x06010000 OCC_CATCH_SIGNALS; diff --git a/src/GEOMImpl/GEOMImpl_IShapesOperations.cxx b/src/GEOMImpl/GEOMImpl_IShapesOperations.cxx index 5ca5029fb..6af52d80a 100644 --- a/src/GEOMImpl/GEOMImpl_IShapesOperations.cxx +++ b/src/GEOMImpl/GEOMImpl_IShapesOperations.cxx @@ -40,6 +40,9 @@ #include "GEOMImpl_IGlue.hxx" #include "GEOMImpl_Block6Explorer.hxx" +#include "GEOMImpl_IHealingOperations.hxx" + +#include #include "GEOM_Function.hxx" #include "GEOM_ISubShape.hxx" @@ -1774,6 +1777,7 @@ Handle(GEOM_Object) GEOMImpl_IShapesOperations::ReverseShape(Handle(GEOM_Object) if (theShape.IsNull()) return NULL; + /* //Add a new reversed object Handle(GEOM_Object) aReversed = GetEngine()->AddObject(GetDocID(), theShape->GetType()); @@ -1813,6 +1817,21 @@ Handle(GEOM_Object) GEOMImpl_IShapesOperations::ReverseShape(Handle(GEOM_Object) << " = geompy.ChangeOrientation(" << theShape << ")"; SetErrorCode(OK); + */ + + Handle(GEOM_Object) aReversed; + + GEOM_Engine* anEngine = GetEngine(); + //GEOMImpl_Gen* aGen = dynamic_cast(anEngine); + GEOMImpl_Gen* aGen = (GEOMImpl_Gen*)anEngine; + + if (aGen) { + GEOMImpl_IHealingOperations* anIHealingOperations = + aGen->GetIHealingOperations(GetDocID()); + aReversed = anIHealingOperations->ChangeOrientation(theShape); + SetErrorCode(anIHealingOperations->GetErrorCode()); + } + return aReversed; } diff --git a/src/GEOMImpl/GEOMImpl_ShapeDriver.cxx b/src/GEOMImpl/GEOMImpl_ShapeDriver.cxx index f254c2a0c..332d11769 100644 --- a/src/GEOMImpl/GEOMImpl_ShapeDriver.cxx +++ b/src/GEOMImpl/GEOMImpl_ShapeDriver.cxx @@ -18,7 +18,6 @@ // 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 @@ -449,6 +448,7 @@ Standard_Integer GEOMImpl_ShapeDriver::Execute(TFunction_Logbook& log) const aShape = C; } + /* else if (aType == REVERSE_ORIENTATION) { Handle(GEOM_Function) aRefShape = aCI.GetBase(); TopoDS_Shape aShape_i = aRefShape->GetValue(); @@ -471,6 +471,7 @@ Standard_Integer GEOMImpl_ShapeDriver::Execute(TFunction_Logbook& log) const aShape = tds; } } + */ else if (aType == EDGE_WIRE) { Handle(GEOM_Function) aRefBase = aCI.GetBase(); TopoDS_Shape aWire = aRefBase->GetValue(); diff --git a/src/GEOMImpl/GEOMImpl_Types.hxx b/src/GEOMImpl/GEOMImpl_Types.hxx index 66b6f5372..9359db7a3 100755 --- a/src/GEOMImpl/GEOMImpl_Types.hxx +++ b/src/GEOMImpl/GEOMImpl_Types.hxx @@ -18,9 +18,9 @@ // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// -//GEOM_Object types + +// GEOM_Object types #define GEOM_COPY 0 #define GEOM_IMPORT 1 @@ -113,11 +113,11 @@ #define POINT_SURFACE_COORD 7 #define POINT_CURVE_LENGTH 8 +// Vector #define VECTOR_TWO_PNT 1 #define VECTOR_DX_DY_DZ 2 #define VECTOR_TANGENT_CURVE_PAR 3 -#define VECTOR_FACE_NORMALE 4 -#define VERTEX_BY_INDEX 5 +#define VECTOR_REVERSE 4 #define PLANE_PNT_VEC 1 #define PLANE_FACE 2 @@ -222,15 +222,16 @@ #define POLYLINE_POINTS 1 +#define SPLINE_BEZIER 1 +#define SPLINE_INTERPOLATION 2 + #define CIRCLE_THREE_PNT 1 #define CIRCLE_PNT_VEC_R 2 #define CIRCLE_CENTER_TWO_PNT 3 -#define SPLINE_BEZIER 1 -#define SPLINE_INTERPOLATION 2 - #define ELLIPSE_PNT_VEC_RR 1 +// Arc #define CIRC_ARC_THREE_PNT 1 #define CIRC_ARC_CENTER 2 #define ELLIPSE_ARC_CENTER_TWO_PNT 3 @@ -252,6 +253,7 @@ #define CHAMFER_SHAPE_FACES_AD 6 #define CHAMFER_SHAPE_EDGES_AD 7 +// Shape creation #define WIRE_EDGES 1 #define FACE_WIRE 2 #define SHELL_FACES 3 @@ -261,7 +263,7 @@ #define SUBSHAPE_SORTED 7 #define SUBSHAPE_NOT_SORTED 8 #define FACE_WIRES 9 -#define REVERSE_ORIENTATION 10 +//#define REVERSE_ORIENTATION 10 #define EDGE_WIRE 11 #define EDGE_CURVE_LENGTH 12 @@ -288,13 +290,16 @@ #define SKETCHER_NINE_DOUBLS 1 #define SKETCHER_PLANE 2 +// Measures #define CDG_MEASURE 1 +#define VECTOR_FACE_NORMALE 4 +#define VERTEX_BY_INDEX 5 #define GROUP_FUNCTION 1 #define SHAPES_ON_SHAPE 1 -//Curve constructor type +// Curve constructor type #define POINT_CONSTRUCTOR 0 #define COORD_CONSTRUCTOR 1 diff --git a/src/GEOMImpl/GEOMImpl_VectorDriver.cxx b/src/GEOMImpl/GEOMImpl_VectorDriver.cxx index 8df2928f0..df75e4241 100644 --- a/src/GEOMImpl/GEOMImpl_VectorDriver.cxx +++ b/src/GEOMImpl/GEOMImpl_VectorDriver.cxx @@ -18,7 +18,6 @@ // 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 @@ -31,7 +30,9 @@ #include #include +#include #include +#include #include #include @@ -72,7 +73,8 @@ Standard_Integer GEOMImpl_VectorDriver::Execute(TFunction_Logbook& log) const GEOMImpl_IVector aPI (aFunction); Standard_Integer aType = aFunction->GetType(); - if (aType != VECTOR_DX_DY_DZ && aType != VECTOR_TWO_PNT && aType != VECTOR_TANGENT_CURVE_PAR) return 0; + if (aType != VECTOR_DX_DY_DZ && aType != VECTOR_TWO_PNT && + aType != VECTOR_TANGENT_CURVE_PAR && aType != VECTOR_REVERSE) return 0; TopoDS_Shape aShape; @@ -85,7 +87,8 @@ Standard_Integer GEOMImpl_VectorDriver::Execute(TFunction_Logbook& log) const Standard_ConstructionError::Raise(aMsg.ToCString()); } aShape = BRepBuilderAPI_MakeEdge(P1, P2).Shape(); - } else if (aType == VECTOR_TWO_PNT) { + } + else if (aType == VECTOR_TWO_PNT) { Handle(GEOM_Function) aRefPnt1 = aPI.GetPoint1(); Handle(GEOM_Function) aRefPnt2 = aPI.GetPoint2(); TopoDS_Shape aShape1 = aRefPnt1->GetValue(); @@ -104,7 +107,7 @@ Standard_Integer GEOMImpl_VectorDriver::Execute(TFunction_Logbook& log) const } aShape = BRepBuilderAPI_MakeEdge(V1, V2).Shape(); } - else if(aType == VECTOR_TANGENT_CURVE_PAR) { + else if (aType == VECTOR_TANGENT_CURVE_PAR) { Handle(GEOM_Function) aRefCurve = aPI.GetCurve(); TopoDS_Shape aRefShape = aRefCurve->GetValue(); if (aRefShape.ShapeType() != TopAbs_EDGE) { @@ -130,6 +133,18 @@ Standard_Integer GEOMImpl_VectorDriver::Execute(TFunction_Logbook& log) const if(aBuilder.IsDone()) aShape = aBuilder.Shape(); } + else if (aType == VECTOR_REVERSE) { + Handle(GEOM_Function) aRefVec = aPI.GetCurve(); + TopoDS_Shape aRefShape = aRefVec->GetValue(); + if (aRefShape.ShapeType() != TopAbs_EDGE) { + Standard_TypeMismatch::Raise + ("Reversed vector creation aborted : vector shape is not an edge"); + } + TopoDS_Edge anE = TopoDS::Edge(aRefShape); + TopoDS_Vertex V1, V2; + TopExp::Vertices(anE, V1, V2, Standard_True); + aShape = BRepBuilderAPI_MakeEdge(V2, V1).Shape(); + } if (aShape.IsNull()) return 0; @@ -181,5 +196,5 @@ const Handle(GEOMImpl_VectorDriver) Handle(GEOMImpl_VectorDriver)::DownCast } } - return _anOtherObject ; + return _anOtherObject; }