1 // Copyright (C) 2005 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
2 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
4 // This library is free software; you can redistribute it and/or
5 // modify it under the terms of the GNU Lesser General Public
6 // License as published by the Free Software Foundation; either
7 // version 2.1 of the License.
9 // This library is distributed in the hope that it will be useful
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 // Lesser General Public License for more details.
14 // You should have received a copy of the GNU Lesser General Public
15 // License along with this library; if not, write to the Free Software
16 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
21 #pragma warning( disable:4786 )
24 #include <Standard_Stream.hxx>
26 #include <GEOMImpl_IHealingOperations.hxx>
28 #include <GEOM_PythonDump.hxx>
30 #include <GEOMImpl_HealingDriver.hxx>
31 #include <GEOMImpl_Types.hxx>
32 #include <GEOMImpl_IHealing.hxx>
33 #include <GEOMImpl_CopyDriver.hxx>
35 #include <ShHealOper_ShapeProcess.hxx>
37 #include "utilities.h"
39 #include <Utils_ExceptHandlers.hxx>
41 #include <ShapeAnalysis_FreeBounds.hxx>
43 #include <TopoDS_Compound.hxx>
44 #include <TopExp_Explorer.hxx>
46 #include <TColStd_HArray1OfExtendedString.hxx>
47 #include <TColStd_HSequenceOfTransient.hxx>
48 #include <TCollection_AsciiString.hxx>
50 #include <TDF_Tool.hxx>
52 #include <Standard_ErrorHandler.hxx> // CAREFUL ! position of this file is critic : see Lucien PIGNOLONI / OCC
55 //=============================================================================
59 //=============================================================================
61 GEOMImpl_IHealingOperations::GEOMImpl_IHealingOperations (GEOM_Engine* theEngine, int theDocID)
62 : GEOM_IOperations(theEngine, theDocID)
64 MESSAGE("GEOMImpl_IHealingOperations::GEOMImpl_IHealingOperations");
67 //=============================================================================
71 //=============================================================================
73 GEOMImpl_IHealingOperations::~GEOMImpl_IHealingOperations()
75 MESSAGE("GEOMImpl_IHealingOperations::~GEOMImpl_IHealingOperations");
79 //=============================================================================
83 //=============================================================================
84 Handle(GEOM_Object) GEOMImpl_IHealingOperations::ShapeProcess (Handle(GEOM_Object) theObject,
85 const Handle(TColStd_HArray1OfExtendedString)& theOperators,
86 const Handle(TColStd_HArray1OfExtendedString)& theParams,
87 const Handle(TColStd_HArray1OfExtendedString)& theValues)
89 // set error code, check parameters
92 if (theObject.IsNull())
95 if (theOperators.IsNull() || theOperators->Length() <= 0) {
96 SetErrorCode("No operators requested");
100 Standard_Integer nbParams = 0, nbValues = 0;
101 if (!theParams.IsNull()) {
102 nbParams = theParams->Length();
104 if (!theValues.IsNull()) {
105 nbValues = theValues->Length();
108 if (nbParams != nbValues) {
109 SetErrorCode("Number of parameter values must be equal to the number of parameters");
113 Handle(GEOM_Function) aFunction, aLastFunction = theObject->GetLastFunction();
114 if (aLastFunction.IsNull()) return NULL; //There is no function which creates an object to be processed
117 Handle(GEOM_Object) aNewObject = GetEngine()->AddObject( GetDocID(), GEOM_COPY );
120 aFunction = aNewObject->AddFunction(GEOMImpl_HealingDriver::GetID(), SHAPE_PROCESS);
122 if (aFunction.IsNull()) return NULL;
124 //Check if the function is set correctly
125 if (aFunction->GetDriverGUID() != GEOMImpl_HealingDriver::GetID()) return NULL;
127 // prepare "data container" class IHealing
128 GEOMImpl_IHealing HI(aFunction);
129 HI.SetOriginal(aLastFunction);
130 HI.SetOperators( theOperators );
132 HI.SetParameters( theParams );
133 HI.SetValues( theValues );
136 //Compute the translation
139 if (!GetSolver()->ComputeFunction(aFunction))
141 SetErrorCode("Shape Healing algorithm failed");
145 catch (Standard_Failure)
147 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
148 SetErrorCode(aFail->GetMessageString());
152 //Make a Python command
153 GEOM::TPythonDump pd (aFunction);
154 pd << aNewObject << " = geompy.ProcessShape(" << theObject << ", [";
157 int i = theOperators->Lower(), nb = theOperators->Upper();
158 for ( ; i <= nb; i++) {
159 pd << "\"" << TCollection_AsciiString(theOperators->Value( i )).ToCString()
160 << (( i < nb ) ? "\", " : "\"");
163 // list of parameters
164 i = theParams->Lower(); nb = theParams->Upper();
165 for ( ; i <= nb; i++) {
166 pd << "\"" << TCollection_AsciiString(theParams->Value( i )).ToCString()
167 << (( i < nb ) ? "\", " : "\"");
171 i = theValues->Lower(); nb = theValues->Upper();
172 for ( ; i <= nb; i++) {
173 pd << "\"" << TCollection_AsciiString(theValues->Value( i )).ToCString()
174 << (( i < nb ) ? "\", " : "\"");
182 //=============================================================================
186 //=============================================================================
187 void GEOMImpl_IHealingOperations::GetShapeProcessParameters (list<string>& theOperations,
188 list<string>& theParams,
189 list<string>& theValues)
191 ShHealOper_ShapeProcess aHealer;
192 TColStd_SequenceOfAsciiString anOperators;
193 int nbOperatorErrors( 0 );
194 if ( aHealer.GetOperators( anOperators ) )
196 for ( Standard_Integer i = 1; i <= anOperators.Length(); i++ )
198 string anOperation = anOperators.Value( i ).ToCString();
199 if ( GetOperatorParameters( anOperation, theParams, theValues ) )
200 theOperations.push_back( anOperation );
207 SetErrorCode("ERROR retrieving operators (GEOMImpl_IHealingOperations)");
210 if ( nbOperatorErrors ) {
211 TCollection_AsciiString aMsg ("ERRORS retrieving ShapeProcess parameters (GEOMImpl_IHealingOperations): nbOperatorErrors = ");
212 aMsg += TCollection_AsciiString( nbOperatorErrors );
213 MESSAGE(aMsg.ToCString());
217 //=============================================================================
219 * GetOperatorParameters
221 //=============================================================================
222 bool GEOMImpl_IHealingOperations::GetOperatorParameters( const string theOperation,
223 list<string>& theParams,
224 list<string>& theValues )
226 ShHealOper_ShapeProcess aHealer;
227 int nbParamValueErrors( 0 );
228 list<string> aParams;
229 if ( GetParameters( theOperation, aParams ) ) {
230 for ( list<string>::iterator it = aParams.begin(); it != aParams.end(); ++it ) {
231 TCollection_AsciiString aParam( (Standard_CString)(*it).c_str() );
232 TCollection_AsciiString aValue;
233 if ( aHealer.GetParameter( aParam, aValue ) ) {
234 theParams.push_back( aParam.ToCString() );
235 theValues.push_back( aValue.ToCString() );
238 nbParamValueErrors++;
244 if ( nbParamValueErrors ) {
245 TCollection_AsciiString aMsg ("ERRORS retrieving ShapeProcess parameter values (GEOMImpl_IHealingOperations): nbParamValueErrors = ");
246 aMsg += TCollection_AsciiString( nbParamValueErrors );
247 MESSAGE(aMsg.ToCString());
253 //=============================================================================
257 //=============================================================================
258 bool GEOMImpl_IHealingOperations::GetParameters (const string theOperation,
259 list<string>& theParams)
261 if ( theOperation == "SplitAngle" ) {
262 theParams.push_back( "SplitAngle.Angle" );
263 theParams.push_back( "SplitAngle.MaxTolerance" );
265 } else if ( theOperation == "SplitClosedFaces" ) {
266 theParams.push_back( "SplitClosedFaces.NbSplitPoints" );
268 } else if ( theOperation == "FixFaceSize" ) {
269 theParams.push_back( "FixFaceSize.Tolerance" );
271 } else if( theOperation == "DropSmallEdges" ) {
272 theParams.push_back( "DropSmallEdges.Tolerance3d" );
274 } else if( theOperation == "BSplineRestriction" ) {
275 theParams.push_back( "BSplineRestriction.SurfaceMode" );
276 theParams.push_back( "BSplineRestriction.Curve3dMode" );
277 theParams.push_back( "BSplineRestriction.Curve2dMode" );
278 theParams.push_back( "BSplineRestriction.Tolerance3d" );
279 theParams.push_back( "BSplineRestriction.Tolerance2d" );
280 theParams.push_back( "BSplineRestriction.RequiredDegree" );
281 theParams.push_back( "BSplineRestriction.RequiredNbSegments" );
282 theParams.push_back( "BSplineRestriction.Continuity3d" );
283 theParams.push_back( "BSplineRestriction.Continuity2d" );
285 } else if( theOperation == "SplitContinuity" ) {
286 theParams.push_back( "SplitContinuity.Tolerance3d" );
287 theParams.push_back( "SplitContinuity.SurfaceContinuity" );
288 theParams.push_back( "SplitContinuity.CurveContinuity" );
290 } else if( theOperation == "ToBezier" ) {
291 theParams.push_back( "ToBezier.SurfaceMode" );
292 theParams.push_back( "ToBezier.Curve3dMode" );
293 theParams.push_back( "ToBezier.Curve2dMode" );
294 theParams.push_back( "ToBezier.MaxTolerance" );
296 } else if( theOperation == "SameParameter" ) {
297 theParams.push_back( "SameParameter.Tolerance3d" );
299 } else if( theOperation == "FixShape" ) {
300 theParams.push_back( "FixShape.Tolerance3d" );
301 theParams.push_back( "FixShape.MaxTolerance3d" );
310 //=============================================================================
314 //=============================================================================
315 Handle(GEOM_Object) GEOMImpl_IHealingOperations::SuppressFaces
316 (Handle(GEOM_Object) theObject, const Handle(TColStd_HArray1OfInteger)& theFaces)
318 // set error code, check parameters
321 if ( theObject.IsNull() ) // if theFaces.IsNull() - it's OK, it means that ALL faces must be removed..
324 Handle(GEOM_Function) aFunction, aLastFunction = theObject->GetLastFunction();
325 if(aLastFunction.IsNull()) return NULL; //There is no function which creates an object to be processed
328 Handle(GEOM_Object) aNewObject = GetEngine()->AddObject( GetDocID(), GEOM_COPY );
331 aFunction = aNewObject->AddFunction(GEOMImpl_HealingDriver::GetID(), SUPPRESS_FACES);
333 if(aFunction.IsNull()) return NULL;
335 //Check if the function is set correctly
336 if(aFunction->GetDriverGUID() != GEOMImpl_HealingDriver::GetID()) return NULL;
338 // prepare "data container" class IHealing
339 GEOMImpl_IHealing HI(aFunction);
340 HI.SetFaces( theFaces );
341 HI.SetOriginal( aLastFunction );
343 //Compute the translation
346 if (!GetSolver()->ComputeFunction(aFunction))
348 SetErrorCode("Healing driver failed");
352 catch (Standard_Failure)
354 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
355 SetErrorCode(aFail->GetMessageString());
359 //Make a Python command
360 GEOM::TPythonDump pd (aFunction);
361 pd << aNewObject << " = geompy.SuppressFaces(" << theObject << ", [";
364 int i = theFaces->Lower(), nb = theFaces->Upper();
365 for ( ; i <= nb; i++)
366 pd << theFaces->Value( i ) << (( i < nb ) ? ", " : "])");
373 //=============================================================================
377 //=============================================================================
378 Handle(GEOM_Object) GEOMImpl_IHealingOperations::CloseContour
379 (Handle(GEOM_Object) theObject,
380 const Handle(TColStd_HArray1OfInteger)& theWires,
383 // set error code, check parameters
386 if (theObject.IsNull())
388 SetErrorCode("NULL object given");
392 Handle(GEOM_Function) aFunction, aLastFunction = theObject->GetLastFunction();
393 if (aLastFunction.IsNull()) return NULL; //There is no function which creates an object to be processed
396 Handle(GEOM_Object) aNewObject = GetEngine()->AddObject( GetDocID(), GEOM_COPY );
399 aFunction = aNewObject->AddFunction(GEOMImpl_HealingDriver::GetID(), CLOSE_CONTOUR);
401 if (aFunction.IsNull()) return NULL;
403 //Check if the function is set correctly
404 if(aFunction->GetDriverGUID() != GEOMImpl_HealingDriver::GetID()) return NULL;
406 // prepare "data container" class IHealing
407 GEOMImpl_IHealing HI(aFunction);
408 HI.SetWires( theWires );
409 HI.SetIsCommonVertex( isCommonVertex );
410 HI.SetOriginal( aLastFunction );
412 //Compute the translation
415 if (!GetSolver()->ComputeFunction(aFunction))
417 SetErrorCode("Healing driver failed");
421 catch (Standard_Failure)
423 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
424 SetErrorCode(aFail->GetMessageString());
428 //Make a Python command
429 GEOM::TPythonDump pd (aFunction);
430 pd << aNewObject << " = geompy.CloseContour(" << theObject << ", [";
433 if (!theWires.IsNull())
435 int i = theWires->Lower(), nb = theWires->Upper();
436 pd << theWires->Value(i++);
438 pd << ", " << theWires->Value(i++);
440 pd << "], " << (int)isCommonVertex << ")";
446 //=============================================================================
450 //=============================================================================
451 Handle(GEOM_Object) GEOMImpl_IHealingOperations::RemoveIntWires
452 (Handle(GEOM_Object) theObject, const Handle(TColStd_HArray1OfInteger)& theWires)
454 // set error code, check parameters
457 if (theObject.IsNull()) // if theWires is NULL it's OK, it means that ALL wires must be removed
460 Handle(GEOM_Function) aFunction, aLastFunction = theObject->GetLastFunction();
461 if (aLastFunction.IsNull()) return NULL; //There is no function which creates an object to be processed
464 Handle(GEOM_Object) aNewObject = GetEngine()->AddObject( GetDocID(), GEOM_COPY );
467 aFunction = aNewObject->AddFunction(GEOMImpl_HealingDriver::GetID(), REMOVE_INT_WIRES);
469 if (aFunction.IsNull()) return NULL;
471 //Check if the function is set correctly
472 if (aFunction->GetDriverGUID() != GEOMImpl_HealingDriver::GetID()) return NULL;
474 // prepare "data container" class IHealing
475 GEOMImpl_IHealing HI(aFunction);
476 HI.SetWires( theWires );
477 HI.SetOriginal( aLastFunction );
479 //Compute the translation
482 if (!GetSolver()->ComputeFunction(aFunction))
484 SetErrorCode("Healing driver failed");
488 catch (Standard_Failure)
490 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
491 SetErrorCode(aFail->GetMessageString());
495 //Make a Python command
496 GEOM::TPythonDump pd (aFunction);
497 pd << aNewObject << " = geompy.SuppressInternalWires(" << theObject << ", [";
500 if (!theWires.IsNull()) {
501 int i = theWires->Lower(), nb = theWires->Upper();
502 for ( ; i <= nb; i++)
503 pd << theWires->Value( i ) << (( i < nb ) ? ", " : "])");
512 //=============================================================================
516 //=============================================================================
517 Handle(GEOM_Object) GEOMImpl_IHealingOperations::FillHoles (Handle(GEOM_Object) theObject,
518 const Handle(TColStd_HArray1OfInteger)& theWires)
520 // set error code, check parameters
523 if (theObject.IsNull()) // if theWires is NULL it's OK, it means that ALL holes must be removed
526 Handle(GEOM_Function) aFunction, aLastFunction = theObject->GetLastFunction();
527 if (aLastFunction.IsNull()) return NULL; //There is no function which creates an object to be processed
530 Handle(GEOM_Object) aNewObject = GetEngine()->AddObject( GetDocID(), GEOM_COPY );
533 aFunction = aNewObject->AddFunction(GEOMImpl_HealingDriver::GetID(), FILL_HOLES);
535 if (aFunction.IsNull()) return NULL;
537 //Check if the function is set correctly
538 if (aFunction->GetDriverGUID() != GEOMImpl_HealingDriver::GetID()) return NULL;
540 // prepare "data container" class IHealing
541 GEOMImpl_IHealing HI(aFunction);
542 HI.SetWires( theWires );
543 HI.SetOriginal( aLastFunction );
545 //Compute the translation
548 if (!GetSolver()->ComputeFunction(aFunction))
550 SetErrorCode("Healing driver failed");
554 catch (Standard_Failure)
556 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
557 SetErrorCode(aFail->GetMessageString());
561 //Make a Python command
562 GEOM::TPythonDump pd (aFunction);
563 pd << aNewObject << " = geompy.SuppressHoles(" << theObject << ", [";
566 if ( theWires.IsNull() )
569 int i = theWires->Lower(), nb = theWires->Upper();
570 for ( ; i <= nb; i++)
571 pd << theWires->Value( i ) << (( i < nb ) ? ", " : "])");
578 //=============================================================================
582 //=============================================================================
583 Handle(GEOM_Object) GEOMImpl_IHealingOperations::Sew (Handle(GEOM_Object) theObject,
586 // set error code, check parameters
589 if (theObject.IsNull())
592 Handle(GEOM_Function) aFunction, aLastFunction = theObject->GetLastFunction();
593 if (aLastFunction.IsNull()) return NULL; //There is no function which creates an object to be processed
596 Handle(GEOM_Object) aNewObject = GetEngine()->AddObject( GetDocID(), GEOM_COPY );
599 aFunction = aNewObject->AddFunction(GEOMImpl_HealingDriver::GetID(), SEWING);
601 if (aFunction.IsNull()) return NULL;
603 //Check if the function is set correctly
604 if (aFunction->GetDriverGUID() != GEOMImpl_HealingDriver::GetID()) return NULL;
606 // prepare "data container" class IHealing
607 GEOMImpl_IHealing HI(aFunction);
608 HI.SetTolerance( theTolerance );
609 HI.SetOriginal( aLastFunction );
611 //Compute the translation
614 if (!GetSolver()->ComputeFunction(aFunction))
616 SetErrorCode("Healing driver failed");
620 catch (Standard_Failure)
622 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
623 SetErrorCode(aFail->GetMessageString());
627 //Make a Python command
628 GEOM::TPythonDump(aFunction) << aNewObject << " = geompy.Sew("
629 << theObject << ", " << theTolerance << ")";
635 //=============================================================================
639 //=============================================================================
640 Handle(GEOM_Object) GEOMImpl_IHealingOperations::DivideEdge (Handle(GEOM_Object) theObject,
645 // set error code, check parameters
648 if (theObject.IsNull())
651 Handle(GEOM_Function) aFunction, aLastFunction = theObject->GetLastFunction();
652 if (aLastFunction.IsNull()) return NULL; //There is no function which creates an object to be processed
655 Handle(GEOM_Object) aNewObject = GetEngine()->AddObject( GetDocID(), GEOM_COPY );
658 aFunction = aNewObject->AddFunction(GEOMImpl_HealingDriver::GetID(), DIVIDE_EDGE);
660 if (aFunction.IsNull()) return NULL;
662 //Check if the function is set correctly
663 if (aFunction->GetDriverGUID() != GEOMImpl_HealingDriver::GetID()) return NULL;
665 // prepare "data container" class IHealing
666 GEOMImpl_IHealing HI(aFunction);
667 HI.SetIndex( theIndex );
668 HI.SetDevideEdgeValue( theValue );
669 HI.SetIsByParameter( isByParameter );
670 HI.SetOriginal( aLastFunction );
672 //Compute the translation
675 if (!GetSolver()->ComputeFunction(aFunction))
677 SetErrorCode("Healing driver failed");
681 catch (Standard_Failure)
683 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
684 SetErrorCode(aFail->GetMessageString());
688 //Make a Python command
689 GEOM::TPythonDump(aFunction) << aNewObject << " = geompy.DivideEdge(" << theObject
690 << ", " << theIndex << ", " << theValue << ", " << (int)isByParameter << ")";
696 //=============================================================================
700 //=============================================================================
701 bool GEOMImpl_IHealingOperations::GetFreeBoundary (Handle(GEOM_Object) theObject,
702 Handle(TColStd_HSequenceOfTransient)& theClosed,
703 Handle(TColStd_HSequenceOfTransient)& theOpen )
705 // set error code, check parameters
708 if ( theObject.IsNull() || theClosed.IsNull() || theOpen.IsNull() )
711 TopoDS_Shape aShape = theObject->GetValue();
712 if ( aShape.IsNull() )
715 // get free boundary shapes
716 ShapeAnalysis_FreeBounds anAnalizer( aShape );
717 TopoDS_Compound aClosed = anAnalizer.GetClosedWires();
718 TopoDS_Compound anOpen = anAnalizer.GetOpenWires();
720 // iterate through shapes and append them to the return sequence
721 Handle(GEOM_Object) anObj;
722 Handle(GEOM_Function) aFunction;
723 TopExp_Explorer anExp;
724 for ( anExp.Init( aClosed, TopAbs_WIRE ); anExp.More(); anExp.Next() )
726 anObj = GetEngine()->AddObject( GetDocID(), GEOM_FREE_BOUNDS );
727 aFunction = anObj->AddFunction( GEOMImpl_CopyDriver::GetID(), COPY_WITHOUT_REF );
728 TopoDS_Shape aValueShape = anExp.Current();
729 aFunction->SetValue( aValueShape );
730 theClosed->Append(anObj);
732 for ( anExp.Init( anOpen, TopAbs_WIRE ); anExp.More(); anExp.Next() )
734 anObj = GetEngine()->AddObject( GetDocID(), GEOM_FREE_BOUNDS );
735 aFunction = anObj->AddFunction( GEOMImpl_CopyDriver::GetID(), COPY_WITHOUT_REF );
736 TopoDS_Shape aValueShape = anExp.Current();
737 aFunction->SetValue( aValueShape );
738 theOpen->Append(anObj);
741 if(!aFunction.IsNull()) {
743 //Make a Python command
744 GEOM::TPythonDump pd (aFunction);
746 Standard_Integer i, aLen = theClosed->Length();
749 for (i = 1; i <= aLen; i++) {
750 Handle(GEOM_Object) anObj_i = Handle(GEOM_Object)::DownCast(theClosed->Value(i));
751 pd << anObj_i << ((i < aLen) ? ", " : "");
755 pd << "(isDone, empty_list, ";
758 aLen = theOpen->Length();
761 for (i = 1; i <= aLen; i++) {
762 Handle(GEOM_Object) anObj_i = Handle(GEOM_Object)::DownCast(theOpen->Value(i));
763 pd << anObj_i << ((i < aLen) ? ", " : "");
770 pd << ") = geompy.GetFreeBoundary(" << theObject << ")";
778 //=============================================================================
782 //=============================================================================
783 Handle(GEOM_Object) GEOMImpl_IHealingOperations::ChangeOrientation (Handle(GEOM_Object) theObject)
785 // set error code, check parameters
788 if (theObject.IsNull())
791 Handle(GEOM_Function) aFunction, aLastFunction = theObject->GetLastFunction();
792 if (aLastFunction.IsNull())
793 return NULL; //There is no function which creates an object to be processed
796 aFunction = theObject->AddFunction(GEOMImpl_HealingDriver::GetID(), CHANGE_ORIENTATION);
798 if (aFunction.IsNull())
801 //Check if the function is set correctly
802 if (aFunction->GetDriverGUID() != GEOMImpl_HealingDriver::GetID()) return NULL;
804 // prepare "data container" class IHealing
805 GEOMImpl_IHealing HI(aFunction);
806 HI.SetOriginal( aLastFunction );
808 //Compute the translation
810 if (!GetSolver()->ComputeFunction(aFunction)) {
811 SetErrorCode("Healing driver failed");
815 catch (Standard_Failure) {
816 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
817 SetErrorCode(aFail->GetMessageString());
821 //Make a Python command
822 GEOM::TPythonDump(aFunction) << "geompy.ChangeOrientationShell("
830 //=============================================================================
832 * ChangeOrientationCopy
834 //=============================================================================
835 Handle(GEOM_Object) GEOMImpl_IHealingOperations::ChangeOrientationCopy (Handle(GEOM_Object) theObject)
837 // set error code, check parameters
840 if (theObject.IsNull())
843 Handle(GEOM_Function) aFunction, aLastFunction = theObject->GetLastFunction();
844 if (aLastFunction.IsNull())
845 return NULL; //There is no function which creates an object to be processed
848 Handle(GEOM_Object) aNewObject = GetEngine()->AddObject( GetDocID(), GEOM_COPY );
851 aFunction = aNewObject->AddFunction(GEOMImpl_HealingDriver::GetID(), CHANGE_ORIENTATION);
853 if (aFunction.IsNull())
856 //Check if the function is set correctly
857 if (aFunction->GetDriverGUID() != GEOMImpl_HealingDriver::GetID()) return NULL;
859 // prepare "data container" class IHealing
860 GEOMImpl_IHealing HI(aFunction);
861 HI.SetOriginal( aLastFunction );
863 //Compute the translation
865 if (!GetSolver()->ComputeFunction(aFunction)) {
866 SetErrorCode("Healing driver failed");
870 catch (Standard_Failure) {
871 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
872 SetErrorCode(aFail->GetMessageString());
876 //Make a Python command
877 GEOM::TPythonDump(aFunction) << aNewObject << " = geompy.ChangeOrientationShellCopy("