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
24 #pragma warning( disable:4786 )
29 #include <Standard_Stream.hxx>
31 #include <GEOMImpl_IHealingOperations.hxx>
33 #include <GEOM_PythonDump.hxx>
35 #include <GEOMImpl_HealingDriver.hxx>
36 #include <GEOMImpl_Types.hxx>
37 #include <GEOMImpl_IHealing.hxx>
38 #include <GEOMImpl_CopyDriver.hxx>
40 #include <ShHealOper_ShapeProcess.hxx>
42 #include "utilities.h"
44 #include <Utils_ExceptHandlers.hxx>
46 #include <ShapeAnalysis_FreeBounds.hxx>
48 #include <TopoDS_Compound.hxx>
49 #include <TopExp_Explorer.hxx>
51 #include <TColStd_HArray1OfExtendedString.hxx>
52 #include <TColStd_HSequenceOfTransient.hxx>
53 #include <TCollection_AsciiString.hxx>
55 #include <TDF_Tool.hxx>
57 #include <Standard_Failure.hxx>
58 #include <Standard_ErrorHandler.hxx> // CAREFUL ! position of this file is critic : see Lucien PIGNOLONI / OCC
61 //=============================================================================
65 //=============================================================================
67 GEOMImpl_IHealingOperations::GEOMImpl_IHealingOperations (GEOM_Engine* theEngine, int theDocID)
68 : GEOM_IOperations(theEngine, theDocID)
70 MESSAGE("GEOMImpl_IHealingOperations::GEOMImpl_IHealingOperations");
73 //=============================================================================
77 //=============================================================================
79 GEOMImpl_IHealingOperations::~GEOMImpl_IHealingOperations()
81 MESSAGE("GEOMImpl_IHealingOperations::~GEOMImpl_IHealingOperations");
85 //=============================================================================
89 //=============================================================================
90 Handle(GEOM_Object) GEOMImpl_IHealingOperations::ShapeProcess (Handle(GEOM_Object) theObject,
91 const Handle(TColStd_HArray1OfExtendedString)& theOperators,
92 const Handle(TColStd_HArray1OfExtendedString)& theParams,
93 const Handle(TColStd_HArray1OfExtendedString)& theValues)
95 // set error code, check parameters
98 if (theObject.IsNull())
101 if (theOperators.IsNull() || theOperators->Length() <= 0) {
102 SetErrorCode("No operators requested");
106 Standard_Integer nbParams = 0, nbValues = 0;
107 if (!theParams.IsNull()) {
108 nbParams = theParams->Length();
110 if (!theValues.IsNull()) {
111 nbValues = theValues->Length();
114 if (nbParams != nbValues) {
115 SetErrorCode("Number of parameter values must be equal to the number of parameters");
119 Handle(GEOM_Function) aFunction, aLastFunction = theObject->GetLastFunction();
120 if (aLastFunction.IsNull()) return NULL; //There is no function which creates an object to be processed
123 Handle(GEOM_Object) aNewObject = GetEngine()->AddObject( GetDocID(), GEOM_COPY );
126 aFunction = aNewObject->AddFunction(GEOMImpl_HealingDriver::GetID(), SHAPE_PROCESS);
128 if (aFunction.IsNull()) return NULL;
130 //Check if the function is set correctly
131 if (aFunction->GetDriverGUID() != GEOMImpl_HealingDriver::GetID()) return NULL;
133 // prepare "data container" class IHealing
134 GEOMImpl_IHealing HI(aFunction);
135 HI.SetOriginal(aLastFunction);
136 HI.SetOperators( theOperators );
138 HI.SetParameters( theParams );
139 HI.SetValues( theValues );
142 //Compute the translation
144 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
147 if (!GetSolver()->ComputeFunction(aFunction))
149 SetErrorCode("Shape Healing algorithm failed");
153 catch (Standard_Failure)
155 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
156 SetErrorCode(aFail->GetMessageString());
160 //Make a Python command
161 GEOM::TPythonDump pd (aFunction);
162 pd << aNewObject << " = geompy.ProcessShape(" << theObject << ", [";
165 int i = theOperators->Lower(), nb = theOperators->Upper();
166 for ( ; i <= nb; i++) {
167 pd << "\"" << TCollection_AsciiString(theOperators->Value( i )).ToCString()
168 << (( i < nb ) ? "\", " : "\"");
171 // list of parameters
172 i = theParams->Lower(); nb = theParams->Upper();
173 for ( ; i <= nb; i++) {
174 pd << "\"" << TCollection_AsciiString(theParams->Value( i )).ToCString()
175 << (( i < nb ) ? "\", " : "\"");
179 i = theValues->Lower(); nb = theValues->Upper();
180 for ( ; i <= nb; i++) {
181 pd << "\"" << TCollection_AsciiString(theValues->Value( i )).ToCString()
182 << (( i < nb ) ? "\", " : "\"");
190 //=============================================================================
194 //=============================================================================
195 void GEOMImpl_IHealingOperations::GetShapeProcessParameters (list<string>& theOperations,
196 list<string>& theParams,
197 list<string>& theValues)
199 ShHealOper_ShapeProcess aHealer;
200 TColStd_SequenceOfAsciiString anOperators;
201 int nbOperatorErrors( 0 );
202 if ( aHealer.GetOperators( anOperators ) )
204 for ( Standard_Integer i = 1; i <= anOperators.Length(); i++ )
206 string anOperation = anOperators.Value( i ).ToCString();
207 if ( GetOperatorParameters( anOperation, theParams, theValues ) )
208 theOperations.push_back( anOperation );
215 SetErrorCode("ERROR retrieving operators (GEOMImpl_IHealingOperations)");
218 if ( nbOperatorErrors ) {
219 TCollection_AsciiString aMsg ("ERRORS retrieving ShapeProcess parameters (GEOMImpl_IHealingOperations): nbOperatorErrors = ");
220 aMsg += TCollection_AsciiString( nbOperatorErrors );
221 MESSAGE(aMsg.ToCString());
225 //=============================================================================
227 * GetOperatorParameters
229 //=============================================================================
230 bool GEOMImpl_IHealingOperations::GetOperatorParameters( const string theOperation,
231 list<string>& theParams,
232 list<string>& theValues )
234 ShHealOper_ShapeProcess aHealer;
235 int nbParamValueErrors( 0 );
236 list<string> aParams;
237 if ( GetParameters( theOperation, aParams ) ) {
238 for ( list<string>::iterator it = aParams.begin(); it != aParams.end(); ++it ) {
239 TCollection_AsciiString aParam( (Standard_CString)(*it).c_str() );
240 TCollection_AsciiString aValue;
241 if ( aHealer.GetParameter( aParam, aValue ) ) {
242 theParams.push_back( aParam.ToCString() );
243 theValues.push_back( aValue.ToCString() );
246 nbParamValueErrors++;
252 if ( nbParamValueErrors ) {
253 TCollection_AsciiString aMsg ("ERRORS retrieving ShapeProcess parameter values (GEOMImpl_IHealingOperations): nbParamValueErrors = ");
254 aMsg += TCollection_AsciiString( nbParamValueErrors );
255 MESSAGE(aMsg.ToCString());
261 //=============================================================================
265 //=============================================================================
266 bool GEOMImpl_IHealingOperations::GetParameters (const string theOperation,
267 list<string>& theParams)
269 if ( theOperation == "SplitAngle" ) {
270 theParams.push_back( "SplitAngle.Angle" );
271 theParams.push_back( "SplitAngle.MaxTolerance" );
273 } else if ( theOperation == "SplitClosedFaces" ) {
274 theParams.push_back( "SplitClosedFaces.NbSplitPoints" );
276 } else if ( theOperation == "FixFaceSize" ) {
277 theParams.push_back( "FixFaceSize.Tolerance" );
279 } else if( theOperation == "DropSmallEdges" ) {
280 theParams.push_back( "DropSmallEdges.Tolerance3d" );
282 } else if( theOperation == "BSplineRestriction" ) {
283 theParams.push_back( "BSplineRestriction.SurfaceMode" );
284 theParams.push_back( "BSplineRestriction.Curve3dMode" );
285 theParams.push_back( "BSplineRestriction.Curve2dMode" );
286 theParams.push_back( "BSplineRestriction.Tolerance3d" );
287 theParams.push_back( "BSplineRestriction.Tolerance2d" );
288 theParams.push_back( "BSplineRestriction.RequiredDegree" );
289 theParams.push_back( "BSplineRestriction.RequiredNbSegments" );
290 theParams.push_back( "BSplineRestriction.Continuity3d" );
291 theParams.push_back( "BSplineRestriction.Continuity2d" );
293 } else if( theOperation == "SplitContinuity" ) {
294 theParams.push_back( "SplitContinuity.Tolerance3d" );
295 theParams.push_back( "SplitContinuity.SurfaceContinuity" );
296 theParams.push_back( "SplitContinuity.CurveContinuity" );
298 } else if( theOperation == "ToBezier" ) {
299 theParams.push_back( "ToBezier.SurfaceMode" );
300 theParams.push_back( "ToBezier.Curve3dMode" );
301 theParams.push_back( "ToBezier.Curve2dMode" );
302 theParams.push_back( "ToBezier.MaxTolerance" );
304 } else if( theOperation == "SameParameter" ) {
305 theParams.push_back( "SameParameter.Tolerance3d" );
307 } else if( theOperation == "FixShape" ) {
308 theParams.push_back( "FixShape.Tolerance3d" );
309 theParams.push_back( "FixShape.MaxTolerance3d" );
318 //=============================================================================
322 //=============================================================================
323 Handle(GEOM_Object) GEOMImpl_IHealingOperations::SuppressFaces
324 (Handle(GEOM_Object) theObject, const Handle(TColStd_HArray1OfInteger)& theFaces)
326 // set error code, check parameters
329 if ( theObject.IsNull() ) // if theFaces.IsNull() - it's OK, it means that ALL faces must be removed..
332 Handle(GEOM_Function) aFunction, aLastFunction = theObject->GetLastFunction();
333 if(aLastFunction.IsNull()) return NULL; //There is no function which creates an object to be processed
336 Handle(GEOM_Object) aNewObject = GetEngine()->AddObject( GetDocID(), GEOM_COPY );
339 aFunction = aNewObject->AddFunction(GEOMImpl_HealingDriver::GetID(), SUPPRESS_FACES);
341 if(aFunction.IsNull()) return NULL;
343 //Check if the function is set correctly
344 if(aFunction->GetDriverGUID() != GEOMImpl_HealingDriver::GetID()) return NULL;
346 // prepare "data container" class IHealing
347 GEOMImpl_IHealing HI(aFunction);
348 HI.SetFaces( theFaces );
349 HI.SetOriginal( aLastFunction );
351 //Compute the translation
353 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
356 if (!GetSolver()->ComputeFunction(aFunction))
358 SetErrorCode("Healing driver failed");
362 catch (Standard_Failure)
364 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
365 SetErrorCode(aFail->GetMessageString());
369 //Make a Python command
370 GEOM::TPythonDump pd (aFunction);
371 pd << aNewObject << " = geompy.SuppressFaces(" << theObject << ", [";
374 int i = theFaces->Lower(), nb = theFaces->Upper();
375 for ( ; i <= nb; i++)
376 pd << theFaces->Value( i ) << (( i < nb ) ? ", " : "])");
383 //=============================================================================
387 //=============================================================================
388 Handle(GEOM_Object) GEOMImpl_IHealingOperations::CloseContour
389 (Handle(GEOM_Object) theObject,
390 const Handle(TColStd_HArray1OfInteger)& theWires,
393 // set error code, check parameters
396 if (theObject.IsNull())
398 SetErrorCode("NULL object given");
402 Handle(GEOM_Function) aFunction, aLastFunction = theObject->GetLastFunction();
403 if (aLastFunction.IsNull()) return NULL; //There is no function which creates an object to be processed
406 Handle(GEOM_Object) aNewObject = GetEngine()->AddObject( GetDocID(), GEOM_COPY );
409 aFunction = aNewObject->AddFunction(GEOMImpl_HealingDriver::GetID(), CLOSE_CONTOUR);
411 if (aFunction.IsNull()) return NULL;
413 //Check if the function is set correctly
414 if(aFunction->GetDriverGUID() != GEOMImpl_HealingDriver::GetID()) return NULL;
416 // prepare "data container" class IHealing
417 GEOMImpl_IHealing HI(aFunction);
418 HI.SetWires( theWires );
419 HI.SetIsCommonVertex( isCommonVertex );
420 HI.SetOriginal( aLastFunction );
422 //Compute the translation
424 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
427 if (!GetSolver()->ComputeFunction(aFunction))
429 SetErrorCode("Healing driver failed");
433 catch (Standard_Failure)
435 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
436 SetErrorCode(aFail->GetMessageString());
440 //Make a Python command
441 GEOM::TPythonDump pd (aFunction);
442 pd << aNewObject << " = geompy.CloseContour(" << theObject << ", [";
445 if (!theWires.IsNull())
447 int i = theWires->Lower(), nb = theWires->Upper();
448 pd << theWires->Value(i++);
450 pd << ", " << theWires->Value(i++);
452 pd << "], " << (int)isCommonVertex << ")";
458 //=============================================================================
462 //=============================================================================
463 Handle(GEOM_Object) GEOMImpl_IHealingOperations::RemoveIntWires
464 (Handle(GEOM_Object) theObject, const Handle(TColStd_HArray1OfInteger)& theWires)
466 // set error code, check parameters
469 if (theObject.IsNull()) // if theWires is NULL it's OK, it means that ALL wires must be removed
472 Handle(GEOM_Function) aFunction, aLastFunction = theObject->GetLastFunction();
473 if (aLastFunction.IsNull()) return NULL; //There is no function which creates an object to be processed
476 Handle(GEOM_Object) aNewObject = GetEngine()->AddObject( GetDocID(), GEOM_COPY );
479 aFunction = aNewObject->AddFunction(GEOMImpl_HealingDriver::GetID(), REMOVE_INT_WIRES);
481 if (aFunction.IsNull()) return NULL;
483 //Check if the function is set correctly
484 if (aFunction->GetDriverGUID() != GEOMImpl_HealingDriver::GetID()) return NULL;
486 // prepare "data container" class IHealing
487 GEOMImpl_IHealing HI(aFunction);
488 HI.SetWires( theWires );
489 HI.SetOriginal( aLastFunction );
491 //Compute the translation
493 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
496 if (!GetSolver()->ComputeFunction(aFunction))
498 SetErrorCode("Healing driver failed");
502 catch (Standard_Failure)
504 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
505 SetErrorCode(aFail->GetMessageString());
509 //Make a Python command
510 GEOM::TPythonDump pd (aFunction);
511 pd << aNewObject << " = geompy.SuppressInternalWires(" << theObject << ", [";
514 if (!theWires.IsNull()) {
515 int i = theWires->Lower(), nb = theWires->Upper();
516 for ( ; i <= nb; i++)
517 pd << theWires->Value( i ) << (( i < nb ) ? ", " : "])");
526 //=============================================================================
530 //=============================================================================
531 Handle(GEOM_Object) GEOMImpl_IHealingOperations::FillHoles (Handle(GEOM_Object) theObject,
532 const Handle(TColStd_HArray1OfInteger)& theWires)
534 // set error code, check parameters
537 if (theObject.IsNull()) // if theWires is NULL it's OK, it means that ALL holes must be removed
540 Handle(GEOM_Function) aFunction, aLastFunction = theObject->GetLastFunction();
541 if (aLastFunction.IsNull()) return NULL; //There is no function which creates an object to be processed
544 Handle(GEOM_Object) aNewObject = GetEngine()->AddObject( GetDocID(), GEOM_COPY );
547 aFunction = aNewObject->AddFunction(GEOMImpl_HealingDriver::GetID(), FILL_HOLES);
549 if (aFunction.IsNull()) return NULL;
551 //Check if the function is set correctly
552 if (aFunction->GetDriverGUID() != GEOMImpl_HealingDriver::GetID()) return NULL;
554 // prepare "data container" class IHealing
555 GEOMImpl_IHealing HI(aFunction);
556 HI.SetWires( theWires );
557 HI.SetOriginal( aLastFunction );
559 //Compute the translation
561 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
564 if (!GetSolver()->ComputeFunction(aFunction))
566 SetErrorCode("Healing driver failed");
570 catch (Standard_Failure)
572 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
573 SetErrorCode(aFail->GetMessageString());
577 //Make a Python command
578 GEOM::TPythonDump pd (aFunction);
579 pd << aNewObject << " = geompy.SuppressHoles(" << theObject << ", [";
582 if ( theWires.IsNull() )
585 int i = theWires->Lower(), nb = theWires->Upper();
586 for ( ; i <= nb; i++)
587 pd << theWires->Value( i ) << (( i < nb ) ? ", " : "])");
594 //=============================================================================
598 //=============================================================================
599 Handle(GEOM_Object) GEOMImpl_IHealingOperations::Sew (Handle(GEOM_Object) theObject,
602 // set error code, check parameters
605 if (theObject.IsNull())
608 Handle(GEOM_Function) aFunction, aLastFunction = theObject->GetLastFunction();
609 if (aLastFunction.IsNull()) return NULL; //There is no function which creates an object to be processed
612 Handle(GEOM_Object) aNewObject = GetEngine()->AddObject( GetDocID(), GEOM_COPY );
615 aFunction = aNewObject->AddFunction(GEOMImpl_HealingDriver::GetID(), SEWING);
617 if (aFunction.IsNull()) return NULL;
619 //Check if the function is set correctly
620 if (aFunction->GetDriverGUID() != GEOMImpl_HealingDriver::GetID()) return NULL;
622 // prepare "data container" class IHealing
623 GEOMImpl_IHealing HI(aFunction);
624 HI.SetTolerance( theTolerance );
625 HI.SetOriginal( aLastFunction );
627 //Compute the translation
629 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
632 if (!GetSolver()->ComputeFunction(aFunction))
634 SetErrorCode("Healing driver failed");
638 catch (Standard_Failure)
640 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
641 SetErrorCode(aFail->GetMessageString());
645 //Make a Python command
646 GEOM::TPythonDump(aFunction) << aNewObject << " = geompy.Sew("
647 << theObject << ", " << theTolerance << ")";
653 //=============================================================================
657 //=============================================================================
658 Handle(GEOM_Object) GEOMImpl_IHealingOperations::DivideEdge (Handle(GEOM_Object) theObject,
663 // set error code, check parameters
666 if (theObject.IsNull())
669 Handle(GEOM_Function) aFunction, aLastFunction = theObject->GetLastFunction();
670 if (aLastFunction.IsNull()) return NULL; //There is no function which creates an object to be processed
673 Handle(GEOM_Object) aNewObject = GetEngine()->AddObject( GetDocID(), GEOM_COPY );
676 aFunction = aNewObject->AddFunction(GEOMImpl_HealingDriver::GetID(), DIVIDE_EDGE);
678 if (aFunction.IsNull()) return NULL;
680 //Check if the function is set correctly
681 if (aFunction->GetDriverGUID() != GEOMImpl_HealingDriver::GetID()) return NULL;
683 // prepare "data container" class IHealing
684 GEOMImpl_IHealing HI(aFunction);
685 HI.SetIndex( theIndex );
686 HI.SetDevideEdgeValue( theValue );
687 HI.SetIsByParameter( isByParameter );
688 HI.SetOriginal( aLastFunction );
690 //Compute the translation
692 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
695 if (!GetSolver()->ComputeFunction(aFunction))
697 SetErrorCode("Healing driver failed");
701 catch (Standard_Failure)
703 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
704 SetErrorCode(aFail->GetMessageString());
708 //Make a Python command
709 GEOM::TPythonDump(aFunction) << aNewObject << " = geompy.DivideEdge(" << theObject
710 << ", " << theIndex << ", " << theValue << ", " << (int)isByParameter << ")";
716 //=============================================================================
720 //=============================================================================
721 bool GEOMImpl_IHealingOperations::GetFreeBoundary (Handle(GEOM_Object) theObject,
722 Handle(TColStd_HSequenceOfTransient)& theClosed,
723 Handle(TColStd_HSequenceOfTransient)& theOpen )
725 // set error code, check parameters
728 if ( theObject.IsNull() || theClosed.IsNull() || theOpen.IsNull() )
731 TopoDS_Shape aShape = theObject->GetValue();
732 if ( aShape.IsNull() )
735 // get free boundary shapes
736 ShapeAnalysis_FreeBounds anAnalizer( aShape );
737 TopoDS_Compound aClosed = anAnalizer.GetClosedWires();
738 TopoDS_Compound anOpen = anAnalizer.GetOpenWires();
740 // iterate through shapes and append them to the return sequence
741 Handle(GEOM_Object) anObj;
742 Handle(GEOM_Function) aFunction;
743 TopExp_Explorer anExp;
744 for ( anExp.Init( aClosed, TopAbs_WIRE ); anExp.More(); anExp.Next() )
746 anObj = GetEngine()->AddObject( GetDocID(), GEOM_FREE_BOUNDS );
747 aFunction = anObj->AddFunction( GEOMImpl_CopyDriver::GetID(), COPY_WITHOUT_REF );
748 TopoDS_Shape aValueShape = anExp.Current();
749 aFunction->SetValue( aValueShape );
750 theClosed->Append(anObj);
752 for ( anExp.Init( anOpen, TopAbs_WIRE ); anExp.More(); anExp.Next() )
754 anObj = GetEngine()->AddObject( GetDocID(), GEOM_FREE_BOUNDS );
755 aFunction = anObj->AddFunction( GEOMImpl_CopyDriver::GetID(), COPY_WITHOUT_REF );
756 TopoDS_Shape aValueShape = anExp.Current();
757 aFunction->SetValue( aValueShape );
758 theOpen->Append(anObj);
761 if(!aFunction.IsNull()) {
763 //Make a Python command
764 GEOM::TPythonDump pd (aFunction);
766 Standard_Integer i, aLen = theClosed->Length();
769 for (i = 1; i <= aLen; i++) {
770 Handle(GEOM_Object) anObj_i = Handle(GEOM_Object)::DownCast(theClosed->Value(i));
771 pd << anObj_i << ((i < aLen) ? ", " : "");
775 pd << "(isDone, empty_list, ";
778 aLen = theOpen->Length();
781 for (i = 1; i <= aLen; i++) {
782 Handle(GEOM_Object) anObj_i = Handle(GEOM_Object)::DownCast(theOpen->Value(i));
783 pd << anObj_i << ((i < aLen) ? ", " : "");
790 pd << ") = geompy.GetFreeBoundary(" << theObject << ")";
798 //=============================================================================
802 //=============================================================================
803 Handle(GEOM_Object) GEOMImpl_IHealingOperations::ChangeOrientation (Handle(GEOM_Object) theObject)
805 // set error code, check parameters
808 if (theObject.IsNull())
811 if (!theObject->IsMainShape()) {
812 SetErrorCode("Sub shape cannot be transformed - need to create a copy");
816 Handle(GEOM_Function) aFunction, aLastFunction = theObject->GetLastFunction();
817 if (aLastFunction.IsNull())
818 return NULL; //There is no function which creates an object to be processed
821 aFunction = theObject->AddFunction(GEOMImpl_HealingDriver::GetID(), CHANGE_ORIENTATION);
823 if (aFunction.IsNull())
826 //Check if the function is set correctly
827 if (aFunction->GetDriverGUID() != GEOMImpl_HealingDriver::GetID()) return NULL;
829 // prepare "data container" class IHealing
830 GEOMImpl_IHealing HI(aFunction);
831 HI.SetOriginal( aLastFunction );
833 //Compute the translation
835 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
838 if (!GetSolver()->ComputeFunction(aFunction)) {
839 SetErrorCode("Healing driver failed");
843 catch (Standard_Failure) {
844 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
845 SetErrorCode(aFail->GetMessageString());
849 //Make a Python command
850 GEOM::TPythonDump(aFunction) << "geompy.ChangeOrientationShell("
858 //=============================================================================
860 * ChangeOrientationCopy
862 //=============================================================================
863 Handle(GEOM_Object) GEOMImpl_IHealingOperations::ChangeOrientationCopy (Handle(GEOM_Object) theObject)
865 // set error code, check parameters
868 if (theObject.IsNull())
871 Handle(GEOM_Function) aFunction, aLastFunction = theObject->GetLastFunction();
872 if (aLastFunction.IsNull())
873 return NULL; //There is no function which creates an object to be processed
876 Handle(GEOM_Object) aNewObject = GetEngine()->AddObject( GetDocID(), GEOM_COPY );
879 aFunction = aNewObject->AddFunction(GEOMImpl_HealingDriver::GetID(), CHANGE_ORIENTATION);
881 if (aFunction.IsNull())
884 //Check if the function is set correctly
885 if (aFunction->GetDriverGUID() != GEOMImpl_HealingDriver::GetID()) return NULL;
887 // prepare "data container" class IHealing
888 GEOMImpl_IHealing HI(aFunction);
889 HI.SetOriginal( aLastFunction );
891 //Compute the translation
893 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
896 if (!GetSolver()->ComputeFunction(aFunction)) {
897 SetErrorCode("Healing driver failed");
901 catch (Standard_Failure) {
902 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
903 SetErrorCode(aFail->GetMessageString());
907 //Make a Python command
908 GEOM::TPythonDump(aFunction) << aNewObject << " = geompy.ChangeOrientationShellCopy("