+ GEOM::TPythonDump pd (aFunction);
+ pd << aGlued << " = geompy.MakeGlueEdgesByList("
+ << theShape << ", " << theTolerance << ", [";
+ // Edges
+ it = theEdges.begin();
+ if (it != theEdges.end()) {
+ pd << (*it++);
+ while (it != theEdges.end()) {
+ pd << ", " << (*it++);
+ }
+ }
+ pd << "])";
+
+ // to provide warning
+ if (!isWarning) SetErrorCode(OK);
+ return aGlued;
+}
+
+//=============================================================================
+/*!
+ * GetExistingSubObjects
+ */
+//=============================================================================
+Handle(TColStd_HSequenceOfTransient) GEOMImpl_IShapesOperations::GetExistingSubObjects
+ (Handle(GEOM_Object) theShape,
+ const Standard_Boolean theGroupsOnly)
+{
+ SetErrorCode(KO);
+
+ if (theShape.IsNull()) return NULL;
+
+ Handle(GEOM_Function) aMainShape = theShape->GetLastFunction();
+ if (aMainShape.IsNull()) return NULL;
+
+ Handle(TColStd_HSequenceOfTransient) aSeq = new TColStd_HSequenceOfTransient;
+ SetErrorCode(NOT_FOUND_ANY);
+
+ if (!aMainShape->HasSubShapeReferences()) return aSeq;
+ const TDataStd_ListOfExtendedString& aListEntries = aMainShape->GetSubShapeReferences();
+ if (aListEntries.IsEmpty()) return aSeq;
+
+ SetErrorCode(KO);
+
+ TCollection_AsciiString anAsciiList;
+
+ TDataStd_ListIteratorOfListOfExtendedString anIt (aListEntries);
+ for (; anIt.More(); anIt.Next()) {
+ TCollection_ExtendedString anEntry = anIt.Value();
+ Standard_Integer aStrLen = anEntry.LengthOfCString();
+ char* anEntryStr = new char[aStrLen];
+ anEntry.ToUTF8CString(anEntryStr);
+ Handle(GEOM_Object) anObj = GetEngine()->GetObject(GetDocID(), anEntryStr, false);
+ if (!anObj.IsNull()) {
+ if (!theGroupsOnly || anObj->GetType() == GEOM_GROUP) {
+ aSeq->Append(anObj);
+
+ // for python command
+ anAsciiList += anEntryStr;
+ anAsciiList += ",";
+ }
+ }
+ delete [] anEntryStr;
+ }
+
+ if (aSeq->Length() == 0) {
+ SetErrorCode(NOT_FOUND_ANY);
+ return aSeq;
+ }
+
+ //Make a Python command
+ anAsciiList.Trunc(anAsciiList.Length() - 1);
+
+ GEOM::TPythonDump pd (aMainShape, /*append=*/true);
+ pd << "[" << anAsciiList.ToCString();
+ pd << "] = geompy.GetExistingSubObjects(";
+ pd << theShape << ", " << (bool)theGroupsOnly << ")";
+
+ SetErrorCode(OK);
+
+ return aSeq;
+}
+
+//=============================================================================
+/*!
+ * MakeExplode
+ */
+//=============================================================================
+Handle(TColStd_HSequenceOfTransient) GEOMImpl_IShapesOperations::MakeExplode
+ (Handle(GEOM_Object) theShape,
+ const Standard_Integer theShapeType,
+ const Standard_Boolean isSorted,
+ const ExplodeType theExplodeType)
+{
+ SetErrorCode(KO);
+
+ if (theShape.IsNull()) return NULL;
+ TopoDS_Shape aShape = theShape->GetValue();
+ if (aShape.IsNull()) return NULL;
+
+ Handle(GEOM_Function) aMainShape = theShape->GetLastFunction();
+
+ Handle(TColStd_HSequenceOfTransient) aSeq = new TColStd_HSequenceOfTransient;
+ Handle(GEOM_Object) anObj;
+ TopTools_MapOfShape mapShape;
+ TopTools_ListOfShape listShape;
+
+ if (aShape.ShapeType() == TopAbs_COMPOUND &&
+ (TopAbs_ShapeEnum(theShapeType) == TopAbs_SHAPE ||
+ TopAbs_ShapeEnum(theShapeType) == TopAbs_COMPSOLID ||
+ TopAbs_ShapeEnum(theShapeType) == TopAbs_COMPOUND))
+ {
+ TopoDS_Iterator It (aShape, Standard_True, Standard_True);
+ for (; It.More(); It.Next()) {
+ if (mapShape.Add(It.Value())) {
+ if (TopAbs_ShapeEnum(theShapeType) == TopAbs_SHAPE ||
+ TopAbs_ShapeEnum(theShapeType) == It.Value().ShapeType()) {
+ listShape.Append(It.Value());
+ }
+ }
+ }
+ }
+ else if (theExplodeType != EXPLODE_NEW_EXCLUDE_MAIN || aShape.ShapeType() != theShapeType) // issue 0021079
+ {
+ TopExp_Explorer exp (aShape, TopAbs_ShapeEnum(theShapeType));
+ for (; exp.More(); exp.Next())
+ if (mapShape.Add(exp.Current()))
+ listShape.Append(exp.Current());
+ }
+
+ if (listShape.IsEmpty()) {
+ //SetErrorCode("The given shape has no sub-shapes of the requested type");
+ SetErrorCode(NOT_FOUND_ANY); // NPAL18017
+ return aSeq;
+ }
+
+ if (isSorted) {
+ bool isOldSorting = false;
+ if (theExplodeType == EXPLODE_OLD_INCLUDE_MAIN)
+ isOldSorting = true;
+ SortShapes(listShape, isOldSorting);
+ }
+
+ TopTools_IndexedMapOfShape anIndices;
+ TopExp::MapShapes(aShape, anIndices);
+ Handle(TColStd_HArray1OfInteger) anArray;
+
+ TopTools_ListIteratorOfListOfShape itSub (listShape);
+ TCollection_AsciiString anAsciiList, anEntry;
+ for (int index = 1; itSub.More(); itSub.Next(), ++index)
+ {
+ TopoDS_Shape aValue = itSub.Value();
+ anArray = new TColStd_HArray1OfInteger(1,1);
+ anArray->SetValue(1, anIndices.FindIndex(aValue));
+
+ //anObj = GetEngine()->AddSubShape(theShape, anArray);
+ {
+ anObj = GetEngine()->AddObject(GetDocID(), GEOM_SUBSHAPE);
+ Handle(GEOM_Function) aFunction = anObj->AddFunction(GEOM_Object::GetSubShapeID(), 1);
+ if (aFunction.IsNull()) return aSeq;
+
+ GEOM_ISubShape aSSI (aFunction);
+ aSSI.SetMainShape(aMainShape);
+ aSSI.SetIndices(anArray);
+
+ // Set function value directly, as we know it.
+ // Usage of Solver here would lead to significant loss of time,
+ // because GEOM_SubShapeDriver will build TopTools_IndexedMapOfShape
+ // on the main shape for each being calculated sub-shape separately.
+ aFunction->SetValue(aValue);
+
+ // Put this subshape in the list of sub-shapes of theMainShape
+ aMainShape->AddSubShapeReference(aFunction);
+ }
+
+ if (!anObj.IsNull()) {
+ aSeq->Append(anObj);
+
+ // for python command
+ TDF_Tool::Entry(anObj->GetEntry(), anEntry);
+ anAsciiList += anEntry;
+ anAsciiList += ",";
+ }
+ }
+
+ //Make a Python command
+ anAsciiList.Trunc(anAsciiList.Length() - 1);
+
+ GEOM::TPythonDump pd (aMainShape, /*append=*/true);
+ pd << "[" << anAsciiList.ToCString() << "] = geompy.";
+ switch (theExplodeType) {
+ case EXPLODE_NEW_EXCLUDE_MAIN:
+ pd << "ExtractShapes(" << theShape << ", "
+ << TopAbs_ShapeEnum(theShapeType) << ", " << (isSorted ? "True" : "False") << ")";
+ break;
+ case EXPLODE_NEW_INCLUDE_MAIN:
+ pd << "SubShapeAll" << (isSorted ? "SortedCentres(" : "(")
+ << theShape << ", " << TopAbs_ShapeEnum(theShapeType) << ")";
+ break;
+ case EXPLODE_OLD_INCLUDE_MAIN:
+ pd << "SubShapeAll" << (isSorted ? "Sorted(" : "(")
+ << theShape << ", " << TopAbs_ShapeEnum(theShapeType) << ")";
+ break;
+ default: ;
+ }
+ SetErrorCode(OK);
+
+ return aSeq;
+}
+
+//=============================================================================
+/*!
+ * SubShapeAllIDs
+ */
+//=============================================================================
+Handle(TColStd_HSequenceOfInteger) GEOMImpl_IShapesOperations::SubShapeAllIDs
+ (Handle(GEOM_Object) theShape,
+ const Standard_Integer theShapeType,
+ const Standard_Boolean isSorted,
+ const ExplodeType theExplodeType)
+{
+ SetErrorCode(KO);
+
+ if (theShape.IsNull()) return NULL;
+ TopoDS_Shape aShape = theShape->GetValue();
+ if (aShape.IsNull()) return NULL;
+
+ Handle(TColStd_HSequenceOfInteger) aSeq = new TColStd_HSequenceOfInteger;
+ TopTools_MapOfShape mapShape;
+ TopTools_ListOfShape listShape;
+
+ if (aShape.ShapeType() == TopAbs_COMPOUND &&
+ (TopAbs_ShapeEnum(theShapeType) == TopAbs_SHAPE ||
+ TopAbs_ShapeEnum(theShapeType) == TopAbs_COMPSOLID ||
+ TopAbs_ShapeEnum(theShapeType) == TopAbs_COMPOUND))
+ {
+ TopoDS_Iterator It (aShape, Standard_True, Standard_True);
+ for (; It.More(); It.Next()) {
+ if (mapShape.Add(It.Value())) {
+ if (TopAbs_ShapeEnum(theShapeType) == TopAbs_SHAPE ||
+ TopAbs_ShapeEnum(theShapeType) == It.Value().ShapeType()) {
+ listShape.Append(It.Value());
+ }
+ }
+ }
+ }
+ else if (theExplodeType != EXPLODE_NEW_EXCLUDE_MAIN || aShape.ShapeType() != theShapeType) // issue 0021079
+ {
+ TopExp_Explorer exp (aShape, TopAbs_ShapeEnum(theShapeType));
+ for (; exp.More(); exp.Next())
+ if (mapShape.Add(exp.Current()))
+ listShape.Append(exp.Current());
+ }
+
+ if (listShape.IsEmpty()) {
+ //SetErrorCode("The given shape has no sub-shapes of the requested type");
+ SetErrorCode(NOT_FOUND_ANY); // NPAL18017
+ return aSeq;
+ }
+
+ if (isSorted) {
+ bool isOldSorting = false;
+ if (theExplodeType == EXPLODE_OLD_INCLUDE_MAIN)
+ isOldSorting = true;
+ SortShapes(listShape, isOldSorting);
+ }
+
+ TopTools_IndexedMapOfShape anIndices;
+ TopExp::MapShapes(aShape, anIndices);
+ Handle(TColStd_HArray1OfInteger) anArray;
+
+ TopTools_ListIteratorOfListOfShape itSub (listShape);
+ for (int index = 1; itSub.More(); itSub.Next(), ++index) {
+ TopoDS_Shape aValue = itSub.Value();
+ aSeq->Append(anIndices.FindIndex(aValue));
+ }
+
+ Handle(GEOM_Function) aFunction = theShape->GetLastFunction();
+
+ //Make a Python command
+ GEOM::TPythonDump pd (aFunction, /*append=*/true);
+ pd << "listSubShapeIDs = geompy.SubShapeAll";
+ switch (theExplodeType) {
+ case EXPLODE_NEW_EXCLUDE_MAIN:
+ break;
+ case EXPLODE_NEW_INCLUDE_MAIN:
+ pd << (isSorted ? "SortedCentresIDs(" : "IDs(")
+ << theShape << ", " << TopAbs_ShapeEnum(theShapeType) << ")";
+ break;
+ case EXPLODE_OLD_INCLUDE_MAIN:
+ pd << (isSorted ? "SortedIDs(" : "IDs(")
+ << theShape << ", " << TopAbs_ShapeEnum(theShapeType) << ")";
+ break;
+ default: ;
+ }
+
+ SetErrorCode(OK);
+ return aSeq;
+}
+
+//=============================================================================
+/*!
+ * GetSubShape
+ */
+//=============================================================================
+Handle(GEOM_Object) GEOMImpl_IShapesOperations::GetSubShape
+ (Handle(GEOM_Object) theMainShape,
+ const Standard_Integer theID)
+{
+ SetErrorCode(KO);
+
+ if (theMainShape.IsNull()) return NULL;
+
+ Handle(TColStd_HArray1OfInteger) anArray = new TColStd_HArray1OfInteger(1,1);
+ anArray->SetValue(1, theID);
+ Handle(GEOM_Object) anObj = GetEngine()->AddSubShape(theMainShape, anArray,true);
+ if (anObj.IsNull()) {
+ SetErrorCode("Can not get a sub-shape with the given ID");
+ return NULL;
+ }
+
+ Handle(GEOM_Function) aFunction = anObj->GetLastFunction();
+
+ //Make a Python command
+ GEOM::TPythonDump(aFunction) << anObj << " = geompy.GetSubShape("
+ << theMainShape << ", [" << theID << "])";
+
+ SetErrorCode(OK);
+ return anObj;
+}
+
+//=============================================================================
+/*!
+ * MakeSubShapes
+ */
+//=============================================================================
+Handle(TColStd_HSequenceOfTransient) GEOMImpl_IShapesOperations::MakeSubShapes
+ (Handle(GEOM_Object) theMainShape,
+ Handle(TColStd_HArray1OfInteger) theIndices)
+{
+ SetErrorCode(KO);
+
+ Handle(TColStd_HSequenceOfTransient) aSeq = new TColStd_HSequenceOfTransient;
+
+ if (!theIndices->Length()) {
+ SetErrorCode(NOT_FOUND_ANY);
+ return aSeq;
+ }
+
+ if (theMainShape.IsNull()) return NULL;
+ TopoDS_Shape aShape = theMainShape->GetValue();
+ if (aShape.IsNull()) return NULL;
+
+ Handle(GEOM_Function) aMainShape = theMainShape->GetLastFunction();
+
+ TopTools_IndexedMapOfShape anIndices;
+ TopExp::MapShapes(aShape, anIndices);
+
+ Handle(TColStd_HArray1OfInteger) anArray;
+ Handle(GEOM_Object) anObj;
+
+ TCollection_AsciiString anAsciiList, anEntry;
+ Standard_Integer i, low = theIndices->Lower(), up = theIndices->Upper();
+ for (i = low; i <= up; i++) {
+ int id = theIndices->Value(i);
+ if (1 <= id && id <= anIndices.Extent()) {
+ TopoDS_Shape aValue = anIndices.FindKey(id);
+ anArray = new TColStd_HArray1OfInteger(1,1);
+ anArray->SetValue(1, id);
+
+ anObj = GetEngine()->AddObject(GetDocID(), GEOM_SUBSHAPE);
+ if (!anObj.IsNull()) {
+ Handle(GEOM_Function) aFunction = anObj->AddFunction(GEOM_Object::GetSubShapeID(), 1);
+ if (aFunction.IsNull()) return aSeq;
+
+ GEOM_ISubShape aSSI (aFunction);
+ aSSI.SetMainShape(aMainShape);
+ aSSI.SetIndices(anArray);
+
+ // Set function value directly, as we know it.
+ // Usage of Solver here would lead to significant loss of time,
+ // because GEOM_SubShapeDriver will build TopTools_IndexedMapOfShape
+ // on the main shape for each being calculated sub-shape separately.
+ aFunction->SetValue(aValue);
+
+ // Put this sub-shape in the list of sub-shapes of theMainShape
+ aMainShape->AddSubShapeReference(aFunction);
+
+ aSeq->Append(anObj);
+
+ // for python command
+ TDF_Tool::Entry(anObj->GetEntry(), anEntry);
+ anAsciiList += anEntry;
+ anAsciiList += ",";
+ }
+ }
+ }
+
+ //Make a Python command
+ anAsciiList.Trunc(anAsciiList.Length() - 1);
+
+ GEOM::TPythonDump pd (aMainShape, /*append=*/true);
+ pd << "[" << anAsciiList.ToCString() << "] = geompy.SubShapes("
+ << theMainShape << ", [" ;
+ for (i = low; i <= up - 1; i++) {
+ pd << theIndices->Value(i) << ", ";
+ }
+ pd << theIndices->Value(up) << "])";
+
+ SetErrorCode(OK);
+
+ return aSeq;
+}
+
+//=============================================================================
+/*!
+ * GetSubShapeIndex
+ */
+//=============================================================================
+Standard_Integer GEOMImpl_IShapesOperations::GetSubShapeIndex (Handle(GEOM_Object) theMainShape,
+ Handle(GEOM_Object) theSubShape)
+{
+ SetErrorCode(KO);
+
+ TopoDS_Shape aMainShape = theMainShape->GetValue();
+ TopoDS_Shape aSubShape = theSubShape->GetValue();
+
+ if (aMainShape.IsNull() || aSubShape.IsNull()) return -1;
+
+ TopTools_IndexedMapOfShape anIndices;
+ TopExp::MapShapes(aMainShape, anIndices);
+ if (anIndices.Contains(aSubShape)) {
+ SetErrorCode(OK);
+ return anIndices.FindIndex(aSubShape);
+ }
+
+ return -1;
+}
+
+//=============================================================================
+/*!
+ * GetTopologyIndex
+ */
+//=============================================================================
+Standard_Integer GEOMImpl_IShapesOperations::GetTopologyIndex (Handle(GEOM_Object) theMainShape,
+ Handle(GEOM_Object) theSubShape)
+{
+ SetErrorCode(OK);
+
+ TopoDS_Shape aMainShape = theMainShape->GetValue();
+ TopoDS_Shape aSubShape = theSubShape->GetValue();
+
+ if (aMainShape.IsNull() || aSubShape.IsNull()) {
+ SetErrorCode("Null argument shape given");
+ return -1;
+ }
+
+ int index = 1;
+ if (aSubShape.ShapeType() == TopAbs_COMPOUND) {
+ TopoDS_Iterator it;
+ TopTools_ListOfShape CL;
+ CL.Append(aMainShape);
+ TopTools_ListIteratorOfListOfShape itC;
+ for (itC.Initialize(CL); itC.More(); itC.Next()) {
+ for (it.Initialize(itC.Value()); it.More(); it.Next()) {
+ if (it.Value().ShapeType() == TopAbs_COMPOUND) {
+ if (it.Value().IsSame(aSubShape))
+ return index;
+ else
+ index++;
+ CL.Append(it.Value());
+ }
+ }
+ }
+ } else {
+ TopExp_Explorer anExp (aMainShape, aSubShape.ShapeType());
+ TopTools_MapOfShape M;
+ for (; anExp.More(); anExp.Next()) {
+ if (M.Add(anExp.Current())) {
+ if (anExp.Current().IsSame(aSubShape))
+ return index;
+ index++;
+ }
+ }
+ }
+
+ SetErrorCode("The sub-shape does not belong to the main shape");
+ return -1;
+}
+
+//=============================================================================
+/*!
+ * GetShapeTypeString
+ */
+//=============================================================================
+TCollection_AsciiString GEOMImpl_IShapesOperations::GetShapeTypeString (Handle(GEOM_Object) theShape)
+{
+ SetErrorCode(KO);
+
+ TCollection_AsciiString aTypeName ("Null Shape");
+
+ TopoDS_Shape aShape = theShape->GetValue();
+ if (aShape.IsNull())
+ return aTypeName;
+
+ switch (aShape.ShapeType() )
+ {
+ case TopAbs_COMPOUND:
+ aTypeName = "Compound";
+ break;
+ case TopAbs_COMPSOLID:
+ aTypeName = "Compound Solid";
+ break;
+ case TopAbs_SOLID:
+ aTypeName = "Solid";
+ break;
+ case TopAbs_SHELL:
+ aTypeName = "Shell";
+ break;
+ case TopAbs_FACE:
+ {
+ BRepAdaptor_Surface surf (TopoDS::Face(aShape));
+ if (surf.GetType() == GeomAbs_Plane)
+ aTypeName = "Plane";
+ else if (surf.GetType() == GeomAbs_Cylinder)
+ aTypeName = "Cylindrical Face";
+ else if (surf.GetType() == GeomAbs_Sphere)
+ aTypeName = "Spherical Face";
+ else if (surf.GetType() == GeomAbs_Torus)
+ aTypeName = "Toroidal Face";
+ else if (surf.GetType() == GeomAbs_Cone)
+ aTypeName = "Conical Face";
+ else
+ aTypeName = "GEOM::FACE";
+ }
+ break;
+ case TopAbs_WIRE:
+ aTypeName = "Wire";
+ break;
+ case TopAbs_EDGE:
+ {
+ BRepAdaptor_Curve curv (TopoDS::Edge(aShape));
+ if (curv.GetType() == GeomAbs_Line) {
+ if ((Abs(curv.FirstParameter()) >= 1E6) ||
+ (Abs(curv.LastParameter()) >= 1E6))
+ aTypeName = "Line";
+ else
+ aTypeName = "Edge";
+ } else if (curv.GetType() == GeomAbs_Circle) {
+ if (curv.IsClosed())
+ aTypeName = "Circle";
+ else
+ aTypeName = "Arc";
+ } else {
+ aTypeName = "Edge";
+ }
+ }
+ break;
+ case TopAbs_VERTEX:
+ aTypeName = "Vertex";
+ break;
+ case TopAbs_SHAPE:
+ aTypeName = "Shape";
+ break;
+ default:
+ aTypeName = "Shape of unknown type";
+ }
+
+ return aTypeName;
+}
+
+//=============================================================================
+/*!
+ * NumberOfSubShapes
+ */
+//=============================================================================
+Standard_Integer GEOMImpl_IShapesOperations::NumberOfSubShapes
+ (Handle(GEOM_Object) theShape,
+ const Standard_Integer theShapeType)
+{
+ SetErrorCode(KO);
+ Standard_Integer nbShapes = 0;
+
+ if (theShape.IsNull()) return -1;
+ TopoDS_Shape aShape = theShape->GetValue();
+ if (aShape.IsNull()) return -1;
+
+ /*
+ TopTools_MapOfShape mapShape;
+
+ if (aShape.ShapeType() == TopAbs_COMPOUND &&
+ (TopAbs_ShapeEnum(theShapeType) == TopAbs_SHAPE ||
+ TopAbs_ShapeEnum(theShapeType) == TopAbs_COMPSOLID ||
+ TopAbs_ShapeEnum(theShapeType) == TopAbs_COMPOUND)) {
+ TopoDS_Iterator It (aShape, Standard_True, Standard_True);
+ for (; It.More(); It.Next()) {
+ if (mapShape.Add(It.Value())) {
+ if (TopAbs_ShapeEnum(theShapeType) == TopAbs_SHAPE ||
+ TopAbs_ShapeEnum(theShapeType) == It.Value().ShapeType()) {
+ nbShapes++;
+ }
+ }
+ }
+ } else {
+ TopExp_Explorer exp (aShape, TopAbs_ShapeEnum(theShapeType));
+ for (; exp.More(); exp.Next())
+ if (mapShape.Add(exp.Current()))
+ nbShapes++;
+ }
+ */
+
+ try {
+#if OCC_VERSION_LARGE > 0x06010000
+ OCC_CATCH_SIGNALS;
+#endif
+ int iType, nbTypes [TopAbs_SHAPE];
+ for (iType = 0; iType < TopAbs_SHAPE; ++iType)
+ nbTypes[iType] = 0;
+ nbTypes[aShape.ShapeType()]++;
+
+ TopTools_MapOfShape aMapOfShape;
+ aMapOfShape.Add(aShape);
+ TopTools_ListOfShape aListOfShape;
+ aListOfShape.Append(aShape);
+
+ TopTools_ListIteratorOfListOfShape itL (aListOfShape);
+ for (; itL.More(); itL.Next()) {
+ TopoDS_Iterator it (itL.Value());
+ for (; it.More(); it.Next()) {
+ TopoDS_Shape s = it.Value();
+ if (aMapOfShape.Add(s)) {
+ aListOfShape.Append(s);
+ nbTypes[s.ShapeType()]++;
+ }
+ }
+ }
+
+ if (TopAbs_ShapeEnum(theShapeType) == TopAbs_SHAPE)
+ nbShapes = aMapOfShape.Extent();
+ else
+ nbShapes = nbTypes[theShapeType];
+ }
+ catch (Standard_Failure) {
+ Handle(Standard_Failure) aFail = Standard_Failure::Caught();
+ SetErrorCode(aFail->GetMessageString());
+ return -1;
+ }
+
+ SetErrorCode(OK);
+ return nbShapes;
+}
+
+//=============================================================================
+/*!
+ * ReverseShape
+ */
+//=============================================================================
+Handle(GEOM_Object) GEOMImpl_IShapesOperations::ReverseShape(Handle(GEOM_Object) theShape)
+{
+ SetErrorCode(KO);
+
+ if (theShape.IsNull()) return NULL;
+
+ /*
+ //Add a new reversed object
+ Handle(GEOM_Object) aReversed = GetEngine()->AddObject(GetDocID(), theShape->GetType());
+
+ //Add a new Revese function
+ Handle(GEOM_Function) aFunction;
+ aFunction = aReversed->AddFunction(GEOMImpl_ShapeDriver::GetID(), REVERSE_ORIENTATION);
+ if (aFunction.IsNull()) return NULL;
+
+ //Check if the function is set correctly
+ if (aFunction->GetDriverGUID() != GEOMImpl_ShapeDriver::GetID()) return NULL;
+
+ GEOMImpl_IShapes aSI (aFunction);
+
+ Handle(GEOM_Function) aRefShape = theShape->GetLastFunction();
+ if (aRefShape.IsNull()) return NULL;
+
+ aSI.SetBase(aRefShape);
+
+ //Compute the sub-shape value
+ try {
+#if OCC_VERSION_LARGE > 0x06010000
+ OCC_CATCH_SIGNALS;
+#endif
+ if (!GetSolver()->ComputeFunction(aFunction)) {
+ SetErrorCode("Shape driver failed to reverse shape");
+ return NULL;
+ }
+ }
+ catch (Standard_Failure) {
+ Handle(Standard_Failure) aFail = Standard_Failure::Caught();
+ SetErrorCode(aFail->GetMessageString());
+ return NULL;
+ }
+
+ //Make a Python command
+ GEOM::TPythonDump(aFunction) << aReversed
+ << " = geompy.ChangeOrientation(" << theShape << ")";
+
+ SetErrorCode(OK);
+ */
+
+ Handle(GEOM_Object) aReversed;
+
+ GEOM_Engine* anEngine = GetEngine();
+ //GEOMImpl_Gen* aGen = dynamic_cast<GEOMImpl_Gen*>(anEngine);
+ GEOMImpl_Gen* aGen = (GEOMImpl_Gen*)anEngine;
+
+ if (aGen) {
+ GEOMImpl_IHealingOperations* anIHealingOperations =
+ aGen->GetIHealingOperations(GetDocID());
+ aReversed = anIHealingOperations->ChangeOrientationCopy(theShape);
+ SetErrorCode(anIHealingOperations->GetErrorCode());
+ }
+