1 // Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE
3 // Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License.
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 // Lesser General Public License for more details.
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
23 #pragma warning( disable:4786 )
26 #include <Standard_Stream.hxx>
28 #include <GEOMImpl_IHealingOperations.hxx>
30 #include <GEOM_PythonDump.hxx>
32 #include <GEOMImpl_HealingDriver.hxx>
33 #include <GEOMImpl_Types.hxx>
34 #include <GEOMImpl_IHealing.hxx>
35 #include <GEOMImpl_CopyDriver.hxx>
37 #include <ShHealOper_ShapeProcess.hxx>
39 #include "utilities.h"
41 #include <Utils_ExceptHandlers.hxx>
43 #include <ShapeAnalysis_FreeBounds.hxx>
45 #include <TopoDS_Compound.hxx>
46 #include <TopExp_Explorer.hxx>
48 #include <TColStd_HArray1OfExtendedString.hxx>
49 #include <TColStd_HSequenceOfTransient.hxx>
50 #include <TCollection_AsciiString.hxx>
52 #include <TDF_Tool.hxx>
54 #include <Standard_Failure.hxx>
55 #include <Standard_ErrorHandler.hxx> // CAREFUL ! position of this file is critic : see Lucien PIGNOLONI / OCC
57 #ifdef OCC_VERSION_SERVICEPACK
58 #if (OCC_VERSION_MAJOR << 24 | OCC_VERSION_MINOR << 16 | OCC_VERSION_MAINTENANCE << 8 | OCC_VERSION_SERVICEPACK) > 0x06030008
59 #define OCCT_6_3_0_sp_9
64 //=============================================================================
68 //=============================================================================
70 GEOMImpl_IHealingOperations::GEOMImpl_IHealingOperations (GEOM_Engine* theEngine, int theDocID)
71 : GEOM_IOperations(theEngine, theDocID)
73 MESSAGE("GEOMImpl_IHealingOperations::GEOMImpl_IHealingOperations");
76 //=============================================================================
80 //=============================================================================
82 GEOMImpl_IHealingOperations::~GEOMImpl_IHealingOperations()
84 MESSAGE("GEOMImpl_IHealingOperations::~GEOMImpl_IHealingOperations");
88 //=============================================================================
92 //=============================================================================
93 Handle(GEOM_Object) GEOMImpl_IHealingOperations::ShapeProcess (Handle(GEOM_Object) theObject,
94 const Handle(TColStd_HArray1OfExtendedString)& theOperators,
95 const Handle(TColStd_HArray1OfExtendedString)& theParams,
96 const Handle(TColStd_HArray1OfExtendedString)& theValues)
98 // set error code, check parameters
101 if (theObject.IsNull())
104 if (theOperators.IsNull() || theOperators->Length() <= 0) {
105 SetErrorCode("No operators requested");
109 Standard_Integer nbParams = 0, nbValues = 0;
110 if (!theParams.IsNull()) {
111 nbParams = theParams->Length();
113 if (!theValues.IsNull()) {
114 nbValues = theValues->Length();
117 if (nbParams != nbValues) {
118 SetErrorCode("Number of parameter values must be equal to the number of parameters");
122 Handle(GEOM_Function) aFunction, aLastFunction = theObject->GetLastFunction();
123 if (aLastFunction.IsNull()) return NULL; //There is no function which creates an object to be processed
126 Handle(GEOM_Object) aNewObject = GetEngine()->AddObject( GetDocID(), GEOM_COPY );
129 aFunction = aNewObject->AddFunction(GEOMImpl_HealingDriver::GetID(), SHAPE_PROCESS);
131 if (aFunction.IsNull()) return NULL;
133 //Check if the function is set correctly
134 if (aFunction->GetDriverGUID() != GEOMImpl_HealingDriver::GetID()) return NULL;
136 // prepare "data container" class IHealing
137 GEOMImpl_IHealing HI(aFunction);
138 HI.SetOriginal(aLastFunction);
139 HI.SetOperators( theOperators );
141 HI.SetParameters( theParams );
142 HI.SetValues( theValues );
145 //Compute the translation
147 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
150 if (!GetSolver()->ComputeFunction(aFunction))
152 SetErrorCode("Shape Healing algorithm failed");
156 catch (Standard_Failure)
158 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
159 SetErrorCode(aFail->GetMessageString());
163 //Make a Python command
164 GEOM::TPythonDump pd (aFunction);
165 pd << aNewObject << " = geompy.ProcessShape(" << theObject << ", [";
168 int i = theOperators->Lower(), nb = theOperators->Upper();
169 for ( ; i <= nb; i++) {
170 pd << "\"" << TCollection_AsciiString(theOperators->Value( i )).ToCString()
171 << (( i < nb ) ? "\", " : "\"");
174 // list of parameters
175 i = theParams->Lower(); nb = theParams->Upper();
176 for ( ; i <= nb; i++) {
177 pd << "\"" << TCollection_AsciiString(theParams->Value( i )).ToCString()
178 << (( i < nb ) ? "\", " : "\"");
182 i = theValues->Lower(); nb = theValues->Upper();
183 for ( ; i <= nb; i++) {
184 pd << "\"" << TCollection_AsciiString(theValues->Value( i )).ToCString()
185 << (( i < nb ) ? "\", " : "\"");
193 //=============================================================================
197 //=============================================================================
198 void GEOMImpl_IHealingOperations::GetShapeProcessParameters (std::list<std::string>& theOperations,
199 std::list<std::string>& theParams,
200 std::list<std::string>& theValues)
202 ShHealOper_ShapeProcess aHealer;
203 TColStd_SequenceOfAsciiString anOperators;
204 int nbOperatorErrors( 0 );
205 if ( aHealer.GetOperators( anOperators ) )
207 for ( Standard_Integer i = 1; i <= anOperators.Length(); i++ )
209 std::string anOperation = anOperators.Value( i ).ToCString();
210 if ( GetOperatorParameters( anOperation, theParams, theValues ) )
211 theOperations.push_back( anOperation );
218 SetErrorCode("ERROR retrieving operators (GEOMImpl_IHealingOperations)");
221 if ( nbOperatorErrors ) {
222 TCollection_AsciiString aMsg ("ERRORS retrieving ShapeProcess parameters (GEOMImpl_IHealingOperations): nbOperatorErrors = ");
223 aMsg += TCollection_AsciiString( nbOperatorErrors );
224 MESSAGE(aMsg.ToCString());
228 //=============================================================================
230 * GetOperatorParameters
232 //=============================================================================
233 bool GEOMImpl_IHealingOperations::GetOperatorParameters( const std::string theOperation,
234 std::list<std::string>& theParams,
235 std::list<std::string>& theValues )
237 ShHealOper_ShapeProcess aHealer;
238 int nbParamValueErrors( 0 );
239 std::list<std::string> aParams;
240 if ( GetParameters( theOperation, aParams ) ) {
241 for ( std::list<std::string>::iterator it = aParams.begin(); it != aParams.end(); ++it ) {
242 TCollection_AsciiString aParam( (Standard_CString)(*it).c_str() );
243 TCollection_AsciiString aValue;
244 if ( aHealer.GetParameter( aParam, aValue ) ) {
245 theParams.push_back( aParam.ToCString() );
246 theValues.push_back( aValue.ToCString() );
249 nbParamValueErrors++;
255 if ( nbParamValueErrors ) {
256 TCollection_AsciiString aMsg ("ERRORS retrieving ShapeProcess parameter values (GEOMImpl_IHealingOperations): nbParamValueErrors = ");
257 aMsg += TCollection_AsciiString( nbParamValueErrors );
258 MESSAGE(aMsg.ToCString());
264 //=============================================================================
268 //=============================================================================
269 bool GEOMImpl_IHealingOperations::GetParameters (const std::string theOperation,
270 std::list<std::string>& theParams)
272 if ( theOperation == "SplitAngle" ) {
273 theParams.push_back( "SplitAngle.Angle" );
274 theParams.push_back( "SplitAngle.MaxTolerance" );
276 } else if ( theOperation == "SplitClosedFaces" ) {
277 theParams.push_back( "SplitClosedFaces.NbSplitPoints" );
279 } else if ( theOperation == "FixFaceSize" ) {
280 theParams.push_back( "FixFaceSize.Tolerance" );
282 } else if( theOperation == "DropSmallEdges" ) {
283 theParams.push_back( "DropSmallEdges.Tolerance3d" );
285 } else if( theOperation == "BSplineRestriction" ) {
286 theParams.push_back( "BSplineRestriction.SurfaceMode" );
287 theParams.push_back( "BSplineRestriction.Curve3dMode" );
288 theParams.push_back( "BSplineRestriction.Curve2dMode" );
289 theParams.push_back( "BSplineRestriction.Tolerance3d" );
290 theParams.push_back( "BSplineRestriction.Tolerance2d" );
291 theParams.push_back( "BSplineRestriction.RequiredDegree" );
292 theParams.push_back( "BSplineRestriction.RequiredNbSegments" );
293 theParams.push_back( "BSplineRestriction.Continuity3d" );
294 theParams.push_back( "BSplineRestriction.Continuity2d" );
296 } else if( theOperation == "SplitContinuity" ) {
297 theParams.push_back( "SplitContinuity.Tolerance3d" );
298 theParams.push_back( "SplitContinuity.SurfaceContinuity" );
299 theParams.push_back( "SplitContinuity.CurveContinuity" );
301 } else if( theOperation == "ToBezier" ) {
302 theParams.push_back( "ToBezier.SurfaceMode" );
303 theParams.push_back( "ToBezier.Curve3dMode" );
304 theParams.push_back( "ToBezier.Curve2dMode" );
305 theParams.push_back( "ToBezier.MaxTolerance" );
307 } else if( theOperation == "SameParameter" ) {
308 theParams.push_back( "SameParameter.Tolerance3d" );
310 } else if( theOperation == "FixShape" ) {
311 theParams.push_back( "FixShape.Tolerance3d" );
312 theParams.push_back( "FixShape.MaxTolerance3d" );
321 //=============================================================================
325 //=============================================================================
326 Handle(GEOM_Object) GEOMImpl_IHealingOperations::SuppressFaces
327 (Handle(GEOM_Object) theObject, const Handle(TColStd_HArray1OfInteger)& theFaces)
329 // set error code, check parameters
332 if (theObject.IsNull()) // if theFaces.IsNull() - it's OK, it means that ALL faces must be removed..
335 Handle(GEOM_Function) aFunction, aLastFunction = theObject->GetLastFunction();
336 if (aLastFunction.IsNull()) return NULL; //There is no function which creates an object to be processed
339 Handle(GEOM_Object) aNewObject = GetEngine()->AddObject(GetDocID(), GEOM_COPY);
342 aFunction = aNewObject->AddFunction(GEOMImpl_HealingDriver::GetID(), SUPPRESS_FACES);
344 if (aFunction.IsNull()) return NULL;
346 //Check if the function is set correctly
347 if (aFunction->GetDriverGUID() != GEOMImpl_HealingDriver::GetID()) return NULL;
349 // prepare "data container" class IHealing
350 GEOMImpl_IHealing HI (aFunction);
351 HI.SetFaces(theFaces);
352 HI.SetOriginal(aLastFunction);
354 //Compute the translation
356 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
359 if (!GetSolver()->ComputeFunction(aFunction))
361 SetErrorCode("Healing driver failed");
365 catch (Standard_Failure)
367 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
368 SetErrorCode(aFail->GetMessageString());
372 //Make a Python command
373 GEOM::TPythonDump pd (aFunction);
374 pd << aNewObject << " = geompy.SuppressFaces(" << theObject << ", [";
377 int i = theFaces->Lower(), nb = theFaces->Upper();
378 for ( ; i <= nb; i++)
379 pd << theFaces->Value( i ) << (( i < nb ) ? ", " : "])");
385 //=============================================================================
389 //=============================================================================
390 Handle(GEOM_Object) GEOMImpl_IHealingOperations::CloseContour
391 (Handle(GEOM_Object) theObject,
392 const Handle(TColStd_HArray1OfInteger)& theWires,
395 // set error code, check parameters
398 if (theObject.IsNull())
400 SetErrorCode("NULL object given");
404 Handle(GEOM_Function) aFunction, aLastFunction = theObject->GetLastFunction();
405 if (aLastFunction.IsNull()) return NULL; //There is no function which creates an object to be processed
408 Handle(GEOM_Object) aNewObject = GetEngine()->AddObject( GetDocID(), GEOM_COPY );
411 aFunction = aNewObject->AddFunction(GEOMImpl_HealingDriver::GetID(), CLOSE_CONTOUR);
413 if (aFunction.IsNull()) return NULL;
415 //Check if the function is set correctly
416 if(aFunction->GetDriverGUID() != GEOMImpl_HealingDriver::GetID()) return NULL;
418 // prepare "data container" class IHealing
419 GEOMImpl_IHealing HI(aFunction);
420 HI.SetWires( theWires );
421 HI.SetIsCommonVertex( isCommonVertex );
422 HI.SetOriginal( aLastFunction );
424 //Compute the translation
426 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
429 if (!GetSolver()->ComputeFunction(aFunction))
431 SetErrorCode("Healing driver failed");
435 catch (Standard_Failure)
437 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
438 SetErrorCode(aFail->GetMessageString());
442 //Make a Python command
443 GEOM::TPythonDump pd (aFunction);
444 pd << aNewObject << " = geompy.CloseContour(" << theObject << ", [";
447 if (!theWires.IsNull())
449 int i = theWires->Lower(), nb = theWires->Upper();
450 pd << theWires->Value(i++);
452 pd << ", " << theWires->Value(i++);
454 pd << "], " << (int)isCommonVertex << ")";
460 //=============================================================================
464 //=============================================================================
465 Handle(GEOM_Object) GEOMImpl_IHealingOperations::RemoveIntWires
466 (Handle(GEOM_Object) theObject, const Handle(TColStd_HArray1OfInteger)& theWires)
468 // set error code, check parameters
471 if (theObject.IsNull()) // if theWires is NULL it's OK, it means that ALL wires must be removed
474 Handle(GEOM_Function) aFunction, aLastFunction = theObject->GetLastFunction();
475 if (aLastFunction.IsNull()) return NULL; //There is no function which creates an object to be processed
478 Handle(GEOM_Object) aNewObject = GetEngine()->AddObject( GetDocID(), GEOM_COPY );
481 aFunction = aNewObject->AddFunction(GEOMImpl_HealingDriver::GetID(), REMOVE_INT_WIRES);
483 if (aFunction.IsNull()) return NULL;
485 //Check if the function is set correctly
486 if (aFunction->GetDriverGUID() != GEOMImpl_HealingDriver::GetID()) return NULL;
488 // prepare "data container" class IHealing
489 GEOMImpl_IHealing HI(aFunction);
490 HI.SetWires( theWires );
491 HI.SetOriginal( aLastFunction );
493 //Compute the translation
495 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
498 if (!GetSolver()->ComputeFunction(aFunction))
500 SetErrorCode("Healing driver failed");
504 catch (Standard_Failure)
506 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
507 SetErrorCode(aFail->GetMessageString());
511 //Make a Python command
512 GEOM::TPythonDump pd (aFunction);
513 pd << aNewObject << " = geompy.SuppressInternalWires(" << theObject << ", [";
516 if (!theWires.IsNull()) {
517 int i = theWires->Lower(), nb = theWires->Upper();
518 for ( ; i <= nb; i++)
519 pd << theWires->Value( i ) << (( i < nb ) ? ", " : "])");
528 //=============================================================================
532 //=============================================================================
533 Handle(GEOM_Object) GEOMImpl_IHealingOperations::FillHoles (Handle(GEOM_Object) theObject,
534 const Handle(TColStd_HArray1OfInteger)& theWires)
536 // set error code, check parameters
539 if (theObject.IsNull()) // if theWires is NULL it's OK, it means that ALL holes must be removed
542 Handle(GEOM_Function) aFunction, aLastFunction = theObject->GetLastFunction();
543 if (aLastFunction.IsNull()) return NULL; //There is no function which creates an object to be processed
546 Handle(GEOM_Object) aNewObject = GetEngine()->AddObject( GetDocID(), GEOM_COPY );
549 aFunction = aNewObject->AddFunction(GEOMImpl_HealingDriver::GetID(), FILL_HOLES);
551 if (aFunction.IsNull()) return NULL;
553 //Check if the function is set correctly
554 if (aFunction->GetDriverGUID() != GEOMImpl_HealingDriver::GetID()) return NULL;
556 // prepare "data container" class IHealing
557 GEOMImpl_IHealing HI(aFunction);
558 HI.SetWires( theWires );
559 HI.SetOriginal( aLastFunction );
561 //Compute the translation
563 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
566 if (!GetSolver()->ComputeFunction(aFunction))
568 SetErrorCode("Healing driver failed");
572 catch (Standard_Failure)
574 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
575 SetErrorCode(aFail->GetMessageString());
579 //Make a Python command
580 GEOM::TPythonDump pd (aFunction);
581 pd << aNewObject << " = geompy.SuppressHoles(" << theObject << ", [";
584 if ( theWires.IsNull() )
587 int i = theWires->Lower(), nb = theWires->Upper();
588 for ( ; i <= nb; i++)
589 pd << theWires->Value( i ) << (( i < nb ) ? ", " : "])");
596 //=============================================================================
600 //=============================================================================
601 Handle(GEOM_Object) GEOMImpl_IHealingOperations::Sew (Handle(GEOM_Object) theObject,
604 // set error code, check parameters
607 if (theObject.IsNull())
610 Handle(GEOM_Function) aFunction, aLastFunction = theObject->GetLastFunction();
611 if (aLastFunction.IsNull()) return NULL; //There is no function which creates an object to be processed
614 Handle(GEOM_Object) aNewObject = GetEngine()->AddObject( GetDocID(), GEOM_COPY );
617 aFunction = aNewObject->AddFunction(GEOMImpl_HealingDriver::GetID(), SEWING);
619 if (aFunction.IsNull()) return NULL;
621 //Check if the function is set correctly
622 if (aFunction->GetDriverGUID() != GEOMImpl_HealingDriver::GetID()) return NULL;
624 // prepare "data container" class IHealing
625 GEOMImpl_IHealing HI(aFunction);
626 HI.SetTolerance( theTolerance );
627 HI.SetOriginal( aLastFunction );
629 //Compute the translation
631 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
634 if (!GetSolver()->ComputeFunction(aFunction))
636 SetErrorCode("Healing driver failed");
640 catch (Standard_Failure)
642 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
643 SetErrorCode(aFail->GetMessageString());
647 //Make a Python command
648 GEOM::TPythonDump(aFunction) << aNewObject << " = geompy.Sew("
649 << theObject << ", " << theTolerance << ")";
655 //=============================================================================
659 //=============================================================================
660 Handle(GEOM_Object) GEOMImpl_IHealingOperations::DivideEdge (Handle(GEOM_Object) theObject,
665 // set error code, check parameters
668 if (theObject.IsNull())
671 Handle(GEOM_Function) aFunction, aLastFunction = theObject->GetLastFunction();
672 if (aLastFunction.IsNull()) return NULL; //There is no function which creates an object to be processed
675 Handle(GEOM_Object) aNewObject = GetEngine()->AddObject( GetDocID(), GEOM_COPY );
678 aFunction = aNewObject->AddFunction(GEOMImpl_HealingDriver::GetID(), DIVIDE_EDGE);
680 if (aFunction.IsNull()) return NULL;
682 //Check if the function is set correctly
683 if (aFunction->GetDriverGUID() != GEOMImpl_HealingDriver::GetID()) return NULL;
685 // prepare "data container" class IHealing
686 GEOMImpl_IHealing HI(aFunction);
687 HI.SetIndex( theIndex );
688 HI.SetDevideEdgeValue( theValue );
689 HI.SetIsByParameter( isByParameter );
690 HI.SetOriginal( aLastFunction );
692 //Compute the translation
694 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
697 if (!GetSolver()->ComputeFunction(aFunction))
699 SetErrorCode("Healing driver failed");
703 catch (Standard_Failure)
705 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
706 SetErrorCode(aFail->GetMessageString());
710 //Make a Python command
711 GEOM::TPythonDump(aFunction) << aNewObject << " = geompy.DivideEdge(" << theObject
712 << ", " << theIndex << ", " << theValue << ", " << (int)isByParameter << ")";
718 //=============================================================================
722 //=============================================================================
723 bool GEOMImpl_IHealingOperations::GetFreeBoundary (Handle(GEOM_Object) theObject,
724 Handle(TColStd_HSequenceOfTransient)& theClosed,
725 Handle(TColStd_HSequenceOfTransient)& theOpen )
727 // set error code, check parameters
730 if ( theObject.IsNull() || theClosed.IsNull() || theOpen.IsNull() )
733 TopoDS_Shape aShape = theObject->GetValue();
734 if ( aShape.IsNull() )
737 // get free boundary shapes
739 #ifdef OCCT_6_3_0_sp_9
740 ShapeAnalysis_FreeBounds anAnalizer(aShape, Standard_False,
741 Standard_True, Standard_True);
743 ShapeAnalysis_FreeBounds anAnalizer(aShape);
745 TopoDS_Compound aClosed = anAnalizer.GetClosedWires();
746 TopoDS_Compound anOpen = anAnalizer.GetOpenWires();
748 // iterate through shapes and append them to the return sequence
749 Handle(GEOM_Object) anObj;
750 Handle(GEOM_Function) aFunction;
751 TopExp_Explorer anExp;
752 for ( anExp.Init( aClosed, 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 theClosed->Append(anObj);
760 for ( anExp.Init( anOpen, TopAbs_WIRE ); anExp.More(); anExp.Next() )
762 anObj = GetEngine()->AddObject( GetDocID(), GEOM_FREE_BOUNDS );
763 aFunction = anObj->AddFunction( GEOMImpl_CopyDriver::GetID(), COPY_WITHOUT_REF );
764 TopoDS_Shape aValueShape = anExp.Current();
765 aFunction->SetValue( aValueShape );
766 theOpen->Append(anObj);
769 if(!aFunction.IsNull()) {
771 //Make a Python command
772 GEOM::TPythonDump pd (aFunction);
774 Standard_Integer i, aLen = theClosed->Length();
777 for (i = 1; i <= aLen; i++) {
778 Handle(GEOM_Object) anObj_i = Handle(GEOM_Object)::DownCast(theClosed->Value(i));
779 pd << anObj_i << ((i < aLen) ? ", " : "");
783 pd << "(isDone, empty_list, ";
786 aLen = theOpen->Length();
789 for (i = 1; i <= aLen; i++) {
790 Handle(GEOM_Object) anObj_i = Handle(GEOM_Object)::DownCast(theOpen->Value(i));
791 pd << anObj_i << ((i < aLen) ? ", " : "");
798 pd << ") = geompy.GetFreeBoundary(" << theObject << ")";
806 //=============================================================================
810 //=============================================================================
811 Handle(GEOM_Object) GEOMImpl_IHealingOperations::ChangeOrientation (Handle(GEOM_Object) theObject)
813 // set error code, check parameters
816 if (theObject.IsNull())
819 if (!theObject->IsMainShape()) {
820 SetErrorCode("Sub shape cannot be transformed - need to create a copy");
824 Handle(GEOM_Function) aFunction, aLastFunction = theObject->GetLastFunction();
825 if (aLastFunction.IsNull())
826 return NULL; //There is no function which creates an object to be processed
829 aFunction = theObject->AddFunction(GEOMImpl_HealingDriver::GetID(), CHANGE_ORIENTATION);
831 if (aFunction.IsNull())
834 //Check if the function is set correctly
835 if (aFunction->GetDriverGUID() != GEOMImpl_HealingDriver::GetID()) return NULL;
837 // prepare "data container" class IHealing
838 GEOMImpl_IHealing HI(aFunction);
839 HI.SetOriginal( aLastFunction );
841 //Compute the translation
843 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
846 if (!GetSolver()->ComputeFunction(aFunction)) {
847 SetErrorCode("Healing driver failed");
851 catch (Standard_Failure) {
852 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
853 SetErrorCode(aFail->GetMessageString());
857 //Make a Python command
858 GEOM::TPythonDump(aFunction) << "geompy.ChangeOrientationShell("
866 //=============================================================================
868 * ChangeOrientationCopy
870 //=============================================================================
871 Handle(GEOM_Object) GEOMImpl_IHealingOperations::ChangeOrientationCopy (Handle(GEOM_Object) theObject)
873 // set error code, check parameters
876 if (theObject.IsNull())
879 Handle(GEOM_Function) aFunction, aLastFunction = theObject->GetLastFunction();
880 if (aLastFunction.IsNull())
881 return NULL; //There is no function which creates an object to be processed
884 Handle(GEOM_Object) aNewObject = GetEngine()->AddObject( GetDocID(), theObject->GetType() );
887 aFunction = aNewObject->AddFunction(GEOMImpl_HealingDriver::GetID(), CHANGE_ORIENTATION);
889 if (aFunction.IsNull())
892 //Check if the function is set correctly
893 if (aFunction->GetDriverGUID() != GEOMImpl_HealingDriver::GetID()) return NULL;
895 // prepare "data container" class IHealing
896 GEOMImpl_IHealing HI(aFunction);
897 HI.SetOriginal( aLastFunction );
899 //Compute the translation
901 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
904 if (!GetSolver()->ComputeFunction(aFunction)) {
905 SetErrorCode("Healing driver failed");
909 catch (Standard_Failure) {
910 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
911 SetErrorCode(aFail->GetMessageString());
915 //Make a Python command
916 GEOM::TPythonDump(aFunction) << aNewObject << " = geompy.ChangeOrientationShellCopy("